@adobe/data 0.9.48 → 0.9.51

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 (51) hide show
  1. package/AGENTS.md +2 -0
  2. package/README.md +18 -101
  3. package/dist/ecs/database/combine-plugins.d.ts +35 -19
  4. package/dist/ecs/database/combine-plugins.js.map +1 -1
  5. package/dist/ecs/database/create-plugin.d.ts +11 -10
  6. package/dist/ecs/database/create-plugin.js.map +1 -1
  7. package/dist/ecs/database/database.d.ts +17 -23
  8. package/dist/ecs/database/database.js.map +1 -1
  9. package/dist/ecs/database/deep-extends-chain.type-test.d.ts +40963 -0
  10. package/dist/ecs/database/deep-extends-chain.type-test.js +282 -0
  11. package/dist/ecs/database/deep-extends-chain.type-test.js.map +1 -0
  12. package/dist/ecs/database/observed/create-observed-database.js.map +1 -1
  13. package/dist/ecs/database/observed/observed-database.d.ts +1 -3
  14. package/dist/ecs/database/public/create-database.d.ts +2 -5
  15. package/dist/ecs/database/public/create-database.js.map +1 -1
  16. package/dist/ecs/plugins/scheduler/scheduler.d.ts +13 -8
  17. package/dist/ecs/store/core/core.d.ts +3 -7
  18. package/dist/functions/serialization/compression.d.ts +2 -0
  19. package/dist/functions/serialization/compression.js +32 -0
  20. package/dist/functions/serialization/compression.js.map +1 -0
  21. package/dist/functions/serialization/serialization.test.js +66 -0
  22. package/dist/functions/serialization/serialization.test.js.map +1 -1
  23. package/dist/functions/serialization/serialize-to-blobs.js +20 -4
  24. package/dist/functions/serialization/serialize-to-blobs.js.map +1 -1
  25. package/dist/functions/serialization/serialize-to-blobs.test.js +21 -0
  26. package/dist/functions/serialization/serialize-to-blobs.test.js.map +1 -1
  27. package/dist/functions/serialization/serialize-to-json.js +5 -70
  28. package/dist/functions/serialization/serialize-to-json.js.map +1 -1
  29. package/dist/old-ecs/index.d.ts +4 -0
  30. package/dist/old-ecs/index.js +4 -0
  31. package/dist/old-ecs/index.js.map +1 -1
  32. package/dist/tsconfig.tsbuildinfo +1 -1
  33. package/dist/typed-buffer/create-enum-buffer.d.ts +4 -0
  34. package/dist/typed-buffer/create-enum-buffer.js +82 -0
  35. package/dist/typed-buffer/create-enum-buffer.js.map +1 -0
  36. package/dist/typed-buffer/create-enum-buffer.test.d.ts +1 -0
  37. package/dist/typed-buffer/create-enum-buffer.test.js +248 -0
  38. package/dist/typed-buffer/create-enum-buffer.test.js.map +1 -0
  39. package/dist/typed-buffer/create-typed-buffer.js +4 -0
  40. package/dist/typed-buffer/create-typed-buffer.js.map +1 -1
  41. package/dist/typed-buffer/register-typed-buffer-codecs.js +20 -2
  42. package/dist/typed-buffer/register-typed-buffer-codecs.js.map +1 -1
  43. package/dist/typed-buffer/typed-buffer.d.ts +1 -1
  44. package/dist/types/types.d.ts +9 -1
  45. package/dist/types/types.js.map +1 -1
  46. package/package.json +1 -2
  47. package/references/data-lit/package.json +1 -1
  48. package/references/data-lit-tictactoe/package.json +1 -1
  49. package/references/data-react/package.json +1 -1
  50. package/references/data-react-hello/package.json +1 -1
  51. package/references/data-react-pixie/package.json +1 -1
