1 line
34 KiB
JSON
1 line
34 KiB
JSON
|
{"ast":null,"code":"function ownKeys(object, enumerableOnly) {\n var keys = Object.keys(object);\n if (Object.getOwnPropertySymbols) {\n var symbols = Object.getOwnPropertySymbols(object);\n enumerableOnly && (symbols = symbols.filter(function (sym) {\n return Object.getOwnPropertyDescriptor(object, sym).enumerable;\n })), keys.push.apply(keys, symbols);\n }\n return keys;\n}\nfunction _objectSpread(target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = null != arguments[i] ? arguments[i] : {};\n i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {\n _defineProperty(target, key, source[key]);\n }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {\n Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));\n });\n }\n return target;\n}\nfunction _defineProperty(obj, key, value) {\n key = _toPropertyKey(key);\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n return obj;\n}\nfunction _toPropertyKey(arg) {\n var key = _toPrimitive(arg, \"string\");\n return typeof key === \"symbol\" ? key : String(key);\n}\nfunction _toPrimitive(input, hint) {\n if (typeof input !== \"object\" || input === null) return input;\n var prim = input[Symbol.toPrimitive];\n if (prim !== undefined) {\n var res = prim.call(input, hint || \"default\");\n if (typeof res !== \"object\") return res;\n throw new TypeError(\"@@toPrimitive must return a primitive value.\");\n }\n return (hint === \"string\" ? String : Number)(input);\n}\n// The error overlay is inspired (and mostly copied) from Create React App (https://github.com/facebookincubator/create-react-app)\n// They, in turn, got inspired by webpack-hot-middleware (https://github.com/glenjamin/webpack-hot-middleware).\n\nimport ansiHTML from \"ansi-html-community\";\nimport { encode } from \"html-entities\";\nimport { listenToRuntimeError, listenToUnhandledRejection, parseErrorToStacks } from \"./overlay/runtime-error.js\";\nimport createOverlayMachine from \"./overlay/state-machine.js\";\nimport { containerStyle, dismissButtonStyle, headerStyle, iframeStyle, msgStyles, msgTextStyle, msgTypeStyle } from \"./overlay/styles.js\";\nvar colors = {\n reset: [\"transparent\", \"transparent\"],\n black: \"181818\",\n red: \"E36049\",\n green: \"B3CB74\",\n yellow: \"FFD080\",\n blue: \"7CAFC2\",\n magenta: \"7FACCA\",\n cyan: \"C3C2EF\",\n lightgrey: \"EBE7E3\",\n darkgrey: \"6D7891\"\n};\nansiHTML.setColors(colors);\n\n/**\n * @param {string} type\n * @param {string | { file?: string, moduleName?: string, loc?: string, message?: string; stack?: string[] }} item\n * @returns {{ header: string, body: string }}\n */\nfunction formatProblem(type, item) {\n var header = type === \"warning\" ? \"WARNING\" : \"ERROR\";\n var body = \"\";\n if (typeof item === \"string\") {\n body += item;\n } else {\n var file = item.file || \"\";\n // eslint-disable-next-line no-nested-ternary\n var moduleName = item.moduleName ? item.moduleName.indexOf(\"!\") !== -1 ? \"\".concat(item.moduleName.replace(/^(\\s|\\S)*!/, \"\"), \" (\").concat(item.moduleName, \")\") : \"\".concat(item.moduleName) : \"\";\n var loc = item.loc;\n header += \"\".concat(moduleName || file ? \" in \".concat(moduleName ? \"\".concat(moduleName).concat(file ? \" (\".concat(file, \")\") : \"\") : file).concat(loc ? \" \".concat(loc) : \"\") : \"\");\n body += item.message || \"\";\n }\n if (Array.isArray(item.stack)) {\n item.stack.forEach(function (stack) {\n if (typeof stack === \"string\") {\n body += \"\\r\\n\".concat(stack);\n }\n });\n }\n return {\n header: header,\n body: body\n };\n}\n\n/**\n * @typedef {Object} CreateOverlayOptions\n * @property {string | null} trustedTypesPolicyName\n * @property {boo
|