@vmz/core 0.1.32 → 0.2.1

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 (66) hide show
  1. package/dist/{client-nav.d.ts → browser/client-nav.d.ts} +4 -13
  2. package/dist/{client-nav.js → browser/client-nav.js} +16 -74
  3. package/dist/browser/direct-api.types.d.ts +141 -0
  4. package/dist/browser/direct-api.types.js +4 -0
  5. package/dist/browser/direct-host-box.d.ts +11 -0
  6. package/dist/{direct-host-box.js → browser/direct-host-box.js} +2 -18
  7. package/dist/{dom-core.d.ts → browser/dom-core.d.ts} +67 -220
  8. package/dist/browser/dom-core.js +2484 -0
  9. package/dist/browser/dom-core.types.d.ts +127 -0
  10. package/dist/browser/dom-core.types.js +4 -0
  11. package/dist/{position-context.js → browser/position-context.js} +1 -1
  12. package/dist/browser/unknown-component.d.ts +14 -0
  13. package/dist/{unknown-component.js → browser/unknown-component.js} +5 -30
  14. package/dist/{dom.browser.d.ts → faces/dom.browser.d.ts} +2 -2
  15. package/dist/{dom.browser.js → faces/dom.browser.js} +2 -3
  16. package/dist/faces/dom.client.d.ts +4 -0
  17. package/dist/faces/dom.client.js +4 -0
  18. package/dist/faces/dom.d.ts +6 -0
  19. package/dist/faces/dom.js +6 -0
  20. package/dist/faces/http.d.ts +6 -0
  21. package/dist/{http.js → faces/http.js} +0 -1
  22. package/dist/faces/server.d.ts +30 -0
  23. package/dist/{server.js → faces/server.js} +27 -149
  24. package/dist/{vmz-dom.d.ts → faces/vmz-dom.d.ts} +1 -1
  25. package/dist/{vmz-dom.js → faces/vmz-dom.js} +1 -2
  26. package/dist/{vmz-runtime.d.ts → faces/vmz-runtime.d.ts} +1 -1
  27. package/dist/{vmz-runtime.js → faces/vmz-runtime.js} +1 -2
  28. package/dist/host/deployment-registry.d.ts +16 -0
  29. package/dist/{deployment-registry.js → host/deployment-registry.js} +1 -68
  30. package/dist/host/list-client-components.d.ts +14 -0
  31. package/dist/{list-client-components.js → host/list-client-components.js} +0 -37
  32. package/dist/{localize-body-links.js → host/localize-body-links.js} +0 -1
  33. package/dist/host/native-addon.d.ts +6 -0
  34. package/dist/{native-addon.js → host/native-addon.js} +0 -20
  35. package/dist/host/render-host.d.ts +20 -0
  36. package/dist/{render-host.js → host/render-host.js} +1 -17
  37. package/dist/{serve-host.d.ts → host/serve-host.d.ts} +3 -3
  38. package/dist/{serve-host.mjs → host/serve-host.mjs} +45 -168
  39. package/dist/shared/dom-attr-normalize.d.ts +8 -0
  40. package/dist/shared/dom-attr-normalize.js +71 -0
  41. package/dist/shared/host.types.d.ts +113 -0
  42. package/dist/shared/host.types.js +4 -0
  43. package/dist/shared/server.types.d.ts +67 -0
  44. package/dist/shared/server.types.js +4 -0
  45. package/dist/{dom-ssr.d.ts → ssr/dom-ssr.d.ts} +8 -37
  46. package/dist/{dom-ssr.js → ssr/dom-ssr.js} +189 -217
  47. package/package.json +34 -34
  48. package/dist/deployment-registry.d.ts +0 -70
  49. package/dist/direct-host-box.d.ts +0 -26
  50. package/dist/dom-core.js +0 -4815
  51. package/dist/dom.client.d.ts +0 -4
  52. package/dist/dom.client.js +0 -5
  53. package/dist/dom.d.ts +0 -6
  54. package/dist/dom.js +0 -7
  55. package/dist/http.d.ts +0 -6
  56. package/dist/list-client-components.d.ts +0 -62
  57. package/dist/native-addon.d.ts +0 -12
  58. package/dist/render-host.d.ts +0 -32
  59. package/dist/server.d.ts +0 -46
  60. package/dist/unknown-component.d.ts +0 -40
  61. /package/dist/{position-context.d.ts → browser/position-context.d.ts} +0 -0
  62. /package/dist/{index.d.ts → faces/index.d.ts} +0 -0
  63. /package/dist/{index.js → faces/index.js} +0 -0
  64. /package/dist/{localize-body-links.d.ts → host/localize-body-links.d.ts} +0 -0
  65. /package/dist/{route-layout-chain.d.ts → host/route-layout-chain.d.ts} +0 -0
  66. /package/dist/{route-layout-chain.js → host/route-layout-chain.js} +0 -0
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Shared class/style normalization for Direct SSR + client (0.1.33).
3
+ * Vue-compatible: string | string[] | object map | falsy parts.
4
+ */
5
+ /** Normalize one or more class fragments into a deduped class string. */
6
+ export declare function mergeClassParts(...parts: unknown[]): string;
7
+ /** Merge static + dynamic style fragments; later parts override same keys. */
8
+ export declare function mergeStyleParts(...parts: unknown[]): string;
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Shared class/style normalization for Direct SSR + client (0.1.33).
3
+ * Vue-compatible: string | string[] | object map | falsy parts.
4
+ */
5
+ function pushClassTokens(out, value) {
6
+ if (value == null || value === false)
7
+ return;
8
+ if (typeof value === 'string') {
9
+ for (const token of value.split(/\s+/)) {
10
+ if (token)
11
+ out.push(token);
12
+ }
13
+ return;
14
+ }
15
+ if (Array.isArray(value)) {
16
+ for (const item of value)
17
+ pushClassTokens(out, item);
18
+ return;
19
+ }
20
+ if (typeof value === 'object') {
21
+ for (const [key, enabled] of Object.entries(value)) {
22
+ if (enabled)
23
+ out.push(key);
24
+ }
25
+ return;
26
+ }
27
+ const s = String(value).trim();
28
+ if (s)
29
+ out.push(s);
30
+ }
31
+ /** Normalize one or more class fragments into a deduped class string. */
32
+ export function mergeClassParts(...parts) {
33
+ const tokens = [];
34
+ for (const part of parts)
35
+ pushClassTokens(tokens, part);
36
+ return [...new Set(tokens)].join(' ');
37
+ }
38
+ function parseStyleObject(value) {
39
+ const out = {};
40
+ if (value == null || value === false)
41
+ return out;
42
+ if (typeof value === 'string') {
43
+ for (const chunk of value.split(';')) {
44
+ const idx = chunk.indexOf(':');
45
+ if (idx < 0)
46
+ continue;
47
+ const key = chunk.slice(0, idx).trim();
48
+ const val = chunk.slice(idx + 1).trim();
49
+ if (key)
50
+ out[key] = val;
51
+ }
52
+ return out;
53
+ }
54
+ if (typeof value === 'object' && !Array.isArray(value)) {
55
+ for (const [key, raw] of Object.entries(value)) {
56
+ if (raw == null || raw === false)
57
+ continue;
58
+ out[key] = String(raw);
59
+ }
60
+ }
61
+ return out;
62
+ }
63
+ /** Merge static + dynamic style fragments; later parts override same keys. */
64
+ export function mergeStyleParts(...parts) {
65
+ const merged = {};
66
+ for (const part of parts)
67
+ Object.assign(merged, parseStyleObject(part));
68
+ return Object.entries(merged)
69
+ .map(([key, val]) => `${key}: ${val}`)
70
+ .join('; ');
71
+ }
@@ -0,0 +1,113 @@
1
+ /**
2
+ * Shared host / Node runtime types for `@vmz/core`.
3
+ */
4
+ import type { ServerResponse } from 'node:http';
5
+ export type ComponentEntry = {
6
+ chunkId: string;
7
+ name: string;
8
+ entry: string;
9
+ source?: string;
10
+ };
11
+ export type HostRequestOpts = {
12
+ signal?: AbortSignal;
13
+ searchParams?: URLSearchParams;
14
+ cookieHeader?: string;
15
+ method?: string;
16
+ body?: unknown;
17
+ };
18
+ export type LocaleHostCtx = {
19
+ localeId?: string;
20
+ dir?: string;
21
+ alternates?: unknown;
22
+ };
23
+ export type ClosedAccessResult = {
24
+ kind: 'allow';
25
+ props?: Record<string, unknown>;
26
+ } | {
27
+ kind: 'redirect';
28
+ location: string;
29
+ } | {
30
+ kind: 'deny';
31
+ } | {
32
+ kind: 'not-found';
33
+ };
34
+ export type SseClient = Pick<ServerResponse, 'write' | 'end'>;
35
+ /** Deployment graph document (`vmz.deployment.v0`). */
36
+ export type DeploymentUnit = {
37
+ chunkId?: string;
38
+ name?: string;
39
+ entry?: string;
40
+ source?: string;
41
+ dependsOn?: string[];
42
+ [key: string]: unknown;
43
+ };
44
+ export type DeploymentLayoutChain = {
45
+ routeId?: string;
46
+ layouts?: string[];
47
+ page?: string;
48
+ [key: string]: unknown;
49
+ };
50
+ export type DeploymentDocument = {
51
+ schema?: string;
52
+ units?: DeploymentUnit[];
53
+ layoutChain?: DeploymentLayoutChain[] | Record<string, unknown>;
54
+ dependsOn?: Record<string, string[]>;
55
+ [key: string]: unknown;
56
+ };
57
+ export type ComponentRegistryMap = Record<string, unknown>;
58
+ export type LoadComponentEntriesOpts = {
59
+ strict?: boolean;
60
+ closureRoots?: string[];
61
+ explicit?: Record<string, string>;
62
+ };
63
+ export type DedupeComponentEntriesOpts = {
64
+ strict?: boolean;
65
+ };
66
+ export type ImportComponentEntriesOpts = {
67
+ cacheBust?: string | number;
68
+ loaded?: Set<string>;
69
+ };
70
+ export type BootstrapComponentRegistryOpts = LoadComponentEntriesOpts & ImportComponentEntriesOpts & {
71
+ preload?: 'all' | 'closure' | 'none';
72
+ };
73
+ export type ClientComponentListEntry = {
74
+ name: string;
75
+ entry: string;
76
+ chunkId?: string;
77
+ };
78
+ export type ListClientComponentsOpts = {
79
+ strict?: boolean;
80
+ };
81
+ export type PreloadComponentRegistryOpts = ListClientComponentsOpts & {
82
+ cacheBust?: string | number;
83
+ include?: (entry: ClientComponentListEntry) => boolean;
84
+ explicit?: Record<string, string>;
85
+ closureRoots?: string[];
86
+ preload?: 'all' | 'closure' | 'none';
87
+ };
88
+ export type NativeAddon = Record<string, unknown>;
89
+ export type ServeHostOpts = {
90
+ distDir?: string;
91
+ port?: number;
92
+ host?: string;
93
+ signal?: AbortSignal;
94
+ [key: string]: unknown;
95
+ };
96
+ export type SoftReloadOpts = {
97
+ reason?: string;
98
+ signal?: AbortSignal;
99
+ [key: string]: unknown;
100
+ };
101
+ export type RenderPageStreamOpts = HostRequestOpts & {
102
+ localeId?: string;
103
+ [key: string]: unknown;
104
+ };
105
+ export type RenderHostOpts = {
106
+ strict?: boolean;
107
+ closureRoots?: string[];
108
+ explicit?: Record<string, string>;
109
+ preload?: 'all' | 'closure' | 'none';
110
+ cacheBust?: string | number;
111
+ rootChunkIds?: string[] | null;
112
+ [key: string]: unknown;
113
+ };
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Shared host / Node runtime types for `@vmz/core`.
3
+ */
4
+ export {};
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Types for `@vmz/core` server / RPC runtime (`faces/server.ts`).
3
+ */
4
+ import type { IncomingMessage } from 'node:http';
5
+ export type RpcRequest = {
6
+ moduleId: string;
7
+ method: string;
8
+ args?: unknown[];
9
+ };
10
+ export type Route = {
11
+ verb: string;
12
+ path: string;
13
+ moduleId: string;
14
+ method: string;
15
+ className?: string;
16
+ };
17
+ export type PageStreamResult = AsyncIterable<string> | {
18
+ status?: number;
19
+ stream?: AsyncIterable<string>;
20
+ redirect?: string;
21
+ headers?: Record<string, string>;
22
+ } | null;
23
+ export type NodeRequestOptions = {
24
+ distDir?: string;
25
+ renderIndex?: () => Promise<string> | string;
26
+ renderIndexStream?: (opts?: {
27
+ signal?: AbortSignal;
28
+ }) => AsyncIterable<string>;
29
+ renderPage?: (pathname: string) => Promise<string | null> | string | null;
30
+ renderPageStream?: (pathname: string, opts?: {
31
+ signal?: AbortSignal;
32
+ searchParams?: URLSearchParams;
33
+ cookieHeader?: string;
34
+ method?: string;
35
+ body?: unknown;
36
+ }) => Promise<PageStreamResult> | PageStreamResult;
37
+ req?: IncomingMessage;
38
+ };
39
+ export type ServerModuleResolver = (id: string) => string | URL;
40
+ /** Subset of `node:path` used by static resolve helpers. */
41
+ export type NodePathModule = {
42
+ resolve(...paths: string[]): string;
43
+ join(...paths: string[]): string;
44
+ extname(path: string): string;
45
+ readonly sep: string;
46
+ };
47
+ /** Minimal `fs.Stats`-like surface for static file probes. */
48
+ export type StatResult = {
49
+ isFile(): boolean;
50
+ isDirectory(): boolean;
51
+ };
52
+ export type StatFn = (path: string) => Promise<StatResult>;
53
+ export type DistStaticResolveOpts = {
54
+ cookieHeader?: string;
55
+ };
56
+ /** Multipart form fields: text, File, or repeated same-name values. */
57
+ export type MultipartFieldValue = string | File | Array<string | File>;
58
+ export type MultipartFields = Record<string, MultipartFieldValue>;
59
+ export type OctetStreamBody = {
60
+ bytes: Buffer;
61
+ size: number;
62
+ key: string;
63
+ uploadId: string;
64
+ chunkIndex?: number;
65
+ chunkTotal?: number;
66
+ contentType: string;
67
+ };
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Types for `@vmz/core` server / RPC runtime (`faces/server.ts`).
3
+ */
4
+ export {};
@@ -1,76 +1,47 @@
1
1
  /**
2
- * VMZ DOM SSR / hydrate / resume — precise patches, no VDOM diff.
2
+ * VMZ DOM SSR / hydrate / resume ??precise patches, no VDOM diff.
3
3
  * Imports client DOM primitives from ./dom-core.js for tree-shakeable browser entry.
4
4
  */
