@colyseus/schema 3.0.70 → 3.0.72
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 +17 -6
- package/build/cjs/index.js.map +1 -1
- package/build/esm/index.mjs +17 -6
- package/build/esm/index.mjs.map +1 -1
- package/build/umd/index.js +17 -6
- package/lib/Decoder.d.ts +16 -0
- package/lib/Decoder.js +182 -0
- package/lib/Decoder.js.map +1 -0
- package/lib/Encoder.d.ts +13 -0
- package/lib/Encoder.js +79 -0
- package/lib/Encoder.js.map +1 -0
- package/lib/annotations.js +18 -3
- package/lib/annotations.js.map +1 -1
- package/lib/bench_encode.d.ts +1 -0
- package/lib/bench_encode.js +93 -0
- package/lib/bench_encode.js.map +1 -0
- package/lib/changes/ChangeSet.d.ts +12 -0
- package/lib/changes/ChangeSet.js +35 -0
- package/lib/changes/ChangeSet.js.map +1 -0
- package/lib/changes/ChangeTree.d.ts +53 -0
- package/lib/changes/ChangeTree.js +202 -0
- package/lib/changes/ChangeTree.js.map +1 -0
- package/lib/changes/DecodeOperation.d.ts +15 -0
- package/lib/changes/DecodeOperation.js +186 -0
- package/lib/changes/DecodeOperation.js.map +1 -0
- package/lib/changes/EncodeOperation.d.ts +18 -0
- package/lib/changes/EncodeOperation.js +130 -0
- package/lib/changes/EncodeOperation.js.map +1 -0
- package/lib/changes/ReferenceTracker.d.ts +14 -0
- package/lib/changes/ReferenceTracker.js +83 -0
- package/lib/changes/ReferenceTracker.js.map +1 -0
- package/lib/changes/consts.d.ts +14 -0
- package/lib/changes/consts.js +18 -0
- package/lib/changes/consts.js.map +1 -0
- package/lib/decoding/decode.d.ts +48 -0
- package/lib/decoding/decode.js +267 -0
- package/lib/decoding/decode.js.map +1 -0
- package/lib/ecs.d.ts +11 -0
- package/lib/ecs.js +160 -0
- package/lib/ecs.js.map +1 -0
- package/lib/filters/index.d.ts +8 -0
- package/lib/filters/index.js +24 -0
- package/lib/filters/index.js.map +1 -0
- package/lib/spec.d.ts +13 -0
- package/lib/spec.js +42 -0
- package/lib/spec.js.map +1 -0
- package/lib/types/ArraySchema.d.ts +238 -0
- package/lib/types/ArraySchema.js +555 -0
- package/lib/types/ArraySchema.js.map +1 -0
- package/lib/types/CollectionSchema.d.ts +35 -0
- package/lib/types/CollectionSchema.js +150 -0
- package/lib/types/CollectionSchema.js.map +1 -0
- package/lib/types/MapSchema.d.ts +38 -0
- package/lib/types/MapSchema.js +215 -0
- package/lib/types/MapSchema.js.map +1 -0
- package/lib/types/SetSchema.d.ts +32 -0
- package/lib/types/SetSchema.js +162 -0
- package/lib/types/SetSchema.js.map +1 -0
- package/lib/types/typeRegistry.d.ts +5 -0
- package/lib/types/typeRegistry.js +13 -0
- package/lib/types/typeRegistry.js.map +1 -0
- package/lib/usage.d.ts +1 -0
- package/lib/usage.js +22 -0
- package/lib/usage.js.map +1 -0
- package/lib/v3.d.ts +1 -0
- package/lib/v3.js +427 -0
- package/lib/v3.js.map +1 -0
- package/lib/v3_experiment.d.ts +1 -0
- package/lib/v3_experiment.js +407 -0
- package/lib/v3_experiment.js.map +1 -0
- package/package.json +1 -1
- package/src/annotations.ts +19 -4
- package/src/bench_encode.ts +64 -0
package/build/cjs/index.js
CHANGED
|
@@ -3524,10 +3524,7 @@ function schema(fieldsAndMethods, name, inherits = Schema) {
|
|
|
3524
3524
|
// Collection: Set → new SetSchema()
|
|
3525
3525
|
defaultValues[fieldName] = new SetSchema();
|
|
3526
3526
|
}
|
|
3527
|
-
else if (value['type'] !== undefined && Schema.is(value['type']))
|
|
3528
|
-
// Direct Schema type: Type → new Type()
|
|
3529
|
-
defaultValues[fieldName] = new value['type']();
|
|
3530
|
-
}
|
|
3527
|
+
else if (value['type'] !== undefined && Schema.is(value['type'])) ;
|
|
3531
3528
|
}
|
|
3532
3529
|
else {
|
|
3533
3530
|
defaultValues[fieldName] = value['default'];
|
|
@@ -3536,7 +3533,8 @@ function schema(fieldsAndMethods, name, inherits = Schema) {
|
|
|
3536
3533
|
else if (typeof (value) === "function") {
|
|
3537
3534
|
if (Schema.is(value)) {
|
|
3538
3535
|
// Direct Schema type: Type → new Type()
|
|
3539
|
-
|
|
3536
|
+
// TODO: should we auto-initialize Schema instances, in case their initialize() method is not defined?
|
|
3537
|
+
// defaultValues[fieldName] = new value();
|
|
3540
3538
|
fields[fieldName] = getNormalizedType(value);
|
|
3541
3539
|
}
|
|
3542
3540
|
else {
|
|
@@ -3563,14 +3561,27 @@ function schema(fieldsAndMethods, name, inherits = Schema) {
|
|
|
3563
3561
|
}
|
|
3564
3562
|
return defaults;
|
|
3565
3563
|
};
|
|
3564
|
+
const getParentProps = (props) => {
|
|
3565
|
+
const fieldNames = Object.keys(fields);
|
|
3566
|
+
const parentProps = {};
|
|
3567
|
+
for (const key in props) {
|
|
3568
|
+
if (!fieldNames.includes(key)) {
|
|
3569
|
+
parentProps[key] = props[key];
|
|
3570
|
+
}
|
|
3571
|
+
}
|
|
3572
|
+
return parentProps;
|
|
3573
|
+
};
|
|
3566
3574
|
/** @codegen-ignore */
|
|
3567
3575
|
const klass = Metadata.setFields(class extends inherits {
|
|
3568
3576
|
constructor(...args) {
|
|
3569
|
-
super(Object.assign({}, getDefaultValues(), args[0] || {}));
|
|
3570
3577
|
// call initialize method
|
|
3571
3578
|
if (methods.initialize && typeof methods.initialize === 'function') {
|
|
3579
|
+
super(Object.assign({}, getDefaultValues(), getParentProps(args[0] || {})));
|
|
3572
3580
|
methods.initialize.apply(this, args);
|
|
3573
3581
|
}
|
|
3582
|
+
else {
|
|
3583
|
+
super(Object.assign({}, getDefaultValues(), args[0] || {}));
|
|
3584
|
+
}
|
|
3574
3585
|
}
|
|
3575
3586
|
}, fields);
|
|
3576
3587
|
// Store the getDefaultValues function on the class for inheritance
|