@flighthq/effects-wgpu 0.3.0-next.1220.6982c21 → 0.3.0-next.1248.f867198
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/package.json +6 -6
- package/src/wgpuDropShadowEffect.test.ts +40 -35
- package/src/wgpuEffectBoxBlur.test.ts +23 -16
- package/src/wgpuEffectTintShader.test.ts +22 -15
- package/src/wgpuInnerGlowEffect.test.ts +44 -36
- package/src/wgpuInnerShadowEffect.test.ts +45 -37
- package/src/wgpuOuterGlowEffect.test.ts +39 -34
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flighthq/effects-wgpu",
|
|
3
|
-
"version": "0.3.0-next.
|
|
3
|
+
"version": "0.3.0-next.1248.f867198",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/flighthq/flight.git",
|
|
@@ -36,11 +36,11 @@
|
|
|
36
36
|
"clean:dist": "tsx ../../scripts/clean-package-dist.ts"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@flighthq/adjustments": "0.3.0-next.
|
|
40
|
-
"@flighthq/effects": "0.3.0-next.
|
|
41
|
-
"@flighthq/geometry": "0.3.0-next.
|
|
42
|
-
"@flighthq/render-wgpu": "0.3.0-next.
|
|
43
|
-
"@flighthq/types": "0.3.0-next.
|
|
39
|
+
"@flighthq/adjustments": "0.3.0-next.1248.f867198",
|
|
40
|
+
"@flighthq/effects": "0.3.0-next.1248.f867198",
|
|
41
|
+
"@flighthq/geometry": "0.3.0-next.1248.f867198",
|
|
42
|
+
"@flighthq/render-wgpu": "0.3.0-next.1248.f867198",
|
|
43
|
+
"@flighthq/types": "0.3.0-next.1248.f867198"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"typescript": "^5.3.0"
|
|
@@ -1,40 +1,45 @@
|
|
|
1
|
-
|
|
1
|
+
import type * as WgpudropshadoweffectModule from './wgpuDropShadowEffect';
|
|
2
|
+
import type * as WgpueffectblitshaderModule from './wgpuEffectBlitShader';
|
|
3
|
+
|
|
4
|
+
// Mocked per file with doMock plus dynamic imports of the subject, not top-level hoisted vi.mock.
|
|
5
|
+
// The suite runs isolate:false over a shared module registry, so a hoisted mock is registered for
|
|
6
|
+
// every file in the worker rather than this one -- see the rule in the root vitest config.
|
|
7
|
+
let applyDropShadowEffectToWgpu: typeof WgpudropshadoweffectModule.applyDropShadowEffectToWgpu;
|
|
8
|
+
let defaultWgpuDropShadowEffectRunner: typeof WgpudropshadoweffectModule.defaultWgpuDropShadowEffectRunner;
|
|
9
|
+
let applyWgpuEffectBlitPass: typeof WgpueffectblitshaderModule.applyWgpuEffectBlitPass;
|
|
10
|
+
let applyWgpuEffectErasePass: typeof WgpueffectblitshaderModule.applyWgpuEffectErasePass;
|
|
11
|
+
|
|
12
|
+
beforeAll(async () => {
|
|
2
13
|
vi.resetModules();
|
|
14
|
+
vi.doMock('@flighthq/render-wgpu/contract', () => {
|
|
15
|
+
let nextTargetId = 0;
|
|
16
|
+
return {
|
|
17
|
+
acquireWgpuRenderTarget: vi.fn((_state, _pool, descriptor) => ({
|
|
18
|
+
...descriptor,
|
|
19
|
+
id: `scratch-${nextTargetId++}`,
|
|
20
|
+
texture: {},
|
|
21
|
+
})),
|
|
22
|
+
releaseWgpuRenderTarget: vi.fn(),
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
vi.doMock('./wgpuEffectBlitShader', () => ({
|
|
26
|
+
applyWgpuEffectBlitOffsetPass: vi.fn(),
|
|
27
|
+
applyWgpuEffectBlitPass: vi.fn(),
|
|
28
|
+
applyWgpuEffectErasePass: vi.fn(),
|
|
29
|
+
}));
|
|
30
|
+
vi.doMock('./wgpuEffectBoxBlur', () => ({
|
|
31
|
+
applyWgpuEffectBoxBlur: vi.fn(),
|
|
32
|
+
}));
|
|
33
|
+
vi.doMock('./wgpuEffectPass', () => ({
|
|
34
|
+
clearWgpuEffectTarget: vi.fn(),
|
|
35
|
+
}));
|
|
36
|
+
vi.doMock('./wgpuEffectTintShader', () => ({
|
|
37
|
+
applyWgpuEffectTintPass: vi.fn(),
|
|
38
|
+
}));
|
|
39
|
+
({ applyDropShadowEffectToWgpu, defaultWgpuDropShadowEffectRunner } = await import('./wgpuDropShadowEffect'));
|
|
40
|
+
({ applyWgpuEffectBlitPass, applyWgpuEffectErasePass } = await import('./wgpuEffectBlitShader'));
|
|
3
41
|
});
|
|
4
42
|
|
|
5
|
-
vi.mock('@flighthq/render-wgpu/contract', () => {
|
|
6
|
-
let nextTargetId = 0;
|
|
7
|
-
return {
|
|
8
|
-
acquireWgpuRenderTarget: vi.fn((_state, _pool, descriptor) => ({
|
|
9
|
-
...descriptor,
|
|
10
|
-
id: `scratch-${nextTargetId++}`,
|
|
11
|
-
texture: {},
|
|
12
|
-
})),
|
|
13
|
-
releaseWgpuRenderTarget: vi.fn(),
|
|
14
|
-
};
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
vi.mock('./wgpuEffectBlitShader', () => ({
|
|
18
|
-
applyWgpuEffectBlitOffsetPass: vi.fn(),
|
|
19
|
-
applyWgpuEffectBlitPass: vi.fn(),
|
|
20
|
-
applyWgpuEffectErasePass: vi.fn(),
|
|
21
|
-
}));
|
|
22
|
-
|
|
23
|
-
vi.mock('./wgpuEffectBoxBlur', () => ({
|
|
24
|
-
applyWgpuEffectBoxBlur: vi.fn(),
|
|
25
|
-
}));
|
|
26
|
-
|
|
27
|
-
vi.mock('./wgpuEffectPass', () => ({
|
|
28
|
-
clearWgpuEffectTarget: vi.fn(),
|
|
29
|
-
}));
|
|
30
|
-
|
|
31
|
-
vi.mock('./wgpuEffectTintShader', () => ({
|
|
32
|
-
applyWgpuEffectTintPass: vi.fn(),
|
|
33
|
-
}));
|
|
34
|
-
|
|
35
|
-
import { applyDropShadowEffectToWgpu, defaultWgpuDropShadowEffectRunner } from './wgpuDropShadowEffect';
|
|
36
|
-
import { applyWgpuEffectBlitPass, applyWgpuEffectErasePass } from './wgpuEffectBlitShader';
|
|
37
|
-
|
|
38
43
|
describe('applyDropShadowEffectToWgpu', () => {
|
|
39
44
|
it('is a function', () => {
|
|
40
45
|
expect(typeof applyDropShadowEffectToWgpu).toBe('function');
|
|
@@ -88,7 +93,7 @@ beforeEach(() => {
|
|
|
88
93
|
});
|
|
89
94
|
|
|
90
95
|
afterAll(() => {
|
|
91
|
-
vi.doUnmock('@flighthq/render-wgpu');
|
|
96
|
+
vi.doUnmock('@flighthq/render-wgpu/contract');
|
|
92
97
|
vi.doUnmock('./wgpuEffectBlitShader');
|
|
93
98
|
vi.doUnmock('./wgpuEffectBoxBlur');
|
|
94
99
|
vi.doUnmock('./wgpuEffectPass');
|
|
@@ -1,24 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import type * as WgpueffectboxblurModule from './wgpuEffectBoxBlur';
|
|
2
|
+
import type * as WgpueffectpassModule from './wgpuEffectPass';
|
|
3
|
+
|
|
4
|
+
// Mocked per file with doMock plus dynamic imports of the subject, not top-level hoisted vi.mock.
|
|
5
|
+
// The suite runs isolate:false over a shared module registry, so a hoisted mock is registered for
|
|
6
|
+
// every file in the worker rather than this one -- see the rule in the root vitest config.
|
|
7
|
+
let applyWgpuEffectBoxBlur: typeof WgpueffectboxblurModule.applyWgpuEffectBoxBlur;
|
|
8
|
+
let createWgpuEffectPipeline: typeof WgpueffectpassModule.createWgpuEffectPipeline;
|
|
9
|
+
let drawWgpuEffectPass: typeof WgpueffectpassModule.drawWgpuEffectPass;
|
|
4
10
|
|
|
5
|
-
|
|
11
|
+
beforeAll(async () => {
|
|
6
12
|
vi.resetModules();
|
|
13
|
+
vi.doMock('./wgpuEffectPass', () => ({
|
|
14
|
+
createWgpuEffectPipeline: vi.fn(() => ({ blendMode: 'replace', pipeline: {} })),
|
|
15
|
+
drawWgpuEffectPass: vi.fn((_state, _source, _dest, _pipeline, setUniforms) => {
|
|
16
|
+
const f32 = new Float32Array(16);
|
|
17
|
+
const i32 = new Int32Array(f32.buffer);
|
|
18
|
+
setUniforms(f32, i32);
|
|
19
|
+
mockState.uniformSnapshots.push(Array.from(f32));
|
|
20
|
+
}),
|
|
21
|
+
}));
|
|
22
|
+
({ applyWgpuEffectBoxBlur } = await import('./wgpuEffectBoxBlur'));
|
|
23
|
+
({ createWgpuEffectPipeline, drawWgpuEffectPass } = await import('./wgpuEffectPass'));
|
|
7
24
|
});
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
createWgpuEffectPipeline: vi.fn(() => ({ blendMode: 'replace', pipeline: {} })),
|
|
11
|
-
drawWgpuEffectPass: vi.fn((_state, _source, _dest, _pipeline, setUniforms) => {
|
|
12
|
-
const f32 = new Float32Array(16);
|
|
13
|
-
const i32 = new Int32Array(f32.buffer);
|
|
14
|
-
setUniforms(f32, i32);
|
|
15
|
-
mockState.uniformSnapshots.push(Array.from(f32));
|
|
16
|
-
}),
|
|
25
|
+
const mockState = vi.hoisted(() => ({
|
|
26
|
+
uniformSnapshots: [] as number[][],
|
|
17
27
|
}));
|
|
18
28
|
|
|
19
|
-
import { applyWgpuEffectBoxBlur } from './wgpuEffectBoxBlur';
|
|
20
|
-
import { createWgpuEffectPipeline, drawWgpuEffectPass } from './wgpuEffectPass';
|
|
21
|
-
|
|
22
29
|
describe('applyWgpuEffectBoxBlur', () => {
|
|
23
30
|
it('is a function', () => {
|
|
24
31
|
expect(typeof applyWgpuEffectBoxBlur).toBe('function');
|
|
@@ -1,20 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
});
|
|
1
|
+
import type * as WgpueffectpassModule from './wgpuEffectPass';
|
|
2
|
+
import type * as WgpueffecttintshaderModule from './wgpuEffectTintShader';
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
// Mocked per file with doMock plus dynamic imports of the subject, not top-level hoisted vi.mock.
|
|
5
|
+
// The suite runs isolate:false over a shared module registry, so a hoisted mock is registered for
|
|
6
|
+
// every file in the worker rather than this one -- see the rule in the root vitest config.
|
|
7
|
+
let createWgpuDualSourceEffectPipeline: typeof WgpueffectpassModule.createWgpuDualSourceEffectPipeline;
|
|
8
|
+
let createWgpuEffectPipeline: typeof WgpueffectpassModule.createWgpuEffectPipeline;
|
|
9
|
+
let applyWgpuEffectInnerClipPass: typeof WgpueffecttintshaderModule.applyWgpuEffectInnerClipPass;
|
|
10
|
+
let applyWgpuEffectInvertTintPass: typeof WgpueffecttintshaderModule.applyWgpuEffectInvertTintPass;
|
|
11
|
+
let applyWgpuEffectTintPass: typeof WgpueffecttintshaderModule.applyWgpuEffectTintPass;
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
beforeAll(async () => {
|
|
14
|
+
vi.resetModules();
|
|
15
|
+
vi.doMock('./wgpuEffectPass', () => ({
|
|
16
|
+
createWgpuDualSourceEffectPipeline: vi.fn(() => ({ blendMode: 'replace', pipeline: {} })),
|
|
17
|
+
createWgpuEffectPipeline: vi.fn(() => ({ blendMode: 'replace', pipeline: {} })),
|
|
18
|
+
drawWgpuDualSourceEffectPass: vi.fn(),
|
|
19
|
+
drawWgpuEffectPass: vi.fn(),
|
|
20
|
+
}));
|
|
21
|
+
({ createWgpuDualSourceEffectPipeline, createWgpuEffectPipeline } = await import('./wgpuEffectPass'));
|
|
22
|
+
({ applyWgpuEffectInnerClipPass, applyWgpuEffectInvertTintPass, applyWgpuEffectTintPass } =
|
|
23
|
+
await import('./wgpuEffectTintShader'));
|
|
24
|
+
});
|
|
18
25
|
|
|
19
26
|
describe('applyWgpuEffectInnerClipPass', () => {
|
|
20
27
|
it('is a function', () => {
|
|
@@ -1,41 +1,49 @@
|
|
|
1
|
-
|
|
1
|
+
import type * as WgpueffectblitshaderModule from './wgpuEffectBlitShader';
|
|
2
|
+
import type * as WgpueffectboxblurModule from './wgpuEffectBoxBlur';
|
|
3
|
+
import type * as WgpueffecttintshaderModule from './wgpuEffectTintShader';
|
|
4
|
+
import type * as WgpuinnergloweffectModule from './wgpuInnerGlowEffect';
|
|
5
|
+
|
|
6
|
+
// Mocked per file with doMock plus dynamic imports of the subject, not top-level hoisted vi.mock.
|
|
7
|
+
// The suite runs isolate:false over a shared module registry, so a hoisted mock is registered for
|
|
8
|
+
// every file in the worker rather than this one -- see the rule in the root vitest config.
|
|
9
|
+
let applyWgpuEffectBlitPass: typeof WgpueffectblitshaderModule.applyWgpuEffectBlitPass;
|
|
10
|
+
let applyWgpuEffectBoxBlur: typeof WgpueffectboxblurModule.applyWgpuEffectBoxBlur;
|
|
11
|
+
let applyWgpuEffectInnerClipPass: typeof WgpueffecttintshaderModule.applyWgpuEffectInnerClipPass;
|
|
12
|
+
let applyInnerGlowEffectToWgpu: typeof WgpuinnergloweffectModule.applyInnerGlowEffectToWgpu;
|
|
13
|
+
let defaultWgpuInnerGlowEffectRunner: typeof WgpuinnergloweffectModule.defaultWgpuInnerGlowEffectRunner;
|
|
14
|
+
|
|
15
|
+
beforeAll(async () => {
|
|
2
16
|
vi.resetModules();
|
|
17
|
+
vi.doMock('@flighthq/render-wgpu/contract', () => {
|
|
18
|
+
let nextTargetId = 0;
|
|
19
|
+
return {
|
|
20
|
+
acquireWgpuRenderTarget: vi.fn((_state, _pool, descriptor) => ({
|
|
21
|
+
...descriptor,
|
|
22
|
+
id: `scratch-${nextTargetId++}`,
|
|
23
|
+
texture: {},
|
|
24
|
+
})),
|
|
25
|
+
releaseWgpuRenderTarget: vi.fn(),
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
vi.doMock('./wgpuEffectBlitShader', () => ({
|
|
29
|
+
applyWgpuEffectBlitPass: vi.fn(),
|
|
30
|
+
}));
|
|
31
|
+
vi.doMock('./wgpuEffectBoxBlur', () => ({
|
|
32
|
+
applyWgpuEffectBoxBlur: vi.fn(),
|
|
33
|
+
}));
|
|
34
|
+
vi.doMock('./wgpuEffectPass', () => ({
|
|
35
|
+
clearWgpuEffectTarget: vi.fn(),
|
|
36
|
+
}));
|
|
37
|
+
vi.doMock('./wgpuEffectTintShader', () => ({
|
|
38
|
+
applyWgpuEffectInnerClipPass: vi.fn(),
|
|
39
|
+
applyWgpuEffectInvertTintPass: vi.fn(),
|
|
40
|
+
}));
|
|
41
|
+
({ applyWgpuEffectBlitPass } = await import('./wgpuEffectBlitShader'));
|
|
42
|
+
({ applyWgpuEffectBoxBlur } = await import('./wgpuEffectBoxBlur'));
|
|
43
|
+
({ applyWgpuEffectInnerClipPass } = await import('./wgpuEffectTintShader'));
|
|
44
|
+
({ applyInnerGlowEffectToWgpu, defaultWgpuInnerGlowEffectRunner } = await import('./wgpuInnerGlowEffect'));
|
|
3
45
|
});
|
|
4
46
|
|
|
5
|
-
vi.mock('@flighthq/render-wgpu/contract', () => {
|
|
6
|
-
let nextTargetId = 0;
|
|
7
|
-
return {
|
|
8
|
-
acquireWgpuRenderTarget: vi.fn((_state, _pool, descriptor) => ({
|
|
9
|
-
...descriptor,
|
|
10
|
-
id: `scratch-${nextTargetId++}`,
|
|
11
|
-
texture: {},
|
|
12
|
-
})),
|
|
13
|
-
releaseWgpuRenderTarget: vi.fn(),
|
|
14
|
-
};
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
vi.mock('./wgpuEffectBlitShader', () => ({
|
|
18
|
-
applyWgpuEffectBlitPass: vi.fn(),
|
|
19
|
-
}));
|
|
20
|
-
|
|
21
|
-
vi.mock('./wgpuEffectBoxBlur', () => ({
|
|
22
|
-
applyWgpuEffectBoxBlur: vi.fn(),
|
|
23
|
-
}));
|
|
24
|
-
|
|
25
|
-
vi.mock('./wgpuEffectPass', () => ({
|
|
26
|
-
clearWgpuEffectTarget: vi.fn(),
|
|
27
|
-
}));
|
|
28
|
-
|
|
29
|
-
vi.mock('./wgpuEffectTintShader', () => ({
|
|
30
|
-
applyWgpuEffectInnerClipPass: vi.fn(),
|
|
31
|
-
applyWgpuEffectInvertTintPass: vi.fn(),
|
|
32
|
-
}));
|
|
33
|
-
|
|
34
|
-
import { applyWgpuEffectBlitPass } from './wgpuEffectBlitShader';
|
|
35
|
-
import { applyWgpuEffectBoxBlur } from './wgpuEffectBoxBlur';
|
|
36
|
-
import { applyWgpuEffectInnerClipPass } from './wgpuEffectTintShader';
|
|
37
|
-
import { applyInnerGlowEffectToWgpu, defaultWgpuInnerGlowEffectRunner } from './wgpuInnerGlowEffect';
|
|
38
|
-
|
|
39
47
|
describe('applyInnerGlowEffectToWgpu', () => {
|
|
40
48
|
it('is a function', () => {
|
|
41
49
|
expect(typeof applyInnerGlowEffectToWgpu).toBe('function');
|
|
@@ -116,7 +124,7 @@ beforeEach(() => {
|
|
|
116
124
|
});
|
|
117
125
|
|
|
118
126
|
afterAll(() => {
|
|
119
|
-
vi.doUnmock('@flighthq/render-wgpu');
|
|
127
|
+
vi.doUnmock('@flighthq/render-wgpu/contract');
|
|
120
128
|
vi.doUnmock('./wgpuEffectBlitShader');
|
|
121
129
|
vi.doUnmock('./wgpuEffectBoxBlur');
|
|
122
130
|
vi.doUnmock('./wgpuEffectPass');
|
|
@@ -1,42 +1,50 @@
|
|
|
1
|
-
|
|
1
|
+
import type * as WgpueffectblitshaderModule from './wgpuEffectBlitShader';
|
|
2
|
+
import type * as WgpueffectboxblurModule from './wgpuEffectBoxBlur';
|
|
3
|
+
import type * as WgpueffecttintshaderModule from './wgpuEffectTintShader';
|
|
4
|
+
import type * as WgpuinnershadoweffectModule from './wgpuInnerShadowEffect';
|
|
5
|
+
|
|
6
|
+
// Mocked per file with doMock plus dynamic imports of the subject, not top-level hoisted vi.mock.
|
|
7
|
+
// The suite runs isolate:false over a shared module registry, so a hoisted mock is registered for
|
|
8
|
+
// every file in the worker rather than this one -- see the rule in the root vitest config.
|
|
9
|
+
let applyWgpuEffectBlitPass: typeof WgpueffectblitshaderModule.applyWgpuEffectBlitPass;
|
|
10
|
+
let applyWgpuEffectBoxBlur: typeof WgpueffectboxblurModule.applyWgpuEffectBoxBlur;
|
|
11
|
+
let applyWgpuEffectInnerClipPass: typeof WgpueffecttintshaderModule.applyWgpuEffectInnerClipPass;
|
|
12
|
+
let applyInnerShadowEffectToWgpu: typeof WgpuinnershadoweffectModule.applyInnerShadowEffectToWgpu;
|
|
13
|
+
let defaultWgpuInnerShadowEffectRunner: typeof WgpuinnershadoweffectModule.defaultWgpuInnerShadowEffectRunner;
|
|
14
|
+
|
|
15
|
+
beforeAll(async () => {
|
|
2
16
|
vi.resetModules();
|
|
17
|
+
vi.doMock('@flighthq/render-wgpu/contract', () => {
|
|
18
|
+
let nextTargetId = 0;
|
|
19
|
+
return {
|
|
20
|
+
acquireWgpuRenderTarget: vi.fn((_state, _pool, descriptor) => ({
|
|
21
|
+
...descriptor,
|
|
22
|
+
id: `scratch-${nextTargetId++}`,
|
|
23
|
+
texture: {},
|
|
24
|
+
})),
|
|
25
|
+
releaseWgpuRenderTarget: vi.fn(),
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
vi.doMock('./wgpuEffectBlitShader', () => ({
|
|
29
|
+
applyWgpuEffectBlitOffsetPass: vi.fn(),
|
|
30
|
+
applyWgpuEffectBlitPass: vi.fn(),
|
|
31
|
+
}));
|
|
32
|
+
vi.doMock('./wgpuEffectBoxBlur', () => ({
|
|
33
|
+
applyWgpuEffectBoxBlur: vi.fn(),
|
|
34
|
+
}));
|
|
35
|
+
vi.doMock('./wgpuEffectPass', () => ({
|
|
36
|
+
clearWgpuEffectTarget: vi.fn(),
|
|
37
|
+
}));
|
|
38
|
+
vi.doMock('./wgpuEffectTintShader', () => ({
|
|
39
|
+
applyWgpuEffectInnerClipPass: vi.fn(),
|
|
40
|
+
applyWgpuEffectInvertTintPass: vi.fn(),
|
|
41
|
+
}));
|
|
42
|
+
({ applyWgpuEffectBlitPass } = await import('./wgpuEffectBlitShader'));
|
|
43
|
+
({ applyWgpuEffectBoxBlur } = await import('./wgpuEffectBoxBlur'));
|
|
44
|
+
({ applyWgpuEffectInnerClipPass } = await import('./wgpuEffectTintShader'));
|
|
45
|
+
({ applyInnerShadowEffectToWgpu, defaultWgpuInnerShadowEffectRunner } = await import('./wgpuInnerShadowEffect'));
|
|
3
46
|
});
|
|
4
47
|
|
|
5
|
-
vi.mock('@flighthq/render-wgpu/contract', () => {
|
|
6
|
-
let nextTargetId = 0;
|
|
7
|
-
return {
|
|
8
|
-
acquireWgpuRenderTarget: vi.fn((_state, _pool, descriptor) => ({
|
|
9
|
-
...descriptor,
|
|
10
|
-
id: `scratch-${nextTargetId++}`,
|
|
11
|
-
texture: {},
|
|
12
|
-
})),
|
|
13
|
-
releaseWgpuRenderTarget: vi.fn(),
|
|
14
|
-
};
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
vi.mock('./wgpuEffectBlitShader', () => ({
|
|
18
|
-
applyWgpuEffectBlitOffsetPass: vi.fn(),
|
|
19
|
-
applyWgpuEffectBlitPass: vi.fn(),
|
|
20
|
-
}));
|
|
21
|
-
|
|
22
|
-
vi.mock('./wgpuEffectBoxBlur', () => ({
|
|
23
|
-
applyWgpuEffectBoxBlur: vi.fn(),
|
|
24
|
-
}));
|
|
25
|
-
|
|
26
|
-
vi.mock('./wgpuEffectPass', () => ({
|
|
27
|
-
clearWgpuEffectTarget: vi.fn(),
|
|
28
|
-
}));
|
|
29
|
-
|
|
30
|
-
vi.mock('./wgpuEffectTintShader', () => ({
|
|
31
|
-
applyWgpuEffectInnerClipPass: vi.fn(),
|
|
32
|
-
applyWgpuEffectInvertTintPass: vi.fn(),
|
|
33
|
-
}));
|
|
34
|
-
|
|
35
|
-
import { applyWgpuEffectBlitPass } from './wgpuEffectBlitShader';
|
|
36
|
-
import { applyWgpuEffectBoxBlur } from './wgpuEffectBoxBlur';
|
|
37
|
-
import { applyWgpuEffectInnerClipPass } from './wgpuEffectTintShader';
|
|
38
|
-
import { applyInnerShadowEffectToWgpu, defaultWgpuInnerShadowEffectRunner } from './wgpuInnerShadowEffect';
|
|
39
|
-
|
|
40
48
|
describe('applyInnerShadowEffectToWgpu', () => {
|
|
41
49
|
it('is a function', () => {
|
|
42
50
|
expect(typeof applyInnerShadowEffectToWgpu).toBe('function');
|
|
@@ -116,7 +124,7 @@ beforeEach(() => {
|
|
|
116
124
|
});
|
|
117
125
|
|
|
118
126
|
afterAll(() => {
|
|
119
|
-
vi.doUnmock('@flighthq/render-wgpu');
|
|
127
|
+
vi.doUnmock('@flighthq/render-wgpu/contract');
|
|
120
128
|
vi.doUnmock('./wgpuEffectBlitShader');
|
|
121
129
|
vi.doUnmock('./wgpuEffectBoxBlur');
|
|
122
130
|
vi.doUnmock('./wgpuEffectPass');
|
|
@@ -1,39 +1,44 @@
|
|
|
1
|
-
|
|
1
|
+
import type * as WgpueffectblitshaderModule from './wgpuEffectBlitShader';
|
|
2
|
+
import type * as WgpuoutergloweffectModule from './wgpuOuterGlowEffect';
|
|
3
|
+
|
|
4
|
+
// Mocked per file with doMock plus dynamic imports of the subject, not top-level hoisted vi.mock.
|
|
5
|
+
// The suite runs isolate:false over a shared module registry, so a hoisted mock is registered for
|
|
6
|
+
// every file in the worker rather than this one -- see the rule in the root vitest config.
|
|
7
|
+
let applyWgpuEffectBlitPass: typeof WgpueffectblitshaderModule.applyWgpuEffectBlitPass;
|
|
8
|
+
let applyWgpuEffectErasePass: typeof WgpueffectblitshaderModule.applyWgpuEffectErasePass;
|
|
9
|
+
let applyOuterGlowEffectToWgpu: typeof WgpuoutergloweffectModule.applyOuterGlowEffectToWgpu;
|
|
10
|
+
let defaultWgpuOuterGlowEffectRunner: typeof WgpuoutergloweffectModule.defaultWgpuOuterGlowEffectRunner;
|
|
11
|
+
|
|
12
|
+
beforeAll(async () => {
|
|
2
13
|
vi.resetModules();
|
|
14
|
+
vi.doMock('@flighthq/render-wgpu/contract', () => {
|
|
15
|
+
let nextTargetId = 0;
|
|
16
|
+
return {
|
|
17
|
+
acquireWgpuRenderTarget: vi.fn((_state, _pool, descriptor) => ({
|
|
18
|
+
...descriptor,
|
|
19
|
+
id: `scratch-${nextTargetId++}`,
|
|
20
|
+
texture: {},
|
|
21
|
+
})),
|
|
22
|
+
releaseWgpuRenderTarget: vi.fn(),
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
vi.doMock('./wgpuEffectBlitShader', () => ({
|
|
26
|
+
applyWgpuEffectBlitPass: vi.fn(),
|
|
27
|
+
applyWgpuEffectErasePass: vi.fn(),
|
|
28
|
+
}));
|
|
29
|
+
vi.doMock('./wgpuEffectBoxBlur', () => ({
|
|
30
|
+
applyWgpuEffectBoxBlur: vi.fn(),
|
|
31
|
+
}));
|
|
32
|
+
vi.doMock('./wgpuEffectPass', () => ({
|
|
33
|
+
clearWgpuEffectTarget: vi.fn(),
|
|
34
|
+
}));
|
|
35
|
+
vi.doMock('./wgpuEffectTintShader', () => ({
|
|
36
|
+
applyWgpuEffectTintPass: vi.fn(),
|
|
37
|
+
}));
|
|
38
|
+
({ applyWgpuEffectBlitPass, applyWgpuEffectErasePass } = await import('./wgpuEffectBlitShader'));
|
|
39
|
+
({ applyOuterGlowEffectToWgpu, defaultWgpuOuterGlowEffectRunner } = await import('./wgpuOuterGlowEffect'));
|
|
3
40
|
});
|
|
4
41
|
|
|
5
|
-
vi.mock('@flighthq/render-wgpu/contract', () => {
|
|
6
|
-
let nextTargetId = 0;
|
|
7
|
-
return {
|
|
8
|
-
acquireWgpuRenderTarget: vi.fn((_state, _pool, descriptor) => ({
|
|
9
|
-
...descriptor,
|
|
10
|
-
id: `scratch-${nextTargetId++}`,
|
|
11
|
-
texture: {},
|
|
12
|
-
})),
|
|
13
|
-
releaseWgpuRenderTarget: vi.fn(),
|
|
14
|
-
};
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
vi.mock('./wgpuEffectBlitShader', () => ({
|
|
18
|
-
applyWgpuEffectBlitPass: vi.fn(),
|
|
19
|
-
applyWgpuEffectErasePass: vi.fn(),
|
|
20
|
-
}));
|
|
21
|
-
|
|
22
|
-
vi.mock('./wgpuEffectBoxBlur', () => ({
|
|
23
|
-
applyWgpuEffectBoxBlur: vi.fn(),
|
|
24
|
-
}));
|
|
25
|
-
|
|
26
|
-
vi.mock('./wgpuEffectPass', () => ({
|
|
27
|
-
clearWgpuEffectTarget: vi.fn(),
|
|
28
|
-
}));
|
|
29
|
-
|
|
30
|
-
vi.mock('./wgpuEffectTintShader', () => ({
|
|
31
|
-
applyWgpuEffectTintPass: vi.fn(),
|
|
32
|
-
}));
|
|
33
|
-
|
|
34
|
-
import { applyWgpuEffectBlitPass, applyWgpuEffectErasePass } from './wgpuEffectBlitShader';
|
|
35
|
-
import { applyOuterGlowEffectToWgpu, defaultWgpuOuterGlowEffectRunner } from './wgpuOuterGlowEffect';
|
|
36
|
-
|
|
37
42
|
describe('applyOuterGlowEffectToWgpu', () => {
|
|
38
43
|
it('is a function', () => {
|
|
39
44
|
expect(typeof applyOuterGlowEffectToWgpu).toBe('function');
|
|
@@ -87,7 +92,7 @@ beforeEach(() => {
|
|
|
87
92
|
});
|
|
88
93
|
|
|
89
94
|
afterAll(() => {
|
|
90
|
-
vi.doUnmock('@flighthq/render-wgpu');
|
|
95
|
+
vi.doUnmock('@flighthq/render-wgpu/contract');
|
|
91
96
|
vi.doUnmock('./wgpuEffectBlitShader');
|
|
92
97
|
vi.doUnmock('./wgpuEffectBoxBlur');
|
|
93
98
|
vi.doUnmock('./wgpuEffectPass');
|