@react-three/test-renderer 8.1.4 → 8.2.0
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/helpers/waitFor.d.ts +5 -0
- package/dist/declarations/src/index.d.ts +6 -2
- package/dist/declarations/src/types/public.d.ts +0 -1
- package/dist/react-three-test-renderer.cjs.dev.js +41 -9
- package/dist/react-three-test-renderer.cjs.prod.js +41 -9
- package/dist/react-three-test-renderer.esm.js +42 -12
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @react-three/test-renderer
|
|
2
2
|
|
|
3
|
+
## 8.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- a5ffb08e: feat(RTTR): waitFor util
|
|
8
|
+
|
|
9
|
+
## 8.1.5
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 673927f7: fix(RTTR): implement HTMLCanvasElement.getContext
|
|
14
|
+
|
|
3
15
|
## 8.1.4
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import type { CreateOptions, Renderer, Act } from './types/public';
|
|
3
|
-
|
|
4
|
-
|
|
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 };
|
|
5
8
|
export * as ReactThreeTest from './types';
|
|
6
9
|
declare const _default: {
|
|
7
10
|
create: (element: React.ReactNode, options?: Partial<CreateOptions> | undefined) => Promise<Renderer>;
|
|
8
11
|
act: Act;
|
|
12
|
+
waitFor: typeof waitFor;
|
|
9
13
|
};
|
|
10
14
|
export default _default;
|
|
@@ -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)}`;
|
|
@@ -603,16 +605,28 @@ const createCanvas = ({
|
|
|
603
605
|
height = 800
|
|
604
606
|
} = {}) => {
|
|
605
607
|
var _globalThis$WebGLRend, _globalThis$WebGL2Ren;
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
608
|
+
let canvas;
|
|
609
|
+
if (typeof document !== 'undefined' && typeof document.createElement === 'function') {
|
|
610
|
+
canvas = document.createElement('canvas');
|
|
611
|
+
} else {
|
|
612
|
+
canvas = {
|
|
613
|
+
style: {},
|
|
614
|
+
addEventListener: () => {},
|
|
615
|
+
removeEventListener: () => {},
|
|
616
|
+
clientWidth: width,
|
|
617
|
+
clientHeight: height,
|
|
618
|
+
getContext: () => new WebGL2RenderingContext(canvas)
|
|
619
|
+
};
|
|
620
|
+
}
|
|
614
621
|
canvas.width = width;
|
|
615
622
|
canvas.height = height;
|
|
623
|
+
if (globalThis.HTMLCanvasElement) {
|
|
624
|
+
const getContext = HTMLCanvasElement.prototype.getContext;
|
|
625
|
+
HTMLCanvasElement.prototype.getContext = function (id) {
|
|
626
|
+
if (id.startsWith('webgl')) return new WebGL2RenderingContext(this);
|
|
627
|
+
return getContext.apply(this, arguments);
|
|
628
|
+
};
|
|
629
|
+
}
|
|
616
630
|
beforeReturn == null ? void 0 : beforeReturn(canvas);
|
|
617
631
|
class WebGLRenderingContext extends WebGL2RenderingContext {}
|
|
618
632
|
// @ts-ignore
|
|
@@ -751,6 +765,22 @@ const wrapFiber = fiber => {
|
|
|
751
765
|
return wrapper;
|
|
752
766
|
};
|
|
753
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
|
+
|
|
754
784
|
var index$1 = /*#__PURE__*/Object.freeze({
|
|
755
785
|
__proto__: null,
|
|
756
786
|
ReactThreeTestInstance: ReactThreeTestInstance
|
|
@@ -820,10 +850,12 @@ const create = async (element, options) => {
|
|
|
820
850
|
};
|
|
821
851
|
var index = {
|
|
822
852
|
create,
|
|
823
|
-
act
|
|
853
|
+
act,
|
|
854
|
+
waitFor
|
|
824
855
|
};
|
|
825
856
|
|
|
826
857
|
exports.ReactThreeTest = index$1;
|
|
827
858
|
exports.act = act;
|
|
828
859
|
exports.create = create;
|
|
829
860
|
exports["default"] = index;
|
|
861
|
+
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)}`;
|
|
@@ -603,16 +605,28 @@ const createCanvas = ({
|
|
|
603
605
|
height = 800
|
|
604
606
|
} = {}) => {
|
|
605
607
|
var _globalThis$WebGLRend, _globalThis$WebGL2Ren;
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
608
|
+
let canvas;
|
|
609
|
+
if (typeof document !== 'undefined' && typeof document.createElement === 'function') {
|
|
610
|
+
canvas = document.createElement('canvas');
|
|
611
|
+
} else {
|
|
612
|
+
canvas = {
|
|
613
|
+
style: {},
|
|
614
|
+
addEventListener: () => {},
|
|
615
|
+
removeEventListener: () => {},
|
|
616
|
+
clientWidth: width,
|
|
617
|
+
clientHeight: height,
|
|
618
|
+
getContext: () => new WebGL2RenderingContext(canvas)
|
|
619
|
+
};
|
|
620
|
+
}
|
|
614
621
|
canvas.width = width;
|
|
615
622
|
canvas.height = height;
|
|
623
|
+
if (globalThis.HTMLCanvasElement) {
|
|
624
|
+
const getContext = HTMLCanvasElement.prototype.getContext;
|
|
625
|
+
HTMLCanvasElement.prototype.getContext = function (id) {
|
|
626
|
+
if (id.startsWith('webgl')) return new WebGL2RenderingContext(this);
|
|
627
|
+
return getContext.apply(this, arguments);
|
|
628
|
+
};
|
|
629
|
+
}
|
|
616
630
|
beforeReturn == null ? void 0 : beforeReturn(canvas);
|
|
617
631
|
class WebGLRenderingContext extends WebGL2RenderingContext {}
|
|
618
632
|
// @ts-ignore
|
|
@@ -751,6 +765,22 @@ const wrapFiber = fiber => {
|
|
|
751
765
|
return wrapper;
|
|
752
766
|
};
|
|
753
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
|
+
|
|
754
784
|
var index$1 = /*#__PURE__*/Object.freeze({
|
|
755
785
|
__proto__: null,
|
|
756
786
|
ReactThreeTestInstance: ReactThreeTestInstance
|
|
@@ -820,10 +850,12 @@ const create = async (element, options) => {
|
|
|
820
850
|
};
|
|
821
851
|
var index = {
|
|
822
852
|
create,
|
|
823
|
-
act
|
|
853
|
+
act,
|
|
854
|
+
waitFor
|
|
824
855
|
};
|
|
825
856
|
|
|
826
857
|
exports.ReactThreeTest = index$1;
|
|
827
858
|
exports.act = act;
|
|
828
859
|
exports.create = create;
|
|
829
860
|
exports["default"] = index;
|
|
861
|
+
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)}`;
|
|
@@ -579,16 +580,28 @@ const createCanvas = ({
|
|
|
579
580
|
height = 800
|
|
580
581
|
} = {}) => {
|
|
581
582
|
var _globalThis$WebGLRend, _globalThis$WebGL2Ren;
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
583
|
+
let canvas;
|
|
584
|
+
if (typeof document !== 'undefined' && typeof document.createElement === 'function') {
|
|
585
|
+
canvas = document.createElement('canvas');
|
|
586
|
+
} else {
|
|
587
|
+
canvas = {
|
|
588
|
+
style: {},
|
|
589
|
+
addEventListener: () => {},
|
|
590
|
+
removeEventListener: () => {},
|
|
591
|
+
clientWidth: width,
|
|
592
|
+
clientHeight: height,
|
|
593
|
+
getContext: () => new WebGL2RenderingContext(canvas)
|
|
594
|
+
};
|
|
595
|
+
}
|
|
590
596
|
canvas.width = width;
|
|
591
597
|
canvas.height = height;
|
|
598
|
+
if (globalThis.HTMLCanvasElement) {
|
|
599
|
+
const getContext = HTMLCanvasElement.prototype.getContext;
|
|
600
|
+
HTMLCanvasElement.prototype.getContext = function (id) {
|
|
601
|
+
if (id.startsWith('webgl')) return new WebGL2RenderingContext(this);
|
|
602
|
+
return getContext.apply(this, arguments);
|
|
603
|
+
};
|
|
604
|
+
}
|
|
592
605
|
beforeReturn == null ? void 0 : beforeReturn(canvas);
|
|
593
606
|
class WebGLRenderingContext extends WebGL2RenderingContext {}
|
|
594
607
|
// @ts-ignore
|
|
@@ -727,6 +740,22 @@ const wrapFiber = fiber => {
|
|
|
727
740
|
return wrapper;
|
|
728
741
|
};
|
|
729
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
|
+
|
|
730
759
|
var index$1 = /*#__PURE__*/Object.freeze({
|
|
731
760
|
__proto__: null,
|
|
732
761
|
ReactThreeTestInstance: ReactThreeTestInstance
|
|
@@ -734,7 +763,7 @@ var index$1 = /*#__PURE__*/Object.freeze({
|
|
|
734
763
|
|
|
735
764
|
// Extend catalogue for render API in tests.
|
|
736
765
|
extend(THREE);
|
|
737
|
-
const act = act$
|
|
766
|
+
const act = act$2;
|
|
738
767
|
const create = async (element, options) => {
|
|
739
768
|
const canvas = createCanvas(options);
|
|
740
769
|
const _root = createRoot(canvas).configure({
|
|
@@ -796,7 +825,8 @@ const create = async (element, options) => {
|
|
|
796
825
|
};
|
|
797
826
|
var index = {
|
|
798
827
|
create,
|
|
799
|
-
act
|
|
828
|
+
act,
|
|
829
|
+
waitFor
|
|
800
830
|
};
|
|
801
831
|
|
|
802
|
-
export { index$1 as ReactThreeTest, act, create, index as default };
|
|
832
|
+
export { index$1 as ReactThreeTest, act, create, index as default, waitFor };
|