@nativescript/vite 8.0.0-beta.0 → 8.0.0-dev.0
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 +89 -14
- package/bin/cli.cjs +8 -14
- package/configuration/angular.d.ts +35 -2
- package/configuration/angular.js +541 -216
- package/configuration/angular.js.map +1 -1
- package/configuration/base.js +228 -78
- package/configuration/base.js.map +1 -1
- package/configuration/javascript.js +17 -96
- package/configuration/javascript.js.map +1 -1
- package/configuration/react.js +41 -73
- package/configuration/react.js.map +1 -1
- package/configuration/solid.js +58 -6
- package/configuration/solid.js.map +1 -1
- package/configuration/typescript.js +15 -96
- package/configuration/typescript.js.map +1 -1
- package/framework.d.ts +22 -0
- package/framework.js +18 -0
- package/framework.js.map +1 -0
- package/helpers/app-components.d.ts +2 -1
- package/helpers/app-components.js.map +1 -1
- package/helpers/app-css-refresh.d.ts +31 -0
- package/helpers/app-css-refresh.js +43 -0
- package/helpers/app-css-refresh.js.map +1 -0
- package/helpers/app-css-state.d.ts +17 -0
- package/helpers/app-css-state.js +51 -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/cli-flags.d.ts +12 -0
- package/helpers/cli-flags.js +34 -0
- package/helpers/cli-flags.js.map +1 -1
- package/helpers/commonjs-plugins.d.ts +5 -2
- package/helpers/commonjs-plugins.js +126 -0
- package/helpers/commonjs-plugins.js.map +1 -1
- package/helpers/config-as-json.js +10 -0
- package/helpers/config-as-json.js.map +1 -1
- package/helpers/css-platform-plugin.d.ts +14 -0
- package/helpers/css-platform-plugin.js +43 -25
- package/helpers/css-platform-plugin.js.map +1 -1
- package/helpers/dev-host.d.ts +360 -0
- package/helpers/dev-host.js +694 -0
- package/helpers/dev-host.js.map +1 -0
- package/helpers/dynamic-import-plugin.d.ts +2 -1
- package/helpers/dynamic-import-plugin.js +59 -53
- package/helpers/dynamic-import-plugin.js.map +1 -1
- package/helpers/esbuild-platform-resolver.js +9 -6
- package/helpers/esbuild-platform-resolver.js.map +1 -1
- package/helpers/external-configs.d.ts +10 -4
- package/helpers/external-configs.js +63 -15
- package/helpers/external-configs.js.map +1 -1
- package/helpers/flavor.d.ts +31 -0
- package/helpers/flavor.js +53 -2
- package/helpers/flavor.js.map +1 -1
- package/helpers/global-defines.d.ts +118 -0
- package/helpers/global-defines.js +214 -11
- 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/import-meta-path.d.ts +4 -0
- package/helpers/import-meta-path.js +5 -0
- package/helpers/import-meta-path.js.map +1 -0
- package/helpers/import-specifier.d.ts +1 -0
- package/helpers/import-specifier.js +18 -0
- package/helpers/import-specifier.js.map +1 -0
- package/helpers/init.js +24 -26
- package/helpers/init.js.map +1 -1
- package/helpers/logging.d.ts +12 -1
- package/helpers/logging.js +81 -5
- package/helpers/logging.js.map +1 -1
- package/helpers/main-entry.d.ts +8 -2
- package/helpers/main-entry.js +622 -120
- package/helpers/main-entry.js.map +1 -1
- package/helpers/nativeclass-esbuild-plugin.d.ts +2 -1
- package/helpers/nativeclass-esbuild-plugin.js +6 -1
- package/helpers/nativeclass-esbuild-plugin.js.map +1 -1
- package/helpers/nativeclass-transform.d.ts +13 -0
- package/helpers/nativeclass-transform.js +42 -131
- package/helpers/nativeclass-transform.js.map +1 -1
- package/helpers/nativeclass-transformer-plugin.d.ts +19 -1
- package/helpers/nativeclass-transformer-plugin.js +324 -37
- package/helpers/nativeclass-transformer-plugin.js.map +1 -1
- package/helpers/nativescript-package-resolver.js +10 -62
- 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-external-urls.d.ts +32 -0
- package/helpers/ns-core-external-urls.js +107 -0
- package/helpers/ns-core-external-urls.js.map +1 -0
- package/helpers/ns-core-url.d.ts +106 -0
- package/helpers/ns-core-url.js +225 -0
- package/helpers/ns-core-url.js.map +1 -0
- package/helpers/optimize-deps.d.ts +16 -0
- package/helpers/optimize-deps.js +17 -0
- package/helpers/optimize-deps.js.map +1 -0
- package/helpers/package-platform-aliases.js +34 -49
- 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/postcss-platform-config.d.ts +17 -1
- package/helpers/postcss-platform-config.js +20 -37
- package/helpers/postcss-platform-config.js.map +1 -1
- package/helpers/project.d.ts +35 -0
- package/helpers/project.js +120 -2
- package/helpers/project.js.map +1 -1
- package/helpers/resolve-main-field-platform.d.ts +20 -0
- package/helpers/resolve-main-field-platform.js +49 -0
- package/helpers/resolve-main-field-platform.js.map +1 -0
- package/helpers/resolver.js +17 -2
- package/helpers/resolver.js.map +1 -1
- package/helpers/theme-core-plugins.js +1 -1
- package/helpers/theme-core-plugins.js.map +1 -1
- package/helpers/ts-config-paths.d.ts +32 -0
- package/helpers/ts-config-paths.js +156 -27
- package/helpers/ts-config-paths.js.map +1 -1
- package/helpers/typescript-check.d.ts +3 -3
- package/helpers/typescript-check.js +4 -4
- package/helpers/typescript-check.js.map +1 -1
- package/helpers/ui-registration.d.ts +21 -0
- package/helpers/ui-registration.js +156 -0
- package/helpers/ui-registration.js.map +1 -0
- package/helpers/utils.d.ts +9 -0
- package/helpers/utils.js +22 -2
- package/helpers/utils.js.map +1 -1
- package/helpers/vite-package-version.d.ts +7 -0
- package/helpers/vite-package-version.js +44 -0
- package/helpers/vite-package-version.js.map +1 -0
- package/helpers/workers.d.ts +40 -19
- package/helpers/workers.js +312 -13
- package/helpers/workers.js.map +1 -1
- package/hmr/client/css-handler.d.ts +2 -1
- package/hmr/client/css-handler.js +95 -23
- 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 +117 -0
- package/hmr/client/framework-client-strategy.js +18 -0
- package/hmr/client/framework-client-strategy.js.map +1 -0
- package/hmr/client/framework.d.ts +31 -0
- package/hmr/client/framework.js +17 -0
- package/hmr/client/framework.js.map +1 -0
- package/hmr/client/hmr-pending-overlay.d.ts +13 -0
- package/hmr/client/hmr-pending-overlay.js +41 -0
- package/hmr/client/hmr-pending-overlay.js.map +1 -0
- package/hmr/client/hot-context.d.ts +89 -0
- package/hmr/client/hot-context.js +404 -0
- package/hmr/client/hot-context.js.map +1 -0
- package/hmr/client/index.d.ts +9 -1
- package/hmr/client/index.js +91 -1418
- package/hmr/client/index.js.map +1 -1
- package/hmr/client/overlay-driver.d.ts +10 -0
- package/hmr/client/overlay-driver.js +33 -0
- package/hmr/client/overlay-driver.js.map +1 -0
- package/hmr/client/protocol-dispatch.d.ts +8 -0
- package/hmr/client/protocol-dispatch.js +308 -0
- package/hmr/client/protocol-dispatch.js.map +1 -0
- package/hmr/client/root-reset.d.ts +15 -0
- package/hmr/client/root-reset.js +358 -0
- package/hmr/client/root-reset.js.map +1 -0
- package/hmr/client/strategy-loader.d.ts +24 -0
- package/hmr/client/strategy-loader.js +136 -0
- package/hmr/client/strategy-loader.js.map +1 -0
- package/hmr/client/update-pipeline.d.ts +27 -0
- package/hmr/client/update-pipeline.js +489 -0
- package/hmr/client/update-pipeline.js.map +1 -0
- package/hmr/client/utils.d.ts +14 -1
- package/hmr/client/utils.js +265 -54
- package/hmr/client/utils.js.map +1 -1
- package/hmr/client/ws-transport.d.ts +21 -0
- package/hmr/client/ws-transport.js +323 -0
- package/hmr/client/ws-transport.js.map +1 -0
- package/hmr/entry-runtime.d.ts +11 -0
- package/hmr/entry-runtime.js +566 -43
- package/hmr/entry-runtime.js.map +1 -1
- package/hmr/framework-flavors.d.ts +59 -0
- package/hmr/framework-flavors.js +108 -0
- package/hmr/framework-flavors.js.map +1 -0
- package/hmr/frameworks/angular/build/angular-linker.d.ts +12 -0
- package/hmr/frameworks/angular/build/angular-linker.js +113 -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/hmr/frameworks/angular/build/inline-decorator-component-templates.d.ts +3 -0
- package/hmr/frameworks/angular/build/inline-decorator-component-templates.js +231 -0
- 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/hmr/frameworks/angular/build/js-lexer.js +182 -0
- package/hmr/frameworks/angular/build/js-lexer.js.map +1 -0
- package/hmr/frameworks/angular/build/linker-stats.d.ts +18 -0
- package/hmr/frameworks/angular/build/linker-stats.js +29 -0
- package/hmr/frameworks/angular/build/linker-stats.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.d.ts +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/hmr/frameworks/angular/build/synthesize-injectable-factories.d.ts +3 -0
- package/hmr/frameworks/angular/build/synthesize-injectable-factories.js +241 -0
- package/hmr/frameworks/angular/build/synthesize-injectable-factories.js.map +1 -0
- package/hmr/frameworks/angular/build/ts-fallback-transform.d.ts +5 -0
- package/hmr/frameworks/angular/build/ts-fallback-transform.js +138 -0
- package/hmr/frameworks/angular/build/ts-fallback-transform.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/build/worker-url-preserve.d.ts +5 -0
- package/hmr/frameworks/angular/build/worker-url-preserve.js +140 -0
- package/hmr/frameworks/angular/build/worker-url-preserve.js.map +1 -0
- package/hmr/frameworks/angular/client/index.d.ts +2 -1
- package/hmr/frameworks/angular/client/index.js +637 -23
- 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 +37 -6
- package/hmr/frameworks/angular/server/linker.js.map +1 -1
- package/hmr/frameworks/angular/server/ng-component-route.d.ts +43 -0
- package/hmr/frameworks/angular/server/ng-component-route.js +113 -0
- package/hmr/frameworks/angular/server/ng-component-route.js.map +1 -0
- package/hmr/frameworks/angular/server/strategy.js +697 -18
- package/hmr/frameworks/angular/server/strategy.js.map +1 -1
- package/hmr/frameworks/angular/server/websocket-angular-entry.d.ts +2 -0
- package/hmr/frameworks/angular/server/websocket-angular-entry.js +68 -0
- package/hmr/frameworks/angular/server/websocket-angular-entry.js.map +1 -0
- package/hmr/frameworks/angular/server/websocket-angular-hot-update.d.ts +94 -0
- package/hmr/frameworks/angular/server/websocket-angular-hot-update.js +485 -0
- package/hmr/frameworks/angular/server/websocket-angular-hot-update.js.map +1 -0
- package/hmr/frameworks/react/client/strategy.d.ts +12 -0
- package/hmr/frameworks/react/client/strategy.js +27 -0
- package/hmr/frameworks/react/client/strategy.js.map +1 -0
- package/hmr/frameworks/react/server/strategy.d.ts +2 -0
- package/hmr/frameworks/react/server/strategy.js +230 -0
- package/hmr/frameworks/react/server/strategy.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/client/app-runtime.d.ts +68 -0
- package/hmr/frameworks/solid/client/app-runtime.js +252 -0
- package/hmr/frameworks/solid/client/app-runtime.js.map +1 -0
- package/hmr/frameworks/solid/client/strategy.d.ts +7 -0
- package/hmr/frameworks/solid/client/strategy.js +391 -0
- package/hmr/frameworks/solid/client/strategy.js.map +1 -0
- package/hmr/frameworks/solid/server/strategy.js +293 -16
- package/hmr/frameworks/solid/server/strategy.js.map +1 -1
- package/hmr/frameworks/typescript/client/strategy.d.ts +7 -0
- package/hmr/frameworks/typescript/client/strategy.js +418 -0
- package/hmr/frameworks/typescript/client/strategy.js.map +1 -0
- package/hmr/frameworks/typescript/server/strategy.js +48 -16
- package/hmr/frameworks/typescript/server/strategy.js.map +1 -1
- package/hmr/frameworks/vue/client/dep-propagation.d.ts +44 -0
- package/hmr/frameworks/vue/client/dep-propagation.js +148 -0
- package/hmr/frameworks/vue/client/dep-propagation.js.map +1 -0
- package/hmr/frameworks/vue/client/index.d.ts +10 -1
- package/hmr/frameworks/vue/client/index.js +287 -562
- package/hmr/frameworks/vue/client/index.js.map +1 -1
- package/hmr/frameworks/vue/client/navigate-app.d.ts +3 -0
- package/hmr/frameworks/vue/client/navigate-app.js +178 -0
- package/hmr/frameworks/vue/client/navigate-app.js.map +1 -0
- package/hmr/frameworks/vue/client/strategy.d.ts +33 -0
- package/hmr/frameworks/vue/client/strategy.js +152 -0
- package/hmr/frameworks/vue/client/strategy.js.map +1 -0
- package/hmr/frameworks/vue/client/vue-sfc-update-overlay.d.ts +49 -0
- package/hmr/frameworks/vue/client/vue-sfc-update-overlay.js +124 -0
- package/hmr/frameworks/vue/client/vue-sfc-update-overlay.js.map +1 -0
- package/hmr/frameworks/vue/server/compiler.d.ts +3 -1
- package/hmr/frameworks/vue/server/compiler.js +3 -1
- package/hmr/frameworks/vue/server/compiler.js.map +1 -1
- package/hmr/frameworks/vue/server/sfc-route-assemble.d.ts +7 -0
- package/hmr/frameworks/vue/server/sfc-route-assemble.js +823 -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 +462 -0
- package/hmr/frameworks/vue/server/sfc-route-serve.js.map +1 -0
- package/hmr/frameworks/vue/server/sfc-route-shared.d.ts +45 -0
- package/hmr/frameworks/vue/server/sfc-route-shared.js +105 -0
- package/hmr/frameworks/vue/server/sfc-route-shared.js.map +1 -0
- package/hmr/frameworks/vue/server/strategy.d.ts +35 -0
- package/hmr/frameworks/vue/server/strategy.js +291 -7
- 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.d.ts +3 -1
- package/hmr/helpers/ast-normalizer.js +131 -24
- 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/helpers/vendor-rewrite.d.ts +1 -1
- package/hmr/helpers/vendor-rewrite.js +5 -3
- package/hmr/helpers/vendor-rewrite.js.map +1 -1
- package/hmr/server/boot-recording.d.ts +51 -0
- package/hmr/server/boot-recording.js +214 -0
- package/hmr/server/boot-recording.js.map +1 -0
- package/hmr/server/constants.d.ts +1 -0
- package/hmr/server/constants.js +21 -4
- package/hmr/server/constants.js.map +1 -1
- package/hmr/server/content-css-update.d.ts +54 -0
- package/hmr/server/content-css-update.js +78 -0
- package/hmr/server/content-css-update.js.map +1 -0
- package/hmr/server/core-bundle.d.ts +140 -0
- package/hmr/server/core-bundle.js +614 -0
- package/hmr/server/core-bundle.js.map +1 -0
- package/hmr/server/core-sanitize.d.ts +130 -4
- package/hmr/server/core-sanitize.js +393 -32
- package/hmr/server/core-sanitize.js.map +1 -1
- package/hmr/server/css-connect-sync.d.ts +28 -0
- package/hmr/server/css-connect-sync.js +59 -0
- package/hmr/server/css-connect-sync.js.map +1 -0
- package/hmr/server/css-device-module.d.ts +28 -0
- package/hmr/server/css-device-module.js +44 -0
- package/hmr/server/css-device-module.js.map +1 -0
- package/hmr/server/css-update-message.d.ts +23 -0
- package/hmr/server/css-update-message.js +41 -0
- package/hmr/server/css-update-message.js.map +1 -0
- package/hmr/server/deps-bundle.d.ts +233 -0
- package/hmr/server/deps-bundle.js +1022 -0
- package/hmr/server/deps-bundle.js.map +1 -0
- package/hmr/server/device-transform-helpers.d.ts +24 -0
- package/hmr/server/device-transform-helpers.js +408 -0
- package/hmr/server/device-transform-helpers.js.map +1 -0
- package/hmr/server/framework-strategy.d.ts +182 -11
- package/hmr/server/hmr-module-graph.d.ts +37 -0
- package/hmr/server/hmr-module-graph.js +215 -0
- package/hmr/server/hmr-module-graph.js.map +1 -0
- package/hmr/server/import-map.d.ts +99 -0
- package/hmr/server/import-map.js +294 -0
- package/hmr/server/import-map.js.map +1 -0
- package/hmr/server/index.d.ts +2 -1
- package/hmr/server/index.js +7 -16
- package/hmr/server/index.js.map +1 -1
- package/hmr/server/node-builtins-route.d.ts +12 -0
- package/hmr/server/node-builtins-route.js +86 -0
- package/hmr/server/node-builtins-route.js.map +1 -0
- 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-m-response-memo.d.ts +10 -0
- package/hmr/server/ns-m-response-memo.js +33 -0
- package/hmr/server/ns-m-response-memo.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 +39 -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 +197 -0
- package/hmr/server/perf-instrumentation.js.map +1 -0
- package/hmr/server/process-code-for-device.d.ts +54 -0
- package/hmr/server/process-code-for-device.js +832 -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 +631 -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/runtime-graph-filter.d.ts +5 -0
- package/hmr/server/runtime-graph-filter.js +28 -0
- package/hmr/server/runtime-graph-filter.js.map +1 -0
- package/hmr/server/server-origin.d.ts +2 -0
- package/hmr/server/server-origin.js +88 -0
- package/hmr/server/server-origin.js.map +1 -0
- package/hmr/server/shared-transform-request.d.ts +12 -0
- package/hmr/server/shared-transform-request.js +143 -0
- package/hmr/server/shared-transform-request.js.map +1 -0
- package/hmr/server/socket-utils.d.ts +10 -0
- package/hmr/server/socket-utils.js +14 -0
- package/hmr/server/socket-utils.js.map +1 -0
- package/hmr/server/transform-cache-invalidation.d.ts +37 -0
- package/hmr/server/transform-cache-invalidation.js +156 -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.d.ts +22 -1
- package/hmr/server/vite-plugin.js +655 -58
- package/hmr/server/vite-plugin.js.map +1 -1
- package/hmr/server/websocket-core-bridge.d.ts +68 -0
- package/hmr/server/websocket-core-bridge.js +370 -0
- package/hmr/server/websocket-core-bridge.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 +21 -0
- package/hmr/server/websocket-graph-upsert.js +33 -0
- package/hmr/server/websocket-graph-upsert.js.map +1 -0
- package/hmr/server/websocket-hmr-pending.d.ts +29 -0
- package/hmr/server/websocket-hmr-pending.js +33 -0
- package/hmr/server/websocket-hmr-pending.js.map +1 -0
- package/hmr/server/websocket-hot-update.d.ts +80 -0
- package/hmr/server/websocket-hot-update.js +299 -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 +51 -0
- package/hmr/server/websocket-import-map-route.js.map +1 -0
- package/hmr/server/websocket-module-bindings.d.ts +21 -0
- package/hmr/server/websocket-module-bindings.js +504 -0
- package/hmr/server/websocket-module-bindings.js.map +1 -0
- package/hmr/server/websocket-module-specifiers.d.ts +98 -0
- package/hmr/server/websocket-module-specifiers.js +832 -0
- package/hmr/server/websocket-module-specifiers.js.map +1 -0
- package/hmr/server/websocket-ns-core.d.ts +34 -0
- package/hmr/server/websocket-ns-core.js +414 -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 +163 -0
- package/hmr/server/websocket-ns-entry.js.map +1 -0
- package/hmr/server/websocket-ns-m-paths.d.ts +19 -0
- package/hmr/server/websocket-ns-m-paths.js +115 -0
- package/hmr/server/websocket-ns-m-paths.js.map +1 -0
- package/hmr/server/websocket-ns-m-request.d.ts +46 -0
- package/hmr/server/websocket-ns-m-request.js +197 -0
- package/hmr/server/websocket-ns-m-request.js.map +1 -0
- package/hmr/server/websocket-ns-m.d.ts +52 -0
- package/hmr/server/websocket-ns-m.js +592 -0
- package/hmr/server/websocket-ns-m.js.map +1 -0
- package/hmr/server/websocket-served-module-helpers.d.ts +98 -0
- package/hmr/server/websocket-served-module-helpers.js +948 -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 +42 -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 +6 -17
- package/hmr/server/websocket.js +723 -5376
- package/hmr/server/websocket.js.map +1 -1
- package/hmr/shared/ns-globals.d.ts +108 -0
- package/hmr/shared/ns-globals.js +29 -0
- package/hmr/shared/ns-globals.js.map +1 -0
- package/hmr/shared/package-classifier.d.ts +9 -0
- package/hmr/shared/package-classifier.js +58 -0
- package/hmr/shared/package-classifier.js.map +1 -0
- package/hmr/shared/protocol.d.ts +157 -0
- package/hmr/shared/protocol.js +28 -0
- package/hmr/shared/protocol.js.map +1 -0
- package/hmr/shared/runtime/boot-complete.d.ts +14 -0
- package/hmr/shared/runtime/boot-complete.js +32 -0
- package/hmr/shared/runtime/boot-complete.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 +44 -0
- package/hmr/shared/runtime/boot-progress.js +134 -0
- package/hmr/shared/runtime/boot-progress.js.map +1 -0
- package/hmr/shared/runtime/boot-timeline.d.ts +17 -0
- package/hmr/shared/runtime/boot-timeline.js +40 -0
- package/hmr/shared/runtime/boot-timeline.js.map +1 -0
- package/hmr/shared/runtime/browser-runtime-contract.d.ts +97 -0
- package/hmr/shared/runtime/browser-runtime-contract.js +66 -0
- package/hmr/shared/runtime/browser-runtime-contract.js.map +1 -0
- package/hmr/shared/runtime/dev-overlay-ios.d.ts +87 -0
- package/hmr/shared/runtime/dev-overlay-ios.js +521 -0
- package/hmr/shared/runtime/dev-overlay-ios.js.map +1 -0
- package/hmr/shared/runtime/dev-overlay-shared.d.ts +58 -0
- package/hmr/shared/runtime/dev-overlay-shared.js +116 -0
- package/hmr/shared/runtime/dev-overlay-shared.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-tree.d.ts +59 -0
- package/hmr/shared/runtime/dev-overlay-tree.js +712 -0
- package/hmr/shared/runtime/dev-overlay-tree.js.map +1 -0
- package/hmr/shared/runtime/dev-overlay.d.ts +39 -0
- package/hmr/shared/runtime/dev-overlay.js +292 -0
- package/hmr/shared/runtime/dev-overlay.js.map +1 -0
- package/hmr/shared/runtime/global-scope.d.ts +18 -0
- package/hmr/shared/runtime/global-scope.js +21 -0
- package/hmr/shared/runtime/global-scope.js.map +1 -0
- package/hmr/shared/runtime/hooks.js +2 -1
- package/hmr/shared/runtime/hooks.js.map +1 -1
- package/hmr/shared/runtime/launch-bridge.d.ts +9 -0
- package/hmr/shared/runtime/launch-bridge.js +98 -0
- package/hmr/shared/runtime/launch-bridge.js.map +1 -0
- package/hmr/shared/runtime/module-provenance.d.ts +1 -0
- package/hmr/shared/runtime/module-provenance.js +64 -0
- package/hmr/shared/runtime/module-provenance.js.map +1 -0
- package/hmr/shared/runtime/ns-runtime-test-double.d.ts +21 -0
- package/hmr/shared/runtime/ns-runtime-test-double.js +20 -0
- package/hmr/shared/runtime/ns-runtime-test-double.js.map +1 -0
- package/hmr/shared/runtime/overlay-flag.d.ts +9 -0
- package/hmr/shared/runtime/overlay-flag.js +34 -0
- package/hmr/shared/runtime/overlay-flag.js.map +1 -0
- package/hmr/shared/runtime/platform-polyfills.d.ts +26 -0
- package/hmr/shared/runtime/platform-polyfills.js +122 -0
- package/hmr/shared/runtime/platform-polyfills.js.map +1 -0
- package/hmr/shared/runtime/root-placeholder-view.d.ts +19 -0
- package/hmr/shared/runtime/root-placeholder-view.js +311 -0
- package/hmr/shared/runtime/root-placeholder-view.js.map +1 -0
- package/hmr/shared/runtime/root-placeholder.d.ts +1 -0
- package/hmr/shared/runtime/root-placeholder.js +778 -83
- package/hmr/shared/runtime/root-placeholder.js.map +1 -1
- package/hmr/shared/runtime/session-bootstrap.d.ts +1 -0
- package/hmr/shared/runtime/session-bootstrap.js +350 -0
- package/hmr/shared/runtime/session-bootstrap.js.map +1 -0
- package/hmr/shared/runtime/vendor-bootstrap.js +54 -16
- package/hmr/shared/runtime/vendor-bootstrap.js.map +1 -1
- package/hmr/shared/runtime/vendor-resolve.d.ts +22 -0
- package/hmr/shared/runtime/vendor-resolve.js +45 -0
- package/hmr/shared/runtime/vendor-resolve.js.map +1 -0
- package/hmr/shared/runtime/worker-tracking.d.ts +28 -0
- package/hmr/shared/runtime/worker-tracking.js +114 -0
- package/hmr/shared/runtime/worker-tracking.js.map +1 -0
- package/hmr/shared/vendor/manifest-collect.d.ts +4 -0
- package/hmr/shared/vendor/manifest-collect.js +909 -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 +5 -3
- package/hmr/shared/vendor/manifest-loader.js.map +1 -1
- package/hmr/shared/vendor/manifest.d.ts +12 -0
- package/hmr/shared/vendor/manifest.js +341 -545
- package/hmr/shared/vendor/manifest.js.map +1 -1
- package/hmr/shared/vendor/registry.d.ts +2 -0
- package/hmr/shared/vendor/registry.js +118 -7
- package/hmr/shared/vendor/registry.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 +107 -0
- package/hmr/shared/vendor/vendor-esbuild-plugins.js +540 -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 +83 -14
- package/runtime/core-aliases-early.js +103 -81
- package/runtime/core-aliases-early.js.map +1 -1
- package/shims/react-jsx-runtime.d.ts +4 -0
- package/shims/react-jsx-runtime.js +61 -0
- package/shims/react-jsx-runtime.js.map +1 -0
- package/shims/solid-jsx-runtime.d.ts +7 -0
- package/shims/solid-jsx-runtime.js +17 -0
- package/shims/solid-jsx-runtime.js.map +1 -0
- package/helpers/angular/angular-linker.d.ts +0 -13
- package/helpers/angular/angular-linker.js +0 -189
- package/helpers/angular/angular-linker.js.map +0 -1
- package/helpers/angular/shared-linker.d.ts +0 -4
- package/helpers/angular/shared-linker.js +0 -39
- package/helpers/angular/shared-linker.js.map +0 -1
- package/helpers/angular/util.js +0 -67
- package/helpers/angular/util.js.map +0 -1
- package/helpers/module-runner-patch.d.ts +0 -3
- package/helpers/module-runner-patch.js +0 -63
- package/helpers/module-runner-patch.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/shared/runtime/http-only-boot.d.ts +0 -1
- package/hmr/shared/runtime/http-only-boot.js +0 -124
- package/hmr/shared/runtime/http-only-boot.js.map +0 -1
- package/hmr/vendor-bootstrap.d.ts +0 -3
- package/hmr/vendor-bootstrap.js +0 -32
- package/hmr/vendor-bootstrap.js.map +0 -1
- package/shims/react-reconciler-constants.d.ts +0 -14
- package/shims/react-reconciler-constants.js +0 -21
- package/shims/react-reconciler-constants.js.map +0 -1
- package/shims/react-reconciler.d.ts +0 -8
- package/shims/react-reconciler.js +0 -15
- package/shims/react-reconciler.js.map +0 -1
- package/transformers/NativeClass/index.d.ts +0 -2
- package/transformers/NativeClass/index.js +0 -222
- package/transformers/NativeClass/index.js.map +0 -1
|
@@ -1,46 +1,660 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';
|
|
2
|
+
import fs from 'node:fs';
|
|
2
3
|
import path from 'path';
|
|
3
|
-
import os from 'os';
|
|
4
4
|
import { pathToFileURL } from 'url';
|
|
5
|
+
import { NS_DEFAULT_DEV_FEATURE_FLAGS, NS_DEFAULT_HOST_MODULES } from '../shared/runtime/browser-runtime-contract.js';
|
|
6
|
+
import { resolveDeviceReachableHost } from '../../helpers/dev-host.js';
|
|
7
|
+
import { setUserDefineEntries } from '../../helpers/global-defines.js';
|
|
8
|
+
import { getMonorepoWorkspaceRoot } from '../../helpers/project.js';
|
|
5
9
|
const require = createRequire(import.meta.url);
|
|
6
10
|
const VIRTUAL_ID = 'virtual:ns-hmr-client';
|
|
7
11
|
const RESOLVED_ID = '\0' + VIRTUAL_ID;
|
|
8
|
-
export function
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
12
|
+
export function computeClientImportSpecifier(options) {
|
|
13
|
+
const { projectRoot, clientFsPath } = options;
|
|
14
|
+
let clientImport = clientFsPath;
|
|
15
|
+
try {
|
|
16
|
+
const fsPosix = clientFsPath.replace(/\\/g, '/');
|
|
17
|
+
const rel = path.relative(projectRoot, clientFsPath);
|
|
18
|
+
const relPosix = rel.replace(/\\/g, '/');
|
|
19
|
+
if (path.isAbsolute(rel)) {
|
|
20
|
+
clientImport = pathToFileURL(clientFsPath).toString();
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
// Prefer routing via the absolute fs path's `node_modules/...` tail. This
|
|
24
|
+
// covers monorepo / pnpm setups where node_modules is hoisted ABOVE the
|
|
25
|
+
// project root and `path.relative` would otherwise produce a
|
|
26
|
+
// "../../node_modules/..." specifier. That relative form is sent to the
|
|
27
|
+
// device's bootstrap as `__NS_BROWSER_RUNTIME_CLIENT_IMPORT__`, where the
|
|
28
|
+
// URL constructor resolves it against `${origin}/__ns_dev__/client` and
|
|
29
|
+
// collapses the leading `..` segments back to `${origin}/node_modules/...`.
|
|
30
|
+
// That URL bypasses the `/ns/m/` AST-normalizer pipeline (which strips
|
|
31
|
+
// browser-only `/@vite/client` imports), so the on-device HTTP loader
|
|
32
|
+
// eventually tries to fetch `/@vite/client` and fails with
|
|
33
|
+
// "HTTP import failed (status=0)" / "Instantiation failed (http-loader)".
|
|
34
|
+
const lastNm = fsPosix.lastIndexOf('/node_modules/');
|
|
35
|
+
if (lastNm !== -1) {
|
|
36
|
+
return `/ns/m${fsPosix.slice(lastNm)}`;
|
|
37
|
+
}
|
|
38
|
+
// Monorepo dist symlink (e.g. `"@nativescript/vite": "file:../../dist/packages/vite"`):
|
|
39
|
+
// require.resolve follows the node_modules symlink to its REAL path under
|
|
40
|
+
// the workspace root, which contains no `/node_modules/` segment. The
|
|
41
|
+
// `../../dist/...` relative form below would resolve on-device to
|
|
42
|
+
// `${origin}/dist/...`, which Vite's middleware 404s (outside root, not
|
|
43
|
+
// /@fs/). Route through /ns/m with a workspace-root-relative path so the
|
|
44
|
+
// fetch goes through the same served-module pipeline as everything else.
|
|
45
|
+
const wsRoot = getMonorepoWorkspaceRoot(projectRoot)?.replace(/\\/g, '/');
|
|
46
|
+
if (wsRoot && fsPosix.startsWith(wsRoot + '/')) {
|
|
47
|
+
return `/ns/m/${fsPosix.slice(wsRoot.length + 1)}`;
|
|
29
48
|
}
|
|
49
|
+
const normalizedRel = (relPosix.startsWith('.') ? relPosix : `/${relPosix}`).replace(/\/+/g, '/');
|
|
50
|
+
clientImport = normalizedRel.startsWith('/node_modules/') ? `/ns/m${normalizedRel}` : normalizedRel;
|
|
30
51
|
}
|
|
31
|
-
|
|
32
|
-
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
clientImport = clientFsPath.replace(/\\/g, '/');
|
|
55
|
+
}
|
|
56
|
+
return clientImport;
|
|
57
|
+
}
|
|
58
|
+
export function resolveProjectMainEntryPath(projectRoot) {
|
|
59
|
+
try {
|
|
60
|
+
const packageJsonPath = path.join(projectRoot, 'package.json');
|
|
61
|
+
const raw = fs.readFileSync(packageJsonPath, 'utf-8');
|
|
62
|
+
const parsed = JSON.parse(raw);
|
|
63
|
+
const mainEntry = typeof parsed.main === 'string' && parsed.main ? parsed.main : 'src/app.ts';
|
|
64
|
+
const resolved = path.resolve(projectRoot, mainEntry);
|
|
65
|
+
const relative = path.relative(projectRoot, resolved).replace(/\\/g, '/');
|
|
66
|
+
return `/${relative}`.replace(/\/+/g, '/');
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
return '/src/app.ts';
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
export function createNsDevSessionDescriptor(options) {
|
|
73
|
+
const protocol = options.secure ? 'https' : 'http';
|
|
74
|
+
const wsProtocol = options.secure ? 'wss' : 'ws';
|
|
75
|
+
const origin = `${protocol}://${options.requestHost}`;
|
|
76
|
+
const entryPathname = options.mainEntryPathname || resolveProjectMainEntryPath(options.projectRoot);
|
|
77
|
+
// Canonical (untagged) entry URL. Boot-progress instrumentation is
|
|
78
|
+
// injected self-gating by the /ns/m module server (the snippet no-ops
|
|
79
|
+
// once `__NS_HMR_BOOT_COMPLETE__` flips), so the entry URL needs no
|
|
80
|
+
// `__ns_boot__` decoration — module identity IS the URL.
|
|
81
|
+
const canonicalEntryPathname = entryPathname.startsWith('/ns/m/') ? entryPathname : `/ns/m${entryPathname.startsWith('/') ? entryPathname : `/${entryPathname}`}`;
|
|
82
|
+
return {
|
|
83
|
+
sessionId: options.sessionId,
|
|
84
|
+
origin,
|
|
85
|
+
entryUrl: `${origin}${canonicalEntryPathname}`,
|
|
86
|
+
clientUrl: `${origin}/__ns_dev__/client`,
|
|
87
|
+
wsUrl: `${wsProtocol}://${options.requestHost}/ns-hmr`,
|
|
88
|
+
platform: options.platform,
|
|
89
|
+
runtimeConfigUrl: `${origin}/ns/import-map.json`,
|
|
90
|
+
hostModules: [...NS_DEFAULT_HOST_MODULES],
|
|
91
|
+
features: { ...NS_DEFAULT_DEV_FEATURE_FLAGS },
|
|
33
92
|
};
|
|
93
|
+
}
|
|
94
|
+
function resolveBootstrapImportUrl(origin, clientImport) {
|
|
95
|
+
const normalizedOrigin = origin.replace(/\/$/, '');
|
|
96
|
+
if (!clientImport) {
|
|
97
|
+
return clientImport;
|
|
98
|
+
}
|
|
99
|
+
if (/^(?:https?|file):\/\//i.test(clientImport)) {
|
|
100
|
+
return clientImport;
|
|
101
|
+
}
|
|
102
|
+
if (clientImport.startsWith('/')) {
|
|
103
|
+
return `${normalizedOrigin}${clientImport}`;
|
|
104
|
+
}
|
|
105
|
+
try {
|
|
106
|
+
return new URL(clientImport, `${normalizedOrigin}/__ns_dev__/client`).toString();
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
return clientImport;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
export function createNsDevClientBootstrapCode(options) {
|
|
113
|
+
const normalizedOrigin = options.origin.replace(/\/$/, '');
|
|
114
|
+
const resolvedClientImport = resolveBootstrapImportUrl(normalizedOrigin, options.clientImport);
|
|
115
|
+
const vendorBundleUrl = `${normalizedOrigin}/@nativescript/vendor.mjs`;
|
|
116
|
+
const vendorBootstrapUrl = `${normalizedOrigin}/ns/m/node_modules/@nativescript/vite/hmr/shared/runtime/vendor-bootstrap.js`;
|
|
117
|
+
const resolvedHotContextImport = resolveBootstrapImportUrl(normalizedOrigin, options.hotContextImport || '/ns/m/node_modules/@nativescript/vite/hmr/client/hot-context.js');
|
|
118
|
+
const entryRuntimeUrl = `${normalizedOrigin}/ns/m/node_modules/@nativescript/vite/hmr/entry-runtime.js`;
|
|
119
|
+
const cssHandlerUrl = `${normalizedOrigin}/ns/m/node_modules/@nativescript/vite/hmr/client/css-handler.js`;
|
|
120
|
+
// Canonical, unversioned core-bridge URL (see helpers/ns-core-url.ts) — the
|
|
121
|
+
// app graph already loaded this exact URL during boot, so importing it here
|
|
122
|
+
// resolves to the SAME module record/realm instead of minting a new one.
|
|
123
|
+
const coreBridgeUrl = `${normalizedOrigin}/ns/core`;
|
|
124
|
+
const launchBridgeUrl = `${normalizedOrigin}/ns/m/node_modules/@nativescript/vite/hmr/shared/runtime/launch-bridge.js`;
|
|
125
|
+
return `
|
|
126
|
+
import { installVendorBootstrap as __nsBrowserRuntimeInstallVendorBootstrap } from ${JSON.stringify(vendorBootstrapUrl)};
|
|
127
|
+
import { vendorManifest as __nsBrowserRuntimeVendorManifest, __nsVendorModuleMap as __nsBrowserRuntimeVendorModuleMap } from ${JSON.stringify(vendorBundleUrl)};
|
|
128
|
+
import { installNsHotRegistry as __nsBrowserRuntimeInstallHotRegistry } from ${JSON.stringify(resolvedHotContextImport)};
|
|
129
|
+
import { installLaunchNotificationBridge as __nsBrowserRuntimeInstallLaunchBridge } from ${JSON.stringify(launchBridgeUrl)};
|
|
130
|
+
import * as __nsBrowserRuntimeCoreBridge from ${JSON.stringify(coreBridgeUrl)};
|
|
131
|
+
|
|
132
|
+
// Launch-notification bridge — must precede the app entry (this wrapper is
|
|
133
|
+
// imported by the session bootstrap BEFORE the entry graph). Passing the
|
|
134
|
+
// /ns/core realm's Application: that is the instance app code gets, and the
|
|
135
|
+
// only deterministic wrap point (the full HMR client evaluates async and
|
|
136
|
+
// loses the race against the entry). See shared/runtime/launch-bridge.ts.
|
|
137
|
+
try {
|
|
138
|
+
const __nsCoreNs = __nsBrowserRuntimeCoreBridge && (__nsBrowserRuntimeCoreBridge.default ?? __nsBrowserRuntimeCoreBridge);
|
|
139
|
+
__nsBrowserRuntimeInstallLaunchBridge(__nsCoreNs && __nsCoreNs.Application);
|
|
140
|
+
} catch (launchBridgeErr) {
|
|
141
|
+
console.warn('[ns-browser-runtime-client] launch-notification bridge install failed', launchBridgeErr);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// Install the JS hot registry FIRST: every served app module's injected
|
|
145
|
+
// prelude reads globalThis.__NS_HOT_REGISTRY__ at evaluation time, and this
|
|
146
|
+
// bootstrap is imported before the entry graph (see session-bootstrap.ts).
|
|
147
|
+
try {
|
|
148
|
+
__nsBrowserRuntimeInstallHotRegistry();
|
|
149
|
+
} catch (hotErr) {
|
|
150
|
+
console.warn('[ns-browser-runtime-client] failed to install hot registry', hotErr);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const __NS_BROWSER_RUNTIME_WS_URL__ = ${JSON.stringify(options.wsUrl)};
|
|
154
|
+
const __NS_BROWSER_RUNTIME_ORIGIN__ = ${JSON.stringify(options.origin)};
|
|
155
|
+
const __NS_BROWSER_RUNTIME_CLIENT_IMPORT__ = ${JSON.stringify(resolvedClientImport)};
|
|
156
|
+
const __NS_BROWSER_RUNTIME_VERBOSE__ = ${options.verbose ? 'true' : 'false'};
|
|
157
|
+
let __nsBrowserRuntimeHmrClientStartPromise;
|
|
158
|
+
let __nsBrowserRuntimeSocket;
|
|
159
|
+
let __nsBrowserRuntimeSocketReconnectTimer;
|
|
160
|
+
let __nsBrowserRuntimeDelegationTimer;
|
|
161
|
+
let __nsBrowserRuntimeDelegationWarningIssued = false;
|
|
162
|
+
let __nsBrowserRuntimeBootWaitWarningIssued = false;
|
|
163
|
+
|
|
164
|
+
function __nsBrowserRuntimeWithSocketRole(url, role) {
|
|
165
|
+
try {
|
|
166
|
+
const resolved = new URL(url);
|
|
167
|
+
resolved.searchParams.set('ns_hmr_role', role);
|
|
168
|
+
return resolved.toString();
|
|
169
|
+
} catch {
|
|
170
|
+
const sep = url.includes('?') ? '&' : '?';
|
|
171
|
+
return url + sep + 'ns_hmr_role=' + encodeURIComponent(role);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const __NS_BROWSER_RUNTIME_FALLBACK_WS_URL__ = __nsBrowserRuntimeWithSocketRole(__NS_BROWSER_RUNTIME_WS_URL__, 'bootstrap');
|
|
176
|
+
const __NS_BROWSER_RUNTIME_FULL_CLIENT_WS_URL__ = __nsBrowserRuntimeWithSocketRole(__NS_BROWSER_RUNTIME_WS_URL__, 'full');
|
|
177
|
+
|
|
178
|
+
function __nsBrowserRuntimeEnsureVendorBootstrap() {
|
|
179
|
+
__nsBrowserRuntimeInstallVendorBootstrap(__nsBrowserRuntimeVendorManifest, __nsBrowserRuntimeVendorModuleMap, __NS_BROWSER_RUNTIME_VERBOSE__);
|
|
180
|
+
const registry = globalThis.__nsVendorRegistry;
|
|
181
|
+
if (!(registry && typeof registry.get === 'function')) {
|
|
182
|
+
throw new Error('NativeScript vendor registry was not initialized');
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// Pure-JS CSS apply for the bootstrap fallback client. Prefers the HTTP
|
|
187
|
+
// core realm applier installed by the entry runtime
|
|
188
|
+
// (__NS_HMR_APPLY_CSS__), then falls back to Application.addCss through
|
|
189
|
+
// the vendor realm. No native CSS hook exists anymore.
|
|
190
|
+
function __nsBrowserRuntimeApplyCss(cssText) {
|
|
191
|
+
if (typeof cssText !== 'string' || !cssText.length) {
|
|
192
|
+
return false;
|
|
193
|
+
}
|
|
194
|
+
try {
|
|
195
|
+
const applyInCoreRealm = globalThis.__NS_HMR_APPLY_CSS__;
|
|
196
|
+
if (typeof applyInCoreRealm === 'function') {
|
|
197
|
+
applyInCoreRealm(cssText, true);
|
|
198
|
+
return true;
|
|
199
|
+
}
|
|
200
|
+
} catch (cssErr) {
|
|
201
|
+
if (__NS_BROWSER_RUNTIME_VERBOSE__) {
|
|
202
|
+
console.warn('[ns-browser-runtime-client] __NS_HMR_APPLY_CSS__ threw', cssErr);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
try {
|
|
206
|
+
const registry = globalThis.__nsVendorRegistry;
|
|
207
|
+
const coreMod = registry && typeof registry.get === 'function' ? registry.get('@nativescript/core') : null;
|
|
208
|
+
const core = (coreMod && (coreMod.default || coreMod)) || coreMod;
|
|
209
|
+
const Application = core && core.Application;
|
|
210
|
+
if (Application && typeof Application.addCss === 'function') {
|
|
211
|
+
Application.addCss(cssText);
|
|
212
|
+
try {
|
|
213
|
+
const rootView = typeof Application.getRootView === 'function' ? Application.getRootView() : null;
|
|
214
|
+
if (rootView && typeof rootView._onCssStateChange === 'function') {
|
|
215
|
+
rootView._onCssStateChange();
|
|
216
|
+
}
|
|
217
|
+
} catch {}
|
|
218
|
+
return true;
|
|
219
|
+
}
|
|
220
|
+
} catch (cssErr) {
|
|
221
|
+
if (__NS_BROWSER_RUNTIME_VERBOSE__) {
|
|
222
|
+
console.warn('[ns-browser-runtime-client] Application.addCss fallback threw', cssErr);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
if (__NS_BROWSER_RUNTIME_VERBOSE__) {
|
|
226
|
+
console.warn('[ns-browser-runtime-client] no CSS applier available; skipping CSS update');
|
|
227
|
+
}
|
|
228
|
+
return false;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
async function __nsBrowserRuntimeInstallHttpCoreCssApplier() {
|
|
232
|
+
// Monorepo / per-module core dev boots ship a minimal vendor bundle with NO
|
|
233
|
+
// @nativescript/core, so neither quick applier above exists. Install the
|
|
234
|
+
// same HTTP-core-realm applier the http-bootloader fallback path uses
|
|
235
|
+
// (entry-runtime's installHttpCoreCssSupport): it prefers the pre-parsed
|
|
236
|
+
// app.css AST (globalThis.__NS_HMR_APP_CSS_AST__), applies the seeded CSS,
|
|
237
|
+
// flips __NS_HMR_HTTP_APP_CSS_APPLIED__, and installs __NS_HMR_APPLY_CSS__
|
|
238
|
+
// so later live CSS edits land in the core realm the app actually uses.
|
|
239
|
+
try {
|
|
240
|
+
const entryRuntime = await import(${JSON.stringify(entryRuntimeUrl)});
|
|
241
|
+
const installHttpCoreCssSupport = entryRuntime && entryRuntime.installHttpCoreCssSupport;
|
|
242
|
+
if (typeof installHttpCoreCssSupport !== 'function') {
|
|
243
|
+
if (__NS_BROWSER_RUNTIME_VERBOSE__) {
|
|
244
|
+
console.warn('[ns-browser-runtime-client] entry runtime is missing installHttpCoreCssSupport; skipping CSS install');
|
|
245
|
+
}
|
|
246
|
+
return false;
|
|
247
|
+
}
|
|
248
|
+
const coreBridge = await import(${JSON.stringify(coreBridgeUrl)});
|
|
249
|
+
const applier = installHttpCoreCssSupport(coreBridge, __NS_BROWSER_RUNTIME_VERBOSE__);
|
|
250
|
+
if (applier && __NS_BROWSER_RUNTIME_VERBOSE__) {
|
|
251
|
+
console.info('[ns-entry] app.css applied in HTTP core realm');
|
|
252
|
+
}
|
|
253
|
+
return !!applier;
|
|
254
|
+
} catch (cssErr) {
|
|
255
|
+
if (__NS_BROWSER_RUNTIME_VERBOSE__) {
|
|
256
|
+
console.warn('[ns-browser-runtime-client] HTTP core realm CSS install failed', cssErr);
|
|
257
|
+
}
|
|
258
|
+
return false;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
async function __nsBrowserRuntimeReplaySeededCss() {
|
|
263
|
+
const cssText = globalThis.__NS_HMR_APP_CSS__;
|
|
264
|
+
if (typeof cssText !== 'string' || !cssText.length || globalThis.__NS_HMR_HTTP_APP_CSS_APPLIED__) {
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
if (__nsBrowserRuntimeApplyCss(cssText)) {
|
|
268
|
+
globalThis.__NS_HMR_HTTP_APP_CSS_APPLIED__ = true;
|
|
269
|
+
if (__NS_BROWSER_RUNTIME_VERBOSE__) {
|
|
270
|
+
console.info('[ns-entry] app.css applied in HTTP core realm');
|
|
271
|
+
}
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
await __nsBrowserRuntimeInstallHttpCoreCssApplier();
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
async function __nsBrowserRuntimeFetchText(url) {
|
|
278
|
+
try {
|
|
279
|
+
if (typeof globalThis.fetch === 'function') {
|
|
280
|
+
const res = await globalThis.fetch(url);
|
|
281
|
+
return await res.text();
|
|
282
|
+
}
|
|
283
|
+
const Http = globalThis.Http;
|
|
284
|
+
if (Http && typeof Http.getString === 'function') {
|
|
285
|
+
return await Http.getString(url);
|
|
286
|
+
}
|
|
287
|
+
} catch (error) {
|
|
288
|
+
if (__NS_BROWSER_RUNTIME_VERBOSE__) {
|
|
289
|
+
console.warn('[ns-browser-runtime-client] failed to fetch text', url, error);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
return '';
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
let __nsBrowserRuntimeCssHandlerPromise;
|
|
296
|
+
function __nsBrowserRuntimeLoadCssHandler() {
|
|
297
|
+
if (!__nsBrowserRuntimeCssHandlerPromise) {
|
|
298
|
+
__nsBrowserRuntimeCssHandlerPromise = import(${JSON.stringify(cssHandlerUrl)}).catch((error) => {
|
|
299
|
+
// Allow a retry on the next update instead of caching the failure.
|
|
300
|
+
__nsBrowserRuntimeCssHandlerPromise = undefined;
|
|
301
|
+
throw error;
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
return __nsBrowserRuntimeCssHandlerPromise;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
async function __nsBrowserRuntimeHandleCssUpdates(msg) {
|
|
308
|
+
const updates = Array.isArray(msg?.updates) ? msg.updates : [];
|
|
309
|
+
if (!updates.length) {
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
// Delegate to the shared client css-handler — the ONE fetch+apply pipeline
|
|
313
|
+
// for bootstrap and full client alike, honoring per-update tags (a
|
|
314
|
+
// component styleUrls update must replace under its own tag; the inline
|
|
315
|
+
// applier below only knows the global stylesheet).
|
|
316
|
+
try {
|
|
317
|
+
const cssHandler = await __nsBrowserRuntimeLoadCssHandler();
|
|
318
|
+
if (cssHandler && typeof cssHandler.handleCssUpdates === 'function') {
|
|
319
|
+
await cssHandler.handleCssUpdates(updates, __NS_BROWSER_RUNTIME_ORIGIN__);
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
} catch (cssHandlerErr) {
|
|
323
|
+
if (__NS_BROWSER_RUNTIME_VERBOSE__) {
|
|
324
|
+
console.warn('[ns-browser-runtime-client] shared css-handler unavailable; using inline fallback', cssHandlerErr);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
// Inline fallback (css-handler import failed): GLOBAL updates only. The
|
|
328
|
+
// inline applier replaces under the global app.css tag, so applying a
|
|
329
|
+
// component-tagged update here would clobber the global stylesheet.
|
|
330
|
+
for (const update of updates) {
|
|
331
|
+
if (update && typeof update.tag === 'string' && update.tag) {
|
|
332
|
+
console.warn('[ns-browser-runtime-client] skipped component CSS update (tagged applier unavailable):', update.tag);
|
|
333
|
+
continue;
|
|
334
|
+
}
|
|
335
|
+
const cssPath = update?.path || update?.acceptedPath || '';
|
|
336
|
+
if (!cssPath) {
|
|
337
|
+
continue;
|
|
338
|
+
}
|
|
339
|
+
const timestamp = update?.timestamp || Date.now();
|
|
340
|
+
const sep = cssPath.includes('?') ? '&' : '?';
|
|
341
|
+
const url = __NS_BROWSER_RUNTIME_ORIGIN__ + cssPath + sep + 'direct=1&t=' + String(timestamp);
|
|
342
|
+
const cssText = await __nsBrowserRuntimeFetchText(url);
|
|
343
|
+
if (typeof cssText === 'string' && cssText.length) {
|
|
344
|
+
__nsBrowserRuntimeApplyCss(cssText);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
function __nsBrowserRuntimeHandleAngularUpdate() {
|
|
350
|
+
const reboot = globalThis.__reboot_ng_modules__;
|
|
351
|
+
if (typeof reboot !== 'function') {
|
|
352
|
+
if (__NS_BROWSER_RUNTIME_VERBOSE__) {
|
|
353
|
+
console.warn('[ns-browser-runtime-client] Angular reboot hook unavailable');
|
|
354
|
+
}
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
try {
|
|
358
|
+
globalThis.__NS_HMR_IMPORT_NONCE__ = (typeof globalThis.__NS_HMR_IMPORT_NONCE__ === 'number' ? globalThis.__NS_HMR_IMPORT_NONCE__ : 0) + 1;
|
|
359
|
+
} catch {}
|
|
360
|
+
try {
|
|
361
|
+
globalThis.__NS_DEV_RESET_IN_PROGRESS__ = true;
|
|
362
|
+
} catch {}
|
|
363
|
+
try {
|
|
364
|
+
reboot(false);
|
|
365
|
+
} finally {
|
|
366
|
+
try {
|
|
367
|
+
globalThis.__NS_DEV_RESET_IN_PROGRESS__ = false;
|
|
368
|
+
} catch {}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
function __nsBrowserRuntimeHandleSocketMessage(msg) {
|
|
373
|
+
if (!msg || typeof msg.type !== 'string') {
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
if (msg.type === 'ns:hmr-full-graph') {
|
|
377
|
+
globalThis.__NS_HMR_BROWSER_RUNTIME_GRAPH_VERSION__ = typeof msg.version === 'number' ? msg.version : 0;
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
if (globalThis.__NS_HMR_BROWSER_RUNTIME_DELEGATED__) {
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
if (msg.type === 'ns:angular-update') {
|
|
384
|
+
__nsBrowserRuntimeHandleAngularUpdate();
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
if (msg.type === 'ns:css-updates') {
|
|
388
|
+
void __nsBrowserRuntimeHandleCssUpdates(msg);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
function __nsBrowserRuntimeScheduleReconnect() {
|
|
393
|
+
if (__nsBrowserRuntimeSocketReconnectTimer) {
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
__nsBrowserRuntimeSocketReconnectTimer = setTimeout(() => {
|
|
397
|
+
__nsBrowserRuntimeSocketReconnectTimer = null;
|
|
398
|
+
__nsBrowserRuntimeConnectSocket();
|
|
399
|
+
}, 1000);
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
function __nsBrowserRuntimeClearDelegationTimer() {
|
|
403
|
+
if (__nsBrowserRuntimeDelegationTimer) {
|
|
404
|
+
clearTimeout(__nsBrowserRuntimeDelegationTimer);
|
|
405
|
+
__nsBrowserRuntimeDelegationTimer = null;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
function __nsBrowserRuntimeCloseFallbackSocket(reason) {
|
|
410
|
+
__nsBrowserRuntimeClearDelegationTimer();
|
|
411
|
+
const ws = __nsBrowserRuntimeSocket;
|
|
412
|
+
if (ws) {
|
|
413
|
+
try {
|
|
414
|
+
ws.onopen = null;
|
|
415
|
+
ws.onmessage = null;
|
|
416
|
+
ws.onerror = null;
|
|
417
|
+
ws.onclose = null;
|
|
418
|
+
} catch {}
|
|
419
|
+
try {
|
|
420
|
+
ws.close();
|
|
421
|
+
} catch {}
|
|
422
|
+
}
|
|
423
|
+
__nsBrowserRuntimeSocket = null;
|
|
424
|
+
globalThis.__NS_HMR_BROWSER_RUNTIME_SOCKET_READY__ = false;
|
|
425
|
+
if (__NS_BROWSER_RUNTIME_VERBOSE__) {
|
|
426
|
+
console.info('[ns-browser-runtime-client] delegated to full HMR client; closing bootstrap fallback socket', reason || 'delegated');
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
function __nsBrowserRuntimeWaitForDelegation(startedAt) {
|
|
431
|
+
if (globalThis.__NS_HMR_BROWSER_RUNTIME_DELEGATED__) {
|
|
432
|
+
__nsBrowserRuntimeClearDelegationTimer();
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
if (globalThis.__NS_HMR_CLIENT_SOCKET_READY__) {
|
|
436
|
+
globalThis.__NS_HMR_BROWSER_RUNTIME_DELEGATED__ = true;
|
|
437
|
+
__nsBrowserRuntimeCloseFallbackSocket('full-client-ready');
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
440
|
+
if (!__nsBrowserRuntimeDelegationWarningIssued && Date.now() - startedAt >= 10000) {
|
|
441
|
+
__nsBrowserRuntimeDelegationWarningIssued = true;
|
|
442
|
+
// Verbose-only: the 10s threshold trips on every real Angular
|
|
443
|
+
// cold boot. The bootstrap fallback keeps running; the message
|
|
444
|
+
// is diagnostic, not actionable.
|
|
445
|
+
if (__NS_BROWSER_RUNTIME_VERBOSE__) {
|
|
446
|
+
console.warn('[ns-browser-runtime-client] full HMR client did not confirm websocket readiness; keeping bootstrap fallback active');
|
|
447
|
+
}
|
|
448
|
+
__nsBrowserRuntimeClearDelegationTimer();
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
__nsBrowserRuntimeDelegationTimer = setTimeout(() => {
|
|
452
|
+
__nsBrowserRuntimeDelegationTimer = null;
|
|
453
|
+
__nsBrowserRuntimeWaitForDelegation(startedAt);
|
|
454
|
+
}, 100);
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
function __nsBrowserRuntimeTrackDelegation() {
|
|
458
|
+
if (globalThis.__NS_HMR_BROWSER_RUNTIME_DELEGATED__) {
|
|
459
|
+
return;
|
|
460
|
+
}
|
|
461
|
+
__nsBrowserRuntimeDelegationWarningIssued = false;
|
|
462
|
+
__nsBrowserRuntimeClearDelegationTimer();
|
|
463
|
+
__nsBrowserRuntimeWaitForDelegation(Date.now());
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
function __nsBrowserRuntimeConnectSocket() {
|
|
467
|
+
const WebSocketCtor = globalThis.WebSocket;
|
|
468
|
+
if (typeof WebSocketCtor !== 'function') {
|
|
469
|
+
if (__NS_BROWSER_RUNTIME_VERBOSE__) {
|
|
470
|
+
console.warn('[ns-browser-runtime-client] WebSocket API unavailable');
|
|
471
|
+
}
|
|
472
|
+
__nsBrowserRuntimeScheduleReconnect();
|
|
473
|
+
return;
|
|
474
|
+
}
|
|
475
|
+
try {
|
|
476
|
+
if (__nsBrowserRuntimeSocket) {
|
|
477
|
+
const readyState = __nsBrowserRuntimeSocket.readyState;
|
|
478
|
+
const openState = typeof __nsBrowserRuntimeSocket.OPEN === 'number' ? __nsBrowserRuntimeSocket.OPEN : 1;
|
|
479
|
+
const connectingState = typeof WebSocketCtor.CONNECTING === 'number' ? WebSocketCtor.CONNECTING : 0;
|
|
480
|
+
if (readyState === openState || readyState === connectingState) {
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
const ws = new WebSocketCtor(__NS_BROWSER_RUNTIME_FALLBACK_WS_URL__);
|
|
485
|
+
__nsBrowserRuntimeSocket = ws;
|
|
486
|
+
ws.onopen = () => {
|
|
487
|
+
globalThis.__NS_HMR_BROWSER_RUNTIME_SOCKET_READY__ = true;
|
|
488
|
+
if (__NS_BROWSER_RUNTIME_VERBOSE__) {
|
|
489
|
+
console.info('[ns-browser-runtime-client] connected', __NS_BROWSER_RUNTIME_FALLBACK_WS_URL__);
|
|
490
|
+
}
|
|
491
|
+
};
|
|
492
|
+
ws.onmessage = (event) => {
|
|
493
|
+
try {
|
|
494
|
+
const raw = typeof event?.data === 'string' ? event.data : String(event?.data || '');
|
|
495
|
+
if (!raw) {
|
|
496
|
+
return;
|
|
497
|
+
}
|
|
498
|
+
__nsBrowserRuntimeHandleSocketMessage(JSON.parse(raw));
|
|
499
|
+
} catch (error) {
|
|
500
|
+
if (__NS_BROWSER_RUNTIME_VERBOSE__) {
|
|
501
|
+
console.warn('[ns-browser-runtime-client] failed to process websocket message', error);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
};
|
|
505
|
+
ws.onerror = (error) => {
|
|
506
|
+
if (__NS_BROWSER_RUNTIME_VERBOSE__) {
|
|
507
|
+
console.warn('[ns-browser-runtime-client] websocket error', error);
|
|
508
|
+
}
|
|
509
|
+
};
|
|
510
|
+
ws.onclose = () => {
|
|
511
|
+
if (__nsBrowserRuntimeSocket === ws) {
|
|
512
|
+
__nsBrowserRuntimeSocket = null;
|
|
513
|
+
}
|
|
514
|
+
globalThis.__NS_HMR_BROWSER_RUNTIME_SOCKET_READY__ = false;
|
|
515
|
+
__nsBrowserRuntimeScheduleReconnect();
|
|
516
|
+
};
|
|
517
|
+
} catch (error) {
|
|
518
|
+
console.warn('[ns-browser-runtime-client] failed to create websocket', error);
|
|
519
|
+
__nsBrowserRuntimeScheduleReconnect();
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
async function __nsBrowserRuntimeEnsureFullClientStarted() {
|
|
524
|
+
if (!__nsBrowserRuntimeHmrClientStartPromise) {
|
|
525
|
+
__nsBrowserRuntimeHmrClientStartPromise = import(__NS_BROWSER_RUNTIME_CLIENT_IMPORT__)
|
|
526
|
+
.then((mod) => {
|
|
527
|
+
const start = mod?.default;
|
|
528
|
+
if (typeof start !== 'function') {
|
|
529
|
+
throw new Error('NativeScript HMR client bootstrap is missing a default export');
|
|
530
|
+
}
|
|
531
|
+
start({ wsUrl: __NS_BROWSER_RUNTIME_FULL_CLIENT_WS_URL__ });
|
|
532
|
+
__nsBrowserRuntimeTrackDelegation();
|
|
533
|
+
})
|
|
534
|
+
.catch((error) => {
|
|
535
|
+
globalThis.__NS_HMR_BROWSER_RUNTIME_CLIENT_ACTIVE__ = false;
|
|
536
|
+
console.error('[ns-browser-runtime-client] failed to start full NativeScript HMR client', __NS_BROWSER_RUNTIME_CLIENT_IMPORT__, error);
|
|
537
|
+
throw error;
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
return __nsBrowserRuntimeHmrClientStartPromise;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
__nsBrowserRuntimeEnsureVendorBootstrap();
|
|
544
|
+
|
|
545
|
+
|
|
546
|
+
if (!globalThis.__NS_HMR_BROWSER_RUNTIME_CLIENT_ACTIVE__) {
|
|
547
|
+
globalThis.__NS_HMR_BROWSER_RUNTIME_CLIENT_ACTIVE__ = true;
|
|
548
|
+
globalThis.__NS_HTTP_ORIGIN__ = __NS_BROWSER_RUNTIME_ORIGIN__;
|
|
549
|
+
__nsBrowserRuntimeConnectSocket();
|
|
550
|
+
const __nsBrowserRuntimeBootWaitStartedAt = Date.now();
|
|
551
|
+
const __nsBrowserRuntimeWaitForBoot = () => {
|
|
552
|
+
if (globalThis.__NS_HMR_BOOT_COMPLETE__) {
|
|
553
|
+
if (__NS_BROWSER_RUNTIME_VERBOSE__) {
|
|
554
|
+
console.info('[ns-browser-runtime-client] boot complete observed; starting full HMR client');
|
|
555
|
+
}
|
|
556
|
+
void __nsBrowserRuntimeReplaySeededCss();
|
|
557
|
+
void __nsBrowserRuntimeEnsureFullClientStarted();
|
|
558
|
+
} else {
|
|
559
|
+
if (!__nsBrowserRuntimeBootWaitWarningIssued && Date.now() - __nsBrowserRuntimeBootWaitStartedAt >= 10000) {
|
|
560
|
+
__nsBrowserRuntimeBootWaitWarningIssued = true;
|
|
561
|
+
// Verbose-only: real Angular cold boots routinely take
|
|
562
|
+
// 15-30s through importing-main. The poller keeps watching
|
|
563
|
+
// __NS_HMR_BOOT_COMPLETE__; until it flips this looks like
|
|
564
|
+
// an error to users but is purely informational.
|
|
565
|
+
// (No backticks: this script body is embedded in a template
|
|
566
|
+
// literal in vite-plugin.ts.)
|
|
567
|
+
if (__NS_BROWSER_RUNTIME_VERBOSE__) {
|
|
568
|
+
console.warn('[ns-browser-runtime-client] boot completion was not observed; full HMR client start is still pending');
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
setTimeout(__nsBrowserRuntimeWaitForBoot, 100);
|
|
572
|
+
}
|
|
573
|
+
};
|
|
574
|
+
__nsBrowserRuntimeWaitForBoot();
|
|
575
|
+
}
|
|
576
|
+
`;
|
|
577
|
+
}
|
|
578
|
+
export function nsHmrClientVitePlugin(opts) {
|
|
579
|
+
let config;
|
|
580
|
+
const sessionId = new Date().toISOString();
|
|
34
581
|
return {
|
|
35
582
|
name: 'ns-hmr-client',
|
|
36
583
|
configResolved(c) {
|
|
37
584
|
config = c;
|
|
585
|
+
// Capture app-configured `__FOO__` defines so HMR-served modules get a
|
|
586
|
+
// const shim for them (Vite's text-substitution doesn't reach raw-served
|
|
587
|
+
// modules; without a shim a free `__FOO__` is mis-bound to /ns/rt → wrong
|
|
588
|
+
// value under HMR vs the production bundle). See setUserDefineEntries.
|
|
589
|
+
setUserDefineEntries(c.define);
|
|
38
590
|
},
|
|
39
591
|
resolveId(id) {
|
|
40
592
|
if (id === VIRTUAL_ID)
|
|
41
593
|
return RESOLVED_ID;
|
|
42
594
|
return null;
|
|
43
595
|
},
|
|
596
|
+
configureServer(server) {
|
|
597
|
+
server.middlewares.use((req, res, next) => {
|
|
598
|
+
try {
|
|
599
|
+
const url = new URL(req.url || '', 'http://localhost');
|
|
600
|
+
if (url.pathname === '/__ns_dev__/client') {
|
|
601
|
+
const requestHost = String(req.headers.host || 'localhost:5173');
|
|
602
|
+
const secure = !!config?.server?.https;
|
|
603
|
+
const origin = `${secure ? 'https' : 'http'}://${requestHost}`;
|
|
604
|
+
const wsUrl = `${secure ? 'wss' : 'ws'}://${requestHost}/ns-hmr`;
|
|
605
|
+
const clientFsPath = require.resolve('@nativescript/vite/hmr/client/index.js');
|
|
606
|
+
const projectRoot = config?.root || process.cwd();
|
|
607
|
+
const clientImport = computeClientImportSpecifier({ projectRoot, clientFsPath });
|
|
608
|
+
let hotContextImport;
|
|
609
|
+
try {
|
|
610
|
+
const hotContextFsPath = require.resolve('@nativescript/vite/hmr/client/hot-context.js');
|
|
611
|
+
hotContextImport = computeClientImportSpecifier({ projectRoot, clientFsPath: hotContextFsPath });
|
|
612
|
+
}
|
|
613
|
+
catch { }
|
|
614
|
+
const code = createNsDevClientBootstrapCode({
|
|
615
|
+
origin,
|
|
616
|
+
wsUrl,
|
|
617
|
+
clientImport,
|
|
618
|
+
hotContextImport,
|
|
619
|
+
verbose: opts.verbose,
|
|
620
|
+
});
|
|
621
|
+
res.setHeader('Access-Control-Allow-Origin', '*');
|
|
622
|
+
res.setHeader('Access-Control-Allow-Methods', 'GET, OPTIONS');
|
|
623
|
+
if (req.method === 'OPTIONS') {
|
|
624
|
+
res.statusCode = 204;
|
|
625
|
+
res.end();
|
|
626
|
+
return;
|
|
627
|
+
}
|
|
628
|
+
res.setHeader('Content-Type', 'application/javascript; charset=utf-8');
|
|
629
|
+
res.end(code);
|
|
630
|
+
return;
|
|
631
|
+
}
|
|
632
|
+
if (url.pathname !== '/__ns_dev__/session')
|
|
633
|
+
return next();
|
|
634
|
+
res.setHeader('Access-Control-Allow-Origin', '*');
|
|
635
|
+
res.setHeader('Access-Control-Allow-Methods', 'GET, OPTIONS');
|
|
636
|
+
if (req.method === 'OPTIONS') {
|
|
637
|
+
res.statusCode = 204;
|
|
638
|
+
res.end();
|
|
639
|
+
return;
|
|
640
|
+
}
|
|
641
|
+
const descriptor = createNsDevSessionDescriptor({
|
|
642
|
+
projectRoot: config?.root || process.cwd(),
|
|
643
|
+
requestHost: String(req.headers.host || 'localhost:5173'),
|
|
644
|
+
platform: opts.platform,
|
|
645
|
+
sessionId,
|
|
646
|
+
secure: !!config?.server?.https,
|
|
647
|
+
});
|
|
648
|
+
res.setHeader('Content-Type', 'application/json');
|
|
649
|
+
res.end(JSON.stringify(descriptor, null, 2));
|
|
650
|
+
}
|
|
651
|
+
catch (error) {
|
|
652
|
+
res.statusCode = 500;
|
|
653
|
+
res.setHeader('Content-Type', 'application/json');
|
|
654
|
+
res.end(JSON.stringify({ error: error?.message || 'Failed to build NativeScript dev session descriptor' }));
|
|
655
|
+
}
|
|
656
|
+
});
|
|
657
|
+
},
|
|
44
658
|
load(id) {
|
|
45
659
|
if (id !== RESOLVED_ID)
|
|
46
660
|
return null;
|
|
@@ -53,41 +667,24 @@ export function nsHmrClientVitePlugin(opts) {
|
|
|
53
667
|
const clientFsPath = require.resolve('@nativescript/vite/hmr/client/index.js');
|
|
54
668
|
// Prefer project root when available; otherwise fall back to cwd.
|
|
55
669
|
const projectRoot = config?.root || process.cwd();
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const relPosix = rel.replace(/\\/g, '/');
|
|
64
|
-
// If `rel` is absolute (e.g. starts with a drive letter on Windows),
|
|
65
|
-
// use a file:// URL for the import so Vite/Rollup do not prepend the
|
|
66
|
-
// project root and cause duplicated drive prefixes.
|
|
67
|
-
if (path.isAbsolute(rel)) {
|
|
68
|
-
clientImport = pathToFileURL(clientFsPath).toString();
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
clientImport = (relPosix.startsWith('.') ? relPosix : `/${relPosix}`).replace(/\/+/g, '/');
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
catch {
|
|
75
|
-
// On any failure, keep the original path but normalize to POSIX
|
|
76
|
-
clientImport = clientFsPath.replace(/\\/g, '/');
|
|
77
|
-
}
|
|
78
|
-
// Build ws url from Vite server info
|
|
79
|
-
let host = process.env.NS_HMR_HOST || config?.server?.host;
|
|
80
|
-
// If Vite is bound to all interfaces, prefer a LAN IP so physical devices work.
|
|
81
|
-
// The HMR client will still try emulator/localhost fallbacks when needed.
|
|
82
|
-
const hostStr = typeof host === 'string' ? host : '';
|
|
83
|
-
const isWildcard = host === true || hostStr === '0.0.0.0' || hostStr === '::' || hostStr === '';
|
|
84
|
-
if (isWildcard) {
|
|
85
|
-
host = guessLanHost() || (opts.platform === 'android' ? '10.0.2.2' : 'localhost');
|
|
86
|
-
}
|
|
87
|
-
else if (!host) {
|
|
88
|
-
host = opts.platform === 'android' ? guessLanHost() || '10.0.2.2' : 'localhost';
|
|
89
|
-
}
|
|
670
|
+
const clientImport = computeClientImportSpecifier({ projectRoot, clientFsPath });
|
|
671
|
+
// Build ws url from Vite server info. Routes through the same
|
|
672
|
+
// canonical helper as `main-entry.ts` / `base.ts` so the
|
|
673
|
+
// websocket endpoint embedded in `bundle.mjs` and every other
|
|
674
|
+
// `/ns/*` URL share one origin string — required by the iOS
|
|
675
|
+
// HTTP ESM cache identity rule, and necessary for Android
|
|
676
|
+
// emulators that can't reach `0.0.0.0` / `localhost`.
|
|
90
677
|
const port = Number(config?.server?.port || 5173);
|
|
678
|
+
// Pass `port` through so the Android emulator path attempts
|
|
679
|
+
// `adb reverse tcp:<port> tcp:<port>` before falling back to
|
|
680
|
+
// `10.0.2.2`. The websocket URL and bundle.mjs URLs both
|
|
681
|
+
// flow from this same helper, so they stay byte-identical
|
|
682
|
+
// (required by the iOS HTTP ESM cache identity rule).
|
|
683
|
+
const { host } = resolveDeviceReachableHost({
|
|
684
|
+
host: config?.server?.host,
|
|
685
|
+
platform: opts.platform,
|
|
686
|
+
port,
|
|
687
|
+
});
|
|
91
688
|
const secure = !!config?.server?.https;
|
|
92
689
|
const protocol = secure ? 'wss' : 'ws';
|
|
93
690
|
const wsUrl = `${protocol}://${host}:${port}/ns-hmr`;
|