@granite-js/mpack 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +46 -0
- package/LICENSE +202 -0
- package/README.md +24 -0
- package/dist/bundler/Bundler.d.ts +24 -0
- package/dist/bundler/Bundler.js +175 -0
- package/dist/bundler/PluginDriver.d.ts +9 -0
- package/dist/bundler/PluginDriver.js +47 -0
- package/dist/bundler/index.d.ts +1 -0
- package/dist/bundler/index.js +22 -0
- package/dist/bundler/plugins/buildStatusPlugin/buildStatusPlugin.d.ts +12 -0
- package/dist/bundler/plugins/buildStatusPlugin/buildStatusPlugin.js +75 -0
- package/dist/bundler/plugins/buildStatusPlugin/index.d.ts +1 -0
- package/dist/bundler/plugins/buildStatusPlugin/index.js +28 -0
- package/dist/bundler/plugins/dependencyAliasPlugin/aliasResolver.d.ts +3 -0
- package/dist/bundler/plugins/dependencyAliasPlugin/aliasResolver.js +89 -0
- package/dist/bundler/plugins/dependencyAliasPlugin/dependencyAliasPlugin.d.ts +3 -0
- package/dist/bundler/plugins/dependencyAliasPlugin/dependencyAliasPlugin.js +43 -0
- package/dist/bundler/plugins/dependencyAliasPlugin/index.d.ts +1 -0
- package/dist/bundler/plugins/dependencyAliasPlugin/index.js +28 -0
- package/dist/bundler/plugins/dependencyAliasPlugin/protocolResolver.d.ts +3 -0
- package/dist/bundler/plugins/dependencyAliasPlugin/protocolResolver.js +53 -0
- package/dist/bundler/plugins/index.d.ts +4 -0
- package/dist/bundler/plugins/index.js +28 -0
- package/dist/bundler/plugins/requireContextPlugin/index.d.ts +1 -0
- package/dist/bundler/plugins/requireContextPlugin/index.js +28 -0
- package/dist/bundler/plugins/requireContextPlugin/requireContextPlugin.d.ts +6 -0
- package/dist/bundler/plugins/requireContextPlugin/requireContextPlugin.js +101 -0
- package/dist/bundler/plugins/requireContextPlugin/scripts.d.ts +56 -0
- package/dist/bundler/plugins/requireContextPlugin/scripts.js +65 -0
- package/dist/bundler/plugins/shared/swc.d.ts +11 -0
- package/dist/bundler/plugins/shared/swc.js +70 -0
- package/dist/bundler/plugins/transformPlugin/helpers/preludeScript.d.ts +23 -0
- package/dist/bundler/plugins/transformPlugin/helpers/preludeScript.js +79 -0
- package/dist/bundler/plugins/transformPlugin/index.d.ts +1 -0
- package/dist/bundler/plugins/transformPlugin/index.js +28 -0
- package/dist/bundler/plugins/transformPlugin/steps/createCacheSteps.d.ts +10 -0
- package/dist/bundler/plugins/transformPlugin/steps/createCacheSteps.js +56 -0
- package/dist/bundler/plugins/transformPlugin/steps/createFullyTransformStep.d.ts +8 -0
- package/dist/bundler/plugins/transformPlugin/steps/createFullyTransformStep.js +120 -0
- package/dist/bundler/plugins/transformPlugin/steps/createStripFlowStep.d.ts +6 -0
- package/dist/bundler/plugins/transformPlugin/steps/createStripFlowStep.js +91 -0
- package/dist/bundler/plugins/transformPlugin/steps/createTransformToHermesSyntaxStep.d.ts +8 -0
- package/dist/bundler/plugins/transformPlugin/steps/createTransformToHermesSyntaxStep.js +100 -0
- package/dist/bundler/plugins/transformPlugin/transformPlugin.d.ts +8 -0
- package/dist/bundler/plugins/transformPlugin/transformPlugin.js +88 -0
- package/dist/bundler/plugins/types.d.ts +7 -0
- package/dist/bundler/plugins/types.js +16 -0
- package/dist/bundler/types.d.ts +17 -0
- package/dist/bundler/types.js +16 -0
- package/dist/cache/Cache.d.ts +25 -0
- package/dist/cache/Cache.js +87 -0
- package/dist/cache/index.d.ts +1 -0
- package/dist/cache/index.js +22 -0
- package/dist/constants/index.d.ts +20 -0
- package/dist/constants/index.js +91 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +60 -0
- package/dist/logger/Logger.d.ts +17 -0
- package/dist/logger/Logger.js +115 -0
- package/dist/logger/clientLogger.d.ts +2 -0
- package/dist/logger/clientLogger.js +49 -0
- package/dist/logger/index.d.ts +3 -0
- package/dist/logger/index.js +31 -0
- package/dist/metro/assetRegistry.d.ts +12 -0
- package/dist/metro/assetRegistry.js +57 -0
- package/dist/metro/enhancedResolver.d.ts +7 -0
- package/dist/metro/enhancedResolver.js +127 -0
- package/dist/metro/getMetroConfig.d.ts +12 -0
- package/dist/metro/getMetroConfig.js +138 -0
- package/dist/metro/getMonorepoRoot.d.ts +4 -0
- package/dist/metro/getMonorepoRoot.js +80 -0
- package/dist/metro/index.d.ts +3 -0
- package/dist/metro/index.js +24 -0
- package/dist/metro/pnpapi.d.ts +6 -0
- package/dist/metro/pnpapi.js +32 -0
- package/dist/metro/runBuild.d.ts +12 -0
- package/dist/metro/runBuild.js +66 -0
- package/dist/metro/runtime.d.ts +3 -0
- package/dist/metro/runtime.js +56 -0
- package/dist/metro/types.d.ts +88 -0
- package/dist/metro/types.js +16 -0
- package/dist/operations/constants.d.ts +3 -0
- package/dist/operations/constants.js +34 -0
- package/dist/operations/createDebuggerMiddleware.d.ts +11 -0
- package/dist/operations/createDebuggerMiddleware.js +128 -0
- package/dist/operations/experimental/StartMenuHandler.d.ts +13 -0
- package/dist/operations/experimental/StartMenuHandler.js +86 -0
- package/dist/operations/experimental/runServer.d.ts +16 -0
- package/dist/operations/experimental/runServer.js +137 -0
- package/dist/operations/index.d.ts +3 -0
- package/dist/operations/index.js +26 -0
- package/dist/operations/openDebugger.d.ts +1 -0
- package/dist/operations/openDebugger.js +73 -0
- package/dist/operations/runBundle.d.ts +12 -0
- package/dist/operations/runBundle.js +97 -0
- package/dist/operations/runServer.d.ts +15 -0
- package/dist/operations/runServer.js +134 -0
- package/dist/performance/Performance.d.ts +23 -0
- package/dist/performance/Performance.js +121 -0
- package/dist/performance/index.d.ts +2 -0
- package/dist/performance/index.js +31 -0
- package/dist/performance/printSummary.d.ts +5 -0
- package/dist/performance/printSummary.js +58 -0
- package/dist/plugins/index.d.ts +1 -0
- package/dist/plugins/index.js +22 -0
- package/dist/plugins/statusPlugin.d.ts +2 -0
- package/dist/plugins/statusPlugin.js +64 -0
- package/dist/server/DevServer.d.ts +23 -0
- package/dist/server/DevServer.js +216 -0
- package/dist/server/constants.d.ts +1 -0
- package/dist/server/constants.js +28 -0
- package/dist/server/debugger/DebuggerEventHandler.d.ts +41 -0
- package/dist/server/debugger/DebuggerEventHandler.js +169 -0
- package/dist/server/debugger/parseDomain.d.ts +1 -0
- package/dist/server/debugger/parseDomain.js +30 -0
- package/dist/server/helpers/createBundlerForDevServer.d.ts +10 -0
- package/dist/server/helpers/createBundlerForDevServer.js +75 -0
- package/dist/server/helpers/mergeBundles.d.ts +7 -0
- package/dist/server/helpers/mergeBundles.js +129 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +22 -0
- package/dist/server/middlewares/createLiveReloadMiddleware.d.ts +10 -0
- package/dist/server/middlewares/createLiveReloadMiddleware.js +129 -0
- package/dist/server/middlewares/index.d.ts +1 -0
- package/dist/server/middlewares/index.js +22 -0
- package/dist/server/plugins/debuggerPlugin.d.ts +7 -0
- package/dist/server/plugins/debuggerPlugin.js +68 -0
- package/dist/server/plugins/index.d.ts +5 -0
- package/dist/server/plugins/index.js +30 -0
- package/dist/server/plugins/indexPagePlugin.d.ts +4 -0
- package/dist/server/plugins/indexPagePlugin.js +52 -0
- package/dist/server/plugins/reply.d.ts +3 -0
- package/dist/server/plugins/reply.js +38 -0
- package/dist/server/plugins/serveBundlePlugin.d.ts +8 -0
- package/dist/server/plugins/serveBundlePlugin.js +118 -0
- package/dist/server/plugins/statusPlugin.d.ts +7 -0
- package/dist/server/plugins/statusPlugin.js +50 -0
- package/dist/server/plugins/symbolicatePlugin/index.d.ts +1 -0
- package/dist/server/plugins/symbolicatePlugin/index.js +28 -0
- package/dist/server/plugins/symbolicatePlugin/parseStackFrame.d.ts +25 -0
- package/dist/server/plugins/symbolicatePlugin/parseStackFrame.js +51 -0
- package/dist/server/plugins/symbolicatePlugin/symbolicate.d.ts +25 -0
- package/dist/server/plugins/symbolicatePlugin/symbolicate.js +84 -0
- package/dist/server/plugins/symbolicatePlugin/symbolicatePlugin.d.ts +8 -0
- package/dist/server/plugins/symbolicatePlugin/symbolicatePlugin.js +77 -0
- package/dist/server/types.d.ts +97 -0
- package/dist/server/types.js +16 -0
- package/dist/server/wss/WebSocketServerDelegate.d.ts +23 -0
- package/dist/server/wss/WebSocketServerDelegate.js +50 -0
- package/dist/server/wss/WebSocketServerRouter.d.ts +8 -0
- package/dist/server/wss/WebSocketServerRouter.js +66 -0
- package/dist/server/wss/index.d.ts +2 -0
- package/dist/server/wss/index.js +24 -0
- package/dist/shared/PersistentStorage.d.ts +21 -0
- package/dist/shared/PersistentStorage.js +68 -0
- package/dist/transformer/AsyncTransformPipeline.d.ts +4 -0
- package/dist/transformer/AsyncTransformPipeline.js +58 -0
- package/dist/transformer/TransformPipeline.d.ts +37 -0
- package/dist/transformer/TransformPipeline.js +64 -0
- package/dist/transformer/index.d.ts +1 -0
- package/dist/transformer/index.js +28 -0
- package/dist/types/BuildConfig.d.ts +183 -0
- package/dist/types/BuildConfig.js +16 -0
- package/dist/types/BundlerConfig.d.ts +56 -0
- package/dist/types/BundlerConfig.js +16 -0
- package/dist/types/Config.d.ts +12 -0
- package/dist/types/Config.js +16 -0
- package/dist/types/DevServerConfig.d.ts +9 -0
- package/dist/types/DevServerConfig.js +16 -0
- package/dist/types/Plugin.d.ts +28 -0
- package/dist/types/Plugin.js +16 -0
- package/dist/types/Preset.d.ts +3 -0
- package/dist/types/Preset.js +16 -0
- package/dist/types/PresetContext.d.ts +2 -0
- package/dist/types/PresetContext.js +16 -0
- package/dist/types/ServicesConfig.d.ts +2 -0
- package/dist/types/ServicesConfig.js +16 -0
- package/dist/types/TaskConfig.d.ts +16 -0
- package/dist/types/TaskConfig.js +16 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/index.js +38 -0
- package/dist/types/schemas/buildConfigSchema.d.ts +235 -0
- package/dist/types/schemas/buildConfigSchema.js +79 -0
- package/dist/types/schemas/bundlerConfigSchema.d.ts +3 -0
- package/dist/types/schemas/bundlerConfigSchema.js +51 -0
- package/dist/types/schemas/configSchema.d.ts +3 -0
- package/dist/types/schemas/configSchema.js +50 -0
- package/dist/types/schemas/devServerConfigSchema.d.ts +3 -0
- package/dist/types/schemas/devServerConfigSchema.js +43 -0
- package/dist/types/schemas/index.d.ts +6 -0
- package/dist/types/schemas/index.js +32 -0
- package/dist/types/schemas/servicesConfigSchema.d.ts +3 -0
- package/dist/types/schemas/servicesConfigSchema.js +48 -0
- package/dist/types/schemas/taskConfigSchema.d.ts +3 -0
- package/dist/types/schemas/taskConfigSchema.js +45 -0
- package/dist/utils/cleanupOutputDirectory.d.ts +1 -0
- package/dist/utils/cleanupOutputDirectory.js +53 -0
- package/dist/utils/defineStepName.d.ts +2 -0
- package/dist/utils/defineStepName.js +30 -0
- package/dist/utils/esbuildUtils.d.ts +1 -0
- package/dist/utils/esbuildUtils.js +45 -0
- package/dist/utils/getBundleName.d.ts +1 -0
- package/dist/utils/getBundleName.js +30 -0
- package/dist/utils/getBundleOutputs.d.ts +5 -0
- package/dist/utils/getBundleOutputs.js +49 -0
- package/dist/utils/getId.d.ts +2 -0
- package/dist/utils/getId.js +41 -0
- package/dist/utils/getSourcemapName.d.ts +1 -0
- package/dist/utils/getSourcemapName.js +30 -0
- package/dist/utils/isDebugMode.d.ts +1 -0
- package/dist/utils/isDebugMode.js +30 -0
- package/dist/utils/loadConfig.d.ts +2 -0
- package/dist/utils/loadConfig.js +37 -0
- package/dist/utils/loadPresets.d.ts +2 -0
- package/dist/utils/loadPresets.js +40 -0
- package/dist/utils/md5.d.ts +1 -0
- package/dist/utils/md5.js +41 -0
- package/dist/utils/mergeBanners.d.ts +6 -0
- package/dist/utils/mergeBanners.js +35 -0
- package/dist/utils/mergeBuildConfigs.d.ts +2 -0
- package/dist/utils/mergeBuildConfigs.js +59 -0
- package/dist/utils/mergeInject.d.ts +3 -0
- package/dist/utils/mergeInject.js +30 -0
- package/dist/utils/printLogo.d.ts +1 -0
- package/dist/utils/printLogo.js +56 -0
- package/dist/utils/printSummary.d.ts +7 -0
- package/dist/utils/printSummary.js +55 -0
- package/dist/utils/progressBar.d.ts +9 -0
- package/dist/utils/progressBar.js +97 -0
- package/dist/utils/promiseHandler.d.ts +12 -0
- package/dist/utils/promiseHandler.js +54 -0
- package/dist/utils/replaceModulePath.d.ts +1 -0
- package/dist/utils/replaceModulePath.js +31 -0
- package/dist/utils/replacePlaceholders.d.ts +1 -0
- package/dist/utils/replacePlaceholders.js +33 -0
- package/dist/utils/stripExtension.d.ts +1 -0
- package/dist/utils/stripExtension.js +41 -0
- package/dist/utils/writeBundle.d.ts +2 -0
- package/dist/utils/writeBundle.js +52 -0
- package/dist/vendors/@react-native/dev-middleware/Device.d.ts +5 -0
- package/dist/vendors/@react-native/dev-middleware/Device.js +33 -0
- package/dist/vendors/@react-native/dev-middleware/InspectorProxy.d.ts +31 -0
- package/dist/vendors/@react-native/dev-middleware/InspectorProxy.js +169 -0
- package/dist/vendors/@react-native/dev-middleware/index.d.ts +3 -0
- package/dist/vendors/@react-native/dev-middleware/index.js +26 -0
- package/dist/vendors/@react-native/dev-middleware/types.d.ts +54 -0
- package/dist/vendors/@react-native/dev-middleware/types.js +16 -0
- package/dist/vendors/@react-native-community/cli-server-api/createWebSocketEndpoints.d.ts +23 -0
- package/dist/vendors/@react-native-community/cli-server-api/createWebSocketEndpoints.js +47 -0
- package/dist/vendors/@react-native-community/cli-server-api/index.d.ts +1 -0
- package/dist/vendors/@react-native-community/cli-server-api/index.js +22 -0
- package/dist/vendors/index.d.ts +27 -0
- package/dist/vendors/index.js +63 -0
- package/dist/vendors/metro/src/Assets.js +159 -0
- package/dist/vendors/metro/src/Bundler/util.js +131 -0
- package/dist/vendors/metro/src/Bundler.js +43 -0
- package/dist/vendors/metro/src/DeltaBundler/DeltaCalculator.js +176 -0
- package/dist/vendors/metro/src/DeltaBundler/Serializers/baseBytecodeBundle.js +61 -0
- package/dist/vendors/metro/src/DeltaBundler/Serializers/baseJSBundle.js +45 -0
- package/dist/vendors/metro/src/DeltaBundler/Serializers/getAllFiles.js +30 -0
- package/dist/vendors/metro/src/DeltaBundler/Serializers/getAssets.js +23 -0
- package/dist/vendors/metro/src/DeltaBundler/Serializers/getExplodedSourceMap.js +17 -0
- package/dist/vendors/metro/src/DeltaBundler/Serializers/getRamBundleInfo.js +87 -0
- package/dist/vendors/metro/src/DeltaBundler/Serializers/helpers/bytecode.js +51 -0
- package/dist/vendors/metro/src/DeltaBundler/Serializers/helpers/getInlineSourceMappingURL.js +6 -0
- package/dist/vendors/metro/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.js +16 -0
- package/dist/vendors/metro/src/DeltaBundler/Serializers/helpers/getTransitiveDependencies.js +21 -0
- package/dist/vendors/metro/src/DeltaBundler/Serializers/helpers/js.js +43 -0
- package/dist/vendors/metro/src/DeltaBundler/Serializers/helpers/processBytecodeModules.js +13 -0
- package/dist/vendors/metro/src/DeltaBundler/Serializers/helpers/processModules.js +13 -0
- package/dist/vendors/metro/src/DeltaBundler/Serializers/hmrJSBundle.js +66 -0
- package/dist/vendors/metro/src/DeltaBundler/Serializers/sourceMapGenerator.js +63 -0
- package/dist/vendors/metro/src/DeltaBundler/Serializers/sourceMapObject.js +18 -0
- package/dist/vendors/metro/src/DeltaBundler/Serializers/sourceMapString.js +8 -0
- package/dist/vendors/metro/src/DeltaBundler/Transformer.js +133 -0
- package/dist/vendors/metro/src/DeltaBundler/Worker.flow.js +64 -0
- package/dist/vendors/metro/src/DeltaBundler/Worker.js +6 -0
- package/dist/vendors/metro/src/DeltaBundler/WorkerFarm.js +128 -0
- package/dist/vendors/metro/src/DeltaBundler/getTransformCacheKey.js +20 -0
- package/dist/vendors/metro/src/DeltaBundler/graphOperations.js +420 -0
- package/dist/vendors/metro/src/DeltaBundler/mergeDeltas.js +52 -0
- package/dist/vendors/metro/src/DeltaBundler/types.flow.js +24 -0
- package/dist/vendors/metro/src/DeltaBundler.js +56 -0
- package/dist/vendors/metro/src/HmrServer.js +224 -0
- package/dist/vendors/metro/src/IncrementalBundler/GraphNotFoundError.js +9 -0
- package/dist/vendors/metro/src/IncrementalBundler/ResourceNotFoundError.js +9 -0
- package/dist/vendors/metro/src/IncrementalBundler/RevisionNotFoundError.js +9 -0
- package/dist/vendors/metro/src/IncrementalBundler.js +213 -0
- package/dist/vendors/metro/src/ModuleGraph/module.js +14 -0
- package/dist/vendors/metro/src/ModuleGraph/node-haste/HasteFS.js +66 -0
- package/dist/vendors/metro/src/ModuleGraph/node-haste/Module.js +22 -0
- package/dist/vendors/metro/src/ModuleGraph/node-haste/ModuleCache.js +43 -0
- package/dist/vendors/metro/src/ModuleGraph/node-haste/Package.js +81 -0
- package/dist/vendors/metro/src/ModuleGraph/node-haste/node-haste.flow.js +1 -0
- package/dist/vendors/metro/src/ModuleGraph/node-haste/node-haste.js +127 -0
- package/dist/vendors/metro/src/ModuleGraph/output/indexed-ram-bundle.js +71 -0
- package/dist/vendors/metro/src/ModuleGraph/output/multiple-files-ram-bundle.js +53 -0
- package/dist/vendors/metro/src/ModuleGraph/output/plain-bundle.js +36 -0
- package/dist/vendors/metro/src/ModuleGraph/output/reverse-dependency-map-references.js +53 -0
- package/dist/vendors/metro/src/ModuleGraph/output/util.js +168 -0
- package/dist/vendors/metro/src/ModuleGraph/silent-console.js +5 -0
- package/dist/vendors/metro/src/ModuleGraph/types.flow.js +1 -0
- package/dist/vendors/metro/src/ModuleGraph/worker/JsFileWrapping.js +87 -0
- package/dist/vendors/metro/src/ModuleGraph/worker/Platforms.js +3 -0
- package/dist/vendors/metro/src/ModuleGraph/worker/collectDependencies.js +440 -0
- package/dist/vendors/metro/src/ModuleGraph/worker/generate.js +21 -0
- package/dist/vendors/metro/src/ModuleGraph/worker/generateImportNames.js +19 -0
- package/dist/vendors/metro/src/ModuleGraph/worker/mergeSourceMaps.js +29 -0
- package/dist/vendors/metro/src/Server/MultipartResponse.js +57 -0
- package/dist/vendors/metro/src/Server/symbolicate.js +109 -0
- package/dist/vendors/metro/src/Server.js +855 -0
- package/dist/vendors/metro/src/cli-utils.js +14 -0
- package/dist/vendors/metro/src/cli.js +9 -0
- package/dist/vendors/metro/src/commands/build.js +67 -0
- package/dist/vendors/metro/src/commands/dependencies.js +75 -0
- package/dist/vendors/metro/src/commands/serve.js +56 -0
- package/dist/vendors/metro/src/index.d.ts +8 -0
- package/dist/vendors/metro/src/index.flow.js +279 -0
- package/dist/vendors/metro/src/index.js +6 -0
- package/dist/vendors/metro/src/isPnP.js +13 -0
- package/dist/vendors/metro/src/lib/BatchProcessor.js +69 -0
- package/dist/vendors/metro/src/lib/CountingSet.js +98 -0
- package/dist/vendors/metro/src/lib/JsonReporter.js +21 -0
- package/dist/vendors/metro/src/lib/RamBundleParser.js +36 -0
- package/dist/vendors/metro/src/lib/TerminalReporter.d.ts +18 -0
- package/dist/vendors/metro/src/lib/TerminalReporter.js +258 -0
- package/dist/vendors/metro/src/lib/bundleToBytecode.js +40 -0
- package/dist/vendors/metro/src/lib/bundleToString.js +22 -0
- package/dist/vendors/metro/src/lib/contextModule.js +73 -0
- package/dist/vendors/metro/src/lib/contextModuleTemplates.js +116 -0
- package/dist/vendors/metro/src/lib/countLines.js +4 -0
- package/dist/vendors/metro/src/lib/createModuleIdFactory.js +14 -0
- package/dist/vendors/metro/src/lib/createWebsocketServer.js +54 -0
- package/dist/vendors/metro/src/lib/debounceAsyncQueue.js +33 -0
- package/dist/vendors/metro/src/lib/formatBundlingError.js +76 -0
- package/dist/vendors/metro/src/lib/getAppendScripts.js +131 -0
- package/dist/vendors/metro/src/lib/getGraphId.js +27 -0
- package/dist/vendors/metro/src/lib/getMaxWorkers.js +6 -0
- package/dist/vendors/metro/src/lib/getPreludeCode.js +32 -0
- package/dist/vendors/metro/src/lib/getPrependedScripts.js +93 -0
- package/dist/vendors/metro/src/lib/logToConsole.js +46 -0
- package/dist/vendors/metro/src/lib/parseCustomResolverOptions.js +13 -0
- package/dist/vendors/metro/src/lib/parseCustomTransformOptions.js +13 -0
- package/dist/vendors/metro/src/lib/parseOptionsFromUrl.js +50 -0
- package/dist/vendors/metro/src/lib/relativizeSourceMap.js +14 -0
- package/dist/vendors/metro/src/lib/reporting.js +26 -0
- package/dist/vendors/metro/src/lib/splitBundleOptions.js +32 -0
- package/dist/vendors/metro/src/lib/transformHelpers.js +112 -0
- package/dist/vendors/metro/src/node-haste/DependencyGraph/ModuleResolution.js +221 -0
- package/dist/vendors/metro/src/node-haste/DependencyGraph/createHasteMap.js +71 -0
- package/dist/vendors/metro/src/node-haste/DependencyGraph.js +223 -0
- package/dist/vendors/metro/src/node-haste/Module.js +21 -0
- package/dist/vendors/metro/src/node-haste/ModuleCache.js +81 -0
- package/dist/vendors/metro/src/node-haste/Package.js +98 -0
- package/dist/vendors/metro/src/node-haste/lib/AssetPaths.js +41 -0
- package/dist/vendors/metro/src/node-haste/lib/parsePlatformFilePath.js +19 -0
- package/dist/vendors/metro/src/shared/output/RamBundle/as-assets.js +61 -0
- package/dist/vendors/metro/src/shared/output/RamBundle/as-indexed-file.js +115 -0
- package/dist/vendors/metro/src/shared/output/RamBundle/buildSourcemapWithMetadata.js +23 -0
- package/dist/vendors/metro/src/shared/output/RamBundle/magic-number.js +2 -0
- package/dist/vendors/metro/src/shared/output/RamBundle/util.js +94 -0
- package/dist/vendors/metro/src/shared/output/RamBundle/write-sourcemap.js +12 -0
- package/dist/vendors/metro/src/shared/output/RamBundle.js +18 -0
- package/dist/vendors/metro/src/shared/output/bundle.flow.js +42 -0
- package/dist/vendors/metro/src/shared/output/bundle.js +6 -0
- package/dist/vendors/metro/src/shared/output/meta.js +31 -0
- package/dist/vendors/metro/src/shared/output/unbundle.js +2 -0
- package/dist/vendors/metro/src/shared/output/writeFile.js +6 -0
- package/dist/vendors/metro/src/shared/types.flow.js +1 -0
- package/dist/vendors/metro-config/src/configTypes.flow.js +1 -0
- package/dist/vendors/metro-config/src/defaults/defaults.js +66 -0
- package/dist/vendors/metro-config/src/defaults/exclusionList.d.ts +3 -0
- package/dist/vendors/metro-config/src/defaults/exclusionList.js +17 -0
- package/dist/vendors/metro-config/src/defaults/index.d.ts +5 -0
- package/dist/vendors/metro-config/src/defaults/index.js +161 -0
- package/dist/vendors/metro-config/src/defaults/validConfig.js +28 -0
- package/dist/vendors/metro-config/src/index.js +9 -0
- package/dist/vendors/metro-config/src/loadConfig.d.ts +4 -0
- package/dist/vendors/metro-config/src/loadConfig.js +188 -0
- package/dist/vendors/metro-core/src/Logger.js +62 -0
- package/dist/vendors/metro-core/src/Terminal.d.ts +30 -0
- package/dist/vendors/metro-core/src/Terminal.js +100 -0
- package/dist/vendors/metro-core/src/canonicalize.js +17 -0
- package/dist/vendors/metro-core/src/errors/AmbiguousModuleResolutionError.js +11 -0
- package/dist/vendors/metro-core/src/errors/PackageResolutionError.js +18 -0
- package/dist/vendors/metro-core/src/errors.js +7 -0
- package/dist/vendors/metro-core/src/index.js +11 -0
- package/dist/vendors/metro-inspector-proxy/src/Device.js +398 -0
- package/dist/vendors/metro-inspector-proxy/src/InspectorProxy.d.ts +21 -0
- package/dist/vendors/metro-inspector-proxy/src/InspectorProxy.js +153 -0
- package/dist/vendors/metro-inspector-proxy/src/cli.js +15 -0
- package/dist/vendors/metro-inspector-proxy/src/index.js +23 -0
- package/dist/vendors/metro-inspector-proxy/src/types.js +1 -0
- package/dist/vendors/metro-transform-worker/src/index.js +430 -0
- package/dist/vendors/metro-transform-worker/src/utils/assetTransformer.js +20 -0
- package/dist/vendors/metro-transform-worker/src/utils/getMinifier.js +11 -0
- package/package.json +162 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var import_metro_file_map = require("metro-file-map");
|
|
3
|
+
const { ModuleResolver } = require("../../node-haste/DependencyGraph/ModuleResolution");
|
|
4
|
+
const parsePlatformFilePath = require("../../node-haste/lib/parsePlatformFilePath");
|
|
5
|
+
const HasteFS = require("./HasteFS");
|
|
6
|
+
const Module = require("./Module");
|
|
7
|
+
const ModuleCache = require("./ModuleCache");
|
|
8
|
+
const defaults = require("../../../../metro-config/src/defaults/defaults");
|
|
9
|
+
const path = require("path");
|
|
10
|
+
const NATIVE_PLATFORM = "native";
|
|
11
|
+
const GENERIC_PLATFORM = "g";
|
|
12
|
+
const PACKAGE_JSON = path.sep + "package.json";
|
|
13
|
+
const NULL_MODULE = {
|
|
14
|
+
path: "/",
|
|
15
|
+
getPackage() {
|
|
16
|
+
},
|
|
17
|
+
isHaste() {
|
|
18
|
+
throw new Error("not implemented");
|
|
19
|
+
},
|
|
20
|
+
getName() {
|
|
21
|
+
throw new Error("not implemented");
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
const NODE_MODULES = path.sep + "node_modules" + path.sep;
|
|
25
|
+
const isNodeModules = (file) => file.includes(NODE_MODULES);
|
|
26
|
+
const createModuleMap = ({ files, moduleCache, sourceExts, additionalExts, platforms }) => {
|
|
27
|
+
const platformSet = new Set((platforms ?? defaults.platforms).concat([NATIVE_PLATFORM]));
|
|
28
|
+
const map = /* @__PURE__ */ new Map();
|
|
29
|
+
files.forEach((filePath) => {
|
|
30
|
+
if (isNodeModules(filePath)) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
let id;
|
|
34
|
+
let module2;
|
|
35
|
+
const fileExt = path.extname(filePath).substr(1);
|
|
36
|
+
if (filePath.endsWith(PACKAGE_JSON)) {
|
|
37
|
+
module2 = moduleCache.getPackage(filePath);
|
|
38
|
+
id = module2.data.name;
|
|
39
|
+
} else if (sourceExts.has(fileExt) || additionalExts.has(fileExt)) {
|
|
40
|
+
module2 = moduleCache.getModule(filePath);
|
|
41
|
+
id = module2.name;
|
|
42
|
+
}
|
|
43
|
+
if (!(id && module2 && module2.isHaste())) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const mapModule = map.get(id) || /* @__PURE__ */ Object.create(null);
|
|
47
|
+
const platform = parsePlatformFilePath(filePath, platformSet).platform || GENERIC_PLATFORM;
|
|
48
|
+
const existingModule = mapModule[platform];
|
|
49
|
+
mapModule[platform] = [filePath, module2.type === "Package" ? 1 : 0];
|
|
50
|
+
if (existingModule && existingModule[0] !== filePath) {
|
|
51
|
+
throw new Error(
|
|
52
|
+
[
|
|
53
|
+
"@providesModule naming collision:",
|
|
54
|
+
` Duplicate module name: \`${id}\``,
|
|
55
|
+
` Paths: \`${filePath}\` collides with \`${existingModule[0]}\``,
|
|
56
|
+
"",
|
|
57
|
+
"This error is caused by a @providesModule declaration with the same name across two different files."
|
|
58
|
+
].join("\n")
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
map.set(id, mapModule);
|
|
62
|
+
});
|
|
63
|
+
return map;
|
|
64
|
+
};
|
|
65
|
+
exports.createResolveFn = function(options) {
|
|
66
|
+
const {
|
|
67
|
+
assetExts,
|
|
68
|
+
assetResolutions,
|
|
69
|
+
extraNodeModules,
|
|
70
|
+
transformedFiles,
|
|
71
|
+
sourceExts,
|
|
72
|
+
additionalExts,
|
|
73
|
+
platform,
|
|
74
|
+
platforms
|
|
75
|
+
} = options;
|
|
76
|
+
const files = Object.keys(transformedFiles);
|
|
77
|
+
function getTransformedFile(path2) {
|
|
78
|
+
const result = transformedFiles[path2];
|
|
79
|
+
if (!result) {
|
|
80
|
+
throw new Error(`"${path2} does not exist`);
|
|
81
|
+
}
|
|
82
|
+
return result;
|
|
83
|
+
}
|
|
84
|
+
const hasteFS = new HasteFS(files);
|
|
85
|
+
const moduleCache = new ModuleCache((filePath) => hasteFS.closest(filePath, "package.json"), getTransformedFile);
|
|
86
|
+
const assetExtensions = new Set(assetExts.map((asset) => "." + asset));
|
|
87
|
+
const isAssetFile = (file) => assetExtensions.has(path.extname(file));
|
|
88
|
+
const moduleResolver = new ModuleResolver({
|
|
89
|
+
dirExists: (filePath) => hasteFS.dirExists(filePath),
|
|
90
|
+
disableHierarchicalLookup: options.disableHierarchicalLookup,
|
|
91
|
+
doesFileExist: (filePath) => hasteFS.exists(filePath),
|
|
92
|
+
emptyModulePath: options.emptyModulePath,
|
|
93
|
+
extraNodeModules,
|
|
94
|
+
isAssetFile,
|
|
95
|
+
mainFields: options.mainFields,
|
|
96
|
+
moduleCache,
|
|
97
|
+
moduleMap: new import_metro_file_map.ModuleMap({
|
|
98
|
+
duplicates: /* @__PURE__ */ new Map(),
|
|
99
|
+
map: createModuleMap({
|
|
100
|
+
files,
|
|
101
|
+
moduleCache,
|
|
102
|
+
sourceExts: new Set(sourceExts),
|
|
103
|
+
additionalExts: new Set(additionalExts),
|
|
104
|
+
platforms
|
|
105
|
+
}),
|
|
106
|
+
mocks: /* @__PURE__ */ new Map(),
|
|
107
|
+
rootDir: ""
|
|
108
|
+
}),
|
|
109
|
+
nodeModulesPaths: options.nodeModulesPaths,
|
|
110
|
+
preferNativePlatform: true,
|
|
111
|
+
projectRoot: "",
|
|
112
|
+
resolveAsset: (dirPath, assetName, extension) => {
|
|
113
|
+
const basePath = dirPath + path.sep + assetName;
|
|
114
|
+
const assets = [
|
|
115
|
+
basePath + extension,
|
|
116
|
+
...assetResolutions.map((resolution) => basePath + "@" + resolution + "x" + extension)
|
|
117
|
+
].filter((candidate) => hasteFS.exists(candidate));
|
|
118
|
+
return assets.length ? assets : null;
|
|
119
|
+
},
|
|
120
|
+
resolveRequest: options.resolveRequest,
|
|
121
|
+
sourceExts
|
|
122
|
+
});
|
|
123
|
+
return (id, sourcePath) => {
|
|
124
|
+
const from = sourcePath != null ? new Module(sourcePath, moduleCache, getTransformedFile(sourcePath)) : NULL_MODULE;
|
|
125
|
+
return moduleResolver.resolveDependency(from, id, true, platform, options.resolverOptions).path;
|
|
126
|
+
};
|
|
127
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const { createRamBundleGroups } = require("../../Bundler/util");
|
|
3
|
+
const { buildTableAndContents, createModuleGroups } = require("../../shared/output/RamBundle/as-indexed-file");
|
|
4
|
+
const buildSourcemapWithMetadata = require("../../shared/output/RamBundle/buildSourcemapWithMetadata.js");
|
|
5
|
+
const { getModuleCodeAndMap, partition, toModuleTransport } = require("./util");
|
|
6
|
+
const invariant = require("invariant");
|
|
7
|
+
function asIndexedRamBundle({
|
|
8
|
+
dependencyMapReservedName,
|
|
9
|
+
filename,
|
|
10
|
+
globalPrefix,
|
|
11
|
+
idsForPath,
|
|
12
|
+
modules,
|
|
13
|
+
preloadedModules,
|
|
14
|
+
ramGroupHeads,
|
|
15
|
+
requireCalls
|
|
16
|
+
}) {
|
|
17
|
+
const idForPath = (x) => idsForPath(x).moduleId;
|
|
18
|
+
const [startup, deferred] = partition(modules, preloadedModules);
|
|
19
|
+
const startupModules = [...startup, ...requireCalls];
|
|
20
|
+
const deferredModules = deferred.map(
|
|
21
|
+
(m) => toModuleTransport(m, idsForPath, { dependencyMapReservedName, globalPrefix })
|
|
22
|
+
);
|
|
23
|
+
for (const m of deferredModules) {
|
|
24
|
+
invariant(
|
|
25
|
+
m.id >= 0,
|
|
26
|
+
`A script (non-module) cannot be part of the deferred modules of a RAM bundle (\`${m.sourcePath}\`, id=${m.id})`
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
const ramGroups = createRamBundleGroups(ramGroupHeads || [], deferredModules, subtree);
|
|
30
|
+
const moduleGroups = createModuleGroups(ramGroups, deferredModules);
|
|
31
|
+
const tableAndContents = buildTableAndContents(
|
|
32
|
+
startupModules.map(
|
|
33
|
+
(m) => getModuleCodeAndMap(m, idForPath, {
|
|
34
|
+
dependencyMapReservedName,
|
|
35
|
+
enableIDInlining: true,
|
|
36
|
+
globalPrefix
|
|
37
|
+
}).moduleCode
|
|
38
|
+
).join("\n"),
|
|
39
|
+
deferredModules,
|
|
40
|
+
moduleGroups,
|
|
41
|
+
"utf8"
|
|
42
|
+
);
|
|
43
|
+
return {
|
|
44
|
+
code: Buffer.concat(tableAndContents),
|
|
45
|
+
map: buildSourcemapWithMetadata({
|
|
46
|
+
fixWrapperOffset: false,
|
|
47
|
+
lazyModules: deferredModules,
|
|
48
|
+
moduleGroups,
|
|
49
|
+
startupModules: startupModules.map(
|
|
50
|
+
(m) => toModuleTransport(m, idsForPath, {
|
|
51
|
+
dependencyMapReservedName,
|
|
52
|
+
globalPrefix
|
|
53
|
+
})
|
|
54
|
+
)
|
|
55
|
+
})
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function* subtree(moduleTransport, moduleTransportsByPath, seen = /* @__PURE__ */ new Set()) {
|
|
59
|
+
seen.add(moduleTransport.id);
|
|
60
|
+
for (const { path } of moduleTransport.dependencies) {
|
|
61
|
+
const dependency = moduleTransportsByPath.get(path);
|
|
62
|
+
if (dependency && !seen.has(dependency.id)) {
|
|
63
|
+
yield dependency.id;
|
|
64
|
+
yield* subtree(dependency, moduleTransportsByPath, seen);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function createBuilder(preloadedModules, ramGroupHeads) {
|
|
69
|
+
return (x) => asIndexedRamBundle({ ...x, preloadedModules, ramGroupHeads });
|
|
70
|
+
}
|
|
71
|
+
exports.createBuilder = createBuilder;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const buildSourcemapWithMetadata = require("../../shared/output/RamBundle/buildSourcemapWithMetadata.js");
|
|
3
|
+
const MAGIC_UNBUNDLE_NUMBER = require("../../shared/output/RamBundle/magic-number");
|
|
4
|
+
const { getModuleCodeAndMap, partition, toModuleTransport } = require("./util");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const MAGIC_UNBUNDLE_FILENAME = "UNBUNDLE";
|
|
7
|
+
const JS_MODULES = "js-modules";
|
|
8
|
+
function asMultipleFilesRamBundle({
|
|
9
|
+
dependencyMapReservedName,
|
|
10
|
+
filename,
|
|
11
|
+
globalPrefix,
|
|
12
|
+
idsForPath,
|
|
13
|
+
modules,
|
|
14
|
+
requireCalls,
|
|
15
|
+
preloadedModules
|
|
16
|
+
}) {
|
|
17
|
+
const idForPath = (x) => idsForPath(x).moduleId;
|
|
18
|
+
const [startup, deferred] = partition(modules, preloadedModules);
|
|
19
|
+
const startupModules = [...startup, ...requireCalls];
|
|
20
|
+
const deferredModules = deferred.map(
|
|
21
|
+
(m) => toModuleTransport(m, idsForPath, { dependencyMapReservedName, globalPrefix })
|
|
22
|
+
);
|
|
23
|
+
const magicFileContents = Buffer.alloc(4);
|
|
24
|
+
const code = startupModules.map(
|
|
25
|
+
(m) => getModuleCodeAndMap(m, idForPath, {
|
|
26
|
+
dependencyMapReservedName,
|
|
27
|
+
enableIDInlining: true,
|
|
28
|
+
globalPrefix
|
|
29
|
+
}).moduleCode
|
|
30
|
+
).join("\n");
|
|
31
|
+
const extraFiles = /* @__PURE__ */ new Map();
|
|
32
|
+
deferredModules.forEach((deferredModule) => {
|
|
33
|
+
extraFiles.set(path.join(JS_MODULES, deferredModule.id + ".js"), deferredModule.code);
|
|
34
|
+
});
|
|
35
|
+
magicFileContents.writeUInt32LE(MAGIC_UNBUNDLE_NUMBER, 0);
|
|
36
|
+
extraFiles.set(path.join(JS_MODULES, MAGIC_UNBUNDLE_FILENAME), magicFileContents);
|
|
37
|
+
const map = buildSourcemapWithMetadata({
|
|
38
|
+
fixWrapperOffset: false,
|
|
39
|
+
lazyModules: deferredModules,
|
|
40
|
+
moduleGroups: null,
|
|
41
|
+
startupModules: startupModules.map(
|
|
42
|
+
(m) => toModuleTransport(m, idsForPath, {
|
|
43
|
+
dependencyMapReservedName,
|
|
44
|
+
globalPrefix
|
|
45
|
+
})
|
|
46
|
+
)
|
|
47
|
+
});
|
|
48
|
+
return { code, extraFiles, map };
|
|
49
|
+
}
|
|
50
|
+
function createBuilder(preloadedModules, ramGroupHeads) {
|
|
51
|
+
return (x) => asMultipleFilesRamBundle({ ...x, preloadedModules, ramGroupHeads });
|
|
52
|
+
}
|
|
53
|
+
exports.createBuilder = createBuilder;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const meta = require("../../shared/output/meta");
|
|
3
|
+
const { concat, getModuleCodeAndMap } = require("./util");
|
|
4
|
+
const { BundleBuilder } = require("metro-source-map");
|
|
5
|
+
function asPlainBundle({
|
|
6
|
+
dependencyMapReservedName,
|
|
7
|
+
filename,
|
|
8
|
+
globalPrefix,
|
|
9
|
+
idsForPath,
|
|
10
|
+
modules,
|
|
11
|
+
requireCalls,
|
|
12
|
+
sourceMapPath,
|
|
13
|
+
enableIDInlining
|
|
14
|
+
}) {
|
|
15
|
+
const builder = new BundleBuilder(filename);
|
|
16
|
+
const modIdForPath = (x) => idsForPath(x).moduleId;
|
|
17
|
+
for (const module2 of concat(modules, requireCalls)) {
|
|
18
|
+
const { moduleCode, moduleMap } = getModuleCodeAndMap(module2, modIdForPath, {
|
|
19
|
+
dependencyMapReservedName,
|
|
20
|
+
enableIDInlining,
|
|
21
|
+
globalPrefix
|
|
22
|
+
});
|
|
23
|
+
builder.append(moduleCode + "\n", moduleMap);
|
|
24
|
+
}
|
|
25
|
+
if (sourceMapPath) {
|
|
26
|
+
builder.append(`//# sourceMappingURL=${sourceMapPath}`);
|
|
27
|
+
}
|
|
28
|
+
const code = builder.getCode();
|
|
29
|
+
const map = builder.getMap();
|
|
30
|
+
return {
|
|
31
|
+
code,
|
|
32
|
+
extraFiles: [[`${filename}.meta`, meta(code)]],
|
|
33
|
+
map
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
module.exports = asPlainBundle;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
+
}
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var import_invariant = __toESM(require("invariant"));
|
|
25
|
+
var import_nullthrows = __toESM(require("nullthrows"));
|
|
26
|
+
function reverseDependencyMapReferences({ types: t }) {
|
|
27
|
+
return {
|
|
28
|
+
visitor: {
|
|
29
|
+
CallExpression(path, state) {
|
|
30
|
+
const { node } = path;
|
|
31
|
+
if (node.callee.name === `${state.opts.globalPrefix}__d`) {
|
|
32
|
+
const lastArg = node.arguments[0].params.slice(-1)[0];
|
|
33
|
+
const depMapName = lastArg && lastArg.name;
|
|
34
|
+
if (depMapName == null) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const body = path.get("arguments.0.body");
|
|
38
|
+
(0, import_invariant.default)(!Array.isArray(body), "meetro: Expected `body` to be a single path.");
|
|
39
|
+
const scope = body.scope;
|
|
40
|
+
const binding = (0, import_nullthrows.default)(scope.getBinding(depMapName));
|
|
41
|
+
binding.referencePaths.forEach(({ parentPath }) => {
|
|
42
|
+
const memberNode = parentPath?.node;
|
|
43
|
+
if (memberNode != null && memberNode.type === "MemberExpression" && memberNode.property.type === "NumericLiteral") {
|
|
44
|
+
const numericLiteral = t.numericLiteral(state.opts.dependencyIds[memberNode.property.value]);
|
|
45
|
+
(0, import_nullthrows.default)(parentPath).replaceWith(numericLiteral);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
module.exports = reverseDependencyMapReferences;
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const virtualModule = require("../module").virtual;
|
|
3
|
+
const generate = require("../worker/generate");
|
|
4
|
+
const mergeSourceMaps = require("../worker/mergeSourceMaps");
|
|
5
|
+
const reverseDependencyMapReferences = require("./reverse-dependency-map-references");
|
|
6
|
+
const { parseSync, transformFromAstSync } = require("@babel/core");
|
|
7
|
+
const { passthroughSyntaxPlugins } = require("metro-react-native-babel-preset");
|
|
8
|
+
const { addParamsToDefineCall } = require("metro-transform-plugins");
|
|
9
|
+
const nullthrows = require("nullthrows");
|
|
10
|
+
function addModuleIdsToModuleWrapper(module2, idForPath) {
|
|
11
|
+
const { dependencies, file } = module2;
|
|
12
|
+
const { code } = file;
|
|
13
|
+
const fileId = idForPath(file);
|
|
14
|
+
const paramsToAdd = [fileId];
|
|
15
|
+
if (dependencies.length) {
|
|
16
|
+
paramsToAdd.push(dependencies.map(idForPath));
|
|
17
|
+
}
|
|
18
|
+
return addParamsToDefineCall(code, ...paramsToAdd);
|
|
19
|
+
}
|
|
20
|
+
exports.addModuleIdsToModuleWrapper = addModuleIdsToModuleWrapper;
|
|
21
|
+
function isTypeScriptSource(fileName) {
|
|
22
|
+
return !!fileName && fileName.endsWith(".ts");
|
|
23
|
+
}
|
|
24
|
+
function isTSXSource(fileName) {
|
|
25
|
+
return !!fileName && fileName.endsWith(".tsx");
|
|
26
|
+
}
|
|
27
|
+
function inlineModuleIds(module2, idForPath, { dependencyMapReservedName, globalPrefix, ignoreMissingDependencyMapReference = false, hermesParser = false }) {
|
|
28
|
+
const { dependencies, file } = module2;
|
|
29
|
+
const { code, map, path } = file;
|
|
30
|
+
const fileId = idForPath(file);
|
|
31
|
+
const dependencyIds = dependencies.map(idForPath);
|
|
32
|
+
if (!dependencyIds.length) {
|
|
33
|
+
return { fileId, moduleCode: code, moduleMap: map };
|
|
34
|
+
}
|
|
35
|
+
if (dependencyMapReservedName != null) {
|
|
36
|
+
if (!code.includes(dependencyMapReservedName)) {
|
|
37
|
+
if (ignoreMissingDependencyMapReference) {
|
|
38
|
+
return { fileId, moduleCode: code, moduleMap: map };
|
|
39
|
+
}
|
|
40
|
+
throw new Error(
|
|
41
|
+
`Module has dependencies but does not use the preconfigured dependency map name '${dependencyMapReservedName}': ${file.path}
|
|
42
|
+
This is an internal error in Metro.`
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
const WS = "[ ]*";
|
|
46
|
+
const depMapReferenceRegex = new RegExp(
|
|
47
|
+
escapeRegex(dependencyMapReservedName) + `${WS}\\[${WS}([0-9]+)${WS}\\]`,
|
|
48
|
+
"g"
|
|
49
|
+
);
|
|
50
|
+
const inlinedCode = code.replace(depMapReferenceRegex, (match, depIndex) => {
|
|
51
|
+
const idStr = dependencyIds[Number.parseInt(depIndex, 10)].toString();
|
|
52
|
+
if (idStr.length > match.length) {
|
|
53
|
+
throw new Error(
|
|
54
|
+
`Module ID doesn't fit in available space; add ${idStr.length - match.length} more characters to 'dependencyMapReservedName'.`
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
return idStr.padEnd(match.length);
|
|
58
|
+
});
|
|
59
|
+
return {
|
|
60
|
+
fileId,
|
|
61
|
+
moduleCode: inlinedCode,
|
|
62
|
+
moduleMap: map
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
const babelConfig = {
|
|
66
|
+
ast: true,
|
|
67
|
+
babelrc: false,
|
|
68
|
+
browserslistConfigFile: false,
|
|
69
|
+
code: false,
|
|
70
|
+
configFile: false,
|
|
71
|
+
plugins: [...passthroughSyntaxPlugins, [reverseDependencyMapReferences, { dependencyIds, globalPrefix }]]
|
|
72
|
+
};
|
|
73
|
+
const sourceAst = isTypeScriptSource(path) || isTSXSource(path) || !hermesParser ? parseSync(code, babelConfig) : require("hermes-parser").parse(code, {
|
|
74
|
+
babel: true,
|
|
75
|
+
// $FlowFixMe[prop-missing]
|
|
76
|
+
sourceType: babelConfig.sourceType
|
|
77
|
+
});
|
|
78
|
+
const ast = nullthrows(transformFromAstSync(sourceAst, code, babelConfig).ast);
|
|
79
|
+
const { code: generatedCode, map: generatedMap } = generate(ast, path, "");
|
|
80
|
+
return {
|
|
81
|
+
fileId,
|
|
82
|
+
moduleCode: generatedCode,
|
|
83
|
+
moduleMap: map && generatedMap && mergeSourceMaps(path, map, generatedMap)
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function inlineModuleIdsAndAddParamsToDefineCall(module2, idForPath, options) {
|
|
87
|
+
const { fileId, moduleCode, moduleMap } = inlineModuleIds(module2, idForPath, options);
|
|
88
|
+
return { moduleCode: addParamsToDefineCall(moduleCode, fileId), moduleMap };
|
|
89
|
+
}
|
|
90
|
+
exports.inlineModuleIds = inlineModuleIds;
|
|
91
|
+
exports.inlineModuleIdsAndAddParamsToDefineCall = inlineModuleIdsAndAddParamsToDefineCall;
|
|
92
|
+
function escapeRegex(str) {
|
|
93
|
+
return str.replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1");
|
|
94
|
+
}
|
|
95
|
+
function getModuleCodeAndMap(module2, idForPath, options) {
|
|
96
|
+
const { file } = module2;
|
|
97
|
+
let moduleCode, moduleMap;
|
|
98
|
+
if (file.type !== "module") {
|
|
99
|
+
moduleCode = file.code;
|
|
100
|
+
moduleMap = file.map;
|
|
101
|
+
} else if (!options.enableIDInlining) {
|
|
102
|
+
moduleCode = addModuleIdsToModuleWrapper(module2, idForPath);
|
|
103
|
+
moduleMap = file.map;
|
|
104
|
+
} else {
|
|
105
|
+
({ moduleCode, moduleMap } = inlineModuleIdsAndAddParamsToDefineCall(module2, idForPath, {
|
|
106
|
+
dependencyMapReservedName: options.dependencyMapReservedName,
|
|
107
|
+
globalPrefix: options.globalPrefix
|
|
108
|
+
}));
|
|
109
|
+
}
|
|
110
|
+
if (moduleMap && moduleMap.sources) {
|
|
111
|
+
const x_facebook_sources = [];
|
|
112
|
+
if (moduleMap.sources.length >= 1) {
|
|
113
|
+
x_facebook_sources.push([module2.file.functionMap]);
|
|
114
|
+
}
|
|
115
|
+
moduleMap = { ...moduleMap, x_facebook_sources };
|
|
116
|
+
}
|
|
117
|
+
return { moduleCode, moduleMap };
|
|
118
|
+
}
|
|
119
|
+
exports.getModuleCodeAndMap = getModuleCodeAndMap;
|
|
120
|
+
exports.concat = function* concat(...iterables) {
|
|
121
|
+
for (const it of iterables) {
|
|
122
|
+
yield* it;
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
exports.createIdForPathFn = () => {
|
|
126
|
+
const seen = /* @__PURE__ */ new Map();
|
|
127
|
+
let next = 0;
|
|
128
|
+
return ({ path }) => {
|
|
129
|
+
let id = seen.get(path);
|
|
130
|
+
if (id == null) {
|
|
131
|
+
id = next++;
|
|
132
|
+
seen.set(path, id);
|
|
133
|
+
}
|
|
134
|
+
return id;
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
exports.requireCallsTo = function* (modules, idForPath, getRunModuleStatement) {
|
|
138
|
+
for (const module2 of modules) {
|
|
139
|
+
const id = idForPath(module2.file);
|
|
140
|
+
yield virtualModule(getRunModuleStatement(id), `/<generated>/require-${id}.js`);
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
exports.partition = (modules, preloadedModules) => {
|
|
144
|
+
const startup = [];
|
|
145
|
+
const deferred = [];
|
|
146
|
+
for (const module2 of modules) {
|
|
147
|
+
(preloadedModules.has(module2.file.path) ? startup : deferred).push(module2);
|
|
148
|
+
}
|
|
149
|
+
return [startup, deferred];
|
|
150
|
+
};
|
|
151
|
+
function toModuleTransport(module2, idsForPath, { dependencyMapReservedName, globalPrefix }) {
|
|
152
|
+
const { dependencies, file } = module2;
|
|
153
|
+
const { moduleCode, moduleMap } = getModuleCodeAndMap(module2, (x) => idsForPath(x).moduleId, {
|
|
154
|
+
dependencyMapReservedName,
|
|
155
|
+
enableIDInlining: true,
|
|
156
|
+
globalPrefix
|
|
157
|
+
});
|
|
158
|
+
return {
|
|
159
|
+
code: moduleCode,
|
|
160
|
+
dependencies,
|
|
161
|
+
// ID is required but we provide an invalid one for "script"s.
|
|
162
|
+
id: file.type === "module" ? nullthrows(idsForPath(file).localId) : -1,
|
|
163
|
+
map: moduleMap,
|
|
164
|
+
name: file.path,
|
|
165
|
+
sourcePath: file.path
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
exports.toModuleTransport = toModuleTransport;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
+
}
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var import_template = __toESM(require("@babel/template"));
|
|
25
|
+
var import_traverse = __toESM(require("@babel/traverse"));
|
|
26
|
+
var t = __toESM(require("@babel/types"));
|
|
27
|
+
var import_invariant = __toESM(require("invariant"));
|
|
28
|
+
const WRAP_NAME = "$$_REQUIRE";
|
|
29
|
+
const IIFE_PARAM = import_template.default.expression(
|
|
30
|
+
"typeof globalThis !== 'undefined' ? globalThis : typeof global !== 'undefined' ? global : typeof window !== 'undefined' ? window : this"
|
|
31
|
+
);
|
|
32
|
+
function wrapModule(fileAst, importDefaultName, importAllName, dependencyMapName, globalPrefix) {
|
|
33
|
+
const params = buildParameters(importDefaultName, importAllName, dependencyMapName);
|
|
34
|
+
const factory = functionFromProgram(fileAst.program, params);
|
|
35
|
+
const def = t.callExpression(t.identifier(`${globalPrefix}__d`), [factory]);
|
|
36
|
+
const ast = t.file(t.program([t.expressionStatement(def)]));
|
|
37
|
+
const requireName = renameRequires(ast);
|
|
38
|
+
return { ast, requireName };
|
|
39
|
+
}
|
|
40
|
+
function wrapPolyfill(fileAst) {
|
|
41
|
+
const factory = functionFromProgram(fileAst.program, ["global"]);
|
|
42
|
+
const iife = t.callExpression(factory, [IIFE_PARAM()]);
|
|
43
|
+
return t.file(t.program([t.expressionStatement(iife)]));
|
|
44
|
+
}
|
|
45
|
+
function jsonToCommonJS(source) {
|
|
46
|
+
return `module.exports = ${source};`;
|
|
47
|
+
}
|
|
48
|
+
function wrapJson(source, globalPrefix) {
|
|
49
|
+
const moduleFactoryParameters = buildParameters("_importDefaultUnused", "_importAllUnused", "_dependencyMapUnused");
|
|
50
|
+
return [
|
|
51
|
+
`${globalPrefix}__d(function(${moduleFactoryParameters.join(", ")}) {`,
|
|
52
|
+
` ${jsonToCommonJS(source)}`,
|
|
53
|
+
"});"
|
|
54
|
+
].join("\n");
|
|
55
|
+
}
|
|
56
|
+
function functionFromProgram(program, parameters) {
|
|
57
|
+
return t.functionExpression(
|
|
58
|
+
void 0,
|
|
59
|
+
parameters.map(makeIdentifier),
|
|
60
|
+
t.blockStatement(program.body, program.directives)
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
function makeIdentifier(name) {
|
|
64
|
+
return t.identifier(name);
|
|
65
|
+
}
|
|
66
|
+
function buildParameters(importDefaultName, importAllName, dependencyMapName) {
|
|
67
|
+
return ["global", "require", importDefaultName, importAllName, "module", "exports", dependencyMapName];
|
|
68
|
+
}
|
|
69
|
+
function renameRequires(ast) {
|
|
70
|
+
let newRequireName = WRAP_NAME;
|
|
71
|
+
(0, import_traverse.default)(ast, {
|
|
72
|
+
Program(path) {
|
|
73
|
+
const body = path.get("body.0.expression.arguments.0.body");
|
|
74
|
+
(0, import_invariant.default)(!Array.isArray(body), "metro: Expected `body` to be a single path.");
|
|
75
|
+
newRequireName = body.scope.generateUid(WRAP_NAME);
|
|
76
|
+
body.scope.rename("require", newRequireName);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
return newRequireName;
|
|
80
|
+
}
|
|
81
|
+
module.exports = {
|
|
82
|
+
WRAP_NAME,
|
|
83
|
+
wrapJson,
|
|
84
|
+
jsonToCommonJS,
|
|
85
|
+
wrapModule,
|
|
86
|
+
wrapPolyfill
|
|
87
|
+
};
|