json-formatter.js 29 KB

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