@vmz/core 0.2.5 → 0.2.7

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 (77) hide show
  1. package/dist/browser/client-nav.d.ts +5 -55
  2. package/dist/browser/client-nav.js +5 -769
  3. package/dist/browser/diagnostics/precision-trace.d.ts +47 -0
  4. package/dist/browser/diagnostics/precision-trace.js +86 -0
  5. package/dist/browser/dom/attributes.d.ts +5 -0
  6. package/dist/browser/dom/attributes.js +102 -0
  7. package/dist/browser/dom/component.d.ts +11 -0
  8. package/dist/browser/dom/component.js +255 -0
  9. package/dist/browser/dom/direct-api.d.ts +66 -0
  10. package/dist/browser/dom/direct-api.js +446 -0
  11. package/dist/browser/dom/lifecycle.d.ts +9 -0
  12. package/dist/browser/dom/lifecycle.js +161 -0
  13. package/dist/browser/dom/registry.d.ts +5 -0
  14. package/dist/browser/dom/registry.js +16 -0
  15. package/dist/browser/dom-core.d.ts +51 -249
  16. package/dist/browser/dom-core.js +51 -2521
  17. package/dist/browser/navigation/client-navigation.d.ts +44 -0
  18. package/dist/browser/navigation/client-navigation.js +277 -0
  19. package/dist/browser/navigation/extract-html.d.ts +1 -0
  20. package/dist/browser/navigation/extract-html.js +5 -0
  21. package/dist/browser/navigation/layout-retain.d.ts +3 -0
  22. package/dist/browser/navigation/layout-retain.js +34 -0
  23. package/dist/browser/navigation/locale-transition.d.ts +24 -0
  24. package/dist/browser/navigation/locale-transition.js +323 -0
  25. package/dist/browser/navigation/scroll-focus.d.ts +14 -0
  26. package/dist/browser/navigation/scroll-focus.js +87 -0
  27. package/dist/browser/reactivity/patch-scheduler.d.ts +12 -0
  28. package/dist/browser/reactivity/patch-scheduler.js +720 -0
  29. package/dist/browser/reactivity/write-barrier.d.ts +16 -0
  30. package/dist/browser/reactivity/write-barrier.js +546 -0
  31. package/dist/browser/resume/adopt.d.ts +1 -0
  32. package/dist/browser/resume/adopt.js +168 -0
  33. package/dist/browser/resume/hydrate.d.ts +4 -0
  34. package/dist/browser/resume/hydrate.js +107 -0
  35. package/dist/browser/resume/resume.d.ts +3 -0
  36. package/dist/browser/resume/resume.js +102 -0
  37. package/dist/faces/dom.browser.d.ts +2 -1
  38. package/dist/faces/dom.browser.js +2 -1
  39. package/dist/host/{deployment-registry.d.ts → deployment/deployment-registry.d.ts} +1 -1
  40. package/dist/host/{deployment-registry.js → deployment/deployment-registry.js} +1 -1
  41. package/dist/host/list-client-components.d.ts +2 -2
  42. package/dist/host/list-client-components.js +4 -4
  43. package/dist/host/{render-host.d.ts → render/render-host.d.ts} +2 -2
  44. package/dist/host/{render-host.js → render/render-host.js} +1 -1
  45. package/dist/host/{route-layout-chain.js → render/route-layout-chain.js} +1 -1
  46. package/dist/host/serve/bootstrap.d.ts +1 -0
  47. package/dist/host/serve/bootstrap.js +25 -0
  48. package/dist/host/serve/constants.d.ts +6 -0
  49. package/dist/host/serve/constants.js +6 -0
  50. package/dist/host/serve/hmr-dev.d.ts +34 -0
  51. package/dist/host/serve/hmr-dev.js +294 -0
  52. package/dist/host/serve/http.d.ts +1 -0
  53. package/dist/host/serve/http.js +124 -0
  54. package/dist/host/serve/locale-theme.d.ts +19 -0
  55. package/dist/host/serve/locale-theme.js +169 -0
  56. package/dist/host/serve/page-catalog.d.ts +14 -0
  57. package/dist/host/serve/page-catalog.js +105 -0
  58. package/dist/host/serve/page-render.d.ts +17 -0
  59. package/dist/host/serve/page-render.js +419 -0
  60. package/dist/host/serve/paths.d.ts +3 -0
  61. package/dist/host/serve/paths.js +74 -0
  62. package/dist/host/serve/route-catalog.d.ts +6 -0
  63. package/dist/host/serve/route-catalog.js +108 -0
  64. package/dist/host/serve/state.d.ts +30 -0
  65. package/dist/host/serve/state.js +36 -0
  66. package/dist/host/serve-host.d.ts +0 -17
  67. package/dist/host/serve-host.mjs +4 -1420
  68. package/dist/ssr/document.d.ts +2 -0
  69. package/dist/ssr/document.js +71 -0
  70. package/dist/ssr/dom-ssr.d.ts +10 -47
  71. package/dist/ssr/dom-ssr.js +10 -1284
  72. package/dist/ssr/render.d.ts +2 -0
  73. package/dist/ssr/render.js +78 -0
  74. package/dist/ssr/serialize.d.ts +3 -0
  75. package/dist/ssr/serialize.js +678 -0
  76. package/package.json +11 -11
  77. /package/dist/host/{route-layout-chain.d.ts → render/route-layout-chain.d.ts} +0 -0
