@react-three/test-renderer 9.1.0 → 9.1.1
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/CHANGELOG.md +482 -476
- package/README.md +61 -61
- package/dist/declarations/src/createTestInstance.d.ts +22 -22
- package/dist/declarations/src/helpers/waitFor.d.ts +5 -5
- package/dist/declarations/src/index.d.ts +14 -14
- package/dist/declarations/src/types/index.d.ts +1 -1
- package/dist/declarations/src/types/internal.d.ts +20 -20
- package/dist/declarations/src/types/public.d.ts +38 -38
- package/dist/react-three-test-renderer.cjs.dev.js +8 -7
- package/dist/react-three-test-renderer.cjs.prod.js +8 -7
- package/dist/react-three-test-renderer.esm.js +3 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
# React Three Test Renderer ⚛️🔼🧪
|
|
2
|
-
|
|
3
|
-
[](https://npmjs.com/package/@react-three/test-renderer)
|
|
4
|
-
[](https://npmjs.com/package/@react-three/test-renderer)
|
|
5
|
-
[](https://twitter.com/pmndrs)
|
|
6
|
-
[](https://twitter.com/_josh_ellis_)
|
|
7
|
-
[](https://discord.gg/ZZjjNvJ)
|
|
8
|
-
|
|
9
|
-
`@react-three/test-renderer` is a React testing <a href="https://reactjs.org/docs/codebase-overview.html#renderers">renderer</a> for threejs in node.
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
yarn add @react-three/fiber three
|
|
13
|
-
yarn add -D @react-three/test-renderer
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
---
|
|
17
|
-
|
|
18
|
-
## The problem
|
|
19
|
-
|
|
20
|
-
You've written a complex and amazing webgl experience using [`@react-three/fiber`](https://github.com/pmndrs/react-three-fiber) and you want to test it to make sure it works even after you add even more features.
|
|
21
|
-
|
|
22
|
-
You go to use `react-dom` but hang on, `THREE` elements aren't in the DOM! You decide to use `@react-three/test-renderer` you can see the container & the canvas but you can't see the tree for the scene!? That's because `@react-three/fiber` renders to a different react root with it's own reconciler.
|
|
23
|
-
|
|
24
|
-
## The solution
|
|
25
|
-
|
|
26
|
-
You use `@react-three/test-renderer` ⚛️-🔼-🧪, an experimental React renderer using `@react-three/fiber` under the hood to expose the scene graph wrapped in a test instance providing helpful utilities to test with.
|
|
27
|
-
|
|
28
|
-
Essentially, this package makes it easy to grab a snapshot of the Scene Graph rendered by `three` without the need for webgl & browser.
|
|
29
|
-
|
|
30
|
-
---
|
|
31
|
-
|
|
32
|
-
## Usage
|
|
33
|
-
|
|
34
|
-
RTTR is testing library agnostic, so we hope that it works with libraries such as [`jest`](https://jestjs.io/), [`jasmine`](https://jasmine.github.io/) etc.
|
|
35
|
-
|
|
36
|
-
```tsx
|
|
37
|
-
import ReactThreeTestRenderer from '@react-three/test-renderer'
|
|
38
|
-
|
|
39
|
-
const renderer = await ReactThreeTestRenderer.create(
|
|
40
|
-
<mesh>
|
|
41
|
-
<boxGeometry args={[2, 2]} />
|
|
42
|
-
<meshStandardMaterial
|
|
43
|
-
args={[
|
|
44
|
-
{
|
|
45
|
-
color: 0x0000ff,
|
|
46
|
-
},
|
|
47
|
-
]}
|
|
48
|
-
/>
|
|
49
|
-
</mesh>,
|
|
50
|
-
)
|
|
51
|
-
|
|
52
|
-
// assertions using the TestInstance & Scene Graph
|
|
53
|
-
console.log(renderer.toGraph())
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
---
|
|
57
|
-
|
|
58
|
-
## API
|
|
59
|
-
|
|
60
|
-
- [React Three Test Renderer API](/packages/test-renderer/markdown/rttr.md)
|
|
61
|
-
- [React Three Test Instance API](/packages/test-renderer/markdown/rttr-instance.md)
|
|
1
|
+
# React Three Test Renderer ⚛️🔼🧪
|
|
2
|
+
|
|
3
|
+
[](https://npmjs.com/package/@react-three/test-renderer)
|
|
4
|
+
[](https://npmjs.com/package/@react-three/test-renderer)
|
|
5
|
+
[](https://twitter.com/pmndrs)
|
|
6
|
+
[](https://twitter.com/_josh_ellis_)
|
|
7
|
+
[](https://discord.gg/ZZjjNvJ)
|
|
8
|
+
|
|
9
|
+
`@react-three/test-renderer` is a React testing <a href="https://reactjs.org/docs/codebase-overview.html#renderers">renderer</a> for threejs in node.
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
yarn add @react-three/fiber three
|
|
13
|
+
yarn add -D @react-three/test-renderer
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## The problem
|
|
19
|
+
|
|
20
|
+
You've written a complex and amazing webgl experience using [`@react-three/fiber`](https://github.com/pmndrs/react-three-fiber) and you want to test it to make sure it works even after you add even more features.
|
|
21
|
+
|
|
22
|
+
You go to use `react-dom` but hang on, `THREE` elements aren't in the DOM! You decide to use `@react-three/test-renderer` you can see the container & the canvas but you can't see the tree for the scene!? That's because `@react-three/fiber` renders to a different react root with it's own reconciler.
|
|
23
|
+
|
|
24
|
+
## The solution
|
|
25
|
+
|
|
26
|
+
You use `@react-three/test-renderer` ⚛️-🔼-🧪, an experimental React renderer using `@react-three/fiber` under the hood to expose the scene graph wrapped in a test instance providing helpful utilities to test with.
|
|
27
|
+
|
|
28
|
+
Essentially, this package makes it easy to grab a snapshot of the Scene Graph rendered by `three` without the need for webgl & browser.
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Usage
|
|
33
|
+
|
|
34
|
+
RTTR is testing library agnostic, so we hope that it works with libraries such as [`jest`](https://jestjs.io/), [`jasmine`](https://jasmine.github.io/) etc.
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
import ReactThreeTestRenderer from '@react-three/test-renderer'
|
|
38
|
+
|
|
39
|
+
const renderer = await ReactThreeTestRenderer.create(
|
|
40
|
+
<mesh>
|
|
41
|
+
<boxGeometry args={[2, 2]} />
|
|
42
|
+
<meshStandardMaterial
|
|
43
|
+
args={[
|
|
44
|
+
{
|
|
45
|
+
color: 0x0000ff,
|
|
46
|
+
},
|
|
47
|
+
]}
|
|
48
|
+
/>
|
|
49
|
+
</mesh>,
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
// assertions using the TestInstance & Scene Graph
|
|
53
|
+
console.log(renderer.toGraph())
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## API
|
|
59
|
+
|
|
60
|
+
- [React Three Test Renderer API](/packages/test-renderer/markdown/rttr.md)
|
|
61
|
+
- [React Three Test Instance API](/packages/test-renderer/markdown/rttr-instance.md)
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import type * as THREE from 'three';
|
|
2
|
-
import type { Instance } from '@react-three/fiber';
|
|
3
|
-
import type { Obj } from "./types/internal.js";
|
|
4
|
-
export declare class ReactThreeTestInstance<TObject extends THREE.Object3D = THREE.Object3D> {
|
|
5
|
-
_fiber: Instance<TObject>;
|
|
6
|
-
constructor(fiber: Instance<TObject>);
|
|
7
|
-
get fiber(): Instance<TObject>;
|
|
8
|
-
get instance(): TObject;
|
|
9
|
-
get type(): string;
|
|
10
|
-
get props(): Obj;
|
|
11
|
-
get parent(): ReactThreeTestInstance | null;
|
|
12
|
-
get children(): ReactThreeTestInstance[];
|
|
13
|
-
get allChildren(): ReactThreeTestInstance[];
|
|
14
|
-
private getChildren;
|
|
15
|
-
findAll: (decider: (node: ReactThreeTestInstance) => boolean) => ReactThreeTestInstance[];
|
|
16
|
-
find: (decider: (node: ReactThreeTestInstance) => boolean) => ReactThreeTestInstance;
|
|
17
|
-
findByType: (type: string) => ReactThreeTestInstance;
|
|
18
|
-
findAllByType: (type: string) => ReactThreeTestInstance[];
|
|
19
|
-
findByProps: (props: Obj) => ReactThreeTestInstance;
|
|
20
|
-
findAllByProps: (props: Obj) => ReactThreeTestInstance[];
|
|
21
|
-
}
|
|
22
|
-
export declare const wrapFiber: (fiber: Instance) => ReactThreeTestInstance;
|
|
1
|
+
import type * as THREE from 'three';
|
|
2
|
+
import type { Instance } from '@react-three/fiber';
|
|
3
|
+
import type { Obj } from "./types/internal.js";
|
|
4
|
+
export declare class ReactThreeTestInstance<TObject extends THREE.Object3D = THREE.Object3D> {
|
|
5
|
+
_fiber: Instance<TObject>;
|
|
6
|
+
constructor(fiber: Instance<TObject>);
|
|
7
|
+
get fiber(): Instance<TObject>;
|
|
8
|
+
get instance(): TObject;
|
|
9
|
+
get type(): string;
|
|
10
|
+
get props(): Obj;
|
|
11
|
+
get parent(): ReactThreeTestInstance | null;
|
|
12
|
+
get children(): ReactThreeTestInstance[];
|
|
13
|
+
get allChildren(): ReactThreeTestInstance[];
|
|
14
|
+
private getChildren;
|
|
15
|
+
findAll: (decider: (node: ReactThreeTestInstance) => boolean) => ReactThreeTestInstance[];
|
|
16
|
+
find: (decider: (node: ReactThreeTestInstance) => boolean) => ReactThreeTestInstance;
|
|
17
|
+
findByType: (type: string) => ReactThreeTestInstance;
|
|
18
|
+
findAllByType: (type: string) => ReactThreeTestInstance[];
|
|
19
|
+
findByProps: (props: Obj) => ReactThreeTestInstance;
|
|
20
|
+
findAllByProps: (props: Obj) => ReactThreeTestInstance[];
|
|
21
|
+
}
|
|
22
|
+
export declare const wrapFiber: (fiber: Instance) => ReactThreeTestInstance;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export interface WaitOptions {
|
|
2
|
-
interval?: number;
|
|
3
|
-
timeout?: number;
|
|
4
|
-
}
|
|
5
|
-
export declare function waitFor(callback: () => boolean | void, { interval, timeout }?: WaitOptions): Promise<void>;
|
|
1
|
+
export interface WaitOptions {
|
|
2
|
+
interval?: number;
|
|
3
|
+
timeout?: number;
|
|
4
|
+
}
|
|
5
|
+
export declare function waitFor(callback: () => boolean | void, { interval, timeout }?: WaitOptions): Promise<void>;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { act } from '
|
|
3
|
-
import type { CreateOptions, Renderer } from "./types/public.js";
|
|
4
|
-
import { waitFor, WaitOptions } from "./helpers/waitFor.js";
|
|
5
|
-
declare const create: (element: React.ReactNode, options?: Partial<CreateOptions>) => Promise<Renderer>;
|
|
6
|
-
export { create, act, waitFor };
|
|
7
|
-
export type { WaitOptions };
|
|
8
|
-
export * as ReactThreeTest from "./types/index.js";
|
|
9
|
-
declare const _default: {
|
|
10
|
-
create: (element: React.ReactNode, options?: Partial<CreateOptions> | undefined) => Promise<Renderer>;
|
|
11
|
-
act:
|
|
12
|
-
waitFor: typeof waitFor;
|
|
13
|
-
};
|
|
14
|
-
export default _default;
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { act } from 'react';
|
|
3
|
+
import type { CreateOptions, Renderer } from "./types/public.js";
|
|
4
|
+
import { waitFor, WaitOptions } from "./helpers/waitFor.js";
|
|
5
|
+
declare const create: (element: React.ReactNode, options?: Partial<CreateOptions>) => Promise<Renderer>;
|
|
6
|
+
export { create, act, waitFor };
|
|
7
|
+
export type { WaitOptions };
|
|
8
|
+
export * as ReactThreeTest from "./types/index.js";
|
|
9
|
+
declare const _default: {
|
|
10
|
+
create: (element: React.ReactNode, options?: Partial<CreateOptions> | undefined) => Promise<Renderer>;
|
|
11
|
+
act: typeof React.act;
|
|
12
|
+
waitFor: typeof waitFor;
|
|
13
|
+
};
|
|
14
|
+
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./public.js";
|
|
1
|
+
export * from "./public.js";
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
export type CreateCanvasParameters = {
|
|
2
|
-
beforeReturn?: (canvas: HTMLCanvasElement) => void;
|
|
3
|
-
width?: number;
|
|
4
|
-
height?: number;
|
|
5
|
-
};
|
|
6
|
-
export interface Obj {
|
|
7
|
-
[key: string]: any;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* this is an empty object of any,
|
|
11
|
-
* the data is passed to a new event
|
|
12
|
-
* and subsequently passed to the
|
|
13
|
-
* event handler you're calling
|
|
14
|
-
*/
|
|
15
|
-
export type MockEventData = {
|
|
16
|
-
[key: string]: any;
|
|
17
|
-
};
|
|
18
|
-
export interface TestInstanceChildOpts {
|
|
19
|
-
exhaustive: boolean;
|
|
20
|
-
}
|
|
1
|
+
export type CreateCanvasParameters = {
|
|
2
|
+
beforeReturn?: (canvas: HTMLCanvasElement) => void;
|
|
3
|
+
width?: number;
|
|
4
|
+
height?: number;
|
|
5
|
+
};
|
|
6
|
+
export interface Obj {
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* this is an empty object of any,
|
|
11
|
+
* the data is passed to a new event
|
|
12
|
+
* and subsequently passed to the
|
|
13
|
+
* event handler you're calling
|
|
14
|
+
*/
|
|
15
|
+
export type MockEventData = {
|
|
16
|
+
[key: string]: any;
|
|
17
|
+
};
|
|
18
|
+
export interface TestInstanceChildOpts {
|
|
19
|
+
exhaustive: boolean;
|
|
20
|
+
}
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import type { Camera, RenderProps } from '@react-three/fiber';
|
|
2
|
-
import { ReactThreeTestInstance } from "../createTestInstance.js";
|
|
3
|
-
import type { MockEventData, CreateCanvasParameters } from "./internal.js";
|
|
4
|
-
export { ReactThreeTestInstance };
|
|
5
|
-
export type MockSyntheticEvent = {
|
|
6
|
-
camera: Camera;
|
|
7
|
-
stopPropagation: () => void;
|
|
8
|
-
target: ReactThreeTestInstance;
|
|
9
|
-
currentTarget: ReactThreeTestInstance;
|
|
10
|
-
sourceEvent: MockEventData;
|
|
11
|
-
[key: string]: any;
|
|
12
|
-
};
|
|
13
|
-
export type CreateOptions = CreateCanvasParameters & RenderProps<HTMLCanvasElement>;
|
|
14
|
-
export type Renderer = {
|
|
15
|
-
scene: ReactThreeTestInstance;
|
|
16
|
-
unmount: () => Promise<void>;
|
|
17
|
-
getInstance: () => null | unknown;
|
|
18
|
-
update: (el: React.ReactNode) => Promise<void>;
|
|
19
|
-
toTree: () => Tree | undefined;
|
|
20
|
-
toGraph: () => SceneGraph | undefined;
|
|
21
|
-
fireEvent: (element: ReactThreeTestInstance, handler: string, data?: MockEventData) => Promise<any>;
|
|
22
|
-
advanceFrames: (frames: number, delta: number | number[]) => Promise<void>;
|
|
23
|
-
};
|
|
24
|
-
export interface SceneGraphItem {
|
|
25
|
-
type: string;
|
|
26
|
-
name: string;
|
|
27
|
-
children: SceneGraphItem[] | null;
|
|
28
|
-
}
|
|
29
|
-
export type SceneGraph = SceneGraphItem[];
|
|
30
|
-
export interface TreeNode {
|
|
31
|
-
type: string;
|
|
32
|
-
props: {
|
|
33
|
-
[key: string]: any;
|
|
34
|
-
};
|
|
35
|
-
children: TreeNode[];
|
|
36
|
-
}
|
|
37
|
-
export type Tree = TreeNode[];
|
|
38
|
-
export type { Act } from '@react-three/fiber';
|
|
1
|
+
import type { Camera, RenderProps } from '@react-three/fiber';
|
|
2
|
+
import { ReactThreeTestInstance } from "../createTestInstance.js";
|
|
3
|
+
import type { MockEventData, CreateCanvasParameters } from "./internal.js";
|
|
4
|
+
export { ReactThreeTestInstance };
|
|
5
|
+
export type MockSyntheticEvent = {
|
|
6
|
+
camera: Camera;
|
|
7
|
+
stopPropagation: () => void;
|
|
8
|
+
target: ReactThreeTestInstance;
|
|
9
|
+
currentTarget: ReactThreeTestInstance;
|
|
10
|
+
sourceEvent: MockEventData;
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
};
|
|
13
|
+
export type CreateOptions = CreateCanvasParameters & RenderProps<HTMLCanvasElement>;
|
|
14
|
+
export type Renderer = {
|
|
15
|
+
scene: ReactThreeTestInstance;
|
|
16
|
+
unmount: () => Promise<void>;
|
|
17
|
+
getInstance: () => null | unknown;
|
|
18
|
+
update: (el: React.ReactNode) => Promise<void>;
|
|
19
|
+
toTree: () => Tree | undefined;
|
|
20
|
+
toGraph: () => SceneGraph | undefined;
|
|
21
|
+
fireEvent: (element: ReactThreeTestInstance, handler: string, data?: MockEventData) => Promise<any>;
|
|
22
|
+
advanceFrames: (frames: number, delta: number | number[]) => Promise<void>;
|
|
23
|
+
};
|
|
24
|
+
export interface SceneGraphItem {
|
|
25
|
+
type: string;
|
|
26
|
+
name: string;
|
|
27
|
+
children: SceneGraphItem[] | null;
|
|
28
|
+
}
|
|
29
|
+
export type SceneGraph = SceneGraphItem[];
|
|
30
|
+
export interface TreeNode {
|
|
31
|
+
type: string;
|
|
32
|
+
props: {
|
|
33
|
+
[key: string]: any;
|
|
34
|
+
};
|
|
35
|
+
children: TreeNode[];
|
|
36
|
+
}
|
|
37
|
+
export type Tree = TreeNode[];
|
|
38
|
+
export type { Act } from '@react-three/fiber';
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var react = require('react');
|
|
5
6
|
var THREE = require('three');
|
|
6
7
|
var fiber = require('@react-three/fiber');
|
|
7
8
|
|
|
@@ -805,7 +806,7 @@ async function waitFor(callback, {
|
|
|
805
806
|
interval = 50,
|
|
806
807
|
timeout = 5000
|
|
807
808
|
} = {}) {
|
|
808
|
-
await
|
|
809
|
+
await react.act(async () => {
|
|
809
810
|
const start = performance.now();
|
|
810
811
|
while (true) {
|
|
811
812
|
const result = callback();
|
|
@@ -840,12 +841,12 @@ const create = async (element, options) => {
|
|
|
840
841
|
events: undefined
|
|
841
842
|
});
|
|
842
843
|
const _store = fiber._roots.get(canvas).store;
|
|
843
|
-
await
|
|
844
|
+
await react.act(async () => _root.render(element));
|
|
844
845
|
const _scene = _store.getState().scene.__r3f;
|
|
845
846
|
return {
|
|
846
847
|
scene: wrapFiber(_scene),
|
|
847
848
|
async unmount() {
|
|
848
|
-
await
|
|
849
|
+
await react.act(async () => {
|
|
849
850
|
_root.unmount();
|
|
850
851
|
});
|
|
851
852
|
},
|
|
@@ -867,7 +868,7 @@ const create = async (element, options) => {
|
|
|
867
868
|
},
|
|
868
869
|
async update(newElement) {
|
|
869
870
|
if (!fiber._roots.has(canvas)) return console.warn('RTTR: attempted to update an unmounted root!');
|
|
870
|
-
await
|
|
871
|
+
await react.act(async () => {
|
|
871
872
|
_root.render(newElement);
|
|
872
873
|
});
|
|
873
874
|
},
|
|
@@ -877,7 +878,7 @@ const create = async (element, options) => {
|
|
|
877
878
|
toGraph() {
|
|
878
879
|
return toGraph(_scene);
|
|
879
880
|
},
|
|
880
|
-
fireEvent: createEventFirer(
|
|
881
|
+
fireEvent: createEventFirer(react.act, _store),
|
|
881
882
|
async advanceFrames(frames, delta = 1) {
|
|
882
883
|
const state = _store.getState();
|
|
883
884
|
const storeSubscribers = state.internal.subscribers;
|
|
@@ -897,13 +898,13 @@ const create = async (element, options) => {
|
|
|
897
898
|
};
|
|
898
899
|
var index = {
|
|
899
900
|
create,
|
|
900
|
-
act:
|
|
901
|
+
act: react.act,
|
|
901
902
|
waitFor
|
|
902
903
|
};
|
|
903
904
|
|
|
904
905
|
Object.defineProperty(exports, 'act', {
|
|
905
906
|
enumerable: true,
|
|
906
|
-
get: function () { return
|
|
907
|
+
get: function () { return react.act; }
|
|
907
908
|
});
|
|
908
909
|
exports.ReactThreeTest = index$1;
|
|
909
910
|
exports.create = create;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var react = require('react');
|
|
5
6
|
var THREE = require('three');
|
|
6
7
|
var fiber = require('@react-three/fiber');
|
|
7
8
|
|
|
@@ -805,7 +806,7 @@ async function waitFor(callback, {
|
|
|
805
806
|
interval = 50,
|
|
806
807
|
timeout = 5000
|
|
807
808
|
} = {}) {
|
|
808
|
-
await
|
|
809
|
+
await react.act(async () => {
|
|
809
810
|
const start = performance.now();
|
|
810
811
|
while (true) {
|
|
811
812
|
const result = callback();
|
|
@@ -840,12 +841,12 @@ const create = async (element, options) => {
|
|
|
840
841
|
events: undefined
|
|
841
842
|
});
|
|
842
843
|
const _store = fiber._roots.get(canvas).store;
|
|
843
|
-
await
|
|
844
|
+
await react.act(async () => _root.render(element));
|
|
844
845
|
const _scene = _store.getState().scene.__r3f;
|
|
845
846
|
return {
|
|
846
847
|
scene: wrapFiber(_scene),
|
|
847
848
|
async unmount() {
|
|
848
|
-
await
|
|
849
|
+
await react.act(async () => {
|
|
849
850
|
_root.unmount();
|
|
850
851
|
});
|
|
851
852
|
},
|
|
@@ -867,7 +868,7 @@ const create = async (element, options) => {
|
|
|
867
868
|
},
|
|
868
869
|
async update(newElement) {
|
|
869
870
|
if (!fiber._roots.has(canvas)) return console.warn('RTTR: attempted to update an unmounted root!');
|
|
870
|
-
await
|
|
871
|
+
await react.act(async () => {
|
|
871
872
|
_root.render(newElement);
|
|
872
873
|
});
|
|
873
874
|
},
|
|
@@ -877,7 +878,7 @@ const create = async (element, options) => {
|
|
|
877
878
|
toGraph() {
|
|
878
879
|
return toGraph(_scene);
|
|
879
880
|
},
|
|
880
|
-
fireEvent: createEventFirer(
|
|
881
|
+
fireEvent: createEventFirer(react.act, _store),
|
|
881
882
|
async advanceFrames(frames, delta = 1) {
|
|
882
883
|
const state = _store.getState();
|
|
883
884
|
const storeSubscribers = state.internal.subscribers;
|
|
@@ -897,13 +898,13 @@ const create = async (element, options) => {
|
|
|
897
898
|
};
|
|
898
899
|
var index = {
|
|
899
900
|
create,
|
|
900
|
-
act:
|
|
901
|
+
act: react.act,
|
|
901
902
|
waitFor
|
|
902
903
|
};
|
|
903
904
|
|
|
904
905
|
Object.defineProperty(exports, 'act', {
|
|
905
906
|
enumerable: true,
|
|
906
|
-
get: function () { return
|
|
907
|
+
get: function () { return react.act; }
|
|
907
908
|
});
|
|
908
909
|
exports.ReactThreeTest = index$1;
|
|
909
910
|
exports.create = create;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { act } from 'react';
|
|
2
|
+
export { act } from 'react';
|
|
1
3
|
import * as THREE from 'three';
|
|
2
|
-
import {
|
|
3
|
-
export { act } from '@react-three/fiber';
|
|
4
|
+
import { extend, createRoot, _roots, reconciler } from '@react-three/fiber';
|
|
4
5
|
|
|
5
6
|
const lowerCaseFirstLetter = str => `${str.charAt(0).toLowerCase()}${str.slice(1)}`;
|
|
6
7
|
const toEventHandlerName = eventName => `on${eventName.charAt(0).toUpperCase()}${eventName.slice(1)}`;
|