@oasys/oecs 0.5.0 → 0.5.2

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 (80) hide show
  1. package/CHANGELOG.md +108 -1
  2. package/README.md +20 -8
  3. package/dist/core/ecs/archetype.d.cts +3 -3
  4. package/dist/core/ecs/archetype.d.ts +3 -3
  5. package/dist/core/ecs/component.d.cts +25 -0
  6. package/dist/core/ecs/component.d.ts +25 -0
  7. package/dist/core/ecs/component.d.ts.map +1 -1
  8. package/dist/core/ecs/ecs.d.cts +67 -49
  9. package/dist/core/ecs/ecs.d.ts +67 -49
  10. package/dist/core/ecs/ecs.d.ts.map +1 -1
  11. package/dist/core/ecs/entity.d.cts +1 -1
  12. package/dist/core/ecs/entity.d.ts +1 -1
  13. package/dist/core/ecs/facades.d.cts +1 -1
  14. package/dist/core/ecs/facades.d.ts +1 -1
  15. package/dist/core/ecs/host_commands.d.cts +30 -20
  16. package/dist/core/ecs/host_commands.d.ts +30 -20
  17. package/dist/core/ecs/host_commands.d.ts.map +1 -1
  18. package/dist/core/ecs/index.d.cts +3 -3
  19. package/dist/core/ecs/index.d.ts +3 -3
  20. package/dist/core/ecs/index.d.ts.map +1 -1
  21. package/dist/core/ecs/observer.d.cts +1 -1
  22. package/dist/core/ecs/observer.d.ts +1 -1
  23. package/dist/core/ecs/observer.d.ts.map +1 -1
  24. package/dist/core/ecs/query.d.cts +22 -6
  25. package/dist/core/ecs/query.d.ts +22 -6
  26. package/dist/core/ecs/query.d.ts.map +1 -1
  27. package/dist/core/ecs/ref.d.ts.map +1 -1
  28. package/dist/core/ecs/run_condition.d.cts +1 -1
  29. package/dist/core/ecs/run_condition.d.ts +1 -1
  30. package/dist/core/ecs/run_condition.d.ts.map +1 -1
  31. package/dist/core/ecs/store.d.cts +10 -23
  32. package/dist/core/ecs/store.d.ts +10 -23
  33. package/dist/core/ecs/store.d.ts.map +1 -1
  34. package/dist/dev_flag.d.cts +0 -15
  35. package/dist/dev_flag.d.ts +0 -15
  36. package/dist/dev_flag.d.ts.map +1 -1
  37. package/dist/extensions/editor/editor.d.cts +31 -29
  38. package/dist/extensions/editor/editor.d.ts +31 -29
  39. package/dist/extensions/editor/editor.d.ts.map +1 -1
  40. package/dist/extensions/editor/field_handle.d.cts +3 -3
  41. package/dist/extensions/editor/field_handle.d.ts +3 -3
  42. package/dist/extensions/editor/field_handle.d.ts.map +1 -1
  43. package/dist/extensions/editor/index.cjs +1 -1
  44. package/dist/extensions/editor/index.development.cjs +1 -0
  45. package/dist/extensions/editor/index.development.js +239 -0
  46. package/dist/extensions/editor/index.js +53 -51
  47. package/dist/extensions/reactive/index.development.cjs +1 -0
  48. package/dist/extensions/reactive/index.development.js +215 -0
  49. package/dist/extensions/solid/index.development.cjs +1 -0
  50. package/dist/extensions/solid/index.development.js +40 -0
  51. package/dist/{host_commands-i4cAeyL5.js → host_commands-BI8pEmjH.js} +26 -18
  52. package/dist/{host_commands-BF8QMi3c.cjs → host_commands-CxhpzMx9.cjs} +1 -1
  53. package/dist/index.cjs +1 -1
  54. package/dist/index.d.cts +3 -3
  55. package/dist/index.d.ts +3 -3
  56. package/dist/index.d.ts.map +1 -1
  57. package/dist/index.development.cjs +1 -0
  58. package/dist/index.development.js +8116 -0
  59. package/dist/index.js +269 -214
  60. package/dist/internal-BMDgWZbt.js +2485 -0
  61. package/dist/internal-LiTSB_tG.cjs +2 -0
  62. package/dist/internal.cjs +1 -1
  63. package/dist/internal.development.cjs +1 -0
  64. package/dist/internal.development.js +24 -0
  65. package/dist/internal.js +1 -1
  66. package/dist/interop-DqxleBo7.js +18 -0
  67. package/dist/interop-T1HZ-Dpa.cjs +1 -0
  68. package/dist/kernel-Cz2Kxlwl.js +240 -0
  69. package/dist/kernel-sw7ScKWu.cjs +1 -0
  70. package/dist/primitives.development.cjs +1 -0
  71. package/dist/primitives.development.js +45 -0
  72. package/dist/reactive/index.development.cjs +1 -0
  73. package/dist/reactive/index.development.js +18 -0
  74. package/dist/shallow-9S1pY_Iw.js +159 -0
  75. package/dist/shallow-C5YmTbtb.cjs +1 -0
  76. package/dist/shared.development.cjs +1 -0
  77. package/dist/shared.development.js +7 -0
  78. package/dist/version.d.cts +1 -1
  79. package/dist/version.d.ts +1 -1
  80. package/package.json +31 -2
