@solidjs/web 2.0.0-rc.1 → 2.0.0-rc.10

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 (107) hide show
  1. package/dist/server.dev.js +4472 -0
  2. package/dist/server.js +1301 -251
  3. package/dist/{server.cjs → server.observe.js} +1501 -452
  4. package/dist/{dev.cjs → web.dev.js} +699 -360
  5. package/dist/web.js +454 -139
  6. package/dist/{dev.js → web.observe.js} +505 -211
  7. package/frames/dist/client.dev.js +463 -71
  8. package/frames/dist/client.js +363 -70
  9. package/frames/dist/{client.dev.cjs → client.observe.js} +486 -133
  10. package/frames/dist/server.dev.js +1713 -0
  11. package/frames/dist/server.js +552 -2583
  12. package/frames/dist/server.observe.js +1713 -0
  13. package/frames/package.json +2 -25
  14. package/package.json +214 -255
  15. package/performance-tracks/dist/performance-tracks.dev.js +678 -0
  16. package/performance-tracks/dist/performance-tracks.js +6 -0
  17. package/performance-tracks/dist/performance-tracks.observe.js +666 -0
  18. package/performance-tracks/package.json +7 -0
  19. package/performance-tracks/types/index.d.ts +67 -0
  20. package/serialization/decode/package.json +2 -15
  21. package/serialization/dist/decode.js +92 -15
  22. package/serialization/dist/serialization.js +103 -23
  23. package/serialization/package.json +2 -15
  24. package/serialization/types/index.d.ts +76 -157
  25. package/serialization/types/serializer-decode.d.ts +149 -112
  26. package/serialization/types/serializer.d.ts +101 -0
  27. package/server-functions/dist/client.dev.js +1364 -0
  28. package/server-functions/dist/client.js +611 -97
  29. package/server-functions/dist/client.observe.js +1343 -0
  30. package/server-functions/dist/server.dev.js +2138 -202
  31. package/server-functions/dist/server.js +2042 -199
  32. package/server-functions/dist/server.observe.js +3043 -0
  33. package/server-functions/package.json +2 -35
  34. package/server-functions/rich-args/package.json +2 -15
  35. package/storage/package.json +2 -15
  36. package/types/client.d.ts +193 -288
  37. package/types/constants.d.ts +20 -0
  38. package/types/cookies.d.ts +32 -84
  39. package/types/diagnostics.d.ts +56 -0
  40. package/types/frames/client.d.ts +1 -1
  41. package/types/frames/frame-client.d.ts +323 -259
  42. package/types/frames/frame-container-plugin.d.ts +72 -0
  43. package/types/frames/frame-sink.d.ts +101 -158
  44. package/types/frames/frame-transport.d.ts +192 -190
  45. package/types/frames/serializer-decode.d.ts +219 -0
  46. package/types/frames/serializer.d.ts +76 -157
  47. package/types/frames/server.d.ts +1 -1
  48. package/types/head.d.ts +19 -0
  49. package/types/index.d.ts +52 -80
  50. package/types/index.server.d.ts +174 -0
  51. package/types/jsx.d.ts +33 -35
  52. package/types/observe.d.ts +358 -0
  53. package/types/reconcile.d.ts +1 -0
  54. package/types/render.d.ts +9 -0
  55. package/types/response.d.ts +75 -150
  56. package/types/serializer-decode.d.ts +149 -112
  57. package/types/serializer.d.ts +76 -157
  58. package/types/server-functions/client.d.ts +192 -194
  59. package/types/server-functions/flash.d.ts +28 -30
  60. package/types/server-functions/registry.d.ts +102 -0
  61. package/types/server-functions/rich-args.d.ts +1 -10
  62. package/types/server-functions/server.d.ts +511 -475
  63. package/types/server-functions/shared.d.ts +366 -425
  64. package/types/server-mock.d.ts +110 -13
  65. package/types/server-observe.d.ts +77 -0
  66. package/types/server.d.ts +425 -425
  67. package/types/trace.d.ts +127 -0
  68. package/LICENSE +0 -21
  69. package/dist/web.cjs +0 -2008
  70. package/frames/dist/client.cjs +0 -1916
  71. package/frames/dist/server.cjs +0 -3756
  72. package/serialization/dist/decode.cjs +0 -122
  73. package/serialization/dist/serialization.cjs +0 -244
  74. package/serialization/types-cjs/index.d.cts +0 -182
  75. package/serialization/types-cjs/package.json +0 -3
  76. package/serialization/types-cjs/serializer-decode.d.cts +0 -182
  77. package/server-functions/dist/client.cjs +0 -793
  78. package/server-functions/dist/rich-args.cjs +0 -11
  79. package/server-functions/dist/server.cjs +0 -1171
  80. package/server-functions/dist/server.dev.cjs +0 -1171
  81. package/storage/dist/storage.cjs +0 -12
  82. package/storage/types-cjs/index.d.cts +0 -28
  83. package/storage/types-cjs/package.json +0 -3
  84. package/types/core.d.ts +0 -6
  85. package/types-cjs/client.d.cts +0 -337
  86. package/types-cjs/cookies.d.cts +0 -93
  87. package/types-cjs/core.d.cts +0 -6
  88. package/types-cjs/frames/client.d.cts +0 -36
  89. package/types-cjs/frames/frame-client.d.cts +0 -338
  90. package/types-cjs/frames/frame-sink.d.cts +0 -194
  91. package/types-cjs/frames/frame-transport.d.cts +0 -222
  92. package/types-cjs/frames/serializer.d.cts +0 -182
  93. package/types-cjs/frames/server.d.cts +0 -52
  94. package/types-cjs/index.d.cts +0 -244
  95. package/types-cjs/jsx-properties.d.cts +0 -93
  96. package/types-cjs/jsx.d.cts +0 -4159
  97. package/types-cjs/package.json +0 -3
  98. package/types-cjs/response.d.cts +0 -174
  99. package/types-cjs/serializer-decode.d.cts +0 -182
  100. package/types-cjs/serializer.d.cts +0 -182
  101. package/types-cjs/server-functions/client.d.cts +0 -231
  102. package/types-cjs/server-functions/flash.d.cts +0 -38
  103. package/types-cjs/server-functions/rich-args.d.cts +0 -10
  104. package/types-cjs/server-functions/server.d.cts +0 -616
  105. package/types-cjs/server-functions/shared.d.cts +0 -523
  106. package/types-cjs/server-mock.d.cts +0 -277
  107. package/types-cjs/server.d.cts +0 -523
