@nativescript/vite 8.0.0-beta.0 → 8.0.0-rc.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 +73 -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 +227 -77
- 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/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 +13 -0
- package/helpers/flavor.js +18 -1
- package/helpers/flavor.js.map +1 -1
- package/helpers/global-defines.d.ts +117 -0
- package/helpers/global-defines.js +209 -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 +6 -20
- package/helpers/init.js.map +1 -1
- package/helpers/logging.d.ts +1 -0
- package/helpers/logging.js +65 -4
- 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 +2 -1
- 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 +87 -0
- package/hmr/client/framework-client-strategy.js +18 -0
- package/hmr/client/framework-client-strategy.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 +67 -0
- package/hmr/client/hot-context.js +307 -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 +100 -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 +464 -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/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 +44 -0
- package/hmr/server/process-code-for-device.js +834 -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 +295 -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 +96 -0
- package/hmr/server/websocket-module-specifiers.js +819 -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 +590 -0
- package/hmr/server/websocket-ns-m.js.map +1 -0
- package/hmr/server/websocket-served-module-helpers.d.ts +89 -0
- package/hmr/server/websocket-served-module-helpers.js +935 -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 +7 -17
- package/hmr/server/websocket.js +723 -5376
- package/hmr/server/websocket.js.map +1 -1
- package/hmr/shared/ns-globals.d.ts +107 -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 +76 -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,3 +1,51 @@
|
|
|
1
|
+
import { getGlobalScope } from '../../../shared/runtime/global-scope.js';
|
|
2
|
+
import { getNsHotRegistry } from '../../../client/hot-context.js';
|
|
3
|
+
import { getOverlayApi, resolveOverlayEnabled, setUpdateStage } from '../../../client/overlay-driver.js';
|
|
4
|
+
import { handleCssUpdates } from '../../../client/css-handler.js';
|
|
5
|
+
import { resolveHmrHttpOrigin } from '../../../client/utils.js';
|
|
6
|
+
import { readNsRuntimeDevHostApi } from '../../../shared/runtime/browser-runtime-contract.js';
|
|
7
|
+
import { sweepTrackedWorkers } from '../../../shared/runtime/worker-tracking.js';
|
|
8
|
+
// HMR-applying progress overlay, driven through `client/overlay-driver.ts`.
|
|
9
|
+
// The opt-out gate is collapsed into a runtime boolean once at module load so
|
|
10
|
+
// each call-site is a single property check rather than a try/typeof chain.
|
|
11
|
+
const overlayEnabled = resolveOverlayEnabled();
|
|
12
|
+
function setUpdateOverlayStage(stage, info) {
|
|
13
|
+
if (!overlayEnabled)
|
|
14
|
+
return;
|
|
15
|
+
setUpdateStage(stage, info);
|
|
16
|
+
}
|
|
17
|
+
function hideUpdateOverlay() {
|
|
18
|
+
if (!overlayEnabled)
|
|
19
|
+
return;
|
|
20
|
+
try {
|
|
21
|
+
const api = getOverlayApi();
|
|
22
|
+
if (api && typeof api.hide === 'function') {
|
|
23
|
+
api.hide('hmr-applied');
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
catch { }
|
|
27
|
+
}
|
|
28
|
+
// Safe accessor for the build-time `__NS_ENV_VERBOSE__` constant.
|
|
29
|
+
//
|
|
30
|
+
// Vite replaces `__NS_ENV_VERBOSE__` at build time via `define`. In
|
|
31
|
+
// unit tests (vitest, plain ts-node, etc.) the identifier is
|
|
32
|
+
// undeclared at runtime, so a bare reference throws ReferenceError —
|
|
33
|
+
// `typeof` is the only safe way to probe it. We collapse the
|
|
34
|
+
// build-time constant into a runtime boolean once at module load and
|
|
35
|
+
// then short-circuit on `verbose` arguments at every call-site.
|
|
36
|
+
//
|
|
37
|
+
// Always order `verbose && envVerbose` so the runtime flag
|
|
38
|
+
// short-circuits the build-time constant; that prevents reference
|
|
39
|
+
// errors in test environments where the `define` substitution does
|
|
40
|
+
// not run.
|
|
41
|
+
const envVerbose = (() => {
|
|
42
|
+
try {
|
|
43
|
+
return typeof __NS_ENV_VERBOSE__ === 'boolean' ? __NS_ENV_VERBOSE__ : false;
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
})();
|
|
1
49
|
export function installAngularHmrClientHooks() {
|
|
2
50
|
const g = globalThis;
|
|
3
51
|
if (g.__NS_ANGULAR_HMR_CLIENT_INSTALLED__) {
|
|
@@ -5,53 +53,619 @@ export function installAngularHmrClientHooks() {
|
|
|
5
53
|
}
|
|
6
54
|
try {
|
|
7
55
|
g.__NS_ANGULAR_HMR_CLIENT_INSTALLED__ = true;
|
|
8
|
-
if (
|
|
56
|
+
if (envVerbose) {
|
|
9
57
|
console.log('[hmr-angular] client hooks installed');
|
|
10
58
|
}
|
|
11
59
|
}
|
|
12
60
|
catch { }
|
|
13
61
|
}
|
|
14
|
-
|
|
62
|
+
async function applyDeferredCssUpdates(msg) {
|
|
63
|
+
const updates = Array.isArray(msg?.cssUpdates) ? msg.cssUpdates : [];
|
|
64
|
+
if (!updates.length)
|
|
65
|
+
return;
|
|
66
|
+
try {
|
|
67
|
+
await handleCssUpdates(updates, resolveHmrHttpOrigin(msg?.origin));
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
// The Angular module refresh is still viable. Surface the CSS failure, but
|
|
71
|
+
// continue with the reboot so one fetch cannot strand the old application.
|
|
72
|
+
console.warn('[ns-hmr][angular] deferred app.css update failed:', error?.message || error);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
// HMR cycle serialization mutex.
|
|
76
|
+
//
|
|
77
|
+
// A back-to-back save (e.g., the user holds Cmd+S, or `runOnSave`
|
|
78
|
+
// saves a file twice during one tick) could overlap two HMR cycles:
|
|
79
|
+
// the first cycle's `import(entry)` would still be resolving when the
|
|
80
|
+
// second cycle's `invalidateModules` (ns:module) ran, leaving the registry in
|
|
81
|
+
// a half-evicted state and producing flaky "module already evaluated"
|
|
82
|
+
// errors.
|
|
83
|
+
//
|
|
84
|
+
// Each `handleAngularHotUpdateMessage` call publishes a promise to
|
|
85
|
+
// `inFlightHmrCycle` and awaits the previous publication before
|
|
86
|
+
// starting its own evict + import. The previous-cycle promise resolves
|
|
87
|
+
// regardless of success or failure (we always run `resolveCycle()` in
|
|
88
|
+
// `finally`), so a stuck cycle can't deadlock the queue. The mutex is
|
|
89
|
+
// intentionally process-wide and resets naturally on cold-boot or
|
|
90
|
+
// websocket reconnect (both blow away the JS realm).
|
|
91
|
+
let inFlightHmrCycle = null;
|
|
92
|
+
// Explicit module eviction.
|
|
93
|
+
//
|
|
94
|
+
// `invalidateModules` is an ns:module builtin member that takes an
|
|
95
|
+
// array of canonical /ns/m/<rel> URLs, removes each one from V8's
|
|
96
|
+
// module registry (`g_moduleRegistry`) and the prefetch cache, and
|
|
97
|
+
// marks the keys "bust next fetch" so the runtime's next HTTP fetch
|
|
98
|
+
// for them defeats OS-level caches with a one-shot query nonce.
|
|
99
|
+
//
|
|
100
|
+
// Soft-fails (with a loud warning) if the runtime is missing the
|
|
101
|
+
// function — the eviction protocol is a required part of the runtime
|
|
102
|
+
// contract, so that indicates a runtime/vite version mismatch.
|
|
103
|
+
// Dispatch one of Vite's standard HMR lifecycle events through the JS
|
|
104
|
+
// hot registry (`hot-context.ts`). The registry owns the listener map
|
|
105
|
+
// that `import.meta.hot.on(event, cb)` populates; this function is the
|
|
106
|
+
// producer side that lets the Angular HMR client emit the canonical
|
|
107
|
+
// Vite events (`vite:beforeUpdate`, `vite:afterUpdate`,
|
|
108
|
+
// `vite:beforeFullReload`, `vite:invalidate`, `vite:error`) at the
|
|
109
|
+
// right moments. User code that does
|
|
110
|
+
// `import.meta.hot.on('vite:beforeUpdate', cb)` only fires when this is
|
|
111
|
+
// called.
|
|
112
|
+
//
|
|
113
|
+
// The registry is a `globalThis.__NS_HOT_REGISTRY__` singleton, so this
|
|
114
|
+
// works even if this module and the served app modules were evaluated
|
|
115
|
+
// from different URLs. Per-listener failures are swallowed inside the
|
|
116
|
+
// registry, so a single bad listener can't break the HMR cycle.
|
|
117
|
+
function dispatchHotEvent(_g, event, payload) {
|
|
118
|
+
try {
|
|
119
|
+
getNsHotRegistry().dispatchHotEvent(event, payload);
|
|
120
|
+
}
|
|
121
|
+
catch (err) {
|
|
122
|
+
// Defensive safety net for registry regressions. Log only under
|
|
123
|
+
// verbose to avoid noisy dev logs.
|
|
124
|
+
if (envVerbose) {
|
|
125
|
+
console.warn(`[ns-hmr][client] dispatchHotEvent('${event}') threw:`, err?.message ?? err);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
// Trigger a JS-driven full app reload, dispatching `vite:beforeFullReload`
|
|
130
|
+
// first so user-code listeners can react. The registry's full-reload path
|
|
131
|
+
// evicts every loaded app module (ns:module `getLoadedModuleUrls` →
|
|
132
|
+
// `invalidateModules`) and re-imports the dev entry; the
|
|
133
|
+
// `Application.run` patch in root-placeholder converts re-entry into
|
|
134
|
+
// `resetRootView`. Returns `true` if the reload was triggered. Used both
|
|
135
|
+
// by `import.meta.hot.invalidate()` (handled inside the registry) AND by
|
|
136
|
+
// the declined-module check below (where the JS layer makes the decision
|
|
137
|
+
// and asks for the reload).
|
|
138
|
+
function triggerFullReload(_g, message) {
|
|
139
|
+
dispatchHotEvent(_g, 'vite:beforeFullReload', { message });
|
|
140
|
+
try {
|
|
141
|
+
// Fire-and-forget — the reload path is async, but we don't await
|
|
142
|
+
// it here because the module graph is about to be torn down. The
|
|
143
|
+
// HMR cycle's caller treats this as terminal and short-circuits
|
|
144
|
+
// the rest of the cycle.
|
|
145
|
+
getNsHotRegistry().requestFullReload(message);
|
|
146
|
+
}
|
|
147
|
+
catch (err) {
|
|
148
|
+
if (envVerbose) {
|
|
149
|
+
console.warn('[ns-hmr][client] requestFullReload threw:', err?.message ?? err);
|
|
150
|
+
}
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
return true;
|
|
154
|
+
}
|
|
155
|
+
// Check if any module being touched by this HMR update has called
|
|
156
|
+
// `import.meta.hot.decline()`. If so, per Vite spec we MUST do a full
|
|
157
|
+
// reload instead of a hot-update — declining means "I refuse to be
|
|
158
|
+
// hot-updated". Returns `true` if a full reload was triggered (caller
|
|
159
|
+
// should short-circuit the rest of the cycle).
|
|
160
|
+
function checkDeclinedAndReload(g, msg, options) {
|
|
161
|
+
// `evictPaths` is the eviction set the dev server computed for this
|
|
162
|
+
// HMR cycle — every module that needs to be re-evaluated. If ANY of
|
|
163
|
+
// those modules declined HMR, the whole cycle has to convert to a
|
|
164
|
+
// full reload. Pass them through verbatim; the registry canonicalizes
|
|
165
|
+
// internally when matching against its declined set.
|
|
166
|
+
const evictPaths = Array.isArray(msg?.evictPaths) ? msg.evictPaths : [];
|
|
167
|
+
let declined = false;
|
|
168
|
+
try {
|
|
169
|
+
declined = getNsHotRegistry().hasDeclined(evictPaths);
|
|
170
|
+
}
|
|
171
|
+
catch (err) {
|
|
172
|
+
if (options.verbose && envVerbose) {
|
|
173
|
+
console.warn('[ns-hmr][client] hasDeclined threw:', err?.message ?? err);
|
|
174
|
+
}
|
|
175
|
+
return false;
|
|
176
|
+
}
|
|
177
|
+
if (!declined)
|
|
178
|
+
return false;
|
|
179
|
+
const filePath = typeof msg?.path === 'string' ? msg.path : '<unknown>';
|
|
180
|
+
const message = `module declined HMR (file=${filePath}, evictPaths=${evictPaths.length})`;
|
|
181
|
+
console.info(`[ns-hmr][decline] ${message} — falling back to full reload`);
|
|
182
|
+
const reloaded = triggerFullReload(g, message);
|
|
183
|
+
if (!reloaded && options.verbose && envVerbose) {
|
|
184
|
+
console.warn('[ns-hmr][client] declined module detected but full reload unavailable; HMR will proceed');
|
|
185
|
+
}
|
|
186
|
+
return reloaded;
|
|
187
|
+
}
|
|
188
|
+
// Drain `import.meta.hot.dispose(cb)` callbacks via the JS hot
|
|
189
|
+
// registry before Angular's reboot.
|
|
190
|
+
//
|
|
191
|
+
// The registry (`hot-context.ts`) owns the dispose map — every call to
|
|
192
|
+
// `import.meta.hot.dispose(cb)` from user code lands there. We pass NO
|
|
193
|
+
// key argument so the registry drains every registered callback across
|
|
194
|
+
// every module, which matches the wholesale-reboot semantics of
|
|
195
|
+
// `__reboot_ng_modules__`: when Angular tears down its component tree
|
|
196
|
+
// and re-bootstraps, every module's accumulated side effects are
|
|
197
|
+
// conceptually being thrown away. (A future per-module HMR client could
|
|
198
|
+
// pass an explicit key list to limit the drain.)
|
|
199
|
+
function runHmrDisposeCallbacks(_g, options) {
|
|
200
|
+
let executed = null;
|
|
201
|
+
try {
|
|
202
|
+
const result = getNsHotRegistry().runDispose();
|
|
203
|
+
executed = typeof result === 'number' ? result : 0;
|
|
204
|
+
}
|
|
205
|
+
catch (err) {
|
|
206
|
+
// Per-callback failures are swallowed inside the registry. If
|
|
207
|
+
// the registry itself throws we MUST NOT take down the HMR cycle.
|
|
208
|
+
if (options.verbose && envVerbose) {
|
|
209
|
+
console.warn('[ns-hmr][client] runDispose threw:', err?.message ?? err);
|
|
210
|
+
}
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
// Surface ONE concise log per HMR cycle that actually had disposers
|
|
214
|
+
// to run — verbose-only, like every other client log.
|
|
215
|
+
if (executed && executed > 0 && options.verbose && envVerbose) {
|
|
216
|
+
console.info(`[ns-hmr][dispose] ran ${executed} import.meta.hot.dispose callback${executed === 1 ? '' : 's'} before reboot`);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
// Terminate every live worker before Angular's reboot — fully userland.
|
|
220
|
+
//
|
|
221
|
+
// Drains `globalThis.__NS_HMR_WORKERS__`, the session-wide tracked set fed
|
|
222
|
+
// by the global `Worker` constructor interception the session bootstrap
|
|
223
|
+
// installs before any app/framework/vendor code evaluates
|
|
224
|
+
// (`shared/runtime/worker-tracking.ts`). Because the interception sits on
|
|
225
|
+
// the sole birth path for main-realm workers, the set covers every spawn —
|
|
226
|
+
// `new Worker(new URL(...))`, raw `Worker('~/x.js')`, dynamic-import- and
|
|
227
|
+
// plugin-spawned workers alike. Nested workers are reclaimed transitively:
|
|
228
|
+
// the runtime cascades `worker.terminate()` through each worker's children.
|
|
229
|
+
//
|
|
230
|
+
// Tolerant of:
|
|
231
|
+
// * Missing global — non-worker apps have no Set; we no-op.
|
|
232
|
+
// * `terminate()` throwing — the runtime can throw on already-dead
|
|
233
|
+
// workers; the sweep counts per-entry failures so subsequent
|
|
234
|
+
// terminations and the reboot itself still proceed.
|
|
235
|
+
//
|
|
236
|
+
// The Set is always cleared after the sweep so producer-side bookkeeping
|
|
237
|
+
// doesn't grow unbounded across HMR cycles.
|
|
238
|
+
function terminateTrackedWorkers(g, options) {
|
|
239
|
+
const { terminated, failed, total } = sweepTrackedWorkers(g);
|
|
240
|
+
// Surface ONE concise log per HMR cycle when there was actually work
|
|
241
|
+
// to do — verbose-only, like every other client log: the dev terminal
|
|
242
|
+
// stays quiet by default.
|
|
243
|
+
if ((terminated > 0 || failed > 0) && options.verbose && envVerbose) {
|
|
244
|
+
console.info(`[ns-hmr][workers] terminated ${terminated}/${total} tracked worker${total === 1 ? '' : 's'} before reboot`);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
// Narrow an unknown eviction-list entry to a fetchable http(s) URL. Shared by
|
|
248
|
+
// the reboot path (refreshAngularBootstrapOptions) and the leaf re-import
|
|
249
|
+
// fallback so the two stay in lockstep on what counts as a valid evict URL.
|
|
250
|
+
const isHttpUrl = (u) => typeof u === 'string' && /^https?:\/\//.test(u);
|
|
251
|
+
function invalidateModules(urls, verbose) {
|
|
252
|
+
if (!urls || !urls.length)
|
|
253
|
+
return false;
|
|
254
|
+
const fn = readNsRuntimeDevHostApi(globalThis).invalidateModules;
|
|
255
|
+
if (typeof fn !== 'function') {
|
|
256
|
+
console.warn(`[ns-hmr][client] runtime missing ns:module invalidateModules (runtime/vite version mismatch?); update cannot apply. evict=${urls.length}`);
|
|
257
|
+
return false;
|
|
258
|
+
}
|
|
259
|
+
try {
|
|
260
|
+
if (verbose && envVerbose) {
|
|
261
|
+
console.info(`[ns-hmr][client] invalidateModules calling ns:module invalidateModules urls=${urls.length}`);
|
|
262
|
+
}
|
|
263
|
+
fn.call(null, urls.slice());
|
|
264
|
+
if (verbose && envVerbose) {
|
|
265
|
+
console.info(`[ns-hmr][client] invalidateModules OK urls=${urls.length}`);
|
|
266
|
+
}
|
|
267
|
+
return true;
|
|
268
|
+
}
|
|
269
|
+
catch (error) {
|
|
270
|
+
// Real exception path — the runtime hook itself threw. Always
|
|
271
|
+
// surfaced for the same reason as the missing-hook warn above.
|
|
272
|
+
console.warn('[ns-hmr][client] ns:module invalidateModules threw', error?.message || error);
|
|
273
|
+
return false;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
function getAngularBootstrapEntryCandidates(msg) {
|
|
277
|
+
// Define substitution does not reach this raw-served file; prefer the
|
|
278
|
+
// globalThis seed from the entry's defines-seed module ('app/'-rooted
|
|
279
|
+
// projects would otherwise get the wrong '/src' default).
|
|
280
|
+
const root = (typeof __NS_APP_ROOT_VIRTUAL__ === 'string' && __NS_APP_ROOT_VIRTUAL__) || (typeof getGlobalScope().__NS_APP_ROOT_VIRTUAL__ === 'string' && getGlobalScope().__NS_APP_ROOT_VIRTUAL__) || '/src';
|
|
281
|
+
// Server announces the canonical bootstrap entry as
|
|
282
|
+
// `importerEntry`, computed from `package.json#main`. Fall back to
|
|
283
|
+
// the legacy `entryCandidates` array (for older servers) and finally
|
|
284
|
+
// to a hard-coded list. All candidates must be project-relative
|
|
285
|
+
// posix paths (e.g. `/src/main.ts`) so they slot directly behind
|
|
286
|
+
// `${origin}/ns/m`.
|
|
287
|
+
const explicit = typeof msg?.importerEntry === 'string' && msg.importerEntry.startsWith('/') ? [msg.importerEntry] : [];
|
|
288
|
+
const legacy = Array.isArray(msg?.entryCandidates) && msg.entryCandidates.length ? msg.entryCandidates : [];
|
|
289
|
+
const fallback = [`${root}/main.ts`, `${root}/app.ts`];
|
|
290
|
+
const merged = [...explicit, ...legacy, ...fallback];
|
|
291
|
+
const seen = new Set();
|
|
292
|
+
const result = [];
|
|
293
|
+
for (const candidate of merged) {
|
|
294
|
+
if (typeof candidate !== 'string' || !candidate.startsWith('/'))
|
|
295
|
+
continue;
|
|
296
|
+
if (seen.has(candidate))
|
|
297
|
+
continue;
|
|
298
|
+
seen.add(candidate);
|
|
299
|
+
result.push(candidate);
|
|
300
|
+
}
|
|
301
|
+
return result;
|
|
302
|
+
}
|
|
303
|
+
async function importAngularBootstrapEntry(url) {
|
|
304
|
+
const g = globalThis;
|
|
305
|
+
if (typeof g.__NS_HMR_IMPORT__ === 'function') {
|
|
306
|
+
return g.__NS_HMR_IMPORT__(url);
|
|
307
|
+
}
|
|
308
|
+
return import(/* @vite-ignore */ url);
|
|
309
|
+
}
|
|
310
|
+
export async function refreshAngularBootstrapOptions(msg, options) {
|
|
311
|
+
const g = globalThis;
|
|
312
|
+
if (typeof g.__NS_UPDATE_ANGULAR_APP_OPTIONS__ !== 'function') {
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
const originSource = typeof msg?.origin === 'string' && /^https?:\/\//.test(msg.origin) ? msg.origin : g.__NS_HTTP_ORIGIN__;
|
|
316
|
+
if (typeof originSource !== 'string' || !/^https?:\/\//.test(originSource)) {
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
const origin = originSource.replace(/\/$/, '');
|
|
320
|
+
// Explicit eviction set takes precedence over URL versioning. The
|
|
321
|
+
// server walks the inverse-dep closure of the changed file
|
|
322
|
+
// (collectAngularEvictionUrls) and emits canonical /ns/m/<rel> URLs
|
|
323
|
+
// in `evictPaths`. We hand the list to the runtime before
|
|
324
|
+
// re-importing the entry; the runtime drops those entries from
|
|
325
|
+
// `g_moduleRegistry` so V8's subsequent `import(entry)` walks the
|
|
326
|
+
// dep graph and re-fetches ONLY those modules. Everything else stays
|
|
327
|
+
// hot in the cache.
|
|
328
|
+
const evictPaths = Array.isArray(msg?.evictPaths) ? msg.evictPaths.filter(isHttpUrl) : [];
|
|
329
|
+
// Diagnostic: log eviction set client-side so we can verify what
|
|
330
|
+
// the runtime is being asked to drop. Up to 32 entries are sampled
|
|
331
|
+
// so large constants edits don't swamp the console. Gated behind
|
|
332
|
+
// the standard `__NS_ENV_VERBOSE__` build define (`NS_VITE_VERBOSE`)
|
|
333
|
+
// so the lines stay silent on normal saves.
|
|
334
|
+
if (options.verbose && envVerbose) {
|
|
335
|
+
const _path = typeof msg?.path === 'string' ? msg.path : '(unknown)';
|
|
336
|
+
console.info(`[ns-hmr][client] received ns:angular-update path=${_path} evictPaths.length=${evictPaths.length} importerEntry=${msg?.importerEntry ?? '(none)'}`);
|
|
337
|
+
if (evictPaths.length) {
|
|
338
|
+
const sample = evictPaths.slice(0, 32);
|
|
339
|
+
console.info(`[ns-hmr][client] evictPaths firstN=`, sample);
|
|
340
|
+
if (evictPaths.length > sample.length) {
|
|
341
|
+
console.info(`[ns-hmr][client] evictPaths hidden=${evictPaths.length - sample.length}`);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
// Drive the apply-progress overlay through the 'evicting' frame
|
|
346
|
+
// *before* the runtime invalidate call so the user sees the count
|
|
347
|
+
// even on the cheapest stage. Eviction count also doubles as a
|
|
348
|
+
// useful debug breadcrumb in the overlay's detail line — large
|
|
349
|
+
// counts (e.g. constants edits → 100+ importers) explain why a
|
|
350
|
+
// cycle takes longer than an HTML edit.
|
|
351
|
+
setUpdateOverlayStage('evicting', {
|
|
352
|
+
detail: evictPaths.length ? `Invalidating ${evictPaths.length} module${evictPaths.length === 1 ? '' : 's'}` : 'Invalidating module cache',
|
|
353
|
+
});
|
|
354
|
+
const evicted = invalidateModules(evictPaths, options.verbose);
|
|
355
|
+
if (options.verbose && envVerbose) {
|
|
356
|
+
console.info(`[ns-hmr][client] evict count=${evictPaths.length} ok=${evicted ? 'yes' : 'no'}`);
|
|
357
|
+
}
|
|
358
|
+
// No client-side prefetch is needed after the eviction: the runtime's
|
|
359
|
+
// async module-graph walk fetches the evicted modules concurrently on
|
|
360
|
+
// background threads when the re-import below triggers it.
|
|
361
|
+
// URL strategy: always the STABLE canonical URL. The eviction removed
|
|
362
|
+
// the changed modules from V8's registry (and armed the runtime's
|
|
363
|
+
// bust-next-fetch nonce), so re-importing the entry under its
|
|
364
|
+
// canonical URL triggers fresh fetches for exactly the evicted
|
|
365
|
+
// modules; the rest of the graph is a cache hit. Never version or
|
|
366
|
+
// tag the URL — the runtime treats the literal URL as module
|
|
367
|
+
// identity, so a tagged re-import would mint a second module
|
|
368
|
+
// identity instead of refreshing the first.
|
|
369
|
+
let lastError;
|
|
370
|
+
// 'reimporting' is the entry point for the long tail of an HMR
|
|
371
|
+
// cycle: V8 walks the freshly-evicted graph and the iOS runtime
|
|
372
|
+
// re-fetches each node from the dev server. We announce the stage
|
|
373
|
+
// once, before the loop, so the user sees a progress jump even when
|
|
374
|
+
// the import resolves on the first candidate (the common case).
|
|
375
|
+
setUpdateOverlayStage('reimporting', {
|
|
376
|
+
detail: 'Re-importing Angular bootstrap entry',
|
|
377
|
+
});
|
|
378
|
+
for (const entry of getAngularBootstrapEntryCandidates(msg)) {
|
|
379
|
+
const url = `${origin}/ns/m${entry}`;
|
|
380
|
+
try {
|
|
381
|
+
g.__NS_ANGULAR_HMR_REGISTER_ONLY__ = true;
|
|
382
|
+
await importAngularBootstrapEntry(url);
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
catch (error) {
|
|
386
|
+
lastError = error;
|
|
387
|
+
}
|
|
388
|
+
finally {
|
|
389
|
+
g.__NS_ANGULAR_HMR_REGISTER_ONLY__ = false;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
if (options.verbose && envVerbose && lastError) {
|
|
393
|
+
console.warn('[hmr-angular] failed to refresh Angular bootstrap entry', lastError?.message || lastError);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
export async function handleAngularHotUpdateMessage(msg, options) {
|
|
15
397
|
if (!msg || msg.type !== 'ns:angular-update') {
|
|
16
398
|
return false;
|
|
17
399
|
}
|
|
400
|
+
// Cycle mutex. See `inFlightHmrCycle` for why this is necessary. We
|
|
401
|
+
// publish `thisCycle` *before* awaiting the previous one so a third
|
|
402
|
+
// concurrent message sees the latest in-flight, not the stale
|
|
403
|
+
// previous. This serializes N concurrent updates into a single FIFO
|
|
404
|
+
// chain.
|
|
405
|
+
const previousCycle = inFlightHmrCycle;
|
|
406
|
+
let resolveCycle;
|
|
407
|
+
const thisCycle = new Promise((resolve) => {
|
|
408
|
+
resolveCycle = resolve;
|
|
409
|
+
});
|
|
410
|
+
inFlightHmrCycle = thisCycle;
|
|
411
|
+
if (previousCycle) {
|
|
412
|
+
try {
|
|
413
|
+
await previousCycle;
|
|
414
|
+
}
|
|
415
|
+
catch { }
|
|
416
|
+
}
|
|
417
|
+
// Single-line log lands in iOS device console as `CONSOLE INFO` so the user can
|
|
418
|
+
// correlate with the server's `[hmr-ws][update] ...` line and see
|
|
419
|
+
// where the save's wall time actually goes (refresh vs. reboot).
|
|
420
|
+
const t0 = Date.now();
|
|
421
|
+
let tAfterRefresh = t0;
|
|
422
|
+
let tEnd = t0;
|
|
423
|
+
const filePath = typeof msg?.path === 'string' ? msg.path : '<unknown>';
|
|
424
|
+
const emitTiming = (ok, errorMessage) => {
|
|
425
|
+
const refreshMs = Math.max(0, tAfterRefresh - t0);
|
|
426
|
+
const rebootMs = Math.max(0, tEnd - tAfterRefresh);
|
|
427
|
+
const totalMs = Math.max(0, tEnd - t0);
|
|
428
|
+
const status = ok ? 'ok' : 'FAILED';
|
|
429
|
+
const suffix = errorMessage ? ` error=${errorMessage}` : '';
|
|
430
|
+
console.info(`[ns-hmr][angular] ${status} file=${filePath} refresh=${refreshMs}ms reboot=${rebootMs}ms total=${totalMs}ms${suffix}`);
|
|
431
|
+
};
|
|
432
|
+
// Show the apply-progress overlay as soon as the
|
|
433
|
+
// mutex unblocks us. Posting this *after* the awaited
|
|
434
|
+
// previousCycle keeps each cycle's stages visually grouped in the
|
|
435
|
+
// overlay (cycle-1 finishes its 'complete' before cycle-2's
|
|
436
|
+
// 'received' overrides it).
|
|
437
|
+
//
|
|
438
|
+
// The detail line surfaces the changed file path so the user can
|
|
439
|
+
// confirm at a glance which save the overlay is reflecting.
|
|
440
|
+
const overlayDetail = filePath && filePath !== '<unknown>' ? `Updating ${filePath}` : 'Preparing update';
|
|
441
|
+
setUpdateOverlayStage('received', { detail: overlayDetail });
|
|
18
442
|
try {
|
|
19
443
|
const g = globalThis;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
444
|
+
// Vite-spec entry: `vite:beforeUpdate` fires as soon as the
|
|
445
|
+
// client receives an update message, BEFORE any work begins
|
|
446
|
+
// (refresh, dispose, reboot). User listeners can use this to
|
|
447
|
+
// pause animations, cancel in-flight requests, etc. Payload
|
|
448
|
+
// matches Vite's `Update[]` shape loosely — `path` is the
|
|
449
|
+
// canonical changed file, `evictPaths` is the eviction
|
|
450
|
+
// closure the server already computed.
|
|
451
|
+
const updatePayload = {
|
|
452
|
+
type: 'js-update',
|
|
453
|
+
path: typeof msg?.path === 'string' ? msg.path : null,
|
|
454
|
+
evictPaths: Array.isArray(msg?.evictPaths) ? msg.evictPaths : [],
|
|
455
|
+
timestamp: t0,
|
|
456
|
+
};
|
|
457
|
+
dispatchHotEvent(g, 'vite:beforeUpdate', { updates: [updatePayload] });
|
|
458
|
+
// Declined-module short-circuit. If any updated module called
|
|
459
|
+
// `import.meta.hot.decline()`, we MUST do a full reload per
|
|
460
|
+
// Vite spec rather than the hot-update path. `triggerFullReload`
|
|
461
|
+
// also dispatches `vite:beforeFullReload`. The reload tears the
|
|
462
|
+
// JS realm down so we don't need to do any further bookkeeping
|
|
463
|
+
// here — return early.
|
|
464
|
+
if (checkDeclinedAndReload(g, msg, options)) {
|
|
465
|
+
tEnd = Date.now();
|
|
466
|
+
emitTiming(true);
|
|
467
|
+
return true;
|
|
468
|
+
}
|
|
469
|
+
// Prefer __reboot_ng_modules__ — it properly disposes existing modules,
|
|
470
|
+
// re-bootstraps Angular inside NgZone, and sets the root view internally.
|
|
471
|
+
// __NS_ANGULAR_BOOTSTRAP__ is exposed as a secondary signal that the
|
|
472
|
+
// Angular HMR system is ready, but __reboot_ng_modules__ is the
|
|
473
|
+
// canonical reboot entry point.
|
|
474
|
+
const reboot = g.__reboot_ng_modules__;
|
|
475
|
+
if (typeof reboot === 'function') {
|
|
476
|
+
if (options.verbose && envVerbose) {
|
|
477
|
+
console.info('[ns-hmr][client] calling __reboot_ng_modules__');
|
|
478
|
+
}
|
|
479
|
+
// Pre-import reset: clear Angular's `GENERATED_COMP_IDS` map BEFORE
|
|
480
|
+
// the changed component modules are re-imported. If we don't, every
|
|
481
|
+
// touched component's `ɵɵdefineComponent` call hashes to the same
|
|
482
|
+
// id as its predecessor (selectors + className haven't changed),
|
|
483
|
+
// hits a "previousCompDefType !== componentDef.type" collision, and
|
|
484
|
+
// surfaces NG0912 "Component ID generation collision detected".
|
|
485
|
+
// The map is cleared again post-reboot as a safety net, but doing
|
|
486
|
+
// it once here suppresses the warning at the source.
|
|
487
|
+
try {
|
|
488
|
+
const preResetCompiled = g.__reset_ng_compiled_components__;
|
|
489
|
+
if (typeof preResetCompiled === 'function') {
|
|
490
|
+
preResetCompiled();
|
|
491
|
+
}
|
|
25
492
|
}
|
|
493
|
+
catch { }
|
|
494
|
+
await refreshAngularBootstrapOptions(msg, options);
|
|
495
|
+
tAfterRefresh = Date.now();
|
|
496
|
+
try {
|
|
497
|
+
g.__NS_HMR_IMPORT_NONCE__ = (typeof g.__NS_HMR_IMPORT_NONCE__ === 'number' ? g.__NS_HMR_IMPORT_NONCE__ : 0) + 1;
|
|
498
|
+
}
|
|
499
|
+
catch { }
|
|
26
500
|
try {
|
|
27
501
|
g.__NS_DEV_RESET_IN_PROGRESS__ = true;
|
|
28
502
|
}
|
|
29
503
|
catch { }
|
|
30
|
-
|
|
31
|
-
|
|
504
|
+
// Two-step pre-reboot cleanup. Order matters: dispose runs
|
|
505
|
+
// FIRST so user-code disposers see a still-live runtime
|
|
506
|
+
// (sockets, workers, etc.) and can issue graceful "I'm
|
|
507
|
+
// going away" messages; then we hard-terminate any worker
|
|
508
|
+
// the user didn't manually clean up.
|
|
509
|
+
//
|
|
510
|
+
// Step 1 — `import.meta.hot.dispose(cb)` callbacks
|
|
511
|
+
// ────────────────────────────────────────────────
|
|
512
|
+
// The JS hot registry (`hot-context.ts`) walks its
|
|
513
|
+
// per-module dispose map — populated by
|
|
514
|
+
// `import.meta.hot.dispose(cb)` — and invokes every
|
|
515
|
+
// callback with that module's `hot.data` object, matching
|
|
516
|
+
// the Vite spec.
|
|
517
|
+
//
|
|
518
|
+
// This is the standards-compliant cleanup hook every Vite
|
|
519
|
+
// user already knows. Apps register their intervals,
|
|
520
|
+
// listeners, sockets, store subscriptions, etc. via
|
|
521
|
+
// `import.meta.hot.dispose(...)` and they're guaranteed to
|
|
522
|
+
// fire before the next Angular reboot — no NS-specific
|
|
523
|
+
// knowledge required.
|
|
524
|
+
runHmrDisposeCallbacks(g, options);
|
|
525
|
+
// Step 2 — worker auto-terminate (defence in depth)
|
|
526
|
+
// ───────────────────────────────────────────────────
|
|
527
|
+
// Even with perfect dispose() coverage, workers spawned
|
|
528
|
+
// from constructors that re-run on Angular reboot (e.g.
|
|
529
|
+
// `new Worker(...)` inside `AppComponent`'s constructor)
|
|
530
|
+
// don't fire dispose for `app.component.ts` when only
|
|
531
|
+
// `login.component.html` changes — `app.component.ts`
|
|
532
|
+
// isn't being replaced, so its disposers don't run per
|
|
533
|
+
// Vite spec. The session-wide tracked set doesn't care
|
|
534
|
+
// about module boundaries: the `Worker` constructor
|
|
535
|
+
// interception recorded every spawn, and this sweep
|
|
536
|
+
// terminates them all.
|
|
537
|
+
terminateTrackedWorkers(g, options);
|
|
538
|
+
// 'rebooting' marks the long tail of the cycle: NgZone
|
|
539
|
+
// teardown, module re-instantiation, and resetRootView.
|
|
540
|
+
// The detail line shows refresh-so-far ms so a user can
|
|
541
|
+
// already see if the slow phase is re-import or reboot.
|
|
542
|
+
setUpdateOverlayStage('rebooting', {
|
|
543
|
+
detail: `Re-bootstrapping Angular (refresh ${Math.max(0, tAfterRefresh - t0)}ms)`,
|
|
544
|
+
});
|
|
545
|
+
// Tailwind content CSS belongs to this same save. Fetch and install it
|
|
546
|
+
// inside the serialized Angular cycle, immediately before constructing
|
|
547
|
+
// the replacement tree. This prevents a standalone CSS message from
|
|
548
|
+
// racing teardown, while allowing the new views to resolve both existing
|
|
549
|
+
// bindings and newly generated utility selectors during construction.
|
|
550
|
+
await applyDeferredCssUpdates(msg);
|
|
551
|
+
try {
|
|
552
|
+
reboot(true);
|
|
553
|
+
}
|
|
554
|
+
finally {
|
|
555
|
+
try {
|
|
556
|
+
g.__NS_DEV_RESET_IN_PROGRESS__ = false;
|
|
557
|
+
}
|
|
558
|
+
catch { }
|
|
559
|
+
}
|
|
560
|
+
tEnd = Date.now();
|
|
561
|
+
emitTiming(true);
|
|
562
|
+
// Vite-spec exit: `vite:afterUpdate` fires after the update
|
|
563
|
+
// has been successfully applied. User code can re-attach
|
|
564
|
+
// any state torn down by `vite:beforeUpdate` (resume
|
|
565
|
+
// animations, re-fetch, etc.). Same payload shape as
|
|
566
|
+
// `vite:beforeUpdate` so listeners can correlate.
|
|
567
|
+
dispatchHotEvent(g, 'vite:afterUpdate', { updates: [updatePayload] });
|
|
568
|
+
// 'complete' surfaces the wall-clock total so a user gets a
|
|
569
|
+
// single-glance confirmation matching the [ns-hmr][angular]
|
|
570
|
+
// log line in the terminal. The overlay auto-hides shortly
|
|
571
|
+
// after.
|
|
572
|
+
setUpdateOverlayStage('complete', {
|
|
573
|
+
detail: `Total ${Math.max(0, tEnd - t0)}ms`,
|
|
574
|
+
});
|
|
575
|
+
return true;
|
|
576
|
+
}
|
|
577
|
+
// Reached only when the NgModule reboot path above was skipped — i.e.
|
|
578
|
+
// `g.__reboot_ng_modules__` was not a function at the time this update
|
|
579
|
+
// arrived, so no full re-bootstrap ran. (That handler is installed by
|
|
580
|
+
// `runNativeScriptAngularApp()`, so this is NOT about how the app boots;
|
|
581
|
+
// it covers the window where the handler isn't registered yet, or any
|
|
582
|
+
// update that never wires one up.) Fall back to the standard Vite
|
|
583
|
+
// leaf-module path: evict + re-import the changed module(s) so their
|
|
584
|
+
// top-level side-effects and `import.meta.hot.accept` callbacks re-run
|
|
585
|
+
// WITHOUT a full reboot. The server narrows leaf edits (no @Component/
|
|
586
|
+
// @Directive/@Pipe/@Injectable/@NgModule decorator) to just the changed
|
|
587
|
+
// file, so this is cheap. This is what makes self-accepting utility
|
|
588
|
+
// modules (e.g. a live-tuning module that posts values to native on
|
|
589
|
+
// evaluation) hot-reload at all — without it they were silently dropped
|
|
590
|
+
// here.
|
|
591
|
+
try {
|
|
592
|
+
const origin = (typeof g.__NS_HTTP_ORIGIN__ === 'string' ? g.__NS_HTTP_ORIGIN__ : '').replace(/\/$/, '');
|
|
593
|
+
let urls = Array.isArray(msg?.evictPaths) ? msg.evictPaths.filter(isHttpUrl) : [];
|
|
594
|
+
// Derive the canonical /ns/m/<rel> URL from msg.path when the server
|
|
595
|
+
// sent no evictPaths (V8 keys app modules by their extensionless URL).
|
|
596
|
+
if (!urls.length && typeof msg?.path === 'string' && origin) {
|
|
597
|
+
const rel = msg.path.replace(/^\//, '').replace(/\.(?:[mc]?[jt]sx?)$/i, '');
|
|
598
|
+
urls = [`${origin}/ns/m/${rel}`];
|
|
599
|
+
}
|
|
600
|
+
if (urls.length) {
|
|
601
|
+
setUpdateOverlayStage('reimporting', { detail: `Re-importing ${urls.length} module${urls.length === 1 ? '' : 's'}` });
|
|
602
|
+
invalidateModules(urls, options.verbose);
|
|
603
|
+
const nonce = (typeof g.__NS_HMR_IMPORT_NONCE__ === 'number' ? g.__NS_HMR_IMPORT_NONCE__ : 0) + 1;
|
|
604
|
+
g.__NS_HMR_IMPORT_NONCE__ = nonce;
|
|
605
|
+
let reimported = 0;
|
|
606
|
+
for (const u of urls) {
|
|
32
607
|
try {
|
|
33
|
-
|
|
608
|
+
await importAngularBootstrapEntry(`${u}${u.includes('?') ? '&' : '?'}hmr=${nonce}`);
|
|
609
|
+
reimported++;
|
|
34
610
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
611
|
+
catch (e) {
|
|
612
|
+
if (options.verbose) {
|
|
613
|
+
console.warn('[ns-hmr][leaf] re-import failed', u, (e && e.message) || e);
|
|
38
614
|
}
|
|
39
|
-
catch { }
|
|
40
615
|
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
616
|
+
}
|
|
617
|
+
const ok = reimported > 0;
|
|
618
|
+
tEnd = Date.now();
|
|
619
|
+
emitTiming(ok, ok ? 'leaf-reimport' : 'leaf-reimport-failed');
|
|
620
|
+
hideUpdateOverlay();
|
|
621
|
+
return ok;
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
catch (e) {
|
|
625
|
+
if (options.verbose) {
|
|
626
|
+
console.warn('[ns-hmr][leaf] fallback threw', (e && e.message) || e);
|
|
627
|
+
}
|
|
44
628
|
}
|
|
45
|
-
if (options.verbose &&
|
|
46
|
-
console.warn('[hmr-angular]
|
|
629
|
+
if (options.verbose && envVerbose) {
|
|
630
|
+
console.warn('[hmr-angular] No Angular HMR handler found. Ensure runNativeScriptAngularApp() has been called.');
|
|
47
631
|
}
|
|
632
|
+
tEnd = Date.now();
|
|
633
|
+
emitTiming(false, 'no-reboot-handler');
|
|
634
|
+
// No reboot handler and nothing to re-import → hide the overlay rather
|
|
635
|
+
// than leaving stale progress on screen.
|
|
636
|
+
hideUpdateOverlay();
|
|
48
637
|
}
|
|
49
638
|
catch (error) {
|
|
50
639
|
if (options.verbose) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
640
|
+
console.warn('[hmr-angular] failed to handle update', (error && error.message) || error);
|
|
641
|
+
}
|
|
642
|
+
tEnd = Date.now();
|
|
643
|
+
const errorMessage = (error && error.message) || String(error);
|
|
644
|
+
emitTiming(false, errorMessage);
|
|
645
|
+
// Vite-spec error event — fires on any HMR cycle that throws.
|
|
646
|
+
// Payload shape mirrors Vite's `ErrorPayload`: `err: { message,
|
|
647
|
+
// stack? }` plus optional `path`. Soft-fails if no listeners.
|
|
648
|
+
dispatchHotEvent(globalThis, 'vite:error', {
|
|
649
|
+
type: 'error',
|
|
650
|
+
err: {
|
|
651
|
+
message: errorMessage,
|
|
652
|
+
stack: (error && error.stack) || undefined,
|
|
653
|
+
},
|
|
654
|
+
path: typeof msg?.path === 'string' ? msg.path : undefined,
|
|
655
|
+
});
|
|
656
|
+
// Errors → drop the overlay so the user isn't left looking
|
|
657
|
+
// at indefinite progress; the underlying error is already
|
|
658
|
+
// logged above (and surfaced via Vite's standard error
|
|
659
|
+
// pipeline through the websocket).
|
|
660
|
+
hideUpdateOverlay();
|
|
661
|
+
}
|
|
662
|
+
finally {
|
|
663
|
+
try {
|
|
664
|
+
resolveCycle();
|
|
665
|
+
}
|
|
666
|
+
catch { }
|
|
667
|
+
if (inFlightHmrCycle === thisCycle) {
|
|
668
|
+
inFlightHmrCycle = null;
|
|
55
669
|
}
|
|
56
670
|
}
|
|
57
671
|
return true;
|