Skip to content

Commit 1e77613

Browse files
chore: cleanup, re-enable eslint tests
1 parent 15fb1dd commit 1e77613

File tree

5 files changed

+45
-57
lines changed

5 files changed

+45
-57
lines changed

Diff for: package.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
"expo-file-system": "^15.4.3",
7272
"expo-gl": "^11.4.0",
7373
"husky": "^7.0.4",
74-
"jest": "^29.3.1",
74+
"jest": "^29.7.0",
7575
"jest-cli": "^27.5.1",
7676
"lint-staged": "^12.3.7",
7777
"prettier": "^2.6.1",
@@ -80,10 +80,9 @@
8080
"react-dom": "19.0.0-beta-94eed63c49-20240425",
8181
"react-native": "0.69.3",
8282
"react-test-renderer": "19.0.0-beta-94eed63c49-20240425",
83-
"regenerator-runtime": "^0.13.9",
8483
"three": "^0.141.0",
8584
"three-stdlib": "^2.13.0",
86-
"ts-jest": "^27.1.4",
85+
"ts-jest": "^29.1.2",
8786
"typescript": "^4.6.3"
8887
},
8988
"dependencies": {}

Diff for: packages/fiber/src/core/store.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as THREE from 'three'
22
import * as React from 'react'
33
import { create, type StoreApi, type UseBoundStore } from 'zustand'
44
import type { DomEvent, EventManager, PointerCaptureTarget, ThreeEvent } from './events'
5-
import { calculateDpr, type Camera, isOrthographicCamera, prepare, updateCamera } from './utils'
5+
import { calculateDpr, type Camera, isOrthographicCamera, updateCamera } from './utils'
66
import type { FixedStage, Stage } from './stages'
77