@@ -1,11 +1,12 @@
1
- import { getOwner, onCleanup, createMemo, runWithOwner, createSignal, createRenderEffect, createLoadingBoundary, createOwner, sharedConfig, materializeContainerTrace } from 'solid-js';
2
- import { insert } from '@solidjs/web';
3
- import { ChunkReader, frameAddress, SINGLE_FLIGHT_HEADER, deserializeStream, getServerFunctionsCodec, createChunk, getFlightDataConsumer, ERROR_HEADER, REVALIDATE_HEADER, configureServerFunctionsClient } from '@solidjs/web/server-functions/client';
1
+ import { DEV, OBSERVE, getOwner, onCleanup, createMemo, runWithOwner, createSignal, createRenderEffect, createLoadingBoundary, createOwner, sharedConfig } from 'solid-js';
2
+ import { delegateEvents, insert } from '@solidjs/web';
3
+ import { frameAddress, SINGLE_FLIGHT_HEADER, LIVE_WIRE, deserializeStream, getServerFunctionsCodec, createChunk, deliverFlightData, ERROR_HEADER, hasFlightMetadata, isEventStream, ChunkReader, configureServerFunctionsClient } from '@solidjs/web/server-functions/client';
4
+ import { materializeContainerTrace } from 'solid-js/internal';
4
5
 
5
6
  const ELEMENT_NODE = 1;
6
7
  const TEXT_NODE = 3;
7
8
  const COMMENT_NODE = 8;
8
- const CLAIM_SEAM = Symbol.for("dom-expressions.element-claims");
9
+ const CLAIM_SEAM = Symbol.for("solid.element-claims");
9
10
  const CLAIMED_ELEMENTS = "a[href], form[action]";
