@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,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const Module = require("./Module");
|
|
3
|
+
const Package = require("./Package");
|
|
4
|
+
class ModuleCache {
|
|
5
|
+
_getClosestPackage;
|
|
6
|
+
_moduleCache;
|
|
7
|
+
_packageCache;
|
|
8
|
+
// Cache for "closest package.json" queries by module path.
|
|
9
|
+
_packagePathByModulePath;
|
|
10
|
+
// The inverse of _packagePathByModulePath.
|
|
11
|
+
_modulePathsByPackagePath;
|
|
12
|
+
constructor(options) {
|
|
13
|
+
this._getClosestPackage = options.getClosestPackage;
|
|
14
|
+
this._moduleCache = /* @__PURE__ */ Object.create(null);
|
|
15
|
+
this._packageCache = /* @__PURE__ */ Object.create(null);
|
|
16
|
+
this._packagePathByModulePath = /* @__PURE__ */ Object.create(null);
|
|
17
|
+
this._modulePathsByPackagePath = /* @__PURE__ */ Object.create(null);
|
|
18
|
+
}
|
|
19
|
+
getModule(filePath) {
|
|
20
|
+
if (!this._moduleCache[filePath]) {
|
|
21
|
+
this._moduleCache[filePath] = new Module(filePath, this);
|
|
22
|
+
}
|
|
23
|
+
return this._moduleCache[filePath];
|
|
24
|
+
}
|
|
25
|
+
getPackage(filePath) {
|
|
26
|
+
if (!this._packageCache[filePath]) {
|
|
27
|
+
this._packageCache[filePath] = new Package({
|
|
28
|
+
file: filePath
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
return this._packageCache[filePath];
|
|
32
|
+
}
|
|
33
|
+
getPackageForModule(module2) {
|
|
34
|
+
return this.getPackageOf(module2.path);
|
|
35
|
+
}
|
|
36
|
+
getPackageOf(modulePath) {
|
|
37
|
+
let packagePath = this._packagePathByModulePath[modulePath];
|
|
38
|
+
if (packagePath && this._packageCache[packagePath]) {
|
|
39
|
+
return this._packageCache[packagePath];
|
|
40
|
+
}
|
|
41
|
+
packagePath = this._getClosestPackage(modulePath);
|
|
42
|
+
if (!packagePath) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
this._packagePathByModulePath[modulePath] = packagePath;
|
|
46
|
+
const modulePaths = this._modulePathsByPackagePath[packagePath] ?? /* @__PURE__ */ new Set();
|
|
47
|
+
modulePaths.add(modulePath);
|
|
48
|
+
this._modulePathsByPackagePath[packagePath] = modulePaths;
|
|
49
|
+
return this.getPackage(packagePath);
|
|
50
|
+
}
|
|
51
|
+
processFileChange(type, filePath) {
|
|
52
|
+
if (this._moduleCache[filePath]) {
|
|
53
|
+
this._moduleCache[filePath].invalidate();
|
|
54
|
+
delete this._moduleCache[filePath];
|
|
55
|
+
}
|
|
56
|
+
if (this._packageCache[filePath]) {
|
|
57
|
+
this._packageCache[filePath].invalidate();
|
|
58
|
+
delete this._packageCache[filePath];
|
|
59
|
+
}
|
|
60
|
+
if (this._packagePathByModulePath[filePath]) {
|
|
61
|
+
const packagePath = this._packagePathByModulePath[filePath];
|
|
62
|
+
delete this._packagePathByModulePath[filePath];
|
|
63
|
+
const modulePaths = this._modulePathsByPackagePath[packagePath];
|
|
64
|
+
if (modulePaths) {
|
|
65
|
+
modulePaths.delete(filePath);
|
|
66
|
+
if (modulePaths.size === 0) {
|
|
67
|
+
delete this._modulePathsByPackagePath[packagePath];
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (this._modulePathsByPackagePath[filePath]) {
|
|
72
|
+
const modulePaths = this._modulePathsByPackagePath[filePath];
|
|
73
|
+
for (const modulePath of modulePaths) {
|
|
74
|
+
delete this._packagePathByModulePath[modulePath];
|
|
75
|
+
}
|
|
76
|
+
modulePaths.clear();
|
|
77
|
+
delete this._modulePathsByPackagePath[filePath];
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
module.exports = ModuleCache;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const fs = require("fs");
|
|
3
|
+
const path = require("path");
|
|
4
|
+
class Package {
|
|
5
|
+
path;
|
|
6
|
+
_root;
|
|
7
|
+
_content;
|
|
8
|
+
constructor({ file }) {
|
|
9
|
+
this.path = path.resolve(file);
|
|
10
|
+
this._root = path.dirname(this.path);
|
|
11
|
+
this._content = null;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The `browser` field and replacement behavior is specified in
|
|
15
|
+
* https://github.com/defunctzombie/package-browser-field-spec.
|
|
16
|
+
*/
|
|
17
|
+
getMain(mainFields) {
|
|
18
|
+
const json = this.read();
|
|
19
|
+
let main;
|
|
20
|
+
for (const name of mainFields) {
|
|
21
|
+
if (typeof json[name] === "string") {
|
|
22
|
+
main = json[name];
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (!main) {
|
|
27
|
+
main = "index";
|
|
28
|
+
}
|
|
29
|
+
const replacements = getReplacements(json, mainFields);
|
|
30
|
+
if (replacements) {
|
|
31
|
+
const variants = [main];
|
|
32
|
+
if (main.slice(0, 2) === "./") {
|
|
33
|
+
variants.push(main.slice(2));
|
|
34
|
+
} else {
|
|
35
|
+
variants.push("./" + main);
|
|
36
|
+
}
|
|
37
|
+
for (const variant of variants) {
|
|
38
|
+
const winner = replacements[variant] || replacements[variant + ".js"] || replacements[variant + ".json"] || replacements[variant.replace(/(\.js|\.json)$/, "")];
|
|
39
|
+
if (winner) {
|
|
40
|
+
main = winner;
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return path.join(this._root, main);
|
|
46
|
+
}
|
|
47
|
+
invalidate() {
|
|
48
|
+
this._content = null;
|
|
49
|
+
}
|
|
50
|
+
redirectRequire(name, mainFields) {
|
|
51
|
+
const json = this.read();
|
|
52
|
+
const replacements = getReplacements(json, mainFields);
|
|
53
|
+
if (!replacements) {
|
|
54
|
+
return name;
|
|
55
|
+
}
|
|
56
|
+
if (!name.startsWith(".") && !path.isAbsolute(name)) {
|
|
57
|
+
const replacement = replacements[name];
|
|
58
|
+
return replacement === false ? false : replacement || name;
|
|
59
|
+
}
|
|
60
|
+
let relPath = "./" + path.relative(this._root, path.resolve(this._root, name));
|
|
61
|
+
if (path.sep !== "/") {
|
|
62
|
+
relPath = relPath.replace(new RegExp("\\" + path.sep, "g"), "/");
|
|
63
|
+
}
|
|
64
|
+
let redirect = replacements[relPath];
|
|
65
|
+
if (redirect == null) {
|
|
66
|
+
redirect = replacements[relPath + ".js"];
|
|
67
|
+
if (redirect == null) {
|
|
68
|
+
redirect = replacements[relPath + ".json"];
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (redirect === false) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
if (redirect) {
|
|
75
|
+
return path.join(this._root, redirect);
|
|
76
|
+
}
|
|
77
|
+
return name;
|
|
78
|
+
}
|
|
79
|
+
read() {
|
|
80
|
+
if (this._content == null) {
|
|
81
|
+
this._content = JSON.parse(fs.readFileSync(this.path, "utf8"));
|
|
82
|
+
}
|
|
83
|
+
return this._content;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function getReplacements(pkg, mainFields) {
|
|
87
|
+
const replacements = mainFields.map((name) => {
|
|
88
|
+
if (!pkg[name] || typeof pkg[name] === "string") {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
return pkg[name];
|
|
92
|
+
}).filter(Boolean);
|
|
93
|
+
if (!replacements.length) {
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
return Object.assign({}, ...replacements.reverse());
|
|
97
|
+
}
|
|
98
|
+
module.exports = Package;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const parsePlatformFilePath = require("./parsePlatformFilePath");
|
|
3
|
+
const path = require("path");
|
|
4
|
+
const ASSET_BASE_NAME_RE = /(.+?)(@([\d.]+)x)?$/;
|
|
5
|
+
function parseBaseName(baseName) {
|
|
6
|
+
const match = baseName.match(ASSET_BASE_NAME_RE);
|
|
7
|
+
if (!match) {
|
|
8
|
+
throw new Error(`invalid asset name: \`${baseName}'`);
|
|
9
|
+
}
|
|
10
|
+
const rootName = match[1];
|
|
11
|
+
if (match[3] != null) {
|
|
12
|
+
const resolution = parseFloat(match[3]);
|
|
13
|
+
if (!Number.isNaN(resolution)) {
|
|
14
|
+
return { rootName, resolution };
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return { rootName, resolution: 1 };
|
|
18
|
+
}
|
|
19
|
+
function tryParse(filePath, platforms) {
|
|
20
|
+
const result = parsePlatformFilePath(filePath, platforms);
|
|
21
|
+
const { dirPath, baseName, platform, extension } = result;
|
|
22
|
+
if (extension == null) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
const { rootName, resolution } = parseBaseName(baseName);
|
|
26
|
+
return {
|
|
27
|
+
assetName: path.join(dirPath, `${rootName}.${extension}`),
|
|
28
|
+
name: rootName,
|
|
29
|
+
platform,
|
|
30
|
+
resolution,
|
|
31
|
+
type: extension
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function parse(filePath, platforms) {
|
|
35
|
+
const result = tryParse(filePath, platforms);
|
|
36
|
+
if (result == null) {
|
|
37
|
+
throw new Error("invalid asset file path: `${filePath}");
|
|
38
|
+
}
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
module.exports = { parse, tryParse };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const path = require("path");
|
|
3
|
+
const PATH_RE = /^(.+?)(\.([^.]+))?\.([^.]+)$/;
|
|
4
|
+
function parsePlatformFilePath(filePath, platforms) {
|
|
5
|
+
const dirPath = path.dirname(filePath);
|
|
6
|
+
const fileName = path.basename(filePath);
|
|
7
|
+
const match = fileName.match(PATH_RE);
|
|
8
|
+
if (!match) {
|
|
9
|
+
return { dirPath, baseName: fileName, platform: null, extension: null };
|
|
10
|
+
}
|
|
11
|
+
const extension = match[4] || null;
|
|
12
|
+
const platform = match[3] || null;
|
|
13
|
+
if (platform == null || platforms.has(platform)) {
|
|
14
|
+
return { dirPath, baseName: match[1], platform, extension };
|
|
15
|
+
}
|
|
16
|
+
const baseName = `${match[1]}.${platform}`;
|
|
17
|
+
return { dirPath, baseName, platform: null, extension };
|
|
18
|
+
}
|
|
19
|
+
module.exports = parsePlatformFilePath;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const relativizeSourceMapInline = require("../../../lib/relativizeSourceMap");
|
|
3
|
+
const writeFile = require("../writeFile");
|
|
4
|
+
const buildSourcemapWithMetadata = require("./buildSourcemapWithMetadata");
|
|
5
|
+
const MAGIC_RAM_BUNDLE_NUMBER = require("./magic-number");
|
|
6
|
+
const { joinModules } = require("./util");
|
|
7
|
+
const writeSourceMap = require("./write-sourcemap");
|
|
8
|
+
const fsPromises = require("fs").promises;
|
|
9
|
+
const path = require("path");
|
|
10
|
+
const MAGIC_RAM_BUNDLE_FILENAME = "UNBUNDLE";
|
|
11
|
+
const MODULES_DIR = "js-modules";
|
|
12
|
+
function saveAsAssets(bundle, options, log) {
|
|
13
|
+
const { bundleOutput, bundleEncoding: encoding, sourcemapOutput, sourcemapSourcesRoot } = options;
|
|
14
|
+
log("start");
|
|
15
|
+
const { startupModules, lazyModules } = bundle;
|
|
16
|
+
log("finish");
|
|
17
|
+
const startupCode = joinModules(startupModules);
|
|
18
|
+
log("Writing bundle output to:", bundleOutput);
|
|
19
|
+
const modulesDir = path.join(path.dirname(bundleOutput), MODULES_DIR);
|
|
20
|
+
const writeUnbundle = createDir(modulesDir).then(
|
|
21
|
+
// create the modules directory first
|
|
22
|
+
() => Promise.all([
|
|
23
|
+
writeModules(lazyModules, modulesDir, encoding),
|
|
24
|
+
writeFile(bundleOutput, startupCode, encoding),
|
|
25
|
+
writeMagicFlagFile(modulesDir)
|
|
26
|
+
])
|
|
27
|
+
);
|
|
28
|
+
writeUnbundle.then(() => log("Done writing unbundle output"));
|
|
29
|
+
if (sourcemapOutput) {
|
|
30
|
+
const sourceMap = buildSourcemapWithMetadata({
|
|
31
|
+
fixWrapperOffset: true,
|
|
32
|
+
lazyModules: lazyModules.concat(),
|
|
33
|
+
moduleGroups: null,
|
|
34
|
+
startupModules: startupModules.concat()
|
|
35
|
+
});
|
|
36
|
+
if (sourcemapSourcesRoot !== void 0) {
|
|
37
|
+
relativizeSourceMapInline(sourceMap, sourcemapSourcesRoot);
|
|
38
|
+
}
|
|
39
|
+
const wroteSourceMap = writeSourceMap(sourcemapOutput, JSON.stringify(sourceMap), log);
|
|
40
|
+
return Promise.all([writeUnbundle, wroteSourceMap]);
|
|
41
|
+
} else {
|
|
42
|
+
return writeUnbundle;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function createDir(dirName) {
|
|
46
|
+
return fsPromises.mkdir(dirName, { recursive: true });
|
|
47
|
+
}
|
|
48
|
+
function writeModuleFile(module2, modulesDir, encoding) {
|
|
49
|
+
const { code, id } = module2;
|
|
50
|
+
return writeFile(path.join(modulesDir, id + ".js"), code, encoding);
|
|
51
|
+
}
|
|
52
|
+
function writeModules(modules, modulesDir, encoding) {
|
|
53
|
+
const writeFiles = modules.map((module2) => writeModuleFile(module2, modulesDir, encoding));
|
|
54
|
+
return Promise.all(writeFiles);
|
|
55
|
+
}
|
|
56
|
+
function writeMagicFlagFile(outputDir) {
|
|
57
|
+
const buffer = Buffer.alloc(4);
|
|
58
|
+
buffer.writeUInt32LE(MAGIC_RAM_BUNDLE_NUMBER, 0);
|
|
59
|
+
return writeFile(path.join(outputDir, MAGIC_RAM_BUNDLE_FILENAME), buffer);
|
|
60
|
+
}
|
|
61
|
+
module.exports = saveAsAssets;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const relativizeSourceMapInline = require("../../../lib/relativizeSourceMap");
|
|
3
|
+
const buildSourcemapWithMetadata = require("./buildSourcemapWithMetadata");
|
|
4
|
+
const MAGIC_UNBUNDLE_FILE_HEADER = require("./magic-number");
|
|
5
|
+
const { joinModules } = require("./util");
|
|
6
|
+
const writeSourceMap = require("./write-sourcemap");
|
|
7
|
+
const fs = require("fs");
|
|
8
|
+
const SIZEOF_UINT32 = 4;
|
|
9
|
+
function saveAsIndexedFile(bundle, options, log) {
|
|
10
|
+
const { bundleOutput, bundleEncoding: encoding, sourcemapOutput, sourcemapSourcesRoot } = options;
|
|
11
|
+
log("start");
|
|
12
|
+
const { startupModules, lazyModules, groups } = bundle;
|
|
13
|
+
log("finish");
|
|
14
|
+
const moduleGroups = createModuleGroups(groups, lazyModules);
|
|
15
|
+
const startupCode = joinModules(startupModules);
|
|
16
|
+
log("Writing unbundle output to:", bundleOutput);
|
|
17
|
+
const writeUnbundle = writeBuffers(
|
|
18
|
+
fs.createWriteStream(bundleOutput),
|
|
19
|
+
buildTableAndContents(startupCode, lazyModules, moduleGroups, encoding)
|
|
20
|
+
).then(() => log("Done writing unbundle output"));
|
|
21
|
+
if (sourcemapOutput) {
|
|
22
|
+
const sourceMap = buildSourcemapWithMetadata({
|
|
23
|
+
startupModules: startupModules.concat(),
|
|
24
|
+
lazyModules: lazyModules.concat(),
|
|
25
|
+
moduleGroups,
|
|
26
|
+
fixWrapperOffset: true
|
|
27
|
+
});
|
|
28
|
+
if (sourcemapSourcesRoot !== void 0) {
|
|
29
|
+
relativizeSourceMapInline(sourceMap, sourcemapSourcesRoot);
|
|
30
|
+
}
|
|
31
|
+
const wroteSourceMap = writeSourceMap(sourcemapOutput, JSON.stringify(sourceMap), log);
|
|
32
|
+
return Promise.all([writeUnbundle, wroteSourceMap]);
|
|
33
|
+
} else {
|
|
34
|
+
return writeUnbundle;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const fileHeader = Buffer.alloc(4);
|
|
38
|
+
fileHeader.writeUInt32LE(MAGIC_UNBUNDLE_FILE_HEADER, 0);
|
|
39
|
+
const nullByteBuffer = Buffer.alloc(1).fill(0);
|
|
40
|
+
function writeBuffers(stream, buffers) {
|
|
41
|
+
buffers.forEach((buffer) => stream.write(buffer));
|
|
42
|
+
return new Promise((resolve, reject) => {
|
|
43
|
+
stream.on("error", reject);
|
|
44
|
+
stream.on("finish", () => resolve());
|
|
45
|
+
stream.end();
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
function nullTerminatedBuffer(contents, encoding) {
|
|
49
|
+
return Buffer.concat([Buffer.from(contents, encoding), nullByteBuffer]);
|
|
50
|
+
}
|
|
51
|
+
function moduleToBuffer(id, code, encoding) {
|
|
52
|
+
return {
|
|
53
|
+
id,
|
|
54
|
+
buffer: nullTerminatedBuffer(code, encoding)
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function entryOffset(n) {
|
|
58
|
+
return (2 + n * 2) * SIZEOF_UINT32;
|
|
59
|
+
}
|
|
60
|
+
function buildModuleTable(startupCode, moduleBuffers, moduleGroups) {
|
|
61
|
+
const moduleIds = [...moduleGroups.modulesById.keys()];
|
|
62
|
+
const maxId = moduleIds.reduce((max, id) => Math.max(max, id));
|
|
63
|
+
const numEntries = maxId + 1;
|
|
64
|
+
const table = Buffer.alloc(entryOffset(numEntries)).fill(0);
|
|
65
|
+
table.writeUInt32LE(numEntries, 0);
|
|
66
|
+
table.writeUInt32LE(startupCode.length, SIZEOF_UINT32);
|
|
67
|
+
let codeOffset = startupCode.length;
|
|
68
|
+
moduleBuffers.forEach(({ id, buffer }) => {
|
|
69
|
+
const group = moduleGroups.groups.get(id);
|
|
70
|
+
const idsInGroup = group ? [id].concat(Array.from(group)) : [id];
|
|
71
|
+
idsInGroup.forEach((moduleId) => {
|
|
72
|
+
const offset = entryOffset(moduleId);
|
|
73
|
+
table.writeUInt32LE(codeOffset, offset);
|
|
74
|
+
table.writeUInt32LE(buffer.length, offset + SIZEOF_UINT32);
|
|
75
|
+
});
|
|
76
|
+
codeOffset += buffer.length;
|
|
77
|
+
});
|
|
78
|
+
return table;
|
|
79
|
+
}
|
|
80
|
+
function groupCode(rootCode, moduleGroup, modulesById) {
|
|
81
|
+
if (!moduleGroup || !moduleGroup.size) {
|
|
82
|
+
return rootCode;
|
|
83
|
+
}
|
|
84
|
+
const code = [rootCode];
|
|
85
|
+
for (const id of moduleGroup) {
|
|
86
|
+
code.push((modulesById.get(id) || { code: "" }).code);
|
|
87
|
+
}
|
|
88
|
+
return code.join("\n");
|
|
89
|
+
}
|
|
90
|
+
function buildModuleBuffers(modules, moduleGroups, encoding) {
|
|
91
|
+
return modules.filter((m) => !moduleGroups.modulesInGroups.has(m.id)).map(
|
|
92
|
+
({ id, code }) => moduleToBuffer(id, groupCode(code, moduleGroups.groups.get(id), moduleGroups.modulesById), encoding)
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
function buildTableAndContents(startupCode, modules, moduleGroups, encoding) {
|
|
96
|
+
const startupCodeBuffer = nullTerminatedBuffer(startupCode, encoding);
|
|
97
|
+
const moduleBuffers = buildModuleBuffers(modules, moduleGroups, encoding);
|
|
98
|
+
const table = buildModuleTable(startupCodeBuffer, moduleBuffers, moduleGroups);
|
|
99
|
+
return [fileHeader, table, startupCodeBuffer].concat(moduleBuffers.map(({ buffer }) => buffer));
|
|
100
|
+
}
|
|
101
|
+
function createModuleGroups(groups, modules) {
|
|
102
|
+
return {
|
|
103
|
+
groups,
|
|
104
|
+
modulesById: new Map(modules.map((m) => [m.id, m])),
|
|
105
|
+
modulesInGroups: new Set(concat(groups.values()))
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
function* concat(iterators) {
|
|
109
|
+
for (const it of iterators) {
|
|
110
|
+
yield* it;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
exports.save = saveAsIndexedFile;
|
|
114
|
+
exports.buildTableAndContents = buildTableAndContents;
|
|
115
|
+
exports.createModuleGroups = createModuleGroups;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const { combineSourceMaps, combineSourceMapsAddingOffsets, joinModules } = require("./util");
|
|
3
|
+
module.exports = ({ fixWrapperOffset, lazyModules, moduleGroups, startupModules }) => {
|
|
4
|
+
const options = fixWrapperOffset ? { fixWrapperOffset: true } : void 0;
|
|
5
|
+
const startupModule = {
|
|
6
|
+
code: joinModules(startupModules),
|
|
7
|
+
id: Number.MIN_SAFE_INTEGER,
|
|
8
|
+
map: combineSourceMaps(startupModules, void 0, options),
|
|
9
|
+
sourcePath: ""
|
|
10
|
+
};
|
|
11
|
+
const module_paths = [];
|
|
12
|
+
startupModules.forEach((m) => {
|
|
13
|
+
module_paths[m.id] = m.sourcePath;
|
|
14
|
+
});
|
|
15
|
+
lazyModules.forEach((m) => {
|
|
16
|
+
module_paths[m.id] = m.sourcePath;
|
|
17
|
+
});
|
|
18
|
+
const map = combineSourceMapsAddingOffsets([startupModule].concat(lazyModules), module_paths, moduleGroups, options);
|
|
19
|
+
if (map.x_facebook_offsets != null) {
|
|
20
|
+
delete map.x_facebook_offsets[Number.MIN_SAFE_INTEGER];
|
|
21
|
+
}
|
|
22
|
+
return map;
|
|
23
|
+
};
|
|
@@ -0,0 +1,94 @@
|
|
|
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_countLines = __toESM(require("../../../lib/countLines"));
|
|
25
|
+
const invariant = require("invariant");
|
|
26
|
+
function lineToLineSourceMap(source, filename = "") {
|
|
27
|
+
const firstLine = "AAAA;";
|
|
28
|
+
const line = "AACA;";
|
|
29
|
+
return {
|
|
30
|
+
file: filename,
|
|
31
|
+
mappings: firstLine + Array((0, import_countLines.default)(source)).join(line),
|
|
32
|
+
sources: [filename],
|
|
33
|
+
names: [],
|
|
34
|
+
version: 3
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
const wrapperEnd = (wrappedCode) => wrappedCode.indexOf("{") + 1;
|
|
38
|
+
const Section = (line, column, map) => ({
|
|
39
|
+
map,
|
|
40
|
+
offset: { line, column }
|
|
41
|
+
});
|
|
42
|
+
function combineSourceMaps(modules, moduleGroups, options) {
|
|
43
|
+
const sections = combineMaps(modules, null, moduleGroups, options);
|
|
44
|
+
return { sections, version: 3 };
|
|
45
|
+
}
|
|
46
|
+
function combineSourceMapsAddingOffsets(modules, x_metro_module_paths, moduleGroups, options) {
|
|
47
|
+
const x_facebook_offsets = [];
|
|
48
|
+
const sections = combineMaps(modules, x_facebook_offsets, moduleGroups, options);
|
|
49
|
+
return { sections, version: 3, x_facebook_offsets, x_metro_module_paths };
|
|
50
|
+
}
|
|
51
|
+
function combineMaps(modules, offsets, moduleGroups, options) {
|
|
52
|
+
const sections = [];
|
|
53
|
+
let line = 0;
|
|
54
|
+
modules.forEach((moduleTransport) => {
|
|
55
|
+
const { code, id, name } = moduleTransport;
|
|
56
|
+
let column = 0;
|
|
57
|
+
let group;
|
|
58
|
+
let groupLines = 0;
|
|
59
|
+
let { map } = moduleTransport;
|
|
60
|
+
if (moduleGroups && moduleGroups.modulesInGroups.has(id)) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (offsets != null) {
|
|
64
|
+
group = moduleGroups && moduleGroups.groups.get(id);
|
|
65
|
+
if (group && moduleGroups) {
|
|
66
|
+
const { modulesById } = moduleGroups;
|
|
67
|
+
const otherModules = Array.from(group || []).map((moduleId) => modulesById.get(moduleId)).filter(Boolean);
|
|
68
|
+
otherModules.forEach((m) => {
|
|
69
|
+
groupLines += (0, import_countLines.default)(m.code);
|
|
70
|
+
});
|
|
71
|
+
map = combineSourceMaps([moduleTransport].concat(otherModules));
|
|
72
|
+
}
|
|
73
|
+
column = options && options.fixWrapperOffset ? wrapperEnd(code) : 0;
|
|
74
|
+
}
|
|
75
|
+
invariant(!Array.isArray(map), "Random Access Bundle source maps cannot be built from raw mappings");
|
|
76
|
+
sections.push(Section(line, column, map || lineToLineSourceMap(code, name)));
|
|
77
|
+
if (offsets != null && id != null) {
|
|
78
|
+
offsets[id] = line;
|
|
79
|
+
for (const moduleId of group || []) {
|
|
80
|
+
offsets[moduleId] = line;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
line += (0, import_countLines.default)(code) + groupLines;
|
|
84
|
+
});
|
|
85
|
+
return sections;
|
|
86
|
+
}
|
|
87
|
+
const joinModules = (modules) => modules.map((m) => m.code).join("\n");
|
|
88
|
+
module.exports = {
|
|
89
|
+
combineSourceMaps,
|
|
90
|
+
combineSourceMapsAddingOffsets,
|
|
91
|
+
countLines: import_countLines.default,
|
|
92
|
+
joinModules,
|
|
93
|
+
lineToLineSourceMap
|
|
94
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const writeFile = require("../writeFile");
|
|
3
|
+
function writeSourcemap(fileName, contents, log) {
|
|
4
|
+
if (!fileName) {
|
|
5
|
+
return Promise.resolve();
|
|
6
|
+
}
|
|
7
|
+
log("Writing sourcemap output to:", fileName);
|
|
8
|
+
const writeMap = writeFile(fileName, contents, null);
|
|
9
|
+
writeMap.then(() => log("Done writing sourcemap output"));
|
|
10
|
+
return writeMap;
|
|
11
|
+
}
|
|
12
|
+
module.exports = writeSourcemap;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const Server = require("../../Server");
|
|
3
|
+
const asAssets = require("./RamBundle/as-assets");
|
|
4
|
+
const asIndexedFile = require("./RamBundle/as-indexed-file").save;
|
|
5
|
+
async function build(packagerClient, requestOptions) {
|
|
6
|
+
const options = {
|
|
7
|
+
...Server.DEFAULT_BUNDLE_OPTIONS,
|
|
8
|
+
...requestOptions,
|
|
9
|
+
bundleType: "ram"
|
|
10
|
+
};
|
|
11
|
+
return await packagerClient.getRamBundleInfo(options);
|
|
12
|
+
}
|
|
13
|
+
function save(bundle, options, log) {
|
|
14
|
+
return options.platform === "android" && !(options.indexedRamBundle === true) ? asAssets(bundle, options, log) : asIndexedFile(bundle, options, log);
|
|
15
|
+
}
|
|
16
|
+
exports.build = build;
|
|
17
|
+
exports.save = save;
|
|
18
|
+
exports.formatName = "bundle";
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const relativizeSourceMapInline = require("../../lib/relativizeSourceMap");
|
|
3
|
+
const Server = require("../../Server");
|
|
4
|
+
const writeFile = require("./writeFile");
|
|
5
|
+
function buildBundle(packagerClient, requestOptions) {
|
|
6
|
+
return packagerClient.build({
|
|
7
|
+
...Server.DEFAULT_BUNDLE_OPTIONS,
|
|
8
|
+
...requestOptions,
|
|
9
|
+
bundleType: "bundle"
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
function relativateSerializedMap(map, sourceMapSourcesRoot) {
|
|
13
|
+
const sourceMap = JSON.parse(map);
|
|
14
|
+
relativizeSourceMapInline(sourceMap, sourceMapSourcesRoot);
|
|
15
|
+
return JSON.stringify(sourceMap);
|
|
16
|
+
}
|
|
17
|
+
async function saveBundleAndMap(bundle, options, log) {
|
|
18
|
+
const { bundleOutput, bundleEncoding: encoding, sourcemapOutput, sourcemapSourcesRoot } = options;
|
|
19
|
+
const writeFns = [];
|
|
20
|
+
writeFns.push(async () => {
|
|
21
|
+
log("Writing bundle output to:", bundleOutput);
|
|
22
|
+
await writeFile(bundleOutput, bundle.code, encoding);
|
|
23
|
+
log("Done writing bundle output");
|
|
24
|
+
});
|
|
25
|
+
if (sourcemapOutput) {
|
|
26
|
+
let { map } = bundle;
|
|
27
|
+
if (sourcemapSourcesRoot !== void 0) {
|
|
28
|
+
log("start relativating source map");
|
|
29
|
+
map = relativateSerializedMap(map, sourcemapSourcesRoot);
|
|
30
|
+
log("finished relativating");
|
|
31
|
+
}
|
|
32
|
+
writeFns.push(async () => {
|
|
33
|
+
log("Writing sourcemap output to:", sourcemapOutput);
|
|
34
|
+
await writeFile(sourcemapOutput, map, null);
|
|
35
|
+
log("Done writing sourcemap output");
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
await Promise.all(writeFns.map((cb) => cb()));
|
|
39
|
+
}
|
|
40
|
+
exports.build = buildBundle;
|
|
41
|
+
exports.save = saveBundleAndMap;
|
|
42
|
+
exports.formatName = "bundle";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const crypto = require("crypto");
|
|
3
|
+
const isUTF8 = (encoding) => /^utf-?8$/i.test(encoding);
|
|
4
|
+
const constantFor = (encoding) => /^ascii$/i.test(encoding) ? 1 : isUTF8(encoding) ? 2 : /^(?:utf-?16(?:le)?|ucs-?2)$/.test(encoding) ? 3 : 0;
|
|
5
|
+
module.exports = function(code, encoding = "utf8") {
|
|
6
|
+
const buffer = asBuffer(code, encoding);
|
|
7
|
+
const hash = crypto.createHash("sha1");
|
|
8
|
+
hash.update(buffer);
|
|
9
|
+
const digest = hash.digest("buffer");
|
|
10
|
+
const signature = Buffer.alloc(digest.length + 1);
|
|
11
|
+
digest.copy(signature);
|
|
12
|
+
signature.writeUInt8(constantFor(tryAsciiPromotion(buffer, encoding)), signature.length - 1);
|
|
13
|
+
return signature;
|
|
14
|
+
};
|
|
15
|
+
function tryAsciiPromotion(buffer, encoding) {
|
|
16
|
+
if (!isUTF8(encoding)) {
|
|
17
|
+
return encoding;
|
|
18
|
+
}
|
|
19
|
+
for (let i = 0, n = buffer.length; i < n; i++) {
|
|
20
|
+
if (buffer[i] > 127) {
|
|
21
|
+
return encoding;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return "ascii";
|
|
25
|
+
}
|
|
26
|
+
function asBuffer(x, encoding) {
|
|
27
|
+
if (typeof x !== "string") {
|
|
28
|
+
return x;
|
|
29
|
+
}
|
|
30
|
+
return Buffer.from(x, encoding);
|
|
31
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|