@colyseus/schema 2.0.4 → 2.0.5

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 (107) hide show
  1. package/README.md +0 -4
  2. package/build/cjs/index.js +50 -49
  3. package/build/cjs/index.js.map +1 -1
  4. package/build/esm/index.mjs +130 -104
  5. package/build/esm/index.mjs.map +1 -1
  6. package/build/umd/index.js +52 -51
  7. package/lib/Reflection.js +87 -119
  8. package/lib/Reflection.js.map +1 -1
  9. package/lib/Schema.js +195 -257
  10. package/lib/Schema.js.map +1 -1
  11. package/lib/annotations.d.ts +6 -6
  12. package/lib/annotations.js +64 -92
  13. package/lib/annotations.js.map +1 -1
  14. package/lib/changes/ChangeTree.d.ts +1 -1
  15. package/lib/changes/ChangeTree.js +63 -70
  16. package/lib/changes/ChangeTree.js.map +1 -1
  17. package/lib/changes/ReferenceTracker.js +24 -27
  18. package/lib/changes/ReferenceTracker.js.map +1 -1
  19. package/lib/codegen/api.js +9 -9
  20. package/lib/codegen/api.js.map +1 -1
  21. package/lib/codegen/argv.d.ts +1 -1
  22. package/lib/codegen/argv.js +11 -11
  23. package/lib/codegen/argv.js.map +1 -1
  24. package/lib/codegen/cli.js +21 -10
  25. package/lib/codegen/cli.js.map +1 -1
  26. package/lib/codegen/languages/cpp.js +126 -77
  27. package/lib/codegen/languages/cpp.js.map +1 -1
  28. package/lib/codegen/languages/csharp.js +121 -62
  29. package/lib/codegen/languages/csharp.js.map +1 -1
  30. package/lib/codegen/languages/haxe.js +34 -26
  31. package/lib/codegen/languages/haxe.js.map +1 -1
  32. package/lib/codegen/languages/java.js +39 -27
  33. package/lib/codegen/languages/java.js.map +1 -1
  34. package/lib/codegen/languages/js.js +48 -32
  35. package/lib/codegen/languages/js.js.map +1 -1
  36. package/lib/codegen/languages/lua.js +35 -24
  37. package/lib/codegen/languages/lua.js.map +1 -1
  38. package/lib/codegen/languages/ts.js +63 -68
  39. package/lib/codegen/languages/ts.js.map +1 -1
  40. package/lib/codegen/parser.d.ts +9 -1
  41. package/lib/codegen/parser.js +88 -46
  42. package/lib/codegen/parser.js.map +1 -1
  43. package/lib/codegen/types.d.ts +8 -0
  44. package/lib/codegen/types.js +64 -54
  45. package/lib/codegen/types.js.map +1 -1
  46. package/lib/encoding/decode.js +15 -15
  47. package/lib/encoding/decode.js.map +1 -1
  48. package/lib/encoding/encode.js +14 -14
  49. package/lib/encoding/encode.js.map +1 -1
  50. package/lib/events/EventEmitter.d.ts +1 -1
  51. package/lib/events/EventEmitter.js +16 -47
  52. package/lib/events/EventEmitter.js.map +1 -1
  53. package/lib/filters/index.js +7 -8
  54. package/lib/filters/index.js.map +1 -1
  55. package/lib/index.js +11 -11
  56. package/lib/index.js.map +1 -1
  57. package/lib/types/ArraySchema.d.ts +1 -1
  58. package/lib/types/ArraySchema.js +161 -219
  59. package/lib/types/ArraySchema.js.map +1 -1
  60. package/lib/types/CollectionSchema.d.ts +1 -1
  61. package/lib/types/CollectionSchema.js +63 -71
  62. package/lib/types/CollectionSchema.js.map +1 -1
  63. package/lib/types/HelperTypes.d.ts +9 -9
  64. package/lib/types/MapSchema.d.ts +16 -16
  65. package/lib/types/MapSchema.js +68 -78
  66. package/lib/types/MapSchema.js.map +1 -1
  67. package/lib/types/SetSchema.js +62 -71
  68. package/lib/types/SetSchema.js.map +1 -1
  69. package/lib/types/index.js +1 -1
  70. package/lib/types/index.js.map +1 -1
  71. package/lib/types/typeRegistry.js +1 -1
  72. package/lib/types/typeRegistry.js.map +1 -1
  73. package/lib/types/utils.js +9 -10
  74. package/lib/types/utils.js.map +1 -1
  75. package/lib/utils.js +10 -13
  76. package/lib/utils.js.map +1 -1
  77. package/package.json +6 -4
  78. package/src/Reflection.ts +159 -0
  79. package/src/Schema.ts +1024 -0
  80. package/src/annotations.ts +400 -0
  81. package/src/changes/ChangeTree.ts +295 -0
  82. package/src/changes/ReferenceTracker.ts +81 -0
  83. package/src/codegen/api.ts +46 -0
  84. package/src/codegen/argv.ts +40 -0
  85. package/src/codegen/cli.ts +65 -0
  86. package/src/codegen/languages/cpp.ts +297 -0
  87. package/src/codegen/languages/csharp.ts +208 -0
  88. package/src/codegen/languages/haxe.ts +110 -0
  89. package/src/codegen/languages/java.ts +115 -0
  90. package/src/codegen/languages/js.ts +115 -0
  91. package/src/codegen/languages/lua.ts +125 -0
  92. package/src/codegen/languages/ts.ts +129 -0
  93. package/src/codegen/parser.ts +299 -0
  94. package/src/codegen/types.ts +177 -0
  95. package/src/encoding/decode.ts +278 -0
  96. package/src/encoding/encode.ts +283 -0
  97. package/src/filters/index.ts +23 -0
  98. package/src/index.ts +59 -0
  99. package/src/spec.ts +49 -0
  100. package/src/types/ArraySchema.ts +612 -0
  101. package/src/types/CollectionSchema.ts +199 -0
  102. package/src/types/HelperTypes.ts +34 -0
  103. package/src/types/MapSchema.ts +268 -0
  104. package/src/types/SetSchema.ts +208 -0
  105. package/src/types/typeRegistry.ts +19 -0
  106. package/src/types/utils.ts +62 -0
  107. package/src/utils.ts +28 -0
