@vmz/core 0.0.1 β†’ 0.0.3

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