|
| 1 | +(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){ |
| 2 | +(function (global){(function (){ |
| 3 | +global.prettyPrintJson = require('pretty-print-json'); |
| 4 | +}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) |
| 5 | +},{"pretty-print-json":2}],2:[function(require,module,exports){ |
| 6 | +//! pretty-print-json v2.0.4 ~~ https://pretty-print-json.js.org ~~ MIT License |
| 7 | + |
| 8 | +(function (factory) { |
| 9 | + if (typeof module === "object" && typeof module.exports === "object") { |
| 10 | + var v = factory(require, exports); |
| 11 | + if (v !== undefined) module.exports = v; |
| 12 | + } |
| 13 | + else if (typeof define === "function" && define.amd) { |
| 14 | + define(["require", "exports"], factory); |
| 15 | + } |
| 16 | +})(function (require, exports) { |
| 17 | + "use strict"; |
| 18 | + Object.defineProperty(exports, "__esModule", { value: true }); |
| 19 | + exports.prettyPrintJson = void 0; |
| 20 | + const prettyPrintJson = { |
| 21 | + version: '2.0.4', |
| 22 | + toHtml(data, options) { |
| 23 | + if (!''.at) |
| 24 | + String.prototype.at = function (i) { return this.charAt(i + (i < 0 ? this.length : 0)); }; |
| 25 | + const defaults = { |
| 26 | + indent: 3, |
| 27 | + lineNumbers: false, |
| 28 | + linkUrls: true, |
| 29 | + linksNewTab: true, |
| 30 | + quoteKeys: false, |
| 31 | + trailingComma: true, |
| 32 | + }; |
| 33 | + const settings = { ...defaults, ...options }; |
| 34 | + const invalidHtml = /[<>&]|\\"/g; |
| 35 | + const toHtml = (char) => char === '<' ? '<' : |
| 36 | + char === '>' ? '>' : |
| 37 | + char === '&' ? '&' : |
| 38 | + '\"'; |
| 39 | + const spanTag = (type, display) => display ? '<span class=json-' + type + '>' + display + '</span>' : ''; |
| 40 | + const buildValueHtml = (value) => { |
| 41 | + const strType = /^"/.test(value) && 'string'; |
| 42 | + const boolType = ['true', 'false'].includes(value) && 'boolean'; |
| 43 | + const nullType = value === 'null' && 'null'; |
| 44 | + const type = boolType || nullType || strType || 'number'; |
| 45 | + const urlPattern = /https?:\/\/[^\s"]+/g; |
| 46 | + const target = settings.linksNewTab ? ' target=_blank' : ''; |
| 47 | + const makeLink = (link) => `<a class=json-link href="${link}"${target}>${link}</a>`; |
| 48 | + const display = strType && settings.linkUrls ? value.replace(urlPattern, makeLink) : value; |
| 49 | + return spanTag(type, display); |
| 50 | + }; |
| 51 | + const replacer = (match, ...parts) => { |
| 52 | + const part = { indent: parts[0], key: parts[1], value: parts[2], end: parts[3] }; |
| 53 | + const findName = settings.quoteKeys ? /(.*)(): / : /"([\w$]+)": |(.*): /; |
| 54 | + const indentHtml = part.indent || ''; |
| 55 | + const keyName = part.key && part.key.replace(findName, '$1$2'); |
| 56 | + const keyHtml = part.key ? spanTag('key', keyName) + spanTag('mark', ': ') : ''; |
| 57 | + const valueHtml = part.value ? buildValueHtml(part.value) : ''; |
| 58 | + const noComma = !part.end || [']', '}'].includes(match.at(-1)); |
| 59 | + const addComma = settings.trailingComma && match.at(0) === ' ' && noComma; |
| 60 | + const endHtml = spanTag('mark', addComma ? (part.end ?? '') + ',' : part.end); |
| 61 | + return indentHtml + keyHtml + valueHtml + endHtml; |
| 62 | + }; |
| 63 | + const jsonLine = /^( *)("[^"]+": )?("[^"]*"|[\w.+-]*)?([{}[\],]*)?$/mg; |
| 64 | + const json = JSON.stringify(data, null, settings.indent) || 'undefined'; |
| 65 | + const html = json.replace(invalidHtml, toHtml).replace(jsonLine, replacer); |
| 66 | + const makeLine = (line) => ` <li>${line}</li>`; |
| 67 | + const addLineNumbers = (html) => ['<ol class=json-lines>', ...html.split('\n').map(makeLine), '</ol>'].join('\n'); |
| 68 | + return settings.lineNumbers ? addLineNumbers(html) : html; |
| 69 | + }, |
| 70 | + }; |
| 71 | + exports.prettyPrintJson = prettyPrintJson; |
| 72 | +}); |
| 73 | + |
| 74 | +},{}]},{},[1]); |
0 commit comments