@@ -1,11 +1,11 @@
1
- function a(r, t, e) {
1
+ function o(r, t, e) {
2
2
  return `${r}:${t.id}:${e}`;
3
3
  }
4
- const d = /* @__PURE__ */ new WeakMap();
4
+ const a = /* @__PURE__ */ new WeakMap();
5
5
  class h {
6
6
  /** @internal */
7
7
  constructor(t, e) {
8
- this.readField = t, this.shadow = e, d.set(this, { forward: [], inverse: [] });
8
+ this.readField = t, this.shadow = e, a.set(this, { forward: [], inverse: [] });
9
9
  }
10
10
  /** Values staged by THIS build, layered over the editor's shared shadow. Kept
11
11
  * transaction-local so an aborted build (the callback throws before commit)
@@ -14,62 +14,64 @@ class h {
14
14
  * held. The one merge point into the shared shadow is commit's `applyShadow`. */
15
15
  staged = /* @__PURE__ */ new Map();
16
16
  get _txn() {
17
- return d.get(this);
17
+ return a.get(this);
18
18
  }
19
19
  spawn(t, e) {
20
- const n = {
20
+ const s = {
21
21
  kind: "despawn",
22
22
  eid: 0
23
23
  };
24
- return this._txn.inverse.push(n), this._txn.forward.push({
24
+ return this._txn.inverse.push(s), this._txn.forward.push({
25
25
  kind: "spawn",
26
26
  components: t,
27
- onSpawned: (s) => {
28
- n.eid = s, e?.(s);
27
+ onSpawned: (n) => {
28
+ s.eid = n, e?.(n);
29
29
  }
30
30
  }), this;
31
31
  }
32
32
  despawn(t, e) {
33
- const n = { kind: "despawn", eid: t };
34
- return this._txn.forward.push(n), this._txn.inverse.push({
33
+ const s = { kind: "despawn", eid: t };
34
+ return this._txn.forward.push(s), this._txn.inverse.push({
35
35
  kind: "spawn",
36
36
  components: e,
37
- onSpawned: (s) => {
38
- n.eid = s;
37
+ onSpawned: (n) => {
38
+ s.eid = n;
39
39
  }
40
40
  }), this;
41
41
  }
42
42
  /**
43
- * Set `field` of `def` on `eid` to `value`. Inverse: set it back to the value
43
+ * Set `field` of `def` on `entityId` to `value`. Inverse: set it back to the value
44
44
  * this edit replaced — read from the staged overlay / shadow (so stacked edits,
45
45
  * within one build or before a commit, invert correctly) or, failing that, the
46
46
  * read channel (`0` if unknown).
47
47
  */
48
- setField(t, e, n, s) {
49
- const i = a(t, e, n), o = this.staged.get(i) ?? this.shadow.get(i) ?? this.readField(t, e, n) ?? 0;
50
- return this.staged.set(i, s), this._txn.forward.push({ kind: "set_field", eid: t, def: e, field: n, value: s }), this._txn.inverse.push({ kind: "set_field", eid: t, def: e, field: n, value: o }), this;
48
+ setField(t, e, s, n) {
49
+ const i = o(t, e, s), d = this.staged.get(i) ?? this.shadow.get(i) ?? this.readField(t, e, s) ?? 0;
50
+ return this.staged.set(i, n), this._txn.forward.push({ kind: "set_field", eid: t, def: e, field: s, value: n }), this._txn.inverse.push({ kind: "set_field", eid: t, def: e, field: s, value: d }), this;
51
51
  }
52
- /** Add `def` (with complete `values`) to `eid`. Inverse: remove it. */
53
- addComponent(t, e, n) {
54
- return this._txn.forward.push({ kind: "add_component", eid: t, def: e, values: n }), this._txn.inverse.push({ kind: "remove_component", eid: t, def: e }), this;
52
+ /** Attach `def` (with complete `values`) to `entityId`. Inverse: remove it.
53
+ * Bare `add` — the namespaced-handle grammar (matches `ctx.commands.add` and
54
+ * the queue's `add`), not `addComponent`. */
55
+ add(t, e, s) {
56
+ return this._txn.forward.push({ kind: "add_component", eid: t, def: e, values: s }), this._txn.inverse.push({ kind: "remove_component", eid: t, def: e }), this;
55
57
  }
56
58
  /**
57
- * Remove `def` from `eid`. Inverse: re-add it from `restore` (the field values
58
- * to recreate — read them from the channel before removing).
59
+ * Detach `def` from `entityId`. Inverse: re-add it from `restore` (the field values
60
+ * to recreate — read them from the channel before removing). Bare `remove` — see `add`.
59
61
  */
60
- removeComponent(t, e, n) {
62
+ remove(t, e, s) {
61
63
  return this._txn.forward.push({ kind: "remove_component", eid: t, def: e }), this._txn.inverse.push({
62
64
  kind: "add_component",
63
65
  eid: t,
64
66
  def: e,
65
- values: n
67
+ values: s
66
68
  }), this;
67
69
  }
68
- /** Disable `eid`. Inverse: enable it. */
70
+ /** Disable `entityId`. Inverse: enable it. */
69
71
  disable(t) {
70
72
  return this._txn.forward.push({ kind: "disable", eid: t }), this._txn.inverse.push({ kind: "enable", eid: t }), this;
71
73
  }
72
- /** Enable `eid`. Inverse: disable it. */
74
+ /** Enable `entityId`. Inverse: disable it. */
73
75
  enable(t) {
74
76
  return this._txn.forward.push({ kind: "enable", eid: t }), this._txn.inverse.push({ kind: "disable", eid: t }), this;
75
77
  }
@@ -91,31 +93,31 @@ class u {
91
93
  */
92
94
  transaction(t) {
93
95
  const e = new h(this.readField, this.shadow);
94
- return t(e), this.commit(d.get(e));
96
+ return t(e), this.commit(a.get(e));
95
97
  }
96
98
  spawn(t, e) {
97
- return this.transaction((n) => n.spawn(t, e));
99
+ return this.transaction((s) => s.spawn(t, e));
98
100
  }
99
101
  despawn(t, e) {
100
- return this.transaction((n) => n.despawn(t, e));
102
+ return this.transaction((s) => s.despawn(t, e));
101
103
  }
102
104
  /** Set one field as its own undo entry. */
103
- setField(t, e, n, s) {
104
- return this.transaction((i) => i.setField(t, e, n, s));
105
+ setField(t, e, s, n) {
106
+ return this.transaction((i) => i.setField(t, e, s, n));
105
107
  }
106
- /** Add a component as its own undo entry. */
107
- addComponent(t, e, n) {
108
- return this.transaction((s) => s.addComponent(t, e, n));
108
+ /** Attach a component as its own undo entry. Bare `add` (see `TransactionBuilder.add`). */
109
+ add(t, e, s) {
110
+ return this.transaction((n) => n.add(t, e, s));
109
111
  }
110
- /** Remove a component as its own undo entry; `restore` re-adds it on undo. */
111
- removeComponent(t, e, n) {
112
- return this.transaction((s) => s.removeComponent(t, e, n));
112
+ /** Detach a component as its own undo entry; `restore` re-adds it on undo. Bare `remove`. */
113
+ remove(t, e, s) {
114
+ return this.transaction((n) => n.remove(t, e, s));
113
115
  }
114
- /** Disable `eid` as its own undo entry. */
116
+ /** Disable `entityId` as its own undo entry. */
115
117
  disable(t) {
116
118
  return this.transaction((e) => e.disable(t));
117
119
  }
118
- /** Enable `eid` as its own undo entry. */
120
+ /** Enable `entityId` as its own undo entry. */
119
121
  enable(t) {
120
122
  return this.transaction((e) => e.enable(t));
121
123
  }
@@ -128,7 +130,7 @@ class u {
128
130
  const t = this.undoStack.pop();
129
131
  if (t === void 0) return !1;
130
132
  const e = t.inverse.slice().reverse();
131
- for (const n of e) this.queue.push(n);
133
+ for (const s of e) this.queue.push(s);
132
134
  return this.applyShadow(e), this.redoStack.push(t), this.notify(), !0;
133
135
  }
134
136
  /**
@@ -177,8 +179,8 @@ class u {
177
179
  /** Read one committed `(entity, component, field)` slot through the reader
178
180
  * this editor was constructed with — the default read for `fieldHandle`
179
181
  * when no channel thunk is supplied (M11). */
180
- committedField(t, e, n) {
181
- return this.readField(t, e, n);
182
+ committedField(t, e, s) {
183
+ return this.readField(t, e, s);
182
184
  }
183
185
  /**
184
186
  * The pending value the editor believes for a field that the committed read
@@ -195,12 +197,12 @@ class u {
195
197
  * the next edit to the slot. `value` (the read channel) is always the source of
196
198
  * truth; `pending` is only the optimistic bridge.
197
199
  */
198
- pendingField(t, e, n) {
199
- const s = a(t, e, n), i = this.shadow.get(s);
200
+ pendingField(t, e, s) {
201
+ const n = o(t, e, s), i = this.shadow.get(n);
200
202
  if (i === void 0) return;
201
- const o = this.readField(t, e, n);
202
- if (o === i || o === void 0) {
203
- this.shadow.delete(s);
203
+ const d = this.readField(t, e, s);
204
+ if (d === i || d === void 0) {
205
+ this.shadow.delete(n);
204
206
  return;
205
207
  }
206
208
  return i;
@@ -214,19 +216,19 @@ class u {
214
216
  /** Keep the setField shadow in step with the commands just enqueued. */
215
217
  applyShadow(t) {
216
218
  for (const e of t)
217
- e.kind === "set_field" && this.shadow.set(a(e.eid, e.def, e.field), e.value);
219
+ e.kind === "set_field" && this.shadow.set(o(e.eid, e.def, e.field), e.value);
218
220
  }
219
221
  }
220
- function c(r, t, e, n, s) {
222
+ function c(r, t, e, s, n) {
221
223
  return {
222
224
  get value() {
223
- return s !== void 0 ? s() : r.committedField(t, e, n);
225
+ return n !== void 0 ? n() : r.committedField(t, e, s);
224
226
  },
225
227
  set(i) {
226
- r.setField(t, e, n, i);
228
+ r.setField(t, e, s, i);
227
229
  },
228
230
  get pending() {
229
- return r.pendingField(t, e, n);
231
+ return r.pendingField(t, e, s);
230
232
  }
231
233
  };
232
234
  }
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../../kernel-sw7ScKWu.cjs"),_=require("../../shallow-C5YmTbtb.cjs");class w{constructor(n){this.def=n}_ctx;_eid=0;get eid(){return this._eid}field(n){return this._ctx.getField(this._eid,this.def,n)}}class m{constructor(n){this.def=n}_eid=0;_row=0;cols=new Map;arch;bind(n){this.arch=n,this.cols.clear()}get eid(){return this._eid}field(n){let s=this.cols.get(n);return s===void 0&&(s=this.arch.getColumnRead(this.def,n),this.cols.set(n,s)),s[this._row]}}class v{_ctx;_eid=0;get eid(){return this._eid}field(n,s){return this._ctx.getField(this._eid,n,s)}}function p(l,n,s,r={}){const c=_.reactiveMap(r.eq),a={...r.access,reads:[n,...r.access?.reads??[]]},h=r.grain??"entity",u=r.seedExisting??!0,b=new w(n),y=(i,o)=>{o.isDisabled(i)||(b._ctx=o,b._eid=i,c.set(i,s(b)))};let g;return f.batch(()=>{if(h==="column"){const i=new m(n);g=l.observe(n,{granularity:"archetype",onSet:o=>{i.bind(o);const t=o.entityIds;for(let e=0;e<o.entityCount;e++)i._row=e,i._eid=t[e],c.set(i._eid,s(i))},onAdd:(o,t)=>y(o,t),onRemove:o=>c.delete(o),onDisable:o=>c.delete(o),onEnable:(o,t)=>y(o,t),access:a,yieldExisting:u})}else g=l.observe(n,{granularity:"entity",onSet:(i,o)=>y(i,o),onAdd:(i,o)=>y(i,o),onRemove:i=>c.delete(i),onDisable:i=>c.delete(i),onEnable:(i,o)=>y(i,o),access:a,yieldExisting:u})}),{map:c,dispose:()=>g.dispose()}}function E(l,n,s,r={}){return p(l,n,a=>{const h={};for(let u=0;u<s.length;u++)h[s[u]]=a.field(s[u]);return h},{...r,eq:_.shallow})}function S(l,n,s,r={}){const c=n,a=_.reactiveMap(r.eq),h={...r.access,reads:[...c,...r.access?.reads??[]]},u=r.seedExisting??!0,b=new v,y=(t,e)=>{for(let d=0;d<c.length;d++)if(!t.hasComponent(e,c[d]))return!1;return!0},g=(t,e)=>{e.isDisabled(t)||y(e,t)&&(b._ctx=e,b._eid=t,a.set(t,s(b)))},i=t=>{a.delete(t)};let o;return f.batch(()=>{o=c.map(t=>l.observe(t,{granularity:"entity",onSet:g,onAdd:g,onRemove:i,onDisable:i,onEnable:g,access:h,yieldExisting:u}))}),{map:a,dispose:()=>{for(let t=0;t<o.length;t++)o[t].dispose()}}}function R(l,n,s,r,c={}){const a={};for(let e=0;e<r.length;e++)a[r[e]]=0;const[h,u]=c.into??_.reactiveStruct(a,c.eq),b=f.untrack(()=>r.map(e=>h[e])),y={...c.access,reads:[n,...c.access?.reads??[]]},g=c.seedExisting??!0,i=e=>{for(let d=0;d<r.length;d++)u[r[d]](e.getField(s,n,r[d]))},o=()=>{for(let e=0;e<r.length;e++)u[r[e]](b[e])};let t;return f.batch(()=>{t=l.observe(n,{granularity:"entity",onSet:(e,d)=>{e===s&&i(d)},onAdd:(e,d)=>{e===s&&!d.isDisabled(s)&&i(d)},onRemove:e=>{e===s&&o()},onDisable:e=>{e===s&&o()},onEnable:(e,d)=>{e===s&&i(d)},access:y,yieldExisting:g})}),{struct:h,dispose:()=>t.dispose()}}function T(l,n,s,r,c={}){const a=c.into??_.reactiveArray(new Array(r.length).fill(0),c.eq),h=f.untrack(()=>a.snapshot());if(c.into!==void 0&&h.length!==r.length)throw new Error(`syncSingletonToArray: into.length (${h.length}) must equal fields.length (${r.length})`);const u={...c.access,reads:[n,...c.access?.reads??[]]},b=c.seedExisting??!0,y=new Array(r.length),g=t=>{for(let e=0;e<r.length;e++)y[e]=t.getField(s,n,r[e]);a.reconcile(y)},i=()=>a.reconcile(h);let o;return f.batch(()=>{o=l.observe(n,{granularity:"entity",onSet:(t,e)=>{t===s&&g(e)},onAdd:(t,e)=>{t===s&&!e.isDisabled(s)&&g(e)},onRemove:t=>{t===s&&i()},onDisable:t=>{t===s&&i()},onEnable:(t,e)=>{t===s&&g(e)},access:u,yieldExisting:b})}),{array:a,dispose:()=>o.dispose()}}function x(l,n){f.batch(()=>l.update(n))}exports.shallow=_.shallow;exports.batchedUpdate=x;exports.syncComponentToMap=p;exports.syncFieldsToMap=E;exports.syncJoinToMap=S;exports.syncSingletonToArray=T;exports.syncSingletonToStruct=R;
@@ -0,0 +1,215 @@
1
+ import { b as f, u as _ } from "../../kernel-Cz2Kxlwl.js";
2
+ import { r as m, s as E, a as p, b as w } from "../../shallow-9S1pY_Iw.js";
3
+ class v {
4
+ constructor(n) {
5
+ this.def = n;
6
+ }
7
+ _ctx;
8
+ _eid = 0;
9
+ get eid() {
10
+ return this._eid;
11
+ }
12
+ field(n) {
13
+ return this._ctx.getField(this._eid, this.def, n);
14
+ }
15
+ }
16
+ class R {
17
+ constructor(n) {
18
+ this.def = n;
19
+ }
20
+ _eid = 0;
21
+ _row = 0;
22
+ cols = /* @__PURE__ */ new Map();
23
+ arch;
24
+ /** Bind to an archetype for one dispatch (drops the previous column cache). */
25
+ bind(n) {
26
+ this.arch = n, this.cols.clear();
27
+ }
28
+ get eid() {
29
+ return this._eid;
30
+ }
31
+ field(n) {
32
+ let s = this.cols.get(n);
33
+ return s === void 0 && (s = this.arch.getColumnRead(this.def, n), this.cols.set(n, s)), s[this._row];
34
+ }
35
+ }
36
+ class x {
37
+ _ctx;
38
+ _eid = 0;
39
+ get eid() {
40
+ return this._eid;
41
+ }
42
+ field(n, s) {
43
+ return this._ctx.getField(this._eid, n, s);
44
+ }
45
+ }
46
+ function A(l, n, s, r = {}) {
47
+ const c = m(r.eq), a = {
48
+ ...r.access,
49
+ reads: [n, ...r.access?.reads ?? []]
50
+ }, h = r.grain ?? "entity", u = r.seedExisting ?? !0, b = new v(n), y = (o, i) => {
51
+ i.isDisabled(o) || (b._ctx = i, b._eid = o, c.set(o, s(b)));
52
+ };
53
+ let g;
54
+ return f(() => {
55
+ if (h === "column") {
56
+ const o = new R(n);
57
+ g = l.observe(n, {
58
+ granularity: "archetype",
59
+ onSet: (i) => {
60
+ o.bind(i);
61
+ const t = i.entityIds;
62
+ for (let e = 0; e < i.entityCount; e++)
63
+ o._row = e, o._eid = t[e], c.set(o._eid, s(o));
64
+ },
65
+ onAdd: (i, t) => y(i, t),
66
+ onRemove: (i) => c.delete(i),
67
+ // Disable = soft remove from the channel; enable = re-add (#677). The
68
+ // column sweep is bounded by enabled rows, so a disabled row would never
69
+ // refresh — drop it on disable, republish on enable.
70
+ onDisable: (i) => c.delete(i),
71
+ onEnable: (i, t) => y(i, t),
72
+ access: a,
73
+ yieldExisting: u
74
+ });
75
+ } else
76
+ g = l.observe(n, {
77
+ granularity: "entity",
78
+ onSet: (o, i) => y(o, i),
79
+ onAdd: (o, i) => y(o, i),
80
+ onRemove: (o) => c.delete(o),
81
+ onDisable: (o) => c.delete(o),
82
+ onEnable: (o, i) => y(o, i),
83
+ access: a,
84
+ yieldExisting: u
85
+ });
86
+ }), { map: c, dispose: () => g.dispose() };
87
+ }
88
+ function q(l, n, s, r = {}) {
89
+ return A(l, n, (a) => {
90
+ const h = {};
91
+ for (let u = 0; u < s.length; u++) h[s[u]] = a.field(s[u]);
92
+ return h;
93
+ }, { ...r, eq: E });
94
+ }
95
+ function M(l, n, s, r = {}) {
96
+ const c = n, a = m(r.eq), h = {
97
+ ...r.access,
98
+ reads: [...c, ...r.access?.reads ?? []]
99
+ }, u = r.seedExisting ?? !0, b = new x(), y = (t, e) => {
100
+ for (let d = 0; d < c.length; d++) if (!t.hasComponent(e, c[d])) return !1;
101
+ return !0;
102
+ }, g = (t, e) => {
103
+ e.isDisabled(t) || y(e, t) && (b._ctx = e, b._eid = t, a.set(t, s(b)));
104
+ }, o = (t) => {
105
+ a.delete(t);
106
+ };
107
+ let i;
108
+ return f(() => {
109
+ i = c.map(
110
+ (t) => l.observe(t, {
111
+ granularity: "entity",
112
+ onSet: g,
113
+ onAdd: g,
114
+ onRemove: o,
115
+ // Disabling any joined component soft-removes the entity from the
116
+ // channel; enabling re-evaluates membership and republishes (#677). A
117
+ // disable fires once per carried joined component — `dropRow` is
118
+ // idempotent, and `publishIfMember` re-checks the full join.
119
+ onDisable: o,
120
+ onEnable: g,
121
+ access: h,
122
+ yieldExisting: u
123
+ })
124
+ );
125
+ }), {
126
+ map: a,
127
+ dispose: () => {
128
+ for (let t = 0; t < i.length; t++) i[t].dispose();
129
+ }
130
+ };
131
+ }
132
+ function T(l, n, s, r, c = {}) {
133
+ const a = {};
134
+ for (let e = 0; e < r.length; e++) a[r[e]] = 0;
135
+ const [h, u] = c.into ?? p(a, c.eq), b = _(() => r.map((e) => h[e])), y = {
136
+ ...c.access,
137
+ reads: [n, ...c.access?.reads ?? []]
138
+ }, g = c.seedExisting ?? !0, o = (e) => {
139
+ for (let d = 0; d < r.length; d++) u[r[d]](e.getField(s, n, r[d]));
140
+ }, i = () => {
141
+ for (let e = 0; e < r.length; e++) u[r[e]](b[e]);
142
+ };
143
+ let t;
144
+ return f(() => {
145
+ t = l.observe(n, {
146
+ granularity: "entity",
147
+ onSet: (e, d) => {
148
+ e === s && o(d);
149
+ },
150
+ onAdd: (e, d) => {
151
+ e === s && !d.isDisabled(s) && o(d);
152
+ },
153
+ onRemove: (e) => {
154
+ e === s && i();
155
+ },
156
+ onDisable: (e) => {
157
+ e === s && i();
158
+ },
159
+ onEnable: (e, d) => {
160
+ e === s && o(d);
161
+ },
162
+ access: y,
163
+ yieldExisting: g
164
+ });
165
+ }), { struct: h, dispose: () => t.dispose() };
166
+ }
167
+ function C(l, n, s, r, c = {}) {
168
+ const a = c.into ?? w(new Array(r.length).fill(0), c.eq), h = _(() => a.snapshot());
169
+ if (c.into !== void 0 && h.length !== r.length)
170
+ throw new Error(
171
+ `syncSingletonToArray: into.length (${h.length}) must equal fields.length (${r.length})`
172
+ );
173
+ const u = {
174
+ ...c.access,
175
+ reads: [n, ...c.access?.reads ?? []]
176
+ }, b = c.seedExisting ?? !0, y = new Array(r.length), g = (t) => {
177
+ for (let e = 0; e < r.length; e++) y[e] = t.getField(s, n, r[e]);
178
+ a.reconcile(y);
179
+ }, o = () => a.reconcile(h);
180
+ let i;
181
+ return f(() => {
182
+ i = l.observe(n, {
183
+ granularity: "entity",
184
+ onSet: (t, e) => {
185
+ t === s && g(e);
186
+ },
187
+ onAdd: (t, e) => {
188
+ t === s && !e.isDisabled(s) && g(e);
189
+ },
190
+ onRemove: (t) => {
191
+ t === s && o();
192
+ },
193
+ onDisable: (t) => {
194
+ t === s && o();
195
+ },
196
+ onEnable: (t, e) => {
197
+ t === s && g(e);
198
+ },
199
+ access: u,
200
+ yieldExisting: b
201
+ });
202
+ }), { array: a, dispose: () => i.dispose() };
203
+ }
204
+ function F(l, n) {
205
+ f(() => l.update(n));
206
+ }
207
+ export {
208
+ F as batchedUpdate,
209
+ E as shallow,
210
+ A as syncComponentToMap,
211
+ q as syncFieldsToMap,
212
+ M as syncJoinToMap,
213
+ C as syncSingletonToArray,
214
+ T as syncSingletonToStruct
215
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("solid-js"),i=require("../../interop-T1HZ-Dpa.cjs");function l(e){const[t,o]=u.createSignal(e());return u.onCleanup(i.subscribe(e,s=>o(()=>s))),t}function c(e){return{keys:l(()=>e.keys()),cell:t=>l(()=>e.get(t))}}function f(e){const t={},o=Object.keys(e),s=new Set(o);for(const n of o)t[n]=l(()=>e[n]);return new Proxy({},{get:(n,r)=>s.has(r)?t[r]():Reflect.get(n,r),has:(n,r)=>s.has(r),ownKeys:()=>o,getOwnPropertyDescriptor:(n,r)=>s.has(r)?{get:()=>t[r](),enumerable:!0,configurable:!0}:void 0,set:(n,r)=>{throw new TypeError(`fromKernelStruct view is read-only: write through the kernel struct's setters (set.${String(r)}(value)), not the bridged view`)}})}function a(e){return l(()=>e.snapshot())}exports.fromKernel=l;exports.fromKernelArray=a;exports.fromKernelMap=c;exports.fromKernelStruct=f;
@@ -0,0 +1,40 @@
1
+ import { createSignal as u, onCleanup as c } from "solid-js";
2
+ import { s as f } from "../../interop-DqxleBo7.js";
3
+ function i(e) {
4
+ const [t, o] = u(e());
5
+ return c(f(e, (s) => o(() => s))), t;
6
+ }
7
+ function g(e) {
8
+ return {
9
+ keys: i(() => e.keys()),
10
+ cell: (t) => i(() => e.get(t))
11
+ };
12
+ }
13
+ function h(e) {
14
+ const t = {}, o = Object.keys(e), s = new Set(o);
15
+ for (const n of o)
16
+ t[n] = i(() => e[n]);
17
+ return new Proxy({}, {
18
+ get: (n, r) => s.has(r) ? t[r]() : Reflect.get(n, r),
19
+ has: (n, r) => s.has(r),
20
+ ownKeys: () => o,
21
+ getOwnPropertyDescriptor: (n, r) => s.has(r) ? { get: () => t[r](), enumerable: !0, configurable: !0 } : void 0,
22
+ // Read surface only (`Readonly<T>`, POLISH_AUDIT #8) — mirrors the kernel
23
+ // struct proxy's trap so a JS-side assignment fails loudly instead of
24
+ // sticking a non-reactive value on the hidden target.
25
+ set: (n, r) => {
26
+ throw new TypeError(
27
+ `fromKernelStruct view is read-only: write through the kernel struct's setters (set.${String(r)}(value)), not the bridged view`
28
+ );
29
+ }
30
+ });
31
+ }
32
+ function y(e) {
33
+ return i(() => e.snapshot());
34
+ }
35
+ export {
36
+ i as fromKernel,
37
+ y as fromKernelArray,
38
+ g as fromKernelMap,
39
+ h as fromKernelStruct
40
+ };
@@ -1991,40 +1991,48 @@ function ue(e, t) {
1991
1991
  class _n {
1992
1992
  queued = [];
1993
1993
  spawn(t, n) {
1994
- this.queued.push({ kind: "spawn", components: t, onSpawned: n });
1994
+ return this.queued.push({ kind: "spawn", components: t, onSpawned: n }), this;
1995
1995
  }
1996
1996
  despawn(t) {
1997
- this.queued.push({ kind: "despawn", eid: t });
1998
- }
1999
- addComponent(t, n, r) {
2000
- this.queued.push({ kind: "add_component", eid: t, def: n, values: r });
2001
- }
2002
- removeComponent(t, n) {
2003
- this.queued.push({ kind: "remove_component", eid: t, def: n });
2004
- }
2005
- /** Set `field` of `def` on `eid`. Applied IMMEDIATELY at the drain, unlike the
2006
- * deferred structural ops so `def` must already be on `eid`. Do NOT
2007
- * `addComponent`/`spawn` `def` and `setField` it in the same frame: the add is
1997
+ return this.queued.push({ kind: "despawn", eid: t }), this;
1998
+ }
1999
+ /** Attach `def` (with complete `values`) to `entityId` (deferred to the
2000
+ * drain). The namespaced-handle grammar the queue is a commands buffer, so
2001
+ * it drops the noun (`add`, not `addComponent`), matching `ctx.commands.add`
2002
+ * and the queue's own bare `spawn`/`despawn`/`disable`/`enable`. Values are
2003
+ * complete (transport carries explicit intent per field; see `spawnEntry`),
2004
+ * unlike the authoring-side bundle sugar. */
2005
+ add(t, n, r) {
2006
+ return this.queued.push({ kind: "add_component", eid: t, def: n, values: r }), this;
2007
+ }
2008
+ /** Detach `def` from `entityId` (deferred to the drain). Bare `remove`
2009
+ * matching `ctx.commands.remove` — see `add`. */
2010
+ remove(t, n) {
2011
+ return this.queued.push({ kind: "remove_component", eid: t, def: n }), this;
2012
+ }
2013
+ /** Set `field` of `def` on `entityId`. Applied IMMEDIATELY at the drain, unlike
2014
+ * the deferred structural ops — so `def` must already be on `entityId`. Do NOT
2015
+ * `add`/`spawn` `def` and `setField` it in the same frame: the add is
2008
2016
  * still pending its flush when the immediate set runs (carry the value in
2009
- * `addComponent`/`spawnEntry` instead). `applyHostCommand` throws an
2017
+ * `add`/`spawnEntry` instead). `applyHostCommand` throws an
2010
2018
  * actionable error in `DEV` if you do. */
2011
2019
  setField(t, n, r, s) {
2012
- this.queued.push({ kind: "set_field", eid: t, def: n, field: r, value: s });
2020
+ return this.queued.push({ kind: "set_field", eid: t, def: n, field: r, value: s }), this;
2013
2021
  }
2014
2022
  disable(t) {
2015
- this.queued.push({ kind: "disable", eid: t });
2023
+ return this.queued.push({ kind: "disable", eid: t }), this;
2016
2024
  }
2017
2025
  enable(t) {
2018
- this.queued.push({ kind: "enable", eid: t });
2026
+ return this.queued.push({ kind: "enable", eid: t }), this;
2019
2027
  }
2020
2028
  /** Enqueue a pre-built command. The path for a SAB-ring codec, an editor's
2021
2029
  * reified inverse, or a replay log — all of which produce `HostCommand` data
2022
2030
  * directly rather than calling the typed sugar above. */
2023
2031
  push(t) {
2024
- this.queued.push(t);
2032
+ return this.queued.push(t), this;
2025
2033
  }
2026
2034
  /** Commands buffered but not yet applied. */
2027
- pending() {
2035
+ get pending() {
2028
2036
  return this.queued.length;
2029
2037
  }
2030
2038
  /** Drop every buffered command without applying it (M15) — e.g. abandoning