@solidjs/web 2.0.0-rc.0 → 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 (108) hide show
  1. package/README.md +1 -1
  2. package/dist/server.dev.js +4472 -0
  3. package/dist/server.js +1363 -224
  4. package/dist/{server.cjs → server.observe.js} +1563 -424
  5. package/dist/{dev.cjs → web.dev.js} +708 -365
  6. package/dist/web.js +460 -144
  7. package/dist/{dev.js → web.observe.js} +511 -213
  8. package/frames/dist/client.dev.js +464 -72
  9. package/frames/dist/client.js +364 -71
  10. package/frames/dist/{client.dev.cjs → client.observe.js} +487 -134
  11. package/frames/dist/server.dev.js +1713 -0
  12. package/frames/dist/server.js +553 -2495
  13. package/frames/dist/server.observe.js +1713 -0
  14. package/frames/package.json +2 -25
  15. package/package.json +214 -254
  16. package/performance-tracks/dist/performance-tracks.dev.js +678 -0
  17. package/performance-tracks/dist/performance-tracks.js +6 -0
  18. package/performance-tracks/dist/performance-tracks.observe.js +666 -0
  19. package/performance-tracks/package.json +7 -0
  20. package/performance-tracks/types/index.d.ts +67 -0
  21. package/serialization/decode/package.json +2 -15
  22. package/serialization/dist/decode.js +101 -12
  23. package/serialization/dist/serialization.js +112 -20
  24. package/serialization/package.json +2 -15
  25. package/serialization/types/index.d.ts +76 -157
  26. package/serialization/types/serializer-decode.d.ts +149 -112
  27. package/serialization/types/serializer.d.ts +101 -0
  28. package/server-functions/dist/client.dev.js +1364 -0
  29. package/server-functions/dist/client.js +745 -85
  30. package/server-functions/dist/client.observe.js +1343 -0
  31. package/server-functions/dist/server.dev.js +2203 -175
  32. package/server-functions/dist/server.js +2111 -176
  33. package/server-functions/dist/server.observe.js +3043 -0
  34. package/server-functions/package.json +2 -35
  35. package/server-functions/rich-args/package.json +2 -15
  36. package/storage/package.json +2 -15
  37. package/types/client.d.ts +193 -288
  38. package/types/constants.d.ts +20 -0
  39. package/types/cookies.d.ts +32 -84
  40. package/types/diagnostics.d.ts +56 -0
  41. package/types/frames/client.d.ts +1 -1
  42. package/types/frames/frame-client.d.ts +323 -259
  43. package/types/frames/frame-container-plugin.d.ts +72 -0
  44. package/types/frames/frame-sink.d.ts +101 -158
  45. package/types/frames/frame-transport.d.ts +192 -190
  46. package/types/frames/serializer-decode.d.ts +219 -0
  47. package/types/frames/serializer.d.ts +76 -157
  48. package/types/frames/server.d.ts +1 -1
  49. package/types/head.d.ts +19 -0
  50. package/types/index.d.ts +62 -76
  51. package/types/index.server.d.ts +174 -0
  52. package/types/jsx.d.ts +33 -26
  53. package/types/observe.d.ts +358 -0
  54. package/types/reconcile.d.ts +1 -0
  55. package/types/render.d.ts +9 -0
  56. package/types/response.d.ts +75 -150
  57. package/types/serializer-decode.d.ts +149 -112
  58. package/types/serializer.d.ts +76 -157
  59. package/types/server-functions/client.d.ts +202 -174
  60. package/types/server-functions/flash.d.ts +28 -30
  61. package/types/server-functions/registry.d.ts +102 -0
  62. package/types/server-functions/rich-args.d.ts +1 -10
  63. package/types/server-functions/server.d.ts +518 -454
  64. package/types/server-functions/shared.d.ts +366 -425
  65. package/types/server-mock.d.ts +110 -13
  66. package/types/server-observe.d.ts +77 -0
  67. package/types/server.d.ts +425 -425
  68. package/types/trace.d.ts +127 -0
  69. package/LICENSE +0 -21
  70. package/dist/web.cjs +0 -2007
  71. package/frames/dist/client.cjs +0 -1916
  72. package/frames/dist/server.cjs +0 -3667
  73. package/serialization/dist/decode.cjs +0 -110
  74. package/serialization/dist/serialization.cjs +0 -232
  75. package/serialization/types-cjs/index.d.cts +0 -182
  76. package/serialization/types-cjs/package.json +0 -3
  77. package/serialization/types-cjs/serializer-decode.d.cts +0 -182
  78. package/server-functions/dist/client.cjs +0 -646
  79. package/server-functions/dist/rich-args.cjs +0 -11
  80. package/server-functions/dist/server.cjs +0 -1077
  81. package/server-functions/dist/server.dev.cjs +0 -1077
  82. package/storage/dist/storage.cjs +0 -12
  83. package/storage/types-cjs/index.d.cts +0 -28
  84. package/storage/types-cjs/package.json +0 -3
  85. package/types/core.d.ts +0 -6
  86. package/types-cjs/client.d.cts +0 -337
  87. package/types-cjs/cookies.d.cts +0 -93
  88. package/types-cjs/core.d.cts +0 -6
  89. package/types-cjs/frames/client.d.cts +0 -36
  90. package/types-cjs/frames/frame-client.d.cts +0 -338
  91. package/types-cjs/frames/frame-sink.d.cts +0 -194
  92. package/types-cjs/frames/frame-transport.d.cts +0 -222
  93. package/types-cjs/frames/serializer.d.cts +0 -182
  94. package/types-cjs/frames/server.d.cts +0 -52
  95. package/types-cjs/index.d.cts +0 -230
  96. package/types-cjs/jsx-properties.d.cts +0 -93
  97. package/types-cjs/jsx.d.cts +0 -4150
  98. package/types-cjs/package.json +0 -3
  99. package/types-cjs/response.d.cts +0 -174
  100. package/types-cjs/serializer-decode.d.cts +0 -182
  101. package/types-cjs/serializer.d.cts +0 -182
  102. package/types-cjs/server-functions/client.d.cts +0 -201
  103. package/types-cjs/server-functions/flash.d.cts +0 -38
  104. package/types-cjs/server-functions/rich-args.d.cts +0 -10
  105. package/types-cjs/server-functions/server.d.cts +0 -588
  106. package/types-cjs/server-functions/shared.d.cts +0 -523
  107. package/types-cjs/server-mock.d.cts +0 -277
  108. package/types-cjs/server.d.cts +0 -523
@@ -1,13 +1,12 @@
1
- 'use strict';
2
-
3
- var solidJs = require('solid-js');
4
- var web = require('@solidjs/web');
5
- var client = require('@solidjs/web/server-functions/client');
1
+ import * as core from 'solid-js';
2
+ import { getOwner, onCleanup, createMemo, runWithOwner, createSignal, createRenderEffect, createLoadingBoundary, createOwner, sharedConfig } from 'solid-js';
3
+ import { delegateEvents, insert } from '@solidjs/web';
4
+ import { frameAddress, SINGLE_FLIGHT_HEADER, LIVE_WIRE, deserializeStream, getServerFunctionsCodec, createChunk, deliverFlightData, ERROR_HEADER, hasFlightMetadata, isEventStream, ChunkReader, configureServerFunctionsClient } from '@solidjs/web/server-functions/client';
6
5
 
7
6
  const ELEMENT_NODE = 1;
8
7
  const TEXT_NODE = 3;
