@solidjs/web 2.0.0-rc.7 → 2.0.0-rc.9
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/dist/server.dev.js +638 -124
- package/dist/server.js +445 -94
- package/dist/{server.dev.cjs → server.observe.js} +602 -416
- package/dist/web.dev.js +229 -49
- package/dist/web.js +194 -46
- package/dist/{web.cjs → web.observe.js} +290 -275
- package/frames/dist/client.dev.js +103 -4
- package/frames/dist/client.js +5 -2
- package/frames/dist/{client.dev.cjs → client.observe.js} +139 -79
- package/frames/dist/server.dev.js +540 -79
- package/frames/dist/server.js +371 -52
- package/frames/dist/{server.cjs → server.observe.js} +544 -140
- package/frames/package.json +15 -21
- package/package.json +145 -294
- package/serialization/decode/package.json +3 -9
- package/serialization/package.json +3 -9
- package/serialization/types/serializer-decode.d.ts +49 -2
- package/server-functions/dist/{client.cjs → client.dev.js} +140 -107
- package/server-functions/dist/client.js +74 -69
- package/server-functions/dist/client.observe.js +1102 -0
- package/server-functions/dist/server.dev.js +430 -41
- package/server-functions/dist/server.js +367 -40
- package/server-functions/dist/{server.cjs → server.observe.js} +430 -85
- package/server-functions/package.json +15 -21
- package/server-functions/rich-args/package.json +3 -9
- package/storage/package.json +3 -9
- package/types/client.d.ts +39 -1
- package/types/diagnostics.d.ts +24 -0
- package/types/frames/frame-transport.d.ts +1 -1
- package/types/frames/serializer-decode.d.ts +49 -2
- package/types/index.d.ts +25 -15
- package/types/index.server.d.ts +35 -8
- package/types/jsx.d.ts +15 -4
- package/types/observe.d.ts +294 -0
- package/types/response.d.ts +18 -0
- package/types/serializer-decode.d.ts +49 -2
- package/types/server-functions/client.d.ts +32 -22
- package/types/server-functions/server.d.ts +55 -41
- package/types/server-functions/shared.d.ts +39 -9
- package/types/server-mock.d.ts +26 -4
- package/types/server-observe.d.ts +39 -0
- package/types/server.d.ts +105 -6
- package/types/trace.d.ts +79 -0
- package/dist/server.cjs +0 -3708
- package/dist/web.dev.cjs +0 -2285
- package/frames/dist/client.cjs +0 -2043
- package/frames/dist/server.dev.cjs +0 -4584
- package/serialization/dist/decode.cjs +0 -155
- package/serialization/dist/serialization.cjs +0 -275
- package/serialization/types-cjs/index.d.cts +0 -101
- package/serialization/types-cjs/package.json +0 -3
- package/serialization/types-cjs/serializer-decode.d.cts +0 -172
- package/serialization/types-cjs/serializer.d.cts +0 -101
- package/server-functions/dist/rich-args.cjs +0 -11
- package/server-functions/dist/server.dev.cjs +0 -2409
- 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-cjs/client.d.cts +0 -197
- package/types-cjs/constants.d.cts +0 -20
- package/types-cjs/cookies.d.cts +0 -41
- package/types-cjs/frames/client.d.cts +0 -36
- package/types-cjs/frames/frame-client.d.cts +0 -370
- package/types-cjs/frames/frame-container-plugin.d.cts +0 -71
- package/types-cjs/frames/frame-sink.d.cts +0 -92
- package/types-cjs/frames/frame-transport.d.cts +0 -189
- package/types-cjs/frames/serializer-decode.d.cts +0 -172
- package/types-cjs/frames/serializer.d.cts +0 -101
- package/types-cjs/frames/server.d.cts +0 -52
- package/types-cjs/head.d.cts +0 -19
- package/types-cjs/index.d.cts +0 -191
- package/types-cjs/index.server.d.cts +0 -147
- package/types-cjs/jsx-properties.d.cts +0 -93
- package/types-cjs/jsx.d.cts +0 -4146
- package/types-cjs/package.json +0 -3
- package/types-cjs/reconcile.d.cts +0 -1
- package/types-cjs/render.d.cts +0 -6
- package/types-cjs/response.d.cts +0 -81
- package/types-cjs/serializer-decode.d.cts +0 -172
- package/types-cjs/serializer.d.cts +0 -101
- package/types-cjs/server-functions/client.d.cts +0 -184
- package/types-cjs/server-functions/flash.d.cts +0 -36
- package/types-cjs/server-functions/registry.d.cts +0 -100
- package/types-cjs/server-functions/rich-args.d.cts +0 -1
- package/types-cjs/server-functions/server.d.cts +0 -546
- package/types-cjs/server-functions/shared.d.cts +0 -283
- package/types-cjs/server-mock.d.cts +0 -337
- package/types-cjs/server.d.cts +0 -408
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { getOwner, onCleanup, createMemo, runWithOwner, createSignal, createRenderEffect, createLoadingBoundary, createOwner, sharedConfig
|
|
1
|
+
import { DEV, OBSERVE, getOwner, onCleanup, createMemo, runWithOwner, createSignal, createRenderEffect, createLoadingBoundary, createOwner, sharedConfig } from 'solid-js';
|
|
2
2
|
import { delegateEvents, insert } from '@solidjs/web';
|
|
3
|
-
import {
|
|
3
|
+
import { frameAddress, SINGLE_FLIGHT_HEADER, deserializeStream, getServerFunctionsCodec, createChunk, getFlightDataConsumer, ERROR_HEADER, REVALIDATE_HEADER, 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;
|
|
@@ -1175,7 +1176,16 @@ function devCheckRange(start, id) {
|
|
|
1175
1176
|
if (n.nodeType === COMMENT_NODE && n.data === end) return;
|
|
1176
1177
|
n = n.nextSibling;
|
|
1177
1178
|
}
|
|
1178
|
-
|
|
1179
|
+
DEV.report(OBSERVE.diagnostics.emit({
|
|
1180
|
+
code: "FRAME_MARKER_CORRUPTED",
|
|
1181
|
+
kind: "ssr",
|
|
1182
|
+
severity: "error",
|
|
1183
|
+
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.`,
|
|
1184
|
+
data: {
|
|
1185
|
+
slot: id,
|
|
1186
|
+
end
|
|
1187
|
+
}
|
|
1188
|
+
}, null));
|
|
1179
1189
|
}
|
|
1180
1190
|
function findRangeStart(from, id, bound) {
|
|
1181
1191
|
const target = `slot:${id}:start`;
|
|
@@ -1330,11 +1340,98 @@ function stashRange(frag, start, id) {
|
|
|
1330
1340
|
return null;
|
|
1331
1341
|
}
|
|
1332
1342
|
|
|
1343
|
+
const RECORDS = Symbol.for("@solidjs/signals/observe/records");
|
|
1344
|
+
function records() {
|
|
1345
|
+
return globalThis[RECORDS];
|
|
1346
|
+
}
|
|
1347
|
+
function frameCensus(event, type, own) {
|
|
1348
|
+
event.chunks++;
|
|
1349
|
+
switch (type) {
|
|
1350
|
+
case "html":
|
|
1351
|
+
if (!own) event.regions++;else if (event.shellMs === undefined) event.shellMs = performance.now() - event.at;
|
|
1352
|
+
break;
|
|
1353
|
+
case "fragment":
|
|
1354
|
+
event.fragments++;
|
|
1355
|
+
break;
|
|
1356
|
+
case "slot":
|
|
1357
|
+
event.slots++;
|
|
1358
|
+
break;
|
|
1359
|
+
case "error":
|
|
1360
|
+
event.errors++;
|
|
1361
|
+
break;
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
function observeFrameApply(response) {
|
|
1365
|
+
const channel = records();
|
|
1366
|
+
if (channel === undefined || !channel.observed("frame")) return undefined;
|
|
1367
|
+
let current;
|
|
1368
|
+
const close = (outcome, error) => {
|
|
1369
|
+
const open = current;
|
|
1370
|
+
current = undefined;
|
|
1371
|
+
open.event.durationMs = performance.now() - open.event.at;
|
|
1372
|
+
open.event.outcome = outcome;
|
|
1373
|
+
const live = {
|
|
1374
|
+
response
|
|
1375
|
+
};
|
|
1376
|
+
if (error !== undefined) live.error = error;
|
|
1377
|
+
channel.emit("frame", open.event, live);
|
|
1378
|
+
};
|
|
1379
|
+
return {
|
|
1380
|
+
chunk(chunk, wireId) {
|
|
1381
|
+
if (chunk.type === "start") {
|
|
1382
|
+
if (current !== undefined) close("truncated");
|
|
1383
|
+
const event = {
|
|
1384
|
+
side: "client",
|
|
1385
|
+
id: wireId,
|
|
1386
|
+
version: chunk.version,
|
|
1387
|
+
at: performance.now(),
|
|
1388
|
+
durationMs: 0,
|
|
1389
|
+
outcome: "complete",
|
|
1390
|
+
chunks: 0,
|
|
1391
|
+
fragments: 0,
|
|
1392
|
+
slots: 0,
|
|
1393
|
+
regions: 0,
|
|
1394
|
+
errors: 0
|
|
1395
|
+
};
|
|
1396
|
+
if (chunk.id !== wireId) event.address = chunk.id;
|
|
1397
|
+
current = {
|
|
1398
|
+
event,
|
|
1399
|
+
applied: chunk.id
|
|
1400
|
+
};
|
|
1401
|
+
return;
|
|
1402
|
+
}
|
|
1403
|
+
if (current === undefined) return;
|
|
1404
|
+
if (chunk.type === "complete") {
|
|
1405
|
+
if (chunk.id === current.applied) close("complete");
|
|
1406
|
+
return;
|
|
1407
|
+
}
|
|
1408
|
+
frameCensus(current.event, chunk.type, chunk.id === current.applied);
|
|
1409
|
+
},
|
|
1410
|
+
end(error) {
|
|
1411
|
+
if (current !== undefined) close(error !== undefined ? "error" : "truncated", error);
|
|
1412
|
+
}
|
|
1413
|
+
};
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1333
1416
|
const FRAME_STREAM_HEADER = "X-Frame-Stream";
|
|
1334
1417
|
function isFrameStreamResponse(response) {
|
|
1335
1418
|
return response.headers.has(FRAME_STREAM_HEADER);
|
|
1336
1419
|
}
|
|
1337
|
-
|
|
1420
|
+
const applyFrameResponse = observedApplyFrameResponse ;
|
|
1421
|
+
async function observedApplyFrameResponse(response, host, options = {}) {
|
|
1422
|
+
const observation = observeFrameApply(response);
|
|
1423
|
+
if (!observation) return applyFrames(response, host, options);
|
|
1424
|
+
let applied;
|
|
1425
|
+
try {
|
|
1426
|
+
applied = await applyFrames(response, host, options, observation);
|
|
1427
|
+
} catch (error) {
|
|
1428
|
+
observation.end(error);
|
|
1429
|
+
throw error;
|
|
1430
|
+
}
|
|
1431
|
+
observation.end();
|
|
1432
|
+
return applied;
|
|
1433
|
+
}
|
|
1434
|
+
async function applyFrames(response, host, options = {}, observation) {
|
|
1338
1435
|
const rootId = response.headers.get(FRAME_STREAM_HEADER) ?? "";
|
|
1339
1436
|
const as = options.as;
|
|
1340
1437
|
const version = options.version;
|
|
@@ -1346,12 +1443,14 @@ async function applyFrameResponse(response, host, options = {}) {
|
|
|
1346
1443
|
if (chunk.type === "outcome") {
|
|
1347
1444
|
if (options.onOutcome) options.onOutcome(chunk.payload);
|
|
1348
1445
|
} else {
|
|
1446
|
+
const wireId = chunk.id;
|
|
1349
1447
|
if (as !== undefined && chunk.id === rootId) chunk.id = as;
|
|
1350
1448
|
if (perFrame) {
|
|
1351
1449
|
let v = perFrame.get(chunk.id);
|
|
1352
1450
|
if (v === undefined) perFrame.set(chunk.id, v = version(chunk.id));
|
|
1353
1451
|
chunk.version = v;
|
|
1354
1452
|
} else if (version !== undefined) chunk.version = version;
|
|
1453
|
+
if (observation) observation.chunk(chunk, wireId);
|
|
1355
1454
|
if (chunk.type === "data" && host.prepareData) await host.prepareData();
|
|
1356
1455
|
host.apply(chunk);
|
|
1357
1456
|
}
|
package/frames/dist/client.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { getOwner, onCleanup, createMemo, runWithOwner, createSignal, createRenderEffect, createLoadingBoundary, createOwner, sharedConfig
|
|
1
|
+
import { getOwner, onCleanup, createMemo, runWithOwner, createSignal, createRenderEffect, createLoadingBoundary, createOwner, sharedConfig } from 'solid-js';
|
|
2
2
|
import { delegateEvents, insert } from '@solidjs/web';
|
|
3
3
|
import { ChunkReader, frameAddress, SINGLE_FLIGHT_HEADER, deserializeStream, getServerFunctionsCodec, createChunk, getFlightDataConsumer, ERROR_HEADER, REVALIDATE_HEADER, 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;
|
|
@@ -1314,7 +1315,8 @@ const FRAME_STREAM_HEADER = "X-Frame-Stream";
|
|
|
1314
1315
|
function isFrameStreamResponse(response) {
|
|
1315
1316
|
return response.headers.has(FRAME_STREAM_HEADER);
|
|
1316
1317
|
}
|
|
1317
|
-
|
|
1318
|
+
const applyFrameResponse = applyFrames;
|
|
1319
|
+
async function applyFrames(response, host, options = {}, observation) {
|
|
1318
1320
|
const rootId = response.headers.get(FRAME_STREAM_HEADER) ?? "";
|
|
1319
1321
|
const as = options.as;
|
|
1320
1322
|
const version = options.version;
|
|
@@ -1326,6 +1328,7 @@ async function applyFrameResponse(response, host, options = {}) {
|
|
|
1326
1328
|
if (chunk.type === "outcome") {
|
|
1327
1329
|
if (options.onOutcome) options.onOutcome(chunk.payload);
|
|
1328
1330
|
} else {
|
|
1331
|
+
chunk.id;
|
|
1329
1332
|
if (as !== undefined && chunk.id === rootId) chunk.id = as;
|
|
1330
1333
|
if (perFrame) {
|
|
1331
1334
|
let v = perFrame.get(chunk.id);
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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, deserializeStream, getServerFunctionsCodec, createChunk, getFlightDataConsumer, ERROR_HEADER, REVALIDATE_HEADER, ChunkReader, configureServerFunctionsClient } from '@solidjs/web/server-functions/client';
|
|
6
5
|
|
|
7
6
|
const ELEMENT_NODE = 1;
|
|
8
7
|
const TEXT_NODE = 3;
|
|
@@ -46,9 +45,6 @@ boundSeam.resolve = (el, type) => {
|
|
|
46
45
|
function claimFn(frame, pos, prop) {
|
|
47
46
|
const fn = frame.clientProp(prop);
|
|
48
47
|
if (typeof fn === "function") return fn;
|
|
49
|
-
if (fn !== undefined) {
|
|
50
|
-
console.warn(`A server element claims \`${pos}\` from client prop \`${prop}\`, but the mounted ` + `frame's prop is not a function.`);
|
|
51
|
-
}
|
|
52
48
|
return undefined;
|
|
53
49
|
}
|
|
54
50
|
function sweepBound(root, frame, delegate, scope) {
|
|
@@ -432,7 +428,6 @@ class FrameImpl {
|
|
|
432
428
|
if (key.startsWith("hole:")) {
|
|
433
429
|
if (key.endsWith(":error")) {
|
|
434
430
|
this.#appliedHoles.set(key, record);
|
|
435
|
-
console.error(`Live hole ${key.slice(5, -6)} failed on the server; latched:`, record);
|
|
436
431
|
} else if (this.#applyHole(key.slice(5), record.value)) {
|
|
437
432
|
this.#appliedHoles.set(key, record);
|
|
438
433
|
this.#applied(version, "morph");
|
|
@@ -771,9 +766,6 @@ class FrameImpl {
|
|
|
771
766
|
if (!open) return false;
|
|
772
767
|
const close = rangeClose(open, "lh:/" + marker.slice(3));
|
|
773
768
|
if (!close) {
|
|
774
|
-
{
|
|
775
|
-
console.error(`Live hole "${marker}" is missing its closing comment; update dropped. ` + `Likely an HTML-rewriting layer stripped it.`, open);
|
|
776
|
-
}
|
|
777
769
|
return false;
|
|
778
770
|
}
|
|
779
771
|
reconcileChildren(open.parentNode, parseFragment(html), open, close, this.#claimTree);
|
|
@@ -826,9 +818,6 @@ class FrameImpl {
|
|
|
826
818
|
if (assets && assets.inlineStyles) applyInlineStyles(assets.inlineStyles);
|
|
827
819
|
const content = this.#store[`seg:${name}`];
|
|
828
820
|
const closing = rangeClose(tpl, placeholderId(name));
|
|
829
|
-
if (!closing) {
|
|
830
|
-
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);
|
|
831
|
-
}
|
|
832
821
|
const parent = tpl.parentNode;
|
|
833
822
|
removeUntil(parent, tpl.nextSibling, closing);
|
|
834
823
|
if (this.#options.reveal) {
|
|
@@ -1043,7 +1032,6 @@ function collectSlots(n, end, out) {
|
|
|
1043
1032
|
while (n && n !== end) {
|
|
1044
1033
|
const id = slotStartId(n);
|
|
1045
1034
|
if (id !== null) {
|
|
1046
|
-
devCheckRange(n, id);
|
|
1047
1035
|
if (!out.has(id)) out.set(id, n);
|
|
1048
1036
|
n = afterRange(n, id);
|
|
1049
1037
|
continue;
|
|
@@ -1170,15 +1158,6 @@ function afterRange(start, id) {
|
|
|
1170
1158
|
}
|
|
1171
1159
|
return null;
|
|
1172
1160
|
}
|
|
1173
|
-
function devCheckRange(start, id) {
|
|
1174
|
-
const end = slotEnd(id);
|
|
1175
|
-
let n = start.nextSibling;
|
|
1176
|
-
while (n) {
|
|
1177
|
-
if (n.nodeType === COMMENT_NODE && n.data === end) return;
|
|
1178
|
-
n = n.nextSibling;
|
|
1179
|
-
}
|
|
1180
|
-
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);
|
|
1181
|
-
}
|
|
1182
1161
|
function findRangeStart(from, id, bound) {
|
|
1183
1162
|
const target = `slot:${id}:start`;
|
|
1184
1163
|
let n = from;
|
|
@@ -1332,28 +1311,117 @@ function stashRange(frag, start, id) {
|
|
|
1332
1311
|
return null;
|
|
1333
1312
|
}
|
|
1334
1313
|
|
|
1314
|
+
const RECORDS = Symbol.for("@solidjs/signals/observe/records");
|
|
1315
|
+
function records() {
|
|
1316
|
+
return globalThis[RECORDS];
|
|
1317
|
+
}
|
|
1318
|
+
function frameCensus(event, type, own) {
|
|
1319
|
+
event.chunks++;
|
|
1320
|
+
switch (type) {
|
|
1321
|
+
case "html":
|
|
1322
|
+
if (!own) event.regions++;else if (event.shellMs === undefined) event.shellMs = performance.now() - event.at;
|
|
1323
|
+
break;
|
|
1324
|
+
case "fragment":
|
|
1325
|
+
event.fragments++;
|
|
1326
|
+
break;
|
|
1327
|
+
case "slot":
|
|
1328
|
+
event.slots++;
|
|
1329
|
+
break;
|
|
1330
|
+
case "error":
|
|
1331
|
+
event.errors++;
|
|
1332
|
+
break;
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
function observeFrameApply(response) {
|
|
1336
|
+
const channel = records();
|
|
1337
|
+
if (channel === undefined || !channel.observed("frame")) return undefined;
|
|
1338
|
+
let current;
|
|
1339
|
+
const close = (outcome, error) => {
|
|
1340
|
+
const open = current;
|
|
1341
|
+
current = undefined;
|
|
1342
|
+
open.event.durationMs = performance.now() - open.event.at;
|
|
1343
|
+
open.event.outcome = outcome;
|
|
1344
|
+
const live = {
|
|
1345
|
+
response
|
|
1346
|
+
};
|
|
1347
|
+
if (error !== undefined) live.error = error;
|
|
1348
|
+
channel.emit("frame", open.event, live);
|
|
1349
|
+
};
|
|
1350
|
+
return {
|
|
1351
|
+
chunk(chunk, wireId) {
|
|
1352
|
+
if (chunk.type === "start") {
|
|
1353
|
+
if (current !== undefined) close("truncated");
|
|
1354
|
+
const event = {
|
|
1355
|
+
side: "client",
|
|
1356
|
+
id: wireId,
|
|
1357
|
+
version: chunk.version,
|
|
1358
|
+
at: performance.now(),
|
|
1359
|
+
durationMs: 0,
|
|
1360
|
+
outcome: "complete",
|
|
1361
|
+
chunks: 0,
|
|
1362
|
+
fragments: 0,
|
|
1363
|
+
slots: 0,
|
|
1364
|
+
regions: 0,
|
|
1365
|
+
errors: 0
|
|
1366
|
+
};
|
|
1367
|
+
if (chunk.id !== wireId) event.address = chunk.id;
|
|
1368
|
+
current = {
|
|
1369
|
+
event,
|
|
1370
|
+
applied: chunk.id
|
|
1371
|
+
};
|
|
1372
|
+
return;
|
|
1373
|
+
}
|
|
1374
|
+
if (current === undefined) return;
|
|
1375
|
+
if (chunk.type === "complete") {
|
|
1376
|
+
if (chunk.id === current.applied) close("complete");
|
|
1377
|
+
return;
|
|
1378
|
+
}
|
|
1379
|
+
frameCensus(current.event, chunk.type, chunk.id === current.applied);
|
|
1380
|
+
},
|
|
1381
|
+
end(error) {
|
|
1382
|
+
if (current !== undefined) close(error !== undefined ? "error" : "truncated", error);
|
|
1383
|
+
}
|
|
1384
|
+
};
|
|
1385
|
+
}
|
|
1386
|
+
|
|
1335
1387
|
const FRAME_STREAM_HEADER = "X-Frame-Stream";
|
|
1336
1388
|
function isFrameStreamResponse(response) {
|
|
1337
1389
|
return response.headers.has(FRAME_STREAM_HEADER);
|
|
1338
1390
|
}
|
|
1339
|
-
|
|
1391
|
+
const applyFrameResponse = observedApplyFrameResponse ;
|
|
1392
|
+
async function observedApplyFrameResponse(response, host, options = {}) {
|
|
1393
|
+
const observation = observeFrameApply(response);
|
|
1394
|
+
if (!observation) return applyFrames(response, host, options);
|
|
1395
|
+
let applied;
|
|
1396
|
+
try {
|
|
1397
|
+
applied = await applyFrames(response, host, options, observation);
|
|
1398
|
+
} catch (error) {
|
|
1399
|
+
observation.end(error);
|
|
1400
|
+
throw error;
|
|
1401
|
+
}
|
|
1402
|
+
observation.end();
|
|
1403
|
+
return applied;
|
|
1404
|
+
}
|
|
1405
|
+
async function applyFrames(response, host, options = {}, observation) {
|
|
1340
1406
|
const rootId = response.headers.get(FRAME_STREAM_HEADER) ?? "";
|
|
1341
1407
|
const as = options.as;
|
|
1342
1408
|
const version = options.version;
|
|
1343
1409
|
const perFrame = typeof version === "function" ? new Map() : null;
|
|
1344
|
-
const reader = new
|
|
1410
|
+
const reader = new ChunkReader(response.body);
|
|
1345
1411
|
let result = await reader.next();
|
|
1346
1412
|
while (!result.done) {
|
|
1347
1413
|
const chunk = JSON.parse(result.value);
|
|
1348
1414
|
if (chunk.type === "outcome") {
|
|
1349
1415
|
if (options.onOutcome) options.onOutcome(chunk.payload);
|
|
1350
1416
|
} else {
|
|
1417
|
+
const wireId = chunk.id;
|
|
1351
1418
|
if (as !== undefined && chunk.id === rootId) chunk.id = as;
|
|
1352
1419
|
if (perFrame) {
|
|
1353
1420
|
let v = perFrame.get(chunk.id);
|
|
1354
1421
|
if (v === undefined) perFrame.set(chunk.id, v = version(chunk.id));
|
|
1355
1422
|
chunk.version = v;
|
|
1356
1423
|
} else if (version !== undefined) chunk.version = version;
|
|
1424
|
+
if (observation) observation.chunk(chunk, wireId);
|
|
1357
1425
|
if (chunk.type === "data" && host.prepareData) await host.prepareData();
|
|
1358
1426
|
host.apply(chunk);
|
|
1359
1427
|
}
|
|
@@ -1412,8 +1480,8 @@ function createServerComponentHandler({
|
|
|
1412
1480
|
component,
|
|
1413
1481
|
onStream,
|
|
1414
1482
|
intercept,
|
|
1415
|
-
consumer =
|
|
1416
|
-
codec =
|
|
1483
|
+
consumer = getFlightDataConsumer,
|
|
1484
|
+
codec = getServerFunctionsCodec
|
|
1417
1485
|
}) {
|
|
1418
1486
|
const byFn = new Map();
|
|
1419
1487
|
const componentFor = fnId => {
|
|
@@ -1446,13 +1514,13 @@ function createServerComponentHandler({
|
|
|
1446
1514
|
intercept: intercept && (info => {
|
|
1447
1515
|
const hit = intercept(info);
|
|
1448
1516
|
if (hit === undefined) return undefined;
|
|
1449
|
-
return bindingFor(
|
|
1517
|
+
return bindingFor(frameAddress(info.id, info.args), info.id);
|
|
1450
1518
|
}),
|
|
1451
1519
|
handle(response, ctx) {
|
|
1452
1520
|
if (!isFrameStreamResponse(response)) return undefined;
|
|
1453
|
-
const address =
|
|
1521
|
+
const address = frameAddress(ctx.id, ctx.args);
|
|
1454
1522
|
const binding = bindingFor(address, ctx.id);
|
|
1455
|
-
if (response.headers.has(
|
|
1523
|
+
if (response.headers.has(SINGLE_FLIGHT_HEADER)) {
|
|
1456
1524
|
return applyFlightResponse(response, address, binding);
|
|
1457
1525
|
}
|
|
1458
1526
|
const version = bump(address);
|
|
@@ -1490,7 +1558,7 @@ function createServerComponentHandler({
|
|
|
1490
1558
|
feed = controller;
|
|
1491
1559
|
}
|
|
1492
1560
|
});
|
|
1493
|
-
const payload =
|
|
1561
|
+
const payload = deserializeStream(new Response(source), flightCodec(codec()));
|
|
1494
1562
|
let carried = false;
|
|
1495
1563
|
await applyFrameResponse(response, host, {
|
|
1496
1564
|
as,
|
|
@@ -1501,7 +1569,7 @@ function createServerComponentHandler({
|
|
|
1501
1569
|
},
|
|
1502
1570
|
onOutcome: text => {
|
|
1503
1571
|
carried = true;
|
|
1504
|
-
feed.enqueue(
|
|
1572
|
+
feed.enqueue(createChunk(text));
|
|
1505
1573
|
}
|
|
1506
1574
|
});
|
|
1507
1575
|
feed.close();
|
|
@@ -1511,7 +1579,7 @@ function createServerComponentHandler({
|
|
|
1511
1579
|
if (deliver) await deliver(envelope.data, {
|
|
1512
1580
|
response
|
|
1513
1581
|
});
|
|
1514
|
-
if (response.headers.has(
|
|
1582
|
+
if (response.headers.has(ERROR_HEADER) && !response.headers.has("Location") && !response.headers.has(REVALIDATE_HEADER)) {
|
|
1515
1583
|
throw envelope.value;
|
|
1516
1584
|
}
|
|
1517
1585
|
return rootId ? binding : envelope.value;
|
|
@@ -1554,7 +1622,9 @@ function reviveContainerTraces(value) {
|
|
|
1554
1622
|
return value;
|
|
1555
1623
|
}
|
|
1556
1624
|
|
|
1557
|
-
|
|
1625
|
+
const materializeContainerTrace = core.materializeContainerTrace;
|
|
1626
|
+
|
|
1627
|
+
setContainerTraceMaterializer(materializeContainerTrace);
|
|
1558
1628
|
function asyncArg(value) {
|
|
1559
1629
|
return value;
|
|
1560
1630
|
}
|
|
@@ -1588,7 +1658,7 @@ function getFrameHost() {
|
|
|
1588
1658
|
resolve: (ref, id) => tableFor(id)?.resolve(ref),
|
|
1589
1659
|
revive: reviveContainerTraces,
|
|
1590
1660
|
isContainer: isMaterializedContainer,
|
|
1591
|
-
delegate:
|
|
1661
|
+
delegate: delegateEvents
|
|
1592
1662
|
});
|
|
1593
1663
|
}
|
|
1594
1664
|
return sharedHost;
|
|
@@ -1621,7 +1691,7 @@ function hasPendingFragment(existing) {
|
|
|
1621
1691
|
return false;
|
|
1622
1692
|
}
|
|
1623
1693
|
function claimRender(prefix, existing, render) {
|
|
1624
|
-
const sc =
|
|
1694
|
+
const sc = sharedConfig;
|
|
1625
1695
|
if (!sc.getNextContextId) return render();
|
|
1626
1696
|
const registry = new Map();
|
|
1627
1697
|
for (const n of existing) {
|
|
@@ -1637,7 +1707,7 @@ function claimRender(prefix, existing, render) {
|
|
|
1637
1707
|
sc.hydrating = true;
|
|
1638
1708
|
sc.claimRoots = existing;
|
|
1639
1709
|
try {
|
|
1640
|
-
return
|
|
1710
|
+
return runWithOwner(createOwner({
|
|
1641
1711
|
id: prefix
|
|
1642
1712
|
}), render);
|
|
1643
1713
|
} finally {
|
|
@@ -1647,7 +1717,7 @@ function claimRender(prefix, existing, render) {
|
|
|
1647
1717
|
}
|
|
1648
1718
|
}
|
|
1649
1719
|
function liveSlotProps(initial, ctx) {
|
|
1650
|
-
const [args, setArgs] =
|
|
1720
|
+
const [args, setArgs] = createSignal(initial);
|
|
1651
1721
|
ctx.onUpdate(next => setArgs(() => next));
|
|
1652
1722
|
return slotArgsProxy(args);
|
|
1653
1723
|
}
|
|
@@ -1655,7 +1725,7 @@ function isAsyncValue(v) {
|
|
|
1655
1725
|
return v !== null && typeof v === "object" && (typeof v.then === "function" || typeof v[Symbol.asyncIterator] === "function");
|
|
1656
1726
|
}
|
|
1657
1727
|
function slotArgsProxy(args) {
|
|
1658
|
-
const owner =
|
|
1728
|
+
const owner = getOwner();
|
|
1659
1729
|
const asyncReads = new Map();
|
|
1660
1730
|
return new Proxy({}, {
|
|
1661
1731
|
get: (_, key) => {
|
|
@@ -1664,7 +1734,7 @@ function slotArgsProxy(args) {
|
|
|
1664
1734
|
if (!isAsyncValue(v)) return v;
|
|
1665
1735
|
let read = asyncReads.get(key);
|
|
1666
1736
|
if (!read) {
|
|
1667
|
-
const make = () =>
|
|
1737
|
+
const make = () => createMemo(() => {
|
|
1668
1738
|
const raw = args()[key];
|
|
1669
1739
|
if (raw != null && typeof raw.then === "function") {
|
|
1670
1740
|
if (raw.s === 1) return raw.v;
|
|
@@ -1674,7 +1744,7 @@ function slotArgsProxy(args) {
|
|
|
1674
1744
|
}, {
|
|
1675
1745
|
transparent: true
|
|
1676
1746
|
});
|
|
1677
|
-
read = owner ?
|
|
1747
|
+
read = owner ? runWithOwner(owner, make) : make();
|
|
1678
1748
|
asyncReads.set(key, read);
|
|
1679
1749
|
}
|
|
1680
1750
|
return read();
|
|
@@ -1712,7 +1782,7 @@ function slotsFor(props) {
|
|
|
1712
1782
|
fillScopes.delete(key);
|
|
1713
1783
|
prevFill.dispose();
|
|
1714
1784
|
}
|
|
1715
|
-
const fillOwner = streamInvoke ?
|
|
1785
|
+
const fillOwner = streamInvoke ? createOwner() : null;
|
|
1716
1786
|
if (fillOwner && key !== undefined && ctx) {
|
|
1717
1787
|
fillScopes.set(key, fillOwner);
|
|
1718
1788
|
ctx.onCleanup(() => {
|
|
@@ -1738,21 +1808,21 @@ function slotsFor(props) {
|
|
|
1738
1808
|
};
|
|
1739
1809
|
const adopted = !!(ctx && ctx.frame && ctx.adopted && ctx.existing && ctx.existing.length);
|
|
1740
1810
|
const prefix = ctx && ctx.frame ? `sc-${ctx.frame}-${ctx.key}-` : "";
|
|
1741
|
-
const value = fillOwner ?
|
|
1811
|
+
const value = fillOwner ? runWithOwner(fillOwner, () => adopted ? claimRender(prefix, ctx.existing, evaluate) : evaluate()) : adopted ? claimRender(prefix, ctx.existing, evaluate) : evaluate();
|
|
1742
1812
|
if (!isReactiveContent(value)) {
|
|
1743
1813
|
return settle(normalizeSlotContent(value));
|
|
1744
1814
|
}
|
|
1745
1815
|
if (ctx && ctx.range) {
|
|
1746
1816
|
const source = value;
|
|
1747
|
-
const owner =
|
|
1817
|
+
const owner = createOwner();
|
|
1748
1818
|
bindings.set(key, owner);
|
|
1749
1819
|
ctx.onCleanup(() => {
|
|
1750
1820
|
if (bindings.get(key) === owner) bindings.delete(key);
|
|
1751
1821
|
owner.dispose();
|
|
1752
1822
|
});
|
|
1753
1823
|
const end = ctx.range.end;
|
|
1754
|
-
const bind = () =>
|
|
1755
|
-
|
|
1824
|
+
const bind = () => insert(end.parentNode, () => typeof source === "function" ? source() : source, end, [...ctx.existing]);
|
|
1825
|
+
runWithOwner(owner, () => adopted ? claimRender(prefix, ctx.existing, bind) : bind());
|
|
1756
1826
|
return undefined;
|
|
1757
1827
|
}
|
|
1758
1828
|
return settle(normalizeSlotContent(value));
|
|
@@ -1761,15 +1831,15 @@ function slotsFor(props) {
|
|
|
1761
1831
|
});
|
|
1762
1832
|
}
|
|
1763
1833
|
function revealSeam(owner) {
|
|
1764
|
-
return seam =>
|
|
1834
|
+
return seam => runWithOwner(owner, () => insert(seam.before.parentNode, createLoadingBoundary(() => seam.content(), () => seam.fallback), seam.before));
|
|
1765
1835
|
}
|
|
1766
1836
|
let streamInvoke = false;
|
|
1767
1837
|
function boundaryScope(owner) {
|
|
1768
1838
|
return fn => {
|
|
1769
|
-
if (
|
|
1839
|
+
if (getOwner()) return fn();
|
|
1770
1840
|
streamInvoke = true;
|
|
1771
1841
|
try {
|
|
1772
|
-
return
|
|
1842
|
+
return runWithOwner(owner, fn);
|
|
1773
1843
|
} finally {
|
|
1774
1844
|
streamInvoke = false;
|
|
1775
1845
|
}
|
|
@@ -1777,7 +1847,7 @@ function boundaryScope(owner) {
|
|
|
1777
1847
|
}
|
|
1778
1848
|
function boundaryComponent(host, fnId) {
|
|
1779
1849
|
return (props, binding) => {
|
|
1780
|
-
const owner =
|
|
1850
|
+
const owner = getOwner();
|
|
1781
1851
|
const id = binding ? binding() : fnId;
|
|
1782
1852
|
let applied = !tables.has(id);
|
|
1783
1853
|
let release;
|
|
@@ -1804,10 +1874,10 @@ function boundaryComponent(host, fnId) {
|
|
|
1804
1874
|
setGate && setGate(undefined);
|
|
1805
1875
|
}
|
|
1806
1876
|
});
|
|
1807
|
-
const [gatePromise, setGatePromise] =
|
|
1877
|
+
const [gatePromise, setGatePromise] = createSignal(applied ? undefined : mountGate);
|
|
1808
1878
|
setGate = setGatePromise;
|
|
1809
1879
|
if (binding) {
|
|
1810
|
-
|
|
1880
|
+
createRenderEffect(binding, (address, prev) => {
|
|
1811
1881
|
if (prev !== undefined && address !== prev && tables.has(address)) {
|
|
1812
1882
|
applied = false;
|
|
1813
1883
|
setGatePromise(arm());
|
|
@@ -1815,10 +1885,10 @@ function boundaryComponent(host, fnId) {
|
|
|
1815
1885
|
frame.rebind(address);
|
|
1816
1886
|
});
|
|
1817
1887
|
}
|
|
1818
|
-
|
|
1888
|
+
onCleanup(dispose);
|
|
1819
1889
|
if (applied && !binding) return element;
|
|
1820
|
-
const gate =
|
|
1821
|
-
return
|
|
1890
|
+
const gate = createMemo(() => gatePromise());
|
|
1891
|
+
return createMemo(() => (gate(), element));
|
|
1822
1892
|
};
|
|
1823
1893
|
}
|
|
1824
1894
|
const claimedBoundaries = new Set();
|
|
@@ -1885,10 +1955,10 @@ function documentBoundary(host, id, props, binding) {
|
|
|
1885
1955
|
const el = !claimed ? findBoundaryElement(id) : undefined;
|
|
1886
1956
|
if (el) return adoptBoundary(host, id, el, props, binding);
|
|
1887
1957
|
if (!claimed && !boundaryWaiters.has(id) && boundaryMayArrive()) {
|
|
1888
|
-
const owner =
|
|
1958
|
+
const owner = getOwner();
|
|
1889
1959
|
const arrival = new Promise(resolve => boundaryWaiters.set(id, resolve));
|
|
1890
|
-
|
|
1891
|
-
return
|
|
1960
|
+
onCleanup(() => boundaryWaiters.delete(id));
|
|
1961
|
+
return createMemo(() => arrival.then(node => runWithOwner(owner, () =>
|
|
1892
1962
|
node ? adoptBoundary(host, id, node, props, binding) : boundaryComponent(host, id)(props, binding))));
|
|
1893
1963
|
}
|
|
1894
1964
|
return boundaryComponent(host, id)(props, binding);
|
|
@@ -1962,14 +2032,14 @@ function adoptBoundary(host, id, el, props, binding) {
|
|
|
1962
2032
|
});
|
|
1963
2033
|
};
|
|
1964
2034
|
liveAppliers.add(applyLiveOp);
|
|
1965
|
-
|
|
2035
|
+
onCleanup(() => {
|
|
1966
2036
|
liveAppliers.delete(applyLiveOp);
|
|
1967
2037
|
unsubscribe && unsubscribe();
|
|
1968
2038
|
if (fr && fr.release) for (const fragId of claimedFragments) fr.release(fragId);
|
|
1969
2039
|
});
|
|
1970
2040
|
drainRecords();
|
|
1971
2041
|
for (const op of liveOps.values()) applyLiveOp(op);
|
|
1972
|
-
const owner =
|
|
2042
|
+
const owner = getOwner();
|
|
1973
2043
|
let release;
|
|
1974
2044
|
let setGate;
|
|
1975
2045
|
const frame = createFrame(el, {
|
|
@@ -1999,18 +2069,18 @@ function adoptBoundary(host, id, el, props, binding) {
|
|
|
1999
2069
|
});
|
|
2000
2070
|
if (binding) {
|
|
2001
2071
|
const arm = () => new Promise(r => release = r);
|
|
2002
|
-
const [gatePromise, setGatePromise] =
|
|
2072
|
+
const [gatePromise, setGatePromise] = createSignal(undefined);
|
|
2003
2073
|
setGate = setGatePromise;
|
|
2004
|
-
const gate =
|
|
2005
|
-
|
|
2074
|
+
const gate = createMemo(() => gatePromise());
|
|
2075
|
+
createRenderEffect(binding, (address, prev) => {
|
|
2006
2076
|
if (prev !== undefined && address !== prev && tables.has(address)) {
|
|
2007
2077
|
setGatePromise(arm());
|
|
2008
2078
|
}
|
|
2009
2079
|
frame.rebind(address);
|
|
2010
2080
|
});
|
|
2011
|
-
|
|
2081
|
+
createRenderEffect(() => (gate(), undefined), () => {});
|
|
2012
2082
|
}
|
|
2013
|
-
|
|
2083
|
+
onCleanup(() => frame.dispose());
|
|
2014
2084
|
return el;
|
|
2015
2085
|
}
|
|
2016
2086
|
function installServerComponents(host = getFrameHost()) {
|
|
@@ -2045,19 +2115,9 @@ function installServerComponents(host = getFrameHost()) {
|
|
|
2045
2115
|
const records = g._$SC.a || (g._$SC.a = {});
|
|
2046
2116
|
for (const address in records) showing(address, records[address]);
|
|
2047
2117
|
g._$SC.reg = showing;
|
|
2048
|
-
|
|
2118
|
+
configureServerFunctionsClient({
|
|
2049
2119
|
responseHandler: handler
|
|
2050
2120
|
});
|
|
2051
2121
|
}
|
|
2052
2122
|
|
|
2053
|
-
|
|
2054
|
-
exports.FRAME_STREAM_HEADER = FRAME_STREAM_HEADER;
|
|
2055
|
-
exports.applyFrameResponse = applyFrameResponse;
|
|
2056
|
-
exports.asyncArg = asyncArg;
|
|
2057
|
-
exports.createFrame = createFrame;
|
|
2058
|
-
exports.createFrameElement = createFrameElement;
|
|
2059
|
-
exports.createFrameHost = createFrameHost;
|
|
2060
|
-
exports.createServerComponentHandler = createServerComponentHandler;
|
|
2061
|
-
exports.getFrameHost = getFrameHost;
|
|
2062
|
-
exports.installServerComponents = installServerComponents;
|
|
2063
|
-
exports.isFrameStreamResponse = isFrameStreamResponse;
|
|
2123
|
+
export { FRAME_APPLIED_EVENT, FRAME_STREAM_HEADER, applyFrameResponse, asyncArg, createFrame, createFrameElement, createFrameHost, createServerComponentHandler, getFrameHost, installServerComponents, isFrameStreamResponse };
|