package/AGENTS.md CHANGED
@@ -11,6 +11,8 @@ Source for peer packages and sample apps is included under `references/` (when p
11
11
  - **references/data-react** — Support functions for React based projects.
12
12
  - **references/data-react-hello** — Very simple react hello world sample.
13
13
  - **references/data-react-pixie** — Simple sample for react pixie based 2d games.
14
+ - **references/data-solid** — Support functions for SolidJS based projects. Minimal: only database context/provider. Observable bridging uses Solid's native `from()`.
15
+ - **references/data-solid-dashboard** — Mini dashboard sample with SolidJS. Demonstrates shared database, multiple components each observing only their own slice, and fine-grained reactivity via `from()`.
14
16
 
15
17
  ## Stack
16
18
 
package/README.md CHANGED
@@ -3,9 +3,9 @@ Adobe Data Oriented Programming Library
3
3
 
4
4
  ## Documentation
5
5
 
6
- [Main Page](https://git.corp.adobe.com/pages/neuralfiltersplatform/firefly-data/docs/api/)
6
+ [API Reference](https://adobe.github.io/data/)
7
7
 
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)
9
9
 
10
10
  ## Breaking API Changes
11
11
 
@@ -76,7 +76,7 @@ An `Observable<T>` is a subscription function that you can pass a callback funct
76
76
 
77
77
  Your callback function *may* be called back synchronously (before the initial call returns) zero or one times and asynchronously later any number of times.
78
78
 
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/)
80
80
 
81
81
  ### Observable Types
82
82
 
@@ -181,116 +181,33 @@ Contains some standard data type schemas in JSON Schema format for convenience.
181
181
 
182
182
  ## Entity Component System (ECS)
183
183
 
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.
185
185
 
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](./src/ecs/README.md)**.
200
187
 
201
188
  ```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";
239
190
 
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 },
253
194
  },
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
+ },
257
199
  },
258
- setGravity(t, gravity: number) {
259
- // Direct resource modification within transaction
260
- t.resources.gravity = gravity;
261
- }
262
200
  });
263
201
 
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);
284
205
  ```
285
206
 
286
207
  ### What is an ECS?
287
208
 
288
- Sanders Mertens also covers this thoroughly in his ECS FAQ:
209
+ Sanders Mertens covers this thoroughly in his ECS FAQ:
289
210
 
290
211
  [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)
291
212
 
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.
@@ -1,24 +1,24 @@
1
- import { Simplify } from "../../types/types.js";
1
+ import { Simplify, StringKeyof } from "../../types/types.js";
2
2
  import type { Database } from "./database.js";
3
3
  type IntersectAll<T extends readonly unknown[]> = Simplify<T extends readonly [infer H, ...infer R] ? H & IntersectAll<R> : unknown>;
4
4
  type UnionAll<T extends readonly unknown[]> = Simplify<T extends readonly [infer H, ...infer R] ? H | UnionAll<R> : never>;
