UNPKG

6.51 kBJavaScriptView Raw
1module.exports =
2/******/ (function(modules) { // webpackBootstrap
3/******/ // The module cache
4/******/ var installedModules = {};
5
6/******/ // The require function
7/******/ function __webpack_require__(moduleId) {
8
9/******/ // Check if module is in cache
10/******/ if(installedModules[moduleId])
11/******/ return installedModules[moduleId].exports;
12
13/******/ // Create a new module (and put it into the cache)
14/******/ var module = installedModules[moduleId] = {
15/******/ exports: {},
16/******/ id: moduleId,
17/******/ loaded: false
18/******/ };
19
20/******/ // Execute the module function
21/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
22
23/******/ // Flag the module as loaded
24/******/ module.loaded = true;
25
26/******/ // Return the exports of the module
27/******/ return module.exports;
28/******/ }
29
30
31/******/ // expose the modules object (__webpack_modules__)
32/******/ __webpack_require__.m = modules;
33
34/******/ // expose the module cache
35/******/ __webpack_require__.c = installedModules;
36
37/******/ // __webpack_public_path__
38/******/ __webpack_require__.p = "";
39
40/******/ // Load entry module and return exports
41/******/ return __webpack_require__(0);
42/******/ })
43/************************************************************************/
44/******/ ([
45/* 0 */
46/***/ function(module, exports, __webpack_require__) {
47
48 "use strict";
49
50 Object.defineProperty(exports, "__esModule", {
51 value: true
52 });
53 exports.default = install;
54
55 var _createFormatter = __webpack_require__(1);
56
57 var _createFormatter2 = _interopRequireDefault(_createFormatter);
58
59 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
60
61 function _typeof(obj) { return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj; }
62
63 var installed = false;
64
65 // Check for globally defined Immutable and add an install method to it.
66 if (typeof Immutable !== "undefined") {
67 Immutable.installDevTools = install.bind(null, Immutable);
68 }
69
70 // I imagine most people are using Immutable as a CommonJS module though...
71
72 function install(Immutable) {
73
74 if ((typeof window === "undefined" ? "undefined" : _typeof(window)) === undefined) {
75 throw new Error("Can only install immutable-devtools in a browser environment.");
76 }
77
78 // Don't install more than once.
79 if (installed === true) {
80 return;
81 }
82
83 window.devtoolsFormatters = window.devtoolsFormatters || [];
84
85 window.devtoolsFormatters.push((0, _createFormatter2.default)(Immutable));
86
87 installed = true;
88 }
89
90/***/ },
91/* 1 */
92/***/ function(module, exports) {
93
94 "use strict";
95
96 Object.defineProperty(exports, "__esModule", {
97 value: true
98 });
99 exports.default = createFormatter;
100
101 function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } else { return Array.from(arr); } }
102
103 var listStyle = { style: "list-style-type: none; padding: 0; margin: 0 0 0 12px" };
104 var keyStyle = { style: "color:#881391" };
105
106 function createFormatter(Immutable) {
107
108 function reference(any, config) {
109 return ["object", { object: any, config: config }];
110 }
111
112 var stop = {}; // Signals formatter to stop infinite recursion
113
114 var defaultFormatter = {
115 header: function header(x, config) {
116 if (config === stop) return null;
117 return reference(x, stop);
118 },
119 hasBody: function hasBody(x, config) {
120 return false;
121 },
122 body: function body(x, config) {
123 return null;
124 }
125 };
126
127 function notEmpty(collection) {
128 return collection.size > 0;
129 }
130
131 function keySpan(key) {
132 return ["span", keyStyle, key + ": "];
133 }
134
135 function displayKeyValueList(collection) {
136 var children = collection.map(function (value, key) {
137 return ["li", keySpan(key), reference(value)];
138 }).toList().toJS();
139 return ["ol", listStyle].concat(_toConsumableArray(children));
140 }
141
142 var mapFormatter = {
143 header: function header() {
144 return ["span", "Map"];
145 },
146
147 hasBody: notEmpty,
148 body: displayKeyValueList
149 };
150
151 var orderedMapFormatter = {
152 header: function header() {
153 return ["span", "OrderedMap"];
154 },
155
156 hasBody: notEmpty,
157 body: displayKeyValueList
158 };
159
160 var listFormatter = {
161 header: function header() {
162 return ["span", "List"];
163 },
164
165 hasBody: notEmpty,
166 body: displayKeyValueList
167 };
168
169 function setBody(set) {
170 var children = set.map(function (item) {
171 return ["li", reference(item)];
172 }).toJS();
173 return ["ol", listStyle].concat(_toConsumableArray(children));
174 }
175
176 var stackFormatter = {
177 header: function header() {
178 return ["span", "Stack"];
179 },
180
181 hasBody: notEmpty,
182 body: setBody
183 };
184
185 var setFormatter = {
186 header: function header() {
187 return ["span", "Set"];
188 },
189
190 hasBody: notEmpty,
191 body: setBody
192 };
193
194 var orderedSetFormatter = {
195 header: function header() {
196 return ["span", "OrderedSet"];
197 },
198
199 hasBody: notEmpty,
200 body: setBody
201 };
202
203 var recordFormatter = {
204 header: function header() {
205 return ["span", "Record"];
206 },
207
208 hasBody: notEmpty,
209 body: function body(record) {
210 var children = record.keySeq().map(function (key) {
211 return ["li", keySpan(key), reference(record.get(key))];
212 }).toJS();
213 return ["ol", listStyle].concat(_toConsumableArray(children));
214 }
215 };
216
217 var immutableFormatters = {
218 List: listFormatter,
219 Map: mapFormatter,
220 OrderedMap: orderedMapFormatter,
221 Set: setFormatter,
222 OrderedSet: orderedSetFormatter,
223 Stack: stackFormatter
224 };
225
226 function getFormatter(any) {
227 if (any instanceof Immutable.Record) return recordFormatter;
228 return Object.keys(immutableFormatters).filter(function (type) {
229 return Immutable[type]["is" + type](any);
230 }).map(function (type) {
231 return immutableFormatters[type];
232 }).concat(defaultFormatter) // Fallback used when not immutable value
233 [0];
234 }
235
236 return {
237 header: function header(any, config) {
238 return getFormatter(any).header(any, config);
239 },
240 hasBody: function hasBody(any, config) {
241 return getFormatter(any).hasBody(any, config);
242 },
243 body: function body(any, config) {
244 return getFormatter(any).body(any, config);
245 }
246 };
247 }
248
249/***/ }
250/******/ ]);
\No newline at end of file