@react-three/test-renderer 8.2.1 → 9.0.0-alpha.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.
@@ -4,7 +4,6 @@ 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');
8
7
 
9
8
  function _interopNamespace(e) {
10
9
  if (e && e.__esModule) return e;
@@ -25,7 +24,6 @@ function _interopNamespace(e) {
25
24
  }
26
25
 
27
26
  var THREE__namespace = /*#__PURE__*/_interopNamespace(THREE);
28
- var React__namespace = /*#__PURE__*/_interopNamespace(React);
29
27
 
30
28
  const lowerCaseFirstLetter = str => `${str.charAt(0).toLowerCase()}${str.slice(1)}`;
31
29
  const toEventHandlerName = eventName => `on${eventName.charAt(0).toUpperCase()}${eventName.slice(1)}`;
@@ -35,43 +33,20 @@ const treeObjectFactory = (type, props, children) => ({
35
33
  props,
36
34
  children
37
35
  });
38
- const toTreeBranch = obj => obj.map(child => {
39
- return treeObjectFactory(lowerCaseFirstLetter(child.type || child.constructor.name), {
40
- ...child.__r3f.memoizedProps
41
- }, toTreeBranch([...(child.children || []), ...child.__r3f.objects]));
36
+ const toTreeBranch = children => children.map(child => {
37
+ return treeObjectFactory(lowerCaseFirstLetter(child.object.type || child.object.constructor.name), child.props, toTreeBranch(child.children));
42
38
  });
43
- const toTree = root => root.children.map(obj => treeObjectFactory(lowerCaseFirstLetter(obj.type), {
44
- ...obj.__r3f.memoizedProps
45
- }, toTreeBranch([...obj.children, ...obj.__r3f.objects])));
39
+ const toTree = root => toTreeBranch(root.children);
46
40
 
47
41
  const graphObjectFactory = (type, name, children) => ({
48
42
  type,
49
43
  name,
50
44
  children
51
45
  });
52
- const toGraph = object => object.children.map(child => graphObjectFactory(child.type, child.name || '', toGraph(child)));
53
-
54
- const is = {
55
- obj: a => a === Object(a) && !is.arr(a) && typeof a !== 'function',
56
- fun: a => typeof a === 'function',
57
- str: a => typeof a === 'string',
58
- num: a => typeof a === 'number',
59
- und: a => a === void 0,
60
- arr: a => Array.isArray(a),
61
- equ(a, b) {
62
- // Wrong type or one of the two undefined, doesn't match
63
- if (typeof a !== typeof b || !!a !== !!b) return false;
64
- // Atomic, just compare a against b
65
- if (is.str(a) || is.num(a) || is.obj(a)) return a === b;
66
- // Array, shallow compare first to see if it's a match
67
- if (is.arr(a) && a == b) return true;
68
- // Last resort, go through keys
69
- let i;
70
- for (i in a) if (!(i in b)) return false;
71
- for (i in b) if (a[i] !== b[i]) return false;
72
- return is.und(i) ? a === b : true;
73
- }
74
- };
46
+ const toGraph = object => object.children.map(child => {
47
+ var _child$object$name;
48
+ return graphObjectFactory(child.object.type, (_child$object$name = child.object.name) != null ? _child$object$name : '', toGraph(child));
49
+ });
75
50
 
76
51
  const functions = ['activeTexture', 'attachShader', 'beginQuery', 'beginTransformFeedback', 'bindAttribLocation', 'bindBufferBase', 'bindBufferRange', 'bindRenderbuffer', 'bindSampler', 'bindTransformFeedback', 'bindVertexArray', 'blendColor', 'blendEquation', 'blendEquationSeparate', 'blendFunc', 'blendFuncSeparate', 'blitFramebuffer', 'bufferData', 'bufferSubData', 'checkFramebufferStatus', 'clientWaitSync', 'compileShader', 'compressedTexImage2D', 'compressedTexImage3D', 'compressedTexSubImage2D', 'compressedTexSubImage3D', 'copyBufferSubData', 'copyTexImage2D', 'copyTexSubImage2D', 'copyTexSubImage3D', 'createBuffer', 'createFramebuffer', 'createProgram', 'createQuery', 'createRenderbuffer', 'createSampler', 'createShader', 'createTexture', 'createTransformFeedback', 'createVertexArray', 'cullFace', 'deleteBuffer', 'deleteFramebuffer', 'deleteProgram', 'deleteQuery', 'deleteRenderbuffer', 'deleteSampler', 'deleteShader', 'deleteSync', 'deleteTexture', 'deleteTransformFeedback', 'deleteVertexArray', 'depthFunc', 'depthMask', 'depthRange', 'detachShader', 'disable', 'drawArraysInstanced', 'drawElementsInstanced', 'drawRangeElements', 'enable', 'endQuery', 'endTransformFeedback', 'fenceSync', 'finish', 'flush', 'framebufferRenderbuffer', 'framebufferTexture2D', 'framebufferTextureLayer', 'frontFace', 'generateMipmap', 'getActiveAttrib', 'getActiveUniform', 'getActiveUniformBlockName', 'getActiveUniformBlockParameter', 'getActiveUniforms', 'getAttachedShaders', 'getAttribLocation', 'getBufferParameter', 'getBufferSubData', 'getContextAttributes', 'getError', 'getExtension', 'getFragDataLocation', 'getFramebufferAttachmentParameter', 'getIndexedParameter', 'getInternalformatParameter', 'getParameter', 'getProgramInfoLog', 'getProgramParameter', 'getQuery', 'getQueryParameter', 'getRenderbufferParameter', 'getSamplerParameter', 'getShaderInfoLog', 'getShaderParameter', 'getShaderPrecisionFormat', 'getShaderSource', 'getSupportedExtensions', 'getSyncParameter', 'getTexParameter', 'getTransformFeedbackVarying', 'getUniform', 'getUniformBlockIndex', 'getUniformIndices', 'getUniformLocation', 'getVertexAttrib', 'getVertexAttribOffset', 'hint', 'invalidateFramebuffer', 'invalidateSubFramebuffer', 'isBuffer', 'isContextLost', 'isEnabled', 'isFramebuffer', 'isProgram', 'isQuery', 'isRenderbuffer', 'isSampler', 'isShader', 'isSync', 'isTexture', 'isTransformFeedback', 'isVertexArray', 'lineWidth', 'linkProgram', 'pauseTransformFeedback', 'pixelStorei', 'polygonOffset', 'readBuffer', 'readPixels', 'renderbufferStorage', 'renderbufferStorageMultisample', 'resumeTransformFeedback', 'sampleCoverage', 'samplerParameterf', 'samplerParameteri', 'shaderSource', 'stencilFunc', 'stencilFuncSeparate', 'stencilMask', 'stencilMaskSeparate', 'stencilOp', 'stencilOpSeparate', 'texImage2D', 'texImage3D', 'texParameterf', 'texParameteri', 'texStorage2D', 'texStorage3D', 'texSubImage2D', 'texSubImage3D', 'transformFeedbackVaryings', 'uniform1ui', 'uniform2ui', 'uniform3ui', 'uniform4ui', 'uniformBlockBinding', 'useProgram', 'validateProgram', 'vertexAttribDivisor', 'vertexAttribI4i', 'vertexAttribI4ui', 'vertexAttribIPointer', 'waitSync', 'bindBuffer', 'bindFramebuffer', 'bindTexture', 'clear', 'clearBufferfi', 'clearBufferfv', 'clearBufferiv', 'clearBufferuiv', 'clearColor', 'clearDepth', 'clearStencil', 'colorMask', 'disableVertexAttribArray', 'drawArrays', 'drawBuffers', 'drawElements', 'enableVertexAttribArray', 'scissor', 'uniform1f', 'uniform1fv', 'uniform1i', 'uniform1iv', 'uniform1uiv', 'uniform2f', 'uniform2fv', 'uniform2i', 'uniform2iv', 'uniform2uiv', 'uniform3f', 'uniform3fv', 'uniform3i', 'uniform3iv', 'uniform3uiv', 'uniform4f', 'uniform4fv', 'uniform4i', 'uniform4iv', 'uniform4uiv', 'uniformMatrix2fv', 'uniformMatrix2x3fv', 'uniformMatrix2x4fv', 'uniformMatrix3fv', 'uniformMatrix3x2fv', 'uniformMatrix3x4fv', 'uniformMatrix4fv', 'uniformMatrix4x2fv', 'uniformMatrix4x3fv', 'vertexAttrib1f', 'vertexAttrib1fv', 'vertexAttrib2f', 'vertexAttrib2fv', 'vertexAttrib3f', 'vertexAttrib3fv', 'vertexAttrib4f', 'vertexAttrib4fv', 'vertexAttribI4iv', 'vertexAttribI4uiv', 'vertexAttribPointer', 'viewport', 'makeXRCompatible'];
77
52
  const enums = {
@@ -711,36 +686,29 @@ class ReactThreeTestInstance {
711
686
  constructor(_fiber) {
712
687
  this.getChildren = (fiber, opts = {
713
688
  exhaustive: false
714
- }) => {
715
- if (opts.exhaustive) {
716
- /**
717
- * this will return objects like
718
- * color or effects etc.
719
- */
720
- return [...(fiber.children || []).map(fib => wrapFiber(fib)), ...fiber.__r3f.objects.map(fib => wrapFiber(fib))];
721
- } else {
722
- return (fiber.children || []).map(fib => wrapFiber(fib));
723
- }
724
- };
725
- this.find = decider => expectOne(findAll(this, decider), `matching custom checker: ${decider.toString()}`);
689
+ }) => fiber.children.filter(child => !child.props.attach || opts.exhaustive).map(fib => wrapFiber(fib));
726
690
  this.findAll = decider => findAll(this, decider);
727
- this.findByType = type => expectOne(findAll(this, node => Boolean(node.type && node.type === type)), `with node type: "${type || 'Unknown'}"`);
728
- this.findAllByType = type => findAll(this, node => Boolean(node.type && node.type === type));
691
+ this.find = decider => expectOne(this.findAll(decider), `matching custom checker: ${decider.toString()}`);
692
+ this.findByType = type => expectOne(this.findAll(node => Boolean(node.type && node.type === type)), `with node type: "${type || 'Unknown'}"`);
693
+ this.findAllByType = type => this.findAll(node => Boolean(node.type && node.type === type));
729
694
  this.findByProps = props => expectOne(this.findAllByProps(props), `with props: ${JSON.stringify(props)}`);
730
- this.findAllByProps = props => findAll(this, node => Boolean(node.props && matchProps(node.props, props)));
695
+ this.findAllByProps = props => this.findAll(node => Boolean(node.props && matchProps(node.props, props)));
731
696
  this._fiber = _fiber;
732
697
  }
733
- get instance() {
698
+ get fiber() {
734
699
  return this._fiber;
735
700
  }
701
+ get instance() {
702
+ return this._fiber.object;
703
+ }
736
704
  get type() {
737
- return this._fiber.type;
705
+ return this._fiber.object.type;
738
706
  }
739
707
  get props() {
740
- return this._fiber.__r3f.memoizedProps;
708
+ return this._fiber.props;
741
709
  }
742
710
  get parent() {
743
- const parent = this._fiber.__r3f.parent;
711
+ const parent = this._fiber.parent;
744
712
  if (parent !== null) {
745
713
  return wrapFiber(parent);
746
714
  }
@@ -765,12 +733,11 @@ const wrapFiber = fiber => {
765
733
  return wrapper;
766
734
  };
767
735
 
768
- const act$1 = React__namespace.unstable_act;
769
736
  async function waitFor(callback, {
770
737
  interval = 50,
771
738
  timeout = 5000
772
739
  } = {}) {
773
- await act$1(async () => {
740
+ await fiber.act(async () => {
774
741
  const start = performance.now();
775
742
  while (true) {
776
743
  const result = callback();
@@ -788,7 +755,6 @@ var index$1 = /*#__PURE__*/Object.freeze({
788
755
 
789
756
  // Extend catalogue for render API in tests.
790
757
  fiber.extend(THREE__namespace);
791
- const act = fiber.act;
792
758
  const create = async (element, options) => {
793
759
  var _options$width, _options$height;
794
760
  const canvas = createCanvas(options);
@@ -799,19 +765,20 @@ const create = async (element, options) => {
799
765
  width: (_options$width = options == null ? void 0 : options.width) != null ? _options$width : 1280,
800
766
  height: (_options$height = options == null ? void 0 : options.height) != null ? _options$height : 800,
801
767
  top: 0,
802
- left: 0,
803
- updateStyle: typeof HTMLCanvasElement !== 'undefined' && canvas instanceof HTMLCanvasElement
768
+ left: 0
804
769
  },
805
770
  ...options,
806
771
  events: undefined
807
772
  });
808
773
  const _store = fiber._roots.get(canvas).store;
809
- await act(async () => _root.render(element));
810
- const scene = _store.getState().scene;
774
+ await fiber.act(async () => _root.render(element));
775
+ const _scene = _store.getState().scene.__r3f;
811
776
  return {
812
- scene: wrapFiber(scene),
777
+ scene: wrapFiber(_scene),
813
778
  async unmount() {
814
- await act(async () => _root.unmount());
779
+ await fiber.act(async () => {
780
+ _root.unmount();
781
+ });
815
782
  },
816
783
  getInstance() {
817
784
  // Bail if canvas is unmounted
@@ -831,40 +798,45 @@ const create = async (element, options) => {
831
798
  },
832
799
  async update(newElement) {
833
800
  if (!fiber._roots.has(canvas)) return console.warn('RTTR: attempted to update an unmounted root!');
834
- await act(async () => _root.render(newElement));
801
+ await fiber.act(async () => {
802
+ _root.render(newElement);
803
+ });
835
804
  },
836
805
  toTree() {
837
- return toTree(scene);
806
+ return toTree(_scene);
838
807
  },
839
808
  toGraph() {
840
- return toGraph(scene);
809
+ return toGraph(_scene);
841
810
  },
842
- fireEvent: createEventFirer(act, _store),
811
+ fireEvent: createEventFirer(fiber.act, _store),
843
812
  async advanceFrames(frames, delta = 1) {
844
813
  const state = _store.getState();
845
814
  const storeSubscribers = state.internal.subscribers;
846
815
  const promises = [];
847
- for (const subscriber of storeSubscribers) {
816
+ storeSubscribers.forEach(subscriber => {
848
817
  for (let i = 0; i < frames; i++) {
849
- if (is.arr(delta)) {
818
+ if (Array.isArray(delta)) {
850
819
  promises.push(new Promise(() => subscriber.ref.current(state, delta[i] || delta[-1])));
851
820
  } else {
852
821
  promises.push(new Promise(() => subscriber.ref.current(state, delta)));
853
822
  }
854
823
  }
855
- }
824
+ });
856
825
  Promise.all(promises);
857
826
  }
858
827
  };
859
828
  };
860
829
  var index = {
861
830
  create,
862
- act,
831
+ act: fiber.act,
863
832
  waitFor
864
833
  };
865
834
 
835
+ Object.defineProperty(exports, 'act', {
836
+ enumerable: true,
837
+ get: function () { return fiber.act; }
838
+ });
866
839
  exports.ReactThreeTest = index$1;
867
- exports.act = act;
868
840
  exports.create = create;
869
841
  exports["default"] = index;
870
842
  exports.waitFor = waitFor;
@@ -1,6 +1,6 @@
1
1
  import * as THREE from 'three';
2
- import { extend, act as act$2, createRoot, _roots, reconciler } from '@react-three/fiber';
3
- import * as React from 'react';
2
+ import { act, extend, createRoot, _roots, reconciler } from '@react-three/fiber';
3
+ export { act } from '@react-three/fiber';
4
4
 
5
5
  const lowerCaseFirstLetter = str => `${str.charAt(0).toLowerCase()}${str.slice(1)}`;
6
6
  const toEventHandlerName = eventName => `on${eventName.charAt(0).toUpperCase()}${eventName.slice(1)}`;
@@ -10,43 +10,20 @@ const treeObjectFactory = (type, props, children) => ({
10
10
  props,
11
11
  children
12
12
  });
13
- const toTreeBranch = obj => obj.map(child => {
14
- return treeObjectFactory(lowerCaseFirstLetter(child.type || child.constructor.name), {
15
- ...child.__r3f.memoizedProps
16
- }, toTreeBranch([...(child.children || []), ...child.__r3f.objects]));
13
+ const toTreeBranch = children => children.map(child => {
14
+ return treeObjectFactory(lowerCaseFirstLetter(child.object.type || child.object.constructor.name), child.props, toTreeBranch(child.children));
17
15
  });
18
- const toTree = root => root.children.map(obj => treeObjectFactory(lowerCaseFirstLetter(obj.type), {
19
- ...obj.__r3f.memoizedProps
20
- }, toTreeBranch([...obj.children, ...obj.__r3f.objects])));
16
+ const toTree = root => toTreeBranch(root.children);
21
17
 
22
18
  const graphObjectFactory = (type, name, children) => ({
23
19
  type,
24
20
  name,
25
21
  children
26
22
  });
27
- const toGraph = object => object.children.map(child => graphObjectFactory(child.type, child.name || '', toGraph(child)));
28
-
29
- const is = {
30
- obj: a => a === Object(a) && !is.arr(a) && typeof a !== 'function',
31
- fun: a => typeof a === 'function',
32
- str: a => typeof a === 'string',
33
- num: a => typeof a === 'number',
34
- und: a => a === void 0,
35
- arr: a => Array.isArray(a),
36
- equ(a, b) {
37
- // Wrong type or one of the two undefined, doesn't match
38
- if (typeof a !== typeof b || !!a !== !!b) return false;
39
- // Atomic, just compare a against b
40
- if (is.str(a) || is.num(a) || is.obj(a)) return a === b;
41
- // Array, shallow compare first to see if it's a match
42
- if (is.arr(a) && a == b) return true;
43
- // Last resort, go through keys
44
- let i;
45
- for (i in a) if (!(i in b)) return false;
46
- for (i in b) if (a[i] !== b[i]) return false;
47
- return is.und(i) ? a === b : true;
48
- }
49
- };
23
+ const toGraph = object => object.children.map(child => {
24
+ var _child$object$name;
25
+ return graphObjectFactory(child.object.type, (_child$object$name = child.object.name) != null ? _child$object$name : '', toGraph(child));
26
+ });
50
27
 
51
28
  const functions = ['activeTexture', 'attachShader', 'beginQuery', 'beginTransformFeedback', 'bindAttribLocation', 'bindBufferBase', 'bindBufferRange', 'bindRenderbuffer', 'bindSampler', 'bindTransformFeedback', 'bindVertexArray', 'blendColor', 'blendEquation', 'blendEquationSeparate', 'blendFunc', 'blendFuncSeparate', 'blitFramebuffer', 'bufferData', 'bufferSubData', 'checkFramebufferStatus', 'clientWaitSync', 'compileShader', 'compressedTexImage2D', 'compressedTexImage3D', 'compressedTexSubImage2D', 'compressedTexSubImage3D', 'copyBufferSubData', 'copyTexImage2D', 'copyTexSubImage2D', 'copyTexSubImage3D', 'createBuffer', 'createFramebuffer', 'createProgram', 'createQuery', 'createRenderbuffer', 'createSampler', 'createShader', 'createTexture', 'createTransformFeedback', 'createVertexArray', 'cullFace', 'deleteBuffer', 'deleteFramebuffer', 'deleteProgram', 'deleteQuery', 'deleteRenderbuffer', 'deleteSampler', 'deleteShader', 'deleteSync', 'deleteTexture', 'deleteTransformFeedback', 'deleteVertexArray', 'depthFunc', 'depthMask', 'depthRange', 'detachShader', 'disable', 'drawArraysInstanced', 'drawElementsInstanced', 'drawRangeElements', 'enable', 'endQuery', 'endTransformFeedback', 'fenceSync', 'finish', 'flush', 'framebufferRenderbuffer', 'framebufferTexture2D', 'framebufferTextureLayer', 'frontFace', 'generateMipmap', 'getActiveAttrib', 'getActiveUniform', 'getActiveUniformBlockName', 'getActiveUniformBlockParameter', 'getActiveUniforms', 'getAttachedShaders', 'getAttribLocation', 'getBufferParameter', 'getBufferSubData', 'getContextAttributes', 'getError', 'getExtension', 'getFragDataLocation', 'getFramebufferAttachmentParameter', 'getIndexedParameter', 'getInternalformatParameter', 'getParameter', 'getProgramInfoLog', 'getProgramParameter', 'getQuery', 'getQueryParameter', 'getRenderbufferParameter', 'getSamplerParameter', 'getShaderInfoLog', 'getShaderParameter', 'getShaderPrecisionFormat', 'getShaderSource', 'getSupportedExtensions', 'getSyncParameter', 'getTexParameter', 'getTransformFeedbackVarying', 'getUniform', 'getUniformBlockIndex', 'getUniformIndices', 'getUniformLocation', 'getVertexAttrib', 'getVertexAttribOffset', 'hint', 'invalidateFramebuffer', 'invalidateSubFramebuffer', 'isBuffer', 'isContextLost', 'isEnabled', 'isFramebuffer', 'isProgram', 'isQuery', 'isRenderbuffer', 'isSampler', 'isShader', 'isSync', 'isTexture', 'isTransformFeedback', 'isVertexArray', 'lineWidth', 'linkProgram', 'pauseTransformFeedback', 'pixelStorei', 'polygonOffset', 'readBuffer', 'readPixels', 'renderbufferStorage', 'renderbufferStorageMultisample', 'resumeTransformFeedback', 'sampleCoverage', 'samplerParameterf', 'samplerParameteri', 'shaderSource', 'stencilFunc', 'stencilFuncSeparate', 'stencilMask', 'stencilMaskSeparate', 'stencilOp', 'stencilOpSeparate', 'texImage2D', 'texImage3D', 'texParameterf', 'texParameteri', 'texStorage2D', 'texStorage3D', 'texSubImage2D', 'texSubImage3D', 'transformFeedbackVaryings', 'uniform1ui', 'uniform2ui', 'uniform3ui', 'uniform4ui', 'uniformBlockBinding', 'useProgram', 'validateProgram', 'vertexAttribDivisor', 'vertexAttribI4i', 'vertexAttribI4ui', 'vertexAttribIPointer', 'waitSync', 'bindBuffer', 'bindFramebuffer', 'bindTexture', 'clear', 'clearBufferfi', 'clearBufferfv', 'clearBufferiv', 'clearBufferuiv', 'clearColor', 'clearDepth', 'clearStencil', 'colorMask', 'disableVertexAttribArray', 'drawArrays', 'drawBuffers', 'drawElements', 'enableVertexAttribArray', 'scissor', 'uniform1f', 'uniform1fv', 'uniform1i', 'uniform1iv', 'uniform1uiv', 'uniform2f', 'uniform2fv', 'uniform2i', 'uniform2iv', 'uniform2uiv', 'uniform3f', 'uniform3fv', 'uniform3i', 'uniform3iv', 'uniform3uiv', 'uniform4f', 'uniform4fv', 'uniform4i', 'uniform4iv', 'uniform4uiv', 'uniformMatrix2fv', 'uniformMatrix2x3fv', 'uniformMatrix2x4fv', 'uniformMatrix3fv', 'uniformMatrix3x2fv', 'uniformMatrix3x4fv', 'uniformMatrix4fv', 'uniformMatrix4x2fv', 'uniformMatrix4x3fv', 'vertexAttrib1f', 'vertexAttrib1fv', 'vertexAttrib2f', 'vertexAttrib2fv', 'vertexAttrib3f', 'vertexAttrib3fv', 'vertexAttrib4f', 'vertexAttrib4fv', 'vertexAttribI4iv', 'vertexAttribI4uiv', 'vertexAttribPointer', 'viewport', 'makeXRCompatible'];
52
29
  const enums = {
@@ -686,36 +663,29 @@ class ReactThreeTestInstance {
686
663
  constructor(_fiber) {
687
664
  this.getChildren = (fiber, opts = {
688
665
  exhaustive: false
689
- }) => {
690
- if (opts.exhaustive) {
691
- /**
692
- * this will return objects like
693
- * color or effects etc.
694
- */
695
- return [...(fiber.children || []).map(fib => wrapFiber(fib)), ...fiber.__r3f.objects.map(fib => wrapFiber(fib))];
696
- } else {
697
- return (fiber.children || []).map(fib => wrapFiber(fib));
698
- }
699
- };
700
- this.find = decider => expectOne(findAll(this, decider), `matching custom checker: ${decider.toString()}`);
666
+ }) => fiber.children.filter(child => !child.props.attach || opts.exhaustive).map(fib => wrapFiber(fib));
701
667
  this.findAll = decider => findAll(this, decider);
702
- this.findByType = type => expectOne(findAll(this, node => Boolean(node.type && node.type === type)), `with node type: "${type || 'Unknown'}"`);
703
- this.findAllByType = type => findAll(this, node => Boolean(node.type && node.type === type));
668
+ this.find = decider => expectOne(this.findAll(decider), `matching custom checker: ${decider.toString()}`);
669
+ this.findByType = type => expectOne(this.findAll(node => Boolean(node.type && node.type === type)), `with node type: "${type || 'Unknown'}"`);
670
+ this.findAllByType = type => this.findAll(node => Boolean(node.type && node.type === type));
704
671
  this.findByProps = props => expectOne(this.findAllByProps(props), `with props: ${JSON.stringify(props)}`);
705
- this.findAllByProps = props => findAll(this, node => Boolean(node.props && matchProps(node.props, props)));
672
+ this.findAllByProps = props => this.findAll(node => Boolean(node.props && matchProps(node.props, props)));
706
673
  this._fiber = _fiber;
707
674
  }
708
- get instance() {
675
+ get fiber() {
709
676
  return this._fiber;
710
677
  }
678
+ get instance() {
679
+ return this._fiber.object;
680
+ }
711
681
  get type() {
712
- return this._fiber.type;
682
+ return this._fiber.object.type;
713
683
  }
714
684
  get props() {
715
- return this._fiber.__r3f.memoizedProps;
685
+ return this._fiber.props;
716
686
  }
717
687
  get parent() {
718
- const parent = this._fiber.__r3f.parent;
688
+ const parent = this._fiber.parent;
719
689
  if (parent !== null) {
720
690
  return wrapFiber(parent);
721
691
  }
@@ -740,12 +710,11 @@ const wrapFiber = fiber => {
740
710
  return wrapper;
741
711
  };
742
712
 
743
- const act$1 = React.unstable_act;
744
713
  async function waitFor(callback, {
745
714
  interval = 50,
746
715
  timeout = 5000
747
716
  } = {}) {
748
- await act$1(async () => {
717
+ await act(async () => {
749
718
  const start = performance.now();
750
719
  while (true) {
751
720
  const result = callback();
@@ -763,7 +732,6 @@ var index$1 = /*#__PURE__*/Object.freeze({
763
732
 
764
733
  // Extend catalogue for render API in tests.
765
734
  extend(THREE);
766
- const act = act$2;
767
735
  const create = async (element, options) => {
768
736
  var _options$width, _options$height;
769
737
  const canvas = createCanvas(options);
@@ -774,19 +742,20 @@ const create = async (element, options) => {
774
742
  width: (_options$width = options == null ? void 0 : options.width) != null ? _options$width : 1280,
775
743
  height: (_options$height = options == null ? void 0 : options.height) != null ? _options$height : 800,
776
744
  top: 0,
777
- left: 0,
778
- updateStyle: typeof HTMLCanvasElement !== 'undefined' && canvas instanceof HTMLCanvasElement
745
+ left: 0
779
746
  },
780
747
  ...options,
781
748
  events: undefined
782
749
  });
783
750
  const _store = _roots.get(canvas).store;
784
751
  await act(async () => _root.render(element));
785
- const scene = _store.getState().scene;
752
+ const _scene = _store.getState().scene.__r3f;
786
753
  return {
787
- scene: wrapFiber(scene),
754
+ scene: wrapFiber(_scene),
788
755
  async unmount() {
789
- await act(async () => _root.unmount());
756
+ await act(async () => {
757
+ _root.unmount();
758
+ });
790
759
  },
791
760
  getInstance() {
792
761
  // Bail if canvas is unmounted
@@ -806,28 +775,30 @@ const create = async (element, options) => {
806
775
  },
807
776
  async update(newElement) {
808
777
  if (!_roots.has(canvas)) return console.warn('RTTR: attempted to update an unmounted root!');
809
- await act(async () => _root.render(newElement));
778
+ await act(async () => {
779
+ _root.render(newElement);
780
+ });
810
781
  },
811
782
  toTree() {
812
- return toTree(scene);
783
+ return toTree(_scene);
813
784
  },
814
785
  toGraph() {
815
- return toGraph(scene);
786
+ return toGraph(_scene);
816
787
  },
817
788
  fireEvent: createEventFirer(act, _store),
818
789
  async advanceFrames(frames, delta = 1) {
819
790
  const state = _store.getState();
820
791
  const storeSubscribers = state.internal.subscribers;
821
792
  const promises = [];
822
- for (const subscriber of storeSubscribers) {
793
+ storeSubscribers.forEach(subscriber => {
823
794
  for (let i = 0; i < frames; i++) {
824
- if (is.arr(delta)) {
795
+ if (Array.isArray(delta)) {
825
796
  promises.push(new Promise(() => subscriber.ref.current(state, delta[i] || delta[-1])));
826
797
  } else {
827
798
  promises.push(new Promise(() => subscriber.ref.current(state, delta)));
828
799
  }
829
800
  }
830
- }
801
+ });
831
802
  Promise.all(promises);
832
803
  }
833
804
  };
@@ -838,4 +809,4 @@ var index = {
838
809
  waitFor
839
810
  };
840
811
 
841
- export { index$1 as ReactThreeTest, act, create, index as default, waitFor };
812
+ export { index$1 as ReactThreeTest, create, index as default, waitFor };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-three/test-renderer",
3
- "version": "8.2.1",
3
+ "version": "9.0.0-alpha.4",
4
4
  "description": "Test Renderer for react-three-fiber",
5
5
  "author": "Josh Ellis",
6
6
  "license": "MIT",
@@ -22,8 +22,8 @@
22
22
  ]
23
23
  },
24
24
  "peerDependencies": {
25
- "react": ">=17.0",
26
- "@react-three/fiber": ">=8.0.0",
27
- "three": ">=0.126"
25
+ "react": ">=19.0",
26
+ "@react-three/fiber": "9.0.0-alpha.4",
27
+ "three": ">=0.141"
28
28
  }
29
29
  }
@@ -1,16 +0,0 @@
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 +0,0 @@
1
- import type { CreateCanvasParameters } from './types/internal';
2
- export declare const createCanvas: ({ beforeReturn, width, height }?: CreateCanvasParameters) => HTMLCanvasElement;
@@ -1,4 +0,0 @@
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 +0,0 @@
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 +0,0 @@
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 +0,0 @@
1
- export declare const lowerCaseFirstLetter: (str: string) => string;
2
- export declare const toEventHandlerName: (eventName: string) => string;
@@ -1,5 +0,0 @@
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 +0,0 @@
1
- import type { Tree } from '../types/public';
2
- import type { MockScene } from '../types/internal';
3
- export declare const toTree: (root: MockScene) => Tree;