@nativescript/vite 8.0.0-alpha.3 → 8.0.0-alpha.31
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/README.md +51 -11
- package/configuration/angular.d.ts +34 -1
- package/configuration/angular.js +373 -163
- package/configuration/angular.js.map +1 -1
- package/configuration/base.js +184 -14
- package/configuration/base.js.map +1 -1
- package/configuration/javascript.js +5 -72
- package/configuration/javascript.js.map +1 -1
- package/configuration/solid.js +27 -1
- package/configuration/solid.js.map +1 -1
- package/configuration/typescript.js +5 -75
- package/configuration/typescript.js.map +1 -1
- package/helpers/app-components.d.ts +2 -1
- package/helpers/app-components.js.map +1 -1
- package/helpers/app-css-state.d.ts +8 -0
- package/helpers/app-css-state.js +8 -0
- package/helpers/app-css-state.js.map +1 -0
- package/helpers/bundler-context.d.ts +11 -0
- package/helpers/bundler-context.js +71 -0
- package/helpers/bundler-context.js.map +1 -0
- package/helpers/config-as-json.js +10 -0
- package/helpers/config-as-json.js.map +1 -1
- package/helpers/dev-host.d.ts +341 -0
- package/helpers/dev-host.js +617 -0
- package/helpers/dev-host.js.map +1 -0
- package/helpers/esbuild-platform-resolver.js +4 -1
- package/helpers/esbuild-platform-resolver.js.map +1 -1
- package/helpers/global-defines.d.ts +51 -0
- package/helpers/global-defines.js +77 -0
- package/helpers/global-defines.js.map +1 -1
- package/helpers/hmr-scope.d.ts +26 -0
- package/helpers/hmr-scope.js +67 -0
- package/helpers/hmr-scope.js.map +1 -0
- package/helpers/init.js +0 -18
- package/helpers/init.js.map +1 -1
- package/helpers/logging.d.ts +1 -0
- package/helpers/logging.js +63 -3
- package/helpers/logging.js.map +1 -1
- package/helpers/main-entry.d.ts +2 -1
- package/helpers/main-entry.js +430 -47
- package/helpers/main-entry.js.map +1 -1
- package/helpers/nativeclass-esbuild-plugin.d.ts +2 -1
- package/helpers/nativeclass-esbuild-plugin.js.map +1 -1
- package/helpers/nativeclass-transform.js.map +1 -1
- package/helpers/nativeclass-transformer-plugin.d.ts +9 -2
- package/helpers/nativeclass-transformer-plugin.js +157 -14
- package/helpers/nativeclass-transformer-plugin.js.map +1 -1
- package/helpers/nativescript-package-resolver.js +8 -3
- package/helpers/nativescript-package-resolver.js.map +1 -1
- package/helpers/normalize-id.d.ts +42 -0
- package/helpers/normalize-id.js +60 -0
- package/helpers/normalize-id.js.map +1 -0
- package/helpers/ns-core-url.d.ts +88 -0
- package/helpers/ns-core-url.js +191 -0
- package/helpers/ns-core-url.js.map +1 -0
- package/helpers/package-platform-aliases.js +4 -3
- package/helpers/package-platform-aliases.js.map +1 -1
- package/helpers/platform-types.d.ts +2 -0
- package/helpers/platform-types.js +2 -0
- package/helpers/platform-types.js.map +1 -0
- package/helpers/project.d.ts +35 -0
- package/helpers/project.js +120 -2
- package/helpers/project.js.map +1 -1
- package/helpers/resolver.js +17 -2
- package/helpers/resolver.js.map +1 -1
- package/helpers/ts-config-paths.d.ts +14 -0
- package/helpers/ts-config-paths.js +89 -8
- package/helpers/ts-config-paths.js.map +1 -1
- package/helpers/typescript-check.d.ts +2 -1
- package/helpers/typescript-check.js.map +1 -1
- package/helpers/workers.d.ts +20 -19
- package/helpers/workers.js +624 -4
- package/helpers/workers.js.map +1 -1
- package/hmr/client/css-handler.d.ts +1 -0
- package/hmr/client/css-handler.js +33 -20
- package/hmr/client/css-handler.js.map +1 -1
- package/hmr/client/css-update-overlay.d.ts +18 -0
- package/hmr/client/css-update-overlay.js +27 -0
- package/hmr/client/css-update-overlay.js.map +1 -0
- package/hmr/client/framework-client-strategy.d.ts +73 -0
- package/hmr/client/framework-client-strategy.js +19 -0
- package/hmr/client/framework-client-strategy.js.map +1 -0
- package/hmr/client/hmr-pending-overlay.d.ts +27 -0
- package/hmr/client/hmr-pending-overlay.js +50 -0
- package/hmr/client/hmr-pending-overlay.js.map +1 -0
- package/hmr/client/index.js +459 -164
- package/hmr/client/index.js.map +1 -1
- package/hmr/client/utils.d.ts +6 -1
- package/hmr/client/utils.js +184 -8
- package/hmr/client/utils.js.map +1 -1
- package/hmr/entry-runtime.d.ts +2 -1
- package/hmr/entry-runtime.js +252 -65
- package/hmr/entry-runtime.js.map +1 -1
- package/hmr/frameworks/angular/build/angular-linker.d.ts +12 -0
- package/hmr/frameworks/angular/build/angular-linker.js +109 -0
- package/hmr/frameworks/angular/build/angular-linker.js.map +1 -0
- package/hmr/frameworks/angular/build/inject-component-hmr-registration.d.ts +112 -0
- package/hmr/frameworks/angular/build/inject-component-hmr-registration.js +291 -0
- package/hmr/frameworks/angular/build/inject-component-hmr-registration.js.map +1 -0
- package/hmr/frameworks/angular/build/inject-hmr-vite-ignore.d.ts +75 -0
- package/hmr/frameworks/angular/build/inject-hmr-vite-ignore.js +221 -0
- package/hmr/frameworks/angular/build/inject-hmr-vite-ignore.js.map +1 -0
- package/{helpers/angular → hmr/frameworks/angular/build}/inline-decorator-component-templates.js +1 -170
- package/hmr/frameworks/angular/build/inline-decorator-component-templates.js.map +1 -0
- package/hmr/frameworks/angular/build/js-lexer.d.ts +4 -0
- package/{helpers/angular/synthesize-decorator-ctor-parameters.js → hmr/frameworks/angular/build/js-lexer.js} +22 -96
- package/hmr/frameworks/angular/build/js-lexer.js.map +1 -0
- package/hmr/frameworks/angular/build/shared-linker.d.ts +39 -0
- package/hmr/frameworks/angular/build/shared-linker.js +128 -0
- package/hmr/frameworks/angular/build/shared-linker.js.map +1 -0
- package/hmr/frameworks/angular/build/synthesize-decorator-ctor-parameters.js +88 -0
- package/hmr/frameworks/angular/build/synthesize-decorator-ctor-parameters.js.map +1 -0
- package/{helpers/angular → hmr/frameworks/angular/build}/synthesize-injectable-factories.js +1 -174
- package/hmr/frameworks/angular/build/synthesize-injectable-factories.js.map +1 -0
- package/{helpers/angular → hmr/frameworks/angular/build}/util.d.ts +1 -0
- package/hmr/frameworks/angular/build/util.js +155 -0
- package/hmr/frameworks/angular/build/util.js.map +1 -0
- package/hmr/frameworks/angular/client/index.d.ts +1 -0
- package/hmr/frameworks/angular/client/index.js +778 -20
- package/hmr/frameworks/angular/client/index.js.map +1 -1
- package/hmr/frameworks/angular/client/strategy.d.ts +9 -0
- package/hmr/frameworks/angular/client/strategy.js +19 -0
- package/hmr/frameworks/angular/client/strategy.js.map +1 -0
- package/hmr/frameworks/angular/server/angular-root-component.d.ts +79 -0
- package/hmr/frameworks/angular/server/angular-root-component.js +149 -0
- package/hmr/frameworks/angular/server/angular-root-component.js.map +1 -0
- package/hmr/frameworks/angular/server/linker.js +1 -4
- package/hmr/frameworks/angular/server/linker.js.map +1 -1
- package/hmr/frameworks/angular/server/strategy.js +448 -12
- package/hmr/frameworks/angular/server/strategy.js.map +1 -1
- package/hmr/{server → frameworks/angular/server}/websocket-angular-entry.js +2 -2
- package/hmr/frameworks/angular/server/websocket-angular-entry.js.map +1 -0
- package/hmr/{server → frameworks/angular/server}/websocket-angular-hot-update.d.ts +17 -11
- package/hmr/frameworks/angular/server/websocket-angular-hot-update.js +336 -0
- package/hmr/frameworks/angular/server/websocket-angular-hot-update.js.map +1 -0
- package/hmr/frameworks/solid/build/solid-jsx-deps.d.ts +15 -0
- package/hmr/frameworks/solid/build/solid-jsx-deps.js +178 -0
- package/hmr/frameworks/solid/build/solid-jsx-deps.js.map +1 -0
- package/hmr/frameworks/solid/server/strategy.js +360 -16
- package/hmr/frameworks/solid/server/strategy.js.map +1 -1
- package/hmr/frameworks/typescript/server/strategy.js +28 -14
- package/hmr/frameworks/typescript/server/strategy.js.map +1 -1
- package/hmr/frameworks/vue/client/index.js +30 -199
- package/hmr/frameworks/vue/client/index.js.map +1 -1
- package/hmr/frameworks/vue/client/strategy.d.ts +7 -0
- package/hmr/frameworks/vue/client/strategy.js +83 -0
- package/hmr/frameworks/vue/client/strategy.js.map +1 -0
- package/hmr/frameworks/vue/client/vue-sfc-update-overlay.d.ts +82 -0
- package/hmr/frameworks/vue/client/vue-sfc-update-overlay.js +133 -0
- package/hmr/frameworks/vue/client/vue-sfc-update-overlay.js.map +1 -0
- package/hmr/frameworks/vue/server/sfc-route-assemble.d.ts +7 -0
- package/hmr/frameworks/vue/server/sfc-route-assemble.js +706 -0
- package/hmr/frameworks/vue/server/sfc-route-assemble.js.map +1 -0
- package/hmr/frameworks/vue/server/sfc-route-meta.d.ts +7 -0
- package/hmr/frameworks/vue/server/sfc-route-meta.js +80 -0
- package/hmr/frameworks/vue/server/sfc-route-meta.js.map +1 -0
- package/hmr/frameworks/vue/server/sfc-route-serve.d.ts +8 -0
- package/hmr/frameworks/vue/server/sfc-route-serve.js +457 -0
- package/hmr/frameworks/vue/server/sfc-route-serve.js.map +1 -0
- package/hmr/frameworks/vue/server/sfc-route-shared.d.ts +19 -0
- package/hmr/frameworks/vue/server/sfc-route-shared.js +14 -0
- package/hmr/frameworks/vue/server/sfc-route-shared.js.map +1 -0
- package/hmr/frameworks/vue/server/strategy.js +244 -0
- package/hmr/frameworks/vue/server/strategy.js.map +1 -1
- package/hmr/frameworks/vue/server/websocket-sfc.d.ts +15 -0
- package/hmr/frameworks/vue/server/websocket-sfc.js +20 -0
- package/hmr/frameworks/vue/server/websocket-sfc.js.map +1 -0
- package/hmr/helpers/ast-normalizer.js +52 -5
- package/hmr/helpers/ast-normalizer.js.map +1 -1
- package/hmr/helpers/cjs-named-exports.d.ts +23 -0
- package/hmr/helpers/cjs-named-exports.js +152 -0
- package/hmr/helpers/cjs-named-exports.js.map +1 -0
- package/hmr/helpers/package-exports.d.ts +16 -0
- package/hmr/helpers/package-exports.js +396 -0
- package/hmr/helpers/package-exports.js.map +1 -0
- package/hmr/server/constants.js +13 -4
- package/hmr/server/constants.js.map +1 -1
- package/hmr/server/core-sanitize.d.ts +90 -7
- package/hmr/server/core-sanitize.js +211 -56
- package/hmr/server/core-sanitize.js.map +1 -1
- package/hmr/server/device-transform-helpers.d.ts +24 -0
- package/hmr/server/device-transform-helpers.js +327 -0
- package/hmr/server/device-transform-helpers.js.map +1 -0
- package/hmr/server/framework-strategy.d.ts +95 -11
- package/hmr/server/hmr-module-graph.d.ts +37 -0
- package/hmr/server/hmr-module-graph.js +214 -0
- package/hmr/server/hmr-module-graph.js.map +1 -0
- package/hmr/server/import-map.d.ts +11 -2
- package/hmr/server/import-map.js +59 -40
- package/hmr/server/import-map.js.map +1 -1
- package/hmr/server/index.js +7 -16
- package/hmr/server/index.js.map +1 -1
- package/hmr/server/ns-core-cjs-shape.d.ts +204 -0
- package/hmr/server/ns-core-cjs-shape.js +271 -0
- package/hmr/server/ns-core-cjs-shape.js.map +1 -0
- package/hmr/server/ns-rt-bridge.d.ts +51 -0
- package/hmr/server/ns-rt-bridge.js +131 -0
- package/hmr/server/ns-rt-bridge.js.map +1 -0
- package/hmr/server/ns-rt-route.d.ts +5 -0
- package/hmr/server/ns-rt-route.js +35 -0
- package/hmr/server/ns-rt-route.js.map +1 -0
- package/hmr/server/perf-instrumentation.d.ts +114 -0
- package/hmr/server/perf-instrumentation.js +195 -0
- package/hmr/server/perf-instrumentation.js.map +1 -0
- package/hmr/server/process-code-for-device.d.ts +15 -0
- package/hmr/server/process-code-for-device.js +654 -0
- package/hmr/server/process-code-for-device.js.map +1 -0
- package/hmr/server/require-guard.d.ts +1 -0
- package/hmr/server/require-guard.js +12 -0
- package/hmr/server/require-guard.js.map +1 -0
- package/hmr/server/rewrite-imports.d.ts +2 -0
- package/hmr/server/rewrite-imports.js +604 -0
- package/hmr/server/rewrite-imports.js.map +1 -0
- package/hmr/server/route-helpers.d.ts +7 -0
- package/hmr/server/route-helpers.js +13 -0
- package/hmr/server/route-helpers.js.map +1 -0
- package/hmr/server/server-origin.d.ts +12 -0
- package/hmr/server/server-origin.js +66 -0
- package/hmr/server/server-origin.js.map +1 -0
- package/hmr/server/shared-transform-request.js +12 -5
- package/hmr/server/shared-transform-request.js.map +1 -1
- package/hmr/server/transform-cache-invalidation.d.ts +11 -0
- package/hmr/server/transform-cache-invalidation.js +84 -0
- package/hmr/server/transform-cache-invalidation.js.map +1 -0
- package/hmr/server/vendor-bare-module-shims.d.ts +4 -0
- package/hmr/server/vendor-bare-module-shims.js +80 -0
- package/hmr/server/vendor-bare-module-shims.js.map +1 -0
- package/hmr/server/vite-plugin.js +60 -42
- package/hmr/server/vite-plugin.js.map +1 -1
- package/hmr/server/websocket-core-bridge.d.ts +41 -6
- package/hmr/server/websocket-core-bridge.js +72 -75
- package/hmr/server/websocket-core-bridge.js.map +1 -1
- package/hmr/server/websocket-css-hot-update.d.ts +33 -0
- package/hmr/server/websocket-css-hot-update.js +65 -0
- package/hmr/server/websocket-css-hot-update.js.map +1 -0
- package/hmr/server/websocket-device-transform.d.ts +3 -0
- package/hmr/server/websocket-device-transform.js +7 -0
- package/hmr/server/websocket-device-transform.js.map +1 -0
- package/hmr/server/websocket-graph-upsert.d.ts +15 -0
- package/hmr/server/websocket-graph-upsert.js +20 -0
- package/hmr/server/websocket-graph-upsert.js.map +1 -1
- package/hmr/server/websocket-hmr-pending.d.ts +37 -0
- package/hmr/server/websocket-hmr-pending.js +55 -0
- package/hmr/server/websocket-hmr-pending.js.map +1 -0
- package/hmr/server/websocket-hot-update.d.ts +77 -0
- package/hmr/server/websocket-hot-update.js +330 -0
- package/hmr/server/websocket-hot-update.js.map +1 -0
- package/hmr/server/websocket-import-map-route.d.ts +15 -0
- package/hmr/server/websocket-import-map-route.js +46 -0
- package/hmr/server/websocket-import-map-route.js.map +1 -0
- package/hmr/server/websocket-module-bindings.js +3 -3
- package/hmr/server/websocket-module-bindings.js.map +1 -1
- package/hmr/server/websocket-module-specifiers.d.ts +66 -2
- package/hmr/server/websocket-module-specifiers.js +202 -19
- package/hmr/server/websocket-module-specifiers.js.map +1 -1
- package/hmr/server/websocket-ns-core.d.ts +21 -0
- package/hmr/server/websocket-ns-core.js +306 -0
- package/hmr/server/websocket-ns-core.js.map +1 -0
- package/hmr/server/websocket-ns-entry.d.ts +21 -0
- package/hmr/server/websocket-ns-entry.js +150 -0
- package/hmr/server/websocket-ns-entry.js.map +1 -0
- package/hmr/server/websocket-ns-m-paths.d.ts +3 -0
- package/hmr/server/websocket-ns-m-paths.js +92 -0
- package/hmr/server/websocket-ns-m-paths.js.map +1 -0
- package/hmr/server/websocket-ns-m-request.d.ts +45 -0
- package/hmr/server/websocket-ns-m-request.js +196 -0
- package/hmr/server/websocket-ns-m-request.js.map +1 -0
- package/hmr/server/websocket-ns-m.d.ts +33 -0
- package/hmr/server/websocket-ns-m.js +748 -0
- package/hmr/server/websocket-ns-m.js.map +1 -0
- package/hmr/server/websocket-served-module-helpers.d.ts +39 -0
- package/hmr/server/websocket-served-module-helpers.js +654 -0
- package/hmr/server/websocket-served-module-helpers.js.map +1 -0
- package/hmr/server/websocket-txn.d.ts +6 -0
- package/hmr/server/websocket-txn.js +39 -0
- package/hmr/server/websocket-txn.js.map +1 -0
- package/hmr/server/websocket-vendor-unifier.d.ts +9 -0
- package/hmr/server/websocket-vendor-unifier.js +46 -0
- package/hmr/server/websocket-vendor-unifier.js.map +1 -0
- package/hmr/server/websocket.d.ts +8 -39
- package/hmr/server/websocket.js +602 -6049
- package/hmr/server/websocket.js.map +1 -1
- package/hmr/shared/ns-globals.d.ts +118 -0
- package/hmr/shared/ns-globals.js +27 -0
- package/hmr/shared/ns-globals.js.map +1 -0
- package/hmr/shared/protocol.d.ts +136 -0
- package/hmr/shared/protocol.js +28 -0
- package/hmr/shared/protocol.js.map +1 -0
- package/hmr/shared/runtime/boot-placeholder-ui.d.ts +69 -0
- package/hmr/shared/runtime/boot-placeholder-ui.js +101 -0
- package/hmr/shared/runtime/boot-placeholder-ui.js.map +1 -0
- package/hmr/shared/runtime/boot-progress.d.ts +40 -0
- package/hmr/shared/runtime/boot-progress.js +128 -0
- package/hmr/shared/runtime/boot-progress.js.map +1 -0
- package/hmr/shared/runtime/boot-timeline.d.ts +18 -0
- package/hmr/shared/runtime/boot-timeline.js +52 -0
- package/hmr/shared/runtime/boot-timeline.js.map +1 -0
- package/hmr/shared/runtime/dev-overlay-snapshots.d.ts +31 -0
- package/hmr/shared/runtime/dev-overlay-snapshots.js +324 -0
- package/hmr/shared/runtime/dev-overlay-snapshots.js.map +1 -0
- package/hmr/shared/runtime/dev-overlay.d.ts +75 -26
- package/hmr/shared/runtime/dev-overlay.js +990 -260
- package/hmr/shared/runtime/dev-overlay.js.map +1 -1
- package/hmr/shared/runtime/module-provenance.js +1 -4
- package/hmr/shared/runtime/module-provenance.js.map +1 -1
- package/hmr/shared/runtime/root-placeholder-view.d.ts +19 -0
- package/hmr/shared/runtime/root-placeholder-view.js +310 -0
- package/hmr/shared/runtime/root-placeholder-view.js.map +1 -0
- package/hmr/shared/runtime/root-placeholder.js +352 -194
- package/hmr/shared/runtime/root-placeholder.js.map +1 -1
- package/hmr/shared/runtime/session-bootstrap.js +164 -1
- package/hmr/shared/runtime/session-bootstrap.js.map +1 -1
- package/hmr/shared/runtime/vendor-bootstrap.js +1 -9
- package/hmr/shared/runtime/vendor-bootstrap.js.map +1 -1
- package/hmr/shared/vendor/manifest-collect.d.ts +4 -0
- package/hmr/shared/vendor/manifest-collect.js +512 -0
- package/hmr/shared/vendor/manifest-collect.js.map +1 -0
- package/hmr/shared/vendor/manifest-loader.d.ts +2 -1
- package/hmr/shared/vendor/manifest-loader.js +3 -2
- package/hmr/shared/vendor/manifest-loader.js.map +1 -1
- package/hmr/shared/vendor/manifest.d.ts +1 -7
- package/hmr/shared/vendor/manifest.js +102 -741
- package/hmr/shared/vendor/manifest.js.map +1 -1
- package/hmr/shared/vendor/vendor-device-shim.d.ts +1 -0
- package/hmr/shared/vendor/vendor-device-shim.js +208 -0
- package/hmr/shared/vendor/vendor-device-shim.js.map +1 -0
- package/hmr/shared/vendor/vendor-esbuild-plugins.d.ts +16 -0
- package/hmr/shared/vendor/vendor-esbuild-plugins.js +203 -0
- package/hmr/shared/vendor/vendor-esbuild-plugins.js.map +1 -0
- package/index.d.ts +1 -0
- package/index.js +5 -0
- package/index.js.map +1 -1
- package/package.json +55 -11
- package/runtime/core-aliases-early.js +17 -41
- package/runtime/core-aliases-early.js.map +1 -1
- package/helpers/angular/angular-linker.d.ts +0 -13
- package/helpers/angular/angular-linker.js +0 -194
- package/helpers/angular/angular-linker.js.map +0 -1
- package/helpers/angular/inline-decorator-component-templates.js.map +0 -1
- package/helpers/angular/shared-linker.d.ts +0 -11
- package/helpers/angular/shared-linker.js +0 -75
- package/helpers/angular/shared-linker.js.map +0 -1
- package/helpers/angular/synthesize-decorator-ctor-parameters.js.map +0 -1
- package/helpers/angular/synthesize-injectable-factories.js.map +0 -1
- package/helpers/angular/util.js +0 -67
- package/helpers/angular/util.js.map +0 -1
- package/helpers/prelink-angular.d.ts +0 -2
- package/helpers/prelink-angular.js +0 -117
- package/helpers/prelink-angular.js.map +0 -1
- package/hmr/server/websocket-angular-entry.js.map +0 -1
- package/hmr/server/websocket-angular-hot-update.js +0 -239
- package/hmr/server/websocket-angular-hot-update.js.map +0 -1
- /package/{helpers/angular → hmr/frameworks/angular/build}/inline-decorator-component-templates.d.ts +0 -0
- /package/{helpers/angular → hmr/frameworks/angular/build}/synthesize-decorator-ctor-parameters.d.ts +0 -0
- /package/{helpers/angular → hmr/frameworks/angular/build}/synthesize-injectable-factories.d.ts +0 -0
- /package/hmr/{server → frameworks/angular/server}/websocket-angular-entry.d.ts +0 -0
|
@@ -0,0 +1,617 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical resolver for the Vite dev-server origin that a NativeScript
|
|
3
|
+
* device or simulator can actually reach.
|
|
4
|
+
*
|
|
5
|
+
* Why this exists. The Vite dev server commonly binds to `0.0.0.0`
|
|
6
|
+
* (the wildcard "all interfaces" address) so both the host browser and
|
|
7
|
+
* a sibling mobile device can hit it. That bind address is fine for
|
|
8
|
+
* the LISTENING socket — but it is NOT a routable hostname:
|
|
9
|
+
*
|
|
10
|
+
* - iOS Simulator shares the host's network stack, so `localhost` /
|
|
11
|
+
* `127.0.0.1` work from inside the simulator and even `0.0.0.0`
|
|
12
|
+
* sometimes resolves there. The simulator path is forgiving.
|
|
13
|
+
*
|
|
14
|
+
* - Android Emulator runs inside a virtual NIC with NAT (QEMU
|
|
15
|
+
* `slirp`). `0.0.0.0` and `localhost` / `127.0.0.1` refer to the
|
|
16
|
+
* EMULATOR ITSELF, not the development host. Two routable paths
|
|
17
|
+
* exist:
|
|
18
|
+
*
|
|
19
|
+
* (a) `adb reverse tcp:<port> tcp:<port>` — multiplexes the
|
|
20
|
+
* device-side `127.0.0.1:<port>` over the existing ADB
|
|
21
|
+
* transport to the host. This is the PREFERRED path: slirp
|
|
22
|
+
* is famously flaky under burst-connect load and drops
|
|
23
|
+
* ~80% of cold-boot module-loader fetches with
|
|
24
|
+
* `IOException: unexpected end of stream`. The ADB tunnel
|
|
25
|
+
* bypasses slirp entirely and is reliable. We try this
|
|
26
|
+
* automatically — see `tryEnableAdbReverse`. We emit the
|
|
27
|
+
* IPv4 literal `127.0.0.1` instead of `localhost` because
|
|
28
|
+
* Android API 36+ system images periodically ship without
|
|
29
|
+
* a `localhost` mapping in the resolver, and
|
|
30
|
+
* `UnknownHostException` fires before adb-reverse can do
|
|
31
|
+
* its job.
|
|
32
|
+
*
|
|
33
|
+
* (b) `10.0.2.2` (Genymotion: `10.0.3.2`) — slirp's host alias.
|
|
34
|
+
* Used as a fallback when ADB isn't available or the user
|
|
35
|
+
* opted out via `NS_HMR_NO_ADB_REVERSE=1`. Works, just less
|
|
36
|
+
* reliable than the ADB tunnel.
|
|
37
|
+
*
|
|
38
|
+
* - Physical Android devices over USB get the same automatic
|
|
39
|
+
* `adb reverse` treatment as emulators. Over Wi-Fi (no ADB
|
|
40
|
+
* tunnel), the user must opt out of adb reverse via
|
|
41
|
+
* `NS_HMR_NO_ADB_REVERSE=1` and supply a routable host via
|
|
42
|
+
* `NS_HMR_HOST=<ip>` or `NS_HMR_PREFER_LAN_HOST=1`.
|
|
43
|
+
*
|
|
44
|
+
* Without this normalization, `bundle.mjs` ships with statically
|
|
45
|
+
* embedded URLs like `http://0.0.0.0:5173/ns/core/xhr` and the very
|
|
46
|
+
* first dynamic import during Application boot fails with
|
|
47
|
+
* `status=0 (network unreachable)` on Android, killing the runtime
|
|
48
|
+
* before any user code runs.
|
|
49
|
+
*
|
|
50
|
+
* Resolution rules (highest precedence first):
|
|
51
|
+
*
|
|
52
|
+
* 1. `process.env.NS_HMR_HOST` — always wins. CI, tunneled setups,
|
|
53
|
+
* and remote devices use this to point at a known-good origin.
|
|
54
|
+
*
|
|
55
|
+
* 2. A concrete non-wildcard, non-loopback `host` arg — trust the
|
|
56
|
+
* developer's explicit choice (`server.host: '192.168.1.42'`
|
|
57
|
+
* already routes from any device on the LAN).
|
|
58
|
+
*
|
|
59
|
+
* 3. `process.env.NS_HMR_PREFER_LAN_HOST` truthy AND a LAN NIC is
|
|
60
|
+
* detected — emit the LAN IP. Opt-in for physical-device-over-
|
|
61
|
+
* Wi-Fi dev. Also disables the adb-reverse path below so the
|
|
62
|
+
* caller actually gets LAN routing.
|
|
63
|
+
*
|
|
64
|
+
* 4. Wildcard bind (`0.0.0.0`, `::`, `true`, empty) OR Android
|
|
65
|
+
* loopback — emit the platform-appropriate routable address.
|
|
66
|
+
* For Android, we first try `adb reverse tcp:<port> tcp:<port>`
|
|
67
|
+
* and emit `127.0.0.1` on success (bypasses slirp NAT entirely
|
|
68
|
+
* and avoids Android API 36+'s missing-`localhost`-from-resolver
|
|
69
|
+
* bug); on failure we fall back to `10.0.2.2`. iOS/visionOS get
|
|
70
|
+
* `localhost` directly. iOS/visionOS loopback passes through
|
|
71
|
+
* unchanged.
|
|
72
|
+
*
|
|
73
|
+
* Every dev-mode emitter that bakes a URL into `bundle.mjs` or sends
|
|
74
|
+
* one to a device-side fetch site MUST run through this helper so the
|
|
75
|
+
* device receives a single canonical, reachable origin.
|
|
76
|
+
*/
|
|
77
|
+
import os from 'node:os';
|
|
78
|
+
import path from 'node:path';
|
|
79
|
+
import fs from 'node:fs';
|
|
80
|
+
import { execFileSync } from 'node:child_process';
|
|
81
|
+
const WILDCARD_HOSTS = new Set(['0.0.0.0', '::', '', 'true']);
|
|
82
|
+
const LOOPBACK_HOSTS = new Set(['localhost', '127.0.0.1', '::1']);
|
|
83
|
+
const adbReverseCache = new Map();
|
|
84
|
+
/**
|
|
85
|
+
* Returns the first non-internal IPv4 address on the host machine, or
|
|
86
|
+
* `undefined` if no LAN NIC is up. Pure wrapper around
|
|
87
|
+
* `os.networkInterfaces()` so callers and tests can stub it cleanly.
|
|
88
|
+
*/
|
|
89
|
+
export function guessLanHost() {
|
|
90
|
+
try {
|
|
91
|
+
const nets = os.networkInterfaces();
|
|
92
|
+
for (const name of Object.keys(nets)) {
|
|
93
|
+
const addrs = nets[name] || [];
|
|
94
|
+
for (const addr of addrs) {
|
|
95
|
+
if (!addr)
|
|
96
|
+
continue;
|
|
97
|
+
// Node typings vary across versions; keep checks defensive.
|
|
98
|
+
const family = addr.family;
|
|
99
|
+
const internal = !!addr.internal;
|
|
100
|
+
const address = String(addr.address || '');
|
|
101
|
+
if (internal)
|
|
102
|
+
continue;
|
|
103
|
+
if (family !== 'IPv4' && family !== 4)
|
|
104
|
+
continue;
|
|
105
|
+
if (address && address !== '127.0.0.1')
|
|
106
|
+
return address;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
catch { }
|
|
111
|
+
return undefined;
|
|
112
|
+
}
|
|
113
|
+
function normalizeHostInput(host) {
|
|
114
|
+
if (host === true)
|
|
115
|
+
return '0.0.0.0';
|
|
116
|
+
if (host === false || host == null)
|
|
117
|
+
return '';
|
|
118
|
+
const s = String(host).trim();
|
|
119
|
+
return s;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Whether the given host string is a wildcard "all interfaces" bind
|
|
123
|
+
* address rather than a routable hostname. `host` may be the literal
|
|
124
|
+
* string from a Vite config (`'0.0.0.0'`), an empty string, or `'true'`
|
|
125
|
+
* (some older Vite/CLI surfaces stringify the boolean).
|
|
126
|
+
*/
|
|
127
|
+
export function isWildcardHost(host) {
|
|
128
|
+
return WILDCARD_HOSTS.has(host);
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Whether the given host string is loopback. On Android the loopback
|
|
132
|
+
* address is the device itself, NOT the development host — so callers
|
|
133
|
+
* must remap it for Android consumers.
|
|
134
|
+
*/
|
|
135
|
+
export function isLoopbackHost(host) {
|
|
136
|
+
return LOOPBACK_HOSTS.has(host);
|
|
137
|
+
}
|
|
138
|
+
function isTruthyEnvFlag(value) {
|
|
139
|
+
if (typeof value !== 'string')
|
|
140
|
+
return false;
|
|
141
|
+
const v = value.trim().toLowerCase();
|
|
142
|
+
if (!v)
|
|
143
|
+
return false;
|
|
144
|
+
return v !== '0' && v !== 'false' && v !== 'off' && v !== 'no';
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Resolve the `adb` executable the way the Android SDK tooling does,
|
|
148
|
+
* so the plugin and the NativeScript CLI drive the *same* adb client.
|
|
149
|
+
*
|
|
150
|
+
* Why this is load-bearing. A bare `adb` from `$PATH` is frequently a
|
|
151
|
+
* DIFFERENT version than the one the CLI resolves from the SDK. When
|
|
152
|
+
* two adb *clients* of differing versions talk to the one global adb
|
|
153
|
+
* server (port 5037), the newer client prints
|
|
154
|
+
* `adb server version (NN) doesn't match this client (MM); killing...`
|
|
155
|
+
* and restarts the daemon — severing the CLI's `track-devices` stream
|
|
156
|
+
* and hanging it at "Searching for devices…" forever. Resolving the
|
|
157
|
+
* exact SDK adb eliminates that mismatch.
|
|
158
|
+
*
|
|
159
|
+
* Precedence:
|
|
160
|
+
* 1. `NS_ADB_PATH` — the CLI exports the absolute path to the adb it
|
|
161
|
+
* itself uses. Always wins so the two processes are byte-identical.
|
|
162
|
+
* 2. `$ANDROID_HOME/platform-tools/adb` (+ `.exe` on Windows).
|
|
163
|
+
* 3. `$ANDROID_SDK_ROOT/platform-tools/adb`.
|
|
164
|
+
* 4. Bare `adb` — last-resort PATH lookup (kept only so a machine
|
|
165
|
+
* with adb on PATH but no SDK env still limps along).
|
|
166
|
+
*
|
|
167
|
+
* Candidates from (2)/(3) are existence-checked; a stale env var that
|
|
168
|
+
* points at a missing binary falls through rather than guaranteeing a
|
|
169
|
+
* spawn failure.
|
|
170
|
+
*/
|
|
171
|
+
export function resolveAdbPath(env = process.env) {
|
|
172
|
+
const explicit = (env.NS_ADB_PATH || '').trim();
|
|
173
|
+
if (explicit)
|
|
174
|
+
return explicit;
|
|
175
|
+
const exe = process.platform === 'win32' ? 'adb.exe' : 'adb';
|
|
176
|
+
for (const root of [env.ANDROID_HOME, env.ANDROID_SDK_ROOT]) {
|
|
177
|
+
const r = (root || '').trim();
|
|
178
|
+
if (!r)
|
|
179
|
+
continue;
|
|
180
|
+
const candidate = path.join(r, 'platform-tools', exe);
|
|
181
|
+
try {
|
|
182
|
+
if (fs.existsSync(candidate))
|
|
183
|
+
return candidate;
|
|
184
|
+
}
|
|
185
|
+
catch {
|
|
186
|
+
// fs probe failed (perms, race) — fall through to the next root.
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return exe;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Read-only view of the current `adb reverse` status for a given
|
|
193
|
+
* dev-server port. Returns `undefined` if `tryEnableAdbReverse` has
|
|
194
|
+
* never been called for that port.
|
|
195
|
+
*/
|
|
196
|
+
export function getAdbReverseStatus(port) {
|
|
197
|
+
return adbReverseCache.get(port);
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Test hook — clears the per-port cache so unit tests can exercise
|
|
201
|
+
* fresh "first call" behavior without leaking state between cases.
|
|
202
|
+
* NOT exported from the package barrel; spec files import via the
|
|
203
|
+
* file path directly.
|
|
204
|
+
*/
|
|
205
|
+
export function __resetAdbReverseCacheForTests() {
|
|
206
|
+
adbReverseCache.clear();
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Try to set up `adb reverse tcp:<port> tcp:<port>` for every
|
|
210
|
+
* connected Android device / emulator so device-side `localhost:port`
|
|
211
|
+
* routes through the ADB transport to the host's dev server.
|
|
212
|
+
*
|
|
213
|
+
* Why this beats `10.0.2.2`. The Android emulator's stock NAT is
|
|
214
|
+
* QEMU's `slirp` user-mode network stack, which is well-known to
|
|
215
|
+
* drop bursts of concurrent TCP setups to the host. In practice this
|
|
216
|
+
* surfaces as ~80% of synchronous module-loader fetches failing with
|
|
217
|
+
* `IOException: unexpected end of stream` — the connection establishes,
|
|
218
|
+
* the request goes out, and then slirp drops the response before
|
|
219
|
+
* okhttp can read the status line. The failures are random per-module
|
|
220
|
+
* across runs, retries help but don't eliminate them, and the symptom
|
|
221
|
+
* masquerades as a server-side bug.
|
|
222
|
+
*
|
|
223
|
+
* `adb reverse` bypasses the emulator NIC entirely — the device-side
|
|
224
|
+
* connection is multiplexed over the existing ADB USB / TCP channel
|
|
225
|
+
* to the host. It's the same mechanism React Native, Expo, and
|
|
226
|
+
* Flutter use for Android dev, and it works for both emulators and
|
|
227
|
+
* USB-connected physical devices.
|
|
228
|
+
*
|
|
229
|
+
* Caching. The result is cached per-port so repeat callers don't
|
|
230
|
+
* fork extra subprocesses. The cache is keyed on port (not platform)
|
|
231
|
+
* because the wildcard "Android-ness" of the call is already implied
|
|
232
|
+
* by the caller — only Android consumers hit this path.
|
|
233
|
+
*
|
|
234
|
+
* CLI handoff (the preferred path). When the NativeScript CLI drives
|
|
235
|
+
* the run it already owns device discovery, install, and launch — it
|
|
236
|
+
* knows the exact target serial and exactly when the device is ready.
|
|
237
|
+
* In that mode the CLI performs the `adb reverse` itself, with its own
|
|
238
|
+
* SDK-resolved adb, AFTER the device is up, and exports
|
|
239
|
+
* `NS_ADB_REVERSE_READY=1`. Seeing that flag, this function returns a
|
|
240
|
+
* synthetic success WITHOUT spawning adb at all — removing the second,
|
|
241
|
+
* racing adb owner that used to collide with the CLI's device search
|
|
242
|
+
* during cold start. `NS_DEVICE_SERIAL` (the CLI's deploy target) and
|
|
243
|
+
* `NS_ADB_PATH` (the CLI's adb) are honored in the self-managed
|
|
244
|
+
* fallback below for setups where the CLI did NOT pre-wire the reverse.
|
|
245
|
+
*
|
|
246
|
+
* Self-managed hardening (fallback). When `NS_ADB_REVERSE_READY` is
|
|
247
|
+
* absent we still set the mapping ourselves, but defensively:
|
|
248
|
+
* - resolve adb from the SDK (`resolveAdbPath`) — never a bare PATH
|
|
249
|
+
* `adb` that could version-mismatch and kill the CLI's daemon;
|
|
250
|
+
* - `adb start-server` once up front so a cold daemon is owned by a
|
|
251
|
+
* single, version-matched client before anything else touches it;
|
|
252
|
+
* - argv `execFileSync` (no shell) with a child-killing timeout so a
|
|
253
|
+
* hung adb is reaped rather than orphaned;
|
|
254
|
+
* - `wait-for-device` per serial so we don't issue `reverse` against
|
|
255
|
+
* an emulator whose `adbd` hasn't finished coming up.
|
|
256
|
+
*
|
|
257
|
+
* Failure modes (all surface as a cached `succeeded: false`):
|
|
258
|
+
* - `NS_HMR_NO_ADB_REVERSE=1` — explicit opt-out for unusual
|
|
259
|
+
* setups (e.g. Wi-Fi-connected device with no ADB tunnel, CI
|
|
260
|
+
* containers without ADB installed).
|
|
261
|
+
* - `adb` not resolvable / not runnable.
|
|
262
|
+
* - No connected devices — user started Vite before booting the
|
|
263
|
+
* emulator. We do NOT keep retrying after the first failure
|
|
264
|
+
* because the URL is baked into bundle.mjs at config-load time
|
|
265
|
+
* and there's no point in flipping it later.
|
|
266
|
+
* - "more than one device" — fatal for unqualified `adb reverse`,
|
|
267
|
+
* so we target each serial individually with `-s <serial>`. As
|
|
268
|
+
* long as at least one device gets the mapping we treat the whole
|
|
269
|
+
* call as a success.
|
|
270
|
+
*/
|
|
271
|
+
export function tryEnableAdbReverse(opts) {
|
|
272
|
+
const cached = adbReverseCache.get(opts.port);
|
|
273
|
+
if (cached)
|
|
274
|
+
return cached;
|
|
275
|
+
const env = opts.env || process.env;
|
|
276
|
+
// Explicit opt-out wins over everything — the user wants the
|
|
277
|
+
// `10.0.2.2` / LAN path, so don't claim a tunnel exists even if the
|
|
278
|
+
// CLI thinks it wired one.
|
|
279
|
+
if (isTruthyEnvFlag(env.NS_HMR_NO_ADB_REVERSE)) {
|
|
280
|
+
const status = { attempted: false, succeeded: false, devices: [], error: 'opt-out via NS_HMR_NO_ADB_REVERSE' };
|
|
281
|
+
adbReverseCache.set(opts.port, status);
|
|
282
|
+
return status;
|
|
283
|
+
}
|
|
284
|
+
// CLI handoff. The CLI already established the reverse with its own
|
|
285
|
+
// adb after the device was ready; we trust it and never spawn adb.
|
|
286
|
+
// This is what removes the cold-start race entirely.
|
|
287
|
+
if (isTruthyEnvFlag(env.NS_ADB_REVERSE_READY)) {
|
|
288
|
+
const serial = (env.NS_DEVICE_SERIAL || '').trim();
|
|
289
|
+
const status = {
|
|
290
|
+
attempted: false,
|
|
291
|
+
succeeded: true,
|
|
292
|
+
devices: serial ? [serial] : [],
|
|
293
|
+
viaCli: true,
|
|
294
|
+
};
|
|
295
|
+
adbReverseCache.set(opts.port, status);
|
|
296
|
+
try {
|
|
297
|
+
console.log(`[NativeScript] adb reverse for tcp:${opts.port} provided by the NativeScript CLI${serial ? ` (device ${serial})` : ''} — device-side 127.0.0.1:${opts.port} tunnels to host.`);
|
|
298
|
+
}
|
|
299
|
+
catch { }
|
|
300
|
+
return status;
|
|
301
|
+
}
|
|
302
|
+
// Test-safety guard. When we're running inside vitest / jest /
|
|
303
|
+
// any other test runner AND the caller did NOT inject an explicit
|
|
304
|
+
// exec stub, refuse to spawn a real `adb` subprocess. Spec files
|
|
305
|
+
// that pass `env: {}` aren't expecting us to mutate the dev's real
|
|
306
|
+
// device state (set up an actual `adb reverse` mapping on
|
|
307
|
+
// `port:5173` they didn't ask for) just by exercising the host
|
|
308
|
+
// resolver. We DO NOT cache this skip — a subsequent call with a
|
|
309
|
+
// real `exec` stub from the same suite should still run.
|
|
310
|
+
const ambient = process.env;
|
|
311
|
+
const inTestRunner = ambient.VITEST === 'true' || ambient.NODE_ENV === 'test' || typeof ambient.JEST_WORKER_ID === 'string';
|
|
312
|
+
if (!opts.exec && inTestRunner) {
|
|
313
|
+
return { attempted: false, succeeded: false, devices: [], error: 'test environment (auto-skip)' };
|
|
314
|
+
}
|
|
315
|
+
const adbPath = resolveAdbPath(env);
|
|
316
|
+
const exec = opts.exec ||
|
|
317
|
+
((bin, args, o) => execFileSync(bin, args, {
|
|
318
|
+
timeout: o.timeout,
|
|
319
|
+
// No `/bin/sh` wrapper: on timeout the signal lands on the
|
|
320
|
+
// real adb child, not a shell that would orphan it.
|
|
321
|
+
killSignal: 'SIGKILL',
|
|
322
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
323
|
+
encoding: 'utf8',
|
|
324
|
+
}));
|
|
325
|
+
// Ensure a single, version-matched adb daemon is up and owned by
|
|
326
|
+
// THIS client before any other command. Best-effort: if it throws,
|
|
327
|
+
// the `adb devices` call below reports the real failure.
|
|
328
|
+
try {
|
|
329
|
+
exec(adbPath, ['start-server'], { timeout: 10000 });
|
|
330
|
+
}
|
|
331
|
+
catch {
|
|
332
|
+
// start-server failures are reported via the enumerate step.
|
|
333
|
+
}
|
|
334
|
+
// Determine target serials. When the CLI handed us the deploy
|
|
335
|
+
// target (`NS_DEVICE_SERIAL`) we scope to exactly that serial and
|
|
336
|
+
// skip enumeration — no `adb devices`, no multi-device ambiguity.
|
|
337
|
+
// Otherwise enumerate so we (a) bail cleanly when there's no device
|
|
338
|
+
// and (b) target each connected device individually.
|
|
339
|
+
let devices = [];
|
|
340
|
+
const targetSerial = (env.NS_DEVICE_SERIAL || '').trim();
|
|
341
|
+
if (targetSerial) {
|
|
342
|
+
devices = [targetSerial];
|
|
343
|
+
}
|
|
344
|
+
else {
|
|
345
|
+
try {
|
|
346
|
+
const raw = exec(adbPath, ['devices'], { timeout: 5000 });
|
|
347
|
+
devices = parseAdbDevicesOutput(raw);
|
|
348
|
+
}
|
|
349
|
+
catch (err) {
|
|
350
|
+
const status = {
|
|
351
|
+
attempted: true,
|
|
352
|
+
succeeded: false,
|
|
353
|
+
devices: [],
|
|
354
|
+
error: `adb not available: ${String(err?.message || err)}`,
|
|
355
|
+
};
|
|
356
|
+
adbReverseCache.set(opts.port, status);
|
|
357
|
+
return status;
|
|
358
|
+
}
|
|
359
|
+
if (devices.length === 0) {
|
|
360
|
+
const status = {
|
|
361
|
+
attempted: true,
|
|
362
|
+
succeeded: false,
|
|
363
|
+
devices: [],
|
|
364
|
+
error: 'no connected Android devices',
|
|
365
|
+
};
|
|
366
|
+
adbReverseCache.set(opts.port, status);
|
|
367
|
+
try {
|
|
368
|
+
console.warn(`[NativeScript] adb reverse skipped — no Android devices connected yet. Bundle URLs will use 10.0.2.2 (emulator NAT). For best reliability boot the emulator BEFORE \`ns run android\` so adb reverse can wire 127.0.0.1:${opts.port} through ADB instead.`);
|
|
369
|
+
}
|
|
370
|
+
catch { }
|
|
371
|
+
return status;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
// Apply per-device so multi-device setups don't hit the "more
|
|
375
|
+
// than one device" failure. We tolerate per-device failures so
|
|
376
|
+
// long as at least one mapping landed — the user's target device
|
|
377
|
+
// is almost always the first connected one.
|
|
378
|
+
const successes = [];
|
|
379
|
+
const errors = [];
|
|
380
|
+
for (const serial of devices) {
|
|
381
|
+
try {
|
|
382
|
+
// Don't `reverse` against a device whose adbd isn't accepting
|
|
383
|
+
// yet (emulators report `device` state before `adbd` is ready).
|
|
384
|
+
// `wait-for-device` blocks only until the transport is up, then
|
|
385
|
+
// returns immediately on an already-ready device.
|
|
386
|
+
try {
|
|
387
|
+
exec(adbPath, ['-s', serial, 'wait-for-device'], { timeout: 10000 });
|
|
388
|
+
}
|
|
389
|
+
catch {
|
|
390
|
+
// Non-fatal: fall through and let `reverse` surface the real
|
|
391
|
+
// error if the device truly isn't reachable.
|
|
392
|
+
}
|
|
393
|
+
exec(adbPath, ['-s', serial, 'reverse', `tcp:${opts.port}`, `tcp:${opts.port}`], { timeout: 5000 });
|
|
394
|
+
successes.push(serial);
|
|
395
|
+
}
|
|
396
|
+
catch (err) {
|
|
397
|
+
errors.push(`${serial}: ${String(err?.message || err)}`);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
const status = {
|
|
401
|
+
attempted: true,
|
|
402
|
+
succeeded: successes.length > 0,
|
|
403
|
+
devices: successes,
|
|
404
|
+
error: successes.length === 0 ? errors.join('; ') || 'all devices failed' : undefined,
|
|
405
|
+
};
|
|
406
|
+
adbReverseCache.set(opts.port, status);
|
|
407
|
+
// One-line user-facing receipt so the dev knows why bundle.mjs
|
|
408
|
+
// suddenly switched from `10.0.2.2` to `127.0.0.1`. We only log
|
|
409
|
+
// outside test runners (covered above) so spec output stays clean.
|
|
410
|
+
try {
|
|
411
|
+
if (status.succeeded) {
|
|
412
|
+
console.log(`[NativeScript] adb reverse tcp:${opts.port} tcp:${opts.port} → ${successes.join(', ')} (Android device-side 127.0.0.1:${opts.port} now tunnels to host — bypasses emulator NAT)`);
|
|
413
|
+
}
|
|
414
|
+
else if (errors.length > 0) {
|
|
415
|
+
console.warn(`[NativeScript] adb reverse failed for tcp:${opts.port} — falling back to 10.0.2.2 (slirp NAT). Module fetches may hit IOException: unexpected end of stream under load. Reasons: ${status.error}`);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
catch {
|
|
419
|
+
// Logging is best-effort. We never want a console misbehavior
|
|
420
|
+
// to take down dev-server boot.
|
|
421
|
+
}
|
|
422
|
+
return status;
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* Parse the line-oriented output of `adb devices`:
|
|
426
|
+
*
|
|
427
|
+
* List of devices attached
|
|
428
|
+
* emulator-5554\tdevice
|
|
429
|
+
* ABCDEF12\tdevice
|
|
430
|
+
* somemodel\tunauthorized
|
|
431
|
+
*
|
|
432
|
+
* We keep only entries whose second column is exactly `device`
|
|
433
|
+
* (skip `unauthorized`, `offline`, `recovery`, etc. — none of those
|
|
434
|
+
* can accept an `adb reverse` command).
|
|
435
|
+
*/
|
|
436
|
+
function parseAdbDevicesOutput(raw) {
|
|
437
|
+
const out = [];
|
|
438
|
+
const lines = String(raw || '').split(/\r?\n/);
|
|
439
|
+
for (const line of lines) {
|
|
440
|
+
const trimmed = line.trim();
|
|
441
|
+
if (!trimmed)
|
|
442
|
+
continue;
|
|
443
|
+
if (trimmed.startsWith('List of devices'))
|
|
444
|
+
continue;
|
|
445
|
+
if (trimmed.startsWith('*'))
|
|
446
|
+
continue; // daemon startup chatter
|
|
447
|
+
const parts = trimmed.split(/\s+/);
|
|
448
|
+
if (parts.length < 2)
|
|
449
|
+
continue;
|
|
450
|
+
if (parts[1] !== 'device')
|
|
451
|
+
continue;
|
|
452
|
+
out.push(parts[0]);
|
|
453
|
+
}
|
|
454
|
+
return out;
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* Pick the host string a device or simulator can actually reach.
|
|
458
|
+
*
|
|
459
|
+
* See the file-level comment for the full resolution-precedence
|
|
460
|
+
* narrative. Returns the chosen host alongside a `source` tag so
|
|
461
|
+
* callers (and logs) can explain why a given URL was emitted.
|
|
462
|
+
*/
|
|
463
|
+
export function resolveDeviceReachableHost(opts) {
|
|
464
|
+
const env = opts.env || process.env;
|
|
465
|
+
const lanHostResolver = opts.lanHostResolver || guessLanHost;
|
|
466
|
+
// 1. Explicit env override always wins.
|
|
467
|
+
const envOverride = env.NS_HMR_HOST;
|
|
468
|
+
if (typeof envOverride === 'string' && envOverride.length > 0) {
|
|
469
|
+
return { host: envOverride, source: 'env' };
|
|
470
|
+
}
|
|
471
|
+
const raw = normalizeHostInput(opts.host);
|
|
472
|
+
// 2. Explicit non-wildcard, non-loopback host — trust the developer.
|
|
473
|
+
// Loopback addresses on Android still need remapping (see step 4),
|
|
474
|
+
// so we only short-circuit here for the truly routable case.
|
|
475
|
+
if (raw && !isWildcardHost(raw) && !isLoopbackHost(raw)) {
|
|
476
|
+
return { host: raw, source: 'explicit' };
|
|
477
|
+
}
|
|
478
|
+
// 3. Physical-device opt-in. The Android emulator default below
|
|
479
|
+
// (`10.0.2.2`) doesn't reach a real device on the LAN, so users
|
|
480
|
+
// running on hardware set `NS_HMR_PREFER_LAN_HOST=1` to pick up
|
|
481
|
+
// the host's LAN IP at build time. iOS/visionOS rarely needs
|
|
482
|
+
// this (the simulator stays on the loopback path) but the same
|
|
483
|
+
// opt-in works on those platforms for parity.
|
|
484
|
+
//
|
|
485
|
+
// `NS_HMR_PREFER_LAN_HOST` ALSO suppresses the adb-reverse path
|
|
486
|
+
// below — when the user has explicitly asked for LAN routing
|
|
487
|
+
// we don't want to silently bypass them with an ADB tunnel.
|
|
488
|
+
if (isTruthyEnvFlag(env.NS_HMR_PREFER_LAN_HOST)) {
|
|
489
|
+
const lan = lanHostResolver();
|
|
490
|
+
if (lan) {
|
|
491
|
+
return { host: lan, source: 'lan' };
|
|
492
|
+
}
|
|
493
|
+
// Fall through to the platform default when no LAN NIC was
|
|
494
|
+
// detected (e.g. running in a CI container) — better to fail
|
|
495
|
+
// at the always-works fallback than emit nothing.
|
|
496
|
+
}
|
|
497
|
+
// 4. Wildcard bind — fall back to the platform-appropriate routable
|
|
498
|
+
// address. We DELIBERATELY do NOT auto-pick a LAN IP here on
|
|
499
|
+
// Android: standard emulator NAT drops packets destined for the
|
|
500
|
+
// host's LAN IP, even when those IPs resolve fine from the
|
|
501
|
+
// host's own browser. `10.0.2.2` is the next-best fallback when
|
|
502
|
+
// adb reverse isn't available; otherwise the emulator slirp NAT
|
|
503
|
+
// drops a meaningful fraction of TCP setups under burst load and
|
|
504
|
+
// cold-boot hits `IOException: unexpected end of stream` for
|
|
505
|
+
// random modules each run.
|
|
506
|
+
if (isWildcardHost(raw)) {
|
|
507
|
+
return platformDefault(opts);
|
|
508
|
+
}
|
|
509
|
+
// 5. Loopback. iOS / visionOS keeps `localhost` (simulator network
|
|
510
|
+
// stack reaches the host); Android remaps to `10.0.2.2` /
|
|
511
|
+
// `localhost`-via-adb-reverse (loopback on Android refers to
|
|
512
|
+
// the EMULATOR ITSELF, not the host).
|
|
513
|
+
if (isLoopbackHost(raw)) {
|
|
514
|
+
if (opts.platform === 'android') {
|
|
515
|
+
return platformDefault(opts);
|
|
516
|
+
}
|
|
517
|
+
return { host: raw, source: 'explicit' };
|
|
518
|
+
}
|
|
519
|
+
// 6. Empty / unrecognised — fall back to platform default.
|
|
520
|
+
return platformDefault(opts);
|
|
521
|
+
}
|
|
522
|
+
function platformDefault(opts) {
|
|
523
|
+
if (opts.platform === 'android') {
|
|
524
|
+
// Try to bring up an `adb reverse` tunnel first. When that
|
|
525
|
+
// succeeds, `localhost` on the device routes through the
|
|
526
|
+
// existing ADB channel to the host's dev server — which
|
|
527
|
+
// sidesteps the QEMU slirp NAT entirely (see
|
|
528
|
+
// `tryEnableAdbReverse` for why that matters). When adb is
|
|
529
|
+
// unavailable, the device is disconnected, or the user opted
|
|
530
|
+
// out via `NS_HMR_NO_ADB_REVERSE`, we fall through to
|
|
531
|
+
// `10.0.2.2` so the cold boot still has *some* working path.
|
|
532
|
+
//
|
|
533
|
+
// We only attempt adb reverse when we know the port — without
|
|
534
|
+
// it we can't issue a valid `adb reverse` command. Older
|
|
535
|
+
// fixtures that call `resolveDeviceReachableHost` without a
|
|
536
|
+
// port still get the legacy `10.0.2.2` answer.
|
|
537
|
+
if (typeof opts.port === 'number' && Number.isFinite(opts.port)) {
|
|
538
|
+
const status = tryEnableAdbReverse({ port: opts.port, env: opts.env, exec: opts.adbExec });
|
|
539
|
+
if (status.succeeded) {
|
|
540
|
+
// Emit `127.0.0.1` (IPv4 literal) instead of `localhost`.
|
|
541
|
+
// Android API 36+ system images periodically ship without
|
|
542
|
+
// a `localhost` entry in the resolver's `/etc/hosts`, so
|
|
543
|
+
// `getaddrinfo("localhost")` throws
|
|
544
|
+
// `UnknownHostException: No address associated with
|
|
545
|
+
// hostname` BEFORE the TCP connect even starts. The IPv4
|
|
546
|
+
// literal bypasses DNS entirely and ADB reverse intercepts
|
|
547
|
+
// loopback traffic regardless of how it's spelled. This is
|
|
548
|
+
// the same workaround React Native, Expo, and Chrome
|
|
549
|
+
// DevTools port forwarding all use.
|
|
550
|
+
return { host: '127.0.0.1', source: 'adb-reverse' };
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
// Stock Android emulator host alias. Physical devices that
|
|
554
|
+
// can't use `adb reverse` need NS_HMR_HOST=<LAN IP> or
|
|
555
|
+
// NS_HMR_PREFER_LAN_HOST=1.
|
|
556
|
+
return { host: '10.0.2.2', source: 'platform-default' };
|
|
557
|
+
}
|
|
558
|
+
return { host: 'localhost', source: 'platform-default' };
|
|
559
|
+
}
|
|
560
|
+
/**
|
|
561
|
+
* Convenience wrapper that returns the full `protocol://host:port`
|
|
562
|
+
* origin string alongside the host-resolution metadata. The vast
|
|
563
|
+
* majority of callers want the assembled origin to splice into a
|
|
564
|
+
* `/ns/...` URL, so this saves them the trivial template string.
|
|
565
|
+
*
|
|
566
|
+
* When the resolved host already includes a `:port` suffix (a common
|
|
567
|
+
* shape for `NS_HMR_HOST=tunnel.example.com:5173`), we split it back
|
|
568
|
+
* out so the assembled origin never doubles up the port.
|
|
569
|
+
*/
|
|
570
|
+
export function resolveDeviceReachableOrigin(opts) {
|
|
571
|
+
const protocol = opts.protocol === 'https' ? 'https' : 'http';
|
|
572
|
+
const requestedPort = typeof opts.port === 'number' && Number.isFinite(opts.port) ? opts.port : 5173;
|
|
573
|
+
// Forward the resolved port to the host resolver so the Android
|
|
574
|
+
// `platformDefault` step can attempt `adb reverse` for the same
|
|
575
|
+
// port the dev server is actually listening on.
|
|
576
|
+
const { host: rawHost, source } = resolveDeviceReachableHost({ ...opts, port: requestedPort });
|
|
577
|
+
const { host, port } = splitHostAndPort(rawHost, requestedPort);
|
|
578
|
+
return {
|
|
579
|
+
host,
|
|
580
|
+
source,
|
|
581
|
+
protocol,
|
|
582
|
+
port,
|
|
583
|
+
origin: `${protocol}://${host}:${port}`,
|
|
584
|
+
};
|
|
585
|
+
}
|
|
586
|
+
function splitHostAndPort(rawHost, fallbackPort) {
|
|
587
|
+
// Bracketed IPv6 — `[::1]:5173` — keep the brackets on the host so
|
|
588
|
+
// callers can splice it straight into a URL without re-escaping.
|
|
589
|
+
if (rawHost.startsWith('[')) {
|
|
590
|
+
const closing = rawHost.indexOf(']');
|
|
591
|
+
if (closing !== -1) {
|
|
592
|
+
const bracketed = rawHost.slice(0, closing + 1);
|
|
593
|
+
const rest = rawHost.slice(closing + 1);
|
|
594
|
+
if (rest.startsWith(':')) {
|
|
595
|
+
const parsed = Number(rest.slice(1));
|
|
596
|
+
if (Number.isFinite(parsed) && parsed > 0) {
|
|
597
|
+
return { host: bracketed, port: parsed };
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
return { host: bracketed, port: fallbackPort };
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
// `host:port` for IPv4 / DNS names. We deliberately do NOT split on
|
|
604
|
+
// the first colon when more than one is present (that would
|
|
605
|
+
// misinterpret an unbracketed IPv6 literal), and we leave the host
|
|
606
|
+
// alone if the trailing segment isn't a positive integer.
|
|
607
|
+
const colonCount = (rawHost.match(/:/g) || []).length;
|
|
608
|
+
if (colonCount === 1) {
|
|
609
|
+
const idx = rawHost.indexOf(':');
|
|
610
|
+
const candidatePort = Number(rawHost.slice(idx + 1));
|
|
611
|
+
if (Number.isFinite(candidatePort) && candidatePort > 0) {
|
|
612
|
+
return { host: rawHost.slice(0, idx), port: candidatePort };
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
return { host: rawHost, port: fallbackPort };
|
|
616
|
+
}
|
|
617
|
+
//# sourceMappingURL=dev-host.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev-host.js","sourceRoot":"","sources":["../../../../packages/vite/helpers/dev-host.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2EG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE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AAC,CAAC,CAAC,CAAC;gBACrC,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;oBAC3C,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gBAC1C,CAAC;YACF,CAAC;YACD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;QAChD,CAAC;IACF,CAAC;IAED,oEAAoE;IACpE,4DAA4D;IAC5D,mEAAmE;IACnE,0DAA0D;IAC1D,MAAM,UAAU,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;IACtD,IAAI,UAAU,KAAK,CAAC,EAAE,CAAC;QACtB,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACjC,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;QACrD,IAAI,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,aAAa,GAAG,CAAC,EAAE,CAAC;YACzD,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;QAC7D,CAAC;IACF,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;AAC9C,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { existsSync } from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
|
+
import { normalizeModuleId } from './normalize-id.js';
|
|
3
4
|
/**
|
|
4
5
|
* Rolldown-compatible resolver plugin for NativeScript platform-specific file
|
|
5
6
|
* resolution during dependency optimization.
|
|
@@ -78,7 +79,9 @@ export function optimizeDepsPlatformResolver(opts) {
|
|
|
78
79
|
// console.log(`ns-optimize-deps-resolver: ${relImporter ?? importer} -> ${source} => ${path.relative(process.cwd(), resolved)}`);
|
|
79
80
|
// } catch {}
|
|
80
81
|
}
|
|
81
|
-
|
|
82
|
+
// Canonicalize separators/drive case so the prebundle graph dedupes
|
|
83
|
+
// platform files consistently on Windows. No-op on POSIX.
|
|
84
|
+
return normalizeModuleId(resolved);
|
|
82
85
|
},
|
|
83
86
|
};
|
|
84
87
|
}
|