Skip to content

Commit 953149d

Browse files
authored
Enum typed buffer and documentation improvements. (#90)
* bumped * feat: add enum typed buffer, fix perftest deploy, update docs Add a new "enum" typed buffer type that stores enumerated values efficiently as Uint8Array indices instead of full JS values. Includes backward-compatible deserialization of legacy array-serialized enum buffers. Fix the ECS performance test link by updating the GitHub Pages deploy workflow to include dist/ in docs/ and restoring the README link. Made-with: Cursor * fix: bump script now enforces consistent versions across all packages The old script ran `pnpm version patch` independently in each package, so packages could drift out of sync. Now it bumps the root, captures that version, and sets every child to the same value. Made-with: Cursor
1 parent 470dabc commit 953149d

26 files changed

Lines changed: 1147 additions & 379 deletions

.github/workflows/deploy-docs.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Deploy API Docs
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
concurrency:
14+
group: pages
15+
cancel-in-progress: true
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- uses: pnpm/action-setup@v4
24+
with:
25+
version: 9
26+
27+
- uses: actions/setup-node@v4
28+
with:
29+
node-version: 20
30+
cache: pnpm
31+
32+
- run: pnpm install --frozen-lockfile
33+
34+
- run: pnpm run build
35+
working-directory: packages/data
36+
37+
- run: cp -r packages/data/dist packages/data/docs/dist
38+
39+
- uses: actions/upload-pages-artifact@v3
40+
with:
41+
path: packages/data/docs
42+
43+
deploy:
44+
needs: build
45+
runs-on: ubuntu-latest
46+
environment:
47+
name: github-pages
48+
url: ${{ steps.deployment.outputs.page_url }}
49+
steps:
50+
- id: deployment
51+
uses: actions/deploy-pages@v4

README.md

Lines changed: 18 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ Adobe Data Oriented Programming Library
33

44
## Documentation
55

6-
[Main Page](https://git.corp.adobe.com/pages/neuralfiltersplatform/firefly-data/docs/api/)
6+
[API Reference](https://adobe.github.io/data/)
77

8-
[ECS Performance Test](https://git.corp.adobe.com/pages/neuralfiltersplatform/firefly-data/docs/perftest.html)
8+
[ECS Performance Test](https://adobe.github.io/data/perftest.html)
99

1010
## Breaking API Changes
1111

@@ -76,7 +76,7 @@ An `Observable<T>` is a subscription function that you can pass a callback funct
7676

7777
Your callback function *may* be called back synchronously (before the initial call returns) zero or one times and asynchronously later any number of times.
7878

79-
For more information see the [Observable API documentation](./docs/api/modules/observe.html)
79+
For more information see the [Observable API documentation](https://adobe.github.io/data/)
8080

8181
### Observable Types
8282

@@ -181,116 +181,33 @@ Contains some standard data type schemas in JSON Schema format for convenience.
181181

182182
## Entity Component System (ECS)
183183

184-
This ECS database is a high performance, strongly typed typescript implementation inspired by the Sanders Mertens C++ based [Flecs](https://www.flecs.dev/flecs/md_docs_2Docs.html).
184+
A high-performance, strongly typed ECS database for TypeScript, inspired by [Flecs](https://www.flecs.dev/flecs/md_docs_2Docs.html). All application state is modeled as composable plugins, and all mutations flow through observable, undoable transactions.
185185

186-
This library provides two main interfaces for ECS operations: **Store** and **Database**. They share the same read API but differ significantly in their approach to writing and observability.
187-
188-
### Store Interface
189-
190-
The **Store** is the foundational, low-level interface for direct ECS data operations.
191-
192-
**Key Characteristics:**
193-
- **Direct Access**: Provides immediate, synchronous read/write access to entities, components, and resources
194-
- **No Transaction Control**: Changes are applied directly without transaction boundaries
195-
- **No Observability**: Changes are not automatically observable or trackable
196-
- **High Performance**: Minimal overhead for direct operations using Structure of Arrays (SoA) with linear memory layout of numeric types for optimal cache performance
197-
- **Core ECS Operations**: Includes entity creation, component updates, archetype querying, and resource management
198-
199-
**Usage**: Ideal for scenarios requiring fast, direct ECS manipulation where you don't need change tracking or transactional safety.
186+
For a complete guide covering plugins, transactions, observability, composition, and transient/ephemeral semantics, see the **[ECS README](./packages/data/src/ecs/README.md)**.
200187

201188
```typescript
202-
// Create a store with components, resources, and archetypes
203-
const store = createStore(
204-
{
205-
position: Vec3.schema,
206-
health: { type: "number" },
207-
player: { const: true }
208-
},
209-
{
210-
gravity: { default: 9.8 as number }
211-
},
212-
{
213-
Player: ["position", "health", "player"],
214-
Particle: ["position"]
215-
}
216-
);
217-
218-
// Direct operations
219-
const playerId = store.archetypes.Player.insert({
220-
position: [0, 0, 0],
221-
health: 100,
222-
player: true
223-
});
224-
store.update(playerId, { position: [1, 1, 1] });
225-
store.resources.gravity = 10.0;
226-
```
227-
228-
### Database Interface
229-
230-
The **Database** wraps a Store to provide **transaction-based operations** with **full observability**.
231-
232-
**Key Characteristics:**
233-
- **Transaction-Based**: All changes must occur within predefined atomic transactions that can be undone.
234-
- **Full Observability**: Every change is observable through the `observe` API
235-
- **Predefined Operations**: Uses predefined transaction functions rather than direct mutations
236-
- **Undo/Redo Support**: Transactions generate undo/redo operations automatically
237-
- **Change Tracking**: Tracks which entities, components, and archetypes changed
238-
- **Event Notifications**: Automatically notifies observers of changes
189+
import { Database } from "@adobe/data/ecs";
239190

240-
**Usage**: Ideal for applications requiring change history, multiplayer synchronization, undo/redo functionality, or reactive UI updates.
241-
242-
**Important Note**: Even when using a Database, transaction functions are written as direct modifications to the underlying Store interface. The Database wraps these operations to provide transactional guarantees and observability.
243-
244-
```typescript
245-
// Create a database with predefined transactions
246-
const database = createDatabase(store, {
247-
createPlayer(t, args: { position: Vector3, health: number }) {
248-
// Transaction function receives Store interface for direct operations
249-
return t.archetypes.Player.insert({
250-
...args,
251-
player: true
252-
});
191+
const myPlugin = Database.Plugin.create({
192+
resources: {
193+
score: { default: 0 as number },
253194
},
254-
movePlayer(t, args: { entity: Entity, position: Vector3 }) {
255-
// Direct Store operations within transaction context
256-
t.update(args.entity, { position: args.position });
195+
transactions: {
196+
addPoints: (t, points: number) => {
197+
t.resources.score += points;
198+
},
257199
},
258-
setGravity(t, gravity: number) {
259-
// Direct resource modification within transaction
260-
t.resources.gravity = gravity;
261-
}
262200
});
263201

264-
// Execute transactions (these provide observability and undo/redo)
265-
const playerId = database.transactions.createPlayer({
266-
position: [10, 20, 0],
267-
health: 100
268-
});
269-
database.transactions.movePlayer({ entity: playerId, position: [15, 25, 5] });
270-
271-
// Observe all changes
272-
database.observe.transactions((result) => {
273-
console.log('Transaction applied:', result);
274-
console.log('Changed entities:', result.changedEntities);
275-
console.log('Undo operations:', result.undo);
276-
});
277-
278-
// Observe specific entities
279-
database.observe.entity(playerId)((entityData) => {
280-
if (entityData) {
281-
console.log('Player moved to:', entityData.position);
282-
}
283-
});
202+
const db = Database.create(myPlugin);
203+
db.observe.resources.score((score) => console.log("Score:", score));
204+
db.transactions.addPoints(10);
284205
```
285206

286207
### What is an ECS?
287208

288-
Sanders Mertens also covers this thoroughly in his ECS FAQ:
209+
Sanders Mertens covers this thoroughly in his ECS FAQ:
289210

290211
[https://github.com/SanderMertens/ecs-faq?tab=readme-ov-file#what-is-ecs](https://github.com/SanderMertens/ecs-faq?tab=readme-ov-file#what-is-ecs)
291212

292-
In addition to the Entity, Component and System definitions which are standard, we also use the term Resource. A Resource is just a value which is defined globally on the ECS itself and not attached to any specific Entity. You can think of them as a singleton Component.
293-
294-
## Performance Test
295-
296-
[Performance Test](https://git.corp.adobe.com/pages/neuralfiltersplatform/firefly-data/docs/perftest.html)
213+
In addition to the standard Entity, Component, and System definitions, we also use the term **Resource** — a global singleton value defined on the ECS itself, not attached to any specific entity.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "data-monorepo",
3-
"version": "0.9.47",
3+
"version": "0.9.49",
44
"private": true,
55
"scripts": {
66
"build": "pnpm -r run build",
@@ -9,7 +9,7 @@
99
"dev:data": "pnpm --filter @adobe/data run dev",
1010
"link": "pnpm -r --filter @adobe/data* run link",
1111
"publish": "sh -c 'for x in \"$@\"; do OTP=\"$x\"; done; export NPM_CONFIG_OTP=\"$OTP\"; pnpm -r --filter @adobe/data --filter @adobe/data-react --filter @adobe/data-lit run publish-public' sh",
12-
"bump": "pnpm version patch --no-git-tag-version && pnpm -r exec -- pnpm version patch --no-git-tag-version",
12+
"bump": "pnpm version patch --no-git-tag-version && V=$(node -p \"require('$PWD/package.json').version\") && pnpm -r exec pnpm version $V --no-git-tag-version --allow-same-version",
1313
"release": "pnpm bump && pnpm publish",
1414
"bp": "pnpm bump && pnpm run publish"
1515
},

packages/data-lit-tictactoe/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "data-lit-tictactoe",
3-
"version": "0.9.47",
3+
"version": "0.9.49",
44
"description": "Tic-Tac-Toe sample - Lit web components with @adobe/data-lit and AgenticService",
55
"type": "module",
66
"private": true,

packages/data-lit-todo/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "data-lit-todo",
3-
"version": "0.9.45",
3+
"version": "0.9.49",
44
"description": "Todo sample app demonstrating @adobe/data with Lit",
55
"type": "module",
66
"private": true,

packages/data-lit/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@adobe/data-lit",
3-
"version": "0.9.47",
3+
"version": "0.9.49",
44
"description": "Adobe data Lit bindings - hooks, elements, decorators",
55
"type": "module",
66
"private": false,

packages/data-react-hello/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "data-react-hello",
3-
"version": "0.9.47",
3+
"version": "0.9.49",
44
"description": "Hello World sample - click counter using @adobe/data-react",
55
"type": "module",
66
"private": true,

packages/data-react-pixie/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "data-react-pixie",
3-
"version": "0.9.47",
3+
"version": "0.9.49",
44
"description": "PixiJS React sample - ECS sprites (bunny, fox) with @adobe/data-react",
55
"type": "module",
66
"private": true,

packages/data-react/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@adobe/data-react",
3-
"version": "0.9.47",
3+
"version": "0.9.49",
44
"description": "Adobe data React bindings — hooks and context for ECS database",
55
"type": "module",
66
"private": false,

0 commit comments

Comments
 (0)