@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,440 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const crypto = require("crypto");
|
|
3
|
+
const generate = require("@babel/generator").default;
|
|
4
|
+
const template = require("@babel/template").default;
|
|
5
|
+
const traverse = require("@babel/traverse").default;
|
|
6
|
+
const types = require("@babel/types");
|
|
7
|
+
const invariant = require("invariant");
|
|
8
|
+
const nullthrows = require("nullthrows");
|
|
9
|
+
const { isImport } = types;
|
|
10
|
+
function collectDependencies(ast, options) {
|
|
11
|
+
const visited = /* @__PURE__ */ new WeakSet();
|
|
12
|
+
const state = {
|
|
13
|
+
asyncRequireModulePathStringLiteral: null,
|
|
14
|
+
dependencyCalls: /* @__PURE__ */ new Set(),
|
|
15
|
+
dependencyRegistry: options.dependencyRegistry ?? new DefaultModuleDependencyRegistry(),
|
|
16
|
+
dependencyTransformer: options.dependencyTransformer ?? DefaultDependencyTransformer,
|
|
17
|
+
dependencyMapIdentifier: null,
|
|
18
|
+
dynamicRequires: options.dynamicRequires,
|
|
19
|
+
keepRequireNames: options.keepRequireNames,
|
|
20
|
+
allowOptionalDependencies: options.allowOptionalDependencies,
|
|
21
|
+
unstable_allowRequireContext: options.unstable_allowRequireContext
|
|
22
|
+
};
|
|
23
|
+
const visitor = {
|
|
24
|
+
CallExpression(path, state2) {
|
|
25
|
+
if (visited.has(path.node)) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const callee = path.node.callee;
|
|
29
|
+
const name = callee.type === "Identifier" ? callee.name : null;
|
|
30
|
+
if (isImport(callee)) {
|
|
31
|
+
processImportCall(path, state2, {
|
|
32
|
+
asyncType: "async"
|
|
33
|
+
});
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (name === "__prefetchImport" && !path.scope.getBinding(name)) {
|
|
37
|
+
processImportCall(path, state2, {
|
|
38
|
+
asyncType: "prefetch"
|
|
39
|
+
});
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (name === "__jsResource" && !path.scope.getBinding(name)) {
|
|
43
|
+
processImportCall(path, state2, {
|
|
44
|
+
asyncType: "async",
|
|
45
|
+
jsResource: true
|
|
46
|
+
});
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (name === "__conditionallySplitJSResource" && !path.scope.getBinding(name)) {
|
|
50
|
+
const args = path.get("arguments");
|
|
51
|
+
invariant(Array.isArray(args), "Expected arguments to be an array");
|
|
52
|
+
processImportCall(path, state2, {
|
|
53
|
+
asyncType: "async",
|
|
54
|
+
jsResource: true,
|
|
55
|
+
splitCondition: args[1]
|
|
56
|
+
});
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (
|
|
60
|
+
// Feature gate, defaults to `false`.
|
|
61
|
+
state2.unstable_allowRequireContext && callee.type === "MemberExpression" && // `require`
|
|
62
|
+
callee.object.type === "Identifier" && callee.object.name === "require" && // `context`
|
|
63
|
+
callee.property.type === "Identifier" && callee.property.name === "context" && !callee.computed && // Ensure `require` refers to the global and not something else.
|
|
64
|
+
!path.scope.getBinding("require")
|
|
65
|
+
) {
|
|
66
|
+
processRequireContextCall(path, state2);
|
|
67
|
+
visited.add(path.node);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (name != null && state2.dependencyCalls.has(name) && !path.scope.getBinding(name)) {
|
|
71
|
+
processRequireCall(path, state2);
|
|
72
|
+
visited.add(path.node);
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
ImportDeclaration: collectImports,
|
|
76
|
+
ExportNamedDeclaration: collectImports,
|
|
77
|
+
ExportAllDeclaration: collectImports,
|
|
78
|
+
Program(path, state2) {
|
|
79
|
+
state2.asyncRequireModulePathStringLiteral = types.stringLiteral(options.asyncRequireModulePath);
|
|
80
|
+
if (options.dependencyMapName != null) {
|
|
81
|
+
state2.dependencyMapIdentifier = types.identifier(options.dependencyMapName);
|
|
82
|
+
} else {
|
|
83
|
+
state2.dependencyMapIdentifier = path.scope.generateUidIdentifier("dependencyMap");
|
|
84
|
+
}
|
|
85
|
+
state2.dependencyCalls = /* @__PURE__ */ new Set(["require", ...options.inlineableCalls]);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
traverse(ast, visitor, null, state);
|
|
89
|
+
const collectedDependencies = state.dependencyRegistry.getDependencies();
|
|
90
|
+
const dependencies = new Array(collectedDependencies.length);
|
|
91
|
+
for (const { index, name, ...dependencyData } of collectedDependencies) {
|
|
92
|
+
dependencies[index] = {
|
|
93
|
+
name,
|
|
94
|
+
data: dependencyData
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
ast,
|
|
99
|
+
dependencies,
|
|
100
|
+
dependencyMapName: nullthrows(state.dependencyMapIdentifier).name
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
function getRequireContextArgs(path) {
|
|
104
|
+
const args = path.get("arguments");
|
|
105
|
+
let directory;
|
|
106
|
+
if (!Array.isArray(args) || args.length < 1) {
|
|
107
|
+
throw new InvalidRequireCallError(path);
|
|
108
|
+
} else {
|
|
109
|
+
const result = args[0].evaluate();
|
|
110
|
+
if (result.confident && typeof result.value === "string") {
|
|
111
|
+
directory = result.value;
|
|
112
|
+
} else {
|
|
113
|
+
throw new InvalidRequireCallError(
|
|
114
|
+
result.deopt ?? args[0],
|
|
115
|
+
"First argument of `require.context` should be a string denoting the directory to require."
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
let recursive = true;
|
|
120
|
+
if (args.length > 1) {
|
|
121
|
+
const result = args[1].evaluate();
|
|
122
|
+
if (result.confident && typeof result.value === "boolean") {
|
|
123
|
+
recursive = result.value;
|
|
124
|
+
} else if (!(result.confident && typeof result.value === "undefined")) {
|
|
125
|
+
throw new InvalidRequireCallError(
|
|
126
|
+
result.deopt ?? args[1],
|
|
127
|
+
"Second argument of `require.context` should be an optional boolean indicating if files should be imported recursively or not."
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
let filter = { pattern: ".*", flags: "" };
|
|
132
|
+
if (args.length > 2) {
|
|
133
|
+
const result = args[2].evaluate();
|
|
134
|
+
const argNode = args[2].node;
|
|
135
|
+
if (argNode.type === "RegExpLiteral") {
|
|
136
|
+
filter = {
|
|
137
|
+
pattern: argNode.pattern,
|
|
138
|
+
flags: argNode.flags || ""
|
|
139
|
+
};
|
|
140
|
+
} else if (!(result.confident && typeof result.value === "undefined")) {
|
|
141
|
+
throw new InvalidRequireCallError(
|
|
142
|
+
args[2],
|
|
143
|
+
`Third argument of \`require.context\` should be an optional RegExp pattern matching all of the files to import, instead found node of type: ${argNode.type}.`
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
let mode = "sync";
|
|
148
|
+
if (args.length > 3) {
|
|
149
|
+
const result = args[3].evaluate();
|
|
150
|
+
if (result.confident && typeof result.value === "string") {
|
|
151
|
+
mode = getContextMode(args[3], result.value);
|
|
152
|
+
} else if (!(result.confident && typeof result.value === "undefined")) {
|
|
153
|
+
throw new InvalidRequireCallError(
|
|
154
|
+
result.deopt ?? args[3],
|
|
155
|
+
'Fourth argument of `require.context` should be an optional string "mode" denoting how the modules will be resolved.'
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
if (args.length > 4) {
|
|
160
|
+
throw new InvalidRequireCallError(
|
|
161
|
+
path,
|
|
162
|
+
`Too many arguments provided to \`require.context\` call. Expected 4, got: ${args.length}`
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
return [
|
|
166
|
+
directory,
|
|
167
|
+
{
|
|
168
|
+
recursive,
|
|
169
|
+
filter,
|
|
170
|
+
mode
|
|
171
|
+
}
|
|
172
|
+
];
|
|
173
|
+
}
|
|
174
|
+
function getContextMode(path, mode) {
|
|
175
|
+
if (mode === "sync" || mode === "eager" || mode === "lazy" || mode === "lazy-once") {
|
|
176
|
+
return mode;
|
|
177
|
+
}
|
|
178
|
+
throw new InvalidRequireCallError(
|
|
179
|
+
path,
|
|
180
|
+
`require.context "${mode}" mode is not supported. Expected one of: sync, eager, lazy, lazy-once`
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
function processRequireContextCall(path, state) {
|
|
184
|
+
const [directory, contextParams] = getRequireContextArgs(path);
|
|
185
|
+
const transformer = state.dependencyTransformer;
|
|
186
|
+
const dep = registerDependency(
|
|
187
|
+
state,
|
|
188
|
+
{
|
|
189
|
+
// We basically want to "import" every file in a folder and then filter them out with the given `filter` RegExp.
|
|
190
|
+
name: directory,
|
|
191
|
+
// Capture the matching context
|
|
192
|
+
contextParams,
|
|
193
|
+
asyncType: null,
|
|
194
|
+
optional: isOptionalDependency(directory, path, state)
|
|
195
|
+
},
|
|
196
|
+
path
|
|
197
|
+
);
|
|
198
|
+
path.get("callee").replaceWith(types.identifier("require"));
|
|
199
|
+
transformer.transformSyncRequire(path, dep, state);
|
|
200
|
+
}
|
|
201
|
+
function collectImports(path, state) {
|
|
202
|
+
if (path.node.source) {
|
|
203
|
+
registerDependency(
|
|
204
|
+
state,
|
|
205
|
+
{
|
|
206
|
+
name: path.node.source.value,
|
|
207
|
+
asyncType: null,
|
|
208
|
+
optional: false
|
|
209
|
+
},
|
|
210
|
+
path
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
function processImportCall(path, state, options) {
|
|
215
|
+
const name = getModuleNameFromCallArgs(path);
|
|
216
|
+
if (name == null) {
|
|
217
|
+
throw new InvalidRequireCallError(path);
|
|
218
|
+
}
|
|
219
|
+
const dep = registerDependency(
|
|
220
|
+
state,
|
|
221
|
+
{
|
|
222
|
+
name,
|
|
223
|
+
asyncType: options.asyncType,
|
|
224
|
+
splitCondition: options.splitCondition,
|
|
225
|
+
optional: isOptionalDependency(name, path, state)
|
|
226
|
+
},
|
|
227
|
+
path
|
|
228
|
+
);
|
|
229
|
+
const transformer = state.dependencyTransformer;
|
|
230
|
+
if (options.jsResource) {
|
|
231
|
+
transformer.transformJSResource(path, dep, state);
|
|
232
|
+
} else if (options.asyncType === "async") {
|
|
233
|
+
transformer.transformImportCall(path, dep, state);
|
|
234
|
+
} else {
|
|
235
|
+
transformer.transformPrefetch(path, dep, state);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
function processRequireCall(path, state) {
|
|
239
|
+
const name = getModuleNameFromCallArgs(path);
|
|
240
|
+
const transformer = state.dependencyTransformer;
|
|
241
|
+
if (name == null) {
|
|
242
|
+
if (state.dynamicRequires === "reject") {
|
|
243
|
+
throw new InvalidRequireCallError(path);
|
|
244
|
+
}
|
|
245
|
+
transformer.transformIllegalDynamicRequire(path, state);
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
const dep = registerDependency(
|
|
249
|
+
state,
|
|
250
|
+
{
|
|
251
|
+
name,
|
|
252
|
+
asyncType: null,
|
|
253
|
+
optional: isOptionalDependency(name, path, state)
|
|
254
|
+
},
|
|
255
|
+
path
|
|
256
|
+
);
|
|
257
|
+
transformer.transformSyncRequire(path, dep, state);
|
|
258
|
+
}
|
|
259
|
+
function getNearestLocFromPath(path) {
|
|
260
|
+
let current = path;
|
|
261
|
+
while (current && !current.node.loc) {
|
|
262
|
+
current = current.parentPath;
|
|
263
|
+
}
|
|
264
|
+
return current?.node.loc;
|
|
265
|
+
}
|
|
266
|
+
function registerDependency(state, qualifier, path) {
|
|
267
|
+
const dependency = state.dependencyRegistry.registerDependency(qualifier);
|
|
268
|
+
const loc = getNearestLocFromPath(path);
|
|
269
|
+
if (loc != null) {
|
|
270
|
+
dependency.locs.push(loc);
|
|
271
|
+
}
|
|
272
|
+
return dependency;
|
|
273
|
+
}
|
|
274
|
+
function isOptionalDependency(name, path, state) {
|
|
275
|
+
const { allowOptionalDependencies } = state;
|
|
276
|
+
if (name === state.asyncRequireModulePathStringLiteral?.value) {
|
|
277
|
+
return false;
|
|
278
|
+
}
|
|
279
|
+
const isExcluded = () => Array.isArray(allowOptionalDependencies.exclude) && allowOptionalDependencies.exclude.includes(name);
|
|
280
|
+
if (!allowOptionalDependencies || isExcluded()) {
|
|
281
|
+
return false;
|
|
282
|
+
}
|
|
283
|
+
let sCount = 0;
|
|
284
|
+
let p = path;
|
|
285
|
+
while (p && sCount < 3) {
|
|
286
|
+
if (p.isStatement()) {
|
|
287
|
+
if (p.node.type === "BlockStatement") {
|
|
288
|
+
return p.parentPath != null && p.parentPath.node.type === "TryStatement" && p.key === "block";
|
|
289
|
+
}
|
|
290
|
+
sCount += 1;
|
|
291
|
+
}
|
|
292
|
+
p = p.parentPath;
|
|
293
|
+
}
|
|
294
|
+
return false;
|
|
295
|
+
}
|
|
296
|
+
function getModuleNameFromCallArgs(path) {
|
|
297
|
+
const expectedCount = path.node.callee.name === "__conditionallySplitJSResource" ? 2 : 1;
|
|
298
|
+
const args = path.get("arguments");
|
|
299
|
+
if (!Array.isArray(args) || args.length !== expectedCount) {
|
|
300
|
+
throw new InvalidRequireCallError(path);
|
|
301
|
+
}
|
|
302
|
+
const result = args[0].evaluate();
|
|
303
|
+
if (result.confident && typeof result.value === "string") {
|
|
304
|
+
return result.value;
|
|
305
|
+
}
|
|
306
|
+
return null;
|
|
307
|
+
}
|
|
308
|
+
collectDependencies.getModuleNameFromCallArgs = getModuleNameFromCallArgs;
|
|
309
|
+
class InvalidRequireCallError extends Error {
|
|
310
|
+
constructor({ node }, message) {
|
|
311
|
+
const line = node.loc && node.loc.start && node.loc.start.line;
|
|
312
|
+
super([`Invalid call at line ${line || "<unknown>"}: ${generate(node).code}`, message].filter(Boolean).join("\n"));
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
collectDependencies.InvalidRequireCallError = InvalidRequireCallError;
|
|
316
|
+
const dynamicRequireErrorTemplate = template.statement(`
|
|
317
|
+
(function(line) {
|
|
318
|
+
throw new Error(
|
|
319
|
+
'Dynamic require defined at line ' + line + '; not supported by Metro',
|
|
320
|
+
);
|
|
321
|
+
})(LINE)
|
|
322
|
+
`);
|
|
323
|
+
const makeAsyncRequireTemplate = template.statement(`
|
|
324
|
+
require(ASYNC_REQUIRE_MODULE_PATH)(MODULE_ID, MODULE_NAME)
|
|
325
|
+
`);
|
|
326
|
+
const makeAsyncPrefetchTemplate = template.statement(`
|
|
327
|
+
require(ASYNC_REQUIRE_MODULE_PATH).prefetch(MODULE_ID, MODULE_NAME)
|
|
328
|
+
`);
|
|
329
|
+
const makeJSResourceTemplate = template.statement(`
|
|
330
|
+
require(ASYNC_REQUIRE_MODULE_PATH).resource(MODULE_ID, MODULE_NAME)
|
|
331
|
+
`);
|
|
332
|
+
const DefaultDependencyTransformer = {
|
|
333
|
+
transformSyncRequire(path, dependency, state) {
|
|
334
|
+
const moduleIDExpression = createModuleIDExpression(dependency, state);
|
|
335
|
+
path.node.arguments = [moduleIDExpression];
|
|
336
|
+
if (state.keepRequireNames) {
|
|
337
|
+
path.node.arguments.push(types.stringLiteral(dependency.name));
|
|
338
|
+
}
|
|
339
|
+
},
|
|
340
|
+
transformImportCall(path, dependency, state) {
|
|
341
|
+
path.replaceWith(
|
|
342
|
+
makeAsyncRequireTemplate({
|
|
343
|
+
ASYNC_REQUIRE_MODULE_PATH: nullthrows(state.asyncRequireModulePathStringLiteral),
|
|
344
|
+
MODULE_ID: createModuleIDExpression(dependency, state),
|
|
345
|
+
MODULE_NAME: createModuleNameLiteral(dependency)
|
|
346
|
+
})
|
|
347
|
+
);
|
|
348
|
+
},
|
|
349
|
+
transformJSResource(path, dependency, state) {
|
|
350
|
+
path.replaceWith(
|
|
351
|
+
makeJSResourceTemplate({
|
|
352
|
+
ASYNC_REQUIRE_MODULE_PATH: nullthrows(state.asyncRequireModulePathStringLiteral),
|
|
353
|
+
MODULE_ID: createModuleIDExpression(dependency, state),
|
|
354
|
+
MODULE_NAME: createModuleNameLiteral(dependency)
|
|
355
|
+
})
|
|
356
|
+
);
|
|
357
|
+
},
|
|
358
|
+
transformPrefetch(path, dependency, state) {
|
|
359
|
+
path.replaceWith(
|
|
360
|
+
makeAsyncPrefetchTemplate({
|
|
361
|
+
ASYNC_REQUIRE_MODULE_PATH: nullthrows(state.asyncRequireModulePathStringLiteral),
|
|
362
|
+
MODULE_ID: createModuleIDExpression(dependency, state),
|
|
363
|
+
MODULE_NAME: createModuleNameLiteral(dependency)
|
|
364
|
+
})
|
|
365
|
+
);
|
|
366
|
+
},
|
|
367
|
+
transformIllegalDynamicRequire(path, state) {
|
|
368
|
+
path.replaceWith(
|
|
369
|
+
dynamicRequireErrorTemplate({
|
|
370
|
+
LINE: types.numericLiteral(path.node.loc?.start.line ?? 0)
|
|
371
|
+
})
|
|
372
|
+
);
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
function createModuleIDExpression(dependency, state) {
|
|
376
|
+
return types.memberExpression(
|
|
377
|
+
nullthrows(state.dependencyMapIdentifier),
|
|
378
|
+
types.numericLiteral(dependency.index),
|
|
379
|
+
true
|
|
380
|
+
);
|
|
381
|
+
}
|
|
382
|
+
function createModuleNameLiteral(dependency) {
|
|
383
|
+
return types.stringLiteral(dependency.name);
|
|
384
|
+
}
|
|
385
|
+
function getKeyForDependency(qualifier) {
|
|
386
|
+
let key = qualifier.name;
|
|
387
|
+
const { asyncType } = qualifier;
|
|
388
|
+
if (asyncType) {
|
|
389
|
+
key += ["", asyncType].join("\0");
|
|
390
|
+
}
|
|
391
|
+
const { contextParams } = qualifier;
|
|
392
|
+
if (contextParams) {
|
|
393
|
+
key += [
|
|
394
|
+
"",
|
|
395
|
+
"context",
|
|
396
|
+
String(contextParams.recursive),
|
|
397
|
+
String(contextParams.filter.pattern),
|
|
398
|
+
String(contextParams.filter.flags),
|
|
399
|
+
contextParams.mode
|
|
400
|
+
// Join together and append to the name:
|
|
401
|
+
].join("\0");
|
|
402
|
+
}
|
|
403
|
+
return key;
|
|
404
|
+
}
|
|
405
|
+
class DefaultModuleDependencyRegistry {
|
|
406
|
+
_dependencies = /* @__PURE__ */ new Map();
|
|
407
|
+
registerDependency(qualifier) {
|
|
408
|
+
const key = getKeyForDependency(qualifier);
|
|
409
|
+
let dependency = this._dependencies.get(key);
|
|
410
|
+
if (dependency == null) {
|
|
411
|
+
const newDependency = {
|
|
412
|
+
name: qualifier.name,
|
|
413
|
+
asyncType: qualifier.asyncType,
|
|
414
|
+
locs: [],
|
|
415
|
+
index: this._dependencies.size,
|
|
416
|
+
key: crypto.createHash("sha1").update(key).digest("base64")
|
|
417
|
+
};
|
|
418
|
+
if (qualifier.optional) {
|
|
419
|
+
newDependency.isOptional = true;
|
|
420
|
+
}
|
|
421
|
+
if (qualifier.contextParams) {
|
|
422
|
+
newDependency.contextParams = qualifier.contextParams;
|
|
423
|
+
}
|
|
424
|
+
dependency = newDependency;
|
|
425
|
+
} else {
|
|
426
|
+
if (dependency.isOptional && !qualifier.optional) {
|
|
427
|
+
dependency = {
|
|
428
|
+
...dependency,
|
|
429
|
+
isOptional: false
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
this._dependencies.set(key, dependency);
|
|
434
|
+
return dependency;
|
|
435
|
+
}
|
|
436
|
+
getDependencies() {
|
|
437
|
+
return Array.from(this._dependencies.values());
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
module.exports = collectDependencies;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const babelGenerate = require("@babel/generator").default;
|
|
3
|
+
function generate(ast, filename, sourceCode) {
|
|
4
|
+
const generated = babelGenerate(
|
|
5
|
+
ast,
|
|
6
|
+
{
|
|
7
|
+
comments: false,
|
|
8
|
+
compact: true,
|
|
9
|
+
filename,
|
|
10
|
+
sourceFileName: filename,
|
|
11
|
+
sourceMaps: true,
|
|
12
|
+
sourceMapTarget: filename
|
|
13
|
+
},
|
|
14
|
+
sourceCode
|
|
15
|
+
);
|
|
16
|
+
if (generated.map) {
|
|
17
|
+
delete generated.map.sourcesContent;
|
|
18
|
+
}
|
|
19
|
+
return generated;
|
|
20
|
+
}
|
|
21
|
+
module.exports = generate;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const traverse = require("@babel/traverse").default;
|
|
3
|
+
const nullthrows = require("nullthrows");
|
|
4
|
+
function generateImportNames(ast) {
|
|
5
|
+
let importDefault;
|
|
6
|
+
let importAll;
|
|
7
|
+
traverse(ast, {
|
|
8
|
+
Program(path) {
|
|
9
|
+
importAll = path.scope.generateUid("$$_IMPORT_ALL");
|
|
10
|
+
importDefault = path.scope.generateUid("$$_IMPORT_DEFAULT");
|
|
11
|
+
path.stop();
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
return {
|
|
15
|
+
importAll: nullthrows(importAll),
|
|
16
|
+
importDefault: nullthrows(importDefault)
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
module.exports = generateImportNames;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const sourceMap = require("source-map");
|
|
3
|
+
function mergeSourceMaps(file, originalMap, secondMap) {
|
|
4
|
+
const merged = new sourceMap.SourceMapGenerator();
|
|
5
|
+
const inputMap = new sourceMap.SourceMapConsumer(originalMap);
|
|
6
|
+
new sourceMap.SourceMapConsumer(secondMap).eachMapping((mapping) => {
|
|
7
|
+
if (mapping.originalLine == null) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
const original = inputMap.originalPositionFor({
|
|
11
|
+
line: mapping.originalLine,
|
|
12
|
+
column: mapping.originalColumn
|
|
13
|
+
});
|
|
14
|
+
if (original.line == null) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
merged.addMapping({
|
|
18
|
+
generated: { line: mapping.generatedLine, column: mapping.generatedColumn },
|
|
19
|
+
original: { line: original.line, column: original.column || 0 },
|
|
20
|
+
source: file,
|
|
21
|
+
name: original.name || mapping.name
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
return {
|
|
25
|
+
...merged.toJSON(),
|
|
26
|
+
sources: inputMap.sources
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
module.exports = mergeSourceMaps;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const accepts = require("accepts");
|
|
3
|
+
const CRLF = "\r\n";
|
|
4
|
+
const BOUNDARY = "3beqjf3apnqeu3h5jqorms4i";
|
|
5
|
+
class MultipartResponse {
|
|
6
|
+
static wrapIfSupported(req, res) {
|
|
7
|
+
if (accepts(req).types().includes("multipart/mixed")) {
|
|
8
|
+
return new MultipartResponse(res);
|
|
9
|
+
}
|
|
10
|
+
return res;
|
|
11
|
+
}
|
|
12
|
+
static serializeHeaders(headers) {
|
|
13
|
+
return Object.keys(headers).map((key) => `${key}: ${headers[key]}`).join(CRLF);
|
|
14
|
+
}
|
|
15
|
+
res;
|
|
16
|
+
headers;
|
|
17
|
+
constructor(res) {
|
|
18
|
+
this.res = res;
|
|
19
|
+
this.headers = {};
|
|
20
|
+
res.writeHead(200, {
|
|
21
|
+
"Content-Type": `multipart/mixed; boundary="${BOUNDARY}"`
|
|
22
|
+
});
|
|
23
|
+
res.write("If you are seeing this, your client does not support multipart response");
|
|
24
|
+
}
|
|
25
|
+
writeChunk(headers, data, isLast = false) {
|
|
26
|
+
if (this.res.finished) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
this.res.write(`${CRLF}--${BOUNDARY}${CRLF}`);
|
|
30
|
+
if (headers) {
|
|
31
|
+
this.res.write(MultipartResponse.serializeHeaders(headers) + CRLF + CRLF);
|
|
32
|
+
}
|
|
33
|
+
if (data != null) {
|
|
34
|
+
this.res.write(data);
|
|
35
|
+
}
|
|
36
|
+
if (isLast) {
|
|
37
|
+
this.res.write(`${CRLF}--${BOUNDARY}--${CRLF}`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
writeHead(status, headers) {
|
|
41
|
+
this.setHeader("X-Http-Status", status);
|
|
42
|
+
if (!headers) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
for (const key in headers) {
|
|
46
|
+
this.setHeader(key, headers[key]);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
setHeader(name, value) {
|
|
50
|
+
this.headers[name] = value;
|
|
51
|
+
}
|
|
52
|
+
end(data) {
|
|
53
|
+
this.writeChunk(this.headers, data, true);
|
|
54
|
+
this.res.end();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
module.exports = MultipartResponse;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const { greatestLowerBound } = require("metro-source-map/src/Consumer/search");
|
|
3
|
+
const { SourceMetadataMapConsumer } = require("metro-symbolicate/src/Symbolication");
|
|
4
|
+
function createFunctionNameGetter(module2) {
|
|
5
|
+
const consumer = new SourceMetadataMapConsumer(
|
|
6
|
+
{
|
|
7
|
+
version: 3,
|
|
8
|
+
mappings: "",
|
|
9
|
+
sources: ["dummy"],
|
|
10
|
+
names: [],
|
|
11
|
+
x_facebook_sources: [[module2.functionMap]]
|
|
12
|
+
},
|
|
13
|
+
(name) => name
|
|
14
|
+
/* no normalization needed */
|
|
15
|
+
);
|
|
16
|
+
return ({ line1Based, column0Based }) => consumer.functionNameFor({
|
|
17
|
+
line: line1Based,
|
|
18
|
+
column: column0Based,
|
|
19
|
+
source: "dummy"
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
async function symbolicate(stack, maps, config) {
|
|
23
|
+
const mapsByUrl = /* @__PURE__ */ new Map();
|
|
24
|
+
for (const [url, map] of maps) {
|
|
25
|
+
mapsByUrl.set(url, map);
|
|
26
|
+
}
|
|
27
|
+
const functionNameGetters = /* @__PURE__ */ new Map();
|
|
28
|
+
function findModule(frame) {
|
|
29
|
+
const map = mapsByUrl.get(frame.file);
|
|
30
|
+
if (!map || frame.lineNumber == null) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
const moduleIndex = greatestLowerBound(
|
|
34
|
+
map,
|
|
35
|
+
frame.lineNumber,
|
|
36
|
+
(target, candidate) => target - candidate.firstLine1Based
|
|
37
|
+
);
|
|
38
|
+
if (moduleIndex == null) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
return map[moduleIndex];
|
|
42
|
+
}
|
|
43
|
+
function findOriginalPos(frame, module2) {
|
|
44
|
+
if (module2.map == null || frame.lineNumber == null || frame.column == null) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
const generatedPosInModule = {
|
|
48
|
+
line1Based: frame.lineNumber - module2.firstLine1Based + 1,
|
|
49
|
+
column0Based: frame.column
|
|
50
|
+
};
|
|
51
|
+
const mappingIndex = greatestLowerBound(module2.map, generatedPosInModule, (target, candidate) => {
|
|
52
|
+
if (target.line1Based === candidate[0]) {
|
|
53
|
+
return target.column0Based - candidate[1];
|
|
54
|
+
}
|
|
55
|
+
return target.line1Based - candidate[0];
|
|
56
|
+
});
|
|
57
|
+
if (mappingIndex == null) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
const mapping = module2.map[mappingIndex];
|
|
61
|
+
if (mapping[0] !== generatedPosInModule.line1Based || mapping.length < 4) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
// $FlowFixMe: Length checks do not refine tuple unions.
|
|
66
|
+
line1Based: mapping[2],
|
|
67
|
+
// $FlowFixMe: Length checks do not refine tuple unions.
|
|
68
|
+
column0Based: mapping[3]
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function findFunctionName(originalPos, module2) {
|
|
72
|
+
if (module2.functionMap) {
|
|
73
|
+
let getFunctionName = functionNameGetters.get(module2);
|
|
74
|
+
if (!getFunctionName) {
|
|
75
|
+
getFunctionName = createFunctionNameGetter(module2);
|
|
76
|
+
functionNameGetters.set(module2, getFunctionName);
|
|
77
|
+
}
|
|
78
|
+
return getFunctionName(originalPos);
|
|
79
|
+
}
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
function symbolicateFrame(frame) {
|
|
83
|
+
const module2 = findModule(frame);
|
|
84
|
+
if (!module2) {
|
|
85
|
+
return frame;
|
|
86
|
+
}
|
|
87
|
+
if (!Array.isArray(module2.map)) {
|
|
88
|
+
throw new Error(`Unexpected module with serialized source map found: ${module2.path}`);
|
|
89
|
+
}
|
|
90
|
+
const originalPos = findOriginalPos(frame, module2);
|
|
91
|
+
if (!originalPos) {
|
|
92
|
+
return frame;
|
|
93
|
+
}
|
|
94
|
+
const methodName = findFunctionName(originalPos, module2) ?? frame.methodName;
|
|
95
|
+
return {
|
|
96
|
+
...frame,
|
|
97
|
+
methodName,
|
|
98
|
+
file: module2.path,
|
|
99
|
+
lineNumber: originalPos.line1Based,
|
|
100
|
+
column: originalPos.column0Based
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
async function customizeFrame(frame) {
|
|
104
|
+
const customizations = await config.symbolicator.customizeFrame(frame) || {};
|
|
105
|
+
return { ...frame, collapse: false, ...customizations };
|
|
106
|
+
}
|
|
107
|
+
return Promise.all(stack.map(symbolicateFrame).map(customizeFrame));
|
|
108
|
+
}
|
|
109
|
+
module.exports = symbolicate;
|