Skip to content

Commit 52cac8d

Browse files
authored
Merge pull request #35 from react-spring/bugfix/node-performance-api
Bugfix/node performance api
2 parents 3d5556b + 4b6246e commit 52cac8d

File tree

4 files changed

+20
-7
lines changed

4 files changed

+20
-7
lines changed

dist/cannon-es.cjs.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13026,8 +13026,12 @@ var World = /*#__PURE__*/function (_EventTarget) {
1302613026
var tmpAABB1 = new AABB();
1302713027
var tmpRay$1 = new Ray(); // performance.now()
1302813028

13029-
if (typeof performance === 'undefined') {
13030-
performance = {};
13029+
var performance = {};
13030+
13031+
if (typeof window !== 'undefined') {
13032+
performance = window.performance;
13033+
} else {
13034+
performance = require('perf_hooks').performance;
1303113035
}
1303213036

1303313037
if (!performance.now) {

dist/cannon-es.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12194,8 +12194,12 @@ class World extends EventTarget {
1219412194
const tmpAABB1 = new AABB();
1219512195
const tmpRay$1 = new Ray(); // performance.now()
1219612196

12197-
if (typeof performance === 'undefined') {
12198-
performance = {};
12197+
let performance = {};
12198+
12199+
if (typeof window !== 'undefined') {
12200+
performance = window.performance;
12201+
} else {
12202+
performance = require('perf_hooks').performance;
1219912203
}
1220012204

1220112205
if (!performance.now) {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cannon-es",
3-
"version": "0.10.0",
3+
"version": "0.11.0",
44
"description": "A lightweight 3D physics engine written in JavaScript.",
55
"homepage": "https://github.com/schteppe/cannon.js",
66
"author": "Stefan Hedman <schteppe@gmail.com> (http://steffe.se)",

src/world/World.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -800,9 +800,14 @@ const tmpArray1 = []
800800
const tmpRay = new Ray()
801801

802802
// performance.now()
803-
if (typeof performance === 'undefined') {
804-
;(performance as any) = {}
803+
let performance = {} as Performance
804+
805+
if (typeof window !== 'undefined') {
806+
performance = window.performance
807+
} else {
808+
performance = require('perf_hooks').performance
805809
}
810+
806811
if (!performance.now) {
807812
let nowOffset = Date.now()
808813
if (performance.timing && performance.timing.navigationStart) {

0 commit comments

Comments
 (0)