@colyseus/schema 2.0.16 → 2.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/index.js +16 -12
- package/build/cjs/index.js.map +1 -1
- package/build/esm/index.mjs +14 -9
- package/build/esm/index.mjs.map +1 -1
- package/build/umd/index.js +16 -12
- package/lib/Reflection.js +3 -3
- package/lib/Reflection.js.map +1 -1
- package/lib/Schema.d.ts +1 -3
- package/lib/Schema.js +2 -2
- package/lib/Schema.js.map +1 -1
- package/lib/encoding/encode.d.ts +1 -1
- package/lib/spec.js +1 -1
- package/lib/spec.js.map +1 -1
- package/lib/types/ArraySchema.js +3 -3
- package/lib/types/ArraySchema.js.map +1 -1
- package/lib/types/HelperTypes.d.ts +2 -2
- package/lib/types/HelperTypes.js.map +1 -1
- package/lib/types/MapSchema.js +3 -3
- package/lib/types/MapSchema.js.map +1 -1
- package/package.json +2 -2
- package/src/Schema.ts +4 -4
- package/src/types/ArraySchema.ts +3 -3
- package/src/types/HelperTypes.ts +2 -2
- package/src/types/MapSchema.ts +3 -3
package/build/cjs/index.js
CHANGED
|
@@ -16,7 +16,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
16
16
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
17
17
|
PERFORMANCE OF THIS SOFTWARE.
|
|
18
18
|
***************************************************************************** */
|
|
19
|
-
/* global Reflect, Promise */
|
|
19
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
20
20
|
|
|
21
21
|
var extendStatics = function(d, b) {
|
|
22
22
|
extendStatics = Object.setPrototypeOf ||
|
|
@@ -48,7 +48,12 @@ function __spreadArray(to, from, pack) {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
51
|
-
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
54
|
+
var e = new Error(message);
|
|
55
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
56
|
+
};
|
|
52
57
|
|
|
53
58
|
// export const SWITCH_TO_STRUCTURE = 193; (easily collides with DELETE_AND_ADD + fieldIndex = 2)
|
|
54
59
|
var SWITCH_TO_STRUCTURE = 255; // (decoding collides with DELETE_AND_ADD + fieldIndex = 63)
|
|
@@ -407,12 +412,12 @@ var ArraySchema = /** @class */ (function () {
|
|
|
407
412
|
}
|
|
408
413
|
ArraySchema.prototype.onAdd = function (callback, triggerAll) {
|
|
409
414
|
if (triggerAll === void 0) { triggerAll = true; }
|
|
410
|
-
return addCallback((this.$callbacks || (this.$callbacks =
|
|
415
|
+
return addCallback((this.$callbacks || (this.$callbacks = {})), exports.OPERATION.ADD, callback, (triggerAll)
|
|
411
416
|
? this.$items
|
|
412
417
|
: undefined);
|
|
413
418
|
};
|
|
414
|
-
ArraySchema.prototype.onRemove = function (callback) { return addCallback(this.$callbacks || (this.$callbacks =
|
|
415
|
-
ArraySchema.prototype.onChange = function (callback) { return addCallback(this.$callbacks || (this.$callbacks =
|
|
419
|
+
ArraySchema.prototype.onRemove = function (callback) { return addCallback(this.$callbacks || (this.$callbacks = {}), exports.OPERATION.DELETE, callback); };
|
|
420
|
+
ArraySchema.prototype.onChange = function (callback) { return addCallback(this.$callbacks || (this.$callbacks = {}), exports.OPERATION.REPLACE, callback); };
|
|
416
421
|
ArraySchema.is = function (type) {
|
|
417
422
|
return (
|
|
418
423
|
// type format: ["string"]
|
|
@@ -934,12 +939,12 @@ var MapSchema = /** @class */ (function () {
|
|
|
934
939
|
}
|
|
935
940
|
MapSchema.prototype.onAdd = function (callback, triggerAll) {
|
|
936
941
|
if (triggerAll === void 0) { triggerAll = true; }
|
|
937
|
-
return addCallback((this.$callbacks || (this.$callbacks =
|
|
942
|
+
return addCallback((this.$callbacks || (this.$callbacks = {})), exports.OPERATION.ADD, callback, (triggerAll)
|
|
938
943
|
? this.$items
|
|
939
944
|
: undefined);
|
|
940
945
|
};
|
|
941
|
-
MapSchema.prototype.onRemove = function (callback) { return addCallback(this.$callbacks || (this.$callbacks =
|
|
942
|
-
MapSchema.prototype.onChange = function (callback) { return addCallback(this.$callbacks || (this.$callbacks =
|
|
946
|
+
MapSchema.prototype.onRemove = function (callback) { return addCallback(this.$callbacks || (this.$callbacks = {}), exports.OPERATION.DELETE, callback); };
|
|
947
|
+
MapSchema.prototype.onChange = function (callback) { return addCallback(this.$callbacks || (this.$callbacks = {}), exports.OPERATION.REPLACE, callback); };
|
|
943
948
|
MapSchema.is = function (type) {
|
|
944
949
|
return type['map'] !== undefined;
|
|
945
950
|
};
|
|
@@ -2429,10 +2434,10 @@ var Schema = /** @class */ (function () {
|
|
|
2429
2434
|
type['_definition'].schema !== undefined);
|
|
2430
2435
|
};
|
|
2431
2436
|
Schema.prototype.onChange = function (callback) {
|
|
2432
|
-
return addCallback((this.$callbacks || (this.$callbacks =
|
|
2437
|
+
return addCallback((this.$callbacks || (this.$callbacks = {})), exports.OPERATION.REPLACE, callback);
|
|
2433
2438
|
};
|
|
2434
2439
|
Schema.prototype.onRemove = function (callback) {
|
|
2435
|
-
return addCallback((this.$callbacks || (this.$callbacks =
|
|
2440
|
+
return addCallback((this.$callbacks || (this.$callbacks = {})), exports.OPERATION.DELETE, callback);
|
|
2436
2441
|
};
|
|
2437
2442
|
Schema.prototype.assign = function (props) {
|
|
2438
2443
|
Object.assign(this, props);
|
|
@@ -2475,7 +2480,6 @@ var Schema = /** @class */ (function () {
|
|
|
2475
2480
|
return function () { return spliceOne(_this.$callbacks[prop], _this.$callbacks[prop].indexOf(callback)); };
|
|
2476
2481
|
};
|
|
2477
2482
|
Schema.prototype.decode = function (bytes, it, ref) {
|
|
2478
|
-
var _a;
|
|
2479
2483
|
if (it === void 0) { it = { offset: 0 }; }
|
|
2480
2484
|
if (ref === void 0) { ref = this; }
|
|
2481
2485
|
var allChanges = [];
|
|
@@ -2615,7 +2619,7 @@ var Schema = /** @class */ (function () {
|
|
|
2615
2619
|
var entries = previousValue.entries();
|
|
2616
2620
|
var iter = void 0;
|
|
2617
2621
|
while ((iter = entries.next()) && !iter.done) {
|
|
2618
|
-
var
|
|
2622
|
+
var _a = iter.value, key = _a[0], value_1 = _a[1];
|
|
2619
2623
|
allChanges.push({
|
|
2620
2624
|
refId: refId_2,
|
|
2621
2625
|
op: exports.OPERATION.DELETE,
|