aiecsjs 0.3.1 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -14
- package/README_ZHTW.md +18 -16
- package/api.json +41 -16
- package/dist/{chunk-37HMYMJG.cjs → chunk-2CF2MNMH.cjs} +2 -2
- package/dist/{chunk-37HMYMJG.cjs.map → chunk-2CF2MNMH.cjs.map} +1 -1
- package/dist/{chunk-4RPFOVQC.cjs → chunk-7NNM4PGP.cjs} +2 -2
- package/dist/{chunk-4RPFOVQC.cjs.map → chunk-7NNM4PGP.cjs.map} +1 -1
- package/dist/{chunk-QOKIEF7C.js → chunk-AW254W5F.js} +2 -2
- package/dist/{chunk-QOKIEF7C.js.map → chunk-AW254W5F.js.map} +1 -1
- package/dist/{chunk-AGHSWLNQ.cjs → chunk-XU3BVVCJ.cjs} +2 -2
- package/dist/{chunk-AGHSWLNQ.cjs.map → chunk-XU3BVVCJ.cjs.map} +1 -1
- package/dist/{chunk-L5CMKMIP.js → chunk-YAHZHZNR.js} +2 -2
- package/dist/{chunk-L5CMKMIP.js.map → chunk-YAHZHZNR.js.map} +1 -1
- package/dist/{chunk-FDXCXNZK.js → chunk-ZNLOJVCV.js} +2 -2
- package/dist/{chunk-FDXCXNZK.js.map → chunk-ZNLOJVCV.js.map} +1 -1
- package/dist/commands.cjs +1 -1
- package/dist/commands.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/observers.cjs +1 -1
- package/dist/observers.js +1 -1
- package/dist/relations.cjs +1 -1
- package/dist/relations.cjs.map +1 -1
- package/dist/relations.d.cts +20 -1
- package/dist/relations.d.ts +20 -1
- package/dist/relations.js +1 -1
- package/dist/relations.js.map +1 -1
- package/dist/serialize.cjs +1 -1
- package/dist/serialize.js +1 -1
- package/dist/worker.cjs +1 -1
- package/dist/worker.js +1 -1
- package/llms-full.txt +58 -27
- package/package.json +11 -12
- package/CHANGELOG.md +0 -275
- package/STABILITY.md +0 -153
- package/STABILITY_ZHTW.md +0 -152
- package/docs/MIGRATION.md +0 -252
- package/docs/MIGRATION_ZHTW.md +0 -252
package/README.md
CHANGED
|
@@ -329,21 +329,22 @@ forEachEntity(world, q, (e) => { cb.remove(e, SomeTag) })
|
|
|
329
329
|
flush(cb)
|
|
330
330
|
```
|
|
331
331
|
|
|
332
|
-
### Relations and hierarchies
|
|
332
|
+
### Relations and hierarchies
|
|
333
333
|
|
|
334
|
-
>
|
|
334
|
+
> The Relations API is **stable since 0.4.0**. The graph API (`defineRelation` / `addRelation` / `removeRelation` / `getRelationTargets` / `getRelationData`) and the built-in `ChildOf` relation are frozen for the 1.x track.
|
|
335
335
|
|
|
336
336
|
```ts
|
|
337
|
-
import { defineRelation, addRelation, ChildOf, getRelationTargets } from 'aiecsjs/relations'
|
|
337
|
+
import { defineRelation, addRelation, ChildOf, getRelationTargets, getRelationData } from 'aiecsjs/relations'
|
|
338
338
|
|
|
339
|
-
const Likes = defineRelation()
|
|
340
|
-
addRelation(world, alice, Likes, bob)
|
|
339
|
+
const Likes = defineRelation<{ since: number }>()
|
|
340
|
+
addRelation(world, alice, Likes, bob, { since: 2020 })
|
|
341
341
|
addRelation(world, alice, ChildOf, parent)
|
|
342
342
|
|
|
343
343
|
const parentOfAlice = getRelationTargets(world, alice, ChildOf)
|
|
344
|
+
const likedSince = getRelationData(world, alice, Likes, bob) // { since: 2020 }
|
|
344
345
|
```
|
|
345
346
|
|
|
346
|
-
|
|
347
|
+
Exclusive relations (one target only) and the `getRelationData` reader are stable as of 0.4.0. Wildcard relation queries and serialisation of relation graphs remain future work and are not part of the frozen surface.
|
|
347
348
|
|
|
348
349
|
## API Reference
|
|
349
350
|
|
|
@@ -467,15 +468,16 @@ const Types = { i8, u8, i16, u16, i32, u32, f32, f64, eid, bool } as const
|
|
|
467
468
|
| `attachWorld` | `(buffer, opts?) => World` | experimental |
|
|
468
469
|
| `detachWorld` | `(world) => void` | experimental |
|
|
469
470
|
|
|
470
|
-
### Relations — `aiecsjs/relations`
|
|
471
|
+
### Relations — `aiecsjs/relations`
|
|
471
472
|
|
|
472
473
|
| Function | Signature | Stability |
|
|
473
474
|
|---|---|---|
|
|
474
|
-
| `defineRelation` | `<T>(opts?) => Relation<T>` |
|
|
475
|
-
| `addRelation` | `(world, src, rel, tgt, data?) => void` |
|
|
476
|
-
| `removeRelation` | `(world, src, rel, tgt) => void` |
|
|
477
|
-
| `getRelationTargets` | `(world, src, rel) => readonly EntityId[]` |
|
|
478
|
-
| `
|
|
475
|
+
| `defineRelation` | `<T>(opts?) => Relation<T>` | stable |
|
|
476
|
+
| `addRelation` | `(world, src, rel, tgt, data?) => void` | stable |
|
|
477
|
+
| `removeRelation` | `(world, src, rel, tgt) => void` | stable |
|
|
478
|
+
| `getRelationTargets` | `(world, src, rel) => readonly EntityId[]` | stable |
|
|
479
|
+
| `getRelationData` | `<T>(world, src, rel, tgt) => T \| undefined` | stable (since 0.4.0) |
|
|
480
|
+
| `ChildOf` (constant) | `Relation` | stable |
|
|
479
481
|
|
|
480
482
|
### Utility — `aiecsjs`
|
|
481
483
|
|
|
@@ -852,7 +854,7 @@ if (VERSION.startsWith('0.')) {
|
|
|
852
854
|
|
|
853
855
|
### Stability contract
|
|
854
856
|
|
|
855
|
-
See [`STABILITY.md`](./STABILITY.md). In short: imports from `aiecsjs` (root) are **stable** within 0.x minors.
|
|
857
|
+
See [`STABILITY.md`](./STABILITY.md). In short: imports from `aiecsjs` (root) are **stable** within 0.x minors. `aiecsjs/relations` is **stable** since 0.4.0; `aiecsjs/worker` is **experimental**. Anything in `aiecsjs/internal` is **internal** — do not import.
|
|
856
858
|
|
|
857
859
|
### Telemetry / privacy
|
|
858
860
|
|
|
@@ -897,7 +899,7 @@ A: It will be on first stable publish. Until then, the docs are the contract.
|
|
|
897
899
|
|
|
898
900
|
- **Max entity count** is capped by `indexBits` × `generationBits`. Default 24 + 8 = 16M entities × 256 recycles.
|
|
899
901
|
- **No automatic system scheduler / parallel execution** in 0.1. Systems run in `pipe()` order on one thread (you can launch additional workers manually).
|
|
900
|
-
- **Relations API is
|
|
902
|
+
- **Relations API (`aiecsjs/relations`) is stable since 0.4.0.** Wildcard relation queries and relation-graph serialisation remain future work.
|
|
901
903
|
- **AoS components** not SAB-shareable across workers.
|
|
902
904
|
- **Network delta serializer** wire format is experimental in 0.1; may change.
|
|
903
905
|
- **WebGPU integration is one-way** (CPU → GPU). No compute-shader system generation.
|
package/README_ZHTW.md
CHANGED
|
@@ -336,25 +336,26 @@ forEachEntity(world, q, (e) => { cb.remove(e, SomeTag) })
|
|
|
336
336
|
flush(cb)
|
|
337
337
|
```
|
|
338
338
|
|
|
339
|
-
### Relations
|
|
339
|
+
### Relations 與階層
|
|
340
340
|
|
|
341
|
-
>
|
|
341
|
+
> Relations API **自 0.4.0 起穩定(stable)**。graph API(`defineRelation` / `addRelation` / `removeRelation` / `getRelationTargets` / `getRelationData`)與內建的 `ChildOf` relation 已凍結至 1.x 軌道。
|
|
342
342
|
|
|
343
343
|
```ts
|
|
344
|
-
import { defineRelation, addRelation, ChildOf, getRelationTargets } from 'aiecsjs/relations'
|
|
344
|
+
import { defineRelation, addRelation, ChildOf, getRelationTargets, getRelationData } from 'aiecsjs/relations'
|
|
345
345
|
|
|
346
|
-
const Likes = defineRelation()
|
|
347
|
-
addRelation(world, alice, Likes, bob)
|
|
346
|
+
const Likes = defineRelation<{ since: number }>()
|
|
347
|
+
addRelation(world, alice, Likes, bob, { since: 2020 })
|
|
348
348
|
addRelation(world, alice, ChildOf, parent)
|
|
349
349
|
|
|
350
350
|
const parentOfAlice = getRelationTargets(world, alice, ChildOf)
|
|
351
|
+
const likedSince = getRelationData(world, alice, Likes, bob) // { since: 2020 }
|
|
351
352
|
```
|
|
352
353
|
|
|
353
|
-
|
|
354
|
+
獨佔關係(exclusive,只允許一個目標)與 `getRelationData` 讀取器自 0.4.0 起穩定。wildcard relation 查詢與關係圖序列化仍屬未來工作,不在凍結表面內。
|
|
354
355
|
|
|
355
356
|
## API 參考
|
|
356
357
|
|
|
357
|
-
完整機器可讀表面在 [`api.json`](./api.json)。各 export 穩定度在 [`STABILITY.md`](./STABILITY.md)
|
|
358
|
+
完整機器可讀表面在 [`api.json`](./api.json)。各 export 穩定度在 [`STABILITY.md`](./STABILITY.md)。
|
|
358
359
|
|
|
359
360
|
### World — `aiecsjs`
|
|
360
361
|
|
|
@@ -474,15 +475,16 @@ const Types = { i8, u8, i16, u16, i32, u32, f32, f64, eid, bool } as const
|
|
|
474
475
|
| `attachWorld` | `(buffer, opts?) => World` | experimental |
|
|
475
476
|
| `detachWorld` | `(world) => void` | experimental |
|
|
476
477
|
|
|
477
|
-
### Relations — `aiecsjs/relations
|
|
478
|
+
### Relations — `aiecsjs/relations`
|
|
478
479
|
|
|
479
480
|
| 函式 | Signature | 穩定度 |
|
|
480
481
|
|---|---|---|
|
|
481
|
-
| `defineRelation` | `<T>(opts?) => Relation<T>` |
|
|
482
|
-
| `addRelation` | `(world, src, rel, tgt, data?) => void` |
|
|
483
|
-
| `removeRelation` | `(world, src, rel, tgt) => void` |
|
|
484
|
-
| `getRelationTargets` | `(world, src, rel) => readonly EntityId[]` |
|
|
485
|
-
| `
|
|
482
|
+
| `defineRelation` | `<T>(opts?) => Relation<T>` | stable |
|
|
483
|
+
| `addRelation` | `(world, src, rel, tgt, data?) => void` | stable |
|
|
484
|
+
| `removeRelation` | `(world, src, rel, tgt) => void` | stable |
|
|
485
|
+
| `getRelationTargets` | `(world, src, rel) => readonly EntityId[]` | stable |
|
|
486
|
+
| `getRelationData` | `<T>(world, src, rel, tgt) => T \| undefined` | stable(自 0.4.0) |
|
|
487
|
+
| `ChildOf`(常數) | `Relation` | stable |
|
|
486
488
|
|
|
487
489
|
### 工具 — `aiecsjs`
|
|
488
490
|
|
|
@@ -861,7 +863,7 @@ if (VERSION.startsWith('0.')) {
|
|
|
861
863
|
|
|
862
864
|
### 穩定度契約
|
|
863
865
|
|
|
864
|
-
請見 [`
|
|
866
|
+
請見 [`STABILITY.md`](./STABILITY.md)。簡言之:從 `aiecsjs`(根目錄)匯入者在 0.x minor 內為 **stable**。`aiecsjs/relations` 自 0.4.0 起為 **stable**;`aiecsjs/worker` 仍為 **experimental**。任何 `aiecsjs/internal` 內的東西為 **internal**,請勿引用。
|
|
865
867
|
|
|
866
868
|
### 遙測 / 隱私
|
|
867
869
|
|
|
@@ -906,7 +908,7 @@ A:將在首次穩定發佈時上架。在那之前,文件即契約。
|
|
|
906
908
|
|
|
907
909
|
- **最大實體數** 由 `indexBits` × `generationBits` 決定。預設 24 + 8 = 16M 實體 × 各 256 次回收。
|
|
908
910
|
- **0.1 沒有自動系統排程器 / 平行執行**。系統以 `pipe()` 順序在單執行緒執行(你可以自行啟動更多 worker)。
|
|
909
|
-
- **Relations API
|
|
911
|
+
- **Relations API(`aiecsjs/relations`)自 0.4.0 起穩定。** wildcard relation 查詢與關係圖序列化仍屬未來工作。
|
|
910
912
|
- **AoS 元件** 無法跨 Worker 透過 SAB 共享。
|
|
911
913
|
- **網路 delta 序列器** wire format 在 0.1 為 experimental,可能改變。
|
|
912
914
|
- **WebGPU 整合為單向**(CPU → GPU)。無 compute-shader 系統生成。
|
|
@@ -918,7 +920,7 @@ aiecsjs 主要由 AI 生成、單一作者維護。問題回報與小型 PR 歡
|
|
|
918
920
|
|
|
919
921
|
## 變更紀錄
|
|
920
922
|
|
|
921
|
-
請見 [`CHANGELOG.md`](./CHANGELOG.md)
|
|
923
|
+
請見 [`CHANGELOG.md`](./CHANGELOG.md)。
|
|
922
924
|
|
|
923
925
|
## 授權
|
|
924
926
|
|
package/api.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://yshengliao.github.io/aiecsjs/api-schema.json",
|
|
3
3
|
"name": "aiecsjs",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.4.1",
|
|
5
5
|
"generated": "2026-05-29",
|
|
6
6
|
"stability": "experimental",
|
|
7
7
|
"license": "MIT",
|
|
@@ -84,13 +84,14 @@
|
|
|
84
84
|
},
|
|
85
85
|
{
|
|
86
86
|
"name": "aiecsjs/relations",
|
|
87
|
-
"description": "Entity relations and hierarchies
|
|
87
|
+
"description": "Entity relations and hierarchies. Stable since 0.4.0; the graph API and built-in ChildOf relation are frozen for the 1.x track.",
|
|
88
88
|
"exports": [
|
|
89
89
|
"defineRelation",
|
|
90
90
|
"addRelation",
|
|
91
91
|
"removeRelation",
|
|
92
92
|
"getRelationTargets",
|
|
93
|
-
"ChildOf"
|
|
93
|
+
"ChildOf",
|
|
94
|
+
"getRelationData"
|
|
94
95
|
]
|
|
95
96
|
}
|
|
96
97
|
],
|
|
@@ -1184,11 +1185,11 @@
|
|
|
1184
1185
|
"name": "defineRelation",
|
|
1185
1186
|
"kind": "function",
|
|
1186
1187
|
"module": "aiecsjs/relations",
|
|
1187
|
-
"since": "0.
|
|
1188
|
-
"stability": "
|
|
1188
|
+
"since": "0.1.0",
|
|
1189
|
+
"stability": "stable",
|
|
1189
1190
|
"deprecated": false,
|
|
1190
1191
|
"signature": "function defineRelation<T = void>(options?: { exclusive?: boolean }): Relation<T>",
|
|
1191
|
-
"summary": "Declare a relation type between two entities.
|
|
1192
|
+
"summary": "Declare a relation type between two entities. Pass `exclusive: true` for one-to-one relations (e.g. ChildOf).",
|
|
1192
1193
|
"params": [
|
|
1193
1194
|
{
|
|
1194
1195
|
"name": "options",
|
|
@@ -1210,8 +1211,8 @@
|
|
|
1210
1211
|
"name": "addRelation",
|
|
1211
1212
|
"kind": "function",
|
|
1212
1213
|
"module": "aiecsjs/relations",
|
|
1213
|
-
"since": "0.
|
|
1214
|
-
"stability": "
|
|
1214
|
+
"since": "0.1.0",
|
|
1215
|
+
"stability": "stable",
|
|
1215
1216
|
"deprecated": false,
|
|
1216
1217
|
"signature": "function addRelation<T>(world: World, source: EntityId, rel: Relation<T>, target: EntityId, data?: T): void",
|
|
1217
1218
|
"summary": "Add a relation edge from source to target.",
|
|
@@ -1229,8 +1230,8 @@
|
|
|
1229
1230
|
"name": "removeRelation",
|
|
1230
1231
|
"kind": "function",
|
|
1231
1232
|
"module": "aiecsjs/relations",
|
|
1232
|
-
"since": "0.
|
|
1233
|
-
"stability": "
|
|
1233
|
+
"since": "0.1.0",
|
|
1234
|
+
"stability": "stable",
|
|
1234
1235
|
"deprecated": false,
|
|
1235
1236
|
"signature": "function removeRelation(world: World, source: EntityId, rel: Relation, target: EntityId): void",
|
|
1236
1237
|
"summary": "Remove a single relation edge.",
|
|
@@ -1243,15 +1244,39 @@
|
|
|
1243
1244
|
"name": "getRelationTargets",
|
|
1244
1245
|
"kind": "function",
|
|
1245
1246
|
"module": "aiecsjs/relations",
|
|
1246
|
-
"since": "0.
|
|
1247
|
-
"stability": "
|
|
1247
|
+
"since": "0.1.0",
|
|
1248
|
+
"stability": "stable",
|
|
1248
1249
|
"deprecated": false,
|
|
1249
1250
|
"signature": "function getRelationTargets(world: World, source: EntityId, rel: Relation): readonly EntityId[]",
|
|
1250
1251
|
"summary": "Enumerate targets reachable from source by this relation.",
|
|
1251
1252
|
"params": [],
|
|
1252
1253
|
"returns": { "type": "readonly EntityId[]", "description": "Target entity IDs." },
|
|
1253
1254
|
"examples": [],
|
|
1254
|
-
"seeAlso": ["defineRelation"]
|
|
1255
|
+
"seeAlso": ["defineRelation", "getRelationData"]
|
|
1256
|
+
},
|
|
1257
|
+
{
|
|
1258
|
+
"name": "getRelationData",
|
|
1259
|
+
"kind": "function",
|
|
1260
|
+
"module": "aiecsjs/relations",
|
|
1261
|
+
"since": "0.4.0",
|
|
1262
|
+
"stability": "stable",
|
|
1263
|
+
"deprecated": false,
|
|
1264
|
+
"signature": "function getRelationData<T>(world: World, source: EntityId, rel: Relation<T>, target: EntityId): T | undefined",
|
|
1265
|
+
"summary": "Read the data payload attached to a relation edge. Returns the value passed as `data` to `addRelation`, or `undefined` if no such edge exists or no data was stored. Subject to raw slot-keying: edges are keyed by slot index, not generation; validate liveness with `entityExists` if slot recycling is a concern.",
|
|
1266
|
+
"params": [
|
|
1267
|
+
{ "name": "world", "type": "World", "optional": false, "description": "Target world." },
|
|
1268
|
+
{ "name": "source", "type": "EntityId", "optional": false, "description": "Source entity." },
|
|
1269
|
+
{ "name": "rel", "type": "Relation<T>", "optional": false, "description": "Relation handle." },
|
|
1270
|
+
{ "name": "target", "type": "EntityId", "optional": false, "description": "Target entity." }
|
|
1271
|
+
],
|
|
1272
|
+
"returns": { "type": "T | undefined", "description": "Data payload, or undefined." },
|
|
1273
|
+
"examples": [
|
|
1274
|
+
{
|
|
1275
|
+
"title": "Read relation payload",
|
|
1276
|
+
"code": "const data = getRelationData(world, alice, Likes, bob) // { since: 2024 } or undefined"
|
|
1277
|
+
}
|
|
1278
|
+
],
|
|
1279
|
+
"seeAlso": ["addRelation", "removeRelation", "getRelationTargets"]
|
|
1255
1280
|
},
|
|
1256
1281
|
{
|
|
1257
1282
|
"name": "isWorld",
|
|
@@ -1575,9 +1600,9 @@
|
|
|
1575
1600
|
"kind": "constant",
|
|
1576
1601
|
"module": "aiecsjs/relations",
|
|
1577
1602
|
"type": "Relation",
|
|
1578
|
-
"stability": "
|
|
1579
|
-
"since": "0.
|
|
1580
|
-
"description": "Built-in parent-child relation.
|
|
1603
|
+
"stability": "stable",
|
|
1604
|
+
"since": "0.1.0",
|
|
1605
|
+
"description": "Built-in exclusive parent-child relation. Each entity may have at most one parent at a time."
|
|
1581
1606
|
}
|
|
1582
1607
|
]
|
|
1583
1608
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
'use strict';var chunk7NNM4PGP_cjs=require('./chunk-7NNM4PGP.cjs');var C=1,f=new Map;function _(n){let e=(n.all??[]).map(r=>r.__id).sort((r,o)=>r-o).join("-"),t=(n.any??[]).map(r=>r.__id).sort((r,o)=>r-o).join("-"),i=(n.none??[]).map(r=>r.__id).sort((r,o)=>r-o).join("-");return `A${e}|Y${t}|N${i}`}function q(n){let e=Array.isArray(n)?{all:n}:n;for(let o of [...e.all??[],...e.any??[],...e.none??[]])if(!o||typeof o!="object"||typeof o.__id!="number")throw new TypeError("aiecsjs: defineQuery received a non-component value");let t=_(e),i=f.get(t);if(i)return i;let r={id:C++,mask:[],all:(e.all??[]).map(o=>o.__id),any:(e.any??[]).map(o=>o.__id),none:(e.none??[]).map(o=>o.__id),columnViewCache:[...e.all??[],...e.any??[]],reactiveKind:"normal",sourceQueryId:-1,sourceQuery:null};return f.set(t,r),r}function z(n){let e=n,t=`enter:${e.id}`,i=f.get(t);if(i)return i;let r={id:C++,mask:[],all:e.all,any:e.any,none:e.none,columnViewCache:e.columnViewCache,reactiveKind:"enter",sourceQueryId:e.id,sourceQuery:e};return f.set(t,r),r}function T(n){let e=n,t=`exit:${e.id}`,i=f.get(t);if(i)return i;let r={id:C++,mask:[],all:e.all,any:e.any,none:e.none,columnViewCache:e.columnViewCache,reactiveKind:"exit",sourceQueryId:e.id,sourceQuery:e};return f.set(t,r),r}function p(n,e){if(n.queries[e.id]===e&&n.queryMasks.has(e.id))return;let t=n.options.maskWordCount,i=chunk7NNM4PGP_cjs.b(t),r=chunk7NNM4PGP_cjs.b(t),o=chunk7NNM4PGP_cjs.b(t);for(let a of e.all){let u=b(a),d=chunk7NNM4PGP_cjs.p(n,u);chunk7NNM4PGP_cjs.c(i,d);}for(let a of e.any){let u=b(a),d=chunk7NNM4PGP_cjs.p(n,u);chunk7NNM4PGP_cjs.c(r,d);}for(let a of e.none){let u=b(a),d=chunk7NNM4PGP_cjs.p(n,u);chunk7NNM4PGP_cjs.c(o,d);}let c={withMask:i,anyMask:r,noneMask:o,anyHasBits:!chunk7NNM4PGP_cjs.d(r)};n.queryMasks.set(e.id,c),n.queries[e.id]=e,n.queryArchetypeCache[e.id]=null,n.queryArchetypeStamp[e.id]=-1;let s=[...chunk7NNM4PGP_cjs.f(i),...chunk7NNM4PGP_cjs.f(r),...chunk7NNM4PGP_cjs.f(o)];for(let a of s){let u=n.bitToQueries.get(a);u||(u=new Set,n.bitToQueries.set(a,u)),u.add(e.id);}e.reactiveKind!=="normal"&&(n.reactiveBuffers.has(e.id)||n.reactiveBuffers.set(e.id,{entered:[],exited:[]}),e.sourceQuery&&p(n,e.sourceQuery));}function v(n,e){if(p(n,e),n.queryArchetypeCache[e.id]&&n.queryArchetypeStamp[e.id]===n.queryVersion)return n.queryArchetypeCache[e.id];let t=n.queryMasks.get(e.id),i=n.options.maskWordCount,r=[];for(let o=0;o<n.archetypes.length;o++){let c=n.archetypes[o];chunk7NNM4PGP_cjs.e(c.mask,t.withMask,t.anyMask,t.noneMask,t.anyHasBits,i)&&r.push(o);}return n.queryArchetypeCache[e.id]=r,n.queryArchetypeStamp[e.id]=n.queryVersion,r}function $(n,e){let t=chunk7NNM4PGP_cjs.i(n),r=v(t,e),o=[];for(let c of r){let s=t.archetypes[c];o.push({id:s.id,mask:Array.from(s.mask),size:s.size});}return o}function D(n,e){let t=chunk7NNM4PGP_cjs.i(n),i=e,r=[];if(i.reactiveKind==="enter"){let c=t.reactiveBuffers.get(i.id);if(c){for(let s of c.entered)r.push(s);c.entered.length=0;}return r}if(i.reactiveKind==="exit"){let c=t.reactiveBuffers.get(i.id);if(c){for(let s of c.exited)r.push(s);c.exited.length=0;}return r}let o=v(t,i);for(let c of o){let s=t.archetypes[c];for(let a=0;a<s.size;a++)r.push(s.entities[a]);}return r}function*H(n,e){let t=chunk7NNM4PGP_cjs.i(n),i=e;if(i.reactiveKind!=="normal"){let o=t.reactiveBuffers.get(i.id);if(!o)return;let c=i.reactiveKind==="enter"?o.entered:o.exited;for(let s of c)yield s;c.length=0;return}let r=v(t,i);for(let o of r){let c=t.archetypes[o];for(let s=0;s<c.size;s++)yield c.entities[s];}}function L(n,e,t){let i=chunk7NNM4PGP_cjs.i(n),r=e;if(r.reactiveKind!=="normal"){let s=i.reactiveBuffers.get(r.id);if(!s)return;let a=r.reactiveKind==="enter"?s.entered:s.exited;if(a.length===0)return;let u=w(i,r);for(let d=0;d<a.length;d++){let y=a[d];x(t,y,u);}a.length=0;return}p(i,r);let o=v(i,r),c=w(i,r);for(let s of o){let a=i.archetypes[s],u=a.entities,d=a.size;for(let y=0;y<d;y++)x(t,u[y],c);}}function x(n,e,t){switch(t.length){case 0:n(e);break;case 1:n(e,t[0]);break;case 2:n(e,t[0],t[1]);break;case 3:n(e,t[0],t[1],t[2]);break;case 4:n(e,t[0],t[1],t[2],t[3]);break;case 5:n(e,t[0],t[1],t[2],t[3],t[4]);break;default:n(e,...t);}}function w(n,e){let t=[];for(let i of e.columnViewCache){let r=chunk7NNM4PGP_cjs.H(i),o=n.componentBitFor.get(r.id);if(o===void 0){t.push(void 0);continue}let c=n.componentStorageByBit[o];if(!c){t.push(void 0);continue}c.kind==="soa"?t.push(c.soa):c.kind==="aos"?t.push(c.aos):t.push(true);}return t}function F(n,e,t,i,r){for(let s of f.values())s.reactiveKind!=="normal"&&s.sourceQuery&&n.queries[s.sourceQuery.id]!==s.sourceQuery&&p(n,s.sourceQuery);let o=n.bitToQueries.get(t);if(!o)return;let c=n.options.maskWordCount;for(let s of o){let a=n.queries[s];if(!a||a.reactiveKind!=="normal")continue;let u=n.queryMasks.get(s);if(!u)continue;let d=chunk7NNM4PGP_cjs.e(i,u.withMask,u.anyMask,u.noneMask,u.anyHasBits,c),y=chunk7NNM4PGP_cjs.e(r,u.withMask,u.anyMask,u.noneMask,u.anyHasBits,c);!d&&y?E(n,s,"enter",e):d&&!y&&E(n,s,"exit",e);}}function E(n,e,t,i){for(let r of f.values()){if(r.sourceQueryId!==e||r.reactiveKind!==t)continue;p(n,r);let o=A(n,r.id);t==="enter"?o.entered.push(i):o.exited.push(i);}}function A(n,e){let t=n.reactiveBuffers.get(e);return t||(t={entered:[],exited:[]},n.reactiveBuffers.set(e,t)),t}function b(n){let e=W(n);if(!e)throw new Error(`aiecsjs: component id ${n} not registered`);return e}var g=null;function O(n){g=n;}function W(n){return g?g(n):void 0}exports.a=q;exports.b=z;exports.c=T;exports.d=$;exports.e=D;exports.f=H;exports.g=L;exports.h=F;exports.i=O;//# sourceMappingURL=chunk-2CF2MNMH.cjs.map
|
|
2
|
+
//# sourceMappingURL=chunk-2CF2MNMH.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/internal/query.ts"],"names":["nextQueryId","moduleQueryCache","descKey","d","all","c","a","b","any","none","defineQuery","arg","desc","key","cached","q","enterQuery","query","reactive","exitQuery","ensureQueryRegistered","state","ww","withMask","createMask","anyMask","noneMask","compId","info","getComponentInfoById","bit","getOrRegisterComponentBit","setBit","bundle","isMaskZero","involvedBits","listBits","s","getQueryArchetypes","words","list","i","arch","matches","queryArchetypes","world","getWorldState","ids","out","id","runQuery","buf","e","archIds","r","iterQuery","src","forEachEntity","fn","cols","buildColumnViews","callWithCols","ents","n","eid","comp","getComponentInfo","storage","recordEntityMaskChange","changedBit","prevMask","nextMask","involved","qid","wasMatch","isMatch","pushReactive","queryId","kind","ensureReactiveBuffer","componentId","lazyGetComponentInfo","_getComponentInfoFn","registerComponentLookup"],"mappings":"mEAsBA,IAAIA,EAAc,CAAA,CACZC,CAAAA,CAAmB,IAAI,GAAA,CAE7B,SAASC,CAAAA,CAAQC,CAAAA,CAA4B,CAC3C,IAAMC,GAAOD,CAAAA,CAAE,GAAA,EAAO,EAAC,EACpB,GAAA,CAAKE,GAAMA,CAAAA,CAAE,IAAI,CAAA,CACjB,IAAA,CAAK,CAACC,CAAAA,CAAGC,CAAAA,GAAMD,EAAIC,CAAC,CAAA,CACpB,KAAK,GAAG,CAAA,CACLC,CAAAA,CAAAA,CAAOL,CAAAA,CAAE,KAAO,EAAC,EACpB,IAAKE,CAAAA,EAAMA,CAAAA,CAAE,IAAI,CAAA,CACjB,IAAA,CAAK,CAACC,CAAAA,CAAGC,IAAMD,CAAAA,CAAIC,CAAC,EACpB,IAAA,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getComponentInfo } from './component.js'\nimport type {\n Archetype,\n ComponentInfo,\n ComponentLike,\n EntityId,\n Query,\n QueryDescriptor,\n QueryInternal,\n QueryMaskBundle,\n ReactiveBuffer,\n World,\n WorldState,\n} from './types.js'\nimport {\n getOrRegisterComponentBit,\n getWorldState,\n readEntityMask,\n tryGetComponentBit,\n} from './world.js'\n\nlet nextQueryId = 1\nconst moduleQueryCache = new Map<string, QueryInternal>()\n\nfunction descKey(d: QueryDescriptor): string {\n const all = (d.all ?? [])\n .map((c) => c.__id)\n .sort((a, b) => a - b)\n .join('-')\n const any = (d.any ?? [])\n .map((c) => c.__id)\n .sort((a, b) => a - b)\n .join('-')\n const none = (d.none ?? [])\n .map((c) => c.__id)\n .sort((a, b) => a - b)\n .join('-')\n return `A${all}|Y${any}|N${none}`\n}\n\nexport function defineQuery(arg: ComponentLike[] | QueryDescriptor): Query {\n const desc: QueryDescriptor = Array.isArray(arg) ? { all: arg } : arg\n\n // Validate all members are components\n for (const c of [...(desc.all ?? []), ...(desc.any ?? []), ...(desc.none ?? [])]) {\n if (!c || typeof c !== 'object' || typeof (c as any).__id !== 'number') {\n throw new TypeError('aiecsjs: defineQuery received a non-component value')\n }\n }\n\n const key = descKey(desc)\n const cached = moduleQueryCache.get(key)\n if (cached) return cached\n\n const q: QueryInternal = {\n id: nextQueryId++,\n mask: [],\n all: (desc.all ?? []).map((c) => c.__id),\n any: (desc.any ?? []).map((c) => c.__id),\n none: (desc.none ?? []).map((c) => c.__id),\n columnViewCache: [...(desc.all ?? []), ...(desc.any ?? [])],\n reactiveKind: 'normal',\n sourceQueryId: -1,\n sourceQuery: null,\n }\n moduleQueryCache.set(key, q)\n return q\n}\n\nexport function enterQuery(query: Query): Query {\n const q = query as QueryInternal\n const key = `enter:${q.id}`\n const cached = moduleQueryCache.get(key)\n if (cached) return cached\n const reactive: QueryInternal = {\n id: nextQueryId++,\n mask: [],\n all: q.all,\n any: q.any,\n none: q.none,\n columnViewCache: q.columnViewCache,\n reactiveKind: 'enter',\n sourceQueryId: q.id,\n sourceQuery: q,\n }\n moduleQueryCache.set(key, reactive)\n return reactive\n}\n\nexport function exitQuery(query: Query): Query {\n const q = query as QueryInternal\n const key = `exit:${q.id}`\n const cached = moduleQueryCache.get(key)\n if (cached) return cached\n const reactive: QueryInternal = {\n id: nextQueryId++,\n mask: [],\n all: q.all,\n any: q.any,\n none: q.none,\n columnViewCache: q.columnViewCache,\n reactiveKind: 'exit',\n sourceQueryId: q.id,\n sourceQuery: q,\n }\n moduleQueryCache.set(key, reactive)\n return reactive\n}\n\n// --- Per-world query setup ---\n\nfunction ensureQueryRegistered(state: WorldState, q: QueryInternal): void {\n if (state.queries[q.id] === q && state.queryMasks.has(q.id)) return\n\n // Build per-world bitmasks (this may register new bits)\n const ww = state.options.maskWordCount\n const withMask = createMask(ww)\n const anyMask = createMask(ww)\n const noneMask = createMask(ww)\n for (const compId of q.all) {\n const info = getComponentInfoById(compId)\n const bit = getOrRegisterComponentBit(state, info)\n setBit(withMask, bit)\n }\n for (const compId of q.any) {\n const info = getComponentInfoById(compId)\n const bit = getOrRegisterComponentBit(state, info)\n setBit(anyMask, bit)\n }\n for (const compId of q.none) {\n const info = getComponentInfoById(compId)\n const bit = getOrRegisterComponentBit(state, info)\n setBit(noneMask, bit)\n }\n\n const bundle: QueryMaskBundle = {\n withMask,\n anyMask,\n noneMask,\n anyHasBits: !isMaskZero(anyMask),\n }\n state.queryMasks.set(q.id, bundle)\n\n state.queries[q.id] = q\n state.queryArchetypeCache[q.id] = null\n state.queryArchetypeStamp[q.id] = -1\n\n // Build bit → queries index for fast reactive lookup\n const involvedBits: number[] = [\n ...listBits(withMask),\n ...listBits(anyMask),\n ...listBits(noneMask),\n ]\n for (const b of involvedBits) {\n let s = state.bitToQueries.get(b)\n if (!s) {\n s = new Set<number>()\n state.bitToQueries.set(b, s)\n }\n s.add(q.id)\n }\n\n // Initialize reactive buffer for enter/exit queries\n if (q.reactiveKind !== 'normal') {\n if (!state.reactiveBuffers.has(q.id)) {\n state.reactiveBuffers.set(q.id, { entered: [], exited: [] })\n }\n // Also register the source query so recordEntityMaskChange will see it\n if (q.sourceQuery) ensureQueryRegistered(state, q.sourceQuery)\n }\n}\n\nfunction getQueryArchetypes(state: WorldState, q: QueryInternal): number[] {\n ensureQueryRegistered(state, q)\n if (state.queryArchetypeCache[q.id] && state.queryArchetypeStamp[q.id] === state.queryVersion) {\n return state.queryArchetypeCache[q.id]!\n }\n const bundle = state.queryMasks.get(q.id)!\n const words = state.options.maskWordCount\n const list: number[] = []\n for (let i = 0; i < state.archetypes.length; i++) {\n const arch = state.archetypes[i]!\n if (\n matches(arch.mask, bundle.withMask, bundle.anyMask, bundle.noneMask, bundle.anyHasBits, words)\n ) {\n list.push(i)\n }\n }\n state.queryArchetypeCache[q.id] = list\n state.queryArchetypeStamp[q.id] = state.queryVersion\n return list\n}\n\nexport function queryArchetypes(world: World, query: Query): readonly Archetype[] {\n const state = getWorldState(world)\n const q = query as QueryInternal\n const ids = getQueryArchetypes(state, q)\n const out: Archetype[] = []\n for (const id of ids) {\n const arch = state.archetypes[id]!\n out.push({ id: arch.id, mask: Array.from(arch.mask), size: arch.size })\n }\n return out\n}\n\nexport function runQuery(world: World, query: Query): readonly EntityId[] {\n const state = getWorldState(world)\n const q = query as QueryInternal\n const out: EntityId[] = []\n if (q.reactiveKind === 'enter') {\n const buf = state.reactiveBuffers.get(q.id)\n if (buf) {\n for (const e of buf.entered) out.push(e as EntityId)\n buf.entered.length = 0\n }\n return out\n }\n if (q.reactiveKind === 'exit') {\n const buf = state.reactiveBuffers.get(q.id)\n if (buf) {\n for (const e of buf.exited) out.push(e as EntityId)\n buf.exited.length = 0\n }\n return out\n }\n const archIds = getQueryArchetypes(state, q)\n for (const id of archIds) {\n const arch = state.archetypes[id]!\n for (let r = 0; r < arch.size; r++) {\n out.push(arch.entities[r] as EntityId)\n }\n }\n return out\n}\n\nexport function* iterQuery(world: World, query: Query): IterableIterator<EntityId> {\n const state = getWorldState(world)\n const q = query as QueryInternal\n if (q.reactiveKind !== 'normal') {\n const buf = state.reactiveBuffers.get(q.id)\n if (!buf) return\n const src = q.reactiveKind === 'enter' ? buf.entered : buf.exited\n for (const e of src) yield e as EntityId\n src.length = 0\n return\n }\n const archIds = getQueryArchetypes(state, q)\n for (const id of archIds) {\n const arch = state.archetypes[id]!\n for (let r = 0; r < arch.size; r++) {\n yield arch.entities[r] as EntityId\n }\n }\n}\n\nexport function forEachEntity(\n world: World,\n query: Query,\n fn: (eid: EntityId, ...cols: any[]) => void,\n): void {\n const state = getWorldState(world)\n const q = query as QueryInternal\n\n if (q.reactiveKind !== 'normal') {\n const buf = state.reactiveBuffers.get(q.id)\n if (!buf) return\n const src = q.reactiveKind === 'enter' ? buf.entered : buf.exited\n if (src.length === 0) return\n const cols = buildColumnViews(state, q)\n for (let i = 0; i < src.length; i++) {\n const e = src[i] as EntityId\n callWithCols(fn, e, cols)\n }\n src.length = 0\n return\n }\n\n ensureQueryRegistered(state, q)\n const archIds = getQueryArchetypes(state, q)\n const cols = buildColumnViews(state, q)\n for (const id of archIds) {\n const arch = state.archetypes[id]!\n const ents = arch.entities\n const n = arch.size\n for (let r = 0; r < n; r++) {\n callWithCols(fn, ents[r] as EntityId, cols)\n }\n }\n}\n\nfunction callWithCols(\n fn: (eid: EntityId, ...cols: any[]) => void,\n eid: EntityId,\n cols: any[],\n): void {\n // Specialise for low arities to avoid spread allocation.\n switch (cols.length) {\n case 0:\n fn(eid)\n break\n case 1:\n fn(eid, cols[0])\n break\n case 2:\n fn(eid, cols[0], cols[1])\n break\n case 3:\n fn(eid, cols[0], cols[1], cols[2])\n break\n case 4:\n fn(eid, cols[0], cols[1], cols[2], cols[3])\n break\n case 5:\n fn(eid, cols[0], cols[1], cols[2], cols[3], cols[4])\n break\n default:\n fn(eid, ...cols)\n }\n}\n\nfunction buildColumnViews(state: WorldState, q: QueryInternal): any[] {\n const out: any[] = []\n for (const comp of q.columnViewCache) {\n const info = getComponentInfo(comp)\n const bit = state.componentBitFor.get(info.id)\n if (bit === undefined) {\n out.push(undefined)\n continue\n }\n const storage = state.componentStorageByBit[bit]\n if (!storage) {\n out.push(undefined)\n continue\n }\n if (storage.kind === 'soa') out.push(storage.soa)\n else if (storage.kind === 'aos') out.push(storage.aos)\n else out.push(true) // tag\n }\n return out\n}\n\n// --- Reactive query updates (called from migration code) ---\n\nexport function recordEntityMaskChange(\n state: WorldState,\n eid: EntityId,\n changedBit: number,\n prevMask: Uint32Array,\n nextMask: Uint32Array,\n): void {\n // Lazy-register any reactive queries (and their sources) so we can correctly\n // determine match transitions even if the user only ever called enterQuery/exitQuery.\n for (const q of moduleQueryCache.values()) {\n if (q.reactiveKind === 'normal') continue\n if (q.sourceQuery && state.queries[q.sourceQuery.id] !== q.sourceQuery) {\n ensureQueryRegistered(state, q.sourceQuery)\n }\n }\n\n const involved = state.bitToQueries.get(changedBit)\n if (!involved) return\n const words = state.options.maskWordCount\n for (const qid of involved) {\n const q = state.queries[qid]\n if (!q) continue\n if (q.reactiveKind !== 'normal') continue\n const bundle = state.queryMasks.get(qid)\n if (!bundle) continue\n const wasMatch = matches(\n prevMask,\n bundle.withMask,\n bundle.anyMask,\n bundle.noneMask,\n bundle.anyHasBits,\n words,\n )\n const isMatch = matches(\n nextMask,\n bundle.withMask,\n bundle.anyMask,\n bundle.noneMask,\n bundle.anyHasBits,\n words,\n )\n if (!wasMatch && isMatch) {\n pushReactive(state, qid, 'enter', eid)\n } else if (wasMatch && !isMatch) {\n pushReactive(state, qid, 'exit', eid)\n }\n }\n}\n\nfunction pushReactive(\n state: WorldState,\n queryId: number,\n kind: 'enter' | 'exit',\n eid: EntityId,\n): void {\n // Walk the module cache (not just state.queries) so reactive variants that\n // haven't been registered with this world yet still receive events.\n for (const r of moduleQueryCache.values()) {\n if (r.sourceQueryId !== queryId) continue\n if (r.reactiveKind !== kind) continue\n // Lazily register the reactive query in this world so subsequent reads can find it\n ensureQueryRegistered(state, r)\n const buf = ensureReactiveBuffer(state, r.id)\n if (kind === 'enter') buf.entered.push(eid as number)\n else buf.exited.push(eid as number)\n }\n}\n\nfunction ensureReactiveBuffer(state: WorldState, qid: number): ReactiveBuffer {\n let buf = state.reactiveBuffers.get(qid)\n if (!buf) {\n buf = { entered: [], exited: [] }\n state.reactiveBuffers.set(qid, buf)\n }\n return buf\n}\n\n// --- Helpers ---\n\nfunction getComponentInfoById(componentId: number): ComponentInfo {\n // We need access to the component registry's lookup by id. Re-import dynamically to avoid cycles.\n const info = lazyGetComponentInfo(componentId)\n if (!info) throw new Error(`aiecsjs: component id ${componentId} not registered`)\n return info\n}\n\nlet _getComponentInfoFn: ((id: number) => ComponentInfo | undefined) | null = null\nexport function registerComponentLookup(fn: (id: number) => ComponentInfo | undefined): void {\n _getComponentInfoFn = fn\n}\nfunction lazyGetComponentInfo(id: number): ComponentInfo | undefined {\n return _getComponentInfoFn ? _getComponentInfoFn(id) : undefined\n}\n\nexport function _resetQueryRegistry_FOR_TESTS_ONLY(): void {\n moduleQueryCache.clear()\n nextQueryId = 1\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/internal/query.ts"],"names":["nextQueryId","moduleQueryCache","descKey","d","all","c","a","b","any","none","defineQuery","arg","desc","key","cached","q","enterQuery","query","reactive","exitQuery","ensureQueryRegistered","state","ww","withMask","createMask","anyMask","noneMask","compId","info","getComponentInfoById","bit","getOrRegisterComponentBit","setBit","bundle","isMaskZero","involvedBits","listBits","s","getQueryArchetypes","words","list","i","arch","matches","queryArchetypes","world","getWorldState","ids","out","id","runQuery","buf","e","archIds","r","iterQuery","src","forEachEntity","fn","cols","buildColumnViews","callWithCols","ents","n","eid","comp","getComponentInfo","storage","recordEntityMaskChange","changedBit","prevMask","nextMask","involved","qid","wasMatch","isMatch","pushReactive","queryId","kind","ensureReactiveBuffer","componentId","lazyGetComponentInfo","_getComponentInfoFn","registerComponentLookup"],"mappings":"mEAsBA,IAAIA,EAAc,CAAA,CACZC,CAAAA,CAAmB,IAAI,G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AEhE,IAAMpD,CAAAA,CAAOqD,CAAAA,CAAqBD,CAAW,CAAA,CAC7C,GAAI,CAACpD,CAAAA,CAAM,MAAM,IAAI,KAAA,CAAM,yBAAyBoD,CAAW,CAAA,eAAA,CAAiB,EAChF,OAAOpD,CACT,CAEA,IAAIsD,EAA0E,IAAA,CACvE,SAASC,EAAwBzB,CAAAA,CAAqD,CAC3FwB,EAAsBxB,EACxB,CACA,SAASuB,CAAAA,CAAqBhC,EAAuC,CACnE,OAAOiC,EAAsBA,CAAAA,CAAoBjC,CAAE,EAAI,MACzD","file":"chunk-2CF2MNMH.cjs","sourcesContent":["import { createMask, isMaskZero, listBits, matches, setBit } from './bitmask.js'\nimport { getComponentInfo } from './component.js'\nimport type {\n Archetype,\n ComponentInfo,\n ComponentLike,\n EntityId,\n Query,\n QueryDescriptor,\n QueryInternal,\n QueryMaskBundle,\n ReactiveBuffer,\n World,\n WorldState,\n} from './types.js'\nimport {\n getOrRegisterComponentBit,\n getWorldState,\n readEntityMask,\n tryGetComponentBit,\n} from './world.js'\n\nlet nextQueryId = 1\nconst moduleQueryCache = new Map<string, QueryInternal>()\n\nfunction descKey(d: QueryDescriptor): string {\n const all = (d.all ?? [])\n .map((c) => c.__id)\n .sort((a, b) => a - b)\n .join('-')\n const any = (d.any ?? [])\n .map((c) => c.__id)\n .sort((a, b) => a - b)\n .join('-')\n const none = (d.none ?? [])\n .map((c) => c.__id)\n .sort((a, b) => a - b)\n .join('-')\n return `A${all}|Y${any}|N${none}`\n}\n\nexport function defineQuery(arg: ComponentLike[] | QueryDescriptor): Query {\n const desc: QueryDescriptor = Array.isArray(arg) ? { all: arg } : arg\n\n // Validate all members are components\n for (const c of [...(desc.all ?? []), ...(desc.any ?? []), ...(desc.none ?? [])]) {\n if (!c || typeof c !== 'object' || typeof (c as any).__id !== 'number') {\n throw new TypeError('aiecsjs: defineQuery received a non-component value')\n }\n }\n\n const key = descKey(desc)\n const cached = moduleQueryCache.get(key)\n if (cached) return cached\n\n const q: QueryInternal = {\n id: nextQueryId++,\n mask: [],\n all: (desc.all ?? []).map((c) => c.__id),\n any: (desc.any ?? []).map((c) => c.__id),\n none: (desc.none ?? []).map((c) => c.__id),\n columnViewCache: [...(desc.all ?? []), ...(desc.any ?? [])],\n reactiveKind: 'normal',\n sourceQueryId: -1,\n sourceQuery: null,\n }\n moduleQueryCache.set(key, q)\n return q\n}\n\nexport function enterQuery(query: Query): Query {\n const q = query as QueryInternal\n const key = `enter:${q.id}`\n const cached = moduleQueryCache.get(key)\n if (cached) return cached\n const reactive: QueryInternal = {\n id: nextQueryId++,\n mask: [],\n all: q.all,\n any: q.any,\n none: q.none,\n columnViewCache: q.columnViewCache,\n reactiveKind: 'enter',\n sourceQueryId: q.id,\n sourceQuery: q,\n }\n moduleQueryCache.set(key, reactive)\n return reactive\n}\n\nexport function exitQuery(query: Query): Query {\n const q = query as QueryInternal\n const key = `exit:${q.id}`\n const cached = moduleQueryCache.get(key)\n if (cached) return cached\n const reactive: QueryInternal = {\n id: nextQueryId++,\n mask: [],\n all: q.all,\n any: q.any,\n none: q.none,\n columnViewCache: q.columnViewCache,\n reactiveKind: 'exit',\n sourceQueryId: q.id,\n sourceQuery: q,\n }\n moduleQueryCache.set(key, reactive)\n return reactive\n}\n\n// --- Per-world query setup ---\n\nfunction ensureQueryRegistered(state: WorldState, q: QueryInternal): void {\n if (state.queries[q.id] === q && state.queryMasks.has(q.id)) return\n\n // Build per-world bitmasks (this may register new bits)\n const ww = state.options.maskWordCount\n const withMask = createMask(ww)\n const anyMask = createMask(ww)\n const noneMask = createMask(ww)\n for (const compId of q.all) {\n const info = getComponentInfoById(compId)\n const bit = getOrRegisterComponentBit(state, info)\n setBit(withMask, bit)\n }\n for (const compId of q.any) {\n const info = getComponentInfoById(compId)\n const bit = getOrRegisterComponentBit(state, info)\n setBit(anyMask, bit)\n }\n for (const compId of q.none) {\n const info = getComponentInfoById(compId)\n const bit = getOrRegisterComponentBit(state, info)\n setBit(noneMask, bit)\n }\n\n const bundle: QueryMaskBundle = {\n withMask,\n anyMask,\n noneMask,\n anyHasBits: !isMaskZero(anyMask),\n }\n state.queryMasks.set(q.id, bundle)\n\n state.queries[q.id] = q\n state.queryArchetypeCache[q.id] = null\n state.queryArchetypeStamp[q.id] = -1\n\n // Build bit → queries index for fast reactive lookup\n const involvedBits: number[] = [\n ...listBits(withMask),\n ...listBits(anyMask),\n ...listBits(noneMask),\n ]\n for (const b of involvedBits) {\n let s = state.bitToQueries.get(b)\n if (!s) {\n s = new Set<number>()\n state.bitToQueries.set(b, s)\n }\n s.add(q.id)\n }\n\n // Initialize reactive buffer for enter/exit queries\n if (q.reactiveKind !== 'normal') {\n if (!state.reactiveBuffers.has(q.id)) {\n state.reactiveBuffers.set(q.id, { entered: [], exited: [] })\n }\n // Also register the source query so recordEntityMaskChange will see it\n if (q.sourceQuery) ensureQueryRegistered(state, q.sourceQuery)\n }\n}\n\nfunction getQueryArchetypes(state: WorldState, q: QueryInternal): number[] {\n ensureQueryRegistered(state, q)\n if (state.queryArchetypeCache[q.id] && state.queryArchetypeStamp[q.id] === state.queryVersion) {\n return state.queryArchetypeCache[q.id]!\n }\n const bundle = state.queryMasks.get(q.id)!\n const words = state.options.maskWordCount\n const list: number[] = []\n for (let i = 0; i < state.archetypes.length; i++) {\n const arch = state.archetypes[i]!\n if (\n matches(arch.mask, bundle.withMask, bundle.anyMask, bundle.noneMask, bundle.anyHasBits, words)\n ) {\n list.push(i)\n }\n }\n state.queryArchetypeCache[q.id] = list\n state.queryArchetypeStamp[q.id] = state.queryVersion\n return list\n}\n\nexport function queryArchetypes(world: World, query: Query): readonly Archetype[] {\n const state = getWorldState(world)\n const q = query as QueryInternal\n const ids = getQueryArchetypes(state, q)\n const out: Archetype[] = []\n for (const id of ids) {\n const arch = state.archetypes[id]!\n out.push({ id: arch.id, mask: Array.from(arch.mask), size: arch.size })\n }\n return out\n}\n\nexport function runQuery(world: World, query: Query): readonly EntityId[] {\n const state = getWorldState(world)\n const q = query as QueryInternal\n const out: EntityId[] = []\n if (q.reactiveKind === 'enter') {\n const buf = state.reactiveBuffers.get(q.id)\n if (buf) {\n for (const e of buf.entered) out.push(e as EntityId)\n buf.entered.length = 0\n }\n return out\n }\n if (q.reactiveKind === 'exit') {\n const buf = state.reactiveBuffers.get(q.id)\n if (buf) {\n for (const e of buf.exited) out.push(e as EntityId)\n buf.exited.length = 0\n }\n return out\n }\n const archIds = getQueryArchetypes(state, q)\n for (const id of archIds) {\n const arch = state.archetypes[id]!\n for (let r = 0; r < arch.size; r++) {\n out.push(arch.entities[r] as EntityId)\n }\n }\n return out\n}\n\nexport function* iterQuery(world: World, query: Query): IterableIterator<EntityId> {\n const state = getWorldState(world)\n const q = query as QueryInternal\n if (q.reactiveKind !== 'normal') {\n const buf = state.reactiveBuffers.get(q.id)\n if (!buf) return\n const src = q.reactiveKind === 'enter' ? buf.entered : buf.exited\n for (const e of src) yield e as EntityId\n src.length = 0\n return\n }\n const archIds = getQueryArchetypes(state, q)\n for (const id of archIds) {\n const arch = state.archetypes[id]!\n for (let r = 0; r < arch.size; r++) {\n yield arch.entities[r] as EntityId\n }\n }\n}\n\nexport function forEachEntity(\n world: World,\n query: Query,\n fn: (eid: EntityId, ...cols: any[]) => void,\n): void {\n const state = getWorldState(world)\n const q = query as QueryInternal\n\n if (q.reactiveKind !== 'normal') {\n const buf = state.reactiveBuffers.get(q.id)\n if (!buf) return\n const src = q.reactiveKind === 'enter' ? buf.entered : buf.exited\n if (src.length === 0) return\n const cols = buildColumnViews(state, q)\n for (let i = 0; i < src.length; i++) {\n const e = src[i] as EntityId\n callWithCols(fn, e, cols)\n }\n src.length = 0\n return\n }\n\n ensureQueryRegistered(state, q)\n const archIds = getQueryArchetypes(state, q)\n const cols = buildColumnViews(state, q)\n for (const id of archIds) {\n const arch = state.archetypes[id]!\n const ents = arch.entities\n const n = arch.size\n for (let r = 0; r < n; r++) {\n callWithCols(fn, ents[r] as EntityId, cols)\n }\n }\n}\n\nfunction callWithCols(\n fn: (eid: EntityId, ...cols: any[]) => void,\n eid: EntityId,\n cols: any[],\n): void {\n // Specialise for low arities to avoid spread allocation.\n switch (cols.length) {\n case 0:\n fn(eid)\n break\n case 1:\n fn(eid, cols[0])\n break\n case 2:\n fn(eid, cols[0], cols[1])\n break\n case 3:\n fn(eid, cols[0], cols[1], cols[2])\n break\n case 4:\n fn(eid, cols[0], cols[1], cols[2], cols[3])\n break\n case 5:\n fn(eid, cols[0], cols[1], cols[2], cols[3], cols[4])\n break\n default:\n fn(eid, ...cols)\n }\n}\n\nfunction buildColumnViews(state: WorldState, q: QueryInternal): any[] {\n const out: any[] = []\n for (const comp of q.columnViewCache) {\n const info = getComponentInfo(comp)\n const bit = state.componentBitFor.get(info.id)\n if (bit === undefined) {\n out.push(undefined)\n continue\n }\n const storage = state.componentStorageByBit[bit]\n if (!storage) {\n out.push(undefined)\n continue\n }\n if (storage.kind === 'soa') out.push(storage.soa)\n else if (storage.kind === 'aos') out.push(storage.aos)\n else out.push(true) // tag\n }\n return out\n}\n\n// --- Reactive query updates (called from migration code) ---\n\nexport function recordEntityMaskChange(\n state: WorldState,\n eid: EntityId,\n changedBit: number,\n prevMask: Uint32Array,\n nextMask: Uint32Array,\n): void {\n // Lazy-register any reactive queries (and their sources) so we can correctly\n // determine match transitions even if the user only ever called enterQuery/exitQuery.\n for (const q of moduleQueryCache.values()) {\n if (q.reactiveKind === 'normal') continue\n if (q.sourceQuery && state.queries[q.sourceQuery.id] !== q.sourceQuery) {\n ensureQueryRegistered(state, q.sourceQuery)\n }\n }\n\n const involved = state.bitToQueries.get(changedBit)\n if (!involved) return\n const words = state.options.maskWordCount\n for (const qid of involved) {\n const q = state.queries[qid]\n if (!q) continue\n if (q.reactiveKind !== 'normal') continue\n const bundle = state.queryMasks.get(qid)\n if (!bundle) continue\n const wasMatch = matches(\n prevMask,\n bundle.withMask,\n bundle.anyMask,\n bundle.noneMask,\n bundle.anyHasBits,\n words,\n )\n const isMatch = matches(\n nextMask,\n bundle.withMask,\n bundle.anyMask,\n bundle.noneMask,\n bundle.anyHasBits,\n words,\n )\n if (!wasMatch && isMatch) {\n pushReactive(state, qid, 'enter', eid)\n } else if (wasMatch && !isMatch) {\n pushReactive(state, qid, 'exit', eid)\n }\n }\n}\n\nfunction pushReactive(\n state: WorldState,\n queryId: number,\n kind: 'enter' | 'exit',\n eid: EntityId,\n): void {\n // Walk the module cache (not just state.queries) so reactive variants that\n // haven't been registered with this world yet still receive events.\n for (const r of moduleQueryCache.values()) {\n if (r.sourceQueryId !== queryId) continue\n if (r.reactiveKind !== kind) continue\n // Lazily register the reactive query in this world so subsequent reads can find it\n ensureQueryRegistered(state, r)\n const buf = ensureReactiveBuffer(state, r.id)\n if (kind === 'enter') buf.entered.push(eid as number)\n else buf.exited.push(eid as number)\n }\n}\n\nfunction ensureReactiveBuffer(state: WorldState, qid: number): ReactiveBuffer {\n let buf = state.reactiveBuffers.get(qid)\n if (!buf) {\n buf = { entered: [], exited: [] }\n state.reactiveBuffers.set(qid, buf)\n }\n return buf\n}\n\n// --- Helpers ---\n\nfunction getComponentInfoById(componentId: number): ComponentInfo {\n // We need access to the component registry's lookup by id. Re-import dynamically to avoid cycles.\n const info = lazyGetComponentInfo(componentId)\n if (!info) throw new Error(`aiecsjs: component id ${componentId} not registered`)\n return info\n}\n\nlet _getComponentInfoFn: ((id: number) => ComponentInfo | undefined) | null = null\nexport function registerComponentLookup(fn: (id: number) => ComponentInfo | undefined): void {\n _getComponentInfoFn = fn\n}\nfunction lazyGetComponentInfo(id: number): ComponentInfo | undefined {\n return _getComponentInfoFn ? _getComponentInfoFn(id) : undefined\n}\n\nexport function _resetQueryRegistry_FOR_TESTS_ONLY(): void {\n moduleQueryCache.clear()\n nextQueryId = 1\n}\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var O="0.3.1";function R(n){return new Uint32Array(n)}function _(n,t){let e=t>>>5;n[e]=(n[e]??0)|1<<(t&31);}function j(n,t){let e=t>>>5;n[e]=(n[e]??0)&~(1<<(t&31));}function m(n,t){let e=t>>>5;return ((n[e]??0)&1<<(t&31))!==0}function w(n){let t=new Uint32Array(n.length);for(let e=0;e<n.length;e++)t[e]=n[e]??0;return t}function v(n){let t=[];for(let e=0;e<n.length;e++)t.push((n[e]??0).toString(16));return t.join(",")}function xt(n){for(let t=0;t<n.length;t++)if((n[t]??0)!==0)return false;return true}function ht(n,t,e,o,i,s){let r=!i;for(let a=0;a<s;a++){let d=n[a]??0,c=t[a]??0,u=e[a]??0,f=o[a]??0;if((d&c)!==c||(d&f)!==0)return false;!r&&(d&u)!==0&&(r=true);}return r}function At(n){let t=[];for(let e=0;e<n.length;e++){let o=n[e]??0;for(;o!==0;){let i=(e<<5)+T(o);t.push(i),o&=o-1;}}return t}function L(n,t,e,o){for(let i=0;i<e;i++){let s=n[t+i]??0;for(;s!==0;){let r=(i<<5)+T(s);o(r),s&=s-1;}}}function wt(n,t,e,o,i,s,r){let a=!r;for(let d=0;d<e;d++){let c=n[t+d]??0,u=o[d]??0,f=i[d]??0,l=s[d]??0;if((c&u)!==u||(c&l)!==0)return false;!a&&(c&f)!==0&&(a=true);}return a}function T(n){return 31-Math.clz32(n&-n)}var C={initialCapacity:1024,maxEntities:1e6,indexBits:24,generationBits:8},Q=256,Z=1,b=new Map;function y(n){let t=b.get(n.id);if(!t)throw new Error(`aiecsjs: world ${n.id} is destroyed or unknown`);if(t.destroyed)throw new Error(`aiecsjs: world ${n.id} is destroyed`);return t}function J(n){b.set(n.id,n);}function tt(n){b.delete(n);}function Et(n){return b.has(n)}function nt(n){let t=n??{},e=t.indexBits??C.indexBits,o=t.generationBits??C.generationBits,i=Q;if(e<1||e>24)throw new Error("aiecsjs: indexBits must be in [1, 24]");if(o<0||o>16)throw new Error("aiecsjs: generationBits must be in [0, 16]");if(e+o>32)throw new Error(`aiecsjs: indexBits (${e}) + generationBits (${o}) must be <= 32`);let s=1<<e,r=Math.max(1,Math.min(t.initialCapacity??C.initialCapacity,s)),a=Math.max(r,Math.min(t.maxEntities??C.maxEntities,s));return {initialCapacity:r,maxEntities:a,indexBits:e,generationBits:o,indexMask:(1<<e)-1,generationMask:o===0?0:(1<<o)-1,maxComponents:i,maskWordCount:Math.ceil(i/32),buffer:t.buffer??null,bufferByteOffset:t.bufferByteOffset??0}}function et(n,t){return {id:0,mask:R(n),size:0,capacity:16,entities:new Uint32Array(16),entityRow:new Map,componentBits:[],edgeAdd:new Int32Array(t).fill(-1),edgeRemove:new Int32Array(t).fill(-1)}}function vt(n){let t=nt(n),e=Z++,o=t.generationBits>8?Uint16Array:Uint8Array,i=new o(t.initialCapacity),s={id:e,capacity:t.initialCapacity,version:O,options:t,size:0,nextFreshIndex:1,freeList:[],generations:i,destroyed:false,componentBitFor:new Map,componentInfoByBit:new Array(t.maxComponents).fill(null),componentStorageByBit:new Array(t.maxComponents).fill(null),nextComponentBit:0,entityArchetype:new Uint32Array(t.initialCapacity),entityMask:new Uint32Array(t.initialCapacity*t.maskWordCount),archetypes:[],archetypeByMaskHash:new Map,queryVersion:0,queries:[],queryMasks:new Map,queryArchetypeCache:[],queryArchetypeStamp:[],bitToQueries:new Map,reactiveBuffers:new Map,observers:[],relationStorage:new Map,sab:t.buffer,readOnly:false},r=et(t.maskWordCount,t.maxComponents);return r.id=0,s.archetypes.push(r),s.archetypeByMaskHash.set(v(r.mask),0),J(s),ot(s)}function ot(n){return {id:n.id,get capacity(){return n.capacity},version:n.version}}function St(n){let t=b.get(n.id);!t||t.destroyed||(t.destroyed=true,t.archetypes=[],t.archetypeByMaskHash.clear(),t.componentInfoByBit=[],t.componentStorageByBit=[],t.queries=[],t.queryMasks.clear(),t.queryArchetypeCache=[],t.observers=[],t.relationStorage.clear(),t.reactiveBuffers.clear(),tt(n.id));}function Wt(n){let t=y(n);t.size=0,t.nextFreshIndex=1,t.freeList=[],t.generations.fill(0),t.entityArchetype.fill(0),t.entityMask.fill(0);for(let e of t.archetypes)e.size=0,e.entityRow.clear();for(let e of t.componentStorageByBit)if(e)if(e.kind==="soa"&&e.soa)for(let o of Object.keys(e.soa))e.soa[o]?.fill(0);else e.kind==="aos"&&e.aos&&e.aos.fill(void 0);t.queryVersion++;for(let e of t.reactiveBuffers.values())e.entered.length=0,e.exited.length=0;}function Bt(n){return y(n).size}function Mt(n){return y(n).capacity}function F(n,t){if(t<=n.capacity)return;if(t>n.options.maxEntities)throw new Error(`aiecsjs: requested capacity ${t} exceeds maxEntities ${n.options.maxEntities}`);let e=n.capacity;for(;e<t;)e=Math.min(e*2,n.options.maxEntities);rt(n,e);}function rt(n,t){let e=n.generations.constructor,o=new e(t);o.set(n.generations),n.generations=o;let i=new Uint32Array(t);i.set(n.entityArchetype),n.entityArchetype=i;let s=n.options.maskWordCount,r=new Uint32Array(t*s);r.set(n.entityMask),n.entityMask=r;for(let a of n.componentStorageByBit)if(a)if(a.kind==="soa"&&a.soa){let d=n.componentInfoByBit[a.bit];d&&it(a.soa,d.fields,t);}else a.kind==="aos"&&a.aos&&(a.aos.length=t);n.capacity=t;}function it(n,t,e){for(let o of t){let i=n[o.name];if(!i)continue;let s=e*o.vectorLen;if(i.length>=s)continue;let r=new o.ctor(s);r.set(i),n[o.name]=r;}}function z(n,t){let e=v(t),o=n.archetypeByMaskHash.get(e);if(o!==void 0)return {archId:o,created:false};let i=n.archetypes.length,s={id:i,mask:w(t),size:0,capacity:16,entities:new Uint32Array(16),entityRow:new Map,componentBits:st(t),edgeAdd:new Int32Array(n.options.maxComponents).fill(-1),edgeRemove:new Int32Array(n.options.maxComponents).fill(-1)};return n.archetypes.push(s),n.archetypeByMaskHash.set(e,i),n.queryVersion++,{archId:i,created:true}}function I(n,t){if(t<=n.capacity)return;let e=n.capacity;for(;e<t;)e*=2;let o=new Uint32Array(e);o.set(n.entities),n.entities=o,n.capacity=e;}function st(n){let t=[];for(let e=0;e<n.length;e++){let o=n[e]??0;for(;o!==0;){let i=o&-o,s=(e<<5)+(31-Math.clz32(i));t.push(s),o&=o-1;}}return t}function D(n,t){let e=n.componentBitFor.get(t.id);if(e!==void 0)return e;if(n.nextComponentBit>=n.options.maxComponents)throw new Error(`aiecsjs: world reached maxComponents=${n.options.maxComponents}`);let o=n.nextComponentBit++;n.componentBitFor.set(t.id,o),n.componentInfoByBit[o]=t;let i;if(t.kind==="soa"){let s={};for(let r of t.fields)s[r.name]=new r.ctor(n.capacity*r.vectorLen);i={kind:"soa",componentId:t.id,bit:o,soa:s};}else t.kind==="aos"?i={kind:"aos",componentId:t.id,bit:o,aos:new Array(n.capacity)}:i={kind:"tag",componentId:t.id,bit:o};return n.componentStorageByBit[o]=i,o}function x(n,t){let e=n.options.maskWordCount,o=new Uint32Array(e),s=(t&n.options.indexMask)*e;for(let r=0;r<e;r++)o[r]=n.entityMask[s+r]??0;return o}function N(n,t,e){let o=n.options.maskWordCount,s=(t&n.options.indexMask)*o;for(let r=0;r<o;r++)n.entityMask[s+r]=e[r]??0;}function g(n,t){return n.componentBitFor.get(t.id)}function Ut(n){if(!n||typeof n!="object")return false;let t=n;return typeof t.id!="number"||typeof t.version!="string"?false:b.has(t.id)}var W=1,at={i8:Int8Array,u8:Uint8Array,i16:Int16Array,u16:Uint16Array,i32:Int32Array,u32:Uint32Array,f32:Float32Array,f64:Float64Array,eid:Uint32Array,bool:Uint8Array},h=new Map;function Lt(n){let t=[];for(let[s,r]of Object.entries(n)){let a,d=1;if(typeof r=="string")a=r;else if(Array.isArray(r)){let[u,f]=r;a=u,d=f;}else throw new TypeError(`aiecsjs: invalid field declaration for "${s}"`);let c=at[a];if(!c)throw new TypeError(`aiecsjs: unknown field type "${a}" for field "${s}"`);t.push({name:s,type:a,vectorLen:d,ctor:c,bytesPerElement:c.BYTES_PER_ELEMENT});}let e=W++,o={id:e,kind:"soa",schema:n,fields:t,factory:null};return h.set(e,o),{__kind:"soa",__id:e,__schema:n}}function Tt(){let n=W++,t={id:n,kind:"tag",schema:null,fields:[],factory:null};return h.set(n,t),{__kind:"tag",__id:n}}function Ft(n){let t=W++,e=n??(()=>({})),o={id:t,kind:"aos",schema:null,fields:[],factory:e};return h.set(t,o),{__kind:"aos",__id:t,__factory:e}}function A(n){let t=h.get(n.__id);if(!t)throw new Error("aiecsjs: component is not registered (call defineComponent/defineTag/defineObjectComponent)");return t}function P(n,t,e,o){let i=y(n);if(i.readOnly)throw new Error("aiecsjs: cannot mutate a read-only world");if(!p(i,t))throw new Error(`aiecsjs: addComponent on dead entity ${t}`);let s=A(e),r=D(i,s),a=x(i,t);if(m(a,r)){o!==void 0&&S(i,t,e,o);return}let d=w(a);_(d,r),G(i,t,d),S(i,t,e,o),ct(i,t,r),V(i,t,r,a,d);}function zt(n,t,e){let o=y(n);if(o.readOnly)throw new Error("aiecsjs: cannot mutate a read-only world");if(!p(o,t))return;let i=A(e),s=g(o,i);if(s===void 0)return;let r=x(o,t);if(!m(r,s))return;let a=w(r);j(a,s),G(o,t,a),dt(o,t,s);let d=t&o.options.indexMask,c=o.componentStorageByBit[s];c?.kind==="soa"&&c.soa?q(c.soa,i.fields,d):c?.kind==="aos"&&c.aos&&(c.aos[d]=void 0),V(o,t,s,r,a);}function Dt(n,t,e){let o=y(n);if(!p(o,t))return false;let i=A(e),s=g(o,i);if(s===void 0)return false;let r=x(o,t);return m(r,s)}function Nt(n,t,e){let o=y(n);if(!p(o,t))return;let i=A(e),s=g(o,i);if(s===void 0)return;let r=x(o,t);if(!m(r,s))return;let a=o.componentStorageByBit[s];if(a){if(a.kind==="soa")return a.soa;if(a.kind==="aos"){let d=t&o.options.indexMask;return a.aos?.[d]}return true}}function Pt(n,t,e,o){let i=y(n);if(i.readOnly)throw new Error("aiecsjs: cannot mutate a read-only world");if(!p(i,t))throw new Error(`aiecsjs: setComponent on dead entity ${t}`);let s=A(e),r=g(i,s);if(r===void 0){P(n,t,e,o);return}let a=x(i,t);if(!m(a,r)){P(n,t,e,o);return}S(i,t,e,o),ft(i,t,r,o);}function S(n,t,e,o){let i=A(e),s=n.componentBitFor.get(i.id);if(s===void 0)return;let r=n.componentStorageByBit[s];if(!r)return;let a=t&n.options.indexMask;if(i.kind==="soa"&&r.soa){if(o==null)return;let d=o;for(let c of i.fields){if(!(c.name in d))continue;let u=r.soa[c.name];if(!u)continue;let f=d[c.name];if(c.vectorLen===1)u[a]=typeof f=="boolean"?f?1:0:Number(f);else if(Array.isArray(f)||ArrayBuffer.isView(f)){let l=a*c.vectorLen,K=f;for(let k=0;k<c.vectorLen;k++)u[l+k]=Number(K[k]??0);}}}else if(i.kind==="aos"&&r.aos){let d=i.factory??(()=>({})),c=r.aos[a];if(c===void 0&&(c=d(),r.aos[a]=c),o&&typeof o=="object"){let u=o,f=c;for(let l of Object.keys(u))l==="__proto__"||l==="constructor"||l==="prototype"||(f[l]=u[l]);}}}function q(n,t,e){for(let o of t){let i=n[o.name];if(i)if(o.vectorLen===1)i[e]=0;else {let s=e*o.vectorLen;for(let r=0;r<o.vectorLen;r++)i[s+r]=0;}}}function $(n,t){let e=n.options.maskWordCount,o=t&n.options.indexMask,i=o*e;L(n.entityMask,i,e,s=>{let r=n.componentStorageByBit[s],a=n.componentInfoByBit[s];r?.kind==="soa"&&r.soa&&a?q(r.soa,a.fields,o):r?.kind==="aos"&&r.aos&&(r.aos[o]=void 0);});}function G(n,t,e){let o=t&n.options.indexMask,i=n.entityArchetype[o]??0,s=n.archetypes[i];if(!s)return;let a=z(n,e).archId,d=n.archetypes[a];if(d){if(a!==i){let c=s.entityRow.get(t);if(c!==void 0){let f=s.size-1;if(c!==f){let l=s.entities[f]??0;s.entities[c]=l,s.entityRow.set(l,c);}s.entities[f]=0,s.entityRow.delete(t),s.size--;}I(d,d.size+1);let u=d.size;d.entities[u]=t,d.entityRow.set(t,u),d.size++,n.entityArchetype[o]=a;}N(n,t,e);}}var E={fireAdd:()=>{},fireRemove:()=>{},fireSet:()=>{}},H=()=>{};function qt(n){H=n;}function V(n,t,e,o,i){H(n,t,e,o,i);}function $t(n){E=n;}function ct(n,t,e){E.fireAdd(n,t,e);}function dt(n,t,e){E.fireRemove(n,t,e);}function ft(n,t,e,o){E.fireSet(n,t,e,o);}function Gt(n){return h.get(n)}function Ht(){return Array.from(h.values())}var U=24,ut=8,Y=(1<<U)-1,X=(1<<ut)-1;function yt(n,t,e){return ((t&e.generationMask)<<e.indexBits|n&e.indexMask)>>>0}function Kt(n,t){return n&t.indexMask}function Qt(n,t){return n>>>t.indexBits&t.generationMask}function Zt(n){let t=y(n);if(t.readOnly)throw new Error("aiecsjs: cannot createEntity on a read-only world (worker-attached)");let e;if(t.freeList.length>0)e=t.freeList.pop();else {if(t.nextFreshIndex>=t.options.maxEntities)throw new Error(`aiecsjs: reached maxEntities ${t.options.maxEntities}`);t.nextFreshIndex>=t.capacity&&F(t,t.nextFreshIndex+1),e=t.nextFreshIndex++;}let o=t.generations[e]??0,i=yt(e,o,t.options),s=t.archetypes[0];if(!s)throw new Error("aiecsjs: missing empty archetype");I(s,s.size+1);let r=s.size;s.entities[r]=i,s.entityRow.set(i,r),s.size++,t.entityArchetype[e]=0;let a=t.options.maskWordCount,d=e*a;for(let c=0;c<a;c++)t.entityMask[d+c]=0;return t.size++,i}function Jt(n,t){let e=y(n);if(e.readOnly)throw new Error("aiecsjs: cannot destroyEntity on a read-only world");if(!p(e,t))return;let o=t&e.options.indexMask,{dispatchDestroyObservers:i}=pt();i(e,t),mt(e,t),$(e,t);let s=e.entityArchetype[o]??0,r=e.archetypes[s];if(r){let c=r.entityRow.get(t);if(c!==void 0){let u=r.size-1;if(c!==u){let f=r.entities[u]??0;r.entities[c]=f,r.entityRow.set(f,c);}r.entities[u]=0,r.entityRow.delete(t),r.size--;}}e.entityArchetype[o]=0;let a=e.options.maskWordCount,d=o*a;for(let c=0;c<a;c++)e.entityMask[d+c]=0;e.generations[o]=(e.generations[o]??0)+1&e.options.generationMask,e.freeList.push(o),e.size--;}function lt(n,t){let e=y(n);return p(e,t)}function p(n,t){let e=t&n.options.indexMask;if(e<=0||e>=n.capacity)return false;let o=n.entityArchetype[e]??0,i=n.archetypes[o];if(!i||!i.entityRow.has(t))return false;let s=n.generations[e]??0,r=t>>>n.options.indexBits&n.options.generationMask;return s===r}function tn(n){return n&Y}function nn(n){return n>>>U&X}function en(n,t){return ((t&X)<<U|n&Y)>>>0}function on(n,t){return typeof t!="number"?false:lt(n,t)}var B=null;function rn(n){B=n;}function pt(){return B||{dispatchDestroyObservers:()=>{}}}var M=null;function sn(n){M=n;}function mt(n,t){M&&M(n,t);}exports.A=en;exports.B=on;exports.C=rn;exports.D=sn;exports.E=Lt;exports.F=Tt;exports.G=Ft;exports.H=A;exports.I=P;exports.J=zt;exports.K=Dt;exports.L=Nt;exports.M=Pt;exports.N=qt;exports.O=$t;exports.P=Gt;exports.Q=Ht;exports.a=O;exports.b=R;exports.c=_;exports.d=xt;exports.e=ht;exports.f=At;exports.g=L;exports.h=wt;exports.i=y;exports.j=Et;exports.k=vt;exports.l=St;exports.m=Wt;exports.n=Bt;exports.o=Mt;exports.p=D;exports.q=Ut;exports.r=yt;exports.s=Kt;exports.t=Qt;exports.u=Zt;exports.v=Jt;exports.w=lt;exports.x=p;exports.y=tn;exports.z=nn;//# sourceMappingURL=chunk-4RPFOVQC.cjs.map
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
'use strict';var O="0.4.1";function R(n){return new Uint32Array(n)}function _(n,t){let e=t>>>5;n[e]=(n[e]??0)|1<<(t&31);}function j(n,t){let e=t>>>5;n[e]=(n[e]??0)&~(1<<(t&31));}function m(n,t){let e=t>>>5;return ((n[e]??0)&1<<(t&31))!==0}function w(n){let t=new Uint32Array(n.length);for(let e=0;e<n.length;e++)t[e]=n[e]??0;return t}function v(n){let t=[];for(let e=0;e<n.length;e++)t.push((n[e]??0).toString(16));return t.join(",")}function xt(n){for(let t=0;t<n.length;t++)if((n[t]??0)!==0)return false;return true}function ht(n,t,e,o,i,s){let r=!i;for(let a=0;a<s;a++){let d=n[a]??0,c=t[a]??0,u=e[a]??0,f=o[a]??0;if((d&c)!==c||(d&f)!==0)return false;!r&&(d&u)!==0&&(r=true);}return r}function At(n){let t=[];for(let e=0;e<n.length;e++){let o=n[e]??0;for(;o!==0;){let i=(e<<5)+T(o);t.push(i),o&=o-1;}}return t}function L(n,t,e,o){for(let i=0;i<e;i++){let s=n[t+i]??0;for(;s!==0;){let r=(i<<5)+T(s);o(r),s&=s-1;}}}function wt(n,t,e,o,i,s,r){let a=!r;for(let d=0;d<e;d++){let c=n[t+d]??0,u=o[d]??0,f=i[d]??0,l=s[d]??0;if((c&u)!==u||(c&l)!==0)return false;!a&&(c&f)!==0&&(a=true);}return a}function T(n){return 31-Math.clz32(n&-n)}var C={initialCapacity:1024,maxEntities:1e6,indexBits:24,generationBits:8},Q=256,Z=1,b=new Map;function y(n){let t=b.get(n.id);if(!t)throw new Error(`aiecsjs: world ${n.id} is destroyed or unknown`);if(t.destroyed)throw new Error(`aiecsjs: world ${n.id} is destroyed`);return t}function J(n){b.set(n.id,n);}function tt(n){b.delete(n);}function Et(n){return b.has(n)}function nt(n){let t=n??{},e=t.indexBits??C.indexBits,o=t.generationBits??C.generationBits,i=Q;if(e<1||e>24)throw new Error("aiecsjs: indexBits must be in [1, 24]");if(o<0||o>16)throw new Error("aiecsjs: generationBits must be in [0, 16]");if(e+o>32)throw new Error(`aiecsjs: indexBits (${e}) + generationBits (${o}) must be <= 32`);let s=1<<e,r=Math.max(1,Math.min(t.initialCapacity??C.initialCapacity,s)),a=Math.max(r,Math.min(t.maxEntities??C.maxEntities,s));return {initialCapacity:r,maxEntities:a,indexBits:e,generationBits:o,indexMask:(1<<e)-1,generationMask:o===0?0:(1<<o)-1,maxComponents:i,maskWordCount:Math.ceil(i/32),buffer:t.buffer??null,bufferByteOffset:t.bufferByteOffset??0}}function et(n,t){return {id:0,mask:R(n),size:0,capacity:16,entities:new Uint32Array(16),entityRow:new Map,componentBits:[],edgeAdd:new Int32Array(t).fill(-1),edgeRemove:new Int32Array(t).fill(-1)}}function vt(n){let t=nt(n),e=Z++,o=t.generationBits>8?Uint16Array:Uint8Array,i=new o(t.initialCapacity),s={id:e,capacity:t.initialCapacity,version:O,options:t,size:0,nextFreshIndex:1,freeList:[],generations:i,destroyed:false,componentBitFor:new Map,componentInfoByBit:new Array(t.maxComponents).fill(null),componentStorageByBit:new Array(t.maxComponents).fill(null),nextComponentBit:0,entityArchetype:new Uint32Array(t.initialCapacity),entityMask:new Uint32Array(t.initialCapacity*t.maskWordCount),archetypes:[],archetypeByMaskHash:new Map,queryVersion:0,queries:[],queryMasks:new Map,queryArchetypeCache:[],queryArchetypeStamp:[],bitToQueries:new Map,reactiveBuffers:new Map,observers:[],relationStorage:new Map,sab:t.buffer,readOnly:false},r=et(t.maskWordCount,t.maxComponents);return r.id=0,s.archetypes.push(r),s.archetypeByMaskHash.set(v(r.mask),0),J(s),ot(s)}function ot(n){return {id:n.id,get capacity(){return n.capacity},version:n.version}}function St(n){let t=b.get(n.id);!t||t.destroyed||(t.destroyed=true,t.archetypes=[],t.archetypeByMaskHash.clear(),t.componentInfoByBit=[],t.componentStorageByBit=[],t.queries=[],t.queryMasks.clear(),t.queryArchetypeCache=[],t.observers=[],t.relationStorage.clear(),t.reactiveBuffers.clear(),tt(n.id));}function Wt(n){let t=y(n);t.size=0,t.nextFreshIndex=1,t.freeList=[],t.generations.fill(0),t.entityArchetype.fill(0),t.entityMask.fill(0);for(let e of t.archetypes)e.size=0,e.entityRow.clear();for(let e of t.componentStorageByBit)if(e)if(e.kind==="soa"&&e.soa)for(let o of Object.keys(e.soa))e.soa[o]?.fill(0);else e.kind==="aos"&&e.aos&&e.aos.fill(void 0);t.queryVersion++;for(let e of t.reactiveBuffers.values())e.entered.length=0,e.exited.length=0;}function Bt(n){return y(n).size}function Mt(n){return y(n).capacity}function F(n,t){if(t<=n.capacity)return;if(t>n.options.maxEntities)throw new Error(`aiecsjs: requested capacity ${t} exceeds maxEntities ${n.options.maxEntities}`);let e=n.capacity;for(;e<t;)e=Math.min(e*2,n.options.maxEntities);rt(n,e);}function rt(n,t){let e=n.generations.constructor,o=new e(t);o.set(n.generations),n.generations=o;let i=new Uint32Array(t);i.set(n.entityArchetype),n.entityArchetype=i;let s=n.options.maskWordCount,r=new Uint32Array(t*s);r.set(n.entityMask),n.entityMask=r;for(let a of n.componentStorageByBit)if(a)if(a.kind==="soa"&&a.soa){let d=n.componentInfoByBit[a.bit];d&&it(a.soa,d.fields,t);}else a.kind==="aos"&&a.aos&&(a.aos.length=t);n.capacity=t;}function it(n,t,e){for(let o of t){let i=n[o.name];if(!i)continue;let s=e*o.vectorLen;if(i.length>=s)continue;let r=new o.ctor(s);r.set(i),n[o.name]=r;}}function z(n,t){let e=v(t),o=n.archetypeByMaskHash.get(e);if(o!==void 0)return {archId:o,created:false};let i=n.archetypes.length,s={id:i,mask:w(t),size:0,capacity:16,entities:new Uint32Array(16),entityRow:new Map,componentBits:st(t),edgeAdd:new Int32Array(n.options.maxComponents).fill(-1),edgeRemove:new Int32Array(n.options.maxComponents).fill(-1)};return n.archetypes.push(s),n.archetypeByMaskHash.set(e,i),n.queryVersion++,{archId:i,created:true}}function I(n,t){if(t<=n.capacity)return;let e=n.capacity;for(;e<t;)e*=2;let o=new Uint32Array(e);o.set(n.entities),n.entities=o,n.capacity=e;}function st(n){let t=[];for(let e=0;e<n.length;e++){let o=n[e]??0;for(;o!==0;){let i=o&-o,s=(e<<5)+(31-Math.clz32(i));t.push(s),o&=o-1;}}return t}function D(n,t){let e=n.componentBitFor.get(t.id);if(e!==void 0)return e;if(n.nextComponentBit>=n.options.maxComponents)throw new Error(`aiecsjs: world reached maxComponents=${n.options.maxComponents}`);let o=n.nextComponentBit++;n.componentBitFor.set(t.id,o),n.componentInfoByBit[o]=t;let i;if(t.kind==="soa"){let s={};for(let r of t.fields)s[r.name]=new r.ctor(n.capacity*r.vectorLen);i={kind:"soa",componentId:t.id,bit:o,soa:s};}else t.kind==="aos"?i={kind:"aos",componentId:t.id,bit:o,aos:new Array(n.capacity)}:i={kind:"tag",componentId:t.id,bit:o};return n.componentStorageByBit[o]=i,o}function x(n,t){let e=n.options.maskWordCount,o=new Uint32Array(e),s=(t&n.options.indexMask)*e;for(let r=0;r<e;r++)o[r]=n.entityMask[s+r]??0;return o}function N(n,t,e){let o=n.options.maskWordCount,s=(t&n.options.indexMask)*o;for(let r=0;r<o;r++)n.entityMask[s+r]=e[r]??0;}function g(n,t){return n.componentBitFor.get(t.id)}function Ut(n){if(!n||typeof n!="object")return false;let t=n;return typeof t.id!="number"||typeof t.version!="string"?false:b.has(t.id)}var W=1,at={i8:Int8Array,u8:Uint8Array,i16:Int16Array,u16:Uint16Array,i32:Int32Array,u32:Uint32Array,f32:Float32Array,f64:Float64Array,eid:Uint32Array,bool:Uint8Array},h=new Map;function Lt(n){let t=[];for(let[s,r]of Object.entries(n)){let a,d=1;if(typeof r=="string")a=r;else if(Array.isArray(r)){let[u,f]=r;a=u,d=f;}else throw new TypeError(`aiecsjs: invalid field declaration for "${s}"`);let c=at[a];if(!c)throw new TypeError(`aiecsjs: unknown field type "${a}" for field "${s}"`);t.push({name:s,type:a,vectorLen:d,ctor:c,bytesPerElement:c.BYTES_PER_ELEMENT});}let e=W++,o={id:e,kind:"soa",schema:n,fields:t,factory:null};return h.set(e,o),{__kind:"soa",__id:e,__schema:n}}function Tt(){let n=W++,t={id:n,kind:"tag",schema:null,fields:[],factory:null};return h.set(n,t),{__kind:"tag",__id:n}}function Ft(n){let t=W++,e=n??(()=>({})),o={id:t,kind:"aos",schema:null,fields:[],factory:e};return h.set(t,o),{__kind:"aos",__id:t,__factory:e}}function A(n){let t=h.get(n.__id);if(!t)throw new Error("aiecsjs: component is not registered (call defineComponent/defineTag/defineObjectComponent)");return t}function P(n,t,e,o){let i=y(n);if(i.readOnly)throw new Error("aiecsjs: cannot mutate a read-only world");if(!p(i,t))throw new Error(`aiecsjs: addComponent on dead entity ${t}`);let s=A(e),r=D(i,s),a=x(i,t);if(m(a,r)){o!==void 0&&S(i,t,e,o);return}let d=w(a);_(d,r),G(i,t,d),S(i,t,e,o),ct(i,t,r),V(i,t,r,a,d);}function zt(n,t,e){let o=y(n);if(o.readOnly)throw new Error("aiecsjs: cannot mutate a read-only world");if(!p(o,t))return;let i=A(e),s=g(o,i);if(s===void 0)return;let r=x(o,t);if(!m(r,s))return;let a=w(r);j(a,s),G(o,t,a),dt(o,t,s);let d=t&o.options.indexMask,c=o.componentStorageByBit[s];c?.kind==="soa"&&c.soa?q(c.soa,i.fields,d):c?.kind==="aos"&&c.aos&&(c.aos[d]=void 0),V(o,t,s,r,a);}function Dt(n,t,e){let o=y(n);if(!p(o,t))return false;let i=A(e),s=g(o,i);if(s===void 0)return false;let r=x(o,t);return m(r,s)}function Nt(n,t,e){let o=y(n);if(!p(o,t))return;let i=A(e),s=g(o,i);if(s===void 0)return;let r=x(o,t);if(!m(r,s))return;let a=o.componentStorageByBit[s];if(a){if(a.kind==="soa")return a.soa;if(a.kind==="aos"){let d=t&o.options.indexMask;return a.aos?.[d]}return true}}function Pt(n,t,e,o){let i=y(n);if(i.readOnly)throw new Error("aiecsjs: cannot mutate a read-only world");if(!p(i,t))throw new Error(`aiecsjs: setComponent on dead entity ${t}`);let s=A(e),r=g(i,s);if(r===void 0){P(n,t,e,o);return}let a=x(i,t);if(!m(a,r)){P(n,t,e,o);return}S(i,t,e,o),ft(i,t,r,o);}function S(n,t,e,o){let i=A(e),s=n.componentBitFor.get(i.id);if(s===void 0)return;let r=n.componentStorageByBit[s];if(!r)return;let a=t&n.options.indexMask;if(i.kind==="soa"&&r.soa){if(o==null)return;let d=o;for(let c of i.fields){if(!(c.name in d))continue;let u=r.soa[c.name];if(!u)continue;let f=d[c.name];if(c.vectorLen===1)u[a]=typeof f=="boolean"?f?1:0:Number(f);else if(Array.isArray(f)||ArrayBuffer.isView(f)){let l=a*c.vectorLen,K=f;for(let k=0;k<c.vectorLen;k++)u[l+k]=Number(K[k]??0);}}}else if(i.kind==="aos"&&r.aos){let d=i.factory??(()=>({})),c=r.aos[a];if(c===void 0&&(c=d(),r.aos[a]=c),o&&typeof o=="object"){let u=o,f=c;for(let l of Object.keys(u))l==="__proto__"||l==="constructor"||l==="prototype"||(f[l]=u[l]);}}}function q(n,t,e){for(let o of t){let i=n[o.name];if(i)if(o.vectorLen===1)i[e]=0;else {let s=e*o.vectorLen;for(let r=0;r<o.vectorLen;r++)i[s+r]=0;}}}function $(n,t){let e=n.options.maskWordCount,o=t&n.options.indexMask,i=o*e;L(n.entityMask,i,e,s=>{let r=n.componentStorageByBit[s],a=n.componentInfoByBit[s];r?.kind==="soa"&&r.soa&&a?q(r.soa,a.fields,o):r?.kind==="aos"&&r.aos&&(r.aos[o]=void 0);});}function G(n,t,e){let o=t&n.options.indexMask,i=n.entityArchetype[o]??0,s=n.archetypes[i];if(!s)return;let a=z(n,e).archId,d=n.archetypes[a];if(d){if(a!==i){let c=s.entityRow.get(t);if(c!==void 0){let f=s.size-1;if(c!==f){let l=s.entities[f]??0;s.entities[c]=l,s.entityRow.set(l,c);}s.entities[f]=0,s.entityRow.delete(t),s.size--;}I(d,d.size+1);let u=d.size;d.entities[u]=t,d.entityRow.set(t,u),d.size++,n.entityArchetype[o]=a;}N(n,t,e);}}var E={fireAdd:()=>{},fireRemove:()=>{},fireSet:()=>{}},H=()=>{};function qt(n){H=n;}function V(n,t,e,o,i){H(n,t,e,o,i);}function $t(n){E=n;}function ct(n,t,e){E.fireAdd(n,t,e);}function dt(n,t,e){E.fireRemove(n,t,e);}function ft(n,t,e,o){E.fireSet(n,t,e,o);}function Gt(n){return h.get(n)}function Ht(){return Array.from(h.values())}var U=24,ut=8,Y=(1<<U)-1,X=(1<<ut)-1;function yt(n,t,e){return ((t&e.generationMask)<<e.indexBits|n&e.indexMask)>>>0}function Kt(n,t){return n&t.indexMask}function Qt(n,t){return n>>>t.indexBits&t.generationMask}function Zt(n){let t=y(n);if(t.readOnly)throw new Error("aiecsjs: cannot createEntity on a read-only world (worker-attached)");let e;if(t.freeList.length>0)e=t.freeList.pop();else {if(t.nextFreshIndex>=t.options.maxEntities)throw new Error(`aiecsjs: reached maxEntities ${t.options.maxEntities}`);t.nextFreshIndex>=t.capacity&&F(t,t.nextFreshIndex+1),e=t.nextFreshIndex++;}let o=t.generations[e]??0,i=yt(e,o,t.options),s=t.archetypes[0];if(!s)throw new Error("aiecsjs: missing empty archetype");I(s,s.size+1);let r=s.size;s.entities[r]=i,s.entityRow.set(i,r),s.size++,t.entityArchetype[e]=0;let a=t.options.maskWordCount,d=e*a;for(let c=0;c<a;c++)t.entityMask[d+c]=0;return t.size++,i}function Jt(n,t){let e=y(n);if(e.readOnly)throw new Error("aiecsjs: cannot destroyEntity on a read-only world");if(!p(e,t))return;let o=t&e.options.indexMask,{dispatchDestroyObservers:i}=pt();i(e,t),mt(e,t),$(e,t);let s=e.entityArchetype[o]??0,r=e.archetypes[s];if(r){let c=r.entityRow.get(t);if(c!==void 0){let u=r.size-1;if(c!==u){let f=r.entities[u]??0;r.entities[c]=f,r.entityRow.set(f,c);}r.entities[u]=0,r.entityRow.delete(t),r.size--;}}e.entityArchetype[o]=0;let a=e.options.maskWordCount,d=o*a;for(let c=0;c<a;c++)e.entityMask[d+c]=0;e.generations[o]=(e.generations[o]??0)+1&e.options.generationMask,e.freeList.push(o),e.size--;}function lt(n,t){let e=y(n);return p(e,t)}function p(n,t){let e=t&n.options.indexMask;if(e<=0||e>=n.capacity)return false;let o=n.entityArchetype[e]??0,i=n.archetypes[o];if(!i||!i.entityRow.has(t))return false;let s=n.generations[e]??0,r=t>>>n.options.indexBits&n.options.generationMask;return s===r}function tn(n){return n&Y}function nn(n){return n>>>U&X}function en(n,t){return ((t&X)<<U|n&Y)>>>0}function on(n,t){return typeof t!="number"?false:lt(n,t)}var B=null;function rn(n){B=n;}function pt(){return B||{dispatchDestroyObservers:()=>{}}}var M=null;function sn(n){M=n;}function mt(n,t){M&&M(n,t);}exports.A=en;exports.B=on;exports.C=rn;exports.D=sn;exports.E=Lt;exports.F=Tt;exports.G=Ft;exports.H=A;exports.I=P;exports.J=zt;exports.K=Dt;exports.L=Nt;exports.M=Pt;exports.N=qt;exports.O=$t;exports.P=Gt;exports.Q=Ht;exports.a=O;exports.b=R;exports.c=_;exports.d=xt;exports.e=ht;exports.f=At;exports.g=L;exports.h=wt;exports.i=y;exports.j=Et;exports.k=vt;exports.l=St;exports.m=Wt;exports.n=Bt;exports.o=Mt;exports.p=D;exports.q=Ut;exports.r=yt;exports.s=Kt;exports.t=Qt;exports.u=Zt;exports.v=Jt;exports.w=lt;exports.x=p;exports.y=tn;exports.z=nn;//# sourceMappingURL=chunk-7NNM4PGP.cjs.map
|
|
2
|
+
//# sourceMappingURL=chunk-7NNM4PGP.cjs.map
|