what-core 0.14.0 → 0.15.0

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 (145) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +64 -38
  3. package/a11y.d.ts +128 -0
  4. package/data.d.ts +294 -0
  5. package/dist/a11y.js +510 -0
  6. package/dist/a11y.min.js +413 -0
  7. package/dist/actions.js +158 -0
  8. package/dist/actions.min.js +112 -0
  9. package/dist/animation.js +481 -0
  10. package/dist/animation.min.js +295 -0
  11. package/dist/async.js +180 -0
  12. package/dist/async.min.js +134 -0
  13. package/dist/components.js +577 -0
  14. package/dist/components.min.js +413 -0
  15. package/dist/data.js +1212 -0
  16. package/dist/data.min.js +918 -0
  17. package/dist/diagnostics.js +187 -0
  18. package/dist/diagnostics.min.js +134 -0
  19. package/dist/dom.js +796 -0
  20. package/dist/dom.min.js +603 -0
  21. package/dist/entries/a11y.js +43 -0
  22. package/dist/entries/a11y.min.js +43 -0
  23. package/dist/entries/data.js +29 -0
  24. package/dist/entries/data.min.js +29 -0
  25. package/dist/entries/dom.js +45 -0
  26. package/dist/entries/dom.min.js +45 -0
  27. package/dist/entries/form.js +31 -0
  28. package/dist/entries/form.min.js +31 -0
  29. package/dist/entries/internal.js +123 -0
  30. package/dist/entries/internal.min.js +123 -0
  31. package/dist/entries/motion.js +23 -0
  32. package/dist/entries/motion.min.js +23 -0
  33. package/dist/entries/ui.js +25 -0
  34. package/dist/entries/ui.min.js +25 -0
  35. package/dist/env.js +5 -0
  36. package/dist/env.min.js +5 -0
  37. package/dist/errors.js +1518 -0
  38. package/dist/errors.min.js +548 -0
  39. package/dist/form.js +936 -0
  40. package/dist/form.min.js +703 -0
  41. package/dist/guardrails.js +84 -0
  42. package/dist/guardrails.min.js +55 -0
  43. package/dist/h.js +232 -0
  44. package/dist/h.min.js +171 -0
  45. package/dist/head.js +241 -0
  46. package/dist/head.min.js +207 -0
  47. package/dist/helpers.js +126 -0
  48. package/dist/helpers.min.js +98 -0
  49. package/dist/hooks.js +255 -0
  50. package/dist/hooks.min.js +153 -0
  51. package/dist/hot.js +215 -0
  52. package/dist/hot.min.js +24 -0
  53. package/dist/hydration-data.js +495 -0
  54. package/dist/hydration-data.min.js +371 -0
  55. package/dist/import-changes.js +273 -0
  56. package/dist/import-changes.min.js +272 -0
  57. package/dist/index.js +95 -0
  58. package/dist/index.min.js +95 -227
  59. package/dist/jsx-dev-runtime.js +10 -0
  60. package/dist/jsx-dev-runtime.min.js +10 -1
  61. package/dist/jsx-runtime.js +27 -0
  62. package/dist/jsx-runtime.min.js +15 -1
  63. package/dist/live.js +54 -0
  64. package/dist/live.min.js +49 -0
  65. package/dist/markup-rules.js +250 -0
  66. package/dist/markup-rules.min.js +213 -0
  67. package/dist/reactive.js +3334 -0
  68. package/dist/reactive.min.js +2033 -0
  69. package/dist/render.js +4746 -0
  70. package/dist/render.min.js +2797 -1
  71. package/dist/scheduler.js +225 -0
  72. package/dist/scheduler.min.js +162 -0
  73. package/dist/selector.js +11 -0
  74. package/dist/selector.min.js +10 -0
  75. package/dist/server-context.js +148 -0
  76. package/dist/server-context.min.js +121 -0
  77. package/dist/skeleton.js +342 -0
  78. package/dist/skeleton.min.js +310 -0
  79. package/dist/store.js +72 -0
  80. package/dist/store.min.js +50 -0
  81. package/dist/testing.js +720 -0
  82. package/dist/testing.min.js +458 -1
  83. package/dist/vnode-adoption.js +19 -0
  84. package/dist/vnode-adoption.min.js +19 -0
  85. package/dist/vnode-renderer.js +61 -0
  86. package/dist/vnode-renderer.min.js +47 -0
  87. package/dom.d.ts +44 -0
  88. package/form.d.ts +218 -0
  89. package/hot.d.ts +35 -0
  90. package/index.d.ts +421 -736
  91. package/internal.d.ts +284 -0
  92. package/jsx-runtime.d.ts +160 -137
  93. package/markup-rules.d.ts +83 -0
  94. package/motion.d.ts +156 -0
  95. package/package.json +117 -3
  96. package/render.d.ts +278 -29
  97. package/src/a11y.js +64 -59
  98. package/src/actions.js +226 -0
  99. package/src/animation.js +105 -57
  100. package/src/async.js +259 -0
  101. package/src/components.js +495 -144
  102. package/src/data.js +1410 -1159
  103. package/src/diagnostics.js +263 -0
  104. package/src/dom.js +1159 -872
  105. package/src/entries/a11y.js +24 -0
  106. package/src/entries/data.js +17 -0
  107. package/src/entries/dom.js +29 -0
  108. package/src/entries/form.js +16 -0
  109. package/src/entries/internal.js +63 -0
  110. package/src/entries/motion.js +13 -0
  111. package/src/entries/ui.js +13 -0
  112. package/src/env-development.js +12 -0
  113. package/src/env.js +33 -0
  114. package/src/errors.js +1144 -168
  115. package/src/form.js +723 -225
  116. package/src/guardrails.js +38 -126
  117. package/src/h.js +227 -152
  118. package/src/head.js +189 -19
  119. package/src/helpers.js +47 -75
  120. package/src/hooks.js +233 -248
  121. package/src/hot.js +316 -0
  122. package/src/hydration-data.js +859 -16
  123. package/src/import-changes.js +156 -0
  124. package/src/index.js +38 -188
  125. package/src/jsx-dev-runtime.js +7 -14
  126. package/src/jsx-runtime.js +25 -9
  127. package/src/live.js +80 -0
  128. package/src/markup-rules.js +387 -0
  129. package/src/reactive.js +4400 -862
  130. package/src/render.js +6502 -2570
  131. package/src/scheduler.js +56 -21
  132. package/src/selector.js +31 -0
  133. package/src/server-context.js +252 -22
  134. package/src/skeleton.js +22 -12
  135. package/src/store.js +17 -31
  136. package/src/testing.js +389 -63
  137. package/src/vnode-adoption.js +48 -0
  138. package/src/vnode-renderer.js +114 -0
  139. package/testing.d.ts +81 -1
  140. package/ui.d.ts +20 -0
  141. package/dist/chunk-6YOUZ6T4.min.js +0 -1
  142. package/dist/chunk-FN6HXME3.min.js +0 -11
  143. package/dist/chunk-VKZY7JPN.min.js +0 -1
  144. package/src/agent-context.js +0 -127
  145. package/src/warnings.js +0 -193
