@colyseus/schema 3.0.6 → 3.0.7

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.
@@ -2688,6 +2688,10 @@
2688
2688
  registerType("map", { constructor: MapSchema });
2689
2689
 
2690
2690
  const DEFAULT_VIEW_TAG = -1;
2691
+ function entity(constructor) {
2692
+ TypeContext.register(constructor);
2693
+ return constructor;
2694
+ }
2691
2695
  /**
2692
2696
  * [See documentation](https://docs.colyseus.io/state/schema/)
2693
2697
  *
@@ -4902,6 +4906,7 @@
4902
4906
  exports.encode = encode;
4903
4907
  exports.encodeKeyValueOperation = encodeArray;
4904
4908
  exports.encodeSchemaOperation = encodeSchemaOperation;
4909
+ exports.entity = entity;
4905
4910
  exports.getDecoderStateCallbacks = getDecoderStateCallbacks;
4906
4911
  exports.getRawChangesCallback = getRawChangesCallback;
4907
4912
  exports.registerType = registerType;
package/lib/index.d.ts CHANGED
@@ -17,7 +17,7 @@ export { encode } from "./encoding/encode";
17
17
  export { decode, type Iterator } from "./encoding/decode";
18
18
  export { Reflection, ReflectionType, ReflectionField, } from "./Reflection";
19
19
  export { Metadata } from "./Metadata";
20
- export { type, deprecated, defineTypes, view, schema, type SchemaWithExtends, } from "./annotations";
20
+ export { type, deprecated, defineTypes, view, schema, entity, type SchemaWithExtends, } from "./annotations";
21
21
  export { TypeContext } from "./types/TypeContext";
22
22
  export type { DefinitionType, PrimitiveType, Definition, } from "./annotations";
23
23
  export { getDecoderStateCallbacks, CallbackProxy, GetCallbackProxy } from "./decoder/strategy/StateCallbacks";
package/lib/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OPERATION = exports.decodeKeyValueOperation = exports.decodeSchemaOperation = exports.Decoder = exports.StateView = exports.ChangeTree = exports.encodeKeyValueOperation = exports.encodeSchemaOperation = exports.Encoder = exports.getRawChangesCallback = exports.getDecoderStateCallbacks = exports.TypeContext = exports.schema = exports.view = exports.defineTypes = exports.deprecated = exports.type = exports.Metadata = exports.ReflectionField = exports.ReflectionType = exports.Reflection = exports.decode = exports.encode = exports.$childType = exports.$changes = exports.$deleteByIndex = exports.$getByIndex = exports.$filter = exports.$decoder = exports.$encoder = exports.$track = exports.dumpChanges = exports.defineCustomTypes = exports.registerType = exports.SetSchema = exports.CollectionSchema = exports.ArraySchema = exports.MapSchema = exports.Schema = void 0;
3
+ exports.OPERATION = exports.decodeKeyValueOperation = exports.decodeSchemaOperation = exports.Decoder = exports.StateView = exports.ChangeTree = exports.encodeKeyValueOperation = exports.encodeSchemaOperation = exports.Encoder = exports.getRawChangesCallback = exports.getDecoderStateCallbacks = exports.TypeContext = exports.entity = exports.schema = exports.view = exports.defineTypes = exports.deprecated = exports.type = exports.Metadata = exports.ReflectionField = exports.ReflectionType = exports.Reflection = exports.decode = exports.encode = exports.$childType = exports.$changes = exports.$deleteByIndex = exports.$getByIndex = exports.$filter = exports.$decoder = exports.$encoder = exports.$track = exports.dumpChanges = exports.defineCustomTypes = exports.registerType = exports.SetSchema = exports.CollectionSchema = exports.ArraySchema = exports.MapSchema = exports.Schema = void 0;
4
4
  var Schema_1 = require("./Schema");
5
5
  Object.defineProperty(exports, "Schema", { enumerable: true, get: function () { return Schema_1.Schema; } });
6
6
  const MapSchema_1 = require("./types/custom/MapSchema");
@@ -49,6 +49,7 @@ Object.defineProperty(exports, "deprecated", { enumerable: true, get: function (
49
49
  Object.defineProperty(exports, "defineTypes", { enumerable: true, get: function () { return annotations_1.defineTypes; } });
50
50
  Object.defineProperty(exports, "view", { enumerable: true, get: function () { return annotations_1.view; } });
51
51
  Object.defineProperty(exports, "schema", { enumerable: true, get: function () { return annotations_1.schema; } });
52
+ Object.defineProperty(exports, "entity", { enumerable: true, get: function () { return annotations_1.entity; } });
52
53
  var TypeContext_1 = require("./types/TypeContext");
53
54
  Object.defineProperty(exports, "TypeContext", { enumerable: true, get: function () { return TypeContext_1.TypeContext; } });
54
55
  var StateCallbacks_1 = require("./decoder/strategy/StateCallbacks");
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mCAAkC;AAAzB,gGAAA,MAAM,OAAA;AAIf,wDAAoD;AAC3C,0FADA,qBAAS,OACA;AAElB,4DAAyD;AAChD,4FADA,yBAAW,OACA;AAEpB,sEAAmE;AAC1D,iGADA,mCAAgB,OACA;AAEzB,wDAAqD;AAC5C,0FADA,qBAAS,OACA;AAElB,+CAAmE;AAC1D,6FADA,uBAAY,OACA;AAAE,kGADA,4BAAiB,OACA;AAExC,IAAA,uBAAY,EAAC,KAAK,EAAE,EAAE,WAAW,EAAE,qBAAS,EAAE,CAAC,CAAC;AAChD,IAAA,uBAAY,EAAC,OAAO,EAAE,EAAE,WAAW,EAAE,yBAAW,EAAE,CAAC,CAAC;AACpD,IAAA,uBAAY,EAAC,KAAK,EAAE,EAAE,WAAW,EAAE,qBAAS,EAAE,CAAC,CAAC;AAChD,IAAA,uBAAY,EAAC,YAAY,EAAE,EAAE,WAAW,EAAE,mCAAgB,GAAG,CAAC,CAAC;AAE/D,QAAQ;AACR,iCAAsC;AAA7B,oGAAA,WAAW,OAAA;AAEpB,oBAAoB;AACpB,2CAAyH;AAAhH,iGAAA,MAAM,OAAA;AAAE,mGAAA,QAAQ,OAAA;AAAE,mGAAA,QAAQ,OAAA;AAAE,kGAAA,OAAO,OAAA;AAAE,sGAAA,WAAW,OAAA;AAAE,yGAAA,cAAc,OAAA;AAAE,mGAAA,QAAQ,OAAA;AAAE,qGAAA,UAAU,OAAA;AAC/F,4CAA2C;AAAlC,gGAAA,MAAM,OAAA;AACf,4CAA0D;AAAjD,gGAAA,MAAM,OAAA;AAEf,aAAa;AACb,2CAIsB;AAHlB,wGAAA,UAAU,OAAA;AACV,4GAAA,cAAc,OAAA;AACd,6GAAA,eAAe,OAAA;AAGnB,wCAAwC;AACxC,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,6CAAqG;AAA5F,mGAAA,IAAI,OAAA;AAAE,yGAAA,UAAU,OAAA;AAAE,0GAAA,WAAW,OAAA;AAAE,mGAAA,IAAI,OAAA;AAAE,qGAAA,MAAM,OAAA;AACpD,mDAAkD;AAAzC,0GAAA,WAAW,OAAA;AAKpB,oEAA8G;AAArG,0HAAA,wBAAwB,OAAA;AACjC,4DAAsE;AAA7D,mHAAA,qBAAqB,OAAA;AAE9B,6CAA4C;AAAnC,kGAAA,OAAO,OAAA;AAChB,6DAA0G;AAAjG,wHAAA,qBAAqB,OAAA;AAAE,0HAAA,WAAW,OAA2B;AACtE,mDAAuD;AAA9C,wGAAA,UAAU,OAAA;AACnB,iDAAgD;AAAvC,sGAAA,SAAS,OAAA;AAElB,6CAA4C;AAAnC,kGAAA,OAAO,OAAA;AAChB,6DAA2F;AAAlF,wHAAA,qBAAqB,OAAA;AAAE,0HAAA,uBAAuB,OAAA;AAEvD,wCAA4C;AAAnC,iGAAA,SAAS,OAAA","sourcesContent":["export { Schema } from \"./Schema\";\nexport type { DataChange } from \"./decoder/DecodeOperation\";\nexport type { ToJSON } from \"./types/HelperTypes\";\n\nimport { MapSchema } from \"./types/custom/MapSchema\"\nexport { MapSchema };\n\nimport { ArraySchema } from \"./types/custom/ArraySchema\";\nexport { ArraySchema };\n\nimport { CollectionSchema } from \"./types/custom/CollectionSchema\";\nexport { CollectionSchema };\n\nimport { SetSchema } from \"./types/custom/SetSchema\";\nexport { SetSchema };\n\nimport { registerType, defineCustomTypes } from \"./types/registry\";\nexport { registerType, defineCustomTypes };\n\nregisterType(\"map\", { constructor: MapSchema });\nregisterType(\"array\", { constructor: ArraySchema });\nregisterType(\"set\", { constructor: SetSchema });\nregisterType(\"collection\", { constructor: CollectionSchema, });\n\n// Utils\nexport { dumpChanges } from \"./utils\";\n\n// Encoder / Decoder\nexport { $track, $encoder, $decoder, $filter, $getByIndex, $deleteByIndex, $changes, $childType } from \"./types/symbols\";\nexport { encode } from \"./encoding/encode\";\nexport { decode, type Iterator } from \"./encoding/decode\";\n\n// Reflection\nexport {\n Reflection,\n ReflectionType,\n ReflectionField,\n} from \"./Reflection\";\n\n// Annotations, Metadata and TypeContext\nexport { Metadata } from \"./Metadata\";\nexport { type, deprecated, defineTypes, view, schema, type SchemaWithExtends, } from \"./annotations\";\nexport { TypeContext } from \"./types/TypeContext\";\n\n// Annotation types\nexport type { DefinitionType, PrimitiveType, Definition, } from \"./annotations\";\n\nexport { getDecoderStateCallbacks, CallbackProxy, GetCallbackProxy } from \"./decoder/strategy/StateCallbacks\";\nexport { getRawChangesCallback } from \"./decoder/strategy/RawChanges\";\n\nexport { Encoder } from \"./encoder/Encoder\";\nexport { encodeSchemaOperation, encodeArray as encodeKeyValueOperation } from \"./encoder/EncodeOperation\";\nexport { ChangeTree, Ref } from \"./encoder/ChangeTree\";\nexport { StateView } from \"./encoder/StateView\";\n\nexport { Decoder } from \"./decoder/Decoder\";\nexport { decodeSchemaOperation, decodeKeyValueOperation } from \"./decoder/DecodeOperation\";\n\nexport { OPERATION } from \"./encoding/spec\";"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mCAAkC;AAAzB,gGAAA,MAAM,OAAA;AAIf,wDAAoD;AAC3C,0FADA,qBAAS,OACA;AAElB,4DAAyD;AAChD,4FADA,yBAAW,OACA;AAEpB,sEAAmE;AAC1D,iGADA,mCAAgB,OACA;AAEzB,wDAAqD;AAC5C,0FADA,qBAAS,OACA;AAElB,+CAAmE;AAC1D,6FADA,uBAAY,OACA;AAAE,kGADA,4BAAiB,OACA;AAExC,IAAA,uBAAY,EAAC,KAAK,EAAE,EAAE,WAAW,EAAE,qBAAS,EAAE,CAAC,CAAC;AAChD,IAAA,uBAAY,EAAC,OAAO,EAAE,EAAE,WAAW,EAAE,yBAAW,EAAE,CAAC,CAAC;AACpD,IAAA,uBAAY,EAAC,KAAK,EAAE,EAAE,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AA,uBAAuB,OAAA;AAEvD,wCAA4C;AAAnC,iGAAA,SAAS,OAAA","sourcesContent":["export { Schema } from \"./Schema\";\nexport type { DataChange } from \"./decoder/DecodeOperation\";\nexport type { ToJSON } from \"./types/HelperTypes\";\n\nimport { MapSchema } from \"./types/custom/MapSchema\"\nexport { MapSchema };\n\nimport { ArraySchema } from \"./types/custom/ArraySchema\";\nexport { ArraySchema };\n\nimport { CollectionSchema } from \"./types/custom/CollectionSchema\";\nexport { CollectionSchema };\n\nimport { SetSchema } from \"./types/custom/SetSchema\";\nexport { SetSchema };\n\nimport { registerType, defineCustomTypes } from \"./types/registry\";\nexport { registerType, defineCustomTypes };\n\nregisterType(\"map\", { constructor: MapSchema });\nregisterType(\"array\", { constructor: ArraySchema });\nregisterType(\"set\", { constructor: SetSchema });\nregisterType(\"collection\", { constructor: CollectionSchema, });\n\n// Utils\nexport { dumpChanges } from \"./utils\";\n\n// Encoder / Decoder\nexport { $track, $encoder, $decoder, $filter, $getByIndex, $deleteByIndex, $changes, $childType } from \"./types/symbols\";\nexport { encode } from \"./encoding/encode\";\nexport { decode, type Iterator } from \"./encoding/decode\";\n\n// Reflection\nexport {\n Reflection,\n ReflectionType,\n ReflectionField,\n} from \"./Reflection\";\n\n// Annotations, Metadata and TypeContext\nexport { Metadata } from \"./Metadata\";\nexport { type, deprecated, defineTypes, view, schema, entity, type SchemaWithExtends, } from \"./annotations\";\nexport { TypeContext } from \"./types/TypeContext\";\n\n// Annotation types\nexport type { DefinitionType, PrimitiveType, Definition, } from \"./annotations\";\n\nexport { getDecoderStateCallbacks, CallbackProxy, GetCallbackProxy } from \"./decoder/strategy/StateCallbacks\";\nexport { getRawChangesCallback } from \"./decoder/strategy/RawChanges\";\n\nexport { Encoder } from \"./encoder/Encoder\";\nexport { encodeSchemaOperation, encodeArray as encodeKeyValueOperation } from \"./encoder/EncodeOperation\";\nexport { ChangeTree, Ref } from \"./encoder/ChangeTree\";\nexport { StateView } from \"./encoder/StateView\";\n\nexport { Decoder } from \"./decoder/Decoder\";\nexport { decodeSchemaOperation, decodeKeyValueOperation } from \"./decoder/DecodeOperation\";\n\nexport { OPERATION } from \"./encoding/spec\";"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@colyseus/schema",
3
- "version": "3.0.6",
3
+ "version": "3.0.7",
4
4
  "description": "Binary state serializer with delta encoding for games",
5
5
  "bin": {
6
6
  "schema-codegen": "./bin/schema-codegen",
package/src/index.ts CHANGED
@@ -39,7 +39,7 @@ export {
39
39
 
40
40
  // Annotations, Metadata and TypeContext
41
41
  export { Metadata } from "./Metadata";
42
- export { type, deprecated, defineTypes, view, schema, type SchemaWithExtends, } from "./annotations";
42
+ export { type, deprecated, defineTypes, view, schema, entity, type SchemaWithExtends, } from "./annotations";
43
43
  export { TypeContext } from "./types/TypeContext";
44
44
 
45
45
  // Annotation types