@colyseus/schema 3.0.0-alpha.19 → 3.0.0-alpha.22

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.
Files changed (75) hide show
  1. package/build/cjs/index.js +94 -63
  2. package/build/cjs/index.js.map +1 -1
  3. package/build/esm/index.mjs +94 -61
  4. package/build/esm/index.mjs.map +1 -1
  5. package/build/umd/index.js +94 -63
  6. package/lib/Metadata.d.ts +1 -0
  7. package/lib/Metadata.js +32 -1
  8. package/lib/Metadata.js.map +1 -1
  9. package/lib/Reflection.d.ts +0 -1
  10. package/lib/Reflection.js +27 -20
  11. package/lib/Reflection.js.map +1 -1
  12. package/lib/Schema.d.ts +1 -1
  13. package/lib/annotations.js +12 -10
  14. package/lib/annotations.js.map +1 -1
  15. package/lib/codegen/api.js +1 -2
  16. package/lib/codegen/api.js.map +1 -1
  17. package/lib/codegen/languages/cpp.js +1 -2
  18. package/lib/codegen/languages/cpp.js.map +1 -1
  19. package/lib/codegen/languages/csharp.js +1 -2
  20. package/lib/codegen/languages/csharp.js.map +1 -1
  21. package/lib/codegen/languages/haxe.js +1 -2
  22. package/lib/codegen/languages/haxe.js.map +1 -1
  23. package/lib/codegen/languages/java.js +1 -2
  24. package/lib/codegen/languages/java.js.map +1 -1
  25. package/lib/codegen/languages/js.js +1 -2
  26. package/lib/codegen/languages/js.js.map +1 -1
  27. package/lib/codegen/languages/lua.js +1 -2
  28. package/lib/codegen/languages/lua.js.map +1 -1
  29. package/lib/codegen/languages/ts.js +1 -2
  30. package/lib/codegen/languages/ts.js.map +1 -1
  31. package/lib/codegen/parser.js +2 -3
  32. package/lib/codegen/parser.js.map +1 -1
  33. package/lib/codegen/types.js +3 -3
  34. package/lib/codegen/types.js.map +1 -1
  35. package/lib/decoder/DecodeOperation.d.ts +0 -1
  36. package/lib/decoder/DecodeOperation.js +2 -2
  37. package/lib/decoder/DecodeOperation.js.map +1 -1
  38. package/lib/decoder/Decoder.d.ts +0 -1
  39. package/lib/decoder/strategy/RawChanges.js +1 -2
  40. package/lib/decoder/strategy/RawChanges.js.map +1 -1
  41. package/lib/decoder/strategy/StateCallbacks.js +1 -2
  42. package/lib/decoder/strategy/StateCallbacks.js.map +1 -1
  43. package/lib/encoder/EncodeOperation.d.ts +0 -1
  44. package/lib/encoder/EncodeOperation.js +3 -3
  45. package/lib/encoder/EncodeOperation.js.map +1 -1
  46. package/lib/encoder/Encoder.d.ts +0 -1
  47. package/lib/encoder/Encoder.js +5 -5
  48. package/lib/encoder/Encoder.js.map +1 -1
  49. package/lib/encoder/StateView.js +2 -2
  50. package/lib/encoder/StateView.js.map +1 -1
  51. package/lib/encoding/assert.js +3 -3
  52. package/lib/encoding/assert.js.map +1 -1
  53. package/lib/encoding/decode.js +20 -21
  54. package/lib/encoding/decode.js.map +1 -1
  55. package/lib/encoding/encode.d.ts +0 -1
  56. package/lib/encoding/encode.js +17 -17
  57. package/lib/encoding/encode.js.map +1 -1
  58. package/lib/index.d.ts +1 -0
  59. package/lib/index.js.map +1 -1
  60. package/lib/types/custom/ArraySchema.d.ts +2 -2
  61. package/lib/types/custom/ArraySchema.js +0 -8
  62. package/lib/types/custom/ArraySchema.js.map +1 -1
  63. package/lib/types/registry.js +3 -4
  64. package/lib/types/registry.js.map +1 -1
  65. package/lib/types/utils.js +1 -2
  66. package/lib/types/utils.js.map +1 -1
  67. package/lib/utils.js +3 -4
  68. package/lib/utils.js.map +1 -1
  69. package/package.json +5 -5
  70. package/src/Metadata.ts +39 -1
  71. package/src/Reflection.ts +30 -20
  72. package/src/annotations.ts +6 -2
  73. package/src/encoder/Encoder.ts +5 -5
  74. package/src/index.ts +2 -0
  75. package/src/types/custom/ArraySchema.ts +2 -1
@@ -22,7 +22,23 @@
22
22
  * SOFTWARE
