@react-three/test-renderer 10.0.0-canary.d46ab63 → 10.0.0-canary.d8aec34

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/README.md CHANGED
@@ -36,7 +36,6 @@ Choose the entry point that matches your `@react-three/fiber` import:
36
36
  | --------------------------- | ----------------------------------- | ------------------------------------ |
37
37
  | `@react-three/fiber` | `@react-three/test-renderer` | Default (WebGPU, mocked GPU context) |
38
38
  | `@react-three/fiber/legacy` | `@react-three/test-renderer/legacy` | WebGL only |
39
- | `@react-three/fiber/webgpu` | `@react-three/test-renderer/webgpu` | WebGPU, with the mocked GPU context |
40
39
 
41
40
  Whichever entry you pick, the root resolves JSX elements from the three namespace of the renderer it loads, exactly as in the app: node materials exist under WebGPU and not under WebGL.
42
41
 
@@ -74,15 +73,16 @@ import { Canvas } from '@react-three/fiber/legacy'
74
73
  const renderer = await ReactThreeTestRenderer.create(<MyScene />)
75
74
  ```
76
75
 
77
- ### WebGPU Entry
76
+ ### TSL (Three Shading Language)
78
77
 
79
- For applications using WebGPU with TSL (Three Shading Language):
78
+ The default entry renders with `WebGPURenderer`, so node materials and the TSL hooks work without
79
+ any setup. It replaces `@react-three/test-renderer/webgpu`, which is removed.
80
80
 
81
81
  ```tsx
82
- import ReactThreeTestRenderer from '@react-three/test-renderer/webgpu'
83
- import { Canvas } from '@react-three/fiber/webgpu'
82
+ import ReactThreeTestRenderer from '@react-three/test-renderer'
83
+ import { color } from 'three/tsl'
84
84
  // The TSL hooks come from @react-three/tsl, in tests as in app code
85
- import { useUniform, useUniforms, useNodes, useLocalNodes } from '@react-three/tsl'
85
+ import { useUniforms, useNodes } from '@react-three/tsl'
86
86
 
87
87
  // Component using WebGPU hooks
