1 line
23 KiB
JSON
1 line
23 KiB
JSON
{"ast":null,"code":"/* global __webpack_require__ */\nvar Refresh = require('react-refresh/runtime');\n/**\r\n * Extracts exports from a webpack module object.\r\n * @param {string} moduleId A Webpack module ID.\r\n * @returns {*} An exports object from the module.\r\n */\n\n\nfunction getModuleExports(moduleId) {\n var maybeModule = __webpack_require__.c[moduleId];\n\n if (typeof maybeModule === 'undefined') {\n console.warn('[React Refresh] Failed to get exports for module: ' + moduleId + '.');\n return {};\n }\n\n var exportsOrPromise = maybeModule.exports;\n\n if (typeof Promise !== 'undefined' && exportsOrPromise instanceof Promise) {\n return exportsOrPromise.then(function (exports) {\n return exports;\n });\n }\n\n return exportsOrPromise;\n}\n/**\r\n * Calculates the signature of a React refresh boundary.\r\n * If this signature changes, it's unsafe to accept the boundary.\r\n *\r\n * This implementation is based on the one in [Metro](https://github.com/facebook/metro/blob/907d6af22ac6ebe58572be418e9253a90665ecbd/packages/metro/src/lib/polyfills/require.js#L795-L816).\r\n * @param {*} moduleExports A Webpack module exports object.\r\n * @returns {string[]} A React refresh boundary signature array.\r\n */\n\n\nfunction getReactRefreshBoundarySignature(moduleExports) {\n var signature = [];\n signature.push(Refresh.getFamilyByType(moduleExports));\n\n if (moduleExports == null || typeof moduleExports !== 'object') {\n // Exit if we can't iterate over exports.\n return signature;\n }\n\n for (var key in moduleExports) {\n if (key === '__esModule') {\n continue;\n }\n\n signature.push(key);\n signature.push(Refresh.getFamilyByType(moduleExports[key]));\n }\n\n return signature;\n}\n/**\r\n * Creates a helper that performs a delayed React refresh.\r\n * @returns {function(function(): void): void} A debounced React refresh function.\r\n */\n\n\nfunction createDebounceUpdate() {\n /**\r\n * A cached setTimeout handler.\r\n * @type {number | undefined}\r\n */\n var refreshTimeout;\n /**\r\n * Performs react refresh on a delay and clears the error overlay.\r\n * @param {function(): void} callback\r\n * @returns {void}\r\n */\n\n function enqueueUpdate(callback) {\n if (typeof refreshTimeout === 'undefined') {\n refreshTimeout = setTimeout(function () {\n refreshTimeout = undefined;\n Refresh.performReactRefresh();\n callback();\n }, 30);\n }\n }\n\n return enqueueUpdate;\n}\n/**\r\n * Checks if all exports are likely a React component.\r\n *\r\n * This implementation is based on the one in [Metro](https://github.com/facebook/metro/blob/febdba2383113c88296c61e28e4ef6a7f4939fda/packages/metro/src/lib/polyfills/require.js#L748-L774).\r\n * @param {*} moduleExports A Webpack module exports object.\r\n * @returns {boolean} Whether the exports are React component like.\r\n */\n\n\nfunction isReactRefreshBoundary(moduleExports) {\n if (Refresh.isLikelyComponentType(moduleExports)) {\n return true;\n }\n\n if (moduleExports === undefined || moduleExports === null || typeof moduleExports !== 'object') {\n // Exit if we can't iterate over exports.\n return false;\n }\n\n var hasExports = false;\n var areAllExportsComponents = true;\n\n for (var key in moduleExports) {\n hasExports = true; // This is the ES Module indicator flag\n\n if (key === '__esModule') {\n continue;\n } // We can (and have to) safely execute getters here,\n // as Webpack manually assigns harmony exports to getters,\n // without any side-effects attached.\n // Ref: https://github.com/webpack/webpack/blob/b93048643fe74de2a6931755911da1212df55897/lib/MainTemplate.js#L281\n\n\n var exportValue = moduleExports[key];\n\n if (!Refresh.isLikelyComponentType(exportValue)) {\n areAllExportsComponents = false;\n }\n }\n\n return hasExports && areAllExportsComponents;\n}\n/**\r\n * Checks if exports are likely a React component and registers them.\r\n *\r\n * This implementation is based on the one in [Metro
|