json-formatter.js 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  1. module.exports = function(modules) {
  2. function __webpack_require__(moduleId) {
  3. if (installedModules[moduleId]) return installedModules[moduleId].exports;
  4. var module = installedModules[moduleId] = {
  5. i: moduleId,
  6. l: !1,
  7. exports: {}
  8. };
  9. return modules[moduleId].call(module.exports, module, module.exports, __webpack_require__),
  10. module.l = !0, module.exports;
  11. }
  12. var installedModules = {};
  13. return __webpack_require__.m = modules, __webpack_require__.c = installedModules,
  14. __webpack_require__.i = function(value) {
  15. return value;
  16. }, __webpack_require__.d = function(exports, name, getter) {
  17. __webpack_require__.o(exports, name) || Object.defineProperty(exports, name, {
  18. configurable: !1,
  19. enumerable: !0,
  20. get: getter
  21. });
  22. }, __webpack_require__.n = function(module) {
  23. var getter = module && module.__esModule ? function() {
  24. return module.default;
  25. } : function() {
  26. return module;
  27. };
  28. return __webpack_require__.d(getter, "a", getter), getter;
  29. }, __webpack_require__.o = function(object, property) {
  30. return Object.prototype.hasOwnProperty.call(object, property);
  31. }, __webpack_require__.p = "dist", __webpack_require__(__webpack_require__.s = 6);
  32. }([ function(module, __webpack_exports__, __webpack_require__) {
  33. "use strict";
  34. Object.defineProperty(__webpack_exports__, "__esModule", {
  35. value: !0
  36. });
  37. 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__),
  38. /(^\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) {
  39. return cb(), 0;
  40. }, _defaultConfig = {
  41. hoverPreviewEnabled: !1,
  42. hoverPreviewArrayCount: 100,
  43. hoverPreviewFieldCount: 5,
  44. animateOpen: !0,
  45. animateClose: !0,
  46. theme: null,
  47. useToJSON: !0,
  48. sortPropertiesBy: null
  49. }, JSONFormatter = function() {
  50. function JSONFormatter(json, open, config, key) {
  51. void 0 === open && (open = 1), void 0 === config && (config = _defaultConfig), this.json = json,
  52. this.open = open, this.config = config, this.key = key, this._isOpen = null, void 0 === this.config.hoverPreviewEnabled && (this.config.hoverPreviewEnabled = _defaultConfig.hoverPreviewEnabled),
  53. void 0 === this.config.hoverPreviewArrayCount && (this.config.hoverPreviewArrayCount = _defaultConfig.hoverPreviewArrayCount),
  54. void 0 === this.config.hoverPreviewFieldCount && (this.config.hoverPreviewFieldCount = _defaultConfig.hoverPreviewFieldCount),
  55. void 0 === this.config.useToJSON && (this.config.useToJSON = _defaultConfig.useToJSON);
  56. }
  57. return Object.defineProperty(JSONFormatter.prototype, "isOpen", {
  58. get: function() {
  59. return null !== this._isOpen ? this._isOpen : this.open > 0;
  60. },
  61. set: function(value) {
  62. this._isOpen = value;
  63. },
  64. enumerable: !0,
  65. configurable: !0
  66. }), Object.defineProperty(JSONFormatter.prototype, "isDate", {
  67. get: function() {
  68. 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));
  69. },
  70. enumerable: !0,
  71. configurable: !0
  72. }), Object.defineProperty(JSONFormatter.prototype, "isUrl", {
  73. get: function() {
  74. return "string" === this.type && 0 === this.json.indexOf("http");
  75. },
  76. enumerable: !0,
  77. configurable: !0
  78. }), Object.defineProperty(JSONFormatter.prototype, "isArray", {
  79. get: function() {
  80. return Array.isArray(this.json);
  81. },
  82. enumerable: !0,
  83. configurable: !0
  84. }), Object.defineProperty(JSONFormatter.prototype, "isObject", {
  85. get: function() {
  86. return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.a)(this.json);
  87. },
  88. enumerable: !0,
  89. configurable: !0
  90. }), Object.defineProperty(JSONFormatter.prototype, "isEmptyObject", {
  91. get: function() {
  92. return !this.keys.length && !this.isArray;
  93. },
  94. enumerable: !0,
  95. configurable: !0
  96. }), Object.defineProperty(JSONFormatter.prototype, "isEmpty", {
  97. get: function() {
  98. return this.isEmptyObject || this.keys && !this.keys.length && this.isArray;
  99. },
  100. enumerable: !0,
  101. configurable: !0
  102. }), Object.defineProperty(JSONFormatter.prototype, "useToJSON", {
  103. get: function() {
  104. return this.config.useToJSON && "stringifiable" === this.type;
  105. },
  106. enumerable: !0,
  107. configurable: !0
  108. }), Object.defineProperty(JSONFormatter.prototype, "hasKey", {
  109. get: function() {
  110. return void 0 !== this.key;
  111. },
  112. enumerable: !0,
  113. configurable: !0
  114. }), Object.defineProperty(JSONFormatter.prototype, "constructorName", {
  115. get: function() {
  116. return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.b)(this.json);
  117. },
  118. enumerable: !0,
  119. configurable: !0
  120. }), Object.defineProperty(JSONFormatter.prototype, "type", {
  121. get: function() {
  122. return null === this.json ? "null" : this.config.useToJSON && this.json && this.json.toJSON ? "stringifiable" : typeof this.json;
  123. },
  124. enumerable: !0,
  125. configurable: !0
  126. }), Object.defineProperty(JSONFormatter.prototype, "keys", {
  127. get: function() {
  128. if (this.isObject) {
  129. var keys = Object.keys(this.json).map(function(key) {
  130. return key || '""';
  131. });
  132. return !this.isArray && this.config.sortPropertiesBy ? keys.sort(this.config.sortPropertiesBy) : keys;
  133. }
  134. return [];
  135. },
  136. enumerable: !0,
  137. configurable: !0
  138. }), JSONFormatter.prototype.toggleOpen = function() {
  139. this.isOpen = !this.isOpen, this.element && (this.isOpen ? this.appendChildren(this.config.animateOpen) : this.removeChildren(this.config.animateClose),
  140. this.element.classList.toggle(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.c)("open")));
  141. }, JSONFormatter.prototype.openAtDepth = function(depth) {
  142. void 0 === depth && (depth = 1), depth < 0 || (this.open = depth, this.isOpen = 0 !== depth,
  143. 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),
  144. this.element.classList.add(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.c)("open")))));
  145. }, JSONFormatter.prototype.getInlinepreview = function() {
  146. var _this = this;
  147. if (this.isArray) return this.json.length > this.config.hoverPreviewArrayCount ? "Array[" + this.json.length + "]" : "[" + this.json.map(__WEBPACK_IMPORTED_MODULE_0__helpers__.d).join(", ") + "]";
  148. var keys = this.keys, narrowKeys = keys.slice(0, this.config.hoverPreviewFieldCount), kvs = narrowKeys.map(function(key) {
  149. return key + ":" + __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.d)(_this.type, _this.json[key]);
  150. }), ellipsis = keys.length >= this.config.hoverPreviewFieldCount ? "…" : "";
  151. return "{" + kvs.join(", ") + ellipsis + "}";
  152. }, JSONFormatter.prototype.render = function() {
  153. this.element = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.e)("div", "row");
  154. 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");
  155. if (this.isObject && !this.useToJSON && togglerLink.appendChild(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.e)("span", "toggler")),
  156. this.hasKey && togglerLink.appendChild(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.e)("span", "key", this.key + ":")),
  157. this.isObject && !this.useToJSON) {
  158. 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);
  159. if (objectWrapperSpan.appendChild(constructorName), this.isArray) {
  160. var arrayWrapperSpan = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.e)("span");
  161. arrayWrapperSpan.appendChild(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.e)("span", "bracket", "[")),
  162. arrayWrapperSpan.appendChild(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.e)("span", "number", this.json.length)),
  163. arrayWrapperSpan.appendChild(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.e)("span", "bracket", "]")),
  164. objectWrapperSpan.appendChild(arrayWrapperSpan);
  165. }
  166. value.appendChild(objectWrapperSpan), togglerLink.appendChild(value);
  167. } else {
  168. var value = this.isUrl ? __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.e)("a") : __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.e)("span");
  169. value.classList.add(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.c)(this.type)),
  170. this.isDate && value.classList.add(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.c)("date")),
  171. this.isUrl && (value.classList.add(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.c)("url")),
  172. value.setAttribute("href", this.json));
  173. var valuePreview = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.f)(this.type, this.json, this.useToJSON ? this.json.toJSON() : this.json);
  174. value.appendChild(document.createTextNode(valuePreview)), togglerLink.appendChild(value);
  175. }
  176. if (this.isObject && this.config.hoverPreviewEnabled) {
  177. var preview = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.e)("span", "preview-text");
  178. preview.appendChild(document.createTextNode(this.getInlinepreview())), togglerLink.appendChild(preview);
  179. }
  180. var children = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.e)("div", "children");
  181. return this.isObject && children.classList.add(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.c)("object")),
  182. this.isArray && children.classList.add(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.c)("array")),
  183. this.isEmpty && children.classList.add(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.c)("empty")),
  184. this.config && this.config.theme && this.element.classList.add(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.c)(this.config.theme)),
  185. this.isOpen && this.element.classList.add(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.c)("open")),
  186. this.element.appendChild(togglerLink), this.element.appendChild(children), this.isObject && this.isOpen && this.appendChildren(),
  187. this.isObject && !this.useToJSON && togglerLink.addEventListener("click", this.toggleOpen.bind(this)),
  188. this.element;
  189. }, JSONFormatter.prototype.appendChildren = function(animated) {
  190. var _this = this;
  191. void 0 === animated && (animated = !1);
  192. var children = this.element.querySelector("div." + __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.c)("children"));
  193. if (children && !this.isEmpty) if (animated) {
  194. var index_1 = 0, addAChild_1 = function() {
  195. var key = _this.keys[index_1], formatter = new JSONFormatter(_this.json[key], _this.open - 1, _this.config, key);
  196. children.appendChild(formatter.render()), (index_1 += 1) < _this.keys.length && (index_1 > 10 ? addAChild_1() : requestAnimationFrame(addAChild_1));
  197. };
  198. requestAnimationFrame(addAChild_1);
  199. } else this.keys.forEach(function(key) {
  200. var formatter = new JSONFormatter(_this.json[key], _this.open - 1, _this.config, key);
  201. children.appendChild(formatter.render());
  202. });
  203. }, JSONFormatter.prototype.removeChildren = function(animated) {
  204. void 0 === animated && (animated = !1);
  205. var childrenElement = this.element.querySelector("div." + __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.c)("children"));
  206. if (animated) {
  207. var childrenRemoved_1 = 0, removeAChild_1 = function() {
  208. childrenElement && childrenElement.children.length && (childrenElement.removeChild(childrenElement.children[0]),
  209. childrenRemoved_1 += 1, childrenRemoved_1 > 10 ? removeAChild_1() : requestAnimationFrame(removeAChild_1));
  210. };
  211. requestAnimationFrame(removeAChild_1);
  212. } else childrenElement && (childrenElement.innerHTML = "");
  213. }, JSONFormatter;
  214. }();
  215. __webpack_exports__.default = JSONFormatter;
  216. }, function(module, exports, __webpack_require__) {
  217. 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;\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;\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', "" ]);
  218. }, function(module, exports) {
  219. module.exports = function() {
  220. var list = [];
  221. return list.toString = function() {
  222. for (var result = [], i = 0; i < this.length; i++) {
  223. var item = this[i];
  224. item[2] ? result.push("@media " + item[2] + "{" + item[1] + "}") : result.push(item[1]);
  225. }
  226. return result.join("");
  227. }, list.i = function(modules, mediaQuery) {
  228. "string" == typeof modules && (modules = [ [ null, modules, "" ] ]);
  229. for (var alreadyImportedModules = {}, i = 0; i < this.length; i++) {
  230. var id = this[i][0];
  231. "number" == typeof id && (alreadyImportedModules[id] = !0);
  232. }
  233. for (i = 0; i < modules.length; i++) {
  234. var item = modules[i];
  235. "number" == typeof item[0] && alreadyImportedModules[item[0]] || (mediaQuery && !item[2] ? item[2] = mediaQuery : mediaQuery && (item[2] = "(" + item[2] + ") and (" + mediaQuery + ")"),
  236. list.push(item));
  237. }
  238. }, list;
  239. };
  240. }, function(module, exports) {
  241. function addStylesToDom(styles, options) {
  242. for (var i = 0; i < styles.length; i++) {
  243. var item = styles[i], domStyle = stylesInDom[item.id];
  244. if (domStyle) {
  245. domStyle.refs++;
  246. for (var j = 0; j < domStyle.parts.length; j++) domStyle.parts[j](item.parts[j]);
  247. for (;j < item.parts.length; j++) domStyle.parts.push(addStyle(item.parts[j], options));
  248. } else {
  249. for (var parts = [], j = 0; j < item.parts.length; j++) parts.push(addStyle(item.parts[j], options));
  250. stylesInDom[item.id] = {
  251. id: item.id,
  252. refs: 1,
  253. parts: parts
  254. };
  255. }
  256. }
  257. }
  258. function listToStyles(list) {
  259. for (var styles = [], newStyles = {}, i = 0; i < list.length; i++) {
  260. var item = list[i], id = item[0], css = item[1], media = item[2], sourceMap = item[3], part = {
  261. css: css,
  262. media: media,
  263. sourceMap: sourceMap
  264. };
  265. newStyles[id] ? newStyles[id].parts.push(part) : styles.push(newStyles[id] = {
  266. id: id,
  267. parts: [ part ]
  268. });
  269. }
  270. return styles;
  271. }
  272. function insertStyleElement(options, styleElement) {
  273. var head = getHeadElement(), lastStyleElementInsertedAtTop = styleElementsInsertedAtTop[styleElementsInsertedAtTop.length - 1];
  274. if ("top" === options.insertAt) lastStyleElementInsertedAtTop ? lastStyleElementInsertedAtTop.nextSibling ? head.insertBefore(styleElement, lastStyleElementInsertedAtTop.nextSibling) : head.appendChild(styleElement) : head.insertBefore(styleElement, head.firstChild),
  275. styleElementsInsertedAtTop.push(styleElement); else {
  276. if ("bottom" !== options.insertAt) throw new Error("Invalid value for parameter 'insertAt'. Must be 'top' or 'bottom'.");
  277. head.appendChild(styleElement);
  278. }
  279. }
  280. function removeStyleElement(styleElement) {
  281. styleElement.parentNode.removeChild(styleElement);
  282. var idx = styleElementsInsertedAtTop.indexOf(styleElement);
  283. idx >= 0 && styleElementsInsertedAtTop.splice(idx, 1);
  284. }
  285. function createStyleElement(options) {
  286. var styleElement = document.createElement("style");
  287. return styleElement.type = "text/css", insertStyleElement(options, styleElement),
  288. styleElement;
  289. }
  290. function createLinkElement(options) {
  291. var linkElement = document.createElement("link");
  292. return linkElement.rel = "stylesheet", insertStyleElement(options, linkElement),
  293. linkElement;
  294. }
  295. function addStyle(obj, options) {
  296. var styleElement, update, remove;
  297. if (options.singleton) {
  298. var styleIndex = singletonCounter++;
  299. styleElement = singletonElement || (singletonElement = createStyleElement(options)),
  300. update = applyToSingletonTag.bind(null, styleElement, styleIndex, !1), remove = applyToSingletonTag.bind(null, styleElement, styleIndex, !0);
  301. } else obj.sourceMap && "function" == typeof URL && "function" == typeof URL.createObjectURL && "function" == typeof URL.revokeObjectURL && "function" == typeof Blob && "function" == typeof btoa ? (styleElement = createLinkElement(options),
  302. update = updateLink.bind(null, styleElement), remove = function() {
  303. removeStyleElement(styleElement), styleElement.href && URL.revokeObjectURL(styleElement.href);
  304. }) : (styleElement = createStyleElement(options), update = applyToTag.bind(null, styleElement),
  305. remove = function() {
  306. removeStyleElement(styleElement);
  307. });
  308. return update(obj), function(newObj) {
  309. if (newObj) {
  310. if (newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap) return;
  311. update(obj = newObj);
  312. } else remove();
  313. };
  314. }
  315. function applyToSingletonTag(styleElement, index, remove, obj) {
  316. var css = remove ? "" : obj.css;
  317. if (styleElement.styleSheet) styleElement.styleSheet.cssText = replaceText(index, css); else {
  318. var cssNode = document.createTextNode(css), childNodes = styleElement.childNodes;
  319. childNodes[index] && styleElement.removeChild(childNodes[index]), childNodes.length ? styleElement.insertBefore(cssNode, childNodes[index]) : styleElement.appendChild(cssNode);
  320. }
  321. }
  322. function applyToTag(styleElement, obj) {
  323. var css = obj.css, media = obj.media;
  324. if (media && styleElement.setAttribute("media", media), styleElement.styleSheet) styleElement.styleSheet.cssText = css; else {
  325. for (;styleElement.firstChild; ) styleElement.removeChild(styleElement.firstChild);
  326. styleElement.appendChild(document.createTextNode(css));
  327. }
  328. }
  329. function updateLink(linkElement, obj) {
  330. var css = obj.css, sourceMap = obj.sourceMap;
  331. sourceMap && (css += "\n/*# sourceMappingURL=data:application/json;base64," + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + " */");
  332. var blob = new Blob([ css ], {
  333. type: "text/css"
  334. }), oldSrc = linkElement.href;
  335. linkElement.href = URL.createObjectURL(blob), oldSrc && URL.revokeObjectURL(oldSrc);
  336. }
  337. var stylesInDom = {}, memoize = function(fn) {
  338. var memo;
  339. return function() {
  340. return void 0 === memo && (memo = fn.apply(this, arguments)), memo;
  341. };
  342. }, isOldIE = memoize(function() {
  343. return /msie [6-9]\b/.test(self.navigator.userAgent.toLowerCase());
  344. }), getHeadElement = memoize(function() {
  345. return document.head || document.getElementsByTagName("head")[0];
  346. }), singletonElement = null, singletonCounter = 0, styleElementsInsertedAtTop = [];
  347. module.exports = function(list, options) {
  348. if ("undefined" != typeof DEBUG && DEBUG && "object" != typeof document) throw new Error("The style-loader cannot be used in a non-browser environment");
  349. options = options || {}, void 0 === options.singleton && (options.singleton = isOldIE()),
  350. void 0 === options.insertAt && (options.insertAt = "bottom");
  351. var styles = listToStyles(list);
  352. return addStylesToDom(styles, options), function(newList) {
  353. for (var mayRemove = [], i = 0; i < styles.length; i++) {
  354. var item = styles[i], domStyle = stylesInDom[item.id];
  355. domStyle.refs--, mayRemove.push(domStyle);
  356. }
  357. if (newList) {
  358. addStylesToDom(listToStyles(newList), options);
  359. }
  360. for (var i = 0; i < mayRemove.length; i++) {
  361. var domStyle = mayRemove[i];
  362. if (0 === domStyle.refs) {
  363. for (var j = 0; j < domStyle.parts.length; j++) domStyle.parts[j]();
  364. delete stylesInDom[domStyle.id];
  365. }
  366. }
  367. };
  368. };
  369. var replaceText = function() {
  370. var textStore = [];
  371. return function(index, replacement) {
  372. return textStore[index] = replacement, textStore.filter(Boolean).join("\n");
  373. };
  374. }();
  375. }, function(module, exports, __webpack_require__) {
  376. var content = __webpack_require__(1);
  377. "string" == typeof content && (content = [ [ module.i, content, "" ] ]);
  378. __webpack_require__(3)(content, {});
  379. content.locals && (module.exports = content.locals);
  380. }, function(module, __webpack_exports__, __webpack_require__) {
  381. "use strict";
  382. function escapeString(str) {
  383. return str.replace('"', '"');
  384. }
  385. function isObject(value) {
  386. var type = typeof value;
  387. return !!value && "object" == type;
  388. }
  389. function getObjectName(object) {
  390. if (void 0 === object) return "";
  391. if (null === object) return "Object";
  392. if ("object" == typeof object && !object.constructor) return "Object";
  393. var funcNameRegex = /function ([^(]*)/, results = funcNameRegex.exec(object.constructor.toString());
  394. return results && results.length > 1 ? results[1] : "";
  395. }
  396. function getValuePreview(type, object, value) {
  397. return "null" === type || "undefined" === type ? type : ("string" !== type && "stringifiable" !== type || (value = '"' + escapeString(value) + '"'),
  398. "function" === type ? object.toString().replace(/[\r\n]/g, "").replace(/\{.*\}/, "") + "{…}" : value);
  399. }
  400. function getPreview(type, object) {
  401. var value = "";
  402. return isObject(object) ? (value = getObjectName(object), Array.isArray(object) && (value += "[" + object.length + "]")) : value = getValuePreview(type, object, object),
  403. value;
  404. }
  405. function cssClass(className) {
  406. return "json-formatter-" + className;
  407. }
  408. function createElement(type, className, content) {
  409. var el = document.createElement(type);
  410. return className && el.classList.add(cssClass(className)), void 0 !== content && (content instanceof Node ? el.appendChild(content) : el.appendChild(document.createTextNode(String(content)))),
  411. el;
  412. }
  413. __webpack_exports__.a = isObject, __webpack_exports__.b = getObjectName, __webpack_exports__.f = getValuePreview,
  414. __webpack_exports__.d = getPreview, __webpack_exports__.c = cssClass, __webpack_exports__.e = createElement;
  415. }, function(module, exports, __webpack_require__) {
  416. module.exports = __webpack_require__(0);
  417. } ]);
  418. //# sourceMappingURL=json-formatter.js.map