seroval 1.6.6 → 1.6.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/dev/index.cjs +173 -19
- package/dist/dev/index.d.cts +14 -3
- package/dist/dev/index.d.ts +14 -3
- package/dist/dev/index.js +173 -19
- package/dist/index.cjs +173 -19
- package/dist/index.d.cts +14 -3
- package/dist/index.d.ts +14 -3
- package/dist/index.js +173 -19
- package/package.json +1 -1
package/dist/dev/index.cjs
CHANGED
|
@@ -197,6 +197,7 @@ function deserializeReplacer(str) {
|
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
199
|
function deserializeString(str) {
|
|
200
|
+
if (typeof str === "string" && !str.includes("\\")) return str;
|
|
200
201
|
return str.replace(/(\\\\|\\"|\\n|\\r|\\b|\\t|\\f|\\u2028|\\u2029|\\x3C)/g, deserializeReplacer);
|
|
201
202
|
}
|
|
202
203
|
//#endregion
|
|
@@ -699,16 +700,26 @@ const ARRAY_BUFFER_CONSTRUCTOR = (b64) => {
|
|
|
699
700
|
const SERIALIZED_ARRAY_BUFFER_CONSTRUCTOR = /* @__PURE__ */ ARRAY_BUFFER_CONSTRUCTOR.toString();
|
|
700
701
|
//#endregion
|
|
701
702
|
//#region src/core/sequence.ts
|
|
703
|
+
/**
|
|
704
|
+
* An internal class rather than a tagged POJO: identity is checked with
|
|
705
|
+
* `instanceof`, which untrusted input cannot forge (the class is not exported).
|
|
706
|
+
* The eval-based `deserialize` path still rebuilds a `{__SEROVAL_SEQUENCE__…}`
|
|
707
|
+
* POJO from embedded source - it has no access to this class - so a value read
|
|
708
|
+
* back through `deserialize` is not an instance and, by design, is not treated
|
|
709
|
+
* as a genuine Sequence on re-serialization.
|
|
710
|
+
*/
|
|
711
|
+
var Sequence = class {
|
|
712
|
+
constructor(values, throwAt, doneAt) {
|
|
713
|
+
this.v = values;
|
|
714
|
+
this.t = throwAt;
|
|
715
|
+
this.d = doneAt;
|
|
716
|
+
}
|
|
717
|
+
};
|
|
702
718
|
function isSequence(value) {
|
|
703
|
-
return
|
|
719
|
+
return value instanceof Sequence;
|
|
704
720
|
}
|
|
705
721
|
function createSequence(values, throwAt, doneAt) {
|
|
706
|
-
return
|
|
707
|
-
__SEROVAL_SEQUENCE__: true,
|
|
708
|
-
v: values,
|
|
709
|
-
t: throwAt,
|
|
710
|
-
d: doneAt
|
|
711
|
-
};
|
|
722
|
+
return new Sequence(values, throwAt, doneAt);
|
|
712
723
|
}
|
|
713
724
|
function createSequenceFromIterable(source) {
|
|
714
725
|
const values = [];
|
|
@@ -724,7 +735,9 @@ function createSequenceFromIterable(source) {
|
|
|
724
735
|
}
|
|
725
736
|
} catch (error) {
|
|
726
737
|
throwsAt = values.length;
|
|
738
|
+
doneAt = throwsAt;
|
|
727
739
|
values.push(error);
|
|
740
|
+
break;
|
|
728
741
|
}
|
|
729
742
|
return createSequence(values, throwsAt, doneAt);
|
|
730
743
|
}
|
|
@@ -756,12 +769,131 @@ const SPECIAL_REF_STRING = {
|
|
|
756
769
|
[5]: SERIALIZED_ARRAY_BUFFER_CONSTRUCTOR
|
|
757
770
|
};
|
|
758
771
|
//#endregion
|
|
772
|
+
//#region \0@oxc-project+runtime@0.143.0/helpers/esm/checkPrivateRedeclaration.js
|
|
773
|
+
function _checkPrivateRedeclaration(e, t) {
|
|
774
|
+
if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
775
|
+
}
|
|
776
|
+
//#endregion
|
|
777
|
+
//#region \0@oxc-project+runtime@0.143.0/helpers/esm/classPrivateMethodInitSpec.js
|
|
778
|
+
function _classPrivateMethodInitSpec(e, a) {
|
|
779
|
+
_checkPrivateRedeclaration(e, a), a.add(e);
|
|
780
|
+
}
|
|
781
|
+
//#endregion
|
|
782
|
+
//#region \0@oxc-project+runtime@0.143.0/helpers/esm/classPrivateFieldInitSpec.js
|
|
783
|
+
function _classPrivateFieldInitSpec(e, t, a) {
|
|
784
|
+
_checkPrivateRedeclaration(e, t), t.set(e, a);
|
|
785
|
+
}
|
|
786
|
+
//#endregion
|
|
787
|
+
//#region \0@oxc-project+runtime@0.143.0/helpers/esm/assertClassBrand.js
|
|
788
|
+
function _assertClassBrand(e, t, n) {
|
|
789
|
+
if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
|
|
790
|
+
throw new TypeError("Private element is not present on this object");
|
|
791
|
+
}
|
|
792
|
+
//#endregion
|
|
793
|
+
//#region \0@oxc-project+runtime@0.143.0/helpers/esm/classPrivateFieldGet2.js
|
|
794
|
+
function _classPrivateFieldGet2(s, a) {
|
|
795
|
+
return s.get(_assertClassBrand(s, a));
|
|
796
|
+
}
|
|
797
|
+
//#endregion
|
|
798
|
+
//#region \0@oxc-project+runtime@0.143.0/helpers/esm/classPrivateFieldSet2.js
|
|
799
|
+
function _classPrivateFieldSet2(s, a, r) {
|
|
800
|
+
return s.set(_assertClassBrand(s, a), r), r;
|
|
801
|
+
}
|
|
802
|
+
//#endregion
|
|
759
803
|
//#region src/core/stream.ts
|
|
804
|
+
var _buffer = /* @__PURE__ */ new WeakMap();
|
|
805
|
+
var _listeners = /* @__PURE__ */ new WeakMap();
|
|
806
|
+
var _alive = /* @__PURE__ */ new WeakMap();
|
|
807
|
+
var _success = /* @__PURE__ */ new WeakMap();
|
|
808
|
+
var _count = /* @__PURE__ */ new WeakMap();
|
|
809
|
+
var _Stream_brand = /* @__PURE__ */ new WeakSet();
|
|
810
|
+
/**
|
|
811
|
+
* An internal class rather than a tagged POJO: identity is checked with
|
|
812
|
+
* `instanceof`, which untrusted input cannot forge (the class is not exported).
|
|
813
|
+
*
|
|
814
|
+
* The behavior is intentionally duplicated from `STREAM_CONSTRUCTOR`. That
|
|
815
|
+
* constructor's source is embedded verbatim into the eval-based `deserialize`
|
|
816
|
+
* output, which has no access to this class, so the two cannot be shared. A
|
|
817
|
+
* stream read back through `deserialize` is therefore a plain POJO and, by
|
|
818
|
+
* design, is not treated as a genuine Stream on re-serialization. Keep the two
|
|
819
|
+
* implementations in sync.
|
|
820
|
+
*/
|
|
821
|
+
var Stream = class {
|
|
822
|
+
constructor() {
|
|
823
|
+
_classPrivateMethodInitSpec(this, _Stream_brand);
|
|
824
|
+
_classPrivateFieldInitSpec(this, _buffer, []);
|
|
825
|
+
_classPrivateFieldInitSpec(this, _listeners, []);
|
|
826
|
+
_classPrivateFieldInitSpec(this, _alive, true);
|
|
827
|
+
_classPrivateFieldInitSpec(this, _success, false);
|
|
828
|
+
_classPrivateFieldInitSpec(this, _count, 0);
|
|
829
|
+
}
|
|
830
|
+
on(listener) {
|
|
831
|
+
let subscribed = _classPrivateFieldGet2(_alive, this);
|
|
832
|
+
let temp = 0;
|
|
833
|
+
if (subscribed) {
|
|
834
|
+
for (; temp < _classPrivateFieldGet2(_count, this); temp++) if (!_classPrivateFieldGet2(_listeners, this)[temp]) break;
|
|
835
|
+
if (temp === _classPrivateFieldGet2(_count, this)) {
|
|
836
|
+
var _this$count;
|
|
837
|
+
_classPrivateFieldSet2(_count, this, (_this$count = _classPrivateFieldGet2(_count, this), _this$count++, _this$count));
|
|
838
|
+
}
|
|
839
|
+
_classPrivateFieldGet2(_listeners, this)[temp] = listener;
|
|
840
|
+
}
|
|
841
|
+
_assertClassBrand(_Stream_brand, this, _replay).call(this, listener);
|
|
842
|
+
return () => {
|
|
843
|
+
if (_classPrivateFieldGet2(_alive, this) && subscribed) {
|
|
844
|
+
subscribed = false;
|
|
845
|
+
_classPrivateFieldGet2(_listeners, this)[temp] = void 0;
|
|
846
|
+
while (_classPrivateFieldGet2(_count, this) > 0 && !_classPrivateFieldGet2(_listeners, this)[_classPrivateFieldGet2(_count, this) - 1]) {
|
|
847
|
+
var _this$count3;
|
|
848
|
+
_classPrivateFieldSet2(_count, this, (_this$count3 = _classPrivateFieldGet2(_count, this), _this$count3--, _this$count3));
|
|
849
|
+
}
|
|
850
|
+
_classPrivateFieldGet2(_listeners, this).length = _classPrivateFieldGet2(_count, this);
|
|
851
|
+
}
|
|
852
|
+
};
|
|
853
|
+
}
|
|
854
|
+
next(value) {
|
|
855
|
+
if (_classPrivateFieldGet2(_alive, this)) {
|
|
856
|
+
_classPrivateFieldGet2(_buffer, this).push(value);
|
|
857
|
+
_assertClassBrand(_Stream_brand, this, _flush).call(this, value, "next");
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
throw(value) {
|
|
861
|
+
if (_classPrivateFieldGet2(_alive, this)) {
|
|
862
|
+
_classPrivateFieldGet2(_buffer, this).push(value);
|
|
863
|
+
_assertClassBrand(_Stream_brand, this, _flush).call(this, value, "throw");
|
|
864
|
+
_classPrivateFieldSet2(_alive, this, false);
|
|
865
|
+
_classPrivateFieldSet2(_success, this, false);
|
|
866
|
+
_classPrivateFieldGet2(_listeners, this).length = 0;
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
return(value) {
|
|
870
|
+
if (_classPrivateFieldGet2(_alive, this)) {
|
|
871
|
+
_classPrivateFieldGet2(_buffer, this).push(value);
|
|
872
|
+
_assertClassBrand(_Stream_brand, this, _flush).call(this, value, "return");
|
|
873
|
+
_classPrivateFieldSet2(_alive, this, false);
|
|
874
|
+
_classPrivateFieldSet2(_success, this, true);
|
|
875
|
+
_classPrivateFieldGet2(_listeners, this).length = 0;
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
};
|
|
879
|
+
function _flush(value, mode) {
|
|
880
|
+
for (let x = 0; x < _classPrivateFieldGet2(_count, this); x++) {
|
|
881
|
+
var _classPrivateFieldGet2$1;
|
|
882
|
+
(_classPrivateFieldGet2$1 = _classPrivateFieldGet2(_listeners, this)[x]) === null || _classPrivateFieldGet2$1 === void 0 || _classPrivateFieldGet2$1[mode](value);
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
function _replay(listener) {
|
|
886
|
+
for (let x = 0, z = _classPrivateFieldGet2(_buffer, this).length; x < z; x++) {
|
|
887
|
+
const current = _classPrivateFieldGet2(_buffer, this)[x];
|
|
888
|
+
if (!_classPrivateFieldGet2(_alive, this) && x === z - 1) listener[_classPrivateFieldGet2(_success, this) ? "return" : "throw"](current);
|
|
889
|
+
else listener.next(current);
|
|
890
|
+
}
|
|
891
|
+
}
|
|
760
892
|
function isStream(value) {
|
|
761
|
-
return
|
|
893
|
+
return value instanceof Stream;
|
|
762
894
|
}
|
|
763
895
|
function createStream() {
|
|
764
|
-
return
|
|
896
|
+
return new Stream();
|
|
765
897
|
}
|
|
766
898
|
function createStreamFromAsyncIterable(iterable, cleanups) {
|
|
767
899
|
const stream = createStream();
|
|
@@ -1234,6 +1366,7 @@ function isValidSymbol(symbol) {
|
|
|
1234
1366
|
//#endregion
|
|
1235
1367
|
//#region src/core/context/deserializer.ts
|
|
1236
1368
|
const DEFAULT_MAX_BASE64_LENGTH = 1e6;
|
|
1369
|
+
const MIN_NATIVE_BASE64_LENGTH = 512;
|
|
1237
1370
|
const MAX_BIGINT_LENGTH = 1e4;
|
|
1238
1371
|
const MAX_REGEXP_SOURCE_LENGTH = 2e4;
|
|
1239
1372
|
function applyObjectFlag(obj, flag) {
|
|
@@ -1292,7 +1425,7 @@ function guardIndexedValue(ctx, id) {
|
|
|
1292
1425
|
if (ctx.refs.has(id)) throw new Error("Conflicted ref id: " + id);
|
|
1293
1426
|
}
|
|
1294
1427
|
function isThennable(value) {
|
|
1295
|
-
return !!value && typeof value === "object" && "then" in value && typeof value.then === "function";
|
|
1428
|
+
return !!value && (typeof value === "object" || typeof value === "function") && "then" in value && typeof value.then === "function";
|
|
1296
1429
|
}
|
|
1297
1430
|
function assignIndexedValueVanilla(ctx, id, value) {
|
|
1298
1431
|
guardIndexedValue(ctx.base, id);
|
|
@@ -1314,8 +1447,12 @@ function deserializeKnownValue(node, record, key) {
|
|
|
1314
1447
|
function deserializeReference(ctx, node) {
|
|
1315
1448
|
return assignIndexedValue$1(ctx, node.i, getReference(deserializeString(node.s)));
|
|
1316
1449
|
}
|
|
1450
|
+
function validateNodeList(node, list) {
|
|
1451
|
+
if (!Array.isArray(list)) throw new SerovalMalformedNodeError(node);
|
|
1452
|
+
}
|
|
1317
1453
|
function deserializeArray(ctx, depth, node) {
|
|
1318
1454
|
const items = node.a;
|
|
1455
|
+
validateNodeList(node, items);
|
|
1319
1456
|
const len = items.length;
|
|
1320
1457
|
const result = assignIndexedValue$1(ctx, node.i, new Array(len));
|
|
1321
1458
|
for (let i = 0, item; i < len; i++) {
|
|
@@ -1357,6 +1494,8 @@ function validateNodeType(ctx, node, id, type) {
|
|
|
1357
1494
|
}
|
|
1358
1495
|
function deserializeProperties(ctx, depth, node, result) {
|
|
1359
1496
|
const keys = node.k;
|
|
1497
|
+
validateNodeList(node, keys);
|
|
1498
|
+
validateNodeList(node, node.v);
|
|
1360
1499
|
if (keys.length > 0) for (let i = 0, vals = node.v, len = keys.length; i < len; i++) assignProperty(ctx, depth, result, keys[i], vals[i]);
|
|
1361
1500
|
return result;
|
|
1362
1501
|
}
|
|
@@ -1411,18 +1550,29 @@ function deserializeRegExp(ctx, node) {
|
|
|
1411
1550
|
}
|
|
1412
1551
|
function deserializeSet(ctx, depth, node) {
|
|
1413
1552
|
const result = assignIndexedValue$1(ctx, node.i, /* @__PURE__ */ new Set());
|
|
1553
|
+
validateNodeList(node, node.a);
|
|
1414
1554
|
for (let i = 0, items = node.a, len = items.length; i < len; i++) result.add(deserialize$1(ctx, depth, items[i]));
|
|
1415
1555
|
return result;
|
|
1416
1556
|
}
|
|
1417
1557
|
function deserializeMap(ctx, depth, node) {
|
|
1418
1558
|
const result = assignIndexedValue$1(ctx, node.i, /* @__PURE__ */ new Map());
|
|
1559
|
+
validateNodeList(node, node.e.k);
|
|
1560
|
+
validateNodeList(node, node.e.v);
|
|
1419
1561
|
for (let i = 0, keys = node.e.k, vals = node.e.v, len = keys.length; i < len; i++) result.set(deserialize$1(ctx, depth, keys[i]), deserialize$1(ctx, depth, vals[i]));
|
|
1420
1562
|
return result;
|
|
1421
1563
|
}
|
|
1422
1564
|
function deserializeArrayBuffer(ctx, node) {
|
|
1423
1565
|
if (typeof node.s !== "string") throw new SerovalMalformedNodeError(node);
|
|
1424
1566
|
if (node.s.length > ctx.base.maxBase64Length) throw new RangeError("ArrayBuffer exceeds maxBase64Length (" + ctx.base.maxBase64Length + ")");
|
|
1425
|
-
|
|
1567
|
+
const source = deserializeString(node.s);
|
|
1568
|
+
let buffer;
|
|
1569
|
+
if (source.length < MIN_NATIVE_BASE64_LENGTH || typeof Buffer === "undefined") buffer = ARRAY_BUFFER_CONSTRUCTOR(source);
|
|
1570
|
+
else {
|
|
1571
|
+
const decoded = atob(source);
|
|
1572
|
+
buffer = new ArrayBuffer(decoded.length);
|
|
1573
|
+
Buffer.from(buffer).write(decoded, "latin1");
|
|
1574
|
+
}
|
|
1575
|
+
return assignIndexedValue$1(ctx, node.i, buffer);
|
|
1426
1576
|
}
|
|
1427
1577
|
function deserializeTypedArray(ctx, depth, node) {
|
|
1428
1578
|
var _node$b;
|
|
@@ -1430,7 +1580,7 @@ function deserializeTypedArray(ctx, depth, node) {
|
|
|
1430
1580
|
const source = deserialize$1(ctx, depth, node.f);
|
|
1431
1581
|
if (!(source instanceof ArrayBuffer)) throw new SerovalMalformedNodeError(node);
|
|
1432
1582
|
const offset = (_node$b = node.b) !== null && _node$b !== void 0 ? _node$b : 0;
|
|
1433
|
-
if (offset < 0 || offset > source.byteLength
|
|
1583
|
+
if (offset < 0 || offset > source.byteLength) throw new SerovalMalformedNodeError(node);
|
|
1434
1584
|
return assignIndexedValue$1(ctx, node.i, new construct(source, offset, node.l));
|
|
1435
1585
|
}
|
|
1436
1586
|
function deserializeDataView(ctx, depth, node) {
|
|
@@ -1438,7 +1588,7 @@ function deserializeDataView(ctx, depth, node) {
|
|
|
1438
1588
|
const source = deserialize$1(ctx, depth, node.f);
|
|
1439
1589
|
if (!(source instanceof ArrayBuffer)) throw new SerovalMalformedNodeError(node);
|
|
1440
1590
|
const offset = (_node$b2 = node.b) !== null && _node$b2 !== void 0 ? _node$b2 : 0;
|
|
1441
|
-
if (offset < 0 || offset > source.byteLength
|
|
1591
|
+
if (offset < 0 || offset > source.byteLength) throw new SerovalMalformedNodeError(node);
|
|
1442
1592
|
return assignIndexedValue$1(ctx, node.i, new DataView(source, offset, node.l));
|
|
1443
1593
|
}
|
|
1444
1594
|
function deserializeDictionary(ctx, depth, node, result) {
|
|
@@ -1498,21 +1648,20 @@ function deserializePromiseFulfill(ctx, depth, node) {
|
|
|
1498
1648
|
function deserializeIteratorFactoryInstance(ctx, depth, node) {
|
|
1499
1649
|
deserialize$1(ctx, depth, node.a[0]);
|
|
1500
1650
|
const source = deserialize$1(ctx, depth, node.a[1]);
|
|
1501
|
-
|
|
1502
|
-
if (!source) throw new SerovalMalformedNodeError(node.a[1]);
|
|
1651
|
+
if (!isSequence(source)) throw new SerovalMalformedNodeError(node.a[1]);
|
|
1503
1652
|
return sequenceToIterator(source);
|
|
1504
1653
|
}
|
|
1505
1654
|
function deserializeAsyncIteratorFactoryInstance(ctx, depth, node) {
|
|
1506
1655
|
deserialize$1(ctx, depth, node.a[0]);
|
|
1507
1656
|
const source = deserialize$1(ctx, depth, node.a[1]);
|
|
1508
|
-
|
|
1509
|
-
if (!source) throw new SerovalMalformedNodeError(node.a[1]);
|
|
1657
|
+
if (!isStream(source)) throw new SerovalMalformedNodeError(node.a[1]);
|
|
1510
1658
|
return streamToAsyncIterable(source);
|
|
1511
1659
|
}
|
|
1512
1660
|
function deserializeStreamConstructor(ctx, depth, node) {
|
|
1513
1661
|
const result = assignIndexedValue$1(ctx, node.i, createStream());
|
|
1514
1662
|
assignNodeType(ctx, node.i, 31);
|
|
1515
1663
|
const items = node.a;
|
|
1664
|
+
validateNodeList(node, items);
|
|
1516
1665
|
const len = items.length;
|
|
1517
1666
|
if (len) for (let i = 0; i < len; i++) deserialize$1(ctx, depth, items[i]);
|
|
1518
1667
|
return result;
|
|
@@ -1550,10 +1699,15 @@ function deserializeIteratorFactory(ctx, depth, node) {
|
|
|
1550
1699
|
function deserializeAsyncIteratorFactory(ctx, depth, node) {
|
|
1551
1700
|
deserialize$1(ctx, depth, node.a[1]);
|
|
1552
1701
|
}
|
|
1702
|
+
function isSequenceIndex(value, size) {
|
|
1703
|
+
return Number.isInteger(value) && value >= -1 && value < size;
|
|
1704
|
+
}
|
|
1553
1705
|
function deserializeSequence(ctx, depth, node) {
|
|
1706
|
+
validateNodeList(node, node.a);
|
|
1707
|
+
const size = node.a.length;
|
|
1708
|
+
if (!(isSequenceIndex(node.s, size) && isSequenceIndex(node.l, size))) throw new SerovalMalformedNodeError(node);
|
|
1554
1709
|
const result = assignIndexedValue$1(ctx, node.i, createSequence([], node.s, node.l));
|
|
1555
|
-
|
|
1556
|
-
for (let i = 0, len = node.a.length; i < len; i++) result.v[i] = deserialize$1(ctx, depth, node.a[i]);
|
|
1710
|
+
for (let i = 0; i < size; i++) result.v[i] = deserialize$1(ctx, depth, node.a[i]);
|
|
1557
1711
|
return result;
|
|
1558
1712
|
}
|
|
1559
1713
|
function deserialize$1(ctx, depth, node) {
|
package/dist/dev/index.d.cts
CHANGED
|
@@ -737,14 +737,25 @@ interface StreamListener<T> {
|
|
|
737
737
|
throw(value: unknown): void;
|
|
738
738
|
return(value: T): void;
|
|
739
739
|
}
|
|
740
|
-
|
|
741
|
-
|
|
740
|
+
/**
|
|
741
|
+
* An internal class rather than a tagged POJO: identity is checked with
|
|
742
|
+
* `instanceof`, which untrusted input cannot forge (the class is not exported).
|
|
743
|
+
*
|
|
744
|
+
* The behavior is intentionally duplicated from `STREAM_CONSTRUCTOR`. That
|
|
745
|
+
* constructor's source is embedded verbatim into the eval-based `deserialize`
|
|
746
|
+
* output, which has no access to this class, so the two cannot be shared. A
|
|
747
|
+
* stream read back through `deserialize` is therefore a plain POJO and, by
|
|
748
|
+
* design, is not treated as a genuine Stream on re-serialization. Keep the two
|
|
749
|
+
* implementations in sync.
|
|
750
|
+
*/
|
|
751
|
+
declare class Stream<T> {
|
|
752
|
+
#private;
|
|
742
753
|
on(listener: StreamListener<T>): () => void;
|
|
743
754
|
next(value: T): void;
|
|
744
755
|
throw(value: unknown): void;
|
|
745
756
|
return(value: T): void;
|
|
746
757
|
}
|
|
747
|
-
declare function isStream<T>(value:
|
|
758
|
+
declare function isStream<T>(value: unknown): value is Stream<T>;
|
|
748
759
|
declare function createStream<T>(): Stream<T>;
|
|
749
760
|
//#endregion
|
|
750
761
|
//#region src/core/tree/index.d.ts
|
package/dist/dev/index.d.ts
CHANGED
|
@@ -737,14 +737,25 @@ interface StreamListener<T> {
|
|
|
737
737
|
throw(value: unknown): void;
|
|
738
738
|
return(value: T): void;
|
|
739
739
|
}
|
|
740
|
-
|
|
741
|
-
|
|
740
|
+
/**
|
|
741
|
+
* An internal class rather than a tagged POJO: identity is checked with
|
|
742
|
+
* `instanceof`, which untrusted input cannot forge (the class is not exported).
|
|
743
|
+
*
|
|
744
|
+
* The behavior is intentionally duplicated from `STREAM_CONSTRUCTOR`. That
|
|
745
|
+
* constructor's source is embedded verbatim into the eval-based `deserialize`
|
|
746
|
+
* output, which has no access to this class, so the two cannot be shared. A
|
|
747
|
+
* stream read back through `deserialize` is therefore a plain POJO and, by
|
|
748
|
+
* design, is not treated as a genuine Stream on re-serialization. Keep the two
|
|
749
|
+
* implementations in sync.
|
|
750
|
+
*/
|
|
751
|
+
declare class Stream<T> {
|
|
752
|
+
#private;
|
|
742
753
|
on(listener: StreamListener<T>): () => void;
|
|
743
754
|
next(value: T): void;
|
|
744
755
|
throw(value: unknown): void;
|
|
745
756
|
return(value: T): void;
|
|
746
757
|
}
|
|
747
|
-
declare function isStream<T>(value:
|
|
758
|
+
declare function isStream<T>(value: unknown): value is Stream<T>;
|
|
748
759
|
declare function createStream<T>(): Stream<T>;
|
|
749
760
|
//#endregion
|
|
750
761
|
//#region src/core/tree/index.d.ts
|