@granite-js/mpack 0.0.0-dev-20250725013859
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/LICENSE +202 -0
- package/README.md +24 -0
- package/dist/bundler/Bundler.d.ts +24 -0
- package/dist/bundler/Bundler.js +180 -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/internal/presets.d.ts +18 -0
- package/dist/bundler/internal/presets.js +103 -0
- package/dist/bundler/plugins/buildStatusPlugin/buildStatusPlugin.d.ts +12 -0
- package/dist/bundler/plugins/buildStatusPlugin/buildStatusPlugin.js +74 -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 +16 -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 +10 -0
- package/dist/index.js +56 -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 +27 -0
- package/dist/metro/getMetroConfig.js +137 -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 +10 -0
- package/dist/metro/runBuild.js +57 -0
- package/dist/metro/types.d.ts +92 -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 +13 -0
- package/dist/operations/experimental/runServer.js +130 -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 +6 -0
- package/dist/operations/runBundle.js +60 -0
- package/dist/operations/runServer.d.ts +13 -0
- package/dist/operations/runServer.js +131 -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 +26 -0
- package/dist/server/DevServer.js +215 -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 +8 -0
- package/dist/server/helpers/createBundlerForDevServer.js +48 -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 +92 -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 +187 -0
- package/dist/types/BuildConfig.js +16 -0
- package/dist/types/BundlerConfig.d.ts +23 -0
- package/dist/types/BundlerConfig.js +16 -0
- package/dist/types/DevServer.d.ts +10 -0
- package/dist/types/DevServer.js +16 -0
- package/dist/types/Id.d.ts +3 -0
- package/dist/types/Id.js +16 -0
- package/dist/types/Plugin.d.ts +28 -0
- package/dist/types/Plugin.js +16 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.js +30 -0
- package/dist/types/schemas/buildConfigSchema.d.ts +131 -0
- package/dist/types/schemas/buildConfigSchema.js +70 -0
- package/dist/types/schemas/index.d.ts +1 -0
- package/dist/types/schemas/index.js +22 -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 +34 -0
- package/dist/utils/getSourcemapName.d.ts +1 -0
- package/dist/utils/getSourcemapName.js +30 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/index.js +34 -0
- package/dist/utils/isDebugMode.d.ts +1 -0
- package/dist/utils/isDebugMode.js +30 -0
- package/dist/utils/md5.d.ts +1 -0
- package/dist/utils/md5.js +41 -0
- package/dist/utils/mergeBabel.d.ts +2 -0
- package/dist/utils/mergeBabel.js +45 -0
- package/dist/utils/mergeBuildConfigs.d.ts +2 -0
- package/dist/utils/mergeBuildConfigs.js +50 -0
- package/dist/utils/mergeEsbuild.d.ts +2 -0
- package/dist/utils/mergeEsbuild.js +54 -0
- package/dist/utils/mergeExtra.d.ts +1 -0
- package/dist/utils/mergeExtra.js +39 -0
- package/dist/utils/mergeResolver.d.ts +2 -0
- package/dist/utils/mergeResolver.js +45 -0
- package/dist/utils/mergeSwc.d.ts +2 -0
- package/dist/utils/mergeSwc.js +43 -0
- package/dist/utils/mergeTransformer.d.ts +2 -0
- package/dist/utils/mergeTransformer.js +69 -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/ReportableEvent.d.ts +152 -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 +429 -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 +163 -0
|
@@ -0,0 +1,73 @@
|
|
|
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 __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var contextModule_exports = {};
|
|
30
|
+
__export(contextModule_exports, {
|
|
31
|
+
deriveAbsolutePathFromContext: () => deriveAbsolutePathFromContext,
|
|
32
|
+
fileMatchesContext: () => fileMatchesContext
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(contextModule_exports);
|
|
35
|
+
var import_crypto = __toESM(require("crypto"));
|
|
36
|
+
var import_path = __toESM(require("path"));
|
|
37
|
+
var import_nullthrows = __toESM(require("nullthrows"));
|
|
38
|
+
function toHash(value) {
|
|
39
|
+
return import_crypto.default.createHash("sha1").update(value).digest("hex");
|
|
40
|
+
}
|
|
41
|
+
function deriveAbsolutePathFromContext(from, context) {
|
|
42
|
+
const filePath = from.endsWith(import_path.default.sep) ? from.slice(0, -1) : from;
|
|
43
|
+
return filePath + "?ctx=" + toHash(
|
|
44
|
+
[
|
|
45
|
+
context.mode,
|
|
46
|
+
context.recursive ? "recursive" : "",
|
|
47
|
+
new RegExp(context.filter.pattern, context.filter.flags).toString()
|
|
48
|
+
].filter(Boolean).join(" ")
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
function fileMatchesContext(testPath, context) {
|
|
52
|
+
const filePath = import_path.default.relative((0, import_nullthrows.default)(context.from), testPath);
|
|
53
|
+
const filter = context.filter;
|
|
54
|
+
if (
|
|
55
|
+
// Ignore everything outside of the provided `root`.
|
|
56
|
+
!(filePath && !filePath.startsWith("..")) || // Prevent searching in child directories during a non-recursive search.
|
|
57
|
+
!context.recursive && filePath.includes(import_path.default.sep) || // Test against the filter.
|
|
58
|
+
!filter.test(
|
|
59
|
+
// NOTE(EvanBacon): Ensure files start with `./` for matching purposes
|
|
60
|
+
// this ensures packages work across Metro and Webpack (ex: Storybook for React DOM / React Native).
|
|
61
|
+
// `a/b.js` -> `./a/b.js`
|
|
62
|
+
"./" + filePath.replace(/\\/g, "/")
|
|
63
|
+
)
|
|
64
|
+
) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
70
|
+
0 && (module.exports = {
|
|
71
|
+
deriveAbsolutePathFromContext,
|
|
72
|
+
fileMatchesContext
|
|
73
|
+
});
|
|
@@ -0,0 +1,116 @@
|
|
|
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 __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var contextModuleTemplates_exports = {};
|
|
30
|
+
__export(contextModuleTemplates_exports, {
|
|
31
|
+
getContextModuleTemplate: () => getContextModuleTemplate
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(contextModuleTemplates_exports);
|
|
34
|
+
var path = __toESM(require("path"));
|
|
35
|
+
function createFileMap(modulePath, files, processModule) {
|
|
36
|
+
let mapString = "\n";
|
|
37
|
+
files.slice().sort().forEach((file) => {
|
|
38
|
+
let filePath = path.relative(modulePath, file);
|
|
39
|
+
if (!filePath.startsWith(".")) {
|
|
40
|
+
filePath = `.${path.sep}` + filePath;
|
|
41
|
+
}
|
|
42
|
+
const key = JSON.stringify(filePath);
|
|
43
|
+
mapString += ` ${key}: { enumerable: true, get() { return ${processModule(file)}; } },
|
|
44
|
+
`;
|
|
45
|
+
});
|
|
46
|
+
return `Object.defineProperties({}, {${mapString}})`;
|
|
47
|
+
}
|
|
48
|
+
function getEmptyContextModuleTemplate(modulePath) {
|
|
49
|
+
return `
|
|
50
|
+
function metroEmptyContext(request) {
|
|
51
|
+
let e = new Error('No modules in context');
|
|
52
|
+
e.code = 'MODULE_NOT_FOUND';
|
|
53
|
+
throw e;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Return the keys that can be resolved.
|
|
57
|
+
metroEmptyContext.keys = () => ([]);
|
|
58
|
+
|
|
59
|
+
// Return the module identifier for a user request.
|
|
60
|
+
metroEmptyContext.resolve = function metroContextResolve(request) {
|
|
61
|
+
throw new Error('Unimplemented Metro module context functionality');
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
module.exports = metroEmptyContext;`;
|
|
65
|
+
}
|
|
66
|
+
function getLoadableContextModuleTemplate(modulePath, files, importSyntax, getContextTemplate) {
|
|
67
|
+
return `// All of the requested modules are loaded behind enumerable getters.
|
|
68
|
+
const map = ${createFileMap(modulePath, files, (moduleId) => `${importSyntax}(${JSON.stringify(moduleId)})`)};
|
|
69
|
+
|
|
70
|
+
function metroContext(request) {
|
|
71
|
+
${getContextTemplate}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Return the keys that can be resolved.
|
|
75
|
+
metroContext.keys = function metroContextKeys() {
|
|
76
|
+
return Object.keys(map);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// Return the module identifier for a user request.
|
|
80
|
+
metroContext.resolve = function metroContextResolve(request) {
|
|
81
|
+
throw new Error('Unimplemented Metro module context functionality');
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
module.exports = metroContext;`;
|
|
85
|
+
}
|
|
86
|
+
function getContextModuleTemplate(mode, modulePath, files) {
|
|
87
|
+
if (!files.length) {
|
|
88
|
+
return getEmptyContextModuleTemplate(modulePath);
|
|
89
|
+
}
|
|
90
|
+
switch (mode) {
|
|
91
|
+
case "eager":
|
|
92
|
+
return getLoadableContextModuleTemplate(
|
|
93
|
+
modulePath,
|
|
94
|
+
files,
|
|
95
|
+
// NOTE(EvanBacon): It's unclear if we should use `import` or `require` here so sticking
|
|
96
|
+
// with the more stable option (`require`) for now.
|
|
97
|
+
"require",
|
|
98
|
+
[
|
|
99
|
+
" // Here Promise.resolve().then() is used instead of new Promise() to prevent",
|
|
100
|
+
" // uncaught exception popping up in devtools",
|
|
101
|
+
" return Promise.resolve().then(() => map[request]);"
|
|
102
|
+
].join("\n")
|
|
103
|
+
);
|
|
104
|
+
case "sync":
|
|
105
|
+
return getLoadableContextModuleTemplate(modulePath, files, "require", " return map[request];");
|
|
106
|
+
case "lazy":
|
|
107
|
+
case "lazy-once":
|
|
108
|
+
return getLoadableContextModuleTemplate(modulePath, files, "import", " return map[request];");
|
|
109
|
+
default:
|
|
110
|
+
throw new Error(`Metro context mode "${mode}" is unimplemented`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
114
|
+
0 && (module.exports = {
|
|
115
|
+
getContextModuleTemplate
|
|
116
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
function createModuleIdFactory() {
|
|
3
|
+
const fileToIdMap = /* @__PURE__ */ new Map();
|
|
4
|
+
let nextId = 0;
|
|
5
|
+
return (path) => {
|
|
6
|
+
let id = fileToIdMap.get(path);
|
|
7
|
+
if (typeof id !== "number") {
|
|
8
|
+
id = nextId++;
|
|
9
|
+
fileToIdMap.set(path, id);
|
|
10
|
+
}
|
|
11
|
+
return id;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
module.exports = createModuleIdFactory;
|
|
@@ -0,0 +1,54 @@
|
|
|
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_ws = __toESM(require("ws"));
|
|
25
|
+
module.exports = function createWebsocketServer({ websocketServer }) {
|
|
26
|
+
const wss = new import_ws.default.Server({
|
|
27
|
+
noServer: true
|
|
28
|
+
});
|
|
29
|
+
wss.on("connection", async (ws2, req) => {
|
|
30
|
+
let connected = true;
|
|
31
|
+
const url = req.url;
|
|
32
|
+
const sendFn = (...args) => {
|
|
33
|
+
if (connected) {
|
|
34
|
+
ws2.send(...args);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
const client = await websocketServer.onClientConnect(url, sendFn);
|
|
38
|
+
if (client == null) {
|
|
39
|
+
ws2.close();
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
ws2.on("error", (e) => {
|
|
43
|
+
websocketServer.onClientError && websocketServer.onClientError(client, e);
|
|
44
|
+
});
|
|
45
|
+
ws2.on("close", () => {
|
|
46
|
+
websocketServer.onClientDisconnect && websocketServer.onClientDisconnect(client);
|
|
47
|
+
connected = false;
|
|
48
|
+
});
|
|
49
|
+
ws2.on("message", (message) => {
|
|
50
|
+
websocketServer.onClientMessage && websocketServer.onClientMessage(client, message, sendFn);
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
return wss;
|
|
54
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
function debounceAsyncQueue(fn, delay) {
|
|
3
|
+
let timeout;
|
|
4
|
+
let waiting = false;
|
|
5
|
+
let executing = false;
|
|
6
|
+
let callbacks = [];
|
|
7
|
+
async function execute() {
|
|
8
|
+
const currentCallbacks = callbacks;
|
|
9
|
+
callbacks = [];
|
|
10
|
+
executing = true;
|
|
11
|
+
const res = await fn();
|
|
12
|
+
currentCallbacks.forEach((c) => c(res));
|
|
13
|
+
executing = false;
|
|
14
|
+
if (callbacks.length > 0) {
|
|
15
|
+
await execute();
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return () => new Promise((resolve, reject) => {
|
|
19
|
+
callbacks.push(resolve);
|
|
20
|
+
if (!executing) {
|
|
21
|
+
if (waiting) {
|
|
22
|
+
clearTimeout(timeout);
|
|
23
|
+
} else {
|
|
24
|
+
waiting = true;
|
|
25
|
+
}
|
|
26
|
+
timeout = setTimeout(async () => {
|
|
27
|
+
waiting = false;
|
|
28
|
+
await execute();
|
|
29
|
+
}, delay);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
module.exports = debounceAsyncQueue;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const GraphNotFoundError = require("../IncrementalBundler/GraphNotFoundError");
|
|
3
|
+
const ResourceNotFoundError = require("../IncrementalBundler/ResourceNotFoundError");
|
|
4
|
+
const RevisionNotFoundError = require("../IncrementalBundler/RevisionNotFoundError");
|
|
5
|
+
const { UnableToResolveError } = require("../node-haste/DependencyGraph/ModuleResolution");
|
|
6
|
+
const { codeFrameColumns } = require("@babel/code-frame");
|
|
7
|
+
const ErrorStackParser = require("error-stack-parser");
|
|
8
|
+
const fs = require("fs");
|
|
9
|
+
const { AmbiguousModuleResolutionError } = require("../../../metro-core/src");
|
|
10
|
+
const serializeError = require("serialize-error");
|
|
11
|
+
function formatBundlingError(error) {
|
|
12
|
+
if (error instanceof AmbiguousModuleResolutionError) {
|
|
13
|
+
const he = error.hasteError;
|
|
14
|
+
const message = `Ambiguous resolution: module '${error.fromModulePath}' tries to require '${he.hasteName}', but there are several files providing this module. You can delete or fix them:
|
|
15
|
+
|
|
16
|
+
` + Object.keys(he.duplicatesSet).sort().map((dupFilePath) => `${dupFilePath}`).join("\n\n");
|
|
17
|
+
return {
|
|
18
|
+
type: "AmbiguousModuleResolutionError",
|
|
19
|
+
message,
|
|
20
|
+
errors: [{ description: message }]
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
if (error instanceof UnableToResolveError || error instanceof Error && (error.type === "TransformError" || error.type === "NotFoundError")) {
|
|
24
|
+
error.errors = [
|
|
25
|
+
{
|
|
26
|
+
description: error.message,
|
|
27
|
+
filename: error.filename,
|
|
28
|
+
lineNumber: error.lineNumber
|
|
29
|
+
}
|
|
30
|
+
];
|
|
31
|
+
return serializeError(error);
|
|
32
|
+
} else if (error instanceof ResourceNotFoundError) {
|
|
33
|
+
return {
|
|
34
|
+
type: "ResourceNotFoundError",
|
|
35
|
+
errors: [],
|
|
36
|
+
message: error.message
|
|
37
|
+
};
|
|
38
|
+
} else if (error instanceof GraphNotFoundError) {
|
|
39
|
+
return {
|
|
40
|
+
type: "GraphNotFoundError",
|
|
41
|
+
errors: [],
|
|
42
|
+
message: error.message
|
|
43
|
+
};
|
|
44
|
+
} else if (error instanceof RevisionNotFoundError) {
|
|
45
|
+
return {
|
|
46
|
+
type: "RevisionNotFoundError",
|
|
47
|
+
errors: [],
|
|
48
|
+
message: error.message
|
|
49
|
+
};
|
|
50
|
+
} else {
|
|
51
|
+
const stack = ErrorStackParser.parse(error);
|
|
52
|
+
const fileName = stack[0].fileName;
|
|
53
|
+
const column = stack[0].columnNumber;
|
|
54
|
+
const line = stack[0].lineNumber;
|
|
55
|
+
let codeFrame = "";
|
|
56
|
+
try {
|
|
57
|
+
codeFrame = codeFrameColumns(
|
|
58
|
+
// If the error was thrown in a node.js builtin module, this call will fail and mask the real error.
|
|
59
|
+
fs.readFileSync(fileName, "utf8"),
|
|
60
|
+
{
|
|
61
|
+
start: { column, line }
|
|
62
|
+
},
|
|
63
|
+
{ forceColor: true }
|
|
64
|
+
);
|
|
65
|
+
} catch {
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
type: "InternalError",
|
|
69
|
+
errors: [],
|
|
70
|
+
message: `Metro has encountered an error: ${error.message}: ${fileName} (${line}:${column})
|
|
71
|
+
|
|
72
|
+
${codeFrame}`
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
module.exports = formatBundlingError;
|
|
@@ -0,0 +1,131 @@
|
|
|
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_CountingSet = __toESM(require("./CountingSet"));
|
|
25
|
+
const getInlineSourceMappingURL = require("../DeltaBundler/Serializers/helpers/getInlineSourceMappingURL");
|
|
26
|
+
const sourceMapString = require("../DeltaBundler/Serializers/sourceMapString");
|
|
27
|
+
const countLines = require("./countLines");
|
|
28
|
+
const nullthrows = require("nullthrows");
|
|
29
|
+
const path = require("path");
|
|
30
|
+
function getAppendScripts(entryPoint, modules, importBundleNames, options) {
|
|
31
|
+
const output = [];
|
|
32
|
+
if (importBundleNames.size) {
|
|
33
|
+
const importBundleNamesObject = /* @__PURE__ */ Object.create(null);
|
|
34
|
+
importBundleNames.forEach((absolutePath) => {
|
|
35
|
+
const bundlePath = path.relative(options.serverRoot, absolutePath);
|
|
36
|
+
importBundleNamesObject[options.createModuleId(absolutePath)] = bundlePath.slice(
|
|
37
|
+
0,
|
|
38
|
+
-path.extname(bundlePath).length
|
|
39
|
+
);
|
|
40
|
+
});
|
|
41
|
+
const code = `(function(){var $$=${options.getRunModuleStatement(
|
|
42
|
+
options.createModuleId(options.asyncRequireModulePath)
|
|
43
|
+
)}$$.addImportBundleNames(${String(JSON.stringify(importBundleNamesObject))})})();`;
|
|
44
|
+
output.push({
|
|
45
|
+
path: "$$importBundleNames",
|
|
46
|
+
dependencies: /* @__PURE__ */ new Map(),
|
|
47
|
+
getSource: () => Buffer.from(""),
|
|
48
|
+
inverseDependencies: new import_CountingSet.default(),
|
|
49
|
+
output: [
|
|
50
|
+
{
|
|
51
|
+
type: "js/script/virtual",
|
|
52
|
+
data: {
|
|
53
|
+
code,
|
|
54
|
+
lineCount: countLines(code),
|
|
55
|
+
map: []
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
]
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
if (options.runModule) {
|
|
62
|
+
const paths = [...options.runBeforeMainModule, entryPoint];
|
|
63
|
+
for (const path2 of paths) {
|
|
64
|
+
if (modules.some((module2) => module2.path === path2)) {
|
|
65
|
+
const code = options.getRunModuleStatement(options.createModuleId(path2));
|
|
66
|
+
output.push({
|
|
67
|
+
path: `require-${path2}`,
|
|
68
|
+
dependencies: /* @__PURE__ */ new Map(),
|
|
69
|
+
getSource: () => Buffer.from(""),
|
|
70
|
+
inverseDependencies: new import_CountingSet.default(),
|
|
71
|
+
output: [
|
|
72
|
+
{
|
|
73
|
+
type: "js/script/virtual",
|
|
74
|
+
data: {
|
|
75
|
+
code,
|
|
76
|
+
lineCount: countLines(code),
|
|
77
|
+
map: []
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
]
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (options.inlineSourceMap || options.sourceMapUrl) {
|
|
86
|
+
const sourceMappingURL = options.inlineSourceMap ? getInlineSourceMappingURL(
|
|
87
|
+
sourceMapString(modules, {
|
|
88
|
+
processModuleFilter: () => true,
|
|
89
|
+
excludeSource: false
|
|
90
|
+
})
|
|
91
|
+
) : nullthrows(options.sourceMapUrl);
|
|
92
|
+
const code = `//# sourceMappingURL=${sourceMappingURL}`;
|
|
93
|
+
output.push({
|
|
94
|
+
path: "source-map",
|
|
95
|
+
dependencies: /* @__PURE__ */ new Map(),
|
|
96
|
+
getSource: () => Buffer.from(""),
|
|
97
|
+
inverseDependencies: new import_CountingSet.default(),
|
|
98
|
+
output: [
|
|
99
|
+
{
|
|
100
|
+
type: "js/script/virtual",
|
|
101
|
+
data: {
|
|
102
|
+
code,
|
|
103
|
+
lineCount: countLines(code),
|
|
104
|
+
map: []
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
]
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
if (options.sourceUrl) {
|
|
111
|
+
const code = `//# sourceURL=${options.sourceUrl}`;
|
|
112
|
+
output.push({
|
|
113
|
+
path: "source-url",
|
|
114
|
+
dependencies: /* @__PURE__ */ new Map(),
|
|
115
|
+
getSource: () => Buffer.from(""),
|
|
116
|
+
inverseDependencies: new import_CountingSet.default(),
|
|
117
|
+
output: [
|
|
118
|
+
{
|
|
119
|
+
type: "js/script/virtual",
|
|
120
|
+
data: {
|
|
121
|
+
code,
|
|
122
|
+
lineCount: countLines(code),
|
|
123
|
+
map: []
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
]
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
return output;
|
|
130
|
+
}
|
|
131
|
+
module.exports = getAppendScripts;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const canonicalize = require("../../../metro-core/src/canonicalize");
|
|
3
|
+
function getGraphId(entryFile, options, { shallow, experimentalImportBundleSupport, unstable_allowRequireContext, resolverOptions }) {
|
|
4
|
+
return JSON.stringify(
|
|
5
|
+
{
|
|
6
|
+
entryFile,
|
|
7
|
+
options: {
|
|
8
|
+
customResolverOptions: resolverOptions.customResolverOptions ?? {},
|
|
9
|
+
customTransformOptions: options.customTransformOptions ?? null,
|
|
10
|
+
dev: options.dev,
|
|
11
|
+
experimentalImportSupport: options.experimentalImportSupport || false,
|
|
12
|
+
hot: options.hot,
|
|
13
|
+
minify: options.minify,
|
|
14
|
+
unstable_disableES6Transforms: options.unstable_disableES6Transforms,
|
|
15
|
+
platform: options.platform != null ? options.platform : null,
|
|
16
|
+
runtimeBytecodeVersion: options.runtimeBytecodeVersion,
|
|
17
|
+
type: options.type,
|
|
18
|
+
experimentalImportBundleSupport,
|
|
19
|
+
unstable_allowRequireContext,
|
|
20
|
+
shallow,
|
|
21
|
+
unstable_transformProfile: options.unstable_transformProfile || "default"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
canonicalize
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
module.exports = getGraphId;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const os = require("os");
|
|
3
|
+
module.exports = (workers) => {
|
|
4
|
+
const cores = os.cpus().length;
|
|
5
|
+
return typeof workers === "number" && Number.isInteger(workers) ? Math.min(cores, workers > 0 ? workers : 1) : Math.max(1, Math.ceil(cores * (0.5 + 0.5 * Math.exp(-cores * 0.07)) - 1));
|
|
6
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
function getPreludeCode({ extraVars, isDev, globalPrefix, requireCycleIgnorePatterns }) {
|
|
3
|
+
const vars = [
|
|
4
|
+
// Ensure these variable names match the ones referenced in metro-runtime
|
|
5
|
+
// require.js
|
|
6
|
+
"__BUNDLE_START_TIME__=this.nativePerformanceNow?nativePerformanceNow():Date.now()",
|
|
7
|
+
`__DEV__=${String(isDev)}`,
|
|
8
|
+
...formatExtraVars(extraVars),
|
|
9
|
+
"process=this.process||{}",
|
|
10
|
+
`__METRO_GLOBAL_PREFIX__='${globalPrefix}'`
|
|
11
|
+
];
|
|
12
|
+
if (isDev) {
|
|
13
|
+
vars.push(
|
|
14
|
+
`${globalPrefix}__requireCycleIgnorePatterns=[${requireCycleIgnorePatterns.map((regex) => regex.toString()).join(",")}]`
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
return `var ${vars.join(",")};${processEnv(isDev ? "development" : "production")}`;
|
|
18
|
+
}
|
|
19
|
+
const excluded = /* @__PURE__ */ new Set(["__BUNDLE_START_TIME__", "__DEV__", "process"]);
|
|
20
|
+
function formatExtraVars(extraVars) {
|
|
21
|
+
const assignments = [];
|
|
22
|
+
for (const key in extraVars) {
|
|
23
|
+
if (extraVars.hasOwnProperty(key) && !excluded.has(key)) {
|
|
24
|
+
assignments.push(`${key}=${JSON.stringify(extraVars[key])}`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return assignments;
|
|
28
|
+
}
|
|
29
|
+
function processEnv(nodeEnv) {
|
|
30
|
+
return `process.env=process.env||{};process.env.NODE_ENV=process.env.NODE_ENV||${JSON.stringify(nodeEnv)};`;
|
|
31
|
+
}
|
|
32
|
+
module.exports = getPreludeCode;
|
|
@@ -0,0 +1,93 @@
|
|
|
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_CountingSet = __toESM(require("./CountingSet"));
|
|
25
|
+
const countLines = require("./countLines");
|
|
26
|
+
const getPreludeCode = require("./getPreludeCode");
|
|
27
|
+
const transformHelpers = require("./transformHelpers");
|
|
28
|
+
const defaults = require("../../../metro-config/src/defaults/defaults");
|
|
29
|
+
async function getPrependedScripts(config, options, resolverOptions, bundler, deltaBundler) {
|
|
30
|
+
const polyfillModuleNames = config.serializer.getPolyfills({
|
|
31
|
+
platform: options.platform
|
|
32
|
+
}).concat(config.serializer.polyfillModuleNames);
|
|
33
|
+
const transformOptions = {
|
|
34
|
+
...options,
|
|
35
|
+
type: "script"
|
|
36
|
+
};
|
|
37
|
+
const dependencies = await deltaBundler.getDependencies([defaults.moduleSystem, ...polyfillModuleNames], {
|
|
38
|
+
resolve: await transformHelpers.getResolveDependencyFn(bundler, options.platform, resolverOptions),
|
|
39
|
+
transform: await transformHelpers.getTransformFn(
|
|
40
|
+
[defaults.moduleSystem, ...polyfillModuleNames],
|
|
41
|
+
bundler,
|
|
42
|
+
deltaBundler,
|
|
43
|
+
config,
|
|
44
|
+
transformOptions,
|
|
45
|
+
resolverOptions
|
|
46
|
+
),
|
|
47
|
+
unstable_allowRequireContext: config.transformer.unstable_allowRequireContext,
|
|
48
|
+
transformOptions,
|
|
49
|
+
onProgress: null,
|
|
50
|
+
experimentalImportBundleSupport: config.transformer.experimentalImportBundleSupport,
|
|
51
|
+
shallow: false
|
|
52
|
+
});
|
|
53
|
+
return [
|
|
54
|
+
_getPrelude({
|
|
55
|
+
dev: options.dev,
|
|
56
|
+
globalPrefix: config.transformer.globalPrefix,
|
|
57
|
+
requireCycleIgnorePatterns: config.resolver.requireCycleIgnorePatterns
|
|
58
|
+
}),
|
|
59
|
+
...dependencies.values()
|
|
60
|
+
];
|
|
61
|
+
}
|
|
62
|
+
function _getPrelude({ dev, globalPrefix, requireCycleIgnorePatterns }) {
|
|
63
|
+
const { compile } = require("metro-hermes-compiler");
|
|
64
|
+
const code = getPreludeCode({
|
|
65
|
+
isDev: dev,
|
|
66
|
+
globalPrefix,
|
|
67
|
+
requireCycleIgnorePatterns
|
|
68
|
+
});
|
|
69
|
+
const name = "__prelude__";
|
|
70
|
+
return {
|
|
71
|
+
dependencies: /* @__PURE__ */ new Map(),
|
|
72
|
+
getSource: () => Buffer.from(code),
|
|
73
|
+
inverseDependencies: new import_CountingSet.default(),
|
|
74
|
+
path: name,
|
|
75
|
+
output: [
|
|
76
|
+
{
|
|
77
|
+
type: "js/script/virtual",
|
|
78
|
+
data: {
|
|
79
|
+
code,
|
|
80
|
+
lineCount: countLines(code),
|
|
81
|
+
map: []
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
type: "bytecode/script/virtual",
|
|
86
|
+
data: {
|
|
87
|
+
bytecode: compile(code, { sourceURL: "__prelude__.virtual.js" }).bytecode
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
]
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
module.exports = getPrependedScripts;
|