@oasys/oecs 0.5.2 → 0.5.3

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.
Files changed (40) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/core/ecs/ecs_memory.d.cts +6 -6
  3. package/dist/core/ecs/ecs_memory.d.ts +6 -6
  4. package/dist/core/ecs/ecs_memory.d.ts.map +1 -1
  5. package/dist/core/store/allocator.d.cts +44 -19
  6. package/dist/core/store/allocator.d.ts +44 -19
  7. package/dist/core/store/allocator.d.ts.map +1 -1
  8. package/dist/core/store/column_store.d.cts +1 -1
  9. package/dist/core/store/column_store.d.ts +1 -1
  10. package/dist/core/store/extend.d.ts.map +1 -1
  11. package/dist/core/store/grow.d.ts.map +1 -1
  12. package/dist/core/store/layout_ops.d.cts +18 -0
  13. package/dist/core/store/layout_ops.d.ts +18 -0
  14. package/dist/core/store/layout_ops.d.ts.map +1 -1
  15. package/dist/{host_commands-BI8pEmjH.js → host_commands-3jyFfWNg.js} +2 -2
  16. package/dist/{host_commands-CxhpzMx9.cjs → host_commands-DNf0f6ko.cjs} +1 -1
  17. package/dist/index.cjs +1 -1
  18. package/dist/index.d.cts +1 -1
  19. package/dist/index.d.ts +1 -1
  20. package/dist/index.development.cjs +1 -1
  21. package/dist/index.development.js +197 -194
  22. package/dist/index.js +195 -192
  23. package/dist/{internal-BMDgWZbt.js → internal-C9jjL90H.js} +2 -2
  24. package/dist/{internal-LiTSB_tG.cjs → internal-RZN14uMw.cjs} +2 -2
  25. package/dist/internal.cjs +1 -1
  26. package/dist/internal.development.cjs +1 -1
  27. package/dist/internal.development.js +1 -1
  28. package/dist/internal.js +1 -1
  29. package/dist/shared-BMXh9hxm.cjs +1 -0
  30. package/dist/{shared-BU1Cd40h.js → shared-DQKK0i-E.js} +38 -32
  31. package/dist/shared.cjs +1 -1
  32. package/dist/shared.d.cts +1 -1
  33. package/dist/shared.d.ts +1 -1
  34. package/dist/shared.development.cjs +1 -1
  35. package/dist/shared.development.js +1 -1
  36. package/dist/shared.js +1 -1
  37. package/dist/version.d.cts +1 -1
  38. package/dist/version.d.ts +1 -1
  39. package/package.json +1 -1
  40. package/dist/shared-BymrGTyR.cjs +0 -1
@@ -1,8 +1,8 @@
1
- import { v as wt, i as Et, S as D, a as _t, b as gt, c as yt, r as ce, d as le, e as $t, u as M, E as _, f as g, N as W, D as ue, g as b, h as m, U as T, j as Ce, k as Re, l as Ae, R as Oe, m as Ie, n as A, o as ot, I as Ut, p as It, q as de, s as Te, t as De, w as ke, x as mt, y as fe, z as Ft, A as pe, B as rt, C as _e, F as Tt, T as xe, G as Me, H as dt, J as Ne, K as Le, L as at, M as $e, O as Fe, P as Be, Q as Ge, V as qt, W as Pe, X as Vt, Y as He, Z as Ue, _ as qe, $, a0 as Ve, a1 as Wt, a2 as J, a3 as zt, a4 as We, a5 as Y, a6 as ct, a7 as ze, a8 as je, a9 as vt, aa as Ye, ab as Qe, ac as Ke, ad as k, ae as F, af as Xe, ag as Ze, ah as Je, ai as ts, aj as es, ak as ss } from "./internal-BMDgWZbt.js";
2
- import { as as Mn, aq as Nn, al as Ln, ap as $n, an as Fn, at as Bn, ar as Gn, am as Pn, ao as Hn } from "./internal-BMDgWZbt.js";
3
- import { h as ns, B as U, i as rs, j as is } from "./typed_arrays-BcXcnzB4.js";
4
- import { D as os, S as jt, g as hs } from "./shared-BU1Cd40h.js";
5
- import { a as qn } from "./shared-BU1Cd40h.js";
1
+ import { v as wt, i as Et, S as D, a as _t, b as gt, c as yt, r as ce, d as le, e as $t, u as M, E as _, f as g, N as W, D as ue, g as b, h as m, U as T, j as Re, k as Ae, l as Oe, R as Ie, m as Te, n as A, o as ot, I as Ut, p as It, q as de, s as De, t as ke, w as xe, x as mt, y as fe, z as Ft, A as pe, B as rt, C as _e, F as Tt, T as Me, G as Ne, H as dt, J as Le, K as $e, L as at, M as Fe, O as Be, P as Ge, Q as Pe, V as qt, W as He, X as Vt, Y as Ue, Z as qe, _ as Ve, $, a0 as We, a1 as Wt, a2 as J, a3 as zt, a4 as ze, a5 as Y, a6 as ct, a7 as je, a8 as Ye, a9 as vt, aa as Qe, ab as Ke, ac as Xe, ad as k, ae as F, af as Ze, ag as Je, ah as ts, ai as es, aj as ss, ak as ns } from "./internal-C9jjL90H.js";
2
+ import { as as Nn, aq as Ln, al as $n, ap as Fn, an as Bn, at as Gn, ar as Pn, am as Hn, ao as Un } from "./internal-C9jjL90H.js";
3
+ import { h as rs, B as U, i as is, j as os } from "./typed_arrays-BcXcnzB4.js";
4
+ import { D as hs, S as jt, g as as } from "./shared-DQKK0i-E.js";
5
+ import { a as Vn } from "./shared-DQKK0i-E.js";
6
6
  const B = !0, ge = (a) => wt(
7
7
  a,
8
8
  Et,
@@ -15,7 +15,7 @@ function ye(a) {
15
15
  }));
16
16
  return Object.defineProperty(t, "id", { value: a, enumerable: !1 }), t;
17
17
  }
