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

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 (61) hide show
  1. package/dist/dev.cjs +163 -36
  2. package/dist/dev.js +161 -37
  3. package/dist/server.cjs +178 -37
  4. package/dist/server.js +177 -38
  5. package/dist/web.cjs +143 -36
  6. package/dist/web.js +141 -37
  7. package/frames/dist/client.cjs +41 -8
  8. package/frames/dist/client.dev.cjs +41 -8
  9. package/frames/dist/client.dev.js +41 -8
  10. package/frames/dist/client.js +41 -8
  11. package/frames/dist/server.cjs +497 -44
  12. package/frames/dist/server.js +497 -44
  13. package/package.json +2 -2
  14. package/serialization/dist/decode.cjs +4 -2
  15. package/serialization/dist/decode.js +4 -2
  16. package/serialization/dist/serialization.cjs +12 -8
  17. package/serialization/dist/serialization.js +12 -8
  18. package/serialization/types/index.d.ts +7 -0
  19. package/serialization/types/serializer-decode.d.ts +14 -1
  20. package/serialization/types/serializer.d.ts +7 -0
  21. package/serialization/types-cjs/index.d.cts +7 -0
  22. package/serialization/types-cjs/serializer-decode.d.cts +14 -1
  23. package/serialization/types-cjs/serializer.d.cts +7 -0
  24. package/server-functions/dist/client.cjs +164 -35
  25. package/server-functions/dist/client.js +161 -36
  26. package/server-functions/dist/server.cjs +899 -136
  27. package/server-functions/dist/server.dev.cjs +919 -136
  28. package/server-functions/dist/server.dev.js +915 -137
  29. package/server-functions/dist/server.js +895 -137
  30. package/types/client.d.ts +2 -1
  31. package/types/constants.d.ts +3 -1
  32. package/types/cookies.d.ts +6 -14
  33. package/types/frames/frame-client.d.ts +4 -0
  34. package/types/frames/serializer-decode.d.ts +14 -1
  35. package/types/frames/serializer.d.ts +7 -0
  36. package/types/jsx.d.ts +11 -16
  37. package/types/response.d.ts +11 -0
  38. package/types/serializer-decode.d.ts +14 -1
  39. package/types/serializer.d.ts +7 -0
  40. package/types/server-functions/client.d.ts +22 -2
  41. package/types/server-functions/flash.d.ts +9 -0
  42. package/types/server-functions/server.d.ts +131 -11
  43. package/types/server-functions/shared.d.ts +77 -14
  44. package/types/server-mock.d.ts +17 -2
  45. package/types/server.d.ts +16 -2
  46. package/types-cjs/client.d.cts +2 -1
  47. package/types-cjs/constants.d.cts +3 -1
  48. package/types-cjs/cookies.d.cts +6 -14
  49. package/types-cjs/frames/frame-client.d.cts +4 -0
  50. package/types-cjs/frames/serializer-decode.d.cts +14 -1
  51. package/types-cjs/frames/serializer.d.cts +7 -0
  52. package/types-cjs/jsx.d.cts +11 -16
  53. package/types-cjs/response.d.cts +11 -0
  54. package/types-cjs/serializer-decode.d.cts +14 -1
  55. package/types-cjs/serializer.d.cts +7 -0
  56. package/types-cjs/server-functions/client.d.cts +22 -2
  57. package/types-cjs/server-functions/flash.d.cts +9 -0
  58. package/types-cjs/server-functions/server.d.cts +131 -11
  59. package/types-cjs/server-functions/shared.d.cts +77 -14
  60. package/types-cjs/server-mock.d.cts +17 -2
  61. package/types-cjs/server.d.cts +16 -2
package/dist/web.js CHANGED
@@ -48,6 +48,7 @@ const Namespaces = {
48
48
  const VoidElements = /*#__PURE__*/new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"]);
49
49
  const RawTextElements = /*#__PURE__*/new Set(["style", "script", "noscript", "template", "textarea", "title"]);
50
50
  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(","));
51
+ const COMPOSED_BODY_FRAMING = /*#__PURE__*/new Set(["content-length", "content-encoding", "transfer-encoding"]);
51
52
 