9
8
  const COMMENT_NODE = 8;
10
- const CLAIM_SEAM = Symbol.for("dom-expressions.element-claims");
9
+ const CLAIM_SEAM = Symbol.for("solid.element-claims");
11
10
  const CLAIMED_ELEMENTS = "a[href], form[action]";
12
11
  function claimHandlers() {
13
12
  const handlers = globalThis[CLAIM_SEAM];
@@ -17,6 +16,71 @@ function claimNode(handlers, el) {
17
16
  for (let i = 0; i < handlers.length; i++) handlers[i](el);
18
17
  }
19
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
+ return undefined;
49
+ }
50
+ function sweepBound(root, frame, delegate, scope) {
51
+ const isElement = root.nodeType === ELEMENT_NODE;
52
+ if (!isElement && root.nodeType !== 11 ) return;
53
+ let els;
54
+ if (isElement && root.hasAttribute(BND_ATTR)) (els = []).push(root);
55
+ const found = root.querySelectorAll(BND_SELECTOR);
56
+ if (found.length) {
57
+ els || (els = []);
58
+ for (let i = 0; i < found.length; i++) els.push(found[i]);
59
+ }
60
+ if (!els) return;
61
+ const run = () => {
62
+ let types;
63
+ for (const el of els) {
64
+ el._$bndFrame = frame;
65
+ const map = bndMap(el);
66
+ if (!map) continue;
67
+ for (const pos in map) {
68
+ if (pos === "ref") fireRefs(frame, el, map.ref);else (types || (types = [])).push(pos);
69
+ }
70
+ }
71
+ if (types && delegate) delegate(types);
72
+ };
73
+ scope ? scope(run) : run();
74
+ }
75
+ function fireRefs(frame, el, prop) {
76
+ const fired = el._$bndFired || (el._$bndFired = new Set());
77
+ for (const p of Array.isArray(prop) ? prop : [prop]) {
78
+ if (fired.has(p)) continue;
79
+ fired.add(p);
80
+ const fn = claimFn(frame, "ref", p);
81
+ if (fn) fn(el);
82
+ }
83
+ }
20
84
  function claimTree(handlers, root) {
21
85
  const isElement = root.nodeType === ELEMENT_NODE;
22
86
  if (!isElement && root.nodeType !== 11 ) return;
@@ -37,14 +101,18 @@ function chunkToRecords(chunk) {
37
101
  return {
38
102
  "": {
39
103
  kind: "html",
40
- value: chunk.html
104
+ value: chunk.html,
105
+ digest: chunk.digest,
106
+ holes: chunk.holes
41
107
  }
42
108
  };
43
109
  case "fragment":
44
110
  return {
45
111
  [`seg:${chunk.key}`]: {
46
112
  kind: "html",
47
- value: chunk.html
113
+ value: chunk.html,
114
+ digest: chunk.digest,
115
+ holes: chunk.holes
48
116
  }
49
117
  };
50
118
  case "reveal":
@@ -69,7 +137,9 @@ function chunkToRecords(chunk) {
69
137
  return {
70
138
  [`hole:${chunk.key}`]: {
71
139
  kind: "html",
72
- value: chunk.html
140
+ value: chunk.html,
141
+ digest: chunk.digest,
142
+ holes: chunk.holes
73
143
  }
74
144
  };
75
145
  case "attr":
@@ -77,7 +147,8 @@ function chunkToRecords(chunk) {
77
147
  [`attr:${chunk.key}`]: {
78
148
  kind: "attrs",
79
149
  value: chunk.attrs,
80
- removed: chunk.removed
150
+ removed: chunk.removed,
151
+ digest: chunk.digest
81
152
  }
82
153
  };
83
154
  case "complete":
@@ -112,10 +183,22 @@ function createFrameHost(options = {}) {
112
183
  store.version = version;
113
184
  clearStreamRecords(store.records);
114
185
  }
115
- Object.assign(store.records, records);
186
+ const assets = records["seg::assets"];
187
+ const previous = assets && store.records["seg::assets"];
188
+ if (!previous || previous === assets) {
189
+ Object.assign(store.records, records);
190
+ } else {
191
+ for (const name in assets) {
192
+ const values = assets[name];
193
+ if (Array.isArray(values)) {
194
+ previous[name] ? previous[name].push(...values) : previous[name] = values;
195
+ }
196
+ }
197
+ }
116
198
  return true;
117
199
  };
118
200
  return {
201
+ delegate: options.delegate,
119
202
  register(id, frame) {
120
203
  let set = frames.get(id);
121
204
  if (!set) frames.set(id, set = new Set());
@@ -195,6 +278,7 @@ class FrameImpl {
195
278
  #revealed = new Set();
196
279
  #fallbackShown = new Set();
197
280
  #appliedHoles = new Map();
281
+ #have;
198
282
  #slots;
199
283
  #mountedSlots = new Set();
200
284
  #slotCleanups = new Map();
@@ -203,17 +287,25 @@ class FrameImpl {
203
287
  #slotRegions = new Map();
204
288
  #slotResolvedRefs = new Map();
205
289
  #slotNodes = new Map();
206
- #processedAssets = new Set();
290
+ #processedAssets = new WeakSet();
207
291
  #recordRefresh = null;
208
292
  #disposed = false;
209
293
  #styleFlush = () => {
210
294
  if (!this.#disposed) this.#flush();
211
295
  };
212
296
  #claimTree = (node, direct) => {
297
+ if (!direct && node.nodeType !== TEXT_NODE && node.nodeType !== COMMENT_NODE) {
298
+ const o = this.#options;
299
+ sweepBound(node, this, o.delegate || o.host && o.host.delegate, o.ownerScope);
300
+ }
213
301
  const handlers = claimHandlers();
214
302
  if (!handlers) return;
215
303
  this.#scoped(() => direct ? claimNode(handlers, node) : claimTree(handlers, node));
216
304
  };
305
+ clientProp(name) {
306
+ const props = this.#options.props;
307
+ return props ? props[name] : undefined;
308
+ }
217
309
  #scoped(fn) {
218
310
  const scope = this.#options.ownerScope;
219
311
  return scope ? scope(fn) : fn();
@@ -296,6 +388,7 @@ class FrameImpl {
296
388
  this.#revealed.clear();
297
389
  this.#fallbackShown.clear();
298
390
  this.#appliedHoles.clear();
391
+ this.#processedAssets = new WeakSet();
299
392
  this.#errorNotified = false;
300
393
  clearStreamRecords(this.#store, root);
301
394
  }
@@ -307,6 +400,10 @@ class FrameImpl {
307
400
  const reason = this.#hasContent ? "morph" : "materialize";
308
401
  this.#applyRoot(root.value);
309
402
  this.#appliedRootValue = root.value;
403
+ this.#have = root.digest === undefined ? undefined : {
404
+ "": root.digest,
405
+ ...root.holes
406
+ };
310
407
  this.#applied(version, reason);
311
408
  }
312
409
  if (this.#store[":error"] && !this.#errorNotified) {
@@ -343,25 +440,31 @@ class FrameImpl {
343
440
  if (key.startsWith("hole:")) {
344
441
  if (key.endsWith(":error")) {
345
442
  this.#appliedHoles.set(key, record);
346
- console.error(`Live hole ${key.slice(5, -6)} failed on the server; latched:`, record);
347
443
  } else if (this.#applyHole(key.slice(5), record.value)) {
348
444
  this.#appliedHoles.set(key, record);
445
+ this.#recordHave(key.slice(5), record);
349
446
  this.#applied(version, "morph");
350
447
  }
351
448
  } else if (key.startsWith("attr:")) {
352
449
  if (this.#applyAttrs(key.slice(5), record.value, record.removed)) {
353
450
  this.#appliedHoles.set(key, record);
451
+ this.#recordHave("lha:" + key.slice(5), record);
354
452
  this.#applied(version, "morph");
355
453
  }
356
454
  }
357
455
  }
358
456
  for (const key in this.#store) {
359
- if (this.#processedAssets.has(key) || !key.endsWith(":assets")) continue;
360
- this.#processedAssets.add(key);
361
457
  const record = this.#store[key];
362
- if (record && record.modules) {
458
+ if (!key.endsWith(":assets") || !record || this.#processedAssets.has(record)) {
459
+ continue;
460
+ }
461
+ this.#processedAssets.add(record);
462
+ if (record.modules) {
363
463
  for (const href of record.modules) ensureModulePreload(href);
364
464
  }
465
+ if (record.preloads) {
466
+ for (const entry of record.preloads) ensurePreload(entry);
467
+ }
365
468
  }
366
469
  this.#syncSlots();
367
470
  }
@@ -636,6 +739,14 @@ class FrameImpl {
636
739
  rebase() {
637
740
  this.#version = undefined;
638
741
  }
742
+ have() {
743
+ return this.#have;
744
+ }
745
+ #recordHave(key, record) {
746
+ if (!this.#have || !record || record.digest === undefined) return;
747
+ this.#have[key] = record.digest;
748
+ if (record.holes) Object.assign(this.#have, record.holes);
749
+ }
639
750
  dispose() {
640
751
  if (this.#disposed) return;
641
752
  const {
@@ -663,7 +774,7 @@ class FrameImpl {
663
774
  parent.insertBefore(fragment, this.#end);
664
775
  this.#hasContent = true;
665
776
  } else {
666
- const claim = claimHandlers() ? this.#claimTree : null;
777
+ const claim = this.#claimTree;
667
778
  const ranges = new Map();
668
779
  this.#collectSlots(ranges);
669
780
  const grafts = [];
@@ -677,13 +788,9 @@ class FrameImpl {
677
788
  if (!open) return false;
678
789
  const close = rangeClose(open, "lh:/" + marker.slice(3));
679
790
  if (!close) {
680
- {
681
- console.error(`Live hole "${marker}" is missing its closing comment; update dropped. ` + `Likely an HTML-rewriting layer stripped it.`, open);
682
- }
683
791
  return false;
684
792
  }
685
- const claim = claimHandlers() ? this.#claimTree : null;
686
- reconcileChildren(open.parentNode, parseFragment(html), open, close, claim);
793
+ reconcileChildren(open.parentNode, parseFragment(html), open, close, this.#claimTree);
687
794
  return true;
688
795
  }
689
796
  #applyAttrs(addr, text, removed) {
@@ -691,23 +798,30 @@ class FrameImpl {
691
798
  const el = findLiveTarget(this.#firstContent(), this.#end, n => n.nodeType === ELEMENT_NODE && n.getAttribute("data-lha") === addr);
692
799
  if (!el) return false;
693
800
  const parsed = parseFragment(`<i${text}></i>`).firstChild;
801
+ const keepOpen = preservesOpen(el);
802
+ const current = el.attributes;
803
+ for (let i = current.length - 1; i >= 0; i--) {
804
+ const name = current[i].name;
805
+ if (name === "data-lha" || keepOpen && name === "open") continue;
806
+ if (!parsed || !parsed.hasAttribute(name)) el.removeAttribute(name);
807
+ }
694
808
  if (parsed) {
695
809
  for (let i = 0; i < parsed.attributes.length; i++) {
696
810
  const {
697
811
  name,
698
812
  value
699
813
  } = parsed.attributes[i];
814
+ if (keepOpen && name === "open") continue;
700
815
  if (el.getAttribute(name) !== value) el.setAttribute(name, value);
701
816
  }
702
817
  }
703
- if (removed) for (const name of removed) el.removeAttribute(name);
818
+ if (removed) for (const name of removed) if (!(keepOpen && name === "open")) el.removeAttribute(name);
704
819
  return true;
705
820
  }
706
821
  #clearContent() {
707
822
  removeUntil(this.#parent(), this.#firstContent(), this.#end);
708
823
  }
709
824
  #claimContent() {
710
- if (!claimHandlers()) return;
711
825
  let n = this.#firstContent();
712
826
  while (n && n !== this.#end) {
713
827
  this.#claimTree(n);
@@ -734,9 +848,6 @@ class FrameImpl {
734
848
  if (assets && assets.inlineStyles) applyInlineStyles(assets.inlineStyles);
735
849
  const content = this.#store[`seg:${name}`];
736
850
  const closing = rangeClose(tpl, placeholderId(name));
737
- if (!closing) {
738
- console.error(`Frame fragment placeholder "${name}" is missing its closing comment ` + `(<!--${placeholderId(name)}-->); revealed content will be appended at the end of ` + `its parent instead of in place. Likely an HTML-rewriting layer stripped the ` + `comment, or invalid nesting split the placeholder range.`, tpl);
739
- }
740
851
  const parent = tpl.parentNode;
741
852
  removeUntil(parent, tpl.nextSibling, closing);
742
853
  if (this.#options.reveal) {
@@ -754,6 +865,7 @@ class FrameImpl {
754
865
  });
755
866
  tpl.remove();
756
867
  this.#revealed.add(name);
868
+ this.#recordHave(name, content);
757
869
  return;
758
870
  }
759
871
  const materialized = this.#materialize(content);
@@ -762,6 +874,7 @@ class FrameImpl {
762
874
  tpl.remove();
763
875
  closing && closing.remove();
764
876
  this.#revealed.add(name);
877
+ this.#recordHave(name, content);
765
878
  }
766
879
  #showFallback(name) {
767
880
  const tpl = this.#findPlaceholder(name);
@@ -780,7 +893,7 @@ class FrameImpl {
780
893
  function createFrame(boundary, options) {
781
894
  return new FrameImpl(boundary, null, null, options);
782
895
  }
783
- const FRAME_TAG = "dx-frame";
896
+ const FRAME_TAG = "solid-frame";
784
897
  const FRAME_ID_ATTR = "data-fid";
785
898
  function createFrameElement(options) {
786
899
  const el = makeFrameElement(options.id);
@@ -837,12 +950,36 @@ function parseFragment(html) {
837
950
  template.innerHTML = html;
838
951
  return template.content;
839
952
  }
840
- function findHeadElement(selector, attr, value) {
841
- for (const node of document.head.querySelectorAll(selector)) {
842
- if (node.getAttribute(attr) === value) return node;
953
+ const PRELOAD_QUALIFIERS = ["as", "crossorigin", "type", "media", "imagesrcset", "imagesizes"];
954
+ function qualifierValue(name, value) {
955
+ if (value == null) return null;
956
+ if (name === "imagesrcset" || name === "imagesizes") return value === "" ? null : value;
957
+ if (name === "as") return value.replace(/[A-Z]/g, c => String.fromCharCode(c.charCodeAt(0) + 32));
958
+ if (name !== "crossorigin") return value;
959
+ return value.length === 15 && value.toLowerCase() === "use-credentials" ? "use-credentials" : "anonymous";
960
+ }
961
+ function findHeadElement(selector, attr, value, qualifiers) {
962
+ candidate: for (const node of document.head.querySelectorAll(selector)) {
963
+ if (node.getAttribute(attr) !== value) continue;
964
+ if (!qualifiers) return node;
965
+ for (let i = 0; i < PRELOAD_QUALIFIERS.length; i++) {
966
+ const name = PRELOAD_QUALIFIERS[i];
967
+ if (qualifierValue(name, node.getAttribute(name)) !== qualifierValue(name, qualifiers[name] ?? null)) continue candidate;
968
+ }
969
+ return node;
843
970
  }
844
971
  return null;
845
972
  }
973
+ function ensurePreload(entry) {
974
+ const attrs = entry.attrs;
975
+ const href = entry.href;
976
+ if (findHeadElement('link[rel="preload"]', "href", href || null, attrs)) return;
977
+ const link = document.createElement("link");
978
+ link.rel = "preload";
979
+ for (const name in attrs) link.setAttribute(name, attrs[name]);
980
+ if (href) link.setAttribute("href", href);
981
+ document.head.appendChild(link);
982
+ }
846
983
  function ensureStylesheet(entry, onSettle) {
847
984
  const href = typeof entry === "string" ? entry : entry.href;
848
985
  let link = findHeadElement('link[rel="stylesheet"]', "href", href);
@@ -927,7 +1064,6 @@ function collectSlots(n, end, out) {
927
1064
  while (n && n !== end) {
928
1065
  const id = slotStartId(n);
929
1066
  if (id !== null) {
930
- devCheckRange(n, id);
931
1067
  if (!out.has(id)) out.set(id, n);
932
1068
  n = afterRange(n, id);
933
1069
  continue;
@@ -1003,7 +1139,7 @@ function isSlotMarker(node) {
1003
1139
  }
1004
1140
  function compatible(a, b) {
1005
1141
  if (a.nodeType !== b.nodeType) return false;
1006
- if (a.nodeType === ELEMENT_NODE) return a.nodeName === b.nodeName;
1142
+ if (a.nodeType === ELEMENT_NODE) return a.nodeName === b.nodeName && a.getAttribute("_key") === b.getAttribute("_key");
1007
1143
  return a.nodeType === TEXT_NODE || a.nodeType === COMMENT_NODE;
1008
1144
  }
1009
1145
  function preservesOpen(el) {
@@ -1054,15 +1190,6 @@ function afterRange(start, id) {
1054
1190
  }
1055
1191
  return null;
1056
1192
  }
1057
- function devCheckRange(start, id) {
1058
- const end = slotEnd(id);
1059
- let n = start.nextSibling;
1060
- while (n) {
1061
- if (n.nodeType === COMMENT_NODE && n.data === end) return;
1062
- n = n.nextSibling;
1063
- }
1064
- 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);
1065
- }
1066
1193
  function findRangeStart(from, id, bound) {
1067
1194
  const target = `slot:${id}:start`;
1068
1195
  let n = from;
@@ -1216,38 +1343,187 @@ function stashRange(frag, start, id) {
1216
1343
  return null;
1217
1344
  }
1218
1345
 
1346
+ const RECORDS = Symbol.for("@solidjs/signals/observe/records");
1347
+ function records() {
1348
+ return globalThis[RECORDS];
1349
+ }
1350
+ function frameCensus(event, type, own) {
1351
+ event.chunks++;
1352
+ switch (type) {
1353
+ case "html":
1354
+ if (!own) event.regions++;else if (event.shellMs === undefined) event.shellMs = performance.now() - event.at;
1355
+ break;
1356
+ case "fragment":
1357
+ event.fragments++;
1358
+ break;
1359
+ case "slot":
1360
+ event.slots++;
1361
+ break;
1362
+ case "error":
1363
+ event.errors++;
1364
+ break;
1365
+ }
1366
+ }
1367
+ function observeFrameApply(response) {
1368
+ const channel = records();
1369
+ if (channel === undefined || !channel.observed("frame")) return undefined;
1370
+ let current;
1371
+ const close = (outcome, error) => {
1372
+ const open = current;
1373
+ current = undefined;
1374
+ open.event.durationMs = performance.now() - open.event.at;
1375
+ open.event.outcome = outcome;
1376
+ const live = {
1377
+ response
1378
+ };
1379
+ if (error !== undefined) live.error = error;
1380
+ channel.emit("frame", open.event, live);
1381
+ };
1382
+ return {
1383
+ chunk(chunk, wireId) {
1384
+ if (chunk.type === "start") {
1385
+ if (current !== undefined) close("truncated");
1386
+ const event = {
1387
+ side: "client",
1388
+ id: wireId,
1389
+ version: chunk.version,
1390
+ at: performance.now(),
1391
+ durationMs: 0,
1392
+ outcome: "complete",
1393
+ chunks: 0,
1394
+ fragments: 0,
1395
+ slots: 0,
1396
+ regions: 0,
1397
+ errors: 0
1398
+ };
1399
+ if (chunk.id !== wireId) event.address = chunk.id;
1400
+ current = {
1401
+ event,
1402
+ applied: chunk.id
1403
+ };
1404
+ return;
1405
+ }
1406
+ if (current === undefined) return;
1407
+ if (chunk.type === "complete") {
1408
+ if (chunk.id === current.applied) close("complete");
1409
+ return;
1410
+ }
1411
+ frameCensus(current.event, chunk.type, chunk.id === current.applied);
1412
+ },
1413
+ end(error) {
1414
+ if (current !== undefined) close(error !== undefined ? "error" : "truncated", error);
1415
+ }
1416
+ };
1417
+ }
1418
+
1219
1419
  const FRAME_STREAM_HEADER = "X-Frame-Stream";
1420
+ const FRAME_HAVE_HEADER = "X-Frame-Have";
1421
+ const FRAME_HAVE_BUDGET = 4096;
1422
+ function encodeHaveList(have) {
1423
+ let out = "";
1424
+ for (const key in have) {
1425
+ const digest = have[key];
1426
+ if (typeof digest !== "string") continue;
1427
+ out += (out ? "," : "") + key + "=" + digest;
1428
+ if (out.length > FRAME_HAVE_BUDGET) return undefined;
1429
+ }
1430
+ return out || undefined;
1431
+ }
1220
1432
  function isFrameStreamResponse(response) {
1221
1433
  return response.headers.has(FRAME_STREAM_HEADER);
1222
1434
  }
1223
- async function applyFrameResponse(response, host, options = {}) {
1435
+ const applyFrameResponse = observedApplyFrameResponse ;
1436
+ async function observedApplyFrameResponse(response, host, options = {}) {
1437
+ const observation = observeFrameApply(response);
1438
+ if (!observation) return applyFrames(response, host, options);
1439
+ let applied;
1440
+ try {
1441
+ applied = await applyFrames(response, host, options, observation);
1442
+ } catch (error) {
1443
+ observation.end(error);
1444
+ throw error;
1445
+ }
1446
+ observation.end();
1447
+ return applied;
1448
+ }
1449
+ function applyFrames(response, host, options = {}, observation) {
1224
1450
  const rootId = response.headers.get(FRAME_STREAM_HEADER) ?? "";
1225
1451
  const as = options.as;
1226
1452
  const version = options.version;
1227
1453
  const perFrame = typeof version === "function" ? new Map() : null;
1228
- const reader = new client.ChunkReader(response.body);
1229
- let result = await reader.next();
1230
- while (!result.done) {
1231
- const chunk = JSON.parse(result.value);
1232
- if (chunk.type === "outcome") {
1233
- if (options.onOutcome) options.onOutcome(chunk.payload);
1234
- } else {
1235
- if (as !== undefined && chunk.id === rootId) chunk.id = as;
1236
- if (perFrame) {
1237
- let v = perFrame.get(chunk.id);
1238
- if (v === undefined) perFrame.set(chunk.id, v = version(chunk.id));
1239
- chunk.version = v;
1240
- } else if (version !== undefined) chunk.version = version;
1241
- if (chunk.type === "data" && host.prepareData) await host.prepareData();
1242
- host.apply(chunk);
1243
- }
1244
- result = await reader.next();
1245
- }
1246
- return as !== undefined ? as : rootId;
1247
- }
1248
- const SERVER_COMPONENT = /*#__PURE__*/Symbol.for("dom-expressions.server-component");
1249
- const SERVER_COMPONENT_ADDRESS = /*#__PURE__*/Symbol.for("dom-expressions.server-component-address");
1250
- const COMPONENT_BINDING = /*#__PURE__*/Symbol.for("dom-expressions.component-binding");
1454
+ const wire = options[LIVE_WIRE];
1455
+ const connection = wire && wire.connection;
1456
+ const reader = wire && isEventStream(response) ? wire.open(response.body) : new ChunkReader(response.body);
1457
+ const open = new Map();
1458
+ let cancelled;
1459
+ let resolveEnd;
1460
+ if (connection) {
1461
+ connection.ended = new Promise(resolve => resolveEnd = resolve);
1462
+ connection.cancel = reason => {
1463
+ if (cancelled !== undefined) return;
1464
+ cancelled = reason;
1465
+ try {
1466
+ const r = reader.cancel && reader.cancel(reason);
1467
+ if (r && typeof r.then === "function") r.then(undefined, () => {});
1468
+ } catch {}
1469
+ };
1470
+ }
1471
+ const errorRecord = (id, error) => ({
1472
+ type: "error",
1473
+ id,
1474
+ version: open.get(id),
1475
+ error: {
1476
+ message: String(error && error.message)
1477
+ }
1478
+ });
1479
+ const drain = async () => {
1480
+ let result = await reader.next();
1481
+ while (!result.done) {
1482
+ const chunk = JSON.parse(result.value);
1483
+ if (chunk.type === "outcome") {
1484
+ if (options.onOutcome) options.onOutcome(chunk.payload);
1485
+ } else {
1486
+ const wireId = chunk.id;
1487
+ if (as !== undefined && chunk.id === rootId) chunk.id = as;
1488
+ if (perFrame) {
1489
+ let v = perFrame.get(chunk.id);
1490
+ if (v === undefined) perFrame.set(chunk.id, v = version(chunk.id));
1491
+ chunk.version = v;
1492
+ } else if (version !== undefined) chunk.version = version;
1493
+ if (chunk.type === "start") open.set(chunk.id, chunk.version);else if (chunk.type === "complete" || chunk.type === "error" && !chunk.key) open.delete(chunk.id);
1494
+ if (observation) observation.chunk(chunk, wireId);
1495
+ if (chunk.type === "data" && host.prepareData) await host.prepareData();
1496
+ host.apply(chunk);
1497
+ }
1498
+ result = await reader.next();
1499
+ }
1500
+ };
1501
+ const end = error => {
1502
+ const dead = error || cancelled || new Error("Frame stream ended before the frame completed.");
1503
+ const sweep = () => {
1504
+ for (const id of open.keys()) host.apply(errorRecord(id, dead));
1505
+ };
1506
+ if (connection) {
1507
+ connection.done = true;
1508
+ resolveEnd({
1509
+ open: open.size,
1510
+ error: dead,
1511
+ sweep,
1512
+ close: () => {}
1513
+ });
1514
+ } else if (error === undefined) sweep();
1515
+ };
1516
+ return drain().then(() => {
1517
+ end(undefined);
1518
+ return as !== undefined ? as : rootId;
1519
+ }, error => {
1520
+ end(error);
1521
+ throw error;
1522
+ });
1523
+ }
1524
+ const SERVER_COMPONENT = /*#__PURE__*/Symbol.for("solid.server-component");
1525
+ const SERVER_COMPONENT_ADDRESS = /*#__PURE__*/Symbol.for("solid.server-component-address");
1526
+ const COMPONENT_BINDING = /*#__PURE__*/Symbol.for("solid.component-binding");
1251
1527
  let resolveServerComponent;
1252
1528
  function parseServerComponent(value, ctx) {
1253
1529
  return {
@@ -1256,7 +1532,7 @@ function parseServerComponent(value, ctx) {
1256
1532
  };
1257
1533
  }
1258
1534
  const ServerComponentPlugin = {
1259
- tag: "dom-expressions/server-component",
1535
+ tag: "solid/server-component",
1260
1536
  test(value) {
1261
1537
  return typeof value === "function" && SERVER_COMPONENT in value;
1262
1538
  },
@@ -1295,9 +1571,7 @@ function createServerComponentHandler({
1295
1571
  host,
1296
1572
  component,
1297
1573
  onStream,
1298
- intercept,
1299
- consumer = client.getFlightDataConsumer,
1300
- codec = client.getServerFunctionsCodec
1574
+ intercept
1301
1575
  }) {
1302
1576
  const byFn = new Map();
1303
1577
  const componentFor = fnId => {
@@ -1321,24 +1595,72 @@ function createServerComponentHandler({
1321
1595
  };
1322
1596
  resolveServerComponent = (id, address) => bindingFor(address, id);
1323
1597
  const versions = new Map();
1598
+ const connections = new Map();
1324
1599
  const bump = address => {
1325
1600
  const version = (versions.get(address) || 0) + 1;
1326
1601
  versions.set(address, version);
1602
+ const connection = connections.get(address);
1603
+ if (connection) {
1604
+ connections.delete(address);
1605
+ connection.cancel(new Error("Superseded by a newer response for the address."));
1606
+ }
1327
1607
  return version;
1328
1608
  };
1609
+ const hold = (address, connection) => {
1610
+ connections.set(address, connection);
1611
+ connection.ended.then(() => {
1612
+ if (connections.get(address) === connection) connections.delete(address);
1613
+ });
1614
+ };
1329
1615
  return {
1330
1616
  intercept: intercept && (info => {
1331
1617
  const hit = intercept(info);
1332
1618
  if (hit === undefined) return undefined;
1333
- return bindingFor(client.frameAddress(info.id, info.args), info.id);
1619
+ const binding = () => bindingFor(frameAddress(info.id, info.args), info.id);
1620
+ if (typeof hit.then === "function") return hit.then(landed => landed ? binding() : undefined);
1621
+ return binding();
1334
1622
  }),
1623
+ resume(info) {
1624
+ const address = frameAddress(info.id, info.args);
1625
+ const version = versions.get(address);
1626
+ const frame = host.get(address);
1627
+ const have = frame && frame.have ? frame.have() : undefined;
1628
+ if (version === undefined && !have) return undefined;
1629
+ const encoded = have && encodeHaveList(have);
1630
+ return {
1631
+ position: String(version || 0),
1632
+ headers: encoded ? {
1633
+ [FRAME_HAVE_HEADER]: encoded
1634
+ } : undefined
1635
+ };
1636
+ },
1335
1637
  handle(response, ctx) {
1336
1638
  if (!isFrameStreamResponse(response)) return undefined;
1337
- const address = client.frameAddress(ctx.id, ctx.args);
1639
+ const address = frameAddress(ctx.id, ctx.args);
1338
1640
  const binding = bindingFor(address, ctx.id);
1339
- if (response.headers.has(client.SINGLE_FLIGHT_HEADER)) {
1641
+ if (response.headers.has(SINGLE_FLIGHT_HEADER)) {
1340
1642
  return applyFlightResponse(response, address, binding);
1341
1643
  }
1644
+ const wire = ctx[LIVE_WIRE];
1645
+ const connection = wire && wire.connection;
1646
+ if (connection) {
1647
+ const current = connections.get(address);
1648
+ if (current && !current.done) {
1649
+ connection.ended = current.ended;
1650
+ const body = response.body;
1651
+ if (body) body.cancel().catch(() => {});
1652
+ return binding;
1653
+ }
1654
+ const version = bump(address);
1655
+ if (onStream) onStream(address, version, response);
1656
+ applyFrameResponse(response, host, {
1657
+ as: address,
1658
+ version,
1659
+ [LIVE_WIRE]: wire
1660
+ }).catch(() => {});
1661
+ hold(address, connection);
1662
+ return binding;
1663
+ }
1342
1664
  const version = bump(address);
1343
1665
  if (onStream) onStream(address, version, response);
1344
1666
  applyFrameResponse(response, host, {
@@ -1374,7 +1696,7 @@ function createServerComponentHandler({
1374
1696
  feed = controller;
1375
1697
  }
1376
1698
  });
1377
- const payload = client.deserializeStream(new Response(source), flightCodec(codec()));
1699
+ const payload = deserializeStream(new Response(source), flightCodec(getServerFunctionsCodec()));
1378
1700
  let carried = false;
1379
1701
  await applyFrameResponse(response, host, {
1380
1702
  as,
@@ -1385,24 +1707,21 @@ function createServerComponentHandler({
1385
1707
  },
1386
1708
  onOutcome: text => {
1387
1709
  carried = true;
1388
- feed.enqueue(client.createChunk(text));
1710
+ feed.enqueue(createChunk(text));
1389
1711
  }
1390
1712
  });
1391
1713
  feed.close();
1392
1714
  if (!carried) throw new Error("Single-flight frame response carried no outcome");
1393
1715
  const envelope = await payload;
1394
- const deliver = consumer();
1395
- if (deliver) await deliver(envelope.data, {
1396
- response
1397
- });
1398
- if (response.headers.has(client.ERROR_HEADER) && !response.headers.has("Location") && !response.headers.has(client.REVALIDATE_HEADER)) {
1716
+ await deliverFlightData(response, envelope.data);
1717
+ if (response.headers.has(ERROR_HEADER) && !hasFlightMetadata(response)) {
1399
1718
  throw envelope.value;
1400
1719
  }
1401
1720
  return rootId ? binding : envelope.value;
1402
1721
  }
1403
1722
  }
1404
1723
 
1405
- const STATE = Symbol.for("dom-expressions.container-trace-state");
1724
+ const STATE = Symbol.for("solid.container-trace-state");
1406
1725
  const state = globalThis[STATE] || (globalThis[STATE] = {
1407
1726
  materialized: new WeakMap(),
1408
1727
  materializedValues: new WeakSet()
@@ -1423,7 +1742,9 @@ function isMaterializedContainer(value) {
1423
1742
  return value !== null && typeof value === "object" && state.materializedValues.has(value);
1424
1743
  }
1425
1744
  function isContainerTraceMarker(value) {
1426
- return value != null && typeof value === "object" && value.$tr != null && typeof value.$tr[Symbol.asyncIterator] === "function";
1745
+ if (value == null || typeof value !== "object" || value.$tr == null) return false;
1746
+ const tr = value.$tr;
1747
+ return tr.__SEROVAL_STREAM__ === true || typeof tr[Symbol.asyncIterator] === "function";
1427
1748
  }
1428
1749
  function reviveContainerTraces(value) {
1429
1750
  if (!state.materializeTrace || value == null || typeof value !== "object") return value;
@@ -1436,7 +1757,9 @@ function reviveContainerTraces(value) {
1436
1757
  return value;
1437
1758
  }
1438
1759
 
1439
- setContainerTraceMaterializer(solidJs.materializeContainerTrace);
1760
+ const materializeContainerTrace = core.materializeContainerTrace;
1761
+
1762
+ setContainerTraceMaterializer(materializeContainerTrace);
1440
1763
  function asyncArg(value) {
1441
1764
  return value;
1442
1765
  }
@@ -1469,7 +1792,8 @@ function getFrameHost() {
1469
1792
  applyData: c => tableFor(c.id)?.apply(c),
1470
1793
  resolve: (ref, id) => tableFor(id)?.resolve(ref),
1471
1794
  revive: reviveContainerTraces,
1472
- isContainer: isMaterializedContainer
1795
+ isContainer: isMaterializedContainer,
1796
+ delegate: delegateEvents
1473
1797
  });
1474
1798
  }
1475
1799
  return sharedHost;
@@ -1502,7 +1826,7 @@ function hasPendingFragment(existing) {
1502
1826
  return false;
1503
1827
  }
1504
1828
  function claimRender(prefix, existing, render) {
1505
- const sc = solidJs.sharedConfig;
1829
+ const sc = sharedConfig;
1506
1830
  if (!sc.getNextContextId) return render();
1507
1831
  const registry = new Map();
1508
1832
  for (const n of existing) {
@@ -1518,7 +1842,7 @@ function claimRender(prefix, existing, render) {
1518
1842
  sc.hydrating = true;
1519
1843
  sc.claimRoots = existing;
1520
1844
  try {
1521
- return solidJs.runWithOwner(solidJs.createOwner({
1845
+ return runWithOwner(createOwner({
1522
1846
  id: prefix
1523
1847
  }), render);
1524
1848
  } finally {
@@ -1528,7 +1852,7 @@ function claimRender(prefix, existing, render) {
1528
1852
  }
1529
1853
  }
1530
1854
  function liveSlotProps(initial, ctx) {
1531
- const [args, setArgs] = solidJs.createSignal(initial);
1855
+ const [args, setArgs] = createSignal(initial);
1532
1856
  ctx.onUpdate(next => setArgs(() => next));
1533
1857
  return slotArgsProxy(args);
1534
1858
  }
@@ -1536,7 +1860,7 @@ function isAsyncValue(v) {
1536
1860
  return v !== null && typeof v === "object" && (typeof v.then === "function" || typeof v[Symbol.asyncIterator] === "function");
1537
1861
  }
1538
1862
  function slotArgsProxy(args) {
1539
- const owner = solidJs.getOwner();
1863
+ const owner = getOwner();
1540
1864
  const asyncReads = new Map();
1541
1865
  return new Proxy({}, {
1542
1866
  get: (_, key) => {
@@ -1545,8 +1869,17 @@ function slotArgsProxy(args) {
1545
1869
  if (!isAsyncValue(v)) return v;
1546
1870
  let read = asyncReads.get(key);
1547
1871
  if (!read) {
1548
- const make = () => solidJs.createMemo(() => args()[key]);
1549
- read = owner ? solidJs.runWithOwner(owner, make) : make();
1872
+ const make = () => createMemo(() => {
1873
+ const raw = args()[key];
1874
+ if (raw != null && typeof raw.then === "function") {
1875
+ if (raw.s === 1) return raw.v;
1876
+ if (raw.s === 2) throw raw.v;
1877
+ }
1878
+ return raw;
1879
+ }, {
1880
+ transparent: true
1881
+ });
1882
+ read = owner ? runWithOwner(owner, make) : make();
1550
1883
  asyncReads.set(key, read);
1551
1884
  }
1552
1885
  return read();
@@ -1584,7 +1917,7 @@ function slotsFor(props) {
1584
1917
  fillScopes.delete(key);
1585
1918
  prevFill.dispose();
1586
1919
  }
1587
- const fillOwner = streamInvoke ? solidJs.createOwner() : null;
1920
+ const fillOwner = streamInvoke ? createOwner() : null;
1588
1921
  if (fillOwner && key !== undefined && ctx) {
1589
1922
  fillScopes.set(key, fillOwner);
1590
1923
  ctx.onCleanup(() => {
@@ -1610,21 +1943,21 @@ function slotsFor(props) {
1610
1943
  };
1611
1944
  const adopted = !!(ctx && ctx.frame && ctx.adopted && ctx.existing && ctx.existing.length);
1612
1945
  const prefix = ctx && ctx.frame ? `sc-${ctx.frame}-${ctx.key}-` : "";
1613
- const value = fillOwner ? solidJs.runWithOwner(fillOwner, () => adopted ? claimRender(prefix, ctx.existing, evaluate) : evaluate()) : adopted ? claimRender(prefix, ctx.existing, evaluate) : evaluate();
1946
+ const value = fillOwner ? runWithOwner(fillOwner, () => adopted ? claimRender(prefix, ctx.existing, evaluate) : evaluate()) : adopted ? claimRender(prefix, ctx.existing, evaluate) : evaluate();
1614
1947
  if (!isReactiveContent(value)) {
1615
1948
  return settle(normalizeSlotContent(value));
1616
1949
  }
1617
1950
  if (ctx && ctx.range) {
1618
1951
  const source = value;
1619
- const owner = solidJs.createOwner();
1952
+ const owner = createOwner();
1620
1953
  bindings.set(key, owner);
1621
1954
  ctx.onCleanup(() => {
1622
1955
  if (bindings.get(key) === owner) bindings.delete(key);
1623
1956
  owner.dispose();
1624
1957
  });
1625
1958
  const end = ctx.range.end;
1626
- const bind = () => web.insert(end.parentNode, () => typeof source === "function" ? source() : source, end, [...ctx.existing]);
1627
- solidJs.runWithOwner(owner, () => adopted ? claimRender(prefix, ctx.existing, bind) : bind());
1959
+ const bind = () => insert(end.parentNode, () => typeof source === "function" ? source() : source, end, [...ctx.existing]);
1960
+ runWithOwner(owner, () => adopted ? claimRender(prefix, ctx.existing, bind) : bind());
1628
1961
  return undefined;
1629
1962
  }
1630
1963
  return settle(normalizeSlotContent(value));
@@ -1633,15 +1966,15 @@ function slotsFor(props) {
1633
1966
  });
1634
1967
  }
1635
1968
  function revealSeam(owner) {
1636
- return seam => solidJs.runWithOwner(owner, () => web.insert(seam.before.parentNode, solidJs.createLoadingBoundary(() => seam.content(), () => seam.fallback), seam.before));
1969
+ return seam => runWithOwner(owner, () => insert(seam.before.parentNode, createLoadingBoundary(() => seam.content(), () => seam.fallback), seam.before));
1637
1970
  }
1638
1971
  let streamInvoke = false;
1639
1972
  function boundaryScope(owner) {
1640
1973
  return fn => {
1641
- if (solidJs.getOwner()) return fn();
1974
+ if (getOwner()) return fn();
1642
1975
  streamInvoke = true;
1643
1976
  try {
1644
- return solidJs.runWithOwner(owner, fn);
1977
+ return runWithOwner(owner, fn);
1645
1978
  } finally {
1646
1979
  streamInvoke = false;
1647
1980
  }
@@ -1649,7 +1982,7 @@ function boundaryScope(owner) {
1649
1982
  }
1650
1983
  function boundaryComponent(host, fnId) {
1651
1984
  return (props, binding) => {
1652
- const owner = solidJs.getOwner();
1985
+ const owner = getOwner();
1653
1986
  const id = binding ? binding() : fnId;
1654
1987
  let applied = !tables.has(id);
1655
1988
  let release;
@@ -1664,6 +1997,7 @@ function boundaryComponent(host, fnId) {
1664
1997
  host,
1665
1998
  id,
1666
1999
  slots: slotsFor(props),
2000
+ props,
1667
2001
  ownerScope: boundaryScope(owner),
1668
2002
  reveal: revealSeam(owner),
1669
2003
  onApply: () => {
@@ -1675,10 +2009,10 @@ function boundaryComponent(host, fnId) {
1675
2009
  setGate && setGate(undefined);
1676
2010
  }
1677
2011
  });
1678
- const [gatePromise, setGatePromise] = solidJs.createSignal(applied ? undefined : mountGate);
2012
+ const [gatePromise, setGatePromise] = createSignal(applied ? undefined : mountGate);
1679
2013
  setGate = setGatePromise;
1680
2014
  if (binding) {
1681
- solidJs.createRenderEffect(binding, (address, prev) => {
2015
+ createRenderEffect(binding, (address, prev) => {
1682
2016
  if (prev !== undefined && address !== prev && tables.has(address)) {
1683
2017
  applied = false;
1684
2018
  setGatePromise(arm());
@@ -1686,10 +2020,10 @@ function boundaryComponent(host, fnId) {
1686
2020
  frame.rebind(address);
1687
2021
  });
1688
2022
  }
1689
- solidJs.onCleanup(dispose);
2023
+ onCleanup(dispose);
1690
2024
  if (applied && !binding) return element;
1691
- const gate = solidJs.createMemo(() => gatePromise());
1692
- return solidJs.createMemo(() => (gate(), element));
2025
+ const gate = createMemo(() => gatePromise());
2026
+ return createMemo(() => (gate(), element));
1693
2027
  };
1694
2028
  }
1695
2029
  const claimedBoundaries = new Set();
@@ -1727,6 +2061,19 @@ function findBoundaryElement(id) {
1727
2061
  return boundaryIndex.get(id);
1728
2062
  }
1729
2063
  const boundaryWaiters = new Map();
2064
+ const arrivals = new Map();
2065
+ function awaitBoundary(id) {
2066
+ let arrival = arrivals.get(id);
2067
+ if (!arrival) {
2068
+ let resolve;
2069
+ const promise = new Promise(r => resolve = r);
2070
+ arrivals.set(id, arrival = {
2071
+ promise,
2072
+ resolve
2073
+ });
2074
+ }
2075
+ return arrival.promise;
2076
+ }
1730
2077
  function boundaryMayArrive() {
1731
2078
  const hy = globalThis._$HY;
1732
2079
  if (!hy) return false;
@@ -1740,7 +2087,7 @@ function installRevealHook() {
1740
2087
  if (!boundaryIndex) return;
1741
2088
  const root = parent || (typeof document !== "undefined" ? document.body : null);
1742
2089
  if (root) indexBoundaries(root);
1743
- if (!boundaryWaiters.size) return;
2090
+ if (!boundaryWaiters.size && !arrivals.size) return;
1744
2091
  const exhausted = hy.done && !hy.fr.pending();
1745
2092
  for (const [id, notify] of boundaryWaiters) {
1746
2093
  const el = boundaryIndex && boundaryIndex.get(id);
@@ -1748,6 +2095,12 @@ function installRevealHook() {
1748
2095
  boundaryWaiters.delete(id);
1749
2096
  notify(el);
1750
2097
  }
2098
+ for (const [id, arrival] of arrivals) {
2099
+ const el = boundaryIndex && boundaryIndex.get(id);
2100
+ if (!el && !exhausted) continue;
2101
+ arrivals.delete(id);
2102
+ arrival.resolve(!!el);
2103
+ }
1751
2104
  });
1752
2105
  }
1753
2106
  function documentBoundary(host, id, props, binding) {
@@ -1756,10 +2109,10 @@ function documentBoundary(host, id, props, binding) {
1756
2109
  const el = !claimed ? findBoundaryElement(id) : undefined;
1757
2110
  if (el) return adoptBoundary(host, id, el, props, binding);
1758
2111
  if (!claimed && !boundaryWaiters.has(id) && boundaryMayArrive()) {
1759
- const owner = solidJs.getOwner();
2112
+ const owner = getOwner();
1760
2113
  const arrival = new Promise(resolve => boundaryWaiters.set(id, resolve));
1761
- solidJs.onCleanup(() => boundaryWaiters.delete(id));
1762
- return solidJs.createMemo(() => arrival.then(node => solidJs.runWithOwner(owner, () =>
2114
+ onCleanup(() => boundaryWaiters.delete(id));
2115
+ return createMemo(() => arrival.then(node => runWithOwner(owner, () =>
1763
2116
  node ? adoptBoundary(host, id, node, props, binding) : boundaryComponent(host, id)(props, binding))));
1764
2117
  }
1765
2118
  return boundaryComponent(host, id)(props, binding);
@@ -1833,14 +2186,14 @@ function adoptBoundary(host, id, el, props, binding) {
1833
2186
  });
1834
2187
  };
1835
2188
  liveAppliers.add(applyLiveOp);
1836
- solidJs.onCleanup(() => {
2189
+ onCleanup(() => {
1837
2190
  liveAppliers.delete(applyLiveOp);
1838
2191
  unsubscribe && unsubscribe();
1839
2192
  if (fr && fr.release) for (const fragId of claimedFragments) fr.release(fragId);
1840
2193
  });
1841
2194
  drainRecords();
1842
2195
  for (const op of liveOps.values()) applyLiveOp(op);
1843
- const owner = solidJs.getOwner();
2196
+ const owner = getOwner();
1844
2197
  let release;
1845
2198
  let setGate;
1846
2199
  const frame = createFrame(el, {
@@ -1848,6 +2201,7 @@ function adoptBoundary(host, id, el, props, binding) {
1848
2201
  host,
1849
2202
  id: address,
1850
2203
  slots: slotsFor(props),
2204
+ props,
1851
2205
  ownerScope: boundaryScope(owner),
1852
2206
  reveal: revealSeam(owner),
1853
2207
  onApply: () => {
@@ -1869,18 +2223,18 @@ function adoptBoundary(host, id, el, props, binding) {
1869
2223
  });
1870
2224
  if (binding) {
1871
2225
  const arm = () => new Promise(r => release = r);
1872
- const [gatePromise, setGatePromise] = solidJs.createSignal(undefined);
2226
+ const [gatePromise, setGatePromise] = createSignal(undefined);
1873
2227
  setGate = setGatePromise;
1874
- const gate = solidJs.createMemo(() => gatePromise());
1875
- solidJs.createRenderEffect(binding, (address, prev) => {
2228
+ const gate = createMemo(() => gatePromise());
2229
+ createRenderEffect(binding, (address, prev) => {
1876
2230
  if (prev !== undefined && address !== prev && tables.has(address)) {
1877
2231
  setGatePromise(arm());
1878
2232
  }
1879
2233
  frame.rebind(address);
1880
2234
  });
1881
- solidJs.createRenderEffect(() => (gate(), undefined), () => {});
2235
+ createRenderEffect(() => (gate(), undefined), () => {});
1882
2236
  }
1883
- solidJs.onCleanup(() => frame.dispose());
2237
+ onCleanup(() => frame.dispose());
1884
2238
  return el;
1885
2239
  }
1886
2240
  function installServerComponents(host = getFrameHost()) {
@@ -1889,12 +2243,18 @@ function installServerComponents(host = getFrameHost()) {
1889
2243
  g._$SC = {
1890
2244
  c: {},
1891
2245
  a: {},
2246
+ b: {},
1892
2247
  r(i, a) {
1893
- if (a) {
1894
- g._$SC.a[a] = i;
1895
- g._$SC.reg && g._$SC.reg(a, i);
1896
- }
1897
- return g._$SC.c[i] || (g._$SC.c[i] = (p, b) => g._$SC.impl(i, p, b));
2248
+ const c = g._$SC.c[i] || (g._$SC.c[i] = (p, b) => g._$SC.impl(i, p, b));
2249
+ if (!a) return c;
2250
+ g._$SC.a[a] = i;
2251
+ g._$SC.reg && g._$SC.reg(a, i);
2252
+ return g._$SC.b[a] || (g._$SC.b[a] = Object.assign(p => c(p, () => a), {
2253
+ [COMPONENT_BINDING]: {
2254
+ component: c,
2255
+ address: a
2256
+ }
2257
+ }));
1898
2258
  }
1899
2259
  };
1900
2260
  }
@@ -1907,27 +2267,20 @@ function installServerComponents(host = getFrameHost()) {
1907
2267
  intercept: ({
1908
2268
  id
1909
2269
  }) => {
1910
- if (claimedBoundaries.has(id) || !findBoundaryElement(id)) return undefined;
1911
- return g._$SC.r(id);
2270
+ if (claimedBoundaries.has(id)) return undefined;
2271
+ if (findBoundaryElement(id)) return true;
2272
+ if (!boundaryMayArrive()) return undefined;
2273
+ installRevealHook();
2274
+ return awaitBoundary(id);
1912
2275
  }
1913
2276
  });
1914
2277
  const showing = (address, id) => handler.showing(address, id);
1915
2278
  const records = g._$SC.a || (g._$SC.a = {});
1916
2279
  for (const address in records) showing(address, records[address]);
1917
2280
  g._$SC.reg = showing;
1918
- client.configureServerFunctionsClient({
2281
+ configureServerFunctionsClient({
1919
2282
  responseHandler: handler
1920
2283
  });
1921
2284
  }
1922
2285
 
1923
- exports.FRAME_APPLIED_EVENT = FRAME_APPLIED_EVENT;
1924
- exports.FRAME_STREAM_HEADER = FRAME_STREAM_HEADER;
1925
- exports.applyFrameResponse = applyFrameResponse;
1926
- exports.asyncArg = asyncArg;
1927
- exports.createFrame = createFrame;
1928
- exports.createFrameElement = createFrameElement;
1929
- exports.createFrameHost = createFrameHost;
1930
- exports.createServerComponentHandler = createServerComponentHandler;
1931
- exports.getFrameHost = getFrameHost;
1932
- exports.installServerComponents = installServerComponents;
1933
- exports.isFrameStreamResponse = isFrameStreamResponse;
2286
+ export { FRAME_APPLIED_EVENT, FRAME_HAVE_BUDGET, FRAME_HAVE_HEADER, FRAME_STREAM_HEADER, applyFrameResponse, asyncArg, createFrame, createFrameElement, createFrameHost, createServerComponentHandler, getFrameHost, installServerComponents, isFrameStreamResponse };