@solidjs/web 2.0.0-beta.32 → 2.0.0-beta.34
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 +58 -16
- package/dist/dev.js +54 -17
- package/dist/server.cjs +714 -75
- package/dist/server.js +711 -78
- package/dist/web.cjs +58 -16
- package/dist/web.js +54 -17
- package/frames/dist/client.cjs +181 -64
- package/frames/dist/client.dev.cjs +185 -64
- package/frames/dist/client.dev.js +183 -62
- package/frames/dist/client.js +179 -62
- package/frames/dist/server.cjs +972 -136
- package/frames/dist/server.js +974 -138
- package/package.json +17 -6
- package/serialization/decode/package.json +20 -0
- package/serialization/dist/decode.cjs +110 -0
- package/serialization/dist/decode.js +104 -0
- package/serialization/dist/serialization.cjs +98 -43
- package/serialization/dist/serialization.js +99 -44
- package/serialization/types/index.d.ts +18 -160
- package/serialization/types/serializer-decode.d.ts +182 -0
- package/serialization/types-cjs/index.d.cts +18 -160
- package/serialization/types-cjs/serializer-decode.d.cts +182 -0
- package/server-functions/dist/client.cjs +101 -105
- package/server-functions/dist/client.js +101 -105
- package/server-functions/dist/server.cjs +131 -107
- package/server-functions/dist/server.dev.cjs +131 -107
- package/server-functions/dist/server.dev.js +132 -108
- package/server-functions/dist/server.js +132 -108
- package/types/client.d.ts +23 -1
- package/types/cookies.d.ts +93 -0
- package/types/core.d.ts +1 -1
- package/types/frames/frame-client.d.ts +26 -0
- package/types/frames/frame-transport.d.ts +1 -1
- package/types/frames/serializer.d.ts +18 -160
- package/types/serializer-decode.d.ts +182 -0
- package/types/serializer.d.ts +18 -160
- package/types/server-functions/client.d.ts +1 -1
- package/types/server-functions/server.d.ts +1 -1
- package/types/server-functions/shared.d.ts +57 -1
- package/types/server.d.ts +21 -1
- package/types-cjs/client.d.cts +23 -1
- package/types-cjs/cookies.d.cts +93 -0
- package/types-cjs/core.d.cts +1 -1
- package/types-cjs/frames/frame-client.d.cts +26 -0
- package/types-cjs/frames/frame-transport.d.cts +1 -1
- package/types-cjs/frames/serializer.d.cts +18 -160
- package/types-cjs/serializer-decode.d.cts +182 -0
- package/types-cjs/serializer.d.cts +18 -160
- package/types-cjs/server-functions/client.d.cts +1 -1
- package/types-cjs/server-functions/server.d.cts +1 -1
- package/types-cjs/server-functions/shared.d.cts +57 -1
- package/types-cjs/server.d.cts +21 -1
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-beta.
|
|
4
|
+
"version": "2.0.0-beta.34",
|
|
5
5
|
"author": "Ryan Carniato",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://solidjs.com",
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"serialization/types",
|
|
34
34
|
"serialization/types-cjs",
|
|
35
35
|
"serialization/package.json",
|
|
36
|
+
"serialization/decode/package.json",
|
|
36
37
|
"server-functions/dist",
|
|
37
38
|
"server-functions/package.json",
|
|
38
39
|
"server-functions/rich-args/package.json",
|
|
@@ -150,6 +151,16 @@
|
|
|
150
151
|
"default": "./serialization/dist/serialization.cjs"
|
|
151
152
|
}
|
|
152
153
|
},
|
|
154
|
+
"./serialization/decode": {
|
|
155
|
+
"import": {
|
|
156
|
+
"types": "./serialization/types/serializer-decode.d.ts",
|
|
157
|
+
"default": "./serialization/dist/decode.js"
|
|
158
|
+
},
|
|
159
|
+
"require": {
|
|
160
|
+
"types": "./serialization/types-cjs/serializer-decode.d.cts",
|
|
161
|
+
"default": "./serialization/dist/decode.cjs"
|
|
162
|
+
}
|
|
163
|
+
},
|
|
153
164
|
"./server-functions": {
|
|
154
165
|
"worker": {
|
|
155
166
|
"development": {
|
|
@@ -367,24 +378,24 @@
|
|
|
367
378
|
"seroval-plugins": "~1.5.4"
|
|
368
379
|
},
|
|
369
380
|
"peerDependencies": {
|
|
370
|
-
"solid-js": "^2.0.0-beta.
|
|
381
|
+
"solid-js": "^2.0.0-beta.34"
|
|
371
382
|
},
|
|
372
383
|
"devDependencies": {
|
|
373
|
-
"solid-js": "2.0.0-beta.
|
|
384
|
+
"solid-js": "2.0.0-beta.34"
|
|
374
385
|
},
|
|
375
386
|
"scripts": {
|
|
376
387
|
"build": "npm-run-all -nl build:clean types:copy-jsx build:js",
|
|
377
388
|
"build:clean": "rimraf dist/",
|
|
378
389
|
"build:js": "rollup -c",
|
|
379
390
|
"link": "symlink-dir . node_modules/@solidjs/web",
|
|
380
|
-
"types": "npm-run-all -nl types:clean types:copy-jsx types:web types:copy-web types:web-storage types:copy-server-functions types:
|
|
391
|
+
"types": "npm-run-all -nl types:clean types:copy-jsx types:web types:copy-web types:web-storage types:copy-server-functions types:copy-serialization types:web-frames types:copy-frames types:cjs",
|
|
381
392
|
"types:clean": "rimraf types/ types-cjs/ storage/types/ storage/types-cjs/ serialization/types/ serialization/types-cjs/ frames/types/",
|
|
382
393
|
"types:copy-jsx": "ncp ../../node_modules/@dom-expressions/runtime/src/jsx.d.ts ./src/jsx.d.ts && ncp ../../node_modules/@dom-expressions/runtime/src/jsx-properties.d.ts ./src/jsx-properties.d.ts && dom-expressions-jsx-types --input ./src/jsx.d.ts --element \"SolidElement | Node | ArrayElement\" --import 'import type { Element as SolidElement } from \"solid-js\";'",
|
|
383
394
|
"types:web": "tsc --project ./tsconfig.build.json",
|
|
384
|
-
"types:copy-web": "
|
|
395
|
+
"types:copy-web": "node -e \"const src = fs.readFileSync('../../node_modules/@dom-expressions/runtime/src/client.d.ts', 'utf8'); const marker = 'export type { RequestEventLocals } from'; if (!src.includes(marker)) throw new Error('client.d.ts drift: the type-only RequestEventLocals re-export was not found — revisit the augmentation-identity rewrite'); fs.writeFileSync('./types/client.d.ts', src.replace(marker, 'export { RequestEventLocals } from'));\" && ncp ../../node_modules/@dom-expressions/runtime/src/server.d.ts ./types/server.d.ts && ncp ../../node_modules/@dom-expressions/runtime/src/serializer.d.ts ./types/serializer.d.ts && ncp ../../node_modules/@dom-expressions/runtime/src/serializer-decode.d.ts ./types/serializer-decode.d.ts && ncp ../../node_modules/@dom-expressions/runtime/src/response.d.ts ./types/response.d.ts && ncp ../../node_modules/@dom-expressions/runtime/src/cookies.d.ts ./types/cookies.d.ts && ncp ./src/jsx.d.ts ./types/jsx.d.ts && ncp ./src/jsx-properties.d.ts ./types/jsx-properties.d.ts",
|
|
385
396
|
"types:web-storage": "tsc --project ./storage/tsconfig.build.json",
|
|
386
397
|
"types:web-frames": "tsc --project ./frames/tsconfig.build.json",
|
|
387
|
-
"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');\"",
|
|
398
|
+
"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');\"",
|
|
388
399
|
"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');\"",
|
|
389
400
|
"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/', './'));\"",
|
|
390
401
|
"types:cjs": "node ../../scripts/sync-dual-types.mjs ./types ./types-cjs ./storage/types ./storage/types-cjs ./serialization/types ./serialization/types-cjs",
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@solidjs/web/serialization/decode",
|
|
3
|
+
"main": "../dist/decode.cjs",
|
|
4
|
+
"module": "../dist/decode.js",
|
|
5
|
+
"types": "../types/serializer-decode.d.ts",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": {
|
|
11
|
+
"types": "../types/serializer-decode.d.ts",
|
|
12
|
+
"default": "../dist/decode.js"
|
|
13
|
+
},
|
|
14
|
+
"require": {
|
|
15
|
+
"types": "../types-cjs/serializer-decode.d.cts",
|
|
16
|
+
"default": "../dist/decode.cjs"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var seroval = require('seroval');
|
|
4
|
+
var web = require('seroval-plugins/web');
|
|
5
|
+
|
|
6
|
+
const STATE = Symbol.for("dom-expressions.container-trace-state");
|
|
7
|
+
const state = globalThis[STATE] || (globalThis[STATE] = {
|
|
8
|
+
materialized: new WeakMap(),
|
|
9
|
+
materializedValues: new WeakSet()
|
|
10
|
+
});
|
|
11
|
+
const TRACE = Symbol.for("dom-expressions.container-trace");
|
|
12
|
+
function materialize(marker) {
|
|
13
|
+
let value = state.materialized.get(marker.$tr);
|
|
14
|
+
if (value === undefined) {
|
|
15
|
+
value = state.materializeTrace(marker);
|
|
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 parseTrace(value, ctx) {
|
|
22
|
+
const trace = value[TRACE];
|
|
23
|
+
return {
|
|
24
|
+
a: trace.array ? 1 : 0,
|
|
25
|
+
i: ctx.parse(trace.subscribe())
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
const ContainerTracePlugin = {
|
|
29
|
+
tag: "dom-expressions/container-trace",
|
|
30
|
+
test(value) {
|
|
31
|
+
return value != null && typeof value === "object" && TRACE in value;
|
|
32
|
+
},
|
|
33
|
+
parse: {
|
|
34
|
+
sync() {
|
|
35
|
+
throw new Error("A reactive container can only be serialized by a streaming serializer.");
|
|
36
|
+
},
|
|
37
|
+
async async(value, ctx) {
|
|
38
|
+
const trace = value[TRACE];
|
|
39
|
+
return {
|
|
40
|
+
a: trace.array ? 1 : 0,
|
|
41
|
+
i: await ctx.parse(trace.subscribe())
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
stream: parseTrace
|
|
45
|
+
},
|
|
46
|
+
serialize(node, ctx) {
|
|
47
|
+
return "{$tr:" + ctx.serialize(node.i) + ",$ta:" + node.a + "}";
|
|
48
|
+
},
|
|
49
|
+
deserialize(node, ctx) {
|
|
50
|
+
const iterable = ctx.deserialize(node.i);
|
|
51
|
+
const marker = {
|
|
52
|
+
$tr: iterable,
|
|
53
|
+
$ta: node.a
|
|
54
|
+
};
|
|
55
|
+
return state.materializeTrace ? materialize(marker) : marker;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const DEFAULT_WEB_PLUGINS = Object.freeze([web.AbortSignalPlugin,
|
|
60
|
+
web.CustomEventPlugin, web.DOMExceptionPlugin, web.EventPlugin,
|
|
61
|
+
web.FormDataPlugin, web.HeadersPlugin, web.ReadableStreamPlugin, web.RequestPlugin, web.ResponsePlugin, web.URLSearchParamsPlugin, web.URLPlugin,
|
|
62
|
+
ContainerTracePlugin]);
|
|
63
|
+
function resolveSerializerPlugins(customPlugins) {
|
|
64
|
+
return customPlugins ? [...customPlugins, ...DEFAULT_WEB_PLUGINS] : [...DEFAULT_WEB_PLUGINS];
|
|
65
|
+
}
|
|
66
|
+
const JSON_CODEC_DISABLED_FEATURES = seroval.Feature.RegExp;
|
|
67
|
+
const JSON_CODEC_DEPTH_LIMIT = 64;
|
|
68
|
+
function resolveCodecOptions({
|
|
69
|
+
plugins,
|
|
70
|
+
disabledFeatures,
|
|
71
|
+
depthLimit
|
|
72
|
+
} = {}) {
|
|
73
|
+
return {
|
|
74
|
+
plugins: resolveSerializerPlugins(plugins),
|
|
75
|
+
disabledFeatures: disabledFeatures === undefined ? JSON_CODEC_DISABLED_FEATURES : disabledFeatures,
|
|
76
|
+
depthLimit: depthLimit === undefined ? JSON_CODEC_DEPTH_LIMIT : depthLimit
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function createJSONDeserializer(options) {
|
|
80
|
+
const refs = new Map();
|
|
81
|
+
const resolved = resolveCodecOptions(options);
|
|
82
|
+
return function deserializeJSONChunk(node) {
|
|
83
|
+
return seroval.fromCrossJSON(node, {
|
|
84
|
+
refs,
|
|
85
|
+
...resolved
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
function createJSONDataTable(options) {
|
|
90
|
+
const deserialize = createJSONDeserializer(options);
|
|
91
|
+
const table = new Map();
|
|
92
|
+
return {
|
|
93
|
+
apply(record) {
|
|
94
|
+
const value = deserialize(record.node);
|
|
95
|
+
if (record.initial) table.set(record.key, value);
|
|
96
|
+
},
|
|
97
|
+
get(key) {
|
|
98
|
+
return table.get(key);
|
|
99
|
+
},
|
|
100
|
+
resolve(ref) {
|
|
101
|
+
return table.get(ref.$ref);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
exports.DEFAULT_WEB_PLUGINS = DEFAULT_WEB_PLUGINS;
|
|
107
|
+
exports.createJSONDataTable = createJSONDataTable;
|
|
108
|
+
exports.createJSONDeserializer = createJSONDeserializer;
|
|
109
|
+
exports.resolveCodecOptions = resolveCodecOptions;
|
|
110
|
+
exports.resolveSerializerPlugins = resolveSerializerPlugins;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { Feature, fromCrossJSON } from 'seroval';
|
|
2
|
+
import { AbortSignalPlugin, CustomEventPlugin, DOMExceptionPlugin, EventPlugin, FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin } from 'seroval-plugins/web';
|
|
3
|
+
|
|
4
|
+
const STATE = Symbol.for("dom-expressions.container-trace-state");
|
|
5
|
+
const state = globalThis[STATE] || (globalThis[STATE] = {
|
|
6
|
+
materialized: new WeakMap(),
|
|
7
|
+
materializedValues: new WeakSet()
|
|
8
|
+
});
|
|
9
|
+
const TRACE = Symbol.for("dom-expressions.container-trace");
|
|
10
|
+
function materialize(marker) {
|
|
11
|
+
let value = state.materialized.get(marker.$tr);
|
|
12
|
+
if (value === undefined) {
|
|
13
|
+
value = state.materializeTrace(marker);
|
|
14
|
+
state.materialized.set(marker.$tr, value);
|
|
15
|
+
if (value !== null && typeof value === "object") state.materializedValues.add(value);
|
|
16
|
+
}
|
|
17
|
+
return value;
|
|
18
|
+
}
|
|
19
|
+
function parseTrace(value, ctx) {
|
|
20
|
+
const trace = value[TRACE];
|
|
21
|
+
return {
|
|
22
|
+
a: trace.array ? 1 : 0,
|
|
23
|
+
i: ctx.parse(trace.subscribe())
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
const ContainerTracePlugin = {
|
|
27
|
+
tag: "dom-expressions/container-trace",
|
|
28
|
+
test(value) {
|
|
29
|
+
return value != null && typeof value === "object" && TRACE in value;
|
|
30
|
+
},
|
|
31
|
+
parse: {
|
|
32
|
+
sync() {
|
|
33
|
+
throw new Error("A reactive container can only be serialized by a streaming serializer.");
|
|
34
|
+
},
|
|
35
|
+
async async(value, ctx) {
|
|
36
|
+
const trace = value[TRACE];
|
|
37
|
+
return {
|
|
38
|
+
a: trace.array ? 1 : 0,
|
|
39
|
+
i: await ctx.parse(trace.subscribe())
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
stream: parseTrace
|
|
43
|
+
},
|
|
44
|
+
serialize(node, ctx) {
|
|
45
|
+
return "{$tr:" + ctx.serialize(node.i) + ",$ta:" + node.a + "}";
|
|
46
|
+
},
|
|
47
|
+
deserialize(node, ctx) {
|
|
48
|
+
const iterable = ctx.deserialize(node.i);
|
|
49
|
+
const marker = {
|
|
50
|
+
$tr: iterable,
|
|
51
|
+
$ta: node.a
|
|
52
|
+
};
|
|
53
|
+
return state.materializeTrace ? materialize(marker) : marker;
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const DEFAULT_WEB_PLUGINS = Object.freeze([AbortSignalPlugin,
|
|
58
|
+
CustomEventPlugin, DOMExceptionPlugin, EventPlugin,
|
|
59
|
+
FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin,
|
|
60
|
+
ContainerTracePlugin]);
|
|
61
|
+
function resolveSerializerPlugins(customPlugins) {
|
|
62
|
+
return customPlugins ? [...customPlugins, ...DEFAULT_WEB_PLUGINS] : [...DEFAULT_WEB_PLUGINS];
|
|
63
|
+
}
|
|
64
|
+
const JSON_CODEC_DISABLED_FEATURES = Feature.RegExp;
|
|
65
|
+
const JSON_CODEC_DEPTH_LIMIT = 64;
|
|
66
|
+
function resolveCodecOptions({
|
|
67
|
+
plugins,
|
|
68
|
+
disabledFeatures,
|
|
69
|
+
depthLimit
|
|
70
|
+
} = {}) {
|
|
71
|
+
return {
|
|
72
|
+
plugins: resolveSerializerPlugins(plugins),
|
|
73
|
+
disabledFeatures: disabledFeatures === undefined ? JSON_CODEC_DISABLED_FEATURES : disabledFeatures,
|
|
74
|
+
depthLimit: depthLimit === undefined ? JSON_CODEC_DEPTH_LIMIT : depthLimit
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function createJSONDeserializer(options) {
|
|
78
|
+
const refs = new Map();
|
|
79
|
+
const resolved = resolveCodecOptions(options);
|
|
80
|
+
return function deserializeJSONChunk(node) {
|
|
81
|
+
return fromCrossJSON(node, {
|
|
82
|
+
refs,
|
|
83
|
+
...resolved
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function createJSONDataTable(options) {
|
|
88
|
+
const deserialize = createJSONDeserializer(options);
|
|
89
|
+
const table = new Map();
|
|
90
|
+
return {
|
|
91
|
+
apply(record) {
|
|
92
|
+
const value = deserialize(record.node);
|
|
93
|
+
if (record.initial) table.set(record.key, value);
|
|
94
|
+
},
|
|
95
|
+
get(key) {
|
|
96
|
+
return table.get(key);
|
|
97
|
+
},
|
|
98
|
+
resolve(ref) {
|
|
99
|
+
return table.get(ref.$ref);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export { DEFAULT_WEB_PLUGINS, createJSONDataTable, createJSONDeserializer, resolveCodecOptions, resolveSerializerPlugins };
|
|
@@ -3,15 +3,109 @@
|
|
|
3
3
|
var seroval = require('seroval');
|
|
4
4
|
var web = require('seroval-plugins/web');
|
|
5
5
|
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
|
|
6
|
+
const STATE = Symbol.for("dom-expressions.container-trace-state");
|
|
7
|
+
const state = globalThis[STATE] || (globalThis[STATE] = {
|
|
8
|
+
materialized: new WeakMap(),
|
|
9
|
+
materializedValues: new WeakSet()
|
|
10
|
+
});
|
|
11
|
+
const TRACE = Symbol.for("dom-expressions.container-trace");
|
|
12
|
+
function materialize(marker) {
|
|
13
|
+
let value = state.materialized.get(marker.$tr);
|
|
14
|
+
if (value === undefined) {
|
|
15
|
+
value = state.materializeTrace(marker);
|
|
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 parseTrace(value, ctx) {
|
|
22
|
+
const trace = value[TRACE];
|
|
23
|
+
return {
|
|
24
|
+
a: trace.array ? 1 : 0,
|
|
25
|
+
i: ctx.parse(trace.subscribe())
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
const ContainerTracePlugin = {
|
|
29
|
+
tag: "dom-expressions/container-trace",
|
|
30
|
+
test(value) {
|
|
31
|
+
return value != null && typeof value === "object" && TRACE in value;
|
|
32
|
+
},
|
|
33
|
+
parse: {
|
|
34
|
+
sync() {
|
|
35
|
+
throw new Error("A reactive container can only be serialized by a streaming serializer.");
|
|
36
|
+
},
|
|
37
|
+
async async(value, ctx) {
|
|
38
|
+
const trace = value[TRACE];
|
|
39
|
+
return {
|
|
40
|
+
a: trace.array ? 1 : 0,
|
|
41
|
+
i: await ctx.parse(trace.subscribe())
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
stream: parseTrace
|
|
45
|
+
},
|
|
46
|
+
serialize(node, ctx) {
|
|
47
|
+
return "{$tr:" + ctx.serialize(node.i) + ",$ta:" + node.a + "}";
|
|
48
|
+
},
|
|
49
|
+
deserialize(node, ctx) {
|
|
50
|
+
const iterable = ctx.deserialize(node.i);
|
|
51
|
+
const marker = {
|
|
52
|
+
$tr: iterable,
|
|
53
|
+
$ta: node.a
|
|
54
|
+
};
|
|
55
|
+
return state.materializeTrace ? materialize(marker) : marker;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
9
59
|
const DEFAULT_WEB_PLUGINS = Object.freeze([web.AbortSignalPlugin,
|
|
10
60
|
web.CustomEventPlugin, web.DOMExceptionPlugin, web.EventPlugin,
|
|
11
|
-
web.FormDataPlugin, web.HeadersPlugin, web.ReadableStreamPlugin, web.RequestPlugin, web.ResponsePlugin, web.URLSearchParamsPlugin, web.URLPlugin
|
|
61
|
+
web.FormDataPlugin, web.HeadersPlugin, web.ReadableStreamPlugin, web.RequestPlugin, web.ResponsePlugin, web.URLSearchParamsPlugin, web.URLPlugin,
|
|
62
|
+
ContainerTracePlugin]);
|
|
12
63
|
function resolveSerializerPlugins(customPlugins) {
|
|
13
64
|
return customPlugins ? [...customPlugins, ...DEFAULT_WEB_PLUGINS] : [...DEFAULT_WEB_PLUGINS];
|
|
14
65
|
}
|
|
66
|
+
const JSON_CODEC_DISABLED_FEATURES = seroval.Feature.RegExp;
|
|
67
|
+
const JSON_CODEC_DEPTH_LIMIT = 64;
|
|
68
|
+
function resolveCodecOptions({
|
|
69
|
+
plugins,
|
|
70
|
+
disabledFeatures,
|
|
71
|
+
depthLimit
|
|
72
|
+
} = {}) {
|
|
73
|
+
return {
|
|
74
|
+
plugins: resolveSerializerPlugins(plugins),
|
|
75
|
+
disabledFeatures: disabledFeatures === undefined ? JSON_CODEC_DISABLED_FEATURES : disabledFeatures,
|
|
76
|
+
depthLimit: depthLimit === undefined ? JSON_CODEC_DEPTH_LIMIT : depthLimit
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function createJSONDeserializer(options) {
|
|
80
|
+
const refs = new Map();
|
|
81
|
+
const resolved = resolveCodecOptions(options);
|
|
82
|
+
return function deserializeJSONChunk(node) {
|
|
83
|
+
return seroval.fromCrossJSON(node, {
|
|
84
|
+
refs,
|
|
85
|
+
...resolved
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
function createJSONDataTable(options) {
|
|
90
|
+
const deserialize = createJSONDeserializer(options);
|
|
91
|
+
const table = new Map();
|
|
92
|
+
return {
|
|
93
|
+
apply(record) {
|
|
94
|
+
const value = deserialize(record.node);
|
|
95
|
+
if (record.initial) table.set(record.key, value);
|
|
96
|
+
},
|
|
97
|
+
get(key) {
|
|
98
|
+
return table.get(key);
|
|
99
|
+
},
|
|
100
|
+
resolve(ref) {
|
|
101
|
+
return table.get(ref.$ref);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const DEFAULT_DISABLED_FEATURES = seroval.Feature.AggregateError | seroval.Feature.BigIntTypedArray;
|
|
107
|
+
const serializeOnlyDisabledFeatures = () => process.env.NODE_ENV === "development" ? 0 : seroval.Feature.ErrorPrototypeStack;
|
|
108
|
+
const HYDRATION_GLOBAL = "_$HY.r";
|
|
15
109
|
function createSerializer(options) {
|
|
16
110
|
return new seroval.Serializer({
|
|
17
111
|
...options,
|
|
@@ -38,19 +132,6 @@ function createHydrationSerializer({
|
|
|
38
132
|
function getLocalHeaderScript(id) {
|
|
39
133
|
return seroval.getCrossReferenceHeader(id) + ";";
|
|
40
134
|
}
|
|
41
|
-
const JSON_CODEC_DISABLED_FEATURES = seroval.Feature.RegExp;
|
|
42
|
-
const JSON_CODEC_DEPTH_LIMIT = 64;
|
|
43
|
-
function resolveCodecOptions({
|
|
44
|
-
plugins,
|
|
45
|
-
disabledFeatures,
|
|
46
|
-
depthLimit
|
|
47
|
-
} = {}) {
|
|
48
|
-
return {
|
|
49
|
-
plugins: resolveSerializerPlugins(plugins),
|
|
50
|
-
disabledFeatures: disabledFeatures === undefined ? JSON_CODEC_DISABLED_FEATURES : disabledFeatures,
|
|
51
|
-
depthLimit: depthLimit === undefined ? JSON_CODEC_DEPTH_LIMIT : depthLimit
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
135
|
function serializeJSON(value, {
|
|
55
136
|
onParse,
|
|
56
137
|
onDone,
|
|
@@ -66,16 +147,6 @@ function serializeJSON(value, {
|
|
|
66
147
|
disabledFeatures: resolved.disabledFeatures | serializeOnlyDisabledFeatures()
|
|
67
148
|
});
|
|
68
149
|
}
|
|
69
|
-
function createJSONDeserializer(options) {
|
|
70
|
-
const refs = new Map();
|
|
71
|
-
const resolved = resolveCodecOptions(options);
|
|
72
|
-
return function deserializeJSONChunk(node) {
|
|
73
|
-
return seroval.fromCrossJSON(node, {
|
|
74
|
-
refs,
|
|
75
|
-
...resolved
|
|
76
|
-
});
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
150
|
function createJSONSerializer({
|
|
80
151
|
onData,
|
|
81
152
|
onDone,
|
|
@@ -141,22 +212,6 @@ function createJSONSerializer({
|
|
|
141
212
|
}
|
|
142
213
|
};
|
|
143
214
|
}
|
|
144
|
-
function createJSONDataTable(options) {
|
|
145
|
-
const deserialize = createJSONDeserializer(options);
|
|
146
|
-
const table = new Map();
|
|
147
|
-
return {
|
|
148
|
-
apply(record) {
|
|
149
|
-
const value = deserialize(record.node);
|
|
150
|
-
if (record.initial) table.set(record.key, value);
|
|
151
|
-
},
|
|
152
|
-
get(key) {
|
|
153
|
-
return table.get(key);
|
|
154
|
-
},
|
|
155
|
-
resolve(ref) {
|
|
156
|
-
return table.get(ref.$ref);
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
215
|
|
|
161
216
|
Object.defineProperty(exports, "OpaqueReference", {
|
|
162
217
|
enumerable: true,
|
|
@@ -1,16 +1,110 @@
|
|
|
1
|
-
import { Feature,
|
|
1
|
+
import { Feature, fromCrossJSON, toCrossJSONStream, Serializer, getCrossReferenceHeader } from 'seroval';
|
|
2
2
|
export { OpaqueReference, createPlugin } from 'seroval';
|
|
3
3
|
import { AbortSignalPlugin, CustomEventPlugin, DOMExceptionPlugin, EventPlugin, FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin } from 'seroval-plugins/web';
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
5
|
+
const STATE = Symbol.for("dom-expressions.container-trace-state");
|
|
6
|
+
const state = globalThis[STATE] || (globalThis[STATE] = {
|
|
7
|
+
materialized: new WeakMap(),
|
|
8
|
+
materializedValues: new WeakSet()
|
|
9
|
+
});
|
|
10
|
+
const TRACE = Symbol.for("dom-expressions.container-trace");
|
|
11
|
+
function materialize(marker) {
|
|
12
|
+
let value = state.materialized.get(marker.$tr);
|
|
13
|
+
if (value === undefined) {
|
|
14
|
+
value = state.materializeTrace(marker);
|
|
15
|
+
state.materialized.set(marker.$tr, value);
|
|
16
|
+
if (value !== null && typeof value === "object") state.materializedValues.add(value);
|
|
17
|
+
}
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
20
|
+
function parseTrace(value, ctx) {
|
|
21
|
+
const trace = value[TRACE];
|
|
22
|
+
return {
|
|
23
|
+
a: trace.array ? 1 : 0,
|
|
24
|
+
i: ctx.parse(trace.subscribe())
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
const ContainerTracePlugin = {
|
|
28
|
+
tag: "dom-expressions/container-trace",
|
|
29
|
+
test(value) {
|
|
30
|
+
return value != null && typeof value === "object" && TRACE in value;
|
|
31
|
+
},
|
|
32
|
+
parse: {
|
|
33
|
+
sync() {
|
|
34
|
+
throw new Error("A reactive container can only be serialized by a streaming serializer.");
|
|
35
|
+
},
|
|
36
|
+
async async(value, ctx) {
|
|
37
|
+
const trace = value[TRACE];
|
|
38
|
+
return {
|
|
39
|
+
a: trace.array ? 1 : 0,
|
|
40
|
+
i: await ctx.parse(trace.subscribe())
|
|
41
|
+
};
|
|
42
|
+
},
|
|
43
|
+
stream: parseTrace
|
|
44
|
+
},
|
|
45
|
+
serialize(node, ctx) {
|
|
46
|
+
return "{$tr:" + ctx.serialize(node.i) + ",$ta:" + node.a + "}";
|
|
47
|
+
},
|
|
48
|
+
deserialize(node, ctx) {
|
|
49
|
+
const iterable = ctx.deserialize(node.i);
|
|
50
|
+
const marker = {
|
|
51
|
+
$tr: iterable,
|
|
52
|
+
$ta: node.a
|
|
53
|
+
};
|
|
54
|
+
return state.materializeTrace ? materialize(marker) : marker;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
8
58
|
const DEFAULT_WEB_PLUGINS = Object.freeze([AbortSignalPlugin,
|
|
9
59
|
CustomEventPlugin, DOMExceptionPlugin, EventPlugin,
|
|
10
|
-
FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin
|
|
60
|
+
FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin,
|
|
61
|
+
ContainerTracePlugin]);
|
|
11
62
|
function resolveSerializerPlugins(customPlugins) {
|
|
12
63
|
return customPlugins ? [...customPlugins, ...DEFAULT_WEB_PLUGINS] : [...DEFAULT_WEB_PLUGINS];
|
|
13
64
|
}
|
|
65
|
+
const JSON_CODEC_DISABLED_FEATURES = Feature.RegExp;
|
|
66
|
+
const JSON_CODEC_DEPTH_LIMIT = 64;
|
|
67
|
+
function resolveCodecOptions({
|
|
68
|
+
plugins,
|
|
69
|
+
disabledFeatures,
|
|
70
|
+
depthLimit
|
|
71
|
+
} = {}) {
|
|
72
|
+
return {
|
|
73
|
+
plugins: resolveSerializerPlugins(plugins),
|
|
74
|
+
disabledFeatures: disabledFeatures === undefined ? JSON_CODEC_DISABLED_FEATURES : disabledFeatures,
|
|
75
|
+
depthLimit: depthLimit === undefined ? JSON_CODEC_DEPTH_LIMIT : depthLimit
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function createJSONDeserializer(options) {
|
|
79
|
+
const refs = new Map();
|
|
80
|
+
const resolved = resolveCodecOptions(options);
|
|
81
|
+
return function deserializeJSONChunk(node) {
|
|
82
|
+
return fromCrossJSON(node, {
|
|
83
|
+
refs,
|
|
84
|
+
...resolved
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function createJSONDataTable(options) {
|
|
89
|
+
const deserialize = createJSONDeserializer(options);
|
|
90
|
+
const table = new Map();
|
|
91
|
+
return {
|
|
92
|
+
apply(record) {
|
|
93
|
+
const value = deserialize(record.node);
|
|
94
|
+
if (record.initial) table.set(record.key, value);
|
|
95
|
+
},
|
|
96
|
+
get(key) {
|
|
97
|
+
return table.get(key);
|
|
98
|
+
},
|
|
99
|
+
resolve(ref) {
|
|
100
|
+
return table.get(ref.$ref);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const DEFAULT_DISABLED_FEATURES = Feature.AggregateError | Feature.BigIntTypedArray;
|
|
106
|
+
const serializeOnlyDisabledFeatures = () => process.env.NODE_ENV === "development" ? 0 : Feature.ErrorPrototypeStack;
|
|
107
|
+
const HYDRATION_GLOBAL = "_$HY.r";
|
|
14
108
|
function createSerializer(options) {
|
|
15
109
|
return new Serializer({
|
|
16
110
|
...options,
|
|
@@ -37,19 +131,6 @@ function createHydrationSerializer({
|
|
|
37
131
|
function getLocalHeaderScript(id) {
|
|
38
132
|
return getCrossReferenceHeader(id) + ";";
|
|
39
133
|
}
|
|
40
|
-
const JSON_CODEC_DISABLED_FEATURES = Feature.RegExp;
|
|
41
|
-
const JSON_CODEC_DEPTH_LIMIT = 64;
|
|
42
|
-
function resolveCodecOptions({
|
|
43
|
-
plugins,
|
|
44
|
-
disabledFeatures,
|
|
45
|
-
depthLimit
|
|
46
|
-
} = {}) {
|
|
47
|
-
return {
|
|
48
|
-
plugins: resolveSerializerPlugins(plugins),
|
|
49
|
-
disabledFeatures: disabledFeatures === undefined ? JSON_CODEC_DISABLED_FEATURES : disabledFeatures,
|
|
50
|
-
depthLimit: depthLimit === undefined ? JSON_CODEC_DEPTH_LIMIT : depthLimit
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
134
|
function serializeJSON(value, {
|
|
54
135
|
onParse,
|
|
55
136
|
onDone,
|
|
@@ -65,16 +146,6 @@ function serializeJSON(value, {
|
|
|
65
146
|
disabledFeatures: resolved.disabledFeatures | serializeOnlyDisabledFeatures()
|
|
66
147
|
});
|
|
67
148
|
}
|
|
68
|
-
function createJSONDeserializer(options) {
|
|
69
|
-
const refs = new Map();
|
|
70
|
-
const resolved = resolveCodecOptions(options);
|
|
71
|
-
return function deserializeJSONChunk(node) {
|
|
72
|
-
return fromCrossJSON(node, {
|
|
73
|
-
refs,
|
|
74
|
-
...resolved
|
|
75
|
-
});
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
149
|
function createJSONSerializer({
|
|
79
150
|
onData,
|
|
80
151
|
onDone,
|
|
@@ -140,21 +211,5 @@ function createJSONSerializer({
|
|
|
140
211
|
}
|
|
141
212
|
};
|
|
142
213
|
}
|
|
143
|
-
function createJSONDataTable(options) {
|
|
144
|
-
const deserialize = createJSONDeserializer(options);
|
|
145
|
-
const table = new Map();
|
|
146
|
-
return {
|
|
147
|
-
apply(record) {
|
|
148
|
-
const value = deserialize(record.node);
|
|
149
|
-
if (record.initial) table.set(record.key, value);
|
|
150
|
-
},
|
|
151
|
-
get(key) {
|
|
152
|
-
return table.get(key);
|
|
153
|
-
},
|
|
154
|
-
resolve(ref) {
|
|
155
|
-
return table.get(ref.$ref);
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
214
|
|
|
160
215
|
export { DEFAULT_WEB_PLUGINS, createHydrationSerializer, createJSONDataTable, createJSONDeserializer, createJSONSerializer, createSerializer, getLocalHeaderScript, resolveSerializerPlugins, serializeJSON };
|