seroval 1.5.2 → 1.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/development/index.cjs +20 -4
- package/dist/cjs/development/index.cjs.map +2 -2
- package/dist/cjs/production/index.cjs +3 -3
- package/dist/esm/development/index.mjs +20 -4
- package/dist/esm/development/index.mjs.map +2 -2
- package/dist/esm/production/index.mjs +3 -3
- package/dist/types/core/context/deserializer.d.ts +2 -0
- package/dist/types/core/context/deserializer.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/core/context/deserializer.ts +32 -4
|
@@ -1973,7 +1973,8 @@ function createBaseDeserializerContext(mode, options) {
|
|
|
1973
1973
|
plugins: options.plugins,
|
|
1974
1974
|
refs: options.refs || /* @__PURE__ */ new Map(),
|
|
1975
1975
|
features: (_a = options.features) != null ? _a : ALL_ENABLED ^ (options.disabledFeatures || 0),
|
|
1976
|
-
depthLimit: options.depthLimit || DEFAULT_DEPTH_LIMIT
|
|
1976
|
+
depthLimit: options.depthLimit || DEFAULT_DEPTH_LIMIT,
|
|
1977
|
+
types: /* @__PURE__ */ new Map()
|
|
1977
1978
|
};
|
|
1978
1979
|
}
|
|
1979
1980
|
function createVanillaDeserializerContext(options) {
|
|
@@ -2118,6 +2119,14 @@ function assignProperty(ctx, depth, object, key, value) {
|
|
|
2118
2119
|
}
|
|
2119
2120
|
}
|
|
2120
2121
|
}
|
|
2122
|
+
function assignNodeType(ctx, id, type) {
|
|
2123
|
+
ctx.base.types.set(id, type);
|
|
2124
|
+
}
|
|
2125
|
+
function validateNodeType(ctx, node, id, type) {
|
|
2126
|
+
if (ctx.base.types.get(id) !== type) {
|
|
2127
|
+
throw new SerovalMalformedNodeError(node);
|
|
2128
|
+
}
|
|
2129
|
+
}
|
|
2121
2130
|
function deserializeProperties(ctx, depth, node, result) {
|
|
2122
2131
|
const keys = node.k;
|
|
2123
2132
|
const len = keys.length;
|
|
@@ -2271,6 +2280,7 @@ function deserializePlugin(ctx, depth, node) {
|
|
|
2271
2280
|
throw new SerovalMissingPluginError(node.c);
|
|
2272
2281
|
}
|
|
2273
2282
|
function deserializePromiseConstructor(ctx, node) {
|
|
2283
|
+
assignNodeType(ctx, node.s, 22 /* PromiseConstructor */);
|
|
2274
2284
|
return assignIndexedValue(
|
|
2275
2285
|
ctx,
|
|
2276
2286
|
node.i,
|
|
@@ -2280,6 +2290,7 @@ function deserializePromiseConstructor(ctx, node) {
|
|
|
2280
2290
|
function deserializePromiseResolve(ctx, depth, node) {
|
|
2281
2291
|
const deferred = ctx.base.refs.get(node.i);
|
|
2282
2292
|
if (deferred) {
|
|
2293
|
+
validateNodeType(ctx, node, node.i, 22 /* PromiseConstructor */);
|
|
2283
2294
|
deferred.s(deserialize(ctx, depth, node.a[1]));
|
|
2284
2295
|
return NIL;
|
|
2285
2296
|
}
|
|
@@ -2288,6 +2299,7 @@ function deserializePromiseResolve(ctx, depth, node) {
|
|
|
2288
2299
|
function deserializePromiseReject(ctx, depth, node) {
|
|
2289
2300
|
const deferred = ctx.base.refs.get(node.i);
|
|
2290
2301
|
if (deferred) {
|
|
2302
|
+
validateNodeType(ctx, node, node.i, 22 /* PromiseConstructor */);
|
|
2291
2303
|
deferred.f(deserialize(ctx, depth, node.a[1]));
|
|
2292
2304
|
return NIL;
|
|
2293
2305
|
}
|
|
@@ -2304,6 +2316,7 @@ function deserializeAsyncIteratorFactoryInstance(ctx, depth, node) {
|
|
|
2304
2316
|
return streamToAsyncIterable(source);
|
|
2305
2317
|
}
|
|
2306
2318
|
function deserializeStreamConstructor(ctx, depth, node) {
|
|
2319
|
+
assignNodeType(ctx, node.i, 31 /* StreamConstructor */);
|
|
2307
2320
|
const result = assignIndexedValue(ctx, node.i, createStream());
|
|
2308
2321
|
const items = node.a;
|
|
2309
2322
|
const len = items.length;
|
|
@@ -2316,7 +2329,8 @@ function deserializeStreamConstructor(ctx, depth, node) {
|
|
|
2316
2329
|
}
|
|
2317
2330
|
function deserializeStreamNext(ctx, depth, node) {
|
|
2318
2331
|
const deferred = ctx.base.refs.get(node.i);
|
|
2319
|
-
if (deferred
|
|
2332
|
+
if (deferred) {
|
|
2333
|
+
validateNodeType(ctx, node, node.i, 31 /* StreamConstructor */);
|
|
2320
2334
|
deferred.next(deserialize(ctx, depth, node.f));
|
|
2321
2335
|
return NIL;
|
|
2322
2336
|
}
|
|
@@ -2324,7 +2338,8 @@ function deserializeStreamNext(ctx, depth, node) {
|
|
|
2324
2338
|
}
|
|
2325
2339
|
function deserializeStreamThrow(ctx, depth, node) {
|
|
2326
2340
|
const deferred = ctx.base.refs.get(node.i);
|
|
2327
|
-
if (deferred
|
|
2341
|
+
if (deferred) {
|
|
2342
|
+
validateNodeType(ctx, node, node.i, 31 /* StreamConstructor */);
|
|
2328
2343
|
deferred.throw(deserialize(ctx, depth, node.f));
|
|
2329
2344
|
return NIL;
|
|
2330
2345
|
}
|
|
@@ -2332,7 +2347,8 @@ function deserializeStreamThrow(ctx, depth, node) {
|
|
|
2332
2347
|
}
|
|
2333
2348
|
function deserializeStreamReturn(ctx, depth, node) {
|
|
2334
2349
|
const deferred = ctx.base.refs.get(node.i);
|
|
2335
|
-
if (deferred
|
|
2350
|
+
if (deferred) {
|
|
2351
|
+
validateNodeType(ctx, node, node.i, 31 /* StreamConstructor */);
|
|
2336
2352
|
deferred.return(deserialize(ctx, depth, node.f));
|
|
2337
2353
|
return NIL;
|
|
2338
2354
|
}
|