@nativescript/vite 8.0.0-alpha.3 → 8.0.0-alpha.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -11
- package/configuration/angular.d.ts +34 -1
- package/configuration/angular.js +373 -163
- package/configuration/angular.js.map +1 -1
- package/configuration/base.js +184 -14
- package/configuration/base.js.map +1 -1
- package/configuration/javascript.js +5 -72
- package/configuration/javascript.js.map +1 -1
- package/configuration/solid.js +27 -1
- package/configuration/solid.js.map +1 -1
- package/configuration/typescript.js +5 -75
- package/configuration/typescript.js.map +1 -1
- package/helpers/app-components.d.ts +2 -1
- package/helpers/app-components.js.map +1 -1
- package/helpers/app-css-state.d.ts +8 -0
- package/helpers/app-css-state.js +8 -0
- package/helpers/app-css-state.js.map +1 -0
- package/helpers/bundler-context.d.ts +11 -0
- package/helpers/bundler-context.js +71 -0
- package/helpers/bundler-context.js.map +1 -0
- package/helpers/config-as-json.js +10 -0
- package/helpers/config-as-json.js.map +1 -1
- package/helpers/dev-host.d.ts +341 -0
- package/helpers/dev-host.js +617 -0
- package/helpers/dev-host.js.map +1 -0
- package/helpers/esbuild-platform-resolver.js +4 -1
- package/helpers/esbuild-platform-resolver.js.map +1 -1
- package/helpers/global-defines.d.ts +51 -0
- package/helpers/global-defines.js +77 -0
- package/helpers/global-defines.js.map +1 -1
- package/helpers/hmr-scope.d.ts +26 -0
- package/helpers/hmr-scope.js +67 -0
- package/helpers/hmr-scope.js.map +1 -0
- package/helpers/init.js +0 -18
- package/helpers/init.js.map +1 -1
- package/helpers/logging.d.ts +1 -0
- package/helpers/logging.js +63 -3
- package/helpers/logging.js.map +1 -1
- package/helpers/main-entry.d.ts +2 -1
- package/helpers/main-entry.js +430 -47
- package/helpers/main-entry.js.map +1 -1
- package/helpers/nativeclass-esbuild-plugin.d.ts +2 -1
- package/helpers/nativeclass-esbuild-plugin.js.map +1 -1
- package/helpers/nativeclass-transform.js.map +1 -1
- package/helpers/nativeclass-transformer-plugin.d.ts +9 -2
- package/helpers/nativeclass-transformer-plugin.js +157 -14
- package/helpers/nativeclass-transformer-plugin.js.map +1 -1
- package/helpers/nativescript-package-resolver.js +8 -3
- package/helpers/nativescript-package-resolver.js.map +1 -1
- package/helpers/normalize-id.d.ts +42 -0
- package/helpers/normalize-id.js +60 -0
- package/helpers/normalize-id.js.map +1 -0
- package/helpers/ns-core-url.d.ts +88 -0
- package/helpers/ns-core-url.js +191 -0
- package/helpers/ns-core-url.js.map +1 -0
- package/helpers/package-platform-aliases.js +4 -3
- package/helpers/package-platform-aliases.js.map +1 -1
- package/helpers/platform-types.d.ts +2 -0
- package/helpers/platform-types.js +2 -0
- package/helpers/platform-types.js.map +1 -0
- package/helpers/project.d.ts +35 -0
- package/helpers/project.js +120 -2
- package/helpers/project.js.map +1 -1
- package/helpers/resolver.js +17 -2
- package/helpers/resolver.js.map +1 -1
- package/helpers/ts-config-paths.d.ts +14 -0
- package/helpers/ts-config-paths.js +89 -8
- package/helpers/ts-config-paths.js.map +1 -1
- package/helpers/typescript-check.d.ts +2 -1
- package/helpers/typescript-check.js.map +1 -1
- package/helpers/workers.d.ts +20 -19
- package/helpers/workers.js +624 -4
- package/helpers/workers.js.map +1 -1
- package/hmr/client/css-handler.d.ts +1 -0
- package/hmr/client/css-handler.js +33 -20
- package/hmr/client/css-handler.js.map +1 -1
- package/hmr/client/css-update-overlay.d.ts +18 -0
- package/hmr/client/css-update-overlay.js +27 -0
- package/hmr/client/css-update-overlay.js.map +1 -0
- package/hmr/client/framework-client-strategy.d.ts +73 -0
- package/hmr/client/framework-client-strategy.js +19 -0
- package/hmr/client/framework-client-strategy.js.map +1 -0
- package/hmr/client/hmr-pending-overlay.d.ts +27 -0
- package/hmr/client/hmr-pending-overlay.js +50 -0
- package/hmr/client/hmr-pending-overlay.js.map +1 -0
- package/hmr/client/index.js +459 -164
- package/hmr/client/index.js.map +1 -1
- package/hmr/client/utils.d.ts +6 -1
- package/hmr/client/utils.js +184 -8
- package/hmr/client/utils.js.map +1 -1
- package/hmr/entry-runtime.d.ts +2 -1
- package/hmr/entry-runtime.js +252 -65
- package/hmr/entry-runtime.js.map +1 -1
- package/hmr/frameworks/angular/build/angular-linker.d.ts +12 -0
- package/hmr/frameworks/angular/build/angular-linker.js +109 -0
- package/hmr/frameworks/angular/build/angular-linker.js.map +1 -0
- package/hmr/frameworks/angular/build/inject-component-hmr-registration.d.ts +112 -0
- package/hmr/frameworks/angular/build/inject-component-hmr-registration.js +291 -0
- package/hmr/frameworks/angular/build/inject-component-hmr-registration.js.map +1 -0
- package/hmr/frameworks/angular/build/inject-hmr-vite-ignore.d.ts +75 -0
- package/hmr/frameworks/angular/build/inject-hmr-vite-ignore.js +221 -0
- package/hmr/frameworks/angular/build/inject-hmr-vite-ignore.js.map +1 -0
- package/{helpers/angular → hmr/frameworks/angular/build}/inline-decorator-component-templates.js +1 -170
- package/hmr/frameworks/angular/build/inline-decorator-component-templates.js.map +1 -0
- package/hmr/frameworks/angular/build/js-lexer.d.ts +4 -0
- package/{helpers/angular/synthesize-decorator-ctor-parameters.js → hmr/frameworks/angular/build/js-lexer.js} +22 -96
- package/hmr/frameworks/angular/build/js-lexer.js.map +1 -0
- package/hmr/frameworks/angular/build/shared-linker.d.ts +39 -0
- package/hmr/frameworks/angular/build/shared-linker.js +128 -0
- package/hmr/frameworks/angular/build/shared-linker.js.map +1 -0
- package/hmr/frameworks/angular/build/synthesize-decorator-ctor-parameters.js +88 -0
- package/hmr/frameworks/angular/build/synthesize-decorator-ctor-parameters.js.map +1 -0
- package/{helpers/angular → hmr/frameworks/angular/build}/synthesize-injectable-factories.js +1 -174
- package/hmr/frameworks/angular/build/synthesize-injectable-factories.js.map +1 -0
- package/{helpers/angular → hmr/frameworks/angular/build}/util.d.ts +1 -0
- package/hmr/frameworks/angular/build/util.js +155 -0
- package/hmr/frameworks/angular/build/util.js.map +1 -0
- package/hmr/frameworks/angular/client/index.d.ts +1 -0
- package/hmr/frameworks/angular/client/index.js +778 -20
- package/hmr/frameworks/angular/client/index.js.map +1 -1
- package/hmr/frameworks/angular/client/strategy.d.ts +9 -0
- package/hmr/frameworks/angular/client/strategy.js +19 -0
- package/hmr/frameworks/angular/client/strategy.js.map +1 -0
- package/hmr/frameworks/angular/server/angular-root-component.d.ts +79 -0
- package/hmr/frameworks/angular/server/angular-root-component.js +149 -0
- package/hmr/frameworks/angular/server/angular-root-component.js.map +1 -0
- package/hmr/frameworks/angular/server/linker.js +1 -4
- package/hmr/frameworks/angular/server/linker.js.map +1 -1
- package/hmr/frameworks/angular/server/strategy.js +448 -12
- package/hmr/frameworks/angular/server/strategy.js.map +1 -1
- package/hmr/{server → frameworks/angular/server}/websocket-angular-entry.js +2 -2
- package/hmr/frameworks/angular/server/websocket-angular-entry.js.map +1 -0
- package/hmr/{server → frameworks/angular/server}/websocket-angular-hot-update.d.ts +17 -11
- package/hmr/frameworks/angular/server/websocket-angular-hot-update.js +336 -0
- package/hmr/frameworks/angular/server/websocket-angular-hot-update.js.map +1 -0
- package/hmr/frameworks/solid/build/solid-jsx-deps.d.ts +15 -0
- package/hmr/frameworks/solid/build/solid-jsx-deps.js +178 -0
- package/hmr/frameworks/solid/build/solid-jsx-deps.js.map +1 -0
- package/hmr/frameworks/solid/server/strategy.js +360 -16
- package/hmr/frameworks/solid/server/strategy.js.map +1 -1
- package/hmr/frameworks/typescript/server/strategy.js +28 -14
- package/hmr/frameworks/typescript/server/strategy.js.map +1 -1
- package/hmr/frameworks/vue/client/index.js +30 -199
- package/hmr/frameworks/vue/client/index.js.map +1 -1
- package/hmr/frameworks/vue/client/strategy.d.ts +7 -0
- package/hmr/frameworks/vue/client/strategy.js +83 -0
- package/hmr/frameworks/vue/client/strategy.js.map +1 -0
- package/hmr/frameworks/vue/client/vue-sfc-update-overlay.d.ts +82 -0
- package/hmr/frameworks/vue/client/vue-sfc-update-overlay.js +133 -0
- package/hmr/frameworks/vue/client/vue-sfc-update-overlay.js.map +1 -0
- package/hmr/frameworks/vue/server/sfc-route-assemble.d.ts +7 -0
- package/hmr/frameworks/vue/server/sfc-route-assemble.js +706 -0
- package/hmr/frameworks/vue/server/sfc-route-assemble.js.map +1 -0
- package/hmr/frameworks/vue/server/sfc-route-meta.d.ts +7 -0
- package/hmr/frameworks/vue/server/sfc-route-meta.js +80 -0
- package/hmr/frameworks/vue/server/sfc-route-meta.js.map +1 -0
- package/hmr/frameworks/vue/server/sfc-route-serve.d.ts +8 -0
- package/hmr/frameworks/vue/server/sfc-route-serve.js +457 -0
- package/hmr/frameworks/vue/server/sfc-route-serve.js.map +1 -0
- package/hmr/frameworks/vue/server/sfc-route-shared.d.ts +19 -0
- package/hmr/frameworks/vue/server/sfc-route-shared.js +14 -0
- package/hmr/frameworks/vue/server/sfc-route-shared.js.map +1 -0
- package/hmr/frameworks/vue/server/strategy.js +244 -0
- package/hmr/frameworks/vue/server/strategy.js.map +1 -1
- package/hmr/frameworks/vue/server/websocket-sfc.d.ts +15 -0
- package/hmr/frameworks/vue/server/websocket-sfc.js +20 -0
- package/hmr/frameworks/vue/server/websocket-sfc.js.map +1 -0
- package/hmr/helpers/ast-normalizer.js +52 -5
- package/hmr/helpers/ast-normalizer.js.map +1 -1
- package/hmr/helpers/cjs-named-exports.d.ts +23 -0
- package/hmr/helpers/cjs-named-exports.js +152 -0
- package/hmr/helpers/cjs-named-exports.js.map +1 -0
- package/hmr/helpers/package-exports.d.ts +16 -0
- package/hmr/helpers/package-exports.js +396 -0
- package/hmr/helpers/package-exports.js.map +1 -0
- package/hmr/server/constants.js +13 -4
- package/hmr/server/constants.js.map +1 -1
- package/hmr/server/core-sanitize.d.ts +90 -7
- package/hmr/server/core-sanitize.js +211 -56
- package/hmr/server/core-sanitize.js.map +1 -1
- package/hmr/server/device-transform-helpers.d.ts +24 -0
- package/hmr/server/device-transform-helpers.js +327 -0
- package/hmr/server/device-transform-helpers.js.map +1 -0
- package/hmr/server/framework-strategy.d.ts +95 -11
- package/hmr/server/hmr-module-graph.d.ts +37 -0
- package/hmr/server/hmr-module-graph.js +214 -0
- package/hmr/server/hmr-module-graph.js.map +1 -0
- package/hmr/server/import-map.d.ts +11 -2
- package/hmr/server/import-map.js +59 -40
- package/hmr/server/import-map.js.map +1 -1
- package/hmr/server/index.js +7 -16
- package/hmr/server/index.js.map +1 -1
- package/hmr/server/ns-core-cjs-shape.d.ts +204 -0
- package/hmr/server/ns-core-cjs-shape.js +271 -0
- package/hmr/server/ns-core-cjs-shape.js.map +1 -0
- package/hmr/server/ns-rt-bridge.d.ts +51 -0
- package/hmr/server/ns-rt-bridge.js +131 -0
- package/hmr/server/ns-rt-bridge.js.map +1 -0
- package/hmr/server/ns-rt-route.d.ts +5 -0
- package/hmr/server/ns-rt-route.js +35 -0
- package/hmr/server/ns-rt-route.js.map +1 -0
- package/hmr/server/perf-instrumentation.d.ts +114 -0
- package/hmr/server/perf-instrumentation.js +195 -0
- package/hmr/server/perf-instrumentation.js.map +1 -0
- package/hmr/server/process-code-for-device.d.ts +15 -0
- package/hmr/server/process-code-for-device.js +654 -0
- package/hmr/server/process-code-for-device.js.map +1 -0
- package/hmr/server/require-guard.d.ts +1 -0
- package/hmr/server/require-guard.js +12 -0
- package/hmr/server/require-guard.js.map +1 -0
- package/hmr/server/rewrite-imports.d.ts +2 -0
- package/hmr/server/rewrite-imports.js +604 -0
- package/hmr/server/rewrite-imports.js.map +1 -0
- package/hmr/server/route-helpers.d.ts +7 -0
- package/hmr/server/route-helpers.js +13 -0
- package/hmr/server/route-helpers.js.map +1 -0
- package/hmr/server/server-origin.d.ts +12 -0
- package/hmr/server/server-origin.js +66 -0
- package/hmr/server/server-origin.js.map +1 -0
- package/hmr/server/shared-transform-request.js +12 -5
- package/hmr/server/shared-transform-request.js.map +1 -1
- package/hmr/server/transform-cache-invalidation.d.ts +11 -0
- package/hmr/server/transform-cache-invalidation.js +84 -0
- package/hmr/server/transform-cache-invalidation.js.map +1 -0
- package/hmr/server/vendor-bare-module-shims.d.ts +4 -0
- package/hmr/server/vendor-bare-module-shims.js +80 -0
- package/hmr/server/vendor-bare-module-shims.js.map +1 -0
- package/hmr/server/vite-plugin.js +60 -42
- package/hmr/server/vite-plugin.js.map +1 -1
- package/hmr/server/websocket-core-bridge.d.ts +41 -6
- package/hmr/server/websocket-core-bridge.js +72 -75
- package/hmr/server/websocket-core-bridge.js.map +1 -1
- package/hmr/server/websocket-css-hot-update.d.ts +33 -0
- package/hmr/server/websocket-css-hot-update.js +65 -0
- package/hmr/server/websocket-css-hot-update.js.map +1 -0
- package/hmr/server/websocket-device-transform.d.ts +3 -0
- package/hmr/server/websocket-device-transform.js +7 -0
- package/hmr/server/websocket-device-transform.js.map +1 -0
- package/hmr/server/websocket-graph-upsert.d.ts +15 -0
- package/hmr/server/websocket-graph-upsert.js +20 -0
- package/hmr/server/websocket-graph-upsert.js.map +1 -1
- package/hmr/server/websocket-hmr-pending.d.ts +37 -0
- package/hmr/server/websocket-hmr-pending.js +55 -0
- package/hmr/server/websocket-hmr-pending.js.map +1 -0
- package/hmr/server/websocket-hot-update.d.ts +77 -0
- package/hmr/server/websocket-hot-update.js +330 -0
- package/hmr/server/websocket-hot-update.js.map +1 -0
- package/hmr/server/websocket-import-map-route.d.ts +15 -0
- package/hmr/server/websocket-import-map-route.js +46 -0
- package/hmr/server/websocket-import-map-route.js.map +1 -0
- package/hmr/server/websocket-module-bindings.js +3 -3
- package/hmr/server/websocket-module-bindings.js.map +1 -1
- package/hmr/server/websocket-module-specifiers.d.ts +66 -2
- package/hmr/server/websocket-module-specifiers.js +202 -19
- package/hmr/server/websocket-module-specifiers.js.map +1 -1
- package/hmr/server/websocket-ns-core.d.ts +21 -0
- package/hmr/server/websocket-ns-core.js +306 -0
- package/hmr/server/websocket-ns-core.js.map +1 -0
- package/hmr/server/websocket-ns-entry.d.ts +21 -0
- package/hmr/server/websocket-ns-entry.js +150 -0
- package/hmr/server/websocket-ns-entry.js.map +1 -0
- package/hmr/server/websocket-ns-m-paths.d.ts +3 -0
- package/hmr/server/websocket-ns-m-paths.js +92 -0
- package/hmr/server/websocket-ns-m-paths.js.map +1 -0
- package/hmr/server/websocket-ns-m-request.d.ts +45 -0
- package/hmr/server/websocket-ns-m-request.js +196 -0
- package/hmr/server/websocket-ns-m-request.js.map +1 -0
- package/hmr/server/websocket-ns-m.d.ts +33 -0
- package/hmr/server/websocket-ns-m.js +748 -0
- package/hmr/server/websocket-ns-m.js.map +1 -0
- package/hmr/server/websocket-served-module-helpers.d.ts +39 -0
- package/hmr/server/websocket-served-module-helpers.js +654 -0
- package/hmr/server/websocket-served-module-helpers.js.map +1 -0
- package/hmr/server/websocket-txn.d.ts +6 -0
- package/hmr/server/websocket-txn.js +39 -0
- package/hmr/server/websocket-txn.js.map +1 -0
- package/hmr/server/websocket-vendor-unifier.d.ts +9 -0
- package/hmr/server/websocket-vendor-unifier.js +46 -0
- package/hmr/server/websocket-vendor-unifier.js.map +1 -0
- package/hmr/server/websocket.d.ts +8 -39
- package/hmr/server/websocket.js +602 -6049
- package/hmr/server/websocket.js.map +1 -1
- package/hmr/shared/ns-globals.d.ts +118 -0
- package/hmr/shared/ns-globals.js +27 -0
- package/hmr/shared/ns-globals.js.map +1 -0
- package/hmr/shared/protocol.d.ts +136 -0
- package/hmr/shared/protocol.js +28 -0
- package/hmr/shared/protocol.js.map +1 -0
- package/hmr/shared/runtime/boot-placeholder-ui.d.ts +69 -0
- package/hmr/shared/runtime/boot-placeholder-ui.js +101 -0
- package/hmr/shared/runtime/boot-placeholder-ui.js.map +1 -0
- package/hmr/shared/runtime/boot-progress.d.ts +40 -0
- package/hmr/shared/runtime/boot-progress.js +128 -0
- package/hmr/shared/runtime/boot-progress.js.map +1 -0
- package/hmr/shared/runtime/boot-timeline.d.ts +18 -0
- package/hmr/shared/runtime/boot-timeline.js +52 -0
- package/hmr/shared/runtime/boot-timeline.js.map +1 -0
- package/hmr/shared/runtime/dev-overlay-snapshots.d.ts +31 -0
- package/hmr/shared/runtime/dev-overlay-snapshots.js +324 -0
- package/hmr/shared/runtime/dev-overlay-snapshots.js.map +1 -0
- package/hmr/shared/runtime/dev-overlay.d.ts +75 -26
- package/hmr/shared/runtime/dev-overlay.js +990 -260
- package/hmr/shared/runtime/dev-overlay.js.map +1 -1
- package/hmr/shared/runtime/module-provenance.js +1 -4
- package/hmr/shared/runtime/module-provenance.js.map +1 -1
- package/hmr/shared/runtime/root-placeholder-view.d.ts +19 -0
- package/hmr/shared/runtime/root-placeholder-view.js +310 -0
- package/hmr/shared/runtime/root-placeholder-view.js.map +1 -0
- package/hmr/shared/runtime/root-placeholder.js +352 -194
- package/hmr/shared/runtime/root-placeholder.js.map +1 -1
- package/hmr/shared/runtime/session-bootstrap.js +164 -1
- package/hmr/shared/runtime/session-bootstrap.js.map +1 -1
- package/hmr/shared/runtime/vendor-bootstrap.js +1 -9
- package/hmr/shared/runtime/vendor-bootstrap.js.map +1 -1
- package/hmr/shared/vendor/manifest-collect.d.ts +4 -0
- package/hmr/shared/vendor/manifest-collect.js +512 -0
- package/hmr/shared/vendor/manifest-collect.js.map +1 -0
- package/hmr/shared/vendor/manifest-loader.d.ts +2 -1
- package/hmr/shared/vendor/manifest-loader.js +3 -2
- package/hmr/shared/vendor/manifest-loader.js.map +1 -1
- package/hmr/shared/vendor/manifest.d.ts +1 -7
- package/hmr/shared/vendor/manifest.js +102 -741
- package/hmr/shared/vendor/manifest.js.map +1 -1
- package/hmr/shared/vendor/vendor-device-shim.d.ts +1 -0
- package/hmr/shared/vendor/vendor-device-shim.js +208 -0
- package/hmr/shared/vendor/vendor-device-shim.js.map +1 -0
- package/hmr/shared/vendor/vendor-esbuild-plugins.d.ts +16 -0
- package/hmr/shared/vendor/vendor-esbuild-plugins.js +203 -0
- package/hmr/shared/vendor/vendor-esbuild-plugins.js.map +1 -0
- package/index.d.ts +1 -0
- package/index.js +5 -0
- package/index.js.map +1 -1
- package/package.json +55 -11
- package/runtime/core-aliases-early.js +17 -41
- package/runtime/core-aliases-early.js.map +1 -1
- package/helpers/angular/angular-linker.d.ts +0 -13
- package/helpers/angular/angular-linker.js +0 -194
- package/helpers/angular/angular-linker.js.map +0 -1
- package/helpers/angular/inline-decorator-component-templates.js.map +0 -1
- package/helpers/angular/shared-linker.d.ts +0 -11
- package/helpers/angular/shared-linker.js +0 -75
- package/helpers/angular/shared-linker.js.map +0 -1
- package/helpers/angular/synthesize-decorator-ctor-parameters.js.map +0 -1
- package/helpers/angular/synthesize-injectable-factories.js.map +0 -1
- package/helpers/angular/util.js +0 -67
- package/helpers/angular/util.js.map +0 -1
- package/helpers/prelink-angular.d.ts +0 -2
- package/helpers/prelink-angular.js +0 -117
- package/helpers/prelink-angular.js.map +0 -1
- package/hmr/server/websocket-angular-entry.js.map +0 -1
- package/hmr/server/websocket-angular-hot-update.js +0 -239
- package/hmr/server/websocket-angular-hot-update.js.map +0 -1
- /package/{helpers/angular → hmr/frameworks/angular/build}/inline-decorator-component-templates.d.ts +0 -0
- /package/{helpers/angular → hmr/frameworks/angular/build}/synthesize-decorator-ctor-parameters.d.ts +0 -0
- /package/{helpers/angular → hmr/frameworks/angular/build}/synthesize-injectable-factories.d.ts +0 -0
- /package/hmr/{server → frameworks/angular/server}/websocket-angular-entry.d.ts +0 -0
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import { isDirectoryIndexFilename, rewriteSpecifiersForDevice } from './core-sanitize.js';
|
|
2
|
+
import { buildDefaultExportFooter, buildShapeInstallHeader, hasNamespaceReExport, rewriteNamespaceReExportsForShape } from './ns-core-cjs-shape.js';
|
|
3
|
+
import { getCliFlags } from '../../helpers/cli-flags.js';
|
|
4
|
+
import { normalizeCoreSub as normalizeCoreSubCanonical } from '../../helpers/ns-core-url.js';
|
|
5
|
+
import { parseCoreBridgeRequest, resolveRuntimeCoreModulePath } from './websocket-core-bridge.js';
|
|
6
|
+
import { setDeviceModuleHeaders } from './route-helpers.js';
|
|
7
|
+
import { getServerOrigin } from './server-origin.js';
|
|
8
|
+
/**
|
|
9
|
+
* Registers the `@nativescript/core` device bridge on the dev server:
|
|
10
|
+
* - a catch-all that rewrites stray `/node_modules/@nativescript/core/*`
|
|
11
|
+
* requests to the canonical `/ns/core[/<sub>]` URL, and
|
|
12
|
+
* - `GET /ns/core[/<sub>]` — the ONE place @nativescript/core is evaluated on
|
|
13
|
+
* device (single module realm, shared class identities, one-time `register()`).
|
|
14
|
+
*/
|
|
15
|
+
export function registerNsCoreRoute(server, options) {
|
|
16
|
+
// 2.5.1) Catch-all redirect for stray /node_modules/@nativescript/core/*
|
|
17
|
+
// requests — route them to the /ns/core bridge so they get the same
|
|
18
|
+
// __DEV__/__IOS__ preamble and specifier rewriting. Without this,
|
|
19
|
+
// Vite's default /node_modules/ handler serves the raw file, which
|
|
20
|
+
// references bare __DEV__ and crashes at module eval.
|
|
21
|
+
server.middlewares.use((req, _res, next) => {
|
|
22
|
+
try {
|
|
23
|
+
const urlObj = new URL(req.url || '', 'http://localhost');
|
|
24
|
+
const coreNmPrefix = '/node_modules/@nativescript/core';
|
|
25
|
+
if (!urlObj.pathname.startsWith(coreNmPrefix))
|
|
26
|
+
return next();
|
|
27
|
+
const sub = urlObj.pathname.slice(coreNmPrefix.length).replace(/^\/+/, '');
|
|
28
|
+
if (sub === '' || sub === 'index.js' || sub === 'index') {
|
|
29
|
+
req.url = `/ns/core`;
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
req.url = `/ns/core/${sub}`;
|
|
33
|
+
}
|
|
34
|
+
return next();
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return next();
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
// 2.6) ESM bridge for @nativescript/core: GET /ns/core[/<sub>]
|
|
41
|
+
//
|
|
42
|
+
// Since bundle.mjs no longer bundles @nativescript/core (it is
|
|
43
|
+
// declared external in the rolldown config under HMR), this
|
|
44
|
+
// endpoint is the ONE place core is evaluated. Every consumer —
|
|
45
|
+
// bundle.mjs's own `@nativescript/core*` imports (resolved to
|
|
46
|
+
// full HTTP URLs in the entry virtual module), externalized
|
|
47
|
+
// vendor packages, HTTP-served app modules — all end up here.
|
|
48
|
+
// No more proxy bridge, no enumeration, no namespace detection,
|
|
49
|
+
// no prototype-polluted maps. We just serve Vite's authoritative
|
|
50
|
+
// transformed module content.
|
|
51
|
+
//
|
|
52
|
+
// iOS caches by URL path, so each unique URL is evaluated exactly
|
|
53
|
+
// once per app lifetime. Every class identity is shared, every
|
|
54
|
+
// `register()` side effect runs once, every `Application` reference
|
|
55
|
+
// is the same iosApp singleton. The entire class of "does not
|
|
56
|
+
// provide an export named X" and "Cannot redefine property" errors
|
|
57
|
+
// is eliminated by construction.
|
|
58
|
+
server.middlewares.use(async (req, res, next) => {
|
|
59
|
+
try {
|
|
60
|
+
const urlObj = new URL(req.url || '', 'http://localhost');
|
|
61
|
+
const coreRequest = parseCoreBridgeRequest(urlObj.pathname, urlObj.searchParams, Number(options.getGraphVersion() || 0));
|
|
62
|
+
if (!coreRequest)
|
|
63
|
+
return next();
|
|
64
|
+
// Non-canonical incoming URL — every emitter is supposed
|
|
65
|
+
// to canonicalize before hitting the device. Promote the
|
|
66
|
+
// drift to a 301 redirect so iOS still gets the file at
|
|
67
|
+
// the canonical URL (no realm split) but the offending
|
|
68
|
+
// caller is forced to update. We log the offending raw
|
|
69
|
+
// pathname so the regression source is easy to find.
|
|
70
|
+
if (coreRequest.canonicalPath) {
|
|
71
|
+
try {
|
|
72
|
+
console.warn(`[ns-core-bridge] 301 ${urlObj.pathname}${urlObj.search} → ${coreRequest.canonicalPath} (non-canonical core URL — please update emitter)`);
|
|
73
|
+
}
|
|
74
|
+
catch { }
|
|
75
|
+
res.setHeader('Access-Control-Allow-Origin', '*');
|
|
76
|
+
res.setHeader('Location', coreRequest.canonicalPath);
|
|
77
|
+
res.statusCode = 301;
|
|
78
|
+
res.end();
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
setDeviceModuleHeaders(res);
|
|
82
|
+
const { normalizedSub, sub } = coreRequest;
|
|
83
|
+
const resolveModuleId = async (moduleId) => {
|
|
84
|
+
const resolved = await server.pluginContainer?.resolveId?.(moduleId, undefined);
|
|
85
|
+
return typeof resolved === 'string' ? resolved : resolved?.id || null;
|
|
86
|
+
};
|
|
87
|
+
let modulePath = null;
|
|
88
|
+
if (sub) {
|
|
89
|
+
const resolvedSubpath = normalizedSub || sub;
|
|
90
|
+
modulePath = await resolveRuntimeCoreModulePath(resolvedSubpath, resolveModuleId);
|
|
91
|
+
if (!modulePath) {
|
|
92
|
+
modulePath = `/node_modules/@nativescript/core/${resolvedSubpath}`;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
modulePath = (await resolveModuleId('@nativescript/core')) || '/node_modules/@nativescript/core/index.js';
|
|
97
|
+
}
|
|
98
|
+
const transformed = await options.sharedTransformRequest(modulePath);
|
|
99
|
+
if (!transformed?.code) {
|
|
100
|
+
res.statusCode = 500;
|
|
101
|
+
res.setHeader('Content-Type', 'application/json');
|
|
102
|
+
res.end(JSON.stringify({ error: 'core-transform-failed', modulePath, sub: sub || null }));
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
// Vite's transform output references module IDs with /@fs,
|
|
106
|
+
// relative specifiers, or absolute project paths. Rewrite
|
|
107
|
+
// those to URLs iOS can fetch over HTTP.
|
|
108
|
+
//
|
|
109
|
+
// We also thread a `RelativeBase` so any lingering relative
|
|
110
|
+
// specifiers (`./x`, `../x`) — which Vite's import-analysis
|
|
111
|
+
// sometimes leaves untouched for `node_modules` files — get
|
|
112
|
+
// resolved against the served URL's logical directory and
|
|
113
|
+
// rewritten to canonical `/ns/core/<resolved>` URLs.
|
|
114
|
+
//
|
|
115
|
+
// Without this, V8/iOS apply RFC 3986 URL resolution against
|
|
116
|
+
// the served URL (which has no trailing slash) and treat the
|
|
117
|
+
// last path segment as a *file*, so `./layout-helper-common`
|
|
118
|
+
// from `/ns/core/utils/layout-helper` becomes
|
|
119
|
+
// `/ns/core/utils/layout-helper-common` — a sibling that
|
|
120
|
+
// doesn't exist, producing "Failed to load url … Does the
|
|
121
|
+
// file exist?" from Vite and a stuck boot screen.
|
|
122
|
+
const __rawSubForRel = String(normalizedSub || sub || '').replace(/^\/+|\/+$/g, '');
|
|
123
|
+
const __isDirIndex = isDirectoryIndexFilename(modulePath || '');
|
|
124
|
+
const __relBase = { sub: __rawSubForRel, isDirectoryIndex: __isDirIndex };
|
|
125
|
+
let rewritten = rewriteSpecifiersForDevice(transformed.code, getServerOrigin(server), Number(options.getGraphVersion() || 0), __relBase);
|
|
126
|
+
// Invariant D (CJS/ESM interop shape) — EXPORT-SIDE fix.
|
|
127
|
+
//
|
|
128
|
+
// `@nativescript/core/index.js` declares namespace
|
|
129
|
+
// re-exports like:
|
|
130
|
+
// export * as Utils from './utils';
|
|
131
|
+
// The ES spec says these produce Module Namespace Objects
|
|
132
|
+
// with [[Prototype]] = null. Consumers that reach them
|
|
133
|
+
// via direct ESM import — `import { Utils } from
|
|
134
|
+
// '@nativescript/core'` — get the raw null-proto value,
|
|
135
|
+
// bypassing any CJS `require` shim we install. Most
|
|
136
|
+
// consumers tolerate this, but CJS-style interop (most
|
|
137
|
+
// notably zone.js's `patchMethod`) calls
|
|
138
|
+
// `hasOwnProperty` on the target and crashes on
|
|
139
|
+
// null-proto.
|
|
140
|
+
//
|
|
141
|
+
// We rewrite the re-export to a shape-wrapped const:
|
|
142
|
+
// import * as __ns_re_Utils__ from './utils';
|
|
143
|
+
// export const Utils = __NS_CJS_SHAPE__(__ns_re_Utils__);
|
|
144
|
+
// so the EXPORT itself is a plain object — visible to
|
|
145
|
+
// both ESM and CJS consumers consistently.
|
|
146
|
+
//
|
|
147
|
+
// We only pay the rewrite cost when the module actually
|
|
148
|
+
// contains namespace re-exports (i.e., the main
|
|
149
|
+
// `index.js`). Subpaths (`/utils`, `/http`, …) don't
|
|
150
|
+
// re-export via `export * as`; they expose named
|
|
151
|
+
// exports directly, so the rewrite is a no-op on them.
|
|
152
|
+
if (hasNamespaceReExport(rewritten)) {
|
|
153
|
+
rewritten = rewriteNamespaceReExportsForShape(rewritten);
|
|
154
|
+
}
|
|
155
|
+
// Prepend the build-time defines (__DEV__, __IOS__, __ANDROID__,
|
|
156
|
+
// __APPLE__, …) that @nativescript/core source references directly.
|
|
157
|
+
// Vite's `define` config substitutes these in user-code transforms but
|
|
158
|
+
// skips node_modules by default; since core is now external and served
|
|
159
|
+
// over HTTP from this endpoint, the served transformed code still has
|
|
160
|
+
// bare identifiers like `if (__DEV__) …`. Without these consts, V8
|
|
161
|
+
// hits `ReferenceError: __DEV__ is not defined` at module eval because
|
|
162
|
+
// globalThis.__DEV__ is set by bundle.mjs's body AFTER all static
|
|
163
|
+
// imports (including these core modules) have resolved.
|
|
164
|
+
//
|
|
165
|
+
// We inject LITERAL boolean values based on CLI flags + dev-server
|
|
166
|
+
// mode rather than reading from globalThis, so the defines are
|
|
167
|
+
// resolved even before bundle.mjs's body runs.
|
|
168
|
+
const __cliFlags = getCliFlags() || {};
|
|
169
|
+
const __platformIsAndroid = !!__cliFlags.android;
|
|
170
|
+
const __platformIsVisionOS = !!__cliFlags.visionos;
|
|
171
|
+
const __platformIsIOS = !__platformIsAndroid && !__platformIsVisionOS;
|
|
172
|
+
const preamble = [
|
|
173
|
+
`const __ANDROID__ = ${__platformIsAndroid ? 'true' : 'false'};`,
|
|
174
|
+
`const __IOS__ = ${__platformIsIOS ? 'true' : 'false'};`,
|
|
175
|
+
`const __VISIONOS__ = ${__platformIsVisionOS ? 'true' : 'false'};`,
|
|
176
|
+
`const __APPLE__ = __IOS__ || __VISIONOS__;`,
|
|
177
|
+
`const __DEV__ = ${server.config?.mode === 'development' ? 'true' : 'false'};`,
|
|
178
|
+
`const __COMMONJS__ = false;`,
|
|
179
|
+
`const __NS_WEBPACK__ = false;`,
|
|
180
|
+
`const __NS_ENV_VERBOSE__ = globalThis.__NS_ENV_VERBOSE__ !== undefined ? !!globalThis.__NS_ENV_VERBOSE__ : false;`,
|
|
181
|
+
`const __CSS_PARSER__ = 'css-tree';`,
|
|
182
|
+
`const __UI_USE_XML_PARSER__ = true;`,
|
|
183
|
+
`const __UI_USE_EXTERNAL_RENDERER__ = false;`,
|
|
184
|
+
`const __TEST__ = false;`,
|
|
185
|
+
].join('\n');
|
|
186
|
+
// Boot-time instrumentation + module self-registration.
|
|
187
|
+
//
|
|
188
|
+
// - URL canonicalization: the same logical module must
|
|
189
|
+
// always resolve to byte-identical URLs across every
|
|
190
|
+
// emitter. The /ns/core handler records the first URL
|
|
191
|
+
// seen for each canonical sub (or '' for main) in
|
|
192
|
+
// `globalThis.__NS_CORE_FIRST_URL__` and fails hard on
|
|
193
|
+
// mismatch so drift in any emitter surfaces
|
|
194
|
+
// immediately, before the realm splits.
|
|
195
|
+
// - CJS/ESM boot order: CommonJS
|
|
196
|
+
// `require('@nativescript/core/...')` calls from
|
|
197
|
+
// vendor install() hooks must resolve to the SAME
|
|
198
|
+
// ESM namespace that ran this side-effect preamble.
|
|
199
|
+
// The registration below keys the namespace object
|
|
200
|
+
// under BOTH the bare specifier and the canonical
|
|
201
|
+
// subpath (and raw subpath for back-compat) so the
|
|
202
|
+
// vendor shim's `createRequire` and the main-entry
|
|
203
|
+
// `_nsReq` hit on any lookup form.
|
|
204
|
+
const rawSub = normalizedSub || sub || '';
|
|
205
|
+
const canonicalSub = normalizeCoreSubCanonical(rawSub);
|
|
206
|
+
const registrationKeySet = new Set();
|
|
207
|
+
registrationKeySet.add(canonicalSub ? `@nativescript/core/${canonicalSub}` : '@nativescript/core');
|
|
208
|
+
registrationKeySet.add(canonicalSub);
|
|
209
|
+
if (rawSub && rawSub !== canonicalSub) {
|
|
210
|
+
registrationKeySet.add(`@nativescript/core/${rawSub}`);
|
|
211
|
+
registrationKeySet.add(rawSub);
|
|
212
|
+
}
|
|
213
|
+
const registrationKeys = Array.from(registrationKeySet).map((k) => JSON.stringify(k));
|
|
214
|
+
const canonicalUrl = `${getServerOrigin(server)}` + (canonicalSub ? `/ns/core/${canonicalSub}` : '/ns/core');
|
|
215
|
+
const instrumentationHeader = [
|
|
216
|
+
`/* @nativescript/core bridge — canonical URL: ${canonicalUrl} */`,
|
|
217
|
+
`try { if (typeof globalThis !== 'undefined') {`,
|
|
218
|
+
` const __nsFirst = globalThis.__NS_CORE_FIRST_URL__ || (globalThis.__NS_CORE_FIRST_URL__ = Object.create(null));`,
|
|
219
|
+
` const __nsSeen = globalThis.__NS_CORE_FETCHED_URLS__ || (globalThis.__NS_CORE_FETCHED_URLS__ = []);`,
|
|
220
|
+
` const __nsKey = ${JSON.stringify(canonicalSub)};`,
|
|
221
|
+
` const __nsUrl = ${JSON.stringify(canonicalUrl)};`,
|
|
222
|
+
` __nsSeen.push(__nsUrl);`,
|
|
223
|
+
` if (typeof __nsFirst[__nsKey] === 'string' && __nsFirst[__nsKey] !== __nsUrl) {`,
|
|
224
|
+
` throw new Error('[ns-core] URL drift for sub=' + __nsKey + ': first=' + __nsFirst[__nsKey] + ' now=' + __nsUrl);`,
|
|
225
|
+
` }`,
|
|
226
|
+
` if (!__nsFirst[__nsKey]) __nsFirst[__nsKey] = __nsUrl;`,
|
|
227
|
+
` globalThis.__NS_CORE_EVAL_COUNT__ = (globalThis.__NS_CORE_EVAL_COUNT__ || 0) + 1;`,
|
|
228
|
+
`} } catch (e) { console.warn('[ns-core] instrumentation failed:', (e && e.message) || e); }`,
|
|
229
|
+
].join('\n');
|
|
230
|
+
// CJS/ESM interop shape — REGISTRATION side.
|
|
231
|
+
//
|
|
232
|
+
// The actual shape installer runs earlier in the module
|
|
233
|
+
// body (between preamble and selfImport; see
|
|
234
|
+
// buildShapeInstallHeader). At this point we just read
|
|
235
|
+
// globalThis.__NS_CJS_SHAPE__ and apply it to the self
|
|
236
|
+
// namespace before registering under the CJS key space.
|
|
237
|
+
//
|
|
238
|
+
// Why shape self at registration: consumers that reach
|
|
239
|
+
// `@nativescript/core` via `require()` (legacy vendors,
|
|
240
|
+
// `globalThis.require` shim) look up the registry. They
|
|
241
|
+
// expect a plain object (Object.prototype in chain) so
|
|
242
|
+
// `.hasOwnProperty` / `.toString` work. Shaping once on
|
|
243
|
+
// registration — the shape function is identity-preserving
|
|
244
|
+
// via WeakMap — gives a stable, shared, CJS-compatible
|
|
245
|
+
// view without copying on every require.
|
|
246
|
+
const registrationFooter = [
|
|
247
|
+
`try { if (typeof globalThis !== 'undefined') {`,
|
|
248
|
+
` const __nsReg = globalThis.__NS_CORE_MODULES__ || (globalThis.__NS_CORE_MODULES__ = Object.create(null));`,
|
|
249
|
+
` const __nsShapeFn = typeof globalThis.__NS_CJS_SHAPE__ === 'function' ? globalThis.__NS_CJS_SHAPE__ : function (x) { return x; };`,
|
|
250
|
+
` const __nsSelfRaw = (typeof __ns_core_self_ns__ !== 'undefined') ? __ns_core_self_ns__ : { default: undefined };`,
|
|
251
|
+
` const __nsSelf = __nsShapeFn(__nsSelfRaw);`,
|
|
252
|
+
...registrationKeys.map((k) => ` __nsReg[${k}] = __nsSelf;`),
|
|
253
|
+
`} } catch (e) { console.warn('[ns-core] self-register failed:', (e && e.message) || e); }`,
|
|
254
|
+
].join('\n');
|
|
255
|
+
// Bind `import * as __ns_core_self_ns__` to the module's
|
|
256
|
+
// own export namespace so the footer can stash it into
|
|
257
|
+
// the registry. Self-import is a no-op at eval time —
|
|
258
|
+
// V8 resolves it to the module record we're already
|
|
259
|
+
// evaluating and the final namespace is the same object
|
|
260
|
+
// the registry receives. We use the CANONICAL URL here
|
|
261
|
+
// so the self-import participates in Invariant A along
|
|
262
|
+
// with every other @nativescript/core URL.
|
|
263
|
+
const canonicalUrlForSelf = canonicalSub ? `/ns/core/${canonicalSub}` : '/ns/core';
|
|
264
|
+
const selfImport = `import * as __ns_core_self_ns__ from ${JSON.stringify(canonicalUrlForSelf)};`;
|
|
265
|
+
// Invariant D — SHAPE INSTALLER.
|
|
266
|
+
//
|
|
267
|
+
// Emits idempotent body-code that installs
|
|
268
|
+
// globalThis.__NS_CJS_SHAPE__ BEFORE `rewritten`'s body
|
|
269
|
+
// runs. This matters because the rewrite step above may
|
|
270
|
+
// have produced statements like
|
|
271
|
+
// `export const Utils = (typeof globalThis.__NS_CJS_SHAPE__ ...)(__ns_re_Utils__);`
|
|
272
|
+
// that execute during module evaluation. Without the
|
|
273
|
+
// installer running first, the ternary falls back to
|
|
274
|
+
// identity — still safe, but the null-proto namespace
|
|
275
|
+
// leaks through and consumers that expect a plain
|
|
276
|
+
// object would still crash.
|
|
277
|
+
//
|
|
278
|
+
// Placement is important: BEFORE selfImport in the
|
|
279
|
+
// concatenation. ESM imports are hoisted regardless of
|
|
280
|
+
// textual position, but body code executes in source
|
|
281
|
+
// order. Placing the installer first guarantees it
|
|
282
|
+
// runs before any body statement in `rewritten`.
|
|
283
|
+
//
|
|
284
|
+
// Install is idempotent: `|| (globalThis.X = ...)` so
|
|
285
|
+
// whichever /ns/core module evaluates first wins and
|
|
286
|
+
// every subsequent module becomes a no-op.
|
|
287
|
+
const shapeInstallHeader = buildShapeInstallHeader();
|
|
288
|
+
// Invariant D — DEFAULT EXPORT BRIDGE.
|
|
289
|
+
//
|
|
290
|
+
// See `buildDefaultExportFooter` in ns-core-cjs-shape.ts
|
|
291
|
+
// for the full rationale (consumer matrix, skip conditions,
|
|
292
|
+
// why the default isn't shaped). The short version:
|
|
293
|
+
// upstream rewrites turn `import { X } from '@nativescript/core'`
|
|
294
|
+
// into a DEFAULT import, and the bridge has to provide one.
|
|
295
|
+
const defaultExportFooter = buildDefaultExportFooter(rewritten);
|
|
296
|
+
const moduleCode = [instrumentationHeader, preamble, shapeInstallHeader, selfImport, rewritten, defaultExportFooter, registrationFooter].join('\n');
|
|
297
|
+
res.statusCode = 200;
|
|
298
|
+
res.end(moduleCode);
|
|
299
|
+
}
|
|
300
|
+
catch (e) {
|
|
301
|
+
console.warn('[ns-core-bridge] serve failed:', e?.message);
|
|
302
|
+
next();
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
//# sourceMappingURL=webs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YACF,mDAAmD;YACnD,uDAAuD;YACvD,qDAAqD;YACrD,mDAAmD;YACnD,iDAAiD;YACjD,EAAE;YACF,sDAAsD;YACtD,qDAAqD;YACrD,2CAA2C;YAC3C,MAAM,kBAAkB,GAAG,uBAAuB,EAAE,CAAC;YAErD,uCAAuC;YACvC,EAAE;YACF,yDAAyD;YACzD,4DAA4D;YAC5D,oDAAoD;YACpD,kEAAkE;YAClE,4DAA4D;YAC5D,MAAM,mBAAmB,GAAG,wBAAwB,CAAC,SAAS,CAAC,CAAC;YAEhE,MAAM,UAAU,GAAG,CAAC,qBAAqB,EAAE,QAAQ,EAAE,kBAAkB,EAAE,UAAU,EAAE,SAAS,EAAE,mBAAmB,EAAE,kBAAkB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACpJ,GAAG,CAAC,UAAU,GAAG,GAAG,CAAC;YACrB,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QACrB,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACZ,OAAO,CAAC,IAAI,CAAC,gCAAgC,EAAG,CAAS,EAAE,OAAO,CAAC,CAAC;YACpE,IAAI,EAAE,CAAC;QACR,CAAC;IACF,CAAC,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ViteDevServer } from 'vite';
|
|
2
|
+
/**
|
|
3
|
+
* Dependencies the device-bootstrap routes need from the HMR plugin closure.
|
|
4
|
+
* The three project-path values are computed once in `websocket.ts`; injecting
|
|
5
|
+
* them (rather than recomputing) keeps a single source of truth.
|
|
6
|
+
*/
|
|
7
|
+
export interface RegisterNsEntryRoutesOptions {
|
|
8
|
+
verbose: boolean;
|
|
9
|
+
appRootDir: string;
|
|
10
|
+
defaultMainEntry: string;
|
|
11
|
+
defaultMainEntryVirtual: string;
|
|
12
|
+
getGraphVersion(): number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Registers the device bootstrap endpoints:
|
|
16
|
+
* - `GET /ns/entry-rt[?v=<ver>]` — serves the compiled entry runtime module
|
|
17
|
+
* (built `entry-runtime.js`, or a transformed `entry-runtime.ts` fallback), and
|
|
18
|
+
* - `GET /ns/entry[/<ver>]` — a script-safe wrapper that fetches the entry
|
|
19
|
+
* runtime and starts the app with `{ origin, main, ver }`.
|
|
20
|
+
*/
|
|
21
|
+
export declare function registerNsEntryRoutes(server: ViteDevServer, options: RegisterNsEntryRoutesOptions): void;
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
import { existsSync, readFileSync } from 'fs';
|
|
3
|
+
import * as path from 'path';
|
|
4
|
+
import babelCore from '@babel/core';
|
|
5
|
+
import { getPackageJson, getProjectFilePath } from '../../helpers/project.js';
|
|
6
|
+
import { REQUIRE_GUARD_SNIPPET } from './require-guard.js';
|
|
7
|
+
import { setDeviceModuleHeaders } from './route-helpers.js';
|
|
8
|
+
import { getServerOrigin } from './server-origin.js';
|
|
9
|
+
// Lazily loaded only for the source-tree fallback below (transform
|
|
10
|
+
// entry-runtime.ts on the fly when the built .js isn't present).
|
|
11
|
+
const pluginTransformTypescript = (() => {
|
|
12
|
+
const requireFromHere = createRequire(import.meta.url);
|
|
13
|
+
const loaded = requireFromHere('@babel/plugin-transform-typescript');
|
|
14
|
+
return loaded?.default || loaded;
|
|
15
|
+
})();
|
|
16
|
+
/**
|
|
17
|
+
* Registers the device bootstrap endpoints:
|
|
18
|
+
* - `GET /ns/entry-rt[?v=<ver>]` — serves the compiled entry runtime module
|
|
19
|
+
* (built `entry-runtime.js`, or a transformed `entry-runtime.ts` fallback), and
|
|
20
|
+
* - `GET /ns/entry[/<ver>]` — a script-safe wrapper that fetches the entry
|
|
21
|
+
* runtime and starts the app with `{ origin, main, ver }`.
|
|
22
|
+
*/
|
|
23
|
+
export function registerNsEntryRoutes(server, options) {
|
|
24
|
+
const verbose = options.verbose;
|
|
25
|
+
const APP_ROOT_DIR = options.appRootDir;
|
|
26
|
+
const DEFAULT_MAIN_ENTRY = options.defaultMainEntry;
|
|
27
|
+
const DEFAULT_MAIN_ENTRY_VIRTUAL = options.defaultMainEntryVirtual;
|
|
28
|
+
const getGraphVersion = options.getGraphVersion;
|
|
29
|
+
// 2.6a) Serve compiled entry runtime module: GET /ns/entry-rt[?v=<ver>]
|
|
30
|
+
server.middlewares.use(async (req, res, next) => {
|
|
31
|
+
try {
|
|
32
|
+
const urlObj = new URL(req.url || '', 'http://localhost');
|
|
33
|
+
if (!(urlObj.pathname === '/ns/entry-rt'))
|
|
34
|
+
return next();
|
|
35
|
+
if (verbose) {
|
|
36
|
+
const ra = req.socket?.remoteAddress;
|
|
37
|
+
const rp = req.socket?.remotePort;
|
|
38
|
+
console.log('[hmr-http] GET /ns/entry-rt from', ra + (rp ? ':' + rp : ''));
|
|
39
|
+
}
|
|
40
|
+
setDeviceModuleHeaders(res);
|
|
41
|
+
let content = '';
|
|
42
|
+
try {
|
|
43
|
+
const _req = createRequire(import.meta.url);
|
|
44
|
+
const entryRtPath = _req.resolve('@nativescript/vite/hmr/entry-runtime.js');
|
|
45
|
+
content = readFileSync(entryRtPath, 'utf-8');
|
|
46
|
+
}
|
|
47
|
+
catch (e) {
|
|
48
|
+
// .js not found (source tree without build) — transform .ts on the fly
|
|
49
|
+
try {
|
|
50
|
+
const tsPath = path.resolve(path.dirname(new URL(import.meta.url).pathname), '..', 'entry-runtime.ts');
|
|
51
|
+
if (existsSync(tsPath)) {
|
|
52
|
+
const tsSource = readFileSync(tsPath, 'utf-8');
|
|
53
|
+
const result = babelCore.transformSync(tsSource, {
|
|
54
|
+
filename: tsPath,
|
|
55
|
+
plugins: [[pluginTransformTypescript, { isTSX: false, allowDeclareFields: true }]],
|
|
56
|
+
sourceType: 'module',
|
|
57
|
+
});
|
|
58
|
+
if (result?.code) {
|
|
59
|
+
content = result.code;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
catch (e2) {
|
|
64
|
+
if (verbose)
|
|
65
|
+
console.warn('[hmr-http] entry-runtime.ts transform failed', e2);
|
|
66
|
+
}
|
|
67
|
+
if (!content) {
|
|
68
|
+
content = 'export default async function start(){ console.error("[/ns/entry-rt] not found"); }\n';
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (verbose)
|
|
72
|
+
console.log('[hmr-http] /ns/entry-rt serving', content.length, 'bytes');
|
|
73
|
+
res.statusCode = 200;
|
|
74
|
+
res.end(content);
|
|
75
|
+
}
|
|
76
|
+
catch (e) {
|
|
77
|
+
console.warn('[hmr-http] /ns/entry-rt error', e);
|
|
78
|
+
next();
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
// 2.6b) HTTP-only app entry endpoint: GET /ns/entry[/<ver>]
|
|
82
|
+
// Thin wrapper that imports the compiled entry runtime and starts it with parameters.
|
|
83
|
+
server.middlewares.use(async (req, res, next) => {
|
|
84
|
+
try {
|
|
85
|
+
const urlObj = new URL(req.url || '', 'http://localhost');
|
|
86
|
+
if (!(urlObj.pathname === '/ns/entry' || /^\/ns\/entry\/[\d]+$/.test(urlObj.pathname)))
|
|
87
|
+
return next();
|
|
88
|
+
try {
|
|
89
|
+
if (verbose) {
|
|
90
|
+
const ra = req.socket?.remoteAddress;
|
|
91
|
+
const rp = req.socket?.remotePort;
|
|
92
|
+
console.log('[hmr-http] GET /ns/entry from', ra + (rp ? ':' + rp : ''));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
catch { }
|
|
96
|
+
const verSeg = urlObj.pathname.replace(/^\/ns\/entry\/?/, '');
|
|
97
|
+
// Resolve app main entry to an absolute path-like key used by /ns/m
|
|
98
|
+
res.setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0');
|
|
99
|
+
res.setHeader('Pragma', 'no-cache');
|
|
100
|
+
res.setHeader('Expires', '0');
|
|
101
|
+
const ver = /^[0-9]+$/.test(verSeg) ? verSeg : String(getGraphVersion() || 0);
|
|
102
|
+
const origin = getServerOrigin(server) || `${urlObj.protocol}//${urlObj.host}`;
|
|
103
|
+
// Resolve app main entry to an absolute path-like key used by /ns/m
|
|
104
|
+
let mainEntry = '/';
|
|
105
|
+
try {
|
|
106
|
+
const pkg = getPackageJson();
|
|
107
|
+
const main = pkg?.main || DEFAULT_MAIN_ENTRY;
|
|
108
|
+
const abs = getProjectFilePath(main).replace(/\\/g, '/');
|
|
109
|
+
// Normalize to '/app/...'
|
|
110
|
+
const marker = `/${APP_ROOT_DIR}/`;
|
|
111
|
+
const idx = abs.indexOf(marker);
|
|
112
|
+
mainEntry = idx >= 0 ? abs.substring(idx) : DEFAULT_MAIN_ENTRY_VIRTUAL;
|
|
113
|
+
}
|
|
114
|
+
catch { }
|
|
115
|
+
// Build a tiny wrapper that imports the compiled entry runtime from the dev server
|
|
116
|
+
let code = REQUIRE_GUARD_SNIPPET +
|
|
117
|
+
`// [ns-entry][v${ver}] wrapper (script-safe) bytes will follow\n` +
|
|
118
|
+
`(async function(){\n` +
|
|
119
|
+
` let origin = ${JSON.stringify(origin)}; const main = ${JSON.stringify(mainEntry)}; const __ns_graph_ver = ${JSON.stringify(ver)};\n` +
|
|
120
|
+
` try { const __b = (globalThis && globalThis.__NS_ENTRY_BASE__) ? String(globalThis.__NS_ENTRY_BASE__) : ''; if (__b) { try { const __o = new URL(__b).origin; if (__o) origin = __o; } catch {} } } catch {}\n` +
|
|
121
|
+
` const __VERBOSE__ = (typeof __NS_ENV_VERBOSE__ !== 'undefined' && __NS_ENV_VERBOSE__) || (globalThis && globalThis.process && globalThis.process.env && globalThis.process.env.verbose) || (globalThis && globalThis.__NS_ENV_VERBOSE__) || ${JSON.stringify(!!verbose)};\n` +
|
|
122
|
+
` if (__VERBOSE__) console.info('[ns-entry][wrapper] start', { origin, main, ver: __ns_graph_ver });\n` +
|
|
123
|
+
` async function __ns_import_entry_rt(u){\n` +
|
|
124
|
+
` // Prefer fetch+eval script transformation to avoid module import limitations on device\n` +
|
|
125
|
+
` try { const r = await fetch(u); const t = await r.text(); if (__VERBOSE__) console.info('[ns-entry][wrapper] entry-rt fetched bytes', (t&&t.length)||0);\n` +
|
|
126
|
+
` // Transform 'export default function' or 'export default async function' into global assignment\n` +
|
|
127
|
+
` let s = t.replace(/export\\s+default\\s+async\\s+function\\s+([A-Za-z0-9_$]+)?/,'globalThis.__NS_START_ENTRY__=async function $1')\n` +
|
|
128
|
+
` .replace(/export\\s+default\\s+function\\s+([A-Za-z0-9_$]+)?/,'globalThis.__NS_START_ENTRY__=function $1');\n` +
|
|
129
|
+
` // Fallback: if function-form replacements didn't run, handle expression default export too\n` +
|
|
130
|
+
` if (String(s).indexOf('__NS_START_ENTRY__') === -1) { s = 'globalThis.__NS_START_ENTRY__=' + s.replace(/export\\s+default\\s*/,''); }\n` +
|
|
131
|
+
` try { (0,eval)(s); } catch (ee) { console.error('[ns-entry][wrapper] eval entry-rt failed', ee && (ee.message||ee)); throw ee; }\n` +
|
|
132
|
+
` const fn = globalThis.__NS_START_ENTRY__; if (!fn) { throw new Error('entry-rt missing __NS_START_ENTRY__'); }\n` +
|
|
133
|
+
` return { default: fn };\n` +
|
|
134
|
+
` } catch(e) { console.error('[ns-entry][wrapper] entry-rt fetch/eval failed', e && (e.message||e)); throw e; }\n` +
|
|
135
|
+
` }\n` +
|
|
136
|
+
` const __entryRtUrl = '/ns/entry-rt?v=' + String(__ns_graph_ver);\n` +
|
|
137
|
+
` let __mod; try { __mod = await __ns_import_entry_rt(__entryRtUrl); if (__VERBOSE__) console.info('[ns-entry][wrapper] entry-rt ready'); } catch (e) { console.error('[ns-entry][wrapper] failed to prepare entry-rt', e && (e.message||e)); throw e; }\n` +
|
|
138
|
+
` const startEntry = (__mod && (__mod.default || __mod));\n` +
|
|
139
|
+
` try { await startEntry({ origin, main, ver: __ns_graph_ver, verbose: !!__VERBOSE__ }); if (__VERBOSE__) console.info('[ns-entry][wrapper] startEntry() resolved'); } catch (e) { console.error('[ns-entry][wrapper] startEntry() failed', e && (e.message||e)); throw e; }\n` +
|
|
140
|
+
`})();\n`;
|
|
141
|
+
code = code + `\n//# sourceURL=${origin}/ns/entry`;
|
|
142
|
+
res.statusCode = 200;
|
|
143
|
+
res.end(code);
|
|
144
|
+
}
|
|
145
|
+
catch (e) {
|
|
146
|
+
next();
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
//# sourceMappingURL=websocket-ns-entry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"websocket-ns-entry.js","sourceRoot":"","sources":["../../../../../packages/vite/hmr/server/websocket-ns-entry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,OAAO,SAAS,MAAM,aAAa,CAAC;AAEpC,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,mEAAmE;AACnE,iEAAiE;AACjE,MAAM,yBAAyB,GAAQ,CAAC,GAAG,EAAE;IAC5C,MAAM,eAAe,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACvD,MAAM,MAAM,GAAG,eAAe,CAAC,oCAAoC,CAAC,CAAC;IACrE,OAAO,MAAM,EAAE,OAAO,IAAI,MAAM,CAAC;AAClC,CAAC,CAAC,EAAE,CAAC;AAeL;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAAqB,EAAE,OAAqC;IACjG,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAChC,MAAM,YAAY,GAAG,OAA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tE,4PAA4P;gBAC5P,6DAA6D;gBAC7D,gRAAgR;gBAChR,SAAS,CAAC;YACX,IAAI,GAAG,IAAI,GAAG,mBAAmB,MAAM,WAAW,CAAC;YACnD,GAAG,CAAC,UAAU,GAAG,GAAG,CAAC;YACrB,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACf,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACZ,IAAI,EAAE,CAAC;QACR,CAAC;IACF,CAAC,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare function formatNsMHmrServeTag(value: string | number): string;
|
|
2
|
+
export declare function rewriteNsMImportPathForHmr(p: string, _ver: string | number, bootTaggedRequest: boolean): string;
|
|
3
|
+
export declare function getNumericServeVersionTag(tag: string | null | undefined, fallback: number): number;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// Stable URL + explicit invalidation contract for `/ns/m/...` modules.
|
|
2
|
+
//
|
|
3
|
+
// Older versions emitted `/ns/m/__ns_hmr__/v<N>/<rel>` URLs in every
|
|
4
|
+
// served module so that V8's HTTP module cache (`g_moduleRegistry`)
|
|
5
|
+
// would see a fresh URL on each save and re-fetch the dependency
|
|
6
|
+
// closure. On every save the server also bumped a global `graphVersion`
|
|
7
|
+
// counter, which propagated into every emitted URL — effectively
|
|
8
|
+
// invalidating the ENTIRE cached graph on every save (Vite's
|
|
9
|
+
// single-threaded transform pipeline became the wall-clock bottleneck).
|
|
10
|
+
//
|
|
11
|
+
// The current contract inverts that:
|
|
12
|
+
// - The runtime registers a canonical key for every URL via
|
|
13
|
+
// `CanonicalizeHttpUrlKey` (HMRSupport.mm), which strips
|
|
14
|
+
// `__ns_hmr__/<tag>/` and `__ns_boot__/b1/` segments before lookup.
|
|
15
|
+
// - The Angular HMR client receives an explicit `evictPaths` list in
|
|
16
|
+
// `ns:angular-update` and calls `__nsInvalidateModules` to drop only
|
|
17
|
+
// the modules that actually need re-evaluation.
|
|
18
|
+
// - The server emits STABLE URLs for app modules. No version segment.
|
|
19
|
+
//
|
|
20
|
+
// `rewriteNsMImportPathForHmr` collapses any inbound URL shape to the
|
|
21
|
+
// canonical stable form. We still preserve `__ns_boot__/b1/` for
|
|
22
|
+
// boot-tagged requests because that wrapper drives boot-progress
|
|
23
|
+
// instrumentation (see `buildBootProgressSnippet`), and we still pass
|
|
24
|
+
// `node_modules` through unchanged because vendor packages live on a
|
|
25
|
+
// stable namespace already.
|
|
26
|
+
export function formatNsMHmrServeTag(value) {
|
|
27
|
+
const raw = String(value ?? '').trim();
|
|
28
|
+
if (!raw) {
|
|
29
|
+
return 'v0';
|
|
30
|
+
}
|
|
31
|
+
if (raw === 'live' || /^n\d+$/i.test(raw) || /^v[^/]+$/i.test(raw)) {
|
|
32
|
+
return raw;
|
|
33
|
+
}
|
|
34
|
+
if (/^\d+$/.test(raw)) {
|
|
35
|
+
return `v${raw}`;
|
|
36
|
+
}
|
|
37
|
+
return raw;
|
|
38
|
+
}
|
|
39
|
+
export function rewriteNsMImportPathForHmr(p, _ver, bootTaggedRequest) {
|
|
40
|
+
if (!p || !p.startsWith('/ns/m/')) {
|
|
41
|
+
return p;
|
|
42
|
+
}
|
|
43
|
+
// Step 1: collapse any legacy boot+hmr or hmr-only prefix back to the
|
|
44
|
+
// canonical `/ns/m/<rest>` form. Inputs we may see in the wild include:
|
|
45
|
+
// * `/ns/m/__ns_boot__/b1/__ns_hmr__/v<N>/<rest>` (legacy cold-boot
|
|
46
|
+
// served code)
|
|
47
|
+
// * `/ns/m/__ns_hmr__/v<N>/<rest>` (legacy HMR served code)
|
|
48
|
+
// * `/ns/m/__ns_boot__/b1/<rest>` (current cold boot)
|
|
49
|
+
// * `/ns/m/<rest>` (current HMR)
|
|
50
|
+
// We strip `__ns_hmr__/<tag>/` regardless of `<tag>` (handles `live`,
|
|
51
|
+
// `v<N>`, `n<N>`, anything matched by `formatNsMHmrServeTag`). The
|
|
52
|
+
// `__ns_boot__/b1/` segment is stripped here too — we'll re-add it
|
|
53
|
+
// below if `bootTaggedRequest` is set, so the canonicalization is
|
|
54
|
+
// idempotent (a boot URL that flows through twice ends up correct).
|
|
55
|
+
let canonical = p
|
|
56
|
+
.replace(/^\/ns\/m\/__ns_boot__\/b1\/__ns_hmr__\/[^/]+\//, '/ns/m/')
|
|
57
|
+
.replace(/^\/ns\/m\/__ns_hmr__\/[^/]+\//, '/ns/m/')
|
|
58
|
+
.replace(/^\/ns\/m\/__ns_boot__\/b1\//, '/ns/m/');
|
|
59
|
+
// Vendor packages: always serve under the canonical
|
|
60
|
+
// `/ns/m/node_modules/<rest>` path, never under the boot prefix. This
|
|
61
|
+
// preserves the longstanding invariant that node_modules paths are
|
|
62
|
+
// stable across boot and HMR (so V8 dedups them in the module
|
|
63
|
+
// registry regardless of which load triggered the fetch first).
|
|
64
|
+
if (canonical.startsWith('/ns/m/node_modules/')) {
|
|
65
|
+
return canonical;
|
|
66
|
+
}
|
|
67
|
+
// Boot-tagged request: app-module URL gets wrapped with the boot
|
|
68
|
+
// prefix. The runtime canonicalizer collapses this back to the same
|
|
69
|
+
// cache key as the unprefixed URL, so cold boot and HMR share module
|
|
70
|
+
// identity. The boot prefix is still useful at request time because
|
|
71
|
+
// the server detects it and injects the boot-progress snippet.
|
|
72
|
+
if (bootTaggedRequest) {
|
|
73
|
+
return `/ns/m/__ns_boot__/b1${canonical.slice('/ns/m'.length)}`;
|
|
74
|
+
}
|
|
75
|
+
// HMR / steady-state request: stable canonical URL.
|
|
76
|
+
return canonical;
|
|
77
|
+
}
|
|
78
|
+
export function getNumericServeVersionTag(tag, fallback) {
|
|
79
|
+
const raw = String(tag || '').trim();
|
|
80
|
+
if (!raw) {
|
|
81
|
+
return fallback;
|
|
82
|
+
}
|
|
83
|
+
const versionMatch = raw.match(/^v(\d+)$/);
|
|
84
|
+
if (versionMatch?.[1]) {
|
|
85
|
+
return Number(versionMatch[1]);
|
|
86
|
+
}
|
|
87
|
+
if (/^\d+$/.test(raw)) {
|
|
88
|
+
return Number(raw);
|
|
89
|
+
}
|
|
90
|
+
return fallback;
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=websocket-ns-m-paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"websocket-ns-m-paths.js","sourceRoot":"","sources":["../../../../../packages/vite/hmr/server/websocket-ns-m-paths.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,EAAE;AACF,qEAAqE;AACrE,oEAAoE;AACpE,iEAAiE;AACjE,wEAAwE;AACxE,iEAAiE;AACjE,6DAA6D;AAC7D,wEAAwE;AACxE,EAAE;AACF,qCAAqC;AACrC,8DAA8D;AAC9D,6DAA6D;AAC7D,wEAAwE;AACxE,uEAAuE;AACvE,yEAAyE;AACzE,oDAAoD;AACpD,wEAAwE;AACxE,EAAE;AACF,sEAAsE;AACtE,iEAAiE;AACjE,iEAAiE;AACjE,sEAAsE;AACtE,qEAAqE;AACrE,4BAA4B;AAE5B,MAAM,UAAU,oBAAoB,CAAC,KAAsB;IAC1D,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IACvC,IAAI,CAAC,GAAG,EAAE,CAAC;QACV,OAAO,IAAI,CAAC;IACb,CAAC;IACD,IAAI,GAAG,KAAK,MAAM,IAAI,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACpE,OAAO,GAAG,CAAC;IACZ,CAAC;IACD,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACvB,OAAO,IAAI,GAAG,EAAE,CAAC;IAClB,CAAC;IACD,OAAO,GAAG,CAAC;AACZ,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,CAAS,EAAE,IAAqB,EAAE,iBAA0B;IACtG,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ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