aiecsjs 0.1.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.
Files changed (56) hide show
  1. package/CHANGELOG.md +102 -0
  2. package/LICENSE +21 -0
  3. package/README.md +881 -0
  4. package/README_ZHTW.md +891 -0
  5. package/STABILITY.md +145 -0
  6. package/STABILITY_ZHTW.md +145 -0
  7. package/api.json +1087 -0
  8. package/dist/commands.cjs +2 -0
  9. package/dist/commands.cjs.map +1 -0
  10. package/dist/commands.d.cts +7 -0
  11. package/dist/commands.d.ts +7 -0
  12. package/dist/commands.js +2 -0
  13. package/dist/commands.js.map +1 -0
  14. package/dist/index.cjs +2 -0
  15. package/dist/index.cjs.map +1 -0
  16. package/dist/index.d.cts +43 -0
  17. package/dist/index.d.ts +43 -0
  18. package/dist/index.js +2 -0
  19. package/dist/index.js.map +1 -0
  20. package/dist/loop.cjs +2 -0
  21. package/dist/loop.cjs.map +1 -0
  22. package/dist/loop.d.cts +13 -0
  23. package/dist/loop.d.ts +13 -0
  24. package/dist/loop.js +2 -0
  25. package/dist/loop.js.map +1 -0
  26. package/dist/observers.cjs +2 -0
  27. package/dist/observers.cjs.map +1 -0
  28. package/dist/observers.d.cts +8 -0
  29. package/dist/observers.d.ts +8 -0
  30. package/dist/observers.js +2 -0
  31. package/dist/observers.js.map +1 -0
  32. package/dist/relations.cjs +2 -0
  33. package/dist/relations.cjs.map +1 -0
  34. package/dist/relations.d.cts +11 -0
  35. package/dist/relations.d.ts +11 -0
  36. package/dist/relations.js +2 -0
  37. package/dist/relations.js.map +1 -0
  38. package/dist/serialize.cjs +2 -0
  39. package/dist/serialize.cjs.map +1 -0
  40. package/dist/serialize.d.cts +9 -0
  41. package/dist/serialize.d.ts +9 -0
  42. package/dist/serialize.js +2 -0
  43. package/dist/serialize.js.map +1 -0
  44. package/dist/types-Bbv2u6kb.d.cts +227 -0
  45. package/dist/types-Bbv2u6kb.d.ts +227 -0
  46. package/dist/worker.cjs +2 -0
  47. package/dist/worker.cjs.map +1 -0
  48. package/dist/worker.d.cts +10 -0
  49. package/dist/worker.d.ts +10 -0
  50. package/dist/worker.js +2 -0
  51. package/dist/worker.js.map +1 -0
  52. package/docs/MIGRATION.md +252 -0
  53. package/docs/MIGRATION_ZHTW.md +252 -0
  54. package/llms-full.txt +579 -0
  55. package/llms.txt +31 -0
  56. package/package.json +93 -0
