@solidjs/web 2.0.0-rc.7 → 2.0.0-rc.8
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 +15 -2
- package/dist/server.js +15 -2
- package/dist/web.dev.js +41 -9
- package/dist/web.js +39 -8
- package/dist/{web.cjs → web.observe.js} +137 -239
- package/frames/dist/server.dev.js +19 -0
- package/frames/dist/server.js +19 -0
- package/frames/package.json +6 -24
- package/package.json +81 -314
- package/serialization/decode/package.json +3 -9
- package/serialization/package.json +3 -9
- package/serialization/types/serializer-decode.d.ts +49 -2
- package/server-functions/dist/server.dev.js +28 -10
- package/server-functions/dist/server.js +28 -10
- package/server-functions/package.json +6 -24
- package/server-functions/rich-args/package.json +3 -9
- package/storage/package.json +3 -9
- package/types/client.d.ts +17 -0
- package/types/frames/serializer-decode.d.ts +49 -2
- package/types/serializer-decode.d.ts +49 -2
- package/types/server-functions/server.d.ts +27 -4
- package/types/server.d.ts +1 -1
- package/dist/server.cjs +0 -3708
- package/dist/server.dev.cjs +0 -3794
- package/dist/web.dev.cjs +0 -2285
- package/frames/dist/client.cjs +0 -2043
- package/frames/dist/client.dev.cjs +0 -2063
- package/frames/dist/server.cjs +0 -4542
- package/frames/dist/server.dev.cjs +0 -4584
- package/serialization/dist/decode.cjs +0 -155
- package/serialization/dist/serialization.cjs +0 -275
- package/serialization/types-cjs/index.d.cts +0 -101
- package/serialization/types-cjs/package.json +0 -3
- package/serialization/types-cjs/serializer-decode.d.cts +0 -172
- package/serialization/types-cjs/serializer.d.cts +0 -101
- package/server-functions/dist/client.cjs +0 -1069
- package/server-functions/dist/rich-args.cjs +0 -11
- package/server-functions/dist/server.cjs +0 -2381
- package/server-functions/dist/server.dev.cjs +0 -2409
- package/storage/dist/storage.cjs +0 -12
- package/storage/types-cjs/index.d.cts +0 -28
- package/storage/types-cjs/package.json +0 -3
- package/types-cjs/client.d.cts +0 -197
- package/types-cjs/constants.d.cts +0 -20
- package/types-cjs/cookies.d.cts +0 -41
- package/types-cjs/frames/client.d.cts +0 -36
- package/types-cjs/frames/frame-client.d.cts +0 -370
- package/types-cjs/frames/frame-container-plugin.d.cts +0 -71
- package/types-cjs/frames/frame-sink.d.cts +0 -92
- package/types-cjs/frames/frame-transport.d.cts +0 -189
- package/types-cjs/frames/serializer-decode.d.cts +0 -172
- package/types-cjs/frames/serializer.d.cts +0 -101
- package/types-cjs/frames/server.d.cts +0 -52
- package/types-cjs/head.d.cts +0 -19
- package/types-cjs/index.d.cts +0 -191
- package/types-cjs/index.server.d.cts +0 -147
- package/types-cjs/jsx-properties.d.cts +0 -93
- package/types-cjs/jsx.d.cts +0 -4146
- package/types-cjs/package.json +0 -3
- package/types-cjs/reconcile.d.cts +0 -1
- package/types-cjs/render.d.cts +0 -6
- package/types-cjs/response.d.cts +0 -81
- package/types-cjs/serializer-decode.d.cts +0 -172
- package/types-cjs/serializer.d.cts +0 -101
- package/types-cjs/server-functions/client.d.cts +0 -184
- package/types-cjs/server-functions/flash.d.cts +0 -36
- package/types-cjs/server-functions/registry.d.cts +0 -100
- package/types-cjs/server-functions/rich-args.d.cts +0 -1
- package/types-cjs/server-functions/server.d.cts +0 -546
- package/types-cjs/server-functions/shared.d.cts +0 -283
- package/types-cjs/server-mock.d.cts +0 -337
- package/types-cjs/server.d.cts +0 -408
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var seroval = require('seroval');
|
|
4
|
-
var web = require('seroval-plugins/web');
|
|
5
|
-
|
|
6
|
-
const STATE = Symbol.for("solid.container-trace-state");
|
|
7
|
-
const state = globalThis[STATE] || (globalThis[STATE] = {
|
|
8
|
-
materialized: new WeakMap(),
|
|
9
|
-
materializedValues: new WeakSet()
|
|
10
|
-
});
|
|
11
|
-
function setContainerTraceStreamMint(fn) {
|
|
12
|
-
state.streamOf = fn;
|
|
13
|
-
}
|
|
14
|
-
const TRACE = Symbol.for("solid.container-trace");
|
|
15
|
-
function materialize(marker) {
|
|
16
|
-
let value = state.materialized.get(marker.$tr);
|
|
17
|
-
if (value === undefined) {
|
|
18
|
-
value = state.materializeTrace(marker);
|
|
19
|
-
state.materialized.set(marker.$tr, value);
|
|
20
|
-
if (value !== null && typeof value === "object") state.materializedValues.add(value);
|
|
21
|
-
}
|
|
22
|
-
return value;
|
|
23
|
-
}
|
|
24
|
-
function parseTrace(value, ctx) {
|
|
25
|
-
const trace = value[TRACE];
|
|
26
|
-
const sub = trace.subscribe();
|
|
27
|
-
return {
|
|
28
|
-
a: trace.array ? 1 : 0,
|
|
29
|
-
i: ctx.parse(state.streamOf ? state.streamOf(sub) : sub)
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
const ContainerTracePlugin = {
|
|
33
|
-
tag: "solid/container-trace",
|
|
34
|
-
test(value) {
|
|
35
|
-
return value != null && typeof value === "object" && TRACE in value;
|
|
36
|
-
},
|
|
37
|
-
parse: {
|
|
38
|
-
sync() {
|
|
39
|
-
throw new Error("A reactive container can only be serialized by a streaming serializer.");
|
|
40
|
-
},
|
|
41
|
-
async async(value, ctx) {
|
|
42
|
-
const trace = value[TRACE];
|
|
43
|
-
const sub = trace.subscribe();
|
|
44
|
-
return {
|
|
45
|
-
a: trace.array ? 1 : 0,
|
|
46
|
-
i: await ctx.parse(state.streamOf ? state.streamOf(sub) : sub)
|
|
47
|
-
};
|
|
48
|
-
},
|
|
49
|
-
stream: parseTrace
|
|
50
|
-
},
|
|
51
|
-
serialize(node, ctx) {
|
|
52
|
-
return "{$tr:" + ctx.serialize(node.i) + ",$ta:" + node.a + "}";
|
|
53
|
-
},
|
|
54
|
-
deserialize(node, ctx) {
|
|
55
|
-
const iterable = ctx.deserialize(node.i);
|
|
56
|
-
const marker = {
|
|
57
|
-
$tr: iterable,
|
|
58
|
-
$ta: node.a
|
|
59
|
-
};
|
|
60
|
-
return state.materializeTrace ? materialize(marker) : marker;
|
|
61
|
-
}
|
|
62
|
-
};
|
|
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
|
-
});
|
|
76
|
-
const DEFAULT_WEB_PLUGINS = Object.freeze([web.AbortSignalPlugin,
|
|
77
|
-
web.CustomEventPlugin, web.DOMExceptionPlugin, web.EventPlugin,
|
|
78
|
-
web.FormDataPlugin, web.HeadersPlugin, web.ReadableStreamPlugin, web.RequestPlugin, web.ResponsePlugin, web.URLSearchParamsPlugin, web.URLPlugin,
|
|
79
|
-
ContainerTracePlugin]);
|
|
80
|
-
function resolveSerializerPlugins(customPlugins) {
|
|
81
|
-
return customPlugins ? [...customPlugins, ...DEFAULT_WEB_PLUGINS] : [...DEFAULT_WEB_PLUGINS];
|
|
82
|
-
}
|
|
83
|
-
const JSON_CODEC_DISABLED_FEATURES = seroval.Feature.RegExp;
|
|
84
|
-
const JSON_CODEC_DEPTH_LIMIT = 64;
|
|
85
|
-
function resolveCodecOptions({
|
|
86
|
-
plugins,
|
|
87
|
-
disabledFeatures,
|
|
88
|
-
depthLimit,
|
|
89
|
-
serializeErrorStacks
|
|
90
|
-
} = {}) {
|
|
91
|
-
return {
|
|
92
|
-
plugins: resolveSerializerPlugins(plugins),
|
|
93
|
-
disabledFeatures: disabledFeatures === undefined ? JSON_CODEC_DISABLED_FEATURES : disabledFeatures,
|
|
94
|
-
depthLimit: depthLimit === undefined ? JSON_CODEC_DEPTH_LIMIT : depthLimit,
|
|
95
|
-
serializeErrorStacks
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
function createJSONDeserializer(options) {
|
|
99
|
-
const refs = new Map();
|
|
100
|
-
const resolved = resolveCodecOptions(options);
|
|
101
|
-
let owned = 0;
|
|
102
|
-
function ownDecodedPromises() {
|
|
103
|
-
if (refs.size === owned) return;
|
|
104
|
-
let index = 0;
|
|
105
|
-
for (const value of refs.values()) {
|
|
106
|
-
if (index++ < owned) continue;
|
|
107
|
-
if (value instanceof Promise) value.then(undefined, () => {});
|
|
108
|
-
}
|
|
109
|
-
owned = refs.size;
|
|
110
|
-
}
|
|
111
|
-
function deserializeJSONChunk(node) {
|
|
112
|
-
try {
|
|
113
|
-
return seroval.fromCrossJSON(node, {
|
|
114
|
-
refs,
|
|
115
|
-
...resolved
|
|
116
|
-
});
|
|
117
|
-
} finally {
|
|
118
|
-
ownDecodedPromises();
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
deserializeJSONChunk.abort = function abort(error) {
|
|
122
|
-
for (const value of refs.values()) {
|
|
123
|
-
if (value === null || typeof value !== "object") continue;
|
|
124
|
-
if (value.__SEROVAL_STREAM__) {
|
|
125
|
-
value.throw(error);
|
|
126
|
-
} else if (typeof value.s === "function" && typeof value.f === "function" && value.p instanceof Promise) {
|
|
127
|
-
value.p.then(undefined, () => {});
|
|
128
|
-
value.f(error);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
return deserializeJSONChunk;
|
|
133
|
-
}
|
|
134
|
-
function createJSONDataTable(options) {
|
|
135
|
-
const deserialize = createJSONDeserializer(options);
|
|
136
|
-
const table = new Map();
|
|
137
|
-
return {
|
|
138
|
-
apply(record) {
|
|
139
|
-
const value = deserialize(record.node);
|
|
140
|
-
if (record.initial) table.set(record.key, value);
|
|
141
|
-
},
|
|
142
|
-
get(key) {
|
|
143
|
-
return table.get(key);
|
|
144
|
-
},
|
|
145
|
-
resolve(ref) {
|
|
146
|
-
return table.get(ref.$ref);
|
|
147
|
-
}
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
exports.DEFAULT_WEB_PLUGINS = DEFAULT_WEB_PLUGINS;
|
|
152
|
-
exports.createJSONDataTable = createJSONDataTable;
|
|
153
|
-
exports.createJSONDeserializer = createJSONDeserializer;
|
|
154
|
-
exports.resolveCodecOptions = resolveCodecOptions;
|
|
155
|
-
exports.resolveSerializerPlugins = resolveSerializerPlugins;
|
|
@@ -1,275 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var seroval = require('seroval');
|
|
4
|
-
var web = require('seroval-plugins/web');
|
|
5
|
-
|
|
6
|
-
const STATE = Symbol.for("solid.container-trace-state");
|
|
7
|
-
const state = globalThis[STATE] || (globalThis[STATE] = {
|
|
8
|
-
materialized: new WeakMap(),
|
|
9
|
-
materializedValues: new WeakSet()
|
|
10
|
-
});
|
|
11
|
-
function setContainerTraceStreamMint(fn) {
|
|
12
|
-
state.streamOf = fn;
|
|
13
|
-
}
|
|
14
|
-
const TRACE = Symbol.for("solid.container-trace");
|
|
15
|
-
function materialize(marker) {
|
|
16
|
-
let value = state.materialized.get(marker.$tr);
|
|
17
|
-
if (value === undefined) {
|
|
18
|
-
value = state.materializeTrace(marker);
|
|
19
|
-
state.materialized.set(marker.$tr, value);
|
|
20
|
-
if (value !== null && typeof value === "object") state.materializedValues.add(value);
|
|
21
|
-
}
|
|
22
|
-
return value;
|
|
23
|
-
}
|
|
24
|
-
function parseTrace(value, ctx) {
|
|
25
|
-
const trace = value[TRACE];
|
|
26
|
-
const sub = trace.subscribe();
|
|
27
|
-
return {
|
|
28
|
-
a: trace.array ? 1 : 0,
|
|
29
|
-
i: ctx.parse(state.streamOf ? state.streamOf(sub) : sub)
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
const ContainerTracePlugin = {
|
|
33
|
-
tag: "solid/container-trace",
|
|
34
|
-
test(value) {
|
|
35
|
-
return value != null && typeof value === "object" && TRACE in value;
|
|
36
|
-
},
|
|
37
|
-
parse: {
|
|
38
|
-
sync() {
|
|
39
|
-
throw new Error("A reactive container can only be serialized by a streaming serializer.");
|
|
40
|
-
},
|
|
41
|
-
async async(value, ctx) {
|
|
42
|
-
const trace = value[TRACE];
|
|
43
|
-
const sub = trace.subscribe();
|
|
44
|
-
return {
|
|
45
|
-
a: trace.array ? 1 : 0,
|
|
46
|
-
i: await ctx.parse(state.streamOf ? state.streamOf(sub) : sub)
|
|
47
|
-
};
|
|
48
|
-
},
|
|
49
|
-
stream: parseTrace
|
|
50
|
-
},
|
|
51
|
-
serialize(node, ctx) {
|
|
52
|
-
return "{$tr:" + ctx.serialize(node.i) + ",$ta:" + node.a + "}";
|
|
53
|
-
},
|
|
54
|
-
deserialize(node, ctx) {
|
|
55
|
-
const iterable = ctx.deserialize(node.i);
|
|
56
|
-
const marker = {
|
|
57
|
-
$tr: iterable,
|
|
58
|
-
$ta: node.a
|
|
59
|
-
};
|
|
60
|
-
return state.materializeTrace ? materialize(marker) : marker;
|
|
61
|
-
}
|
|
62
|
-
};
|
|
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
|
-
});
|
|
76
|
-
const DEFAULT_WEB_PLUGINS = Object.freeze([web.AbortSignalPlugin,
|
|
77
|
-
web.CustomEventPlugin, web.DOMExceptionPlugin, web.EventPlugin,
|
|
78
|
-
web.FormDataPlugin, web.HeadersPlugin, web.ReadableStreamPlugin, web.RequestPlugin, web.ResponsePlugin, web.URLSearchParamsPlugin, web.URLPlugin,
|
|
79
|
-
ContainerTracePlugin]);
|
|
80
|
-
function resolveSerializerPlugins(customPlugins) {
|
|
81
|
-
return customPlugins ? [...customPlugins, ...DEFAULT_WEB_PLUGINS] : [...DEFAULT_WEB_PLUGINS];
|
|
82
|
-
}
|
|
83
|
-
const JSON_CODEC_DISABLED_FEATURES = seroval.Feature.RegExp;
|
|
84
|
-
const JSON_CODEC_DEPTH_LIMIT = 64;
|
|
85
|
-
function resolveCodecOptions({
|
|
86
|
-
plugins,
|
|
87
|
-
disabledFeatures,
|
|
88
|
-
depthLimit,
|
|
89
|
-
serializeErrorStacks
|
|
90
|
-
} = {}) {
|
|
91
|
-
return {
|
|
92
|
-
plugins: resolveSerializerPlugins(plugins),
|
|
93
|
-
disabledFeatures: disabledFeatures === undefined ? JSON_CODEC_DISABLED_FEATURES : disabledFeatures,
|
|
94
|
-
depthLimit: depthLimit === undefined ? JSON_CODEC_DEPTH_LIMIT : depthLimit,
|
|
95
|
-
serializeErrorStacks
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
function createJSONDeserializer(options) {
|
|
99
|
-
const refs = new Map();
|
|
100
|
-
const resolved = resolveCodecOptions(options);
|
|
101
|
-
let owned = 0;
|
|
102
|
-
function ownDecodedPromises() {
|
|
103
|
-
if (refs.size === owned) return;
|
|
104
|
-
let index = 0;
|
|
105
|
-
for (const value of refs.values()) {
|
|
106
|
-
if (index++ < owned) continue;
|
|
107
|
-
if (value instanceof Promise) value.then(undefined, () => {});
|
|
108
|
-
}
|
|
109
|
-
owned = refs.size;
|
|
110
|
-
}
|
|
111
|
-
function deserializeJSONChunk(node) {
|
|
112
|
-
try {
|
|
113
|
-
return seroval.fromCrossJSON(node, {
|
|
114
|
-
refs,
|
|
115
|
-
...resolved
|
|
116
|
-
});
|
|
117
|
-
} finally {
|
|
118
|
-
ownDecodedPromises();
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
deserializeJSONChunk.abort = function abort(error) {
|
|
122
|
-
for (const value of refs.values()) {
|
|
123
|
-
if (value === null || typeof value !== "object") continue;
|
|
124
|
-
if (value.__SEROVAL_STREAM__) {
|
|
125
|
-
value.throw(error);
|
|
126
|
-
} else if (typeof value.s === "function" && typeof value.f === "function" && value.p instanceof Promise) {
|
|
127
|
-
value.p.then(undefined, () => {});
|
|
128
|
-
value.f(error);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
return deserializeJSONChunk;
|
|
133
|
-
}
|
|
134
|
-
function createJSONDataTable(options) {
|
|
135
|
-
const deserialize = createJSONDeserializer(options);
|
|
136
|
-
const table = new Map();
|
|
137
|
-
return {
|
|
138
|
-
apply(record) {
|
|
139
|
-
const value = deserialize(record.node);
|
|
140
|
-
if (record.initial) table.set(record.key, value);
|
|
141
|
-
},
|
|
142
|
-
get(key) {
|
|
143
|
-
return table.get(key);
|
|
144
|
-
},
|
|
145
|
-
resolve(ref) {
|
|
146
|
-
return table.get(ref.$ref);
|
|
147
|
-
}
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
const DEFAULT_DISABLED_FEATURES = seroval.Feature.AggregateError | seroval.Feature.BigIntTypedArray;
|
|
152
|
-
const serializeOnlyDisabledFeatures = serializeErrorStacks => (serializeErrorStacks === undefined ? process.env.NODE_ENV === "development" : serializeErrorStacks) ? 0 : seroval.Feature.ErrorPrototypeStack;
|
|
153
|
-
const HYDRATION_GLOBAL = "_$HY.r";
|
|
154
|
-
const createPlugin = seroval.createPlugin;
|
|
155
|
-
const OpaqueReference = seroval.OpaqueReference;
|
|
156
|
-
function createSerializer(options) {
|
|
157
|
-
return new seroval.Serializer({
|
|
158
|
-
...options,
|
|
159
|
-
plugins: resolveSerializerPlugins(options.plugins),
|
|
160
|
-
disabledFeatures: (options.disabledFeatures === undefined ? DEFAULT_DISABLED_FEATURES : options.disabledFeatures) | serializeOnlyDisabledFeatures(options.serializeErrorStacks)
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
function createHydrationSerializer({
|
|
164
|
-
onData,
|
|
165
|
-
onDone,
|
|
166
|
-
scopeId,
|
|
167
|
-
onError,
|
|
168
|
-
plugins
|
|
169
|
-
}) {
|
|
170
|
-
return createSerializer({
|
|
171
|
-
scopeId,
|
|
172
|
-
plugins,
|
|
173
|
-
globalIdentifier: HYDRATION_GLOBAL,
|
|
174
|
-
onData,
|
|
175
|
-
onDone,
|
|
176
|
-
onError
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
function getLocalHeaderScript(id) {
|
|
180
|
-
return seroval.getCrossReferenceHeader(id) + ";";
|
|
181
|
-
}
|
|
182
|
-
function serializeJSON(value, {
|
|
183
|
-
onParse,
|
|
184
|
-
onDone,
|
|
185
|
-
onError,
|
|
186
|
-
...codecOptions
|
|
187
|
-
}) {
|
|
188
|
-
const resolved = resolveCodecOptions(codecOptions);
|
|
189
|
-
return seroval.toCrossJSONStream(value, {
|
|
190
|
-
onParse,
|
|
191
|
-
onDone,
|
|
192
|
-
onError,
|
|
193
|
-
...resolved,
|
|
194
|
-
disabledFeatures: resolved.disabledFeatures | serializeOnlyDisabledFeatures(resolved.serializeErrorStacks)
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
function createJSONSerializer({
|
|
198
|
-
onData,
|
|
199
|
-
onDone,
|
|
200
|
-
onError,
|
|
201
|
-
plugins,
|
|
202
|
-
disabledFeatures,
|
|
203
|
-
depthLimit,
|
|
204
|
-
serializeErrorStacks
|
|
205
|
-
}) {
|
|
206
|
-
const resolved = resolveCodecOptions({
|
|
207
|
-
plugins,
|
|
208
|
-
disabledFeatures,
|
|
209
|
-
depthLimit,
|
|
210
|
-
serializeErrorStacks
|
|
211
|
-
});
|
|
212
|
-
const refs = new Map();
|
|
213
|
-
const cancels = new Set();
|
|
214
|
-
let pendingWrites = 0;
|
|
215
|
-
let flushed = false;
|
|
216
|
-
let done = false;
|
|
217
|
-
const maybeDone = () => {
|
|
218
|
-
if (flushed && pendingWrites === 0 && !done) {
|
|
219
|
-
done = true;
|
|
220
|
-
onDone && onDone();
|
|
221
|
-
}
|
|
222
|
-
};
|
|
223
|
-
return {
|
|
224
|
-
write(key, value) {
|
|
225
|
-
if (flushed) return;
|
|
226
|
-
pendingWrites++;
|
|
227
|
-
let settled = false;
|
|
228
|
-
let cancel = null;
|
|
229
|
-
const stream = seroval.toCrossJSONStream(value, {
|
|
230
|
-
refs,
|
|
231
|
-
plugins: resolved.plugins,
|
|
232
|
-
disabledFeatures: resolved.disabledFeatures | serializeOnlyDisabledFeatures(resolved.serializeErrorStacks),
|
|
233
|
-
onParse(node, initial) {
|
|
234
|
-
onData({
|
|
235
|
-
key,
|
|
236
|
-
node,
|
|
237
|
-
initial
|
|
238
|
-
});
|
|
239
|
-
},
|
|
240
|
-
onError,
|
|
241
|
-
onDone() {
|
|
242
|
-
settled = true;
|
|
243
|
-
if (cancel) cancels.delete(cancel);
|
|
244
|
-
pendingWrites--;
|
|
245
|
-
maybeDone();
|
|
246
|
-
}
|
|
247
|
-
});
|
|
248
|
-
if (!settled) {
|
|
249
|
-
cancel = stream;
|
|
250
|
-
cancels.add(cancel);
|
|
251
|
-
}
|
|
252
|
-
},
|
|
253
|
-
flush() {
|
|
254
|
-
flushed = true;
|
|
255
|
-
maybeDone();
|
|
256
|
-
},
|
|
257
|
-
close() {
|
|
258
|
-
flushed = true;
|
|
259
|
-
for (const cancel of cancels) cancel();
|
|
260
|
-
cancels.clear();
|
|
261
|
-
}
|
|
262
|
-
};
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
exports.DEFAULT_WEB_PLUGINS = DEFAULT_WEB_PLUGINS;
|
|
266
|
-
exports.OpaqueReference = OpaqueReference;
|
|
267
|
-
exports.createHydrationSerializer = createHydrationSerializer;
|
|
268
|
-
exports.createJSONDataTable = createJSONDataTable;
|
|
269
|
-
exports.createJSONDeserializer = createJSONDeserializer;
|
|
270
|
-
exports.createJSONSerializer = createJSONSerializer;
|
|
271
|
-
exports.createPlugin = createPlugin;
|
|
272
|
-
exports.createSerializer = createSerializer;
|
|
273
|
-
exports.getLocalHeaderScript = getLocalHeaderScript;
|
|
274
|
-
exports.resolveSerializerPlugins = resolveSerializerPlugins;
|
|
275
|
-
exports.serializeJSON = serializeJSON;
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { Serializer } from "seroval";
|
|
2
|
-
import type { JSONCodecOptions, PluginInfo, SerializerPlugin, SerovalNode } from "./serializer-decode.cjs";
|
|
3
|
-
export { DEFAULT_WEB_PLUGINS, createJSONDataTable, createJSONDeserializer, resolveSerializerPlugins } from "./serializer-decode.cjs";
|
|
4
|
-
export type * from "./serializer-decode.cjs";
|
|
5
|
-
/**
|
|
6
|
-
* Options for `createSerializer`.
|
|
7
|
-
*
|
|
8
|
-
* Integration-facing; may change (see the entry banner).
|
|
9
|
-
*/
|
|
10
|
-
export interface WebSerializerOptions {
|
|
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
|
-
/**
|
|
23
|
-
* Whether serialized `Error`s carry their `.stack`. Defaults to
|
|
24
|
-
* `NODE_ENV === "development"`; set `false` to pin production disclosure
|
|
25
|
-
* to the deployment rather than the ambient variable (#3152 — see
|
|
26
|
-
* `JSONCodecOptions.serializeErrorStacks`).
|
|
27
|
-
*/
|
|
28
|
-
serializeErrorStacks?: boolean;
|
|
29
|
-
/** Extra plugins, composed ahead of `DEFAULT_WEB_PLUGINS`. */
|
|
30
|
-
plugins?: SerializerPlugin[];
|
|
31
|
-
/** Receives each emitted script chunk. */
|
|
32
|
-
onData: (result: string) => void;
|
|
33
|
-
onError?: (error: unknown) => void;
|
|
34
|
-
/** Fires once all async values have settled. */
|
|
35
|
-
onDone?: () => void;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Options for `createHydrationSerializer` — `WebSerializerOptions` minus
|
|
39
|
-
* the knobs hydration pins (`globalIdentifier`, `disabledFeatures`).
|
|
40
|
-
* @internal
|
|
41
|
-
*/
|
|
42
|
-
export type HydrationSerializerOptions = Omit<WebSerializerOptions, "globalIdentifier" | "disabledFeatures">;
|
|
43
|
-
/**
|
|
44
|
-
* Options for `serializeJSON`.
|
|
45
|
-
*
|
|
46
|
-
* Integration-facing; may change (see the entry banner).
|
|
47
|
-
*/
|
|
48
|
-
export interface JSONSerializeOptions extends JSONCodecOptions {
|
|
49
|
-
/**
|
|
50
|
-
* Receives each serialized node; `initial` is true for the first chunk
|
|
51
|
-
* (the source value itself). Async values produce additional chunks as
|
|
52
|
-
* they resolve.
|
|
53
|
-
*/
|
|
54
|
-
onParse: (node: SerovalNode, initial: boolean) => void;
|
|
55
|
-
onError?: (error: unknown) => void;
|
|
56
|
-
/** Fires once all async values have settled. */
|
|
57
|
-
onDone?: () => void;
|
|
58
|
-
}
|
|
59
|
-
/** Options for `createJSONSerializer`. */
|
|
60
|
-
export interface JSONSerializerOptions extends JSONCodecOptions {
|
|
61
|
-
/**
|
|
62
|
-
* Receives each keyed record — `initial` is true for a key's first node
|
|
63
|
-
* (the written value itself); async values patch through later records
|
|
64
|
-
* under the same key. The decoding peer is `createJSONDataTable`.
|
|
65
|
-
*/
|
|
66
|
-
onData: (record: {
|
|
67
|
-
key: string;
|
|
68
|
-
node: SerovalNode;
|
|
69
|
-
initial: boolean;
|
|
70
|
-
}) => void;
|
|
71
|
-
onError?: (error: unknown) => void;
|
|
72
|
-
/** Fires once `flush()` has been called and every pending value settled. */
|
|
73
|
-
onDone?: () => void;
|
|
74
|
-
}
|
|
75
|
-
export declare const createPlugin: <Value, Info extends PluginInfo>(plugin: SerializerPlugin<Value, Info>) => SerializerPlugin<Value, Info>;
|
|
76
|
-
export interface OpaqueReference<V = unknown, R = undefined> {
|
|
77
|
-
readonly value: V;
|
|
78
|
-
readonly replacement?: R;
|
|
79
|
-
}
|
|
80
|
-
export declare const OpaqueReference: {
|
|
81
|
-
new <V, R = undefined>(value: V, replacement?: R): OpaqueReference<V, R>;
|
|
82
|
-
};
|
|
83
|
-
/**
|
|
84
|
-
* Creates a streaming Seroval serializer preconfigured with the web plugin
|
|
85
|
-
* set and the default feature policy. Emits JavaScript chunks (through
|
|
86
|
-
* `onData`) that reconstruct the values under `globalIdentifier` when
|
|
87
|
-
* evaluated — the script-injection form of serialization renderers build
|
|
88
|
-
* on. For a JSON-based wire codec (no eval on the receiving side), use
|
|
89
|
-
* `serializeJSON` / `createJSONDeserializer` instead.
|
|
90
|
-
*
|
|
91
|
-
* Integration-facing; may change (see the entry banner).
|
|
92
|
-
*/
|
|
93
|
-
export declare function createSerializer(options: WebSerializerOptions): Serializer;
|
|
94
|
-
export declare function createHydrationSerializer(options: HydrationSerializerOptions): Serializer;
|
|
95
|
-
export declare function getLocalHeaderScript(id?: string): string;
|
|
96
|
-
export declare function serializeJSON(value: unknown, options: JSONSerializeOptions): () => void;
|
|
97
|
-
export declare function createJSONSerializer(options: JSONSerializerOptions): {
|
|
98
|
-
write(key: string, value: unknown): void;
|
|
99
|
-
flush(): void;
|
|
100
|
-
close(): void;
|
|
101
|
-
};
|