@solidjs/web 2.0.0-rc.6 → 2.0.0-rc.8

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 (82) hide show
  1. package/dist/{server.cjs → server.dev.js} +274 -272
  2. package/dist/server.js +119 -36
  3. package/dist/{dev.js → web.dev.js} +131 -399
  4. package/dist/web.js +78 -388
  5. package/dist/{web.cjs → web.observe.js} +174 -622
  6. package/frames/dist/client.dev.js +11 -3
  7. package/frames/dist/client.js +11 -3
  8. package/frames/dist/{server.cjs → server.dev.js} +375 -125
  9. package/frames/dist/server.js +253 -32
  10. package/frames/package.json +7 -15
  11. package/package.json +88 -251
  12. package/serialization/decode/package.json +3 -9
  13. package/serialization/dist/decode.js +18 -4
  14. package/serialization/dist/serialization.js +18 -4
  15. package/serialization/package.json +3 -9
  16. package/serialization/types/serializer-decode.d.ts +49 -2
  17. package/server-functions/dist/client.js +13 -14
  18. package/server-functions/dist/server.dev.js +359 -85
  19. package/server-functions/dist/server.js +352 -86
  20. package/server-functions/package.json +6 -24
  21. package/server-functions/rich-args/package.json +3 -9
  22. package/storage/package.json +3 -9
  23. package/types/client.d.ts +17 -3
  24. package/types/frames/frame-client.d.ts +1 -1
  25. package/types/frames/serializer-decode.d.ts +49 -2
  26. package/types/head.d.ts +3 -0
  27. package/types/index.d.ts +18 -7
  28. package/types/index.server.d.ts +31 -9
  29. package/types/render.d.ts +3 -1
  30. package/types/serializer-decode.d.ts +49 -2
  31. package/types/server-functions/flash.d.ts +12 -3
  32. package/types/server-functions/server.d.ts +50 -3
  33. package/types/server-mock.d.ts +43 -7
  34. package/types/server.d.ts +48 -6
  35. package/dist/dev.cjs +0 -2590
  36. package/frames/dist/client.cjs +0 -2035
  37. package/frames/dist/client.dev.cjs +0 -2055
  38. package/serialization/dist/decode.cjs +0 -141
  39. package/serialization/dist/serialization.cjs +0 -261
  40. package/serialization/types-cjs/index.d.cts +0 -101
  41. package/serialization/types-cjs/package.json +0 -3
  42. package/serialization/types-cjs/serializer-decode.d.cts +0 -172
  43. package/serialization/types-cjs/serializer.d.cts +0 -101
  44. package/server-functions/dist/client.cjs +0 -1070
  45. package/server-functions/dist/rich-args.cjs +0 -11
  46. package/server-functions/dist/server.cjs +0 -2133
  47. package/server-functions/dist/server.dev.cjs +0 -2153
  48. package/storage/dist/storage.cjs +0 -12
  49. package/storage/types-cjs/index.d.cts +0 -28
  50. package/storage/types-cjs/package.json +0 -3
  51. package/types/patch-driver.d.ts +0 -3
  52. package/types-cjs/client.d.cts +0 -200
  53. package/types-cjs/constants.d.cts +0 -20
  54. package/types-cjs/cookies.d.cts +0 -41
  55. package/types-cjs/frames/client.d.cts +0 -36
  56. package/types-cjs/frames/frame-client.d.cts +0 -370
  57. package/types-cjs/frames/frame-container-plugin.d.cts +0 -71
  58. package/types-cjs/frames/frame-sink.d.cts +0 -92
  59. package/types-cjs/frames/frame-transport.d.cts +0 -189
  60. package/types-cjs/frames/serializer-decode.d.cts +0 -172
  61. package/types-cjs/frames/serializer.d.cts +0 -101
  62. package/types-cjs/frames/server.d.cts +0 -52
  63. package/types-cjs/head.d.cts +0 -16
  64. package/types-cjs/index.d.cts +0 -180
  65. package/types-cjs/index.server.d.cts +0 -125
  66. package/types-cjs/jsx-properties.d.cts +0 -93
  67. package/types-cjs/jsx.d.cts +0 -4146
  68. package/types-cjs/package.json +0 -3
  69. package/types-cjs/patch-driver.d.cts +0 -3
  70. package/types-cjs/reconcile.d.cts +0 -1
  71. package/types-cjs/render.d.cts +0 -4
  72. package/types-cjs/response.d.cts +0 -81
  73. package/types-cjs/serializer-decode.d.cts +0 -172
  74. package/types-cjs/serializer.d.cts +0 -101
  75. package/types-cjs/server-functions/client.d.cts +0 -184
  76. package/types-cjs/server-functions/flash.d.cts +0 -27
  77. package/types-cjs/server-functions/registry.d.cts +0 -100
  78. package/types-cjs/server-functions/rich-args.d.cts +0 -1
  79. package/types-cjs/server-functions/server.d.cts +0 -522
  80. package/types-cjs/server-functions/shared.d.cts +0 -283
  81. package/types-cjs/server-mock.d.cts +0 -301
  82. package/types-cjs/server.d.cts +0 -366
