Skip to content

Commit 6c81308

Browse files
committed
feat: polyfill performance and raf for perf tab
1 parent f70fdf0 commit 6c81308

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

index.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
11
const devtools = require('@vue/devtools');
22
const {isAndroid} = require('tns-core-modules/platform')
33

4+
if (!global.performance) {
5+
global.performance = {};
6+
}
7+
8+
if (!global.performance.now) {
9+
const nowOffset = Date.now();
10+
11+
global.performance.now = function now() {
12+
return Date.now() - nowOffset;
13+
}
14+
}
15+
16+
if (!global.requestAnimationFrame) {
17+
global.requestAnimationFrame = function raf(cb) {
18+
return setTimeout(cb, 1000 / 60)
19+
}
20+
}
21+
422
/**
523
* Returns the correct address for the host machine when running on emulator
624
* @param host
@@ -46,7 +64,7 @@ module.exports = function install(Vue, {debug = false, host = null, port = 8098}
4664
devtools.init(Vue);
4765
}
4866

49-
if(isAndroid) {
67+
if (isAndroid) {
5068
setupDevtools()
5169
} else {
5270
// on ios we need to delay the call because the socket connection is not established

0 commit comments

Comments
 (0)