@adobe/data 0.9.5 → 0.9.6
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/ecs/database/create-plugin-cryos-pattern.test.d.ts +3 -0
- package/ecs/database/create-plugin-cryos-pattern.test.js +83 -0
- package/ecs/database/create-plugin-cryos-pattern.test.js.map +1 -0
- package/ecs/database/create-plugin-graphics.test.d.ts +93 -0
- package/ecs/database/create-plugin-graphics.test.js +135 -0
- package/ecs/database/create-plugin-graphics.test.js.map +1 -0
- package/ecs/database/create-plugin-type.type-test.js +563 -0
- package/ecs/database/create-plugin-type.type-test.js.map +1 -0
- package/ecs/database/create-plugin-type.type.test.js +563 -0
- package/ecs/database/create-plugin-type.type.test.js.map +1 -0
- package/ecs/database/database.d.ts +6 -1
- package/ecs/database/database.js.map +1 -1
- package/ecs/database/experimental-action-types.js +275 -0
- package/ecs/database/experimental-action-types.js.map +1 -0
- package/ecs/database/from-plugin.type-test.js +180 -0
- package/ecs/database/from-plugin.type-test.js.map +1 -0
- package/ecs/database/plugin-types.js +5 -0
- package/ecs/database/plugin-types.js.map +1 -0
- package/ecs/database/type-investigation.test.js +54 -0
- package/ecs/database/type-investigation.test.js.map +1 -0
- package/ecs/store/core/create-core.test.js +21 -0
- package/ecs/store/core/create-core.test.js.map +1 -1
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/typed-buffer/create-array-buffer.js +10 -0
- package/typed-buffer/create-array-buffer.js.map +1 -1
- package/typed-buffer/create-array-buffer.test.js +50 -0
- package/typed-buffer/create-array-buffer.test.js.map +1 -1
- package/typed-buffer/create-const-buffer.js +3 -0
- package/typed-buffer/create-const-buffer.js.map +1 -1
- package/typed-buffer/create-const-buffer.test.js +24 -0
- package/typed-buffer/create-const-buffer.test.js.map +1 -1
- package/typed-buffer/create-number-buffer.js +4 -0
- package/typed-buffer/create-number-buffer.js.map +1 -1
- package/typed-buffer/create-number-buffer.test.js +38 -0
- package/typed-buffer/create-number-buffer.test.js.map +1 -1
- package/typed-buffer/create-struct-buffer.js +11 -0
- package/typed-buffer/create-struct-buffer.js.map +1 -1
- package/typed-buffer/create-struct-buffer.test.js +60 -0
- package/typed-buffer/create-struct-buffer.test.js.map +1 -1
- package/typed-buffer/typed-buffer.d.ts +2 -0
- package/typed-buffer/typed-buffer.js.map +1 -1
- package/assembly/package.json +0 -1
- package/blob/package.json +0 -1
- package/cache/package.json +0 -1
- package/debug-type-test.js +0 -12
- package/debug-type-test.js.map +0 -1
- package/ecs/database/archetype-type-safety-test.d.ts +0 -21
- package/ecs/database/archetype-type-safety-test.js +0 -36
- package/ecs/database/archetype-type-safety-test.js.map +0 -1
- package/ecs/database/create-database-schema-test.js +0 -150
- package/ecs/database/create-database-schema-test.js.map +0 -1
- package/ecs/database/create-plugin-v2.d.ts +0 -79
- package/ecs/database/create-plugin-v2.js +0 -68
- package/ecs/database/create-plugin-v2.js.map +0 -1
- package/ecs/database/create-plugin-v2.test.js +0 -362
- package/ecs/database/create-plugin-v2.test.js.map +0 -1
- package/ecs/database/create-plugin.OLD.d.ts +0 -138
- package/ecs/database/create-plugin.OLD.js +0 -59
- package/ecs/database/create-plugin.OLD.js.map +0 -1
- package/ecs/database/database-with-systems.test.js +0 -292
- package/ecs/database/database-with-systems.test.js.map +0 -1
- package/ecs/database/database.plugin.create.test.OLD.js +0 -601
- package/ecs/database/database.plugin.create.test.OLD.js.map +0 -1
- package/ecs/database/database.plugin.create.test.js +0 -321
- package/ecs/database/database.plugin.create.test.js.map +0 -1
- package/ecs/database/database.plugin.test.d.ts +0 -1
- package/ecs/database/database.plugin.test.js +0 -90
- package/ecs/database/database.plugin.test.js.map +0 -1
- package/ecs/database/database.test copy.d.ts +0 -1
- package/ecs/database/database.test copy.js +0 -199
- package/ecs/database/database.test copy.js.map +0 -1
- package/ecs/database/multi-param-inference-poc.test.d.ts +0 -1
- package/ecs/database/multi-param-inference-poc.test.js +0 -96
- package/ecs/database/multi-param-inference-poc.test.js.map +0 -1
- package/ecs/database/old-plugin-create-with-dependencies-array.d.ts +0 -61
- package/ecs/database/old-plugin-create-with-dependencies-array.js +0 -76
- package/ecs/database/old-plugin-create-with-dependencies-array.js.map +0 -1
- package/ecs/database/overload-inference-poc.test.d.ts +0 -1
- package/ecs/database/overload-inference-poc.test.js +0 -109
- package/ecs/database/overload-inference-poc.test.js.map +0 -1
- package/ecs/database/schedule-type-check-demo.d.ts +0 -10
- package/ecs/database/schedule-type-check-demo.js +0 -71
- package/ecs/database/schedule-type-check-demo.js.map +0 -1
- package/ecs/database/test-archetype-validation.d.ts +0 -9
- package/ecs/database/test-archetype-validation.js +0 -14
- package/ecs/database/test-archetype-validation.js.map +0 -1
- package/ecs/database/test-exactkeys.d.ts +0 -1
- package/ecs/database/test-exactkeys.js +0 -17
- package/ecs/database/test-exactkeys.js.map +0 -1
- package/ecs/database/transactional-store/coalesce-transactions.test.js +0 -433
- package/ecs/database/transactional-store/coalesce-transactions.test.js.map +0 -1
- package/ecs/database/type-inference-demo.d.ts +0 -75
- package/ecs/database/type-inference-demo.js +0 -73
- package/ecs/database/type-inference-demo.js.map +0 -1
- package/ecs/database/type-inference-poc.test.d.ts +0 -1
- package/ecs/database/type-inference-poc.test.js +0 -73
- package/ecs/database/type-inference-poc.test.js.map +0 -1
- package/ecs/package.json +0 -1
- package/ecs/plugins/scheduler/create-scheduler-plugin.d.ts +0 -8
- package/ecs/plugins/scheduler/create-scheduler-plugin.js +0 -54
- package/ecs/plugins/scheduler/create-scheduler-plugin.js.map +0 -1
- package/ecs/plugins/scheduler/create-scheduler-plugin.test.d.ts +0 -1
- package/ecs/plugins/scheduler/create-scheduler-plugin.test.js +0 -198
- package/ecs/plugins/scheduler/create-scheduler-plugin.test.js.map +0 -1
- package/ecs/plugins/scheduler/type-inference-test.d.ts +0 -1
- package/ecs/plugins/scheduler/type-inference-test.js +0 -2
- package/ecs/plugins/scheduler/type-inference-test.js.map +0 -1
- package/ecs/store/entity-functions.d.ts +0 -7
- package/ecs/store/entity-functions.js +0 -2
- package/ecs/store/entity-functions.js.map +0 -1
- package/ecs/store/functions.d.ts +0 -2
- package/ecs/store/functions.js +0 -2
- package/ecs/store/functions.js.map +0 -1
- package/ecs/system/system-declaration.d.ts +0 -7
- package/ecs/system/system-declaration.js +0 -23
- package/ecs/system/system-declaration.js.map +0 -1
- package/ecs/system/system-declarations.d.ts +0 -4
- package/ecs/system/system-declarations.js +0 -23
- package/ecs/system/system-declarations.js.map +0 -1
- package/ecs/system/system-factory/public/create copy.d.ts +0 -12
- package/ecs/system/system-factory/public/create copy.js +0 -8
- package/ecs/system/system-factory/public/create copy.js.map +0 -1
- package/ecs/system/system-factory/public/create.d.ts +0 -12
- package/ecs/system/system-factory/public/create.js +0 -8
- package/ecs/system/system-factory/public/create.js.map +0 -1
- package/ecs/system/system-factory/public/create.test.d.ts +0 -1
- package/ecs/system/system-factory/public/create.test.js +0 -42
- package/ecs/system/system-factory/public/create.test.js.map +0 -1
- package/ecs/system/system-factory/public/index.d.ts +0 -1
- package/ecs/system/system-factory/public/index.js +0 -2
- package/ecs/system/system-factory/public/index.js.map +0 -1
- package/ecs/system/system-factory/system-factory.d.ts +0 -17
- package/ecs/system/system-factory/system-factory.js +0 -23
- package/ecs/system/system-factory/system-factory.js.map +0 -1
- package/ecs/system/system-factory.d.ts +0 -9
- package/ecs/system/system-factory.js +0 -23
- package/ecs/system/system-factory.js.map +0 -1
- package/ecs/system/system-interface.d.ts +0 -5
- package/ecs/system/system-interface.js +0 -2
- package/ecs/system/system-interface.js.map +0 -1
- package/ecs/system/system.d.ts +0 -4
- package/ecs/system/system.js +0 -23
- package/ecs/system/system.js.map +0 -1
- package/ecs/system/systems-type.d.ts +0 -2
- package/ecs/system/systems-type.js +0 -2
- package/ecs/system/systems-type.js.map +0 -1
- package/ecs/system/systems.d.ts +0 -2
- package/ecs/system/systems.js +0 -23
- package/ecs/system/systems.js.map +0 -1
- package/ecs/system/world-schema/public/create.d.ts +0 -12
- package/ecs/system/world-schema/public/create.js +0 -8
- package/ecs/system/world-schema/public/create.js.map +0 -1
- package/ecs/system/world-schema/public/create.test.d.ts +0 -1
- package/ecs/system/world-schema/public/create.test.js +0 -42
- package/ecs/system/world-schema/public/create.test.js.map +0 -1
- package/ecs/system/world-schema/public/index.d.ts +0 -1
- package/ecs/system/world-schema/public/index.js +0 -2
- package/ecs/system/world-schema/public/index.js.map +0 -1
- package/ecs/system/world-schema/system-factory.d.ts +0 -17
- package/ecs/system/world-schema/system-factory.js +0 -23
- package/ecs/system/world-schema/system-factory.js.map +0 -1
- package/ecs/world/calculate-system-order.d.ts +0 -18
- package/ecs/world/calculate-system-order.js +0 -113
- package/ecs/world/calculate-system-order.js.map +0 -1
- package/ecs/world/calculate-system-order.test.d.ts +0 -1
- package/ecs/world/calculate-system-order.test.js +0 -168
- package/ecs/world/calculate-system-order.test.js.map +0 -1
- package/ecs/world/create-world-schema-test.d.ts +0 -1
- package/ecs/world/create-world-schema-test.js +0 -294
- package/ecs/world/create-world-schema-test.js.map +0 -1
- package/ecs/world/create-world-type-test.d.ts +0 -1
- package/ecs/world/create-world-type-test.js +0 -129
- package/ecs/world/create-world-type-test.js.map +0 -1
- package/ecs/world/create-world.d.ts +0 -19
- package/ecs/world/create-world.js +0 -80
- package/ecs/world/create-world.js.map +0 -1
- package/ecs/world/create-world.test.d.ts +0 -1
- package/ecs/world/create-world.test.js +0 -292
- package/ecs/world/create-world.test.js.map +0 -1
- package/ecs/world/public/world-schema/public/create.d.ts +0 -12
- package/ecs/world/public/world-schema/public/create.js +0 -8
- package/ecs/world/public/world-schema/public/create.js.map +0 -1
- package/ecs/world/public/world-schema/public/create.test.d.ts +0 -1
- package/ecs/world/public/world-schema/public/create.test.js +0 -42
- package/ecs/world/public/world-schema/public/create.test.js.map +0 -1
- package/ecs/world/public/world-schema/public/index.d.ts +0 -1
- package/ecs/world/public/world-schema/public/index.js +0 -2
- package/ecs/world/public/world-schema/public/index.js.map +0 -1
- package/ecs/world/public/world-schema/world-schema.d.ts +0 -17
- package/ecs/world/public/world-schema/world-schema.js +0 -23
- package/ecs/world/public/world-schema/world-schema.js.map +0 -1
- package/ecs/world/system-declaration.d.ts +0 -1
- package/ecs/world/system-declaration.js +0 -23
- package/ecs/world/system-declaration.js.map +0 -1
- package/ecs/world/system-schedule-typing-test.d.ts +0 -1
- package/ecs/world/system-schedule-typing-test.js +0 -83
- package/ecs/world/system-schedule-typing-test.js.map +0 -1
- package/ecs/world/world-schema/public/create.d.ts +0 -12
- package/ecs/world/world-schema/public/create.js +0 -10
- package/ecs/world/world-schema/public/create.js.map +0 -1
- package/ecs/world/world-schema/public/create.test.d.ts +0 -1
- package/ecs/world/world-schema/public/create.test.js +0 -41
- package/ecs/world/world-schema/public/create.test.js.map +0 -1
- package/ecs/world/world-schema/public/index.d.ts +0 -1
- package/ecs/world/world-schema/public/index.js +0 -2
- package/ecs/world/world-schema/public/index.js.map +0 -1
- package/ecs/world/world-schema/system-factory.d.ts +0 -17
- package/ecs/world/world-schema/system-factory.js +0 -23
- package/ecs/world/world-schema/system-factory.js.map +0 -1
- package/ecs/world/world-schema/world-schema.d.ts +0 -19
- package/ecs/world/world-schema/world-schema.js +0 -23
- package/ecs/world/world-schema/world-schema.js.map +0 -1
- package/ecs/world/world.d.ts +0 -86
- package/ecs/world/world.js +0 -81
- package/ecs/world/world.js.map +0 -1
- package/ecs/world/world.test.d.ts +0 -1
- package/ecs/world/world.test.js +0 -176
- package/ecs/world/world.test.js.map +0 -1
- package/functions/package.json +0 -1
- package/lit/elements/application-element copy.d.ts +0 -9
- package/lit/elements/application-element copy.js +0 -62
- package/lit/elements/application-element copy.js.map +0 -1
- package/lit/package.json +0 -1
- package/math/package.json +0 -1
- package/observe/package.json +0 -1
- package/old-ecs/package.json +0 -1
- package/perftest/package.json +0 -1
- package/samples/package.json +0 -1
- package/schema/package.json +0 -1
- package/service/package.json +0 -1
- package/table/package.json +0 -1
- package/typed-buffer/package.json +0 -1
- package/types/package.json +0 -1
- /package/{debug-type-test.d.ts → ecs/database/create-plugin-type.type-test.d.ts} +0 -0
- /package/ecs/database/{create-database-schema-test.d.ts → create-plugin-type.type.test.d.ts} +0 -0
- /package/ecs/database/{create-plugin-v2.test.d.ts → experimental-action-types.d.ts} +0 -0
- /package/ecs/database/{database-with-systems.test.d.ts → from-plugin.type-test.d.ts} +0 -0
- /package/ecs/database/{database.plugin.create.test.OLD.d.ts → plugin-types.d.ts} +0 -0
- /package/ecs/database/{database.plugin.create.test.d.ts → type-investigation.test.d.ts} +0 -0
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
// /*MIT License
|
|
2
|
+
export {};
|
|
3
|
+
// © Copyright 2025 Adobe. All rights reserved.
|
|
4
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
// of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
// in the Software without restriction, including without limitation the rights
|
|
7
|
+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
// copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
// furnished to do so, subject to the following conditions:
|
|
10
|
+
// The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
// copies or substantial portions of the Software.
|
|
12
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
13
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
14
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
15
|
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
16
|
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
17
|
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
18
|
+
// SOFTWARE.*/
|
|
19
|
+
// /**
|
|
20
|
+
// * EXPERIMENTAL: Testing type inference patterns for actions
|
|
21
|
+
// * This file is for experimentation only - not part of the actual implementation
|
|
22
|
+
// */
|
|
23
|
+
// import type { Database } from "./database.js";
|
|
24
|
+
// import type { ComponentSchemas } from "../component-schemas.js";
|
|
25
|
+
// import type { ResourceSchemas } from "../resource-schemas.js";
|
|
26
|
+
// import type { ArchetypeComponents } from "../store/archetype-components.js";
|
|
27
|
+
// import type { TransactionDeclarations, ToTransactionFunctions } from "../store/transaction-functions.js";
|
|
28
|
+
// import type { ActionDeclarations, ToActionFunctions } from "../store/action-functions.js";
|
|
29
|
+
// import type { FromSchemas } from "../../schema/index.js";
|
|
30
|
+
// import type { StringKeyof, Simplify } from "../../types/types.js";
|
|
31
|
+
// type RemoveIndex<T> = Simplify<{
|
|
32
|
+
// [K in keyof T as
|
|
33
|
+
// string extends K ? never :
|
|
34
|
+
// number extends K ? never :
|
|
35
|
+
// symbol extends K ? never :
|
|
36
|
+
// K
|
|
37
|
+
// ]: T[K]
|
|
38
|
+
// }>;
|
|
39
|
+
// // Test 1: Current approach - using ActionDeclarations constraint
|
|
40
|
+
// function testCurrentApproach<
|
|
41
|
+
// const CS extends ComponentSchemas,
|
|
42
|
+
// const RS extends ResourceSchemas,
|
|
43
|
+
// const A extends ArchetypeComponents<StringKeyof<CS>>,
|
|
44
|
+
// const TD extends TransactionDeclarations<FromSchemas<CS>, FromSchemas<RS>, A>,
|
|
45
|
+
// const S extends string,
|
|
46
|
+
// const AD extends ActionDeclarations<FromSchemas<CS>, FromSchemas<RS>, A, ToTransactionFunctions<TD>, S> = {}
|
|
47
|
+
// >(
|
|
48
|
+
// plugins: {
|
|
49
|
+
// components?: CS,
|
|
50
|
+
// resources?: RS,
|
|
51
|
+
// archetypes?: A,
|
|
52
|
+
// transactions?: TD,
|
|
53
|
+
// systems?: { readonly [K in S]: {
|
|
54
|
+
// readonly create: (db: Database<
|
|
55
|
+
// FromSchemas<CS>,
|
|
56
|
+
// FromSchemas<RS>,
|
|
57
|
+
// A,
|
|
58
|
+
// ToTransactionFunctions<TD>,
|
|
59
|
+
// S,
|
|
60
|
+
// ToActionFunctions<AD>
|
|
61
|
+
// >) => (() => void) | void;
|
|
62
|
+
// } },
|
|
63
|
+
// actions?: AD
|
|
64
|
+
// }
|
|
65
|
+
// ) {
|
|
66
|
+
// // This should work if AD is properly constrained
|
|
67
|
+
// const testActions = plugins.actions;
|
|
68
|
+
// return testActions;
|
|
69
|
+
// }
|
|
70
|
+
// // Test 2: Inline explicit Database type (EXACTLY like systems pattern)
|
|
71
|
+
// // Key insight: Systems use 'string' not 'S' for the system name in Database type!
|
|
72
|
+
// // This breaks the circular dependency while still providing correct types
|
|
73
|
+
// function testInlineExplicitType<
|
|
74
|
+
// const CS extends ComponentSchemas,
|
|
75
|
+
// const RS extends ResourceSchemas,
|
|
76
|
+
// const A extends ArchetypeComponents<StringKeyof<CS>>,
|
|
77
|
+
// const TD extends TransactionDeclarations<FromSchemas<CS>, FromSchemas<RS>, A>,
|
|
78
|
+
// const S extends string,
|
|
79
|
+
// const AD extends ActionDeclarations<FromSchemas<CS>, FromSchemas<RS>, A, ToTransactionFunctions<TD>, S> = {}
|
|
80
|
+
// >(
|
|
81
|
+
// plugins: {
|
|
82
|
+
// components?: CS,
|
|
83
|
+
// resources?: RS,
|
|
84
|
+
// archetypes?: A,
|
|
85
|
+
// transactions?: TD,
|
|
86
|
+
// systems?: { readonly [K in S]: {
|
|
87
|
+
// readonly create: (db: Database<
|
|
88
|
+
// FromSchemas<CS>,
|
|
89
|
+
// FromSchemas<RS>,
|
|
90
|
+
// A,
|
|
91
|
+
// ToTransactionFunctions<TD>,
|
|
92
|
+
// string, // Note: 'string' not 'S' - this is the key!
|
|
93
|
+
// ToActionFunctions<AD>
|
|
94
|
+
// >) => (() => void) | void;
|
|
95
|
+
// } },
|
|
96
|
+
// actions?: {
|
|
97
|
+
// readonly [K in string]: (db: Database<
|
|
98
|
+
// FromSchemas<CS>,
|
|
99
|
+
// FromSchemas<RS>,
|
|
100
|
+
// A,
|
|
101
|
+
// ToTransactionFunctions<TD>,
|
|
102
|
+
// string, // Use 'string' not 'S' to match systems pattern
|
|
103
|
+
// ToActionFunctions<AD>
|
|
104
|
+
// >, input?: any) => any
|
|
105
|
+
// }
|
|
106
|
+
// }
|
|
107
|
+
// ) {
|
|
108
|
+
// const testActions = plugins.actions;
|
|
109
|
+
// return testActions;
|
|
110
|
+
// }
|
|
111
|
+
// // Test 2b: Inline explicit Database type without AD in Database (to break circular dependency)
|
|
112
|
+
// function testInlineExplicitTypeNoCircular<
|
|
113
|
+
// const CS extends ComponentSchemas,
|
|
114
|
+
// const RS extends ResourceSchemas,
|
|
115
|
+
// const A extends ArchetypeComponents<StringKeyof<CS>>,
|
|
116
|
+
// const TD extends TransactionDeclarations<FromSchemas<CS>, FromSchemas<RS>, A>,
|
|
117
|
+
// const S extends string
|
|
118
|
+
// >(
|
|
119
|
+
// plugins: {
|
|
120
|
+
// components?: CS,
|
|
121
|
+
// resources?: RS,
|
|
122
|
+
// archetypes?: A,
|
|
123
|
+
// transactions?: TD,
|
|
124
|
+
// systems?: { readonly [K in S]: {
|
|
125
|
+
// readonly create: (db: Database<
|
|
126
|
+
// FromSchemas<CS>,
|
|
127
|
+
// FromSchemas<RS>,
|
|
128
|
+
// A,
|
|
129
|
+
// ToTransactionFunctions<TD>,
|
|
130
|
+
// S,
|
|
131
|
+
// {} // Empty actions in Database type to break circular dependency
|
|
132
|
+
// >) => (() => void) | void;
|
|
133
|
+
// } },
|
|
134
|
+
// actions?: {
|
|
135
|
+
// readonly [K in string]: (db: Database<
|
|
136
|
+
// FromSchemas<CS>,
|
|
137
|
+
// FromSchemas<RS>,
|
|
138
|
+
// A,
|
|
139
|
+
// ToTransactionFunctions<TD>,
|
|
140
|
+
// S,
|
|
141
|
+
// {} // Empty actions - but this means actions can't call other actions
|
|
142
|
+
// >, input?: any) => any
|
|
143
|
+
// }
|
|
144
|
+
// }
|
|
145
|
+
// ) {
|
|
146
|
+
// const testActions = plugins.actions;
|
|
147
|
+
// return testActions;
|
|
148
|
+
// }
|
|
149
|
+
// // Test 3: Using satisfies to help inference
|
|
150
|
+
// function testSatisfiesApproach<
|
|
151
|
+
// const CS extends ComponentSchemas,
|
|
152
|
+
// const RS extends ResourceSchemas,
|
|
153
|
+
// const A extends ArchetypeComponents<StringKeyof<CS>>,
|
|
154
|
+
// const TD extends TransactionDeclarations<FromSchemas<CS>, FromSchemas<RS>, A>,
|
|
155
|
+
// const S extends string,
|
|
156
|
+
// const AD extends ActionDeclarations<FromSchemas<CS>, FromSchemas<RS>, A, ToTransactionFunctions<TD>, S> = {}
|
|
157
|
+
// >(
|
|
158
|
+
// plugins: {
|
|
159
|
+
// components?: CS,
|
|
160
|
+
// resources?: RS,
|
|
161
|
+
// archetypes?: A,
|
|
162
|
+
// transactions?: TD,
|
|
163
|
+
// systems?: { readonly [K in S]: {
|
|
164
|
+
// readonly create: (db: Database<
|
|
165
|
+
// FromSchemas<CS>,
|
|
166
|
+
// FromSchemas<RS>,
|
|
167
|
+
// A,
|
|
168
|
+
// ToTransactionFunctions<TD>,
|
|
169
|
+
// S,
|
|
170
|
+
// ToActionFunctions<AD>
|
|
171
|
+
// >) => (() => void) | void;
|
|
172
|
+
// } },
|
|
173
|
+
// actions?: AD
|
|
174
|
+
// }
|
|
175
|
+
// ) {
|
|
176
|
+
// const testActions = plugins.actions;
|
|
177
|
+
// return testActions;
|
|
178
|
+
// }
|
|
179
|
+
// // Test cases to verify inference
|
|
180
|
+
// function testTypeInference() {
|
|
181
|
+
// // Test Case 1: Current approach - using ActionDeclarations constraint
|
|
182
|
+
// const test1 = testCurrentApproach({
|
|
183
|
+
// components: {
|
|
184
|
+
// a: { type: "number" },
|
|
185
|
+
// b: { type: "string" }
|
|
186
|
+
// },
|
|
187
|
+
// resources: {
|
|
188
|
+
// c: { default: false as boolean }
|
|
189
|
+
// },
|
|
190
|
+
// transactions: {
|
|
191
|
+
// testTx: (store) => {
|
|
192
|
+
// // store should be typed - verify this works
|
|
193
|
+
// store.resources.c = true;
|
|
194
|
+
// }
|
|
195
|
+
// },
|
|
196
|
+
// actions: {
|
|
197
|
+
// testAction: (db) => {
|
|
198
|
+
// // QUESTION: Is db typed here? Or does it need 'any'?
|
|
199
|
+
// // db should be typed - does it work?
|
|
200
|
+
// db.transactions.testTx();
|
|
201
|
+
// return db.resources.c;
|
|
202
|
+
// }
|
|
203
|
+
// }
|
|
204
|
+
// });
|
|
205
|
+
// // Test Case 2: Inline explicit type (like systems pattern)
|
|
206
|
+
// const test2 = testInlineExplicitType({
|
|
207
|
+
// components: {
|
|
208
|
+
// a: { type: "number" },
|
|
209
|
+
// b: { type: "string" }
|
|
210
|
+
// },
|
|
211
|
+
// resources: {
|
|
212
|
+
// c: { default: false as boolean }
|
|
213
|
+
// },
|
|
214
|
+
// transactions: {
|
|
215
|
+
// testTx: (store) => {
|
|
216
|
+
// store.resources.c = true;
|
|
217
|
+
// }
|
|
218
|
+
// },
|
|
219
|
+
// actions: {
|
|
220
|
+
// testAction: (db) => {
|
|
221
|
+
// // QUESTION: Is db typed here with inline explicit type?
|
|
222
|
+
// // db should be typed with inline explicit type
|
|
223
|
+
// db.transactions.testTx();
|
|
224
|
+
// return db.resources.c;
|
|
225
|
+
// }
|
|
226
|
+
// }
|
|
227
|
+
// });
|
|
228
|
+
// // Test Case 3: With satisfies helper
|
|
229
|
+
// const test3 = testSatisfiesApproach({
|
|
230
|
+
// components: {
|
|
231
|
+
// a: { type: "number" },
|
|
232
|
+
// b: { type: "string" }
|
|
233
|
+
// },
|
|
234
|
+
// resources: {
|
|
235
|
+
// c: { default: false as boolean }
|
|
236
|
+
// },
|
|
237
|
+
// transactions: {
|
|
238
|
+
// testTx: (store) => {
|
|
239
|
+
// store.resources.c = true;
|
|
240
|
+
// }
|
|
241
|
+
// },
|
|
242
|
+
// actions: {
|
|
243
|
+
// testAction: (db) => {
|
|
244
|
+
// // QUESTION: Does satisfies help with inference?
|
|
245
|
+
// // db should be typed
|
|
246
|
+
// db.transactions.testTx();
|
|
247
|
+
// return db.resources.c;
|
|
248
|
+
// }
|
|
249
|
+
// } satisfies ActionDeclarations<any, any, any, any, any>
|
|
250
|
+
// });
|
|
251
|
+
// // Test Case 4: Actions without circular dependency (can't call other actions, but can call transactions)
|
|
252
|
+
// const test4 = testActionsWithoutCircularDependency({
|
|
253
|
+
// components: {
|
|
254
|
+
// a: { type: "number" },
|
|
255
|
+
// b: { type: "string" }
|
|
256
|
+
// },
|
|
257
|
+
// resources: {
|
|
258
|
+
// c: { default: false as boolean }
|
|
259
|
+
// },
|
|
260
|
+
// transactions: {
|
|
261
|
+
// testTx: (store) => {
|
|
262
|
+
// store.resources.c = true;
|
|
263
|
+
// }
|
|
264
|
+
// },
|
|
265
|
+
// actions: {
|
|
266
|
+
// testAction: (db) => {
|
|
267
|
+
// // QUESTION: Is db typed here? This should work since no circular dependency
|
|
268
|
+
// // db should be typed - can call transactions but not other actions
|
|
269
|
+
// db.transactions.testTx();
|
|
270
|
+
// return db.resources.c;
|
|
271
|
+
// }
|
|
272
|
+
// }
|
|
273
|
+
// });
|
|
274
|
+
// }
|
|
275
|
+
//# sourceMappingURL=experimental-action-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"experimental-action-types.js","sourceRoot":"","sources":["../../../src/ecs/database/experimental-action-types.ts"],"names":[],"mappings":"AAAA,gBAAgB;;AAEhB,+CAA+C;AAE/C,+EAA+E;AAC/E,gFAAgF;AAChF,+EAA+E;AAC/E,4EAA4E;AAC5E,wEAAwE;AACxE,2DAA2D;AAE3D,iFAAiF;AACjF,kDAAkD;AAElD,6EAA6E;AAC7E,2EAA2E;AAC3E,8EAA8E;AAC9E,yEAAyE;AACzE,gFAAgF;AAChF,gFAAgF;AAChF,cAAc;AAEd,MAAM;AACN,+DAA+D;AAC/D,mFAAmF;AACnF,MAAM;AAEN,iDAAiD;AACjD,mEAAmE;AACnE,i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B;AACrB,oCAAoC;AACpC,wEAAwE;AACxE,wDAAwD;AACxD,4CAA4C;AAC5C,yCAAyC;AACzC,gBAAgB;AAChB,YAAY;AACZ,UAAU;AAEV,kEAAkE;AAClE,6CAA6C;AAC7C,wBAAwB;AACxB,qCAAqC;AACrC,oCAAoC;AACpC,aAAa;AACb,uBAAuB;AACvB,+CAA+C;AAC/C,aAAa;AACb,0BAA0B;AAC1B,mCAAmC;AACnC,4CAA4C;AAC5C,gBAAgB;AAChB,aAAa;AACb,qBAAqB;AACrB,oCAAoC;AACpC,2EAA2E;AAC3E,kEAAkE;AAClE,4CAA4C;AAC5C,yCAAyC;AACzC,gBAAgB;AAChB,YAAY;AACZ,UAAU;AAEV,4CAA4C;AAC5C,4CAA4C;AAC5C,wBAAwB;AACxB,qCAAqC;AACrC,oCAAoC;AACpC,aAAa;AACb,uBAAuB;AACvB,+CAA+C;AAC/C,aAAa;AACb,0BAA0B;AAC1B,mCAAmC;AACnC,4CAA4C;AAC5C,gBAAgB;AAChB,aAAa;AACb,qBAAqB;AACrB,oCAAoC;AACpC,mEAAmE;AACnE,wCAAwC;AACxC,4CAA4C;AAC5C,yCAAyC;AACzC,gBAAgB;AAChB,kEAAkE;AAClE,UAAU;AAEV,gHAAgH;AAChH,2DAA2D;AAC3D,wBAAwB;AACxB,qCAAqC;AACrC,oCAAoC;AACpC,aAAa;AACb,uBAAuB;AACvB,+CAA+C;AAC/C,aAAa;AACb,0BAA0B;AAC1B,mCAAmC;AACnC,4CAA4C;AAC5C,gBAAgB;AAChB,aAAa;AACb,qBAAqB;AACrB,oCAAoC;AACpC,+FAA+F;AAC/F,sFAAsF;AACtF,4CAA4C;AAC5C,yCAAyC;AACzC,gBAAgB;AAChB,YAAY;AACZ,UAAU;AACV,IAAI"}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
// © 2026 Adobe. MIT License. See /LICENSE for details.
|
|
2
|
+
import { Database } from "./database.js";
|
|
3
|
+
/**
|
|
4
|
+
* Type-only tests for Database.FromPlugin and Database.FromPluginWithStore helper types.
|
|
5
|
+
*
|
|
6
|
+
* These tests verify that:
|
|
7
|
+
* 1. Database.FromPlugin extracts correct Database type from simple plugins
|
|
8
|
+
* 2. Database.FromPluginWithStore includes store intersection
|
|
9
|
+
* 3. Both work with plugins using `extends`
|
|
10
|
+
* 4. Both work with combined plugins
|
|
11
|
+
*
|
|
12
|
+
* The tests verify type correctness using Assert<Equal<...>> to catch type-breaking changes early.
|
|
13
|
+
*
|
|
14
|
+
* Note: These are compile-time type checks only - they don't need to execute.
|
|
15
|
+
*/
|
|
16
|
+
// ============================================================================
|
|
17
|
+
// PROOF: Types are equivalent but Equal check fails
|
|
18
|
+
// ============================================================================
|
|
19
|
+
function proofTypesAreEquivalentButNotEqual() {
|
|
20
|
+
const plugin = Database.Plugin.create({
|
|
21
|
+
components: {
|
|
22
|
+
position: { type: "number" },
|
|
23
|
+
},
|
|
24
|
+
resources: {
|
|
25
|
+
time: { default: 0 },
|
|
26
|
+
},
|
|
27
|
+
archetypes: {
|
|
28
|
+
Position: ["position"],
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
const db = Database.create(plugin);
|
|
32
|
+
// PROOF 7: Practical compatibility test - can we use ExtractedDatabase where CreatedDatabase is expected?
|
|
33
|
+
// This function accepts CreatedDatabase - if ExtractedDatabase works here, they're compatible
|
|
34
|
+
function acceptCreatedDatabase(db) {
|
|
35
|
+
// Access key properties to verify compatibility
|
|
36
|
+
const _resources = db.resources;
|
|
37
|
+
const _transactions = db.transactions;
|
|
38
|
+
const _store = db.store; // store might not be in CreatedDatabase type
|
|
39
|
+
}
|
|
40
|
+
// PROOF 8: Can we use CreatedDatabase where ExtractedDatabase is expected?
|
|
41
|
+
function acceptExtractedDatabase(db) {
|
|
42
|
+
const _resources = db.resources;
|
|
43
|
+
const _transactions = db.transactions;
|
|
44
|
+
}
|
|
45
|
+
// If both of these compile without errors, types are practically compatible
|
|
46
|
+
acceptCreatedDatabase(db); // ✅ Should work - db is CreatedDatabase
|
|
47
|
+
// CONCLUSION:
|
|
48
|
+
// The proof above shows:
|
|
49
|
+
// 1. Key properties (resources, components, archetypes) match exactly ✅
|
|
50
|
+
// 2. Equal check fails (too strict for complex types) ✅
|
|
51
|
+
// 3. Bidirectional assignability - check by uncommenting PROOF B assertions
|
|
52
|
+
// - If both pass → types ARE equivalent, Equal is too strict
|
|
53
|
+
// - If either fails → types are NOT equivalent, Equal correctly fails
|
|
54
|
+
//
|
|
55
|
+
// To see the actual results, hover over the type aliases in your IDE:
|
|
56
|
+
// - _ExtractedToCreated, _CreatedToExtracted, _EquivalentTypesResult, _EqualResult
|
|
57
|
+
}
|
|
58
|
+
// ============================================================================
|
|
59
|
+
// SIMPLE PLUGIN TESTS
|
|
60
|
+
// ============================================================================
|
|
61
|
+
function testFromPluginSimple() {
|
|
62
|
+
const plugin = Database.Plugin.create({
|
|
63
|
+
components: {
|
|
64
|
+
position: { type: "number" },
|
|
65
|
+
},
|
|
66
|
+
resources: {
|
|
67
|
+
time: { default: 0 },
|
|
68
|
+
},
|
|
69
|
+
archetypes: {
|
|
70
|
+
Position: ["position"],
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
// Test that FromPlugin extracts a compatible type to Database.create
|
|
74
|
+
const db = Database.create(plugin);
|
|
75
|
+
}
|
|
76
|
+
function testFromPluginWithStoreSimple() {
|
|
77
|
+
const plugin = Database.Plugin.create({
|
|
78
|
+
components: {
|
|
79
|
+
position: { type: "number" },
|
|
80
|
+
},
|
|
81
|
+
resources: {
|
|
82
|
+
time: { default: 0 },
|
|
83
|
+
},
|
|
84
|
+
archetypes: {
|
|
85
|
+
Position: ["position"],
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
// ============================================================================
|
|
90
|
+
// PLUGIN WITH EXTENDS TESTS
|
|
91
|
+
// ============================================================================
|
|
92
|
+
function testFromPluginWithExtends() {
|
|
93
|
+
const basePlugin = Database.Plugin.create({
|
|
94
|
+
components: {
|
|
95
|
+
base: { type: "string" },
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
const extendedPlugin = Database.Plugin.create({
|
|
99
|
+
extends: basePlugin,
|
|
100
|
+
components: {
|
|
101
|
+
position: { type: "number" },
|
|
102
|
+
},
|
|
103
|
+
resources: {
|
|
104
|
+
time: { default: 0 },
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
// Test that FromPlugin extracts a compatible type to Database.create
|
|
108
|
+
const db = Database.create(extendedPlugin);
|
|
109
|
+
}
|
|
110
|
+
function testFromPluginWithStoreExtends() {
|
|
111
|
+
const basePlugin = Database.Plugin.create({
|
|
112
|
+
components: {
|
|
113
|
+
base: { type: "string" },
|
|
114
|
+
},
|
|
115
|
+
});
|
|
116
|
+
const extendedPlugin = Database.Plugin.create({
|
|
117
|
+
extends: basePlugin,
|
|
118
|
+
components: {
|
|
119
|
+
position: { type: "number" },
|
|
120
|
+
},
|
|
121
|
+
resources: {
|
|
122
|
+
time: { default: 0 },
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
// ============================================================================
|
|
127
|
+
// COMBINED PLUGIN TESTS
|
|
128
|
+
// ============================================================================
|
|
129
|
+
function testFromPluginCombined() {
|
|
130
|
+
const plugin1 = Database.Plugin.create({
|
|
131
|
+
components: {
|
|
132
|
+
a: { type: "number" },
|
|
133
|
+
},
|
|
134
|
+
});
|
|
135
|
+
const plugin2 = Database.Plugin.create({
|
|
136
|
+
components: {
|
|
137
|
+
b: { type: "string" },
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
const combinedPlugin = Database.Plugin.combine(plugin1, plugin2);
|
|
141
|
+
// Test that FromPlugin extracts a compatible type to Database.create
|
|
142
|
+
const db = Database.create(combinedPlugin);
|
|
143
|
+
}
|
|
144
|
+
function testFromPluginWithStoreCombined() {
|
|
145
|
+
const plugin1 = Database.Plugin.create({
|
|
146
|
+
components: {
|
|
147
|
+
a: { type: "number" },
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
const plugin2 = Database.Plugin.create({
|
|
151
|
+
components: {
|
|
152
|
+
b: { type: "string" },
|
|
153
|
+
},
|
|
154
|
+
});
|
|
155
|
+
const combinedPlugin = Database.Plugin.combine(plugin1, plugin2);
|
|
156
|
+
}
|
|
157
|
+
// ============================================================================
|
|
158
|
+
// CONVENIENCE ALIAS TESTS
|
|
159
|
+
// ============================================================================
|
|
160
|
+
function testConvenienceAliases() {
|
|
161
|
+
const plugin = Database.Plugin.create({
|
|
162
|
+
components: {
|
|
163
|
+
position: { type: "number" },
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
// ============================================================================
|
|
168
|
+
// STORE PROPERTY ACCESS TESTS
|
|
169
|
+
// ============================================================================
|
|
170
|
+
function testStorePropertyAccess() {
|
|
171
|
+
const plugin = Database.Plugin.create({
|
|
172
|
+
components: {
|
|
173
|
+
position: { type: "number" },
|
|
174
|
+
},
|
|
175
|
+
archetypes: {
|
|
176
|
+
Position: ["position"],
|
|
177
|
+
},
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
//# sourceMappingURL=from-plugin.type-test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"from-plugin.type-test.js","sourceRoot":"","sources":["../../../src/ecs/database/from-plugin.type-test.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAKvD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGzC;;;;;;;;;;;;GAYG;AAEH,+EAA+E;AAC/E,oDAAoD;AACpD,+EAA+E;AAE/E,SAAS,kCAAkC;IACvC,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;QAClC,UAAU,EAAE;YACR,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;SAC/B;QACD,SAAS,EAAE;YACP,IAAI,EAAE,EAAE,OAAO,EAAE,CAAW,EAAE;SACjC;QACD,U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Q,EAAE;SAC/B;KACJ,CAAC,CAAC;AAaP,CAAC;AAED,+EAA+E;AAC/E,8BAA8B;AAC9B,+EAA+E;AAE/E,SAAS,uBAAuB;IAC5B,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;QAClC,UAAU,EAAE;YACR,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;SAC/B;QACD,UAAU,EAAE;YACR,QAAQ,EAAE,CAAC,UAAU,CAAC;SACzB;KACJ,CAAC,CAAC;AAiBP,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-types.js","sourceRoot":"","sources":["../../../src/ecs/database/plugin-types.ts"],"names":[],"mappings":"AAeA,SAAS,YAAY,CAYjB,OAoBC,EACD,MAA+C;IAO/C,OAAO,IAAW,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/*MIT License
|
|
2
|
+
|
|
3
|
+
© Copyright 2025 Adobe. All rights reserved.
|
|
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.*/
|
|
22
|
+
import { describe, it } from "vitest";
|
|
23
|
+
import { createPlugin } from "./create-plugin.js";
|
|
24
|
+
import { Database } from "./database.js";
|
|
25
|
+
import { Vec4 } from "../../math/index.js";
|
|
26
|
+
import { scheduler } from "../plugins/scheduler/scheduler.js";
|
|
27
|
+
describe("Type Investigation: componentSchemas type inference", () => {
|
|
28
|
+
it("should investigate ComponentSchemas index signature behavior", () => {
|
|
29
|
+
// Expected: string
|
|
30
|
+
// Test 3: What happens with a specific component schema object?
|
|
31
|
+
const specificSchema = { foo: Vec4.schema };
|
|
32
|
+
// Expected: "foo"
|
|
33
|
+
});
|
|
34
|
+
it("should investigate plugin type inference", () => {
|
|
35
|
+
const plugin = createPlugin({
|
|
36
|
+
components: {
|
|
37
|
+
foo: Vec4.schema,
|
|
38
|
+
}
|
|
39
|
+
}, [scheduler]);
|
|
40
|
+
// What is the inferred CS type parameter?
|
|
41
|
+
// This is what gets passed to createDatabaseFromPlugin
|
|
42
|
+
});
|
|
43
|
+
it("should investigate database type inference", () => {
|
|
44
|
+
const plugin = createPlugin({
|
|
45
|
+
components: {
|
|
46
|
+
foo: Vec4.schema,
|
|
47
|
+
}
|
|
48
|
+
}, [scheduler]);
|
|
49
|
+
const database = Database.create(plugin);
|
|
50
|
+
// What is StringKeyof<C> where C is the Components type parameter?
|
|
51
|
+
// This is what determines the keys of componentSchemas
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
//# sourceMappingURL=type-investigation.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-investigation.test.js","sourceRoot":"","sources":["../../../src/ecs/database/type-investigation.test.ts"],"names":[],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positionOnlyArchetypes[0].components.has("health")).toBe(false);
|
|
92
92
|
});
|
|
93
|
+
it("should exclude multiple components - guarantees neither component exists in result", () => {
|
|
94
|
+
const core = factory({
|
|
95
|
+
position: positionSchema,
|
|
96
|
+
health: healthSchema,
|
|
97
|
+
name: nameSchema,
|
|
98
|
+
});
|
|
99
|
+
// Create archetypes with different component combinations
|
|
100
|
+
const positionOnly = core.ensureArchetype(["id", "position"]);
|
|
101
|
+
const positionHealth = core.ensureArchetype(["id", "position", "health"]);
|
|
102
|
+
const positionName = core.ensureArchetype(["id", "position", "name"]);
|
|
103
|
+
const positionHealthName = core.ensureArchetype(["id", "position", "health", "name"]);
|
|
104
|
+
// Query for position but exclude both health and name
|
|
105
|
+
// Should only return archetype with position only (neither health nor name)
|
|
106
|
+
const result = core.queryArchetypes(["position"], { exclude: ["health", "name"] });
|
|
107
|
+
expect(result).toHaveLength(1);
|
|
108
|
+
expect(result[0].components.has("position")).toBe(true);
|
|
109
|
+
expect(result[0].components.has("health")).toBe(false);
|
|
110
|
+
expect(result[0].components.has("name")).toBe(false);
|
|
111
|
+
// Verify it's the position-only archetype
|
|
112
|
+
expect(result[0]).toBe(positionOnly);
|
|
113
|
+
});
|
|
93
114
|
it("should ensure archetype creates new archetype when needed", () => {
|
|
94
115
|
const core = factory({
|
|
95
116
|
position: positionSchema,
|