@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,3 @@
|
|
|
1
|
+
import { Database } from "../index.js";
|
|
2
|
+
export declare function createHelloModelService(): Database<import("../index.js").FromSchemas<never>, import("../index.js").FromSchemas<never>, never, never, "myrender">;
|
|
3
|
+
export type HelloModelService = ReturnType<typeof createHelloModelService>;
|
|
@@ -0,0 +1,83 @@
|
|
|
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 "../index.js";
|
|
23
|
+
import { describe, it, expect } from "vitest";
|
|
24
|
+
// Replicate the graphicsPlugin pattern from cryos (simplified without GPU types)
|
|
25
|
+
const graphicsPlugin = Database.Plugin.create({
|
|
26
|
+
resources: {
|
|
27
|
+
canvas: { default: null, transient: true },
|
|
28
|
+
time: { default: 0, transient: true },
|
|
29
|
+
},
|
|
30
|
+
systems: {
|
|
31
|
+
input: {
|
|
32
|
+
create: () => () => { }
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
// Replicate the helloModelService pattern from cryos
|
|
37
|
+
export function createHelloModelService() {
|
|
38
|
+
return Database.create(Database.Plugin.create({
|
|
39
|
+
systems: {
|
|
40
|
+
myrender: {
|
|
41
|
+
create: db => () => {
|
|
42
|
+
console.log("myrender " + db.resources.time);
|
|
43
|
+
},
|
|
44
|
+
schedule: {
|
|
45
|
+
after: []
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
}
|
|
49
|
+
}, [graphicsPlugin]));
|
|
50
|
+
}
|
|
51
|
+
describe("cryos pattern replication", () => {
|
|
52
|
+
it("should allow access to canvas resource from dependency plugin", () => {
|
|
53
|
+
const service = createHelloModelService();
|
|
54
|
+
// This is the line that fails in cryos: service.store.resources.canvas = ...
|
|
55
|
+
const canvasElement = document.createElement("canvas");
|
|
56
|
+
// Test: Should be able to assign HTMLCanvasElement | null to canvas
|
|
57
|
+
// If this compiles without error, the fix works
|
|
58
|
+
// TypeScript should NOT error here - this is the exact pattern from cryos
|
|
59
|
+
service.store.resources.canvas = canvasElement;
|
|
60
|
+
service.store.resources.canvas = null;
|
|
61
|
+
service.store.resources.canvas = canvasElement ?? null;
|
|
62
|
+
// Type check: This should compile without error
|
|
63
|
+
const testAssignment = (canvas) => {
|
|
64
|
+
service.store.resources.canvas = canvas;
|
|
65
|
+
};
|
|
66
|
+
testAssignment(canvasElement);
|
|
67
|
+
testAssignment(null);
|
|
68
|
+
// Verify runtime behavior (resources start as null from default)
|
|
69
|
+
expect(service.store.resources.canvas).toBe(canvasElement);
|
|
70
|
+
service.store.resources.canvas = null;
|
|
71
|
+
expect(service.store.resources.canvas).toBe(null);
|
|
72
|
+
});
|
|
73
|
+
it("should have correct types for all graphics resources", () => {
|
|
74
|
+
const service = createHelloModelService();
|
|
75
|
+
// Type check: canvas should be HTMLCanvasElement | null
|
|
76
|
+
const canvas = service.store.resources.canvas;
|
|
77
|
+
expect(canvas).toBe(null);
|
|
78
|
+
// Type check: time should be number
|
|
79
|
+
const time = service.store.resources.time;
|
|
80
|
+
expect(time).toBe(0);
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
//# sourceMappingURL=create-plugin-cryos-pattern.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-plugin-cryos-pattern.test.js","sourceRoot":"","sources":["../../../src/ecs/database/create-plugin-cryos-pattern.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;WAoBW;AAEX,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE9C,iFAAiF;AACjF,MAAM,cAAc,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;IAC1C,SAAS,EAAE;QACP,MAAM,EAAE,EAAE,OAAO,EAAE,IAAgC,EAAE,SAAS,EAAE,IAAI,EAAE;QACtE,IAAI,EAAE,EAAE,OAAO,EAAE,CAAW,EAAE,SAAS,EAAE,IAAI,EAAE;KAClD;IACD,OAAO,EAAE;QACL,KAAK,EAAE;YACH,MAAM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AC,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAE3D,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC;QACtC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,sDAAsD,EAAE,GAAG,EAAE;QAC5D,MAAM,OAAO,GAAG,uBAAuB,EAAE,CAAC;QAE1C,wDAAwD;QACxD,MAAM,MAAM,GAA6B,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC;QACxE,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE1B,oCAAoC;QACpC,MAAM,IAAI,GAAW,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC;QAClD,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACzB,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { Vec4 } from "../../math/index.js";
|
|
2
|
+
import { Database } from "./database.js";
|
|
3
|
+
export declare const graphicsPlugin: import("./combine-plugins.js").CombinePlugins<[import("./combine-plugins.js").CombinePlugins<[Database.Plugin<{}, {}, {}, {}, never, {}>, Database.Plugin<{}, {
|
|
4
|
+
readonly schedulerState: {
|
|
5
|
+
readonly default: "running" | "paused" | "disposed";
|
|
6
|
+
};
|
|
7
|
+
}, {}, {}, "schedulerSystem", import("../store/action-functions.js").ActionDeclarations<import("../../schema/from-schemas.js").FromSchemas<{}>, import("../../schema/from-schemas.js").FromSchemas<{
|
|
8
|
+
readonly schedulerState: {
|
|
9
|
+
readonly default: "running" | "paused" | "disposed";
|
|
10
|
+
};
|
|
11
|
+
}>, {}, import("../index.js").ToTransactionFunctions<{}>, "schedulerSystem">>]>, Database.Plugin<{
|
|
12
|
+
readonly foo: {
|
|
13
|
+
readonly type: "array";
|
|
14
|
+
readonly items: {
|
|
15
|
+
readonly type: "number";
|
|
16
|
+
readonly precision: 1;
|
|
17
|
+
readonly default: number;
|
|
18
|
+
};
|
|
19
|
+
readonly minItems: 4;
|
|
20
|
+
readonly maxItems: 4;
|
|
21
|
+
readonly default: readonly [0, 0, 0, 0];
|
|
22
|
+
};
|
|
23
|
+
}, {
|
|
24
|
+
readonly device: {
|
|
25
|
+
readonly default: GPUDevice | null;
|
|
26
|
+
readonly transient: true;
|
|
27
|
+
};
|
|
28
|
+
readonly commandEncoder: {
|
|
29
|
+
readonly default: GPUCommandEncoder | null;
|
|
30
|
+
readonly transient: true;
|
|
31
|
+
};
|
|
32
|
+
readonly renderPassEncoder: {
|
|
33
|
+
readonly default: GPURenderPassEncoder | null;
|
|
34
|
+
readonly transient: true;
|
|
35
|
+
};
|
|
36
|
+
readonly depthTexture: {
|
|
37
|
+
readonly default: GPUTexture | null;
|
|
38
|
+
readonly transient: true;
|
|
39
|
+
};
|
|
40
|
+
readonly clearColor: {
|
|
41
|
+
readonly default: Vec4;
|
|
42
|
+
readonly transient: true;
|
|
43
|
+
};
|
|
44
|
+
readonly canvas: {
|
|
45
|
+
readonly default: HTMLCanvasElement | null;
|
|
46
|
+
readonly transient: true;
|
|
47
|
+
};
|
|
48
|
+
readonly canvasContext: {
|
|
49
|
+
readonly default: GPUCanvasContext | null;
|
|
50
|
+
readonly transient: true;
|
|
51
|
+
};
|
|
52
|
+
}, {}, {}, "update" | "render" | "input" | "preUpdate" | "postUpdate" | "physics" | "preRender" | "postRender", import("../store/action-functions.js").ActionDeclarations<import("../../schema/from-schemas.js").FromSchemas<{
|
|
53
|
+
readonly foo: {
|
|
54
|
+
readonly type: "array";
|
|
55
|
+
readonly items: {
|
|
56
|
+
readonly type: "number";
|
|
57
|
+
readonly precision: 1;
|
|
58
|
+
readonly default: number;
|
|
59
|
+
};
|
|
60
|
+
readonly minItems: 4;
|
|
61
|
+
readonly maxItems: 4;
|
|
62
|
+
readonly default: readonly [0, 0, 0, 0];
|
|
63
|
+
};
|
|
64
|
+
}>, import("../../schema/from-schemas.js").FromSchemas<{
|
|
65
|
+
readonly device: {
|
|
66
|
+
readonly default: GPUDevice | null;
|
|
67
|
+
readonly transient: true;
|
|
68
|
+
};
|
|
69
|
+
readonly commandEncoder: {
|
|
70
|
+
readonly default: GPUCommandEncoder | null;
|
|
71
|
+
readonly transient: true;
|
|
72
|
+
};
|
|
73
|
+
readonly renderPassEncoder: {
|
|
74
|
+
readonly default: GPURenderPassEncoder | null;
|
|
75
|
+
readonly transient: true;
|
|
76
|
+
};
|
|
77
|
+
readonly depthTexture: {
|
|
78
|
+
readonly default: GPUTexture | null;
|
|
79
|
+
readonly transient: true;
|
|
80
|
+
};
|
|
81
|
+
readonly clearColor: {
|
|
82
|
+
readonly default: Vec4;
|
|
83
|
+
readonly transient: true;
|
|
84
|
+
};
|
|
85
|
+
readonly canvas: {
|
|
86
|
+
readonly default: HTMLCanvasElement | null;
|
|
87
|
+
readonly transient: true;
|
|
88
|
+
};
|
|
89
|
+
readonly canvasContext: {
|
|
90
|
+
readonly default: GPUCanvasContext | null;
|
|
91
|
+
readonly transient: true;
|
|
92
|
+
};
|
|
93
|
+
}>, {}, import("../index.js").ToTransactionFunctions<{}>, "update" | "render" | "input" | "preUpdate" | "postUpdate" | "physics" | "preRender" | "postRender">>]>;
|
|
@@ -0,0 +1,135 @@
|
|
|
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 { scheduler } from "../plugins/scheduler/scheduler.js";
|
|
25
|
+
import { Vec4 } from "../../math/index.js";
|
|
26
|
+
import { Database } from "./database.js";
|
|
27
|
+
export const graphicsPlugin = createPlugin({
|
|
28
|
+
components: {
|
|
29
|
+
foo: Vec4.schema,
|
|
30
|
+
},
|
|
31
|
+
resources: {
|
|
32
|
+
device: { default: null, transient: true },
|
|
33
|
+
commandEncoder: { default: null, transient: true },
|
|
34
|
+
renderPassEncoder: { default: null, transient: true },
|
|
35
|
+
depthTexture: { default: null, transient: true },
|
|
36
|
+
clearColor: { default: [0, 0, 0, 1], transient: true },
|
|
37
|
+
canvas: { default: null, transient: true },
|
|
38
|
+
canvasContext: { default: null, transient: true },
|
|
39
|
+
},
|
|
40
|
+
systems: {
|
|
41
|
+
input: {
|
|
42
|
+
create: db => () => { }
|
|
43
|
+
},
|
|
44
|
+
preUpdate: {
|
|
45
|
+
create: db => () => {
|
|
46
|
+
const { device } = db.store.resources;
|
|
47
|
+
if (device) {
|
|
48
|
+
db.store.resources.commandEncoder = device.createCommandEncoder();
|
|
49
|
+
let { canvas, canvasContext } = db.store.resources;
|
|
50
|
+
if (canvas && !canvasContext) {
|
|
51
|
+
canvasContext = db.store.resources.canvasContext = canvas.getContext('webgpu');
|
|
52
|
+
if (!canvasContext) {
|
|
53
|
+
throw new Error('No WebGPU context');
|
|
54
|
+
}
|
|
55
|
+
canvasContext.configure({
|
|
56
|
+
device,
|
|
57
|
+
format: navigator.gpu.getPreferredCanvasFormat(),
|
|
58
|
+
alphaMode: 'premultiplied',
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
update: {
|
|
65
|
+
create: db => () => {
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
postUpdate: {
|
|
69
|
+
create: db => () => {
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
physics: {
|
|
73
|
+
create: db => () => { }
|
|
74
|
+
},
|
|
75
|
+
preRender: {
|
|
76
|
+
create: db => () => {
|
|
77
|
+
let { canvas, commandEncoder, clearColor, canvasContext, device, depthTexture } = db.store.resources;
|
|
78
|
+
if (!commandEncoder || !canvasContext || !device || !canvas)
|
|
79
|
+
return;
|
|
80
|
+
if (!depthTexture) {
|
|
81
|
+
depthTexture = db.store.resources.depthTexture = device.createTexture({
|
|
82
|
+
size: [canvas.width, canvas.height],
|
|
83
|
+
format: 'depth24plus',
|
|
84
|
+
usage: GPUTextureUsage.RENDER_ATTACHMENT
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
db.store.resources.renderPassEncoder = commandEncoder.beginRenderPass({
|
|
88
|
+
colorAttachments: [{
|
|
89
|
+
clearValue: clearColor,
|
|
90
|
+
loadOp: 'clear',
|
|
91
|
+
storeOp: 'store',
|
|
92
|
+
view: canvasContext.getCurrentTexture().createView(),
|
|
93
|
+
}],
|
|
94
|
+
depthStencilAttachment: {
|
|
95
|
+
view: depthTexture.createView(),
|
|
96
|
+
depthClearValue: 1.0,
|
|
97
|
+
depthLoadOp: 'clear',
|
|
98
|
+
depthStoreOp: 'store',
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
render: {
|
|
104
|
+
create: db => { return () => { }; }
|
|
105
|
+
},
|
|
106
|
+
postRender: {
|
|
107
|
+
create: db => () => {
|
|
108
|
+
const { commandEncoder, renderPassEncoder } = db.store.resources;
|
|
109
|
+
if (renderPassEncoder) {
|
|
110
|
+
renderPassEncoder.end();
|
|
111
|
+
db.store.resources.renderPassEncoder = null;
|
|
112
|
+
}
|
|
113
|
+
if (commandEncoder) {
|
|
114
|
+
commandEncoder.finish();
|
|
115
|
+
db.store.resources.commandEncoder = null;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
extends: scheduler
|
|
121
|
+
});
|
|
122
|
+
// type checks
|
|
123
|
+
function typeCheck() {
|
|
124
|
+
const database = Database.create(graphicsPlugin);
|
|
125
|
+
// @ts-expect-error - bar does not exist, should error
|
|
126
|
+
database.componentSchemas.bar;
|
|
127
|
+
// this should be fine.
|
|
128
|
+
database.componentSchemas.foo;
|
|
129
|
+
}
|
|
130
|
+
describe("Database.Plugin.create", () => {
|
|
131
|
+
it("should create a property typed graphics plugin", () => {
|
|
132
|
+
// only compile time checks.
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
//# sourceMappingURL=create-plugin-graphics.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-plugin-graphics.test.js","sourceRoot":"","sources":["../../../src/ecs/database/create-plugin-graphics.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;WAoBW;AAEX,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACtC,OA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