@solidjs/web 2.0.0-rc.2 → 2.0.0-rc.20

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 (124) hide show
  1. package/README.md +1 -1
  2. package/dist/server.dev.js +5065 -0
  3. package/dist/server.js +1757 -355
  4. package/dist/{server.cjs → server.observe.js} +1951 -558
  5. package/dist/{dev.cjs → web.dev.js} +945 -550
  6. package/dist/web.js +635 -332
  7. package/dist/{dev.js → web.observe.js} +688 -403
  8. package/frames/dist/assets.js +92 -0
  9. package/frames/dist/client.dev.js +1296 -1198
  10. package/frames/dist/client.js +1128 -1191
  11. package/frames/dist/client.observe.js +2041 -0
  12. package/frames/dist/regions.js +171 -0
  13. package/frames/dist/server.dev.js +2549 -0
  14. package/frames/dist/server.js +1688 -3005
  15. package/frames/dist/server.observe.js +2548 -0
  16. package/frames/dist/trace.js +45 -0
  17. package/frames/dist/wire.js +594 -0
  18. package/frames/package.json +2 -25
  19. package/package.json +244 -256
  20. package/performance-tracks/dist/performance-tracks.dev.js +679 -0
  21. package/performance-tracks/dist/performance-tracks.js +6 -0
  22. package/performance-tracks/dist/performance-tracks.observe.js +667 -0
  23. package/performance-tracks/package.json +7 -0
  24. package/performance-tracks/types/index.d.ts +69 -0
  25. package/serialization/decode/package.json +2 -15
  26. package/serialization/dist/decode.js +121 -25
  27. package/serialization/dist/serialization.js +242 -88
  28. package/serialization/package.json +2 -15
  29. package/serialization/types/index.d.ts +85 -158
  30. package/serialization/types/serializer-decode.d.ts +173 -114
  31. package/serialization/types/serializer.d.ts +109 -0
  32. package/server-functions/dist/client.dev.js +1462 -0
  33. package/server-functions/dist/client.js +667 -165
  34. package/server-functions/dist/client.observe.js +1441 -0
  35. package/server-functions/dist/rich-args.js +84 -1
  36. package/server-functions/dist/server.dev.js +2714 -297
  37. package/server-functions/dist/server.js +2595 -271
  38. package/server-functions/dist/server.observe.js +3594 -0
  39. package/server-functions/package.json +2 -35
  40. package/server-functions/rich-args/package.json +2 -15
  41. package/skills/server-components/SKILL.md +117 -0
  42. package/storage/package.json +2 -15
  43. package/types/client.d.ts +342 -288
  44. package/types/constants.d.ts +22 -0
  45. package/types/cookies.d.ts +32 -84
  46. package/types/diagnostics.d.ts +80 -0
  47. package/types/frames/assets-tier.d.ts +78 -0
  48. package/types/frames/client.d.ts +40 -1
  49. package/types/frames/frame-client.d.ts +443 -280
  50. package/types/frames/frame-container-plugin.d.ts +64 -0
  51. package/types/frames/frame-morph.d.ts +29 -0
  52. package/types/frames/frame-sink.d.ts +141 -161
  53. package/types/frames/frame-transport.d.ts +263 -184
  54. package/types/frames/regions-tier.d.ts +60 -0
  55. package/types/frames/serializer-decode.d.ts +241 -0
  56. package/types/frames/serializer.d.ts +85 -158
  57. package/types/frames/server.d.ts +2 -2
  58. package/types/frames/trace-tier.d.ts +2 -0
  59. package/types/frames/tree-rewrite.d.ts +39 -0
  60. package/types/frames/wire-tier.d.ts +169 -0
  61. package/types/head.d.ts +20 -0
  62. package/types/index.d.ts +98 -81
  63. package/types/index.server.d.ts +159 -0
  64. package/types/jsx.d.ts +49 -44
  65. package/types/observe.d.ts +535 -0
  66. package/types/reconcile.d.ts +1 -0
  67. package/types/render.d.ts +11 -0
  68. package/types/request-error-hook.d.ts +5 -0
  69. package/types/response.d.ts +95 -147
  70. package/types/serializer-decode.d.ts +173 -114
  71. package/types/serializer.d.ts +85 -158
  72. package/types/server-functions/argument-codec.d.ts +30 -0
  73. package/types/server-functions/client.d.ts +238 -223
  74. package/types/server-functions/flash.d.ts +28 -30
  75. package/types/server-functions/registry.d.ts +105 -0
  76. package/types/server-functions/rich-args.d.ts +1 -10
  77. package/types/server-functions/server.d.ts +539 -531
  78. package/types/server-functions/shared.d.ts +398 -425
  79. package/types/server-functions/uploads.d.ts +50 -0
  80. package/types/server-mock.d.ts +120 -13
  81. package/types/server-observe.d.ts +86 -0
  82. package/types/server.d.ts +571 -422
  83. package/types/trace.d.ts +127 -0
  84. package/LICENSE +0 -21
  85. package/dist/web.cjs +0 -2033
  86. package/frames/dist/client.cjs +0 -2002
  87. package/frames/dist/client.dev.cjs +0 -2022
  88. package/frames/dist/server.cjs +0 -3877
  89. package/serialization/dist/decode.cjs +0 -139
  90. package/serialization/dist/serialization.cjs +0 -261
  91. package/serialization/types-cjs/index.d.cts +0 -182
  92. package/serialization/types-cjs/package.json +0 -3
  93. package/serialization/types-cjs/serializer-decode.d.cts +0 -182
  94. package/server-functions/dist/client.cjs +0 -834
  95. package/server-functions/dist/rich-args.cjs +0 -11
  96. package/server-functions/dist/server.cjs +0 -1242
  97. package/server-functions/dist/server.dev.cjs +0 -1242
  98. package/storage/dist/storage.cjs +0 -12
  99. package/storage/types-cjs/index.d.cts +0 -28
  100. package/storage/types-cjs/package.json +0 -3
  101. package/types/core.d.ts +0 -9
  102. package/types-cjs/client.d.cts +0 -337
  103. package/types-cjs/cookies.d.cts +0 -93
  104. package/types-cjs/core.d.cts +0 -9
  105. package/types-cjs/frames/client.d.cts +0 -36
  106. package/types-cjs/frames/frame-client.d.cts +0 -356
  107. package/types-cjs/frames/frame-sink.d.cts +0 -194
  108. package/types-cjs/frames/frame-transport.d.cts +0 -222
  109. package/types-cjs/frames/serializer.d.cts +0 -182
  110. package/types-cjs/frames/server.d.cts +0 -52
  111. package/types-cjs/index.d.cts +0 -244
  112. package/types-cjs/jsx-properties.d.cts +0 -93
  113. package/types-cjs/jsx.d.cts +0 -4159
  114. package/types-cjs/package.json +0 -3
  115. package/types-cjs/response.d.cts +0 -174
  116. package/types-cjs/serializer-decode.d.cts +0 -182
  117. package/types-cjs/serializer.d.cts +0 -182
  118. package/types-cjs/server-functions/client.d.cts +0 -262
  119. package/types-cjs/server-functions/flash.d.cts +0 -38
  120. package/types-cjs/server-functions/rich-args.d.cts +0 -10
  121. package/types-cjs/server-functions/server.d.cts +0 -681
  122. package/types-cjs/server-functions/shared.d.cts +0 -523
  123. package/types-cjs/server-mock.d.cts +0 -286
  124. package/types-cjs/server.d.cts +0 -544
package/dist/web.js CHANGED
@@ -1,5 +1,6 @@
1
- import { createRenderEffect, createMemo, runWithOwner, sharedConfig, untrack, flatten, createRoot, merge, createComponent, omit, createOwner, createSignal, onCleanup, enableHydration, flush, getOwner, createEffect } from 'solid-js';
2
- export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, getOwner, untrack } from 'solid-js';
1
+ import { createRenderEffect, createMemo, enableHydration, $PROXY, untrack, runWithOwner, createRoot, getOwner, ROOT_ERROR_HOOK, flatten, flush, createComponent, omit, createOwner, createSignal, createEffect } from 'solid-js';
2
+ export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, dynamicComponent, getOwner, merge as mergeProps, untrack } from 'solid-js';
3
+ import { sharedConfig, enableServerComponentHydration, resolvedTable, viewOf, OmitView, hasStaticKeys, SOURCE_MEMO, sourceHas, SOURCE_OMIT, sourceGet, sourceKeys, SOURCE_PROXY, SOURCE_PLAIN, dynamicCore } from 'solid-js/internal';
3
4
 
