index.js 35 KB

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