88
88
  function MyWebGPUScene() {
@@ -133,12 +133,12 @@ console.log(renderer.toGraph())
133
133
 
134
134
  ## Testing WebGPU Hooks
135
135
 
136
- The `/webgpu` entry exports all WebGPU-specific hooks for testing TSL uniforms and nodes:
136
+ Test TSL uniforms and nodes with the default entry and the hooks from `@react-three/tsl`:
137
137
 
138
138
  ```tsx
139
- import ReactThreeTestRenderer from '@react-three/test-renderer/webgpu'
140
- import { useThree } from '@react-three/fiber/webgpu'
141
- import { useUniform, useUniforms, useNodes, useLocalNodes } from '@react-three/tsl'
139
+ import ReactThreeTestRenderer from '@react-three/test-renderer'
140
+ import { color } from 'three/tsl'
141
+ import { useUniforms, useNodes } from '@react-three/tsl'
142
142
 
143
143
  describe('My WebGPU Scene', () => {
144
144
  it('should create and use uniforms', async () => {
@@ -188,23 +188,15 @@ describe('My WebGPU Scene', () => {
188
188
 
189
189
  ---
190
190
 
191
- ## Migration from v8
191
+ ## Upgrading from v9
192
192
 
193
- If you're upgrading from v8 and using WebGPU features:
193
+ v9 had one entry, which rendered with WebGL. In v10 the default entry renders with WebGPU, to match
194
+ `@react-three/fiber`. If your app imports `Canvas` from `@react-three/fiber/legacy`, test with the
195
+ `/legacy` entry:
194
196
 
195
197
  ```diff
196
- // Before (v8) - single entry point
197
198
  -import ReactThreeTestRenderer from '@react-three/test-renderer'
198
-
199
- // After (v9+) - choose matching entry
200
- // For WebGPU apps:
201
- +import ReactThreeTestRenderer from '@react-three/test-renderer/webgpu'
202
-
203
- // For legacy WebGL apps:
204
199
  +import ReactThreeTestRenderer from '@react-three/test-renderer/legacy'
205
-
206
- // For default (auto-detection):
207
- +import ReactThreeTestRenderer from '@react-three/test-renderer'
208
200
  ```
209
201
 
210
202
  ---
@@ -213,4 +205,4 @@ If you're upgrading from v8 and using WebGPU features:
213
205
 
214
206
  - [React Three Test Renderer API](./markdown/rttr.md)
215
207
  - [React Three Test Instance API](./markdown/rttr-instance.md)
216
- - [WebGPU Testing Guide](./markdown/webgpu-testing.md)
208
+ - [Testing WebGPU and TSL](https://r3f.docs.pmnd.rs/next/api/testing#testing-webgpu-and-tsl)
package/dist/index.cjs CHANGED
@@ -387,6 +387,16 @@ function mockWebGPU() {
387
387
  ALL: 15
388
388
  };
389
389
  }
390
+ function unmockWebGPU() {
391
+ if (typeof globalThis.navigator !== "undefined") {
392
+ delete globalThis.navigator.gpu;
393
+ }
394
+ delete globalThis.GPUTextureUsage;
395
+ delete globalThis.GPUBufferUsage;
396
+ delete globalThis.GPUMapMode;
397
+ delete globalThis.GPUShaderStage;
398
+ delete globalThis.GPUColorWrite;
399
+ }
390
400
 
391
401
  const lowerCaseFirstLetter = (str) => `${str.charAt(0).toLowerCase()}${str.slice(1)}`;
392
402
  const toEventHandlerName = (eventName) => `on${eventName.charAt(0).toUpperCase()}${eventName.slice(1)}`;
@@ -1566,4 +1576,6 @@ exports.act = react.act;
1566
1576
  exports.ReactThreeTest = index$1;
1567
1577
  exports.create = create;
1568
1578
  exports.default = index;
1579
+ exports.mockWebGPU = mockWebGPU;
1580
+ exports.unmockWebGPU = unmockWebGPU;
1569
1581
  exports.waitFor = waitFor;
package/dist/index.d.cts CHANGED
@@ -88,6 +88,16 @@ interface WaitOptions {
88
88
  }
89
89
  declare function waitFor(callback: () => boolean | void, { interval, timeout }?: WaitOptions): Promise<void>;
90
90
 
91
+ /**
92
+ * Installs WebGPU mocks into the global scope
93
+ * Call this before running tests that use WebGPU
94
+ */
95
+ declare function mockWebGPU(): void;
96
+ /**
97
+ * Removes WebGPU mocks from the global scope
98
+ */
99
+ declare function unmockWebGPU(): void;
100
+
91
101
  declare const index_Act: typeof Act;
92
102
  type index_CreateOptions = CreateOptions;
93
103
  type index_MockSyntheticEvent = MockSyntheticEvent;
@@ -113,5 +123,5 @@ declare const _default: {
113
123
 
114
124
  // @ts-ignore
115
125
  export = _default;
116
- export { index as ReactThreeTest, create, waitFor };
126
+ export { index as ReactThreeTest, create, mockWebGPU, unmockWebGPU, waitFor };
117
127
  export type { WaitOptions };
package/dist/index.d.mts CHANGED
@@ -88,6 +88,16 @@ interface WaitOptions {
88
88
  }
89
89
  declare function waitFor(callback: () => boolean | void, { interval, timeout }?: WaitOptions): Promise<void>;
90
90
 
91
+ /**
92
+ * Installs WebGPU mocks into the global scope
93
+ * Call this before running tests that use WebGPU
94
+ */
95
+ declare function mockWebGPU(): void;
96
+ /**
97
+ * Removes WebGPU mocks from the global scope
98
+ */
99
+ declare function unmockWebGPU(): void;
100
+
91
101
  declare const index_Act: typeof Act;
92
102
  type index_CreateOptions = CreateOptions;
93
103
  type index_MockSyntheticEvent = MockSyntheticEvent;
@@ -111,5 +121,5 @@ declare const _default: {
111
121
  waitFor: typeof waitFor;
112
122
  };
113
123
 
114
- export { index as ReactThreeTest, create, _default as default, waitFor };
124
+ export { index as ReactThreeTest, create, _default as default, mockWebGPU, unmockWebGPU, waitFor };
115
125
  export type { WaitOptions };
package/dist/index.d.ts CHANGED
@@ -88,6 +88,16 @@ interface WaitOptions {
88
88
  }
89
89
  declare function waitFor(callback: () => boolean | void, { interval, timeout }?: WaitOptions): Promise<void>;
90
90
 
91
+ /**
92
+ * Installs WebGPU mocks into the global scope
93
+ * Call this before running tests that use WebGPU
94
+ */
95
+ declare function mockWebGPU(): void;
96
+ /**
97
+ * Removes WebGPU mocks from the global scope
98
+ */
99
+ declare function unmockWebGPU(): void;
100
+
91
101
  declare const index_Act: typeof Act;
92
102
  type index_CreateOptions = CreateOptions;
93
103
  type index_MockSyntheticEvent = MockSyntheticEvent;
@@ -113,5 +123,5 @@ declare const _default: {
113
123
 
114
124
  // @ts-ignore
115
125
  export = _default;
116
- export { index as ReactThreeTest, create, waitFor };
126
+ export { index as ReactThreeTest, create, mockWebGPU, unmockWebGPU, waitFor };
117
127
  export type { WaitOptions };
package/dist/index.mjs CHANGED
@@ -384,6 +384,16 @@ function mockWebGPU() {
384
384
  ALL: 15
385
385
  };
386
386
  }
387
+ function unmockWebGPU() {
388
+ if (typeof globalThis.navigator !== "undefined") {
389
+ delete globalThis.navigator.gpu;
390
+ }
391
+ delete globalThis.GPUTextureUsage;
392
+ delete globalThis.GPUBufferUsage;
393
+ delete globalThis.GPUMapMode;
394
+ delete globalThis.GPUShaderStage;
395
+ delete globalThis.GPUColorWrite;
396
+ }
387
397
 
388
398
  const lowerCaseFirstLetter = (str) => `${str.charAt(0).toLowerCase()}${str.slice(1)}`;
389
399
  const toEventHandlerName = (eventName) => `on${eventName.charAt(0).toUpperCase()}${eventName.slice(1)}`;
@@ -1559,4 +1569,4 @@ const renderer = createTestRenderer({
1559
1569
  const { create } = renderer;
1560
1570
  const index = { create, act, waitFor };
1561
1571
 
1562
- export { index$1 as ReactThreeTest, create, index as default, waitFor };
1572
+ export { index$1 as ReactThreeTest, create, index as default, mockWebGPU, unmockWebGPU, waitFor };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-three/test-renderer",
3
- "version": "10.0.0-canary.d46ab63",
3
+ "version": "10.0.0-canary.d8aec34",
4
4
  "description": "Test Renderer for react-three-fiber",
5
5
  "author": "Josh Ellis",
6
6
  "license": "MIT",
@@ -19,11 +19,6 @@
19
19
  "import": "./dist/legacy.mjs",
20
20
  "require": "./dist/legacy.cjs"
21
21
  },
22
- "./webgpu": {
23
- "types": "./dist/webgpu/index.d.ts",
24
- "import": "./dist/webgpu/index.mjs",
25
- "require": "./dist/webgpu/index.cjs"
26
- },
27
22
  "./package.json": "./package.json"
28
23
  },
29
24
  "bugs": {
@@ -47,8 +42,8 @@
47
42
  "devDependencies": {
48
43
  "@webgpu/types": "^0.1.64",
49
44
  "three": ">=0.185.0",
50
- "@react-three/fiber": "10.0.0-canary.d46ab63",
51
- "@react-three/tsl": "10.0.0-canary.d46ab63"
45
+ "@react-three/tsl": "10.0.0-canary.d8aec34",
46
+ "@react-three/fiber": "10.0.0-canary.d8aec34"
52
47
  },
53
48
  "files": [
54
49
  "dist",