@forgeax/engine-ecs 0.1.26 → 0.1.28
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 +94 -35
- package/dist/__tests__/world-read.unit.test.d.ts +2 -0
- package/dist/__tests__/world-read.unit.test.d.ts.map +1 -0
- package/dist/commands.d.ts +2 -0
- package/dist/commands.d.ts.map +1 -1
- package/dist/index.mjs +3471 -4263
- package/dist/index.mjs.map +1 -1
- package/dist/internal.d.ts +2 -3
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.mjs +3 -333
- package/dist/internal.mjs.map +1 -1
- package/dist/projection/index.mjs.map +1 -1
- package/dist/shared.mjs.map +1 -1
- package/dist/world-entity-lifecycle.d.ts +3 -14
- package/dist/world-entity-lifecycle.d.ts.map +1 -1
- package/dist/world-internal.d.ts +65 -5
- package/dist/world-internal.d.ts.map +1 -1
- package/dist/world-read.d.ts +16 -0
- package/dist/world-read.d.ts.map +1 -0
- package/dist/world-read.mjs +8 -0
- package/dist/world-read.mjs.map +1 -0
- package/dist/world-scheduling.d.ts +0 -4
- package/dist/world-scheduling.d.ts.map +1 -1
- package/dist/world-storage-primitives.d.ts +26 -0
- package/dist/world-storage-primitives.d.ts.map +1 -0
- package/dist/world.d.ts +352 -157
- package/dist/world.d.ts.map +1 -1
- package/package.json +8 -4
- package/src/__tests__/command-buffer.test.ts +29 -3
- package/src/__tests__/hierarchy.unit.test.ts +3 -3
- package/src/__tests__/world-health.contract.test.ts +195 -2
- package/src/__tests__/world-read.unit.test.ts +30 -0
- package/src/commands.ts +22 -9
- package/src/internal.ts +5 -3
- package/src/world-entity-lifecycle.ts +23 -252
- package/src/world-internal-augmentation.d.ts +11 -0
- package/src/world-internal.ts +114 -63
- package/src/world-read.ts +38 -0
- package/src/world-scheduling.ts +0 -26
- package/src/world-storage-primitives.ts +179 -0
- package/src/world.ts +2590 -509
- package/dist/world-component-access.d.ts +0 -311
- package/dist/world-component-access.d.ts.map +0 -1
- package/dist/world-component-storage.d.ts +0 -298
- package/dist/world-component-storage.d.ts.map +0 -1
- package/dist/world-core.d.ts +0 -39
- package/dist/world-core.d.ts.map +0 -1
- package/src/world-component-access.ts +0 -1769
- package/src/world-component-storage.ts +0 -1264
- package/src/world-core.ts +0 -74
|
@@ -1,311 +0,0 @@
|
|
|
1
|
-
import { type Result } from '@forgeax/engine-types';
|
|
2
|
-
import type { BufferPool } from './buffer-pool';
|
|
3
|
-
import { type Component, type ComponentSchema, type InputShapeOf, type ShapeOf } from './component';
|
|
4
|
-
import { type EntityHandle } from './entity-handle';
|
|
5
|
-
import { RelationshipIndex } from './relationship-index';
|
|
6
|
-
import type { SharedRefStore } from './shared-ref-store';
|
|
7
|
-
import { type Archetype } from './storage/archetype';
|
|
8
|
-
import { type ArchetypeGraph } from './storage/archetype-graph';
|
|
9
|
-
import { type FieldView } from './storage/column';
|
|
10
|
-
import type { StructuralEvidenceInput } from './storage/structural-evidence';
|
|
11
|
-
import type { UniqueRefStore } from './unique-ref-store';
|
|
12
|
-
import type { ComponentData, EcsError, EntityRecord } from './world';
|
|
13
|
-
type ErrorContext = {
|
|
14
|
-
readonly systemName: string;
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* Prepared target-side work for one relationship source write.
|
|
18
|
-
*
|
|
19
|
-
* A reservation is deliberately kept outside the World columns until the
|
|
20
|
-
* source operation is ready to commit. That lets direct, spawn, and deferred
|
|
21
|
-
* source writes observe BufferPool failures before adding a mirror component
|
|
22
|
-
* or advancing any ECS epoch.
|
|
23
|
-
*/
|
|
24
|
-
interface RelationshipPreparation {
|
|
25
|
-
readonly target: EntityHandle;
|
|
26
|
-
readonly mirror: Component;
|
|
27
|
-
readonly fieldName: string;
|
|
28
|
-
readonly mirrorPresent: boolean;
|
|
29
|
-
reservedSlotId: number | undefined;
|
|
30
|
-
}
|
|
31
|
-
export interface ComponentAccessState {
|
|
32
|
-
readonly graph: ArchetypeGraph;
|
|
33
|
-
readonly records: EntityRecord[];
|
|
34
|
-
readonly freeIndices: number[];
|
|
35
|
-
readonly bufferPool: BufferPool;
|
|
36
|
-
readonly uniqueRefs: UniqueRefStore;
|
|
37
|
-
readonly sharedRefs: SharedRefStore;
|
|
38
|
-
readonly relationshipIndexes: Map<number, RelationshipIndex>;
|
|
39
|
-
readonly markComponentAdded: (entity: EntityHandle, componentId: number) => void;
|
|
40
|
-
readonly markComponentsAdded: (entity: EntityHandle, componentIds: readonly number[]) => void;
|
|
41
|
-
readonly markComponentChanged: (entity: EntityHandle, componentId: number) => void;
|
|
42
|
-
readonly markStructureChanged: () => void;
|
|
43
|
-
readonly recordStructuralEvidence: (evidence: StructuralEvidenceInput) => void;
|
|
44
|
-
routeError(err: unknown, ctx: ErrorContext): void;
|
|
45
|
-
}
|
|
46
|
-
export declare class WorldComponentAccess {
|
|
47
|
-
private readonly state;
|
|
48
|
-
private readonly storage;
|
|
49
|
-
constructor(state: ComponentAccessState);
|
|
50
|
-
private get graph();
|
|
51
|
-
private get records();
|
|
52
|
-
private table;
|
|
53
|
-
private tableRow;
|
|
54
|
-
private get freeIndices();
|
|
55
|
-
private get bufferPool();
|
|
56
|
-
private get uniqueRefs();
|
|
57
|
-
private routeError;
|
|
58
|
-
private relationshipIndex;
|
|
59
|
-
/**
|
|
60
|
-
* Read the World-owned materialized target array without a public snapshot.
|
|
61
|
-
* This is an internal relationship-owner path: it borrows the live
|
|
62
|
-
* `Uint32Array` so attach/detach stays zero-copy. Public `World.get` detaches
|
|
63
|
-
* target arrays before returning them to callers.
|
|
64
|
-
*/
|
|
65
|
-
relationshipTargetEntries(source: Component, target: EntityHandle): readonly EntityHandle[];
|
|
66
|
-
private markComponentAdded;
|
|
67
|
-
private markComponentChanged;
|
|
68
|
-
private markStructureChanged;
|
|
69
|
-
relationshipTargetEntity(component: Component, value: Record<string, unknown>): EntityHandle | null;
|
|
70
|
-
private preflightComponentFieldValues;
|
|
71
|
-
/**
|
|
72
|
-
* Validate one structural component payload without touching archetypes,
|
|
73
|
-
* columns, relationship mirrors, epochs, or managed-reference stores.
|
|
74
|
-
* CommandBuffer uses this same owner-level gate as the direct World facade;
|
|
75
|
-
* the optional pending set lets a batch refer to an entity reserved earlier
|
|
76
|
-
* in that batch without mistaking it for a stale live handle.
|
|
77
|
-
*/
|
|
78
|
-
preflightComponentData(holder: EntityHandle | null, componentData: ComponentData, pendingEntities?: ReadonlySet<number>, unavailableEntities?: ReadonlySet<number>): Result<void, EcsError>;
|
|
79
|
-
private relationshipCycleHit;
|
|
80
|
-
/**
|
|
81
|
-
* Reserve target-side relationship capacity without touching World columns.
|
|
82
|
-
*
|
|
83
|
-
* A missing mirror reserves its first slot before the mirror archetype is
|
|
84
|
-
* created. An existing mirror either reserves an empty slot or grows its
|
|
85
|
-
* existing BufferPool slot; both failure paths return before any component,
|
|
86
|
-
* relationship index, or ECS epoch changes.
|
|
87
|
-
*/
|
|
88
|
-
prepareRelationshipInsert(component: Component, value: Record<string, unknown>): Result<RelationshipPreparation | undefined, EcsError>;
|
|
89
|
-
/** Release a target-capacity reservation that did not reach commit. */
|
|
90
|
-
releaseRelationshipPreparation(preparation: RelationshipPreparation | undefined): void;
|
|
91
|
-
/** Install a reserved slot after the target mirror archetype exists. */
|
|
92
|
-
private installRelationshipPreparation;
|
|
93
|
-
/** Append `holder` to the materialized target list. */
|
|
94
|
-
relationshipOnInsert(holder: EntityHandle, component: Component, value: Record<string, unknown>, preparation?: RelationshipPreparation): Result<void, EcsError>;
|
|
95
|
-
/** Remove `holder` from the materialized target list. */
|
|
96
|
-
relationshipOnRemove(holder: EntityHandle, component: Component, oldValue: Record<string, unknown>): Result<void, EcsError>;
|
|
97
|
-
/**
|
|
98
|
-
* Read component data from an entity.
|
|
99
|
-
*
|
|
100
|
-
* **Public array contract:** relationship target `array<entity>` fields are
|
|
101
|
-
* detached `Uint32Array` copies. Mutating that returned array cannot alter
|
|
102
|
-
* the materialized target, relationship index, or source. Other array
|
|
103
|
-
* fields retain the existing transient view contract: fixed-capacity
|
|
104
|
-
* `array<T,N>` and `buffer<N>` fields alias the archetype column buffer
|
|
105
|
-
* directly, while variable managed arrays alias their BufferPool slot. Those
|
|
106
|
-
* views are valid only until the next structural change (`spawn` /
|
|
107
|
-
* `despawn` / `addComponent` / `removeComponent`); callers must re-fetch
|
|
108
|
-
* `world.get(e, C)` on every access. Internal owners use `readRow` and
|
|
109
|
-
* `_getArrayView` directly and retain zero-copy access.
|
|
110
|
-
*
|
|
111
|
-
* @returns `Result<ShapeOf<S>, EcsError>` —
|
|
112
|
-
* `ok(ShapeOf<S>)` on success;
|
|
113
|
-
* `err(StaleEntityError)` (`.code = 'stale-entity'`) if entity is dead;
|
|
114
|
-
* `err(ComponentNotPresentError)` (`.code = 'component-not-present'`) if
|
|
115
|
-
* the entity does not have the component (a never-present component on
|
|
116
|
-
* this entity degrades to the same `component-not-present` path — there is
|
|
117
|
-
* no separate "not registered" failure; components are global at
|
|
118
|
-
* `defineComponent` time).
|
|
119
|
-
*
|
|
120
|
-
* @example
|
|
121
|
-
* ```ts
|
|
122
|
-
* const Position = defineComponent('Position', { x: 'f32', y: 'f32' });
|
|
123
|
-
* const world = new World();
|
|
124
|
-
* const e = world.spawn({ component: Position, data: { x: 1, y: 2 } }).unwrap();
|
|
125
|
-
* const r = world.get(e, Position);
|
|
126
|
-
* if (!r.ok) { return; } // r.error.code === 'stale-entity' on dead handle
|
|
127
|
-
* const pos = r.value;
|
|
128
|
-
* ```
|
|
129
|
-
*/
|
|
130
|
-
get<S extends ComponentSchema>(entity: EntityHandle, component: Component<string, S>): Result<ShapeOf<S>, EcsError>;
|
|
131
|
-
/**
|
|
132
|
-
* Column-level zero-copy view of an `array<T, N>` / `array<T>` field.
|
|
133
|
-
*
|
|
134
|
-
* Resolves the live byte region for `(entity, component, fieldName)`
|
|
135
|
-
* directly at the column level and returns the element-typed TypedArray
|
|
136
|
-
* aliasing it (`view.buffer` is the SSOT byte region; mutations route
|
|
137
|
-
* through `world.set`). Unlike `get`, this does NOT build the
|
|
138
|
-
* `{}` whole-component object nor walk every schema field. Per-frame
|
|
139
|
-
* consumers that need one column (the resolved world mat4) take this path to
|
|
140
|
-
* avoid the `get` overhead (1 `{}` alloc + N-field readRow walk).
|
|
141
|
-
*
|
|
142
|
-
* Fixed `array<T,N>` columns (feat-20260602) store their elements inline, so
|
|
143
|
-
* the view aliases the archetype column buffer directly (no BufferPool
|
|
144
|
-
* indirection); variable `array<T>` columns still alias the BufferPool slot.
|
|
145
|
-
* The returned view's element type follows the schema element type
|
|
146
|
-
* (`array<entity,N>` -> `Uint32Array`, `array<f32,N>` -> `Float32Array`,
|
|
147
|
-
* etc.) -- the prior f32-only early-return gate is removed.
|
|
148
|
-
*
|
|
149
|
-
* **Transient view contract:** the returned `TypedArray` aliases the column
|
|
150
|
-
* buffer and is valid only until the next structural change (`spawn` /
|
|
151
|
-
* `despawn` / `addComponent` / `removeComponent`). Column growth
|
|
152
|
-
* (`growColumn`) detaches the old `ArrayBuffer` via `transfer()`; a
|
|
153
|
-
* swap-remove at the same row index leaves the view pointing to the wrong
|
|
154
|
-
* entity. **Callers must re-fetch `_getArrayView` on every access** and must
|
|
155
|
-
* not hold the view across any operation that may cause archetype migration.
|
|
156
|
-
* All existing per-frame consumers (`propagateTransforms` / `render-extract`
|
|
157
|
-
* / `pick`) already conform -- they fetch the view inside a single pass with
|
|
158
|
-
* no intervening structural changes.
|
|
159
|
-
*
|
|
160
|
-
* Returns `undefined` when the entity is dead, the component is absent, the
|
|
161
|
-
* field does not exist, or the field is not an `array<...>` column.
|
|
162
|
-
*
|
|
163
|
-
* @internal Engine-internal fast path; AI users read public component values
|
|
164
|
-
* through `world.get`. This accessor is the zero-materialization route the
|
|
165
|
-
* propagate kernel, relationship owner, and render walk use; it bypasses
|
|
166
|
-
* the detached public relationship-target snapshot.
|
|
167
|
-
*/
|
|
168
|
-
_getArrayView(entity: EntityHandle, component: Component, fieldName: string): FieldView | undefined;
|
|
169
|
-
/** Internal zero-materialisation read for ECS-owned relationship lists. */
|
|
170
|
-
_getArrayLength(entity: EntityHandle, component: Component, fieldName: string): number | undefined;
|
|
171
|
-
/** Internal zero-materialisation read for one ECS-owned array element. */
|
|
172
|
-
_getArrayElement(entity: EntityHandle, component: Component, fieldName: string, index: number): number | undefined;
|
|
173
|
-
/** Internal scalar-column read used by parent-first hierarchy traversal. */
|
|
174
|
-
_getFieldValue(entity: EntityHandle, component: Component, fieldName: string): number | undefined;
|
|
175
|
-
/**
|
|
176
|
-
* Converge one writable relationship source mutation through the source
|
|
177
|
-
* owner. The source scalar and its materialized target list are committed as
|
|
178
|
-
* one operation; no caller receives a raw source column view that could
|
|
179
|
-
* bypass the mirror/index maintenance.
|
|
180
|
-
*/
|
|
181
|
-
private setRelationshipSource;
|
|
182
|
-
/**
|
|
183
|
-
* Write (partial) component data to an entity.
|
|
184
|
-
*
|
|
185
|
-
* @returns `Result<void, EcsError>` —
|
|
186
|
-
* `ok(void)` on success;
|
|
187
|
-
* `err(StaleEntityError)` (`.code = 'stale-entity'`) if entity is dead;
|
|
188
|
-
* `err(ComponentNotPresentError)` (`.code = 'component-not-present'`) if
|
|
189
|
-
* entity does not have the component (F-02: no longer silently ignores).
|
|
190
|
-
*
|
|
191
|
-
* @example
|
|
192
|
-
* ```ts
|
|
193
|
-
* const Position = defineComponent('Position', { x: 'f32', y: 'f32' });
|
|
194
|
-
* const world = new World();
|
|
195
|
-
* const e = world.spawn({ component: Position, data: { x: 0, y: 0 } }).unwrap();
|
|
196
|
-
* const r = world.set(e, Position, { x: 10 });
|
|
197
|
-
* if (!r.ok) { return; } // r.error.code === 'stale-entity' on dead handle
|
|
198
|
-
* r.unwrap();
|
|
199
|
-
* ```
|
|
200
|
-
*/
|
|
201
|
-
set<S extends ComponentSchema>(entity: EntityHandle, component: Component<string, S>, value: Partial<InputShapeOf<S>>, markChanged?: boolean): Result<void, EcsError>;
|
|
202
|
-
/**
|
|
203
|
-
* Append `value` to the variable `array<T>` field `fieldName` on `entity`.
|
|
204
|
-
*
|
|
205
|
-
* BufferPool grow is amortized O(1) via the size-class freelist (research
|
|
206
|
-
* Finding 5). Relationship target arrays grow byte-wise.
|
|
207
|
-
*
|
|
208
|
-
* @returns `Result<void, EcsError>` with the normal stale/component errors.
|
|
209
|
-
*
|
|
210
|
-
* The helper is called only by relationship synchronization.
|
|
211
|
-
*/
|
|
212
|
-
private appendArrayElement;
|
|
213
|
-
/**
|
|
214
|
-
* Remove one variable-array element at a known slot. Relationship holders
|
|
215
|
-
* supply the slot from their backpointer, so this is O(1) and never scans
|
|
216
|
-
* the materialized target array.
|
|
217
|
-
*/
|
|
218
|
-
private removeArrayElementAt;
|
|
219
|
-
/**
|
|
220
|
-
* Add a component to an existing entity, triggering archetype migration.
|
|
221
|
-
*
|
|
222
|
-
* @returns `Result<void, EcsError>` —
|
|
223
|
-
* `ok(void)` on success;
|
|
224
|
-
* `err(StaleEntityError)` (`.code = 'stale-entity'`) if entity is dead;
|
|
225
|
-
* `err(ComponentAlreadyPresentError)` (`.code = 'component-already-present'`)
|
|
226
|
-
* if entity already has the component (E-03).
|
|
227
|
-
*
|
|
228
|
-
* @example
|
|
229
|
-
* ```ts
|
|
230
|
-
* const Position = defineComponent('Position', { x: 'f32', y: 'f32' });
|
|
231
|
-
* const Velocity = defineComponent('Velocity', { dx: 'f32', dy: 'f32' });
|
|
232
|
-
* const world = new World();
|
|
233
|
-
* const e = world.spawn({ component: Position, data: { x: 0, y: 0 } }).unwrap();
|
|
234
|
-
* const r = world.addComponent(e, { component: Velocity, data: { dx: 1, dy: 0 } });
|
|
235
|
-
* if (!r.ok) { return; } // r.error.code === 'stale-entity' on dead handle
|
|
236
|
-
* r.unwrap();
|
|
237
|
-
* ```
|
|
238
|
-
*/
|
|
239
|
-
addComponent<S extends ComponentSchema>(entity: EntityHandle, componentData: ComponentData<S>): Result<void, EcsError>;
|
|
240
|
-
/**
|
|
241
|
-
* Core implementation of `addComponent` with reentry guard.
|
|
242
|
-
*
|
|
243
|
-
* @param internal — `true` when called from relationship maintenance
|
|
244
|
-
* (lazy mirror create or exclusive reparent).
|
|
245
|
-
* @internal
|
|
246
|
-
*/
|
|
247
|
-
_addComponentCore<S extends ComponentSchema>(entity: EntityHandle, componentData: ComponentData<S>, internal: boolean, resolveRequirements?: boolean, skipVariableArrayInitialization?: boolean): Result<void, EcsError>;
|
|
248
|
-
/**
|
|
249
|
-
* Remove a component from an existing entity, triggering archetype migration.
|
|
250
|
-
*
|
|
251
|
-
* @returns `Result<void, EcsError>` —
|
|
252
|
-
* `ok(void)` on success;
|
|
253
|
-
* `err(StaleEntityError)` (`.code = 'stale-entity'`) if entity is dead;
|
|
254
|
-
* `err(ComponentNotPresentError)` (`.code = 'component-not-present'`)
|
|
255
|
-
* if entity doesn't have the component (E-04).
|
|
256
|
-
*
|
|
257
|
-
* @example
|
|
258
|
-
* ```ts
|
|
259
|
-
* const Position = defineComponent('Position', { x: 'f32', y: 'f32' });
|
|
260
|
-
* const world = new World();
|
|
261
|
-
* const e = world.spawn({ component: Position, data: { x: 0, y: 0 } }).unwrap();
|
|
262
|
-
* const r = world.removeComponent(e, Position);
|
|
263
|
-
* if (!r.ok) { return; } // r.error.code === 'stale-entity' on dead handle
|
|
264
|
-
* r.unwrap();
|
|
265
|
-
* ```
|
|
266
|
-
*/
|
|
267
|
-
removeComponent<S extends ComponentSchema>(entity: EntityHandle, component: Component<string, S>): Result<void, EcsError>;
|
|
268
|
-
/**
|
|
269
|
-
* Core implementation of `removeComponent` with reentry guard.
|
|
270
|
-
*
|
|
271
|
-
* @param internal — `true` when called from relationship maintenance
|
|
272
|
-
* (exclusive reparent).
|
|
273
|
-
* @internal
|
|
274
|
-
*/
|
|
275
|
-
_removeComponentCore<S extends ComponentSchema>(entity: EntityHandle, component: Component<string, S>, internal: boolean): Result<void, EcsError>;
|
|
276
|
-
/**
|
|
277
|
-
* @internal Allocate a pending entity for deferred spawn.
|
|
278
|
-
* Returns an Entity handle. The entity is "pending" because
|
|
279
|
-
* archetypeId === -1 (set by allocateIndex); no separate flag needed.
|
|
280
|
-
*/
|
|
281
|
-
_allocatePendingEntity(): EntityHandle;
|
|
282
|
-
/**
|
|
283
|
-
* Return a deferred-spawn reservation to the free-list without publishing a
|
|
284
|
-
* row or advancing an epoch. CommandBuffer.abort is the sole caller; a
|
|
285
|
-
* materialized entity is intentionally left untouched so an unexpected
|
|
286
|
-
* post-write failure poisons the World instead of attempting an unsafe undo.
|
|
287
|
-
*/
|
|
288
|
-
_cancelPendingEntity(entity: EntityHandle): void;
|
|
289
|
-
/**
|
|
290
|
-
* @internal Materialize a pending entity: actually place it into an archetype.
|
|
291
|
-
* Idempotent: a record with archetypeId !== -1 is already materialized.
|
|
292
|
-
*/
|
|
293
|
-
_materializePendingEntity(entity: EntityHandle, componentDatas: ComponentData[]): Result<void, EcsError>;
|
|
294
|
-
allocateIndex(): number;
|
|
295
|
-
/**
|
|
296
|
-
* Single liveness predicate (feat-20260602 / plan-strategy D-4): a slot is
|
|
297
|
-
* live for a given handle generation iff the record exists, its generation
|
|
298
|
-
* still matches the handle (despawn bumps generation, so a stale or recycled
|
|
299
|
-
* handle fails here), and the slot is materialized into an archetype
|
|
300
|
-
* (archetypeId !== -1). Replaces the former `record.alive && record.generation
|
|
301
|
-
* === gen` conjunction and the intermediate `!record.pending` clause.
|
|
302
|
-
*/
|
|
303
|
-
recordIsLive(record: EntityRecord | undefined, gen: number): record is EntityRecord;
|
|
304
|
-
lookupAlive(entity: EntityHandle, operation: string, component?: string): Result<EntityRecord, EcsError>;
|
|
305
|
-
readRow<S extends ComponentSchema>(arch: Archetype, component: Component<string, S>, row: number): ShapeOf<S>;
|
|
306
|
-
writeEntitySelf(arch: Archetype, row: number, handle: EntityHandle): void;
|
|
307
|
-
writeRow<S extends ComponentSchema>(arch: Archetype, component: Component<string, S>, row: number, value: ShapeOf<S>): void;
|
|
308
|
-
releaseManagedRefsOnRow(arch: Archetype, component: Component, row: number): void;
|
|
309
|
-
}
|
|
310
|
-
export {};
|
|
311
|
-
//# sourceMappingURL=world-component-access.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"world-component-access.d.ts","sourceRoot":"","sources":["../src/world-component-access.ts"],"names":[],"mappings":"AAMA,OAAO,EAA0B,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAC1F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,eAAe,EAGpB,KAAK,YAAY,EAMjB,KAAK,OAAO,EAEb,MAAM,aAAa,CAAC;AAKrB,OAAO,EAGL,KAAK,YAAY,EAIlB,MAAM,iBAAiB,CAAC;AAczB,OAAO,EAEL,iBAAiB,EAGlB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,KAAK,SAAS,EAAsB,MAAM,qBAAqB,CAAC;AACzE,OAAO,EACL,KAAK,cAAc,EAKpB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAwB,KAAK,SAAS,EAAwB,MAAM,kBAAkB,CAAC;AAC9F,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAE7E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAGrE,KAAK,YAAY,GAAG;IAAE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC;AAEpD;;;;;;;GAOG;AACH,UAAU,uBAAuB;IAC/B,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;IAChC,cAAc,EAAE,M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AM,EAAE,YAAY,GAAG,SAAS,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,IAAI,YAAY;IAInF,WAAW,CACT,MAAM,EAAE,YAAY,EACpB,SAAS,EAAE,MAAM,EACjB,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,CAAC,YAAY,EAAE,QAAQ,CAAC;IAiBjC,OAAO,CAAC,CAAC,SAAS,eAAe,EAC/B,IAAI,EAAE,SAAS,EACf,SAAS,EAAE,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,EAC/B,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,CAAC,CAAC;IAIb,eAAe,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI;IAIzE,QAAQ,CAAC,CAAC,SAAS,eAAe,EAChC,IAAI,EAAE,SAAS,EACf,SAAS,EAAE,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,EAC/B,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,GAChB,IAAI;IAIP,uBAAuB,CAAC,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI;CAGlF"}
|
|
@@ -1,298 +0,0 @@
|
|
|
1
|
-
import type { BufferPool } from './buffer-pool';
|
|
2
|
-
import { type ArrayMeta, type Component, type ComponentSchema, type ManagedArrayElementType, type ShapeOf } from './component';
|
|
3
|
-
import { type EntityHandle } from './entity-handle';
|
|
4
|
-
import type { ManagedArrayErrorEnvelope } from './errors';
|
|
5
|
-
type ErrorContext = {
|
|
6
|
-
readonly systemName: string;
|
|
7
|
-
};
|
|
8
|
-
import type { SharedRefStore } from './shared-ref-store';
|
|
9
|
-
import { type Archetype } from './storage/archetype';
|
|
10
|
-
import { type ArchetypeGraph } from './storage/archetype-graph';
|
|
11
|
-
import { type FieldView } from './storage/column';
|
|
12
|
-
import type { UniqueRefStore } from './unique-ref-store';
|
|
13
|
-
import type { EntityRecord } from './world';
|
|
14
|
-
export interface ComponentStorageState {
|
|
15
|
-
readonly graph: ArchetypeGraph;
|
|
16
|
-
readonly records: EntityRecord[];
|
|
17
|
-
readonly bufferPool: BufferPool;
|
|
18
|
-
readonly uniqueRefs: UniqueRefStore;
|
|
19
|
-
readonly sharedRefs: SharedRefStore;
|
|
20
|
-
routeError(err: unknown, ctx: ErrorContext): void;
|
|
21
|
-
}
|
|
22
|
-
export declare class ComponentStorage {
|
|
23
|
-
private readonly state;
|
|
24
|
-
constructor(state: ComponentStorageState);
|
|
25
|
-
private get records();
|
|
26
|
-
private table;
|
|
27
|
-
private get bufferPool();
|
|
28
|
-
private get uniqueRefs();
|
|
29
|
-
private get sharedRefs();
|
|
30
|
-
private routeError;
|
|
31
|
-
readArrayView(arch: Archetype, component: Component, row: number, fieldName: string): FieldView | undefined;
|
|
32
|
-
/**
|
|
33
|
-
* Read the live length of an array field without materialising a typed view.
|
|
34
|
-
* Relationship consumers use this narrow storage seam for hot reverse-list
|
|
35
|
-
* walks; the target array remains owned by the ECS column and no snapshot is
|
|
36
|
-
* created per entity.
|
|
37
|
-
*/
|
|
38
|
-
readArrayLength(arch: Archetype, component: Component, row: number, fieldName: string): number | undefined;
|
|
39
|
-
/**
|
|
40
|
-
* Read one array element directly from its backing column/BufferPool slot.
|
|
41
|
-
* The relationship target vocabulary is `array<entity>`, so its hot path
|
|
42
|
-
* decodes the packed u32 in-place and does not allocate a TypedArray view.
|
|
43
|
-
*/
|
|
44
|
-
readArrayElement(arch: Archetype, component: Component, row: number, fieldName: string, index: number): number | undefined;
|
|
45
|
-
/** Read one scalar field without constructing a component shape. */
|
|
46
|
-
readFieldValue(arch: Archetype, component: Component, row: number, fieldName: string): number | undefined;
|
|
47
|
-
readRow<S extends ComponentSchema>(arch: Archetype, component: Component<string, S>, row: number): ShapeOf<S>;
|
|
48
|
-
/**
|
|
49
|
-
* Write the full packed entity handle into the row's essential id=0 `Entity`
|
|
50
|
-
* column (`self` field). Called by `spawn` / `_materializePendingEntity`
|
|
51
|
-
* after the row is appended (feat-20260602 / plan-strategy D-3). The column
|
|
52
|
-
* always exists -- `createArchetype` folds the Entity column into every
|
|
53
|
-
* archetype -- so this is a direct u32 store, no readRow/writeRow walk.
|
|
54
|
-
*/
|
|
55
|
-
writeEntitySelf(arch: Archetype, row: number, handle: EntityHandle): void;
|
|
56
|
-
writeRow<S extends ComponentSchema>(arch: Archetype, component: Component<string, S>, row: number, value: ShapeOf<S>, options?: {
|
|
57
|
-
readonly skipVariableArrayInitialization?: boolean;
|
|
58
|
-
}): void;
|
|
59
|
-
/**
|
|
60
|
-
* Release every managed-resource field on `component` for the row at
|
|
61
|
-
* `row` in `arch`. Walks the schema once and delegates each field to
|
|
62
|
-
* `releaseManagedFieldOnRow` (feat-20260614 M2 SSOT). Family coverage
|
|
63
|
-
* (per-field) lives in that helper's JSDoc.
|
|
64
|
-
*
|
|
65
|
-
* Naming note (D-6 whitelist): the prefix `managed` here means
|
|
66
|
-
* `managed = ECS-tracked` — i.e. fields whose lifecycle the ECS
|
|
67
|
-
* actively releases on despawn / overwrite / removeComponent. It does
|
|
68
|
-
* NOT refer to the retired `'managed' | 'unmanaged'` Handle brand
|
|
69
|
-
* (renamed to `'unique' | 'shared'` in feat-20260614 M1). The helper
|
|
70
|
-
* walks BOTH `'unique<T>'` and `'shared<T>'` fields because both are
|
|
71
|
-
* ECS-tracked from the column's perspective; the per-field dispatch
|
|
72
|
-
* inside `releaseManagedFieldOnRow` distinguishes drop-on-despawn
|
|
73
|
-
* (unique) vs ref-counted release (shared).
|
|
74
|
-
*
|
|
75
|
-
* Skips sentinel slots (handle / id 0) and missing stores. Failures
|
|
76
|
-
* (double release / lookup mismatch) route to the Layer 3 ErrorHandler so
|
|
77
|
-
* the despawn / removeComponent chain never aborts (charter: explicit-
|
|
78
|
-
* failure boundary; the chain is total).
|
|
79
|
-
*
|
|
80
|
-
* Four release paths route through this helper (AC-11, plan §6 M2):
|
|
81
|
-
* 1. `world.despawn(e)` - every component on `e`.
|
|
82
|
-
* 2. `world.removeComponent(e, C)` - the removed component only.
|
|
83
|
-
* 3. `world.set` ref/string/buffer overwrite - per-field, before the new
|
|
84
|
-
* value lands in the column.
|
|
85
|
-
* 4. `writeArrayField` set arm prior-slot release (variable array<T>).
|
|
86
|
-
*
|
|
87
|
-
* After feat-20260614 M2 SSOT collapse the schema-field 3-arm dispatch
|
|
88
|
-
* lives in `releaseManagedFieldOnRow` (one site); this method walks the
|
|
89
|
-
* component schema and delegates per field.
|
|
90
|
-
*
|
|
91
|
-
* BufferPool slot id is reusable post-release: same-bucket free-list LIFO
|
|
92
|
-
* (D-7) returns the freed id on the next `alloc(byteLength)`. Tests:
|
|
93
|
-
* `__tests__/managed-array-release.test.ts` (w10) +
|
|
94
|
-
* `__tests__/world-managed-roundtrip.unit.test.ts` (w3 net-zero matrix).
|
|
95
|
-
*/
|
|
96
|
-
releaseManagedRefsOnRow(arch: Archetype, component: Component, row: number): void;
|
|
97
|
-
/**
|
|
98
|
-
* SSOT release dispatch for a single managed field on a row (feat-20260614
|
|
99
|
-
* M2 / D-2). Inspects the component schema's field type and routes to the
|
|
100
|
-
* matching release path:
|
|
101
|
-
*
|
|
102
|
-
* - `'unique<T>'` / `'string'` (`isManagedField`) — release the
|
|
103
|
-
* UniqueRefStore handle u32 stored in the column.
|
|
104
|
-
* - `'buffer'` variable (`isManagedBufferField`) — release the
|
|
105
|
-
* BufferPool slot id stored in the column. Fixed `'buffer<N>'` is
|
|
106
|
-
* inline stride-N (feat-20260602) and has no slot to release.
|
|
107
|
-
* - `array<T>` variable (`isManagedArrayField`) — release the
|
|
108
|
-
* BufferPool slot id in the primary column + zero the column and the
|
|
109
|
-
* `<fieldName>:count` sidecar so post-recycle reads observe count=0
|
|
110
|
-
* (defense-in-depth; the swap-pop row migration overwrites both
|
|
111
|
-
* columns anyway). Fixed `array<T,N>` is inline stride-N — nothing to
|
|
112
|
-
* release.
|
|
113
|
-
*
|
|
114
|
-
* Sentinel handle / slot id 0 short-circuits silently. Double-release /
|
|
115
|
-
* lookup mismatch routes via Layer 3 ErrorHandler so the despawn /
|
|
116
|
-
* removeComponent / set chain never aborts (charter explicit-failure
|
|
117
|
-
* boundary; the chain is total).
|
|
118
|
-
*
|
|
119
|
-
* SceneInstance state alloc/release rollback at world.ts:3494/3522 stays
|
|
120
|
-
* a direct `uniqueRefs.release(stateRef)` (research Finding 1.8 / D-5):
|
|
121
|
-
* those two sites are alloc-pair rollback, not schema-field dispatch.
|
|
122
|
-
*
|
|
123
|
-
* Naming note (D-6 whitelist): `releaseManagedFieldOnRow` uses
|
|
124
|
-
* `managed = ECS-tracked` — every field family this dispatcher knows
|
|
125
|
-
* (`'unique<T>'`, `'shared<T>'`, `'string'`, variable `'buffer'`,
|
|
126
|
-
* variable `'array<T>'`) is one whose lifecycle the ECS owns. The
|
|
127
|
-
* `'managed' | 'unmanaged'` Handle brand is gone (M1 renamed to
|
|
128
|
-
* `'unique' | 'shared'`); the helper name was deliberately kept
|
|
129
|
-
* because `managed` here is a column-side semantic, not a brand label.
|
|
130
|
-
*/
|
|
131
|
-
releaseManagedFieldOnRow(arch: Archetype, component: Component, row: number, fieldName: string): void;
|
|
132
|
-
/**
|
|
133
|
-
* Release a single managed handle u32. Routes failures through Layer 3.
|
|
134
|
-
* Slot-0 sentinel short-circuits silently (no error); already-released
|
|
135
|
-
* slots surface `unique-ref-double-release` through the ErrorHandler so
|
|
136
|
-
* AI users see the structured payload (`.code` / `.hint` / `.expected` /
|
|
137
|
-
* `.detail`) - charter explicit-failure boundary.
|
|
138
|
-
*
|
|
139
|
-
* Helper-internal only after feat-20260614 M2 (AC-03 grep gate). External
|
|
140
|
-
* callers route via `releaseManagedFieldOnRow`.
|
|
141
|
-
*/
|
|
142
|
-
releaseManagedRefHandle(handleU32: number, componentName: string, fieldName: string): void;
|
|
143
|
-
/**
|
|
144
|
-
* Release a single shared-ref handle u32 (feat-20260614 M4 / AC-08).
|
|
145
|
-
* Decrements the SharedRefStore refcount; the slot drops on rc 1 -> 0.
|
|
146
|
-
* Slot-0 sentinel short-circuits silently. Already-released slots route
|
|
147
|
-
* `shared-ref-double-release` through Layer 3 ErrorHandler so AI users
|
|
148
|
-
* see structured payloads (charter explicit-failure boundary).
|
|
149
|
-
*
|
|
150
|
-
* Mirrors `releaseManagedRefHandle` in shape; the store + error code are
|
|
151
|
-
* the only differences. Helper-internal — external callers route via
|
|
152
|
-
* `releaseManagedFieldOnRow` (D-2 SSOT).
|
|
153
|
-
*/
|
|
154
|
-
releaseSharedRefHandle(handleU32: number, componentName: string, fieldName: string): void;
|
|
155
|
-
/**
|
|
156
|
-
* Retain a single `shared<T>` scalar slot id (feat-20260614 M5 / D-5).
|
|
157
|
-
* Mirrors `releaseSharedRefHandle`; called from spawn / set scalar write
|
|
158
|
-
* paths so each ECS holder participates in the SharedRefStore rc.
|
|
159
|
-
* Sentinel slot 0 is a no-op. Failures (handle already released) route
|
|
160
|
-
* via Layer 3 ErrorHandler so the spawn / set chain stays total.
|
|
161
|
-
*/
|
|
162
|
-
retainSharedScalarHandle(handleU32: number, componentName: string, fieldName: string): void;
|
|
163
|
-
/**
|
|
164
|
-
* Release a single managed buffer slot id. Routes failures through Layer 3.
|
|
165
|
-
* Slot id 0 (sentinel for unallocated buffer fields) short-circuits
|
|
166
|
-
* silently. M2 v1 release surface is total - `BufferPool.release` returns
|
|
167
|
-
* `Result<void, never>` for unknown ids, so the chain stays noise-free.
|
|
168
|
-
*
|
|
169
|
-
* Helper-internal only after feat-20260614 M2 (AC-03 grep gate). External
|
|
170
|
-
* callers route via `releaseManagedFieldOnRow`.
|
|
171
|
-
*/
|
|
172
|
-
releaseManagedBufferSlot(slotId: number, componentName: string, fieldName: string): void;
|
|
173
|
-
/**
|
|
174
|
-
* Bridge a Layer-3 ErrorHandler call from a `ManagedArrayErrorEnvelope`.
|
|
175
|
-
* The envelope shape (`code / hint / expected / detail`) already mirrors
|
|
176
|
-
* the EcsError contract; this helper only attaches the systemName context
|
|
177
|
-
* so AI users can correlate the error with the holder component / field.
|
|
178
|
-
*/
|
|
179
|
-
routeArrayError(err: ManagedArrayErrorEnvelope, componentName: string, fieldName: string): void;
|
|
180
|
-
/**
|
|
181
|
-
* Write the value of an `array<T>` / `array<T,N>` field at `row` (D-3 +
|
|
182
|
-
/**
|
|
183
|
-
* Write an `array<T>` / `array<T,N>` field's payload at `row` (M1 / w7,
|
|
184
|
-
* D-1; feat-20260614 M2 / D-3). Spawn and set both delegate here without
|
|
185
|
-
* an `operation` parameter — the caller's calling convention encodes the
|
|
186
|
-
* difference:
|
|
187
|
-
* - Set path: caller invokes `releaseManagedFieldOnRow(arch, comp, row,
|
|
188
|
-
* fieldName)` BEFORE this method to release the prior slot (variable
|
|
189
|
-
* `array<T>`). Fixed `array<T,N>` is inline stride-N (feat-20260602)
|
|
190
|
-
* and has no slot to release on either path.
|
|
191
|
-
* - Spawn path: caller does NOT call the helper — fresh rows treat any
|
|
192
|
-
* non-zero u32 in the column as stale swap-pop debris owned by the
|
|
193
|
-
* migrated entity in the new archetype.
|
|
194
|
-
*
|
|
195
|
-
* Body:
|
|
196
|
-
* - Alloc a fresh BufferPool slot of `payload.length * elementBytes`.
|
|
197
|
-
* - Copy bytes from the payload's typed-array buffer into the slot view.
|
|
198
|
-
* - Persist slot id in the primary u32 column. For `array<T>` (variable),
|
|
199
|
-
* persist the live count in the sidecar `<fieldName>:count` column.
|
|
200
|
-
*
|
|
201
|
-
* Errors flow through `routeArrayError` with a uniform `World.write` label.
|
|
202
|
-
*/
|
|
203
|
-
writeArrayField(arch: Archetype, component: Component, row: number, fieldName: string, _fieldType: string, arrayMeta: ArrayMeta, raw: unknown): void;
|
|
204
|
-
/**
|
|
205
|
-
* Walk the first `count` u32 handles in `bytes` and call
|
|
206
|
-
* `SharedRefStore.retain` on each non-sentinel slot id (feat-20260614 M4 /
|
|
207
|
-
* D-3). Failures route via Layer 3 ErrorHandler so the write chain stays
|
|
208
|
-
* total; charter explicit-failure boundary lets AI users see structured
|
|
209
|
-
* `shared-ref-released` payloads when retaining a stale handle.
|
|
210
|
-
*
|
|
211
|
-
* Helper-internal -- only called from `writeArrayField`'s `'shared'` arm.
|
|
212
|
-
*/
|
|
213
|
-
retainSharedArrayElements(bytes: Uint8Array, count: number): void;
|
|
214
|
-
/**
|
|
215
|
-
* Walk the first `count` u32 handles in `bytes` and call
|
|
216
|
-
* `SharedRefStore.release` on each non-sentinel slot id (feat-20260614 M4 /
|
|
217
|
-
* D-3). Mirrors `retainSharedArrayElements`; called from
|
|
218
|
-
* `releaseManagedFieldOnRow`'s array arm BEFORE the BufferPool slot is
|
|
219
|
-
* released so the underlying bytes are still valid.
|
|
220
|
-
*/
|
|
221
|
-
releaseSharedArrayElements(bytes: Uint8Array, count: number): void;
|
|
222
|
-
writeArrayElementAt(bytes: Uint8Array, idx: number, elementType: ManagedArrayElementType, value: number): void;
|
|
223
|
-
readArrayElementAt(bytes: Uint8Array, idx: number, elementType: ManagedArrayElementType): number;
|
|
224
|
-
/**
|
|
225
|
-
* Materialise a fresh `TypedArray` view for an `array<T,N>` / `array<T>`
|
|
226
|
-
* field at `row`. This is the internal row-storage path: the returned view
|
|
227
|
-
* aliases the live column or BufferPool slot. `WorldComponentAccess.get`
|
|
228
|
-
* detaches relationship target arrays at the public boundary; internal ECS
|
|
229
|
-
* relationship maintenance and Scene traversal keep this zero-copy path.
|
|
230
|
-
*
|
|
231
|
-
* **Transient view contract (feat-20260602):** for fixed `array<T,N>`
|
|
232
|
-
* columns the returned `TypedArray` aliases the inline column buffer
|
|
233
|
-
* directly (`col.view.subarray(row * arity, ...)`); for variable
|
|
234
|
-
* `array<T>` columns it aliases the live `BufferPool` slot bytes
|
|
235
|
-
* (zero-copy; `pool.view(slotId)` is the SSOT byte region). In both cases
|
|
236
|
-
* the view is valid only until the next structural change. Internal callers
|
|
237
|
-
* must not write through it except via the owner mutation helpers.
|
|
238
|
-
*
|
|
239
|
-
* For variable arrays the typed-array length matches the live count from
|
|
240
|
-
* the sidecar `<fieldName>:count` column; for fixed arrays it matches the
|
|
241
|
-
* schema-declared `N`. `entity` element fields surface as a `Uint32Array`
|
|
242
|
-
* view (Entity packs slot+gen into u32).
|
|
243
|
-
*/
|
|
244
|
-
materializeArrayView(arch: Archetype, component: Component, row: number, fieldName: string, elementType: ManagedArrayElementType, fixedLength: number | undefined, slotId: number): Float32Array | Float64Array | Int32Array | Uint32Array | Int16Array | Uint16Array | Int8Array | Uint8Array;
|
|
245
|
-
/**
|
|
246
|
-
* Migrate an entity from srcArch to targetArch.
|
|
247
|
-
* Copies all shared component data, then removes from src via swap-pop.
|
|
248
|
-
*
|
|
249
|
-
* AC-04 carry-over contract (M4): for every component that survives the
|
|
250
|
-
* migration (i.e. the target archetype carries the same `compId`), every
|
|
251
|
-
* field column's u32 value is copied verbatim from src to target. This
|
|
252
|
-
* preserves every managed resource handle in place:
|
|
253
|
-
*
|
|
254
|
-
* - `ref<T>` field - the u32 (managed handle = (slot << 8) | gen) is
|
|
255
|
-
* bit-equal across migrate, so `Object.is` on the
|
|
256
|
-
* handle holds and `UniqueRefStore.resolve` returns
|
|
257
|
-
* the same payload object reference (per-(slot, gen)
|
|
258
|
-
* wrapper singleton, D-3).
|
|
259
|
-
* - `buffer<N>` field - fixed-capacity inline stride-N `u8` column
|
|
260
|
-
* (feat-20260602): the N bytes are copied verbatim
|
|
261
|
-
* by the generic per-column row copy, so the live
|
|
262
|
-
* bytes survive byte-for-byte. No BufferPool slot
|
|
263
|
-
* (only variable `buffer` carries a pool slot id).
|
|
264
|
-
* - `entity` field - the u32 (encoded slot+gen) is bit-equal across
|
|
265
|
-
* migrate.
|
|
266
|
-
* - `array<T,N>` field - fixed-capacity inline stride-N column
|
|
267
|
-
* (feat-20260602): the N elements live contiguously
|
|
268
|
-
* in the column row and are copied verbatim by the
|
|
269
|
-
* generic per-column row copy, so they survive
|
|
270
|
-
* byte-for-byte (no BufferPool slot). The TypedArray
|
|
271
|
-
* snapshot is rematerialised on every `world.get`
|
|
272
|
-
* (D-4 no cache); we do NOT guarantee `Object.is` on
|
|
273
|
-
* the wrapper — only the underlying bytes (D-R7 weak
|
|
274
|
-
* carry-over).
|
|
275
|
-
* - `array<T>` field - dual u32 columns: primary slot id + sidecar
|
|
276
|
-
* `<fieldName>:count`. Both columns are copied via
|
|
277
|
-
* the generic per-column loop below, so count and
|
|
278
|
-
* slot id stay in lock-step. Capacity is derived
|
|
279
|
-
* from `BufferPool.view(slotId).byteLength /
|
|
280
|
-
* elementBytes` and is therefore preserved by the
|
|
281
|
-
* slot-id carry-over alone (no separate column).
|
|
282
|
-
*
|
|
283
|
-
* Negative invariant: this routine MUST NOT call UniqueRefStore.release /
|
|
284
|
-
* BufferPool.release for surviving components. The pre-migrate release
|
|
285
|
-
* loop lives at `removeComponent` (only for the component being removed)
|
|
286
|
-
* and `despawn` (every component); migrate is only a column copy. The
|
|
287
|
-
* array-field release-loop split (D-3 / D-5) further guarantees that
|
|
288
|
-
* spawn into a vacated row treats stale slot-id debris as no-op (the slot
|
|
289
|
-
* is owned by the migrated entity in the new archetype) — see
|
|
290
|
-
* `writeArrayField`'s `operation: 'spawn' | 'set'` discriminant.
|
|
291
|
-
* Tests: `__tests__/managed-carry-over.test.ts` (w16),
|
|
292
|
-
* `__tests__/managed-array-carry-over.test.ts` (w8).
|
|
293
|
-
*/
|
|
294
|
-
migrateEntity(record: EntityRecord, srcArch: Archetype, targetArch: Archetype): void;
|
|
295
|
-
moveEntityArchetype(record: EntityRecord, srcArch: Archetype, targetArch: Archetype): void;
|
|
296
|
-
}
|
|
297
|
-
export {};
|
|
298
|
-
//# sourceMappingURL=world-component-storage.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"world-component-storage.d.ts","sourceRoot":"","sources":["../src/world-component-storage.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EACL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