@adobe/data 0.9.47 → 0.9.50
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 +18 -101
- package/dist/ecs/database/combine-plugins.d.ts +35 -19
- package/dist/ecs/database/combine-plugins.js.map +1 -1
- package/dist/ecs/database/create-plugin.d.ts +11 -10
- package/dist/ecs/database/create-plugin.js.map +1 -1
- package/dist/ecs/database/database.d.ts +17 -23
- package/dist/ecs/database/database.js.map +1 -1
- package/dist/ecs/database/deep-extends-chain.type-test.d.ts +40963 -0
- package/dist/ecs/database/deep-extends-chain.type-test.js +282 -0
- package/dist/ecs/database/deep-extends-chain.type-test.js.map +1 -0
- package/dist/ecs/database/observed/create-observed-database.js.map +1 -1
- package/dist/ecs/database/observed/observed-database.d.ts +1 -3
- package/dist/ecs/database/public/create-database.d.ts +2 -5
- package/dist/ecs/database/public/create-database.js.map +1 -1
- package/dist/ecs/plugins/scheduler/scheduler.d.ts +13 -8
- package/dist/ecs/store/core/core.d.ts +3 -7
- package/dist/functions/serialization/compression.d.ts +2 -0
- package/dist/functions/serialization/compression.js +32 -0
- package/dist/functions/serialization/compression.js.map +1 -0
- package/dist/functions/serialization/serialization.test.js +66 -0
- package/dist/functions/serialization/serialization.test.js.map +1 -1
- package/dist/functions/serialization/serialize-to-blobs.js +20 -4
- package/dist/functions/serialization/serialize-to-blobs.js.map +1 -1
- package/dist/functions/serialization/serialize-to-blobs.test.js +21 -0
- package/dist/functions/serialization/serialize-to-blobs.test.js.map +1 -1
- package/dist/functions/serialization/serialize-to-json.js +5 -70
- package/dist/functions/serialization/serialize-to-json.js.map +1 -1
- package/dist/observe/public.d.ts +1 -0
- package/dist/observe/public.js +1 -0
- package/dist/observe/public.js.map +1 -1
- package/dist/observe/with-switch.d.ts +18 -0
- package/dist/observe/with-switch.js +45 -0
- package/dist/observe/with-switch.js.map +1 -0
- package/dist/observe/with-switch.test.d.ts +1 -0
- package/dist/observe/with-switch.test.js +142 -0
- package/dist/observe/with-switch.test.js.map +1 -0
- package/dist/old-ecs/index.d.ts +4 -0
- package/dist/old-ecs/index.js +4 -0
- package/dist/old-ecs/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/typed-buffer/create-enum-buffer.d.ts +4 -0
- package/dist/typed-buffer/create-enum-buffer.js +82 -0
- package/dist/typed-buffer/create-enum-buffer.js.map +1 -0
- package/dist/typed-buffer/create-enum-buffer.test.d.ts +1 -0
- package/dist/typed-buffer/create-enum-buffer.test.js +248 -0
- package/dist/typed-buffer/create-enum-buffer.test.js.map +1 -0
- package/dist/typed-buffer/create-typed-buffer.js +4 -0
- package/dist/typed-buffer/create-typed-buffer.js.map +1 -1
- package/dist/typed-buffer/register-typed-buffer-codecs.js +20 -2
- package/dist/typed-buffer/register-typed-buffer-codecs.js.map +1 -1
- package/dist/typed-buffer/typed-buffer.d.ts +1 -1
- package/dist/types/types.d.ts +9 -1
- package/dist/types/types.js.map +1 -1
- package/package.json +1 -2
- package/references/data-lit/package.json +1 -1
- package/references/data-lit-tictactoe/package.json +1 -1
- package/references/data-react/package.json +1 -1
- package/references/data-react-hello/package.json +1 -1
- package/references/data-react-pixie/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,9 +3,9 @@ Adobe Data Oriented Programming Library
|
|
|
3
3
|
|
|
4
4
|
## Documentation
|
|
5
5
|
|
|
6
|
-
[
|
|
6
|
+
[API Reference](https://adobe.github.io/data/)
|
|
7
7
|
|
|
8
|
-
[ECS Performance Test](https://
|
|
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](
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
241
|
-
|
|
242
|
-
|
|
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
|
-
|
|
255
|
-
|
|
256
|
-
|
|
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
|
-
|
|
265
|
-
|
|
266
|
-
|
|
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
|
|
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
|
|
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<
|
|
6
|
-
[K in keyof Plugins]: Plugins[K]
|
|
7
|
-
}
|
|
8
|
-
[K in keyof Plugins]: Plugins[K]
|
|
9
|
-
}
|
|
10
|
-
[K in keyof Plugins]: Plugins[K]
|
|
11
|
-
}
|
|
12
|
-
[K in keyof Plugins]: Plugins[K]
|
|
13
|
-
}
|
|
14
|
-
[K in keyof Plugins]: Plugins[K]
|
|
15
|
-
}
|
|
16
|
-
[K in keyof Plugins]: Plugins[K]
|
|
17
|
-
}
|
|
18
|
-
[K in keyof Plugins]: Plugins[K]
|
|
19
|
-
}
|
|
20
|
-
[K in keyof Plugins]: Plugins[K]
|
|
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):
|
|
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;
|
|
1
|
+
{"version":3,"file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QAAQ,EAAE,EAAE,EAAE,CAAC;IAE9I,6BAA6B;IAC7B,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,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 {
|
|
6
|
+
import type { ToActionFunctions } from "../store/action-functions.js";
|
|
7
7
|
import type { FromSchemas } from "../../schema/index.js";
|
|
8
|
-
import type { StringKeyof,
|
|
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
|
-
|
|
12
|
-
|
|
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
|
-
}):
|
|
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,
|
|
1
|
+
{"version":3,"file":"create-plugin.js","sourceRoot":"","sources":["../../../src/ecs/database/create-plugin.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAUvD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAwCtD,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,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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
|
|
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
|
-
/**
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
type
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
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
|
-
|
|
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']
|
|
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']
|
|
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,
|
|
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,CA6DxB;AA7DD,WAAiB,QAAQ;IAkBV,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;IAsBpD,IAAiB,MAAM,CAatB;IAbD,WAAiB,MAAM;QACR,aAAM,GAAG,YAAY,CAAC;QACtB,cAAO,GAAG,cAAc,CAAC;IAWxC,CAAC,EAbgB,MAAM,GAAN,eAAM,KAAN,eAAM,QAatB;AAEH,CAAC,EA7DgB,QAAQ,KAAR,QAAQ,QA6DxB"}
|