@nativescript/vite 8.0.0-alpha.5 → 8.0.0-alpha.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -11
- package/bin/cli.cjs +8 -14
- package/configuration/angular.d.ts +34 -1
- package/configuration/angular.js +376 -165
- package/configuration/angular.js.map +1 -1
- package/configuration/base.js +241 -51
- package/configuration/base.js.map +1 -1
- package/configuration/javascript.js +14 -93
- package/configuration/javascript.js.map +1 -1
- package/configuration/react.js +41 -73
- package/configuration/react.js.map +1 -1
- package/configuration/solid.js +51 -6
- package/configuration/solid.js.map +1 -1
- package/configuration/typescript.js +12 -93
- package/configuration/typescript.js.map +1 -1
- package/helpers/app-components.d.ts +2 -1
- package/helpers/app-components.js.map +1 -1
- package/helpers/app-css-state.d.ts +8 -0
- package/helpers/app-css-state.js +8 -0
- package/helpers/app-css-state.js.map +1 -0
- package/helpers/bundler-context.d.ts +11 -0
- package/helpers/bundler-context.js +71 -0
- package/helpers/bundler-context.js.map +1 -0
- package/helpers/cli-flags.d.ts +12 -0
- package/helpers/cli-flags.js +34 -0
- package/helpers/cli-flags.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.js +1 -1
- package/helpers/dynamic-import-plugin.js.map +1 -1
- package/helpers/esbuild-platform-resolver.js +4 -1
- package/helpers/esbuild-platform-resolver.js.map +1 -1
- package/helpers/external-configs.d.ts +10 -12
- package/helpers/external-configs.js +58 -35
- package/helpers/external-configs.js.map +1 -1
- package/helpers/global-defines.d.ts +142 -0
- package/helpers/global-defines.js +213 -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/init.js +0 -18
- 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 +3 -1
- package/helpers/main-entry.js +301 -53
- package/helpers/main-entry.js.map +1 -1
- package/helpers/nativeclass-esbuild-plugin.d.ts +2 -1
- package/helpers/nativeclass-esbuild-plugin.js.map +1 -1
- package/helpers/nativeclass-transform.js +5 -6
- package/helpers/nativeclass-transform.js.map +1 -1
- package/helpers/nativeclass-transformer-plugin.d.ts +9 -2
- package/helpers/nativeclass-transformer-plugin.js +157 -14
- package/helpers/nativeclass-transformer-plugin.js.map +1 -1
- package/helpers/nativescript-package-resolver.js +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-url.d.ts +29 -7
- package/helpers/ns-core-url.js +69 -12
- package/helpers/ns-core-url.js.map +1 -1
- 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 +14 -0
- package/helpers/ts-config-paths.js +90 -9
- package/helpers/ts-config-paths.js.map +1 -1
- package/helpers/typescript-check.d.ts +2 -1
- package/helpers/typescript-check.js +2 -2
- 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/workers.d.ts +20 -19
- package/helpers/workers.js +624 -4
- package/helpers/workers.js.map +1 -1
- package/hmr/client/css-handler.d.ts +2 -1
- package/hmr/client/css-handler.js +50 -26
- 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 +79 -0
- package/hmr/client/framework-client-strategy.js +19 -0
- package/hmr/client/framework-client-strategy.js.map +1 -0
- package/hmr/client/hmr-pending-overlay.d.ts +13 -0
- package/hmr/client/hmr-pending-overlay.js +60 -0
- package/hmr/client/hmr-pending-overlay.js.map +1 -0
- package/hmr/client/index.js +891 -220
- package/hmr/client/index.js.map +1 -1
- package/hmr/client/utils.d.ts +7 -1
- package/hmr/client/utils.js +207 -29
- package/hmr/client/utils.js.map +1 -1
- package/hmr/entry-runtime.d.ts +2 -1
- package/hmr/entry-runtime.js +256 -69
- package/hmr/entry-runtime.js.map +1 -1
- package/hmr/frameworks/angular/build/angular-linker.d.ts +12 -0
- package/hmr/frameworks/angular/build/angular-linker.js +109 -0
- package/hmr/frameworks/angular/build/angular-linker.js.map +1 -0
- package/hmr/frameworks/angular/build/inject-component-hmr-registration.d.ts +112 -0
- package/hmr/frameworks/angular/build/inject-component-hmr-registration.js +291 -0
- package/hmr/frameworks/angular/build/inject-component-hmr-registration.js.map +1 -0
- package/hmr/frameworks/angular/build/inject-hmr-vite-ignore.d.ts +75 -0
- package/hmr/frameworks/angular/build/inject-hmr-vite-ignore.js +221 -0
- package/hmr/frameworks/angular/build/inject-hmr-vite-ignore.js.map +1 -0
- package/{helpers/angular → hmr/frameworks/angular/build}/inline-decorator-component-templates.js +1 -170
- package/hmr/frameworks/angular/build/inline-decorator-component-templates.js.map +1 -0
- package/hmr/frameworks/angular/build/js-lexer.d.ts +4 -0
- package/{helpers/angular/synthesize-decorator-ctor-parameters.js → hmr/frameworks/angular/build/js-lexer.js} +22 -96
- package/hmr/frameworks/angular/build/js-lexer.js.map +1 -0
- package/hmr/frameworks/angular/build/shared-linker.d.ts +39 -0
- package/hmr/frameworks/angular/build/shared-linker.js +128 -0
- package/hmr/frameworks/angular/build/shared-linker.js.map +1 -0
- package/hmr/frameworks/angular/build/synthesize-decorator-ctor-parameters.js +88 -0
- package/hmr/frameworks/angular/build/synthesize-decorator-ctor-parameters.js.map +1 -0
- package/{helpers/angular → hmr/frameworks/angular/build}/synthesize-injectable-factories.js +1 -174
- package/hmr/frameworks/angular/build/synthesize-injectable-factories.js.map +1 -0
- package/{helpers/angular → hmr/frameworks/angular/build}/util.d.ts +1 -0
- package/hmr/frameworks/angular/build/util.js +155 -0
- package/hmr/frameworks/angular/build/util.js.map +1 -0
- package/hmr/frameworks/angular/client/index.d.ts +1 -0
- package/hmr/frameworks/angular/client/index.js +859 -21
- package/hmr/frameworks/angular/client/index.js.map +1 -1
- package/hmr/frameworks/angular/client/strategy.d.ts +9 -0
- package/hmr/frameworks/angular/client/strategy.js +19 -0
- package/hmr/frameworks/angular/client/strategy.js.map +1 -0
- package/hmr/frameworks/angular/server/angular-root-component.d.ts +79 -0
- package/hmr/frameworks/angular/server/angular-root-component.js +149 -0
- package/hmr/frameworks/angular/server/angular-root-component.js.map +1 -0
- package/hmr/frameworks/angular/server/linker.js +1 -4
- package/hmr/frameworks/angular/server/linker.js.map +1 -1
- package/hmr/frameworks/angular/server/strategy.js +460 -12
- package/hmr/frameworks/angular/server/strategy.js.map +1 -1
- package/hmr/{server → frameworks/angular/server}/websocket-angular-entry.js +2 -2
- package/hmr/frameworks/angular/server/websocket-angular-entry.js.map +1 -0
- package/hmr/{server → frameworks/angular/server}/websocket-angular-hot-update.d.ts +17 -11
- package/hmr/frameworks/angular/server/websocket-angular-hot-update.js +336 -0
- package/hmr/frameworks/angular/server/websocket-angular-hot-update.js.map +1 -0
- package/hmr/frameworks/react/server/strategy.d.ts +2 -0
- package/hmr/frameworks/react/server/strategy.js +150 -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 +54 -0
- package/hmr/frameworks/solid/client/app-runtime.js +184 -0
- package/hmr/frameworks/solid/client/app-runtime.js.map +1 -0
- package/hmr/frameworks/solid/server/strategy.js +291 -16
- package/hmr/frameworks/solid/server/strategy.js.map +1 -1
- package/hmr/frameworks/typescript/server/strategy.js +38 -14
- package/hmr/frameworks/typescript/server/strategy.js.map +1 -1
- package/hmr/frameworks/vue/client/dep-propagation.d.ts +36 -0
- package/hmr/frameworks/vue/client/dep-propagation.js +101 -0
- package/hmr/frameworks/vue/client/dep-propagation.js.map +1 -0
- package/hmr/frameworks/vue/client/index.d.ts +8 -0
- package/hmr/frameworks/vue/client/index.js +56 -243
- package/hmr/frameworks/vue/client/index.js.map +1 -1
- package/hmr/frameworks/vue/client/strategy.d.ts +33 -0
- package/hmr/frameworks/vue/client/strategy.js +157 -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 +142 -0
- package/hmr/frameworks/vue/client/vue-sfc-update-overlay.js.map +1 -0
- package/hmr/frameworks/vue/server/sfc-route-assemble.d.ts +7 -0
- package/hmr/frameworks/vue/server/sfc-route-assemble.js +747 -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 +459 -0
- package/hmr/frameworks/vue/server/sfc-route-serve.js.map +1 -0
- package/hmr/frameworks/vue/server/sfc-route-shared.d.ts +38 -0
- package/hmr/frameworks/vue/server/sfc-route-shared.js +48 -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 +278 -1
- 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 +77 -10
- package/hmr/helpers/ast-normalizer.js.map +1 -1
- package/hmr/helpers/cjs-named-exports.d.ts +23 -0
- package/hmr/helpers/cjs-named-exports.js +152 -0
- package/hmr/helpers/cjs-named-exports.js.map +1 -0
- package/hmr/helpers/package-exports.d.ts +16 -0
- package/hmr/helpers/package-exports.js +396 -0
- package/hmr/helpers/package-exports.js.map +1 -0
- package/hmr/server/constants.js +20 -5
- package/hmr/server/constants.js.map +1 -1
- package/hmr/server/core-sanitize.d.ts +86 -7
- package/hmr/server/core-sanitize.js +170 -45
- package/hmr/server/core-sanitize.js.map +1 -1
- package/hmr/server/device-transform-helpers.d.ts +24 -0
- package/hmr/server/device-transform-helpers.js +408 -0
- package/hmr/server/device-transform-helpers.js.map +1 -0
- package/hmr/server/framework-strategy.d.ts +108 -11
- package/hmr/server/hmr-module-graph.d.ts +37 -0
- package/hmr/server/hmr-module-graph.js +214 -0
- package/hmr/server/hmr-module-graph.js.map +1 -0
- package/hmr/server/import-map.d.ts +11 -2
- package/hmr/server/import-map.js +92 -45
- package/hmr/server/import-map.js.map +1 -1
- package/hmr/server/index.js +7 -16
- package/hmr/server/index.js.map +1 -1
- package/hmr/server/ns-core-cjs-shape.d.ts +2 -4
- package/hmr/server/ns-core-cjs-shape.js +4 -6
- package/hmr/server/ns-core-cjs-shape.js.map +1 -1
- 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 +38 -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 +14 -0
- package/hmr/server/process-code-for-device.js +699 -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 +630 -0
- package/hmr/server/rewrite-imports.js.map +1 -0
- package/hmr/server/route-helpers.d.ts +7 -0
- package/hmr/server/route-helpers.js +13 -0
- package/hmr/server/route-helpers.js.map +1 -0
- package/hmr/server/server-origin.d.ts +2 -0
- package/hmr/server/server-origin.js +83 -0
- package/hmr/server/server-origin.js.map +1 -0
- package/hmr/server/shared-transform-request.js +13 -7
- package/hmr/server/shared-transform-request.js.map +1 -1
- 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.js +78 -42
- package/hmr/server/vite-plugin.js.map +1 -1
- package/hmr/server/websocket-core-bridge.d.ts +45 -4
- package/hmr/server/websocket-core-bridge.js +50 -48
- package/hmr/server/websocket-core-bridge.js.map +1 -1
- package/hmr/server/websocket-css-hot-update.d.ts +33 -0
- package/hmr/server/websocket-css-hot-update.js +65 -0
- package/hmr/server/websocket-css-hot-update.js.map +1 -0
- package/hmr/server/websocket-device-transform.d.ts +3 -0
- package/hmr/server/websocket-device-transform.js +7 -0
- package/hmr/server/websocket-device-transform.js.map +1 -0
- package/hmr/server/websocket-graph-upsert.d.ts +15 -0
- package/hmr/server/websocket-graph-upsert.js +20 -0
- package/hmr/server/websocket-graph-upsert.js.map +1 -1
- package/hmr/server/websocket-hmr-pending.d.ts +37 -0
- package/hmr/server/websocket-hmr-pending.js +55 -0
- package/hmr/server/websocket-hmr-pending.js.map +1 -0
- package/hmr/server/websocket-hot-update.d.ts +77 -0
- package/hmr/server/websocket-hot-update.js +360 -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 +50 -0
- package/hmr/server/websocket-import-map-route.js.map +1 -0
- package/hmr/server/websocket-module-bindings.js +3 -3
- package/hmr/server/websocket-module-bindings.js.map +1 -1
- package/hmr/server/websocket-module-specifiers.d.ts +66 -2
- package/hmr/server/websocket-module-specifiers.js +191 -20
- package/hmr/server/websocket-module-specifiers.js.map +1 -1
- package/hmr/server/websocket-ns-core.d.ts +21 -0
- package/hmr/server/websocket-ns-core.js +311 -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 +164 -0
- package/hmr/server/websocket-ns-entry.js.map +1 -0
- package/hmr/server/websocket-ns-m-paths.d.ts +1 -1
- package/hmr/server/websocket-ns-m-paths.js +58 -13
- package/hmr/server/websocket-ns-m-paths.js.map +1 -1
- package/hmr/server/websocket-ns-m-request.d.ts +11 -1
- package/hmr/server/websocket-ns-m-request.js +18 -25
- package/hmr/server/websocket-ns-m-request.js.map +1 -1
- package/hmr/server/websocket-ns-m.d.ts +33 -0
- package/hmr/server/websocket-ns-m.js +752 -0
- package/hmr/server/websocket-ns-m.js.map +1 -0
- package/hmr/server/websocket-served-module-helpers.d.ts +49 -3
- package/hmr/server/websocket-served-module-helpers.js +403 -87
- package/hmr/server/websocket-served-module-helpers.js.map +1 -1
- package/hmr/server/websocket-txn.js +2 -8
- package/hmr/server/websocket-txn.js.map +1 -1
- package/hmr/server/websocket-vendor-unifier.d.ts +0 -1
- package/hmr/server/websocket-vendor-unifier.js +4 -9
- package/hmr/server/websocket-vendor-unifier.js.map +1 -1
- package/hmr/server/websocket.d.ts +8 -39
- package/hmr/server/websocket.js +608 -6300
- package/hmr/server/websocket.js.map +1 -1
- package/hmr/shared/ns-globals.d.ts +118 -0
- package/hmr/shared/ns-globals.js +29 -0
- package/hmr/shared/ns-globals.js.map +1 -0
- package/hmr/shared/protocol.d.ts +145 -0
- package/hmr/shared/protocol.js +28 -0
- package/hmr/shared/protocol.js.map +1 -0
- package/hmr/shared/runtime/boot-placeholder-ui.d.ts +69 -0
- package/hmr/shared/runtime/boot-placeholder-ui.js +101 -0
- package/hmr/shared/runtime/boot-placeholder-ui.js.map +1 -0
- package/hmr/shared/runtime/boot-progress.d.ts +44 -0
- package/hmr/shared/runtime/boot-progress.js +133 -0
- package/hmr/shared/runtime/boot-progress.js.map +1 -0
- package/hmr/shared/runtime/boot-timeline.d.ts +18 -0
- package/hmr/shared/runtime/boot-timeline.js +42 -0
- package/hmr/shared/runtime/boot-timeline.js.map +1 -0
- package/hmr/shared/runtime/browser-runtime-contract.js.map +1 -1
- package/hmr/shared/runtime/dev-overlay-snapshots.d.ts +31 -0
- package/hmr/shared/runtime/dev-overlay-snapshots.js +324 -0
- package/hmr/shared/runtime/dev-overlay-snapshots.js.map +1 -0
- package/hmr/shared/runtime/dev-overlay.d.ts +119 -26
- package/hmr/shared/runtime/dev-overlay.js +1196 -262
- package/hmr/shared/runtime/dev-overlay.js.map +1 -1
- 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/http-only-boot.js +7 -6
- package/hmr/shared/runtime/http-only-boot.js.map +1 -1
- package/hmr/shared/runtime/module-provenance.js +4 -6
- package/hmr/shared/runtime/module-provenance.js.map +1 -1
- package/hmr/shared/runtime/root-placeholder-view.d.ts +19 -0
- package/hmr/shared/runtime/root-placeholder-view.js +311 -0
- package/hmr/shared/runtime/root-placeholder-view.js.map +1 -0
- package/hmr/shared/runtime/root-placeholder.js +393 -200
- package/hmr/shared/runtime/root-placeholder.js.map +1 -1
- package/hmr/shared/runtime/session-bootstrap.js +168 -4
- package/hmr/shared/runtime/session-bootstrap.js.map +1 -1
- package/hmr/shared/runtime/vendor-bootstrap.js +3 -10
- package/hmr/shared/runtime/vendor-bootstrap.js.map +1 -1
- package/hmr/shared/vendor/manifest-collect.d.ts +4 -0
- package/hmr/shared/vendor/manifest-collect.js +549 -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 +1 -7
- package/hmr/shared/vendor/manifest.js +84 -819
- package/hmr/shared/vendor/manifest.js.map +1 -1
- package/hmr/shared/vendor/vendor-device-shim.d.ts +1 -0
- package/hmr/shared/vendor/vendor-device-shim.js +208 -0
- package/hmr/shared/vendor/vendor-device-shim.js.map +1 -0
- package/hmr/shared/vendor/vendor-esbuild-plugins.d.ts +38 -0
- package/hmr/shared/vendor/vendor-esbuild-plugins.js +296 -0
- package/hmr/shared/vendor/vendor-esbuild-plugins.js.map +1 -0
- package/hmr/vendor-bootstrap.d.ts +1 -3
- package/hmr/vendor-bootstrap.js +4 -6
- package/hmr/vendor-bootstrap.js.map +1 -1
- package/index.d.ts +1 -0
- package/index.js +5 -0
- package/index.js.map +1 -1
- package/package.json +61 -11
- package/runtime/core-aliases-early.js +25 -55
- package/runtime/core-aliases-early.js.map +1 -1
- package/shims/react-jsx-runtime.d.ts +4 -0
- package/shims/react-jsx-runtime.js +37 -0
- package/shims/react-jsx-runtime.js.map +1 -0
- package/helpers/angular/angular-linker.d.ts +0 -13
- package/helpers/angular/angular-linker.js +0 -194
- package/helpers/angular/angular-linker.js.map +0 -1
- package/helpers/angular/inline-decorator-component-templates.js.map +0 -1
- package/helpers/angular/shared-linker.d.ts +0 -11
- package/helpers/angular/shared-linker.js +0 -75
- package/helpers/angular/shared-linker.js.map +0 -1
- package/helpers/angular/synthesize-decorator-ctor-parameters.js.map +0 -1
- package/helpers/angular/synthesize-injectable-factories.js.map +0 -1
- package/helpers/angular/util.js +0 -67
- package/helpers/angular/util.js.map +0 -1
- package/helpers/prelink-angular.d.ts +0 -2
- package/helpers/prelink-angular.js +0 -117
- package/helpers/prelink-angular.js.map +0 -1
- package/hmr/server/websocket-angular-entry.js.map +0 -1
- package/hmr/server/websocket-angular-hot-update.js +0 -239
- package/hmr/server/websocket-angular-hot-update.js.map +0 -1
- package/hmr/server/websocket-ns-m-finalize.d.ts +0 -22
- package/hmr/server/websocket-ns-m-finalize.js +0 -88
- package/hmr/server/websocket-ns-m-finalize.js.map +0 -1
- package/hmr/server/websocket-runtime-compat.d.ts +0 -19
- package/hmr/server/websocket-runtime-compat.js +0 -286
- package/hmr/server/websocket-runtime-compat.js.map +0 -1
- package/hmr/server/websocket-vue-sfc.d.ts +0 -27
- package/hmr/server/websocket-vue-sfc.js +0 -1117
- package/hmr/server/websocket-vue-sfc.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
- /package/{helpers/angular → hmr/frameworks/angular/build}/inline-decorator-component-templates.d.ts +0 -0
- /package/{helpers/angular → hmr/frameworks/angular/build}/synthesize-decorator-ctor-parameters.d.ts +0 -0
- /package/{helpers/angular → hmr/frameworks/angular/build}/synthesize-injectable-factories.d.ts +0 -0
- /package/hmr/{server → frameworks/angular/server}/websocket-angular-entry.d.ts +0 -0
|
@@ -1,9 +1,99 @@
|
|
|
1
1
|
import { parse as babelParse } from '@babel/parser';
|
|
2
2
|
import * as t from '@babel/types';
|
|
3
|
+
import { existsSync, readFileSync } from 'fs';
|
|
4
|
+
import * as path from 'path';
|
|
3
5
|
import * as PAT from './constants.js';
|
|
4
6
|
import { isDeepCoreSubpath } from './core-sanitize.js';
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
+
import { getCjsNamedExports } from '../helpers/cjs-named-exports.js';
|
|
8
|
+
import { getMonorepoWorkspaceRoot } from '../../helpers/project.js';
|
|
9
|
+
import { extractDirectExportedNames, parseExportSpecList } from './websocket-core-bridge.js';
|
|
10
|
+
import { resolveCandidateFilePath } from './websocket-module-specifiers.js';
|
|
11
|
+
let cachedWorkspaceCoreRoot;
|
|
12
|
+
/**
|
|
13
|
+
* Absolute root of @nativescript/core when it is consumed from monorepo
|
|
14
|
+
* source (`<workspace>/packages/core` in the NativeScript repo) rather than
|
|
15
|
+
* node_modules. Returns null for standalone apps.
|
|
16
|
+
*/
|
|
17
|
+
export function getWorkspaceCoreSourceRoot() {
|
|
18
|
+
if (cachedWorkspaceCoreRoot !== undefined)
|
|
19
|
+
return cachedWorkspaceCoreRoot;
|
|
20
|
+
cachedWorkspaceCoreRoot = null;
|
|
21
|
+
try {
|
|
22
|
+
const wsRoot = getMonorepoWorkspaceRoot();
|
|
23
|
+
if (wsRoot) {
|
|
24
|
+
const pkgPath = path.join(wsRoot, 'packages/core/package.json');
|
|
25
|
+
if (existsSync(pkgPath)) {
|
|
26
|
+
const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));
|
|
27
|
+
if (pkg?.name === '@nativescript/core') {
|
|
28
|
+
cachedWorkspaceCoreRoot = path.resolve(wsRoot, 'packages/core').replace(/\\/g, '/');
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
catch { }
|
|
34
|
+
return cachedWorkspaceCoreRoot;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* True when a served module path points into @nativescript/core consumed from
|
|
38
|
+
* monorepo source. These modules are library code: the app-source HMR passes
|
|
39
|
+
* (AST normalization, /ns/rt underscore-helper alias injection) must NOT run
|
|
40
|
+
* on them — they exist for compiled app/SFC output, and on core sources they
|
|
41
|
+
* misread internals (e.g. `ClassInfo._getBase`) as Vue template helpers and
|
|
42
|
+
* inject destructures that shadow real bindings or TDZ-crash on the circular
|
|
43
|
+
* /ns/rt dependency. In standalone apps core lives under node_modules and is
|
|
44
|
+
* already excluded by the node_modules check.
|
|
45
|
+
*/
|
|
46
|
+
export function isWorkspaceCoreModulePath(p) {
|
|
47
|
+
if (!p)
|
|
48
|
+
return false;
|
|
49
|
+
const coreRoot = getWorkspaceCoreSourceRoot();
|
|
50
|
+
if (!coreRoot)
|
|
51
|
+
return false;
|
|
52
|
+
const normalized = String(p).split('?')[0].replace(/\\/g, '/');
|
|
53
|
+
return normalized.includes(coreRoot + '/') || /(^|\/)packages\/core\//.test(normalized);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* True when a served module path points into the @nativescript/vite package
|
|
57
|
+
* routed via its monorepo build output (`dist/packages/vite/...`). Apps that
|
|
58
|
+
* consume the package via `file:../../dist/packages/vite` get a node_modules
|
|
59
|
+
* SYMLINK, and require.resolve follows it to the real dist path — so the
|
|
60
|
+
* served URL carries no `node_modules/` segment and escapes the node_modules
|
|
61
|
+
* library check. Like core source, this is library code: the app-source HMR
|
|
62
|
+
* passes (AST normalization, /ns/rt alias injection) must not run on it —
|
|
63
|
+
* e.g. the HMR client bundle already carries its own `__ns_rt_ns_re` import,
|
|
64
|
+
* and a second injected one is a duplicate-declaration SyntaxError on device.
|
|
65
|
+
*/
|
|
66
|
+
export function isWorkspaceVitePackageModulePath(p) {
|
|
67
|
+
if (!p)
|
|
68
|
+
return false;
|
|
69
|
+
const normalized = String(p).split('?')[0].replace(/\\/g, '/');
|
|
70
|
+
return /(^|\/)dist\/packages\/vite\//.test(normalized);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Single classification point for the /ns/m served-module pipeline. The
|
|
74
|
+
* app-source passes inside processCodeForDevice (AST normalization, /ns/rt
|
|
75
|
+
* underscore-helper alias injection) must run ONLY on 'app' modules; 'library'
|
|
76
|
+
* code is served as-is plus import rewriting. Three things count as library:
|
|
77
|
+
* - anything under node_modules
|
|
78
|
+
* - @nativescript/core consumed from monorepo source (packages/core)
|
|
79
|
+
* - the @nativescript/vite package served from its dist build output
|
|
80
|
+
* (file:../../dist/packages/vite symlinks resolve to the real dist path,
|
|
81
|
+
* so no node_modules segment appears in the URL)
|
|
82
|
+
* Add the next workspace-library case HERE, not at a call site.
|
|
83
|
+
*/
|
|
84
|
+
export function classifyServedModule(p) {
|
|
85
|
+
if (!p)
|
|
86
|
+
return 'app';
|
|
87
|
+
const normalized = String(p).split('?')[0].replace(/\\/g, '/');
|
|
88
|
+
if (/(?:^|\/)node_modules\//.test(normalized))
|
|
89
|
+
return 'library';
|
|
90
|
+
if (isWorkspaceCoreModulePath(normalized))
|
|
91
|
+
return 'library';
|
|
92
|
+
if (isWorkspaceVitePackageModulePath(normalized))
|
|
93
|
+
return 'library';
|
|
94
|
+
return 'app';
|
|
95
|
+
}
|
|
96
|
+
export const MODULE_IMPORT_ANALYSIS_PLUGINS = ['typescript', 'jsx', 'importMeta', 'topLevelAwait', 'classProperties', 'classPrivateProperties', 'classPrivateMethods', 'decorators-legacy'];
|
|
7
97
|
export function collectTopLevelImportRecords(code) {
|
|
8
98
|
if (!code || typeof code !== 'string' || !/\bimport\b/.test(code)) {
|
|
9
99
|
return [];
|
|
@@ -63,14 +153,27 @@ export function hoistTopLevelStaticImports(code) {
|
|
|
63
153
|
}
|
|
64
154
|
return `${hoisted.join('\n')}\n${stripped.replace(/^\s*\n+/, '')}`;
|
|
65
155
|
}
|
|
156
|
+
// Boot-progress instrumentation snippet (server-side string-only).
|
|
157
|
+
//
|
|
158
|
+
// Injected at the top of every `__ns_boot__/b1`-tagged module the dev
|
|
159
|
+
// server serves during cold boot. The snippet is FULLY SYNCHRONOUS —
|
|
160
|
+
// even one conditional top-level `await` would mark the module async
|
|
161
|
+
// in V8, propagating an async-promise chain through the entire boot
|
|
162
|
+
// graph and tripping the iOS 10 s top-level-await deadline (see
|
|
163
|
+
// `ModuleInternal.mm::pumpAsyncProgress`). It just bumps the
|
|
164
|
+
// `__NS_HMR_BOOT_MODULE_COUNT__` / `__NS_HMR_BOOT_LAST_MODULE__`
|
|
165
|
+
// globals; the 250 ms heartbeat in `session-bootstrap.ts` owns
|
|
166
|
+
// `setBootStage` and runs `boot-progress.ts::computeBootImportProgress`
|
|
167
|
+
// against those counters plus elapsed wall-clock to drive the bar.
|
|
168
|
+
// The iOS runtime's `MaybePumpJSThreadDuringBoot` keeps the JS-thread
|
|
169
|
+
// CFRunLoop ticking between sync fetches so the heartbeat can fire
|
|
170
|
+
// during the otherwise-blocking cold-boot module walk.
|
|
171
|
+
//
|
|
172
|
+
// Regression-tested by `websocket-integrity.spec.ts` (snippet stays
|
|
173
|
+
// fully synchronous + propagates exactly via the boot-tag prefix).
|
|
66
174
|
export function buildBootProgressSnippet(bootModuleLabel) {
|
|
67
175
|
const normalizedLabel = JSON.stringify(String(bootModuleLabel || '').replace(/\\/g, '/'));
|
|
68
|
-
return [
|
|
69
|
-
`const __nsBootGlobal=globalThis;`,
|
|
70
|
-
`try{if(!__nsBootGlobal.__NS_HMR_BOOT_COMPLETE__){const __nsBootApi=__nsBootGlobal.__NS_HMR_DEV_OVERLAY__;if(__nsBootApi&&typeof __nsBootApi.setBootStage==='function'){const __nsBootCount=(__nsBootGlobal.__NS_HMR_BOOT_MODULE_COUNT__=Number(__nsBootGlobal.__NS_HMR_BOOT_MODULE_COUNT__||0)+1);__nsBootGlobal.__NS_HMR_BOOT_LAST_MODULE__=${normalizedLabel};const __nsBootNow=Date.now();const __nsBootLast=Number(__nsBootGlobal.__NS_HMR_BOOT_LAST_PROGRESS_AT__||0);if(__nsBootCount<=8||__nsBootCount%6===0||__nsBootNow-__nsBootLast>90){__nsBootGlobal.__NS_HMR_BOOT_LAST_PROGRESS_AT__=__nsBootNow;const __nsBootProgress=Math.min(94,82+Math.min(10,Math.round((Math.log(__nsBootCount+1)/Math.LN2)*2)));__nsBootApi.setBootStage('importing-main',{detail:'Evaluated '+__nsBootCount+' modules\\n'+__nsBootGlobal.__NS_HMR_BOOT_LAST_MODULE__,attempt:Number(__nsBootGlobal.__NS_HMR_BOOT_MAIN_ATTEMPT__||1),attempts:Number(__nsBootGlobal.__NS_HMR_BOOT_MAIN_ATTEMPTS__||6),progress:__nsBootProgress});}}}}catch(__nsBootErr){}`,
|
|
71
|
-
`if(!__nsBootGlobal.__NS_HMR_BOOT_COMPLETE__){const __nsBootCount=Number(__nsBootGlobal.__NS_HMR_BOOT_MODULE_COUNT__||0);if(__nsBootCount<=24||__nsBootCount%8===0){await new Promise((resolve)=>setTimeout(resolve,0));}}`,
|
|
72
|
-
'',
|
|
73
|
-
].join('\n');
|
|
176
|
+
return [`const __nsBootGlobal=globalThis;`, `try{if(!__nsBootGlobal.__NS_HMR_BOOT_COMPLETE__){__nsBootGlobal.__NS_HMR_BOOT_MODULE_COUNT__=Number(__nsBootGlobal.__NS_HMR_BOOT_MODULE_COUNT__||0)+1;__nsBootGlobal.__NS_HMR_BOOT_LAST_MODULE__=${normalizedLabel};}}catch(__nsBootErr){}`, ''].join('\n');
|
|
74
177
|
}
|
|
75
178
|
export function stripCoreGlobalsImports(code) {
|
|
76
179
|
const pattern = /^\s*(?:import\s+(?:[^'"\n]*from\s+)?|export\s+\*\s+from\s+)["'][^"']*(?:@nativescript(?:[/_-])core(?:[\/_-])globals|@nativescript_core_globals)[^"']*["'];?\s*$/gm;
|
|
@@ -99,7 +202,7 @@ export function ensureVariableDynamicImportHelper(code) {
|
|
|
99
202
|
`};\n`;
|
|
100
203
|
return `${helper}${code}`;
|
|
101
204
|
}
|
|
102
|
-
export function ensureGuardPlainDynamicImports(code
|
|
205
|
+
export function ensureGuardPlainDynamicImports(code) {
|
|
103
206
|
try {
|
|
104
207
|
if (!code || !/\bimport\s*\(/.test(code))
|
|
105
208
|
return code;
|
|
@@ -114,6 +217,41 @@ export function ensureGuardPlainDynamicImports(code, _origin) {
|
|
|
114
217
|
return code;
|
|
115
218
|
}
|
|
116
219
|
}
|
|
220
|
+
// Stable URL helper for dynamic imports.
|
|
221
|
+
//
|
|
222
|
+
// Older versions of the helper synthesized
|
|
223
|
+
// `/ns/m/__ns_hmr__/<tag>/<rest>` URLs from
|
|
224
|
+
// `globalThis.__NS_HMR_GRAPH_VERSION__` and an importer-derived tag.
|
|
225
|
+
// That tag flowed straight into V8's `g_moduleRegistry` cache key — so
|
|
226
|
+
// a `graphVersion` bump on every save effectively flushed the whole
|
|
227
|
+
// module graph (HMR latency was dominated by Vite re-transforming the
|
|
228
|
+
// unchanged closure on every save).
|
|
229
|
+
//
|
|
230
|
+
// The current contract inverts that:
|
|
231
|
+
// * The runtime canonicalizes any URL shape (boot prefix, hmr prefix,
|
|
232
|
+
// stable) to a single key via `CanonicalizeHttpUrlKey`.
|
|
233
|
+
// * The Angular client receives an explicit eviction set in
|
|
234
|
+
// `ns:angular-update` and calls `__nsInvalidateModules` before
|
|
235
|
+
// re-importing the entry, so V8 only refetches modules that
|
|
236
|
+
// actually changed.
|
|
237
|
+
// * The dynamic-import helper no longer needs to busy-construct
|
|
238
|
+
// versioned URLs. Boot prefix preservation still matters at COLD
|
|
239
|
+
// boot because the server-side handler routes `/__ns_boot__/b1/`
|
|
240
|
+
// paths to the boot-progress instrumentation snippet — but the
|
|
241
|
+
// prefix is read from `import.meta.url`, never synthesized from
|
|
242
|
+
// `__NS_HMR_GRAPH_VERSION__`.
|
|
243
|
+
//
|
|
244
|
+
// The helper is intentionally tiny:
|
|
245
|
+
// 1. `@` and falsy specs route to `/ns/m/__invalid_at__.mjs` (existing
|
|
246
|
+
// defensive sentinel for misencoded imports).
|
|
247
|
+
// 2. `/ns/m/...` specs that don't yet have a boot prefix get one
|
|
248
|
+
// added when the caller is itself a boot-tagged module. This
|
|
249
|
+
// keeps the boot-progress instrumentation flowing through the
|
|
250
|
+
// transitive cold-boot graph during cold-boot sequences. Once HMR
|
|
251
|
+
// takes over (`__NS_HMR_BOOT_COMPLETE__` is set on the global), no
|
|
252
|
+
// prefix is added — the runtime canonicalizer collapses any
|
|
253
|
+
// historical prefix to the same key.
|
|
254
|
+
// 3. Everything else is a pass-through `import(spec)`.
|
|
117
255
|
export function ensureDynamicHmrImportHelper(code) {
|
|
118
256
|
try {
|
|
119
257
|
if (!code.includes('__nsDynamicHmrImport('))
|
|
@@ -122,26 +260,16 @@ export function ensureDynamicHmrImportHelper(code) {
|
|
|
122
260
|
return code;
|
|
123
261
|
const helper = 'const __nsDynamicHmrImport = (spec) => {\n' +
|
|
124
262
|
" const __nsm = '/ns' + '/m';\n" +
|
|
125
|
-
" const __nsBootPrefix = typeof import.meta !== 'undefined' && import.meta && typeof import.meta.url === 'string' && import.meta.url.includes('/__ns_boot__/b1/') ? '/__ns_boot__/b1' : '';\n" +
|
|
126
|
-
" const __nsImporterTagMatch = typeof import.meta !== 'undefined' && import.meta && typeof import.meta.url === 'string' ? import.meta.url.match(/\\/__ns_hmr__\\/([^/]+)\\//) : null;\n" +
|
|
127
|
-
" const __nsImporterTag = __nsImporterTagMatch && __nsImporterTagMatch[1] ? decodeURIComponent(__nsImporterTagMatch[1]) : '';\n" +
|
|
128
263
|
" try { if (!spec || spec === '@') { return import(new URL(__nsm + '/__invalid_at__.mjs', import.meta.url).href); } } catch {}\n" +
|
|
129
264
|
' try {\n' +
|
|
130
|
-
" if (typeof spec
|
|
131
|
-
'
|
|
132
|
-
"
|
|
133
|
-
"
|
|
134
|
-
"
|
|
135
|
-
"
|
|
136
|
-
"
|
|
137
|
-
'
|
|
138
|
-
' }\n' +
|
|
139
|
-
" if (spec.startsWith(__nsm + '/node_modules/')) { return import(new URL(spec, import.meta.url).href); }\n" +
|
|
140
|
-
" const tag = nonce ? `n${nonce}` : (graphVersion ? `v${graphVersion}` : (__nsImporterTag || 'live'));\n" +
|
|
141
|
-
" const nextPath = __nsm + __nsActiveBootPrefix + '/__ns_hmr__/' + encodeURIComponent(tag) + spec.slice(__nsm.length);\n" +
|
|
142
|
-
" const origin = typeof g.__NS_HTTP_ORIGIN__ === 'string' && /^https?:\\/\\//.test(g.__NS_HTTP_ORIGIN__) ? g.__NS_HTTP_ORIGIN__ : '';\n" +
|
|
143
|
-
' return import(origin ? origin + nextPath : new URL(nextPath, import.meta.url).href);\n' +
|
|
144
|
-
' }\n' +
|
|
265
|
+
" if (typeof spec !== 'string' || !spec.startsWith(__nsm + '/')) return import(spec);\n" +
|
|
266
|
+
' const g = globalThis;\n' +
|
|
267
|
+
" const inBoot = !g.__NS_HMR_BOOT_COMPLETE__ && typeof import.meta !== 'undefined' && import.meta && typeof import.meta.url === 'string' && import.meta.url.includes('/__ns_boot__/b1/');\n" +
|
|
268
|
+
" const noBootPrefixYet = !spec.startsWith(__nsm + '/__ns_boot__/');\n" +
|
|
269
|
+
" const isAppModule = !spec.startsWith(__nsm + '/node_modules/');\n" +
|
|
270
|
+
" const finalSpec = inBoot && noBootPrefixYet && isAppModule ? __nsm + '/__ns_boot__/b1' + spec.slice(__nsm.length) : spec;\n" +
|
|
271
|
+
" const origin = typeof g.__NS_HTTP_ORIGIN__ === 'string' && /^https?:\\/\\//.test(g.__NS_HTTP_ORIGIN__) ? g.__NS_HTTP_ORIGIN__ : '';\n" +
|
|
272
|
+
' return import(origin ? origin + finalSpec : new URL(finalSpec, import.meta.url).href);\n' +
|
|
145
273
|
' } catch {}\n' +
|
|
146
274
|
' return import(spec);\n' +
|
|
147
275
|
'};\n';
|
|
@@ -151,40 +279,198 @@ export function ensureDynamicHmrImportHelper(code) {
|
|
|
151
279
|
return code;
|
|
152
280
|
}
|
|
153
281
|
}
|
|
154
|
-
|
|
155
|
-
|
|
282
|
+
/**
|
|
283
|
+
* Star-export expansion must be TRANSITIVE.
|
|
284
|
+
*
|
|
285
|
+
* The expansion below replaces `export * from "url"` with an explicit named
|
|
286
|
+
* list, so any name missing from that list is silently dropped from the
|
|
287
|
+
* importer's export surface — the device then fails at link time with
|
|
288
|
+
* "does not provide an export named '<name>'". Real packages routinely chain
|
|
289
|
+
* star re-exports (`index.ios.js → export * from './canvas'` →
|
|
290
|
+
* `canvas.ios.js → export * from './canvas.common'`), so the name set for a
|
|
291
|
+
* star target is the union of its direct exports, its named re-exports, and
|
|
292
|
+
* — recursively — every nested `export * from` chain, cycles included.
|
|
293
|
+
*
|
|
294
|
+
* This mirrors `collectStaticExportOriginsFromFile` in
|
|
295
|
+
* `websocket-core-bridge.ts`, which solved the identical problem for the
|
|
296
|
+
* /ns/core bridge (see its `Application` comment). That walker reads files
|
|
297
|
+
* from disk; this one works on Vite-transformed code via the shared
|
|
298
|
+
* transformer, because star targets here are served URLs (aliases, /@fs
|
|
299
|
+
* paths, platform-extension resolution already applied by Vite's resolver).
|
|
300
|
+
* If you change export-name semantics in one walker, check the other.
|
|
301
|
+
*/
|
|
302
|
+
const STAR_EXPANSION_MAX_DEPTH = 64;
|
|
303
|
+
/**
|
|
304
|
+
* Normalize a star-export target (served URL or nested transformed
|
|
305
|
+
* specifier) into a root-relative path feedable to Vite's transform
|
|
306
|
+
* pipeline. Returns null for specifiers that cannot be walked (bare ids,
|
|
307
|
+
* relative specs with no parent context).
|
|
308
|
+
*/
|
|
309
|
+
function normalizeStarExportTargetPath(spec, parentVitePath) {
|
|
310
|
+
let p = String(spec || '').trim();
|
|
311
|
+
if (!p)
|
|
312
|
+
return null;
|
|
313
|
+
p = p.replace(/^https?:\/\/[^/]+/, '');
|
|
314
|
+
p = p.replace(/[?#].*$/, '');
|
|
315
|
+
p = p.replace(/^\/ns\/m\//, '/');
|
|
316
|
+
p = p.replace(/^\/__ns_boot__\/[^/]+/, '');
|
|
317
|
+
p = p.replace(/\/__ns_hmr__\/[^/]+/, '');
|
|
318
|
+
if (p.startsWith('.')) {
|
|
319
|
+
// Vite's import analysis normally rewrites nested specifiers to
|
|
320
|
+
// root-relative URLs; resolve any relative stragglers against the
|
|
321
|
+
// parent module's directory.
|
|
322
|
+
const parent = String(parentVitePath || '')
|
|
323
|
+
.replace(/\\/g, '/')
|
|
324
|
+
.replace(/[?#].*$/, '');
|
|
325
|
+
if (!parent.startsWith('/'))
|
|
326
|
+
return null;
|
|
327
|
+
p = path.posix.normalize(path.posix.join(path.posix.dirname(parent), p));
|
|
328
|
+
}
|
|
329
|
+
return p.startsWith('/') ? p : null;
|
|
330
|
+
}
|
|
331
|
+
function scanModuleExportSurface(code) {
|
|
332
|
+
const ownNames = new Set(extractDirectExportedNames(code));
|
|
333
|
+
for (const m of code.matchAll(/\bexport\s+\*\s+as\s+([A-Za-z_$][\w$]*)\s+from\s*["'][^"']+["']/g)) {
|
|
334
|
+
ownNames.add(m[1]);
|
|
335
|
+
}
|
|
336
|
+
for (const m of code.matchAll(/\bexport\s*\{([^}]+)\}\s*from\s*["'][^"']+["']/g)) {
|
|
337
|
+
for (const { exportedName } of parseExportSpecList(m[1])) {
|
|
338
|
+
ownNames.add(exportedName);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
const starSources = [];
|
|
342
|
+
// Tolerate trailing comments/code on the line (see the identical fix in
|
|
343
|
+
// websocket-core-bridge.ts: a strict `$` anchor silently skipped
|
|
344
|
+
// `export * from './layouts'; // barrel export` lines).
|
|
345
|
+
for (const m of code.matchAll(/^[ \t]*export\s+\*\s+from\s+["']([^"']+)["'][^\n]*$/gm)) {
|
|
346
|
+
starSources.push(m[1]);
|
|
347
|
+
}
|
|
348
|
+
return { ownNames, starSources };
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Recursively collect the full export-name set of a star-export target,
|
|
352
|
+
* following nested `export * from` chains. Cycle-safe via the DFS `stack`
|
|
353
|
+
* set (a revisited module contributes nothing new at that point — its names
|
|
354
|
+
* are already being collected by the outer visit, matching spec
|
|
355
|
+
* GetExportedNames semantics). Returns null when the target itself cannot
|
|
356
|
+
* be transformed; partial failures deeper in the chain are reported through
|
|
357
|
+
* `diagnostics` while still returning every name that could be collected.
|
|
358
|
+
*/
|
|
359
|
+
async function collectStarTargetExportNames(vitePath, transformer, stack, depth, diagnostics) {
|
|
360
|
+
if (stack.has(vitePath))
|
|
361
|
+
return new Set();
|
|
362
|
+
if (depth > STAR_EXPANSION_MAX_DEPTH) {
|
|
363
|
+
diagnostics.push(`star-export chain deeper than ${STAR_EXPANSION_MAX_DEPTH} at ${vitePath}`);
|
|
364
|
+
return null;
|
|
365
|
+
}
|
|
366
|
+
let targetCode;
|
|
367
|
+
try {
|
|
368
|
+
targetCode = (await transformer(vitePath))?.code ?? undefined;
|
|
369
|
+
}
|
|
370
|
+
catch { }
|
|
371
|
+
if (!targetCode) {
|
|
372
|
+
diagnostics.push(`unresolvable star-export target ${vitePath}`);
|
|
373
|
+
return null;
|
|
374
|
+
}
|
|
375
|
+
const surface = scanModuleExportSurface(targetCode);
|
|
376
|
+
const names = new Set(surface.ownNames);
|
|
377
|
+
stack.add(vitePath);
|
|
378
|
+
try {
|
|
379
|
+
for (const spec of surface.starSources) {
|
|
380
|
+
const childPath = normalizeStarExportTargetPath(spec, vitePath);
|
|
381
|
+
if (!childPath) {
|
|
382
|
+
diagnostics.push(`unwalkable nested star-export specifier ${JSON.stringify(spec)} in ${vitePath}`);
|
|
383
|
+
continue;
|
|
384
|
+
}
|
|
385
|
+
const childNames = await collectStarTargetExportNames(childPath, transformer, stack, depth + 1, diagnostics);
|
|
386
|
+
if (!childNames)
|
|
387
|
+
continue;
|
|
388
|
+
for (const n of childNames)
|
|
389
|
+
names.add(n);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
finally {
|
|
393
|
+
stack.delete(vitePath);
|
|
394
|
+
}
|
|
395
|
+
// `export *` never re-exports default.
|
|
396
|
+
names.delete('default');
|
|
397
|
+
return names;
|
|
156
398
|
}
|
|
157
|
-
export async function expandStarExports(code, server,
|
|
158
|
-
const STAR_RE = /^[ \t]*
|
|
399
|
+
export async function expandStarExports(code, server, projectRoot, verbose, sharedTransformer, importerId) {
|
|
400
|
+
const STAR_RE = /^[ \t]*export\s+\*\s+from\s+["']([^"']+)["'];?(?=[ \t]*(?:\/\/[^\n]*)?$)/gm;
|
|
159
401
|
let match;
|
|
160
402
|
const replacements = [];
|
|
161
403
|
while ((match = STAR_RE.exec(code)) !== null) {
|
|
162
|
-
const url = match[
|
|
404
|
+
const url = match[1];
|
|
163
405
|
if (!url.includes('/node_modules/'))
|
|
164
406
|
continue;
|
|
165
|
-
replacements.push({ full: match[0], url
|
|
407
|
+
replacements.push({ full: match[0], url });
|
|
166
408
|
}
|
|
167
409
|
if (!replacements.length)
|
|
168
410
|
return code;
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
411
|
+
// Names already exported lexically by the importing module. Per spec,
|
|
412
|
+
// lexical exports shadow star-exported names — re-emitting them in an
|
|
413
|
+
// explicit list would be a duplicate-export SyntaxError on device.
|
|
414
|
+
const claimed = new Set(scanModuleExportSurface(code).ownNames);
|
|
415
|
+
// Resolve each star-export target in parallel through the shared runner
|
|
416
|
+
// (when provided) so they share the /ns/m TTL cache and concurrency gate.
|
|
417
|
+
const baseTransformer = sharedTransformer ?? ((url) => server.transformRequest(url));
|
|
418
|
+
// A bare `/node_modules/<pkg>/...` URL is NOT transformable on its own:
|
|
419
|
+
// Vite's bare-specifier resolver is gated by the package's
|
|
420
|
+
// `package.json#exports` and refuses internal sub-paths even when the file
|
|
421
|
+
// is on disk (e.g. `css-tree/lib/version.js`, `css-what/dist/esm/types.js`),
|
|
422
|
+
// and in a monorepo the package is hoisted ABOVE the app's `root` so the
|
|
423
|
+
// path doesn't exist relative to it at all. Either way the transform
|
|
424
|
+
// returns nothing and the star target is mis-reported as "unresolvable",
|
|
425
|
+
// silently dropping its names from the importer's export surface. Mirror the
|
|
426
|
+
// main /ns/m route (`filterExistingNodeModulesTransformCandidates`): resolve
|
|
427
|
+
// the path to a concrete file under the project or workspace root and feed
|
|
428
|
+
// the `/@fs/<abs>` form to Vite, which bypasses the `exports` gate. Falls
|
|
429
|
+
// back to the raw URL for anything that doesn't resolve to a real file.
|
|
430
|
+
const workspaceRoot = projectRoot ? getMonorepoWorkspaceRoot(projectRoot) : null;
|
|
431
|
+
const transformer = (url) => {
|
|
432
|
+
if (projectRoot && url.includes('/node_modules/')) {
|
|
433
|
+
const abs = resolveCandidateFilePath(url, projectRoot, workspaceRoot);
|
|
434
|
+
if (abs) {
|
|
435
|
+
// Posix-normalize and guarantee a leading slash so Windows drive
|
|
436
|
+
// letters produce the `/@fs/C:/...` form Vite expects.
|
|
437
|
+
const absPosix = abs.replace(/\\/g, '/');
|
|
438
|
+
return baseTransformer(`/@fs${absPosix.startsWith('/') ? '' : '/'}${absPosix}`);
|
|
185
439
|
}
|
|
186
440
|
}
|
|
187
|
-
|
|
441
|
+
return baseTransformer(url);
|
|
442
|
+
};
|
|
443
|
+
const resolved = await Promise.all(replacements.map(async (rep) => {
|
|
444
|
+
const diagnostics = [];
|
|
445
|
+
const vitePath = normalizeStarExportTargetPath(rep.url, null);
|
|
446
|
+
if (!vitePath) {
|
|
447
|
+
diagnostics.push(`unwalkable star-export URL ${rep.url}`);
|
|
448
|
+
return { rep, names: null, diagnostics };
|
|
449
|
+
}
|
|
450
|
+
const names = await collectStarTargetExportNames(vitePath, transformer, new Set(), 0, diagnostics);
|
|
451
|
+
if (verbose && names) {
|
|
452
|
+
console.log(`[ns/m] expanded export* -> ${names.size} names from ${vitePath}${diagnostics.length ? ' (partial)' : ''}`);
|
|
453
|
+
}
|
|
454
|
+
return { rep, names, diagnostics };
|
|
455
|
+
}));
|
|
456
|
+
for (const entry of resolved) {
|
|
457
|
+
if (entry.diagnostics.length) {
|
|
458
|
+
// Always-on: an incomplete expansion silently narrows the importer's
|
|
459
|
+
// export surface, which surfaces on device as a link-time
|
|
460
|
+
// "does not provide an export named ..." with no server-side trace.
|
|
461
|
+
console.warn(`[ns/m][export*] incomplete star-export expansion${importerId ? ` in ${importerId}` : ''} for ${entry.rep.url}: ${entry.diagnostics.join('; ')}`);
|
|
462
|
+
}
|
|
463
|
+
if (!entry.names)
|
|
464
|
+
continue;
|
|
465
|
+
// First star wins for names provided by multiple siblings; duplicates
|
|
466
|
+
// would be a SyntaxError, and spec-ambiguous names have no good answer.
|
|
467
|
+
const emit = Array.from(entry.names).filter((n) => !claimed.has(n));
|
|
468
|
+
for (const n of emit)
|
|
469
|
+
claimed.add(n);
|
|
470
|
+
// An empty list still keeps the dependency edge (side effects,
|
|
471
|
+
// evaluation order) via a side-effect import.
|
|
472
|
+
const explicit = emit.length ? `export { ${emit.join(', ')} } from ${JSON.stringify(entry.rep.url)};` : `import ${JSON.stringify(entry.rep.url)};`;
|
|
473
|
+
code = code.replace(entry.rep.full, explicit);
|
|
188
474
|
}
|
|
189
475
|
return code;
|
|
190
476
|
}
|
|
@@ -219,7 +505,13 @@ export function stripViteDynamicImportVirtual(code) {
|
|
|
219
505
|
return code;
|
|
220
506
|
}
|
|
221
507
|
const original = code;
|
|
222
|
-
|
|
508
|
+
// Statement-scoped, NOT line-anchored: Vite 8 emits its injected imports
|
|
509
|
+
// concatenated on ONE line with the module's original first line, e.g.
|
|
510
|
+
// import …"/@vite/client";import …"/@id/__x00__vite/dynamic-import-helper.js";/**
|
|
511
|
+
// A `^…$`-anchored replace would delete the whole line — including the
|
|
512
|
+
// module's leading `/**`, leaving an orphaned JSDoc body that is a
|
|
513
|
+
// SyntaxError ("Unexpected token '*'") on device.
|
|
514
|
+
code = code.replace(/import\s+[^;'"\n]*['"][^'"\n]*\/@id\/__x00__vite\/dynamic-import-helper[^'"\n]*['"]\s*;?/g, '');
|
|
223
515
|
if (/\/@id\/__x00__vite\/dynamic-import-helper/.test(code)) {
|
|
224
516
|
code = code.replace(/\/@id\/__x00__vite\/dynamic-import-helper[^"'`)]*/g, '/__NS_UNUSED_DYNAMIC_IMPORT_HELPER__');
|
|
225
517
|
}
|
|
@@ -264,44 +556,52 @@ export function extractExportMetadata(code) {
|
|
|
264
556
|
return { hasDefault, named: Array.from(named) };
|
|
265
557
|
}
|
|
266
558
|
function shouldAllowLocalCoreSanitizerPaths(contextLabel) {
|
|
267
|
-
|
|
559
|
+
// The @nativescript/vite HMR runtime (client + framework strategies)
|
|
560
|
+
// legitimately references local core paths in strings — allow it whether it
|
|
561
|
+
// is served from node_modules or from the monorepo dist output
|
|
562
|
+
// (`file:../../dist/packages/vite` symlinks resolve to the real dist path,
|
|
563
|
+
// so no node_modules segment appears in the served URL).
|
|
564
|
+
return /\b(?:node_modules\/@nativescript\/vite|dist\/packages\/vite)\/hmr\/(?:client|frameworks)\//.test(contextLabel);
|
|
268
565
|
}
|
|
269
566
|
export function assertNoOptimizedArtifacts(code, contextLabel) {
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
offenders.push(`${i + 1}: ${line.substring(0, 200)}`);
|
|
280
|
-
break;
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
if (localCore.test(line)) {
|
|
284
|
-
const trimmed = line.trimStart();
|
|
285
|
-
if (trimmed.startsWith('//') || trimmed.startsWith('/*') || trimmed.startsWith('*')) {
|
|
286
|
-
continue;
|
|
287
|
-
}
|
|
288
|
-
if (shouldAllowLocalCoreSanitizerPaths(contextLabel)) {
|
|
289
|
-
continue;
|
|
290
|
-
}
|
|
291
|
-
offenders.push(`${i + 1}: ${line.substring(0, 200)} [local-core-path]`);
|
|
292
|
-
}
|
|
293
|
-
if (offenders.length >= 10)
|
|
567
|
+
const offenders = [];
|
|
568
|
+
const lines = code.split('\n');
|
|
569
|
+
const tests = [/\b__VITE_PLUGIN__\b/, /\b__VITE_PRELOAD__\b/];
|
|
570
|
+
const localCore = /(^|[^\w@])(?:\.\.?\/|\/)??@nativescript[\/_-]core\//i;
|
|
571
|
+
for (let i = 0; i < lines.length; i++) {
|
|
572
|
+
const line = lines[i];
|
|
573
|
+
for (const re of tests) {
|
|
574
|
+
if (re.test(line)) {
|
|
575
|
+
offenders.push(`${i + 1}: ${line.substring(0, 200)}`);
|
|
294
576
|
break;
|
|
577
|
+
}
|
|
295
578
|
}
|
|
296
|
-
if (
|
|
297
|
-
const
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
579
|
+
if (localCore.test(line)) {
|
|
580
|
+
const trimmed = line.trimStart();
|
|
581
|
+
if (trimmed.startsWith('//') || trimmed.startsWith('/*') || trimmed.startsWith('*')) {
|
|
582
|
+
continue;
|
|
583
|
+
}
|
|
584
|
+
if (shouldAllowLocalCoreSanitizerPaths(contextLabel)) {
|
|
585
|
+
continue;
|
|
586
|
+
}
|
|
587
|
+
// Only module-resolution contexts (import/export/require) leak to the
|
|
588
|
+
// device ESM loader. A core path appearing as plain runtime string data
|
|
589
|
+
// — e.g. component-builder's `const CORE_UI_BARREL = '@nativescript/core/ui'`
|
|
590
|
+
// passed to `global.loadModule()`, which reads the bundler module
|
|
591
|
+
// registry, not the ESM loader — is legitimate and must not fail serving.
|
|
592
|
+
if (!/(?:\bimport\b|\bexport\b|\bfrom\s*["']|\brequire\s*\()/.test(line)) {
|
|
593
|
+
continue;
|
|
594
|
+
}
|
|
595
|
+
offenders.push(`${i + 1}: ${line.substring(0, 200)} [local-core-path]`);
|
|
302
596
|
}
|
|
303
|
-
|
|
304
|
-
|
|
597
|
+
if (offenders.length >= 10)
|
|
598
|
+
break;
|
|
599
|
+
}
|
|
600
|
+
if (offenders.length) {
|
|
601
|
+
const msg = `[sanitize-fail] Optimized deps/virtual id artifacts detected in ${contextLabel}. These cannot be evaluated by the device HTTP ESM loader. Offending lines (first ${Math.min(5, offenders.length)} shown):\n` + offenders.slice(0, 5).join('\n');
|
|
602
|
+
const error = new Error(msg);
|
|
603
|
+
error.code = 'NS_SANITIZE_FAIL';
|
|
604
|
+
error.offenders = offenders;
|
|
305
605
|
throw error;
|
|
306
606
|
}
|
|
307
607
|
}
|
|
@@ -318,7 +618,7 @@ export function ensureDestructureCoreImports(code) {
|
|
|
318
618
|
return match.length === 2 ? `${match[0].trim()}: ${match[1].trim()}` : seg;
|
|
319
619
|
})
|
|
320
620
|
.join(', ');
|
|
321
|
-
const reNamed = /(^|\n)\s*import\s*\{([^}]+)\}\s*from\s*["']((?:https?:\/\/[^"']+)?\/ns\/core(?:\/[
|
|
621
|
+
const reNamed = /(^|\n)\s*import\s*\{([^}]+)\}\s*from\s*["']((?:https?:\/\/[^"']+)?\/ns\/core(?:\/[^"']+)?)['"];?\s*/gm;
|
|
322
622
|
result = result.replace(reNamed, (_full, prefix, specList, src) => {
|
|
323
623
|
if (isDeepCoreSubpath(src))
|
|
324
624
|
return _full;
|
|
@@ -327,7 +627,7 @@ export function ensureDestructureCoreImports(code) {
|
|
|
327
627
|
const decl = `const { ${toDestructure(specList)} } = ${tempName};`;
|
|
328
628
|
return `${prefix}import ${tempName} from ${JSON.stringify(src)};\n${decl}\n`;
|
|
329
629
|
});
|
|
330
|
-
const reMixed = /(^|\n)\s*import\s+([A-Za-z_$][\w$]*)\s*,\s*\{([^}]+)\}\s*from\s*["']((?:https?:\/\/[^"']+)?\/ns\/core(?:\/[
|
|
630
|
+
const reMixed = /(^|\n)\s*import\s+([A-Za-z_$][\w$]*)\s*,\s*\{([^}]+)\}\s*from\s*["']((?:https?:\/\/[^"']+)?\/ns\/core(?:\/[^"']+)?)['"];?\s*/gm;
|
|
331
631
|
result = result.replace(reMixed, (_full, prefix, defName, specList, src) => {
|
|
332
632
|
if (isDeepCoreSubpath(src))
|
|
333
633
|
return _full;
|
|
@@ -512,7 +812,7 @@ export function deduplicateLinkerImports(code) {
|
|
|
512
812
|
return code;
|
|
513
813
|
}
|
|
514
814
|
}
|
|
515
|
-
export function wrapCommonJsModuleForDevice(code) {
|
|
815
|
+
export function wrapCommonJsModuleForDevice(code, absolutePath) {
|
|
516
816
|
if (!code)
|
|
517
817
|
return code;
|
|
518
818
|
try {
|
|
@@ -538,6 +838,22 @@ export function wrapCommonJsModuleForDevice(code) {
|
|
|
538
838
|
namedExports.add(name);
|
|
539
839
|
}
|
|
540
840
|
}
|
|
841
|
+
// Static enumeration only sees `exports.foo = ...` and `Object.defineProperty(exports, 'foo', ...)`.
|
|
842
|
+
// Real-world packages like lodash attach their entire surface to a function inside an IIFE and
|
|
843
|
+
// then `module.exports = thatFunction`. Static analysis returns zero in that case. To handle
|
|
844
|
+
// these modules we ALSO load the package in the dev-server's Node context (only when we have a
|
|
845
|
+
// node_modules path) and merge the runtime keys. See `helpers/cjs-named-exports.ts` for the
|
|
846
|
+
// reasoning and safety boundaries.
|
|
847
|
+
if (absolutePath) {
|
|
848
|
+
try {
|
|
849
|
+
for (const n of getCjsNamedExports(absolutePath)) {
|
|
850
|
+
namedExports.add(n);
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
catch {
|
|
854
|
+
/* fall through to whatever we caught statically */
|
|
855
|
+
}
|
|
856
|
+
}
|
|
541
857
|
let suffix = `\nvar __cjs_mod = module.exports;\nexport default __cjs_mod;\n`;
|
|
542
858
|
if (namedExports.size) {
|
|
543
859
|
const entries = Array.from(namedExports);
|