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.
- package/CHANGELOG.md +102 -0
- package/LICENSE +21 -0
- package/README.md +881 -0
- package/README_ZHTW.md +891 -0
- package/STABILITY.md +145 -0
- package/STABILITY_ZHTW.md +145 -0
- package/api.json +1087 -0
- package/dist/commands.cjs +2 -0
- package/dist/commands.cjs.map +1 -0
- package/dist/commands.d.cts +7 -0
- package/dist/commands.d.ts +7 -0
- package/dist/commands.js +2 -0
- package/dist/commands.js.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +43 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/loop.cjs +2 -0
- package/dist/loop.cjs.map +1 -0
- package/dist/loop.d.cts +13 -0
- package/dist/loop.d.ts +13 -0
- package/dist/loop.js +2 -0
- package/dist/loop.js.map +1 -0
- package/dist/observers.cjs +2 -0
- package/dist/observers.cjs.map +1 -0
- package/dist/observers.d.cts +8 -0
- package/dist/observers.d.ts +8 -0
- package/dist/observers.js +2 -0
- package/dist/observers.js.map +1 -0
- package/dist/relations.cjs +2 -0
- package/dist/relations.cjs.map +1 -0
- package/dist/relations.d.cts +11 -0
- package/dist/relations.d.ts +11 -0
- package/dist/relations.js +2 -0
- package/dist/relations.js.map +1 -0
- package/dist/serialize.cjs +2 -0
- package/dist/serialize.cjs.map +1 -0
- package/dist/serialize.d.cts +9 -0
- package/dist/serialize.d.ts +9 -0
- package/dist/serialize.js +2 -0
- package/dist/serialize.js.map +1 -0
- package/dist/types-Bbv2u6kb.d.cts +227 -0
- package/dist/types-Bbv2u6kb.d.ts +227 -0
- package/dist/worker.cjs +2 -0
- package/dist/worker.cjs.map +1 -0
- package/dist/worker.d.cts +10 -0
- package/dist/worker.d.ts +10 -0
- package/dist/worker.js +2 -0
- package/dist/worker.js.map +1 -0
- package/docs/MIGRATION.md +252 -0
- package/docs/MIGRATION_ZHTW.md +252 -0
- package/llms-full.txt +579 -0
- package/llms.txt +31 -0
- package/package.json +93 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
[English](CHANGELOG.md) | [繁體中文](CHANGELOG_ZHTW.md)
|
|
4
|
+
|
|
5
|
+
All notable changes to `aiecsjs` are recorded in this file.
|
|
6
|
+
|
|
7
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
8
|
+
|
|
9
|
+
## [Unreleased]
|
|
10
|
+
|
|
11
|
+
### Planned for 0.2
|
|
12
|
+
|
|
13
|
+
- Implement `aiecsjs/relations`: `defineRelation`, `addRelation`, `removeRelation`, `getRelationTargets`, `ChildOf`.
|
|
14
|
+
- Add `pipeAsync` for async system composition.
|
|
15
|
+
- Doc-test harness so README code blocks are mechanically verified.
|
|
16
|
+
|
|
17
|
+
### Planned for 0.3
|
|
18
|
+
|
|
19
|
+
- Promote `aiecsjs/relations` and `aiecsjs/worker` to `stable`.
|
|
20
|
+
- Stabilize the network delta wire format.
|
|
21
|
+
- Add automated benchmark suite committed to repo.
|
|
22
|
+
|
|
23
|
+
### Planned for 1.0
|
|
24
|
+
|
|
25
|
+
- API freeze for the 1.x line.
|
|
26
|
+
- Drop the experimental status label.
|
|
27
|
+
|
|
28
|
+
## [0.1.1] - 2026-05-28
|
|
29
|
+
|
|
30
|
+
The "documentation honesty + test backstop" release. No new public APIs; this is the version of 0.1.0 that ships with the public surface, the documentation, and the test coverage in agreement.
|
|
31
|
+
|
|
32
|
+
### Fixed
|
|
33
|
+
|
|
34
|
+
- `destroyEntity` now clears the SoA columns and undefines the AoS slots that the destroyed entity owned. Previously only the entity mask was cleared, leaving stale data at the slot visible to debug snapshots and the serialisation path. Public `hasComponent` / query behaviour was already correct, so user-visible behaviour is unchanged; this closes the gap surfaced by the new `destroyEntity zeroes the destroyed entity’s SoA slot` test.
|
|
35
|
+
|
|
36
|
+
### Changed (docs hygiene)
|
|
37
|
+
|
|
38
|
+
- README and STABILITY now describe `aiecsjs/worker` honestly as a snapshot-copy transport for 0.1; true shared columns remain a 0.2 target. README description and `package.json` description updated accordingly.
|
|
39
|
+
- README clarifies that 0.1 `EntityId` is a bare slot index; internal generation is tracked for slot reuse but not encoded in the ID. ABA-safe `EntityRef` is on the 0.2 roadmap.
|
|
40
|
+
- Sub-paths (`loop` / `commands` / `observers` / `serialize` / `worker` / `relations`) re-positioned in STABILITY as utility / adapter sub-paths; the root `aiecsjs` is the stable core surface. Tree-shakers should drop any sub-path the app does not import.
|
|
41
|
+
- README adds a "What aiecsjs does NOT do" section listing explicit non-goals (system scheduler, render binding, physics, network replication, value-predicate reactive queries, prefab/inheritance).
|
|
42
|
+
- Language version filenames renamed from `*.zh-TW.md` to `*_ZHTW.md`. Cross-links, `llms.txt`, and `package.json` `files` updated. Future language variants follow the same uppercase ISO 639-1 pattern.
|
|
43
|
+
- Removed emoji from documentation prose (language switchers, status banners).
|
|
44
|
+
|
|
45
|
+
### Build & tooling
|
|
46
|
+
|
|
47
|
+
- tsup build now runs with `minify: true`.
|
|
48
|
+
- `size-limit` added as a dev dependency; per-export gzip budgets enforced via `npm run size`. Current measurements: core 5.49 kB, all sub-paths combined 12.6 kB gzip.
|
|
49
|
+
- GitHub Actions CI workflow added: typecheck → test → build → size check on push and PR to `main`.
|
|
50
|
+
- `prepublishOnly` now runs typecheck, tests, build, and the size budget gate before allowing publish.
|
|
51
|
+
|
|
52
|
+
### Tests
|
|
53
|
+
|
|
54
|
+
- Test count increased from 84 to 140. New file `tests/internal/bitmask.test.ts` covers the multi-word bitmask helpers in isolation (27 cases including `matches` truth table). New file `tests/multi-world.test.ts` covers per-world isolation when the same component is reused. Existing files gained: naive linear-filter cross-check against `runQuery` for all clause combinations, archetype migration boundary path, query mid-traversal stability and lazy cache behaviour, SoA field clear assertions on both `removeComponent` and `destroyEntity`, SoA vector-length round trip, `maxEntities` / `maxComponents` boundary throws, observer fan-out for destroy across multiple components, `onSet` value content, query observer ignores unrelated mutation, relation source-side destroy cleanup, exclusive relation storage resize, worker `readOnly` rejects add / remove / destroy, serialize `options.components` filter, `onUnknownVersion: throw | best-effort` paths, command buffer placeholder resolves into a queryable entity, slot-reuse limitation made explicit. Loop tests rewritten on top of `vi.useFakeTimers({ toFake: ['performance', ...] })` for deterministic dt validation.
|
|
55
|
+
|
|
56
|
+
## [0.1.0] - 2026-05-27
|
|
57
|
+
|
|
58
|
+
**Initial release.** All 50 documented exports across 7 modules are implemented and covered by 84 passing Vitest behaviour tests. Built with tsup to dual ESM + CJS, ships `.d.ts` declarations and source maps.
|
|
59
|
+
|
|
60
|
+
### Implementation notes
|
|
61
|
+
|
|
62
|
+
- **Storage**: world-level TypedArray columns per SoA component field, sized to world capacity. Archetypes track entity membership (a `Uint32Array entities[]`) but do not own column data. This makes archetype migration O(1) and lets `Position.x[eid]` work directly without per-archetype indirection. Trade-off: iteration over archetypes reads columns at potentially non-contiguous offsets; for hot data this stays in L1.
|
|
63
|
+
- **EntityId is unversioned in 0.1**: `EntityId` is the entity index. Generation is tracked internally for slot reuse but not encoded in the ID. `getEntityIndex` / `getEntityGeneration` / `packEntity` are identity helpers. ABA-safe references via a separate `EntityRef` type are planned for 0.2.
|
|
64
|
+
- **Bitmask queries**: multi-word Uint32 masks, default 8 words (256 components). Per-world bit allocation, global component identity.
|
|
65
|
+
- **Worker / SAB**: 0.1 implements snapshot-copy semantics (serialize-into-SAB on send, deserialize-on-adopt) rather than true shared-memory column aliasing. The API surface matches the documented contract; true shared columns ship in 0.2.
|
|
66
|
+
- **Binary serialization**: a JSON payload wrapped in a 4-byte magic + version header. Compact binary column encoding is planned for 0.2.
|
|
67
|
+
|
|
68
|
+
### Added
|
|
69
|
+
|
|
70
|
+
- `README.md` (English) and `README_ZHTW.md` (Traditional Chinese) with quick start, guide, API reference, performance notes, multi-threading guide, WebGPU interop section, serialization guide, migration guides, and "For AI Agents" section.
|
|
71
|
+
- `llms.txt` — Jeremy Howard format AI-discovery file.
|
|
72
|
+
- `llms-full.txt` — Single-file complete reference for LLM consumption.
|
|
73
|
+
- `api.json` — Machine-readable export manifest with stability and `since` fields on every entry.
|
|
74
|
+
- `STABILITY.md` and `STABILITY_ZHTW.md` — Per-export stability contract.
|
|
75
|
+
- `docs/MIGRATION.md` and `docs/MIGRATION_ZHTW.md` — Migration guides from bitECS 0.4, miniplex 2.0, and ECSY.
|
|
76
|
+
|
|
77
|
+
### API surface declared
|
|
78
|
+
|
|
79
|
+
- Core: `createWorld`, `destroyWorld`, `resetWorld`, `getWorldSize`, `getWorldCapacity`.
|
|
80
|
+
- Entity: `createEntity`, `destroyEntity`, `entityExists`, `getEntityIndex`, `getEntityGeneration`, `packEntity`.
|
|
81
|
+
- Component: `defineComponent`, `defineTag`, `defineObjectComponent`, `addComponent`, `removeComponent`, `hasComponent`, `getComponent`, `setComponent`, `Types`.
|
|
82
|
+
- Query: `defineQuery`, `runQuery`, `forEachEntity`, `iterQuery`, `enterQuery`, `exitQuery`, `queryArchetypes` (experimental).
|
|
83
|
+
- System: `pipe`.
|
|
84
|
+
- Subpath `aiecsjs/loop`: `createLoop`.
|
|
85
|
+
- Subpath `aiecsjs/commands`: `createCommandBuffer`, `flush`, `withCommandBuffer`.
|
|
86
|
+
- Subpath `aiecsjs/observers`: `observe`, `onAdd`, `onRemove`, `onSet`.
|
|
87
|
+
- Subpath `aiecsjs/serialize`: `serializeWorld`, `deserializeWorld`, `toJSON`, `fromJSON`, `createDeltaSerializer` (experimental).
|
|
88
|
+
- Subpath `aiecsjs/worker` (experimental): `transferableSnapshot`, `adoptSnapshot`, `attachWorld`, `detachWorld`.
|
|
89
|
+
- Subpath `aiecsjs/relations` (experimental, not implemented): `defineRelation`, `addRelation`, `removeRelation`, `getRelationTargets`, `ChildOf`.
|
|
90
|
+
- Utility: `VERSION`, `IS_SAB_SUPPORTED`, `isWorld`, `isEntity`.
|
|
91
|
+
|
|
92
|
+
### Known limitations in 0.1
|
|
93
|
+
|
|
94
|
+
- `aiecsjs/relations` and `aiecsjs/worker` are implemented but tagged experimental; API may shift.
|
|
95
|
+
- Network delta wire format is JSON-based; binary patch format is planned for 0.2.
|
|
96
|
+
- AoS components are main-thread only; cannot be shared via SharedArrayBuffer.
|
|
97
|
+
- No automatic system scheduler / parallel execution.
|
|
98
|
+
- Worker/SAB uses snapshot-copy in 0.1 rather than true shared-memory aliasing.
|
|
99
|
+
- EntityId is unversioned; ABA-safe references arrive with `EntityRef` in 0.2.
|
|
100
|
+
|
|
101
|
+
[Unreleased]: https://github.com/yshengliao/aiecsjs/compare/v0.1.0...HEAD
|
|
102
|
+
[0.1.0]: https://github.com/yshengliao/aiecsjs/releases/tag/v0.1.0
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 yshengliao
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|