@colyseus/schema 4.0.2 → 4.0.4
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/{lib → build}/Metadata.d.ts +2 -2
- package/{lib → build}/Reflection.d.ts +13 -13
- package/{lib → build}/Schema.d.ts +10 -10
- package/{lib/src → build}/annotations.d.ts +10 -10
- package/build/codegen/languages/cpp.d.ts +3 -0
- package/build/codegen/languages/csharp.d.ts +4 -0
- package/build/codegen/languages/haxe.d.ts +3 -0
- package/{lib → build}/codegen/languages/java.d.ts +2 -2
- package/build/codegen/languages/js.d.ts +3 -0
- package/build/codegen/languages/lua.d.ts +3 -0
- package/build/codegen/languages/ts.d.ts +3 -0
- package/{lib → build}/codegen/parser.d.ts +1 -1
- package/{lib → build}/decoder/DecodeOperation.d.ts +5 -5
- package/{lib/src → build}/decoder/Decoder.d.ts +7 -7
- package/{lib → build}/decoder/ReferenceTracker.d.ts +1 -1
- package/{lib → build}/decoder/strategy/Callbacks.d.ts +18 -43
- package/{lib → build}/decoder/strategy/RawChanges.d.ts +2 -2
- package/{lib → build}/decoder/strategy/getDecoderStateCallbacks.d.ts +3 -3
- package/{lib → build}/encoder/ChangeTree.d.ts +11 -11
- package/{lib → build}/encoder/EncodeOperation.d.ts +5 -5
- package/{lib → build}/encoder/Encoder.d.ts +6 -6
- package/{lib/src → build}/encoder/Root.d.ts +2 -2
- package/{lib/src → build}/encoder/StateView.d.ts +1 -1
- package/{lib/src → build}/encoding/assert.d.ts +6 -6
- package/{lib/src → build}/encoding/decode.d.ts +1 -1
- package/{lib/src → build}/encoding/encode.d.ts +1 -1
- package/build/{cjs/index.cjs → index.cjs} +8 -34
- package/build/index.cjs.map +1 -0
- package/build/index.d.ts +32 -0
- package/build/{umd/index.js → index.js} +8 -34
- package/build/{esm/index.mjs → index.mjs} +8 -34
- package/build/index.mjs.map +1 -0
- package/{lib → build}/types/HelperTypes.d.ts +6 -6
- package/{lib → build}/types/TypeContext.d.ts +1 -1
- package/{lib/src → build}/types/custom/ArraySchema.d.ts +8 -8
- package/{lib/src → build}/types/custom/CollectionSchema.d.ts +7 -7
- package/{lib → build}/types/custom/MapSchema.d.ts +7 -7
- package/{lib/src → build}/types/custom/SetSchema.d.ts +7 -7
- package/{lib/src → build}/types/registry.d.ts +2 -2
- package/{lib → build}/utils.d.ts +1 -1
- package/package.json +9 -10
- package/src/Metadata.ts +5 -5
- package/src/Reflection.ts +7 -7
- package/src/Schema.ts +11 -11
- package/src/annotations.ts +13 -13
- package/src/codegen/api.ts +3 -3
- package/src/codegen/cli.ts +2 -2
- package/src/codegen/languages/cpp.ts +2 -2
- package/src/codegen/languages/csharp.ts +3 -3
- package/src/codegen/languages/haxe.ts +2 -2
- package/src/codegen/languages/java.ts +2 -2
- package/src/codegen/languages/js.ts +2 -2
- package/src/codegen/languages/lua.ts +2 -2
- package/src/codegen/languages/ts.ts +2 -2
- package/src/codegen/parser.ts +6 -1
- package/src/decoder/DecodeOperation.ts +14 -14
- package/src/decoder/Decoder.ts +11 -11
- package/src/decoder/ReferenceTracker.ts +8 -8
- package/src/decoder/strategy/Callbacks.ts +27 -53
- package/src/decoder/strategy/RawChanges.ts +2 -2
- package/src/decoder/strategy/getDecoderStateCallbacks.ts +10 -10
- package/src/encoder/ChangeTree.ts +13 -13
- package/src/encoder/EncodeOperation.ts +9 -9
- package/src/encoder/Encoder.ts +10 -10
- package/src/encoder/Root.ts +4 -4
- package/src/encoder/StateView.ts +7 -7
- package/src/encoding/assert.ts +6 -6
- package/src/encoding/decode.ts +1 -1
- package/src/encoding/encode.ts +1 -1
- package/src/index.ts +27 -27
- package/src/types/HelperTypes.ts +6 -6
- package/src/types/TypeContext.ts +3 -3
- package/src/types/custom/ArraySchema.ts +11 -11
- package/src/types/custom/CollectionSchema.ts +9 -9
- package/src/types/custom/MapSchema.ts +10 -10
- package/src/types/custom/SetSchema.ts +9 -9
- package/src/types/registry.ts +3 -3
- package/src/utils.ts +3 -3
- package/src/v3_bench.ts +1 -1
- package/build/cjs/index.cjs.map +0 -1
- package/build/esm/index.mjs.map +0 -1
- package/lib/Metadata.js +0 -256
- package/lib/Metadata.js.map +0 -1
- package/lib/Reflection.js +0 -179
- package/lib/Reflection.js.map +0 -1
- package/lib/Schema.js +0 -352
- package/lib/Schema.js.map +0 -1
- package/lib/annotations.d.ts +0 -109
- package/lib/annotations.js +0 -473
- package/lib/annotations.js.map +0 -1
- package/lib/bench_encode.d.ts +0 -1
- package/lib/bench_encode.js +0 -91
- package/lib/bench_encode.js.map +0 -1
- package/lib/benchmark.d.ts +0 -1
- package/lib/benchmark.js +0 -218
- package/lib/benchmark.js.map +0 -1
- package/lib/codegen/api.js +0 -56
- package/lib/codegen/api.js.map +0 -1
- package/lib/codegen/argv.js +0 -39
- package/lib/codegen/argv.js.map +0 -1
- package/lib/codegen/cli.js +0 -58
- package/lib/codegen/cli.js.map +0 -1
- package/lib/codegen/languages/cpp.d.ts +0 -3
- package/lib/codegen/languages/cpp.js +0 -258
- package/lib/codegen/languages/cpp.js.map +0 -1
- package/lib/codegen/languages/csharp.d.ts +0 -4
- package/lib/codegen/languages/csharp.js +0 -154
- package/lib/codegen/languages/csharp.js.map +0 -1
- package/lib/codegen/languages/haxe.d.ts +0 -3
- package/lib/codegen/languages/haxe.js +0 -100
- package/lib/codegen/languages/haxe.js.map +0 -1
- package/lib/codegen/languages/java.js +0 -100
- package/lib/codegen/languages/java.js.map +0 -1
- package/lib/codegen/languages/js.d.ts +0 -3
- package/lib/codegen/languages/js.js +0 -101
- package/lib/codegen/languages/js.js.map +0 -1
- package/lib/codegen/languages/lua.d.ts +0 -3
- package/lib/codegen/languages/lua.js +0 -103
- package/lib/codegen/languages/lua.js.map +0 -1
- package/lib/codegen/languages/ts.d.ts +0 -3
- package/lib/codegen/languages/ts.js +0 -116
- package/lib/codegen/languages/ts.js.map +0 -1
- package/lib/codegen/parser.js +0 -327
- package/lib/codegen/parser.js.map +0 -1
- package/lib/codegen/types.js +0 -142
- package/lib/codegen/types.js.map +0 -1
- package/lib/decoder/DecodeOperation.js +0 -248
- package/lib/decoder/DecodeOperation.js.map +0 -1
- package/lib/decoder/Decoder.d.ts +0 -21
- package/lib/decoder/Decoder.js +0 -114
- package/lib/decoder/Decoder.js.map +0 -1
- package/lib/decoder/ReferenceTracker.js +0 -135
- package/lib/decoder/ReferenceTracker.js.map +0 -1
- package/lib/decoder/strategy/Callbacks.js +0 -336
- package/lib/decoder/strategy/Callbacks.js.map +0 -1
- package/lib/decoder/strategy/RawChanges.js +0 -4
- package/lib/decoder/strategy/RawChanges.js.map +0 -1
- package/lib/decoder/strategy/getDecoderStateCallbacks.js +0 -274
- package/lib/decoder/strategy/getDecoderStateCallbacks.js.map +0 -1
- package/lib/encoder/ChangeTree.js +0 -534
- package/lib/encoder/ChangeTree.js.map +0 -1
- package/lib/encoder/EncodeOperation.js +0 -132
- package/lib/encoder/EncodeOperation.js.map +0 -1
- package/lib/encoder/Encoder.js +0 -204
- package/lib/encoder/Encoder.js.map +0 -1
- package/lib/encoder/Root.d.ts +0 -28
- package/lib/encoder/Root.js +0 -229
- package/lib/encoder/Root.js.map +0 -1
- package/lib/encoder/StateView.d.ts +0 -34
- package/lib/encoder/StateView.js +0 -279
- package/lib/encoder/StateView.js.map +0 -1
- package/lib/encoding/assert.d.ts +0 -10
- package/lib/encoding/assert.js +0 -49
- package/lib/encoding/assert.js.map +0 -1
- package/lib/encoding/decode.d.ts +0 -67
- package/lib/encoding/decode.js +0 -217
- package/lib/encoding/decode.js.map +0 -1
- package/lib/encoding/encode.d.ts +0 -40
- package/lib/encoding/encode.js +0 -279
- package/lib/encoding/encode.js.map +0 -1
- package/lib/encoding/spec.js +0 -26
- package/lib/encoding/spec.js.map +0 -1
- package/lib/index.d.ts +0 -32
- package/lib/index.js +0 -39
- package/lib/index.js.map +0 -1
- package/lib/src/Metadata.d.ts +0 -49
- package/lib/src/Metadata.js +0 -256
- package/lib/src/Metadata.js.map +0 -1
- package/lib/src/Reflection.d.ts +0 -71
- package/lib/src/Reflection.js +0 -179
- package/lib/src/Reflection.js.map +0 -1
- package/lib/src/Schema.d.ts +0 -86
- package/lib/src/Schema.js +0 -352
- package/lib/src/Schema.js.map +0 -1
- package/lib/src/annotations.js +0 -473
- package/lib/src/annotations.js.map +0 -1
- package/lib/src/bench_encode.d.ts +0 -1
- package/lib/src/bench_encode.js +0 -91
- package/lib/src/bench_encode.js.map +0 -1
- package/lib/src/codegen/api.d.ts +0 -7
- package/lib/src/codegen/api.js +0 -56
- package/lib/src/codegen/api.js.map +0 -1
- package/lib/src/codegen/argv.d.ts +0 -6
- package/lib/src/codegen/argv.js +0 -39
- package/lib/src/codegen/argv.js.map +0 -1
- package/lib/src/codegen/cli.d.ts +0 -1
- package/lib/src/codegen/cli.js +0 -58
- package/lib/src/codegen/cli.js.map +0 -1
- package/lib/src/codegen/languages/cpp.d.ts +0 -3
- package/lib/src/codegen/languages/cpp.js +0 -258
- package/lib/src/codegen/languages/cpp.js.map +0 -1
- package/lib/src/codegen/languages/csharp.d.ts +0 -4
- package/lib/src/codegen/languages/csharp.js +0 -154
- package/lib/src/codegen/languages/csharp.js.map +0 -1
- package/lib/src/codegen/languages/haxe.d.ts +0 -3
- package/lib/src/codegen/languages/haxe.js +0 -100
- package/lib/src/codegen/languages/haxe.js.map +0 -1
- package/lib/src/codegen/languages/java.d.ts +0 -6
- package/lib/src/codegen/languages/java.js +0 -100
- package/lib/src/codegen/languages/java.js.map +0 -1
- package/lib/src/codegen/languages/js.d.ts +0 -3
- package/lib/src/codegen/languages/js.js +0 -101
- package/lib/src/codegen/languages/js.js.map +0 -1
- package/lib/src/codegen/languages/lua.d.ts +0 -3
- package/lib/src/codegen/languages/lua.js +0 -103
- package/lib/src/codegen/languages/lua.js.map +0 -1
- package/lib/src/codegen/languages/ts.d.ts +0 -3
- package/lib/src/codegen/languages/ts.js +0 -116
- package/lib/src/codegen/languages/ts.js.map +0 -1
- package/lib/src/codegen/parser.d.ts +0 -13
- package/lib/src/codegen/parser.js +0 -327
- package/lib/src/codegen/parser.js.map +0 -1
- package/lib/src/codegen/types.d.ts +0 -52
- package/lib/src/codegen/types.js +0 -142
- package/lib/src/codegen/types.js.map +0 -1
- package/lib/src/decoder/DecodeOperation.d.ts +0 -23
- package/lib/src/decoder/DecodeOperation.js +0 -248
- package/lib/src/decoder/DecodeOperation.js.map +0 -1
- package/lib/src/decoder/Decoder.js +0 -114
- package/lib/src/decoder/Decoder.js.map +0 -1
- package/lib/src/decoder/ReferenceTracker.d.ts +0 -25
- package/lib/src/decoder/ReferenceTracker.js +0 -135
- package/lib/src/decoder/ReferenceTracker.js.map +0 -1
- package/lib/src/decoder/strategy/Callbacks.d.ts +0 -154
- package/lib/src/decoder/strategy/Callbacks.js +0 -336
- package/lib/src/decoder/strategy/Callbacks.js.map +0 -1
- package/lib/src/decoder/strategy/RawChanges.d.ts +0 -3
- package/lib/src/decoder/strategy/RawChanges.js +0 -4
- package/lib/src/decoder/strategy/RawChanges.js.map +0 -1
- package/lib/src/decoder/strategy/getDecoderStateCallbacks.d.ts +0 -76
- package/lib/src/decoder/strategy/getDecoderStateCallbacks.js +0 -274
- package/lib/src/decoder/strategy/getDecoderStateCallbacks.js.map +0 -1
- package/lib/src/encoder/ChangeTree.d.ts +0 -135
- package/lib/src/encoder/ChangeTree.js +0 -534
- package/lib/src/encoder/ChangeTree.js.map +0 -1
- package/lib/src/encoder/EncodeOperation.d.ts +0 -22
- package/lib/src/encoder/EncodeOperation.js +0 -132
- package/lib/src/encoder/EncodeOperation.js.map +0 -1
- package/lib/src/encoder/Encoder.d.ts +0 -22
- package/lib/src/encoder/Encoder.js +0 -204
- package/lib/src/encoder/Encoder.js.map +0 -1
- package/lib/src/encoder/Root.js +0 -229
- package/lib/src/encoder/Root.js.map +0 -1
- package/lib/src/encoder/StateView.js +0 -279
- package/lib/src/encoder/StateView.js.map +0 -1
- package/lib/src/encoding/assert.js +0 -49
- package/lib/src/encoding/assert.js.map +0 -1
- package/lib/src/encoding/decode.js +0 -217
- package/lib/src/encoding/decode.js.map +0 -1
- package/lib/src/encoding/encode.js +0 -279
- package/lib/src/encoding/encode.js.map +0 -1
- package/lib/src/encoding/spec.d.ts +0 -24
- package/lib/src/encoding/spec.js +0 -26
- package/lib/src/encoding/spec.js.map +0 -1
- package/lib/src/index.d.ts +0 -32
- package/lib/src/index.js +0 -39
- package/lib/src/index.js.map +0 -1
- package/lib/src/symbol.shim.js +0 -3
- package/lib/src/symbol.shim.js.map +0 -1
- package/lib/src/types/HelperTypes.d.ts +0 -77
- package/lib/src/types/HelperTypes.js +0 -2
- package/lib/src/types/HelperTypes.js.map +0 -1
- package/lib/src/types/TypeContext.d.ts +0 -31
- package/lib/src/types/TypeContext.js +0 -143
- package/lib/src/types/TypeContext.js.map +0 -1
- package/lib/src/types/custom/ArraySchema.js +0 -733
- package/lib/src/types/custom/ArraySchema.js.map +0 -1
- package/lib/src/types/custom/CollectionSchema.js +0 -170
- package/lib/src/types/custom/CollectionSchema.js.map +0 -1
- package/lib/src/types/custom/MapSchema.d.ts +0 -51
- package/lib/src/types/custom/MapSchema.js +0 -222
- package/lib/src/types/custom/MapSchema.js.map +0 -1
- package/lib/src/types/custom/SetSchema.js +0 -178
- package/lib/src/types/custom/SetSchema.js.map +0 -1
- package/lib/src/types/registry.js +0 -30
- package/lib/src/types/registry.js.map +0 -1
- package/lib/src/types/symbols.js +0 -34
- package/lib/src/types/symbols.js.map +0 -1
- package/lib/src/types/utils.js +0 -13
- package/lib/src/types/utils.js.map +0 -1
- package/lib/src/utils.d.ts +0 -13
- package/lib/src/utils.js +0 -49
- package/lib/src/utils.js.map +0 -1
- package/lib/src/v3_bench.js +0 -128
- package/lib/src/v3_bench.js.map +0 -1
- package/lib/symbol.shim.d.ts +0 -6
- package/lib/symbol.shim.js +0 -3
- package/lib/symbol.shim.js.map +0 -1
- package/lib/types/HelperTypes.js +0 -2
- package/lib/types/HelperTypes.js.map +0 -1
- package/lib/types/TypeContext.js +0 -143
- package/lib/types/TypeContext.js.map +0 -1
- package/lib/types/custom/ArraySchema.d.ts +0 -270
- package/lib/types/custom/ArraySchema.js +0 -733
- package/lib/types/custom/ArraySchema.js.map +0 -1
- package/lib/types/custom/CollectionSchema.d.ts +0 -51
- package/lib/types/custom/CollectionSchema.js +0 -170
- package/lib/types/custom/CollectionSchema.js.map +0 -1
- package/lib/types/custom/MapSchema.js +0 -222
- package/lib/types/custom/MapSchema.js.map +0 -1
- package/lib/types/custom/SetSchema.d.ts +0 -48
- package/lib/types/custom/SetSchema.js +0 -178
- package/lib/types/custom/SetSchema.js.map +0 -1
- package/lib/types/registry.d.ts +0 -16
- package/lib/types/registry.js +0 -30
- package/lib/types/registry.js.map +0 -1
- package/lib/types/symbols.d.ts +0 -33
- package/lib/types/symbols.js +0 -34
- package/lib/types/symbols.js.map +0 -1
- package/lib/types/utils.d.ts +0 -1
- package/lib/types/utils.js +0 -13
- package/lib/types/utils.js.map +0 -1
- package/lib/utils.js +0 -49
- package/lib/utils.js.map +0 -1
- package/lib/v3_bench.d.ts +0 -1
- package/lib/v3_bench.js +0 -128
- package/lib/v3_bench.js.map +0 -1
- /package/{lib → build}/codegen/api.d.ts +0 -0
- /package/{lib → build}/codegen/argv.d.ts +0 -0
- /package/{lib → build}/codegen/cli.d.ts +0 -0
- /package/{lib → build}/codegen/types.d.ts +0 -0
- /package/{lib → build}/encoding/spec.d.ts +0 -0
- /package/{lib/src → build}/symbol.shim.d.ts +0 -0
- /package/{lib/src → build}/types/symbols.d.ts +0 -0
- /package/{lib/src → build}/types/utils.d.ts +0 -0
- /package/{lib/src → build}/v3_bench.d.ts +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DefinitionType } from "./annotations";
|
|
2
|
-
import { $descriptors, $fieldIndexesByViewTag, $numFields, $refTypeFieldIndexes, $viewFieldIndexes } from "./types/symbols";
|
|
1
|
+
import { DefinitionType } from "./annotations.js";
|
|
2
|
+
import { $descriptors, $fieldIndexesByViewTag, $numFields, $refTypeFieldIndexes, $viewFieldIndexes } from "./types/symbols.js";
|
|
3
3
|
export type MetadataField = {
|
|
4
4
|
type: DefinitionType;
|
|
5
5
|
name: string;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { schema, SchemaType } from "./annotations";
|
|
2
|
-
import { Iterator } from "./encoding/decode";
|
|
3
|
-
import { Encoder } from "./encoder/Encoder";
|
|
4
|
-
import { Decoder } from "./decoder/Decoder";
|
|
5
|
-
import { Schema } from "./Schema";
|
|
1
|
+
import { schema, SchemaType } from "./annotations.js";
|
|
2
|
+
import { Iterator } from "./encoding/decode.js";
|
|
3
|
+
import { Encoder } from "./encoder/Encoder.js";
|
|
4
|
+
import { Decoder } from "./decoder/Decoder.js";
|
|
5
|
+
import { Schema } from "./Schema.js";
|
|
6
6
|
/**
|
|
7
7
|
* Static methods available on Reflection
|
|
8
8
|
*/
|
|
@@ -27,36 +27,36 @@ interface ReflectionStatic {
|
|
|
27
27
|
/**
|
|
28
28
|
* Reflection
|
|
29
29
|
*/
|
|
30
|
-
export declare const ReflectionField: import("./annotations").SchemaWithExtendsConstructor<{
|
|
30
|
+
export declare const ReflectionField: import("./annotations.js").SchemaWithExtendsConstructor<{
|
|
31
31
|
name: "string";
|
|
32
32
|
type: "string";
|
|
33
33
|
referencedType: "number";
|
|
34
|
-
}, import(".").AssignableProps<import(".").InferSchemaInstanceType<{
|
|
34
|
+
}, import("./index.js").AssignableProps<import("./index.js").InferSchemaInstanceType<{
|
|
35
35
|
name: "string";
|
|
36
36
|
type: "string";
|
|
37
37
|
referencedType: "number";
|
|
38
38
|
}>>, typeof Schema>;
|
|
39
39
|
export type ReflectionField = SchemaType<typeof ReflectionField>;
|
|
40
|
-
export declare const ReflectionType: import("./annotations").SchemaWithExtendsConstructor<{
|
|
40
|
+
export declare const ReflectionType: import("./annotations.js").SchemaWithExtendsConstructor<{
|
|
41
41
|
id: "number";
|
|
42
42
|
extendsId: "number";
|
|
43
|
-
fields: import("./annotations").SchemaWithExtendsConstructor<{
|
|
43
|
+
fields: import("./annotations.js").SchemaWithExtendsConstructor<{
|
|
44
44
|
name: "string";
|
|
45
45
|
type: "string";
|
|
46
46
|
referencedType: "number";
|
|
47
|
-
}, import(".").AssignableProps<import(".").InferSchemaInstanceType<{
|
|
47
|
+
}, import("./index.js").AssignableProps<import("./index.js").InferSchemaInstanceType<{
|
|
48
48
|
name: "string";
|
|
49
49
|
type: "string";
|
|
50
50
|
referencedType: "number";
|
|
51
51
|
}>>, typeof Schema>[];
|
|
52
|
-
}, import(".").AssignableProps<import(".").InferSchemaInstanceType<{
|
|
52
|
+
}, import("./index.js").AssignableProps<import("./index.js").InferSchemaInstanceType<{
|
|
53
53
|
id: "number";
|
|
54
54
|
extendsId: "number";
|
|
55
|
-
fields: import("./annotations").SchemaWithExtendsConstructor<{
|
|
55
|
+
fields: import("./annotations.js").SchemaWithExtendsConstructor<{
|
|
56
56
|
name: "string";
|
|
57
57
|
type: "string";
|
|
58
58
|
referencedType: "number";
|
|
59
|
-
}, import(".").AssignableProps<import(".").InferSchemaInstanceType<{
|
|
59
|
+
}, import("./index.js").AssignableProps<import("./index.js").InferSchemaInstanceType<{
|
|
60
60
|
name: "string";
|
|
61
61
|
type: "string";
|
|
62
62
|
referencedType: "number";
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { OPERATION } from './encoding/spec';
|
|
2
|
-
import { type DefinitionType } from "./annotations";
|
|
3
|
-
import { AssignableProps, NonFunctionPropNames, ToJSON } from './types/HelperTypes';
|
|
4
|
-
import { ChangeSetName, ChangeTree, IRef, Ref } from './encoder/ChangeTree';
|
|
5
|
-
import { $decoder, $deleteByIndex, $encoder, $filter, $getByIndex, $refId, $track } from './types/symbols';
|
|
6
|
-
import { StateView } from './encoder/StateView';
|
|
7
|
-
import type { Decoder } from './decoder/Decoder';
|
|
8
|
-
import type { Metadata } from './Metadata';
|
|
1
|
+
import { OPERATION } from './encoding/spec.js';
|
|
2
|
+
import { type DefinitionType } from "./annotations.js";
|
|
3
|
+
import { AssignableProps, NonFunctionPropNames, ToJSON } from './types/HelperTypes.js';
|
|
4
|
+
import { ChangeSetName, ChangeTree, IRef, Ref } from './encoder/ChangeTree.js';
|
|
5
|
+
import { $decoder, $deleteByIndex, $encoder, $filter, $getByIndex, $refId, $track } from './types/symbols.js';
|
|
6
|
+
import { StateView } from './encoder/StateView.js';
|
|
7
|
+
import type { Decoder } from './decoder/Decoder.js';
|
|
8
|
+
import type { Metadata } from './Metadata.js';
|
|
9
9
|
/**
|
|
10
10
|
* Schema encoder / decoder
|
|
11
11
|
*/
|
|
12
12
|
export declare class Schema<C = any> implements IRef {
|
|
13
13
|
static [Symbol.metadata]: Metadata;
|
|
14
|
-
static [$encoder]: import("./encoder/EncodeOperation").EncodeOperation<any>;
|
|
15
|
-
static [$decoder]: import("./decoder/DecodeOperation").DecodeOperation<any>;
|
|
14
|
+
static [$encoder]: import("./encoder/EncodeOperation.js").EncodeOperation<any>;
|
|
15
|
+
static [$decoder]: import("./decoder/DecodeOperation.js").DecodeOperation<any>;
|
|
16
16
|
[$refId]?: number;
|
|
17
17
|
/**
|
|
18
18
|
* Assign the property descriptors required to track changes on this instance.
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import "./symbol.shim";
|
|
2
|
-
import { Schema } from './Schema';
|
|
3
|
-
import { ArraySchema } from './types/custom/ArraySchema';
|
|
4
|
-
import { MapSchema } from './types/custom/MapSchema';
|
|
5
|
-
import { TypeDefinition } from "./types/registry";
|
|
6
|
-
import { OPERATION } from "./encoding/spec";
|
|
7
|
-
import type { InferValueType, InferSchemaInstanceType, AssignableProps } from "./types/HelperTypes";
|
|
8
|
-
import { CollectionSchema } from "./types/custom/CollectionSchema";
|
|
9
|
-
import { SetSchema } from "./types/custom/SetSchema";
|
|
1
|
+
import "./symbol.shim.js";
|
|
2
|
+
import { Schema } from './Schema.js';
|
|
3
|
+
import { ArraySchema } from './types/custom/ArraySchema.js';
|
|
4
|
+
import { MapSchema } from './types/custom/MapSchema.js';
|
|
5
|
+
import { TypeDefinition } from "./types/registry.js";
|
|
6
|
+
import { OPERATION } from "./encoding/spec.js";
|
|
7
|
+
import type { InferValueType, InferSchemaInstanceType, AssignableProps } from "./types/HelperTypes.js";
|
|
8
|
+
import { CollectionSchema } from "./types/custom/CollectionSchema.js";
|
|
9
|
+
import { SetSchema } from "./types/custom/SetSchema.js";
|
|
10
10
|
export type RawPrimitiveType = "string" | "number" | "boolean" | "int8" | "uint8" | "int16" | "uint16" | "int32" | "uint32" | "int64" | "uint64" | "float32" | "float64" | "bigint64" | "biguint64";
|
|
11
11
|
export type PrimitiveType = RawPrimitiveType | typeof Schema | object;
|
|
12
12
|
export type DefinitionType<T extends PrimitiveType = PrimitiveType> = T | T[] | {
|
|
@@ -63,7 +63,7 @@ export declare function view<T>(tag?: number): (target: T, fieldName: string) =>
|
|
|
63
63
|
export declare function unreliable<T>(target: T, field: string): void;
|
|
64
64
|
export declare function type(type: DefinitionType, options?: TypeOptions): PropertyDecorator;
|
|
65
65
|
export declare function getPropertyDescriptor(fieldCached: string, fieldIndex: number, type: DefinitionType, complexTypeKlass: TypeDefinition): {
|
|
66
|
-
get: (this: Schema) => number | ((index: number) => any) | ((index: number) => void) | (() => Schema<any>) | (<T extends Partial<Schema<any>>>(props: AssignableProps<T>) => Schema<any>) | ((jsonData: import("./
|
|
66
|
+
get: (this: Schema) => number | ((index: number) => any) | ((index: number) => void) | (() => Schema<any>) | (<T extends Partial<Schema<any>>>(props: AssignableProps<T>) => Schema<any>) | ((jsonData: import("./index.js").ToJSON<Schema<any>>) => Schema<any>) | (<K extends "~refId">(property: number | K, operation?: OPERATION) => void) | ((this: any) => import("./index.js").ToJSON<Schema<any>>) | (() => void);
|
|
67
67
|
set: (this: Schema, value: any) => void;
|
|
68
68
|
enumerable: boolean;
|
|
69
69
|
configurable: boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as ts from "typescript";
|
|
2
|
-
import { Class, Interface, Context, Enum } from "./types";
|
|
2
|
+
import { Class, Interface, Context, Enum } from "./types.js";
|
|
3
3
|
export declare function parseFiles(fileNames: string[], decoratorName?: string, context?: Context): {
|
|
4
4
|
classes: Class[];
|
|
5
5
|
interfaces: Interface[];
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { OPERATION } from "../encoding/spec";
|
|
2
|
-
import { Schema } from "../Schema";
|
|
3
|
-
import type { Ref } from "../encoder/ChangeTree";
|
|
4
|
-
import type { Decoder } from "./Decoder";
|
|
5
|
-
import { Iterator } from "../encoding/decode";
|
|
1
|
+
import { OPERATION } from "../encoding/spec.js";
|
|
2
|
+
import { Schema } from "../Schema.js";
|
|
3
|
+
import type { Ref } from "../encoder/ChangeTree.js";
|
|
4
|
+
import type { Decoder } from "./Decoder.js";
|
|
5
|
+
import { Iterator } from "../encoding/decode.js";
|
|
6
6
|
export interface DataChange<T = any, F = string> {
|
|
7
7
|
ref: Ref;
|
|
8
8
|
refId: number;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { TypeContext } from "../types/TypeContext";
|
|
2
|
-
import { Schema } from "../Schema";
|
|
3
|
-
import type { Ref } from "../encoder/ChangeTree";
|
|
4
|
-
import type { Iterator } from "../encoding/decode";
|
|
5
|
-
import { ReferenceTracker } from "./ReferenceTracker";
|
|
6
|
-
import { type DataChange } from "./DecodeOperation";
|
|
7
|
-
import { Collection } from "../types/HelperTypes";
|
|
1
|
+
import { TypeContext } from "../types/TypeContext.js";
|
|
2
|
+
import { Schema } from "../Schema.js";
|
|
3
|
+
import type { Ref } from "../encoder/ChangeTree.js";
|
|
4
|
+
import type { Iterator } from "../encoding/decode.js";
|
|
5
|
+
import { ReferenceTracker } from "./ReferenceTracker.js";
|
|
6
|
+
import { type DataChange } from "./DecodeOperation.js";
|
|
7
|
+
import { Collection } from "../types/HelperTypes.js";
|
|
8
8
|
export declare class Decoder<T extends Schema = any> {
|
|
9
9
|
context: TypeContext;
|
|
10
10
|
state: T;
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { Collection, NonFunctionPropNames } from "../../types/HelperTypes";
|
|
2
|
-
import { Ref } from "../../encoder/ChangeTree";
|
|
3
|
-
import { Decoder } from "../Decoder";
|
|
4
|
-
import { DataChange } from "../DecodeOperation";
|
|
5
|
-
import { OPERATION } from "../../encoding/spec";
|
|
6
|
-
import { Schema } from "../../Schema";
|
|
7
|
-
import { $refId } from "../../types/symbols";
|
|
8
|
-
import { MapSchema } from "../../types/custom/MapSchema";
|
|
9
|
-
import { ArraySchema } from "../../types/custom/ArraySchema";
|
|
10
|
-
import { type SchemaCallbackProxy } from "./getDecoderStateCallbacks";
|
|
1
|
+
import { Collection, NonFunctionPropNames } from "../../types/HelperTypes.js";
|
|
2
|
+
import { Ref } from "../../encoder/ChangeTree.js";
|
|
3
|
+
import { Decoder } from "../Decoder.js";
|
|
4
|
+
import { DataChange } from "../DecodeOperation.js";
|
|
5
|
+
import { OPERATION } from "../../encoding/spec.js";
|
|
6
|
+
import { Schema } from "../../Schema.js";
|
|
7
|
+
import { $refId } from "../../types/symbols.js";
|
|
8
|
+
import { MapSchema } from "../../types/custom/MapSchema.js";
|
|
9
|
+
import { ArraySchema } from "../../types/custom/ArraySchema.js";
|
|
10
|
+
import { type SchemaCallbackProxy } from "./getDecoderStateCallbacks.js";
|
|
11
11
|
type PropertyChangeCallback<K> = (currentValue: K, previousValue: K) => void;
|
|
12
12
|
type KeyValueCallback<K, V> = (key: K, value: V) => void;
|
|
13
|
+
type ValueKeyCallback<V, K> = (value: V, key: K) => void;
|
|
13
14
|
type InstanceChangeCallback = () => void;
|
|
14
15
|
type PublicPropNames<T> = Exclude<NonFunctionPropNames<T>, typeof $refId> & string;
|
|
15
16
|
type CollectionPropNames<T> = Exclude<{
|
|
@@ -17,39 +18,13 @@ type CollectionPropNames<T> = Exclude<{
|
|
|
17
18
|
}[keyof T] & string, typeof $refId>;
|
|
18
19
|
type CollectionValueType<T, K extends keyof T> = T[K] extends MapSchema<infer V, any> ? V : T[K] extends ArraySchema<infer V> ? V : T[K] extends Collection<any, infer V, any> ? V : never;
|
|
19
20
|
type CollectionKeyType<T, K extends keyof T> = T[K] extends MapSchema<any, infer Key> ? Key : T[K] extends ArraySchema<any> ? number : T[K] extends Collection<infer Key, any, any> ? Key : never;
|
|
20
|
-
/**
|
|
21
|
-
* State Callbacks handler
|
|
22
|
-
*
|
|
23
|
-
* Usage:
|
|
24
|
-
* ```ts
|
|
25
|
-
* const $ = Callbacks.get(decoder);
|
|
26
|
-
*
|
|
27
|
-
* // Listen to property changes
|
|
28
|
-
* $.listen("currentTurn", (currentValue, previousValue) => { ... });
|
|
29
|
-
*
|
|
30
|
-
* // Listen to collection additions
|
|
31
|
-
* $.onAdd("entities", (sessionId, entity) => {
|
|
32
|
-
* // Nested property listening
|
|
33
|
-
* $.listen(entity, "hp", (currentHp, previousHp) => { ... });
|
|
34
|
-
* });
|
|
35
|
-
*
|
|
36
|
-
* // Listen to collection removals
|
|
37
|
-
* $.onRemove("entities", (sessionId, entity) => { ... });
|
|
38
|
-
*
|
|
39
|
-
* // Listen to any property change on an instance
|
|
40
|
-
* $.onChange(entity, () => { ... });
|
|
41
|
-
*
|
|
42
|
-
* // Bind properties to another object
|
|
43
|
-
* $.bindTo(player, playerVisual);
|
|
44
|
-
* ```
|
|
45
|
-
*/
|
|
46
21
|
export declare class StateCallbackStrategy<TState extends Schema> {
|
|
47
22
|
protected decoder: Decoder<TState>;
|
|
48
23
|
protected uniqueRefIds: Set<number>;
|
|
49
24
|
protected isTriggering: boolean;
|
|
50
25
|
constructor(decoder: Decoder<TState>);
|
|
51
26
|
protected get callbacks(): {
|
|
52
|
-
[refId: number]: import("../ReferenceTracker").SchemaCallbacks;
|
|
27
|
+
[refId: number]: import("../ReferenceTracker.js").SchemaCallbacks;
|
|
53
28
|
};
|
|
54
29
|
protected get state(): TState;
|
|
55
30
|
protected addCallback(refId: number, operationOrProperty: OPERATION | string, handler: Function): () => void;
|
|
@@ -78,19 +53,19 @@ export declare class StateCallbackStrategy<TState extends Schema> {
|
|
|
78
53
|
/**
|
|
79
54
|
* Listen to items added to a collection on root state.
|
|
80
55
|
*/
|
|
81
|
-
onAdd<K extends CollectionPropNames<TState>>(property: K, handler:
|
|
56
|
+
onAdd<K extends CollectionPropNames<TState>>(property: K, handler: ValueKeyCallback<CollectionValueType<TState, K>, CollectionKeyType<TState, K>>, immediate?: boolean): () => void;
|
|
82
57
|
/**
|
|
83
58
|
* Listen to items added to a nested collection.
|
|
84
59
|
*/
|
|
85
|
-
onAdd<TInstance extends Schema, K extends CollectionPropNames<TInstance>>(instance: TInstance, property: K, handler:
|
|
60
|
+
onAdd<TInstance extends Schema, K extends CollectionPropNames<TInstance>>(instance: TInstance, property: K, handler: ValueKeyCallback<CollectionValueType<TInstance, K>, CollectionKeyType<TInstance, K>>, immediate?: boolean): () => void;
|
|
86
61
|
/**
|
|
87
62
|
* Listen to items removed from a collection on root state.
|
|
88
63
|
*/
|
|
89
|
-
onRemove<K extends CollectionPropNames<TState>>(property: K, handler:
|
|
64
|
+
onRemove<K extends CollectionPropNames<TState>>(property: K, handler: ValueKeyCallback<CollectionValueType<TState, K>, CollectionKeyType<TState, K>>): () => void;
|
|
90
65
|
/**
|
|
91
66
|
* Listen to items removed from a nested collection.
|
|
92
67
|
*/
|
|
93
|
-
onRemove<TInstance extends Schema, K extends CollectionPropNames<TInstance>>(instance: TInstance, property: K, handler:
|
|
68
|
+
onRemove<TInstance extends Schema, K extends CollectionPropNames<TInstance>>(instance: TInstance, property: K, handler: ValueKeyCallback<CollectionValueType<TInstance, K>, CollectionKeyType<TInstance, K>>): () => void;
|
|
94
69
|
/**
|
|
95
70
|
* Bind properties from a Schema instance to a target object.
|
|
96
71
|
* Changes will be automatically reflected on the target object.
|
|
@@ -113,13 +88,13 @@ export declare const Callbacks: {
|
|
|
113
88
|
* callbacks.listen("currentTurn", (currentValue, previousValue) => { ... });
|
|
114
89
|
*
|
|
115
90
|
* // Listen to collection additions
|
|
116
|
-
* callbacks.onAdd("entities", (
|
|
91
|
+
* callbacks.onAdd("entities", (entity, sessionId) => {
|
|
117
92
|
* // Nested property listening
|
|
118
93
|
* callbacks.listen(entity, "hp", (currentHp, previousHp) => { ... });
|
|
119
94
|
* });
|
|
120
95
|
*
|
|
121
96
|
* // Listen to collection removals
|
|
122
|
-
* callbacks.onRemove("entities", (
|
|
97
|
+
* callbacks.onRemove("entities", (entity, sessionId) => { ... });
|
|
123
98
|
*
|
|
124
99
|
* // Listen to any property change on an instance
|
|
125
100
|
* callbacks.onChange(entity, () => { ... });
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { DataChange } from "../DecodeOperation";
|
|
2
|
-
import { Decoder } from "../Decoder";
|
|
1
|
+
import { DataChange } from "../DecodeOperation.js";
|
|
2
|
+
import { Decoder } from "../Decoder.js";
|
|
3
3
|
export declare function getRawChangesCallback(decoder: Decoder, callback: (changes: DataChange[]) => void): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Collection, NonFunctionNonPrimitivePropNames, NonFunctionPropNames } from "../../types/HelperTypes";
|
|
2
|
-
import { Decoder } from "../Decoder";
|
|
3
|
-
import { Schema } from "../../Schema";
|
|
1
|
+
import { Collection, NonFunctionNonPrimitivePropNames, NonFunctionPropNames } from "../../types/HelperTypes.js";
|
|
2
|
+
import { Decoder } from "../Decoder.js";
|
|
3
|
+
import { Schema } from "../../Schema.js";
|
|
4
4
|
/**
|
|
5
5
|
* TODO: define a schema interface, which even having duplicate definitions, it could be used to get the callback proxy.
|
|
6
6
|
*
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { OPERATION } from "../encoding/spec";
|
|
2
|
-
import { Schema } from "../Schema";
|
|
3
|
-
import { $changes, $decoder, $encoder, $getByIndex, $refId, type $deleteByIndex } from "../types/symbols";
|
|
4
|
-
import type { MapSchema } from "../types/custom/MapSchema";
|
|
5
|
-
import type { ArraySchema } from "../types/custom/ArraySchema";
|
|
6
|
-
import type { CollectionSchema } from "../types/custom/CollectionSchema";
|
|
7
|
-
import type { SetSchema } from "../types/custom/SetSchema";
|
|
8
|
-
import { Root } from "./Root";
|
|
9
|
-
import { Metadata } from "../Metadata";
|
|
10
|
-
import type { EncodeOperation } from "./EncodeOperation";
|
|
11
|
-
import type { DecodeOperation } from "../decoder/DecodeOperation";
|
|
1
|
+
import { OPERATION } from "../encoding/spec.js";
|
|
2
|
+
import { Schema } from "../Schema.js";
|
|
3
|
+
import { $changes, $decoder, $encoder, $getByIndex, $refId, type $deleteByIndex } from "../types/symbols.js";
|
|
4
|
+
import type { MapSchema } from "../types/custom/MapSchema.js";
|
|
5
|
+
import type { ArraySchema } from "../types/custom/ArraySchema.js";
|
|
6
|
+
import type { CollectionSchema } from "../types/custom/CollectionSchema.js";
|
|
7
|
+
import type { SetSchema } from "../types/custom/SetSchema.js";
|
|
8
|
+
import { Root } from "./Root.js";
|
|
9
|
+
import { Metadata } from "../Metadata.js";
|
|
10
|
+
import type { EncodeOperation } from "./EncodeOperation.js";
|
|
11
|
+
import type { DecodeOperation } from "../decoder/DecodeOperation.js";
|
|
12
12
|
declare global {
|
|
13
13
|
interface Object {
|
|
14
14
|
[$changes]?: ChangeTree;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { OPERATION } from "../encoding/spec";
|
|
2
|
-
import type { ChangeTree, Ref } from "./ChangeTree";
|
|
3
|
-
import type { Encoder } from "./Encoder";
|
|
4
|
-
import type { Iterator } from "../encoding/decode";
|
|
5
|
-
import type { Metadata } from "../Metadata";
|
|
1
|
+
import { OPERATION } from "../encoding/spec.js";
|
|
2
|
+
import type { ChangeTree, Ref } from "./ChangeTree.js";
|
|
3
|
+
import type { Encoder } from "./Encoder.js";
|
|
4
|
+
import type { Iterator } from "../encoding/decode.js";
|
|
5
|
+
import type { Metadata } from "../Metadata.js";
|
|
6
6
|
export type EncodeOperation<T extends Ref = any> = (encoder: Encoder, bytes: Uint8Array, changeTree: ChangeTree<T>, index: number, operation: OPERATION, it: Iterator, isEncodeAll: boolean, hasView: boolean, metadata?: Metadata) => void;
|
|
7
7
|
export declare function encodeValue(encoder: Encoder, bytes: Uint8Array, type: any, value: any, operation: OPERATION, it: Iterator): void;
|
|
8
8
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { Schema } from "../Schema";
|
|
2
|
-
import { TypeContext } from "../types/TypeContext";
|
|
3
|
-
import type { Iterator } from "../encoding/decode";
|
|
4
|
-
import { Root } from "./Root";
|
|
5
|
-
import type { StateView } from "./StateView";
|
|
6
|
-
import type { ChangeSetName } from "./ChangeTree";
|
|
1
|
+
import type { Schema } from "../Schema.js";
|
|
2
|
+
import { TypeContext } from "../types/TypeContext.js";
|
|
3
|
+
import type { Iterator } from "../encoding/decode.js";
|
|
4
|
+
import { Root } from "./Root.js";
|
|
5
|
+
import type { StateView } from "./StateView.js";
|
|
6
|
+
import type { ChangeSetName } from "./ChangeTree.js";
|
|
7
7
|
export declare class Encoder<T extends Schema = any> {
|
|
8
8
|
static BUFFER_SIZE: number;
|
|
9
9
|
sharedBuffer: Uint8Array;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { TypeContext } from "../types/TypeContext";
|
|
2
|
-
import { ChangeTree, ChangeTreeList, ChangeSetName, type ChangeTreeNode } from "./ChangeTree";
|
|
1
|
+
import { TypeContext } from "../types/TypeContext.js";
|
|
2
|
+
import { ChangeTree, ChangeTreeList, ChangeSetName, type ChangeTreeNode } from "./ChangeTree.js";
|
|
3
3
|
export declare class Root {
|
|
4
4
|
types: TypeContext;
|
|
5
5
|
protected nextUniqueId: number;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { Schema } from "../Schema";
|
|
2
|
-
import type { CollectionSchema } from "../types/custom/CollectionSchema";
|
|
3
|
-
import type { MapSchema } from "../types/custom/MapSchema";
|
|
4
|
-
import type { SetSchema } from "../types/custom/SetSchema";
|
|
5
|
-
import type { ArraySchema } from "../types/custom/ArraySchema";
|
|
6
|
-
import type { Ref } from "../encoder/ChangeTree";
|
|
1
|
+
import type { Schema } from "../Schema.js";
|
|
2
|
+
import type { CollectionSchema } from "../types/custom/CollectionSchema.js";
|
|
3
|
+
import type { MapSchema } from "../types/custom/MapSchema.js";
|
|
4
|
+
import type { SetSchema } from "../types/custom/SetSchema.js";
|
|
5
|
+
import type { ArraySchema } from "../types/custom/ArraySchema.js";
|
|
6
|
+
import type { Ref } from "../encoder/ChangeTree.js";
|
|
7
7
|
export declare class EncodeSchemaError extends Error {
|
|
8
8
|
}
|
|
9
9
|
export declare function assertType(value: any, type: string, klass: Schema, field: string | number): void;
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
21
|
* SOFTWARE
|
|
22
22
|
*/
|
|
23
|
-
import type { BufferLike } from "./encode";
|
|
23
|
+
import type { BufferLike } from "./encode.js";
|
|
24
24
|
/**
|
|
25
25
|
* msgpack implementation highly based on notepack.io
|
|
26
26
|
* https://github.com/darrachequesne/notepack
|
|
@@ -5122,32 +5122,6 @@ function getRawChangesCallback(decoder, callback) {
|
|
|
5122
5122
|
decoder.triggerChanges = callback;
|
|
5123
5123
|
}
|
|
5124
5124
|
|
|
5125
|
-
/**
|
|
5126
|
-
* State Callbacks handler
|
|
5127
|
-
*
|
|
5128
|
-
* Usage:
|
|
5129
|
-
* ```ts
|
|
5130
|
-
* const $ = Callbacks.get(decoder);
|
|
5131
|
-
*
|
|
5132
|
-
* // Listen to property changes
|
|
5133
|
-
* $.listen("currentTurn", (currentValue, previousValue) => { ... });
|
|
5134
|
-
*
|
|
5135
|
-
* // Listen to collection additions
|
|
5136
|
-
* $.onAdd("entities", (sessionId, entity) => {
|
|
5137
|
-
* // Nested property listening
|
|
5138
|
-
* $.listen(entity, "hp", (currentHp, previousHp) => { ... });
|
|
5139
|
-
* });
|
|
5140
|
-
*
|
|
5141
|
-
* // Listen to collection removals
|
|
5142
|
-
* $.onRemove("entities", (sessionId, entity) => { ... });
|
|
5143
|
-
*
|
|
5144
|
-
* // Listen to any property change on an instance
|
|
5145
|
-
* $.onChange(entity, () => { ... });
|
|
5146
|
-
*
|
|
5147
|
-
* // Bind properties to another object
|
|
5148
|
-
* $.bindTo(player, playerVisual);
|
|
5149
|
-
* ```
|
|
5150
|
-
*/
|
|
5151
5125
|
class StateCallbackStrategy {
|
|
5152
5126
|
decoder;
|
|
5153
5127
|
uniqueRefIds = new Set();
|
|
@@ -5186,7 +5160,7 @@ class StateCallbackStrategy {
|
|
|
5186
5160
|
immediate = immediate && this.isTriggering === false;
|
|
5187
5161
|
if (operation === exports.OPERATION.ADD && immediate) {
|
|
5188
5162
|
collection.forEach((value, key) => {
|
|
5189
|
-
handler(
|
|
5163
|
+
handler(value, key);
|
|
5190
5164
|
});
|
|
5191
5165
|
}
|
|
5192
5166
|
return this.addCallback(collection[$refId], operation, handler);
|
|
@@ -5342,11 +5316,11 @@ class StateCallbackStrategy {
|
|
|
5342
5316
|
// FIXME: `previousValue` should always be available.
|
|
5343
5317
|
//
|
|
5344
5318
|
if (change.previousValue !== undefined) {
|
|
5345
|
-
// trigger onRemove (
|
|
5319
|
+
// trigger onRemove (value, key)
|
|
5346
5320
|
const deleteCallbacks = $callbacks[exports.OPERATION.DELETE];
|
|
5347
5321
|
if (deleteCallbacks) {
|
|
5348
5322
|
for (let j = deleteCallbacks.length - 1; j >= 0; j--) {
|
|
5349
|
-
deleteCallbacks[j](
|
|
5323
|
+
deleteCallbacks[j](change.previousValue, dynamicIndex);
|
|
5350
5324
|
}
|
|
5351
5325
|
}
|
|
5352
5326
|
}
|
|
@@ -5356,7 +5330,7 @@ class StateCallbackStrategy {
|
|
|
5356
5330
|
if (addCallbacks) {
|
|
5357
5331
|
this.isTriggering = true;
|
|
5358
5332
|
for (let j = addCallbacks.length - 1; j >= 0; j--) {
|
|
5359
|
-
addCallbacks[j](
|
|
5333
|
+
addCallbacks[j](change.value, dynamicIndex);
|
|
5360
5334
|
}
|
|
5361
5335
|
this.isTriggering = false;
|
|
5362
5336
|
}
|
|
@@ -5364,12 +5338,12 @@ class StateCallbackStrategy {
|
|
|
5364
5338
|
}
|
|
5365
5339
|
else if ((change.op & exports.OPERATION.ADD) === exports.OPERATION.ADD &&
|
|
5366
5340
|
change.previousValue !== change.value) {
|
|
5367
|
-
// trigger onAdd (
|
|
5341
|
+
// trigger onAdd (value, key)
|
|
5368
5342
|
const addCallbacks = $callbacks[exports.OPERATION.ADD];
|
|
5369
5343
|
if (addCallbacks) {
|
|
5370
5344
|
this.isTriggering = true;
|
|
5371
5345
|
for (let j = addCallbacks.length - 1; j >= 0; j--) {
|
|
5372
|
-
addCallbacks[j](
|
|
5346
|
+
addCallbacks[j](change.value, dynamicIndex);
|
|
5373
5347
|
}
|
|
5374
5348
|
this.isTriggering = false;
|
|
5375
5349
|
}
|
|
@@ -5403,13 +5377,13 @@ const Callbacks = {
|
|
|
5403
5377
|
* callbacks.listen("currentTurn", (currentValue, previousValue) => { ... });
|
|
5404
5378
|
*
|
|
5405
5379
|
* // Listen to collection additions
|
|
5406
|
-
* callbacks.onAdd("entities", (
|
|
5380
|
+
* callbacks.onAdd("entities", (entity, sessionId) => {
|
|
5407
5381
|
* // Nested property listening
|
|
5408
5382
|
* callbacks.listen(entity, "hp", (currentHp, previousHp) => { ... });
|
|
5409
5383
|
* });
|
|
5410
5384
|
*
|
|
5411
5385
|
* // Listen to collection removals
|
|
5412
|
-
* callbacks.onRemove("entities", (
|
|
5386
|
+
* callbacks.onRemove("entities", (entity, sessionId) => { ... });
|
|
5413
5387
|
*
|
|
5414
5388
|
* // Listen to any property change on an instance
|
|
5415
5389
|
* callbacks.onChange(entity, () => { ... });
|