@granite-js/mpack 0.0.0-dev-20250725013859
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/LICENSE +202 -0
- package/README.md +24 -0
- package/dist/bundler/Bundler.d.ts +24 -0
- package/dist/bundler/Bundler.js +180 -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/internal/presets.d.ts +18 -0
- package/dist/bundler/internal/presets.js +103 -0
- package/dist/bundler/plugins/buildStatusPlugin/buildStatusPlugin.d.ts +12 -0
- package/dist/bundler/plugins/buildStatusPlugin/buildStatusPlugin.js +74 -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 +16 -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 +10 -0
- package/dist/index.js +56 -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 +27 -0
- package/dist/metro/getMetroConfig.js +137 -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 +10 -0
- package/dist/metro/runBuild.js +57 -0
- package/dist/metro/types.d.ts +92 -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 +13 -0
- package/dist/operations/experimental/runServer.js +130 -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 +6 -0
- package/dist/operations/runBundle.js +60 -0
- package/dist/operations/runServer.d.ts +13 -0
- package/dist/operations/runServer.js +131 -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 +26 -0
- package/dist/server/DevServer.js +215 -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 +8 -0
- package/dist/server/helpers/createBundlerForDevServer.js +48 -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 +92 -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 +187 -0
- package/dist/types/BuildConfig.js +16 -0
- package/dist/types/BundlerConfig.d.ts +23 -0
- package/dist/types/BundlerConfig.js +16 -0
- package/dist/types/DevServer.d.ts +10 -0
- package/dist/types/DevServer.js +16 -0
- package/dist/types/Id.d.ts +3 -0
- package/dist/types/Id.js +16 -0
- package/dist/types/Plugin.d.ts +28 -0
- package/dist/types/Plugin.js +16 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.js +30 -0
- package/dist/types/schemas/buildConfigSchema.d.ts +131 -0
- package/dist/types/schemas/buildConfigSchema.js +70 -0
- package/dist/types/schemas/index.d.ts +1 -0
- package/dist/types/schemas/index.js +22 -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 +34 -0
- package/dist/utils/getSourcemapName.d.ts +1 -0
- package/dist/utils/getSourcemapName.js +30 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/index.js +34 -0
- package/dist/utils/isDebugMode.d.ts +1 -0
- package/dist/utils/isDebugMode.js +30 -0
- package/dist/utils/md5.d.ts +1 -0
- package/dist/utils/md5.js +41 -0
- package/dist/utils/mergeBabel.d.ts +2 -0
- package/dist/utils/mergeBabel.js +45 -0
- package/dist/utils/mergeBuildConfigs.d.ts +2 -0
- package/dist/utils/mergeBuildConfigs.js +50 -0
- package/dist/utils/mergeEsbuild.d.ts +2 -0
- package/dist/utils/mergeEsbuild.js +54 -0
- package/dist/utils/mergeExtra.d.ts +1 -0
- package/dist/utils/mergeExtra.js +39 -0
- package/dist/utils/mergeResolver.d.ts +2 -0
- package/dist/utils/mergeResolver.js +45 -0
- package/dist/utils/mergeSwc.d.ts +2 -0
- package/dist/utils/mergeSwc.js +43 -0
- package/dist/utils/mergeTransformer.d.ts +2 -0
- package/dist/utils/mergeTransformer.js +69 -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/ReportableEvent.d.ts +152 -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 +429 -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 +163 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var CountingSet_exports = {};
|
|
20
|
+
__export(CountingSet_exports, {
|
|
21
|
+
default: () => CountingSet
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(CountingSet_exports);
|
|
24
|
+
class CountingSet {
|
|
25
|
+
#map = /* @__PURE__ */ new Map();
|
|
26
|
+
constructor(items) {
|
|
27
|
+
if (items) {
|
|
28
|
+
if (items instanceof CountingSet) {
|
|
29
|
+
this.#map = new Map(items.#map);
|
|
30
|
+
} else {
|
|
31
|
+
for (const item of items) {
|
|
32
|
+
this.add(item);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
has(item) {
|
|
38
|
+
return this.#map.has(item);
|
|
39
|
+
}
|
|
40
|
+
add(item) {
|
|
41
|
+
const newCount = this.count(item) + 1;
|
|
42
|
+
this.#map.set(item, newCount);
|
|
43
|
+
}
|
|
44
|
+
delete(item) {
|
|
45
|
+
const newCount = this.count(item) - 1;
|
|
46
|
+
if (newCount <= 0) {
|
|
47
|
+
this.#map.delete(item);
|
|
48
|
+
} else {
|
|
49
|
+
this.#map.set(item, newCount);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
keys() {
|
|
53
|
+
return this.#map.keys();
|
|
54
|
+
}
|
|
55
|
+
values() {
|
|
56
|
+
return this.#map.keys();
|
|
57
|
+
}
|
|
58
|
+
*entries() {
|
|
59
|
+
for (const item of this) {
|
|
60
|
+
yield [item, item];
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
// Iterate over unique entries
|
|
64
|
+
// $FlowIssue[unsupported-syntax]
|
|
65
|
+
[Symbol.iterator]() {
|
|
66
|
+
return this.values();
|
|
67
|
+
}
|
|
68
|
+
/*::
|
|
69
|
+
// For Flow's benefit
|
|
70
|
+
@@iterator(): Iterator<T> {
|
|
71
|
+
return this.values();
|
|
72
|
+
}
|
|
73
|
+
*/
|
|
74
|
+
// Number of unique entries
|
|
75
|
+
// $FlowIssue[unsafe-getters-setters]
|
|
76
|
+
get size() {
|
|
77
|
+
return this.#map.size;
|
|
78
|
+
}
|
|
79
|
+
count(item) {
|
|
80
|
+
return this.#map.get(item) ?? 0;
|
|
81
|
+
}
|
|
82
|
+
clear() {
|
|
83
|
+
this.#map.clear();
|
|
84
|
+
}
|
|
85
|
+
forEach(callbackFn, thisArg) {
|
|
86
|
+
for (const item of this) {
|
|
87
|
+
callbackFn.call(thisArg, item, item, this);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
// For Jest purposes. Ideally a custom serializer would be enough, but in
|
|
91
|
+
// practice there is hardcoded magic for Set in toEqual (etc) that we cannot
|
|
92
|
+
// extend to custom collection classes. Instead let's assume values are
|
|
93
|
+
// sortable ( = strings) and make this look like an array with some stable
|
|
94
|
+
// order.
|
|
95
|
+
toJSON() {
|
|
96
|
+
return [...this].sort();
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
class JsonReporter {
|
|
3
|
+
_stream;
|
|
4
|
+
constructor(stream) {
|
|
5
|
+
this._stream = stream;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* There is a special case for errors because they have non-enumerable fields.
|
|
9
|
+
* (Perhaps we should switch in favor of plain object?)
|
|
10
|
+
*/
|
|
11
|
+
update(event) {
|
|
12
|
+
if (Object.prototype.toString.call(event.error) === "[object Error]") {
|
|
13
|
+
event = Object.assign(event, {
|
|
14
|
+
message: event.error.message,
|
|
15
|
+
stack: event.error.stack
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
this._stream.write(JSON.stringify(event) + "\n");
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
module.exports = JsonReporter;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const MAGIC_NUMBER = require("../shared/output/RamBundle/magic-number");
|
|
3
|
+
const SIZEOF_UINT32 = 4;
|
|
4
|
+
const HEADER_SIZE = 3;
|
|
5
|
+
class RamBundleParser {
|
|
6
|
+
_buffer;
|
|
7
|
+
_numModules;
|
|
8
|
+
_startupCodeLength;
|
|
9
|
+
_startOffset;
|
|
10
|
+
// $FlowFixMe[missing-local-annot]
|
|
11
|
+
constructor(buffer) {
|
|
12
|
+
this._buffer = buffer;
|
|
13
|
+
if (this._readPosition(0) !== MAGIC_NUMBER) {
|
|
14
|
+
throw new Error("File is not a RAM bundle file");
|
|
15
|
+
}
|
|
16
|
+
this._numModules = this._readPosition(1);
|
|
17
|
+
this._startupCodeLength = this._readPosition(2);
|
|
18
|
+
this._startOffset = (HEADER_SIZE + this._numModules * 2) * SIZEOF_UINT32;
|
|
19
|
+
}
|
|
20
|
+
_readPosition(pos) {
|
|
21
|
+
return this._buffer.readUInt32LE(pos * SIZEOF_UINT32);
|
|
22
|
+
}
|
|
23
|
+
getStartupCode() {
|
|
24
|
+
const start = this._startOffset;
|
|
25
|
+
const end = start + this._startupCodeLength - 1;
|
|
26
|
+
return this._buffer.toString("utf8", start, end);
|
|
27
|
+
}
|
|
28
|
+
getModule(id) {
|
|
29
|
+
const moduleOffset = this._readPosition(HEADER_SIZE + id * 2);
|
|
30
|
+
const moduleLength = this._readPosition(HEADER_SIZE + id * 2 + 1);
|
|
31
|
+
const start = this._startOffset + moduleOffset;
|
|
32
|
+
const end = start + moduleLength - 1;
|
|
33
|
+
return this._buffer.toString("utf8", start, end);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
module.exports = RamBundleParser;
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
interface BundleDetails {
|
|
2
|
+
bundleType: string;
|
|
3
|
+
dev: boolean;
|
|
4
|
+
entryFile: string;
|
|
5
|
+
minify: boolean;
|
|
6
|
+
platform?: string;
|
|
7
|
+
runtimeBytecodeVersion?: number;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
type WatcherStatus =
|
|
11
|
+
| {
|
|
12
|
+
type: 'watchman_slow_command';
|
|
13
|
+
timeElapsed: number;
|
|
14
|
+
command: 'watch-project' | 'query';
|
|
15
|
+
}
|
|
16
|
+
| {
|
|
17
|
+
type: 'watchman_slow_command_complete';
|
|
18
|
+
timeElapsed: number;
|
|
19
|
+
command: 'watch-project' | 'query';
|
|
20
|
+
}
|
|
21
|
+
| {
|
|
22
|
+
type: 'watchman_warning';
|
|
23
|
+
warning: unknown;
|
|
24
|
+
command: 'watch-project' | 'query';
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
type HealthCheckResult =
|
|
28
|
+
| {type: 'error'; timeout: number; error: Error; watcher: string | null}
|
|
29
|
+
| {
|
|
30
|
+
type: 'success';
|
|
31
|
+
timeout: number;
|
|
32
|
+
timeElapsed: number;
|
|
33
|
+
watcher: string | null;
|
|
34
|
+
}
|
|
35
|
+
| {
|
|
36
|
+
type: 'timeout';
|
|
37
|
+
timeout: number;
|
|
38
|
+
watcher: string | null;
|
|
39
|
+
pauseReason: string | null;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export type ReportableEvent =
|
|
43
|
+
| {
|
|
44
|
+
port: number;
|
|
45
|
+
hasReducedPerformance: boolean;
|
|
46
|
+
type: 'initialize_started';
|
|
47
|
+
}
|
|
48
|
+
| {
|
|
49
|
+
type: 'initialize_failed';
|
|
50
|
+
port: number;
|
|
51
|
+
error: Error;
|
|
52
|
+
}
|
|
53
|
+
| {
|
|
54
|
+
type: 'initialize_done';
|
|
55
|
+
port: number;
|
|
56
|
+
}
|
|
57
|
+
| {
|
|
58
|
+
buildID: string;
|
|
59
|
+
type: 'bundle_build_done';
|
|
60
|
+
}
|
|
61
|
+
| {
|
|
62
|
+
buildID: string;
|
|
63
|
+
type: 'bundle_build_failed';
|
|
64
|
+
}
|
|
65
|
+
| {
|
|
66
|
+
type: 'bundle_save_log';
|
|
67
|
+
message: string;
|
|
68
|
+
}
|
|
69
|
+
| {
|
|
70
|
+
buildID: string;
|
|
71
|
+
bundleDetails: BundleDetails;
|
|
72
|
+
isPrefetch?: boolean;
|
|
73
|
+
type: 'bundle_build_started';
|
|
74
|
+
}
|
|
75
|
+
| {
|
|
76
|
+
error: Error;
|
|
77
|
+
type: 'bundling_error';
|
|
78
|
+
}
|
|
79
|
+
| {
|
|
80
|
+
type: 'dep_graph_loading';
|
|
81
|
+
hasReducedPerformance: boolean;
|
|
82
|
+
}
|
|
83
|
+
| {type: 'dep_graph_loaded'}
|
|
84
|
+
| {
|
|
85
|
+
buildID: string;
|
|
86
|
+
type: 'bundle_transform_progressed';
|
|
87
|
+
transformedFileCount: number;
|
|
88
|
+
totalFileCount: number;
|
|
89
|
+
}
|
|
90
|
+
| {
|
|
91
|
+
type: 'cache_read_error';
|
|
92
|
+
error: Error;
|
|
93
|
+
}
|
|
94
|
+
| {
|
|
95
|
+
type: 'cache_write_error';
|
|
96
|
+
error: Error;
|
|
97
|
+
}
|
|
98
|
+
| {type: 'transform_cache_reset'}
|
|
99
|
+
| {
|
|
100
|
+
type: 'worker_stdout_chunk';
|
|
101
|
+
chunk: string;
|
|
102
|
+
}
|
|
103
|
+
| {
|
|
104
|
+
type: 'worker_stderr_chunk';
|
|
105
|
+
chunk: string;
|
|
106
|
+
}
|
|
107
|
+
| {
|
|
108
|
+
type: 'hmr_client_error';
|
|
109
|
+
error: Error;
|
|
110
|
+
}
|
|
111
|
+
| {
|
|
112
|
+
type: 'client_log';
|
|
113
|
+
level:
|
|
114
|
+
| 'trace'
|
|
115
|
+
| 'info'
|
|
116
|
+
| 'warn'
|
|
117
|
+
| 'log'
|
|
118
|
+
| 'group'
|
|
119
|
+
| 'groupCollapsed'
|
|
120
|
+
| 'groupEnd'
|
|
121
|
+
| 'debug';
|
|
122
|
+
data: Array<unknown>;
|
|
123
|
+
mode: 'BRIDGE' | 'NOBRIDGE';
|
|
124
|
+
}
|
|
125
|
+
| {
|
|
126
|
+
type: 'resolver_warning';
|
|
127
|
+
message: string;
|
|
128
|
+
}
|
|
129
|
+
| {
|
|
130
|
+
type: 'server_listening';
|
|
131
|
+
port: number;
|
|
132
|
+
address: string;
|
|
133
|
+
family: string;
|
|
134
|
+
}
|
|
135
|
+
| {
|
|
136
|
+
type: 'transformer_load_started';
|
|
137
|
+
}
|
|
138
|
+
| {
|
|
139
|
+
type: 'transformer_load_done';
|
|
140
|
+
}
|
|
141
|
+
| {
|
|
142
|
+
type: 'transformer_load_failed';
|
|
143
|
+
error: Error;
|
|
144
|
+
}
|
|
145
|
+
| {
|
|
146
|
+
type: 'watcher_health_check_result';
|
|
147
|
+
result: HealthCheckResult;
|
|
148
|
+
}
|
|
149
|
+
| {
|
|
150
|
+
type: 'watcher_status';
|
|
151
|
+
status: WatcherStatus;
|
|
152
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ReportableEvent } from "./ReportableEvent";
|
|
2
|
+
type Terminal = any;
|
|
3
|
+
type TerminalReportableEvent =
|
|
4
|
+
| ReportableEvent
|
|
5
|
+
| {
|
|
6
|
+
buildID: string;
|
|
7
|
+
type: 'bundle_transform_progressed_throttled';
|
|
8
|
+
transformedFileCount: number;
|
|
9
|
+
totalFileCount: number;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
declare class TerminalReporter {
|
|
13
|
+
readonly terminal: Terminal;
|
|
14
|
+
constructor(terminal: Terminal);
|
|
15
|
+
update(event: TerminalReportableEvent): void;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default TerminalReporter;
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const logToConsole = require("./logToConsole");
|
|
3
|
+
const reporting = require("./reporting");
|
|
4
|
+
const chalk = require("chalk");
|
|
5
|
+
const throttle = require("lodash.throttle");
|
|
6
|
+
const { AmbiguousModuleResolutionError } = require("../../../metro-core/src");
|
|
7
|
+
const path = require("path");
|
|
8
|
+
const debug = require("debug")("metro");
|
|
9
|
+
const GLOBAL_CACHE_DISABLED_MESSAGE_FORMAT = "The global cache is now disabled because %s";
|
|
10
|
+
const DARK_BLOCK_CHAR = "\u2593";
|
|
11
|
+
const LIGHT_BLOCK_CHAR = "\u2591";
|
|
12
|
+
const MAX_PROGRESS_BAR_CHAR_WIDTH = 16;
|
|
13
|
+
class TerminalReporter {
|
|
14
|
+
/**
|
|
15
|
+
* The bundle builds for which we are actively maintaining the status on the
|
|
16
|
+
* terminal, ie. showing a progress bar. There can be several bundles being
|
|
17
|
+
* built at the same time.
|
|
18
|
+
*/
|
|
19
|
+
_activeBundles;
|
|
20
|
+
_scheduleUpdateBundleProgress;
|
|
21
|
+
terminal;
|
|
22
|
+
constructor(terminal) {
|
|
23
|
+
this._activeBundles = /* @__PURE__ */ new Map();
|
|
24
|
+
this._scheduleUpdateBundleProgress = throttle((data) => {
|
|
25
|
+
this.update({ ...data, type: "bundle_transform_progressed_throttled" });
|
|
26
|
+
}, 100);
|
|
27
|
+
this.terminal = terminal;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Construct a message that represents the progress of a
|
|
31
|
+
* single bundle build, for example:
|
|
32
|
+
*
|
|
33
|
+
* BUNDLE path/to/bundle.js ▓▓▓▓▓░░░░░░░░░░░ 36.6% (4790/7922)
|
|
34
|
+
*/
|
|
35
|
+
_getBundleStatusMessage({ bundleDetails: { entryFile, bundleType, runtimeBytecodeVersion }, transformedFileCount, totalFileCount, ratio }, phase) {
|
|
36
|
+
if (runtimeBytecodeVersion) {
|
|
37
|
+
bundleType = "bytecodebundle";
|
|
38
|
+
}
|
|
39
|
+
const localPath = path.relative(".", entryFile);
|
|
40
|
+
const filledBar = Math.floor(ratio * MAX_PROGRESS_BAR_CHAR_WIDTH);
|
|
41
|
+
const bundleTypeColor = phase === "done" ? chalk.green : phase === "failed" ? chalk.red : chalk.yellow;
|
|
42
|
+
const progress = phase === "in_progress" ? chalk.green.bgGreen(DARK_BLOCK_CHAR.repeat(filledBar)) + chalk.bgWhite.white(LIGHT_BLOCK_CHAR.repeat(MAX_PROGRESS_BAR_CHAR_WIDTH - filledBar)) + chalk.bold(` ${(100 * ratio).toFixed(1)}% `) + chalk.dim(`(${transformedFileCount}/${totalFileCount})`) : "";
|
|
43
|
+
return bundleTypeColor.inverse.bold(` ${bundleType.toUpperCase()} `) + chalk.reset.dim(` ${path.dirname(localPath)}/`) + chalk.bold(path.basename(localPath)) + " " + progress + "\n";
|
|
44
|
+
}
|
|
45
|
+
_logCacheDisabled(reason) {
|
|
46
|
+
const format = GLOBAL_CACHE_DISABLED_MESSAGE_FORMAT;
|
|
47
|
+
switch (reason) {
|
|
48
|
+
case "too_many_errors":
|
|
49
|
+
reporting.logWarning(this.terminal, format, "it has been failing too many times.");
|
|
50
|
+
break;
|
|
51
|
+
case "too_many_misses":
|
|
52
|
+
reporting.logWarning(this.terminal, format, "it has been missing too many consecutive keys.");
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
_logBundleBuildDone(buildID) {
|
|
57
|
+
const progress = this._activeBundles.get(buildID);
|
|
58
|
+
if (progress != null) {
|
|
59
|
+
const msg = this._getBundleStatusMessage(
|
|
60
|
+
{
|
|
61
|
+
...progress,
|
|
62
|
+
ratio: 1,
|
|
63
|
+
transformedFileCount: progress.totalFileCount
|
|
64
|
+
},
|
|
65
|
+
"done"
|
|
66
|
+
);
|
|
67
|
+
this.terminal.log(msg);
|
|
68
|
+
this._activeBundles.delete(buildID);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
_logBundleBuildFailed(buildID) {
|
|
72
|
+
const progress = this._activeBundles.get(buildID);
|
|
73
|
+
if (progress != null) {
|
|
74
|
+
const msg = this._getBundleStatusMessage(progress, "failed");
|
|
75
|
+
this.terminal.log(msg);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
_logInitializing(port, hasReducedPerformance) {
|
|
79
|
+
}
|
|
80
|
+
_logInitializingFailed(port, error) {
|
|
81
|
+
if (error.code === "EADDRINUSE") {
|
|
82
|
+
this.terminal.log(chalk.bgRed.bold(" ERROR "), chalk.red("Metro can't listen on port", chalk.bold(String(port))));
|
|
83
|
+
this.terminal.log("Most likely another process is already using this port");
|
|
84
|
+
this.terminal.log("Run the following command to find out which process:");
|
|
85
|
+
this.terminal.log("\n ", chalk.bold("lsof -i :" + port), "\n");
|
|
86
|
+
this.terminal.log("Then, you can either shut down the other process:");
|
|
87
|
+
this.terminal.log("\n ", chalk.bold("kill -9 <PID>"), "\n");
|
|
88
|
+
this.terminal.log("or run Metro on different port.");
|
|
89
|
+
} else {
|
|
90
|
+
this.terminal.log(chalk.bgRed.bold(" ERROR "), chalk.red(error.message));
|
|
91
|
+
const errorAttributes = JSON.stringify(error);
|
|
92
|
+
if (errorAttributes !== "{}") {
|
|
93
|
+
this.terminal.log(chalk.red(errorAttributes));
|
|
94
|
+
}
|
|
95
|
+
this.terminal.log(chalk.red(error.stack));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* This function is only concerned with logging and should not do state
|
|
100
|
+
* or terminal status updates.
|
|
101
|
+
*/
|
|
102
|
+
_log(event) {
|
|
103
|
+
switch (event.type) {
|
|
104
|
+
case "initialize_started":
|
|
105
|
+
this._logInitializing(event.port, event.hasReducedPerformance);
|
|
106
|
+
break;
|
|
107
|
+
case "initialize_failed":
|
|
108
|
+
this._logInitializingFailed(event.port, event.error);
|
|
109
|
+
break;
|
|
110
|
+
case "bundle_build_done":
|
|
111
|
+
this._logBundleBuildDone(event.buildID);
|
|
112
|
+
break;
|
|
113
|
+
case "bundle_build_failed":
|
|
114
|
+
this._logBundleBuildFailed(event.buildID);
|
|
115
|
+
break;
|
|
116
|
+
case "bundling_error":
|
|
117
|
+
this._logBundlingError(event.error);
|
|
118
|
+
break;
|
|
119
|
+
case "global_cache_disabled":
|
|
120
|
+
this._logCacheDisabled(event.reason);
|
|
121
|
+
break;
|
|
122
|
+
case "transform_cache_reset":
|
|
123
|
+
debug("the transform cache was reset.");
|
|
124
|
+
break;
|
|
125
|
+
case "worker_stdout_chunk":
|
|
126
|
+
this._logWorkerChunk("stdout", event.chunk);
|
|
127
|
+
break;
|
|
128
|
+
case "worker_stderr_chunk":
|
|
129
|
+
this._logWorkerChunk("stderr", event.chunk);
|
|
130
|
+
break;
|
|
131
|
+
case "hmr_client_error":
|
|
132
|
+
this._logHmrClientError(event.error);
|
|
133
|
+
break;
|
|
134
|
+
case "client_log":
|
|
135
|
+
logToConsole(this.terminal, event.level, event.mode, ...event.data);
|
|
136
|
+
break;
|
|
137
|
+
case "dep_graph_loading":
|
|
138
|
+
if (event.hasReducedPerformance) {
|
|
139
|
+
this.terminal.log(
|
|
140
|
+
chalk.red(
|
|
141
|
+
"Metro is operating with reduced performance.\nPlease fix the problem above and restart Metro.\n\n"
|
|
142
|
+
)
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* We do not want to log the whole stacktrace for bundling error, because
|
|
150
|
+
* these are operational errors, not programming errors, and the stacktrace
|
|
151
|
+
* is not actionable to end users.
|
|
152
|
+
*/
|
|
153
|
+
_logBundlingError(error) {
|
|
154
|
+
if (error instanceof AmbiguousModuleResolutionError) {
|
|
155
|
+
const he = error.hasteError;
|
|
156
|
+
const message2 = `ambiguous resolution: module \`${error.fromModulePath}\` tries to require \`${he.hasteName}\`, but there are several files providing this module. You can delete or fix them:
|
|
157
|
+
|
|
158
|
+
` + Object.keys(he.duplicatesSet).sort().map((dupFilePath) => ` * \`${dupFilePath}\`
|
|
159
|
+
`).join("");
|
|
160
|
+
reporting.logError(this.terminal, message2);
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
let { message } = error;
|
|
164
|
+
if (!(error instanceof SyntaxError)) {
|
|
165
|
+
if (error.snippet == null && error.stack != null) {
|
|
166
|
+
message = error.stack;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
if (error.filename && !message.includes(error.filename)) {
|
|
170
|
+
message += ` [${error.filename}]`;
|
|
171
|
+
}
|
|
172
|
+
if (error.snippet != null) {
|
|
173
|
+
message += "\n" + error.snippet;
|
|
174
|
+
}
|
|
175
|
+
reporting.logError(this.terminal, message);
|
|
176
|
+
}
|
|
177
|
+
_logWorkerChunk(origin, chunk) {
|
|
178
|
+
const lines = chunk.split("\n");
|
|
179
|
+
if (lines.length >= 1 && lines[lines.length - 1] === "") {
|
|
180
|
+
lines.splice(lines.length - 1, 1);
|
|
181
|
+
}
|
|
182
|
+
lines.forEach((line) => {
|
|
183
|
+
this.terminal.log(`transform[${origin}]: ${line}`);
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* We use Math.pow(ratio, 2) to as a conservative measure of progress because
|
|
188
|
+
* we know the `totalCount` is going to progressively increase as well. We
|
|
189
|
+
* also prevent the ratio from going backwards.
|
|
190
|
+
*/
|
|
191
|
+
_updateBundleProgress({ buildID, transformedFileCount, totalFileCount }) {
|
|
192
|
+
const currentProgress = this._activeBundles.get(buildID);
|
|
193
|
+
if (currentProgress == null) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
const rawRatio = transformedFileCount / totalFileCount;
|
|
197
|
+
const conservativeRatio = Math.pow(rawRatio, 2);
|
|
198
|
+
const ratio = Math.max(conservativeRatio, currentProgress.ratio);
|
|
199
|
+
Object.assign(currentProgress, {
|
|
200
|
+
ratio,
|
|
201
|
+
transformedFileCount,
|
|
202
|
+
totalFileCount
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* This function is exclusively concerned with updating the internal state.
|
|
207
|
+
* No logging or status updates should be done at this point.
|
|
208
|
+
*/
|
|
209
|
+
_updateState(event) {
|
|
210
|
+
switch (event.type) {
|
|
211
|
+
case "bundle_build_done":
|
|
212
|
+
case "bundle_build_failed":
|
|
213
|
+
this._activeBundles.delete(event.buildID);
|
|
214
|
+
break;
|
|
215
|
+
case "bundle_build_started":
|
|
216
|
+
const bundleProgress = {
|
|
217
|
+
bundleDetails: event.bundleDetails,
|
|
218
|
+
transformedFileCount: 0,
|
|
219
|
+
totalFileCount: 1,
|
|
220
|
+
ratio: 0
|
|
221
|
+
};
|
|
222
|
+
this._activeBundles.set(event.buildID, bundleProgress);
|
|
223
|
+
break;
|
|
224
|
+
case "bundle_transform_progressed_throttled":
|
|
225
|
+
this._updateBundleProgress(event);
|
|
226
|
+
break;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Return a status message that is always consistent with the current state
|
|
231
|
+
* of the application. Having this single function ensures we don't have
|
|
232
|
+
* different callsites overriding each other status messages.
|
|
233
|
+
*/
|
|
234
|
+
_getStatusMessage() {
|
|
235
|
+
return Array.from(this._activeBundles.entries()).map(([_, progress]) => this._getBundleStatusMessage(progress, "in_progress")).filter((str) => str != null).join("\n");
|
|
236
|
+
}
|
|
237
|
+
_logHmrClientError(e) {
|
|
238
|
+
reporting.logError(
|
|
239
|
+
this.terminal,
|
|
240
|
+
"A WebSocket client got a connection error. Please reload your device to get HMR working again: %s",
|
|
241
|
+
e
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Single entry point for reporting events. That allows us to implement the
|
|
246
|
+
* corresponding JSON reporter easily and have a consistent repor∏ting.
|
|
247
|
+
*/
|
|
248
|
+
update(event) {
|
|
249
|
+
if (event.type === "bundle_transform_progressed") {
|
|
250
|
+
this._scheduleUpdateBundleProgress(event);
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
this._log(event);
|
|
254
|
+
this._updateState(event);
|
|
255
|
+
this.terminal.status(this._getStatusMessage());
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
module.exports = TerminalReporter;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const MAGIC_NUMBER = 4293379011;
|
|
3
|
+
function getFileHeader(moduleCount) {
|
|
4
|
+
const buffer = Buffer.alloc(8);
|
|
5
|
+
buffer.writeUInt32LE(MAGIC_NUMBER, 0);
|
|
6
|
+
buffer.writeUInt32LE(moduleCount, 4);
|
|
7
|
+
return buffer;
|
|
8
|
+
}
|
|
9
|
+
function addModuleHeader(buffer) {
|
|
10
|
+
const { getFileLength } = require("metro-hermes-compiler");
|
|
11
|
+
const fileLength = getFileLength(buffer, 0);
|
|
12
|
+
const header = Buffer.alloc(4);
|
|
13
|
+
header.writeUInt32LE(fileLength, 0);
|
|
14
|
+
return [header, buffer];
|
|
15
|
+
}
|
|
16
|
+
function bundleToBytecode(bundle) {
|
|
17
|
+
const buffers = [];
|
|
18
|
+
if (bundle.pre.length) {
|
|
19
|
+
buffers.push(...bundle.pre);
|
|
20
|
+
}
|
|
21
|
+
const modules = [];
|
|
22
|
+
const sortedModules = bundle.modules.slice().sort((a, b) => a[0] - b[0]);
|
|
23
|
+
for (const [id, bytecodeBundle] of sortedModules) {
|
|
24
|
+
buffers.push(...bytecodeBundle);
|
|
25
|
+
modules.push([id, bytecodeBundle[bytecodeBundle.length - 1].length]);
|
|
26
|
+
}
|
|
27
|
+
if (bundle.post.length) {
|
|
28
|
+
buffers.push(...bundle.post);
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
bytecode: Buffer.concat([getFileHeader(buffers.length), ...buffers.flatMap(addModuleHeader)]),
|
|
32
|
+
metadata: {
|
|
33
|
+
pre: bundle.pre ? bundle.pre.length : 0,
|
|
34
|
+
post: bundle.post.length,
|
|
35
|
+
modules
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
module.exports = bundleToBytecode;
|
|
40
|
+
module.exports.MAGIC_NUMBER = MAGIC_NUMBER;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
function bundleToString(bundle) {
|
|
3
|
+
let code = bundle.pre.length > 0 ? bundle.pre + "\n" : "";
|
|
4
|
+
const modules = [];
|
|
5
|
+
const sortedModules = bundle.modules.slice().sort((a, b) => a[0] - b[0]);
|
|
6
|
+
for (const [id, moduleCode] of sortedModules) {
|
|
7
|
+
if (moduleCode.length > 0) {
|
|
8
|
+
code += moduleCode + "\n";
|
|
9
|
+
}
|
|
10
|
+
modules.push([id, moduleCode.length]);
|
|
11
|
+
}
|
|
12
|
+
if (bundle.post.length > 0) {
|
|
13
|
+
code += bundle.post;
|
|
14
|
+
} else {
|
|
15
|
+
code = code.slice(0, -1);
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
code,
|
|
19
|
+
metadata: { pre: bundle.pre.length, post: bundle.post.length, modules }
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
module.exports = bundleToString;
|