@vidact/runtime 0.2.0-beta.0 → 0.2.0-beta.4

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