23
23
  */
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.number = exports.string = exports.boolean = exports.writeFloat64 = exports.writeFloat32 = exports.float64 = exports.float32 = exports.uint64 = exports.int64 = exports.uint32 = exports.int32 = exports.uint16 = exports.int16 = exports.uint8 = exports.int8 = exports.utf8Write = exports.utf8Length = void 0;
25
+ exports.utf8Length = void 0;
26
+ exports.utf8Write = utf8Write;
27
+ exports.int8 = int8;
28
+ exports.uint8 = uint8;
29
+ exports.int16 = int16;
30
+ exports.uint16 = uint16;
31
+ exports.int32 = int32;
32
+ exports.uint32 = uint32;
33
+ exports.int64 = int64;
34
+ exports.uint64 = uint64;
35
+ exports.float32 = float32;
36
+ exports.float64 = float64;
37
+ exports.writeFloat32 = writeFloat32;
38
+ exports.writeFloat64 = writeFloat64;
39
+ exports.boolean = boolean;
40
+ exports.string = string;
41
+ exports.number = number;
26
42
  /**
27
43
  * msgpack implementation highly based on notepack.io
28
44
  * https://github.com/darrachequesne/notepack
@@ -82,28 +98,23 @@ function utf8Write(view, str, it) {
82
98
  }
83
99
  }
84
100
  }
85
- exports.utf8Write = utf8Write;
86
101
  function int8(bytes, value, it) {
87
102
  bytes[it.offset++] = value & 255;
88
103
  }
89
- exports.int8 = int8;
90
104
  ;
91
105
  function uint8(bytes, value, it) {
92
106
  bytes[it.offset++] = value & 255;
93
107
  }
94
- exports.uint8 = uint8;
95
108
  ;
96
109
  function int16(bytes, value, it) {
97
110
  bytes[it.offset++] = value & 255;
98
111
  bytes[it.offset++] = (value >> 8) & 255;
99
112
  }
100
- exports.int16 = int16;
101
113
  ;
102
114
  function uint16(bytes, value, it) {
103
115
  bytes[it.offset++] = value & 255;
104
116
  bytes[it.offset++] = (value >> 8) & 255;
105
117
  }
106
- exports.uint16 = uint16;
107
118
  ;
108
119
  function int32(bytes, value, it) {
109
120
  bytes[it.offset++] = value & 255;
@@ -111,7 +122,6 @@ function int32(bytes, value, it) {
111
122
  bytes[it.offset++] = (value >> 16) & 255;
112
123
  bytes[it.offset++] = (value >> 24) & 255;
113
124
  }
114
- exports.int32 = int32;
115
125
  ;
116
126
  function uint32(bytes, value, it) {
117
127
  const b4 = value >> 24;
@@ -123,7 +133,6 @@ function uint32(bytes, value, it) {
123
133
  bytes[it.offset++] = b3 & 255;
124
134
  bytes[it.offset++] = b4 & 255;
125
135
  }
126
- exports.uint32 = uint32;
127
136
  ;
128
137
  function int64(bytes, value, it) {
129
138
  const high = Math.floor(value / Math.pow(2, 32));
@@ -131,7 +140,6 @@ function int64(bytes, value, it) {
131
140
  uint32(bytes, low, it);
132
141
  uint32(bytes, high, it);
133
142
  }
134
- exports.int64 = int64;
135
143
  ;
136
144
  function uint64(bytes, value, it) {
137
145
  const high = (value / Math.pow(2, 32)) >> 0;
@@ -139,16 +147,13 @@ function uint64(bytes, value, it) {
139
147
  uint32(bytes, low, it);
140
148
  uint32(bytes, high, it);
141
149
  }
142
- exports.uint64 = uint64;
143
150
  ;
144
151
  function float32(bytes, value, it) {
145
152
  writeFloat32(bytes, value, it);
146
153
  }
147
- exports.float32 = float32;
148
154
  function float64(bytes, value, it) {
149
155
  writeFloat64(bytes, value, it);
150
156
  }
151
- exports.float64 = float64;
152
157
  // force little endian to facilitate decoding on multiple implementations
153
158
  const _isLittleEndian = true; // new Uint16Array(new Uint8Array([1, 0]).buffer)[0] === 1;
154
159
  const _int32 = new Int32Array(2);
@@ -158,19 +163,16 @@ function writeFloat32(bytes, value, it) {
158
163
  _float32[0] = value;
159
164
  int32(bytes, _int32[0], it);
160
165
  }
161
- exports.writeFloat32 = writeFloat32;
162
166
  ;
163
167
  function writeFloat64(bytes, value, it) {
164
168
  _float64[0] = value;
165
169
  int32(bytes, _int32[_isLittleEndian ? 0 : 1], it);
166
170
  int32(bytes, _int32[_isLittleEndian ? 1 : 0], it);
167
171
  }
168
- exports.writeFloat64 = writeFloat64;
169
172
  ;
170
173
  function boolean(bytes, value, it) {
171
174
  bytes[it.offset++] = value ? 1 : 0; // uint8
172
175
  }
173
- exports.boolean = boolean;
174
176
  ;
175
177
  function string(bytes, value, it) {
176
178
  // encode `null` strings as empty.
@@ -208,7 +210,6 @@ function string(bytes, value, it) {
208
210
  utf8Write(bytes, value, it);
209
211
  return size + length;
210
212
  }
211
- exports.string = string;
212
213
  function number(bytes, value, it) {
213
214
  if (isNaN(value)) {
214
215
  return number(bytes, 0, it);
@@ -286,5 +287,4 @@ function number(bytes, value, it) {
286
287
  return 9;
287
288
  }
288
289
  }
289
- exports.number = number;
290
290
  //# sourceMappingURL=encode.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"encode.js","sourceRoot":"","sources":["../../src/encoding/encode.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;;;AAOH;;;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,MAAM,mBAAmB,GAAG,CAAC,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,CAAC,UAAU,CAAC,CAAC;AAEpE,QAAA,UAAU,GAAG,CAAC,mBAAmB,CAAC;IAC3C,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO;IAC3B,CAAC,CAAC,UAAU,GAAW,EAAE,CAAO;QAC5B,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC;QACtB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YACzC,CAAC,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;YACtB,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC;gBACX,MAAM,IAAI,CAAC,CAAC;YAChB,CAAC;iBACI,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC;gBACjB,MAAM,IAAI,CAAC,CAAC;YAChB,CAAC;iBACI,IAAI,CAAC,GAAG,MAAM,IAAI,CAAC,IAAI,MAAM,EAAE,CAAC;gBACjC,MAAM,IAAI,CA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KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC;YAC1B,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;YACxB,OAAO,CAAC,CAAC;QACX,CAAC;QAED,SAAS;QACT,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC;QAC1B,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QACxB,OAAO,CAAC,CAAC;IACX,CAAC;AACH,CAAC;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\";\nimport type { Iterator } from \"./decode\";\n\nexport type BufferLike = number[] | ArrayBufferLike;\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\nconst hasBufferByteLength = (typeof Buffer !== 'undefined' && Buffer.byteLength);\n\nexport const utf8Length = (hasBufferByteLength)\n ? Buffer.byteLength // node\n : function (str: string, _?: any) {\n var c = 0, length = 0;\n for (var i = 0, l = str.length; i < l; i++) {\n c = str.charCodeAt(i);\n if (c < 0x80) {\n length += 1;\n }\n else if (c < 0x800) {\n length += 2;\n }\n else if (c < 0xd800 || c >= 0xe000) {\n length += 3;\n }\n else {\n i++;\n length += 4;\n }\n }\n return length;\n }\n\nexport function utf8Write(view: BufferLike, str: string, it: Iterator) {\n var c = 0;\n for (var i = 0, l = str.length; i < l; i++) {\n c = str.charCodeAt(i);\n if (c < 0x80) {\n view[it.offset++] = c;\n }\n else if (c < 0x800) {\n view[it.offset++] = 0xc0 | (c >> 6);\n view[it.offset++] = 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: BufferLike, value: number, it: Iterator) {\n bytes[it.offset++] = value & 255;\n};\n\nexport function uint8(bytes: BufferLike, value: number, it: Iterator) {\n bytes[it.offset++] = value & 255;\n};\n\nexport function int16(bytes: BufferLike, value: number, it: Iterator) {\n bytes[it.offset++] = value & 255;\n bytes[it.offset++] = (value >> 8) & 255;\n};\n\nexport function uint16(bytes: BufferLike, value: number, it: Iterator) {\n bytes[it.offset++] = value & 255;\n bytes[it.offset++] = (value >> 8) & 255;\n};\n\nexport function int32(bytes: BufferLike, value: number, it: Iterator) {\n bytes[it.offset++] = value & 255;\n bytes[it.offset++] = (value >> 8) & 255;\n bytes[it.offset++] = (value >> 16) & 255;\n bytes[it.offset++] = (value >> 24) & 255;\n};\n\nexport function uint32(bytes: BufferLike, value: number, it: Iterator) {\n const b4 = value >> 24;\n const b3 = value >> 16;\n const b2 = value >> 8;\n const b1 = value;\n bytes[it.offset++] = b1 & 255;\n bytes[it.offset++] = b2 & 255;\n bytes[it.offset++] = b3 & 255;\n bytes[it.offset++] = b4 & 255;\n};\n\nexport function int64(bytes: BufferLike, value: number, it: Iterator) {\n const high = Math.floor(value / Math.pow(2, 32));\n const low = value >>> 0;\n uint32(bytes, low, it);\n uint32(bytes, high, it);\n};\n\nexport function uint64(bytes: BufferLike, value: number, it: Iterator) {\n const high = (value / Math.pow(2, 32)) >> 0;\n const low = value >>> 0;\n uint32(bytes, low, it);\n uint32(bytes, high, it);\n};\n\nexport function float32(bytes: BufferLike, value: number, it: Iterator) {\n writeFloat32(bytes, value, it);\n}\n\nexport function float64(bytes: BufferLike, value: number, it: Iterator) {\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: BufferLike, value: number, it: Iterator) {\n _float32[0] = value;\n int32(bytes, _int32[0], it);\n};\n\nexport function writeFloat64(bytes: BufferLike, value: number, it: Iterator) {\n _float64[0] = value;\n int32(bytes, _int32[_isLittleEndian ? 0 : 1], it);\n int32(bytes, _int32[_isLittleEndian ? 1 : 0], it);\n};\n\nexport function boolean(bytes: BufferLike, value: number, it: Iterator) {\n bytes[it.offset++] = value ? 1 : 0; // uint8\n};\n\nexport function string(bytes: BufferLike, value: string, it: Iterator) {\n // encode `null` strings as empty.\n if (!value) { value = \"\"; }\n\n let length = utf8Length(value, \"utf8\");\n let size = 0;\n\n // fixstr\n if (length < 0x20) {\n bytes[it.offset++] = length | 0xa0;\n size = 1;\n }\n // str 8\n else if (length < 0x100) {\n bytes[it.offset++] = 0xd9;\n bytes[it.offset++] = length % 255;\n size = 2;\n }\n // str 16\n else if (length < 0x10000) {\n bytes[it.offset++] = 0xda;\n uint16(bytes, length, it);\n size = 3;\n }\n // str 32\n else if (length < 0x100000000) {\n bytes[it.offset++] = 0xdb;\n uint32(bytes, length, it);\n size = 5;\n } else {\n throw new Error('String too long');\n }\n\n utf8Write(bytes, value, it);\n\n return size + length;\n}\n\nexport function number(bytes: BufferLike, value: number, it: Iterator) {\n if (isNaN(value)) {\n return number(bytes, 0, it);\n\n } else if (!isFinite(value)) {\n return number(bytes, (value > 0) ? Number.MAX_SAFE_INTEGER : -Number.MAX_SAFE_INTEGER, it);\n\n } else if (value !== (value|0)) {\n 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"]}
1
+ {"version":3,"file":"encode.js","sourceRoot":"","sources":["../../src/encoding/encode.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;;;AAyCH,8BAyBC;AAED,oBAEC;AAED,sBAEC;AAED,sBAGC;AAED,wBAGC;AAED,sBAKC;AAED,wBASC;AAED,sBAKC;AAED,wBAKC;AAED,0BAEC;AAED,0BAEC;AAQD,oCAGC;AAED,oCAIC;AAED,0BAEC;AAED,wBAoCC;AAED,wBAwFC;AA1QD;;;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,MAAM,mBAAmB,GAAG,CAAC,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,CAAC,UAAU,CAAC,CAAC;AAEpE,QAAA,UAAU,GAAG,CAAC,mBAAmB,CAAC;IAC3C,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO;IAC3B,CAAC,CAAC,UAAU,GAAW,EAAE,CAAO;QAC5B,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC;QACtB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YACzC,CAAC,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;YACtB,IAAI,CAAC,GAAG,IAAI,EAA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AC,UAAU,EAAE,CAAC;YACzB,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC;YAC1B,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;YACxB,OAAO,CAAC,CAAC;QACX,CAAC;QAED,SAAS;QACT,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC;QAC1B,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QACxB,OAAO,CAAC,CAAC;IACX,CAAC;AACH,CAAC","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\";\nimport type { Iterator } from \"./decode\";\n\nexport type BufferLike = number[] | ArrayBufferLike;\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\nconst hasBufferByteLength = (typeof Buffer !== 'undefined' && Buffer.byteLength);\n\nexport const utf8Length = (hasBufferByteLength)\n ? Buffer.byteLength // node\n : function (str: string, _?: any) {\n var c = 0, length = 0;\n for (var i = 0, l = str.length; i < l; i++) {\n c = str.charCodeAt(i);\n if (c < 0x80) {\n length += 1;\n }\n else if (c < 0x800) {\n length += 2;\n }\n else if (c < 0xd800 || c >= 0xe000) {\n length += 3;\n }\n else {\n i++;\n length += 4;\n }\n }\n return length;\n }\n\nexport function utf8Write(view: BufferLike, str: string, it: Iterator) {\n var c = 0;\n for (var i = 0, l = str.length; i < l; i++) {\n c = str.charCodeAt(i);\n if (c < 0x80) {\n view[it.offset++] = c;\n }\n else if (c < 0x800) {\n view[it.offset++] = 0xc0 | (c >> 6);\n view[it.offset++] = 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: BufferLike, value: number, it: Iterator) {\n bytes[it.offset++] = value & 255;\n};\n\nexport function uint8(bytes: BufferLike, value: number, it: Iterator) {\n bytes[it.offset++] = value & 255;\n};\n\nexport function int16(bytes: BufferLike, value: number, it: Iterator) {\n bytes[it.offset++] = value & 255;\n bytes[it.offset++] = (value >> 8) & 255;\n};\n\nexport function uint16(bytes: BufferLike, value: number, it: Iterator) {\n bytes[it.offset++] = value & 255;\n bytes[it.offset++] = (value >> 8) & 255;\n};\n\nexport function int32(bytes: BufferLike, value: number, it: Iterator) {\n bytes[it.offset++] = value & 255;\n bytes[it.offset++] = (value >> 8) & 255;\n bytes[it.offset++] = (value >> 16) & 255;\n bytes[it.offset++] = (value >> 24) & 255;\n};\n\nexport function uint32(bytes: BufferLike, value: number, it: Iterator) {\n const b4 = value >> 24;\n const b3 = value >> 16;\n const b2 = value >> 8;\n const b1 = value;\n bytes[it.offset++] = b1 & 255;\n bytes[it.offset++] = b2 & 255;\n bytes[it.offset++] = b3 & 255;\n bytes[it.offset++] = b4 & 255;\n};\n\nexport function int64(bytes: BufferLike, value: number, it: Iterator) {\n const high = Math.floor(value / Math.pow(2, 32));\n const low = value >>> 0;\n uint32(bytes, low, it);\n uint32(bytes, high, it);\n};\n\nexport function uint64(bytes: BufferLike, value: number, it: Iterator) {\n const high = (value / Math.pow(2, 32)) >> 0;\n const low = value >>> 0;\n uint32(bytes, low, it);\n uint32(bytes, high, it);\n};\n\nexport function float32(bytes: BufferLike, value: number, it: Iterator) {\n writeFloat32(bytes, value, it);\n}\n\nexport function float64(bytes: BufferLike, value: number, it: Iterator) {\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: BufferLike, value: number, it: Iterator) {\n _float32[0] = value;\n int32(bytes, _int32[0], it);\n};\n\nexport function writeFloat64(bytes: BufferLike, value: number, it: Iterator) {\n _float64[0] = value;\n int32(bytes, _int32[_isLittleEndian ? 0 : 1], it);\n int32(bytes, _int32[_isLittleEndian ? 1 : 0], it);\n};\n\nexport function boolean(bytes: BufferLike, value: number, it: Iterator) {\n bytes[it.offset++] = value ? 1 : 0; // uint8\n};\n\nexport function string(bytes: BufferLike, value: string, it: Iterator) {\n // encode `null` strings as empty.\n if (!value) { value = \"\"; }\n\n let length = utf8Length(value, \"utf8\");\n let size = 0;\n\n // fixstr\n if (length < 0x20) {\n bytes[it.offset++] = length | 0xa0;\n size = 1;\n }\n // str 8\n else if (length < 0x100) {\n bytes[it.offset++] = 0xd9;\n bytes[it.offset++] = length % 255;\n size = 2;\n }\n // str 16\n else if (length < 0x10000) {\n bytes[it.offset++] = 0xda;\n uint16(bytes, length, it);\n size = 3;\n }\n // str 32\n else if (length < 0x100000000) {\n bytes[it.offset++] = 0xdb;\n uint32(bytes, length, it);\n size = 5;\n } else {\n throw new Error('String too long');\n }\n\n utf8Write(bytes, value, it);\n\n return size + length;\n}\n\nexport function number(bytes: BufferLike, value: number, it: Iterator) {\n if (isNaN(value)) {\n return number(bytes, 0, it);\n\n } else if (!isFinite(value)) {\n return number(bytes, (value > 0) ? Number.MAX_SAFE_INTEGER : -Number.MAX_SAFE_INTEGER, it);\n\n } else if (value !== (value|0)) {\n 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"]}
package/lib/index.d.ts CHANGED
@@ -2,6 +2,7 @@ export { Schema } from "./Schema";
2
2
  export type { DataChange } from "./decoder/DecodeOperation";
3
3
  import { $track, $encoder, $decoder, $filter, $getByIndex, $deleteByIndex, $changes, $childType } from "./types/symbols";
4
4
  export { $track, $encoder, $decoder, $filter, $getByIndex, $deleteByIndex, $changes, $childType };
5
+ export type { ToJSON } from "./types/HelperTypes";
5
6
  import { MapSchema } from "./types/custom/MapSchema";
6
7
  export { MapSchema };
7
8
  import { ArraySchema } from "./types/custom/ArraySchema";
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mCAAkC;AAAzB,gGAAA,MAAM,OAAA;AAGf,6CAAyH;AAChH,uFADA,gBAAM,OACA;AAAE,yFADA,kBAAQ,OACA;AAAE,yFADA,kBAAQ,OACA;AAAE,wFADA,iBAAO,OACA;AAAE,4FADA,qBAAW,OACA;AAAE,+FADA,wBAAc,OACA;AAAE,yFADA,kBAAQ,OACA;AAAE,2FADA,oBAAU,OACA;AAE/F,wDAAoD;AAC3C,0FADA,qBAAS,OACA;AAElB,4DAAyD;AAChD,4FADA,yBAAW,OACA;AAEpB,sEAAmE;AAC1D,iGADA,mCAAgB,OACA;AAEzB,wDAAqD;AAC5C,0FADA,qBAAS,OACA;AAElB,+CAAgD;AACvC,6FADA,uBAAY,OACA;AAErB,IAAA,uBAAY,EAAC,KAAK,EAAE,EAAE,WAAW,EAAE,qBAAS,EAAE,CAAC,CAAC;AAChD,IAAA,uBAAY,EAAC,OAAO,EAAE,EAAE,WAAW,EAAE,yBAAW,EAAE,CAAC,CAAC;AACpD,IAAA,uBAAY,EAAC,KAAK,EAAE,EAAE,WAAW,EAAE,qBAAS,EAAE,CAAC,CAAC;AAChD,IAAA,uBAAY,EAAC,YAAY,EAAE,EAAE,WAAW,EAAE,mCAAgB,GAAG,CAAC,CAAC;AAE/D,QAAQ;AACR,iCAAsC;AAA7B,oGAAA,WAAW,OAAA;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,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AAEjB,6CASuB;AARnB,cAAc;AACd,mGAAA,IAAI,OAAA;AACJ,yGAAA,UAAU,OAAA;AACV,0GAAA,WAAW,OAAA;AACX,mGAAA,IAAI,OAAA;AAEJ,YAAY;AACZ,0GAAA,WAAW,OAAA;AAMf,oEAA8G;AAArG,0HAAA,wBAAwB,OAAA;AACjC,4DAAsE;AAA7D,mHAAA,qBAAqB,OAAA;AAE9B,6CAA4C;AAAnC,kGAAA,OAAO,OAAA;AAChB,6DAA0G;AAAjG,wHAAA,qBAAqB,OAAA;AAAE,0HAAA,WAAW,OAA2B;AACtE,mDAAuD;AAA9C,wGAAA,UAAU,OAAA;AACnB,iDAAgD;AAAvC,sGAAA,SAAS,OAAA;AAElB,6CAA4C;AAAnC,kGAAA,OAAO,OAAA;AAChB,6DAA2F;AAAlF,wHAAA,qBAAqB,OAAA;AAAE,0HAAA,uBAAuB,OAAA;AAEvD,wCAA4C;AAAnC,iGAAA,SAAS,OAAA","sourcesContent":["export { Schema } from \"./Schema\";\nexport type { DataChange } from \"./decoder/DecodeOperation\";\n\nimport { $track, $encoder, $decoder, $filter, $getByIndex, $deleteByIndex, $changes, $childType } from \"./types/symbols\";\nexport { $track, $encoder, $decoder, $filter, $getByIndex, $deleteByIndex, $changes, $childType };\n\nimport { MapSchema } from \"./types/custom/MapSchema\"\nexport { MapSchema };\n\nimport { ArraySchema } from \"./types/custom/ArraySchema\";\nexport { ArraySchema };\n\nimport { CollectionSchema } from \"./types/custom/CollectionSchema\";\nexport { CollectionSchema };\n\nimport { SetSchema } from \"./types/custom/SetSchema\";\nexport { SetSchema };\n\nimport { registerType } from \"./types/registry\";\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 type { 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 { Metadata } from \"./Metadata\";\n\nexport {\n // Annotations\n type,\n deprecated,\n defineTypes,\n view,\n\n // Internals\n TypeContext,\n} from \"./annotations\";\n\n// Annotation types\nexport type { DefinitionType, PrimitiveType, Definition, } from \"./annotations\";\n\nexport { getDecoderStateCallbacks, CallbackProxy, GetCallbackProxy } from \"./decoder/strategy/StateCallbacks\";\nexport { getRawChangesCallback } from \"./decoder/strategy/RawChanges\";\n\nexport { Encoder } from \"./encoder/Encoder\";\nexport { encodeSchemaOperation, encodeArray as encodeKeyValueOperation } from \"./encoder/EncodeOperation\";\nexport { ChangeTree, Ref } from \"./encoder/ChangeTree\";\nexport { StateView } from \"./encoder/StateView\";\n\nexport { Decoder } from \"./decoder/Decoder\";\nexport { decodeSchemaOperation, decodeKeyValueOperation } from \"./decoder/DecodeOperation\";\n\nexport { OPERATION } from \"./encoding/spec\";"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mCAAkC;AAA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;AAA7D,mHAAA,qBAAqB,OAAA;AAE9B,6CAA4C;AAAnC,kGAAA,OAAO,OAAA;AAChB,6DAA0G;AAAjG,wHAAA,qBAAqB,OAAA;AAAE,0HAAA,WAAW,OAA2B;AACtE,mDAAuD;AAA9C,wGAAA,UAAU,OAAA;AACnB,iDAAgD;AAAvC,sGAAA,SAAS,OAAA;AAElB,6CAA4C;AAAnC,kGAAA,OAAO,OAAA;AAChB,6DAA2F;AAAlF,wHAAA,qBAAqB,OAAA;AAAE,0HAAA,uBAAuB,OAAA;AAEvD,wCAA4C;AAAnC,iGAAA,SAAS,OAAA","sourcesContent":["export { Schema } from \"./Schema\";\nexport type { DataChange } from \"./decoder/DecodeOperation\";\n\nimport { $track, $encoder, $decoder, $filter, $getByIndex, $deleteByIndex, $changes, $childType } from \"./types/symbols\";\nexport { $track, $encoder, $decoder, $filter, $getByIndex, $deleteByIndex, $changes, $childType };\n\nexport type { ToJSON } from \"./types/HelperTypes\";\n\nimport { MapSchema } from \"./types/custom/MapSchema\"\nexport { MapSchema };\n\nimport { ArraySchema } from \"./types/custom/ArraySchema\";\nexport { ArraySchema };\n\nimport { CollectionSchema } from \"./types/custom/CollectionSchema\";\nexport { CollectionSchema };\n\nimport { SetSchema } from \"./types/custom/SetSchema\";\nexport { SetSchema };\n\nimport { registerType } from \"./types/registry\";\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 type { 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 { Metadata } from \"./Metadata\";\n\nexport {\n // Annotations\n type,\n deprecated,\n defineTypes,\n view,\n\n // Internals\n TypeContext,\n} from \"./annotations\";\n\n// Annotation types\nexport type { DefinitionType, PrimitiveType, Definition, } from \"./annotations\";\n\nexport { getDecoderStateCallbacks, CallbackProxy, GetCallbackProxy } from \"./decoder/strategy/StateCallbacks\";\nexport { getRawChangesCallback } from \"./decoder/strategy/RawChanges\";\n\nexport { Encoder } from \"./encoder/Encoder\";\nexport { encodeSchemaOperation, encodeArray as encodeKeyValueOperation } from \"./encoder/EncodeOperation\";\nexport { ChangeTree, Ref } from \"./encoder/ChangeTree\";\nexport { StateView } from \"./encoder/StateView\";\n\nexport { Decoder } from \"./decoder/Decoder\";\nexport { decodeSchemaOperation, decodeKeyValueOperation } from \"./decoder/DecodeOperation\";\n\nexport { OPERATION } from \"./encoding/spec\";"]}
@@ -101,7 +101,7 @@ export declare class ArraySchema<V = any> implements Array<V>, Collection<number
101
101
  * @param thisArg An object to which the this keyword can refer in the callbackfn function.
102
102
  * If thisArg is omitted, undefined is used as the this value.
103
103
  */