88
export interface Intersection extends THREE.Intersection {

Diff for: packages/fiber/src/core/utils.tsx

+13-10
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ export const RESERVED_PROPS = [
313313
'dispose',
314314
]
315315

316-
export const DEFAULTS = new Map()
316+
const MEMOIZED_PROTOTYPES = new Map()
317317

318318
// This function prepares a set of changes to be applied to the instance
319319
export function diffProps<T = any>(
@@ -353,10 +353,10 @@ export function diffProps<T = any>(
353353
// For removed props, try to set default values, if possible
354354
if (root.constructor && root.constructor.length === 0) {
355355
// create a blank slate of the instance and copy the particular parameter.
356-
let ctor = DEFAULTS.get(root.constructor)
356+
let ctor = MEMOIZED_PROTOTYPES.get(root.constructor)
357357
if (!ctor) {
358358
ctor = new root.constructor()
359-
DEFAULTS.set(root.constructor, ctor)
359+
MEMOIZED_PROTOTYPES.set(root.constructor, ctor)
360360
}
361361
changedProps[key] = ctor[key]
362362
} else {
@@ -389,6 +389,8 @@ const colorMaps = [
389389
'envMap',
390390
]
391391

392+
const EVENT_REGEX = /^on(Pointer|Click|DoubleClick|ContextMenu|Wheel)/
393+
392394
// This function applies a set of changes to the instance
393395
export function applyProps<T = any>(object: Instance<T>['object'], props: Instance<T>['props']): Instance<T>['object'] {
394396
const instance = object.__r3f
@@ -402,13 +404,14 @@ export function applyProps<T = any>(object: Instance<T>['object'], props: Instan
402404
if (RESERVED_PROPS.includes(prop)) continue
403405

404406
// Deal with pointer events, including removing them if undefined
405-
if (instance && /^on(Pointer|Click|DoubleClick|ContextMenu|Wheel)/.test(prop)) {
407+
if (instance && EVENT_REGEX.test(prop)) {
406408
if (typeof value === 'function') instance.handlers[prop as keyof EventHandlers] = value as any
407409
else delete instance.handlers[prop as keyof EventHandlers]
408410
instance.eventCount = Object.keys(instance.handlers).length
409411
}
410412

411413
// Ignore setting undefined props
414+
// https://github.com/pmndrs/react-three-fiber/issues/274
412415
if (value === undefined) continue
413416

414417
let { root, key, target } = resolve(object, prop)
@@ -447,17 +450,15 @@ export function applyProps<T = any>(object: Instance<T>['object'], props: Instan
447450
if (target.fromArray) target.fromArray(value)
448451
else target.set(...value)
449452
}
450-
// Set literal types, ignore undefined
451-
// https://github.com/pmndrs/react-three-fiber/issues/274
453+
// Set literal types
452454
else if (target?.set && typeof value !== 'object') {
453455
const isColor = target instanceof THREE.Color
454456
// Allow setting array scalars
455457
if (!isColor && target.setScalar && typeof value === 'number') target.setScalar(value)
456-
// Otherwise just set ...
457-
else if (value !== undefined) target.set(value) // TODO: unreachable
458+
// Otherwise just set single value
459+
else target.set(value)
458460

459-
// For versions of three which don't support THREE.ColorManagement,
460-
// Auto-convert sRGB colors
461+
// Emulate THREE.ColorManagement for older three.js versions
461462
// https://github.com/pmndrs/react-three-fiber/issues/344
462463
if (!getColorManagement() && !rootState?.linear && isColor) target.convertSRGBToLinear()
463464
}
@@ -484,6 +485,7 @@ export function applyProps<T = any>(object: Instance<T>['object'], props: Instan
484485
}
485486
}
486487

488+
// Register event handlers
487489
if (
488490
instance?.parent &&
489491
rootState?.internal &&
@@ -505,6 +507,7 @@ export function applyProps<T = any>(object: Instance<T>['object'], props: Instan
505507
else if (instance.object instanceof THREE.Material) instance.props.attach = 'material'
506508
}
507509

510+
// Instance was updated, request a frame
508511
if (instance) invalidateInstance(instance)
509512

510513
return object

Diff for: packages/shared/setupTests.ts

-14
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import * as THREE from 'three'
22
import { WebGL2RenderingContext } from '@react-three/test-renderer/src/WebGL2RenderingContext'
33
import { extend } from '@react-three/fiber'
4-
import 'regenerator-runtime/runtime'
54

65
declare global {
76
var IS_REACT_ACT_ENVIRONMENT: boolean
@@ -12,19 +11,6 @@ declare global {
1211
global.IS_REACT_ACT_ENVIRONMENT = true
1312
global.IS_REACT_NATIVE_TEST_ENVIRONMENT = true // hide react-test-renderer warnings
1413

15-
// ESLint is broken atm -- TypeError: The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received 'http://localhost/eslintrc.cjs'
16-
jest.mock('eslint', () => ({
17-
RuleTester: class {
18-
run() {
19-
it.skip('RuleTester.run', () => {})
20-
}
21-
static only() {
22-
it.skip('RuleTester.only', () => {})
23-
return {}
24-
}
25-
},
26-
}))
27-
2814
// PointerEvent is not in JSDOM
2915
// https://github.com/jsdom/jsdom/pull/2666#issuecomment-691216178
3016
// https://w3c.github.io/pointerevents/#pointerevent-interface

Diff for: yarn.lock

+29-29
Original file line numberDiff line numberDiff line change
@@ -7040,7 +7040,7 @@ jest-snapshot@^29.7.0:
70407040
pretty-format "^29.7.0"
70417041
semver "^7.5.3"
70427042

7043-
jest-util@^27.0.0, jest-util@^27.5.1:
7043+
jest-util@^27.5.1:
70447044
version "27.5.1"
70457045
resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-27.5.1.tgz#3ba9771e8e31a0b85da48fe0b0891fb86c01c2f9"
70467046
integrity sha512-Kv2o/8jNvX1MQ0KGtw480E/w4fBCDOnH6+6DmeKi6LZUIlKA5kwY0YNdlzaWTiVgxqAqik11QyxDOKk543aKXw==
@@ -7052,7 +7052,7 @@ jest-util@^27.0.0, jest-util@^27.5.1:
70527052
graceful-fs "^4.2.9"
70537053
picomatch "^2.2.3"
70547054

7055-
jest-util@^29.7.0:
7055+
jest-util@^29.0.0, jest-util@^29.7.0:
70567056
version "29.7.0"
70577057
resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-29.7.0.tgz#23c2b62bfb22be82b44de98055802ff3710fc0bc"
70587058
integrity sha512-z6EbKajIpqGKU56y5KBUgy1dt1ihhQJgWzUlZHArA/+X2ad7Cb5iF+AK1EWVL/Bo7Rz9uurpqw6SiBCefUbCGA==
@@ -7155,7 +7155,7 @@ jest-worker@^29.7.0:
71557155
merge-stream "^2.0.0"
71567156
supports-color "^8.0.0"
71577157

7158-
jest@^29.3.1:
7158+
jest@^29.7.0:
71597159
version "29.7.0"
71607160
resolved "https://registry.yarnpkg.com/jest/-/jest-29.7.0.tgz#994676fc24177f088f1c5e3737f5697204ff2613"
71617161
integrity sha512-NIy3oAFp9shda19hy4HK0HRTWKtPJmGdnvywu01nOqNC2vZg+Z+fvJDxpMQA88eb2I9EcafcdjYgsDthnYTvGw==
@@ -7304,18 +7304,18 @@ json-stable-stringify-without-jsonify@^1.0.1:
73047304
resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651"
73057305
integrity sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==
73067306

7307-
[email protected], json5@^2.1.2, json5@^2.2.2, json5@^2.2.3:
7308-
version "2.2.3"
7309-
resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283"
7310-
integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==
7311-
73127307
json5@^1.0.2:
73137308
version "1.0.2"
73147309
resolved "https://registry.yarnpkg.com/json5/-/json5-1.0.2.tgz#63d98d60f21b313b77c4d6da18bfa69d80e1d593"
73157310
integrity sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==
73167311
dependencies:
73177312
minimist "^1.2.0"
73187313

7314+
json5@^2.1.2, json5@^2.2.2, json5@^2.2.3:
7315+
version "2.2.3"
7316+
resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283"
7317+
integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==
7318+
73197319
jsonfile@^2.1.0:
73207320
version "2.4.0"
73217321
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-2.4.0.tgz#3736a2b428b87bbda0cc83b53fa3d633a35c2ae8"
@@ -9161,7 +9161,7 @@ regenerate@^1.4.2:
91619161
resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.4.2.tgz#b9346d8827e8f5a32f7ba29637d398b69014848a"
91629162
integrity sha512-zrceR/XhGYU/d/opr2EKO7aRHUeiBI8qjtfHqADTwZd6Szfy16la6kqD0MIUs5z5hx6AaKa+PixpPrR289+I0A==
91639163

9164-
regenerator-runtime@^0.13.2, regenerator-runtime@^0.13.9:
9164+
regenerator-runtime@^0.13.2:
91659165
version "0.13.11"
91669166
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz#f6dca3e7ceec20590d07ada785636a90cdca17f9"
91679167
integrity sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==
@@ -9470,18 +9470,18 @@ [email protected]:
94709470
dependencies:
94719471
lru-cache "^6.0.0"
94729472

9473-
[email protected], semver@^7.3.2, semver@^7.3.4, semver@^7.3.7, semver@^7.5.3, semver@^7.5.4:
9473+
semver@^6.1.1, semver@^6.1.2, semver@^6.3.0, semver@^6.3.1:
9474+
version "6.3.1"
9475+
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4"
9476+
integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==
9477+
9478+
semver@^7.3.2, semver@^7.3.4, semver@^7.3.7, semver@^7.5.3, semver@^7.5.4:
94749479
version "7.6.0"
94759480
resolved "https://registry.yarnpkg.com/semver/-/semver-7.6.0.tgz#1a46a4db4bffcccd97b743b5005c8325f23d4e2d"
94769481
integrity sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==
94779482
dependencies:
94789483
lru-cache "^6.0.0"
94799484

9480-
semver@^6.1.1, semver@^6.1.2, semver@^6.3.0, semver@^6.3.1:
9481-
version "6.3.1"
9482-
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4"
9483-
integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==
9484-
94859485
94869486
version "0.18.0"
94879487
resolved "https://registry.yarnpkg.com/send/-/send-0.18.0.tgz#670167cc654b05f5aa4a767f9113bb371bc706be"
@@ -10310,19 +10310,19 @@ ts-interface-checker@^0.1.9:
1031010310
resolved "https://registry.yarnpkg.com/ts-interface-checker/-/ts-interface-checker-0.1.13.tgz#784fd3d679722bc103b1b4b8030bcddb5db2a699"
1031110311
integrity sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==
1031210312

10313-
ts-jest@^27.1.4:
10314-
version "27.1.5"
10315-
resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-27.1.5.tgz#0ddf1b163fbaae3d5b7504a1e65c914a95cff297"
10316-
integrity sha512-Xv6jBQPoBEvBq/5i2TeSG9tt/nqkbpcurrEG1b+2yfBrcJelOZF9Ml6dmyMh7bcW9JyFbRYpR5rxROSlBLTZHA==
10313+
ts-jest@^29.1.2:
10314+
version "29.1.2"
10315+
resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-29.1.2.tgz#7613d8c81c43c8cb312c6904027257e814c40e09"
10316+
integrity sha512-br6GJoH/WUX4pu7FbZXuWGKGNDuU7b8Uj77g/Sp7puZV6EXzuByl6JrECvm0MzVzSTkSHWTihsXt+5XYER5b+g==
1031710317
dependencies:
1031810318
bs-logger "0.x"
1031910319
fast-json-stable-stringify "2.x"
10320-
jest-util "^27.0.0"
10321-
json5 "2.x"
10320+
jest-util "^29.0.0"
10321+
json5 "^2.2.3"
1032210322
lodash.memoize "4.x"
1032310323
make-error "1.x"
10324-
semver "7.x"
10325-
yargs-parser "20.x"
10324+
semver "^7.5.3"
10325+
yargs-parser "^21.0.1"
1032610326

1032710327
ts-node@^10.9.1:
1032810328
version "10.9.2"
@@ -11025,11 +11025,6 @@ yaml@^1.10.2:
1102511025
resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.2.tgz#2301c5ffbf12b467de8da2333a459e29e7920e4b"
1102611026
integrity sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==
1102711027

11028-
[email protected], yargs-parser@^20.2.2:
11029-
version "20.2.9"
11030-
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.9.tgz#2eb7dc3b0289718fc295f362753845c41a0c94ee"
11031-
integrity sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==
11032-
1103311028
yargs-parser@^18.1.2, yargs-parser@^18.1.3:
1103411029
version "18.1.3"
1103511030
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-18.1.3.tgz#be68c4975c6b2abf469236b0c870362fab09a7b0"
@@ -11038,7 +11033,12 @@ yargs-parser@^18.1.2, yargs-parser@^18.1.3:
1103811033
camelcase "^5.0.0"
1103911034
decamelize "^1.2.0"
1104011035

11041-
yargs-parser@^21.1.1:
11036+
yargs-parser@^20.2.2:
11037+
version "20.2.9"
11038+
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.9.tgz#2eb7dc3b0289718fc295f362753845c41a0c94ee"
11039+
integrity sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==
11040+
11041+
yargs-parser@^21.0.1, yargs-parser@^21.1.1:
1104211042
version "21.1.1"
1104311043
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-21.1.1.tgz#9096bceebf990d21bb31fa9516e0ede294a77d35"
1104411044
integrity sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==

0 commit comments

Comments
 (0)