18
- function un(a, ...t) {
18
+ function dn(a, ...t) {
19
19
  return { def: a, values: t[0] ?? Bt };
20
20
  }
21
21
  function K(a) {
@@ -29,11 +29,11 @@ class tt extends Error {
29
29
  super(t), this.name = "StoreRestoreError";
30
30
  }
31
31
  }
32
- function as(a) {
32
+ function cs(a) {
33
33
  const t = a.view.getUint32(D.capacity, !0);
34
34
  return new Uint8Array(a.buffer, 0, t);
35
35
  }
36
- function cs(a, t = os) {
36
+ function ls(a, t = hs) {
37
37
  const e = new DataView(a.buffer, a.byteOffset, a.byteLength);
38
38
  if (a.byteLength < _t)
39
39
  throw new tt(
@@ -69,12 +69,12 @@ function cs(a, t = os) {
69
69
  ) : h;
70
70
  }
71
71
  }
72
- const ls = (a) => wt(
72
+ const us = (a) => wt(
73
73
  a,
74
74
  Et,
75
75
  "EventID must be a non-negative integer"
76
76
  );
77
- class us {
77
+ class ds {
78
78
  fieldNames;
79
79
  columns;
80
80
  // any: type-erased storage — channel is stored in Map<number, EventChannel>, S is lost
@@ -117,13 +117,13 @@ class us {
117
117
  t[e].length = 0;
118
118
  }
119
119
  }
120
- function dn(a) {
120
+ function fn(a) {
121
121
  return M(Symbol(a));
122
122
  }
123
- function fn(a) {
123
+ function pn(a) {
124
124
  return M(Symbol(a));
125
125
  }
126
- class ds {
126
+ class fs {
127
127
  // Parallel array indexed by EventID: each channel holds SoA columns + reader.
128
128
  channels = [];
129
129
  // IDs of channels emitted to since the last `clearEvents()`. An `emit*`
@@ -136,7 +136,7 @@ class ds {
136
136
  // callers via EventKey<F>
137
137
  keyMap = /* @__PURE__ */ new Map();
138
138
  registerEvent(t) {
139
- const e = ls(this.count++), s = new us(t);
139
+ const e = us(this.count++), s = new ds(t);
140
140
  return this.channels.push(s), M(e);
141
141
  }
142
142
  emitEvent(t, e) {
@@ -192,7 +192,7 @@ class ds {
192
192
  return this.keyMap.has(t);
193
193
  }
194
194
  }
195
- class fs {
195
+ class ps {
196
196
  map = /* @__PURE__ */ new Map();
197
197
  register(t, e) {
198
198
  if (this.map.has(t))
@@ -465,7 +465,7 @@ class Gt {
465
465
  * current SAB row capacity. (#171 §6.1.9 Phase 3) */
466
466
  growHandler = null;
467
467
  constructor(t, e, s, n = ue, r) {
468
- if (this.id = t, this.mask = e, this._entityIds = new ns(n), s) {
468
+ if (this.id = t, this.mask = e, this._entityIds = new rs(n), s) {
469
469
  let i = 0;
470
470
  for (let o = 0; o < s.length; o++) {
471
471
  const h = s[o], c = h.componentId, l = new Array(h.fieldNames.length);
@@ -502,7 +502,7 @@ class Gt {
502
502
  `ColumnStore has no archetype ${r}`
503
503
  );
504
504
  const o = (c, l) => {
505
- const u = i.columns.get(Ce(c, l));
505
+ const u = i.columns.get(Re(c, l));
506
506
  if (!u)
507
507
  throw new _(
508
508
  g.COMPONENT_NOT_REGISTERED,
@@ -609,7 +609,7 @@ class Gt {
609
609
  const s = this.enabledCount;
610
610
  if (s === t)
611
611
  return this.enabledCount = t + 1, t;
612
- if (e === void 0) throw ps();
612
+ if (e === void 0) throw _s();
613
613
  if (this.swapRows(s, t), e !== void 0) {
614
614
  const n = this._entityIds.buf;
615
615
  e[b(n[t])] = t;
@@ -1198,7 +1198,7 @@ function et(a) {
1198
1198
  `${a} hit an archetype a live query iteration is visiting — immediate structural mutation mid-walk relocates rows under the iterator (entities get skipped or visited twice). Collect ids during the walk and mutate after it; inside a system use the deferred ctx.commands.`
1199
1199
  );
1200
1200
  }
1201
- function ps() {
1201
+ function _s() {
1202
1202
  return new _(
1203
1203
  g.PARTITION_APPEND_NEEDS_ENTITY_ROW,
1204
1204
  "appending into a disabled-bearing archetype requires the entity_row map (to repoint the displaced disabled row). A Store append path is missing its entity_row argument."
@@ -1231,7 +1231,7 @@ const me = (a) => wt(
1231
1231
  function Xt(a) {
1232
1232
  return typeof a == "object" && !Array.isArray(a);
1233
1233
  }
1234
- function _s(a) {
1234
+ function gs(a) {
1235
1235
  let t = st;
1236
1236
  a.spawns !== void 0 && a.spawns.length > 0 && (t = a.spawns.map((s) => Xt(s) ? s.defs : s));
1237
1237
  let e = st;
@@ -1255,7 +1255,7 @@ function _s(a) {
1255
1255
  relationWrites: a.relationWrites
1256
1256
  };
1257
1257
  }
1258
- function gs(a) {
1258
+ function ys(a) {
1259
1259
  const t = a.queries;
1260
1260
  if (t === void 0 || a.exclusive === !0) return;
1261
1261
  const e = /* @__PURE__ */ new Set();
@@ -1284,26 +1284,26 @@ const xt = Object.freeze({
1284
1284
  sparseWrites: Object.freeze([]),
1285
1285
  relationReads: Object.freeze([]),
1286
1286
  relationWrites: Object.freeze([])
1287
- }), ys = Symbol.dispose ?? Symbol.for("Symbol.dispose"), bt = (1 << 20) - 1;
1288
- let ms = 0;
1289
- function ws(a, t) {
1287
+ }), ms = Symbol.dispose ?? Symbol.for("Symbol.dispose"), bt = (1 << 20) - 1;
1288
+ let ws = 0;
1289
+ function Es(a, t) {
1290
1290
  const e = {
1291
1291
  ...xt,
1292
1292
  ...t,
1293
- id: me(ms++),
1293
+ id: me(ws++),
1294
1294
  name: a,
1295
- fn: Es
1295
+ fn: vs
1296
1296
  };
1297
1297
  return Object.freeze(e);
1298
1298
  }
1299
- function Es() {
1299
+ function vs() {
1300
1300
  }
1301
1301
  function Zt(a) {
1302
1302
  const t = /* @__PURE__ */ new Set();
1303
1303
  if (a) for (let e = 0; e < a.length; e++) t.add(a[e].id);
1304
1304
  return t;
1305
1305
  }
1306
- function vs(a) {
1306
+ function bs(a) {
1307
1307
  const t = (i, o) => i.cid - o.cid || i.id - o.id, e = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
1308
1308
  for (const i of a)
1309
1309
  e.set(i, []), s.set(i, 0);
@@ -1334,7 +1334,7 @@ function vs(a) {
1334
1334
  }
1335
1335
  return r;
1336
1336
  }
1337
- class bs {
1337
+ class Ss {
1338
1338
  constructor(t, e) {
1339
1339
  this.store = t, this.ctx = e;
1340
1340
  }
@@ -1388,8 +1388,8 @@ class bs {
1388
1388
  g.OBSERVER_INVALID_CONFIG,
1389
1389
  "observe(): at least one of onAdd / onRemove / onDisable / onEnable / onSet is required"
1390
1390
  );
1391
- const o = e.access ?? {}, h = ws(
1392
- e.name ?? `observer(${Re(t) ?? s})`,
1391
+ const o = e.access ?? {}, h = Es(
1392
+ e.name ?? `observer(${Ae(t) ?? s})`,
1393
1393
  o
1394
1394
  ), c = {
1395
1395
  // Share one identity space with the descriptor (used only for the
@@ -1414,7 +1414,7 @@ class bs {
1414
1414
  let l = this.byCid.get(s);
1415
1415
  l === void 0 && (l = [], this.byCid.set(s, l)), l.push(c), this._topo = null, this._reconfigureComponent(s), c.yieldExisting && c.onAdd !== void 0 && this._yieldExisting(c);
1416
1416
  const u = () => this._dispose(c);
1417
- return { dispose: u, [ys]: u };
1417
+ return { dispose: u, [ms]: u };
1418
1418
  }
1419
1419
  _dispose(t) {
1420
1420
  if (t.disposed) return;
@@ -1449,7 +1449,7 @@ class bs {
1449
1449
  );
1450
1450
  }
1451
1451
  getTopo() {
1452
- return this._topo === null && (this._topo = vs(this.entries)), this._topo;
1452
+ return this._topo === null && (this._topo = bs(this.entries)), this._topo;
1453
1453
  }
1454
1454
  // =======================================================
1455
1455
  // Structural dispatch (onAdd / onRemove)
@@ -1600,7 +1600,7 @@ function ft(a, t, e, s) {
1600
1600
  }
1601
1601
  }
1602
1602
  }
1603
- class Ss {
1603
+ class Cs {
1604
1604
  constructor(t) {
1605
1605
  this.host = t;
1606
1606
  }
@@ -1662,9 +1662,9 @@ class Ss {
1662
1662
  g.RELATION_MODE_INVALID,
1663
1663
  "register_relation: a relation cannot be both exclusive and multi-target"
1664
1664
  );
1665
- const n = !e, r = t?.onDeleteTarget ?? Ae, i = n ? this.host.pushSparseStore([Oe], ["f64"]) : this.host.pushSparseStore([], []), o = this.relations.length;
1665
+ const n = !e, r = t?.onDeleteTarget ?? Oe, i = n ? this.host.pushSparseStore([Ie], ["f64"]) : this.host.pushSparseStore([], []), o = this.relations.length;
1666
1666
  return this.relations.push(
1667
- Ie(n, i, this.host.sparseStoreOf(i), r)
1667
+ Te(n, i, this.host.sparseStoreOf(i), r)
1668
1668
  ), r !== "orphan" && (this._hasTargetCleanup = !0), M(o);
1669
1669
  }
1670
1670
  relationOf(t) {
@@ -2104,7 +2104,7 @@ class Ss {
2104
2104
  return s.get(t);
2105
2105
  }
2106
2106
  }
2107
- class Cs {
2107
+ class Rs {
2108
2108
  /** SAB-backed per-slot generation counters — replanted on restore. */
2109
2109
  _generations;
2110
2110
  /** Single-slot view over the entity-index region's `length` header field —
@@ -2211,7 +2211,7 @@ class Cs {
2211
2211
  }
2212
2212
  }
2213
2213
  const Jt = 65536;
2214
- class Rs {
2214
+ class As {
2215
2215
  // --- Deferred operation buffers ---
2216
2216
  // Flat parallel arrays: addIds[i], addDefs[i], addValues[i] describe one
2217
2217
  // deferred add. No per-operation object allocation. Public so the Store
@@ -2298,7 +2298,7 @@ function we(a, t) {
2298
2298
  const r = t[n], i = new Array(r.columns.length);
2299
2299
  for (let o = 0; o < r.columns.length; o++) {
2300
2300
  const h = r.columns[o];
2301
- e = Te(e, h.stride), i[o] = {
2301
+ e = De(e, h.stride), i[o] = {
2302
2302
  componentId: h.componentId,
2303
2303
  fieldId: h.fieldId,
2304
2304
  typeTag: h.typeTag,
@@ -2315,15 +2315,18 @@ function we(a, t) {
2315
2315
  columns: i
2316
2316
  };
2317
2317
  }
2318
- if (e > De)
2319
- throw new ke(e);
2318
+ if (e > ke)
2319
+ throw new xe(e);
2320
2320
  return { descriptors: s, newTotal: e };
2321
2321
  }
2322
2322
  function Ee(a, t) {
2323
2323
  const e = a._allocator(t), s = e !== a.buffer ? new DataView(e) : a.view;
2324
2324
  return { grownBuffer: e, newView: s };
2325
2325
  }
2326
- function As(a) {
2326
+ function ve(a) {
2327
+ return a.buffer instanceof ArrayBuffer ? a.view.getUint32(D.capacity, !0) : a.buffer.byteLength;
2328
+ }
2329
+ function Os(a) {
2327
2330
  const t = {};
2328
2331
  for (let n = 0; n < mt.length; n++) {
2329
2332
  const r = mt[n], i = a.view.getUint32(D[r.headerOff], !0);
@@ -2346,7 +2349,7 @@ function As(a) {
2346
2349
  }
2347
2350
  return Ft(a) && a._reservedDescriptorBytes > 0 && (t.reservedDescriptorBytes = a._reservedDescriptorBytes), t;
2348
2351
  }
2349
- function Os(a) {
2352
+ function Is(a) {
2350
2353
  const t = /* @__PURE__ */ new Map();
2351
2354
  for (let n = 0; n < mt.length; n++) {
2352
2355
  const r = mt[n], i = a.view.getUint32(D[r.headerOff], !0);
@@ -2361,7 +2364,7 @@ function Os(a) {
2361
2364
  }
2362
2365
  return { mechanism: t, consumer: e };
2363
2366
  }
2364
- function Is(a, t) {
2367
+ function Ts(a, t) {
2365
2368
  for (const [e, s] of t.mechanism) {
2366
2369
  const n = a.view.getUint32(D[e], !0);
2367
2370
  new Uint8Array(a.buffer, n, s.byteLength).set(s);
@@ -2372,7 +2375,7 @@ function Is(a, t) {
2372
2375
  new Uint8Array(a.buffer, n, s.byteLength).set(s);
2373
2376
  }
2374
2377
  }
2375
- function Ts(a, t) {
2378
+ function Ds(a, t) {
2376
2379
  const e = /* @__PURE__ */ new Map();
2377
2380
  for (const [s, n] of a.archetypes) {
2378
2381
  const r = t.get(s) ?? 0;
@@ -2386,7 +2389,7 @@ function Ts(a, t) {
2386
2389
  }
2387
2390
  return e;
2388
2391
  }
2389
- function Ds(a, t) {
2392
+ function ks(a, t) {
2390
2393
  for (const [e, s] of t) {
2391
2394
  const n = a.archetypes.get(e);
2392
2395
  if (n === void 0)
@@ -2400,16 +2403,16 @@ function Ds(a, t) {
2400
2403
  }
2401
2404
  }
2402
2405
  }
2403
- function ve(a, t, e, s) {
2404
- const n = a.view.getUint32(D.view_stamp, !0), r = Ts(a, e), i = Os(a), o = As(a), h = de(t, s, o);
2405
- Ds(h, r), Is(h, i);
2406
+ function be(a, t, e, s) {
2407
+ const n = a.view.getUint32(D.view_stamp, !0), r = Ds(a, e), i = Is(a), o = Os(a), h = de(t, s, o);
2408
+ ks(h, r), Ts(h, i);
2406
2409
  const c = n + 1 >>> 0;
2407
2410
  return h.view.setUint32(D.view_stamp, c, !0), { store: {
2408
2411
  ...h,
2409
2412
  header: { ...h.header, viewStamp: c }
2410
2413
  }, oldViewStamp: n, newViewStamp: c };
2411
2414
  }
2412
- function ks(a, t, e) {
2415
+ function xs(a, t, e) {
2413
2416
  const s = new Array(t.length);
2414
2417
  for (let p = 0; p < t.length; p++) {
2415
2418
  const v = t[p], C = a.archetypes.get(v.archetypeId);
@@ -2420,7 +2423,7 @@ function ks(a, t, e) {
2420
2423
  columns: C.columnsInOrder
2421
2424
  };
2422
2425
  }
2423
- const { descriptors: n, newTotal: r } = we(a.buffer.byteLength, s), i = /* @__PURE__ */ new Map();
2426
+ const { descriptors: n, newTotal: r } = we(ve(a), s), i = /* @__PURE__ */ new Map();
2424
2427
  for (let p = 0; p < n.length; p++)
2425
2428
  i.set(n[p].archetypeId, n[p]);
2426
2429
  const { grownBuffer: o, newView: h } = Ee(a, r), c = new Uint8Array(o);
@@ -2476,7 +2479,7 @@ class pt extends Error {
2476
2479
  super(t), this.name = "StoreGrowError";
2477
2480
  }
2478
2481
  }
2479
- function xs(a, t, e) {
2482
+ function Ms(a, t, e) {
2480
2483
  const s = /* @__PURE__ */ new Map();
2481
2484
  for (let l = 0; l < t.archetypes.length; l++) {
2482
2485
  const u = t.archetypes[l];
@@ -2515,9 +2518,9 @@ function xs(a, t, e) {
2515
2518
  }
2516
2519
  if (e?.isInPlace === !0 && Ft(a) && a._allocator === e && r.length > 0) {
2517
2520
  const l = a.view.getUint32(D.layout_descriptor_off, !0);
2518
- return ks(a, r, l);
2521
+ return xs(a, r, l);
2519
2522
  }
2520
- const { store: o, oldViewStamp: h, newViewStamp: c } = ve(
2523
+ const { store: o, oldViewStamp: h, newViewStamp: c } = be(
2521
2524
  a,
2522
2525
  n,
2523
2526
  i,
@@ -2536,7 +2539,7 @@ class Q extends Error {
2536
2539
  super(t), this.name = "StoreExtendError";
2537
2540
  }
2538
2541
  }
2539
- function Ms(a, t, e) {
2542
+ function Ns(a, t, e) {
2540
2543
  if (t.newArchetypes.length === 0)
2541
2544
  throw new Q("extend plan has no new archetypes; use grow_column_store for resizes");
2542
2545
  const s = /* @__PURE__ */ new Set();
@@ -2580,7 +2583,7 @@ function Ms(a, t, e) {
2580
2583
  for (let d = 0; d < t.newArchetypes.length; d++)
2581
2584
  u += Tt(t.newArchetypes[d].columns.length);
2582
2585
  if (l + u <= a._regionBytes)
2583
- return Ns(a, t.newArchetypes, c, l);
2586
+ return Ls(a, t.newArchetypes, c, l);
2584
2587
  }
2585
2588
  const r = [];
2586
2589
  for (const [c, l] of a.archetypes)
@@ -2592,7 +2595,7 @@ function Ms(a, t, e) {
2592
2595
  });
2593
2596
  for (let c = 0; c < t.newArchetypes.length; c++)
2594
2597
  r.push(t.newArchetypes[c]);
2595
- const { store: i, oldViewStamp: o, newViewStamp: h } = ve(
2598
+ const { store: i, oldViewStamp: o, newViewStamp: h } = be(
2596
2599
  a,
2597
2600
  r,
2598
2601
  n,
@@ -2600,7 +2603,7 @@ function Ms(a, t, e) {
2600
2603
  );
2601
2604
  return { store: i, oldViewStamp: o, newViewStamp: h, viewsPreserved: !1 };
2602
2605
  }
2603
- function Ns(a, t, e, s) {
2606
+ function Ls(a, t, e, s) {
2604
2607
  const n = new Array(t.length);
2605
2608
  for (let E = 0; E < t.length; E++) {
2606
2609
  const p = t[E];
@@ -2612,12 +2615,12 @@ function Ns(a, t, e, s) {
2612
2615
  componentId: v.componentId,
2613
2616
  fieldId: v.fieldId,
2614
2617
  typeTag: v.typeTag,
2615
- stride: xe[v.typeTag]
2618
+ stride: Me[v.typeTag]
2616
2619
  }))
2617
2620
  };
2618
2621
  }
2619
2622
  const { descriptors: r, newTotal: i } = we(
2620
- a.buffer.byteLength,
2623
+ ve(a),
2621
2624
  n
2622
2625
  ), { grownBuffer: o, newView: h } = Ee(a, i);
2623
2626
  let c = e + s;
@@ -2656,7 +2659,7 @@ class x extends Error {
2656
2659
  }
2657
2660
  }
2658
2661
  const Z = 4;
2659
- function Ls(a) {
2662
+ function $s(a) {
2660
2663
  const t = a.freeIndices.length, e = a.archetypeRows.length, s = Z * (4 + t + 1 + e * 3), n = new Uint8Array(s), r = new DataView(n.buffer);
2661
2664
  let i = 0;
2662
2665
  const o = (h) => {
@@ -2671,7 +2674,7 @@ function Ls(a) {
2671
2674
  }
2672
2675
  return n;
2673
2676
  }
2674
- function $s(a) {
2677
+ function Fs(a) {
2675
2678
  const t = new DataView(a.buffer, a.byteOffset, a.byteLength), e = a.byteLength;
2676
2679
  let s = 0;
2677
2680
  const n = (f) => {
@@ -2696,11 +2699,11 @@ function $s(a) {
2696
2699
  );
2697
2700
  return { tick: i, entityHighWater: o, entityAliveCount: h, freeIndices: l, archetypeRows: d };
2698
2701
  }
2699
- function Fs(a, t, e) {
2702
+ function Bs(a, t, e) {
2700
2703
  const s = Z * 5, n = new Uint8Array(s + a.length + t.length + e.length), r = new DataView(n.buffer);
2701
2704
  return r.setUint32(0, Mt, !0), r.setUint32(4, Nt, !0), r.setUint32(8, a.length, !0), r.setUint32(12, t.length, !0), r.setUint32(16, e.length, !0), n.set(a, s), n.set(t, s + a.length), n.set(e, s + a.length + t.length), n;
2702
2705
  }
2703
- function Bs(a) {
2706
+ function Gs(a) {
2704
2707
  const t = Z * 5;
2705
2708
  if (a.byteLength < t)
2706
2709
  throw new x(
@@ -2728,7 +2731,7 @@ function Bs(a) {
2728
2731
  host: new Uint8Array(c, h + t + r + i, o)
2729
2732
  };
2730
2733
  }
2731
- function Gs(a, t, e) {
2734
+ function Ps(a, t, e) {
2732
2735
  if (a.byteLength < _t)
2733
2736
  throw new x(
2734
2737
  `dense section too small: ${a.byteLength} bytes (SAB header needs ${_t})`
@@ -2749,7 +2752,7 @@ function Gs(a, t, e) {
2749
2752
  `dense layoutDescriptorOff ${i.layoutDescriptorOff} is outside the section (${a.byteLength} bytes)`
2750
2753
  );
2751
2754
  const o = i.entityIndexOff;
2752
- if (o < 0 || o + Me > a.byteLength)
2755
+ if (o < 0 || o + Ne > a.byteLength)
2753
2756
  throw new x(
2754
2757
  `dense entityIndexOff ${o} is outside the section (${a.byteLength} bytes)`
2755
2758
  );
@@ -2780,7 +2783,7 @@ function Gs(a, t, e) {
2780
2783
  throw new x(
2781
2784
  `archetype-set mismatch: snapshot archetype ${u.archetypeId} is absent from the live world`
2782
2785
  );
2783
- if (!Ps(d.componentMask, u.componentMask))
2786
+ if (!Hs(d.componentMask, u.componentMask))
2784
2787
  throw new x(
2785
2788
  `archetype ${u.archetypeId} component-mask mismatch between the live world and the snapshot (different component registration)`
2786
2789
  );
@@ -2796,12 +2799,12 @@ function Gs(a, t, e) {
2796
2799
  );
2797
2800
  }
2798
2801
  }
2799
- function Ps(a, t) {
2802
+ function Hs(a, t) {
2800
2803
  if (a.length !== t.length) return !1;
2801
2804
  for (let e = 0; e < a.length; e++) if (a[e] !== t[e]) return !1;
2802
2805
  return !0;
2803
2806
  }
2804
- class Hs {
2807
+ class Us {
2805
2808
  host;
2806
2809
  /** The allocator IS its own snapshot seam (H1 step 3): free-list copy on
2807
2810
  * capture; `setHighWater` + `restoreHostState` on mount. */
@@ -2819,7 +2822,7 @@ class Hs {
2819
2822
  * different orders snapshot byte-for-byte the same (#470). The reverse index
2820
2823
  * is derived and never serialized — `restoreSparse` rebuilds it. */
2821
2824
  snapshotSparse() {
2822
- const t = Ne(this.host.sparseStores()), e = Le(this.host.relationStores()), s = new Uint8Array(8 + t.length + e.length), n = new DataView(s.buffer);
2825
+ const t = Le(this.host.sparseStores()), e = $e(this.host.relationStores()), s = new Uint8Array(8 + t.length + e.length), n = new DataView(s.buffer);
2823
2826
  return n.setUint32(0, t.length, !0), n.setUint32(4, e.length, !0), s.set(t, 8), s.set(e, 8 + t.length), s;
2824
2827
  }
2825
2828
  /** Repopulate the sparse stores from `snapshotSparse` bytes, replacing all
@@ -2842,7 +2845,7 @@ class Hs {
2842
2845
  throw new at(
2843
2846
  `sparse snapshot frame mismatch: header declares 8+${s}+${n}=${8 + s + n} bytes, buffer is ${t.byteLength}`
2844
2847
  );
2845
- $e(this.host.sparseStores(), t.subarray(8, 8 + s)), this.rebuildRelationIndices(t.subarray(8 + s, 8 + s + n));
2848
+ Fe(this.host.sparseStores(), t.subarray(8, 8 + s)), this.rebuildRelationIndices(t.subarray(8 + s, 8 + s + n));
2846
2849
  }
2847
2850
  /** Rebuild every relation's derived side indices after the sparse stores have
2848
2851
  * been restored. `restoreRelations` resets all relations, rebuilds the multi
@@ -2852,7 +2855,7 @@ class Hs {
2852
2855
  * `(source index → target EntityID)`, which is exactly one reverse edge. */
2853
2856
  rebuildRelationIndices(t) {
2854
2857
  const e = this.host.generations(), s = (r) => ot(r, e[r]), n = this.host.relationStores();
2855
- Fe(n, t, s);
2858
+ Be(n, t, s);
2856
2859
  for (let r = 0; r < n.length; r++) n[r].rebuildReverseFromForward(s);
2857
2860
  }
2858
2861
  /** Capture the full live world to one self-contained byte buffer that
@@ -2861,8 +2864,8 @@ class Hs {
2861
2864
  * relation bytes, and the host-side bookkeeping the SAB omits. */
2862
2865
  snapshot() {
2863
2866
  this.host.publishRowCounts();
2864
- const t = new Uint8Array(as(this.host.columnStore())), e = this.snapshotSparse(), s = Ls(this.collectHostState());
2865
- return Fs(t, e, s);
2867
+ const t = new Uint8Array(cs(this.host.columnStore())), e = this.snapshotSparse(), s = $s(this.collectHostState());
2868
+ return Bs(t, e, s);
2866
2869
  }
2867
2870
  /** Gather the host-side state a snapshot carries alongside the dense + sparse
2868
2871
  * bytes — see `snapshot()`. The free-list is copied (it's a live mutable). */
@@ -2888,13 +2891,13 @@ class Hs {
2888
2891
  * ticking. Fails closed on a malformed frame or a registration mismatch
2889
2892
  * BEFORE any live state is touched. */
2890
2893
  restoreInto(t) {
2891
- const e = Bs(t), s = $s(e.host);
2892
- Gs(
2894
+ const e = Gs(t), s = Fs(e.host);
2895
+ Ps(
2893
2896
  e.dense,
2894
2897
  this.host.columnStore().archetypes,
2895
2898
  this.host.entityIndexCapacity()
2896
2899
  ), this.assertSparseSectionMatches(e.sparse);
2897
- const n = cs(e.dense, this.host.bufferAllocator());
2900
+ const n = ls(e.dense, this.host.bufferAllocator());
2898
2901
  this.host.mountRestoredDense(n), this.host.reconstructHostRows(s), this.allocator.restoreHostState(s.freeIndices, s.entityAliveCount), this.host.setTick(s.tick), this.host.invalidateQueryCaches(), this.restoreSparse(e.sparse);
2899
2902
  }
2900
2903
  /** Read-only validation of a `snapshotSparse` SECTION (the framed
@@ -2916,14 +2919,14 @@ class Hs {
2916
2919
  throw new at(
2917
2920
  `sparse snapshot frame mismatch: header declares 8+${s}+${n}=${8 + s + n} bytes, buffer is ${t.byteLength}`
2918
2921
  );
2919
- Be(this.host.sparseStores(), t.subarray(8, 8 + s));
2922
+ Ge(this.host.sparseStores(), t.subarray(8, 8 + s));
2920
2923
  }
2921
2924
  }
2922
- function be(a, t, e) {
2925
+ function Se(a, t, e) {
2923
2926
  const s = a.get(t);
2924
2927
  s !== void 0 ? s.push(e) : a.set(t, [e]);
2925
2928
  }
2926
- class Us {
2929
+ class qs {
2927
2930
  /** All archetypes, indexed by `ArchetypeID` (ids are minted monotonically
2928
2931
  * and never removed). Store's flush loops hoist this array to a local. */
2929
2932
  archetypes = [];
@@ -3049,7 +3052,7 @@ class Us {
3049
3052
  * mask-allocating callers (`copyWithSet`, `copyWithClear`, etc.). */
3050
3053
  install(t, e, s, n) {
3051
3054
  const r = e.copy(), i = this.host.materialize(t, r, s);
3052
- this.archetypes.push(i), be(this.archetypeMap, n, t), e.forEach((o) => {
3055
+ this.archetypes.push(i), Se(this.archetypeMap, n, t), e.forEach((o) => {
3053
3056
  const h = o;
3054
3057
  let c = this.componentIndex[h];
3055
3058
  if (c === void 0 && (c = [], this.componentIndex[h] = c), c.length > 0 && t <= c[c.length - 1])
@@ -3108,7 +3111,7 @@ function te(a, t, e, s) {
3108
3111
  n.push({
3109
3112
  componentId: h.componentId,
3110
3113
  fieldId: l,
3111
- typeTag: Ge[c[l]]
3114
+ typeTag: Pe[c[l]]
3112
3115
  });
3113
3116
  }
3114
3117
  const r = t._words, i = new Array(qt);
@@ -3121,8 +3124,8 @@ function te(a, t, e, s) {
3121
3124
  columns: n
3122
3125
  };
3123
3126
  }
3124
- const qs = [], ee = -1, St = new DataView(new ArrayBuffer(8)), se = 129, Vs = 7, Ct = -1;
3125
- class Ws {
3127
+ const Vs = [], ee = -1, St = new DataView(new ArrayBuffer(8)), se = 129, Ws = 7, Ct = -1;
3128
+ class zs {
3126
3129
  // --- Entity ID management ---
3127
3130
  // Generational slot allocation (generations view, high-water, free-list,
3128
3131
  // alive count) lives in `EntityAllocator` (H1 step 3). `entityArchetype` /
@@ -3159,7 +3162,7 @@ class Ws {
3159
3162
  // --- Event channels ---
3160
3163
  // Channel array + key map + per-tick dirty list live in `EventRegistry`
3161
3164
  // (event_registry.ts, H1 step 2); the event methods below delegate.
3162
- events = new ds();
3165
+ events = new fs();
3163
3166
  // --- Archetype management ---
3164
3167
  // Topology (archetype list, mask→id map, id counter, inverted component
3165
3168
  // index, edge resolution/creation) lives in `ArchetypeGraph` (H1 step 6).
@@ -3360,7 +3363,7 @@ class Ws {
3360
3363
  }
3361
3364
  let l;
3362
3365
  try {
3363
- l = xs(
3366
+ l = Ms(
3364
3367
  this._columnStore,
3365
3368
  { archetypes: h },
3366
3369
  this._bufferAllocator
@@ -3409,12 +3412,12 @@ class Ws {
3409
3412
  * that pass `new Store(4)` keep working. */
3410
3413
  constructor(t) {
3411
3414
  const e = typeof t == "number" ? { initialCapacity: t } : t ?? {};
3412
- if (this.initialCapacity = e.initialCapacity ?? ue, this._bufferAllocator = e.bufferAllocator ?? hs(), this._bufferAllocator.isInPlace !== !0)
3415
+ if (this.initialCapacity = e.initialCapacity ?? ue, this._bufferAllocator = e.bufferAllocator ?? as(), this._bufferAllocator.isInPlace !== !0)
3413
3416
  throw new _(
3414
3417
  g.INVALID_MEMORY_OPTIONS,
3415
3418
  "Store requires an in-place SAB allocator (ADR-0008): the flush loops keep writing through hoisted entity-index views across grows, so a non-in-place allocator (e.g. DEFAULT_SAB_ALLOCATOR) corrupts the entity→row mapping. Use growable_sab_allocator / wasm_memory_allocator; non-in-place allocators are snapshot/test sizing utilities only."
3416
3419
  );
3417
- this._capContext = e.capContext, this._onBufferResized = e.onBufferResized, this._entityIndexCapacity = e.entityIndexCapacity ?? Pe, this._regions = e.regions, this._bindingsRegionBytes = e.bindingsRegionBytes ?? 0, this._deterministic = e.deterministic ?? !1, this._deferred = new Rs(
3420
+ this._capContext = e.capContext, this._onBufferResized = e.onBufferResized, this._entityIndexCapacity = e.entityIndexCapacity ?? He, this._regions = e.regions, this._bindingsRegionBytes = e.bindingsRegionBytes ?? 0, this._deterministic = e.deterministic ?? !1, this._deferred = new As(
3418
3421
  {
3419
3422
  applyAdds: () => this._flushAdds(),
3420
3423
  applyRemoves: () => this._flushRemoves(),
@@ -3425,7 +3428,7 @@ class Ws {
3425
3428
  structuralObserverHook: () => this._structuralObserverHook
3426
3429
  },
3427
3430
  this._obsEvents
3428
- ), this.relationService = new Ss({
3431
+ ), this.relationService = new Cs({
3429
3432
  isAlive: (n) => this.isAlive(n),
3430
3433
  hasSparse: (n, r) => this.hasSparse(n, r),
3431
3434
  pushSparseStore: (n, r) => this._pushSparseStore(n, r),
@@ -3448,9 +3451,9 @@ class Ws {
3448
3451
  }), this._columnStore = de([], this._bufferAllocator, {
3449
3452
  reservedDescriptorBytes: 64 * 1024,
3450
3453
  entityIndexCapacity: this._entityIndexCapacity,
3451
- eventRingCapacitySlots: Ke,
3452
- commandRingCapacitySlots: Qe,
3453
- actionRingCapacitySlots: Ye,
3454
+ eventRingCapacitySlots: Xe,
3455
+ commandRingCapacitySlots: Ke,
3456
+ actionRingCapacitySlots: Qe,
3454
3457
  regions: this._regions,
3455
3458
  bindingsRegionBytes: this._bindingsRegionBytes
3456
3459
  });
@@ -3459,7 +3462,7 @@ class Ws {
3459
3462
  this._columnStore.header.entityIndexOff,
3460
3463
  this._entityIndexCapacity
3461
3464
  );
3462
- this.entityArchetype = s.archetypes, this.entityRow = s.rows, this.entityAllocator = new Cs(
3465
+ this.entityArchetype = s.archetypes, this.entityRow = s.rows, this.entityAllocator = new Rs(
3463
3466
  this._entityIndexCapacity,
3464
3467
  s.generations,
3465
3468
  new Uint32Array(
@@ -3467,7 +3470,7 @@ class Ws {
3467
3470
  this._columnStore.header.entityIndexOff + dt.length,
3468
3471
  1
3469
3472
  )
3470
- ), this._snapshots = new Hs(
3473
+ ), this._snapshots = new Us(
3471
3474
  {
3472
3475
  sparseStores: () => this.sparseStores,
3473
3476
  relationStores: () => this.relationService.stores,
@@ -3488,7 +3491,7 @@ class Ws {
3488
3491
  }
3489
3492
  },
3490
3493
  this.entityAllocator
3491
- ), this.archGraph = new Us({
3494
+ ), this.archGraph = new qs({
3492
3495
  componentMetas: () => this.componentMetas,
3493
3496
  initialCapacity: () => this.initialCapacity,
3494
3497
  extendStore: (n) => this._archExtendStoreWithNewSpecs(n),
@@ -3598,7 +3601,7 @@ class Ws {
3598
3601
  * view over exactly the region's span without re-reading the directory.
3599
3602
  * Re-fetch after a SAB grow (the offset/view may have moved). (#623) */
3600
3603
  regionHandle(t) {
3601
- const e = He(this._columnStore.view, t);
3604
+ const e = Ue(this._columnStore.view, t);
3602
3605
  return e === null ? null : {
3603
3606
  buffer: this._columnStore.buffer,
3604
3607
  view: this._columnStore.view,
@@ -3660,7 +3663,7 @@ class Ws {
3660
3663
  e + rt.enabled_count,
3661
3664
  r.hasColumns ? r.enabledCount : 0,
3662
3665
  !0
3663
- ), e += Ue + i * qe;
3666
+ ), e += qe + i * Ve;
3664
3667
  }
3665
3668
  this._rowCountsDirty = !1;
3666
3669
  }
@@ -3709,7 +3712,7 @@ class Ws {
3709
3712
  * target sets) is the determinism tax the flag gates. */
3710
3713
  stateHash() {
3711
3714
  this._requireDeterministic("state_hash()");
3712
- let t = Ve;
3715
+ let t = We;
3713
3716
  const e = this.archGraph.archetypes;
3714
3717
  for (let r = 0; r < e.length; r++) {
3715
3718
  const i = e[r], o = i.id, h = i.length;
@@ -3816,7 +3819,7 @@ class Ws {
3816
3819
  }
3817
3820
  let n;
3818
3821
  try {
3819
- n = Ms(
3822
+ n = Ns(
3820
3823
  this._columnStore,
3821
3824
  { newArchetypes: t, existing: e },
3822
3825
  this._bufferAllocator
@@ -4070,7 +4073,7 @@ class Ws {
4070
4073
  * well-formed handle pays two branches and nothing else (#778 measured).
4071
4074
  */
4072
4075
  isAlive(t) {
4073
- if (t < 0 || t > We) return !1;
4076
+ if (t < 0 || t > ze) return !1;
4074
4077
  const e = zt(t);
4075
4078
  if (e === It) return !1;
4076
4079
  const s = b(t);
@@ -4365,8 +4368,8 @@ class Ws {
4365
4368
  if (Ht)
4366
4369
  N.moveEntityFromTag(O, j, p, i);
4367
4370
  else {
4368
- const Se = O.getEdge(R);
4369
- N.moveEntityFrom(O, j, p, Se.addMap, u, i);
4371
+ const Ce = O.getEdge(R);
4372
+ N.moveEntityFrom(O, j, p, Ce.addMap, u, i);
4370
4373
  }
4371
4374
  ht = L[0];
4372
4375
  } else
@@ -4460,7 +4463,7 @@ class Ws {
4460
4463
  * when nothing is dirty. Caller owns the returned array. */
4461
4464
  _takeDirty(t) {
4462
4465
  const e = this._dirtyLists[t];
4463
- if (e === void 0 || e.length === 0) return qs;
4466
+ if (e === void 0 || e.length === 0) return Vs;
4464
4467
  this._dirtyLists[t] = [];
4465
4468
  const s = this._dirtyMarks[t];
4466
4469
  for (let n = 0; n < e.length; n++) s[e[n] & Y] = 0;
@@ -4532,7 +4535,7 @@ class Ws {
4532
4535
  trackDirty: !1
4533
4536
  });
4534
4537
  const o = ye(i);
4535
- return e !== void 0 && ze(o, e), o;
4538
+ return e !== void 0 && je(o, e), o;
4536
4539
  }
4537
4540
  /** `'Pos' (component 5)` when the component was registered with a debug
4538
4541
  * name, else `component 5` — the label diagnostics interpolate. */
@@ -4584,7 +4587,7 @@ class Ws {
4584
4587
  * through `registerSparseComponent`, which guards first. */
4585
4588
  _pushSparseStore(t, e, s) {
4586
4589
  const n = this.sparseStores.length;
4587
- return this.sparseStores.push(new je(t, e)), this.sparseNames.push(s), M(n);
4590
+ return this.sparseStores.push(new Ye(t, e)), this.sparseNames.push(s), M(n);
4588
4591
  }
4589
4592
  sparseStoreOf(t) {
4590
4593
  const e = t, s = this.sparseStores[e];
@@ -5010,7 +5013,7 @@ class Ws {
5010
5013
  let o = i;
5011
5014
  for (let d = 0; d < i; d++) {
5012
5015
  const f = e[d].def.id;
5013
- if (f >= se - 1 || i > Vs) {
5016
+ if (f >= se - 1 || i > Ws) {
5014
5017
  o = Ct;
5015
5018
  break;
5016
5019
  }
@@ -5234,9 +5237,9 @@ class Ws {
5234
5237
  for (let c = 0; c < n.length; c++) {
5235
5238
  let l = n[c];
5236
5239
  if (l === 0) continue;
5237
- const u = c << is;
5240
+ const u = c << os;
5238
5241
  for (; l !== 0; ) {
5239
- const d = l & -l >>> 0, f = u + (rs - Math.clz32(d));
5242
+ const d = l & -l >>> 0, f = u + (is - Math.clz32(d));
5240
5243
  l ^= d;
5241
5244
  const w = this.archGraph.componentIndex[f];
5242
5245
  if (w === void 0 || w.length === 0) {
@@ -5316,7 +5319,7 @@ class Ws {
5316
5319
  // =======================================================
5317
5320
  // Resource storage — delegations to `ResourceRegistry` (resource_registry.ts)
5318
5321
  // =======================================================
5319
- resources = new fs();
5322
+ resources = new ps();
5320
5323
  registerResource(t, e) {
5321
5324
  this.resources.register(t, e);
5322
5325
  }
@@ -5335,7 +5338,7 @@ class Ws {
5335
5338
  return this.resources.has(t);
5336
5339
  }
5337
5340
  }
5338
- class zs {
5341
+ class js {
5339
5342
  store;
5340
5343
  /** @internal constructed by `ECS`. */
5341
5344
  constructor(t) {
@@ -5409,7 +5412,7 @@ class zs {
5409
5412
  return this.store.compactRelations();
5410
5413
  }
5411
5414
  }
5412
- class js {
5415
+ class Ys {
5413
5416
  store;
5414
5417
  /** @internal constructed by `ECS`. */
5415
5418
  constructor(t) {
@@ -5445,7 +5448,7 @@ class js {
5445
5448
  return this.store.getEventReader(e);
5446
5449
  }
5447
5450
  }
5448
- class Ys {
5451
+ class Qs {
5449
5452
  store;
5450
5453
  /** @internal constructed by `ECS`. */
5451
5454
  constructor(t) {
@@ -5479,7 +5482,7 @@ class Ys {
5479
5482
  return this.store.hasResource(t);
5480
5483
  }
5481
5484
  }
5482
- class Qs {
5485
+ class Ks {
5483
5486
  store;
5484
5487
  /** @internal constructed by `ECS`. */
5485
5488
  constructor(t) {
@@ -5546,7 +5549,7 @@ function Lt(a, t) {
5546
5549
  const s = Object.create(e);
5547
5550
  return s._row = t, s;
5548
5551
  }
5549
- class Ks {
5552
+ class Xs {
5550
5553
  // Query deduplication: hash(include, exclude, anyOf) → bucket of cache
5551
5554
  // entries. Multiple term sets can share a hash (collision), so each bucket
5552
5555
  // is an array; `findDedup` equality-checks masks within the bucket.
@@ -5594,10 +5597,10 @@ class Ks {
5594
5597
  }
5595
5598
  /** Record a freshly minted query under its dedup key. */
5596
5599
  addDedup(t, e) {
5597
- be(this.dedup, t, e);
5600
+ Se(this.dedup, t, e);
5598
5601
  }
5599
5602
  }
5600
- const re = Object.freeze([]), Xs = Object.freeze([]), ie = Object.freeze([]), Rt = Number.POSITIVE_INFINITY, At = 65536;
5603
+ const re = Object.freeze([]), Zs = Object.freeze([]), ie = Object.freeze([]), Rt = Number.POSITIVE_INFINITY, At = 65536;
5601
5604
  function nt(a, t) {
5602
5605
  if (a >= At || t >= At)
5603
5606
  throw new _(
@@ -5611,7 +5614,7 @@ function ut(a, t) {
5611
5614
  if (a[e] === t) return a;
5612
5615
  return [...a, t];
5613
5616
  }
5614
- function Zs(a, t) {
5617
+ function Js(a, t) {
5615
5618
  for (let e = 0; e < a.length; e++)
5616
5619
  if (a[e] === t) return a;
5617
5620
  return [...a, t];
@@ -5621,7 +5624,7 @@ function oe(a, t) {
5621
5624
  if (a[e] === t) return a;
5622
5625
  return [...a, t];
5623
5626
  }
5624
- class Js {
5627
+ class tn {
5625
5628
  /** @internal */
5626
5629
  _arch;
5627
5630
  /** @internal */
@@ -5705,7 +5708,7 @@ class H {
5705
5708
  // archetypes — there is no SoA span — so `forEach` rejects it, like a sparse
5706
5709
  // term); `accessCheck` validates `relationReads: [R]` at iteration time.
5707
5710
  _hierarchy;
5708
- constructor(t, e, s, n, r, i, o, h = re, c = re, l = Xs, u = !1, d = ie, f = ie, w = null) {
5711
+ constructor(t, e, s, n, r, i, o, h = re, c = re, l = Zs, u = !1, d = ie, f = ie, w = null) {
5709
5712
  this._archetypes = t, this._defs = e, this._resolver = s, this._include = n, this._exclude = r, this._anyOf = i, this._id = o, this._sparseInclude = h, this._sparseExclude = c, this._optional = l, this._includeDisabled = u, this._relationIncludes = d, this._relationExcludes = f, this._hierarchy = w;
5710
5713
  }
5711
5714
  /** Guard the dense-only methods (`count` / `forEach` / `archetype_count`)
@@ -6120,7 +6123,7 @@ class H {
6120
6123
  _optionalOne(t) {
6121
6124
  const e = (this._id << 16 | t) >>> 0, s = this._resolver._caches.optionalSingle, n = s.get(e);
6122
6125
  if (n !== void 0) return n;
6123
- const r = this._deriveOptional(Zs(this._optional, t));
6126
+ const r = this._deriveOptional(Js(this._optional, t));
6124
6127
  return s.set(e, r), r;
6125
6128
  }
6126
6129
  /** Build a derived query carrying new optional terms. Reuses this query's
@@ -6254,7 +6257,7 @@ class H {
6254
6257
  * column-group caches that actually matter for allocation live on the
6255
6258
  * `Archetype`, untouched. */
6256
6259
  _eachChunkInner(t) {
6257
- const e = new Js();
6260
+ const e = new tn();
6258
6261
  e._tick = this._resolver._getCurrentTick();
6259
6262
  {
6260
6263
  this._assertDenseOnly("eachChunk"), m.enterOptionalScope(this._optional);
@@ -6477,7 +6480,7 @@ class H {
6477
6480
  return this._resolver._getLastRunTick();
6478
6481
  }
6479
6482
  }
6480
- class tn {
6483
+ class en {
6481
6484
  constructor(t) {
6482
6485
  this._resolver = t;
6483
6486
  }
@@ -6487,7 +6490,7 @@ class tn {
6487
6490
  return this._resolver._resolveQuery(e, null, null, t);
6488
6491
  }
6489
6492
  }
6490
- class en {
6493
+ class sn {
6491
6494
  constructor(t) {
6492
6495
  this.store = t;
6493
6496
  }
@@ -6542,9 +6545,9 @@ class en {
6542
6545
  return this.store.enableEntityDeferred(t), this.store._trace?.commandQueued("enable", t, null), this;
6543
6546
  }
6544
6547
  }
6545
- class sn {
6548
+ class nn {
6546
6549
  constructor(t) {
6547
- this.store = t, this.commands = new en(t);
6550
+ this.store = t, this.commands = new sn(t);
6548
6551
  }
6549
6552
  lastRunTick = 0;
6550
6553
  /** Deferred structural-command facade (§ctx.commands). */
@@ -6901,7 +6904,7 @@ function ae(a) {
6901
6904
  );
6902
6905
  return a;
6903
6906
  }
6904
- function nn(a) {
6907
+ function rn(a) {
6905
6908
  if (!Number.isInteger(a) || a < 1)
6906
6909
  throw new _(
6907
6910
  g.INVALID_MAX_FIXED_STEPS,
@@ -6909,7 +6912,7 @@ function nn(a) {
6909
6912
  );
6910
6913
  return a;
6911
6914
  }
6912
- class pn {
6915
+ class _n {
6913
6916
  store;
6914
6917
  schedule;
6915
6918
  ctx;
@@ -6951,7 +6954,7 @@ class pn {
6951
6954
  // All query-resolution caches — dedup + the shared composition maps — in
6952
6955
  // one owner (M2); see `QueryCache` in query.ts for keying/id-space notes.
6953
6956
  /** @internal Query-composition caches (QueryResolver seam) — not public API. */
6954
- _caches = new Ks();
6957
+ _caches = new Xs();
6955
6958
  // --- SAB layout subscribers (e.g. a compute backend) ---
6956
6959
  // The engine publishes SAB-layout changes to whoever subscribed via
6957
6960
  // `onStoreLayoutPublished`. The engine has no knowledge of what the
@@ -6989,8 +6992,8 @@ class pn {
6989
6992
  he.has(n) || (t.onWarn ?? console.warn)(
6990
6993
  `ECSOptions: unknown option '${n}' ignored — known options: ${[...he].join(", ")}`
6991
6994
  );
6992
- const s = Xe(t?.memory);
6993
- this._memory = s, this.store = new Ws({
6995
+ const s = Ze(t?.memory);
6996
+ this._memory = s, this.store = new zs({
6994
6997
  initialCapacity: s.columnCapacity,
6995
6998
  bufferAllocator: s.allocator,
6996
6999
  entityIndexCapacity: s.entityIndexCapacity,
@@ -7007,10 +7010,10 @@ class pn {
7007
7010
  regions: t?.regions,
7008
7011
  bindingsRegionBytes: t?.bindingsRegionBytes,
7009
7012
  deterministic: t?.deterministic
7010
- }), this.schedule = new Ze(t?.onWarn), this.relations = new zs(this.store), this.events = new js(this.store), this.resources = new Ys(this.store), this.snapshots = new Qs(this.store), this.ctx = new sn(this.store), this._observers = new bs(this.store, this.ctx), this.store.setStructuralObserverHook((n) => this._observers.dispatchStructural(n)), this._fixedTimestep = ae(
7011
- t?.fixedTimestep ?? Je
7012
- ), this._maxFixedSteps = nn(
7013
- t?.maxFixedSteps ?? ts
7013
+ }), this.schedule = new Je(t?.onWarn), this.relations = new js(this.store), this.events = new Ys(this.store), this.resources = new Qs(this.store), this.snapshots = new Ks(this.store), this.ctx = new nn(this.store), this._observers = new Ss(this.store, this.ctx), this.store.setStructuralObserverHook((n) => this._observers.dispatchStructural(n)), this._fixedTimestep = ae(
7014
+ t?.fixedTimestep ?? ts
7015
+ ), this._maxFixedSteps = rn(
7016
+ t?.maxFixedSteps ?? es
7014
7017
  );
7015
7018
  }
7016
7019
  /** Batch variant of `regionHandle` for hosts wiring several consumer
@@ -7378,7 +7381,7 @@ class pn {
7378
7381
  }
7379
7382
  /** QueryResolver implementation — creates or retrieves a cached Query. */
7380
7383
  _resolveQuery(t, e, s, n) {
7381
- const r = t.hash(), i = e ? e.hash() : 0, o = s ? s.hash() : 0, h = r ^ Math.imul(i, es) ^ Math.imul(o, ss) | 0, c = this._caches.findDedup(h, t, e, s);
7384
+ const r = t.hash(), i = e ? e.hash() : 0, o = s ? s.hash() : 0, h = r ^ Math.imul(i, ss) ^ Math.imul(o, ns) | 0, c = this._caches.findDedup(h, t, e, s);
7382
7385
  if (c !== void 0) return c.query;
7383
7386
  const l = this.store.registerQuery(t, e ?? void 0, s ?? void 0), u = new H(
7384
7387
  l,
@@ -7403,7 +7406,7 @@ class pn {
7403
7406
  let s;
7404
7407
  if (typeof t == "function")
7405
7408
  if (e !== void 0) {
7406
- const i = e(new tn(this)), o = this.ctx, h = t;
7409
+ const i = e(new en(this)), o = this.ctx, h = t;
7407
7410
  s = { ...xt, fn: (c, l) => h(i, o, l) };
7408
7411
  } else {
7409
7412
  if (t.length >= 3)
@@ -7415,14 +7418,14 @@ class pn {
7415
7418
  }
7416
7419
  else
7417
7420
  s = t;
7418
- if (gs(s), s.fn === void 0 && s.backendHandle === void 0)
7421
+ if (ys(s), s.fn === void 0 && s.backendHandle === void 0)
7419
7422
  throw new _(
7420
7423
  g.SYSTEM_FN_ARITY,
7421
7424
  `registerSystem: config${s.name ? ` '${s.name}'` : ""} has neither 'fn' nor 'backendHandle' — provide a system body, or a backend handle for backend execution`
7422
7425
  );
7423
7426
  const n = me(this.nextSystemId++), r = Object.freeze({
7424
7427
  ...s,
7425
- ..._s(s),
7428
+ ...gs(s),
7426
7429
  id: n
7427
7430
  });
7428
7431
  return this.systems.add(r), r;
@@ -7472,7 +7475,7 @@ class pn {
7472
7475
  * `private` because the only caller is `startup()`; visible to tests via
7473
7476
  * the `archetype_count` delta on the public ECS facade. */
7474
7477
  prewarmArchetypes() {
7475
- const t = rn([...this.systems, ...this._observers.descriptors()]);
7478
+ const t = on([...this.systems, ...this._observers.descriptors()]);
7476
7479
  t.length !== 0 && this.store.archCreateManyFromMasks(t);
7477
7480
  }
7478
7481
  /**
@@ -7728,7 +7731,7 @@ class pn {
7728
7731
  }
7729
7732
  // === END STORE PASS-THROUGH BAND ===
7730
7733
  }
7731
- function rn(a) {
7734
+ function on(a) {
7732
7735
  const t = /* @__PURE__ */ new Map(), e = [], s = (o) => {
7733
7736
  const h = o.hash(), c = t.get(h);
7734
7737
  if (c !== void 0) {
@@ -7776,7 +7779,7 @@ function rn(a) {
7776
7779
  for (const o of t.values()) for (let h = 0; h < o.length; h++) i.push(o[h]);
7777
7780
  return i;
7778
7781
  }
7779
- function _n(a, t) {
7782
+ function gn(a, t) {
7780
7783
  return typeof t == "object" && t !== null && console.warn(
7781
7784
  `runIfResourceEq('${a.description ?? "?"}'): 'expected' is an object — comparison is by reference identity (===), so the gate only fires when the resource is set to this exact instance. Prefer a primitive phase value.`
7782
7785
  ), {
@@ -7785,7 +7788,7 @@ function _n(a, t) {
7785
7788
  evaluate: (e) => e.getResource(a) === t
7786
7789
  };
7787
7790
  }
7788
- function gn(a, t = 0) {
7791
+ function yn(a, t = 0) {
7789
7792
  if (!Number.isInteger(a) || a < 1)
7790
7793
  throw new _(
7791
7794
  g.INVALID_RUN_CONDITION,
@@ -7802,7 +7805,7 @@ function gn(a, t = 0) {
7802
7805
  evaluate: (s) => (s.ecsTick - e) % a === 0
7803
7806
  };
7804
7807
  }
7805
- function yn(a) {
7808
+ function mn(a) {
7806
7809
  return {
7807
7810
  name: "runIfAnyMatch",
7808
7811
  reads: a._defs,
@@ -7818,31 +7821,31 @@ function Pt(a) {
7818
7821
  ...e.length > 0 ? { resourceReads: e } : {}
7819
7822
  };
7820
7823
  }
7821
- function mn(a) {
7824
+ function wn(a) {
7822
7825
  return {
7823
7826
  name: `not(${a.name})`,
7824
7827
  ...Pt([a]),
7825
7828
  evaluate: (t) => !a.evaluate(t)
7826
7829
  };
7827
7830
  }
7828
- function wn(...a) {
7831
+ function En(...a) {
7829
7832
  return {
7830
7833
  name: `allOf(${a.map((t) => t.name).join(", ")})`,
7831
7834
  ...Pt(a),
7832
7835
  evaluate: (t) => a.every((e) => e.evaluate(t))
7833
7836
  };
7834
7837
  }
7835
- function En(...a) {
7838
+ function vn(...a) {
7836
7839
  return {
7837
7840
  name: `anyOf(${a.map((t) => t.name).join(", ")})`,
7838
7841
  ...Pt(a),
7839
7842
  evaluate: (t) => a.some((e) => e.evaluate(t))
7840
7843
  };
7841
7844
  }
7842
- function on(a) {
7845
+ function hn(a) {
7843
7846
  return a.kind === "spawn" && a.onSpawned !== void 0 ? { kind: "spawn", components: a.components } : a;
7844
7847
  }
7845
- class vn {
7848
+ class bn {
7846
7849
  /** Session seed, echoed into the produced {@link CommandLog}. */
7847
7850
  seed;
7848
7851
  _startup = [];
@@ -7863,7 +7866,7 @@ class vn {
7863
7866
  this._ticks.push({ tick: t, dt: e, commands: n }), this.sink = n;
7864
7867
  }
7865
7868
  record = (t) => {
7866
- this.sink.push(on(t));
7869
+ this.sink.push(hn(t));
7867
7870
  };
7868
7871
  /** A live {@link CommandLog} view over the accumulated stream — not a copy.
7869
7872
  * Serialize it (which deep-copies through JSON) before mutating the world
@@ -7882,7 +7885,7 @@ class vn {
7882
7885
  }
7883
7886
  }
7884
7887
  const it = "__component_def";
7885
- function bn(a) {
7888
+ function Sn(a) {
7886
7889
  return JSON.stringify(a, (t, e) => {
7887
7890
  if (typeof e == "function" && "id" in e)
7888
7891
  return { [it]: e.id };
@@ -7894,10 +7897,10 @@ function bn(a) {
7894
7897
  return e;
7895
7898
  });
7896
7899
  }
7897
- function Sn(a) {
7900
+ function Cn(a) {
7898
7901
  return JSON.parse(a, (t, e) => e !== null && typeof e == "object" && it in e ? ye(ge(e[it])) : e);
7899
7902
  }
7900
- function Cn(a, t, e, s) {
7903
+ function Rn(a, t, e, s) {
7901
7904
  for (const i of e.startup) t.push(i);
7902
7905
  a.startup();
7903
7906
  const n = s?.hash ?? a.snapshots.deterministic, r = [];
@@ -7910,7 +7913,7 @@ function Cn(a, t, e, s) {
7910
7913
  function Ot(a) {
7911
7914
  return a.name ?? `system#${a.id}`;
7912
7915
  }
7913
- class Rn {
7916
+ class An {
7914
7917
  _frames = [];
7915
7918
  _current = null;
7916
7919
  tickBegin(t, e) {
@@ -7975,7 +7978,7 @@ function V(a, t) {
7975
7978
  );
7976
7979
  return t;
7977
7980
  }
7978
- function hn(a) {
7981
+ function an(a) {
7979
7982
  if (!Number.isInteger(a) || a < 0)
7980
7983
  throw new _(
7981
7984
  g.INVALID_FRAME_STEP,
@@ -7983,7 +7986,7 @@ function hn(a) {
7983
7986
  );
7984
7987
  return a;
7985
7988
  }
7986
- class An {
7989
+ class On {
7987
7990
  ecs;
7988
7991
  requestFrame;
7989
7992
  cancelFrame;
@@ -8018,7 +8021,7 @@ class An {
8018
8021
  }
8019
8022
  /** Advance several fixed-size frames, useful for replaying a paused sim. */
8020
8023
  stepFrames(t, e = this._fixedDt) {
8021
- hn(t);
8024
+ an(t);
8022
8025
  const s = V("dt", e);
8023
8026
  for (let n = 0; n < t; n++) this.ecs.update(s);
8024
8027
  }
@@ -8052,65 +8055,65 @@ class An {
8052
8055
  this.lastTimestampMs = t, this.ecs.update(Math.min(V("dt", e), this._maxDt)), this.running && this.scheduleNextFrame();
8053
8056
  };
8054
8057
  }
8055
- function On(a, t) {
8058
+ function In(a, t) {
8056
8059
  return a.relations.register({
8057
8060
  exclusive: !0,
8058
8061
  onDeleteTarget: t?.onDeleteTarget ?? "clear"
8059
8062
  });
8060
8063
  }
8061
- function In(a, t) {
8064
+ function Tn(a, t) {
8062
8065
  return a.relations.register({
8063
8066
  exclusive: !0,
8064
8067
  onDeleteTarget: t?.onDeleteTarget ?? "delete"
8065
8068
  });
8066
8069
  }
8067
- function Tn(a) {
8070
+ function Dn(a) {
8068
8071
  return M(Symbol(a));
8069
8072
  }
8070
- const Dn = "0.5.2";
8073
+ const kn = "0.5.3";
8071
8074
  export {
8072
- Mn as ANY_RELATION,
8075
+ Nn as ANY_RELATION,
8073
8076
  z as ChangedQuery,
8074
- Js as ChunkColumns,
8075
- en as Commands,
8076
- pn as ECS,
8077
+ tn as ChunkColumns,
8078
+ sn as Commands,
8079
+ _n as ECS,
8077
8080
  _ as ECSError,
8078
8081
  x as ECSRestoreError,
8079
8082
  g as ECS_ERROR,
8080
8083
  Nt as ECS_SNAPSHOT_VERSION,
8081
- An as FrameStepper,
8082
- Rn as FrameTraceRecorder,
8084
+ On as FrameStepper,
8085
+ An as FrameTraceRecorder,
8083
8086
  Rt as HIERARCHY_UNBOUNDED,
8084
- Nn as HostCommandQueue,
8085
- vn as HostCommandRecorder,
8087
+ Ln as HostCommandQueue,
8088
+ bn as HostCommandRecorder,
8086
8089
  H as Query,
8087
- tn as QueryBuilder,
8088
- Ln as SCHEDULE,
8089
- qn as SabUnavailableError,
8090
+ en as QueryBuilder,
8091
+ $n as SCHEDULE,
8092
+ Vn as SabUnavailableError,
8090
8093
  at as SparseRestoreError,
8091
8094
  tt as StoreRestoreError,
8092
- sn as SystemContext,
8093
- Dn as VERSION,
8094
- wn as allOf,
8095
- En as anyOf,
8096
- $n as applyHostCommand,
8097
- un as bundle,
8098
- Sn as deserializeCommandLog,
8099
- dn as eventKey,
8095
+ nn as SystemContext,
8096
+ kn as VERSION,
8097
+ En as allOf,
8098
+ vn as anyOf,
8099
+ Fn as applyHostCommand,
8100
+ dn as bundle,
8101
+ Cn as deserializeCommandLog,
8102
+ fn as eventKey,
8100
8103
  b as getEntityIndex,
8101
- Fn as installHostCommandSeam,
8102
- Bn as isEcsError,
8103
- mn as not,
8104
- In as registerChildOf,
8105
- On as registerIsA,
8106
- Cn as replayCommandLog,
8107
- Tn as resourceKey,
8108
- gn as runEveryNTicks,
8109
- yn as runIfAnyMatch,
8110
- _n as runIfResourceEq,
8111
- bn as serializeCommandLog,
8112
- fn as signalKey,
8113
- Gn as spawnEntry,
8114
- Pn as systemSet,
8115
- Hn as uninstallHostCommandSeam
8104
+ Bn as installHostCommandSeam,
8105
+ Gn as isEcsError,
8106
+ wn as not,
8107
+ Tn as registerChildOf,
8108
+ In as registerIsA,
8109
+ Rn as replayCommandLog,
8110
+ Dn as resourceKey,
8111
+ yn as runEveryNTicks,
8112
+ mn as runIfAnyMatch,
8113
+ gn as runIfResourceEq,
8114
+ Sn as serializeCommandLog,
8115
+ pn as signalKey,
8116
+ Pn as spawnEntry,
8117
+ Hn as systemSet,
8118
+ Un as uninstallHostCommandSeam
8116
8119
  };