@nativescript/vite 8.0.0-alpha.3 → 8.0.0-alpha.30
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 +369 -159
- 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/angular/angular-linker.d.ts +5 -6
- package/helpers/angular/angular-linker.js +36 -121
- package/helpers/angular/angular-linker.js.map +1 -1
- package/helpers/angular/inject-component-hmr-registration.d.ts +112 -0
- package/helpers/angular/inject-component-hmr-registration.js +291 -0
- package/helpers/angular/inject-component-hmr-registration.js.map +1 -0
- package/helpers/angular/inject-hmr-vite-ignore.d.ts +75 -0
- package/helpers/angular/inject-hmr-vite-ignore.js +221 -0
- package/helpers/angular/inject-hmr-vite-ignore.js.map +1 -0
- package/helpers/angular/inline-decorator-component-templates.js +1 -170
- package/helpers/angular/inline-decorator-component-templates.js.map +1 -1
- package/helpers/angular/js-lexer.d.ts +4 -0
- package/helpers/angular/js-lexer.js +182 -0
- package/helpers/angular/js-lexer.js.map +1 -0
- package/helpers/angular/shared-linker.d.ts +31 -3
- package/helpers/angular/shared-linker.js +67 -14
- package/helpers/angular/shared-linker.js.map +1 -1
- package/helpers/angular/synthesize-decorator-ctor-parameters.js +2 -170
- package/helpers/angular/synthesize-decorator-ctor-parameters.js.map +1 -1
- package/helpers/angular/synthesize-injectable-factories.js +1 -174
- package/helpers/angular/synthesize-injectable-factories.js.map +1 -1
- package/helpers/angular/util.d.ts +1 -0
- package/helpers/angular/util.js +88 -0
- package/helpers/angular/util.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/prelink-angular.js +12 -33
- package/helpers/prelink-angular.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/resolver.js +17 -2
- package/helpers/resolver.js.map +1 -1
- package/helpers/solid-jsx-deps.d.ts +15 -0
- package/helpers/solid-jsx-deps.js +178 -0
- package/helpers/solid-jsx-deps.js.map +1 -0
- 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/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 +419 -15
- 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/client/vue-sfc-update-overlay.d.ts +82 -0
- package/hmr/client/vue-sfc-update-overlay.js +133 -0
- package/hmr/client/vue-sfc-update-overlay.js.map +1 -0
- 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/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/server/linker.js +1 -4
- package/hmr/frameworks/angular/server/linker.js.map +1 -1
- package/hmr/frameworks/angular/server/strategy.js +13 -15
- package/hmr/frameworks/angular/server/strategy.js.map +1 -1
- package/hmr/frameworks/solid/server/strategy.js +3 -18
- package/hmr/frameworks/solid/server/strategy.js.map +1 -1
- package/hmr/frameworks/typescript/server/strategy.js +2 -15
- 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/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/angular-root-component.d.ts +79 -0
- package/hmr/server/angular-root-component.js +149 -0
- package/hmr/server/angular-root-component.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/framework-strategy.d.ts +9 -19
- 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.js +60 -8
- package/hmr/server/import-map.js.map +1 -1
- package/hmr/server/index.js +1 -0
- 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/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/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/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-angular-entry.js +1 -1
- package/hmr/server/websocket-angular-entry.js.map +1 -1
- package/hmr/server/websocket-angular-hot-update.d.ts +17 -0
- package/hmr/server/websocket-angular-hot-update.js +176 -2
- package/hmr/server/websocket-angular-hot-update.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 +21 -0
- package/hmr/server/websocket-device-transform.js +1570 -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 +43 -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 +51 -0
- package/hmr/server/websocket-hot-update.js +1160 -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 +44 -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 +305 -0
- package/hmr/server/websocket-ns-core.js.map +1 -0
- package/hmr/server/websocket-ns-entry.d.ts +22 -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 +34 -0
- package/hmr/server/websocket-ns-m.js +853 -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-sfc.d.ts +24 -0
- package/hmr/server/websocket-sfc.js +1223 -0
- package/hmr/server/websocket-sfc.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 +10 -0
- package/hmr/server/websocket-vendor-unifier.js +45 -0
- package/hmr/server/websocket-vendor-unifier.js.map +1 -0
- package/hmr/server/websocket.d.ts +0 -30
- package/hmr/server/websocket.js +599 -6038
- package/hmr/server/websocket.js.map +1 -1
- 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 +32 -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 -5
- package/hmr/shared/vendor/manifest.js +102 -739
- 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
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { matchesRuntimeGraphModuleId } from './runtime-graph-filter.js';
|
|
2
|
+
import { classifyGraphUpsert, shouldBroadcastGraphUpsertDelta, shouldBumpGraphVersion } from './websocket-graph-upsert.js';
|
|
3
|
+
import { getProjectAppVirtualPath } from '../../helpers/utils.js';
|
|
4
|
+
const APP_VIRTUAL_WITH_SLASH = `${getProjectAppVirtualPath()}/`;
|
|
5
|
+
// The HMR module graph: spec -> { deps, hash } plus a monotonically increasing
|
|
6
|
+
// version used to tag served module URLs. Owns delta/full-graph broadcasts to
|
|
7
|
+
// connected clients and the per-version transactional batch ordering.
|
|
8
|
+
//
|
|
9
|
+
// version starts at 1 so the very first /ns/m response uses a stable `v1` URL
|
|
10
|
+
// tag; it stays stable during cold boot (bulk warm-ups pass bumpVersion:false)
|
|
11
|
+
// and only advances on live edits, which prevents double-loads as the graph
|
|
12
|
+
// fills in lazily.
|
|
13
|
+
export class HmrModuleGraph {
|
|
14
|
+
constructor(deps) {
|
|
15
|
+
this.deps = deps;
|
|
16
|
+
this.modules = new Map();
|
|
17
|
+
// Transactional HMR batches: version -> ordered list of changed ids for that version.
|
|
18
|
+
this.txnBatches = new Map();
|
|
19
|
+
this._version = 1;
|
|
20
|
+
}
|
|
21
|
+
get version() {
|
|
22
|
+
return this._version;
|
|
23
|
+
}
|
|
24
|
+
get size() {
|
|
25
|
+
return this.modules.size;
|
|
26
|
+
}
|
|
27
|
+
get(id) {
|
|
28
|
+
return this.modules.get(id);
|
|
29
|
+
}
|
|
30
|
+
getTxnBatch(version) {
|
|
31
|
+
return this.txnBatches.get(version) || [];
|
|
32
|
+
}
|
|
33
|
+
computeHash(content) {
|
|
34
|
+
let h = 0;
|
|
35
|
+
for (let i = 0; i < content.length; i++) {
|
|
36
|
+
h = (h * 31 + content.charCodeAt(i)) | 0;
|
|
37
|
+
}
|
|
38
|
+
return ('00000000' + (h >>> 0).toString(16)).slice(-8);
|
|
39
|
+
}
|
|
40
|
+
normalizeGraphId(raw) {
|
|
41
|
+
if (!raw)
|
|
42
|
+
return raw;
|
|
43
|
+
let id = raw.split('?')[0].replace(/\\/g, '/');
|
|
44
|
+
id = id.replace(/^file:\/\//, '');
|
|
45
|
+
const pluginRoot = this.deps.getPluginRoot();
|
|
46
|
+
if (pluginRoot) {
|
|
47
|
+
const rootNorm = pluginRoot.replace(/\\/g, '/');
|
|
48
|
+
if (id.startsWith(rootNorm)) {
|
|
49
|
+
id = id.slice(rootNorm.length);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (!id.startsWith('/'))
|
|
53
|
+
id = '/' + id;
|
|
54
|
+
// Collapse nested app root indicators when present (defensive)
|
|
55
|
+
const idx = id.indexOf(APP_VIRTUAL_WITH_SLASH);
|
|
56
|
+
if (idx !== -1)
|
|
57
|
+
id = id.slice(idx);
|
|
58
|
+
return id;
|
|
59
|
+
}
|
|
60
|
+
// Dependency-closed, topologically sorted list of modules for a set of
|
|
61
|
+
// changed ids. Only includes application modules we can serve (under the
|
|
62
|
+
// app virtual root and known framework/.ts/.js entries already in the graph).
|
|
63
|
+
computeTxnOrderForChanged(changedIds) {
|
|
64
|
+
const { strategy } = this.deps;
|
|
65
|
+
const includeAppModule = (id) => matchesRuntimeGraphModuleId(id, APP_VIRTUAL_WITH_SLASH, /\.(ts|js|mjs|tsx|jsx)$/i);
|
|
66
|
+
const includeExt = (id) => strategy.matchesFile(id) || includeAppModule(id);
|
|
67
|
+
const isApp = (id) => id.startsWith(APP_VIRTUAL_WITH_SLASH);
|
|
68
|
+
const roots = changedIds.map((id) => this.normalizeGraphId(id)).filter((id) => this.modules.has(id) && (isApp(id) || strategy.matchesFile(id)) && includeExt(id));
|
|
69
|
+
const toVisit = new Set();
|
|
70
|
+
const stack = [...roots];
|
|
71
|
+
while (stack.length) {
|
|
72
|
+
const id = stack.pop();
|
|
73
|
+
if (toVisit.has(id))
|
|
74
|
+
continue;
|
|
75
|
+
toVisit.add(id);
|
|
76
|
+
const m = this.modules.get(id);
|
|
77
|
+
if (m) {
|
|
78
|
+
for (const d of m.deps) {
|
|
79
|
+
if (!this.modules.has(d))
|
|
80
|
+
continue;
|
|
81
|
+
if ((isApp(d) || strategy.matchesFile(d)) && includeExt(d) && !toVisit.has(d)) {
|
|
82
|
+
stack.push(d);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
// Topological order: deps first (post-order DFS)
|
|
88
|
+
const ordered = [];
|
|
89
|
+
const temp = new Set();
|
|
90
|
+
const perm = new Set();
|
|
91
|
+
const visit = (id) => {
|
|
92
|
+
if (perm.has(id))
|
|
93
|
+
return;
|
|
94
|
+
if (temp.has(id)) {
|
|
95
|
+
perm.add(id);
|
|
96
|
+
return;
|
|
97
|
+
} // cycle: bail out
|
|
98
|
+
temp.add(id);
|
|
99
|
+
const m = this.modules.get(id);
|
|
100
|
+
if (m) {
|
|
101
|
+
for (const d of m.deps) {
|
|
102
|
+
if (toVisit.has(d))
|
|
103
|
+
visit(d);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
temp.delete(id);
|
|
107
|
+
perm.add(id);
|
|
108
|
+
ordered.push(id);
|
|
109
|
+
};
|
|
110
|
+
for (const id of toVisit)
|
|
111
|
+
visit(id);
|
|
112
|
+
return ordered;
|
|
113
|
+
}
|
|
114
|
+
fullGraphPayload() {
|
|
115
|
+
return {
|
|
116
|
+
type: 'ns:hmr-full-graph',
|
|
117
|
+
version: this._version,
|
|
118
|
+
modules: Array.from(this.modules.values()).map((m) => ({
|
|
119
|
+
id: m.id,
|
|
120
|
+
deps: m.deps,
|
|
121
|
+
hash: m.hash,
|
|
122
|
+
})),
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
emitFullGraph(ws) {
|
|
126
|
+
try {
|
|
127
|
+
if (this.deps.verbose) {
|
|
128
|
+
try {
|
|
129
|
+
const payload = this.fullGraphPayload();
|
|
130
|
+
console.log('[hmr-ws][graph] emitFullGraph version', payload.version, 'modules=', payload.modules.length);
|
|
131
|
+
if (payload.modules.length) {
|
|
132
|
+
console.log('[hmr-ws][graph] sample module ids', payload.modules.slice(0, 5).map((m) => m.id));
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
catch { }
|
|
136
|
+
}
|
|
137
|
+
ws.send(JSON.stringify(this.fullGraphPayload()));
|
|
138
|
+
}
|
|
139
|
+
catch { }
|
|
140
|
+
}
|
|
141
|
+
emitDelta(changed, removed) {
|
|
142
|
+
const wss = this.deps.getWss();
|
|
143
|
+
if (!wss)
|
|
144
|
+
return;
|
|
145
|
+
// Record this version's txn batch order
|
|
146
|
+
try {
|
|
147
|
+
const changedIds = changed.map((m) => m.id);
|
|
148
|
+
if (changedIds.length) {
|
|
149
|
+
const ordered = this.computeTxnOrderForChanged(changedIds);
|
|
150
|
+
this.txnBatches.set(this._version, ordered);
|
|
151
|
+
// Keep only the last ~20 versions
|
|
152
|
+
if (this.txnBatches.size > 20) {
|
|
153
|
+
const drop = Array.from(this.txnBatches.keys())
|
|
154
|
+
.sort((a, b) => a - b)
|
|
155
|
+
.slice(0, this.txnBatches.size - 20);
|
|
156
|
+
for (const k of drop)
|
|
157
|
+
this.txnBatches.delete(k);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
catch { }
|
|
162
|
+
const payload = {
|
|
163
|
+
type: 'ns:hmr-delta',
|
|
164
|
+
baseVersion: this._version - 1,
|
|
165
|
+
newVersion: this._version,
|
|
166
|
+
changed: changed.map((m) => ({ id: m.id, deps: m.deps, hash: m.hash })),
|
|
167
|
+
removed,
|
|
168
|
+
};
|
|
169
|
+
const json = JSON.stringify(payload);
|
|
170
|
+
wss.clients.forEach((c) => {
|
|
171
|
+
try {
|
|
172
|
+
c.send(json);
|
|
173
|
+
}
|
|
174
|
+
catch { }
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
upsert(rawId, code, deps, options) {
|
|
178
|
+
const id = this.normalizeGraphId(rawId);
|
|
179
|
+
const normDeps = deps
|
|
180
|
+
.map((d) => this.normalizeGraphId(d))
|
|
181
|
+
.filter(Boolean)
|
|
182
|
+
.slice()
|
|
183
|
+
.sort();
|
|
184
|
+
const hash = this.computeHash(code);
|
|
185
|
+
const existing = this.modules.get(id);
|
|
186
|
+
const classification = classifyGraphUpsert(existing, hash, normDeps);
|
|
187
|
+
if (classification === 'unchanged')
|
|
188
|
+
return existing;
|
|
189
|
+
// Version bumps are only meaningful for live edits — serve-time graph
|
|
190
|
+
// warm-ups and the initial bulk walk should leave the version stable.
|
|
191
|
+
const bumpVersion = shouldBumpGraphVersion(classification, options?.bumpVersion !== false);
|
|
192
|
+
if (bumpVersion) {
|
|
193
|
+
this._version++;
|
|
194
|
+
}
|
|
195
|
+
const gm = { id, deps: normDeps, hash };
|
|
196
|
+
this.modules.set(id, gm);
|
|
197
|
+
if (this.deps.verbose) {
|
|
198
|
+
console.log('[hmr-ws][graph] upsert', { id, deps: normDeps, hash, graphVersion: this._version, classification, bumpVersion });
|
|
199
|
+
console.log('[hmr-ws][graph] size', this.modules.size);
|
|
200
|
+
}
|
|
201
|
+
if (shouldBroadcastGraphUpsertDelta(classification, options?.emitDeltaOnInsert === true, options?.broadcastDelta !== false)) {
|
|
202
|
+
this.emitDelta([gm], []);
|
|
203
|
+
}
|
|
204
|
+
return gm;
|
|
205
|
+
}
|
|
206
|
+
remove(id) {
|
|
207
|
+
if (!this.modules.has(id))
|
|
208
|
+
return;
|
|
209
|
+
this.modules.delete(id);
|
|
210
|
+
this._version++;
|
|
211
|
+
this.emitDelta([], [id]);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
//# sourceMappingURL=hmr-module-graph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hmr-module-graph.js","sourceRoot":"","sources":["../../../../../packages/vite/hmr/server/hmr-module-graph.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AACxE,OAAO,EAAE,mBAAmB,EAAE,+BAA+B,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAC3H,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAElE,MAAM,sBAAsB,GAAG,GAAG,wBAAwB,EAAE,GAAG,CAAC;AAwBhE,+EAA+E;AAC/E,8EAA8E;AAC9E,sEAAsE;AACtE,EAAE;AACF,8EAA8E;AAC9E,+EAA+E;AAC/E,4EAA4E;AAC5E,mBAAmB;AACnB,MAAM,OAAO,cAAc;IAM1B,YAA6B,IAAwB;QAAxB,SAAI,GAAJ,IAAI,CAAoB;QAL5C,YAAO,GAAG,IAAI,GAAG,EAAuB,CAAC;QAClD,sFAAsF;QACrE,eAAU,GAAG,IAAI,GAAG,EAAoB,CAAC;QAClD,aAAQ,GAAG,CAAC,CAAC;IAEmC,CAAC;IAEzD,IAAI,OAAO;QACV,OAAO,IAAI,CAAC,QAAQ,CAAC;IACtB,CAAC;IAED,IAAI,IAA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AAC,EAAU;QAChB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;YAAE,OAAO;QAClC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACxB,IAAI,CAAC,QAAQ,EAAE,CAAC;QAChB,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAC1B,CAAC;CACD"}
|
package/hmr/server/import-map.js
CHANGED
|
@@ -24,6 +24,7 @@ import { getVendorManifest, listVendorModules } from '../shared/vendor/registry.
|
|
|
24
24
|
import { readFileSync, readdirSync, existsSync } from 'fs';
|
|
25
25
|
import { resolve, join } from 'path';
|
|
26
26
|
import { getProjectRootPath } from '../../helpers/project.js';
|
|
27
|
+
import { buildCoreUrl } from '../../helpers/ns-core-url.js';
|
|
27
28
|
const OMIT_DEVICE_IMPORT_MAP_PACKAGES = new Set(['typescript', 'ts-node', 'esbuild', 'prettier', 'webpack', 'vite', '@nativescript/android', '@nativescript/ios', '@nativescript/visionos', '@nativescript/webpack', '@nativescript/types']);
|
|
28
29
|
const OMIT_DEVICE_IMPORT_MAP_PREFIXES = ['@types/', '@babel/', 'babel-', '@rollup/', '@vitejs/', 'vite-plugin-', '@angular-devkit/', '@angular/build', '@analogjs/'];
|
|
29
30
|
const PREFIX_ONLY_DEVICE_IMPORT_MAP_PACKAGES = new Set(['@nativescript/vite']);
|
|
@@ -65,22 +66,56 @@ export function generateImportMap(options) {
|
|
|
65
66
|
if (manifest) {
|
|
66
67
|
// Map vendor modules to ns-vendor:// — EXACT entries only.
|
|
67
68
|
// No trailing-slash prefixes: subpaths must resolve via HTTP, not vendor.
|
|
69
|
+
//
|
|
70
|
+
// IMPORTANT: `@nativescript/core` and any `@nativescript/core/<sub>` are
|
|
71
|
+
// deliberately routed through the HTTP bridge (`${origin}/ns/core/...`),
|
|
72
|
+
// NEVER through `ns-vendor://`. Two reasons:
|
|
73
|
+
// 1. Single realm. The core bridge is the canonical source for every
|
|
74
|
+
// `Application`, `View`, `Frame`, etc. instance — having a second
|
|
75
|
+
// copy in the vendor registry produces the classic
|
|
76
|
+
// `vendorApplicationSame: false` realm split (different
|
|
77
|
+
// `globalThis.Application` than the one the iOS/Android hooks
|
|
78
|
+
// patched) and HMR placeholder finalize stalls.
|
|
79
|
+
// 2. Chicken-and-egg. esbuild's vendor build externalizes
|
|
80
|
+
// `@nativescript/core(/...)` (see `nsCoreExternalPlugin` in
|
|
81
|
+
// `manifest.ts`), so the externalized `import` statements stay
|
|
82
|
+
// in `vendor.mjs` itself. If those externals resolve through
|
|
83
|
+
// `ns-vendor://`, the synthetic wrapper module's evaluation
|
|
84
|
+
// runs DURING `vendor.mjs` linking — but `vendor-bootstrap`
|
|
85
|
+
// hasn't populated `__nsVendorRegistry` yet (it runs LATER,
|
|
86
|
+
// from the clientUrl module body), so every wrapper throws
|
|
87
|
+
// `Vendor module not found in registry: @nativescript/core/...`.
|
|
88
|
+
// Routing core through the HTTP bridge sidesteps the registry
|
|
89
|
+
// lookup entirely; the dev server normalizes platform suffixes
|
|
90
|
+
// (see `normalizeCoreSub` in `ns-core-url.ts`) so
|
|
91
|
+
// `@nativescript/core/ui/frame/activity.android` → bridge URL
|
|
92
|
+
// `/ns/core/ui/frame/activity.android` → served from the
|
|
93
|
+
// platform-specific `.android.ts` source.
|
|
68
94
|
const vendorModules = listVendorModules();
|
|
69
95
|
for (const specifier of vendorModules) {
|
|
96
|
+
if (specifier === '@nativescript/core' || specifier.startsWith('@nativescript/core/')) {
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
70
99
|
imports[specifier] = `ns-vendor://${specifier}`;
|
|
71
100
|
}
|
|
72
101
|
// Map aliases from the manifest (e.g., "solid-js/web" → ns-vendor://solid-js)
|
|
73
102
|
if (manifest.aliases) {
|
|
74
103
|
for (const [alias, canonical] of Object.entries(manifest.aliases)) {
|
|
104
|
+
// Same single-realm + chicken-and-egg reasons as above.
|
|
105
|
+
if (alias === '@nativescript/core' || alias.startsWith('@nativescript/core/')) {
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
75
108
|
if (!imports[alias] && imports[canonical]) {
|
|
76
109
|
imports[alias] = imports[canonical];
|
|
77
110
|
}
|
|
78
111
|
}
|
|
79
112
|
}
|
|
80
113
|
}
|
|
81
|
-
// @nativescript/core → bridge endpoint
|
|
82
|
-
|
|
83
|
-
imports
|
|
114
|
+
// @nativescript/core → bridge endpoint (canonical URL generator).
|
|
115
|
+
// The trailing-slash entry intentionally uses the same generator so
|
|
116
|
+
// subpath imports resolve via `${origin}/ns/core/<sub>`.
|
|
117
|
+
imports['@nativescript/core'] = buildCoreUrl(origin);
|
|
118
|
+
imports['@nativescript/core/'] = `${buildCoreUrl(origin)}/`;
|
|
84
119
|
// Add framework-specific entries
|
|
85
120
|
addFrameworkEntries(imports, origin, flavor);
|
|
86
121
|
// Scan installed packages and add HTTP URL entries for ALL packages
|
|
@@ -128,7 +163,7 @@ export function buildRuntimeConfig(options) {
|
|
|
128
163
|
volatilePatterns,
|
|
129
164
|
};
|
|
130
165
|
}
|
|
131
|
-
function addFrameworkEntries(imports,
|
|
166
|
+
function addFrameworkEntries(imports, origin, flavor) {
|
|
132
167
|
switch (flavor) {
|
|
133
168
|
case 'vue':
|
|
134
169
|
// nativescript-vue should resolve from vendor if available
|
|
@@ -140,10 +175,27 @@ function addFrameworkEntries(imports, _origin, flavor) {
|
|
|
140
175
|
}
|
|
141
176
|
break;
|
|
142
177
|
case 'solid':
|
|
143
|
-
// Solid runtime root
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
178
|
+
// Solid runtime root MUST resolve to the same HTTP URL that
|
|
179
|
+
// Vite's solid-js alias produces for user code and the
|
|
180
|
+
// HTTP-served `@solid-refresh` middleware. The vendor bundle
|
|
181
|
+
// no longer ships `solid-js` for the Solid flavor — see
|
|
182
|
+
// `manifest.ts`'s `nsSolidJsExternalPlugin` + the matching
|
|
183
|
+
// `addCandidate` skip — so all three import sites (vendor's
|
|
184
|
+
// externalized `import 'solid-js'`, user code's
|
|
185
|
+
// alias-rewritten `/ns/m/node_modules/solid-js/...`, and
|
|
186
|
+
// `@solid-refresh`'s own rewritten import) converge on the
|
|
187
|
+
// dev.js URL below. V8's ESM loader dedupes by URL, so the
|
|
188
|
+
// app sees one `Owner` module-local, one `$DEVCOMP`/`$PROXY`
|
|
189
|
+
// symbol identity, and one reactive graph end-to-end. Without
|
|
190
|
+
// this unification, `solid-refresh`'s `setComp` ticks a
|
|
191
|
+
// signal whose subscribers live in a different solid-js
|
|
192
|
+
// realm than the page tree's render effect → HMR appears to
|
|
193
|
+
// fire (toast shows) but the screen never re-renders, and
|
|
194
|
+
// boot logs the `computations created outside a createRoot`
|
|
195
|
+
// warning because solid-refresh's HMRComp memo is created in
|
|
196
|
+
// the HTTP-side solid-js whose `Owner` was never set by the
|
|
197
|
+
// vendor-side `render()` createRoot.
|
|
198
|
+
imports['solid-js'] = `${origin}/ns/m/node_modules/solid-js/dist/dev.js`;
|
|
147
199
|
// No trailing-slash prefix — subpaths like solid-js/store,
|
|
148
200
|
// solid-js/jsx-runtime resolve via HTTP from discoverInstalledPackages()
|
|
149
201
|
break;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import-map.js","sourceRoot":"","sources":["../../../../../packages/vite/hmr/server/import-map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACpF,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"import-map.js","sourceRoot":"","sources":["../../../../../packages/vite/hmr/server/import-map.ts"],"names":[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AAC,cAAc,EAAE,IAAI,CAAC,CAAC;gBAC5C,IAAI,CAAC;oBACJ,MAAM,YAAY,GAAG,WAAW,CAAC,QAAQ,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;oBACpE,KAAK,MAAM,UAAU,IAAI,YAAY,EAAE,CAAC;wBACvC,IAAI,CAAC,UAAU,CAAC,WAAW,EAAE,IAAI,CAAC,UAAU,CAAC,cAAc,EAAE;4BAAE,SAAS;wBACxE,IAAI,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;4BAAE,SAAS;wBAC9C,UAAU,CAAC,GAAG,IAAI,IAAI,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC;oBAC1C,CAAC;gBACF,CAAC;gBAAC,MAAM,CAAC,CAAA,CAAC;YACX,CAAC;iBAAM,CAAC;gBACP,UAAU,CAAC,IAAI,CAAC,CAAC;YAClB,CAAC;QACF,CAAC;IACF,CAAC;IAAC,MAAM,CAAC,CAAA,CAAC;AACX,CAAC"}
|
package/hmr/server/index.js
CHANGED
package/hmr/server/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/vite/hmr/server/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAEjH,MAAM,UAAU,aAAa,CAAC,IAAmE;IAChG,MAAM,OAAO,GAAG,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC,CAAC;IAC9C,QAAQ,IAAI,CAAC,MAAM,EAAE,CAAC;QACrB,KAAK,KAAK;YACT,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC;YACpC,MAAM;QACP,KAAK,OAAO;YACX,MAAM;QACP,KAAK,SAAS;YACb,OAAO,CAAC,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC;YACxC,MAAM;QACP,KAAK,YAAY;YAChB,OAAO,CAAC,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAC,CAAC;YAC3C,MAAM;QACP,KAAK,OAAO;YACX,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC;YACtC,MAAM;IACR,CAAC;IACD,OAAO,OAAO,CAAC;AAChB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/vite/hmr/server/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAEjH,MAAM,UAAU,aAAa,CAAC,IAAmE;IAChG,MAAM,OAAO,GAAG,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC,CAAC;IAC9C,QAAQ,IAAI,CAAC,MAAM,EAAE,CAAC;QACrB,KAAK,KAAK;YACT,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC;YACpC,MAAM;QACP,KAAK,OAAO;YACX,iFAAiF;YACjF,MAAM;QACP,KAAK,SAAS;YACb,OAAO,CAAC,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC;YACxC,MAAM;QACP,KAAK,YAAY;YAChB,OAAO,CAAC,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAC,CAAC;YAC3C,MAAM;QACP,KAAK,OAAO;YACX,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC;YACtC,MAAM;IACR,CAAC;IACD,OAAO,OAAO,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CJS/ESM interop shape.
|
|
3
|
+
*
|
|
4
|
+
* PROBLEM
|
|
5
|
+
* -------
|
|
6
|
+
* ESM Module Namespace Objects (ECMA §9.4.6) have [[Prototype]] = null.
|
|
7
|
+
* They do NOT inherit Object.prototype — no `hasOwnProperty`, no `toString`,
|
|
8
|
+
* no `isPrototypeOf`. CJS consumers (most notably zone.js's `patchMethod`)
|
|
9
|
+
* assume their require() result is a plain object that has those methods:
|
|
10
|
+
*
|
|
11
|
+
* let proto = target;
|
|
12
|
+
* while (proto && !proto.hasOwnProperty(name)) // ← crashes on null-proto
|
|
13
|
+
* proto = Object.getPrototypeOf(proto);
|
|
14
|
+
*
|
|
15
|
+
* `@nativescript/core/index.js` re-exports several sub-modules as namespaces:
|
|
16
|
+
*
|
|
17
|
+
* export * as Utils from './utils';
|
|
18
|
+
* export * as Http from './http';
|
|
19
|
+
* export * as Connectivity from './connectivity';
|
|
20
|
+
* export * as ApplicationSettings from './application-settings';
|
|
21
|
+
*
|
|
22
|
+
* When bundle.mjs does `import { Utils } from '@nativescript/core'`, `Utils`
|
|
23
|
+
* binds to that null-proto sub-namespace. zone.js then does
|
|
24
|
+
* `patchMethod(Utils, 'mainThreadify', …)` and crashes.
|
|
25
|
+
*
|
|
26
|
+
* WHY globalThis.require shims ALONE DON'T FIX THIS
|
|
27
|
+
* -------------------------------------------------
|
|
28
|
+
* ESM imports never pass through `globalThis.require`. They go through the
|
|
29
|
+
* host's ESM linker (V8 on iOS). Shimming `require` only intercepts the CJS
|
|
30
|
+
* path (vendor packages that use `require('@nativescript/core')`); direct
|
|
31
|
+
* ESM imports of `Utils` still see the raw null-proto namespace.
|
|
32
|
+
*
|
|
33
|
+
* THE FIX
|
|
34
|
+
* -------
|
|
35
|
+
* Rewrite `export * as X from 'Y'` at the /ns/core bridge response level:
|
|
36
|
+
*
|
|
37
|
+
* // before
|
|
38
|
+
* export * as Utils from './utils';
|
|
39
|
+
*
|
|
40
|
+
* // after
|
|
41
|
+
* import * as __ns_re_Utils__ from './utils';
|
|
42
|
+
* export const Utils = __NS_CJS_SHAPE__(__ns_re_Utils__);
|
|
43
|
+
*
|
|
44
|
+
* Now `Utils` is a plain Object (inherits Object.prototype). Zone.js's
|
|
45
|
+
* `patchMethod(Utils, ...)` succeeds. The shape function is recursive —
|
|
46
|
+
* nested namespaces get the same treatment — and identity-preserving
|
|
47
|
+
* (WeakMap-cached) so mutations stick across lookups.
|
|
48
|
+
*
|
|
49
|
+
* WHY THE SHAPE INSTALL MUST RUN IN MODULE BODY (NOT FOOTER)
|
|
50
|
+
* ---------------------------------------------------------
|
|
51
|
+
* `export const Utils = __NS_CJS_SHAPE__(__ns_re_Utils__)` is body code. It
|
|
52
|
+
* executes during module evaluation, BEFORE the registration footer. So the
|
|
53
|
+
* shape function must be installed as a body-level statement that runs
|
|
54
|
+
* before the rewritten body — we can't rely on the footer's install.
|
|
55
|
+
*
|
|
56
|
+
* Each served /ns/core module independently installs the shape function via
|
|
57
|
+
* an idempotent `|| (globalThis.__NS_CJS_SHAPE__ = ...)` assignment. The
|
|
58
|
+
* first module to evaluate wins; subsequent evaluations are no-ops. This
|
|
59
|
+
* also handles dependency-before-importer order (depth-first ESM eval):
|
|
60
|
+
* `/ns/core/utils` evaluates before `/ns/core` main, so the shape helper
|
|
61
|
+
* is in place whenever any body needs it.
|
|
62
|
+
*/
|
|
63
|
+
/**
|
|
64
|
+
* Body-code statements that idempotently install `globalThis.__NS_CJS_SHAPE__`
|
|
65
|
+
* and `globalThis.__NS_CJS_SHAPE_CACHE__`. Must execute BEFORE any transformed
|
|
66
|
+
* `export const X = __NS_CJS_SHAPE__(...)` statement in the same module.
|
|
67
|
+
*
|
|
68
|
+
* Properties:
|
|
69
|
+
* - Recursive: traverses nested namespaces so `Utils.Something` is also
|
|
70
|
+
* a plain Object (if that sub-namespace is itself null-proto).
|
|
71
|
+
* - Identity-preserving: WeakMap keyed on the underlying ESM namespace.
|
|
72
|
+
* zone.js mutates its patch target; a fresh copy per call would lose
|
|
73
|
+
* mutations. Every lookup of the same namespace returns the same
|
|
74
|
+
* shaped object.
|
|
75
|
+
* - Cycle-safe: records the output in the cache BEFORE recursing into
|
|
76
|
+
* children. Handles `core ↔ platform` style cycles.
|
|
77
|
+
* - TDZ-safe: wraps each property read in try/catch. Some exports
|
|
78
|
+
* (Angular zone.js with early-access patterns) are still in their
|
|
79
|
+
* temporal dead zone when the namespace is first snapshotted. A thrown
|
|
80
|
+
* property read is skipped rather than failing the whole shape.
|
|
81
|
+
*/
|
|
82
|
+
export declare function buildShapeInstallHeader(): string;
|
|
83
|
+
/**
|
|
84
|
+
* Rewrite namespace re-exports from CJS-incompatible ESM namespace form into
|
|
85
|
+
* shape-aware const exports. Handles the two forms Vite/esbuild may emit:
|
|
86
|
+
*
|
|
87
|
+
* (1) Original ES2020 syntax preserved unchanged:
|
|
88
|
+
* export * as X from 'Y';
|
|
89
|
+
*
|
|
90
|
+
* (2) Transpiled form esbuild emits when targeting older ES:
|
|
91
|
+
* import * as _foo from 'Y';
|
|
92
|
+
* export { _foo as X };
|
|
93
|
+
*
|
|
94
|
+
* Both become:
|
|
95
|
+
* import * as __ns_re_X__ from 'Y';
|
|
96
|
+
* export const X = __NS_CJS_SHAPE__(__ns_re_X__);
|
|
97
|
+
*
|
|
98
|
+
* Notes on the transform:
|
|
99
|
+
* - The internal binding uses a derived name (`__ns_re_<X>__`) so
|
|
100
|
+
* collisions with user bindings are extremely unlikely. Core doesn't
|
|
101
|
+
* declare identifiers matching that shape.
|
|
102
|
+
* - `__NS_CJS_SHAPE__` is read from globalThis with a defensive fallback
|
|
103
|
+
* (identity function) in case installation failed or runs in an
|
|
104
|
+
* environment where it hasn't been initialized yet. This makes the
|
|
105
|
+
* transform safe to apply to modules that don't always go through the
|
|
106
|
+
* /ns/core handler's headers.
|
|
107
|
+
* - We do NOT shape `export *` (star re-exports without alias). Those
|
|
108
|
+
* spread individual named exports — they don't create a nested
|
|
109
|
+
* namespace and aren't affected by the null-proto issue.
|
|
110
|
+
* - We do NOT shape `export { x } from 'y'` forms. Those copy individual
|
|
111
|
+
* named exports directly; the consumer never sees the namespace.
|
|
112
|
+
*
|
|
113
|
+
* The regex is intentionally precise. It matches only the `export * as X from
|
|
114
|
+
* 'Y'` syntactic form (and its transpiled equivalent) — no accidental matches
|
|
115
|
+
* in string literals or comments because those can't start a top-level
|
|
116
|
+
* statement with `export`.
|
|
117
|
+
*/
|
|
118
|
+
export declare function rewriteNamespaceReExportsForShape(code: string): string;
|
|
119
|
+
/**
|
|
120
|
+
* Convenience: returns true if the given code appears to contain at least one
|
|
121
|
+
* namespace re-export that would benefit from the shape transform. Used to
|
|
122
|
+
* skip the regex replace for modules that don't need it (keeps the response
|
|
123
|
+
* identical for most submodules, which just have plain `export * from` or
|
|
124
|
+
* named exports).
|
|
125
|
+
*/
|
|
126
|
+
export declare function hasNamespaceReExport(code: string): boolean;
|
|
127
|
+
/**
|
|
128
|
+
* Default-export bridge footer.
|
|
129
|
+
*
|
|
130
|
+
* BACKGROUND
|
|
131
|
+
* ----------
|
|
132
|
+
* Upstream consumer rewrites in the /ns/m handler convert
|
|
133
|
+
* `import { X } from '@nativescript/core'` into
|
|
134
|
+
* `import __ns_core_ns from '/ns/core'; const { X } = __ns_core_ns;`
|
|
135
|
+
* — a DEFAULT import followed by destructuring. The inline comment on that
|
|
136
|
+
* rewrite says explicitly: "This makes `import { Frame } from
|
|
137
|
+
* '@nativescript/core'` work even if the bridge provides only a default
|
|
138
|
+
* export."
|
|
139
|
+
*
|
|
140
|
+
* The original `@nativescript/core/index.js` has no `export default` — all
|
|
141
|
+
* named exports. Without this footer, consumers of the transformed import
|
|
142
|
+
* fail at ESM link time:
|
|
143
|
+
*
|
|
144
|
+
* SyntaxError: The requested module '/ns/core/<ver>' does not
|
|
145
|
+
* provide an export named 'default'
|
|
146
|
+
*
|
|
147
|
+
* THE FIX
|
|
148
|
+
* -------
|
|
149
|
+
* Emit `export default __ns_core_self_ns__;` at the end of the served
|
|
150
|
+
* module body. `__ns_core_self_ns__` is the namespace import the server
|
|
151
|
+
* already emits at the top of every /ns/core response for self-
|
|
152
|
+
* registration purposes. ESM spec guarantees a module re-entering itself
|
|
153
|
+
* during evaluation returns the in-progress namespace — so no extra
|
|
154
|
+
* evaluation occurs, and the default binding receives an object whose
|
|
155
|
+
* properties are every named export of the same module.
|
|
156
|
+
*
|
|
157
|
+
* CONSUMER MATRIX AFTER THIS FIX
|
|
158
|
+
* ------------------------------
|
|
159
|
+
* • `import X from '/ns/core'` (default) → X = self namespace
|
|
160
|
+
* • `import * as X from '/ns/core'` → X = self namespace + X.default = self
|
|
161
|
+
* • `import { X } from '/ns/core'` (named) → individual named binding (untouched)
|
|
162
|
+
* • `const { X } = <default-import>` → destructure from self namespace
|
|
163
|
+
* • `require('@nativescript/core')` (CJS) → shaped self via registry
|
|
164
|
+
*
|
|
165
|
+
* SKIP CONDITIONS
|
|
166
|
+
* ---------------
|
|
167
|
+
* Returns empty string when the source already declares a default export
|
|
168
|
+
* (some deep subpaths do — e.g. a file that does `export default MyClass`
|
|
169
|
+
* would SyntaxError on a duplicate). The consumer rewrite is also gated
|
|
170
|
+
* on `isDeepCoreSubpath`, so those paths don't normally hit the default-
|
|
171
|
+
* import pattern anyway.
|
|
172
|
+
*
|
|
173
|
+
* WHY THE DEFAULT ISN'T SHAPED
|
|
174
|
+
* ----------------------------
|
|
175
|
+
* The default is the raw null-proto MNO. This is intentional:
|
|
176
|
+
*
|
|
177
|
+
* 1. All current default-import consumers either destructure or do
|
|
178
|
+
* property access. Neither requires Object.prototype in the chain.
|
|
179
|
+
* 2. Shaping the default inside the module body would require calling
|
|
180
|
+
* __NS_CJS_SHAPE__ on a namespace whose own `default` slot is still
|
|
181
|
+
* being initialized — temporal dead zone hazard.
|
|
182
|
+
* 3. CJS consumers that need `.hasOwnProperty` go through the registry
|
|
183
|
+
* (shaped at registration), not through the default import.
|
|
184
|
+
*
|
|
185
|
+
* If a future consumer surfaces that calls `.hasOwnProperty` on the
|
|
186
|
+
* default, we can revisit. The current rule-of-least-surprise is:
|
|
187
|
+
* shape at the CJS boundary, not at the ESM boundary.
|
|
188
|
+
*/
|
|
189
|
+
export declare function buildDefaultExportFooter(rewrittenCode: string): string;
|
|
190
|
+
/**
|
|
191
|
+
* Detects whether a module body already declares a default export in any of
|
|
192
|
+
* the syntactic forms the ESM spec allows. Mirrors the logic in
|
|
193
|
+
* `websocket-core-bridge.ts:hasModuleDefaultExport` — kept here so the
|
|
194
|
+
* default-export bridge helper is self-contained and unit-testable.
|
|
195
|
+
*
|
|
196
|
+
* Handles:
|
|
197
|
+
* - `export default <expr>;`
|
|
198
|
+
* - `export default function|class ...`
|
|
199
|
+
* - `export { x as default };`
|
|
200
|
+
* - `export { default };` (implicit `default as default`)
|
|
201
|
+
* - `export { default as default };`
|
|
202
|
+
* - `export { foo, default };`
|
|
203
|
+
*/
|
|
204
|
+
export declare function hasExistingDefaultExport(code: string): boolean;
|