@solidjs/web 2.0.0-rc.2 → 2.0.0-rc.20
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/README.md +1 -1
- package/dist/server.dev.js +5065 -0
- package/dist/server.js +1757 -355
- package/dist/{server.cjs → server.observe.js} +1951 -558
- package/dist/{dev.cjs → web.dev.js} +945 -550
- package/dist/web.js +635 -332
- package/dist/{dev.js → web.observe.js} +688 -403
- package/frames/dist/assets.js +92 -0
- package/frames/dist/client.dev.js +1296 -1198
- package/frames/dist/client.js +1128 -1191
- package/frames/dist/client.observe.js +2041 -0
- package/frames/dist/regions.js +171 -0
- package/frames/dist/server.dev.js +2549 -0
- package/frames/dist/server.js +1688 -3005
- package/frames/dist/server.observe.js +2548 -0
- package/frames/dist/trace.js +45 -0
- package/frames/dist/wire.js +594 -0
- package/frames/package.json +2 -25
- package/package.json +244 -256
- package/performance-tracks/dist/performance-tracks.dev.js +679 -0
- package/performance-tracks/dist/performance-tracks.js +6 -0
- package/performance-tracks/dist/performance-tracks.observe.js +667 -0
- package/performance-tracks/package.json +7 -0
- package/performance-tracks/types/index.d.ts +69 -0
- package/serialization/decode/package.json +2 -15
- package/serialization/dist/decode.js +121 -25
- package/serialization/dist/serialization.js +242 -88
- package/serialization/package.json +2 -15
- package/serialization/types/index.d.ts +85 -158
- package/serialization/types/serializer-decode.d.ts +173 -114
- package/serialization/types/serializer.d.ts +109 -0
- package/server-functions/dist/client.dev.js +1462 -0
- package/server-functions/dist/client.js +667 -165
- package/server-functions/dist/client.observe.js +1441 -0
- package/server-functions/dist/rich-args.js +84 -1
- package/server-functions/dist/server.dev.js +2714 -297
- package/server-functions/dist/server.js +2595 -271
- package/server-functions/dist/server.observe.js +3594 -0
- package/server-functions/package.json +2 -35
- package/server-functions/rich-args/package.json +2 -15
- package/skills/server-components/SKILL.md +117 -0
- package/storage/package.json +2 -15
- package/types/client.d.ts +342 -288
- package/types/constants.d.ts +22 -0
- package/types/cookies.d.ts +32 -84
- package/types/diagnostics.d.ts +80 -0
- package/types/frames/assets-tier.d.ts +78 -0
- package/types/frames/client.d.ts +40 -1
- package/types/frames/frame-client.d.ts +443 -280
- package/types/frames/frame-container-plugin.d.ts +64 -0
- package/types/frames/frame-morph.d.ts +29 -0
- package/types/frames/frame-sink.d.ts +141 -161
- package/types/frames/frame-transport.d.ts +263 -184
- package/types/frames/regions-tier.d.ts +60 -0
- package/types/frames/serializer-decode.d.ts +241 -0
- package/types/frames/serializer.d.ts +85 -158
- package/types/frames/server.d.ts +2 -2
- package/types/frames/trace-tier.d.ts +2 -0
- package/types/frames/tree-rewrite.d.ts +39 -0
- package/types/frames/wire-tier.d.ts +169 -0
- package/types/head.d.ts +20 -0
- package/types/index.d.ts +98 -81
- package/types/index.server.d.ts +159 -0
- package/types/jsx.d.ts +49 -44
- package/types/observe.d.ts +535 -0
- package/types/reconcile.d.ts +1 -0
- package/types/render.d.ts +11 -0
- package/types/request-error-hook.d.ts +5 -0
- package/types/response.d.ts +95 -147
- package/types/serializer-decode.d.ts +173 -114
- package/types/serializer.d.ts +85 -158
- package/types/server-functions/argument-codec.d.ts +30 -0
- package/types/server-functions/client.d.ts +238 -223
- package/types/server-functions/flash.d.ts +28 -30
- package/types/server-functions/registry.d.ts +105 -0
- package/types/server-functions/rich-args.d.ts +1 -10
- package/types/server-functions/server.d.ts +539 -531
- package/types/server-functions/shared.d.ts +398 -425
- package/types/server-functions/uploads.d.ts +50 -0
- package/types/server-mock.d.ts +120 -13
- package/types/server-observe.d.ts +86 -0
- package/types/server.d.ts +571 -422
- package/types/trace.d.ts +127 -0
- package/LICENSE +0 -21
- package/dist/web.cjs +0 -2033
- package/frames/dist/client.cjs +0 -2002
- package/frames/dist/client.dev.cjs +0 -2022
- package/frames/dist/server.cjs +0 -3877
- package/serialization/dist/decode.cjs +0 -139
- package/serialization/dist/serialization.cjs +0 -261
- 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 -834
- package/server-functions/dist/rich-args.cjs +0 -11
- package/server-functions/dist/server.cjs +0 -1242
- package/server-functions/dist/server.dev.cjs +0 -1242
- 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 -9
- package/types-cjs/client.d.cts +0 -337
- package/types-cjs/cookies.d.cts +0 -93
- package/types-cjs/core.d.cts +0 -9
- package/types-cjs/frames/client.d.cts +0 -36
- package/types-cjs/frames/frame-client.d.cts +0 -356
- 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 -262
- 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 -681
- package/types-cjs/server-functions/shared.d.cts +0 -523
- package/types-cjs/server-mock.d.cts +0 -286
- package/types-cjs/server.d.cts +0 -544
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { OpaqueReference, createPlugin } from 'seroval';
|
|
1
|
+
import { isStream, fromCrossJSON, Feature, createStream, OpaqueReference as OpaqueReference$1, createPlugin as createPlugin$1, Serializer, getCrossReferenceHeader, toCrossJSONStream, crossSerializeStream } 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()
|
|
@@ -10,11 +9,11 @@ const state = globalThis[STATE] || (globalThis[STATE] = {
|
|
|
10
9
|
function setContainerTraceStreamMint(fn) {
|
|
11
10
|
state.streamOf = fn;
|
|
12
11
|
}
|
|
13
|
-
const TRACE = Symbol.for("
|
|
14
|
-
function materialize(marker) {
|
|
12
|
+
const TRACE = Symbol.for("solid.container-trace");
|
|
13
|
+
function materialize(marker, claiming) {
|
|
15
14
|
let value = state.materialized.get(marker.$tr);
|
|
16
15
|
if (value === undefined) {
|
|
17
|
-
value = state.materializeTrace(marker);
|
|
16
|
+
value = state.materializeTrace(marker, claiming);
|
|
18
17
|
state.materialized.set(marker.$tr, value);
|
|
19
18
|
if (value !== null && typeof value === "object") state.materializedValues.add(value);
|
|
20
19
|
}
|
|
@@ -29,7 +28,7 @@ function parseTrace(value, ctx) {
|
|
|
29
28
|
};
|
|
30
29
|
}
|
|
31
30
|
const ContainerTracePlugin = {
|
|
32
|
-
tag: "
|
|
31
|
+
tag: "solid/container-trace",
|
|
33
32
|
test(value) {
|
|
34
33
|
return value != null && typeof value === "object" && TRACE in value;
|
|
35
34
|
},
|
|
@@ -72,75 +71,257 @@ setContainerTraceStreamMint(iterable => {
|
|
|
72
71
|
})();
|
|
73
72
|
return stream;
|
|
74
73
|
});
|
|
75
|
-
const DEFAULT_WEB_PLUGINS = Object.freeze([AbortSignalPlugin,
|
|
74
|
+
const DEFAULT_WEB_PLUGINS = /* @__PURE__ */Object.freeze([AbortSignalPlugin,
|
|
76
75
|
CustomEventPlugin, DOMExceptionPlugin, EventPlugin,
|
|
77
76
|
FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin,
|
|
78
77
|
ContainerTracePlugin]);
|
|
79
78
|
function resolveSerializerPlugins(customPlugins) {
|
|
80
79
|
return customPlugins ? [...customPlugins, ...DEFAULT_WEB_PLUGINS] : [...DEFAULT_WEB_PLUGINS];
|
|
81
80
|
}
|
|
82
|
-
const
|
|
81
|
+
const jsonCodecDisabledFeatures = () => Feature.RegExp;
|
|
83
82
|
const JSON_CODEC_DEPTH_LIMIT = 64;
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
83
|
+
const RESOLVED_PLUGINS = Symbol.for("solid.codec.resolvedPlugins");
|
|
84
|
+
function resolveCodecOptions(options = {}) {
|
|
85
|
+
const {
|
|
86
|
+
plugins,
|
|
87
|
+
disabledFeatures,
|
|
88
|
+
depthLimit,
|
|
89
|
+
serializeErrorStacks
|
|
90
|
+
} = options;
|
|
89
91
|
return {
|
|
90
|
-
plugins: resolveSerializerPlugins(plugins),
|
|
91
|
-
disabledFeatures: disabledFeatures === undefined ?
|
|
92
|
-
depthLimit: depthLimit === undefined ? JSON_CODEC_DEPTH_LIMIT : depthLimit
|
|
92
|
+
plugins: options[RESOLVED_PLUGINS] || resolveSerializerPlugins(plugins),
|
|
93
|
+
disabledFeatures: disabledFeatures === undefined ? jsonCodecDisabledFeatures() : disabledFeatures,
|
|
94
|
+
depthLimit: depthLimit === undefined ? JSON_CODEC_DEPTH_LIMIT : depthLimit,
|
|
95
|
+
serializeErrorStacks
|
|
93
96
|
};
|
|
94
97
|
}
|
|
95
98
|
function createJSONDeserializer(options) {
|
|
96
99
|
const refs = new Map();
|
|
97
100
|
const resolved = resolveCodecOptions(options);
|
|
101
|
+
let owned = 0;
|
|
102
|
+
const pendingResolvers = new Set();
|
|
103
|
+
const streams = new Set();
|
|
104
|
+
const STREAM = 1;
|
|
105
|
+
const RESOLVER = 2;
|
|
106
|
+
function classify(value) {
|
|
107
|
+
if (value === null || typeof value !== "object") return 0;
|
|
108
|
+
try {
|
|
109
|
+
if (isStream(value) && typeof value.on === "function") return STREAM;
|
|
110
|
+
if (typeof value.s === "function" && typeof value.f === "function" && value.p instanceof Promise) return RESOLVER;
|
|
111
|
+
} catch {}
|
|
112
|
+
return 0;
|
|
113
|
+
}
|
|
114
|
+
function ownDecodedPromises() {
|
|
115
|
+
if (refs.size === owned) return;
|
|
116
|
+
let index = 0;
|
|
117
|
+
for (const value of refs.values()) {
|
|
118
|
+
if (index++ < owned) continue;
|
|
119
|
+
if (value instanceof Promise) value.then(undefined, () => {});else {
|
|
120
|
+
const kind = classify(value);
|
|
121
|
+
if (kind === STREAM) streams.add(value);else if (kind === RESOLVER) {
|
|
122
|
+
pendingResolvers.add(value);
|
|
123
|
+
const settled = () => pendingResolvers.delete(value);
|
|
124
|
+
value.p.then(settled, settled);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
owned = refs.size;
|
|
129
|
+
}
|
|
130
|
+
function isOpenStream(stream) {
|
|
131
|
+
let alive = true;
|
|
132
|
+
const close = () => {
|
|
133
|
+
alive = false;
|
|
134
|
+
};
|
|
135
|
+
let off;
|
|
136
|
+
try {
|
|
137
|
+
off = stream.on({
|
|
138
|
+
next() {},
|
|
139
|
+
throw: close,
|
|
140
|
+
return: close
|
|
141
|
+
});
|
|
142
|
+
} catch {
|
|
143
|
+
return stream.alive !== false;
|
|
144
|
+
}
|
|
145
|
+
if (typeof off === "function") off();
|
|
146
|
+
return alive;
|
|
147
|
+
}
|
|
98
148
|
function deserializeJSONChunk(node) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
149
|
+
try {
|
|
150
|
+
return fromCrossJSON(node, {
|
|
151
|
+
refs,
|
|
152
|
+
...resolved
|
|
153
|
+
});
|
|
154
|
+
} finally {
|
|
155
|
+
ownDecodedPromises();
|
|
156
|
+
}
|
|
103
157
|
}
|
|
104
158
|
deserializeJSONChunk.abort = function abort(error) {
|
|
105
159
|
for (const value of refs.values()) {
|
|
106
|
-
|
|
107
|
-
if (
|
|
160
|
+
const kind = classify(value);
|
|
161
|
+
if (kind === STREAM) {
|
|
108
162
|
value.throw(error);
|
|
109
|
-
} else if (
|
|
163
|
+
} else if (kind === RESOLVER) {
|
|
110
164
|
value.p.then(undefined, () => {});
|
|
111
165
|
value.f(error);
|
|
112
166
|
}
|
|
113
167
|
}
|
|
114
168
|
};
|
|
169
|
+
deserializeJSONChunk.close = function close() {
|
|
170
|
+
for (const value of refs.values()) {
|
|
171
|
+
if (classify(value) === STREAM) value.return(undefined);
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
deserializeJSONChunk.open = function open() {
|
|
175
|
+
let count = pendingResolvers.size;
|
|
176
|
+
for (const stream of streams) {
|
|
177
|
+
if (isOpenStream(stream)) count++;else streams.delete(stream);
|
|
178
|
+
}
|
|
179
|
+
return count;
|
|
180
|
+
};
|
|
115
181
|
return deserializeJSONChunk;
|
|
116
182
|
}
|
|
117
183
|
function createJSONDataTable(options) {
|
|
118
184
|
const deserialize = createJSONDeserializer(options);
|
|
119
185
|
const table = new Map();
|
|
186
|
+
const waits = new Map();
|
|
187
|
+
const settle = (w, s, value) => {
|
|
188
|
+
const p = w.p;
|
|
189
|
+
p.s = s;
|
|
190
|
+
p.v = value;
|
|
191
|
+
s === 1 ? w.r(value) : w.j(value);
|
|
192
|
+
for (const c of p.c) c();
|
|
193
|
+
};
|
|
120
194
|
return {
|
|
121
195
|
apply(record) {
|
|
122
196
|
const value = deserialize(record.node);
|
|
123
|
-
if (record.initial)
|
|
197
|
+
if (record.initial) {
|
|
198
|
+
table.set(record.key, value);
|
|
199
|
+
const w = waits.get(record.key);
|
|
200
|
+
if (w) {
|
|
201
|
+
waits.delete(record.key);
|
|
202
|
+
settle(w, 1, value);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
124
205
|
},
|
|
125
206
|
get(key) {
|
|
126
207
|
return table.get(key);
|
|
127
208
|
},
|
|
128
209
|
resolve(ref) {
|
|
129
|
-
|
|
210
|
+
const key = ref.$ref;
|
|
211
|
+
if (table.has(key)) return table.get(key);
|
|
212
|
+
let w = waits.get(key);
|
|
213
|
+
if (!w) {
|
|
214
|
+
waits.set(key, w = {});
|
|
215
|
+
const p = w.p = new Promise((r, j) => (w.r = r, w.j = j));
|
|
216
|
+
p.s = 0;
|
|
217
|
+
p.c = [];
|
|
218
|
+
p.then(undefined, () => {});
|
|
219
|
+
}
|
|
220
|
+
return w.p;
|
|
221
|
+
},
|
|
222
|
+
close(error) {
|
|
223
|
+
for (const [key, w] of waits) settle(w, 2, error || new Error(`Stream ended without delivering {$ref: "${key}"}`));
|
|
224
|
+
waits.clear();
|
|
130
225
|
}
|
|
131
226
|
};
|
|
132
227
|
}
|
|
133
228
|
|
|
134
|
-
const
|
|
135
|
-
const serializeOnlyDisabledFeatures =
|
|
229
|
+
const defaultDisabledFeatures = () => Feature.AggregateError | Feature.BigIntTypedArray;
|
|
230
|
+
const serializeOnlyDisabledFeatures = serializeErrorStacks => (serializeErrorStacks === undefined ? process.env.NODE_ENV === "development" : serializeErrorStacks) ? 0 : Feature.ErrorPrototypeStack;
|
|
136
231
|
const HYDRATION_GLOBAL = "_$HY.r";
|
|
232
|
+
const createPlugin = createPlugin$1;
|
|
233
|
+
const OpaqueReference = OpaqueReference$1;
|
|
137
234
|
function createSerializer(options) {
|
|
138
235
|
return new Serializer({
|
|
139
236
|
...options,
|
|
140
237
|
plugins: resolveSerializerPlugins(options.plugins),
|
|
141
|
-
disabledFeatures: (options.disabledFeatures === undefined ?
|
|
238
|
+
disabledFeatures: (options.disabledFeatures === undefined ? defaultDisabledFeatures() : options.disabledFeatures) | serializeOnlyDisabledFeatures(options.serializeErrorStacks)
|
|
142
239
|
});
|
|
143
240
|
}
|
|
241
|
+
function createKeyedSerializer(serialize, onError, onDone) {
|
|
242
|
+
const cancels = new Set();
|
|
243
|
+
let pendingWrites = 0;
|
|
244
|
+
let flushed = false;
|
|
245
|
+
let done = false;
|
|
246
|
+
let closed = false;
|
|
247
|
+
const maybeDone = () => {
|
|
248
|
+
if (flushed && pendingWrites === 0 && !done) {
|
|
249
|
+
done = true;
|
|
250
|
+
onDone && onDone();
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
return {
|
|
254
|
+
write(key, value) {
|
|
255
|
+
if (flushed) return;
|
|
256
|
+
pendingWrites++;
|
|
257
|
+
let settled = false;
|
|
258
|
+
let failed = false;
|
|
259
|
+
let started = false;
|
|
260
|
+
let cancel = null;
|
|
261
|
+
const settle = () => {
|
|
262
|
+
if (settled) return;
|
|
263
|
+
settled = true;
|
|
264
|
+
if (cancel) cancels.delete(cancel);
|
|
265
|
+
pendingWrites--;
|
|
266
|
+
maybeDone();
|
|
267
|
+
};
|
|
268
|
+
let stream;
|
|
269
|
+
try {
|
|
270
|
+
stream = serialize(key, value, {
|
|
271
|
+
onError: onError && (err => {
|
|
272
|
+
failed = true;
|
|
273
|
+
onError(err);
|
|
274
|
+
if (cancel) {
|
|
275
|
+
cancel();
|
|
276
|
+
settle();
|
|
277
|
+
}
|
|
278
|
+
}),
|
|
279
|
+
onDone: settle
|
|
280
|
+
}, initial => {
|
|
281
|
+
if (initial) started = true;
|
|
282
|
+
return !closed;
|
|
283
|
+
});
|
|
284
|
+
} catch (err) {
|
|
285
|
+
settle();
|
|
286
|
+
throw err;
|
|
287
|
+
}
|
|
288
|
+
if (settled) return;
|
|
289
|
+
if (closed || failed) {
|
|
290
|
+
stream();
|
|
291
|
+
settle();
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
cancel = stream;
|
|
295
|
+
cancels.add(cancel);
|
|
296
|
+
},
|
|
297
|
+
flush() {
|
|
298
|
+
flushed = true;
|
|
299
|
+
maybeDone();
|
|
300
|
+
},
|
|
301
|
+
close() {
|
|
302
|
+
closed = flushed = true;
|
|
303
|
+
for (const cancel of cancels) cancel();
|
|
304
|
+
cancels.clear();
|
|
305
|
+
if (!done) {
|
|
306
|
+
done = true;
|
|
307
|
+
onDone && onDone();
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
const KEY_ESCAPES = {
|
|
313
|
+
'"': '\\"',
|
|
314
|
+
"\\": "\\\\",
|
|
315
|
+
"\n": "\\n",
|
|
316
|
+
"\r": "\\r",
|
|
317
|
+
"\b": "\\b",
|
|
318
|
+
"\t": "\\t",
|
|
319
|
+
"\f": "\\f",
|
|
320
|
+
"<": "\\x3C",
|
|
321
|
+
"\u2028": "\\u2028",
|
|
322
|
+
"\u2029": "\\u2029"
|
|
323
|
+
};
|
|
324
|
+
const serializeKey = key => ("" + key).replace(/["\\\n\r\b\t\f<\u2028\u2029]/g, c => KEY_ESCAPES[c]);
|
|
144
325
|
function createHydrationSerializer({
|
|
145
326
|
onData,
|
|
146
327
|
onDone,
|
|
@@ -148,14 +329,20 @@ function createHydrationSerializer({
|
|
|
148
329
|
onError,
|
|
149
330
|
plugins
|
|
150
331
|
}) {
|
|
151
|
-
|
|
332
|
+
const resolvedPlugins = resolveSerializerPlugins(plugins);
|
|
333
|
+
const disabledFeatures = defaultDisabledFeatures() | serializeOnlyDisabledFeatures();
|
|
334
|
+
const refs = new Map();
|
|
335
|
+
return createKeyedSerializer((key, value, callbacks, live) => crossSerializeStream(value, {
|
|
152
336
|
scopeId,
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
337
|
+
refs,
|
|
338
|
+
plugins: resolvedPlugins,
|
|
339
|
+
disabledFeatures,
|
|
340
|
+
onSerialize(data, initial) {
|
|
341
|
+
if (!live(initial)) return;
|
|
342
|
+
onData(initial ? HYDRATION_GLOBAL + '["' + serializeKey(key) + '"]=' + data : data);
|
|
343
|
+
},
|
|
344
|
+
...callbacks
|
|
345
|
+
}), onError, onDone);
|
|
159
346
|
}
|
|
160
347
|
function getLocalHeaderScript(id) {
|
|
161
348
|
return getCrossReferenceHeader(id) + ";";
|
|
@@ -164,6 +351,7 @@ function serializeJSON(value, {
|
|
|
164
351
|
onParse,
|
|
165
352
|
onDone,
|
|
166
353
|
onError,
|
|
354
|
+
refs,
|
|
167
355
|
...codecOptions
|
|
168
356
|
}) {
|
|
169
357
|
const resolved = resolveCodecOptions(codecOptions);
|
|
@@ -171,8 +359,9 @@ function serializeJSON(value, {
|
|
|
171
359
|
onParse,
|
|
172
360
|
onDone,
|
|
173
361
|
onError,
|
|
362
|
+
refs,
|
|
174
363
|
...resolved,
|
|
175
|
-
disabledFeatures: resolved.disabledFeatures | serializeOnlyDisabledFeatures()
|
|
364
|
+
disabledFeatures: resolved.disabledFeatures | serializeOnlyDisabledFeatures(resolved.serializeErrorStacks)
|
|
176
365
|
});
|
|
177
366
|
}
|
|
178
367
|
function createJSONSerializer({
|
|
@@ -181,64 +370,29 @@ function createJSONSerializer({
|
|
|
181
370
|
onError,
|
|
182
371
|
plugins,
|
|
183
372
|
disabledFeatures,
|
|
184
|
-
depthLimit
|
|
373
|
+
depthLimit,
|
|
374
|
+
serializeErrorStacks
|
|
185
375
|
}) {
|
|
186
376
|
const resolved = resolveCodecOptions({
|
|
187
377
|
plugins,
|
|
188
378
|
disabledFeatures,
|
|
189
|
-
depthLimit
|
|
379
|
+
depthLimit,
|
|
380
|
+
serializeErrorStacks
|
|
190
381
|
});
|
|
191
382
|
const refs = new Map();
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
};
|
|
202
|
-
return {
|
|
203
|
-
write(key, value) {
|
|
204
|
-
if (flushed) return;
|
|
205
|
-
pendingWrites++;
|
|
206
|
-
let settled = false;
|
|
207
|
-
let cancel = null;
|
|
208
|
-
const stream = toCrossJSONStream(value, {
|
|
209
|
-
refs,
|
|
210
|
-
plugins: resolved.plugins,
|
|
211
|
-
disabledFeatures: resolved.disabledFeatures | serializeOnlyDisabledFeatures(),
|
|
212
|
-
onParse(node, initial) {
|
|
213
|
-
onData({
|
|
214
|
-
key,
|
|
215
|
-
node,
|
|
216
|
-
initial
|
|
217
|
-
});
|
|
218
|
-
},
|
|
219
|
-
onError,
|
|
220
|
-
onDone() {
|
|
221
|
-
settled = true;
|
|
222
|
-
if (cancel) cancels.delete(cancel);
|
|
223
|
-
pendingWrites--;
|
|
224
|
-
maybeDone();
|
|
225
|
-
}
|
|
383
|
+
return createKeyedSerializer((key, value, callbacks, live) => toCrossJSONStream(value, {
|
|
384
|
+
refs,
|
|
385
|
+
plugins: resolved.plugins,
|
|
386
|
+
disabledFeatures: resolved.disabledFeatures | serializeOnlyDisabledFeatures(resolved.serializeErrorStacks),
|
|
387
|
+
onParse(node, initial) {
|
|
388
|
+
if (live(initial)) onData({
|
|
389
|
+
key,
|
|
390
|
+
node,
|
|
391
|
+
initial
|
|
226
392
|
});
|
|
227
|
-
if (!settled) {
|
|
228
|
-
cancel = stream;
|
|
229
|
-
cancels.add(cancel);
|
|
230
|
-
}
|
|
231
|
-
},
|
|
232
|
-
flush() {
|
|
233
|
-
flushed = true;
|
|
234
|
-
maybeDone();
|
|
235
393
|
},
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
for (const cancel of cancels) cancel();
|
|
239
|
-
cancels.clear();
|
|
240
|
-
}
|
|
241
|
-
};
|
|
394
|
+
...callbacks
|
|
395
|
+
}), onError, onDone);
|
|
242
396
|
}
|
|
243
397
|
|
|
244
|
-
export { DEFAULT_WEB_PLUGINS, createHydrationSerializer, createJSONDataTable, createJSONDeserializer, createJSONSerializer, createSerializer, getLocalHeaderScript, resolveSerializerPlugins, serializeJSON };
|
|
398
|
+
export { DEFAULT_WEB_PLUGINS, OpaqueReference, createHydrationSerializer, createJSONDataTable, createJSONDeserializer, createJSONSerializer, createPlugin, createSerializer, getLocalHeaderScript, resolveSerializerPlugins, serializeJSON };
|
|
@@ -1,20 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
"main": "./dist/serialization.cjs",
|
|
2
|
+
"main": "./dist/serialization.js",
|
|
4
3
|
"module": "./dist/serialization.js",
|
|
5
4
|
"types": "./types/index.d.ts",
|
|
6
5
|
"type": "module",
|
|
7
|
-
"sideEffects": false
|
|
8
|
-
"exports": {
|
|
9
|
-
".": {
|
|
10
|
-
"import": {
|
|
11
|
-
"types": "./types/index.d.ts",
|
|
12
|
-
"default": "./dist/serialization.js"
|
|
13
|
-
},
|
|
14
|
-
"require": {
|
|
15
|
-
"types": "./types-cjs/index.d.cts",
|
|
16
|
-
"default": "./dist/serialization.cjs"
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
6
|
+
"sideEffects": false
|
|
20
7
|
}
|