@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.
- package/README.md +1 -1
- package/dist/server.dev.js +4472 -0
- package/dist/server.js +1363 -224
- package/dist/{server.cjs → server.observe.js} +1563 -424
- package/dist/{dev.cjs → web.dev.js} +708 -365
- package/dist/web.js +460 -144
- package/dist/{dev.js → web.observe.js} +511 -213
- package/frames/dist/client.dev.js +464 -72
- package/frames/dist/client.js +364 -71
- package/frames/dist/{client.dev.cjs → client.observe.js} +487 -134
- package/frames/dist/server.dev.js +1713 -0
- package/frames/dist/server.js +553 -2495
- package/frames/dist/server.observe.js +1713 -0
- package/frames/package.json +2 -25
- package/package.json +214 -254
- package/performance-tracks/dist/performance-tracks.dev.js +678 -0
- package/performance-tracks/dist/performance-tracks.js +6 -0
- package/performance-tracks/dist/performance-tracks.observe.js +666 -0
- package/performance-tracks/package.json +7 -0
- package/performance-tracks/types/index.d.ts +67 -0
- package/serialization/decode/package.json +2 -15
- package/serialization/dist/decode.js +101 -12
- package/serialization/dist/serialization.js +112 -20
- package/serialization/package.json +2 -15
- package/serialization/types/index.d.ts +76 -157
- package/serialization/types/serializer-decode.d.ts +149 -112
- package/serialization/types/serializer.d.ts +101 -0
- package/server-functions/dist/client.dev.js +1364 -0
- package/server-functions/dist/client.js +745 -85
- package/server-functions/dist/client.observe.js +1343 -0
- package/server-functions/dist/server.dev.js +2203 -175
- package/server-functions/dist/server.js +2111 -176
- package/server-functions/dist/server.observe.js +3043 -0
- package/server-functions/package.json +2 -35
- package/server-functions/rich-args/package.json +2 -15
- package/storage/package.json +2 -15
- package/types/client.d.ts +193 -288
- package/types/constants.d.ts +20 -0
- package/types/cookies.d.ts +32 -84
- package/types/diagnostics.d.ts +56 -0
- package/types/frames/client.d.ts +1 -1
- package/types/frames/frame-client.d.ts +323 -259
- package/types/frames/frame-container-plugin.d.ts +72 -0
- package/types/frames/frame-sink.d.ts +101 -158
- package/types/frames/frame-transport.d.ts +192 -190
- package/types/frames/serializer-decode.d.ts +219 -0
- package/types/frames/serializer.d.ts +76 -157
- package/types/frames/server.d.ts +1 -1
- package/types/head.d.ts +19 -0
- package/types/index.d.ts +62 -76
- package/types/index.server.d.ts +174 -0
- package/types/jsx.d.ts +33 -26
- package/types/observe.d.ts +358 -0
- package/types/reconcile.d.ts +1 -0
- package/types/render.d.ts +9 -0
- package/types/response.d.ts +75 -150
- package/types/serializer-decode.d.ts +149 -112
- package/types/serializer.d.ts +76 -157
- package/types/server-functions/client.d.ts +202 -174
- package/types/server-functions/flash.d.ts +28 -30
- package/types/server-functions/registry.d.ts +102 -0
- package/types/server-functions/rich-args.d.ts +1 -10
- package/types/server-functions/server.d.ts +518 -454
- package/types/server-functions/shared.d.ts +366 -425
- package/types/server-mock.d.ts +110 -13
- package/types/server-observe.d.ts +77 -0
- package/types/server.d.ts +425 -425
- package/types/trace.d.ts +127 -0
- package/LICENSE +0 -21
- package/dist/web.cjs +0 -2007
- package/frames/dist/client.cjs +0 -1916
- package/frames/dist/server.cjs +0 -3667
- package/serialization/dist/decode.cjs +0 -110
- package/serialization/dist/serialization.cjs +0 -232
- package/serialization/types-cjs/index.d.cts +0 -182
- package/serialization/types-cjs/package.json +0 -3
- package/serialization/types-cjs/serializer-decode.d.cts +0 -182
- package/server-functions/dist/client.cjs +0 -646
- package/server-functions/dist/rich-args.cjs +0 -11
- package/server-functions/dist/server.cjs +0 -1077
- package/server-functions/dist/server.dev.cjs +0 -1077
- package/storage/dist/storage.cjs +0 -12
- package/storage/types-cjs/index.d.cts +0 -28
- package/storage/types-cjs/package.json +0 -3
- package/types/core.d.ts +0 -6
- package/types-cjs/client.d.cts +0 -337
- package/types-cjs/cookies.d.cts +0 -93
- package/types-cjs/core.d.cts +0 -6
- package/types-cjs/frames/client.d.cts +0 -36
- package/types-cjs/frames/frame-client.d.cts +0 -338
- package/types-cjs/frames/frame-sink.d.cts +0 -194
- package/types-cjs/frames/frame-transport.d.cts +0 -222
- package/types-cjs/frames/serializer.d.cts +0 -182
- package/types-cjs/frames/server.d.cts +0 -52
- package/types-cjs/index.d.cts +0 -230
- package/types-cjs/jsx-properties.d.cts +0 -93
- package/types-cjs/jsx.d.cts +0 -4150
- package/types-cjs/package.json +0 -3
- package/types-cjs/response.d.cts +0 -174
- package/types-cjs/serializer-decode.d.cts +0 -182
- package/types-cjs/serializer.d.cts +0 -182
- package/types-cjs/server-functions/client.d.cts +0 -201
- package/types-cjs/server-functions/flash.d.cts +0 -38
- package/types-cjs/server-functions/rich-args.d.cts +0 -10
- package/types-cjs/server-functions/server.d.cts +0 -588
- package/types-cjs/server-functions/shared.d.cts +0 -523
- package/types-cjs/server-mock.d.cts +0 -277
- package/types-cjs/server.d.cts +0 -523
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { getOwner, onCleanup, createMemo, runWithOwner, createSignal, createRenderEffect, createLoadingBoundary, createOwner, sharedConfig
|
|
2
|
-
import { insert } from '@solidjs/web';
|
|
3
|
-
import {
|
|
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("
|
|
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
|
-
|
|
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
|
|
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
|
|
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 =
|
|
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
|
-
|
|
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 = "
|
|
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
|
-
|
|
839
|
-
|
|
840
|
-
|
|
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);
|
|
@@ -1001,7 +1150,7 @@ function isSlotMarker(node) {
|
|
|
1001
1150
|
}
|
|
1002
1151
|
function compatible(a, b) {
|
|
1003
1152
|
if (a.nodeType !== b.nodeType) return false;
|
|
1004
|
-
if (a.nodeType === ELEMENT_NODE) return a.nodeName === b.nodeName;
|
|
1153
|
+
if (a.nodeType === ELEMENT_NODE) return a.nodeName === b.nodeName && a.getAttribute("_key") === b.getAttribute("_key");
|
|
1005
1154
|
return a.nodeType === TEXT_NODE || a.nodeType === COMMENT_NODE;
|
|
1006
1155
|
}
|
|
1007
1156
|
function preservesOpen(el) {
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
}
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
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: "
|
|
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
|
-
|
|
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(
|
|
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
|
-
|
|
1393
|
-
if (
|
|
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("
|
|
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
|
-
|
|
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(() =>
|
|
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
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
return g._$SC.
|
|
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)
|
|
1909
|
-
|
|
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 };
|