@react-three/test-renderer 8.1.5 → 8.2.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 +12 -0
- package/dist/declarations/src/WebGL2RenderingContext.d.ts +16 -16
- package/dist/declarations/src/createTestCanvas.d.ts +2 -2
- package/dist/declarations/src/createTestInstance.d.ts +20 -20
- package/dist/declarations/src/fireEvent.d.ts +4 -4
- package/dist/declarations/src/helpers/graph.d.ts +3 -3
- package/dist/declarations/src/helpers/is.d.ts +9 -9
- package/dist/declarations/src/helpers/strings.d.ts +2 -2
- package/dist/declarations/src/helpers/testInstance.d.ts +5 -5
- package/dist/declarations/src/helpers/tree.d.ts +3 -3
- package/dist/declarations/src/helpers/waitFor.d.ts +5 -0
- package/dist/declarations/src/index.d.ts +14 -10
- package/dist/declarations/src/types/index.d.ts +1 -1
- package/dist/declarations/src/types/internal.d.ts +37 -31
- package/dist/declarations/src/types/public.d.ts +38 -39
- package/dist/react-three-test-renderer.cjs.dev.js +30 -1
- package/dist/react-three-test-renderer.cjs.prod.js +30 -1
- package/dist/react-three-test-renderer.esm.js +31 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
export declare class WebGL2RenderingContext {
|
|
2
|
-
[key: string]: any;
|
|
3
|
-
constructor(canvas: HTMLCanvasElement);
|
|
4
|
-
getShaderPrecisionFormat: () => {
|
|
5
|
-
rangeMin: number;
|
|
6
|
-
rangeMax: number;
|
|
7
|
-
precision: number;
|
|
8
|
-
};
|
|
9
|
-
private GL_VERSION;
|
|
10
|
-
private SCISSOR_BOX;
|
|
11
|
-
private VIEWPORT;
|
|
12
|
-
getParameter(paramId: number): string[] | number[] | undefined;
|
|
13
|
-
getExtension(ext: string): any;
|
|
14
|
-
getProgramInfoLog: () => string;
|
|
15
|
-
getShaderInfoLog: () => string;
|
|
16
|
-
}
|
|
1
|
+
export declare class WebGL2RenderingContext {
|
|
2
|
+
[key: string]: any;
|
|
3
|
+
constructor(canvas: HTMLCanvasElement);
|
|
4
|
+
getShaderPrecisionFormat: () => {
|
|
5
|
+
rangeMin: number;
|
|
6
|
+
rangeMax: number;
|
|
7
|
+
precision: number;
|
|
8
|
+
};
|
|
9
|
+
private GL_VERSION;
|
|
10
|
+
private SCISSOR_BOX;
|
|
11
|
+
private VIEWPORT;
|
|
12
|
+
getParameter(paramId: number): string[] | number[] | undefined;
|
|
13
|
+
getExtension(ext: string): any;
|
|
14
|
+
getProgramInfoLog: () => string;
|
|
15
|
+
getShaderInfoLog: () => string;
|
|
16
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { CreateCanvasParameters } from './types/internal';
|
|
2
|
-
export declare const createCanvas: ({ beforeReturn, width, height }?: CreateCanvasParameters) => HTMLCanvasElement;
|
|
1
|
+
import type { CreateCanvasParameters } from './types/internal';
|
|
2
|
+
export declare const createCanvas: ({ beforeReturn, width, height }?: CreateCanvasParameters) => HTMLCanvasElement;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { Object3D } from 'three';
|
|
2
|
-
import type { MockInstance, MockScene, Obj } from './types/internal';
|
|
3
|
-
export declare class ReactThreeTestInstance<TInstance extends Object3D = Object3D> {
|
|
4
|
-
_fiber: MockInstance;
|
|
5
|
-
constructor(fiber: MockInstance | MockScene);
|
|
6
|
-
get instance(): Object3D;
|
|
7
|
-
get type(): string;
|
|
8
|
-
get props(): Obj;
|
|
9
|
-
get parent(): ReactThreeTestInstance | null;
|
|
10
|
-
get children(): ReactThreeTestInstance[];
|
|
11
|
-
get allChildren(): ReactThreeTestInstance[];
|
|
12
|
-
private getChildren;
|
|
13
|
-
find: (decider: (node: ReactThreeTestInstance) => boolean) => ReactThreeTestInstance;
|
|
14
|
-
findAll: (decider: (node: ReactThreeTestInstance) => boolean) => ReactThreeTestInstance[];
|
|
15
|
-
findByType: (type: string) => ReactThreeTestInstance;
|
|
16
|
-
findAllByType: (type: string) => ReactThreeTestInstance[];
|
|
17
|
-
findByProps: (props: Obj) => ReactThreeTestInstance;
|
|
18
|
-
findAllByProps: (props: Obj) => ReactThreeTestInstance[];
|
|
19
|
-
}
|
|
20
|
-
export declare const wrapFiber: (fiber: MockInstance | MockScene) => ReactThreeTestInstance;
|
|
1
|
+
import { Object3D } from 'three';
|
|
2
|
+
import type { MockInstance, MockScene, Obj } from './types/internal';
|
|
3
|
+
export declare class ReactThreeTestInstance<TInstance extends Object3D = Object3D> {
|
|
4
|
+
_fiber: MockInstance;
|
|
5
|
+
constructor(fiber: MockInstance | MockScene);
|
|
6
|
+
get instance(): Object3D;
|
|
7
|
+
get type(): string;
|
|
8
|
+
get props(): Obj;
|
|
9
|
+
get parent(): ReactThreeTestInstance | null;
|
|
10
|
+
get children(): ReactThreeTestInstance[];
|
|
11
|
+
get allChildren(): ReactThreeTestInstance[];
|
|
12
|
+
private getChildren;
|
|
13
|
+
find: (decider: (node: ReactThreeTestInstance) => boolean) => ReactThreeTestInstance;
|
|
14
|
+
findAll: (decider: (node: ReactThreeTestInstance) => boolean) => ReactThreeTestInstance[];
|
|
15
|
+
findByType: (type: string) => ReactThreeTestInstance;
|
|
16
|
+
findAllByType: (type: string) => ReactThreeTestInstance[];
|
|
17
|
+
findByProps: (props: Obj) => ReactThreeTestInstance;
|
|
18
|
+
findAllByProps: (props: Obj) => ReactThreeTestInstance[];
|
|
19
|
+
}
|
|
20
|
+
export declare const wrapFiber: (fiber: MockInstance | MockScene) => ReactThreeTestInstance;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import ReactReconciler from 'react-reconciler';
|
|
2
|
-
import { ReactThreeTestInstance } from './createTestInstance';
|
|
3
|
-
import type { MockUseStoreState, MockEventData } from './types/internal';
|
|
4
|
-
export declare const createEventFirer: (act: ReactReconciler.Reconciler<unknown, unknown, unknown, unknown, unknown>['act'], store: MockUseStoreState) => (element: ReactThreeTestInstance, eventName: string, data?: MockEventData) => Promise<any>;
|
|
1
|
+
import ReactReconciler from 'react-reconciler';
|
|
2
|
+
import { ReactThreeTestInstance } from './createTestInstance';
|
|
3
|
+
import type { MockUseStoreState, MockEventData } from './types/internal';
|
|
4
|
+
export declare const createEventFirer: (act: ReactReconciler.Reconciler<unknown, unknown, unknown, unknown, unknown>['act'], store: MockUseStoreState) => (element: ReactThreeTestInstance, eventName: string, data?: MockEventData) => Promise<any>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { MockScene, MockSceneChild } from '../types/internal';
|
|
2
|
-
import type { SceneGraphItem } from '../types/public';
|
|
3
|
-
export declare const toGraph: (object: MockScene | MockSceneChild) => SceneGraphItem[];
|
|
1
|
+
import type { MockScene, MockSceneChild } from '../types/internal';
|
|
2
|
+
import type { SceneGraphItem } from '../types/public';
|
|
3
|
+
export declare const toGraph: (object: MockScene | MockSceneChild) => SceneGraphItem[];
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export declare const is: {
|
|
2
|
-
obj: (a: any) => boolean;
|
|
3
|
-
fun: (a: any) => boolean;
|
|
4
|
-
str: (a: any) => boolean;
|
|
5
|
-
num: (a: any) => boolean;
|
|
6
|
-
und: (a: any) => boolean;
|
|
7
|
-
arr: (a: any) => boolean;
|
|
8
|
-
equ(a: any, b: any): boolean;
|
|
9
|
-
};
|
|
1
|
+
export declare const is: {
|
|
2
|
+
obj: (a: any) => boolean;
|
|
3
|
+
fun: (a: any) => boolean;
|
|
4
|
+
str: (a: any) => boolean;
|
|
5
|
+
num: (a: any) => boolean;
|
|
6
|
+
und: (a: any) => boolean;
|
|
7
|
+
arr: (a: any) => boolean;
|
|
8
|
+
equ(a: any, b: any): boolean;
|
|
9
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const lowerCaseFirstLetter: (str: string) => string;
|
|
2
|
-
export declare const toEventHandlerName: (eventName: string) => string;
|
|
1
|
+
export declare const lowerCaseFirstLetter: (str: string) => string;
|
|
2
|
+
export declare const toEventHandlerName: (eventName: string) => string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ReactThreeTestInstance } from '../createTestInstance';
|
|
2
|
-
import type { Obj } from '../types/internal';
|
|
3
|
-
export declare const expectOne: <TItem>(items: TItem[], msg: string) => TItem;
|
|
4
|
-
export declare const matchProps: (props: Obj, filter: Obj) => boolean;
|
|
5
|
-
export declare const findAll: (root: ReactThreeTestInstance, decider: (node: ReactThreeTestInstance) => boolean) => ReactThreeTestInstance<import("three").Object3D<import("three").Event>>[];
|
|
1
|
+
import { ReactThreeTestInstance } from '../createTestInstance';
|
|
2
|
+
import type { Obj } from '../types/internal';
|
|
3
|
+
export declare const expectOne: <TItem>(items: TItem[], msg: string) => TItem;
|
|
4
|
+
export declare const matchProps: (props: Obj, filter: Obj) => boolean;
|
|
5
|
+
export declare const findAll: (root: ReactThreeTestInstance, decider: (node: ReactThreeTestInstance) => boolean) => ReactThreeTestInstance<import("three").Object3D<import("three").Event>>[];
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { Tree } from '../types/public';
|
|
2
|
-
import type { MockScene } from '../types/internal';
|
|
3
|
-
export declare const toTree: (root: MockScene) => Tree;
|
|
1
|
+
import type { Tree } from '../types/public';
|
|
2
|
+
import type { MockScene } from '../types/internal';
|
|
3
|
+
export declare const toTree: (root: MockScene) => Tree;
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import type { CreateOptions, Renderer, Act } from './types/public';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { CreateOptions, Renderer, Act } from './types/public';
|
|
3
|
+
import { waitFor, WaitOptions } from './helpers/waitFor';
|
|
4
|
+
declare const act: Act;
|
|
5
|
+
declare const create: (element: React.ReactNode, options?: Partial<CreateOptions> | undefined) => Promise<Renderer>;
|
|
6
|
+
export { create, act, waitFor };
|
|
7
|
+
export type { WaitOptions };
|
|
8
|
+
export * as ReactThreeTest from './types';
|
|
9
|
+
declare const _default: {
|
|
10
|
+
create: (element: React.ReactNode, options?: Partial<CreateOptions> | undefined) => Promise<Renderer>;
|
|
11
|
+
act: Act;
|
|
12
|
+
waitFor: typeof waitFor;
|
|
13
|
+
};
|
|
14
|
+
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './public';
|
|
1
|
+
export * from './public';
|
|
@@ -1,31 +1,37 @@
|
|
|
1
|
-
import * as THREE from 'three';
|
|
2
|
-
import { UseBoundStore } from 'zustand';
|
|
3
|
-
import type { BaseInstance, LocalState, RootState } from '@react-three/fiber';
|
|
4
|
-
export declare type MockUseStoreState = UseBoundStore<RootState>;
|
|
5
|
-
export interface MockInstance extends Omit<BaseInstance, '__r3f'> {
|
|
6
|
-
__r3f: Omit<LocalState, 'root' | 'objects' | 'parent'> & {
|
|
7
|
-
root: MockUseStoreState;
|
|
8
|
-
objects: MockSceneChild[];
|
|
9
|
-
parent: MockInstance;
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
export interface MockSceneChild extends Omit<MockInstance, 'children'> {
|
|
13
|
-
children: MockSceneChild[];
|
|
14
|
-
}
|
|
15
|
-
export interface MockScene extends Omit<THREE.Scene, 'children'>, Pick<MockInstance, '__r3f'> {
|
|
16
|
-
children: MockSceneChild[];
|
|
17
|
-
}
|
|
18
|
-
export declare type CreateCanvasParameters = {
|
|
19
|
-
beforeReturn?: (canvas: HTMLCanvasElement) => void;
|
|
20
|
-
width?: number;
|
|
21
|
-
height?: number;
|
|
22
|
-
};
|
|
23
|
-
export interface Obj {
|
|
24
|
-
[key: string]: any;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { UseBoundStore } from 'zustand';
|
|
3
|
+
import type { BaseInstance, LocalState, RootState } from '@react-three/fiber';
|
|
4
|
+
export declare type MockUseStoreState = UseBoundStore<RootState>;
|
|
5
|
+
export interface MockInstance extends Omit<BaseInstance, '__r3f'> {
|
|
6
|
+
__r3f: Omit<LocalState, 'root' | 'objects' | 'parent'> & {
|
|
7
|
+
root: MockUseStoreState;
|
|
8
|
+
objects: MockSceneChild[];
|
|
9
|
+
parent: MockInstance;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export interface MockSceneChild extends Omit<MockInstance, 'children'> {
|
|
13
|
+
children: MockSceneChild[];
|
|
14
|
+
}
|
|
15
|
+
export interface MockScene extends Omit<THREE.Scene, 'children'>, Pick<MockInstance, '__r3f'> {
|
|
16
|
+
children: MockSceneChild[];
|
|
17
|
+
}
|
|
18
|
+
export declare type CreateCanvasParameters = {
|
|
19
|
+
beforeReturn?: (canvas: HTMLCanvasElement) => void;
|
|
20
|
+
width?: number;
|
|
21
|
+
height?: number;
|
|
22
|
+
};
|
|
23
|
+
export interface Obj {
|
|
24
|
+
[key: string]: any;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* this is an empty object of any,
|
|
28
|
+
* the data is passed to a new event
|
|
29
|
+
* and subsequently passed to the
|
|
30
|
+
* event handler you're calling
|
|
31
|
+
*/
|
|
32
|
+
export declare type MockEventData = {
|
|
33
|
+
[key: string]: any;
|
|
34
|
+
};
|
|
35
|
+
export interface TestInstanceChildOpts {
|
|
36
|
+
exhaustive: boolean;
|
|
37
|
+
}
|
|
@@ -1,39 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export declare type
|
|
15
|
-
export declare type
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
export
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
export declare type Tree = TreeNode[];
|
|
1
|
+
import type { Camera, RenderProps } from '@react-three/fiber';
|
|
2
|
+
import { ReactThreeTestInstance } from '../createTestInstance';
|
|
3
|
+
import type { MockEventData, CreateCanvasParameters } from './internal';
|
|
4
|
+
export { ReactThreeTestInstance };
|
|
5
|
+
export declare type MockSyntheticEvent = {
|
|
6
|
+
camera: Camera;
|
|
7
|
+
stopPropagation: () => void;
|
|
8
|
+
target: ReactThreeTestInstance;
|
|
9
|
+
currentTarget: ReactThreeTestInstance;
|
|
10
|
+
sourceEvent: MockEventData;
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
};
|
|
13
|
+
export declare type CreateOptions = CreateCanvasParameters & RenderProps<HTMLCanvasElement>;
|
|
14
|
+
export declare type Act = (cb: () => Promise<any>) => Promise<any>;
|
|
15
|
+
export declare type Renderer = {
|
|
16
|
+
scene: ReactThreeTestInstance;
|
|
17
|
+
unmount: () => Promise<void>;
|
|
18
|
+
getInstance: () => null | unknown;
|
|
19
|
+
update: (el: React.ReactNode) => Promise<void>;
|
|
20
|
+
toTree: () => Tree | undefined;
|
|
21
|
+
toGraph: () => SceneGraph | undefined;
|
|
22
|
+
fireEvent: (element: ReactThreeTestInstance, handler: string, data?: MockEventData) => Promise<any>;
|
|
23
|
+
advanceFrames: (frames: number, delta: number | number[]) => Promise<void>;
|
|
24
|
+
};
|
|
25
|
+
export interface SceneGraphItem {
|
|
26
|
+
type: string;
|
|
27
|
+
name: string;
|
|
28
|
+
children: SceneGraphItem[] | null;
|
|
29
|
+
}
|
|
30
|
+
export declare type SceneGraph = SceneGraphItem[];
|
|
31
|
+
export interface TreeNode {
|
|
32
|
+
type: string;
|
|
33
|
+
props: {
|
|
34
|
+
[key: string]: any;
|
|
35
|
+
};
|
|
36
|
+
children: TreeNode[];
|
|
37
|
+
}
|
|
38
|
+
export declare type Tree = TreeNode[];
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var THREE = require('three');
|
|
6
6
|
var fiber = require('@react-three/fiber');
|
|
7
|
+
var React = require('react');
|
|
7
8
|
|
|
8
9
|
function _interopNamespace(e) {
|
|
9
10
|
if (e && e.__esModule) return e;
|
|
@@ -24,6 +25,7 @@ function _interopNamespace(e) {
|
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
var THREE__namespace = /*#__PURE__*/_interopNamespace(THREE);
|
|
28
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
27
29
|
|
|
28
30
|
const lowerCaseFirstLetter = str => `${str.charAt(0).toLowerCase()}${str.slice(1)}`;
|
|
29
31
|
const toEventHandlerName = eventName => `on${eventName.charAt(0).toUpperCase()}${eventName.slice(1)}`;
|
|
@@ -763,6 +765,22 @@ const wrapFiber = fiber => {
|
|
|
763
765
|
return wrapper;
|
|
764
766
|
};
|
|
765
767
|
|
|
768
|
+
const act$1 = React__namespace.unstable_act;
|
|
769
|
+
async function waitFor(callback, {
|
|
770
|
+
interval = 50,
|
|
771
|
+
timeout = 5000
|
|
772
|
+
} = {}) {
|
|
773
|
+
await act$1(async () => {
|
|
774
|
+
const start = performance.now();
|
|
775
|
+
while (true) {
|
|
776
|
+
const result = callback();
|
|
777
|
+
if (result || result == null) break;
|
|
778
|
+
if (interval) await new Promise(resolve => setTimeout(resolve, interval));
|
|
779
|
+
if (timeout && performance.now() - start >= timeout) throw new Error(`Timed out after ${timeout}ms.`);
|
|
780
|
+
}
|
|
781
|
+
});
|
|
782
|
+
}
|
|
783
|
+
|
|
766
784
|
var index$1 = /*#__PURE__*/Object.freeze({
|
|
767
785
|
__proto__: null,
|
|
768
786
|
ReactThreeTestInstance: ReactThreeTestInstance
|
|
@@ -772,9 +790,18 @@ var index$1 = /*#__PURE__*/Object.freeze({
|
|
|
772
790
|
fiber.extend(THREE__namespace);
|
|
773
791
|
const act = fiber.act;
|
|
774
792
|
const create = async (element, options) => {
|
|
793
|
+
var _options$width, _options$height;
|
|
775
794
|
const canvas = createCanvas(options);
|
|
776
795
|
const _root = fiber.createRoot(canvas).configure({
|
|
777
796
|
frameloop: 'never',
|
|
797
|
+
// TODO: remove and use default behavior
|
|
798
|
+
size: {
|
|
799
|
+
width: (_options$width = options == null ? void 0 : options.width) != null ? _options$width : 1280,
|
|
800
|
+
height: (_options$height = options == null ? void 0 : options.height) != null ? _options$height : 800,
|
|
801
|
+
top: 0,
|
|
802
|
+
left: 0,
|
|
803
|
+
updateStyle: typeof HTMLCanvasElement !== 'undefined' && canvas instanceof HTMLCanvasElement
|
|
804
|
+
},
|
|
778
805
|
...options,
|
|
779
806
|
events: undefined
|
|
780
807
|
});
|
|
@@ -832,10 +859,12 @@ const create = async (element, options) => {
|
|
|
832
859
|
};
|
|
833
860
|
var index = {
|
|
834
861
|
create,
|
|
835
|
-
act
|
|
862
|
+
act,
|
|
863
|
+
waitFor
|
|
836
864
|
};
|
|
837
865
|
|
|
838
866
|
exports.ReactThreeTest = index$1;
|
|
839
867
|
exports.act = act;
|
|
840
868
|
exports.create = create;
|
|
841
869
|
exports["default"] = index;
|
|
870
|
+
exports.waitFor = waitFor;
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var THREE = require('three');
|
|
6
6
|
var fiber = require('@react-three/fiber');
|
|
7
|
+
var React = require('react');
|
|
7
8
|
|
|
8
9
|
function _interopNamespace(e) {
|
|
9
10
|
if (e && e.__esModule) return e;
|
|
@@ -24,6 +25,7 @@ function _interopNamespace(e) {
|
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
var THREE__namespace = /*#__PURE__*/_interopNamespace(THREE);
|
|
28
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
27
29
|
|
|
28
30
|
const lowerCaseFirstLetter = str => `${str.charAt(0).toLowerCase()}${str.slice(1)}`;
|
|
29
31
|
const toEventHandlerName = eventName => `on${eventName.charAt(0).toUpperCase()}${eventName.slice(1)}`;
|
|
@@ -763,6 +765,22 @@ const wrapFiber = fiber => {
|
|
|
763
765
|
return wrapper;
|
|
764
766
|
};
|
|
765
767
|
|
|
768
|
+
const act$1 = React__namespace.unstable_act;
|
|
769
|
+
async function waitFor(callback, {
|
|
770
|
+
interval = 50,
|
|
771
|
+
timeout = 5000
|
|
772
|
+
} = {}) {
|
|
773
|
+
await act$1(async () => {
|
|
774
|
+
const start = performance.now();
|
|
775
|
+
while (true) {
|
|
776
|
+
const result = callback();
|
|
777
|
+
if (result || result == null) break;
|
|
778
|
+
if (interval) await new Promise(resolve => setTimeout(resolve, interval));
|
|
779
|
+
if (timeout && performance.now() - start >= timeout) throw new Error(`Timed out after ${timeout}ms.`);
|
|
780
|
+
}
|
|
781
|
+
});
|
|
782
|
+
}
|
|
783
|
+
|
|
766
784
|
var index$1 = /*#__PURE__*/Object.freeze({
|
|
767
785
|
__proto__: null,
|
|
768
786
|
ReactThreeTestInstance: ReactThreeTestInstance
|
|
@@ -772,9 +790,18 @@ var index$1 = /*#__PURE__*/Object.freeze({
|
|
|
772
790
|
fiber.extend(THREE__namespace);
|
|
773
791
|
const act = fiber.act;
|
|
774
792
|
const create = async (element, options) => {
|
|
793
|
+
var _options$width, _options$height;
|
|
775
794
|
const canvas = createCanvas(options);
|
|
776
795
|
const _root = fiber.createRoot(canvas).configure({
|
|
777
796
|
frameloop: 'never',
|
|
797
|
+
// TODO: remove and use default behavior
|
|
798
|
+
size: {
|
|
799
|
+
width: (_options$width = options == null ? void 0 : options.width) != null ? _options$width : 1280,
|
|
800
|
+
height: (_options$height = options == null ? void 0 : options.height) != null ? _options$height : 800,
|
|
801
|
+
top: 0,
|
|
802
|
+
left: 0,
|
|
803
|
+
updateStyle: typeof HTMLCanvasElement !== 'undefined' && canvas instanceof HTMLCanvasElement
|
|
804
|
+
},
|
|
778
805
|
...options,
|
|
779
806
|
events: undefined
|
|
780
807
|
});
|
|
@@ -832,10 +859,12 @@ const create = async (element, options) => {
|
|
|
832
859
|
};
|
|
833
860
|
var index = {
|
|
834
861
|
create,
|
|
835
|
-
act
|
|
862
|
+
act,
|
|
863
|
+
waitFor
|
|
836
864
|
};
|
|
837
865
|
|
|
838
866
|
exports.ReactThreeTest = index$1;
|
|
839
867
|
exports.act = act;
|
|
840
868
|
exports.create = create;
|
|
841
869
|
exports["default"] = index;
|
|
870
|
+
exports.waitFor = waitFor;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
|
-
import { extend, act as act$
|
|
2
|
+
import { extend, act as act$2, createRoot, _roots, reconciler } from '@react-three/fiber';
|
|
3
|
+
import * as React from 'react';
|
|
3
4
|
|
|
4
5
|
const lowerCaseFirstLetter = str => `${str.charAt(0).toLowerCase()}${str.slice(1)}`;
|
|
5
6
|
const toEventHandlerName = eventName => `on${eventName.charAt(0).toUpperCase()}${eventName.slice(1)}`;
|
|
@@ -739,6 +740,22 @@ const wrapFiber = fiber => {
|
|
|
739
740
|
return wrapper;
|
|
740
741
|
};
|
|
741
742
|
|
|
743
|
+
const act$1 = React.unstable_act;
|
|
744
|
+
async function waitFor(callback, {
|
|
745
|
+
interval = 50,
|
|
746
|
+
timeout = 5000
|
|
747
|
+
} = {}) {
|
|
748
|
+
await act$1(async () => {
|
|
749
|
+
const start = performance.now();
|
|
750
|
+
while (true) {
|
|
751
|
+
const result = callback();
|
|
752
|
+
if (result || result == null) break;
|
|
753
|
+
if (interval) await new Promise(resolve => setTimeout(resolve, interval));
|
|
754
|
+
if (timeout && performance.now() - start >= timeout) throw new Error(`Timed out after ${timeout}ms.`);
|
|
755
|
+
}
|
|
756
|
+
});
|
|
757
|
+
}
|
|
758
|
+
|
|
742
759
|
var index$1 = /*#__PURE__*/Object.freeze({
|
|
743
760
|
__proto__: null,
|
|
744
761
|
ReactThreeTestInstance: ReactThreeTestInstance
|
|
@@ -746,11 +763,20 @@ var index$1 = /*#__PURE__*/Object.freeze({
|
|
|
746
763
|
|
|
747
764
|
// Extend catalogue for render API in tests.
|
|
748
765
|
extend(THREE);
|
|
749
|
-
const act = act$
|
|
766
|
+
const act = act$2;
|
|
750
767
|
const create = async (element, options) => {
|
|
768
|
+
var _options$width, _options$height;
|
|
751
769
|
const canvas = createCanvas(options);
|
|
752
770
|
const _root = createRoot(canvas).configure({
|
|
753
771
|
frameloop: 'never',
|
|
772
|
+
// TODO: remove and use default behavior
|
|
773
|
+
size: {
|
|
774
|
+
width: (_options$width = options == null ? void 0 : options.width) != null ? _options$width : 1280,
|
|
775
|
+
height: (_options$height = options == null ? void 0 : options.height) != null ? _options$height : 800,
|
|
776
|
+
top: 0,
|
|
777
|
+
left: 0,
|
|
778
|
+
updateStyle: typeof HTMLCanvasElement !== 'undefined' && canvas instanceof HTMLCanvasElement
|
|
779
|
+
},
|
|
754
780
|
...options,
|
|
755
781
|
events: undefined
|
|
756
782
|
});
|
|
@@ -808,7 +834,8 @@ const create = async (element, options) => {
|
|
|
808
834
|
};
|
|
809
835
|
var index = {
|
|
810
836
|
create,
|
|
811
|
-
act
|
|
837
|
+
act,
|
|
838
|
+
waitFor
|
|
812
839
|
};
|
|
813
840
|
|
|
814
|
-
export { index$1 as ReactThreeTest, act, create, index as default };
|
|
841
|
+
export { index$1 as ReactThreeTest, act, create, index as default, waitFor };
|