@colyseus/schema 2.0.16 → 2.0.17
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 +8 -4
- package/build/cjs/index.js.map +1 -1
- package/build/esm/index.mjs +6 -1
- package/build/esm/index.mjs.map +1 -1
- package/build/umd/index.js +8 -4
- package/lib/Reflection.js +3 -3
- package/lib/Reflection.js.map +1 -1
- package/lib/Schema.d.ts +1 -3
- package/lib/Schema.js.map +1 -1
- package/lib/encoding/encode.d.ts +1 -1
- package/lib/events/EventEmitter.d.ts +13 -0
- package/lib/events/EventEmitter.js +31 -0
- package/lib/events/EventEmitter.js.map +1 -0
- package/lib/spec.js +1 -1
- package/lib/spec.js.map +1 -1
- package/lib/types/HelperTypes.d.ts +2 -2
- package/lib/types/HelperTypes.js.map +1 -1
- package/lib/types/index.d.ts +6 -0
- package/lib/types/index.js +13 -0
- package/lib/types/index.js.map +1 -0
- package/package.json +2 -2
- package/src/Schema.ts +2 -2
- package/src/types/HelperTypes.ts +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@colyseus/schema",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.17",
|
|
4
4
|
"description": "Binary state serializer with delta encoding for games",
|
|
5
5
|
"bin": {
|
|
6
6
|
"schema-codegen": "./bin/schema-codegen"
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"source-map-support": "^0.5.13",
|
|
79
79
|
"ts-node": "^7.0.1",
|
|
80
80
|
"tslib": "^2.1.0",
|
|
81
|
-
"tsx": "^3.
|
|
81
|
+
"tsx": "^3.13.0",
|
|
82
82
|
"typescript": "^5.0.4"
|
|
83
83
|
},
|
|
84
84
|
"nyc": {
|
package/src/Schema.ts
CHANGED
|
@@ -898,7 +898,7 @@ export abstract class Schema {
|
|
|
898
898
|
const schema = this._definition.schema;
|
|
899
899
|
const deprecated = this._definition.deprecated;
|
|
900
900
|
|
|
901
|
-
const obj:
|
|
901
|
+
const obj: unknown = {};
|
|
902
902
|
for (let field in schema) {
|
|
903
903
|
if (!deprecated[field] && this[field] !== null && typeof (this[field]) !== "undefined") {
|
|
904
904
|
obj[field] = (typeof (this[field]['toJSON']) === "function")
|
|
@@ -906,7 +906,7 @@ export abstract class Schema {
|
|
|
906
906
|
: this[`_${field}`];
|
|
907
907
|
}
|
|
908
908
|
}
|
|
909
|
-
return obj
|
|
909
|
+
return obj as ToJSON<typeof this>;
|
|
910
910
|
}
|
|
911
911
|
|
|
912
912
|
discardAllChanges() {
|
package/src/types/HelperTypes.ts
CHANGED
|
@@ -9,10 +9,10 @@ export type NonFunctionPropNames<T> = {
|
|
|
9
9
|
[K in keyof T]: T[K] extends Function ? never : K
|
|
10
10
|
}[keyof T];
|
|
11
11
|
|
|
12
|
-
export type ToJSON<T> =
|
|
12
|
+
export type ToJSON<T> = NonFunctionProps<{
|
|
13
13
|
[K in keyof T]: T[K] extends MapSchema<infer U>
|
|
14
14
|
? Record<string, U>
|
|
15
15
|
: T[K] extends ArraySchema<infer U>
|
|
16
16
|
? U[]
|
|
17
17
|
: T[K]
|
|
18
|
-
}
|
|
18
|
+
}>;
|