@quake2ts/test-utils 0.0.851 → 0.0.852
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/index.cjs +7 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/package.json +9 -9
- package/src/setup/webgpu.ts +16 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quake2ts/test-utils",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.852",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -55,10 +55,10 @@
|
|
|
55
55
|
"serve-handler": "^6.1.6",
|
|
56
56
|
"vitest": "^1.6.0",
|
|
57
57
|
"webgpu": "^0.3.8",
|
|
58
|
-
"@quake2ts/engine": "^0.0.
|
|
59
|
-
"@quake2ts/game": "0.0.
|
|
60
|
-
"@quake2ts/server": "0.0.
|
|
61
|
-
"@quake2ts/shared": "0.0.
|
|
58
|
+
"@quake2ts/engine": "^0.0.852",
|
|
59
|
+
"@quake2ts/game": "0.0.852",
|
|
60
|
+
"@quake2ts/server": "0.0.852",
|
|
61
|
+
"@quake2ts/shared": "0.0.852"
|
|
62
62
|
},
|
|
63
63
|
"peerDependenciesMeta": {
|
|
64
64
|
"@quake2ts/engine": {
|
|
@@ -114,10 +114,10 @@
|
|
|
114
114
|
"typescript": "^5.9.3",
|
|
115
115
|
"vitest": "^4.0.16",
|
|
116
116
|
"webgpu": "^0.3.8",
|
|
117
|
-
"@quake2ts/engine": "^0.0.
|
|
118
|
-
"@quake2ts/
|
|
119
|
-
"@quake2ts/
|
|
120
|
-
"@quake2ts/
|
|
117
|
+
"@quake2ts/engine": "^0.0.852",
|
|
118
|
+
"@quake2ts/server": "0.0.852",
|
|
119
|
+
"@quake2ts/shared": "0.0.852",
|
|
120
|
+
"@quake2ts/game": "0.0.852"
|
|
121
121
|
},
|
|
122
122
|
"dependencies": {
|
|
123
123
|
"upng-js": "^2.1.0"
|
package/src/setup/webgpu.ts
CHANGED
|
@@ -14,17 +14,13 @@ export interface WebGPUContextState {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* Setup the Headless WebGPU environment (globals, navigator.gpu) without creating a device.
|
|
18
|
+
* Use this when tests create their own devices.
|
|
18
19
|
*/
|
|
19
|
-
export async function
|
|
20
|
-
options?: {
|
|
21
|
-
powerPreference?: 'low-power' | 'high-performance';
|
|
22
|
-
requiredFeatures?: GPUFeatureName[];
|
|
23
|
-
}
|
|
24
|
-
): Promise<HeadlessWebGPUSetup> {
|
|
20
|
+
export async function setupHeadlessWebGPUEnv(): Promise<void> {
|
|
25
21
|
// Check if we are in Node.js environment
|
|
26
22
|
if (typeof process === 'undefined' || process.release?.name !== 'node') {
|
|
27
|
-
throw new Error('
|
|
23
|
+
throw new Error('setupHeadlessWebGPUEnv should only be called in a Node.js environment');
|
|
28
24
|
}
|
|
29
25
|
|
|
30
26
|
// Dynamic import to avoid hard dependency
|
|
@@ -68,6 +64,18 @@ export async function initHeadlessWebGPU(
|
|
|
68
64
|
// Also inject other globals like GPUAdapter, GPUDevice etc.
|
|
69
65
|
Object.assign(globalThis, globals);
|
|
70
66
|
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Initialize WebGPU in a headless Node.js environment using @webgpu/dawn (via webgpu package)
|
|
71
|
+
*/
|
|
72
|
+
export async function initHeadlessWebGPU(
|
|
73
|
+
options?: {
|
|
74
|
+
powerPreference?: 'low-power' | 'high-performance';
|
|
75
|
+
requiredFeatures?: GPUFeatureName[];
|
|
76
|
+
}
|
|
77
|
+
): Promise<HeadlessWebGPUSetup> {
|
|
78
|
+
await setupHeadlessWebGPUEnv();
|
|
71
79
|
|
|
72
80
|
// Request Adapter
|
|
73
81
|
const adapter = await navigator.gpu.requestAdapter({
|