@@ -0,0 +1,108 @@
1
+ export function parsePathPattern(pattern) {
2
+ const raw = String(pattern || '').trim();
3
+ if (!raw || raw === '/')
4
+ return [];
5
+ const parts = raw.replace(/^\/+/, '').split('/').filter(Boolean);
6
+ const segs = [];
7
+ for (const p of parts) {
8
+ if (isRouteGroupDir(p))
9
+ continue;
10
+ segs.push(parsePathSegment(p));
11
+ }
12
+ return segs;
13
+ }
14
+ function parsePathSegment(p) {
15
+ const catchAll = /^\[\.\.\.([^\]]+)\]$/.exec(p);
16
+ const param = /^\[([^\]]+)\]$/.exec(p);
17
+ const colon = /^:([A-Za-z_][\w]*)$/.exec(p);
18
+ if (catchAll)
19
+ return { kind: 'catch', name: catchAll[1] };
20
+ if (param)
21
+ return { kind: 'param', name: param[1] };
22
+ if (colon)
23
+ return { kind: 'param', name: colon[1] };
24
+ return { kind: 'static', value: p.toLowerCase() };
25
+ }
26
+ function isRouteGroupDir(seg) {
27
+ return typeof seg === 'string' && seg.startsWith('(') && seg.endsWith(')') && seg.length > 2;
28
+ }
29
+ export function isRouteBoundaryStem(stem) {
30
+ return stem === 'Layout' || stem === 'Loading' || stem === 'Error' || stem === 'NotFound';
31
+ }
32
+ export function matchFileRoute(pathname, catalog) {
33
+ const pathParts = decodeURIComponent(pathname.split('?')[0] || '/')
34
+ .replace(/\/+$/, '')
35
+ .split('/')
36
+ .filter(Boolean)
37
+ .map((p) => p.toLowerCase());
38
+ let best = null;
39
+ let bestScore = -1;
40
+ for (const page of catalog) {
41
+ const score = scoreRoute(page.segs, pathParts);
42
+ if (score == null)
43
+ continue;
44
+ if (score > bestScore) {
45
+ bestScore = score;
46
+ best = page;
47
+ }
48
+ }
49
+ return best;
50
+ }
51
+ export function extractRouteParams(segs, pathname) {
52
+ const pathParts = decodeURIComponent(pathname.split('?')[0] || '/')
53
+ .replace(/\/+$/, '')
54
+ .split('/')
55
+ .filter(Boolean);
56
+ const params = {};
57
+ let j = 0;
58
+ for (let i = 0; i < segs.length; i++) {
59
+ const s = segs[i];
60
+ if (s.kind === 'catch') {
61
+ if (s.name)
62
+ params[s.name] = pathParts.slice(j).join('/');
63
+ return params;
64
+ }
65
+ if (j >= pathParts.length)
66
+ break;
67
+ if (s.kind === 'param' && s.name) {
68
+ params[s.name] = pathParts[j];
69
+ }
70
+ j++;
71
+ }
72
+ return params;
73
+ }
74
+ function scoreRoute(segs, pathParts) {
75
+ let i = 0;
76
+ let j = 0;
77
+ let score = 0;
78
+ while (i < segs.length) {
79
+ const s = segs[i];
80
+ if (s.kind === 'catch') {
81
+ if (j >= pathParts.length)
82
+ return null;
83
+ score += 1;
84
+ return score;
85
+ }
86
+ if (j >= pathParts.length)
87
+ return null;
88
+ if (s.kind === 'static') {
89
+ if (s.value !== pathParts[j])
90
+ return null;
91
+ score += 1000;
92
+ }
93
+ else if (s.kind === 'param') {
94
+ score += 100;
95
+ }
96
+ i++;
97
+ j++;
98
+ }
99
+ if (j !== pathParts.length)
100
+ return null;
101
+ return score + segs.length;
102
+ }
103
+ export function isRootCatchAll(page) {
104
+ return page?.segs?.length === 1 && page.segs[0].kind === 'catch';
105
+ }
106
+ export function findRootCatchAll(catalog) {
107
+ return catalog.find((p) => isRootCatchAll(p)) || null;
108
+ }
@@ -0,0 +1,30 @@
1
+ import type { Server } from 'node:http';
2
+ import type { SseClient } from '../../shared/host.types.js';
3
+ export declare function resolveServeDistDir(): string;
4
+ export declare const serveState: {
5
+ distDir: string;
6
+ appPackageRequire: ReturnType<typeof import("node:module").createRequire> | null;
7
+ host: string;
8
+ port: number;
9
+ isDev: boolean;
10
+ reloadToken: number;
11
+ ssrRenderHost: Awaited<ReturnType<typeof import("../render/render-host.js").createRenderHost>> | null;
12
+ lastDevBuildId: string | null;
13
+ pageCatalog: any[];
14
+ pageCtors: Map<string, any>;
15
+ cssEntry: string | null;
16
+ styleBundleHash: string | null;
17
+ styleTheme: any;
18
+ localeArtifact: any;
19
+ localeLinkPlan: any;
20
+ sseClients: Set<SseClient>;
21
+ inFlight: number;
22
+ shuttingDown: boolean;
23
+ ready: boolean;
24
+ lastDevError: {
25
+ message: string;
26
+ stack?: string;
27
+ at: number;
28
+ } | null;
29
+ server: Server | null;
30
+ };
@@ -0,0 +1,36 @@
1
+ import path from 'node:path';
2
+ import { fileURLToPath } from 'node:url';
3
+ export function resolveServeDistDir() {
4
+ if (process.env.VMZ_DIST)
5
+ return path.resolve(process.env.VMZ_DIST);
6
+ const hostDir = path.join(path.dirname(fileURLToPath(import.meta.url)), '..');
7
+ const norm = hostDir.replace(/\\/g, '/');
8
+ const marker = '/_vmz/host';
9
+ const idx = norm.toLowerCase().lastIndexOf(marker);
10
+ if (idx >= 0)
11
+ return path.resolve(hostDir.slice(0, idx));
12
+ return hostDir;
13
+ }
14
+ export const serveState = {
15
+ distDir: resolveServeDistDir(),
16
+ appPackageRequire: null,
17
+ host: process.env.VMZ_HOST || '127.0.0.1',
18
+ port: Number(process.env.VMZ_PORT || process.env.PORT || 5173),
19
+ isDev: process.env.VMZ_DEV === '1' || process.env.VMZ_DEV === 'true',
20
+ reloadToken: Date.now(),
21
+ ssrRenderHost: null,
22
+ lastDevBuildId: null,
23
+ pageCatalog: [],
24
+ pageCtors: new Map(),
25
+ cssEntry: null,
26
+ styleBundleHash: null,
27
+ styleTheme: null,
28
+ localeArtifact: null,
29
+ localeLinkPlan: null,
30
+ sseClients: new Set(),
31
+ inFlight: 0,
32
+ shuttingDown: false,
33
+ ready: false,
34
+ lastDevError: null,
35
+ server: null,
36
+ };
@@ -1,18 +1 @@
1
- /**
2
- * Generic VMZ Node host �?SSR Route Graph pages + dist static + RPC/REST.
3
- *
4
- * Invoked by `vmz serve` / `vmz dev` (or: node dist/vmz-serve-host.mjs).
5
- *
6
- * Pathname matches compiled `_vmz/route-catalog.json` (frozen segs / pathPattern).
7
- * Hosts must not re-parse deployment pathPattern into a live catalog.
8
- * Not an SPA shell.
9
- *
10
- * `VMZ_DEV=1`: POST `/__vmz/reload` soft-reloads modules (cache-bust import);
11
- * GET `/__vmz/events` SSE notifies the browser:
12
- * - island HMR �?re-import `entry-client.js` (no full document reload)
13
- * - otherwise �?`location.reload`
14
- *
15
- * Dev resolve hook propagates `?t=` onto nested relative `file:` imports under
16
- * dist so soft reload does not keep a stale `lib/*.js` ESM cache entry.
17
- */
18
1
  export {};