@colyseus/schema 3.0.0-alpha.40 → 3.0.0-alpha.41

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.
Files changed (50) hide show
  1. package/README.md +19 -3
  2. package/build/cjs/index.js +1205 -1223
  3. package/build/cjs/index.js.map +1 -1
  4. package/build/esm/index.mjs +1205 -1224
  5. package/build/esm/index.mjs.map +1 -1
  6. package/build/umd/index.js +1205 -1223
  7. package/lib/annotations.d.ts +1 -1
  8. package/lib/annotations.js.map +1 -1
  9. package/lib/codegen/languages/csharp.js +1 -44
  10. package/lib/codegen/languages/csharp.js.map +1 -1
  11. package/lib/decoder/DecodeOperation.d.ts +3 -3
  12. package/lib/decoder/DecodeOperation.js +9 -9
  13. package/lib/decoder/DecodeOperation.js.map +1 -1
  14. package/lib/decoder/Decoder.js +5 -5
  15. package/lib/decoder/Decoder.js.map +1 -1
  16. package/lib/encoder/EncodeOperation.js +7 -7
  17. package/lib/encoder/EncodeOperation.js.map +1 -1
  18. package/lib/encoder/Encoder.js +4 -4
  19. package/lib/encoder/Encoder.js.map +1 -1
  20. package/lib/encoding/assert.d.ts +5 -5
  21. package/lib/encoding/assert.js +8 -0
  22. package/lib/encoding/assert.js.map +1 -1
  23. package/lib/encoding/decode.d.ts +35 -20
  24. package/lib/encoding/decode.js +43 -86
  25. package/lib/encoding/decode.js.map +1 -1
  26. package/lib/encoding/encode.d.ts +36 -17
  27. package/lib/encoding/encode.js +49 -39
  28. package/lib/encoding/encode.js.map +1 -1
  29. package/lib/encoding/spec.d.ts +2 -4
  30. package/lib/encoding/spec.js +0 -2
  31. package/lib/encoding/spec.js.map +1 -1
  32. package/lib/index.d.ts +4 -6
  33. package/lib/index.js +6 -5
  34. package/lib/index.js.map +1 -1
  35. package/lib/types/registry.d.ts +8 -1
  36. package/lib/types/registry.js +20 -2
  37. package/lib/types/registry.js.map +1 -1
  38. package/package.json +1 -1
  39. package/src/annotations.ts +3 -1
  40. package/src/codegen/languages/csharp.ts +1 -47
  41. package/src/decoder/DecodeOperation.ts +6 -6
  42. package/src/decoder/Decoder.ts +3 -3
  43. package/src/encoder/EncodeOperation.ts +1 -1
  44. package/src/encoder/Encoder.ts +1 -1
  45. package/src/encoding/assert.ts +13 -5
  46. package/src/encoding/decode.ts +62 -97
  47. package/src/encoding/encode.ts +64 -36
  48. package/src/encoding/spec.ts +2 -5
  49. package/src/index.ts +4 -6
  50. package/src/types/registry.ts +22 -3
package/README.md CHANGED
@@ -163,7 +163,7 @@ view.add(player);
163
163
 
164
164
  ## Encoder
165
165
 
166
- There are 3 majour features of the `Encoder` class:
166
+ There are 3 major features of the `Encoder` class:
167
167
 
168
168
  - Encoding the full state
169
169
  - Encoding the state changes
@@ -233,6 +233,18 @@ const view2Encoded = this.encoder.encodeView(view2, sharedOffset, it);
233
233
  encoder.discardChanges();
234
234
  ```
235
235
 
236
+ ## Decoder
237
+
238
+ The `Decoder` class is used to decode the binary data received from the server.
239
+
240
+ ```typescript
241
+ import { Decoder } from "@colyseus/schema";
242
+
243
+ const state = new MyState();
244
+ const decoder = new Decoder(state);
245
+ decoder.decode(encodedBytes);
246
+ ```
247
+
236
248
  ### Backwards/forwards compability
237
249
 
238
250
  Backwards/fowards compatibility is possible by declaring new fields at the
@@ -283,10 +295,14 @@ schema-codegen ./schemas/State.ts --output ./haxe-project/ --haxe
283
295
  | Updating x/y of 50 entities after initial state | 342 | 684 |
284
296
  | Updating x/y of 100 entities after initial state | 668 | 1529 |
285
297
 
298
+ ## Decoder implementation in other languages
286
299
 
287
- ## Decoder implementations
300
+ Each Colyseus SDK has its own decoder implementation of the `@colyseus/schema` protocol:
288
301
 
289
- Decoders for each target language are located at [`/decoders/`](decoders). They have no third party dependencies.
302
+ - [C#](https://github.com/colyseus/colyseus-unity-sdk)
303
+ - [Haxe](https://github.com/colyseus/colyseus-haxe)
304
+ - [Lua](https://github.com/colyseus/colyseus-defold)
305
+ - [C++](https://github.com/colyseus/colyseus-cocos2d-x) _(Not up-to-date)_
290
306
 
291
307
  ## Why
292
308