@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,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const babylon = require("@babel/parser");
|
|
3
|
+
const template = require("@babel/template").default;
|
|
4
|
+
const babelTypes = require("@babel/types");
|
|
5
|
+
const nullthrows = require("nullthrows");
|
|
6
|
+
const assetPropertyBlockList = /* @__PURE__ */ new Set(["files", "fileSystemLocation", "path"]);
|
|
7
|
+
function generateAssetCodeFileAst(assetRegistryPath, assetDescriptor) {
|
|
8
|
+
const properDescriptor = filterObject(assetDescriptor, assetPropertyBlockList);
|
|
9
|
+
const descriptorAst = babylon.parseExpression(JSON.stringify(properDescriptor));
|
|
10
|
+
const t = babelTypes;
|
|
11
|
+
const buildRequire = template.statement(`
|
|
12
|
+
module.exports = require(ASSET_REGISTRY_PATH).registerAsset(DESCRIPTOR_AST)
|
|
13
|
+
`);
|
|
14
|
+
return t.file(
|
|
15
|
+
t.program([
|
|
16
|
+
buildRequire({
|
|
17
|
+
ASSET_REGISTRY_PATH: t.stringLiteral(assetRegistryPath),
|
|
18
|
+
DESCRIPTOR_AST: descriptorAst
|
|
19
|
+
})
|
|
20
|
+
])
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
function generateRemoteAssetCodeFileAst(assetUtilsPath, assetDescriptor, remoteServer, remoteFileMap) {
|
|
24
|
+
const t = babelTypes;
|
|
25
|
+
const file = remoteFileMap[assetDescriptor.fileSystemLocation];
|
|
26
|
+
const descriptor = file && file[assetDescriptor.name];
|
|
27
|
+
const data = {};
|
|
28
|
+
if (!descriptor) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
for (const scale in descriptor) {
|
|
32
|
+
data[+scale] = descriptor[+scale].handle;
|
|
33
|
+
}
|
|
34
|
+
const astData = babylon.parseExpression(JSON.stringify(data));
|
|
35
|
+
const URI = t.stringLiteral(remoteServer);
|
|
36
|
+
const WIDTH = t.numericLiteral(nullthrows(assetDescriptor.width));
|
|
37
|
+
const HEIGHT = t.numericLiteral(nullthrows(assetDescriptor.height));
|
|
38
|
+
const buildRequire = template.program(`
|
|
39
|
+
const {pickScale, getUrlCacheBreaker}= require(ASSET_UTILS_PATH);
|
|
40
|
+
module.exports = {
|
|
41
|
+
"width": WIDTH,
|
|
42
|
+
"height": HEIGHT,
|
|
43
|
+
"uri": URI + OBJECT_AST[pickScale(SCALE_ARRAY)] + getUrlCacheBreaker()
|
|
44
|
+
};
|
|
45
|
+
`);
|
|
46
|
+
return t.file(
|
|
47
|
+
buildRequire({
|
|
48
|
+
WIDTH,
|
|
49
|
+
HEIGHT,
|
|
50
|
+
URI,
|
|
51
|
+
OBJECT_AST: astData,
|
|
52
|
+
ASSET_UTILS_PATH: t.stringLiteral(assetUtilsPath),
|
|
53
|
+
SCALE_ARRAY: t.arrayExpression(
|
|
54
|
+
Object.keys(descriptor).map(Number).sort((a, b) => a - b).map((scale) => t.numericLiteral(scale))
|
|
55
|
+
)
|
|
56
|
+
})
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
function isAssetTypeAnImage(type) {
|
|
60
|
+
return ["png", "jpg", "jpeg", "bmp", "gif", "webp", "psd", "svg", "tiff"].indexOf(type) !== -1;
|
|
61
|
+
}
|
|
62
|
+
function filterObject(object, blockList) {
|
|
63
|
+
const copied = { ...object };
|
|
64
|
+
for (const key of blockList) {
|
|
65
|
+
delete copied[key];
|
|
66
|
+
}
|
|
67
|
+
return copied;
|
|
68
|
+
}
|
|
69
|
+
function createRamBundleGroups(ramGroups, groupableModules, subtree) {
|
|
70
|
+
const byPath = /* @__PURE__ */ new Map();
|
|
71
|
+
const byId = /* @__PURE__ */ new Map();
|
|
72
|
+
groupableModules.forEach((m) => {
|
|
73
|
+
byPath.set(m.sourcePath, m);
|
|
74
|
+
byId.set(m.id, m.sourcePath);
|
|
75
|
+
});
|
|
76
|
+
const result = new Map(
|
|
77
|
+
ramGroups.map((modulePath) => {
|
|
78
|
+
const root = byPath.get(modulePath);
|
|
79
|
+
if (root == null) {
|
|
80
|
+
throw Error(`Group root ${modulePath} is not part of the bundle`);
|
|
81
|
+
}
|
|
82
|
+
return [
|
|
83
|
+
root.id,
|
|
84
|
+
// `subtree` yields the IDs of all transitive dependencies of a module
|
|
85
|
+
new Set(subtree(root, byPath))
|
|
86
|
+
];
|
|
87
|
+
})
|
|
88
|
+
);
|
|
89
|
+
if (ramGroups.length > 1) {
|
|
90
|
+
const all = new ArrayMap();
|
|
91
|
+
for (const [parent, children] of result) {
|
|
92
|
+
for (const module2 of children) {
|
|
93
|
+
all.get(module2).push(parent);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const doubles = filter(all, ([, parents]) => parents.length > 1);
|
|
97
|
+
for (const [moduleId, parents] of doubles) {
|
|
98
|
+
const parentNames = parents.map(byId.get, byId);
|
|
99
|
+
const lastName = parentNames.pop();
|
|
100
|
+
throw new Error(
|
|
101
|
+
`Module ${byId.get(moduleId) || moduleId} belongs to groups ${parentNames.join(", ")}, and ${String(
|
|
102
|
+
lastName
|
|
103
|
+
)}. Ensure that each module is only part of one group.`
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return result;
|
|
108
|
+
}
|
|
109
|
+
function* filter(iterator, predicate) {
|
|
110
|
+
for (const value of iterator) {
|
|
111
|
+
if (predicate(value)) {
|
|
112
|
+
yield value;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
class ArrayMap extends Map {
|
|
117
|
+
get(key) {
|
|
118
|
+
let array = super.get(key);
|
|
119
|
+
if (!array) {
|
|
120
|
+
array = [];
|
|
121
|
+
this.set(key, array);
|
|
122
|
+
}
|
|
123
|
+
return array;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
module.exports = {
|
|
127
|
+
createRamBundleGroups,
|
|
128
|
+
generateAssetCodeFileAst,
|
|
129
|
+
generateRemoteAssetCodeFileAst,
|
|
130
|
+
isAssetTypeAnImage
|
|
131
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const Transformer = require("./DeltaBundler/Transformer");
|
|
3
|
+
const DependencyGraph = require("./node-haste/DependencyGraph");
|
|
4
|
+
class Bundler {
|
|
5
|
+
_depGraph;
|
|
6
|
+
_readyPromise;
|
|
7
|
+
_transformer;
|
|
8
|
+
constructor(config, options) {
|
|
9
|
+
this._depGraph = new DependencyGraph(config, options);
|
|
10
|
+
this._readyPromise = this._depGraph.ready().then(() => {
|
|
11
|
+
config.reporter.update({ type: "transformer_load_started" });
|
|
12
|
+
this._transformer = new Transformer(config, (...args) => this._depGraph.getSha1(...args));
|
|
13
|
+
config.reporter.update({ type: "transformer_load_done" });
|
|
14
|
+
}).catch((error) => {
|
|
15
|
+
console.error("Failed to construct transformer: ", error);
|
|
16
|
+
config.reporter.update({
|
|
17
|
+
type: "transformer_load_failed",
|
|
18
|
+
error
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
getWatcher() {
|
|
23
|
+
return this._depGraph.getWatcher();
|
|
24
|
+
}
|
|
25
|
+
async end() {
|
|
26
|
+
await this._depGraph.ready();
|
|
27
|
+
this._transformer.end();
|
|
28
|
+
this._depGraph.end();
|
|
29
|
+
}
|
|
30
|
+
async getDependencyGraph() {
|
|
31
|
+
await this._depGraph.ready();
|
|
32
|
+
return this._depGraph;
|
|
33
|
+
}
|
|
34
|
+
async transformFile(filePath, transformOptions, fileBuffer) {
|
|
35
|
+
await this._depGraph.ready();
|
|
36
|
+
return this._transformer.transformFile(filePath, transformOptions, fileBuffer);
|
|
37
|
+
}
|
|
38
|
+
// Waits for the bundler to become ready.
|
|
39
|
+
async ready() {
|
|
40
|
+
await this._readyPromise;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
module.exports = Bundler;
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var import_graphOperations = require("./graphOperations");
|
|
3
|
+
const { EventEmitter } = require("events");
|
|
4
|
+
class DeltaCalculator extends EventEmitter {
|
|
5
|
+
_changeEventSource;
|
|
6
|
+
_options;
|
|
7
|
+
_currentBuildPromise;
|
|
8
|
+
_deletedFiles = /* @__PURE__ */ new Set();
|
|
9
|
+
_modifiedFiles = /* @__PURE__ */ new Set();
|
|
10
|
+
_addedFiles = /* @__PURE__ */ new Set();
|
|
11
|
+
_graph;
|
|
12
|
+
constructor(entryPoints, changeEventSource, options) {
|
|
13
|
+
super();
|
|
14
|
+
this._options = options;
|
|
15
|
+
this._changeEventSource = changeEventSource;
|
|
16
|
+
this._graph = (0, import_graphOperations.createGraph)({
|
|
17
|
+
entryPoints,
|
|
18
|
+
transformOptions: this._options.transformOptions
|
|
19
|
+
});
|
|
20
|
+
this._changeEventSource.on("change", this._handleMultipleFileChanges);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Stops listening for file changes and clears all the caches.
|
|
24
|
+
*/
|
|
25
|
+
end() {
|
|
26
|
+
this._changeEventSource.removeListener("change", this._handleMultipleFileChanges);
|
|
27
|
+
this.removeAllListeners();
|
|
28
|
+
this._graph = (0, import_graphOperations.createGraph)({
|
|
29
|
+
entryPoints: this._graph.entryPoints,
|
|
30
|
+
transformOptions: this._options.transformOptions
|
|
31
|
+
});
|
|
32
|
+
this._modifiedFiles = /* @__PURE__ */ new Set();
|
|
33
|
+
this._deletedFiles = /* @__PURE__ */ new Set();
|
|
34
|
+
this._addedFiles = /* @__PURE__ */ new Set();
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Main method to calculate the delta of modules. It returns a DeltaResult,
|
|
38
|
+
* which contain the modified/added modules and the removed modules.
|
|
39
|
+
*/
|
|
40
|
+
async getDelta({ reset, shallow }) {
|
|
41
|
+
if (this._currentBuildPromise) {
|
|
42
|
+
await this._currentBuildPromise;
|
|
43
|
+
}
|
|
44
|
+
const modifiedFiles = this._modifiedFiles;
|
|
45
|
+
this._modifiedFiles = /* @__PURE__ */ new Set();
|
|
46
|
+
const deletedFiles = this._deletedFiles;
|
|
47
|
+
this._deletedFiles = /* @__PURE__ */ new Set();
|
|
48
|
+
const addedFiles = this._addedFiles;
|
|
49
|
+
this._addedFiles = /* @__PURE__ */ new Set();
|
|
50
|
+
this._currentBuildPromise = this._getChangedDependencies(modifiedFiles, deletedFiles, addedFiles);
|
|
51
|
+
let result;
|
|
52
|
+
const numDependencies = this._graph.dependencies.size;
|
|
53
|
+
try {
|
|
54
|
+
result = await this._currentBuildPromise;
|
|
55
|
+
} catch (error) {
|
|
56
|
+
modifiedFiles.forEach((file) => this._modifiedFiles.add(file));
|
|
57
|
+
deletedFiles.forEach((file) => this._deletedFiles.add(file));
|
|
58
|
+
addedFiles.forEach((file) => this._addedFiles.add(file));
|
|
59
|
+
if (this._graph.dependencies.size !== numDependencies) {
|
|
60
|
+
this._graph.dependencies = /* @__PURE__ */ new Map();
|
|
61
|
+
}
|
|
62
|
+
throw error;
|
|
63
|
+
} finally {
|
|
64
|
+
this._currentBuildPromise = null;
|
|
65
|
+
}
|
|
66
|
+
if (reset) {
|
|
67
|
+
(0, import_graphOperations.reorderGraph)(this._graph, { shallow });
|
|
68
|
+
return {
|
|
69
|
+
added: this._graph.dependencies,
|
|
70
|
+
modified: /* @__PURE__ */ new Map(),
|
|
71
|
+
deleted: /* @__PURE__ */ new Set(),
|
|
72
|
+
reset: true
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
return result;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Returns the graph with all the dependencies. Each module contains the
|
|
79
|
+
* needed information to do the traversing (dependencies, inverseDependencies)
|
|
80
|
+
* plus some metadata.
|
|
81
|
+
*/
|
|
82
|
+
getGraph() {
|
|
83
|
+
return this._graph;
|
|
84
|
+
}
|
|
85
|
+
/* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's
|
|
86
|
+
* LTI update could not be added via codemod */
|
|
87
|
+
_handleMultipleFileChanges = ({ eventsQueue }) => {
|
|
88
|
+
eventsQueue.forEach(this._handleFileChange);
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Handles a single file change. To avoid doing any work before it's needed,
|
|
92
|
+
* the listener only stores the modified file, which will then be used later
|
|
93
|
+
* when the delta needs to be calculated.
|
|
94
|
+
*/
|
|
95
|
+
_handleFileChange = ({ type, filePath }) => {
|
|
96
|
+
let state;
|
|
97
|
+
if (this._deletedFiles.has(filePath)) {
|
|
98
|
+
state = "deleted";
|
|
99
|
+
} else if (this._modifiedFiles.has(filePath)) {
|
|
100
|
+
state = "modified";
|
|
101
|
+
} else if (this._addedFiles.has(filePath)) {
|
|
102
|
+
state = "added";
|
|
103
|
+
}
|
|
104
|
+
let nextState;
|
|
105
|
+
if (type === "delete") {
|
|
106
|
+
nextState = "deleted";
|
|
107
|
+
} else if (type === "add") {
|
|
108
|
+
nextState = state === "deleted" ? "modified" : "added";
|
|
109
|
+
} else {
|
|
110
|
+
nextState = state === "added" ? "added" : "modified";
|
|
111
|
+
}
|
|
112
|
+
switch (nextState) {
|
|
113
|
+
case "deleted":
|
|
114
|
+
this._deletedFiles.add(filePath);
|
|
115
|
+
this._modifiedFiles.delete(filePath);
|
|
116
|
+
this._addedFiles.delete(filePath);
|
|
117
|
+
break;
|
|
118
|
+
case "added":
|
|
119
|
+
this._addedFiles.add(filePath);
|
|
120
|
+
this._deletedFiles.delete(filePath);
|
|
121
|
+
this._modifiedFiles.delete(filePath);
|
|
122
|
+
break;
|
|
123
|
+
case "modified":
|
|
124
|
+
this._modifiedFiles.add(filePath);
|
|
125
|
+
this._deletedFiles.delete(filePath);
|
|
126
|
+
this._addedFiles.delete(filePath);
|
|
127
|
+
break;
|
|
128
|
+
default:
|
|
129
|
+
nextState;
|
|
130
|
+
}
|
|
131
|
+
this.emit("change");
|
|
132
|
+
};
|
|
133
|
+
async _getChangedDependencies(modifiedFiles, deletedFiles, addedFiles) {
|
|
134
|
+
if (!this._graph.dependencies.size) {
|
|
135
|
+
const { added: added2 } = await (0, import_graphOperations.initialTraverseDependencies)(this._graph, this._options);
|
|
136
|
+
return {
|
|
137
|
+
added: added2,
|
|
138
|
+
modified: /* @__PURE__ */ new Map(),
|
|
139
|
+
deleted: /* @__PURE__ */ new Set(),
|
|
140
|
+
reset: true
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
deletedFiles.forEach((filePath) => {
|
|
144
|
+
const module2 = this._graph.dependencies.get(filePath);
|
|
145
|
+
if (module2) {
|
|
146
|
+
module2.inverseDependencies.forEach((path) => {
|
|
147
|
+
if (!deletedFiles.has(path)) {
|
|
148
|
+
modifiedFiles.add(path);
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
if (this._options.unstable_allowRequireContext) {
|
|
154
|
+
addedFiles.forEach((filePath) => {
|
|
155
|
+
(0, import_graphOperations.markModifiedContextModules)(this._graph, filePath, modifiedFiles);
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
const modifiedDependencies = Array.from(modifiedFiles).filter((filePath) => this._graph.dependencies.has(filePath));
|
|
159
|
+
if (modifiedDependencies.length === 0) {
|
|
160
|
+
return {
|
|
161
|
+
added: /* @__PURE__ */ new Map(),
|
|
162
|
+
modified: /* @__PURE__ */ new Map(),
|
|
163
|
+
deleted: /* @__PURE__ */ new Set(),
|
|
164
|
+
reset: false
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
const { added, modified, deleted } = await (0, import_graphOperations.traverseDependencies)(modifiedDependencies, this._graph, this._options);
|
|
168
|
+
return {
|
|
169
|
+
added,
|
|
170
|
+
modified,
|
|
171
|
+
deleted,
|
|
172
|
+
reset: false
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
module.exports = DeltaCalculator;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const getAppendScripts = require("../../lib/getAppendScripts");
|
|
3
|
+
const { getJsOutput } = require("./helpers/js");
|
|
4
|
+
const processBytecodeModules = require("./helpers/processBytecodeModules");
|
|
5
|
+
function baseBytecodeBundle(entryPoint, preModules, graph, options) {
|
|
6
|
+
for (const module2 of graph.dependencies.values()) {
|
|
7
|
+
options.createModuleId(module2.path);
|
|
8
|
+
}
|
|
9
|
+
const processModulesOptions = {
|
|
10
|
+
filter: options.processModuleFilter,
|
|
11
|
+
createModuleId: options.createModuleId,
|
|
12
|
+
dev: options.dev,
|
|
13
|
+
projectRoot: options.projectRoot
|
|
14
|
+
};
|
|
15
|
+
if (options.modulesOnly) {
|
|
16
|
+
preModules = [];
|
|
17
|
+
}
|
|
18
|
+
const modules = [...graph.dependencies.values()].sort(
|
|
19
|
+
(a, b) => options.createModuleId(a.path) - options.createModuleId(b.path)
|
|
20
|
+
);
|
|
21
|
+
const { compile } = require("metro-hermes-compiler");
|
|
22
|
+
const post = processBytecodeModules(
|
|
23
|
+
getAppendScripts(entryPoint, [...preModules, ...modules], graph.importBundleNames, {
|
|
24
|
+
asyncRequireModulePath: options.asyncRequireModulePath,
|
|
25
|
+
createModuleId: options.createModuleId,
|
|
26
|
+
getRunModuleStatement: options.getRunModuleStatement,
|
|
27
|
+
inlineSourceMap: options.inlineSourceMap,
|
|
28
|
+
projectRoot: options.projectRoot,
|
|
29
|
+
runBeforeMainModule: options.runBeforeMainModule,
|
|
30
|
+
runModule: options.runModule,
|
|
31
|
+
serverRoot: options.serverRoot,
|
|
32
|
+
sourceMapUrl: options.sourceMapUrl,
|
|
33
|
+
sourceUrl: options.sourceUrl
|
|
34
|
+
}).map((module2) => {
|
|
35
|
+
return {
|
|
36
|
+
...module2,
|
|
37
|
+
output: [
|
|
38
|
+
...module2.output,
|
|
39
|
+
{
|
|
40
|
+
type: "bytecode/script/virtual",
|
|
41
|
+
data: {
|
|
42
|
+
bytecode: compile(getJsOutput(module2).data.code, {
|
|
43
|
+
sourceURL: module2.path
|
|
44
|
+
}).bytecode
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
};
|
|
49
|
+
}),
|
|
50
|
+
processModulesOptions
|
|
51
|
+
).flatMap(([module2, bytecodeBundle]) => bytecodeBundle);
|
|
52
|
+
const processedModules = processBytecodeModules([...graph.dependencies.values()], processModulesOptions).map(
|
|
53
|
+
([module2, bytecodeBundle]) => [options.createModuleId(module2.path), bytecodeBundle]
|
|
54
|
+
);
|
|
55
|
+
return {
|
|
56
|
+
pre: processBytecodeModules(preModules, processModulesOptions).flatMap(([_, bytecodeBundle]) => bytecodeBundle),
|
|
57
|
+
post,
|
|
58
|
+
modules: processedModules
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
module.exports = baseBytecodeBundle;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const getAppendScripts = require("../../lib/getAppendScripts");
|
|
3
|
+
const processModules = require("./helpers/processModules");
|
|
4
|
+
function baseJSBundle(entryPoint, preModules, graph, options) {
|
|
5
|
+
for (const module2 of graph.dependencies.values()) {
|
|
6
|
+
options.createModuleId(module2.path);
|
|
7
|
+
}
|
|
8
|
+
const processModulesOptions = {
|
|
9
|
+
filter: options.processModuleFilter,
|
|
10
|
+
createModuleId: options.createModuleId,
|
|
11
|
+
dev: options.dev,
|
|
12
|
+
projectRoot: options.projectRoot
|
|
13
|
+
};
|
|
14
|
+
if (options.modulesOnly) {
|
|
15
|
+
preModules = [];
|
|
16
|
+
}
|
|
17
|
+
const preCode = processModules(preModules, processModulesOptions).map(([_, code]) => code).join("\n");
|
|
18
|
+
const modules = [...graph.dependencies.values()].sort(
|
|
19
|
+
(a, b) => options.createModuleId(a.path) - options.createModuleId(b.path)
|
|
20
|
+
);
|
|
21
|
+
const postCode = processModules(
|
|
22
|
+
getAppendScripts(entryPoint, [...preModules, ...modules], graph.importBundleNames, {
|
|
23
|
+
asyncRequireModulePath: options.asyncRequireModulePath,
|
|
24
|
+
createModuleId: options.createModuleId,
|
|
25
|
+
getRunModuleStatement: options.getRunModuleStatement,
|
|
26
|
+
inlineSourceMap: options.inlineSourceMap,
|
|
27
|
+
projectRoot: options.projectRoot,
|
|
28
|
+
runBeforeMainModule: options.runBeforeMainModule,
|
|
29
|
+
runModule: options.runModule,
|
|
30
|
+
serverRoot: options.serverRoot,
|
|
31
|
+
sourceMapUrl: options.sourceMapUrl,
|
|
32
|
+
sourceUrl: options.sourceUrl
|
|
33
|
+
}),
|
|
34
|
+
processModulesOptions
|
|
35
|
+
).map(([_, code]) => code).join("\n");
|
|
36
|
+
return {
|
|
37
|
+
pre: preCode,
|
|
38
|
+
post: postCode,
|
|
39
|
+
modules: processModules([...graph.dependencies.values()], processModulesOptions).map(([module2, code]) => [
|
|
40
|
+
options.createModuleId(module2.path),
|
|
41
|
+
code
|
|
42
|
+
])
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
module.exports = baseJSBundle;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const { getAssetFiles } = require("../../Assets");
|
|
3
|
+
const { getJsOutput, isJsModule } = require("./helpers/js");
|
|
4
|
+
async function getAllFiles(pre, graph, options) {
|
|
5
|
+
const modules = graph.dependencies;
|
|
6
|
+
const { processModuleFilter } = options;
|
|
7
|
+
const promises = [];
|
|
8
|
+
for (const module2 of pre) {
|
|
9
|
+
if (processModuleFilter(module2)) {
|
|
10
|
+
promises.push([module2.path]);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
for (const module2 of modules.values()) {
|
|
14
|
+
if (!isJsModule(module2) || !processModuleFilter(module2)) {
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
if (getJsOutput(module2).type === "js/module/asset") {
|
|
18
|
+
promises.push(getAssetFiles(module2.path, options.platform));
|
|
19
|
+
} else {
|
|
20
|
+
promises.push([module2.path]);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const dependencies = await Promise.all(promises);
|
|
24
|
+
const output = [];
|
|
25
|
+
for (const dependencyArray of dependencies) {
|
|
26
|
+
output.push(...dependencyArray);
|
|
27
|
+
}
|
|
28
|
+
return output;
|
|
29
|
+
}
|
|
30
|
+
module.exports = getAllFiles;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const { getAssetData } = require("../../Assets");
|
|
3
|
+
const { getJsOutput, isJsModule } = require("./helpers/js");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
async function getAssets(dependencies, options) {
|
|
6
|
+
const promises = [];
|
|
7
|
+
const { processModuleFilter } = options;
|
|
8
|
+
for (const module2 of dependencies.values()) {
|
|
9
|
+
if (isJsModule(module2) && processModuleFilter(module2) && getJsOutput(module2).type === "js/module/asset" && path.relative(options.projectRoot, module2.path) !== "package.json") {
|
|
10
|
+
promises.push(
|
|
11
|
+
getAssetData(
|
|
12
|
+
module2.path,
|
|
13
|
+
path.relative(options.projectRoot, module2.path),
|
|
14
|
+
options.assetPlugins,
|
|
15
|
+
options.platform,
|
|
16
|
+
options.publicPath
|
|
17
|
+
)
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return await Promise.all(promises);
|
|
22
|
+
}
|
|
23
|
+
module.exports = getAssets;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const { getJsOutput, isJsModule } = require("./helpers/js");
|
|
3
|
+
function getExplodedSourceMap(modules, options) {
|
|
4
|
+
const modulesToProcess = modules.filter(isJsModule).filter(options.processModuleFilter);
|
|
5
|
+
const result = [];
|
|
6
|
+
let firstLine1Based = 1;
|
|
7
|
+
for (const module2 of modulesToProcess) {
|
|
8
|
+
const { path } = module2;
|
|
9
|
+
const { lineCount, functionMap, map } = getJsOutput(module2).data;
|
|
10
|
+
result.push({ firstLine1Based, functionMap, path, map });
|
|
11
|
+
firstLine1Based += lineCount;
|
|
12
|
+
}
|
|
13
|
+
return result;
|
|
14
|
+
}
|
|
15
|
+
module.exports = {
|
|
16
|
+
getExplodedSourceMap
|
|
17
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const { createRamBundleGroups } = require("../../Bundler/util");
|
|
3
|
+
const getAppendScripts = require("../../lib/getAppendScripts");
|
|
4
|
+
const getTransitiveDependencies = require("./helpers/getTransitiveDependencies");
|
|
5
|
+
const { isJsModule, wrapModule } = require("./helpers/js");
|
|
6
|
+
const { sourceMapObject } = require("./sourceMapObject");
|
|
7
|
+
const nullthrows = require("nullthrows");
|
|
8
|
+
const path = require("path");
|
|
9
|
+
async function getRamBundleInfo(entryPoint, pre, graph, options) {
|
|
10
|
+
let modules = [...pre, ...graph.dependencies.values()];
|
|
11
|
+
modules = modules.concat(getAppendScripts(entryPoint, modules, graph.importBundleNames, options));
|
|
12
|
+
modules.forEach((module2) => options.createModuleId(module2.path));
|
|
13
|
+
const ramModules = modules.filter(isJsModule).filter(options.processModuleFilter).map((module2) => ({
|
|
14
|
+
id: options.createModuleId(module2.path),
|
|
15
|
+
code: wrapModule(module2, options),
|
|
16
|
+
map: sourceMapObject([module2], {
|
|
17
|
+
excludeSource: options.excludeSource,
|
|
18
|
+
processModuleFilter: options.processModuleFilter
|
|
19
|
+
}),
|
|
20
|
+
name: path.basename(module2.path),
|
|
21
|
+
sourcePath: module2.path,
|
|
22
|
+
source: module2.getSource().toString(),
|
|
23
|
+
type: nullthrows(module2.output.find(({ type }) => type.startsWith("js"))).type
|
|
24
|
+
}));
|
|
25
|
+
const { preloadedModules, ramGroups } = await _getRamOptions(
|
|
26
|
+
entryPoint,
|
|
27
|
+
{
|
|
28
|
+
dev: options.dev,
|
|
29
|
+
platform: options.platform
|
|
30
|
+
},
|
|
31
|
+
(filePath) => getTransitiveDependencies(filePath, graph),
|
|
32
|
+
options.getTransformOptions
|
|
33
|
+
);
|
|
34
|
+
const startupModules = [];
|
|
35
|
+
const lazyModules = [];
|
|
36
|
+
ramModules.forEach((module2) => {
|
|
37
|
+
if (preloadedModules.hasOwnProperty(module2.sourcePath)) {
|
|
38
|
+
startupModules.push(module2);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (module2.type.startsWith("js/script")) {
|
|
42
|
+
startupModules.push(module2);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (module2.type.startsWith("js/module")) {
|
|
46
|
+
lazyModules.push(module2);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
const groups = createRamBundleGroups(ramGroups, lazyModules, (module2, dependenciesByPath) => {
|
|
50
|
+
const deps = getTransitiveDependencies(module2.sourcePath, graph);
|
|
51
|
+
const output = /* @__PURE__ */ new Set();
|
|
52
|
+
for (const dependency of deps) {
|
|
53
|
+
const module3 = dependenciesByPath.get(dependency);
|
|
54
|
+
if (module3) {
|
|
55
|
+
output.add(module3.id);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return output;
|
|
59
|
+
});
|
|
60
|
+
return {
|
|
61
|
+
getDependencies: (filePath) => getTransitiveDependencies(filePath, graph),
|
|
62
|
+
groups,
|
|
63
|
+
lazyModules,
|
|
64
|
+
startupModules
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
async function _getRamOptions(entryFile, options, getDependencies, getTransformOptions) {
|
|
68
|
+
if (getTransformOptions == null) {
|
|
69
|
+
return {
|
|
70
|
+
preloadedModules: {},
|
|
71
|
+
ramGroups: []
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
const { preloadedModules, ramGroups } = await getTransformOptions(
|
|
75
|
+
[entryFile],
|
|
76
|
+
{ dev: options.dev, hot: true, platform: options.platform },
|
|
77
|
+
/* $FlowFixMe(>=0.99.0 site=react_native_fb) This comment suppresses an
|
|
78
|
+
* error found when Flow v0.99 was deployed. To see the error, delete this
|
|
79
|
+
* comment and run Flow. */
|
|
80
|
+
async (x) => Array.from(getDependencies)
|
|
81
|
+
);
|
|
82
|
+
return {
|
|
83
|
+
preloadedModules: preloadedModules || {},
|
|
84
|
+
ramGroups: ramGroups || []
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
module.exports = getRamBundleInfo;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const invariant = require("invariant");
|
|
3
|
+
const path = require("path");
|
|
4
|
+
function wrapModule(module2, options) {
|
|
5
|
+
const output = getBytecodeOutput(module2);
|
|
6
|
+
if (output.type.startsWith("bytecode/script")) {
|
|
7
|
+
return [output.data.bytecode];
|
|
8
|
+
}
|
|
9
|
+
const params = [
|
|
10
|
+
options.createModuleId(module2.path),
|
|
11
|
+
"[" + Array.from(module2.dependencies.values()).map((dependency) => options.createModuleId(dependency.absolutePath)).join(",") + "]"
|
|
12
|
+
];
|
|
13
|
+
if (options.dev) {
|
|
14
|
+
params.push(JSON.stringify(path.relative(options.projectRoot, module2.path)));
|
|
15
|
+
}
|
|
16
|
+
const { compile } = require("metro-hermes-compiler");
|
|
17
|
+
const headerCode = `globalThis.$$METRO_D=[${params.join(",")}];`;
|
|
18
|
+
return [
|
|
19
|
+
compile(headerCode, {
|
|
20
|
+
sourceURL: module2.path + "-virtual.js"
|
|
21
|
+
}).bytecode,
|
|
22
|
+
output.data.bytecode
|
|
23
|
+
];
|
|
24
|
+
}
|
|
25
|
+
function getBytecodeOutput(module2) {
|
|
26
|
+
const output = module2.output.filter(({ type }) => type.startsWith("bytecode/")).map(
|
|
27
|
+
(output2) => output2.data.bytecode instanceof Buffer ? output2 : (
|
|
28
|
+
// Re-create buffers after losing the Buffer instance when sending data over workers.
|
|
29
|
+
{
|
|
30
|
+
...output2,
|
|
31
|
+
data: {
|
|
32
|
+
...output2.data,
|
|
33
|
+
bytecode: Buffer.from(output2.data.bytecode.data)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
)
|
|
37
|
+
);
|
|
38
|
+
invariant(
|
|
39
|
+
output.length === 1,
|
|
40
|
+
`Modules must have exactly one bytecode output, but ${module2.path} has ${output.length} bytecode outputs.`
|
|
41
|
+
);
|
|
42
|
+
return output[0];
|
|
43
|
+
}
|
|
44
|
+
function isBytecodeModule(module2) {
|
|
45
|
+
return module2.output.filter(({ type }) => type.startsWith("bytecode/")).length > 0;
|
|
46
|
+
}
|
|
47
|
+
module.exports = {
|
|
48
|
+
getBytecodeOutput,
|
|
49
|
+
isBytecodeModule,
|
|
50
|
+
wrapModule
|
|
51
|
+
};
|