5
- export type CombinePlugins<Plugins extends readonly Database.Plugin[]> = Database.Plugin<Simplify<{} & IntersectAll<{
6
- [K in keyof Plugins]: Plugins[K] extends Database.Plugin<infer C, any, any, any, any, any, any, any> ? C : never;
7
- }>>, Simplify<{} & IntersectAll<{
8
- [K in keyof Plugins]: Plugins[K] extends Database.Plugin<any, infer R, any, any, any, any, any, any> ? R : never;
9
- }>>, Simplify<{} & IntersectAll<{
10
- [K in keyof Plugins]: Plugins[K] extends Database.Plugin<any, any, infer A, any, any, any, any, any> ? A : never;
11
- }>>, Simplify<{} & IntersectAll<{
12
- [K in keyof Plugins]: Plugins[K] extends Database.Plugin<any, any, any, infer TD, any, any, any, any> ? TD : never;
13
- }>>, Extract<Simplify<UnionAll<{
14
- [K in keyof Plugins]: Plugins[K] extends Database.Plugin<any, any, any, any, infer S, any, any, any> ? S : never;
15
- }>>, string>, Simplify<{} & IntersectAll<{
16
- [K in keyof Plugins]: Plugins[K] extends Database.Plugin<any, any, any, any, any, infer AD, any, any> ? AD : never;
17
- }>>, Simplify<{} & IntersectAll<{
18
- [K in keyof Plugins]: Plugins[K] extends Database.Plugin<any, any, any, any, any, any, infer SVF, any> ? SVF : never;
19
- }>>, Simplify<{} & IntersectAll<{
20
- [K in keyof Plugins]: Plugins[K] extends Database.Plugin<any, any, any, any, any, any, any, infer CVF> ? CVF : never;
21
- }>>>;
5
+ export type CombinePlugins<Plugins extends readonly Database.Plugin[]> = Database.Plugin<{} & IntersectAll<{
6
+ [K in keyof Plugins]: Plugins[K]['components'];
7
+ }>, {} & IntersectAll<{
8
+ [K in keyof Plugins]: Plugins[K]['resources'];
9
+ }>, {} & IntersectAll<{
10
+ [K in keyof Plugins]: Plugins[K]['archetypes'];
11
+ }>, {} & IntersectAll<{
12
+ [K in keyof Plugins]: Plugins[K]['transactions'];
13
+ }>, Extract<UnionAll<{
14
+ [K in keyof Plugins]: StringKeyof<Plugins[K]['systems']>;
15
+ }>, string>, {} & IntersectAll<{
16
+ [K in keyof Plugins]: Plugins[K]['actions'];
17
+ }>, {} & IntersectAll<{
18
+ [K in keyof Plugins]: Plugins[K]['services'];
19
+ }>, {} & IntersectAll<{
20
+ [K in keyof Plugins]: Plugins[K]['computed'];
21
+ }>>;
22
22
  /**
23
23
  * Combines multiple plugins into a single plugin.
24
24
  * All plugin properties (components, resources, archetypes, computed, transactions, systems, actions, services)
@@ -27,5 +27,21 @@ export type CombinePlugins<Plugins extends readonly Database.Plugin[]> = Databas
27
27
  * IMPORTANT: Services are merged in order, preserving the initialization order
28
28
  * so that extended plugin services are initialized before current plugin services.
29
29
  */
30
- export declare function combinePlugins<const Plugins extends readonly Database.Plugin[]>(...plugins: Plugins): CombinePlugins<Plugins>;
30
+ export declare function combinePlugins<const Plugins extends readonly Database.Plugin[]>(...plugins: Plugins): Database.Plugin<{} & IntersectAll<{
31
+ [K in keyof Plugins]: Plugins[K]['components'];
32
+ }>, {} & IntersectAll<{
33
+ [K in keyof Plugins]: Plugins[K]['resources'];
34
+ }>, {} & IntersectAll<{
35
+ [K in keyof Plugins]: Plugins[K]['archetypes'];
36
+ }>, {} & IntersectAll<{
37
+ [K in keyof Plugins]: Plugins[K]['transactions'];
38
+ }>, Extract<UnionAll<{
39
+ [K in keyof Plugins]: StringKeyof<Plugins[K]['systems']>;
40
+ }>, string>, {} & IntersectAll<{
41
+ [K in keyof Plugins]: Plugins[K]['actions'];
42
+ }>, {} & IntersectAll<{
43
+ [K in keyof Plugins]: Plugins[K]['services'];
44
+ }>, {} & IntersectAll<{
45
+ [K in keyof Plugins]: Plugins[K]['computed'];
46
+ }>>;
31
47
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"combine-plugins.js","sourceRoot":"","sources":["../../../src/ecs/database/combine-plugins.ts"],"names":[],"mappings":"AAAA,uDAAuD;AA6BvD;;;;;;;GAOG;AACH,MAAM,UAAU,cAAc,CAE5B,GAAG,OAAgB;IACnB,MAAM,IAAI,GAAG,CAAC,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,SAAS,EAAE,SAAS,CAAU,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C,KAAK,EAAE,WAAW,CAAC,CAAC;IAElD,OAAO,MAAiC,CAAC;AAC3C,CAAC"}
@@ -3,14 +3,18 @@ import type { ComponentSchemas } from "../component-schemas.js";
3
3
  import type { ResourceSchemas } from "../resource-schemas.js";
