@solidjs/web 2.0.0-rc.13 → 2.0.0-rc.14
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 +200 -73
- package/dist/server.js +182 -59
- package/dist/server.observe.js +183 -60
- package/dist/web.dev.js +70 -35
- package/dist/web.js +43 -31
- package/dist/web.observe.js +43 -33
- package/frames/dist/assets.js +92 -0
- package/frames/dist/bind.dev.js +326 -0
- package/frames/dist/bind.js +295 -0
- package/frames/dist/client.dev.js +605 -1086
- package/frames/dist/client.js +572 -1066
- package/frames/dist/client.observe.js +571 -1066
- package/frames/dist/regions.js +130 -0
- package/frames/dist/server.dev.js +339 -177
- package/frames/dist/server.js +335 -173
- package/frames/dist/server.observe.js +335 -173
- package/frames/dist/trace.js +42 -0
- package/frames/dist/wire.js +133 -0
- package/package.json +28 -2
- package/performance-tracks/dist/performance-tracks.dev.js +2 -1
- package/performance-tracks/dist/performance-tracks.observe.js +2 -1
- package/performance-tracks/types/index.d.ts +8 -6
- package/serialization/dist/decode.js +37 -8
- package/serialization/dist/serialization.js +39 -10
- package/serialization/types/serializer-decode.d.ts +24 -2
- package/server-functions/dist/client.dev.js +99 -61
- package/server-functions/dist/client.js +99 -61
- package/server-functions/dist/client.observe.js +99 -61
- package/server-functions/dist/server.dev.js +87 -50
- package/server-functions/dist/server.js +87 -50
- package/server-functions/dist/server.observe.js +87 -50
- package/skills/server-components/SKILL.md +65 -43
- package/types/client.d.ts +20 -0
- package/types/constants.d.ts +2 -1
- package/types/diagnostics.d.ts +8 -0
- package/types/frames/assets-tier.d.ts +78 -0
- package/types/frames/bind-tier.d.ts +60 -0
- package/types/frames/client.d.ts +37 -3
- package/types/frames/frame-client.d.ts +249 -78
- package/types/frames/frame-container-plugin.d.ts +2 -2
- package/types/frames/frame-sink.d.ts +33 -0
- package/types/frames/frame-transport.d.ts +66 -18
- package/types/frames/regions-tier.d.ts +45 -0
- package/types/frames/serializer-decode.d.ts +24 -2
- package/types/frames/server.d.ts +32 -8
- package/types/frames/trace-tier.d.ts +2 -0
- package/types/frames/wire-tier.d.ts +116 -0
- package/types/index.d.ts +38 -0
- package/types/index.server.d.ts +9 -0
- package/types/jsx.d.ts +1 -1
- package/types/observe.d.ts +4 -2
- package/types/serializer-decode.d.ts +24 -2
- package/types/server-functions/client.d.ts +26 -0
- package/types/server-functions/registry.d.ts +4 -1
- package/types/server-functions/shared.d.ts +12 -8
- package/types/server-mock.d.ts +13 -1
- package/types/server.d.ts +34 -8
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { materializeContainerTrace } from 'solid-js/internal/container-trace';
|
|
2
|
+
import { getFrameHost } from '@solidjs/web/frames';
|
|
3
|
+
|
|
4
|
+
const STATE = Symbol.for("solid.container-trace-state");
|
|
5
|
+
const state = globalThis[STATE] || (globalThis[STATE] = {
|
|
6
|
+
materialized: new WeakMap(),
|
|
7
|
+
materializedValues: new WeakSet()
|
|
8
|
+
});
|
|
9
|
+
function setContainerTraceMaterializer(fn) {
|
|
10
|
+
state.materializeTrace = fn;
|
|
11
|
+
}
|
|
12
|
+
function materialize(marker, claiming) {
|
|
13
|
+
let value = state.materialized.get(marker.$tr);
|
|
14
|
+
if (value === undefined) {
|
|
15
|
+
value = state.materializeTrace(marker, claiming);
|
|
16
|
+
state.materialized.set(marker.$tr, value);
|
|
17
|
+
if (value !== null && typeof value === "object") state.materializedValues.add(value);
|
|
18
|
+
}
|
|
19
|
+
return value;
|
|
20
|
+
}
|
|
21
|
+
function isContainerTraceMarker(value) {
|
|
22
|
+
if (value == null || typeof value !== "object" || value.$tr == null) return false;
|
|
23
|
+
const tr = value.$tr;
|
|
24
|
+
return tr.__SEROVAL_STREAM__ === true || typeof tr[Symbol.asyncIterator] === "function";
|
|
25
|
+
}
|
|
26
|
+
function reviveContainerTraces(value, claiming) {
|
|
27
|
+
if (!state.materializeTrace || value == null || typeof value !== "object") return value;
|
|
28
|
+
if (isContainerTraceMarker(value)) return materialize(value, claiming);
|
|
29
|
+
if (Array.isArray(value)) {
|
|
30
|
+
for (let i = 0; i < value.length; i++) value[i] = reviveContainerTraces(value[i], claiming);
|
|
31
|
+
} else if (Object.getPrototypeOf(value) === Object.prototype) {
|
|
32
|
+
for (const key of Object.keys(value)) value[key] = reviveContainerTraces(value[key], claiming);
|
|
33
|
+
}
|
|
34
|
+
return value;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function install() {
|
|
38
|
+
setContainerTraceMaterializer(materializeContainerTrace);
|
|
39
|
+
getFrameHost().revive = reviveContainerTraces;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export { install };
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { applyFrameResponse } from '@solidjs/web/frames';
|
|
2
|
+
import { frameAddress, isEventStream, ChunkReader, LIVE_WIRE } from '@solidjs/web/server-functions/client';
|
|
3
|
+
|
|
4
|
+
const FRAME_HAVE_HEADER = "X-Frame-Have";
|
|
5
|
+
const FRAME_HAVE_BUDGET = 4096;
|
|
6
|
+
|
|
7
|
+
const connections = new WeakMap();
|
|
8
|
+
const connectionsOf = host => {
|
|
9
|
+
let map = connections.get(host);
|
|
10
|
+
if (!map) connections.set(host, map = new Map());
|
|
11
|
+
return map;
|
|
12
|
+
};
|
|
13
|
+
const ledgers = new WeakMap();
|
|
14
|
+
function have(frame, key, record) {
|
|
15
|
+
if (key === "") {
|
|
16
|
+
ledgers.set(frame, record.digest === undefined ? undefined : {
|
|
17
|
+
"": record.digest,
|
|
18
|
+
...record.holes
|
|
19
|
+
});
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const ledger = ledgers.get(frame);
|
|
23
|
+
if (!ledger || !record || record.digest === undefined) return;
|
|
24
|
+
ledger[key] = record.digest;
|
|
25
|
+
if (record.holes) Object.assign(ledger, record.holes);
|
|
26
|
+
}
|
|
27
|
+
function haveOf(frame) {
|
|
28
|
+
return ledgers.get(frame);
|
|
29
|
+
}
|
|
30
|
+
function encodeHaveList(have) {
|
|
31
|
+
let out = "";
|
|
32
|
+
for (const key in have) {
|
|
33
|
+
const digest = have[key];
|
|
34
|
+
if (typeof digest !== "string") continue;
|
|
35
|
+
out += (out ? "," : "") + key + "=" + digest;
|
|
36
|
+
if (out.length > FRAME_HAVE_BUDGET) return undefined;
|
|
37
|
+
}
|
|
38
|
+
return out || undefined;
|
|
39
|
+
}
|
|
40
|
+
function resume(host, info, versions) {
|
|
41
|
+
const address = frameAddress(info.id, info.args);
|
|
42
|
+
const version = versions.get(address);
|
|
43
|
+
const frame = host.get(address);
|
|
44
|
+
const list = frame && ledgers.get(frame);
|
|
45
|
+
if (version === undefined && !list) return undefined;
|
|
46
|
+
const encoded = list && encodeHaveList(list);
|
|
47
|
+
return {
|
|
48
|
+
position: String(version || 0),
|
|
49
|
+
headers: encoded ? {
|
|
50
|
+
[FRAME_HAVE_HEADER]: encoded
|
|
51
|
+
} : undefined
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function cancel(host, address) {
|
|
55
|
+
const map = connections.get(host);
|
|
56
|
+
const connection = map && map.get(address);
|
|
57
|
+
if (connection) {
|
|
58
|
+
map.delete(address);
|
|
59
|
+
connection.cancel(new Error("Superseded by a newer response for the address."));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function connect(response, wire, address, binding, host, bump, begin) {
|
|
63
|
+
const connection = wire.connection;
|
|
64
|
+
const map = connectionsOf(host);
|
|
65
|
+
const current = map.get(address);
|
|
66
|
+
if (current && !current.done) {
|
|
67
|
+
connection.ended = current.ended;
|
|
68
|
+
const body = response.body;
|
|
69
|
+
if (body) body.cancel().catch(() => {});
|
|
70
|
+
return binding;
|
|
71
|
+
}
|
|
72
|
+
const version = bump(address);
|
|
73
|
+
begin(address, version);
|
|
74
|
+
const inner = isEventStream(response) ? wire.open(response.body) : new ChunkReader(response.body);
|
|
75
|
+
let drained = false;
|
|
76
|
+
let cancelled;
|
|
77
|
+
const reader = {
|
|
78
|
+
next: () => inner.next().then(result => {
|
|
79
|
+
if (result.done) drained = true;
|
|
80
|
+
return result;
|
|
81
|
+
})
|
|
82
|
+
};
|
|
83
|
+
const open = new Map();
|
|
84
|
+
const target = {
|
|
85
|
+
prepareData: host.prepareData,
|
|
86
|
+
apply(chunk) {
|
|
87
|
+
if (drained) return;
|
|
88
|
+
if (chunk.type === "start") open.set(chunk.id, chunk.version);else if (chunk.type === "complete" || chunk.type === "error" && !chunk.key) open.delete(chunk.id);
|
|
89
|
+
host.apply(chunk);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
let resolveEnd;
|
|
93
|
+
connection.ended = new Promise(resolve => resolveEnd = resolve);
|
|
94
|
+
connection.cancel = reason => {
|
|
95
|
+
if (cancelled !== undefined) return;
|
|
96
|
+
cancelled = reason;
|
|
97
|
+
try {
|
|
98
|
+
const r = inner.cancel && inner.cancel(reason);
|
|
99
|
+
if (r && typeof r.then === "function") r.then(undefined, () => {});
|
|
100
|
+
} catch {}
|
|
101
|
+
};
|
|
102
|
+
const end = error => {
|
|
103
|
+
const dead = error || cancelled || new Error("Frame stream ended before the frame completed.");
|
|
104
|
+
connection.done = true;
|
|
105
|
+
resolveEnd({
|
|
106
|
+
open: open.size,
|
|
107
|
+
error: dead,
|
|
108
|
+
sweep: () => {
|
|
109
|
+
for (const [id, version] of open) host.apply({
|
|
110
|
+
type: "error",
|
|
111
|
+
id,
|
|
112
|
+
version,
|
|
113
|
+
error: {
|
|
114
|
+
message: String(dead && dead.message)
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
},
|
|
118
|
+
close: () => {}
|
|
119
|
+
});
|
|
120
|
+
};
|
|
121
|
+
applyFrameResponse(response, target, {
|
|
122
|
+
as: address,
|
|
123
|
+
version,
|
|
124
|
+
[LIVE_WIRE]: reader
|
|
125
|
+
}).then(() => end(), end);
|
|
126
|
+
map.set(address, connection);
|
|
127
|
+
connection.ended.then(() => {
|
|
128
|
+
if (map.get(address) === connection) map.delete(address);
|
|
129
|
+
});
|
|
130
|
+
return binding;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export { cancel, connect, encodeHaveList, have, haveOf, resume };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solidjs/web",
|
|
3
3
|
"description": "Solid's web runtime: client rendering, hydration, SSR, and DOM-specific control flow (Portal, Dynamic).",
|
|
4
|
-
"version": "2.0.0-rc.
|
|
4
|
+
"version": "2.0.0-rc.14",
|
|
5
5
|
"author": "Ryan Carniato",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://solidjs.com",
|
|
@@ -333,6 +333,30 @@
|
|
|
333
333
|
"types": "./types/frames/client.d.ts",
|
|
334
334
|
"default": "./frames/dist/client.js"
|
|
335
335
|
},
|
|
336
|
+
"./frames/trace": {
|
|
337
|
+
"types": "./types/frames/trace-tier.d.ts",
|
|
338
|
+
"default": "./frames/dist/trace.js"
|
|
339
|
+
},
|
|
340
|
+
"./frames/regions": {
|
|
341
|
+
"types": "./types/frames/regions-tier.d.ts",
|
|
342
|
+
"default": "./frames/dist/regions.js"
|
|
343
|
+
},
|
|
344
|
+
"./frames/assets": {
|
|
345
|
+
"types": "./types/frames/assets-tier.d.ts",
|
|
346
|
+
"default": "./frames/dist/assets.js"
|
|
347
|
+
},
|
|
348
|
+
"./frames/bind": {
|
|
349
|
+
"development": {
|
|
350
|
+
"types": "./types/frames/bind-tier.d.ts",
|
|
351
|
+
"default": "./frames/dist/bind.dev.js"
|
|
352
|
+
},
|
|
353
|
+
"types": "./types/frames/bind-tier.d.ts",
|
|
354
|
+
"default": "./frames/dist/bind.js"
|
|
355
|
+
},
|
|
356
|
+
"./frames/wire": {
|
|
357
|
+
"types": "./types/frames/wire-tier.d.ts",
|
|
358
|
+
"default": "./frames/dist/wire.js"
|
|
359
|
+
},
|
|
336
360
|
"./types/*": "./types/*"
|
|
337
361
|
},
|
|
338
362
|
"scripts": {
|
|
@@ -350,6 +374,7 @@
|
|
|
350
374
|
"types:web-performance-tracks": "tsc --project ./performance-tracks/tsconfig.build.json",
|
|
351
375
|
"test": "vitest run && vitest run --config vite.config.server.mjs && vitest run --config vite.config.hydrate.mjs",
|
|
352
376
|
"test:server": "vitest run --config vite.config.server.mjs",
|
|
377
|
+
"consistency:fuzz": "CONSISTENCY_FUZZ=1 vitest run --config vite.config.hydrate.mjs test/consistency/harness",
|
|
353
378
|
"coverage": "vitest run --coverage",
|
|
354
379
|
"bench": "vitest bench --run",
|
|
355
380
|
"bench:server": "vitest bench --run --config vite.config.server-bench.mjs",
|
|
@@ -360,11 +385,12 @@
|
|
|
360
385
|
"seroval-plugins": "~1.6.7"
|
|
361
386
|
},
|
|
362
387
|
"peerDependencies": {
|
|
363
|
-
"solid-js": "^2.0.0-rc.
|
|
388
|
+
"solid-js": "^2.0.0-rc.14"
|
|
364
389
|
},
|
|
365
390
|
"devDependencies": {
|
|
366
391
|
"@codspeed/vitest-plugin": "^5.4.0",
|
|
367
392
|
"@solidjs/signals": "workspace:*",
|
|
393
|
+
"fast-check": "3.23.2",
|
|
368
394
|
"solid-js": "workspace:*"
|
|
369
395
|
}
|
|
370
396
|
}
|
|
@@ -30,7 +30,8 @@ function enablePerformanceTracks(options = {}) {
|
|
|
30
30
|
} = observe;
|
|
31
31
|
const releases = [() => server.dispose(), attribution.enable({
|
|
32
32
|
log: false,
|
|
33
|
-
...options.attribution
|
|
33
|
+
...options.attribution,
|
|
34
|
+
checks: options.attribution?.checks ?? false
|
|
34
35
|
}), records.subscribe("rerun", (e, node) => painter.rerun(e, node)), records.subscribe("create", (e, node) => painter.create(e, node)), records.subscribe("effect", (e, node) => painter.effect(e, node)), records.subscribe("flush", e => painter.flush(e)), records.subscribe("flight", (e, node) => painter.flight(e, node)), records.subscribe("fallback", (e, subtree) => painter.fallback(e, subtree)), records.subscribe("interaction", e => painter.interaction(e)), records.subscribe("hold", e => painter.hold(e)), records.subscribe("navigation", e => painter.navigation(e)), records.subscribe("call", (e, live) => {
|
|
35
36
|
painter.call(e);
|
|
36
37
|
server.call(e, live);
|
|
@@ -30,7 +30,8 @@ function enablePerformanceTracks(options = {}) {
|
|
|
30
30
|
} = observe;
|
|
31
31
|
const releases = [() => server.dispose(), attribution.enable({
|
|
32
32
|
log: false,
|
|
33
|
-
...options.attribution
|
|
33
|
+
...options.attribution,
|
|
34
|
+
checks: options.attribution?.checks ?? false
|
|
34
35
|
}), records.subscribe("rerun", (e, node) => painter.rerun(e, node)), records.subscribe("create", (e, node) => painter.create(e, node)), records.subscribe("effect", (e, node) => painter.effect(e, node)), records.subscribe("flush", e => painter.flush(e)), records.subscribe("flight", (e, node) => painter.flight(e, node)), records.subscribe("fallback", (e, subtree) => painter.fallback(e, subtree)), records.subscribe("interaction", e => painter.interaction(e)), records.subscribe("hold", e => painter.hold(e)), records.subscribe("navigation", e => painter.navigation(e)), records.subscribe("call", (e, live) => {
|
|
35
36
|
painter.call(e);
|
|
36
37
|
server.call(e, live);
|
|
@@ -2,12 +2,14 @@ import { type AttributionOptions } from "solid-js/attribution";
|
|
|
2
2
|
export interface PerformanceTracksOptions {
|
|
3
3
|
/**
|
|
4
4
|
* Options for the engine hold this adapter takes
|
|
5
|
-
* (`attribution.enable({ log: false, ...attribution })`).
|
|
6
|
-
* for no console log — the timeline is
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
5
|
+
* (`attribution.enable({ log: false, checks: false, ...attribution })`).
|
|
6
|
+
* The adapter asks for no console log and records only — the timeline is
|
|
7
|
+
* the output — which, the engine combining holds by the most demanding
|
|
8
|
+
* request, quiets the console and the cost checks (`hotRuns`, `hotTime`,
|
|
9
|
+
* `wideDeps`, `unstableMemos`, `fanOut`, `wastedRecompute`) only while
|
|
10
|
+
* nobody else wants them: a console session beside the tracks keeps its
|
|
11
|
+
* log and its checks. Pass `checks: true` to have the tracks' own hold
|
|
12
|
+
* run them, their findings painted as markers like any other.
|
|
11
13
|
*/
|
|
12
14
|
attribution?: AttributionOptions;
|
|
13
15
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { fromCrossJSON, Feature, createStream } from 'seroval';
|
|
2
2
|
import { AbortSignalPlugin, CustomEventPlugin, DOMExceptionPlugin, EventPlugin, FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin } from 'seroval-plugins/web';
|
|
3
3
|
|
|
4
4
|
const STATE = Symbol.for("solid.container-trace-state");
|
|
@@ -10,10 +10,10 @@ function setContainerTraceStreamMint(fn) {
|
|
|
10
10
|
state.streamOf = fn;
|
|
11
11
|
}
|
|
12
12
|
const TRACE = Symbol.for("solid.container-trace");
|
|
13
|
-
function materialize(marker) {
|
|
13
|
+
function materialize(marker, claiming) {
|
|
14
14
|
let value = state.materialized.get(marker.$tr);
|
|
15
15
|
if (value === undefined) {
|
|
16
|
-
value = state.materializeTrace(marker);
|
|
16
|
+
value = state.materializeTrace(marker, claiming);
|
|
17
17
|
state.materialized.set(marker.$tr, value);
|
|
18
18
|
if (value !== null && typeof value === "object") state.materializedValues.add(value);
|
|
19
19
|
}
|
|
@@ -71,14 +71,14 @@ setContainerTraceStreamMint(iterable => {
|
|
|
71
71
|
})();
|
|
72
72
|
return stream;
|
|
73
73
|
});
|
|
74
|
-
const DEFAULT_WEB_PLUGINS = Object.freeze([AbortSignalPlugin,
|
|
74
|
+
const DEFAULT_WEB_PLUGINS = /* @__PURE__ */Object.freeze([AbortSignalPlugin,
|
|
75
75
|
CustomEventPlugin, DOMExceptionPlugin, EventPlugin,
|
|
76
76
|
FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin,
|
|
77
77
|
ContainerTracePlugin]);
|
|
78
78
|
function resolveSerializerPlugins(customPlugins) {
|
|
79
79
|
return customPlugins ? [...customPlugins, ...DEFAULT_WEB_PLUGINS] : [...DEFAULT_WEB_PLUGINS];
|
|
80
80
|
}
|
|
81
|
-
const
|
|
81
|
+
const jsonCodecDisabledFeatures = () => Feature.RegExp;
|
|
82
82
|
const JSON_CODEC_DEPTH_LIMIT = 64;
|
|
83
83
|
function resolveCodecOptions({
|
|
84
84
|
plugins,
|
|
@@ -88,7 +88,7 @@ function resolveCodecOptions({
|
|
|
88
88
|
} = {}) {
|
|
89
89
|
return {
|
|
90
90
|
plugins: resolveSerializerPlugins(plugins),
|
|
91
|
-
disabledFeatures: disabledFeatures === undefined ?
|
|
91
|
+
disabledFeatures: disabledFeatures === undefined ? jsonCodecDisabledFeatures() : disabledFeatures,
|
|
92
92
|
depthLimit: depthLimit === undefined ? JSON_CODEC_DEPTH_LIMIT : depthLimit,
|
|
93
93
|
serializeErrorStacks
|
|
94
94
|
};
|
|
@@ -176,16 +176,45 @@ function createJSONDeserializer(options) {
|
|
|
176
176
|
function createJSONDataTable(options) {
|
|
177
177
|
const deserialize = createJSONDeserializer(options);
|
|
178
178
|
const table = new Map();
|
|
179
|
+
const waits = new Map();
|
|
180
|
+
const settle = (w, s, value) => {
|
|
181
|
+
const p = w.p;
|
|
182
|
+
p.s = s;
|
|
183
|
+
p.v = value;
|
|
184
|
+
s === 1 ? w.r(value) : w.j(value);
|
|
185
|
+
for (const c of p.c) c();
|
|
186
|
+
};
|
|
179
187
|
return {
|
|
180
188
|
apply(record) {
|
|
181
189
|
const value = deserialize(record.node);
|
|
182
|
-
if (record.initial)
|
|
190
|
+
if (record.initial) {
|
|
191
|
+
table.set(record.key, value);
|
|
192
|
+
const w = waits.get(record.key);
|
|
193
|
+
if (w) {
|
|
194
|
+
waits.delete(record.key);
|
|
195
|
+
settle(w, 1, value);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
183
198
|
},
|
|
184
199
|
get(key) {
|
|
185
200
|
return table.get(key);
|
|
186
201
|
},
|
|
187
202
|
resolve(ref) {
|
|
188
|
-
|
|
203
|
+
const key = ref.$ref;
|
|
204
|
+
if (table.has(key)) return table.get(key);
|
|
205
|
+
let w = waits.get(key);
|
|
206
|
+
if (!w) {
|
|
207
|
+
waits.set(key, w = {});
|
|
208
|
+
const p = w.p = new Promise((r, j) => (w.r = r, w.j = j));
|
|
209
|
+
p.s = 0;
|
|
210
|
+
p.c = [];
|
|
211
|
+
p.then(undefined, () => {});
|
|
212
|
+
}
|
|
213
|
+
return w.p;
|
|
214
|
+
},
|
|
215
|
+
close(error) {
|
|
216
|
+
for (const [key, w] of waits) settle(w, 2, error || new Error(`Stream ended without delivering {$ref: "${key}"}`));
|
|
217
|
+
waits.clear();
|
|
189
218
|
}
|
|
190
219
|
};
|
|
191
220
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { fromCrossJSON, Feature, createStream, OpaqueReference as OpaqueReference$1, createPlugin as createPlugin$1, toCrossJSONStream, Serializer, getCrossReferenceHeader } from 'seroval';
|
|
2
2
|
import { AbortSignalPlugin, CustomEventPlugin, DOMExceptionPlugin, EventPlugin, FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin } from 'seroval-plugins/web';
|
|
3
3
|
|
|
4
4
|
const STATE = Symbol.for("solid.container-trace-state");
|
|
@@ -10,10 +10,10 @@ function setContainerTraceStreamMint(fn) {
|
|
|
10
10
|
state.streamOf = fn;
|
|
11
11
|
}
|
|
12
12
|
const TRACE = Symbol.for("solid.container-trace");
|
|
13
|
-
function materialize(marker) {
|
|
13
|
+
function materialize(marker, claiming) {
|
|
14
14
|
let value = state.materialized.get(marker.$tr);
|
|
15
15
|
if (value === undefined) {
|
|
16
|
-
value = state.materializeTrace(marker);
|
|
16
|
+
value = state.materializeTrace(marker, claiming);
|
|
17
17
|
state.materialized.set(marker.$tr, value);
|
|
18
18
|
if (value !== null && typeof value === "object") state.materializedValues.add(value);
|
|
19
19
|
}
|
|
@@ -71,14 +71,14 @@ setContainerTraceStreamMint(iterable => {
|
|
|
71
71
|
})();
|
|
72
72
|
return stream;
|
|
73
73
|
});
|
|
74
|
-
const DEFAULT_WEB_PLUGINS = Object.freeze([AbortSignalPlugin,
|
|
74
|
+
const DEFAULT_WEB_PLUGINS = /* @__PURE__ */Object.freeze([AbortSignalPlugin,
|
|
75
75
|
CustomEventPlugin, DOMExceptionPlugin, EventPlugin,
|
|
76
76
|
FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin,
|
|
77
77
|
ContainerTracePlugin]);
|
|
78
78
|
function resolveSerializerPlugins(customPlugins) {
|
|
79
79
|
return customPlugins ? [...customPlugins, ...DEFAULT_WEB_PLUGINS] : [...DEFAULT_WEB_PLUGINS];
|
|
80
80
|
}
|
|
81
|
-
const
|
|
81
|
+
const jsonCodecDisabledFeatures = () => Feature.RegExp;
|
|
82
82
|
const JSON_CODEC_DEPTH_LIMIT = 64;
|
|
83
83
|
function resolveCodecOptions({
|
|
84
84
|
plugins,
|
|
@@ -88,7 +88,7 @@ function resolveCodecOptions({
|
|
|
88
88
|
} = {}) {
|
|
89
89
|
return {
|
|
90
90
|
plugins: resolveSerializerPlugins(plugins),
|
|
91
|
-
disabledFeatures: disabledFeatures === undefined ?
|
|
91
|
+
disabledFeatures: disabledFeatures === undefined ? jsonCodecDisabledFeatures() : disabledFeatures,
|
|
92
92
|
depthLimit: depthLimit === undefined ? JSON_CODEC_DEPTH_LIMIT : depthLimit,
|
|
93
93
|
serializeErrorStacks
|
|
94
94
|
};
|
|
@@ -176,21 +176,50 @@ function createJSONDeserializer(options) {
|
|
|
176
176
|
function createJSONDataTable(options) {
|
|
177
177
|
const deserialize = createJSONDeserializer(options);
|
|
178
178
|
const table = new Map();
|
|
179
|
+
const waits = new Map();
|
|
180
|
+
const settle = (w, s, value) => {
|
|
181
|
+
const p = w.p;
|
|
182
|
+
p.s = s;
|
|
183
|
+
p.v = value;
|
|
184
|
+
s === 1 ? w.r(value) : w.j(value);
|
|
185
|
+
for (const c of p.c) c();
|
|
186
|
+
};
|
|
179
187
|
return {
|
|
180
188
|
apply(record) {
|
|
181
189
|
const value = deserialize(record.node);
|
|
182
|
-
if (record.initial)
|
|
190
|
+
if (record.initial) {
|
|
191
|
+
table.set(record.key, value);
|
|
192
|
+
const w = waits.get(record.key);
|
|
193
|
+
if (w) {
|
|
194
|
+
waits.delete(record.key);
|
|
195
|
+
settle(w, 1, value);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
183
198
|
},
|
|
184
199
|
get(key) {
|
|
185
200
|
return table.get(key);
|
|
186
201
|
},
|
|
187
202
|
resolve(ref) {
|
|
188
|
-
|
|
203
|
+
const key = ref.$ref;
|
|
204
|
+
if (table.has(key)) return table.get(key);
|
|
205
|
+
let w = waits.get(key);
|
|
206
|
+
if (!w) {
|
|
207
|
+
waits.set(key, w = {});
|
|
208
|
+
const p = w.p = new Promise((r, j) => (w.r = r, w.j = j));
|
|
209
|
+
p.s = 0;
|
|
210
|
+
p.c = [];
|
|
211
|
+
p.then(undefined, () => {});
|
|
212
|
+
}
|
|
213
|
+
return w.p;
|
|
214
|
+
},
|
|
215
|
+
close(error) {
|
|
216
|
+
for (const [key, w] of waits) settle(w, 2, error || new Error(`Stream ended without delivering {$ref: "${key}"}`));
|
|
217
|
+
waits.clear();
|
|
189
218
|
}
|
|
190
219
|
};
|
|
191
220
|
}
|
|
192
221
|
|
|
193
|
-
const
|
|
222
|
+
const defaultDisabledFeatures = () => Feature.AggregateError | Feature.BigIntTypedArray;
|
|
194
223
|
const serializeOnlyDisabledFeatures = serializeErrorStacks => (serializeErrorStacks === undefined ? process.env.NODE_ENV === "development" : serializeErrorStacks) ? 0 : Feature.ErrorPrototypeStack;
|
|
195
224
|
const HYDRATION_GLOBAL = "_$HY.r";
|
|
196
225
|
const createPlugin = createPlugin$1;
|
|
@@ -199,7 +228,7 @@ function createSerializer(options) {
|
|
|
199
228
|
return new Serializer({
|
|
200
229
|
...options,
|
|
201
230
|
plugins: resolveSerializerPlugins(options.plugins),
|
|
202
|
-
disabledFeatures: (options.disabledFeatures === undefined ?
|
|
231
|
+
disabledFeatures: (options.disabledFeatures === undefined ? defaultDisabledFeatures() : options.disabledFeatures) | serializeOnlyDisabledFeatures(options.serializeErrorStacks)
|
|
203
232
|
});
|
|
204
233
|
}
|
|
205
234
|
function createHydrationSerializer({
|
|
@@ -121,8 +121,17 @@ export interface JSONCodecOptions {
|
|
|
121
121
|
/**
|
|
122
122
|
* A resident, response-scoped decode table over the keyed JSON codec: apply
|
|
123
123
|
* each frame `data` chunk with `apply`, resolve `{ $ref }` slot args with
|
|
124
|
-
* `resolve
|
|
125
|
-
* (`applyData: c => table.apply(c)
|
|
124
|
+
* `resolve`, and `close` it when the response ends. The frames client host
|
|
125
|
+
* wires one per response (`applyData: c => table.apply(c)`,
|
|
126
|
+
* `closeData: (…) => table.close(error)`).
|
|
127
|
+
*
|
|
128
|
+
* A `{ $ref }` to a key no `apply` has delivered yet is a PENDING READ the
|
|
129
|
+
* table owns (`@internal` behaviour — the frames client is its consumer): a
|
|
130
|
+
* promise marked `s = 0`, settled by the key's `apply` and rejected by
|
|
131
|
+
* `close` — the response ended without delivering the key, so a value that
|
|
132
|
+
* never comes is an error where it is read, not a silence. Stamped `s`/`v`
|
|
133
|
+
* as it settles (`1` fulfilled, `2` rejected — the hydration serializer's
|
|
134
|
+
* marks, which a reader adopts synchronously).
|
|
126
135
|
*
|
|
127
136
|
* Integration-facing; may change (see the entry banner). This serialization
|
|
128
137
|
* entry is the single home of the data table — the frames client consumes
|
|
@@ -134,9 +143,22 @@ export interface JSONDataTable {
|
|
|
134
143
|
node?: unknown;
|
|
135
144
|
initial?: boolean;
|
|
136
145
|
}): void;
|
|
146
|
+
/**
|
|
147
|
+
* The value under `ref`, or the table's pending read of it: a promise
|
|
148
|
+
* marked `s = 0` carrying `c`, the callbacks the table runs in the
|
|
149
|
+
* `apply` / `close` that settles it — the key delivered (whatever its
|
|
150
|
+
* value's shape: a delivered promise is adopted by the read, the
|
|
151
|
+
* callbacks do not wait for it) or the table closed.
|
|
152
|
+
*/
|
|
137
153
|
resolve<T = unknown>(ref: {
|
|
138
154
|
$ref: string;
|
|
139
155
|
}): T;
|
|
156
|
+
/**
|
|
157
|
+
* The response has ended: every pending read of a key it never
|
|
158
|
+
* delivered rejects — with `error` (the response's own) when given, with
|
|
159
|
+
* an `Error` naming the key otherwise. Idempotent.
|
|
160
|
+
*/
|
|
161
|
+
close(error?: unknown): void;
|
|
140
162
|
}
|
|
141
163
|
/**
|
|
142
164
|
* Baseline plugin set for serializing web-platform values. Shared by the
|