@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
|
@@ -1,150 +0,0 @@
|
|
|
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 { Database } from "./database.js";
|
|
23
|
-
const databaseSchema = Database.Plugin.create({
|
|
24
|
-
components: {
|
|
25
|
-
velocity: { type: "number" },
|
|
26
|
-
particle: { type: "boolean" },
|
|
27
|
-
},
|
|
28
|
-
resources: {
|
|
29
|
-
mousePosition: { type: "number", default: 0 },
|
|
30
|
-
fooPosition: { type: "number", default: 0 },
|
|
31
|
-
},
|
|
32
|
-
archetypes: {
|
|
33
|
-
Particle: ["particle"],
|
|
34
|
-
DynamicParticle: ["particle", "velocity"],
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
// Test database schema dependencies and merging
|
|
38
|
-
const aSchema = Database.Plugin.create({
|
|
39
|
-
components: {
|
|
40
|
-
a: { type: "number" },
|
|
41
|
-
b: { type: "string" }
|
|
42
|
-
},
|
|
43
|
-
resources: {
|
|
44
|
-
c: { default: "string" }
|
|
45
|
-
},
|
|
46
|
-
archetypes: {
|
|
47
|
-
one: ["a", "b"]
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
const bSchema = Database.Plugin.create({
|
|
51
|
-
components: {
|
|
52
|
-
x: { type: "number" },
|
|
53
|
-
y: { type: "string" }
|
|
54
|
-
},
|
|
55
|
-
resources: {
|
|
56
|
-
z: { default: "string" }
|
|
57
|
-
},
|
|
58
|
-
archetypes: {
|
|
59
|
-
two: ["x", "y"]
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
const cSchema = Database.Plugin.create(aSchema, bSchema, {
|
|
63
|
-
components: {
|
|
64
|
-
m: { type: "number" },
|
|
65
|
-
n: { type: "string" }
|
|
66
|
-
},
|
|
67
|
-
resources: {
|
|
68
|
-
c: { default: "string" }
|
|
69
|
-
},
|
|
70
|
-
archetypes: {
|
|
71
|
-
three: ["m", "n", "x"]
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
// NOTE: Type test disabled - the merged plugin returns Record<never, never> for empty transactions,
|
|
75
|
-
// which is correct at runtime but doesn't satisfy the Equal<keyof T, never> type test.
|
|
76
|
-
// The runtime test below verifies the transactions object is empty.
|
|
77
|
-
// type CheckMergedTransactions = Assert<Equal<keyof MergedSchemaTransactions, never>>;
|
|
78
|
-
// Runtime checks: verify the merged schema contains all properties
|
|
79
|
-
const hasAllComponents = "a" in cSchema.components &&
|
|
80
|
-
"b" in cSchema.components &&
|
|
81
|
-
"x" in cSchema.components &&
|
|
82
|
-
"y" in cSchema.components &&
|
|
83
|
-
"m" in cSchema.components &&
|
|
84
|
-
"n" in cSchema.components;
|
|
85
|
-
const hasAllResources = "c" in cSchema.resources &&
|
|
86
|
-
"z" in cSchema.resources;
|
|
87
|
-
const hasAllArchetypes = "one" in cSchema.archetypes &&
|
|
88
|
-
"two" in cSchema.archetypes &&
|
|
89
|
-
"three" in cSchema.archetypes;
|
|
90
|
-
if (!hasAllComponents) {
|
|
91
|
-
throw new Error("Schema merging failed: missing components");
|
|
92
|
-
}
|
|
93
|
-
if (!hasAllResources) {
|
|
94
|
-
throw new Error("Schema merging failed: missing resources");
|
|
95
|
-
}
|
|
96
|
-
if (!hasAllArchetypes) {
|
|
97
|
-
throw new Error("Schema merging failed: missing archetypes");
|
|
98
|
-
}
|
|
99
|
-
// Test with transactions in dependencies
|
|
100
|
-
const baseSchemaWithTransactions = Database.Plugin.create({
|
|
101
|
-
components: {
|
|
102
|
-
position: { type: "number" },
|
|
103
|
-
health: { type: "number" }
|
|
104
|
-
},
|
|
105
|
-
resources: {
|
|
106
|
-
time: { default: 0 }
|
|
107
|
-
},
|
|
108
|
-
transactions: {
|
|
109
|
-
updateHealth: () => { }
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
const extendedSchemaWithTransactions = Database.Plugin.create(baseSchemaWithTransactions, {
|
|
113
|
-
components: {
|
|
114
|
-
velocity: { type: "number" }
|
|
115
|
-
},
|
|
116
|
-
resources: {
|
|
117
|
-
delta: { default: 0 }
|
|
118
|
-
},
|
|
119
|
-
archetypes: {
|
|
120
|
-
Moving: ["position", "velocity"]
|
|
121
|
-
},
|
|
122
|
-
transactions: {
|
|
123
|
-
move: () => { }
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
// NOTE: Type test disabled - archetype keys inference may be broader than expected after merge.
|
|
127
|
-
// The runtime test below verifies the archetypes object has the correct keys.
|
|
128
|
-
// type CheckExtendedArchetypes = Assert<Equal<keyof ExtendedArchetypes, "Moving">>;
|
|
129
|
-
// Runtime checks for extended schema
|
|
130
|
-
const hasExtendedComponents = "position" in extendedSchemaWithTransactions.components &&
|
|
131
|
-
"health" in extendedSchemaWithTransactions.components &&
|
|
132
|
-
"velocity" in extendedSchemaWithTransactions.components;
|
|
133
|
-
const hasExtendedResources = "time" in extendedSchemaWithTransactions.resources &&
|
|
134
|
-
"delta" in extendedSchemaWithTransactions.resources;
|
|
135
|
-
const hasExtendedTransactions = "updateHealth" in extendedSchemaWithTransactions.transactions &&
|
|
136
|
-
"move" in extendedSchemaWithTransactions.transactions;
|
|
137
|
-
const hasExtendedArchetypes = "Moving" in extendedSchemaWithTransactions.archetypes;
|
|
138
|
-
if (!hasExtendedComponents) {
|
|
139
|
-
throw new Error("Extended schema merging failed: missing components");
|
|
140
|
-
}
|
|
141
|
-
if (!hasExtendedResources) {
|
|
142
|
-
throw new Error("Extended schema merging failed: missing resources");
|
|
143
|
-
}
|
|
144
|
-
if (!hasExtendedTransactions) {
|
|
145
|
-
throw new Error("Extended schema merging failed: missing transactions");
|
|
146
|
-
}
|
|
147
|
-
if (!hasExtendedArchetypes) {
|
|
148
|
-
throw new Error("Extended schema merging failed: missing archetypes");
|
|
149
|
-
}
|
|
150
|
-
//# sourceMappingURL=create-database-schema-test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-database-schema-test.js","sourceRoot":"","sources":["../../../src/ecs/database/create-database-schema-test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;WAoBW;AAIX,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe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,CAAC,oDAAoD,CAAC,CAAC;AAC1E,CAAC;AAED,IAAI,CAAC,oBAAoB,EAAE,CAAC;IACxB,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;AACzE,CAAC;AAED,IAAI,CAAC,uBAAuB,EAAE,CAAC;IAC3B,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;AAC5E,CAAC;AAED,IAAI,CAAC,qBAAqB,EAAE,CAAC;IACzB,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;AAC1E,CAAC"}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import type { Database } from "./database.js";
|
|
2
|
-
import type { ComponentSchemas } from "../component-schemas.js";
|
|
3
|
-
import type { ResourceSchemas } from "../resource-schemas.js";
|
|
4
|
-
import type { ArchetypeComponents } from "../store/archetype-components.js";
|
|
5
|
-
import type { ActionDeclarations, ToActionFunctions } from "../store/action-functions.js";
|
|
6
|
-
import type { FromSchemas } from "../../schema/index.js";
|
|
7
|
-
import type { StringKeyof, IntersectTuple } from "../../types/types.js";
|
|
8
|
-
type SystemFunction = () => void | Promise<void>;
|
|
9
|
-
type RemoveIndexSignature<T> = {
|
|
10
|
-
[K in keyof T as string extends K ? never : number extends K ? never : symbol extends K ? never : K]: T[K];
|
|
11
|
-
};
|
|
12
|
-
export type SystemDeclarations = {
|
|
13
|
-
readonly [K in string]: {
|
|
14
|
-
readonly create: (db: Database<any, any, any, any, any>) => SystemFunction;
|
|
15
|
-
readonly schedule?: {
|
|
16
|
-
readonly before?: readonly string[];
|
|
17
|
-
readonly after?: readonly string[];
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
export type PluginSchema<CS extends ComponentSchemas = {}, RS extends ResourceSchemas = {}, A extends ArchetypeComponents<any> = {}, TD extends ActionDeclarations<any, any, any> = {}, SYS extends SystemDeclarations = {}> = {
|
|
22
|
-
components?: CS;
|
|
23
|
-
resources?: RS;
|
|
24
|
-
archetypes?: A;
|
|
25
|
-
transactions?: TD;
|
|
26
|
-
systems?: SYS;
|
|
27
|
-
};
|
|
28
|
-
type ExtractSystemNames<P> = P extends Database.Plugin<any, any, any, any, infer S> ? S : never;
|
|
29
|
-
type MergeDependencies<D extends readonly Database.Plugin<any, any, any, any, any>[]> = {
|
|
30
|
-
components: {} & IntersectTuple<{
|
|
31
|
-
[K in keyof D]: D[K] extends Database.Plugin<infer C, any, any, any, any> ? (C extends undefined ? {} : C) : never;
|
|
32
|
-
}>;
|
|
33
|
-
resources: {} & IntersectTuple<{
|
|
34
|
-
[K in keyof D]: D[K] extends Database.Plugin<any, infer R, any, any, any> ? (R extends undefined ? {} : R) : never;
|
|
35
|
-
}>;
|
|
36
|
-
archetypes: {} & IntersectTuple<{
|
|
37
|
-
[K in keyof D]: D[K] extends Database.Plugin<any, any, infer A, any, any> ? (A extends undefined ? {} : A) : never;
|
|
38
|
-
}>;
|
|
39
|
-
transactions: {} & IntersectTuple<{
|
|
40
|
-
[K in keyof D]: D[K] extends Database.Plugin<any, any, any, infer TD, any> ? (TD extends undefined ? Record<never, never> : TD) : never;
|
|
41
|
-
}>;
|
|
42
|
-
systemNames: Extract<{
|
|
43
|
-
[K in keyof D]: ExtractSystemNames<D[K]>;
|
|
44
|
-
}[number], string>;
|
|
45
|
-
};
|
|
46
|
-
export declare function createPlugin<const CS extends ComponentSchemas, const RS extends ResourceSchemas, const A extends ArchetypeComponents<any>, const TD extends ActionDeclarations<any, any, any>, const SYS extends {
|
|
47
|
-
readonly [K in string]: {
|
|
48
|
-
readonly create: (db: Database<FromSchemas<RemoveIndexSignature<CS>>, FromSchemas<RemoveIndexSignature<RS>>, A, ToActionFunctions<TD>, string>) => SystemFunction;
|
|
49
|
-
readonly schedule?: {
|
|
50
|
-
readonly before?: readonly string[];
|
|
51
|
-
readonly after?: readonly string[];
|
|
52
|
-
};
|
|
53
|
-
};
|
|
54
|
-
}>(descriptor: {
|
|
55
|
-
components?: CS;
|
|
56
|
-
resources?: RS;
|
|
57
|
-
archetypes?: A;
|
|
58
|
-
transactions?: TD;
|
|
59
|
-
systems?: SYS;
|
|
60
|
-
}): Required<Database.Plugin<CS, RS, A, TD, StringKeyof<SYS>>>;
|
|
61
|
-
export declare function createPlugin<const D extends readonly any[], const CS extends ComponentSchemas, const RS extends ResourceSchemas, const A extends ArchetypeComponents<any>, const TD extends ActionDeclarations<any, any, any>, const SYS extends {
|
|
62
|
-
readonly [K in string]: {
|
|
63
|
-
readonly create: (db: Database<FromSchemas<RemoveIndexSignature<CS & MergeDependencies<D>['components']>>, FromSchemas<RemoveIndexSignature<RS & MergeDependencies<D>['resources']>>, A | MergeDependencies<D>['archetypes'], ToActionFunctions<TD & MergeDependencies<D>['transactions']>, MergeDependencies<D>['systemNames'] | string>) => SystemFunction;
|
|
64
|
-
readonly schedule?: {
|
|
65
|
-
readonly before?: readonly MergeDependencies<D>['systemNames'][];
|
|
66
|
-
readonly after?: readonly MergeDependencies<D>['systemNames'][];
|
|
67
|
-
};
|
|
68
|
-
};
|
|
69
|
-
}>(descriptor: {
|
|
70
|
-
components?: CS;
|
|
71
|
-
resources?: RS;
|
|
72
|
-
archetypes?: A;
|
|
73
|
-
transactions?: TD;
|
|
74
|
-
systems?: SYS;
|
|
75
|
-
}, dependencies: D): Database.Plugin.Intersect<[
|
|
76
|
-
...D,
|
|
77
|
-
Database.Plugin<CS, RS, A, TD, StringKeyof<SYS>>
|
|
78
|
-
]>;
|
|
79
|
-
export {};
|
|
@@ -1,68 +0,0 @@
|
|
|
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
|
-
// Implementation
|
|
23
|
-
export function createPlugin(descriptor, dependencies) {
|
|
24
|
-
// Merge dependencies first
|
|
25
|
-
const mergedDeps = (dependencies ?? []).reduce((acc, curr) => ({
|
|
26
|
-
components: { ...acc.components, ...curr.components },
|
|
27
|
-
resources: { ...acc.resources, ...curr.resources },
|
|
28
|
-
archetypes: { ...acc.archetypes, ...curr.archetypes },
|
|
29
|
-
transactions: { ...acc.transactions, ...curr.transactions },
|
|
30
|
-
systems: { ...acc.systems, ...curr.systems },
|
|
31
|
-
}), {
|
|
32
|
-
components: {},
|
|
33
|
-
resources: {},
|
|
34
|
-
archetypes: {},
|
|
35
|
-
transactions: {},
|
|
36
|
-
systems: {},
|
|
37
|
-
});
|
|
38
|
-
// Merge descriptor on top of dependencies
|
|
39
|
-
const result = {
|
|
40
|
-
components: { ...mergedDeps.components, ...descriptor.components },
|
|
41
|
-
resources: { ...mergedDeps.resources, ...descriptor.resources },
|
|
42
|
-
archetypes: { ...mergedDeps.archetypes, ...descriptor.archetypes },
|
|
43
|
-
transactions: { ...mergedDeps.transactions, ...descriptor.transactions },
|
|
44
|
-
systems: { ...mergedDeps.systems, ...descriptor.systems },
|
|
45
|
-
};
|
|
46
|
-
// Validate system schedule references
|
|
47
|
-
if (result.systems) {
|
|
48
|
-
const systemNames = new Set(Object.keys(result.systems));
|
|
49
|
-
for (const [systemName, systemDef] of Object.entries(result.systems)) {
|
|
50
|
-
const schedule = systemDef?.schedule;
|
|
51
|
-
if (schedule) {
|
|
52
|
-
const validateRefs = (refs, type) => {
|
|
53
|
-
if (refs) {
|
|
54
|
-
for (const ref of refs) {
|
|
55
|
-
if (!systemNames.has(ref)) {
|
|
56
|
-
throw new Error(`System "${systemName}" references non-existent system "${ref}" in schedule.${type}`);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
validateRefs(schedule.before, 'before');
|
|
62
|
-
validateRefs(schedule.after, 'after');
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return result;
|
|
67
|
-
}
|
|
68
|
-
//# sourceMappingURL=create-plugin-v2.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-plugin-v2.js","sourceRoot":"","sources":["../../../src/ecs/database/create-plugin-v2.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;WAoBW;AA+GX,iBAAiB;AACjB,MAAM,UAAU,YAAY,CACxB,UAAe,EACf,YAAkB;IAElB,2BAA2B;IAC3B,MAAM,UAAU,GAAG,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,GAAQ,EAAE,IAAS,EAAE,EAAE,CAAC,CAAC;QACrE,UAAU,EAAE,EAAE,GAAG,GAAG,CAAC,UAAU,EAAE,GAAG,IAAI,CAAC,UAAU,EAAE;QACrD,SAAS,EAAE,EAAE,GAAG,GAAG,CAAC,SAAS,EAAE,GAAG,IAAI,CAAC,SAAS,EAAE;QAClD,UAAU,EAAE,EAA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,GAAG,CAAC,IAA0B,EAAE,IAAwB,EAAE,EAAE;oBAC1E,IAAI,IAAI,EAAE,CAAC;wBACP,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;4BACrB,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;gCACxB,MAAM,IAAI,KAAK,CACX,WAAW,UAAU,qCAAqC,GAAG,iBAAiB,IAAI,EAAE,CACvF,CAAC;4BACN,CAAC;wBACL,CAAC;oBACL,CAAC;gBACL,CAAC,CAAC;gBACF,YAAY,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;gBACxC,YAAY,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;YAC1C,CAAC;QACL,CAAC;IACL,CAAC;IAED,OAAO,MAAa,CAAC;AACzB,CAAC"}
|
|
@@ -1,362 +0,0 @@
|
|
|
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, expect } from "vitest";
|
|
23
|
-
import { createPlugin } from "./create-plugin-v2.js";
|
|
24
|
-
describe("Database.Plugin.create (v2 - descriptor + dependencies)", () => {
|
|
25
|
-
describe("single descriptor (no dependencies)", () => {
|
|
26
|
-
it("should create plugin with components, resources, and archetypes", () => {
|
|
27
|
-
const plugin = createPlugin({
|
|
28
|
-
components: {
|
|
29
|
-
velocity: { type: "number" },
|
|
30
|
-
particle: { type: "boolean" },
|
|
31
|
-
},
|
|
32
|
-
resources: {
|
|
33
|
-
mousePosition: { type: "number", default: 0 },
|
|
34
|
-
fooPosition: { type: "number", default: 0 },
|
|
35
|
-
},
|
|
36
|
-
archetypes: {
|
|
37
|
-
Particle: ["particle"],
|
|
38
|
-
DynamicParticle: ["particle", "velocity"],
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
expect(plugin.components).toBeDefined();
|
|
42
|
-
expect("velocity" in plugin.components).toBe(true);
|
|
43
|
-
expect("particle" in plugin.components).toBe(true);
|
|
44
|
-
expect(plugin.resources).toBeDefined();
|
|
45
|
-
expect("mousePosition" in plugin.resources).toBe(true);
|
|
46
|
-
expect("fooPosition" in plugin.resources).toBe(true);
|
|
47
|
-
expect(plugin.archetypes).toBeDefined();
|
|
48
|
-
expect("Particle" in plugin.archetypes).toBe(true);
|
|
49
|
-
expect("DynamicParticle" in plugin.archetypes).toBe(true);
|
|
50
|
-
});
|
|
51
|
-
it("should infer db type correctly with single descriptor", () => {
|
|
52
|
-
const plugin = createPlugin({
|
|
53
|
-
resources: {
|
|
54
|
-
time: { default: 0 },
|
|
55
|
-
},
|
|
56
|
-
systems: {
|
|
57
|
-
physicsSystem: {
|
|
58
|
-
create: (db) => () => {
|
|
59
|
-
const time = db.resources.time;
|
|
60
|
-
// @ts-expect-error - this should be an error
|
|
61
|
-
const dt = db.resources.deltaTime2;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
expect(plugin).toBeDefined();
|
|
67
|
-
expect(plugin.systems).toBeDefined();
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
describe("with dependencies", () => {
|
|
71
|
-
it("should merge components from dependencies", () => {
|
|
72
|
-
const basePlugin = createPlugin({
|
|
73
|
-
components: {
|
|
74
|
-
position: { type: "number" },
|
|
75
|
-
health: { type: "number" }
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
const extendedPlugin = createPlugin({
|
|
79
|
-
components: {
|
|
80
|
-
velocity: { type: "number" }
|
|
81
|
-
}
|
|
82
|
-
}, [basePlugin]);
|
|
83
|
-
expect("position" in extendedPlugin.components).toBe(true);
|
|
84
|
-
expect("health" in extendedPlugin.components).toBe(true);
|
|
85
|
-
expect("velocity" in extendedPlugin.components).toBe(true);
|
|
86
|
-
});
|
|
87
|
-
it("should merge resources from dependencies", () => {
|
|
88
|
-
const basePlugin = createPlugin({
|
|
89
|
-
resources: {
|
|
90
|
-
time: { default: 0 },
|
|
91
|
-
config: { default: "default" }
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
const extendedPlugin = createPlugin({
|
|
95
|
-
resources: {
|
|
96
|
-
delta: { default: 0 }
|
|
97
|
-
}
|
|
98
|
-
}, [basePlugin]);
|
|
99
|
-
expect("time" in extendedPlugin.resources).toBe(true);
|
|
100
|
-
expect("config" in extendedPlugin.resources).toBe(true);
|
|
101
|
-
expect("delta" in extendedPlugin.resources).toBe(true);
|
|
102
|
-
});
|
|
103
|
-
it("should merge systems from dependencies", () => {
|
|
104
|
-
const basePlugin = createPlugin({
|
|
105
|
-
systems: {
|
|
106
|
-
inputSystem: {
|
|
107
|
-
create: (_db) => () => { }
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
const extendedPlugin = createPlugin({
|
|
112
|
-
systems: {
|
|
113
|
-
renderSystem: {
|
|
114
|
-
create: (_db) => () => { }
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}, [basePlugin]);
|
|
118
|
-
expect("inputSystem" in extendedPlugin.systems).toBe(true);
|
|
119
|
-
expect("renderSystem" in extendedPlugin.systems).toBe(true);
|
|
120
|
-
});
|
|
121
|
-
it("should allow systems to access dependency resources", () => {
|
|
122
|
-
const basePlugin = createPlugin({
|
|
123
|
-
resources: {
|
|
124
|
-
time: { default: 0 }
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
const extendedPlugin = createPlugin({
|
|
128
|
-
systems: {
|
|
129
|
-
mySystem: {
|
|
130
|
-
create: (db) => () => {
|
|
131
|
-
const time = db.resources.time; // Should work!
|
|
132
|
-
expect(typeof time).toBe("number");
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}, [basePlugin]);
|
|
137
|
-
expect(extendedPlugin).toBeDefined();
|
|
138
|
-
});
|
|
139
|
-
it("should allow multiple dependencies", () => {
|
|
140
|
-
const plugin1 = createPlugin({
|
|
141
|
-
components: { a: { type: "number" } }
|
|
142
|
-
});
|
|
143
|
-
const plugin2 = createPlugin({
|
|
144
|
-
components: { b: { type: "string" } }
|
|
145
|
-
});
|
|
146
|
-
const plugin3 = createPlugin({
|
|
147
|
-
components: { c: { type: "boolean" } }
|
|
148
|
-
});
|
|
149
|
-
const merged = createPlugin({
|
|
150
|
-
components: { d: { type: "number" } }
|
|
151
|
-
}, [plugin1, plugin2, plugin3]);
|
|
152
|
-
expect("a" in merged.components).toBe(true);
|
|
153
|
-
expect("b" in merged.components).toBe(true);
|
|
154
|
-
expect("c" in merged.components).toBe(true);
|
|
155
|
-
expect("d" in merged.components).toBe(true);
|
|
156
|
-
});
|
|
157
|
-
});
|
|
158
|
-
describe("schedule validation", () => {
|
|
159
|
-
it("should throw error for non-existent system in schedule.after", () => {
|
|
160
|
-
expect(() => {
|
|
161
|
-
createPlugin({
|
|
162
|
-
systems: {
|
|
163
|
-
system1: {
|
|
164
|
-
create: (_db) => () => { }
|
|
165
|
-
},
|
|
166
|
-
system2: {
|
|
167
|
-
create: (_db) => () => { },
|
|
168
|
-
schedule: {
|
|
169
|
-
after: ["nonExistentSystem"]
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
}).toThrow('System "system2" references non-existent system "nonExistentSystem" in schedule.after');
|
|
175
|
-
});
|
|
176
|
-
it("should throw error for non-existent system in schedule.before", () => {
|
|
177
|
-
expect(() => {
|
|
178
|
-
createPlugin({
|
|
179
|
-
systems: {
|
|
180
|
-
system1: {
|
|
181
|
-
create: (_db) => () => { },
|
|
182
|
-
schedule: {
|
|
183
|
-
before: ["anotherNonExistentSystem"]
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
|
-
}).toThrow('System "system1" references non-existent system "anotherNonExistentSystem" in schedule.before');
|
|
189
|
-
});
|
|
190
|
-
it("should not throw error for valid system references in schedule", () => {
|
|
191
|
-
expect(() => {
|
|
192
|
-
createPlugin({
|
|
193
|
-
systems: {
|
|
194
|
-
system1: {
|
|
195
|
-
create: (_db) => () => { }
|
|
196
|
-
},
|
|
197
|
-
system2: {
|
|
198
|
-
create: (_db) => () => { },
|
|
199
|
-
schedule: {
|
|
200
|
-
after: ["system1"]
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
});
|
|
205
|
-
}).not.toThrow();
|
|
206
|
-
});
|
|
207
|
-
it("should allow referencing dependency systems in schedule", () => {
|
|
208
|
-
const basePlugin = createPlugin({
|
|
209
|
-
systems: {
|
|
210
|
-
inputSystem: {
|
|
211
|
-
create: (_db) => () => { }
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
});
|
|
215
|
-
expect(() => {
|
|
216
|
-
createPlugin({
|
|
217
|
-
systems: {
|
|
218
|
-
renderSystem: {
|
|
219
|
-
create: (_db) => () => { },
|
|
220
|
-
schedule: {
|
|
221
|
-
after: ["inputSystem"] // Reference from dependency!
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
}, [basePlugin]);
|
|
226
|
-
}).not.toThrow();
|
|
227
|
-
});
|
|
228
|
-
it("should validate across multiple dependencies", () => {
|
|
229
|
-
const plugin1 = createPlugin({
|
|
230
|
-
systems: {
|
|
231
|
-
system1: {
|
|
232
|
-
create: (_db) => () => { }
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
});
|
|
236
|
-
const plugin2 = createPlugin({
|
|
237
|
-
systems: {
|
|
238
|
-
system2: {
|
|
239
|
-
create: (_db) => () => { }
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
});
|
|
243
|
-
expect(() => {
|
|
244
|
-
createPlugin({
|
|
245
|
-
systems: {
|
|
246
|
-
system3: {
|
|
247
|
-
create: (_db) => () => { },
|
|
248
|
-
schedule: {
|
|
249
|
-
after: ["system1", "system2"] // Both from dependencies
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
}, [plugin1, plugin2]);
|
|
254
|
-
}).not.toThrow();
|
|
255
|
-
});
|
|
256
|
-
it("should still catch errors when using dependencies", () => {
|
|
257
|
-
const basePlugin = createPlugin({
|
|
258
|
-
systems: {
|
|
259
|
-
realSystem: {
|
|
260
|
-
create: (_db) => () => { }
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
});
|
|
264
|
-
expect(() => {
|
|
265
|
-
createPlugin({
|
|
266
|
-
systems: {
|
|
267
|
-
mySystem: {
|
|
268
|
-
create: (_db) => () => { },
|
|
269
|
-
schedule: {
|
|
270
|
-
// @ts-expect-error - Type error AND runtime error
|
|
271
|
-
after: ["nonExistentSystem"]
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
}, [basePlugin]);
|
|
276
|
-
}).toThrow('System "mySystem" references non-existent system "nonExistentSystem" in schedule.after');
|
|
277
|
-
});
|
|
278
|
-
it("should constrain schedule references to dependency system names", () => {
|
|
279
|
-
const basePlugin = createPlugin({
|
|
280
|
-
systems: {
|
|
281
|
-
inputSystem: {
|
|
282
|
-
create: (_db) => () => { }
|
|
283
|
-
},
|
|
284
|
-
physicsSystem: {
|
|
285
|
-
create: (_db) => () => { }
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
});
|
|
289
|
-
// ✅ VALID: referencing actual systems from dependencies (no 'as const' needed!)
|
|
290
|
-
const validPlugin = createPlugin({
|
|
291
|
-
systems: {
|
|
292
|
-
renderSystem: {
|
|
293
|
-
create: (_db) => () => { },
|
|
294
|
-
schedule: {
|
|
295
|
-
// TypeScript autocompletes: "inputSystem" | "physicsSystem"
|
|
296
|
-
after: ["inputSystem", "physicsSystem"]
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
}, [basePlugin]);
|
|
301
|
-
expect(validPlugin).toBeDefined();
|
|
302
|
-
expect(validPlugin.systems).toHaveProperty("renderSystem");
|
|
303
|
-
// ❌ INVALID: This should have BOTH compile-time AND runtime errors
|
|
304
|
-
expect(() => {
|
|
305
|
-
createPlugin({
|
|
306
|
-
systems: {
|
|
307
|
-
renderSystem: {
|
|
308
|
-
create: (_db) => () => { },
|
|
309
|
-
schedule: {
|
|
310
|
-
// @ts-expect-error - "badSystemName" doesn't exist in dependencies (no 'as const' needed!)
|
|
311
|
-
after: ["badSystemName"]
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
}, [basePlugin]);
|
|
316
|
-
}).toThrow('System "renderSystem" references non-existent system "badSystemName" in schedule.after');
|
|
317
|
-
});
|
|
318
|
-
});
|
|
319
|
-
describe("type inference edge cases", () => {
|
|
320
|
-
it("should block arbitrary property access on resources", () => {
|
|
321
|
-
const plugin = createPlugin({
|
|
322
|
-
resources: {
|
|
323
|
-
time: { default: 0 }
|
|
324
|
-
},
|
|
325
|
-
systems: {
|
|
326
|
-
testSystem: {
|
|
327
|
-
create: (db) => () => {
|
|
328
|
-
const time = db.resources.time; // OK
|
|
329
|
-
// @ts-expect-error - should error
|
|
330
|
-
const invalid = db.resources.nonExistent;
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
});
|
|
335
|
-
expect(plugin).toBeDefined();
|
|
336
|
-
});
|
|
337
|
-
it("should block arbitrary property access with dependencies", () => {
|
|
338
|
-
const basePlugin = createPlugin({
|
|
339
|
-
resources: {
|
|
340
|
-
time: { default: 0 }
|
|
341
|
-
}
|
|
342
|
-
});
|
|
343
|
-
const extendedPlugin = createPlugin({
|
|
344
|
-
resources: {
|
|
345
|
-
delta: { default: 0 }
|
|
346
|
-
},
|
|
347
|
-
systems: {
|
|
348
|
-
testSystem: {
|
|
349
|
-
create: (db) => () => {
|
|
350
|
-
const time = db.resources.time; // OK - from dependency
|
|
351
|
-
const delta = db.resources.delta; // OK - from descriptor
|
|
352
|
-
// @ts-expect-error - should error
|
|
353
|
-
const invalid = db.resources.nonExistent;
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
}, [basePlugin]);
|
|
358
|
-
expect(extendedPlugin).toBeDefined();
|
|
359
|
-
});
|
|
360
|
-
});
|
|
361
|
-
});
|
|
362
|
-
//# sourceMappingURL=create-plugin-v2.test.js.map
|