@solidjs/web 2.0.0-rc.1 → 2.0.0-rc.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/server.dev.js +4472 -0
- package/dist/server.js +1301 -251
- package/dist/{server.cjs → server.observe.js} +1501 -452
- package/dist/{dev.cjs → web.dev.js} +699 -360
- package/dist/web.js +454 -139
- package/dist/{dev.js → web.observe.js} +505 -211
- package/frames/dist/client.dev.js +463 -71
- package/frames/dist/client.js +363 -70
- package/frames/dist/{client.dev.cjs → client.observe.js} +486 -133
- package/frames/dist/server.dev.js +1713 -0
- package/frames/dist/server.js +552 -2583
- package/frames/dist/server.observe.js +1713 -0
- package/frames/package.json +2 -25
- package/package.json +214 -255
- package/performance-tracks/dist/performance-tracks.dev.js +678 -0
- package/performance-tracks/dist/performance-tracks.js +6 -0
- package/performance-tracks/dist/performance-tracks.observe.js +666 -0
- package/performance-tracks/package.json +7 -0
- package/performance-tracks/types/index.d.ts +67 -0
- package/serialization/decode/package.json +2 -15
- package/serialization/dist/decode.js +92 -15
- package/serialization/dist/serialization.js +103 -23
- package/serialization/package.json +2 -15
- package/serialization/types/index.d.ts +76 -157
- package/serialization/types/serializer-decode.d.ts +149 -112
- package/serialization/types/serializer.d.ts +101 -0
- package/server-functions/dist/client.dev.js +1364 -0
- package/server-functions/dist/client.js +611 -97
- package/server-functions/dist/client.observe.js +1343 -0
- package/server-functions/dist/server.dev.js +2138 -202
- package/server-functions/dist/server.js +2042 -199
- package/server-functions/dist/server.observe.js +3043 -0
- package/server-functions/package.json +2 -35
- package/server-functions/rich-args/package.json +2 -15
- package/storage/package.json +2 -15
- package/types/client.d.ts +193 -288
- package/types/constants.d.ts +20 -0
- package/types/cookies.d.ts +32 -84
- package/types/diagnostics.d.ts +56 -0
- package/types/frames/client.d.ts +1 -1
- package/types/frames/frame-client.d.ts +323 -259
- package/types/frames/frame-container-plugin.d.ts +72 -0
- package/types/frames/frame-sink.d.ts +101 -158
- package/types/frames/frame-transport.d.ts +192 -190
- package/types/frames/serializer-decode.d.ts +219 -0
- package/types/frames/serializer.d.ts +76 -157
- package/types/frames/server.d.ts +1 -1
- package/types/head.d.ts +19 -0
- package/types/index.d.ts +52 -80
- package/types/index.server.d.ts +174 -0
- package/types/jsx.d.ts +33 -35
- package/types/observe.d.ts +358 -0
- package/types/reconcile.d.ts +1 -0
- package/types/render.d.ts +9 -0
- package/types/response.d.ts +75 -150
- package/types/serializer-decode.d.ts +149 -112
- package/types/serializer.d.ts +76 -157
- package/types/server-functions/client.d.ts +192 -194
- package/types/server-functions/flash.d.ts +28 -30
- package/types/server-functions/registry.d.ts +102 -0
- package/types/server-functions/rich-args.d.ts +1 -10
- package/types/server-functions/server.d.ts +511 -475
- package/types/server-functions/shared.d.ts +366 -425
- package/types/server-mock.d.ts +110 -13
- package/types/server-observe.d.ts +77 -0
- package/types/server.d.ts +425 -425
- package/types/trace.d.ts +127 -0
- package/LICENSE +0 -21
- package/dist/web.cjs +0 -2008
- package/frames/dist/client.cjs +0 -1916
- package/frames/dist/server.cjs +0 -3756
- package/serialization/dist/decode.cjs +0 -122
- package/serialization/dist/serialization.cjs +0 -244
- package/serialization/types-cjs/index.d.cts +0 -182
- package/serialization/types-cjs/package.json +0 -3
- package/serialization/types-cjs/serializer-decode.d.cts +0 -182
- package/server-functions/dist/client.cjs +0 -793
- package/server-functions/dist/rich-args.cjs +0 -11
- package/server-functions/dist/server.cjs +0 -1171
- package/server-functions/dist/server.dev.cjs +0 -1171
- package/storage/dist/storage.cjs +0 -12
- package/storage/types-cjs/index.d.cts +0 -28
- package/storage/types-cjs/package.json +0 -3
- package/types/core.d.ts +0 -6
- package/types-cjs/client.d.cts +0 -337
- package/types-cjs/cookies.d.cts +0 -93
- package/types-cjs/core.d.cts +0 -6
- package/types-cjs/frames/client.d.cts +0 -36
- package/types-cjs/frames/frame-client.d.cts +0 -338
- package/types-cjs/frames/frame-sink.d.cts +0 -194
- package/types-cjs/frames/frame-transport.d.cts +0 -222
- package/types-cjs/frames/serializer.d.cts +0 -182
- package/types-cjs/frames/server.d.cts +0 -52
- package/types-cjs/index.d.cts +0 -244
- package/types-cjs/jsx-properties.d.cts +0 -93
- package/types-cjs/jsx.d.cts +0 -4159
- package/types-cjs/package.json +0 -3
- package/types-cjs/response.d.cts +0 -174
- package/types-cjs/serializer-decode.d.cts +0 -182
- package/types-cjs/serializer.d.cts +0 -182
- package/types-cjs/server-functions/client.d.cts +0 -231
- package/types-cjs/server-functions/flash.d.cts +0 -38
- package/types-cjs/server-functions/rich-args.d.cts +0 -10
- package/types-cjs/server-functions/server.d.cts +0 -616
- package/types-cjs/server-functions/shared.d.cts +0 -523
- package/types-cjs/server-mock.d.cts +0 -277
- package/types-cjs/server.d.cts +0 -523
|
@@ -1,122 +0,0 @@
|
|
|
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
|
-
function deserializeJSONChunk(node) {
|
|
83
|
-
return seroval.fromCrossJSON(node, {
|
|
84
|
-
refs,
|
|
85
|
-
...resolved
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
deserializeJSONChunk.abort = function abort(error) {
|
|
89
|
-
for (const value of refs.values()) {
|
|
90
|
-
if (value === null || typeof value !== "object") continue;
|
|
91
|
-
if (value.__SEROVAL_STREAM__) {
|
|
92
|
-
value.throw(error);
|
|
93
|
-
} else if (typeof value.s === "function" && typeof value.f === "function" && value.p instanceof Promise) {
|
|
94
|
-
value.p.then(undefined, () => {});
|
|
95
|
-
value.f(error);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
return deserializeJSONChunk;
|
|
100
|
-
}
|
|
101
|
-
function createJSONDataTable(options) {
|
|
102
|
-
const deserialize = createJSONDeserializer(options);
|
|
103
|
-
const table = new Map();
|
|
104
|
-
return {
|
|
105
|
-
apply(record) {
|
|
106
|
-
const value = deserialize(record.node);
|
|
107
|
-
if (record.initial) table.set(record.key, value);
|
|
108
|
-
},
|
|
109
|
-
get(key) {
|
|
110
|
-
return table.get(key);
|
|
111
|
-
},
|
|
112
|
-
resolve(ref) {
|
|
113
|
-
return table.get(ref.$ref);
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
exports.DEFAULT_WEB_PLUGINS = DEFAULT_WEB_PLUGINS;
|
|
119
|
-
exports.createJSONDataTable = createJSONDataTable;
|
|
120
|
-
exports.createJSONDeserializer = createJSONDeserializer;
|
|
121
|
-
exports.resolveCodecOptions = resolveCodecOptions;
|
|
122
|
-
exports.resolveSerializerPlugins = resolveSerializerPlugins;
|
|
@@ -1,244 +0,0 @@
|
|
|
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
|
-
function deserializeJSONChunk(node) {
|
|
83
|
-
return seroval.fromCrossJSON(node, {
|
|
84
|
-
refs,
|
|
85
|
-
...resolved
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
deserializeJSONChunk.abort = function abort(error) {
|
|
89
|
-
for (const value of refs.values()) {
|
|
90
|
-
if (value === null || typeof value !== "object") continue;
|
|
91
|
-
if (value.__SEROVAL_STREAM__) {
|
|
92
|
-
value.throw(error);
|
|
93
|
-
} else if (typeof value.s === "function" && typeof value.f === "function" && value.p instanceof Promise) {
|
|
94
|
-
value.p.then(undefined, () => {});
|
|
95
|
-
value.f(error);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
return deserializeJSONChunk;
|
|
100
|
-
}
|
|
101
|
-
function createJSONDataTable(options) {
|
|
102
|
-
const deserialize = createJSONDeserializer(options);
|
|
103
|
-
const table = new Map();
|
|
104
|
-
return {
|
|
105
|
-
apply(record) {
|
|
106
|
-
const value = deserialize(record.node);
|
|
107
|
-
if (record.initial) table.set(record.key, value);
|
|
108
|
-
},
|
|
109
|
-
get(key) {
|
|
110
|
-
return table.get(key);
|
|
111
|
-
},
|
|
112
|
-
resolve(ref) {
|
|
113
|
-
return table.get(ref.$ref);
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const DEFAULT_DISABLED_FEATURES = seroval.Feature.AggregateError | seroval.Feature.BigIntTypedArray;
|
|
119
|
-
const serializeOnlyDisabledFeatures = () => process.env.NODE_ENV === "development" ? 0 : seroval.Feature.ErrorPrototypeStack;
|
|
120
|
-
const HYDRATION_GLOBAL = "_$HY.r";
|
|
121
|
-
function createSerializer(options) {
|
|
122
|
-
return new seroval.Serializer({
|
|
123
|
-
...options,
|
|
124
|
-
plugins: resolveSerializerPlugins(options.plugins),
|
|
125
|
-
disabledFeatures: (options.disabledFeatures === undefined ? DEFAULT_DISABLED_FEATURES : options.disabledFeatures) | serializeOnlyDisabledFeatures()
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
function createHydrationSerializer({
|
|
129
|
-
onData,
|
|
130
|
-
onDone,
|
|
131
|
-
scopeId,
|
|
132
|
-
onError,
|
|
133
|
-
plugins
|
|
134
|
-
}) {
|
|
135
|
-
return createSerializer({
|
|
136
|
-
scopeId,
|
|
137
|
-
plugins,
|
|
138
|
-
globalIdentifier: HYDRATION_GLOBAL,
|
|
139
|
-
onData,
|
|
140
|
-
onDone,
|
|
141
|
-
onError
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
function getLocalHeaderScript(id) {
|
|
145
|
-
return seroval.getCrossReferenceHeader(id) + ";";
|
|
146
|
-
}
|
|
147
|
-
function serializeJSON(value, {
|
|
148
|
-
onParse,
|
|
149
|
-
onDone,
|
|
150
|
-
onError,
|
|
151
|
-
...codecOptions
|
|
152
|
-
}) {
|
|
153
|
-
const resolved = resolveCodecOptions(codecOptions);
|
|
154
|
-
return seroval.toCrossJSONStream(value, {
|
|
155
|
-
onParse,
|
|
156
|
-
onDone,
|
|
157
|
-
onError,
|
|
158
|
-
...resolved,
|
|
159
|
-
disabledFeatures: resolved.disabledFeatures | serializeOnlyDisabledFeatures()
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
function createJSONSerializer({
|
|
163
|
-
onData,
|
|
164
|
-
onDone,
|
|
165
|
-
onError,
|
|
166
|
-
plugins,
|
|
167
|
-
disabledFeatures,
|
|
168
|
-
depthLimit
|
|
169
|
-
}) {
|
|
170
|
-
const resolved = resolveCodecOptions({
|
|
171
|
-
plugins,
|
|
172
|
-
disabledFeatures,
|
|
173
|
-
depthLimit
|
|
174
|
-
});
|
|
175
|
-
const refs = new Map();
|
|
176
|
-
const cancels = new Set();
|
|
177
|
-
let pendingWrites = 0;
|
|
178
|
-
let flushed = false;
|
|
179
|
-
let done = false;
|
|
180
|
-
const maybeDone = () => {
|
|
181
|
-
if (flushed && pendingWrites === 0 && !done) {
|
|
182
|
-
done = true;
|
|
183
|
-
onDone && onDone();
|
|
184
|
-
}
|
|
185
|
-
};
|
|
186
|
-
return {
|
|
187
|
-
write(key, value) {
|
|
188
|
-
if (flushed) return;
|
|
189
|
-
pendingWrites++;
|
|
190
|
-
let settled = false;
|
|
191
|
-
let cancel = null;
|
|
192
|
-
const stream = seroval.toCrossJSONStream(value, {
|
|
193
|
-
refs,
|
|
194
|
-
plugins: resolved.plugins,
|
|
195
|
-
disabledFeatures: resolved.disabledFeatures | serializeOnlyDisabledFeatures(),
|
|
196
|
-
onParse(node, initial) {
|
|
197
|
-
onData({
|
|
198
|
-
key,
|
|
199
|
-
node,
|
|
200
|
-
initial
|
|
201
|
-
});
|
|
202
|
-
},
|
|
203
|
-
onError,
|
|
204
|
-
onDone() {
|
|
205
|
-
settled = true;
|
|
206
|
-
if (cancel) cancels.delete(cancel);
|
|
207
|
-
pendingWrites--;
|
|
208
|
-
maybeDone();
|
|
209
|
-
}
|
|
210
|
-
});
|
|
211
|
-
if (!settled) {
|
|
212
|
-
cancel = stream;
|
|
213
|
-
cancels.add(cancel);
|
|
214
|
-
}
|
|
215
|
-
},
|
|
216
|
-
flush() {
|
|
217
|
-
flushed = true;
|
|
218
|
-
maybeDone();
|
|
219
|
-
},
|
|
220
|
-
close() {
|
|
221
|
-
flushed = true;
|
|
222
|
-
for (const cancel of cancels) cancel();
|
|
223
|
-
cancels.clear();
|
|
224
|
-
}
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
|
|
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
|
-
exports.DEFAULT_WEB_PLUGINS = DEFAULT_WEB_PLUGINS;
|
|
237
|
-
exports.createHydrationSerializer = createHydrationSerializer;
|
|
238
|
-
exports.createJSONDataTable = createJSONDataTable;
|
|
239
|
-
exports.createJSONDeserializer = createJSONDeserializer;
|
|
240
|
-
exports.createJSONSerializer = createJSONSerializer;
|
|
241
|
-
exports.createSerializer = createSerializer;
|
|
242
|
-
exports.getLocalHeaderScript = getLocalHeaderScript;
|
|
243
|
-
exports.resolveSerializerPlugins = resolveSerializerPlugins;
|
|
244
|
-
exports.serializeJSON = serializeJSON;
|
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
// Serialization surface (published as `@solidjs/web/serialization`): the
|
|
2
|
-
// runtime's Seroval machinery, exposed for the runtime's own entries and
|
|
3
|
-
// for integrations building transports on the same codec. This is
|
|
4
|
-
// INTEGRATION-FACING plumbing, not application API — it is exempt from the
|
|
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.cjs";
|
|
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.cjs";
|
|
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
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Options for `createSerializer`.
|
|
62
|
-
*
|
|
63
|
-
* Integration-facing; may change (see the entry banner).
|
|
64
|
-
*/
|
|
65
|
-
export interface WebSerializerOptions {
|
|
66
|
-
/** Name of the global object the emitted scripts write resolved values into. */
|
|
67
|
-
globalIdentifier: string;
|
|
68
|
-
/** Cross-reference scope id, for isolating multiple streams on one page. */
|
|
69
|
-
scopeId?: string;
|
|
70
|
-
/**
|
|
71
|
-
* Seroval feature bitflags to exclude from output. Defaults to disabling
|
|
72
|
-
* post-ES2017 features (AggregateError, BigInt typed arrays). Outside
|
|
73
|
-
* development, `Error.prototype.stack` is additionally stripped on top of
|
|
74
|
-
* any override — serialized stacks leak server paths to the client.
|
|
75
|
-
*/
|
|
76
|
-
disabledFeatures?: number;
|
|
77
|
-
/** Extra plugins, composed ahead of `DEFAULT_WEB_PLUGINS`. */
|
|
78
|
-
plugins?: SerializerPlugin[];
|
|
79
|
-
/** Receives each emitted script chunk. */
|
|
80
|
-
onData: (result: string) => void;
|
|
81
|
-
onError?: (error: unknown) => void;
|
|
82
|
-
/** Fires once all async values have settled. */
|
|
83
|
-
onDone?: () => void;
|
|
84
|
-
}
|
|
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
|
-
/**
|
|
99
|
-
* Options for `createHydrationSerializer` — `WebSerializerOptions` minus
|
|
100
|
-
* the knobs hydration pins (`globalIdentifier`, `disabledFeatures`).
|
|
101
|
-
* @internal
|
|
102
|
-
*/
|
|
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
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Options for `serializeJSON`.
|
|
132
|
-
*
|
|
133
|
-
* Integration-facing; may change (see the entry banner).
|
|
134
|
-
*/
|
|
135
|
-
export interface JSONSerializeOptions extends JSONCodecOptions {
|
|
136
|
-
/**
|
|
137
|
-
* Receives each serialized node; `initial` is true for the first chunk
|
|
138
|
-
* (the source value itself). Async values produce additional chunks as
|
|
139
|
-
* they resolve.
|
|
140
|
-
*/
|
|
141
|
-
onParse: (node: SerovalNode, initial: boolean) => void;
|
|
142
|
-
onError?: (error: unknown) => void;
|
|
143
|
-
/** Fires once all async values have settled. */
|
|
144
|
-
onDone?: () => void;
|
|
145
|
-
}
|
|
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
|
-
/** Options for `createJSONSerializer`. */
|
|
159
|
-
export interface JSONSerializerOptions extends JSONCodecOptions {
|
|
160
|
-
/**
|
|
161
|
-
* Receives each keyed record — `initial` is true for a key's first node
|
|
162
|
-
* (the written value itself); async values patch through later records
|
|
163
|
-
* under the same key. The decoding peer is `createJSONDataTable`.
|
|
164
|
-
*/
|
|
165
|
-
onData: (record: { key: string; node: SerovalNode; initial: boolean }) => void;
|
|
166
|
-
onError?: (error: unknown) => void;
|
|
167
|
-
/** Fires once `flush()` has been called and every pending value settled. */
|
|
168
|
-
onDone?: () => void;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* The keyed, streaming encoder of the eval-free JSON codec — the render
|
|
173
|
-
* stream's data serializer (frames default to it). Each `write(key, value)`
|
|
174
|
-
* shares one reference space, so cross-record identity holds; `flush()`
|
|
175
|
-
* marks the write set complete (writes after it are dropped, mirroring the
|
|
176
|
-
* hydration serializer); `close()` aborts pending async serialization.
|
|
177
|
-
*/
|
|
178
|
-
export function createJSONSerializer(options: JSONSerializerOptions): {
|
|
179
|
-
write(key: string, value: unknown): void;
|
|
180
|
-
flush(): void;
|
|
181
|
-
close(): void;
|
|
182
|
-
};
|