104
- every(callbackfn: (value: V, index: number, array: V[]) => unknown, thisArg?: any): boolean;
104
+ every<S extends V>(predicate: (value: V, index: number, array: V[]) => value is S, thisArg?: any): this is S[];
105
105
  /**
106
106
  * Determines whether the specified callback function returns true for any element of an array.
107
107
  * @param callbackfn A function that accepts up to three arguments. The some method calls
@@ -230,7 +230,7 @@ export declare class ArraySchema<V = any> implements Array<V>, Collection<number
230
230
  flat<A, D extends number = 1>(this: A, depth?: D): any;
231
231
  findLast(): any;
232
232
  findLastIndex(...args: any[]): any;
233
- with(index: number, value: V): V[];
233
+ with(index: number, value: V): ArraySchema<V>;
234
234
  toReversed(): V[];
235
235
  toSorted(compareFn?: (a: V, b: V) => number): V[];
236
236
  toSpliced(start: number, deleteCount: number, ...items: V[]): V[];
@@ -392,14 +392,6 @@ class ArraySchema {
392
392
  lastIndexOf(searchElement, fromIndex = this.length - 1) {
393
393
  return this.items.lastIndexOf(searchElement, fromIndex);
394
394
  }
395
- /**
396
- * Determines whether all the members of an array satisfy the specified test.
397
- * @param callbackfn A function that accepts up to three arguments. The every method calls
398
- * the callbackfn function for each element in the array until the callbackfn returns a value
399
- * which is coercible to the Boolean value false, or until the end of the array.
400
- * @param thisArg An object to which the this keyword can refer in the callbackfn function.
401
- * If thisArg is omitted, undefined is used as the this value.
402
- */
403
395
  every(callbackfn, thisArg) {
404
396
  return this.items.every(callbackfn, thisArg);
405
397
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ArraySchema.js","sourceRoot":"","sources":["../../../src/types/custom/ArraySchema.ts"],"names":[],"mappings":";;;;AAAA,wCAAgJ;AAEhJ,yDAAsD;AACtD,8CAAgD;AAChD,0CAA2C;AAG3C,mEAA4D;AAC5D,mEAA4D;AAG5D,MAAM,YAAY,GAAG,CAAC,CAAM,EAAE,CAAM,EAAE,EAAE;IACpC,MAAM,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC;IACvB,MAAM,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC;IACvB,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,CAAC,CAAC,CAAC;SAChB,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,CAAC,CAAC;;QACpB,OAAO,CAAC,CAAA;AACjB,CAAC,CAAA;AAED,MAAa,WAAW;aAOb,QAAU,GAAG,6BAAW,AAAd,CAAe;aACzB,QAAU,GAAG,6BAAW,AAAd,CAAe;IAEhC;;;;;;;;OAQG;IACH,MAAM,CAAC,OAZC,kBAAQ,OACR,kBAAQ,EAWR,iBAAO,EAAC,CAAE,GAAgB,EAAE,KAAa,EAAE,IAAe;QAC9D,mDAAmD;QACnD,OAAO,CACH,CAAC,IAAI;YACL,OAAO,CAAC,GAAG,CAAC,oBAAU,CAAC,CAAC,KAAK,QAAQ;YACrC,oDAAoD;YACpD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,kBAAQ,CAAC,CAAC,CACrD,CAA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AAC,KAAK,EAAE,EAAE;YAChC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,KAAK,UAAU,CAAC;gBAC5C,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE;gBACnB,CAAC,CAAC,KAAK,CAAC;QAChB,CAAC,CAAC,CAAC;IACP,CAAC;IAED,EAAE;IACF,qBAAqB;IACrB,EAAE;IACF,KAAK,CAAC,UAAoB;QACtB,IAAI,MAAmB,CAAC;QAExB,IAAI,UAAU,EAAE,CAAC;YACb,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;YAC3B,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;QAE/B,CAAC;aAAM,CAAC;YACJ,MAAM,GAAG,IAAI,WAAW,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CACzC,CAAC,IAAI,CAAC,kBAAQ,CAAC,CAAC;gBACZ,CAAC,CAAE,IAAsB,CAAC,KAAK,EAAE;gBACjC,CAAC,CAAC,IAAI,CACb,CAAC,CAAC,CAAC;QACR,CAAC;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;IAAA,CAAC;;AAnvBN,kCAqvBC;AAED,IAAA,uBAAY,EAAC,OAAO,EAAE,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC,CAAC","sourcesContent":["import { $changes, $childType, $decoder, $deleteByIndex, $onEncodeEnd, $encoder, $filter, $getByIndex, $onDecodeEnd, $isNew } from \"../symbols\";\nimport type { Schema } from \"../../Schema\";\nimport { ChangeTree } from \"../../encoder/ChangeTree\";\nimport { OPERATION } from \"../../encoding/spec\";\nimport { registerType } from \"../registry\";\nimport { Collection } from \"../HelperTypes\";\n\nimport { encodeArray } from \"../../encoder/EncodeOperation\";\nimport { decodeArray } from \"../../decoder/DecodeOperation\";\nimport type { StateView } from \"../../encoder/StateView\";\n\nconst DEFAULT_SORT = (a: any, b: any) => {\n const A = a.toString();\n const B = b.toString();\n if (A < B) return -1;\n else if (A > B) return 1;\n else return 0\n}\n\nexport class ArraySchema<V = any> implements Array<V>, Collection<number, V> {\n [n: number]: V;\n\n protected items: V[] = [];\n protected tmpItems: V[] = [];\n protected deletedIndexes: {[index: number]: boolean} = {};\n\n static [$encoder] = encodeArray;\n static [$decoder] = decodeArray;\n\n /**\n * Determine if a property must be filtered.\n * - If returns false, the property is NOT going to be encoded.\n * - If returns true, the property is going to be encoded.\n *\n * Encoding with \"filters\" happens in two steps:\n * - First, the encoder iterates over all \"not owned\" properties and encodes them.\n * - Then, the encoder iterates over all \"owned\" properties per instance and encodes them.\n */\n static [$filter] (ref: ArraySchema, index: number, view: StateView) {\n // console.log(\"ArraSchema[$filter] VIEW??\", !view)\n return (\n !view ||\n typeof (ref[$childType]) === \"string\" ||\n // view.items.has(ref[$getByIndex](index)[$changes])\n view.items.has(ref['tmpItems'][index]?.[$changes])\n );\n }\n\n static is(type: any) {\n return (\n // type format: [\"string\"]\n Array.isArray(type) ||\n\n // type format: { array: \"string\" }\n (type['array'] !== undefined)\n );\n }\n\n constructor (...items: V[]) {\n\n Object.defineProperty(this, $childType, {\n value: undefined,\n enumerable: false,\n writable: true,\n configurable: true,\n });\n\n const proxy = new Proxy(this, {\n get: (obj, prop) => {\n if (\n typeof (prop) !== \"symbol\" &&\n !isNaN(prop as any) // https://stackoverflow.com/a/175787/892698\n ) {\n return this.items[prop];\n\n } else {\n return Reflect.get(obj, prop);\n }\n },\n\n set: (obj, key, setValue) => {\n if (typeof (key) !== \"symbol\" && !isNaN(key as any)) {\n if (setValue === undefined || setValue === null) {\n obj.$deleteAt(key as unknown as number);\n\n } else {\n if (setValue[$changes]) {\n if (obj.items[key as unknown as number] !== undefined) {\n if (setValue[$changes][$isNew]) {\n this[$changes].indexedOperation(Number(key), OPERATION.MOVE_AND_ADD);\n\n } else {\n if ((obj[$changes].getChange(Number(key)) & OPERATION.DELETE) === OPERATION.DELETE) {\n this[$changes].indexedOperation(Number(key), OPERATION.DELETE_AND_MOVE);\n } else {\n this[$changes].indexedOperation(Number(key), OPERATION.MOVE);\n }\n }\n } else if (setValue[$changes][$isNew]) {\n this[$changes].indexedOperation(Number(key), OPERATION.ADD);\n }\n } else {\n obj.$changeAt(Number(key), setValue);\n }\n\n this.items[key as unknown as number] = setValue;\n this.tmpItems[key as unknown as number] = setValue;\n }\n\n return true;\n } else {\n return Reflect.set(obj, key, setValue);\n }\n },\n\n deleteProperty: (obj, prop) => {\n if (typeof (prop) === \"number\") {\n obj.$deleteAt(prop);\n\n } else {\n delete obj[prop];\n }\n\n return true;\n },\n\n has: (obj, key) => {\n if (typeof (key) !== \"symbol\" && !isNaN(Number(key))) {\n return Reflect.has(this.items, key);\n }\n return Reflect.has(obj, key)\n }\n });\n\n this[$changes] = new ChangeTree(proxy);\n this.push.apply(this, items);\n\n return proxy;\n }\n\n set length (newLength: number) {\n if (newLength === 0) {\n this.clear();\n } else if (newLength < this.items.length) {\n this.splice(newLength, this.length - newLength);\n } else {\n console.warn(\"ArraySchema: can't set .length to a higher value than its length.\");\n }\n }\n\n get length() {\n return this.items.length;\n }\n\n push(...values: V[]) {\n let length = this.tmpItems.length;\n\n values.forEach((value, i) => {\n // skip null values\n if (value === undefined || value === null) {\n return;\n }\n\n const changeTree = this[$changes];\n changeTree.indexedOperation(length, OPERATION.ADD, this.items.length);\n // changeTree.indexes[length] = length;\n\n this.items.push(value);\n this.tmpItems.push(value);\n\n //\n // set value's parent after the value is set\n // (to avoid encoding \"refId\" operations before parent's \"ADD\" operation)\n //\n value[$changes]?.setParent(this, changeTree.root, length);\n\n length++;\n });\n\n return length;\n }\n\n /**\n * Removes the last element from an array and returns it.\n */\n pop(): V | undefined {\n let index: number = -1;\n\n // find last non-undefined index\n for (let i = this.tmpItems.length - 1; i >= 0; i--) {\n // if (this.tmpItems[i] !== undefined) {\n if (this.deletedIndexes[i] !== true) {\n index = i;\n break;\n }\n }\n\n if (index < 0) {\n return undefined;\n }\n\n this[$changes].delete(index, undefined, this.items.length - 1);\n\n // this.tmpItems[index] = undefined;\n this.deletedIndexes[index] = true;\n\n return this.items.pop();\n }\n\n at(index: number) {\n // Allow negative indexing from the end\n if (index < 0) index += this.length;\n return this.items[index];\n }\n\n // encoding only\n protected $changeAt(index: number, value: V) {\n if (value === undefined || value === null) {\n console.error(\"ArraySchema items cannot be null nor undefined; Use `deleteAt(index)` instead.\");\n return;\n }\n\n // skip if the value is the same as cached.\n if (this.items[index] === value) {\n return;\n }\n\n const changeTree = this[$changes];\n const operation = changeTree.indexes?.[index]?.op ?? OPERATION.ADD;\n\n changeTree.change(index, operation);\n\n //\n // set value's parent after the value is set\n // (to avoid encoding \"refId\" operations before parent's \"ADD\" operation)\n //\n value[$changes]?.setParent(this, changeTree.root, index);\n }\n\n // encoding only\n protected $deleteAt(index: number, operation?: OPERATION) {\n this[$changes].delete(index, operation);\n }\n\n // decoding only\n protected $setAt(index: number, value: V, operation: OPERATION) {\n if (\n index === 0 &&\n operation === OPERATION.ADD &&\n this.items[index] !== undefined\n ) {\n // handle decoding unshift\n this.items.unshift(value);\n\n } else if (operation === OPERATION.DELETE_AND_MOVE) {\n this.items.splice(index, 1);\n this.items[index] = value;\n\n } else {\n this.items[index] = value;\n }\n }\n\n clear() {\n // skip if already clear\n if (this.items.length === 0) { return; }\n\n // discard previous operations.\n const changeTree = this[$changes]\n\n // discard children\n changeTree.forEachChild((changeTree, _) => {\n changeTree.discard(true);\n\n //\n // TODO: add tests with instance sharing + .clear()\n // FIXME: this.root? is required because it is being called at decoding time.\n //\n // TODO: do not use [$changes] at decoding time.\n //\n changeTree.root?.changes.delete(changeTree);\n changeTree.root?.allChanges.delete(changeTree);\n changeTree.root?.allFilteredChanges.delete(changeTree);\n });\n\n changeTree.discard(true);\n changeTree.operation(OPERATION.CLEAR);\n\n this.items.length = 0;\n this.tmpItems.length = 0;\n }\n\n /**\n * Combines two or more arrays.\n * @param items Additional items to add to the end of array1.\n */\n // @ts-ignore\n concat(...items: (V | ConcatArray<V>)[]): ArraySchema<V> {\n return new ArraySchema(...this.items.concat(...items));\n }\n\n /**\n * Adds all the elements of an array separated by the specified separator string.\n * @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma.\n */\n join(separator?: string): string {\n return this.items.join(separator);\n }\n\n /**\n * Reverses the elements in an Array.\n */\n // @ts-ignore\n reverse(): ArraySchema<V> {\n this[$changes].operation(OPERATION.REVERSE);\n this.items.reverse();\n this.tmpItems.reverse();\n return this;\n }\n\n /**\n * Removes the first element from an array and returns it.\n */\n shift(): V | undefined {\n if (this.items.length === 0) { return undefined; }\n\n // const index = Number(Object.keys(changeTree.indexes)[0]);\n const index = this.tmpItems.findIndex((item, i) => item === this.items[0]);\n const changeTree = this[$changes];\n\n changeTree.delete(index);\n changeTree.shiftAllChangeIndexes(-1, index);\n\n return this.items.shift();\n }\n\n /**\n * Returns a section of an array.\n * @param start The beginning of the specified portion of the array.\n * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'.\n */\n slice(start?: number, end?: number): V[] {\n const sliced = new ArraySchema<V>();\n sliced.push(...this.items.slice(start, end));\n return sliced as unknown as V[];\n }\n\n /**\n * Sorts an array.\n * @param compareFn Function used to determine the order of the elements. It is expected to return\n * a negative value if first argument is less than second argument, zero if they're equal and a positive\n * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order.\n * ```ts\n * [11,2,22,1].sort((a, b) => a - b)\n * ```\n */\n sort(compareFn: (a: V, b: V) => number = DEFAULT_SORT): this {\n const changeTree = this[$changes];\n const sortedItems = this.items.sort(compareFn);\n\n // wouldn't OPERATION.MOVE make more sense here?\n sortedItems.forEach((_, i) => changeTree.change(i, OPERATION.REPLACE));\n\n this.tmpItems.sort(compareFn);\n return this;\n }\n\n /**\n * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements.\n * @param start The zero-based location in the array from which to start removing elements.\n * @param deleteCount The number of elements to remove.\n * @param insertItems Elements to insert into the array in place of the deleted elements.\n */\n splice(\n start: number,\n deleteCount: number = this.items.length - start,\n ...insertItems: V[]\n ): V[] {\n const changeTree = this[$changes];\n\n const tmpItemsLength = this.tmpItems.length;\n const insertCount = insertItems.length;\n\n // build up-to-date list of indexes, excluding removed values.\n const indexes: number[] = [];\n for (let i = 0; i < tmpItemsLength; i++) {\n // if (this.tmpItems[i] !== undefined) {\n if (this.deletedIndexes[i] !== true) {\n indexes.push(i);\n }\n }\n\n // delete operations at correct index\n for (let i = start; i < start + deleteCount; i++) {\n const index = indexes[i];\n changeTree.delete(index);\n // this.tmpItems[index] = undefined;\n this.deletedIndexes[index] = true;\n }\n\n // force insert operations\n for (let i = 0; i < insertCount; i++) {\n const addIndex = indexes[start] + i;\n changeTree.indexedOperation(addIndex, OPERATION.ADD);\n\n // set value's parent/root\n insertItems[i][$changes]?.setParent(this, changeTree.root, addIndex);\n }\n\n //\n // delete exceeding indexes from \"allChanges\"\n // (prevent .encodeAll() from encoding non-existing items)\n //\n if (deleteCount > insertCount) {\n changeTree.shiftAllChangeIndexes(-(deleteCount - insertCount), indexes[start + insertCount]);\n }\n\n return this.items.splice(start, deleteCount, ...insertItems);\n }\n\n /**\n * Inserts new elements at the start of an array.\n * @param items Elements to insert at the start of the Array.\n */\n unshift(...items: V[]): number {\n const changeTree = this[$changes];\n\n // shift indexes\n changeTree.shiftChangeIndexes(items.length);\n\n // new index\n if (changeTree.isFiltered) {\n changeTree.filteredChanges.set(this.items.length, OPERATION.ADD);\n } else {\n changeTree.allChanges.set(this.items.length, OPERATION.ADD);\n }\n\n // FIXME: should we use OPERATION.MOVE here instead?\n items.forEach((_, index) => {\n changeTree.change(index, OPERATION.ADD)\n });\n\n this.tmpItems.unshift(...items);\n\n return this.items.unshift(...items);\n }\n\n /**\n * Returns the index of the first occurrence of a value in an array.\n * @param searchElement The value to locate in the array.\n * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0.\n */\n indexOf(searchElement: V, fromIndex?: number): number {\n return this.items.indexOf(searchElement, fromIndex);\n }\n\n /**\n * Returns the index of the last occurrence of a specified value in an array.\n * @param searchElement The value to locate in the array.\n * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the array.\n */\n lastIndexOf(searchElement: V, fromIndex: number = this.length - 1): number {\n return this.items.lastIndexOf(searchElement, fromIndex);\n }\n\n /**\n * Determines whether all the members of an array satisfy the specified test.\n * @param callbackfn A function that accepts up to three arguments. The every method calls\n * the callbackfn function for each element in the array until the callbackfn returns a value\n * which is coercible to the Boolean value false, or until the end of the array.\n * @param thisArg An object to which the this keyword can refer in the callbackfn function.\n * If thisArg is omitted, undefined is used as the this value.\n */\n every(callbackfn: (value: V, index: number, array: V[]) => unknown, thisArg?: any): boolean {\n return this.items.every(callbackfn, thisArg);\n }\n\n /**\n * Determines whether the specified callback function returns true for any element of an array.\n * @param callbackfn A function that accepts up to three arguments. The some method calls\n * the callbackfn function for each element in the array until the callbackfn returns a value\n * which is coercible to the Boolean value true, or until the end of the array.\n * @param thisArg An object to which the this keyword can refer in the callbackfn function.\n * If thisArg is omitted, undefined is used as the this value.\n */\n some(callbackfn: (value: V, index: number, array: V[]) => unknown, thisArg?: any): boolean {\n return this.items.some(callbackfn, thisArg);\n }\n\n /**\n * Performs the specified action for each element in an array.\n * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array.\n * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.\n */\n forEach(callbackfn: (value: V, index: number, array: V[]) => void, thisArg?: any): void {\n return this.items.forEach(callbackfn, thisArg);\n }\n\n /**\n * Calls a defined callback function on each element of an array, and returns an array that contains the results.\n * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.\n * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.\n */\n map<U>(callbackfn: (value: V, index: number, array: V[]) => U, thisArg?: any): U[] {\n return this.items.map(callbackfn, thisArg);\n }\n\n /**\n * Returns the elements of an array that meet the condition specified in a callback function.\n * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array.\n * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.\n */\n filter(callbackfn: (value: V, index: number, array: V[]) => unknown, thisArg?: any): V[]\n filter<S extends V>(callbackfn: (value: V, index: number, array: V[]) => value is S, thisArg?: any): V[] {\n return this.items.filter(callbackfn, thisArg);\n }\n\n /**\n * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.\n * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array.\n * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.\n */\n reduce<U=V>(callbackfn: (previousValue: U, currentValue: V, currentIndex: number, array: V[]) => U, initialValue?: U): U {\n return this.items.reduce(callbackfn, initialValue);\n }\n\n /**\n * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.\n * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array.\n * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.\n */\n reduceRight<U=V>(callbackfn: (previousValue: U, currentValue: V, currentIndex: number, array: V[]) => U, initialValue?: U): U {\n return this.items.reduceRight(callbackfn, initialValue);\n }\n\n /**\n * Returns the value of the first element in the array where predicate is true, and undefined\n * otherwise.\n * @param predicate find calls predicate once for each element of the array, in ascending\n * order, until it finds one where predicate returns true. If such an element is found, find\n * immediately returns that element value. Otherwise, find returns undefined.\n * @param thisArg If provided, it will be used as the this value for each invocation of\n * predicate. If it is not provided, undefined is used instead.\n */\n find(predicate: (value: V, index: number, obj: V[]) => boolean, thisArg?: any): V | undefined {\n return this.items.find(predicate, thisArg);\n }\n\n /**\n * Returns the index of the first element in the array where predicate is true, and -1\n * otherwise.\n * @param predicate find calls predicate once for each element of the array, in ascending\n * order, until it finds one where predicate returns true. If such an element is found,\n * findIndex immediately returns that element index. Otherwise, findIndex returns -1.\n * @param thisArg If provided, it will be used as the this value for each invocation of\n * predicate. If it is not provided, undefined is used instead.\n */\n findIndex(predicate: (value: V, index: number, obj: V[]) => unknown, thisArg?: any): number {\n return this.items.findIndex(predicate, thisArg);\n }\n\n /**\n * Returns the this object after filling the section identified by start and end with value\n * @param value value to fill array section with\n * @param start index to start filling the array at. If start is negative, it is treated as\n * length+start where length is the length of the array.\n * @param end index to stop filling the array at. If end is negative, it is treated as\n * length+end.\n */\n fill(value: V, start?: number, end?: number): this {\n //\n // TODO\n //\n throw new Error(\"ArraySchema#fill() not implemented\");\n // this.$items.fill(value, start, end);\n\n return this;\n }\n\n /**\n * Returns the this object after copying a section of the array identified by start and end\n * to the same array starting at position target\n * @param target If target is negative, it is treated as length+target where length is the\n * length of the array.\n * @param start If start is negative, it is treated as length+start. If end is negative, it\n * is treated as length+end.\n * @param end If not specified, length of the this object is used as its default value.\n */\n copyWithin(target: number, start: number, end?: number): this {\n //\n // TODO\n //\n throw new Error(\"ArraySchema#copyWithin() not implemented\");\n return this;\n }\n\n /**\n * Returns a string representation of an array.\n */\n toString(): string {\n return this.items.toString();\n }\n\n /**\n * Returns a string representation of an array. The elements are converted to string using their toLocalString methods.\n */\n toLocaleString(): string {\n return this.items.toLocaleString()\n };\n\n /** Iterator */\n [Symbol.iterator](): IterableIterator<V> {\n return this.items[Symbol.iterator]();\n }\n\n static get [Symbol.species]() {\n return ArraySchema;\n }\n\n // WORKAROUND for compatibility\n // - TypeScript 4 defines @@unscopables as a function\n // - TypeScript 5 defines @@unscopables as an object\n [Symbol.unscopables]: any;\n\n /**\n * Returns an iterable of key, value pairs for every entry in the array\n */\n entries(): IterableIterator<[number, V]> { return this.items.entries(); }\n\n /**\n * Returns an iterable of keys in the array\n */\n keys(): IterableIterator<number> { return this.items.keys(); }\n\n /**\n * Returns an iterable of values in the array\n */\n values(): IterableIterator<V> { return this.items.values(); }\n\n /**\n * Determines whether an array includes a certain element, returning true or false as appropriate.\n * @param searchElement The element to search for.\n * @param fromIndex The position in this array at which to begin searching for searchElement.\n */\n includes(searchElement: V, fromIndex?: number): boolean {\n return this.items.includes(searchElement, fromIndex);\n }\n\n //\n // ES2022\n //\n\n /**\n * Calls a defined callback function on each element of an array. Then, flattens the result into\n * a new array.\n * This is identical to a map followed by flat with depth 1.\n *\n * @param callback A function that accepts up to three arguments. The flatMap method calls the\n * callback function one time for each element in the array.\n * @param thisArg An object to which the this keyword can refer in the callback function. If\n * thisArg is omitted, undefined is used as the this value.\n */\n // @ts-ignore\n flatMap<U, This = undefined>(callback: (this: This, value: V, index: number, array: V[]) => U | ReadonlyArray<U>, thisArg?: This): U[] {\n // @ts-ignore\n throw new Error(\"ArraySchema#flatMap() is not supported.\");\n }\n\n /**\n * Returns a new array with all sub-array elements concatenated into it recursively up to the\n * specified depth.\n *\n * @param depth The maximum recursion depth\n */\n // @ts-ignore\n flat<A, D extends number = 1>(this: A, depth?: D): any {\n throw new Error(\"ArraySchema#flat() is not supported.\");\n }\n\n findLast() {\n // @ts-ignore\n return this.items.findLast.apply(this.items, arguments);\n }\n\n findLastIndex(...args) {\n // @ts-ignore\n return this.items.findLastIndex.apply(this.items, arguments);\n }\n\n //\n // ES2023\n //\n with(index: number, value: V): V[] {\n const copy = this.items.slice();\n copy[index] = value;\n return new ArraySchema(...copy);\n }\n toReversed(): V[] {\n return this.items.slice().reverse();\n }\n toSorted(compareFn?: (a: V, b: V) => number): V[] {\n return this.items.slice().sort(compareFn);\n }\n toSpliced(start: number, deleteCount: number, ...items: V[]): V[];\n toSpliced(start: number, deleteCount?: number): V[];\n // @ts-ignore\n toSpliced(start: unknown, deleteCount?: unknown, ...items?: unknown[]): V[] {\n // @ts-ignore\n return this.items.toSpliced.apply(copy, arguments);\n }\n\n protected [$getByIndex](index: number, isEncodeAll: boolean = false) {\n //\n // TODO: avoid unecessary `this.tmpItems` check during decoding.\n //\n // ENCODING uses `this.tmpItems` (or `this.items` if `isEncodeAll` is true)\n // DECODING uses `this.items`\n //\n\n return (isEncodeAll)\n ? this.items[index]\n : this.deletedIndexes[index]\n ? this.items[index]\n : this.tmpItems[index] || this.items[index];\n\n // return (isEncodeAll)\n // ? this.items[index]\n // : this.tmpItems[index] ?? this.items[index];\n }\n\n protected [$deleteByIndex](index: number) {\n this.items[index] = undefined;\n }\n\n protected [$onEncodeEnd]() {\n this.tmpItems = this.items.slice();\n this.deletedIndexes = {};\n }\n\n protected [$onDecodeEnd]() {\n this.items = this.items.filter((item) => item !== undefined);\n }\n\n toArray() {\n return this.items.slice(0);\n }\n\n toJSON() {\n return this.toArray().map((value) => {\n return (typeof (value['toJSON']) === \"function\")\n ? value['toJSON']()\n : value;\n });\n }\n\n //\n // Decoding utilities\n //\n clone(isDecoding?: boolean): ArraySchema<V> {\n let cloned: ArraySchema;\n\n if (isDecoding) {\n cloned = new ArraySchema();\n cloned.push(...this.items);\n\n } else {\n cloned = new ArraySchema(...this.map(item => (\n (item[$changes])\n ? (item as any as Schema).clone()\n : item\n )));\n }\n\n return cloned;\n };\n\n}\n\nregisterType(\"array\", { constructor: ArraySchema });"]}
1
+ {"version":3,"file":"ArraySchema.js","sourceRoot":"","sources":["../../../src/types/custom/ArraySchema.ts"],"names":[],"mappings":";;;;AAAA,wCAAgJ;AAEhJ,yDAAsD;AACtD,8CAAgD;AAChD,0CAA2C;AAG3C,mEAA4D;AAC5D,mEAA4D;AAG5D,MAAM,YAAY,GAAG,CAAC,CAAM,EAAE,CAAM,EAAE,EAAE;IACpC,MAAM,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC;IACvB,MAAM,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC;IACvB,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,CAAC,CAAC,CAAC;SAChB,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,CAAC,CAAC;;Q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,CAAC;;AApvBN,kCAsvBC;AAED,IAAA,uBAAY,EAAC,OAAO,EAAE,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC,CAAC","sourcesContent":["import { $changes, $childType, $decoder, $deleteByIndex, $onEncodeEnd, $encoder, $filter, $getByIndex, $onDecodeEnd, $isNew } from \"../symbols\";\nimport type { Schema } from \"../../Schema\";\nimport { ChangeTree } from \"../../encoder/ChangeTree\";\nimport { OPERATION } from \"../../encoding/spec\";\nimport { registerType } from \"../registry\";\nimport { Collection } from \"../HelperTypes\";\n\nimport { encodeArray } from \"../../encoder/EncodeOperation\";\nimport { decodeArray } from \"../../decoder/DecodeOperation\";\nimport type { StateView } from \"../../encoder/StateView\";\n\nconst DEFAULT_SORT = (a: any, b: any) => {\n const A = a.toString();\n const B = b.toString();\n if (A < B) return -1;\n else if (A > B) return 1;\n else return 0\n}\n\nexport class ArraySchema<V = any> implements Array<V>, Collection<number, V> {\n [n: number]: V;\n\n protected items: V[] = [];\n protected tmpItems: V[] = [];\n protected deletedIndexes: {[index: number]: boolean} = {};\n\n static [$encoder] = encodeArray;\n static [$decoder] = decodeArray;\n\n /**\n * Determine if a property must be filtered.\n * - If returns false, the property is NOT going to be encoded.\n * - If returns true, the property is going to be encoded.\n *\n * Encoding with \"filters\" happens in two steps:\n * - First, the encoder iterates over all \"not owned\" properties and encodes them.\n * - Then, the encoder iterates over all \"owned\" properties per instance and encodes them.\n */\n static [$filter] (ref: ArraySchema, index: number, view: StateView) {\n // console.log(\"ArraSchema[$filter] VIEW??\", !view)\n return (\n !view ||\n typeof (ref[$childType]) === \"string\" ||\n // view.items.has(ref[$getByIndex](index)[$changes])\n view.items.has(ref['tmpItems'][index]?.[$changes])\n );\n }\n\n static is(type: any) {\n return (\n // type format: [\"string\"]\n Array.isArray(type) ||\n\n // type format: { array: \"string\" }\n (type['array'] !== undefined)\n );\n }\n\n constructor (...items: V[]) {\n\n Object.defineProperty(this, $childType, {\n value: undefined,\n enumerable: false,\n writable: true,\n configurable: true,\n });\n\n const proxy = new Proxy(this, {\n get: (obj, prop) => {\n if (\n typeof (prop) !== \"symbol\" &&\n !isNaN(prop as any) // https://stackoverflow.com/a/175787/892698\n ) {\n return this.items[prop];\n\n } else {\n return Reflect.get(obj, prop);\n }\n },\n\n set: (obj, key, setValue) => {\n if (typeof (key) !== \"symbol\" && !isNaN(key as any)) {\n if (setValue === undefined || setValue === null) {\n obj.$deleteAt(key as unknown as number);\n\n } else {\n if (setValue[$changes]) {\n if (obj.items[key as unknown as number] !== undefined) {\n if (setValue[$changes][$isNew]) {\n this[$changes].indexedOperation(Number(key), OPERATION.MOVE_AND_ADD);\n\n } else {\n if ((obj[$changes].getChange(Number(key)) & OPERATION.DELETE) === OPERATION.DELETE) {\n this[$changes].indexedOperation(Number(key), OPERATION.DELETE_AND_MOVE);\n } else {\n this[$changes].indexedOperation(Number(key), OPERATION.MOVE);\n }\n }\n } else if (setValue[$changes][$isNew]) {\n this[$changes].indexedOperation(Number(key), OPERATION.ADD);\n }\n } else {\n obj.$changeAt(Number(key), setValue);\n }\n\n this.items[key as unknown as number] = setValue;\n this.tmpItems[key as unknown as number] = setValue;\n }\n\n return true;\n } else {\n return Reflect.set(obj, key, setValue);\n }\n },\n\n deleteProperty: (obj, prop) => {\n if (typeof (prop) === \"number\") {\n obj.$deleteAt(prop);\n\n } else {\n delete obj[prop];\n }\n\n return true;\n },\n\n has: (obj, key) => {\n if (typeof (key) !== \"symbol\" && !isNaN(Number(key))) {\n return Reflect.has(this.items, key);\n }\n return Reflect.has(obj, key)\n }\n });\n\n this[$changes] = new ChangeTree(proxy);\n this.push.apply(this, items);\n\n return proxy;\n }\n\n set length (newLength: number) {\n if (newLength === 0) {\n this.clear();\n } else if (newLength < this.items.length) {\n this.splice(newLength, this.length - newLength);\n } else {\n console.warn(\"ArraySchema: can't set .length to a higher value than its length.\");\n }\n }\n\n get length() {\n return this.items.length;\n }\n\n push(...values: V[]) {\n let length = this.tmpItems.length;\n\n values.forEach((value, i) => {\n // skip null values\n if (value === undefined || value === null) {\n return;\n }\n\n const changeTree = this[$changes];\n changeTree.indexedOperation(length, OPERATION.ADD, this.items.length);\n // changeTree.indexes[length] = length;\n\n this.items.push(value);\n this.tmpItems.push(value);\n\n //\n // set value's parent after the value is set\n // (to avoid encoding \"refId\" operations before parent's \"ADD\" operation)\n //\n value[$changes]?.setParent(this, changeTree.root, length);\n\n length++;\n });\n\n return length;\n }\n\n /**\n * Removes the last element from an array and returns it.\n */\n pop(): V | undefined {\n let index: number = -1;\n\n // find last non-undefined index\n for (let i = this.tmpItems.length - 1; i >= 0; i--) {\n // if (this.tmpItems[i] !== undefined) {\n if (this.deletedIndexes[i] !== true) {\n index = i;\n break;\n }\n }\n\n if (index < 0) {\n return undefined;\n }\n\n this[$changes].delete(index, undefined, this.items.length - 1);\n\n // this.tmpItems[index] = undefined;\n this.deletedIndexes[index] = true;\n\n return this.items.pop();\n }\n\n at(index: number) {\n // Allow negative indexing from the end\n if (index < 0) index += this.length;\n return this.items[index];\n }\n\n // encoding only\n protected $changeAt(index: number, value: V) {\n if (value === undefined || value === null) {\n console.error(\"ArraySchema items cannot be null nor undefined; Use `deleteAt(index)` instead.\");\n return;\n }\n\n // skip if the value is the same as cached.\n if (this.items[index] === value) {\n return;\n }\n\n const changeTree = this[$changes];\n const operation = changeTree.indexes?.[index]?.op ?? OPERATION.ADD;\n\n changeTree.change(index, operation);\n\n //\n // set value's parent after the value is set\n // (to avoid encoding \"refId\" operations before parent's \"ADD\" operation)\n //\n value[$changes]?.setParent(this, changeTree.root, index);\n }\n\n // encoding only\n protected $deleteAt(index: number, operation?: OPERATION) {\n this[$changes].delete(index, operation);\n }\n\n // decoding only\n protected $setAt(index: number, value: V, operation: OPERATION) {\n if (\n index === 0 &&\n operation === OPERATION.ADD &&\n this.items[index] !== undefined\n ) {\n // handle decoding unshift\n this.items.unshift(value);\n\n } else if (operation === OPERATION.DELETE_AND_MOVE) {\n this.items.splice(index, 1);\n this.items[index] = value;\n\n } else {\n this.items[index] = value;\n }\n }\n\n clear() {\n // skip if already clear\n if (this.items.length === 0) { return; }\n\n // discard previous operations.\n const changeTree = this[$changes]\n\n // discard children\n changeTree.forEachChild((changeTree, _) => {\n changeTree.discard(true);\n\n //\n // TODO: add tests with instance sharing + .clear()\n // FIXME: this.root? is required because it is being called at decoding time.\n //\n // TODO: do not use [$changes] at decoding time.\n //\n changeTree.root?.changes.delete(changeTree);\n changeTree.root?.allChanges.delete(changeTree);\n changeTree.root?.allFilteredChanges.delete(changeTree);\n });\n\n changeTree.discard(true);\n changeTree.operation(OPERATION.CLEAR);\n\n this.items.length = 0;\n this.tmpItems.length = 0;\n }\n\n /**\n * Combines two or more arrays.\n * @param items Additional items to add to the end of array1.\n */\n // @ts-ignore\n concat(...items: (V | ConcatArray<V>)[]): ArraySchema<V> {\n return new ArraySchema(...this.items.concat(...items));\n }\n\n /**\n * Adds all the elements of an array separated by the specified separator string.\n * @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma.\n */\n join(separator?: string): string {\n return this.items.join(separator);\n }\n\n /**\n * Reverses the elements in an Array.\n */\n // @ts-ignore\n reverse(): ArraySchema<V> {\n this[$changes].operation(OPERATION.REVERSE);\n this.items.reverse();\n this.tmpItems.reverse();\n return this;\n }\n\n /**\n * Removes the first element from an array and returns it.\n */\n shift(): V | undefined {\n if (this.items.length === 0) { return undefined; }\n\n // const index = Number(Object.keys(changeTree.indexes)[0]);\n const index = this.tmpItems.findIndex((item, i) => item === this.items[0]);\n const changeTree = this[$changes];\n\n changeTree.delete(index);\n changeTree.shiftAllChangeIndexes(-1, index);\n\n return this.items.shift();\n }\n\n /**\n * Returns a section of an array.\n * @param start The beginning of the specified portion of the array.\n * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'.\n */\n slice(start?: number, end?: number): V[] {\n const sliced = new ArraySchema<V>();\n sliced.push(...this.items.slice(start, end));\n return sliced as unknown as V[];\n }\n\n /**\n * Sorts an array.\n * @param compareFn Function used to determine the order of the elements. It is expected to return\n * a negative value if first argument is less than second argument, zero if they're equal and a positive\n * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order.\n * ```ts\n * [11,2,22,1].sort((a, b) => a - b)\n * ```\n */\n sort(compareFn: (a: V, b: V) => number = DEFAULT_SORT): this {\n const changeTree = this[$changes];\n const sortedItems = this.items.sort(compareFn);\n\n // wouldn't OPERATION.MOVE make more sense here?\n sortedItems.forEach((_, i) => changeTree.change(i, OPERATION.REPLACE));\n\n this.tmpItems.sort(compareFn);\n return this;\n }\n\n /**\n * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements.\n * @param start The zero-based location in the array from which to start removing elements.\n * @param deleteCount The number of elements to remove.\n * @param insertItems Elements to insert into the array in place of the deleted elements.\n */\n splice(\n start: number,\n deleteCount: number = this.items.length - start,\n ...insertItems: V[]\n ): V[] {\n const changeTree = this[$changes];\n\n const tmpItemsLength = this.tmpItems.length;\n const insertCount = insertItems.length;\n\n // build up-to-date list of indexes, excluding removed values.\n const indexes: number[] = [];\n for (let i = 0; i < tmpItemsLength; i++) {\n // if (this.tmpItems[i] !== undefined) {\n if (this.deletedIndexes[i] !== true) {\n indexes.push(i);\n }\n }\n\n // delete operations at correct index\n for (let i = start; i < start + deleteCount; i++) {\n const index = indexes[i];\n changeTree.delete(index);\n // this.tmpItems[index] = undefined;\n this.deletedIndexes[index] = true;\n }\n\n // force insert operations\n for (let i = 0; i < insertCount; i++) {\n const addIndex = indexes[start] + i;\n changeTree.indexedOperation(addIndex, OPERATION.ADD);\n\n // set value's parent/root\n insertItems[i][$changes]?.setParent(this, changeTree.root, addIndex);\n }\n\n //\n // delete exceeding indexes from \"allChanges\"\n // (prevent .encodeAll() from encoding non-existing items)\n //\n if (deleteCount > insertCount) {\n changeTree.shiftAllChangeIndexes(-(deleteCount - insertCount), indexes[start + insertCount]);\n }\n\n return this.items.splice(start, deleteCount, ...insertItems);\n }\n\n /**\n * Inserts new elements at the start of an array.\n * @param items Elements to insert at the start of the Array.\n */\n unshift(...items: V[]): number {\n const changeTree = this[$changes];\n\n // shift indexes\n changeTree.shiftChangeIndexes(items.length);\n\n // new index\n if (changeTree.isFiltered) {\n changeTree.filteredChanges.set(this.items.length, OPERATION.ADD);\n } else {\n changeTree.allChanges.set(this.items.length, OPERATION.ADD);\n }\n\n // FIXME: should we use OPERATION.MOVE here instead?\n items.forEach((_, index) => {\n changeTree.change(index, OPERATION.ADD)\n });\n\n this.tmpItems.unshift(...items);\n\n return this.items.unshift(...items);\n }\n\n /**\n * Returns the index of the first occurrence of a value in an array.\n * @param searchElement The value to locate in the array.\n * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0.\n */\n indexOf(searchElement: V, fromIndex?: number): number {\n return this.items.indexOf(searchElement, fromIndex);\n }\n\n /**\n * Returns the index of the last occurrence of a specified value in an array.\n * @param searchElement The value to locate in the array.\n * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the array.\n */\n lastIndexOf(searchElement: V, fromIndex: number = this.length - 1): number {\n return this.items.lastIndexOf(searchElement, fromIndex);\n }\n\n /**\n * Determines whether all the members of an array satisfy the specified test.\n * @param callbackfn A function that accepts up to three arguments. The every method calls\n * the callbackfn function for each element in the array until the callbackfn returns a value\n * which is coercible to the Boolean value false, or until the end of the array.\n * @param thisArg An object to which the this keyword can refer in the callbackfn function.\n * If thisArg is omitted, undefined is used as the this value.\n */\n every<S extends V>(predicate: (value: V, index: number, array: V[]) => value is S, thisArg?: any): this is S[];\n every(callbackfn: (value: V, index: number, array: V[]) => unknown, thisArg?: any): boolean {\n return this.items.every(callbackfn, thisArg);\n }\n\n /**\n * Determines whether the specified callback function returns true for any element of an array.\n * @param callbackfn A function that accepts up to three arguments. The some method calls\n * the callbackfn function for each element in the array until the callbackfn returns a value\n * which is coercible to the Boolean value true, or until the end of the array.\n * @param thisArg An object to which the this keyword can refer in the callbackfn function.\n * If thisArg is omitted, undefined is used as the this value.\n */\n some(callbackfn: (value: V, index: number, array: V[]) => unknown, thisArg?: any): boolean {\n return this.items.some(callbackfn, thisArg);\n }\n\n /**\n * Performs the specified action for each element in an array.\n * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array.\n * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.\n */\n forEach(callbackfn: (value: V, index: number, array: V[]) => void, thisArg?: any): void {\n return this.items.forEach(callbackfn, thisArg);\n }\n\n /**\n * Calls a defined callback function on each element of an array, and returns an array that contains the results.\n * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.\n * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.\n */\n map<U>(callbackfn: (value: V, index: number, array: V[]) => U, thisArg?: any): U[] {\n return this.items.map(callbackfn, thisArg);\n }\n\n /**\n * Returns the elements of an array that meet the condition specified in a callback function.\n * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array.\n * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.\n */\n filter(callbackfn: (value: V, index: number, array: V[]) => unknown, thisArg?: any): V[]\n filter<S extends V>(callbackfn: (value: V, index: number, array: V[]) => value is S, thisArg?: any): V[] {\n return this.items.filter(callbackfn, thisArg);\n }\n\n /**\n * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.\n * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array.\n * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.\n */\n reduce<U=V>(callbackfn: (previousValue: U, currentValue: V, currentIndex: number, array: V[]) => U, initialValue?: U): U {\n return this.items.reduce(callbackfn, initialValue);\n }\n\n /**\n * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.\n * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array.\n * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.\n */\n reduceRight<U=V>(callbackfn: (previousValue: U, currentValue: V, currentIndex: number, array: V[]) => U, initialValue?: U): U {\n return this.items.reduceRight(callbackfn, initialValue);\n }\n\n /**\n * Returns the value of the first element in the array where predicate is true, and undefined\n * otherwise.\n * @param predicate find calls predicate once for each element of the array, in ascending\n * order, until it finds one where predicate returns true. If such an element is found, find\n * immediately returns that element value. Otherwise, find returns undefined.\n * @param thisArg If provided, it will be used as the this value for each invocation of\n * predicate. If it is not provided, undefined is used instead.\n */\n find(predicate: (value: V, index: number, obj: V[]) => boolean, thisArg?: any): V | undefined {\n return this.items.find(predicate, thisArg);\n }\n\n /**\n * Returns the index of the first element in the array where predicate is true, and -1\n * otherwise.\n * @param predicate find calls predicate once for each element of the array, in ascending\n * order, until it finds one where predicate returns true. If such an element is found,\n * findIndex immediately returns that element index. Otherwise, findIndex returns -1.\n * @param thisArg If provided, it will be used as the this value for each invocation of\n * predicate. If it is not provided, undefined is used instead.\n */\n findIndex(predicate: (value: V, index: number, obj: V[]) => unknown, thisArg?: any): number {\n return this.items.findIndex(predicate, thisArg);\n }\n\n /**\n * Returns the this object after filling the section identified by start and end with value\n * @param value value to fill array section with\n * @param start index to start filling the array at. If start is negative, it is treated as\n * length+start where length is the length of the array.\n * @param end index to stop filling the array at. If end is negative, it is treated as\n * length+end.\n */\n fill(value: V, start?: number, end?: number): this {\n //\n // TODO\n //\n throw new Error(\"ArraySchema#fill() not implemented\");\n // this.$items.fill(value, start, end);\n\n return this;\n }\n\n /**\n * Returns the this object after copying a section of the array identified by start and end\n * to the same array starting at position target\n * @param target If target is negative, it is treated as length+target where length is the\n * length of the array.\n * @param start If start is negative, it is treated as length+start. If end is negative, it\n * is treated as length+end.\n * @param end If not specified, length of the this object is used as its default value.\n */\n copyWithin(target: number, start: number, end?: number): this {\n //\n // TODO\n //\n throw new Error(\"ArraySchema#copyWithin() not implemented\");\n return this;\n }\n\n /**\n * Returns a string representation of an array.\n */\n toString(): string {\n return this.items.toString();\n }\n\n /**\n * Returns a string representation of an array. The elements are converted to string using their toLocalString methods.\n */\n toLocaleString(): string {\n return this.items.toLocaleString()\n };\n\n /** Iterator */\n [Symbol.iterator](): IterableIterator<V> {\n return this.items[Symbol.iterator]();\n }\n\n static get [Symbol.species]() {\n return ArraySchema;\n }\n\n // WORKAROUND for compatibility\n // - TypeScript 4 defines @@unscopables as a function\n // - TypeScript 5 defines @@unscopables as an object\n [Symbol.unscopables]: any;\n\n /**\n * Returns an iterable of key, value pairs for every entry in the array\n */\n entries(): IterableIterator<[number, V]> { return this.items.entries(); }\n\n /**\n * Returns an iterable of keys in the array\n */\n keys(): IterableIterator<number> { return this.items.keys(); }\n\n /**\n * Returns an iterable of values in the array\n */\n values(): IterableIterator<V> { return this.items.values(); }\n\n /**\n * Determines whether an array includes a certain element, returning true or false as appropriate.\n * @param searchElement The element to search for.\n * @param fromIndex The position in this array at which to begin searching for searchElement.\n */\n includes(searchElement: V, fromIndex?: number): boolean {\n return this.items.includes(searchElement, fromIndex);\n }\n\n //\n // ES2022\n //\n\n /**\n * Calls a defined callback function on each element of an array. Then, flattens the result into\n * a new array.\n * This is identical to a map followed by flat with depth 1.\n *\n * @param callback A function that accepts up to three arguments. The flatMap method calls the\n * callback function one time for each element in the array.\n * @param thisArg An object to which the this keyword can refer in the callback function. If\n * thisArg is omitted, undefined is used as the this value.\n */\n // @ts-ignore\n flatMap<U, This = undefined>(callback: (this: This, value: V, index: number, array: V[]) => U | ReadonlyArray<U>, thisArg?: This): U[] {\n // @ts-ignore\n throw new Error(\"ArraySchema#flatMap() is not supported.\");\n }\n\n /**\n * Returns a new array with all sub-array elements concatenated into it recursively up to the\n * specified depth.\n *\n * @param depth The maximum recursion depth\n */\n // @ts-ignore\n flat<A, D extends number = 1>(this: A, depth?: D): any {\n throw new Error(\"ArraySchema#flat() is not supported.\");\n }\n\n findLast() {\n // @ts-ignore\n return this.items.findLast.apply(this.items, arguments);\n }\n\n findLastIndex(...args) {\n // @ts-ignore\n return this.items.findLastIndex.apply(this.items, arguments);\n }\n\n //\n // ES2023\n //\n with(index: number, value: V): ArraySchema<V> {\n const copy = this.items.slice();\n copy[index] = value;\n return new ArraySchema(...copy);\n }\n toReversed(): V[] {\n return this.items.slice().reverse();\n }\n toSorted(compareFn?: (a: V, b: V) => number): V[] {\n return this.items.slice().sort(compareFn);\n }\n toSpliced(start: number, deleteCount: number, ...items: V[]): V[];\n toSpliced(start: number, deleteCount?: number): V[];\n // @ts-ignore\n toSpliced(start: unknown, deleteCount?: unknown, ...items?: unknown[]): V[] {\n // @ts-ignore\n return this.items.toSpliced.apply(copy, arguments);\n }\n\n protected [$getByIndex](index: number, isEncodeAll: boolean = false) {\n //\n // TODO: avoid unecessary `this.tmpItems` check during decoding.\n //\n // ENCODING uses `this.tmpItems` (or `this.items` if `isEncodeAll` is true)\n // DECODING uses `this.items`\n //\n\n return (isEncodeAll)\n ? this.items[index]\n : this.deletedIndexes[index]\n ? this.items[index]\n : this.tmpItems[index] || this.items[index];\n\n // return (isEncodeAll)\n // ? this.items[index]\n // : this.tmpItems[index] ?? this.items[index];\n }\n\n protected [$deleteByIndex](index: number) {\n this.items[index] = undefined;\n }\n\n protected [$onEncodeEnd]() {\n this.tmpItems = this.items.slice();\n this.deletedIndexes = {};\n }\n\n protected [$onDecodeEnd]() {\n this.items = this.items.filter((item) => item !== undefined);\n }\n\n toArray() {\n return this.items.slice(0);\n }\n\n toJSON() {\n return this.toArray().map((value) => {\n return (typeof (value['toJSON']) === \"function\")\n ? value['toJSON']()\n : value;\n });\n }\n\n //\n // Decoding utilities\n //\n clone(isDecoding?: boolean): ArraySchema<V> {\n let cloned: ArraySchema;\n\n if (isDecoding) {\n cloned = new ArraySchema();\n cloned.push(...this.items);\n\n } else {\n cloned = new ArraySchema(...this.map(item => (\n (item[$changes])\n ? (item as any as Schema).clone()\n : item\n )));\n }\n\n return cloned;\n };\n\n}\n\nregisterType(\"array\", { constructor: ArraySchema });"]}
@@ -1,19 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getType = exports.getIdentifier = exports.registerType = void 0;
3
+ exports.registerType = registerType;
4
+ exports.getIdentifier = getIdentifier;
5
+ exports.getType = getType;
4
6
  const registeredTypes = {};
