@solidjs/web 2.0.0-rc.1 → 2.0.0-rc.3
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/dev.cjs +116 -66
- package/dist/dev.js +109 -65
- package/dist/server.cjs +386 -109
- package/dist/server.js +378 -113
- package/dist/web.cjs +113 -64
- package/dist/web.js +106 -63
- package/frames/dist/client.cjs +100 -14
- package/frames/dist/client.dev.cjs +103 -14
- package/frames/dist/client.dev.js +104 -15
- package/frames/dist/client.js +101 -15
- package/frames/dist/server.cjs +285 -154
- package/frames/dist/server.js +287 -156
- package/package.json +20 -22
- package/serialization/dist/decode.cjs +22 -5
- package/serialization/dist/decode.js +23 -6
- package/serialization/dist/serialization.cjs +26 -13
- package/serialization/dist/serialization.js +26 -8
- package/serialization/types/index.d.ts +69 -157
- package/serialization/types/serializer-decode.d.ts +89 -112
- package/serialization/types/serializer.d.ts +94 -0
- package/serialization/types-cjs/index.d.cts +69 -157
- package/serialization/types-cjs/serializer-decode.d.cts +89 -112
- package/serialization/types-cjs/serializer.d.cts +94 -0
- package/server-functions/dist/client.cjs +48 -7
- package/server-functions/dist/client.js +48 -8
- package/server-functions/dist/server.cjs +76 -5
- package/server-functions/dist/server.dev.cjs +76 -5
- package/server-functions/dist/server.dev.js +76 -6
- package/server-functions/dist/server.js +76 -6
- package/types/client.d.ts +150 -290
- package/types/constants.d.ts +18 -0
- package/types/cookies.d.ts +31 -75
- package/types/frames/frame-client.d.ts +287 -259
- package/types/frames/frame-container-plugin.d.ts +71 -0
- package/types/frames/frame-sink.d.ts +58 -160
- package/types/frames/frame-transport.d.ts +161 -194
- package/types/frames/serializer-decode.d.ts +159 -0
- package/types/frames/serializer.d.ts +69 -157
- package/types/head.d.ts +16 -0
- package/types/index.d.ts +0 -65
- package/types/index.server.d.ts +125 -0
- package/types/jsx.d.ts +5 -13
- package/types/reconcile.d.ts +1 -0
- package/types/render.d.ts +4 -0
- package/types/response.d.ts +41 -153
- package/types/serializer-decode.d.ts +89 -112
- package/types/serializer.d.ts +69 -157
- package/types/server-functions/client.d.ts +101 -199
- package/types/server-functions/flash.d.ts +10 -30
- package/types/server-functions/registry.d.ts +63 -0
- package/types/server-functions/rich-args.d.ts +1 -10
- package/types/server-functions/server.d.ts +301 -518
- package/types/server-functions/shared.d.ts +112 -458
- package/types/server-mock.d.ts +13 -4
- package/types/server.d.ts +256 -427
- package/types-cjs/client.d.cts +150 -290
- package/types-cjs/constants.d.cts +18 -0
- package/types-cjs/cookies.d.cts +31 -75
- package/types-cjs/frames/frame-client.d.cts +287 -259
- package/types-cjs/frames/frame-container-plugin.d.cts +71 -0
- package/types-cjs/frames/frame-sink.d.cts +58 -160
- package/types-cjs/frames/frame-transport.d.cts +161 -194
- package/types-cjs/frames/serializer-decode.d.cts +159 -0
- package/types-cjs/frames/serializer.d.cts +69 -157
- package/types-cjs/head.d.cts +16 -0
- package/types-cjs/index.d.cts +0 -65
- package/types-cjs/index.server.d.cts +125 -0
- package/types-cjs/jsx.d.cts +5 -13
- package/types-cjs/reconcile.d.cts +1 -0
- package/types-cjs/render.d.cts +4 -0
- package/types-cjs/response.d.cts +41 -153
- package/types-cjs/serializer-decode.d.cts +89 -112
- package/types-cjs/serializer.d.cts +69 -157
- package/types-cjs/server-functions/client.d.cts +101 -199
- package/types-cjs/server-functions/flash.d.cts +10 -30
- package/types-cjs/server-functions/registry.d.cts +63 -0
- package/types-cjs/server-functions/rich-args.d.cts +1 -10
- package/types-cjs/server-functions/server.d.cts +301 -518
- package/types-cjs/server-functions/shared.d.cts +112 -458
- package/types-cjs/server-mock.d.cts +13 -4
- package/types-cjs/server.d.cts +256 -427
- package/LICENSE +0 -21
- package/types/core.d.ts +0 -6
- package/types-cjs/core.d.cts +0 -6
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
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.3",
|
|
5
5
|
"author": "Ryan Carniato",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://solidjs.com",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
10
|
"url": "git+https://github.com/solidjs/solid.git",
|
|
11
|
-
"directory": "packages/
|
|
11
|
+
"directory": "packages/web"
|
|
12
12
|
},
|
|
13
13
|
"publishConfig": {
|
|
14
14
|
"access": "public"
|
|
@@ -373,32 +373,18 @@
|
|
|
373
373
|
},
|
|
374
374
|
"./types/*": "./types/*"
|
|
375
375
|
},
|
|
376
|
-
"dependencies": {
|
|
377
|
-
"seroval": "~1.5.4",
|
|
378
|
-
"seroval-plugins": "~1.5.4"
|
|
379
|
-
},
|
|
380
|
-
"peerDependencies": {
|
|
381
|
-
"solid-js": "^2.0.0-rc.1"
|
|
382
|
-
},
|
|
383
|
-
"devDependencies": {
|
|
384
|
-
"@codspeed/vitest-plugin": "^5.4.0",
|
|
385
|
-
"solid-js": "2.0.0-rc.1"
|
|
386
|
-
},
|
|
387
376
|
"scripts": {
|
|
388
377
|
"build": "npm-run-all -nl build:clean types:copy-jsx build:js",
|
|
389
378
|
"build:clean": "rimraf dist/",
|
|
390
379
|
"build:js": "rollup -c",
|
|
391
380
|
"link": "symlink-dir . node_modules/@solidjs/web",
|
|
392
|
-
"types": "npm-run-all -nl types:clean types:copy-jsx types:web types:copy-web types:web-storage types:
|
|
393
|
-
"types:clean": "rimraf types/ types-cjs/ storage/types/ storage/types-cjs/ serialization/types/ serialization/types-cjs/ frames/types/",
|
|
394
|
-
"
|
|
381
|
+
"types": "npm-run-all -nl types:clean types:copy-jsx types:web types:copy-web types:web-storage types:cjs",
|
|
382
|
+
"types:clean": "rimraf types/ types-cjs/ storage/types/ storage/types-cjs/ serialization/types/ serialization/types-cjs/ frames/types/ .types-build/",
|
|
383
|
+
"jsx-sync": "node ./scripts/jsx-sync.mjs --compile --element \"SolidElement | Node | ArrayElement\" --import \"import type { Element as SolidElement } from \\\"solid-js\\\";\"",
|
|
384
|
+
"types:copy-jsx": "pnpm run jsx-sync",
|
|
395
385
|
"types:web": "tsc --project ./tsconfig.build.json",
|
|
396
|
-
"types:copy-web": "node
|
|
386
|
+
"types:copy-web": "node ./scripts/copy-types.mjs",
|
|
397
387
|
"types:web-storage": "tsc --project ./storage/tsconfig.build.json",
|
|
398
|
-
"types:web-frames": "tsc --project ./frames/tsconfig.build.json",
|
|
399
|
-
"types:copy-serialization": "node -e \"fs.mkdirSync('./serialization/types', { recursive: true }); fs.copyFileSync('../../node_modules/@dom-expressions/runtime/src/serializer.d.ts', './serialization/types/index.d.ts'); fs.copyFileSync('../../node_modules/@dom-expressions/runtime/src/serializer-decode.d.ts', './serialization/types/serializer-decode.d.ts');\"",
|
|
400
|
-
"types:copy-server-functions": "node -e \"fs.mkdirSync('./types/server-functions', { recursive: true }); for (const f of ['shared', 'flash', 'client', 'server', 'rich-args']) fs.copyFileSync('../../node_modules/@dom-expressions/runtime/src/server-functions/' + f + '.d.ts', './types/server-functions/' + f + '.d.ts');\"",
|
|
401
|
-
"types:copy-frames": "node -e \"fs.mkdirSync('./types/frames', { recursive: true }); for (const f of ['frame-client', 'frame-transport', 'frame-sink', 'serializer']) fs.copyFileSync('../../node_modules/@dom-expressions/runtime/src/' + f + '.d.ts', './types/frames/' + f + '.d.ts'); for (const f of ['client', 'server']) fs.writeFileSync('./types/frames/' + f + '.d.ts', fs.readFileSync('./frames/types/' + f + '.d.ts', 'utf8').replaceAll('@dom-expressions/runtime/src/', './'));\"",
|
|
402
388
|
"types:cjs": "node ../../scripts/sync-dual-types.mjs ./types ./types-cjs ./storage/types ./storage/types-cjs ./serialization/types ./serialization/types-cjs",
|
|
403
389
|
"test": "vitest run && vitest run --config vite.config.server.mjs && vitest run --config vite.config.hydrate.mjs",
|
|
404
390
|
"test:server": "vitest run --config vite.config.server.mjs",
|
|
@@ -406,5 +392,17 @@
|
|
|
406
392
|
"bench": "vitest bench --run",
|
|
407
393
|
"bench:server": "vitest bench --run --config vite.config.server-bench.mjs",
|
|
408
394
|
"test-types": "tsc --project tsconfig.test.json"
|
|
395
|
+
},
|
|
396
|
+
"dependencies": {
|
|
397
|
+
"seroval": "~1.5.4",
|
|
398
|
+
"seroval-plugins": "~1.5.4"
|
|
399
|
+
},
|
|
400
|
+
"peerDependencies": {
|
|
401
|
+
"solid-js": "^2.0.0-rc.3"
|
|
402
|
+
},
|
|
403
|
+
"devDependencies": {
|
|
404
|
+
"@codspeed/vitest-plugin": "^5.4.0",
|
|
405
|
+
"@solidjs/signals": "workspace:*",
|
|
406
|
+
"solid-js": "workspace:*"
|
|
409
407
|
}
|
|
410
|
-
}
|
|
408
|
+
}
|
|
@@ -3,12 +3,15 @@
|
|
|
3
3
|
var seroval = require('seroval');
|
|
4
4
|
var web = require('seroval-plugins/web');
|
|
5
5
|
|
|
6
|
-
const STATE = Symbol.for("
|
|
6
|
+
const STATE = Symbol.for("solid.container-trace-state");
|
|
7
7
|
const state = globalThis[STATE] || (globalThis[STATE] = {
|
|
8
8
|
materialized: new WeakMap(),
|
|
9
9
|
materializedValues: new WeakSet()
|
|
10
10
|
});
|
|
11
|
-
|
|
11
|
+
function setContainerTraceStreamMint(fn) {
|
|
12
|
+
state.streamOf = fn;
|
|
13
|
+
}
|
|
14
|
+
const TRACE = Symbol.for("solid.container-trace");
|
|
12
15
|
function materialize(marker) {
|
|
13
16
|
let value = state.materialized.get(marker.$tr);
|
|
14
17
|
if (value === undefined) {
|
|
@@ -20,13 +23,14 @@ function materialize(marker) {
|
|
|
20
23
|
}
|
|
21
24
|
function parseTrace(value, ctx) {
|
|
22
25
|
const trace = value[TRACE];
|
|
26
|
+
const sub = trace.subscribe();
|
|
23
27
|
return {
|
|
24
28
|
a: trace.array ? 1 : 0,
|
|
25
|
-
i: ctx.parse(
|
|
29
|
+
i: ctx.parse(state.streamOf ? state.streamOf(sub) : sub)
|
|
26
30
|
};
|
|
27
31
|
}
|
|
28
32
|
const ContainerTracePlugin = {
|
|
29
|
-
tag: "
|
|
33
|
+
tag: "solid/container-trace",
|
|
30
34
|
test(value) {
|
|
31
35
|
return value != null && typeof value === "object" && TRACE in value;
|
|
32
36
|
},
|
|
@@ -36,9 +40,10 @@ const ContainerTracePlugin = {
|
|
|
36
40
|
},
|
|
37
41
|
async async(value, ctx) {
|
|
38
42
|
const trace = value[TRACE];
|
|
43
|
+
const sub = trace.subscribe();
|
|
39
44
|
return {
|
|
40
45
|
a: trace.array ? 1 : 0,
|
|
41
|
-
i: await ctx.parse(
|
|
46
|
+
i: await ctx.parse(state.streamOf ? state.streamOf(sub) : sub)
|
|
42
47
|
};
|
|
43
48
|
},
|
|
44
49
|
stream: parseTrace
|
|
@@ -56,6 +61,18 @@ const ContainerTracePlugin = {
|
|
|
56
61
|
}
|
|
57
62
|
};
|
|
58
63
|
|
|
64
|
+
setContainerTraceStreamMint(iterable => {
|
|
65
|
+
const stream = seroval.createStream();
|
|
66
|
+
(async () => {
|
|
67
|
+
try {
|
|
68
|
+
for await (const value of iterable) stream.next(value);
|
|
69
|
+
stream.return(undefined);
|
|
70
|
+
} catch (error) {
|
|
71
|
+
stream.throw(error);
|
|
72
|
+
}
|
|
73
|
+
})();
|
|
74
|
+
return stream;
|
|
75
|
+
});
|
|
59
76
|
const DEFAULT_WEB_PLUGINS = Object.freeze([web.AbortSignalPlugin,
|
|
60
77
|
web.CustomEventPlugin, web.DOMExceptionPlugin, web.EventPlugin,
|
|
61
78
|
web.FormDataPlugin, web.HeadersPlugin, web.ReadableStreamPlugin, web.RequestPlugin, web.ResponsePlugin, web.URLSearchParamsPlugin, web.URLPlugin,
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import { Feature, fromCrossJSON } from 'seroval';
|
|
1
|
+
import { Feature, fromCrossJSON, createStream } from 'seroval';
|
|
2
2
|
import { AbortSignalPlugin, CustomEventPlugin, DOMExceptionPlugin, EventPlugin, FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin } from 'seroval-plugins/web';
|
|
3
3
|
|
|
4
|
-
const STATE = Symbol.for("
|
|
4
|
+
const STATE = Symbol.for("solid.container-trace-state");
|
|
5
5
|
const state = globalThis[STATE] || (globalThis[STATE] = {
|
|
6
6
|
materialized: new WeakMap(),
|
|
7
7
|
materializedValues: new WeakSet()
|
|
8
8
|
});
|
|
9
|
-
|
|
9
|
+
function setContainerTraceStreamMint(fn) {
|
|
10
|
+
state.streamOf = fn;
|
|
11
|
+
}
|
|
12
|
+
const TRACE = Symbol.for("solid.container-trace");
|
|
10
13
|
function materialize(marker) {
|
|
11
14
|
let value = state.materialized.get(marker.$tr);
|
|
12
15
|
if (value === undefined) {
|
|
@@ -18,13 +21,14 @@ function materialize(marker) {
|
|
|
18
21
|
}
|
|
19
22
|
function parseTrace(value, ctx) {
|
|
20
23
|
const trace = value[TRACE];
|
|
24
|
+
const sub = trace.subscribe();
|
|
21
25
|
return {
|
|
22
26
|
a: trace.array ? 1 : 0,
|
|
23
|
-
i: ctx.parse(
|
|
27
|
+
i: ctx.parse(state.streamOf ? state.streamOf(sub) : sub)
|
|
24
28
|
};
|
|
25
29
|
}
|
|
26
30
|
const ContainerTracePlugin = {
|
|
27
|
-
tag: "
|
|
31
|
+
tag: "solid/container-trace",
|
|
28
32
|
test(value) {
|
|
29
33
|
return value != null && typeof value === "object" && TRACE in value;
|
|
30
34
|
},
|
|
@@ -34,9 +38,10 @@ const ContainerTracePlugin = {
|
|
|
34
38
|
},
|
|
35
39
|
async async(value, ctx) {
|
|
36
40
|
const trace = value[TRACE];
|
|
41
|
+
const sub = trace.subscribe();
|
|
37
42
|
return {
|
|
38
43
|
a: trace.array ? 1 : 0,
|
|
39
|
-
i: await ctx.parse(
|
|
44
|
+
i: await ctx.parse(state.streamOf ? state.streamOf(sub) : sub)
|
|
40
45
|
};
|
|
41
46
|
},
|
|
42
47
|
stream: parseTrace
|
|
@@ -54,6 +59,18 @@ const ContainerTracePlugin = {
|
|
|
54
59
|
}
|
|
55
60
|
};
|
|
56
61
|
|
|
62
|
+
setContainerTraceStreamMint(iterable => {
|
|
63
|
+
const stream = createStream();
|
|
64
|
+
(async () => {
|
|
65
|
+
try {
|
|
66
|
+
for await (const value of iterable) stream.next(value);
|
|
67
|
+
stream.return(undefined);
|
|
68
|
+
} catch (error) {
|
|
69
|
+
stream.throw(error);
|
|
70
|
+
}
|
|
71
|
+
})();
|
|
72
|
+
return stream;
|
|
73
|
+
});
|
|
57
74
|
const DEFAULT_WEB_PLUGINS = Object.freeze([AbortSignalPlugin,
|
|
58
75
|
CustomEventPlugin, DOMExceptionPlugin, EventPlugin,
|
|
59
76
|
FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin,
|
|
@@ -3,12 +3,15 @@
|
|
|
3
3
|
var seroval = require('seroval');
|
|
4
4
|
var web = require('seroval-plugins/web');
|
|
5
5
|
|
|
6
|
-
const STATE = Symbol.for("
|
|
6
|
+
const STATE = Symbol.for("solid.container-trace-state");
|
|
7
7
|
const state = globalThis[STATE] || (globalThis[STATE] = {
|
|
8
8
|
materialized: new WeakMap(),
|
|
9
9
|
materializedValues: new WeakSet()
|
|
10
10
|
});
|
|
11
|
-
|
|
11
|
+
function setContainerTraceStreamMint(fn) {
|
|
12
|
+
state.streamOf = fn;
|
|
13
|
+
}
|
|
14
|
+
const TRACE = Symbol.for("solid.container-trace");
|
|
12
15
|
function materialize(marker) {
|
|
13
16
|
let value = state.materialized.get(marker.$tr);
|
|
14
17
|
if (value === undefined) {
|
|
@@ -20,13 +23,14 @@ function materialize(marker) {
|
|
|
20
23
|
}
|
|
21
24
|
function parseTrace(value, ctx) {
|
|
22
25
|
const trace = value[TRACE];
|
|
26
|
+
const sub = trace.subscribe();
|
|
23
27
|
return {
|
|
24
28
|
a: trace.array ? 1 : 0,
|
|
25
|
-
i: ctx.parse(
|
|
29
|
+
i: ctx.parse(state.streamOf ? state.streamOf(sub) : sub)
|
|
26
30
|
};
|
|
27
31
|
}
|
|
28
32
|
const ContainerTracePlugin = {
|
|
29
|
-
tag: "
|
|
33
|
+
tag: "solid/container-trace",
|
|
30
34
|
test(value) {
|
|
31
35
|
return value != null && typeof value === "object" && TRACE in value;
|
|
32
36
|
},
|
|
@@ -36,9 +40,10 @@ const ContainerTracePlugin = {
|
|
|
36
40
|
},
|
|
37
41
|
async async(value, ctx) {
|
|
38
42
|
const trace = value[TRACE];
|
|
43
|
+
const sub = trace.subscribe();
|
|
39
44
|
return {
|
|
40
45
|
a: trace.array ? 1 : 0,
|
|
41
|
-
i: await ctx.parse(
|
|
46
|
+
i: await ctx.parse(state.streamOf ? state.streamOf(sub) : sub)
|
|
42
47
|
};
|
|
43
48
|
},
|
|
44
49
|
stream: parseTrace
|
|
@@ -56,6 +61,18 @@ const ContainerTracePlugin = {
|
|
|
56
61
|
}
|
|
57
62
|
};
|
|
58
63
|
|
|
64
|
+
setContainerTraceStreamMint(iterable => {
|
|
65
|
+
const stream = seroval.createStream();
|
|
66
|
+
(async () => {
|
|
67
|
+
try {
|
|
68
|
+
for await (const value of iterable) stream.next(value);
|
|
69
|
+
stream.return(undefined);
|
|
70
|
+
} catch (error) {
|
|
71
|
+
stream.throw(error);
|
|
72
|
+
}
|
|
73
|
+
})();
|
|
74
|
+
return stream;
|
|
75
|
+
});
|
|
59
76
|
const DEFAULT_WEB_PLUGINS = Object.freeze([web.AbortSignalPlugin,
|
|
60
77
|
web.CustomEventPlugin, web.DOMExceptionPlugin, web.EventPlugin,
|
|
61
78
|
web.FormDataPlugin, web.HeadersPlugin, web.ReadableStreamPlugin, web.RequestPlugin, web.ResponsePlugin, web.URLSearchParamsPlugin, web.URLPlugin,
|
|
@@ -118,6 +135,8 @@ function createJSONDataTable(options) {
|
|
|
118
135
|
const DEFAULT_DISABLED_FEATURES = seroval.Feature.AggregateError | seroval.Feature.BigIntTypedArray;
|
|
119
136
|
const serializeOnlyDisabledFeatures = () => process.env.NODE_ENV === "development" ? 0 : seroval.Feature.ErrorPrototypeStack;
|
|
120
137
|
const HYDRATION_GLOBAL = "_$HY.r";
|
|
138
|
+
const createPlugin = seroval.createPlugin;
|
|
139
|
+
const OpaqueReference = seroval.OpaqueReference;
|
|
121
140
|
function createSerializer(options) {
|
|
122
141
|
return new seroval.Serializer({
|
|
123
142
|
...options,
|
|
@@ -225,19 +244,13 @@ function createJSONSerializer({
|
|
|
225
244
|
};
|
|
226
245
|
}
|
|
227
246
|
|
|
228
|
-
Object.defineProperty(exports, "OpaqueReference", {
|
|
229
|
-
enumerable: true,
|
|
230
|
-
get: function () { return seroval.OpaqueReference; }
|
|
231
|
-
});
|
|
232
|
-
Object.defineProperty(exports, "createPlugin", {
|
|
233
|
-
enumerable: true,
|
|
234
|
-
get: function () { return seroval.createPlugin; }
|
|
235
|
-
});
|
|
236
247
|
exports.DEFAULT_WEB_PLUGINS = DEFAULT_WEB_PLUGINS;
|
|
248
|
+
exports.OpaqueReference = OpaqueReference;
|
|
237
249
|
exports.createHydrationSerializer = createHydrationSerializer;
|
|
238
250
|
exports.createJSONDataTable = createJSONDataTable;
|
|
239
251
|
exports.createJSONDeserializer = createJSONDeserializer;
|
|
240
252
|
exports.createJSONSerializer = createJSONSerializer;
|
|
253
|
+
exports.createPlugin = createPlugin;
|
|
241
254
|
exports.createSerializer = createSerializer;
|
|
242
255
|
exports.getLocalHeaderScript = getLocalHeaderScript;
|
|
243
256
|
exports.resolveSerializerPlugins = resolveSerializerPlugins;
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import { Feature, fromCrossJSON, toCrossJSONStream, Serializer, getCrossReferenceHeader } from 'seroval';
|
|
2
|
-
export { OpaqueReference, createPlugin } from 'seroval';
|
|
1
|
+
import { Feature, fromCrossJSON, createStream, OpaqueReference as OpaqueReference$1, createPlugin as createPlugin$1, toCrossJSONStream, Serializer, getCrossReferenceHeader } from 'seroval';
|
|
3
2
|
import { AbortSignalPlugin, CustomEventPlugin, DOMExceptionPlugin, EventPlugin, FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin } from 'seroval-plugins/web';
|
|
4
3
|
|
|
5
|
-
const STATE = Symbol.for("
|
|
4
|
+
const STATE = Symbol.for("solid.container-trace-state");
|
|
6
5
|
const state = globalThis[STATE] || (globalThis[STATE] = {
|
|
7
6
|
materialized: new WeakMap(),
|
|
8
7
|
materializedValues: new WeakSet()
|
|
9
8
|
});
|
|
10
|
-
|
|
9
|
+
function setContainerTraceStreamMint(fn) {
|
|
10
|
+
state.streamOf = fn;
|
|
11
|
+
}
|
|
12
|
+
const TRACE = Symbol.for("solid.container-trace");
|
|
11
13
|
function materialize(marker) {
|
|
12
14
|
let value = state.materialized.get(marker.$tr);
|
|
13
15
|
if (value === undefined) {
|
|
@@ -19,13 +21,14 @@ function materialize(marker) {
|
|
|
19
21
|
}
|
|
20
22
|
function parseTrace(value, ctx) {
|
|
21
23
|
const trace = value[TRACE];
|
|
24
|
+
const sub = trace.subscribe();
|
|
22
25
|
return {
|
|
23
26
|
a: trace.array ? 1 : 0,
|
|
24
|
-
i: ctx.parse(
|
|
27
|
+
i: ctx.parse(state.streamOf ? state.streamOf(sub) : sub)
|
|
25
28
|
};
|
|
26
29
|
}
|
|
27
30
|
const ContainerTracePlugin = {
|
|
28
|
-
tag: "
|
|
31
|
+
tag: "solid/container-trace",
|
|
29
32
|
test(value) {
|
|
30
33
|
return value != null && typeof value === "object" && TRACE in value;
|
|
31
34
|
},
|
|
@@ -35,9 +38,10 @@ const ContainerTracePlugin = {
|
|
|
35
38
|
},
|
|
36
39
|
async async(value, ctx) {
|
|
37
40
|
const trace = value[TRACE];
|
|
41
|
+
const sub = trace.subscribe();
|
|
38
42
|
return {
|
|
39
43
|
a: trace.array ? 1 : 0,
|
|
40
|
-
i: await ctx.parse(
|
|
44
|
+
i: await ctx.parse(state.streamOf ? state.streamOf(sub) : sub)
|
|
41
45
|
};
|
|
42
46
|
},
|
|
43
47
|
stream: parseTrace
|
|
@@ -55,6 +59,18 @@ const ContainerTracePlugin = {
|
|
|
55
59
|
}
|
|
56
60
|
};
|
|
57
61
|
|
|
62
|
+
setContainerTraceStreamMint(iterable => {
|
|
63
|
+
const stream = createStream();
|
|
64
|
+
(async () => {
|
|
65
|
+
try {
|
|
66
|
+
for await (const value of iterable) stream.next(value);
|
|
67
|
+
stream.return(undefined);
|
|
68
|
+
} catch (error) {
|
|
69
|
+
stream.throw(error);
|
|
70
|
+
}
|
|
71
|
+
})();
|
|
72
|
+
return stream;
|
|
73
|
+
});
|
|
58
74
|
const DEFAULT_WEB_PLUGINS = Object.freeze([AbortSignalPlugin,
|
|
59
75
|
CustomEventPlugin, DOMExceptionPlugin, EventPlugin,
|
|
60
76
|
FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin,
|
|
@@ -117,6 +133,8 @@ function createJSONDataTable(options) {
|
|
|
117
133
|
const DEFAULT_DISABLED_FEATURES = Feature.AggregateError | Feature.BigIntTypedArray;
|
|
118
134
|
const serializeOnlyDisabledFeatures = () => process.env.NODE_ENV === "development" ? 0 : Feature.ErrorPrototypeStack;
|
|
119
135
|
const HYDRATION_GLOBAL = "_$HY.r";
|
|
136
|
+
const createPlugin = createPlugin$1;
|
|
137
|
+
const OpaqueReference = OpaqueReference$1;
|
|
120
138
|
function createSerializer(options) {
|
|
121
139
|
return new Serializer({
|
|
122
140
|
...options,
|
|
@@ -224,4 +242,4 @@ function createJSONSerializer({
|
|
|
224
242
|
};
|
|
225
243
|
}
|
|
226
244
|
|
|
227
|
-
export { DEFAULT_WEB_PLUGINS, createHydrationSerializer, createJSONDataTable, createJSONDeserializer, createJSONSerializer, createSerializer, getLocalHeaderScript, resolveSerializerPlugins, serializeJSON };
|
|
245
|
+
export { DEFAULT_WEB_PLUGINS, OpaqueReference, createHydrationSerializer, createJSONDataTable, createJSONDeserializer, createJSONSerializer, createPlugin, createSerializer, getLocalHeaderScript, resolveSerializerPlugins, serializeJSON };
|
|
@@ -1,182 +1,94 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
// 2.0 stability guarantee and may change between releases. Application and
|
|
6
|
-
// router code should configure `codec` on the server-function entries
|
|
7
|
-
// instead of importing from here.
|
|
8
|
-
import type { Serializer } from "seroval";
|
|
9
|
-
import {
|
|
10
|
-
JSONCodecOptions,
|
|
11
|
-
PluginInfo,
|
|
12
|
-
SerializerPlugin,
|
|
13
|
-
SerovalNode
|
|
14
|
-
} from "./serializer-decode.js";
|
|
15
|
-
|
|
16
|
-
// The decode half — `SerovalNode`, the plugin TYPES, `DEFAULT_WEB_PLUGINS`,
|
|
17
|
-
// `resolveSerializerPlugins`, `JSONCodecOptions`, `createJSONDeserializer`,
|
|
18
|
-
// `createJSONDataTable` — is declared in serializer-decode.d.ts (published
|
|
19
|
-
// as `@solidjs/web/serialization/decode`, the module lazy client consumers
|
|
20
|
-
// load) and re-exported here so this remains the full surface.
|
|
21
|
-
export * from "./serializer-decode.js";
|
|
22
|
-
|
|
23
|
-
// ---- Plugin authoring ----
|
|
24
|
-
//
|
|
25
|
-
// Unlike the rest of this entry, plugin authoring is APPLICATION-FACING —
|
|
26
|
-
// it is the supported way to feed the serializers' `plugins` options and
|
|
27
|
-
// the server-function entries' `codec.plugins`. The values re-export
|
|
28
|
-
// seroval's own (`createPlugin`, `OpaqueReference` — see serializer.js);
|
|
29
|
-
// the plugin TYPES live in serializer-decode.d.ts (hand-declared there —
|
|
30
|
-
// see its banner for why).
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Builds a `SerializerPlugin` — seroval's `createPlugin`, re-exported so
|
|
34
|
-
* plugin authors stay on the exact seroval instance/version the runtime
|
|
35
|
-
* serializes with. Import it from HERE, not from your own `seroval`
|
|
36
|
-
* dependency: a plugin built against a different copy/version would not
|
|
37
|
-
* fail the build — it would emit nodes the other peer can't interpret.
|
|
38
|
-
*
|
|
39
|
-
* Application-facing (see the plugin-authoring banner above).
|
|
40
|
-
*/
|
|
41
|
-
export function createPlugin<Value, Info extends PluginInfo>(
|
|
42
|
-
plugin: SerializerPlugin<Value, Info>
|
|
43
|
-
): SerializerPlugin<Value, Info>;
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Seroval's `OpaqueReference`, re-exported from the runtime's own instance
|
|
47
|
-
* (an `OpaqueReference` from another seroval copy fails the serializer's
|
|
48
|
-
* instanceof check and serializes as a plain value): wraps a value so it
|
|
49
|
-
* crosses the wire as its `replacement` (default `undefined`) while
|
|
50
|
-
* staying readable in-process through `.value`.
|
|
51
|
-
*
|
|
52
|
-
* Application-facing (see the plugin-authoring banner above).
|
|
53
|
-
*/
|
|
54
|
-
export class OpaqueReference<V, R = undefined> {
|
|
55
|
-
readonly value: V;
|
|
56
|
-
readonly replacement?: R;
|
|
57
|
-
constructor(value: V, replacement?: R);
|
|
58
|
-
}
|
|
59
|
-
|
|
1
|
+
import { Serializer } from "seroval";
|
|
2
|
+
import type { JSONCodecOptions, PluginInfo, SerializerPlugin, SerovalNode } from "./serializer-decode.js";
|
|
3
|
+
export { DEFAULT_WEB_PLUGINS, createJSONDataTable, createJSONDeserializer, resolveSerializerPlugins } from "./serializer-decode.js";
|
|
4
|
+
export type * from "./serializer-decode.js";
|
|
60
5
|
/**
|
|
61
6
|
* Options for `createSerializer`.
|
|
62
7
|
*
|
|
63
8
|
* Integration-facing; may change (see the entry banner).
|
|
64
9
|
*/
|
|
65
10
|
export interface WebSerializerOptions {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
11
|
+
/** Name of the global object the emitted scripts write resolved values into. */
|
|
12
|
+
globalIdentifier: string;
|
|
13
|
+
/** Cross-reference scope id, for isolating multiple streams on one page. */
|
|
14
|
+
scopeId?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Seroval feature bitflags to exclude from output. Defaults to disabling
|
|
17
|
+
* post-ES2017 features (AggregateError, BigInt typed arrays). Outside
|
|
18
|
+
* development, `Error.prototype.stack` is additionally stripped on top of
|
|
19
|
+
* any override — serialized stacks leak server paths to the client.
|
|
20
|
+
*/
|
|
21
|
+
disabledFeatures?: number;
|
|
22
|
+
/** Extra plugins, composed ahead of `DEFAULT_WEB_PLUGINS`. */
|
|
23
|
+
plugins?: SerializerPlugin[];
|
|
24
|
+
/** Receives each emitted script chunk. */
|
|
25
|
+
onData: (result: string) => void;
|
|
26
|
+
onError?: (error: unknown) => void;
|
|
27
|
+
/** Fires once all async values have settled. */
|
|
28
|
+
onDone?: () => void;
|
|
84
29
|
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Creates a streaming Seroval serializer preconfigured with the web plugin
|
|
88
|
-
* set and the default feature policy. Emits JavaScript chunks (through
|
|
89
|
-
* `onData`) that reconstruct the values under `globalIdentifier` when
|
|
90
|
-
* evaluated — the script-injection form of serialization renderers build
|
|
91
|
-
* on. For a JSON-based wire codec (no eval on the receiving side), use
|
|
92
|
-
* `serializeJSON` / `createJSONDeserializer` instead.
|
|
93
|
-
*
|
|
94
|
-
* Integration-facing; may change (see the entry banner).
|
|
95
|
-
*/
|
|
96
|
-
export function createSerializer(options: WebSerializerOptions): Serializer;
|
|
97
|
-
|
|
98
30
|
/**
|
|
99
31
|
* Options for `createHydrationSerializer` — `WebSerializerOptions` minus
|
|
100
32
|
* the knobs hydration pins (`globalIdentifier`, `disabledFeatures`).
|
|
101
33
|
* @internal
|
|
102
34
|
*/
|
|
103
|
-
export type HydrationSerializerOptions = Omit<
|
|
104
|
-
WebSerializerOptions,
|
|
105
|
-
"globalIdentifier" | "disabledFeatures"
|
|
106
|
-
>;
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Renderer primitive — the serializer SSR uses for hydration output. Pins
|
|
110
|
-
* the hydration global (`_$HY.r`) and feature policy; only the wiring
|
|
111
|
-
* options (callbacks, scope, extra plugins) are configurable. Not meant
|
|
112
|
-
* for hand-written code — custom serialization should use
|
|
113
|
-
* `createSerializer` or the JSON codec.
|
|
114
|
-
* @internal
|
|
115
|
-
*/
|
|
116
|
-
export function createHydrationSerializer(options: HydrationSerializerOptions): Serializer;
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Renderer primitive — returns the cross-reference bootstrap script SSR
|
|
120
|
-
* emits ahead of hydration data for a render scope. Not meant for
|
|
121
|
-
* hand-written code.
|
|
122
|
-
* @internal
|
|
123
|
-
*/
|
|
124
|
-
export function getLocalHeaderScript(id?: string): string;
|
|
125
|
-
|
|
126
|
-
// ---- JSON codec (server function transports) ----
|
|
127
|
-
// (`JSONCodecOptions` and the decode half are declared in
|
|
128
|
-
// serializer-decode.d.ts and re-exported above.)
|
|
129
|
-
|
|
35
|
+
export type HydrationSerializerOptions = Omit<WebSerializerOptions, "globalIdentifier" | "disabledFeatures">;
|
|
130
36
|
/**
|
|
131
37
|
* Options for `serializeJSON`.
|
|
132
38
|
*
|
|
133
39
|
* Integration-facing; may change (see the entry banner).
|
|
134
40
|
*/
|
|
135
41
|
export interface JSONSerializeOptions extends JSONCodecOptions {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Receives each serialized node; `initial` is true for the first chunk
|
|
44
|
+
* (the source value itself). Async values produce additional chunks as
|
|
45
|
+
* they resolve.
|
|
46
|
+
*/
|
|
47
|
+
onParse: (node: SerovalNode, initial: boolean) => void;
|
|
48
|
+
onError?: (error: unknown) => void;
|
|
49
|
+
/** Fires once all async values have settled. */
|
|
50
|
+
onDone?: () => void;
|
|
145
51
|
}
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* Serializes `value` as SerovalNode chunks delivered through `onParse` —
|
|
149
|
-
* the encoding half of the eval-free JSON codec (RPC-style transports;
|
|
150
|
-
* the deserializing peer needs no script evaluation, so CSP-safe). Wire
|
|
151
|
-
* framing of the nodes is the transport's concern. Returns a cancel
|
|
152
|
-
* function that aborts pending async serialization.
|
|
153
|
-
*
|
|
154
|
-
* Integration-facing; may change (see the entry banner).
|
|
155
|
-
*/
|
|
156
|
-
export function serializeJSON(value: unknown, options: JSONSerializeOptions): () => void;
|
|
157
|
-
|
|
158
52
|
/** Options for `createJSONSerializer`. */
|
|
159
53
|
export interface JSONSerializerOptions extends JSONCodecOptions {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Receives each keyed record — `initial` is true for a key's first node
|
|
56
|
+
* (the written value itself); async values patch through later records
|
|
57
|
+
* under the same key. The decoding peer is `createJSONDataTable`.
|
|
58
|
+
*/
|
|
59
|
+
onData: (record: {
|
|
60
|
+
key: string;
|
|
61
|
+
node: SerovalNode;
|
|
62
|
+
initial: boolean;
|
|
63
|
+
}) => void;
|
|
64
|
+
onError?: (error: unknown) => void;
|
|
65
|
+
/** Fires once `flush()` has been called and every pending value settled. */
|
|
66
|
+
onDone?: () => void;
|
|
67
|
+
}
|
|
68
|
+
export declare const createPlugin: <Value, Info extends PluginInfo>(plugin: SerializerPlugin<Value, Info>) => SerializerPlugin<Value, Info>;
|
|
69
|
+
export interface OpaqueReference<V = unknown, R = undefined> {
|
|
70
|
+
readonly value: V;
|
|
71
|
+
readonly replacement?: R;
|
|
169
72
|
}
|
|
170
|
-
|
|
73
|
+
export declare const OpaqueReference: {
|
|
74
|
+
new <V, R = undefined>(value: V, replacement?: R): OpaqueReference<V, R>;
|
|
75
|
+
};
|
|
171
76
|
/**
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
*
|
|
77
|
+
* Creates a streaming Seroval serializer preconfigured with the web plugin
|
|
78
|
+
* set and the default feature policy. Emits JavaScript chunks (through
|
|
79
|
+
* `onData`) that reconstruct the values under `globalIdentifier` when
|
|
80
|
+
* evaluated — the script-injection form of serialization renderers build
|
|
81
|
+
* on. For a JSON-based wire codec (no eval on the receiving side), use
|
|
82
|
+
* `serializeJSON` / `createJSONDeserializer` instead.
|
|
83
|
+
*
|
|
84
|
+
* Integration-facing; may change (see the entry banner).
|
|
177
85
|
*/
|
|
178
|
-
export function
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
86
|
+
export declare function createSerializer(options: WebSerializerOptions): Serializer;
|
|
87
|
+
export declare function createHydrationSerializer(options: HydrationSerializerOptions): Serializer;
|
|
88
|
+
export declare function getLocalHeaderScript(id?: string): string;
|
|
89
|
+
export declare function serializeJSON(value: unknown, options: JSONSerializeOptions): () => void;
|
|
90
|
+
export declare function createJSONSerializer(options: JSONSerializerOptions): {
|
|
91
|
+
write(key: string, value: unknown): void;
|
|
92
|
+
flush(): void;
|
|
93
|
+
close(): void;
|
|
182
94
|
};
|