@vxrn/vite-plugin-metro 2.0.0-beta.33.1 → 2.0.0-beta.45.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/dist/cjs/babel-plugins/import-meta-env-plugin.cjs +84 -102
- package/dist/cjs/babel-plugins/import-meta-env-plugin.native.cjs +108 -0
- package/dist/cjs/babel-plugins/import-meta-env-plugin.native.js +90 -107
- package/dist/cjs/babel-plugins/import-meta-env-plugin.native.js.map +1 -1
- package/dist/cjs/env/platformEnv.cjs +55 -57
- package/dist/cjs/env/platformEnv.native.cjs +93 -0
- package/dist/cjs/env/platformEnv.native.js +72 -75
- package/dist/cjs/env/platformEnv.native.js.map +1 -1
- package/dist/cjs/index.cjs +22 -24
- package/dist/cjs/index.native.cjs +41 -0
- package/dist/cjs/index.native.js +22 -23
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/metro-config/getMetroBabelConfigFromViteConfig.cjs +48 -51
- package/dist/cjs/metro-config/getMetroBabelConfigFromViteConfig.native.cjs +101 -0
- package/dist/cjs/metro-config/getMetroBabelConfigFromViteConfig.native.js +88 -94
- package/dist/cjs/metro-config/getMetroBabelConfigFromViteConfig.native.js.map +1 -1
- package/dist/cjs/metro-config/getMetroConfigFromViteConfig.cjs +249 -256
- package/dist/cjs/metro-config/getMetroConfigFromViteConfig.native.cjs +295 -0
- package/dist/cjs/metro-config/getMetroConfigFromViteConfig.native.js +260 -266
- package/dist/cjs/metro-config/getMetroConfigFromViteConfig.native.js.map +1 -1
- package/dist/cjs/metro-config/patchMetroServerWithViteConfigAndMetroPluginOptions.cjs +38 -44
- package/dist/cjs/metro-config/patchMetroServerWithViteConfigAndMetroPluginOptions.native.cjs +53 -0
- package/dist/cjs/metro-config/patchMetroServerWithViteConfigAndMetroPluginOptions.native.js +39 -44
- package/dist/cjs/metro-config/patchMetroServerWithViteConfigAndMetroPluginOptions.native.js.map +1 -1
- package/dist/cjs/metro-config/types.cjs +9 -11
- package/dist/cjs/metro-config/types.native.cjs +18 -0
- package/dist/cjs/metro-config/types.native.js +9 -10
- package/dist/cjs/metro-config/types.native.js.map +1 -1
- package/dist/cjs/plugins/expoManifestRequestHandlerPlugin.cjs +44 -56
- package/dist/cjs/plugins/expoManifestRequestHandlerPlugin.native.cjs +62 -0
- package/dist/cjs/plugins/expoManifestRequestHandlerPlugin.native.js +45 -63
- package/dist/cjs/plugins/expoManifestRequestHandlerPlugin.native.js.map +1 -1
- package/dist/cjs/plugins/metroPlugin.cjs +210 -248
- package/dist/cjs/plugins/metroPlugin.native.cjs +242 -0
- package/dist/cjs/plugins/metroPlugin.native.js +216 -253
- package/dist/cjs/plugins/metroPlugin.native.js.map +1 -1
- package/dist/cjs/rn-commands/bundle/assetCatalogIOS.cjs +56 -65
- package/dist/cjs/rn-commands/bundle/assetCatalogIOS.native.cjs +121 -0
- package/dist/cjs/rn-commands/bundle/assetCatalogIOS.native.js +94 -106
- package/dist/cjs/rn-commands/bundle/assetCatalogIOS.native.js.map +1 -1
- package/dist/cjs/rn-commands/bundle/assetPathUtils.cjs +51 -55
- package/dist/cjs/rn-commands/bundle/assetPathUtils.native.cjs +72 -0
- package/dist/cjs/rn-commands/bundle/assetPathUtils.native.js +51 -54
- package/dist/cjs/rn-commands/bundle/assetPathUtils.native.js.map +1 -1
- package/dist/cjs/rn-commands/bundle/buildBundle.cjs +37 -46
- package/dist/cjs/rn-commands/bundle/buildBundle.native.cjs +57 -0
- package/dist/cjs/rn-commands/bundle/buildBundle.native.js +39 -47
- package/dist/cjs/rn-commands/bundle/buildBundle.native.js.map +1 -1
- package/dist/cjs/rn-commands/bundle/buildBundleWithConfig.cjs +57 -68
- package/dist/cjs/rn-commands/bundle/buildBundleWithConfig.native.cjs +81 -0
- package/dist/cjs/rn-commands/bundle/buildBundleWithConfig.native.js +59 -70
- package/dist/cjs/rn-commands/bundle/buildBundleWithConfig.native.js.map +1 -1
- package/dist/cjs/rn-commands/bundle/filterPlatformAssetScales.cjs +37 -39
- package/dist/cjs/rn-commands/bundle/filterPlatformAssetScales.native.cjs +70 -0
- package/dist/cjs/rn-commands/bundle/filterPlatformAssetScales.native.js +56 -59
- package/dist/cjs/rn-commands/bundle/filterPlatformAssetScales.native.js.map +1 -1
- package/dist/cjs/rn-commands/bundle/getAssetDestPathAndroid.cjs +20 -29
- package/dist/cjs/rn-commands/bundle/getAssetDestPathAndroid.native.cjs +39 -0
- package/dist/cjs/rn-commands/bundle/getAssetDestPathAndroid.native.js +20 -28
- package/dist/cjs/rn-commands/bundle/getAssetDestPathAndroid.native.js.map +1 -1
- package/dist/cjs/rn-commands/bundle/getAssetDestPathIOS.cjs +20 -33
- package/dist/cjs/rn-commands/bundle/getAssetDestPathIOS.native.cjs +38 -0
- package/dist/cjs/rn-commands/bundle/getAssetDestPathIOS.native.js +20 -32
- package/dist/cjs/rn-commands/bundle/getAssetDestPathIOS.native.js.map +1 -1
- package/dist/cjs/rn-commands/bundle/getBuildBundleFn.cjs +23 -32
- package/dist/cjs/rn-commands/bundle/getBuildBundleFn.native.cjs +38 -0
- package/dist/cjs/rn-commands/bundle/getBuildBundleFn.native.js +23 -31
- package/dist/cjs/rn-commands/bundle/getBuildBundleFn.native.js.map +1 -1
- package/dist/cjs/rn-commands/bundle/index.cjs +15 -17
- package/dist/cjs/rn-commands/bundle/index.native.cjs +30 -0
- package/dist/cjs/rn-commands/bundle/index.native.js +15 -16
- package/dist/cjs/rn-commands/bundle/index.native.js.map +1 -1
- package/dist/cjs/rn-commands/bundle/saveAssets.cjs +85 -96
- package/dist/cjs/rn-commands/bundle/saveAssets.native.cjs +129 -0
- package/dist/cjs/rn-commands/bundle/saveAssets.native.js +102 -114
- package/dist/cjs/rn-commands/bundle/saveAssets.native.js.map +1 -1
- package/dist/cjs/rn-commands/bundle/types.cjs +9 -11
- package/dist/cjs/rn-commands/bundle/types.native.cjs +18 -0
- package/dist/cjs/rn-commands/bundle/types.native.js +9 -10
- package/dist/cjs/rn-commands/bundle/types.native.js.map +1 -1
- package/dist/cjs/rn-commands/index.cjs +17 -26
- package/dist/cjs/rn-commands/index.native.cjs +32 -0
- package/dist/cjs/rn-commands/index.native.js +17 -25
- package/dist/cjs/rn-commands/index.native.js.map +1 -1
- package/dist/cjs/transformer/babel-core.cjs +16 -18
- package/dist/cjs/transformer/babel-core.native.cjs +30 -0
- package/dist/cjs/transformer/babel-core.native.js +16 -17
- package/dist/cjs/transformer/babel-core.native.js.map +1 -1
- package/dist/cjs/transformer/babel-transformer.cjs +101 -152
- package/dist/cjs/transformer/babel-transformer.native.cjs +131 -0
- package/dist/cjs/transformer/babel-transformer.native.js +106 -159
- package/dist/cjs/transformer/babel-transformer.native.js.map +1 -1
- package/dist/cjs/transformer/loadBabelConfig.cjs +44 -49
- package/dist/cjs/transformer/loadBabelConfig.native.cjs +64 -0
- package/dist/cjs/transformer/loadBabelConfig.native.js +48 -52
- package/dist/cjs/transformer/loadBabelConfig.native.js.map +1 -1
- package/dist/cjs/transformer/metroNativeWorker.cjs +1442 -1480
- package/dist/cjs/transformer/metroNativeWorker.native.cjs +2536 -0
- package/dist/cjs/transformer/metroNativeWorker.native.js +2416 -2552
- package/dist/cjs/transformer/metroNativeWorker.native.js.map +1 -1
- package/dist/cjs/transformer/transformSync.cjs +47 -63
- package/dist/cjs/transformer/transformSync.native.cjs +74 -0
- package/dist/cjs/transformer/transformSync.native.js +49 -64
- package/dist/cjs/transformer/transformSync.native.js.map +1 -1
- package/dist/cjs/transformer/types.cjs +9 -11
- package/dist/cjs/transformer/types.native.cjs +18 -0
- package/dist/cjs/transformer/types.native.js +9 -10
- package/dist/cjs/transformer/types.native.js.map +1 -1
- package/dist/cjs/utils/exit.cjs +141 -139
- package/dist/cjs/utils/exit.native.cjs +266 -0
- package/dist/cjs/utils/exit.native.js +228 -241
- package/dist/cjs/utils/exit.native.js.map +1 -1
- package/dist/cjs/utils/getTerminalReporter.cjs +35 -47
- package/dist/cjs/utils/getTerminalReporter.native.cjs +57 -0
- package/dist/cjs/utils/getTerminalReporter.native.js +38 -49
- package/dist/cjs/utils/getTerminalReporter.native.js.map +1 -1
- package/dist/cjs/utils/metroCacheManager.cjs +84 -99
- package/dist/cjs/utils/metroCacheManager.native.cjs +130 -0
- package/dist/cjs/utils/metroCacheManager.native.js +102 -118
- package/dist/cjs/utils/metroCacheManager.native.js.map +1 -1
- package/dist/cjs/utils/patchExpoGoManifestHandlerMiddlewareWithCustomMainModuleName.cjs +24 -28
- package/dist/cjs/utils/patchExpoGoManifestHandlerMiddlewareWithCustomMainModuleName.native.cjs +37 -0
- package/dist/cjs/utils/patchExpoGoManifestHandlerMiddlewareWithCustomMainModuleName.native.js +24 -27
- package/dist/cjs/utils/patchExpoGoManifestHandlerMiddlewareWithCustomMainModuleName.native.js.map +1 -1
- package/dist/cjs/utils/projectImport.cjs +40 -51
- package/dist/cjs/utils/projectImport.native.cjs +64 -0
- package/dist/cjs/utils/projectImport.native.js +41 -58
- package/dist/cjs/utils/projectImport.native.js.map +1 -1
- package/dist/esm/babel-plugins/import-meta-env-plugin.mjs +72 -86
- package/dist/esm/babel-plugins/import-meta-env-plugin.mjs.map +1 -1
- package/dist/esm/babel-plugins/import-meta-env-plugin.native.js +78 -92
- package/dist/esm/babel-plugins/import-meta-env-plugin.native.js.map +1 -1
- package/dist/esm/env/platformEnv.mjs +40 -39
- package/dist/esm/env/platformEnv.mjs.map +1 -1
- package/dist/esm/env/platformEnv.native.js +57 -58
- package/dist/esm/env/platformEnv.native.js.map +1 -1
- package/dist/esm/index.js +3 -3
- package/dist/esm/index.mjs +3 -3
- package/dist/esm/index.native.js +3 -3
- package/dist/esm/metro-config/getMetroBabelConfigFromViteConfig.mjs +35 -33
- package/dist/esm/metro-config/getMetroBabelConfigFromViteConfig.mjs.map +1 -1
- package/dist/esm/metro-config/getMetroBabelConfigFromViteConfig.native.js +75 -77
- package/dist/esm/metro-config/getMetroBabelConfigFromViteConfig.native.js.map +1 -1
- package/dist/esm/metro-config/getMetroConfigFromViteConfig.mjs +233 -231
- package/dist/esm/metro-config/getMetroConfigFromViteConfig.mjs.map +1 -1
- package/dist/esm/metro-config/getMetroConfigFromViteConfig.native.js +244 -242
- package/dist/esm/metro-config/getMetroConfigFromViteConfig.native.js.map +1 -1
- package/dist/esm/metro-config/patchMetroServerWithViteConfigAndMetroPluginOptions.mjs +26 -26
- package/dist/esm/metro-config/patchMetroServerWithViteConfigAndMetroPluginOptions.mjs.map +1 -1
- package/dist/esm/metro-config/patchMetroServerWithViteConfigAndMetroPluginOptions.native.js +27 -27
- package/dist/esm/metro-config/patchMetroServerWithViteConfigAndMetroPluginOptions.native.js.map +1 -1
- package/dist/esm/metro-config/types.mjs +0 -2
- package/dist/esm/metro-config/types.native.js +0 -2
- package/dist/esm/plugins/expoManifestRequestHandlerPlugin.mjs +32 -38
- package/dist/esm/plugins/expoManifestRequestHandlerPlugin.mjs.map +1 -1
- package/dist/esm/plugins/expoManifestRequestHandlerPlugin.native.js +33 -46
- package/dist/esm/plugins/expoManifestRequestHandlerPlugin.native.js.map +1 -1
- package/dist/esm/plugins/metroPlugin.mjs +195 -222
- package/dist/esm/plugins/metroPlugin.mjs.map +1 -1
- package/dist/esm/plugins/metroPlugin.native.js +201 -228
- package/dist/esm/plugins/metroPlugin.native.js.map +1 -1
- package/dist/esm/rn-commands/bundle/assetCatalogIOS.mjs +38 -38
- package/dist/esm/rn-commands/bundle/assetCatalogIOS.mjs.map +1 -1
- package/dist/esm/rn-commands/bundle/assetCatalogIOS.native.js +76 -80
- package/dist/esm/rn-commands/bundle/assetCatalogIOS.native.js.map +1 -1
- package/dist/esm/rn-commands/bundle/assetPathUtils.mjs +38 -37
- package/dist/esm/rn-commands/bundle/assetPathUtils.mjs.map +1 -1
- package/dist/esm/rn-commands/bundle/assetPathUtils.native.js +38 -37
- package/dist/esm/rn-commands/bundle/assetPathUtils.native.js.map +1 -1
- package/dist/esm/rn-commands/bundle/buildBundle.mjs +25 -28
- package/dist/esm/rn-commands/bundle/buildBundle.mjs.map +1 -1
- package/dist/esm/rn-commands/bundle/buildBundle.native.js +27 -30
- package/dist/esm/rn-commands/bundle/buildBundle.native.js.map +1 -1
- package/dist/esm/rn-commands/bundle/buildBundleWithConfig.mjs +43 -43
- package/dist/esm/rn-commands/bundle/buildBundleWithConfig.mjs.map +1 -1
- package/dist/esm/rn-commands/bundle/buildBundleWithConfig.native.js +45 -46
- package/dist/esm/rn-commands/bundle/buildBundleWithConfig.native.js.map +1 -1
- package/dist/esm/rn-commands/bundle/filterPlatformAssetScales.mjs +24 -21
- package/dist/esm/rn-commands/bundle/filterPlatformAssetScales.mjs.map +1 -1
- package/dist/esm/rn-commands/bundle/filterPlatformAssetScales.native.js +43 -42
- package/dist/esm/rn-commands/bundle/filterPlatformAssetScales.native.js.map +1 -1
- package/dist/esm/rn-commands/bundle/getAssetDestPathAndroid.mjs +5 -3
- package/dist/esm/rn-commands/bundle/getAssetDestPathAndroid.mjs.map +1 -1
- package/dist/esm/rn-commands/bundle/getAssetDestPathAndroid.native.js +5 -3
- package/dist/esm/rn-commands/bundle/getAssetDestPathAndroid.native.js.map +1 -1
- package/dist/esm/rn-commands/bundle/getAssetDestPathIOS.mjs +5 -7
- package/dist/esm/rn-commands/bundle/getAssetDestPathIOS.mjs.map +1 -1
- package/dist/esm/rn-commands/bundle/getAssetDestPathIOS.native.js +5 -7
- package/dist/esm/rn-commands/bundle/getAssetDestPathIOS.native.js.map +1 -1
- package/dist/esm/rn-commands/bundle/getBuildBundleFn.mjs +11 -14
- package/dist/esm/rn-commands/bundle/getBuildBundleFn.mjs.map +1 -1
- package/dist/esm/rn-commands/bundle/getBuildBundleFn.native.js +11 -14
- package/dist/esm/rn-commands/bundle/getBuildBundleFn.native.js.map +1 -1
- package/dist/esm/rn-commands/bundle/index.mjs +2 -2
- package/dist/esm/rn-commands/bundle/index.native.js +2 -2
- package/dist/esm/rn-commands/bundle/saveAssets.mjs +70 -70
- package/dist/esm/rn-commands/bundle/saveAssets.mjs.map +1 -1
- package/dist/esm/rn-commands/bundle/saveAssets.native.js +87 -89
- package/dist/esm/rn-commands/bundle/saveAssets.native.js.map +1 -1
- package/dist/esm/rn-commands/bundle/types.mjs +0 -2
- package/dist/esm/rn-commands/bundle/types.native.js +0 -2
- package/dist/esm/rn-commands/index.mjs +2 -2
- package/dist/esm/rn-commands/index.native.js +2 -2
- package/dist/esm/transformer/babel-core.mjs +2 -2
- package/dist/esm/transformer/babel-core.native.js +2 -2
- package/dist/esm/transformer/babel-transformer.mjs +108 -144
- package/dist/esm/transformer/babel-transformer.mjs.map +1 -1
- package/dist/esm/transformer/babel-transformer.native.js +114 -155
- package/dist/esm/transformer/babel-transformer.native.js.map +1 -1
- package/dist/esm/transformer/loadBabelConfig.mjs +29 -23
- package/dist/esm/transformer/loadBabelConfig.mjs.map +1 -1
- package/dist/esm/transformer/loadBabelConfig.native.js +33 -27
- package/dist/esm/transformer/loadBabelConfig.native.js.map +1 -1
- package/dist/esm/transformer/metroNativeWorker.mjs +1405 -1434
- package/dist/esm/transformer/metroNativeWorker.mjs.map +1 -1
- package/dist/esm/transformer/metroNativeWorker.native.js +2379 -2507
- package/dist/esm/transformer/metroNativeWorker.native.js.map +1 -1
- package/dist/esm/transformer/transformSync.mjs +32 -37
- package/dist/esm/transformer/transformSync.mjs.map +1 -1
- package/dist/esm/transformer/transformSync.native.js +34 -39
- package/dist/esm/transformer/transformSync.native.js.map +1 -1
- package/dist/esm/transformer/types.mjs +0 -2
- package/dist/esm/transformer/types.native.js +0 -2
- package/dist/esm/utils/exit.mjs +123 -112
- package/dist/esm/utils/exit.mjs.map +1 -1
- package/dist/esm/utils/exit.native.js +210 -215
- package/dist/esm/utils/exit.native.js.map +1 -1
- package/dist/esm/utils/getTerminalReporter.mjs +20 -21
- package/dist/esm/utils/getTerminalReporter.mjs.map +1 -1
- package/dist/esm/utils/getTerminalReporter.native.js +23 -24
- package/dist/esm/utils/getTerminalReporter.native.js.map +1 -1
- package/dist/esm/utils/metroCacheManager.mjs +73 -82
- package/dist/esm/utils/metroCacheManager.mjs.map +1 -1
- package/dist/esm/utils/metroCacheManager.native.js +91 -102
- package/dist/esm/utils/metroCacheManager.native.js.map +1 -1
- package/dist/esm/utils/patchExpoGoManifestHandlerMiddlewareWithCustomMainModuleName.mjs +11 -10
- package/dist/esm/utils/patchExpoGoManifestHandlerMiddlewareWithCustomMainModuleName.mjs.map +1 -1
- package/dist/esm/utils/patchExpoGoManifestHandlerMiddlewareWithCustomMainModuleName.native.js +11 -10
- package/dist/esm/utils/patchExpoGoManifestHandlerMiddlewareWithCustomMainModuleName.native.js.map +1 -1
- package/dist/esm/utils/projectImport.mjs +23 -25
- package/dist/esm/utils/projectImport.mjs.map +1 -1
- package/dist/esm/utils/projectImport.native.js +24 -33
- package/dist/esm/utils/projectImport.native.js.map +1 -1
- package/package.json +5 -6
- package/src/metro-config/getMetroConfigFromViteConfig.ts +46 -10
- package/src/transformer/loadBabelConfig.ts +2 -0
- package/src/transformer/metroNativeWorker.test.ts +267 -35
- package/src/transformer/metroNativeWorker.ts +3 -11
- package/types/babel-plugins/import-meta-env-plugin.d.ts.map +1 -1
- package/types/metro-config/getMetroConfigFromViteConfig.d.ts.map +1 -1
- package/types/rn-commands/bundle/assetPathUtils.d.ts.map +1 -1
- package/types/rn-commands/bundle/filterPlatformAssetScales.d.ts.map +1 -1
- package/types/rn-commands/bundle/getAssetDestPathAndroid.d.ts.map +1 -1
- package/types/rn-commands/bundle/getAssetDestPathIOS.d.ts.map +1 -1
- package/types/rn-commands/bundle/saveAssets.d.ts.map +1 -1
- package/types/transformer/loadBabelConfig.d.ts.map +1 -1
- package/types/transformer/metroNativeWorker.d.ts.map +1 -1
- package/dist/cjs/transformer/metroNativeWorker.test.cjs +0 -897
- package/dist/cjs/transformer/metroNativeWorker.test.native.js +0 -1010
- package/dist/cjs/transformer/metroNativeWorker.test.native.js.map +0 -1
- package/dist/cjs/transformer/transformSync.test.cjs +0 -36
- package/dist/cjs/transformer/transformSync.test.native.js +0 -49
- package/dist/cjs/transformer/transformSync.test.native.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/index.native.js.map +0 -1
- package/dist/esm/metro-config/types.mjs.map +0 -1
- package/dist/esm/metro-config/types.native.js.map +0 -1
- package/dist/esm/rn-commands/bundle/index.mjs.map +0 -1
- package/dist/esm/rn-commands/bundle/index.native.js.map +0 -1
- package/dist/esm/rn-commands/bundle/types.mjs.map +0 -1
- package/dist/esm/rn-commands/bundle/types.native.js.map +0 -1
- package/dist/esm/rn-commands/index.mjs.map +0 -1
- package/dist/esm/rn-commands/index.native.js.map +0 -1
- package/dist/esm/transformer/babel-core.mjs.map +0 -1
- package/dist/esm/transformer/babel-core.native.js.map +0 -1
- package/dist/esm/transformer/metroNativeWorker.test.mjs +0 -861
- package/dist/esm/transformer/metroNativeWorker.test.mjs.map +0 -1
- package/dist/esm/transformer/metroNativeWorker.test.native.js +0 -972
- package/dist/esm/transformer/metroNativeWorker.test.native.js.map +0 -1
- package/dist/esm/transformer/transformSync.test.mjs +0 -37
- package/dist/esm/transformer/transformSync.test.mjs.map +0 -1
- package/dist/esm/transformer/transformSync.test.native.js +0 -47
- package/dist/esm/transformer/transformSync.test.native.js.map +0 -1
- package/dist/esm/transformer/types.mjs.map +0 -1
- package/dist/esm/transformer/types.native.js.map +0 -1
- package/types/transformer/metroNativeWorker.test.d.ts +0 -2
- package/types/transformer/metroNativeWorker.test.d.ts.map +0 -1
- package/types/transformer/transformSync.test.d.ts +0 -2
- package/types/transformer/transformSync.test.d.ts.map +0 -1
|
@@ -6,2607 +6,2479 @@ import { parseSync } from "oxc-parser";
|
|
|
6
6
|
import MagicString from "magic-string";
|
|
7
7
|
import remapping from "@jridgewell/remapping";
|
|
8
8
|
import { TraceMap, eachMapping } from "@jridgewell/trace-mapping";
|
|
9
|
-
import { shouldStripFlow, transformHermesAsync, transformHermesLoops, transformReactNativeCodegen } from "@vxrn/compiler";
|
|
9
|
+
import { shouldStripFlow, stripFlowTypes, transformHermesAsync, transformHermesLoops, transformReactNativeCodegen } from "@vxrn/compiler";
|
|
10
10
|
import { getPlatformEnv, metroPlatformToViteEnvironment } from "../env/platformEnv.native.js";
|
|
11
|
+
|
|
11
12
|
function _class_call_check(instance, Constructor) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
if (!(instance instanceof Constructor)) {
|
|
14
|
+
throw new TypeError("Cannot call a class as a function");
|
|
15
|
+
}
|
|
15
16
|
}
|
|
16
17
|
function _defineProperties(target, props) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
for (var i = 0; i < props.length; i++) {
|
|
19
|
+
var descriptor = props[i];
|
|
20
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
21
|
+
descriptor.configurable = true;
|
|
22
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
23
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
24
|
+
}
|
|
24
25
|
}
|
|
25
26
|
function _create_class(Constructor, protoProps, staticProps) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
28
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
29
|
+
return Constructor;
|
|
29
30
|
}
|
|
30
31
|
function _define_property(obj, key, value) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
function _type_of(obj) {
|
|
44
|
-
"@swc/helpers - typeof";
|
|
45
|
-
|
|
46
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
32
|
+
if (key in obj) {
|
|
33
|
+
Object.defineProperty(obj, key, {
|
|
34
|
+
value,
|
|
35
|
+
enumerable: true,
|
|
36
|
+
configurable: true,
|
|
37
|
+
writable: true
|
|
38
|
+
});
|
|
39
|
+
} else {
|
|
40
|
+
obj[key] = value;
|
|
41
|
+
}
|
|
42
|
+
return obj;
|
|
47
43
|
}
|
|
48
44
|
function collectModuleLiteralBindings(program) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
|
176
|
-
_iterator2.return();
|
|
177
|
-
}
|
|
178
|
-
} finally {
|
|
179
|
-
if (_didIteratorError2) {
|
|
180
|
-
throw _iteratorError2;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
return bindings;
|
|
45
|
+
var reassigned = /* @__PURE__ */ new Set();
|
|
46
|
+
var declCount = /* @__PURE__ */ new Map();
|
|
47
|
+
(function findReassignments(node) {
|
|
48
|
+
var _node_left, _node_argument;
|
|
49
|
+
if (!node || typeof node !== "object") return;
|
|
50
|
+
if (Array.isArray(node)) {
|
|
51
|
+
var _iteratorNormalCompletion4 = true, _didIteratorError4 = false, _iteratorError4 = void 0;
|
|
52
|
+
try {
|
|
53
|
+
for (var _iterator4 = node[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
|
|
54
|
+
var child = _step4.value;
|
|
55
|
+
findReassignments(child);
|
|
56
|
+
}
|
|
57
|
+
} catch (err) {
|
|
58
|
+
_didIteratorError4 = true;
|
|
59
|
+
_iteratorError4 = err;
|
|
60
|
+
} finally {
|
|
61
|
+
try {
|
|
62
|
+
if (!_iteratorNormalCompletion4 && _iterator4.return != null) {
|
|
63
|
+
_iterator4.return();
|
|
64
|
+
}
|
|
65
|
+
} finally {
|
|
66
|
+
if (_didIteratorError4) {
|
|
67
|
+
throw _iteratorError4;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (node.type === "AssignmentExpression" && ((_node_left = node.left) === null || _node_left === void 0 ? void 0 : _node_left.type) === "Identifier") {
|
|
74
|
+
reassigned.add(node.left.name);
|
|
75
|
+
} else if (node.type === "UpdateExpression" && ((_node_argument = node.argument) === null || _node_argument === void 0 ? void 0 : _node_argument.type) === "Identifier") {
|
|
76
|
+
reassigned.add(node.argument.name);
|
|
77
|
+
}
|
|
78
|
+
for (var key in node) {
|
|
79
|
+
if (key === "type" || key === "start" || key === "end") continue;
|
|
80
|
+
findReassignments(node[key]);
|
|
81
|
+
}
|
|
82
|
+
})(program);
|
|
83
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
84
|
+
try {
|
|
85
|
+
for (var _iterator = (program.body || [])[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
86
|
+
var stmt = _step.value;
|
|
87
|
+
if (stmt.type !== "VariableDeclaration") continue;
|
|
88
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;
|
|
89
|
+
try {
|
|
90
|
+
for (var _iterator1 = (stmt.declarations || [])[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
|
|
91
|
+
var decl = _step1.value;
|
|
92
|
+
var _decl_id;
|
|
93
|
+
if (((_decl_id = decl.id) === null || _decl_id === void 0 ? void 0 : _decl_id.type) === "Identifier") {
|
|
94
|
+
declCount.set(decl.id.name, (declCount.get(decl.id.name) || 0) + 1);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
} catch (err) {
|
|
98
|
+
_didIteratorError1 = true;
|
|
99
|
+
_iteratorError1 = err;
|
|
100
|
+
} finally {
|
|
101
|
+
try {
|
|
102
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
103
|
+
_iterator1.return();
|
|
104
|
+
}
|
|
105
|
+
} finally {
|
|
106
|
+
if (_didIteratorError1) {
|
|
107
|
+
throw _iteratorError1;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
} catch (err) {
|
|
113
|
+
_didIteratorError = true;
|
|
114
|
+
_iteratorError = err;
|
|
115
|
+
} finally {
|
|
116
|
+
try {
|
|
117
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
118
|
+
_iterator.return();
|
|
119
|
+
}
|
|
120
|
+
} finally {
|
|
121
|
+
if (_didIteratorError) {
|
|
122
|
+
throw _iteratorError;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
var bindings = /* @__PURE__ */ new Map();
|
|
127
|
+
var _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = void 0;
|
|
128
|
+
try {
|
|
129
|
+
for (var _iterator2 = (program.body || [])[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
|
130
|
+
var stmt1 = _step2.value;
|
|
131
|
+
if (stmt1.type !== "VariableDeclaration") continue;
|
|
132
|
+
var _iteratorNormalCompletion3 = true, _didIteratorError3 = false, _iteratorError3 = void 0;
|
|
133
|
+
try {
|
|
134
|
+
for (var _iterator3 = (stmt1.declarations || [])[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
|
|
135
|
+
var decl1 = _step3.value;
|
|
136
|
+
var _decl_id1, _decl_init;
|
|
137
|
+
if (((_decl_id1 = decl1.id) === null || _decl_id1 === void 0 ? void 0 : _decl_id1.type) === "Identifier" && ((_decl_init = decl1.init) === null || _decl_init === void 0 ? void 0 : _decl_init.type) === "Literal" && !reassigned.has(decl1.id.name) && declCount.get(decl1.id.name) === 1) {
|
|
138
|
+
bindings.set(decl1.id.name, decl1.init);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
} catch (err) {
|
|
142
|
+
_didIteratorError3 = true;
|
|
143
|
+
_iteratorError3 = err;
|
|
144
|
+
} finally {
|
|
145
|
+
try {
|
|
146
|
+
if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
|
|
147
|
+
_iterator3.return();
|
|
148
|
+
}
|
|
149
|
+
} finally {
|
|
150
|
+
if (_didIteratorError3) {
|
|
151
|
+
throw _iteratorError3;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
} catch (err) {
|
|
157
|
+
_didIteratorError2 = true;
|
|
158
|
+
_iteratorError2 = err;
|
|
159
|
+
} finally {
|
|
160
|
+
try {
|
|
161
|
+
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
|
162
|
+
_iterator2.return();
|
|
163
|
+
}
|
|
164
|
+
} finally {
|
|
165
|
+
if (_didIteratorError2) {
|
|
166
|
+
throw _iteratorError2;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return bindings;
|
|
185
171
|
}
|
|
186
172
|
var WORKER_CACHE_KEY_VERSION = "5";
|
|
187
173
|
function langForFilename(filename) {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
174
|
+
if (filename.endsWith(".tsx")) return "tsx";
|
|
175
|
+
if (filename.endsWith(".ts")) return "ts";
|
|
176
|
+
return "jsx";
|
|
191
177
|
}
|
|
192
178
|
function getOneRouterMetroOptions(options) {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
}
|
|
220
|
-
return void 0;
|
|
179
|
+
var _options_customTransformOptions_vite_babelConfig, _options_customTransformOptions_vite, _options_customTransformOptions;
|
|
180
|
+
var plugins = (_options_customTransformOptions = options.customTransformOptions) === null || _options_customTransformOptions === void 0 ? void 0 : (_options_customTransformOptions_vite = _options_customTransformOptions.vite) === null || _options_customTransformOptions_vite === void 0 ? void 0 : (_options_customTransformOptions_vite_babelConfig = _options_customTransformOptions_vite.babelConfig) === null || _options_customTransformOptions_vite_babelConfig === void 0 ? void 0 : _options_customTransformOptions_vite_babelConfig.plugins;
|
|
181
|
+
if (!Array.isArray(plugins)) return void 0;
|
|
182
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
183
|
+
try {
|
|
184
|
+
for (var _iterator = plugins[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
185
|
+
var plugin = _step.value;
|
|
186
|
+
if (Array.isArray(plugin) && typeof plugin[0] === "string" && plugin[0].includes("one-router-metro")) {
|
|
187
|
+
return plugin[1];
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
} catch (err) {
|
|
191
|
+
_didIteratorError = true;
|
|
192
|
+
_iteratorError = err;
|
|
193
|
+
} finally {
|
|
194
|
+
try {
|
|
195
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
196
|
+
_iterator.return();
|
|
197
|
+
}
|
|
198
|
+
} finally {
|
|
199
|
+
if (_didIteratorError) {
|
|
200
|
+
throw _iteratorError;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return void 0;
|
|
221
205
|
}
|
|
222
206
|
function getRemoveServerCodeRouterRoot(options) {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
}
|
|
252
|
-
return void 0;
|
|
207
|
+
var _options_customTransformOptions_vite_babelConfig, _options_customTransformOptions_vite, _options_customTransformOptions;
|
|
208
|
+
var plugins = (_options_customTransformOptions = options.customTransformOptions) === null || _options_customTransformOptions === void 0 ? void 0 : (_options_customTransformOptions_vite = _options_customTransformOptions.vite) === null || _options_customTransformOptions_vite === void 0 ? void 0 : (_options_customTransformOptions_vite_babelConfig = _options_customTransformOptions_vite.babelConfig) === null || _options_customTransformOptions_vite_babelConfig === void 0 ? void 0 : _options_customTransformOptions_vite_babelConfig.plugins;
|
|
209
|
+
if (!Array.isArray(plugins)) return void 0;
|
|
210
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
211
|
+
try {
|
|
212
|
+
for (var _iterator = plugins[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
213
|
+
var plugin = _step.value;
|
|
214
|
+
if (Array.isArray(plugin) && typeof plugin[0] === "string" && plugin[0].includes("remove-server-code")) {
|
|
215
|
+
var _ref;
|
|
216
|
+
var _plugin_;
|
|
217
|
+
return (_ref = (_plugin_ = plugin[1]) === null || _plugin_ === void 0 ? void 0 : _plugin_.routerRoot) !== null && _ref !== void 0 ? _ref : "app";
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
} catch (err) {
|
|
221
|
+
_didIteratorError = true;
|
|
222
|
+
_iteratorError = err;
|
|
223
|
+
} finally {
|
|
224
|
+
try {
|
|
225
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
226
|
+
_iterator.return();
|
|
227
|
+
}
|
|
228
|
+
} finally {
|
|
229
|
+
if (_didIteratorError) {
|
|
230
|
+
throw _iteratorError;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
return void 0;
|
|
253
235
|
}
|
|
254
|
-
var importMetaEnvCache = /* @__PURE__ */new WeakMap();
|
|
236
|
+
var importMetaEnvCache = /* @__PURE__ */ new WeakMap();
|
|
255
237
|
function getImportMetaEnv(options) {
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
}
|
|
303
|
-
return merged;
|
|
238
|
+
var _options_platform;
|
|
239
|
+
var _options_customTransformOptions_vite_babelConfig, _options_customTransformOptions_vite, _options_customTransformOptions;
|
|
240
|
+
var plugins = (_options_customTransformOptions = options.customTransformOptions) === null || _options_customTransformOptions === void 0 ? void 0 : (_options_customTransformOptions_vite = _options_customTransformOptions.vite) === null || _options_customTransformOptions_vite === void 0 ? void 0 : (_options_customTransformOptions_vite_babelConfig = _options_customTransformOptions_vite.babelConfig) === null || _options_customTransformOptions_vite_babelConfig === void 0 ? void 0 : _options_customTransformOptions_vite_babelConfig.plugins;
|
|
241
|
+
var platform = (_options_platform = options.platform) !== null && _options_platform !== void 0 ? _options_platform : "";
|
|
242
|
+
var byPlatform = Array.isArray(plugins) ? importMetaEnvCache.get(plugins) : void 0;
|
|
243
|
+
var cached = byPlatform === null || byPlatform === void 0 ? void 0 : byPlatform.get(platform);
|
|
244
|
+
if (cached) return cached;
|
|
245
|
+
var env = {};
|
|
246
|
+
if (Array.isArray(plugins)) {
|
|
247
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
248
|
+
try {
|
|
249
|
+
for (var _iterator = plugins[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
250
|
+
var plugin = _step.value;
|
|
251
|
+
if (Array.isArray(plugin) && typeof plugin[0] === "string" && plugin[0].includes("import-meta-env-plugin")) {
|
|
252
|
+
var _plugin_;
|
|
253
|
+
var found = (_plugin_ = plugin[1]) === null || _plugin_ === void 0 ? void 0 : _plugin_.env;
|
|
254
|
+
if (found && typeof found === "object") env = found;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
} catch (err) {
|
|
258
|
+
_didIteratorError = true;
|
|
259
|
+
_iteratorError = err;
|
|
260
|
+
} finally {
|
|
261
|
+
try {
|
|
262
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
263
|
+
_iterator.return();
|
|
264
|
+
}
|
|
265
|
+
} finally {
|
|
266
|
+
if (_didIteratorError) {
|
|
267
|
+
throw _iteratorError;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
var merged = {
|
|
273
|
+
...env,
|
|
274
|
+
...getPlatformEnv(metroPlatformToViteEnvironment(options.platform))
|
|
275
|
+
};
|
|
276
|
+
if (Array.isArray(plugins)) {
|
|
277
|
+
if (!byPlatform) {
|
|
278
|
+
byPlatform = /* @__PURE__ */ new Map();
|
|
279
|
+
importMetaEnvCache.set(plugins, byPlatform);
|
|
280
|
+
}
|
|
281
|
+
byPlatform.set(platform, merged);
|
|
282
|
+
}
|
|
283
|
+
return merged;
|
|
304
284
|
}
|
|
305
|
-
var PORTED_BABEL_PLUGINS = [
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
"
|
|
309
|
-
|
|
310
|
-
|
|
285
|
+
var PORTED_BABEL_PLUGINS = [
|
|
286
|
+
"import-meta-env-plugin",
|
|
287
|
+
"one-router-metro",
|
|
288
|
+
"remove-server-code",
|
|
289
|
+
"module-resolver",
|
|
290
|
+
"environment-guard",
|
|
291
|
+
"inline-one-server-url",
|
|
292
|
+
"react-native-worklets/plugin",
|
|
293
|
+
"react-native-reanimated/plugin",
|
|
294
|
+
"babel-plugin-react-compiler"
|
|
295
|
+
];
|
|
296
|
+
var unportedPluginCache = /* @__PURE__ */ new WeakMap();
|
|
297
|
+
var loadedNativeTransforms = /* @__PURE__ */ new Map();
|
|
311
298
|
function getNativeTransforms(options, projectRoot) {
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
299
|
+
var _options_customTransformOptions_vite, _options_customTransformOptions;
|
|
300
|
+
var ids = (_options_customTransformOptions = options.customTransformOptions) === null || _options_customTransformOptions === void 0 ? void 0 : (_options_customTransformOptions_vite = _options_customTransformOptions.vite) === null || _options_customTransformOptions_vite === void 0 ? void 0 : _options_customTransformOptions_vite.nativeTransformModules;
|
|
301
|
+
if (!Array.isArray(ids) || !ids.length) return [];
|
|
302
|
+
var req = createRequire(path.join(projectRoot, "package.json"));
|
|
303
|
+
return ids.map(function(id) {
|
|
304
|
+
var _ref;
|
|
305
|
+
var cached = loadedNativeTransforms.get(id);
|
|
306
|
+
if (cached) return cached;
|
|
307
|
+
var mod;
|
|
308
|
+
try {
|
|
309
|
+
mod = req(id);
|
|
310
|
+
} catch (err) {
|
|
311
|
+
throw new Error(`[vxrn/metro] Could not load the native transform "${id}" from ${projectRoot}: ${err.message}`);
|
|
312
|
+
}
|
|
313
|
+
var fn = (_ref = mod === null || mod === void 0 ? void 0 : mod.default) !== null && _ref !== void 0 ? _ref : mod;
|
|
314
|
+
if (typeof fn !== "function") {
|
|
315
|
+
throw new Error(`[vxrn/metro] The native transform "${id}" must default-export a function (code, ctx) => string.`);
|
|
316
|
+
}
|
|
317
|
+
loadedNativeTransforms.set(id, fn);
|
|
318
|
+
return fn;
|
|
319
|
+
});
|
|
333
320
|
}
|
|
334
321
|
function isReactCompilerCandidate(filename) {
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
322
|
+
if (!/\.tsx?$/.test(filename)) return false;
|
|
323
|
+
if (filename.includes("node_modules")) return false;
|
|
324
|
+
if (filename.includes("+api.")) return false;
|
|
325
|
+
return true;
|
|
339
326
|
}
|
|
340
327
|
function hasBabelPlugin(options, id) {
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
328
|
+
var _options_customTransformOptions_vite_babelConfig, _options_customTransformOptions_vite, _options_customTransformOptions;
|
|
329
|
+
var plugins = (_options_customTransformOptions = options.customTransformOptions) === null || _options_customTransformOptions === void 0 ? void 0 : (_options_customTransformOptions_vite = _options_customTransformOptions.vite) === null || _options_customTransformOptions_vite === void 0 ? void 0 : (_options_customTransformOptions_vite_babelConfig = _options_customTransformOptions_vite.babelConfig) === null || _options_customTransformOptions_vite_babelConfig === void 0 ? void 0 : _options_customTransformOptions_vite_babelConfig.plugins;
|
|
330
|
+
if (!Array.isArray(plugins)) return false;
|
|
331
|
+
return plugins.some(function(plugin) {
|
|
332
|
+
return (Array.isArray(plugin) ? plugin[0] : plugin) === id;
|
|
333
|
+
});
|
|
347
334
|
}
|
|
348
335
|
function assertNoUnportedBabelPlugins(options) {
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
return ` - ${id}`;
|
|
393
|
-
}).join("\n") + `
|
|
336
|
+
var _options_customTransformOptions_vite_babelConfig, _options_customTransformOptions_vite, _options_customTransformOptions;
|
|
337
|
+
var plugins = (_options_customTransformOptions = options.customTransformOptions) === null || _options_customTransformOptions === void 0 ? void 0 : (_options_customTransformOptions_vite = _options_customTransformOptions.vite) === null || _options_customTransformOptions_vite === void 0 ? void 0 : (_options_customTransformOptions_vite_babelConfig = _options_customTransformOptions_vite.babelConfig) === null || _options_customTransformOptions_vite_babelConfig === void 0 ? void 0 : _options_customTransformOptions_vite_babelConfig.plugins;
|
|
338
|
+
if (!Array.isArray(plugins)) return;
|
|
339
|
+
var unported = unportedPluginCache.get(plugins);
|
|
340
|
+
if (!unported) {
|
|
341
|
+
unported = [];
|
|
342
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
343
|
+
try {
|
|
344
|
+
var _loop = function() {
|
|
345
|
+
var plugin = _step.value;
|
|
346
|
+
var id = Array.isArray(plugin) ? plugin[0] : plugin;
|
|
347
|
+
if (typeof id !== "string") {
|
|
348
|
+
unported.push("(a function or object plugin, which cannot be ported)");
|
|
349
|
+
return "continue";
|
|
350
|
+
}
|
|
351
|
+
if (!PORTED_BABEL_PLUGINS.some(function(ported) {
|
|
352
|
+
return id.includes(ported);
|
|
353
|
+
})) {
|
|
354
|
+
unported.push(id);
|
|
355
|
+
}
|
|
356
|
+
};
|
|
357
|
+
for (var _iterator = plugins[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) _loop();
|
|
358
|
+
} catch (err) {
|
|
359
|
+
_didIteratorError = true;
|
|
360
|
+
_iteratorError = err;
|
|
361
|
+
} finally {
|
|
362
|
+
try {
|
|
363
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
364
|
+
_iterator.return();
|
|
365
|
+
}
|
|
366
|
+
} finally {
|
|
367
|
+
if (_didIteratorError) {
|
|
368
|
+
throw _iteratorError;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
unportedPluginCache.set(plugins, unported);
|
|
373
|
+
}
|
|
374
|
+
if (unported.length) {
|
|
375
|
+
throw new Error(`[vxrn/metro] the native transform path runs no babel, so these babel plugins would be silently ignored:
|
|
376
|
+
` + unported.map(function(id) {
|
|
377
|
+
return ` - ${id}`;
|
|
378
|
+
}).join("\n") + `
|
|
394
379
|
|
|
395
380
|
Port each one to a native transform and list it in bundlerOptions.nativeTransformModules, remove it from bundlerOptions.babelConfigOverrides, or set bundlerOptions.nativeTransforms: false (or ONE_METRO_NATIVE_TRANSFORMS=0) to go back to the babel transformer.`);
|
|
396
|
-
|
|
381
|
+
}
|
|
397
382
|
}
|
|
398
383
|
function getModuleResolverAliases(options) {
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
}
|
|
428
|
-
return void 0;
|
|
384
|
+
var _options_customTransformOptions_vite_babelConfig, _options_customTransformOptions_vite, _options_customTransformOptions;
|
|
385
|
+
var plugins = (_options_customTransformOptions = options.customTransformOptions) === null || _options_customTransformOptions === void 0 ? void 0 : (_options_customTransformOptions_vite = _options_customTransformOptions.vite) === null || _options_customTransformOptions_vite === void 0 ? void 0 : (_options_customTransformOptions_vite_babelConfig = _options_customTransformOptions_vite.babelConfig) === null || _options_customTransformOptions_vite_babelConfig === void 0 ? void 0 : _options_customTransformOptions_vite_babelConfig.plugins;
|
|
386
|
+
if (!Array.isArray(plugins)) return void 0;
|
|
387
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
388
|
+
try {
|
|
389
|
+
for (var _iterator = plugins[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
390
|
+
var plugin = _step.value;
|
|
391
|
+
if (Array.isArray(plugin) && typeof plugin[0] === "string" && plugin[0].includes("module-resolver")) {
|
|
392
|
+
var _plugin_;
|
|
393
|
+
var alias = (_plugin_ = plugin[1]) === null || _plugin_ === void 0 ? void 0 : _plugin_.alias;
|
|
394
|
+
if (alias && typeof alias === "object") return alias;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
} catch (err) {
|
|
398
|
+
_didIteratorError = true;
|
|
399
|
+
_iteratorError = err;
|
|
400
|
+
} finally {
|
|
401
|
+
try {
|
|
402
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
403
|
+
_iterator.return();
|
|
404
|
+
}
|
|
405
|
+
} finally {
|
|
406
|
+
if (_didIteratorError) {
|
|
407
|
+
throw _iteratorError;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
return void 0;
|
|
429
412
|
}
|
|
430
413
|
function resolveAliasSpecifier(specifier, filename, projectRoot, aliases) {
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
}
|
|
463
|
-
return void 0;
|
|
414
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
415
|
+
try {
|
|
416
|
+
for (var _iterator = Object.entries(aliases)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
417
|
+
var [rawKey, value] = _step.value;
|
|
418
|
+
var target = void 0;
|
|
419
|
+
if (rawKey.endsWith("$")) {
|
|
420
|
+
if (specifier === rawKey.slice(0, -1)) target = value;
|
|
421
|
+
} else if (specifier === rawKey || specifier.startsWith(`${rawKey}/`)) {
|
|
422
|
+
target = value + specifier.slice(rawKey.length);
|
|
423
|
+
}
|
|
424
|
+
if (target === void 0) continue;
|
|
425
|
+
var abs = path.resolve(projectRoot, target);
|
|
426
|
+
var rel = path.relative(path.dirname(filename), abs).split(path.sep).join("/");
|
|
427
|
+
if (!rel.startsWith(".")) rel = `./${rel}`;
|
|
428
|
+
return rel;
|
|
429
|
+
}
|
|
430
|
+
} catch (err) {
|
|
431
|
+
_didIteratorError = true;
|
|
432
|
+
_iteratorError = err;
|
|
433
|
+
} finally {
|
|
434
|
+
try {
|
|
435
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
436
|
+
_iterator.return();
|
|
437
|
+
}
|
|
438
|
+
} finally {
|
|
439
|
+
if (_didIteratorError) {
|
|
440
|
+
throw _iteratorError;
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
return void 0;
|
|
464
445
|
}
|
|
465
446
|
function applyModuleResolverAliases(code, filename, projectRoot, aliases) {
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
walk(parsed.program);
|
|
543
|
-
return changed ? ms.toString() : code;
|
|
447
|
+
var _parsed_errors;
|
|
448
|
+
var parsed = parseSync(filename, code, { lang: langForFilename(filename) });
|
|
449
|
+
if (parsed === null || parsed === void 0 ? void 0 : (_parsed_errors = parsed.errors) === null || _parsed_errors === void 0 ? void 0 : _parsed_errors.length) {
|
|
450
|
+
throw new Error(`[vxrn/metro] Failed to parse ${filename} for alias resolution: ${parsed.errors[0].message}`);
|
|
451
|
+
}
|
|
452
|
+
if (!(parsed === null || parsed === void 0 ? void 0 : parsed.program)) return code;
|
|
453
|
+
var ms = new MagicString(code);
|
|
454
|
+
var changed = false;
|
|
455
|
+
function rewrite(sourceNode) {
|
|
456
|
+
if ((sourceNode === null || sourceNode === void 0 ? void 0 : sourceNode.type) !== "Literal" || typeof sourceNode.value !== "string") return;
|
|
457
|
+
var resolved = resolveAliasSpecifier(sourceNode.value, filename, projectRoot, aliases);
|
|
458
|
+
if (resolved === void 0) return;
|
|
459
|
+
ms.overwrite(sourceNode.start, sourceNode.end, JSON.stringify(resolved));
|
|
460
|
+
changed = true;
|
|
461
|
+
}
|
|
462
|
+
function walk(node) {
|
|
463
|
+
var _node_callee;
|
|
464
|
+
if (!node || typeof node !== "object") return;
|
|
465
|
+
if (node.type === "ImportDeclaration" || node.type === "ExportNamedDeclaration" || node.type === "ExportAllDeclaration" || node.type === "ImportExpression") {
|
|
466
|
+
rewrite(node.source);
|
|
467
|
+
} else if (node.type === "CallExpression" && ((_node_callee = node.callee) === null || _node_callee === void 0 ? void 0 : _node_callee.type) === "Identifier" && node.callee.name === "require") {
|
|
468
|
+
var _node_arguments;
|
|
469
|
+
rewrite((_node_arguments = node.arguments) === null || _node_arguments === void 0 ? void 0 : _node_arguments[0]);
|
|
470
|
+
}
|
|
471
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
472
|
+
try {
|
|
473
|
+
for (var _iterator = Object.keys(node)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
474
|
+
var k = _step.value;
|
|
475
|
+
if (k === "start" || k === "end" || k === "loc" || k === "range" || k === "parent" || k === "comments") continue;
|
|
476
|
+
var child = node[k];
|
|
477
|
+
if (Array.isArray(child)) {
|
|
478
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;
|
|
479
|
+
try {
|
|
480
|
+
for (var _iterator1 = child[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
|
|
481
|
+
var item = _step1.value;
|
|
482
|
+
walk(item);
|
|
483
|
+
}
|
|
484
|
+
} catch (err) {
|
|
485
|
+
_didIteratorError1 = true;
|
|
486
|
+
_iteratorError1 = err;
|
|
487
|
+
} finally {
|
|
488
|
+
try {
|
|
489
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
490
|
+
_iterator1.return();
|
|
491
|
+
}
|
|
492
|
+
} finally {
|
|
493
|
+
if (_didIteratorError1) {
|
|
494
|
+
throw _iteratorError1;
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
} else if (child && typeof child === "object") {
|
|
499
|
+
walk(child);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
} catch (err) {
|
|
503
|
+
_didIteratorError = true;
|
|
504
|
+
_iteratorError = err;
|
|
505
|
+
} finally {
|
|
506
|
+
try {
|
|
507
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
508
|
+
_iterator.return();
|
|
509
|
+
}
|
|
510
|
+
} finally {
|
|
511
|
+
if (_didIteratorError) {
|
|
512
|
+
throw _iteratorError;
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
walk(parsed.program);
|
|
518
|
+
return changed ? ms.toString() : code;
|
|
544
519
|
}
|
|
545
520
|
function applyInlineEnvVars(code, filename, isProduction) {
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
_iteratorError1 = err;
|
|
804
|
-
} finally {
|
|
805
|
-
try {
|
|
806
|
-
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
807
|
-
_iterator1.return();
|
|
808
|
-
}
|
|
809
|
-
} finally {
|
|
810
|
-
if (_didIteratorError1) {
|
|
811
|
-
throw _iteratorError1;
|
|
812
|
-
}
|
|
813
|
-
}
|
|
814
|
-
}
|
|
815
|
-
if (needsEnvImport) {
|
|
816
|
-
ms.prepend(`import { env as _$$_EXPO_ENV } from "expo/virtual/env";
|
|
521
|
+
var env = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
|
|
522
|
+
var _parsed_errors;
|
|
523
|
+
var parsed = parseSync(filename, code, { lang: langForFilename(filename) });
|
|
524
|
+
if (parsed === null || parsed === void 0 ? void 0 : (_parsed_errors = parsed.errors) === null || _parsed_errors === void 0 ? void 0 : _parsed_errors.length) {
|
|
525
|
+
throw new Error(`[vxrn/metro] Failed to parse ${filename} for env inlining: ${parsed.errors[0].message}`);
|
|
526
|
+
}
|
|
527
|
+
if (!(parsed === null || parsed === void 0 ? void 0 : parsed.program)) return code;
|
|
528
|
+
var ms = new MagicString(code);
|
|
529
|
+
var needsEnvImport = false;
|
|
530
|
+
var edits = [];
|
|
531
|
+
var known = /* @__PURE__ */ new Map();
|
|
532
|
+
function replace(node, value) {
|
|
533
|
+
var text = value === void 0 ? "undefined" : JSON.stringify(value);
|
|
534
|
+
edits.push({
|
|
535
|
+
start: node.start,
|
|
536
|
+
end: node.end,
|
|
537
|
+
text
|
|
538
|
+
});
|
|
539
|
+
known.set(node, value);
|
|
540
|
+
}
|
|
541
|
+
function keyOf(prop, computed) {
|
|
542
|
+
if (!computed && (prop === null || prop === void 0 ? void 0 : prop.type) === "Identifier") return prop.name;
|
|
543
|
+
if ((prop === null || prop === void 0 ? void 0 : prop.type) === "Literal" && typeof prop.value === "string") return prop.value;
|
|
544
|
+
return void 0;
|
|
545
|
+
}
|
|
546
|
+
function isImportMeta(node) {
|
|
547
|
+
var _node_meta, _node_property;
|
|
548
|
+
return (node === null || node === void 0 ? void 0 : node.type) === "MetaProperty" && ((_node_meta = node.meta) === null || _node_meta === void 0 ? void 0 : _node_meta.name) === "import" && ((_node_property = node.property) === null || _node_property === void 0 ? void 0 : _node_property.name) === "meta";
|
|
549
|
+
}
|
|
550
|
+
function walk(node, parent) {
|
|
551
|
+
if (!node || typeof node !== "object") return;
|
|
552
|
+
if (node.type === "MemberExpression" || node.type === "OptionalMemberExpression") {
|
|
553
|
+
var _obj_object;
|
|
554
|
+
var obj = node.object;
|
|
555
|
+
var isMember = (obj === null || obj === void 0 ? void 0 : obj.type) === "MemberExpression" || (obj === null || obj === void 0 ? void 0 : obj.type) === "OptionalMemberExpression";
|
|
556
|
+
var isProcessEnv = isMember && ((_obj_object = obj.object) === null || _obj_object === void 0 ? void 0 : _obj_object.type) === "Identifier" && obj.object.name === "process" && keyOf(obj.property, obj.computed) === "env";
|
|
557
|
+
var isAssignmentTarget = (parent === null || parent === void 0 ? void 0 : parent.type) === "AssignmentExpression" && parent.left === node;
|
|
558
|
+
var key = keyOf(node.property, node.computed);
|
|
559
|
+
if (isProcessEnv && !isAssignmentTarget && key === "ONE_SERVER_URL") {
|
|
560
|
+
replace(node, process.env.ONE_SERVER_URL || "");
|
|
561
|
+
return;
|
|
562
|
+
}
|
|
563
|
+
if (isProcessEnv && !isAssignmentTarget && (key === null || key === void 0 ? void 0 : key.startsWith("EXPO_PUBLIC_"))) {
|
|
564
|
+
if (isProduction) {
|
|
565
|
+
var _process_env_key;
|
|
566
|
+
replace(node, (_process_env_key = process.env[key]) !== null && _process_env_key !== void 0 ? _process_env_key : void 0);
|
|
567
|
+
} else {
|
|
568
|
+
edits.push({
|
|
569
|
+
start: node.start,
|
|
570
|
+
end: node.end,
|
|
571
|
+
text: `_$$_EXPO_ENV.${key}`
|
|
572
|
+
});
|
|
573
|
+
needsEnvImport = true;
|
|
574
|
+
}
|
|
575
|
+
return;
|
|
576
|
+
}
|
|
577
|
+
if (!isAssignmentTarget && isMember && isImportMeta(obj.object) && keyOf(obj.property, obj.computed) === "env" && key !== void 0) {
|
|
578
|
+
replace(node, env[key]);
|
|
579
|
+
return;
|
|
580
|
+
}
|
|
581
|
+
if (!isAssignmentTarget && isImportMeta(obj) && key === "env") {
|
|
582
|
+
edits.push({
|
|
583
|
+
start: node.start,
|
|
584
|
+
end: node.end,
|
|
585
|
+
text: JSON.stringify(env)
|
|
586
|
+
});
|
|
587
|
+
return;
|
|
588
|
+
}
|
|
589
|
+
if (isProcessEnv && !isAssignmentTarget && key !== void 0 && key in env) {
|
|
590
|
+
replace(node, env[key]);
|
|
591
|
+
return;
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
var _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = void 0;
|
|
595
|
+
try {
|
|
596
|
+
for (var _iterator2 = Object.keys(node)[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
|
597
|
+
var k = _step2.value;
|
|
598
|
+
if (k === "start" || k === "end" || k === "loc" || k === "range" || k === "parent" || k === "comments") continue;
|
|
599
|
+
var child = node[k];
|
|
600
|
+
if (Array.isArray(child)) {
|
|
601
|
+
var _iteratorNormalCompletion12 = true, _didIteratorError12 = false, _iteratorError12 = void 0;
|
|
602
|
+
try {
|
|
603
|
+
for (var _iterator12 = child[Symbol.iterator](), _step12; !(_iteratorNormalCompletion12 = (_step12 = _iterator12.next()).done); _iteratorNormalCompletion12 = true) {
|
|
604
|
+
var item = _step12.value;
|
|
605
|
+
walk(item, node);
|
|
606
|
+
}
|
|
607
|
+
} catch (err) {
|
|
608
|
+
_didIteratorError12 = true;
|
|
609
|
+
_iteratorError12 = err;
|
|
610
|
+
} finally {
|
|
611
|
+
try {
|
|
612
|
+
if (!_iteratorNormalCompletion12 && _iterator12.return != null) {
|
|
613
|
+
_iterator12.return();
|
|
614
|
+
}
|
|
615
|
+
} finally {
|
|
616
|
+
if (_didIteratorError12) {
|
|
617
|
+
throw _iteratorError12;
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
} else if (child && typeof child === "object") {
|
|
622
|
+
walk(child, node);
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
} catch (err) {
|
|
626
|
+
_didIteratorError2 = true;
|
|
627
|
+
_iteratorError2 = err;
|
|
628
|
+
} finally {
|
|
629
|
+
try {
|
|
630
|
+
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
|
631
|
+
_iterator2.return();
|
|
632
|
+
}
|
|
633
|
+
} finally {
|
|
634
|
+
if (_didIteratorError2) {
|
|
635
|
+
throw _iteratorError2;
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
walk(parsed.program, null);
|
|
641
|
+
function testValue(node) {
|
|
642
|
+
if (known.has(node)) return !!known.get(node);
|
|
643
|
+
if ((node === null || node === void 0 ? void 0 : node.type) === "UnaryExpression" && node.operator === "!") {
|
|
644
|
+
var inner = testValue(node.argument);
|
|
645
|
+
return inner === void 0 ? void 0 : !inner;
|
|
646
|
+
}
|
|
647
|
+
if ((node === null || node === void 0 ? void 0 : node.type) === "BinaryExpression" && (node.operator === "===" || node.operator === "!==")) {
|
|
648
|
+
var _node_right, _node_right1;
|
|
649
|
+
var left = known.has(node.left) ? known.get(node.left) : void 0;
|
|
650
|
+
var right = ((_node_right = node.right) === null || _node_right === void 0 ? void 0 : _node_right.type) === "Literal" ? node.right.value : void 0;
|
|
651
|
+
if (!known.has(node.left) || ((_node_right1 = node.right) === null || _node_right1 === void 0 ? void 0 : _node_right1.type) !== "Literal") return void 0;
|
|
652
|
+
return node.operator === "===" ? left === right : left !== right;
|
|
653
|
+
}
|
|
654
|
+
return void 0;
|
|
655
|
+
}
|
|
656
|
+
var dead = [];
|
|
657
|
+
(function foldWalk(node) {
|
|
658
|
+
if (!node || typeof node !== "object") return;
|
|
659
|
+
if (Array.isArray(node)) {
|
|
660
|
+
var _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = void 0;
|
|
661
|
+
try {
|
|
662
|
+
for (var _iterator2 = node[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
|
663
|
+
var child = _step2.value;
|
|
664
|
+
foldWalk(child);
|
|
665
|
+
}
|
|
666
|
+
} catch (err) {
|
|
667
|
+
_didIteratorError2 = true;
|
|
668
|
+
_iteratorError2 = err;
|
|
669
|
+
} finally {
|
|
670
|
+
try {
|
|
671
|
+
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
|
672
|
+
_iterator2.return();
|
|
673
|
+
}
|
|
674
|
+
} finally {
|
|
675
|
+
if (_didIteratorError2) {
|
|
676
|
+
throw _iteratorError2;
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
return;
|
|
681
|
+
}
|
|
682
|
+
if (node.type === "IfStatement" || node.type === "ConditionalExpression") {
|
|
683
|
+
var value = testValue(node.test);
|
|
684
|
+
if (value !== void 0) {
|
|
685
|
+
var kept = value ? node.consequent : node.alternate;
|
|
686
|
+
if (!kept) {
|
|
687
|
+
dead.push({
|
|
688
|
+
start: node.start,
|
|
689
|
+
end: node.end,
|
|
690
|
+
text: ";"
|
|
691
|
+
});
|
|
692
|
+
return;
|
|
693
|
+
}
|
|
694
|
+
dead.push({
|
|
695
|
+
start: node.start,
|
|
696
|
+
end: kept.start,
|
|
697
|
+
text: ""
|
|
698
|
+
});
|
|
699
|
+
if (kept.end < node.end) {
|
|
700
|
+
dead.push({
|
|
701
|
+
start: kept.end,
|
|
702
|
+
end: node.end,
|
|
703
|
+
text: ""
|
|
704
|
+
});
|
|
705
|
+
}
|
|
706
|
+
foldWalk(kept);
|
|
707
|
+
return;
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
var _iteratorNormalCompletion12 = true, _didIteratorError12 = false, _iteratorError12 = void 0;
|
|
711
|
+
try {
|
|
712
|
+
for (var _iterator12 = Object.keys(node)[Symbol.iterator](), _step12; !(_iteratorNormalCompletion12 = (_step12 = _iterator12.next()).done); _iteratorNormalCompletion12 = true) {
|
|
713
|
+
var k = _step12.value;
|
|
714
|
+
if (k === "start" || k === "end" || k === "loc" || k === "range" || k === "parent" || k === "comments") continue;
|
|
715
|
+
foldWalk(node[k]);
|
|
716
|
+
}
|
|
717
|
+
} catch (err) {
|
|
718
|
+
_didIteratorError12 = true;
|
|
719
|
+
_iteratorError12 = err;
|
|
720
|
+
} finally {
|
|
721
|
+
try {
|
|
722
|
+
if (!_iteratorNormalCompletion12 && _iterator12.return != null) {
|
|
723
|
+
_iterator12.return();
|
|
724
|
+
}
|
|
725
|
+
} finally {
|
|
726
|
+
if (_didIteratorError12) {
|
|
727
|
+
throw _iteratorError12;
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
})(parsed.program);
|
|
732
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
733
|
+
try {
|
|
734
|
+
for (var _iterator = dead[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
735
|
+
var range = _step.value;
|
|
736
|
+
ms.overwrite(range.start, range.end, range.text);
|
|
737
|
+
}
|
|
738
|
+
} catch (err) {
|
|
739
|
+
_didIteratorError = true;
|
|
740
|
+
_iteratorError = err;
|
|
741
|
+
} finally {
|
|
742
|
+
try {
|
|
743
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
744
|
+
_iterator.return();
|
|
745
|
+
}
|
|
746
|
+
} finally {
|
|
747
|
+
if (_didIteratorError) {
|
|
748
|
+
throw _iteratorError;
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;
|
|
753
|
+
try {
|
|
754
|
+
var _loop = function() {
|
|
755
|
+
var edit = _step1.value;
|
|
756
|
+
if (dead.some(function(d) {
|
|
757
|
+
return edit.start >= d.start && edit.end <= d.end;
|
|
758
|
+
})) return "continue";
|
|
759
|
+
ms.overwrite(edit.start, edit.end, edit.text);
|
|
760
|
+
};
|
|
761
|
+
for (var _iterator1 = edits[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) _loop();
|
|
762
|
+
} catch (err) {
|
|
763
|
+
_didIteratorError1 = true;
|
|
764
|
+
_iteratorError1 = err;
|
|
765
|
+
} finally {
|
|
766
|
+
try {
|
|
767
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
768
|
+
_iterator1.return();
|
|
769
|
+
}
|
|
770
|
+
} finally {
|
|
771
|
+
if (_didIteratorError1) {
|
|
772
|
+
throw _iteratorError1;
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
if (needsEnvImport) {
|
|
777
|
+
ms.prepend(`import { env as _$$_EXPO_ENV } from "expo/virtual/env";
|
|
817
778
|
`);
|
|
818
|
-
|
|
819
|
-
|
|
779
|
+
}
|
|
780
|
+
return ms.hasChanged() ? ms.toString() : code;
|
|
820
781
|
}
|
|
821
|
-
var GUARD_SPECIFIERS = /* @__PURE__ */new Set([
|
|
782
|
+
var GUARD_SPECIFIERS = /* @__PURE__ */ new Set([
|
|
783
|
+
"server-only",
|
|
784
|
+
"client-only",
|
|
785
|
+
"web-only"
|
|
786
|
+
]);
|
|
822
787
|
function applyEnvironmentGuard(code, filename) {
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
}
|
|
863
|
-
}
|
|
864
|
-
}
|
|
865
|
-
return changed ? ms.toString() : code;
|
|
788
|
+
var _parsed_errors, _parsed_program;
|
|
789
|
+
var parsed = parseSync(filename, code, { lang: langForFilename(filename) });
|
|
790
|
+
if (parsed === null || parsed === void 0 ? void 0 : (_parsed_errors = parsed.errors) === null || _parsed_errors === void 0 ? void 0 : _parsed_errors.length) {
|
|
791
|
+
throw new Error(`[vxrn/metro] Failed to parse ${filename} for environment guards: ${parsed.errors[0].message}`);
|
|
792
|
+
}
|
|
793
|
+
var body = parsed === null || parsed === void 0 ? void 0 : (_parsed_program = parsed.program) === null || _parsed_program === void 0 ? void 0 : _parsed_program.body;
|
|
794
|
+
if (!body) return code;
|
|
795
|
+
var ms = new MagicString(code);
|
|
796
|
+
var changed = false;
|
|
797
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
798
|
+
try {
|
|
799
|
+
for (var _iterator = body[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
800
|
+
var node = _step.value;
|
|
801
|
+
var _node_source;
|
|
802
|
+
if (node.type !== "ImportDeclaration") continue;
|
|
803
|
+
var source = (_node_source = node.source) === null || _node_source === void 0 ? void 0 : _node_source.value;
|
|
804
|
+
if (source === "native-only") {
|
|
805
|
+
ms.remove(node.start, node.end);
|
|
806
|
+
changed = true;
|
|
807
|
+
} else if (GUARD_SPECIFIERS.has(source)) {
|
|
808
|
+
ms.overwrite(node.start, node.end, `throw new Error(${JSON.stringify(`${source} cannot be imported in a native environment`)});`);
|
|
809
|
+
changed = true;
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
} catch (err) {
|
|
813
|
+
_didIteratorError = true;
|
|
814
|
+
_iteratorError = err;
|
|
815
|
+
} finally {
|
|
816
|
+
try {
|
|
817
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
818
|
+
_iterator.return();
|
|
819
|
+
}
|
|
820
|
+
} finally {
|
|
821
|
+
if (_didIteratorError) {
|
|
822
|
+
throw _iteratorError;
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
return changed ? ms.toString() : code;
|
|
866
827
|
}
|
|
867
828
|
function applyOneRouterMetro(code, filename, options) {
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
}
|
|
965
|
-
}
|
|
966
|
-
}
|
|
967
|
-
walk(parsed.program, parsed.program);
|
|
968
|
-
if (isMetroEntry && options.ONE_SETUP_FILE_NATIVE) {
|
|
969
|
-
var stmt = `
|
|
829
|
+
var _parsed_errors;
|
|
830
|
+
var isMetroEntry = filename.endsWith("metro-entry.js");
|
|
831
|
+
var isEntryCtx = filename.endsWith("metro-entry-ctx.js");
|
|
832
|
+
if (!isMetroEntry && !isEntryCtx) return code;
|
|
833
|
+
var parsed = parseSync(filename, code, { lang: langForFilename(filename) });
|
|
834
|
+
if (parsed === null || parsed === void 0 ? void 0 : (_parsed_errors = parsed.errors) === null || _parsed_errors === void 0 ? void 0 : _parsed_errors.length) {
|
|
835
|
+
throw new Error(`[vxrn/metro] Failed to parse ${filename} for one-router-metro: ${parsed.errors[0].message}`);
|
|
836
|
+
}
|
|
837
|
+
if (!(parsed === null || parsed === void 0 ? void 0 : parsed.program)) return code;
|
|
838
|
+
var ms = new MagicString(code);
|
|
839
|
+
var lastImportEnd = -1;
|
|
840
|
+
function replacementFor(key) {
|
|
841
|
+
if (key.startsWith("ONE_ROUTER_APP_ROOT_RELATIVE_TO_ENTRY")) {
|
|
842
|
+
return JSON.stringify(options.ONE_ROUTER_APP_ROOT_RELATIVE_TO_ENTRY);
|
|
843
|
+
}
|
|
844
|
+
if (key.startsWith("ONE_ROUTER_ROOT_FOLDER_NAME")) {
|
|
845
|
+
return JSON.stringify(options.ONE_ROUTER_ROOT_FOLDER_NAME);
|
|
846
|
+
}
|
|
847
|
+
if (key.startsWith("ONE_ROUTER_REQUIRE_CONTEXT_REGEX")) {
|
|
848
|
+
return `/${options.ONE_ROUTER_REQUIRE_CONTEXT_REGEX_STRING}/`;
|
|
849
|
+
}
|
|
850
|
+
if (key === "ONE_ROUTER_LINKING_CONFIG") {
|
|
851
|
+
var _options_ONE_ROUTER_LINKING_CONFIG;
|
|
852
|
+
return isMetroEntry ? JSON.stringify((_options_ONE_ROUTER_LINKING_CONFIG = options.ONE_ROUTER_LINKING_CONFIG) !== null && _options_ONE_ROUTER_LINKING_CONFIG !== void 0 ? _options_ONE_ROUTER_LINKING_CONFIG : null) : void 0;
|
|
853
|
+
}
|
|
854
|
+
if (key === "ONE_SETUP_FILE_NATIVE") {
|
|
855
|
+
return options.ONE_SETUP_FILE_NATIVE ? JSON.stringify(options.ONE_SETUP_FILE_NATIVE) : "undefined";
|
|
856
|
+
}
|
|
857
|
+
return void 0;
|
|
858
|
+
}
|
|
859
|
+
function walk(node, parent) {
|
|
860
|
+
var _node_object, _node_object_object, _node_object_property;
|
|
861
|
+
if (!node || typeof node !== "object") return;
|
|
862
|
+
if (node.type === "ImportDeclaration" && parent === parsed.program) {
|
|
863
|
+
lastImportEnd = Math.max(lastImportEnd, node.end);
|
|
864
|
+
}
|
|
865
|
+
if (node.type === "MemberExpression" && ((_node_object = node.object) === null || _node_object === void 0 ? void 0 : _node_object.type) === "MemberExpression" && !node.object.computed && ((_node_object_object = node.object.object) === null || _node_object_object === void 0 ? void 0 : _node_object_object.type) === "Identifier" && node.object.object.name === "process" && ((_node_object_property = node.object.property) === null || _node_object_property === void 0 ? void 0 : _node_object_property.type) === "Identifier" && node.object.property.name === "env") {
|
|
866
|
+
var _node_property, _node_property1;
|
|
867
|
+
var key = node.computed ? ((_node_property = node.property) === null || _node_property === void 0 ? void 0 : _node_property.type) === "Literal" && typeof node.property.value === "string" ? node.property.value : void 0 : ((_node_property1 = node.property) === null || _node_property1 === void 0 ? void 0 : _node_property1.type) === "Identifier" ? node.property.name : void 0;
|
|
868
|
+
var isAssignTarget = (parent === null || parent === void 0 ? void 0 : parent.type) === "AssignmentExpression" && parent.left === node;
|
|
869
|
+
if (key && !isAssignTarget) {
|
|
870
|
+
var replacement = replacementFor(key);
|
|
871
|
+
if (replacement !== void 0) {
|
|
872
|
+
ms.overwrite(node.start, node.end, replacement);
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
877
|
+
try {
|
|
878
|
+
for (var _iterator = Object.keys(node)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
879
|
+
var k = _step.value;
|
|
880
|
+
if (k === "start" || k === "end" || k === "loc" || k === "range" || k === "parent" || k === "comments") continue;
|
|
881
|
+
var child = node[k];
|
|
882
|
+
if (Array.isArray(child)) {
|
|
883
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;
|
|
884
|
+
try {
|
|
885
|
+
for (var _iterator1 = child[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
|
|
886
|
+
var item = _step1.value;
|
|
887
|
+
walk(item, node);
|
|
888
|
+
}
|
|
889
|
+
} catch (err) {
|
|
890
|
+
_didIteratorError1 = true;
|
|
891
|
+
_iteratorError1 = err;
|
|
892
|
+
} finally {
|
|
893
|
+
try {
|
|
894
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
895
|
+
_iterator1.return();
|
|
896
|
+
}
|
|
897
|
+
} finally {
|
|
898
|
+
if (_didIteratorError1) {
|
|
899
|
+
throw _iteratorError1;
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
} else if (child && typeof child === "object") {
|
|
904
|
+
walk(child, node);
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
} catch (err) {
|
|
908
|
+
_didIteratorError = true;
|
|
909
|
+
_iteratorError = err;
|
|
910
|
+
} finally {
|
|
911
|
+
try {
|
|
912
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
913
|
+
_iterator.return();
|
|
914
|
+
}
|
|
915
|
+
} finally {
|
|
916
|
+
if (_didIteratorError) {
|
|
917
|
+
throw _iteratorError;
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
walk(parsed.program, parsed.program);
|
|
923
|
+
if (isMetroEntry && options.ONE_SETUP_FILE_NATIVE) {
|
|
924
|
+
var stmt = `
|
|
970
925
|
import ${JSON.stringify(options.ONE_SETUP_FILE_NATIVE)};`;
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
926
|
+
if (lastImportEnd >= 0) {
|
|
927
|
+
ms.appendRight(lastImportEnd, stmt);
|
|
928
|
+
} else {
|
|
929
|
+
ms.prepend(`${stmt}
|
|
975
930
|
`);
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
return ms.toString();
|
|
979
934
|
}
|
|
980
935
|
function collectPatternNames(pattern, names) {
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
} else if (pattern.type === "RestElement") {
|
|
1033
|
-
collectPatternNames(pattern.argument, names);
|
|
1034
|
-
}
|
|
936
|
+
if (!pattern) return;
|
|
937
|
+
if (pattern.type === "Identifier") {
|
|
938
|
+
names.add(pattern.name);
|
|
939
|
+
} else if (pattern.type === "AssignmentPattern") {
|
|
940
|
+
collectPatternNames(pattern.left, names);
|
|
941
|
+
} else if (pattern.type === "ObjectPattern") {
|
|
942
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
943
|
+
try {
|
|
944
|
+
for (var _iterator = (pattern.properties || [])[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
945
|
+
var prop = _step.value;
|
|
946
|
+
if (prop.type === "Property") collectPatternNames(prop.value, names);
|
|
947
|
+
else if (prop.type === "RestElement") collectPatternNames(prop.argument, names);
|
|
948
|
+
}
|
|
949
|
+
} catch (err) {
|
|
950
|
+
_didIteratorError = true;
|
|
951
|
+
_iteratorError = err;
|
|
952
|
+
} finally {
|
|
953
|
+
try {
|
|
954
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
955
|
+
_iterator.return();
|
|
956
|
+
}
|
|
957
|
+
} finally {
|
|
958
|
+
if (_didIteratorError) {
|
|
959
|
+
throw _iteratorError;
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
} else if (pattern.type === "ArrayPattern") {
|
|
964
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;
|
|
965
|
+
try {
|
|
966
|
+
for (var _iterator1 = (pattern.elements || [])[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
|
|
967
|
+
var elem = _step1.value;
|
|
968
|
+
if (elem) collectPatternNames(elem, names);
|
|
969
|
+
}
|
|
970
|
+
} catch (err) {
|
|
971
|
+
_didIteratorError1 = true;
|
|
972
|
+
_iteratorError1 = err;
|
|
973
|
+
} finally {
|
|
974
|
+
try {
|
|
975
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
976
|
+
_iterator1.return();
|
|
977
|
+
}
|
|
978
|
+
} finally {
|
|
979
|
+
if (_didIteratorError1) {
|
|
980
|
+
throw _iteratorError1;
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
} else if (pattern.type === "RestElement") {
|
|
985
|
+
collectPatternNames(pattern.argument, names);
|
|
986
|
+
}
|
|
1035
987
|
}
|
|
1036
988
|
function collectHoistedBindings(node, names) {
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
throw _iteratorError1;
|
|
1116
|
-
}
|
|
1117
|
-
}
|
|
1118
|
-
}
|
|
1119
|
-
}
|
|
1120
|
-
traverse(node);
|
|
989
|
+
function traverse(n) {
|
|
990
|
+
if (!n || typeof n !== "object") return;
|
|
991
|
+
if (n === node) {} else if (n.type === "FunctionDeclaration" || n.type === "FunctionExpression" || n.type === "ArrowFunctionExpression") {
|
|
992
|
+
var _n_id;
|
|
993
|
+
if (n.type === "FunctionDeclaration" && ((_n_id = n.id) === null || _n_id === void 0 ? void 0 : _n_id.name)) {
|
|
994
|
+
names.add(n.id.name);
|
|
995
|
+
}
|
|
996
|
+
return;
|
|
997
|
+
}
|
|
998
|
+
if (n.type === "VariableDeclaration" && n.kind === "var") {
|
|
999
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
1000
|
+
try {
|
|
1001
|
+
for (var _iterator = (n.declarations || [])[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
1002
|
+
var decl = _step.value;
|
|
1003
|
+
collectPatternNames(decl.id, names);
|
|
1004
|
+
}
|
|
1005
|
+
} catch (err) {
|
|
1006
|
+
_didIteratorError = true;
|
|
1007
|
+
_iteratorError = err;
|
|
1008
|
+
} finally {
|
|
1009
|
+
try {
|
|
1010
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
1011
|
+
_iterator.return();
|
|
1012
|
+
}
|
|
1013
|
+
} finally {
|
|
1014
|
+
if (_didIteratorError) {
|
|
1015
|
+
throw _iteratorError;
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;
|
|
1021
|
+
try {
|
|
1022
|
+
for (var _iterator1 = Object.keys(n)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
|
|
1023
|
+
var key = _step1.value;
|
|
1024
|
+
if (key === "start" || key === "end" || key === "loc" || key === "range" || key === "parent" || key === "comments") continue;
|
|
1025
|
+
var child = n[key];
|
|
1026
|
+
if (Array.isArray(child)) {
|
|
1027
|
+
var _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = void 0;
|
|
1028
|
+
try {
|
|
1029
|
+
for (var _iterator2 = child[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
|
1030
|
+
var item = _step2.value;
|
|
1031
|
+
traverse(item);
|
|
1032
|
+
}
|
|
1033
|
+
} catch (err) {
|
|
1034
|
+
_didIteratorError2 = true;
|
|
1035
|
+
_iteratorError2 = err;
|
|
1036
|
+
} finally {
|
|
1037
|
+
try {
|
|
1038
|
+
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
|
1039
|
+
_iterator2.return();
|
|
1040
|
+
}
|
|
1041
|
+
} finally {
|
|
1042
|
+
if (_didIteratorError2) {
|
|
1043
|
+
throw _iteratorError2;
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
} else if (child && typeof child === "object") {
|
|
1048
|
+
traverse(child);
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
} catch (err) {
|
|
1052
|
+
_didIteratorError1 = true;
|
|
1053
|
+
_iteratorError1 = err;
|
|
1054
|
+
} finally {
|
|
1055
|
+
try {
|
|
1056
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
1057
|
+
_iterator1.return();
|
|
1058
|
+
}
|
|
1059
|
+
} finally {
|
|
1060
|
+
if (_didIteratorError1) {
|
|
1061
|
+
throw _iteratorError1;
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
traverse(node);
|
|
1121
1067
|
}
|
|
1122
1068
|
function collectBlockBindings(statements, names) {
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
throw _iteratorError;
|
|
1172
|
-
}
|
|
1173
|
-
}
|
|
1174
|
-
}
|
|
1069
|
+
if (!Array.isArray(statements)) return;
|
|
1070
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
1071
|
+
try {
|
|
1072
|
+
for (var _iterator = statements[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
1073
|
+
var stmt = _step.value;
|
|
1074
|
+
var _stmt_id, _stmt_id1;
|
|
1075
|
+
if (!stmt) continue;
|
|
1076
|
+
if (stmt.type === "VariableDeclaration" && stmt.kind !== "var") {
|
|
1077
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;
|
|
1078
|
+
try {
|
|
1079
|
+
for (var _iterator1 = (stmt.declarations || [])[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
|
|
1080
|
+
var decl = _step1.value;
|
|
1081
|
+
collectPatternNames(decl.id, names);
|
|
1082
|
+
}
|
|
1083
|
+
} catch (err) {
|
|
1084
|
+
_didIteratorError1 = true;
|
|
1085
|
+
_iteratorError1 = err;
|
|
1086
|
+
} finally {
|
|
1087
|
+
try {
|
|
1088
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
1089
|
+
_iterator1.return();
|
|
1090
|
+
}
|
|
1091
|
+
} finally {
|
|
1092
|
+
if (_didIteratorError1) {
|
|
1093
|
+
throw _iteratorError1;
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
} else if (stmt.type === "ClassDeclaration" && ((_stmt_id = stmt.id) === null || _stmt_id === void 0 ? void 0 : _stmt_id.name)) {
|
|
1098
|
+
names.add(stmt.id.name);
|
|
1099
|
+
} else if (stmt.type === "FunctionDeclaration" && ((_stmt_id1 = stmt.id) === null || _stmt_id1 === void 0 ? void 0 : _stmt_id1.name)) {
|
|
1100
|
+
names.add(stmt.id.name);
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
} catch (err) {
|
|
1104
|
+
_didIteratorError = true;
|
|
1105
|
+
_iteratorError = err;
|
|
1106
|
+
} finally {
|
|
1107
|
+
try {
|
|
1108
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
1109
|
+
_iterator.return();
|
|
1110
|
+
}
|
|
1111
|
+
} finally {
|
|
1112
|
+
if (_didIteratorError) {
|
|
1113
|
+
throw _iteratorError;
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1175
1117
|
}
|
|
1176
|
-
var ScopeTracker = /* @__PURE__ */
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
}
|
|
1118
|
+
var ScopeTracker = /* @__PURE__ */ (function() {
|
|
1119
|
+
"use strict";
|
|
1120
|
+
function ScopeTracker2() {
|
|
1121
|
+
_class_call_check(this, ScopeTracker2);
|
|
1122
|
+
_define_property(this, "stack", [/* @__PURE__ */ new Set()]);
|
|
1123
|
+
}
|
|
1124
|
+
_create_class(ScopeTracker2, [
|
|
1125
|
+
{
|
|
1126
|
+
key: "enter",
|
|
1127
|
+
value: function enter(initialBindings) {
|
|
1128
|
+
this.stack.push(new Set(initialBindings));
|
|
1129
|
+
}
|
|
1130
|
+
},
|
|
1131
|
+
{
|
|
1132
|
+
key: "exit",
|
|
1133
|
+
value: function exit() {
|
|
1134
|
+
if (this.stack.length > 1) {
|
|
1135
|
+
this.stack.pop();
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
},
|
|
1139
|
+
{
|
|
1140
|
+
key: "add",
|
|
1141
|
+
value: function add(name) {
|
|
1142
|
+
this.stack[this.stack.length - 1].add(name);
|
|
1143
|
+
}
|
|
1144
|
+
},
|
|
1145
|
+
{
|
|
1146
|
+
key: "currentScope",
|
|
1147
|
+
value: function currentScope() {
|
|
1148
|
+
return this.stack[this.stack.length - 1];
|
|
1149
|
+
}
|
|
1150
|
+
},
|
|
1151
|
+
{
|
|
1152
|
+
key: "addPattern",
|
|
1153
|
+
value: function addPattern(pattern) {
|
|
1154
|
+
collectPatternNames(pattern, this.currentScope());
|
|
1155
|
+
}
|
|
1156
|
+
},
|
|
1157
|
+
{
|
|
1158
|
+
key: "isShadowed",
|
|
1159
|
+
value: function isShadowed(name) {
|
|
1160
|
+
for (var i = this.stack.length - 1; i >= 0; i--) {
|
|
1161
|
+
if (this.stack[i].has(name)) return true;
|
|
1162
|
+
}
|
|
1163
|
+
return false;
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
]);
|
|
1167
|
+
return ScopeTracker2;
|
|
1168
|
+
})();
|
|
1221
1169
|
function getCacheKey() {
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
return hash.digest("hex");
|
|
1170
|
+
var config = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, opts = arguments.length > 1 ? arguments[1] : void 0;
|
|
1171
|
+
var hash = crypto.createHash("sha256");
|
|
1172
|
+
hash.update("metroNativeWorker");
|
|
1173
|
+
hash.update(WORKER_CACHE_KEY_VERSION);
|
|
1174
|
+
if (config.globalPrefix) {
|
|
1175
|
+
hash.update(config.globalPrefix);
|
|
1176
|
+
}
|
|
1177
|
+
if (config.unstable_dependencyMapReservedName) {
|
|
1178
|
+
hash.update(config.unstable_dependencyMapReservedName);
|
|
1179
|
+
}
|
|
1180
|
+
if (config.minifierPath) {
|
|
1181
|
+
hash.update(config.minifierPath);
|
|
1182
|
+
}
|
|
1183
|
+
if (opts === null || opts === void 0 ? void 0 : opts.projectRoot) {
|
|
1184
|
+
hash.update(opts.projectRoot);
|
|
1185
|
+
}
|
|
1186
|
+
return hash.digest("hex");
|
|
1240
1187
|
}
|
|
1241
1188
|
function convertSourceMapToMetroRawMappings(composedMap) {
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1189
|
+
if (!composedMap) return [];
|
|
1190
|
+
var tracer = new TraceMap(composedMap);
|
|
1191
|
+
var rawMappings = [];
|
|
1192
|
+
eachMapping(tracer, function(m) {
|
|
1193
|
+
if (m.originalLine == null) {
|
|
1194
|
+
rawMappings.push([m.generatedLine, m.generatedColumn]);
|
|
1195
|
+
} else if (m.name == null) {
|
|
1196
|
+
rawMappings.push([
|
|
1197
|
+
m.generatedLine,
|
|
1198
|
+
m.generatedColumn,
|
|
1199
|
+
m.originalLine,
|
|
1200
|
+
m.originalColumn
|
|
1201
|
+
]);
|
|
1202
|
+
} else {
|
|
1203
|
+
rawMappings.push([
|
|
1204
|
+
m.generatedLine,
|
|
1205
|
+
m.generatedColumn,
|
|
1206
|
+
m.originalLine,
|
|
1207
|
+
m.originalColumn,
|
|
1208
|
+
m.name
|
|
1209
|
+
]);
|
|
1210
|
+
}
|
|
1211
|
+
});
|
|
1212
|
+
rawMappings.sort(function(a, b) {
|
|
1213
|
+
if (a[0] !== b[0]) return a[0] - b[0];
|
|
1214
|
+
return a[1] - b[1];
|
|
1215
|
+
});
|
|
1216
|
+
var deduped = [];
|
|
1217
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
1218
|
+
try {
|
|
1219
|
+
for (var _iterator = rawMappings[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
1220
|
+
var mapping = _step.value;
|
|
1221
|
+
var prev = deduped[deduped.length - 1];
|
|
1222
|
+
if (prev && prev[0] === mapping[0] && prev[1] === mapping[1]) {
|
|
1223
|
+
continue;
|
|
1224
|
+
}
|
|
1225
|
+
deduped.push(mapping);
|
|
1226
|
+
}
|
|
1227
|
+
} catch (err) {
|
|
1228
|
+
_didIteratorError = true;
|
|
1229
|
+
_iteratorError = err;
|
|
1230
|
+
} finally {
|
|
1231
|
+
try {
|
|
1232
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
1233
|
+
_iterator.return();
|
|
1234
|
+
}
|
|
1235
|
+
} finally {
|
|
1236
|
+
if (_didIteratorError) {
|
|
1237
|
+
throw _iteratorError;
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
1241
|
+
return deduped;
|
|
1286
1242
|
}
|
|
1287
1243
|
function countLinesAndTerminateMap(code) {
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
map: [...map]
|
|
1329
|
-
};
|
|
1244
|
+
var map = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
|
|
1245
|
+
var NEWLINE = /\r\n?|\n|\u2028|\u2029/g;
|
|
1246
|
+
var lineCount = 1;
|
|
1247
|
+
var lastLineStart = 0;
|
|
1248
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
1249
|
+
try {
|
|
1250
|
+
for (var _iterator = code.matchAll(NEWLINE)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
1251
|
+
var match = _step.value;
|
|
1252
|
+
lineCount++;
|
|
1253
|
+
lastLineStart = match.index + match[0].length;
|
|
1254
|
+
}
|
|
1255
|
+
} catch (err) {
|
|
1256
|
+
_didIteratorError = true;
|
|
1257
|
+
_iteratorError = err;
|
|
1258
|
+
} finally {
|
|
1259
|
+
try {
|
|
1260
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
1261
|
+
_iterator.return();
|
|
1262
|
+
}
|
|
1263
|
+
} finally {
|
|
1264
|
+
if (_didIteratorError) {
|
|
1265
|
+
throw _iteratorError;
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
var lastLineLength = code.length - lastLineStart;
|
|
1270
|
+
var lastLineIndex1Based = lineCount;
|
|
1271
|
+
var lastLineNextColumn0Based = lastLineLength;
|
|
1272
|
+
var lastMapping = map[map.length - 1];
|
|
1273
|
+
var terminatingMapping = [lastLineIndex1Based, lastLineNextColumn0Based];
|
|
1274
|
+
if (!lastMapping || lastMapping[0] !== terminatingMapping[0] || lastMapping[1] !== terminatingMapping[1]) {
|
|
1275
|
+
return {
|
|
1276
|
+
lineCount,
|
|
1277
|
+
map: map.concat([terminatingMapping])
|
|
1278
|
+
};
|
|
1279
|
+
}
|
|
1280
|
+
return {
|
|
1281
|
+
lineCount,
|
|
1282
|
+
map: [...map]
|
|
1283
|
+
};
|
|
1330
1284
|
}
|
|
1331
1285
|
function wrapJson(source, options) {
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1286
|
+
var globalPrefix = (options === null || options === void 0 ? void 0 : options.globalPrefix) || "";
|
|
1287
|
+
var factory = [
|
|
1288
|
+
"function (global, require, _importDefaultUnused, _importAllUnused, module, exports, _dependencyMapUnused) {",
|
|
1289
|
+
` module.exports = ${source};`,
|
|
1290
|
+
"}"
|
|
1291
|
+
].join("\n");
|
|
1292
|
+
if ((options === null || options === void 0 ? void 0 : options.moduleId) !== void 0) {
|
|
1293
|
+
var depIds = options.dependencyIds ? JSON.stringify(options.dependencyIds) : "[]";
|
|
1294
|
+
return `${globalPrefix}__d(${factory}, ${JSON.stringify(options.moduleId)}, ${depIds});`;
|
|
1295
|
+
}
|
|
1296
|
+
return `${globalPrefix}__d(${factory});`;
|
|
1339
1297
|
}
|
|
1340
1298
|
function wrapModule(code, options) {
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1299
|
+
var globalPrefix = (options === null || options === void 0 ? void 0 : options.globalPrefix) || "";
|
|
1300
|
+
var depMap = (options === null || options === void 0 ? void 0 : options.dependencyMapName) || "_dependencyMap";
|
|
1301
|
+
var header = `function (global, _$$_REQUIRE, _$$_IMPORT_DEFAULT, _$$_IMPORT_ALL, module, exports, ${depMap}) {`;
|
|
1302
|
+
var requireAlias = (options === null || options === void 0 ? void 0 : options.requireAlias) !== false ? "var require = _$$_REQUIRE;\n" : "";
|
|
1303
|
+
var footer = `}`;
|
|
1304
|
+
if ((options === null || options === void 0 ? void 0 : options.moduleId) !== void 0) {
|
|
1305
|
+
var depIds = options.dependencyIds ? JSON.stringify(options.dependencyIds) : "[]";
|
|
1306
|
+
return `${globalPrefix}__d(${header}
|
|
1349
1307
|
${requireAlias}${code}
|
|
1350
1308
|
${footer}, ${JSON.stringify(options.moduleId)}, ${depIds});`;
|
|
1351
|
-
|
|
1352
|
-
|
|
1309
|
+
}
|
|
1310
|
+
return `${globalPrefix}__d(${header}
|
|
1353
1311
|
${requireAlias}${code}
|
|
1354
1312
|
${footer});`;
|
|
1355
1313
|
}
|
|
1356
1314
|
function getDependencyKey(name, isESM) {
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1315
|
+
var asyncType = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : null, contextParams = arguments.length > 3 ? arguments[3] : void 0;
|
|
1316
|
+
var key = `${name}\0${isESM ? "import" : "require"}`;
|
|
1317
|
+
if (asyncType != null) {
|
|
1318
|
+
key += `\0${asyncType}`;
|
|
1319
|
+
}
|
|
1320
|
+
if (contextParams) {
|
|
1321
|
+
key += [
|
|
1322
|
+
"",
|
|
1323
|
+
"context",
|
|
1324
|
+
String(contextParams.recursive),
|
|
1325
|
+
String(contextParams.filter.pattern),
|
|
1326
|
+
String(contextParams.filter.flags),
|
|
1327
|
+
contextParams.mode
|
|
1328
|
+
].join("\0");
|
|
1329
|
+
}
|
|
1330
|
+
return key;
|
|
1367
1331
|
}
|
|
1368
1332
|
function rewriteDependencyCalls(code, dependencies) {
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
}
|
|
1626
|
-
if (pushedScope) {
|
|
1627
|
-
scopeTracker.exit();
|
|
1628
|
-
}
|
|
1629
|
-
}
|
|
1630
|
-
walk(parsed.program);
|
|
1631
|
-
var resultString = ms.toString();
|
|
1632
|
-
var map = ms.generateMap({
|
|
1633
|
-
source: filename,
|
|
1634
|
-
hires: true,
|
|
1635
|
-
includeContent: true
|
|
1636
|
-
});
|
|
1637
|
-
return {
|
|
1638
|
-
code: resultString,
|
|
1639
|
-
map,
|
|
1640
|
-
toString() {
|
|
1641
|
-
return resultString;
|
|
1642
|
-
}
|
|
1643
|
-
};
|
|
1333
|
+
var depMapName = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "_dependencyMap", filename = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : "module.js", asyncRequirePath = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : "metro-runtime/src/modules/asyncRequire";
|
|
1334
|
+
var _parsed_errors;
|
|
1335
|
+
var ms = new MagicString(code);
|
|
1336
|
+
var emptyResult = {
|
|
1337
|
+
code,
|
|
1338
|
+
map: ms.generateMap({
|
|
1339
|
+
source: filename,
|
|
1340
|
+
hires: true,
|
|
1341
|
+
includeContent: true
|
|
1342
|
+
}),
|
|
1343
|
+
toString() {
|
|
1344
|
+
return code;
|
|
1345
|
+
}
|
|
1346
|
+
};
|
|
1347
|
+
if (dependencies.length === 0) return emptyResult;
|
|
1348
|
+
var parsed;
|
|
1349
|
+
try {
|
|
1350
|
+
parsed = parseSync(filename, code, { lang: langForFilename(filename) });
|
|
1351
|
+
} catch (err) {
|
|
1352
|
+
throw new Error(`[vxrn/metro] Failed to parse ${filename} for dependency rewriting: ${err.message || err}`);
|
|
1353
|
+
}
|
|
1354
|
+
if (parsed === null || parsed === void 0 ? void 0 : (_parsed_errors = parsed.errors) === null || _parsed_errors === void 0 ? void 0 : _parsed_errors.length) {
|
|
1355
|
+
throw new Error(`[vxrn/metro] Failed to parse ${filename} for dependency rewriting: ${parsed.errors[0].message}`);
|
|
1356
|
+
}
|
|
1357
|
+
if (!(parsed === null || parsed === void 0 ? void 0 : parsed.program)) return emptyResult;
|
|
1358
|
+
var contextLiteralBindings = collectModuleLiteralBindings(parsed.program);
|
|
1359
|
+
var scopeTracker = new ScopeTracker();
|
|
1360
|
+
collectHoistedBindings(parsed.program, scopeTracker.currentScope());
|
|
1361
|
+
collectBlockBindings(parsed.program.body, scopeTracker.currentScope());
|
|
1362
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
1363
|
+
try {
|
|
1364
|
+
for (var _iterator = (parsed.program.body || [])[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
1365
|
+
var stmt = _step.value;
|
|
1366
|
+
if (stmt.type === "ImportDeclaration") {
|
|
1367
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;
|
|
1368
|
+
try {
|
|
1369
|
+
for (var _iterator1 = (stmt.specifiers || [])[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
|
|
1370
|
+
var spec = _step1.value;
|
|
1371
|
+
var _spec_local;
|
|
1372
|
+
if ((_spec_local = spec.local) === null || _spec_local === void 0 ? void 0 : _spec_local.name) {
|
|
1373
|
+
scopeTracker.add(spec.local.name);
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
} catch (err) {
|
|
1377
|
+
_didIteratorError1 = true;
|
|
1378
|
+
_iteratorError1 = err;
|
|
1379
|
+
} finally {
|
|
1380
|
+
try {
|
|
1381
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
1382
|
+
_iterator1.return();
|
|
1383
|
+
}
|
|
1384
|
+
} finally {
|
|
1385
|
+
if (_didIteratorError1) {
|
|
1386
|
+
throw _iteratorError1;
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
} catch (err) {
|
|
1393
|
+
_didIteratorError = true;
|
|
1394
|
+
_iteratorError = err;
|
|
1395
|
+
} finally {
|
|
1396
|
+
try {
|
|
1397
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
1398
|
+
_iterator.return();
|
|
1399
|
+
}
|
|
1400
|
+
} finally {
|
|
1401
|
+
if (_didIteratorError) {
|
|
1402
|
+
throw _iteratorError;
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
}
|
|
1406
|
+
function walk(node) {
|
|
1407
|
+
var _node_source, _node_callee, _node_arguments, _node_callee1, _node_callee_object, _node_callee_property, _node_arguments1;
|
|
1408
|
+
if (!node || typeof node !== "object") return;
|
|
1409
|
+
var pushedScope = false;
|
|
1410
|
+
if (node.type === "FunctionDeclaration" || node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression") {
|
|
1411
|
+
var _node_id;
|
|
1412
|
+
scopeTracker.enter();
|
|
1413
|
+
pushedScope = true;
|
|
1414
|
+
var _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = void 0;
|
|
1415
|
+
try {
|
|
1416
|
+
for (var _iterator2 = (node.params || [])[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
|
1417
|
+
var param = _step2.value;
|
|
1418
|
+
scopeTracker.addPattern(param);
|
|
1419
|
+
}
|
|
1420
|
+
} catch (err) {
|
|
1421
|
+
_didIteratorError2 = true;
|
|
1422
|
+
_iteratorError2 = err;
|
|
1423
|
+
} finally {
|
|
1424
|
+
try {
|
|
1425
|
+
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
|
1426
|
+
_iterator2.return();
|
|
1427
|
+
}
|
|
1428
|
+
} finally {
|
|
1429
|
+
if (_didIteratorError2) {
|
|
1430
|
+
throw _iteratorError2;
|
|
1431
|
+
}
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1434
|
+
if (node.type === "FunctionExpression" && ((_node_id = node.id) === null || _node_id === void 0 ? void 0 : _node_id.name)) {
|
|
1435
|
+
scopeTracker.add(node.id.name);
|
|
1436
|
+
}
|
|
1437
|
+
if (node.body) {
|
|
1438
|
+
collectHoistedBindings(node.body, scopeTracker.currentScope());
|
|
1439
|
+
}
|
|
1440
|
+
} else if (node.type === "BlockStatement") {
|
|
1441
|
+
scopeTracker.enter();
|
|
1442
|
+
pushedScope = true;
|
|
1443
|
+
collectBlockBindings(node.body, scopeTracker.currentScope());
|
|
1444
|
+
} else if (node.type === "CatchClause") {
|
|
1445
|
+
scopeTracker.enter();
|
|
1446
|
+
pushedScope = true;
|
|
1447
|
+
if (node.param) {
|
|
1448
|
+
scopeTracker.addPattern(node.param);
|
|
1449
|
+
}
|
|
1450
|
+
} else if (node.type === "ForStatement" || node.type === "ForInStatement" || node.type === "ForOfStatement") {
|
|
1451
|
+
var decl = node.type === "ForStatement" ? node.init : node.left;
|
|
1452
|
+
if ((decl === null || decl === void 0 ? void 0 : decl.type) === "VariableDeclaration" && decl.kind !== "var") {
|
|
1453
|
+
scopeTracker.enter();
|
|
1454
|
+
pushedScope = true;
|
|
1455
|
+
var _iteratorNormalCompletion12 = true, _didIteratorError12 = false, _iteratorError12 = void 0;
|
|
1456
|
+
try {
|
|
1457
|
+
for (var _iterator12 = (decl.declarations || [])[Symbol.iterator](), _step12; !(_iteratorNormalCompletion12 = (_step12 = _iterator12.next()).done); _iteratorNormalCompletion12 = true) {
|
|
1458
|
+
var d = _step12.value;
|
|
1459
|
+
scopeTracker.addPattern(d.id);
|
|
1460
|
+
}
|
|
1461
|
+
} catch (err) {
|
|
1462
|
+
_didIteratorError12 = true;
|
|
1463
|
+
_iteratorError12 = err;
|
|
1464
|
+
} finally {
|
|
1465
|
+
try {
|
|
1466
|
+
if (!_iteratorNormalCompletion12 && _iterator12.return != null) {
|
|
1467
|
+
_iterator12.return();
|
|
1468
|
+
}
|
|
1469
|
+
} finally {
|
|
1470
|
+
if (_didIteratorError12) {
|
|
1471
|
+
throw _iteratorError12;
|
|
1472
|
+
}
|
|
1473
|
+
}
|
|
1474
|
+
}
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
1477
|
+
if (node.type === "ImportExpression" && ((_node_source = node.source) === null || _node_source === void 0 ? void 0 : _node_source.type) === "Literal" && typeof node.source.value === "string") {
|
|
1478
|
+
var depName = node.source.value;
|
|
1479
|
+
var depKey = getDependencyKey(depName, true, "async");
|
|
1480
|
+
var dep = dependencies.find(function(d2) {
|
|
1481
|
+
return d2.data.key === depKey;
|
|
1482
|
+
}) || dependencies.find(function(d2) {
|
|
1483
|
+
return d2.name === depName && d2.data.asyncType === "async";
|
|
1484
|
+
});
|
|
1485
|
+
var asyncKey = getDependencyKey(asyncRequirePath, false, null);
|
|
1486
|
+
var asyncDep = dependencies.find(function(d2) {
|
|
1487
|
+
return d2.data.key === asyncKey;
|
|
1488
|
+
}) || dependencies.find(function(d2) {
|
|
1489
|
+
return d2.name === asyncRequirePath && d2.data.asyncType == null;
|
|
1490
|
+
});
|
|
1491
|
+
if (dep && asyncDep) {
|
|
1492
|
+
var _dep_data_index, _asyncDep_data_index;
|
|
1493
|
+
var depIndex = (_dep_data_index = dep.data.index) !== null && _dep_data_index !== void 0 ? _dep_data_index : dependencies.indexOf(dep);
|
|
1494
|
+
var asyncIndex = (_asyncDep_data_index = asyncDep.data.index) !== null && _asyncDep_data_index !== void 0 ? _asyncDep_data_index : dependencies.indexOf(asyncDep);
|
|
1495
|
+
ms.overwrite(node.start, node.end, `require(${depMapName}[${asyncIndex}], ${JSON.stringify(asyncRequirePath)})(${depMapName}[${depIndex}], ${depMapName}.paths, ${JSON.stringify(depName)})`);
|
|
1496
|
+
}
|
|
1497
|
+
} else if (node.type === "CallExpression" && ((_node_callee = node.callee) === null || _node_callee === void 0 ? void 0 : _node_callee.type) === "Identifier" && node.callee.name === "require" && !scopeTracker.isShadowed("require") && ((_node_arguments = node.arguments) === null || _node_arguments === void 0 ? void 0 : _node_arguments.length) >= 1) {
|
|
1498
|
+
var arg = node.arguments[0];
|
|
1499
|
+
if (arg.type === "Literal" && typeof arg.value === "string") {
|
|
1500
|
+
var depKey1 = getDependencyKey(arg.value, false, null);
|
|
1501
|
+
var dep1 = dependencies.find(function(d2) {
|
|
1502
|
+
return d2.data.key === depKey1;
|
|
1503
|
+
}) || dependencies.find(function(d2) {
|
|
1504
|
+
return d2.name === arg.value && d2.data.asyncType == null;
|
|
1505
|
+
});
|
|
1506
|
+
if (dep1) {
|
|
1507
|
+
var _dep_data_index1;
|
|
1508
|
+
var index = (_dep_data_index1 = dep1.data.index) !== null && _dep_data_index1 !== void 0 ? _dep_data_index1 : dependencies.indexOf(dep1);
|
|
1509
|
+
ms.overwrite(arg.start, arg.end, `${depMapName}[${index}], ${JSON.stringify(arg.value)}`);
|
|
1510
|
+
}
|
|
1511
|
+
}
|
|
1512
|
+
} else if (node.type === "CallExpression" && ((_node_callee1 = node.callee) === null || _node_callee1 === void 0 ? void 0 : _node_callee1.type) === "MemberExpression" && !node.callee.computed && ((_node_callee_object = node.callee.object) === null || _node_callee_object === void 0 ? void 0 : _node_callee_object.type) === "Identifier" && node.callee.object.name === "require" && ((_node_callee_property = node.callee.property) === null || _node_callee_property === void 0 ? void 0 : _node_callee_property.type) === "Identifier" && node.callee.property.name === "context" && !scopeTracker.isShadowed("require") && ((_node_arguments1 = node.arguments) === null || _node_arguments1 === void 0 ? void 0 : _node_arguments1.length) >= 1) {
|
|
1513
|
+
var _node_arguments_;
|
|
1514
|
+
var arg1 = ((_node_arguments_ = node.arguments[0]) === null || _node_arguments_ === void 0 ? void 0 : _node_arguments_.type) === "Identifier" ? contextLiteralBindings.get(node.arguments[0].name) : node.arguments[0];
|
|
1515
|
+
if ((arg1 === null || arg1 === void 0 ? void 0 : arg1.type) === "Literal" && typeof arg1.value === "string") {
|
|
1516
|
+
var dep2 = dependencies.find(function(d2) {
|
|
1517
|
+
return d2.name === arg1.value && d2.data.contextParams != null;
|
|
1518
|
+
});
|
|
1519
|
+
if (dep2) {
|
|
1520
|
+
var _dep_data_index2;
|
|
1521
|
+
var index1 = (_dep_data_index2 = dep2.data.index) !== null && _dep_data_index2 !== void 0 ? _dep_data_index2 : dependencies.indexOf(dep2);
|
|
1522
|
+
ms.overwrite(node.start, node.end, `require(${depMapName}[${index1}], ${JSON.stringify(arg1.value)})`);
|
|
1523
|
+
}
|
|
1524
|
+
}
|
|
1525
|
+
}
|
|
1526
|
+
var _iteratorNormalCompletion22 = true, _didIteratorError22 = false, _iteratorError22 = void 0;
|
|
1527
|
+
try {
|
|
1528
|
+
for (var _iterator22 = Object.keys(node)[Symbol.iterator](), _step22; !(_iteratorNormalCompletion22 = (_step22 = _iterator22.next()).done); _iteratorNormalCompletion22 = true) {
|
|
1529
|
+
var key = _step22.value;
|
|
1530
|
+
if (key === "start" || key === "end" || key === "loc" || key === "range" || key === "parent" || key === "comments") continue;
|
|
1531
|
+
var child = node[key];
|
|
1532
|
+
if (Array.isArray(child)) {
|
|
1533
|
+
var _iteratorNormalCompletion3 = true, _didIteratorError3 = false, _iteratorError3 = void 0;
|
|
1534
|
+
try {
|
|
1535
|
+
for (var _iterator3 = child[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
|
|
1536
|
+
var item = _step3.value;
|
|
1537
|
+
walk(item);
|
|
1538
|
+
}
|
|
1539
|
+
} catch (err) {
|
|
1540
|
+
_didIteratorError3 = true;
|
|
1541
|
+
_iteratorError3 = err;
|
|
1542
|
+
} finally {
|
|
1543
|
+
try {
|
|
1544
|
+
if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
|
|
1545
|
+
_iterator3.return();
|
|
1546
|
+
}
|
|
1547
|
+
} finally {
|
|
1548
|
+
if (_didIteratorError3) {
|
|
1549
|
+
throw _iteratorError3;
|
|
1550
|
+
}
|
|
1551
|
+
}
|
|
1552
|
+
}
|
|
1553
|
+
} else if (child && typeof child === "object") {
|
|
1554
|
+
walk(child);
|
|
1555
|
+
}
|
|
1556
|
+
}
|
|
1557
|
+
} catch (err) {
|
|
1558
|
+
_didIteratorError22 = true;
|
|
1559
|
+
_iteratorError22 = err;
|
|
1560
|
+
} finally {
|
|
1561
|
+
try {
|
|
1562
|
+
if (!_iteratorNormalCompletion22 && _iterator22.return != null) {
|
|
1563
|
+
_iterator22.return();
|
|
1564
|
+
}
|
|
1565
|
+
} finally {
|
|
1566
|
+
if (_didIteratorError22) {
|
|
1567
|
+
throw _iteratorError22;
|
|
1568
|
+
}
|
|
1569
|
+
}
|
|
1570
|
+
}
|
|
1571
|
+
if (pushedScope) {
|
|
1572
|
+
scopeTracker.exit();
|
|
1573
|
+
}
|
|
1574
|
+
}
|
|
1575
|
+
walk(parsed.program);
|
|
1576
|
+
var resultString = ms.toString();
|
|
1577
|
+
var map = ms.generateMap({
|
|
1578
|
+
source: filename,
|
|
1579
|
+
hires: true,
|
|
1580
|
+
includeContent: true
|
|
1581
|
+
});
|
|
1582
|
+
return {
|
|
1583
|
+
code: resultString,
|
|
1584
|
+
map,
|
|
1585
|
+
toString() {
|
|
1586
|
+
return resultString;
|
|
1587
|
+
}
|
|
1588
|
+
};
|
|
1644
1589
|
}
|
|
1645
1590
|
function extractDependencies(code, filename, options) {
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
}
|
|
1981
|
-
} catch (err) {
|
|
1982
|
-
_didIteratorError22 = true;
|
|
1983
|
-
_iteratorError22 = err;
|
|
1984
|
-
} finally {
|
|
1985
|
-
try {
|
|
1986
|
-
if (!_iteratorNormalCompletion22 && _iterator22.return != null) {
|
|
1987
|
-
_iterator22.return();
|
|
1988
|
-
}
|
|
1989
|
-
} finally {
|
|
1990
|
-
if (_didIteratorError22) {
|
|
1991
|
-
throw _iteratorError22;
|
|
1992
|
-
}
|
|
1993
|
-
}
|
|
1994
|
-
}
|
|
1995
|
-
ancestors.pop();
|
|
1996
|
-
if (pushedScope) {
|
|
1997
|
-
scopeTracker.exit();
|
|
1998
|
-
}
|
|
1999
|
-
}
|
|
2000
|
-
walk(parseResult.program);
|
|
2001
|
-
return Array.from(depMap.values());
|
|
1591
|
+
var _parseResult_errors;
|
|
1592
|
+
var asyncRequirePath = (options === null || options === void 0 ? void 0 : options.asyncRequireModulePath) || "metro-runtime/src/modules/asyncRequire";
|
|
1593
|
+
var allowOptionalDependencies = options === null || options === void 0 ? void 0 : options.allowOptionalDependencies;
|
|
1594
|
+
var lineOffsets = [0];
|
|
1595
|
+
for (var i = 0; i < code.length; i++) {
|
|
1596
|
+
if (code[i] === "\n") {
|
|
1597
|
+
lineOffsets.push(i + 1);
|
|
1598
|
+
}
|
|
1599
|
+
}
|
|
1600
|
+
function offsetToLoc(pos) {
|
|
1601
|
+
var low = 0;
|
|
1602
|
+
var high = lineOffsets.length - 1;
|
|
1603
|
+
while (low <= high) {
|
|
1604
|
+
var mid = low + high >> 1;
|
|
1605
|
+
if (lineOffsets[mid] <= pos) {
|
|
1606
|
+
low = mid + 1;
|
|
1607
|
+
} else {
|
|
1608
|
+
high = mid - 1;
|
|
1609
|
+
}
|
|
1610
|
+
}
|
|
1611
|
+
var line = high + 1;
|
|
1612
|
+
var column = pos - lineOffsets[high];
|
|
1613
|
+
return {
|
|
1614
|
+
line,
|
|
1615
|
+
column
|
|
1616
|
+
};
|
|
1617
|
+
}
|
|
1618
|
+
var parseResult;
|
|
1619
|
+
try {
|
|
1620
|
+
parseResult = parseSync(filename, code, { lang: langForFilename(filename) });
|
|
1621
|
+
} catch (err) {
|
|
1622
|
+
throw new Error(`[vxrn/metro] Failed to parse ${filename} for dependency extraction: ${err.message || err}`);
|
|
1623
|
+
}
|
|
1624
|
+
if (parseResult === null || parseResult === void 0 ? void 0 : (_parseResult_errors = parseResult.errors) === null || _parseResult_errors === void 0 ? void 0 : _parseResult_errors.length) {
|
|
1625
|
+
throw new Error(`[vxrn/metro] Failed to parse ${filename} for dependency extraction: ${parseResult.errors[0].message}`);
|
|
1626
|
+
}
|
|
1627
|
+
if (!(parseResult === null || parseResult === void 0 ? void 0 : parseResult.program)) {
|
|
1628
|
+
return [];
|
|
1629
|
+
}
|
|
1630
|
+
var depMap = /* @__PURE__ */ new Map();
|
|
1631
|
+
function addDep(name, isESM, asyncType, start, end, contextParams, isOptional) {
|
|
1632
|
+
var key = getDependencyKey(name, isESM, asyncType, contextParams);
|
|
1633
|
+
var entry = depMap.get(key);
|
|
1634
|
+
var loc = {
|
|
1635
|
+
start: offsetToLoc(start),
|
|
1636
|
+
end: offsetToLoc(end)
|
|
1637
|
+
};
|
|
1638
|
+
if (!entry) {
|
|
1639
|
+
entry = {
|
|
1640
|
+
name,
|
|
1641
|
+
data: {
|
|
1642
|
+
key,
|
|
1643
|
+
asyncType,
|
|
1644
|
+
locs: [loc],
|
|
1645
|
+
isESMImportAtSource: isESM,
|
|
1646
|
+
isESMImport: isESM,
|
|
1647
|
+
index: depMap.size,
|
|
1648
|
+
...contextParams ? { contextParams } : {},
|
|
1649
|
+
...isOptional ? { isOptional: true } : {}
|
|
1650
|
+
}
|
|
1651
|
+
};
|
|
1652
|
+
depMap.set(key, entry);
|
|
1653
|
+
} else {
|
|
1654
|
+
entry.data.locs.push(loc);
|
|
1655
|
+
}
|
|
1656
|
+
}
|
|
1657
|
+
var moduleConsts = collectModuleLiteralBindings(parseResult.program);
|
|
1658
|
+
function resolveConst(node) {
|
|
1659
|
+
if ((node === null || node === void 0 ? void 0 : node.type) === "Identifier") return moduleConsts.get(node.name);
|
|
1660
|
+
return node;
|
|
1661
|
+
}
|
|
1662
|
+
var ancestors = [];
|
|
1663
|
+
function isOptionalHere(name) {
|
|
1664
|
+
if (!allowOptionalDependencies) return false;
|
|
1665
|
+
if (Array.isArray(allowOptionalDependencies.exclude)) {
|
|
1666
|
+
if (allowOptionalDependencies.exclude.includes(name)) return false;
|
|
1667
|
+
}
|
|
1668
|
+
var sCount = 0;
|
|
1669
|
+
for (var i2 = ancestors.length - 1; i2 >= 0 && sCount < 3; i2--) {
|
|
1670
|
+
var n = ancestors[i2];
|
|
1671
|
+
var isStatement = /(?:Statement|Declaration)$/.test(n.type);
|
|
1672
|
+
if (!isStatement) continue;
|
|
1673
|
+
if (n.type === "BlockStatement") {
|
|
1674
|
+
var parent = ancestors[i2 - 1];
|
|
1675
|
+
return (parent === null || parent === void 0 ? void 0 : parent.type) === "TryStatement" && parent.block === n;
|
|
1676
|
+
}
|
|
1677
|
+
sCount += 1;
|
|
1678
|
+
}
|
|
1679
|
+
return false;
|
|
1680
|
+
}
|
|
1681
|
+
var scopeTracker = new ScopeTracker();
|
|
1682
|
+
collectHoistedBindings(parseResult.program, scopeTracker.currentScope());
|
|
1683
|
+
collectBlockBindings(parseResult.program.body, scopeTracker.currentScope());
|
|
1684
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
1685
|
+
try {
|
|
1686
|
+
for (var _iterator = (parseResult.program.body || [])[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
1687
|
+
var stmt = _step.value;
|
|
1688
|
+
if (stmt.type === "ImportDeclaration") {
|
|
1689
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;
|
|
1690
|
+
try {
|
|
1691
|
+
for (var _iterator1 = (stmt.specifiers || [])[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
|
|
1692
|
+
var spec = _step1.value;
|
|
1693
|
+
var _spec_local;
|
|
1694
|
+
if ((_spec_local = spec.local) === null || _spec_local === void 0 ? void 0 : _spec_local.name) {
|
|
1695
|
+
scopeTracker.add(spec.local.name);
|
|
1696
|
+
}
|
|
1697
|
+
}
|
|
1698
|
+
} catch (err) {
|
|
1699
|
+
_didIteratorError1 = true;
|
|
1700
|
+
_iteratorError1 = err;
|
|
1701
|
+
} finally {
|
|
1702
|
+
try {
|
|
1703
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
1704
|
+
_iterator1.return();
|
|
1705
|
+
}
|
|
1706
|
+
} finally {
|
|
1707
|
+
if (_didIteratorError1) {
|
|
1708
|
+
throw _iteratorError1;
|
|
1709
|
+
}
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1712
|
+
}
|
|
1713
|
+
}
|
|
1714
|
+
} catch (err) {
|
|
1715
|
+
_didIteratorError = true;
|
|
1716
|
+
_iteratorError = err;
|
|
1717
|
+
} finally {
|
|
1718
|
+
try {
|
|
1719
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
1720
|
+
_iterator.return();
|
|
1721
|
+
}
|
|
1722
|
+
} finally {
|
|
1723
|
+
if (_didIteratorError) {
|
|
1724
|
+
throw _iteratorError;
|
|
1725
|
+
}
|
|
1726
|
+
}
|
|
1727
|
+
}
|
|
1728
|
+
function walk(node) {
|
|
1729
|
+
var _node_source, _node_source1, _node_callee, _node_callee1, _node_callee_object, _node_callee_property;
|
|
1730
|
+
if (!node || typeof node !== "object") return;
|
|
1731
|
+
var pushedScope = false;
|
|
1732
|
+
ancestors.push(node);
|
|
1733
|
+
if (node.type === "FunctionDeclaration" || node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression") {
|
|
1734
|
+
var _node_id;
|
|
1735
|
+
scopeTracker.enter();
|
|
1736
|
+
pushedScope = true;
|
|
1737
|
+
var _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = void 0;
|
|
1738
|
+
try {
|
|
1739
|
+
for (var _iterator2 = (node.params || [])[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
|
1740
|
+
var param = _step2.value;
|
|
1741
|
+
scopeTracker.addPattern(param);
|
|
1742
|
+
}
|
|
1743
|
+
} catch (err) {
|
|
1744
|
+
_didIteratorError2 = true;
|
|
1745
|
+
_iteratorError2 = err;
|
|
1746
|
+
} finally {
|
|
1747
|
+
try {
|
|
1748
|
+
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
|
1749
|
+
_iterator2.return();
|
|
1750
|
+
}
|
|
1751
|
+
} finally {
|
|
1752
|
+
if (_didIteratorError2) {
|
|
1753
|
+
throw _iteratorError2;
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1756
|
+
}
|
|
1757
|
+
if (node.type === "FunctionExpression" && ((_node_id = node.id) === null || _node_id === void 0 ? void 0 : _node_id.name)) {
|
|
1758
|
+
scopeTracker.add(node.id.name);
|
|
1759
|
+
}
|
|
1760
|
+
if (node.body) {
|
|
1761
|
+
collectHoistedBindings(node.body, scopeTracker.currentScope());
|
|
1762
|
+
}
|
|
1763
|
+
} else if (node.type === "BlockStatement") {
|
|
1764
|
+
scopeTracker.enter();
|
|
1765
|
+
pushedScope = true;
|
|
1766
|
+
collectBlockBindings(node.body, scopeTracker.currentScope());
|
|
1767
|
+
} else if (node.type === "CatchClause") {
|
|
1768
|
+
scopeTracker.enter();
|
|
1769
|
+
pushedScope = true;
|
|
1770
|
+
if (node.param) {
|
|
1771
|
+
scopeTracker.addPattern(node.param);
|
|
1772
|
+
}
|
|
1773
|
+
} else if (node.type === "ForStatement" || node.type === "ForInStatement" || node.type === "ForOfStatement") {
|
|
1774
|
+
var decl = node.type === "ForStatement" ? node.init : node.left;
|
|
1775
|
+
if ((decl === null || decl === void 0 ? void 0 : decl.type) === "VariableDeclaration" && decl.kind !== "var") {
|
|
1776
|
+
scopeTracker.enter();
|
|
1777
|
+
pushedScope = true;
|
|
1778
|
+
var _iteratorNormalCompletion12 = true, _didIteratorError12 = false, _iteratorError12 = void 0;
|
|
1779
|
+
try {
|
|
1780
|
+
for (var _iterator12 = (decl.declarations || [])[Symbol.iterator](), _step12; !(_iteratorNormalCompletion12 = (_step12 = _iterator12.next()).done); _iteratorNormalCompletion12 = true) {
|
|
1781
|
+
var d = _step12.value;
|
|
1782
|
+
scopeTracker.addPattern(d.id);
|
|
1783
|
+
}
|
|
1784
|
+
} catch (err) {
|
|
1785
|
+
_didIteratorError12 = true;
|
|
1786
|
+
_iteratorError12 = err;
|
|
1787
|
+
} finally {
|
|
1788
|
+
try {
|
|
1789
|
+
if (!_iteratorNormalCompletion12 && _iterator12.return != null) {
|
|
1790
|
+
_iterator12.return();
|
|
1791
|
+
}
|
|
1792
|
+
} finally {
|
|
1793
|
+
if (_didIteratorError12) {
|
|
1794
|
+
throw _iteratorError12;
|
|
1795
|
+
}
|
|
1796
|
+
}
|
|
1797
|
+
}
|
|
1798
|
+
}
|
|
1799
|
+
}
|
|
1800
|
+
if (node.type === "ImportDeclaration" && ((_node_source = node.source) === null || _node_source === void 0 ? void 0 : _node_source.value)) {
|
|
1801
|
+
if (node.importKind !== "type") {
|
|
1802
|
+
var _node_specifiers;
|
|
1803
|
+
var hasValueSpecifier = !((_node_specifiers = node.specifiers) === null || _node_specifiers === void 0 ? void 0 : _node_specifiers.length) || node.specifiers.some(function(s) {
|
|
1804
|
+
return s.importKind !== "type";
|
|
1805
|
+
});
|
|
1806
|
+
if (hasValueSpecifier) {
|
|
1807
|
+
addDep(node.source.value, true, null, node.start, node.end);
|
|
1808
|
+
}
|
|
1809
|
+
}
|
|
1810
|
+
} else if ((node.type === "ExportNamedDeclaration" || node.type === "ExportAllDeclaration") && ((_node_source1 = node.source) === null || _node_source1 === void 0 ? void 0 : _node_source1.value)) {
|
|
1811
|
+
if (node.exportKind !== "type") {
|
|
1812
|
+
addDep(node.source.value, true, null, node.start, node.end);
|
|
1813
|
+
}
|
|
1814
|
+
} else if (node.type === "ImportExpression") {
|
|
1815
|
+
var _node_source2;
|
|
1816
|
+
if (((_node_source2 = node.source) === null || _node_source2 === void 0 ? void 0 : _node_source2.type) === "Literal" && typeof node.source.value === "string") {
|
|
1817
|
+
addDep(node.source.value, true, "async", node.start, node.end);
|
|
1818
|
+
addDep(asyncRequirePath, false, null, node.start, node.end);
|
|
1819
|
+
} else {
|
|
1820
|
+
throw new Error(`[vxrn/metro] Dynamic import with non-string literal is not supported by Metro in ${filename}`);
|
|
1821
|
+
}
|
|
1822
|
+
} else if (node.type === "CallExpression" && ((_node_callee = node.callee) === null || _node_callee === void 0 ? void 0 : _node_callee.type) === "Identifier" && node.callee.name === "require" && !scopeTracker.isShadowed("require")) {
|
|
1823
|
+
var _node_arguments_, _node_arguments;
|
|
1824
|
+
if (((_node_arguments = node.arguments) === null || _node_arguments === void 0 ? void 0 : (_node_arguments_ = _node_arguments[0]) === null || _node_arguments_ === void 0 ? void 0 : _node_arguments_.type) === "Literal" && typeof node.arguments[0].value === "string") {
|
|
1825
|
+
addDep(node.arguments[0].value, false, null, node.start, node.end, void 0, node.arguments[0].value !== asyncRequirePath && isOptionalHere(node.arguments[0].value));
|
|
1826
|
+
}
|
|
1827
|
+
} else if (node.type === "CallExpression" && ((_node_callee1 = node.callee) === null || _node_callee1 === void 0 ? void 0 : _node_callee1.type) === "MemberExpression" && !node.callee.computed && ((_node_callee_object = node.callee.object) === null || _node_callee_object === void 0 ? void 0 : _node_callee_object.type) === "Identifier" && node.callee.object.name === "require" && ((_node_callee_property = node.callee.property) === null || _node_callee_property === void 0 ? void 0 : _node_callee_property.type) === "Identifier" && node.callee.property.name === "context" && !scopeTracker.isShadowed("require")) {
|
|
1828
|
+
var args = node.arguments || [];
|
|
1829
|
+
var dir = resolveConst(args[0]);
|
|
1830
|
+
if ((dir === null || dir === void 0 ? void 0 : dir.type) !== "Literal" || typeof dir.value !== "string") {
|
|
1831
|
+
throw new Error(`[vxrn/metro] First argument of require.context must be a string literal in ${filename}`);
|
|
1832
|
+
}
|
|
1833
|
+
if (args.length > 4) {
|
|
1834
|
+
throw new Error(`[vxrn/metro] Too many arguments provided to require.context in ${filename}. Expected 4, got: ${args.length}`);
|
|
1835
|
+
}
|
|
1836
|
+
var recursive = true;
|
|
1837
|
+
var recursiveArg = resolveConst(args[1]);
|
|
1838
|
+
if (recursiveArg) {
|
|
1839
|
+
if (recursiveArg.type !== "Literal" || typeof recursiveArg.value !== "boolean") {
|
|
1840
|
+
throw new Error(`[vxrn/metro] Second argument of require.context must be an optional boolean literal in ${filename}`);
|
|
1841
|
+
}
|
|
1842
|
+
recursive = recursiveArg.value;
|
|
1843
|
+
}
|
|
1844
|
+
var filter = {
|
|
1845
|
+
pattern: ".*",
|
|
1846
|
+
flags: ""
|
|
1847
|
+
};
|
|
1848
|
+
var filterArg = resolveConst(args[2]);
|
|
1849
|
+
if (filterArg) {
|
|
1850
|
+
if (filterArg.type !== "Literal" || !filterArg.regex) {
|
|
1851
|
+
throw new Error(`[vxrn/metro] Third argument of require.context must be an optional RegExp literal in ${filename}, instead found node of type: ${filterArg.type}`);
|
|
1852
|
+
}
|
|
1853
|
+
filter = {
|
|
1854
|
+
pattern: filterArg.regex.pattern,
|
|
1855
|
+
flags: filterArg.regex.flags || ""
|
|
1856
|
+
};
|
|
1857
|
+
}
|
|
1858
|
+
var mode = "sync";
|
|
1859
|
+
var modeArg = resolveConst(args[3]);
|
|
1860
|
+
if (modeArg) {
|
|
1861
|
+
var m = modeArg.type === "Literal" ? modeArg.value : void 0;
|
|
1862
|
+
if (m !== "sync" && m !== "eager" && m !== "lazy" && m !== "lazy-once") {
|
|
1863
|
+
throw new Error(`[vxrn/metro] require.context mode must be one of sync, eager, lazy, lazy-once in ${filename}`);
|
|
1864
|
+
}
|
|
1865
|
+
mode = m;
|
|
1866
|
+
}
|
|
1867
|
+
addDep(dir.value, false, null, node.start, node.end, {
|
|
1868
|
+
recursive,
|
|
1869
|
+
filter,
|
|
1870
|
+
mode
|
|
1871
|
+
});
|
|
1872
|
+
}
|
|
1873
|
+
var _iteratorNormalCompletion22 = true, _didIteratorError22 = false, _iteratorError22 = void 0;
|
|
1874
|
+
try {
|
|
1875
|
+
for (var _iterator22 = Object.keys(node)[Symbol.iterator](), _step22; !(_iteratorNormalCompletion22 = (_step22 = _iterator22.next()).done); _iteratorNormalCompletion22 = true) {
|
|
1876
|
+
var key = _step22.value;
|
|
1877
|
+
if (key === "start" || key === "end" || key === "loc" || key === "range" || key === "parent" || key === "comments") continue;
|
|
1878
|
+
var child = node[key];
|
|
1879
|
+
if (Array.isArray(child)) {
|
|
1880
|
+
var _iteratorNormalCompletion3 = true, _didIteratorError3 = false, _iteratorError3 = void 0;
|
|
1881
|
+
try {
|
|
1882
|
+
for (var _iterator3 = child[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
|
|
1883
|
+
var item = _step3.value;
|
|
1884
|
+
walk(item);
|
|
1885
|
+
}
|
|
1886
|
+
} catch (err) {
|
|
1887
|
+
_didIteratorError3 = true;
|
|
1888
|
+
_iteratorError3 = err;
|
|
1889
|
+
} finally {
|
|
1890
|
+
try {
|
|
1891
|
+
if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
|
|
1892
|
+
_iterator3.return();
|
|
1893
|
+
}
|
|
1894
|
+
} finally {
|
|
1895
|
+
if (_didIteratorError3) {
|
|
1896
|
+
throw _iteratorError3;
|
|
1897
|
+
}
|
|
1898
|
+
}
|
|
1899
|
+
}
|
|
1900
|
+
} else if (child && typeof child === "object") {
|
|
1901
|
+
walk(child);
|
|
1902
|
+
}
|
|
1903
|
+
}
|
|
1904
|
+
} catch (err) {
|
|
1905
|
+
_didIteratorError22 = true;
|
|
1906
|
+
_iteratorError22 = err;
|
|
1907
|
+
} finally {
|
|
1908
|
+
try {
|
|
1909
|
+
if (!_iteratorNormalCompletion22 && _iterator22.return != null) {
|
|
1910
|
+
_iterator22.return();
|
|
1911
|
+
}
|
|
1912
|
+
} finally {
|
|
1913
|
+
if (_didIteratorError22) {
|
|
1914
|
+
throw _iteratorError22;
|
|
1915
|
+
}
|
|
1916
|
+
}
|
|
1917
|
+
}
|
|
1918
|
+
ancestors.pop();
|
|
1919
|
+
if (pushedScope) {
|
|
1920
|
+
scopeTracker.exit();
|
|
1921
|
+
}
|
|
1922
|
+
}
|
|
1923
|
+
walk(parseResult.program);
|
|
1924
|
+
return Array.from(depMap.values());
|
|
2002
1925
|
}
|
|
2003
1926
|
function checkReservedStrings(sourceCode, config, options) {
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
}
|
|
2036
|
-
}
|
|
1927
|
+
var _options_customTransformOptions;
|
|
1928
|
+
var reservedStrings = [];
|
|
1929
|
+
if (((_options_customTransformOptions = options.customTransformOptions) === null || _options_customTransformOptions === void 0 ? void 0 : _options_customTransformOptions.unstable_staticHermesOptimizedRequire) === true) {
|
|
1930
|
+
reservedStrings.push("_$$_METRO_MODULE_ID");
|
|
1931
|
+
}
|
|
1932
|
+
if (config.unstable_dependencyMapReservedName != null) {
|
|
1933
|
+
reservedStrings.push(config.unstable_dependencyMapReservedName);
|
|
1934
|
+
}
|
|
1935
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
1936
|
+
try {
|
|
1937
|
+
for (var _iterator = reservedStrings[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
1938
|
+
var reservedString = _step.value;
|
|
1939
|
+
var position = sourceCode.indexOf(reservedString);
|
|
1940
|
+
if (position > -1) {
|
|
1941
|
+
throw new SyntaxError("Source code contains the reserved string `" + reservedString + "` at character offset " + position);
|
|
1942
|
+
}
|
|
1943
|
+
}
|
|
1944
|
+
} catch (err) {
|
|
1945
|
+
_didIteratorError = true;
|
|
1946
|
+
_iteratorError = err;
|
|
1947
|
+
} finally {
|
|
1948
|
+
try {
|
|
1949
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
1950
|
+
_iterator.return();
|
|
1951
|
+
}
|
|
1952
|
+
} finally {
|
|
1953
|
+
if (_didIteratorError) {
|
|
1954
|
+
throw _iteratorError;
|
|
1955
|
+
}
|
|
1956
|
+
}
|
|
1957
|
+
}
|
|
2037
1958
|
}
|
|
2038
1959
|
var workletsConfigured = false;
|
|
2039
1960
|
var oneNativeTransforms;
|
|
2040
1961
|
function loadOneNativeTransforms(projectRoot) {
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
1962
|
+
if (oneNativeTransforms !== void 0) return oneNativeTransforms;
|
|
1963
|
+
try {
|
|
1964
|
+
var req = createRequire(path.resolve(projectRoot, "package.json"));
|
|
1965
|
+
oneNativeTransforms = req("one/native-transforms");
|
|
1966
|
+
} catch (unused) {
|
|
1967
|
+
oneNativeTransforms = null;
|
|
1968
|
+
}
|
|
1969
|
+
return oneNativeTransforms;
|
|
2049
1970
|
}
|
|
2050
1971
|
async function configureWorkletsForWorker(projectRoot) {
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
} = await import("@vxrn/compiler");
|
|
2068
|
-
configureVXRNCompilerPlugin({
|
|
2069
|
-
enableReanimated: hasReanimated
|
|
2070
|
-
});
|
|
1972
|
+
if (workletsConfigured) return;
|
|
1973
|
+
workletsConfigured = true;
|
|
1974
|
+
if (!projectRoot) return;
|
|
1975
|
+
var req = createRequire(path.resolve(projectRoot, "package.json"));
|
|
1976
|
+
var hasReanimated = false;
|
|
1977
|
+
try {
|
|
1978
|
+
req.resolve("react-native-reanimated/package.json");
|
|
1979
|
+
hasReanimated = true;
|
|
1980
|
+
} catch (unused) {
|
|
1981
|
+
try {
|
|
1982
|
+
req.resolve("react-native-worklets/package.json");
|
|
1983
|
+
hasReanimated = true;
|
|
1984
|
+
} catch (unused2) {}
|
|
1985
|
+
}
|
|
1986
|
+
var { configureVXRNCompilerPlugin } = await import("@vxrn/compiler");
|
|
1987
|
+
configureVXRNCompilerPlugin({ enableReanimated: hasReanimated });
|
|
2071
1988
|
}
|
|
2072
1989
|
async function transform(config, projectRoot, filename, data, options) {
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
1990
|
+
var _options_customTransformOptions, _options_customTransformOptions1, _options_customTransformOptions2, _oxcRes_errors;
|
|
1991
|
+
assertNoUnportedBabelPlugins(options);
|
|
1992
|
+
var sourceCode = typeof data === "string" ? data : data.toString("utf8");
|
|
1993
|
+
var environment = (_options_customTransformOptions = options.customTransformOptions) === null || _options_customTransformOptions === void 0 ? void 0 : _options_customTransformOptions.environment;
|
|
1994
|
+
var isClientEnvironment = environment !== "node" && environment !== "react-server";
|
|
1995
|
+
if (isClientEnvironment && /[\\/]expo[\\/]virtual[\\/]env\.js$/.test(filename)) {
|
|
1996
|
+
if (options.dev) {
|
|
1997
|
+
var rel = path.relative(path.dirname(filename), projectRoot).split(path.sep).join("/");
|
|
1998
|
+
sourceCode = `const dotEnvModules = require.context(${JSON.stringify(rel)},false,/^\\.\\/\\.env/);
|
|
2082
1999
|
export const env = !dotEnvModules.keys().length ? process.env : { ...process.env, ...['.env', '.env.development', '.env.local', '.env.development.local'].reduce((acc, file) => {
|
|
2083
2000
|
return { ...acc, ...(dotEnvModules(file)?.default ?? {}) };
|
|
2084
2001
|
}, {}) };`;
|
|
2085
|
-
|
|
2086
|
-
|
|
2002
|
+
} else {
|
|
2003
|
+
sourceCode = `export const env = new Proxy({}, {
|
|
2087
2004
|
get(target, key) {
|
|
2088
2005
|
throw new Error(\`Attempting to access internal environment variable "\${String(key)}" is not supported in production bundles.\`);
|
|
2089
2006
|
},
|
|
2090
2007
|
});`;
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
try {
|
|
2467
|
-
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
|
2468
|
-
_iterator2.return();
|
|
2469
|
-
}
|
|
2470
|
-
} finally {
|
|
2471
|
-
if (_didIteratorError2) {
|
|
2472
|
-
throw _iteratorError2;
|
|
2473
|
-
}
|
|
2474
|
-
}
|
|
2475
|
-
}
|
|
2476
|
-
dependencies1.length = 0;
|
|
2477
|
-
var _iteratorNormalCompletion3 = true,
|
|
2478
|
-
_didIteratorError3 = false,
|
|
2479
|
-
_iteratorError3 = void 0;
|
|
2480
|
-
try {
|
|
2481
|
-
for (var _iterator3 = reconciled[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
|
|
2482
|
-
var dep = _step3.value;
|
|
2483
|
-
dependencies1.push({
|
|
2484
|
-
...dep,
|
|
2485
|
-
data: {
|
|
2486
|
-
...dep.data,
|
|
2487
|
-
index: dependencies1.length
|
|
2488
|
-
}
|
|
2489
|
-
});
|
|
2490
|
-
}
|
|
2491
|
-
} catch (err) {
|
|
2492
|
-
_didIteratorError3 = true;
|
|
2493
|
-
_iteratorError3 = err;
|
|
2494
|
-
} finally {
|
|
2495
|
-
try {
|
|
2496
|
-
if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
|
|
2497
|
-
_iterator3.return();
|
|
2498
|
-
}
|
|
2499
|
-
} finally {
|
|
2500
|
-
if (_didIteratorError3) {
|
|
2501
|
-
throw _iteratorError3;
|
|
2502
|
-
}
|
|
2503
|
-
}
|
|
2504
|
-
}
|
|
2505
|
-
var depMapName = config.unstable_dependencyMapReservedName || "_dependencyMap";
|
|
2506
|
-
if (options.type === "script") {
|
|
2507
|
-
var msScript = new MagicString(code2);
|
|
2508
|
-
msScript.prepend(`(function (global) {
|
|
2008
|
+
}
|
|
2009
|
+
} else if (/(^|[\\/])\.env(\.(local|(development|production)(\.local)?))?$/.test(filename)) {
|
|
2010
|
+
var { parseEnvFile } = await import("@expo/metro-config/build/transform-worker/dot-env-development");
|
|
2011
|
+
sourceCode = `export default ${JSON.stringify(parseEnvFile(sourceCode, isClientEnvironment))};`;
|
|
2012
|
+
}
|
|
2013
|
+
checkReservedStrings(sourceCode, config, options);
|
|
2014
|
+
if (filename.endsWith(".json")) {
|
|
2015
|
+
try {
|
|
2016
|
+
JSON.parse(sourceCode);
|
|
2017
|
+
} catch (err) {
|
|
2018
|
+
throw new Error(`[vxrn/metro] JSON parse error in ${filename}: ${err.message || err}`);
|
|
2019
|
+
}
|
|
2020
|
+
var code = config.unstable_disableModuleWrapping === true ? `module.exports = ${sourceCode};` : wrapJson(sourceCode, {
|
|
2021
|
+
globalPrefix: config.globalPrefix,
|
|
2022
|
+
moduleId: options.moduleId,
|
|
2023
|
+
dependencyIds: options.dependencyIds
|
|
2024
|
+
});
|
|
2025
|
+
if (options.minify && options.unstable_transformProfile !== "hermes-canary" && options.unstable_transformProfile !== "hermes-stable" && config.minifierPath) {
|
|
2026
|
+
try {
|
|
2027
|
+
var minifier = require(config.minifierPath);
|
|
2028
|
+
var minified = await minifier({
|
|
2029
|
+
code,
|
|
2030
|
+
config: config.minifierConfig,
|
|
2031
|
+
filename
|
|
2032
|
+
});
|
|
2033
|
+
code = minified.code;
|
|
2034
|
+
} catch (err) {
|
|
2035
|
+
throw new Error(`[vxrn/metro] Minifier failed for ${filename}: ${err.message || err}`);
|
|
2036
|
+
}
|
|
2037
|
+
}
|
|
2038
|
+
var { lineCount, map } = countLinesAndTerminateMap(code, []);
|
|
2039
|
+
var outputType = options.type === "asset" ? "js/module/asset" : options.type === "script" ? "js/script" : "js/module";
|
|
2040
|
+
return {
|
|
2041
|
+
dependencies: [],
|
|
2042
|
+
output: [{
|
|
2043
|
+
data: {
|
|
2044
|
+
code,
|
|
2045
|
+
lineCount,
|
|
2046
|
+
map,
|
|
2047
|
+
functionMap: null
|
|
2048
|
+
},
|
|
2049
|
+
type: outputType
|
|
2050
|
+
}]
|
|
2051
|
+
};
|
|
2052
|
+
}
|
|
2053
|
+
if (options.type === "asset") {
|
|
2054
|
+
var assetRegistryPath = config.assetRegistryPath || "react-native/asset-registry";
|
|
2055
|
+
var properDescriptor = null;
|
|
2056
|
+
var absolutePath = path.resolve(projectRoot, filename);
|
|
2057
|
+
if (fs.existsSync(absolutePath)) {
|
|
2058
|
+
try {
|
|
2059
|
+
var getAssetData;
|
|
2060
|
+
try {
|
|
2061
|
+
getAssetData = require("metro/private/Assets").getAssetData;
|
|
2062
|
+
} catch (unused) {
|
|
2063
|
+
getAssetData = require("metro/src/Assets").getAssetData;
|
|
2064
|
+
}
|
|
2065
|
+
if (typeof getAssetData === "function") {
|
|
2066
|
+
var rawData = await getAssetData(absolutePath, filename, config.assetPlugins || [], options.platform || "", config.publicPath || "/assets");
|
|
2067
|
+
var copied = { ...rawData };
|
|
2068
|
+
delete copied.files;
|
|
2069
|
+
delete copied.fileSystemLocation;
|
|
2070
|
+
delete copied.path;
|
|
2071
|
+
properDescriptor = copied;
|
|
2072
|
+
}
|
|
2073
|
+
} catch (err) {
|
|
2074
|
+
throw new Error(`[vxrn/metro] Asset resolution failed for ${filename}: ${err.message || err}`);
|
|
2075
|
+
}
|
|
2076
|
+
}
|
|
2077
|
+
if (!properDescriptor) {
|
|
2078
|
+
var ext = path.extname(filename).slice(1);
|
|
2079
|
+
var name = path.basename(filename, "." + ext);
|
|
2080
|
+
properDescriptor = {
|
|
2081
|
+
__packager_asset: true,
|
|
2082
|
+
httpServerLocation: config.publicPath || "/assets",
|
|
2083
|
+
width: void 0,
|
|
2084
|
+
height: void 0,
|
|
2085
|
+
scales: [1],
|
|
2086
|
+
hash: crypto.createHash("md5").update(sourceCode).digest("hex"),
|
|
2087
|
+
name,
|
|
2088
|
+
type: ext
|
|
2089
|
+
};
|
|
2090
|
+
}
|
|
2091
|
+
var assetDepMapName = config.unstable_dependencyMapReservedName || "_dependencyMap";
|
|
2092
|
+
var assetCode = `module.exports = require(${assetDepMapName}[0], ${JSON.stringify(assetRegistryPath)}).registerAsset(${JSON.stringify(properDescriptor)});`;
|
|
2093
|
+
var code1 = config.unstable_disableModuleWrapping === true ? assetCode : wrapModule(assetCode, {
|
|
2094
|
+
globalPrefix: config.globalPrefix,
|
|
2095
|
+
moduleId: options.moduleId,
|
|
2096
|
+
dependencyIds: options.dependencyIds,
|
|
2097
|
+
dependencyMapName: config.unstable_dependencyMapReservedName
|
|
2098
|
+
});
|
|
2099
|
+
var dependencies = [{
|
|
2100
|
+
name: assetRegistryPath,
|
|
2101
|
+
data: {
|
|
2102
|
+
key: getDependencyKey(assetRegistryPath, false, null),
|
|
2103
|
+
asyncType: null,
|
|
2104
|
+
locs: [],
|
|
2105
|
+
isESMImportAtSource: false,
|
|
2106
|
+
isESMImport: false,
|
|
2107
|
+
index: 0
|
|
2108
|
+
}
|
|
2109
|
+
}];
|
|
2110
|
+
var { lineCount: lineCount1, map: map1 } = countLinesAndTerminateMap(code1, []);
|
|
2111
|
+
return {
|
|
2112
|
+
dependencies,
|
|
2113
|
+
output: [{
|
|
2114
|
+
data: {
|
|
2115
|
+
code: code1,
|
|
2116
|
+
lineCount: lineCount1,
|
|
2117
|
+
map: map1,
|
|
2118
|
+
functionMap: null
|
|
2119
|
+
},
|
|
2120
|
+
type: "js/module/asset"
|
|
2121
|
+
}]
|
|
2122
|
+
};
|
|
2123
|
+
}
|
|
2124
|
+
var code2 = sourceCode;
|
|
2125
|
+
var intermediateMaps = [];
|
|
2126
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
2127
|
+
try {
|
|
2128
|
+
for (var _iterator = getNativeTransforms(options, projectRoot)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
2129
|
+
var nativeTransform = _step.value;
|
|
2130
|
+
var out = nativeTransform(code2, {
|
|
2131
|
+
filename: path.isAbsolute(filename) ? filename : path.resolve(projectRoot, filename),
|
|
2132
|
+
platform: options.platform,
|
|
2133
|
+
dev: options.dev,
|
|
2134
|
+
projectRoot
|
|
2135
|
+
});
|
|
2136
|
+
if (typeof out === "string") code2 = out;
|
|
2137
|
+
}
|
|
2138
|
+
} catch (err) {
|
|
2139
|
+
_didIteratorError = true;
|
|
2140
|
+
_iteratorError = err;
|
|
2141
|
+
} finally {
|
|
2142
|
+
try {
|
|
2143
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
2144
|
+
_iterator.return();
|
|
2145
|
+
}
|
|
2146
|
+
} finally {
|
|
2147
|
+
if (_didIteratorError) {
|
|
2148
|
+
throw _iteratorError;
|
|
2149
|
+
}
|
|
2150
|
+
}
|
|
2151
|
+
}
|
|
2152
|
+
var oneRouterOptions = getOneRouterMetroOptions(options);
|
|
2153
|
+
if (oneRouterOptions) {
|
|
2154
|
+
code2 = applyOneRouterMetro(code2, filename, oneRouterOptions);
|
|
2155
|
+
}
|
|
2156
|
+
try {
|
|
2157
|
+
var codegenRes = transformReactNativeCodegen(code2, filename, projectRoot);
|
|
2158
|
+
if (codegenRes === null || codegenRes === void 0 ? void 0 : codegenRes.code) {
|
|
2159
|
+
code2 = codegenRes.code;
|
|
2160
|
+
if (codegenRes.map) {
|
|
2161
|
+
intermediateMaps.push(codegenRes.map);
|
|
2162
|
+
}
|
|
2163
|
+
}
|
|
2164
|
+
} catch (err) {
|
|
2165
|
+
throw new Error(`[vxrn/metro] React Native codegen failed for ${filename}: ${err.message || err}`);
|
|
2166
|
+
}
|
|
2167
|
+
if (shouldStripFlow(filename, code2)) {
|
|
2168
|
+
try {
|
|
2169
|
+
var flowResult = await stripFlowTypes(filename, code2);
|
|
2170
|
+
if (flowResult === null || flowResult === void 0 ? void 0 : flowResult.code) {
|
|
2171
|
+
code2 = flowResult.code;
|
|
2172
|
+
if (flowResult.map) {
|
|
2173
|
+
intermediateMaps.push(typeof flowResult.map === "string" ? JSON.parse(flowResult.map) : flowResult.map);
|
|
2174
|
+
}
|
|
2175
|
+
}
|
|
2176
|
+
} catch (err) {
|
|
2177
|
+
throw new Error(`[vxrn/metro] Flow transform failed for ${filename}: ${err.message || err}`);
|
|
2178
|
+
}
|
|
2179
|
+
}
|
|
2180
|
+
var asyncRequirePath = config.asyncRequireModulePath || "metro-runtime/src/modules/asyncRequire";
|
|
2181
|
+
var aliases = getModuleResolverAliases(options);
|
|
2182
|
+
if (aliases && projectRoot) {
|
|
2183
|
+
var aliasKeys = Object.keys(aliases);
|
|
2184
|
+
if (aliasKeys.some(function(k) {
|
|
2185
|
+
return code2.includes(k.endsWith("$") ? k.slice(0, -1) : k);
|
|
2186
|
+
})) {
|
|
2187
|
+
code2 = applyModuleResolverAliases(code2, filename, projectRoot, aliases);
|
|
2188
|
+
}
|
|
2189
|
+
}
|
|
2190
|
+
if (code2.includes("process.env") || code2.includes("import.meta")) {
|
|
2191
|
+
code2 = applyInlineEnvVars(code2, filename, !options.dev, getImportMetaEnv(options));
|
|
2192
|
+
}
|
|
2193
|
+
if (code2.includes("-only")) {
|
|
2194
|
+
code2 = applyEnvironmentGuard(code2, filename);
|
|
2195
|
+
}
|
|
2196
|
+
var serverCodeRouterRoot = getRemoveServerCodeRouterRoot(options);
|
|
2197
|
+
if (serverCodeRouterRoot && projectRoot && !filename.includes("node_modules")) {
|
|
2198
|
+
var oneNativeTransforms2 = loadOneNativeTransforms(projectRoot);
|
|
2199
|
+
if (oneNativeTransforms2) {
|
|
2200
|
+
var shaken = await oneNativeTransforms2.transformTreeShakeClient(code2, filename, projectRoot, serverCodeRouterRoot);
|
|
2201
|
+
if (shaken === null || shaken === void 0 ? void 0 : shaken.code) {
|
|
2202
|
+
code2 = shaken.code;
|
|
2203
|
+
}
|
|
2204
|
+
}
|
|
2205
|
+
}
|
|
2206
|
+
var dependencies1 = extractDependencies(code2, filename, {
|
|
2207
|
+
asyncRequireModulePath: asyncRequirePath,
|
|
2208
|
+
allowOptionalDependencies: config.allowOptionalDependencies
|
|
2209
|
+
});
|
|
2210
|
+
await configureWorkletsForWorker(projectRoot);
|
|
2211
|
+
var shouldRunWorklets = Boolean((_options_customTransformOptions1 = options.customTransformOptions) === null || _options_customTransformOptions1 === void 0 ? void 0 : _options_customTransformOptions1.worklets);
|
|
2212
|
+
if (!shouldRunWorklets) {
|
|
2213
|
+
var { shouldTransformWorklets } = await import("@vxrn/compiler");
|
|
2214
|
+
shouldRunWorklets = shouldTransformWorklets({
|
|
2215
|
+
id: filename,
|
|
2216
|
+
code: code2
|
|
2217
|
+
});
|
|
2218
|
+
}
|
|
2219
|
+
var shouldRunReactCompiler = Boolean((_options_customTransformOptions2 = options.customTransformOptions) === null || _options_customTransformOptions2 === void 0 ? void 0 : _options_customTransformOptions2.reactCompiler) || hasBabelPlugin(options, "babel-plugin-react-compiler") && isReactCompilerCandidate(filename) || code2.includes("\"use memo\"") || code2.includes("'use memo'");
|
|
2220
|
+
if (shouldRunReactCompiler) {
|
|
2221
|
+
try {
|
|
2222
|
+
var { prepareWorkletsForReactCompiler, transformOxcReactCompiler } = await import("@vxrn/compiler");
|
|
2223
|
+
if (shouldRunWorklets) {
|
|
2224
|
+
var prepared = prepareWorkletsForReactCompiler(filename, code2, true);
|
|
2225
|
+
if (prepared) {
|
|
2226
|
+
code2 = prepared.code;
|
|
2227
|
+
if (prepared.map) intermediateMaps.push(prepared.map);
|
|
2228
|
+
}
|
|
2229
|
+
}
|
|
2230
|
+
var compilerRes = await transformOxcReactCompiler(filename, code2, "19", true);
|
|
2231
|
+
if (compilerRes === null || compilerRes === void 0 ? void 0 : compilerRes.code) {
|
|
2232
|
+
code2 = compilerRes.code;
|
|
2233
|
+
if (compilerRes.map) {
|
|
2234
|
+
intermediateMaps.push(typeof compilerRes.map === "string" ? JSON.parse(compilerRes.map) : compilerRes.map);
|
|
2235
|
+
}
|
|
2236
|
+
}
|
|
2237
|
+
} catch (err) {
|
|
2238
|
+
throw new Error(`[vxrn/metro] React Compiler failed for ${filename}: ${err.message || err}`);
|
|
2239
|
+
}
|
|
2240
|
+
}
|
|
2241
|
+
if (shouldRunWorklets) {
|
|
2242
|
+
try {
|
|
2243
|
+
var { transformWorklets } = await import("@vxrn/compiler");
|
|
2244
|
+
var workletRes = await transformWorklets(filename, code2, true, { projectRoot });
|
|
2245
|
+
if (workletRes === null || workletRes === void 0 ? void 0 : workletRes.code) {
|
|
2246
|
+
code2 = workletRes.code;
|
|
2247
|
+
if (workletRes.map) {
|
|
2248
|
+
intermediateMaps.push(typeof workletRes.map === "string" ? JSON.parse(workletRes.map) : workletRes.map);
|
|
2249
|
+
}
|
|
2250
|
+
}
|
|
2251
|
+
} catch (err) {
|
|
2252
|
+
throw new Error(`[vxrn/metro] Worklets transform failed for ${filename}: ${err.message || err}`);
|
|
2253
|
+
}
|
|
2254
|
+
}
|
|
2255
|
+
var lang = langForFilename(filename);
|
|
2256
|
+
var { transformSync: oxcTransform } = await import("oxc-transform");
|
|
2257
|
+
var oxcRes;
|
|
2258
|
+
try {
|
|
2259
|
+
oxcRes = oxcTransform(filename, code2, {
|
|
2260
|
+
lang,
|
|
2261
|
+
target: "es2020",
|
|
2262
|
+
assumptions: { setPublicClassFields: true },
|
|
2263
|
+
jsx: {
|
|
2264
|
+
runtime: "automatic",
|
|
2265
|
+
development: Boolean(options.dev)
|
|
2266
|
+
},
|
|
2267
|
+
sourcemap: true
|
|
2268
|
+
});
|
|
2269
|
+
} catch (err) {
|
|
2270
|
+
throw new Error(`[vxrn/metro] Oxc transform failed for ${filename}: ${err.message || err}`);
|
|
2271
|
+
}
|
|
2272
|
+
if ((_oxcRes_errors = oxcRes.errors) === null || _oxcRes_errors === void 0 ? void 0 : _oxcRes_errors.length) {
|
|
2273
|
+
throw new Error(`[vxrn/metro] Oxc transform failed for ${filename}: ${oxcRes.errors[0].message || oxcRes.errors[0]}`);
|
|
2274
|
+
}
|
|
2275
|
+
code2 = oxcRes.code || code2;
|
|
2276
|
+
if (oxcRes.map) {
|
|
2277
|
+
intermediateMaps.push(typeof oxcRes.map === "string" ? JSON.parse(oxcRes.map) : oxcRes.map);
|
|
2278
|
+
}
|
|
2279
|
+
try {
|
|
2280
|
+
var esbuildRes = await transformHermesAsync(code2, filename, true, options.type === "script" ? void 0 : "cjs");
|
|
2281
|
+
if (esbuildRes) {
|
|
2282
|
+
code2 = esbuildRes.code;
|
|
2283
|
+
if (esbuildRes.map) {
|
|
2284
|
+
intermediateMaps.push(esbuildRes.map);
|
|
2285
|
+
}
|
|
2286
|
+
}
|
|
2287
|
+
} catch (err) {
|
|
2288
|
+
throw new Error(`[vxrn/metro] native async/CJS lowering failed for ${filename}: ${err.message || err}`);
|
|
2289
|
+
}
|
|
2290
|
+
try {
|
|
2291
|
+
var loopsRes = transformHermesLoops(code2, filename);
|
|
2292
|
+
if (loopsRes) {
|
|
2293
|
+
code2 = loopsRes.code;
|
|
2294
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;
|
|
2295
|
+
try {
|
|
2296
|
+
for (var _iterator1 = loopsRes.maps[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
|
|
2297
|
+
var map2 = _step1.value;
|
|
2298
|
+
intermediateMaps.push(map2);
|
|
2299
|
+
}
|
|
2300
|
+
} catch (err) {
|
|
2301
|
+
_didIteratorError1 = true;
|
|
2302
|
+
_iteratorError1 = err;
|
|
2303
|
+
} finally {
|
|
2304
|
+
try {
|
|
2305
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
2306
|
+
_iterator1.return();
|
|
2307
|
+
}
|
|
2308
|
+
} finally {
|
|
2309
|
+
if (_didIteratorError1) {
|
|
2310
|
+
throw _iteratorError1;
|
|
2311
|
+
}
|
|
2312
|
+
}
|
|
2313
|
+
}
|
|
2314
|
+
}
|
|
2315
|
+
} catch (err) {
|
|
2316
|
+
throw new Error(`[vxrn/metro] Hermes loop-binding transform failed for ${filename}: ${err.message || err}`);
|
|
2317
|
+
}
|
|
2318
|
+
var finalDeps = extractDependencies(code2, filename, {
|
|
2319
|
+
asyncRequireModulePath: asyncRequirePath,
|
|
2320
|
+
allowOptionalDependencies: config.allowOptionalDependencies
|
|
2321
|
+
});
|
|
2322
|
+
var finalNames = new Set(finalDeps.map(function(d) {
|
|
2323
|
+
return d.name;
|
|
2324
|
+
}));
|
|
2325
|
+
var reconciled = dependencies1.filter(function(d) {
|
|
2326
|
+
return finalNames.has(d.name);
|
|
2327
|
+
});
|
|
2328
|
+
var _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = void 0;
|
|
2329
|
+
try {
|
|
2330
|
+
var _loop = function() {
|
|
2331
|
+
var injected = _step2.value;
|
|
2332
|
+
if (reconciled.some(function(d) {
|
|
2333
|
+
return d.name === injected.name;
|
|
2334
|
+
})) return "continue";
|
|
2335
|
+
reconciled.push(injected);
|
|
2336
|
+
};
|
|
2337
|
+
for (var _iterator2 = finalDeps[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) _loop();
|
|
2338
|
+
} catch (err) {
|
|
2339
|
+
_didIteratorError2 = true;
|
|
2340
|
+
_iteratorError2 = err;
|
|
2341
|
+
} finally {
|
|
2342
|
+
try {
|
|
2343
|
+
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
|
2344
|
+
_iterator2.return();
|
|
2345
|
+
}
|
|
2346
|
+
} finally {
|
|
2347
|
+
if (_didIteratorError2) {
|
|
2348
|
+
throw _iteratorError2;
|
|
2349
|
+
}
|
|
2350
|
+
}
|
|
2351
|
+
}
|
|
2352
|
+
dependencies1.length = 0;
|
|
2353
|
+
var _iteratorNormalCompletion3 = true, _didIteratorError3 = false, _iteratorError3 = void 0;
|
|
2354
|
+
try {
|
|
2355
|
+
for (var _iterator3 = reconciled[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
|
|
2356
|
+
var dep = _step3.value;
|
|
2357
|
+
dependencies1.push({
|
|
2358
|
+
...dep,
|
|
2359
|
+
data: {
|
|
2360
|
+
...dep.data,
|
|
2361
|
+
index: dependencies1.length
|
|
2362
|
+
}
|
|
2363
|
+
});
|
|
2364
|
+
}
|
|
2365
|
+
} catch (err) {
|
|
2366
|
+
_didIteratorError3 = true;
|
|
2367
|
+
_iteratorError3 = err;
|
|
2368
|
+
} finally {
|
|
2369
|
+
try {
|
|
2370
|
+
if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
|
|
2371
|
+
_iterator3.return();
|
|
2372
|
+
}
|
|
2373
|
+
} finally {
|
|
2374
|
+
if (_didIteratorError3) {
|
|
2375
|
+
throw _iteratorError3;
|
|
2376
|
+
}
|
|
2377
|
+
}
|
|
2378
|
+
}
|
|
2379
|
+
var depMapName = config.unstable_dependencyMapReservedName || "_dependencyMap";
|
|
2380
|
+
if (options.type === "script") {
|
|
2381
|
+
var msScript = new MagicString(code2);
|
|
2382
|
+
msScript.prepend(`(function (global) {
|
|
2509
2383
|
`);
|
|
2510
|
-
|
|
2384
|
+
msScript.append(`
|
|
2511
2385
|
})(typeof globalThis !== 'undefined' ? globalThis : typeof global !== 'undefined' ? global : typeof window !== 'undefined' ? window : this);`);
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2386
|
+
code2 = msScript.toString();
|
|
2387
|
+
intermediateMaps.push(msScript.generateMap({
|
|
2388
|
+
source: filename,
|
|
2389
|
+
hires: true,
|
|
2390
|
+
includeContent: true
|
|
2391
|
+
}));
|
|
2392
|
+
} else if (config.unstable_disableModuleWrapping === true) {
|
|
2393
|
+
var rewriteRes = rewriteDependencyCalls(code2, dependencies1, depMapName, filename, asyncRequirePath);
|
|
2394
|
+
code2 = rewriteRes.code;
|
|
2395
|
+
if (rewriteRes.map) {
|
|
2396
|
+
intermediateMaps.push(rewriteRes.map);
|
|
2397
|
+
}
|
|
2398
|
+
} else {
|
|
2399
|
+
var rewriteRes1 = rewriteDependencyCalls(code2, dependencies1, depMapName, filename, asyncRequirePath);
|
|
2400
|
+
if (rewriteRes1.map) {
|
|
2401
|
+
intermediateMaps.push(rewriteRes1.map);
|
|
2402
|
+
}
|
|
2403
|
+
var msWrap = new MagicString(rewriteRes1.code);
|
|
2404
|
+
var globalPrefix = config.globalPrefix || "";
|
|
2405
|
+
var header = `function (global, _$$_REQUIRE, _$$_IMPORT_DEFAULT, _$$_IMPORT_ALL, module, exports, ${depMapName}) {
|
|
2532
2406
|
var require = _$$_REQUIRE;
|
|
2533
2407
|
`;
|
|
2534
|
-
|
|
2408
|
+
var footer = `
|
|
2535
2409
|
}`;
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
type: options.type === "script" ? "js/script" : "js/module"
|
|
2599
|
-
}]
|
|
2600
|
-
};
|
|
2410
|
+
msWrap.prepend(`${globalPrefix}__d(${header}`);
|
|
2411
|
+
if (options.moduleId !== void 0) {
|
|
2412
|
+
var depIds = options.dependencyIds ? JSON.stringify(options.dependencyIds) : "[]";
|
|
2413
|
+
msWrap.append(`${footer}, ${JSON.stringify(options.moduleId)}, ${depIds});`);
|
|
2414
|
+
} else {
|
|
2415
|
+
msWrap.append(`${footer});`);
|
|
2416
|
+
}
|
|
2417
|
+
code2 = msWrap.toString();
|
|
2418
|
+
intermediateMaps.push(msWrap.generateMap({
|
|
2419
|
+
source: filename,
|
|
2420
|
+
hires: true,
|
|
2421
|
+
includeContent: true
|
|
2422
|
+
}));
|
|
2423
|
+
}
|
|
2424
|
+
if (options.minify && options.unstable_transformProfile !== "hermes-canary" && options.unstable_transformProfile !== "hermes-stable" && config.minifierPath) {
|
|
2425
|
+
try {
|
|
2426
|
+
var minifier1 = require(config.minifierPath);
|
|
2427
|
+
var minified1 = await minifier1({
|
|
2428
|
+
code: code2,
|
|
2429
|
+
config: config.minifierConfig,
|
|
2430
|
+
filename,
|
|
2431
|
+
map: new MagicString(code2).generateMap({
|
|
2432
|
+
source: filename,
|
|
2433
|
+
hires: true,
|
|
2434
|
+
includeContent: true
|
|
2435
|
+
})
|
|
2436
|
+
});
|
|
2437
|
+
code2 = minified1.code;
|
|
2438
|
+
if (minified1.map) {
|
|
2439
|
+
intermediateMaps.push(typeof minified1.map === "string" ? JSON.parse(minified1.map) : minified1.map);
|
|
2440
|
+
} else {
|
|
2441
|
+
intermediateMaps.length = 0;
|
|
2442
|
+
}
|
|
2443
|
+
} catch (err) {
|
|
2444
|
+
throw new Error(`[vxrn/metro] Minifier failed for ${filename}: ${err.message || err}`);
|
|
2445
|
+
}
|
|
2446
|
+
}
|
|
2447
|
+
var rawMappings = [];
|
|
2448
|
+
if (intermediateMaps.length > 0) {
|
|
2449
|
+
var cleanMaps = intermediateMaps.map(function(m) {
|
|
2450
|
+
return typeof m === "string" ? JSON.parse(m) : m;
|
|
2451
|
+
}).filter(Boolean);
|
|
2452
|
+
if (cleanMaps.length > 0) {
|
|
2453
|
+
var composed = cleanMaps.length === 1 ? cleanMaps[0] : remapping(cleanMaps.slice().reverse(), function() {
|
|
2454
|
+
return null;
|
|
2455
|
+
});
|
|
2456
|
+
rawMappings = convertSourceMapToMetroRawMappings(composed);
|
|
2457
|
+
}
|
|
2458
|
+
}
|
|
2459
|
+
var { lineCount: lineCount2, map: map3 } = countLinesAndTerminateMap(code2, rawMappings);
|
|
2460
|
+
return {
|
|
2461
|
+
dependencies: dependencies1,
|
|
2462
|
+
output: [{
|
|
2463
|
+
data: {
|
|
2464
|
+
code: code2,
|
|
2465
|
+
lineCount: lineCount2,
|
|
2466
|
+
map: map3,
|
|
2467
|
+
functionMap: null
|
|
2468
|
+
},
|
|
2469
|
+
type: options.type === "script" ? "js/script" : "js/module"
|
|
2470
|
+
}]
|
|
2471
|
+
};
|
|
2601
2472
|
}
|
|
2602
2473
|
var metroNativeWorker_default = {
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2474
|
+
transform,
|
|
2475
|
+
getCacheKey,
|
|
2476
|
+
wrapModule,
|
|
2477
|
+
wrapJson,
|
|
2478
|
+
extractDependencies,
|
|
2479
|
+
rewriteDependencyCalls,
|
|
2480
|
+
convertSourceMapToMetroRawMappings
|
|
2610
2481
|
};
|
|
2482
|
+
|
|
2611
2483
|
export { ScopeTracker, applyEnvironmentGuard, applyInlineEnvVars, applyModuleResolverAliases, applyOneRouterMetro, assertNoUnportedBabelPlugins, collectBlockBindings, collectHoistedBindings, collectPatternNames, convertSourceMapToMetroRawMappings, countLinesAndTerminateMap, metroNativeWorker_default as default, extractDependencies, getCacheKey, getDependencyKey, getImportMetaEnv, getModuleResolverAliases, getOneRouterMetroOptions, getRemoveServerCodeRouterRoot, resolveAliasSpecifier, rewriteDependencyCalls, transform, wrapJson, wrapModule };
|
|
2612
2484
|
//# sourceMappingURL=metroNativeWorker.native.js.map
|