5
7
  const identifiers = new Map();
6
8
  function registerType(identifier, definition) {
7
9
  identifiers.set(definition.constructor, identifier);
8
10
  registeredTypes[identifier] = definition;
9
11
  }
10
- exports.registerType = registerType;
11
12
  function getIdentifier(klass) {
12
13
  return identifiers.get(klass);
13
14
  }
14
- exports.getIdentifier = getIdentifier;
15
15
  function getType(identifier) {
16
16
  return registeredTypes[identifier];
17
17
  }
18
- exports.getType = getType;
19
18
  //# sourceMappingURL=registry.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/types/registry.ts"],"names":[],"mappings":";;;AAIA,MAAM,eAAe,GAA4C,EAAE,CAAC;AACpE,MAAM,WAAW,GAAG,IAAI,GAAG,EAAe,CAAC;AAE3C,SAAgB,YAAY,CAAC,UAAkB,EAAE,UAA0B;IACvE,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;IACpD,eAAe,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC;AAC7C,CAAC;AAHD,oCAGC;AAED,SAAgB,aAAa,CAAC,KAAU;IACpC,OAAO,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AAClC,CAAC;AAFD,sCAEC;AAED,SAAgB,OAAO,CAAC,UAAkB;IACtC,OAAO,eAAe,CAAC,UAAU,CAAC,CAAC;AACvC,CAAC;AAFD,0BAEC","sourcesContent":["export interface TypeDefinition {\n constructor: any,\n}\n\nconst registeredTypes: {[identifier: string] : TypeDefinition} = {};\nconst identifiers = new Map<any, string>();\n\nexport function registerType(identifier: string, definition: TypeDefinition) {\n identifiers.set(definition.constructor, identifier);\n registeredTypes[identifier] = definition;\n}\n\nexport function getIdentifier(klass: any): string {\n return identifiers.get(klass);\n}\n\nexport function getType(identifier: string): TypeDefinition {\n return registeredTypes[identifier];\n}\n"]}
