@oasys/oecs 0.5.0 → 0.5.1
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/CHANGELOG.md +84 -1
- package/README.md +11 -7
- package/dist/core/ecs/archetype.d.cts +3 -3
- package/dist/core/ecs/archetype.d.ts +3 -3
- package/dist/core/ecs/component.d.cts +25 -0
- package/dist/core/ecs/component.d.ts +25 -0
- package/dist/core/ecs/component.d.ts.map +1 -1
- package/dist/core/ecs/ecs.d.cts +67 -49
- package/dist/core/ecs/ecs.d.ts +67 -49
- package/dist/core/ecs/ecs.d.ts.map +1 -1
- package/dist/core/ecs/entity.d.cts +1 -1
- package/dist/core/ecs/entity.d.ts +1 -1
- package/dist/core/ecs/facades.d.cts +1 -1
- package/dist/core/ecs/facades.d.ts +1 -1
- package/dist/core/ecs/host_commands.d.cts +30 -20
- package/dist/core/ecs/host_commands.d.ts +30 -20
- package/dist/core/ecs/host_commands.d.ts.map +1 -1
- package/dist/core/ecs/index.d.cts +3 -3
- package/dist/core/ecs/index.d.ts +3 -3
- package/dist/core/ecs/index.d.ts.map +1 -1
- package/dist/core/ecs/observer.d.cts +1 -1
- package/dist/core/ecs/observer.d.ts +1 -1
- package/dist/core/ecs/observer.d.ts.map +1 -1
- package/dist/core/ecs/query.d.cts +22 -6
- package/dist/core/ecs/query.d.ts +22 -6
- package/dist/core/ecs/query.d.ts.map +1 -1
- package/dist/core/ecs/ref.d.ts.map +1 -1
- package/dist/core/ecs/run_condition.d.cts +1 -1
- package/dist/core/ecs/run_condition.d.ts +1 -1
- package/dist/core/ecs/run_condition.d.ts.map +1 -1
- package/dist/core/ecs/store.d.cts +10 -23
- package/dist/core/ecs/store.d.ts +10 -23
- package/dist/core/ecs/store.d.ts.map +1 -1
- package/dist/dev_flag.d.cts +0 -15
- package/dist/dev_flag.d.ts +0 -15
- package/dist/dev_flag.d.ts.map +1 -1
- package/dist/extensions/editor/editor.d.cts +31 -29
- package/dist/extensions/editor/editor.d.ts +31 -29
- package/dist/extensions/editor/editor.d.ts.map +1 -1
- package/dist/extensions/editor/field_handle.d.cts +3 -3
- package/dist/extensions/editor/field_handle.d.ts +3 -3
- package/dist/extensions/editor/field_handle.d.ts.map +1 -1
- package/dist/extensions/editor/index.cjs +1 -1
- package/dist/extensions/editor/index.js +53 -51
- package/dist/{host_commands-i4cAeyL5.js → host_commands-BI8pEmjH.js} +26 -18
- package/dist/{host_commands-BF8QMi3c.cjs → host_commands-CxhpzMx9.cjs} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +269 -214
- package/dist/internal.cjs +1 -1
- package/dist/internal.js +1 -1
- package/dist/version.d.cts +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,90 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.5.1] — 2026-07-06
|
|
9
|
+
|
|
10
|
+
### Changed (breaking) — one attach grammar
|
|
11
|
+
|
|
12
|
+
`addComponents` and `template` now take the same callable-bundle varargs as `spawnBundle`
|
|
13
|
+
and `ctx.commands.spawn` / `add`, replacing the `{ def, values }[]` entry-object array — one
|
|
14
|
+
grammar across every authoring surface:
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
// before
|
|
18
|
+
ecs.addComponents(e, [{ def: Pos, values: { x, y } }, { def: Vel, values: { vx } }]);
|
|
19
|
+
const Bullet = ecs.template([{ def: Pos, values: { x: 0, y: 0 } }]);
|
|
20
|
+
// after
|
|
21
|
+
ecs.addComponents(e, Pos({ x, y }), Vel({ vx }));
|
|
22
|
+
const Bullet = ecs.template(Pos({ x: 0, y: 0 }));
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
To migrate: drop the array brackets, wrap a valued entry in its def's call
|
|
26
|
+
(`{ def: X, values: V }` → `X(V)`), and leave a bare entry bare (`{ def: X }` → `X`).
|
|
27
|
+
|
|
28
|
+
- Each item is schema-checked against its **own** def via the `StrictBundles` mapped tuple
|
|
29
|
+
(`{ [K in keyof Items]: … }`) — a misspelled or cross-component field, including a
|
|
30
|
+
hand-written raw `{ def, values }` literal, is a compile error. `spawnBundle` gains this
|
|
31
|
+
per-item checking (it previously had none).
|
|
32
|
+
- `ctx.commands.spawn` / `ctx.commands.add` now schema-check their bundle values in
|
|
33
|
+
declared-access systems as well (the `DeclaredBundleOrDef` type distributes over the
|
|
34
|
+
declared add set); a permissive / `exclusive` context stays loose, as before.
|
|
35
|
+
- The `TemplateEntry` / `TemplateEntries` public types are removed (they encoded the retired
|
|
36
|
+
entry-object grammar). The host command seam (`HostCommandQueue.spawn` — the record/replay
|
|
37
|
+
and editor-undo transport) deliberately keeps its entry-object + complete-values shape.
|
|
38
|
+
|
|
39
|
+
### Changed — API vocabulary consistency
|
|
40
|
+
|
|
41
|
+
Cheap alignments from a public-API vocabulary audit that followed the grammar unification:
|
|
42
|
+
|
|
43
|
+
- `removeComponents(e, ...defs)` is now varargs, mirroring `addComponents` (was
|
|
44
|
+
`removeComponents(e, defs[])`).
|
|
45
|
+
- `HostCommandQueue.pending()` is now a `pending` getter (matching every other count accessor).
|
|
46
|
+
- `ReadonlyEntityIdArray` → `ReadonlyEntityIDArray` (acronym casing, matching `EntityID`).
|
|
47
|
+
- The entity-id parameter is now uniformly `entityId` across the core surface (ECS lifecycle,
|
|
48
|
+
host-command queue, `ObserverFn`); the `HostCommand` wire-format field stays `eid`.
|
|
49
|
+
- Source-compatible widenings: `ecs.despawn`, `ecs.removeSystem`, and the `HostCommandQueue`
|
|
50
|
+
mutators now return `this` for chaining.
|
|
51
|
+
|
|
52
|
+
The `ref` / `refRead` argument order was reviewed and **deliberately kept** def-first
|
|
53
|
+
(`ctx.ref(def, entityId)`): these are the outside-iteration members of the `cols.mut` /
|
|
54
|
+
`cols.read` column-cursor family, so def-first is the cursor convention, not an inconsistency
|
|
55
|
+
to fix — flipping it would align with `getField` while breaking alignment with `cols.mut`.
|
|
56
|
+
Documented as such (`refs.md`, `queries.md`) rather than flipped.
|
|
57
|
+
|
|
58
|
+
### Changed (breaking) — host-write-seam verb grammar
|
|
59
|
+
|
|
60
|
+
The host-write-seam handles are namespaced command buffers, so they drop the component noun
|
|
61
|
+
to match `ctx.commands.add` / `remove` — and their own already-bare
|
|
62
|
+
`spawn`/`despawn`/`disable`/`enable`/`setField`:
|
|
63
|
+
|
|
64
|
+
- `HostCommandQueue.addComponent` / `removeComponent` → `add` / `remove`.
|
|
65
|
+
- `Editor` and `TransactionBuilder` `.addComponent` / `.removeComponent` → `add` / `remove`
|
|
66
|
+
(the two surfaces are designed to match, so they move together).
|
|
67
|
+
- The editor extension's entity-id parameters and its `FieldReader` type now read `entityId`,
|
|
68
|
+
completing the core's `eid` → `entityId` pass.
|
|
69
|
+
|
|
70
|
+
The wire-format `kind` discriminants (`"add_component"` / `"remove_component"`), the ring
|
|
71
|
+
codecs, and the `HostCommand` record's `eid` field are unchanged — transport vocabulary.
|
|
72
|
+
|
|
73
|
+
### Changed (breaking) — `ctx.getResource`
|
|
74
|
+
|
|
75
|
+
The in-system resource getter is now `ctx.getResource(key)` (was the verb-less `ctx.resource(key)`),
|
|
76
|
+
matching its flat-surface siblings `setResource` / `removeResource` / `hasResource` and the
|
|
77
|
+
`getField` / `setField` / `hasComponent` convention. The rule is now explicit: the flat `ctx`
|
|
78
|
+
surface verbs every accessor; the grouped `ecs.resources` facade drops the noun (`get` / `set` /
|
|
79
|
+
`remove` / `has`) because its receiver already names it. `ConditionContext` (run-condition
|
|
80
|
+
predicates) moves in lockstep.
|
|
81
|
+
|
|
82
|
+
### Fixed
|
|
83
|
+
|
|
84
|
+
- The immediate host spawn family (`spawn` / `spawnBundle` / `spawnMany`) now throws in DEV
|
|
85
|
+
when called from inside a system body — redirecting to `ctx.commands.spawn` — like every
|
|
86
|
+
other immediate host structural mutator. Previously it was silently unguarded (the archetype
|
|
87
|
+
iteration guard does not cover the append path), a live mid-iteration footgun; its guard
|
|
88
|
+
docstring's "one rule for every host mutator" claim is now true.
|
|
89
|
+
- Added explicit public `QueryCache` cache-map type annotations so JSR publish passes
|
|
90
|
+
slow-type validation and can generate package declarations cleanly.
|
|
91
|
+
|
|
8
92
|
## [0.5.0] — 2026-07-06
|
|
9
93
|
|
|
10
94
|
### Changed (breaking) — lifecycle & naming unification
|
|
@@ -27,7 +111,6 @@ rename/removal map:
|
|
|
27
111
|
| `sourcesOf(def, tgt)` | `sourcesOf(tgt, def)` — matches `targetOf` / `targetsOf` |
|
|
28
112
|
| `query.count()` | `query.entityCount` (getter, beside `archetypeCount`) |
|
|
29
113
|
| `WorldRestoreError` / `WORLD_SNAPSHOT_VERSION` | `ECSRestoreError` / `ECS_SNAPSHOT_VERSION` |
|
|
30
|
-
| `DestroyEntityArg` (type) | `DespawnArg` |
|
|
31
114
|
|
|
32
115
|
- **Host `despawn` is immediate** — `ecs.despawn(e); ecs.isAlive(e)` is `false` on the next
|
|
33
116
|
line, closing the audit's M1 finding (host `addComponent` immediate but destroy buffered).
|
package/README.md
CHANGED
|
@@ -114,13 +114,14 @@ ecs.getField(e, Pos, "x"); // ≈ 1.667
|
|
|
114
114
|
**Structural changes**
|
|
115
115
|
|
|
116
116
|
- **Deferred inside systems, immediate on the host** — `ctx.commands` (a Bevy-`Commands`-style
|
|
117
|
-
facade) buffers
|
|
118
|
-
|
|
117
|
+
facade) buffers add / remove / despawn / enable / disable until the phase flush, so iterators
|
|
118
|
+
stay valid (`commands.spawn` returns the id immediately; its component attaches are deferred). Every host-side mutation (`ecs.addComponent` / `removeComponent` /
|
|
119
119
|
`despawn` / `disable` / `enable`) applies immediately.
|
|
120
120
|
- **Entity enable/disable** — `disable` / `enable` / `isDisabled`; disabled rows sit in a partitioned
|
|
121
121
|
tail and are skipped by default queries.
|
|
122
|
-
- **Templates & bundles** — `ecs.template(
|
|
123
|
-
`spawnMany` for zero-transition spawns;
|
|
122
|
+
- **Templates & bundles** — `ecs.template(Pos({ x, y }), …)` blueprints consumed by `spawn` /
|
|
123
|
+
`spawnMany` for zero-transition spawns; the same callable-bundle varargs drive `spawnBundle(...)`
|
|
124
|
+
and `addComponents(...)`.
|
|
124
125
|
|
|
125
126
|
**Reactivity & relationships**
|
|
126
127
|
|
|
@@ -139,8 +140,8 @@ ecs.getField(e, Pos, "x"); // ≈ 1.667
|
|
|
139
140
|
|
|
140
141
|
**Determinism, persistence & integration**
|
|
141
142
|
|
|
142
|
-
- **Determinism** (opt-in) — `new ECS({ deterministic: true })`, then `ecs.snapshots.stateHash()` (FNV-1a
|
|
143
|
-
live dense bytes, sparse stores, and multi-relation target sets), `ecs.snapshots.capture()` /
|
|
143
|
+
- **Determinism** (opt-in) — `new ECS({ deterministic: true })`, then `ecs.snapshots.stateHash()` (an FNV-1a-style
|
|
144
|
+
32-bit digest over live dense bytes, sparse stores, and multi-relation target sets), `ecs.snapshots.capture()` /
|
|
144
145
|
`ecs.snapshots.restore(...)`, plus sparse variants. Backing-agnostic: a heap world and a shared world with identical history produce
|
|
145
146
|
identical hashes.
|
|
146
147
|
- **Host → ECS write seam** — `installHostCommandSeam(ecs)` applies typed `HostCommand`s off-schedule
|
|
@@ -174,13 +175,16 @@ The core is `@oasys/oecs`; everything else is opt-in and costs nothing until imp
|
|
|
174
175
|
| `@oasys/oecs/editor` | undo/redo + field-handle layer over the host-write seam |
|
|
175
176
|
| `@oasys/oecs/solid` | SolidJS adapter (`solid-js` is an **optional** peer dependency) |
|
|
176
177
|
| `@oasys/oecs/primitives` | the standalone data structures oecs is built on |
|
|
178
|
+
| `@oasys/oecs/internal` | unstable internals (codecs, ABI constants, access checker) — **no semver guarantees** |
|
|
177
179
|
|
|
178
180
|
## Dev vs prod
|
|
179
181
|
|
|
180
182
|
A compile-time `__DEV__` flag gates every runtime check — bounds and liveness checks, duplicate-system
|
|
181
183
|
detection, registration validation, and the system access checker (`reads`/`writes`). These are
|
|
182
184
|
**tree-shaken out of production builds**, so treat "throws in dev" as a development tripwire, not a
|
|
183
|
-
production guarantee.
|
|
185
|
+
production guarantee. (Raw-source consumers — JSR/Deno — get `__DEV__ = true` by default; set
|
|
186
|
+
`globalThis.__DEV__ = false` to opt out.) The scheduler's cycle detection and constructor-option
|
|
187
|
+
validation (timestep, memory options, relation cardinality) are always active.
|
|
184
188
|
|
|
185
189
|
## Documentation
|
|
186
190
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Brand, AnyTypedArray, ColumnBacking, TypedArrayTag, BitSet } from '../../type_primitives/index.cjs';
|
|
2
2
|
import { ColumnStore } from '../store/column_store.cjs';
|
|
3
3
|
import { ComponentID, ComponentDef, ComponentSchema, SchemaOf, DeclaredQueryTerm, TagToTypedArray, ColumnsForSchema, MutableColumnsForSchema, ReadonlyColumn } from './component.cjs';
|
|
4
|
-
import { EntityID,
|
|
4
|
+
import { EntityID, ReadonlyEntityIDArray } from './entity.cjs';
|
|
5
5
|
export type ArchetypeID = Brand<number, "archetype_id">;
|
|
6
6
|
export declare const asArchetypeId: (value: number) => ArchetypeID;
|
|
7
7
|
export interface ArchetypeEdge {
|
|
@@ -86,7 +86,7 @@ export interface ArchetypeView<out Defs extends readonly ComponentDef<any>[] = r
|
|
|
86
86
|
readonly disabledCount: number;
|
|
87
87
|
/** Raw entity ID buffer (packed `EntityID`s). Valid data at indices
|
|
88
88
|
* 0..totalCount-1 (enabled rows first, then disabled). */
|
|
89
|
-
readonly entityIds:
|
|
89
|
+
readonly entityIds: ReadonlyEntityIDArray;
|
|
90
90
|
/** True if this archetype's mask includes the given component. */
|
|
91
91
|
hasComponent(id: ComponentID): boolean;
|
|
92
92
|
/** Get a single field's column (read-only). Valid data: indices
|
|
@@ -243,7 +243,7 @@ export declare class Archetype implements ArchetypeView {
|
|
|
243
243
|
get disabledCount(): number;
|
|
244
244
|
/** Raw entity ID buffer (packed `EntityID`s). Valid data at indices
|
|
245
245
|
* 0..totalCount-1 (enabled rows first, then disabled). */
|
|
246
|
-
get entityIds():
|
|
246
|
+
get entityIds(): ReadonlyEntityIDArray;
|
|
247
247
|
/**
|
|
248
248
|
* Swap the two rows `a` and `b` — entity ids and every column. Does NOT touch
|
|
249
249
|
* `entityRow`; the caller updates the entity→row map for whichever rows it
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Brand, AnyTypedArray, ColumnBacking, TypedArrayTag, BitSet } from '../../type_primitives/index.js';
|
|
2
2
|
import { ColumnStore } from '../store/column_store.js';
|
|
3
3
|
import { ComponentID, ComponentDef, ComponentSchema, SchemaOf, DeclaredQueryTerm, TagToTypedArray, ColumnsForSchema, MutableColumnsForSchema, ReadonlyColumn } from './component.js';
|
|
4
|
-
import { EntityID,
|
|
4
|
+
import { EntityID, ReadonlyEntityIDArray } from './entity.js';
|
|
5
5
|
export type ArchetypeID = Brand<number, "archetype_id">;
|
|
6
6
|
export declare const asArchetypeId: (value: number) => ArchetypeID;
|
|
7
7
|
export interface ArchetypeEdge {
|
|
@@ -86,7 +86,7 @@ export interface ArchetypeView<out Defs extends readonly ComponentDef<any>[] = r
|
|
|
86
86
|
readonly disabledCount: number;
|
|
87
87
|
/** Raw entity ID buffer (packed `EntityID`s). Valid data at indices
|
|
88
88
|
* 0..totalCount-1 (enabled rows first, then disabled). */
|
|
89
|
-
readonly entityIds:
|
|
89
|
+
readonly entityIds: ReadonlyEntityIDArray;
|
|
90
90
|
/** True if this archetype's mask includes the given component. */
|
|
91
91
|
hasComponent(id: ComponentID): boolean;
|
|
92
92
|
/** Get a single field's column (read-only). Valid data: indices
|
|
@@ -243,7 +243,7 @@ export declare class Archetype implements ArchetypeView {
|
|
|
243
243
|
get disabledCount(): number;
|
|
244
244
|
/** Raw entity ID buffer (packed `EntityID`s). Valid data at indices
|
|
245
245
|
* 0..totalCount-1 (enabled rows first, then disabled). */
|
|
246
|
-
get entityIds():
|
|
246
|
+
get entityIds(): ReadonlyEntityIDArray;
|
|
247
247
|
/**
|
|
248
248
|
* Swap the two rows `a` and `b` — entity ids and every column. Does NOT touch
|
|
249
249
|
* `entityRow`; the caller updates the entity→row map for whichever rows it
|
|
@@ -142,6 +142,31 @@ export interface Bundle<S extends ComponentSchema = ComponentSchema> {
|
|
|
142
142
|
}
|
|
143
143
|
/** Either a populated bundle or a bare def (tag / all-fields-zero). */
|
|
144
144
|
export type BundleOrDef<S extends ComponentSchema = ComponentSchema> = Bundle<S> | ComponentDef<S>;
|
|
145
|
+
/** Re-validate one bundle-or-def item against its OWN def's schema. A bare def
|
|
146
|
+
* (the callable) passes as-is; a bundle is re-stated as `Bundle<S>` for its
|
|
147
|
+
* def's `S`, so a hand-written `{ def, values }` literal whose fields don't
|
|
148
|
+
* match the def is rejected — closing the raw-literal leak that `bundle(Pos,…)`
|
|
149
|
+
* / `Pos(…)` never had (those validate at their own call site). Per-element
|
|
150
|
+
* mapper for `StrictBundles`. */
|
|
151
|
+
export type StrictBundle<T> = T extends ComponentDef ? T : T extends {
|
|
152
|
+
def: ComponentDef<infer S>;
|
|
153
|
+
} ? Bundle<S> : never;
|
|
154
|
+
/** Mapped tuple over a bundle-or-def varargs list — each element re-checked
|
|
155
|
+
* against its own def's schema. The SolidJS-`on` per-element pattern (pull the
|
|
156
|
+
* tuple apart, map every element), over callable bundles instead of
|
|
157
|
+
* `{ def, values }` entry-objects. The one strictness mechanism shared by
|
|
158
|
+
* `spawnBundle`, `addComponents`, and `template`. */
|
|
159
|
+
export type StrictBundles<Items extends readonly BundleOrDef[]> = {
|
|
160
|
+
[K in keyof Items]: StrictBundle<Items[K]>;
|
|
161
|
+
};
|
|
162
|
+
/** Recover the def tuple from a bundle-or-def varargs list, so `template(...)`
|
|
163
|
+
* still returns `Template<[Pos, Vel]>` — the typed key set that `spawn`'s
|
|
164
|
+
* `overrides` (`TemplateOverrides`) maps over. Also a per-element tuple map. */
|
|
165
|
+
export type DefsOf<Items extends readonly BundleOrDef[]> = {
|
|
166
|
+
[K in keyof Items]: Items[K] extends {
|
|
167
|
+
def: infer D extends ComponentDef;
|
|
168
|
+
} ? D : Items[K] extends ComponentDef ? Items[K] : never;
|
|
169
|
+
};
|
|
145
170
|
/** Pair a component def with field values to attach. Omitted fields zero-fill;
|
|
146
171
|
* a tag def takes no values (see `ValuesArg`). */
|
|
147
172
|
export declare function bundle<S extends ComponentSchema>(def: ComponentDef<S>, ...values: ValuesArg<S>): Bundle<S>;
|
|
@@ -142,6 +142,31 @@ export interface Bundle<S extends ComponentSchema = ComponentSchema> {
|
|
|
142
142
|
}
|
|
143
143
|
/** Either a populated bundle or a bare def (tag / all-fields-zero). */
|
|
144
144
|
export type BundleOrDef<S extends ComponentSchema = ComponentSchema> = Bundle<S> | ComponentDef<S>;
|
|
145
|
+
/** Re-validate one bundle-or-def item against its OWN def's schema. A bare def
|
|
146
|
+
* (the callable) passes as-is; a bundle is re-stated as `Bundle<S>` for its
|
|
147
|
+
* def's `S`, so a hand-written `{ def, values }` literal whose fields don't
|
|
148
|
+
* match the def is rejected — closing the raw-literal leak that `bundle(Pos,…)`
|
|
149
|
+
* / `Pos(…)` never had (those validate at their own call site). Per-element
|
|
150
|
+
* mapper for `StrictBundles`. */
|
|
151
|
+
export type StrictBundle<T> = T extends ComponentDef ? T : T extends {
|
|
152
|
+
def: ComponentDef<infer S>;
|
|
153
|
+
} ? Bundle<S> : never;
|
|
154
|
+
/** Mapped tuple over a bundle-or-def varargs list — each element re-checked
|
|
155
|
+
* against its own def's schema. The SolidJS-`on` per-element pattern (pull the
|
|
156
|
+
* tuple apart, map every element), over callable bundles instead of
|
|
157
|
+
* `{ def, values }` entry-objects. The one strictness mechanism shared by
|
|
158
|
+
* `spawnBundle`, `addComponents`, and `template`. */
|
|
159
|
+
export type StrictBundles<Items extends readonly BundleOrDef[]> = {
|
|
160
|
+
[K in keyof Items]: StrictBundle<Items[K]>;
|
|
161
|
+
};
|
|
162
|
+
/** Recover the def tuple from a bundle-or-def varargs list, so `template(...)`
|
|
163
|
+
* still returns `Template<[Pos, Vel]>` — the typed key set that `spawn`'s
|
|
164
|
+
* `overrides` (`TemplateOverrides`) maps over. Also a per-element tuple map. */
|
|
165
|
+
export type DefsOf<Items extends readonly BundleOrDef[]> = {
|
|
166
|
+
[K in keyof Items]: Items[K] extends {
|
|
167
|
+
def: infer D extends ComponentDef;
|
|
168
|
+
} ? D : Items[K] extends ComponentDef ? Items[K] : never;
|
|
169
|
+
};
|
|
145
170
|
/** Pair a component def with field values to attach. Omitted fields zero-fill;
|
|
146
171
|
* a tag def takes no values (see `ValuesArg`). */
|
|
147
172
|
export declare function bundle<S extends ComponentSchema>(def: ComponentDef<S>, ...values: ValuesArg<S>): Bundle<S>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/core/ecs/component.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;KAwBK;AAEL,OAAO,EACN,KAAK,EAGL,KAAK,aAAa,EAClB,MAAM,uBAAuB,CAAC;AAE/B,MAAM,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;AACxD,eAAO,MAAM,aAAa,UAAW,MAAM,gBAKzC,CAAC;AAEH,8DAA8D;AAC9D,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC;AAEtE,6CAA6C;AAC7C,MAAM,MAAM,eAAe,GAAG;IAC7B,GAAG,EAAE,YAAY,CAAC;IAClB,GAAG,EAAE,YAAY,CAAC;IAClB,EAAE,EAAE,SAAS,CAAC;IACd,GAAG,EAAE,UAAU,CAAC;IAChB,GAAG,EAAE,UAAU,CAAC;IAChB,EAAE,EAAE,UAAU,CAAC;IACf,GAAG,EAAE,WAAW,CAAC;IACjB,GAAG,E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AACjG,wBAAgB,SAAS,CAAC,IAAI,EAAE,WAAW,GAAG,YAAY,CAEzD;AAED,kFAAkF;AAClF,wBAAgB,YAAY,CAAC,IAAI,EAAE,WAAW,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAEhF;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,cAAc;IAC9B,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACjC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACxB;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IACnC,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACjC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACxB"}
|
package/dist/core/ecs/ecs.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Template,
|
|
1
|
+
import { Template, TemplateOverrides } from './store.cjs';
|
|
2
2
|
import { FrameTraceSink } from './frame_trace.cjs';
|
|
3
3
|
import { ObserverHandle, EntitySetObserverConfig, ArchetypeSetObserverConfig, StructuralObserverConfig } from './observer.cjs';
|
|
4
4
|
import { ColumnStore, ColumnStoreRegionHandle, StoreRegionSpec } from '../store/index.cjs';
|
|
@@ -8,7 +8,7 @@ import { Archetype, ArchetypeID } from './archetype.cjs';
|
|
|
8
8
|
import { SystemContext, Query, QueryBuilder, QueryCache, QueryResolver } from './query.cjs';
|
|
9
9
|
import { EntityID } from './entity.cjs';
|
|
10
10
|
import { ReadonlyComponentRef } from './ref.cjs';
|
|
11
|
-
import { ComponentDef, ComponentHandle, ComponentRegisterOptions, ComponentSchema, CompleteFieldValues, Bundle, BundleOrDef } from './component.cjs';
|
|
11
|
+
import { ComponentDef, ComponentHandle, ComponentRegisterOptions, ComponentSchema, CompleteFieldValues, Bundle, BundleOrDef, StrictBundles, DefsOf } from './component.cjs';
|
|
12
12
|
import { SparseComponentDef, SparseComponentID } from './sparse_store.cjs';
|
|
13
13
|
import { RelationDef } from './relation.cjs';
|
|
14
14
|
import { SystemFn, SystemConfig, SystemDescriptor, TypedSystemConfig, DenseAccessDecl, SpawnsAccessDecl, DespawnsAccessDecl, TransitionsAccessDecl, SparseAccessDecl, RelationsAccessDecl, ResourcesAccessDecl } from './system.cjs';
|
|
@@ -193,22 +193,40 @@ export declare class ECS implements QueryResolver {
|
|
|
193
193
|
spawn<Defs extends readonly ComponentDef[]>(template: Template<Defs>, overrides?: TemplateOverrides<Defs>): EntityID;
|
|
194
194
|
/**
|
|
195
195
|
* Spawn an entity from varargs bundles (§bundles) — the immediate
|
|
196
|
-
* host-side analog of `ctx.commands.spawn
|
|
197
|
-
*
|
|
198
|
-
*
|
|
199
|
-
*
|
|
200
|
-
*
|
|
196
|
+
* host-side analog of `ctx.commands.spawn`, and the same callable-bundle
|
|
197
|
+
* grammar as `addComponents` / `template`. `ecs.spawnBundle(Pos({x,y}),
|
|
198
|
+
* Vel({vx:1}), IsEnemy)` collapses the attach shapes into one; each item is
|
|
199
|
+
* checked against its own def's schema (`StrictBundles`). Bundles are applied
|
|
200
|
+
* immediately; a single combined-archetype insertion (one transition instead
|
|
201
|
+
* of one-per-component) is a later optimization — for now this mirrors the
|
|
202
|
+
* per-component `addComponent` path (unlike `addComponents`, which batches).
|
|
203
|
+
*
|
|
204
|
+
* Immediate — inside a system use the deferred `ctx.commands.spawn(...)`
|
|
205
|
+
* (calling this from a system body throws in DEV). Note the redirect trades
|
|
206
|
+
* timing: `commands.spawn` returns the id now but defers the attaches to the
|
|
207
|
+
* phase flush, so the entity sits in its empty/partial archetype until then —
|
|
208
|
+
* unlike `spawnBundle`'s immediate, fully-populated archetype.
|
|
201
209
|
*/
|
|
202
|
-
spawnBundle(...items:
|
|
210
|
+
spawnBundle<Items extends readonly BundleOrDef[]>(...items: StrictBundles<Items>): EntityID;
|
|
211
|
+
/** Bulk-spawn `count` entities from `template`, optionally applying one
|
|
212
|
+
* shared `overrides` object to every spawned row (same typed keys as
|
|
213
|
+
* `spawn`). Field writes are O(columns) (one `TypedArray.fill` per
|
|
214
|
+
* column), not O(count×columns). Returns the new ids in spawn order.
|
|
215
|
+
* Immediate — inside a system use `ctx.commands.spawn` per entity (calling
|
|
216
|
+
* this from a system body throws in DEV). */
|
|
217
|
+
spawnMany<Defs extends readonly ComponentDef[]>(template: Template<Defs>, count: number, overrides?: TemplateOverrides<Defs>): EntityID[];
|
|
203
218
|
/** DEV-only: throw when an *immediate* host structural mutator is called
|
|
204
219
|
* from inside one of THIS world's system bodies (or an observer / onAdded
|
|
205
220
|
* hook — they run in the same access spans). One rule for every host
|
|
206
|
-
* mutator
|
|
207
|
-
*
|
|
208
|
-
*
|
|
209
|
-
*
|
|
210
|
-
*
|
|
211
|
-
*
|
|
221
|
+
* structural mutator — despawn, add/remove(Components), batchAdd/Remove,
|
|
222
|
+
* disable/enable, AND the spawn family (spawn/spawnBundle/spawnMany): an
|
|
223
|
+
* immediate structural op mid-schedule can move or swap rows a running query
|
|
224
|
+
* is walking — or, for a spawn-append into that archetype, trip a column
|
|
225
|
+
* realloc under it — and it is invisible to observers. The archetype-level
|
|
226
|
+
* `_iterDepth` guard only catches mutations touching the archetype currently
|
|
227
|
+
* being iterated (and the append paths skip even that), so an op landing
|
|
228
|
+
* elsewhere would silently skip observers; the receiver rule ("inside a
|
|
229
|
+
* system, use ctx.commands") is enforced wholesale here.
|
|
212
230
|
*
|
|
213
231
|
* `_updating` scopes the guard to THIS world: the accessCheck slot is
|
|
214
232
|
* process-global, so without it a system of world A mutating world B (a
|
|
@@ -220,11 +238,11 @@ export declare class ECS implements QueryResolver {
|
|
|
220
238
|
* `ctx.commands.despawn` (applied at the phase flush); calling this from
|
|
221
239
|
* a system body throws in DEV, since an immediate destroy mid-iteration
|
|
222
240
|
* can invalidate rows the running query is walking. */
|
|
223
|
-
despawn(
|
|
224
|
-
/** Disable `
|
|
225
|
-
disable(
|
|
226
|
-
/** Re-enable a disabled `
|
|
227
|
-
enable(
|
|
241
|
+
despawn(entityId: EntityID): this;
|
|
242
|
+
/** Disable `entityId` (idempotent). Excluded from default queries until re-enabled. */
|
|
243
|
+
disable(entityId: EntityID): this;
|
|
244
|
+
/** Re-enable a disabled `entityId` (idempotent). */
|
|
245
|
+
enable(entityId: EntityID): this;
|
|
228
246
|
/**
|
|
229
247
|
* Attach a component to an entity, immediately (inside a system, use the
|
|
230
248
|
* deferred `ctx.commands.add`). Three shapes: a bare def attaches a tag; a
|
|
@@ -240,13 +258,16 @@ export declare class ECS implements QueryResolver {
|
|
|
240
258
|
addComponent(entityId: EntityID, def: ComponentDef<Record<string, never>>): this;
|
|
241
259
|
addComponent<S extends ComponentSchema>(entityId: EntityID, bundle: Bundle<S>): this;
|
|
242
260
|
addComponent<S extends ComponentSchema>(entityId: EntityID, def: ComponentDef<S>, values: CompleteFieldValues<S>): this;
|
|
243
|
-
/** Batch-attach several components in one archetype transition.
|
|
244
|
-
*
|
|
245
|
-
*
|
|
246
|
-
*
|
|
247
|
-
|
|
261
|
+
/** Batch-attach several components in one archetype transition. Takes the
|
|
262
|
+
* same callable-bundle varargs as `spawnBundle` — `world.addComponents(e,
|
|
263
|
+
* Pos({ x, y }), Vel({ vx }), Frozen)` — each item checked against its own
|
|
264
|
+
* def's schema (a misspelled or cross-component field is a compile error;
|
|
265
|
+
* tags refuse values). Omitted fields zero-fill. */
|
|
266
|
+
addComponents<Items extends readonly BundleOrDef[]>(entityId: EntityID, ...items: StrictBundles<Items>): this;
|
|
248
267
|
removeComponent(entityId: EntityID, def: ComponentDef): this;
|
|
249
|
-
|
|
268
|
+
/** Detach several components in one archetype transition — the varargs
|
|
269
|
+
* mirror of `addComponents` (bare defs; removing needs no values). */
|
|
270
|
+
removeComponents(entityId: EntityID, ...defs: ComponentDef[]): this;
|
|
250
271
|
/**
|
|
251
272
|
* Bulk add a component to ALL entities in the given archetype.
|
|
252
273
|
* O(columns) via TypedArray.set() instead of O(N×columns).
|
|
@@ -351,7 +372,7 @@ export declare class ECS implements QueryResolver {
|
|
|
351
372
|
* access record. Escape hatch: annotate `fn(ctx: SystemContext, dt)`
|
|
352
373
|
* explicitly to keep a system permissive at compile time. */
|
|
353
374
|
registerSystem<R extends DenseAccessDecl, W extends DenseAccessDecl, Sp extends SpawnsAccessDecl = readonly never[], De extends DespawnsAccessDecl = readonly never[], Tr extends TransitionsAccessDecl = readonly never[], SR extends SparseAccessDecl = readonly never[], SW extends SparseAccessDecl = readonly never[], RR extends RelationsAccessDecl = readonly never[], RW extends RelationsAccessDecl = readonly never[], QR extends ResourcesAccessDecl = readonly never[], QW extends ResourcesAccessDecl = readonly never[]>(config: TypedSystemConfig<R, W, Sp, De, Tr, SR, SW, RR, RW, QR, QW>): SystemDescriptor;
|
|
354
|
-
removeSystem(system: SystemDescriptor):
|
|
375
|
+
removeSystem(system: SystemDescriptor): this;
|
|
355
376
|
get systemCount(): number;
|
|
356
377
|
/**
|
|
357
378
|
* Run the startup phases, once, before the first `update()`. Prewarms
|
|
@@ -393,6 +414,23 @@ export declare class ECS implements QueryResolver {
|
|
|
393
414
|
*/
|
|
394
415
|
update(dt: number): void;
|
|
395
416
|
dispose(): void;
|
|
417
|
+
/** Register an archetype template (#462). Resolves the component set +
|
|
418
|
+
* default field values to a target archetype once (creating it if absent —
|
|
419
|
+
* fits the prewarm model), so later `spawn` / `spawnMany` calls land
|
|
420
|
+
* entities directly in that archetype with **zero archetype transitions**.
|
|
421
|
+
*
|
|
422
|
+
* const Bullet = ecs.template(Position({ x: 0, y: 0 }), Velocity({ vx: 0, vy: 0 }));
|
|
423
|
+
*
|
|
424
|
+
* Takes the same callable-bundle varargs as `spawnBundle` / `addComponents`
|
|
425
|
+
* (each item schema-checked against its own def); the resulting
|
|
426
|
+
* `Template<[Position, Velocity]>` keeps the typed key set that `spawn`'s
|
|
427
|
+
* `overrides` map over. Not a pass-through — it normalizes bundles to the
|
|
428
|
+
* store's entry shape, so it lives here with the other real logic, not in the
|
|
429
|
+
* delegation band. The big win is multi-component entities and bulk spawns; a
|
|
430
|
+
* single-component spawn is no faster than `spawn` + `addComponent`, which
|
|
431
|
+
* already bump-allocates a fresh entity into the target archetype. See
|
|
432
|
+
* ADR-0010. */
|
|
433
|
+
template<Items extends readonly BundleOrDef[]>(...items: StrictBundles<Items>): Template<DefsOf<Items>>;
|
|
396
434
|
/** Resolve a consumer-declared SAB region's byte offset by `region_id`, or
|
|
397
435
|
* 0 when absent. Generic, de-gamed replacement (#623) for the removed
|
|
398
436
|
* game-named accessors; pair with the consumer's own region module to
|
|
@@ -430,32 +468,12 @@ export declare class ECS implements QueryResolver {
|
|
|
430
468
|
registerTag(): ComponentDef<Record<string, never>>;
|
|
431
469
|
/** Register a sparse tag (empty schema) — membership only, no data. */
|
|
432
470
|
registerSparseTag(): SparseComponentDef<Record<string, never>>;
|
|
433
|
-
|
|
434
|
-
* default field values to a target archetype once (creating it if absent —
|
|
435
|
-
* fits the prewarm model), so later `spawn` / `spawnMany` calls land
|
|
436
|
-
* entities directly in that archetype with **zero archetype transitions**.
|
|
437
|
-
*
|
|
438
|
-
* const Bullet = ecs.template([
|
|
439
|
-
* { def: Position, values: { x: 0, y: 0 } },
|
|
440
|
-
* { def: Velocity, values: { vx: 0, vy: 0 } },
|
|
441
|
-
* ]);
|
|
442
|
-
*
|
|
443
|
-
* The big win is multi-component entities and bulk spawns; a single-
|
|
444
|
-
* component spawn is no faster than `spawn` + `addComponent`, which
|
|
445
|
-
* already bump-allocates a fresh entity into the target archetype. See
|
|
446
|
-
* ADR-0010. */
|
|
447
|
-
template<Defs extends readonly ComponentDef[]>(entries: TemplateEntries<Defs>): Template<Defs>;
|
|
448
|
-
/** Bulk-spawn `count` entities from `template`, optionally applying one
|
|
449
|
-
* shared `overrides` object to every spawned row (same typed keys as
|
|
450
|
-
* `spawn`). Field writes are O(columns) (one `TypedArray.fill` per
|
|
451
|
-
* column), not O(count×columns). Returns the new ids in spawn order. */
|
|
452
|
-
spawnMany<Defs extends readonly ComponentDef[]>(template: Template<Defs>, count: number, overrides?: TemplateOverrides<Defs>): EntityID[];
|
|
453
|
-
isAlive(id: EntityID): boolean;
|
|
471
|
+
isAlive(entityId: EntityID): boolean;
|
|
454
472
|
get entityCount(): number;
|
|
455
473
|
hasComponent(entityId: EntityID, def: ComponentDef): boolean;
|
|
456
|
-
/** Whether `
|
|
474
|
+
/** Whether `entityId` is currently disabled. Toggle via `disable` / `enable`
|
|
457
475
|
* (immediate, above the band — they carry the in-system dev guard). */
|
|
458
|
-
isDisabled(
|
|
476
|
+
isDisabled(entityId: EntityID): boolean;
|
|
459
477
|
addSparse(entityId: EntityID, def: SparseComponentDef<Record<string, never>>): this;
|
|
460
478
|
addSparse<S extends ComponentSchema>(entityId: EntityID, def: SparseComponentDef<S>, values: CompleteFieldValues<S>): this;
|
|
461
479
|
removeSparse(entityId: EntityID, def: SparseComponentDef): this;
|