@colyseus/schema 2.0.31 → 3.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/index.js +3614 -2634
- package/build/cjs/index.js.map +1 -1
- package/build/esm/index.mjs +3324 -2445
- package/build/esm/index.mjs.map +1 -1
- package/build/umd/index.js +3614 -2634
- package/lib/Decoder.d.ts +16 -0
- package/lib/Decoder.js +182 -0
- package/lib/Decoder.js.map +1 -0
- package/lib/Encoder.d.ts +13 -0
- package/lib/Encoder.js +79 -0
- package/lib/Encoder.js.map +1 -0
- package/lib/Metadata.d.ts +36 -0
- package/lib/Metadata.js +91 -0
- package/lib/Metadata.js.map +1 -0
- package/lib/Reflection.d.ts +7 -5
- package/lib/Reflection.js +62 -58
- package/lib/Reflection.js.map +1 -1
- package/lib/Schema.d.ts +39 -51
- package/lib/Schema.js +189 -731
- package/lib/Schema.js.map +1 -1
- package/lib/annotations.d.ts +26 -45
- package/lib/annotations.js +363 -194
- package/lib/annotations.js.map +1 -1
- package/lib/changes/ChangeSet.d.ts +12 -0
- package/lib/changes/ChangeSet.js +35 -0
- package/lib/changes/ChangeSet.js.map +1 -0
- package/lib/changes/DecodeOperation.d.ts +15 -0
- package/lib/changes/DecodeOperation.js +186 -0
- package/lib/changes/DecodeOperation.js.map +1 -0
- package/lib/changes/EncodeOperation.d.ts +18 -0
- package/lib/changes/EncodeOperation.js +130 -0
- package/lib/changes/EncodeOperation.js.map +1 -0
- package/lib/changes/consts.d.ts +14 -0
- package/lib/changes/consts.js +18 -0
- package/lib/changes/consts.js.map +1 -0
- package/lib/decoder/DecodeOperation.d.ts +24 -0
- package/lib/decoder/DecodeOperation.js +256 -0
- package/lib/decoder/DecodeOperation.js.map +1 -0
- package/lib/decoder/Decoder.d.ts +21 -0
- package/lib/decoder/Decoder.js +114 -0
- package/lib/decoder/Decoder.js.map +1 -0
- package/lib/decoder/ReferenceTracker.d.ts +26 -0
- package/lib/decoder/ReferenceTracker.js +131 -0
- package/lib/decoder/ReferenceTracker.js.map +1 -0
- package/lib/decoder/strategy/RawChanges.d.ts +3 -0
- package/lib/decoder/strategy/RawChanges.js +8 -0
- package/lib/decoder/strategy/RawChanges.js.map +1 -0
- package/lib/decoder/strategy/StateCallbacks.d.ts +20 -0
- package/lib/decoder/strategy/StateCallbacks.js +240 -0
- package/lib/decoder/strategy/StateCallbacks.js.map +1 -0
- package/lib/decoding/decode.d.ts +48 -0
- package/lib/decoding/decode.js +267 -0
- package/lib/decoding/decode.js.map +1 -0
- package/lib/ecs.d.ts +11 -0
- package/lib/ecs.js +160 -0
- package/lib/ecs.js.map +1 -0
- package/lib/encoder/ChangeTree.d.ts +72 -0
- package/lib/encoder/ChangeTree.js +384 -0
- package/lib/encoder/ChangeTree.js.map +1 -0
- package/lib/encoder/EncodeOperation.d.ts +25 -0
- package/lib/encoder/EncodeOperation.js +156 -0
- package/lib/encoder/EncodeOperation.js.map +1 -0
- package/lib/encoder/Encoder.d.ts +23 -0
- package/lib/encoder/Encoder.js +192 -0
- package/lib/encoder/Encoder.js.map +1 -0
- package/lib/encoder/StateView.d.ts +21 -0
- package/lib/encoder/StateView.js +196 -0
- package/lib/encoder/StateView.js.map +1 -0
- package/lib/encoding/assert.d.ts +9 -0
- package/lib/encoding/assert.js +47 -0
- package/lib/encoding/assert.js.map +1 -0
- package/lib/encoding/decode.js +1 -1
- package/lib/encoding/decode.js.map +1 -1
- package/lib/encoding/encode.d.ts +17 -16
- package/lib/encoding/encode.js +88 -81
- package/lib/encoding/encode.js.map +1 -1
- package/lib/encoding/spec.d.ts +25 -0
- package/lib/encoding/spec.js +30 -0
- package/lib/encoding/spec.js.map +1 -0
- package/lib/index.d.ts +18 -10
- package/lib/index.js +39 -17
- package/lib/index.js.map +1 -1
- package/lib/symbol.shim.d.ts +6 -0
- package/lib/symbol.shim.js +4 -0
- package/lib/symbol.shim.js.map +1 -0
- package/lib/types/ArraySchema.js +0 -7
- package/lib/types/ArraySchema.js.map +1 -1
- package/lib/types/HelperTypes.d.ts +10 -2
- package/lib/types/HelperTypes.js.map +1 -1
- package/lib/types/custom/ArraySchema.d.ts +245 -0
- package/lib/types/custom/ArraySchema.js +659 -0
- package/lib/types/custom/ArraySchema.js.map +1 -0
- package/lib/types/custom/CollectionSchema.d.ts +42 -0
- package/lib/types/custom/CollectionSchema.js +165 -0
- package/lib/types/custom/CollectionSchema.js.map +1 -0
- package/lib/types/custom/MapSchema.d.ts +43 -0
- package/lib/types/custom/MapSchema.js +200 -0
- package/lib/types/custom/MapSchema.js.map +1 -0
- package/lib/types/custom/SetSchema.d.ts +39 -0
- package/lib/types/custom/SetSchema.js +177 -0
- package/lib/types/custom/SetSchema.js.map +1 -0
- package/lib/types/registry.d.ts +6 -0
- package/lib/types/registry.js +19 -0
- package/lib/types/registry.js.map +1 -0
- package/lib/types/symbols.d.ts +29 -0
- package/lib/types/symbols.js +33 -0
- package/lib/types/symbols.js.map +1 -0
- package/lib/types/utils.d.ts +0 -8
- package/lib/types/utils.js +1 -33
- package/lib/types/utils.js.map +1 -1
- package/lib/usage.d.ts +1 -0
- package/lib/usage.js +22 -0
- package/lib/usage.js.map +1 -0
- package/lib/utils.d.ts +13 -2
- package/lib/utils.js +36 -15
- package/lib/utils.js.map +1 -1
- package/lib/v3.d.ts +1 -0
- package/lib/v3.js +427 -0
- package/lib/v3.js.map +1 -0
- package/lib/v3_bench.d.ts +1 -0
- package/lib/v3_bench.js +130 -0
- package/lib/v3_bench.js.map +1 -0
- package/lib/v3_experiment.d.ts +1 -0
- package/lib/v3_experiment.js +407 -0
- package/lib/v3_experiment.js.map +1 -0
- package/package.json +5 -5
- package/src/Metadata.ts +135 -0
- package/src/Reflection.ts +75 -66
- package/src/Schema.ts +213 -931
- package/src/annotations.ts +430 -243
- package/src/decoder/DecodeOperation.ts +372 -0
- package/src/decoder/Decoder.ts +155 -0
- package/src/decoder/ReferenceTracker.ts +151 -0
- package/src/decoder/strategy/RawChanges.ts +9 -0
- package/src/decoder/strategy/StateCallbacks.ts +326 -0
- package/src/encoder/ChangeTree.ts +492 -0
- package/src/encoder/EncodeOperation.ts +237 -0
- package/src/encoder/Encoder.ts +246 -0
- package/src/encoder/StateView.ts +229 -0
- package/src/encoding/assert.ts +58 -0
- package/src/encoding/decode.ts +1 -1
- package/src/encoding/encode.ts +88 -82
- package/src/encoding/spec.ts +29 -0
- package/src/index.ts +22 -19
- package/src/symbol.shim.ts +12 -0
- package/src/types/HelperTypes.ts +16 -2
- package/src/types/{ArraySchema.ts → custom/ArraySchema.ts} +345 -251
- package/src/types/{CollectionSchema.ts → custom/CollectionSchema.ts} +56 -46
- package/src/types/{MapSchema.ts → custom/MapSchema.ts} +88 -115
- package/src/types/{SetSchema.ts → custom/SetSchema.ts} +58 -47
- package/src/types/{typeRegistry.ts → registry.ts} +6 -6
- package/src/types/symbols.ts +36 -0
- package/src/types/utils.ts +0 -46
- package/src/utils.ts +50 -21
- package/src/v3_bench.ts +107 -0
- package/src/changes/ChangeTree.ts +0 -295
- package/src/changes/ReferenceTracker.ts +0 -91
- package/src/filters/index.ts +0 -23
- package/src/spec.ts +0 -49
|
@@ -1 +1 @@
|
|
|
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,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,CAAC;QACzD,IAAI,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;YAC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9C,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}"]}
|
|
1
|
+
{"version":3,"file":"decode.js","sourceRoot":"","sources":["../../src/encoding/decode.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;;;AAEH,iCAA6C;AAS7C,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,CAAC;QACzD,IAAI,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;YAC3B,MAAM,IAAI,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;YACpC,SAAS;QACX,CAAC;QACD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;YAC3B,MAAM,IAAI,MAAM,CAAC,YAAY,CAC3B,CAAC,CAAC,IAAI,GAAG,IAAI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yB;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.d.ts
CHANGED
|
@@ -20,19 +20,20 @@
|
|
|
20
20
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
21
|
* SOFTWARE
|
|
22
22
|
*/
|
|
23
|
-
|
|
24
|
-
export declare function
|
|
25
|
-
export declare function
|
|
26
|
-
export declare function
|
|
27
|
-
export declare function
|
|
28
|
-
export declare function
|
|
29
|
-
export declare function
|
|
30
|
-
export declare function
|
|
31
|
-
export declare function
|
|
32
|
-
export declare function
|
|
33
|
-
export declare function
|
|
34
|
-
export declare function
|
|
35
|
-
export declare function
|
|
36
|
-
export declare function
|
|
37
|
-
export declare function
|
|
38
|
-
export declare function
|
|
23
|
+
/// <reference types="node" />
|
|
24
|
+
export declare function utf8Write(view: any, str: any, it: any): void;
|
|
25
|
+
export declare function int8(bytes: any, value: any, it: any): void;
|
|
26
|
+
export declare function uint8(bytes: any, value: any, it: any): void;
|
|
27
|
+
export declare function int16(bytes: any, value: any, it: any): void;
|
|
28
|
+
export declare function uint16(bytes: any, value: any, it: any): void;
|
|
29
|
+
export declare function int32(bytes: any, value: any, it: any): void;
|
|
30
|
+
export declare function uint32(bytes: any, value: any, it: any): void;
|
|
31
|
+
export declare function int64(bytes: any, value: any, it: any): void;
|
|
32
|
+
export declare function uint64(bytes: any, value: any, it: any): void;
|
|
33
|
+
export declare function float32(bytes: any, value: any, it: any): void;
|
|
34
|
+
export declare function float64(bytes: any, value: any, it: any): void;
|
|
35
|
+
export declare function writeFloat32(bytes: any, value: any, it: any): void;
|
|
36
|
+
export declare function writeFloat64(bytes: any, value: any, it: any): void;
|
|
37
|
+
export declare function boolean(bytes: any, value: any, it: any): void;
|
|
38
|
+
export declare function string(bytes: Buffer, value: any, it: any): number;
|
|
39
|
+
export declare function number(bytes: any, value: any, it: any): 1 | 2 | 3 | 5 | 9;
|
package/lib/encoding/encode.js
CHANGED
|
@@ -27,6 +27,12 @@ exports.number = exports.string = exports.boolean = exports.writeFloat64 = expor
|
|
|
27
27
|
* msgpack implementation highly based on notepack.io
|
|
28
28
|
* https://github.com/darrachequesne/notepack
|
|
29
29
|
*/
|
|
30
|
+
let textEncoder;
|
|
31
|
+
// @ts-ignore
|
|
32
|
+
try {
|
|
33
|
+
textEncoder = new TextEncoder();
|
|
34
|
+
}
|
|
35
|
+
catch (e) { }
|
|
30
36
|
function utf8Length(str) {
|
|
31
37
|
var c = 0, length = 0;
|
|
32
38
|
for (var i = 0, l = str.length; i < l; i++) {
|
|
@@ -47,97 +53,97 @@ function utf8Length(str) {
|
|
|
47
53
|
}
|
|
48
54
|
return length;
|
|
49
55
|
}
|
|
50
|
-
function utf8Write(view,
|
|
56
|
+
function utf8Write(view, str, it) {
|
|
51
57
|
var c = 0;
|
|
52
58
|
for (var i = 0, l = str.length; i < l; i++) {
|
|
53
59
|
c = str.charCodeAt(i);
|
|
54
60
|
if (c < 0x80) {
|
|
55
|
-
view[offset++] = c;
|
|
61
|
+
view[it.offset++] = c;
|
|
56
62
|
}
|
|
57
63
|
else if (c < 0x800) {
|
|
58
|
-
view[offset++] = 0xc0 | (c >> 6);
|
|
59
|
-
view[offset++] = 0x80 | (c & 0x3f);
|
|
64
|
+
view[it.offset++] = 0xc0 | (c >> 6);
|
|
65
|
+
view[it.offset++] = 0x80 | (c & 0x3f);
|
|
60
66
|
}
|
|
61
67
|
else if (c < 0xd800 || c >= 0xe000) {
|
|
62
|
-
view[offset++] = 0xe0 | (c >> 12);
|
|
63
|
-
view[offset++] = 0x80 | (c >> 6 & 0x3f);
|
|
64
|
-
view[offset++] = 0x80 | (c & 0x3f);
|
|
68
|
+
view[it.offset++] = 0xe0 | (c >> 12);
|
|
69
|
+
view[it.offset++] = 0x80 | (c >> 6 & 0x3f);
|
|
70
|
+
view[it.offset++] = 0x80 | (c & 0x3f);
|
|
65
71
|
}
|
|
66
72
|
else {
|
|
67
73
|
i++;
|
|
68
74
|
c = 0x10000 + (((c & 0x3ff) << 10) | (str.charCodeAt(i) & 0x3ff));
|
|
69
|
-
view[offset++] = 0xf0 | (c >> 18);
|
|
70
|
-
view[offset++] = 0x80 | (c >> 12 & 0x3f);
|
|
71
|
-
view[offset++] = 0x80 | (c >> 6 & 0x3f);
|
|
72
|
-
view[offset++] = 0x80 | (c & 0x3f);
|
|
75
|
+
view[it.offset++] = 0xf0 | (c >> 18);
|
|
76
|
+
view[it.offset++] = 0x80 | (c >> 12 & 0x3f);
|
|
77
|
+
view[it.offset++] = 0x80 | (c >> 6 & 0x3f);
|
|
78
|
+
view[it.offset++] = 0x80 | (c & 0x3f);
|
|
73
79
|
}
|
|
74
80
|
}
|
|
75
81
|
}
|
|
76
82
|
exports.utf8Write = utf8Write;
|
|
77
|
-
function int8(bytes, value) {
|
|
78
|
-
bytes.
|
|
83
|
+
function int8(bytes, value, it) {
|
|
84
|
+
bytes[it.offset++] = value & 255;
|
|
79
85
|
}
|
|
80
86
|
exports.int8 = int8;
|
|
81
87
|
;
|
|
82
|
-
function uint8(bytes, value) {
|
|
83
|
-
bytes.
|
|
88
|
+
function uint8(bytes, value, it) {
|
|
89
|
+
bytes[it.offset++] = value & 255;
|
|
84
90
|
}
|
|
85
91
|
exports.uint8 = uint8;
|
|
86
92
|
;
|
|
87
|
-
function int16(bytes, value) {
|
|
88
|
-
bytes.
|
|
89
|
-
bytes.
|
|
93
|
+
function int16(bytes, value, it) {
|
|
94
|
+
bytes[it.offset++] = value & 255;
|
|
95
|
+
bytes[it.offset++] = (value >> 8) & 255;
|
|
90
96
|
}
|
|
91
97
|
exports.int16 = int16;
|
|
92
98
|
;
|
|
93
|
-
function uint16(bytes, value) {
|
|
94
|
-
bytes.
|
|
95
|
-
bytes.
|
|
99
|
+
function uint16(bytes, value, it) {
|
|
100
|
+
bytes[it.offset++] = value & 255;
|
|
101
|
+
bytes[it.offset++] = (value >> 8) & 255;
|
|
96
102
|
}
|
|
97
103
|
exports.uint16 = uint16;
|
|
98
104
|
;
|
|
99
|
-
function int32(bytes, value) {
|
|
100
|
-
bytes.
|
|
101
|
-
bytes.
|
|
102
|
-
bytes.
|
|
103
|
-
bytes.
|
|
105
|
+
function int32(bytes, value, it) {
|
|
106
|
+
bytes[it.offset++] = value & 255;
|
|
107
|
+
bytes[it.offset++] = (value >> 8) & 255;
|
|
108
|
+
bytes[it.offset++] = (value >> 16) & 255;
|
|
109
|
+
bytes[it.offset++] = (value >> 24) & 255;
|
|
104
110
|
}
|
|
105
111
|
exports.int32 = int32;
|
|
106
112
|
;
|
|
107
|
-
function uint32(bytes, value) {
|
|
113
|
+
function uint32(bytes, value, it) {
|
|
108
114
|
const b4 = value >> 24;
|
|
109
115
|
const b3 = value >> 16;
|
|
110
116
|
const b2 = value >> 8;
|
|
111
117
|
const b1 = value;
|
|
112
|
-
bytes.
|
|
113
|
-
bytes.
|
|
114
|
-
bytes.
|
|
115
|
-
bytes.
|
|
118
|
+
bytes[it.offset++] = b1 & 255;
|
|
119
|
+
bytes[it.offset++] = b2 & 255;
|
|
120
|
+
bytes[it.offset++] = b3 & 255;
|
|
121
|
+
bytes[it.offset++] = b4 & 255;
|
|
116
122
|
}
|
|
117
123
|
exports.uint32 = uint32;
|
|
118
124
|
;
|
|
119
|
-
function int64(bytes, value) {
|
|
125
|
+
function int64(bytes, value, it) {
|
|
120
126
|
const high = Math.floor(value / Math.pow(2, 32));
|
|
121
127
|
const low = value >>> 0;
|
|
122
|
-
uint32(bytes, low);
|
|
123
|
-
uint32(bytes, high);
|
|
128
|
+
uint32(bytes, low, it);
|
|
129
|
+
uint32(bytes, high, it);
|
|
124
130
|
}
|
|
125
131
|
exports.int64 = int64;
|
|
126
132
|
;
|
|
127
|
-
function uint64(bytes, value) {
|
|
133
|
+
function uint64(bytes, value, it) {
|
|
128
134
|
const high = (value / Math.pow(2, 32)) >> 0;
|
|
129
135
|
const low = value >>> 0;
|
|
130
|
-
uint32(bytes, low);
|
|
131
|
-
uint32(bytes, high);
|
|
136
|
+
uint32(bytes, low, it);
|
|
137
|
+
uint32(bytes, high, it);
|
|
132
138
|
}
|
|
133
139
|
exports.uint64 = uint64;
|
|
134
140
|
;
|
|
135
|
-
function float32(bytes, value) {
|
|
136
|
-
writeFloat32(bytes, value);
|
|
141
|
+
function float32(bytes, value, it) {
|
|
142
|
+
writeFloat32(bytes, value, it);
|
|
137
143
|
}
|
|
138
144
|
exports.float32 = float32;
|
|
139
|
-
function float64(bytes, value) {
|
|
140
|
-
writeFloat64(bytes, value);
|
|
145
|
+
function float64(bytes, value, it) {
|
|
146
|
+
writeFloat64(bytes, value, it);
|
|
141
147
|
}
|
|
142
148
|
exports.float64 = float64;
|
|
143
149
|
// force little endian to facilitate decoding on multiple implementations
|
|
@@ -145,71 +151,72 @@ const _isLittleEndian = true; // new Uint16Array(new Uint8Array([1, 0]).buffer)[
|
|
|
145
151
|
const _int32 = new Int32Array(2);
|
|
146
152
|
const _float32 = new Float32Array(_int32.buffer);
|
|
147
153
|
const _float64 = new Float64Array(_int32.buffer);
|
|
148
|
-
function writeFloat32(bytes, value) {
|
|
154
|
+
function writeFloat32(bytes, value, it) {
|
|
149
155
|
_float32[0] = value;
|
|
150
|
-
int32(bytes, _int32[0]);
|
|
156
|
+
int32(bytes, _int32[0], it);
|
|
151
157
|
}
|
|
152
158
|
exports.writeFloat32 = writeFloat32;
|
|
153
159
|
;
|
|
154
|
-
function writeFloat64(bytes, value) {
|
|
160
|
+
function writeFloat64(bytes, value, it) {
|
|
155
161
|
_float64[0] = value;
|
|
156
|
-
int32(bytes, _int32[_isLittleEndian ? 0 : 1]);
|
|
157
|
-
int32(bytes, _int32[_isLittleEndian ? 1 : 0]);
|
|
162
|
+
int32(bytes, _int32[_isLittleEndian ? 0 : 1], it);
|
|
163
|
+
int32(bytes, _int32[_isLittleEndian ? 1 : 0], it);
|
|
158
164
|
}
|
|
159
165
|
exports.writeFloat64 = writeFloat64;
|
|
160
166
|
;
|
|
161
|
-
function boolean(bytes, value) {
|
|
162
|
-
|
|
167
|
+
function boolean(bytes, value, it) {
|
|
168
|
+
bytes[it.offset++] = value ? 1 : 0; // uint8
|
|
163
169
|
}
|
|
164
170
|
exports.boolean = boolean;
|
|
165
171
|
;
|
|
166
|
-
function string(bytes, value) {
|
|
172
|
+
function string(bytes, value, it) {
|
|
167
173
|
// encode `null` strings as empty.
|
|
168
174
|
if (!value) {
|
|
169
175
|
value = "";
|
|
170
176
|
}
|
|
171
|
-
let length = utf8Length(value);
|
|
177
|
+
// let length = utf8Length(value);
|
|
178
|
+
let length = Buffer.byteLength(value, "utf8");
|
|
172
179
|
let size = 0;
|
|
173
180
|
// fixstr
|
|
174
181
|
if (length < 0x20) {
|
|
175
|
-
bytes.
|
|
182
|
+
bytes[it.offset++] = length | 0xa0;
|
|
176
183
|
size = 1;
|
|
177
184
|
}
|
|
178
185
|
// str 8
|
|
179
186
|
else if (length < 0x100) {
|
|
180
|
-
bytes.
|
|
181
|
-
|
|
187
|
+
bytes[it.offset++] = 0xd9;
|
|
188
|
+
bytes[it.offset++] = length % 255;
|
|
182
189
|
size = 2;
|
|
183
190
|
}
|
|
184
191
|
// str 16
|
|
185
192
|
else if (length < 0x10000) {
|
|
186
|
-
bytes.
|
|
187
|
-
uint16(bytes, length);
|
|
193
|
+
bytes[it.offset++] = 0xda;
|
|
194
|
+
uint16(bytes, length, it);
|
|
188
195
|
size = 3;
|
|
189
196
|
}
|
|
190
197
|
// str 32
|
|
191
198
|
else if (length < 0x100000000) {
|
|
192
|
-
bytes.
|
|
193
|
-
uint32(bytes, length);
|
|
199
|
+
bytes[it.offset++] = 0xdb;
|
|
200
|
+
uint32(bytes, length, it);
|
|
194
201
|
size = 5;
|
|
195
202
|
}
|
|
196
203
|
else {
|
|
197
204
|
throw new Error('String too long');
|
|
198
205
|
}
|
|
199
|
-
utf8Write(bytes,
|
|
206
|
+
utf8Write(bytes, value, it);
|
|
200
207
|
return size + length;
|
|
201
208
|
}
|
|
202
209
|
exports.string = string;
|
|
203
|
-
function number(bytes, value) {
|
|
210
|
+
function number(bytes, value, it) {
|
|
204
211
|
if (isNaN(value)) {
|
|
205
|
-
return number(bytes, 0);
|
|
212
|
+
return number(bytes, 0, it);
|
|
206
213
|
}
|
|
207
214
|
else if (!isFinite(value)) {
|
|
208
|
-
return number(bytes, (value > 0) ? Number.MAX_SAFE_INTEGER : -Number.MAX_SAFE_INTEGER);
|
|
215
|
+
return number(bytes, (value > 0) ? Number.MAX_SAFE_INTEGER : -Number.MAX_SAFE_INTEGER, it);
|
|
209
216
|
}
|
|
210
217
|
else if (value !== (value | 0)) {
|
|
211
|
-
bytes.
|
|
212
|
-
writeFloat64(bytes, value);
|
|
218
|
+
bytes[it.offset++] = 0xcb;
|
|
219
|
+
writeFloat64(bytes, value, it);
|
|
213
220
|
return 9;
|
|
214
221
|
// TODO: encode float 32?
|
|
215
222
|
// is it possible to differentiate between float32 / float64 here?
|
|
@@ -221,59 +228,59 @@ function number(bytes, value) {
|
|
|
221
228
|
if (value >= 0) {
|
|
222
229
|
// positive fixnum
|
|
223
230
|
if (value < 0x80) {
|
|
224
|
-
|
|
231
|
+
bytes[it.offset++] = value & 255; // uint8
|
|
225
232
|
return 1;
|
|
226
233
|
}
|
|
227
234
|
// uint 8
|
|
228
235
|
if (value < 0x100) {
|
|
229
|
-
bytes.
|
|
230
|
-
|
|
236
|
+
bytes[it.offset++] = 0xcc;
|
|
237
|
+
bytes[it.offset++] = value & 255; // uint8
|
|
231
238
|
return 2;
|
|
232
239
|
}
|
|
233
240
|
// uint 16
|
|
234
241
|
if (value < 0x10000) {
|
|
235
|
-
bytes.
|
|
236
|
-
uint16(bytes, value);
|
|
242
|
+
bytes[it.offset++] = 0xcd;
|
|
243
|
+
uint16(bytes, value, it);
|
|
237
244
|
return 3;
|
|
238
245
|
}
|
|
239
246
|
// uint 32
|
|
240
247
|
if (value < 0x100000000) {
|
|
241
|
-
bytes.
|
|
242
|
-
uint32(bytes, value);
|
|
248
|
+
bytes[it.offset++] = 0xce;
|
|
249
|
+
uint32(bytes, value, it);
|
|
243
250
|
return 5;
|
|
244
251
|
}
|
|
245
252
|
// uint 64
|
|
246
|
-
bytes.
|
|
247
|
-
uint64(bytes, value);
|
|
253
|
+
bytes[it.offset++] = 0xcf;
|
|
254
|
+
uint64(bytes, value, it);
|
|
248
255
|
return 9;
|
|
249
256
|
}
|
|
250
257
|
else {
|
|
251
258
|
// negative fixnum
|
|
252
259
|
if (value >= -0x20) {
|
|
253
|
-
bytes.
|
|
260
|
+
bytes[it.offset++] = 0xe0 | (value + 0x20);
|
|
254
261
|
return 1;
|
|
255
262
|
}
|
|
256
263
|
// int 8
|
|
257
264
|
if (value >= -0x80) {
|
|
258
|
-
bytes.
|
|
259
|
-
int8(bytes, value);
|
|
265
|
+
bytes[it.offset++] = 0xd0;
|
|
266
|
+
int8(bytes, value, it);
|
|
260
267
|
return 2;
|
|
261
268
|
}
|
|
262
269
|
// int 16
|
|
263
270
|
if (value >= -0x8000) {
|
|
264
|
-
bytes.
|
|
265
|
-
int16(bytes, value);
|
|
271
|
+
bytes[it.offset++] = 0xd1;
|
|
272
|
+
int16(bytes, value, it);
|
|
266
273
|
return 3;
|
|
267
274
|
}
|
|
268
275
|
// int 32
|
|
269
276
|
if (value >= -0x80000000) {
|
|
270
|
-
bytes.
|
|
271
|
-
int32(bytes, value);
|
|
277
|
+
bytes[it.offset++] = 0xd2;
|
|
278
|
+
int32(bytes, value, it);
|
|
272
279
|
return 5;
|
|
273
280
|
}
|
|
274
281
|
// int 64
|
|
275
|
-
bytes.
|
|
276
|
-
int64(bytes, value);
|
|
282
|
+
bytes[it.offset++] = 0xd3;
|
|
283
|
+
int64(bytes, value, it);
|
|
277
284
|
return 9;
|
|
278
285
|
}
|
|
279
286
|
}
|
|
@@ -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,CAAC;QAC3C,CAAC,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QACtB,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC;YACb,MAAM,IAAI,CAAC,CAAC;QACd,CAAC;aACI,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC;YACnB,MAAM,IAAI,CAAC,CAAC;QACd,CAAC;aACI,IAAI,CAAC,GAAG,MAAM,IAAI,CAAC,IAAI,MAAM,EAAE,CAAC;YACnC,MAAM,IAAI,CAAC,CAAC;QACd,CAAC;aACI,CAAC;YACJ,CAAC,EAAE,CAAC;YACJ,MAAM,IAAI,CAAC,CAAC;QACd,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG;IACzC,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3C,CAAC,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QACtB,IAAI,CAA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K,CAAC,CAAC;YACrB,OAAO,CAAC,CAAC;QACX,CAAC;QAED,UAAU;QACV,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjB,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QACrB,OAAO,CAAC,CAAC;IAEX,CAAC;SAAM,CAAC;QAEN,kBAAkB;QAClB,IAAI,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;YACnB,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC;YAClC,OAAO,CAAC,CAAC;QACX,CAAC;QAED,QAAQ;QACR,IAAI,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;YACnB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACjB,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;YACnB,OAAO,CAAC,CAAC;QACX,CAAC;QAED,SAAS;QACT,IAAI,KAAK,IAAI,CAAC,MAAM,EAAE,CAAC;YACrB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACjB,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;YACpB,OAAO,CAAC,CAAC;QACX,CAAC;QAED,SAAS;QACT,IAAI,KAAK,IAAI,CAAC,UAAU,EAAE,CAAC;YACzB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACjB,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;YACpB,OAAO,CAAC,CAAC;QACX,CAAC;QAED,SAAS;QACT,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjB,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QACpB,OAAO,CAAC,CAAC;IACX,CAAC;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;;;AAIH;;;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,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,CAAC;QAC3C,CAAC,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QACtB,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC;YACb,MAAM,IAAI,CAAC,CAAC;QACd,CAAC;aACI,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC;YACnB,MAAM,IAAI,CAAC,CAAC;QACd,CAAC;aACI,IAAI,CAAC,GAAG,MAAM,IAAI,CAAC,IAAI,MAAM,EAAE,CAAC;YACnC,MAAM,IAAI,CAAC,CAAC;QACd,CAAC;aACI,CAAC;YACJ,CAAC,EAAE,CAAC;YACJ,MAAM,IAAI,CAAC,CAAC;QACd,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAgB,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE;IACrC,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,KAAK,IAAI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,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QACxB,OAAO,CAAC,CAAC;IACX,CAAC;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\nimport type { TextEncoder } from \"util\";\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\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, str, it) {\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++] = 0x80 | (c & 0x3f);\n }\n else if (c < 0xd800 || c >= 0xe000) {\n view[it.offset++] = 0xe0 | (c >> 12);\n view[it.offset++] = 0x80 | (c >> 6 & 0x3f);\n view[it.offset++] = 0x80 | (c & 0x3f);\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++] = 0x80 | (c >> 12 & 0x3f);\n view[it.offset++] = 0x80 | (c >> 6 & 0x3f);\n view[it.offset++] = 0x80 | (c & 0x3f);\n }\n }\n}\n\nexport function int8(bytes, value, it) {\n bytes[it.offset++] = value & 255;\n};\n\nexport function uint8(bytes, value, it) {\n bytes[it.offset++] = value & 255;\n};\n\nexport function int16(bytes, value, it) {\n bytes[it.offset++] = value & 255;\n bytes[it.offset++] = (value >> 8) & 255;\n};\n\nexport function uint16(bytes, value, it) {\n bytes[it.offset++] = value & 255;\n bytes[it.offset++] = (value >> 8) & 255;\n};\n\nexport function int32(bytes, value, it) {\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\nexport function uint32(bytes, value, it) {\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\nexport function int64(bytes, value, it) {\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\nexport function uint64(bytes, value, it) {\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\nexport function float32(bytes, value, it) {\n writeFloat32(bytes, value, it);\n}\n\nexport function float64(bytes, value, it) {\n writeFloat64(bytes, value, it);\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, it) {\n _float32[0] = value;\n int32(bytes, _int32[0], it);\n};\n\nexport function writeFloat64(bytes, value, it) {\n _float64[0] = value;\n int32(bytes, _int32[_isLittleEndian ? 0 : 1], it);\n int32(bytes, _int32[_isLittleEndian ? 1 : 0], it);\n};\n\nexport function boolean(bytes, value, it) {\n bytes[it.offset++] = value ? 1 : 0; // uint8\n};\n\nexport function string(bytes: Buffer, value, it) {\n // encode `null` strings as empty.\n if (!value) { value = \"\"; }\n\n // let length = utf8Length(value);\n let length = Buffer.byteLength(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\nexport function number(bytes, value, it) {\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 bytes[it.offset++] = 0xcb;\n writeFloat64(bytes, value, it);\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 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"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare const SWITCH_TO_STRUCTURE = 255;
|
|
2
|
+
export declare const TYPE_ID = 213;
|
|
3
|
+
/**
|
|
4
|
+
* Encoding Schema field operations.
|
|
5
|
+
*/
|
|
6
|
+
export declare enum OPERATION {
|
|
7
|
+
ADD = 128,// (10000000) add new structure/primitive
|
|
8
|
+
REPLACE = 0,// (00000001) replace structure/primitive
|
|
9
|
+
DELETE = 64,// (01000000) delete field
|
|
10
|
+
DELETE_AND_MOVE = 96,// () add new structure/primitive
|
|
11
|
+
MOVE_AND_ADD = 160,// () add new structure/primitive
|
|
12
|
+
DELETE_AND_ADD = 192,// (11000000) DELETE field, followed by an ADD
|
|
13
|
+
/**
|
|
14
|
+
* Collection operations
|
|
15
|
+
*/
|
|
16
|
+
CLEAR = 10,
|
|
17
|
+
/**
|
|
18
|
+
* ArraySchema operations
|
|
19
|
+
*/
|
|
20
|
+
PUSH = 11,
|
|
21
|
+
UNSHIFT = 12,
|
|
22
|
+
REVERSE = 15,
|
|
23
|
+
MOVE = 32,
|
|
24
|
+
DELETE_BY_REFID = 33
|
|
25
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
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["PUSH"] = 11] = "PUSH";
|
|
25
|
+
OPERATION[OPERATION["UNSHIFT"] = 12] = "UNSHIFT";
|
|
26
|
+
OPERATION[OPERATION["REVERSE"] = 15] = "REVERSE";
|
|
27
|
+
OPERATION[OPERATION["MOVE"] = 32] = "MOVE";
|
|
28
|
+
OPERATION[OPERATION["DELETE_BY_REFID"] = 33] = "DELETE_BY_REFID";
|
|
29
|
+
})(OPERATION || (exports.OPERATION = OPERATION = {}));
|
|
30
|
+
//# sourceMappingURL=spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,SAsBX;AAtBD,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,0CAAS,CAAA;IACT,gDAAY,CAAA;IACZ,gDAAY,CAAA;IACZ,0CAAS,CAAA;IACT,gEAAoB,CAAA;AAExB,CAAC,EAtBW,SAAS,yBAAT,SAAS,QAsBpB","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, // () add new structure/primitive\n MOVE_AND_ADD = 160, // () add new structure/primitive\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 PUSH = 11,\n UNSHIFT = 12,\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\n}\n"]}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
export { Schema } from "./Schema";
|
|
2
|
-
export type { DataChange } from "./
|
|
3
|
-
import {
|
|
2
|
+
export type { DataChange } from "./decoder/DecodeOperation";
|
|
3
|
+
import { $track, $encoder, $decoder, $filter, $getByIndex, $deleteByIndex, $changes, $childType } from "./types/symbols";
|
|
4
|
+
export { $track, $encoder, $decoder, $filter, $getByIndex, $deleteByIndex, $changes, $childType };
|
|
5
|
+
import { MapSchema } from "./types/custom/MapSchema";
|
|
4
6
|
export { MapSchema };
|
|
5
|
-
import { ArraySchema } from "./types/ArraySchema";
|
|
7
|
+
import { ArraySchema } from "./types/custom/ArraySchema";
|
|
6
8
|
export { ArraySchema };
|
|
7
|
-
import { CollectionSchema } from "./types/CollectionSchema";
|
|
9
|
+
import { CollectionSchema } from "./types/custom/CollectionSchema";
|
|
8
10
|
export { CollectionSchema };
|
|
9
|
-
import { SetSchema } from "./types/SetSchema";
|
|
11
|
+
import { SetSchema } from "./types/custom/SetSchema";
|
|
10
12
|
export { SetSchema };
|
|
11
|
-
import { registerType } from "./types/
|
|
13
|
+
import { registerType } from "./types/registry";
|
|
12
14
|
export { registerType };
|
|
13
15
|
export { dumpChanges } from "./utils";
|
|
14
16
|
export type { Iterator } from "./encoding/decode";
|
|
@@ -16,7 +18,13 @@ import * as encode from "./encoding/encode";
|
|
|
16
18
|
import * as decode from "./encoding/decode";
|
|
17
19
|
export { encode, decode };
|
|
18
20
|
export { Reflection, ReflectionType, ReflectionField, } from "./Reflection";
|
|
19
|
-
export {
|
|
20
|
-
export
|
|
21
|
-
export {
|
|
22
|
-
export
|
|
21
|
+
export { Metadata } from "./Metadata";
|
|
22
|
+
export { type, deprecated, defineTypes, view, TypeContext, } from "./annotations";
|
|
23
|
+
export type { DefinitionType, PrimitiveType, Definition, } from "./annotations";
|
|
24
|
+
export { Encoder } from "./encoder/Encoder";
|
|
25
|
+
export { encodeSchemaOperation, encodeArray as encodeKeyValueOperation } from "./encoder/EncodeOperation";
|
|
26
|
+
export { ChangeTree, Ref } from "./encoder/ChangeTree";
|
|
27
|
+
export { StateView } from "./encoder/StateView";
|
|
28
|
+
export { Decoder } from "./decoder/Decoder";
|
|
29
|
+
export { decodeSchemaOperation, decodeKeyValueOperation } from "./decoder/DecodeOperation";
|
|
30
|
+
export { OPERATION } from "./encoding/spec";
|