@flighthq/effects-wgpu 0.3.1-next.625.675880d → 0.3.1-next.704.69286f6
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wgpuRenderEffectRegistry.d.ts","sourceRoot":"","sources":["../src/wgpuRenderEffectRegistry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wgpuRenderEffectRegistry.d.ts","sourceRoot":"","sources":["../src/wgpuRenderEffectRegistry.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAWxF,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,GAAG,sBAAsB,GAAG,IAAI,CAG7G;AAMD,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAIvF;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,sBAAsB,GAAG,IAAI,CAGnH"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { withRegistryTableEntry } from '@flighthq/registry/contract';
|
|
1
2
|
import { getWgpuRenderStateRuntime } from '@flighthq/render-wgpu/contract';
|
|
3
|
+
import { RegistryEntryState } from '@flighthq/types/contract';
|
|
2
4
|
// Per-state registry mapping an effect `kind` string to its Wgpu runner — the material-renderer
|
|
3
5
|
// pattern one tier up. Registration is opt-in (import a runner only to register it) and dispatch is a
|
|
4
6
|
// Map lookup, so there is no monolithic switch and unused effect recipes tree-shake away. Register an
|
|
@@ -7,17 +9,18 @@ import { getWgpuRenderStateRuntime } from '@flighthq/render-wgpu/contract';
|
|
|
7
9
|
// A built-in registerWgpu<Kind>Effect wrapper is pure ergonomics: it calls this function with the
|
|
8
10
|
// literal kind and public default runner, and installs no padding, shader-source, or backdrop companions.
|
|
9
11
|
export function getWgpuRenderEffectRunner(state, kind) {
|
|
10
|
-
|
|
12
|
+
const entry = getWgpuRenderStateRuntime(state).registries.renderEffects.entries.get(kind);
|
|
13
|
+
return entry?.state === RegistryEntryState.Bound ? entry.value : null;
|
|
11
14
|
}
|
|
12
15
|
// Returns true if a runner is registered for the given kind in this state. Symmetric with
|
|
13
16
|
// hasGlRenderEffectRunner. Use to validate an effect chain before dispatching — the pipeline
|
|
14
17
|
// silently skips unregistered kinds; check up front to apply your own policy (warn, filter)
|
|
15
18
|
// rather than relying on silent no-ops.
|
|
16
19
|
export function hasWgpuRenderEffectRunner(state, kind) {
|
|
17
|
-
return getWgpuRenderStateRuntime(state).
|
|
20
|
+
return (getWgpuRenderStateRuntime(state).registries.renderEffects.entries.get(kind)?.state === RegistryEntryState.Bound);
|
|
18
21
|
}
|
|
19
22
|
export function registerWgpuRenderEffect(state, kind, runner) {
|
|
20
23
|
const runtime = getWgpuRenderStateRuntime(state);
|
|
21
|
-
|
|
24
|
+
runtime.registries.renderEffects = withRegistryTableEntry(runtime.registries.renderEffects, kind, runner);
|
|
22
25
|
}
|
|
23
26
|
//# sourceMappingURL=wgpuRenderEffectRegistry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wgpuRenderEffectRegistry.js","sourceRoot":"","sources":["../src/wgpuRenderEffectRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"wgpuRenderEffectRegistry.js","sourceRoot":"","sources":["../src/wgpuRenderEffectRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAE3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE9D,gGAAgG;AAChG,sGAAsG;AACtG,sGAAsG;AACtG,8FAA8F;AAC9F,yGAAyG;AACzG,kGAAkG;AAClG,0GAA0G;AAE1G,MAAM,UAAU,yBAAyB,CAAC,KAAsB,EAAE,IAAY;IAC5E,MAAM,KAAK,GAAG,yBAAyB,CAAC,KAAK,CAAC,CAAC,UAAU,CAAC,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC1F,OAAO,KAAK,EAAE,KAAK,KAAK,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AACxE,CAAC;AAED,0FAA0F;AAC1F,6FAA6F;AAC7F,4FAA4F;AAC5F,wCAAwC;AACxC,MAAM,UAAU,yBAAyB,CAAC,KAAsB,EAAE,IAAY;IAC5E,OAAO,CACL,yBAAyB,CAAC,KAAK,CAAC,CAAC,UAAU,CAAC,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,KAAK,KAAK,kBAAkB,CAAC,KAAK,CAChH,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,KAAsB,EAAE,IAAY,EAAE,MAA8B;IAC3G,MAAM,OAAO,GAAG,yBAAyB,CAAC,KAAK,CAAC,CAAC;IACjD,OAAO,CAAC,UAAU,CAAC,aAAa,GAAG,sBAAsB,CAAC,OAAO,CAAC,UAAU,CAAC,aAAa,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AAC5G,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flighthq/effects-wgpu",
|
|
3
|
-
"version": "0.3.1-next.
|
|
3
|
+
"version": "0.3.1-next.704.69286f6",
|
|
4
4
|
"author": "Joshua Granick and other contributors",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -38,11 +38,12 @@
|
|
|
38
38
|
"clean:dist": "tsx ../../scripts/clean-package-dist.ts"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@flighthq/adjustments": "0.3.1-next.
|
|
42
|
-
"@flighthq/effects": "0.3.1-next.
|
|
43
|
-
"@flighthq/geometry": "0.3.1-next.
|
|
44
|
-
"@flighthq/render-wgpu": "0.3.1-next.
|
|
45
|
-
"@flighthq/
|
|
41
|
+
"@flighthq/adjustments": "0.3.1-next.704.69286f6",
|
|
42
|
+
"@flighthq/effects": "0.3.1-next.704.69286f6",
|
|
43
|
+
"@flighthq/geometry": "0.3.1-next.704.69286f6",
|
|
44
|
+
"@flighthq/render-wgpu": "0.3.1-next.704.69286f6",
|
|
45
|
+
"@flighthq/registry": "0.3.1-next.704.69286f6",
|
|
46
|
+
"@flighthq/types": "0.3.1-next.704.69286f6"
|
|
46
47
|
},
|
|
47
48
|
"peerDependencies": {
|
|
48
49
|
"@webgpu/types": "^0.1.70"
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
createWgpuRenderStateForTest,
|
|
3
|
+
getWgpuRenderStateRuntime,
|
|
4
|
+
installWgpuMock,
|
|
5
|
+
} from '@flighthq/render-wgpu/contract';
|
|
2
6
|
|
|
3
7
|
import {
|
|
4
8
|
getWgpuRenderEffectRunner,
|
|
@@ -34,7 +38,23 @@ describe('registerWgpuRenderEffect', () => {
|
|
|
34
38
|
it('registers a runner retrievable by its kind', async () => {
|
|
35
39
|
const state = await createWgpuRenderStateForTest();
|
|
36
40
|
const runner = vi.fn();
|
|
41
|
+
const before = getWgpuRenderStateRuntime(state).registries.renderEffects;
|
|
37
42
|
registerWgpuRenderEffect(state, 'VignetteEffect', runner);
|
|
38
43
|
expect(getWgpuRenderEffectRunner(state, 'VignetteEffect')).toBe(runner);
|
|
44
|
+
expect(getWgpuRenderStateRuntime(state).registries.renderEffects).not.toBe(before);
|
|
45
|
+
expect(before.entries.size).toBe(0);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('is last-write-wins without mutating the earlier snapshot', async () => {
|
|
49
|
+
const state = await createWgpuRenderStateForTest();
|
|
50
|
+
const runnerA = vi.fn();
|
|
51
|
+
const runnerB = vi.fn();
|
|
52
|
+
registerWgpuRenderEffect(state, 'TestEffect', runnerA);
|
|
53
|
+
const before = getWgpuRenderStateRuntime(state).registries.renderEffects;
|
|
54
|
+
|
|
55
|
+
registerWgpuRenderEffect(state, 'TestEffect', runnerB);
|
|
56
|
+
|
|
57
|
+
expect(getWgpuRenderEffectRunner(state, 'TestEffect')).toBe(runnerB);
|
|
58
|
+
expect(before.entries.get('TestEffect')).toEqual({ state: 'bound', value: runnerA });
|
|
39
59
|
});
|
|
40
60
|
});
|