vxrn 1.27.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/cli.mjs +212 -261
- package/dist/cli.mjs.map +1 -1
- package/dist/cli.native.js +216 -265
- package/dist/cli.native.js.map +1 -1
- package/dist/config/getAdditionalViteConfig.mjs +33 -62
- package/dist/config/getAdditionalViteConfig.mjs.map +1 -1
- package/dist/config/getAdditionalViteConfig.native.js +33 -62
- package/dist/config/getAdditionalViteConfig.native.js.map +1 -1
- package/dist/config/getBaseViteConfigOnly.mjs +84 -77
- package/dist/config/getBaseViteConfigOnly.mjs.map +1 -1
- package/dist/config/getBaseViteConfigOnly.native.js +86 -79
- package/dist/config/getBaseViteConfigOnly.native.js.map +1 -1
- package/dist/config/getBaseViteConfigWithPlugins.mjs +6 -4
- package/dist/config/getBaseViteConfigWithPlugins.mjs.map +1 -1
- package/dist/config/getBaseViteConfigWithPlugins.native.js +6 -4
- package/dist/config/getBaseViteConfigWithPlugins.native.js.map +1 -1
- package/dist/config/getBaseVitePlugins.mjs +102 -130
- package/dist/config/getBaseVitePlugins.mjs.map +1 -1
- package/dist/config/getBaseVitePlugins.native.js +123 -152
- package/dist/config/getBaseVitePlugins.native.js.map +1 -1
- package/dist/config/getNonCliModeOnlyVitePlugins.mjs +3 -3
- package/dist/config/getNonCliModeOnlyVitePlugins.mjs.map +1 -1
- package/dist/config/getNonCliModeOnlyVitePlugins.native.js +3 -1
- package/dist/config/getNonCliModeOnlyVitePlugins.native.js.map +1 -1
- package/dist/config/getOptimizeDeps.mjs +138 -42
- package/dist/config/getOptimizeDeps.mjs.map +1 -1
- package/dist/config/getOptimizeDeps.native.js +138 -42
- package/dist/config/getOptimizeDeps.native.js.map +1 -1
- package/dist/config/getOptionsFilled.mjs +48 -52
- package/dist/config/getOptionsFilled.mjs.map +1 -1
- package/dist/config/getOptionsFilled.native.js +51 -55
- package/dist/config/getOptionsFilled.native.js.map +1 -1
- package/dist/config/getReactNativePlugins.mjs +23 -15
- package/dist/config/getReactNativePlugins.mjs.map +1 -1
- package/dist/config/getReactNativePlugins.native.js +25 -16
- package/dist/config/getReactNativePlugins.native.js.map +1 -1
- package/dist/config/getServerOptionsFilled.mjs +33 -35
- package/dist/config/getServerOptionsFilled.mjs.map +1 -1
- package/dist/config/getServerOptionsFilled.native.js +35 -38
- package/dist/config/getServerOptionsFilled.native.js.map +1 -1
- package/dist/config/getViteServerConfig.mjs +34 -45
- package/dist/config/getViteServerConfig.mjs.map +1 -1
- package/dist/config/getViteServerConfig.native.js +35 -46
- package/dist/config/getViteServerConfig.native.js.map +1 -1
- package/dist/config/mergeUserConfig.mjs +50 -28
- package/dist/config/mergeUserConfig.mjs.map +1 -1
- package/dist/config/mergeUserConfig.native.js +60 -38
- package/dist/config/mergeUserConfig.native.js.map +1 -1
- package/dist/constants/defaults.mjs +29 -12
- package/dist/constants/defaults.mjs.map +1 -1
- package/dist/constants/defaults.native.js +29 -12
- package/dist/constants/defaults.native.js.map +1 -1
- package/dist/constants.mjs +41 -6
- package/dist/constants.mjs.map +1 -1
- package/dist/constants.native.js +41 -6
- package/dist/constants.native.js.map +1 -1
- package/dist/exports/build.mjs +218 -270
- package/dist/exports/build.mjs.map +1 -1
- package/dist/exports/build.native.js +226 -283
- package/dist/exports/build.native.js.map +1 -1
- package/dist/exports/clean.mjs +71 -78
- package/dist/exports/clean.mjs.map +1 -1
- package/dist/exports/clean.native.js +76 -90
- package/dist/exports/clean.native.js.map +1 -1
- package/dist/exports/createServer.mjs +43 -46
- package/dist/exports/createServer.mjs.map +1 -1
- package/dist/exports/createServer.native.js +45 -48
- package/dist/exports/createServer.native.js.map +1 -1
- package/dist/exports/dev.mjs +177 -201
- package/dist/exports/dev.mjs.map +1 -1
- package/dist/exports/dev.native.js +191 -215
- package/dist/exports/dev.native.js.map +1 -1
- package/dist/exports/loadEnv.mjs +51 -48
- package/dist/exports/loadEnv.mjs.map +1 -1
- package/dist/exports/loadEnv.native.js +59 -57
- package/dist/exports/loadEnv.native.js.map +1 -1
- package/dist/exports/patch.mjs +9 -7
- package/dist/exports/patch.mjs.map +1 -1
- package/dist/exports/patch.native.js +9 -7
- package/dist/exports/patch.native.js.map +1 -1
- package/dist/exports/prebuild.mjs +177 -157
- package/dist/exports/prebuild.mjs.map +1 -1
- package/dist/exports/prebuild.native.js +197 -160
- package/dist/exports/prebuild.native.js.map +1 -1
- package/dist/exports/prebuildWithoutExpo.mjs +46 -44
- package/dist/exports/prebuildWithoutExpo.mjs.map +1 -1
- package/dist/exports/prebuildWithoutExpo.native.js +48 -46
- package/dist/exports/prebuildWithoutExpo.native.js.map +1 -1
- package/dist/exports/runAndroid.mjs +9 -10
- package/dist/exports/runAndroid.mjs.map +1 -1
- package/dist/exports/runAndroid.native.js +10 -11
- package/dist/exports/runAndroid.native.js.map +1 -1
- package/dist/exports/runIos.mjs +9 -10
- package/dist/exports/runIos.mjs.map +1 -1
- package/dist/exports/runIos.native.js +10 -11
- package/dist/exports/runIos.native.js.map +1 -1
- package/dist/exports/serve.mjs +23 -31
- package/dist/exports/serve.mjs.map +1 -1
- package/dist/exports/serve.native.js +26 -34
- package/dist/exports/serve.native.js.map +1 -1
- package/dist/exports/serveStaticAssets.mjs +109 -113
- package/dist/exports/serveStaticAssets.mjs.map +1 -1
- package/dist/exports/serveStaticAssets.native.js +180 -192
- package/dist/exports/serveStaticAssets.native.js.map +1 -1
- package/dist/index.js +25 -14
- package/dist/index.mjs +25 -14
- package/dist/index.native.js +25 -14
- package/dist/patches/builtInDepPatches.mjs +346 -435
- package/dist/patches/builtInDepPatches.mjs.map +1 -1
- package/dist/patches/builtInDepPatches.native.js +349 -438
- package/dist/patches/builtInDepPatches.native.js.map +1 -1
- package/dist/plugins/applyBuiltInPatchesPlugin.mjs +11 -11
- package/dist/plugins/applyBuiltInPatchesPlugin.mjs.map +1 -1
- package/dist/plugins/applyBuiltInPatchesPlugin.native.js +11 -11
- package/dist/plugins/applyBuiltInPatchesPlugin.native.js.map +1 -1
- package/dist/plugins/autoDepOptimizePlugin.mjs +87 -90
- package/dist/plugins/autoDepOptimizePlugin.mjs.map +1 -1
- package/dist/plugins/autoDepOptimizePlugin.native.js +99 -102
- package/dist/plugins/autoDepOptimizePlugin.native.js.map +1 -1
- package/dist/plugins/clientInjectPlugin.mjs +13 -11
- package/dist/plugins/clientInjectPlugin.mjs.map +1 -1
- package/dist/plugins/clientInjectPlugin.native.js +13 -11
- package/dist/plugins/clientInjectPlugin.native.js.map +1 -1
- package/dist/plugins/defaultDepOptimizePlugin.mjs +15 -23
- package/dist/plugins/defaultDepOptimizePlugin.mjs.map +1 -1
- package/dist/plugins/defaultDepOptimizePlugin.native.js +15 -23
- package/dist/plugins/defaultDepOptimizePlugin.native.js.map +1 -1
- package/dist/plugins/expoManifestRequestHandlerPlugin.mjs +163 -179
- package/dist/plugins/expoManifestRequestHandlerPlugin.mjs.map +1 -1
- package/dist/plugins/expoManifestRequestHandlerPlugin.native.js +169 -191
- package/dist/plugins/expoManifestRequestHandlerPlugin.native.js.map +1 -1
- package/dist/plugins/getResolvedConfigSubset.mjs +6 -5
- package/dist/plugins/getResolvedConfigSubset.mjs.map +1 -1
- package/dist/plugins/getResolvedConfigSubset.native.js +6 -5
- package/dist/plugins/getResolvedConfigSubset.native.js.map +1 -1
- package/dist/plugins/reactNativeCommonJsPlugin.mjs +210 -178
- package/dist/plugins/reactNativeCommonJsPlugin.mjs.map +1 -1
- package/dist/plugins/reactNativeCommonJsPlugin.native.js +283 -259
- package/dist/plugins/reactNativeCommonJsPlugin.native.js.map +1 -1
- package/dist/plugins/reactNativeDevAssetPlugin.mjs +72 -83
- package/dist/plugins/reactNativeDevAssetPlugin.mjs.map +1 -1
- package/dist/plugins/reactNativeDevAssetPlugin.native.js +75 -92
- package/dist/plugins/reactNativeDevAssetPlugin.native.js.map +1 -1
- package/dist/plugins/reactNativeDevServer.mjs +283 -328
- package/dist/plugins/reactNativeDevServer.mjs.map +1 -1
- package/dist/plugins/reactNativeDevServer.native.js +332 -391
- package/dist/plugins/reactNativeDevServer.native.js.map +1 -1
- package/dist/plugins/rnCodegenPlugin.mjs +13 -12
- package/dist/plugins/rnCodegenPlugin.mjs.map +1 -1
- package/dist/plugins/rnCodegenPlugin.native.js +13 -12
- package/dist/plugins/rnCodegenPlugin.native.js.map +1 -1
- package/dist/plugins/rollupRemoveUnusedImports.mjs +8 -7
- package/dist/plugins/rollupRemoveUnusedImports.mjs.map +1 -1
- package/dist/plugins/rollupRemoveUnusedImports.native.js +8 -7
- package/dist/plugins/rollupRemoveUnusedImports.native.js.map +1 -1
- package/dist/plugins/workletImportsPlugin.mjs +127 -132
- package/dist/plugins/workletImportsPlugin.mjs.map +1 -1
- package/dist/plugins/workletImportsPlugin.native.js +192 -203
- package/dist/plugins/workletImportsPlugin.native.js.map +1 -1
- package/dist/rn-commands/bundle/buildBundle.mjs +45 -79
- package/dist/rn-commands/bundle/buildBundle.mjs.map +1 -1
- package/dist/rn-commands/bundle/buildBundle.native.js +45 -85
- package/dist/rn-commands/bundle/buildBundle.native.js.map +1 -1
- package/dist/runtime/hmr-client.mjs +133 -140
- package/dist/runtime/hmr-client.mjs.map +1 -1
- package/dist/runtime/hmr-client.native.js +223 -222
- package/dist/runtime/hmr-client.native.js.map +1 -1
- package/dist/runtime/hmr-runtime.mjs +192 -194
- package/dist/runtime/hmr-runtime.mjs.map +1 -1
- package/dist/runtime/hmr-runtime.native.js +424 -411
- package/dist/runtime/hmr-runtime.native.js.map +1 -1
- package/dist/runtime/hmr-types.mjs +0 -2
- package/dist/runtime/hmr-types.native.js +0 -2
- package/dist/runtime/native-prelude.mjs +2 -1
- package/dist/runtime/native-prelude.mjs.map +1 -1
- package/dist/runtime/native-prelude.native.js +2 -1
- package/dist/runtime/native-prelude.native.js.map +1 -1
- package/dist/runtime/react-refresh-utils.mjs +23 -22
- package/dist/runtime/react-refresh-utils.mjs.map +1 -1
- package/dist/runtime/react-refresh-utils.native.js +23 -27
- package/dist/runtime/react-refresh-utils.native.js.map +1 -1
- package/dist/serve/node.mjs +49 -49
- package/dist/serve/node.mjs.map +1 -1
- package/dist/serve/node.native.js +92 -96
- package/dist/serve/node.native.js.map +1 -1
- package/dist/types.mjs +0 -2
- package/dist/types.native.js +0 -2
- package/dist/user-interface/index.mjs +245 -262
- package/dist/user-interface/index.mjs.map +1 -1
- package/dist/user-interface/index.native.js +274 -298
- package/dist/user-interface/index.native.js.map +1 -1
- package/dist/utils/assert.mjs +7 -6
- package/dist/utils/assert.mjs.map +1 -1
- package/dist/utils/assert.native.js +7 -18
- package/dist/utils/assert.native.js.map +1 -1
- package/dist/utils/bindKeypressInput.mjs +36 -38
- package/dist/utils/bindKeypressInput.mjs.map +1 -1
- package/dist/utils/bindKeypressInput.native.js +36 -38
- package/dist/utils/bindKeypressInput.native.js.map +1 -1
- package/dist/utils/coerceToArray.mjs +2 -1
- package/dist/utils/coerceToArray.mjs.map +1 -1
- package/dist/utils/coerceToArray.native.js +2 -1
- package/dist/utils/coerceToArray.native.js.map +1 -1
- package/dist/utils/connectedNativeClients.mjs +3 -2
- package/dist/utils/connectedNativeClients.mjs.map +1 -1
- package/dist/utils/connectedNativeClients.native.js +3 -2
- package/dist/utils/connectedNativeClients.native.js.map +1 -1
- package/dist/utils/createNativeDevEngine.mjs +992 -966
- package/dist/utils/createNativeDevEngine.mjs.map +1 -1
- package/dist/utils/createNativeDevEngine.native.js +1184 -1179
- package/dist/utils/createNativeDevEngine.native.js.map +1 -1
- package/dist/utils/dispose.mjs +4 -3
- package/dist/utils/dispose.mjs.map +1 -1
- package/dist/utils/dispose.native.js +6 -5
- package/dist/utils/dispose.native.js.map +1 -1
- package/dist/utils/environmentUtils.mjs +5 -4
- package/dist/utils/environmentUtils.mjs.map +1 -1
- package/dist/utils/environmentUtils.native.js +5 -4
- package/dist/utils/environmentUtils.native.js.map +1 -1
- package/dist/utils/execSync.mjs +7 -5
- package/dist/utils/execSync.mjs.map +1 -1
- package/dist/utils/execSync.native.js +8 -6
- package/dist/utils/execSync.native.js.map +1 -1
- package/dist/utils/expoRun.mjs +27 -35
- package/dist/utils/expoRun.mjs.map +1 -1
- package/dist/utils/expoRun.native.js +27 -35
- package/dist/utils/expoRun.native.js.map +1 -1
- package/dist/utils/filterViteServerResolvedUrls.mjs +24 -22
- package/dist/utils/filterViteServerResolvedUrls.mjs.map +1 -1
- package/dist/utils/filterViteServerResolvedUrls.native.js +61 -63
- package/dist/utils/filterViteServerResolvedUrls.native.js.map +1 -1
- package/dist/utils/getBoundPort.mjs +6 -5
- package/dist/utils/getBoundPort.mjs.map +1 -1
- package/dist/utils/getBoundPort.native.js +8 -12
- package/dist/utils/getBoundPort.native.js.map +1 -1
- package/dist/utils/getCacheDir.mjs +3 -1
- package/dist/utils/getCacheDir.mjs.map +1 -1
- package/dist/utils/getCacheDir.native.js +3 -1
- package/dist/utils/getCacheDir.native.js.map +1 -1
- package/dist/utils/getServerEntry.mjs +6 -4
- package/dist/utils/getServerEntry.mjs.map +1 -1
- package/dist/utils/getServerEntry.native.js +8 -11
- package/dist/utils/getServerEntry.native.js.map +1 -1
- package/dist/utils/getVitePath.mjs +42 -42
- package/dist/utils/getVitePath.mjs.map +1 -1
- package/dist/utils/getVitePath.native.js +43 -41
- package/dist/utils/getVitePath.native.js.map +1 -1
- package/dist/utils/globDir.mjs +7 -11
- package/dist/utils/globDir.mjs.map +1 -1
- package/dist/utils/globDir.native.js +10 -14
- package/dist/utils/globDir.native.js.map +1 -1
- package/dist/utils/isWithin.mjs +4 -2
- package/dist/utils/isWithin.mjs.map +1 -1
- package/dist/utils/isWithin.native.js +4 -2
- package/dist/utils/isWithin.native.js.map +1 -1
- package/dist/utils/patches.mjs +233 -255
- package/dist/utils/patches.mjs.map +1 -1
- package/dist/utils/patches.native.js +415 -460
- package/dist/utils/patches.native.js.map +1 -1
- package/dist/utils/printServerUrls.mjs +9 -7
- package/dist/utils/printServerUrls.mjs.map +1 -1
- package/dist/utils/printServerUrls.native.js +48 -51
- package/dist/utils/printServerUrls.native.js.map +1 -1
- package/dist/utils/removeUndefined.mjs +8 -7
- package/dist/utils/removeUndefined.mjs.map +1 -1
- package/dist/utils/removeUndefined.native.js +8 -7
- package/dist/utils/removeUndefined.native.js.map +1 -1
- package/dist/utils/scanDepsToOptimize.mjs +194 -161
- package/dist/utils/scanDepsToOptimize.mjs.map +1 -1
- package/dist/utils/scanDepsToOptimize.native.js +227 -197
- package/dist/utils/scanDepsToOptimize.native.js.map +1 -1
- package/dist/utils/state.mjs +18 -18
- package/dist/utils/state.mjs.map +1 -1
- package/dist/utils/state.native.js +18 -18
- package/dist/utils/state.native.js.map +1 -1
- package/dist/utils/symbolicateNativeStack.mjs +54 -54
- package/dist/utils/symbolicateNativeStack.mjs.map +1 -1
- package/dist/utils/symbolicateNativeStack.native.js +58 -58
- package/dist/utils/symbolicateNativeStack.native.js.map +1 -1
- package/dist/utils/uniq.mjs +2 -1
- package/dist/utils/uniq.mjs.map +1 -1
- package/dist/utils/uniq.native.js +2 -1
- package/dist/utils/uniq.native.js.map +1 -1
- package/dist/utils/utils.mjs +19 -19
- package/dist/utils/utils.mjs.map +1 -1
- package/dist/utils/utils.native.js +38 -40
- package/dist/utils/utils.native.js.map +1 -1
- package/dist/vendor/debugger-app/index.mjs +0 -2
- package/dist/vendor/debugger-app/index.native.js +0 -2
- package/dist/vendor/debugger-app/src/debuggerWorker.mjs +0 -2
- package/dist/vendor/debugger-app/src/debuggerWorker.native.js +0 -2
- package/dist/vendor/debugger-app/src/index.mjs +0 -2
- package/dist/vendor/debugger-app/src/index.native.js +0 -2
- package/dist/vxrn-vite-plugin.mjs +34 -33
- package/dist/vxrn-vite-plugin.mjs.map +1 -1
- package/dist/vxrn-vite-plugin.native.js +35 -34
- package/dist/vxrn-vite-plugin.native.js.map +1 -1
- package/expo-plugin.cjs +12 -6
- package/package.json +12 -13
- package/src/config/getBaseViteConfigOnly.ts +6 -0
- package/src/exports/prebuild.ts +40 -12
- package/src/patches/builtInDepPatches.ts +24 -48
- package/src/utils/createNativeDevEngine.test.ts +1 -1
- package/src/utils/createNativeDevEngine.ts +15 -9
- package/src/utils/scanDepsToOptimize.ts +0 -3
- package/types/config/getBaseViteConfigOnly.d.ts.map +1 -1
- package/types/config/getOptimizeDeps.d.ts.map +1 -1
- package/types/config/getOptionsFilled.d.ts +15 -15
- package/types/config/getOptionsFilled.d.ts.map +1 -1
- package/types/exports/build.d.ts +11 -11
- package/types/exports/build.d.ts.map +1 -1
- package/types/exports/clean.d.ts +1 -1
- package/types/exports/clean.d.ts.map +1 -1
- package/types/exports/createServer.d.ts.map +1 -1
- package/types/exports/dev.d.ts.map +1 -1
- package/types/exports/patch.d.ts.map +1 -1
- package/types/exports/prebuild.d.ts +3 -3
- package/types/exports/prebuild.d.ts.map +1 -1
- package/types/exports/prebuildWithoutExpo.d.ts +1 -1
- package/types/exports/prebuildWithoutExpo.d.ts.map +1 -1
- package/types/exports/runAndroid.d.ts.map +1 -1
- package/types/exports/runIos.d.ts.map +1 -1
- package/types/exports/serve.d.ts.map +1 -1
- package/types/patches/builtInDepPatches.d.ts.map +1 -1
- package/types/plugins/autoDepOptimizePlugin.d.ts.map +1 -1
- package/types/plugins/rollupRemoveUnusedImports.d.ts.map +1 -1
- package/types/runtime/hmr-client.d.ts.map +1 -1
- package/types/runtime/hmr-runtime.d.ts.map +1 -1
- package/types/runtime/hmr-types.d.ts.map +1 -1
- package/types/utils/createNativeDevEngine.d.ts +1 -1
- package/types/utils/createNativeDevEngine.d.ts.map +1 -1
- package/types/utils/execSync.d.ts.map +1 -1
- package/types/utils/getServerEntry.d.ts.map +1 -1
- package/types/utils/scanDepsToOptimize.d.ts.map +1 -1
- package/types/vxrn-vite-plugin.d.ts.map +1 -1
- package/dist/config/getOptimizeDeps.test.mjs +0 -20
- package/dist/config/getOptimizeDeps.test.mjs.map +0 -1
- package/dist/config/getOptimizeDeps.test.native.js +0 -39
- package/dist/config/getOptimizeDeps.test.native.js.map +0 -1
- package/dist/config/getServerOptionsFilled.test.mjs +0 -20
- package/dist/config/getServerOptionsFilled.test.mjs.map +0 -1
- package/dist/config/getServerOptionsFilled.test.native.js +0 -20
- package/dist/config/getServerOptionsFilled.test.native.js.map +0 -1
- package/dist/config/getViteServerConfig.test.mjs +0 -26
- package/dist/config/getViteServerConfig.test.mjs.map +0 -1
- package/dist/config/getViteServerConfig.test.native.js +0 -26
- package/dist/config/getViteServerConfig.test.native.js.map +0 -1
- package/dist/config/mergeUserConfig.test.mjs +0 -108
- package/dist/config/mergeUserConfig.test.mjs.map +0 -1
- package/dist/config/mergeUserConfig.test.native.js +0 -108
- package/dist/config/mergeUserConfig.test.native.js.map +0 -1
- package/dist/exports/clean.test.mjs +0 -81
- package/dist/exports/clean.test.mjs.map +0 -1
- package/dist/exports/clean.test.native.js +0 -88
- package/dist/exports/clean.test.native.js.map +0 -1
- package/dist/exports/loadEnv.test.mjs +0 -65
- package/dist/exports/loadEnv.test.mjs.map +0 -1
- package/dist/exports/loadEnv.test.native.js +0 -65
- package/dist/exports/loadEnv.test.native.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/index.native.js.map +0 -1
- package/dist/plugins/autoDepOptimizePlugin.test.mjs +0 -31
- package/dist/plugins/autoDepOptimizePlugin.test.mjs.map +0 -1
- package/dist/plugins/autoDepOptimizePlugin.test.native.js +0 -39
- package/dist/plugins/autoDepOptimizePlugin.test.native.js.map +0 -1
- package/dist/plugins/resolveIdScan.test.mjs +0 -31
- package/dist/plugins/resolveIdScan.test.mjs.map +0 -1
- package/dist/plugins/resolveIdScan.test.native.js +0 -38
- package/dist/plugins/resolveIdScan.test.native.js.map +0 -1
- package/dist/plugins/rnCodegenPlugin.test.mjs +0 -239
- package/dist/plugins/rnCodegenPlugin.test.mjs.map +0 -1
- package/dist/plugins/rnCodegenPlugin.test.native.js +0 -242
- package/dist/plugins/rnCodegenPlugin.test.native.js.map +0 -1
- package/dist/plugins/serverExtensions.test.mjs +0 -106
- package/dist/plugins/serverExtensions.test.mjs.map +0 -1
- package/dist/plugins/serverExtensions.test.native.js +0 -117
- package/dist/plugins/serverExtensions.test.native.js.map +0 -1
- package/dist/runtime/hmr-types.mjs.map +0 -1
- package/dist/runtime/hmr-types.native.js.map +0 -1
- package/dist/serve/node.test.mjs +0 -60
- package/dist/serve/node.test.mjs.map +0 -1
- package/dist/serve/node.test.native.js +0 -72
- package/dist/serve/node.test.native.js.map +0 -1
- package/dist/types.mjs.map +0 -1
- package/dist/types.native.js.map +0 -1
- package/dist/utils/bindKeypressInput.test.mjs +0 -48
- package/dist/utils/bindKeypressInput.test.mjs.map +0 -1
- package/dist/utils/bindKeypressInput.test.native.js +0 -48
- package/dist/utils/bindKeypressInput.test.native.js.map +0 -1
- package/dist/utils/createNativeDevEngine.test.mjs +0 -1788
- package/dist/utils/createNativeDevEngine.test.mjs.map +0 -1
- package/dist/utils/createNativeDevEngine.test.native.js +0 -1942
- package/dist/utils/createNativeDevEngine.test.native.js.map +0 -1
- package/dist/utils/createNativeDevEngineFailure.test.mjs +0 -44
- package/dist/utils/createNativeDevEngineFailure.test.mjs.map +0 -1
- package/dist/utils/createNativeDevEngineFailure.test.native.js +0 -54
- package/dist/utils/createNativeDevEngineFailure.test.native.js.map +0 -1
- package/dist/utils/getBoundPort.test.mjs +0 -71
- package/dist/utils/getBoundPort.test.mjs.map +0 -1
- package/dist/utils/getBoundPort.test.native.js +0 -82
- package/dist/utils/getBoundPort.test.native.js.map +0 -1
- package/dist/utils/imageSizePatch.test.mjs +0 -29
- package/dist/utils/imageSizePatch.test.mjs.map +0 -1
- package/dist/utils/imageSizePatch.test.native.js +0 -30
- package/dist/utils/imageSizePatch.test.native.js.map +0 -1
- package/dist/utils/patches.test.mjs +0 -242
- package/dist/utils/patches.test.mjs.map +0 -1
- package/dist/utils/patches.test.native.js +0 -271
- package/dist/utils/patches.test.native.js.map +0 -1
- package/dist/utils/symbolicateNativeStack.test.mjs +0 -96
- package/dist/utils/symbolicateNativeStack.test.mjs.map +0 -1
- package/dist/utils/symbolicateNativeStack.test.native.js +0 -96
- package/dist/utils/symbolicateNativeStack.test.native.js.map +0 -1
- package/dist/vendor/debugger-app/index.mjs.map +0 -1
- package/dist/vendor/debugger-app/index.native.js.map +0 -1
- package/dist/vendor/debugger-app/src/debuggerWorker.mjs.map +0 -1
- package/dist/vendor/debugger-app/src/debuggerWorker.native.js.map +0 -1
- package/dist/vendor/debugger-app/src/index.mjs.map +0 -1
- package/dist/vendor/debugger-app/src/index.native.js.map +0 -1
- package/types/config/getOptimizeDeps.test.d.ts +0 -2
- package/types/config/getOptimizeDeps.test.d.ts.map +0 -1
- package/types/config/getServerOptionsFilled.test.d.ts +0 -2
- package/types/config/getServerOptionsFilled.test.d.ts.map +0 -1
- package/types/config/getViteServerConfig.test.d.ts +0 -2
- package/types/config/getViteServerConfig.test.d.ts.map +0 -1
- package/types/config/mergeUserConfig.test.d.ts +0 -2
- package/types/config/mergeUserConfig.test.d.ts.map +0 -1
- package/types/exports/clean.test.d.ts +0 -2
- package/types/exports/clean.test.d.ts.map +0 -1
- package/types/exports/loadEnv.test.d.ts +0 -2
- package/types/exports/loadEnv.test.d.ts.map +0 -1
- package/types/plugins/autoDepOptimizePlugin.test.d.ts +0 -2
- package/types/plugins/autoDepOptimizePlugin.test.d.ts.map +0 -1
- package/types/plugins/resolveIdScan.test.d.ts +0 -2
- package/types/plugins/resolveIdScan.test.d.ts.map +0 -1
- package/types/plugins/rnCodegenPlugin.test.d.ts +0 -2
- package/types/plugins/rnCodegenPlugin.test.d.ts.map +0 -1
- package/types/plugins/serverExtensions.test.d.ts +0 -2
- package/types/plugins/serverExtensions.test.d.ts.map +0 -1
- package/types/serve/node.test.d.ts +0 -2
- package/types/serve/node.test.d.ts.map +0 -1
- package/types/utils/bindKeypressInput.test.d.ts +0 -2
- package/types/utils/bindKeypressInput.test.d.ts.map +0 -1
- package/types/utils/createNativeDevEngine.test.d.ts +0 -2
- package/types/utils/createNativeDevEngine.test.d.ts.map +0 -1
- package/types/utils/createNativeDevEngineFailure.test.d.ts +0 -2
- package/types/utils/createNativeDevEngineFailure.test.d.ts.map +0 -1
- package/types/utils/getBoundPort.test.d.ts +0 -2
- package/types/utils/getBoundPort.test.d.ts.map +0 -1
- package/types/utils/imageSizePatch.test.d.ts +0 -2
- package/types/utils/imageSizePatch.test.d.ts.map +0 -1
- package/types/utils/patches.test.d.ts +0 -2
- package/types/utils/patches.test.d.ts.map +0 -1
- package/types/utils/symbolicateNativeStack.test.d.ts +0 -2
- package/types/utils/symbolicateNativeStack.test.d.ts.map +0 -1
|
@@ -9,285 +9,314 @@ import { resolvePath } from "@vxrn/resolve";
|
|
|
9
9
|
import { DEFAULT_ASSET_EXTS } from "../constants/defaults.mjs";
|
|
10
10
|
import { getNativePrelude } from "../runtime/native-prelude.mjs";
|
|
11
11
|
import { rnCodegenPlugin } from "../plugins/rnCodegenPlugin.mjs";
|
|
12
|
-
|
|
12
|
+
|
|
13
|
+
const HERMES_CLASS_TRANSFORMS = [
|
|
14
|
+
"transform-classes",
|
|
15
|
+
"transform-parameters",
|
|
16
|
+
"transform-block-scoping",
|
|
17
|
+
"transform-class-properties",
|
|
18
|
+
"transform-class-static-block",
|
|
19
|
+
"transform-private-methods",
|
|
20
|
+
"transform-private-property-in-object"
|
|
21
|
+
];
|
|
13
22
|
const HERMES_ASYNC_TRANSFORMS = ["transform-async-to-generator"];
|
|
14
23
|
function getHermesSWCIncludes(dev) {
|
|
15
|
-
|
|
24
|
+
return [...HERMES_CLASS_TRANSFORMS, ...HERMES_ASYNC_TRANSFORMS];
|
|
16
25
|
}
|
|
17
26
|
function getResolveExtensions(platform) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
27
|
+
const platformExts = platform === "ios" ? [
|
|
28
|
+
".ios.tsx",
|
|
29
|
+
".ios.ts",
|
|
30
|
+
".ios.jsx",
|
|
31
|
+
".ios.js"
|
|
32
|
+
] : [
|
|
33
|
+
".android.tsx",
|
|
34
|
+
".android.ts",
|
|
35
|
+
".android.jsx",
|
|
36
|
+
".android.js"
|
|
37
|
+
];
|
|
38
|
+
const nativeExts = [
|
|
39
|
+
".native.tsx",
|
|
40
|
+
".native.ts",
|
|
41
|
+
".native.jsx",
|
|
42
|
+
".native.js"
|
|
43
|
+
];
|
|
44
|
+
const defaultExts = [
|
|
45
|
+
".tsx",
|
|
46
|
+
".ts",
|
|
47
|
+
".jsx",
|
|
48
|
+
".js",
|
|
49
|
+
".mjs",
|
|
50
|
+
".cjs",
|
|
51
|
+
".json"
|
|
52
|
+
];
|
|
53
|
+
return [
|
|
54
|
+
...platformExts,
|
|
55
|
+
...nativeExts,
|
|
56
|
+
...defaultExts
|
|
57
|
+
];
|
|
22
58
|
}
|
|
23
59
|
function getNativeResolveConfig(platform) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
60
|
+
return {
|
|
61
|
+
extensions: getResolveExtensions(platform),
|
|
62
|
+
conditionNames: ["react-native"],
|
|
63
|
+
mainFields: [
|
|
64
|
+
"react-native",
|
|
65
|
+
"module",
|
|
66
|
+
"main"
|
|
67
|
+
]
|
|
68
|
+
};
|
|
29
69
|
}
|
|
30
70
|
function getNativeTransformConfig(platform, dev, root) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
"import.meta.env.SSR": "false",
|
|
102
|
-
"import.meta.env.VITE_ENVIRONMENT": JSON.stringify(platform),
|
|
103
|
-
"import.meta.env.VITE_NATIVE": "\"1\"",
|
|
104
|
-
"import.meta.env.EXPO_OS": JSON.stringify(platform),
|
|
105
|
-
"import.meta.env.TAMAGUI_TARGET": "\"native\"",
|
|
106
|
-
"import.meta.env.TAMAGUI_ENVIRONMENT": JSON.stringify(platform),
|
|
107
|
-
...setupFileDefines
|
|
108
|
-
},
|
|
109
|
-
inject: {
|
|
110
|
-
React: "react"
|
|
111
|
-
}
|
|
112
|
-
};
|
|
71
|
+
const entryConfig = globalThis.__vxrnNativeEntryConfig || {};
|
|
72
|
+
const setupFileDefines = (() => {
|
|
73
|
+
const sf = entryConfig.setupFile;
|
|
74
|
+
if (!sf) return {};
|
|
75
|
+
const files = typeof sf === "string" ? {
|
|
76
|
+
client: sf,
|
|
77
|
+
server: sf,
|
|
78
|
+
ios: sf,
|
|
79
|
+
android: sf
|
|
80
|
+
} : "native" in sf ? {
|
|
81
|
+
client: sf.client,
|
|
82
|
+
server: sf.server,
|
|
83
|
+
ios: sf.native,
|
|
84
|
+
android: sf.native
|
|
85
|
+
} : sf;
|
|
86
|
+
return {
|
|
87
|
+
...files.client && { "process.env.ONE_SETUP_FILE_CLIENT": JSON.stringify(files.client) },
|
|
88
|
+
...files.server && { "process.env.ONE_SETUP_FILE_SERVER": JSON.stringify(files.server) },
|
|
89
|
+
...files.ios && { "process.env.ONE_SETUP_FILE_IOS": JSON.stringify(files.ios) },
|
|
90
|
+
...files.android && { "process.env.ONE_SETUP_FILE_ANDROID": JSON.stringify(files.android) }
|
|
91
|
+
};
|
|
92
|
+
})();
|
|
93
|
+
const userDefines = {};
|
|
94
|
+
for (const [key, value] of Object.entries(globalThis.__vxrnNativeUserDefine || {})) userDefines[key] = typeof value === "string" ? value : JSON.stringify(value);
|
|
95
|
+
const mode = dev ? "development" : "production";
|
|
96
|
+
const publicEnv = loadEnv(mode, root, ["VITE_", "EXPO_PUBLIC_"]);
|
|
97
|
+
const envDefines = {};
|
|
98
|
+
for (const [key, value] of Object.entries(publicEnv)) {
|
|
99
|
+
envDefines[`import.meta.env.${key}`] = JSON.stringify(value);
|
|
100
|
+
envDefines[`process.env.${key}`] = JSON.stringify(value);
|
|
101
|
+
}
|
|
102
|
+
const envObject = {
|
|
103
|
+
...publicEnv,
|
|
104
|
+
MODE: mode,
|
|
105
|
+
DEV: dev,
|
|
106
|
+
PROD: !dev,
|
|
107
|
+
SSR: false,
|
|
108
|
+
VITE_ENVIRONMENT: platform,
|
|
109
|
+
VITE_NATIVE: "1",
|
|
110
|
+
EXPO_OS: platform,
|
|
111
|
+
TAMAGUI_TARGET: "native",
|
|
112
|
+
TAMAGUI_ENVIRONMENT: platform
|
|
113
|
+
};
|
|
114
|
+
return {
|
|
115
|
+
jsx: { runtime: "classic" },
|
|
116
|
+
define: {
|
|
117
|
+
...userDefines,
|
|
118
|
+
...envDefines,
|
|
119
|
+
"process.env.NODE_ENV": JSON.stringify(mode),
|
|
120
|
+
"process.env.VXRN_REACT_19": "false",
|
|
121
|
+
"process.env.VITE_ENVIRONMENT": JSON.stringify(platform),
|
|
122
|
+
"process.env.VITE_NATIVE": "\"1\"",
|
|
123
|
+
"process.env.EXPO_OS": JSON.stringify(platform),
|
|
124
|
+
"process.env.TAMAGUI_TARGET": "\"native\"",
|
|
125
|
+
"process.env.TAMAGUI_ENVIRONMENT": JSON.stringify(platform),
|
|
126
|
+
__DEV__: dev ? "true" : "false",
|
|
127
|
+
"import.meta.env": JSON.stringify(envObject),
|
|
128
|
+
"import.meta.env.MODE": JSON.stringify(mode),
|
|
129
|
+
"import.meta.env.DEV": dev ? "true" : "false",
|
|
130
|
+
"import.meta.env.PROD": dev ? "false" : "true",
|
|
131
|
+
"import.meta.env.SSR": "false",
|
|
132
|
+
"import.meta.env.VITE_ENVIRONMENT": JSON.stringify(platform),
|
|
133
|
+
"import.meta.env.VITE_NATIVE": "\"1\"",
|
|
134
|
+
"import.meta.env.EXPO_OS": JSON.stringify(platform),
|
|
135
|
+
"import.meta.env.TAMAGUI_TARGET": "\"native\"",
|
|
136
|
+
"import.meta.env.TAMAGUI_ENVIRONMENT": JSON.stringify(platform),
|
|
137
|
+
...setupFileDefines
|
|
138
|
+
},
|
|
139
|
+
inject: { React: "react" }
|
|
140
|
+
};
|
|
113
141
|
}
|
|
114
142
|
function getNativePlugins(root, platform, viteImportGlobPlugin, dev, assetsDest, onAsset, sourceMaps = false, userPlugins = []) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
143
|
+
const context = {
|
|
144
|
+
root,
|
|
145
|
+
platform,
|
|
146
|
+
dev
|
|
147
|
+
};
|
|
148
|
+
return [
|
|
149
|
+
...globalThis.__vxrnAddNativePlugins || [],
|
|
150
|
+
serverFileExclusionPlugin(),
|
|
151
|
+
environmentGuardPlugin(),
|
|
152
|
+
hmrClientNoopPlugin(),
|
|
153
|
+
{
|
|
154
|
+
name: "vxrn:legacy-asset-registry",
|
|
155
|
+
resolveId(source, importer) {
|
|
156
|
+
if (source === "@react-native/assets-registry/registry") return this.resolve("react-native/asset-registry", importer, { skipSelf: true });
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
...dev ? [reactNativeDedupePlugin(root)] : [],
|
|
160
|
+
cssStubPlugin(),
|
|
161
|
+
viteImportGlobPlugin({ root }),
|
|
162
|
+
vxrnCompilerPlugin(platform, dev, root, sourceMaps),
|
|
163
|
+
rnCodegenPlugin({ projectRoot: root }),
|
|
164
|
+
flowStripPlugin(),
|
|
165
|
+
nativeAnimatedGuardPlugin(),
|
|
166
|
+
assetPlugin({
|
|
167
|
+
root,
|
|
168
|
+
platform,
|
|
169
|
+
assetsDest,
|
|
170
|
+
onAsset
|
|
171
|
+
}),
|
|
172
|
+
hermesCompatSWCPlugin(dev, sourceMaps),
|
|
173
|
+
hermesLoopsPlugin(sourceMaps),
|
|
174
|
+
...userPlugins
|
|
175
|
+
].map((plugin) => plugin.api?.vxrnNative ? plugin.api.vxrnNative(context) : plugin);
|
|
130
176
|
}
|
|
131
177
|
function getNativeOutputOptions(prelude, sourcemap, minify) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
178
|
+
return {
|
|
179
|
+
format: "esm",
|
|
180
|
+
sourcemap,
|
|
181
|
+
sourcemapPathTransform: (relativeSourcePath, sourcemapPath) => normalizePath(resolve(dirname(sourcemapPath), relativeSourcePath)),
|
|
182
|
+
intro: prelude,
|
|
183
|
+
codeSplitting: false,
|
|
184
|
+
strictExecutionOrder: true,
|
|
185
|
+
minify: minify || "dce-only"
|
|
186
|
+
};
|
|
141
187
|
}
|
|
142
188
|
function normalizeNativeCommonJSInterop(code) {
|
|
143
|
-
|
|
189
|
+
return code.replace(/(\b__toESM(?:\$\d+)?\(\s*(?:require[\w$]*\(\)|__rolldown_runtime__\.loadExports\("(?:\\.|[^"\\])*"\))\s*),\s*1(\s*\))/g, "$1$2");
|
|
144
190
|
}
|
|
145
191
|
function blankPreservingLines(match) {
|
|
146
|
-
|
|
192
|
+
return "\n".repeat(match.match(/\n/g)?.length ?? 0);
|
|
147
193
|
}
|
|
148
194
|
function countLines(code) {
|
|
149
|
-
|
|
195
|
+
return (code.match(/\n/g)?.length ?? 0) + 1;
|
|
150
196
|
}
|
|
151
197
|
function assertBundleLinesPreserved(before, after, stage) {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
198
|
+
const beforeLines = countLines(before);
|
|
199
|
+
const afterLines = countLines(after);
|
|
200
|
+
if (beforeLines !== afterLines) throw new Error(`[vxrn] native bundle post-processing (${stage}) changed the line count (${beforeLines} -> ${afterLines}), which invalidates the source map. Every pass after Rolldown emits the map must preserve lines.`);
|
|
155
201
|
}
|
|
156
202
|
function postProcessNativeBundle(code) {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
203
|
+
code = normalizeNativeCommonJSInterop(code);
|
|
204
|
+
code = code.replace(/\btypeof\s+import\.meta\b/g, "\"object\"");
|
|
205
|
+
code = code.replace(/^[^\S\n]*export[^\S\n]*\{[^}]*\}[^\S\n]*;?[^\S\n]*$/gm, blankPreservingLines);
|
|
206
|
+
code = code.replace(/^([^\S\n]*)export[^\S\n]+default[^\S\n]+([^;\n]+);?[^\S\n]*$/gm, "$1$2;");
|
|
207
|
+
code = code.replace(/^if \(import\.meta\.hot\).*$/gm, "");
|
|
208
|
+
{
|
|
209
|
+
const idx = code.indexOf("NativeAnimatedModule_default ?? NativeAnimatedTurboModule_default;");
|
|
210
|
+
if (idx !== -1) {
|
|
211
|
+
const beforeMarker = code.lastIndexOf("NativeAnimatedModule = ", idx);
|
|
212
|
+
if (beforeMarker !== -1) {
|
|
213
|
+
const lineStart = code.lastIndexOf("\n", beforeMarker);
|
|
214
|
+
const snippet = code.slice(lineStart + 1, beforeMarker + 50);
|
|
215
|
+
if (snippet.includes("(function()") || snippet.includes("new Proxy")) {
|
|
216
|
+
const afterMarker = code.indexOf("})();", idx);
|
|
217
|
+
if (afterMarker !== -1) {
|
|
218
|
+
const end = afterMarker + 5;
|
|
219
|
+
const removed = code.slice(beforeMarker, end);
|
|
220
|
+
code = code.slice(0, beforeMarker) + "NativeAnimatedModule = NativeAnimatedModule_default ?? NativeAnimatedTurboModule_default;" + blankPreservingLines(removed) + code.slice(end);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return code;
|
|
181
227
|
}
|
|
182
228
|
function wrapNativeBundleModuleScope(code) {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
229
|
+
const idx = code.indexOf("//#region \\0rolldown/runtime.js");
|
|
230
|
+
if (idx === -1) return code;
|
|
231
|
+
return code.slice(0, idx) + ";(function() {" + code.slice(idx) + "\n})();\n";
|
|
186
232
|
}
|
|
187
233
|
async function downlevelClassFieldsInBundle(code) {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
});
|
|
206
|
-
if (result.errors?.length) throw new Error(result.errors.map(e => e.message).join("\n"));
|
|
207
|
-
const transformedCode = result.code.trimEnd();
|
|
208
|
-
const transformed = transformedCode.includes(startMarker) ? transformedCode : `${startMarker}
|
|
234
|
+
const startMarker = "//#region \\0rolldown/runtime.js";
|
|
235
|
+
const endMarker = "//#endregion";
|
|
236
|
+
const startIdx = code.indexOf(startMarker);
|
|
237
|
+
if (startIdx === -1) return code;
|
|
238
|
+
const endIdx = code.indexOf(endMarker, startIdx);
|
|
239
|
+
if (endIdx === -1) return code;
|
|
240
|
+
const runtimeEnd = endIdx + 12;
|
|
241
|
+
const runtimeSection = code.slice(startIdx, runtimeEnd);
|
|
242
|
+
const originalNewlines = runtimeSection.match(/\n/g)?.length ?? 0;
|
|
243
|
+
const { transformSync } = await import("oxc-transform");
|
|
244
|
+
const result = transformSync("rolldown-runtime.js", runtimeSection, {
|
|
245
|
+
target: "es2020",
|
|
246
|
+
assumptions: { setPublicClassFields: true }
|
|
247
|
+
});
|
|
248
|
+
if (result.errors?.length) throw new Error(result.errors.map((e) => e.message).join("\n"));
|
|
249
|
+
const transformedCode = result.code.trimEnd();
|
|
250
|
+
const transformed = transformedCode.includes(startMarker) ? transformedCode : `${startMarker}
|
|
209
251
|
${transformedCode}`;
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
252
|
+
const transformedNewlines = transformed.match(/\n/g)?.length ?? 0;
|
|
253
|
+
if (transformedNewlines > originalNewlines) throw new Error("[vxrn] Hermes runtime transform added lines and would invalidate the production source map");
|
|
254
|
+
const linePreservingRuntime = transformed + "\n".repeat(originalNewlines - transformedNewlines);
|
|
255
|
+
return code.slice(0, startIdx) + linePreservingRuntime + code.slice(runtimeEnd);
|
|
214
256
|
}
|
|
215
257
|
function nativeBundlePostProcessPlugin() {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
258
|
+
return {
|
|
259
|
+
name: "vxrn:native-post-process",
|
|
260
|
+
async renderChunk(code) {
|
|
261
|
+
const processed = await downlevelClassFieldsInBundle(postProcessNativeBundle(code));
|
|
262
|
+
assertBundleLinesPreserved(code, processed, "production");
|
|
263
|
+
return {
|
|
264
|
+
code: processed,
|
|
265
|
+
map: null
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
};
|
|
227
269
|
}
|
|
228
270
|
async function createNativeDevEngine(options) {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
incrementalBuild: true,
|
|
279
|
-
lazyBarrel: true
|
|
280
|
-
},
|
|
281
|
-
treeshake: false,
|
|
282
|
-
shimMissingExports: true,
|
|
283
|
-
moduleTypes: {
|
|
284
|
-
".js": "jsx"
|
|
285
|
-
},
|
|
286
|
-
plugins: [virtualEntry.plugin, ...getNativePlugins(root, platform, viteImportGlobPlugin, true, void 0, assetRegistry.register, true, userPlugins)]
|
|
287
|
-
};
|
|
288
|
-
const outputOptions = {
|
|
289
|
-
...getNativeOutputOptions(prelude, true, false),
|
|
290
|
-
outro: `
|
|
271
|
+
const { root, port, host = "localhost", platform, serverUrl, plugins: userPlugins = [], onHmrUpdate } = options;
|
|
272
|
+
const { dev, viteImportGlobPlugin } = await import("rolldown/experimental");
|
|
273
|
+
const hmrRuntimeSource = getHmrRuntimeSource();
|
|
274
|
+
const prelude = getNativePrelude({
|
|
275
|
+
dev: true,
|
|
276
|
+
platform,
|
|
277
|
+
serverUrl: serverUrl || `http://${host}:${port}`
|
|
278
|
+
});
|
|
279
|
+
const assetRegistry = createNativeDevAssetRegistry();
|
|
280
|
+
let currentBundle = null;
|
|
281
|
+
let firstBuildError = null;
|
|
282
|
+
let bundleResolve = null;
|
|
283
|
+
let bundleReject = null;
|
|
284
|
+
let bundlePromise = null;
|
|
285
|
+
const resolvedHost = host === "0.0.0.0" ? "localhost" : host;
|
|
286
|
+
const virtualEntry = nativeVirtualEntryPlugin(root, {
|
|
287
|
+
dev: true,
|
|
288
|
+
platform,
|
|
289
|
+
dynamicRoutes: true
|
|
290
|
+
});
|
|
291
|
+
let engineWork = Promise.resolve();
|
|
292
|
+
const queueEngineWork = (work) => {
|
|
293
|
+
const result = engineWork.then(work, work);
|
|
294
|
+
engineWork = result.catch(() => {});
|
|
295
|
+
return result;
|
|
296
|
+
};
|
|
297
|
+
const inputOptions = {
|
|
298
|
+
input: VIRTUAL_NATIVE_ENTRY,
|
|
299
|
+
cwd: root,
|
|
300
|
+
platform: "neutral",
|
|
301
|
+
resolve: getNativeResolveConfig(platform),
|
|
302
|
+
transform: getNativeTransformConfig(platform, true, root),
|
|
303
|
+
experimental: {
|
|
304
|
+
devMode: {
|
|
305
|
+
implement: hmrRuntimeSource,
|
|
306
|
+
host,
|
|
307
|
+
port
|
|
308
|
+
},
|
|
309
|
+
incrementalBuild: true,
|
|
310
|
+
lazyBarrel: true
|
|
311
|
+
},
|
|
312
|
+
treeshake: false,
|
|
313
|
+
shimMissingExports: true,
|
|
314
|
+
moduleTypes: { ".js": "jsx" },
|
|
315
|
+
plugins: [virtualEntry.plugin, ...getNativePlugins(root, platform, viteImportGlobPlugin, true, void 0, assetRegistry.register, true, userPlugins)]
|
|
316
|
+
};
|
|
317
|
+
const outputOptions = {
|
|
318
|
+
...getNativeOutputOptions(prelude, true, false),
|
|
319
|
+
outro: `
|
|
291
320
|
try {
|
|
292
321
|
var __WS = (init_WebSocket(), __toCommonJS(WebSocket_exports)).default;
|
|
293
322
|
var __hmrUrl = 'ws://${resolvedHost}:${port}/hot?platform=${platform}&clientId=' + encodeURIComponent(__rolldown_runtime__.clientId);
|
|
@@ -298,228 +327,212 @@ try {
|
|
|
298
327
|
console.error('[vxrn] HMR client failed to start:', (e && e.message) || e);
|
|
299
328
|
}
|
|
300
329
|
`
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
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
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
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
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
});
|
|
442
|
-
}
|
|
443
|
-
return bundlePromise;
|
|
444
|
-
},
|
|
445
|
-
getAsset(pathname, hash) {
|
|
446
|
-
return assetRegistry.resolve(pathname, hash);
|
|
447
|
-
},
|
|
448
|
-
async close() {
|
|
449
|
-
routeWatcher?.close();
|
|
450
|
-
await engine.close();
|
|
451
|
-
}
|
|
452
|
-
};
|
|
330
|
+
};
|
|
331
|
+
let outputProcessed = Promise.resolve();
|
|
332
|
+
let engine;
|
|
333
|
+
let routeWatcher;
|
|
334
|
+
const rebuildIfRouteGraphChanged = () => queueEngineWork(async () => {
|
|
335
|
+
const { files: knownRoutes, scanFiles, updateFiles } = virtualEntry.routes;
|
|
336
|
+
const currentRoutes = scanFiles();
|
|
337
|
+
if (!(currentRoutes.size !== knownRoutes.size || [...currentRoutes].some((route) => !knownRoutes.has(route)))) return false;
|
|
338
|
+
updateFiles(currentRoutes);
|
|
339
|
+
return true;
|
|
340
|
+
});
|
|
341
|
+
engine = await dev(inputOptions, outputOptions, {
|
|
342
|
+
onOutput: async (result) => {
|
|
343
|
+
let finishOutput = () => {};
|
|
344
|
+
outputProcessed = new Promise((resolve2) => {
|
|
345
|
+
finishOutput = resolve2;
|
|
346
|
+
});
|
|
347
|
+
try {
|
|
348
|
+
await handleOutput(result);
|
|
349
|
+
} finally {
|
|
350
|
+
finishOutput();
|
|
351
|
+
}
|
|
352
|
+
},
|
|
353
|
+
onHmrUpdates: async (result) => {
|
|
354
|
+
if (result instanceof Error) {
|
|
355
|
+
console.error("[vxrn] HMR error:", result.message);
|
|
356
|
+
onHmrUpdate?.({ type: "hmr:error" });
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
if (await rebuildIfRouteGraphChanged()) return;
|
|
360
|
+
for (const { clientId, update } of result.updates) if (update.type === "Patch" && update.code) onHmrUpdate?.({
|
|
361
|
+
type: "hmr:update",
|
|
362
|
+
clientId,
|
|
363
|
+
code: normalizeNativeCommonJSInterop(update.code),
|
|
364
|
+
changedIds: update.changedIds,
|
|
365
|
+
seq: update.seq
|
|
366
|
+
});
|
|
367
|
+
else if (update.type === "FullReload") onHmrUpdate?.({
|
|
368
|
+
type: "hmr:reload",
|
|
369
|
+
clientId
|
|
370
|
+
});
|
|
371
|
+
},
|
|
372
|
+
rebuildStrategy: "never",
|
|
373
|
+
watch: {}
|
|
374
|
+
});
|
|
375
|
+
async function handleOutput(result) {
|
|
376
|
+
if (result instanceof Error) {
|
|
377
|
+
console.error("[vxrn] native bundle error:", result.message);
|
|
378
|
+
if (/panic/i.test(result.message)) console.error("[vxrn] rolldown itself panicked. Fast Refresh will full-reload until you restart the dev server.");
|
|
379
|
+
if (!currentBundle) {
|
|
380
|
+
firstBuildError ||= result;
|
|
381
|
+
if (bundleReject) {
|
|
382
|
+
const reject = bundleReject;
|
|
383
|
+
bundleResolve = null;
|
|
384
|
+
bundleReject = null;
|
|
385
|
+
bundlePromise = null;
|
|
386
|
+
reject(firstBuildError);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
const chunk = result.output.find((o) => o.type === "chunk" && o.isEntry);
|
|
392
|
+
if (chunk && "code" in chunk) {
|
|
393
|
+
firstBuildError = null;
|
|
394
|
+
let code = postProcessNativeBundle(chunk.code);
|
|
395
|
+
code = await downlevelClassFieldsInBundle(code);
|
|
396
|
+
assertBundleLinesPreserved(chunk.code, code, "dev");
|
|
397
|
+
code = wrapNativeBundleModuleScope(code);
|
|
398
|
+
if (!chunk.map) throw new Error("[vxrn] rolldown produced no source map for the dev bundle, so /symbolicate cannot resolve a frame");
|
|
399
|
+
currentBundle = {
|
|
400
|
+
code,
|
|
401
|
+
map: chunk.map.toString()
|
|
402
|
+
};
|
|
403
|
+
console.info(`[vxrn] native bundle ready (${Math.round(code.length / 1024)}KB)`);
|
|
404
|
+
if (bundleResolve) {
|
|
405
|
+
bundleResolve(currentBundle);
|
|
406
|
+
bundleResolve = null;
|
|
407
|
+
bundleReject = null;
|
|
408
|
+
bundlePromise = null;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
await engine.run();
|
|
413
|
+
let routeWatchTarget = virtualEntry.routes.routeRoot;
|
|
414
|
+
while (!statSync(routeWatchTarget, { throwIfNoEntry: false })?.isDirectory()) {
|
|
415
|
+
const parent = dirname(routeWatchTarget);
|
|
416
|
+
if (parent === routeWatchTarget) break;
|
|
417
|
+
routeWatchTarget = parent;
|
|
418
|
+
}
|
|
419
|
+
const normalizedRouteRoot = normalizePath(virtualEntry.routes.routeRoot);
|
|
420
|
+
routeWatcher = watch(routeWatchTarget, { recursive: true }, (_eventType, file) => {
|
|
421
|
+
if (file === null) return;
|
|
422
|
+
const changed = normalizePath(resolve(routeWatchTarget, file.toString()));
|
|
423
|
+
if (changed !== normalizedRouteRoot && !changed.startsWith(`${normalizedRouteRoot}/`)) return;
|
|
424
|
+
rebuildIfRouteGraphChanged().catch((error) => {
|
|
425
|
+
console.error(`[vxrn] rebuilding the native route map failed`, error);
|
|
426
|
+
});
|
|
427
|
+
});
|
|
428
|
+
routeWatcher.on("error", (error) => {
|
|
429
|
+
console.error(`[vxrn] watching the native route map failed`, error);
|
|
430
|
+
});
|
|
431
|
+
await rebuildIfRouteGraphChanged();
|
|
432
|
+
return {
|
|
433
|
+
engine,
|
|
434
|
+
async getBundle() {
|
|
435
|
+
await queueEngineWork(async () => {
|
|
436
|
+
await engine.ensureLatestBuildOutput();
|
|
437
|
+
await outputProcessed;
|
|
438
|
+
});
|
|
439
|
+
if (currentBundle) return currentBundle;
|
|
440
|
+
if (firstBuildError) throw firstBuildError;
|
|
441
|
+
if (!bundlePromise) {
|
|
442
|
+
let timeoutId;
|
|
443
|
+
bundlePromise = new Promise((resolve2, reject) => {
|
|
444
|
+
bundleResolve = (value) => {
|
|
445
|
+
clearTimeout(timeoutId);
|
|
446
|
+
resolve2(value);
|
|
447
|
+
};
|
|
448
|
+
bundleReject = (error) => {
|
|
449
|
+
clearTimeout(timeoutId);
|
|
450
|
+
reject(error);
|
|
451
|
+
};
|
|
452
|
+
timeoutId = setTimeout(() => {
|
|
453
|
+
bundleResolve = null;
|
|
454
|
+
bundleReject = null;
|
|
455
|
+
bundlePromise = null;
|
|
456
|
+
reject(/* @__PURE__ */ new Error("[vxrn] bundle build timed out after 120s"));
|
|
457
|
+
}, 12e4);
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
return bundlePromise;
|
|
461
|
+
},
|
|
462
|
+
getAsset(pathname, hash) {
|
|
463
|
+
return assetRegistry.resolve(pathname, hash);
|
|
464
|
+
},
|
|
465
|
+
async close() {
|
|
466
|
+
routeWatcher?.close();
|
|
467
|
+
await engine.close();
|
|
468
|
+
}
|
|
469
|
+
};
|
|
453
470
|
}
|
|
454
471
|
async function buildNativeBundle(options) {
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
".js": "jsx"
|
|
490
|
-
},
|
|
491
|
-
plugins: [...(entryFile ? [] : [nativeVirtualEntryPlugin(root, {
|
|
492
|
-
dev,
|
|
493
|
-
platform
|
|
494
|
-
}).plugin]), ...getNativePlugins(root, platform, viteImportGlobPlugin, dev, assetsDest, void 0, sourcemap, userPlugins), nativeBundlePostProcessPlugin()],
|
|
495
|
-
output: getNativeOutputOptions(prelude, sourcemap, minify)
|
|
496
|
-
})).output.find(o => o.type === "chunk" && o.isEntry);
|
|
497
|
-
if (!chunk || !("code" in chunk)) throw new Error("[vxrn] production build produced no output");
|
|
498
|
-
if (sourcemap && !chunk.map) throw new Error("[vxrn] a source map was requested but rolldown produced none for the production bundle");
|
|
499
|
-
return {
|
|
500
|
-
code: chunk.code,
|
|
501
|
-
map: sourcemap ? chunk.map?.toString() : void 0
|
|
502
|
-
};
|
|
472
|
+
const { root, platform, dev = false, serverUrl, entryFile, assetsDest, plugins: userPlugins = [], sourcemap = false, minify = !dev } = options;
|
|
473
|
+
const { build } = await import("rolldown");
|
|
474
|
+
const { viteImportGlobPlugin } = await import("rolldown/experimental");
|
|
475
|
+
const prelude = getNativePrelude({
|
|
476
|
+
dev,
|
|
477
|
+
platform,
|
|
478
|
+
serverUrl
|
|
479
|
+
});
|
|
480
|
+
const chunk = (await build({
|
|
481
|
+
input: entryFile ? normalizePath(resolve(root, entryFile)) : VIRTUAL_NATIVE_ENTRY,
|
|
482
|
+
cwd: root,
|
|
483
|
+
platform: "neutral",
|
|
484
|
+
resolve: getNativeResolveConfig(platform),
|
|
485
|
+
transform: getNativeTransformConfig(platform, dev, root),
|
|
486
|
+
treeshake: !dev,
|
|
487
|
+
experimental: { lazyBarrel: false },
|
|
488
|
+
shimMissingExports: true,
|
|
489
|
+
moduleTypes: { ".js": "jsx" },
|
|
490
|
+
plugins: [
|
|
491
|
+
...entryFile ? [] : [nativeVirtualEntryPlugin(root, {
|
|
492
|
+
dev,
|
|
493
|
+
platform
|
|
494
|
+
}).plugin],
|
|
495
|
+
...getNativePlugins(root, platform, viteImportGlobPlugin, dev, assetsDest, void 0, sourcemap, userPlugins),
|
|
496
|
+
nativeBundlePostProcessPlugin()
|
|
497
|
+
],
|
|
498
|
+
output: getNativeOutputOptions(prelude, sourcemap, minify)
|
|
499
|
+
})).output.find((o) => o.type === "chunk" && o.isEntry);
|
|
500
|
+
if (!chunk || !("code" in chunk)) throw new Error("[vxrn] production build produced no output");
|
|
501
|
+
if (sourcemap && !chunk.map) throw new Error("[vxrn] a source map was requested but rolldown produced none for the production bundle");
|
|
502
|
+
return {
|
|
503
|
+
code: chunk.code,
|
|
504
|
+
map: sourcemap ? chunk.map?.toString() : void 0
|
|
505
|
+
};
|
|
503
506
|
}
|
|
504
507
|
const VIRTUAL_NATIVE_ENTRY = "virtual:native-entry";
|
|
505
508
|
function nativeVirtualEntryPlugin(root, opts) {
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
509
|
+
const isDev = opts?.dev !== false;
|
|
510
|
+
const useDynamicRouteRegistry = opts.dynamicRoutes === true;
|
|
511
|
+
const resolvedId = normalizePath(resolve(root, "__virtual-native-entry.tsx"));
|
|
512
|
+
const entryConfig = globalThis.__vxrnNativeEntryConfig || {};
|
|
513
|
+
const routerRoot = entryConfig.routerRoot || "app";
|
|
514
|
+
const flags = entryConfig.flags || {};
|
|
515
|
+
const linking = entryConfig.linking;
|
|
516
|
+
const setupFileImport = (() => {
|
|
517
|
+
const sf = entryConfig.setupFile;
|
|
518
|
+
if (!sf) return "";
|
|
519
|
+
const file = typeof sf === "string" ? sf : "native" in sf ? sf.native : sf.ios;
|
|
520
|
+
if (!file) return "";
|
|
521
|
+
const resolved = pathToFileURL(resolve(root, file)).href;
|
|
522
|
+
return `import ${JSON.stringify(resolved)};`;
|
|
523
|
+
})();
|
|
524
|
+
const routeGlobs = [
|
|
525
|
+
`./${routerRoot}/**/*.tsx`,
|
|
526
|
+
`./${routerRoot}/**/*.ts`,
|
|
527
|
+
`!./${routerRoot}/**/*+api.*`,
|
|
528
|
+
`!./${routerRoot}/**/*.test.*`,
|
|
529
|
+
`!./${routerRoot}/**/*.d.ts`,
|
|
530
|
+
`!./${routerRoot}/**/*.server.*`,
|
|
531
|
+
`!./${routerRoot}/**/_middleware.*`,
|
|
532
|
+
`!./${routerRoot}/**/*.web.*`,
|
|
533
|
+
...(entryConfig.ignoredRouteFiles || []).map((pattern) => `!./${routerRoot}/${pattern}`)
|
|
534
|
+
];
|
|
535
|
+
const refreshSetup = isDev ? `
|
|
523
536
|
// react-refresh/runtime MUST initialize before React loads
|
|
524
537
|
import RefreshRuntime from 'react-refresh/runtime';
|
|
525
538
|
RefreshRuntime.injectIntoGlobalHook(globalThis);
|
|
@@ -529,7 +542,7 @@ globalThis.$RefreshReg$ = function(type, id) {
|
|
|
529
542
|
};
|
|
530
543
|
globalThis.$RefreshSig$ = RefreshRuntime.createSignatureFunctionForTransform;
|
|
531
544
|
` : "";
|
|
532
|
-
|
|
545
|
+
const entryCode = () => `
|
|
533
546
|
${refreshSetup}
|
|
534
547
|
import * as ReactNativeInitializeCore from 'react-native/Libraries/Core/InitializeCore';
|
|
535
548
|
import NativeWebSocket from 'react-native/Libraries/WebSocket/WebSocket';
|
|
@@ -557,317 +570,312 @@ createApp({
|
|
|
557
570
|
|
|
558
571
|
${routeHmr}
|
|
559
572
|
`;
|
|
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
|
-
if (!importPath.startsWith(".")) importPath = `./${importPath}`;
|
|
598
|
-
return ` ${JSON.stringify(routeKey)}: () => import(${JSON.stringify(importPath)})`;
|
|
599
|
-
}).join(",\n")}
|
|
573
|
+
const routeRoot = resolve(root, routerRoot);
|
|
574
|
+
const stripDot = (pattern) => pattern.replace(/^\.\//, "");
|
|
575
|
+
const includeGlobs = routeGlobs.filter((p) => !p.startsWith("!")).map(stripDot);
|
|
576
|
+
const excludeGlobs = routeGlobs.filter((p) => p.startsWith("!")).map((p) => stripDot(p.slice(1)));
|
|
577
|
+
const isRouteFile = (file) => {
|
|
578
|
+
const relativeToRoot = normalizePath(relative(root, file));
|
|
579
|
+
return micromatch.isMatch(relativeToRoot, includeGlobs) && !micromatch.isMatch(relativeToRoot, excludeGlobs);
|
|
580
|
+
};
|
|
581
|
+
const scanFiles = () => {
|
|
582
|
+
const files = /* @__PURE__ */ new Set();
|
|
583
|
+
const walkRouteRoot = (dir) => {
|
|
584
|
+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
585
|
+
const child = resolve(dir, entry.name);
|
|
586
|
+
if (entry.isDirectory()) walkRouteRoot(child);
|
|
587
|
+
else if (isRouteFile(child)) files.add(normalizePath(child));
|
|
588
|
+
}
|
|
589
|
+
};
|
|
590
|
+
if (statSync(routeRoot, { throwIfNoEntry: false })?.isDirectory()) walkRouteRoot(routeRoot);
|
|
591
|
+
return files;
|
|
592
|
+
};
|
|
593
|
+
const registrySpecifier = `./node_modules/.vxrn/native-routes-${opts.platform}.mjs`;
|
|
594
|
+
const registryPath = resolve(root, registrySpecifier);
|
|
595
|
+
const routes = {
|
|
596
|
+
routeRoot,
|
|
597
|
+
files: /* @__PURE__ */ new Set(),
|
|
598
|
+
isRouteFile,
|
|
599
|
+
scanFiles,
|
|
600
|
+
updateFiles(files) {
|
|
601
|
+
routes.files = files;
|
|
602
|
+
if (!useDynamicRouteRegistry) return;
|
|
603
|
+
const source = `export const routes = {
|
|
604
|
+
${[...files].sort().map((file) => {
|
|
605
|
+
const routeKey = `/${normalizePath(relative(root, file))}`;
|
|
606
|
+
let importPath = normalizePath(relative(dirname(registryPath), file));
|
|
607
|
+
if (!importPath.startsWith(".")) importPath = `./${importPath}`;
|
|
608
|
+
return ` ${JSON.stringify(routeKey)}: () => import(${JSON.stringify(importPath)})`;
|
|
609
|
+
}).join(",\n")}
|
|
600
610
|
}
|
|
601
611
|
`;
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
routes.updateFiles(routes.scanFiles());
|
|
609
|
-
const routeImports = useDynamicRouteRegistry ? `import { routes } from ${JSON.stringify(registrySpecifier)};` : `var _routes = import.meta.glob(${JSON.stringify(routeGlobs)}, { exhaustive: true });
|
|
612
|
+
mkdirSync(dirname(registryPath), { recursive: true });
|
|
613
|
+
if (!existsSync(registryPath) || readFileSync(registryPath, "utf8") !== source) writeFileSync(registryPath, source);
|
|
614
|
+
}
|
|
615
|
+
};
|
|
616
|
+
routes.updateFiles(routes.scanFiles());
|
|
617
|
+
const routeImports = useDynamicRouteRegistry ? `import { routes } from ${JSON.stringify(registrySpecifier)};` : `var _routes = import.meta.glob(${JSON.stringify(routeGlobs)}, { exhaustive: true });
|
|
610
618
|
// fix route keys: One expects '/${routerRoot}/...' prefix but import.meta.glob returns './${routerRoot}/...'
|
|
611
619
|
var routes = {};
|
|
612
620
|
Object.keys(_routes).forEach(function(key) {
|
|
613
621
|
var normalizedKey = key.replace(/^\\.\\//, '');
|
|
614
622
|
routes['/' + normalizedKey] = _routes[key];
|
|
615
623
|
});`;
|
|
616
|
-
|
|
624
|
+
const routeHmr = useDynamicRouteRegistry ? `if (import.meta.hot) {
|
|
617
625
|
import.meta.hot.accept(${JSON.stringify(registrySpecifier)}, function(next) {
|
|
618
626
|
if (globalThis.__VXRN_UPDATE_NATIVE_ROUTES__) {
|
|
619
627
|
globalThis.__VXRN_UPDATE_NATIVE_ROUTES__(next.routes);
|
|
620
628
|
}
|
|
621
629
|
});
|
|
622
630
|
}` : "";
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
631
|
+
return {
|
|
632
|
+
routes,
|
|
633
|
+
plugin: {
|
|
634
|
+
name: "vxrn:native-virtual-entry",
|
|
635
|
+
resolveId(id) {
|
|
636
|
+
if (id === VIRTUAL_NATIVE_ENTRY) return resolvedId;
|
|
637
|
+
},
|
|
638
|
+
load(id) {
|
|
639
|
+
if (id !== resolvedId) return;
|
|
640
|
+
return entryCode();
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
};
|
|
636
644
|
}
|
|
637
645
|
function nativeAnimatedGuardPlugin() {
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
646
|
+
return {
|
|
647
|
+
name: "vxrn:native-animated-guard",
|
|
648
|
+
transform(code, id) {
|
|
649
|
+
if (!id.includes("animated/NativeAnimatedHelper")) return;
|
|
650
|
+
const target = "const method = nullthrows(NativeAnimatedModule)[methodName];";
|
|
651
|
+
if (!code.includes(target)) return;
|
|
652
|
+
return {
|
|
653
|
+
code: code.replace(target, `${target} if (typeof method !== 'function') return;`),
|
|
654
|
+
map: {
|
|
655
|
+
version: 3,
|
|
656
|
+
sources: [id],
|
|
657
|
+
sourcesContent: [code],
|
|
658
|
+
names: [],
|
|
659
|
+
mappings: code.split("\n").map((_, index) => index === 0 ? "AAAA" : "AACA").join(";")
|
|
660
|
+
}
|
|
661
|
+
};
|
|
662
|
+
}
|
|
663
|
+
};
|
|
656
664
|
}
|
|
657
665
|
function serverFileExclusionPlugin() {
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
666
|
+
return {
|
|
667
|
+
name: "vxrn:server-file-exclusion",
|
|
668
|
+
load(id) {
|
|
669
|
+
if (/\.server\.\w+$/.test(id)) return {
|
|
670
|
+
code: "export default undefined;",
|
|
671
|
+
moduleType: "js"
|
|
672
|
+
};
|
|
673
|
+
if (/[\\/]_middleware\.\w+$/.test(id)) return {
|
|
674
|
+
code: "export default undefined;",
|
|
675
|
+
moduleType: "js"
|
|
676
|
+
};
|
|
677
|
+
}
|
|
678
|
+
};
|
|
671
679
|
}
|
|
672
680
|
function environmentGuardPlugin() {
|
|
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
|
-
|
|
681
|
+
const THROWING = [
|
|
682
|
+
"server-only",
|
|
683
|
+
"client-only",
|
|
684
|
+
"web-only"
|
|
685
|
+
];
|
|
686
|
+
const NOOP = ["native-only"];
|
|
687
|
+
return {
|
|
688
|
+
name: "vxrn:environment-guard",
|
|
689
|
+
resolveId(source) {
|
|
690
|
+
if (THROWING.includes(source)) return {
|
|
691
|
+
id: `\0env-guard-throw:${source}`,
|
|
692
|
+
external: false
|
|
693
|
+
};
|
|
694
|
+
if (NOOP.includes(source)) return {
|
|
695
|
+
id: `\0env-guard-noop:${source}`,
|
|
696
|
+
external: false
|
|
697
|
+
};
|
|
698
|
+
},
|
|
699
|
+
load(id) {
|
|
700
|
+
if (id.startsWith("\0env-guard-throw:")) return {
|
|
701
|
+
code: `throw new Error("Cannot import '${id.slice(17)}' in a native bundle.");`,
|
|
702
|
+
moduleType: "js"
|
|
703
|
+
};
|
|
704
|
+
if (id.startsWith("\0env-guard-noop:")) return {
|
|
705
|
+
code: "",
|
|
706
|
+
moduleType: "js"
|
|
707
|
+
};
|
|
708
|
+
}
|
|
709
|
+
};
|
|
698
710
|
}
|
|
699
711
|
function hmrClientNoopPlugin() {
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
+
const RN_HMR_CLIENT_RE = /(^|[\\/])Utilities[\\/]HMRClient(\.[cm]?[jt]sx?)?$/;
|
|
713
|
+
return {
|
|
714
|
+
name: "vxrn:hmr-client-noop",
|
|
715
|
+
resolveId(source, importer) {
|
|
716
|
+
if ((source.startsWith("react-native/") || importer != null && /(^|[\\/])react-native[\\/]/.test(importer)) && RN_HMR_CLIENT_RE.test(source)) return {
|
|
717
|
+
id: "\0vxrn-hmr-client-noop",
|
|
718
|
+
external: false
|
|
719
|
+
};
|
|
720
|
+
},
|
|
721
|
+
load(id) {
|
|
722
|
+
if (id === "\0vxrn-hmr-client-noop") return {
|
|
723
|
+
code: `const HMRClient = { setup() {}, enable() {}, disable() {}, registerBundle() {}, log() {}, isEnabled() { return false } }
|
|
712
724
|
export default HMRClient`,
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
725
|
+
moduleType: "js"
|
|
726
|
+
};
|
|
727
|
+
}
|
|
728
|
+
};
|
|
717
729
|
}
|
|
718
730
|
function reactNativeDedupePlugin(root) {
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
}
|
|
730
|
-
};
|
|
731
|
+
let reactNativeRoot;
|
|
732
|
+
return {
|
|
733
|
+
name: "vxrn:react-native-dedupe",
|
|
734
|
+
async resolveId(source, importer) {
|
|
735
|
+
if (source !== "react-native" && !source.startsWith("react-native/")) return;
|
|
736
|
+
reactNativeRoot ||= realpathSync(dirname(resolvePath("react-native/package.json", root)));
|
|
737
|
+
const subpath = source === "react-native" ? "index.js" : source.slice(13);
|
|
738
|
+
return this.resolve(normalizePath(resolve(reactNativeRoot, subpath)), importer, { skipSelf: true });
|
|
739
|
+
}
|
|
740
|
+
};
|
|
731
741
|
}
|
|
732
742
|
function cssStubPlugin() {
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
}
|
|
743
|
-
};
|
|
743
|
+
return {
|
|
744
|
+
name: "vxrn:css-stub",
|
|
745
|
+
load: { handler(id) {
|
|
746
|
+
if (id.endsWith(".css")) return {
|
|
747
|
+
code: "",
|
|
748
|
+
moduleType: "js"
|
|
749
|
+
};
|
|
750
|
+
} }
|
|
751
|
+
};
|
|
744
752
|
}
|
|
745
753
|
function vxrnCompilerPlugin(platform, dev, projectRoot = process.cwd(), sourceMaps = false) {
|
|
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
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
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
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
754
|
+
let compiler = null;
|
|
755
|
+
const isRefreshCandidate = (id) => dev && !id.includes("node_modules") && !id.includes("__virtual-native-entry") && /\.[tj]sx?$/.test(id);
|
|
756
|
+
return {
|
|
757
|
+
name: "vxrn:compiler",
|
|
758
|
+
async transform(code, id) {
|
|
759
|
+
if (!/\.[cm]?[jt]sx?$/.test(id)) return;
|
|
760
|
+
if (id.includes("\0") || id.includes("virtual:")) return;
|
|
761
|
+
const needsRefresh = isRefreshCandidate(id);
|
|
762
|
+
if (!compiler) compiler = await import("@vxrn/compiler");
|
|
763
|
+
const props = {
|
|
764
|
+
id,
|
|
765
|
+
code,
|
|
766
|
+
projectRoot,
|
|
767
|
+
development: dev,
|
|
768
|
+
environment: platform,
|
|
769
|
+
reactForRNVersion: "19"
|
|
770
|
+
};
|
|
771
|
+
let babelOptions = compiler.getBabelOptions(props);
|
|
772
|
+
let curCode = code;
|
|
773
|
+
const intermediateMaps = [];
|
|
774
|
+
const isWorkletPlugin = (entry) => {
|
|
775
|
+
if (!entry) return false;
|
|
776
|
+
const name = typeof entry === "string" ? entry : Array.isArray(entry) ? entry[0] : null;
|
|
777
|
+
return typeof name === "string" && (name.includes("react-native-worklets") || name.includes("react-native-reanimated"));
|
|
778
|
+
};
|
|
779
|
+
const workletEntry = babelOptions?.plugins?.find(isWorkletPlugin);
|
|
780
|
+
const workletPluginOptions = Array.isArray(workletEntry) ? workletEntry[1] : void 0;
|
|
781
|
+
const useWorklets = compiler.isNativeWorkletsEnabled() && (Boolean(workletEntry) || compiler.shouldTransformWorklets({
|
|
782
|
+
id,
|
|
783
|
+
code
|
|
784
|
+
}));
|
|
785
|
+
const compilerPluginIndex = babelOptions?.plugins?.findIndex((x) => Array.isArray(x) && x[0] === "babel-plugin-react-compiler") ?? -1;
|
|
786
|
+
if (compilerPluginIndex !== -1) {
|
|
787
|
+
if (useWorklets) {
|
|
788
|
+
const prepared = compiler.prepareWorkletsForReactCompiler(id, curCode, sourceMaps);
|
|
789
|
+
if (prepared) {
|
|
790
|
+
curCode = prepared.code;
|
|
791
|
+
if (prepared.map) intermediateMaps.push(prepared.map);
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
const compilerPluginOptions = babelOptions.plugins[compilerPluginIndex][1] || {};
|
|
795
|
+
if (!(compilerPluginOptions.compiler === "babel" || process.env.ONE_REACT_COMPILER === "babel" || process.env.VXRN_REACT_COMPILER === "babel")) {
|
|
796
|
+
const compilerOut = await compiler.transformOxcReactCompiler(id, curCode, compilerPluginOptions, sourceMaps);
|
|
797
|
+
if (compilerOut?.code) {
|
|
798
|
+
curCode = compilerOut.code;
|
|
799
|
+
if (sourceMaps && compilerOut.map) intermediateMaps.push(compilerOut.map);
|
|
800
|
+
}
|
|
801
|
+
babelOptions.plugins.splice(compilerPluginIndex, 1);
|
|
802
|
+
if (babelOptions.plugins.length === 0 && !babelOptions.configFile && !babelOptions.babelrc) babelOptions = null;
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
if (useWorklets) {
|
|
806
|
+
const workletOut = await compiler.transformWorklets(id, curCode, sourceMaps, {
|
|
807
|
+
projectRoot,
|
|
808
|
+
...workletPluginOptions
|
|
809
|
+
});
|
|
810
|
+
if (workletOut?.code) {
|
|
811
|
+
curCode = workletOut.code;
|
|
812
|
+
if (sourceMaps && workletOut.map) intermediateMaps.push(workletOut.map);
|
|
813
|
+
}
|
|
814
|
+
if (babelOptions?.plugins) {
|
|
815
|
+
babelOptions.plugins = babelOptions.plugins.filter((entry) => !isWorkletPlugin(entry));
|
|
816
|
+
if (babelOptions.plugins.length === 0 && !babelOptions.configFile && !babelOptions.babelrc) babelOptions = null;
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
if (!babelOptions && !needsRefresh) {
|
|
820
|
+
if (curCode !== code) {
|
|
821
|
+
let finalMap = void 0;
|
|
822
|
+
if (sourceMaps && intermediateMaps.length > 0) if (intermediateMaps.length === 1) finalMap = intermediateMaps[0];
|
|
823
|
+
else {
|
|
824
|
+
const remapping = (await import("@jridgewell/remapping")).default;
|
|
825
|
+
finalMap = remapping(intermediateMaps.slice().reverse(), () => null);
|
|
826
|
+
}
|
|
827
|
+
return {
|
|
828
|
+
code: curCode,
|
|
829
|
+
map: finalMap
|
|
830
|
+
};
|
|
831
|
+
}
|
|
832
|
+
return;
|
|
833
|
+
}
|
|
834
|
+
if (sourceMaps && babelOptions) {
|
|
835
|
+
babelOptions = {
|
|
836
|
+
...babelOptions,
|
|
837
|
+
sourceMaps: true,
|
|
838
|
+
sourceFileName: id
|
|
839
|
+
};
|
|
840
|
+
delete babelOptions.inputSourceMap;
|
|
841
|
+
}
|
|
842
|
+
if (babelOptions) {
|
|
843
|
+
const result = await compiler.transformBabel(id, curCode, babelOptions);
|
|
844
|
+
if (result?.code) {
|
|
845
|
+
curCode = result.code;
|
|
846
|
+
if (sourceMaps && result.map) intermediateMaps.push(result.map);
|
|
847
|
+
if (!needsRefresh) {
|
|
848
|
+
let finalMap = void 0;
|
|
849
|
+
if (sourceMaps && intermediateMaps.length > 0) if (intermediateMaps.length === 1) finalMap = intermediateMaps[0];
|
|
850
|
+
else {
|
|
851
|
+
const remapping = (await import("@jridgewell/remapping")).default;
|
|
852
|
+
finalMap = remapping(intermediateMaps.slice().reverse(), () => null);
|
|
853
|
+
}
|
|
854
|
+
return {
|
|
855
|
+
code: curCode,
|
|
856
|
+
map: finalMap
|
|
857
|
+
};
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
if (needsRefresh) {
|
|
862
|
+
const { transformSync } = await import("oxc-transform-react");
|
|
863
|
+
const jsxImportSource = compiler.configuration?.enableNativewind && !id.includes("node_modules") ? "nativewind" : "react";
|
|
864
|
+
const res = transformSync(id, curCode, {
|
|
865
|
+
jsx: {
|
|
866
|
+
development: dev,
|
|
867
|
+
runtime: "automatic",
|
|
868
|
+
importSource: jsxImportSource,
|
|
869
|
+
refresh: {
|
|
870
|
+
refreshReg: "__vxrnRefreshReg",
|
|
871
|
+
refreshSig: "__vxrnRefreshSig"
|
|
872
|
+
}
|
|
873
|
+
},
|
|
874
|
+
reactCompiler: false,
|
|
875
|
+
sourcemap: sourceMaps
|
|
876
|
+
});
|
|
877
|
+
if (res.fatal) throw new Error(`[vxrn:compiler] oxc react transform failed on ${id}: ${(res.errors ?? []).map((e) => e.message ?? String(e)).join(", ")}`);
|
|
878
|
+
const header = `var __prevRefreshReg = globalThis.$RefreshReg$;
|
|
871
879
|
var __prevRefreshSig = globalThis.$RefreshSig$;
|
|
872
880
|
if (globalThis.__ReactRefresh) {
|
|
873
881
|
globalThis.$RefreshReg$ = function(type, id) {
|
|
@@ -880,7 +888,7 @@ var __vxrnRefreshReg = globalThis.$RefreshReg$;
|
|
|
880
888
|
var __vxrnRefreshSig = globalThis.$RefreshSig$;
|
|
881
889
|
|
|
882
890
|
`;
|
|
883
|
-
|
|
891
|
+
const footer = `
|
|
884
892
|
|
|
885
893
|
globalThis.$RefreshReg$ = __prevRefreshReg;
|
|
886
894
|
globalThis.$RefreshSig$ = __prevRefreshSig;
|
|
@@ -892,251 +900,268 @@ if (import.meta.hot) {
|
|
|
892
900
|
});
|
|
893
901
|
}
|
|
894
902
|
`;
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
903
|
+
let out;
|
|
904
|
+
let finalMap = void 0;
|
|
905
|
+
if (sourceMaps) {
|
|
906
|
+
const MagicString = (await import("magic-string")).default;
|
|
907
|
+
const ms = new MagicString(res.code);
|
|
908
|
+
ms.prepend(header);
|
|
909
|
+
ms.append(footer);
|
|
910
|
+
out = ms.toString();
|
|
911
|
+
const allMaps = [
|
|
912
|
+
ms.generateMap({
|
|
913
|
+
source: id,
|
|
914
|
+
hires: true
|
|
915
|
+
}),
|
|
916
|
+
res.map,
|
|
917
|
+
...intermediateMaps.slice().reverse()
|
|
918
|
+
].filter(Boolean);
|
|
919
|
+
const remapping = (await import("@jridgewell/remapping")).default;
|
|
920
|
+
finalMap = remapping(allMaps, () => null);
|
|
921
|
+
} else out = header + res.code + footer;
|
|
922
|
+
return {
|
|
923
|
+
code: out,
|
|
924
|
+
map: finalMap
|
|
925
|
+
};
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
};
|
|
917
929
|
}
|
|
918
930
|
function flowStripPlugin() {
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
return {
|
|
932
|
-
code: result.code,
|
|
933
|
-
map: result.map
|
|
934
|
-
};
|
|
935
|
-
}
|
|
936
|
-
}
|
|
937
|
-
};
|
|
931
|
+
return {
|
|
932
|
+
name: "vxrn:flow-strip",
|
|
933
|
+
transform: { async handler(code, id) {
|
|
934
|
+
if (!shouldStripFlow(id, code)) return;
|
|
935
|
+
const { stripFlowTypes } = await import("@vxrn/compiler");
|
|
936
|
+
const result = await stripFlowTypes(id, code);
|
|
937
|
+
return {
|
|
938
|
+
code: result.code,
|
|
939
|
+
map: result.map
|
|
940
|
+
};
|
|
941
|
+
} }
|
|
942
|
+
};
|
|
938
943
|
}
|
|
939
944
|
function assetPlugin(opts) {
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
}
|
|
955
|
-
};
|
|
945
|
+
const assetRegex = new RegExp(`\\.(?:${DEFAULT_ASSET_EXTS.join("|")})$`);
|
|
946
|
+
return {
|
|
947
|
+
name: "vxrn:asset",
|
|
948
|
+
load: { async handler(id) {
|
|
949
|
+
if (!assetRegex.test(id)) return;
|
|
950
|
+
const assetData = await getNativeAssetData(id, opts.root, opts.platform);
|
|
951
|
+
opts.onAsset?.(assetData);
|
|
952
|
+
if (opts.assetsDest) copyNativeAssetFiles(assetData, opts.assetsDest, opts.platform);
|
|
953
|
+
return {
|
|
954
|
+
code: `module.exports = require('react-native/asset-registry').registerAsset(${JSON.stringify(assetData)});`,
|
|
955
|
+
moduleType: "js"
|
|
956
|
+
};
|
|
957
|
+
} }
|
|
958
|
+
};
|
|
956
959
|
}
|
|
957
960
|
function createNativeDevAssetRegistry() {
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
961
|
+
const assets = /* @__PURE__ */ new Map();
|
|
962
|
+
return {
|
|
963
|
+
register(asset) {
|
|
964
|
+
for (const [index, scale] of asset.scales.entries()) {
|
|
965
|
+
const filePath = asset.files[index];
|
|
966
|
+
if (!filePath) continue;
|
|
967
|
+
const fileName = `${asset.name}${scale === 1 ? "" : `@${scale}x`}.${asset.type}`;
|
|
968
|
+
assets.set(`${asset.httpServerLocation}/${fileName}`, {
|
|
969
|
+
filePath,
|
|
970
|
+
hash: asset.hash,
|
|
971
|
+
type: asset.type
|
|
972
|
+
});
|
|
973
|
+
}
|
|
974
|
+
},
|
|
975
|
+
resolve(pathname, hash) {
|
|
976
|
+
const asset = assets.get(pathname);
|
|
977
|
+
if (!asset || hash !== void 0 && hash !== asset.hash) return;
|
|
978
|
+
return asset;
|
|
979
|
+
}
|
|
980
|
+
};
|
|
978
981
|
}
|
|
979
|
-
const NATIVE_IMAGE_EXTS = /* @__PURE__ */new Set([
|
|
982
|
+
const NATIVE_IMAGE_EXTS = /* @__PURE__ */ new Set([
|
|
983
|
+
"png",
|
|
984
|
+
"jpg",
|
|
985
|
+
"jpeg",
|
|
986
|
+
"gif",
|
|
987
|
+
"webp",
|
|
988
|
+
"bmp",
|
|
989
|
+
"psd",
|
|
990
|
+
"svg",
|
|
991
|
+
"tiff",
|
|
992
|
+
"ktx"
|
|
993
|
+
]);
|
|
980
994
|
function parseNativeAssetName(filePath) {
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
995
|
+
const type = extname(filePath).slice(1);
|
|
996
|
+
if (!type) return;
|
|
997
|
+
const stem = basename(filePath, `.${type}`);
|
|
998
|
+
const platformMatch = stem.match(/^(.*)\.(ios|android)$/);
|
|
999
|
+
const platform = platformMatch?.[2];
|
|
1000
|
+
const scaleMatch = (platformMatch?.[1] ?? stem).match(/^(.+?)(?:@([\d.]+)x)?$/);
|
|
1001
|
+
if (!scaleMatch) return;
|
|
1002
|
+
const scale = scaleMatch[2] === void 0 ? 1 : Number.parseFloat(scaleMatch[2]);
|
|
1003
|
+
if (!Number.isFinite(scale) || scale <= 0) return;
|
|
1004
|
+
return {
|
|
1005
|
+
name: scaleMatch[1],
|
|
1006
|
+
scale,
|
|
1007
|
+
platform,
|
|
1008
|
+
type
|
|
1009
|
+
};
|
|
996
1010
|
}
|
|
997
1011
|
function getNativeAssetUrlDirectory(root, assetDirectory) {
|
|
998
|
-
|
|
999
|
-
|
|
1012
|
+
const safeDirectory = relative(realpathSync(root), realpathSync(assetDirectory)).replace(/\\/g, "/").split("/").filter((segment) => segment && segment !== ".").map((segment) => segment === ".." ? "_" : segment).join("/");
|
|
1013
|
+
return safeDirectory ? `/assets/${safeDirectory}` : "/assets";
|
|
1000
1014
|
}
|
|
1001
1015
|
async function getNativeAssetData(id, root, platform) {
|
|
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
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
} catch {}
|
|
1039
|
-
return assetData;
|
|
1016
|
+
const requested = parseNativeAssetName(id);
|
|
1017
|
+
if (!requested) throw new Error(`[vxrn] invalid native asset path: ${id}`);
|
|
1018
|
+
const assetDirectory = dirname(id);
|
|
1019
|
+
const filesByScale = /* @__PURE__ */ new Map();
|
|
1020
|
+
for (const fileName of readdirSync(assetDirectory)) {
|
|
1021
|
+
const candidate = parseNativeAssetName(fileName);
|
|
1022
|
+
if (!candidate || candidate.name !== requested.name || candidate.type !== requested.type || candidate.platform !== void 0 && candidate.platform !== platform) continue;
|
|
1023
|
+
const platformSpecific = candidate.platform === platform;
|
|
1024
|
+
const existing = filesByScale.get(candidate.scale);
|
|
1025
|
+
if (!existing || platformSpecific && !existing.platformSpecific) filesByScale.set(candidate.scale, {
|
|
1026
|
+
file: join(assetDirectory, fileName),
|
|
1027
|
+
platformSpecific
|
|
1028
|
+
});
|
|
1029
|
+
}
|
|
1030
|
+
const scales = [...filesByScale.keys()].sort((a, b) => a - b);
|
|
1031
|
+
const files = scales.map((scale) => filesByScale.get(scale).file);
|
|
1032
|
+
if (files.length === 0) throw new Error(`[vxrn] native asset has no files for ${platform}: ${id}`);
|
|
1033
|
+
const hash = createHash("md5");
|
|
1034
|
+
for (const file of files) hash.update(readFileSync(file));
|
|
1035
|
+
const assetData = {
|
|
1036
|
+
__packager_asset: true,
|
|
1037
|
+
name: requested.name,
|
|
1038
|
+
type: requested.type,
|
|
1039
|
+
scales,
|
|
1040
|
+
files,
|
|
1041
|
+
httpServerLocation: getNativeAssetUrlDirectory(root, assetDirectory),
|
|
1042
|
+
fileSystemLocation: assetDirectory,
|
|
1043
|
+
hash: hash.digest("hex")
|
|
1044
|
+
};
|
|
1045
|
+
if (NATIVE_IMAGE_EXTS.has(requested.type)) try {
|
|
1046
|
+
const { imageSize } = await import("image-size");
|
|
1047
|
+
const dims = imageSize(files[0]);
|
|
1048
|
+
assetData.width = dims.width === void 0 ? void 0 : dims.width / scales[0];
|
|
1049
|
+
assetData.height = dims.height === void 0 ? void 0 : dims.height / scales[0];
|
|
1050
|
+
} catch {}
|
|
1051
|
+
return assetData;
|
|
1040
1052
|
}
|
|
1041
1053
|
function getIOSAssetScales(scales) {
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1054
|
+
const supported = scales.filter((scale) => scale === 1 || scale === 2 || scale === 3);
|
|
1055
|
+
if (supported.length > 0 || scales.length === 0) return supported;
|
|
1056
|
+
return [scales.find((scale) => scale > 3) ?? scales[scales.length - 1]];
|
|
1045
1057
|
}
|
|
1046
1058
|
function getAndroidAssetDirectory(type, scale) {
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1059
|
+
if (!(/* @__PURE__ */ new Set([
|
|
1060
|
+
"gif",
|
|
1061
|
+
"heic",
|
|
1062
|
+
"heif",
|
|
1063
|
+
"jpeg",
|
|
1064
|
+
"jpg",
|
|
1065
|
+
"ktx",
|
|
1066
|
+
"png",
|
|
1067
|
+
"webp",
|
|
1068
|
+
"xml"
|
|
1069
|
+
])).has(type)) return "raw";
|
|
1070
|
+
const density = (/* @__PURE__ */ new Map([
|
|
1071
|
+
[.75, "ldpi"],
|
|
1072
|
+
[1, "mdpi"],
|
|
1073
|
+
[1.5, "hdpi"],
|
|
1074
|
+
[2, "xhdpi"],
|
|
1075
|
+
[3, "xxhdpi"],
|
|
1076
|
+
[4, "xxxhdpi"]
|
|
1077
|
+
])).get(scale);
|
|
1078
|
+
if (density) return `drawable-${density}`;
|
|
1079
|
+
return `drawable-${Math.round(scale * 160)}dpi`;
|
|
1051
1080
|
}
|
|
1052
1081
|
function getAndroidAssetName(asset) {
|
|
1053
|
-
|
|
1082
|
+
return `${asset.httpServerLocation}/${asset.name}`.toLowerCase().replace(/^\//, "").replace(/\//g, "_").replace(/([^a-z0-9_])/g, "").replace(/^assets_/, "");
|
|
1054
1083
|
}
|
|
1055
1084
|
function copyNativeAssetFiles(asset, assetsDest, platform) {
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
copyFileSync(asset.files[index], destination);
|
|
1064
|
-
}
|
|
1085
|
+
const validIOSScales = new Set(getIOSAssetScales(asset.scales));
|
|
1086
|
+
for (const [index, scale] of asset.scales.entries()) {
|
|
1087
|
+
if (platform === "ios" && !validIOSScales.has(scale)) continue;
|
|
1088
|
+
const destination = platform === "android" ? join(assetsDest, getAndroidAssetDirectory(asset.type, scale), `${getAndroidAssetName(asset)}.${asset.type}`) : join(assetsDest, asset.httpServerLocation.slice(1), `${asset.name}${scale === 1 ? "" : `@${scale}x`}.${asset.type}`);
|
|
1089
|
+
mkdirSync(dirname(destination), { recursive: true });
|
|
1090
|
+
copyFileSync(asset.files[index], destination);
|
|
1091
|
+
}
|
|
1065
1092
|
}
|
|
1066
1093
|
function hermesCompatSWCPlugin(dev, sourceMaps = false) {
|
|
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
|
-
const err = result.errors[0];
|
|
1093
|
-
throw new Error(err.message + (err.codeframe ? `
|
|
1094
|
+
let oxc = null;
|
|
1095
|
+
return {
|
|
1096
|
+
name: "vxrn:hermes-compat",
|
|
1097
|
+
async transform(code, id) {
|
|
1098
|
+
if (!/\.[cm]?[jt]sx?$/.test(id)) return;
|
|
1099
|
+
if (id.includes("\0") || id.includes("virtual:")) return;
|
|
1100
|
+
const hasClass = code.includes("class ") || code.includes("class{");
|
|
1101
|
+
const hasAsync = code.includes("async");
|
|
1102
|
+
const hasBlockScopedLoop = /\bfor\s*\(\s*(?:const|let)\b/.test(code);
|
|
1103
|
+
if (!hasClass && !hasAsync && !hasBlockScopedLoop) return;
|
|
1104
|
+
let output;
|
|
1105
|
+
if (code.length <= 5e5) {
|
|
1106
|
+
if (!oxc) oxc = await import("oxc-transform");
|
|
1107
|
+
const lang = /\.[cm]?ts$/.test(id) ? "ts" : id.endsWith(".tsx") ? "tsx" : "jsx";
|
|
1108
|
+
const result = oxc.transformSync(id, code, {
|
|
1109
|
+
lang,
|
|
1110
|
+
target: "es2020",
|
|
1111
|
+
assumptions: { setPublicClassFields: true },
|
|
1112
|
+
jsx: "preserve",
|
|
1113
|
+
sourcemap: sourceMaps,
|
|
1114
|
+
sourceType: id.endsWith(".cjs") ? "script" : "module"
|
|
1115
|
+
});
|
|
1116
|
+
if (result.errors?.length) {
|
|
1117
|
+
const err = result.errors[0];
|
|
1118
|
+
throw new Error(err.message + (err.codeframe ? `
|
|
1094
1119
|
${err.codeframe}` : ""));
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1120
|
+
}
|
|
1121
|
+
output = {
|
|
1122
|
+
code: result.code,
|
|
1123
|
+
map: sourceMaps ? result.map : void 0
|
|
1124
|
+
};
|
|
1125
|
+
}
|
|
1126
|
+
const lowered = await transformHermesAsync(output?.code ?? code, id, sourceMaps);
|
|
1127
|
+
if (!lowered) return output;
|
|
1128
|
+
if (lowered.map && output?.map) {
|
|
1129
|
+
const remapping = (await import("@jridgewell/remapping")).default;
|
|
1130
|
+
lowered.map = remapping([lowered.map, output.map], () => null);
|
|
1131
|
+
}
|
|
1132
|
+
return lowered;
|
|
1133
|
+
}
|
|
1134
|
+
};
|
|
1110
1135
|
}
|
|
1111
1136
|
const hermesCompatPlugin = hermesCompatSWCPlugin;
|
|
1112
1137
|
function hermesLoopsPlugin(sourceMaps = false) {
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1138
|
+
let compiler = null;
|
|
1139
|
+
return {
|
|
1140
|
+
name: "vxrn:hermes-loops",
|
|
1141
|
+
async transform(code, id) {
|
|
1142
|
+
if (!/\.[cm]?[jt]sx?$/.test(id)) return;
|
|
1143
|
+
if (id.includes("\0") || id.includes("virtual:")) return;
|
|
1144
|
+
if (!compiler) compiler = await import("@vxrn/compiler");
|
|
1145
|
+
const result = compiler.transformHermesLoops(code, id);
|
|
1146
|
+
if (!result) return;
|
|
1147
|
+
if (!sourceMaps) return {
|
|
1148
|
+
code: result.code,
|
|
1149
|
+
map: null
|
|
1150
|
+
};
|
|
1151
|
+
if (result.maps.length === 1) return {
|
|
1152
|
+
code: result.code,
|
|
1153
|
+
map: result.maps[0]
|
|
1154
|
+
};
|
|
1155
|
+
const remapping = (await import("@jridgewell/remapping")).default;
|
|
1156
|
+
return {
|
|
1157
|
+
code: result.code,
|
|
1158
|
+
map: remapping(result.maps.slice().reverse(), () => null)
|
|
1159
|
+
};
|
|
1160
|
+
}
|
|
1161
|
+
};
|
|
1137
1162
|
}
|
|
1138
1163
|
function getHmrRuntimeSource() {
|
|
1139
|
-
|
|
1164
|
+
return `
|
|
1140
1165
|
// vxrn HMR runtime for rolldown devMode
|
|
1141
1166
|
var BaseDevRuntime = DevRuntime;
|
|
1142
1167
|
|
|
@@ -1373,5 +1398,6 @@ class ReactNativeDevRuntime extends BaseDevRuntime {
|
|
|
1373
1398
|
globalThis.__rolldown_runtime__ = new ReactNativeDevRuntime();
|
|
1374
1399
|
`;
|
|
1375
1400
|
}
|
|
1401
|
+
|
|
1376
1402
|
export { buildNativeBundle, createNativeDevAssetRegistry, createNativeDevEngine, getHermesSWCIncludes, getHmrRuntimeSource, getNativeAssetData, getNativeTransformConfig, hermesCompatPlugin, hermesCompatSWCPlugin, hermesLoopsPlugin, hmrClientNoopPlugin, nativeAnimatedGuardPlugin, normalizeNativeCommonJSInterop, postProcessNativeBundle, vxrnCompilerPlugin, wrapNativeBundleModuleScope };
|
|
1377
1403
|
//# sourceMappingURL=createNativeDevEngine.mjs.map
|