1 line
34 KiB
JSON
1 line
34 KiB
JSON
|
{"ast":null,"code":"function ownKeys(e, r) {\n var t = Object.keys(e);\n if (Object.getOwnPropertySymbols) {\n var o = Object.getOwnPropertySymbols(e);\n r && (o = o.filter(function (r) {\n return Object.getOwnPropertyDescriptor(e, r).enumerable;\n })), t.push.apply(t, o);\n }\n return t;\n}\nfunction _objectSpread(e) {\n for (var r = 1; r < arguments.length; r++) {\n var t = null != arguments[r] ? arguments[r] : {};\n r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {\n _defineProperty(e, r, t[r]);\n }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {\n Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));\n });\n }\n return e;\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(t) {\n var i = _toPrimitive(t, \"string\");\n return \"symbol\" == typeof i ? i : i + \"\";\n}\nfunction _toPrimitive(t, r) {\n if (\"object\" != typeof t || !t) return t;\n var e = t[Symbol.toPrimitive];\n if (void 0 !== e) {\n var i = e.call(t, r || \"default\");\n if (\"object\" != typeof i) return i;\n throw new TypeError(\"@@toPrimitive must return a primitive value.\");\n }\n return (\"string\" === r ? String : Number)(t);\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 {boolean | (error: Error) => void} [catchRuntimeError]\n */\n\n/**\n *\n * @param {CreateOverlayOptions} options\n */\nvar createOverlay = function createOverlay(options) {\n /** @type {HTMLIFrameElement | null | undefined} */\n var i
|