@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
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
- import { v as dt, S as O, o as ht, p as at, q as ct, s as Jt, t as te, u as Ot, w as T, E as v, x as b, N as P, y as ee, z as w, U as I, A as pe, C as _e, F as ge, G as ye, I as me, j as J, J as Lt, R as Et, K as se, L as we, O as Ee, P as ve, Q as lt, T as ne, V as kt, W as re, X as ie, Y as vt, Z as be, _ as Ce, $ as it, a0 as Se, a1 as Re, a2 as et, a3 as Ie, a4 as Ae, a5 as Oe, a6 as ke, a7 as Nt, a8 as Te, a9 as Bt, aa as De, ab as ft, ac as xe, ad as Me, ae as M, af as Le, ag as Ft, ah as Y, k as $t, n as Ne, ai as V, aj as st, ak as Be, al as Fe, am as pt, an as $e, ao as Ge, ap as Pe, c as ut, r as Ue, aq as He, ar as Ve, as as qe, at as je, au as ze } from "./host_commands-BI8pEmjH.js";
2
- import { aC as bn, aA as Cn, av as Sn, az as Rn, ax as In, aD as An, aB as On, aw as kn, ay as Tn } from "./host_commands-BI8pEmjH.js";
3
- import { h as We, B as $, i as Ye, j as Qe } from "./typed_arrays-BcXcnzB4.js";
4
- import { D as Ke, S as Gt, g as Xe } from "./shared-BU1Cd40h.js";
5
- import { a as xn } from "./shared-BU1Cd40h.js";
1
+ import { v as dt, S as O, o as ht, p as at, q as ct, s as Jt, t as te, u as Ot, w as T, E as v, x as b, N as P, y as ee, z as w, U as I, A as _e, C as ge, F as ye, G as me, I as we, j as J, J as Lt, R as Et, K as se, L as Ee, O as ve, P as be, Q as lt, T as ne, V as kt, W as re, X as ie, Y as vt, Z as Ce, _ as Se, $ as it, a0 as Re, a1 as Ie, a2 as et, a3 as Ae, a4 as Oe, a5 as ke, a6 as Te, a7 as Nt, a8 as De, a9 as Bt, aa as xe, ab as ft, ac as Me, ad as Le, ae as M, af as Ne, ag as Ft, ah as Y, k as $t, n as Be, ai as V, aj as st, ak as Fe, al as $e, am as pt, an as Ge, ao as Pe, ap as Ue, c as ut, r as He, aq as Ve, ar as qe, as as je, at as ze, au as We } from "./host_commands-3jyFfWNg.js";
2
+ import { aC as Cn, aA as Sn, av as Rn, az as In, ax as An, aD as On, aB as kn, aw as Tn, ay as Dn } from "./host_commands-3jyFfWNg.js";
3
+ import { h as Ye, B as $, i as Qe, j as Ke } from "./typed_arrays-BcXcnzB4.js";
4
+ import { D as Xe, S as Gt, g as Ze } from "./shared-DQKK0i-E.js";
5
+ import { a as Mn } from "./shared-DQKK0i-E.js";
6
6
  const L = !1, oe = (a) => dt(
7
7
  a
8
8
  ), Tt = Object.freeze({});
@@ -13,7 +13,7 @@ function he(a) {
13
13
  }));
14
14
  return Object.defineProperty(t, "id", { value: a, enumerable: !1 }), t;
15
15
  }