5
- import { findOwnedDefaultSlot } from './dom-core.js';
6
- export declare function renderToString(Component: any, props?: {}, opts?: {}): Promise<any>;
5
+ import { findOwnedDefaultSlot } from '../browser/dom-core.js';
6
+ export declare function renderToString(Component: any, props?: any, opts?: any): Promise<any>;
7
7
  /**
8
8
  * Stream SSR via the same Direct serialize schedule as `renderToString`.
9
- * Yields HTML chunks (open tag → children → close). Joining chunks equals `renderToString`.
9
+ * Yields HTML chunks (open tag ??children ??close). Joining chunks equals `renderToString`.
10
10
  * Supports AbortSignal for cancel; consumers should respect backpressure (await between chunks).
11
- * @param {new (props?: object) => any} Component
12
- * @param {object} [props]
13
- * @param {{ signal?: AbortSignal, slotHtml?: string }} [opts]
14
- * @returns {AsyncGenerator<string, void, void>}
15
11
  */
16
- export declare function renderToStream(Component: any, props?: {}, opts?: {}): AsyncGenerator<any, void, unknown>;
12
+ export declare function renderToStream(Component: any, props?: any, opts?: any): AsyncGenerator<any, void, unknown>;
17
13
  /**
18
14
  * Live-DOM counterpart: first default `<slot>` owned by this tree, not by a nested
19
15
  * `[data-vmz]` component (Button/Link labels, etc.).
20
16
  * Re-exported from dom-core (single implementation).
21
- * @param {Element | null | undefined} root
22
- * @returns {Element | null}
23
17
  */