52
53
  const transparentOptions = {
53
54
  transparent: true,
@@ -214,7 +215,8 @@ function resourceIdentity(tag, props) {
214
215
  let id = "res:" + tag + ":" + (props.rel || "") + ":" + (props.href || props.src || "");
215
216
  for (let i = 0; i < RESOURCE_QUALIFIERS.length; i++) {
216
217
  const q = RESOURCE_QUALIFIERS[i];
217
- if (props[q] != null) id += ":" + q + "=" + props[q];
218
+ const value = props[q];
219
+ if (value != null) id += ":" + q + "=" + (value === true ? "" : value);
218
220
  }
219
221
  return id;
220
222
  }
@@ -293,6 +295,7 @@ function serializeCookie(name, value, options = {}) {
293
295
  if (options.expires) cookie += `; Expires=${options.expires.toUTCString()}`;
294
296
  if (options.httpOnly) cookie += "; HttpOnly";
295
297
  if (options.secure) cookie += "; Secure";
298
+ if (options.partitioned) cookie += "; Partitioned";
296
299
  if (options.sameSite) {
297
300
  const sameSite = options.sameSite.toLowerCase();
298
301
  cookie += `; SameSite=${sameSite === "none" ? "None" : sameSite === "strict" ? "Strict" : "Lax"}`;
@@ -337,6 +340,8 @@ function installListDriver(driver) {
337
340
  listDriver = driver;
338
341
  }
339
342
  const $$EVENT_OWNER = "_$SOLID_EVENT_OWNER";
343
+ const $$EVENT_TUPLE = Symbol();
344
+ const hasOwn = Object.prototype.hasOwnProperty;
340
345
  const INNER_OWNED = {};
341
346
  const delegatedEvents = new Set();
342
347
  const delegatedContainers = new Map();
@@ -454,7 +459,8 @@ function findOwner(target, state) {
454
459
  }
455
460
  function setProperty(node, name, value) {
456
461
  if (isHydrating(node)) return;
457
- node[name] = value;
462
+ const nodeName = node.nodeName;
463
+ 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;
458
464
  }
459
465
  let claimHandlers = null;
460
466
  const CLAIM_SEAM = Symbol.for("solid.element-claims");
@@ -488,7 +494,17 @@ function claimElement(node) {
488
494
  }
489
495
  function setAttribute(node, name, value) {
490
496
  if (isHydrating(node)) return;
491
- if (value == null || value === false) node.removeAttribute(name);else node.setAttribute(name, value === true ? "" : value);
497
+ const selectMultiple = name === "multiple" && node.localName === "select";
498
+ if (value == null || value === false) node.removeAttribute(name);else {
499
+ node.setAttribute(name, value === true ? "" : value);
500
+ if (selectMultiple && !node._$multiple) {
501
+ const options = node.options;
502
+ for (let i = 0; i < options.length; i++) {
503
+ if (options[i].defaultSelected) options[i].selected = true;
504
+ }
505
+ }
506
+ }
507
+ if (selectMultiple) node._$multiple = true;
492
508
  if (claimHandlers !== null && (name === "href" || name === "action")) claimElement(node);
493
509
  }
494
510
  function setAttributeNS(node, namespace, name, value) {
@@ -496,22 +512,32 @@ function setAttributeNS(node, namespace, name, value) {
496
512
  if (value == null || value === false) node.removeAttributeNS(namespace, name.indexOf(":") > -1 ? name.split(":").pop() : name);else node.setAttributeNS(namespace, name, value === true ? "" : value);
497
513
  }
498
514
  function className(node, value, prev) {
499
- if (isHydrating(node)) return;
515
+ if (typeof value === "number") value = "" + value;
516
+ if (typeof prev === "number") prev = "" + prev;
517
+ if (isHydrating(node)) {
518
+ node._$classes = value && typeof value === "object" ? classListToObject(value) : undefined;
519
+ return;
520
+ }
500
521
  if (value == null || value === false) {
501
- prev && node.removeAttribute("class");
522
+ if (prev || node._$classes) {
523
+ node.removeAttribute("class");
524
+ node._$classes = undefined;
525
+ }
502
526
  return;
503
527
  }
504
528
  if (typeof value === "string") {
529
+ node._$classes = undefined;
505
530
  value !== prev && node.setAttribute("class", value);
506
531
  return;
507
532
  }
533
+ let applied;
508
534
  if (typeof prev === "string") {
509
- prev = {};
535
+ applied = {};
510
536
  node.removeAttribute("class");
511
- } else prev = classListToObject(prev || {});
537
+ } else applied = node._$classes || classListToObject(prev || {});
512
538
  value = classListToObject(value);
513
- const classKeys = Object.keys(value || {});
514
- const prevKeys = Object.keys(prev);
539
+ const classKeys = Object.keys(value);
540
+ const prevKeys = Object.keys(applied);
515
541
  let i, len;
516
542
  for (i = 0, len = prevKeys.length; i < len; i++) {
517
543
  const key = prevKeys[i];
@@ -521,22 +547,34 @@ function className(node, value, prev) {
521
547
  for (i = 0, len = classKeys.length; i < len; i++) {
522
548
  const key = classKeys[i],
523
549
  classValue = !!value[key];
524
- if (!key || key === "undefined" || prev[key] === classValue || !classValue) continue;
550
+ if (!key || key === "undefined" || applied[key] === classValue || !classValue) continue;
525
551
  node.classList.add(key);
526
552
  }
553
+ node._$classes = value;
527
554
  }
528
555
  function addEvent(node, name, handler, delegate) {
529
556
  if (delegate) {
557
+ const key = `$$${name}`;
558
+ let data;
530
559
  if (Array.isArray(handler)) {
531
- node[`$$${name}`] = handler[0];
532
- node[`$$${name}Data`] = handler[1];
533
- } else node[`$$${name}`] = handler;
534
- } else if (Array.isArray(handler)) {
560
+ data = handler[1];
561
+ node[key] = handler[0];
562
+ } else node[key] = handler;
563
+ node[`${key}Data`] = data;
564
+ return;
565
+ }
566
+ if (Array.isArray(handler)) {
535
567
  const handlerFn = handler[0];
536
- node.addEventListener(name, handler[0] = e => handlerFn.call(node, handler[1], e));
537
- } else node.addEventListener(name, handler, typeof handler !== "function" && handler);
568
+ const listener = e => handlerFn.call(node, handler[1], e);
569
+ listener[$$EVENT_TUPLE] = handler;
570
+ node.addEventListener(name, listener);
571
+ return listener;
572
+ }
573
+ node.addEventListener(name, handler, typeof handler !== "function" && handler);
574
+ return handler;
538
575
  }
539
576
  function style(node, value, prev) {
577
+ if (isHydrating(node)) return;
540
578
  if (!value) {
541
579
  if (prev || node._$styles) {
542
580
  setAttribute(node, "style");
@@ -561,12 +599,13 @@ function style(node, value, prev) {
561
599
  }
562
600
  let v, s;
563
601
  for (s in applied) {
564
- if (value[s] == null) {
602
+ if (!hasOwn.call(value, s) || value[s] == null) {
565
603
  nodeStyle.removeProperty(s);
566
604
  delete applied[s];
567
605
  }
568
606
  }
569
607
  for (s in value) {
608
+ if (!hasOwn.call(value, s)) continue;
570
609
  v = value[s];
571
610
  if (v != null && v !== applied[s]) {
572
611
  nodeStyle.setProperty(s, v);
@@ -575,20 +614,28 @@ function style(node, value, prev) {
575
614
  }
576
615
  }
577
616
  function setStyleProperty(node, name, value) {
617
+ if (isHydrating(node)) return;
578
618
  value != null ? node.style.setProperty(name, value) : node.style.removeProperty(name);
579
619
  }
580
620
  function spread(node, props = {}, skipChildren) {
581
621
  const prevProps = {};
582
- if (!skipChildren) insert(node, () => props.children);
622
+ const get = typeof props === "function" ? props : () => props;
623
+ if (!skipChildren) insert(node, () => {
624
+ const source = get();
625
+ return hasOwn.call(source, "children") ? source.children : undefined;
626
+ });
583
627
  effect(() => {
584
- const r = props.ref;
628
+ const source = get();
629
+ const r = hasOwn.call(source, "ref") && source.ref;
585
630
  (typeof r === "function" || Array.isArray(r)) && ref(() => r, node);
586
631
  }, () => {});
587
632
  effect(() => {
633
+ const source = get();
588
634
  const newProps = {};
589
- for (const prop in props) {
635
+ for (const prop in source) {
636
+ if (!hasOwn.call(source, prop)) continue;
590
637
  if (prop === "children" || prop === "ref") continue;
591
- newProps[prop] = props[prop];
638
+ newProps[prop] = source[prop];
592
639
  }
593
640
  return newProps;
594
641
  }, props => assign(node, props, true, prevProps, true));
@@ -618,6 +665,19 @@ function scope(fn) {
618
665
  const SCOPE_OPTIONS = {
619
666
  scope: true
620
667
  };
668
+ let insertionParent = null;
669
+ function getInsertionParent() {
670
+ return insertionParent;
671
+ }
672
+ function withInsertionParent(parent, fn) {
673
+ const prev = insertionParent;
674
+ insertionParent = parent;
675
+ try {
676
+ return fn();
677
+ } finally {
678
+ insertionParent = prev;
679
+ }
680
+ }
621
681
  let hydrationRt = null;
622
682
  function installHydrationRuntime() {
623
683
  hydrationRt = {
@@ -685,7 +745,7 @@ function insert(parent, accessor, marker, initial, options) {
685
745
  if (listDriver(parent, accessor, marker, () => runWithOwner(owner, () => insert(parent, () => listAccessor(), marker, marker !== undefined ? [] : undefined, options)))) return;
686
746
  }
687
747
  if (typeof accessor !== "function") {
688
- accessor = normalize(accessor, initial, multi, true);
748
+ accessor = withInsertionParent(parent, () => normalize(accessor, initial, multi, true));
689
749
  if (typeof accessor !== "function") {
690
750
  insertExpression(parent, accessor, initial, marker);
691
751
  host && tagHost(accessor, host);
@@ -700,9 +760,9 @@ function insert(parent, accessor, marker, initial, options) {
700
760
  let current = initial;
701
761
  effect(prev => {
702
762
  if (hydrationRt !== null) current = hydrationRt.reclaimRegion(current, parent, marker);
703
- const value = normalize(accessor(), current, multi, true);
763
+ const value = withInsertionParent(parent, () => normalize(accessor(), current, multi, true));
704
764
  if (typeof value !== "function") return value;
705
- effect(() => (hydrationRt !== null && (current = hydrationRt.reclaimRegion(current, parent, marker)), normalize(value, current, multi)), inner => {
765
+ effect(() => (hydrationRt !== null && (current = hydrationRt.reclaimRegion(current, parent, marker)), withInsertionParent(parent, () => normalize(value, current, multi))), inner => {
706
766
  current = insertExpression(parent, inner, current, marker);
707
767
  host && tagHost(current, host);
708
768
  }, prev !== undefined && !(options && options.schedule) ? {
@@ -1362,7 +1422,8 @@ function classListToObject(classList) {
1362
1422
  function flattenClassList(list, result) {
1363
1423
  for (let i = 0, len = list.length; i < len; i++) {
1364
1424
  const item = list[i];
1365
- 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;
1425
+ if (Array.isArray(item)) flattenClassList(item, result);else if (typeof item === "object" && item != null) Object.assign(result, item);
1426
+ else if (typeof item !== "boolean" && (item || item === 0)) result[item] = true;
1366
1427
  }
1367
1428
  }
1368
1429
  function assignProp(node, prop, value, prev, skipRef, nodeName) {
@@ -1378,12 +1439,13 @@ function assignProp(node, prop, value, prev, skipRef, nodeName) {
1378
1439
  const name = prop.slice(2).toLowerCase();
1379
1440
  const delegate = DelegatedEvents.has(name);
1380
1441
  if (!delegate && prev) {
1381
- const h = Array.isArray(prev) ? prev[0] : prev;
1382
- node.removeEventListener(name, h);
1442
+ if (Array.isArray(value) && typeof prev === "function" && prev[$$EVENT_TUPLE] === value) return prev;
1443
+ node.removeEventListener(name, prev, typeof prev !== "function" && prev);
1383
1444
  }
1384
1445
  if (delegate || value) {
1385
- addEvent(node, name, value, delegate);
1446
+ const attached = addEvent(node, name, value, delegate);
1386
1447
  delegate && delegateEvents([name]);
1448
+ if (!delegate) return attached;
1387
1449
  }
1388
1450
  } else if (hasNamespace && prop.slice(0, 5) === "prop:" || ChildProperties.has(prop) || DOMWithState[nodeName]?.[prop]) {
1389
1451
  if (hasNamespace) prop = prop.slice(5);else if (isHydrating(node)) return value;
@@ -1423,7 +1485,7 @@ function eventHandler(e, container, state) {
1423
1485
  }
1424
1486
  if (handler && !node.disabled) {
1425
1487
  const data = node[`${key}Data`];
1426
- data !== undefined ? handler.call(node, data, e) : handler.call(node, e);
1488
+ data !== undefined ? handler.call(node, data, e) : typeof handler === "function" ? handler.call(node, e) : handler.handleEvent(e);
1427
1489
  if (e.cancelBubble) return;
1428
1490
  }
1429
1491
  node.host && typeof node.host !== "string" && !node.host._$host && node.contains(e.target) && retarget(node.host);
@@ -1543,7 +1605,7 @@ function normalize(value, current, multi, doNotUnwrap) {
1543
1605
  const item = value[i],
1544
1606
  prev = current && current[i],
1545
1607
  t = typeof item;
1546
- if ((t === "string" || t === "number") && prev && prev.nodeType === 3) value[i] = prev;
1608
+ if ((t === "string" || t === "number") && prev && prev.nodeType === 3 && isHydrating(prev)) value[i] = prev;
1547
1609
  }
1548
1610
  }
1549
1611
  return value;
@@ -2015,6 +2077,7 @@ function isSafeError(value) {
2015
2077
  return !!(value && (typeof value === "object" || typeof value === "function") && value[SAFE_ERROR]);
2016
2078
  }
2017
2079
  const REVALIDATE_HEADER = "X-Revalidate";
2080
+ const RESPONSE_HEADER_VALUE_LIMIT = 4096;
2018
2081
  function initWithRevalidate(init = {}) {
2019
2082
  const resolved = typeof init === "number" ? {
2020
2083
  status: init
@@ -2035,7 +2098,13 @@ function initWithRevalidate(init = {}) {
2035
2098
  } else {
2036
2099
  headers = new Headers(responseInit.headers);
2037
2100
  }
2038
- revalidate !== undefined && headers.set(REVALIDATE_HEADER, revalidate.toString());
2101
+ if (revalidate !== undefined) {
2102
+ const keys = revalidate.toString();
2103
+ if (keys.length > RESPONSE_HEADER_VALUE_LIMIT) {
2104
+ 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.`);
2105
+ }
2106
+ headers.set(REVALIDATE_HEADER, keys);
2107
+ }
2039
2108
  return {
2040
2109
  responseInit,
2041
2110
  headers
@@ -2053,7 +2122,12 @@ function redirect(url, init = 302) {
2053
2122
  responseInit.status = 302;
2054
2123
  }
2055
2124
  const target = typeof url === "string" ? url : url[HREF];
2056
- headers.set("Location", typeof target === "string" ? target : String(url));
2125
+ const location = typeof target === "string" ? target : String(url);
2126
+ const encoded = location.replace(/[^\x00-\x7f]/gu, encodeURIComponent);
2127
+ if (encoded.length > RESPONSE_HEADER_VALUE_LIMIT) {
2128
+ 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.`);
2129
+ }
2130
+ headers.set("Location", encoded);
2057
2131
  return new Response(null, {
2058
2132
  ...responseInit,
2059
2133
  headers
@@ -2069,11 +2143,19 @@ function reload(init = {}) {
2069
2143
  headers
2070
2144
  });
2071
2145
  }
2146
+ const NULL_BODY_STATUSES = new Set([204, 205, 304]);
2072
2147
  function respond(value, init = {}) {
2073
2148
  const {
2074
2149
  responseInit,
2075
2150
  headers
2076
2151
  } = initWithRevalidate(init);
2152
+ for (const header of COMPOSED_BODY_FRAMING) headers.delete(header);
2153
+ if (NULL_BODY_STATUSES.has(responseInit.status)) {
2154
+ return new ResponseEnvelope(new Response(null, {
2155
+ ...responseInit,
2156
+ headers
2157
+ }), value);
2158
+ }
2077
2159
  headers.set("Content-Type", "application/json");
2078
2160
  return new ResponseEnvelope(new Response(JSON.stringify(value), {
2079
2161
  ...responseInit,
@@ -2180,9 +2262,24 @@ function dynamic(source) {
2180
2262
  return untrack(() => component(props));
2181
2263
  }
2182
2264
  case "string":
2183
- const el = sharedConfig.hydrating ? getNextElement() : createElement(component, untrack(() => props.is));
2184
- spread(el, props);
2185
- return el;
2265
+ {
2266
+ if (sharedConfig.hydrating) {
2267
+ const el = getNextElement();
2268
+ spread(el, props);
2269
+ return el;
2270
+ }
2271
+ const owner = getOwner();
2272
+ let el;
2273
+ return () => {
2274
+ if (!el) {
2275
+ runWithOwner(owner, () => {
2276
+ el = createElement(component, untrack(() => props.is));
2277
+ spread(el, props);
2278
+ });
2279
+ }
2280
+ return el;
2281
+ };
2282
+ }
2186
2283
  }
2187
2284
  });
2188
2285
  };
@@ -2191,8 +2288,15 @@ function Dynamic(props) {
2191
2288
  const Comp = dynamic(() => props.component);
2192
2289
  return createComponent(Comp, omit(props, "component"));
2193
2290
  }
2291
+ const AmbiguousSVGElements = /*#__PURE__*/new Set(["a", "script", "style", "title"]);
2194
2292
  function createElement(tagName, is = undefined) {
2195
- return SVGElements.has(tagName) ? document.createElementNS(Namespaces.svg, tagName) : MathMLElements.has(tagName) ? document.createElementNS(Namespaces.mathml, tagName) : document.createElement(tagName, {
2293
+ if (SVGElements.has(tagName)) return document.createElementNS(Namespaces.svg, tagName);
2294
+ if (MathMLElements.has(tagName)) return document.createElementNS(Namespaces.mathml, tagName);
2295
+ if (AmbiguousSVGElements.has(tagName)) {
2296
+ const parent = getInsertionParent();
2297
+ if (parent && parent.namespaceURI === Namespaces.svg && parent.localName !== "foreignObject") return document.createElementNS(Namespaces.svg, tagName);
2298
+ }
2299
+ return document.createElement(tagName, {
2196
2300
  is
2197
2301
  });
2198
2302
  }
@@ -2224,4 +2328,4 @@ _moduleUrl) {
2224
2328
  function httpStatus(_code, _text) {}
2225
2329
  function httpHeader(_name, _value, _options) {}
2226
2330
 
2227
- export { ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, HREF, 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, driveList, dynamic, dynamicProperty, effect, escape, generateHydrationScript, getDelegatedRoot, getExpectedRedirectStatus, getFirstChild, getHydrationKey, getNextElement, getNextMarker, getNextMatch, getNextSibling, getRequestEvent, getServerFunctionMetadata, getServerFunctionRPC, hasFlashCookie, httpHeader, httpStatus, hydrate, insert, installHydrationRuntime, installListDriver, isDev, isHref, isResponseEnvelope, isSafeError, isServer, isServerFunction, listDriver, markSafeError, memo, 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, waitAsset, warmAsset };
2331
+ export { ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, HREF, HydrationScript, MathMLElements, NULL_BODY_STATUSES, Namespaces, Portal, RESPONSE_HEADER_VALUE_LIMIT, REVALIDATE_HEADER, RawTextElements, RequestContext, ResponseEnvelope, SAFE_ERROR, SVGElements, VoidElements, acquireAsset, addEvent, applyRef, assign, claimElement, claimElementTree, className, clearFlashCookie, clientOnly, commitEventResponse, composeMiddleware, createRequestEvent, createResponseStub, createSSRResponse, delegateEvents, driveList, dynamic, dynamicProperty, effect, escape, generateHydrationScript, getDelegatedRoot, getExpectedRedirectStatus, getFirstChild, getHydrationKey, getInsertionParent, getNextElement, getNextMarker, getNextMatch, getNextSibling, getRequestEvent, getServerFunctionMetadata, getServerFunctionRPC, hasFlashCookie, httpHeader, httpStatus, hydrate, insert, installHydrationRuntime, installListDriver, isDev, isHref, isResponseEnvelope, isSafeError, isServer, isServerFunction, listDriver, markSafeError, memo, 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, waitAsset, warmAsset };
@@ -177,7 +177,18 @@ function createFrameHost(options = {}) {
177
177
  store.version = version;
178
178
  clearStreamRecords(store.records);
179
179
  }
180
- Object.assign(store.records, records);
180
+ const assets = records["seg::assets"];
181
+ const previous = assets && store.records["seg::assets"];
182
+ if (!previous || previous === assets) {
183
+ Object.assign(store.records, records);
184
+ } else {
185
+ for (const name in assets) {
186
+ const values = assets[name];
187
+ if (Array.isArray(values)) {
188
+ previous[name] ? previous[name].push(...values) : previous[name] = values;
189
+ }
190
+ }
191
+ }
181
192
  return true;
182
193
  };
183
194
  return {
@@ -269,7 +280,7 @@ class FrameImpl {
269
280
  #slotRegions = new Map();
270
281
  #slotResolvedRefs = new Map();
271
282
  #slotNodes = new Map();
272
- #processedAssets = new Set();
283
+ #processedAssets = new WeakSet();
273
284
  #recordRefresh = null;
274
285
  #disposed = false;
275
286
  #styleFlush = () => {
@@ -370,6 +381,7 @@ class FrameImpl {
370
381
  this.#revealed.clear();
371
382
  this.#fallbackShown.clear();
372
383
  this.#appliedHoles.clear();
384
+ this.#processedAssets = new WeakSet();
373
385
  this.#errorNotified = false;
374
386
  clearStreamRecords(this.#store, root);
375
387
  }
@@ -429,12 +441,17 @@ class FrameImpl {
429
441
  }
430
442
  }
431
443
  for (const key in this.#store) {
432
- if (this.#processedAssets.has(key) || !key.endsWith(":assets")) continue;
433
- this.#processedAssets.add(key);
434
444
  const record = this.#store[key];
435
- if (record && record.modules) {
445
+ if (!key.endsWith(":assets") || !record || this.#processedAssets.has(record)) {
446
+ continue;
447
+ }
448
+ this.#processedAssets.add(record);
449
+ if (record.modules) {
436
450
  for (const href of record.modules) ensureModulePreload(href);
437
451
  }
452
+ if (record.preloads) {
453
+ for (const entry of record.preloads) ensurePreload(entry);
454
+ }
438
455
  }
439
456
  this.#syncSlots();
440
457
  }
@@ -902,12 +919,28 @@ function parseFragment(html) {
902
919
  template.innerHTML = html;
903
920
  return template.content;
904
921
  }
905
- function findHeadElement(selector, attr, value) {
906
- for (const node of document.head.querySelectorAll(selector)) {
907
- if (node.getAttribute(attr) === value) return node;
922
+ const PRELOAD_QUALIFIERS = ["as", "crossorigin", "type", "media", "imagesrcset", "imagesizes"];
923
+ function findHeadElement(selector, attr, value, qualifiers) {
924
+ candidate: for (const node of document.head.querySelectorAll(selector)) {
925
+ if (node.getAttribute(attr) !== value) continue;
926
+ if (!qualifiers) return node;
927
+ for (let i = 0; i < PRELOAD_QUALIFIERS.length; i++) {
928
+ const name = PRELOAD_QUALIFIERS[i];
929
+ if (node.getAttribute(name) !== (qualifiers[name] ?? null)) continue candidate;
930
+ }
931
+ return node;
908
932
  }
909
933
  return null;
910
934
  }
935
+ function ensurePreload(entry) {
936
+ const attrs = entry.attrs;
937
+ if (findHeadElement('link[rel="preload"]', "href", entry.href, attrs)) return;
938
+ const link = document.createElement("link");
939
+ link.rel = "preload";
940
+ for (const name in attrs) link.setAttribute(name, attrs[name]);
941
+ link.setAttribute("href", entry.href);
942
+ document.head.appendChild(link);
943
+ }
911
944
  function ensureStylesheet(entry, onSettle) {
912
945
  const href = typeof entry === "string" ? entry : entry.href;
913
946
  let link = findHeadElement('link[rel="stylesheet"]', "href", href);
@@ -180,7 +180,18 @@ function createFrameHost(options = {}) {
180
180
  store.version = version;
181
181
  clearStreamRecords(store.records);
182
182
  }
183
- Object.assign(store.records, records);
183
+ const assets = records["seg::assets"];
184
+ const previous = assets && store.records["seg::assets"];
185
+ if (!previous || previous === assets) {
186
+ Object.assign(store.records, records);
187
+ } else {
188
+ for (const name in assets) {
189
+ const values = assets[name];
190
+ if (Array.isArray(values)) {
191
+ previous[name] ? previous[name].push(...values) : previous[name] = values;
192
+ }
193
+ }
194
+ }
184
195
  return true;
185
196
  };
186
197
  return {
@@ -272,7 +283,7 @@ class FrameImpl {
272
283
  #slotRegions = new Map();
273
284
  #slotResolvedRefs = new Map();
274
285
  #slotNodes = new Map();
275
- #processedAssets = new Set();
286
+ #processedAssets = new WeakSet();
276
287
  #recordRefresh = null;
277
288
  #disposed = false;
278
289
  #styleFlush = () => {
@@ -373,6 +384,7 @@ class FrameImpl {
373
384
  this.#revealed.clear();
374
385
  this.#fallbackShown.clear();
375
386
  this.#appliedHoles.clear();
387
+ this.#processedAssets = new WeakSet();
376
388
  this.#errorNotified = false;
377
389
  clearStreamRecords(this.#store, root);
378
390
  }
@@ -433,12 +445,17 @@ class FrameImpl {
433
445
  }
434
446
  }
435
447
  for (const key in this.#store) {
436
- if (this.#processedAssets.has(key) || !key.endsWith(":assets")) continue;
437
- this.#processedAssets.add(key);
438
448
  const record = this.#store[key];
439
- if (record && record.modules) {
449
+ if (!key.endsWith(":assets") || !record || this.#processedAssets.has(record)) {
450
+ continue;
451
+ }
452
+ this.#processedAssets.add(record);
453
+ if (record.modules) {
440
454
  for (const href of record.modules) ensureModulePreload(href);
441
455
  }
456
+ if (record.preloads) {
457
+ for (const entry of record.preloads) ensurePreload(entry);
458
+ }
442
459
  }
443
460
  this.#syncSlots();
444
461
  }
@@ -912,12 +929,28 @@ function parseFragment(html) {
912
929
  template.innerHTML = html;
913
930
  return template.content;
914
931
  }
915
- function findHeadElement(selector, attr, value) {
916
- for (const node of document.head.querySelectorAll(selector)) {
917
- if (node.getAttribute(attr) === value) return node;
932
+ const PRELOAD_QUALIFIERS = ["as", "crossorigin", "type", "media", "imagesrcset", "imagesizes"];
933
+ function findHeadElement(selector, attr, value, qualifiers) {
934
+ candidate: for (const node of document.head.querySelectorAll(selector)) {
935
+ if (node.getAttribute(attr) !== value) continue;
936
+ if (!qualifiers) return node;
937
+ for (let i = 0; i < PRELOAD_QUALIFIERS.length; i++) {
938
+ const name = PRELOAD_QUALIFIERS[i];
939
+ if (node.getAttribute(name) !== (qualifiers[name] ?? null)) continue candidate;
940
+ }
941
+ return node;
918
942
  }
919
943
  return null;
920
944
  }
945
+ function ensurePreload(entry) {
946
+ const attrs = entry.attrs;
947
+ if (findHeadElement('link[rel="preload"]', "href", entry.href, attrs)) return;
948
+ const link = document.createElement("link");
949
+ link.rel = "preload";
950
+ for (const name in attrs) link.setAttribute(name, attrs[name]);
951
+ link.setAttribute("href", entry.href);
952
+ document.head.appendChild(link);
953
+ }
921
954
  function ensureStylesheet(entry, onSettle) {
922
955
  const href = typeof entry === "string" ? entry : entry.href;
923
956
  let link = findHeadElement('link[rel="stylesheet"]', "href", href);
@@ -178,7 +178,18 @@ function createFrameHost(options = {}) {
178
178
  store.version = version;
179
179
  clearStreamRecords(store.records);
180
180
  }
181
- Object.assign(store.records, records);
181
+ const assets = records["seg::assets"];
182
+ const previous = assets && store.records["seg::assets"];
183
+ if (!previous || previous === assets) {
184
+ Object.assign(store.records, records);
185
+ } else {
186
+ for (const name in assets) {
187
+ const values = assets[name];
188
+ if (Array.isArray(values)) {
189
+ previous[name] ? previous[name].push(...values) : previous[name] = values;
190
+ }
191
+ }
192
+ }
182
193
  return true;
183
194
  };
184
195
  return {
@@ -270,7 +281,7 @@ class FrameImpl {
270
281
  #slotRegions = new Map();
271
282
  #slotResolvedRefs = new Map();
272
283
  #slotNodes = new Map();
273
- #processedAssets = new Set();
284
+ #processedAssets = new WeakSet();
274
285
  #recordRefresh = null;
275
286
  #disposed = false;
276
287
  #styleFlush = () => {
@@ -371,6 +382,7 @@ class FrameImpl {
371
382
  this.#revealed.clear();
372
383
  this.#fallbackShown.clear();
373
384
  this.#appliedHoles.clear();
385
+ this.#processedAssets = new WeakSet();
374
386
  this.#errorNotified = false;
375
387
  clearStreamRecords(this.#store, root);
376
388
  }
@@ -431,12 +443,17 @@ class FrameImpl {
431
443
  }
432
444
  }
433
445
  for (const key in this.#store) {
434
- if (this.#processedAssets.has(key) || !key.endsWith(":assets")) continue;
435
- this.#processedAssets.add(key);
436
446
  const record = this.#store[key];
437
- if (record && record.modules) {
447
+ if (!key.endsWith(":assets") || !record || this.#processedAssets.has(record)) {
448
+ continue;
449
+ }
450
+ this.#processedAssets.add(record);
451
+ if (record.modules) {
438
452
  for (const href of record.modules) ensureModulePreload(href);
439
453
  }
454
+ if (record.preloads) {
455
+ for (const entry of record.preloads) ensurePreload(entry);
456
+ }
440
457
  }
441
458
  this.#syncSlots();
442
459
  }
@@ -910,12 +927,28 @@ function parseFragment(html) {
910
927
  template.innerHTML = html;
911
928
  return template.content;
912
929
  }
913
- function findHeadElement(selector, attr, value) {
914
- for (const node of document.head.querySelectorAll(selector)) {
915
- if (node.getAttribute(attr) === value) return node;
930
+ const PRELOAD_QUALIFIERS = ["as", "crossorigin", "type", "media", "imagesrcset", "imagesizes"];
931
+ function findHeadElement(selector, attr, value, qualifiers) {
932
+ candidate: for (const node of document.head.querySelectorAll(selector)) {
933
+ if (node.getAttribute(attr) !== value) continue;
934
+ if (!qualifiers) return node;
935
+ for (let i = 0; i < PRELOAD_QUALIFIERS.length; i++) {
936
+ const name = PRELOAD_QUALIFIERS[i];
937
+ if (node.getAttribute(name) !== (qualifiers[name] ?? null)) continue candidate;
938
+ }
939
+ return node;
916
940
  }
917
941
  return null;
918
942
  }
943
+ function ensurePreload(entry) {
944
+ const attrs = entry.attrs;
945
+ if (findHeadElement('link[rel="preload"]', "href", entry.href, attrs)) return;
946
+ const link = document.createElement("link");
947
+ link.rel = "preload";
948
+ for (const name in attrs) link.setAttribute(name, attrs[name]);
949
+ link.setAttribute("href", entry.href);
950
+ document.head.appendChild(link);
951
+ }
919
952
  function ensureStylesheet(entry, onSettle) {
920
953
  const href = typeof entry === "string" ? entry : entry.href;
921
954
  let link = findHeadElement('link[rel="stylesheet"]', "href", href);