16
- function Js(a, ...t) {
16
+ function tn(a, ...t) {
17
17
  return { def: a, values: t[0] ?? Tt };
18
18
  }
19
19
  function j(a) {
@@ -27,11 +27,11 @@ class Q extends Error {
27
27
  super(t), this.name = "StoreRestoreError";
28
28
  }
29
29
  }
30
- function Ze(a) {
30
+ function Je(a) {
31
31
  const t = a.view.getUint32(O.capacity, !0);
32
32
  return new Uint8Array(a.buffer, 0, t);
33
33
  }
34
- function Je(a, t = Ke) {
34
+ function ts(a, t = Xe) {
35
35
  const e = new DataView(a.buffer, a.byteOffset, a.byteLength);
36
36
  if (a.byteLength < ht)
37
37
  throw new Q(
@@ -67,10 +67,10 @@ function Je(a, t = Ke) {
67
67
  ) : h;
68
68
  }
69
69
  }
70
- const ts = (a) => dt(
70
+ const es = (a) => dt(
71
71
  a
72
72
  );
73
- class es {
73
+ class ss {
74
74
  fieldNames;
75
75
  columns;
76
76
  // any: type-erased storage — channel is stored in Map<number, EventChannel>, S is lost
@@ -107,13 +107,13 @@ class es {
107
107
  t[e].length = 0;
108
108
  }
109
109
  }
110
- function tn(a) {
110
+ function en(a) {
111
111
  return T(Symbol(a));
112
112
  }
113
- function en(a) {
113
+ function sn(a) {
114
114
  return T(Symbol(a));
115
115
  }
116
- class ss {
116
+ class ns {
117
117
  // Parallel array indexed by EventID: each channel holds SoA columns + reader.
118
118
  channels = [];
119
119
  // IDs of channels emitted to since the last `clearEvents()`. An `emit*`
@@ -126,7 +126,7 @@ class ss {
126
126
  // callers via EventKey<F>
127
127
  keyMap = /* @__PURE__ */ new Map();
128
128
  registerEvent(t) {
129
- const e = ts(this.count++), s = new es(t);
129
+ const e = es(this.count++), s = new ss(t);
130
130
  return this.channels.push(s), T(e);
131
131
  }
132
132
  emitEvent(t, e) {
@@ -182,7 +182,7 @@ class ss {
182
182
  return this.keyMap.has(t);
183
183
  }
184
184
  }
185
- class ns {
185
+ class rs {
186
186
  map = /* @__PURE__ */ new Map();
187
187
  register(t, e) {
188
188
  if (this.map.has(t))
@@ -235,7 +235,7 @@ class nt extends Error {
235
235
  super(`BufferBackedColumn overflow: requested length ${e} exceeds capacity ${t}`), this.name = "StoreColumnOverflowError", this.capacity = t, this.requested = e;
236
236
  }
237
237
  }
238
- class rs {
238
+ class is {
239
239
  _buf;
240
240
  _capacity;
241
241
  _len = 0;
@@ -453,7 +453,7 @@ class Dt {
453
453
  * current SAB row capacity. (#171 §6.1.9 Phase 3) */
454
454
  growHandler = null;
455
455
  constructor(t, e, s, n = ee, r) {
456
- if (this.id = t, this.mask = e, this._entityIds = new We(n), s) {
456
+ if (this.id = t, this.mask = e, this._entityIds = new Ye(n), s) {
457
457
  let i = 0;
458
458
  for (let o = 0; o < s.length; o++) {
459
459
  const h = s[o], c = h.componentId, l = new Array(h.fieldNames.length);
@@ -490,13 +490,13 @@ class Dt {
490
490
  `ColumnStore has no archetype ${r}`
491
491
  );
492
492
  const o = (c, l) => {
493
- const u = i.columns.get(pe(c, l));
493
+ const u = i.columns.get(_e(c, l));
494
494
  if (!u)
495
495
  throw new v(
496
496
  b.COMPONENT_NOT_REGISTERED,
497
497
  `ColumnStore archetype ${r} has no column for (${c}, ${l})`
498
498
  );
499
- return new rs(u.view);
499
+ return new is(u.view);
500
500
  }, h = new Dt(t, e, s, i.rowCapacity, o);
501
501
  return h._storeArchetypeId = r, h;
502
502
  }
@@ -1118,7 +1118,7 @@ const ae = (a) => dt(
1118
1118
  function Ut(a) {
1119
1119
  return typeof a == "object" && !Array.isArray(a);
1120
1120
  }
1121
- function is(a) {
1121
+ function os(a) {
1122
1122
  let t = K;
1123
1123
  a.spawns !== void 0 && a.spawns.length > 0 && (t = a.spawns.map((s) => Ut(s) ? s.defs : s));
1124
1124
  let e = K;
@@ -1154,26 +1154,26 @@ const St = Object.freeze({
1154
1154
  sparseWrites: Object.freeze([]),
1155
1155
  relationReads: Object.freeze([]),
1156
1156
  relationWrites: Object.freeze([])
1157
- }), os = Symbol.dispose ?? Symbol.for("Symbol.dispose"), _t = (1 << 20) - 1;
1158
- let hs = 0;
1159
- function as(a, t) {
1157
+ }), hs = Symbol.dispose ?? Symbol.for("Symbol.dispose"), _t = (1 << 20) - 1;
1158
+ let as = 0;
1159
+ function cs(a, t) {
1160
1160
  const e = {
1161
1161
  ...St,
1162
1162
  ...t,
1163
- id: ae(hs++),
1163
+ id: ae(as++),
1164
1164
  name: a,
1165
- fn: cs
1165
+ fn: ls
1166
1166
  };
1167
1167
  return Object.freeze(e);
1168
1168
  }
1169
- function cs() {
1169
+ function ls() {
1170
1170
  }
1171
1171
  function Ht(a) {
1172
1172
  const t = /* @__PURE__ */ new Set();
1173
1173
  if (a) for (let e = 0; e < a.length; e++) t.add(a[e].id);
1174
1174
  return t;
1175
1175
  }
1176
- function ls(a) {
1176
+ function us(a) {
1177
1177
  const t = (i, o) => i.cid - o.cid || i.id - o.id, e = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
1178
1178
  for (const i of a)
1179
1179
  e.set(i, []), s.set(i, 0);
@@ -1204,7 +1204,7 @@ function ls(a) {
1204
1204
  }
1205
1205
  return r;
1206
1206
  }
1207
- class us {
1207
+ class ds {
1208
1208
  constructor(t, e) {
1209
1209
  this.store = t, this.ctx = e;
1210
1210
  }
@@ -1247,8 +1247,8 @@ class us {
1247
1247
  return t;
1248
1248
  }
1249
1249
  register(t, e) {
1250
- const s = t.id, n = e.granularity ?? "archetype", r = e.onSet !== void 0 && n === "entity", i = e.onSet !== void 0 && n !== "entity", o = e.access ?? {}, h = as(
1251
- e.name ?? `observer(${_e(t) ?? s})`,
1250
+ const s = t.id, n = e.granularity ?? "archetype", r = e.onSet !== void 0 && n === "entity", i = e.onSet !== void 0 && n !== "entity", o = e.access ?? {}, h = cs(
1251
+ e.name ?? `observer(${ge(t) ?? s})`,
1252
1252
  o
1253
1253
  ), c = {
1254
1254
  // Share one identity space with the descriptor (used only for the
@@ -1273,7 +1273,7 @@ class us {
1273
1273
  let l = this.byCid.get(s);
1274
1274
  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);
1275
1275
  const u = () => this._dispose(c);
1276
- return { dispose: u, [os]: u };
1276
+ return { dispose: u, [hs]: u };
1277
1277
  }
1278
1278
  _dispose(t) {
1279
1279
  if (t.disposed) return;
@@ -1308,7 +1308,7 @@ class us {
1308
1308
  );
1309
1309
  }
1310
1310
  getTopo() {
1311
- return this._topo === null && (this._topo = ls(this.entries)), this._topo;
1311
+ return this._topo === null && (this._topo = us(this.entries)), this._topo;
1312
1312
  }
1313
1313
  // =======================================================
1314
1314
  // Structural dispatch (onAdd / onRemove)
@@ -1452,7 +1452,7 @@ function ot(a, t, e, s) {
1452
1452
  }
1453
1453
  }
1454
1454
  }
1455
- class ds {
1455
+ class fs {
1456
1456
  constructor(t) {
1457
1457
  this.host = t;
1458
1458
  }
@@ -1514,9 +1514,9 @@ class ds {
1514
1514
  b.RELATION_MODE_INVALID,
1515
1515
  "register_relation: a relation cannot be both exclusive and multi-target"
1516
1516
  );
1517
- const n = !e, r = t?.onDeleteTarget ?? ge, i = n ? this.host.pushSparseStore([ye], ["f64"]) : this.host.pushSparseStore([], []), o = this.relations.length;
1517
+ const n = !e, r = t?.onDeleteTarget ?? ye, i = n ? this.host.pushSparseStore([me], ["f64"]) : this.host.pushSparseStore([], []), o = this.relations.length;
1518
1518
  return this.relations.push(
1519
- me(n, i, this.host.sparseStoreOf(i), r)
1519
+ we(n, i, this.host.sparseStoreOf(i), r)
1520
1520
  ), r !== "orphan" && (this._hasTargetCleanup = !0), T(o);
1521
1521
  }
1522
1522
  relationOf(t) {
@@ -1906,7 +1906,7 @@ class ds {
1906
1906
  return s.get(t);
1907
1907
  }
1908
1908
  }
1909
- class fs {
1909
+ class ps {
1910
1910
  /** SAB-backed per-slot generation counters — replanted on restore. */
1911
1911
  _generations;
1912
1912
  /** Single-slot view over the entity-index region's `length` header field —
@@ -2013,7 +2013,7 @@ class fs {
2013
2013
  }
2014
2014
  }
2015
2015
  const Vt = 65536;
2016
- class ps {
2016
+ class _s {
2017
2017
  // --- Deferred operation buffers ---
2018
2018
  // Flat parallel arrays: addIds[i], addDefs[i], addValues[i] describe one
2019
2019
  // deferred add. No per-operation object allocation. Public so the Store
@@ -2100,7 +2100,7 @@ function ce(a, t) {
2100
2100
  const r = t[n], i = new Array(r.columns.length);
2101
2101
  for (let o = 0; o < r.columns.length; o++) {
2102
2102
  const h = r.columns[o];
2103
- e = we(e, h.stride), i[o] = {
2103
+ e = Ee(e, h.stride), i[o] = {
2104
2104
  componentId: h.componentId,
2105
2105
  fieldId: h.fieldId,
2106
2106
  typeTag: h.typeTag,
@@ -2117,15 +2117,18 @@ function ce(a, t) {
2117
2117
  columns: i
2118
2118
  };
2119
2119
  }
2120
- if (e > Ee)
2121
- throw new ve(e);
2120
+ if (e > ve)
2121
+ throw new be(e);
2122
2122
  return { descriptors: s, newTotal: e };
2123
2123
  }
2124
2124
  function le(a, t) {
2125
2125
  const e = a._allocator(t), s = e !== a.buffer ? new DataView(e) : a.view;
2126
2126
  return { grownBuffer: e, newView: s };
2127
2127
  }
2128
- function _s(a) {
2128
+ function ue(a) {
2129
+ return a.buffer instanceof ArrayBuffer ? a.view.getUint32(O.capacity, !0) : a.buffer.byteLength;
2130
+ }
2131
+ function gs(a) {
2129
2132
  const t = {};
2130
2133
  for (let n = 0; n < lt.length; n++) {
2131
2134
  const r = lt[n], i = a.view.getUint32(O[r.headerOff], !0);
@@ -2148,7 +2151,7 @@ function _s(a) {
2148
2151
  }
2149
2152
  return kt(a) && a._reservedDescriptorBytes > 0 && (t.reservedDescriptorBytes = a._reservedDescriptorBytes), t;
2150
2153
  }
2151
- function gs(a) {
2154
+ function ys(a) {
2152
2155
  const t = /* @__PURE__ */ new Map();
2153
2156
  for (let n = 0; n < lt.length; n++) {
2154
2157
  const r = lt[n], i = a.view.getUint32(O[r.headerOff], !0);
@@ -2163,7 +2166,7 @@ function gs(a) {
2163
2166
  }
2164
2167
  return { mechanism: t, consumer: e };
2165
2168
  }
2166
- function ys(a, t) {
2169
+ function ms(a, t) {
2167
2170
  for (const [e, s] of t.mechanism) {
2168
2171
  const n = a.view.getUint32(O[e], !0);
2169
2172
  new Uint8Array(a.buffer, n, s.byteLength).set(s);
@@ -2174,7 +2177,7 @@ function ys(a, t) {
2174
2177
  new Uint8Array(a.buffer, n, s.byteLength).set(s);
2175
2178
  }
2176
2179
  }
2177
- function ms(a, t) {
2180
+ function ws(a, t) {
2178
2181
  const e = /* @__PURE__ */ new Map();
2179
2182
  for (const [s, n] of a.archetypes) {
2180
2183
  const r = t.get(s) ?? 0;
@@ -2188,7 +2191,7 @@ function ms(a, t) {
2188
2191
  }
2189
2192
  return e;
2190
2193
  }
2191
- function ws(a, t) {
2194
+ function Es(a, t) {
2192
2195
  for (const [e, s] of t) {
2193
2196
  const n = a.archetypes.get(e);
2194
2197
  if (n === void 0)
@@ -2202,16 +2205,16 @@ function ws(a, t) {
2202
2205
  }
2203
2206
  }
2204
2207
  }
2205
- function ue(a, t, e, s) {
2206
- const n = a.view.getUint32(O.view_stamp, !0), r = ms(a, e), i = gs(a), o = _s(a), h = se(t, s, o);
2207
- ws(h, r), ys(h, i);
2208
+ function de(a, t, e, s) {
2209
+ const n = a.view.getUint32(O.view_stamp, !0), r = ws(a, e), i = ys(a), o = gs(a), h = se(t, s, o);
2210
+ Es(h, r), ms(h, i);
2208
2211
  const c = n + 1 >>> 0;
2209
2212
  return h.view.setUint32(O.view_stamp, c, !0), { store: {
2210
2213
  ...h,
2211
2214
  header: { ...h.header, viewStamp: c }
2212
2215
  }, oldViewStamp: n, newViewStamp: c };
2213
2216
  }
2214
- function Es(a, t, e) {
2217
+ function vs(a, t, e) {
2215
2218
  const s = new Array(t.length);
2216
2219
  for (let p = 0; p < t.length; p++) {
2217
2220
  const m = t[p], C = a.archetypes.get(m.archetypeId);
@@ -2222,7 +2225,7 @@ function Es(a, t, e) {
2222
2225
  columns: C.columnsInOrder
2223
2226
  };
2224
2227
  }
2225
- const { descriptors: n, newTotal: r } = ce(a.buffer.byteLength, s), i = /* @__PURE__ */ new Map();
2228
+ const { descriptors: n, newTotal: r } = ce(ue(a), s), i = /* @__PURE__ */ new Map();
2226
2229
  for (let p = 0; p < n.length; p++)
2227
2230
  i.set(n[p].archetypeId, n[p]);
2228
2231
  const { grownBuffer: o, newView: h } = le(a, r), c = new Uint8Array(o);
@@ -2271,7 +2274,7 @@ class gt extends Error {
2271
2274
  super(t), this.name = "StoreGrowError";
2272
2275
  }
2273
2276
  }
2274
- function vs(a, t, e) {
2277
+ function bs(a, t, e) {
2275
2278
  const s = /* @__PURE__ */ new Map();
2276
2279
  for (let l = 0; l < t.archetypes.length; l++) {
2277
2280
  const u = t.archetypes[l];
@@ -2310,9 +2313,9 @@ function vs(a, t, e) {
2310
2313
  }
2311
2314
  if (e?.isInPlace === !0 && kt(a) && a._allocator === e && r.length > 0) {
2312
2315
  const l = a.view.getUint32(O.layout_descriptor_off, !0);
2313
- return Es(a, r, l);
2316
+ return vs(a, r, l);
2314
2317
  }
2315
- const { store: o, oldViewStamp: h, newViewStamp: c } = ue(
2318
+ const { store: o, oldViewStamp: h, newViewStamp: c } = de(
2316
2319
  a,
2317
2320
  n,
2318
2321
  i,
@@ -2331,7 +2334,7 @@ class q extends Error {
2331
2334
  super(t), this.name = "StoreExtendError";
2332
2335
  }
2333
2336
  }
2334
- function bs(a, t, e) {
2337
+ function Cs(a, t, e) {
2335
2338
  if (t.newArchetypes.length === 0)
2336
2339
  throw new q("extend plan has no new archetypes; use grow_column_store for resizes");
2337
2340
  const s = /* @__PURE__ */ new Set();
@@ -2375,7 +2378,7 @@ function bs(a, t, e) {
2375
2378
  for (let d = 0; d < t.newArchetypes.length; d++)
2376
2379
  u += vt(t.newArchetypes[d].columns.length);
2377
2380
  if (l + u <= a._regionBytes)
2378
- return Cs(a, t.newArchetypes, c, l);
2381
+ return Ss(a, t.newArchetypes, c, l);
2379
2382
  }
2380
2383
  const r = [];
2381
2384
  for (const [c, l] of a.archetypes)
@@ -2387,7 +2390,7 @@ function bs(a, t, e) {
2387
2390
  });
2388
2391
  for (let c = 0; c < t.newArchetypes.length; c++)
2389
2392
  r.push(t.newArchetypes[c]);
2390
- const { store: i, oldViewStamp: o, newViewStamp: h } = ue(
2393
+ const { store: i, oldViewStamp: o, newViewStamp: h } = de(
2391
2394
  a,
2392
2395
  r,
2393
2396
  n,
@@ -2395,7 +2398,7 @@ function bs(a, t, e) {
2395
2398
  );
2396
2399
  return { store: i, oldViewStamp: o, newViewStamp: h, viewsPreserved: !1 };
2397
2400
  }
2398
- function Cs(a, t, e, s) {
2401
+ function Ss(a, t, e, s) {
2399
2402
  const n = new Array(t.length);
2400
2403
  for (let y = 0; y < t.length; y++) {
2401
2404
  const p = t[y];
@@ -2407,12 +2410,12 @@ function Cs(a, t, e, s) {
2407
2410
  componentId: m.componentId,
2408
2411
  fieldId: m.fieldId,
2409
2412
  typeTag: m.typeTag,
2410
- stride: be[m.typeTag]
2413
+ stride: Ce[m.typeTag]
2411
2414
  }))
2412
2415
  };
2413
2416
  }
2414
2417
  const { descriptors: r, newTotal: i } = ce(
2415
- a.buffer.byteLength,
2418
+ ue(a),
2416
2419
  n
2417
2420
  ), { grownBuffer: o, newView: h } = le(a, i);
2418
2421
  let c = e + s;
@@ -2451,7 +2454,7 @@ class k extends Error {
2451
2454
  }
2452
2455
  }
2453
2456
  const W = 4;
2454
- function Ss(a) {
2457
+ function Rs(a) {
2455
2458
  const t = a.freeIndices.length, e = a.archetypeRows.length, s = W * (4 + t + 1 + e * 3), n = new Uint8Array(s), r = new DataView(n.buffer);
2456
2459
  let i = 0;
2457
2460
  const o = (h) => {
@@ -2466,7 +2469,7 @@ function Ss(a) {
2466
2469
  }
2467
2470
  return n;
2468
2471
  }
2469
- function Rs(a) {
2472
+ function Is(a) {
2470
2473
  const t = new DataView(a.buffer, a.byteOffset, a.byteLength), e = a.byteLength;
2471
2474
  let s = 0;
2472
2475
  const n = (f) => {
@@ -2491,11 +2494,11 @@ function Rs(a) {
2491
2494
  );
2492
2495
  return { tick: i, entityHighWater: o, entityAliveCount: h, freeIndices: l, archetypeRows: d };
2493
2496
  }
2494
- function Is(a, t, e) {
2497
+ function As(a, t, e) {
2495
2498
  const s = W * 5, n = new Uint8Array(s + a.length + t.length + e.length), r = new DataView(n.buffer);
2496
2499
  return r.setUint32(0, Rt, !0), r.setUint32(4, It, !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;
2497
2500
  }
2498
- function As(a) {
2501
+ function Os(a) {
2499
2502
  const t = W * 5;
2500
2503
  if (a.byteLength < t)
2501
2504
  throw new k(
@@ -2523,7 +2526,7 @@ function As(a) {
2523
2526
  host: new Uint8Array(c, h + t + r + i, o)
2524
2527
  };
2525
2528
  }
2526
- function Os(a, t, e) {
2529
+ function ks(a, t, e) {
2527
2530
  if (a.byteLength < ht)
2528
2531
  throw new k(
2529
2532
  `dense section too small: ${a.byteLength} bytes (SAB header needs ${ht})`
@@ -2544,7 +2547,7 @@ function Os(a, t, e) {
2544
2547
  `dense layoutDescriptorOff ${i.layoutDescriptorOff} is outside the section (${a.byteLength} bytes)`
2545
2548
  );
2546
2549
  const o = i.entityIndexOff;
2547
- if (o < 0 || o + Ce > a.byteLength)
2550
+ if (o < 0 || o + Se > a.byteLength)
2548
2551
  throw new k(
2549
2552
  `dense entityIndexOff ${o} is outside the section (${a.byteLength} bytes)`
2550
2553
  );
@@ -2575,7 +2578,7 @@ function Os(a, t, e) {
2575
2578
  throw new k(
2576
2579
  `archetype-set mismatch: snapshot archetype ${u.archetypeId} is absent from the live world`
2577
2580
  );
2578
- if (!ks(d.componentMask, u.componentMask))
2581
+ if (!Ts(d.componentMask, u.componentMask))
2579
2582
  throw new k(
2580
2583
  `archetype ${u.archetypeId} component-mask mismatch between the live world and the snapshot (different component registration)`
2581
2584
  );
@@ -2591,12 +2594,12 @@ function Os(a, t, e) {
2591
2594
  );
2592
2595
  }
2593
2596
  }
2594
- function ks(a, t) {
2597
+ function Ts(a, t) {
2595
2598
  if (a.length !== t.length) return !1;
2596
2599
  for (let e = 0; e < a.length; e++) if (a[e] !== t[e]) return !1;
2597
2600
  return !0;
2598
2601
  }
2599
- class Ts {
2602
+ class Ds {
2600
2603
  host;
2601
2604
  /** The allocator IS its own snapshot seam (H1 step 3): free-list copy on
2602
2605
  * capture; `setHighWater` + `restoreHostState` on mount. */
@@ -2614,7 +2617,7 @@ class Ts {
2614
2617
  * different orders snapshot byte-for-byte the same (#470). The reverse index
2615
2618
  * is derived and never serialized — `restoreSparse` rebuilds it. */
2616
2619
  snapshotSparse() {
2617
- const t = Se(this.host.sparseStores()), e = Re(this.host.relationStores()), s = new Uint8Array(8 + t.length + e.length), n = new DataView(s.buffer);
2620
+ const t = Re(this.host.sparseStores()), e = Ie(this.host.relationStores()), s = new Uint8Array(8 + t.length + e.length), n = new DataView(s.buffer);
2618
2621
  return n.setUint32(0, t.length, !0), n.setUint32(4, e.length, !0), s.set(t, 8), s.set(e, 8 + t.length), s;
2619
2622
  }
2620
2623
  /** Repopulate the sparse stores from `snapshotSparse` bytes, replacing all
@@ -2637,7 +2640,7 @@ class Ts {
2637
2640
  throw new et(
2638
2641
  `sparse snapshot frame mismatch: header declares 8+${s}+${n}=${8 + s + n} bytes, buffer is ${t.byteLength}`
2639
2642
  );
2640
- Ie(this.host.sparseStores(), t.subarray(8, 8 + s)), this.rebuildRelationIndices(t.subarray(8 + s, 8 + s + n));
2643
+ Ae(this.host.sparseStores(), t.subarray(8, 8 + s)), this.rebuildRelationIndices(t.subarray(8 + s, 8 + s + n));
2641
2644
  }
2642
2645
  /** Rebuild every relation's derived side indices after the sparse stores have
2643
2646
  * been restored. `restoreRelations` resets all relations, rebuilds the multi
@@ -2647,7 +2650,7 @@ class Ts {
2647
2650
  * `(source index → target EntityID)`, which is exactly one reverse edge. */
2648
2651
  rebuildRelationIndices(t) {
2649
2652
  const e = this.host.generations(), s = (r) => J(r, e[r]), n = this.host.relationStores();
2650
- Ae(n, t, s);
2653
+ Oe(n, t, s);
2651
2654
  for (let r = 0; r < n.length; r++) n[r].rebuildReverseFromForward(s);
2652
2655
  }
2653
2656
  /** Capture the full live world to one self-contained byte buffer that
@@ -2656,8 +2659,8 @@ class Ts {
2656
2659
  * relation bytes, and the host-side bookkeeping the SAB omits. */
2657
2660
  snapshot() {
2658
2661
  this.host.publishRowCounts();
2659
- const t = new Uint8Array(Ze(this.host.columnStore())), e = this.snapshotSparse(), s = Ss(this.collectHostState());
2660
- return Is(t, e, s);
2662
+ const t = new Uint8Array(Je(this.host.columnStore())), e = this.snapshotSparse(), s = Rs(this.collectHostState());
2663
+ return As(t, e, s);
2661
2664
  }
2662
2665
  /** Gather the host-side state a snapshot carries alongside the dense + sparse
2663
2666
  * bytes — see `snapshot()`. The free-list is copied (it's a live mutable). */
@@ -2683,13 +2686,13 @@ class Ts {
2683
2686
  * ticking. Fails closed on a malformed frame or a registration mismatch
2684
2687
  * BEFORE any live state is touched. */
2685
2688
  restoreInto(t) {
2686
- const e = As(t), s = Rs(e.host);
2687
- Os(
2689
+ const e = Os(t), s = Is(e.host);
2690
+ ks(
2688
2691
  e.dense,
2689
2692
  this.host.columnStore().archetypes,
2690
2693
  this.host.entityIndexCapacity()
2691
2694
  ), this.assertSparseSectionMatches(e.sparse);
2692
- const n = Je(e.dense, this.host.bufferAllocator());
2695
+ const n = ts(e.dense, this.host.bufferAllocator());
2693
2696
  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);
2694
2697
  }
2695
2698
  /** Read-only validation of a `snapshotSparse` SECTION (the framed
@@ -2711,14 +2714,14 @@ class Ts {
2711
2714
  throw new et(
2712
2715
  `sparse snapshot frame mismatch: header declares 8+${s}+${n}=${8 + s + n} bytes, buffer is ${t.byteLength}`
2713
2716
  );
2714
- Oe(this.host.sparseStores(), t.subarray(8, 8 + s));
2717
+ ke(this.host.sparseStores(), t.subarray(8, 8 + s));
2715
2718
  }
2716
2719
  }
2717
- function de(a, t, e) {
2720
+ function fe(a, t, e) {
2718
2721
  const s = a.get(t);
2719
2722
  s !== void 0 ? s.push(e) : a.set(t, [e]);
2720
2723
  }
2721
- class Ds {
2724
+ class xs {
2722
2725
  /** All archetypes, indexed by `ArchetypeID` (ids are minted monotonically
2723
2726
  * and never removed). Store's flush loops hoist this array to a local. */
2724
2727
  archetypes = [];
@@ -2842,7 +2845,7 @@ class Ds {
2842
2845
  * mask-allocating callers (`copyWithSet`, `copyWithClear`, etc.). */
2843
2846
  install(t, e, s, n) {
2844
2847
  const r = e.copy(), i = this.host.materialize(t, r, s);
2845
- this.archetypes.push(i), de(this.archetypeMap, n, t), e.forEach((o) => {
2848
+ this.archetypes.push(i), fe(this.archetypeMap, n, t), e.forEach((o) => {
2846
2849
  const h = o;
2847
2850
  let c = this.componentIndex[h];
2848
2851
  c === void 0 && (c = [], this.componentIndex[h] = c), c.push(t);
@@ -2896,7 +2899,7 @@ function qt(a, t, e, s) {
2896
2899
  n.push({
2897
2900
  componentId: h.componentId,
2898
2901
  fieldId: l,
2899
- typeTag: ke[c[l]]
2902
+ typeTag: Te[c[l]]
2900
2903
  });
2901
2904
  }
2902
2905
  const r = t._words, i = new Array(Nt);
@@ -2909,8 +2912,8 @@ function qt(a, t, e, s) {
2909
2912
  columns: n
2910
2913
  };
2911
2914
  }
2912
- const xs = [], jt = -1, yt = new DataView(new ArrayBuffer(8)), zt = 129, Ms = 7, mt = -1;
2913
- class Ls {
2915
+ const Ms = [], jt = -1, yt = new DataView(new ArrayBuffer(8)), zt = 129, Ls = 7, mt = -1;
2916
+ class Ns {
2914
2917
  // --- Entity ID management ---
2915
2918
  // Generational slot allocation (generations view, high-water, free-list,
2916
2919
  // alive count) lives in `EntityAllocator` (H1 step 3). `entityArchetype` /
@@ -2947,7 +2950,7 @@ class Ls {
2947
2950
  // --- Event channels ---
2948
2951
  // Channel array + key map + per-tick dirty list live in `EventRegistry`
2949
2952
  // (event_registry.ts, H1 step 2); the event methods below delegate.
2950
- events = new ss();
2953
+ events = new ns();
2951
2954
  // --- Archetype management ---
2952
2955
  // Topology (archetype list, mask→id map, id counter, inverted component
2953
2956
  // index, edge resolution/creation) lives in `ArchetypeGraph` (H1 step 6).
@@ -3148,7 +3151,7 @@ class Ls {
3148
3151
  }
3149
3152
  let l;
3150
3153
  try {
3151
- l = vs(
3154
+ l = bs(
3152
3155
  this._columnStore,
3153
3156
  { archetypes: h },
3154
3157
  this._bufferAllocator
@@ -3197,12 +3200,12 @@ class Ls {
3197
3200
  * that pass `new Store(4)` keep working. */
3198
3201
  constructor(t) {
3199
3202
  const e = typeof t == "number" ? { initialCapacity: t } : t ?? {};
3200
- if (this.initialCapacity = e.initialCapacity ?? ee, this._bufferAllocator = e.bufferAllocator ?? Xe(), this._bufferAllocator.isInPlace !== !0)
3203
+ if (this.initialCapacity = e.initialCapacity ?? ee, this._bufferAllocator = e.bufferAllocator ?? Ze(), this._bufferAllocator.isInPlace !== !0)
3201
3204
  throw new v(
3202
3205
  b.INVALID_MEMORY_OPTIONS,
3203
3206
  "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."
3204
3207
  );
3205
- this._capContext = e.capContext, this._onBufferResized = e.onBufferResized, this._entityIndexCapacity = e.entityIndexCapacity ?? Te, this._regions = e.regions, this._bindingsRegionBytes = e.bindingsRegionBytes ?? 0, this._deterministic = e.deterministic ?? !1, this._deferred = new ps(
3208
+ this._capContext = e.capContext, this._onBufferResized = e.onBufferResized, this._entityIndexCapacity = e.entityIndexCapacity ?? De, this._regions = e.regions, this._bindingsRegionBytes = e.bindingsRegionBytes ?? 0, this._deterministic = e.deterministic ?? !1, this._deferred = new _s(
3206
3209
  {
3207
3210
  applyAdds: () => this._flushAdds(),
3208
3211
  applyRemoves: () => this._flushRemoves(),
@@ -3213,7 +3216,7 @@ class Ls {
3213
3216
  structuralObserverHook: () => this._structuralObserverHook
3214
3217
  },
3215
3218
  this._obsEvents
3216
- ), this.relationService = new ds({
3219
+ ), this.relationService = new fs({
3217
3220
  isAlive: (n) => this.isAlive(n),
3218
3221
  hasSparse: (n, r) => this.hasSparse(n, r),
3219
3222
  pushSparseStore: (n, r) => this._pushSparseStore(n, r),
@@ -3236,9 +3239,9 @@ class Ls {
3236
3239
  }), this._columnStore = se([], this._bufferAllocator, {
3237
3240
  reservedDescriptorBytes: 64 * 1024,
3238
3241
  entityIndexCapacity: this._entityIndexCapacity,
3239
- eventRingCapacitySlots: Pe,
3240
- commandRingCapacitySlots: Ge,
3241
- actionRingCapacitySlots: $e,
3242
+ eventRingCapacitySlots: Ue,
3243
+ commandRingCapacitySlots: Pe,
3244
+ actionRingCapacitySlots: Ge,
3242
3245
  regions: this._regions,
3243
3246
  bindingsRegionBytes: this._bindingsRegionBytes
3244
3247
  });
@@ -3247,7 +3250,7 @@ class Ls {
3247
3250
  this._columnStore.header.entityIndexOff,
3248
3251
  this._entityIndexCapacity
3249
3252
  );
3250
- this.entityArchetype = s.archetypes, this.entityRow = s.rows, this.entityAllocator = new fs(
3253
+ this.entityArchetype = s.archetypes, this.entityRow = s.rows, this.entityAllocator = new ps(
3251
3254
  this._entityIndexCapacity,
3252
3255
  s.generations,
3253
3256
  new Uint32Array(
@@ -3255,7 +3258,7 @@ class Ls {
3255
3258
  this._columnStore.header.entityIndexOff + it.length,
3256
3259
  1
3257
3260
  )
3258
- ), this._snapshots = new Ts(
3261
+ ), this._snapshots = new Ds(
3259
3262
  {
3260
3263
  sparseStores: () => this.sparseStores,
3261
3264
  relationStores: () => this.relationService.stores,
@@ -3276,7 +3279,7 @@ class Ls {
3276
3279
  }
3277
3280
  },
3278
3281
  this.entityAllocator
3279
- ), this.archGraph = new Ds({
3282
+ ), this.archGraph = new xs({
3280
3283
  componentMetas: () => this.componentMetas,
3281
3284
  initialCapacity: () => this.initialCapacity,
3282
3285
  extendStore: (n) => this._archExtendStoreWithNewSpecs(n),
@@ -3386,7 +3389,7 @@ class Ls {
3386
3389
  * view over exactly the region's span without re-reading the directory.
3387
3390
  * Re-fetch after a SAB grow (the offset/view may have moved). (#623) */
3388
3391
  regionHandle(t) {
3389
- const e = De(this._columnStore.view, t);
3392
+ const e = xe(this._columnStore.view, t);
3390
3393
  return e === null ? null : {
3391
3394
  buffer: this._columnStore.buffer,
3392
3395
  view: this._columnStore.view,
@@ -3438,7 +3441,7 @@ class Ls {
3438
3441
  e + ft.enabled_count,
3439
3442
  r.hasColumns ? r.enabledCount : 0,
3440
3443
  !0
3441
- ), e += xe + i * Me;
3444
+ ), e += Me + i * Le;
3442
3445
  }
3443
3446
  this._rowCountsDirty = !1;
3444
3447
  }
@@ -3487,7 +3490,7 @@ class Ls {
3487
3490
  * target sets) is the determinism tax the flag gates. */
3488
3491
  stateHash() {
3489
3492
  this._requireDeterministic("state_hash()");
3490
- let t = Le;
3493
+ let t = Ne;
3491
3494
  const e = this.archGraph.archetypes;
3492
3495
  for (let r = 0; r < e.length; r++) {
3493
3496
  const i = e[r], o = i.id, h = i.length;
@@ -3588,7 +3591,7 @@ class Ls {
3588
3591
  }
3589
3592
  let n;
3590
3593
  try {
3591
- n = bs(
3594
+ n = Cs(
3592
3595
  this._columnStore,
3593
3596
  { newArchetypes: t, existing: e },
3594
3597
  this._bufferAllocator
@@ -3832,7 +3835,7 @@ class Ls {
3832
3835
  * well-formed handle pays two branches and nothing else (#778 measured).
3833
3836
  */
3834
3837
  isAlive(t) {
3835
- if (t < 0 || t > Ne) return !1;
3838
+ if (t < 0 || t > Be) return !1;
3836
3839
  const e = $t(t);
3837
3840
  if (e === Et) return !1;
3838
3841
  const s = w(t);
@@ -4119,8 +4122,8 @@ class Ls {
4119
4122
  if (Mt)
4120
4123
  D.moveEntityFromTag(R, H, p, i);
4121
4124
  else {
4122
- const fe = R.getEdge(S);
4123
- D.moveEntityFrom(R, H, p, fe.addMap, u, i);
4125
+ const pe = R.getEdge(S);
4126
+ D.moveEntityFrom(R, H, p, pe.addMap, u, i);
4124
4127
  }
4125
4128
  tt = x[0];
4126
4129
  } else
@@ -4214,7 +4217,7 @@ class Ls {
4214
4217
  * when nothing is dirty. Caller owns the returned array. */
4215
4218
  _takeDirty(t) {
4216
4219
  const e = this._dirtyLists[t];
4217
- if (e === void 0 || e.length === 0) return xs;
4220
+ if (e === void 0 || e.length === 0) return Ms;
4218
4221
  this._dirtyLists[t] = [];
4219
4222
  const s = this._dirtyMarks[t];
4220
4223
  for (let n = 0; n < e.length; n++) s[e[n] & V] = 0;
@@ -4286,7 +4289,7 @@ class Ls {
4286
4289
  trackDirty: !1
4287
4290
  });
4288
4291
  const o = he(i);
4289
- return e !== void 0 && Be(o, e), o;
4292
+ return e !== void 0 && Fe(o, e), o;
4290
4293
  }
4291
4294
  /** `'Pos' (component 5)` when the component was registered with a debug
4292
4295
  * name, else `component 5` — the label diagnostics interpolate. */
@@ -4338,7 +4341,7 @@ class Ls {
4338
4341
  * through `registerSparseComponent`, which guards first. */
4339
4342
  _pushSparseStore(t, e, s) {
4340
4343
  const n = this.sparseStores.length;
4341
- return this.sparseStores.push(new Fe(t, e)), this.sparseNames.push(s), T(n);
4344
+ return this.sparseStores.push(new $e(t, e)), this.sparseNames.push(s), T(n);
4342
4345
  }
4343
4346
  sparseStoreOf(t) {
4344
4347
  const e = t, s = this.sparseStores[e];
@@ -4716,7 +4719,7 @@ class Ls {
4716
4719
  let o = i;
4717
4720
  for (let d = 0; d < i; d++) {
4718
4721
  const f = e[d].def.id;
4719
- if (f >= zt - 1 || i > Ms) {
4722
+ if (f >= zt - 1 || i > Ls) {
4720
4723
  o = mt;
4721
4724
  break;
4722
4725
  }
@@ -4940,9 +4943,9 @@ class Ls {
4940
4943
  for (let c = 0; c < n.length; c++) {
4941
4944
  let l = n[c];
4942
4945
  if (l === 0) continue;
4943
- const u = c << Qe;
4946
+ const u = c << Ke;
4944
4947
  for (; l !== 0; ) {
4945
- const d = l & -l >>> 0, f = u + (Ye - Math.clz32(d));
4948
+ const d = l & -l >>> 0, f = u + (Qe - Math.clz32(d));
4946
4949
  l ^= d;
4947
4950
  const g = this.archGraph.componentIndex[f];
4948
4951
  if (g === void 0 || g.length === 0) {
@@ -5022,7 +5025,7 @@ class Ls {
5022
5025
  // =======================================================
5023
5026
  // Resource storage — delegations to `ResourceRegistry` (resource_registry.ts)
5024
5027
  // =======================================================
5025
- resources = new ns();
5028
+ resources = new rs();
5026
5029
  registerResource(t, e) {
5027
5030
  this.resources.register(t, e);
5028
5031
  }
@@ -5041,7 +5044,7 @@ class Ls {
5041
5044
  return this.resources.has(t);
5042
5045
  }
5043
5046
  }
5044
- class Ns {
5047
+ class Bs {
5045
5048
  store;
5046
5049
  /** @internal constructed by `ECS`. */
5047
5050
  constructor(t) {
@@ -5115,7 +5118,7 @@ class Ns {
5115
5118
  return this.store.compactRelations();
5116
5119
  }
5117
5120
  }
5118
- class Bs {
5121
+ class Fs {
5119
5122
  store;
5120
5123
  /** @internal constructed by `ECS`. */
5121
5124
  constructor(t) {
@@ -5149,7 +5152,7 @@ class Bs {
5149
5152
  return this.store.getEventReader(e);
5150
5153
  }
5151
5154
  }
5152
- class Fs {
5155
+ class $s {
5153
5156
  store;
5154
5157
  /** @internal constructed by `ECS`. */
5155
5158
  constructor(t) {
@@ -5183,7 +5186,7 @@ class Fs {
5183
5186
  return this.store.hasResource(t);
5184
5187
  }
5185
5188
  }
5186
- class $s {
5189
+ class Gs {
5187
5190
  store;
5188
5191
  /** @internal constructed by `ECS`. */
5189
5192
  constructor(t) {
@@ -5250,7 +5253,7 @@ function At(a, t) {
5250
5253
  const s = Object.create(e);
5251
5254
  return s._row = t, s;
5252
5255
  }
5253
- class Gs {
5256
+ class Ps {
5254
5257
  // Query deduplication: hash(include, exclude, anyOf) → bucket of cache
5255
5258
  // entries. Multiple term sets can share a hash (collision), so each bucket
5256
5259
  // is an array; `findDedup` equality-checks masks within the bucket.
@@ -5298,10 +5301,10 @@ class Gs {
5298
5301
  }
5299
5302
  /** Record a freshly minted query under its dedup key. */
5300
5303
  addDedup(t, e) {
5301
- de(this.dedup, t, e);
5304
+ fe(this.dedup, t, e);
5302
5305
  }
5303
5306
  }
5304
- const Yt = Object.freeze([]), Ps = Object.freeze([]), Qt = Object.freeze([]), Kt = Number.POSITIVE_INFINITY;
5307
+ const Yt = Object.freeze([]), Us = Object.freeze([]), Qt = Object.freeze([]), Kt = Number.POSITIVE_INFINITY;
5305
5308
  function X(a, t) {
5306
5309
  return (a << 16 | t) >>> 0;
5307
5310
  }
@@ -5310,7 +5313,7 @@ function rt(a, t) {
5310
5313
  if (a[e] === t) return a;
5311
5314
  return [...a, t];
5312
5315
  }
5313
- function Us(a, t) {
5316
+ function Hs(a, t) {
5314
5317
  for (let e = 0; e < a.length; e++)
5315
5318
  if (a[e] === t) return a;
5316
5319
  return [...a, t];
@@ -5320,7 +5323,7 @@ function Xt(a, t) {
5320
5323
  if (a[e] === t) return a;
5321
5324
  return [...a, t];
5322
5325
  }
5323
- class Hs {
5326
+ class Vs {
5324
5327
  /** @internal */
5325
5328
  _arch;
5326
5329
  /** @internal */
@@ -5404,7 +5407,7 @@ class F {
5404
5407
  // archetypes — there is no SoA span — so `forEach` rejects it, like a sparse
5405
5408
  // term); `accessCheck` validates `relationReads: [R]` at iteration time.
5406
5409
  _hierarchy;
5407
- constructor(t, e, s, n, r, i, o, h = Yt, c = Yt, l = Ps, u = !1, d = Qt, f = Qt, g = null) {
5410
+ constructor(t, e, s, n, r, i, o, h = Yt, c = Yt, l = Us, u = !1, d = Qt, f = Qt, g = null) {
5408
5411
  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 = g;
5409
5412
  }
5410
5413
  /** Guard the dense-only methods (`count` / `forEach` / `archetype_count`)
@@ -5797,7 +5800,7 @@ class F {
5797
5800
  _optionalOne(t) {
5798
5801
  const e = (this._id << 16 | t) >>> 0, s = this._resolver._caches.optionalSingle, n = s.get(e);
5799
5802
  if (n !== void 0) return n;
5800
- const r = this._deriveOptional(Us(this._optional, t));
5803
+ const r = this._deriveOptional(Hs(this._optional, t));
5801
5804
  return s.set(e, r), r;
5802
5805
  }
5803
5806
  /** Build a derived query carrying new optional terms. Reuses this query's
@@ -5916,7 +5919,7 @@ class F {
5916
5919
  * column-group caches that actually matter for allocation live on the
5917
5920
  * `Archetype`, untouched. */
5918
5921
  _eachChunkInner(t) {
5919
- const e = new Hs();
5922
+ const e = new Vs();
5920
5923
  e._tick = this._resolver._getCurrentTick();
5921
5924
  const s = this._nonEmpty();
5922
5925
  for (let n = 0; n < s.length; n++)
@@ -6091,7 +6094,7 @@ class F {
6091
6094
  return this._resolver._getLastRunTick();
6092
6095
  }
6093
6096
  }
6094
- class Vs {
6097
+ class qs {
6095
6098
  constructor(t) {
6096
6099
  this._resolver = t;
6097
6100
  }
@@ -6101,7 +6104,7 @@ class Vs {
6101
6104
  return this._resolver._resolveQuery(e, null, null, t);
6102
6105
  }
6103
6106
  }
6104
- class qs {
6107
+ class js {
6105
6108
  constructor(t) {
6106
6109
  this.store = t;
6107
6110
  }
@@ -6154,9 +6157,9 @@ class qs {
6154
6157
  return this.store.enableEntityDeferred(t), this;
6155
6158
  }
6156
6159
  }
6157
- class js {
6160
+ class zs {
6158
6161
  constructor(t) {
6159
- this.store = t, this.commands = new qs(t);
6162
+ this.store = t, this.commands = new js(t);
6160
6163
  }
6161
6164
  lastRunTick = 0;
6162
6165
  /** Deferred structural-command facade (§ctx.commands). */
@@ -6453,7 +6456,7 @@ function Zt(a) {
6453
6456
  );
6454
6457
  return a;
6455
6458
  }
6456
- function zs(a) {
6459
+ function Ws(a) {
6457
6460
  if (!Number.isInteger(a) || a < 1)
6458
6461
  throw new v(
6459
6462
  b.INVALID_MAX_FIXED_STEPS,
@@ -6461,7 +6464,7 @@ function zs(a) {
6461
6464
  );
6462
6465
  return a;
6463
6466
  }
6464
- class sn {
6467
+ class nn {
6465
6468
  store;
6466
6469
  schedule;
6467
6470
  ctx;
@@ -6503,7 +6506,7 @@ class sn {
6503
6506
  // All query-resolution caches — dedup + the shared composition maps — in
6504
6507
  // one owner (M2); see `QueryCache` in query.ts for keying/id-space notes.
6505
6508
  /** @internal Query-composition caches (QueryResolver seam) — not public API. */
6506
- _caches = new Gs();
6509
+ _caches = new Ps();
6507
6510
  // --- SAB layout subscribers (e.g. a compute backend) ---
6508
6511
  // The engine publishes SAB-layout changes to whoever subscribed via
6509
6512
  // `onStoreLayoutPublished`. The engine has no knowledge of what the
@@ -6536,8 +6539,8 @@ class sn {
6536
6539
  b.INVALID_MEMORY_OPTIONS,
6537
6540
  "ECSOptions.initial_capacity / buffer_allocator were replaced by ECSOptions.memory: initial_capacity → memory.columnCapacity (or memory.budget); buffer_allocator → memory.wasm (WASM-backed) or memory.allocator (custom in-place)."
6538
6541
  );
6539
- const s = Ue(t?.memory);
6540
- this._memory = s, this.store = new Ls({
6542
+ const s = He(t?.memory);
6543
+ this._memory = s, this.store = new Ns({
6541
6544
  initialCapacity: s.columnCapacity,
6542
6545
  bufferAllocator: s.allocator,
6543
6546
  entityIndexCapacity: s.entityIndexCapacity,
@@ -6554,10 +6557,10 @@ class sn {
6554
6557
  regions: t?.regions,
6555
6558
  bindingsRegionBytes: t?.bindingsRegionBytes,
6556
6559
  deterministic: t?.deterministic
6557
- }), this.schedule = new He(t?.onWarn), this.relations = new Ns(this.store), this.events = new Bs(this.store), this.resources = new Fs(this.store), this.snapshots = new $s(this.store), this.ctx = new js(this.store), this._observers = new us(this.store, this.ctx), this.store.setStructuralObserverHook((n) => this._observers.dispatchStructural(n)), this._fixedTimestep = Zt(
6558
- t?.fixedTimestep ?? Ve
6559
- ), this._maxFixedSteps = zs(
6560
- t?.maxFixedSteps ?? qe
6560
+ }), this.schedule = new Ve(t?.onWarn), this.relations = new Bs(this.store), this.events = new Fs(this.store), this.resources = new $s(this.store), this.snapshots = new Gs(this.store), this.ctx = new zs(this.store), this._observers = new ds(this.store, this.ctx), this.store.setStructuralObserverHook((n) => this._observers.dispatchStructural(n)), this._fixedTimestep = Zt(
6561
+ t?.fixedTimestep ?? qe
6562
+ ), this._maxFixedSteps = Ws(
6563
+ t?.maxFixedSteps ?? je
6561
6564
  );
6562
6565
  }
6563
6566
  /** Batch variant of `regionHandle` for hosts wiring several consumer
@@ -6864,7 +6867,7 @@ class sn {
6864
6867
  }
6865
6868
  /** QueryResolver implementation — creates or retrieves a cached Query. */
6866
6869
  _resolveQuery(t, e, s, n) {
6867
- const r = t.hash(), i = e ? e.hash() : 0, o = s ? s.hash() : 0, h = r ^ Math.imul(i, je) ^ Math.imul(o, ze) | 0, c = this._caches.findDedup(h, t, e, s);
6870
+ const r = t.hash(), i = e ? e.hash() : 0, o = s ? s.hash() : 0, h = r ^ Math.imul(i, ze) ^ Math.imul(o, We) | 0, c = this._caches.findDedup(h, t, e, s);
6868
6871
  if (c !== void 0) return c.query;
6869
6872
  const l = this.store.registerQuery(t, e ?? void 0, s ?? void 0), u = new F(
6870
6873
  l,
@@ -6889,7 +6892,7 @@ class sn {
6889
6892
  let s;
6890
6893
  if (typeof t == "function")
6891
6894
  if (e !== void 0) {
6892
- const i = e(new Vs(this)), o = this.ctx, h = t;
6895
+ const i = e(new qs(this)), o = this.ctx, h = t;
6893
6896
  s = { ...St, fn: (c, l) => h(i, o, l) };
6894
6897
  } else
6895
6898
  s = { ...St, fn: t };
@@ -6897,7 +6900,7 @@ class sn {
6897
6900
  s = t;
6898
6901
  const n = ae(this.nextSystemId++), r = Object.freeze({
6899
6902
  ...s,
6900
- ...is(s),
6903
+ ...os(s),
6901
6904
  id: n
6902
6905
  });
6903
6906
  return this.systems.add(r), r;
@@ -6943,7 +6946,7 @@ class sn {
6943
6946
  * `private` because the only caller is `startup()`; visible to tests via
6944
6947
  * the `archetype_count` delta on the public ECS facade. */
6945
6948
  prewarmArchetypes() {
6946
- const t = Ws([...this.systems, ...this._observers.descriptors()]);
6949
+ const t = Ys([...this.systems, ...this._observers.descriptors()]);
6947
6950
  t.length !== 0 && this.store.archCreateManyFromMasks(t);
6948
6951
  }
6949
6952
  /**
@@ -7192,7 +7195,7 @@ class sn {
7192
7195
  }
7193
7196
  // === END STORE PASS-THROUGH BAND ===
7194
7197
  }
7195
- function Ws(a) {
7198
+ function Ys(a) {
7196
7199
  const t = /* @__PURE__ */ new Map(), e = [], s = (o) => {
7197
7200
  const h = o.hash(), c = t.get(h);
7198
7201
  if (c !== void 0) {
@@ -7240,21 +7243,21 @@ function Ws(a) {
7240
7243
  for (const o of t.values()) for (let h = 0; h < o.length; h++) i.push(o[h]);
7241
7244
  return i;
7242
7245
  }
7243
- function nn(a, t) {
7246
+ function rn(a, t) {
7244
7247
  return {
7245
7248
  name: `runIfResourceEq(${a.description ?? "?"})`,
7246
7249
  resourceReads: [a],
7247
7250
  evaluate: (e) => e.getResource(a) === t
7248
7251
  };
7249
7252
  }
7250
- function rn(a, t = 0) {
7253
+ function on(a, t = 0) {
7251
7254
  const e = (t % a + a) % a;
7252
7255
  return {
7253
7256
  name: `runEveryNTicks(${a}${e !== 0 ? `, +${e}` : ""})`,
7254
7257
  evaluate: (s) => (s.ecsTick - e) % a === 0
7255
7258
  };
7256
7259
  }
7257
- function on(a) {
7260
+ function hn(a) {
7258
7261
  return {
7259
7262
  name: "runIfAnyMatch",
7260
7263
  reads: a._defs,
@@ -7270,31 +7273,31 @@ function xt(a) {
7270
7273
  ...e.length > 0 ? { resourceReads: e } : {}
7271
7274
  };
7272
7275
  }
7273
- function hn(a) {
7276
+ function an(a) {
7274
7277
  return {
7275
7278
  name: `not(${a.name})`,
7276
7279
  ...xt([a]),
7277
7280
  evaluate: (t) => !a.evaluate(t)
7278
7281
  };
7279
7282
  }
7280
- function an(...a) {
7283
+ function cn(...a) {
7281
7284
  return {
7282
7285
  name: `allOf(${a.map((t) => t.name).join(", ")})`,
7283
7286
  ...xt(a),
7284
7287
  evaluate: (t) => a.every((e) => e.evaluate(t))
7285
7288
  };
7286
7289
  }
7287
- function cn(...a) {
7290
+ function ln(...a) {
7288
7291
  return {
7289
7292
  name: `anyOf(${a.map((t) => t.name).join(", ")})`,
7290
7293
  ...xt(a),
7291
7294
  evaluate: (t) => a.some((e) => e.evaluate(t))
7292
7295
  };
7293
7296
  }
7294
- function Ys(a) {
7297
+ function Qs(a) {
7295
7298
  return a.kind === "spawn" && a.onSpawned !== void 0 ? { kind: "spawn", components: a.components } : a;
7296
7299
  }
7297
- class ln {
7300
+ class un {
7298
7301
  /** Session seed, echoed into the produced {@link CommandLog}. */
7299
7302
  seed;
7300
7303
  _startup = [];
@@ -7315,7 +7318,7 @@ class ln {
7315
7318
  this._ticks.push({ tick: t, dt: e, commands: n }), this.sink = n;
7316
7319
  }
7317
7320
  record = (t) => {
7318
- this.sink.push(Ys(t));
7321
+ this.sink.push(Qs(t));
7319
7322
  };
7320
7323
  /** A live {@link CommandLog} view over the accumulated stream — not a copy.
7321
7324
  * Serialize it (which deep-copies through JSON) before mutating the world
@@ -7334,7 +7337,7 @@ class ln {
7334
7337
  }
7335
7338
  }
7336
7339
  const Z = "__component_def";
7337
- function un(a) {
7340
+ function dn(a) {
7338
7341
  return JSON.stringify(a, (t, e) => {
7339
7342
  if (typeof e == "function" && "id" in e)
7340
7343
  return { [Z]: e.id };
@@ -7346,10 +7349,10 @@ function un(a) {
7346
7349
  return e;
7347
7350
  });
7348
7351
  }
7349
- function dn(a) {
7352
+ function fn(a) {
7350
7353
  return JSON.parse(a, (t, e) => e !== null && typeof e == "object" && Z in e ? he(oe(e[Z])) : e);
7351
7354
  }
7352
- function fn(a, t, e, s) {
7355
+ function pn(a, t, e, s) {
7353
7356
  for (const i of e.startup) t.push(i);
7354
7357
  a.startup();
7355
7358
  const n = s?.hash ?? a.snapshots.deterministic, r = [];
@@ -7362,7 +7365,7 @@ function fn(a, t, e, s) {
7362
7365
  function wt(a) {
7363
7366
  return a.name ?? `system#${a.id}`;
7364
7367
  }
7365
- class pn {
7368
+ class _n {
7366
7369
  _frames = [];
7367
7370
  _current = null;
7368
7371
  tickBegin(t, e) {
@@ -7427,7 +7430,7 @@ function G(a, t) {
7427
7430
  );
7428
7431
  return t;
7429
7432
  }
7430
- function Qs(a) {
7433
+ function Ks(a) {
7431
7434
  if (!Number.isInteger(a) || a < 0)
7432
7435
  throw new v(
7433
7436
  b.INVALID_FRAME_STEP,
@@ -7435,7 +7438,7 @@ function Qs(a) {
7435
7438
  );
7436
7439
  return a;
7437
7440
  }
7438
- class _n {
7441
+ class gn {
7439
7442
  ecs;
7440
7443
  requestFrame;
7441
7444
  cancelFrame;
@@ -7470,7 +7473,7 @@ class _n {
7470
7473
  }
7471
7474
  /** Advance several fixed-size frames, useful for replaying a paused sim. */
7472
7475
  stepFrames(t, e = this._fixedDt) {
7473
- Qs(t);
7476
+ Ks(t);
7474
7477
  const s = G("dt", e);
7475
7478
  for (let n = 0; n < t; n++) this.ecs.update(s);
7476
7479
  }
@@ -7504,65 +7507,65 @@ class _n {
7504
7507
  this.lastTimestampMs = t, this.ecs.update(Math.min(G("dt", e), this._maxDt)), this.running && this.scheduleNextFrame();
7505
7508
  };
7506
7509
  }
7507
- function gn(a, t) {
7510
+ function yn(a, t) {
7508
7511
  return a.relations.register({
7509
7512
  exclusive: !0,
7510
7513
  onDeleteTarget: t?.onDeleteTarget ?? "clear"
7511
7514
  });
7512
7515
  }
7513
- function yn(a, t) {
7516
+ function mn(a, t) {
7514
7517
  return a.relations.register({
7515
7518
  exclusive: !0,
7516
7519
  onDeleteTarget: t?.onDeleteTarget ?? "delete"
7517
7520
  });
7518
7521
  }
7519
- function mn(a) {
7522
+ function wn(a) {
7520
7523
  return T(Symbol(a));
7521
7524
  }
7522
- const wn = "0.5.2";
7525
+ const En = "0.5.3";
7523
7526
  export {
7524
- bn as ANY_RELATION,
7527
+ Cn as ANY_RELATION,
7525
7528
  U as ChangedQuery,
7526
- Hs as ChunkColumns,
7527
- qs as Commands,
7528
- sn as ECS,
7529
+ Vs as ChunkColumns,
7530
+ js as Commands,
7531
+ nn as ECS,
7529
7532
  v as ECSError,
7530
7533
  k as ECSRestoreError,
7531
7534
  b as ECS_ERROR,
7532
7535
  It as ECS_SNAPSHOT_VERSION,
7533
- _n as FrameStepper,
7534
- pn as FrameTraceRecorder,
7536
+ gn as FrameStepper,
7537
+ _n as FrameTraceRecorder,
7535
7538
  Kt as HIERARCHY_UNBOUNDED,
7536
- Cn as HostCommandQueue,
7537
- ln as HostCommandRecorder,
7539
+ Sn as HostCommandQueue,
7540
+ un as HostCommandRecorder,
7538
7541
  F as Query,
7539
- Vs as QueryBuilder,
7540
- Sn as SCHEDULE,
7541
- xn as SabUnavailableError,
7542
+ qs as QueryBuilder,
7543
+ Rn as SCHEDULE,
7544
+ Mn as SabUnavailableError,
7542
7545
  et as SparseRestoreError,
7543
7546
  Q as StoreRestoreError,
7544
- js as SystemContext,
7545
- wn as VERSION,
7546
- an as allOf,
7547
- cn as anyOf,
7548
- Rn as applyHostCommand,
7549
- Js as bundle,
7550
- dn as deserializeCommandLog,
7551
- tn as eventKey,
7547
+ zs as SystemContext,
7548
+ En as VERSION,
7549
+ cn as allOf,
7550
+ ln as anyOf,
7551
+ In as applyHostCommand,
7552
+ tn as bundle,
7553
+ fn as deserializeCommandLog,
7554
+ en as eventKey,
7552
7555
  w as getEntityIndex,
7553
- In as installHostCommandSeam,
7554
- An as isEcsError,
7555
- hn as not,
7556
- yn as registerChildOf,
7557
- gn as registerIsA,
7558
- fn as replayCommandLog,
7559
- mn as resourceKey,
7560
- rn as runEveryNTicks,
7561
- on as runIfAnyMatch,
7562
- nn as runIfResourceEq,
7563
- un as serializeCommandLog,
7564
- en as signalKey,
7565
- On as spawnEntry,
7566
- kn as systemSet,
7567
- Tn as uninstallHostCommandSeam
7556
+ An as installHostCommandSeam,
7557
+ On as isEcsError,
7558
+ an as not,
7559
+ mn as registerChildOf,
7560
+ yn as registerIsA,
7561
+ pn as replayCommandLog,
7562
+ wn as resourceKey,
7563
+ on as runEveryNTicks,
7564
+ hn as runIfAnyMatch,
7565
+ rn as runIfResourceEq,
7566
+ dn as serializeCommandLog,
7567
+ sn as signalKey,
7568
+ kn as spawnEntry,
7569
+ Tn as systemSet,
7570
+ Dn as uninstallHostCommandSeam
7568
7571
  };