@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,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
function canonicalize(key, value) {
|
|
3
|
+
if (
|
|
4
|
+
// eslint-disable-next-line lint/strictly-null
|
|
5
|
+
value === null || typeof value !== "object" || Array.isArray(value)
|
|
6
|
+
) {
|
|
7
|
+
return value;
|
|
8
|
+
}
|
|
9
|
+
const keys = Object.keys(value).sort();
|
|
10
|
+
const length = keys.length;
|
|
11
|
+
const object = {};
|
|
12
|
+
for (let i = 0; i < length; i++) {
|
|
13
|
+
object[keys[i]] = value[keys[i]];
|
|
14
|
+
}
|
|
15
|
+
return object;
|
|
16
|
+
}
|
|
17
|
+
module.exports = canonicalize;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
class AmbiguousModuleResolutionError extends Error {
|
|
3
|
+
fromModulePath;
|
|
4
|
+
hasteError;
|
|
5
|
+
constructor(fromModulePath, hasteError) {
|
|
6
|
+
super(`Ambiguous module resolution from \`${fromModulePath}\`: ` + hasteError.message);
|
|
7
|
+
this.fromModulePath = fromModulePath;
|
|
8
|
+
this.hasteError = hasteError;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
module.exports = AmbiguousModuleResolutionError;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const { formatFileCandidates } = require("metro-resolver");
|
|
3
|
+
class PackageResolutionError extends Error {
|
|
4
|
+
originModulePath;
|
|
5
|
+
packageError;
|
|
6
|
+
targetModuleName;
|
|
7
|
+
constructor(opts) {
|
|
8
|
+
const perr = opts.packageError;
|
|
9
|
+
super(
|
|
10
|
+
`While trying to resolve module \`${opts.targetModuleName}\` from file \`${opts.originModulePath}\`, the package \`${perr.packageJsonPath}\` was successfully found. However, this package itself specifies a \`main\` module field that could not be resolved (\`${perr.mainPrefixPath}\`. Indeed, none of these files exist:
|
|
11
|
+
|
|
12
|
+
* ${formatFileCandidates(perr.fileCandidates)}
|
|
13
|
+
* ${formatFileCandidates(perr.indexCandidates)}`
|
|
14
|
+
);
|
|
15
|
+
Object.assign(this, opts);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
module.exports = PackageResolutionError;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const AmbiguousModuleResolutionError = require("./errors/AmbiguousModuleResolutionError");
|
|
3
|
+
const PackageResolutionError = require("./errors/PackageResolutionError");
|
|
4
|
+
module.exports = {
|
|
5
|
+
AmbiguousModuleResolutionError,
|
|
6
|
+
PackageResolutionError
|
|
7
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const AmbiguousModuleResolutionError = require("./errors/AmbiguousModuleResolutionError");
|
|
3
|
+
const PackageResolutionError = require("./errors/PackageResolutionError");
|
|
4
|
+
const Logger = require("./Logger");
|
|
5
|
+
const Terminal = require("./Terminal");
|
|
6
|
+
module.exports = {
|
|
7
|
+
AmbiguousModuleResolutionError,
|
|
8
|
+
Logger,
|
|
9
|
+
PackageResolutionError,
|
|
10
|
+
Terminal
|
|
11
|
+
};
|
|
@@ -0,0 +1,398 @@
|
|
|
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 fs = __toESM(require("fs"));
|
|
25
|
+
var path = __toESM(require("path"));
|
|
26
|
+
var import_ws = __toESM(require("ws"));
|
|
27
|
+
const debug = require("debug")("Metro:InspectorProxy");
|
|
28
|
+
const PAGES_POLLING_INTERVAL = 1e3;
|
|
29
|
+
const EMULATOR_LOCALHOST_ADDRESSES = ["10.0.2.2", "10.0.3.2"];
|
|
30
|
+
const FILE_PREFIX = "file://";
|
|
31
|
+
const REACT_NATIVE_RELOADABLE_PAGE_ID = "-1";
|
|
32
|
+
class Device {
|
|
33
|
+
// ID of the device.
|
|
34
|
+
_id;
|
|
35
|
+
// Name of the device.
|
|
36
|
+
_name;
|
|
37
|
+
// Package name of the app.
|
|
38
|
+
_app;
|
|
39
|
+
// Stores socket connection between Inspector Proxy and device.
|
|
40
|
+
_deviceSocket;
|
|
41
|
+
// Stores last list of device's pages.
|
|
42
|
+
_pages;
|
|
43
|
+
// Stores information about currently connected debugger (if any).
|
|
44
|
+
_debuggerConnection = null;
|
|
45
|
+
// Last known Page ID of the React Native page.
|
|
46
|
+
// This is used by debugger connections that don't have PageID specified
|
|
47
|
+
// (and will interact with the latest React Native page).
|
|
48
|
+
_lastConnectedReactNativePage = null;
|
|
49
|
+
// Whether we are in the middle of a reload in the REACT_NATIVE_RELOADABLE_PAGE.
|
|
50
|
+
_isReloading = false;
|
|
51
|
+
// The previous "GetPages" message, for deduplication in debug logs.
|
|
52
|
+
_lastGetPagesMessage = "";
|
|
53
|
+
// Mapping built from scriptParsed events and used to fetch file content in `Debugger.getScriptSource`.
|
|
54
|
+
_scriptIdToSourcePathMapping = /* @__PURE__ */ new Map();
|
|
55
|
+
// Root of the project used for relative to absolute source path conversion.
|
|
56
|
+
_projectRoot;
|
|
57
|
+
// MARK: - GRANITE
|
|
58
|
+
// 네트워크 응답 데이터 저장하기 위한 변수 (key: requestId, value: { data: string, base64Encoded: bool })
|
|
59
|
+
_networkResponseData = /* @__PURE__ */ new Map();
|
|
60
|
+
constructor(id, name, app, socket, projectRoot) {
|
|
61
|
+
this._id = id;
|
|
62
|
+
this._name = name;
|
|
63
|
+
this._app = app;
|
|
64
|
+
this._pages = [];
|
|
65
|
+
this._deviceSocket = socket;
|
|
66
|
+
this._projectRoot = projectRoot;
|
|
67
|
+
this._deviceSocket.on("message", (message) => {
|
|
68
|
+
const parsedMessage = JSON.parse(message);
|
|
69
|
+
if (parsedMessage.event === "getPages") {
|
|
70
|
+
if (message !== this._lastGetPagesMessage) {
|
|
71
|
+
debug("(Debugger) (Proxy) <- (Device), getPages ping has changed: " + message);
|
|
72
|
+
this._lastGetPagesMessage = message;
|
|
73
|
+
}
|
|
74
|
+
} else {
|
|
75
|
+
debug("(Debugger) (Proxy) <- (Device): " + message);
|
|
76
|
+
}
|
|
77
|
+
this._handleMessageFromDevice(parsedMessage);
|
|
78
|
+
});
|
|
79
|
+
this._deviceSocket.on("close", () => {
|
|
80
|
+
if (this._debuggerConnection) {
|
|
81
|
+
this._debuggerConnection.socket.close();
|
|
82
|
+
this._debuggerConnection = null;
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
this._setPagesPolling();
|
|
86
|
+
}
|
|
87
|
+
getName() {
|
|
88
|
+
return this._name;
|
|
89
|
+
}
|
|
90
|
+
getPagesList() {
|
|
91
|
+
if (this._lastConnectedReactNativePage) {
|
|
92
|
+
const reactNativeReloadablePage = {
|
|
93
|
+
id: REACT_NATIVE_RELOADABLE_PAGE_ID,
|
|
94
|
+
title: "React Native Experimental (Improved Chrome Reloads)",
|
|
95
|
+
vm: "don't use",
|
|
96
|
+
app: this._app
|
|
97
|
+
};
|
|
98
|
+
return this._pages.concat(reactNativeReloadablePage);
|
|
99
|
+
} else {
|
|
100
|
+
return this._pages;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
// Handles new debugger connection to this device:
|
|
104
|
+
// 1. Sends connect event to device
|
|
105
|
+
// 2. Forwards all messages from the debugger to device as wrappedEvent
|
|
106
|
+
// 3. Sends disconnect event to device when debugger connection socket closes.
|
|
107
|
+
handleDebuggerConnection(socket, pageId) {
|
|
108
|
+
if (this._debuggerConnection) {
|
|
109
|
+
this._debuggerConnection.socket.close();
|
|
110
|
+
this._debuggerConnection = null;
|
|
111
|
+
}
|
|
112
|
+
const debuggerInfo = {
|
|
113
|
+
socket,
|
|
114
|
+
prependedFilePrefix: false,
|
|
115
|
+
pageId
|
|
116
|
+
};
|
|
117
|
+
this._debuggerConnection = debuggerInfo;
|
|
118
|
+
debug(`Got new debugger connection for page ${pageId} of ${this._name}`);
|
|
119
|
+
this._sendMessageToDevice({
|
|
120
|
+
event: "connect",
|
|
121
|
+
payload: {
|
|
122
|
+
pageId: this._mapToDevicePageId(pageId)
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
socket.on("message", (message) => {
|
|
126
|
+
if (!this._lastConnectedReactNativePage) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
debug("(Debugger) -> (Proxy) (Device): " + message);
|
|
130
|
+
const debuggerRequest = JSON.parse(message);
|
|
131
|
+
const interceptedResponse = this._interceptMessageFromDebugger(debuggerRequest, debuggerInfo);
|
|
132
|
+
if (interceptedResponse) {
|
|
133
|
+
socket.send(JSON.stringify(interceptedResponse));
|
|
134
|
+
} else {
|
|
135
|
+
this._sendMessageToDevice({
|
|
136
|
+
event: "wrappedEvent",
|
|
137
|
+
payload: {
|
|
138
|
+
pageId: this._mapToDevicePageId(pageId),
|
|
139
|
+
wrappedEvent: JSON.stringify(debuggerRequest)
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
socket.on("close", () => {
|
|
145
|
+
debug(`Debugger for page ${pageId} and ${this._name} disconnected.`);
|
|
146
|
+
this._sendMessageToDevice({
|
|
147
|
+
event: "disconnect",
|
|
148
|
+
payload: {
|
|
149
|
+
pageId: this._mapToDevicePageId(pageId)
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
this._debuggerConnection = null;
|
|
153
|
+
});
|
|
154
|
+
const sendFunc = socket.send;
|
|
155
|
+
socket.send = function(message) {
|
|
156
|
+
debug("(Debugger) <- (Proxy) (Device): " + message);
|
|
157
|
+
return sendFunc.call(socket, message);
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
// Handles messages received from device:
|
|
161
|
+
// 1. For getPages responses updates local _pages list.
|
|
162
|
+
// 2. All other messages are forwarded to debugger as wrappedEvent.
|
|
163
|
+
//
|
|
164
|
+
// In the future more logic will be added to this method for modifying
|
|
165
|
+
// some of the messages (like updating messages with source maps and file
|
|
166
|
+
// locations).
|
|
167
|
+
_handleMessageFromDevice(message) {
|
|
168
|
+
if (message.event === "getPages") {
|
|
169
|
+
this._pages = message.payload;
|
|
170
|
+
for (let i = 0; i < this._pages.length; ++i) {
|
|
171
|
+
if (this._pages[i].title.indexOf("React") >= 0) {
|
|
172
|
+
if (this._pages[i].id != this._lastConnectedReactNativePage?.id) {
|
|
173
|
+
this._newReactNativePage(this._pages[i]);
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
} else if (message.event === "disconnect") {
|
|
179
|
+
const pageId = message.payload.pageId;
|
|
180
|
+
const debuggerSocket = this._debuggerConnection ? this._debuggerConnection.socket : null;
|
|
181
|
+
if (debuggerSocket && debuggerSocket.readyState === import_ws.default.OPEN) {
|
|
182
|
+
if (this._debuggerConnection != null && this._debuggerConnection.pageId !== REACT_NATIVE_RELOADABLE_PAGE_ID) {
|
|
183
|
+
debug(`Page ${pageId} is reloading.`);
|
|
184
|
+
debuggerSocket.send(JSON.stringify({ method: "reload" }));
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
} else if (message.event === "wrappedEvent") {
|
|
188
|
+
if (this._debuggerConnection == null) {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
const debuggerSocket = this._debuggerConnection.socket;
|
|
192
|
+
if (debuggerSocket == null || debuggerSocket.readyState !== import_ws.default.OPEN) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
const parsedPayload = JSON.parse(message.payload.wrappedEvent);
|
|
196
|
+
if (this._debuggerConnection) {
|
|
197
|
+
this._processMessageFromDevice(parsedPayload, this._debuggerConnection);
|
|
198
|
+
}
|
|
199
|
+
const messageToSend = JSON.stringify(parsedPayload);
|
|
200
|
+
debuggerSocket.send(messageToSend);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
// Sends single message to device.
|
|
204
|
+
_sendMessageToDevice(message) {
|
|
205
|
+
try {
|
|
206
|
+
if (message.event !== "getPages") {
|
|
207
|
+
debug("(Debugger) (Proxy) -> (Device): " + JSON.stringify(message));
|
|
208
|
+
}
|
|
209
|
+
this._deviceSocket.send(JSON.stringify(message));
|
|
210
|
+
} catch (error) {
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
// Sends 'getPages' request to device every PAGES_POLLING_INTERVAL milliseconds.
|
|
214
|
+
_setPagesPolling() {
|
|
215
|
+
setInterval(() => this._sendMessageToDevice({ event: "getPages" }), PAGES_POLLING_INTERVAL);
|
|
216
|
+
}
|
|
217
|
+
// We received new React Native Page ID.
|
|
218
|
+
_newReactNativePage(page) {
|
|
219
|
+
debug(`React Native page updated to ${page.id}`);
|
|
220
|
+
if (this._debuggerConnection == null || this._debuggerConnection.pageId !== REACT_NATIVE_RELOADABLE_PAGE_ID) {
|
|
221
|
+
this._lastConnectedReactNativePage = page;
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
const oldPageId = this._lastConnectedReactNativePage?.id;
|
|
225
|
+
this._lastConnectedReactNativePage = page;
|
|
226
|
+
this._isReloading = true;
|
|
227
|
+
if (oldPageId != null) {
|
|
228
|
+
this._sendMessageToDevice({
|
|
229
|
+
event: "disconnect",
|
|
230
|
+
payload: {
|
|
231
|
+
pageId: oldPageId
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
this._sendMessageToDevice({
|
|
236
|
+
event: "connect",
|
|
237
|
+
payload: {
|
|
238
|
+
pageId: page.id
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
const toSend = [
|
|
242
|
+
{ method: "Runtime.enable", id: 1e9 },
|
|
243
|
+
{ method: "Debugger.enable", id: 1e9 }
|
|
244
|
+
];
|
|
245
|
+
for (const message of toSend) {
|
|
246
|
+
this._sendMessageToDevice({
|
|
247
|
+
event: "wrappedEvent",
|
|
248
|
+
payload: {
|
|
249
|
+
pageId: this._mapToDevicePageId(page.id),
|
|
250
|
+
wrappedEvent: JSON.stringify(message)
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
// Allows to make changes in incoming message from device.
|
|
256
|
+
_processMessageFromDevice(payload, debuggerInfo) {
|
|
257
|
+
if (payload.method === "Debugger.scriptParsed") {
|
|
258
|
+
const params = payload.params || {};
|
|
259
|
+
if ("sourceMapURL" in params) {
|
|
260
|
+
for (let i = 0; i < EMULATOR_LOCALHOST_ADDRESSES.length; ++i) {
|
|
261
|
+
const address = EMULATOR_LOCALHOST_ADDRESSES[i];
|
|
262
|
+
if (params.sourceMapURL.indexOf(address) >= 0) {
|
|
263
|
+
payload.params.sourceMapURL = params.sourceMapURL.replace(address, "localhost");
|
|
264
|
+
debuggerInfo.originalSourceURLAddress = address;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
if ("url" in params) {
|
|
269
|
+
for (let i = 0; i < EMULATOR_LOCALHOST_ADDRESSES.length; ++i) {
|
|
270
|
+
const address = EMULATOR_LOCALHOST_ADDRESSES[i];
|
|
271
|
+
if (params.url.indexOf(address) >= 0) {
|
|
272
|
+
payload.params.url = params.url.replace(address, "localhost");
|
|
273
|
+
debuggerInfo.originalSourceURLAddress = address;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
if (payload.params.url.match(/^[0-9a-z]+$/)) {
|
|
277
|
+
payload.params.url = FILE_PREFIX + payload.params.url;
|
|
278
|
+
debuggerInfo.prependedFilePrefix = true;
|
|
279
|
+
}
|
|
280
|
+
if (params.scriptId != null) {
|
|
281
|
+
this._scriptIdToSourcePathMapping.set(params.scriptId, params.url);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
if (debuggerInfo.pageId == REACT_NATIVE_RELOADABLE_PAGE_ID) {
|
|
285
|
+
if (payload.params.sourceMapURL) {
|
|
286
|
+
payload.params.sourceMapURL += "&cachePrevention=" + this._mapToDevicePageId(debuggerInfo.pageId);
|
|
287
|
+
}
|
|
288
|
+
if (payload.params.url) {
|
|
289
|
+
payload.params.url += "&cachePrevention=" + this._mapToDevicePageId(debuggerInfo.pageId);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
if (payload.method === "Runtime.executionContextCreated" && this._isReloading) {
|
|
294
|
+
debuggerInfo.socket.send(JSON.stringify({ method: "Runtime.executionContextsCleared" }));
|
|
295
|
+
this._sendMessageToDevice({
|
|
296
|
+
event: "wrappedEvent",
|
|
297
|
+
payload: {
|
|
298
|
+
pageId: this._mapToDevicePageId(debuggerInfo.pageId),
|
|
299
|
+
wrappedEvent: JSON.stringify({ method: "Debugger.resume", id: 0 })
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
this._isReloading = false;
|
|
303
|
+
}
|
|
304
|
+
if (payload.method === "Bedrock.networkResponseData" || payload.method === "Granite.networkResponseData") {
|
|
305
|
+
const params = payload.params ?? {};
|
|
306
|
+
if (typeof params.requestId === "string") {
|
|
307
|
+
this._networkResponseData.set(params.requestId, {
|
|
308
|
+
data: params.data,
|
|
309
|
+
base64Encoded: params.base64Encoded
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
// Allows to make changes in incoming messages from debugger.
|
|
315
|
+
_interceptMessageFromDebugger(req, debuggerInfo) {
|
|
316
|
+
let response = null;
|
|
317
|
+
if (req.method === "Debugger.setBreakpointByUrl") {
|
|
318
|
+
this._processDebuggerSetBreakpointByUrl(req, debuggerInfo);
|
|
319
|
+
} else if (req.method === "Debugger.getScriptSource") {
|
|
320
|
+
response = {
|
|
321
|
+
id: req.id,
|
|
322
|
+
result: this._processDebuggerGetScriptSource(req)
|
|
323
|
+
};
|
|
324
|
+
} else if (req.method === "Network.getResponseBody") {
|
|
325
|
+
return this._processDebuggerGetResponseBody(req, debuggerInfo.socket);
|
|
326
|
+
}
|
|
327
|
+
return response;
|
|
328
|
+
}
|
|
329
|
+
// MARK: - GRANITE
|
|
330
|
+
_processDebuggerGetResponseBody(req, socket) {
|
|
331
|
+
const { requestId } = req.params;
|
|
332
|
+
if (this._networkResponseData.has(requestId)) {
|
|
333
|
+
const responseData = this._networkResponseData.get(requestId);
|
|
334
|
+
this._networkResponseData.delete(requestId);
|
|
335
|
+
socket.send(
|
|
336
|
+
JSON.stringify({
|
|
337
|
+
id: req.id,
|
|
338
|
+
result: this._createNetworkResponseData(responseData)
|
|
339
|
+
})
|
|
340
|
+
);
|
|
341
|
+
return true;
|
|
342
|
+
}
|
|
343
|
+
return false;
|
|
344
|
+
}
|
|
345
|
+
// MARK: - GRANITE
|
|
346
|
+
_createNetworkResponseData(responseData) {
|
|
347
|
+
let parsedOriginalData;
|
|
348
|
+
try {
|
|
349
|
+
parsedOriginalData = JSON.parse(responseData.base64Encoded ? atob(responseData.data) : responseData.data);
|
|
350
|
+
} catch {
|
|
351
|
+
return {
|
|
352
|
+
body: responseData.data,
|
|
353
|
+
base64Encoded: responseData.base64Encoded
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
const body = typeof parsedOriginalData === "object" ? JSON.stringify(parsedOriginalData) : responseData.data;
|
|
357
|
+
return { body, base64Encoded: false };
|
|
358
|
+
}
|
|
359
|
+
_processDebuggerSetBreakpointByUrl(req, debuggerInfo) {
|
|
360
|
+
if (debuggerInfo.originalSourceURLAddress) {
|
|
361
|
+
if (req.params.url) {
|
|
362
|
+
req.params.url = req.params.url.replace("localhost", debuggerInfo.originalSourceURLAddress);
|
|
363
|
+
if (req.params.url && req.params.url.startsWith(FILE_PREFIX) && debuggerInfo.prependedFilePrefix) {
|
|
364
|
+
req.params.url = req.params.url.slice(FILE_PREFIX.length);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
if (req.params.urlRegex) {
|
|
368
|
+
req.params.urlRegex = req.params.urlRegex.replace(
|
|
369
|
+
/localhost/g,
|
|
370
|
+
// $FlowFixMe[incompatible-call]
|
|
371
|
+
debuggerInfo.originalSourceURLAddress
|
|
372
|
+
);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
_processDebuggerGetScriptSource(req) {
|
|
377
|
+
let scriptSource = `Source for script with id '${req.params.scriptId}' was not found.`;
|
|
378
|
+
const pathToSource = this._scriptIdToSourcePathMapping.get(req.params.scriptId);
|
|
379
|
+
if (pathToSource) {
|
|
380
|
+
try {
|
|
381
|
+
scriptSource = fs.readFileSync(path.resolve(this._projectRoot, pathToSource), "utf8");
|
|
382
|
+
} catch (err) {
|
|
383
|
+
scriptSource = err.message;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
return {
|
|
387
|
+
scriptSource
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
_mapToDevicePageId(pageId) {
|
|
391
|
+
if (pageId === REACT_NATIVE_RELOADABLE_PAGE_ID && this._lastConnectedReactNativePage != null) {
|
|
392
|
+
return this._lastConnectedReactNativePage.id;
|
|
393
|
+
} else {
|
|
394
|
+
return pageId;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
module.exports = Device;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as http from 'http';
|
|
2
|
+
import * as ws from 'ws';
|
|
3
|
+
|
|
4
|
+
declare class Device {
|
|
5
|
+
getName(): string;
|
|
6
|
+
getPageList(): unknown[];
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
declare class InspectorProxy {
|
|
10
|
+
static devices: Map<number, Device>;
|
|
11
|
+
|
|
12
|
+
processRequest: (request: http.IncomingMessage, response: http.ServerResponse, next: (error?: Error) => void) => void;
|
|
13
|
+
createWebSocketListeners: (server: http.Server) => {
|
|
14
|
+
['/inspector/device']: ws.WebSocketServer;
|
|
15
|
+
['/inspector/debug']: ws.WebSocketServer;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
constructor(projectRoot: string);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default InspectorProxy;
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const Device = require("./Device");
|
|
3
|
+
const debug = require("debug")("Metro:InspectorProxy");
|
|
4
|
+
const url = require("url");
|
|
5
|
+
const WS = require("ws");
|
|
6
|
+
const WS_DEVICE_URL = "/inspector/device";
|
|
7
|
+
const WS_DEBUGGER_URL = "/inspector/debug";
|
|
8
|
+
const PAGES_LIST_JSON_URL = "/json";
|
|
9
|
+
const PAGES_LIST_JSON_URL_2 = "/json/list";
|
|
10
|
+
const PAGES_LIST_JSON_VERSION_URL = "/json/version";
|
|
11
|
+
const INTERNAL_ERROR_CODE = 1011;
|
|
12
|
+
class InspectorProxy {
|
|
13
|
+
// MARK: - GRANITE
|
|
14
|
+
static devices;
|
|
15
|
+
// Root of the project used for relative to absolute source path conversion.
|
|
16
|
+
_projectRoot;
|
|
17
|
+
// MARK: - GRANITE
|
|
18
|
+
// 내부 변수를 static 필드로 변경하여 외부에서 접근하도록 변경함 (미사용)
|
|
19
|
+
// Maps device ID to Device instance.
|
|
20
|
+
_devices;
|
|
21
|
+
// Internal counter for device IDs -- just gets incremented for each new device.
|
|
22
|
+
_deviceCounter = 0;
|
|
23
|
+
// We store server's address with port (like '127.0.0.1:8081') to be able to build URLs
|
|
24
|
+
// (devtoolsFrontendUrl and webSocketDebuggerUrl) for page descriptions. These URLs are used
|
|
25
|
+
// by debugger to know where to connect.
|
|
26
|
+
_serverAddressWithPort = "";
|
|
27
|
+
constructor(projectRoot) {
|
|
28
|
+
this._projectRoot = projectRoot;
|
|
29
|
+
InspectorProxy.devices = /* @__PURE__ */ new Map();
|
|
30
|
+
}
|
|
31
|
+
// Process HTTP request sent to server. We only respond to 2 HTTP requests:
|
|
32
|
+
// 1. /json/version returns Chrome debugger protocol version that we use
|
|
33
|
+
// 2. /json and /json/list returns list of page descriptions (list of inspectable apps).
|
|
34
|
+
// This list is combined from all the connected devices.
|
|
35
|
+
processRequest(request, response, next) {
|
|
36
|
+
if (request.url === PAGES_LIST_JSON_URL || request.url === PAGES_LIST_JSON_URL_2) {
|
|
37
|
+
let result = [];
|
|
38
|
+
Array.from(InspectorProxy.devices.entries()).forEach(([deviceId, device]) => {
|
|
39
|
+
result = result.concat(device.getPagesList().map((page) => this._buildPageDescription(deviceId, device, page)));
|
|
40
|
+
});
|
|
41
|
+
this._sendJsonResponse(response, result);
|
|
42
|
+
} else if (request.url === PAGES_LIST_JSON_VERSION_URL) {
|
|
43
|
+
this._sendJsonResponse(response, {
|
|
44
|
+
Browser: "Mobile JavaScript",
|
|
45
|
+
"Protocol-Version": "1.1"
|
|
46
|
+
});
|
|
47
|
+
} else {
|
|
48
|
+
next();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
// Adds websocket listeners to the provided HTTP/HTTPS server.
|
|
52
|
+
createWebSocketListeners(server) {
|
|
53
|
+
const { port } = server.address();
|
|
54
|
+
if (server.address().family === "IPv6") {
|
|
55
|
+
this._serverAddressWithPort = `[::1]:${port}`;
|
|
56
|
+
} else {
|
|
57
|
+
this._serverAddressWithPort = `localhost:${port}`;
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
[WS_DEVICE_URL]: this._createDeviceConnectionWSServer(),
|
|
61
|
+
[WS_DEBUGGER_URL]: this._createDebuggerConnectionWSServer()
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
// Converts page information received from device into PageDescription object
|
|
65
|
+
// that is sent to debugger.
|
|
66
|
+
_buildPageDescription(deviceId, device, page) {
|
|
67
|
+
const debuggerUrl = `${this._serverAddressWithPort}${WS_DEBUGGER_URL}?device=${deviceId}&page=${page.id}`;
|
|
68
|
+
const webSocketDebuggerUrl = "ws://" + debuggerUrl;
|
|
69
|
+
const devtoolsFrontendUrl = "devtools://devtools/bundled/js_app.html?experiments=true&v8only=true&ws=" + encodeURIComponent(debuggerUrl);
|
|
70
|
+
return {
|
|
71
|
+
id: `${deviceId}-${page.id}`,
|
|
72
|
+
description: page.app,
|
|
73
|
+
title: page.title,
|
|
74
|
+
faviconUrl: "https://reactjs.org/favicon.ico",
|
|
75
|
+
devtoolsFrontendUrl,
|
|
76
|
+
type: "node",
|
|
77
|
+
webSocketDebuggerUrl,
|
|
78
|
+
vm: page.vm
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
// Sends object as response to HTTP request.
|
|
82
|
+
// Just serializes object using JSON and sets required headers.
|
|
83
|
+
_sendJsonResponse(response, object) {
|
|
84
|
+
const data = JSON.stringify(object, null, 2);
|
|
85
|
+
response.writeHead(200, {
|
|
86
|
+
"Content-Type": "application/json; charset=UTF-8",
|
|
87
|
+
"Cache-Control": "no-cache",
|
|
88
|
+
"Content-Length": data.length.toString(),
|
|
89
|
+
Connection: "close"
|
|
90
|
+
});
|
|
91
|
+
response.end(data);
|
|
92
|
+
}
|
|
93
|
+
// Adds websocket handler for device connections.
|
|
94
|
+
// Device connects to /inspector/device and passes device and app names as
|
|
95
|
+
// HTTP GET params.
|
|
96
|
+
// For each new websocket connection we parse device and app names and create
|
|
97
|
+
// new instance of Device class.
|
|
98
|
+
_createDeviceConnectionWSServer() {
|
|
99
|
+
const wss = new WS.Server({
|
|
100
|
+
noServer: true,
|
|
101
|
+
perMessageDeflate: true
|
|
102
|
+
});
|
|
103
|
+
wss.on("connection", async (socket, req) => {
|
|
104
|
+
try {
|
|
105
|
+
const query = url.parse(req.url || "", true).query || {};
|
|
106
|
+
const deviceName = query.name || "Unknown";
|
|
107
|
+
const appName = query.app || "Unknown";
|
|
108
|
+
const deviceId = this._deviceCounter++;
|
|
109
|
+
InspectorProxy.devices.set(deviceId, new Device(deviceId, deviceName, appName, socket, this._projectRoot));
|
|
110
|
+
debug(`Got new connection: device=${deviceName}, app=${appName}`);
|
|
111
|
+
socket.on("close", () => {
|
|
112
|
+
InspectorProxy.devices.delete(deviceId);
|
|
113
|
+
debug(`Device ${deviceName} disconnected.`);
|
|
114
|
+
});
|
|
115
|
+
} catch (e) {
|
|
116
|
+
console.error("error", e);
|
|
117
|
+
socket.close(INTERNAL_ERROR_CODE, e?.toString() ?? "Unknown error");
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
return wss;
|
|
121
|
+
}
|
|
122
|
+
// Returns websocket handler for debugger connections.
|
|
123
|
+
// Debugger connects to webSocketDebuggerUrl that we return as part of page description
|
|
124
|
+
// in /json response.
|
|
125
|
+
// When debugger connects we try to parse device and page IDs from the query and pass
|
|
126
|
+
// websocket object to corresponding Device instance.
|
|
127
|
+
_createDebuggerConnectionWSServer() {
|
|
128
|
+
const wss = new WS.Server({
|
|
129
|
+
noServer: true,
|
|
130
|
+
perMessageDeflate: false
|
|
131
|
+
});
|
|
132
|
+
wss.on("connection", async (socket, req) => {
|
|
133
|
+
try {
|
|
134
|
+
const query = url.parse(req.url || "", true).query || {};
|
|
135
|
+
const deviceId = query.device;
|
|
136
|
+
const pageId = query.page;
|
|
137
|
+
if (deviceId == null || pageId == null) {
|
|
138
|
+
throw new Error("Incorrect URL - must provide device and page IDs");
|
|
139
|
+
}
|
|
140
|
+
const device = InspectorProxy.devices.get(parseInt(deviceId, 10));
|
|
141
|
+
if (device == null) {
|
|
142
|
+
throw new Error("Unknown device with ID " + deviceId);
|
|
143
|
+
}
|
|
144
|
+
device.handleDebuggerConnection(socket, pageId);
|
|
145
|
+
} catch (e) {
|
|
146
|
+
console.error(e);
|
|
147
|
+
socket.close(INTERNAL_ERROR_CODE, e?.toString() ?? "Unknown error");
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
return wss;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
module.exports = InspectorProxy;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const { runInspectorProxy } = require("./index");
|
|
3
|
+
const yargs = require("yargs");
|
|
4
|
+
const argv = yargs.option("port", {
|
|
5
|
+
alias: "p",
|
|
6
|
+
describe: "port to run inspector proxy on",
|
|
7
|
+
type: "number",
|
|
8
|
+
default: 8081
|
|
9
|
+
}).option("root", {
|
|
10
|
+
alias: "r",
|
|
11
|
+
describe: "root folder of metro project",
|
|
12
|
+
type: "string",
|
|
13
|
+
default: ""
|
|
14
|
+
}).argv;
|
|
15
|
+
runInspectorProxy(argv.port, argv.root);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const InspectorProxy = require("./InspectorProxy");
|
|
3
|
+
const { parse } = require("url");
|
|
4
|
+
function runInspectorProxy(port, projectRoot) {
|
|
5
|
+
const inspectorProxy = new InspectorProxy(projectRoot);
|
|
6
|
+
const app = require("connect")();
|
|
7
|
+
app.use(inspectorProxy.processRequest.bind(inspectorProxy));
|
|
8
|
+
const httpServer = require("http").createServer(app);
|
|
9
|
+
httpServer.listen(port, "127.0.0.1", () => {
|
|
10
|
+
const websocketEndpoints = inspectorProxy.createWebSocketListeners(httpServer);
|
|
11
|
+
httpServer.on("upgrade", (request, socket, head) => {
|
|
12
|
+
const { pathname } = parse(request.url);
|
|
13
|
+
if (pathname != null && websocketEndpoints[pathname]) {
|
|
14
|
+
websocketEndpoints[pathname].handleUpgrade(request, socket, head, (ws) => {
|
|
15
|
+
websocketEndpoints[pathname].emit("connection", ws, request);
|
|
16
|
+
});
|
|
17
|
+
} else {
|
|
18
|
+
socket.destroy();
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
module.exports = { InspectorProxy, runInspectorProxy };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|