@nativescript/vite 8.0.0-alpha.29 → 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.
Files changed (74) hide show
  1. package/hmr/server/angular-root-component.d.ts +79 -0
  2. package/hmr/server/angular-root-component.js +149 -0
  3. package/hmr/server/angular-root-component.js.map +1 -0
  4. package/hmr/server/hmr-module-graph.d.ts +37 -0
  5. package/hmr/server/hmr-module-graph.js +214 -0
  6. package/hmr/server/hmr-module-graph.js.map +1 -0
  7. package/hmr/server/index.js +1 -0
  8. package/hmr/server/index.js.map +1 -1
  9. package/hmr/server/ns-rt-route.d.ts +5 -0
  10. package/hmr/server/ns-rt-route.js +35 -0
  11. package/hmr/server/ns-rt-route.js.map +1 -0
  12. package/hmr/server/require-guard.d.ts +1 -0
  13. package/hmr/server/require-guard.js +12 -0
  14. package/hmr/server/require-guard.js.map +1 -0
  15. package/hmr/server/route-helpers.d.ts +7 -0
  16. package/hmr/server/route-helpers.js +13 -0
  17. package/hmr/server/route-helpers.js.map +1 -0
  18. package/hmr/server/server-origin.d.ts +12 -0
  19. package/hmr/server/server-origin.js +66 -0
  20. package/hmr/server/server-origin.js.map +1 -0
  21. package/hmr/server/websocket-core-bridge.js +0 -11
  22. package/hmr/server/websocket-core-bridge.js.map +1 -1
  23. package/hmr/server/websocket-device-transform.d.ts +21 -0
  24. package/hmr/server/websocket-device-transform.js +1570 -0
  25. package/hmr/server/websocket-device-transform.js.map +1 -0
  26. package/hmr/server/websocket-hot-update.d.ts +51 -0
  27. package/hmr/server/websocket-hot-update.js +1160 -0
  28. package/hmr/server/websocket-hot-update.js.map +1 -0
  29. package/hmr/server/websocket-import-map-route.d.ts +15 -0
  30. package/hmr/server/websocket-import-map-route.js +44 -0
  31. package/hmr/server/websocket-import-map-route.js.map +1 -0
  32. package/hmr/server/websocket-ns-core.d.ts +21 -0
  33. package/hmr/server/websocket-ns-core.js +305 -0
  34. package/hmr/server/websocket-ns-core.js.map +1 -0
  35. package/hmr/server/websocket-ns-entry.d.ts +22 -0
  36. package/hmr/server/websocket-ns-entry.js +150 -0
  37. package/hmr/server/websocket-ns-entry.js.map +1 -0
  38. package/hmr/server/websocket-ns-m.d.ts +34 -0
  39. package/hmr/server/websocket-ns-m.js +853 -0
  40. package/hmr/server/websocket-ns-m.js.map +1 -0
  41. package/hmr/server/websocket-served-module-helpers.d.ts +1 -1
  42. package/hmr/server/websocket-served-module-helpers.js +1 -1
  43. package/hmr/server/websocket-served-module-helpers.js.map +1 -1
  44. package/hmr/server/websocket-sfc.d.ts +24 -0
  45. package/hmr/server/websocket-sfc.js +1223 -0
  46. package/hmr/server/websocket-sfc.js.map +1 -0
  47. package/hmr/server/websocket-txn.js +2 -8
  48. package/hmr/server/websocket-txn.js.map +1 -1
  49. package/hmr/server/websocket-vendor-unifier.js +2 -8
  50. package/hmr/server/websocket-vendor-unifier.js.map +1 -1
  51. package/hmr/server/websocket.d.ts +1 -44
  52. package/hmr/server/websocket.js +588 -6691
  53. package/hmr/server/websocket.js.map +1 -1
  54. package/hmr/shared/runtime/root-placeholder-view.d.ts +19 -0
  55. package/hmr/shared/runtime/root-placeholder-view.js +310 -0
  56. package/hmr/shared/runtime/root-placeholder-view.js.map +1 -0
  57. package/hmr/shared/runtime/root-placeholder.js +1 -309
  58. package/hmr/shared/runtime/root-placeholder.js.map +1 -1
  59. package/hmr/shared/vendor/manifest-collect.d.ts +32 -0
  60. package/hmr/shared/vendor/manifest-collect.js +512 -0
  61. package/hmr/shared/vendor/manifest-collect.js.map +1 -0
  62. package/hmr/shared/vendor/manifest.d.ts +1 -35
  63. package/hmr/shared/vendor/manifest.js +3 -914
  64. package/hmr/shared/vendor/manifest.js.map +1 -1
  65. package/hmr/shared/vendor/vendor-device-shim.d.ts +1 -0
  66. package/hmr/shared/vendor/vendor-device-shim.js +208 -0
  67. package/hmr/shared/vendor/vendor-device-shim.js.map +1 -0
  68. package/hmr/shared/vendor/vendor-esbuild-plugins.d.ts +16 -0
  69. package/hmr/shared/vendor/vendor-esbuild-plugins.js +203 -0
  70. package/hmr/shared/vendor/vendor-esbuild-plugins.js.map +1 -0
  71. package/package.json +1 -1
  72. package/hmr/server/websocket-vue-sfc.d.ts +0 -26
  73. package/hmr/server/websocket-vue-sfc.js +0 -1053
  74. package/hmr/server/websocket-vue-sfc.js.map +0 -1
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Identifies the Angular **bootstrap (root) component** of a project from
3
+ * its dev-server entry module, and provides helpers to match Analog's
4
+ * `angular:component-update` events against it.
5
+ *
6
+ * Why this exists
7
+ * ---------------
8
+ * NativeScript's root Angular component hosts the navigation `Frame` (via
9
+ * `<page-router-outlet>`). Analog's in-place template HMR
10
+ * (`ɵɵreplaceMetadata`) recreates the matching `LView`s for the edited
11
+ * component WITHOUT re-running router navigation. For a normal child
12
+ * component that's exactly right — its view re-renders inside an intact
13
+ * page. For the ROOT component it's fatal: replacing the root metadata
14
+ * tears down the `PageRouterOutlet`'s `Frame` and nothing re-navigates,
15
+ * leaving a permanent blank/white screen that no further in-place update
16
+ * can recover.
17
+ *
18
+ * The reboot path (`ns:angular-update` → `__reboot_ng_modules__`) DOES
19
+ * recover the root view (it re-bootstraps and replays route state). So the
20
+ * fix is to route every root-component edit through the reboot path and
21
+ * suppress the destructive in-place update for it. Both halves need to know
22
+ * which file is the root component — that's what this module resolves.
23
+ *
24
+ * Resolution is intentionally dependency-free string/path math so it can be
25
+ * unit-tested without a Vite server or filesystem. It targets the modern
26
+ * standalone bootstrap shape (`bootstrapApplication(AppComponent, …)`),
27
+ * which is what `main.ts` uses; it degrades gracefully to `null` for shapes
28
+ * it can't statically resolve (e.g. NgModule `bootstrap: [...]`), in which
29
+ * case callers keep their existing behavior.
30
+ */
31
+ export interface BootstrapRootComponent {
32
+ /**
33
+ * Extensionless, project-relative POSIX path with a leading slash —
34
+ * e.g. `/src/app/app.component`. Comparisons are always extensionless so
35
+ * a `.html` template edit and its `.ts` component resolve to the same key.
36
+ */
37
+ moduleRel: string;
38
+ /**
39
+ * The class name passed to `bootstrapApplication(...)` (best-effort,
40
+ * resolved back to the imported binding name when aliased). Used as a
41
+ * secondary match signal for Analog ids whose path base differs from the
42
+ * project root.
43
+ */
44
+ className: string;
45
+ }
46
+ /**
47
+ * Normalizes any project-relative path to a leading-slash, extensionless
48
+ * POSIX key suitable for equality comparison between a `.html`/`.ts` edit
49
+ * and the resolved root component.
50
+ */
51
+ export declare function toExtensionlessModuleRel(rel: string): string;
52
+ /** True when two project-relative paths refer to the same module (ignoring extension). */
53
+ export declare function isSameAngularModuleRel(a: string | null | undefined, b: string | null | undefined): boolean;
54
+ /**
55
+ * Resolves the bootstrap root component from a dev-server entry module's
56
+ * source. Returns `null` when the bootstrap shape can't be statically
57
+ * resolved (callers should then keep their default behavior).
58
+ */
59
+ export declare function resolveBootstrapRootComponent(options: {
60
+ entrySource: string;
61
+ entryRel: string;
62
+ appRootRel?: string;
63
+ }): BootstrapRootComponent | null;
64
+ /**
65
+ * Decodes Analog's `angular:component-update` payload `id`
66
+ * (`encodeURIComponent(relativePath + '@' + className)`) into a normalized,
67
+ * extensionless module rel plus the class name, so the bridge can compare it
68
+ * against the resolved root component. Returns `null` for empty/invalid ids.
69
+ */
70
+ export declare function decodeAngularComponentUpdateId(id: unknown): {
71
+ moduleRel: string;
72
+ className: string;
73
+ } | null;
74
+ /**
75
+ * True when an Analog `angular:component-update` `id` targets the resolved
76
+ * root component — matched by module path first (robust to class-name
77
+ * collisions), then by class name as a fallback.
78
+ */
79
+ export declare function isAngularRootComponentUpdate(root: BootstrapRootComponent | null | undefined, id: unknown): boolean;
@@ -0,0 +1,149 @@
1
+ import path from 'path';
2
+ const BOOTSTRAP_APPLICATION_RE = /\bbootstrapApplication\s*\(\s*([A-Za-z_$][\w$]*)/;
3
+ const IMPORT_STATEMENT_RE = /import\s+([^;'"]+?)\s+from\s+['"]([^'"]+)['"]/g;
4
+ const SOURCE_EXTENSION_RE = /\.(?:tsx?|jsx?|mjs|cjs|html?|css|scss|sass|less)$/i;
5
+ function scanImportBindings(source) {
6
+ const bindings = new Map();
7
+ IMPORT_STATEMENT_RE.lastIndex = 0;
8
+ let match;
9
+ while ((match = IMPORT_STATEMENT_RE.exec(source)) !== null) {
10
+ const clause = match[1].trim();
11
+ const specifier = match[2];
12
+ recordClauseBindings(clause, specifier, bindings);
13
+ }
14
+ return bindings;
15
+ }
16
+ function recordClauseBindings(clause, specifier, out) {
17
+ const namedStart = clause.indexOf('{');
18
+ if (namedStart !== -1) {
19
+ const namedEnd = clause.indexOf('}', namedStart);
20
+ const namedSegment = namedEnd === -1 ? clause.slice(namedStart + 1) : clause.slice(namedStart + 1, namedEnd);
21
+ for (const raw of namedSegment.split(',')) {
22
+ const entry = raw.trim();
23
+ if (!entry)
24
+ continue;
25
+ const asMatch = /^(\S+)\s+as\s+(\S+)$/.exec(entry);
26
+ if (asMatch) {
27
+ out.set(asMatch[2], { specifier, importedName: asMatch[1] });
28
+ }
29
+ else {
30
+ out.set(entry, { specifier, importedName: entry });
31
+ }
32
+ }
33
+ // Strip the `{ … }` group so a leading default import in the same
34
+ // statement (`import Foo, { Bar } from '…'`) is still captured below.
35
+ clause = (clause.slice(0, namedStart) + clause.slice(namedEnd === -1 ? clause.length : namedEnd + 1)).trim();
36
+ }
37
+ const namespaceMatch = /^\*\s+as\s+([A-Za-z_$][\w$]*)$/.exec(clause);
38
+ if (namespaceMatch) {
39
+ out.set(namespaceMatch[1], { specifier, importedName: '*' });
40
+ return;
41
+ }
42
+ const defaultName = clause.replace(/,\s*$/, '').trim();
43
+ if (/^[A-Za-z_$][\w$]*$/.test(defaultName)) {
44
+ out.set(defaultName, { specifier, importedName: 'default' });
45
+ }
46
+ }
47
+ /**
48
+ * Resolves a (relative or `~`/`@` aliased) module specifier — as written in
49
+ * the entry's import — to an extensionless project-relative POSIX path.
50
+ * Returns `null` for bare/package specifiers (a root component is always a
51
+ * project-local file).
52
+ */
53
+ function resolveSpecifierToModuleRel(specifier, entryRel, appRootRel) {
54
+ const entryDir = path.posix.dirname(normalizeRel(entryRel));
55
+ if (specifier.startsWith('./') || specifier.startsWith('../')) {
56
+ return toExtensionlessModuleRel(path.posix.join(entryDir, specifier));
57
+ }
58
+ if (specifier.startsWith('~/') || specifier.startsWith('@/')) {
59
+ const base = normalizeRel(appRootRel || entryDir);
60
+ return toExtensionlessModuleRel(path.posix.join(base, specifier.slice(2)));
61
+ }
62
+ return null;
63
+ }
64
+ function normalizeRel(rel) {
65
+ let normalized = String(rel || '').replace(/\\/g, '/');
66
+ if (!normalized.startsWith('/'))
67
+ normalized = '/' + normalized;
68
+ return normalized.replace(/\/{2,}/g, '/');
69
+ }
70
+ /**
71
+ * Normalizes any project-relative path to a leading-slash, extensionless
72
+ * POSIX key suitable for equality comparison between a `.html`/`.ts` edit
73
+ * and the resolved root component.
74
+ */
75
+ export function toExtensionlessModuleRel(rel) {
76
+ const normalized = normalizeRel(rel);
77
+ return normalized.replace(SOURCE_EXTENSION_RE, '');
78
+ }
79
+ /** True when two project-relative paths refer to the same module (ignoring extension). */
80
+ export function isSameAngularModuleRel(a, b) {
81
+ if (!a || !b)
82
+ return false;
83
+ return toExtensionlessModuleRel(a) === toExtensionlessModuleRel(b);
84
+ }
85
+ /**
86
+ * Resolves the bootstrap root component from a dev-server entry module's
87
+ * source. Returns `null` when the bootstrap shape can't be statically
88
+ * resolved (callers should then keep their default behavior).
89
+ */
90
+ export function resolveBootstrapRootComponent(options) {
91
+ const { entrySource, entryRel } = options;
92
+ if (!entrySource || !entryRel)
93
+ return null;
94
+ const bootstrapMatch = BOOTSTRAP_APPLICATION_RE.exec(entrySource);
95
+ if (!bootstrapMatch)
96
+ return null;
97
+ const localName = bootstrapMatch[1];
98
+ const binding = scanImportBindings(entrySource).get(localName);
99
+ if (!binding)
100
+ return null;
101
+ const moduleRel = resolveSpecifierToModuleRel(binding.specifier, entryRel, options.appRootRel ?? '');
102
+ if (!moduleRel)
103
+ return null;
104
+ // Prefer the originally-imported name (the declared class) over a local
105
+ // alias so it lines up with the class name Analog encodes in its id.
106
+ const className = binding.importedName && binding.importedName !== 'default' && binding.importedName !== '*' ? binding.importedName : localName;
107
+ return { moduleRel, className };
108
+ }
109
+ /**
110
+ * Decodes Analog's `angular:component-update` payload `id`
111
+ * (`encodeURIComponent(relativePath + '@' + className)`) into a normalized,
112
+ * extensionless module rel plus the class name, so the bridge can compare it
113
+ * against the resolved root component. Returns `null` for empty/invalid ids.
114
+ */
115
+ export function decodeAngularComponentUpdateId(id) {
116
+ if (typeof id !== 'string' || !id)
117
+ return null;
118
+ let decoded = id;
119
+ try {
120
+ decoded = decodeURIComponent(id);
121
+ }
122
+ catch {
123
+ // Leave as-is — a non-encoded id still splits/normalizes correctly.
124
+ }
125
+ // Class names never contain `@`, but scoped paths can — split on the LAST
126
+ // `@` so `relativePath` keeps any leading `@scope/...` segments intact.
127
+ const at = decoded.lastIndexOf('@');
128
+ const pathPart = at >= 0 ? decoded.slice(0, at) : decoded;
129
+ const className = at >= 0 ? decoded.slice(at + 1) : '';
130
+ if (!pathPart)
131
+ return null;
132
+ return { moduleRel: toExtensionlessModuleRel(pathPart), className };
133
+ }
134
+ /**
135
+ * True when an Analog `angular:component-update` `id` targets the resolved
136
+ * root component — matched by module path first (robust to class-name
137
+ * collisions), then by class name as a fallback.
138
+ */
139
+ export function isAngularRootComponentUpdate(root, id) {
140
+ if (!root)
141
+ return false;
142
+ const decoded = decodeAngularComponentUpdateId(id);
143
+ if (!decoded)
144
+ return false;
145
+ if (isSameAngularModuleRel(root.moduleRel, decoded.moduleRel))
146
+ return true;
147
+ return !!decoded.className && decoded.className === root.className;
148
+ }
149
+ //# sourceMappingURL=angular-root-component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"angular-root-component.js","sourceRoot":"","sources":["../../../../../packages/vite/hmr/server/angular-root-component.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAiDxB,MAAM,wBAAw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AAI,OAAO,GAAG,EAAE,CAAC;IACjB,IAAI,CAAC;QACJ,OAAO,GAAG,kBAAkB,CAAC,EAAE,CAAC,CAAC;IAClC,CAAC;IAAC,MAAM,CAAC;QACR,oEAAoE;IACrE,CAAC;IACD,0EAA0E;IAC1E,wEAAwE;IACxE,MAAM,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IACpC,MAAM,QAAQ,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IAC1D,MAAM,SAAS,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACvD,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC3B,OAAO,EAAE,SAAS,EAAE,wBAAwB,CAAC,QAAQ,CAAC,EAAE,SAAS,EAAE,CAAC;AACrE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,4BAA4B,CAAC,IAA+C,EAAE,EAAW;IACxG,IAAI,CAAC,IAAI;QAAE,OAAO,KAAK,CAAC;IACxB,MAAM,OAAO,GAAG,8BAA8B,CAAC,EAAE,CAAC,CAAC;IACnD,IAAI,CAAC,OAAO;QAAE,OAAO,KAAK,CAAC;IAC3B,IAAI,sBAAsB,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,SAAS,CAAC;QAAE,OAAO,IAAI,CAAC;IAC3E,OAAO,CAAC,CAAC,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,SAAS,KAAK,IAAI,CAAC,SAAS,CAAC;AACpE,CAAC"}
@@ -0,0 +1,37 @@
1
+ import type { WebSocket, WebSocketServer } from 'ws';
2
+ import type { FrameworkServerStrategy } from './framework-strategy.js';
3
+ export interface GraphModule {
4
+ id: string;
5
+ deps: string[];
6
+ hash: string;
7
+ }
8
+ export interface UpsertOptions {
9
+ emitDeltaOnInsert?: boolean;
10
+ broadcastDelta?: boolean;
11
+ bumpVersion?: boolean;
12
+ }
13
+ export interface HmrModuleGraphDeps {
14
+ verbose: boolean;
15
+ strategy: FrameworkServerStrategy;
16
+ getWss: () => WebSocketServer | null;
17
+ getPluginRoot: () => string | undefined;
18
+ }
19
+ export declare class HmrModuleGraph {
20
+ private readonly deps;
21
+ readonly modules: Map<string, GraphModule>;
22
+ private readonly txnBatches;
23
+ private _version;
24
+ constructor(deps: HmrModuleGraphDeps);
25
+ get version(): number;
26
+ get size(): number;
27
+ get(id: string): GraphModule | undefined;
28
+ getTxnBatch(version: number): string[];
29
+ computeHash(content: string): string;
30
+ normalizeGraphId(raw: string): string;
31
+ computeTxnOrderForChanged(changedIds: string[]): string[];
32
+ private fullGraphPayload;
33
+ emitFullGraph(ws: WebSocket): void;
34
+ emitDelta(changed: GraphModule[], removed: string[]): void;
35
+ upsert(rawId: string, code: string, deps: string[], options?: UpsertOptions): GraphModule | undefined;
36
+ remove(id: string): void;
37
+ }
@@ -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,IAAI;QACP,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;IAC1B,CAAC;IAED,GAAG,CAAC,EAAU;QACb,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAC7B,CAAC;IAED,WAAW,CAAC,OAAe;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,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AAC,CAAC;IAC1B,CAAC;CACD"}
@@ -7,6 +7,7 @@ export function getHMRPlugins(opts) {
7
7
  plugins.push(hmrWebSocketVue(opts));
8
8
  break;
9
9
  case 'react':
10
+ // React has no server-side HMR WebSocket plugin yet; the client plugin suffices.
10
11
  break;
11
12
  case 'angular':
12
13
  plugins.push(hmrWebSocketAngular(opts));
@@ -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,5 @@
1
+ import type { ViteDevServer } from 'vite';
2
+ export interface NsRtRouteOptions {
3
+ getGraphVersion(): number;
4
+ }
5
+ export declare function registerNsRtBridgeRoute(server: ViteDevServer, options: NsRtRouteOptions): void;
@@ -0,0 +1,35 @@
1
+ import { getProjectRootPath } from '../../helpers/project.js';
2
+ import { buildNsRtBridgeModule, discoverNsvBridgeExports } from './ns-rt-bridge.js';
3
+ import { REQUIRE_GUARD_SNIPPET } from './require-guard.js';
4
+ import { setDeviceModuleHeaders } from './route-helpers.js';
5
+ // ESM runtime bridge for NativeScript-Vue: `GET /ns/rt[/<ver>]`.
6
+ //
7
+ // Serves a single authoritative source of Vue helpers bound to the
8
+ // NativeScript renderer. The bridge lazily resolves helpers from the vendor
9
+ // registry on first evaluation (it does not statically import `vue`), then
10
+ // re-exports them so SFCs can call them during module evaluation. The shared
11
+ // `buildNsRtBridgeModule` owns the body (preamble, passthroughs, HMR shims,
12
+ // polyfills, default export); discovery is the only source of truth for which
13
+ // vendor symbols are forwarded.
14
+ export function registerNsRtBridgeRoute(server, options) {
15
+ server.middlewares.use(async (req, res, next) => {
16
+ try {
17
+ const urlObj = new URL(req.url || '', 'http://localhost');
18
+ // Accept only /ns/rt and /ns/rt/<ver> for cache-busting semantics
19
+ if (!(urlObj.pathname === '/ns/rt' || /^\/ns\/rt\/[\d]+$/.test(urlObj.pathname)))
20
+ return next();
21
+ setDeviceModuleHeaders(res);
22
+ const rtVerSeg = urlObj.pathname.replace(/^\/ns\/rt\/?/, '');
23
+ const rtVer = /^[0-9]+$/.test(rtVerSeg) ? rtVerSeg : String(options.getGraphVersion() || 0);
24
+ const vendorExports = discoverNsvBridgeExports(getProjectRootPath());
25
+ const code = buildNsRtBridgeModule({ rtVer, requireGuardSnippet: REQUIRE_GUARD_SNIPPET, vendorExports });
26
+ res.statusCode = 200;
27
+ res.end(code);
28
+ }
29
+ catch {
30
+ res.statusCode = 500;
31
+ res.end('export {}\n');
32
+ }
33
+ });
34
+ }
35
+ //# sourceMappingURL=ns-rt-route.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ns-rt-route.js","sourceRoot":"","sources":["../../../../../packages/vite/hmr/server/ns-rt-route.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AACpF,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAQ5D,iEAAiE;AACjE,EAAE;AACF,mEAAmE;AACnE,4EAA4E;AAC5E,2EAA2E;AAC3E,6EAA6E;AAC7E,4EAA4E;AAC5E,8EAA8E;AAC9E,gCAAgC;AAChC,MAAM,UAAU,uBAAuB,C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.__NS_REQUIRE_GUARD_INSTALLED__){}else{var seen=g.__NS_REQUIRE_GUARD_SEEN__||(g.__NS_REQUIRE_GUARD_SEEN__=new Set());var mk=function(o,l){return function(){try{var s=arguments[0];if(typeof s==='string'&&/^(?:https?:)\\/\\//.test(s)){var k=l+'|'+s;var v=g.__NS_REQUIRE_GUARD_VERBOSE__===true;var first=!seen.has(k);if(first)seen.add(k);if(first||v){var e=new Error('[ns-hmr][require-guard] require of URL: '+s+' via '+l);if(v)console.warn(e.message+'\\n'+(e.stack||''));else console.warn(e.message);try{g.__NS_REQUIRE_GUARD_LAST__={spec:s,stack:e.stack,label:l,ts:Date.now()};}catch(e3){}}}}catch(e1){}return o.apply(this, arguments);};};if(typeof g.require==='function'&&!g.require.__NS_REQ_GUARDED__){var o1=g.require;g.require=mk(o1,'require');g.require.__NS_REQ_GUARDED__=true;}if(typeof g.__nsRequire==='function'&&!g.__nsRequire.__NS_REQ_GUARDED__){var o2=g.__nsRequire;g.__nsRequire=mk(o2,'__nsRequire');g.__nsRequire.__NS_REQ_GUARDED__=true;}g.__NS_REQUIRE_GUARD_INSTALLED__=true;}}catch(e){}})();\n";
@@ -0,0 +1,12 @@
1
+ // Detect (and log) `require('http(s)://...')` calls made from CJS shims.
2
+ // Pattern: HTTP-served ESM modules end up in NS-vite's `__nsRequire`
3
+ // shim with HTTP URLs as their relative resolution targets. The guard
4
+ // is install-once-per-isolate, dedupes per-URL (so semver's ~30 deep
5
+ // imports produce ~30 lines on the first boot and 0 on subsequent
6
+ // boots within the same isolate), and uses `console.warn` so the
7
+ // message reads as advisory. Forensic detail
8
+ // (stack) lives on `globalThis.__NS_REQUIRE_GUARD_LAST__` for
9
+ // post-mortem inspection. Set `globalThis.__NS_REQUIRE_GUARD_VERBOSE__`
10
+ // to `true` before any module loads to restore per-call logging.
11
+ export const REQUIRE_GUARD_SNIPPET = `// [guard] install require('http(s)://') detector\n(()=>{try{var g=globalThis;if(g.__NS_REQUIRE_GUARD_INSTALLED__){}else{var seen=g.__NS_REQUIRE_GUARD_SEEN__||(g.__NS_REQUIRE_GUARD_SEEN__=new Set());var mk=function(o,l){return function(){try{var s=arguments[0];if(typeof s==='string'&&/^(?:https?:)\\/\\//.test(s)){var k=l+'|'+s;var v=g.__NS_REQUIRE_GUARD_VERBOSE__===true;var first=!seen.has(k);if(first)seen.add(k);if(first||v){var e=new Error('[ns-hmr][require-guard] require of URL: '+s+' via '+l);if(v)console.warn(e.message+'\\n'+(e.stack||''));else console.warn(e.message);try{g.__NS_REQUIRE_GUARD_LAST__={spec:s,stack:e.stack,label:l,ts:Date.now()};}catch(e3){}}}}catch(e1){}return o.apply(this, arguments);};};if(typeof g.require==='function'&&!g.require.__NS_REQ_GUARDED__){var o1=g.require;g.require=mk(o1,'require');g.require.__NS_REQ_GUARDED__=true;}if(typeof g.__nsRequire==='function'&&!g.__nsRequire.__NS_REQ_GUARDED__){var o2=g.__nsRequire;g.__nsRequire=mk(o2,'__nsRequire');g.__nsRequire.__NS_REQ_GUARDED__=true;}g.__NS_REQUIRE_GUARD_INSTALLED__=true;}}catch(e){}})();\n`;
12
+ //# sourceMappingURL=require-guard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"require-guard.js","sourceRoot":"","sources":["../../../../../packages/vite/hmr/server/require-guard.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,qEAAqE;AACrE,sEAAsE;AACtE,qEAAqE;AACrE,kEAAkE;AAClE,iEAAiE;AACjE,6CAA6C;AAC7C,8DAA8D;AAC9D,wEAAwE;AACxE,iEAAiE;AACjE,MAAM,CAAC,MAAM,qBAAqB,GAAG,kkCAAkkC,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { ServerResponse } from 'node:http';
2
+ /**
3
+ * Response headers for device-served ESM module endpoints: permissive CORS plus
4
+ * aggressive no-store caching so the device never reuses a stale module across
5
+ * HMR cycles.
6
+ */
7
+ export declare function setDeviceModuleHeaders(res: ServerResponse): void;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Response headers for device-served ESM module endpoints: permissive CORS plus
3
+ * aggressive no-store caching so the device never reuses a stale module across
4
+ * HMR cycles.
5
+ */
6
+ export function setDeviceModuleHeaders(res) {
7
+ res.setHeader('Access-Control-Allow-Origin', '*');
8
+ res.setHeader('Content-Type', 'application/javascript; charset=utf-8');
9
+ res.setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0');
10
+ res.setHeader('Pragma', 'no-cache');
11
+ res.setHeader('Expires', '0');
12
+ }
13
+ //# sourceMappingURL=route-helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route-helpers.js","sourceRoot":"","sources":["../../../../../packages/vite/hmr/server/route-helpers.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CAAC,GAAmB;IACzD,GAAG,CAAC,SAAS,CAAC,6BAA6B,EAAE,GAAG,CAAC,CAAC;IAClD,GAAG,CAAC,SAAS,CAAC,cAAc,EAAE,uCAAuC,CAAC,CAAC;IACvE,GAAG,CAAC,SAAS,CAAC,eAAe,EAAE,gDAAgD,CAAC,CAAC;IACjF,GAAG,CAAC,SAAS,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IACpC,GAAG,CAAC,SAAS,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;AAC/B,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { ViteDevServer } from 'vite';
2
+ /**
3
+ * Dev-server origin baked into every module served to the device
4
+ * (`/ns/core/...`, `/ns/m/...`). MUST match the origin `dev-host.ts` bakes
5
+ * into `bundle.mjs`; if they disagree V8 keys them as different modules and
6
+ * the app ends up with two `@nativescript/core` realms (a singleton-state
7
+ * split). `resolveDeviceReachableOrigin` keeps every platform in lock-step:
8
+ * Android wildcard/loopback -> `10.0.2.2`, iOS/visionOS wildcard ->
9
+ * `localhost`, explicit non-loopback `server.host` -> trusted verbatim
10
+ * (physical devices opt into LAN via `NS_HMR_PREFER_LAN_HOST`/`NS_HMR_HOST`).
11
+ */
12
+ export declare function getServerOrigin(server: ViteDevServer): string;