@colyseus/schema 4.0.22 → 4.0.23

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.
@@ -41,7 +41,7 @@ export declare class StateCallbackStrategy<TState extends IRef> {
41
41
  /**
42
42
  * Listen to any property change on an instance.
43
43
  */
44
- onChange<TInstance extends Schema>(instance: TInstance, handler: InstanceChangeCallback): () => void;
44
+ onChange<TInstance extends object>(instance: TInstance, handler: InstanceChangeCallback): () => void;
45
45
  /**
46
46
  * Listen to item changes in a collection on root state.
47
47
  */
@@ -49,7 +49,7 @@ export declare class StateCallbackStrategy<TState extends IRef> {
49
49
  /**
50
50
  * Listen to item changes in a nested collection.
51
51
  */
52
- onChange<TInstance extends Schema, K extends CollectionPropNames<TInstance>>(instance: TInstance, property: K, handler: KeyValueCallback<CollectionKeyType<TInstance, K>, CollectionValueType<TInstance, K>>): () => void;
52
+ onChange<TInstance extends object, K extends CollectionPropNames<TInstance>>(instance: TInstance, property: K, handler: KeyValueCallback<CollectionKeyType<TInstance, K>, CollectionValueType<TInstance, K>>): () => void;
53
53
  /**
54
54
  * Listen to items added to a collection on root state.
55
55
  */
@@ -57,7 +57,7 @@ export declare class StateCallbackStrategy<TState extends IRef> {
57
57
  /**
58
58
  * Listen to items added to a nested collection.
59
59
  */
60
- onAdd<TInstance extends Schema, K extends CollectionPropNames<TInstance>>(instance: TInstance, property: K, handler: ValueKeyCallback<CollectionValueType<TInstance, K>, CollectionKeyType<TInstance, K>>, immediate?: boolean): () => void;
60
+ onAdd<TInstance, K extends CollectionPropNames<TInstance>>(instance: TInstance, property: K, handler: ValueKeyCallback<CollectionValueType<TInstance, K>, CollectionKeyType<TInstance, K>>, immediate?: boolean): () => void;
61
61
  /**
62
62
  * Listen to items removed from a collection on root state.
63
63
  */
@@ -65,12 +65,12 @@ export declare class StateCallbackStrategy<TState extends IRef> {
65
65
  /**
66
66
  * Listen to items removed from a nested collection.
67
67
  */
68
- onRemove<TInstance extends Schema, K extends CollectionPropNames<TInstance>>(instance: TInstance, property: K, handler: ValueKeyCallback<CollectionValueType<TInstance, K>, CollectionKeyType<TInstance, K>>): () => void;
68
+ onRemove<TInstance, K extends CollectionPropNames<TInstance>>(instance: TInstance, property: K, handler: ValueKeyCallback<CollectionValueType<TInstance, K>, CollectionKeyType<TInstance, K>>): () => void;
69
69
  /**
70
70
  * Bind properties from a Schema instance to a target object.
71
71
  * Changes will be automatically reflected on the target object.
72
72
  */
73
- bindTo<TInstance extends Schema, TTarget>(from: TInstance, to: TTarget, properties?: string[], immediate?: boolean): () => void;
73
+ bindTo<TInstance, TTarget>(from: TInstance, to: TTarget, properties?: string[], immediate?: boolean): () => void;
74
74
  protected triggerChanges(allChanges: DataChange[]): void;
75
75
  }
76
76
  /**
package/build/index.cjs CHANGED
@@ -5534,6 +5534,7 @@ const Callbacks = {
5534
5534
  else if ('decoder' in roomOrDecoder.serializer) {
5535
5535
  return getDecoderStateCallbacks(roomOrDecoder.serializer.decoder);
5536
5536
  }
5537
+ throw new Error('Invalid room or decoder');
5537
5538
  },
5538
5539
  getRawChanges(decoder, callback) {
5539
5540
  return getRawChangesCallback(decoder, callback);