@ecsia/core 0.1.0
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/LICENSE +21 -0
- package/README.md +29 -0
- package/dist/bitmask/bitmask.d.ts +21 -0
- package/dist/bitmask/bitmask.d.ts.map +1 -0
- package/dist/bitmask/bitmask.js +103 -0
- package/dist/bitmask/bitmask.js.map +1 -0
- package/dist/bitmask/index.d.ts +3 -0
- package/dist/bitmask/index.d.ts.map +1 -0
- package/dist/bitmask/index.js +2 -0
- package/dist/bitmask/index.js.map +1 -0
- package/dist/component/accessor.d.ts +40 -0
- package/dist/component/accessor.d.ts.map +1 -0
- package/dist/component/accessor.js +220 -0
- package/dist/component/accessor.js.map +1 -0
- package/dist/component/column-set.d.ts +20 -0
- package/dist/component/column-set.d.ts.map +1 -0
- package/dist/component/column-set.js +60 -0
- package/dist/component/column-set.js.map +1 -0
- package/dist/component/define.d.ts +23 -0
- package/dist/component/define.d.ts.map +1 -0
- package/dist/component/define.js +155 -0
- package/dist/component/define.js.map +1 -0
- package/dist/component/descriptors.d.ts +3 -0
- package/dist/component/descriptors.d.ts.map +1 -0
- package/dist/component/descriptors.js +147 -0
- package/dist/component/descriptors.js.map +1 -0
- package/dist/component/index.d.ts +10 -0
- package/dist/component/index.d.ts.map +1 -0
- package/dist/component/index.js +6 -0
- package/dist/component/index.js.map +1 -0
- package/dist/component/sidecar.d.ts +58 -0
- package/dist/component/sidecar.d.ts.map +1 -0
- package/dist/component/sidecar.js +136 -0
- package/dist/component/sidecar.js.map +1 -0
- package/dist/config.d.ts +55 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +70 -0
- package/dist/config.js.map +1 -0
- package/dist/entity/codec.d.ts +45 -0
- package/dist/entity/codec.d.ts.map +1 -0
- package/dist/entity/codec.js +53 -0
- package/dist/entity/codec.js.map +1 -0
- package/dist/entity/index-allocator.d.ts +46 -0
- package/dist/entity/index-allocator.d.ts.map +1 -0
- package/dist/entity/index-allocator.js +121 -0
- package/dist/entity/index-allocator.js.map +1 -0
- package/dist/entity/index.d.ts +13 -0
- package/dist/entity/index.d.ts.map +1 -0
- package/dist/entity/index.js +7 -0
- package/dist/entity/index.js.map +1 -0
- package/dist/entity/record.d.ts +28 -0
- package/dist/entity/record.d.ts.map +1 -0
- package/dist/entity/record.js +42 -0
- package/dist/entity/record.js.map +1 -0
- package/dist/entity/ref.d.ts +70 -0
- package/dist/entity/ref.d.ts.map +1 -0
- package/dist/entity/ref.js +104 -0
- package/dist/entity/ref.js.map +1 -0
- package/dist/entity/reservation.d.ts +12 -0
- package/dist/entity/reservation.d.ts.map +1 -0
- package/dist/entity/reservation.js +28 -0
- package/dist/entity/reservation.js.map +1 -0
- package/dist/entity/store.d.ts +60 -0
- package/dist/entity/store.d.ts.map +1 -0
- package/dist/entity/store.js +193 -0
- package/dist/entity/store.js.map +1 -0
- package/dist/env.d.ts +2 -0
- package/dist/env.d.ts.map +1 -0
- package/dist/env.js +12 -0
- package/dist/env.js.map +1 -0
- package/dist/ids.d.ts +9 -0
- package/dist/ids.d.ts.map +1 -0
- package/dist/ids.js +8 -0
- package/dist/ids.js.map +1 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +33 -0
- package/dist/index.js.map +1 -0
- package/dist/inspect-surface.d.ts +27 -0
- package/dist/inspect-surface.d.ts.map +1 -0
- package/dist/inspect-surface.js +14 -0
- package/dist/inspect-surface.js.map +1 -0
- package/dist/internal.d.ts +19 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +19 -0
- package/dist/internal.js.map +1 -0
- package/dist/memory/allocU32.d.ts +25 -0
- package/dist/memory/allocU32.d.ts.map +1 -0
- package/dist/memory/allocU32.js +95 -0
- package/dist/memory/allocU32.js.map +1 -0
- package/dist/memory/buffers.d.ts +94 -0
- package/dist/memory/buffers.d.ts.map +1 -0
- package/dist/memory/buffers.js +308 -0
- package/dist/memory/buffers.js.map +1 -0
- package/dist/memory/index.d.ts +7 -0
- package/dist/memory/index.d.ts.map +1 -0
- package/dist/memory/index.js +4 -0
- package/dist/memory/index.js.map +1 -0
- package/dist/memory/layout.d.ts +37 -0
- package/dist/memory/layout.d.ts.map +1 -0
- package/dist/memory/layout.js +116 -0
- package/dist/memory/layout.js.map +1 -0
- package/dist/query/compile.d.ts +73 -0
- package/dist/query/compile.d.ts.map +1 -0
- package/dist/query/compile.js +158 -0
- package/dist/query/compile.js.map +1 -0
- package/dist/query/engine.d.ts +48 -0
- package/dist/query/engine.d.ts.map +1 -0
- package/dist/query/engine.js +230 -0
- package/dist/query/engine.js.map +1 -0
- package/dist/query/index.d.ts +8 -0
- package/dist/query/index.d.ts.map +1 -0
- package/dist/query/index.js +10 -0
- package/dist/query/index.js.map +1 -0
- package/dist/query/live-query.d.ts +122 -0
- package/dist/query/live-query.d.ts.map +1 -0
- package/dist/query/live-query.js +543 -0
- package/dist/query/live-query.js.map +1 -0
- package/dist/query/sparse-set.d.ts +18 -0
- package/dist/query/sparse-set.d.ts.map +1 -0
- package/dist/query/sparse-set.js +126 -0
- package/dist/query/sparse-set.js.map +1 -0
- package/dist/reactivity/change-version.d.ts +19 -0
- package/dist/reactivity/change-version.d.ts.map +1 -0
- package/dist/reactivity/change-version.js +76 -0
- package/dist/reactivity/change-version.js.map +1 -0
- package/dist/reactivity/index.d.ts +12 -0
- package/dist/reactivity/index.d.ts.map +1 -0
- package/dist/reactivity/index.js +12 -0
- package/dist/reactivity/index.js.map +1 -0
- package/dist/reactivity/log.d.ts +83 -0
- package/dist/reactivity/log.d.ts.map +1 -0
- package/dist/reactivity/log.js +260 -0
- package/dist/reactivity/log.js.map +1 -0
- package/dist/reactivity/observer-commands.d.ts +40 -0
- package/dist/reactivity/observer-commands.d.ts.map +1 -0
- package/dist/reactivity/observer-commands.js +111 -0
- package/dist/reactivity/observer-commands.js.map +1 -0
- package/dist/reactivity/observers.d.ts +50 -0
- package/dist/reactivity/observers.d.ts.map +1 -0
- package/dist/reactivity/observers.js +127 -0
- package/dist/reactivity/observers.js.map +1 -0
- package/dist/reactivity/reactivity.d.ts +141 -0
- package/dist/reactivity/reactivity.d.ts.map +1 -0
- package/dist/reactivity/reactivity.js +479 -0
- package/dist/reactivity/reactivity.js.map +1 -0
- package/dist/reactivity/structural-journal.d.ts +30 -0
- package/dist/reactivity/structural-journal.d.ts.map +1 -0
- package/dist/reactivity/structural-journal.js +77 -0
- package/dist/reactivity/structural-journal.js.map +1 -0
- package/dist/registry.d.ts +26 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +58 -0
- package/dist/registry.js.map +1 -0
- package/dist/serialize-surface.d.ts +170 -0
- package/dist/serialize-surface.d.ts.map +1 -0
- package/dist/serialize-surface.js +6 -0
- package/dist/serialize-surface.js.map +1 -0
- package/dist/storage/archetype.d.ts +38 -0
- package/dist/storage/archetype.d.ts.map +1 -0
- package/dist/storage/archetype.js +47 -0
- package/dist/storage/archetype.js.map +1 -0
- package/dist/storage/cold-store.d.ts +41 -0
- package/dist/storage/cold-store.d.ts.map +1 -0
- package/dist/storage/cold-store.js +100 -0
- package/dist/storage/cold-store.js.map +1 -0
- package/dist/storage/index.d.ts +10 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +5 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/signature.d.ts +27 -0
- package/dist/storage/signature.d.ts.map +1 -0
- package/dist/storage/signature.js +115 -0
- package/dist/storage/signature.js.map +1 -0
- package/dist/storage/storage.d.ts +72 -0
- package/dist/storage/storage.d.ts.map +1 -0
- package/dist/storage/storage.js +192 -0
- package/dist/storage/storage.js.map +1 -0
- package/dist/storage/store.d.ts +88 -0
- package/dist/storage/store.d.ts.map +1 -0
- package/dist/storage/store.js +473 -0
- package/dist/storage/store.js.map +1 -0
- package/dist/util/stable-index.d.ts +29 -0
- package/dist/util/stable-index.d.ts.map +1 -0
- package/dist/util/stable-index.js +51 -0
- package/dist/util/stable-index.js.map +1 -0
- package/dist/world.d.ts +262 -0
- package/dist/world.d.ts.map +1 -0
- package/dist/world.js +831 -0
- package/dist/world.js.map +1 -0
- package/package.json +52 -0
package/dist/world.d.ts
ADDED
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import type { ResolvedWorldOptions, WorldOptions } from './config.js';
|
|
2
|
+
import type { EntityGeneration, EntityHandle, EntityIndex, EntityRef, EntityReservation, HandleLayout, HandleStats } from './entity/index.js';
|
|
3
|
+
import type { ComponentDef, ComponentId, RelationDef, RelationId, Schema, SpawnArg, SpawnArgFor } from '@ecsia/schema';
|
|
4
|
+
import type { SharedHandleManifest } from './memory/index.js';
|
|
5
|
+
import type { AccessorWorld } from './component/index.js';
|
|
6
|
+
import type { ResolvedPair } from './query/index.js';
|
|
7
|
+
import type { ColumnSet } from './component/index.js';
|
|
8
|
+
import type { Buffers as BuffersType, ColumnGrowthLog } from './memory/index.js';
|
|
9
|
+
import type { ObserverHandle, ObserverHandler, ObserverTerm } from './reactivity/index.js';
|
|
10
|
+
import type { WorldQuery } from '@ecsia/schema';
|
|
11
|
+
import type { SerializationSurface, SerializeRelationProvider } from './serialize-surface.js';
|
|
12
|
+
import type { InspectSurface } from './inspect-surface.js';
|
|
13
|
+
/**: 'serial' during the serial slot (and always, single-threaded); 'wave' only while the scheduler dispatches worker waves. */
|
|
14
|
+
export type WorldPhase = 'serial' | 'wave';
|
|
15
|
+
/**
|
|
16
|
+
* The ComponentId-keyed structural-apply verbs the command-buffer flush path drives.
|
|
17
|
+
* Built from the world's storage + registry; every call runs serial/main-thread.
|
|
18
|
+
*/
|
|
19
|
+
export interface WorldApplySurface {
|
|
20
|
+
defOf(id: ComponentId): ComponentDef<Schema> | undefined;
|
|
21
|
+
addMany(handle: EntityHandle, defs: readonly ComponentDef<Schema>[]): void;
|
|
22
|
+
removeMany(handle: EntityHandle, defs: readonly ComponentDef<Schema>[]): void;
|
|
23
|
+
/** Overwrite `def`'s fields on `handle`'s current row + emit the `.changed` write-log entry. */
|
|
24
|
+
writePayload(handle: EntityHandle, def: ComponentDef<Schema>, values: Record<string, unknown>): void;
|
|
25
|
+
/**
|
|
26
|
+
* Relation apply. Filled by `__installRelations`; undefined in a
|
|
27
|
+
* relation-free world. The scheduler's command-apply path calls these for OP_ADD_PAIR /
|
|
28
|
+
* OP_REMOVE_PAIR — it does NOT import relations (the acyclic boundary holds).
|
|
29
|
+
*/
|
|
30
|
+
addPair?(subject: EntityHandle, relationId: RelationId, target: EntityHandle, payload: Record<string, unknown> | undefined): void;
|
|
31
|
+
removePair?(subject: EntityHandle, relationId: RelationId, target: EntityHandle): void;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The minimal core surface the relations runtime drives. The world exposes it through
|
|
35
|
+
* `__installRelations` so `@ecsia/relations` attaches WITHOUT @ecsia/core ever importing it (the
|
|
36
|
+
* acyclic dependency direction, seam). Everything here is serial / main-thread.
|
|
37
|
+
*/
|
|
38
|
+
export interface RelationsHost {
|
|
39
|
+
/** Mint the next dense ComponentId. */
|
|
40
|
+
allocSyntheticId(): ComponentId;
|
|
41
|
+
/** Intern a synthetic ComponentDef (presence/overflow) at a minted id so storage can build its columns. */
|
|
42
|
+
registerSynthetic(def: ComponentDef<Schema>, id: ComponentId): void;
|
|
43
|
+
/** id → registered def (real or synthetic). */
|
|
44
|
+
defOf(id: ComponentId): ComponentDef<Schema> | undefined;
|
|
45
|
+
/** ONE migration adding several ids (relations atomicity; archetype-storage ). */
|
|
46
|
+
migrateAddingMany(handle: EntityHandle, defs: readonly ComponentDef<Schema>[]): void;
|
|
47
|
+
migrateRemovingMany(handle: EntityHandle, defs: readonly ComponentDef<Schema>[]): void;
|
|
48
|
+
/** O(1) membership of a (possibly synthetic) component id via the per-entity bitmask. */
|
|
49
|
+
bitmaskHas(index: number, id: ComponentId): boolean;
|
|
50
|
+
/** Resolve the live ColumnSet + current row for `def` on `handle`, or null if absent / not hot. */
|
|
51
|
+
columnSetFor(handle: EntityHandle, def: ComponentDef<Schema>): {
|
|
52
|
+
set: ColumnSet;
|
|
53
|
+
row: number;
|
|
54
|
+
} | null;
|
|
55
|
+
/** Entity-layer helpers. */
|
|
56
|
+
isAlive(handle: EntityHandle): boolean;
|
|
57
|
+
handleIndex(handle: EntityHandle): number;
|
|
58
|
+
handleOfIndex(index: number): EntityHandle;
|
|
59
|
+
/** Re-enter the despawn protocol for a cascaded victim. */
|
|
60
|
+
despawn(handle: EntityHandle): void;
|
|
61
|
+
/**
|
|
62
|
+
* deferral seam: while an observer drain is running, structural relation
|
|
63
|
+
* ops issued by a handler must STAGE to the world's deferred command buffer rather than mutate the
|
|
64
|
+
* world mid-drain. The relations runtime calls this at the top of addPair/removePair; if it returns
|
|
65
|
+
* true the op was staged (the runtime returns immediately) — else the runtime applies it directly.
|
|
66
|
+
*/
|
|
67
|
+
deferRelationOp(op: 'add' | 'remove', subject: EntityHandle, relation: RelationDef<Schema | void>, target: EntityHandle, payload?: Record<string, unknown>): boolean;
|
|
68
|
+
/** Push a write-log entry for a `.changed`-tracked pair-payload write. */
|
|
69
|
+
trackWrite(index: number, componentId: ComponentId): void;
|
|
70
|
+
/** Push an ADD_PAIR / REMOVE_PAIR shape-log entry. */
|
|
71
|
+
trackShapePair(index: number, pairId: ComponentId, targetIndex: number, add: boolean): void;
|
|
72
|
+
/**
|
|
73
|
+
* Journal a SET_PAYLOAD structural op for a non-exclusive overflow pair whose payload changed on an
|
|
74
|
+
* already-live pair (overflow payload changes are explicit OP_PAIR_PAYLOAD
|
|
75
|
+
* records, since they do not live in an archetype column the changed-row scan covers).
|
|
76
|
+
*/
|
|
77
|
+
trackShapeSetPayload(index: number, pairId: ComponentId, targetIndex: number): void;
|
|
78
|
+
/** The SAB-capable buffers registry, for the non-exclusive overflow payload ColumnSet. */
|
|
79
|
+
readonly buffers: BuffersType;
|
|
80
|
+
readonly accessorWorld: AccessorWorld;
|
|
81
|
+
/** Register a preDespawn hook fired BEFORE the row is torn down. */
|
|
82
|
+
setPreDespawn(hook: (dying: EntityHandle) => void): void;
|
|
83
|
+
/** Inject the Pair(...) term resolver into the query compiler. */
|
|
84
|
+
setPairResolver(resolve: (relationId: number, target: number | symbol) => ResolvedPair): void;
|
|
85
|
+
/** Fill the OP_ADD_PAIR / OP_REMOVE_PAIR apply seam so the scheduler can drive relations. */
|
|
86
|
+
setApplyPair(addPair: (subject: EntityHandle, relationId: RelationId, target: EntityHandle, payload: Record<string, unknown> | undefined) => void, removePair: (subject: EntityHandle, relationId: RelationId, target: EntityHandle) => void): void;
|
|
87
|
+
/**
|
|
88
|
+
* Install the relation snapshot/apply provider the serialization module reads through `world.__serialize`
|
|
89
|
+
* Lets @ecsia/serialization enumerate live pairs and re-establish them
|
|
90
|
+
* WITHOUT importing @ecsia/relations directly off the world — the relations runtime hands the provider
|
|
91
|
+
* in, core relays it, the acyclic boundary holds.
|
|
92
|
+
*/
|
|
93
|
+
setSerializationProvider(provider: SerializeRelationProvider): void;
|
|
94
|
+
readonly maxEntities: number;
|
|
95
|
+
readonly indexBits: number;
|
|
96
|
+
}
|
|
97
|
+
export interface World {
|
|
98
|
+
/** Fully-resolved, validated configuration (frozen). */
|
|
99
|
+
readonly options: ResolvedWorldOptions;
|
|
100
|
+
/** Structural-change phase. Owned by the world; the scheduler is the only component that flips it to 'wave'. */
|
|
101
|
+
readonly phase: WorldPhase;
|
|
102
|
+
/**
|
|
103
|
+
* Phase-flip seam. The world OWNS the field and seeds it to 'serial';
|
|
104
|
+
* the scheduler is the SOLE caller of this, flipping to 'wave' across worker dispatch and back to
|
|
105
|
+
* 'serial' for the merge/apply flush slot. @ecsia/core never calls it (the acyclic boundary holds —
|
|
106
|
+
* the scheduler drives the world externally). Not for user code.
|
|
107
|
+
*/
|
|
108
|
+
__setPhase(phase: WorldPhase): void;
|
|
109
|
+
/**
|
|
110
|
+
* Command-buffer apply seam (`spawnReserved`). Place a handle that was
|
|
111
|
+
* already made alive by `reserveEntityBlock` into the EMPTY archetype and
|
|
112
|
+
* emit its Create shape entry — the deferred analogue of `world.spawn()` whose identity was minted
|
|
113
|
+
* before the wave. Serial-phase only. Called ONLY by the scheduler's flush path. Not for user code.
|
|
114
|
+
*/
|
|
115
|
+
__spawnReserved(handle: EntityHandle): void;
|
|
116
|
+
/**
|
|
117
|
+
* Command-buffer apply surface, exposed as ONE seam so the scheduler's flush
|
|
118
|
+
* path drives the same storage primitives a main-thread direct-apply would, keyed by ComponentId.
|
|
119
|
+
* Serial-phase only; called ONLY by the scheduler. Not for user code.
|
|
120
|
+
*/
|
|
121
|
+
readonly __apply: WorldApplySurface;
|
|
122
|
+
/**
|
|
123
|
+
* Relations attach seam. `@ecsia/relations` calls this ONCE to obtain the core
|
|
124
|
+
* surface it drives (synthetic id minting, migrate-many, preDespawn hook, pair-resolver injection,
|
|
125
|
+
* OP_ADD_PAIR apply). @ecsia/core never imports @ecsia/relations — the host is handed OUT, keeping
|
|
126
|
+
* the dependency direction acyclic. Not for user code; call createRelations(world) instead.
|
|
127
|
+
*/
|
|
128
|
+
__installRelations(): RelationsHost;
|
|
129
|
+
/** Export the SAB buffer-set manifest for one-time worker transfer. */
|
|
130
|
+
__exportShared(): SharedHandleManifest;
|
|
131
|
+
/**
|
|
132
|
+
* Column re-backing journal. The scheduler reads
|
|
133
|
+
* `.generation` once per wave (a cheap monotonic int) and only `.drain()`s when it advanced — the
|
|
134
|
+
* notices it gets are the new SAB backings the worker pool must re-wrap at the wave fence before the
|
|
135
|
+
* next dispatch. In-place `.grow()` never bumps the generation (length-tracking views auto-widen).
|
|
136
|
+
* Serial / main-thread; called ONLY by the scheduler. Not for user code.
|
|
137
|
+
*/
|
|
138
|
+
__columnGrowth(): ColumnGrowthLog;
|
|
139
|
+
/**
|
|
140
|
+
* Serialization seam. @ecsia/serialization reads archetype columns + the
|
|
141
|
+
* registry + the relation provider through this, and drives deserialize-side spawn/migrate. Serial /
|
|
142
|
+
* main-thread only; @ecsia/core never imports @ecsia/serialization (acyclic boundary). Not for user code.
|
|
143
|
+
*/
|
|
144
|
+
readonly __serialize: SerializationSurface;
|
|
145
|
+
/**
|
|
146
|
+
* Read-only introspection seam (@ecsia/devtools). Exposes the FULL archetype census (cold +
|
|
147
|
+
* empty included) and the live-query enumeration — the two data an inspector needs that `__serialize`
|
|
148
|
+
* (snapshot-shaped: hot, non-empty only) and the public query surface do not reach. Pure reads, serial
|
|
149
|
+
* / main-thread; @ecsia/core never imports @ecsia/devtools (acyclic boundary). Not for user code.
|
|
150
|
+
*/
|
|
151
|
+
readonly __inspect: InspectSurface;
|
|
152
|
+
/**
|
|
153
|
+
* Merge ONE worker's staged value writes into the reactivity write log ( * ). `pairs` is the worker's raw `[index, componentId, …]` corral payload and `count` the number
|
|
154
|
+
* of `(index, componentId)` entries. The scheduler drives this in ASCENDING worker-index order in
|
|
155
|
+
* the serial flush slot so onChange observers + `.changed` filters fire for worker writes
|
|
156
|
+
* deterministically. Serial-phase only; called ONLY by the scheduler. Not for user code.
|
|
157
|
+
*/
|
|
158
|
+
__mergeWorkerWrites(pairs: Int32Array | Uint32Array, count: number): void;
|
|
159
|
+
/** Current frame tick. Advanced by reactivity at frame reset. */
|
|
160
|
+
readonly tick: number;
|
|
161
|
+
/** Alias for `tick`. */
|
|
162
|
+
currentTick(): number;
|
|
163
|
+
/** Create a new entity with the empty signature. Main-thread/serial. O(1). */
|
|
164
|
+
spawn(): EntityHandle;
|
|
165
|
+
/**
|
|
166
|
+
* Create a new entity and add the given components in ONE migration (EMPTY → target signature),
|
|
167
|
+
* never N. Main-thread/serial.
|
|
168
|
+
*
|
|
169
|
+
* Each argument is either a bare `ComponentDef` (membership only) or a `[def, values]` tuple that
|
|
170
|
+
* also INITIALIZES the component: `spawnWith([Position, { x: 1, y: 2 }], Velocity)` spawns the entity,
|
|
171
|
+
* migrates it to the target signature once, then writes the supplied values through the normal tracked
|
|
172
|
+
* accessor path (so onChange/write-log fire). The value object is type-inferred from the def's schema.
|
|
173
|
+
*/
|
|
174
|
+
spawnWith<const T extends readonly SpawnArg[]>(...specs: {
|
|
175
|
+
[I in keyof T]: SpawnArgFor<T[I]>;
|
|
176
|
+
}): EntityHandle;
|
|
177
|
+
/** Add a component to a live entity (single migration via the cached edge). Main-thread/serial. */
|
|
178
|
+
add(handle: EntityHandle, def: ComponentDef<Schema>): void;
|
|
179
|
+
/** Remove a component from a live entity (single migration via the cached edge). Main-thread/serial. */
|
|
180
|
+
remove(handle: EntityHandle, def: ComponentDef<Schema>): void;
|
|
181
|
+
/** Explicit cold→hot archetype promotion at a serial flush point. */
|
|
182
|
+
warm(...defs: readonly ComponentDef<Schema>[]): void;
|
|
183
|
+
/** Destroy an entity. Main-thread/serial. Idempotent on dead handles. */
|
|
184
|
+
despawn(handle: EntityHandle): void;
|
|
185
|
+
/** O(1) liveness/staleness check. Never consults the bitmask. */
|
|
186
|
+
isAlive(handle: EntityHandle): boolean;
|
|
187
|
+
/**
|
|
188
|
+
* O(1) component membership point-test via the per-entity bitmask.
|
|
189
|
+
* Main-thread/serial only. Returns false for a dead handle (liveness checked first,
|
|
190
|
+
* without reading the bitmask).
|
|
191
|
+
*/
|
|
192
|
+
has(handle: EntityHandle, def: ComponentDef<Schema>): boolean;
|
|
193
|
+
/**
|
|
194
|
+
* Resolve the pooled EntityRef for `handle`; throws on a dead handle unless `{ lenient: true }`
|
|
195
|
+
* `spawnWith(...defs)` is the other; it is
|
|
196
|
+
* intentionally deferred to storage, which owns target-signature computation and the
|
|
197
|
+
* single migration — the handle mint here is meaningless without an archetype to land in.
|
|
198
|
+
*/
|
|
199
|
+
entity(handle: EntityHandle, opts?: {
|
|
200
|
+
lenient?: boolean;
|
|
201
|
+
}): EntityRef;
|
|
202
|
+
/** Pre-reserve a block of live handles for a worker to consume mid-wave. Serial-phase only. */
|
|
203
|
+
reserveEntityBlock(workerIndex: number, count: number): EntityReservation;
|
|
204
|
+
/** Reclaim the unconsumed tail of a reservation, LIFO, at bumped generation. */
|
|
205
|
+
returnReservedIds(reservation: EntityReservation, consumedCount: number): void;
|
|
206
|
+
/** Frozen handle codec layout, also valid to hand to workers. */
|
|
207
|
+
readonly handleLayout: HandleLayout;
|
|
208
|
+
encodeHandle(index: number, generation: number): EntityHandle;
|
|
209
|
+
decodeHandle(handle: EntityHandle): {
|
|
210
|
+
index: EntityIndex;
|
|
211
|
+
generation: EntityGeneration;
|
|
212
|
+
};
|
|
213
|
+
handleStats(): HandleStats;
|
|
214
|
+
/**
|
|
215
|
+
* Push (entityIndex, componentId[, fieldIndex]) to the reactivity write log for the `.changed`
|
|
216
|
+
* filter. STUBBED as a no-op until — the canonical signature and
|
|
217
|
+
* accessor-setter call sites are in place now so only fills the body.
|
|
218
|
+
*/
|
|
219
|
+
trackWrite(index: number, componentId: ComponentId, fieldIndex?: number): void;
|
|
220
|
+
/**
|
|
221
|
+
* Register a deferred observer. Fires ONLY at the serial observer slot
|
|
222
|
+
* (observerDrain), NEVER synchronously mid-system. Mutations inside the handler stage to the
|
|
223
|
+
* command buffer and apply at the next serial flush ( re-entrancy safety).
|
|
224
|
+
*/
|
|
225
|
+
observe(term: ObserverTerm, handler: ObserverHandler): ObserverHandle;
|
|
226
|
+
/**
|
|
227
|
+
* Did any component on `handle` change strictly after tick `since`?. Driven by
|
|
228
|
+
* the per-row changeVersion stamps, NOT the write log. Lazily enabled the first time a
|
|
229
|
+
* `.changed` query flavor or this predicate is used.
|
|
230
|
+
*/
|
|
231
|
+
changedSince(handle: EntityHandle, since: number): boolean;
|
|
232
|
+
/** The rows of `archetypeId` whose changeVersion stamp is > since (the delta serializer scan). */
|
|
233
|
+
changedRows(archetypeId: number, since: number): Iterable<number>;
|
|
234
|
+
/** Advance the frame tick (reactivity.frameReset calls this; world owns the counter). */
|
|
235
|
+
advanceTick(): void;
|
|
236
|
+
/** (no-op single-threaded). */
|
|
237
|
+
mergeCorrals(): void;
|
|
238
|
+
/**, re-testing affected entities against referencing queries. */
|
|
239
|
+
maintainStructural(): void;
|
|
240
|
+
/** */
|
|
241
|
+
observerDrain(): void;
|
|
242
|
+
/** /merge spill, schedule next-frame ring resize. */
|
|
243
|
+
flushLogs(): void;
|
|
244
|
+
/**
|
|
245
|
+
* Compile (or fetch the cached) LiveQuery for `terms` and return it. Identical
|
|
246
|
+
* term sets share one LiveQuery by canonical hash (order-independent, pair-target-encoded). The
|
|
247
|
+
* arity-cap overload family (1..8 inferred, 9+ → LooseQueryElement) is the WorldQuery type.
|
|
248
|
+
*/
|
|
249
|
+
query: WorldQuery;
|
|
250
|
+
/**
|
|
251
|
+
* Reset every live query's per-frame transient flavor (added/removed) lists. The kernel-only frame
|
|
252
|
+
* loop calls this at frame start; the scheduler drives it at.
|
|
253
|
+
*/
|
|
254
|
+
frameReset(): void;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* The only world constructor. Resolves and validates options fail-fast, then
|
|
258
|
+
* (at later milestones) probes capabilities, allocates bounded buffers, and wires the owning
|
|
259
|
+
* modules. Returns a frozen World facade.
|
|
260
|
+
*/
|
|
261
|
+
export declare function createWorld(options?: WorldOptions): World;
|
|
262
|
+
//# sourceMappingURL=world.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"world.d.ts","sourceRoot":"","sources":["../src/world.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAQrE,OAAO,KAAK,EACV,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,SAAS,EACT,iBAAiB,EACjB,YAAY,EACZ,WAAW,EACZ,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAEtH,OAAO,KAAK,EAAc,oBAAoB,EAAa,MAAM,mBAAmB,CAAA;AAEpF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAOzD,OAAO,KAAK,EAAa,YAAY,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