10
11
  function claimHandlers() {
11
12
  const handlers = globalThis[CLAIM_SEAM];
@@ -15,6 +16,74 @@ function claimNode(handlers, el) {
15
16
  for (let i = 0; i < handlers.length; i++) handlers[i](el);
16
17
  }
17
18
  const claimedAttr = name => name === "href" || name === "action";
19
+ const BOUND_SEAM = Symbol.for("solid.bnd");
20
+ const boundSeam = globalThis[BOUND_SEAM] || (globalThis[BOUND_SEAM] = {});
21
+ const BND_ATTR = "_bnd";
22
+ const BND_SELECTOR = "[_bnd]";
23
+ function bndMap(el) {
24
+ const s = el.getAttribute(BND_ATTR);
25
+ if (!s) return undefined;
26
+ const map = {};
27
+ for (const entry of s.split(",")) {
28
+ const eq = entry.indexOf("=");
29
+ if (eq < 1) continue;
30
+ const pos = entry.slice(0, eq);
31
+ const prop = decodeURIComponent(entry.slice(eq + 1));
32
+ const prev = map[pos];
33
+ if (prev === undefined) map[pos] = prop;else if (Array.isArray(prev)) prev.push(prop);else map[pos] = [prev, prop];
34
+ }
35
+ return map;
36
+ }
37
+ boundSeam.resolve = (el, type) => {
38
+ const frame = el._$bndFrame;
39
+ if (!frame) return undefined;
40
+ const map = bndMap(el);
41
+ const prop = map && map[type];
42
+ if (typeof prop !== "string") return undefined;
43
+ return claimFn(frame, type, prop);
44
+ };
45
+ function claimFn(frame, pos, prop) {
46
+ const fn = frame.clientProp(prop);
47
+ if (typeof fn === "function") return fn;
48
+ if (fn !== undefined) {
49
+ console.warn(`A server element claims \`${pos}\` from client prop \`${prop}\`, but the mounted ` + `frame's prop is not a function.`);
50
+ }
51
+ return undefined;
52
+ }
53
+ function sweepBound(root, frame, delegate, scope) {
54
+ const isElement = root.nodeType === ELEMENT_NODE;
55
+ if (!isElement && root.nodeType !== 11 ) return;
56
+ let els;
57
+ if (isElement && root.hasAttribute(BND_ATTR)) (els = []).push(root);
58
+ const found = root.querySelectorAll(BND_SELECTOR);
59
+ if (found.length) {
60
+ els || (els = []);
61
+ for (let i = 0; i < found.length; i++) els.push(found[i]);
62
+ }
63
+ if (!els) return;
64
+ const run = () => {
65
+ let types;
66
+ for (const el of els) {
67
+ el._$bndFrame = frame;
68
+ const map = bndMap(el);
69
+ if (!map) continue;
70
+ for (const pos in map) {
71
+ if (pos === "ref") fireRefs(frame, el, map.ref);else (types || (types = [])).push(pos);
72
+ }
73
+ }
74
+ if (types && delegate) delegate(types);
75
+ };
76
+ scope ? scope(run) : run();
77
+ }
78
+ function fireRefs(frame, el, prop) {
79
+ const fired = el._$bndFired || (el._$bndFired = new Set());
80
+ for (const p of Array.isArray(prop) ? prop : [prop]) {
81
+ if (fired.has(p)) continue;
82
+ fired.add(p);
83
+ const fn = claimFn(frame, "ref", p);
84
+ if (fn) fn(el);
85
+ }
86
+ }
18
87
  function claimTree(handlers, root) {
19
88
  const isElement = root.nodeType === ELEMENT_NODE;
20
89
  if (!isElement && root.nodeType !== 11 ) return;
@@ -35,14 +104,18 @@ function chunkToRecords(chunk) {
35
104
  return {
36
105
  "": {
37
106
  kind: "html",
38
- value: chunk.html
107
+ value: chunk.html,
108
+ digest: chunk.digest,
109
+ holes: chunk.holes
39
110
  }
40
111
  };
41
112
  case "fragment":
42
113
  return {
43
114
  [`seg:${chunk.key}`]: {
44
115
  kind: "html",
45
- value: chunk.html
116
+ value: chunk.html,
117
+ digest: chunk.digest,
118
+ holes: chunk.holes
46
119
  }
47
120
  };
48
121
  case "reveal":
@@ -67,7 +140,9 @@ function chunkToRecords(chunk) {
67
140
  return {
68
141
  [`hole:${chunk.key}`]: {
69
142
  kind: "html",
70
- value: chunk.html
143
+ value: chunk.html,
144
+ digest: chunk.digest,
145
+ holes: chunk.holes
71
146
  }
72
147
  };
73
148
  case "attr":
@@ -75,7 +150,8 @@ function chunkToRecords(chunk) {
75
150
  [`attr:${chunk.key}`]: {
76
151
  kind: "attrs",
77
152
  value: chunk.attrs,
78
- removed: chunk.removed
153
+ removed: chunk.removed,
154
+ digest: chunk.digest
79
155
  }
80
156
  };
81
157
  case "complete":
@@ -110,10 +186,22 @@ function createFrameHost(options = {}) {
110
186
  store.version = version;
111
187
  clearStreamRecords(store.records);
112
188
  }
113
- Object.assign(store.records, records);
189
+ const assets = records["seg::assets"];
190
+ const previous = assets && store.records["seg::assets"];
191
+ if (!previous || previous === assets) {
192
+ Object.assign(store.records, records);
193
+ } else {
194
+ for (const name in assets) {
195
+ const values = assets[name];
196
+ if (Array.isArray(values)) {
197
+ previous[name] ? previous[name].push(...values) : previous[name] = values;
198
+ }
199
+ }
200
+ }
114
201
  return true;
115
202
  };
116
203
  return {
204
+ delegate: options.delegate,
117
205
  register(id, frame) {
118
206
  let set = frames.get(id);
119
207
  if (!set) frames.set(id, set = new Set());
@@ -193,6 +281,7 @@ class FrameImpl {
193
281
  #revealed = new Set();
194
282
  #fallbackShown = new Set();
195
283
  #appliedHoles = new Map();
284
+ #have;
196
285
  #slots;
197
286
  #mountedSlots = new Set();
198
287
  #slotCleanups = new Map();
@@ -201,17 +290,25 @@ class FrameImpl {
201
290
  #slotRegions = new Map();
202
291
  #slotResolvedRefs = new Map();
203
292
  #slotNodes = new Map();
204
- #processedAssets = new Set();
293
+ #processedAssets = new WeakSet();
205
294
  #recordRefresh = null;
206
295
  #disposed = false;
207
296
  #styleFlush = () => {
208
297
  if (!this.#disposed) this.#flush();
209
298
  };
210
299
  #claimTree = (node, direct) => {
300
+ if (!direct && node.nodeType !== TEXT_NODE && node.nodeType !== COMMENT_NODE) {
301
+ const o = this.#options;
302
+ sweepBound(node, this, o.delegate || o.host && o.host.delegate, o.ownerScope);
303
+ }
211
304
  const handlers = claimHandlers();
212
305
  if (!handlers) return;
213
306
  this.#scoped(() => direct ? claimNode(handlers, node) : claimTree(handlers, node));
214
307
  };
308
+ clientProp(name) {
309
+ const props = this.#options.props;
310
+ return props ? props[name] : undefined;
311
+ }
215
312
  #scoped(fn) {
216
313
  const scope = this.#options.ownerScope;
217
314
  return scope ? scope(fn) : fn();
@@ -294,6 +391,7 @@ class FrameImpl {
294
391
  this.#revealed.clear();
295
392
  this.#fallbackShown.clear();
296
393
  this.#appliedHoles.clear();
394
+ this.#processedAssets = new WeakSet();
297
395
  this.#errorNotified = false;
298
396
  clearStreamRecords(this.#store, root);
299
397
  }
@@ -305,6 +403,10 @@ class FrameImpl {
305
403
  const reason = this.#hasContent ? "morph" : "materialize";
306
404
  this.#applyRoot(root.value);
307
405
  this.#appliedRootValue = root.value;
406
+ this.#have = root.digest === undefined ? undefined : {
407
+ "": root.digest,
408
+ ...root.holes
409
+ };
308
410
  this.#applied(version, reason);
309
411
  }
310
412
  if (this.#store[":error"] && !this.#errorNotified) {
@@ -344,22 +446,29 @@ class FrameImpl {
344
446
  console.error(`Live hole ${key.slice(5, -6)} failed on the server; latched:`, record);
345
447
  } else if (this.#applyHole(key.slice(5), record.value)) {
346
448
  this.#appliedHoles.set(key, record);
449
+ this.#recordHave(key.slice(5), record);
347
450
  this.#applied(version, "morph");
348
451
  }
349
452
  } else if (key.startsWith("attr:")) {
350
453
  if (this.#applyAttrs(key.slice(5), record.value, record.removed)) {
351
454
  this.#appliedHoles.set(key, record);
455
+ this.#recordHave("lha:" + key.slice(5), record);
352
456
  this.#applied(version, "morph");
353
457
  }
354
458
  }
355
459
  }
356
460
  for (const key in this.#store) {
357
- if (this.#processedAssets.has(key) || !key.endsWith(":assets")) continue;
358
- this.#processedAssets.add(key);
359
461
  const record = this.#store[key];
360
- if (record && record.modules) {
462
+ if (!key.endsWith(":assets") || !record || this.#processedAssets.has(record)) {
463
+ continue;
464
+ }
465
+ this.#processedAssets.add(record);
466
+ if (record.modules) {
361
467
  for (const href of record.modules) ensureModulePreload(href);
362
468
  }
469
+ if (record.preloads) {
470
+ for (const entry of record.preloads) ensurePreload(entry);
471
+ }
363
472
  }
364
473
  this.#syncSlots();
365
474
  }
@@ -634,6 +743,14 @@ class FrameImpl {
634
743
  rebase() {
635
744
  this.#version = undefined;
636
745
  }
746
+ have() {
747
+ return this.#have;
748
+ }
749
+ #recordHave(key, record) {
750
+ if (!this.#have || !record || record.digest === undefined) return;
751
+ this.#have[key] = record.digest;
752
+ if (record.holes) Object.assign(this.#have, record.holes);
753
+ }
637
754
  dispose() {
638
755
  if (this.#disposed) return;
639
756
  const {
@@ -661,7 +778,7 @@ class FrameImpl {
661
778
  parent.insertBefore(fragment, this.#end);
662
779
  this.#hasContent = true;
663
780
  } else {
664
- const claim = claimHandlers() ? this.#claimTree : null;
781
+ const claim = this.#claimTree;
665
782
  const ranges = new Map();
666
783
  this.#collectSlots(ranges);
667
784
  const grafts = [];
@@ -680,8 +797,7 @@ class FrameImpl {
680
797
  }
681
798
  return false;
682
799
  }
683
- const claim = claimHandlers() ? this.#claimTree : null;
684
- reconcileChildren(open.parentNode, parseFragment(html), open, close, claim);
800
+ reconcileChildren(open.parentNode, parseFragment(html), open, close, this.#claimTree);
685
801
  return true;
686
802
  }
687
803
  #applyAttrs(addr, text, removed) {
@@ -689,23 +805,30 @@ class FrameImpl {
689
805
  const el = findLiveTarget(this.#firstContent(), this.#end, n => n.nodeType === ELEMENT_NODE && n.getAttribute("data-lha") === addr);
690
806
  if (!el) return false;
691
807
  const parsed = parseFragment(`<i${text}></i>`).firstChild;
808
+ const keepOpen = preservesOpen(el);
809
+ const current = el.attributes;
810
+ for (let i = current.length - 1; i >= 0; i--) {
811
+ const name = current[i].name;
812
+ if (name === "data-lha" || keepOpen && name === "open") continue;
813
+ if (!parsed || !parsed.hasAttribute(name)) el.removeAttribute(name);
814
+ }
692
815
  if (parsed) {
693
816
  for (let i = 0; i < parsed.attributes.length; i++) {
694
817
  const {
695
818
  name,
696
819
  value
697
820
  } = parsed.attributes[i];
821
+ if (keepOpen && name === "open") continue;
698
822
  if (el.getAttribute(name) !== value) el.setAttribute(name, value);
699
823
  }
700
824
  }
701
- if (removed) for (const name of removed) el.removeAttribute(name);
825
+ if (removed) for (const name of removed) if (!(keepOpen && name === "open")) el.removeAttribute(name);
702
826
  return true;
703
827
  }
704
828
  #clearContent() {
705
829
  removeUntil(this.#parent(), this.#firstContent(), this.#end);
706
830
  }
707
831
  #claimContent() {
708
- if (!claimHandlers()) return;
709
832
  let n = this.#firstContent();
710
833
  while (n && n !== this.#end) {
711
834
  this.#claimTree(n);
@@ -752,6 +875,7 @@ class FrameImpl {
752
875
  });
753
876
  tpl.remove();
754
877
  this.#revealed.add(name);
878
+ this.#recordHave(name, content);
755
879
  return;
756
880
  }
757
881
  const materialized = this.#materialize(content);
@@ -760,6 +884,7 @@ class FrameImpl {
760
884
  tpl.remove();
761
885
  closing && closing.remove();
762
886
  this.#revealed.add(name);
887
+ this.#recordHave(name, content);
763
888
  }
764
889
  #showFallback(name) {
765
890
  const tpl = this.#findPlaceholder(name);
@@ -778,7 +903,7 @@ class FrameImpl {
778
903
  function createFrame(boundary, options) {
779
904
  return new FrameImpl(boundary, null, null, options);
780
905
  }
781
- const FRAME_TAG = "dx-frame";
906
+ const FRAME_TAG = "solid-frame";
782
907
  const FRAME_ID_ATTR = "data-fid";
783
908
  function createFrameElement(options) {
784
909
  const el = makeFrameElement(options.id);
@@ -835,12 +960,36 @@ function parseFragment(html) {
835
960
  template.innerHTML = html;
836
961
  return template.content;
837
962
  }
838
- function findHeadElement(selector, attr, value) {
839
- for (const node of document.head.querySelectorAll(selector)) {
840
- if (node.getAttribute(attr) === value) return node;
963
+ const PRELOAD_QUALIFIERS = ["as", "crossorigin", "type", "media", "imagesrcset", "imagesizes"];
964
+ function qualifierValue(name, value) {
965
+ if (value == null) return null;
966
+ if (name === "imagesrcset" || name === "imagesizes") return value === "" ? null : value;
967
+ if (name === "as") return value.replace(/[A-Z]/g, c => String.fromCharCode(c.charCodeAt(0) + 32));
968
+ if (name !== "crossorigin") return value;
969
+ return value.length === 15 && value.toLowerCase() === "use-credentials" ? "use-credentials" : "anonymous";
970
+ }
971
+ function findHeadElement(selector, attr, value, qualifiers) {
972
+ candidate: for (const node of document.head.querySelectorAll(selector)) {
973
+ if (node.getAttribute(attr) !== value) continue;
974
+ if (!qualifiers) return node;
975
+ for (let i = 0; i < PRELOAD_QUALIFIERS.length; i++) {
976
+ const name = PRELOAD_QUALIFIERS[i];
977
+ if (qualifierValue(name, node.getAttribute(name)) !== qualifierValue(name, qualifiers[name] ?? null)) continue candidate;
978
+ }
979
+ return node;
841
980
  }
842
981
  return null;
843
982
  }
983
+ function ensurePreload(entry) {
984
+ const attrs = entry.attrs;
985
+ const href = entry.href;
986
+ if (findHeadElement('link[rel="preload"]', "href", href || null, attrs)) return;
987
+ const link = document.createElement("link");
988
+ link.rel = "preload";
989
+ for (const name in attrs) link.setAttribute(name, attrs[name]);
990
+ if (href) link.setAttribute("href", href);
991
+ document.head.appendChild(link);
992
+ }
844
993
  function ensureStylesheet(entry, onSettle) {
845
994
  const href = typeof entry === "string" ? entry : entry.href;
846
995
  let link = findHeadElement('link[rel="stylesheet"]', "href", href);
@@ -1059,7 +1208,16 @@ function devCheckRange(start, id) {
1059
1208
  if (n.nodeType === COMMENT_NODE && n.data === end) return;
1060
1209
  n = n.nextSibling;
1061
1210
  }
1062
- console.error(`Frame slot range "${id}" is missing its end marker (<!--${end}-->) among its start ` + `marker's siblings. Slots after it in this content cannot be discovered. Likely causes: ` + `invalid HTML nesting split the range during parsing (e.g. a block element inside <p>), ` + `or an HTML-rewriting layer (CDN/minifier/translator) removed or moved the comment — ` + `serve frame documents with Cache-Control: no-transform.`, start);
1211
+ DEV.report(OBSERVE.diagnostics.emit({
1212
+ code: "FRAME_MARKER_CORRUPTED",
1213
+ kind: "ssr",
1214
+ severity: "error",
1215
+ message: `[FRAME_MARKER_CORRUPTED] Frame slot range "${id}" is missing its end marker (<!--${end}-->) among its start ` + `marker's siblings. Slots after it in this content cannot be discovered. Likely causes: ` + `invalid HTML nesting split the range during parsing (e.g. a block element inside <p>), ` + `or an HTML-rewriting layer (CDN/minifier/translator) removed or moved the comment — ` + `serve frame documents with Cache-Control: no-transform.`,
1216
+ data: {
1217
+ slot: id,
1218
+ end
1219
+ }
1220
+ }, null));
1063
1221
  }
1064
1222
  function findRangeStart(from, id, bound) {
1065
1223
  const target = `slot:${id}:start`;
@@ -1214,38 +1372,187 @@ function stashRange(frag, start, id) {
1214
1372
  return null;
1215
1373
  }
1216
1374
 
1375
+ const RECORDS = Symbol.for("@solidjs/signals/observe/records");
1376
+ function records() {
1377
+ return globalThis[RECORDS];
1378
+ }
1379
+ function frameCensus(event, type, own) {
1380
+ event.chunks++;
1381
+ switch (type) {
1382
+ case "html":
1383
+ if (!own) event.regions++;else if (event.shellMs === undefined) event.shellMs = performance.now() - event.at;
1384
+ break;
1385
+ case "fragment":
1386
+ event.fragments++;
1387
+ break;
1388
+ case "slot":
1389
+ event.slots++;
1390
+ break;
1391
+ case "error":
1392
+ event.errors++;
1393
+ break;
1394
+ }
1395
+ }
1396
+ function observeFrameApply(response) {
1397
+ const channel = records();
1398
+ if (channel === undefined || !channel.observed("frame")) return undefined;
1399
+ let current;
1400
+ const close = (outcome, error) => {
1401
+ const open = current;
1402
+ current = undefined;
1403
+ open.event.durationMs = performance.now() - open.event.at;
1404
+ open.event.outcome = outcome;
1405
+ const live = {
1406
+ response
1407
+ };
1408
+ if (error !== undefined) live.error = error;
1409
+ channel.emit("frame", open.event, live);
1410
+ };
1411
+ return {
1412
+ chunk(chunk, wireId) {
1413
+ if (chunk.type === "start") {
1414
+ if (current !== undefined) close("truncated");
1415
+ const event = {
1416
+ side: "client",
1417
+ id: wireId,
1418
+ version: chunk.version,
1419
+ at: performance.now(),
1420
+ durationMs: 0,
1421
+ outcome: "complete",
1422
+ chunks: 0,
1423
+ fragments: 0,
1424
+ slots: 0,
1425
+ regions: 0,
1426
+ errors: 0
1427
+ };
1428
+ if (chunk.id !== wireId) event.address = chunk.id;
1429
+ current = {
1430
+ event,
1431
+ applied: chunk.id
1432
+ };
1433
+ return;
1434
+ }
1435
+ if (current === undefined) return;
1436
+ if (chunk.type === "complete") {
1437
+ if (chunk.id === current.applied) close("complete");
1438
+ return;
1439
+ }
1440
+ frameCensus(current.event, chunk.type, chunk.id === current.applied);
1441
+ },
1442
+ end(error) {
1443
+ if (current !== undefined) close(error !== undefined ? "error" : "truncated", error);
1444
+ }
1445
+ };
1446
+ }
1447
+
1217
1448
  const FRAME_STREAM_HEADER = "X-Frame-Stream";
1449
+ const FRAME_HAVE_HEADER = "X-Frame-Have";
1450
+ const FRAME_HAVE_BUDGET = 4096;
1451
+ function encodeHaveList(have) {
1452
+ let out = "";
1453
+ for (const key in have) {
1454
+ const digest = have[key];
1455
+ if (typeof digest !== "string") continue;
1456
+ out += (out ? "," : "") + key + "=" + digest;
1457
+ if (out.length > FRAME_HAVE_BUDGET) return undefined;
1458
+ }
1459
+ return out || undefined;
1460
+ }
1218
1461
  function isFrameStreamResponse(response) {
1219
1462
  return response.headers.has(FRAME_STREAM_HEADER);
1220
1463
  }
1221
- async function applyFrameResponse(response, host, options = {}) {
1464
+ const applyFrameResponse = observedApplyFrameResponse ;
1465
+ async function observedApplyFrameResponse(response, host, options = {}) {
1466
+ const observation = observeFrameApply(response);
1467
+ if (!observation) return applyFrames(response, host, options);
1468
+ let applied;
1469
+ try {
1470
+ applied = await applyFrames(response, host, options, observation);
1471
+ } catch (error) {
1472
+ observation.end(error);
1473
+ throw error;
1474
+ }
1475
+ observation.end();
1476
+ return applied;
1477
+ }
1478
+ function applyFrames(response, host, options = {}, observation) {
1222
1479
  const rootId = response.headers.get(FRAME_STREAM_HEADER) ?? "";
1223
1480
  const as = options.as;
1224
1481
  const version = options.version;
1225
1482
  const perFrame = typeof version === "function" ? new Map() : null;
1226
- const reader = new ChunkReader(response.body);
1227
- let result = await reader.next();
1228
- while (!result.done) {
1229
- const chunk = JSON.parse(result.value);
1230
- if (chunk.type === "outcome") {
1231
- if (options.onOutcome) options.onOutcome(chunk.payload);
1232
- } else {
1233
- if (as !== undefined && chunk.id === rootId) chunk.id = as;
1234
- if (perFrame) {
1235
- let v = perFrame.get(chunk.id);
1236
- if (v === undefined) perFrame.set(chunk.id, v = version(chunk.id));
1237
- chunk.version = v;
1238
- } else if (version !== undefined) chunk.version = version;
1239
- if (chunk.type === "data" && host.prepareData) await host.prepareData();
1240
- host.apply(chunk);
1241
- }
1242
- result = await reader.next();
1243
- }
1244
- return as !== undefined ? as : rootId;
1245
- }
1246
- const SERVER_COMPONENT = /*#__PURE__*/Symbol.for("dom-expressions.server-component");
1247
- const SERVER_COMPONENT_ADDRESS = /*#__PURE__*/Symbol.for("dom-expressions.server-component-address");
1248
- const COMPONENT_BINDING = /*#__PURE__*/Symbol.for("dom-expressions.component-binding");
1483
+ const wire = options[LIVE_WIRE];
1484
+ const connection = wire && wire.connection;
1485
+ const reader = wire && isEventStream(response) ? wire.open(response.body) : new ChunkReader(response.body);
1486
+ const open = new Map();
1487
+ let cancelled;
1488
+ let resolveEnd;
1489
+ if (connection) {
1490
+ connection.ended = new Promise(resolve => resolveEnd = resolve);
1491
+ connection.cancel = reason => {
1492
+ if (cancelled !== undefined) return;
1493
+ cancelled = reason;
1494
+ try {
1495
+ const r = reader.cancel && reader.cancel(reason);
1496
+ if (r && typeof r.then === "function") r.then(undefined, () => {});
1497
+ } catch {}
1498
+ };
1499
+ }
1500
+ const errorRecord = (id, error) => ({
1501
+ type: "error",
1502
+ id,
1503
+ version: open.get(id),
1504
+ error: {
1505
+ message: String(error && error.message)
1506
+ }
1507
+ });
1508
+ const drain = async () => {
1509
+ let result = await reader.next();
1510
+ while (!result.done) {
1511
+ const chunk = JSON.parse(result.value);
1512
+ if (chunk.type === "outcome") {
1513
+ if (options.onOutcome) options.onOutcome(chunk.payload);
1514
+ } else {
1515
+ const wireId = chunk.id;
1516
+ if (as !== undefined && chunk.id === rootId) chunk.id = as;
1517
+ if (perFrame) {
1518
+ let v = perFrame.get(chunk.id);
1519
+ if (v === undefined) perFrame.set(chunk.id, v = version(chunk.id));
1520
+ chunk.version = v;
1521
+ } else if (version !== undefined) chunk.version = version;
1522
+ if (chunk.type === "start") open.set(chunk.id, chunk.version);else if (chunk.type === "complete" || chunk.type === "error" && !chunk.key) open.delete(chunk.id);
1523
+ if (observation) observation.chunk(chunk, wireId);
1524
+ if (chunk.type === "data" && host.prepareData) await host.prepareData();
1525
+ host.apply(chunk);
1526
+ }
1527
+ result = await reader.next();
1528
+ }
1529
+ };
1530
+ const end = error => {
1531
+ const dead = error || cancelled || new Error("Frame stream ended before the frame completed.");
1532
+ const sweep = () => {
1533
+ for (const id of open.keys()) host.apply(errorRecord(id, dead));
1534
+ };
1535
+ if (connection) {
1536
+ connection.done = true;
1537
+ resolveEnd({
1538
+ open: open.size,
1539
+ error: dead,
1540
+ sweep,
1541
+ close: () => {}
1542
+ });
1543
+ } else if (error === undefined) sweep();
1544
+ };
1545
+ return drain().then(() => {
1546
+ end(undefined);
1547
+ return as !== undefined ? as : rootId;
1548
+ }, error => {
1549
+ end(error);
1550
+ throw error;
1551
+ });
1552
+ }
1553
+ const SERVER_COMPONENT = /*#__PURE__*/Symbol.for("solid.server-component");
1554
+ const SERVER_COMPONENT_ADDRESS = /*#__PURE__*/Symbol.for("solid.server-component-address");
1555
+ const COMPONENT_BINDING = /*#__PURE__*/Symbol.for("solid.component-binding");
1249
1556
  let resolveServerComponent;
1250
1557
  function parseServerComponent(value, ctx) {
1251
1558
  return {
@@ -1254,7 +1561,7 @@ function parseServerComponent(value, ctx) {
1254
1561
  };
1255
1562
  }
1256
1563
  const ServerComponentPlugin = {
1257
- tag: "dom-expressions/server-component",
1564
+ tag: "solid/server-component",
1258
1565
  test(value) {
1259
1566
  return typeof value === "function" && SERVER_COMPONENT in value;
1260
1567
  },
@@ -1293,9 +1600,7 @@ function createServerComponentHandler({
1293
1600
  host,
1294
1601
  component,
1295
1602
  onStream,
1296
- intercept,
1297
- consumer = getFlightDataConsumer,
1298
- codec = getServerFunctionsCodec
1603
+ intercept
1299
1604
  }) {
1300
1605
  const byFn = new Map();
1301
1606
  const componentFor = fnId => {
@@ -1319,17 +1624,45 @@ function createServerComponentHandler({
1319
1624
  };
1320
1625
  resolveServerComponent = (id, address) => bindingFor(address, id);
1321
1626
  const versions = new Map();
1627
+ const connections = new Map();
1322
1628
  const bump = address => {
1323
1629
  const version = (versions.get(address) || 0) + 1;
1324
1630
  versions.set(address, version);
1631
+ const connection = connections.get(address);
1632
+ if (connection) {
1633
+ connections.delete(address);
1634
+ connection.cancel(new Error("Superseded by a newer response for the address."));
1635
+ }
1325
1636
  return version;
1326
1637
  };
1638
+ const hold = (address, connection) => {
1639
+ connections.set(address, connection);
1640
+ connection.ended.then(() => {
1641
+ if (connections.get(address) === connection) connections.delete(address);
1642
+ });
1643
+ };
1327
1644
  return {
1328
1645
  intercept: intercept && (info => {
1329
1646
  const hit = intercept(info);
1330
1647
  if (hit === undefined) return undefined;
1331
- return bindingFor(frameAddress(info.id, info.args), info.id);
1648
+ const binding = () => bindingFor(frameAddress(info.id, info.args), info.id);
1649
+ if (typeof hit.then === "function") return hit.then(landed => landed ? binding() : undefined);
1650
+ return binding();
1332
1651
  }),
1652
+ resume(info) {
1653
+ const address = frameAddress(info.id, info.args);
1654
+ const version = versions.get(address);
1655
+ const frame = host.get(address);
1656
+ const have = frame && frame.have ? frame.have() : undefined;
1657
+ if (version === undefined && !have) return undefined;
1658
+ const encoded = have && encodeHaveList(have);
1659
+ return {
1660
+ position: String(version || 0),
1661
+ headers: encoded ? {
1662
+ [FRAME_HAVE_HEADER]: encoded
1663
+ } : undefined
1664
+ };
1665
+ },
1333
1666
  handle(response, ctx) {
1334
1667
  if (!isFrameStreamResponse(response)) return undefined;
1335
1668
  const address = frameAddress(ctx.id, ctx.args);
@@ -1337,6 +1670,26 @@ function createServerComponentHandler({
1337
1670
  if (response.headers.has(SINGLE_FLIGHT_HEADER)) {
1338
1671
  return applyFlightResponse(response, address, binding);
1339
1672
  }
1673
+ const wire = ctx[LIVE_WIRE];
1674
+ const connection = wire && wire.connection;
1675
+ if (connection) {
1676
+ const current = connections.get(address);
1677
+ if (current && !current.done) {
1678
+ connection.ended = current.ended;
1679
+ const body = response.body;
1680
+ if (body) body.cancel().catch(() => {});
1681
+ return binding;
1682
+ }
1683
+ const version = bump(address);
1684
+ if (onStream) onStream(address, version, response);
1685
+ applyFrameResponse(response, host, {
1686
+ as: address,
1687
+ version,
1688
+ [LIVE_WIRE]: wire
1689
+ }).catch(() => {});
1690
+ hold(address, connection);
1691
+ return binding;
1692
+ }
1340
1693
  const version = bump(address);
1341
1694
  if (onStream) onStream(address, version, response);
1342
1695
  applyFrameResponse(response, host, {
@@ -1372,7 +1725,7 @@ function createServerComponentHandler({
1372
1725
  feed = controller;
1373
1726
  }
1374
1727
  });
1375
- const payload = deserializeStream(new Response(source), flightCodec(codec()));
1728
+ const payload = deserializeStream(new Response(source), flightCodec(getServerFunctionsCodec()));
1376
1729
  let carried = false;
1377
1730
  await applyFrameResponse(response, host, {
1378
1731
  as,
@@ -1389,18 +1742,15 @@ function createServerComponentHandler({
1389
1742
  feed.close();
1390
1743
  if (!carried) throw new Error("Single-flight frame response carried no outcome");
1391
1744
  const envelope = await payload;
1392
- const deliver = consumer();
1393
- if (deliver) await deliver(envelope.data, {
1394
- response
1395
- });
1396
- if (response.headers.has(ERROR_HEADER) && !response.headers.has("Location") && !response.headers.has(REVALIDATE_HEADER)) {
1745
+ await deliverFlightData(response, envelope.data);
1746
+ if (response.headers.has(ERROR_HEADER) && !hasFlightMetadata(response)) {
1397
1747
  throw envelope.value;
1398
1748
  }
1399
1749
  return rootId ? binding : envelope.value;
1400
1750
  }
1401
1751
  }
1402
1752
 
1403
- const STATE = Symbol.for("dom-expressions.container-trace-state");
1753
+ const STATE = Symbol.for("solid.container-trace-state");
1404
1754
  const state = globalThis[STATE] || (globalThis[STATE] = {
1405
1755
  materialized: new WeakMap(),
1406
1756
  materializedValues: new WeakSet()
@@ -1421,7 +1771,9 @@ function isMaterializedContainer(value) {
1421
1771
  return value !== null && typeof value === "object" && state.materializedValues.has(value);
1422
1772
  }
1423
1773
  function isContainerTraceMarker(value) {
1424
- return value != null && typeof value === "object" && value.$tr != null && typeof value.$tr[Symbol.asyncIterator] === "function";
1774
+ if (value == null || typeof value !== "object" || value.$tr == null) return false;
1775
+ const tr = value.$tr;
1776
+ return tr.__SEROVAL_STREAM__ === true || typeof tr[Symbol.asyncIterator] === "function";
1425
1777
  }
1426
1778
  function reviveContainerTraces(value) {
1427
1779
  if (!state.materializeTrace || value == null || typeof value !== "object") return value;
@@ -1467,7 +1819,8 @@ function getFrameHost() {
1467
1819
  applyData: c => tableFor(c.id)?.apply(c),
1468
1820
  resolve: (ref, id) => tableFor(id)?.resolve(ref),
1469
1821
  revive: reviveContainerTraces,
1470
- isContainer: isMaterializedContainer
1822
+ isContainer: isMaterializedContainer,
1823
+ delegate: delegateEvents
1471
1824
  });
1472
1825
  }
1473
1826
  return sharedHost;
@@ -1543,7 +1896,16 @@ function slotArgsProxy(args) {
1543
1896
  if (!isAsyncValue(v)) return v;
1544
1897
  let read = asyncReads.get(key);
1545
1898
  if (!read) {
1546
- const make = () => createMemo(() => args()[key]);
1899
+ const make = () => createMemo(() => {
1900
+ const raw = args()[key];
1901
+ if (raw != null && typeof raw.then === "function") {
1902
+ if (raw.s === 1) return raw.v;
1903
+ if (raw.s === 2) throw raw.v;
1904
+ }
1905
+ return raw;
1906
+ }, {
1907
+ transparent: true
1908
+ });
1547
1909
  read = owner ? runWithOwner(owner, make) : make();
1548
1910
  asyncReads.set(key, read);
1549
1911
  }
@@ -1662,6 +2024,7 @@ function boundaryComponent(host, fnId) {
1662
2024
  host,
1663
2025
  id,
1664
2026
  slots: slotsFor(props),
2027
+ props,
1665
2028
  ownerScope: boundaryScope(owner),
1666
2029
  reveal: revealSeam(owner),
1667
2030
  onApply: () => {
@@ -1725,6 +2088,19 @@ function findBoundaryElement(id) {
1725
2088
  return boundaryIndex.get(id);
1726
2089
  }
1727
2090
  const boundaryWaiters = new Map();
2091
+ const arrivals = new Map();
2092
+ function awaitBoundary(id) {
2093
+ let arrival = arrivals.get(id);
2094
+ if (!arrival) {
2095
+ let resolve;
2096
+ const promise = new Promise(r => resolve = r);
2097
+ arrivals.set(id, arrival = {
2098
+ promise,
2099
+ resolve
2100
+ });
2101
+ }
2102
+ return arrival.promise;
2103
+ }
1728
2104
  function boundaryMayArrive() {
1729
2105
  const hy = globalThis._$HY;
1730
2106
  if (!hy) return false;
@@ -1738,7 +2114,7 @@ function installRevealHook() {
1738
2114
  if (!boundaryIndex) return;
1739
2115
  const root = parent || (typeof document !== "undefined" ? document.body : null);
1740
2116
  if (root) indexBoundaries(root);
1741
- if (!boundaryWaiters.size) return;
2117
+ if (!boundaryWaiters.size && !arrivals.size) return;
1742
2118
  const exhausted = hy.done && !hy.fr.pending();
1743
2119
  for (const [id, notify] of boundaryWaiters) {
1744
2120
  const el = boundaryIndex && boundaryIndex.get(id);
@@ -1746,6 +2122,12 @@ function installRevealHook() {
1746
2122
  boundaryWaiters.delete(id);
1747
2123
  notify(el);
1748
2124
  }
2125
+ for (const [id, arrival] of arrivals) {
2126
+ const el = boundaryIndex && boundaryIndex.get(id);
2127
+ if (!el && !exhausted) continue;
2128
+ arrivals.delete(id);
2129
+ arrival.resolve(!!el);
2130
+ }
1749
2131
  });
1750
2132
  }
1751
2133
  function documentBoundary(host, id, props, binding) {
@@ -1846,6 +2228,7 @@ function adoptBoundary(host, id, el, props, binding) {
1846
2228
  host,
1847
2229
  id: address,
1848
2230
  slots: slotsFor(props),
2231
+ props,
1849
2232
  ownerScope: boundaryScope(owner),
1850
2233
  reveal: revealSeam(owner),
1851
2234
  onApply: () => {
@@ -1887,12 +2270,18 @@ function installServerComponents(host = getFrameHost()) {
1887
2270
  g._$SC = {
1888
2271
  c: {},
1889
2272
  a: {},
2273
+ b: {},
1890
2274
  r(i, a) {
1891
- if (a) {
1892
- g._$SC.a[a] = i;
1893
- g._$SC.reg && g._$SC.reg(a, i);
1894
- }
1895
- return g._$SC.c[i] || (g._$SC.c[i] = (p, b) => g._$SC.impl(i, p, b));
2275
+ const c = g._$SC.c[i] || (g._$SC.c[i] = (p, b) => g._$SC.impl(i, p, b));
2276
+ if (!a) return c;
2277
+ g._$SC.a[a] = i;
2278
+ g._$SC.reg && g._$SC.reg(a, i);
2279
+ return g._$SC.b[a] || (g._$SC.b[a] = Object.assign(p => c(p, () => a), {
2280
+ [COMPONENT_BINDING]: {
2281
+ component: c,
2282
+ address: a
2283
+ }
2284
+ }));
1896
2285
  }
1897
2286
  };
1898
2287
  }
@@ -1905,8 +2294,11 @@ function installServerComponents(host = getFrameHost()) {
1905
2294
  intercept: ({
1906
2295
  id
1907
2296
  }) => {
1908
- if (claimedBoundaries.has(id) || !findBoundaryElement(id)) return undefined;
1909
- return g._$SC.r(id);
2297
+ if (claimedBoundaries.has(id)) return undefined;
2298
+ if (findBoundaryElement(id)) return true;
2299
+ if (!boundaryMayArrive()) return undefined;
2300
+ installRevealHook();
2301
+ return awaitBoundary(id);
1910
2302
  }
1911
2303
  });
1912
2304
  const showing = (address, id) => handler.showing(address, id);
@@ -1918,4 +2310,4 @@ function installServerComponents(host = getFrameHost()) {
1918
2310
  });
1919
2311
  }
1920
2312
 
1921
- export { FRAME_APPLIED_EVENT, FRAME_STREAM_HEADER, applyFrameResponse, asyncArg, createFrame, createFrameElement, createFrameHost, createServerComponentHandler, getFrameHost, installServerComponents, isFrameStreamResponse };
2313
+ export { FRAME_APPLIED_EVENT, FRAME_HAVE_BUDGET, FRAME_HAVE_HEADER, FRAME_STREAM_HEADER, applyFrameResponse, asyncArg, createFrame, createFrameElement, createFrameHost, createServerComponentHandler, getFrameHost, installServerComponents, isFrameStreamResponse };