4
5
  const DOMWithState = {
5
6
  INPUT: {
@@ -48,6 +49,7 @@ const Namespaces = {
48
49
  const VoidElements = /*#__PURE__*/new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"]);
49
50
  const RawTextElements = /*#__PURE__*/new Set(["style", "script", "noscript", "template", "textarea", "title"]);
50
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"]);
51
53
 
52
54
  const transparentOptions = {
53
55
  transparent: true,
@@ -56,90 +58,76 @@ const transparentOptions = {
56
58
  const syncOptions = {
57
59
  sync: true
58
60
  };
59
- const effect = (fn, effectFn, options) => createRenderEffect(fn, effectFn, options ? {
60
- sync: true,
61
- ...options,
62
- transparent: !options.scope
63
- } : transparentOptions);
64
- const memo = fn => createMemo(() => fn(), syncOptions);
65
- const assetGates = new WeakMap();
66
- const waitAsset = promise => {
67
- let gate = assetGates.get(promise);
68
- if (!gate) {
69
- runWithOwner(null, () => {
70
- gate = createMemo(() => promise);
71
- });
72
- assetGates.set(promise, gate);
73
- }
74
- gate();
75
- };
61
+ function effect(fn, effectFn, options) {
62
+ const nodeOptions = options ? {
63
+ sync: true,
64
+ ...options,
65
+ transparent: !options.scope
66
+ } : transparentOptions;
67
+ createRenderEffect(fn, effectFn, nodeOptions);
68
+ }
69
+ function memo(fn) {
70
+ return createMemo(() => fn(), syncOptions);
71
+ }
76
72
 
77
73
  function reconcileArrays(parentNode, a, b, marker) {
74
+ let active = parentNode.moveBefore && parentNode.isConnected && document.activeElement;
75
+ if (active === document.body) active = null;
76
+ const slot = marker || parentNode;
77
+ const insert = (n, ref) => {
78
+ active && n.isConnected && n.contains(active) ? parentNode.moveBefore(n, ref) : parentNode.insertBefore(n, ref);
79
+ if (marker || n[$$SLOT]) n[$$SLOT] = slot;
80
+ };
81
+ if (!a.length) {
82
+ for (const n of b) insert(n, marker);
83
+ return;
84
+ }
85
+ const isLive = n => {
86
+ if (!n) return false;
87
+ const tag = n[$$SLOT];
88
+ return n.parentNode === parentNode && (!tag || tag === slot);
89
+ };
78
90
  let bLength = b.length,
79
91
  aEnd = a.length,
80
92
  bEnd = bLength,
81
93
  aStart = 0,
82
94
  bStart = 0,
83
95
  tail = a[aEnd - 1],
84
- tailTag = tail[$$SLOT],
85
- after = tail.parentNode === parentNode && (!tailTag || tailTag === marker) ? tail.nextSibling : marker || null,
96
+ after = isLive(tail) ? tail.nextSibling : marker || null,
86
97
  map = null,
87
98
  anchor,
88
99
  anchorTag;
89
- const isLive = n => {
90
- if (!n) return false;
91
- const tag = n[$$SLOT];
92
- return n.parentNode === parentNode && (!tag || tag === marker);
93
- };
94
100
  while (aStart < aEnd || bStart < bEnd) {
95
- if (a[aStart] === b[bStart] && isLive(a[aStart])) {
101
+ if (a[aStart] === b[bStart]) {
96
102
  aStart++;
97
103
  bStart++;
98
104
  continue;
99
105
  }
100
- while (a[aEnd - 1] === b[bEnd - 1] && isLive(a[aEnd - 1])) {
106
+ while (aEnd > aStart && bEnd > bStart && a[aEnd - 1] === b[bEnd - 1]) {
101
107
  aEnd--;
102
108
  bEnd--;
103
109
  }
104
110
  if (aEnd === aStart) {
105
- let node;
106
- if (bEnd < bLength) {
107
- if (bStart) {
108
- const prev = b[bStart - 1];
109
- const prevTag = prev[$$SLOT];
110
- node = prev.parentNode === parentNode && (!prevTag || prevTag === marker) ? prev.nextSibling : after;
111
- } else node = b[bEnd - bStart];
112
- } else node = after;
113
- while (bStart < bEnd) {
114
- const n = b[bStart++];
115
- parentNode.insertBefore(n, node);
116
- if (marker) n[$$SLOT] = marker;
117
- }
111
+ let k = bEnd;
112
+ while (k < bLength && !isLive(b[k])) k++;
113
+ const node = k < bLength ? b[k] : after;
114
+ while (bStart < bEnd) insert(b[bStart++], node);
118
115
  } else if (bEnd === bStart) {
119
116
  while (aStart < aEnd) {
120
117
  const n = a[aStart++];
121
- if (!map || !map.has(n)) {
122
- const tag = n[$$SLOT];
123
- if (n.parentNode === parentNode && (!tag || tag === marker)) n.remove();
124
- }
125
- }
126
- } else if ((anchor = a[aStart]) === b[bEnd - 1] && b[bStart] === a[aEnd - 1] && anchor.parentNode === parentNode && (!(anchorTag = anchor[$$SLOT]) || anchorTag === marker)) {
127
- if (marker) {
128
- do {
129
- const n = a[--aEnd];
130
- parentNode.insertBefore(n, anchor);
131
- n[$$SLOT] = marker;
132
- bStart++;
133
- if (aStart >= aEnd - 1 || bStart >= bEnd) break;
134
- } while (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]);
135
- } else {
136
- do {
137
- parentNode.insertBefore(a[--aEnd], anchor);
138
- bStart++;
139
- if (aStart >= aEnd - 1 || bStart >= bEnd) break;
140
- } while (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]);
118
+ if ((!map || !map.has(n)) && isLive(n)) n.remove();
141
119
  }
120
+ } else if ((anchor = a[aStart]) === b[bEnd - 1] && b[bStart] === a[aEnd - 1] && anchor.parentNode === parentNode && (!(anchorTag = anchor[$$SLOT]) || anchorTag === slot)) {
121
+ do {
122
+ insert(a[--aEnd], anchor);
123
+ bStart++;
124
+ if (aStart >= aEnd - 1 || bStart >= bEnd) break;
125
+ } while (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]);
142
126
  } else {
127
+ if (!isLive(a[aStart])) {
128
+ aStart++;
129
+ continue;
130
+ }
143
131
  if (!map) {
144
132
  map = new Map();
145
133
  let i = bStart;
@@ -156,31 +144,16 @@ function reconcileArrays(parentNode, a, b, marker) {
156
144
  sequence++;
157
145
  }
158
146
  if (sequence > index - bStart) {
159
- const head = a[aStart];
160
- const headTag = head[$$SLOT];
161
- const node = head.parentNode === parentNode && (!headTag || headTag === marker) ? head : after;
162
- while (bStart < index) {
163
- const n = b[bStart++];
164
- parentNode.insertBefore(n, node);
165
- if (marker) n[$$SLOT] = marker;
166
- }
147
+ const node = a[aStart];
148
+ while (bStart < index) insert(b[bStart++], node);
167
149
  } else {
168
- const oldNode = a[aStart++];
169
- const newNode = b[bStart++];
170
- const oldTag = oldNode[$$SLOT];
171
- if (oldNode.parentNode === parentNode && (!oldTag || oldTag === marker)) {
172
- parentNode.replaceChild(newNode, oldNode);
173
- } else {
174
- parentNode.insertBefore(newNode, after);
175
- }
176
- if (marker) newNode[$$SLOT] = marker;
150
+ const newNode = b[bStart++],
151
+ node = a[aStart++];
152
+ active && parentNode.contains(active) ? insert(newNode, node) : parentNode.replaceChild(newNode, node);
153
+ if (marker || newNode[$$SLOT]) newNode[$$SLOT] = slot;
177
154
  }
178
155
  } else aStart++;
179
- } else {
180
- const n = a[aStart++];
181
- const nTag = n[$$SLOT];
182
- if (n.parentNode === parentNode && (!nTag || nTag === marker)) n.remove();
183
- }
156
+ } else a[aStart++].remove();
184
157
  }
185
158
  }
186
159
  }
@@ -217,11 +190,28 @@ function classifyHeadTag(desc) {
217
190
  resource: false
218
191
  };
219
192
  }
193
+ function qualifierValue(name, value) {
194
+ if (value == null || value === false) return null;
195
+ if (name === "imagesrcset" || name === "imagesizes") return typeof value === "string" && value !== "" ? value : null;
196
+ const v = value === true ? "" : String(value);
197
+ if (name === "as") return asciiLowerCase(v);
198
+ if (name !== "crossorigin") return v;
199
+ return v.length === 15 && v.toLowerCase() === "use-credentials" ? v.toLowerCase() : "anonymous";
200
+ }
201
+ function asciiLowerCase(value) {
202
+ return value.replace(/[A-Z]/g, c => String.fromCharCode(c.charCodeAt(0) + 32));
203
+ }
204
+ const JSON_SCRIPT_TYPE = /^(?:importmap|speculationrules)$|^[\t\n\r ]*(?:application\/json|text\/json|[\w!#$%&'*+.^`|~-]+\/[\w!#$%&'*+.^`|~-]*\+json)[\t\n\r ]*(?:;|$)/i;
205
+ function headBodyText(tag, props, text) {
206
+ return tag === "script" && JSON_SCRIPT_TYPE.test(String(props.type)) ? text.replace(/</g, "\\u003C") : text;
207
+ }
220
208
  function resourceIdentity(tag, props) {
221
- let id = "res:" + tag + ":" + (props.rel || "") + ":" + (props.href || props.src || "");
209
+ const url = String(props.href || props.src || "");
210
+ let id = "res:" + tag + ":" + (props.rel || "") + ":" + url.length + ":" + url;
222
211
  for (let i = 0; i < RESOURCE_QUALIFIERS.length; i++) {
223
212
  const q = RESOURCE_QUALIFIERS[i];
224
- if (props[q] != null) id += ":" + q + "=" + props[q];
213
+ const value = qualifierValue(q, props[q]);
214
+ if (value !== null) id += ":" + q + "=" + value.length + ":" + value;
225
215
  }
226
216
  return id;
227
217
  }
@@ -300,6 +290,7 @@ function serializeCookie(name, value, options = {}) {
300
290
  if (options.expires) cookie += `; Expires=${options.expires.toUTCString()}`;
301
291
  if (options.httpOnly) cookie += "; HttpOnly";
302
292
  if (options.secure) cookie += "; Secure";
293
+ if (options.partitioned) cookie += "; Partitioned";
303
294
  if (options.sameSite) {
304
295
  const sameSite = options.sameSite.toLowerCase();
305
296
  cookie += `; SameSite=${sameSite === "none" ? "None" : sameSite === "strict" ? "Strict" : "Lax"}`;
@@ -307,7 +298,7 @@ function serializeCookie(name, value, options = {}) {
307
298
  return cookie;
308
299
  }
309
300
  const FLASH_COOKIE = "flash";
310
- const FLASH_MATCHER = new RegExp(`(?:^|;\\s*)${FLASH_COOKIE}=([^;]+)`);
301
+ const FLASH_MATCHER = /(?:^|;\s*)flash=([^;]+)/;
311
302
  function hasFlashCookie(cookieHeader) {
312
303
  return !!cookieHeader && FLASH_MATCHER.test(cookieHeader);
313
304
  }
@@ -328,30 +319,96 @@ function getServerFunctionRPC() {
328
319
  return globalThis[SERVER_FUNCTION_RPC];
329
320
  }
330
321
 
331
- const $$EVENT_OWNER = "_$DX_EVENT_OWNER";
322
+ const assetGates = new WeakMap();
323
+ const waitAsset = promise => {
324
+ let gate = assetGates.get(promise);
325
+ if (!gate) {
326
+ runWithOwner(null, () => {
327
+ gate = createMemo(() => promise, {
328
+ transparent: true
329
+ });
330
+ });
331
+ assetGates.set(promise, gate);
332
+ }
333
+ gate();
334
+ };
335
+ const EVENT_KEY = "_$$";
336
+ const $$EVENT_OWNER = "_$SOLID_EVENT_OWNER";
337
+ const $$EVENT_TUPLE = Symbol();
338
+ const hasOwn = Object.prototype.hasOwnProperty;
332
339
  const INNER_OWNED = {};
333
340
  const delegatedEvents = new Set();
334
341
  const delegatedContainers = new Map();
335
- function render$1(code, element, init, options = {}) {
342
+ function voidFn() {}
343
+ function generateHydrationScript(_options) {
344
+ return "";
345
+ }
346
+ function HydrationScript(_props) {
347
+ return null;
348
+ }
349
+ const getRequestEvent = voidFn;
350
+ const getHydrationWriter = voidFn;
351
+ function takeHydrationValue(key) {
352
+ const registry = globalThis._$HY && globalThis._$HY.r;
353
+ if (!registry || !(key in registry)) return;
354
+ const v = registry[key];
355
+ delete registry[key];
356
+ if (v !== null && typeof v === "object" && typeof v.then === "function") {
357
+ if (v.s === 1) return {
358
+ status: "resolved",
359
+ value: v.v
360
+ };
361
+ if (v.s === 2) {
362
+ v.then(undefined, voidFn);
363
+ return {
364
+ status: "rejected",
365
+ error: v.v
366
+ };
367
+ }
368
+ return {
369
+ status: "pending",
370
+ promise: v
371
+ };
372
+ }
373
+ return {
374
+ status: "resolved",
375
+ value: v
376
+ };
377
+ }
378
+ function setLinkClaim(_handler) {
379
+ return false;
380
+ }
381
+ function hasServerLinkState() {
382
+ const registry = globalThis._$HY && globalThis._$HY.r;
383
+ return !!registry && registry.links === 1;
384
+ }
385
+ const getTraceContext = voidFn;
386
+ function render(code, element, init, options = {}) {
336
387
  let disposer;
337
388
  registerDelegatedRoot(element);
338
389
  try {
339
390
  createRoot(dispose => {
340
391
  disposer = dispose;
392
+ if (options.onError) getOwner()[ROOT_ERROR_HOOK] = options.onError;
341
393
  if (element === document) {
342
394
  const tree = code();
343
395
  effect(() => flatten(tree), () => {});
344
396
  } else {
345
397
  const tree = code();
346
- insert(element, () => tree, element.firstChild ? null : undefined, init, options.insertOptions);
398
+ insert(element, () => tree, element.firstChild ? null : undefined, init, {
399
+ ...options.insertOptions,
400
+ schedule: true
401
+ });
347
402
  }
348
403
  }, {
349
404
  id: options.renderId
350
405
  });
406
+ flush();
351
407
  } catch (err) {
352
408
  if (disposer) disposer();
353
409
  unregisterDelegatedRoot(element);
354
410
  throw err;
411
+ } finally {
355
412
  }
356
413
  return () => {
357
414
  disposer();
@@ -413,6 +470,9 @@ function attachDelegatedEvent(name, container, state) {
413
470
  state.handlers.set(name, handler);
414
471
  container.addEventListener(name, handler);
415
472
  }
473
+ function dispatchAsInteraction(e, fn) {
474
+ return fn();
475
+ }
416
476
  function getDelegatedRoot(node) {
417
477
  while (node) {
418
478
  if (delegatedContainers.get(node)?.roots) return node;
@@ -433,17 +493,35 @@ function findOwner(target, state) {
433
493
  }
434
494
  function setProperty(node, name, value) {
435
495
  if (isHydrating(node)) return;
496
+ const nodeName = node.nodeName;
497
+ if (name === "value" && nodeName === "SELECT") writeSelectValue(node, value);else if ((name === "value" || name === "defaultValue") && (nodeName === "INPUT" || nodeName === "TEXTAREA")) {
498
+ if (value == null && /^(checkbox|radio)$/.test(node.type)) node.removeAttribute("value");else node[name] = value ?? "";
499
+ } else node[name] = value;
500
+ reclaimAttribute(node, name);
501
+ }
502
+ function setStatefulProperty(node, name, value) {
436
503
  node[name] = value;
437
504
  }
438
505
  let claimHandlers = null;
439
- const CLAIM_SEAM = Symbol.for("dom-expressions.element-claims");
440
- function registerElementClaim(handler) {
506
+ const claimAttributeSets = [];
507
+ const CLAIM_SEAM = Symbol.for("solid.element-claims");
508
+ function registerElementClaim(handler, options) {
441
509
  (claimHandlers || (claimHandlers = globalThis[CLAIM_SEAM] = [])).push(handler);
510
+ claimAttributeSets.push(options?.attributes || ["href", "action"]);
442
511
  return () => {
443
512
  const index = claimHandlers.indexOf(handler);
444
- index > -1 && claimHandlers.splice(index, 1);
513
+ if (index > -1) {
514
+ claimHandlers.splice(index, 1);
515
+ claimAttributeSets.splice(index, 1);
516
+ }
445
517
  };
446
518
  }
519
+ function runClaimHandlers(handlers, node) {
520
+ for (let i = 0; i < handlers.length; i++) handlers[i](node);
521
+ }
522
+ function reclaimAttribute(node, name) {
523
+ if (claimHandlers !== null && node._$claimed && claimAttributeSets.some(set => set.includes(name.slice(name.indexOf(":") + 1)))) runClaimHandlers(claimHandlers, node);
524
+ }
447
525
  const CLAIMED_ELEMENTS = "a[href], form[action]";
448
526
  function claimElementTree(root) {
449
527
  const handlers = globalThis[CLAIM_SEAM];
@@ -451,46 +529,70 @@ function claimElementTree(root) {
451
529
  const isElement = root.nodeType === 1;
452
530
  if (!isElement && root.nodeType !== 11) return root;
453
531
  if (isElement && root.matches(CLAIMED_ELEMENTS)) {
454
- for (let i = 0; i < handlers.length; i++) handlers[i](root);
532
+ root._$claimed = true;
533
+ runClaimHandlers(handlers, root);
455
534
  }
456
535
  const found = root.querySelectorAll(CLAIMED_ELEMENTS);
457
536
  for (let i = 0; i < found.length; i++) {
458
- for (let j = 0; j < handlers.length; j++) handlers[j](found[i]);
537
+ found[i]._$claimed = true;
538
+ runClaimHandlers(handlers, found[i]);
459
539
  }
460
540
  return root;
461
541
  }
462
- function claimElement(node) {
463
- if (claimHandlers !== null) {
464
- for (let i = 0; i < claimHandlers.length; i++) claimHandlers[i](node);
542
+ function claimElement(node, owner) {
543
+ if (claimHandlers !== null && !node._$claimed) {
544
+ node._$claimed = true;
545
+ if (owner === undefined) runClaimHandlers(claimHandlers, node);else runWithOwner(owner, () => runClaimHandlers(claimHandlers, node));
465
546
  }
466
547
  return node;
467
548
  }
468
549
  function setAttribute(node, name, value) {
469
550
  if (isHydrating(node)) return;
470
- if (value == null || value === false) node.removeAttribute(name);else node.setAttribute(name, value === true ? "" : value);
471
- if (claimHandlers !== null && (name === "href" || name === "action")) claimElement(node);
551
+ const selectMultiple = name === "multiple" && node.localName === "select";
552
+ if (value == null || value === false) node.removeAttribute(name);else {
553
+ node.setAttribute(name, value === true ? "" : value);
554
+ if (selectMultiple && !node._$multiple) {
555
+ const options = node.options;
556
+ for (let i = 0; i < options.length; i++) {
557
+ if (options[i].defaultSelected) options[i].selected = true;
558
+ }
559
+ }
560
+ }
561
+ if (selectMultiple) node._$multiple = true;
562
+ reclaimAttribute(node, name);
472
563
  }
473
564
  function setAttributeNS(node, namespace, name, value) {
474
565
  if (isHydrating(node)) return;
475
566
  if (value == null || value === false) node.removeAttributeNS(namespace, name.indexOf(":") > -1 ? name.split(":").pop() : name);else node.setAttributeNS(namespace, name, value === true ? "" : value);
567
+ reclaimAttribute(node, name);
476
568
  }
477
569
  function className(node, value, prev) {
478
- if (isHydrating(node)) return;
570
+ if (typeof value === "number") value = "" + value;
571
+ if (typeof prev === "number") prev = "" + prev;
572
+ if (isHydrating(node)) {
573
+ node._$classes = value && typeof value === "object" ? classListToObject(value) : undefined;
574
+ return;
575
+ }
479
576
  if (value == null || value === false) {
480
- prev && node.removeAttribute("class");
577
+ if (prev || node._$classes) {
578
+ node.removeAttribute("class");
579
+ node._$classes = undefined;
580
+ }
481
581
  return;
482
582
  }
483
583
  if (typeof value === "string") {
584
+ node._$classes = undefined;
484
585
  value !== prev && node.setAttribute("class", value);
485
586
  return;
486
587
  }
588
+ let applied;
487
589
  if (typeof prev === "string") {
488
- prev = {};
590
+ applied = {};
489
591
  node.removeAttribute("class");
490
- } else prev = classListToObject(prev || {});
592
+ } else applied = node._$classes || classListToObject(prev || {});
491
593
  value = classListToObject(value);
492
- const classKeys = Object.keys(value || {});
493
- const prevKeys = Object.keys(prev);
594
+ const classKeys = Object.keys(value);
595
+ const prevKeys = Object.keys(applied);
494
596
  let i, len;
495
597
  for (i = 0, len = prevKeys.length; i < len; i++) {
496
598
  const key = prevKeys[i];
@@ -500,22 +602,34 @@ function className(node, value, prev) {
500
602
  for (i = 0, len = classKeys.length; i < len; i++) {
501
603
  const key = classKeys[i],
502
604
  classValue = !!value[key];
503
- if (!key || key === "undefined" || prev[key] === classValue || !classValue) continue;
605
+ if (!key || key === "undefined" || applied[key] === classValue || !classValue) continue;
504
606
  node.classList.add(key);
505
607
  }
608
+ node._$classes = value;
506
609
  }
507
610
  function addEvent(node, name, handler, delegate) {
508
611
  if (delegate) {
612
+ const key = EVENT_KEY + name;
613
+ let data;
509
614
  if (Array.isArray(handler)) {
510
- node[`$$${name}`] = handler[0];
511
- node[`$$${name}Data`] = handler[1];
512
- } else node[`$$${name}`] = handler;
513
- } else if (Array.isArray(handler)) {
615
+ data = handler[1];
616
+ node[key] = handler[0];
617
+ } else node[key] = handler;
618
+ node[`${key}Data`] = data;
619
+ return;
620
+ }
621
+ if (Array.isArray(handler)) {
514
622
  const handlerFn = handler[0];
515
- node.addEventListener(name, handler[0] = e => handlerFn.call(node, handler[1], e));
516
- } else node.addEventListener(name, handler, typeof handler !== "function" && handler);
623
+ const listener = e => handlerFn.call(node, handler[1], e);
624
+ listener[$$EVENT_TUPLE] = handler;
625
+ node.addEventListener(name, listener);
626
+ return listener;
627
+ }
628
+ node.addEventListener(name, handler, typeof handler !== "function" && handler);
629
+ return handler;
517
630
  }
518
631
  function style(node, value, prev) {
632
+ if (isHydrating(node)) return;
519
633
  if (!value) {
520
634
  if (prev || node._$styles) {
521
635
  setAttribute(node, "style");
@@ -540,12 +654,13 @@ function style(node, value, prev) {
540
654
  }
541
655
  let v, s;
542
656
  for (s in applied) {
543
- if (value[s] == null) {
657
+ if (!hasOwn.call(value, s) || value[s] == null) {
544
658
  nodeStyle.removeProperty(s);
545
659
  delete applied[s];
546
660
  }
547
661
  }
548
662
  for (s in value) {
663
+ if (!hasOwn.call(value, s)) continue;
549
664
  v = value[s];
550
665
  if (v != null && v !== applied[s]) {
551
666
  nodeStyle.setProperty(s, v);
@@ -553,26 +668,124 @@ function style(node, value, prev) {
553
668
  }
554
669
  }
555
670
  }
671
+ function readShallow(value) {
672
+ if (value === null || typeof value !== "object") return value;
673
+ if (Array.isArray(value)) return value.map(readShallow);
674
+ if (value[$PROXY] !== value) return value;
675
+ const keys = Reflect.ownKeys(value);
676
+ const out = {};
677
+ for (let i = 0; i < keys.length; i++) {
678
+ const k = keys[i];
679
+ if (typeof k === "string") out[k] = value[k];
680
+ }
681
+ return out;
682
+ }
556
683
  function setStyleProperty(node, name, value) {
684
+ if (isHydrating(node)) return;
557
685
  value != null ? node.style.setProperty(name, value) : node.style.removeProperty(name);
558
686
  }
559
- function spread(node, props = {}, skipChildren) {
687
+ function spread(node, props, skipChildren, skip, name, loc) {
560
688
  const prevProps = {};
561
- if (!skipChildren) insert(node, () => props.children);
562
- effect(() => {
563
- const r = props.ref;
564
- (typeof r === "function" || Array.isArray(r)) && ref(() => r, node);
565
- }, () => {});
689
+ const owner = claimHandlers !== null && (node.localName === "a" || node.localName === "form") ? getOwner() : undefined;
690
+ const apply = newProps => {
691
+ const r = newProps.ref;
692
+ if (r !== prevProps.ref && (typeof r === "function" || Array.isArray(r))) ref(() => r, node);
693
+ assign(node, newProps, true, prevProps, true);
694
+ if (owner !== undefined) claimElement(node, owner);
695
+ };
696
+ if (Array.isArray(props)) {
697
+ effect(() => collectSources({}, props, undefined, skip), apply);
698
+ if (!skipChildren && !(skip !== undefined && skip("children"))) insert(node, () => {
699
+ for (let i = props.length - 1; i >= 0; i--) {
700
+ const s = resolveSource(props[i]);
701
+ if (s != null && entryHas(s, "children")) return entryGet(s, "children");
702
+ }
703
+ });
704
+ return prevProps;
705
+ }
566
706
  effect(() => {
707
+ const source = resolveSource(props);
567
708
  const newProps = {};
568
- for (const prop in props) {
569
- if (prop === "children" || prop === "ref") continue;
570
- newProps[prop] = props[prop];
709
+ const table = resolvedTable(source);
710
+ if (table !== undefined) return collectTable(newProps, table, skip);
711
+ if (source != null) {
712
+ const view = viewOf(source);
713
+ if (view instanceof OmitView) collectProps(newProps, view, SOURCE_OMIT, skip);else if (view !== undefined) collectSources(newProps, view.sources, view.kinds, skip);else collectProps(newProps, source, $PROXY in source ? SOURCE_PROXY : SOURCE_PLAIN, skip);
571
714
  }
572
715
  return newProps;
573
- }, props => assign(node, props, true, prevProps, true));
716
+ }, apply);
717
+ if (!skipChildren && !(skip !== undefined && skip("children"))) {
718
+ if (typeof props !== "function" && props != null && hasStaticKeys(props)) {
719
+ const desc = Object.getOwnPropertyDescriptor(props, "children");
720
+ if (desc !== undefined) {
721
+ if (desc.get === undefined) insert(node, desc.value);else insert(node, () => props.children);
722
+ }
723
+ } else insert(node, () => {
724
+ const source = resolveSource(props);
725
+ return source != null && entryHas(source, "children") ? entryGet(source, "children") : undefined;
726
+ });
727
+ }
574
728
  return prevProps;
575
729
  }
730
+ function collectTable(out, table, skip) {
731
+ for (const [prop, leaf] of table) {
732
+ if (typeof prop !== "string" || prop === "children") continue;
733
+ if (skip !== undefined && skip(prop)) continue;
734
+ const v = leaf[prop];
735
+ out[prop] = prop === "style" || prop === "class" ? readShallow(v) : v;
736
+ }
737
+ return out;
738
+ }
739
+ function resolveSource(s) {
740
+ return typeof s === "function" ? s() : s;
741
+ }
742
+ function entryHas(s, key) {
743
+ const view = viewOf(s);
744
+ return view instanceof OmitView ? sourceHas(view, SOURCE_OMIT, key) : key in s;
745
+ }
746
+ function entryGet(s, key) {
747
+ const view = viewOf(s);
748
+ return view instanceof OmitView ? sourceGet(view, SOURCE_OMIT, key) : s[key];
749
+ }
750
+ function collectSources(out, sources, kinds, skip) {
751
+ const resolved = [];
752
+ const resolvedKinds = [];
753
+ for (let i = 0; i < sources.length; i++) pushEntry(resolved, resolvedKinds, sources[i], kinds !== undefined ? kinds[i] : SOURCE_MEMO);
754
+ for (let i = 0; i < resolved.length; i++) collectProps(out, resolved[i], resolvedKinds[i], skip, resolved, resolvedKinds, i + 1);
755
+ return out;
756
+ }
757
+ function pushEntry(resolved, kinds, s, kind) {
758
+ if (kind !== SOURCE_MEMO) {
759
+ resolved.push(s);
760
+ kinds.push(kind);
761
+ return;
762
+ }
763
+ s = resolveSource(s);
764
+ if (s == null) return;
765
+ const view = viewOf(s);
766
+ if (view instanceof OmitView) {
767
+ resolved.push(view);
768
+ kinds.push(SOURCE_OMIT);
769
+ } else if (view !== undefined) {
770
+ const f = view.sources,
771
+ k = view.kinds;
772
+ for (let j = 0; j < f.length; j++) pushEntry(resolved, kinds, f[j], k[j]);
773
+ } else {
774
+ resolved.push(s);
775
+ kinds.push($PROXY in s ? SOURCE_PROXY : SOURCE_PLAIN);
776
+ }
777
+ }
778
+ function collectProps(out, s, kind, skip, later, laterKinds, from) {
779
+ const keys = sourceKeys(s, kind);
780
+ outer: for (let i = 0; i < keys.length; i++) {
781
+ const prop = keys[i];
782
+ if (typeof prop !== "string" || prop === "children") continue;
783
+ if (skip !== undefined && skip(prop)) continue;
784
+ if (later !== undefined) for (let j = from; j < later.length; j++) if (sourceHas(later[j], laterKinds[j], prop)) continue outer;
785
+ const v = sourceGet(s, kind, prop);
786
+ out[prop] = prop === "style" || prop === "class" ? readShallow(v) : v;
787
+ }
788
+ }
576
789
  function dynamicProperty(props, key) {
577
790
  const src = props[key];
578
791
  Object.defineProperty(props, key, {
@@ -590,11 +803,6 @@ function ref(fn, element) {
590
803
  const resolved = untrack(fn);
591
804
  runWithOwner(null, () => applyRef(resolved, element));
592
805
  }
593
- const PURE_ROW = Symbol.for("solid.pure-row");
594
- function rowProof(fn) {
595
- fn[PURE_ROW] = true;
596
- return fn;
597
- }
598
806
  function scope(fn) {
599
807
  fn.$s = true;
600
808
  return fn;
@@ -603,19 +811,19 @@ const SCOPE_OPTIONS = {
603
811
  scope: true
604
812
  };
605
813
  let hydrationRt = null;
814
+ let selectInsert = null;
606
815
  function installHydrationRuntime() {
607
816
  hydrationRt = {
608
817
  claimInitial(parent, multi, initial) {
609
818
  if (isHydrating(parent)) {
610
- if (!multi && initial === undefined && parent) initial = [...parent.childNodes];
611
- if (Array.isArray(initial)) stripTextSeparators(initial);
819
+ if (!multi && initial === undefined && parent) initial = claimChildNodes(parent);else if (Array.isArray(initial)) stripTextSeparators(initial);
612
820
  }
613
821
  return initial;
614
822
  },
615
823
  reclaimRegion(current, parent, marker) {
616
- if (!sharedConfig.hydrating || !current || !parent.isConnected) return current;
824
+ if (!sharedConfig.hydrating || current == null || !parent.isConnected) return current;
617
825
  const first = Array.isArray(current) ? current[0] : current;
618
- if (!first || !first.nodeType || first.isConnected) return current;
826
+ if (first == null || first.isConnected) return current;
619
827
  let nodes;
620
828
  if (marker) {
621
829
  nodes = [];
@@ -632,7 +840,7 @@ function installHydrationRuntime() {
632
840
  nodes.unshift(node);
633
841
  node = node.previousSibling;
634
842
  }
635
- } else nodes = [...parent.childNodes];
843
+ } else return claimChildNodes(parent);
636
844
  return stripTextSeparators(nodes);
637
845
  },
638
846
  dedupEvent(e) {
@@ -645,23 +853,35 @@ function stripTextSeparators(nodes) {
645
853
  for (let i = 0; i < nodes.length; i++) {
646
854
  const node = nodes[i],
647
855
  t = node.nodeType;
648
- if (t === 8) {
649
- const v = node.nodeValue;
650
- if (v === "!$") {
651
- node.remove();
652
- continue;
653
- }
654
- if (v.startsWith("pl-")) continue;
655
- } else if (t === 1 && node.localName === "template" && node.id.startsWith("pl-")) continue;
856
+ if (t === 8 && node.nodeValue === "!$") {
857
+ node.remove();
858
+ continue;
859
+ }
860
+ if (isPlaceholderScaffolding(node, t)) continue;
656
861
  nodes[j++] = node;
657
862
  }
658
863
  nodes.length = j;
659
864
  return nodes;
660
865
  }
661
- function patchDriver(subject, body) {
662
- {
663
- effect(() => body(subject, subject, false), () => body(subject, undefined, true));
866
+ function claimChildNodes(parent) {
867
+ const live = parent.childNodes;
868
+ const out = [];
869
+ for (let i = 0, n = live.length; i < n; i++) {
870
+ const node = live[i],
871
+ t = node.nodeType;
872
+ if (t === 8 && node.nodeValue === "!$") {
873
+ node.remove();
874
+ i--;
875
+ n--;
876
+ continue;
877
+ }
878
+ if (isPlaceholderScaffolding(node, t)) continue;
879
+ out.push(node);
664
880
  }
881
+ return out;
882
+ }
883
+ function isPlaceholderScaffolding(node, t) {
884
+ return t === 8 ? node.nodeValue.startsWith("pl-") : t === 1 && node.localName === "template" && node.id.startsWith("pl-");
665
885
  }
666
886
  function insert(parent, accessor, marker, initial, options) {
667
887
  const multi = marker !== undefined;
@@ -682,17 +902,21 @@ function insert(parent, accessor, marker, initial, options) {
682
902
  initial = [placeholder];
683
903
  }
684
904
  let current = initial;
685
- effect(prev => {
905
+ let ran = false;
906
+ effect(() => {
686
907
  if (hydrationRt !== null) current = hydrationRt.reclaimRegion(current, parent, marker);
687
908
  const value = normalize(accessor(), current, multi, true);
909
+ const again = ran;
910
+ ran = true;
688
911
  if (typeof value !== "function") return value;
912
+ const innerOptions = again && !(options && options.schedule) ? {
913
+ ...options,
914
+ schedule: true
915
+ } : options;
689
916
  effect(() => (hydrationRt !== null && (current = hydrationRt.reclaimRegion(current, parent, marker)), normalize(value, current, multi)), inner => {
690
917
  current = insertExpression(parent, inner, current, marker);
691
918
  host && tagHost(current, host);
692
- }, prev !== undefined && !(options && options.schedule) ? {
693
- ...options,
694
- schedule: true
695
- } : options);
919
+ }, innerOptions);
696
920
  return INNER_OWNED;
697
921
  }, value => {
698
922
  if (value === INNER_OWNED) return;
@@ -727,10 +951,16 @@ function assetEntryKey(descriptor) {
727
951
  if (descriptor.policy === "exclusive") return "x|" + descriptor.key;
728
952
  return descriptor.type === "inline-style" ? "i|" + descriptor.id : descriptor.type + "|" + descriptor.href;
729
953
  }
730
- function findAssetElement(selector, attr, value) {
954
+ function findAssetElement(selector, attr, value, qualifiers) {
731
955
  const nodes = document.querySelectorAll(selector);
732
- for (let i = 0; i < nodes.length; i++) {
733
- if (nodes[i].getAttribute(attr) === value) return nodes[i];
956
+ outer: for (let i = 0; i < nodes.length; i++) {
957
+ if (nodes[i].getAttribute(attr) !== value) continue;
958
+ if (!qualifiers) return nodes[i];
959
+ for (let q = 0; q < RESOURCE_QUALIFIERS.length; q++) {
960
+ const name = RESOURCE_QUALIFIERS[q];
961
+ if (qualifierValue(name, qualifiers[name]) !== qualifierValue(name, nodes[i].getAttribute(name))) continue outer;
962
+ }
963
+ return nodes[i];
734
964
  }
735
965
  return null;
736
966
  }
@@ -995,7 +1225,7 @@ function flushHeadRegistry() {
995
1225
  function createHeadElement(tag, props) {
996
1226
  const el = document.createElement(tag);
997
1227
  for (const name in props) {
998
- if (name === "children" || name === "ref" || name.slice(0, 2) === "on") continue;
1228
+ if (name === "children" || name === "ref" || /^on[A-Z]/.test(name)) continue;
999
1229
  if (!HEAD_ATTR_NAME.test(name)) {
1000
1230
  continue;
1001
1231
  }
@@ -1003,7 +1233,7 @@ function createHeadElement(tag, props) {
1003
1233
  if (v == null || v === false) continue;
1004
1234
  el.setAttribute(name, v === true ? "" : String(v));
1005
1235
  }
1006
- if (props.children != null) el.textContent = String(props.children);
1236
+ if (props.children != null) el.textContent = headBodyText(tag, props, String(props.children));
1007
1237
  return el;
1008
1238
  }
1009
1239
  function renderHeadElement(t, identity, existing) {
@@ -1018,7 +1248,7 @@ function renderHeadElement(t, identity, existing) {
1018
1248
  function headElementMatches(el, t) {
1019
1249
  if (el.tagName.toLowerCase() !== t.tag) return false;
1020
1250
  for (const name in t.props) {
1021
- if (name === "children" || name === "ref" || name.slice(0, 2) === "on") continue;
1251
+ if (name === "children" || name === "ref" || /^on[A-Z]/.test(name)) continue;
1022
1252
  if (!HEAD_ATTR_NAME.test(name)) continue;
1023
1253
  const v = t.props[name];
1024
1254
  if (v == null || v === false) {
@@ -1026,7 +1256,7 @@ function headElementMatches(el, t) {
1026
1256
  } else if (el.getAttribute(name) !== (v === true ? "" : String(v))) return false;
1027
1257
  }
1028
1258
  const children = t.props.children;
1029
- return (children == null ? "" : String(children)) === el.textContent;
1259
+ return (children == null ? "" : headBodyText(t.tag, t.props, String(children))) === el.textContent;
1030
1260
  }
1031
1261
  function mountHeadResource(tag, props) {
1032
1262
  const identity = resourceIdentity(tag, props);
@@ -1034,8 +1264,8 @@ function mountHeadResource(tag, props) {
1034
1264
  headMountedResources.add(identity);
1035
1265
  const url = props.href || props.src;
1036
1266
  let el = null;
1037
- if (url != null) {
1038
- 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);
1267
+ if (tag === "link" && url == null && typeof props.imagesrcset === "string") el = findAssetElement(`link[rel="${props.rel}"]`, "href", null, props);else if (url != null) {
1268
+ if (tag === "link") el = findAssetElement(`link[rel="${props.rel}"]`, "href", url, props);else if (tag === "script") el = findAssetElement("script[src]", "src", url);else el = findAssetElement("style[href]", "href", url);
1039
1269
  }
1040
1270
  if (!el) document.head.appendChild(createHeadElement(tag, props));
1041
1271
  }
@@ -1057,7 +1287,7 @@ function gateHeadResource(props) {
1057
1287
  if (attrs) descriptor.attrs = attrs;
1058
1288
  effect(() => {
1059
1289
  const entry = warmAsset(descriptor);
1060
- if (gateable && entry.loadState === "pending" && typeof waitAsset === "function") waitAsset(entry.loadPromise);
1290
+ if (gateable && !isHydrating() && entry.loadState === "pending" && typeof waitAsset === "function") waitAsset(entry.loadPromise);
1061
1291
  }, () => acquireAsset(descriptor));
1062
1292
  }
1063
1293
  function useHead(tags) {
@@ -1139,9 +1369,34 @@ function loadModuleAssets(mapping) {
1139
1369
  }
1140
1370
  return pending.length ? Promise.all(pending).then(() => {}) : undefined;
1141
1371
  }
1142
- function hydrate$1(code, element, options = {}) {
1372
+ function hydrate(code, element, options = {}) {
1373
+ enableHydration();
1143
1374
  installHydrationRuntime();
1144
- if (globalThis._$HY.done) return render$1(code, element, [...element.childNodes], options);
1375
+ const hy = globalThis._$HY;
1376
+ const id = options.renderId || "";
1377
+ if (hy.s && !hy.s[id] && !hy.s[""] && !hy.done && document.readyState === "loading") {
1378
+ let started, disposer;
1379
+ const start = () => started || (started = true, disposer = hydrate(code, element, options));
1380
+ (hy.sp || (hy.sp = [])).push([id, start]);
1381
+ hy.sw = key => hy.sp.forEach(([k, f]) => (!key || k === key) && queueMicrotask(f));
1382
+ document.addEventListener("DOMContentLoaded", start, {
1383
+ once: true
1384
+ });
1385
+ return () => {
1386
+ started = true;
1387
+ disposer && disposer();
1388
+ };
1389
+ }
1390
+ if (hy.done) return render(code, element, [...element.childNodes], options);
1391
+ const head = (element.nodeType === 9 ? element : element.ownerDocument).head;
1392
+ if (head && element.contains(head)) {
1393
+ let n = head.firstChild;
1394
+ while (n && n.nodeType === 1 && n.hasAttribute("data-dh") && !n.hasAttribute("data-dhf")) {
1395
+ const next = n.nextSibling;
1396
+ head.appendChild(n);
1397
+ n = next;
1398
+ }
1399
+ }
1145
1400
  options.renderId ||= "";
1146
1401
  if (!globalThis._$HY.modules) globalThis._$HY.modules = {};
1147
1402
  if (!globalThis._$HY.loading) globalThis._$HY.loading = {};
@@ -1190,31 +1445,34 @@ function hydrate$1(code, element, options = {}) {
1190
1445
  sharedConfig.gather = gather;
1191
1446
  sharedConfig.hydrating = true;
1192
1447
  try {
1193
- disposer = render$1(code, element, [...element.childNodes], options);
1448
+ disposer = render(code, element, [...element.childNodes], options);
1194
1449
  } finally {
1195
1450
  sharedConfig.hydrating = false;
1196
1451
  }
1197
1452
  }, err => {
1198
- console.error("Hydration module preload failed, falling back to client render:", err);
1199
1453
  sharedConfig.hydrating = false;
1200
1454
  sharedConfig.registry = undefined;
1201
- disposer = render$1(code, element, [...element.childNodes], options);
1455
+ if (element.nodeType === 9) {
1456
+ (globalThis.reportError || console.error)(err);
1457
+ return;
1458
+ }
1459
+ console.error("Hydration module preload failed, falling back to client render:", err);
1460
+ disposer = render(code, element, [...element.childNodes], options);
1202
1461
  });
1203
1462
  return () => disposer && disposer();
1204
1463
  }
1205
1464
  }
1206
1465
  try {
1207
1466
  gatherHydratable(element, options.renderId);
1208
- return render$1(code, element, [...element.childNodes], options);
1467
+ return render(code, element, [...element.childNodes], options);
1209
1468
  } finally {
1210
1469
  sharedConfig.hydrating = false;
1211
1470
  }
1212
1471
  }
1213
1472
  function getNextElement(template) {
1214
- let node,
1215
- key,
1216
- hydrating = isHydrating();
1217
- if (!hydrating || !(node = sharedConfig.registry.get(key = getHydrationKey()))) {
1473
+ let key = sharedConfig.hydrating && getHydrationKey(),
1474
+ node = isHydrating() && sharedConfig.registry.get(key);
1475
+ if (!node) {
1218
1476
  if (!template) {
1219
1477
  throw new Error(`Hydration Mismatch. Unable to find DOM nodes for hydration key: ${key}`);
1220
1478
  }
@@ -1294,6 +1552,7 @@ function runHydrationEvents() {
1294
1552
  matches.sort((a, b) => a.distance - b.distance);
1295
1553
  for (let i = 0; i < matches.length; i++) eventHandler(e, matches[i].container, matches[i].state);
1296
1554
  } else if (matchContainer) eventHandler(e, matchContainer, matchState);
1555
+ flush();
1297
1556
  }
1298
1557
  if (sharedConfig.done) {
1299
1558
  sharedConfig.events = _$HY.events = null;
@@ -1305,14 +1564,34 @@ function runHydrationEvents() {
1305
1564
  }
1306
1565
  function isHydrating(node) {
1307
1566
  if (!sharedConfig.hydrating) return false;
1567
+ if (sharedConfig.isClaiming && !sharedConfig.isClaiming()) return false;
1308
1568
  if (!node || node.isConnected) return true;
1309
- const roots = sharedConfig.claimRoots;
1310
- if (roots) {
1311
- for (let i = 0; i < roots.length; i++) {
1312
- if (roots[i].contains(node)) return true;
1569
+ return serverComponentClaims !== null && serverComponentClaims.claimed(node);
1570
+ }
1571
+ let serverComponentClaims = null;
1572
+ function installServerComponentHydration() {
1573
+ enableServerComponentHydration();
1574
+ if (serverComponentClaims !== null) return;
1575
+ serverComponentClaims = {
1576
+ claimed(node) {
1577
+ const roots = sharedConfig.claimRoots;
1578
+ if (roots) {
1579
+ for (let i = 0; i < roots.length; i++) {
1580
+ if (roots[i].contains(node)) return true;
1581
+ }
1582
+ }
1583
+ return false;
1584
+ },
1585
+ inFrame(element) {
1586
+ const frames = element.querySelectorAll("[data-fid]");
1587
+ const frameCount = frames.length;
1588
+ if (frameCount === 0) return undefined;
1589
+ return node => {
1590
+ for (let j = 0; j < frameCount; j++) if (frames[j].contains(node)) return true;
1591
+ return false;
1592
+ };
1313
1593
  }
1314
- }
1315
- return false;
1594
+ };
1316
1595
  }
1317
1596
  function classListToObject(classList) {
1318
1597
  if (Array.isArray(classList)) {
@@ -1336,7 +1615,8 @@ function classListToObject(classList) {
1336
1615
  function flattenClassList(list, result) {
1337
1616
  for (let i = 0, len = list.length; i < len; i++) {
1338
1617
  const item = list[i];
1339
- if (Array.isArray(item)) flattenClassList(item, result);else if (typeof item === "object" && item != null) Object.assign(result, item);else if (item || item === 0) result[item] = true;
1618
+ if (Array.isArray(item)) flattenClassList(item, result);else if (typeof item === "object" && item != null) Object.assign(result, item);
1619
+ else if (typeof item !== "boolean" && (item || item === 0)) result[item] = true;
1340
1620
  }
1341
1621
  }
1342
1622
  function assignProp(node, prop, value, prev, skipRef, nodeName) {
@@ -1347,22 +1627,26 @@ function assignProp(node, prop, value, prev, skipRef, nodeName) {
1347
1627
  if (!skipRef && value) ref(() => value, node);
1348
1628
  return value;
1349
1629
  }
1630
+ let c;
1350
1631
  const hasNamespace = prop.indexOf(":") > -1;
1351
- if (!hasNamespace && prop.slice(0, 2) === "on") {
1632
+ if (!hasNamespace && prop.startsWith("on") && (c = prop.charCodeAt(2)) > 64 && c < 91) {
1352
1633
  const name = prop.slice(2).toLowerCase();
1353
1634
  const delegate = DelegatedEvents.has(name);
1354
1635
  if (!delegate && prev) {
1355
- const h = Array.isArray(prev) ? prev[0] : prev;
1356
- node.removeEventListener(name, h);
1636
+ if (Array.isArray(value) && typeof prev === "function" && prev[$$EVENT_TUPLE] === value) return prev;
1637
+ node.removeEventListener(name, prev, typeof prev !== "function" && prev);
1357
1638
  }
1358
1639
  if (delegate || value) {
1359
- addEvent(node, name, value, delegate);
1640
+ const attached = addEvent(node, name, value, delegate);
1360
1641
  delegate && delegateEvents([name]);
1642
+ if (!delegate) return attached;
1361
1643
  }
1362
1644
  } else if (hasNamespace && prop.slice(0, 5) === "prop:" || ChildProperties.has(prop) || DOMWithState[nodeName]?.[prop]) {
1363
1645
  if (hasNamespace) prop = prop.slice(5);else if (isHydrating(node)) return value;
1364
- if (prop === "value" && nodeName === "SELECT") queueMicrotask(() => node.value = value) || (node.value = value);else if ((prop === "value" || prop === "defaultValue") && (nodeName === "INPUT" || nodeName === "TEXTAREA"))
1365
- node[prop] = value ?? "";else node[prop] = value;
1646
+ if (prop === "value" && nodeName === "SELECT") writeSelectValue(node, value);else if ((prop === "value" || prop === "defaultValue") && (nodeName === "INPUT" || nodeName === "TEXTAREA")) {
1647
+ if (value == null && /^(checkbox|radio)$/.test(node.type)) node.removeAttribute("value");else node[prop] = value ?? "";
1648
+ } else node[prop] = value;
1649
+ reclaimAttribute(node, prop);
1366
1650
  } else {
1367
1651
  const ns = hasNamespace && Namespaces[prop.split(":")[0]];
1368
1652
  if (ns) setAttributeNS(node, ns, prop, value);else setAttribute(node, prop, value);
@@ -1377,27 +1661,21 @@ function eventHandler(e, container, state) {
1377
1661
  if (prev === true || prev === container || !container.contains(prev)) return;
1378
1662
  resumeNode = prev;
1379
1663
  }
1380
- const owner = state && (state.owners.size === 1 && state.owners.has(container) ? container : findOwner(e.target, state)?.owner);
1381
- if (state && !owner) return;
1382
- if (owner && owner === resumeNode) return;
1383
- e[$$EVENT_OWNER] = owner || true;
1664
+ const owner = state.owners.size === 1 && state.owners.has(container) ? container : findOwner(e.target, state)?.owner;
1665
+ if (!owner) return;
1666
+ if (owner === resumeNode) return;
1667
+ e[$$EVENT_OWNER] = owner;
1384
1668
  let node = resumeNode || e.target;
1385
- const key = `$$${e.type}`;
1386
- const oriTarget = e.target;
1387
- const boundary = owner || container || e.currentTarget;
1669
+ const key = EVENT_KEY + e.type;
1388
1670
  const retarget = value => Object.defineProperty(e, "target", {
1389
1671
  configurable: true,
1390
1672
  value
1391
1673
  });
1392
1674
  const handleNode = () => {
1393
- let handler = node[key];
1394
- if (handler === undefined && node.hasAttribute && node.hasAttribute("_bnd")) {
1395
- const seam = globalThis[Symbol.for("dx.bnd")];
1396
- if (seam) handler = seam.resolve(node, e.type);
1397
- }
1675
+ const handler = node[key];
1398
1676
  if (handler && !node.disabled) {
1399
1677
  const data = node[`${key}Data`];
1400
- data !== undefined ? handler.call(node, data, e) : handler.call(node, e);
1678
+ data !== undefined ? handler.call(node, data, e) : typeof handler === "function" ? handler.call(node, e) : handler.handleEvent(e);
1401
1679
  if (e.cancelBubble) return;
1402
1680
  }
1403
1681
  node.host && typeof node.host !== "string" && !node.host._$host && node.contains(e.target) && retarget(node.host);
@@ -1405,19 +1683,19 @@ function eventHandler(e, container, state) {
1405
1683
  };
1406
1684
  const walkUpTree = () => {
1407
1685
  while (node && handleNode()) {
1408
- if (node === boundary || node.parentNode === boundary) break;
1686
+ if (node === owner || node.parentNode === owner) break;
1409
1687
  node = node._$host || node.parentNode || node.host;
1410
1688
  }
1411
1689
  };
1412
1690
  Object.defineProperty(e, "currentTarget", {
1413
1691
  configurable: true,
1414
1692
  get() {
1415
- return node || boundary || document;
1693
+ return node || owner;
1416
1694
  }
1417
1695
  });
1418
1696
  if (resumeNode) {
1419
1697
  if (resumeNode === e.target) node = resumeNode._$host || resumeNode.parentNode || resumeNode.host;
1420
- if (node && node !== boundary) walkUpTree();
1698
+ if (node && node !== owner) walkUpTree();
1421
1699
  } else if (e.composedPath) {
1422
1700
  const path = e.composedPath();
1423
1701
  if (path.length) {
@@ -1430,21 +1708,35 @@ function eventHandler(e, container, state) {
1430
1708
  walkUpTree();
1431
1709
  break;
1432
1710
  }
1433
- if (node === boundary || node.parentNode === boundary) {
1711
+ if (node === owner || node.parentNode === owner) {
1434
1712
  break;
1435
1713
  }
1436
1714
  }
1437
1715
  } else walkUpTree();
1438
1716
  }
1439
1717
  else walkUpTree();
1440
- retarget(oriTarget);
1718
+ delete e.target;
1719
+ delete e.currentTarget;
1441
1720
  }
1442
1721
  function insertExpression(parent, value, current, marker) {
1443
1722
  if (hydrationRt !== null && isHydrating(parent)) {
1444
- if (value && value !== current) for (const n of Array.isArray(value) ? value : [value]) if (n && n.nodeType && !isHydrating(n)) return current;
1723
+ if (value && value !== current) {
1724
+ const arr = Array.isArray(value);
1725
+ for (const n of arr ? value : [value]) {
1726
+ if (n && n.nodeType) {
1727
+ if (!isHydrating(n)) return current;
1728
+ } else if (arr && (typeof n === "string" || typeof n === "number")) {
1729
+ return current;
1730
+ }
1731
+ }
1732
+ }
1445
1733
  return value;
1446
1734
  }
1447
1735
  if (value === current) return value;
1736
+ if (hydrationRt !== null && sharedConfig.hydrating && value && value.length !== 0) {
1737
+ const tracked = [].concat(current ?? []);
1738
+ if ([].concat(value).every(n => (n === tracked[0] && tracked.shift(), n?.parentNode === parent)) && !tracked.length) return value;
1739
+ }
1448
1740
  const t = typeof value,
1449
1741
  multi = marker !== undefined;
1450
1742
  if (t === "string" || t === "number") {
@@ -1462,29 +1754,65 @@ function insertExpression(parent, value, current, marker) {
1462
1754
  } else if (value.nodeType) {
1463
1755
  if (Array.isArray(current)) {
1464
1756
  cleanChildren(parent, current, multi ? marker : null, value);
1465
- } else if (current && current.nodeType) {
1757
+ } else if (current != null && current.nodeType) {
1466
1758
  current.parentNode === parent ? parent.replaceChild(value, current) : parent.appendChild(value);
1467
- } else if (current && parent.firstChild) {
1759
+ } else if (current != null && parent.firstChild) {
1468
1760
  parent.replaceChild(value, parent.firstChild);
1469
1761
  } else {
1470
1762
  parent.appendChild(value);
1471
1763
  }
1472
- if (marker) value[$$SLOT] = marker;
1764
+ if (marker || value[$$SLOT]) value[$$SLOT] = marker || parent;
1473
1765
  } else if (Array.isArray(value)) {
1474
- const currentArray = current && Array.isArray(current);
1766
+ const currentArray = Array.isArray(current);
1767
+ for (let i = 0, len = value.length; i < len; i++) {
1768
+ const item = value[i],
1769
+ t = typeof item;
1770
+ if (t === "string" || t === "number") {
1771
+ const prev = currentArray ? current[i] : undefined;
1772
+ if (prev && prev.nodeType === 3) {
1773
+ if (prev.data !== "" + item) prev.data = item;
1774
+ value[i] = prev;
1775
+ } else value[i] = document.createTextNode(item);
1776
+ }
1777
+ }
1475
1778
  if (value.length === 0) {
1476
1779
  cleanChildren(parent, current, marker);
1477
1780
  } else if (currentArray) {
1478
- if (current.length === 0) {
1479
- appendNodes(parent, value, marker);
1480
- } else reconcileArrays(parent, current, value, marker);
1781
+ reconcileArrays(parent, current, value, marker);
1481
1782
  } else {
1482
- current && cleanChildren(parent, current);
1483
- appendNodes(parent, value);
1783
+ if (current != null) cleanChildren(parent, current);
1784
+ reconcileArrays(parent, [], value);
1484
1785
  }
1485
1786
  } else ;
1787
+ selectInsert && selectInsert(parent);
1486
1788
  return value;
1487
1789
  }
1790
+ function selectChange(e) {
1791
+ (e = e.currentTarget || e)._$v = null;
1792
+ e.removeEventListener("change", selectChange, true);
1793
+ }
1794
+ function writeSelectValue(node, value) {
1795
+ const had = node._$v && node._$v.map,
1796
+ has = value != null && value.map;
1797
+ if (has) had || node.addEventListener("change", selectChange, true);else had && node.removeEventListener("change", selectChange, true);
1798
+ if (value == null) {
1799
+ node._$v = null;
1800
+ return queueMicrotask(() => node.value = value) || (node.value = value);
1801
+ }
1802
+ node._$v = value;
1803
+ (selectInsert ||= applySelectValue)(node);
1804
+ queueMicrotask(() => selectInsert(node));
1805
+ }
1806
+ function applySelectValue(p) {
1807
+ p && p._$v == null && (p = p.parentNode);
1808
+ const v = p && p._$v;
1809
+ if (v == null) return;
1810
+ if (v.map) {
1811
+ const o = [...p.options];
1812
+ for (let i = 0; i < o.length; i++) o[i].selected = v.some(x => x == o[i].value);
1813
+ v.every(x => o.some(el => el.value == x)) && selectChange(p);
1814
+ } else p.value = v, p.selectedIndex > -1 && p.value == v && (p._$v = null);
1815
+ }
1488
1816
  function normalize(value, current, multi, doNotUnwrap) {
1489
1817
  value = flatten(value, {
1490
1818
  skipNonRendered: true,
@@ -1492,12 +1820,12 @@ function normalize(value, current, multi, doNotUnwrap) {
1492
1820
  });
1493
1821
  if (doNotUnwrap && typeof value === "function") return value;
1494
1822
  if (multi && !Array.isArray(value)) value = [value != null ? value : ""];
1495
- if (Array.isArray(value)) {
1823
+ if (hydrationRt !== null && sharedConfig.hydrating && Array.isArray(value)) {
1496
1824
  for (let i = 0, len = value.length; i < len; i++) {
1497
1825
  const item = value[i],
1498
1826
  prev = current && current[i],
1499
1827
  t = typeof item;
1500
- if (t === "string" || t === "number") value[i] = prev && prev.nodeType === 3 && (sharedConfig.hydrating || prev.data === "" + item) ? prev : document.createTextNode(item);
1828
+ if ((t === "string" || t === "number") && prev && prev.nodeType === 3 && isHydrating(prev)) value[i] = prev;
1501
1829
  }
1502
1830
  }
1503
1831
  return value;
@@ -1513,13 +1841,6 @@ function tagHost(value, host) {
1513
1841
  });
1514
1842
  }
1515
1843
  }
1516
- function appendNodes(parent, array, marker = null) {
1517
- for (let i = 0, len = array.length; i < len; i++) {
1518
- const n = array[i];
1519
- parent.insertBefore(n, marker);
1520
- if (marker) n[$$SLOT] = marker;
1521
- }
1522
- }
1523
1844
  function ownsAllChildren(parent, current) {
1524
1845
  if (current == null) return true;
1525
1846
  if (Array.isArray(current)) {
@@ -1554,33 +1875,31 @@ function cleanChildren(parent, current, marker, replacement) {
1554
1875
  const el = current[i];
1555
1876
  if (replacement !== el) {
1556
1877
  const tag = el[$$SLOT];
1557
- const owns = el.parentNode === parent && (!tag || tag === marker);
1878
+ const owns = el.parentNode === parent && (!tag || tag === (marker || parent));
1558
1879
  if (replacement && !inserted && !i) owns ? parent.replaceChild(replacement, el) : parent.insertBefore(replacement, marker);else if (owns) el.remove();
1559
1880
  } else inserted = true;
1560
1881
  }
1561
1882
  } else if (replacement) parent.insertBefore(replacement, marker);
1562
- if (replacement && marker) replacement[$$SLOT] = marker;
1883
+ if (replacement && (marker || replacement[$$SLOT])) replacement[$$SLOT] = marker || parent;
1563
1884
  }
1564
1885
  function gatherHydratable(element, root) {
1565
- const templates = element.querySelectorAll(`*[_hk]`);
1886
+ const templates = element.querySelectorAll(root ? `[_hk^="${root.replace(/["\\]/g, "\\$&")}"]` : `*[_hk]`);
1887
+ const inFrame = root || serverComponentClaims === null ? undefined : serverComponentClaims.inFrame(element);
1888
+ const registry = sharedConfig.registry;
1566
1889
  for (let i = 0; i < templates.length; i++) {
1567
1890
  const node = templates[i];
1891
+ if (inFrame !== undefined && inFrame(node)) continue;
1568
1892
  const key = node.getAttribute("_hk");
1569
- if (root) {
1570
- if (!key.startsWith(root)) continue;
1571
- } else {
1572
- const frame = node.closest("[data-fid]");
1573
- if (frame && frame !== element && element.contains(frame)) continue;
1574
- }
1575
- if (!sharedConfig.registry.has(key)) sharedConfig.registry.set(key, node);
1893
+ if (!registry.has(key)) registry.set(key, node);
1576
1894
  }
1577
1895
  }
1578
1896
  function getHydrationKey() {
1579
1897
  return sharedConfig.getNextContextId();
1580
1898
  }
1581
- const voidFn = () => undefined;
1582
1899
  const RequestContext = Symbol();
1583
1900
 
1901
+ function configureServerErrors(_config) {}
1902
+ function reportRequestFailure(_error, _event) {}
1584
1903
  function throwInBrowser(func) {
1585
1904
  const err = new Error(`${func.name} is not supported in the browser, returning undefined`);
1586
1905
  console.error(err);
@@ -1610,28 +1929,38 @@ function composeMiddleware(middlewares) {
1610
1929
  throwInBrowser(composeMiddleware);
1611
1930
  }
1612
1931
  function ssr(template, ...nodes) {}
1613
- function ssrElement(name, props, children, needsId) {}
1932
+ function ssrElement(name, props, children, needsId, skip, attrs) {}
1933
+ function ssrElementAttribute(key, value) {}
1934
+ function ssrLinkClaim(attrs) {}
1614
1935
  function ssrClassName(value) {}
1615
1936
  function ssrStyle(value) {}
1616
1937
  function ssrStyleProperty(name, value) {}
1938
+ function ssrStyleProperties(...entries) {}
1617
1939
  function ssrAttribute(key, value) {}
1618
1940
  function ssrGroup(fn, n) {}
1619
1941
  function ssrHydrationKey() {}
1620
- function resolveSSRNode(node, result, top) {}
1942
+ function resolveSSRNode(node, result, top, nested) {}
1621
1943
  function escape(s, attr) {}
1622
1944
 
1623
1945
  const ENVELOPE = Symbol.for("solid.ResponseEnvelope");
1624
- // PURE-annotated factory (same convention as solid's MockPromise): the brand
1625
- const ResponseEnvelope = /* @__PURE__ */(() => {
1626
- class ResponseEnvelope {
1627
- constructor(response, value) {
1628
- this.response = response;
1629
- this.value = value;
1630
- }
1946
+ let EnvelopeClass;
1947
+ const ResponseEnvelope = function ResponseEnvelope(response, value) {
1948
+ if (!EnvelopeClass) {
1949
+ EnvelopeClass = class extends Response {
1950
+ constructor(response, value) {
1951
+ super(response ? response.body : null, response && {
1952
+ status: response.status,
1953
+ statusText: response.statusText,
1954
+ headers: copyHeaders(response.headers)
1955
+ });
1956
+ this.response = response ? this : undefined;
1957
+ this.value = value;
1958
+ }
1959
+ };
1960
+ EnvelopeClass.prototype[ENVELOPE] = true;
1631
1961
  }
1632
- ResponseEnvelope.prototype[ENVELOPE] = true;
1633
- return ResponseEnvelope;
1634
- })();
1962
+ return new EnvelopeClass(response, value);
1963
+ };
1635
1964
  function isResponseEnvelope(value) {
1636
1965
  return !!(value && typeof value === "object" && value[ENVELOPE]);
1637
1966
  }
@@ -1654,24 +1983,38 @@ function isSafeError(value) {
1654
1983
  return !!(value && (typeof value === "object" || typeof value === "function") && value[SAFE_ERROR]);
1655
1984
  }
1656
1985
  const REVALIDATE_HEADER = "X-Revalidate";
1657
- function initWithRevalidate(init) {
1986
+ const REVALIDATE_ALL = "*";
1987
+ const RESPONSE_HEADER_VALUE_LIMIT = 4096;
1988
+ function copyHeaders(init) {
1989
+ const source = init;
1990
+ if (!source || !source.getSetCookie) return new Headers(init);
1991
+ const headers = new Headers();
1992
+ source.forEach((value, key) => {
1993
+ if (key !== "set-cookie") headers.append(key, value);
1994
+ });
1995
+ for (const cookie of source.getSetCookie()) headers.append("Set-Cookie", cookie);
1996
+ return headers;
1997
+ }
1998
+ function initWithRevalidate(init = {}) {
1999
+ const resolved = typeof init === "number" ? {
2000
+ status: init
2001
+ } : init;
1658
2002
  const {
1659
2003
  revalidate,
1660
2004
  ...responseInit
1661
- } = init;
1662
- let headers;
1663
- if (responseInit.headers && responseInit.headers.getSetCookie) {
1664
- headers = new Headers();
1665
- responseInit.headers.forEach((value, key) => {
1666
- if (key !== "set-cookie") headers.append(key, value);
1667
- });
1668
- for (const cookie of responseInit.headers.getSetCookie()) {
1669
- headers.append("Set-Cookie", cookie);
2005
+ } = resolved;
2006
+ const headers = copyHeaders(responseInit.headers);
2007
+ if (revalidate !== undefined) {
2008
+ const list = Array.isArray(revalidate) ? revalidate : [revalidate];
2009
+ if (list.length > 1 && list.includes(REVALIDATE_ALL)) {
2010
+ throw new TypeError(`revalidate names "${REVALIDATE_ALL}" alongside other keys; "${REVALIDATE_ALL}" already ` + `means every entry and stands alone — pass revalidate: "${REVALIDATE_ALL}" or the named keys.`);
1670
2011
  }
1671
- } else {
1672
- headers = new Headers(responseInit.headers);
2012
+ const keys = list.join(",");
2013
+ if (keys.length > RESPONSE_HEADER_VALUE_LIMIT) {
2014
+ 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.`);
2015
+ }
2016
+ headers.set(REVALIDATE_HEADER, keys);
1673
2017
  }
1674
- revalidate !== undefined && headers.set(REVALIDATE_HEADER, revalidate.toString());
1675
2018
  return {
1676
2019
  responseInit,
1677
2020
  headers
@@ -1684,13 +2027,17 @@ function redirect(url, init = 302) {
1684
2027
  const {
1685
2028
  responseInit,
1686
2029
  headers
1687
- } = initWithRevalidate(typeof init === "number" ? {
1688
- status: init
1689
- } : init);
2030
+ } = initWithRevalidate(init);
1690
2031
  if (responseInit.status === undefined) {
1691
2032
  responseInit.status = 302;
1692
2033
  }
1693
- headers.set("Location", String(url));
2034
+ const target = typeof url === "string" ? url : url[HREF];
2035
+ const location = typeof target === "string" ? target : String(url);
2036
+ const encoded = location.replace(/[^\x00-\x7f]/gu, encodeURIComponent);
2037
+ if (encoded.length > RESPONSE_HEADER_VALUE_LIMIT) {
2038
+ 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.`);
2039
+ }
2040
+ headers.set("Location", encoded);
1694
2041
  return new Response(null, {
1695
2042
  ...responseInit,
1696
2043
  headers
@@ -1706,38 +2053,33 @@ function reload(init = {}) {
1706
2053
  headers
1707
2054
  });
1708
2055
  }
2056
+ const NULL_BODY_STATUSES = new Set([204, 205, 304]);
1709
2057
  function respond(value, init = {}) {
1710
2058
  const {
1711
2059
  responseInit,
1712
2060
  headers
1713
2061
  } = initWithRevalidate(init);
2062
+ for (const header of COMPOSED_BODY_FRAMING) headers.delete(header);
2063
+ if (NULL_BODY_STATUSES.has(responseInit.status)) {
2064
+ return new ResponseEnvelope(new Response(null, {
2065
+ ...responseInit,
2066
+ headers
2067
+ }), value);
2068
+ }
1714
2069
  headers.set("Content-Type", "application/json");
1715
- return new ResponseEnvelope(new Response(JSON.stringify(value), {
2070
+ return new ResponseEnvelope(new Response(new ReadableStream({
2071
+ pull(controller) {
2072
+ controller.enqueue(new TextEncoder().encode(JSON.stringify(value)));
2073
+ controller.close();
2074
+ }
2075
+ }), {
1716
2076
  ...responseInit,
1717
2077
  headers
1718
2078
  }), value);
1719
2079
  }
1720
2080
 
1721
- const mergeProps = merge;
1722
2081
  const isServer = false;
1723
2082
  const isDev = false;
1724
- function render(code, element, init, options = {}) {
1725
- try {
1726
- const dispose = render$1(code, element, init, {
1727
- ...options,
1728
- insertOptions: {
1729
- schedule: true
1730
- }
1731
- });
1732
- flush();
1733
- return dispose;
1734
- } finally {
1735
- }
1736
- }
1737
- const hydrate = (...args) => {
1738
- enableHydration();
1739
- return hydrate$1(...args);
1740
- };
1741
2083
  function Portal(props) {
1742
2084
  return runWithOwner(createOwner(), () => portalImpl(props));
1743
2085
  }
@@ -1790,64 +2132,25 @@ function portalImpl(props) {
1790
2132
  });
1791
2133
  return treeMarker;
1792
2134
  }
1793
- const COMPONENT_BINDING = Symbol.for("dom-expressions.component-binding");
1794
- function bindingOf(value) {
1795
- return value !== null && (typeof value === "function" || typeof value === "object") && value[COMPONENT_BINDING] || undefined;
1796
- }
1797
- function dynamic(source) {
1798
- let latest = 0;
1799
- const sites = new Set();
1800
- let deliveredAddress;
1801
- const resolveBinding = (next, prev) => {
1802
- const binding = bindingOf(next);
1803
- if (!binding) return next;
1804
- deliveredAddress = binding.address;
1805
- const prevBinding = bindingOf(prev);
1806
- if (prevBinding && prevBinding.component === binding.component) {
1807
- for (const deliver of sites) deliver(binding.address);
1808
- return prev;
1809
- }
1810
- return next;
1811
- };
1812
- const cached = createMemo(prev => {
1813
- const next = source();
1814
- if (!next || typeof next.then !== "function") return resolveBinding(next, prev);
1815
- const token = ++latest;
1816
- return {
1817
- then: (onFulfilled, onRejected) => next.then(resolved => onFulfilled(token === latest ? resolveBinding(resolved, prev) : resolved), onRejected)
1818
- };
1819
- }, {
1820
- lazy: true
1821
- });
1822
- return props => {
1823
- return createMemo(() => {
1824
- const component = cached();
1825
- switch (typeof component) {
1826
- case "function":
1827
- {
1828
- const binding = bindingOf(component);
1829
- if (binding) {
1830
- const [address, setAddress] = createSignal(deliveredAddress ?? binding.address);
1831
- sites.add(setAddress);
1832
- onCleanup(() => sites.delete(setAddress));
1833
- return untrack(() => binding.component(props, address));
1834
- }
1835
- return untrack(() => component(props));
1836
- }
1837
- case "string":
1838
- const el = sharedConfig.hydrating ? getNextElement() : createElement(component, untrack(() => props.is));
1839
- spread(el, props);
1840
- return el;
1841
- }
1842
- });
1843
- };
2135
+ function dynamic(source, options) {
2136
+ return dynamicCore(source, options, staticElement);
2137
+ }
2138
+ function staticElement(tag, props) {
2139
+ const hydrating = sharedConfig.hydrating;
2140
+ const create = () => createElement(tag, untrack(() => props.is), untrack(() => props.xmlns));
2141
+ const el = hydrating ? getNextElement(create) : create();
2142
+ spread(el, props);
2143
+ if (hydrating) runHydrationEvents();
2144
+ return el;
1844
2145
  }
1845
2146
  function Dynamic(props) {
1846
2147
  const Comp = dynamic(() => props.component);
1847
2148
  return createComponent(Comp, omit(props, "component"));
1848
2149
  }
1849
- function createElement(tagName, is = undefined) {
1850
- return SVGElements.has(tagName) ? document.createElementNS(Namespaces.svg, tagName) : MathMLElements.has(tagName) ? document.createElementNS(Namespaces.mathml, tagName) : document.createElement(tagName, {
2150
+ function createElement(tagName, is = undefined, xmlns = undefined) {
2151
+ return xmlns ? document.createElementNS(xmlns, tagName, {
2152
+ is
2153
+ }) : SVGElements.has(tagName) ? document.createElementNS(Namespaces.svg, tagName) : MathMLElements.has(tagName) ? document.createElementNS(Namespaces.mathml, tagName) : document.createElement(tagName, {
1851
2154
  is
1852
2155
  });
1853
2156
  }
@@ -1879,4 +2182,4 @@ _moduleUrl) {
1879
2182
  function httpStatus(_code, _text) {}
1880
2183
  function httpHeader(_name, _value, _options) {}
1881
2184
 
1882
- export { ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, HREF, voidFn as HydrationScript, MathMLElements, Namespaces, Portal, REVALIDATE_HEADER, RawTextElements, RequestContext, ResponseEnvelope, SAFE_ERROR, SVGElements, VoidElements, acquireAsset, addEvent, applyRef, assign, claimElement, claimElementTree, className, clearFlashCookie, clientOnly, commitEventResponse, composeMiddleware, createRequestEvent, createResponseStub, createSSRResponse, delegateEvents, dynamic, dynamicProperty, effect, escape, voidFn as generateHydrationScript, getDelegatedRoot, getExpectedRedirectStatus, getFirstChild, getHydrationKey, getNextElement, getNextMarker, getNextMatch, getNextSibling, voidFn as getRequestEvent, getServerFunctionMetadata, getServerFunctionRPC, hasFlashCookie, httpHeader, httpStatus, hydrate, insert, installHydrationRuntime, isDev, isHref, isResponseEnvelope, isSafeError, isServer, isServerFunction, markSafeError, memo, mergeProps, parseCookieHeader, patchDriver, redirect, ref, registerDelegatedContainer, registerDelegatedRoot, registerElementClaim, reload, render, renderToStream, renderToString, resolveSSRNode, respond, rowProof, runHydrationEvents, scope, serializeCookie, setAttribute, setAttributeNS, setProperty, setStyleProperty, spread, ssr, ssrAttribute, ssrClassName, ssrElement, ssrGroup, ssrHydrationKey, ssrStyle, ssrStyleProperty, style, template, unregisterDelegatedContainer, unregisterDelegatedRoot, useHead, warmAsset };
2185
+ export { ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, HREF, HydrationScript, MathMLElements, NULL_BODY_STATUSES, Namespaces, Portal, RESPONSE_HEADER_VALUE_LIMIT, REVALIDATE_ALL, REVALIDATE_HEADER, RawTextElements, RequestContext, ResponseEnvelope, SAFE_ERROR, SVGElements, VoidElements, acquireAsset, addEvent, applyRef, assign, claimElement, claimElementTree, className, clearFlashCookie, clientOnly, commitEventResponse, composeMiddleware, configureServerErrors, createRequestEvent, createResponseStub, createSSRResponse, delegateEvents, dispatchAsInteraction, dynamic, dynamicProperty, effect, escape, generateHydrationScript, getDelegatedRoot, getExpectedRedirectStatus, getFirstChild, getHydrationKey, getHydrationWriter, getNextElement, getNextMarker, getNextMatch, getNextSibling, getRequestEvent, getServerFunctionMetadata, getServerFunctionRPC, getTraceContext, hasFlashCookie, hasServerLinkState, httpHeader, httpStatus, hydrate, insert, installHydrationRuntime, installServerComponentHydration, isDev, isHref, isResponseEnvelope, isSafeError, isServer, isServerFunction, markSafeError, memo, parseCookieHeader, readShallow, redirect, ref, registerDelegatedContainer, registerDelegatedRoot, registerElementClaim, reload, render, renderToStream, renderToString, reportRequestFailure, resolveSSRNode, respond, runHydrationEvents, scope, serializeCookie, setAttribute, setAttributeNS, setLinkClaim, setProperty, setStatefulProperty, setStyleProperty, spread, ssr, ssrAttribute, ssrClassName, ssrElement, ssrElementAttribute, ssrGroup, ssrHydrationKey, ssrLinkClaim, ssrStyle, ssrStyleProperties, ssrStyleProperty, style, takeHydrationValue, template, unregisterDelegatedContainer, unregisterDelegatedRoot, useHead, waitAsset, warmAsset };