@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,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;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const chalk = require("chalk");
|
|
3
|
+
const util = require("util");
|
|
4
|
+
const groupStack = [];
|
|
5
|
+
let collapsedGuardTimer;
|
|
6
|
+
module.exports = (terminal, level, mode, ...data) => {
|
|
7
|
+
const logFunction = console[level] && level !== "trace" ? level : "log";
|
|
8
|
+
const color = level === "error" ? chalk.inverse.red : level === "warn" ? chalk.inverse.yellow : chalk.inverse.white;
|
|
9
|
+
if (level === "group") {
|
|
10
|
+
groupStack.push(level);
|
|
11
|
+
} else if (level === "groupCollapsed") {
|
|
12
|
+
groupStack.push(level);
|
|
13
|
+
clearTimeout(collapsedGuardTimer);
|
|
14
|
+
collapsedGuardTimer = setTimeout(() => {
|
|
15
|
+
if (groupStack.includes("groupCollapsed")) {
|
|
16
|
+
terminal.log(
|
|
17
|
+
chalk.inverse.yellow.bold(" WARN "),
|
|
18
|
+
"Expected `console.groupEnd` to be called after `console.groupCollapsed`."
|
|
19
|
+
);
|
|
20
|
+
groupStack.length = 0;
|
|
21
|
+
}
|
|
22
|
+
}, 3e3);
|
|
23
|
+
return;
|
|
24
|
+
} else if (level === "groupEnd") {
|
|
25
|
+
groupStack.pop();
|
|
26
|
+
if (!groupStack.length) {
|
|
27
|
+
clearTimeout(collapsedGuardTimer);
|
|
28
|
+
}
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (!groupStack.includes("groupCollapsed")) {
|
|
32
|
+
const lastItem = data[data.length - 1];
|
|
33
|
+
if (typeof lastItem === "string") {
|
|
34
|
+
data[data.length - 1] = lastItem.trimEnd();
|
|
35
|
+
}
|
|
36
|
+
const modePrefix = !mode || mode == "BRIDGE" ? "" : `(${mode.toUpperCase()}) `;
|
|
37
|
+
terminal.log(
|
|
38
|
+
color.bold(` ${modePrefix}${logFunction.toUpperCase()} `) + "".padEnd(groupStack.length * 2, " "),
|
|
39
|
+
// `util.format` actually accepts any arguments.
|
|
40
|
+
// If the first argument is a string, it tries to format it.
|
|
41
|
+
// Otherwise, it just concatenates all arguments.
|
|
42
|
+
// $FlowIssue[incompatible-call] util.format expected the first argument to be a string
|
|
43
|
+
util.format(...data)
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const nullthrows = require("nullthrows");
|
|
3
|
+
const PREFIX = "resolver.";
|
|
4
|
+
module.exports = function parseCustomResolverOptions(urlObj) {
|
|
5
|
+
const customResolverOptions = /* @__PURE__ */ Object.create(null);
|
|
6
|
+
const query = nullthrows(urlObj.query);
|
|
7
|
+
Object.keys(query).forEach((key) => {
|
|
8
|
+
if (key.startsWith(PREFIX)) {
|
|
9
|
+
customResolverOptions[key.substr(PREFIX.length)] = query[key];
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
return customResolverOptions;
|
|
13
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const nullthrows = require("nullthrows");
|
|
3
|
+
const PREFIX = "transform.";
|
|
4
|
+
module.exports = function parseCustomTransformOptions(urlObj) {
|
|
5
|
+
const customTransformOptions = /* @__PURE__ */ Object.create(null);
|
|
6
|
+
const query = nullthrows(urlObj.query);
|
|
7
|
+
Object.keys(query).forEach((key) => {
|
|
8
|
+
if (key.startsWith(PREFIX)) {
|
|
9
|
+
customTransformOptions[key.substr(PREFIX.length)] = query[key];
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
return customTransformOptions;
|
|
13
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const parsePlatformFilePath = require("../node-haste/lib/parsePlatformFilePath");
|
|
3
|
+
const parseCustomResolverOptions = require("./parseCustomResolverOptions");
|
|
4
|
+
const parseCustomTransformOptions = require("./parseCustomTransformOptions");
|
|
5
|
+
const nullthrows = require("nullthrows");
|
|
6
|
+
const path = require("path");
|
|
7
|
+
const url = require("url");
|
|
8
|
+
const getBoolean = (query, opt, defaultValue) => query[opt] == null ? defaultValue : query[opt] === "true" || query[opt] === "1";
|
|
9
|
+
const getNumber = (query, opt, defaultValue) => {
|
|
10
|
+
const number = parseInt(query[opt], 10);
|
|
11
|
+
return Number.isNaN(number) ? defaultValue : number;
|
|
12
|
+
};
|
|
13
|
+
const getBundleType = (bundleType) => bundleType === "map" ? bundleType : "bundle";
|
|
14
|
+
const getTransformProfile = (transformProfile) => transformProfile === "hermes-stable" || transformProfile === "hermes-canary" ? transformProfile : "default";
|
|
15
|
+
module.exports = function parseOptionsFromUrl(requestUrl, platforms, bytecodeVersion) {
|
|
16
|
+
const parsedURL = nullthrows(url.parse(requestUrl, true));
|
|
17
|
+
const query = nullthrows(parsedURL.query);
|
|
18
|
+
const pathname = query.bundleEntry || (parsedURL.pathname != null ? decodeURIComponent(parsedURL.pathname) : "");
|
|
19
|
+
const platform = query.platform || parsePlatformFilePath(pathname, platforms).platform;
|
|
20
|
+
const bundleType = getBundleType(path.extname(pathname).substr(1));
|
|
21
|
+
const runtimeBytecodeVersion = getNumber(query, "runtimeBytecodeVersion", null);
|
|
22
|
+
return {
|
|
23
|
+
bundleType,
|
|
24
|
+
runtimeBytecodeVersion: bytecodeVersion === runtimeBytecodeVersion ? bytecodeVersion : null,
|
|
25
|
+
customResolverOptions: parseCustomResolverOptions(parsedURL),
|
|
26
|
+
customTransformOptions: parseCustomTransformOptions(parsedURL),
|
|
27
|
+
dev: getBoolean(query, "dev", true),
|
|
28
|
+
entryFile: pathname.replace(/^(?:\.?\/)?/, "./").replace(/\.[^/.]+$/, ""),
|
|
29
|
+
excludeSource: getBoolean(query, "excludeSource", false),
|
|
30
|
+
hot: true,
|
|
31
|
+
inlineSourceMap: getBoolean(query, "inlineSourceMap", false),
|
|
32
|
+
minify: getBoolean(query, "minify", false),
|
|
33
|
+
modulesOnly: getBoolean(query, "modulesOnly", false),
|
|
34
|
+
onProgress: null,
|
|
35
|
+
platform,
|
|
36
|
+
runModule: getBoolean(query, "runModule", true),
|
|
37
|
+
shallow: getBoolean(query, "shallow", false),
|
|
38
|
+
sourceMapUrl: url.format({
|
|
39
|
+
...parsedURL,
|
|
40
|
+
// The Chrome Debugger loads bundles via Blob urls, whose
|
|
41
|
+
// protocol is blob:http. This breaks loading source maps through
|
|
42
|
+
// protocol-relative URLs, which is why we must force the HTTP protocol
|
|
43
|
+
// when loading the bundle for either Android or iOS.
|
|
44
|
+
protocol: platform != null && platform.match(/^(android|ios)$/) ? "http" : "",
|
|
45
|
+
pathname: pathname.replace(/\.(bundle|delta)$/, ".map")
|
|
46
|
+
}),
|
|
47
|
+
sourceUrl: requestUrl,
|
|
48
|
+
unstable_transformProfile: getTransformProfile(query.unstable_transformProfile)
|
|
49
|
+
};
|
|
50
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const path = require("path");
|
|
3
|
+
function relativizeSourceMapInline(sourceMap, sourcesRoot) {
|
|
4
|
+
if (sourceMap.mappings === void 0) {
|
|
5
|
+
for (let i = 0; i < sourceMap.sections.length; i++) {
|
|
6
|
+
relativizeSourceMapInline(sourceMap.sections[i].map, sourcesRoot);
|
|
7
|
+
}
|
|
8
|
+
} else {
|
|
9
|
+
for (let i = 0; i < sourceMap.sources.length; i++) {
|
|
10
|
+
sourceMap.sources[i] = path.relative(sourcesRoot, sourceMap.sources[i]);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
module.exports = relativizeSourceMapInline;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const chalk = require("chalk");
|
|
3
|
+
const stripAnsi = require("strip-ansi");
|
|
4
|
+
const util = require("util");
|
|
5
|
+
function logWarning(terminal, format, ...args) {
|
|
6
|
+
const str = util.format(format, ...args);
|
|
7
|
+
terminal.log("%s: %s", chalk.yellow("warning"), str);
|
|
8
|
+
}
|
|
9
|
+
function logError(terminal, format, ...args) {
|
|
10
|
+
terminal.log(
|
|
11
|
+
"%s: %s",
|
|
12
|
+
chalk.red("error"),
|
|
13
|
+
// Syntax errors may have colors applied for displaying code frames
|
|
14
|
+
// in various places outside of where Metro is currently running.
|
|
15
|
+
// If the current terminal does not support color, we'll strip the colors
|
|
16
|
+
// here.
|
|
17
|
+
util.format(chalk.supportsColor ? format : stripAnsi(format), ...args)
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
const nullReporter = { update() {
|
|
21
|
+
} };
|
|
22
|
+
module.exports = {
|
|
23
|
+
logWarning,
|
|
24
|
+
logError,
|
|
25
|
+
nullReporter
|
|
26
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
function splitBundleOptions(options) {
|
|
3
|
+
return {
|
|
4
|
+
entryFile: options.entryFile,
|
|
5
|
+
resolverOptions: {
|
|
6
|
+
customResolverOptions: options.customResolverOptions
|
|
7
|
+
},
|
|
8
|
+
transformOptions: {
|
|
9
|
+
customTransformOptions: options.customTransformOptions,
|
|
10
|
+
dev: options.dev,
|
|
11
|
+
hot: options.hot,
|
|
12
|
+
minify: options.minify,
|
|
13
|
+
platform: options.platform,
|
|
14
|
+
runtimeBytecodeVersion: options.runtimeBytecodeVersion,
|
|
15
|
+
type: "module",
|
|
16
|
+
unstable_transformProfile: options.unstable_transformProfile
|
|
17
|
+
},
|
|
18
|
+
serializerOptions: {
|
|
19
|
+
excludeSource: options.excludeSource,
|
|
20
|
+
inlineSourceMap: options.inlineSourceMap,
|
|
21
|
+
modulesOnly: options.modulesOnly,
|
|
22
|
+
runModule: options.runModule,
|
|
23
|
+
sourceMapUrl: options.sourceMapUrl,
|
|
24
|
+
sourceUrl: options.sourceUrl
|
|
25
|
+
},
|
|
26
|
+
graphOptions: {
|
|
27
|
+
shallow: options.shallow
|
|
28
|
+
},
|
|
29
|
+
onProgress: options.onProgress
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
module.exports = splitBundleOptions;
|