24
18
  export { findOwnedDefaultSlot };
25
19
  /**
26
- * Hydrate/mount a file-route page inside an optional layout chain (outer → inner).
20
+ * Hydrate/mount a file-route page inside an optional layout chain (outer ??inner).
27
21
  * Mirrors SSR `slotHtml` wrapping: each layout's owned default slot becomes the
28
22
  * outlet for the next layout or the page. Retains layout instances on `container`
29
23
  * so SPA transitions can dispose only the page host.
30
- * @param {new (props?: object) => any} Page
31
- * @param {Element} container
32
- * @param {object} [props]
33
- * @param {Array<new (props?: object) => any>} [layoutCtors] outer → inner
34
- * @param {{ preserveState?: boolean | Record<string, unknown>, skipOnMount?: boolean }} [opts]
35
24
  */
36
25
  export declare function hydrateRoute(Page: any, container: any, props?: {}, layoutCtors?: any[], opts?: {}): Promise<any>;
37
26
  /**
38
27
  * SPA same-layout transition: dispose only the page host, keep layout instances.
39
28
  * Callers must verify `data-vmz-layout` is unchanged before using this.
40
- * @param {new (props?: object) => any} Page
41
- * @param {Element} container `#app` that already has `__vmzPageHost` / `__vmzLayoutInsts`
42
- * @param {object} [props]
43
- * @param {{ preserveState?: boolean | Record<string, unknown>, skipOnMount?: boolean }} [opts]
44
29
  */
