@vmz/core 0.1.32 → 0.2.0
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/dist/{client-nav.d.ts → browser/client-nav.d.ts} +4 -13
- package/dist/{client-nav.js → browser/client-nav.js} +16 -74
- package/dist/browser/direct-api.types.d.ts +58 -0
- package/dist/browser/direct-api.types.js +4 -0
- package/dist/browser/direct-host-box.d.ts +11 -0
- package/dist/{direct-host-box.js → browser/direct-host-box.js} +2 -18
- package/dist/{dom-core.d.ts → browser/dom-core.d.ts} +64 -220
- package/dist/browser/dom-core.js +2453 -0
- package/dist/browser/dom-core.types.d.ts +138 -0
- package/dist/browser/dom-core.types.js +4 -0
- package/dist/{position-context.js → browser/position-context.js} +1 -1
- package/dist/browser/unknown-component.d.ts +14 -0
- package/dist/{unknown-component.js → browser/unknown-component.js} +4 -28
- package/dist/{dom.browser.d.ts → faces/dom.browser.d.ts} +2 -2
- package/dist/{dom.browser.js → faces/dom.browser.js} +2 -3
- package/dist/faces/dom.client.d.ts +4 -0
- package/dist/faces/dom.client.js +4 -0
- package/dist/faces/dom.d.ts +6 -0
- package/dist/faces/dom.js +6 -0
- package/dist/{http.d.ts → faces/http.d.ts} +1 -1
- package/dist/{http.js → faces/http.js} +1 -2
- package/dist/{server.d.ts → faces/server.d.ts} +8 -25
- package/dist/{server.js → faces/server.js} +25 -155
- package/dist/{vmz-dom.d.ts → faces/vmz-dom.d.ts} +1 -1
- package/dist/{vmz-dom.js → faces/vmz-dom.js} +1 -2
- package/dist/{vmz-runtime.d.ts → faces/vmz-runtime.d.ts} +1 -1
- package/dist/{vmz-runtime.js → faces/vmz-runtime.js} +1 -2
- package/dist/host/deployment-registry.d.ts +16 -0
- package/dist/{deployment-registry.js → host/deployment-registry.js} +1 -68
- package/dist/host/list-client-components.d.ts +14 -0
- package/dist/{list-client-components.js → host/list-client-components.js} +0 -37
- package/dist/{localize-body-links.js → host/localize-body-links.js} +0 -1
- package/dist/host/native-addon.d.ts +6 -0
- package/dist/{native-addon.js → host/native-addon.js} +0 -20
- package/dist/host/render-host.d.ts +20 -0
- package/dist/{render-host.js → host/render-host.js} +0 -16
- package/dist/{serve-host.d.ts → host/serve-host.d.ts} +3 -3
- package/dist/{serve-host.mjs → host/serve-host.mjs} +45 -168
- package/dist/shared/host.types.d.ts +67 -0
- package/dist/shared/host.types.js +4 -0
- package/dist/shared/server.types.d.ts +39 -0
- package/dist/shared/server.types.js +4 -0
- package/dist/{dom-ssr.d.ts → ssr/dom-ssr.d.ts} +8 -37
- package/dist/{dom-ssr.js → ssr/dom-ssr.js} +159 -217
- package/package.json +34 -34
- package/dist/deployment-registry.d.ts +0 -70
- package/dist/direct-host-box.d.ts +0 -26
- package/dist/dom-core.js +0 -4815
- package/dist/dom.client.d.ts +0 -4
- package/dist/dom.client.js +0 -5
- package/dist/dom.d.ts +0 -6
- package/dist/dom.js +0 -7
- package/dist/list-client-components.d.ts +0 -62
- package/dist/native-addon.d.ts +0 -12
- package/dist/render-host.d.ts +0 -32
- package/dist/unknown-component.d.ts +0 -40
- /package/dist/{position-context.d.ts → browser/position-context.d.ts} +0 -0
- /package/dist/{index.d.ts → faces/index.d.ts} +0 -0
- /package/dist/{index.js → faces/index.js} +0 -0
- /package/dist/{localize-body-links.d.ts → host/localize-body-links.d.ts} +0 -0
- /package/dist/{route-layout-chain.d.ts → host/route-layout-chain.d.ts} +0 -0
- /package/dist/{route-layout-chain.js → host/route-layout-chain.js} +0 -0
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
/**
|
|
3
2
|
* Discover compiled client component modules from Deployment Plan only.
|
|
4
3
|
* Shared by serve-host SSR, static emit, and test hosts (plan-only host).
|
|
@@ -8,11 +7,6 @@ import { pathToFileURL } from 'node:url';
|
|
|
8
7
|
import { componentEntriesFromDeployment, dedupeComponentEntriesByTag, mergeExplicitComponentEntries, readDeploymentDocument, } from './deployment-registry.js';
|
|
9
8
|
export { DEPLOYMENT_SCHEMA, readDeploymentDocument, componentEntriesFromDeployment, collectDependsOnClosure, dedupeComponentEntriesByTag, mergeExplicitComponentEntries, loadComponentEntries, importAndRegisterComponentEntries, bootstrapComponentRegistry, } from './deployment-registry.js';
|
|
10
9
|
export { createRenderHost } from './render-host.js';
|
|
11
|
-
/**
|
|
12
|
-
* @param {string} dir
|
|
13
|
-
* @param {{ strict?: boolean }} [opts]
|
|
14
|
-
* @returns {Promise<Array<{ name: string, entry: string, chunkId?: string }>>}
|
|
15
|
-
*/
|
|
16
10
|
export async function listClientComponents(dir, opts = {}) {
|
|
17
11
|
const strict = opts.strict === true;
|
|
18
12
|
const deployment = readDeploymentDocument(dir, { strict });
|
|
@@ -33,12 +27,6 @@ export async function listClientComponents(dir, opts = {}) {
|
|
|
33
27
|
}
|
|
34
28
|
return [];
|
|
35
29
|
}
|
|
36
|
-
/**
|
|
37
|
-
* Sync variant for callers that already use fs sync (legacy static-emit helpers).
|
|
38
|
-
* @param {string} dir
|
|
39
|
-
* @param {{ strict?: boolean }} [opts]
|
|
40
|
-
* @returns {Array<{ name: string, entry: string, chunkId?: string }>}
|
|
41
|
-
*/
|
|
42
30
|
export function listClientComponentsSync(dir, opts = {}) {
|
|
43
31
|
const strict = opts.strict === true;
|
|
44
32
|
const deployment = readDeploymentDocument(dir, { strict });
|
|
@@ -59,11 +47,6 @@ export function listClientComponentsSync(dir, opts = {}) {
|
|
|
59
47
|
}
|
|
60
48
|
return [];
|
|
61
49
|
}
|
|
62
|
-
/**
|
|
63
|
-
* @param {Array<{ name: string, entry: string, chunkId?: string }>} entries
|
|
64
|
-
* @param {Record<string, string> | undefined} explicit
|
|
65
|
-
* @returns {Array<{ name: string, entry: string, chunkId?: string }>}
|
|
66
|
-
*/
|
|
67
50
|
export function mergeComponentEntries(entries, explicit) {
|
|
68
51
|
const normalized = entries.map((e) => ({
|
|
69
52
|
chunkId: e.chunkId || `components/${e.name}`,
|
|
@@ -76,12 +59,6 @@ export function mergeComponentEntries(entries, explicit) {
|
|
|
76
59
|
chunkId: e.chunkId,
|
|
77
60
|
}));
|
|
78
61
|
}
|
|
79
|
-
/**
|
|
80
|
-
* @param {string} distDir
|
|
81
|
-
* @param {Record<string, string> | undefined} [explicit]
|
|
82
|
-
* @param {{ strict?: boolean, closureRoots?: string[] }} [opts]
|
|
83
|
-
* @returns {Promise<Array<{ name: string, entry: string, chunkId?: string }>>}
|
|
84
|
-
*/
|
|
85
62
|
export async function resolveComponentEntries(distDir, explicit, opts = {}) {
|
|
86
63
|
const { loadComponentEntries } = await import('./deployment-registry.js');
|
|
87
64
|
const entries = await loadComponentEntries(distDir, {
|
|
@@ -91,19 +68,6 @@ export async function resolveComponentEntries(distDir, explicit, opts = {}) {
|
|
|
91
68
|
});
|
|
92
69
|
return entries.map((e) => ({ name: e.name, entry: e.entry, chunkId: e.chunkId }));
|
|
93
70
|
}
|
|
94
|
-
/**
|
|
95
|
-
* Import all (or filtered) client components and register for SSR / static emit / test hosts.
|
|
96
|
-
* @param {string} distDir
|
|
97
|
-
* @param {(map: Record<string, unknown>) => void} registerComponents
|
|
98
|
-
* @param {{
|
|
99
|
-
* cacheBust?: string | number,
|
|
100
|
-
* include?: (entry: { name: string, entry: string, chunkId?: string }) => boolean,
|
|
101
|
-
* explicit?: Record<string, string>,
|
|
102
|
-
* strict?: boolean,
|
|
103
|
-
* closureRoots?: string[],
|
|
104
|
-
* preload?: 'all' | 'closure' | 'none',
|
|
105
|
-
* }} [opts]
|
|
106
|
-
*/
|
|
107
71
|
export async function preloadComponentRegistry(distDir, registerComponents, opts = {}) {
|
|
108
72
|
let entries = await resolveComponentEntries(distDir, opts.explicit, {
|
|
109
73
|
strict: opts.strict,
|
|
@@ -111,7 +75,6 @@ export async function preloadComponentRegistry(distDir, registerComponents, opts
|
|
|
111
75
|
});
|
|
112
76
|
if (opts.include)
|
|
113
77
|
entries = entries.filter((e) => opts.include(e));
|
|
114
|
-
/** @type {Record<string, unknown>} */
|
|
115
78
|
const map = {};
|
|
116
79
|
for (const entry of entries) {
|
|
117
80
|
const abs = path.join(distDir, entry.entry);
|
|
@@ -82,7 +82,6 @@ export function localizeBodyLinks(html, localeId, artifact, escapeAttr, frozenPl
|
|
|
82
82
|
}
|
|
83
83
|
/** Compact RouteId → LocaleId → href table for browser (no path-prefix algebra). */
|
|
84
84
|
export function localeHrefTableFromPlan(plan) {
|
|
85
|
-
/** @type {Record<string, Record<string, string>>} */
|
|
86
85
|
const out = Object.create(null);
|
|
87
86
|
for (const row of plan?.rows || []) {
|
|
88
87
|
if (!row?.routeId || !row?.localeId || !row?.href)
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Discover and load the vmz N-API addon (same contract as `@vmz/vmz` loadNative).
|
|
3
|
+
*/
|
|
4
|
+
import type { NativeAddon } from '../shared/host.types.js';
|
|
5
|
+
export declare function loadNativeAddon(): NativeAddon;
|
|
6
|
+
export declare function requireNativeFn(fnName: string): (...args: unknown[]) => unknown;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
/**
|
|
3
2
|
* Discover and load the vmz N-API addon (same contract as `@vmz/vmz` loadNative).
|
|
4
3
|
*/
|
|
@@ -7,11 +6,7 @@ import { createRequire } from 'node:module';
|
|
|
7
6
|
import path from 'node:path';
|
|
8
7
|
import { fileURLToPath } from 'node:url';
|
|
9
8
|
const require = createRequire(import.meta.url);
|
|
10
|
-
/** @type {any | null | undefined} */
|
|
11
9
|
let _nativeAddon;
|
|
12
|
-
/**
|
|
13
|
-
* @returns {string}
|
|
14
|
-
*/
|
|
15
10
|
function platformTriple() {
|
|
16
11
|
const { platform, arch } = process;
|
|
17
12
|
if (platform === 'win32' && arch === 'x64')
|
|
@@ -28,10 +23,6 @@ function platformTriple() {
|
|
|
28
23
|
return 'linux-arm64-gnu';
|
|
29
24
|
return `${platform}-${arch}`;
|
|
30
25
|
}
|
|
31
|
-
/**
|
|
32
|
-
* @param {string} triple
|
|
33
|
-
* @returns {string}
|
|
34
|
-
*/
|
|
35
26
|
function platformShort(triple) {
|
|
36
27
|
if (triple === 'win32-x64-msvc')
|
|
37
28
|
return 'win32-x64';
|
|
@@ -43,14 +34,10 @@ function platformShort(triple) {
|
|
|
43
34
|
return 'linux-arm64';
|
|
44
35
|
return triple;
|
|
45
36
|
}
|
|
46
|
-
/**
|
|
47
|
-
* @returns {string[]}
|
|
48
|
-
*/
|
|
49
37
|
function nativeCandidatePaths() {
|
|
50
38
|
const triple = platformTriple();
|
|
51
39
|
const short = platformShort(triple);
|
|
52
40
|
const name = `@vmz/vmz-${short}`;
|
|
53
|
-
/** @type {string[]} */
|
|
54
41
|
const candidates = [];
|
|
55
42
|
try {
|
|
56
43
|
const resolved = require.resolve(`${name}/package.json`);
|
|
@@ -70,9 +57,6 @@ function nativeCandidatePaths() {
|
|
|
70
57
|
}
|
|
71
58
|
return candidates;
|
|
72
59
|
}
|
|
73
|
-
/**
|
|
74
|
-
* @returns {any}
|
|
75
|
-
*/
|
|
76
60
|
export function loadNativeAddon() {
|
|
77
61
|
if (_nativeAddon !== undefined) {
|
|
78
62
|
if (!_nativeAddon) {
|
|
@@ -102,10 +86,6 @@ export function loadNativeAddon() {
|
|
|
102
86
|
}
|
|
103
87
|
return _nativeAddon;
|
|
104
88
|
}
|
|
105
|
-
/**
|
|
106
|
-
* @param {string} fnName
|
|
107
|
-
* @returns {any}
|
|
108
|
-
*/
|
|
109
89
|
export function requireNativeFn(fnName) {
|
|
110
90
|
const native = loadNativeAddon();
|
|
111
91
|
const fn = native[fnName];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified SSR/DOM render host — explicit deployment bootstrap before renderToString/stream/mount.
|
|
3
|
+
* Hosts must not call renderToString until ensureComponents() has run for the active closure.
|
|
4
|
+
*/
|
|
5
|
+
export declare function createRenderHost(distDir: string, opts?: Record<string, unknown>): Promise<{
|
|
6
|
+
distDir: string;
|
|
7
|
+
deployment: import("../shared/host.types.js").DeploymentDocument;
|
|
8
|
+
dom: any;
|
|
9
|
+
loadedChunkIds: Set<string>;
|
|
10
|
+
ensureComponents: (rootChunkIds: any) => Promise<import("../shared/host.types.js").ComponentRegistryMap>;
|
|
11
|
+
closureChunkIds: (rootChunkIds: any) => Set<unknown>;
|
|
12
|
+
renderToString: any;
|
|
13
|
+
renderToStream: any;
|
|
14
|
+
mount: any;
|
|
15
|
+
hydrate: any;
|
|
16
|
+
resume: any;
|
|
17
|
+
destroy: any;
|
|
18
|
+
flushPending: any;
|
|
19
|
+
registerComponents: any;
|
|
20
|
+
}>;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
/**
|
|
3
2
|
* Unified SSR/DOM render host — explicit deployment bootstrap before renderToString/stream/mount.
|
|
4
3
|
* Hosts must not call renderToString until ensureComponents() has run for the active closure.
|
|
@@ -6,23 +5,11 @@
|
|
|
6
5
|
import path from 'node:path';
|
|
7
6
|
import { pathToFileURL } from 'node:url';
|
|
8
7
|
import { bootstrapComponentRegistry, collectDependsOnClosure, loadComponentEntries, readDeploymentDocument, importAndRegisterComponentEntries, } from './deployment-registry.js';
|
|
9
|
-
/**
|
|
10
|
-
* @param {string} distDir
|
|
11
|
-
* @param {{
|
|
12
|
-
* strictDeployment?: boolean,
|
|
13
|
-
* strict?: boolean,
|
|
14
|
-
* explicit?: Record<string, string>,
|
|
15
|
-
* cacheBust?: string | number,
|
|
16
|
-
* preload?: 'all' | 'closure' | 'none',
|
|
17
|
-
* closureRoots?: string[],
|
|
18
|
-
* }} [opts]
|
|
19
|
-
*/
|
|
20
8
|
export async function createRenderHost(distDir, opts = {}) {
|
|
21
9
|
const strict = opts.strictDeployment === true || opts.strict === true;
|
|
22
10
|
const domPath = path.join(distDir, 'vmz-dom.js');
|
|
23
11
|
const dom = await import(pathToFileURL(domPath).href);
|
|
24
12
|
const deployment = readDeploymentDocument(distDir, { strict });
|
|
25
|
-
/** @type {Set<string>} */
|
|
26
13
|
const loadedChunkIds = new Set();
|
|
27
14
|
const bootstrapOpts = {
|
|
28
15
|
strict,
|
|
@@ -37,7 +24,6 @@ export async function createRenderHost(distDir, opts = {}) {
|
|
|
37
24
|
}
|
|
38
25
|
/**
|
|
39
26
|
* Load component closure for root chunk ids (page + layouts + fixture).
|
|
40
|
-
* @param {string[]} rootChunkIds
|
|
41
27
|
*/
|
|
42
28
|
async function ensureComponents(rootChunkIds) {
|
|
43
29
|
if (!rootChunkIds?.length)
|
|
@@ -54,7 +40,6 @@ export async function createRenderHost(distDir, opts = {}) {
|
|
|
54
40
|
}
|
|
55
41
|
/**
|
|
56
42
|
* Union closure chunk ids (pages + layouts) without importing yet.
|
|
57
|
-
* @param {string[]} rootChunkIds
|
|
58
43
|
*/
|
|
59
44
|
function closureChunkIds(rootChunkIds) {
|
|
60
45
|
if (!deployment || !rootChunkIds?.length)
|
|
@@ -75,7 +60,6 @@ export async function createRenderHost(distDir, opts = {}) {
|
|
|
75
60
|
resume: dom.resume?.bind(dom),
|
|
76
61
|
destroy: dom.destroy?.bind(dom),
|
|
77
62
|
flushPending: dom.flushPending?.bind(dom),
|
|
78
|
-
/** @deprecated Prefer ensureComponents via createRenderHost; low-level escape hatch. */
|
|
79
63
|
registerComponents: dom.registerComponents.bind(dom),
|
|
80
64
|
};
|
|
81
65
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Generic VMZ Node host
|
|
2
|
+
* Generic VMZ Node host �?SSR Route Graph pages + dist static + RPC/REST.
|
|
3
3
|
*
|
|
4
4
|
* Invoked by `vmz serve` / `vmz dev` (or: node dist/vmz-serve-host.mjs).
|
|
5
5
|
*
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
*
|
|
10
10
|
* `VMZ_DEV=1`: POST `/__vmz/reload` soft-reloads modules (cache-bust import);
|
|
11
11
|
* GET `/__vmz/events` SSE notifies the browser:
|
|
12
|
-
* - island HMR
|
|
13
|
-
* - otherwise
|
|
12
|
+
* - island HMR �?re-import `entry-client.js` (no full document reload)
|
|
13
|
+
* - otherwise �?`location.reload`
|
|
14
14
|
*
|
|
15
15
|
* Dev resolve hook propagates `?t=` onto nested relative `file:` imports under
|
|
16
16
|
* dist so soft reload does not keep a stale `lib/*.js` ESM cache entry.
|