@flighthq/scene2d-wgpu 0.3.1-next.975.01aea94 → 0.4.0-edge.1908.751021c
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/dist/wgpuClipRectangle.js +6 -6
- package/dist/wgpuClipRectangle.js.map +1 -1
- package/dist/wgpuShapeMesh.js +8 -8
- package/dist/wgpuShapeMesh.js.map +1 -1
- package/package.json +19 -19
- package/src/wgpuCache.test.ts +82 -103
- package/src/wgpuMeshShapeRenderer.test.ts +17 -19
- package/src/wgpuRasterShapeRenderer.test.ts +15 -17
- package/src/wgpuScale9Shape.test.ts +1 -1
- package/src/wgpuShape.test.ts +23 -27
- package/src/wgpuShapeMesh.test.ts +5 -5
- package/src/wgpuTextLabel.test.ts +28 -32
- package/dist/moduleMockTestHelper.d.ts +0 -15
- package/dist/moduleMockTestHelper.d.ts.map +0 -1
- package/dist/moduleMockTestHelper.js +0 -25
- package/dist/moduleMockTestHelper.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getWgpuRenderStateRuntime } from '@flighthq/render-wgpu/contract';
|
|
1
|
+
import { getWgpuRenderStateRuntime, setWgpuRenderPassScissorRect } from '@flighthq/render-wgpu/contract';
|
|
2
2
|
import { flushWgpuQuadBatchWriter } from './wgpuQuadBatchWriter';
|
|
3
3
|
export function popWgpuClipRectangle(state) {
|
|
4
4
|
const runtime = getWgpuRenderStateRuntime(state);
|
|
@@ -12,14 +12,14 @@ export function popWgpuClipRectangle(state) {
|
|
|
12
12
|
return;
|
|
13
13
|
if (previous === null) {
|
|
14
14
|
const viewport = runtime.renderTargetViewport ?? state.canvas;
|
|
15
|
-
pass
|
|
15
|
+
setWgpuRenderPassScissorRect(state, pass, 0, 0, viewport.width, viewport.height);
|
|
16
16
|
}
|
|
17
17
|
else if (previous.width <= 0 || previous.height <= 0) {
|
|
18
18
|
// Empty intersection stored during push — maintain degenerate scissor until fully popped.
|
|
19
|
-
pass
|
|
19
|
+
setWgpuRenderPassScissorRect(state, pass, 0, 0, 1, 1);
|
|
20
20
|
}
|
|
21
21
|
else {
|
|
22
|
-
pass
|
|
22
|
+
setWgpuRenderPassScissorRect(state, pass, previous.x, previous.y, previous.width, previous.height);
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
export function pushWgpuClipRectangle(state, rect, transform) {
|
|
@@ -34,10 +34,10 @@ export function pushWgpuClipRectangle(state, rect, transform) {
|
|
|
34
34
|
if (next.width <= 0 || next.height <= 0) {
|
|
35
35
|
// Clip rect projects entirely outside the viewport — use a 1×1 degenerate scissor at
|
|
36
36
|
// the origin so the node is effectively invisible while the rect remains Wgpu-valid.
|
|
37
|
-
pass
|
|
37
|
+
setWgpuRenderPassScissorRect(state, pass, 0, 0, 1, 1);
|
|
38
38
|
}
|
|
39
39
|
else {
|
|
40
|
-
pass
|
|
40
|
+
setWgpuRenderPassScissorRect(state, pass, next.x, next.y, next.width, next.height);
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
function computeWgpuScissorRect(state, rect, transform) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wgpuClipRectangle.js","sourceRoot":"","sources":["../src/wgpuClipRectangle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"wgpuClipRectangle.js","sourceRoot":"","sources":["../src/wgpuClipRectangle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAGzG,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAEjE,MAAM,UAAU,oBAAoB,CAAC,KAAsB;IACzD,MAAM,OAAO,GAAG,yBAAyB,CAAC,KAAK,CAAC,CAAC;IACjD,wBAAwB,CAAC,KAAK,CAAC,CAAC;IAChC,MAAM,KAAK,GAAG,OAAO,CAAC,YAAY,CAAC;IACnC,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,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7B,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;IACrD,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC;IAExD,OAAO;QACL,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC;QAC/B,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC;QAC7B,CAAC;QACD,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/wgpuShapeMesh.js
CHANGED
|
@@ -48,14 +48,14 @@ export function drawWgpuShapeMeshBatch(state, renderProxy, meshes, buffers, pipe
|
|
|
48
48
|
const indexBuffer = ensureShapeMeshIndexBuffer(state, buffers, i, mesh.indices.byteLength);
|
|
49
49
|
queue.writeBuffer(vertexBuffer, 0, mesh.vertices.buffer, mesh.vertices.byteOffset, mesh.vertices.byteLength);
|
|
50
50
|
writeShapeMeshIndices(queue, indexBuffer, mesh.indices);
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
uniformData[12] = r *
|
|
56
|
-
uniformData[13] = g *
|
|
57
|
-
uniformData[14] = b *
|
|
58
|
-
uniformData[15] =
|
|
51
|
+
const r = ((mesh.color >>> 24) & 0xff) / 255;
|
|
52
|
+
const g = ((mesh.color >>> 16) & 0xff) / 255;
|
|
53
|
+
const b = ((mesh.color >>> 8) & 0xff) / 255;
|
|
54
|
+
const ca = ((mesh.color & 0xff) / 255) * a;
|
|
55
|
+
uniformData[12] = r * ca;
|
|
56
|
+
uniformData[13] = g * ca;
|
|
57
|
+
uniformData[14] = b * ca;
|
|
58
|
+
uniformData[15] = ca;
|
|
59
59
|
queue.writeBuffer(uniformBuffers[i], 0, uniformData.buffer, uniformData.byteOffset, uniformData.byteLength);
|
|
60
60
|
pass.setBindGroup(0, bindGroups[i]);
|
|
61
61
|
pass.setVertexBuffer(0, vertexBuffer);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wgpuShapeMesh.js","sourceRoot":"","sources":["../src/wgpuShapeMesh.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,qCAAqC,EACrC,yBAAyB,EACzB,gBAAgB,GACjB,MAAM,gCAAgC,CAAC;AASxC,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAEjE,gGAAgG;AAChG,uGAAuG;AACvG,0GAA0G;AAC1G,uGAAuG;AACvG,uGAAuG;AACvG,QAAQ;AACR,EAAE;AACF,uGAAuG;AACvG,wGAAwG;AACxG,sGAAsG;AACtG,sGAAsG;AACtG,EAAE;AACF,oGAAoG;AACpG,4EAA4E;AAE5E,uGAAuG;AACvG,qGAAqG;AACrG,sGAAsG;AACtG,kFAAkF;AAClF,MAAM,UAAU,sBAAsB,CACpC,KAAsB,EACtB,WAA0B,EAC1B,MAAgC,EAChC,OAA6B,EAC7B,aAAoC,EACpC,cAA2B,EAC3B,UAA0B,EAC1B,WAAyB;IAEzB,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO;IAChC,MAAM,OAAO,GAAG,yBAAyB,CAAC,KAAK,CAAC,CAAC;IACjD,wBAAwB,CAAC,KAAK,CAAC,CAAC;IAEhC,MAAM,IAAI,GAAG,OAAO,CAAC,UAAU,CAAC;IAChC,IAAI,IAAI,KAAK,IAAI;QAAE,OAAO;IAE1B,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;IAC5B,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;IAE3B,gGAAgG;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G,OAAO,CAAC,UAAU,CAAC;IACtC,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3B,KAAK,CAAC,WAAW,CAAC,WAAW,EAAE,CAAC,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;QAClF,OAAO;IACT,CAAC;IACD,MAAM,WAAW,GAAG,CAAC,UAAU,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1C,MAAM,SAAS,GAAG,WAAW,IAAI,CAAC,CAAC;IACnC,IAAI,sBAAsB,CAAC,MAAM,GAAG,SAAS;QAAE,sBAAsB,GAAG,IAAI,WAAW,CAAC,SAAS,CAAC,CAAC;IACnG,sBAAsB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACpC,KAAK,CAAC,WAAW,CAAC,WAAW,EAAE,CAAC,EAAE,sBAAsB,CAAC,MAAM,EAAE,CAAC,EAAE,WAAW,CAAC,CAAC;AACnF,CAAC;AAED,qGAAqG;AACrG,wFAAwF;AACxF,MAAM,wBAAwB,GAAG,IAAI,YAAY,CAAC,yBAAyB,CAAC,CAAC;AAE7E,2GAA2G;AAC3G,0FAA0F;AAC1F,IAAI,sBAAsB,GAAG,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flighthq/scene2d-wgpu",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0-edge.1908.751021c",
|
|
4
4
|
"author": "Joshua Granick and other contributors",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -38,24 +38,24 @@
|
|
|
38
38
|
"clean:dist": "tsx ../../scripts/clean-package-dist.ts"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@flighthq/color": "0.
|
|
42
|
-
"@flighthq/scene2d": "0.
|
|
43
|
-
"@flighthq/scene2d-canvas": "0.
|
|
44
|
-
"@flighthq/geometry": "0.
|
|
45
|
-
"@flighthq/image": "0.
|
|
46
|
-
"@flighthq/log": "0.
|
|
47
|
-
"@flighthq/node": "0.
|
|
48
|
-
"@flighthq/path": "0.
|
|
49
|
-
"@flighthq/registry": "0.
|
|
50
|
-
"@flighthq/render": "0.
|
|
51
|
-
"@flighthq/render-wgpu": "0.
|
|
52
|
-
"@flighthq/shape": "0.
|
|
53
|
-
"@flighthq/text": "0.
|
|
54
|
-
"@flighthq/textinput": "0.
|
|
55
|
-
"@flighthq/textlayout": "0.
|
|
56
|
-
"@flighthq/texture": "0.
|
|
57
|
-
"@flighthq/types": "0.
|
|
58
|
-
"@flighthq/velocity": "0.
|
|
41
|
+
"@flighthq/color": "0.4.0-edge.1908.751021c",
|
|
42
|
+
"@flighthq/scene2d": "0.4.0-edge.1908.751021c",
|
|
43
|
+
"@flighthq/scene2d-canvas": "0.4.0-edge.1908.751021c",
|
|
44
|
+
"@flighthq/geometry": "0.4.0-edge.1908.751021c",
|
|
45
|
+
"@flighthq/image": "0.4.0-edge.1908.751021c",
|
|
46
|
+
"@flighthq/log": "0.4.0-edge.1908.751021c",
|
|
47
|
+
"@flighthq/node": "0.4.0-edge.1908.751021c",
|
|
48
|
+
"@flighthq/path": "0.4.0-edge.1908.751021c",
|
|
49
|
+
"@flighthq/registry": "0.4.0-edge.1908.751021c",
|
|
50
|
+
"@flighthq/render": "0.4.0-edge.1908.751021c",
|
|
51
|
+
"@flighthq/render-wgpu": "0.4.0-edge.1908.751021c",
|
|
52
|
+
"@flighthq/shape": "0.4.0-edge.1908.751021c",
|
|
53
|
+
"@flighthq/text": "0.4.0-edge.1908.751021c",
|
|
54
|
+
"@flighthq/textinput": "0.4.0-edge.1908.751021c",
|
|
55
|
+
"@flighthq/textlayout": "0.4.0-edge.1908.751021c",
|
|
56
|
+
"@flighthq/texture": "0.4.0-edge.1908.751021c",
|
|
57
|
+
"@flighthq/types": "0.4.0-edge.1908.751021c",
|
|
58
|
+
"@flighthq/velocity": "0.4.0-edge.1908.751021c"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
61
|
"@webgpu/types": "^0.1.70"
|
package/src/wgpuCache.test.ts
CHANGED
|
@@ -20,116 +20,95 @@ import type {
|
|
|
20
20
|
} from '@flighthq/types/contract';
|
|
21
21
|
import { EntityRuntimeKey, RegistryEntryState } from '@flighthq/types/contract';
|
|
22
22
|
|
|
23
|
-
import { scopeModuleMocks } from './moduleMockTestHelper';
|
|
24
|
-
import type * as WgpuCacheModule from './wgpuCache';
|
|
25
23
|
import type * as WgpuNode2DModule from './wgpuNode2D';
|
|
26
24
|
import type * as WgpuQuadBatchWriterModule from './wgpuQuadBatchWriter';
|
|
27
25
|
|
|
28
26
|
// The GPU render-target lifecycle (@flighthq/render-wgpu) and the two local collaborators
|
|
29
|
-
// ./wgpuQuadBatchWriter and ./wgpuNode2D are stubbed so cache orchestration can be unit-tested
|
|
30
|
-
//
|
|
31
|
-
//
|
|
32
|
-
//
|
|
33
|
-
//
|
|
34
|
-
//
|
|
35
|
-
//
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
...actual,
|
|
71
|
-
beginWgpuFrame: vi.fn((state: WgpuRenderState) => {
|
|
72
|
-
getWgpuRenderStateRuntime(state).commandEncoder = {} as GPUCommandEncoder;
|
|
73
|
-
}),
|
|
74
|
-
beginWgpuRenderPass: vi.fn(),
|
|
75
|
-
setWgpuRenderTransform2D: vi.fn(),
|
|
76
|
-
createWgpuRenderTarget: vi.fn(
|
|
77
|
-
(_state: unknown, width: number, height: number): WgpuRenderTarget => ({
|
|
78
|
-
bindGroup: {} as GPUBindGroup,
|
|
79
|
-
colorSpace: 'srgb',
|
|
80
|
-
depthStencilTexture: {} as GPUTexture,
|
|
81
|
-
depthStencilView: {} as GPUTextureView,
|
|
82
|
-
texture: {} as GPUTexture,
|
|
83
|
-
view: {} as GPUTextureView,
|
|
84
|
-
format: 'bgra8unorm',
|
|
85
|
-
clearColors: [],
|
|
86
|
-
clearDepth: 1,
|
|
87
|
-
width,
|
|
88
|
-
height,
|
|
89
|
-
}),
|
|
90
|
-
),
|
|
91
|
-
destroyWgpuRenderTarget: vi.fn(),
|
|
92
|
-
drawWgpuRenderTargetResult: vi.fn(),
|
|
93
|
-
endWgpuRenderPass: vi.fn(),
|
|
94
|
-
resizeWgpuRenderTarget: vi.fn((_state: unknown, target: WgpuRenderTarget, width: number, height: number) => {
|
|
95
|
-
target.width = width;
|
|
96
|
-
target.height = height;
|
|
97
|
-
}),
|
|
98
|
-
submitWgpuRenderPass: vi.fn((state: WgpuRenderState) => {
|
|
99
|
-
getWgpuRenderStateRuntime(state).commandEncoder = null;
|
|
27
|
+
// ./wgpuQuadBatchWriter and ./wgpuNode2D are stubbed so cache orchestration can be unit-tested without a
|
|
28
|
+
// real GPU pipeline: createWgpuRenderTarget returns a plain descriptor, and the composite, batch-flush
|
|
29
|
+
// and subtree-render calls become spies for the call and ordering assertions below.
|
|
30
|
+
//
|
|
31
|
+
// ★ HOISTED MOCKS, NOT HAND-ROLLED ONES. This file is in REGISTRY_ISOLATED_TESTS, so it already runs with
|
|
32
|
+
// its own module registry — the hermeticity the `scopeModuleMocks` + `vi.doMock` + dynamic-import dance
|
|
33
|
+
// bought by hand comes from the platform here, with no hook, and these stubs cannot reach the real
|
|
34
|
+
// render-wgpu / scene2d-wgpu consumers. The dance was not merely redundant: it rebuilt the subject's
|
|
35
|
+
// entire transitive module graph inside a FIXED `beforeAll` deadline — three modules plus everything they
|
|
36
|
+
// import — which is unbounded work against a fixed clock and the shape of flake tiering exists to remove.
|
|
37
|
+
//
|
|
38
|
+
// ★ THE FRAME STUBS REACH THROUGH `actual`, NOT THROUGH AN OUTER BINDING. A hoisted factory runs during
|
|
39
|
+
// this file's own import phase, so closing over a module-scope `const` declared below it would be a
|
|
40
|
+
// temporal-dead-zone trap that only fires once the import order changes. `actual` is in hand already.
|
|
41
|
+
vi.mock('./wgpuQuadBatchWriter', async (importOriginal) => {
|
|
42
|
+
const actual = await importOriginal<typeof WgpuQuadBatchWriterModule>();
|
|
43
|
+
return { ...actual, flushWgpuQuadBatchWriter: vi.fn() };
|
|
44
|
+
});
|
|
45
|
+
vi.mock('@flighthq/render-wgpu/contract', async (importOriginal) => {
|
|
46
|
+
const actual = await importOriginal<typeof WgpuRenderWgpuModule>();
|
|
47
|
+
return {
|
|
48
|
+
...actual,
|
|
49
|
+
beginWgpuFrame: vi.fn((state: WgpuRenderState) => {
|
|
50
|
+
actual.getWgpuRenderStateRuntime(state).commandEncoder = {} as GPUCommandEncoder;
|
|
51
|
+
}),
|
|
52
|
+
beginWgpuRenderPass: vi.fn(),
|
|
53
|
+
setWgpuRenderTransform2D: vi.fn(),
|
|
54
|
+
createWgpuRenderTarget: vi.fn(
|
|
55
|
+
(_state: unknown, width: number, height: number): WgpuRenderTarget => ({
|
|
56
|
+
bindGroup: {} as GPUBindGroup,
|
|
57
|
+
colorSpace: 'srgb',
|
|
58
|
+
depthStencilTexture: {} as GPUTexture,
|
|
59
|
+
depthStencilView: {} as GPUTextureView,
|
|
60
|
+
texture: {} as GPUTexture,
|
|
61
|
+
view: {} as GPUTextureView,
|
|
62
|
+
format: 'bgra8unorm',
|
|
63
|
+
sampleCount: 1,
|
|
64
|
+
clearColors: [],
|
|
65
|
+
clearDepth: 1,
|
|
66
|
+
width,
|
|
67
|
+
height,
|
|
100
68
|
}),
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
submitWgpuRenderPass,
|
|
118
|
-
} = await import('@flighthq/render-wgpu/contract'));
|
|
119
|
-
({ flushWgpuQuadBatchWriter } = await import('./wgpuQuadBatchWriter'));
|
|
120
|
-
({ renderWgpuScene2D } = await import('./wgpuNode2D'));
|
|
121
|
-
({
|
|
122
|
-
createWgpuCacheState,
|
|
123
|
-
defaultWgpuRenderCacheRenderer,
|
|
124
|
-
enableWgpuRenderCache,
|
|
125
|
-
ensureWgpuRenderCacheTarget,
|
|
126
|
-
getWgpuRenderCacheScreenState,
|
|
127
|
-
getWgpuRenderCacheTarget,
|
|
128
|
-
refreshWgpuRenderCache,
|
|
129
|
-
releaseWgpuRenderCache,
|
|
130
|
-
} = await import('./wgpuCache'));
|
|
69
|
+
),
|
|
70
|
+
destroyWgpuRenderTarget: vi.fn(),
|
|
71
|
+
drawWgpuRenderTargetResult: vi.fn(),
|
|
72
|
+
endWgpuRenderPass: vi.fn(),
|
|
73
|
+
resizeWgpuRenderTarget: vi.fn((_state: unknown, target: WgpuRenderTarget, width: number, height: number) => {
|
|
74
|
+
target.width = width;
|
|
75
|
+
target.height = height;
|
|
76
|
+
}),
|
|
77
|
+
submitWgpuRenderPass: vi.fn((state: WgpuRenderState) => {
|
|
78
|
+
actual.getWgpuRenderStateRuntime(state).commandEncoder = null;
|
|
79
|
+
}),
|
|
80
|
+
};
|
|
81
|
+
});
|
|
82
|
+
vi.mock('./wgpuNode2D', async (importOriginal) => {
|
|
83
|
+
const actual = await importOriginal<typeof WgpuNode2DModule>();
|
|
84
|
+
return { ...actual, renderWgpuScene2D: vi.fn() };
|
|
131
85
|
});
|
|
132
86
|
|
|
87
|
+
import {
|
|
88
|
+
beginWgpuFrame,
|
|
89
|
+
createWgpuRenderStateRuntime,
|
|
90
|
+
destroyWgpuRenderTarget,
|
|
91
|
+
drawWgpuRenderTargetResult,
|
|
92
|
+
getWgpuMaterialRenderer,
|
|
93
|
+
getWgpuRenderStateRuntime,
|
|
94
|
+
registerWgpuMaterialRenderer,
|
|
95
|
+
resolveWgpuApplyBlendMode,
|
|
96
|
+
submitWgpuRenderPass,
|
|
97
|
+
} from '@flighthq/render-wgpu/contract';
|
|
98
|
+
|
|
99
|
+
import {
|
|
100
|
+
createWgpuCacheState,
|
|
101
|
+
defaultWgpuRenderCacheRenderer,
|
|
102
|
+
enableWgpuRenderCache,
|
|
103
|
+
ensureWgpuRenderCacheTarget,
|
|
104
|
+
getWgpuRenderCacheScreenState,
|
|
105
|
+
getWgpuRenderCacheTarget,
|
|
106
|
+
refreshWgpuRenderCache,
|
|
107
|
+
releaseWgpuRenderCache,
|
|
108
|
+
} from './wgpuCache';
|
|
109
|
+
import { renderWgpuScene2D } from './wgpuNode2D';
|
|
110
|
+
import { flushWgpuQuadBatchWriter } from './wgpuQuadBatchWriter';
|
|
111
|
+
|
|
133
112
|
function fakeScreen(options = {}): WgpuRenderState {
|
|
134
113
|
const state = createRenderState(options) as unknown as WgpuRenderState;
|
|
135
114
|
(state as any).device = {} as GPUDevice;
|
|
@@ -12,24 +12,22 @@ import {
|
|
|
12
12
|
import type { RenderProxy2D } from '@flighthq/types/contract';
|
|
13
13
|
import { BatchFormat, RenderRegistry } from '@flighthq/types/contract';
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
// ★ A HOISTED MOCK, NOT A HAND-ROLLED ONE. This file is in REGISTRY_ISOLATED_TESTS, so it already runs
|
|
16
|
+
// with its own module registry — the hermeticity the `scopeModuleMocks` + `vi.doMock` + dynamic-import
|
|
17
|
+
// dance bought by hand comes from the platform here, with no hook. The dance was not merely redundant:
|
|
18
|
+
// it rebuilt the subject's entire transitive module graph inside a FIXED `beforeAll` deadline, which is
|
|
19
|
+
// unbounded work against a fixed clock and the shape of flake that tiering exists to remove.
|
|
20
|
+
vi.mock('@flighthq/node/contract', async (importOriginal) => ({
|
|
21
|
+
...(await importOriginal<typeof FlightNodeModule>()),
|
|
22
|
+
getNodeLocalBoundsRectangle: () => ({ x: 0, y: 0, width: 64, height: 48 }),
|
|
23
|
+
getNodeLocalContentRevision: (source: { data?: { version?: number } } | null | undefined) =>
|
|
24
|
+
source?.data?.version ?? 0,
|
|
25
|
+
}));
|
|
26
|
+
|
|
27
|
+
import { defaultWgpuMeshShapeRenderer, drawWgpuMeshShape } from './wgpuMeshShapeRenderer';
|
|
17
28
|
import { registerWgpuShapeRasterizer } from './wgpuShapeRasterizer';
|
|
18
29
|
|
|
19
|
-
|
|
20
|
-
let drawWgpuMeshShape: typeof WgpuMeshShapeModule.drawWgpuMeshShape;
|
|
21
|
-
|
|
22
|
-
scopeModuleMocks(['@flighthq/node']);
|
|
23
|
-
|
|
24
|
-
beforeAll(async () => {
|
|
25
|
-
vi.doMock('@flighthq/node/contract', async (importOriginal) => ({
|
|
26
|
-
...(await importOriginal<typeof FlightNodeModule>()),
|
|
27
|
-
getNodeLocalBoundsRectangle: () => ({ x: 0, y: 0, width: 64, height: 48 }),
|
|
28
|
-
getNodeLocalContentRevision: (source: any) => source?.data?.version ?? 0,
|
|
29
|
-
}));
|
|
30
|
-
({ defaultWgpuMeshShapeRenderer, drawWgpuMeshShape } = await import('./wgpuMeshShapeRenderer'));
|
|
31
|
-
installWgpuMock();
|
|
32
|
-
});
|
|
30
|
+
beforeAll(() => installWgpuMock());
|
|
33
31
|
|
|
34
32
|
function makeShapeData() {
|
|
35
33
|
return {
|
|
@@ -80,7 +78,7 @@ function makeMeshPassSpy(): GPURenderPassEncoder {
|
|
|
80
78
|
|
|
81
79
|
function gradientShape() {
|
|
82
80
|
const shape = createShape();
|
|
83
|
-
appendShapeBeginGradientFill(shape, 'linear', [
|
|
81
|
+
appendShapeBeginGradientFill(shape, 'linear', [0xff0000ff, 0x0000ffff], [1, 1], [0, 255], null);
|
|
84
82
|
appendShapeRectangle(shape, 8, 8, 32, 24);
|
|
85
83
|
appendShapeEndFill(shape);
|
|
86
84
|
return shape;
|
|
@@ -133,7 +131,7 @@ describe('drawWgpuMeshShape', () => {
|
|
|
133
131
|
const pass = makeMeshPassSpy();
|
|
134
132
|
getWgpuRenderStateRuntime(state).renderPass = pass;
|
|
135
133
|
const shape = createShape();
|
|
136
|
-
appendShapeBeginFill(shape,
|
|
134
|
+
appendShapeBeginFill(shape, 0x00cc00ff);
|
|
137
135
|
appendShapeRectangle(shape, 8, 8, 32, 24);
|
|
138
136
|
appendShapeEndFill(shape);
|
|
139
137
|
|
|
@@ -154,7 +152,7 @@ describe('drawWgpuMeshShape', () => {
|
|
|
154
152
|
const state = await createWgpuRenderStateForTest();
|
|
155
153
|
renderWgpuBackground(state);
|
|
156
154
|
const shape = createShape();
|
|
157
|
-
appendShapeBeginFill(shape,
|
|
155
|
+
appendShapeBeginFill(shape, 0x00cc00ff);
|
|
158
156
|
appendShapeRectangle(shape, 8, 8, 32, 24);
|
|
159
157
|
appendShapeEndFill(shape);
|
|
160
158
|
|
|
@@ -6,25 +6,23 @@ import { appendShapeBeginFill, appendShapeEndFill, appendShapeRectangle, createS
|
|
|
6
6
|
import type { RenderProxy2D } from '@flighthq/types/contract';
|
|
7
7
|
import { BatchFormat, RenderRegistry } from '@flighthq/types/contract';
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
// ★ A HOISTED MOCK, NOT A HAND-ROLLED ONE. This file is in REGISTRY_ISOLATED_TESTS, so it already runs
|
|
10
|
+
// with its own module registry — the hermeticity the `scopeModuleMocks` + `vi.doMock` + dynamic-import
|
|
11
|
+
// dance bought by hand comes from the platform here, with no hook. The dance was not merely redundant:
|
|
12
|
+
// it rebuilt the subject's entire transitive module graph inside a FIXED `beforeAll` deadline, which is
|
|
13
|
+
// unbounded work against a fixed clock and the shape of flake that tiering exists to remove.
|
|
14
|
+
vi.mock('@flighthq/node/contract', async (importOriginal) => ({
|
|
15
|
+
...(await importOriginal<typeof FlightNodeModule>()),
|
|
16
|
+
getNodeLocalBoundsRectangle: () => ({ x: 0, y: 0, width: 64, height: 48 }),
|
|
17
|
+
getNodeLocalContentRevision: (source: { data?: { version?: number } } | null | undefined) =>
|
|
18
|
+
source?.data?.version ?? 0,
|
|
19
|
+
}));
|
|
20
|
+
|
|
21
|
+
import { defaultWgpuRasterShapeRenderer, drawWgpuRasterShape } from './wgpuRasterShapeRenderer';
|
|
11
22
|
import { registerWgpuShapeRasterizer } from './wgpuShapeRasterizer';
|
|
12
23
|
import { registerWgpuStandardMaterial } from './wgpuStandardMaterial';
|
|
13
24
|
|
|
14
|
-
|
|
15
|
-
let drawWgpuRasterShape: typeof WgpuRasterShapeModule.drawWgpuRasterShape;
|
|
16
|
-
|
|
17
|
-
scopeModuleMocks(['@flighthq/node']);
|
|
18
|
-
|
|
19
|
-
beforeAll(async () => {
|
|
20
|
-
vi.doMock('@flighthq/node/contract', async (importOriginal) => ({
|
|
21
|
-
...(await importOriginal<typeof FlightNodeModule>()),
|
|
22
|
-
getNodeLocalBoundsRectangle: () => ({ x: 0, y: 0, width: 64, height: 48 }),
|
|
23
|
-
getNodeLocalContentRevision: (source: any) => source?.data?.version ?? 0,
|
|
24
|
-
}));
|
|
25
|
-
({ defaultWgpuRasterShapeRenderer, drawWgpuRasterShape } = await import('./wgpuRasterShapeRenderer'));
|
|
26
|
-
installWgpuMock();
|
|
27
|
-
});
|
|
25
|
+
beforeAll(() => installWgpuMock());
|
|
28
26
|
|
|
29
27
|
function makeShapeData() {
|
|
30
28
|
return {
|
|
@@ -76,7 +74,7 @@ function makeMeshPassSpy(): GPURenderPassEncoder {
|
|
|
76
74
|
// A plain solid rectangle — precisely the shape the mesh strategy would tessellate.
|
|
77
75
|
function solidShape() {
|
|
78
76
|
const shape = createShape();
|
|
79
|
-
appendShapeBeginFill(shape,
|
|
77
|
+
appendShapeBeginFill(shape, 0x00cc00ff);
|
|
80
78
|
appendShapeRectangle(shape, 8, 8, 32, 24);
|
|
81
79
|
appendShapeEndFill(shape);
|
|
82
80
|
return shape;
|
|
@@ -60,7 +60,7 @@ describe('drawWgpuScale9Shape', () => {
|
|
|
60
60
|
const state = await createWgpuRenderStateForTest();
|
|
61
61
|
renderWgpuBackground(state);
|
|
62
62
|
const shape = createScale9Shape(grid);
|
|
63
|
-
appendShapeBeginFill(shape,
|
|
63
|
+
appendShapeBeginFill(shape, 0xff0000ff);
|
|
64
64
|
appendShapeRectangle(shape, 0, 0, 100, 100);
|
|
65
65
|
prepareScene2DRender(state, shape);
|
|
66
66
|
const renderProxy = getOrCreateRenderProxy2D(state, shape);
|
package/src/wgpuShape.test.ts
CHANGED
|
@@ -17,33 +17,29 @@ import type { RenderProxy2D } from '@flighthq/types/contract';
|
|
|
17
17
|
import { BatchFormat, PathCommand } from '@flighthq/types/contract';
|
|
18
18
|
|
|
19
19
|
import { enableWgpuStrokePathTessellation } from './enableWgpuStrokePathTessellation';
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
// @flighthq/node's bounds/revision queries expect a real BoundsNode; these tests drive drawWgpuShape with
|
|
21
|
+
// lightweight fake proxies, so the two queries are stubbed.
|
|
22
|
+
//
|
|
23
|
+
// ★ A HOISTED MOCK, NOT A HAND-ROLLED ONE. This file is in REGISTRY_ISOLATED_TESTS, so it already runs
|
|
24
|
+
// with its own module registry — the hermeticity the `scopeModuleMocks` + `vi.doMock` + dynamic-import
|
|
25
|
+
// dance bought by hand comes from the platform here, with no hook, and the stub cannot reach the many
|
|
26
|
+
// real consumers of these functions (node, interaction, shape, text). The dance was not merely
|
|
27
|
+
// redundant: it rebuilt the subject's entire transitive module graph inside a FIXED `beforeAll`
|
|
28
|
+
// deadline, which is unbounded work against a fixed clock and the shape of flake tiering exists to remove.
|
|
29
|
+
vi.mock('@flighthq/node/contract', async (importOriginal) => ({
|
|
30
|
+
...(await importOriginal<typeof FlightNodeModule>()),
|
|
31
|
+
getNodeLocalBoundsRectangle: () => ({ x: 0, y: 0, width: 64, height: 48 }),
|
|
32
|
+
getNodeLocalContentRevision: (source: { data?: { version?: number } } | null | undefined) =>
|
|
33
|
+
source?.data?.version ?? 0,
|
|
34
|
+
}));
|
|
35
|
+
|
|
36
|
+
import { defaultWgpuMorphShapeRenderer, defaultWgpuShapeRenderer, drawWgpuShape } from './wgpuShape';
|
|
22
37
|
import { registerWgpuShapeRasterizer } from './wgpuShapeRasterizer';
|
|
23
38
|
import { registerWgpuStandardMaterial } from './wgpuStandardMaterial';
|
|
24
39
|
|
|
25
40
|
const noopRasterizer = (): void => {};
|
|
26
41
|
|
|
27
|
-
|
|
28
|
-
// with lightweight fake proxies, so the two queries are stubbed. scopeModuleMocks scopes the stub to
|
|
29
|
-
// this file (registry reset before the mock applies, unmock + reset after), so under a shared
|
|
30
|
-
// (isolate:false) worker it never leaks into the many real consumers of these functions (node,
|
|
31
|
-
// interaction, shape, text) — and a sibling that pre-evaluated ./wgpuShape still picks up the stub.
|
|
32
|
-
let defaultWgpuMorphShapeRenderer: typeof WgpuShapeModule.defaultWgpuMorphShapeRenderer;
|
|
33
|
-
let defaultWgpuShapeRenderer: typeof WgpuShapeModule.defaultWgpuShapeRenderer;
|
|
34
|
-
let drawWgpuShape: typeof WgpuShapeModule.drawWgpuShape;
|
|
35
|
-
|
|
36
|
-
scopeModuleMocks(['@flighthq/node']);
|
|
37
|
-
|
|
38
|
-
beforeAll(async () => {
|
|
39
|
-
vi.doMock('@flighthq/node/contract', async (importOriginal) => ({
|
|
40
|
-
...(await importOriginal<typeof FlightNodeModule>()),
|
|
41
|
-
getNodeLocalBoundsRectangle: () => ({ x: 0, y: 0, width: 64, height: 48 }),
|
|
42
|
-
getNodeLocalContentRevision: (source: any) => source?.data?.version ?? 0,
|
|
43
|
-
}));
|
|
44
|
-
({ defaultWgpuMorphShapeRenderer, defaultWgpuShapeRenderer, drawWgpuShape } = await import('./wgpuShape'));
|
|
45
|
-
installWgpuMock();
|
|
46
|
-
});
|
|
42
|
+
beforeAll(() => installWgpuMock());
|
|
47
43
|
|
|
48
44
|
// Mirrors createWgpuShapeData: the rasterization surface is absent until a shape actually needs one,
|
|
49
45
|
// so a scene drawn entirely through the mesh path carries no canvases.
|
|
@@ -116,10 +112,10 @@ describe('drawWgpuShape', () => {
|
|
|
116
112
|
renderWgpuBackground(state);
|
|
117
113
|
getWgpuRenderStateRuntime(state).renderPass = makeMeshPassSpy();
|
|
118
114
|
const shape = createShape();
|
|
119
|
-
appendShapeBeginFill(shape,
|
|
115
|
+
appendShapeBeginFill(shape, 0x00cc00ff);
|
|
120
116
|
appendShapeRectangle(shape, 8, 8, 32, 24);
|
|
121
117
|
appendShapeEndFill(shape);
|
|
122
|
-
appendShapeLineStyle(shape, 4,
|
|
118
|
+
appendShapeLineStyle(shape, 4, 0xff0000ff);
|
|
123
119
|
appendShapeMoveTo(shape, 8, 4);
|
|
124
120
|
appendShapeLineTo(shape, 40, 4);
|
|
125
121
|
const rendererData = defaultWgpuShapeRenderer.createData!(state, shape)!;
|
|
@@ -141,7 +137,7 @@ describe('drawWgpuShape', () => {
|
|
|
141
137
|
renderWgpuBackground(state);
|
|
142
138
|
getWgpuRenderStateRuntime(state).renderPass = makeMeshPassSpy();
|
|
143
139
|
const shape = createShape();
|
|
144
|
-
appendShapeLineStyle(shape, 8,
|
|
140
|
+
appendShapeLineStyle(shape, 8, 0xff0000ff);
|
|
145
141
|
appendShapeRectangle(shape, 8, 8, 32, 24);
|
|
146
142
|
const rendererData = defaultWgpuShapeRenderer.createData!(state, shape)!;
|
|
147
143
|
|
|
@@ -163,7 +159,7 @@ describe('drawWgpuShape', () => {
|
|
|
163
159
|
const pass = makeMeshPassSpy();
|
|
164
160
|
getWgpuRenderStateRuntime(state).renderPass = pass;
|
|
165
161
|
const shape = createShape();
|
|
166
|
-
appendShapeLineStyle(shape, 8,
|
|
162
|
+
appendShapeLineStyle(shape, 8, 0xff0000ff);
|
|
167
163
|
appendShapeRectangle(shape, 8, 8, 32, 24);
|
|
168
164
|
const rendererData = defaultWgpuShapeRenderer.createData!(state, shape)!;
|
|
169
165
|
|
|
@@ -183,7 +179,7 @@ describe('drawWgpuShape', () => {
|
|
|
183
179
|
const pass = makeMeshPassSpy();
|
|
184
180
|
getWgpuRenderStateRuntime(state).renderPass = pass;
|
|
185
181
|
const shape = createShape();
|
|
186
|
-
appendShapeLineStyle(shape, 8,
|
|
182
|
+
appendShapeLineStyle(shape, 8, 0xff0000ff);
|
|
187
183
|
appendShapePath(
|
|
188
184
|
shape,
|
|
189
185
|
[PathCommand.MOVE_TO, PathCommand.LINE_TO, PathCommand.LINE_TO, PathCommand.LINE_TO, PathCommand.CLOSE],
|
|
@@ -21,7 +21,7 @@ beforeAll(() => {
|
|
|
21
21
|
const TRIANGLE: WgpuShapeMesh = {
|
|
22
22
|
vertices: new Float32Array([0, 0, 10, 0, 0, 10]),
|
|
23
23
|
indices: new Uint16Array([0, 1, 2]),
|
|
24
|
-
color:
|
|
24
|
+
color: 0xff8040ff,
|
|
25
25
|
alpha: 1,
|
|
26
26
|
};
|
|
27
27
|
|
|
@@ -111,7 +111,7 @@ describe('drawWgpuShapeMeshBatch', () => {
|
|
|
111
111
|
drawWgpuShapeMeshBatch(
|
|
112
112
|
state,
|
|
113
113
|
makeProxy({ alpha: 0.5 }),
|
|
114
|
-
[{ ...TRIANGLE, color:
|
|
114
|
+
[{ ...TRIANGLE, color: 0xffffffff }],
|
|
115
115
|
buffers,
|
|
116
116
|
pipelineEntry,
|
|
117
117
|
uniformBuffers,
|
|
@@ -146,7 +146,7 @@ describe('drawWgpuShapeMeshes', () => {
|
|
|
146
146
|
const state = await makeState();
|
|
147
147
|
const buffers = makeBuffers();
|
|
148
148
|
|
|
149
|
-
drawWgpuShapeMeshes(state, makeProxy(), [TRIANGLE, { ...TRIANGLE, color:
|
|
149
|
+
drawWgpuShapeMeshes(state, makeProxy(), [TRIANGLE, { ...TRIANGLE, color: 0x0080ffff }], buffers);
|
|
150
150
|
|
|
151
151
|
expect(buffers.vertexBuffers).toHaveLength(2);
|
|
152
152
|
expect(buffers.indexBuffers).toHaveLength(2);
|
|
@@ -219,7 +219,7 @@ describe('drawWgpuShapeMeshes', () => {
|
|
|
219
219
|
}
|
|
220
220
|
}) as unknown as GPUQueue['writeBuffer'];
|
|
221
221
|
|
|
222
|
-
drawWgpuShapeMeshes(state, makeProxy({ alpha: 0.5 }), [{ ...TRIANGLE, color:
|
|
222
|
+
drawWgpuShapeMeshes(state, makeProxy({ alpha: 0.5 }), [{ ...TRIANGLE, color: 0xffffffff }], buffers);
|
|
223
223
|
|
|
224
224
|
const uniformData = writes.get(buffers.uniformBuffers[0]);
|
|
225
225
|
expect(uniformData).toBeDefined();
|
|
@@ -288,7 +288,7 @@ describe('drawWgpuShapeMeshes', () => {
|
|
|
288
288
|
drawWgpuShapeMeshes(
|
|
289
289
|
state,
|
|
290
290
|
makeProxy({ alpha: 0.5, colorScaleBias: ct(0.25, 0.5, 0.75, 0.8, 0.1, 0.2, 0.3, 0.4) }),
|
|
291
|
-
[{ ...TRIANGLE, color:
|
|
291
|
+
[{ ...TRIANGLE, color: 0xffffffff }],
|
|
292
292
|
buffers,
|
|
293
293
|
);
|
|
294
294
|
|
|
@@ -6,41 +6,37 @@ import { createTextLabel } from '@flighthq/text/contract';
|
|
|
6
6
|
import type { RenderProxy2D } from '@flighthq/types/contract';
|
|
7
7
|
import { BatchFormat } from '@flighthq/types/contract';
|
|
8
8
|
|
|
9
|
-
import { scopeModuleMocks } from './moduleMockTestHelper';
|
|
10
|
-
import { registerWgpuStandardMaterial } from './wgpuStandardMaterial';
|
|
11
|
-
import type * as WgpuTextLabelModule from './wgpuTextLabel';
|
|
12
|
-
|
|
13
9
|
// @flighthq/textlayout.computeTextLayout is stubbed to emit one deterministic glyph group.
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
|
|
18
|
-
|
|
10
|
+
//
|
|
11
|
+
// ★ A HOISTED MOCK, NOT A HAND-ROLLED ONE. This file is in REGISTRY_ISOLATED_TESTS, so it already runs
|
|
12
|
+
// with its own module registry — the hermeticity the `scopeModuleMocks` + `vi.doMock` + dynamic-import
|
|
13
|
+
// dance bought by hand comes from the platform here, with no hook, and the stub cannot reach the real
|
|
14
|
+
// text-layout consumers. The dance was not merely redundant: it rebuilt the subject's entire transitive
|
|
15
|
+
// module graph inside a FIXED `beforeAll` deadline, which is unbounded work against a fixed clock and
|
|
16
|
+
// the shape of flake tiering exists to remove.
|
|
17
|
+
vi.mock('@flighthq/textlayout/contract', async (importOriginal) => {
|
|
18
|
+
const actual = (await importOriginal()) as Record<string, unknown>;
|
|
19
|
+
return {
|
|
20
|
+
...actual,
|
|
21
|
+
computeTextLayout: vi.fn((result: { groups: object[] }, params: { formatRanges: Array<{ format: object }> }) => {
|
|
22
|
+
result.groups.push({
|
|
23
|
+
offsetX: 0,
|
|
24
|
+
offsetY: 0,
|
|
25
|
+
width: 50,
|
|
26
|
+
ascent: 12,
|
|
27
|
+
descent: 4,
|
|
28
|
+
format: params.formatRanges[0]?.format ?? {},
|
|
29
|
+
startIndex: 0,
|
|
30
|
+
endIndex: 5,
|
|
31
|
+
});
|
|
32
|
+
}),
|
|
33
|
+
};
|
|
34
|
+
});
|
|
19
35
|
|
|
20
|
-
|
|
36
|
+
import { registerWgpuStandardMaterial } from './wgpuStandardMaterial';
|
|
37
|
+
import { defaultWgpuTextLabelRenderer, drawWgpuTextLabel } from './wgpuTextLabel';
|
|
21
38
|
|
|
22
|
-
beforeAll(
|
|
23
|
-
vi.doMock('@flighthq/textlayout/contract', async (importOriginal) => {
|
|
24
|
-
const actual = (await importOriginal()) as Record<string, unknown>;
|
|
25
|
-
return {
|
|
26
|
-
...actual,
|
|
27
|
-
computeTextLayout: vi.fn((result: { groups: object[] }, params: { formatRanges: Array<{ format: object }> }) => {
|
|
28
|
-
result.groups.push({
|
|
29
|
-
offsetX: 0,
|
|
30
|
-
offsetY: 0,
|
|
31
|
-
width: 50,
|
|
32
|
-
ascent: 12,
|
|
33
|
-
descent: 4,
|
|
34
|
-
format: params.formatRanges[0]?.format ?? {},
|
|
35
|
-
startIndex: 0,
|
|
36
|
-
endIndex: 5,
|
|
37
|
-
});
|
|
38
|
-
}),
|
|
39
|
-
};
|
|
40
|
-
});
|
|
41
|
-
({ defaultWgpuTextLabelRenderer, drawWgpuTextLabel } = await import('./wgpuTextLabel'));
|
|
42
|
-
installWgpuMock();
|
|
43
|
-
});
|
|
39
|
+
beforeAll(() => installWgpuMock());
|
|
44
40
|
|
|
45
41
|
function makeTextData() {
|
|
46
42
|
const canvas = document.createElement('canvas');
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Makes vi.doMock-based module mocking safe under the shared (isolate:false) worker the root vitest
|
|
3
|
-
* config uses. Call once at the top of a test file with every module id the file mocks, then apply
|
|
4
|
-
* the mocks and dynamically import the subject inside a beforeAll — both must stay in the test file
|
|
5
|
-
* so relative ids resolve against it. (This helper is colocated in the same package src, so the
|
|
6
|
-
* doUnmock ids passed here resolve to the same modules the test's doMock ids do.)
|
|
7
|
-
*
|
|
8
|
-
* It brackets the file with two vi.resetModules() calls. The first is registered here so it runs
|
|
9
|
-
* before the file's own beforeAll applies the mocks: it forces a subject a sibling already evaluated
|
|
10
|
-
* against the real modules to re-evaluate under the mocks (otherwise the dynamic import returns the
|
|
11
|
-
* cached, real-bound copy). The second, after unmocking, drops the mocked instances so a later file
|
|
12
|
-
* re-imports the real modules instead of the mock left in the shared registry.
|
|
13
|
-
*/
|
|
14
|
-
export declare function scopeModuleMocks(mockedIds: readonly string[]): void;
|
|
15
|
-
//# sourceMappingURL=moduleMockTestHelper.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"moduleMockTestHelper.d.ts","sourceRoot":"","sources":["../src/moduleMockTestHelper.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAQnE"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { afterAll, beforeAll, vi } from 'vitest';
|
|
2
|
-
/**
|
|
3
|
-
* Makes vi.doMock-based module mocking safe under the shared (isolate:false) worker the root vitest
|
|
4
|
-
* config uses. Call once at the top of a test file with every module id the file mocks, then apply
|
|
5
|
-
* the mocks and dynamically import the subject inside a beforeAll — both must stay in the test file
|
|
6
|
-
* so relative ids resolve against it. (This helper is colocated in the same package src, so the
|
|
7
|
-
* doUnmock ids passed here resolve to the same modules the test's doMock ids do.)
|
|
8
|
-
*
|
|
9
|
-
* It brackets the file with two vi.resetModules() calls. The first is registered here so it runs
|
|
10
|
-
* before the file's own beforeAll applies the mocks: it forces a subject a sibling already evaluated
|
|
11
|
-
* against the real modules to re-evaluate under the mocks (otherwise the dynamic import returns the
|
|
12
|
-
* cached, real-bound copy). The second, after unmocking, drops the mocked instances so a later file
|
|
13
|
-
* re-imports the real modules instead of the mock left in the shared registry.
|
|
14
|
-
*/
|
|
15
|
-
export function scopeModuleMocks(mockedIds) {
|
|
16
|
-
beforeAll(() => {
|
|
17
|
-
vi.resetModules();
|
|
18
|
-
});
|
|
19
|
-
afterAll(() => {
|
|
20
|
-
for (const id of mockedIds)
|
|
21
|
-
vi.doUnmock(id);
|
|
22
|
-
vi.resetModules();
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=moduleMockTestHelper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"moduleMockTestHelper.js","sourceRoot":"","sources":["../src/moduleMockTestHelper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAEjD;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,gBAAgB,CAAC,SAA4B;IAC3D,SAAS,CAAC,GAAG,EAAE;QACb,EAAE,CAAC,YAAY,EAAE,CAAC;IACpB,CAAC,CAAC,CAAC;IACH,QAAQ,CAAC,GAAG,EAAE;QACZ,KAAK,MAAM,EAAE,IAAI,SAAS;YAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QAC5C,EAAE,CAAC,YAAY,EAAE,CAAC;IACpB,CAAC,CAAC,CAAC;AACL,CAAC"}
|