package/README.md CHANGED
@@ -7,10 +7,6 @@
7
7
  An incremental binary state serializer with delta encoding for games.<br>
8
8
  Although it was born to be used on <a href="https://github.com/colyseus/colyseus">Colyseus</a>, this library can be used as standalone.
9
9
  </p>
10
-
11
- <a href="https://travis-ci.org/colyseus/schema">
12
- <img src="https://img.shields.io/travis/colyseus/schema.svg?style=for-the-badge" alt="Build status" />
13
- </a>
14
10
  </div>
15
11
 
16
12
  ## Defining Schema
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- /*! *****************************************************************************
5
+ /******************************************************************************
6
6
  Copyright (c) Microsoft Corporation.
7
7
 
8
8
  Permission to use, copy, modify, and/or distribute this software for any
@@ -40,10 +40,14 @@ function __decorate(decorators, target, key, desc) {
40
40
  return c > 3 && r && Object.defineProperty(target, key, r), r;
41
41
  }
42
42
 
43
- function __spreadArray(to, from) {
44
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
45
- to[j] = from[i];
46
- return to;
43
+ function __spreadArray(to, from, pack) {
44
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
45
+ if (ar || !(i in from)) {
46
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
47
+ ar[i] = from[i];
48
+ }
49
+ }
50
+ return to.concat(ar || Array.prototype.slice.call(from));
47
51
  }
48
52
 
49
53
  // export const SWITCH_TO_STRUCTURE = 193; (easily collides with DELETE_AND_ADD + fieldIndex = 2)
@@ -210,7 +214,7 @@ var ChangeTree = /** @class */ (function () {
210
214
  ? fieldName
211
215
  : this.indexes[fieldName];
212
216
  if (index === undefined) {
213
- console.warn("@colyseus/schema " + this.ref.constructor.name + ": trying to delete non-existing index: " + fieldName + " (" + index + ")");
217
+ console.warn("@colyseus/schema ".concat(this.ref.constructor.name, ": trying to delete non-existing index: ").concat(fieldName, " (").concat(index, ")"));
214
218
  return;
215
219
  }
216
220
  var previousValue = this.getValue(index);
@@ -282,7 +286,7 @@ var ChangeTree = /** @class */ (function () {
282
286
  };
283
287
  ChangeTree.prototype.assertValidIndex = function (index, fieldName) {
284
288
  if (index === undefined) {
285
- throw new Error("ChangeTree: missing index for field \"" + fieldName + "\"");
289
+ throw new Error("ChangeTree: missing index for field \"".concat(fieldName, "\""));
286
290
  }
287
291
  };
288
292
  return ChangeTree;
@@ -520,7 +524,7 @@ var ArraySchema = /** @class */ (function () {
520
524
  for (var _i = 0; _i < arguments.length; _i++) {
521
525
  items[_i] = arguments[_i];
522
526
  }
523
- return new (ArraySchema.bind.apply(ArraySchema, __spreadArray([void 0], (_a = Array.from(this.$items.values())).concat.apply(_a, items))))();
527
+ return new (ArraySchema.bind.apply(ArraySchema, __spreadArray([void 0], (_a = Array.from(this.$items.values())).concat.apply(_a, items), false)))();
524
528
  };
525
529
  /**
526
530
  * Adds all the elements of an array separated by the specified separator string.
@@ -560,7 +564,7 @@ var ArraySchema = /** @class */ (function () {
560
564
  * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'.
561
565
  */
562
566
  ArraySchema.prototype.slice = function (start, end) {
563
- return new (ArraySchema.bind.apply(ArraySchema, __spreadArray([void 0], Array.from(this.$items.values()).slice(start, end))))();
567
+ return new (ArraySchema.bind.apply(ArraySchema, __spreadArray([void 0], Array.from(this.$items.values()).slice(start, end), false)))();
564
568
  };
565
569
  /**
566
570
  * Sorts an array.
@@ -589,10 +593,6 @@ var ArraySchema = /** @class */ (function () {
589
593
  */
590
594
  ArraySchema.prototype.splice = function (start, deleteCount) {
591
595
  if (deleteCount === void 0) { deleteCount = this.length - start; }
592
- var items = [];
593
- for (var _i = 2; _i < arguments.length; _i++) {
594
- items[_i - 2] = arguments[_i];
595
- }
596
596
  var indexes = Array.from(this.$items.keys());
597
597
  var removedItems = [];
598
598
  for (var i = start; i < start + deleteCount; i++) {
@@ -687,7 +687,7 @@ var ArraySchema = /** @class */ (function () {
687
687
  * @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.
688
688
  */
689
689
  ArraySchema.prototype.reduce = function (callbackfn, initialValue) {
690
- return Array.from(this.$items.values()).reduce(callbackfn, initialValue);
690
+ return Array.prototype.reduce.apply(Array.from(this.$items.values()), arguments);
691
691
  };
692
692
  /**
693
693
  * 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.
@@ -695,7 +695,7 @@ var ArraySchema = /** @class */ (function () {
695
695
  * @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.
696
696
  */
697
697
  ArraySchema.prototype.reduceRight = function (callbackfn, initialValue) {
698
- return Array.from(this.$items.values()).reduceRight(callbackfn, initialValue);
698
+ return Array.prototype.reduceRight.apply(Array.from(this.$items.values()), arguments);
699
699
  };
700
700
  /**
701
701
  * Returns the value of the first element in the array where predicate is true, and undefined
@@ -762,9 +762,6 @@ var ArraySchema = /** @class */ (function () {
762
762
  ArraySchema.prototype[Symbol.iterator] = function () {
763
763
  return Array.from(this.$items.values())[Symbol.iterator]();
764
764
  };
765
- ArraySchema.prototype[Symbol.unscopables] = function () {
766
- return this.$items[Symbol.unscopables]();
767
- };
768
765
  /**
769
766
  * Returns an iterable of key, value pairs for every entry in the array
770
767
  */
@@ -844,12 +841,12 @@ var ArraySchema = /** @class */ (function () {
844
841
  ArraySchema.prototype.clone = function (isDecoding) {
845
842
  var cloned;
846
843
  if (isDecoding) {
847
- cloned = new (ArraySchema.bind.apply(ArraySchema, __spreadArray([void 0], Array.from(this.$items.values()))))();
844
+ cloned = new (ArraySchema.bind.apply(ArraySchema, __spreadArray([void 0], Array.from(this.$items.values()), false)))();
848
845
  }
849
846
  else {
850
847
  cloned = new (ArraySchema.bind.apply(ArraySchema, __spreadArray([void 0], this.map(function (item) { return ((item['$changes'])
851
848
  ? item.clone()
852
- : item); }))))();
849
+ : item); }), false)))();
853
850
  }
854
851
  return cloned;
855
852
  };
@@ -896,7 +893,8 @@ var MapSchema = /** @class */ (function () {
896
893
  this.$indexes = new Map();
897
894
  this.$refId = 0;
898
895
  if (initialValues) {
899
- if (initialValues instanceof Map) {
896
+ if (initialValues instanceof Map ||
897
+ initialValues instanceof MapSchema) {
900
898
  initialValues.forEach(function (v, k) { return _this.set(k, v); });
901
899
  }
902
900
  else {
@@ -926,7 +924,7 @@ var MapSchema = /** @class */ (function () {
926
924
  });
927
925
  MapSchema.prototype.set = function (key, value) {
928
926
  if (value === undefined || value === null) {
929
- throw new Error("MapSchema#set('" + key + "', " + value + "): trying to set " + value + " value on '" + key + "'.");
927
+ throw new Error("MapSchema#set('".concat(key, "', ").concat(value, "): trying to set ").concat(value, " value on '").concat(key, "'."));
930
928
  }
931
929
  // get "index" for this value.
932
930
  var hasIndex = typeof (this.$changes.indexes[key]) !== "undefined";
@@ -1121,7 +1119,7 @@ var SchemaDefinition = /** @class */ (function () {
1121
1119
  return true;
1122
1120
  }
1123
1121
  else {
1124
- console.warn("@filterChildren: field '" + field + "' can't have children. Ignoring filter.");
1122
+ console.warn("@filterChildren: field '".concat(field, "' can't have children. Ignoring filter."));
1125
1123
  }
1126
1124
  };
1127
1125
  SchemaDefinition.prototype.getChildrenFilter = function (field) {
@@ -1191,7 +1189,7 @@ function type(type, options) {
1191
1189
  var constructor = target.constructor;
1192
1190
  constructor._context = context;
1193
1191
  if (!type) {
1194
- throw new Error(constructor.name + ": @type() reference provided for \"" + field + "\" is undefined. Make sure you don't have any circular dependencies.");
1192
+ throw new Error("".concat(constructor.name, ": @type() reference provided for \"").concat(field, "\" is undefined. Make sure you don't have any circular dependencies."));
1195
1193
  }
1196
1194
  /*
1197
1195
  * static schema
@@ -1213,11 +1211,11 @@ function type(type, options) {
1213
1211
  // trying to define same property multiple times across inheritance.
1214
1212
  // https://github.com/colyseus/colyseus-unity3d/issues/131#issuecomment-814308572
1215
1213
  try {
1216
- throw new Error("@colyseus/schema: Duplicate '" + field + "' definition on '" + constructor.name + "'.\nCheck @type() annotation");
1214
+ throw new Error("@colyseus/schema: Duplicate '".concat(field, "' definition on '").concat(constructor.name, "'.\nCheck @type() annotation"));
1217
1215
  }
1218
1216
  catch (e) {
1219
1217
  var definitionAtLine = e.stack.split("\n")[4].trim();
1220
- throw new Error(e.message + " " + definitionAtLine);
1218
+ throw new Error("".concat(e.message, " ").concat(definitionAtLine));
1221
1219
  }
1222
1220
  }
1223
1221
  }
@@ -1241,7 +1239,7 @@ function type(type, options) {
1241
1239
  };
1242
1240
  return;
1243
1241
  }
1244
- var fieldCached = "_" + field;
1242
+ var fieldCached = "_".concat(field);
1245
1243
  definition.descriptors[fieldCached] = {
1246
1244
  enumerable: false,
1247
1245
  configurable: false,
@@ -1263,7 +1261,7 @@ function type(type, options) {
1263
1261
  value !== null) {
1264
1262
  // automaticallty transform Array into ArraySchema
1265
1263
  if (isArray && !(value instanceof ArraySchema)) {
1266
- value = new (ArraySchema.bind.apply(ArraySchema, __spreadArray([void 0], value)))();
1264
+ value = new (ArraySchema.bind.apply(ArraySchema, __spreadArray([void 0], value, false)))();
1267
1265
  }
1268
1266
  // automaticallty transform Map into MapSchema
1269
1267
  if (isMap && !(value instanceof MapSchema)) {
@@ -1288,7 +1286,7 @@ function type(type, options) {
1288
1286
  value['$changes'].setParent(this, this.$changes.root, this._definition.indexes[field]);
1289
1287
  }
1290
1288
  }
1291
- else {
1289
+ else if (this[fieldCached]) {
1292
1290
  //
1293
1291
  // Setting a field to `null` or `undefined` will delete it.
1294
1292
  //
@@ -1334,7 +1332,7 @@ function deprecated(throws) {
1334
1332
  definition.deprecated[field] = true;
1335
1333
  if (throws) {
1336
1334
  definition.descriptors[field] = {
1337
- get: function () { throw new Error(field + " is deprecated."); },
1335
+ get: function () { throw new Error("".concat(field, " is deprecated.")); },
1338
1336
  set: function (value) { },
1339
1337
  enumerable: false,
1340
1338
  configurable: true
@@ -2307,7 +2305,7 @@ function assertType(value, type, klass, field) {
2307
2305
  case "float64":
2308
2306
  typeofTarget = "number";
2309
2307
  if (isNaN(value)) {
2310
- console.log("trying to encode \"NaN\" in " + klass.constructor.name + "#" + field);
2308
+ console.log("trying to encode \"NaN\" in ".concat(klass.constructor.name, "#").concat(field));
2311
2309
  }
2312
2310
  break;
2313
2311
  case "string":
@@ -2319,13 +2317,13 @@ function assertType(value, type, klass, field) {
2319
2317
  return;
2320
2318
  }
2321
2319
  if (typeof (value) !== typeofTarget && (!allowNull || (allowNull && value !== null))) {
2322
- var foundValue = "'" + JSON.stringify(value) + "'" + ((value && value.constructor && " (" + value.constructor.name + ")") || '');
2323
- throw new EncodeSchemaError("a '" + typeofTarget + "' was expected, but " + foundValue + " was provided in " + klass.constructor.name + "#" + field);
2320
+ var foundValue = "'".concat(JSON.stringify(value), "'").concat((value && value.constructor && " (".concat(value.constructor.name, ")")) || '');
2321
+ throw new EncodeSchemaError("a '".concat(typeofTarget, "' was expected, but ").concat(foundValue, " was provided in ").concat(klass.constructor.name, "#").concat(field));
2324
2322
  }
2325
2323
  }
2326
2324
  function assertInstanceType(value, type, klass, field) {
2327
2325
  if (!(value instanceof type)) {
2328
- throw new EncodeSchemaError("a '" + type.name + "' was expected, but '" + value.constructor.name + "' was provided in " + klass.constructor.name + "#" + field);
2326
+ throw new EncodeSchemaError("a '".concat(type.name, "' was expected, but '").concat(value.constructor.name, "' was provided in ").concat(klass.constructor.name, "#").concat(field));
2329
2327
  }
2330
2328
  }
2331
2329
  function encodePrimitiveType(type, bytes, value, klass, field) {
@@ -2335,7 +2333,7 @@ function encodePrimitiveType(type, bytes, value, klass, field) {
2335
2333
  encodeFunc(bytes, value);
2336
2334
  }
2337
2335
  else {
2338
- throw new EncodeSchemaError("a '" + type + "' was expected, but " + value + " was provided in " + klass.constructor.name + "#" + field);
2336
+ throw new EncodeSchemaError("a '".concat(type, "' was expected, but ").concat(value, " was provided in ").concat(klass.constructor.name, "#").concat(field));
2339
2337
  }
2340
2338
  }
2341
2339
  function decodePrimitiveType(type, bytes, it) {
@@ -2424,6 +2422,7 @@ var Schema = /** @class */ (function () {
2424
2422
  return function () { return spliceOne(_this.$callbacks[attr], _this.$callbacks[attr].indexOf(callback)); };
2425
2423
  };
2426
2424
  Schema.prototype.decode = function (bytes, it, ref) {
2425
+ var _a;
2427
2426
  if (it === void 0) { it = { offset: 0 }; }
2428
2427
  if (ref === void 0) { ref = this; }
2429
2428
  var allChanges = [];
@@ -2440,7 +2439,7 @@ var Schema = /** @class */ (function () {
2440
2439
  // Trying to access a reference that haven't been decoded yet.
2441
2440
  //
2442
2441
  if (!nextRef) {
2443
- throw new Error("\"refId\" not found: " + refId);
2442
+ throw new Error("\"refId\" not found: ".concat(refId));
2444
2443
  }
2445
2444
  ref = nextRef;
2446
2445
  continue;
@@ -2483,7 +2482,7 @@ var Schema = /** @class */ (function () {
2483
2482
  }
2484
2483
  }
2485
2484
  else {
2486
- previousValue = ref["_" + fieldName];
2485
+ previousValue = ref["_".concat(fieldName)];
2487
2486
  }
2488
2487
  //
2489
2488
  // Delete operations
@@ -2563,7 +2562,7 @@ var Schema = /** @class */ (function () {
2563
2562
  var entries = previousValue.entries();
2564
2563
  var iter = void 0;
2565
2564
  while ((iter = entries.next()) && !iter.done) {
2566
- var _a = iter.value, key = _a[0], value_1 = _a[1];
2565
+ var key = (_a = iter.value, _a[0]), value_1 = _a[1];
2567
2566
  allChanges.push({
2568
2567
  refId: refId_2,
2569
2568
  op: exports.OPERATION.DELETE,
@@ -2590,6 +2589,7 @@ var Schema = /** @class */ (function () {
2590
2589
  var key = dynamicIndex;
2591
2590
  // ref.set(key, value);
2592
2591
  ref['$items'].set(key, value);
2592
+ ref['$changes'].allChanges.add(fieldIndex);
2593
2593
  }
2594
2594
  else if (ref instanceof ArraySchema) {
2595
2595
  // const key = ref['$indexes'][field];
@@ -2742,7 +2742,7 @@ var Schema = /** @class */ (function () {
2742
2742
  //
2743
2743
  // ensure a ArraySchema has been provided
2744
2744
  //
2745
- assertInstanceType(ref["_" + field], definition.constructor, ref, field);
2745
+ assertInstanceType(ref["_".concat(field)], definition.constructor, ref, field);
2746
2746
  //
2747
2747
  // Encode refId for this instance.
2748
2748
  // The actual instance is going to be encoded on next `changeTree` iteration.
@@ -2944,11 +2944,12 @@ var Schema = /** @class */ (function () {
2944
2944
  return filteredBytes;
2945
2945
  };
2946
2946
  Schema.prototype.clone = function () {
2947
+ var _a;
2947
2948
  var cloned = new (this.constructor);
2948
2949
  var schema = this._definition.schema;
2949
2950
  for (var field in schema) {
2950
2951
  if (typeof (this[field]) === "object" &&
2951
- typeof (this[field].clone) === "function") {
2952
+ typeof ((_a = this[field]) === null || _a === void 0 ? void 0 : _a.clone) === "function") {
2952
2953
  // deep clone
2953
2954
  cloned[field] = this[field].clone();
2954
2955
  }
@@ -2967,7 +2968,7 @@ var Schema = /** @class */ (function () {
2967
2968
  if (!deprecated[field] && this[field] !== null && typeof (this[field]) !== "undefined") {
2968
2969
  obj[field] = (typeof (this[field]['toJSON']) === "function")
2969
2970
  ? this[field]['toJSON']()
2970
- : this["_" + field];
2971
+ : this["_".concat(field)];
2971
2972
  }
2972
2973
  }
2973
2974
  return obj;
@@ -3002,7 +3003,7 @@ var Schema = /** @class */ (function () {
3002
3003
  return instance;
3003
3004
  };
3004
3005
  Schema.prototype._triggerChanges = function (changes) {
3005
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
3006
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
3006
3007
  var uniqueRefIds = new Set();
3007
3008
  var $refs = this.$changes.root.refs;
3008
3009
  var _loop_2 = function (i) {
@@ -3025,7 +3026,7 @@ var Schema = /** @class */ (function () {
3025
3026
  if (!uniqueRefIds.has(refId)) {
3026
3027
  try {
3027
3028
  // trigger onChange
3028
- (_d = (_c = $callbacks) === null || _c === void 0 ? void 0 : _c[exports.OPERATION.REPLACE]) === null || _d === void 0 ? void 0 : _d.forEach(function (callback) {
3029
+ (_c = $callbacks === null || $callbacks === void 0 ? void 0 : $callbacks[exports.OPERATION.REPLACE]) === null || _c === void 0 ? void 0 : _c.forEach(function (callback) {
3029
3030
  return callback(changes);
3030
3031
  });
3031
3032
  }
@@ -3035,7 +3036,7 @@ var Schema = /** @class */ (function () {
3035
3036
  }
3036
3037
  try {
3037
3038
  if ($callbacks.hasOwnProperty(change.field)) {
3038
- (_e = $callbacks[change.field]) === null || _e === void 0 ? void 0 : _e.forEach(function (callback) {
3039
+ (_d = $callbacks[change.field]) === null || _d === void 0 ? void 0 : _d.forEach(function (callback) {
3039
3040
  return callback(change.value, change.previousValue);
3040
3041
  });
3041
3042
  }
@@ -3048,7 +3049,7 @@ var Schema = /** @class */ (function () {
3048
3049
  // is a collection of items
3049
3050
  if (change.op === exports.OPERATION.ADD && change.previousValue === undefined) {
3050
3051
  // triger onAdd
3051
- (_f = $callbacks[exports.OPERATION.ADD]) === null || _f === void 0 ? void 0 : _f.forEach(function (callback) { var _a; return callback(change.value, (_a = change.dynamicIndex) !== null && _a !== void 0 ? _a : change.field); });
3052
+ (_e = $callbacks[exports.OPERATION.ADD]) === null || _e === void 0 ? void 0 : _e.forEach(function (callback) { var _a; return callback(change.value, (_a = change.dynamicIndex) !== null && _a !== void 0 ? _a : change.field); });
3052
3053
  }
3053
3054
  else if (change.op === exports.OPERATION.DELETE) {
3054
3055
  //
@@ -3057,20 +3058,20 @@ var Schema = /** @class */ (function () {
3057
3058
  //
3058
3059
  if (change.previousValue !== undefined) {
3059
3060
  // triger onRemove
3060
- (_g = $callbacks[exports.OPERATION.DELETE]) === null || _g === void 0 ? void 0 : _g.forEach(function (callback) { var _a; return callback(change.previousValue, (_a = change.dynamicIndex) !== null && _a !== void 0 ? _a : change.field); });
3061
+ (_f = $callbacks[exports.OPERATION.DELETE]) === null || _f === void 0 ? void 0 : _f.forEach(function (callback) { var _a; return callback(change.previousValue, (_a = change.dynamicIndex) !== null && _a !== void 0 ? _a : change.field); });
3061
3062
  }
3062
3063
  }
3063
3064
  else if (change.op === exports.OPERATION.DELETE_AND_ADD) {
3064
3065
  // triger onRemove
3065
3066
  if (change.previousValue !== undefined) {
3066
- (_h = $callbacks[exports.OPERATION.DELETE]) === null || _h === void 0 ? void 0 : _h.forEach(function (callback) { var _a; return callback(change.previousValue, (_a = change.dynamicIndex) !== null && _a !== void 0 ? _a : change.field); });
3067
+ (_g = $callbacks[exports.OPERATION.DELETE]) === null || _g === void 0 ? void 0 : _g.forEach(function (callback) { var _a; return callback(change.previousValue, (_a = change.dynamicIndex) !== null && _a !== void 0 ? _a : change.field); });
3067
3068
  }
3068
3069
  // triger onAdd
3069
- (_j = $callbacks[exports.OPERATION.ADD]) === null || _j === void 0 ? void 0 : _j.forEach(function (callback) { var _a; return callback(change.value, (_a = change.dynamicIndex) !== null && _a !== void 0 ? _a : change.field); });
3070
+ (_h = $callbacks[exports.OPERATION.ADD]) === null || _h === void 0 ? void 0 : _h.forEach(function (callback) { var _a; return callback(change.value, (_a = change.dynamicIndex) !== null && _a !== void 0 ? _a : change.field); });
3070
3071
  }
3071
3072
  // trigger onChange
3072
3073
  if (change.value !== change.previousValue) {
3073
- (_k = $callbacks[exports.OPERATION.REPLACE]) === null || _k === void 0 ? void 0 : _k.forEach(function (callback) { var _a; return callback(change.value, (_a = change.dynamicIndex) !== null && _a !== void 0 ? _a : change.field); });
3074
+ (_j = $callbacks[exports.OPERATION.REPLACE]) === null || _j === void 0 ? void 0 : _j.forEach(function (callback) { var _a; return callback(change.value, (_a = change.dynamicIndex) !== null && _a !== void 0 ? _a : change.field); });
3074
3075
  }
3075
3076
  }
3076
3077
  uniqueRefIds.add(refId);