metro-runtime
Advanced tools
Comparing version 0.80.9 to 0.80.10
{ | ||
"name": "metro-runtime", | ||
"version": "0.80.9", | ||
"version": "0.80.10", | ||
"description": "🚇 Module required for evaluating Metro bundles.", | ||
@@ -16,9 +16,10 @@ "main": "src", | ||
"dependencies": { | ||
"@babel/runtime": "^7.0.0" | ||
"@babel/runtime": "^7.0.0", | ||
"flow-enums-runtime": "^0.0.6" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.20.0", | ||
"react": "^18.2.0", | ||
"react": "19.0.0-rc-fb9a90fa48-20240614", | ||
"react-refresh": "^0.14.0", | ||
"react-test-renderer": "^18.2.0" | ||
"react-test-renderer": "19.0.0-rc-fb9a90fa48-20240614" | ||
}, | ||
@@ -25,0 +26,0 @@ "engines": { |
"use strict"; | ||
const DEFAULT_OPTIONS = { | ||
isPrefetchOnly: false, | ||
}; | ||
async function asyncRequireImpl(moduleID, paths, options) { | ||
function maybeLoadBundle(moduleID, paths) { | ||
const loadBundle = global[`${__METRO_GLOBAL_PREFIX__}__loadBundleAsync`]; | ||
@@ -13,18 +10,27 @@ if (loadBundle != null) { | ||
if (bundlePath != null) { | ||
await loadBundle(bundlePath); | ||
return loadBundle(bundlePath); | ||
} | ||
} | ||
} | ||
if (!options.isPrefetchOnly) { | ||
return require.importAll(moduleID); | ||
} | ||
return undefined; | ||
} | ||
function asyncRequireImpl(moduleID, paths) { | ||
const maybeLoadBundlePromise = maybeLoadBundle(moduleID, paths); | ||
const importAll = () => require.importAll(moduleID); | ||
if (maybeLoadBundlePromise != null) { | ||
return maybeLoadBundlePromise.then(importAll); | ||
} | ||
return importAll(); | ||
} | ||
async function asyncRequire(moduleID, paths, moduleName) { | ||
return asyncRequireImpl(moduleID, paths, DEFAULT_OPTIONS); | ||
return asyncRequireImpl(moduleID, paths); | ||
} | ||
asyncRequire.unstable_importMaybeSync = function unstable_importMaybeSync( | ||
moduleID, | ||
paths | ||
) { | ||
return asyncRequireImpl(moduleID, paths); | ||
}; | ||
asyncRequire.prefetch = function (moduleID, paths, moduleName) { | ||
asyncRequireImpl(moduleID, paths, { | ||
isPrefetchOnly: true, | ||
}).then( | ||
maybeLoadBundle(moduleID, paths)?.then( | ||
() => {}, | ||
@@ -31,0 +37,0 @@ () => {} |
@@ -16,11 +16,18 @@ "use strict"; | ||
function clear() { | ||
modules = Object.create(null); | ||
modules = new Map(); | ||
return modules; | ||
} | ||
if (__DEV__) { | ||
var verboseNamesToModuleIds = Object.create(null); | ||
var verboseNamesToModuleIds = new Map(); | ||
var getModuleIdForVerboseName = (verboseName) => { | ||
const moduleId = verboseNamesToModuleIds.get(verboseName); | ||
if (moduleId == null) { | ||
throw new Error(`Unknown named module: "${verboseName}"`); | ||
} | ||
return moduleId; | ||
}; | ||
var initializingModuleIds = []; | ||
} | ||
function define(factory, moduleId, dependencyMap) { | ||
if (modules[moduleId] != null) { | ||
if (modules.has(moduleId)) { | ||
if (__DEV__) { | ||
@@ -45,3 +52,3 @@ const inverseDependencies = arguments[4]; | ||
}; | ||
modules[moduleId] = mod; | ||
modules.set(moduleId, mod); | ||
if (__DEV__) { | ||
@@ -52,3 +59,3 @@ mod.hot = createHotReloadingObject(); | ||
mod.verboseName = verboseName; | ||
verboseNamesToModuleIds[verboseName] = moduleId; | ||
verboseNamesToModuleIds.set(verboseName, moduleId); | ||
} | ||
@@ -60,11 +67,7 @@ } | ||
const verboseName = moduleId; | ||
moduleId = verboseNamesToModuleIds[verboseName]; | ||
if (moduleId == null) { | ||
throw new Error(`Unknown named module: "${verboseName}"`); | ||
} else { | ||
console.warn( | ||
`Requiring module "${verboseName}" by name is only supported for ` + | ||
"debugging purposes and will BREAK IN PRODUCTION!" | ||
); | ||
} | ||
moduleId = getModuleIdForVerboseName(verboseName); | ||
console.warn( | ||
`Requiring module "${verboseName}" by name is only supported for ` + | ||
"debugging purposes and will BREAK IN PRODUCTION!" | ||
); | ||
} | ||
@@ -79,3 +82,3 @@ const moduleIdReallyIsNumber = moduleId; | ||
.slice(initializingIndex) | ||
.map((id) => (modules[id] ? modules[id].verboseName : "[unknown]")); | ||
.map((id) => modules.get(id)?.verboseName ?? "[unknown]"); | ||
if (shouldPrintRequireCycle(cycle)) { | ||
@@ -91,3 +94,3 @@ cycle.push(cycle[0]); | ||
} | ||
const module = modules[moduleIdReallyIsNumber]; | ||
const module = modules.get(moduleIdReallyIsNumber); | ||
return module && module.isInitialized | ||
@@ -110,10 +113,11 @@ ? module.publicModule.exports | ||
const verboseName = moduleId; | ||
moduleId = verboseNamesToModuleIds[verboseName]; | ||
moduleId = getModuleIdForVerboseName(verboseName); | ||
} | ||
const moduleIdReallyIsNumber = moduleId; | ||
const maybeInitializedModule = modules.get(moduleIdReallyIsNumber); | ||
if ( | ||
modules[moduleIdReallyIsNumber] && | ||
modules[moduleIdReallyIsNumber].importedDefault !== EMPTY | ||
maybeInitializedModule && | ||
maybeInitializedModule.importedDefault !== EMPTY | ||
) { | ||
return modules[moduleIdReallyIsNumber].importedDefault; | ||
return maybeInitializedModule.importedDefault; | ||
} | ||
@@ -123,3 +127,4 @@ const exports = metroRequire(moduleIdReallyIsNumber); | ||
exports && exports.__esModule ? exports.default : exports; | ||
return (modules[moduleIdReallyIsNumber].importedDefault = importedDefault); | ||
const initializedModule = modules.get(moduleIdReallyIsNumber); | ||
return (initializedModule.importedDefault = importedDefault); | ||
} | ||
@@ -130,10 +135,8 @@ metroRequire.importDefault = metroImportDefault; | ||
const verboseName = moduleId; | ||
moduleId = verboseNamesToModuleIds[verboseName]; | ||
moduleId = getModuleIdForVerboseName(verboseName); | ||
} | ||
const moduleIdReallyIsNumber = moduleId; | ||
if ( | ||
modules[moduleIdReallyIsNumber] && | ||
modules[moduleIdReallyIsNumber].importedAll !== EMPTY | ||
) { | ||
return modules[moduleIdReallyIsNumber].importedAll; | ||
const maybeInitializedModule = modules.get(moduleIdReallyIsNumber); | ||
if (maybeInitializedModule && maybeInitializedModule.importedAll !== EMPTY) { | ||
return maybeInitializedModule.importedAll; | ||
} | ||
@@ -155,3 +158,4 @@ const exports = metroRequire(moduleIdReallyIsNumber); | ||
} | ||
return (modules[moduleIdReallyIsNumber].importedAll = importedAll); | ||
const initializedModule = modules.get(moduleIdReallyIsNumber); | ||
return (initializedModule.importedAll = importedAll); | ||
} | ||
@@ -227,3 +231,3 @@ metroRequire.importAll = metroImportAll; | ||
moduleIds.forEach((moduleId) => { | ||
if (!modules[moduleId] && !definingSegmentByModuleID.has(moduleId)) { | ||
if (!modules.has(moduleId) && !definingSegmentByModuleID.has(moduleId)) { | ||
definingSegmentByModuleID.set(moduleId, segmentId); | ||
@@ -240,3 +244,3 @@ } | ||
definer(moduleId); | ||
module = modules[moduleId]; | ||
module = modules.get(moduleId); | ||
definingSegmentByModuleID.delete(moduleId); | ||
@@ -249,3 +253,3 @@ } | ||
nativeRequire(localId, segmentId); | ||
module = modules[moduleId]; | ||
module = modules.get(moduleId); | ||
} | ||
@@ -363,3 +367,3 @@ if (!module) { | ||
) { | ||
const mod = modules[id]; | ||
const mod = modules.get(id); | ||
if (!mod) { | ||
@@ -384,3 +388,3 @@ if (factory) { | ||
(pendingID) => { | ||
const pendingModule = modules[pendingID]; | ||
const pendingModule = modules.get(pendingID); | ||
if (pendingModule == null) { | ||
@@ -441,3 +445,3 @@ return []; | ||
seenModuleIDs.add(updatedID); | ||
const updatedMod = modules[updatedID]; | ||
const updatedMod = modules.get(updatedID); | ||
if (updatedMod == null) { | ||
@@ -482,3 +486,3 @@ throw new Error("[Refresh] Expected to find the updated module."); | ||
const parentID = parentIDs[j]; | ||
const parentMod = modules[parentID]; | ||
const parentMod = modules.get(parentID); | ||
if (parentMod == null) { | ||
@@ -544,3 +548,3 @@ throw new Error("[Refresh] Expected to find parent module."); | ||
const runUpdatedModule = function (id, factory, dependencyMap) { | ||
const mod = modules[id]; | ||
const mod = modules.get(id); | ||
if (mod == null) { | ||
@@ -547,0 +551,0 @@ throw new Error("[Refresh] Expected to find the module."); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
74742
1077
2
+ Addedflow-enums-runtime@^0.0.6
+ Addedflow-enums-runtime@0.0.6(transitive)