@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,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var import_contextModuleTemplates = require("./contextModuleTemplates");
|
|
3
|
+
const path = require("path");
|
|
4
|
+
const baseIgnoredInlineRequires = ["React", "react", "react-native"];
|
|
5
|
+
async function calcTransformerOptions(entryFiles, bundler, deltaBundler, config, options, resolverOptions) {
|
|
6
|
+
const baseOptions = {
|
|
7
|
+
customTransformOptions: options.customTransformOptions,
|
|
8
|
+
dev: options.dev,
|
|
9
|
+
hot: options.hot,
|
|
10
|
+
inlineRequires: false,
|
|
11
|
+
inlinePlatform: true,
|
|
12
|
+
minify: options.minify,
|
|
13
|
+
platform: options.platform,
|
|
14
|
+
runtimeBytecodeVersion: options.runtimeBytecodeVersion,
|
|
15
|
+
unstable_transformProfile: options.unstable_transformProfile
|
|
16
|
+
};
|
|
17
|
+
if (options.type === "script") {
|
|
18
|
+
return {
|
|
19
|
+
...baseOptions,
|
|
20
|
+
type: "script"
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
const getDependencies = async (path2) => {
|
|
24
|
+
const dependencies = await deltaBundler.getDependencies([path2], {
|
|
25
|
+
resolve: await getResolveDependencyFn(bundler, options.platform, resolverOptions),
|
|
26
|
+
transform: await getTransformFn(
|
|
27
|
+
[path2],
|
|
28
|
+
bundler,
|
|
29
|
+
deltaBundler,
|
|
30
|
+
config,
|
|
31
|
+
{
|
|
32
|
+
...options,
|
|
33
|
+
minify: false
|
|
34
|
+
},
|
|
35
|
+
resolverOptions
|
|
36
|
+
),
|
|
37
|
+
transformOptions: options,
|
|
38
|
+
onProgress: null,
|
|
39
|
+
experimentalImportBundleSupport: config.transformer.experimentalImportBundleSupport,
|
|
40
|
+
unstable_allowRequireContext: config.transformer.unstable_allowRequireContext,
|
|
41
|
+
shallow: false
|
|
42
|
+
});
|
|
43
|
+
return Array.from(dependencies.keys());
|
|
44
|
+
};
|
|
45
|
+
const { transform } = await config.transformer.getTransformOptions(
|
|
46
|
+
entryFiles,
|
|
47
|
+
{ dev: options.dev, hot: options.hot, platform: options.platform },
|
|
48
|
+
getDependencies
|
|
49
|
+
);
|
|
50
|
+
return {
|
|
51
|
+
...baseOptions,
|
|
52
|
+
inlineRequires: transform.inlineRequires || false,
|
|
53
|
+
experimentalImportSupport: transform.experimentalImportSupport || false,
|
|
54
|
+
unstable_disableES6Transforms: transform.unstable_disableES6Transforms || false,
|
|
55
|
+
nonInlinedRequires: transform.nonInlinedRequires || baseIgnoredInlineRequires,
|
|
56
|
+
type: "module"
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function removeInlineRequiresBlockListFromOptions(path2, inlineRequires) {
|
|
60
|
+
if (typeof inlineRequires === "object") {
|
|
61
|
+
return !(path2 in inlineRequires.blockList);
|
|
62
|
+
}
|
|
63
|
+
return inlineRequires;
|
|
64
|
+
}
|
|
65
|
+
async function getTransformFn(entryFiles, bundler, deltaBundler, config, options, resolverOptions) {
|
|
66
|
+
const { inlineRequires, ...transformOptions } = await calcTransformerOptions(
|
|
67
|
+
entryFiles,
|
|
68
|
+
bundler,
|
|
69
|
+
deltaBundler,
|
|
70
|
+
config,
|
|
71
|
+
options,
|
|
72
|
+
resolverOptions
|
|
73
|
+
);
|
|
74
|
+
return async (modulePath, requireContext) => {
|
|
75
|
+
let templateBuffer;
|
|
76
|
+
if (requireContext) {
|
|
77
|
+
const graph = await bundler.getDependencyGraph();
|
|
78
|
+
const files = graph.matchFilesWithContext(requireContext.from, {
|
|
79
|
+
filter: requireContext.filter,
|
|
80
|
+
recursive: requireContext.recursive
|
|
81
|
+
});
|
|
82
|
+
const template = (0, import_contextModuleTemplates.getContextModuleTemplate)(requireContext.mode, requireContext.from, files);
|
|
83
|
+
templateBuffer = Buffer.from(template);
|
|
84
|
+
}
|
|
85
|
+
return await bundler.transformFile(
|
|
86
|
+
modulePath,
|
|
87
|
+
{
|
|
88
|
+
...transformOptions,
|
|
89
|
+
type: getType(transformOptions.type, modulePath, config.resolver.assetExts),
|
|
90
|
+
inlineRequires: removeInlineRequiresBlockListFromOptions(modulePath, inlineRequires)
|
|
91
|
+
},
|
|
92
|
+
templateBuffer
|
|
93
|
+
);
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function getType(type, filePath, assetExts) {
|
|
97
|
+
if (type === "script") {
|
|
98
|
+
return type;
|
|
99
|
+
}
|
|
100
|
+
if (assetExts.indexOf(path.extname(filePath).slice(1)) !== -1) {
|
|
101
|
+
return "asset";
|
|
102
|
+
}
|
|
103
|
+
return "module";
|
|
104
|
+
}
|
|
105
|
+
async function getResolveDependencyFn(bundler, platform, resolverOptions) {
|
|
106
|
+
const dependencyGraph = await await bundler.getDependencyGraph();
|
|
107
|
+
return (from, to) => dependencyGraph.resolveDependency(from, to, platform ?? null, resolverOptions);
|
|
108
|
+
}
|
|
109
|
+
module.exports = {
|
|
110
|
+
getTransformFn,
|
|
111
|
+
getResolveDependencyFn
|
|
112
|
+
};
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const { codeFrameColumns } = require("@babel/code-frame");
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const invariant = require("invariant");
|
|
5
|
+
const Resolver = require("metro-resolver");
|
|
6
|
+
const path = require("path");
|
|
7
|
+
const util = require("util");
|
|
8
|
+
class ModuleResolver {
|
|
9
|
+
_options;
|
|
10
|
+
// A module representing the project root, used as the origin when resolving `emptyModulePath`.
|
|
11
|
+
_projectRootFakeModule;
|
|
12
|
+
// An empty module, the result of resolving `emptyModulePath` from the project root.
|
|
13
|
+
_cachedEmptyModule;
|
|
14
|
+
// $FlowFixMe[missing-local-annot]
|
|
15
|
+
constructor(options) {
|
|
16
|
+
this._options = options;
|
|
17
|
+
const { projectRoot, moduleCache } = this._options;
|
|
18
|
+
this._projectRootFakeModule = {
|
|
19
|
+
path: path.join(projectRoot, "_"),
|
|
20
|
+
getPackage: () => moduleCache.getPackageOf(this._projectRootFakeModule.path),
|
|
21
|
+
isHaste() {
|
|
22
|
+
throw new Error("not implemented");
|
|
23
|
+
},
|
|
24
|
+
getName() {
|
|
25
|
+
throw new Error("not implemented");
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
_getEmptyModule() {
|
|
30
|
+
let emptyModule = this._cachedEmptyModule;
|
|
31
|
+
if (!emptyModule) {
|
|
32
|
+
emptyModule = this.resolveDependency(
|
|
33
|
+
this._projectRootFakeModule,
|
|
34
|
+
this._options.emptyModulePath,
|
|
35
|
+
false,
|
|
36
|
+
null,
|
|
37
|
+
/* resolverOptions */
|
|
38
|
+
{}
|
|
39
|
+
);
|
|
40
|
+
this._cachedEmptyModule = emptyModule;
|
|
41
|
+
}
|
|
42
|
+
return emptyModule;
|
|
43
|
+
}
|
|
44
|
+
_redirectRequire(fromModule, modulePath) {
|
|
45
|
+
const moduleCache = this._options.moduleCache;
|
|
46
|
+
try {
|
|
47
|
+
if (modulePath.startsWith(".")) {
|
|
48
|
+
const fromPackage = fromModule.getPackage();
|
|
49
|
+
if (fromPackage) {
|
|
50
|
+
const fromPackagePath = "./" + path.relative(path.dirname(fromPackage.path), path.resolve(path.dirname(fromModule.path), modulePath));
|
|
51
|
+
let redirectedPath = fromPackage.redirectRequire(fromPackagePath, this._options.mainFields);
|
|
52
|
+
if (redirectedPath !== false) {
|
|
53
|
+
redirectedPath = "./" + path.relative(
|
|
54
|
+
path.dirname(fromModule.path),
|
|
55
|
+
path.resolve(path.dirname(fromPackage.path), redirectedPath)
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
return redirectedPath;
|
|
59
|
+
}
|
|
60
|
+
} else {
|
|
61
|
+
const pck = path.isAbsolute(modulePath) ? moduleCache.getPackageOf(modulePath) : fromModule.getPackage();
|
|
62
|
+
if (pck) {
|
|
63
|
+
return pck.redirectRequire(modulePath, this._options.mainFields);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
} catch (err) {
|
|
67
|
+
}
|
|
68
|
+
return modulePath;
|
|
69
|
+
}
|
|
70
|
+
resolveDependency(fromModule, moduleName, allowHaste, platform, resolverOptions) {
|
|
71
|
+
try {
|
|
72
|
+
const result = Resolver.resolve(
|
|
73
|
+
{
|
|
74
|
+
...this._options,
|
|
75
|
+
customResolverOptions: resolverOptions.customResolverOptions ?? {},
|
|
76
|
+
originModulePath: fromModule.path,
|
|
77
|
+
redirectModulePath: (modulePath) => this._redirectRequire(fromModule, modulePath),
|
|
78
|
+
allowHaste,
|
|
79
|
+
platform,
|
|
80
|
+
resolveHasteModule: (name) => this._options.moduleMap.getModule(name, platform, true),
|
|
81
|
+
resolveHastePackage: (name) => this._options.moduleMap.getPackage(name, platform, true),
|
|
82
|
+
getPackageMainPath: this._getPackageMainPath
|
|
83
|
+
},
|
|
84
|
+
moduleName,
|
|
85
|
+
platform
|
|
86
|
+
);
|
|
87
|
+
return this._getFileResolvedModule(result);
|
|
88
|
+
} catch (error) {
|
|
89
|
+
if (error instanceof Resolver.FailedToResolvePathError) {
|
|
90
|
+
const { candidates } = error;
|
|
91
|
+
throw new UnableToResolveError(
|
|
92
|
+
fromModule.path,
|
|
93
|
+
moduleName,
|
|
94
|
+
[
|
|
95
|
+
"\n\nNone of these files exist:",
|
|
96
|
+
` * ${Resolver.formatFileCandidates(this._removeRoot(candidates.file))}`,
|
|
97
|
+
` * ${Resolver.formatFileCandidates(this._removeRoot(candidates.dir))}`
|
|
98
|
+
].join("\n"),
|
|
99
|
+
{
|
|
100
|
+
cause: error
|
|
101
|
+
}
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
if (error instanceof Resolver.FailedToResolveNameError) {
|
|
105
|
+
const dirPaths = error.dirPaths;
|
|
106
|
+
const extraPaths = error.extraPaths;
|
|
107
|
+
const displayDirPaths = dirPaths.filter((dirPath) => this._options.dirExists(dirPath)).map((dirPath) => path.relative(this._options.projectRoot, dirPath)).concat(extraPaths);
|
|
108
|
+
const hint = displayDirPaths.length ? " or in these directories:" : "";
|
|
109
|
+
throw new UnableToResolveError(
|
|
110
|
+
fromModule.path,
|
|
111
|
+
moduleName,
|
|
112
|
+
[
|
|
113
|
+
`${moduleName} could not be found within the project${hint || "."}`,
|
|
114
|
+
...displayDirPaths.map((dirPath) => ` ${dirPath}`)
|
|
115
|
+
].join("\n"),
|
|
116
|
+
{
|
|
117
|
+
cause: error
|
|
118
|
+
}
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
throw error;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
_getPackageMainPath = (packageJsonPath) => {
|
|
125
|
+
const package_ = this._options.moduleCache.getPackage(packageJsonPath);
|
|
126
|
+
return package_.getMain(this._options.mainFields);
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* FIXME: get rid of this function and of the reliance on `TModule`
|
|
130
|
+
* altogether, return strongly typed resolutions at the top-level instead.
|
|
131
|
+
*/
|
|
132
|
+
_getFileResolvedModule(resolution) {
|
|
133
|
+
switch (resolution.type) {
|
|
134
|
+
case "sourceFile":
|
|
135
|
+
return this._options.moduleCache.getModule(resolution.filePath);
|
|
136
|
+
case "assetFiles":
|
|
137
|
+
const arbitrary = getArrayLowestItem(resolution.filePaths);
|
|
138
|
+
invariant(arbitrary != null, "invalid asset resolution");
|
|
139
|
+
return this._options.moduleCache.getModule(arbitrary);
|
|
140
|
+
case "empty":
|
|
141
|
+
return this._getEmptyModule();
|
|
142
|
+
default:
|
|
143
|
+
resolution.type;
|
|
144
|
+
throw new Error("invalid type");
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
_removeRoot(candidates) {
|
|
148
|
+
if (candidates.filePathPrefix) {
|
|
149
|
+
candidates.filePathPrefix = path.relative(this._options.projectRoot, candidates.filePathPrefix);
|
|
150
|
+
}
|
|
151
|
+
return candidates;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
function getArrayLowestItem(a) {
|
|
155
|
+
if (a.length === 0) {
|
|
156
|
+
return void 0;
|
|
157
|
+
}
|
|
158
|
+
let lowest = a[0];
|
|
159
|
+
for (let i = 1; i < a.length; ++i) {
|
|
160
|
+
if (a[i] < lowest) {
|
|
161
|
+
lowest = a[i];
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return lowest;
|
|
165
|
+
}
|
|
166
|
+
class UnableToResolveError extends Error {
|
|
167
|
+
/**
|
|
168
|
+
* File path of the module that tried to require a module, ex. `/js/foo.js`.
|
|
169
|
+
*/
|
|
170
|
+
originModulePath;
|
|
171
|
+
/**
|
|
172
|
+
* The name of the module that was required, no necessarily a path,
|
|
173
|
+
* ex. `./bar`, or `invariant`.
|
|
174
|
+
*/
|
|
175
|
+
targetModuleName;
|
|
176
|
+
/**
|
|
177
|
+
* Original error that causes this error
|
|
178
|
+
*/
|
|
179
|
+
cause;
|
|
180
|
+
constructor(originModulePath, targetModuleName, message, options) {
|
|
181
|
+
super();
|
|
182
|
+
this.originModulePath = originModulePath;
|
|
183
|
+
this.targetModuleName = targetModuleName;
|
|
184
|
+
const codeFrameMessage = this.buildCodeFrameMessage();
|
|
185
|
+
this.message = util.format("Unable to resolve module %s from %s: %s", targetModuleName, originModulePath, message) + (codeFrameMessage ? "\n" + codeFrameMessage : "");
|
|
186
|
+
this.cause = options?.cause;
|
|
187
|
+
}
|
|
188
|
+
buildCodeFrameMessage() {
|
|
189
|
+
let file;
|
|
190
|
+
try {
|
|
191
|
+
file = fs.readFileSync(this.originModulePath, "utf8");
|
|
192
|
+
} catch (error) {
|
|
193
|
+
if (error.code === "ENOENT" || error.code === "EISDIR") {
|
|
194
|
+
return null;
|
|
195
|
+
}
|
|
196
|
+
throw error;
|
|
197
|
+
}
|
|
198
|
+
const lines = file.split("\n");
|
|
199
|
+
let lineNumber = 0;
|
|
200
|
+
let column = -1;
|
|
201
|
+
for (let line = 0; line < lines.length; line++) {
|
|
202
|
+
const columnLocation = lines[line].lastIndexOf(this.targetModuleName);
|
|
203
|
+
if (columnLocation >= 0) {
|
|
204
|
+
lineNumber = line;
|
|
205
|
+
column = columnLocation;
|
|
206
|
+
break;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return codeFrameColumns(
|
|
210
|
+
fs.readFileSync(this.originModulePath, "utf8"),
|
|
211
|
+
{
|
|
212
|
+
start: { column: column + 1, line: lineNumber + 1 }
|
|
213
|
+
},
|
|
214
|
+
{ forceColor: process.env.NODE_ENV !== "test" }
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
module.exports = {
|
|
219
|
+
ModuleResolver,
|
|
220
|
+
UnableToResolveError
|
|
221
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
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_metro_file_map = __toESM(require("metro-file-map"));
|
|
25
|
+
const ci = require("ci-info");
|
|
26
|
+
const path = require("path");
|
|
27
|
+
function getIgnorePattern(config) {
|
|
28
|
+
const { blockList, blacklistRE } = config.resolver;
|
|
29
|
+
const ignorePattern = blacklistRE || blockList;
|
|
30
|
+
if (!ignorePattern) {
|
|
31
|
+
return / ^/;
|
|
32
|
+
}
|
|
33
|
+
const combine = (regexes) => new RegExp(regexes.map((regex) => "(" + regex.source.replace(/\//g, path.sep) + ")").join("|"));
|
|
34
|
+
if (Array.isArray(ignorePattern)) {
|
|
35
|
+
return combine(ignorePattern);
|
|
36
|
+
}
|
|
37
|
+
return ignorePattern;
|
|
38
|
+
}
|
|
39
|
+
function createHasteMap(config, options) {
|
|
40
|
+
const dependencyExtractor = options?.extractDependencies === false ? null : config.resolver.dependencyExtractor;
|
|
41
|
+
const computeDependencies = dependencyExtractor != null;
|
|
42
|
+
return import_metro_file_map.default.create({
|
|
43
|
+
cacheManagerFactory: config?.unstable_fileMapCacheManagerFactory ?? ((buildParameters) => new import_metro_file_map.DiskCacheManager({
|
|
44
|
+
buildParameters,
|
|
45
|
+
cacheDirectory: config.fileMapCacheDirectory ?? config.hasteMapCacheDirectory,
|
|
46
|
+
cacheFilePrefix: options?.cacheFilePrefix
|
|
47
|
+
})),
|
|
48
|
+
perfLogger: config.unstable_perfLogger?.subSpan("hasteMap") ?? null,
|
|
49
|
+
computeDependencies,
|
|
50
|
+
computeSha1: true,
|
|
51
|
+
dependencyExtractor: config.resolver.dependencyExtractor,
|
|
52
|
+
extensions: Array.from(
|
|
53
|
+
/* @__PURE__ */ new Set([...config.resolver.sourceExts, ...config.resolver.assetExts, ...config.watcher.additionalExts])
|
|
54
|
+
),
|
|
55
|
+
forceNodeFilesystemAPI: !config.resolver.useWatchman,
|
|
56
|
+
hasteImplModulePath: config.resolver.hasteImplModulePath,
|
|
57
|
+
ignorePattern: getIgnorePattern(config),
|
|
58
|
+
maxWorkers: config.maxWorkers,
|
|
59
|
+
mocksPattern: "",
|
|
60
|
+
platforms: config.resolver.platforms,
|
|
61
|
+
retainAllFiles: true,
|
|
62
|
+
resetCache: config.resetCache,
|
|
63
|
+
rootDir: config.projectRoot,
|
|
64
|
+
roots: config.watchFolders,
|
|
65
|
+
throwOnModuleCollision: options?.throwOnModuleCollision ?? true,
|
|
66
|
+
useWatchman: config.resolver.useWatchman,
|
|
67
|
+
watch: options?.watch == null ? !ci.isCI : options.watch,
|
|
68
|
+
watchmanDeferStates: config.watcher.watchman.deferStates
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
module.exports = createHasteMap;
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var import_metro_file_map = require("metro-file-map");
|
|
3
|
+
const canonicalize = require("../../../metro-core/src/canonicalize");
|
|
4
|
+
const createHasteMap = require("./DependencyGraph/createHasteMap");
|
|
5
|
+
const { ModuleResolver } = require("./DependencyGraph/ModuleResolution");
|
|
6
|
+
const ModuleCache = require("./ModuleCache");
|
|
7
|
+
const { EventEmitter } = require("events");
|
|
8
|
+
const fs = require("fs");
|
|
9
|
+
const {
|
|
10
|
+
AmbiguousModuleResolutionError,
|
|
11
|
+
Logger: { createActionStartEntry, createActionEndEntry, log },
|
|
12
|
+
PackageResolutionError
|
|
13
|
+
} = require("../../../metro-core/src");
|
|
14
|
+
const { InvalidPackageError } = require("metro-resolver");
|
|
15
|
+
const nullthrows = require("nullthrows");
|
|
16
|
+
const path = require("path");
|
|
17
|
+
const isPnP = require("../isPnP");
|
|
18
|
+
let pnpapi;
|
|
19
|
+
if (isPnP()) {
|
|
20
|
+
pnpapi = require("pnpapi");
|
|
21
|
+
}
|
|
22
|
+
const { DuplicateHasteCandidatesError } = import_metro_file_map.ModuleMap;
|
|
23
|
+
const NULL_PLATFORM = Symbol();
|
|
24
|
+
function getOrCreateMap(map, field) {
|
|
25
|
+
let subMap = map.get(field);
|
|
26
|
+
if (!subMap) {
|
|
27
|
+
subMap = /* @__PURE__ */ new Map();
|
|
28
|
+
map.set(field, subMap);
|
|
29
|
+
}
|
|
30
|
+
return subMap;
|
|
31
|
+
}
|
|
32
|
+
class DependencyGraph extends EventEmitter {
|
|
33
|
+
_assetExtensions;
|
|
34
|
+
_config;
|
|
35
|
+
_haste;
|
|
36
|
+
_hasteFS;
|
|
37
|
+
_moduleCache;
|
|
38
|
+
_moduleMap;
|
|
39
|
+
_moduleResolver;
|
|
40
|
+
_resolutionCache;
|
|
41
|
+
_readyPromise;
|
|
42
|
+
constructor(config, options) {
|
|
43
|
+
super();
|
|
44
|
+
this._config = config;
|
|
45
|
+
this._assetExtensions = new Set(config.resolver.assetExts.map((asset) => "." + asset));
|
|
46
|
+
const { hasReducedPerformance, watch } = options ?? {};
|
|
47
|
+
const initializingMetroLogEntry = log(createActionStartEntry("Initializing Metro"));
|
|
48
|
+
config.reporter.update({
|
|
49
|
+
type: "dep_graph_loading",
|
|
50
|
+
hasReducedPerformance: !!hasReducedPerformance
|
|
51
|
+
});
|
|
52
|
+
const haste = createHasteMap(config, { watch });
|
|
53
|
+
haste.setMaxListeners(1e3);
|
|
54
|
+
this._haste = haste;
|
|
55
|
+
this._readyPromise = haste.build().then(({ hasteFS, moduleMap }) => {
|
|
56
|
+
log(createActionEndEntry(initializingMetroLogEntry));
|
|
57
|
+
config.reporter.update({ type: "dep_graph_loaded" });
|
|
58
|
+
this._hasteFS = hasteFS;
|
|
59
|
+
this._moduleMap = moduleMap;
|
|
60
|
+
this._haste.on("change", this._onHasteChange.bind(this));
|
|
61
|
+
this._resolutionCache = /* @__PURE__ */ new Map();
|
|
62
|
+
this._moduleCache = this._createModuleCache();
|
|
63
|
+
this._createModuleResolver();
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
// Waits for the dependency graph to become ready after initialisation.
|
|
67
|
+
// Don't read anything from the graph until this resolves.
|
|
68
|
+
async ready() {
|
|
69
|
+
await this._readyPromise;
|
|
70
|
+
}
|
|
71
|
+
// Creates the dependency graph and waits for it to become ready.
|
|
72
|
+
// @deprecated Use the constructor + ready() directly.
|
|
73
|
+
static async load(config, options) {
|
|
74
|
+
const self = new DependencyGraph(config, options);
|
|
75
|
+
await self.ready();
|
|
76
|
+
return self;
|
|
77
|
+
}
|
|
78
|
+
_getClosestPackage(filePath) {
|
|
79
|
+
const parsedPath = path.parse(filePath);
|
|
80
|
+
const root = parsedPath.root;
|
|
81
|
+
let dir = parsedPath.dir;
|
|
82
|
+
do {
|
|
83
|
+
const candidate = path.join(dir, "package.json");
|
|
84
|
+
if (this._hasteFS.exists(candidate)) {
|
|
85
|
+
return candidate;
|
|
86
|
+
}
|
|
87
|
+
dir = path.dirname(dir);
|
|
88
|
+
} while (dir !== "." && dir !== root);
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
/* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's
|
|
92
|
+
* LTI update could not be added via codemod */
|
|
93
|
+
_onHasteChange({ eventsQueue, hasteFS, moduleMap }) {
|
|
94
|
+
this._hasteFS = hasteFS;
|
|
95
|
+
this._resolutionCache = /* @__PURE__ */ new Map();
|
|
96
|
+
this._moduleMap = moduleMap;
|
|
97
|
+
eventsQueue.forEach(({ type, filePath }) => this._moduleCache.processFileChange(type, filePath));
|
|
98
|
+
this._createModuleResolver();
|
|
99
|
+
this.emit("change");
|
|
100
|
+
}
|
|
101
|
+
_createModuleResolver() {
|
|
102
|
+
this._moduleResolver = new ModuleResolver({
|
|
103
|
+
dirExists: (filePath) => {
|
|
104
|
+
try {
|
|
105
|
+
return fs.lstatSync(filePath).isDirectory();
|
|
106
|
+
} catch (e) {
|
|
107
|
+
}
|
|
108
|
+
return false;
|
|
109
|
+
},
|
|
110
|
+
disableHierarchicalLookup: this._config.resolver.disableHierarchicalLookup,
|
|
111
|
+
doesFileExist: this._doesFileExist,
|
|
112
|
+
emptyModulePath: this._config.resolver.emptyModulePath,
|
|
113
|
+
extraNodeModules: this._config.resolver.extraNodeModules,
|
|
114
|
+
isAssetFile: (file) => this._assetExtensions.has(path.extname(file)),
|
|
115
|
+
mainFields: this._config.resolver.resolverMainFields,
|
|
116
|
+
moduleCache: this._moduleCache,
|
|
117
|
+
moduleMap: this._moduleMap,
|
|
118
|
+
nodeModulesPaths: this._config.resolver.nodeModulesPaths,
|
|
119
|
+
preferNativePlatform: true,
|
|
120
|
+
projectRoot: this._config.projectRoot,
|
|
121
|
+
resolveAsset: (dirPath, assetName, extension) => {
|
|
122
|
+
const basePath = dirPath + path.sep + assetName;
|
|
123
|
+
const assets = [
|
|
124
|
+
basePath + extension,
|
|
125
|
+
...this._config.resolver.assetResolutions.map((resolution) => basePath + "@" + resolution + "x" + extension)
|
|
126
|
+
].filter((candidate) => this._hasteFS.exists(candidate));
|
|
127
|
+
return assets.length ? assets : null;
|
|
128
|
+
},
|
|
129
|
+
resolveRequest: this._config.resolver.resolveRequest,
|
|
130
|
+
sourceExts: this._config.resolver.sourceExts
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
_createModuleCache() {
|
|
134
|
+
return new ModuleCache({
|
|
135
|
+
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
|
136
|
+
getClosestPackage: this._getClosestPackage.bind(this)
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
getSha1(filename) {
|
|
140
|
+
const splitIndex = filename.indexOf(".zip/");
|
|
141
|
+
const containerName = splitIndex !== -1 ? filename.slice(0, splitIndex + 4) : filename;
|
|
142
|
+
const realpath = fs.realpathSync(containerName);
|
|
143
|
+
const resolvedPath = (pnpapi ? pnpapi.resolveVirtual(realpath) : realpath) ?? realpath;
|
|
144
|
+
const sha1 = this._hasteFS.getSha1(resolvedPath);
|
|
145
|
+
if (!sha1) {
|
|
146
|
+
throw new ReferenceError(
|
|
147
|
+
`SHA-1 for file ${filename} (${resolvedPath}) is not computed.
|
|
148
|
+
Potential causes:
|
|
149
|
+
1) You have symlinks in your project - watchman does not follow symlinks.
|
|
150
|
+
2) Check \`blockList\` in your metro.config.js and make sure it isn't excluding the file path.`
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
return sha1;
|
|
154
|
+
}
|
|
155
|
+
getWatcher() {
|
|
156
|
+
return this._haste;
|
|
157
|
+
}
|
|
158
|
+
end() {
|
|
159
|
+
this._haste.end();
|
|
160
|
+
}
|
|
161
|
+
/** Given a search context, return a list of file paths matching the query. */
|
|
162
|
+
matchFilesWithContext(from, context) {
|
|
163
|
+
return this._hasteFS.matchFilesWithContext(from, context);
|
|
164
|
+
}
|
|
165
|
+
resolveDependency(from, to, platform, resolverOptions, { assumeFlatNodeModules } = {
|
|
166
|
+
assumeFlatNodeModules: false
|
|
167
|
+
}) {
|
|
168
|
+
const isSensitiveToOriginFolder = (
|
|
169
|
+
// Resolution is always relative to the origin folder unless we assume a flat node_modules
|
|
170
|
+
!assumeFlatNodeModules || // Path requests are resolved relative to the origin folder
|
|
171
|
+
to.includes("/") || to === "." || to === ".." || // Preserve standard assumptions under node_modules
|
|
172
|
+
from.includes(path.sep + "node_modules" + path.sep)
|
|
173
|
+
);
|
|
174
|
+
const resolverOptionsKey = JSON.stringify(resolverOptions.customResolverOptions ?? {}, canonicalize) ?? "";
|
|
175
|
+
const originKey = isSensitiveToOriginFolder ? path.dirname(from) : "";
|
|
176
|
+
const targetKey = to;
|
|
177
|
+
const platformKey = platform ?? NULL_PLATFORM;
|
|
178
|
+
const mapByResolverOptions = this._resolutionCache;
|
|
179
|
+
const mapByOrigin = getOrCreateMap(mapByResolverOptions, resolverOptionsKey);
|
|
180
|
+
const mapByTarget = getOrCreateMap(mapByOrigin, originKey);
|
|
181
|
+
const mapByPlatform = getOrCreateMap(mapByTarget, targetKey);
|
|
182
|
+
let modulePath = mapByPlatform.get(platformKey);
|
|
183
|
+
if (!modulePath) {
|
|
184
|
+
try {
|
|
185
|
+
modulePath = this._moduleResolver.resolveDependency(
|
|
186
|
+
this._moduleCache.getModule(from),
|
|
187
|
+
to,
|
|
188
|
+
true,
|
|
189
|
+
platform,
|
|
190
|
+
resolverOptions
|
|
191
|
+
).path;
|
|
192
|
+
} catch (error) {
|
|
193
|
+
if (error instanceof DuplicateHasteCandidatesError) {
|
|
194
|
+
throw new AmbiguousModuleResolutionError(from, error);
|
|
195
|
+
}
|
|
196
|
+
if (error instanceof InvalidPackageError) {
|
|
197
|
+
throw new PackageResolutionError({
|
|
198
|
+
packageError: error,
|
|
199
|
+
originModulePath: from,
|
|
200
|
+
targetModuleName: to
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
throw error;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
mapByPlatform.set(platformKey, modulePath);
|
|
207
|
+
return modulePath;
|
|
208
|
+
}
|
|
209
|
+
_doesFileExist = (filePath) => {
|
|
210
|
+
return this._hasteFS.exists(filePath);
|
|
211
|
+
};
|
|
212
|
+
getHasteName(filePath) {
|
|
213
|
+
const hasteName = this._hasteFS.getModuleName(filePath);
|
|
214
|
+
if (hasteName) {
|
|
215
|
+
return hasteName;
|
|
216
|
+
}
|
|
217
|
+
return path.relative(this._config.projectRoot, filePath);
|
|
218
|
+
}
|
|
219
|
+
getDependencies(filePath) {
|
|
220
|
+
return nullthrows(this._hasteFS.getDependencies(filePath));
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
module.exports = DependencyGraph;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const isAbsolutePath = require("absolute-path");
|
|
3
|
+
class Module {
|
|
4
|
+
path;
|
|
5
|
+
_moduleCache;
|
|
6
|
+
_sourceCode;
|
|
7
|
+
// $FlowFixMe[missing-local-annot]
|
|
8
|
+
constructor(file, moduleCache) {
|
|
9
|
+
if (!isAbsolutePath(file)) {
|
|
10
|
+
throw new Error("Expected file to be absolute path but got " + file);
|
|
11
|
+
}
|
|
12
|
+
this.path = file;
|
|
13
|
+
this._moduleCache = moduleCache;
|
|
14
|
+
}
|
|
15
|
+
getPackage() {
|
|
16
|
+
return this._moduleCache.getPackageForModule(this);
|
|
17
|
+
}
|
|
18
|
+
invalidate() {
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
module.exports = Module;
|