index.js 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575
  1. /******/ (function(modules) { // webpackBootstrap
  2. /******/ // The module cache
  3. /******/ var installedModules = {};
  4. /******/
  5. /******/ // The require function
  6. /******/ function __webpack_require__(moduleId) {
  7. /******/
  8. /******/ // Check if module is in cache
  9. /******/ if(installedModules[moduleId])
  10. /******/ return installedModules[moduleId].exports;
  11. /******/
  12. /******/ // Create a new module (and put it into the cache)
  13. /******/ var module = installedModules[moduleId] = {
  14. /******/ i: moduleId,
  15. /******/ l: false,
  16. /******/ exports: {}
  17. /******/ };
  18. /******/
  19. /******/ // Execute the module function
  20. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  21. /******/
  22. /******/ // Flag the module as loaded
  23. /******/ module.l = true;
  24. /******/
  25. /******/ // Return the exports of the module
  26. /******/ return module.exports;
  27. /******/ }
  28. /******/
  29. /******/
  30. /******/ // expose the modules object (__webpack_modules__)
  31. /******/ __webpack_require__.m = modules;
  32. /******/
  33. /******/ // expose the module cache
  34. /******/ __webpack_require__.c = installedModules;
  35. /******/
  36. /******/ // identity function for calling harmony imports with the correct context
  37. /******/ __webpack_require__.i = function(value) { return value; };
  38. /******/
  39. /******/ // define getter function for harmony exports
  40. /******/ __webpack_require__.d = function(exports, name, getter) {
  41. /******/ if(!__webpack_require__.o(exports, name)) {
  42. /******/ Object.defineProperty(exports, name, {
  43. /******/ configurable: false,
  44. /******/ enumerable: true,
  45. /******/ get: getter
  46. /******/ });
  47. /******/ }
  48. /******/ };
  49. /******/
  50. /******/ // getDefaultExport function for compatibility with non-harmony modules
  51. /******/ __webpack_require__.n = function(module) {
  52. /******/ var getter = module && module.__esModule ?
  53. /******/ function getDefault() { return module['default']; } :
  54. /******/ function getModuleExports() { return module; };
  55. /******/ __webpack_require__.d(getter, 'a', getter);
  56. /******/ return getter;
  57. /******/ };
  58. /******/
  59. /******/ // Object.prototype.hasOwnProperty.call
  60. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  61. /******/
  62. /******/ // __webpack_public_path__
  63. /******/ __webpack_require__.p = "";
  64. /******/
  65. /******/ // Load entry module and return exports
  66. /******/ return __webpack_require__(__webpack_require__.s = 1);
  67. /******/ })
  68. /************************************************************************/
  69. /******/ ([
  70. /* 0 */
  71. /***/ (function(module, exports) {
  72. module.exports = function(modules) {
  73. function __webpack_require__(moduleId) {
  74. if (installedModules[moduleId]) return installedModules[moduleId].exports;
  75. var module = installedModules[moduleId] = {
  76. i: moduleId,
  77. l: !1,
  78. exports: {}
  79. };
  80. return modules[moduleId].call(module.exports, module, module.exports, __webpack_require__),
  81. module.l = !0, module.exports;
  82. }
  83. var installedModules = {};
  84. return __webpack_require__.m = modules, __webpack_require__.c = installedModules,
  85. __webpack_require__.i = function(value) {
  86. return value;
  87. }, __webpack_require__.d = function(exports, name, getter) {
  88. __webpack_require__.o(exports, name) || Object.defineProperty(exports, name, {
  89. configurable: !1,
  90. enumerable: !0,
  91. get: getter
  92. });
  93. }, __webpack_require__.n = function(module) {
  94. var getter = module && module.__esModule ? function() {
  95. return module.default;
  96. } : function() {
  97. return module;
  98. };
  99. return __webpack_require__.d(getter, "a", getter), getter;
  100. }, __webpack_require__.o = function(object, property) {
  101. return Object.prototype.hasOwnProperty.call(object, property);
  102. }, __webpack_require__.p = "dist", __webpack_require__(__webpack_require__.s = 6);
  103. }([ function(module, __webpack_exports__, __webpack_require__) {
  104. "use strict";
  105. Object.defineProperty(__webpack_exports__, "__esModule", {
  106. value: !0
  107. });
  108. 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__),
  109. /(^\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) {
  110. return cb(), 0;
  111. }, _defaultConfig = {
  112. hoverPreviewEnabled: !1,
  113. hoverPreviewArrayCount: 100,
  114. hoverPreviewFieldCount: 5,
  115. animateOpen: !0,
  116. animateClose: !0,
  117. theme: null
  118. }, JSONFormatter = function() {
  119. function JSONFormatter(json, open, config, key) {
  120. void 0 === open && (open = 1), void 0 === config && (config = _defaultConfig), this.json = json,
  121. this.open = open, this.config = config, this.key = key, this._isOpen = null, void 0 === this.config.hoverPreviewEnabled && (this.config.hoverPreviewEnabled = _defaultConfig.hoverPreviewEnabled),
  122. void 0 === this.config.hoverPreviewArrayCount && (this.config.hoverPreviewArrayCount = _defaultConfig.hoverPreviewArrayCount),
  123. void 0 === this.config.hoverPreviewFieldCount && (this.config.hoverPreviewFieldCount = _defaultConfig.hoverPreviewFieldCount);
  124. }
  125. return Object.defineProperty(JSONFormatter.prototype, "isOpen", {
  126. get: function() {
  127. return null !== this._isOpen ? this._isOpen : this.open > 0;
  128. },
  129. set: function(value) {
  130. this._isOpen = value;
  131. },
  132. enumerable: !0,
  133. configurable: !0
  134. }), Object.defineProperty(JSONFormatter.prototype, "isDate", {
  135. get: function() {
  136. return "string" === this.type && (DATE_STRING_REGEX.test(this.json) || JSON_DATE_REGEX.test(this.json) || PARTIAL_DATE_REGEX.test(this.json));
  137. },
  138. enumerable: !0,
  139. configurable: !0
  140. }), Object.defineProperty(JSONFormatter.prototype, "isUrl", {
  141. get: function() {
  142. return "string" === this.type && 0 === this.json.indexOf("http");
  143. },
  144. enumerable: !0,
  145. configurable: !0
  146. }), Object.defineProperty(JSONFormatter.prototype, "isArray", {
  147. get: function() {
  148. return Array.isArray(this.json);
  149. },
  150. enumerable: !0,
  151. configurable: !0
  152. }), Object.defineProperty(JSONFormatter.prototype, "isObject", {
  153. get: function() {
  154. return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.a)(this.json);
  155. },
  156. enumerable: !0,
  157. configurable: !0
  158. }), Object.defineProperty(JSONFormatter.prototype, "isEmptyObject", {
  159. get: function() {
  160. return !this.keys.length && !this.isArray;
  161. },
  162. enumerable: !0,
  163. configurable: !0
  164. }), Object.defineProperty(JSONFormatter.prototype, "isEmpty", {
  165. get: function() {
  166. return this.isEmptyObject || this.keys && !this.keys.length && this.isArray;
  167. },
  168. enumerable: !0,
  169. configurable: !0
  170. }), Object.defineProperty(JSONFormatter.prototype, "hasKey", {
  171. get: function() {
  172. return void 0 !== this.key;
  173. },
  174. enumerable: !0,
  175. configurable: !0
  176. }), Object.defineProperty(JSONFormatter.prototype, "constructorName", {
  177. get: function() {
  178. return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.b)(this.json);
  179. },
  180. enumerable: !0,
  181. configurable: !0
  182. }), Object.defineProperty(JSONFormatter.prototype, "type", {
  183. get: function() {
  184. return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.c)(this.json);
  185. },
  186. enumerable: !0,
  187. configurable: !0
  188. }), Object.defineProperty(JSONFormatter.prototype, "keys", {
  189. get: function() {
  190. return this.isObject ? Object.keys(this.json).map(function(key) {
  191. return key || '""';
  192. }) : [];
  193. },
  194. enumerable: !0,
  195. configurable: !0
  196. }), JSONFormatter.prototype.toggleOpen = function() {
  197. this.isOpen = !this.isOpen, this.element && (this.isOpen ? this.appendChildren(this.config.animateOpen) : this.removeChildren(this.config.animateClose),
  198. this.element.classList.toggle(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.d)("open")));
  199. }, JSONFormatter.prototype.openAtDepth = function(depth) {
  200. void 0 === depth && (depth = 1), depth < 0 || (this.open = depth, this.isOpen = 0 !== depth,
  201. 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),
  202. this.element.classList.add(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.d)("open")))));
  203. }, JSONFormatter.prototype.getInlinepreview = function() {
  204. var _this = this;
  205. if (this.isArray) return this.json.length > this.config.hoverPreviewArrayCount ? "Array[" + this.json.length + "]" : "[" + this.json.map(__WEBPACK_IMPORTED_MODULE_0__helpers__.e).join(", ") + "]";
  206. var keys = this.keys, narrowKeys = keys.slice(0, this.config.hoverPreviewFieldCount), kvs = narrowKeys.map(function(key) {
  207. return key + ":" + __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.e)(_this.json[key]);
  208. }), ellipsis = keys.length >= this.config.hoverPreviewFieldCount ? "…" : "";
  209. return "{" + kvs.join(", ") + ellipsis + "}";
  210. }, JSONFormatter.prototype.render = function() {
  211. this.element = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.f)("div", "row");
  212. var togglerLink = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.f)("a", "toggler-link");
  213. if (this.isObject && togglerLink.appendChild(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.f)("span", "toggler")),
  214. this.hasKey && togglerLink.appendChild(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.f)("span", "key", this.key + ":")),
  215. this.isObject) {
  216. 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);
  217. if (objectWrapperSpan.appendChild(constructorName), this.isArray) {
  218. var arrayWrapperSpan = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.f)("span");
  219. arrayWrapperSpan.appendChild(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.f)("span", "bracket", "[")),
  220. arrayWrapperSpan.appendChild(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.f)("span", "number", this.json.length)),
  221. arrayWrapperSpan.appendChild(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.f)("span", "bracket", "]")),
  222. objectWrapperSpan.appendChild(arrayWrapperSpan);
  223. }
  224. value.appendChild(objectWrapperSpan), togglerLink.appendChild(value);
  225. } else {
  226. var value = this.isUrl ? __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.f)("a") : __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.f)("span");
  227. value.classList.add(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.d)(this.type)),
  228. this.isDate && value.classList.add(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.d)("date")),
  229. this.isUrl && (value.classList.add(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.d)("url")),
  230. value.setAttribute("href", this.json));
  231. var valuePreview = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.g)(this.json, this.json);
  232. value.appendChild(document.createTextNode(valuePreview)), togglerLink.appendChild(value);
  233. }
  234. if (this.isObject && this.config.hoverPreviewEnabled) {
  235. var preview = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.f)("span", "preview-text");
  236. preview.appendChild(document.createTextNode(this.getInlinepreview())), togglerLink.appendChild(preview);
  237. }
  238. var children = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.f)("div", "children");
  239. return this.isObject && children.classList.add(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.d)("object")),
  240. this.isArray && children.classList.add(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.d)("array")),
  241. this.isEmpty && children.classList.add(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.d)("empty")),
  242. this.config && this.config.theme && this.element.classList.add(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.d)(this.config.theme)),
  243. this.isOpen && this.element.classList.add(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.d)("open")),
  244. this.element.appendChild(togglerLink), this.element.appendChild(children), this.isObject && this.isOpen && this.appendChildren(),
  245. this.isObject && togglerLink.addEventListener("click", this.toggleOpen.bind(this)),
  246. this.element;
  247. }, JSONFormatter.prototype.appendChildren = function(animated) {
  248. var _this = this;
  249. void 0 === animated && (animated = !1);
  250. var children = this.element.querySelector("div." + __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.d)("children"));
  251. if (children && !this.isEmpty) if (animated) {
  252. var index_1 = 0, addAChild_1 = function() {
  253. var key = _this.keys[index_1], formatter = new JSONFormatter(_this.json[key], _this.open - 1, _this.config, key);
  254. children.appendChild(formatter.render()), (index_1 += 1) < _this.keys.length && (index_1 > 10 ? addAChild_1() : requestAnimationFrame(addAChild_1));
  255. };
  256. requestAnimationFrame(addAChild_1);
  257. } else this.keys.forEach(function(key) {
  258. var formatter = new JSONFormatter(_this.json[key], _this.open - 1, _this.config, key);
  259. children.appendChild(formatter.render());
  260. });
  261. }, JSONFormatter.prototype.removeChildren = function(animated) {
  262. void 0 === animated && (animated = !1);
  263. var childrenElement = this.element.querySelector("div." + __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__helpers__.d)("children"));
  264. if (animated) {
  265. var childrenRemoved_1 = 0, removeAChild_1 = function() {
  266. childrenElement && childrenElement.children.length && (childrenElement.removeChild(childrenElement.children[0]),
  267. childrenRemoved_1 += 1, childrenRemoved_1 > 10 ? removeAChild_1() : requestAnimationFrame(removeAChild_1));
  268. };
  269. requestAnimationFrame(removeAChild_1);
  270. } else childrenElement && (childrenElement.innerHTML = "");
  271. }, JSONFormatter;
  272. }();
  273. __webpack_exports__.default = JSONFormatter;
  274. }, function(module, exports, __webpack_require__) {
  275. 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', "" ]);
  276. }, function(module, exports) {
  277. module.exports = function() {
  278. var list = [];
  279. return list.toString = function() {
  280. for (var result = [], i = 0; i < this.length; i++) {
  281. var item = this[i];
  282. item[2] ? result.push("@media " + item[2] + "{" + item[1] + "}") : result.push(item[1]);
  283. }
  284. return result.join("");
  285. }, list.i = function(modules, mediaQuery) {
  286. "string" == typeof modules && (modules = [ [ null, modules, "" ] ]);
  287. for (var alreadyImportedModules = {}, i = 0; i < this.length; i++) {
  288. var id = this[i][0];
  289. "number" == typeof id && (alreadyImportedModules[id] = !0);
  290. }
  291. for (i = 0; i < modules.length; i++) {
  292. var item = modules[i];
  293. "number" == typeof item[0] && alreadyImportedModules[item[0]] || (mediaQuery && !item[2] ? item[2] = mediaQuery : mediaQuery && (item[2] = "(" + item[2] + ") and (" + mediaQuery + ")"),
  294. list.push(item));
  295. }
  296. }, list;
  297. };
  298. }, function(module, exports) {
  299. function addStylesToDom(styles, options) {
  300. for (var i = 0; i < styles.length; i++) {
  301. var item = styles[i], domStyle = stylesInDom[item.id];
  302. if (domStyle) {
  303. domStyle.refs++;
  304. for (var j = 0; j < domStyle.parts.length; j++) domStyle.parts[j](item.parts[j]);
  305. for (;j < item.parts.length; j++) domStyle.parts.push(addStyle(item.parts[j], options));
  306. } else {
  307. for (var parts = [], j = 0; j < item.parts.length; j++) parts.push(addStyle(item.parts[j], options));
  308. stylesInDom[item.id] = {
  309. id: item.id,
  310. refs: 1,
  311. parts: parts
  312. };
  313. }
  314. }
  315. }
  316. function listToStyles(list) {
  317. for (var styles = [], newStyles = {}, i = 0; i < list.length; i++) {
  318. var item = list[i], id = item[0], css = item[1], media = item[2], sourceMap = item[3], part = {
  319. css: css,
  320. media: media,
  321. sourceMap: sourceMap
  322. };
  323. newStyles[id] ? newStyles[id].parts.push(part) : styles.push(newStyles[id] = {
  324. id: id,
  325. parts: [ part ]
  326. });
  327. }
  328. return styles;
  329. }
  330. function insertStyleElement(options, styleElement) {
  331. var head = getHeadElement(), lastStyleElementInsertedAtTop = styleElementsInsertedAtTop[styleElementsInsertedAtTop.length - 1];
  332. if ("top" === options.insertAt) lastStyleElementInsertedAtTop ? lastStyleElementInsertedAtTop.nextSibling ? head.insertBefore(styleElement, lastStyleElementInsertedAtTop.nextSibling) : head.appendChild(styleElement) : head.insertBefore(styleElement, head.firstChild),
  333. styleElementsInsertedAtTop.push(styleElement); else {
  334. if ("bottom" !== options.insertAt) throw new Error("Invalid value for parameter 'insertAt'. Must be 'top' or 'bottom'.");
  335. head.appendChild(styleElement);
  336. }
  337. }
  338. function removeStyleElement(styleElement) {
  339. styleElement.parentNode.removeChild(styleElement);
  340. var idx = styleElementsInsertedAtTop.indexOf(styleElement);
  341. idx >= 0 && styleElementsInsertedAtTop.splice(idx, 1);
  342. }
  343. function createStyleElement(options) {
  344. var styleElement = document.createElement("style");
  345. return styleElement.type = "text/css", insertStyleElement(options, styleElement),
  346. styleElement;
  347. }
  348. function createLinkElement(options) {
  349. var linkElement = document.createElement("link");
  350. return linkElement.rel = "stylesheet", insertStyleElement(options, linkElement),
  351. linkElement;
  352. }
  353. function addStyle(obj, options) {
  354. var styleElement, update, remove;
  355. if (options.singleton) {
  356. var styleIndex = singletonCounter++;
  357. styleElement = singletonElement || (singletonElement = createStyleElement(options)),
  358. update = applyToSingletonTag.bind(null, styleElement, styleIndex, !1), remove = applyToSingletonTag.bind(null, styleElement, styleIndex, !0);
  359. } else obj.sourceMap && "function" == typeof URL && "function" == typeof URL.createObjectURL && "function" == typeof URL.revokeObjectURL && "function" == typeof Blob && "function" == typeof btoa ? (styleElement = createLinkElement(options),
  360. update = updateLink.bind(null, styleElement), remove = function() {
  361. removeStyleElement(styleElement), styleElement.href && URL.revokeObjectURL(styleElement.href);
  362. }) : (styleElement = createStyleElement(options), update = applyToTag.bind(null, styleElement),
  363. remove = function() {
  364. removeStyleElement(styleElement);
  365. });
  366. return update(obj), function(newObj) {
  367. if (newObj) {
  368. if (newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap) return;
  369. update(obj = newObj);
  370. } else remove();
  371. };
  372. }
  373. function applyToSingletonTag(styleElement, index, remove, obj) {
  374. var css = remove ? "" : obj.css;
  375. if (styleElement.styleSheet) styleElement.styleSheet.cssText = replaceText(index, css); else {
  376. var cssNode = document.createTextNode(css), childNodes = styleElement.childNodes;
  377. childNodes[index] && styleElement.removeChild(childNodes[index]), childNodes.length ? styleElement.insertBefore(cssNode, childNodes[index]) : styleElement.appendChild(cssNode);
  378. }
  379. }
  380. function applyToTag(styleElement, obj) {
  381. var css = obj.css, media = obj.media;
  382. if (media && styleElement.setAttribute("media", media), styleElement.styleSheet) styleElement.styleSheet.cssText = css; else {
  383. for (;styleElement.firstChild; ) styleElement.removeChild(styleElement.firstChild);
  384. styleElement.appendChild(document.createTextNode(css));
  385. }
  386. }
  387. function updateLink(linkElement, obj) {
  388. var css = obj.css, sourceMap = obj.sourceMap;
  389. sourceMap && (css += "\n/*# sourceMappingURL=data:application/json;base64," + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + " */");
  390. var blob = new Blob([ css ], {
  391. type: "text/css"
  392. }), oldSrc = linkElement.href;
  393. linkElement.href = URL.createObjectURL(blob), oldSrc && URL.revokeObjectURL(oldSrc);
  394. }
  395. var stylesInDom = {}, memoize = function(fn) {
  396. var memo;
  397. return function() {
  398. return void 0 === memo && (memo = fn.apply(this, arguments)), memo;
  399. };
  400. }, isOldIE = memoize(function() {
  401. return /msie [6-9]\b/.test(window.navigator.userAgent.toLowerCase());
  402. }), getHeadElement = memoize(function() {
  403. return document.head || document.getElementsByTagName("head")[0];
  404. }), singletonElement = null, singletonCounter = 0, styleElementsInsertedAtTop = [];
  405. module.exports = function(list, options) {
  406. if ("undefined" != typeof DEBUG && DEBUG && "object" != typeof document) throw new Error("The style-loader cannot be used in a non-browser environment");
  407. options = options || {}, void 0 === options.singleton && (options.singleton = isOldIE()),
  408. void 0 === options.insertAt && (options.insertAt = "bottom");
  409. var styles = listToStyles(list);
  410. return addStylesToDom(styles, options), function(newList) {
  411. for (var mayRemove = [], i = 0; i < styles.length; i++) {
  412. var item = styles[i], domStyle = stylesInDom[item.id];
  413. domStyle.refs--, mayRemove.push(domStyle);
  414. }
  415. if (newList) {
  416. addStylesToDom(listToStyles(newList), options);
  417. }
  418. for (var i = 0; i < mayRemove.length; i++) {
  419. var domStyle = mayRemove[i];
  420. if (0 === domStyle.refs) {
  421. for (var j = 0; j < domStyle.parts.length; j++) domStyle.parts[j]();
  422. delete stylesInDom[domStyle.id];
  423. }
  424. }
  425. };
  426. };
  427. var replaceText = function() {
  428. var textStore = [];
  429. return function(index, replacement) {
  430. return textStore[index] = replacement, textStore.filter(Boolean).join("\n");
  431. };
  432. }();
  433. }, function(module, exports, __webpack_require__) {
  434. var content = __webpack_require__(1);
  435. "string" == typeof content && (content = [ [ module.i, content, "" ] ]);
  436. __webpack_require__(3)(content, {});
  437. content.locals && (module.exports = content.locals);
  438. }, function(module, __webpack_exports__, __webpack_require__) {
  439. "use strict";
  440. function escapeString(str) {
  441. return str.replace('"', '"');
  442. }
  443. function isObject(value) {
  444. var type = typeof value;
  445. return !!value && "object" == type;
  446. }
  447. function getObjectName(object) {
  448. if (void 0 === object) return "";
  449. if (null === object) return "Object";
  450. if ("object" == typeof object && !object.constructor) return "Object";
  451. var funcNameRegex = /function ([^(]*)/, results = funcNameRegex.exec(object.constructor.toString());
  452. return results && results.length > 1 ? results[1] : "";
  453. }
  454. function getType(object) {
  455. return null === object ? "null" : typeof object;
  456. }
  457. function getValuePreview(object, value) {
  458. var type = getType(object);
  459. return "null" === type || "undefined" === type ? type : ("string" === type && (value = '"' + escapeString(value) + '"'),
  460. "function" === type ? object.toString().replace(/[\r\n]/g, "").replace(/\{.*\}/, "") + "{…}" : value);
  461. }
  462. function getPreview(object) {
  463. var value = "";
  464. return isObject(object) ? (value = getObjectName(object), Array.isArray(object) && (value += "[" + object.length + "]")) : value = getValuePreview(object, object),
  465. value;
  466. }
  467. function cssClass(className) {
  468. return "json-formatter-" + className;
  469. }
  470. function createElement(type, className, content) {
  471. var el = document.createElement(type);
  472. return className && el.classList.add(cssClass(className)), void 0 !== content && (content instanceof Node ? el.appendChild(content) : el.appendChild(document.createTextNode(String(content)))),
  473. el;
  474. }
  475. __webpack_exports__.a = isObject, __webpack_exports__.b = getObjectName, __webpack_exports__.c = getType,
  476. __webpack_exports__.g = getValuePreview, __webpack_exports__.e = getPreview, __webpack_exports__.d = cssClass,
  477. __webpack_exports__.f = createElement;
  478. }, function(module, exports, __webpack_require__) {
  479. module.exports = __webpack_require__(0);
  480. } ]);
  481. //# sourceMappingURL=json-formatter.js.map
  482. /***/ }),
  483. /* 1 */
  484. /***/ (function(module, exports, __webpack_require__) {
  485. var JSONFormatter = __webpack_require__(0).default;
  486. var live = document.getElementById('live');
  487. var hoverPreviewEnabledCheckbox = document.getElementById('hoverPreviewEnabled');
  488. function render() {
  489. live.style.backgroundColor = 'transparent';
  490. var result = document.getElementById('live-result');
  491. try {
  492. var formatter = new JSONFormatter(JSON.parse(live.value), 1, { hoverPreviewEnabled: hoverPreviewEnabledCheckbox.checked });
  493. result.innerHTML = '';
  494. result.appendChild(formatter.render());
  495. } catch (e) {
  496. live.style.backgroundColor = 'rgba(255, 87, 34, 0.35)';
  497. }
  498. }
  499. live.addEventListener('keyup', render);
  500. hoverPreviewEnabledCheckbox.addEventListener('change', render);
  501. render();
  502. var complex = {
  503. numbers: [
  504. 1,
  505. 2,
  506. 3
  507. ],
  508. boolean: true,
  509. 'null': null,
  510. number: 123,
  511. anObject: {
  512. a: 'b',
  513. c: 'd',
  514. e: 'f\"'
  515. },
  516. string: 'Hello World',
  517. url: 'https://github.com/mohsen1/json-formatter-js',
  518. date: 'Sun Aug 03 2014 20:46:55 GMT-0700 (PDT)',
  519. func: function add(a, b) { return a + b; }
  520. };
  521. var deep = { a: { b: { c: { d: {} } } } };
  522. var examples = [
  523. { title: 'Complex', json: complex },
  524. { title: 'Number', json: 42 },
  525. { title: 'null', json: null },
  526. { title: 'Empty Object', json: Object.create(null) },
  527. { title: 'Empty Array', json: [] },
  528. { title: 'Deep', json: deep },
  529. { title: 'Dark', json: complex, config: { theme: 'dark' } }
  530. ];
  531. var result = document.querySelector('.result');
  532. examples.forEach(function (example) {
  533. var title = document.createElement('h3');
  534. var formatter = new JSONFormatter(example.json, 1, example.config);
  535. title.innerText = example.title;
  536. result.appendChild(title)
  537. var el = formatter.render();
  538. if (example.config && example.config.theme === 'dark') {
  539. el.style.backgroundColor = '#1E1E1E';
  540. }
  541. result.appendChild(el);
  542. });
  543. fetch('demo/giant.json').then(function (resp) {
  544. resp.json().then(function (giant) {
  545. var giantFormatter = new JSONFormatter(giant, 2, { hoverPreviewEnabled: true });
  546. var title = document.createElement('h3');
  547. title.innerText = 'Giant JSON';
  548. result.appendChild(title);
  549. console.time('Rendering giant JSON');
  550. result.appendChild(giantFormatter.render());
  551. console.timeEnd('Rendering giant JSON');
  552. });
  553. })
  554. /***/ })
  555. /******/ ]);
  556. //# sourceMappingURL=index.js.map