@react-three/test-renderer 8.2.2 → 8.2.4
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 -0
- package/dist/declarations/src/createTestCanvas.d.ts +2 -0
- package/dist/declarations/src/createTestInstance.d.ts +20 -0
- package/dist/declarations/src/fireEvent.d.ts +4 -0
- package/dist/declarations/src/helpers/graph.d.ts +3 -0
- package/dist/declarations/src/helpers/is.d.ts +9 -0
- package/dist/declarations/src/helpers/strings.d.ts +2 -0
- package/dist/declarations/src/helpers/testInstance.d.ts +5 -0
- package/dist/declarations/src/helpers/tree.d.ts +3 -0
- package/dist/declarations/src/helpers/waitFor.d.ts +5 -0
- package/dist/declarations/src/index.d.ts +14 -0
- package/dist/declarations/src/types/index.d.ts +1 -0
- package/dist/declarations/src/types/internal.d.ts +37 -0
- package/dist/declarations/src/types/public.d.ts +38 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -0,0 +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): number[] | string[] | undefined;
|
|
13
|
+
getExtension(ext: string): any;
|
|
14
|
+
getProgramInfoLog: () => string;
|
|
15
|
+
getShaderInfoLog: () => string;
|
|
16
|
+
}
|
|
@@ -0,0 +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;
|
|
@@ -0,0 +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>;
|
|
@@ -0,0 +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>>[];
|
|
@@ -0,0 +1,14 @@
|
|
|
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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './public';
|
|
@@ -0,0 +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
|
+
* 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
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
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[];
|