@vmz/core 0.0.0 → 0.0.2
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 +46 -1
- package/dist/dom.d.ts +206 -0
- package/dist/dom.js +3067 -0
- package/dist/http.d.ts +6 -0
- package/dist/http.js +27 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/serve-host.d.ts +1 -0
- package/dist/serve-host.js +736 -0
- package/dist/serve-host.mjs +736 -0
- package/dist/server.d.ts +39 -0
- package/dist/server.js +437 -0
- package/package.json +39 -5
package/README.md
CHANGED
|
@@ -1,3 +1,48 @@
|
|
|
1
1
|
# @vmz/core
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The browser should not have to rediscover an application's structure after every click. Yet that is the default cost of
|
|
4
|
+
many UI systems: execute components again, compare a virtual tree, and infer which DOM work might be necessary.
|
|
5
|
+
|
|
6
|
+
`@vmz/core` is the production runtime behind VMZ's alternative. It executes the creation, patch, SSR, resumption, HTTP,
|
|
7
|
+
and lifetime schedules produced by the compiler. When VMZ can prove that a write affects one text binding, one control
|
|
8
|
+
region, or one keyed item, the runtime can update that target directly rather than begin from a whole component tree.
|
|
9
|
+
|
|
10
|
+
The same idea continues beyond a single browser update. SSR serializes planned regions; resumption attaches only
|
|
11
|
+
reachable state and event entries instead of repeating completed server work; ownership regions give async tasks and
|
|
12
|
+
resources a deterministic end; server and HTTP output stay tied to compiler-visible capabilities.
|
|
13
|
+
|
|
14
|
+
| Instead of... | VMZ runtime work begins from... |
|
|
15
|
+
|------------------------------------|-------------------------------------------------------|
|
|
16
|
+
| Re-running a component tree | A known affected binding or region |
|
|
17
|
+
| Reconciling a generic virtual tree | Direct create, patch, switch, or keyed-list work |
|
|
18
|
+
| Hydrating every rendered component | The event and state entries that are actually reached |
|
|
19
|
+
| Hoping cleanup follows callbacks | A compiler-known ownership and disposal boundary |
|
|
20
|
+
|
|
21
|
+
For application authors, this mostly stays out of sight: write VMZ source and let the compiler generate the plan.
|
|
22
|
+
`@vmz/core` matters when you care about the kind of runtime your product ships: small in responsibility, direct in
|
|
23
|
+
execution, and able to account for why its work exists. 🌱
|
|
24
|
+
|
|
25
|
+
## The hot path VMZ is aiming for
|
|
26
|
+
|
|
27
|
+
```text
|
|
28
|
+
state write
|
|
29
|
+
-> known dependency edge
|
|
30
|
+
-> affected computation or region
|
|
31
|
+
-> direct patch / switch / reconcile
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
There is no default detour through “execute every component that might matter, build virtual nodes, then compare them.” If analysis must widen, it widens to a safe region and should preserve the reason.
|
|
35
|
+
|
|
36
|
+
## More than DOM updates
|
|
37
|
+
|
|
38
|
+
- **Transactions:** related writes can settle before dependent work runs.
|
|
39
|
+
- **Ownership:** branches, list items, resources, and tasks have a known lifetime.
|
|
40
|
+
- **Cancellation:** an obsolete navigation or async generation cannot write into new state.
|
|
41
|
+
- **Resumption:** the browser attaches to server-produced work at the smallest reachable boundary.
|
|
42
|
+
- **Zero-JS delivery:** pages with no interactive requirement do not need an eager framework shell.
|
|
43
|
+
|
|
44
|
+
The runtime should not grow a second compiler made of reflection, string dependencies, or generic proxies. Its quality comes from faithfully executing the generated plan while keeping the production surface focused.
|
|
45
|
+
|
|
46
|
+
## License
|
|
47
|
+
|
|
48
|
+
MIT
|
package/dist/dom.d.ts
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VMZ DOM / SSR runtime — precise patches, no VDOM diff.
|
|
3
|
+
*
|
|
4
|
+
* Design: 规划设计/vmz/04 · Gate 3 (no production `render()`)
|
|
5
|
+
*
|
|
6
|
+
* Direct components expose `__vmzCreate` / `__vmzSerialize` / `__vmzPlan`.
|
|
7
|
+
* Mount, SSR, hydrate, and resume all run that same schedule.
|
|
8
|
+
* Field writes only run registered dep patches — never re-create structure.
|
|
9
|
+
*/
|
|
10
|
+
/** @param {boolean} [on] */
|
|
11
|
+
export declare function __vmzPrecisionEnable(on?: boolean): void;
|
|
12
|
+
/** @param {boolean} [on] */
|
|
13
|
+
export declare function __vmzTraceEnable(on?: boolean): void;
|
|
14
|
+
export declare function __vmzPrecisionReset(): void;
|
|
15
|
+
export declare function __vmzTraceReset(): void;
|
|
16
|
+
/**
|
|
17
|
+
* X5 StableId event snapshot (`vmz.dx.trace.v0` shape without schema stamp —
|
|
18
|
+
* host may wrap via ingestRuntimeTrace).
|
|
19
|
+
* @returns {{ schema: string, events: typeof traceBuf.events, status: string }}
|
|
20
|
+
*/
|
|
21
|
+
export declare function __vmzTraceSnapshot(): {
|
|
22
|
+
schema: string;
|
|
23
|
+
events: any[];
|
|
24
|
+
status: string;
|
|
25
|
+
};
|
|
26
|
+
/** @returns {typeof precision} */
|
|
27
|
+
export declare function __vmzPrecisionSnapshot(): {
|
|
28
|
+
enabled: boolean;
|
|
29
|
+
writes: number;
|
|
30
|
+
bindingEvals: number;
|
|
31
|
+
patchExecs: number;
|
|
32
|
+
domCreates: number;
|
|
33
|
+
domMoves: number;
|
|
34
|
+
domRemoves: number;
|
|
35
|
+
componentExecs: number;
|
|
36
|
+
writesByRoot: any;
|
|
37
|
+
bindingEvalsByDep: any;
|
|
38
|
+
patchesByDep: any;
|
|
39
|
+
bindingEvalsByBinding: any;
|
|
40
|
+
patchesByBinding: any;
|
|
41
|
+
};
|
|
42
|
+
/** @param {Record<string, any>} map */
|
|
43
|
+
export declare function registerComponents(map: any): void;
|
|
44
|
+
/**
|
|
45
|
+
* @param {new (props?: object) => any} Component
|
|
46
|
+
* @param {object} [props]
|
|
47
|
+
*/
|
|
48
|
+
export declare function renderToString(Component: any, props?: {}): Promise<any>;
|
|
49
|
+
/**
|
|
50
|
+
* Stream SSR via the same Direct serialize schedule as `renderToString`.
|
|
51
|
+
* Yields HTML chunks (open tag → children → close). Joining chunks equals `renderToString`.
|
|
52
|
+
* Supports AbortSignal for cancel; consumers should respect backpressure (await between chunks).
|
|
53
|
+
* @param {new (props?: object) => any} Component
|
|
54
|
+
* @param {object} [props]
|
|
55
|
+
* @param {{ signal?: AbortSignal }} [opts]
|
|
56
|
+
* @returns {AsyncGenerator<string, void, void>}
|
|
57
|
+
*/
|
|
58
|
+
export declare function renderToStream(Component: any, props?: {}, opts?: {}): AsyncGenerator<any, void, unknown>;
|
|
59
|
+
/**
|
|
60
|
+
* Mount once; later updates are dep patches only (never re-run structure).
|
|
61
|
+
* Requires compiler `__vmzCreate` (Gate 3 — no blueprint fallback).
|
|
62
|
+
* @param {new (props?: object) => any} Component
|
|
63
|
+
* @param {Element} container
|
|
64
|
+
* @param {object} [props]
|
|
65
|
+
*/
|
|
66
|
+
export declare function mount(Component: any, container: any, props?: {}): Promise<any>;
|
|
67
|
+
/**
|
|
68
|
+
* Snapshot plain state/prop field values for Island HMR (N4.3).
|
|
69
|
+
* @param {object} inst
|
|
70
|
+
* @returns {Record<string, unknown> | null}
|
|
71
|
+
*/
|
|
72
|
+
export declare function snapshotInstanceState(inst: any): {};
|
|
73
|
+
/**
|
|
74
|
+
* @param {object} inst
|
|
75
|
+
* @param {Record<string, unknown> | null | undefined} state
|
|
76
|
+
*/
|
|
77
|
+
export declare function applyPreservedState(inst: any, state: any): void;
|
|
78
|
+
/**
|
|
79
|
+
* L5: attach to existing Island DOM without re-running construct structure or onMount.
|
|
80
|
+
* Consumes ResumeEntry product (`data-vmz-resume`) derived from the same Execution Plan.
|
|
81
|
+
* @param {new (props?: object) => any} Component
|
|
82
|
+
* @param {HTMLElement} container
|
|
83
|
+
* @param {{ props?: object, state?: Record<string, unknown>, strategy?: string } | null} [slice]
|
|
84
|
+
*/
|
|
85
|
+
export declare function resume(Component: any, container: any, slice?: any): Promise<any>;
|
|
86
|
+
/**
|
|
87
|
+
* Resume all `[data-vmz-island]` hosts (prefer ResumeEntry / EventEntry over mount).
|
|
88
|
+
* Event strategy islands wait for the DOM event before attach (lazy EventEntry).
|
|
89
|
+
* @param {ParentNode} [root]
|
|
90
|
+
*/
|
|
91
|
+
export declare function resumeIslands(root?: Document): void;
|
|
92
|
+
/**
|
|
93
|
+
* EventEntry attach: only wire `client:event` / `client:event:*` islands.
|
|
94
|
+
* Idle/load/visible ResumeEntries are left alone (static shell can defer framework work).
|
|
95
|
+
* @param {ParentNode} [root]
|
|
96
|
+
*/
|
|
97
|
+
export declare function attachEventEntries(root?: Document): void;
|
|
98
|
+
/**
|
|
99
|
+
* @param {new (props?: object) => any} Component
|
|
100
|
+
* @param {HTMLElement} container
|
|
101
|
+
* @param {object} [props]
|
|
102
|
+
* @param {{ preserveState?: boolean | Record<string, unknown>, skipOnMount?: boolean }} [opts]
|
|
103
|
+
*/
|
|
104
|
+
export declare function hydrate(Component: any, container: any, props?: {}, opts?: {}): Promise<any>;
|
|
105
|
+
/**
|
|
106
|
+
* Tear down binders and stop patches. Safe to call more than once.
|
|
107
|
+
* Field writes after destroy no longer update DOM (values may still change).
|
|
108
|
+
* L4: also dispose owned DOM trees (child __vmzInst / region __vmzDispose).
|
|
109
|
+
* @param {object} inst
|
|
110
|
+
*/
|
|
111
|
+
export declare function destroy(inst: any): void;
|
|
112
|
+
/**
|
|
113
|
+
* L4: walk a DOM subtree and run lifetime dispose hooks + nested instance destroy.
|
|
114
|
+
* Does not mark the *calling* parent destroyed; safe from destroy(inst).
|
|
115
|
+
* @param {Node | null | undefined} root
|
|
116
|
+
*/
|
|
117
|
+
export declare function disposeDomTree(root: any): void;
|
|
118
|
+
/**
|
|
119
|
+
* @param {ParentNode} [root]
|
|
120
|
+
*/
|
|
121
|
+
export declare function hydrateIslands(root?: Document): void;
|
|
122
|
+
export declare function scheduleClient(strategy: any, fn: any): void;
|
|
123
|
+
/**
|
|
124
|
+
* AsyncTask cancel protocol (first slice): keyed generation + AbortSignal.
|
|
125
|
+
* Superseded runs and `destroy(inst)` abort prior work; stale results must not apply.
|
|
126
|
+
* @param {object} inst
|
|
127
|
+
* @param {string} key
|
|
128
|
+
* @param {(signal: AbortSignal, meta: { generation: number }) => any | Promise<any>} fn
|
|
129
|
+
* @returns {Promise<any>}
|
|
130
|
+
*/
|
|
131
|
+
export declare function __vmzRunTask(inst: any, key: any, fn: any): Promise<any>;
|
|
132
|
+
/** Abort all keyed tasks on an instance (also called from destroy). */
|
|
133
|
+
export declare function __vmzCancelTasks(inst: any): void;
|
|
134
|
+
/** @returns {'pending'|'success'|'error'|'cancelled'|null} */
|
|
135
|
+
export declare function __vmzTaskStatus(inst: any, key: any): any;
|
|
136
|
+
/**
|
|
137
|
+
* Mark a plain object as intentionally shared across ownership boundaries.
|
|
138
|
+
* Suppresses cross-component shared diagnostics (规划设计/vmz/13 §7.3).
|
|
139
|
+
* @param {any} value
|
|
140
|
+
*/
|
|
141
|
+
export declare function __vmzAllowShared(value: any): any;
|
|
142
|
+
/**
|
|
143
|
+
* Take exclusive ownership intent: clear multi-owner registry for this object.
|
|
144
|
+
* Subsequent field assigns re-register from the assigning instance only.
|
|
145
|
+
* @param {any} value
|
|
146
|
+
*/
|
|
147
|
+
export declare function __vmzTakeShared(value: any): any;
|
|
148
|
+
/**
|
|
149
|
+
* @returns {Array<{ kind: string, message: string }>}
|
|
150
|
+
*/
|
|
151
|
+
export declare function __vmzSharedCrossComponentDiagnostics(): any[];
|
|
152
|
+
export declare function __vmzSharedCrossComponentDiagnosticsReset(): void;
|
|
153
|
+
/**
|
|
154
|
+
* Read a nested path under a field root (for compound / update expansion).
|
|
155
|
+
* @param {any} inst
|
|
156
|
+
* @param {string} root
|
|
157
|
+
* @param {string[]} segs
|
|
158
|
+
*/
|
|
159
|
+
export declare function __vmzReadPath(inst: any, root: any, segs: any): any;
|
|
160
|
+
/**
|
|
161
|
+
* Short-circuit logical path assign (`||=` / `&&=` / `??=`).
|
|
162
|
+
* @param {any} inst
|
|
163
|
+
* @param {string} root
|
|
164
|
+
* @param {string[]} segs
|
|
165
|
+
* @param {'||'|'&&'|'??'} kind
|
|
166
|
+
* @param {any} rhs
|
|
167
|
+
*/
|
|
168
|
+
export declare function __vmzWritePathLogical(inst: any, root: any, segs: any, kind: any, rhs: any): any;
|
|
169
|
+
/**
|
|
170
|
+
* Compiler-inserted path write barrier (规划设计/vmz/13 §7.3).
|
|
171
|
+
* Mutates a plain owned object/array and schedules the same path notice Proxy would.
|
|
172
|
+
*
|
|
173
|
+
* Root-array index assigns (`tags[0] = x`) notify as field replace (structural),
|
|
174
|
+
* matching the transitional Proxy wrapArray behavior.
|
|
175
|
+
* Shared multi-owner: writing through one field notifies all owners of the same raw object.
|
|
176
|
+
*
|
|
177
|
+
* @param {any} inst
|
|
178
|
+
* @param {string} root field root
|
|
179
|
+
* @param {string[]} segs path under root (non-empty); dynamic indices already String(...)'d
|
|
180
|
+
* @param {any} value
|
|
181
|
+
*/
|
|
182
|
+
export declare function __vmzWritePath(inst: any, root: any, segs: any, value: any): any;
|
|
183
|
+
/**
|
|
184
|
+
* Compiler-inserted array mutator barrier (push/pop/splice/…).
|
|
185
|
+
* Applies the mutator on the plain array and schedules a structural notice
|
|
186
|
+
* at `root` + `baseSegs` (empty baseSegs → field replace).
|
|
187
|
+
*
|
|
188
|
+
* @param {any} inst
|
|
189
|
+
* @param {string} root
|
|
190
|
+
* @param {string[]} baseSegs
|
|
191
|
+
* @param {string} method
|
|
192
|
+
* @param {any[]} args
|
|
193
|
+
*/
|
|
194
|
+
export declare function __vmzArrayMutate(inst: any, root: any, baseSegs: any, method: any, args: any): any;
|
|
195
|
+
/**
|
|
196
|
+
* L4 WriteBarrier: true when value is an owned plain object with path barriers (no Proxy).
|
|
197
|
+
* @param {any} value
|
|
198
|
+
*/
|
|
199
|
+
export declare function __vmzIsWriteBarrierOwned(value: any): boolean;
|
|
200
|
+
/**
|
|
201
|
+
* True when value is the Proxy wrapper from array (or residual) reactive wrap.
|
|
202
|
+
* @param {any} value
|
|
203
|
+
*/
|
|
204
|
+
export declare function __vmzIsReactiveProxy(value: any): boolean;
|
|
205
|
+
/** @param {object} inst */
|
|
206
|
+
export declare function flushPending(inst: any): Promise<void>;
|