@colyseus/schema 3.0.0-alpha.17 → 3.0.0-alpha.19
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 +14 -2
- package/build/cjs/index.js.map +1 -1
- package/build/esm/index.mjs +14 -2
- package/build/esm/index.mjs.map +1 -1
- package/build/umd/index.js +14 -2
- package/lib/Metadata.d.ts +1 -0
- package/lib/Metadata.js +8 -0
- package/lib/Metadata.js.map +1 -1
- package/lib/decoder/strategy/StateCallbacks.d.ts +1 -1
- package/lib/decoder/strategy/StateCallbacks.js +3 -3
- package/lib/decoder/strategy/StateCallbacks.js.map +1 -1
- package/lib/encoder/Encoder.js +5 -0
- package/lib/encoder/Encoder.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/src/Metadata.ts +9 -0
- package/src/decoder/strategy/StateCallbacks.ts +1 -1
- package/src/encoder/Encoder.ts +7 -0
- package/src/index.ts +1 -1
package/build/esm/index.mjs
CHANGED
|
@@ -140,6 +140,14 @@ const Metadata = {
|
|
|
140
140
|
isDeprecated(metadata, field) {
|
|
141
141
|
return metadata[field].deprecated === true;
|
|
142
142
|
},
|
|
143
|
+
init(klass) {
|
|
144
|
+
//
|
|
145
|
+
// Used only to initialize an empty Schema (Encoder#constructor)
|
|
146
|
+
//
|
|
147
|
+
const metadata = {};
|
|
148
|
+
klass.constructor[Symbol.metadata] = metadata;
|
|
149
|
+
Object.defineProperty(metadata, -1, { value: 0, enumerable: false, configurable: true });
|
|
150
|
+
},
|
|
143
151
|
isValidInstance(klass) {
|
|
144
152
|
return (klass.constructor[Symbol.metadata] &&
|
|
145
153
|
Object.prototype.hasOwnProperty.call(klass.constructor[Symbol.metadata], -1));
|
|
@@ -3408,6 +3416,10 @@ class Encoder {
|
|
|
3408
3416
|
setRoot(state) {
|
|
3409
3417
|
this.root = new Root();
|
|
3410
3418
|
this.state = state;
|
|
3419
|
+
// Workaround to allow using an empty Schema.
|
|
3420
|
+
if (state.constructor[Symbol.metadata] === undefined) {
|
|
3421
|
+
Metadata.init(state);
|
|
3422
|
+
}
|
|
3411
3423
|
state[$changes].setRoot(this.root);
|
|
3412
3424
|
}
|
|
3413
3425
|
encode(it = { offset: 0 }, view, buffer = this.sharedBuffer, changeTrees = this.root.changes, isEncodeAll = this.root.allChanges === changeTrees) {
|
|
@@ -3976,7 +3988,7 @@ __decorate([
|
|
|
3976
3988
|
type([ReflectionType])
|
|
3977
3989
|
], Reflection.prototype, "types", void 0);
|
|
3978
3990
|
|
|
3979
|
-
function
|
|
3991
|
+
function getDecoderStateCallbacks(decoder) {
|
|
3980
3992
|
const $root = decoder.root;
|
|
3981
3993
|
const callbacks = $root.callbacks;
|
|
3982
3994
|
let isTriggeringOnAdd = false;
|
|
@@ -4406,5 +4418,5 @@ registerType("array", { constructor: ArraySchema });
|
|
|
4406
4418
|
registerType("set", { constructor: SetSchema });
|
|
4407
4419
|
registerType("collection", { constructor: CollectionSchema, });
|
|
4408
4420
|
|
|
4409
|
-
export { $changes, $childType, $decoder, $deleteByIndex, $encoder, $filter, $getByIndex, $track, ArraySchema, ChangeTree, CollectionSchema, Decoder, Encoder, MapSchema, Metadata, OPERATION, Reflection, ReflectionField, ReflectionType, Schema, SetSchema, StateView, TypeContext, decode, decodeKeyValueOperation, decodeSchemaOperation, defineTypes, deprecated, dumpChanges, encode, encodeArray as encodeKeyValueOperation, encodeSchemaOperation,
|
|
4421
|
+
export { $changes, $childType, $decoder, $deleteByIndex, $encoder, $filter, $getByIndex, $track, ArraySchema, ChangeTree, CollectionSchema, Decoder, Encoder, MapSchema, Metadata, OPERATION, Reflection, ReflectionField, ReflectionType, Schema, SetSchema, StateView, TypeContext, decode, decodeKeyValueOperation, decodeSchemaOperation, defineTypes, deprecated, dumpChanges, encode, encodeArray as encodeKeyValueOperation, encodeSchemaOperation, getDecoderStateCallbacks, getRawChangesCallback, registerType, type, view };
|
|
4410
4422
|
//# sourceMappingURL=index.mjs.map
|