@colyseus/schema 2.0.4 → 2.0.6
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 +0 -4
- package/build/cjs/index.js +48 -48
- package/build/cjs/index.js.map +1 -1
- package/build/esm/index.mjs +130 -104
- package/build/esm/index.mjs.map +1 -1
- package/build/umd/index.js +50 -50
- package/lib/Reflection.js +87 -119
- package/lib/Reflection.js.map +1 -1
- package/lib/Schema.js +195 -257
- package/lib/Schema.js.map +1 -1
- package/lib/annotations.d.ts +6 -6
- package/lib/annotations.js +64 -92
- package/lib/annotations.js.map +1 -1
- package/lib/changes/ChangeTree.d.ts +1 -1
- package/lib/changes/ChangeTree.js +63 -70
- package/lib/changes/ChangeTree.js.map +1 -1
- package/lib/changes/ReferenceTracker.js +24 -27
- package/lib/changes/ReferenceTracker.js.map +1 -1
- package/lib/codegen/api.js +9 -9
- package/lib/codegen/api.js.map +1 -1
- package/lib/codegen/argv.d.ts +1 -1
- package/lib/codegen/argv.js +11 -11
- package/lib/codegen/argv.js.map +1 -1
- package/lib/codegen/cli.js +21 -10
- package/lib/codegen/cli.js.map +1 -1
- package/lib/codegen/languages/cpp.js +126 -77
- package/lib/codegen/languages/cpp.js.map +1 -1
- package/lib/codegen/languages/csharp.js +121 -62
- package/lib/codegen/languages/csharp.js.map +1 -1
- package/lib/codegen/languages/haxe.js +34 -26
- package/lib/codegen/languages/haxe.js.map +1 -1
- package/lib/codegen/languages/java.js +39 -27
- package/lib/codegen/languages/java.js.map +1 -1
- package/lib/codegen/languages/js.js +48 -32
- package/lib/codegen/languages/js.js.map +1 -1
- package/lib/codegen/languages/lua.js +35 -24
- package/lib/codegen/languages/lua.js.map +1 -1
- package/lib/codegen/languages/ts.js +63 -68
- package/lib/codegen/languages/ts.js.map +1 -1
- package/lib/codegen/parser.d.ts +9 -1
- package/lib/codegen/parser.js +88 -46
- package/lib/codegen/parser.js.map +1 -1
- package/lib/codegen/types.d.ts +8 -0
- package/lib/codegen/types.js +64 -54
- package/lib/codegen/types.js.map +1 -1
- package/lib/encoding/decode.js +15 -15
- package/lib/encoding/decode.js.map +1 -1
- package/lib/encoding/encode.js +14 -14
- package/lib/encoding/encode.js.map +1 -1
- package/lib/events/EventEmitter.d.ts +1 -1
- package/lib/events/EventEmitter.js +16 -47
- package/lib/events/EventEmitter.js.map +1 -1
- package/lib/filters/index.js +7 -8
- package/lib/filters/index.js.map +1 -1
- package/lib/index.js +11 -11
- package/lib/index.js.map +1 -1
- package/lib/types/ArraySchema.d.ts +1 -1
- package/lib/types/ArraySchema.js +161 -219
- package/lib/types/ArraySchema.js.map +1 -1
- package/lib/types/CollectionSchema.d.ts +1 -1
- package/lib/types/CollectionSchema.js +63 -71
- package/lib/types/CollectionSchema.js.map +1 -1
- package/lib/types/HelperTypes.d.ts +9 -9
- package/lib/types/MapSchema.d.ts +16 -16
- package/lib/types/MapSchema.js +68 -78
- package/lib/types/MapSchema.js.map +1 -1
- package/lib/types/SetSchema.js +62 -71
- package/lib/types/SetSchema.js.map +1 -1
- package/lib/types/index.js +1 -1
- package/lib/types/index.js.map +1 -1
- package/lib/types/typeRegistry.js +1 -1
- package/lib/types/typeRegistry.js.map +1 -1
- package/lib/types/utils.js +9 -10
- package/lib/types/utils.js.map +1 -1
- package/lib/utils.js +10 -13
- package/lib/utils.js.map +1 -1
- package/package.json +18 -15
- package/src/Reflection.ts +159 -0
- package/src/Schema.ts +1024 -0
- package/src/annotations.ts +400 -0
- package/src/changes/ChangeTree.ts +295 -0
- package/src/changes/ReferenceTracker.ts +81 -0
- package/src/codegen/api.ts +46 -0
- package/src/codegen/argv.ts +40 -0
- package/src/codegen/cli.ts +65 -0
- package/src/codegen/languages/cpp.ts +297 -0
- package/src/codegen/languages/csharp.ts +208 -0
- package/src/codegen/languages/haxe.ts +110 -0
- package/src/codegen/languages/java.ts +115 -0
- package/src/codegen/languages/js.ts +115 -0
- package/src/codegen/languages/lua.ts +125 -0
- package/src/codegen/languages/ts.ts +129 -0
- package/src/codegen/parser.ts +299 -0
- package/src/codegen/types.ts +177 -0
- package/src/encoding/decode.ts +278 -0
- package/src/encoding/encode.ts +283 -0
- package/src/filters/index.ts +23 -0
- package/src/index.ts +59 -0
- package/src/spec.ts +49 -0
- package/src/types/ArraySchema.ts +612 -0
- package/src/types/CollectionSchema.ts +199 -0
- package/src/types/HelperTypes.ts +34 -0
- package/src/types/MapSchema.ts +268 -0
- package/src/types/SetSchema.ts +208 -0
- package/src/types/typeRegistry.ts +19 -0
- package/src/types/utils.ts +62 -0
- package/src/utils.ts +28 -0
package/lib/encoding/decode.js
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
*/
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
25
|
exports.switchStructureCheck = exports.arrayCheck = exports.numberCheck = exports.number = exports.stringCheck = exports.string = exports.boolean = exports.readFloat64 = exports.readFloat32 = exports.uint64 = exports.int64 = exports.float64 = exports.float32 = exports.uint32 = exports.int32 = exports.uint16 = exports.int16 = exports.uint8 = exports.int8 = void 0;
|
|
26
|
-
|
|
26
|
+
const spec_1 = require("../spec");
|
|
27
27
|
function utf8Read(bytes, offset, length) {
|
|
28
28
|
var string = '', chr = 0;
|
|
29
29
|
for (var i = offset, end = offset + length; i < end; i++) {
|
|
@@ -102,24 +102,24 @@ function float64(bytes, it) {
|
|
|
102
102
|
}
|
|
103
103
|
exports.float64 = float64;
|
|
104
104
|
function int64(bytes, it) {
|
|
105
|
-
|
|
106
|
-
|
|
105
|
+
const low = uint32(bytes, it);
|
|
106
|
+
const high = int32(bytes, it) * Math.pow(2, 32);
|
|
107
107
|
return high + low;
|
|
108
108
|
}
|
|
109
109
|
exports.int64 = int64;
|
|
110
110
|
;
|
|
111
111
|
function uint64(bytes, it) {
|
|
112
|
-
|
|
113
|
-
|
|
112
|
+
const low = uint32(bytes, it);
|
|
113
|
+
const high = uint32(bytes, it) * Math.pow(2, 32);
|
|
114
114
|
return high + low;
|
|
115
115
|
}
|
|
116
116
|
exports.uint64 = uint64;
|
|
117
117
|
;
|
|
118
118
|
// force little endian to facilitate decoding on multiple implementations
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
119
|
+
const _isLittleEndian = true; // new Uint16Array(new Uint8Array([1, 0]).buffer)[0] === 1;
|
|
120
|
+
const _int32 = new Int32Array(2);
|
|
121
|
+
const _float32 = new Float32Array(_int32.buffer);
|
|
122
|
+
const _float64 = new Float64Array(_int32.buffer);
|
|
123
123
|
function readFloat32(bytes, it) {
|
|
124
124
|
_int32[0] = int32(bytes, it);
|
|
125
125
|
return _float32[0];
|
|
@@ -139,8 +139,8 @@ function boolean(bytes, it) {
|
|
|
139
139
|
exports.boolean = boolean;
|
|
140
140
|
;
|
|
141
141
|
function string(bytes, it) {
|
|
142
|
-
|
|
143
|
-
|
|
142
|
+
const prefix = bytes[it.offset++];
|
|
143
|
+
let length;
|
|
144
144
|
if (prefix < 0xc0) {
|
|
145
145
|
// fixstr
|
|
146
146
|
length = prefix & 0x1f;
|
|
@@ -154,13 +154,13 @@ function string(bytes, it) {
|
|
|
154
154
|
else if (prefix === 0xdb) {
|
|
155
155
|
length = uint32(bytes, it);
|
|
156
156
|
}
|
|
157
|
-
|
|
157
|
+
const value = utf8Read(bytes, it.offset, length);
|
|
158
158
|
it.offset += length;
|
|
159
159
|
return value;
|
|
160
160
|
}
|
|
161
161
|
exports.string = string;
|
|
162
162
|
function stringCheck(bytes, it) {
|
|
163
|
-
|
|
163
|
+
const prefix = bytes[it.offset];
|
|
164
164
|
return (
|
|
165
165
|
// fixstr
|
|
166
166
|
(prefix < 0xc0 && prefix > 0xa0) ||
|
|
@@ -173,7 +173,7 @@ function stringCheck(bytes, it) {
|
|
|
173
173
|
}
|
|
174
174
|
exports.stringCheck = stringCheck;
|
|
175
175
|
function number(bytes, it) {
|
|
176
|
-
|
|
176
|
+
const prefix = bytes[it.offset++];
|
|
177
177
|
if (prefix < 0x80) {
|
|
178
178
|
// positive fixint
|
|
179
179
|
return prefix;
|
|
@@ -226,7 +226,7 @@ function number(bytes, it) {
|
|
|
226
226
|
exports.number = number;
|
|
227
227
|
;
|
|
228
228
|
function numberCheck(bytes, it) {
|
|
229
|
-
|
|
229
|
+
const prefix = bytes[it.offset];
|
|
230
230
|
// positive fixint - 0x00 - 0x7f
|
|
231
231
|
// float 32 - 0xca
|
|
232
232
|
// float 64 - 0xcb
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decode.js","sourceRoot":"","sources":["../../src/encoding/decode.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;;;AAEH,gCAA8C;AAS9C,SAAS,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM;IACrC,IAAI,MAAM,GAAG,EAAE,EAAE,GAAG,GAAG,CAAC,CAAC;IACzB,KAAK,IAAI,CAAC,GAAG,MAAM,EAAE,GAAG,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;QACxD,IAAI,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,IAAI,EAAE;YAC1B,MAAM,IAAI,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;YACpC,SAAS;SACV;QACD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,IAAI,EAAE;YAC1B,MAAM,IAAI,MAAM,CAAC,YAAY,CAC3B,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;gBACpB,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CACpB,CAAC;YACF,SAAS;SACV;QACD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,IAAI,EAAE;YAC1B,MAAM,IAAI,MAAM,CAAC,YAAY,CAC3B,CAAC,CAAC,IAAI,GAAG,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,CAAC,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,0BAAmB;QAC5C,+BAA+B;QAC/B,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,CACtF,CAAC;AACJ,CAAC;AAPD,oDAOC","sourcesContent":["/**\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 { SWITCH_TO_STRUCTURE } from \"../spec\";\n\n/**\n * msgpack implementation highly based on notepack.io\n * https://github.com/darrachequesne/notepack\n */\n\nexport interface Iterator { offset: number; }\n\nfunction utf8Read(bytes, offset, length) {\n var string = '', chr = 0;\n for (var i = offset, end = 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 console.error('Invalid byte ' + byte.toString(16));\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 return string;\n}\n\nexport function int8 (bytes: number[], it: Iterator) {\n return uint8(bytes, it) << 24 >> 24;\n};\n\nexport function uint8 (bytes: number[], it: Iterator) {\n return bytes[it.offset++];\n};\n\nexport function int16 (bytes: number[], it: Iterator) {\n return uint16(bytes, it) << 16 >> 16;\n};\n\nexport function uint16 (bytes: number[], it: Iterator) {\n return bytes[it.offset++] | bytes[it.offset++] << 8;\n};\n\nexport function int32 (bytes: number[], it: Iterator) {\n return bytes[it.offset++] | bytes[it.offset++] << 8 | bytes[it.offset++] << 16 | bytes[it.offset++] << 24;\n};\n\nexport function uint32 (bytes: number[], it: Iterator) {\n return int32(bytes, it) >>> 0;\n};\n\nexport function float32(bytes: number[], it: Iterator) {\n return readFloat32(bytes, it);\n}\n\nexport function float64(bytes: number[], it: Iterator) {\n return readFloat64(bytes, it);\n}\n\nexport function int64(bytes: number[], it: Iterator) {\n const low = uint32(bytes, it);\n const high = int32(bytes, it) * Math.pow(2, 32);\n return high + low;\n};\n\nexport function uint64(bytes: number[], it: Iterator) {\n const low = uint32(bytes, it);\n const high = uint32(bytes, it) * Math.pow(2, 32);\n return high + low;\n};\n\n// force little endian to facilitate decoding on multiple implementations\nconst _isLittleEndian = true; // new Uint16Array(new Uint8Array([1, 0]).buffer)[0] === 1;\nconst _int32 = new Int32Array(2);\nconst _float32 = new Float32Array(_int32.buffer);\nconst _float64 = new Float64Array(_int32.buffer);\n\nexport function readFloat32 (bytes: number[], it: Iterator) {\n _int32[0] = int32(bytes, it);\n return _float32[0];\n};\n\nexport function readFloat64 (bytes: number[], it: Iterator) {\n _int32[_isLittleEndian ? 0 : 1] = int32(bytes, it);\n _int32[_isLittleEndian ? 1 : 0] = int32(bytes, it);\n return _float64[0];\n};\n\nexport function boolean (bytes: number[], it: Iterator) {\n return uint8(bytes, it) > 0;\n};\n\nexport function string (bytes, 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 const value = utf8Read(bytes, it.offset, length);\n it.offset += length;\n\n return value;\n}\n\nexport function stringCheck(bytes, 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 function number (bytes, 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 readFloat32(bytes, it);\n\n } else if (prefix === 0xcb) {\n // float 64\n return readFloat64(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 numberCheck (bytes, it: Iterator) {\n const prefix = bytes[it.offset];\n // positive fixint - 0x00 - 0x7f\n // float 32 - 0xca\n // float 64 - 0xcb\n // uint 8 - 0xcc\n // uint 16 - 0xcd\n // uint 32 - 0xce\n // uint 64 - 0xcf\n // int 8 - 0xd0\n // int 16 - 0xd1\n // int 32 - 0xd2\n // int 64 - 0xd3\n return (\n prefix < 0x80 ||\n (prefix >= 0xca && prefix <= 0xd3)\n );\n}\n\nexport function arrayCheck (bytes, it: Iterator) {\n return bytes[it.offset] < 0xa0;\n\n // const prefix = bytes[it.offset] ;\n\n // if (prefix < 0xa0) {\n // return prefix;\n\n // // array\n // } else if (prefix === 0xdc) {\n // it.offset += 2;\n\n // } else if (0xdd) {\n // it.offset += 4;\n // }\n\n // return prefix;\n}\n\nexport function switchStructureCheck(bytes, it: Iterator) {\n return (\n // previous byte should be `SWITCH_TO_STRUCTURE`\n bytes[it.offset - 1] === SWITCH_TO_STRUCTURE &&\n // next byte should be a number\n (bytes[it.offset] < 0x80 || (bytes[it.offset] >= 0xca && bytes[it.offset] <= 0xd3))\n );\n}"]}
|
|
1
|
+
{"version":3,"file":"decode.js","sourceRoot":"","sources":["../../src/encoding/decode.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;;;AAEH,kCAA8C;AAS9C,SAAS,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM;IACrC,IAAI,MAA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AE,EAAY;IAC9C,MAAM,MAAM,GAAG,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;IAChC,gCAAgC;IAChC,yBAAyB;IACzB,yBAAyB;IACzB,yBAAyB;IACzB,yBAAyB;IACzB,yBAAyB;IACzB,yBAAyB;IACzB,yBAAyB;IACzB,yBAAyB;IACzB,yBAAyB;IACzB,yBAAyB;IACzB,OAAO,CACL,MAAM,GAAG,IAAI;QACb,CAAC,MAAM,IAAI,IAAI,IAAI,MAAM,IAAI,IAAI,CAAC,CACnC,CAAC;AACJ,CAAC;AAjBD,kCAiBC;AAED,SAAgB,UAAU,CAAE,KAAK,EAAE,EAAY;IAC7C,OAAO,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;IAE/B,oCAAoC;IAEpC,uBAAuB;IACvB,mBAAmB;IAEnB,WAAW;IACX,gCAAgC;IAChC,oBAAoB;IAEpB,qBAAqB;IACrB,oBAAoB;IACpB,IAAI;IAEJ,iBAAiB;AACnB,CAAC;AAjBD,gCAiBC;AAED,SAAgB,oBAAoB,CAAC,KAAK,EAAE,EAAY;IACtD,OAAO;IACH,gDAAgD;IAChD,KAAK,CAAC,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,0BAAmB;QAC5C,+BAA+B;QAC/B,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,CACtF,CAAC;AACJ,CAAC;AAPD,oDAOC","sourcesContent":["/**\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 { SWITCH_TO_STRUCTURE } from \"../spec\";\n\n/**\n * msgpack implementation highly based on notepack.io\n * https://github.com/darrachequesne/notepack\n */\n\nexport interface Iterator { offset: number; }\n\nfunction utf8Read(bytes, offset, length) {\n var string = '', chr = 0;\n for (var i = offset, end = 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 console.error('Invalid byte ' + byte.toString(16));\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 return string;\n}\n\nexport function int8 (bytes: number[], it: Iterator) {\n return uint8(bytes, it) << 24 >> 24;\n};\n\nexport function uint8 (bytes: number[], it: Iterator) {\n return bytes[it.offset++];\n};\n\nexport function int16 (bytes: number[], it: Iterator) {\n return uint16(bytes, it) << 16 >> 16;\n};\n\nexport function uint16 (bytes: number[], it: Iterator) {\n return bytes[it.offset++] | bytes[it.offset++] << 8;\n};\n\nexport function int32 (bytes: number[], it: Iterator) {\n return bytes[it.offset++] | bytes[it.offset++] << 8 | bytes[it.offset++] << 16 | bytes[it.offset++] << 24;\n};\n\nexport function uint32 (bytes: number[], it: Iterator) {\n return int32(bytes, it) >>> 0;\n};\n\nexport function float32(bytes: number[], it: Iterator) {\n return readFloat32(bytes, it);\n}\n\nexport function float64(bytes: number[], it: Iterator) {\n return readFloat64(bytes, it);\n}\n\nexport function int64(bytes: number[], it: Iterator) {\n const low = uint32(bytes, it);\n const high = int32(bytes, it) * Math.pow(2, 32);\n return high + low;\n};\n\nexport function uint64(bytes: number[], it: Iterator) {\n const low = uint32(bytes, it);\n const high = uint32(bytes, it) * Math.pow(2, 32);\n return high + low;\n};\n\n// force little endian to facilitate decoding on multiple implementations\nconst _isLittleEndian = true; // new Uint16Array(new Uint8Array([1, 0]).buffer)[0] === 1;\nconst _int32 = new Int32Array(2);\nconst _float32 = new Float32Array(_int32.buffer);\nconst _float64 = new Float64Array(_int32.buffer);\n\nexport function readFloat32 (bytes: number[], it: Iterator) {\n _int32[0] = int32(bytes, it);\n return _float32[0];\n};\n\nexport function readFloat64 (bytes: number[], it: Iterator) {\n _int32[_isLittleEndian ? 0 : 1] = int32(bytes, it);\n _int32[_isLittleEndian ? 1 : 0] = int32(bytes, it);\n return _float64[0];\n};\n\nexport function boolean (bytes: number[], it: Iterator) {\n return uint8(bytes, it) > 0;\n};\n\nexport function string (bytes, 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 const value = utf8Read(bytes, it.offset, length);\n it.offset += length;\n\n return value;\n}\n\nexport function stringCheck(bytes, 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 function number (bytes, 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 readFloat32(bytes, it);\n\n } else if (prefix === 0xcb) {\n // float 64\n return readFloat64(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 numberCheck (bytes, it: Iterator) {\n const prefix = bytes[it.offset];\n // positive fixint - 0x00 - 0x7f\n // float 32 - 0xca\n // float 64 - 0xcb\n // uint 8 - 0xcc\n // uint 16 - 0xcd\n // uint 32 - 0xce\n // uint 64 - 0xcf\n // int 8 - 0xd0\n // int 16 - 0xd1\n // int 32 - 0xd2\n // int 64 - 0xd3\n return (\n prefix < 0x80 ||\n (prefix >= 0xca && prefix <= 0xd3)\n );\n}\n\nexport function arrayCheck (bytes, it: Iterator) {\n return bytes[it.offset] < 0xa0;\n\n // const prefix = bytes[it.offset] ;\n\n // if (prefix < 0xa0) {\n // return prefix;\n\n // // array\n // } else if (prefix === 0xdc) {\n // it.offset += 2;\n\n // } else if (0xdd) {\n // it.offset += 4;\n // }\n\n // return prefix;\n}\n\nexport function switchStructureCheck(bytes, it: Iterator) {\n return (\n // previous byte should be `SWITCH_TO_STRUCTURE`\n bytes[it.offset - 1] === SWITCH_TO_STRUCTURE &&\n // next byte should be a number\n (bytes[it.offset] < 0x80 || (bytes[it.offset] >= 0xca && bytes[it.offset] <= 0xd3))\n );\n}"]}
|
package/lib/encoding/encode.js
CHANGED
|
@@ -105,10 +105,10 @@ function int32(bytes, value) {
|
|
|
105
105
|
exports.int32 = int32;
|
|
106
106
|
;
|
|
107
107
|
function uint32(bytes, value) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
108
|
+
const b4 = value >> 24;
|
|
109
|
+
const b3 = value >> 16;
|
|
110
|
+
const b2 = value >> 8;
|
|
111
|
+
const b1 = value;
|
|
112
112
|
bytes.push(b1 & 255);
|
|
113
113
|
bytes.push(b2 & 255);
|
|
114
114
|
bytes.push(b3 & 255);
|
|
@@ -117,16 +117,16 @@ function uint32(bytes, value) {
|
|
|
117
117
|
exports.uint32 = uint32;
|
|
118
118
|
;
|
|
119
119
|
function int64(bytes, value) {
|
|
120
|
-
|
|
121
|
-
|
|
120
|
+
const high = Math.floor(value / Math.pow(2, 32));
|
|
121
|
+
const low = value >>> 0;
|
|
122
122
|
uint32(bytes, low);
|
|
123
123
|
uint32(bytes, high);
|
|
124
124
|
}
|
|
125
125
|
exports.int64 = int64;
|
|
126
126
|
;
|
|
127
127
|
function uint64(bytes, value) {
|
|
128
|
-
|
|
129
|
-
|
|
128
|
+
const high = (value / Math.pow(2, 32)) >> 0;
|
|
129
|
+
const low = value >>> 0;
|
|
130
130
|
uint32(bytes, low);
|
|
131
131
|
uint32(bytes, high);
|
|
132
132
|
}
|
|
@@ -141,10 +141,10 @@ function float64(bytes, value) {
|
|
|
141
141
|
}
|
|
142
142
|
exports.float64 = float64;
|
|
143
143
|
// force little endian to facilitate decoding on multiple implementations
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
144
|
+
const _isLittleEndian = true; // new Uint16Array(new Uint8Array([1, 0]).buffer)[0] === 1;
|
|
145
|
+
const _int32 = new Int32Array(2);
|
|
146
|
+
const _float32 = new Float32Array(_int32.buffer);
|
|
147
|
+
const _float64 = new Float64Array(_int32.buffer);
|
|
148
148
|
function writeFloat32(bytes, value) {
|
|
149
149
|
_float32[0] = value;
|
|
150
150
|
int32(bytes, _int32[0]);
|
|
@@ -168,8 +168,8 @@ function string(bytes, value) {
|
|
|
168
168
|
if (!value) {
|
|
169
169
|
value = "";
|
|
170
170
|
}
|
|
171
|
-
|
|
172
|
-
|
|
171
|
+
let length = utf8Length(value);
|
|
172
|
+
let size = 0;
|
|
173
173
|
// fixstr
|
|
174
174
|
if (length < 0x20) {
|
|
175
175
|
bytes.push(length | 0xa0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encode.js","sourceRoot":"","sources":["../../src/encoding/encode.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;;;AAEH;;;GAGG;AAGH,SAAS,UAAU,CAAC,GAAG;IACrB,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC;IACtB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;QAC1C,CAAC,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,C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ACjB,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;YACpB,OAAO,CAAC,CAAC;SACV;QAED,SAAS;QACT,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjB,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QACpB,OAAO,CAAC,CAAC;KACV;AACH,CAAC;AAxFD,wBAwFC","sourcesContent":["/**\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\n/**\n * msgpack implementation highly based on notepack.io\n * https://github.com/darrachequesne/notepack\n */\n\n\nfunction utf8Length(str) {\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\nexport function utf8Write(view, offset, str) {\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[offset++] = c;\n }\n else if (c < 0x800) {\n view[offset++] = 0xc0 | (c >> 6);\n view[offset++] = 0x80 | (c & 0x3f);\n }\n else if (c < 0xd800 || c >= 0xe000) {\n view[offset++] = 0xe0 | (c >> 12);\n view[offset++] = 0x80 | (c >> 6 & 0x3f);\n view[offset++] = 0x80 | (c & 0x3f);\n }\n else {\n i++;\n c = 0x10000 + (((c & 0x3ff) << 10) | (str.charCodeAt(i) & 0x3ff));\n view[offset++] = 0xf0 | (c >> 18);\n view[offset++] = 0x80 | (c >> 12 & 0x3f);\n view[offset++] = 0x80 | (c >> 6 & 0x3f);\n view[offset++] = 0x80 | (c & 0x3f);\n }\n }\n}\n\nexport function int8(bytes, value) {\n bytes.push(value & 255);\n};\n\nexport function uint8(bytes, value) {\n bytes.push(value & 255);\n};\n\nexport function int16(bytes, value) {\n bytes.push(value & 255);\n bytes.push((value >> 8) & 255);\n};\n\nexport function uint16(bytes, value) {\n bytes.push(value & 255);\n bytes.push((value >> 8) & 255);\n};\n\nexport function int32(bytes, value) {\n bytes.push(value & 255);\n bytes.push((value >> 8) & 255);\n bytes.push((value >> 16) & 255);\n bytes.push((value >> 24) & 255);\n};\n\nexport function uint32(bytes, value) {\n const b4 = value >> 24;\n const b3 = value >> 16;\n const b2 = value >> 8;\n const b1 = value;\n bytes.push(b1 & 255);\n bytes.push(b2 & 255);\n bytes.push(b3 & 255);\n bytes.push(b4 & 255);\n};\n\nexport function int64(bytes, value) {\n const high = Math.floor(value / Math.pow(2, 32));\n const low = value >>> 0;\n uint32(bytes, low);\n uint32(bytes, high);\n};\n\nexport function uint64(bytes, value) {\n const high = (value / Math.pow(2, 32)) >> 0;\n const low = value >>> 0;\n uint32(bytes, low);\n uint32(bytes, high);\n};\n\nexport function float32(bytes, value) {\n writeFloat32(bytes, value);\n}\n\nexport function float64(bytes, value) {\n writeFloat64(bytes, value);\n}\n\n// force little endian to facilitate decoding on multiple implementations\nconst _isLittleEndian = true; // new Uint16Array(new Uint8Array([1, 0]).buffer)[0] === 1;\nconst _int32 = new Int32Array(2);\nconst _float32 = new Float32Array(_int32.buffer);\nconst _float64 = new Float64Array(_int32.buffer);\n\nexport function writeFloat32(bytes, value) {\n _float32[0] = value;\n int32(bytes, _int32[0]);\n};\n\nexport function writeFloat64(bytes, value) {\n _float64[0] = value;\n int32(bytes, _int32[_isLittleEndian ? 0 : 1]);\n int32(bytes, _int32[_isLittleEndian ? 1 : 0]);\n};\n\nexport function boolean(bytes, value) {\n return uint8(bytes, value ? 1 : 0);\n};\n\nexport function string(bytes, value) {\n // encode `null` strings as empty.\n if (!value) { value = \"\"; }\n\n let length = utf8Length(value);\n let size = 0;\n\n // fixstr\n if (length < 0x20) {\n bytes.push(length | 0xa0);\n size = 1;\n }\n // str 8\n else if (length < 0x100) {\n bytes.push(0xd9);\n uint8(bytes, length);\n size = 2;\n }\n // str 16\n else if (length < 0x10000) {\n bytes.push(0xda);\n uint16(bytes, length);\n size = 3;\n }\n // str 32\n else if (length < 0x100000000) {\n bytes.push(0xdb);\n uint32(bytes, length);\n size = 5;\n } else {\n throw new Error('String too long');\n }\n\n utf8Write(bytes, bytes.length, value);\n\n return size + length;\n}\n\nexport function number(bytes, value) {\n if (isNaN(value)) {\n return number(bytes, 0);\n\n } else if (!isFinite(value)) {\n return number(bytes, (value > 0) ? Number.MAX_SAFE_INTEGER : -Number.MAX_SAFE_INTEGER);\n\n } else if (value !== (value|0)) {\n bytes.push(0xcb);\n writeFloat64(bytes, value);\n return 9;\n\n // TODO: encode float 32?\n // is it possible to differentiate between float32 / float64 here?\n\n // // float 32\n // bytes.push(0xca);\n // writeFloat32(bytes, value);\n // return 5;\n }\n\n if (value >= 0) {\n // positive fixnum\n if (value < 0x80) {\n uint8(bytes, value);\n return 1;\n }\n\n // uint 8\n if (value < 0x100) {\n bytes.push(0xcc);\n uint8(bytes, value);\n return 2;\n }\n\n // uint 16\n if (value < 0x10000) {\n bytes.push(0xcd);\n uint16(bytes, value);\n return 3;\n }\n\n // uint 32\n if (value < 0x100000000) {\n bytes.push(0xce);\n uint32(bytes, value);\n return 5;\n }\n\n // uint 64\n bytes.push(0xcf);\n uint64(bytes, value);\n return 9;\n\n } else {\n\n // negative fixnum\n if (value >= -0x20) {\n bytes.push(0xe0 | (value + 0x20));\n return 1;\n }\n\n // int 8\n if (value >= -0x80) {\n bytes.push(0xd0);\n int8(bytes, value);\n return 2;\n }\n\n // int 16\n if (value >= -0x8000) {\n bytes.push(0xd1);\n int16(bytes, value);\n return 3;\n }\n\n // int 32\n if (value >= -0x80000000) {\n bytes.push(0xd2);\n int32(bytes, value);\n return 5;\n }\n\n // int 64\n bytes.push(0xd3);\n int64(bytes, value);\n return 9;\n }\n}"]}
|
|
1
|
+
{"version":3,"file":"encode.js","sourceRoot":"","sources":["../../src/encoding/encode.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;;;AAEH;;;GAGG;AAGH,SAAS,UAAU,CAAC,GAAG;IACrB,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC;IACtB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;QAC1C,CAAC,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QACtB,IAAI,CAAC,GAAG,IAAI,EAAE;YACZ,MAAM,IAAI,CAAC,CAAC;SACb;aACI,IAAI,CAAC,GAAG,KAAK,EAAE;YAClB,MAAM,IAAI,CAAC,CAAC;SACb;aACI,IAAI,CAAC,GAAG,MAAM,IAAI,CAAC,IAAI,MAAM,EAAE;YAClC,MAAM,IAAI,CAAC,CAAC;SACb;aACI;YACH,CAAC,EAAE,CAAC;YACJ,MAAM,IAAI,CAAC,CAAC;SACb;KACF;IACD,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ission 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\n/**\n * msgpack implementation highly based on notepack.io\n * https://github.com/darrachequesne/notepack\n */\n\n\nfunction utf8Length(str) {\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\nexport function utf8Write(view, offset, str) {\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[offset++] = c;\n }\n else if (c < 0x800) {\n view[offset++] = 0xc0 | (c >> 6);\n view[offset++] = 0x80 | (c & 0x3f);\n }\n else if (c < 0xd800 || c >= 0xe000) {\n view[offset++] = 0xe0 | (c >> 12);\n view[offset++] = 0x80 | (c >> 6 & 0x3f);\n view[offset++] = 0x80 | (c & 0x3f);\n }\n else {\n i++;\n c = 0x10000 + (((c & 0x3ff) << 10) | (str.charCodeAt(i) & 0x3ff));\n view[offset++] = 0xf0 | (c >> 18);\n view[offset++] = 0x80 | (c >> 12 & 0x3f);\n view[offset++] = 0x80 | (c >> 6 & 0x3f);\n view[offset++] = 0x80 | (c & 0x3f);\n }\n }\n}\n\nexport function int8(bytes, value) {\n bytes.push(value & 255);\n};\n\nexport function uint8(bytes, value) {\n bytes.push(value & 255);\n};\n\nexport function int16(bytes, value) {\n bytes.push(value & 255);\n bytes.push((value >> 8) & 255);\n};\n\nexport function uint16(bytes, value) {\n bytes.push(value & 255);\n bytes.push((value >> 8) & 255);\n};\n\nexport function int32(bytes, value) {\n bytes.push(value & 255);\n bytes.push((value >> 8) & 255);\n bytes.push((value >> 16) & 255);\n bytes.push((value >> 24) & 255);\n};\n\nexport function uint32(bytes, value) {\n const b4 = value >> 24;\n const b3 = value >> 16;\n const b2 = value >> 8;\n const b1 = value;\n bytes.push(b1 & 255);\n bytes.push(b2 & 255);\n bytes.push(b3 & 255);\n bytes.push(b4 & 255);\n};\n\nexport function int64(bytes, value) {\n const high = Math.floor(value / Math.pow(2, 32));\n const low = value >>> 0;\n uint32(bytes, low);\n uint32(bytes, high);\n};\n\nexport function uint64(bytes, value) {\n const high = (value / Math.pow(2, 32)) >> 0;\n const low = value >>> 0;\n uint32(bytes, low);\n uint32(bytes, high);\n};\n\nexport function float32(bytes, value) {\n writeFloat32(bytes, value);\n}\n\nexport function float64(bytes, value) {\n writeFloat64(bytes, value);\n}\n\n// force little endian to facilitate decoding on multiple implementations\nconst _isLittleEndian = true; // new Uint16Array(new Uint8Array([1, 0]).buffer)[0] === 1;\nconst _int32 = new Int32Array(2);\nconst _float32 = new Float32Array(_int32.buffer);\nconst _float64 = new Float64Array(_int32.buffer);\n\nexport function writeFloat32(bytes, value) {\n _float32[0] = value;\n int32(bytes, _int32[0]);\n};\n\nexport function writeFloat64(bytes, value) {\n _float64[0] = value;\n int32(bytes, _int32[_isLittleEndian ? 0 : 1]);\n int32(bytes, _int32[_isLittleEndian ? 1 : 0]);\n};\n\nexport function boolean(bytes, value) {\n return uint8(bytes, value ? 1 : 0);\n};\n\nexport function string(bytes, value) {\n // encode `null` strings as empty.\n if (!value) { value = \"\"; }\n\n let length = utf8Length(value);\n let size = 0;\n\n // fixstr\n if (length < 0x20) {\n bytes.push(length | 0xa0);\n size = 1;\n }\n // str 8\n else if (length < 0x100) {\n bytes.push(0xd9);\n uint8(bytes, length);\n size = 2;\n }\n // str 16\n else if (length < 0x10000) {\n bytes.push(0xda);\n uint16(bytes, length);\n size = 3;\n }\n // str 32\n else if (length < 0x100000000) {\n bytes.push(0xdb);\n uint32(bytes, length);\n size = 5;\n } else {\n throw new Error('String too long');\n }\n\n utf8Write(bytes, bytes.length, value);\n\n return size + length;\n}\n\nexport function number(bytes, value) {\n if (isNaN(value)) {\n return number(bytes, 0);\n\n } else if (!isFinite(value)) {\n return number(bytes, (value > 0) ? Number.MAX_SAFE_INTEGER : -Number.MAX_SAFE_INTEGER);\n\n } else if (value !== (value|0)) {\n bytes.push(0xcb);\n writeFloat64(bytes, value);\n return 9;\n\n // TODO: encode float 32?\n // is it possible to differentiate between float32 / float64 here?\n\n // // float 32\n // bytes.push(0xca);\n // writeFloat32(bytes, value);\n // return 5;\n }\n\n if (value >= 0) {\n // positive fixnum\n if (value < 0x80) {\n uint8(bytes, value);\n return 1;\n }\n\n // uint 8\n if (value < 0x100) {\n bytes.push(0xcc);\n uint8(bytes, value);\n return 2;\n }\n\n // uint 16\n if (value < 0x10000) {\n bytes.push(0xcd);\n uint16(bytes, value);\n return 3;\n }\n\n // uint 32\n if (value < 0x100000000) {\n bytes.push(0xce);\n uint32(bytes, value);\n return 5;\n }\n\n // uint 64\n bytes.push(0xcf);\n uint64(bytes, value);\n return 9;\n\n } else {\n\n // negative fixnum\n if (value >= -0x20) {\n bytes.push(0xe0 | (value + 0x20));\n return 1;\n }\n\n // int 8\n if (value >= -0x80) {\n bytes.push(0xd0);\n int8(bytes, value);\n return 2;\n }\n\n // int 16\n if (value >= -0x8000) {\n bytes.push(0xd1);\n int16(bytes, value);\n return 3;\n }\n\n // int 32\n if (value >= -0x80000000) {\n bytes.push(0xd2);\n int32(bytes, value);\n return 5;\n }\n\n // int 64\n bytes.push(0xd3);\n int64(bytes, value);\n return 9;\n }\n}"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Extracted from https://www.npmjs.com/package/strong-events
|
|
3
3
|
*/
|
|
4
|
-
|
|
4
|
+
type ExtractFunctionParameters<T extends (...args: any[]) => any> = T extends (...args: infer P) => any ? P : never;
|
|
5
5
|
export declare class EventEmitter_<CallbackSignature extends (...args: any[]) => any> {
|
|
6
6
|
handlers: Array<CallbackSignature>;
|
|
7
7
|
register(cb: CallbackSignature, once?: boolean): this;
|
|
@@ -2,61 +2,30 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Extracted from https://www.npmjs.com/package/strong-events
|
|
4
4
|
*/
|
|
5
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
6
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
7
|
-
if (!m) return o;
|
|
8
|
-
var i = m.call(o), r, ar = [], e;
|
|
9
|
-
try {
|
|
10
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
11
|
-
}
|
|
12
|
-
catch (error) { e = { error: error }; }
|
|
13
|
-
finally {
|
|
14
|
-
try {
|
|
15
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
16
|
-
}
|
|
17
|
-
finally { if (e) throw e.error; }
|
|
18
|
-
}
|
|
19
|
-
return ar;
|
|
20
|
-
};
|
|
21
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
22
|
-
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
23
|
-
to[j] = from[i];
|
|
24
|
-
return to;
|
|
25
|
-
};
|
|
26
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
6
|
exports.EventEmitter_ = void 0;
|
|
28
|
-
|
|
29
|
-
|
|
7
|
+
class EventEmitter_ {
|
|
8
|
+
constructor() {
|
|
30
9
|
this.handlers = [];
|
|
31
10
|
}
|
|
32
|
-
|
|
33
|
-
if (once === void 0) { once = false; }
|
|
11
|
+
register(cb, once = false) {
|
|
34
12
|
this.handlers.push(cb);
|
|
35
13
|
return this;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
var args = [];
|
|
46
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
47
|
-
args[_i] = arguments[_i];
|
|
48
|
-
}
|
|
49
|
-
return Promise.all(this.handlers.map(function (handler) { return handler.apply(void 0, __spreadArray([], __read(args))); }));
|
|
50
|
-
};
|
|
51
|
-
EventEmitter_.prototype.remove = function (cb) {
|
|
52
|
-
var index = this.handlers.indexOf(cb);
|
|
14
|
+
}
|
|
15
|
+
invoke(...args) {
|
|
16
|
+
this.handlers.forEach((handler) => handler(...args));
|
|
17
|
+
}
|
|
18
|
+
invokeAsync(...args) {
|
|
19
|
+
return Promise.all(this.handlers.map((handler) => handler(...args)));
|
|
20
|
+
}
|
|
21
|
+
remove(cb) {
|
|
22
|
+
const index = this.handlers.indexOf(cb);
|
|
53
23
|
this.handlers[index] = this.handlers[this.handlers.length - 1];
|
|
54
24
|
this.handlers.pop();
|
|
55
|
-
}
|
|
56
|
-
|
|
25
|
+
}
|
|
26
|
+
clear() {
|
|
57
27
|
this.handlers = [];
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
}());
|
|
28
|
+
}
|
|
29
|
+
}
|
|
61
30
|
exports.EventEmitter_ = EventEmitter_;
|
|
62
31
|
//# sourceMappingURL=EventEmitter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EventEmitter.js","sourceRoot":"","sources":["../../src/events/EventEmitter.ts"],"names":[],"mappings":";AAAA;;GAEG
|
|
1
|
+
{"version":3,"file":"EventEmitter.js","sourceRoot":"","sources":["../../src/events/EventEmitter.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAIH,MAAa,aAAa;IAA1B;QACE,aAAQ,GAA6B,EAAE,CAAC;IAwB1C,CAAC;IAtBC,QAAQ,CAAC,EAAqB,EAAE,OAAgB,KAAK;QACnD,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,CAAC,GAAG,IAAkD;QAC1D,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;IACvD,CAAC;IAED,WAAW,CAAC,GAAG,IAAkD;QAC/D,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IACvE,CAAC;IAED,MAAM,CAAE,EAAqB;QAC3B,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QACxC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAC/D,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;IACtB,CAAC;IAED,KAAK;QACH,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;IACrB,CAAC;CACF;AAzBD,sCAyBC","sourcesContent":["/**\n * Extracted from https://www.npmjs.com/package/strong-events\n */\n\ntype ExtractFunctionParameters<T extends (...args: any[]) => any> = T extends (...args: infer P) => any ? P : never;\n\nexport class EventEmitter_<CallbackSignature extends (...args: any[]) => any> {\n handlers: Array<CallbackSignature> = [];\n\n register(cb: CallbackSignature, once: boolean = false) {\n this.handlers.push(cb);\n return this;\n }\n\n invoke(...args: ExtractFunctionParameters<CallbackSignature>) {\n this.handlers.forEach((handler) => handler(...args));\n }\n\n invokeAsync(...args: ExtractFunctionParameters<CallbackSignature>) {\n return Promise.all(this.handlers.map((handler) => handler(...args)));\n }\n\n remove (cb: CallbackSignature) {\n const index = this.handlers.indexOf(cb);\n this.handlers[index] = this.handlers[this.handlers.length - 1];\n this.handlers.pop();\n }\n\n clear() {\n this.handlers = [];\n }\n}\n"]}
|
package/lib/filters/index.js
CHANGED
|
@@ -1,25 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ClientState = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
class ClientState {
|
|
5
|
+
constructor() {
|
|
6
6
|
this.refIds = new WeakSet();
|
|
7
7
|
this.containerIndexes = new WeakMap();
|
|
8
8
|
}
|
|
9
9
|
// containerIndexes = new Map<ChangeTree, Set<number>>();
|
|
10
|
-
|
|
10
|
+
addRefId(changeTree) {
|
|
11
11
|
if (!this.refIds.has(changeTree)) {
|
|
12
12
|
this.refIds.add(changeTree);
|
|
13
13
|
this.containerIndexes.set(changeTree, new Set());
|
|
14
14
|
}
|
|
15
|
-
}
|
|
16
|
-
|
|
15
|
+
}
|
|
16
|
+
static get(client) {
|
|
17
17
|
if (client.$filterState === undefined) {
|
|
18
18
|
client.$filterState = new ClientState();
|
|
19
19
|
}
|
|
20
20
|
return client.$filterState;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
}());
|
|
21
|
+
}
|
|
22
|
+
}
|
|
24
23
|
exports.ClientState = ClientState;
|
|
25
24
|
//# sourceMappingURL=index.js.map
|
package/lib/filters/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/filters/index.ts"],"names":[],"mappings":";;;AAGA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/filters/index.ts"],"names":[],"mappings":";;;AAGA,MAAa,WAAW;IAAxB;QACI,WAAM,GAAG,IAAI,OAAO,EAAc,CAAC;QACnC,qBAAgB,GAAG,IAAI,OAAO,EAA2B,CAAC;IAiB9D,CAAC;IAhBG,yDAAyD;IAEzD,QAAQ,CAAC,UAAsB;QAC3B,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE;YAC9B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;YAC5B,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;SACpD;IACL,CAAC;IAED,MAAM,CAAC,GAAG,CAAC,MAA2B;QAClC,IAAI,MAAM,CAAC,YAAY,KAAK,SAAS,EAAE;YACnC,MAAM,CAAC,YAAY,GAAG,IAAI,WAAW,EAAE,CAAC;SAC3C;QAED,OAAO,MAAM,CAAC,YAA2B,CAAC;IAC9C,CAAC;CACJ;AAnBD,kCAmBC","sourcesContent":["import { ChangeTree } from \"../changes/ChangeTree\";\nimport { ClientWithSessionId } from \"../annotations\";\n\nexport class ClientState {\n refIds = new WeakSet<ChangeTree>();\n containerIndexes = new WeakMap<ChangeTree, Set<number>>();\n // containerIndexes = new Map<ChangeTree, Set<number>>();\n\n addRefId(changeTree: ChangeTree) {\n if (!this.refIds.has(changeTree)) {\n this.refIds.add(changeTree);\n this.containerIndexes.set(changeTree, new Set());\n }\n }\n\n static get(client: ClientWithSessionId) {\n if (client.$filterState === undefined) {\n client.$filterState = new ClientState();\n }\n\n return client.$filterState as ClientState;\n }\n}\n"]}
|
package/lib/index.js
CHANGED
|
@@ -3,26 +3,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.OPERATION = exports.Context = exports.SchemaDefinition = exports.hasFilter = exports.defineTypes = exports.filterChildren = exports.filter = exports.deprecated = exports.type = exports.ReflectionField = exports.ReflectionType = exports.Reflection = exports.decode = exports.encode = exports.dumpChanges = exports.registerType = exports.SetSchema = exports.CollectionSchema = exports.ArraySchema = exports.MapSchema = exports.Schema = void 0;
|
|
4
4
|
var Schema_1 = require("./Schema");
|
|
5
5
|
Object.defineProperty(exports, "Schema", { enumerable: true, get: function () { return Schema_1.Schema; } });
|
|
6
|
-
|
|
6
|
+
const MapSchema_1 = require("./types/MapSchema");
|
|
7
7
|
Object.defineProperty(exports, "MapSchema", { enumerable: true, get: function () { return MapSchema_1.MapSchema; } });
|
|
8
|
-
|
|
8
|
+
const ArraySchema_1 = require("./types/ArraySchema");
|
|
9
9
|
Object.defineProperty(exports, "ArraySchema", { enumerable: true, get: function () { return ArraySchema_1.ArraySchema; } });
|
|
10
|
-
|
|
10
|
+
const CollectionSchema_1 = require("./types/CollectionSchema");
|
|
11
11
|
Object.defineProperty(exports, "CollectionSchema", { enumerable: true, get: function () { return CollectionSchema_1.CollectionSchema; } });
|
|
12
|
-
|
|
12
|
+
const SetSchema_1 = require("./types/SetSchema");
|
|
13
13
|
Object.defineProperty(exports, "SetSchema", { enumerable: true, get: function () { return SetSchema_1.SetSchema; } });
|
|
14
|
-
|
|
14
|
+
const typeRegistry_1 = require("./types/typeRegistry");
|
|
15
15
|
Object.defineProperty(exports, "registerType", { enumerable: true, get: function () { return typeRegistry_1.registerType; } });
|
|
16
|
-
typeRegistry_1.registerType("map", { constructor: MapSchema_1.MapSchema });
|
|
17
|
-
typeRegistry_1.registerType("array", { constructor: ArraySchema_1.ArraySchema });
|
|
18
|
-
typeRegistry_1.registerType("set", { constructor: SetSchema_1.SetSchema });
|
|
19
|
-
typeRegistry_1.registerType("collection", { constructor: CollectionSchema_1.CollectionSchema, });
|
|
16
|
+
(0, typeRegistry_1.registerType)("map", { constructor: MapSchema_1.MapSchema });
|
|
17
|
+
(0, typeRegistry_1.registerType)("array", { constructor: ArraySchema_1.ArraySchema });
|
|
18
|
+
(0, typeRegistry_1.registerType)("set", { constructor: SetSchema_1.SetSchema });
|
|
19
|
+
(0, typeRegistry_1.registerType)("collection", { constructor: CollectionSchema_1.CollectionSchema, });
|
|
20
20
|
// Utils
|
|
21
21
|
var utils_1 = require("./utils");
|
|
22
22
|
Object.defineProperty(exports, "dumpChanges", { enumerable: true, get: function () { return utils_1.dumpChanges; } });
|
|
23
|
-
|
|
23
|
+
const encode = require("./encoding/encode");
|
|
24
24
|
exports.encode = encode;
|
|
25
|
-
|
|
25
|
+
const decode = require("./encoding/decode");
|
|
26
26
|
exports.decode = decode;
|
|
27
27
|
// Reflection
|
|
28
28
|
var Reflection_1 = require("./Reflection");
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mCAA8C;AAArC,gGAAA,MAAM,OAAA;AAEf
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mCAA8C;AAArC,gGAAA,MAAM,OAAA;AAEf,iDAA6C;AACpC,0FADA,qBAAS,OACA;AAElB,qDAAkD;AACzC,4FADA,yBAAW,OACA;AAEpB,+DAA4D;AACnD,iGADA,mCAAgB,OACA;AAEzB,iDAA8C;AACrC,0FADA,qBAAS,OACA;AAElB,uDAAoD;AAC3C,6FADA,2BAAY,OACA;AAErB,IAAA,2BAAY,EAAC,KAAK,EAAE,EAAE,WAAW,EAAE,qBAAS,EAAE,CAAC,CAAC;AAChD,IAAA,2BAAY,EAAC,OAAO,EAAE,EAAE,WAAW,EAAE,yBAAW,EAAE,CAAC,CAAC;AACpD,IAAA,2BAAY,EAAC,KAAK,EAAE,EAAE,WAAW,EAAE,qBAAS,EAAE,CAAC,CAAC;AAChD,IAAA,2BAAY,EAAC,YAAY,EAAE,EAAE,WAAW,EAAE,mCAAgB,GAAG,CAAC,CAAC;AAE/D,QAAQ;AACR,iCAAsC;AAA7B,oGAAA,WAAW,OAAA;AAIpB,4CAA4C;AAEnC,wBAAM;AADf,4CAA4C;AAC3B,wBAAM;AAEvB,aAAa;AACb,2CAIsB;AAHlB,wGAAA,UAAU,OAAA;AACV,4GAAA,cAAc,OAAA;AACd,6GAAA,eAAe,OAAA;AAGnB,6CAkBuB;AAjBnB,cAAc;AACd,mGAAA,IAAI,OAAA;AACJ,yGAAA,UAAU,OAAA;AACV,qGAAA,MAAM,OAAA;AACN,6GAAA,cAAc,OAAA;AACd,0GAAA,WAAW,OAAA;AACX,wGAAA,SAAS,OAAA;AAET,YAAY;AACZ,+GAAA,gBAAgB,OAAA;AAEhB,QAAQ;AACR,sGAAA,OAAO,OAAA;AAOX,+BAAmC;AAA1B,iGAAA,SAAS,OAAA","sourcesContent":["export { Schema, DataChange } from \"./Schema\";\n\nimport { MapSchema } from \"./types/MapSchema\"\nexport { MapSchema };\n\nimport { ArraySchema } from \"./types/ArraySchema\";\nexport { ArraySchema };\n\nimport { CollectionSchema } from \"./types/CollectionSchema\";\nexport { CollectionSchema };\n\nimport { SetSchema } from \"./types/SetSchema\";\nexport { SetSchema };\n\nimport { registerType } from \"./types/typeRegistry\";\nexport { registerType };\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 { Iterator } from \"./encoding/decode\";\nimport * as encode from \"./encoding/encode\";\nimport * as decode from \"./encoding/decode\";\nexport { encode, decode };\n\n// Reflection\nexport {\n Reflection,\n ReflectionType,\n ReflectionField,\n} from \"./Reflection\";\n\nexport {\n // Annotations\n type,\n deprecated,\n filter,\n filterChildren,\n defineTypes,\n hasFilter,\n\n // Internals\n SchemaDefinition,\n\n // Types\n Context,\n PrimitiveType,\n Definition,\n DefinitionType,\n FilterCallback,\n} from \"./annotations\";\n\nexport { OPERATION } from \"./spec\";"]}
|
|
@@ -183,7 +183,7 @@ export declare class ArraySchema<V = any> implements Array<V>, SchemaDecoderCall
|
|
|
183
183
|
toLocaleString(): string;
|
|
184
184
|
/** Iterator */
|
|
185
185
|
[Symbol.iterator](): IterableIterator<V>;
|
|
186
|
-
[Symbol.unscopables]
|
|
186
|
+
[Symbol.unscopables]: any;
|
|
187
187
|
/**
|
|
188
188
|
* Returns an iterable of key, value pairs for every entry in the array
|
|
189
189
|
*/
|