1
+ {"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/types/registry.ts"],"names":[],"mappings":";;AAOA,oCAGC;AAED,sCAEC;AAED,0BAEC;AAdD,MAAM,eAAe,GAA4C,EAAE,CAAC;AACpE,MAAM,WAAW,GAAG,IAAI,GAAG,EAAe,CAAC;AAE3C,SAAgB,YAAY,CAAC,UAAkB,EAAE,UAA0B;IACvE,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;IACpD,eAAe,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC;AAC7C,CAAC;AAED,SAAgB,aAAa,CAAC,KAAU;IACpC,OAAO,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AAClC,CAAC;AAED,SAAgB,OAAO,CAAC,UAAkB;IACtC,OAAO,eAAe,CAAC,UAAU,CAAC,CAAC;AACvC,CAAC","sourcesContent":["export interface TypeDefinition {\n constructor: any,\n}\n\nconst registeredTypes: {[identifier: string] : TypeDefinition} = {};\nconst identifiers = new Map<any, string>();\n\nexport function registerType(identifier: string, definition: TypeDefinition) {\n identifiers.set(definition.constructor, identifier);\n registeredTypes[identifier] = definition;\n}\n\nexport function getIdentifier(klass: any): string {\n return identifiers.get(klass);\n}\n\nexport function getType(identifier: string): TypeDefinition {\n return registeredTypes[identifier];\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.spliceOne = void 0;
3
+ exports.spliceOne = spliceOne;
4
4
  function spliceOne(arr, index) {
5
5
  // manually splice an array
6
6
  if (index === -1 || index >= arr.length) {
@@ -13,5 +13,4 @@ function spliceOne(arr, index) {
13
13
  arr.length = len;
14
14
  return true;
15
15
  }
16
- exports.spliceOne = spliceOne;
17
16
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/types/utils.ts"],"names":[],"mappings":";;;AAAA,SAAgB,SAAS,CAAC,GAAU,EAAE,KAAa;IAC/C,2BAA2B;IAC3B,IAAI,KAAK,KAAK,CAAC,CAAC,IAAI,KAAK,IAAI,GAAG,CAAC,MAAM,EAAE,CAAC;QACtC,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC;IAE3B,KAAK,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;QAC/B,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IACxB,CAAC;IAED,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC;IAEjB,OAAO,IAAI,CAAC;AAChB,CAAC;AAfD,8BAeC","sourcesContent":["export function spliceOne(arr: any[], index: number): boolean {\n // manually splice an array\n if (index === -1 || index >= arr.length) {\n return false;\n }\n\n const len = arr.length - 1;\n\n for (let i = index; i < len; i++) {\n arr[i] = arr[i + 1];\n }\n\n arr.length = len;\n\n return true;\n}"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/types/utils.ts"],"names":[],"mappings":";;AAAA,8BAeC;AAfD,SAAgB,SAAS,CAAC,GAAU,EAAE,KAAa;IAC/C,2BAA2B;IAC3B,IAAI,KAAK,KAAK,CAAC,CAAC,IAAI,KAAK,IAAI,GAAG,CAAC,MAAM,EAAE,CAAC;QACtC,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC;IAE3B,KAAK,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;QAC/B,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IACxB,CAAC;IAED,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC;IAEjB,OAAO,IAAI,CAAC;AAChB,CAAC","sourcesContent":["export function spliceOne(arr: any[], index: number): boolean {\n // manually splice an array\n if (index === -1 || index >= arr.length) {\n return false;\n }\n\n const len = arr.length - 1;\n\n for (let i = index; i < len; i++) {\n arr[i] = arr[i + 1];\n }\n\n arr.length = len;\n\n return true;\n}"]}
package/lib/utils.js CHANGED
@@ -1,12 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getNextPowerOf2 = exports.dumpChanges = exports.getIndent = void 0;
3
+ exports.getIndent = getIndent;
4
+ exports.dumpChanges = dumpChanges;
5
+ exports.getNextPowerOf2 = getNextPowerOf2;
4
6
  const spec_1 = require("./encoding/spec");
5
7
  const symbols_1 = require("./types/symbols");
6
8
  function getIndent(level) {
7
9
  return (new Array(level).fill(0)).map((_, i) => (i === level - 1) ? `└─ ` : ` `).join("");
8
10
  }
9
- exports.getIndent = getIndent;
10
11
  function dumpChanges(schema) {
11
12
  const $root = schema[symbols_1.$changes].root;
12
13
  const dump = {
@@ -25,7 +26,6 @@ function dumpChanges(schema) {
25
26
  });
26
27
  return dump;
27
28
  }
28
- exports.dumpChanges = dumpChanges;
29
29
  function getNextPowerOf2(number) {
30
30
  // If number is already a power of 2, return it
31
31
  if ((number & (number - 1)) === 0) {
@@ -40,5 +40,4 @@ function getNextPowerOf2(number) {
40
40
  // Return the next power of 2
41
41
  return 1 << msbPosition;
42
42
  }
43
- exports.getNextPowerOf2 = getNextPowerOf2;
44
43
  //# sourceMappingURL=utils.js.map
package/lib/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AACA,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AAG,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;QAChC,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,gDAAgD;IAChD,IAAI,WAAW,GAAG,CAAC,CAAC;IACpB,OAAO,MAAM,GAAG,CAAC,EAAE,CAAC;QAChB,MAAM,KAAK,CAAC,CAAC;QACb,WAAW,EAAE,CAAC;IAClB,CAAC;IAED,6BAA6B;IAC7B,OAAO,CAAC,IAAI,WAAW,CAAC;AAC5B,CAAC;AAfD,0CAeC","sourcesContent":["import type { Schema } from \"./Schema\";\nimport { OPERATION } from \"./encoding/spec\";\nimport { $changes } from \"./types/symbols\";\n\ntype ChangeItem = [string, number | string, any?];\n\ninterface ChangeDump {\n ops: {\n ADD?: number;\n REMOVE?: number;\n REPLACE?: number;\n },\n refs: string[],\n}\n\nexport function getIndent(level: number) {\n return (new Array(level).fill(0)).map((_, i) =>\n (i === level - 1) ? `└─ ` : ` `\n ).join(\"\");\n}\n\nexport function dumpChanges(schema: Schema) {\n const $root = schema[$changes].root;\n\n const dump: ChangeDump = {\n ops: {},\n refs: []\n };\n\n $root.changes.forEach((operations, changeTree) => {\n dump.refs.push(`refId#${changeTree.refId}`);\n operations.forEach((op, index) => {\n const opName = OPERATION[op];\n if (!dump.ops[opName]) { dump.ops[opName] = 0; }\n dump.ops[OPERATION[op]]++;\n });\n });\n\n return dump;\n}\n\nexport function getNextPowerOf2(number: number) {\n // If number is already a power of 2, return it\n if ((number & (number - 1)) === 0) {\n return number;\n }\n\n // Find the position of the most significant bit\n let msbPosition = 0;\n while (number > 0) {\n number >>= 1;\n msbPosition++;\n }\n\n // Return the next power of 2\n return 1 << msbPosition;\n}"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;AAeA,8BAIC;AAED,kCAkBC;AAED,0CAeC;AAvDD,0CAA4C;AAC5C,6CAA2C;AAa3C,SAAgB,SAAS,CAAC,KAAa;IACnC,OAAO,CAAC,IAAI,KA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W,GAAG,CAAC,CAAC;IACpB,OAAO,MAAM,GAAG,CAAC,EAAE,CAAC;QAChB,MAAM,KAAK,CAAC,CAAC;QACb,WAAW,EAAE,CAAC;IAClB,CAAC;IAED,6BAA6B;IAC7B,OAAO,CAAC,IAAI,WAAW,CAAC;AAC5B,CAAC","sourcesContent":["import type { Schema } from \"./Schema\";\nimport { OPERATION } from \"./encoding/spec\";\nimport { $changes } from \"./types/symbols\";\n\ntype ChangeItem = [string, number | string, any?];\n\ninterface ChangeDump {\n ops: {\n ADD?: number;\n REMOVE?: number;\n REPLACE?: number;\n },\n refs: string[],\n}\n\nexport function getIndent(level: number) {\n return (new Array(level).fill(0)).map((_, i) =>\n (i === level - 1) ? `└─ ` : ` `\n ).join(\"\");\n}\n\nexport function dumpChanges(schema: Schema) {\n const $root = schema[$changes].root;\n\n const dump: ChangeDump = {\n ops: {},\n refs: []\n };\n\n $root.changes.forEach((operations, changeTree) => {\n dump.refs.push(`refId#${changeTree.refId}`);\n operations.forEach((op, index) => {\n const opName = OPERATION[op];\n if (!dump.ops[opName]) { dump.ops[opName] = 0; }\n dump.ops[OPERATION[op]]++;\n });\n });\n\n return dump;\n}\n\nexport function getNextPowerOf2(number: number) {\n // If number is already a power of 2, return it\n if ((number & (number - 1)) === 0) {\n return number;\n }\n\n // Find the position of the most significant bit\n let msbPosition = 0;\n while (number > 0) {\n number >>= 1;\n msbPosition++;\n }\n\n // Return the next power of 2\n return 1 << msbPosition;\n}"]}