-
Notifications
You must be signed in to change notification settings - Fork 1
/
json-formatter.js
executable file
·450 lines (448 loc) · 33.8 KB
/
json-formatter.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
// This file is derived from https://github.com/mohsen1/json-formatter-js, which uses the following license:
//
// The MIT License (MIT)
//
// Copyright (c) 2015 Mohsen Azimi
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
!function(root, factory) {
"object" == typeof exports && "object" == typeof module ? module.exports = factory() : "function" == typeof define && define.amd ? define("JSONFormatter", [], factory) : "object" == typeof exports ? exports.JSONFormatter = factory() : root.JSONFormatter = factory();
}(this, function() {
return function(modules) {
function __webpack_require__(moduleId) {
if (installedModules[moduleId]) return installedModules[moduleId].exports;
var module = installedModules[moduleId] = {
i: moduleId,
l: !1,
exports: {}
};
return modules[moduleId].call(module.exports, module, module.exports, __webpack_require__),
module.l = !0, module.exports;
}
var installedModules = {};
return __webpack_require__.m = modules, __webpack_require__.c = installedModules,
__webpack_require__.i = function(value) {
return value;
}, __webpack_require__.d = function(exports, name, getter) {
__webpack_require__.o(exports, name) || Object.defineProperty(exports, name, {
configurable: !1,
enumerable: !0,
get: getter
});
}, __webpack_require__.n = function(module) {
var getter = module && module.__esModule ? function() {
return module.default;
} : function() {
return module;
};
return __webpack_require__.d(getter, "a", getter), getter;
}, __webpack_require__.o = function(object, property) {
return Object.prototype.hasOwnProperty.call(object, property);
}, __webpack_require__.p = "dist", __webpack_require__(__webpack_require__.s = 6);
}([ function(module, __webpack_exports__, __webpack_require__) {
"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", {
value: !0
});
var __WEBPACK_IMPORTED_MODULE_0__helpers__ = __webpack_require__(5), __WEBPACK_IMPORTED_MODULE_1__style_less__ = __webpack_require__(4), DATE_STRING_REGEX = (__webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1__style_less__),
/(^\d{1,4}[\.|\\\/|-]\d{1,2}[\.|\\\/|-]\d{1,4})(\s*(?:0?[1-9]:[0-5]|1(?=[012])\d:[0-5])\d\s*[ap]m)?$/), PARTIAL_DATE_REGEX = /\d{2}:\d{2}:\d{2} GMT-\d{4}/, JSON_DATE_REGEX = /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/, requestAnimationFrame = window.requestAnimationFrame || function(cb) {
return cb(), 0;
}, _defaultConfig = {
hoverPreviewEnabled: !1,
hoverPreviewArrayCount: 100,
hoverPreviewFieldCount: 5,
animateOpen: !0,
animateClose: !0,
theme: null,
useToJSON: !0,
sortPropertiesBy: null,
pathsToCollapse: []
}, JSONFormatter = function() {
function JSONFormatter(json, open, config, key, path) {
void 0 === open && (open = 1), void 0 === config && (config = _defaultConfig), void 0 === path && (path = ""),
this.json = json, this.open = open, this.config = config, this.key = key, this.path = path,
this._isOpen = null, void 0 === this.config.hoverPreviewEnabled && (this.config.hoverPreviewEnabled = _defaultConfig.hoverPreviewEnabled),
void 0 === this.config.hoverPreviewArrayCount && (this.config.hoverPreviewArrayCount = _defaultConfig.hoverPreviewArrayCount),
void 0 === this.config.hoverPreviewFieldCount && (this.config.hoverPreviewFieldCount = _defaultConfig.hoverPreviewFieldCount),
void 0 === this.config.useToJSON && (this.config.useToJSON = _defaultConfig.useToJSON),
void 0 === this.config.pathsToCollapse && (this.config.pathsToCollapse = _defaultConfig.pathsToCollapse);
}
return Object.defineProperty(JSONFormatter.prototype, "isOpen", {
get: function() {
return null !== this._isOpen ? this._isOpen : this.open > 0;
},
set: function(value) {
this._isOpen = value;
},
enumerable: !0,
configurable: !0
}), Object.defineProperty(JSONFormatter.prototype, "isDate", {
get: function() {
return this.json instanceof Date || "string" === this.type && (DATE_STRING_REGEX.test(this.json) || JSON_DATE_REGEX.test(this.json) || PARTIAL_DATE_REGEX.test(this.json));
},
enumerable: !0,
configurable: !0
}), Object.defineProperty(JSONFormatter.prototype, "isUrl", {
get: function() {
return "string" === this.type && 0 === this.json.indexOf("http");
},
enumerable: !0,
configurable: !0
}), Object.defineProperty(JSONFormatter.prototype, "isArray", {
get: function() {
return Array.isArray(this.json);
},
enumerable: !0,
configurable: !0
}), Object.defineProperty(JSONFormatter.prototype, "isObject", {
get: function() {
return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.a)(this.json);
},
enumerable: !0,
configurable: !0
}), Object.defineProperty(JSONFormatter.prototype, "isEmptyObject", {
get: function() {
return !this.keys.length && !this.isArray;
},
enumerable: !0,
configurable: !0
}), Object.defineProperty(JSONFormatter.prototype, "isEmpty", {
get: function() {
return this.isEmptyObject || this.keys && !this.keys.length && this.isArray;
},
enumerable: !0,
configurable: !0
}), Object.defineProperty(JSONFormatter.prototype, "useToJSON", {
get: function() {
return this.config.useToJSON && "stringifiable" === this.type;
},
enumerable: !0,
configurable: !0
}), Object.defineProperty(JSONFormatter.prototype, "hasKey", {
get: function() {
return void 0 !== this.key;
},
enumerable: !0,
configurable: !0
}), Object.defineProperty(JSONFormatter.prototype, "constructorName", {
get: function() {
return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.b)(this.json);
},
enumerable: !0,
configurable: !0
}), Object.defineProperty(JSONFormatter.prototype, "type", {
get: function() {
return null === this.json ? "null" : this.config.useToJSON && this.json && this.json.toJSON ? "stringifiable" : typeof this.json;
},
enumerable: !0,
configurable: !0
}), Object.defineProperty(JSONFormatter.prototype, "keys", {
get: function() {
if (this.isObject) {
var keys = Object.keys(this.json).map(function(key) {
return key || '""';
});
return !this.isArray && this.config.sortPropertiesBy ? keys.sort(this.config.sortPropertiesBy) : keys;
}
return [];
},
enumerable: !0,
configurable: !0
}), JSONFormatter.prototype.toggleOpen = function() {
this.isOpen = !this.isOpen, this.element && (this.isOpen ? this.appendChildren(this.config.animateOpen) : this.removeChildren(this.config.animateClose),
this.element.classList.toggle(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.c)("open")));
}, JSONFormatter.prototype.openAtDepth = function(depth) {
void 0 === depth && (depth = 1), depth < 0 || (this.open = depth, this.isOpen = 0 !== depth,
this.element && (this.removeChildren(!1), 0 === depth ? this.element.classList.remove(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.c)("open")) : (this.appendChildren(this.config.animateOpen),
this.element.classList.add(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.c)("open")))));
}, JSONFormatter.prototype.getInlinepreview = function() {
var _this = this;
if (this.isArray) return this.json.length > this.config.hoverPreviewArrayCount ? "Array[" + this.json.length + "]" : "[" + this.json.map(__WEBPACK_IMPORTED_MODULE_0__helpers__.d).join(", ") + "]";
var keys = this.keys, narrowKeys = keys.slice(0, this.config.hoverPreviewFieldCount), kvs = narrowKeys.map(function(key) {
return key + ":" + __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.d)(_this.type, _this.json[key]);
}), ellipsis = keys.length >= this.config.hoverPreviewFieldCount ? "…" : "";
return "{" + kvs.join(", ") + ellipsis + "}";
}, JSONFormatter.prototype.render = function() {
this.element = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.e)("div", "row");
var togglerLink = this.isObject ? __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.e)("a", "toggler-link") : __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.e)("span");
if (this.isObject && !this.useToJSON && togglerLink.appendChild(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.e)("span", "toggler")),
this.hasKey && togglerLink.appendChild(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.e)("span", "key", this.key + ":")),
this.isObject && !this.useToJSON) {
var value = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.e)("span", "value"), objectWrapperSpan = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.e)("span"), constructorName = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.e)("span", "constructor-name", this.constructorName);
if (objectWrapperSpan.appendChild(constructorName), this.isArray) {
var arrayWrapperSpan = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.e)("span");
arrayWrapperSpan.appendChild(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.e)("span", "bracket", "[")),
arrayWrapperSpan.appendChild(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.e)("span", "number", this.json.length)),
arrayWrapperSpan.appendChild(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.e)("span", "bracket", "]")),
objectWrapperSpan.appendChild(arrayWrapperSpan);
}
value.appendChild(objectWrapperSpan), togglerLink.appendChild(value);
} else {
var value = this.isUrl ? __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.e)("a") : __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.e)("span");
value.classList.add(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.c)(this.type)),
this.isDate && value.classList.add(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.c)("date")),
this.isUrl && (value.classList.add(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.c)("url")),
value.setAttribute("href", this.json));
var valuePreview = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.f)(this.type, this.json, this.useToJSON ? this.json.toJSON() : this.json);
value.appendChild(document.createTextNode(valuePreview)), togglerLink.appendChild(value);
}
if (this.isObject && this.config.hoverPreviewEnabled) {
var preview = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.e)("span", "preview-text");
preview.appendChild(document.createTextNode(this.getInlinepreview())), togglerLink.appendChild(preview);
}
var children = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.e)("div", "children");
return this.isObject && children.classList.add(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.c)("object")),
this.isArray && children.classList.add(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.c)("array")),
this.isEmpty && children.classList.add(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.c)("empty")),
this.config && this.config.theme && this.element.classList.add(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.c)(this.config.theme)),
this.isOpen && this.element.classList.add(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.c)("open")),
this.element.appendChild(togglerLink), this.element.appendChild(children), this.isObject && this.isOpen && this.appendChildren(),
this.isObject && !this.useToJSON && togglerLink.addEventListener("click", this.toggleOpen.bind(this)),
this.element;
}, JSONFormatter.prototype.appendChildren = function(animated) {
var _this = this;
void 0 === animated && (animated = !1);
var children = this.element.querySelector("div." + __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.c)("children"));
if (children && !this.isEmpty) if (animated) {
var index_1 = 0, addAChild_1 = function() {
var key = _this.keys[index_1], formatter = new JSONFormatter(_this.json[key], _this.open - 1, _this.config, key);
children.appendChild(formatter.render()), (index_1 += 1) < _this.keys.length && (index_1 > 10 ? addAChild_1() : requestAnimationFrame(addAChild_1));
};
requestAnimationFrame(addAChild_1);
} else this.keys.forEach(function(key) {
var updatedPath = (_this.path.length > 0 ? _this.path + "." : "") + key, isOpen = _this.config.pathsToCollapse.includes(updatedPath) ? 0 : _this.open - 1, formatter = new JSONFormatter(_this.json[key], isOpen, _this.config, key, updatedPath);
children.appendChild(formatter.render());
});
}, JSONFormatter.prototype.removeChildren = function(animated) {
void 0 === animated && (animated = !1);
var childrenElement = this.element.querySelector("div." + __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.c)("children"));
if (animated) {
var childrenRemoved_1 = 0, removeAChild_1 = function() {
childrenElement && childrenElement.children.length && (childrenElement.removeChild(childrenElement.children[0]),
childrenRemoved_1 += 1, childrenRemoved_1 > 10 ? removeAChild_1() : requestAnimationFrame(removeAChild_1));
};
requestAnimationFrame(removeAChild_1);
} else childrenElement && (childrenElement.innerHTML = "");
}, JSONFormatter;
}();
__webpack_exports__.default = JSONFormatter;
}, function(module, exports, __webpack_require__) {
exports = module.exports = __webpack_require__(2)(), exports.push([ module.i, '.json-formatter-row {\n font-family: monospace;\n}\n.json-formatter-row,\n.json-formatter-row a,\n.json-formatter-row a:hover {\n color: black;\n text-decoration: none;\n}\n.json-formatter-row .json-formatter-row {\n margin-left: 1rem;\n}\n.json-formatter-row .json-formatter-children.json-formatter-empty {\n opacity: 0.5;\n margin-left: 1rem;\n}\n.json-formatter-row .json-formatter-children.json-formatter-empty:after {\n display: none;\n}\n.json-formatter-row .json-formatter-children.json-formatter-empty.json-formatter-object:after {\n content: "No properties";\n}\n.json-formatter-row .json-formatter-children.json-formatter-empty.json-formatter-array:after {\n content: "[]";\n}\n.json-formatter-row .json-formatter-string,\n.json-formatter-row .json-formatter-stringifiable {\n color: green;\n white-space: pre-wrap;\n word-wrap: break-word;\n}\n.json-formatter-row .json-formatter-number {\n color: blue;\n}\n.json-formatter-row .json-formatter-boolean {\n color: red;\n}\n.json-formatter-row .json-formatter-null {\n color: #855A00;\n}\n.json-formatter-row .json-formatter-undefined {\n color: #ca0b69;\n}\n.json-formatter-row .json-formatter-function {\n color: #FF20ED;\n}\n.json-formatter-row .json-formatter-date {\n background-color: rgba(0, 0, 0, 0.05);\n}\n.json-formatter-row .json-formatter-url {\n text-decoration: underline;\n color: blue;\n cursor: pointer;\n}\n.json-formatter-row .json-formatter-bracket {\n color: blue;\n}\n.json-formatter-row .json-formatter-key {\n color: #00008B;\n padding-right: 0.2rem;\n}\n.json-formatter-row .json-formatter-toggler-link {\n cursor: pointer;\n}\n.json-formatter-row .json-formatter-toggler {\n line-height: 1.2rem;\n font-size: 0.7rem;\n vertical-align: middle;\n opacity: 0.6;\n cursor: pointer;\n padding-right: 0.2rem;\n}\n.json-formatter-row .json-formatter-toggler:after {\n display: inline-block;\n transition: transform 100ms ease-in;\n content: "\\25BA";\n}\n.json-formatter-row > a > .json-formatter-preview-text {\n opacity: 0;\n transition: opacity 0.15s ease-in;\n font-style: italic;\n}\n.json-formatter-row:hover > a > .json-formatter-preview-text {\n opacity: 0.6;\n}\n.json-formatter-row.json-formatter-open > .json-formatter-toggler-link .json-formatter-toggler:after {\n transform: rotate(90deg);\n}\n.json-formatter-row.json-formatter-open > .json-formatter-children:after {\n display: inline-block;\n}\n.json-formatter-row.json-formatter-open > a > .json-formatter-preview-text {\n display: none;\n}\n.json-formatter-row.json-formatter-open.json-formatter-empty:after {\n display: block;\n}\n.json-formatter-dark.json-formatter-row {\n font-family: monospace;\n}\n.json-formatter-dark.json-formatter-row,\n.json-formatter-dark.json-formatter-row a,\n.json-formatter-dark.json-formatter-row a:hover {\n color: white;\n text-decoration: none;\n}\n.json-formatter-dark.json-formatter-row .json-formatter-row {\n margin-left: 1rem;\n}\n.json-formatter-dark.json-formatter-row .json-formatter-children.json-formatter-empty {\n opacity: 0.5;\n margin-left: 1rem;\n}\n.json-formatter-dark.json-formatter-row .json-formatter-children.json-formatter-empty:after {\n display: none;\n}\n.json-formatter-dark.json-formatter-row .json-formatter-children.json-formatter-empty.json-formatter-object:after {\n content: "No properties";\n}\n.json-formatter-dark.json-formatter-row .json-formatter-children.json-formatter-empty.json-formatter-array:after {\n content: "[]";\n}\n.json-formatter-dark.json-formatter-row .json-formatter-string,\n.json-formatter-dark.json-formatter-row .json-formatter-stringifiable {\n color: #31F031;\n white-space: pre-wrap;\n word-wrap: break-word;\n}\n.json-formatter-dark.json-formatter-row .json-formatter-number {\n color: #66C2FF;\n}\n.json-formatter-dark.json-formatter-row .json-formatter-boolean {\n color: #EC4242;\n}\n.json-formatter-dark.json-formatter-row .json-formatter-null {\n color: #EEC97D;\n}\n.json-formatter-dark.json-formatter-row .json-formatter-undefined {\n color: #ef8fbe;\n}\n.json-formatter-dark.json-formatter-row .json-formatter-function {\n color: #FD48CB;\n}\n.json-formatter-dark.json-formatter-row .json-formatter-date {\n background-color: rgba(255, 255, 255, 0.05);\n}\n.json-formatter-dark.json-formatter-row .json-formatter-url {\n text-decoration: underline;\n color: #027BFF;\n cursor: pointer;\n}\n.json-formatter-dark.json-formatter-row .json-formatter-bracket {\n color: #9494FF;\n}\n.json-formatter-dark.json-formatter-row .json-formatter-key {\n color: #23A0DB;\n padding-right: 0.2rem;\n}\n.json-formatter-dark.json-formatter-row .json-formatter-toggler-link {\n cursor: pointer;\n}\n.json-formatter-dark.json-formatter-row .json-formatter-toggler {\n line-height: 1.2rem;\n font-size: 0.7rem;\n vertical-align: middle;\n opacity: 0.6;\n cursor: pointer;\n padding-right: 0.2rem;\n}\n.json-formatter-dark.json-formatter-row .json-formatter-toggler:after {\n display: inline-block;\n transition: transform 100ms ease-in;\n content: "\\25BA";\n}\n.json-formatter-dark.json-formatter-row > a > .json-formatter-preview-text {\n opacity: 0;\n transition: opacity 0.15s ease-in;\n font-style: italic;\n}\n.json-formatter-dark.json-formatter-row:hover > a > .json-formatter-preview-text {\n opacity: 0.6;\n}\n.json-formatter-dark.json-formatter-row.json-formatter-open > .json-formatter-toggler-link .json-formatter-toggler:after {\n transform: rotate(90deg);\n}\n.json-formatter-dark.json-formatter-row.json-formatter-open > .json-formatter-children:after {\n display: inline-block;\n}\n.json-formatter-dark.json-formatter-row.json-formatter-open > a > .json-formatter-preview-text {\n display: none;\n}\n.json-formatter-dark.json-formatter-row.json-formatter-open.json-formatter-empty:after {\n display: block;\n}\n', "" ]);
}, function(module, exports) {
module.exports = function() {
var list = [];
return list.toString = function() {
for (var result = [], i = 0; i < this.length; i++) {
var item = this[i];
item[2] ? result.push("@media " + item[2] + "{" + item[1] + "}") : result.push(item[1]);
}
return result.join("");
}, list.i = function(modules, mediaQuery) {
"string" == typeof modules && (modules = [ [ null, modules, "" ] ]);
for (var alreadyImportedModules = {}, i = 0; i < this.length; i++) {
var id = this[i][0];
"number" == typeof id && (alreadyImportedModules[id] = !0);
}
for (i = 0; i < modules.length; i++) {
var item = modules[i];
"number" == typeof item[0] && alreadyImportedModules[item[0]] || (mediaQuery && !item[2] ? item[2] = mediaQuery : mediaQuery && (item[2] = "(" + item[2] + ") and (" + mediaQuery + ")"),
list.push(item));
}
}, list;
};
}, function(module, exports) {
function addStylesToDom(styles, options) {
for (var i = 0; i < styles.length; i++) {
var item = styles[i], domStyle = stylesInDom[item.id];
if (domStyle) {
domStyle.refs++;
for (var j = 0; j < domStyle.parts.length; j++) domStyle.parts[j](item.parts[j]);
for (;j < item.parts.length; j++) domStyle.parts.push(addStyle(item.parts[j], options));
} else {
for (var parts = [], j = 0; j < item.parts.length; j++) parts.push(addStyle(item.parts[j], options));
stylesInDom[item.id] = {
id: item.id,
refs: 1,
parts: parts
};
}
}
}
function listToStyles(list) {
for (var styles = [], newStyles = {}, i = 0; i < list.length; i++) {
var item = list[i], id = item[0], css = item[1], media = item[2], sourceMap = item[3], part = {
css: css,
media: media,
sourceMap: sourceMap
};
newStyles[id] ? newStyles[id].parts.push(part) : styles.push(newStyles[id] = {
id: id,
parts: [ part ]
});
}
return styles;
}
function insertStyleElement(options, styleElement) {
var head = getHeadElement(), lastStyleElementInsertedAtTop = styleElementsInsertedAtTop[styleElementsInsertedAtTop.length - 1];
if ("top" === options.insertAt) lastStyleElementInsertedAtTop ? lastStyleElementInsertedAtTop.nextSibling ? head.insertBefore(styleElement, lastStyleElementInsertedAtTop.nextSibling) : head.appendChild(styleElement) : head.insertBefore(styleElement, head.firstChild),
styleElementsInsertedAtTop.push(styleElement); else {
if ("bottom" !== options.insertAt) throw new Error("Invalid value for parameter 'insertAt'. Must be 'top' or 'bottom'.");
head.appendChild(styleElement);
}
}
function removeStyleElement(styleElement) {
styleElement.parentNode.removeChild(styleElement);
var idx = styleElementsInsertedAtTop.indexOf(styleElement);
idx >= 0 && styleElementsInsertedAtTop.splice(idx, 1);
}
function createStyleElement(options) {
var styleElement = document.createElement("style");
return styleElement.type = "text/css", insertStyleElement(options, styleElement),
styleElement;
}
function createLinkElement(options) {
var linkElement = document.createElement("link");
return linkElement.rel = "stylesheet", insertStyleElement(options, linkElement),
linkElement;
}
function addStyle(obj, options) {
var styleElement, update, remove;
if (options.singleton) {
var styleIndex = singletonCounter++;
styleElement = singletonElement || (singletonElement = createStyleElement(options)),
update = applyToSingletonTag.bind(null, styleElement, styleIndex, !1), remove = applyToSingletonTag.bind(null, styleElement, styleIndex, !0);
} else obj.sourceMap && "function" == typeof URL && "function" == typeof URL.createObjectURL && "function" == typeof URL.revokeObjectURL && "function" == typeof Blob && "function" == typeof btoa ? (styleElement = createLinkElement(options),
update = updateLink.bind(null, styleElement), remove = function() {
removeStyleElement(styleElement), styleElement.href && URL.revokeObjectURL(styleElement.href);
}) : (styleElement = createStyleElement(options), update = applyToTag.bind(null, styleElement),
remove = function() {
removeStyleElement(styleElement);
});
return update(obj), function(newObj) {
if (newObj) {
if (newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap) return;
update(obj = newObj);
} else remove();
};
}
function applyToSingletonTag(styleElement, index, remove, obj) {
var css = remove ? "" : obj.css;
if (styleElement.styleSheet) styleElement.styleSheet.cssText = replaceText(index, css); else {
var cssNode = document.createTextNode(css), childNodes = styleElement.childNodes;
childNodes[index] && styleElement.removeChild(childNodes[index]), childNodes.length ? styleElement.insertBefore(cssNode, childNodes[index]) : styleElement.appendChild(cssNode);
}
}
function applyToTag(styleElement, obj) {
var css = obj.css, media = obj.media;
if (media && styleElement.setAttribute("media", media), styleElement.styleSheet) styleElement.styleSheet.cssText = css; else {
for (;styleElement.firstChild; ) styleElement.removeChild(styleElement.firstChild);
styleElement.appendChild(document.createTextNode(css));
}
}
function updateLink(linkElement, obj) {
var css = obj.css, sourceMap = obj.sourceMap;
sourceMap && (css += "\n/*# sourceMappingURL=data:application/json;base64," + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + " */");
var blob = new Blob([ css ], {
type: "text/css"
}), oldSrc = linkElement.href;
linkElement.href = URL.createObjectURL(blob), oldSrc && URL.revokeObjectURL(oldSrc);
}
var stylesInDom = {}, memoize = function(fn) {
var memo;
return function() {
return void 0 === memo && (memo = fn.apply(this, arguments)), memo;
};
}, isOldIE = memoize(function() {
return /msie [6-9]\b/.test(self.navigator.userAgent.toLowerCase());
}), getHeadElement = memoize(function() {
return document.head || document.getElementsByTagName("head")[0];
}), singletonElement = null, singletonCounter = 0, styleElementsInsertedAtTop = [];
module.exports = function(list, options) {
if ("undefined" != typeof DEBUG && DEBUG && "object" != typeof document) throw new Error("The style-loader cannot be used in a non-browser environment");
options = options || {}, void 0 === options.singleton && (options.singleton = isOldIE()),
void 0 === options.insertAt && (options.insertAt = "bottom");
var styles = listToStyles(list);
return addStylesToDom(styles, options), function(newList) {
for (var mayRemove = [], i = 0; i < styles.length; i++) {
var item = styles[i], domStyle = stylesInDom[item.id];
domStyle.refs--, mayRemove.push(domStyle);
}
if (newList) {
addStylesToDom(listToStyles(newList), options);
}
for (var i = 0; i < mayRemove.length; i++) {
var domStyle = mayRemove[i];
if (0 === domStyle.refs) {
for (var j = 0; j < domStyle.parts.length; j++) domStyle.parts[j]();
delete stylesInDom[domStyle.id];
}
}
};
};
var replaceText = function() {
var textStore = [];
return function(index, replacement) {
return textStore[index] = replacement, textStore.filter(Boolean).join("\n");
};
}();
}, function(module, exports, __webpack_require__) {
var content = __webpack_require__(1);
"string" == typeof content && (content = [ [ module.i, content, "" ] ]);
__webpack_require__(3)(content, {});
content.locals && (module.exports = content.locals);
}, function(module, __webpack_exports__, __webpack_require__) {
"use strict";
function escapeString(str) {
return str.replace(/"/g, '\\"');
}
function isObject(value) {
var type = typeof value;
return !!value && "object" == type;
}
function getObjectName(object) {
if (void 0 === object) return "";
if (null === object) return "Object";
if ("object" == typeof object && !object.constructor) return "Object";
var funcNameRegex = /function ([^(]*)/, results = funcNameRegex.exec(object.constructor.toString());
return results && results.length > 1 ? results[1] : "";
}
function getValuePreview(type, object, value) {
return "null" === type || "undefined" === type ? type : ("string" !== type && "stringifiable" !== type || (value = '"' + escapeString(value) + '"'),
"function" === type ? object.toString().replace(/[\r\n]/g, "").replace(/\{.*\}/, "") + "{…}" : value);
}
function getPreview(type, object) {
var value = "";
return isObject(object) ? (value = getObjectName(object), Array.isArray(object) && (value += "[" + object.length + "]")) : value = getValuePreview(type, object, object),
value;
}
function cssClass(className) {
return "json-formatter-" + className;
}
function createElement(type, className, content) {
var el = document.createElement(type);
return className && el.classList.add(cssClass(className)), void 0 !== content && (content instanceof Node ? el.appendChild(content) : el.appendChild(document.createTextNode(String(content)))),
el;
}
__webpack_exports__.a = isObject, __webpack_exports__.b = getObjectName, __webpack_exports__.f = getValuePreview,
__webpack_exports__.d = getPreview, __webpack_exports__.c = cssClass, __webpack_exports__.e = createElement;
}, function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(0);
} ]);
});
//# sourceMappingURL=json-formatter.js.map