@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
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Early "pending" notification for HMR.
|
|
3
|
+
*
|
|
4
|
+
* When `handleHotUpdate(ctx)` first fires for a save event, the server
|
|
5
|
+
* spends 7–200ms doing graph upserts, transforms and dependency
|
|
6
|
+
* analysis BEFORE broadcasting `ns:angular-update` (or
|
|
7
|
+
* `ns:css-updates`). During that window the client has no idea a
|
|
8
|
+
* change is in flight, so the HMR-applying overlay only appears at
|
|
9
|
+
* the tail end of the cycle and the user perceives the dev loop as
|
|
10
|
+
* laggy.
|
|
11
|
+
*
|
|
12
|
+
* `ns:hmr-pending` is broadcast at the very start of `handleHotUpdate`
|
|
13
|
+
* with just the file path + classified kind. The client reacts by
|
|
14
|
+
* showing the 'received' overlay frame immediately. The authoritative
|
|
15
|
+
* payload (`ns:angular-update` / `ns:css-updates`) follows once the
|
|
16
|
+
* server is ready and walks the rest of the stage progression.
|
|
17
|
+
*
|
|
18
|
+
* This module is intentionally a pure helper so the message shape and
|
|
19
|
+
* narrowing rules can be verified without spinning up a Vite dev
|
|
20
|
+
* server.
|
|
21
|
+
*/
|
|
22
|
+
export function createHmrPendingMessage(input) {
|
|
23
|
+
const allowed = ['ts', 'css', 'html', 'unknown'];
|
|
24
|
+
const kind = allowed.includes(input.kind || '') ? input.kind : 'unknown';
|
|
25
|
+
return {
|
|
26
|
+
type: 'ns:hmr-pending',
|
|
27
|
+
origin: typeof input.origin === 'string' ? input.origin : '',
|
|
28
|
+
path: typeof input.path === 'string' ? input.path : '',
|
|
29
|
+
kind,
|
|
30
|
+
timestamp: typeof input.timestamp === 'number' && Number.isFinite(input.timestamp) ? input.timestamp : 0,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=websocket-hmr-pending.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"websocket-hmr-pending.js","sourceRoot":"","sources":["../../../../../packages/vite/hmr/server/websocket-hmr-pending.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAQH,MAAM,UAAU,uBAAuB,CAAC,KAAwE;IAC/G,MAAM,OAAO,GAAqB,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;IACnE,MAAM,IAAI,GAAI,OAA6B,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,CAAE,KAAK,CAAC,IAAuB,CAAC,CAAC,CAAC,SAAS,CAAC;IACpH,OAAO;QACN,IAAI,EAAE,gBAAgB;QACtB,MAAM,EAAE,OAAO,KAAK,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE;QAC5D,IAAI,EAAE,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE;QACtD,IAAI;QACJ,SAAS,EAAE,OAAO,KAAK,CAAC,SAAS,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;KACxG,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { HmrContext } from 'vite';
|
|
2
|
+
import type { WebSocketServer } from 'ws';
|
|
3
|
+
import type { FrameworkServerStrategy } from './framework-strategy.js';
|
|
4
|
+
import type { HmrModuleGraph } from './hmr-module-graph.js';
|
|
5
|
+
import type { SharedTransformRequestRunner } from './shared-transform-request.js';
|
|
6
|
+
import type { CssUpdateItem } from '../shared/protocol.js';
|
|
7
|
+
import type { BootstrapRootComponent } from '../frameworks/angular/server/angular-root-component.js';
|
|
8
|
+
/**
|
|
9
|
+
* Dependencies injected into each strategy's `handleHotUpdate` (and the shared
|
|
10
|
+
* {@link runHotUpdatePrologue} it runs first). These hold per-server instance
|
|
11
|
+
* state (`wss`, `moduleGraph`, the file maps, `sharedTransformRequest`) or are
|
|
12
|
+
* plugin-closure accessors. Pure transform helpers (`cleanCode`,
|
|
13
|
+
* `rewriteImports`, `processSfcCode`, `collectImportDependencies`) are NOT on the
|
|
14
|
+
* context — the strategies that need them import them directly from
|
|
15
|
+
* `websocket-device-transform.ts`. `getServerOrigin` is likewise imported
|
|
16
|
+
* directly here from `server-origin.ts` (spy via the module in tests).
|
|
17
|
+
*/
|
|
18
|
+
export interface NsHotUpdateContext {
|
|
19
|
+
wss: WebSocketServer | null;
|
|
20
|
+
moduleGraph: HmrModuleGraph;
|
|
21
|
+
strategy: FrameworkServerStrategy;
|
|
22
|
+
verbose: boolean;
|
|
23
|
+
sfcFileMap: Map<string, string>;
|
|
24
|
+
depFileMap: Map<string, string>;
|
|
25
|
+
sharedTransformRequest: SharedTransformRequestRunner;
|
|
26
|
+
getHmrSourceRootsCached: () => string[];
|
|
27
|
+
getBootstrapEntryRelPath: () => string;
|
|
28
|
+
isSocketClientOpen: (client: {
|
|
29
|
+
readyState?: number;
|
|
30
|
+
OPEN?: number;
|
|
31
|
+
} | null | undefined) => boolean;
|
|
32
|
+
getHmrSocketRole: (client: {
|
|
33
|
+
__nsHmrClientRole?: string;
|
|
34
|
+
} | null | undefined) => string;
|
|
35
|
+
shouldRemapImport: (spec: string) => boolean;
|
|
36
|
+
rememberAngularReloadSuppression: (root: string, file: string, ttlMs?: number) => void;
|
|
37
|
+
/**
|
|
38
|
+
* Resolves the Angular bootstrap (root) component, or `null` when it
|
|
39
|
+
* can't be statically determined. Used to force root-component template
|
|
40
|
+
* edits through the reboot path instead of Analog's in-place update,
|
|
41
|
+
* which is destructive for the root view (see {@link BootstrapRootComponent}).
|
|
42
|
+
*/
|
|
43
|
+
getRootComponentIdentity: () => BootstrapRootComponent | null;
|
|
44
|
+
getGraphInitialPopulationPromise: () => Promise<void> | null;
|
|
45
|
+
appRootDir: string;
|
|
46
|
+
}
|
|
47
|
+
/** Always-on per-update timing + diagnostics, mutated in place across the prologue and the framework tail. */
|
|
48
|
+
export interface HmrUpdateMetrics {
|
|
49
|
+
file: string;
|
|
50
|
+
kind: string;
|
|
51
|
+
t0: number;
|
|
52
|
+
tAfterAwait: number;
|
|
53
|
+
tAfterFramework: number;
|
|
54
|
+
tEnd: number;
|
|
55
|
+
invalidated: number;
|
|
56
|
+
recipients: number;
|
|
57
|
+
narrowed: boolean | undefined;
|
|
58
|
+
emitted: boolean;
|
|
59
|
+
}
|
|
60
|
+
/** Per-invocation locals computed by {@link runHotUpdatePrologue} and consumed by the per-flavor tail. */
|
|
61
|
+
export interface HotUpdatePrologueState {
|
|
62
|
+
root: string;
|
|
63
|
+
updateRel: string;
|
|
64
|
+
metrics: HmrUpdateMetrics;
|
|
65
|
+
emitSummary: () => void;
|
|
66
|
+
/** App CSS output changed during an Angular TS edit; attach it to the reboot message. */
|
|
67
|
+
deferredCssUpdates?: CssUpdateItem[];
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Shared, framework-agnostic prologue for every strategy's `handleHotUpdate`:
|
|
71
|
+
* scope gating, update-metrics setup, the `ns:hmr-pending` broadcast, awaiting the
|
|
72
|
+
* initial graph population, the common module-graph upsert, CSS hot-update +
|
|
73
|
+
* Tailwind content-CSS broadcast, and the project-scope filter. Returns `null`
|
|
74
|
+
* when one of those steps fully handles the change (every such path resolves to
|
|
75
|
+
* Vite's `undefined` result, so the caller just returns), otherwise the
|
|
76
|
+
* per-invocation {@link HotUpdatePrologueState} (`root`, `updateRel`, the live
|
|
77
|
+
* `metrics` object, the idempotent `emitSummary`) the per-flavor tail consumes.
|
|
78
|
+
* Exported so per-flavor strategies can own `prologue + their tail`.
|
|
79
|
+
*/
|
|
80
|
+
export declare function runHotUpdatePrologue(ctx: HmrContext, deps: NsHotUpdateContext): Promise<HotUpdatePrologueState | null>;
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
import { isRuntimeGraphExcludedPath } from './runtime-graph-filter.js';
|
|
3
|
+
import { isWithinHmrScope } from '../../helpers/hmr-scope.js';
|
|
4
|
+
import { collectGraphUpdateModulesForHotUpdate } from '../frameworks/angular/server/websocket-angular-hot-update.js';
|
|
5
|
+
import { getAppCssState } from '../../helpers/app-css-state.js';
|
|
6
|
+
import { classifyHmrUpdateKind, formatHmrUpdateSummary } from './perf-instrumentation.js';
|
|
7
|
+
import { createHmrPendingMessage } from './websocket-hmr-pending.js';
|
|
8
|
+
import { appCssRootRelPath, buildCssUpdateItem, buildCssUpdatesMessage } from './css-update-message.js';
|
|
9
|
+
import { processContentCssUpdate } from './content-css-update.js';
|
|
10
|
+
import { getServerOrigin } from './server-origin.js';
|
|
11
|
+
/**
|
|
12
|
+
* Shared, framework-agnostic prologue for every strategy's `handleHotUpdate`:
|
|
13
|
+
* scope gating, update-metrics setup, the `ns:hmr-pending` broadcast, awaiting the
|
|
14
|
+
* initial graph population, the common module-graph upsert, CSS hot-update +
|
|
15
|
+
* Tailwind content-CSS broadcast, and the project-scope filter. Returns `null`
|
|
16
|
+
* when one of those steps fully handles the change (every such path resolves to
|
|
17
|
+
* Vite's `undefined` result, so the caller just returns), otherwise the
|
|
18
|
+
* per-invocation {@link HotUpdatePrologueState} (`root`, `updateRel`, the live
|
|
19
|
+
* `metrics` object, the idempotent `emitSummary`) the per-flavor tail consumes.
|
|
20
|
+
* Exported so per-flavor strategies can own `prologue + their tail`.
|
|
21
|
+
*/
|
|
22
|
+
export async function runHotUpdatePrologue(ctx, deps) {
|
|
23
|
+
const { wss, moduleGraph, strategy, verbose, getHmrSourceRootsCached, isSocketClientOpen } = deps;
|
|
24
|
+
const APP_ROOT_DIR = deps.appRootDir;
|
|
25
|
+
const graphInitialPopulationPromise = deps.getGraphInitialPopulationPromise();
|
|
26
|
+
const { file, server } = ctx;
|
|
27
|
+
if (!wss) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
if (isRuntimeGraphExcludedPath(file)) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
// Authoritative "what triggers HMR" gate, applied before the pending
|
|
34
|
+
// overlay broadcast below: react only to files inside the app source
|
|
35
|
+
// dir (`appPath`) or a tsconfig-configured shared library.
|
|
36
|
+
if (!isWithinHmrScope(file, getHmrSourceRootsCached())) {
|
|
37
|
+
if (verbose) {
|
|
38
|
+
console.log(`[ns-hmr][server] ignored change (outside HMR source scope): ${file}`);
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
// Always-on update timing. Captures the four phases (await,
|
|
43
|
+
// framework, broadcast, total) plus invalidated module count
|
|
44
|
+
// and recipient count. Emitted at the end of this function via
|
|
45
|
+
// `emitHmrUpdateSummary()`. Single line, always-on so a
|
|
46
|
+
// 6-second `.ts` save is immediately visible without flipping
|
|
47
|
+
// verbose.
|
|
48
|
+
const updateRoot = server.config.root || process.cwd();
|
|
49
|
+
const updateRel = (() => {
|
|
50
|
+
try {
|
|
51
|
+
return '/' + path.posix.normalize(path.relative(updateRoot, file)).split(path.sep).join('/');
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return file;
|
|
55
|
+
}
|
|
56
|
+
})();
|
|
57
|
+
const updateMetrics = {
|
|
58
|
+
file: updateRel,
|
|
59
|
+
kind: classifyHmrUpdateKind(file),
|
|
60
|
+
t0: Date.now(),
|
|
61
|
+
tAfterAwait: 0,
|
|
62
|
+
tAfterFramework: 0,
|
|
63
|
+
tEnd: 0,
|
|
64
|
+
invalidated: 0,
|
|
65
|
+
recipients: 0,
|
|
66
|
+
// Narrowing diagnostic — populated by the angular branch when
|
|
67
|
+
// the changed file is `.ts`, otherwise remains undefined and is
|
|
68
|
+
// omitted from the summary line entirely.
|
|
69
|
+
narrowed: undefined,
|
|
70
|
+
emitted: false,
|
|
71
|
+
};
|
|
72
|
+
// Broadcast a "pending" notification at the very start of
|
|
73
|
+
// handleHotUpdate so the client can show the HMR-applying
|
|
74
|
+
// overlay BEFORE we spend time on graph updates / transforms /
|
|
75
|
+
// dependency analysis (typically 7–200ms on a warm cache).
|
|
76
|
+
// Without this, the overlay only appears at `ns:angular-update`
|
|
77
|
+
// broadcast time and the user perceives a "delayed" reaction
|
|
78
|
+
// to their save.
|
|
79
|
+
//
|
|
80
|
+
// Fire-and-forget: a failed pending broadcast must never
|
|
81
|
+
// hold up the actual update. The client treats receipt of
|
|
82
|
+
// `ns:angular-update` (or `ns:css-updates`) as authoritative;
|
|
83
|
+
// the pending message is purely a UX hint.
|
|
84
|
+
try {
|
|
85
|
+
const pendingPayload = JSON.stringify(createHmrPendingMessage({
|
|
86
|
+
origin: getServerOrigin(server),
|
|
87
|
+
path: updateMetrics.file,
|
|
88
|
+
kind: updateMetrics.kind,
|
|
89
|
+
timestamp: updateMetrics.t0,
|
|
90
|
+
}));
|
|
91
|
+
wss.clients.forEach((client) => {
|
|
92
|
+
if (isSocketClientOpen(client)) {
|
|
93
|
+
try {
|
|
94
|
+
client.send(pendingPayload);
|
|
95
|
+
}
|
|
96
|
+
catch { }
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
catch { }
|
|
101
|
+
const emitHmrUpdateSummary = () => {
|
|
102
|
+
if (updateMetrics.emitted)
|
|
103
|
+
return;
|
|
104
|
+
updateMetrics.emitted = true;
|
|
105
|
+
updateMetrics.tEnd = Date.now();
|
|
106
|
+
try {
|
|
107
|
+
const awaitMs = (updateMetrics.tAfterAwait || updateMetrics.t0) - updateMetrics.t0;
|
|
108
|
+
const frameworkMs = (updateMetrics.tAfterFramework || updateMetrics.tAfterAwait || updateMetrics.t0) - (updateMetrics.tAfterAwait || updateMetrics.t0);
|
|
109
|
+
const broadcastMs = updateMetrics.tEnd - (updateMetrics.tAfterFramework || updateMetrics.tAfterAwait || updateMetrics.t0);
|
|
110
|
+
const totalMs = updateMetrics.tEnd - updateMetrics.t0;
|
|
111
|
+
console.info(formatHmrUpdateSummary({
|
|
112
|
+
file: updateMetrics.file,
|
|
113
|
+
kind: updateMetrics.kind,
|
|
114
|
+
awaitMs,
|
|
115
|
+
frameworkMs,
|
|
116
|
+
broadcastMs,
|
|
117
|
+
totalMs,
|
|
118
|
+
invalidated: updateMetrics.invalidated,
|
|
119
|
+
recipients: updateMetrics.recipients,
|
|
120
|
+
narrowed: updateMetrics.narrowed,
|
|
121
|
+
}));
|
|
122
|
+
}
|
|
123
|
+
catch { }
|
|
124
|
+
};
|
|
125
|
+
// The first /ns/m request kicks off populateInitialGraph in the
|
|
126
|
+
// background. If an HMR update races in before that walk
|
|
127
|
+
// completes, we'd lose transitive-importer data. Await
|
|
128
|
+
// completion here so the delta computation below always sees a
|
|
129
|
+
// populated graph.
|
|
130
|
+
if (graphInitialPopulationPromise) {
|
|
131
|
+
try {
|
|
132
|
+
await graphInitialPopulationPromise;
|
|
133
|
+
}
|
|
134
|
+
catch { }
|
|
135
|
+
}
|
|
136
|
+
updateMetrics.tAfterAwait = Date.now();
|
|
137
|
+
// Graph update for this file change (wrapped to avoid aborting rest of handler)
|
|
138
|
+
try {
|
|
139
|
+
// Angular HTML templates opt out via `skipDefaultGraphUpdate` — their tail
|
|
140
|
+
// re-queries the graph and drives the in-place swap / reboot itself.
|
|
141
|
+
const skipDefaultGraphUpdate = strategy.skipDefaultGraphUpdate?.(file) ?? false;
|
|
142
|
+
if (!skipDefaultGraphUpdate) {
|
|
143
|
+
const graphTargets = collectGraphUpdateModulesForHotUpdate({
|
|
144
|
+
file,
|
|
145
|
+
flavor: strategy.flavor,
|
|
146
|
+
modules: ctx.modules,
|
|
147
|
+
getModuleById: (id) => server.moduleGraph.getModuleById(id),
|
|
148
|
+
verbose,
|
|
149
|
+
});
|
|
150
|
+
for (const mod of graphTargets) {
|
|
151
|
+
if (!mod?.id)
|
|
152
|
+
continue;
|
|
153
|
+
try {
|
|
154
|
+
const deps = Array.from(mod.importedModules || [])
|
|
155
|
+
.map((m) => (m.id || '').replace(/\?.*$/, ''))
|
|
156
|
+
.filter(Boolean);
|
|
157
|
+
const transformed = await server.transformRequest(mod.id);
|
|
158
|
+
const code = transformed?.code || '';
|
|
159
|
+
moduleGraph.upsert((mod.id || '').replace(/\?.*$/, ''), code, deps, {
|
|
160
|
+
emitDeltaOnInsert: true,
|
|
161
|
+
// Defer the delta broadcast until AFTER the framework
|
|
162
|
+
// hot-update handler has had a chance to invalidate the
|
|
163
|
+
// shared transform-request cache + Vite's moduleGraph
|
|
164
|
+
// for the changed file and its transitive importers.
|
|
165
|
+
// Otherwise the client races: it receives the delta
|
|
166
|
+
// (eviction + re-import via tagged URL) before the
|
|
167
|
+
// server has purged its caches, and the re-import is
|
|
168
|
+
// served from cache → V8 evaluates the previous save's
|
|
169
|
+
// transformed code → patchRegistry runs against an
|
|
170
|
+
// unchanged source → the visible page is "one save
|
|
171
|
+
// behind". Angular has always taken this path; Solid
|
|
172
|
+
// needs the same contract because Solid HMR depends
|
|
173
|
+
// on the client re-fetching the just-changed module
|
|
174
|
+
// to drive `solid-refresh.patchRegistry`.
|
|
175
|
+
broadcastDelta: !strategy.deferDeltaBroadcast,
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
catch (error) {
|
|
179
|
+
if (verbose)
|
|
180
|
+
console.warn('[hmr-ws][v2] failed graph update target', mod.id, error);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
catch (e) {
|
|
186
|
+
if (verbose)
|
|
187
|
+
console.warn('[hmr-ws][v2] failed graph update', e);
|
|
188
|
+
}
|
|
189
|
+
const root = server.config.root || process.cwd();
|
|
190
|
+
let deferredCssUpdates;
|
|
191
|
+
// CSS hot-update — handled BEFORE the project-scope filter because
|
|
192
|
+
// workspace deps (component `styleUrls`, `@import` partials) live outside
|
|
193
|
+
// `<root>/`. We distinguish two kinds of style edit and apply each
|
|
194
|
+
// correctly on the device — this is the fix for the regression where
|
|
195
|
+
// component `styleUrls` edits were misrouted to a global `app.css` refresh
|
|
196
|
+
// and silently did nothing:
|
|
197
|
+
//
|
|
198
|
+
// • GLOBAL stylesheet — the app entry CSS itself OR one of its `@import`
|
|
199
|
+
// deps (tracked via `getAppCssState().deps`). Broadcast the app entry
|
|
200
|
+
// CSS path so Vite re-runs PostCSS through the `@import` chain; the
|
|
201
|
+
// device replaces the boot-time `app.css`-tagged selectors.
|
|
202
|
+
//
|
|
203
|
+
// • COMPONENT style (`styleUrls`, including workspace-library
|
|
204
|
+
// components). Broadcast the style file's OWN path under a per-file
|
|
205
|
+
// tag. The device fetches that component's CSS and replaces just that
|
|
206
|
+
// file's selectors (`addTaggedAdditionalCSS` keyed by the file path),
|
|
207
|
+
// re-styling the live view without a reboot or `ɵɵreplaceMetadata`
|
|
208
|
+
// swap. `app.css` is never involved — it does not contain the
|
|
209
|
+
// component's inlined styles. Using a per-file tag (instead of the
|
|
210
|
+
// shared `app.css` tag) avoids clobbering the global stylesheet.
|
|
211
|
+
if (file.endsWith('.css')) {
|
|
212
|
+
const fileAbs = path.resolve(file).replace(/\\/g, '/');
|
|
213
|
+
const appCssState = getAppCssState(server);
|
|
214
|
+
const appEntryCssAbs = (appCssState?.path || path.resolve(root, APP_ROOT_DIR, 'app.css')).replace(/\\/g, '/');
|
|
215
|
+
const isGlobalStyle = fileAbs === appEntryCssAbs || !!appCssState?.deps?.has(fileAbs);
|
|
216
|
+
// Component-scoped style edit the framework applies in place itself
|
|
217
|
+
// (Angular + Analog liveReload → `angular:component-update`). Suppress
|
|
218
|
+
// the `ns:css-updates` broadcast: it can't win the emulated-scoping
|
|
219
|
+
// specificity battle anyway, AND the device's `?direct=1` fetch would
|
|
220
|
+
// create the css `?direct` module that stops the framework from
|
|
221
|
+
// re-emitting its component-update on subsequent edits. The framework's
|
|
222
|
+
// own `handleHotUpdate` (a separate plugin) drives the update.
|
|
223
|
+
if (!isGlobalStyle && strategy.ownsComponentStyleHmr?.(server)) {
|
|
224
|
+
updateMetrics.tAfterFramework = Date.now();
|
|
225
|
+
if (verbose)
|
|
226
|
+
console.log(`[hmr-ws] component style edit ${file} → left to framework component-update (no css broadcast)`);
|
|
227
|
+
emitHmrUpdateSummary();
|
|
228
|
+
return null;
|
|
229
|
+
}
|
|
230
|
+
const toRootRel = (absOrFile) => '/' + path.posix.normalize(path.relative(root, absOrFile)).split(path.sep).join('/');
|
|
231
|
+
// GLOBAL → app entry CSS path (default `app.css` tag on the client),
|
|
232
|
+
// through the guarded canonical helper. COMPONENT → the style file's
|
|
233
|
+
// OWN path (may legitimately escape the root for workspace libs).
|
|
234
|
+
const broadcastPath = isGlobalStyle ? appCssRootRelPath(root, appEntryCssAbs) : toRootRel(file);
|
|
235
|
+
const tag = isGlobalStyle ? undefined : broadcastPath;
|
|
236
|
+
updateMetrics.tAfterFramework = Date.now();
|
|
237
|
+
if (!broadcastPath) {
|
|
238
|
+
if (verbose)
|
|
239
|
+
console.warn(`[hmr-ws] global app.css path escapes the project root; skipped CSS broadcast for ${file}`);
|
|
240
|
+
emitHmrUpdateSummary();
|
|
241
|
+
return null;
|
|
242
|
+
}
|
|
243
|
+
try {
|
|
244
|
+
const msg = buildCssUpdatesMessage(server, [buildCssUpdateItem(broadcastPath, { tag })]);
|
|
245
|
+
wss.clients.forEach((client) => {
|
|
246
|
+
if (isSocketClientOpen(client)) {
|
|
247
|
+
client.send(JSON.stringify(msg));
|
|
248
|
+
updateMetrics.recipients += 1;
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
catch (error) {
|
|
253
|
+
console.warn('[hmr-ws] CSS update failed:', error);
|
|
254
|
+
}
|
|
255
|
+
if (verbose)
|
|
256
|
+
console.log(`[hmr-ws] Hot update for: ${file} → broadcast CSS ${broadcastPath} (${isGlobalStyle ? 'global app.css' : `component, tag=${tag}`})`);
|
|
257
|
+
emitHmrUpdateSummary();
|
|
258
|
+
return null;
|
|
259
|
+
}
|
|
260
|
+
// No second project-scope filter here. The authoritative allowlist is the
|
|
261
|
+
// `isWithinHmrScope` gate at the top of this prologue — app source dir plus
|
|
262
|
+
// tsconfig-configured shared-library roots. An older, narrower re-filter at
|
|
263
|
+
// this point (project-root `src`/`core`/app-dir substring checks) silently
|
|
264
|
+
// dropped workspace-library files: their `.ts`/`.html` edits never reached
|
|
265
|
+
// the framework tails, so a monorepo lib component's class edit could only
|
|
266
|
+
// flow through Analog's in-place `ɵɵreplaceMetadata` path — which reuses
|
|
267
|
+
// the live instance and can NEVER apply class-body changes — while the
|
|
268
|
+
// Angular reboot broadcast (`ns:angular-update`) that actually delivers
|
|
269
|
+
// them never fired. The visible symptom: editing a lib component's class
|
|
270
|
+
// (e.g. converting inputs to signals) appears to hot-update but the running
|
|
271
|
+
// instance keeps the old shape, and the next template edit that uses the
|
|
272
|
+
// new shape throws (`ctx.x is not a function`) on every subsequent save.
|
|
273
|
+
if (verbose)
|
|
274
|
+
console.log(`[hmr-ws] Hot update for: ${file}`);
|
|
275
|
+
// Tailwind / content-scanning CSS routing for non-CSS edits — see
|
|
276
|
+
// `processContentCssUpdate` for the full background. This MUST run before
|
|
277
|
+
// the framework branches because several of them return early (notably the
|
|
278
|
+
// Angular HTML live-reload path), and the broadcast must land alongside
|
|
279
|
+
// the framework's own template-update payload.
|
|
280
|
+
if (!file.endsWith('.css')) {
|
|
281
|
+
const contentCss = await processContentCssUpdate({
|
|
282
|
+
server,
|
|
283
|
+
file,
|
|
284
|
+
root,
|
|
285
|
+
wss,
|
|
286
|
+
isSocketClientOpen,
|
|
287
|
+
deferToFrameworkUpdate: strategy.defersContentCssToFrameworkUpdate?.(file) ?? false,
|
|
288
|
+
verbose,
|
|
289
|
+
});
|
|
290
|
+
deferredCssUpdates = contentCss.deferredCssUpdates;
|
|
291
|
+
updateMetrics.recipients += contentCss.recipients;
|
|
292
|
+
}
|
|
293
|
+
return { root, updateRel, metrics: updateMetrics, emitSummary: emitHmrUpdateSummary, deferredCssUpdates };
|
|
294
|
+
}
|
|
295
|
+
//# sourceMappingURL=websocket-hot-update.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"websocket-hot-update.js","sourceRoot":"","sources":["../../../../../packages/vite/hmr/server/websocket-hot-update.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAI7B,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,qCAAqC,EAAiC,MAAM,8DAA8D,CAAC;AACpJ,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAC1F,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAErE,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACxG,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AA8DrD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,GAAe,EAAE,IAAwB;IACnF,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,GAAG,IAAI,CAAC;IAClG,MAAM,YAAY,GAAG,IAAI,CAAC,UAAU,CAAC;IACrC,MAAM,6BAA6B,GAAG,IAAI,CA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F,OAAO;SACP,CAAC,CAAC;QACH,kBAAkB,GAAG,UAAU,CAAC,kBAAkB,CAAC;QACnD,aAAa,CAAC,UAAU,IAAI,UAAU,CAAC,UAAU,CAAC;IACnD,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,CAAC;AAC3G,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ViteDevServer } from 'vite';
|
|
2
|
+
import type { FrameworkServerStrategy } from './framework-strategy.js';
|
|
3
|
+
export interface RegisterImportMapRouteOptions {
|
|
4
|
+
/** The active framework strategy — only its `flavor` is consulted. */
|
|
5
|
+
getStrategy: () => FrameworkServerStrategy | undefined;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Registers the device import-map endpoint: `GET /ns/import-map.json`.
|
|
9
|
+
*
|
|
10
|
+
* Returns the import map + runtime config consumed by ns:module `configureLoader()`
|
|
11
|
+
* on the device during cold boot. Extracted verbatim from
|
|
12
|
+
* `createHmrWebSocketPlugin`; the only injected dependency is the active
|
|
13
|
+
* framework strategy (for its `flavor`).
|
|
14
|
+
*/
|
|
15
|
+
export declare function registerImportMapRoute(server: ViteDevServer, options: RegisterImportMapRouteOptions): void;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { buildRuntimeConfig } from './import-map.js';
|
|
2
|
+
import { getServerOrigin } from './server-origin.js';
|
|
3
|
+
/**
|
|
4
|
+
* Registers the device import-map endpoint: `GET /ns/import-map.json`.
|
|
5
|
+
*
|
|
6
|
+
* Returns the import map + runtime config consumed by ns:module `configureLoader()`
|
|
7
|
+
* on the device during cold boot. Extracted verbatim from
|
|
8
|
+
* `createHmrWebSocketPlugin`; the only injected dependency is the active
|
|
9
|
+
* framework strategy (for its `flavor`).
|
|
10
|
+
*/
|
|
11
|
+
export function registerImportMapRoute(server, options) {
|
|
12
|
+
const { getStrategy } = options;
|
|
13
|
+
server.middlewares.use(async (req, res, next) => {
|
|
14
|
+
try {
|
|
15
|
+
const urlObj = new URL(req.url || '', 'http://localhost');
|
|
16
|
+
if (urlObj.pathname !== '/ns/import-map.json')
|
|
17
|
+
return next();
|
|
18
|
+
res.setHeader('Access-Control-Allow-Origin', '*');
|
|
19
|
+
res.setHeader('Access-Control-Allow-Methods', 'GET, OPTIONS');
|
|
20
|
+
if (req.method === 'OPTIONS') {
|
|
21
|
+
res.statusCode = 204;
|
|
22
|
+
res.end();
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
// Use the single trusted origin resolver (https-aware, validated, and
|
|
26
|
+
// byte-identical to the origin baked into bundle.mjs by dev-host.ts).
|
|
27
|
+
// Do NOT derive the origin from the client-supplied `Host` header: the
|
|
28
|
+
// dev server binds 0.0.0.0, so a spoofed Host would rewrite the origin
|
|
29
|
+
// of every device module URL.
|
|
30
|
+
const origin = getServerOrigin(server);
|
|
31
|
+
const strategy = getStrategy();
|
|
32
|
+
const runtimeConfig = buildRuntimeConfig({
|
|
33
|
+
origin,
|
|
34
|
+
flavor: strategy?.flavor || 'typescript',
|
|
35
|
+
strategy,
|
|
36
|
+
});
|
|
37
|
+
res.setHeader('Content-Type', 'application/json');
|
|
38
|
+
res.end(JSON.stringify({
|
|
39
|
+
importMap: JSON.parse(runtimeConfig.importMap),
|
|
40
|
+
volatilePatterns: runtimeConfig.volatilePatterns,
|
|
41
|
+
canonicalization: runtimeConfig.canonicalization,
|
|
42
|
+
}, null, 2));
|
|
43
|
+
}
|
|
44
|
+
catch (err) {
|
|
45
|
+
console.error('[import-map] error generating import map:', err?.message || err);
|
|
46
|
+
res.statusCode = 500;
|
|
47
|
+
res.end(JSON.stringify({ error: 'Failed to generate import map' }));
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=websocket-import-map-route.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"websocket-import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CAAC,CAAC;YAClD,GAAG,CAAC,GAAG,CACN,IAAI,CAAC,SAAS,CACb;gBACC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,SAAS,CAAC;gBAC9C,gBAAgB,EAAE,aAAa,CAAC,gBAAgB;gBAChD,gBAAgB,EAAE,aAAa,CAAC,gBAAgB;aAChD,EACD,IAAI,EACJ,CAAC,CACD,CACD,CAAC;QACH,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YACnB,OAAO,CAAC,KAAK,CAAC,2CAA2C,EAAE,GAAG,EAAE,OAAO,IAAI,GAAG,CAAC,CAAC;YAChF,GAAG,CAAC,UAAU,GAAG,GAAG,CAAC;YACrB,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,+BAA+B,EAAE,CAAC,CAAC,CAAC;QACrE,CAAC;IACF,CAAC,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface EnsureNativeScriptModuleBindingsOptions {
|
|
2
|
+
preserveNonPluginVendorImports?: boolean;
|
|
3
|
+
resolvedSpecifierOverrides?: Map<string, string>;
|
|
4
|
+
/**
|
|
5
|
+
* Rewrite vendor/plugin imports to their `/ns/m/node_modules/<pkg>` HTTP
|
|
6
|
+
* ESM form instead of the `__nsVendorRequire` registry shim.
|
|
7
|
+
*
|
|
8
|
+
* Worker realms need this: the vendor registry (`__nsVendorRegistry` /
|
|
9
|
+
* `__nsRequire`) is installed by the MAIN realm's dev-session bootstrap
|
|
10
|
+
* and never exists inside a `new Worker(...)` context, so the registry
|
|
11
|
+
* shim's fallback to the native `require()` fails for every vendor
|
|
12
|
+
* package (observed with `@nativescript/zip` in a zip worker on a fresh
|
|
13
|
+
* install — the first boot's DB unzip was the first code path to ever
|
|
14
|
+
* exercise a vendor require inside a worker). The HTTP form gives the
|
|
15
|
+
* worker its own realm-local copy via the deps-bundle bridge — the same
|
|
16
|
+
* isolation semantics webpack's per-worker bundles had.
|
|
17
|
+
*/
|
|
18
|
+
vendorImportsAsHttp?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export declare function ensureNativeScriptModuleBindings(code: string, options?: EnsureNativeScriptModuleBindingsOptions): string;
|
|
21
|
+
export declare function getProcessCodeResolvedSpecifierOverrides(sourceId: string | undefined, projectRoot: string): Map<string, string> | undefined;
|