@@ -0,0 +1,495 @@
1
+ // src/hydration-data.js
2
+ import { isHydrating, _resumeBoundary, _rowKeyDigest, _rowKeySalt, _installRowEntry } from "./render.js";
3
+ import { getCurrentComponent } from "./dom.js";
4
+ import { _currentComponent, _installSeedOps, _installStoreSeedOps, _serverStoreKey } from "./reactive.js";
5
+ import { getServerContext, isServerRender } from "./server-context.js";
6
+ import { report } from "./diagnostics.js";
7
+ var _data;
8
+ var _merged = null;
9
+ var MAPS = ["resources", "owned", "owners", "errors", "ownedErrors", "caught", "failed", "islandStores", "head", "loaded"];
10
+ var DATA_ELEMENTS = 'script[type="application/json"]#__what_data, script[type="application/json"][data-what-data]';
11
+ function mergeElement(el) {
12
+ _merged.add(el);
13
+ let payload;
14
+ try {
15
+ payload = JSON.parse(el.textContent);
16
+ } catch {
17
+ return;
18
+ }
19
+ if (!payload || typeof payload !== "object") return;
20
+ if (_data === null) _data = {};
21
+ if ("loaderData" in payload) _data.loaderData = payload.loaderData;
22
+ for (const name of MAPS) {
23
+ if (payload[name]) _data[name] = Object.assign(_data[name] || {}, payload[name]);
24
+ }
25
+ }
26
+ function scan() {
27
+ if (typeof document === "undefined") return;
28
+ if (_merged === null) {
29
+ _merged = /* @__PURE__ */ new Set();
30
+ _data = null;
31
+ }
32
+ for (const el of document.querySelectorAll(DATA_ELEMENTS)) {
33
+ if (!_merged.has(el)) mergeElement(el);
34
+ }
35
+ }
36
+ function isDataElement(el) {
37
+ return el.tagName === "SCRIPT" && el.getAttribute("type") === "application/json" && (el.id === "__what_data" || el.hasAttribute("data-what-data"));
38
+ }
39
+ function __readHydrationData() {
40
+ if (typeof document === "undefined") return null;
41
+ scan();
42
+ return _data;
43
+ }
44
+ function __resetHydrationData() {
45
+ _data = void 0;
46
+ _merged = null;
47
+ }
48
+ function getLoaderData() {
49
+ const data = __readHydrationData();
50
+ return data ? data.loaderData : void 0;
51
+ }
52
+ function lookup(map, key) {
53
+ const data = __readHydrationData();
54
+ return data && data[map] && Object.hasOwn(data[map], key) ? data[map][key] : void 0;
55
+ }
56
+ function getResource(key) {
57
+ return lookup("resources", key);
58
+ }
59
+ function _loadedResource(key) {
60
+ return lookup("loaded", key) !== void 0;
61
+ }
62
+ function getResourceError(key) {
63
+ return lookup("errors", key);
64
+ }
65
+ function formatId(prefix, index) {
66
+ const digits = index.toString(36);
67
+ const extra = digits.length - 1;
68
+ return prefix + (extra ? String.fromCharCode(64 + extra) : "") + digits;
69
+ }
70
+ function stepAt(path, at) {
71
+ const c = path.charCodeAt(at);
72
+ const extra = c >= 65 && c <= 90 ? c - 64 : 0;
73
+ const start = extra ? at + 1 : at;
74
+ const end = start + extra + 1;
75
+ if (end > path.length) return null;
76
+ const index = parseInt(path.slice(start, end), 36);
77
+ return Number.isNaN(index) ? null : { end, index };
78
+ }
79
+ function holderOf(frame, root) {
80
+ return frame === null ? root : frame._ownerHolder || frame;
81
+ }
82
+ function _ownerCounter(frame, root) {
83
+ return holderOf(frame, root);
84
+ }
85
+ function _assignOwnerPath(frame, parent, root, site) {
86
+ const holder = holderOf(parent, root);
87
+ const prefix = parent ? parent._ownerPath || "" : "";
88
+ if (frame.Component !== void 0 && frame.Component._lowered === true) {
89
+ frame._ownerPath = prefix;
90
+ frame._ownerHolder = holder;
91
+ if (placeRow !== null) placeRow(frame, parent, null, site);
92
+ return false;
93
+ }
94
+ const index = holder._ownerChildren || 0;
95
+ holder._ownerChildren = index + 1;
96
+ frame._ownerPath = formatId(prefix, index);
97
+ if (placeRow !== null) placeRow(frame, parent, holder, site);
98
+ return true;
99
+ }
100
+ function _currentOwnerPath() {
101
+ const frame = getCurrentComponent();
102
+ return frame ? frame._ownerPath : void 0;
103
+ }
104
+ function _nextOwnerKey(frame, root) {
105
+ const holder = holderOf(frame || null, root);
106
+ const index = holder._ownerResources || 0;
107
+ holder._ownerResources = index + 1;
108
+ return `${frame ? frame._ownerPath || "" : ""}:${index}`;
109
+ }
110
+ var isRowKey = (key) => typeof key === "string" || typeof key === "number" && Number.isFinite(key);
111
+ var placeRow = null;
112
+ var rootRow = null;
113
+ function placeInRow(frame, parent, holder, site) {
114
+ const open = holder === null ? void 0 : holder._row;
115
+ const row = rowOf(open);
116
+ const step = holder === null ? "" : holder._islandHost === true ? placeOf(void 0, holder, void 0, "X", frame._ownerPath) : placeOf(open, row !== void 0 ? row : holder, site, "X", frame._ownerPath);
117
+ if (row !== void 0) {
118
+ frame._rowIn = row;
119
+ frame._rowPath = step;
120
+ } else if (parent && parent._rowIn !== void 0) {
121
+ frame._rowIn = parent._rowIn;
122
+ frame._rowPath = parent._rowPath + step;
123
+ } else {
124
+ frame._placePath = (parent ? parent._placePath || "" : "") + step;
125
+ }
126
+ }
127
+ function stepsOf(frame) {
128
+ const path = frame._ownerPath || "";
129
+ return frame._placePath !== void 0 && path[0] !== UNANCHORED ? frame._placePath : path;
130
+ }
131
+ function readRootRow(root, container) {
132
+ const row = root._ownerPath[0] !== UNANCHORED ? container.getAttribute("data-what-row") : null;
133
+ if (row === null || !ROW_PATH.test(row)) return;
134
+ if (row.includes("-")) {
135
+ root._rowIn = { written: row };
136
+ root._rowPath = "";
137
+ } else {
138
+ root._placePath = row;
139
+ }
140
+ }
141
+ var ROW_PATH = /^[0-9A-Za-z_.-]+$/;
142
+ var rowOf = (open) => open !== void 0 && open.slot !== void 0 ? open.row : open;
143
+ function _enterRow(frame, root, list, key, index) {
144
+ const holder = holderOf(frame === void 0 ? _currentComponent() : frame, root);
145
+ const open = holder._row;
146
+ if (list === null) {
147
+ if (typeof key === "number") holder._row = { up: open, slot: key, row: rowOf(open) };
148
+ return open;
149
+ }
150
+ const outer = rowOf(open);
151
+ list.place ??= placeOf(open, outer !== void 0 ? outer : holder, list.slot, "", list);
152
+ if (!isRowKey(key)) return open;
153
+ let n;
154
+ if (list.keys !== void 0) n = (list.counts ??= keyCounts(list.keys))[
155
+ /** @type {number} */
156
+ index
157
+ ];
158
+ else {
159
+ const seen = list.seen ??= /* @__PURE__ */ new Map();
160
+ n = seen.get(key) || 0;
161
+ seen.set(key, n + 1);
162
+ }
163
+ let up = outer;
164
+ let lead = "";
165
+ if (outer === void 0) {
166
+ up = holder._rowIn !== void 0 ? holder._rowIn : null;
167
+ lead = up !== null ? holder._rowPath : stepsOf(holder);
168
+ }
169
+ holder._row = { up, lead, list: list.place, key, n };
170
+ return open;
171
+ }
172
+ function placeOf(open, scope, number, end, who) {
173
+ let place = "";
174
+ for (let s = open; s !== void 0 && s.slot !== void 0; s = s.up) place = formatId("", s.slot) + place;
175
+ if (number != null) place += "Z" + formatId("", number);
176
+ place += end;
177
+ const taken = scope._places ??= /* @__PURE__ */ new Map();
178
+ const seen = taken.get(place);
179
+ let before = 0;
180
+ if (seen === void 0) taken.set(place, [1, who]);
181
+ else if (seen[1] === who) before = seen[0] - 1;
182
+ else {
183
+ before = seen[0]++;
184
+ seen[1] = who;
185
+ }
186
+ return before === 0 ? place : place + "Y" + formatId("", before);
187
+ }
188
+ function keyCounts(keys) {
189
+ const seen = /* @__PURE__ */ new Map();
190
+ const counts = [];
191
+ for (let i = 0; i < keys.length; i++) {
192
+ const key = keys[i];
193
+ if (!isRowKey(key)) {
194
+ counts.push(0);
195
+ continue;
196
+ }
197
+ const n = seen.get(key) || 0;
198
+ seen.set(key, n + 1);
199
+ counts.push(n);
200
+ }
201
+ return counts;
202
+ }
203
+ function _leaveRow(frame, root, saved) {
204
+ holderOf(frame === void 0 ? _currentComponent() : frame, root)._row = saved;
205
+ }
206
+ function _installRowKeys() {
207
+ placeRow = placeInRow;
208
+ rootRow = readRootRow;
209
+ _installRowEntry(_enterRow, _leaveRow);
210
+ }
211
+ function _tracksRows() {
212
+ return placeRow !== null;
213
+ }
214
+ function rowPath(row, salt) {
215
+ let path = "";
216
+ for (let r = row; r !== null; r = r.up) {
217
+ if (r.written !== void 0) return r.written + path;
218
+ path = r.lead + "-" + r.list + "." + _rowKeyDigest(r.key, salt) + formatId("", r.n) + path;
219
+ }
220
+ return path;
221
+ }
222
+ function _islandHost() {
223
+ const frame = _currentComponent();
224
+ if (frame !== null) frame._islandHost = true;
225
+ }
226
+ function _currentRowPath(salt) {
227
+ const frame = _currentComponent();
228
+ if (frame === null || frame._rowIn === void 0 && frame._placePath === void 0) return null;
229
+ frame._islandHost = true;
230
+ return frame._rowIn !== void 0 ? rowPath(frame._rowIn, salt) + frame._rowPath : frame._placePath;
231
+ }
232
+ var SALT = /^[0-9A-Za-z_.]{11}$/;
233
+ function _renderSalt() {
234
+ const ctx = getServerContext();
235
+ if (ctx === null) return _rowKeySalt();
236
+ let salt = salts.get(ctx);
237
+ if (salt === void 0) salts.set(ctx, salt = _rowKeySalt());
238
+ return salt;
239
+ }
240
+ var salts = /* @__PURE__ */ new WeakMap();
241
+ function _actionKeySalt(key) {
242
+ if (typeof key !== "string" || key.charCodeAt(11) !== 47) return null;
243
+ const salt = key.slice(0, 11);
244
+ return SALT.test(salt) ? salt : null;
245
+ }
246
+ function _actionStateKey() {
247
+ const frame = _currentComponent();
248
+ if (frame === null || frame._ownerPath === void 0 || !(isServerRender() || isHydrating())) return null;
249
+ const holder = holderOf(frame, null);
250
+ const index = holder._ownerActions || 0;
251
+ holder._ownerActions = index + 1;
252
+ const positional = `${stepsOf(frame)}:${index}`;
253
+ const row = frame._rowIn;
254
+ if (row === void 0 || positional[0] === UNANCHORED) {
255
+ const key2 = () => positional;
256
+ key2.salted = false;
257
+ return key2;
258
+ }
259
+ const below = `${frame._rowPath}:${index}`;
260
+ const key = (salt) => typeof salt === "string" && SALT.test(salt) ? `${salt}/${rowPath(row, salt)}${below}` : UNANCHORED + positional;
261
+ key.salted = true;
262
+ return key;
263
+ }
264
+ var UNANCHORED = "~";
265
+ var OWNER_PATH = /^[0-9A-Za-z]*$/;
266
+ function _hydrationRoot(container) {
267
+ const root = { _ownerPath: anchorPath(container), _ownerChildren: 0 };
268
+ if (rootRow !== null) rootRow(root, container);
269
+ return root;
270
+ }
271
+ function anchorPath(container) {
272
+ if (!container || container.nodeType !== 1) return UNANCHORED;
273
+ const owner = container.getAttribute("data-what-owner");
274
+ if (owner !== null) return OWNER_PATH.test(owner) ? owner : UNANCHORED;
275
+ for (let el = container.lastElementChild; el; el = el.previousElementSibling) {
276
+ if (isDataElement(el)) return "";
277
+ }
278
+ return UNANCHORED;
279
+ }
280
+ function _assignHydrationOwnerPath(ctx, root, key, ordered, site) {
281
+ if (!isHydrating()) return 1;
282
+ let parent = ctx.owner;
283
+ while (parent && parent.Component === void 0) parent = parent.owner;
284
+ if (parent && parent._ownerPath === void 0) {
285
+ ctx._ownerPath = UNANCHORED;
286
+ return 1;
287
+ }
288
+ const frame = parent || root;
289
+ if (!_assignOwnerPath(ctx, frame, null, site)) return 0;
290
+ const prefix = frame._ownerPath;
291
+ if (prefix[0] === UNANCHORED) return 1;
292
+ const step = key && key.startsWith(prefix) ? stepAt(key, prefix.length) : null;
293
+ if (step !== null) {
294
+ ctx._ownerPath = key.slice(0, step.end);
295
+ holderOf(frame, null)._ownerChildren = step.index + 1;
296
+ return 1;
297
+ }
298
+ if (key !== "" || !ordered) ctx._ownerPath = UNANCHORED + ctx._ownerPath;
299
+ return key ? 2 : 1;
300
+ }
301
+ function componentName(frame) {
302
+ return frame.Component && frame.Component.name || "";
303
+ }
304
+ function _adoptOwnedValue(frame) {
305
+ if (!frame || frame._ownerPath === void 0 || !isHydrating()) return void 0;
306
+ const key = _nextOwnerKey(frame, null);
307
+ const data = __readHydrationData();
308
+ if (!data) return void 0;
309
+ const failed = !!data.ownedErrors && Object.hasOwn(data.ownedErrors, key);
310
+ if (!failed && !(data.owned && Object.hasOwn(data.owned, key))) return void 0;
311
+ if ((process.env.NODE_ENV !== "production")) {
312
+ const path = frame._ownerPath;
313
+ const server = data.owners && Object.hasOwn(data.owners, path) ? data.owners[path] : null;
314
+ const client = componentName(frame);
315
+ if (server !== client) {
316
+ report("ERR_HYDRATION_OWNER_MISMATCH", { data: { path, server: String(server), client } });
317
+ return void 0;
318
+ }
319
+ }
320
+ return failed ? { error: data.ownedErrors[key] } : { value: data.owned[key] };
321
+ }
322
+ var seeder = null;
323
+ function _installSeeding() {
324
+ seeder = seedFor;
325
+ }
326
+ function _installServerSeeding() {
327
+ seeder = seedFor;
328
+ _installStoreSeedOps();
329
+ }
330
+ function _seedFor(key, track) {
331
+ if (seeder !== null) return seeder(key, track);
332
+ globalThis[_serverStoreKey]?.refuse?.();
333
+ return null;
334
+ }
335
+ function seedFor(key, track) {
336
+ const keyed = key != null;
337
+ if (isServerRender()) {
338
+ const ctx = getServerContext();
339
+ if (ctx === null) return null;
340
+ const frame = _currentComponent();
341
+ return {
342
+ store: keyed ? ctx.resources : ctx.owned,
343
+ key: keyed ? key : _nextOwnerKey(frame, ctx),
344
+ owner: keyed ? void 0 : frame && frame.Component && frame.Component.name || ""
345
+ };
346
+ }
347
+ if (keyed || !isHydrating()) return null;
348
+ const taken = _adoptOwnedValue(_currentComponent());
349
+ if (taken === void 0) return null;
350
+ _installSeedOps();
351
+ return "error" in taken ? { error: _errorFromRecord(taken.error), track } : { value: taken.value, track };
352
+ }
353
+ function _caughtError(frame) {
354
+ if (!frame || typeof frame._ownerPath !== "string" || frame._ownerPath[0] === UNANCHORED) return void 0;
355
+ const record = lookup("caught", frame._ownerPath);
356
+ return record === void 0 ? void 0 : _errorFromRecord(record);
357
+ }
358
+ function _errorFromRecord(record) {
359
+ const error = new Error(record && record.message ? record.message : "Server error");
360
+ if (record && record.code) error.code = record.code;
361
+ return error;
362
+ }
363
+ function endMarker(placeholder) {
364
+ const end = placeholder.id;
365
+ for (let node = placeholder.nextSibling; node; node = node.nextSibling) {
366
+ if (node.nodeType === 8 && node.data === end) return node;
367
+ }
368
+ return null;
369
+ }
370
+ function swapBoundary(placeholder, content, end) {
371
+ for (let node = placeholder.nextSibling; node !== end; ) {
372
+ const next = node.nextSibling;
373
+ node.remove();
374
+ node = next;
375
+ }
376
+ end.remove();
377
+ placeholder.replaceWith(content.content);
378
+ content.remove();
379
+ }
380
+ function _swapArrived(placeholder) {
381
+ const id = placeholder.id.slice(3);
382
+ if (!BOUNDARY_ID.test(id)) return false;
383
+ const content = document.querySelector(`template[id="${id}"]`);
384
+ const end = content && endMarker(placeholder);
385
+ if (!end) return false;
386
+ swapBoundary(placeholder, content, end);
387
+ const data = __readHydrationData();
388
+ if (data && data.head && Object.hasOwn(data.head, id)) applyLateHead(data.head[id]);
389
+ return true;
390
+ }
391
+ var SAFE_HEAD_ATTR = /^[a-zA-Z_:][a-zA-Z0-9:._-]*$/;
392
+ var BOUNDARY_ID = /^[A-Za-z][\w-]*$/;
393
+ function headElement(tag, attrs) {
394
+ const el = document.createElement(tag);
395
+ for (const key in attrs) {
396
+ const value = attrs[key];
397
+ if (value == null || value === false) continue;
398
+ const name = key === "httpEquiv" ? "http-equiv" : key;
399
+ if (SAFE_HEAD_ATTR.test(name) && !/^on./i.test(name)) el.setAttribute(name, String(value));
400
+ }
401
+ return el;
402
+ }
403
+ function putHeadElement(el, matches) {
404
+ const head = document.head;
405
+ if (matches) {
406
+ for (let node = head.firstChild; node; node = node.nextSibling) {
407
+ if (node.nodeType === 1 && /** @type {Element} */
408
+ node.tagName === el.tagName && matches(node)) {
409
+ node.replaceWith(el);
410
+ return;
411
+ }
412
+ }
413
+ }
414
+ head.appendChild(el);
415
+ }
416
+ function applyLateHead(head) {
417
+ if (head.title != null) document.title = head.title;
418
+ for (const attrs of head.meta || []) {
419
+ const by = attrs.name ? "name" : attrs.property ? "property" : attrs.httpEquiv ? "http-equiv" : null;
420
+ const value = String(attrs.name || attrs.property || attrs.httpEquiv);
421
+ putHeadElement(headElement("meta", attrs), by && ((node) => node.getAttribute(by) === value));
422
+ }
423
+ for (const attrs of head.link || []) {
424
+ const href = attrs.href == null ? null : String(attrs.href);
425
+ putHeadElement(
426
+ headElement("link", attrs),
427
+ (node) => node.getAttribute("rel") === String(attrs.rel) && node.getAttribute("href") === href
428
+ );
429
+ }
430
+ }
431
+ function applyStreamedBoundaries() {
432
+ if (typeof document === "undefined") return 0;
433
+ const data = __readHydrationData() || {};
434
+ let count = 0;
435
+ for (let progress = true; progress; ) {
436
+ progress = false;
437
+ for (const placeholder of document.querySelectorAll('template[id^="pl-"]')) {
438
+ const id = placeholder.id.slice(3);
439
+ if (!BOUNDARY_ID.test(id)) continue;
440
+ const content = document.querySelector(`template[id="${id}"]`);
441
+ if (!content) continue;
442
+ const end = endMarker(placeholder);
443
+ if (!end) continue;
444
+ swapBoundary(placeholder, content, end);
445
+ if (data.head && Object.hasOwn(data.head, id)) applyLateHead(data.head[id]);
446
+ _resumeBoundary(id);
447
+ count++;
448
+ progress = true;
449
+ }
450
+ }
451
+ for (const placeholder of document.querySelectorAll('template[id^="pl-"]')) {
452
+ const id = placeholder.id.slice(3);
453
+ if (!BOUNDARY_ID.test(id)) continue;
454
+ const end = endMarker(placeholder);
455
+ if (!end) continue;
456
+ const open = placeholder.previousSibling;
457
+ if (open !== null && open.nodeType === 8 && /** @type {Comment} */
458
+ open.data === "b") open.data = "b!";
459
+ end.remove();
460
+ placeholder.remove();
461
+ _resumeBoundary(id);
462
+ }
463
+ return count;
464
+ }
465
+ export {
466
+ __readHydrationData,
467
+ __resetHydrationData,
468
+ _actionKeySalt,
469
+ _actionStateKey,
470
+ _adoptOwnedValue,
471
+ _assignHydrationOwnerPath,
472
+ _assignOwnerPath,
473
+ _caughtError,
474
+ _currentOwnerPath,
475
+ _currentRowPath,
476
+ _enterRow,
477
+ _errorFromRecord,
478
+ _hydrationRoot,
479
+ _installRowKeys,
480
+ _installSeeding,
481
+ _installServerSeeding,
482
+ _islandHost,
483
+ _leaveRow,
484
+ _loadedResource,
485
+ _nextOwnerKey,
486
+ _ownerCounter,
487
+ _renderSalt,
488
+ _seedFor,
489
+ _swapArrived,
490
+ _tracksRows,
491
+ applyStreamedBoundaries,
492
+ getLoaderData,
493
+ getResource,
494
+ getResourceError
495
+ };