package/dist/dev.cjs DELETED
@@ -1,2590 +0,0 @@
1
- 'use strict';
2
-
3
- var solidJs = require('solid-js');
4
-
5
- const DOMWithState = {
6
- INPUT: {
7
- value: 1,
8
- defaultValue: 2,
9
- checked: 1,
10
- defaultChecked: 2
11
- },
12
- SELECT: {
13
- value: 1
14
- },
15
- OPTION: {
16
- value: 1,
17
- selected: 1,
18
- defaultSelected: 2
19
- },
20
- TEXTAREA: {
21
- value: 1,
22
- defaultValue: 2
23
- },
24
- VIDEO: {
25
- muted: 1,
26
- defaultMuted: 2
27
- },
28
- AUDIO: {
29
- muted: 1,
30
- defaultMuted: 2
31
- }
32
- };
33
- const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
34
- const $$SLOT = /*#__PURE__*/Symbol("slot");
35
- const $$HOST = /*#__PURE__*/Symbol("host");
36
- const DelegatedEvents = /*#__PURE__*/new Set(["beforeinput", "click", "dblclick", "contextmenu", "focusin", "focusout", "input", "keydown", "keyup", "mousedown", "mousemove", "mouseout", "mouseover", "mouseup", "pointerdown", "pointermove", "pointerout", "pointerover", "pointerup", "touchend", "touchmove", "touchstart"]);
37
- const SVGElements = /*#__PURE__*/new Set([
38
- "altGlyph", "altGlyphDef", "altGlyphItem", "animate", "animateColor", "animateMotion", "animateTransform", "circle", "clipPath", "color-profile", "cursor", "defs", "desc", "ellipse", "feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence", "filter", "font", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "foreignObject", "g", "glyph", "glyphRef", "hkern", "image", "line", "linearGradient", "marker", "mask", "metadata", "missing-glyph", "mpath", "path", "pattern", "polygon", "polyline", "radialGradient", "rect",
39
- "set", "stop",
40
- "svg", "switch", "symbol", "text", "textPath",
41
- "tref", "tspan", "use", "view", "vkern"]);
42
- const MathMLElements = /*#__PURE__*/new Set(["annotation", "annotation-xml", "maction", "math", "menclose", "merror", "mfenced", "mfrac", "mi", "mmultiscripts", "mn", "mo", "mover", "mpadded", "mphantom", "mprescripts", "mroot", "mrow", "ms", "mspace", "msqrt", "mstyle", "msub", "msubsup", "msup", "mtable", "mtd", "mtext", "mtr", "munder", "munderover", "semantics"]);
43
- const Namespaces = {
44
- svg: "http://www.w3.org/2000/svg",
45
- mathml: "http://www.w3.org/1998/Math/MathML",
46
- xlink: "http://www.w3.org/1999/xlink",
47
- xml: "http://www.w3.org/XML/1998/namespace"
48
- };
49
- const VoidElements = /*#__PURE__*/new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"]);
50
- const RawTextElements = /*#__PURE__*/new Set(["style", "script", "noscript", "template", "textarea", "title"]);
51
- const DOMElements = /*#__PURE__*/new Set(/*#__PURE__*/"a,abbr,acronym,address,applet,area,article,aside,audio,b,base,basefont,bdi,bdo,bgsound,big,blink,blockquote,body,br,button,canvas,caption,center,cite,code,col,colgroup,content,data,datalist,dd,del,details,dfn,dialog,dir,div,dl,dt,em,embed,fieldset,figcaption,figure,font,footer,form,frame,frameset,h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,i,iframe,image,img,input,ins,isindex,kbd,keygen,label,legend,li,link,listing,main,map,mark,marquee,math,menu,menuitem,meta,meter,multicol,nav,nextid,nobr,noembed,noframes,noindex,noscript,object,ol,optgroup,option,output,p,param,picture,plaintext,portal,pre,progress,q,rb,rp,rt,rtc,ruby,s,samp,script,search,section,select,shadow,slot,small,source,spacer,span,strike,strong,style,sub,summary,sup,svg,table,tbody,td,template,textarea,tfoot,th,thead,time,title,tr,track,tt,u,ul,var,video,wbr,webview,xmp".split(","));
52
- const COMPOSED_BODY_FRAMING = /*#__PURE__*/new Set(["content-length", "content-encoding", "transfer-encoding"]);
53
-
54
- const transparentOptions = {
55
- transparent: true,
56
- sync: true
57
- };
58
- const syncOptions = {
59
- sync: true
60
- };
61
- function effect(fn, effectFn, options) {
62
- solidJs.createRenderEffect(fn, effectFn, options ? {
63
- sync: true,
64
- ...options,
65
- transparent: !options.scope
66
- } : transparentOptions);
67
- }
68
- function memo(fn) {
69
- return solidJs.createMemo(() => fn(), syncOptions);
70
- }
71
-
72
- function reconcileArrays(parentNode, a, b, marker) {
73
- let bLength = b.length,
74
- aEnd = a.length,
75
- bEnd = bLength,
76
- aStart = 0,
77
- bStart = 0,
78
- tail = a[aEnd - 1],
79
- tailTag = tail[$$SLOT],
80
- after = tail.parentNode === parentNode && (!tailTag || tailTag === marker) ? tail.nextSibling : marker || null,
81
- map = null,
82
- anchor,
83
- anchorTag;
84
- const isLive = n => {
85
- if (!n) return false;
86
- const tag = n[$$SLOT];
87
- return n.parentNode === parentNode && (!tag || tag === marker);
88
- };
89
- while (aStart < aEnd || bStart < bEnd) {
90
- if (a[aStart] === b[bStart] && isLive(a[aStart])) {
91
- aStart++;
92
- bStart++;
93
- continue;
94
- }
95
- while (a[aEnd - 1] === b[bEnd - 1] && isLive(a[aEnd - 1])) {
96
- aEnd--;
97
- bEnd--;
98
- }
99
- if (aEnd === aStart) {
100
- let node;
101
- if (bEnd < bLength) {
102
- if (bStart) {
103
- const prev = b[bStart - 1];
104
- const prevTag = prev[$$SLOT];
105
- node = prev.parentNode === parentNode && (!prevTag || prevTag === marker) ? prev.nextSibling : after;
106
- } else node = b[bEnd - bStart];
107
- } else node = after;
108
- while (bStart < bEnd) {
109
- const n = b[bStart++];
110
- parentNode.insertBefore(n, node);
111
- if (marker) n[$$SLOT] = marker;
112
- }
113
- } else if (bEnd === bStart) {
114
- while (aStart < aEnd) {
115
- const n = a[aStart++];
116
- if (!map || !map.has(n)) {
117
- const tag = n[$$SLOT];
118
- if (n.parentNode === parentNode && (!tag || tag === marker)) n.remove();
119
- }
120
- }
121
- } else if ((anchor = a[aStart]) === b[bEnd - 1] && b[bStart] === a[aEnd - 1] && anchor.parentNode === parentNode && (!(anchorTag = anchor[$$SLOT]) || anchorTag === marker)) {
122
- if (marker) {
123
- do {
124
- const n = a[--aEnd];
125
- parentNode.insertBefore(n, anchor);
126
- n[$$SLOT] = marker;
127
- bStart++;
128
- if (aStart >= aEnd - 1 || bStart >= bEnd) break;
129
- } while (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]);
130
- } else {
131
- do {
132
- parentNode.insertBefore(a[--aEnd], anchor);
133
- bStart++;
134
- if (aStart >= aEnd - 1 || bStart >= bEnd) break;
135
- } while (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]);
136
- }
137
- } else {
138
- if (!map) {
139
- map = new Map();
140
- let i = bStart;
141
- while (i < bEnd) map.set(b[i], i++);
142
- }
143
- const index = map.get(a[aStart]);
144
- if (index != null) {
145
- if (bStart < index && index < bEnd) {
146
- let i = aStart,
147
- sequence = 1,
148
- t;
149
- while (++i < aEnd && i < bEnd) {
150
- if ((t = map.get(a[i])) == null || t !== index + sequence) break;
151
- sequence++;
152
- }
153
- if (sequence > index - bStart) {
154
- const head = a[aStart];
155
- const headTag = head[$$SLOT];
156
- const node = head.parentNode === parentNode && (!headTag || headTag === marker) ? head : after;
157
- while (bStart < index) {
158
- const n = b[bStart++];
159
- parentNode.insertBefore(n, node);
160
- if (marker) n[$$SLOT] = marker;
161
- }
162
- } else {
163
- const oldNode = a[aStart++];
164
- const newNode = b[bStart++];
165
- const oldTag = oldNode[$$SLOT];
166
- if (oldNode.parentNode === parentNode && (!oldTag || oldTag === marker)) {
167
- parentNode.replaceChild(newNode, oldNode);
168
- } else {
169
- parentNode.insertBefore(newNode, after);
170
- }
171
- if (marker) newNode[$$SLOT] = marker;
172
- }
173
- } else aStart++;
174
- } else {
175
- const n = a[aStart++];
176
- const nTag = n[$$SLOT];
177
- if (n.parentNode === parentNode && (!nTag || nTag === marker)) n.remove();
178
- }
179
- }
180
- }
181
- }
182
-
183
- const HEAD_ELIGIBLE_TAGS = new Set(["title", "meta", "link", "style", "script", "base"]);
184
- const HEAD_ATTR_NAME = /^[a-zA-Z_][a-zA-Z0-9_:.-]*$/;
185
- const RESOURCE_LINK_RELS = new Set(["preload", "modulepreload", "prefetch", "preconnect", "dns-prefetch", "stylesheet"]);
186
- const RESOURCE_QUALIFIERS = ["as", "crossorigin", "type", "media", "imagesrcset", "imagesizes"];
187
- const STYLESHEET_FETCH_META = new Set(["crossorigin", "integrity", "referrerpolicy", "fetchpriority"]);
188
- function evalHeadValue(v) {
189
- return typeof v === "function" ? v() : v;
190
- }
191
- function evalHeadProps(props, presets) {
192
- const out = {};
193
- for (const name in props) out[name] = presets && name in presets ? presets[name] : evalHeadValue(props[name]);
194
- return out;
195
- }
196
- function classifyHeadTag(desc) {
197
- const tag = desc.tag;
198
- if (tag === "link") {
199
- const rel = evalHeadValue(desc.props && desc.props.rel);
200
- return {
201
- resource: RESOURCE_LINK_RELS.has(rel),
202
- rel
203
- };
204
- }
205
- if (tag === "style") return {
206
- resource: !!(desc.props && "href" in desc.props)
207
- };
208
- if (tag === "script") return {
209
- resource: !!(desc.props && "src" in desc.props)
210
- };
211
- return {
212
- resource: false
213
- };
214
- }
215
- function resourceIdentity(tag, props) {
216
- let id = "res:" + tag + ":" + (props.rel || "") + ":" + (props.href || props.src || "");
217
- for (let i = 0; i < RESOURCE_QUALIFIERS.length; i++) {
218
- const q = RESOURCE_QUALIFIERS[i];
219
- const value = props[q];
220
- if (value != null) id += ":" + q + "=" + (value === true ? "" : value);
221
- }
222
- return id;
223
- }
224
- function replaceableIdentity(tag, props, key, unique) {
225
- if (tag === "title") return "title";
226
- if (tag === "base") return "base";
227
- if (tag === "meta" && props.charset != null) return "charset";
228
- if (key != null) return tag + ":key:" + key;
229
- if (tag === "meta") {
230
- for (const ns of ["name", "property", "http-equiv"]) if (props[ns] != null) return "meta:" + ns + ":" + props[ns] + (props.media != null ? ":media=" + props.media : "");
231
- return unique;
232
- }
233
- if (tag === "link") {
234
- const rel = props.rel || "";
235
- if (rel === "icon" || rel === "apple-touch-icon") return "link:" + rel + (props.sizes != null ? ":sizes=" + props.sizes : "") + (props.type != null ? ":type=" + props.type : "");
236
- return "link:" + rel + ":" + (props.href || "");
237
- }
238
- return unique;
239
- }
240
- function resolveHead(groups) {
241
- const winners = new Map();
242
- const sorted = groups.slice().sort((a, b) => a.seq - b.seq);
243
- for (let i = 0; i < sorted.length; i++) {
244
- const group = sorted[i];
245
- const byIdentity = new Map();
246
- for (let j = 0; j < group.tags.length; j++) {
247
- const t = group.tags[j];
248
- let list = byIdentity.get(t.identity);
249
- if (!list) byIdentity.set(t.identity, list = []);
250
- list.push(t);
251
- }
252
- for (const [identity, tags] of byIdentity) {
253
- if (identity === "title") {
254
- if (tags.length > 1) console.warn("Multiple <title> tags in one head group; the last one wins.");
255
- winners.set(identity, {
256
- seq: group.seq,
257
- tags: [tags[tags.length - 1]]
258
- });
259
- } else {
260
- winners.set(identity, {
261
- seq: group.seq,
262
- tags
263
- });
264
- }
265
- }
266
- }
267
- return winners;
268
- }
269
-
270
- function parseCookieHeader(header) {
271
- const cookies = {};
272
- if (!header) return cookies;
273
- for (const part of header.split(";")) {
274
- const eq = part.indexOf("=");
275
- if (eq < 0) continue;
276
- const name = decodeSafe(part.slice(0, eq).trim());
277
- let value = part.slice(eq + 1).trim();
278
- if (value.length > 1 && value[0] === '"' && value[value.length - 1] === '"') {
279
- value = value.slice(1, -1);
280
- }
281
- cookies[name] = decodeSafe(value);
282
- }
283
- return cookies;
284
- }
285
- function decodeSafe(text) {
286
- try {
287
- return decodeURIComponent(text);
288
- } catch {
289
- return text;
290
- }
291
- }
292
- function serializeCookie(name, value, options = {}) {
293
- assertServableCookie(name, options);
294
- let cookie = `${encodeURIComponent(name)}=${encodeURIComponent(value)}`;
295
- cookie += `; Path=${options.path === undefined ? "/" : options.path}`;
296
- if (options.domain) cookie += `; Domain=${options.domain}`;
297
- if (options.maxAge !== undefined) cookie += `; Max-Age=${Math.trunc(options.maxAge)}`;
298
- if (options.expires) cookie += `; Expires=${options.expires.toUTCString()}`;
299
- if (options.httpOnly) cookie += "; HttpOnly";
300
- if (options.secure) cookie += "; Secure";
301
- if (options.partitioned) cookie += "; Partitioned";
302
- if (options.sameSite) {
303
- const sameSite = options.sameSite.toLowerCase();
304
- cookie += `; SameSite=${sameSite === "none" ? "None" : sameSite === "strict" ? "Strict" : "Lax"}`;
305
- }
306
- return cookie;
307
- }
308
- function assertServableCookie(name, options) {
309
- const reject = reason => {
310
- throw new Error(`serializeCookie: every browser silently rejects this cookie — ${reason}. ` + `It would never come back on a request, with no error anywhere.`);
311
- };
312
- const lower = name.toLowerCase();
313
- if (lower.startsWith("__host-")) {
314
- if (!options.secure) reject(`the __Host- prefix on \`${name}\` requires \`secure: true\``);
315
- if (options.path !== undefined && options.path !== "/") reject(`the __Host- prefix on \`${name}\` requires \`Path=/\` (got \`${options.path}\`) — ` + `host-locking is the prefix's whole contract, so it cannot be path-scoped`);
316
- if (options.domain) reject(`the __Host- prefix on \`${name}\` forbids \`Domain\` (got \`${options.domain}\`)`);
317
- } else if (lower.startsWith("__secure-") && !options.secure) {
318
- reject(`the __Secure- prefix on \`${name}\` requires \`secure: true\``);
319
- }
320
- if (options.sameSite && options.sameSite.toLowerCase() === "none" && !options.secure) {
321
- reject("`SameSite=None` requires `secure: true`");
322
- }
323
- if (options.partitioned && !options.secure) {
324
- reject("`Partitioned` requires `secure: true`");
325
- }
326
- }
327
- const FLASH_COOKIE = "flash";
328
- const FLASH_MATCHER = new RegExp(`(?:^|;\\s*)${FLASH_COOKIE}=([^;]+)`);
329
- function hasFlashCookie(cookieHeader) {
330
- return !!cookieHeader && FLASH_MATCHER.test(cookieHeader);
331
- }
332
- function clearFlashCookie() {
333
- return `${FLASH_COOKIE}=; Max-Age=0; Path=/`;
334
- }
335
-
336
- const SERVER_FUNCTION_METADATA = Symbol.for("solid.ServerFunctionMetadata");
337
- function getServerFunctionMetadata(fn) {
338
- if (typeof fn !== "function") return undefined;
339
- return fn[SERVER_FUNCTION_METADATA] || undefined;
340
- }
341
- function isServerFunction(fn) {
342
- return typeof fn === "function" && !!fn[SERVER_FUNCTION_METADATA];
343
- }
344
- const SERVER_FUNCTION_RPC = Symbol.for("solid.ServerFunctionRPC");
345
- function getServerFunctionRPC() {
346
- return globalThis[SERVER_FUNCTION_RPC];
347
- }
348
-
349
- const assetGates = new WeakMap();
350
- const waitAsset = promise => {
351
- let gate = assetGates.get(promise);
352
- if (!gate) {
353
- solidJs.runWithOwner(null, () => {
354
- gate = solidJs.createMemo(() => promise);
355
- });
356
- assetGates.set(promise, gate);
357
- }
358
- gate();
359
- };
360
- exports.listDriver = void 0;
361
- function installListDriver(driver) {
362
- exports.listDriver = driver;
363
- }
364
- const $$EVENT_OWNER = "_$SOLID_EVENT_OWNER";
365
- const $$EVENT_TUPLE = Symbol();
366
- const hasOwn = Object.prototype.hasOwnProperty;
367
- const INNER_OWNED = {};
368
- const delegatedEvents = new Set();
369
- const delegatedContainers = new Map();
370
- function voidFn() {}
371
- function generateHydrationScript(_options) {
372
- return "";
373
- }
374
- function HydrationScript(_props) {
375
- return null;
376
- }
377
- const getRequestEvent = voidFn;
378
- function render(code, element, init, options = {}) {
379
- if (!element) {
380
- throw new Error("The `element` passed to `render(..., element)` doesn't exist. Make sure `element` exists in the document.");
381
- }
382
- solidJs.resetErrorHalt();
383
- solidJs.enforceLoadingBoundary(true);
384
- let disposer;
385
- registerDelegatedRoot(element);
386
- try {
387
- solidJs.createRoot(dispose => {
388
- disposer = dispose;
389
- if (element === document) {
390
- const tree = code();
391
- effect(() => solidJs.flatten(tree), () => {});
392
- } else {
393
- const tree = code();
394
- insert(element, () => tree, element.firstChild ? null : undefined, init, {
395
- ...options.insertOptions,
396
- schedule: true
397
- });
398
- }
399
- }, {
400
- id: options.renderId
401
- });
402
- solidJs.flush();
403
- } catch (err) {
404
- if (disposer) disposer();
405
- unregisterDelegatedRoot(element);
406
- throw err;
407
- } finally {
408
- solidJs.enforceLoadingBoundary(false);
409
- }
410
- return () => {
411
- disposer();
412
- unregisterDelegatedRoot(element);
413
- element.textContent = "";
414
- };
415
- }
416
- function create(html, bypassGuard, flag) {
417
- if (isHydrating() && !bypassGuard) throw new Error("Failed attempt to create new DOM elements during hydration. Check that the libraries you are using support hydration.");
418
- const t = document.createElement("template");
419
- t.innerHTML = html;
420
- return flag === 2 ? t.content.firstChild.firstChild : t.content.firstChild;
421
- }
422
- function template(html, flag) {
423
- let node;
424
- const fn = flag === 1 ? bypassGuard => document.importNode(node || (node = create(html, bypassGuard, flag)), true) : bypassGuard => (node || (node = create(html, bypassGuard, flag))).cloneNode(true);
425
- fn._html = flag === 2 ? html.replace(/^<[^>]+>/, "") : html;
426
- return fn;
427
- }
428
- function delegateEvents(eventNames) {
429
- for (let i = 0, l = eventNames.length; i < l; i++) {
430
- const name = eventNames[i];
431
- if (!delegatedEvents.has(name)) {
432
- delegatedEvents.add(name);
433
- delegatedContainers.forEach((state, container) => attachDelegatedEvent(name, container, state));
434
- }
435
- }
436
- }
437
- function registerDelegatedRoot(root) {
438
- const state = registerDelegatedContainer(root, root);
439
- if (state) state.roots = (state.roots || 0) + 1;
440
- }
441
- function unregisterDelegatedRoot(root) {
442
- const state = delegatedContainers.get(root);
443
- if (state) state.roots > 1 ? state.roots-- : delete state.roots;
444
- unregisterDelegatedContainer(root, root);
445
- }
446
- function registerDelegatedContainer(container, owner = container) {
447
- if (!container || !owner) return;
448
- let state = delegatedContainers.get(container);
449
- if (!state) delegatedContainers.set(container, state = {
450
- owners: new Map(),
451
- handlers: new Map()
452
- });
453
- state.owners.set(owner, (state.owners.get(owner) || 0) + 1);
454
- delegatedEvents.forEach(name => attachDelegatedEvent(name, container, state));
455
- return state;
456
- }
457
- function unregisterDelegatedContainer(container, owner = container) {
458
- const state = delegatedContainers.get(container);
459
- if (!state) return;
460
- const count = state.owners.get(owner);
461
- if (count > 1) state.owners.set(owner, count - 1);else state.owners.delete(owner);
462
- if (state.owners.size) return;
463
- state.handlers.forEach((handler, name) => container.removeEventListener(name, handler));
464
- delegatedContainers.delete(container);
465
- }
466
- function attachDelegatedEvent(name, container, state) {
467
- if (state.handlers.has(name)) return;
468
- const handler = e => eventHandler(e, container, state);
469
- state.handlers.set(name, handler);
470
- container.addEventListener(name, handler);
471
- }
472
- function getDelegatedRoot(node) {
473
- while (node) {
474
- if (delegatedContainers.get(node)?.roots) return node;
475
- node = node._$host || node.parentNode || node.host;
476
- }
477
- }
478
- function findOwner(target, state) {
479
- let node = target;
480
- let distance = 0;
481
- while (node) {
482
- if (state.owners.has(node)) return {
483
- owner: node,
484
- distance
485
- };
486
- distance++;
487
- node = node._$host || node.parentNode || node.host;
488
- }
489
- }
490
- function setProperty(node, name, value) {
491
- if (isHydrating(node)) return;
492
- const nodeName = node.nodeName;
493
- if (name === "value" && nodeName === "SELECT") queueMicrotask(() => node.value = value) || (node.value = value);else if ((name === "value" || name === "defaultValue") && (nodeName === "INPUT" || nodeName === "TEXTAREA")) node[name] = value ?? "";else node[name] = value;
494
- }
495
- let claimHandlers = null;
496
- const CLAIM_SEAM = Symbol.for("solid.element-claims");
497
- function registerElementClaim(handler) {
498
- (claimHandlers || (claimHandlers = globalThis[CLAIM_SEAM] = [])).push(handler);
499
- return () => {
500
- const index = claimHandlers.indexOf(handler);
501
- index > -1 && claimHandlers.splice(index, 1);
502
- };
503
- }
504
- const CLAIMED_ELEMENTS = "a[href], form[action]";
505
- function claimElementTree(root) {
506
- const handlers = globalThis[CLAIM_SEAM];
507
- if (handlers === undefined || handlers.length === 0) return root;
508
- const isElement = root.nodeType === 1;
509
- if (!isElement && root.nodeType !== 11) return root;
510
- if (isElement && root.matches(CLAIMED_ELEMENTS)) {
511
- for (let i = 0; i < handlers.length; i++) handlers[i](root);
512
- }
513
- const found = root.querySelectorAll(CLAIMED_ELEMENTS);
514
- for (let i = 0; i < found.length; i++) {
515
- for (let j = 0; j < handlers.length; j++) handlers[j](found[i]);
516
- }
517
- return root;
518
- }
519
- function claimElement(node) {
520
- if (claimHandlers !== null) {
521
- for (let i = 0; i < claimHandlers.length; i++) claimHandlers[i](node);
522
- }
523
- return node;
524
- }
525
- function setAttribute(node, name, value) {
526
- if (isHydrating(node)) return;
527
- const selectMultiple = name === "multiple" && node.localName === "select";
528
- if (value == null || value === false) node.removeAttribute(name);else {
529
- node.setAttribute(name, value === true ? "" : value);
530
- if (selectMultiple && !node._$multiple) {
531
- const options = node.options;
532
- for (let i = 0; i < options.length; i++) {
533
- if (options[i].defaultSelected) options[i].selected = true;
534
- }
535
- }
536
- }
537
- if (selectMultiple) node._$multiple = true;
538
- if (claimHandlers !== null && (name === "href" || name === "action")) claimElement(node);
539
- }
540
- function setAttributeNS(node, namespace, name, value) {
541
- if (isHydrating(node)) return;
542
- if (value == null || value === false) node.removeAttributeNS(namespace, name.indexOf(":") > -1 ? name.split(":").pop() : name);else node.setAttributeNS(namespace, name, value === true ? "" : value);
543
- }
544
- function className(node, value, prev) {
545
- if (typeof value === "number") value = "" + value;
546
- if (typeof prev === "number") prev = "" + prev;
547
- if (isHydrating(node)) {
548
- node._$classes = value && typeof value === "object" ? classListToObject(value) : undefined;
549
- return;
550
- }
551
- if (value == null || value === false) {
552
- if (prev || node._$classes) {
553
- node.removeAttribute("class");
554
- node._$classes = undefined;
555
- }
556
- return;
557
- }
558
- if (typeof value === "string") {
559
- node._$classes = undefined;
560
- value !== prev && node.setAttribute("class", value);
561
- return;
562
- }
563
- let applied;
564
- if (typeof prev === "string") {
565
- applied = {};
566
- node.removeAttribute("class");
567
- } else applied = node._$classes || classListToObject(prev || {});
568
- value = classListToObject(value);
569
- const classKeys = Object.keys(value);
570
- const prevKeys = Object.keys(applied);
571
- let i, len;
572
- for (i = 0, len = prevKeys.length; i < len; i++) {
573
- const key = prevKeys[i];
574
- if (!key || key === "undefined" || value[key]) continue;
575
- node.classList.remove(key);
576
- }
577
- for (i = 0, len = classKeys.length; i < len; i++) {
578
- const key = classKeys[i],
579
- classValue = !!value[key];
580
- if (!key || key === "undefined" || applied[key] === classValue || !classValue) continue;
581
- node.classList.add(key);
582
- }
583
- node._$classes = value;
584
- }
585
- function addEvent(node, name, handler, delegate) {
586
- if (delegate) {
587
- const key = `$$${name}`;
588
- let data;
589
- if (Array.isArray(handler)) {
590
- data = handler[1];
591
- node[key] = handler[0];
592
- } else node[key] = handler;
593
- node[`${key}Data`] = data;
594
- return;
595
- }
596
- if (Array.isArray(handler)) {
597
- const handlerFn = handler[0];
598
- const listener = e => handlerFn.call(node, handler[1], e);
599
- listener[$$EVENT_TUPLE] = handler;
600
- node.addEventListener(name, listener);
601
- return listener;
602
- }
603
- node.addEventListener(name, handler, typeof handler !== "function" && handler);
604
- return handler;
605
- }
606
- function style(node, value, prev) {
607
- if (isHydrating(node)) return;
608
- if (!value) {
609
- if (prev || node._$styles) {
610
- setAttribute(node, "style");
611
- node._$styles = undefined;
612
- }
613
- return;
614
- }
615
- const nodeStyle = node.style;
616
- if (typeof value === "string") {
617
- node._$styles = undefined;
618
- return nodeStyle.cssText = value;
619
- }
620
- if (typeof prev === "string") {
621
- nodeStyle.cssText = "";
622
- prev = undefined;
623
- }
624
- let applied = node._$styles;
625
- if (!applied) {
626
- applied = node._$styles = prev ? {
627
- ...prev
628
- } : {};
629
- }
630
- let v, s;
631
- for (s in applied) {
632
- if (!hasOwn.call(value, s) || value[s] == null) {
633
- nodeStyle.removeProperty(s);
634
- delete applied[s];
635
- }
636
- }
637
- for (s in value) {
638
- if (!hasOwn.call(value, s)) continue;
639
- v = value[s];
640
- if (v != null && v !== applied[s]) {
641
- nodeStyle.setProperty(s, v);
642
- applied[s] = v;
643
- }
644
- }
645
- }
646
- function setStyleProperty(node, name, value) {
647
- if (isHydrating(node)) return;
648
- value != null ? node.style.setProperty(name, value) : node.style.removeProperty(name);
649
- }
650
- function spread(node, props = {}, skipChildren) {
651
- const prevProps = {};
652
- const get = typeof props === "function" ? props : () => props;
653
- if (!skipChildren) insert(node, () => {
654
- const source = get();
655
- return hasOwn.call(source, "children") ? source.children : undefined;
656
- });
657
- effect(() => {
658
- const source = get();
659
- const r = hasOwn.call(source, "ref") && source.ref;
660
- (typeof r === "function" || Array.isArray(r)) && ref(() => r, node);
661
- }, () => {});
662
- effect(() => {
663
- const source = get();
664
- const newProps = {};
665
- for (const prop in source) {
666
- if (!hasOwn.call(source, prop)) continue;
667
- if (prop === "children" || prop === "ref") continue;
668
- newProps[prop] = source[prop];
669
- }
670
- return newProps;
671
- }, props => assign(node, props, true, prevProps, true));
672
- return prevProps;
673
- }
674
- function dynamicProperty(props, key) {
675
- const src = props[key];
676
- Object.defineProperty(props, key, {
677
- get() {
678
- return src();
679
- },
680
- enumerable: true
681
- });
682
- return props;
683
- }
684
- function applyRef(r, element) {
685
- Array.isArray(r) ? r.flat(Infinity).forEach(f => f && f(element)) : r(element);
686
- }
687
- function ref(fn, element) {
688
- const resolved = solidJs.untrack(fn);
689
- solidJs.runWithOwner(null, () => applyRef(resolved, element));
690
- }
691
- function scope(fn) {
692
- fn.$s = true;
693
- return fn;
694
- }
695
- const SCOPE_OPTIONS = {
696
- scope: true
697
- };
698
- let insertionParent = null;
699
- function getInsertionParent() {
700
- return insertionParent;
701
- }
702
- function withInsertionParent(parent, fn) {
703
- const prev = insertionParent;
704
- insertionParent = parent;
705
- try {
706
- return fn();
707
- } finally {
708
- insertionParent = prev;
709
- }
710
- }
711
- let hydrationRt = null;
712
- function installHydrationRuntime() {
713
- hydrationRt = {
714
- claimInitial(parent, multi, initial) {
715
- if (isHydrating(parent)) {
716
- if (!multi && initial === undefined && parent) initial = [...parent.childNodes];
717
- if (Array.isArray(initial)) stripTextSeparators(initial);
718
- }
719
- return initial;
720
- },
721
- reclaimRegion(current, parent, marker) {
722
- if (!solidJs.sharedConfig.hydrating || !current || !parent.isConnected) return current;
723
- const first = Array.isArray(current) ? current[0] : current;
724
- if (!first || !first.nodeType || first.isConnected) return current;
725
- let nodes;
726
- if (marker) {
727
- nodes = [];
728
- let node = marker.previousSibling,
729
- depth = 0;
730
- while (node) {
731
- if (node.nodeType === 8) {
732
- const v = node.nodeValue;
733
- if (v === "/") depth++;else if (v === "$") {
734
- if (depth === 0) break;
735
- depth--;
736
- }
737
- }
738
- nodes.unshift(node);
739
- node = node.previousSibling;
740
- }
741
- } else nodes = [...parent.childNodes];
742
- return stripTextSeparators(nodes);
743
- },
744
- dedupEvent(e) {
745
- return !!(solidJs.sharedConfig.registry && solidJs.sharedConfig.events && solidJs.sharedConfig.events.find(([el, ev]) => ev === e));
746
- }
747
- };
748
- }
749
- function stripTextSeparators(nodes) {
750
- let j = 0;
751
- for (let i = 0; i < nodes.length; i++) {
752
- const node = nodes[i],
753
- t = node.nodeType;
754
- if (t === 8) {
755
- const v = node.nodeValue;
756
- if (v === "!$") {
757
- node.remove();
758
- continue;
759
- }
760
- if (v.startsWith("pl-")) continue;
761
- } else if (t === 1 && node.localName === "template" && node.id.startsWith("pl-")) continue;
762
- nodes[j++] = node;
763
- }
764
- nodes.length = j;
765
- return nodes;
766
- }
767
- function insert(parent, accessor, marker, initial, options) {
768
- const multi = marker !== undefined;
769
- const host = options && options.host;
770
- if (multi && !initial) initial = [];
771
- if (hydrationRt !== null) initial = hydrationRt.claimInitial(parent, multi, initial);
772
- if (exports.listDriver !== undefined && typeof accessor === "function" && accessor.$ll !== undefined) {
773
- const listAccessor = accessor;
774
- const owner = solidJs.getOwner();
775
- if (exports.listDriver(parent, accessor, marker, () => solidJs.runWithOwner(owner, () => insert(parent, () => listAccessor(), marker, marker !== undefined ? [] : undefined, options)))) return;
776
- }
777
- if (typeof accessor !== "function") {
778
- accessor = withInsertionParent(parent, () => normalize(accessor, initial, multi, true));
779
- if (typeof accessor !== "function") {
780
- insertExpression(parent, accessor, initial, marker);
781
- host && tagHost(accessor, host);
782
- return;
783
- }
784
- }
785
- if (multi && initial.length === 0) {
786
- const placeholder = document.createTextNode("");
787
- parent.insertBefore(placeholder, marker);
788
- initial = [placeholder];
789
- }
790
- let current = initial;
791
- effect(prev => {
792
- if (hydrationRt !== null) current = hydrationRt.reclaimRegion(current, parent, marker);
793
- const value = withInsertionParent(parent, () => normalize(accessor(), current, multi, true));
794
- if (typeof value !== "function") return value;
795
- effect(() => (hydrationRt !== null && (current = hydrationRt.reclaimRegion(current, parent, marker)), withInsertionParent(parent, () => normalize(value, current, multi))), inner => {
796
- current = insertExpression(parent, inner, current, marker);
797
- host && tagHost(current, host);
798
- }, prev !== undefined && !(options && options.schedule) ? {
799
- ...options,
800
- schedule: true
801
- } : options);
802
- return INNER_OWNED;
803
- }, value => {
804
- if (value === INNER_OWNED) return;
805
- current = insertExpression(parent, value, current, marker);
806
- host && tagHost(current, host);
807
- },
808
- accessor.$s ? options ? {
809
- ...options,
810
- scope: true
811
- } : SCOPE_OPTIONS : options);
812
- }
813
- function assign(node, props, skipChildren, prevProps = {}, skipRef = false) {
814
- const nodeName = node.nodeName;
815
- props || (props = {});
816
- for (const prop in prevProps) {
817
- if (!(prop in props)) {
818
- if (prop === "children") continue;
819
- prevProps[prop] = assignProp(node, prop, null, prevProps[prop], skipRef, nodeName);
820
- }
821
- }
822
- for (const prop in props) {
823
- if (prop === "children") {
824
- if (!skipChildren) insertExpression(node, normalize(props.children, undefined, false));
825
- continue;
826
- }
827
- prevProps[prop] = assignProp(node, prop, props[prop], prevProps[prop], skipRef, nodeName);
828
- }
829
- }
830
- const ASSET_REMOVAL_GRACE = 100;
831
- const assetRegistry = new Map();
832
- function assetEntryKey(descriptor) {
833
- if (descriptor.policy === "exclusive") return "x|" + descriptor.key;
834
- return descriptor.type === "inline-style" ? "i|" + descriptor.id : descriptor.type + "|" + descriptor.href;
835
- }
836
- function findAssetElement(selector, attr, value) {
837
- const nodes = document.querySelectorAll(selector);
838
- for (let i = 0; i < nodes.length; i++) {
839
- if (nodes[i].getAttribute(attr) === value) return nodes[i];
840
- }
841
- return null;
842
- }
843
- function setAssetAttrs(el, attrs) {
844
- for (const name in attrs) el.setAttribute(name, attrs[name]);
845
- }
846
- function mountAssetElement(descriptor) {
847
- let el;
848
- if (descriptor.type === "inline-style") {
849
- el = findAssetElement("style[data-asset]", "data-asset", descriptor.id);
850
- if (!el) {
851
- el = document.createElement("style");
852
- el.setAttribute("data-asset", descriptor.id);
853
- el.textContent = descriptor.content || "";
854
- }
855
- } else {
856
- const rel = descriptor.type === "module" ? "modulepreload" : "stylesheet";
857
- el = findAssetElement(`link[rel="${rel}"]`, "href", descriptor.href);
858
- if (!el) {
859
- el = document.createElement("link");
860
- el.rel = rel;
861
- el.href = descriptor.href;
862
- }
863
- }
864
- if (descriptor.attrs) setAssetAttrs(el, descriptor.attrs);
865
- if (!el.isConnected) document.head.appendChild(el);
866
- return el;
867
- }
868
- const assetLoadSettled = /*#__PURE__*/Promise.resolve();
869
- function trackAssetLoad(entry, adopted) {
870
- if (entry.loadPromise) return;
871
- const el = entry.element;
872
- let settled = el.sheet != null;
873
- if (!settled && adopted && typeof performance !== "undefined" && performance.getEntriesByName) {
874
- settled = performance.getEntriesByName(el.href).length > 0;
875
- }
876
- if (settled) {
877
- entry.loadState = "loaded";
878
- entry.loadPromise = assetLoadSettled;
879
- return;
880
- }
881
- entry.loadState = "pending";
882
- entry.loadPromise = new Promise(resolve => {
883
- const settle = state => {
884
- entry.loadState = state;
885
- resolve();
886
- };
887
- el.addEventListener("load", () => settle("loaded"), {
888
- once: true
889
- });
890
- el.addEventListener("error", () => settle("errored"), {
891
- once: true
892
- });
893
- });
894
- }
895
- function warmAsset(descriptor) {
896
- if (descriptor.policy === "exclusive" || descriptor.type === "inline-style") return;
897
- const key = assetEntryKey(descriptor);
898
- let entry = assetRegistry.get(key);
899
- if (!entry) {
900
- entry = {
901
- count: 0,
902
- element: null,
903
- timer: null
904
- };
905
- assetRegistry.set(key, entry);
906
- }
907
- let adopted = true;
908
- if (!entry.element || !entry.element.isConnected) {
909
- const rel = descriptor.type === "module" ? "modulepreload" : "stylesheet";
910
- let el = findAssetElement(`link[rel="${rel}"]`, "href", descriptor.href);
911
- if (!el && descriptor.type === "style") {
912
- el = findAssetElement('link[rel="preload"][as="style"]', "href", descriptor.href);
913
- }
914
- if (!el) {
915
- adopted = false;
916
- el = document.createElement("link");
917
- if (descriptor.type === "style") {
918
- el.setAttribute("rel", "preload");
919
- el.setAttribute("as", "style");
920
- } else {
921
- el.setAttribute("rel", "modulepreload");
922
- }
923
- el.setAttribute("href", descriptor.href);
924
- if (!document.body) el.setAttribute("blocking", "render");
925
- }
926
- if (descriptor.attrs) setAssetAttrs(el, descriptor.attrs);
927
- if (!el.isConnected) document.head.appendChild(el);
928
- entry.element = el;
929
- entry.loadState = undefined;
930
- entry.loadPromise = undefined;
931
- }
932
- if (descriptor.type === "style") trackAssetLoad(entry, adopted);
933
- return entry;
934
- }
935
- function acquireAsset(descriptor) {
936
- const key = assetEntryKey(descriptor);
937
- let entry = assetRegistry.get(key);
938
- if (descriptor.policy === "exclusive") {
939
- if (!entry) {
940
- entry = {
941
- original: descriptor.get(),
942
- set: descriptor.set,
943
- writers: []
944
- };
945
- assetRegistry.set(key, entry);
946
- }
947
- const writer = {
948
- value: descriptor.value
949
- };
950
- entry.writers.push(writer);
951
- entry.set(writer.value);
952
- let released = false;
953
- return () => {
954
- if (released) return;
955
- released = true;
956
- const index = entry.writers.indexOf(writer);
957
- const wasTop = index === entry.writers.length - 1;
958
- entry.writers.splice(index, 1);
959
- if (!wasTop) return;
960
- if (entry.writers.length) {
961
- entry.set(entry.writers[entry.writers.length - 1].value);
962
- } else {
963
- entry.set(entry.original);
964
- assetRegistry.delete(key);
965
- }
966
- };
967
- }
968
- if (!entry) {
969
- entry = {
970
- count: 0,
971
- element: null,
972
- timer: null
973
- };
974
- assetRegistry.set(key, entry);
975
- }
976
- if (entry.timer) {
977
- clearTimeout(entry.timer);
978
- entry.timer = null;
979
- }
980
- entry.count++;
981
- if (!entry.element || !entry.element.isConnected) {
982
- entry.element = mountAssetElement(descriptor);
983
- } else if (descriptor.type === "style" && entry.element.getAttribute("rel") === "preload") {
984
- entry.element.removeAttribute("as");
985
- entry.element.setAttribute("rel", "stylesheet");
986
- }
987
- let released = false;
988
- return () => {
989
- if (released) return;
990
- released = true;
991
- if (--entry.count > 0) return;
992
- entry.timer = setTimeout(() => {
993
- assetRegistry.delete(key);
994
- entry.element && entry.element.remove();
995
- }, ASSET_REMOVAL_GRACE);
996
- };
997
- }
998
- let headRegistrations = null;
999
- let headSeq = 0;
1000
- let headUid = 0;
1001
- let headOwned = null;
1002
- let headApplied = null;
1003
- let headFallbackTitle = null;
1004
- let headScheduled = false;
1005
- const headMountedResources = new Set();
1006
- function initHeadRegistry() {
1007
- if (headRegistrations) return;
1008
- headRegistrations = [];
1009
- headOwned = new Map();
1010
- headApplied = new Map();
1011
- const t = document.querySelector("title");
1012
- headFallbackTitle = t ? t.hasAttribute("data-dh") ? t.getAttribute("data-dhf") : t.textContent : null;
1013
- if (globalThis._$HY) globalThis._$HY.h = applyServerHeadOps;
1014
- }
1015
- function applyServerHeadOps(ops) {
1016
- for (let i = 0; i < ops.length; i++) {
1017
- const op = ops[i];
1018
- const identity = op[0] === "t" ? "title" : op[1];
1019
- if (headOwned.has(identity)) continue;
1020
- if (op[0] === "t") setHeadTitle(op[1]);else if (op[0] === "r") {
1021
- const els = headMarkedElements(identity);
1022
- for (let j = 0; j < els.length; j++) els[j].remove();
1023
- } else {
1024
- const el = document.createElement(op[2]);
1025
- for (const name in op[3]) el.setAttribute(name, op[3][name]);
1026
- if (op[4] != null) el.textContent = op[4];
1027
- el.setAttribute("data-dh", identity);
1028
- document.head.appendChild(el);
1029
- }
1030
- }
1031
- }
1032
- function headMarkedElements(identity) {
1033
- const nodes = document.head.querySelectorAll("[data-dh]");
1034
- const out = [];
1035
- for (let i = 0; i < nodes.length; i++) {
1036
- if (nodes[i].getAttribute("data-dh") === identity) out.push(nodes[i]);
1037
- }
1038
- return out;
1039
- }
1040
- function setHeadTitle(text) {
1041
- let el = document.querySelector("title");
1042
- if (!el) {
1043
- el = document.createElement("title");
1044
- document.head.appendChild(el);
1045
- }
1046
- el.textContent = text;
1047
- el.setAttribute("data-dh", "title");
1048
- return el;
1049
- }
1050
- function scheduleHeadApply() {
1051
- if (headScheduled) return;
1052
- headScheduled = true;
1053
- queueMicrotask(flushHeadRegistry);
1054
- }
1055
- function flushHeadRegistry() {
1056
- if (solidJs.sharedConfig.hydrating) {
1057
- setTimeout(flushHeadRegistry, 0);
1058
- return;
1059
- }
1060
- headScheduled = false;
1061
- const winners = resolveHead(headRegistrations);
1062
- for (const [identity, els] of headOwned) {
1063
- if (winners.has(identity)) continue;
1064
- headOwned.delete(identity);
1065
- headApplied.delete(identity);
1066
- if (identity === "title") {
1067
- if (headFallbackTitle != null) {
1068
- const el = setHeadTitle(headFallbackTitle);
1069
- el.removeAttribute("data-dh");
1070
- el.removeAttribute("data-dhf");
1071
- }
1072
- } else {
1073
- for (let i = 0; i < els.length; i++) els[i].remove();
1074
- }
1075
- }
1076
- for (const [identity, winner] of winners) {
1077
- let sig = "";
1078
- for (let i = 0; i < winner.tags.length; i++) sig += winner.tags[i].tag + JSON.stringify(winner.tags[i].props) + "|";
1079
- if (headApplied.get(identity) === sig) continue;
1080
- headApplied.set(identity, sig);
1081
- if (identity === "base" || identity === "charset") {
1082
- console.warn(`useHead: <${winner.tags[0].tag}> (${identity}) is shell-only and ignored on the client`);
1083
- continue;
1084
- }
1085
- if (identity === "title") {
1086
- const children = winner.tags[0].props.children;
1087
- setHeadTitle(children == null ? "" : String(children));
1088
- headOwned.set(identity, []);
1089
- continue;
1090
- }
1091
- const existing = headMarkedElements(identity);
1092
- const els = [];
1093
- for (let i = 0; i < winner.tags.length; i++) {
1094
- els.push(renderHeadElement(winner.tags[i], identity, existing));
1095
- }
1096
- for (let i = 0; i < existing.length; i++) {
1097
- if (els.indexOf(existing[i]) === -1) existing[i].remove();
1098
- }
1099
- headOwned.set(identity, els);
1100
- }
1101
- }
1102
- function createHeadElement(tag, props) {
1103
- const el = document.createElement(tag);
1104
- for (const name in props) {
1105
- if (name === "children" || name === "ref" || name.slice(0, 2) === "on") continue;
1106
- if (!HEAD_ATTR_NAME.test(name)) {
1107
- console.warn(`useHead: ignoring invalid attribute name "${name}"`);
1108
- continue;
1109
- }
1110
- const v = props[name];
1111
- if (v == null || v === false) continue;
1112
- el.setAttribute(name, v === true ? "" : String(v));
1113
- }
1114
- if (props.children != null) el.textContent = String(props.children);
1115
- return el;
1116
- }
1117
- function renderHeadElement(t, identity, existing) {
1118
- for (let i = 0; i < existing.length; i++) {
1119
- if (headElementMatches(existing[i], t)) return existing.splice(i, 1)[0];
1120
- }
1121
- const el = createHeadElement(t.tag, t.props);
1122
- el.setAttribute("data-dh", identity);
1123
- document.head.appendChild(el);
1124
- return el;
1125
- }
1126
- function headElementMatches(el, t) {
1127
- if (el.tagName.toLowerCase() !== t.tag) return false;
1128
- for (const name in t.props) {
1129
- if (name === "children" || name === "ref" || name.slice(0, 2) === "on") continue;
1130
- if (!HEAD_ATTR_NAME.test(name)) continue;
1131
- const v = t.props[name];
1132
- if (v == null || v === false) {
1133
- if (el.hasAttribute(name)) return false;
1134
- } else if (el.getAttribute(name) !== (v === true ? "" : String(v))) return false;
1135
- }
1136
- const children = t.props.children;
1137
- return (children == null ? "" : String(children)) === el.textContent;
1138
- }
1139
- function mountHeadResource(tag, props) {
1140
- const identity = resourceIdentity(tag, props);
1141
- if (headMountedResources.has(identity)) return;
1142
- headMountedResources.add(identity);
1143
- const url = props.href || props.src;
1144
- let el = null;
1145
- if (url != null) {
1146
- if (tag === "link") el = findAssetElement(`link[rel="${props.rel}"]`, "href", url);else if (tag === "script") el = findAssetElement("script[src]", "src", url);else el = findAssetElement("style[href]", "href", url);
1147
- }
1148
- if (!el) document.head.appendChild(createHeadElement(tag, props));
1149
- }
1150
- function gateHeadResource(props) {
1151
- const descriptor = {
1152
- type: props.rel === "stylesheet" ? "style" : "module",
1153
- href: props.href
1154
- };
1155
- let gateable = props.rel === "stylesheet" && props.href != null;
1156
- let attrs = null;
1157
- for (const name in props) {
1158
- if (name === "rel" || name === "href") continue;
1159
- if (!STYLESHEET_FETCH_META.has(name)) gateable = false;
1160
- if (!HEAD_ATTR_NAME.test(name)) continue;
1161
- const v = props[name];
1162
- if (v == null || v === false) continue;
1163
- (attrs || (attrs = {}))[name] = v === true ? "" : String(v);
1164
- }
1165
- if (attrs) descriptor.attrs = attrs;
1166
- effect(() => {
1167
- const entry = warmAsset(descriptor);
1168
- if (gateable && entry.loadState === "pending" && typeof waitAsset === "function") waitAsset(entry.loadPromise);
1169
- }, () => acquireAsset(descriptor));
1170
- }
1171
- function useHead(tags) {
1172
- initHeadRegistry();
1173
- const reg = {
1174
- seq: -1,
1175
- tags: null
1176
- };
1177
- const uid = ++headUid;
1178
- effect(() => {
1179
- let list = typeof tags === "function" ? tags() : tags;
1180
- if (!Array.isArray(list)) list = [list];
1181
- const replaceable = [];
1182
- const resources = [];
1183
- for (let i = 0; i < list.length; i++) {
1184
- const desc = list[i];
1185
- if (!desc || !HEAD_ELIGIBLE_TAGS.has(desc.tag)) {
1186
- console.warn(`useHead: ignoring non-head tag`, desc);
1187
- continue;
1188
- }
1189
- const cls = classifyHeadTag(desc);
1190
- const props = evalHeadProps(desc.props || {}, cls.rel !== undefined ? {
1191
- rel: cls.rel
1192
- } : undefined);
1193
- if (cls.resource) {
1194
- if (desc.tag === "link" && (props.rel === "stylesheet" || props.rel === "modulepreload")) {
1195
- gateHeadResource(props);
1196
- } else if (desc.tag === "link") {
1197
- mountHeadResource(desc.tag, props);
1198
- } else {
1199
- resources.push({
1200
- tag: desc.tag,
1201
- props
1202
- });
1203
- }
1204
- } else {
1205
- const key = evalHeadValue(desc.key);
1206
- replaceable.push({
1207
- tag: desc.tag,
1208
- props,
1209
- identity: replaceableIdentity(desc.tag, props, key, "u:c" + uid + ":" + i)
1210
- });
1211
- }
1212
- }
1213
- return {
1214
- replaceable,
1215
- resources
1216
- };
1217
- }, evaluated => {
1218
- for (let i = 0; i < evaluated.resources.length; i++) {
1219
- mountHeadResource(evaluated.resources[i].tag, evaluated.resources[i].props);
1220
- }
1221
- reg.tags = evaluated.replaceable;
1222
- if (reg.seq < 0) reg.seq = ++headSeq;
1223
- if (headRegistrations.indexOf(reg) === -1) headRegistrations.push(reg);
1224
- scheduleHeadApply();
1225
- return () => {
1226
- const idx = headRegistrations.indexOf(reg);
1227
- if (idx > -1) headRegistrations.splice(idx, 1);
1228
- scheduleHeadApply();
1229
- };
1230
- });
1231
- }
1232
- function loadModuleAssets(mapping) {
1233
- const hy = globalThis._$HY;
1234
- if (!hy) return;
1235
- const pending = [];
1236
- for (const key in mapping) {
1237
- if (hy.modules[key]) continue;
1238
- const entryUrl = new URL(mapping[key], document.baseURI).href;
1239
- if (!hy.loading[key]) {
1240
- hy.loading[key] = import(entryUrl).then(mod => {
1241
- hy.modules[key] = mod;
1242
- }, err => {
1243
- delete hy.loading[key];
1244
- throw err;
1245
- });
1246
- }
1247
- pending.push(hy.loading[key]);
1248
- }
1249
- return pending.length ? Promise.all(pending).then(() => {}) : undefined;
1250
- }
1251
- function hydrate(code, element, options = {}) {
1252
- solidJs.enableHydration();
1253
- installHydrationRuntime();
1254
- if (globalThis._$HY.done) return render(code, element, [...element.childNodes], options);
1255
- const head = (element.nodeType === 9 ? element : element.ownerDocument).head;
1256
- if (head && element.contains(head)) {
1257
- let n = head.firstChild;
1258
- while (n && n.nodeType === 1 && n.hasAttribute("data-dh") && !n.hasAttribute("data-dhf")) {
1259
- const next = n.nextSibling;
1260
- head.appendChild(n);
1261
- n = next;
1262
- }
1263
- }
1264
- options.renderId ||= "";
1265
- if (!globalThis._$HY.modules) globalThis._$HY.modules = {};
1266
- if (!globalThis._$HY.loading) globalThis._$HY.loading = {};
1267
- solidJs.sharedConfig.completed = globalThis._$HY.completed;
1268
- solidJs.sharedConfig.events = globalThis._$HY.events;
1269
- solidJs.sharedConfig.load = id => globalThis._$HY.r[id];
1270
- solidJs.sharedConfig.has = id => id in globalThis._$HY.r;
1271
- solidJs.sharedConfig.gather = root => gatherHydratable(element, root);
1272
- solidJs.sharedConfig.loadModuleAssets = loadModuleAssets;
1273
- solidJs.sharedConfig.cleanupFragment = id => {
1274
- const tpl = document.getElementById("pl-" + id);
1275
- if (tpl) {
1276
- let node = tpl.nextSibling;
1277
- while (node) {
1278
- const next = node.nextSibling;
1279
- if (node.nodeType === 8 && node.nodeValue === "pl-" + id) {
1280
- node.remove();
1281
- break;
1282
- }
1283
- node.remove();
1284
- node = next;
1285
- }
1286
- tpl.remove();
1287
- }
1288
- };
1289
- solidJs.sharedConfig.registry = new Map();
1290
- if (!solidJs.sharedConfig.boundaryScopes) solidJs.sharedConfig.boundaryScopes = new Map();
1291
- solidJs.sharedConfig.captureBoundaryScope = id => {
1292
- if (solidJs.sharedConfig.registry) solidJs.sharedConfig.boundaryScopes.set(id, {
1293
- registry: solidJs.sharedConfig.registry,
1294
- gather: solidJs.sharedConfig.gather
1295
- });
1296
- };
1297
- solidJs.sharedConfig.hydrating = true;
1298
- {
1299
- solidJs.sharedConfig.verifyHydration = () => {
1300
- if (solidJs.sharedConfig.registry && solidJs.sharedConfig.registry.size) {
1301
- const orphaned = [...solidJs.sharedConfig.registry.values()].filter(node => node.isConnected);
1302
- solidJs.sharedConfig.registry.clear();
1303
- if (!orphaned.length) return;
1304
- console.warn(`Hydration completed with ${orphaned.length} unclaimed server-rendered node(s):\n` + orphaned.map(node => ` ${node.outerHTML.slice(0, 100)}`).join("\n"));
1305
- }
1306
- };
1307
- }
1308
- const hyr = globalThis._$HY.r;
1309
- const rootMapping = hyr && (hyr[options.renderId + "_assets"] || hyr["_assets"]);
1310
- if (rootMapping && typeof rootMapping === "object") {
1311
- const p = loadModuleAssets(rootMapping);
1312
- if (p) {
1313
- gatherHydratable(element, options.renderId);
1314
- const registry = solidJs.sharedConfig.registry;
1315
- const gather = solidJs.sharedConfig.gather;
1316
- let disposer;
1317
- p.then(() => {
1318
- solidJs.sharedConfig.registry = registry;
1319
- solidJs.sharedConfig.gather = gather;
1320
- solidJs.sharedConfig.hydrating = true;
1321
- try {
1322
- disposer = render(code, element, [...element.childNodes], options);
1323
- } finally {
1324
- solidJs.sharedConfig.hydrating = false;
1325
- }
1326
- }, err => {
1327
- console.error("Hydration module preload failed, falling back to client render:", err);
1328
- solidJs.sharedConfig.hydrating = false;
1329
- solidJs.sharedConfig.registry = undefined;
1330
- disposer = render(code, element, [...element.childNodes], options);
1331
- });
1332
- return () => disposer && disposer();
1333
- }
1334
- }
1335
- try {
1336
- gatherHydratable(element, options.renderId);
1337
- return render(code, element, [...element.childNodes], options);
1338
- } finally {
1339
- solidJs.sharedConfig.hydrating = false;
1340
- }
1341
- }
1342
- function getNextElement(template) {
1343
- let node,
1344
- key,
1345
- hydrating = isHydrating();
1346
- if (!hydrating || !(node = solidJs.sharedConfig.registry.get(key = getHydrationKey()))) {
1347
- if (!template) {
1348
- throw new Error(`Hydration Mismatch. Unable to find DOM nodes for hydration key: ${key}`);
1349
- }
1350
- if (hydrating) {
1351
- console.warn(`Hydration key miss for "${key}": no server-rendered element carries this key` + (template._html ? ` (template: ${template._html.slice(0, 60)})` : "") + `. A detached element was created instead; its subtree will not appear in the ` + `document or become interactive. This usually means the server and client ` + `hydration id namespaces are misaligned — when hydrating a subtree of a larger ` + `server render, wrap the document shell in <NoHydration> and re-enter with ` + `<Hydration> around the hydrated subtree (or pass hydrate() a renderId matching ` + `the server's <Hydration id>).`);
1352
- }
1353
- return template(true);
1354
- }
1355
- if (template && template._html) {
1356
- const expected = template._html.match(/^<(\w+)/)?.[1];
1357
- if (expected && node.localName !== expected) {
1358
- console.warn(`Hydration tag mismatch for key "${key}": expected <${expected}> but found`, node);
1359
- }
1360
- }
1361
- if (solidJs.sharedConfig.completed) solidJs.sharedConfig.completed.add(node);
1362
- solidJs.sharedConfig.registry.delete(key);
1363
- return node;
1364
- }
1365
- function getNextMatch(el, nodeName) {
1366
- while (el && el.localName !== nodeName) el = el.nextSibling;
1367
- return el;
1368
- }
1369
- function getNextMarker(start) {
1370
- let end = start,
1371
- count = 0,
1372
- current = [];
1373
- if (isHydrating(start)) {
1374
- while (end) {
1375
- if (end.nodeType === 8) {
1376
- const v = end.nodeValue;
1377
- if (v === "$") count++;else if (v === "/") {
1378
- if (count === 0) return [end, current];
1379
- count--;
1380
- }
1381
- }
1382
- current.push(end);
1383
- end = end.nextSibling;
1384
- }
1385
- }
1386
- return [end, current];
1387
- }
1388
- function getFirstChild(node, expectedTag) {
1389
- const child = node.firstChild;
1390
- if (isHydrating() && expectedTag && child?.localName !== expectedTag) {
1391
- const isMissing = !child || child.nodeType !== 1;
1392
- console.warn("Hydration structure mismatch: expected <" + expectedTag + "> as first child of", node, "\n " + describeSiblings(node, child, expectedTag, isMissing));
1393
- }
1394
- return child;
1395
- }
1396
- function getNextSibling(node, expectedTag) {
1397
- const sibling = node.nextSibling;
1398
- if (isHydrating() && expectedTag && sibling?.localName !== expectedTag) {
1399
- const parent = node.parentNode;
1400
- const isMissing = !sibling || sibling.nodeType !== 1;
1401
- console.warn("Hydration structure mismatch: expected <" + expectedTag + "> after", node, "in", parent, "\n " + describeSiblings(parent, sibling, expectedTag, isMissing));
1402
- }
1403
- return sibling;
1404
- }
1405
- function describeSiblings(parent, mismatchChild, expectedTag, isMissing) {
1406
- if (!parent) return `<${expectedTag} \u2190 parent unavailable>`;
1407
- const children = [];
1408
- let child = parent.firstChild;
1409
- while (child) {
1410
- if (child.nodeType === 1) children.push(child);
1411
- child = child.nextSibling;
1412
- }
1413
- const pTag = parent.localName || "#fragment";
1414
- if (isMissing) {
1415
- const tags = children.map(c => `<${c.localName}>`).join("");
1416
- return `<${pTag}>${tags}<${expectedTag} \u2190 missing></${pTag}>`;
1417
- }
1418
- const idx = children.indexOf(mismatchChild);
1419
- let start = 0,
1420
- end = children.length;
1421
- let prefix = "",
1422
- suffix = "";
1423
- if (children.length > 6) {
1424
- start = Math.max(0, idx - 2);
1425
- end = Math.min(children.length, idx + 3);
1426
- if (start > 0) prefix = "...";
1427
- if (end < children.length) suffix = "...";
1428
- }
1429
- const tags = children.slice(start, end).map(c => c === mismatchChild ? `<${c.localName} \u2190 expected ${expectedTag}>` : `<${c.localName}>`).join("");
1430
- return `<${pTag}>${prefix}${tags}${suffix}</${pTag}>`;
1431
- }
1432
- function runHydrationEvents() {
1433
- if (solidJs.sharedConfig.events && !solidJs.sharedConfig.events.queued) {
1434
- queueMicrotask(() => {
1435
- const {
1436
- completed,
1437
- events
1438
- } = solidJs.sharedConfig;
1439
- if (!events) return;
1440
- events.queued = false;
1441
- while (events.length) {
1442
- const [el, e] = events[0];
1443
- if (!completed.has(el)) return;
1444
- events.shift();
1445
- let matchContainer, matchState, matchDistance, matches;
1446
- for (const [container, state] of delegatedContainers) {
1447
- if (!state.handlers.has(e.type)) continue;
1448
- const entry = findOwner(e.target, state);
1449
- if (!entry) continue;
1450
- if (matchContainer) {
1451
- if (!matches) matches = [{
1452
- container: matchContainer,
1453
- state: matchState,
1454
- distance: matchDistance
1455
- }];
1456
- matches.push({
1457
- container,
1458
- state,
1459
- distance: entry.distance
1460
- });
1461
- } else {
1462
- matchContainer = container;
1463
- matchState = state;
1464
- matchDistance = entry.distance;
1465
- }
1466
- }
1467
- if (matches) {
1468
- matches.sort((a, b) => a.distance - b.distance);
1469
- for (let i = 0; i < matches.length; i++) eventHandler(e, matches[i].container, matches[i].state);
1470
- } else if (matchContainer) eventHandler(e, matchContainer, matchState);
1471
- }
1472
- if (solidJs.sharedConfig.done) {
1473
- solidJs.sharedConfig.events = _$HY.events = null;
1474
- solidJs.sharedConfig.completed = _$HY.completed = null;
1475
- }
1476
- });
1477
- solidJs.sharedConfig.events.queued = true;
1478
- }
1479
- }
1480
- function isHydrating(node) {
1481
- if (!solidJs.sharedConfig.hydrating) return false;
1482
- if (!node || node.isConnected) return true;
1483
- const roots = solidJs.sharedConfig.claimRoots;
1484
- if (roots) {
1485
- for (let i = 0; i < roots.length; i++) {
1486
- if (roots[i].contains(node)) return true;
1487
- }
1488
- }
1489
- return false;
1490
- }
1491
- function classListToObject(classList) {
1492
- if (Array.isArray(classList)) {
1493
- const result = {};
1494
- flattenClassList(classList, result);
1495
- classList = result;
1496
- }
1497
- if (classList && typeof classList === "object") {
1498
- const result = {},
1499
- keys = Object.keys(classList);
1500
- for (let i = 0, len = keys.length; i < len; i++) {
1501
- const key = keys[i];
1502
- if (!classList[key]) continue;
1503
- const classNames = key.trim().split(/\s+/);
1504
- for (let j = 0, nameLen = classNames.length; j < nameLen; j++) classNames[j] && (result[classNames[j]] = true);
1505
- }
1506
- return result;
1507
- }
1508
- return classList;
1509
- }
1510
- function flattenClassList(list, result) {
1511
- for (let i = 0, len = list.length; i < len; i++) {
1512
- const item = list[i];
1513
- if (Array.isArray(item)) flattenClassList(item, result);else if (typeof item === "object" && item != null) Object.assign(result, item);
1514
- else if (typeof item !== "boolean" && (item || item === 0)) result[item] = true;
1515
- }
1516
- }
1517
- function assignProp(node, prop, value, prev, skipRef, nodeName) {
1518
- if (prop === "style") return style(node, value, prev), value;
1519
- if (prop === "class") return className(node, value, prev), value;
1520
- if (value === prev && DOMWithState[nodeName]?.[prop] !== 1) return prev;
1521
- if (prop === "ref") {
1522
- if (!skipRef && value) ref(() => value, node);
1523
- return value;
1524
- }
1525
- const hasNamespace = prop.indexOf(":") > -1;
1526
- if (!hasNamespace && prop.slice(0, 2) === "on") {
1527
- const name = prop.slice(2).toLowerCase();
1528
- const delegate = DelegatedEvents.has(name);
1529
- if (!delegate && prev) {
1530
- if (Array.isArray(value) && typeof prev === "function" && prev[$$EVENT_TUPLE] === value) return prev;
1531
- node.removeEventListener(name, prev, typeof prev !== "function" && prev);
1532
- }
1533
- if (delegate || value) {
1534
- const attached = addEvent(node, name, value, delegate);
1535
- delegate && delegateEvents([name]);
1536
- if (!delegate) return attached;
1537
- }
1538
- } else if (hasNamespace && prop.slice(0, 5) === "prop:" || ChildProperties.has(prop) || DOMWithState[nodeName]?.[prop]) {
1539
- if (hasNamespace) prop = prop.slice(5);else if (isHydrating(node)) return value;
1540
- if (prop === "value" && nodeName === "SELECT") queueMicrotask(() => node.value = value) || (node.value = value);else if ((prop === "value" || prop === "defaultValue") && (nodeName === "INPUT" || nodeName === "TEXTAREA"))
1541
- node[prop] = value ?? "";else node[prop] = value;
1542
- } else {
1543
- const ns = hasNamespace && Namespaces[prop.split(":")[0]];
1544
- if (ns) setAttributeNS(node, ns, prop, value);else setAttribute(node, prop, value);
1545
- }
1546
- return value;
1547
- }
1548
- function eventHandler(e, container, state) {
1549
- if (hydrationRt !== null && hydrationRt.dedupEvent(e)) return;
1550
- const prev = e[$$EVENT_OWNER];
1551
- let resumeNode;
1552
- if (prev) {
1553
- if (prev === true || prev === container || !container.contains(prev)) return;
1554
- resumeNode = prev;
1555
- }
1556
- const owner = state && (state.owners.size === 1 && state.owners.has(container) ? container : findOwner(e.target, state)?.owner);
1557
- if (state && !owner) return;
1558
- if (owner && owner === resumeNode) return;
1559
- e[$$EVENT_OWNER] = owner || true;
1560
- let node = resumeNode || e.target;
1561
- const key = `$$${e.type}`;
1562
- const oriTarget = e.target;
1563
- const boundary = owner || container || e.currentTarget;
1564
- const retarget = value => Object.defineProperty(e, "target", {
1565
- configurable: true,
1566
- value
1567
- });
1568
- const handleNode = () => {
1569
- let handler = node[key];
1570
- if (handler === undefined && node.hasAttribute && node.hasAttribute("_bnd")) {
1571
- const seam = globalThis[Symbol.for("solid.bnd")];
1572
- if (seam) handler = seam.resolve(node, e.type);
1573
- }
1574
- if (handler && !node.disabled) {
1575
- const data = node[`${key}Data`];
1576
- data !== undefined ? handler.call(node, data, e) : typeof handler === "function" ? handler.call(node, e) : handler.handleEvent(e);
1577
- if (e.cancelBubble) return;
1578
- }
1579
- node.host && typeof node.host !== "string" && !node.host._$host && node.contains(e.target) && retarget(node.host);
1580
- return true;
1581
- };
1582
- const walkUpTree = () => {
1583
- while (node && handleNode()) {
1584
- if (node === boundary || node.parentNode === boundary) break;
1585
- node = node._$host || node.parentNode || node.host;
1586
- }
1587
- };
1588
- Object.defineProperty(e, "currentTarget", {
1589
- configurable: true,
1590
- get() {
1591
- return node || boundary || document;
1592
- }
1593
- });
1594
- if (resumeNode) {
1595
- if (resumeNode === e.target) node = resumeNode._$host || resumeNode.parentNode || resumeNode.host;
1596
- if (node && node !== boundary) walkUpTree();
1597
- } else if (e.composedPath) {
1598
- const path = e.composedPath();
1599
- if (path.length) {
1600
- retarget(path[0]);
1601
- for (let i = 0; i < path.length; i++) {
1602
- node = path[i];
1603
- if (!handleNode()) break;
1604
- if (node._$host) {
1605
- node = node._$host;
1606
- walkUpTree();
1607
- break;
1608
- }
1609
- if (node === boundary || node.parentNode === boundary) {
1610
- break;
1611
- }
1612
- }
1613
- } else walkUpTree();
1614
- }
1615
- else walkUpTree();
1616
- retarget(oriTarget);
1617
- }
1618
- function insertExpression(parent, value, current, marker) {
1619
- if (hydrationRt !== null && isHydrating(parent)) {
1620
- if (value && value !== current) {
1621
- const arr = Array.isArray(value);
1622
- for (const n of arr ? value : [value]) {
1623
- if (n && n.nodeType) {
1624
- if (!isHydrating(n)) return current;
1625
- } else if (arr && (typeof n === "string" || typeof n === "number")) {
1626
- return current;
1627
- }
1628
- }
1629
- }
1630
- return value;
1631
- }
1632
- if (value === current) return value;
1633
- const t = typeof value,
1634
- multi = marker !== undefined;
1635
- if (t === "string" || t === "number") {
1636
- const tc = typeof current;
1637
- if (tc === "string" || tc === "number") {
1638
- parent.firstChild.data = value;
1639
- } else {
1640
- if (ownsAllChildren(parent, current)) parent.textContent = value;else {
1641
- removeOwnedChildren(parent, current);
1642
- parent.insertBefore(document.createTextNode(value), parent.firstChild);
1643
- }
1644
- }
1645
- } else if (value === undefined) {
1646
- cleanChildren(parent, current, marker);
1647
- } else if (value.nodeType) {
1648
- if (Array.isArray(current)) {
1649
- cleanChildren(parent, current, multi ? marker : null, value);
1650
- } else if (current && current.nodeType) {
1651
- current.parentNode === parent ? parent.replaceChild(value, current) : parent.appendChild(value);
1652
- } else if (current && parent.firstChild) {
1653
- parent.replaceChild(value, parent.firstChild);
1654
- } else {
1655
- parent.appendChild(value);
1656
- }
1657
- if (marker) value[$$SLOT] = marker;
1658
- } else if (Array.isArray(value)) {
1659
- const currentArray = current && Array.isArray(current);
1660
- for (let i = 0, len = value.length; i < len; i++) {
1661
- const item = value[i],
1662
- t = typeof item;
1663
- if (t === "string" || t === "number") {
1664
- const prev = currentArray ? current[i] : undefined;
1665
- if (prev && prev.nodeType === 3) {
1666
- if (prev.data !== "" + item) prev.data = item;
1667
- value[i] = prev;
1668
- } else value[i] = document.createTextNode(item);
1669
- }
1670
- }
1671
- if (value.length === 0) {
1672
- cleanChildren(parent, current, marker);
1673
- } else if (currentArray) {
1674
- if (current.length === 0) {
1675
- appendNodes(parent, value, marker);
1676
- } else reconcileArrays(parent, current, value, marker);
1677
- } else {
1678
- current && cleanChildren(parent, current);
1679
- appendNodes(parent, value);
1680
- }
1681
- } else console.warn(`Unrecognized value. Skipped inserting`, value);
1682
- return value;
1683
- }
1684
- function normalize(value, current, multi, doNotUnwrap) {
1685
- value = solidJs.flatten(value, {
1686
- skipNonRendered: true,
1687
- doNotUnwrap
1688
- });
1689
- if (doNotUnwrap && typeof value === "function") return value;
1690
- if (multi && !Array.isArray(value)) value = [value != null ? value : ""];
1691
- if (solidJs.sharedConfig.hydrating && Array.isArray(value)) {
1692
- for (let i = 0, len = value.length; i < len; i++) {
1693
- const item = value[i],
1694
- prev = current && current[i],
1695
- t = typeof item;
1696
- if ((t === "string" || t === "number") && prev && prev.nodeType === 3 && isHydrating(prev)) value[i] = prev;
1697
- }
1698
- }
1699
- return value;
1700
- }
1701
- function tagHost(value, host) {
1702
- if (Array.isArray(value)) {
1703
- for (let i = 0, len = value.length; i < len; i++) tagHost(value[i], host);
1704
- } else if (value && value.nodeType && value[$$HOST] !== host) {
1705
- value[$$HOST] = host;
1706
- Object.defineProperty(value, "_$host", {
1707
- get: host,
1708
- configurable: true
1709
- });
1710
- }
1711
- }
1712
- function appendNodes(parent, array, marker = null) {
1713
- for (let i = 0, len = array.length; i < len; i++) {
1714
- const n = array[i];
1715
- parent.insertBefore(n, marker);
1716
- if (marker) n[$$SLOT] = marker;
1717
- }
1718
- }
1719
- function ownsAllChildren(parent, current) {
1720
- if (current == null) return true;
1721
- if (Array.isArray(current)) {
1722
- return current.length ? parent.firstChild === current[0] && parent.lastChild === current[current.length - 1] : parent.firstChild === null;
1723
- }
1724
- if (current === "") return parent.firstChild === null;
1725
- if (current.nodeType) return parent.firstChild === current && parent.lastChild === current;
1726
- const first = parent.firstChild;
1727
- return first !== null && first.nodeType === 3 && parent.lastChild === first;
1728
- }
1729
- function removeOwnedChildren(parent, current) {
1730
- if (Array.isArray(current)) {
1731
- for (let i = 0; i < current.length; i++) {
1732
- const el = current[i];
1733
- if (el.parentNode === parent) el.remove();
1734
- }
1735
- } else if (current.nodeType) {
1736
- if (current.parentNode === parent) current.remove();
1737
- } else {
1738
- const first = parent.firstChild;
1739
- if (first && first.nodeType === 3) first.remove();
1740
- }
1741
- }
1742
- function cleanChildren(parent, current, marker, replacement) {
1743
- if (marker === undefined) {
1744
- if (ownsAllChildren(parent, current)) return parent.textContent = "";
1745
- return removeOwnedChildren(parent, current);
1746
- }
1747
- if (current.length) {
1748
- let inserted = false;
1749
- for (let i = current.length - 1; i >= 0; i--) {
1750
- const el = current[i];
1751
- if (replacement !== el) {
1752
- const tag = el[$$SLOT];
1753
- const owns = el.parentNode === parent && (!tag || tag === marker);
1754
- if (replacement && !inserted && !i) owns ? parent.replaceChild(replacement, el) : parent.insertBefore(replacement, marker);else if (owns) el.remove();
1755
- } else inserted = true;
1756
- }
1757
- } else if (replacement) parent.insertBefore(replacement, marker);
1758
- if (replacement && marker) replacement[$$SLOT] = marker;
1759
- }
1760
- function gatherHydratable(element, root) {
1761
- const templates = element.querySelectorAll(`*[_hk]`);
1762
- for (let i = 0; i < templates.length; i++) {
1763
- const node = templates[i];
1764
- const key = node.getAttribute("_hk");
1765
- if (root) {
1766
- if (!key.startsWith(root)) continue;
1767
- } else {
1768
- const frame = node.closest("[data-fid]");
1769
- if (frame && frame !== element && element.contains(frame)) continue;
1770
- }
1771
- if (!solidJs.sharedConfig.registry.has(key)) solidJs.sharedConfig.registry.set(key, node);
1772
- }
1773
- }
1774
- function getHydrationKey() {
1775
- return solidJs.sharedConfig.getNextContextId();
1776
- }
1777
- const RequestContext = Symbol();
1778
-
1779
- const PURE_ROW = Symbol.for("solid.pure-row");
1780
- const arm = () => {
1781
- installListDriver(driveList);
1782
- };
1783
- function rowProof(fn) {
1784
- arm();
1785
- fn[PURE_ROW] = true;
1786
- return fn;
1787
- }
1788
- let rowCollector = null;
1789
- const lisPositions = sources => {
1790
- const n = sources.length;
1791
- const tails = [];
1792
- const tailsIdx = [];
1793
- const prev = new Array(n).fill(-1);
1794
- for (let j = 0; j < n; j++) {
1795
- const v = sources[j];
1796
- if (v === -1) continue;
1797
- let lo = 0,
1798
- hi = tails.length;
1799
- while (lo < hi) {
1800
- const mid = lo + hi >> 1;
1801
- if (tails[mid] < v) lo = mid + 1;else hi = mid;
1802
- }
1803
- if (lo > 0) prev[j] = tailsIdx[lo - 1];
1804
- tails[lo] = v;
1805
- tailsIdx[lo] = j;
1806
- }
1807
- const stable = new Set();
1808
- let k = tailsIdx.length ? tailsIdx[tails.length - 1] : -1;
1809
- while (k >= 0) {
1810
- stable.add(k);
1811
- k = prev[k];
1812
- }
1813
- return stable;
1814
- };
1815
- const driveList = (parent, listFn, marker, lateClassic) => {
1816
- const meta = listFn.$ll;
1817
- if (meta.row?.[PURE_ROW] !== true) return false;
1818
- if (typeof meta.keyed === "function") return false;
1819
- const evalOwner = solidJs.createOwner({
1820
- id: "&each"
1821
- });
1822
- let subject = solidJs.runWithOwner(evalOwner, () => solidJs.untrack(meta.each));
1823
- evalOwner.dispose();
1824
- let raw = subject != null ? solidJs.patchableRaw(subject) : undefined;
1825
- if (raw === undefined || !Array.isArray(raw)) return false;
1826
- const optimistic = solidJs.storeHasOptimisticFamily(subject);
1827
- if (optimistic) raw = solidJs.untrack(() => Array.from(subject));
1828
- const hydrating = !!solidJs.sharedConfig.hydrating;
1829
- if (hydrating && raw.length === 0) return false;
1830
- let domRows;
1831
- let rowIds;
1832
- if (hydrating) {
1833
- if (marker !== undefined) return false;
1834
- domRows = Array.from(parent.children);
1835
- if (domRows.length !== raw.length) return false;
1836
- rowIds = new Array(raw.length);
1837
- for (let i = 0; i < domRows.length; i++) {
1838
- const key = domRows[i].getAttribute("_hk");
1839
- if (key === null || !key.endsWith("0") || key.length < 2) return false;
1840
- rowIds[i] = key.slice(0, -1);
1841
- }
1842
- }
1843
- const rowFn = meta.row;
1844
- const endAnchor = marker ?? null;
1845
- const shallow = solidJs.storeIsShallow(subject);
1846
- let lastBodies = null;
1847
- let lastUnbinds = null;
1848
- const collectBind = (abs, build) => {
1849
- const prevC = rowCollector;
1850
- rowCollector = {
1851
- row: shallow ? subject[abs] : undefined,
1852
- bodies: [],
1853
- unbinds: []
1854
- };
1855
- try {
1856
- return build();
1857
- } finally {
1858
- lastBodies = rowCollector.bodies;
1859
- lastUnbinds = rowCollector.unbinds;
1860
- rowCollector = prevC;
1861
- }
1862
- };
1863
- const listOwner = solidJs.createOwner();
1864
- let declined = false;
1865
- const bindRow = (abs, claimId) => {
1866
- {
1867
- const o = listOwner;
1868
- const prevChild = o._firstChild;
1869
- const prevDisposal = o._disposal;
1870
- const node = collectBind(abs, () => solidJs.runWithOwner(listOwner, () => claimId !== undefined ? solidJs.runWithOwner(solidJs.createOwner({
1871
- id: claimId
1872
- }), () => solidJs.untrack(() => rowFn(subject[abs]))) : solidJs.untrack(() => rowFn(subject[abs]))));
1873
- if (o._firstChild !== prevChild || o._disposal !== prevDisposal) {
1874
- console.warn("A patch-mode list row created reactive computations or cleanups " + "during build (likely a handler/attribute value expression calling " + "createEffect/onCleanup). This work attaches to the LIST, not the " + "row, and will not dispose when the row is removed. Move owned " + "work into effects/refs (which opt the row out of patch mode).");
1875
- }
1876
- return node;
1877
- }
1878
- };
1879
- let entries = new Array(raw.length);
1880
- let rowBodies = shallow ? new Array(raw.length) : null;
1881
- let rowUnbinds = new Array(raw.length);
1882
- const runUnbinds = list => {
1883
- if (list !== undefined) for (let u = 0; u < list.length; u++) list[u]();
1884
- };
1885
- const unbindAllRows = () => {
1886
- for (let j = 0; j < rowUnbinds.length; j++) runUnbinds(rowUnbinds[j]);
1887
- rowUnbinds = [];
1888
- };
1889
- let prevRaws = raw.slice();
1890
- try {
1891
- if (hydrating) {
1892
- for (let i = 0; i < raw.length; i++) {
1893
- entries[i] = bindRow(i, rowIds[i]);
1894
- if (rowBodies !== null) rowBodies[i] = lastBodies;
1895
- rowUnbinds[i] = lastUnbinds;
1896
- }
1897
- } else {
1898
- for (let i = 0; i < raw.length; i++) {
1899
- const node = bindRow(i);
1900
- entries[i] = node;
1901
- if (rowBodies !== null) rowBodies[i] = lastBodies;
1902
- rowUnbinds[i] = lastUnbinds;
1903
- parent.insertBefore(node, endAnchor);
1904
- }
1905
- }
1906
- } catch (err) {
1907
- unbindAllRows();
1908
- runUnbinds(lastUnbinds ?? undefined);
1909
- for (let j = 0; j < entries.length; j++) {
1910
- const n = entries[j];
1911
- if (n !== undefined && n.parentNode === parent) n.remove();
1912
- }
1913
- listOwner.dispose();
1914
- throw err;
1915
- }
1916
- const identityOps = nextArr => {
1917
- const keyOf = r => {
1918
- const w = r != null ? solidJs.patchableRaw(r) : undefined;
1919
- return w !== undefined ? w : r;
1920
- };
1921
- const oldIndex = new Map();
1922
- for (let j = 0; j < prevRaws.length; j++) {
1923
- const k = keyOf(prevRaws[j]);
1924
- const existing = oldIndex.get(k);
1925
- if (existing === undefined) oldIndex.set(k, j);else if (Array.isArray(existing)) existing.push(j);else oldIndex.set(k, [existing, j]);
1926
- }
1927
- const sources = new Array(nextArr.length);
1928
- for (let k = 0; k < nextArr.length; k++) {
1929
- const m = oldIndex.get(keyOf(nextArr[k]));
1930
- if (m === undefined) sources[k] = -1;else if (Array.isArray(m)) {
1931
- sources[k] = m.shift();
1932
- if (m.length === 1) oldIndex.set(keyOf(nextArr[k]), m[0]);
1933
- } else {
1934
- sources[k] = m;
1935
- oldIndex.delete(keyOf(nextArr[k]));
1936
- }
1937
- }
1938
- return {
1939
- prefix: 0,
1940
- sources
1941
- };
1942
- };
1943
- let resyncNeeded = false;
1944
- const applyOps = (next, ops) => {
1945
- if (declined) return;
1946
- if (resyncNeeded) ops = null;
1947
- if (ops === null) ops = identityOps(next);
1948
- const {
1949
- prefix,
1950
- sources
1951
- } = ops;
1952
- const built = new Array(sources.length);
1953
- const builtBodies = rowBodies !== null ? new Array(sources.length) : null;
1954
- const builtUnbinds = new Array(sources.length);
1955
- let j = 0;
1956
- try {
1957
- for (; j < sources.length; j++) {
1958
- const abs = prefix + j;
1959
- const src = sources[j];
1960
- if (src === -1 || refRebuild && src >= 0 && next[abs] !== prevRaws[src]) {
1961
- built[j] = bindRow(abs);
1962
- if (builtBodies !== null) builtBodies[j] = lastBodies;
1963
- builtUnbinds[j] = lastUnbinds;
1964
- }
1965
- }
1966
- } catch (err) {
1967
- for (let k = 0; k < j; k++) runUnbinds(builtUnbinds[k]);
1968
- runUnbinds(lastUnbinds ?? undefined);
1969
- resyncNeeded = true;
1970
- throw err;
1971
- }
1972
- const retained = new Set();
1973
- for (let k = 0; k < sources.length; k++) {
1974
- if (sources[k] >= 0 && built[k] === undefined) retained.add(sources[k]);
1975
- }
1976
- for (let k = prefix; k < entries.length; k++) {
1977
- if (!retained.has(k)) {
1978
- entries[k].remove();
1979
- runUnbinds(rowUnbinds[k]);
1980
- }
1981
- }
1982
- const newEntries = new Array(prefix + sources.length);
1983
- const newBodies = rowBodies !== null ? new Array(prefix + sources.length) : null;
1984
- const newUnbinds = new Array(prefix + sources.length);
1985
- for (let i = 0; i < prefix; i++) {
1986
- newEntries[i] = entries[i];
1987
- if (newBodies !== null) newBodies[i] = rowBodies[i];
1988
- newUnbinds[i] = rowUnbinds[i];
1989
- }
1990
- const stable = lisPositions(sources);
1991
- let anchor = endAnchor;
1992
- for (let k = sources.length - 1; k >= 0; k--) {
1993
- const abs = prefix + k;
1994
- const src = sources[k];
1995
- let node;
1996
- if (built[k] !== undefined) {
1997
- node = built[k];
1998
- if (newBodies !== null) newBodies[abs] = builtBodies[k];
1999
- newUnbinds[abs] = builtUnbinds[k];
2000
- parent.insertBefore(node, anchor);
2001
- } else {
2002
- node = entries[src];
2003
- if (newBodies !== null) newBodies[abs] = rowBodies[src];
2004
- newUnbinds[abs] = rowUnbinds[src];
2005
- if (!stable.has(k)) parent.insertBefore(node, anchor);
2006
- }
2007
- newEntries[abs] = node;
2008
- anchor = node;
2009
- }
2010
- entries = newEntries;
2011
- if (newBodies !== null) rowBodies = newBodies;
2012
- rowUnbinds = newUnbinds;
2013
- prevRaws = next.slice();
2014
- resyncNeeded = false;
2015
- };
2016
- let unbindOps = solidJs.runWithOwner(listOwner, () => solidJs.registerRowOps(subject, applyOps));
2017
- const refRebuild = shallow && typeof meta.keyed !== "function";
2018
- const rebuildSlot = i => {
2019
- runUnbinds(rowUnbinds[i]);
2020
- const old = entries[i];
2021
- const node = bindRow(i);
2022
- rowBodies[i] = lastBodies;
2023
- rowUnbinds[i] = lastUnbinds;
2024
- parent.insertBefore(node, old);
2025
- old.remove();
2026
- entries[i] = node;
2027
- };
2028
- const applySlot = (i, next, prev) => {
2029
- if (declined) return;
2030
- if (resyncNeeded) {
2031
- const live = subject != null ? solidJs.patchableRaw(subject) : undefined;
2032
- if (live !== undefined && Array.isArray(live)) applyOps(live, null);
2033
- return;
2034
- }
2035
- if (refRebuild) {
2036
- rebuildSlot(i);
2037
- prevRaws[i] = next;
2038
- return;
2039
- }
2040
- const bodies = rowBodies[i];
2041
- if (bodies !== undefined) {
2042
- for (let b = 0; b < bodies.length; b++) bodies[b](next, prev, false);
2043
- }
2044
- prevRaws[i] = next;
2045
- };
2046
- let unbindSlots = shallow ? solidJs.runWithOwner(listOwner, () => solidJs.registerSlotPatch(subject, applySlot)) : null;
2047
- solidJs.runWithOwner(listOwner, () => effect(() => meta.each(), value => {
2048
- if (declined || value === subject) return;
2049
- const nextRaw = value != null ? solidJs.patchableRaw(value) : undefined;
2050
- unbindOps();
2051
- unbindSlots?.();
2052
- if (nextRaw !== undefined && Array.isArray(nextRaw) && solidJs.storeIsShallow(value) !== shallow) {
2053
- for (let j = 0; j < entries.length; j++) entries[j].remove();
2054
- entries = [];
2055
- prevRaws = [];
2056
- unbindAllRows();
2057
- subject = value;
2058
- declined = true;
2059
- listOwner.dispose();
2060
- lateClassic?.();
2061
- return;
2062
- }
2063
- if (nextRaw === undefined || !Array.isArray(nextRaw)) {
2064
- for (let j = 0; j < entries.length; j++) entries[j].remove();
2065
- entries = [];
2066
- prevRaws = [];
2067
- unbindAllRows();
2068
- subject = value;
2069
- declined = true;
2070
- listOwner.dispose();
2071
- lateClassic?.();
2072
- return;
2073
- }
2074
- const swapOps = identityOps(nextRaw);
2075
- subject = value;
2076
- unbindOps = solidJs.runWithOwner(listOwner, () => solidJs.registerRowOps(subject, applyOps));
2077
- if (shallow) unbindSlots = solidJs.runWithOwner(listOwner, () => solidJs.registerSlotPatch(subject, applySlot));
2078
- applyOps(nextRaw, swapOps);
2079
- }));
2080
- solidJs.onCleanup(() => {
2081
- unbindOps();
2082
- unbindSlots?.();
2083
- unbindAllRows();
2084
- listOwner.dispose();
2085
- });
2086
- return true;
2087
- };
2088
- const patchDriver = (subject, body) => {
2089
- const raw = solidJs.patchableRaw(subject);
2090
- if (raw !== undefined) {
2091
- if (!solidJs.sharedConfig.hydrating) body(raw, undefined, true);
2092
- const unbind = solidJs.registerPatch(subject, body);
2093
- if (rowCollector !== null) rowCollector.unbinds.push(unbind);
2094
- else solidJs.onCleanup(unbind);
2095
- } else if (rowCollector !== null && subject === rowCollector.row) {
2096
- rowCollector.bodies.push(body);
2097
- if (!solidJs.sharedConfig.hydrating) body(subject, undefined, true);
2098
- } else {
2099
- effect(() => body(subject, subject, false),
2100
- () => solidJs.untrack(() => body(subject, undefined, true)));
2101
- }
2102
- };
2103
-
2104
- function throwInBrowser(func) {
2105
- const err = new Error(`${func.name} is not supported in the browser, returning undefined`);
2106
- console.error(err);
2107
- }
2108
- function renderToString(fn, options) {
2109
- throwInBrowser(renderToString);
2110
- }
2111
- function renderToStream(fn, options) {
2112
- throwInBrowser(renderToStream);
2113
- }
2114
- function createResponseStub() {
2115
- throwInBrowser(createResponseStub);
2116
- }
2117
- function createRequestEvent(request, init) {
2118
- throwInBrowser(createRequestEvent);
2119
- }
2120
- function getExpectedRedirectStatus(response) {
2121
- throwInBrowser(getExpectedRedirectStatus);
2122
- }
2123
- function createSSRResponse() {
2124
- throwInBrowser(createSSRResponse);
2125
- }
2126
- function commitEventResponse(response, event) {
2127
- throwInBrowser(commitEventResponse);
2128
- }
2129
- function composeMiddleware(middlewares) {
2130
- throwInBrowser(composeMiddleware);
2131
- }
2132
- function ssr(template, ...nodes) {}
2133
- function ssrElement(name, props, children, needsId) {}
2134
- function ssrClassName(value) {}
2135
- function ssrStyle(value) {}
2136
- function ssrStyleProperty(name, value) {}
2137
- function ssrAttribute(key, value) {}
2138
- function ssrGroup(fn, n) {}
2139
- function ssrHydrationKey() {}
2140
- function resolveSSRNode(node, result, top) {}
2141
- function escape(s, attr) {}
2142
-
2143
- const ENVELOPE = Symbol.for("solid.ResponseEnvelope");
2144
- // PURE-annotated factory (same convention as solid's MockPromise): the brand
2145
- const ResponseEnvelope = /* @__PURE__ */(() => {
2146
- class ResponseEnvelope {
2147
- constructor(response, value) {
2148
- this.response = response;
2149
- this.value = value;
2150
- }
2151
- }
2152
- ResponseEnvelope.prototype[ENVELOPE] = true;
2153
- return ResponseEnvelope;
2154
- })();
2155
- function isResponseEnvelope(value) {
2156
- return !!(value && typeof value === "object" && value[ENVELOPE]);
2157
- }
2158
- const HREF = Symbol.for("solid.Href");
2159
- function isHref(value) {
2160
- return !!(value && (typeof value === "object" || typeof value === "function") && value[HREF]);
2161
- }
2162
- const SAFE_ERROR = Symbol.for("solid.SafeError");
2163
- function markSafeError(error) {
2164
- if (error && (typeof error === "object" || typeof error === "function")) {
2165
- Object.defineProperty(error, SAFE_ERROR, {
2166
- value: true,
2167
- enumerable: false,
2168
- configurable: true
2169
- });
2170
- }
2171
- return error;
2172
- }
2173
- function isSafeError(value) {
2174
- return !!(value && (typeof value === "object" || typeof value === "function") && value[SAFE_ERROR]);
2175
- }
2176
- const REVALIDATE_HEADER = "X-Revalidate";
2177
- const RESPONSE_HEADER_VALUE_LIMIT = 4096;
2178
- function initWithRevalidate(init = {}) {
2179
- const resolved = typeof init === "number" ? {
2180
- status: init
2181
- } : init;
2182
- const {
2183
- revalidate,
2184
- ...responseInit
2185
- } = resolved;
2186
- let headers;
2187
- if (responseInit.headers && responseInit.headers.getSetCookie) {
2188
- headers = new Headers();
2189
- responseInit.headers.forEach((value, key) => {
2190
- if (key !== "set-cookie") headers.append(key, value);
2191
- });
2192
- for (const cookie of responseInit.headers.getSetCookie()) {
2193
- headers.append("Set-Cookie", cookie);
2194
- }
2195
- } else {
2196
- headers = new Headers(responseInit.headers);
2197
- }
2198
- if (revalidate !== undefined) {
2199
- const keys = revalidate.toString();
2200
- if (keys.length > RESPONSE_HEADER_VALUE_LIMIT) {
2201
- throw new TypeError(`revalidate names ${keys.length} characters of cache keys; past ` + `${RESPONSE_HEADER_VALUE_LIMIT} the ${REVALIDATE_HEADER} header would overflow ` + `receivers (an 8 KiB proxy buffer holds the whole header block) and the response ` + `dies at the socket after the mutation committed. Split the invalidation across ` + `calls or use coarser keys — a dropped key would be a silently stale cache, so ` + `the runtime refuses rather than trims.`);
2202
- }
2203
- headers.set(REVALIDATE_HEADER, keys);
2204
- }
2205
- return {
2206
- responseInit,
2207
- headers
2208
- };
2209
- }
2210
- function redirect(url, init = 302) {
2211
- if (typeof url !== "string" && !isHref(url)) {
2212
- throw new TypeError("redirect() expects a string URL or an Href-branded value (Symbol.for('solid.Href')).");
2213
- }
2214
- const {
2215
- responseInit,
2216
- headers
2217
- } = initWithRevalidate(init);
2218
- if (responseInit.status === undefined) {
2219
- responseInit.status = 302;
2220
- }
2221
- const target = typeof url === "string" ? url : url[HREF];
2222
- const location = typeof target === "string" ? target : String(url);
2223
- const encoded = location.replace(/[^\x00-\x7f]/gu, encodeURIComponent);
2224
- if (encoded.length > RESPONSE_HEADER_VALUE_LIMIT) {
2225
- throw new TypeError(`redirect() target is ${encoded.length} characters; past ` + `${RESPONSE_HEADER_VALUE_LIMIT} the Location header (and the scripted transport's ` + `redirect header) would overflow receivers and the response dies at the socket. ` + `A target this size is usually unbounded input echoed into the url — carry the ` + `state server-side instead. Refused rather than trimmed: a cut target is a ` + `different address.`);
2226
- }
2227
- headers.set("Location", encoded);
2228
- return new Response(null, {
2229
- ...responseInit,
2230
- headers
2231
- });
2232
- }
2233
- function reload(init = {}) {
2234
- const {
2235
- responseInit,
2236
- headers
2237
- } = initWithRevalidate(init);
2238
- return new Response(null, {
2239
- ...responseInit,
2240
- headers
2241
- });
2242
- }
2243
- const NULL_BODY_STATUSES = new Set([204, 205, 304]);
2244
- function respond(value, init = {}) {
2245
- const {
2246
- responseInit,
2247
- headers
2248
- } = initWithRevalidate(init);
2249
- for (const header of COMPOSED_BODY_FRAMING) headers.delete(header);
2250
- if (NULL_BODY_STATUSES.has(responseInit.status)) {
2251
- return new ResponseEnvelope(new Response(null, {
2252
- ...responseInit,
2253
- headers
2254
- }), value);
2255
- }
2256
- headers.set("Content-Type", "application/json");
2257
- return new ResponseEnvelope(new Response(JSON.stringify(value), {
2258
- ...responseInit,
2259
- headers
2260
- }), value);
2261
- }
2262
-
2263
- const isServer = false;
2264
- const isDev = true;
2265
- function Portal(props) {
2266
- return solidJs.runWithOwner(solidJs.createOwner(), () => portalImpl(props));
2267
- }
2268
- function portalImpl(props) {
2269
- const treeMarker = document.createTextNode(""),
2270
- startMarker = document.createTextNode(""),
2271
- endMarker = document.createTextNode(""),
2272
- mount = () => props.mount || document.body,
2273
- content = solidJs.createMemo(() => [startMarker, props.children], {
2274
- ssrSource: "client",
2275
- loadingValue: undefined
2276
- });
2277
- solidJs.createRenderEffect(
2278
- () => [mount(), content(), solidJs.getOwner()], ([, c, owner]) => {
2279
- const m = solidJs.untrack(mount);
2280
- m.appendChild(endMarker);
2281
- const dispose = solidJs.runWithOwner(owner, () => solidJs.createRoot(d => {
2282
- insert(m, c, endMarker, undefined, {
2283
- host: () => treeMarker.parentNode
2284
- });
2285
- return d;
2286
- }));
2287
- return () => {
2288
- dispose();
2289
- let c = startMarker;
2290
- while (c) {
2291
- const n = c.nextSibling;
2292
- m.removeChild(c);
2293
- if (c === endMarker) break;
2294
- c = n;
2295
- }
2296
- };
2297
- },
2298
- {
2299
- schedule: true,
2300
- ssrSource: "client"
2301
- });
2302
- solidJs.createEffect(mount, () => {
2303
- const m = solidJs.untrack(mount);
2304
- const ownerRoot = getDelegatedRoot(treeMarker);
2305
- if (!ownerRoot || ownerRoot.contains(m)) return;
2306
- registerDelegatedContainer(m, ownerRoot);
2307
- return () => unregisterDelegatedContainer(m, ownerRoot);
2308
- }, {
2309
- ssrSource: "client"
2310
- });
2311
- if (solidJs.sharedConfig.hydrating) return solidJs.createMemo(() => treeMarker, {
2312
- ssrSource: "client",
2313
- loadingValue: undefined
2314
- });
2315
- return treeMarker;
2316
- }
2317
- const COMPONENT_BINDING = Symbol.for("solid.component-binding");
2318
- function bindingOf(value) {
2319
- return value !== null && (typeof value === "function" || typeof value === "object") && value[COMPONENT_BINDING] || undefined;
2320
- }
2321
- function dynamic(source) {
2322
- let latest = 0;
2323
- const sites = new Set();
2324
- let deliveredAddress;
2325
- const resolveBinding = (next, prev) => {
2326
- const binding = bindingOf(next);
2327
- if (!binding) return next;
2328
- deliveredAddress = binding.address;
2329
- const prevBinding = bindingOf(prev);
2330
- if (prevBinding && prevBinding.component === binding.component) {
2331
- for (const deliver of sites) deliver(binding.address);
2332
- return prev;
2333
- }
2334
- return next;
2335
- };
2336
- const cached = solidJs.createMemo(prev => {
2337
- const next = source();
2338
- if (!next || typeof next.then !== "function") return resolveBinding(next, prev);
2339
- const token = ++latest;
2340
- return {
2341
- then: (onFulfilled, onRejected) => next.then(resolved => onFulfilled(token === latest ? resolveBinding(resolved, prev) : resolved), onRejected)
2342
- };
2343
- }, {
2344
- lazy: true
2345
- });
2346
- return props => {
2347
- return solidJs.createMemo(() => {
2348
- const component = cached();
2349
- switch (typeof component) {
2350
- case "function":
2351
- {
2352
- Object.assign(component, {
2353
- [solidJs.$DEVCOMP]: true
2354
- });
2355
- const binding = bindingOf(component);
2356
- if (binding) {
2357
- const [address, setAddress] = solidJs.createSignal(deliveredAddress ?? binding.address);
2358
- sites.add(setAddress);
2359
- solidJs.onCleanup(() => sites.delete(setAddress));
2360
- return solidJs.untrack(() => binding.component(props, address));
2361
- }
2362
- return solidJs.untrack(() => component(props));
2363
- }
2364
- case "string":
2365
- {
2366
- if (solidJs.sharedConfig.hydrating) {
2367
- const el = getNextElement();
2368
- spread(el, props);
2369
- return el;
2370
- }
2371
- const owner = solidJs.getOwner();
2372
- let el;
2373
- return () => {
2374
- if (!el) {
2375
- solidJs.runWithOwner(owner, () => {
2376
- el = createElement(component, solidJs.untrack(() => props.is));
2377
- spread(el, props);
2378
- });
2379
- }
2380
- return el;
2381
- };
2382
- }
2383
- }
2384
- });
2385
- };
2386
- }
2387
- function Dynamic(props) {
2388
- const Comp = dynamic(() => props.component);
2389
- return solidJs.createComponent(Comp, solidJs.omit(props, "component"));
2390
- }
2391
- const AmbiguousSVGElements = /*#__PURE__*/new Set(["a", "script", "style", "title"]);
2392
- function createElement(tagName, is = undefined) {
2393
- if (SVGElements.has(tagName)) return document.createElementNS(Namespaces.svg, tagName);
2394
- if (MathMLElements.has(tagName)) return document.createElementNS(Namespaces.mathml, tagName);
2395
- if (AmbiguousSVGElements.has(tagName)) {
2396
- const parent = getInsertionParent();
2397
- if (parent && parent.namespaceURI === Namespaces.svg && parent.localName !== "foreignObject") return document.createElementNS(Namespaces.svg, tagName);
2398
- }
2399
- return document.createElement(tagName, {
2400
- is
2401
- });
2402
- }
2403
- function loadClientOnly(fn, setComp, exportName) {
2404
- fn().then(m => setComp(() => exportName ? m[exportName] : m.default));
2405
- }
2406
- function clientOnly(fn, options = {},
2407
- _moduleUrl) {
2408
- const [comp, setComp] = solidJs.createSignal();
2409
- let started = !options.lazy;
2410
- started && loadClientOnly(fn, setComp, options.export);
2411
- return props => {
2412
- let Comp;
2413
- let m;
2414
- const rest = solidJs.omit(props, "fallback");
2415
- if (!started) {
2416
- started = true;
2417
- loadClientOnly(fn, setComp, options.export);
2418
- }
2419
- if ((Comp = solidJs.untrack(comp)) && !solidJs.sharedConfig.hydrating) return Comp(rest);
2420
- const [mounted, setMounted] = solidJs.createSignal(!solidJs.sharedConfig.hydrating);
2421
- const gate = solidJs.createMemo(() => (Comp = comp(), m = mounted(), solidJs.untrack(() => Comp && m ? Comp(rest) : props.fallback)));
2422
- const onHydrationEnd = solidJs.sharedConfig.onHydrationEnd;
2423
- const release = () => setMounted(true);
2424
- onHydrationEnd ? onHydrationEnd(release) : queueMicrotask(release);
2425
- return gate;
2426
- };
2427
- }
2428
- function httpStatus(_code, _text) {}
2429
- function httpHeader(_name, _value, _options) {}
2430
-
2431
- Object.defineProperty(exports, "Errored", {
2432
- enumerable: true,
2433
- get: function () { return solidJs.Errored; }
2434
- });
2435
- Object.defineProperty(exports, "For", {
2436
- enumerable: true,
2437
- get: function () { return solidJs.For; }
2438
- });
2439
- Object.defineProperty(exports, "Hydration", {
2440
- enumerable: true,
2441
- get: function () { return solidJs.Hydration; }
2442
- });
2443
- Object.defineProperty(exports, "Loading", {
2444
- enumerable: true,
2445
- get: function () { return solidJs.Loading; }
2446
- });
2447
- Object.defineProperty(exports, "Match", {
2448
- enumerable: true,
2449
- get: function () { return solidJs.Match; }
2450
- });
2451
- Object.defineProperty(exports, "NoHydration", {
2452
- enumerable: true,
2453
- get: function () { return solidJs.NoHydration; }
2454
- });
2455
- Object.defineProperty(exports, "Repeat", {
2456
- enumerable: true,
2457
- get: function () { return solidJs.Repeat; }
2458
- });
2459
- Object.defineProperty(exports, "Reveal", {
2460
- enumerable: true,
2461
- get: function () { return solidJs.Reveal; }
2462
- });
2463
- Object.defineProperty(exports, "Show", {
2464
- enumerable: true,
2465
- get: function () { return solidJs.Show; }
2466
- });
2467
- Object.defineProperty(exports, "Switch", {
2468
- enumerable: true,
2469
- get: function () { return solidJs.Switch; }
2470
- });
2471
- Object.defineProperty(exports, "createComponent", {
2472
- enumerable: true,
2473
- get: function () { return solidJs.createComponent; }
2474
- });
2475
- Object.defineProperty(exports, "getOwner", {
2476
- enumerable: true,
2477
- get: function () { return solidJs.getOwner; }
2478
- });
2479
- Object.defineProperty(exports, "mergeProps", {
2480
- enumerable: true,
2481
- get: function () { return solidJs.merge; }
2482
- });
2483
- Object.defineProperty(exports, "untrack", {
2484
- enumerable: true,
2485
- get: function () { return solidJs.untrack; }
2486
- });
2487
- exports.ChildProperties = ChildProperties;
2488
- exports.DOMElements = DOMElements;
2489
- exports.DOMWithState = DOMWithState;
2490
- exports.DelegatedEvents = DelegatedEvents;
2491
- exports.Dynamic = Dynamic;
2492
- exports.HREF = HREF;
2493
- exports.HydrationScript = HydrationScript;
2494
- exports.MathMLElements = MathMLElements;
2495
- exports.NULL_BODY_STATUSES = NULL_BODY_STATUSES;
2496
- exports.Namespaces = Namespaces;
2497
- exports.Portal = Portal;
2498
- exports.RESPONSE_HEADER_VALUE_LIMIT = RESPONSE_HEADER_VALUE_LIMIT;
2499
- exports.REVALIDATE_HEADER = REVALIDATE_HEADER;
2500
- exports.RawTextElements = RawTextElements;
2501
- exports.RequestContext = RequestContext;
2502
- exports.ResponseEnvelope = ResponseEnvelope;
2503
- exports.SAFE_ERROR = SAFE_ERROR;
2504
- exports.SVGElements = SVGElements;
2505
- exports.VoidElements = VoidElements;
2506
- exports.acquireAsset = acquireAsset;
2507
- exports.addEvent = addEvent;
2508
- exports.applyRef = applyRef;
2509
- exports.assign = assign;
2510
- exports.claimElement = claimElement;
2511
- exports.claimElementTree = claimElementTree;
2512
- exports.className = className;
2513
- exports.clearFlashCookie = clearFlashCookie;
2514
- exports.clientOnly = clientOnly;
2515
- exports.commitEventResponse = commitEventResponse;
2516
- exports.composeMiddleware = composeMiddleware;
2517
- exports.createRequestEvent = createRequestEvent;
2518
- exports.createResponseStub = createResponseStub;
2519
- exports.createSSRResponse = createSSRResponse;
2520
- exports.delegateEvents = delegateEvents;
2521
- exports.driveList = driveList;
2522
- exports.dynamic = dynamic;
2523
- exports.dynamicProperty = dynamicProperty;
2524
- exports.effect = effect;
2525
- exports.escape = escape;
2526
- exports.generateHydrationScript = generateHydrationScript;
2527
- exports.getDelegatedRoot = getDelegatedRoot;
2528
- exports.getExpectedRedirectStatus = getExpectedRedirectStatus;
2529
- exports.getFirstChild = getFirstChild;
2530
- exports.getHydrationKey = getHydrationKey;
2531
- exports.getInsertionParent = getInsertionParent;
2532
- exports.getNextElement = getNextElement;
2533
- exports.getNextMarker = getNextMarker;
2534
- exports.getNextMatch = getNextMatch;
2535
- exports.getNextSibling = getNextSibling;
2536
- exports.getRequestEvent = getRequestEvent;
2537
- exports.getServerFunctionMetadata = getServerFunctionMetadata;
2538
- exports.getServerFunctionRPC = getServerFunctionRPC;
2539
- exports.hasFlashCookie = hasFlashCookie;
2540
- exports.httpHeader = httpHeader;
2541
- exports.httpStatus = httpStatus;
2542
- exports.hydrate = hydrate;
2543
- exports.insert = insert;
2544
- exports.installHydrationRuntime = installHydrationRuntime;
2545
- exports.installListDriver = installListDriver;
2546
- exports.isDev = isDev;
2547
- exports.isHref = isHref;
2548
- exports.isResponseEnvelope = isResponseEnvelope;
2549
- exports.isSafeError = isSafeError;
2550
- exports.isServer = isServer;
2551
- exports.isServerFunction = isServerFunction;
2552
- exports.markSafeError = markSafeError;
2553
- exports.memo = memo;
2554
- exports.parseCookieHeader = parseCookieHeader;
2555
- exports.patchDriver = patchDriver;
2556
- exports.redirect = redirect;
2557
- exports.ref = ref;
2558
- exports.registerDelegatedContainer = registerDelegatedContainer;
2559
- exports.registerDelegatedRoot = registerDelegatedRoot;
2560
- exports.registerElementClaim = registerElementClaim;
2561
- exports.reload = reload;
2562
- exports.render = render;
2563
- exports.renderToStream = renderToStream;
2564
- exports.renderToString = renderToString;
2565
- exports.resolveSSRNode = resolveSSRNode;
2566
- exports.respond = respond;
2567
- exports.rowProof = rowProof;
2568
- exports.runHydrationEvents = runHydrationEvents;
2569
- exports.scope = scope;
2570
- exports.serializeCookie = serializeCookie;
2571
- exports.setAttribute = setAttribute;
2572
- exports.setAttributeNS = setAttributeNS;
2573
- exports.setProperty = setProperty;
2574
- exports.setStyleProperty = setStyleProperty;
2575
- exports.spread = spread;
2576
- exports.ssr = ssr;
2577
- exports.ssrAttribute = ssrAttribute;
2578
- exports.ssrClassName = ssrClassName;
2579
- exports.ssrElement = ssrElement;
2580
- exports.ssrGroup = ssrGroup;
2581
- exports.ssrHydrationKey = ssrHydrationKey;
2582
- exports.ssrStyle = ssrStyle;
2583
- exports.ssrStyleProperty = ssrStyleProperty;
2584
- exports.style = style;
2585
- exports.template = template;
2586
- exports.unregisterDelegatedContainer = unregisterDelegatedContainer;
2587
- exports.unregisterDelegatedRoot = unregisterDelegatedRoot;
2588
- exports.useHead = useHead;
2589
- exports.waitAsset = waitAsset;
2590
- exports.warmAsset = warmAsset;