45
- export declare function hydrateRoutePage(Page: any, container: any, props?: {}, opts?: {}): Promise<any>;
30
+ export declare function hydrateRoutePage(Page: any, container: any, props?: any, opts?: any): Promise<any>;
46
31
  /**
47
32
  * resume: attach to existing Island DOM without re-running construct structure or onMount.
48
33
  * Consumes ResumeEntry product (`data-vmz-resume`) derived from the same Execution Plan.
49
- * @param {new (props?: object) => any} Component
50
- * @param {HTMLElement} container
51
- * @param {{ props?: object, state?: Record<string, unknown>, strategy?: string } | null} [slice]
52
34
  */
53
35
  export declare function resume(Component: any, container: any, slice?: any): Promise<any>;
54
36
  /**
55
37
  * Resume all `[data-vmz-island]` hosts (prefer ResumeEntry / EventEntry over mount).
56
38
  * Event strategy islands wait for the DOM event before attach (lazy EventEntry).
57
- * @param {ParentNode} [root]
58
39
  */
59
40
  export declare function resumeIslands(root?: Document): void;
60
41
  /**
61
42
  * EventEntry attach: only wire `client:event` / `client:event:*` islands.
62
43
  * Idle/load/visible ResumeEntries are left alone (static shell can defer framework work).
63
- * @param {ParentNode} [root]
64
44
  */
65
45
  export declare function attachEventEntries(root?: Document): void;
66
- /**
67
- * @param {new (props?: object) => any} Component
68
- * @param {HTMLElement} container
69
- * @param {object} [props]
70
- * @param {{ preserveState?: boolean | Record<string, unknown>, skipOnMount?: boolean }} [opts]
71
- */
72
- export declare function hydrate(Component: any, container: any, props?: {}, opts?: {}): Promise<any>;
73
- /**
74
- * @param {ParentNode} [root]
75
- */
46
+ export declare function hydrate(Component: any, container: any, props?: any, opts?: any): Promise<any>;
76
47
  export declare function hydrateIslands(root?: Document): void;