@colyseus/schema 5.0.3 → 5.0.5
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/codegen/cli.cjs +23 -0
- package/build/codegen/cli.cjs.map +1 -1
- package/build/decoder/strategy/Callbacks.d.ts +6 -6
- package/build/encoder/StateView.d.ts +17 -0
- package/build/index.cjs +184 -37
- package/build/index.cjs.map +1 -1
- package/build/index.js +184 -37
- package/build/index.mjs +184 -37
- package/build/index.mjs.map +1 -1
- package/build/input/index.cjs +28 -4
- package/build/input/index.cjs.map +1 -1
- package/build/input/index.mjs +28 -4
- package/build/input/index.mjs.map +1 -1
- package/build/types/builder.d.ts +83 -29
- package/package.json +6 -5
- package/src/annotations.ts +48 -18
- package/src/codegen/languages/csharp.ts +24 -0
- package/src/decoder/strategy/Callbacks.ts +16 -14
- package/src/encoder/Encoder.ts +13 -2
- package/src/encoder/StateView.ts +63 -2
- package/src/encoder/changeTree/inheritedFlags.ts +16 -2
- package/src/types/builder.ts +82 -20
package/build/input/index.mjs
CHANGED
|
@@ -1237,11 +1237,24 @@ function checkInheritedFlags(tree, parent, parentIndex) {
|
|
|
1237
1237
|
const refType = Metadata.isValidInstance(tree.ref)
|
|
1238
1238
|
? tree.ref.constructor
|
|
1239
1239
|
: tree.ref[$childType];
|
|
1240
|
+
// #218: nested Schema fields inherit visibility from a @view-gated
|
|
1241
|
+
// parent regardless of whether the parent is a collection. The
|
|
1242
|
+
// `parentIsCollection` constraint that used to live here blocked
|
|
1243
|
+
// nested-Schema-field-of-@view-tagged-Schema from sharing visibility,
|
|
1244
|
+
// forcing users to wrap the child in an ArraySchema as a workaround.
|
|
1245
|
+
//
|
|
1246
|
+
// #226 (4.0.25): items inside a non-default-tag `@view(N)` collection
|
|
1247
|
+
// also inherit visibility from the parent collection, so items
|
|
1248
|
+
// pushed/set after `view.add(state, N)` show up automatically.
|
|
1249
|
+
// Default-tag `@view()` collections keep per-item gating —
|
|
1250
|
+
// `view.add(item)` is still required to opt each one in.
|
|
1251
|
+
// The `parentMetadata[parentIndex].tag` access is safe inside the
|
|
1252
|
+
// `fieldHasViewTag` short-circuit (the metadata entry and its `tag`
|
|
1253
|
+
// are guaranteed to exist when that flag is set).
|
|
1240
1254
|
tree.isVisibilitySharedWithParent = (parentChangeTree.isFiltered
|
|
1241
1255
|
&& typeof refType !== "string"
|
|
1242
|
-
&& !fieldHasViewTag
|
|
1243
1256
|
&& !fieldHasStream
|
|
1244
|
-
&& parentIsCollection);
|
|
1257
|
+
&& (!fieldHasViewTag || (parentIsCollection && parentMetadata[parentIndex].tag !== DEFAULT_VIEW_TAG)));
|
|
1245
1258
|
}
|
|
1246
1259
|
}
|
|
1247
1260
|
|
|
@@ -6601,8 +6614,19 @@ class Encoder {
|
|
|
6601
6614
|
// selected element is passed to `view.add()` which populates
|
|
6602
6615
|
// view.changes with the stream-link ADD + element-field ADDs.
|
|
6603
6616
|
this._emitStreamPriority(view);
|
|
6604
|
-
//
|
|
6605
|
-
|
|
6617
|
+
//
|
|
6618
|
+
// `view.changes` Map insertion order IS topological order:
|
|
6619
|
+
// - `view.add` walks the parent chain to root via `addParentOf`
|
|
6620
|
+
// (depth-first ancestor-first), inserting every ancestor's
|
|
6621
|
+
// entry before the descendant's.
|
|
6622
|
+
// - `view.remove` calls `_touchAncestorsOf` before its own
|
|
6623
|
+
// write to insert any missing ancestors at the front of the
|
|
6624
|
+
// chain — empty entries that get skipped by the size==0
|
|
6625
|
+
// check below but establish Map position.
|
|
6626
|
+
// No per-encode topo sort needed.
|
|
6627
|
+
//
|
|
6628
|
+
for (const refId of view.changes.keys()) {
|
|
6629
|
+
const changes = view.changes.get(refId);
|
|
6606
6630
|
const changeTree = this.root.changeTrees[refId];
|
|
6607
6631
|
if (changeTree === undefined) {
|
|
6608
6632
|
// detached instance, remove from view and skip.
|