@vworlds/vecs 1.0.58 → 1.0.59
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/README.md +6 -0
- package/dist/component_def.d.ts +11 -0
- package/dist/component_def.js +12 -0
- package/dist/component_def.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/modules/snapshot.js +2 -0
- package/dist/modules/snapshot.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/world/world.components.d.ts +1 -0
- package/dist/world/world.components.js +5 -0
- package/dist/world/world.components.js.map +1 -1
- package/docs/README.md +20 -16
- package/docs/components.md +26 -0
- package/docs/design-guide.md +5 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -64,6 +64,9 @@ world.progress(performance.now(), 16); // call once per frame
|
|
|
64
64
|
For synchronous world teardown and its allowed call sites, see
|
|
65
65
|
[Disposing a world](./docs/entities.md#disposing-a-world).
|
|
66
66
|
|
|
67
|
+
For local schema reflection, query [`ComponentDef`](./docs/components.md#reflecting-on-component-definitions)
|
|
68
|
+
to enumerate registered component and module entities.
|
|
69
|
+
|
|
67
70
|
System entity callbacks can inject [`Now` and `Delta`](./docs/systems.md#clock-injection) alongside
|
|
68
71
|
components to read the processing tick's timestamp and the system's accumulated tick delta.
|
|
69
72
|
|
|
@@ -94,9 +97,12 @@ Plus the [Utilities](./docs/utilities.md) guide for helper classes and the
|
|
|
94
97
|
the source under [`src/`](./src/) — read it in your IDE.
|
|
95
98
|
|
|
96
99
|
Networking is documented alongside the packages that own it:
|
|
100
|
+
[MCP hubs and linked worlds](../vecs-mcp/docs/topology.md) ·
|
|
97
101
|
[Remote procedure calls](../vecs-protocol/docs/rpc.md) ·
|
|
98
102
|
[Sessions and caller context](../vecs-server/docs/sessions.md) ·
|
|
99
103
|
[Client world](../vecs-client/docs/client-world.md).
|
|
104
|
+
For MCP inspection through an opted-in browser connection, see
|
|
105
|
+
[Browser client targets](../vecs-mcp/docs/clients.md).
|
|
100
106
|
|
|
101
107
|
## Build & Test
|
|
102
108
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local schema marker automatically attached to every registered component and
|
|
3
|
+
* module entity, including this tag's own component entity.
|
|
4
|
+
*
|
|
5
|
+
* Use `world.query("Definitions").with(ComponentDef).build()` to enumerate
|
|
6
|
+
* definitions without scanning game entities. Treat the marker as world-managed
|
|
7
|
+
* metadata: do not add or remove it yourself. It is excluded from subtree
|
|
8
|
+
* snapshots and cannot be networked.
|
|
9
|
+
*/
|
|
10
|
+
export declare class ComponentDef {
|
|
11
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local schema marker automatically attached to every registered component and
|
|
3
|
+
* module entity, including this tag's own component entity.
|
|
4
|
+
*
|
|
5
|
+
* Use `world.query("Definitions").with(ComponentDef).build()` to enumerate
|
|
6
|
+
* definitions without scanning game entities. Treat the marker as world-managed
|
|
7
|
+
* metadata: do not add or remove it yourself. It is excluded from subtree
|
|
8
|
+
* snapshots and cannot be networked.
|
|
9
|
+
*/
|
|
10
|
+
export class ComponentDef {
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=component_def.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component_def.js","sourceRoot":"","sources":["../src/component_def.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,OAAO,YAAY;CAAG"}
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export type { ClockInject, ComponentInjectElement, ComponentInjectTuple, Compone
|
|
|
7
7
|
export { DEFAULT_POOLS, World, type WorldOptions } from "./world/index.js";
|
|
8
8
|
export { WorldStats, type Timing, type SystemTiming, type OperationTiming } from "./world/stats.js";
|
|
9
9
|
export { Filter } from "./filter.js";
|
|
10
|
+
export { ComponentDef } from "./component_def.js";
|
|
10
11
|
export { ChildOf, DependsOn, Exclusive, OneOf, OwnedTarget, SilenceSource, } from "./modules/relationships.js";
|
|
11
12
|
export { CleanupPolicy, Component, Implements, Relationship, type ComponentInstance, type ComponentClass, type ComponentMeta, type ComponentRef, type CustomSnapshotOptions, type HookEvent, type HookEventMap, type HookHandler, type TargetHandler, } from "./component.js";
|
|
12
13
|
export { Entity, type EID, type EntityClass, Identity } from "./entity/index.js";
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,7 @@ export { Delta, Iter, Now } from "./inject.js";
|
|
|
4
4
|
export { DEFAULT_POOLS, World } from "./world/index.js";
|
|
5
5
|
export { WorldStats } from "./world/stats.js";
|
|
6
6
|
export { Filter } from "./filter.js";
|
|
7
|
+
export { ComponentDef } from "./component_def.js";
|
|
7
8
|
export { ChildOf, DependsOn, Exclusive, OneOf, OwnedTarget, SilenceSource, } from "./modules/relationships.js";
|
|
8
9
|
export { CleanupPolicy, Component, Implements, Relationship, } from "./component.js";
|
|
9
10
|
export { Entity, Identity } from "./entity/index.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAA6C,MAAM,aAAa,CAAC;AAEhF,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAE9D,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAmB/C,OAAO,EAAE,aAAa,EAAE,KAAK,EAAqB,MAAM,kBAAkB,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAwD,MAAM,kBAAkB,CAAC;AACpG,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EACL,OAAO,EACP,SAAS,EACT,SAAS,EACT,KAAK,EACL,WAAW,EACX,aAAa,GACd,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,aAAa,EACb,SA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c,GACf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,IAAI,EAAoC,MAAM,iBAAiB,CAAC;AACzE,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,GAEf,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAuC,MAAM,kBAAkB,CAAC;AAC/E,OAAO,EAAE,4BAA4B,EAAqB,MAAM,mBAAmB,CAAC"}
|
package/dist/modules/snapshot.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// `snapshot_types.ts`, which is dependency-light on purpose: `component.ts`
|
|
4
4
|
// imports it, so it must not reach back through `module.ts`.
|
|
5
5
|
import { Module } from "../module.js";
|
|
6
|
+
import { ComponentDef } from "../component_def.js";
|
|
6
7
|
import { Query } from "../query/index.js";
|
|
7
8
|
import { System } from "../system.js";
|
|
8
9
|
import { Exclusive, OneOf } from "./relationship_types.js";
|
|
@@ -40,6 +41,7 @@ export class SnapshotModule extends Module {
|
|
|
40
41
|
onSnapshot.add(Exclusive);
|
|
41
42
|
world.component(Query).snapshotPolicy(DontSnapshot);
|
|
42
43
|
world.component(System).snapshotPolicy(DontSnapshot);
|
|
44
|
+
world.component(ComponentDef).snapshotPolicy(DontSnapshot);
|
|
43
45
|
}
|
|
44
46
|
}
|
|
45
47
|
//# sourceMappingURL=snapshot.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snapshot.js","sourceRoot":"","sources":["../../src/modules/snapshot.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,gEAAgE;AAChE,4EAA4E;AAC5E,6DAA6D;AAE7D,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE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package.json
CHANGED
|
@@ -11,6 +11,7 @@ export declare class Components extends Entities {
|
|
|
11
11
|
* and its id is drawn from the `"component"` id pool (1–899 by default).
|
|
12
12
|
* Subsequent calls with the same class return the same entity. The same class
|
|
13
13
|
* may be registered independently in multiple worlds.
|
|
14
|
+
* Every registered definition carries the local-only `ComponentDef` tag.
|
|
14
15
|
* A newly registered definition inherits the current scope parent immediately.
|
|
15
16
|
* Scopes must be entered outside deferred mode. Existing lookups do not reparent it.
|
|
16
17
|
*
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Component } from "../component.js";
|
|
2
|
+
import { ComponentDef } from "../component_def.js";
|
|
2
3
|
import { Entities } from "./world.entities.js";
|
|
3
4
|
const RESERVED_EID = 0;
|
|
4
5
|
export class Components extends Entities {
|
|
@@ -71,6 +72,10 @@ export class Components extends Entities {
|
|
|
71
72
|
const component = new Constructor(this, ceid, ComponentClass);
|
|
72
73
|
this._entities.set(ceid, component);
|
|
73
74
|
this._classRegistry.set(ComponentClass, component);
|
|
75
|
+
// Publish the class before resolving the marker: its own registration then
|
|
76
|
+
// finds itself, so bootstrap needs neither a special id nor a second pass.
|
|
77
|
+
this.component(ComponentDef);
|
|
78
|
+
component.add(ComponentDef);
|
|
74
79
|
const parent = this._scope;
|
|
75
80
|
if (parent !== undefined) {
|
|
76
81
|
component.childOf(parent);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"world.components.js","sourceRoot":"","sources":["../../src/world/world.components.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA2C,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"world.components.js","sourceRoot":"","sources":["../../src/world/world.components.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA2C,MAAM,iBAAiB,CAAC;AACrF,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGnD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAG/C,MA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AS,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;QAC5B,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC3B,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACzB,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAC5B,CAAC;QACD,wEAAwE;QACxE,sEAAsE;QACtE,6CAA6C;QAC7C,IAAI,CAAC,oBAAoB,CAAC,SAA8B,CAAC,CAAC;QAC1D,OAAO,SAAS,CAAC;IACnB,CAAC;CACF"}
|
package/docs/README.md
CHANGED
|
@@ -15,7 +15,8 @@ Read in this order the first time through:
|
|
|
15
15
|
routing. Read this before designing anything non-trivial.
|
|
16
16
|
4. Subsystem guides, in any order:
|
|
17
17
|
- [Components](./components.md) — registration, hooks, traits, exclusivity, cleanup policies,
|
|
18
|
-
interfaces, singletons,
|
|
18
|
+
interfaces, singletons, [definition reflection with ComponentDef](./components.md#reflecting-on-component-definitions),
|
|
19
|
+
and [registration provenance](./components.md#registration-provenance).
|
|
19
20
|
- [Entities](./entities.md) — creation, lookup, the component API, relationship targets, lifecycle,
|
|
20
21
|
[synchronous world disposal and allowed call sites](./entities.md#disposing-a-world).
|
|
21
22
|
- [Systems](./systems.md) — membership, reactive callbacks, callback options, `each`/`run`, cadence,
|
|
@@ -43,21 +44,21 @@ For Node clients that need replicated Phaser poses, see [Headless clients](../..
|
|
|
43
44
|
For physics integration, see the [post-step pose-change view](../../vecs-physics/docs/queries.md#pose-changes)
|
|
44
45
|
after reading the execution-model and systems guides.
|
|
45
46
|
|
|
46
|
-
| Guide | Covers
|
|
47
|
-
| -------------------------------------------------- |
|
|
48
|
-
| [getting-started.md](./getting-started.md) | A runnable tutorial from `npm install` to a ticking world.
|
|
49
|
-
| [concepts.md](./concepts.md) | The core vocabulary and how the pieces relate, including the shared `Vec2` type.
|
|
50
|
-
| [execution-model.md](./execution-model.md) | `world.progress`, the 8 built-in phases, deferred commands, flush boundaries, event routing.
|
|
51
|
-
| [components.md](./components.md) | Component registration/provenance, hooks, traits, exclusivity, cleanup, aliases, and singletons.
|
|
52
|
-
| [entities.md](./entities.md) | Entity creation, mutation, relationship targets, lifecycle, disposal, deferred reads.
|
|
53
|
-
| [systems.md](./systems.md) | `world.system`, callbacks, injection, ordering, cadence, introspection of callbacks and watches, and opt-in timing.
|
|
54
|
-
| [queries-and-filters.md](./queries-and-filters.md) | `QueryDSL`, `Query`, `Filter`, `groupBy`, `ignoreSource`.
|
|
55
|
-
| [relationships.md](./relationships.md) | Relationships, target creation, projection and ownership, hierarchy, traversal, and cleanup.
|
|
56
|
-
| [modules.md](./modules.md) | `Module<Config>`, `world.module`, `world.scope`, hierarchy provenance, built-in modules.
|
|
57
|
-
| [snapshots.md](./snapshots.md) | `snapshotSubtree`, `restoreSubtree`, `moveSubtree`, and `OnSnapshot` capture policies.
|
|
58
|
-
| [design-guide.md](./design-guide.md) | Patterns, anti-patterns, and a Phaser render-layer case study.
|
|
59
|
-
| [utilities.md](./utilities.md) | Public helper classes: `Events`, `ArrayMap`, `IterableArrayMap`, plus `Bitset` cross-ref.
|
|
60
|
-
| [glossary.md](./glossary.md) | ECS and vecs terminology.
|
|
47
|
+
| Guide | Covers |
|
|
48
|
+
| -------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
|
|
49
|
+
| [getting-started.md](./getting-started.md) | A runnable tutorial from `npm install` to a ticking world. |
|
|
50
|
+
| [concepts.md](./concepts.md) | The core vocabulary and how the pieces relate, including the shared `Vec2` type. |
|
|
51
|
+
| [execution-model.md](./execution-model.md) | `world.progress`, the 8 built-in phases, deferred commands, flush boundaries, event routing. |
|
|
52
|
+
| [components.md](./components.md) | Component registration/provenance, definition reflection, hooks, traits, exclusivity, cleanup, aliases, and singletons. |
|
|
53
|
+
| [entities.md](./entities.md) | Entity creation, mutation, relationship targets, lifecycle, disposal, deferred reads. |
|
|
54
|
+
| [systems.md](./systems.md) | `world.system`, callbacks, injection, ordering, cadence, introspection of callbacks and watches, and opt-in timing. |
|
|
55
|
+
| [queries-and-filters.md](./queries-and-filters.md) | `QueryDSL`, `Query`, `Filter`, `groupBy`, `ignoreSource`. |
|
|
56
|
+
| [relationships.md](./relationships.md) | Relationships, target creation, projection and ownership, hierarchy, traversal, and cleanup. |
|
|
57
|
+
| [modules.md](./modules.md) | `Module<Config>`, `world.module`, `world.scope`, hierarchy provenance, built-in modules. |
|
|
58
|
+
| [snapshots.md](./snapshots.md) | `snapshotSubtree`, `restoreSubtree`, `moveSubtree`, and `OnSnapshot` capture policies. |
|
|
59
|
+
| [design-guide.md](./design-guide.md) | Patterns, anti-patterns, and a Phaser render-layer case study. |
|
|
60
|
+
| [utilities.md](./utilities.md) | Public helper classes: `Events`, `ArrayMap`, `IterableArrayMap`, plus `Bitset` cross-ref. |
|
|
61
|
+
| [glossary.md](./glossary.md) | ECS and vecs terminology. |
|
|
61
62
|
|
|
62
63
|
Networking (wire encoding with `@wireType`, protocol component ordering, replication, RPCs, server
|
|
63
64
|
sessions, and the client world) lives in the `@vworlds/vecs-wire`, `@vworlds/vecs-protocol`,
|
|
@@ -72,3 +73,6 @@ sessions, and the client world) lives in the `@vworlds/vecs-wire`, `@vworlds/vec
|
|
|
72
73
|
query membership, acknowledged content, and the replicated-state render clock.
|
|
73
74
|
- [Client world](../../vecs-client/docs/client-world.md) — replication, render time,
|
|
74
75
|
`invoke`/`listen`, and disposal.
|
|
76
|
+
- [Browser client targets](../../vecs-mcp/docs/clients.md) — opt-in MCP access through
|
|
77
|
+
the vecs connection, macrotask execution and replication caveats.
|
|
78
|
+
- [MCP nodes and links](../../vecs-mcp/docs/topology.md) — join worlds to a hub or mount remote nodes.
|
package/docs/components.md
CHANGED
|
@@ -55,6 +55,32 @@ same class return the same entity. The same class can be registered independentl
|
|
|
55
55
|
worlds — metadata is world-specific. Passing an explicit id for an already-registered class (with
|
|
56
56
|
a different id) throws, as does passing a name with no matching component entity.
|
|
57
57
|
|
|
58
|
+
### Reflecting on component definitions
|
|
59
|
+
|
|
60
|
+
Use the built-in `ComponentDef` tag to query registered definitions rather than scanning every
|
|
61
|
+
entity with an `instanceof Component` predicate:
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
import { ComponentDef, World } from "@vworlds/vecs";
|
|
65
|
+
|
|
66
|
+
const world = new World();
|
|
67
|
+
const definitions = world.query("Definitions").with(ComponentDef).build();
|
|
68
|
+
for (const definition of definitions) {
|
|
69
|
+
console.log(definition.meta.Class.name);
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Every registered component and module entity carries the tag, including built-ins and
|
|
74
|
+
`ComponentDef` itself. The query tracks later registrations and destroyed definitions incrementally;
|
|
75
|
+
iterating it visits definitions only, not ordinary game, query, system, or phase entities.
|
|
76
|
+
Registration adds one tag per class; worlds that never query it need no reflection query.
|
|
77
|
+
|
|
78
|
+
Treat `ComponentDef` as world-managed schema metadata: do not add or remove it yourself.
|
|
79
|
+
Its `DontSnapshot` policy excludes it from subtree snapshots, and `NetworkWorld` rejects it in
|
|
80
|
+
`networkComponents`. Each destination world tags its own locally registered definitions instead.
|
|
81
|
+
Component entities themselves remain invalid subtree snapshot roots. The tag does not change
|
|
82
|
+
[world disposal priorities](./entities.md#disposing-a-world).
|
|
83
|
+
|
|
58
84
|
### Registration provenance
|
|
59
85
|
|
|
60
86
|
Components created during a module's `init` become its `ChildOf` children, through
|
package/docs/design-guide.md
CHANGED
|
@@ -160,6 +160,11 @@ in registration order and are removed with `off(event, handler)` by reference (s
|
|
|
160
160
|
|
|
161
161
|
### Component traits: policy on component entities
|
|
162
162
|
|
|
163
|
+
For schema reflection, query the built-in `ComponentDef` marker with
|
|
164
|
+
`world.query("Definitions").with(ComponentDef).build()` rather than scanning all entities with
|
|
165
|
+
`instanceof Component`. See [Reflecting on component definitions](./components.md#reflecting-on-component-definitions)
|
|
166
|
+
for membership and local-only snapshot/network behavior.
|
|
167
|
+
|
|
163
168
|
A registered component is also an entity. Components attached to that component entity can declare
|
|
164
169
|
policy for every use of the component type; these configuration components are **component traits**:
|
|
165
170
|
|