cbor-x 1.0.0 → 1.1.0
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 -2
- package/decode.d.ts +1 -0
- package/decode.js +31 -11
- package/dist/index.js +111 -81
- package/dist/index.js.map +1 -0
- package/dist/index.min.js +66 -105
- package/dist/node-index.js +93 -0
- package/dist/node.cjs +111 -81
- package/dist/test.js +46 -2
- package/encode.js +76 -66
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,10 +7,9 @@
|
|
|
7
7
|
[](README.md)
|
|
8
8
|
[](LICENSE)
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
The cbor-x package is an extremely fast and conformant CBOR NodeJS/JavaScript implementation. Currently, it is over 3-10x faster than any other CBOR JS implementation (including cbor-js and cborg) and faster than most MessagePack encoders, Avro, and generally faster than native V8 JSON.stringify/parse, on NodeJS. It implements the CBOR format as specificed in [RFC-8949](https://www.rfc-editor.org/rfc/rfc8949.html), [RFC-8746](https://tools.ietf.org/html/rfc8746), [RFC-8742](https://datatracker.ietf.org/doc/html/rfc8742), [Packed CBOR](https://www.ietf.org/id/draft-ietf-cbor-packed-03.html), numerous [registered IANA tag extensions](https://www.iana.org/assignments/cbor-tags/cbor-tags.xhtml) (the `x` in cbor-x), and proposed optional [record extension](https://github.com/kriszyp/cbor-records), for defining record structures that makes CBOR even faster and more compact, often over twice as fast as even native JSON functions, and 15-50% more compact. See the performance section for more details. Structured cloning (with support for cyclical references) is supported through these tag extensions.
|
|
12
10
|
<img align="right" src="./assets/performance.png" width="380"/>
|
|
13
11
|
|
|
12
|
+
The cbor-x package is an extremely fast and conformant CBOR NodeJS/JavaScript implementation. Currently, it is over 3-10x faster than any other CBOR JS implementation (including cbor-js and cborg) and faster than most MessagePack encoders, Avro, and generally faster than native V8 JSON.stringify/parse, on NodeJS. It implements the CBOR format as specificed in [RFC-8949](https://www.rfc-editor.org/rfc/rfc8949.html), [RFC-8746](https://tools.ietf.org/html/rfc8746), [RFC-8742](https://datatracker.ietf.org/doc/html/rfc8742), [Packed CBOR](https://www.ietf.org/id/draft-ietf-cbor-packed-03.html), numerous [registered IANA tag extensions](https://www.iana.org/assignments/cbor-tags/cbor-tags.xhtml) (the `x` in cbor-x), and proposed optional [record extension](https://github.com/kriszyp/cbor-records), for defining record structures that makes CBOR even faster and more compact, often over twice as fast as even native JSON functions, and 15-50% more compact. See the performance section for more details. Structured cloning (with support for cyclical references) is supported through these tag extensions.
|
|
14
13
|
|
|
15
14
|
## Basic Usage
|
|
16
15
|
Install on NodeJS with:
|
package/decode.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ export interface Options {
|
|
|
19
19
|
encodeUndefinedAsNil?: boolean
|
|
20
20
|
maxSharedStructures?: number
|
|
21
21
|
maxOwnStructures?: number
|
|
22
|
+
useSelfDescribedHeader?: boolean
|
|
22
23
|
shouldShareStructure?: (keys: string[]) => boolean
|
|
23
24
|
getStructures?(): {}[]
|
|
24
25
|
saveStructures?(structures: {}[]): boolean | void
|
package/decode.js
CHANGED
|
@@ -254,7 +254,11 @@ export function read() {
|
|
|
254
254
|
position += 8
|
|
255
255
|
return value
|
|
256
256
|
}
|
|
257
|
-
if (
|
|
257
|
+
if (majorType > 1) {
|
|
258
|
+
if (dataView.getUint32(position) > 0)
|
|
259
|
+
throw new Error('JavaScript does not support arrays, maps, or strings with length over 4294967295')
|
|
260
|
+
token = dataView.getUint32(position + 4)
|
|
261
|
+
} else if (currentDecoder.int64AsNumber) {
|
|
258
262
|
token = dataView.getUint32(position) * 0x100000000
|
|
259
263
|
token += dataView.getUint32(position + 4)
|
|
260
264
|
} else
|
|
@@ -434,21 +438,30 @@ function createStructureReader(structure) {
|
|
|
434
438
|
}
|
|
435
439
|
}
|
|
436
440
|
// This initial function is quick to instantiate, but runs slower. After several iterations pay the cost to build the faster function
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
441
|
+
let compiledReader = this.compiledReader // first look to see if we have the fast compiled function
|
|
442
|
+
while(compiledReader) {
|
|
443
|
+
// we have a fast compiled object literal reader
|
|
444
|
+
if (compiledReader.propertyCount === length)
|
|
445
|
+
return compiledReader(read) // with the right length, so we use it
|
|
446
|
+
compiledReader = compiledReader.next // see if there is another reader with the right length
|
|
447
|
+
}
|
|
448
|
+
if (this.slowReads++ >= 3) { // create a fast compiled reader
|
|
449
|
+
let array = this.length == length ? this : this.slice(0, length)
|
|
450
|
+
compiledReader = currentDecoder.keyMap
|
|
451
|
+
? new Function('r', 'return {' + array.map(k => currentDecoder.decodeKey(k)).map(k => validName.test(k) ? k + ':r()' : ('[' + JSON.stringify(k) + ']:r()')).join(',') + '}')
|
|
452
|
+
: new Function('r', 'return {' + array.map(key => validName.test(key) ? key + ':r()' : ('[' + JSON.stringify(key) + ']:r()')).join(',') + '}')
|
|
453
|
+
if (this.compiledReader)
|
|
454
|
+
compiledReader.next = this.compiledReader // if there is an existing one, we store multiple readers as a linked list because it is usually pretty rare to have multiple readers (of different length) for the same structure
|
|
455
|
+
compiledReader.propertyCount = length
|
|
456
|
+
this.compiledReader = compiledReader
|
|
457
|
+
return compiledReader(read)
|
|
445
458
|
}
|
|
446
459
|
let object = {}
|
|
447
460
|
if (currentDecoder.keyMap) for (let i = 0; i < length; i++) object[currentDecoder.decodeKey(this[i])] = read()
|
|
448
461
|
else for (let i = 0; i < length; i++) object[this[i]] = read()
|
|
449
462
|
return object
|
|
450
463
|
}
|
|
451
|
-
structure.
|
|
464
|
+
structure.slowReads = 0
|
|
452
465
|
return readObject
|
|
453
466
|
}
|
|
454
467
|
|
|
@@ -837,11 +850,16 @@ currentExtensions[5] = (fraction) => {
|
|
|
837
850
|
return fraction[1] * Math.exp(fraction[0] * Math.log(2))
|
|
838
851
|
}
|
|
839
852
|
|
|
840
|
-
// the registration of the record definition extension
|
|
853
|
+
// the registration of the record definition extension
|
|
841
854
|
const recordDefinition = (definition) => {
|
|
842
855
|
let id = definition[0] - 0xe000
|
|
843
856
|
let structure = definition[1]
|
|
857
|
+
let existingStructure = currentStructures[id]
|
|
858
|
+
if (existingStructure && existingStructure.isShared) {
|
|
859
|
+
(currentStructures.restoreStructures || (currentStructures.restoreStructures = []))[id] = existingStructure
|
|
860
|
+
}
|
|
844
861
|
currentStructures[id] = structure
|
|
862
|
+
|
|
845
863
|
structure.read = createStructureReader(structure)
|
|
846
864
|
let object = {}
|
|
847
865
|
if (currentDecoder.keyMap) for (let i = 2,l = definition.length; i < l; i++) {
|
|
@@ -985,6 +1003,8 @@ currentExtensionRanges.push((tag, input) => {
|
|
|
985
1003
|
version: input,
|
|
986
1004
|
}
|
|
987
1005
|
}
|
|
1006
|
+
if (tag == 55799) // self-descriptive CBOR tag, just return input value
|
|
1007
|
+
return input
|
|
988
1008
|
})
|
|
989
1009
|
|
|
990
1010
|
export const typedArrays = ['Uint8', 'Uint8Clamped', 'Uint16', 'Uint32', 'BigUint64','Int8', 'Int16', 'Int32', 'BigInt64', 'Float32', 'Float64'].map(type => type + 'Array')
|
package/dist/index.js
CHANGED
|
@@ -250,7 +250,11 @@
|
|
|
250
250
|
position += 8;
|
|
251
251
|
return value
|
|
252
252
|
}
|
|
253
|
-
if (
|
|
253
|
+
if (majorType > 1) {
|
|
254
|
+
if (dataView.getUint32(position) > 0)
|
|
255
|
+
throw new Error('JavaScript does not support arrays, maps, or strings with length over 4294967295')
|
|
256
|
+
token = dataView.getUint32(position + 4);
|
|
257
|
+
} else if (currentDecoder.int64AsNumber) {
|
|
254
258
|
token = dataView.getUint32(position) * 0x100000000;
|
|
255
259
|
token += dataView.getUint32(position + 4);
|
|
256
260
|
} else
|
|
@@ -430,21 +434,30 @@
|
|
|
430
434
|
}
|
|
431
435
|
}
|
|
432
436
|
// This initial function is quick to instantiate, but runs slower. After several iterations pay the cost to build the faster function
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
437
|
+
let compiledReader = this.compiledReader; // first look to see if we have the fast compiled function
|
|
438
|
+
while(compiledReader) {
|
|
439
|
+
// we have a fast compiled object literal reader
|
|
440
|
+
if (compiledReader.propertyCount === length)
|
|
441
|
+
return compiledReader(read) // with the right length, so we use it
|
|
442
|
+
compiledReader = compiledReader.next; // see if there is another reader with the right length
|
|
443
|
+
}
|
|
444
|
+
if (this.slowReads++ >= 3) { // create a fast compiled reader
|
|
445
|
+
let array = this.length == length ? this : this.slice(0, length);
|
|
446
|
+
compiledReader = currentDecoder.keyMap
|
|
447
|
+
? new Function('r', 'return {' + array.map(k => currentDecoder.decodeKey(k)).map(k => validName.test(k) ? k + ':r()' : ('[' + JSON.stringify(k) + ']:r()')).join(',') + '}')
|
|
448
|
+
: new Function('r', 'return {' + array.map(key => validName.test(key) ? key + ':r()' : ('[' + JSON.stringify(key) + ']:r()')).join(',') + '}');
|
|
449
|
+
if (this.compiledReader)
|
|
450
|
+
compiledReader.next = this.compiledReader; // if there is an existing one, we store multiple readers as a linked list because it is usually pretty rare to have multiple readers (of different length) for the same structure
|
|
451
|
+
compiledReader.propertyCount = length;
|
|
452
|
+
this.compiledReader = compiledReader;
|
|
453
|
+
return compiledReader(read)
|
|
441
454
|
}
|
|
442
455
|
let object = {};
|
|
443
456
|
if (currentDecoder.keyMap) for (let i = 0; i < length; i++) object[currentDecoder.decodeKey(this[i])] = read();
|
|
444
457
|
else for (let i = 0; i < length; i++) object[this[i]] = read();
|
|
445
458
|
return object
|
|
446
459
|
}
|
|
447
|
-
structure.
|
|
460
|
+
structure.slowReads = 0;
|
|
448
461
|
return readObject
|
|
449
462
|
}
|
|
450
463
|
|
|
@@ -722,11 +735,16 @@
|
|
|
722
735
|
return fraction[1] * Math.exp(fraction[0] * Math.log(2))
|
|
723
736
|
};
|
|
724
737
|
|
|
725
|
-
// the registration of the record definition extension
|
|
738
|
+
// the registration of the record definition extension
|
|
726
739
|
const recordDefinition = (definition) => {
|
|
727
740
|
let id = definition[0] - 0xe000;
|
|
728
741
|
let structure = definition[1];
|
|
742
|
+
let existingStructure = currentStructures[id];
|
|
743
|
+
if (existingStructure && existingStructure.isShared) {
|
|
744
|
+
(currentStructures.restoreStructures || (currentStructures.restoreStructures = []))[id] = existingStructure;
|
|
745
|
+
}
|
|
729
746
|
currentStructures[id] = structure;
|
|
747
|
+
|
|
730
748
|
structure.read = createStructureReader(structure);
|
|
731
749
|
let object = {};
|
|
732
750
|
if (currentDecoder.keyMap) for (let i = 2,l = definition.length; i < l; i++) {
|
|
@@ -870,6 +888,8 @@
|
|
|
870
888
|
version: input,
|
|
871
889
|
}
|
|
872
890
|
}
|
|
891
|
+
if (tag == 55799) // self-descriptive CBOR tag, just return input value
|
|
892
|
+
return input
|
|
873
893
|
});
|
|
874
894
|
|
|
875
895
|
const typedArrays = ['Uint8', 'Uint8Clamped', 'Uint16', 'Uint32', 'BigUint64','Int8', 'Int16', 'Int32', 'BigInt64', 'Float32', 'Float64'].map(type => type + 'Array');
|
|
@@ -1037,12 +1057,18 @@
|
|
|
1037
1057
|
} : false;
|
|
1038
1058
|
|
|
1039
1059
|
let encoder = this;
|
|
1040
|
-
let
|
|
1060
|
+
let hasSharedStructures = options.structures || options.saveStructures;
|
|
1061
|
+
let maxSharedStructures = options.maxSharedStructures;
|
|
1062
|
+
if (maxSharedStructures == null)
|
|
1063
|
+
maxSharedStructures = hasSharedStructures ? 128 : 0;
|
|
1064
|
+
if (maxSharedStructures > 8190)
|
|
1065
|
+
throw new Error('Maximum maxSharedStructure is 8190')
|
|
1041
1066
|
let isSequential = options.sequential;
|
|
1042
1067
|
if (isSequential) {
|
|
1043
1068
|
maxSharedStructures = 0;
|
|
1044
|
-
this.structures = [];
|
|
1045
1069
|
}
|
|
1070
|
+
if (!this.structures)
|
|
1071
|
+
this.structures = [];
|
|
1046
1072
|
if (this.saveStructures)
|
|
1047
1073
|
this.saveShared = this.saveStructures;
|
|
1048
1074
|
let samplingPackedValues, packedObjectMap, sharedValues = options.sharedValues;
|
|
@@ -1090,6 +1116,10 @@
|
|
|
1090
1116
|
} else if (encodeOptions === REUSE_BUFFER_MODE)
|
|
1091
1117
|
position$1 = (position$1 + 7) & 0x7ffffff8; // Word align to make any future copying of this buffer faster
|
|
1092
1118
|
start = position$1;
|
|
1119
|
+
if (encoder.useSelfDescribedHeader) {
|
|
1120
|
+
targetView.setUint32(position$1, 0xd9d9f700); // tag two byte, then self-descriptive tag
|
|
1121
|
+
position$1 += 3;
|
|
1122
|
+
}
|
|
1093
1123
|
referenceMap = encoder.structuredClone ? new Map() : null;
|
|
1094
1124
|
if (encoder.bundleStrings && typeof value !== 'string') {
|
|
1095
1125
|
bundledStrings$1 = [];
|
|
@@ -1123,6 +1153,8 @@
|
|
|
1123
1153
|
continue
|
|
1124
1154
|
let nextTransition, transition = sharedStructures.transitions;
|
|
1125
1155
|
for (let j = 0, l = keys.length; j < l; j++) {
|
|
1156
|
+
if (transition[RECORD_SYMBOL] === undefined)
|
|
1157
|
+
transition[RECORD_SYMBOL] = i;
|
|
1126
1158
|
let key = keys[j];
|
|
1127
1159
|
nextTransition = transition[key];
|
|
1128
1160
|
if (!nextTransition) {
|
|
@@ -1130,7 +1162,7 @@
|
|
|
1130
1162
|
}
|
|
1131
1163
|
transition = nextTransition;
|
|
1132
1164
|
}
|
|
1133
|
-
transition[RECORD_SYMBOL] = i;
|
|
1165
|
+
transition[RECORD_SYMBOL] = i | 0x100000;
|
|
1134
1166
|
}
|
|
1135
1167
|
}
|
|
1136
1168
|
if (!isSequential)
|
|
@@ -1182,11 +1214,13 @@
|
|
|
1182
1214
|
target.end = position$1;
|
|
1183
1215
|
return target
|
|
1184
1216
|
}
|
|
1185
|
-
return target.subarray(start, position$1) // position can change if we call
|
|
1217
|
+
return target.subarray(start, position$1) // position can change if we call encode again in saveShared, so we get the buffer now
|
|
1186
1218
|
} finally {
|
|
1187
1219
|
if (sharedStructures) {
|
|
1188
1220
|
if (serializationsSinceTransitionRebuild < 10)
|
|
1189
1221
|
serializationsSinceTransitionRebuild++;
|
|
1222
|
+
if (sharedStructures.length > maxSharedStructures)
|
|
1223
|
+
sharedStructures.length = maxSharedStructures;
|
|
1190
1224
|
if (transitionsCount > 10000) {
|
|
1191
1225
|
// force a rebuild occasionally after a lot of transitions so it can get cleaned up
|
|
1192
1226
|
sharedStructures.transitions = null;
|
|
@@ -1199,6 +1233,7 @@
|
|
|
1199
1233
|
recordIdsToRemove[i][RECORD_SYMBOL] = undefined;
|
|
1200
1234
|
}
|
|
1201
1235
|
recordIdsToRemove = [];
|
|
1236
|
+
//sharedStructures.nextId = maxSharedStructures
|
|
1202
1237
|
}
|
|
1203
1238
|
}
|
|
1204
1239
|
if (hasSharedUpdate && encoder.saveShared) {
|
|
@@ -1609,88 +1644,74 @@
|
|
|
1609
1644
|
target[objectOffset++ + start] = size >> 8;
|
|
1610
1645
|
target[objectOffset + start] = size & 0xff;
|
|
1611
1646
|
} :
|
|
1612
|
-
|
|
1613
|
-
/* sharedStructures ? // For highly stable structures, using for-in can a little bit faster
|
|
1614
1647
|
(object, safePrototype) => {
|
|
1615
|
-
let nextTransition, transition = structures.transitions || (structures.transitions = Object.create(null))
|
|
1616
|
-
let
|
|
1617
|
-
let
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1648
|
+
let nextTransition, transition = structures.transitions || (structures.transitions = Object.create(null));
|
|
1649
|
+
let newTransitions = 0;
|
|
1650
|
+
let length = 0;
|
|
1651
|
+
let parentRecordId;
|
|
1652
|
+
let keys;
|
|
1653
|
+
if (this.keyMap) {
|
|
1654
|
+
keys = Object.keys(object).map(k => this.encodeKey(k));
|
|
1655
|
+
length = keys.length;
|
|
1656
|
+
for (let i = 0; i < length; i++) {
|
|
1657
|
+
let key = keys[i];
|
|
1658
|
+
nextTransition = transition[key];
|
|
1621
1659
|
if (!nextTransition) {
|
|
1622
|
-
nextTransition = transition[key] = Object.create(null)
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
nextTransition.__keys__ = keys.slice(0, i + 1)
|
|
1634
|
-
}
|
|
1660
|
+
nextTransition = transition[key] = Object.create(null);
|
|
1661
|
+
newTransitions++;
|
|
1662
|
+
}
|
|
1663
|
+
transition = nextTransition;
|
|
1664
|
+
}
|
|
1665
|
+
} else {
|
|
1666
|
+
for (let key in object) if (safePrototype || object.hasOwnProperty(key)) {
|
|
1667
|
+
nextTransition = transition[key];
|
|
1668
|
+
if (!nextTransition) {
|
|
1669
|
+
if (transition[RECORD_SYMBOL] & 0x100000) {// this indicates it is a brancheable/extendable terminal node, so we will use this record id and extend it
|
|
1670
|
+
parentRecordId = transition[RECORD_SYMBOL] & 0xffff;
|
|
1635
1671
|
}
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
target.copy(target, )
|
|
1639
|
-
objectOffset
|
|
1672
|
+
nextTransition = transition[key] = Object.create(null);
|
|
1673
|
+
newTransitions++;
|
|
1640
1674
|
}
|
|
1641
|
-
transition = nextTransition
|
|
1642
|
-
|
|
1675
|
+
transition = nextTransition;
|
|
1676
|
+
length++;
|
|
1643
1677
|
}
|
|
1644
1678
|
}
|
|
1645
|
-
let id = transition.id
|
|
1646
|
-
if (!id) {
|
|
1647
|
-
id = transition.id = structures.push(transition.__keys__) + 63
|
|
1648
|
-
if (sharedStructures.onUpdate)
|
|
1649
|
-
sharedStructures.onUpdate(id, transition.__keys__)
|
|
1650
|
-
}
|
|
1651
|
-
target[objectOffset + start] = id
|
|
1652
|
-
}*/
|
|
1653
|
-
(object) => {
|
|
1654
|
-
let keys = Object.keys(object);
|
|
1655
|
-
let vals = Object.values(object);
|
|
1656
|
-
if (this.keyMap) keys = keys.map(k => this.encodeKey(k));
|
|
1657
|
-
let nextTransition, transition = structures.transitions || (structures.transitions = Object.create(null));
|
|
1658
|
-
let newTransitions = 0;
|
|
1659
|
-
let length = keys.length;
|
|
1660
|
-
//let parentRecordId
|
|
1661
|
-
for (let i = 0; i < length; i++) {
|
|
1662
|
-
//if (!parentRecordId)
|
|
1663
|
-
let key = keys[i];
|
|
1664
|
-
// parentRecordId = transition[RECORD_SYMBOL]
|
|
1665
|
-
nextTransition = transition[key];
|
|
1666
|
-
if (!nextTransition) {
|
|
1667
|
-
nextTransition = transition[key] = Object.create(null);
|
|
1668
|
-
newTransitions++;
|
|
1669
|
-
}
|
|
1670
|
-
transition = nextTransition;
|
|
1671
|
-
}
|
|
1672
1679
|
let recordId = transition[RECORD_SYMBOL];
|
|
1673
1680
|
if (recordId !== undefined) {
|
|
1681
|
+
recordId &= 0xffff;
|
|
1674
1682
|
target[position$1++] = 0xd9;
|
|
1675
1683
|
target[position$1++] = (recordId >> 8) | 0xe0;
|
|
1676
1684
|
target[position$1++] = recordId & 0xff;
|
|
1677
1685
|
} else {
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
structures.nextId
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1686
|
+
if (!keys)
|
|
1687
|
+
keys = transition.__keys__ || (transition.__keys__ = Object.keys(object));
|
|
1688
|
+
if (parentRecordId === undefined) {
|
|
1689
|
+
recordId = structures.nextId++;
|
|
1690
|
+
if (!recordId) {
|
|
1691
|
+
recordId = 0;
|
|
1692
|
+
structures.nextId = 1;
|
|
1693
|
+
}
|
|
1694
|
+
if (recordId >= MAX_STRUCTURES) {// cycle back around
|
|
1695
|
+
structures.nextId = (recordId = maxSharedStructures) + 1;
|
|
1696
|
+
}
|
|
1697
|
+
} else {
|
|
1698
|
+
recordId = parentRecordId;
|
|
1685
1699
|
}
|
|
1686
|
-
transition[RECORD_SYMBOL] = recordId;
|
|
1687
1700
|
structures[recordId] = keys;
|
|
1688
|
-
if (
|
|
1701
|
+
if (recordId < maxSharedStructures) {
|
|
1689
1702
|
target[position$1++] = 0xd9;
|
|
1690
1703
|
target[position$1++] = (recordId >> 8) | 0xe0;
|
|
1691
1704
|
target[position$1++] = recordId & 0xff;
|
|
1705
|
+
transition = structures.transitions;
|
|
1706
|
+
for (let i = 0; i < length; i++) {
|
|
1707
|
+
if (transition[RECORD_SYMBOL] === undefined || (transition[RECORD_SYMBOL] & 0x100000))
|
|
1708
|
+
transition[RECORD_SYMBOL] = recordId;
|
|
1709
|
+
transition = transition[keys[i]];
|
|
1710
|
+
}
|
|
1711
|
+
transition[RECORD_SYMBOL] = recordId | 0x100000; // indicates it is a extendable terminal
|
|
1692
1712
|
hasSharedUpdate = true;
|
|
1693
1713
|
} else {
|
|
1714
|
+
transition[RECORD_SYMBOL] = recordId;
|
|
1694
1715
|
targetView.setUint32(position$1, 0xd9dfff00); // tag two byte, then record definition id
|
|
1695
1716
|
position$1 += 3;
|
|
1696
1717
|
if (newTransitions)
|
|
@@ -1711,7 +1732,9 @@
|
|
|
1711
1732
|
} else {
|
|
1712
1733
|
writeArrayHeader(length);
|
|
1713
1734
|
}
|
|
1714
|
-
for (let
|
|
1735
|
+
for (let key in object)
|
|
1736
|
+
if (safePrototype || object.hasOwnProperty(key))
|
|
1737
|
+
encode(object[key]);
|
|
1715
1738
|
};
|
|
1716
1739
|
const makeRoom = (end) => {
|
|
1717
1740
|
let newSize;
|
|
@@ -1750,15 +1773,22 @@
|
|
|
1750
1773
|
updateSharedData() {
|
|
1751
1774
|
let lastVersion = this.sharedVersion || 0;
|
|
1752
1775
|
this.sharedVersion = lastVersion + 1;
|
|
1753
|
-
let
|
|
1776
|
+
let structuresCopy = this.structures.slice(0);
|
|
1777
|
+
let sharedData = new SharedData(structuresCopy, this.sharedValues, this.sharedVersion);
|
|
1778
|
+
let saveResults = this.saveShared(sharedData,
|
|
1754
1779
|
existingShared => (existingShared && existingShared.version || 0) == lastVersion);
|
|
1755
1780
|
if (saveResults === false) {
|
|
1756
1781
|
// get updated structures and try again if the update failed
|
|
1757
|
-
|
|
1782
|
+
sharedData = this.getShared() || {};
|
|
1758
1783
|
this.structures = sharedData.structures || [];
|
|
1759
1784
|
this.sharedValues = sharedData.packedValues;
|
|
1760
1785
|
this.sharedVersion = sharedData.version;
|
|
1786
|
+
this.structures.nextId = this.structures.length;
|
|
1787
|
+
} else {
|
|
1788
|
+
// restore structures
|
|
1789
|
+
structuresCopy.forEach((structure, i) => this.structures[i] = structure);
|
|
1761
1790
|
}
|
|
1791
|
+
// saveShared may fail to write and reload, or may have reloaded to check compatibility and overwrite saved data, either way load the correct shared data
|
|
1762
1792
|
return saveResults
|
|
1763
1793
|
}
|
|
1764
1794
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["webpack://CBOR/webpack/universalModuleDefinition","webpack://CBOR/webpack/bootstrap","webpack://CBOR/./encode.js","webpack://CBOR/./decode.js","webpack://CBOR/./browser.js","webpack://CBOR/(webpack)/buildin/global.js"],"names":["root","factory","exports","module","define","amd","window","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","decoderModule","Decoder","mult10","typedArrays","textEncoder","extensions","extensionClasses","TextEncoder","error","hasNodeBuffer","Buffer","ByteArrayAllocate","allocUnsafeSlow","Uint8Array","ByteArray","target","targetView","safeEnd","position","RECORD_SYMBOL","copyBinary","source","targetOffset","offset","endOffset","writeExtBuffer","typedArray","type","encode","length","byteLength","byteOffset","buffer","from","writeBuffer","setUint32","copy","Encoder","options","start","sharedStructures","hasSharedUpdate","structures","referenceMap","super","this","lastSharedStructuresLength","encodeUtf8","utf8Write","string","maxBytes","encodeInto","subarray","written","encoder","maxSharedStructures","isSequential","sequential","recordIdsToRemove","transitionsCount","serializationsSinceTransitionRebuild","Error","DataView","structuredClone","Map","uninitialized","getStructures","sharedStructuresLength","transitions","keys","nextTransition","transition","nextId","idsToInsert","makeRoom","serialized","distanceToMove","lastEnd","sort","a","b","pop","id","copyWithin","insertIds","saveStructures","slice","headerSize","strLength","c1","c2","strPosition","charCodeAt","setUint16","useFloat32","xShifted","setFloat32","setFloat64","referee","push","set","constructor","writeObject","Array","size","entryValue","extension","tag","useRecords","variableMapSize","safePrototype","objectOffset","newTransitions","recordId","shift","concat","end","newSize","Math","max","newBuffer","Date","Set","RegExp","ArrayBuffer","getPrototypeOf","date","seconds","getTime","useTimestamp32","getMilliseconds","message","regex","flags","arrayBuffer","indexOf","addExtension","Class","unshift","decoder","src","srcEnd","TextDecoder","EMPTY_ARRAY","srcString","dataView","currentStructures","strings","stringPosition","currentDecoder","srcStringStart","srcStringEnd","currentExtensions","defaultOptions","mapsAsObjects","undefined","assign","continueReading","saveState","decode","read","token","majorType","val","byte0","byte1","half","exp","mant","Infinity","NaN","getFloat16","getUint16","getFloat32","multiplier","getUint32","getFloat64","uint64AsNumber","getBigUint64","copyBuffers","shortStringInJS","readFixedString","array","map","structure","createStructureReader","updatedStructures","splice","apply","isNaN","incomplete","getPosition","validName","readObject","count","Function","test","JSON","stringify","join","readStringJS","readString8","readString16","readString32","result","units","byte2","byte3","unit","fromCharCode","String","setExtractor","extractStrings","readString","headerLength","srcStringLength","e","f","g","h","j","k","glbl","global","dateString","epochSec","BigInt","data","refEntry","targetProperties","used","callback","savedSrcEnd","savedPosition","savedStringPosition","savedSrcStringStart","savedSrcStringEnd","savedSrcString","savedStrings","savedReferenceMap","savedSrc","savedStructures","savedDecoder","typeCode","typedArrayName","clearSource","floor","ALWAYS","DECIMAL_ROUND","DECIMAL_FIT"],"mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAc,KAAID,IAElBD,EAAW,KAAIC,IARjB,CASGK,QAAQ,WACX,O,YCTE,IAAIC,EAAmB,GAGvB,S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,QAAU,EAAQ,GAAYA,QACtCzC,EAAQgL,aAAe,EAAQ,GAAYA,aAC3C,IAAIlF,EAAU,IAAI9F,EAAQ6E,QAAQ,CAAEuE,YAAY,IAChDpJ,EAAQuM,OAASzG,EAAQyG,OACzBvM,EAAQoE,OAAS0B,EAAQ1B,OACzBlD,OAAOkL,OAAOpM,EAAS,CACtB+R,OAAO,EACPC,cAAe,EACfC,YAAa,K,cCTd,IAAI/B,EAGJA,EAAI,WACH,OAAO7K,KADJ,GAIJ,IAEC6K,EAAIA,GAAK,IAAIvB,SAAS,cAAb,GACR,MAAOqB,GAEc,iBAAX5P,SAAqB8P,EAAI9P,QAOrCH,EAAOD,QAAUkQ","file":"index.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"CBOR\"] = factory();\n\telse\n\t\troot[\"CBOR\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 2);\n","\"use strict\"\r\nlet decoderModule = require('./decode')\r\nlet Decoder = decoderModule.Decoder\r\nlet mult10 = decoderModule.mult10\r\nconst typedArrays = decoderModule.typedArrays\r\nlet textEncoder\r\ntry {\r\n\ttextEncoder = new TextEncoder()\r\n} catch (error) {}\r\nlet extensions, extensionClasses\r\nconst hasNodeBuffer = typeof Buffer !== 'undefined'\r\nconst ByteArrayAllocate = hasNodeBuffer ? Buffer.allocUnsafeSlow : Uint8Array\r\nconst ByteArray = hasNodeBuffer ? Buffer : Uint8Array\r\nlet target\r\nlet targetView\r\nlet position = 0\r\nlet safeEnd\r\nconst RECORD_SYMBOL = Symbol('record-id')\r\nclass Encoder extends Decoder {\r\n\tconstructor(options) {\r\n\t\tsuper(options)\r\n\t\tthis.offset = 0\r\n\t\tlet typeBuffer\r\n\t\tlet start\r\n\t\tlet sharedStructures\r\n\t\tlet hasSharedUpdate\r\n\t\tlet structures\r\n\t\tlet referenceMap\r\n\t\tlet lastSharedStructuresLength = 0\r\n\t\tlet encodeUtf8 = ByteArray.prototype.utf8Write ? function(string, position, maxBytes) {\r\n\t\t\treturn target.utf8Write(string, position, maxBytes)\r\n\t\t} : (textEncoder && textEncoder.encodeInto) ?\r\n\t\t\tfunction(string, position) {\r\n\t\t\t\treturn textEncoder.encodeInto(string, target.subarray(position)).written\r\n\t\t\t} : false\r\n\r\n\t\tlet encoder = this\r\n\t\tlet maxSharedStructures = 64\r\n\t\tlet isSequential = options && options.sequential\r\n\t\tif (isSequential) {\r\n\t\t\tmaxSharedStructures = 0\r\n\t\t\tthis.structures = []\r\n\t\t}\r\n\t\tlet recordIdsToRemove = []\r\n\t\tlet transitionsCount = 0\r\n\t\tlet serializationsSinceTransitionRebuild = 0\r\n\t\tif (this.structures && this.structures.length > maxSharedStructures) {\r\n\t\t\tthrow new Error('Too many shared structures')\r\n\t\t}\r\n\r\n\t\tthis.encode = function(value) {\r\n\t\t\tif (!target) {\r\n\t\t\t\ttarget = new ByteArrayAllocate(8192)\r\n\t\t\t\ttargetView = new DataView(target.buffer, 0, 8192)\r\n\t\t\t\tposition = 0\r\n\t\t\t}\r\n\t\t\tsafeEnd = target.length - 10\r\n\t\t\tif (safeEnd - position < 0x800) {\r\n\t\t\t\t// don't start too close to the end, \r\n\t\t\t\ttarget = new ByteArrayAllocate(target.length)\r\n\t\t\t\ttargetView = new DataView(target.buffer, 0, target.length)\r\n\t\t\t\tsafeEnd = target.length - 10\r\n\t\t\t\tposition = 0\r\n\t\t\t}\r\n\t\t\tstart = position\r\n\t\t\treferenceMap = encoder.structuredClone ? new Map() : null\r\n\t\t\tsharedStructures = encoder.structures\r\n\t\t\tif (sharedStructures) {\r\n\t\t\t\tif (sharedStructures.uninitialized)\r\n\t\t\t\t\tencoder.structures = sharedStructures = encoder.getStructures()\r\n\t\t\t\tlet sharedStructuresLength = sharedStructures.length\r\n\t\t\t\tif (sharedStructuresLength > maxSharedStructures && !isSequential)\r\n\t\t\t\t\tsharedStructuresLength = maxSharedStructures\r\n\t\t\t\tif (!sharedStructures.transitions) {\r\n\t\t\t\t\t// rebuild our structure transitions\r\n\t\t\t\t\tsharedStructures.transitions = Object.create(null)\r\n\t\t\t\t\tfor (let i = 0; i < sharedStructuresLength; i++) {\r\n\t\t\t\t\t\tlet keys = sharedStructures[i]\r\n\t\t\t\t\t\tif (!keys)\r\n\t\t\t\t\t\t\tcontinue\r\n\t\t\t\t\t\tlet nextTransition, transition = sharedStructures.transitions\r\n\t\t\t\t\t\tfor (let i =0, l = keys.length; i < l; i++) {\r\n\t\t\t\t\t\t\tlet key = keys[i]\r\n\t\t\t\t\t\t\tnextTransition = transition[key]\r\n\t\t\t\t\t\t\tif (!nextTransition) {\r\n\t\t\t\t\t\t\t\tnextTransition = transition[key] = Object.create(null)\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\ttransition = nextTransition\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\ttransition[RECORD_SYMBOL] = i + 0x40\r\n\t\t\t\t\t}\r\n\t\t\t\t\tlastSharedStructuresLength = sharedStructures.length\r\n\t\t\t\t}\r\n\t\t\t\tif (!isSequential)\r\n\t\t\t\t\tsharedStructures.nextId = sharedStructuresLength + 0x40\r\n\t\t\t}\r\n\t\t\tif (hasSharedUpdate)\r\n\t\t\t\thasSharedUpdate = false\r\n\t\t\tstructures = sharedStructures || []\r\n\t\t\ttry {\r\n\t\t\t\tencode(value)\r\n\t\t\t\tencoder.offset = position // update the offset so next serialization doesn't write over our buffer, but can continue writing to same buffer sequentially\r\n\t\t\t\tif (referenceMap && referenceMap.idsToInsert) {\r\n\t\t\t\t\tposition += referenceMap.idsToInsert.length * 6\r\n\t\t\t\t\tif (position > safeEnd)\r\n\t\t\t\t\t\tmakeRoom(position)\r\n\t\t\t\t\tencoder.offset = position\r\n\t\t\t\t\tlet serialized = insertIds(target.subarray(start, position), referenceMap.idsToInsert)\r\n\t\t\t\t\treferenceMap = null\r\n\t\t\t\t\treturn serialized\r\n\t\t\t\t}\r\n\t\t\t\treturn target.subarray(start, position) // position can change if we call encode again in saveStructures, so we get the buffer now\r\n\t\t\t} finally {\r\n\t\t\t\tif (sharedStructures) {\r\n\t\t\t\t\tif (serializationsSinceTransitionRebuild < 10)\r\n\t\t\t\t\t\tserializationsSinceTransitionRebuild++\r\n\t\t\t\t\tif (transitionsCount > 10000) {\r\n\t\t\t\t\t\t// force a rebuild occasionally after a lot of transitions so it can get cleaned up\r\n\t\t\t\t\t\tsharedStructures.transitions = null\r\n\t\t\t\t\t\tserializationsSinceTransitionRebuild = 0\r\n\t\t\t\t\t\ttransitionsCount = 0\r\n\t\t\t\t\t\tif (recordIdsToRemove.length > 0)\r\n\t\t\t\t\t\t\trecordIdsToRemove = []\r\n\t\t\t\t\t} else if (recordIdsToRemove.length > 0 && !isSequential) {\r\n\t\t\t\t\t\tfor (let i = 0, l = recordIdsToRemove.length; i < l; i++) {\r\n\t\t\t\t\t\t\trecordIdsToRemove[i][RECORD_SYMBOL] = 0\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\trecordIdsToRemove = []\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif (hasSharedUpdate && encoder.saveStructures) {\r\n\t\t\t\t\t\tif (encoder.structures.length > maxSharedStructures) {\r\n\t\t\t\t\t\t\tencoder.structures = encoder.structures.slice(0, maxSharedStructures)\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\tif (encoder.saveStructures(encoder.structures, lastSharedStructuresLength) === false) {\r\n\t\t\t\t\t\t\t// get updated structures and try again if the update failed\r\n\t\t\t\t\t\t\tencoder.structures = encoder.getStructures() || []\r\n\t\t\t\t\t\t\treturn encoder.encode(value)\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tlastSharedStructuresLength = encoder.structures.length\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tconst encode = (value) => {\r\n\t\t\tif (position > safeEnd)\r\n\t\t\t\ttarget = makeRoom(position)\r\n\r\n\t\t\tvar type = typeof value\r\n\t\t\tvar length\r\n\t\t\tif (type === 'string') {\r\n\t\t\t\tlet strLength = value.length\r\n\t\t\t\tlet headerSize\r\n\t\t\t\t// first we estimate the header size, so we can write to the correct location\r\n\t\t\t\tif (strLength < 0x20) {\r\n\t\t\t\t\theaderSize = 1\r\n\t\t\t\t} else if (strLength < 0x100) {\r\n\t\t\t\t\theaderSize = 2\r\n\t\t\t\t} else if (strLength < 0x10000) {\r\n\t\t\t\t\theaderSize = 3\r\n\t\t\t\t} else {\r\n\t\t\t\t\theaderSize = 5\r\n\t\t\t\t}\r\n\t\t\t\tlet maxBytes = strLength * 3\r\n\t\t\t\tif (position + maxBytes > safeEnd)\r\n\t\t\t\t\ttarget = makeRoom(position + maxBytes)\r\n\r\n\t\t\t\tif (strLength < 0x40 || !encodeUtf8) {\r\n\t\t\t\t\tlet i, c1, c2, strPosition = position + headerSize\r\n\t\t\t\t\tfor (i = 0; i < strLength; i++) {\r\n\t\t\t\t\t\tc1 = value.charCodeAt(i)\r\n\t\t\t\t\t\tif (c1 < 0x80) {\r\n\t\t\t\t\t\t\ttarget[strPosition++] = c1\r\n\t\t\t\t\t\t} else if (c1 < 0x800) {\r\n\t\t\t\t\t\t\ttarget[strPosition++] = c1 >> 6 | 0xc0\r\n\t\t\t\t\t\t\ttarget[strPosition++] = c1 & 0x3f | 0x80\r\n\t\t\t\t\t\t} else if (\r\n\t\t\t\t\t\t\t(c1 & 0xfc00) === 0xd800 &&\r\n\t\t\t\t\t\t\t((c2 = value.charCodeAt(i + 1)) & 0xfc00) === 0xdc00\r\n\t\t\t\t\t\t) {\r\n\t\t\t\t\t\t\tc1 = 0x10000 + ((c1 & 0x03ff) << 10) + (c2 & 0x03ff)\r\n\t\t\t\t\t\t\ti++\r\n\t\t\t\t\t\t\ttarget[strPosition++] = c1 >> 18 | 0xf0\r\n\t\t\t\t\t\t\ttarget[strPosition++] = c1 >> 12 & 0x3f | 0x80\r\n\t\t\t\t\t\t\ttarget[strPosition++] = c1 >> 6 & 0x3f | 0x80\r\n\t\t\t\t\t\t\ttarget[strPosition++] = c1 & 0x3f | 0x80\r\n\t\t\t\t\t\t} else {\r\n\t\t\t\t\t\t\ttarget[strPosition++] = c1 >> 12 | 0xe0\r\n\t\t\t\t\t\t\ttarget[strPosition++] = c1 >> 6 & 0x3f | 0x80\r\n\t\t\t\t\t\t\ttarget[strPosition++] = c1 & 0x3f | 0x80\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tlength = strPosition - position - headerSize\r\n\t\t\t\t} else {\r\n\t\t\t\t\tlength = encodeUtf8(value, position + headerSize, maxBytes)\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (length < 0x18) {\r\n\t\t\t\t\ttarget[position++] = 0x60 | length\r\n\t\t\t\t} else if (length < 0x100) {\r\n\t\t\t\t\tif (headerSize < 2) {\r\n\t\t\t\t\t\ttarget.copyWithin(position + 2, position + 1, position + 1 + length)\r\n\t\t\t\t\t}\r\n\t\t\t\t\ttarget[position++] = 0x78\r\n\t\t\t\t\ttarget[position++] = length\r\n\t\t\t\t} else if (length < 0x10000) {\r\n\t\t\t\t\tif (headerSize < 3) {\r\n\t\t\t\t\t\ttarget.copyWithin(position + 3, position + 2, position + 2 + length)\r\n\t\t\t\t\t}\r\n\t\t\t\t\ttarget[position++] = 0x79\r\n\t\t\t\t\ttarget[position++] = length >> 8\r\n\t\t\t\t\ttarget[position++] = length & 0xff\r\n\t\t\t\t} else {\r\n\t\t\t\t\tif (headerSize < 5) {\r\n\t\t\t\t\t\ttarget.copyWithin(position + 5, position + 3, position + 3 + length)\r\n\t\t\t\t\t}\r\n\t\t\t\t\ttarget[position++] = 0x7a\r\n\t\t\t\t\ttargetView.setUint32(position, length)\r\n\t\t\t\t\tposition += 4\r\n\t\t\t\t}\r\n\t\t\t\tposition += length\r\n\t\t\t} else if (type === 'number') {\r\n\t\t\t\tif (value >>> 0 === value) {// positive integer, 32-bit or less\r\n\t\t\t\t\t// positive uint\r\n\t\t\t\t\tif (value < 0x18) {\r\n\t\t\t\t\t\ttarget[position++] = value\r\n\t\t\t\t\t} else if (value < 0x100) {\r\n\t\t\t\t\t\ttarget[position++] = 0x18\r\n\t\t\t\t\t\ttarget[position++] = value\r\n\t\t\t\t\t} else if (value < 0x10000) {\r\n\t\t\t\t\t\ttarget[position++] = 0x19\r\n\t\t\t\t\t\ttarget[position++] = value >> 8\r\n\t\t\t\t\t\ttarget[position++] = value & 0xff\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\ttarget[position++] = 0x1a\r\n\t\t\t\t\t\ttargetView.setUint32(position, value)\r\n\t\t\t\t\t\tposition += 4\r\n\t\t\t\t\t}\r\n\t\t\t\t} else if (value >> 0 === value) { // negative integer\r\n\t\t\t\t\tif (value >= -0x18) {\r\n\t\t\t\t\t\ttarget[position++] = 0x1f - value\r\n\t\t\t\t\t} else if (value >= -0x100) {\r\n\t\t\t\t\t\ttarget[position++] = 0x38\r\n\t\t\t\t\t\ttarget[position++] = ~value\r\n\t\t\t\t\t} else if (value >= -0x10000) {\r\n\t\t\t\t\t\ttarget[position++] = 0x39\r\n\t\t\t\t\t\ttargetView.setUint16(position, ~value)\r\n\t\t\t\t\t\tposition += 2\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\ttarget[position++] = 0x3a\r\n\t\t\t\t\t\ttargetView.setUint32(position, ~value)\r\n\t\t\t\t\t\tposition += 4\r\n\t\t\t\t\t}\r\n\t\t\t\t} else {\r\n\t\t\t\t\tlet useFloat32\r\n\t\t\t\t\tif ((useFloat32 = this.useFloat32) > 0 && value < 0x100000000 && value >= -0x80000000) {\r\n\t\t\t\t\t\ttarget[position++] = 0xfa\r\n\t\t\t\t\t\ttargetView.setFloat32(position, value)\r\n\t\t\t\t\t\tlet xShifted\r\n\t\t\t\t\t\tif (useFloat32 < 4 ||\r\n\t\t\t\t\t\t\t// this checks for rounding of numbers that were encoded in 32-bit float to nearest significant decimal digit that could be preserved\r\n\t\t\t\t\t\t\t\t((xShifted = value * mult10[((target[position] & 0x7f) << 1) | (target[position + 1] >> 7)]) >> 0) === xShifted) {\r\n\t\t\t\t\t\t\tposition += 4\r\n\t\t\t\t\t\t\treturn\r\n\t\t\t\t\t\t} else\r\n\t\t\t\t\t\t\tposition-- // move back into position for writing a double\r\n\t\t\t\t\t}\r\n\t\t\t\t\ttarget[position++] = 0xfb\r\n\t\t\t\t\ttargetView.setFloat64(position, value)\r\n\t\t\t\t\t/*if (!target[position[4] && !target[position[5] && !target[position[6] && !target[position[7] && !(target[0] & 0x78) < ) {\r\n\t\t\t\t\t\t// something like this can be represented as a float with binary rounding\r\n\t\t\t\t\t}*/\r\n\t\t\t\t\tposition += 8\r\n\t\t\t\t}\r\n\t\t\t} else if (type === 'object') {\r\n\t\t\t\tif (!value)\r\n\t\t\t\t\ttarget[position++] = 0xf6\r\n\t\t\t\telse {\r\n\t\t\t\t\tif (referenceMap) {\r\n\t\t\t\t\t\tlet referee = referenceMap.get(value)\r\n\t\t\t\t\t\tif (referee) {\r\n\t\t\t\t\t\t\tif (!referee.id) {\r\n\t\t\t\t\t\t\t\tlet idsToInsert = referenceMap.idsToInsert || (referenceMap.idsToInsert = [])\r\n\t\t\t\t\t\t\t\treferee.id = idsToInsert.push(referee)\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\ttarget[position++] = 0xca // tag 10\r\n\t\t\t\t\t\t\ttarget[position++] = 0x1a // uint32\r\n\t\t\t\t\t\t\ttargetView.setUint32(position, referee.id)\r\n\t\t\t\t\t\t\tposition += 4\r\n\t\t\t\t\t\t\treturn\r\n\t\t\t\t\t\t} else \r\n\t\t\t\t\t\t\treferenceMap.set(value, { offset: position - start })\r\n\t\t\t\t\t}\r\n\t\t\t\t\tlet constructor = value.constructor\r\n\t\t\t\t\tif (constructor === Object) {\r\n\t\t\t\t\t\twriteObject(value, true)\r\n\t\t\t\t\t} else if (constructor === Array) {\r\n\t\t\t\t\t\tlength = value.length\r\n\t\t\t\t\t\tif (length < 0x18) {\r\n\t\t\t\t\t\t\ttarget[position++] = 0x80 | length\r\n\t\t\t\t\t\t} else if (length < 0x100) {\r\n\t\t\t\t\t\t\ttarget[position++] = 0x98\r\n\t\t\t\t\t\t\ttarget[position++] = length\r\n\t\t\t\t\t\t} else if (length < 0x10000) {\r\n\t\t\t\t\t\t\ttarget[position++] = 0x99\r\n\t\t\t\t\t\t\ttarget[position++] = length >> 8\r\n\t\t\t\t\t\t\ttarget[position++] = length & 0xff\r\n\t\t\t\t\t\t} else {\r\n\t\t\t\t\t\t\ttarget[position++] = 0x9a\r\n\t\t\t\t\t\t\ttargetView.setUint32(position, length)\r\n\t\t\t\t\t\t\tposition += 4\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tfor (let i = 0; i < length; i++) {\r\n\t\t\t\t\t\t\tencode(value[i])\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t} else if (constructor === Map) {\r\n\t\t\t\t\t\tlength = value.size\r\n\t\t\t\t\t\tif (length < 0x18) {\r\n\t\t\t\t\t\t\ttarget[position++] = 0xa0 | length\r\n\t\t\t\t\t\t} else if (length < 0x100) {\r\n\t\t\t\t\t\t\ttarget[position++] = 0xb8\r\n\t\t\t\t\t\t\ttarget[position++] = length\r\n\t\t\t\t\t\t} else if (length < 0x10000) {\r\n\t\t\t\t\t\t\ttarget[position++] = 0xb9\r\n\t\t\t\t\t\t\ttarget[position++] = length >> 8\r\n\t\t\t\t\t\t\ttarget[position++] = length & 0xff\r\n\t\t\t\t\t\t} else {\r\n\t\t\t\t\t\t\ttarget[position++] = 0xba\r\n\t\t\t\t\t\t\ttargetView.setUint32(position, length)\r\n\t\t\t\t\t\t\tposition += 4\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tfor (let [ key, entryValue ] of value) {\r\n\t\t\t\t\t\t\tencode(key)\r\n\t\t\t\t\t\t\tencode(entryValue)\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t} else {\t\r\n\t\t\t\t\t\tfor (let i = 0, l = extensions.length; i < l; i++) {\r\n\t\t\t\t\t\t\tlet extensionClass = extensionClasses[i]\r\n\t\t\t\t\t\t\tif (value instanceof extensionClass) {\r\n\t\t\t\t\t\t\t\tlet extension = extensions[i]\r\n\t\t\t\t\t\t\t\tlet tag = extension.tag\r\n\t\t\t\t\t\t\t\tif (tag < 0x18) {\r\n\t\t\t\t\t\t\t\t\ttarget[position++] = 0xc0 | tag\r\n\t\t\t\t\t\t\t\t} else if (tag < 0x100) {\r\n\t\t\t\t\t\t\t\t\ttarget[position++] = 0xd8\r\n\t\t\t\t\t\t\t\t\ttarget[position++] = tag\r\n\t\t\t\t\t\t\t\t} else if (tag < 0x10000) {\r\n\t\t\t\t\t\t\t\t\ttarget[position++] = 0xd9\r\n\t\t\t\t\t\t\t\t\ttarget[position++] = tag >> 8\r\n\t\t\t\t\t\t\t\t\ttarget[position++] = tag & 0xff\r\n\t\t\t\t\t\t\t\t} else if (tag > -1) {\r\n\t\t\t\t\t\t\t\t\ttarget[position++] = 0xba\r\n\t\t\t\t\t\t\t\t\ttargetView.setUint32(position, tag)\r\n\t\t\t\t\t\t\t\t\tposition += 4\r\n\t\t\t\t\t\t\t\t} // else undefined, don't write tag\r\n\t\t\t\t\t\t\t\textension.encode.call(this, value, encode)\r\n\t\t\t\t\t\t\t\treturn\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t// no extension found, write as object\r\n\t\t\t\t\t\twriteObject(value, false)\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t} else if (type === 'boolean') {\r\n\t\t\t\ttarget[position++] = value ? 0xf5 : 0xf4\r\n\t\t\t} else if (type === 'bigint') {\r\n\t\t\t\ttarget[position++] = 0xfb\r\n\t\t\t\t/*if (value < 9223372036854776000 && value > -9223372036854776000) \r\n\t\t\t\t\ttargetView.setBigInt64(position, value)\r\n\t\t\t\telse*/\r\n\t\t\t\t\ttargetView.setFloat64(position, value)\r\n\t\t\t\tposition += 8\r\n\t\t\t} else if (type === 'undefined') {\r\n\t\t\t\t//target[position++] = 0xc1 // this is the \"never-used\" byte\r\n\t\t\t\ttarget[position++] = 0xf7\r\n\t\t\t} else {\r\n\t\t\t\tthrow new Error('Unknown type ' + type)\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tconst writeObject = this.useRecords === false ? this.variableMapSize ? (object) => {\r\n\t\t\tlet keys = Object.keys(object)\r\n\t\t\tlet length = keys.length\r\n\t\t\tif (length < 0x18) {\r\n\t\t\t\ttarget[position++] = 0xa0 | length\r\n\t\t\t} else if (length < 0x100) {\r\n\t\t\t\ttarget[position++] = 0xb8\r\n\t\t\t\ttarget[position++] = length\r\n\t\t\t} else if (length < 0x10000) {\r\n\t\t\t\ttarget[position++] = 0xb9\r\n\t\t\t\ttarget[position++] = length >> 8\r\n\t\t\t\ttarget[position++] = length & 0xff\r\n\t\t\t} else {\r\n\t\t\t\ttarget[position++] = 0xba\r\n\t\t\t\ttargetView.setUint32(position, length)\r\n\t\t\t\tposition += 4\r\n\t\t\t}\r\n\t\t\tlet key\r\n\t\t\tfor (let i = 0; i < length; i++) {\r\n\t\t\t\tencode(key = keys[i])\r\n\t\t\t\tencode(object[key])\r\n\t\t\t}\r\n\t\t} :\r\n\t\t(object, safePrototype) => {\r\n\t\t\ttarget[position++] = 0xb9 // always use map 16, so we can preallocate and set the length afterwards\r\n\t\t\tlet objectOffset = position - start\r\n\t\t\tposition += 2\r\n\t\t\tlet size = 0\r\n\t\t\tfor (let key in object) {\r\n\t\t\t\tif (safePrototype || object.hasOwnProperty(key)) {\r\n\t\t\t\t\tencode(key)\r\n\t\t\t\t\tencode(object[key])\r\n\t\t\t\t\tsize++\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\ttarget[objectOffset++ + start] = size >> 8\r\n\t\t\ttarget[objectOffset + start] = size & 0xff\r\n\t\t} :\r\n\r\n\t/*\tsharedStructures ? // For highly stable structures, using for-in can a little bit faster\r\n\t\t(object, safePrototype) => {\r\n\t\t\tlet nextTransition, transition = structures.transitions || (structures.transitions = Object.create(null))\r\n\t\t\tlet objectOffset = position++ - start\r\n\t\t\tlet wroteKeys\r\n\t\t\tfor (let key in object) {\r\n\t\t\t\tif (safePrototype || object.hasOwnProperty(key)) {\r\n\t\t\t\t\tnextTransition = transition[key]\r\n\t\t\t\t\tif (!nextTransition) {\r\n\t\t\t\t\t\tnextTransition = transition[key] = Object.create(null)\r\n\t\t\t\t\t\tnextTransition.__keys__ = (transition.__keys__ || []).concat([key])\r\n\t\t\t\t\t\t/*let keys = Object.keys(object)\r\n\t\t\t\t\t\tif \r\n\t\t\t\t\t\tlet size = 0\r\n\t\t\t\t\t\tlet startBranch = transition.__keys__ ? transition.__keys__.length : 0\r\n\t\t\t\t\t\tfor (let i = 0, l = keys.length; i++) {\r\n\t\t\t\t\t\t\tlet key = keys[i]\r\n\t\t\t\t\t\t\tsize += key.length << 2\r\n\t\t\t\t\t\t\tif (i >= startBranch) {\r\n\t\t\t\t\t\t\t\tnextTransition = nextTransition[key] = Object.create(null)\r\n\t\t\t\t\t\t\t\tnextTransition.__keys__ = keys.slice(0, i + 1)\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tmakeRoom(position + size)\r\n\t\t\t\t\t\tnextTransition = transition[key]\r\n\t\t\t\t\t\ttarget.copy(target, )\r\n\t\t\t\t\t\tobjectOffset\r\n\t\t\t\t\t}\r\n\t\t\t\t\ttransition = nextTransition\r\n\t\t\t\t\tencode(object[key])\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tlet id = transition.id\r\n\t\t\tif (!id) {\r\n\t\t\t\tid = transition.id = structures.push(transition.__keys__) + 63\r\n\t\t\t\tif (sharedStructures.onUpdate)\r\n\t\t\t\t\tsharedStructures.onUpdate(id, transition.__keys__)\r\n\t\t\t}\r\n\t\t\ttarget[objectOffset + start] = id\r\n\t\t}*/\r\n\t\t(object) => {\r\n\t\t\tlet keys = Object.keys(object)\r\n\t\t\tlet nextTransition, transition = structures.transitions || (structures.transitions = Object.create(null))\r\n\t\t\tlet newTransitions = 0\r\n\t\t\tfor (let i =0, l = keys.length; i < l; i++) {\r\n\t\t\t\tlet key = keys[i]\r\n\t\t\t\tnextTransition = transition[key]\r\n\t\t\t\tif (!nextTransition) {\r\n\t\t\t\t\tnextTransition = transition[key] = Object.create(null)\r\n\t\t\t\t\tnewTransitions++\r\n\t\t\t\t}\r\n\t\t\t\ttransition = nextTransition\r\n\t\t\t}\r\n\t\t\tlet recordId = transition[RECORD_SYMBOL]\r\n\t\t\tif (recordId) {\r\n\t\t\t\ttarget[position++] = 0xd8 // tag one byte\r\n\t\t\t\ttarget[position++] = recordId\r\n\t\t\t} else {\r\n\t\t\t\trecordId = structures.nextId++\r\n\t\t\t\tif (!recordId) {\r\n\t\t\t\t\trecordId = 0x40\r\n\t\t\t\t\tstructures.nextId = 0x41\r\n\t\t\t\t}\r\n\t\t\t\tif (recordId >= 0x100) {// cycle back around\r\n\t\t\t\t\tstructures.nextId = (recordId = maxSharedStructures + 0x40) + 1\r\n\t\t\t\t}\r\n\t\t\t\ttransition[RECORD_SYMBOL] = recordId\r\n\t\t\t\tstructures[recordId - 0x40] = keys\r\n\t\t\t\tif (sharedStructures && sharedStructures.length <= maxSharedStructures) {\r\n\t\t\t\t\ttarget[position++] = 0xd8 // tag one byte\r\n\t\t\t\t\ttarget[position++] = recordId // tag number\r\n\t\t\t\t\thasSharedUpdate = true\r\n\t\t\t\t} else {\r\n\t\t\t\t\ttarget[position++] = 0xc6 // tag 6\r\n\t\t\t\t\tif (newTransitions)\r\n\t\t\t\t\t\ttransitionsCount += serializationsSinceTransitionRebuild * newTransitions\r\n\t\t\t\t\t// record the removal of the id, we can maintain our shared structure\r\n\t\t\t\t\tif (recordIdsToRemove.length >= 0xc0 - maxSharedStructures)\r\n\t\t\t\t\t\trecordIdsToRemove.shift()[RECORD_SYMBOL] = 0 // we are cycling back through, and have to remove old ones\r\n\t\t\t\t\trecordIdsToRemove.push(transition)\r\n\t\t\t\t\tencode([ recordId ].concat(keys))\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t// now write the values\r\n\t\t\tfor (let i =0, l = keys.length; i < l; i++)\r\n\t\t\t\tencode(object[keys[i]])\r\n\t\t}\r\n\t\tconst makeRoom = (end) => {\r\n\t\t\tlet newSize = ((Math.max((end - start) << 2, target.length - 1) >> 12) + 1) << 12\r\n\t\t\tlet newBuffer = new ByteArrayAllocate(newSize)\r\n\t\t\ttargetView = new DataView(newBuffer.buffer, 0, newSize)\r\n\t\t\tif (target.copy)\r\n\t\t\t\ttarget.copy(newBuffer, 0, start, end)\r\n\t\t\telse\r\n\t\t\t\tcopyBinary(target, newBuffer, 0, start, end)\r\n\t\t\tposition -= start\r\n\t\t\tstart = 0\r\n\t\t\tsafeEnd = newBuffer.length - 10\r\n\t\t\treturn target = newBuffer\r\n\t\t}\r\n\t}\r\n\tuseBuffer(buffer) {\r\n\t\t// this means we are finished using our own buffer and we can write over it safely\r\n\t\ttarget = buffer\r\n\t\ttargetView = new DataView(target.buffer, target.byteOffset, target.byteLength)\r\n\t\tposition = 0\r\n\t}\r\n}\r\nexports.Encoder = Encoder\r\n\r\nfunction copyBinary(source, target, targetOffset, offset, endOffset) {\r\n\twhile (offset < endOffset) {\r\n\t\ttarget[targetOffset++] = source[offset++]\r\n\t}\r\n}\r\n\r\nextensionClasses = [ Date, Set, Error, RegExp, ArrayBuffer, Object.getPrototypeOf(Uint8Array.prototype).constructor /*TypedArray*/ ]\r\nextensions = [{\r\n\ttag: 1,\r\n\tencode(date, encode) {\r\n\t\tlet seconds = date.getTime() / 1000\r\n\t\tif ((this.useTimestamp32 || date.getMilliseconds() === 0) && seconds >= 0 && seconds < 0x100000000) {\r\n\t\t\t// Timestamp 32\r\n\t\t\ttarget[position++] = 0x1a\r\n\t\t\ttargetView.setUint32(position, seconds)\r\n\t\t\tposition += 4\r\n\t\t} else {\r\n\t\t\t// Timestamp float64\r\n\t\t\ttarget[position++] = 0xfb\r\n\t\t\ttargetView.setFloat64(position, seconds)\r\n\t\t\tposition += 8\r\n\t\t}\r\n\t}\r\n}, {\r\n\ttag: 11,\r\n\tencode(set, encode) {\r\n\t\tlet array = Array.from(set)\r\n\t\tencode(array)\r\n\t}\r\n}, {\r\n\ttag: 8,\r\n\tencode(error, encode) {\r\n\t\tencode([ error.name, error.message ])\r\n\t}\r\n}, {\r\n\ttag: 13,\r\n\tencode(regex, encode) {\r\n\t\tencode([ regex.source, regex.flags ])\r\n\t}\r\n}, {\r\n\tencode(arrayBuffer, encode) {\r\n\t\tif (this.structuredClone)\r\n\t\t\twriteExtBuffer(arrayBuffer, 0x10, encode)\r\n\t\telse\r\n\t\t\twriteBuffer(hasNodeBuffer ? Buffer.from(arrayBuffer) : new Uint8Array(arrayBuffer))\r\n\t}\r\n}, {\r\n\tencode(typedArray, encode) {\r\n\t\tlet constructor = typedArray.constructor\r\n\t\tif (constructor !== ByteArray && this.structuredClone)\r\n\t\t\twriteExtBuffer(typedArray, typedArrays.indexOf(constructor.name), encode)\r\n\t\telse\r\n\t\t\twriteBuffer(typedArray)\r\n\t}\r\n}]\r\n\r\nfunction writeExtBuffer(typedArray, type, encode) {\r\n\ttarget[position++] = 0xcc // tag 12\r\n\tlet length = typedArray.byteLength\r\n\tlet offset = typedArray.byteOffset || 0\r\n\tlet buffer = typedArray.buffer || typedArray\r\n\tencode([type, hasNodeBuffer ? Buffer.from(buffer, offset, length) :\r\n\t\tnew Uint8Array(buffer, offset, length)])\r\n}\r\nfunction writeBuffer(buffer) {\r\n\tlet length = buffer.byteLength\r\n\tif (length < 0x100) {\r\n\t\ttarget[position++] = 0x58\r\n\t\ttarget[position++] = length\r\n\t} else if (length < 0x10000) {\r\n\t\ttarget[position++] = 0x59\r\n\t\ttarget[position++] = length >> 8\r\n\t\ttarget[position++] = length & 0xff\r\n\t} else {\r\n\t\ttarget[position++] = 0x5a\r\n\t\ttargetView.setUint32(position, length)\r\n\t\tposition += 4\r\n\t}\r\n\tif (buffer.copy)\r\n\t\tbuffer.copy(target, position)\r\n\telse\r\n\t\tcopyBinary(buffer, target, position, 0, length)\r\n\tposition += length\r\n}\r\n\r\nfunction writeExtensionData(result, target, position, type) {\r\n\tlet length = result.length\r\n\tswitch (length) {\r\n\t\tcase 1:\r\n\t\t\ttarget[position++] = 0xd4\r\n\t\t\tbreak\r\n\t\tcase 2:\r\n\t\t\ttarget[position++] = 0xd5\r\n\t\t\tbreak\r\n\t\tcase 4:\r\n\t\t\ttarget[position++] = 0xd6\r\n\t\t\tbreak\r\n\t\tcase 8:\r\n\t\t\ttarget[position++] = 0xd7\r\n\t\t\tbreak\r\n\t\tcase 16:\r\n\t\t\ttarget[position++] = 0xd8\r\n\t\t\tbreak\r\n\t\tdefault:\r\n\t\t\tif (length < 0x100) {\r\n\t\t\t\ttarget[position++] = 0xc7\r\n\t\t\t\ttarget[position++] = length\r\n\t\t\t} else if (length < 0x10000) {\r\n\t\t\t\ttarget[position++] = 0xc8\r\n\t\t\t\ttarget[position++] = length << 8\r\n\t\t\t\ttarget[position++] = length & 0xff\r\n\t\t\t} else {\r\n\t\t\t\ttarget[position++] = 0xc9\r\n\t\t\t\ttarget[position++] = length << 24\r\n\t\t\t\ttarget[position++] = (length << 16) & 0xff\r\n\t\t\t\ttarget[position++] = (length << 8) & 0xff\r\n\t\t\t\ttarget[position++] = length & 0xff\r\n\t\t\t}\r\n\t}\r\n\ttarget[position++] = type\r\n\tif (result.copy)\r\n\t\tresult.copy(target, position)\r\n\telse\r\n\t\tcopyBinary(result, target, position, 0, length)\r\n\tposition += length\r\n\treturn position\r\n}\r\n\r\nfunction insertIds(serialized, idsToInsert) {\r\n\t// insert the ids that need to be referenced for structured clones\r\n\tlet nextId\r\n\tlet distanceToMove = idsToInsert.length * 6\r\n\tlet lastEnd = serialized.length - distanceToMove\r\n\tidsToInsert.sort((a, b) => a.offset > b.offset ? 1 : -1)\r\n\twhile (nextId = idsToInsert.pop()) {\r\n\t\tlet offset = nextId.offset\r\n\t\tlet id = nextId.id\r\n\t\tserialized.copyWithin(offset + distanceToMove, offset, lastEnd)\r\n\t\tdistanceToMove -= 6\r\n\t\tlet position = offset + distanceToMove\r\n\t\tserialized[position++] = 0xc9 // tag 9\r\n\t\tserialized[position++] = 0x1a // uint32\r\n\t\tserialized[position++] = id << 24\r\n\t\tserialized[position++] = (id << 16) & 0xff\r\n\t\tserialized[position++] = (id << 8) & 0xff\r\n\t\tserialized[position++] = id & 0xff\r\n\t\tlastEnd = offset\r\n\t}\r\n\treturn serialized\r\n}\r\n\r\nexports.addExtension = function(extension) {\r\n\tif (extension.Class) {\r\n\t\tif (!extension.encode)\r\n\t\t\tthrow new Error('Extension has no encode function')\r\n\t\textensionClasses.unshift(extension.Class)\r\n\t\textensions.unshift(extension)\r\n\t}\r\n\tdecoderModule.addExtension(extension)\r\n}\r\n","\"use strict\"\r\nlet decoder\r\ntry {\r\n\tdecoder = new TextDecoder()\r\n} catch(error) {}\r\nlet src\r\nlet srcEnd\r\nlet position = 0\r\nlet alreadySet\r\nconst EMPTY_ARRAY = []\r\nlet strings = EMPTY_ARRAY\r\nlet stringPosition = 0\r\nlet currentDecoder = {}\r\nlet srcString\r\nlet srcStringStart = 0\r\nlet srcStringEnd = 0\r\nlet referenceMap\r\nlet currentExtensions = []\r\nlet dataView\r\nlet defaultOptions = {\r\n\tuseRecords: false,\r\n\tmapsAsObjects: true\r\n}\r\n\r\nclass Decoder {\r\n\tconstructor(options) {\r\n\t\tif (options) {\r\n\t\t\tif (options.useRecords === false && options.mapsAsObjects === undefined)\r\n\t\t\t\toptions.mapsAsObjects = true\r\n\t\t\tif (options.getStructures && !options.structures)\r\n\t\t\t\t(options.structures = []).uninitialized = true // this is what we use to denote an uninitialized structures\r\n\t\t}\r\n\t\tObject.assign(this, options)\r\n\t}\r\n\tdecode(source, end, continueReading) {\r\n\t\tif (src) {\r\n\t\t\t// re-entrant execution, save the state and restore it after we do this decode\r\n\t\t\treturn saveState(() => {\r\n\t\t\t\tsrc = null\r\n\t\t\t\treturn this ? this.decode(source, end, continueReading) : Decoder.prototype.decode.call(defaultOptions, source, end, continueReading)\r\n\t\t\t})\r\n\t\t}\r\n\t\tsrcEnd = end > -1 ? end : source.length\r\n\t\tposition = 0\r\n\t\tstringPosition = 0\r\n\t\tsrcStringEnd = 0\r\n\t\tsrcString = null\r\n\t\tstrings = EMPTY_ARRAY\r\n\t\tsrc = source\r\n\t\t// this provides cached access to the data view for a buffer if it is getting reused, which is a recommend\r\n\t\t// technique for getting data from a database where it can be copied into an existing buffer instead of creating\r\n\t\t// new ones\r\n\t\tdataView = source.dataView || (source.dataView = new DataView(source.buffer, source.byteOffset, source.byteLength))\r\n\t\tif (this) {\r\n\t\t\tcurrentDecoder = this\r\n\t\t\tif (this.structures) {\r\n\t\t\t\tcurrentStructures = this.structures\r\n\t\t\t\ttry {\r\n\t\t\t\t\treturn read()\r\n\t\t\t\t} finally {\r\n\t\t\t\t\tif (position >= srcEnd || !continueReading) {\r\n\t\t\t\t\t\t// finished reading this source, cleanup references\r\n\t\t\t\t\t\tcurrentStructures = null\r\n\t\t\t\t\t\tsrc = null\r\n\t\t\t\t\t\tif (referenceMap)\r\n\t\t\t\t\t\t\treferenceMap = null\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t} else if (!currentStructures || currentStructures.length > 0) {\r\n\t\t\t\tcurrentStructures = []\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\tcurrentDecoder = defaultOptions\r\n\t\t\tif (!currentStructures || currentStructures.length > 0)\r\n\t\t\t\tcurrentStructures = []\r\n\t\t}\r\n\t\ttry {\r\n\t\t\treturn read()\r\n\t\t} finally {\r\n\t\t\tsrc = null\r\n\t\t\tif (referenceMap)\r\n\t\t\t\treferenceMap = null\r\n\t\t}\r\n\t}\r\n}\r\nlet currentStructures\r\nexports.Decoder = Decoder\r\nexports.read = read\r\nexports.getPosition = () => {\r\n\treturn position\r\n}\r\n\r\nfunction read() {\r\n\tlet token = src[position++]\r\n\tlet majorType = token >> 5\r\n\ttoken = token & 0x1f\r\n\tif (token > 0x17) {\r\n\t\tswitch (token) {\r\n\t\t\tcase 0x18:\r\n\t\t\t\ttoken = src[position++]\r\n\t\t\t\tbreak\r\n\t\t\tcase 0x19:\r\n\t\t\t\tif (majorType == 7) {\r\n\t\t\t\t\treturn getFloat16()\r\n\t\t\t\t}\r\n\t\t\t\ttoken = dataView.getUint16(position)\r\n\t\t\t\tposition += 2\r\n\t\t\t\tbreak\r\n\t\t\tcase 0x1a:\r\n\t\t\t\tif (majorType == 7) {\r\n\t\t\t\t\tlet value = dataView.getFloat32(position)\r\n\t\t\t\t\tif (currentDecoder.useFloat32 > 2) {\r\n\t\t\t\t\t\t// this does rounding of numbers that were encoded in 32-bit float to nearest significant decimal digit that could be preserved\r\n\t\t\t\t\t\tlet multiplier = mult10[((src[position] & 0x7f) << 1) | (src[position + 1] >> 7)]\r\n\t\t\t\t\t\tposition += 4\r\n\t\t\t\t\t\treturn ((multiplier * value + (value > 0 ? 0.5 : -0.5)) >> 0) / multiplier\r\n\t\t\t\t\t}\r\n\t\t\t\t\tposition += 4\r\n\t\t\t\t\treturn value\r\n\t\t\t\t}\r\n\t\t\t\ttoken = dataView.getUint32(position)\r\n\t\t\t\tposition += 4\r\n\t\t\t\tbreak\r\n\t\t\tcase 0x1b:\r\n\t\t\t\tif (majorType == 7) {\r\n\t\t\t\t\tlet value = dataView.getFloat64(position)\r\n\t\t\t\t\tposition += 8\r\n\t\t\t\t\treturn value\r\n\t\t\t\t}\r\n\t\t\t\tif (currentDecoder.uint64AsNumber)\r\n\t\t\t\t\treturn src[position++] * 0x100000000000000 + src[position++] * 0x1000000000000 + src[position++] * 0x10000000000 + src[position++] * 0x100000000 +\r\n\t\t\t\t\t\tsrc[position++] * 0x1000000 + (src[position++] << 16) + (src[position++] << 8) + src[position++]\r\n\t\t\t\ttoken = dataView.getBigUint64(position)\r\n\t\t\t\tposition += 8\r\n\t\t\t\tbreak\r\n\t\t\tdefault:\r\n\t\t\t\tthrow new Error('Unknown token ' + token)\r\n\t\t}\r\n\t}\r\n\tswitch (majorType) {\r\n\t\tcase 0: // positive int\r\n\t\t\treturn token\r\n\t\tcase 1: // negative int\r\n\t\t\treturn ~token\r\n\t\tcase 2: // buffer\r\n\t\t\treturn readBin(token)\r\n\t\tcase 3: // string\r\n\t\t\tif (srcStringEnd >= position) {\r\n\t\t\t\treturn srcString.slice(position - srcStringStart, (position += token) - srcStringStart)\r\n\t\t\t}\r\n\t\t\tif (srcStringEnd == 0 && srcEnd < 120 && token < 16) {\r\n\t\t\t\t// for small blocks, avoiding the overhead of the extract call is helpful\r\n\t\t\t\tlet string = /*length < 16 ? */shortStringInJS(token)// : longStringInJS(length)\r\n\t\t\t\tif (string != null)\r\n\t\t\t\t\treturn string\r\n\t\t\t}\r\n\t\t\treturn readFixedString(token)\r\n\t\tcase 4: // array\r\n\t\t\tlet array = new Array(token)\r\n\t\t\tfor (let i = 0; i < token; i++) {\r\n\t\t\t\tarray[i] = read()\r\n\t\t\t}\r\n\t\t\treturn array\r\n\t\tcase 5: // map\r\n\t\t\tif (currentDecoder.mapsAsObjects) {\r\n\t\t\t\tlet object = {}\r\n\t\t\t\tfor (let i = 0; i < token; i++) {\r\n\t\t\t\t\tobject[read()] = read()\r\n\t\t\t\t}\r\n\t\t\t\treturn object\r\n\t\t\t} else {\r\n\t\t\t\tlet map = new Map()\r\n\t\t\t\tfor (let i = 0; i < token; i++) {\r\n\t\t\t\t\tmap.set(read(), read())\r\n\t\t\t\t}\r\n\t\t\t\treturn map\r\n\t\t\t}\r\n\t\tcase 6: // extension\r\n\t\t\tif (token >= 0x40 && token < 0x100) { // record structures\r\n\t\t\t\tlet structure = currentStructures[token - 0x40]\r\n\t\t\t\tif (structure) {\r\n\t\t\t\t\tif (!structure.read)\r\n\t\t\t\t\t\tstructure.read = createStructureReader(structure)\r\n\t\t\t\t\treturn structure.read()\r\n\t\t\t\t} else if (currentDecoder.getStructures) {\r\n\t\t\t\t\tlet updatedStructures = saveState(() => {\r\n\t\t\t\t\t\t// save the state in case getStructures modifies our buffer\r\n\t\t\t\t\t\tsrc = null\r\n\t\t\t\t\t\treturn currentDecoder.getStructures()\r\n\t\t\t\t\t})\r\n\t\t\t\t\tif (currentStructures === true)\r\n\t\t\t\t\t\tcurrentDecoder.structures = currentStructures = updatedStructures\r\n\t\t\t\t\telse\r\n\t\t\t\t\t\tcurrentStructures.splice.apply(currentStructures, [0, updatedStructures.length].concat(updatedStructures))\r\n\t\t\t\t\tstructure = currentStructures[token - 0x40]\r\n\t\t\t\t\tif (structure) {\r\n\t\t\t\t\t\tif (!structure.read)\r\n\t\t\t\t\t\t\tstructure.read = createStructureReader(structure)\r\n\t\t\t\t\t\treturn structure.read()\r\n\t\t\t\t\t} else\r\n\t\t\t\t\t\treturn token\r\n\t\t\t\t} else\r\n\t\t\t\t\treturn token\r\n\t\t\t} else {\r\n\t\t\t\tif (currentExtensions[token])\r\n\t\t\t\t\treturn currentExtensions[token](read())\r\n\t\t\t\telse\r\n\t\t\t\t\tthrow new Error('Unknown extension ' + token)\r\n\t\t\t}\r\n\t\tcase 7: // fixed value\r\n\t\t\tswitch (token) {\r\n\t\t\t\tcase 0x14: return false\r\n\t\t\t\tcase 0x15: return true\r\n\t\t\t\tcase 0x16: return null\r\n\t\t\t\tcase 0x17: return; // undefined\r\n\t\t\t\t// case 0x19: // half-precision float\r\n\t\t\t\tdefault:\r\n\t\t\t\t\tthrow new Error('Unknown token ' + token)\r\n\t\t\t}\r\n\t\tdefault: // negative int\r\n\t\t\tif (isNaN(token)) {\r\n\t\t\t\tlet error = new Error('Unexpected end of CBOR data')\r\n\t\t\t\terror.incomplete = true\r\n\t\t\t\tthrow error\r\n\t\t\t}\r\n\t\t\tthrow new Error('Unknown CBOR token ' + token)\r\n\t}\r\n}\r\nconst validName = /^[a-zA-Z_$][a-zA-Z\\d_$]*$/\r\nfunction createStructureReader(structure) {\r\n\tfunction readObject() {\r\n\t\t// This initial function is quick to instantiate, but runs slower. After several iterations pay the cost to build the faster function\r\n\t\tif (readObject.count++ > 2) {\r\n\t\t\tthis.read = (new Function('r', 'return function(){return {' + structure.map(key => validName.test(key) ? key + ':r()' : ('[' + JSON.stringify(key) + ']:r()')).join(',') + '}}'))(read)\r\n\t\t\treturn this.read()\r\n\t\t}\r\n\t\tlet object = {}\r\n\t\tfor (let i = 0, l = structure.length; i < l; i++) {\r\n\t\t\tlet key = structure[i]\r\n\t\t\tobject[key] = read()\r\n\t\t}\r\n\t\treturn object\r\n\t}\r\n\treadObject.count = 0\r\n\treturn readObject\r\n}\r\n\r\nlet readFixedString = readStringJS\r\nlet readString8 = readStringJS\r\nlet readString16 = readStringJS\r\nlet readString32 = readStringJS\r\n\r\nexports.setExtractor = (extractStrings) => {\r\n\treadFixedString = readString(1)\r\n\treadString8 = readString(2)\r\n\treadString16 = readString(3)\r\n\treadString32 = readString(5)\r\n\tfunction readString(headerLength) {\r\n\t\treturn function readString(length) {\r\n\t\t\tlet string = strings[stringPosition++]\r\n\t\t\tif (string == null) {\r\n\t\t\t\tstrings = extractStrings(position, srcEnd, length, src)\r\n\t\t\t\tstringPosition = 0\r\n\t\t\t\tstring = strings[stringPosition++]\r\n\t\t\t}\r\n\t\t\tlet srcStringLength = string.length\r\n\t\t\tif (srcStringLength <= length) {\r\n\t\t\t\tposition += length\r\n\t\t\t\treturn string\r\n\t\t\t}\r\n\t\t\tsrcString = string\r\n\t\t\tsrcStringStart = position\r\n\t\t\tsrcStringEnd = position + srcStringLength\r\n\t\t\tposition += length\r\n\t\t\treturn string.slice(0, length) // we know we just want the beginning\r\n\t\t}\r\n\t}\r\n}\r\nfunction readStringJS(length) {\r\n\tlet result\r\n\tif (length < 16) {\r\n\t\tif (result = shortStringInJS(length))\r\n\t\t\treturn result\r\n\t}\r\n\tif (length > 64 && decoder)\r\n\t\treturn decoder.decode(src.subarray(position, position += length))\r\n\tconst end = position + length\r\n\tconst units = []\r\n\tresult = ''\r\n\twhile (position < end) {\r\n\t\tconst byte1 = src[position++]\r\n\t\tif ((byte1 & 0x80) === 0) {\r\n\t\t\t// 1 byte\r\n\t\t\tunits.push(byte1)\r\n\t\t} else if ((byte1 & 0xe0) === 0xc0) {\r\n\t\t\t// 2 bytes\r\n\t\t\tconst byte2 = src[position++] & 0x3f\r\n\t\t\tunits.push(((byte1 & 0x1f) << 6) | byte2)\r\n\t\t} else if ((byte1 & 0xf0) === 0xe0) {\r\n\t\t\t// 3 bytes\r\n\t\t\tconst byte2 = src[position++] & 0x3f\r\n\t\t\tconst byte3 = src[position++] & 0x3f\r\n\t\t\tunits.push(((byte1 & 0x1f) << 12) | (byte2 << 6) | byte3)\r\n\t\t} else if ((byte1 & 0xf8) === 0xf0) {\r\n\t\t\t// 4 bytes\r\n\t\t\tconst byte2 = src[position++] & 0x3f\r\n\t\t\tconst byte3 = src[position++] & 0x3f\r\n\t\t\tconst byte4 = src[position++] & 0x3f\r\n\t\t\tlet unit = ((byte1 & 0x07) << 0x12) | (byte2 << 0x0c) | (byte3 << 0x06) | byte4\r\n\t\t\tif (unit > 0xffff) {\r\n\t\t\t\tunit -= 0x10000\r\n\t\t\t\tunits.push(((unit >>> 10) & 0x3ff) | 0xd800)\r\n\t\t\t\tunit = 0xdc00 | (unit & 0x3ff)\r\n\t\t\t}\r\n\t\t\tunits.push(unit)\r\n\t\t} else {\r\n\t\t\tunits.push(byte1)\r\n\t\t}\r\n\r\n\t\tif (units.length >= 0x1000) {\r\n\t\t\tresult += fromCharCode.apply(String, units)\r\n\t\t\tunits.length = 0\r\n\t\t}\r\n\t}\r\n\r\n\tif (units.length > 0) {\r\n\t\tresult += fromCharCode.apply(String, units)\r\n\t}\r\n\r\n\treturn result\r\n}\r\n/*function readShortString(length) {\r\n\tlet start = position\r\n\tlet end = start + length\r\n\twhile (position < end) {\r\n\t\tconst byte = src[position++];\r\n\t\tif ((byte & 0x80) > 0) {\r\n\t\t\tposition = end\r\n\t\t\tconsole.log('utf8 slice')\r\n\t\t\treturn src.utf8Slice(start, end)\r\n\t\t}\r\n\t}\r\n\tif (srcStringEnd < end) {\r\n\t\tsrcStringStart = start\r\n\t\tsrcStringEnd = start + 8192\r\n\t\tsrcString = src.toString('latin1', start, srcStringEnd)\r\n\t}\r\n\treturn srcString.slice(start - srcStringStart, end - srcStringStart)\r\n}*/\r\nlet fromCharCode = String.fromCharCode\r\nfunction longStringInJS(length) {\r\n\tlet start = position\r\n\tlet bytes = new Array(length)\r\n\tfor (let i = 0; i < length; i++) {\r\n\t\tconst byte = src[position++];\r\n\t\tif ((byte & 0x80) > 0) {\r\n\t\t\tposition = start\r\n \t\t\treturn\r\n \t\t}\r\n \t\tbytes[i] = byte\r\n \t}\r\n \treturn fromCharCode.apply(String, bytes)\r\n}\r\nfunction shortStringInJS(length) {\r\n\tif (length < 4) {\r\n\t\tif (length < 2) {\r\n\t\t\tif (length === 0)\r\n\t\t\t\treturn ''\r\n\t\t\telse {\r\n\t\t\t\tlet a = src[position++]\r\n\t\t\t\tif ((a & 0x80) > 1) {\r\n\t\t\t\t\tposition -= 1\r\n\t\t\t\t\treturn\r\n\t\t\t\t}\r\n\t\t\t\treturn fromCharCode(a)\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\tlet a = src[position++]\r\n\t\t\tlet b = src[position++]\r\n\t\t\tif ((a & 0x80) > 0 || (b & 0x80) > 0) {\r\n\t\t\t\tposition -= 2\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t\tif (length < 3)\r\n\t\t\t\treturn fromCharCode(a, b)\r\n\t\t\tlet c = src[position++]\r\n\t\t\tif ((c & 0x80) > 0) {\r\n\t\t\t\tposition -= 3\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t\treturn fromCharCode(a, b, c)\r\n\t\t}\r\n\t} else {\r\n\t\tlet a = src[position++]\r\n\t\tlet b = src[position++]\r\n\t\tlet c = src[position++]\r\n\t\tlet d = src[position++]\r\n\t\tif ((a & 0x80) > 0 || (b & 0x80) > 0 || (c & 0x80) > 0 || (d & 0x80) > 0) {\r\n\t\t\tposition -= 4\r\n\t\t\treturn\r\n\t\t}\r\n\t\tif (length < 6) {\r\n\t\t\tif (length === 4)\r\n\t\t\t\treturn fromCharCode(a, b, c, d)\r\n\t\t\telse {\r\n\t\t\t\tlet e = src[position++]\r\n\t\t\t\tif ((e & 0x80) > 0) {\r\n\t\t\t\t\tposition -= 5\r\n\t\t\t\t\treturn\r\n\t\t\t\t}\r\n\t\t\t\treturn fromCharCode(a, b, c, d, e)\r\n\t\t\t}\r\n\t\t} else if (length < 8) {\r\n\t\t\tlet e = src[position++]\r\n\t\t\tlet f = src[position++]\r\n\t\t\tif ((e & 0x80) > 0 || (f & 0x80) > 0) {\r\n\t\t\t\tposition -= 6\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t\tif (length < 7)\r\n\t\t\t\treturn fromCharCode(a, b, c, d, e, f)\r\n\t\t\tlet g = src[position++]\r\n\t\t\tif ((g & 0x80) > 0) {\r\n\t\t\t\tposition -= 7\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t\treturn fromCharCode(a, b, c, d, e, f, g)\r\n\t\t} else {\r\n\t\t\tlet e = src[position++]\r\n\t\t\tlet f = src[position++]\r\n\t\t\tlet g = src[position++]\r\n\t\t\tlet h = src[position++]\r\n\t\t\tif ((e & 0x80) > 0 || (f & 0x80) > 0 || (g & 0x80) > 0 || (h & 0x80) > 0) {\r\n\t\t\t\tposition -= 8\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t\tif (length < 10) {\r\n\t\t\t\tif (length === 8)\r\n\t\t\t\t\treturn fromCharCode(a, b, c, d, e, f, g, h)\r\n\t\t\t\telse {\r\n\t\t\t\t\tlet i = src[position++]\r\n\t\t\t\t\tif ((i & 0x80) > 0) {\r\n\t\t\t\t\t\tposition -= 9\r\n\t\t\t\t\t\treturn\r\n\t\t\t\t\t}\r\n\t\t\t\t\treturn fromCharCode(a, b, c, d, e, f, g, h, i)\r\n\t\t\t\t}\r\n\t\t\t} else if (length < 12) {\r\n\t\t\t\tlet i = src[position++]\r\n\t\t\t\tlet j = src[position++]\r\n\t\t\t\tif ((i & 0x80) > 0 || (j & 0x80) > 0) {\r\n\t\t\t\t\tposition -= 10\r\n\t\t\t\t\treturn\r\n\t\t\t\t}\r\n\t\t\t\tif (length < 11)\r\n\t\t\t\t\treturn fromCharCode(a, b, c, d, e, f, g, h, i, j)\r\n\t\t\t\tlet k = src[position++]\r\n\t\t\t\tif ((k & 0x80) > 0) {\r\n\t\t\t\t\tposition -= 11\r\n\t\t\t\t\treturn\r\n\t\t\t\t}\r\n\t\t\t\treturn fromCharCode(a, b, c, d, e, f, g, h, i, j, k)\r\n\t\t\t} else {\r\n\t\t\t\tlet i = src[position++]\r\n\t\t\t\tlet j = src[position++]\r\n\t\t\t\tlet k = src[position++]\r\n\t\t\t\tlet l = src[position++]\r\n\t\t\t\tif ((i & 0x80) > 0 || (j & 0x80) > 0 || (k & 0x80) > 0 || (l & 0x80) > 0) {\r\n\t\t\t\t\tposition -= 12\r\n\t\t\t\t\treturn\r\n\t\t\t\t}\r\n\t\t\t\tif (length < 14) {\r\n\t\t\t\t\tif (length === 12)\r\n\t\t\t\t\t\treturn fromCharCode(a, b, c, d, e, f, g, h, i, j, k, l)\r\n\t\t\t\t\telse {\r\n\t\t\t\t\t\tlet m = src[position++]\r\n\t\t\t\t\t\tif ((m & 0x80) > 0) {\r\n\t\t\t\t\t\t\tposition -= 13\r\n\t\t\t\t\t\t\treturn\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\treturn fromCharCode(a, b, c, d, e, f, g, h, i, j, k, l, m)\r\n\t\t\t\t\t}\r\n\t\t\t\t} else {\r\n\t\t\t\t\tlet m = src[position++]\r\n\t\t\t\t\tlet n = src[position++]\r\n\t\t\t\t\tif ((m & 0x80) > 0 || (n & 0x80) > 0) {\r\n\t\t\t\t\t\tposition -= 14\r\n\t\t\t\t\t\treturn\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif (length < 15)\r\n\t\t\t\t\t\treturn fromCharCode(a, b, c, d, e, f, g, h, i, j, k, l, m, n)\r\n\t\t\t\t\tlet o = src[position++]\r\n\t\t\t\t\tif ((o & 0x80) > 0) {\r\n\t\t\t\t\t\tposition -= 15\r\n\t\t\t\t\t\treturn\r\n\t\t\t\t\t}\r\n\t\t\t\t\treturn fromCharCode(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\nfunction readBin(length) {\r\n\treturn currentDecoder.copyBuffers ?\r\n\t\t// specifically use the copying slice (not the node one)\r\n\t\tUint8Array.prototype.slice.call(src, position, position += length) :\r\n\t\tsrc.subarray(position, position += length)\r\n}\r\nfunction readExt(length) {\r\n\tlet type = src[position++]\r\n\tif (currentExtensions[type]) {\r\n\t\treturn currentExtensions[type](src.subarray(position, position += length))\r\n\t}\r\n\telse\r\n\t\tthrow new Error('Unknown extension type ' + type)\r\n}\r\n\r\nfunction getFloat16() {\r\n\tlet byte0 = src[position++]\r\n\tlet byte1 = src[position++]\r\n\tlet half = (byte0 << 8) + byte1\r\n\tlet exp = (half >> 10) & 0x1f\r\n\tlet mant = half & 0x3ff\r\n\tlet val\r\n\tif (exp == 0) val = Math.exp(mant, -24)\r\n\telse if (exp != 31) val = Math.exp(mant + 1024, exp - 25)\r\n\telse val = mant == 0 ? Infinity : NaN\r\n\treturn half & 0x8000 ? -val : val\r\n}\r\nlet glbl = typeof window == 'object' ? window : global\r\n\r\ncurrentExtensions[0] = (dateString) => {\r\n\t// string date extension\r\n\treturn new Date(dateString)\r\n}\r\n\r\ncurrentExtensions[1] = (epochSec) => {\r\n\t// numeric date extension\r\n\treturn new Date(epochSec * 1000)\r\n}\r\n\r\ncurrentExtensions[2] = (buffer) => {\r\n\t// bigint extension\r\n\treturn new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength).getBigUint64(0)\r\n}\r\n\r\ncurrentExtensions[3] = (buffer) => {\r\n\t// negative bigint extension\r\n\treturn BigInt(-1) - (new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength).getBigUint64(0))\r\n}\r\n\r\n// the registration of the record definition extension (tag 6)\r\ncurrentExtensions[6] = (structure) => {\r\n\tlet id = structure[0]\r\n\tstructure = structure.slice(1)\r\n\tcurrentStructures[id - 0x40] = structure\r\n\tstructure.read = createStructureReader(structure)\r\n\treturn structure.read()\r\n}\r\n\r\ncurrentExtensions[8] = (data) => {\r\n\treturn (glbl[data[0]] || Error)(data[1])\r\n}\r\n\r\ncurrentExtensions[9] = (id) => {\r\n\t// id extension (for structured clones)\r\n\tif (!referenceMap)\r\n\t\treferenceMap = new Map()\r\n\tlet token = src[position]\r\n\tlet target\r\n\t// TODO: handle Maps, Sets, and other types that can cycle; this is complicated, because you potentially need to read\r\n\t// ahead past references to record structure definitions\r\n\tif ((token >> 5) == 4)\r\n\t\ttarget = []\r\n\telse\r\n\t\ttarget = {}\r\n\r\n\tlet refEntry = { target } // a placeholder object\r\n\treferenceMap.set(id, refEntry)\r\n\tlet targetProperties = read() // read the next value as the target object to id\r\n\tif (refEntry.used) // there is a cycle, so we have to assign properties to original target\r\n\t\treturn Object.assign(target, targetProperties)\r\n\trefEntry.target = targetProperties // the placeholder wasn't used, replace with the deserialized one\r\n\treturn targetProperties // no cycle, can just use the returned read object\r\n}\r\n\r\ncurrentExtensions[10] = (id) => {\r\n\t// pointer extension (for structured clones)\r\n\tlet refEntry = referenceMap.get(id)\r\n\trefEntry.used = true\r\n\treturn refEntry.target\r\n}\r\n\r\ncurrentExtensions[11] = (array) => new Set(array)\r\n\r\nconst typedArrays = ['Int8','Uint8\t','Uint8Clamped','Int16','Uint16','Int32','Uint32','Float32','Float64','BigInt64','BigUint64'].map(type => type + 'Array')\r\n\r\ncurrentExtensions[12] = (data) => {\r\n\tlet [ typeCode, buffer ] = data\r\n\tlet typedArrayName = typedArrays[typeCode]\r\n\tif (!typedArrayName)\r\n\t\tthrow new Error('Could not find typed array for code ' + typeCode)\r\n\t// we have to always slice/copy here to get a new ArrayBuffer that is word/byte aligned\r\n\treturn new glbl[typedArrayName](Uint8Array.prototype.slice.call(buffer, 0).buffer)\r\n}\r\ncurrentExtensions[13] = (data) => {\r\n\treturn new RegExp(data[0], data[1])\r\n}\r\n\r\nfunction saveState(callback) {\r\n\tlet savedSrcEnd = srcEnd\r\n\tlet savedPosition = position\r\n\tlet savedStringPosition = stringPosition\r\n\tlet savedSrcStringStart = srcStringStart\r\n\tlet savedSrcStringEnd = srcStringEnd\r\n\tlet savedSrcString = srcString\r\n\tlet savedStrings = strings\r\n\tlet savedReferenceMap = referenceMap\r\n\t// TODO: We may need to revisit this if we do more external calls to user code (since it could be slow)\r\n\tlet savedSrc = new Uint8Array(src.slice(0, srcEnd)) // we copy the data in case it changes while external data is processed\r\n\tlet savedStructures = currentStructures\r\n\tlet savedDecoder = currentDecoder\r\n\tlet value = callback()\r\n\tsrcEnd = savedSrcEnd\r\n\tposition = savedPosition\r\n\tstringPosition = savedStringPosition\r\n\tsrcStringStart = savedSrcStringStart\r\n\tsrcStringEnd = savedSrcStringEnd\r\n\tsrcString = savedSrcString\r\n\tstrings = savedStrings\r\n\treferenceMap = savedReferenceMap\r\n\tsrc = savedSrc\r\n\tcurrentStructures = savedStructures\r\n\tcurrentDecoder = savedDecoder\r\n\tdataView = new DataView(src.buffer, src.byteOffset, src.byteLength)\r\n\treturn value\r\n}\r\nexports.clearSource = function() {\r\n\tsrc = null\r\n}\r\n\r\nexports.addExtension = function(extension) {\r\n\tcurrentExtensions[extension.tag] = extension.decode\r\n}\r\n\r\nlet mult10 = new Array(147) // this is a table matching binary exponents to the multiplier to determine significant digit rounding\r\nfor (let i = 0; i < 256; i++) {\r\n\tmult10[i] = +('1e' + Math.floor(45.15 - i * 0.30103))\r\n}\r\nexports.mult10 = mult10\r\nexports.typedArrays = typedArrays\r\n","exports.Encoder = require('./encode').Encoder\r\nexports.Decoder = require('./decode').Decoder\r\nexports.addExtension = require('./encode').addExtension\r\nlet encoder = new exports.Encoder({ useRecords: false })\r\nexports.decode = encoder.decode\r\nexports.encode = encoder.encode\r\nObject.assign(exports, {\r\n\tALWAYS:1,\r\n\tDECIMAL_ROUND: 3,\r\n\tDECIMAL_FIT: 4\r\n})\r\n","var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn this;\n})();\n\ntry {\n\t// This works if eval is allowed (see CSP)\n\tg = g || new Function(\"return this\")();\n} catch (e) {\n\t// This works if the window reference is available\n\tif (typeof window === \"object\") g = window;\n}\n\n// g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\nmodule.exports = g;\n"],"sourceRoot":""}
|