@colyseus/schema 4.0.1 → 4.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{lib → build}/Metadata.d.ts +2 -2
- package/{lib → build}/Reflection.d.ts +13 -13
- package/{lib → build}/Schema.d.ts +10 -10
- package/{lib → build}/annotations.d.ts +10 -10
- package/build/codegen/languages/cpp.d.ts +3 -0
- package/build/codegen/languages/csharp.d.ts +4 -0
- package/build/codegen/languages/haxe.d.ts +3 -0
- package/{lib → build}/codegen/languages/java.d.ts +2 -2
- package/build/codegen/languages/js.d.ts +3 -0
- package/build/codegen/languages/lua.d.ts +3 -0
- package/build/codegen/languages/ts.d.ts +3 -0
- package/{lib → build}/codegen/parser.d.ts +1 -1
- package/{lib → build}/decoder/DecodeOperation.d.ts +5 -5
- package/{lib → build}/decoder/Decoder.d.ts +7 -7
- package/{lib → build}/decoder/ReferenceTracker.d.ts +1 -1
- package/{lib → build}/decoder/strategy/Callbacks.d.ts +11 -11
- package/{lib → build}/decoder/strategy/RawChanges.d.ts +2 -2
- package/{lib → build}/decoder/strategy/getDecoderStateCallbacks.d.ts +3 -3
- package/{lib → build}/encoder/ChangeTree.d.ts +11 -11
- package/{lib → build}/encoder/EncodeOperation.d.ts +5 -5
- package/{lib → build}/encoder/Encoder.d.ts +6 -6
- package/{lib → build}/encoder/Root.d.ts +2 -2
- package/{lib → build}/encoder/StateView.d.ts +1 -1
- package/{lib → build}/encoding/assert.d.ts +6 -6
- package/{lib → build}/encoding/decode.d.ts +1 -1
- package/{lib → build}/encoding/encode.d.ts +1 -1
- package/build/{cjs/index.js → index.cjs} +1 -1
- package/build/index.cjs.map +1 -0
- package/build/index.d.ts +32 -0
- package/build/index.mjs.map +1 -0
- package/{lib → build}/types/HelperTypes.d.ts +6 -6
- package/{lib → build}/types/TypeContext.d.ts +1 -1
- package/{lib → build}/types/custom/ArraySchema.d.ts +8 -8
- package/{lib → build}/types/custom/CollectionSchema.d.ts +7 -7
- package/{lib → build}/types/custom/MapSchema.d.ts +7 -7
- package/{lib → build}/types/custom/SetSchema.d.ts +7 -7
- package/{lib → build}/types/registry.d.ts +2 -2
- package/{lib → build}/utils.d.ts +1 -1
- package/package.json +15 -14
- package/src/Metadata.ts +5 -5
- package/src/Reflection.ts +7 -7
- package/src/Schema.ts +11 -11
- package/src/annotations.ts +13 -13
- package/src/codegen/api.ts +10 -3
- package/src/codegen/cli.ts +2 -2
- package/src/codegen/languages/cpp.ts +2 -2
- package/src/codegen/languages/csharp.ts +3 -3
- package/src/codegen/languages/haxe.ts +2 -2
- package/src/codegen/languages/java.ts +2 -2
- package/src/codegen/languages/js.ts +2 -2
- package/src/codegen/languages/lua.ts +2 -2
- package/src/codegen/languages/ts.ts +2 -2
- package/src/codegen/parser.ts +7 -2
- package/src/codegen/types.ts +5 -0
- package/src/decoder/DecodeOperation.ts +14 -14
- package/src/decoder/Decoder.ts +11 -11
- package/src/decoder/ReferenceTracker.ts +8 -8
- package/src/decoder/strategy/Callbacks.ts +12 -12
- package/src/decoder/strategy/RawChanges.ts +2 -2
- package/src/decoder/strategy/getDecoderStateCallbacks.ts +10 -10
- package/src/encoder/ChangeTree.ts +13 -13
- package/src/encoder/EncodeOperation.ts +9 -9
- package/src/encoder/Encoder.ts +10 -10
- package/src/encoder/Root.ts +4 -4
- package/src/encoder/StateView.ts +7 -7
- package/src/encoding/assert.ts +6 -6
- package/src/encoding/decode.ts +1 -1
- package/src/encoding/encode.ts +1 -1
- package/src/index.ts +27 -27
- package/src/types/HelperTypes.ts +6 -6
- package/src/types/TypeContext.ts +3 -3
- package/src/types/custom/ArraySchema.ts +11 -11
- package/src/types/custom/CollectionSchema.ts +9 -9
- package/src/types/custom/MapSchema.ts +10 -10
- package/src/types/custom/SetSchema.ts +9 -9
- package/src/types/registry.ts +3 -3
- package/src/utils.ts +3 -3
- package/src/v3_bench.ts +1 -1
- package/build/cjs/index.js.map +0 -1
- package/build/esm/index.mjs.map +0 -1
- package/lib/Metadata.js +0 -260
- package/lib/Metadata.js.map +0 -1
- package/lib/Reflection.js +0 -182
- package/lib/Reflection.js.map +0 -1
- package/lib/Schema.js +0 -356
- package/lib/Schema.js.map +0 -1
- package/lib/annotations.js +0 -484
- package/lib/annotations.js.map +0 -1
- package/lib/bench_encode.d.ts +0 -1
- package/lib/bench_encode.js +0 -126
- package/lib/bench_encode.js.map +0 -1
- package/lib/codegen/api.js +0 -87
- package/lib/codegen/api.js.map +0 -1
- package/lib/codegen/argv.js +0 -41
- package/lib/codegen/argv.js.map +0 -1
- package/lib/codegen/cli.js +0 -63
- package/lib/codegen/cli.js.map +0 -1
- package/lib/codegen/languages/cpp.d.ts +0 -3
- package/lib/codegen/languages/cpp.js +0 -261
- package/lib/codegen/languages/cpp.js.map +0 -1
- package/lib/codegen/languages/csharp.d.ts +0 -4
- package/lib/codegen/languages/csharp.js +0 -157
- package/lib/codegen/languages/csharp.js.map +0 -1
- package/lib/codegen/languages/haxe.d.ts +0 -3
- package/lib/codegen/languages/haxe.js +0 -103
- package/lib/codegen/languages/haxe.js.map +0 -1
- package/lib/codegen/languages/java.js +0 -103
- package/lib/codegen/languages/java.js.map +0 -1
- package/lib/codegen/languages/js.d.ts +0 -3
- package/lib/codegen/languages/js.js +0 -104
- package/lib/codegen/languages/js.js.map +0 -1
- package/lib/codegen/languages/lua.d.ts +0 -3
- package/lib/codegen/languages/lua.js +0 -106
- package/lib/codegen/languages/lua.js.map +0 -1
- package/lib/codegen/languages/ts.d.ts +0 -3
- package/lib/codegen/languages/ts.js +0 -119
- package/lib/codegen/languages/ts.js.map +0 -1
- package/lib/codegen/parser.js +0 -364
- package/lib/codegen/parser.js.map +0 -1
- package/lib/codegen/types.js +0 -181
- package/lib/codegen/types.js.map +0 -1
- package/lib/decoder/DecodeOperation.js +0 -255
- package/lib/decoder/DecodeOperation.js.map +0 -1
- package/lib/decoder/Decoder.js +0 -118
- package/lib/decoder/Decoder.js.map +0 -1
- package/lib/decoder/ReferenceTracker.js +0 -139
- package/lib/decoder/ReferenceTracker.js.map +0 -1
- package/lib/decoder/strategy/Callbacks.js +0 -340
- package/lib/decoder/strategy/Callbacks.js.map +0 -1
- package/lib/decoder/strategy/RawChanges.js +0 -7
- package/lib/decoder/strategy/RawChanges.js.map +0 -1
- package/lib/decoder/strategy/getDecoderStateCallbacks.js +0 -277
- package/lib/decoder/strategy/getDecoderStateCallbacks.js.map +0 -1
- package/lib/encoder/ChangeTree.js +0 -542
- package/lib/encoder/ChangeTree.js.map +0 -1
- package/lib/encoder/EncodeOperation.js +0 -139
- package/lib/encoder/EncodeOperation.js.map +0 -1
- package/lib/encoder/Encoder.js +0 -208
- package/lib/encoder/Encoder.js.map +0 -1
- package/lib/encoder/Root.js +0 -233
- package/lib/encoder/Root.js.map +0 -1
- package/lib/encoder/StateView.js +0 -284
- package/lib/encoder/StateView.js.map +0 -1
- package/lib/encoding/assert.js +0 -55
- package/lib/encoding/assert.js.map +0 -1
- package/lib/encoding/decode.js +0 -221
- package/lib/encoding/decode.js.map +0 -1
- package/lib/encoding/encode.js +0 -282
- package/lib/encoding/encode.js.map +0 -1
- package/lib/encoding/spec.js +0 -29
- package/lib/encoding/spec.js.map +0 -1
- package/lib/index.d.ts +0 -32
- package/lib/index.js +0 -81
- package/lib/index.js.map +0 -1
- package/lib/symbol.shim.js +0 -4
- package/lib/symbol.shim.js.map +0 -1
- package/lib/types/HelperTypes.js +0 -3
- package/lib/types/HelperTypes.js.map +0 -1
- package/lib/types/TypeContext.js +0 -147
- package/lib/types/TypeContext.js.map +0 -1
- package/lib/types/custom/ArraySchema.js +0 -737
- package/lib/types/custom/ArraySchema.js.map +0 -1
- package/lib/types/custom/CollectionSchema.js +0 -174
- package/lib/types/custom/CollectionSchema.js.map +0 -1
- package/lib/types/custom/MapSchema.js +0 -226
- package/lib/types/custom/MapSchema.js.map +0 -1
- package/lib/types/custom/SetSchema.js +0 -182
- package/lib/types/custom/SetSchema.js.map +0 -1
- package/lib/types/registry.js +0 -37
- package/lib/types/registry.js.map +0 -1
- package/lib/types/symbols.js +0 -37
- package/lib/types/symbols.js.map +0 -1
- package/lib/types/utils.js +0 -16
- package/lib/types/utils.js.map +0 -1
- package/lib/utils.js +0 -54
- package/lib/utils.js.map +0 -1
- package/lib/v3_bench.js +0 -130
- package/lib/v3_bench.js.map +0 -1
- package/src/bench_encode.ts +0 -64
- /package/{lib → build}/codegen/api.d.ts +0 -0
- /package/{lib → build}/codegen/argv.d.ts +0 -0
- /package/{lib → build}/codegen/cli.d.ts +0 -0
- /package/{lib → build}/codegen/types.d.ts +0 -0
- /package/{lib → build}/encoding/spec.d.ts +0 -0
- /package/build/{umd/index.js → index.js} +0 -0
- /package/build/{esm/index.mjs → index.mjs} +0 -0
- /package/{lib → build}/symbol.shim.d.ts +0 -0
- /package/{lib → build}/types/symbols.d.ts +0 -0
- /package/{lib → build}/types/utils.d.ts +0 -0
- /package/{lib → build}/v3_bench.d.ts +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"decode.js","sourceRoot":"","sources":["../../src/encoding/decode.ts"],"names":[],"mappings":";AAAA,cAAc;;;AAuOd,kCAYC;AAjND,yEAAyE;AACzE,MAAM,eAAe,GAAG,IAAI,CAAC,CAAE,2DAA2D;AAC1F,MAAM,YAAY,GAAG,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC;AAExC,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,YAAY,CAAC,CAAC;AAC5C,MAAM,QAAQ,GAAG,IAAI,YAAY,CAAC,YAAY,CAAC,CAAC;AAChD,MAAM,QAAQ,GAAG,IAAI,YAAY,CAAC,YAAY,CAAC,CAAC;AAChD,MAAM,OAAO,GAAG,IAAI,cAAc,CAAC,YAAY,CAAC,CAAC;AACjD,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,YAAY,CAAC,CAAC;AAE/C,SAAS,QAAQ,CAAC,KAAiB,EAAE,EAAY,EAAE,MAAc;IAC/D,iBAAiB;IACjB,I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AAY;IACzD,MAAM,MAAM,GAAG,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;IAChC,OAAO;IACL,SAAS;IACT,CAAC,MAAM,GAAG,IAAI,IAAI,MAAM,GAAG,IAAI,CAAC;QAChC,QAAQ;QACR,MAAM,KAAK,IAAI;QACf,SAAS;QACT,MAAM,KAAK,IAAI;QACf,SAAS;QACT,MAAM,KAAK,IAAI,CAChB,CAAC;AACJ,CAAC;AAEY,QAAA,MAAM,GAAG;IAClB,QAAQ;IACR,IAAI;IACJ,KAAK;IACL,KAAK;IACL,MAAM;IACN,KAAK;IACL,MAAM;IACN,OAAO;IACP,OAAO;IACP,KAAK;IACL,MAAM;IACN,QAAQ;IACR,SAAS;IACT,OAAO;IACP,MAAM;IACN,MAAM;IACN,WAAW;CACd,CAAC","sourcesContent":["// @ts-nocheck\n\n/**\n * Copyright (c) 2018 Endel Dreyer\n * Copyright (c) 2014 Ion Drive Software Ltd.\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE\n */\n\nimport type { BufferLike } from \"./encode\";\n\n/**\n * msgpack implementation highly based on notepack.io\n * https://github.com/darrachequesne/notepack\n */\n\nexport interface Iterator { offset: number; }\n\n// force little endian to facilitate decoding on multiple implementations\nconst _isLittleEndian = true; // new Uint16Array(new Uint8Array([1, 0]).buffer)[0] === 1;\nconst _convoBuffer = new ArrayBuffer(8);\n\nconst _int32 = new Int32Array(_convoBuffer);\nconst _float32 = new Float32Array(_convoBuffer);\nconst _float64 = new Float64Array(_convoBuffer);\nconst _uint64 = new BigUint64Array(_convoBuffer);\nconst _int64 = new BigInt64Array(_convoBuffer);\n\nfunction utf8Read(bytes: BufferLike, it: Iterator, length: number) {\n // boundary check\n if (length > bytes.length - it.offset) { length = bytes.length - it.offset; }\n\n var string = '', chr = 0;\n for (var i = it.offset, end = it.offset + length; i < end; i++) {\n var byte = bytes[i];\n if ((byte & 0x80) === 0x00) {\n string += String.fromCharCode(byte);\n continue;\n }\n if ((byte & 0xe0) === 0xc0) {\n string += String.fromCharCode(\n ((byte & 0x1f) << 6) |\n (bytes[++i] & 0x3f)\n );\n continue;\n }\n if ((byte & 0xf0) === 0xe0) {\n string += String.fromCharCode(\n ((byte & 0x0f) << 12) |\n ((bytes[++i] & 0x3f) << 6) |\n ((bytes[++i] & 0x3f) << 0)\n );\n continue;\n }\n if ((byte & 0xf8) === 0xf0) {\n chr = ((byte & 0x07) << 18) |\n ((bytes[++i] & 0x3f) << 12) |\n ((bytes[++i] & 0x3f) << 6) |\n ((bytes[++i] & 0x3f) << 0);\n if (chr >= 0x010000) { // surrogate pair\n chr -= 0x010000;\n string += String.fromCharCode((chr >>> 10) + 0xD800, (chr & 0x3FF) + 0xDC00);\n } else {\n string += String.fromCharCode(chr);\n }\n continue;\n }\n\n // (do not throw error to avoid server/client from crashing due to hack attemps)\n // throw new Error('Invalid byte ' + byte.toString(16));\n\n console.error('decode.utf8Read(): Invalid byte ' + byte + ' at offset ' + i + '. Skip to end of string: ' + (it.offset + length));\n break;\n }\n it.offset += length;\n return string;\n}\n\nfunction int8 (bytes: BufferLike, it: Iterator) {\n return uint8(bytes, it) << 24 >> 24;\n};\n\nfunction uint8 (bytes: BufferLike, it: Iterator) {\n return bytes[it.offset++];\n};\n\nfunction int16 (bytes: BufferLike, it: Iterator) {\n return uint16(bytes, it) << 16 >> 16;\n};\n\nfunction uint16 (bytes: BufferLike, it: Iterator) {\n return bytes[it.offset++] | bytes[it.offset++] << 8;\n};\n\nfunction int32 (bytes: BufferLike, it: Iterator) {\n return bytes[it.offset++] | bytes[it.offset++] << 8 | bytes[it.offset++] << 16 | bytes[it.offset++] << 24;\n};\n\nfunction uint32 (bytes: BufferLike, it: Iterator) {\n return int32(bytes, it) >>> 0;\n};\n\nfunction float32 (bytes: BufferLike, it: Iterator) {\n _int32[0] = int32(bytes, it);\n return _float32[0];\n};\n\nfunction float64 (bytes: BufferLike, it: Iterator) {\n _int32[_isLittleEndian ? 0 : 1] = int32(bytes, it);\n _int32[_isLittleEndian ? 1 : 0] = int32(bytes, it);\n return _float64[0];\n};\n\nfunction int64(bytes: BufferLike, it: Iterator) {\n const low = uint32(bytes, it);\n const high = int32(bytes, it) * Math.pow(2, 32);\n return high + low;\n};\n\nfunction uint64(bytes: BufferLike, it: Iterator) {\n const low = uint32(bytes, it);\n const high = uint32(bytes, it) * Math.pow(2, 32);\n return high + low;\n};\n\nfunction bigint64(bytes: BufferLike, it: Iterator) {\n _int32[0] = int32(bytes, it);\n _int32[1] = int32(bytes, it);\n return _int64[0];\n}\n\nfunction biguint64(bytes: BufferLike, it: Iterator) {\n _int32[0] = int32(bytes, it);\n _int32[1] = int32(bytes, it);\n return _uint64[0];\n}\n\nfunction boolean (bytes: BufferLike, it: Iterator) {\n return uint8(bytes, it) > 0;\n};\n\nfunction string (bytes: BufferLike, it: Iterator) {\n const prefix = bytes[it.offset++];\n let length: number;\n\n if (prefix < 0xc0) {\n // fixstr\n length = prefix & 0x1f;\n\n } else if (prefix === 0xd9) {\n length = uint8(bytes, it);\n\n } else if (prefix === 0xda) {\n length = uint16(bytes, it);\n\n } else if (prefix === 0xdb) {\n length = uint32(bytes, it);\n }\n\n return utf8Read(bytes, it, length);\n}\n\nfunction number (bytes: BufferLike, it: Iterator) {\n const prefix = bytes[it.offset++];\n\n if (prefix < 0x80) {\n // positive fixint\n return prefix;\n\n } else if (prefix === 0xca) {\n // float 32\n return float32(bytes, it);\n\n } else if (prefix === 0xcb) {\n // float 64\n return float64(bytes, it);\n\n } else if (prefix === 0xcc) {\n // uint 8\n return uint8(bytes, it);\n\n } else if (prefix === 0xcd) {\n // uint 16\n return uint16(bytes, it);\n\n } else if (prefix === 0xce) {\n // uint 32\n return uint32(bytes, it);\n\n } else if (prefix === 0xcf) {\n // uint 64\n return uint64(bytes, it);\n\n } else if (prefix === 0xd0) {\n // int 8\n return int8(bytes, it);\n\n } else if (prefix === 0xd1) {\n // int 16\n return int16(bytes, it);\n\n } else if (prefix === 0xd2) {\n // int 32\n return int32(bytes, it);\n\n } else if (prefix === 0xd3) {\n // int 64\n return int64(bytes, it);\n\n } else if (prefix > 0xdf) {\n // negative fixint\n return (0xff - prefix + 1) * -1\n }\n};\n\nexport function stringCheck(bytes: BufferLike, it: Iterator) {\n const prefix = bytes[it.offset];\n return (\n // fixstr\n (prefix < 0xc0 && prefix > 0xa0) ||\n // str 8\n prefix === 0xd9 ||\n // str 16\n prefix === 0xda ||\n // str 32\n prefix === 0xdb\n );\n}\n\nexport const decode = {\n utf8Read,\n int8,\n uint8,\n int16,\n uint16,\n int32,\n uint32,\n float32,\n float64,\n int64,\n uint64,\n bigint64,\n biguint64,\n boolean,\n string,\n number,\n stringCheck,\n};"]}
|
package/lib/encoding/encode.js
DELETED
|
@@ -1,282 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// @ts-nocheck
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.encode = void 0;
|
|
5
|
-
/**
|
|
6
|
-
* msgpack implementation highly based on notepack.io
|
|
7
|
-
* https://github.com/darrachequesne/notepack
|
|
8
|
-
*/
|
|
9
|
-
let textEncoder;
|
|
10
|
-
// @ts-ignore
|
|
11
|
-
try {
|
|
12
|
-
textEncoder = new TextEncoder();
|
|
13
|
-
}
|
|
14
|
-
catch (e) { }
|
|
15
|
-
// force little endian to facilitate decoding on multiple implementations
|
|
16
|
-
const _isLittleEndian = true; // new Uint16Array(new Uint8Array([1, 0]).buffer)[0] === 1;
|
|
17
|
-
const _convoBuffer = new ArrayBuffer(8);
|
|
18
|
-
const _int32 = new Int32Array(_convoBuffer);
|
|
19
|
-
const _float32 = new Float32Array(_convoBuffer);
|
|
20
|
-
const _float64 = new Float64Array(_convoBuffer);
|
|
21
|
-
const _int64 = new BigInt64Array(_convoBuffer);
|
|
22
|
-
const hasBufferByteLength = (typeof Buffer !== 'undefined' && Buffer.byteLength);
|
|
23
|
-
const utf8Length = (hasBufferByteLength)
|
|
24
|
-
? Buffer.byteLength // node
|
|
25
|
-
: function (str, _) {
|
|
26
|
-
var c = 0, length = 0;
|
|
27
|
-
for (var i = 0, l = str.length; i < l; i++) {
|
|
28
|
-
c = str.charCodeAt(i);
|
|
29
|
-
if (c < 0x80) {
|
|
30
|
-
length += 1;
|
|
31
|
-
}
|
|
32
|
-
else if (c < 0x800) {
|
|
33
|
-
length += 2;
|
|
34
|
-
}
|
|
35
|
-
else if (c < 0xd800 || c >= 0xe000) {
|
|
36
|
-
length += 3;
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
i++;
|
|
40
|
-
length += 4;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return length;
|
|
44
|
-
};
|
|
45
|
-
function utf8Write(view, str, it) {
|
|
46
|
-
var c = 0;
|
|
47
|
-
for (var i = 0, l = str.length; i < l; i++) {
|
|
48
|
-
c = str.charCodeAt(i);
|
|
49
|
-
if (c < 0x80) {
|
|
50
|
-
view[it.offset++] = c;
|
|
51
|
-
}
|
|
52
|
-
else if (c < 0x800) {
|
|
53
|
-
view[it.offset] = 0xc0 | (c >> 6);
|
|
54
|
-
view[it.offset + 1] = 0x80 | (c & 0x3f);
|
|
55
|
-
it.offset += 2;
|
|
56
|
-
}
|
|
57
|
-
else if (c < 0xd800 || c >= 0xe000) {
|
|
58
|
-
view[it.offset] = 0xe0 | (c >> 12);
|
|
59
|
-
view[it.offset + 1] = 0x80 | (c >> 6 & 0x3f);
|
|
60
|
-
view[it.offset + 2] = 0x80 | (c & 0x3f);
|
|
61
|
-
it.offset += 3;
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
i++;
|
|
65
|
-
c = 0x10000 + (((c & 0x3ff) << 10) | (str.charCodeAt(i) & 0x3ff));
|
|
66
|
-
view[it.offset] = 0xf0 | (c >> 18);
|
|
67
|
-
view[it.offset + 1] = 0x80 | (c >> 12 & 0x3f);
|
|
68
|
-
view[it.offset + 2] = 0x80 | (c >> 6 & 0x3f);
|
|
69
|
-
view[it.offset + 3] = 0x80 | (c & 0x3f);
|
|
70
|
-
it.offset += 4;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
function int8(bytes, value, it) {
|
|
75
|
-
bytes[it.offset++] = value & 255;
|
|
76
|
-
}
|
|
77
|
-
;
|
|
78
|
-
function uint8(bytes, value, it) {
|
|
79
|
-
bytes[it.offset++] = value & 255;
|
|
80
|
-
}
|
|
81
|
-
;
|
|
82
|
-
function int16(bytes, value, it) {
|
|
83
|
-
bytes[it.offset++] = value & 255;
|
|
84
|
-
bytes[it.offset++] = (value >> 8) & 255;
|
|
85
|
-
}
|
|
86
|
-
;
|
|
87
|
-
function uint16(bytes, value, it) {
|
|
88
|
-
bytes[it.offset++] = value & 255;
|
|
89
|
-
bytes[it.offset++] = (value >> 8) & 255;
|
|
90
|
-
}
|
|
91
|
-
;
|
|
92
|
-
function int32(bytes, value, it) {
|
|
93
|
-
bytes[it.offset++] = value & 255;
|
|
94
|
-
bytes[it.offset++] = (value >> 8) & 255;
|
|
95
|
-
bytes[it.offset++] = (value >> 16) & 255;
|
|
96
|
-
bytes[it.offset++] = (value >> 24) & 255;
|
|
97
|
-
}
|
|
98
|
-
;
|
|
99
|
-
function uint32(bytes, value, it) {
|
|
100
|
-
const b4 = value >> 24;
|
|
101
|
-
const b3 = value >> 16;
|
|
102
|
-
const b2 = value >> 8;
|
|
103
|
-
const b1 = value;
|
|
104
|
-
bytes[it.offset++] = b1 & 255;
|
|
105
|
-
bytes[it.offset++] = b2 & 255;
|
|
106
|
-
bytes[it.offset++] = b3 & 255;
|
|
107
|
-
bytes[it.offset++] = b4 & 255;
|
|
108
|
-
}
|
|
109
|
-
;
|
|
110
|
-
function int64(bytes, value, it) {
|
|
111
|
-
const high = Math.floor(value / Math.pow(2, 32));
|
|
112
|
-
const low = value >>> 0;
|
|
113
|
-
uint32(bytes, low, it);
|
|
114
|
-
uint32(bytes, high, it);
|
|
115
|
-
}
|
|
116
|
-
;
|
|
117
|
-
function uint64(bytes, value, it) {
|
|
118
|
-
const high = (value / Math.pow(2, 32)) >> 0;
|
|
119
|
-
const low = value >>> 0;
|
|
120
|
-
uint32(bytes, low, it);
|
|
121
|
-
uint32(bytes, high, it);
|
|
122
|
-
}
|
|
123
|
-
;
|
|
124
|
-
function bigint64(bytes, value, it) {
|
|
125
|
-
_int64[0] = BigInt.asIntN(64, value);
|
|
126
|
-
int32(bytes, _int32[0], it);
|
|
127
|
-
int32(bytes, _int32[1], it);
|
|
128
|
-
}
|
|
129
|
-
function biguint64(bytes, value, it) {
|
|
130
|
-
_int64[0] = BigInt.asIntN(64, value);
|
|
131
|
-
int32(bytes, _int32[0], it);
|
|
132
|
-
int32(bytes, _int32[1], it);
|
|
133
|
-
}
|
|
134
|
-
function float32(bytes, value, it) {
|
|
135
|
-
_float32[0] = value;
|
|
136
|
-
int32(bytes, _int32[0], it);
|
|
137
|
-
}
|
|
138
|
-
function float64(bytes, value, it) {
|
|
139
|
-
_float64[0] = value;
|
|
140
|
-
int32(bytes, _int32[_isLittleEndian ? 0 : 1], it);
|
|
141
|
-
int32(bytes, _int32[_isLittleEndian ? 1 : 0], it);
|
|
142
|
-
}
|
|
143
|
-
function boolean(bytes, value, it) {
|
|
144
|
-
bytes[it.offset++] = value ? 1 : 0; // uint8
|
|
145
|
-
}
|
|
146
|
-
;
|
|
147
|
-
function string(bytes, value, it) {
|
|
148
|
-
// encode `null` strings as empty.
|
|
149
|
-
if (!value) {
|
|
150
|
-
value = "";
|
|
151
|
-
}
|
|
152
|
-
let length = utf8Length(value, "utf8");
|
|
153
|
-
let size = 0;
|
|
154
|
-
// fixstr
|
|
155
|
-
if (length < 0x20) {
|
|
156
|
-
bytes[it.offset++] = length | 0xa0;
|
|
157
|
-
size = 1;
|
|
158
|
-
}
|
|
159
|
-
// str 8
|
|
160
|
-
else if (length < 0x100) {
|
|
161
|
-
bytes[it.offset++] = 0xd9;
|
|
162
|
-
bytes[it.offset++] = length % 255;
|
|
163
|
-
size = 2;
|
|
164
|
-
}
|
|
165
|
-
// str 16
|
|
166
|
-
else if (length < 0x10000) {
|
|
167
|
-
bytes[it.offset++] = 0xda;
|
|
168
|
-
uint16(bytes, length, it);
|
|
169
|
-
size = 3;
|
|
170
|
-
}
|
|
171
|
-
// str 32
|
|
172
|
-
else if (length < 0x100000000) {
|
|
173
|
-
bytes[it.offset++] = 0xdb;
|
|
174
|
-
uint32(bytes, length, it);
|
|
175
|
-
size = 5;
|
|
176
|
-
}
|
|
177
|
-
else {
|
|
178
|
-
throw new Error('String too long');
|
|
179
|
-
}
|
|
180
|
-
utf8Write(bytes, value, it);
|
|
181
|
-
return size + length;
|
|
182
|
-
}
|
|
183
|
-
function number(bytes, value, it) {
|
|
184
|
-
if (isNaN(value)) {
|
|
185
|
-
return number(bytes, 0, it);
|
|
186
|
-
}
|
|
187
|
-
else if (!isFinite(value)) {
|
|
188
|
-
return number(bytes, (value > 0) ? Number.MAX_SAFE_INTEGER : -Number.MAX_SAFE_INTEGER, it);
|
|
189
|
-
}
|
|
190
|
-
else if (value !== (value | 0)) {
|
|
191
|
-
if (Math.abs(value) <= 3.4028235e+38) { // range check
|
|
192
|
-
_float32[0] = value;
|
|
193
|
-
if (Math.abs(Math.abs(_float32[0]) - Math.abs(value)) < 1e-4) { // precision check; adjust 1e-n (n = precision) to in-/decrease acceptable precision loss
|
|
194
|
-
// now we know value is in range for f32 and has acceptable precision for f32
|
|
195
|
-
bytes[it.offset++] = 0xca;
|
|
196
|
-
float32(bytes, value, it);
|
|
197
|
-
return 5;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
bytes[it.offset++] = 0xcb;
|
|
201
|
-
float64(bytes, value, it);
|
|
202
|
-
return 9;
|
|
203
|
-
}
|
|
204
|
-
if (value >= 0) {
|
|
205
|
-
// positive fixnum
|
|
206
|
-
if (value < 0x80) {
|
|
207
|
-
bytes[it.offset++] = value & 255; // uint8
|
|
208
|
-
return 1;
|
|
209
|
-
}
|
|
210
|
-
// uint 8
|
|
211
|
-
if (value < 0x100) {
|
|
212
|
-
bytes[it.offset++] = 0xcc;
|
|
213
|
-
bytes[it.offset++] = value & 255; // uint8
|
|
214
|
-
return 2;
|
|
215
|
-
}
|
|
216
|
-
// uint 16
|
|
217
|
-
if (value < 0x10000) {
|
|
218
|
-
bytes[it.offset++] = 0xcd;
|
|
219
|
-
uint16(bytes, value, it);
|
|
220
|
-
return 3;
|
|
221
|
-
}
|
|
222
|
-
// uint 32
|
|
223
|
-
if (value < 0x100000000) {
|
|
224
|
-
bytes[it.offset++] = 0xce;
|
|
225
|
-
uint32(bytes, value, it);
|
|
226
|
-
return 5;
|
|
227
|
-
}
|
|
228
|
-
// uint 64
|
|
229
|
-
bytes[it.offset++] = 0xcf;
|
|
230
|
-
uint64(bytes, value, it);
|
|
231
|
-
return 9;
|
|
232
|
-
}
|
|
233
|
-
else {
|
|
234
|
-
// negative fixnum
|
|
235
|
-
if (value >= -0x20) {
|
|
236
|
-
bytes[it.offset++] = 0xe0 | (value + 0x20);
|
|
237
|
-
return 1;
|
|
238
|
-
}
|
|
239
|
-
// int 8
|
|
240
|
-
if (value >= -0x80) {
|
|
241
|
-
bytes[it.offset++] = 0xd0;
|
|
242
|
-
int8(bytes, value, it);
|
|
243
|
-
return 2;
|
|
244
|
-
}
|
|
245
|
-
// int 16
|
|
246
|
-
if (value >= -0x8000) {
|
|
247
|
-
bytes[it.offset++] = 0xd1;
|
|
248
|
-
int16(bytes, value, it);
|
|
249
|
-
return 3;
|
|
250
|
-
}
|
|
251
|
-
// int 32
|
|
252
|
-
if (value >= -0x80000000) {
|
|
253
|
-
bytes[it.offset++] = 0xd2;
|
|
254
|
-
int32(bytes, value, it);
|
|
255
|
-
return 5;
|
|
256
|
-
}
|
|
257
|
-
// int 64
|
|
258
|
-
bytes[it.offset++] = 0xd3;
|
|
259
|
-
int64(bytes, value, it);
|
|
260
|
-
return 9;
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
exports.encode = {
|
|
264
|
-
int8,
|
|
265
|
-
uint8,
|
|
266
|
-
int16,
|
|
267
|
-
uint16,
|
|
268
|
-
int32,
|
|
269
|
-
uint32,
|
|
270
|
-
int64,
|
|
271
|
-
uint64,
|
|
272
|
-
bigint64,
|
|
273
|
-
biguint64,
|
|
274
|
-
float32,
|
|
275
|
-
float64,
|
|
276
|
-
boolean,
|
|
277
|
-
string,
|
|
278
|
-
number,
|
|
279
|
-
utf8Write,
|
|
280
|
-
utf8Length,
|
|
281
|
-
};
|
|
282
|
-
//# sourceMappingURL=encode.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"encode.js","sourceRoot":"","sources":["../../src/encoding/encode.ts"],"names":[],"mappings":";AAAA,cAAc;;;AA8Bd;;;GAGG;AAEH,IAAI,WAAwB,CAAC;AAC7B,aAAa;AACb,IAAI,CAAC;IAAC,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;AAAC,CAAC;AAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;AAEtD,yE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AAC,CAAC;QACX,CAAC;QAED,SAAS;QACT,IAAI,KAAK,IAAI,CAAC,MAAM,EAAE,CAAC;YACrB,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC;YAC1B,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;YACxB,OAAO,CAAC,CAAC;QACX,CAAC;QAED,SAAS;QACT,IAAI,KAAK,IAAI,CAAC,UAAU,EAAE,CAAC;YACzB,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC;YAC1B,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;YACxB,OAAO,CAAC,CAAC;QACX,CAAC;QAED,SAAS;QACT,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC;QAC1B,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QACxB,OAAO,CAAC,CAAC;IACX,CAAC;AACH,CAAC;AAEY,QAAA,MAAM,GAAG;IAClB,IAAI;IACJ,KAAK;IACL,KAAK;IACL,MAAM;IACN,KAAK;IACL,MAAM;IACN,KAAK;IACL,MAAM;IACN,QAAQ;IACR,SAAS;IACT,OAAO;IACP,OAAO;IACP,OAAO;IACP,MAAM;IACN,MAAM;IACN,SAAS;IACT,UAAU;CACb,CAAA","sourcesContent":["// @ts-nocheck\n\n/**\n * Copyright (c) 2018 Endel Dreyer\n * Copyright (c) 2014 Ion Drive Software Ltd.\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE\n */\n\nimport type { TextEncoder } from \"util\";\nimport type { Iterator } from \"./decode\";\n\nexport type BufferLike = ArrayLike<number> & { [index: number]: number };\n\n/**\n * msgpack implementation highly based on notepack.io\n * https://github.com/darrachequesne/notepack\n */\n\nlet textEncoder: TextEncoder;\n// @ts-ignore\ntry { textEncoder = new TextEncoder(); } catch (e) { }\n\n// force little endian to facilitate decoding on multiple implementations\nconst _isLittleEndian = true; // new Uint16Array(new Uint8Array([1, 0]).buffer)[0] === 1;\nconst _convoBuffer = new ArrayBuffer(8);\nconst _int32 = new Int32Array(_convoBuffer);\nconst _float32 = new Float32Array(_convoBuffer);\nconst _float64 = new Float64Array(_convoBuffer);\nconst _int64 = new BigInt64Array(_convoBuffer);\n\nconst hasBufferByteLength = (typeof Buffer !== 'undefined' && Buffer.byteLength);\n\nconst utf8Length: (str: string, _?: any) => number = (hasBufferByteLength)\n ? Buffer.byteLength // node\n : function (str: string, _?: any) {\n var c = 0, length = 0;\n for (var i = 0, l = str.length; i < l; i++) {\n c = str.charCodeAt(i);\n if (c < 0x80) {\n length += 1;\n }\n else if (c < 0x800) {\n length += 2;\n }\n else if (c < 0xd800 || c >= 0xe000) {\n length += 3;\n }\n else {\n i++;\n length += 4;\n }\n }\n return length;\n }\n\nfunction utf8Write(view: BufferLike, str: string, it: Iterator) {\n var c = 0;\n for (var i = 0, l = str.length; i < l; i++) {\n c = str.charCodeAt(i);\n if (c < 0x80) {\n view[it.offset++] = c;\n }\n else if (c < 0x800) {\n view[it.offset] = 0xc0 | (c >> 6);\n view[it.offset + 1] = 0x80 | (c & 0x3f);\n it.offset += 2;\n }\n else if (c < 0xd800 || c >= 0xe000) {\n view[it.offset] = 0xe0 | (c >> 12);\n view[it.offset+1] = 0x80 | (c >> 6 & 0x3f);\n view[it.offset+2] = 0x80 | (c & 0x3f);\n it.offset += 3;\n }\n else {\n i++;\n c = 0x10000 + (((c & 0x3ff) << 10) | (str.charCodeAt(i) & 0x3ff));\n view[it.offset] = 0xf0 | (c >> 18);\n view[it.offset+1] = 0x80 | (c >> 12 & 0x3f);\n view[it.offset+2] = 0x80 | (c >> 6 & 0x3f);\n view[it.offset+3] = 0x80 | (c & 0x3f);\n it.offset += 4;\n }\n }\n}\n\nfunction int8(bytes: BufferLike, value: number, it: Iterator) {\n bytes[it.offset++] = value & 255;\n};\n\nfunction uint8(bytes: BufferLike, value: number, it: Iterator) {\n bytes[it.offset++] = value & 255;\n};\n\nfunction int16(bytes: BufferLike, value: number, it: Iterator) {\n bytes[it.offset++] = value & 255;\n bytes[it.offset++] = (value >> 8) & 255;\n};\n\nfunction uint16(bytes: BufferLike, value: number, it: Iterator) {\n bytes[it.offset++] = value & 255;\n bytes[it.offset++] = (value >> 8) & 255;\n};\n\nfunction int32(bytes: BufferLike, value: number, it: Iterator) {\n bytes[it.offset++] = value & 255;\n bytes[it.offset++] = (value >> 8) & 255;\n bytes[it.offset++] = (value >> 16) & 255;\n bytes[it.offset++] = (value >> 24) & 255;\n};\n\nfunction uint32(bytes: BufferLike, value: number, it: Iterator) {\n const b4 = value >> 24;\n const b3 = value >> 16;\n const b2 = value >> 8;\n const b1 = value;\n bytes[it.offset++] = b1 & 255;\n bytes[it.offset++] = b2 & 255;\n bytes[it.offset++] = b3 & 255;\n bytes[it.offset++] = b4 & 255;\n};\n\nfunction int64(bytes: BufferLike, value: number, it: Iterator) {\n const high = Math.floor(value / Math.pow(2, 32));\n const low = value >>> 0;\n uint32(bytes, low, it);\n uint32(bytes, high, it);\n};\n\nfunction uint64(bytes: BufferLike, value: number, it: Iterator) {\n const high = (value / Math.pow(2, 32)) >> 0;\n const low = value >>> 0;\n uint32(bytes, low, it);\n uint32(bytes, high, it);\n};\n\nfunction bigint64(bytes: BufferLike, value: bigint, it: Iterator) {\n _int64[0] = BigInt.asIntN(64, value);\n int32(bytes, _int32[0], it);\n int32(bytes, _int32[1], it);\n}\n\nfunction biguint64(bytes: BufferLike, value: bigint, it: Iterator) {\n _int64[0] = BigInt.asIntN(64, value);\n int32(bytes, _int32[0], it);\n int32(bytes, _int32[1], it);\n}\n\nfunction float32(bytes: BufferLike, value: number, it: Iterator) {\n _float32[0] = value;\n int32(bytes, _int32[0], it);\n}\n\nfunction float64(bytes: BufferLike, value: number, it: Iterator) {\n _float64[0] = value;\n int32(bytes, _int32[_isLittleEndian ? 0 : 1], it);\n int32(bytes, _int32[_isLittleEndian ? 1 : 0], it);\n}\n\nfunction boolean(bytes: BufferLike, value: number, it: Iterator) {\n bytes[it.offset++] = value ? 1 : 0; // uint8\n};\n\nfunction string(bytes: BufferLike, value: string, it: Iterator) {\n // encode `null` strings as empty.\n if (!value) { value = \"\"; }\n\n let length = utf8Length(value, \"utf8\");\n let size = 0;\n\n // fixstr\n if (length < 0x20) {\n bytes[it.offset++] = length | 0xa0;\n size = 1;\n }\n // str 8\n else if (length < 0x100) {\n bytes[it.offset++] = 0xd9;\n bytes[it.offset++] = length % 255;\n size = 2;\n }\n // str 16\n else if (length < 0x10000) {\n bytes[it.offset++] = 0xda;\n uint16(bytes, length, it);\n size = 3;\n }\n // str 32\n else if (length < 0x100000000) {\n bytes[it.offset++] = 0xdb;\n uint32(bytes, length, it);\n size = 5;\n } else {\n throw new Error('String too long');\n }\n\n utf8Write(bytes, value, it);\n\n return size + length;\n}\n\nfunction number(bytes: BufferLike, value: number, it: Iterator) {\n if (isNaN(value)) {\n return number(bytes, 0, it);\n\n } else if (!isFinite(value)) {\n return number(bytes, (value > 0) ? Number.MAX_SAFE_INTEGER : -Number.MAX_SAFE_INTEGER, it);\n\n } else if (value !== (value|0)) {\n if (Math.abs(value) <= 3.4028235e+38) { // range check\n _float32[0] = value;\n if (Math.abs(Math.abs(_float32[0]) - Math.abs(value)) < 1e-4) { // precision check; adjust 1e-n (n = precision) to in-/decrease acceptable precision loss\n // now we know value is in range for f32 and has acceptable precision for f32\n bytes[it.offset++] = 0xca;\n float32(bytes, value, it);\n return 5;\n }\n }\n\n bytes[it.offset++] = 0xcb;\n float64(bytes, value, it);\n return 9;\n }\n\n if (value >= 0) {\n // positive fixnum\n if (value < 0x80) {\n bytes[it.offset++] = value & 255; // uint8\n return 1;\n }\n\n // uint 8\n if (value < 0x100) {\n bytes[it.offset++] = 0xcc;\n bytes[it.offset++] = value & 255; // uint8\n return 2;\n }\n\n // uint 16\n if (value < 0x10000) {\n bytes[it.offset++] = 0xcd;\n uint16(bytes, value, it);\n return 3;\n }\n\n // uint 32\n if (value < 0x100000000) {\n bytes[it.offset++] = 0xce;\n uint32(bytes, value, it);\n return 5;\n }\n\n // uint 64\n bytes[it.offset++] = 0xcf;\n uint64(bytes, value, it);\n return 9;\n\n } else {\n\n // negative fixnum\n if (value >= -0x20) {\n bytes[it.offset++] = 0xe0 | (value + 0x20);\n return 1;\n }\n\n // int 8\n if (value >= -0x80) {\n bytes[it.offset++] = 0xd0;\n int8(bytes, value, it);\n return 2;\n }\n\n // int 16\n if (value >= -0x8000) {\n bytes[it.offset++] = 0xd1;\n int16(bytes, value, it);\n return 3;\n }\n\n // int 32\n if (value >= -0x80000000) {\n bytes[it.offset++] = 0xd2;\n int32(bytes, value, it);\n return 5;\n }\n\n // int 64\n bytes[it.offset++] = 0xd3;\n int64(bytes, value, it);\n return 9;\n }\n}\n\nexport const encode = {\n int8,\n uint8,\n int16,\n uint16,\n int32,\n uint32,\n int64,\n uint64,\n bigint64,\n biguint64,\n float32,\n float64,\n boolean,\n string,\n number,\n utf8Write,\n utf8Length,\n}"]}
|
package/lib/encoding/spec.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OPERATION = exports.TYPE_ID = exports.SWITCH_TO_STRUCTURE = void 0;
|
|
4
|
-
exports.SWITCH_TO_STRUCTURE = 255; // (decoding collides with DELETE_AND_ADD + fieldIndex = 63)
|
|
5
|
-
exports.TYPE_ID = 213;
|
|
6
|
-
/**
|
|
7
|
-
* Encoding Schema field operations.
|
|
8
|
-
*/
|
|
9
|
-
var OPERATION;
|
|
10
|
-
(function (OPERATION) {
|
|
11
|
-
OPERATION[OPERATION["ADD"] = 128] = "ADD";
|
|
12
|
-
OPERATION[OPERATION["REPLACE"] = 0] = "REPLACE";
|
|
13
|
-
OPERATION[OPERATION["DELETE"] = 64] = "DELETE";
|
|
14
|
-
OPERATION[OPERATION["DELETE_AND_MOVE"] = 96] = "DELETE_AND_MOVE";
|
|
15
|
-
OPERATION[OPERATION["MOVE_AND_ADD"] = 160] = "MOVE_AND_ADD";
|
|
16
|
-
OPERATION[OPERATION["DELETE_AND_ADD"] = 192] = "DELETE_AND_ADD";
|
|
17
|
-
/**
|
|
18
|
-
* Collection operations
|
|
19
|
-
*/
|
|
20
|
-
OPERATION[OPERATION["CLEAR"] = 10] = "CLEAR";
|
|
21
|
-
/**
|
|
22
|
-
* ArraySchema operations
|
|
23
|
-
*/
|
|
24
|
-
OPERATION[OPERATION["REVERSE"] = 15] = "REVERSE";
|
|
25
|
-
OPERATION[OPERATION["MOVE"] = 32] = "MOVE";
|
|
26
|
-
OPERATION[OPERATION["DELETE_BY_REFID"] = 33] = "DELETE_BY_REFID";
|
|
27
|
-
OPERATION[OPERATION["ADD_BY_REFID"] = 129] = "ADD_BY_REFID";
|
|
28
|
-
})(OPERATION || (exports.OPERATION = OPERATION = {}));
|
|
29
|
-
//# sourceMappingURL=spec.js.map
|
package/lib/encoding/spec.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"spec.js","sourceRoot":"","sources":["../../src/encoding/spec.ts"],"names":[],"mappings":";;;AAAa,QAAA,mBAAmB,GAAG,GAAG,CAAC,CAAC,4DAA4D;AACvF,QAAA,OAAO,GAAG,GAAG,CAAC;AAE3B;;GAEG;AACH,IAAY,SAoBX;AApBD,WAAY,SAAS;IACjB,yCAAS,CAAA;IACT,+CAAW,CAAA;IACX,8CAAW,CAAA;IACX,gEAAoB,CAAA;IACpB,2DAAkB,CAAA;IAClB,+DAAoB,CAAA;IAEpB;;OAEG;IACH,4CAAU,CAAA;IAEV;;OAEG;IACH,gDAAY,CAAA;IACZ,0CAAS,CAAA;IACT,gEAAoB,CAAA;IACpB,2DAAkB,CAAA;AACtB,CAAC,EApBW,SAAS,yBAAT,SAAS,QAoBpB","sourcesContent":["export const SWITCH_TO_STRUCTURE = 255; // (decoding collides with DELETE_AND_ADD + fieldIndex = 63)\nexport const TYPE_ID = 213;\n\n/**\n * Encoding Schema field operations.\n */\nexport enum OPERATION {\n ADD = 128, // (10000000) add new structure/primitive\n REPLACE = 0, // (00000001) replace structure/primitive\n DELETE = 64, // (01000000) delete field\n DELETE_AND_MOVE = 96, // () ArraySchema only\n MOVE_AND_ADD = 160, // () ArraySchema only\n DELETE_AND_ADD = 192, // (11000000) DELETE field, followed by an ADD\n\n /**\n * Collection operations\n */\n CLEAR = 10,\n\n /**\n * ArraySchema operations\n */\n REVERSE = 15,\n MOVE = 32,\n DELETE_BY_REFID = 33, // This operation is only used at ENCODING time. During DECODING, DELETE_BY_REFID is converted to DELETE\n ADD_BY_REFID = 129,\n}\n"]}
|
package/lib/index.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export { Schema } from "./Schema";
|
|
2
|
-
export type { DataChange } from "./decoder/DecodeOperation";
|
|
3
|
-
export type { ToJSON } from "./types/HelperTypes";
|
|
4
|
-
import { MapSchema } from "./types/custom/MapSchema";
|
|
5
|
-
export { MapSchema };
|
|
6
|
-
import { ArraySchema } from "./types/custom/ArraySchema";
|
|
7
|
-
export { ArraySchema };
|
|
8
|
-
import { CollectionSchema } from "./types/custom/CollectionSchema";
|
|
9
|
-
export { CollectionSchema };
|
|
10
|
-
import { SetSchema } from "./types/custom/SetSchema";
|
|
11
|
-
export { SetSchema };
|
|
12
|
-
import { registerType, defineCustomTypes } from "./types/registry";
|
|
13
|
-
export { registerType, defineCustomTypes };
|
|
14
|
-
export { dumpChanges } from "./utils";
|
|
15
|
-
export { $track, $encoder, $decoder, $filter, $getByIndex, $deleteByIndex, $changes, $childType, $refId } from "./types/symbols";
|
|
16
|
-
export { encode } from "./encoding/encode";
|
|
17
|
-
export { decode, type Iterator } from "./encoding/decode";
|
|
18
|
-
export { Reflection, ReflectionType, ReflectionField, } from "./Reflection";
|
|
19
|
-
export { Metadata } from "./Metadata";
|
|
20
|
-
export { type, deprecated, defineTypes, view, schema, entity, type DefinitionType, type PrimitiveType, type Definition, type SchemaWithExtendsConstructor, type SchemaWithExtends, type SchemaType, } from "./annotations";
|
|
21
|
-
export { TypeContext } from "./types/TypeContext";
|
|
22
|
-
export type { InferValueType, InferSchemaInstanceType, AssignableProps } from "./types/HelperTypes";
|
|
23
|
-
export { getDecoderStateCallbacks, CallbackProxy, SchemaCallback, CollectionCallback, SchemaCallbackProxy } from "./decoder/strategy/getDecoderStateCallbacks";
|
|
24
|
-
export { Callbacks, StateCallbackStrategy } from "./decoder/strategy/Callbacks";
|
|
25
|
-
export { getRawChangesCallback } from "./decoder/strategy/RawChanges";
|
|
26
|
-
export { Encoder } from "./encoder/Encoder";
|
|
27
|
-
export { encodeSchemaOperation, encodeArray, encodeKeyValueOperation } from "./encoder/EncodeOperation";
|
|
28
|
-
export { ChangeTree, Ref, IRef, type ChangeSetName, type ChangeSet } from "./encoder/ChangeTree";
|
|
29
|
-
export { StateView } from "./encoder/StateView";
|
|
30
|
-
export { Decoder } from "./decoder/Decoder";
|
|
31
|
-
export { decodeSchemaOperation, decodeKeyValueOperation } from "./decoder/DecodeOperation";
|
|
32
|
-
export { OPERATION } from "./encoding/spec";
|
package/lib/index.js
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OPERATION = exports.decodeKeyValueOperation = exports.decodeSchemaOperation = exports.Decoder = exports.StateView = exports.ChangeTree = exports.encodeKeyValueOperation = exports.encodeArray = exports.encodeSchemaOperation = exports.Encoder = exports.getRawChangesCallback = exports.StateCallbackStrategy = exports.Callbacks = exports.getDecoderStateCallbacks = exports.TypeContext = exports.entity = exports.schema = exports.view = exports.defineTypes = exports.deprecated = exports.type = exports.Metadata = exports.ReflectionField = exports.ReflectionType = exports.Reflection = exports.decode = exports.encode = exports.$refId = exports.$childType = exports.$changes = exports.$deleteByIndex = exports.$getByIndex = exports.$filter = exports.$decoder = exports.$encoder = exports.$track = exports.dumpChanges = exports.defineCustomTypes = exports.registerType = exports.SetSchema = exports.CollectionSchema = exports.ArraySchema = exports.MapSchema = exports.Schema = void 0;
|
|
4
|
-
var Schema_1 = require("./Schema");
|
|
5
|
-
Object.defineProperty(exports, "Schema", { enumerable: true, get: function () { return Schema_1.Schema; } });
|
|
6
|
-
const MapSchema_1 = require("./types/custom/MapSchema");
|
|
7
|
-
Object.defineProperty(exports, "MapSchema", { enumerable: true, get: function () { return MapSchema_1.MapSchema; } });
|
|
8
|
-
const ArraySchema_1 = require("./types/custom/ArraySchema");
|
|
9
|
-
Object.defineProperty(exports, "ArraySchema", { enumerable: true, get: function () { return ArraySchema_1.ArraySchema; } });
|
|
10
|
-
const CollectionSchema_1 = require("./types/custom/CollectionSchema");
|
|
11
|
-
Object.defineProperty(exports, "CollectionSchema", { enumerable: true, get: function () { return CollectionSchema_1.CollectionSchema; } });
|
|
12
|
-
const SetSchema_1 = require("./types/custom/SetSchema");
|
|
13
|
-
Object.defineProperty(exports, "SetSchema", { enumerable: true, get: function () { return SetSchema_1.SetSchema; } });
|
|
14
|
-
const registry_1 = require("./types/registry");
|
|
15
|
-
Object.defineProperty(exports, "registerType", { enumerable: true, get: function () { return registry_1.registerType; } });
|
|
16
|
-
Object.defineProperty(exports, "defineCustomTypes", { enumerable: true, get: function () { return registry_1.defineCustomTypes; } });
|
|
17
|
-
(0, registry_1.registerType)("map", { constructor: MapSchema_1.MapSchema });
|
|
18
|
-
(0, registry_1.registerType)("array", { constructor: ArraySchema_1.ArraySchema });
|
|
19
|
-
(0, registry_1.registerType)("set", { constructor: SetSchema_1.SetSchema });
|
|
20
|
-
(0, registry_1.registerType)("collection", { constructor: CollectionSchema_1.CollectionSchema, });
|
|
21
|
-
// Utils
|
|
22
|
-
var utils_1 = require("./utils");
|
|
23
|
-
Object.defineProperty(exports, "dumpChanges", { enumerable: true, get: function () { return utils_1.dumpChanges; } });
|
|
24
|
-
// Encoder / Decoder
|
|
25
|
-
var symbols_1 = require("./types/symbols");
|
|
26
|
-
Object.defineProperty(exports, "$track", { enumerable: true, get: function () { return symbols_1.$track; } });
|
|
27
|
-
Object.defineProperty(exports, "$encoder", { enumerable: true, get: function () { return symbols_1.$encoder; } });
|
|
28
|
-
Object.defineProperty(exports, "$decoder", { enumerable: true, get: function () { return symbols_1.$decoder; } });
|
|
29
|
-
Object.defineProperty(exports, "$filter", { enumerable: true, get: function () { return symbols_1.$filter; } });
|
|
30
|
-
Object.defineProperty(exports, "$getByIndex", { enumerable: true, get: function () { return symbols_1.$getByIndex; } });
|
|
31
|
-
Object.defineProperty(exports, "$deleteByIndex", { enumerable: true, get: function () { return symbols_1.$deleteByIndex; } });
|
|
32
|
-
Object.defineProperty(exports, "$changes", { enumerable: true, get: function () { return symbols_1.$changes; } });
|
|
33
|
-
Object.defineProperty(exports, "$childType", { enumerable: true, get: function () { return symbols_1.$childType; } });
|
|
34
|
-
Object.defineProperty(exports, "$refId", { enumerable: true, get: function () { return symbols_1.$refId; } });
|
|
35
|
-
var encode_1 = require("./encoding/encode");
|
|
36
|
-
Object.defineProperty(exports, "encode", { enumerable: true, get: function () { return encode_1.encode; } });
|
|
37
|
-
var decode_1 = require("./encoding/decode");
|
|
38
|
-
Object.defineProperty(exports, "decode", { enumerable: true, get: function () { return decode_1.decode; } });
|
|
39
|
-
// Reflection
|
|
40
|
-
var Reflection_1 = require("./Reflection");
|
|
41
|
-
Object.defineProperty(exports, "Reflection", { enumerable: true, get: function () { return Reflection_1.Reflection; } });
|
|
42
|
-
Object.defineProperty(exports, "ReflectionType", { enumerable: true, get: function () { return Reflection_1.ReflectionType; } });
|
|
43
|
-
Object.defineProperty(exports, "ReflectionField", { enumerable: true, get: function () { return Reflection_1.ReflectionField; } });
|
|
44
|
-
// Annotations, Metadata and TypeContext
|
|
45
|
-
var Metadata_1 = require("./Metadata");
|
|
46
|
-
Object.defineProperty(exports, "Metadata", { enumerable: true, get: function () { return Metadata_1.Metadata; } });
|
|
47
|
-
// Schema definition types
|
|
48
|
-
var annotations_1 = require("./annotations");
|
|
49
|
-
Object.defineProperty(exports, "type", { enumerable: true, get: function () { return annotations_1.type; } });
|
|
50
|
-
Object.defineProperty(exports, "deprecated", { enumerable: true, get: function () { return annotations_1.deprecated; } });
|
|
51
|
-
Object.defineProperty(exports, "defineTypes", { enumerable: true, get: function () { return annotations_1.defineTypes; } });
|
|
52
|
-
Object.defineProperty(exports, "view", { enumerable: true, get: function () { return annotations_1.view; } });
|
|
53
|
-
Object.defineProperty(exports, "schema", { enumerable: true, get: function () { return annotations_1.schema; } });
|
|
54
|
-
Object.defineProperty(exports, "entity", { enumerable: true, get: function () { return annotations_1.entity; } });
|
|
55
|
-
var TypeContext_1 = require("./types/TypeContext");
|
|
56
|
-
Object.defineProperty(exports, "TypeContext", { enumerable: true, get: function () { return TypeContext_1.TypeContext; } });
|
|
57
|
-
var getDecoderStateCallbacks_1 = require("./decoder/strategy/getDecoderStateCallbacks");
|
|
58
|
-
Object.defineProperty(exports, "getDecoderStateCallbacks", { enumerable: true, get: function () { return getDecoderStateCallbacks_1.getDecoderStateCallbacks; } });
|
|
59
|
-
var Callbacks_1 = require("./decoder/strategy/Callbacks");
|
|
60
|
-
Object.defineProperty(exports, "Callbacks", { enumerable: true, get: function () { return Callbacks_1.Callbacks; } });
|
|
61
|
-
Object.defineProperty(exports, "StateCallbackStrategy", { enumerable: true, get: function () { return Callbacks_1.StateCallbackStrategy; } });
|
|
62
|
-
var RawChanges_1 = require("./decoder/strategy/RawChanges");
|
|
63
|
-
Object.defineProperty(exports, "getRawChangesCallback", { enumerable: true, get: function () { return RawChanges_1.getRawChangesCallback; } });
|
|
64
|
-
var Encoder_1 = require("./encoder/Encoder");
|
|
65
|
-
Object.defineProperty(exports, "Encoder", { enumerable: true, get: function () { return Encoder_1.Encoder; } });
|
|
66
|
-
var EncodeOperation_1 = require("./encoder/EncodeOperation");
|
|
67
|
-
Object.defineProperty(exports, "encodeSchemaOperation", { enumerable: true, get: function () { return EncodeOperation_1.encodeSchemaOperation; } });
|
|
68
|
-
Object.defineProperty(exports, "encodeArray", { enumerable: true, get: function () { return EncodeOperation_1.encodeArray; } });
|
|
69
|
-
Object.defineProperty(exports, "encodeKeyValueOperation", { enumerable: true, get: function () { return EncodeOperation_1.encodeKeyValueOperation; } });
|
|
70
|
-
var ChangeTree_1 = require("./encoder/ChangeTree");
|
|
71
|
-
Object.defineProperty(exports, "ChangeTree", { enumerable: true, get: function () { return ChangeTree_1.ChangeTree; } });
|
|
72
|
-
var StateView_1 = require("./encoder/StateView");
|
|
73
|
-
Object.defineProperty(exports, "StateView", { enumerable: true, get: function () { return StateView_1.StateView; } });
|
|
74
|
-
var Decoder_1 = require("./decoder/Decoder");
|
|
75
|
-
Object.defineProperty(exports, "Decoder", { enumerable: true, get: function () { return Decoder_1.Decoder; } });
|
|
76
|
-
var DecodeOperation_1 = require("./decoder/DecodeOperation");
|
|
77
|
-
Object.defineProperty(exports, "decodeSchemaOperation", { enumerable: true, get: function () { return DecodeOperation_1.decodeSchemaOperation; } });
|
|
78
|
-
Object.defineProperty(exports, "decodeKeyValueOperation", { enumerable: true, get: function () { return DecodeOperation_1.decodeKeyValueOperation; } });
|
|
79
|
-
var spec_1 = require("./encoding/spec");
|
|
80
|
-
Object.defineProperty(exports, "OPERATION", { enumerable: true, get: function () { return spec_1.OPERATION; } });
|
|
81
|
-
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mCAAkC;AAAzB,gGAAA,MAAM,OAAA;AAIf,wDAAoD;AAC3C,0FADA,qBAAS,OACA;AAElB,4DAAyD;AAChD,4FADA,yBAAW,OACA;AAEpB,sEAAmE;AAC1D,iGADA,mCAAgB,OACA;AAEzB,wDAAqD;AAC5C,0FADA,qBAAS,OACA;AAElB,+CAAmE;AAC1D,6FADA,uBAAY,OACA;AAAE,kGADA,4BAAiB,OACA;AAExC,IAAA,uBAAY,EAAC,KAAK,EAAE,EAAE,WAAW,EAAE,qBAAS,EAAE,CAAC,CAAC;AAChD,IAAA,uBAAY,EAAC,OAAO,EAAE,EAAE,WAAW,EAAE,yBAAW,EAAE,CAAC,CAAC;AACpD,IAAA,uBAAY,EAAC,KAAK,EAAE,EAAE,WAAW,EAAE,qBAAS,EAAE,CAAC,CAAC;AAChD,IAAA,uBAAY,EAAC,YAAY,EAAE,EAAE,WAAW,EAAE,mCAAgB,GAAG,CAAC,CAAC;AAE/D,QAAQ;AACR,iCAAsC;AAA7B,oGAAA,WAAW,OAAA;AAEpB,oBAAoB;AACpB,2CAAiI;AAAxH,iGAAA,MAAM,OAAA;AAAE,mGAAA,QAAQ,OAAA;AAAE,mGAAA,QAAQ,OAAA;AAAE,kGAAA,OAAO,OAAA;AAAE,sGAAA,WAAW,OAAA;AAAE,yGAAA,cAAc,OAAA;AAAE,mGAAA,QAAQ,OAAA;AAAE,qGAAA,UAAU,OAAA;AAAE,iGAAA,MAAM,OAAA;AACvG,4CAA2C;AAAlC,gGAAA,MAAM,OAAA;AACf,4CAA0D;AAAjD,gGAAA,MAAM,OAAA;AAEf,aAAa;AACb,2CAIsB;AAHlB,wGAAA,UAAU,OAAA;AACV,4GAAA,cAAc,OAAA;AACd,6GAAA,eAAe,OAAA;AAGnB,wCAAwC;AACxC,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AAEjB,0BAA0B;AAC1B,6CAcuB;AAbnB,mGAAA,IAAI,OAAA;AACJ,yGAAA,UAAU,OAAA;AACV,0GAAA,WAAW,OAAA;AACX,mGAAA,IAAI,OAAA;AACJ,qGAAA,MAAM,OAAA;AACN,qGAAA,MAAM,OAAA;AAUV,mDAAkD;AAAzC,0GAAA,WAAW,OAAA;AAKpB,wFAA+J;AAAtJ,oIAAA,wBAAwB,OAAA;AACjC,0DAAgF;AAAvE,sGAAA,SAAS,OAAA;AAAE,kHAAA,qBAAqB,OAAA;AACzC,4DAAsE;AAA7D,mHAAA,qBAAqB,OAAA;AAE9B,6CAA4C;AAAnC,kGAAA,OAAO,OAAA;AAChB,6DAAwG;AAA/F,wHAAA,qBAAqB,OAAA;AAAE,8GAAA,WAAW,OAAA;AAAE,0HAAA,uBAAuB,OAAA;AACpE,mDAAgG;AAAvF,wGAAA,UAAU,OAAA;AACnB,iDAAgD;AAAvC,sGAAA,SAAS,OAAA;AAElB,6CAA4C;AAAnC,kGAAA,OAAO,OAAA;AAChB,6DAA2F;AAAlF,wHAAA,qBAAqB,OAAA;AAAE,0HAAA,uBAAuB,OAAA;AAEvD,wCAA4C;AAAnC,iGAAA,SAAS,OAAA","sourcesContent":["export { Schema } from \"./Schema\";\nexport type { DataChange } from \"./decoder/DecodeOperation\";\nexport type { ToJSON } from \"./types/HelperTypes\";\n\nimport { MapSchema } from \"./types/custom/MapSchema\"\nexport { MapSchema };\n\nimport { ArraySchema } from \"./types/custom/ArraySchema\";\nexport { ArraySchema };\n\nimport { CollectionSchema } from \"./types/custom/CollectionSchema\";\nexport { CollectionSchema };\n\nimport { SetSchema } from \"./types/custom/SetSchema\";\nexport { SetSchema };\n\nimport { registerType, defineCustomTypes } from \"./types/registry\";\nexport { registerType, defineCustomTypes };\n\nregisterType(\"map\", { constructor: MapSchema });\nregisterType(\"array\", { constructor: ArraySchema });\nregisterType(\"set\", { constructor: SetSchema });\nregisterType(\"collection\", { constructor: CollectionSchema, });\n\n// Utils\nexport { dumpChanges } from \"./utils\";\n\n// Encoder / Decoder\nexport { $track, $encoder, $decoder, $filter, $getByIndex, $deleteByIndex, $changes, $childType, $refId } from \"./types/symbols\";\nexport { encode } from \"./encoding/encode\";\nexport { decode, type Iterator } from \"./encoding/decode\";\n\n// Reflection\nexport {\n Reflection,\n ReflectionType,\n ReflectionField,\n} from \"./Reflection\";\n\n// Annotations, Metadata and TypeContext\nexport { Metadata } from \"./Metadata\";\n\n// Schema definition types\nexport {\n type,\n deprecated,\n defineTypes,\n view,\n schema,\n entity,\n type DefinitionType,\n type PrimitiveType,\n type Definition,\n // Raw schema() return types\n type SchemaWithExtendsConstructor,\n type SchemaWithExtends,\n type SchemaType,\n} from \"./annotations\";\n\nexport { TypeContext } from \"./types/TypeContext\";\n\n// Helper types for type inference\nexport type { InferValueType, InferSchemaInstanceType, AssignableProps } from \"./types/HelperTypes\";\n\nexport { getDecoderStateCallbacks, CallbackProxy, SchemaCallback, CollectionCallback, SchemaCallbackProxy } from \"./decoder/strategy/getDecoderStateCallbacks\";\nexport { Callbacks, StateCallbackStrategy } from \"./decoder/strategy/Callbacks\";\nexport { getRawChangesCallback } from \"./decoder/strategy/RawChanges\";\n\nexport { Encoder } from \"./encoder/Encoder\";\nexport { encodeSchemaOperation, encodeArray, encodeKeyValueOperation } from \"./encoder/EncodeOperation\";\nexport { ChangeTree, Ref, IRef, type ChangeSetName, type ChangeSet} from \"./encoder/ChangeTree\";\nexport { StateView } from \"./encoder/StateView\";\n\nexport { Decoder } from \"./decoder/Decoder\";\nexport { decodeSchemaOperation, decodeKeyValueOperation } from \"./decoder/DecodeOperation\";\n\nexport { OPERATION } from \"./encoding/spec\";"]}
|
package/lib/symbol.shim.js
DELETED
package/lib/symbol.shim.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"symbol.shim.js","sourceRoot":"","sources":["../src/symbol.shim.ts"],"names":[],"mappings":";;AAWC,MAAc,CAAC,QAAQ,KAAK,MAAM,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC","sourcesContent":["\n//\n// Must have Symbol.metadata defined for metadata support on decorators:\n// https://github.com/microsoft/TypeScript/issues/55453#issuecomment-1687496648\n//\nexport {};\ndeclare global {\n interface SymbolConstructor {\n readonly metadata: unique symbol;\n }\n}\n(Symbol as any).metadata ??= Symbol.for(\"Symbol.metadata\");"]}
|
package/lib/types/HelperTypes.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"HelperTypes.js","sourceRoot":"","sources":["../../src/types/HelperTypes.ts"],"names":[],"mappings":"","sourcesContent":["import type { Definition, DefinitionType, PrimitiveType, RawPrimitiveType } from \"../annotations\";\nimport type { Schema } from \"../Schema\";\nimport type { ArraySchema } from \"./custom/ArraySchema\";\nimport type { CollectionSchema } from \"./custom/CollectionSchema\";\nimport type { MapSchema } from \"./custom/MapSchema\";\nimport type { SetSchema } from \"./custom/SetSchema\";\n\nexport type Constructor<T = {}> = new (...args: any[]) => T;\n\n// Helper to convert primitive type literals to actual runtime types\ntype PrimitiveStringToType<T> =\n T extends \"string\" ? string\n : T extends \"number\" | \"int8\" | \"uint8\" | \"int16\" | \"uint16\" | \"int32\" | \"uint32\" | \"int64\" | \"uint64\" | \"float32\" | \"float64\" ? number\n : T extends \"boolean\" ? boolean\n : T;\n\nexport interface Collection<K = any, V = any, IT = V> {\n [Symbol.iterator](): IterableIterator<IT>;\n forEach(callback: Function): void;\n entries(): IterableIterator<[K, V]>;\n}\n\nexport type InferValueType<T extends DefinitionType> =\n T extends \"string\" ? string\n : T extends \"number\" ? number\n : T extends \"int8\" ? number\n : T extends \"uint8\" ? number\n : T extends \"int16\" ? number\n : T extends \"uint16\" ? number\n : T extends \"int32\" ? number\n : T extends \"uint32\" ? number\n : T extends \"int64\" ? number\n : T extends \"uint64\" ? number\n : T extends \"float32\" ? number\n : T extends \"float64\" ? number\n : T extends \"boolean\" ? boolean\n\n // Handle { type: ... } patterns\n : T extends { type: infer ChildType extends PrimitiveType } ? InferValueType<ChildType>\n : T extends { type: infer ChildType extends Constructor } ? InstanceType<ChildType>\n : T extends { type: Array<infer ChildType> } ? (ChildType extends Record<string | number, string | number> ? ChildType[keyof ChildType][] : ChildType[]) // TS ENUM\n : T extends { type: { map: infer ChildType } } ? (ChildType extends Record<string | number, string | number> ? MapSchema<ChildType[keyof ChildType]> : MapSchema<ChildType>) // TS ENUM\n : T extends { type: { set: infer ChildType } } ? (ChildType extends Record<string | number, string | number> ? SetSchema<ChildType[keyof ChildType]> : SetSchema<ChildType>) // TS ENUM\n : T extends { type: { collection: infer ChildType } } ? (ChildType extends Record<string | number, string | number> ? CollectionSchema<ChildType[keyof ChildType]> : CollectionSchema<ChildType>) // TS ENUM\n : T extends { type: infer ChildType } ? (ChildType extends Record<string | number, string | number> ? ChildType[keyof ChildType] : ChildType) // TS ENUM\n\n // Handle direct array patterns\n : T extends Array<infer ChildType extends Constructor> ? ArraySchema<InstanceType<ChildType>>\n : T extends Array<infer ChildType> ? (ChildType extends Record<string | number, string | number> ? ArraySchema<ChildType[keyof ChildType]> : ArraySchema<PrimitiveStringToType<ChildType>>) // TS ENUM\n\n // Handle collection object patterns\n : T extends { array: infer ChildType extends Constructor } ? ArraySchema<InstanceType<ChildType>>\n : T extends { array: infer ChildType } ? (ChildType extends Record<string | number, string | number> ? ArraySchema<ChildType[keyof ChildType]> : ArraySchema<PrimitiveStringToType<ChildType>>) // TS ENUM\n\n : T extends { map: infer ChildType extends Constructor } ? MapSchema<InstanceType<ChildType>>\n : T extends { map: infer ChildType } ? (ChildType extends Record<string | number, string | number> ? MapSchema<ChildType[keyof ChildType]> : MapSchema<PrimitiveStringToType<ChildType>>) // TS ENUM\n\n : T extends { set: infer ChildType extends Constructor } ? SetSchema<InstanceType<ChildType>>\n : T extends { set: infer ChildType } ? (ChildType extends Record<string | number, string | number> ? SetSchema<ChildType[keyof ChildType]> : SetSchema<ChildType>) // TS ENUM\n\n : T extends { collection: infer ChildType extends Constructor } ? CollectionSchema<InstanceType<ChildType>>\n : T extends { collection: infer ChildType } ? (ChildType extends Record<string | number, string | number> ? CollectionSchema<ChildType[keyof ChildType]> : CollectionSchema<ChildType>) // TS ENUM\n\n // Handle direct types\n : T extends Constructor ? InstanceType<T>\n : T extends Record<string | number, string | number> ? T[keyof T] // TS ENUM\n : T extends PrimitiveType ? T\n\n : never;\n\nexport type InferSchemaInstanceType<T extends Definition> = {\n [K in keyof T]: T[K] extends (...args: any[]) => any\n ? (T[K] extends new (...args: any[]) => any ? InferValueType<T[K]> : T[K])\n : InferValueType<T[K]>\n} & Schema;\n\nexport type NonFunctionProps<T> = Omit<T, {\n [K in keyof T]: T[K] extends Function ? K : never;\n}[keyof T]>;\n\nexport type NonFunctionPropNames<T> = {\n [K in keyof T]: T[K] extends Function ? never : K\n}[keyof T];\n\nexport type NonFunctionNonPrimitivePropNames<T> = {\n [K in keyof T]: T[K] extends Function\n ? never\n : T[K] extends number | string | boolean\n ? never\n : K\n}[keyof T];\n\n// Helper to recursively convert Schema instances to their JSON representation\ntype ToJSONValue<U> = U extends Schema ? ToJSON<U> : PrimitiveStringToType<U>;\n\nexport type ToJSON<T> = NonFunctionProps<{\n [K in keyof T]:\n T[K] extends MapSchema<infer U> ? Record<string, ToJSONValue<U>>\n : T[K] extends Map<string, infer U> ? Record<string, ToJSONValue<U>>\n : T[K] extends ArraySchema<infer U> ? ToJSONValue<U>[]\n : T[K] extends SetSchema<infer U> ? ToJSONValue<U>[]\n : T[K] extends CollectionSchema<infer U> ? ToJSONValue<U>[]\n : T[K] extends Schema ? ToJSON<T[K]>\n : T[K]\n}>;\n\n// Helper type to check if T is exactly 'never' (meaning no InitProps was provided)\nexport type IsNever<T> = [T] extends [never] ? true : false;\n\n/**\n * Type helper for .assign() method - allows assigning values in a flexible way\n * - Primitives can be assigned directly\n * - Schema instances can be assigned from plain objects or Schema instances\n * - Collections can be assigned from their JSON representations\n */\nexport type AssignableProps<T> = {\n [K in NonFunctionPropNames<T>]?: T[K] extends MapSchema<infer U>\n ? MapSchema<U> | Record<string, U extends Schema ? (U | AssignableProps<U>) : U>\n : T[K] extends ArraySchema<infer U>\n ? ArraySchema<U> | (U extends Schema ? (U | AssignableProps<U>)[] : U[])\n : T[K] extends SetSchema<infer U>\n ? SetSchema<U> | Set<U> | (U extends Schema ? (U | AssignableProps<U>)[] : U[])\n : T[K] extends CollectionSchema<infer U>\n ? CollectionSchema<U> | (U extends Schema ? (U | AssignableProps<U>)[] : U[])\n : T[K] extends Schema\n ? T[K] | AssignableProps<T[K]>\n : T[K]\n};"]}
|