@colyseus/schema 3.0.63 → 3.0.65
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 +6 -1
- 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 +6 -1
- package/lib/Schema.js +3 -1
- package/lib/Schema.js.map +1 -1
- package/lib/annotations.d.ts +3 -5
- package/lib/annotations.js.map +1 -1
- package/lib/encoder/ChangeTree.js +3 -0
- package/lib/encoder/ChangeTree.js.map +1 -1
- package/package.json +1 -1
- package/src/Schema.ts +4 -1
- package/src/annotations.ts +14 -12
- package/src/encoder/ChangeTree.ts +1 -0
package/src/annotations.ts
CHANGED
|
@@ -499,23 +499,25 @@ export function defineTypes(
|
|
|
499
499
|
// Helper type to extract InitProps from initialize method
|
|
500
500
|
// Supports both single object parameter and multiple parameters
|
|
501
501
|
// If no initialize method is specified, use AssignableProps for field initialization
|
|
502
|
-
type ExtractInitProps<T> = T extends { initialize: (
|
|
503
|
-
? P extends
|
|
504
|
-
?
|
|
505
|
-
:
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
502
|
+
type ExtractInitProps<T> = T extends { initialize: (...args: infer P) => void }
|
|
503
|
+
? P extends readonly []
|
|
504
|
+
? never
|
|
505
|
+
: P extends readonly [infer First]
|
|
506
|
+
? First extends object
|
|
507
|
+
? First
|
|
508
|
+
: P
|
|
509
509
|
: P
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
510
|
+
: T extends Definition
|
|
511
|
+
? AssignableProps<InferSchemaInstanceType<T>>
|
|
512
|
+
: never;
|
|
513
513
|
|
|
514
514
|
// Helper type to determine if InitProps should be required
|
|
515
515
|
type IsInitPropsRequired<T> = T extends { initialize: (props: any) => void }
|
|
516
516
|
? true
|
|
517
|
-
: T extends { initialize: (...args:
|
|
518
|
-
?
|
|
517
|
+
: T extends { initialize: (...args: infer P) => void }
|
|
518
|
+
? P extends readonly []
|
|
519
|
+
? false
|
|
520
|
+
: true
|
|
519
521
|
: false;
|
|
520
522
|
|
|
521
523
|
export interface SchemaWithExtends<T extends Definition, P extends typeof Schema, > {
|
|
@@ -237,6 +237,7 @@ export class ChangeTree<T extends Ref = any> {
|
|
|
237
237
|
if (typeof ((this.ref as any)[$childType]) !== "string") {
|
|
238
238
|
// MapSchema / ArraySchema, etc.
|
|
239
239
|
for (const [key, value] of (this.ref as MapSchema).entries()) {
|
|
240
|
+
if (!value) { continue; } // sparse arrays can have undefined values
|
|
240
241
|
callback(value[$changes], this.indexes?.[key] ?? key);
|
|
241
242
|
};
|
|
242
243
|
}
|