@vidact/runtime 0.2.0-beta.0 → 0.2.0-beta.5
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/CHANGELOG.md +52 -0
- package/README.md +1 -1
- package/dist/actions.d.ts +32 -30
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +251 -266
- package/dist/actions.js.map +1 -1
- package/dist/async.d.ts +20 -17
- package/dist/async.d.ts.map +1 -1
- package/dist/async.js +18 -17
- package/dist/async.js.map +1 -1
- package/dist/compiled/async-resource.d.ts +9 -6
- package/dist/compiled/async-resource.d.ts.map +1 -1
- package/dist/compiled/async-resource.js +69 -77
- package/dist/compiled/async-resource.js.map +1 -1
- package/dist/compiled/core.d.ts +136 -147
- package/dist/compiled/core.d.ts.map +1 -1
- package/dist/compiled/core.js +2672 -2985
- package/dist/compiled/core.js.map +1 -1
- package/dist/compiled/types.d.ts +44 -56
- package/dist/compiled/types.d.ts.map +1 -1
- package/dist/compiled/types.js +10 -6
- package/dist/compiled/types.js.map +1 -1
- package/dist/compiled/validation.d.ts +4 -1
- package/dist/compiled/validation.d.ts.map +1 -1
- package/dist/compiled/validation.js +17 -20
- package/dist/compiled/validation.js.map +1 -1
- package/dist/component-spread.d.ts +5 -3
- package/dist/component-spread.d.ts.map +1 -1
- package/dist/component-spread.js +49 -67
- package/dist/component-spread.js.map +1 -1
- package/dist/concurrent.d.ts +20 -18
- package/dist/concurrent.d.ts.map +1 -1
- package/dist/concurrent.js +191 -210
- package/dist/concurrent.js.map +1 -1
- package/dist/direct-dom.d.ts +17 -12
- package/dist/direct-dom.d.ts.map +1 -1
- package/dist/direct-dom.js +187 -221
- package/dist/direct-dom.js.map +1 -1
- package/dist/dom/attributes.d.ts +9 -6
- package/dist/dom/attributes.d.ts.map +1 -1
- package/dist/dom/attributes.js +65 -47
- package/dist/dom/attributes.js.map +1 -1
- package/dist/dom/events.d.ts +5 -2
- package/dist/dom/events.d.ts.map +1 -1
- package/dist/dom/events.js +53 -65
- package/dist/dom/events.js.map +1 -1
- package/dist/dom/forms.d.ts +9 -6
- package/dist/dom/forms.d.ts.map +1 -1
- package/dist/dom/forms.js +152 -198
- package/dist/dom/forms.js.map +1 -1
- package/dist/dom/intrinsic.d.ts +17 -15
- package/dist/dom/intrinsic.d.ts.map +1 -1
- package/dist/dom/intrinsic.js +48 -50
- package/dist/dom/intrinsic.js.map +1 -1
- package/dist/dom/namespace.d.ts +4 -1
- package/dist/dom/namespace.d.ts.map +1 -1
- package/dist/dom/namespace.js +25 -28
- package/dist/dom/namespace.js.map +1 -1
- package/dist/dom/namespaces.d.ts +11 -8
- package/dist/dom/namespaces.d.ts.map +1 -1
- package/dist/dom/namespaces.js +14 -12
- package/dist/dom/namespaces.js.map +1 -1
- package/dist/dom/properties.d.ts +18 -16
- package/dist/dom/properties.d.ts.map +1 -1
- package/dist/dom/properties.js +273 -296
- package/dist/dom/properties.js.map +1 -1
- package/dist/dom/style-properties.d.ts +4 -1
- package/dist/dom/style-properties.d.ts.map +1 -1
- package/dist/dom/style-properties.js +49 -45
- package/dist/dom/style-properties.js.map +1 -1
- package/dist/dom/styles.d.ts +5 -2
- package/dist/dom/styles.d.ts.map +1 -1
- package/dist/dom/styles.js +47 -67
- package/dist/dom/styles.js.map +1 -1
- package/dist/dom-forms.d.ts +4 -1
- package/dist/dom-forms.d.ts.map +1 -1
- package/dist/dom-forms.js +16 -13
- package/dist/dom-forms.js.map +1 -1
- package/dist/dom-styles.d.ts +4 -1
- package/dist/dom-styles.d.ts.map +1 -1
- package/dist/dom-styles.js +10 -7
- package/dist/dom-styles.js.map +1 -1
- package/dist/framework-hydrate.d.ts +20 -17
- package/dist/framework-hydrate.d.ts.map +1 -1
- package/dist/framework-hydrate.js +128 -146
- package/dist/framework-hydrate.js.map +1 -1
- package/dist/framework-protocol.d.ts +27 -25
- package/dist/framework-protocol.d.ts.map +1 -1
- package/dist/framework-protocol.js +173 -211
- package/dist/framework-protocol.js.map +1 -1
- package/dist/framework.d.ts +34 -32
- package/dist/framework.d.ts.map +1 -1
- package/dist/framework.js +74 -93
- package/dist/framework.js.map +1 -1
- package/dist/hydrate.d.ts +11 -8
- package/dist/hydrate.d.ts.map +1 -1
- package/dist/hydrate.js +13 -9
- package/dist/hydrate.js.map +1 -1
- package/dist/hydration-bridge.d.ts +70 -58
- package/dist/hydration-bridge.d.ts.map +1 -1
- package/dist/hydration-bridge.js +77 -66
- package/dist/hydration-bridge.js.map +1 -1
- package/dist/hydration.d.ts +54 -28
- package/dist/hydration.d.ts.map +1 -1
- package/dist/hydration.js +450 -463
- package/dist/hydration.js.map +1 -1
- package/dist/index.d.ts +13 -13
- package/dist/index.js +11 -13
- package/dist/indexed-list.d.ts +8 -5
- package/dist/indexed-list.d.ts.map +1 -1
- package/dist/indexed-list.js +14 -7
- package/dist/indexed-list.js.map +1 -1
- package/dist/jsx-runtime.d.ts +10 -8
- package/dist/jsx-runtime.d.ts.map +1 -1
- package/dist/jsx-runtime.js +28 -23
- package/dist/jsx-runtime.js.map +1 -1
- package/dist/keyed-list.d.ts +13 -14
- package/dist/keyed-list.d.ts.map +1 -1
- package/dist/keyed-list.js +132 -160
- package/dist/keyed-list.js.map +1 -1
- package/dist/metadata.d.ts +6 -3
- package/dist/metadata.d.ts.map +1 -1
- package/dist/metadata.js +131 -164
- package/dist/metadata.js.map +1 -1
- package/dist/nested-prop.d.ts +4 -2
- package/dist/nested-prop.d.ts.map +1 -1
- package/dist/nested-prop.js +17 -16
- package/dist/nested-prop.js.map +1 -1
- package/dist/profiling.d.ts +11 -8
- package/dist/profiling.d.ts.map +1 -1
- package/dist/profiling.js +17 -17
- package/dist/profiling.js.map +1 -1
- package/dist/protocol.d.ts +5 -2
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +8 -5
- package/dist/protocol.js.map +1 -1
- package/dist/raw-html.d.ts +5 -2
- package/dist/raw-html.d.ts.map +1 -1
- package/dist/raw-html.js +86 -146
- package/dist/raw-html.js.map +1 -1
- package/dist/ref.d.ts +8 -3
- package/dist/ref.d.ts.map +1 -1
- package/dist/ref.js +10 -2
- package/dist/ref.js.map +1 -1
- package/dist/renderable-protocol.d.ts +26 -8
- package/dist/renderable-protocol.d.ts.map +1 -1
- package/dist/renderable-protocol.js +30 -9
- package/dist/renderable-protocol.js.map +1 -1
- package/dist/renderable.d.ts +27 -22
- package/dist/renderable.d.ts.map +1 -1
- package/dist/renderable.js +141 -133
- package/dist/renderable.js.map +1 -1
- package/dist/retained-ui.d.ts +9 -6
- package/dist/retained-ui.d.ts.map +1 -1
- package/dist/retained-ui.js +12 -10
- package/dist/retained-ui.js.map +1 -1
- package/dist/root.d.ts +18 -15
- package/dist/root.d.ts.map +1 -1
- package/dist/root.js +73 -85
- package/dist/root.js.map +1 -1
- package/dist/scheduler.d.ts +10 -8
- package/dist/scheduler.d.ts.map +1 -1
- package/dist/scheduler.js +97 -105
- package/dist/scheduler.js.map +1 -1
- package/dist/server-framework.d.ts +45 -42
- package/dist/server-framework.d.ts.map +1 -1
- package/dist/server-framework.js +209 -217
- package/dist/server-framework.js.map +1 -1
- package/dist/server.d.ts +130 -128
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +603 -710
- package/dist/server.js.map +1 -1
- package/dist/shared/promise.d.ts +6 -3
- package/dist/shared/promise.d.ts.map +1 -1
- package/dist/shared/promise.js +21 -19
- package/dist/shared/promise.js.map +1 -1
- package/dist/source-mask.d.ts +9 -6
- package/dist/source-mask.d.ts.map +1 -1
- package/dist/source-mask.js +45 -63
- package/dist/source-mask.js.map +1 -1
- package/dist/spread.d.ts +5 -2
- package/dist/spread.d.ts.map +1 -1
- package/dist/spread.js +79 -99
- package/dist/spread.js.map +1 -1
- package/dist/state-slot.d.ts +18 -15
- package/dist/state-slot.d.ts.map +1 -1
- package/dist/state-slot.js +43 -42
- package/dist/state-slot.js.map +1 -1
- package/dist/testing.d.ts +9 -6
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +16 -12
- package/dist/testing.js.map +1 -1
- package/package.json +8 -7
- package/src/actions.ts +415 -0
- package/src/async.ts +78 -0
- package/src/compiled/async-resource.ts +113 -0
- package/src/compiled/core.ts +4041 -0
- package/src/compiled/types.ts +96 -0
- package/src/compiled/validation.ts +23 -0
- package/src/component-spread.ts +86 -0
- package/src/concurrent.ts +310 -0
- package/src/direct-dom.ts +365 -0
- package/src/dom/attributes.ts +55 -0
- package/src/dom/events.ts +93 -0
- package/src/dom/forms.ts +220 -0
- package/src/dom/intrinsic.ts +94 -0
- package/src/dom/namespace.ts +30 -0
- package/src/dom/namespaces.ts +14 -0
- package/src/dom/properties.ts +355 -0
- package/src/dom/style-properties.ts +46 -0
- package/src/dom/styles.ts +86 -0
- package/src/dom-forms.ts +23 -0
- package/src/dom-styles.ts +11 -0
- package/src/env.d.ts +6 -0
- package/src/framework-hydrate.ts +224 -0
- package/src/framework-protocol.ts +335 -0
- package/src/framework.ts +161 -0
- package/src/hydrate.ts +38 -0
- package/src/hydration-bridge.ts +196 -0
- package/src/hydration.ts +642 -0
- package/src/index.ts +92 -0
- package/src/indexed-list.ts +20 -0
- package/src/jsx-runtime.ts +55 -0
- package/src/keyed-list.ts +233 -0
- package/src/metadata.ts +212 -0
- package/src/nested-prop.ts +27 -0
- package/src/profiling.ts +43 -0
- package/src/protocol.ts +8 -0
- package/src/raw-html.ts +206 -0
- package/src/ref.ts +13 -0
- package/src/renderable-protocol.ts +63 -0
- package/src/renderable.ts +283 -0
- package/src/retained-ui.ts +19 -0
- package/src/root.ts +122 -0
- package/src/scheduler.ts +136 -0
- package/src/server-framework.ts +397 -0
- package/src/server.ts +1160 -0
- package/src/shared/promise.ts +28 -0
- package/src/source-mask.ts +83 -0
- package/src/spread.ts +131 -0
- package/src/state-slot.ts +76 -0
- package/src/testing.ts +27 -0
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
package/dist/hydration.js
CHANGED
|
@@ -1,489 +1,476 @@
|
|
|
1
|
-
import { HydrationMismatch, installHydrationOperations
|
|
2
|
-
|
|
1
|
+
import { HydrationMismatch, installHydrationOperations } from "./hydration-bridge.js";
|
|
2
|
+
//#region src/hydration.ts
|
|
3
3
|
let activeHydration;
|
|
4
4
|
let activeInsertionPoint;
|
|
5
|
-
const hydrationFragments = new WeakMap();
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
}
|
|
286
|
-
export function hydrationRangeParent(start, end) {
|
|
287
|
-
if (activeHydration === undefined)
|
|
288
|
-
return undefined;
|
|
289
|
-
const parent = start.parentNode;
|
|
290
|
-
if (parent === null || end.parentNode !== parent)
|
|
291
|
-
throw mismatch('detached server marker range');
|
|
292
|
-
return parent;
|
|
5
|
+
const hydrationFragments = /* @__PURE__ */ new WeakMap();
|
|
6
|
+
function beginHydration(host) {
|
|
7
|
+
if (activeHydration !== void 0) throw new Error("a Vidact hydration is already active");
|
|
8
|
+
const ranges = scanRanges(host);
|
|
9
|
+
const root = ranges.roots[0];
|
|
10
|
+
if (root === void 0 || ranges.roots.length !== 1) throw mismatch(`expected exactly one v2 root marker range`);
|
|
11
|
+
activeHydration = {
|
|
12
|
+
host,
|
|
13
|
+
root,
|
|
14
|
+
components: ranges.components,
|
|
15
|
+
claimedElements: /* @__PURE__ */ new WeakSet(),
|
|
16
|
+
elementComponents: collectElementComponents(host),
|
|
17
|
+
elements: collectPostorderElements(root),
|
|
18
|
+
cursors: new WeakMap([[host, root[0].nextSibling]]),
|
|
19
|
+
slots: /* @__PURE__ */ new WeakMap(),
|
|
20
|
+
componentIndex: 0,
|
|
21
|
+
claimedElementCount: 0,
|
|
22
|
+
pendingStructuralParents: 0,
|
|
23
|
+
activeComponentStart: void 0
|
|
24
|
+
};
|
|
25
|
+
return () => {
|
|
26
|
+
activeHydration = void 0;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function finishHydration() {
|
|
30
|
+
const state = requireHydration();
|
|
31
|
+
if (state.componentIndex !== state.components.length) throw mismatch(`claimed ${state.componentIndex} of ${state.components.length} server component ranges`);
|
|
32
|
+
if (state.claimedElementCount !== state.elements.length) throw mismatch(`claimed ${state.claimedElementCount} of ${state.elements.length} server elements`);
|
|
33
|
+
const rootCursor = cursor(state, state.host);
|
|
34
|
+
if (rootCursor !== state.root[1]) throw mismatch(`compiled root did not consume the complete server root range; stopped at ${JSON.stringify(markerValue(rootCursor) ?? rootCursor?.nodeName ?? null)}`);
|
|
35
|
+
}
|
|
36
|
+
function hydrationRootMarkers() {
|
|
37
|
+
return requireHydration().root;
|
|
38
|
+
}
|
|
39
|
+
function isHydrating() {
|
|
40
|
+
return activeHydration !== void 0;
|
|
41
|
+
}
|
|
42
|
+
function createHydrationFragment(children) {
|
|
43
|
+
const fragment = document.createDocumentFragment();
|
|
44
|
+
hydrationFragments.set(fragment, children);
|
|
45
|
+
return fragment;
|
|
46
|
+
}
|
|
47
|
+
function hydrationFragmentChildren(fragment) {
|
|
48
|
+
return hydrationFragments.get(fragment);
|
|
49
|
+
}
|
|
50
|
+
function isHydrationMismatch(error) {
|
|
51
|
+
return error instanceof HydrationMismatch;
|
|
52
|
+
}
|
|
53
|
+
function claimHydrationElement(localName, namespace, matchesExpected) {
|
|
54
|
+
const state = activeHydration;
|
|
55
|
+
if (state === void 0) return void 0;
|
|
56
|
+
const candidates = state.elements.filter((candidate) => !state.claimedElements.has(candidate) && (state.activeComponentStart === void 0 || state.elementComponents.get(candidate) === state.activeComponentStart) && candidate.localName === localName && candidate.namespaceURI === namespace);
|
|
57
|
+
const expectedMatches = matchesExpected === void 0 ? candidates : candidates.filter(matchesExpected);
|
|
58
|
+
const matches = expectedMatches.length === 0 ? candidates : expectedMatches;
|
|
59
|
+
const element = state.pendingStructuralParents > 0 ? matches.find(containsArrayMarker) ?? matches[0] : matches[0];
|
|
60
|
+
if (element === void 0) throw mismatch(state.pendingStructuralParents > 0 ? `missing server structural parent <${localName}>` : `missing server element <${localName}>`);
|
|
61
|
+
if (state.pendingStructuralParents > 0) state.pendingStructuralParents = 0;
|
|
62
|
+
state.claimedElements.add(element);
|
|
63
|
+
state.claimedElementCount += 1;
|
|
64
|
+
state.cursors.set(element, initialCursor(element));
|
|
65
|
+
return element;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Called by a compiled list right before its container element is claimed. Lists are the
|
|
69
|
+
* only structural bindings whose server markup carries an `a` marker, so they are the
|
|
70
|
+
* only ones that may prefer a candidate containing one — for a conditional, Suspense or
|
|
71
|
+
* any other structural child that bias would pick an unrelated element that happens to
|
|
72
|
+
* hold a list (see `claimHydrationElement`).
|
|
73
|
+
*/
|
|
74
|
+
function noteHydrationStructuralParent() {
|
|
75
|
+
if (activeHydration !== void 0) activeHydration.pendingStructuralParents += 1;
|
|
76
|
+
}
|
|
77
|
+
function claimHydrationComponentRange() {
|
|
78
|
+
const state = activeHydration;
|
|
79
|
+
if (state === void 0) return void 0;
|
|
80
|
+
const range = state.components[state.componentIndex];
|
|
81
|
+
if (range === void 0) throw mismatch("missing server component marker range");
|
|
82
|
+
state.componentIndex += 1;
|
|
83
|
+
const parent = range[0].parentNode;
|
|
84
|
+
if (parent === null || range[1].parentNode !== parent) throw mismatch("server component marker range is detached");
|
|
85
|
+
return range;
|
|
86
|
+
}
|
|
87
|
+
function withHydrationComponentRange(range, operation) {
|
|
88
|
+
const state = activeHydration;
|
|
89
|
+
if (state === void 0) return operation();
|
|
90
|
+
const previous = state.activeComponentStart;
|
|
91
|
+
state.activeComponentStart = range[0];
|
|
92
|
+
try {
|
|
93
|
+
return operation();
|
|
94
|
+
} finally {
|
|
95
|
+
state.activeComponentStart = previous;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function withHydrationCursor(parent, value, operation) {
|
|
99
|
+
const state = activeHydration;
|
|
100
|
+
if (state === void 0) return operation();
|
|
101
|
+
const hadCursor = state.cursors.has(parent);
|
|
102
|
+
const previous = state.cursors.get(parent) ?? null;
|
|
103
|
+
state.cursors.set(parent, value);
|
|
104
|
+
try {
|
|
105
|
+
return operation();
|
|
106
|
+
} finally {
|
|
107
|
+
if (hadCursor) state.cursors.set(parent, previous);
|
|
108
|
+
else state.cursors.delete(parent);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
function claimHydrationNode(parent, node) {
|
|
112
|
+
const state = activeHydration;
|
|
113
|
+
if (state === void 0) return false;
|
|
114
|
+
enterHydrationSlot(state, parent);
|
|
115
|
+
if (cursor(state, parent) !== node) throw mismatch(`expected existing ${node.nodeName} at the current hydration position`);
|
|
116
|
+
setHydrationCursor(state, parent, node.nextSibling);
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
function claimHydrationComponentMount(parent, start, end) {
|
|
120
|
+
const state = activeHydration;
|
|
121
|
+
if (state === void 0) return false;
|
|
122
|
+
enterHydrationSlot(state, parent);
|
|
123
|
+
const current = cursor(state, parent);
|
|
124
|
+
if (current !== start && current !== end || start.parentNode !== parent || end.parentNode !== parent) throw mismatch("server component range does not match the compiled child position");
|
|
125
|
+
setHydrationCursor(state, parent, end.nextSibling);
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
function claimHydrationText(parent, expected) {
|
|
129
|
+
const state = activeHydration;
|
|
130
|
+
if (state === void 0) return void 0;
|
|
131
|
+
enterHydrationSlot(state, parent);
|
|
132
|
+
return claimTextPrefix(state, parent, expected);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Claims the text for a scalar binding together with a range it can later swap an
|
|
136
|
+
* element or collection into. The server emits no markers around text, so the binding
|
|
137
|
+
* borrows the enclosing child-slot markers when the slot holds exactly this text — the
|
|
138
|
+
* common case, and no DOM is touched. A text node shared with adjacent scalars (one
|
|
139
|
+
* parsed node for several array items) gets fresh anchor comments instead.
|
|
140
|
+
*/
|
|
141
|
+
function claimHydrationTextRange(parent, expected) {
|
|
142
|
+
const state = activeHydration;
|
|
143
|
+
if (state === void 0) return void 0;
|
|
144
|
+
enterHydrationSlot(state, parent);
|
|
145
|
+
const at = cursor(state, parent);
|
|
146
|
+
const slotStart = at === null ? parent.lastChild : at.previousSibling;
|
|
147
|
+
const text = claimTextPrefix(state, parent, expected);
|
|
148
|
+
const slotEnd = text === null ? at : text.nextSibling;
|
|
149
|
+
if (isMarker(slotStart, `v2:b`) && isMarker(slotEnd, `/v2:b`) && findClosingSibling(slotStart, `v2:b`) === slotEnd) return [
|
|
150
|
+
slotStart,
|
|
151
|
+
slotEnd,
|
|
152
|
+
text
|
|
153
|
+
];
|
|
154
|
+
const start = document.createComment("");
|
|
155
|
+
const end = document.createComment("");
|
|
156
|
+
const reference = text ?? at;
|
|
157
|
+
parent.insertBefore(start, reference);
|
|
158
|
+
parent.insertBefore(end, text === null ? reference : text.nextSibling);
|
|
159
|
+
return [
|
|
160
|
+
start,
|
|
161
|
+
end,
|
|
162
|
+
text
|
|
163
|
+
];
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* The server renders a scalar as bare text, and nothing at all for an empty one. Adjacent
|
|
167
|
+
* scalars in one collection parse into a single text node, so a claim takes only its own
|
|
168
|
+
* prefix and splits the rest off for the next claim.
|
|
169
|
+
*/
|
|
170
|
+
function claimTextPrefix(state, parent, expected) {
|
|
171
|
+
const node = cursor(state, parent);
|
|
172
|
+
if (expected === "") {
|
|
173
|
+
if (node instanceof Text && node.data === "") {
|
|
174
|
+
setHydrationCursor(state, parent, node.nextSibling);
|
|
175
|
+
return node;
|
|
176
|
+
}
|
|
177
|
+
setHydrationCursor(state, parent, node);
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
if (!(node instanceof Text)) throw mismatch(`expected server text ${JSON.stringify(expected)} in ${describeNode(parent)}; found ${describeNode(node)}`);
|
|
181
|
+
if (!node.data.startsWith(expected)) throw mismatch(`server text ${JSON.stringify(node.data)} does not match ${JSON.stringify(expected)}`);
|
|
182
|
+
if (node.data.length > expected.length) node.splitText(expected.length);
|
|
183
|
+
setHydrationCursor(state, parent, node.nextSibling);
|
|
184
|
+
return node;
|
|
185
|
+
}
|
|
186
|
+
function claimHydrationArrayRange(parent) {
|
|
187
|
+
const state = activeHydration;
|
|
188
|
+
if (state === void 0) return void 0;
|
|
189
|
+
enterHydrationSlot(state, parent);
|
|
190
|
+
const start = cursor(state, parent);
|
|
191
|
+
if (!isMarker(start, `v2:a`)) throw mismatch(`expected a v2 array marker in ${describeNode(parent)}; found ${JSON.stringify(markerValue(start) ?? start?.nodeName ?? null)}`);
|
|
192
|
+
const end = findClosingSibling(start, `v2:a`);
|
|
193
|
+
state.cursors.set(parent, start.nextSibling);
|
|
194
|
+
return [start, end];
|
|
195
|
+
}
|
|
196
|
+
function finishHydrationArrayRange(parent, end) {
|
|
197
|
+
const state = requireHydration();
|
|
198
|
+
if (cursor(state, parent) !== end) throw mismatch("compiled collection did not consume its complete server array range");
|
|
199
|
+
setHydrationCursor(state, parent, end.nextSibling);
|
|
200
|
+
}
|
|
201
|
+
function claimHydrationSlotRange(parent) {
|
|
202
|
+
const state = activeHydration;
|
|
203
|
+
if (state === void 0) return void 0;
|
|
204
|
+
const start = cursor(state, parent);
|
|
205
|
+
if (!isMarker(start, `v2:b`)) throw mismatch(`expected a v2 child-slot marker in ${describeNode(parent)}; found ${JSON.stringify(markerValue(start) ?? start?.nodeName ?? null)} after ${JSON.stringify(markerValue(start?.previousSibling) ?? start?.previousSibling?.nodeName ?? null)}; insertion=${JSON.stringify(markerValue(activeInsertionPoint?.[1]) ?? activeInsertionPoint?.[1]?.nodeName ?? null)}`);
|
|
206
|
+
const end = findClosingSibling(start, `v2:b`);
|
|
207
|
+
const slots = state.slots.get(parent) ?? [];
|
|
208
|
+
slots.push(end);
|
|
209
|
+
state.slots.set(parent, slots);
|
|
210
|
+
state.cursors.set(parent, start.nextSibling);
|
|
211
|
+
return [start, end];
|
|
212
|
+
}
|
|
213
|
+
function borrowHydrationSlotRange(parent, current) {
|
|
214
|
+
const state = activeHydration;
|
|
215
|
+
if (state === void 0) return void 0;
|
|
216
|
+
const start = current ? cursor(state, parent) : cursor(state, parent)?.previousSibling;
|
|
217
|
+
if (!isMarker(start, `v2:b`)) return void 0;
|
|
218
|
+
if (!current && activeInsertionPoint?.[0] === parent && isMarker(activeInsertionPoint[1], `/v2:b`)) return [start, activeInsertionPoint[1]];
|
|
219
|
+
return [start, findClosingSibling(start, `v2:b`)];
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Claims everything between two markers as-is, without hydrating into it. A Suspense
|
|
223
|
+
* boundary uses this when the server rendered its content but the client cannot
|
|
224
|
+
* produce it yet (a lazy chunk still loading): the server DOM stays on screen as a
|
|
225
|
+
* dehydrated boundary and the client render replaces it once the resource resolves.
|
|
226
|
+
* The elements and component ranges inside are marked claimed so `finishHydration`'s
|
|
227
|
+
* accounting still balances.
|
|
228
|
+
*/
|
|
229
|
+
function skipHydrationRange(start, end) {
|
|
230
|
+
const state = requireHydration();
|
|
231
|
+
const parent = start.parentNode;
|
|
232
|
+
if (parent === null || end.parentNode !== parent) throw mismatch("detached server marker range");
|
|
233
|
+
for (const element of collectPostorderElements([start, end])) {
|
|
234
|
+
if (state.claimedElements.has(element)) continue;
|
|
235
|
+
state.claimedElements.add(element);
|
|
236
|
+
state.claimedElementCount += 1;
|
|
237
|
+
}
|
|
238
|
+
while (state.componentIndex < state.components.length) {
|
|
239
|
+
const componentStart = state.components[state.componentIndex][0];
|
|
240
|
+
if (!((start.compareDocumentPosition(componentStart) & Node.DOCUMENT_POSITION_FOLLOWING) !== 0 && (componentStart.compareDocumentPosition(end) & Node.DOCUMENT_POSITION_FOLLOWING) !== 0)) break;
|
|
241
|
+
state.componentIndex += 1;
|
|
242
|
+
}
|
|
243
|
+
state.pendingStructuralParents = 0;
|
|
244
|
+
setHydrationCursor(state, parent, end);
|
|
245
|
+
}
|
|
246
|
+
function claimHydrationSuspenseFallback(parent) {
|
|
247
|
+
const state = activeHydration;
|
|
248
|
+
if (state === void 0) return void 0;
|
|
249
|
+
const marker = cursor(state, parent);
|
|
250
|
+
if (!isMarker(marker, `v2:p`)) return void 0;
|
|
251
|
+
setHydrationCursor(state, parent, marker.nextSibling);
|
|
252
|
+
return marker;
|
|
253
|
+
}
|
|
254
|
+
function withoutHydration(operation) {
|
|
255
|
+
const previous = activeHydration;
|
|
256
|
+
activeHydration = void 0;
|
|
257
|
+
try {
|
|
258
|
+
return operation();
|
|
259
|
+
} finally {
|
|
260
|
+
activeHydration = previous;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
function withHydrationInsertion(parent, before, operation) {
|
|
264
|
+
if (activeHydration === void 0) return operation();
|
|
265
|
+
const previous = activeInsertionPoint;
|
|
266
|
+
activeInsertionPoint = [parent, before];
|
|
267
|
+
try {
|
|
268
|
+
return operation();
|
|
269
|
+
} finally {
|
|
270
|
+
activeInsertionPoint = previous;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
function hydrationInsertionPoint() {
|
|
274
|
+
return activeInsertionPoint;
|
|
275
|
+
}
|
|
276
|
+
function hydrationCursor(parent) {
|
|
277
|
+
const state = activeHydration;
|
|
278
|
+
return state === void 0 ? void 0 : cursor(state, parent);
|
|
279
|
+
}
|
|
280
|
+
function hydrationRangeParent(start, end) {
|
|
281
|
+
if (activeHydration === void 0) return void 0;
|
|
282
|
+
const parent = start.parentNode;
|
|
283
|
+
if (parent === null || end.parentNode !== parent) throw mismatch("detached server marker range");
|
|
284
|
+
return parent;
|
|
293
285
|
}
|
|
294
286
|
function requireHydration() {
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
return activeHydration;
|
|
287
|
+
if (activeHydration === void 0) throw new Error("no Vidact hydration is active");
|
|
288
|
+
return activeHydration;
|
|
298
289
|
}
|
|
299
290
|
function cursor(state, parent) {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
291
|
+
if (!state.cursors.has(parent)) state.cursors.set(parent, initialCursor(parent));
|
|
292
|
+
return state.cursors.get(parent) ?? null;
|
|
293
|
+
}
|
|
294
|
+
function initialCursor(parent) {
|
|
295
|
+
return parent.firstChild;
|
|
303
296
|
}
|
|
304
297
|
function enterHydrationSlot(state, parent) {
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
state.cursors.set(parent, start);
|
|
298
|
+
const slots = state.slots.get(parent) ?? [];
|
|
299
|
+
let start = cursor(state, parent);
|
|
300
|
+
while (isMarker(start, `v2:b`)) {
|
|
301
|
+
slots.push(findClosingSibling(start, `v2:b`));
|
|
302
|
+
start = start.nextSibling;
|
|
303
|
+
}
|
|
304
|
+
if (slots.length !== 0) state.slots.set(parent, slots);
|
|
305
|
+
state.cursors.set(parent, start);
|
|
314
306
|
}
|
|
315
307
|
function setHydrationCursor(state, parent, value) {
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
state.cursors.set(parent, next);
|
|
308
|
+
const slots = state.slots.get(parent);
|
|
309
|
+
let next = value;
|
|
310
|
+
if (slots !== void 0) for (;;) {
|
|
311
|
+
const end = slots.at(-1);
|
|
312
|
+
if (end !== next) break;
|
|
313
|
+
slots.pop();
|
|
314
|
+
next = end.nextSibling;
|
|
315
|
+
}
|
|
316
|
+
state.cursors.set(parent, next);
|
|
328
317
|
}
|
|
329
318
|
function mismatch(message) {
|
|
330
|
-
|
|
319
|
+
return new HydrationMismatch(message);
|
|
320
|
+
}
|
|
321
|
+
/** `DIV.class-a[data-x]` — enough of an element to find it in the server markup. */
|
|
322
|
+
function describeNode(node) {
|
|
323
|
+
if (!(node instanceof Element)) return node?.nodeName ?? "null";
|
|
324
|
+
const classes = node.classList.length === 0 ? "" : `.${[...node.classList].join(".")}`;
|
|
325
|
+
const data = [...node.attributes].filter((attribute) => attribute.name.startsWith("data-") || attribute.name === "id").map((attribute) => `[${attribute.name}]`).join("");
|
|
326
|
+
return `${node.nodeName}${classes}${data}`;
|
|
331
327
|
}
|
|
332
328
|
function markerValue(node) {
|
|
333
|
-
|
|
329
|
+
return node instanceof Comment ? node.data : void 0;
|
|
334
330
|
}
|
|
335
331
|
function isMarker(node, value) {
|
|
336
|
-
|
|
332
|
+
return markerValue(node) === value;
|
|
337
333
|
}
|
|
338
334
|
function findClosingSibling(start, kind) {
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
335
|
+
let depth = 0;
|
|
336
|
+
for (let node = start.nextSibling; node !== null; node = node.nextSibling) {
|
|
337
|
+
if (isMarker(node, kind)) {
|
|
338
|
+
depth += 1;
|
|
339
|
+
continue;
|
|
340
|
+
}
|
|
341
|
+
if (!isMarker(node, `/${kind}`)) continue;
|
|
342
|
+
if (depth === 0) return node;
|
|
343
|
+
depth -= 1;
|
|
344
|
+
}
|
|
345
|
+
throw mismatch(`missing closing ${kind} marker`);
|
|
346
|
+
}
|
|
347
|
+
/** Paired markers; `p` (pending fallback) is a lone marker and stays out of the stacks. */
|
|
348
|
+
const RANGE_MARKER = new RegExp(`^\\/?v2:([abchr])$`);
|
|
353
349
|
function scanRanges(host) {
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
if (position & Node.DOCUMENT_POSITION_PRECEDING)
|
|
386
|
-
return 1;
|
|
387
|
-
return 0;
|
|
388
|
-
});
|
|
389
|
-
return { roots, components };
|
|
350
|
+
const roots = [];
|
|
351
|
+
const components = [];
|
|
352
|
+
const stacks = /* @__PURE__ */ new Map();
|
|
353
|
+
const walker = document.createTreeWalker(host, NodeFilter.SHOW_COMMENT);
|
|
354
|
+
for (let node = walker.nextNode(); node !== null; node = walker.nextNode()) {
|
|
355
|
+
const comment = node;
|
|
356
|
+
const match = RANGE_MARKER.exec(comment.data);
|
|
357
|
+
if (match === null) continue;
|
|
358
|
+
const kind = match[1];
|
|
359
|
+
if (!comment.data.startsWith("/")) {
|
|
360
|
+
const stack = stacks.get(kind) ?? [];
|
|
361
|
+
stack.push(comment);
|
|
362
|
+
stacks.set(kind, stack);
|
|
363
|
+
continue;
|
|
364
|
+
}
|
|
365
|
+
const start = stacks.get(kind)?.pop();
|
|
366
|
+
if (start === void 0) throw mismatch(`orphan closing v2:${kind} marker`);
|
|
367
|
+
if (kind === "r") roots.push([start, comment]);
|
|
368
|
+
if (kind === "c") components.push([start, comment]);
|
|
369
|
+
}
|
|
370
|
+
if ([...stacks.values()].some((stack) => stack.length !== 0)) throw mismatch(`unclosed v2 hydration marker`);
|
|
371
|
+
components.sort(([left], [right]) => {
|
|
372
|
+
const position = left.compareDocumentPosition(right);
|
|
373
|
+
if (position & Node.DOCUMENT_POSITION_FOLLOWING) return -1;
|
|
374
|
+
if (position & Node.DOCUMENT_POSITION_PRECEDING) return 1;
|
|
375
|
+
return 0;
|
|
376
|
+
});
|
|
377
|
+
return {
|
|
378
|
+
roots,
|
|
379
|
+
components
|
|
380
|
+
};
|
|
390
381
|
}
|
|
391
382
|
function collectPostorderElements(root) {
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
}
|
|
427
|
-
if (opaqueDepth !== 0)
|
|
428
|
-
throw mismatch('unbalanced vidact:v1 raw HTML marker range');
|
|
429
|
-
return elements;
|
|
383
|
+
const elements = [];
|
|
384
|
+
const visit = (element) => {
|
|
385
|
+
visitChildren(element);
|
|
386
|
+
elements.push(element);
|
|
387
|
+
};
|
|
388
|
+
const visitChildren = (parent) => {
|
|
389
|
+
let opaqueDepth = 0;
|
|
390
|
+
for (const child of parent.childNodes) {
|
|
391
|
+
if (isMarker(child, `v2:h`)) {
|
|
392
|
+
opaqueDepth += 1;
|
|
393
|
+
continue;
|
|
394
|
+
}
|
|
395
|
+
if (isMarker(child, `/v2:h`)) {
|
|
396
|
+
opaqueDepth -= 1;
|
|
397
|
+
continue;
|
|
398
|
+
}
|
|
399
|
+
if (opaqueDepth === 0 && child instanceof Element) visit(child);
|
|
400
|
+
}
|
|
401
|
+
if (opaqueDepth !== 0) throw mismatch(`unbalanced v2 raw HTML marker range`);
|
|
402
|
+
};
|
|
403
|
+
let opaqueDepth = 0;
|
|
404
|
+
for (let node = root[0].nextSibling; node !== null && node !== root[1]; node = node.nextSibling) {
|
|
405
|
+
if (isMarker(node, `v2:h`)) {
|
|
406
|
+
opaqueDepth += 1;
|
|
407
|
+
continue;
|
|
408
|
+
}
|
|
409
|
+
if (isMarker(node, `/v2:h`)) {
|
|
410
|
+
opaqueDepth -= 1;
|
|
411
|
+
continue;
|
|
412
|
+
}
|
|
413
|
+
if (opaqueDepth === 0 && node instanceof Element) visit(node);
|
|
414
|
+
}
|
|
415
|
+
if (opaqueDepth !== 0) throw mismatch(`unbalanced v2 raw HTML marker range`);
|
|
416
|
+
return elements;
|
|
430
417
|
}
|
|
431
418
|
function collectElementComponents(host) {
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
return owners;
|
|
419
|
+
const owners = /* @__PURE__ */ new WeakMap();
|
|
420
|
+
const components = [];
|
|
421
|
+
const walker = document.createTreeWalker(host, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT);
|
|
422
|
+
for (let node = walker.nextNode(); node !== null; node = walker.nextNode()) {
|
|
423
|
+
if (isMarker(node, `v2:c`)) {
|
|
424
|
+
components.push(node);
|
|
425
|
+
continue;
|
|
426
|
+
}
|
|
427
|
+
if (isMarker(node, `/v2:c`)) {
|
|
428
|
+
components.pop();
|
|
429
|
+
continue;
|
|
430
|
+
}
|
|
431
|
+
if (node instanceof Element) {
|
|
432
|
+
const owner = components.at(-1);
|
|
433
|
+
if (owner !== void 0) owners.set(node, owner);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
return owners;
|
|
451
437
|
}
|
|
452
438
|
function containsArrayMarker(element) {
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
}
|
|
439
|
+
const walker = document.createTreeWalker(element, NodeFilter.SHOW_COMMENT);
|
|
440
|
+
for (let node = walker.nextNode(); node !== null; node = walker.nextNode()) if (isMarker(node, `v2:a`)) return true;
|
|
441
|
+
return false;
|
|
442
|
+
}
|
|
443
|
+
function installHydration() {
|
|
444
|
+
installHydrationOperations({
|
|
445
|
+
begin: beginHydration,
|
|
446
|
+
finish: finishHydration,
|
|
447
|
+
rootMarkers: hydrationRootMarkers,
|
|
448
|
+
active: isHydrating,
|
|
449
|
+
createFragment: createHydrationFragment,
|
|
450
|
+
fragmentChildren: hydrationFragmentChildren,
|
|
451
|
+
claimElement: claimHydrationElement,
|
|
452
|
+
noteStructuralParent: noteHydrationStructuralParent,
|
|
453
|
+
claimComponentRange: claimHydrationComponentRange,
|
|
454
|
+
withComponentRange: withHydrationComponentRange,
|
|
455
|
+
withCursor: withHydrationCursor,
|
|
456
|
+
claimNode: claimHydrationNode,
|
|
457
|
+
claimComponentMount: claimHydrationComponentMount,
|
|
458
|
+
claimText: claimHydrationText,
|
|
459
|
+
claimTextRange: claimHydrationTextRange,
|
|
460
|
+
claimArrayRange: claimHydrationArrayRange,
|
|
461
|
+
finishArrayRange: finishHydrationArrayRange,
|
|
462
|
+
claimSlotRange: claimHydrationSlotRange,
|
|
463
|
+
borrowSlotRange: borrowHydrationSlotRange,
|
|
464
|
+
claimSuspenseFallback: claimHydrationSuspenseFallback,
|
|
465
|
+
skipRange: skipHydrationRange,
|
|
466
|
+
withoutHydration,
|
|
467
|
+
withInsertion: withHydrationInsertion,
|
|
468
|
+
insertionPoint: hydrationInsertionPoint,
|
|
469
|
+
cursor: hydrationCursor,
|
|
470
|
+
rangeParent: hydrationRangeParent
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
//#endregion
|
|
474
|
+
export { beginHydration, borrowHydrationSlotRange, claimHydrationArrayRange, claimHydrationComponentMount, claimHydrationComponentRange, claimHydrationElement, claimHydrationNode, claimHydrationSlotRange, claimHydrationSuspenseFallback, claimHydrationText, claimHydrationTextRange, createHydrationFragment, finishHydration, finishHydrationArrayRange, hydrationCursor, hydrationFragmentChildren, hydrationInsertionPoint, hydrationRangeParent, hydrationRootMarkers, installHydration, isHydrating, isHydrationMismatch, noteHydrationStructuralParent, skipHydrationRange, withHydrationComponentRange, withHydrationCursor, withHydrationInsertion, withoutHydration };
|
|
475
|
+
|
|
489
476
|
//# sourceMappingURL=hydration.js.map
|