4
4
  import type { ArchetypeComponents } from "../store/archetype-components.js";
5
5
  import type { TransactionDeclarations, ToTransactionFunctions } from "../store/transaction-functions.js";
6
- import type { ActionDeclarations, ToActionFunctions } from "../store/action-functions.js";
6
+ import type { ToActionFunctions } from "../store/action-functions.js";
7
7
  import type { FromSchemas } from "../../schema/index.js";
8
- import type { StringKeyof, Simplify, NoInfer } from "../../types/types.js";
9
- import { CombinePlugins } from "./combine-plugins.js";
8
+ import type { StringKeyof, NoInfer, RemoveIndex } from "../../types/types.js";
10
9
  import { Store } from "../store/store.js";
11
- type RemoveIndex<T> = Simplify<{
12
- [K in keyof T as string extends K ? never : number extends K ? never : symbol extends K ? never : K]: T[K];
13
- }>;
10
+ /**
11
+ * Direct-intersection return type for createPlugin.
12
+ *
13
+ * Uses direct property access (`XP['components']`) instead of conditional
14
+ * inference (`CombinePlugins<[XP, ...]>`) to avoid expensive 8-way type
15
+ * expansion that amplifies TS7056 serialization overflow.
16
+ */
17
+ type CreatePluginResult<XP extends Database.Plugin, CS, RS, A, TD, S extends string, AD, SVF, CVF> = Database.Plugin<XP['components'] & CS, XP['resources'] & RS, XP['archetypes'] & A, XP['transactions'] & TD, S | StringKeyof<XP['systems']>, XP['actions'] & AD, XP['services'] & SVF, XP['computed'] & CVF>;
14
18
  /**
15
19
  * Creates a Database.Plugin from a plugin descriptor.
16
20
  *
@@ -84,8 +88,5 @@ export declare function createPlugin<const XP extends Database.Plugin<{}, {}, {}
84
88
  };
85
89
  };
86
90
  };
87
- }): CombinePlugins<[
88
- XP,
89
- Database.Plugin<RemoveIndex<CS>, RemoveIndex<RS>, RemoveIndex<A>, RemoveIndex<TD>, S, AD & ActionDeclarations<FromSchemas<RemoveIndex<CS>>, FromSchemas<RemoveIndex<RS>>, RemoveIndex<A>, ToTransactionFunctions<RemoveIndex<TD>>, S>, RemoveIndex<SVF>, RemoveIndex<CVF>>
90
- ]>;
91
+ }): CreatePluginResult<XP, RemoveIndex<CS>, RemoveIndex<RS>, RemoveIndex<A>, RemoveIndex<TD>, S, AD, RemoveIndex<SVF>, RemoveIndex<CVF>>;
91
92
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"create-plugin.js","sourceRoot":"","sources":["../../../src/ecs/database/create-plugin.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAUvD,OAAO,EAAkB,cAAc,EAAE,MAAM,sBAAsB,CAAC;AA4BtE,SAAS,qBAAqB,CAAC,OAAgC;IAC3D,MAAM,aAAa,GAAG,CAAC,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;IACzI,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACxC,MAAM,WAAW,GAAG,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,OAAO,CAAC,CAAC;IAE7D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC1C,MAAM,GAAG,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;QAC3B,MAAM,aAAa,GAAG,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACjD,IAAI,aAAa,KAAK,CAAC,CAAC,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CAAC,6CAA6C,GAAG,4BAA4B,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC5H,CAAC;QACD,uDAAuD;QACvD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE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,IAAI,CAAC,IAAI,CAAC,EAAE,CACrF,CAAC;YACN,CAAC;QACL,CAAC;IACL,CAAC;AACL,CAAC;AA2DD,MAAM,UAAU,YAAY,CAWxB,OA+CC;IAED,qBAAqB,CAAC,OAAO,CAAC,CAAC;IAE/B,mEAAmE;IACnE,MAAM,MAAM,GAAQ;QAChB,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,EAAE;QAChC,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,EAAE;QACpC,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,EAAE;QAClC,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,EAAE;QACpC,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,EAAE;QAChC,YAAY,EAAE,OAAO,CAAC,YAAY,IAAI,EAAE;QACxC,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,EAAE;QAC9B,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,EAAE;KACjC,CAAC;IAEF,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QAClB,OAAO,cAAc,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,CAAQ,CAAC;IAC1D,CAAC;IACD,OAAO,MAAa,CAAC;AACzB,CAAC"}
@@ -5,7 +5,7 @@ import { Entity } from "../entity/entity.js";
5
5
  import { EntityReadValues } from "../store/core/index.js";
6
6
  import { Observe } from "../../observe/index.js";
7
7
  import { TransactionResult } from "./transactional-store/index.js";
8
- import { StringKeyof } from "../../types/types.js";
8
+ import { StringKeyof, RemoveIndex } from "../../types/types.js";
9
9
  import { Components } from "../store/components.js";
10
10
  import { ArchetypeComponents } from "../store/archetype-components.js";
11
11
  import { RequiredComponents } from "../required-components.js";
@@ -90,9 +90,7 @@ export interface Database<C extends Components = {}, R extends ResourceComponent
90
90
  readonly [K in StringKeyof<R>]: Observe<R[K]>;
91
91
  };
92
92
  readonly transactions: Observe<TransactionResult<C>>;
93
- entity<T extends RequiredComponents>(id: Entity, minArchetype?: ReadonlyArchetype<T> | Archetype<T>): Observe<{
94
- readonly [K in (StringKeyof<RequiredComponents & T>)]: (RequiredComponents & T)[K];
95
- } & EntityReadValues<C> | null>;
93
+ entity<T extends RequiredComponents>(id: Entity, minArchetype?: ReadonlyArchetype<T> | Archetype<T>): Observe<Readonly<T> & EntityReadValues<C> | null>;
96
94
  entity(id: Entity): Observe<EntityReadValues<C> | null>;
97
95
  archetype(id: ArchetypeId): Observe<void>;
98
96
  select<Include extends StringKeyof<C>, T extends Include>(include: readonly Include[] | ReadonlySet<string>, options?: EntitySelectOptions<C, Pick<C & RequiredComponents, T>>): Observe<readonly Entity[]>;
@@ -107,23 +105,20 @@ export interface Database<C extends Components = {}, R extends ResourceComponent
107
105
  };
108
106
  toData(): unknown;
109
107
  fromData(data: unknown): void;
110
- extend<P extends Database.Plugin<any, any, any, any, any, any, any, any>>(plugin: P): Database<C & (P extends Database.Plugin<infer XC, any, any, any, any, any, any, any> ? FromSchemas<XC> : never), R & (P extends Database.Plugin<any, infer XR, any, any, any, any, any, any> ? FromSchemas<XR> : never), A & (P extends Database.Plugin<any, any, infer XA, any, any, any, any, any> ? XA : never), F & (P extends Database.Plugin<any, any, any, infer XTD, any, any, any, any> ? ToTransactionFunctions<XTD> : never), S | (P extends Database.Plugin<any, any, any, any, infer XS, any, any, any> ? XS : never), AF & (P extends Database.Plugin<any, any, any, any, any, infer XAD, any, any> ? ToActionFunctions<XAD> : never), SV & (P extends Database.Plugin<any, any, any, any, any, any, infer XSVF, any> ? FromServiceFactories<XSVF> : never), CV & (P extends Database.Plugin<any, any, any, any, any, any, any, infer XCVF> ? FromComputedFactories<XCVF> : never)>;
108
+ extend<P extends Database.Plugin>(plugin: P): Database<C & FromSchemas<RemoveIndex<P['components']>>, R & FromSchemas<RemoveIndex<P['resources']>>, A & RemoveIndex<P['archetypes']>, F & ToTransactionFunctions<RemoveIndex<P['transactions']>>, S | StringKeyof<P['systems']>, AF & ToActionFunctions<RemoveIndex<P['actions']>>, SV & FromServiceFactories<RemoveIndex<P['services']>>, CV & FromComputedFactories<RemoveIndex<P['computed']>>>;
111
109
  }
112
110
  export declare namespace Database {
113
- /** Stepwise inference helpers - each infers one Plugin param to reduce compiler depth. */
114
- type FromPluginComponents<P> = P extends Database.Plugin<infer CS, any, any, any, any, any, any, any> ? CS : never;
115
- type FromPluginResources<P> = P extends Database.Plugin<any, infer RS, any, any, any, any, any, any> ? RS : never;
116
- type FromPluginArchetypes<P> = P extends Database.Plugin<any, any, infer A, any, any, any, any, any> ? A : never;
117
- type FromPluginTransactions<P> = P extends Database.Plugin<any, any, any, infer TD, any, any, any, any> ? TD : never;
118
- type FromPluginSystems<P> = P extends Database.Plugin<any, any, any, any, infer S, any, any, any> ? S : never;
119
- type FromPluginActions<P> = P extends Database.Plugin<any, any, any, any, any, infer AD, any, any> ? AD : never;
120
- type FromPluginServices<P> = P extends Database.Plugin<any, any, any, any, any, any, infer SVF, any> ? SVF : never;
121
- type FromPluginComputed<P> = P extends Database.Plugin<any, any, any, any, any, any, any, infer CVF> ? CVF : never;
122
- export type FromPlugin<P extends Database.Plugin> = P extends Database.Plugin ? Database<FromSchemas<FromPluginComponents<P>>, FromSchemas<FromPluginResources<P>>, FromPluginArchetypes<P>, ToTransactionFunctions<FromPluginTransactions<P>>, FromPluginSystems<P>, ToActionFunctions<FromPluginActions<P>>, FromServiceFactories<FromPluginServices<P>>, FromComputedFactories<FromPluginComputed<P>>> : never;
123
- export const create: typeof createDatabase;
124
- export const is: (value: unknown) => value is Database;
125
- export const observeSelectDeep: <C extends Components, Include extends StringKeyof<C>>(db: Database<C, any, any, any, any, any, any, any>, include: readonly Include[] | ReadonlySet<Include | "id">, options?: EntitySelectOptions<C, Pick<C & RequiredComponents, Include>>) => Observe<readonly (RequiredComponents & { readonly [K in Include]: C[K]; })[]>;
126
- export type Plugin<CS extends ComponentSchemas = any, RS extends ResourceSchemas = any, A extends ArchetypeComponents<StringKeyof<CS>> = any, TD extends TransactionDeclarations<FromSchemas<CS>, FromSchemas<RS>, any> = any, S extends string = any, AD extends ActionDeclarations<FromSchemas<CS>, FromSchemas<RS>, A, ToTransactionFunctions<TD>, S> = any, SVF extends ServiceFactories = any, CVF extends ComputedFactories = any> = {
111
+ /**
112
+ * Converts a Plugin type to its corresponding Database type.
113
+ * Uses direct property access (P['components']) instead of conditional inference
114
+ * (P extends Plugin<infer CS, ...> ? CS : never) to avoid expensive 8-way type
115
+ * expansion that amplifies TS7056 serialization overflow in deep extends chains.
116
+ */
117
+ type FromPlugin<P extends Database.Plugin> = Database<FromSchemas<RemoveIndex<P['components']>>, FromSchemas<RemoveIndex<P['resources']>>, RemoveIndex<P['archetypes']>, ToTransactionFunctions<RemoveIndex<P['transactions']>>, StringKeyof<P['systems']>, ToActionFunctions<RemoveIndex<P['actions']>>, FromServiceFactories<RemoveIndex<P['services']>>, FromComputedFactories<RemoveIndex<P['computed']>>>;
118
+ const create: typeof createDatabase;
119
+ const is: (value: unknown) => value is Database;
120
+ const observeSelectDeep: <C extends Components, Include extends StringKeyof<C>>(db: Database<C, any, any, any, any, any, any, any>, include: readonly Include[] | ReadonlySet<Include | "id">, options?: EntitySelectOptions<C, Pick<C & RequiredComponents, Include>>) => Observe<readonly (RequiredComponents & { readonly [K in Include]: C[K]; })[]>;
121
+ type Plugin<CS extends ComponentSchemas = any, RS extends ResourceSchemas = any, A extends ArchetypeComponents<StringKeyof<CS>> = any, TD extends TransactionDeclarations<FromSchemas<CS>, FromSchemas<RS>, any> = any, S extends string = any, AD extends ActionDeclarations<FromSchemas<CS>, FromSchemas<RS>, A, ToTransactionFunctions<TD>, S> = any, SVF extends ServiceFactories = any, CVF extends ComputedFactories = any> = {
127
122
  readonly components: CS;
128
123
  readonly resources: RS;
129
124
  readonly archetypes: A;
@@ -133,17 +128,16 @@ export declare namespace Database {
133
128
  readonly services: SVF;
134
129
  readonly computed: CVF;
135
130
  };
136
- export namespace Plugin {
131
+ namespace Plugin {
137
132
  const create: typeof createPlugin;
138
133
  const combine: typeof combinePlugins;
139
134
  type ToDatabase<P extends Database.Plugin> = Database.FromPlugin<P>;
140
- type ToStore<P extends Database.Plugin> = Store<FromSchemas<P['components']>, FromSchemas<P['resources']>, P['archetypes']>;
135
+ type ToStore<P extends Database.Plugin> = Store<FromSchemas<RemoveIndex<P['components']>>, FromSchemas<RemoveIndex<P['resources']>>, RemoveIndex<P['archetypes']>>;
141
136
  type ToSystemDatabase<P extends Database.Plugin> = Database.FromPlugin<P> & {
142
137
  readonly store: Database.Plugin.ToStore<P>;
143
138
  services: {
144
- -readonly [K in keyof FromServiceFactories<P['services']>]: FromServiceFactories<P['services']>[K];
139
+ -readonly [K in keyof FromServiceFactories<RemoveIndex<P['services']>>]: FromServiceFactories<RemoveIndex<P['services']>>[K];
145
140
  };
146
141
  };
147
142
  }
148
- export {};
149
143
  }
@@ -1 +1 @@
1
- {"version":3,"file":"database.js","sourceRoot":"","sources":["../../../src/ecs/database/database.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAevD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,iBAAiB,IAAI,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAc1F,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AA0GtD,MAAM,KAAW,QAAQ,CAmExB;AAnED,WAAiB,QAAQ;IAwBV,eAAM,GAAG,cAAc,CAAC;IAExB,WAAE,GAAG,CAAC,KAAc,EAAqB,EAAE;QACtD,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,cAAc,IAAI,KAAK,IAAI,SAAS,IAAI,KAAK,IAAI,OAAO,IAAI,KAAK,IAAI,SAAS,IAAI,KAAK,IAAI,QAAQ,IAAI,KAAK,IAAI,QAAQ,IAAI,KAAK,CAAC;IAC1L,CAAC,CAAA;IAEY,0BAAiB,GAAG,kBAAkB,CAAC;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