package/STABILITY.md ADDED
@@ -0,0 +1,145 @@
1
+ # Stability Contract
2
+
3
+ [English](STABILITY.md) | [繁體中文](STABILITY_ZHTW.md)
4
+
5
+ This document is the per-export stability promise for `aiecsjs`. It is the contract AI tools and human users can rely on when pinning versions and writing import paths.
6
+
7
+ ## Policy
8
+
9
+ aiecsjs follows [semver](https://semver.org/). Within the **0.x** series:
10
+ - **`stable`** exports do not change in breaking ways across minor versions (e.g. 0.1 → 0.2).
11
+ - **`experimental`** exports may change shape, name, or behaviour in any minor release. Pin the exact version if you depend on them.
12
+ - **`internal`** is not part of the API. May change in any patch release. Do not import.
13
+ - **`deprecated`** still works as documented but is scheduled for removal. The deprecation notice states the target version.
14
+
15
+ At **1.0**, the `stable` surface freezes for the entire 1.x series.
16
+
17
+ The full machine-readable export list lives in [`api.json`](./api.json), with the `stability` and `since` fields on every entry.
18
+
19
+ ## By module
20
+
21
+ The **root** entry (`aiecsjs`) is the stable core: world, entity, component, query, system. Everything under a sub-path (`aiecsjs/<name>`) is a **utility or adapter sub-path** — useful but non-essential, decoupled from the core, and importable a la carte. Tree-shakers should be able to drop any sub-path the application does not import.
22
+
23
+ ### `aiecsjs` (root core)
24
+
25
+ | Export | Stability | Since | Notes |
26
+ |---|---|---|---|
27
+ | `createWorld` | stable | 0.1.0 | |
28
+ | `destroyWorld` | stable | 0.1.0 | |
29
+ | `resetWorld` | stable | 0.1.0 | |
30
+ | `getWorldSize` | stable | 0.1.0 | |
31
+ | `getWorldCapacity` | stable | 0.1.0 | |
32
+ | `createEntity` | stable | 0.1.0 | |
33
+ | `destroyEntity` | stable | 0.1.0 | |
34
+ | `entityExists` | stable | 0.1.0 | |
35
+ | `getEntityIndex` | stable | 0.1.0 | |
36
+ | `getEntityGeneration` | stable | 0.1.0 | |
37
+ | `packEntity` | stable | 0.1.0 | |
38
+ | `defineComponent` | stable | 0.1.0 | |
39
+ | `defineTag` | stable | 0.1.0 | |
40
+ | `defineObjectComponent` | stable | 0.1.0 | AoS components are main-thread only; not SAB-shareable. |
41
+ | `addComponent` | stable | 0.1.0 | Argument order `(world, eid, component, init?)` is final. |
42
+ | `removeComponent` | stable | 0.1.0 | |
43
+ | `hasComponent` | stable | 0.1.0 | |
44
+ | `getComponent` | stable | 0.1.0 | |
45
+ | `setComponent` | stable | 0.1.0 | |
46
+ | `Types` | stable | 0.1.0 | Constant map; field names are part of the contract. |
47
+ | `defineQuery` | stable | 0.1.0 | |
48
+ | `runQuery` | stable | 0.1.0 | |
49
+ | `forEachEntity` | stable | 0.1.0 | |
50
+ | `iterQuery` | stable | 0.1.0 | |
51
+ | `enterQuery` | stable | 0.1.0 | |
52
+ | `exitQuery` | stable | 0.1.0 | |
53
+ | `queryArchetypes` | **experimental** | 0.1.0 | `Archetype.id` is opaque-internal; the shape of `Archetype` may grow. |
54
+ | `pipe` | stable | 0.1.0 | |
55
+ | `VERSION` | stable | 0.1.0 | |
56
+ | `IS_SAB_SUPPORTED` | stable | 0.1.0 | |
57
+ | `isWorld` | stable | 0.1.0 | |
58
+ | `isEntity` | stable | 0.1.0 | |
59
+
60
+ ### `aiecsjs/loop` (utility sub-path)
61
+
62
+ Fixed-timestep accumulator loop. Drop this sub-path if you already drive frame updates yourself (PixiJS `Ticker`, requestAnimationFrame, server-side simulation).
63
+
64
+ | Export | Stability | Since | Notes |
65
+ |---|---|---|---|
66
+ | `createLoop` | stable | 0.1.0 | |
67
+
68
+ ### `aiecsjs/commands` (utility sub-path)
69
+
70
+ Deferred structural mutations so systems can mutate world structure mid-iteration without invalidating queries.
71
+
72
+ | Export | Stability | Since | Notes |
73
+ |---|---|---|---|
74
+ | `createCommandBuffer` | stable | 0.1.0 | |
75
+ | `flush` | stable | 0.1.0 | |
76
+ | `withCommandBuffer` | stable | 0.1.0 | |
77
+
78
+ ### `aiecsjs/observers` (utility sub-path)
79
+
80
+ Component lifecycle hooks. The core does not require observers; install this sub-path only if a system needs add/remove/set callbacks.
81
+
82
+ | Export | Stability | Since | Notes |
83
+ |---|---|---|---|
84
+ | `observe` | stable | 0.1.0 | |
85
+ | `onAdd` | stable | 0.1.0 | |
86
+ | `onRemove` | stable | 0.1.0 | |
87
+ | `onSet` | stable | 0.1.0 | |
88
+
89
+ ### `aiecsjs/serialize` (utility sub-path)
90
+
91
+ | Export | Stability | Since | Notes |
92
+ |---|---|---|---|
93
+ | `serializeWorld` | stable | 0.1.0 | Binary format includes a version stamp. |
94
+ | `deserializeWorld` | stable | 0.1.0 | |
95
+ | `toJSON` | stable | 0.1.0 | |
96
+ | `fromJSON` | stable | 0.1.0 | |
97
+ | `createDeltaSerializer` | **experimental** | 0.1.0 | Wire format may change before 1.0. |
98
+
99
+ ### `aiecsjs/worker` (experimental adapter sub-path)
100
+
101
+ The entire subpath is **experimental** in 0.1. **In 0.1 the implementation is a snapshot-copy transport** — serialize the world into the SAB on send, deserialize into a fresh world on adopt. It is not true shared-memory column aliasing. The API surface matches the documented contract; true shared columns ship in 0.2. Snapshot layout and capability flags may change.
102
+
103
+ | Export | Stability | Since | Notes |
104
+ |---|---|---|---|
105
+ | `transferableSnapshot` | experimental | 0.1.0 | |
106
+ | `adoptSnapshot` | experimental | 0.1.0 | |
107
+ | `attachWorld` | experimental | 0.1.0 | |
108
+ | `detachWorld` | experimental | 0.1.0 | |
109
+
110
+ ### `aiecsjs/relations` (experimental adapter sub-path)
111
+
112
+ The entire subpath is **experimental** in 0.1 but implemented. Targeted for stabilization in 0.3.
113
+
114
+ | Export | Stability | Since | Notes |
115
+ |---|---|---|---|
116
+ | `defineRelation` | experimental | 0.1.0 | |
117
+ | `addRelation` | experimental | 0.1.0 | |
118
+ | `removeRelation` | experimental | 0.1.0 | |
119
+ | `getRelationTargets` | experimental | 0.1.0 | |
120
+ | `ChildOf` (constant) | experimental | 0.1.0 | Built-in exclusive relation. |
121
+
122
+ ### `aiecsjs/internal/*`
123
+
124
+ Everything under this prefix is **internal**. It exists for the implementation's own use and may break in any release. Do not import.
125
+
126
+ ## Roadmap
127
+
128
+ | Version | Focus | Stability shift |
129
+ |---|---|---|
130
+ | 0.1.x | Core surface (world, entity, component, query, system, loop, commands, observers, serialize) | Initial publish; all marked experimental at the package level but per-export stable where listed. |
131
+ | 0.2.x | Relations & hierarchies | `aiecsjs/relations` becomes implemented; still experimental. |
132
+ | 0.3.x | Hardening, relations stabilization, multi-threading polish | `aiecsjs/relations` and `aiecsjs/worker` → stable. |
133
+ | 1.0.0 | API freeze | All `stable` exports frozen for 1.x. |
134
+
135
+ ## How to check stability at runtime
136
+
137
+ ```ts
138
+ import { VERSION } from 'aiecsjs'
139
+
140
+ if (VERSION.startsWith('0.')) {
141
+ console.warn('aiecsjs is in pre-1.0; API surface may shift')
142
+ }
143
+ ```
144
+
145
+ For programmatic introspection, parse [`api.json`](./api.json) — each entry has `stability` and `since` fields.
@@ -0,0 +1,145 @@
1
+ # 穩定度契約
2
+
3
+ [English](STABILITY.md) | [繁體中文](STABILITY_ZHTW.md)
4
+
5
+ 本文件為 `aiecsjs` 中各匯出的穩定度承諾。AI 工具與人類使用者可依此契約來鎖定版本與書寫 import 路徑。
6
+
7
+ ## 規範
8
+
9
+ aiecsjs 遵循 [semver](https://semver.org/)。在 **0.x** 系列內:
10
+ - **`stable`** 匯出於 minor 版本之間(例如 0.1 → 0.2)不會破壞性變更。
11
+ - **`experimental`** 匯出可能在任何 minor 釋出時改變形狀、命名或行為。若有依賴請鎖定明確版本。
12
+ - **`internal`** 不屬於 API 表面,可能在任何 patch 釋出時改變。請勿匯入。
13
+ - **`deprecated`** 仍可正常運作但已排入移除計畫。棄用通知中會載明目標版本。
14
+
15
+ 至 **1.0** 時,`stable` 表面為整個 1.x 系列凍結。
16
+
17
+ 完整機器可讀的匯出清單位於 [`api.json`](./api.json),每筆都有 `stability` 與 `since` 欄位。
18
+
19
+ ## 依模組分類
20
+
21
+ **根目錄** entry(`aiecsjs`)為穩定核心:world、entity、component、query、system。任何 sub-path(`aiecsjs/<名稱>`)為 **utility 或 adapter sub-path** — 實用但非核心,與 core 解耦,可單獨 a la carte import。Tree-shaker 應能丟掉未引用的任何 sub-path。
22
+
23
+ ### `aiecsjs`(根核心)
24
+
25
+ | 匯出 | 穩定度 | 起始版本 | 備註 |
26
+ |---|---|---|---|
27
+ | `createWorld` | stable | 0.1.0 | |
28
+ | `destroyWorld` | stable | 0.1.0 | |
29
+ | `resetWorld` | stable | 0.1.0 | |
30
+ | `getWorldSize` | stable | 0.1.0 | |
31
+ | `getWorldCapacity` | stable | 0.1.0 | |
32
+ | `createEntity` | stable | 0.1.0 | |
33
+ | `destroyEntity` | stable | 0.1.0 | |
34
+ | `entityExists` | stable | 0.1.0 | |
35
+ | `getEntityIndex` | stable | 0.1.0 | |
36
+ | `getEntityGeneration` | stable | 0.1.0 | |
37
+ | `packEntity` | stable | 0.1.0 | |
38
+ | `defineComponent` | stable | 0.1.0 | |
39
+ | `defineTag` | stable | 0.1.0 | |
40
+ | `defineObjectComponent` | stable | 0.1.0 | AoS 元件僅限主執行緒;不可跨 SAB 共享。 |
41
+ | `addComponent` | stable | 0.1.0 | 參數順序 `(world, eid, component, init?)` 為最終定義。 |
42
+ | `removeComponent` | stable | 0.1.0 | |
43
+ | `hasComponent` | stable | 0.1.0 | |
44
+ | `getComponent` | stable | 0.1.0 | |
45
+ | `setComponent` | stable | 0.1.0 | |
46
+ | `Types` | stable | 0.1.0 | 常數對應表;欄位名稱屬於契約。 |
47
+ | `defineQuery` | stable | 0.1.0 | |
48
+ | `runQuery` | stable | 0.1.0 | |
49
+ | `forEachEntity` | stable | 0.1.0 | |
50
+ | `iterQuery` | stable | 0.1.0 | |
51
+ | `enterQuery` | stable | 0.1.0 | |
52
+ | `exitQuery` | stable | 0.1.0 | |
53
+ | `queryArchetypes` | **experimental** | 0.1.0 | `Archetype.id` 為 opaque 內部值;`Archetype` 的形狀可能增加欄位。 |
54
+ | `pipe` | stable | 0.1.0 | |
55
+ | `VERSION` | stable | 0.1.0 | |
56
+ | `IS_SAB_SUPPORTED` | stable | 0.1.0 | |
57
+ | `isWorld` | stable | 0.1.0 | |
58
+ | `isEntity` | stable | 0.1.0 | |
59
+
60
+ ### `aiecsjs/loop`(utility sub-path)
61
+
62
+ 定步長累加迴圈。若應用層已自有 frame 更新驅動(PixiJS `Ticker`、requestAnimationFrame、伺服端模擬),可直接略過本 sub-path。
63
+
64
+ | 匯出 | 穩定度 | 起始版本 | 備註 |
65
+ |---|---|---|---|
66
+ | `createLoop` | stable | 0.1.0 | |
67
+
68
+ ### `aiecsjs/commands`(utility sub-path)
69
+
70
+ 延後的結構性變更,讓系統可在迭代中安全改動 world 結構而不會讓查詢失效。
71
+
72
+ | 匯出 | 穩定度 | 起始版本 | 備註 |
73
+ |---|---|---|---|
74
+ | `createCommandBuffer` | stable | 0.1.0 | |
75
+ | `flush` | stable | 0.1.0 | |
76
+ | `withCommandBuffer` | stable | 0.1.0 | |
77
+
78
+ ### `aiecsjs/observers`(utility sub-path)
79
+
80
+ 元件生命週期 hook。Core 不依賴 observers;只在系統需要 add/remove/set callback 時才安裝本 sub-path。
81
+
82
+ | 匯出 | 穩定度 | 起始版本 | 備註 |
83
+ |---|---|---|---|
84
+ | `observe` | stable | 0.1.0 | |
85
+ | `onAdd` | stable | 0.1.0 | |
86
+ | `onRemove` | stable | 0.1.0 | |
87
+ | `onSet` | stable | 0.1.0 | |
88
+
89
+ ### `aiecsjs/serialize`(utility sub-path)
90
+
91
+ | 匯出 | 穩定度 | 起始版本 | 備註 |
92
+ |---|---|---|---|
93
+ | `serializeWorld` | stable | 0.1.0 | 二進位格式包含版本戳記。 |
94
+ | `deserializeWorld` | stable | 0.1.0 | |
95
+ | `toJSON` | stable | 0.1.0 | |
96
+ | `fromJSON` | stable | 0.1.0 | |
97
+ | `createDeltaSerializer` | **experimental** | 0.1.0 | Wire format 在 1.0 之前可能改變。 |
98
+
99
+ ### `aiecsjs/worker`(experimental adapter sub-path)
100
+
101
+ 整個 subpath 在 0.1 為 **experimental**。**0.1 的實作為 snapshot-copy 傳輸**——傳送時將 world 序列化進 SAB,接收端反序列化成全新 world,並非真正的共享記憶體欄位 aliasing。API 表面符合文件契約;真正的共享欄位將於 0.2 推出。Snapshot 佈局與能力旗標可能改變。
102
+
103
+ | 匯出 | 穩定度 | 起始版本 | 備註 |
104
+ |---|---|---|---|
105
+ | `transferableSnapshot` | experimental | 0.1.0 | |
106
+ | `adoptSnapshot` | experimental | 0.1.0 | |
107
+ | `attachWorld` | experimental | 0.1.0 | |
108
+ | `detachWorld` | experimental | 0.1.0 | |
109
+
110
+ ### `aiecsjs/relations`(experimental adapter sub-path)
111
+
112
+ 整個 subpath 在 0.1 為 **experimental** 但已實作。預期於 0.3 穩定。
113
+
114
+ | 匯出 | 穩定度 | 起始版本 | 備註 |
115
+ |---|---|---|---|
116
+ | `defineRelation` | experimental | 0.1.0 | |
117
+ | `addRelation` | experimental | 0.1.0 | |
118
+ | `removeRelation` | experimental | 0.1.0 | |
119
+ | `getRelationTargets` | experimental | 0.1.0 | |
120
+ | `ChildOf`(常數) | experimental | 0.1.0 | 內建獨佔關係。 |
121
+
122
+ ### `aiecsjs/internal/*`
123
+
124
+ 此前綴底下的所有內容皆為 **internal**。它存在於實作自用,可能在任何 release 變更。請勿匯入。
125
+
126
+ ## Roadmap
127
+
128
+ | 版本 | 焦點 | 穩定度變動 |
129
+ |---|---|---|
130
+ | 0.1.x | 核心表面(world、entity、component、query、system、loop、commands、observers、serialize) | 初次發佈;package 整體標 experimental,但各 export 表中列為 stable 者皆穩定。 |
131
+ | 0.2.x | Relations 與階層 | `aiecsjs/relations` 落實實作;仍為 experimental。 |
132
+ | 0.3.x | 硬化、Relations 穩定、多執行緒打磨 | `aiecsjs/relations` 與 `aiecsjs/worker` → stable。 |
133
+ | 1.0.0 | API 凍結 | 所有 `stable` 匯出於 1.x 系列凍結。 |
134
+
135
+ ## 在執行時檢查穩定度
136
+
137
+ ```ts
138
+ import { VERSION } from 'aiecsjs'
139
+
140
+ if (VERSION.startsWith('0.')) {
141
+ console.warn('aiecsjs 處於 1.0 前;API 表面可能調整')
142
+ }
143
+ ```
144
+
145
+ 如需程式化檢視,請解析 [`api.json`](./api.json) — 每筆都有 `stability` 與 `since` 欄位。