+34
-1
lines changedFilter options
+34
-1
lines changed Original file line number Diff line number Diff line change
@@ -15,7 +15,9 @@ const enum DevtoolsHooks {
15
15
COMPONENT_UPDATED = 'component:updated',
16
16
COMPONENT_ADDED = 'component:added',
17
17
COMPONENT_REMOVED = 'component:removed',
18
-
COMPONENT_EMIT = 'component:emit'
18
+
COMPONENT_EMIT = 'component:emit',
19
+
PERFORMANCE_START = 'perf:start',
20
+
PERFORMANCE_END = 'perf:end'
19
21
}
20
22
21
23
interface DevtoolsHook {
@@ -73,6 +75,28 @@ function createDevtoolsComponentHook(hook: DevtoolsHooks) {
73
75
}
74
76
}
75
77
78
+
export const devtoolsPerfStart = /*#__PURE__*/ createDevtoolsPerformanceHook(
79
+
DevtoolsHooks.PERFORMANCE_START
80
+
)
81
+
82
+
export const devtoolsPerfEnd = /*#__PURE__*/ createDevtoolsPerformanceHook(
83
+
DevtoolsHooks.PERFORMANCE_END
84
+
)
85
+
86
+
function createDevtoolsPerformanceHook(hook: DevtoolsHooks) {
87
+
return (component: ComponentInternalInstance, type: string, time: number) => {
88
+
if (!devtools) return
89
+
devtools.emit(
90
+
hook,
91
+
component.appContext.app,
92
+
component.uid,
93
+
component,
94
+
type,
95
+
time
96
+
)
97
+
}
98
+
}
99
+
76
100
export function devtoolsComponentEmit(
77
101
component: ComponentInternalInstance,
78
102
event: string,
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
1
1
import { ComponentInternalInstance, formatComponentName } from './component'
2
+
import { devtoolsPerfEnd, devtoolsPerfStart } from './devtools'
2
3
3
4
let supported: boolean
4
5
let perf: any
@@ -10,6 +11,10 @@ export function startMeasure(
10
11
if (instance.appContext.config.performance && isSupported()) {
11
12
perf.mark(`vue-${type}-${instance.uid}`)
12
13
}
14
+
15
+
if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) {
16
+
devtoolsPerfStart(instance, type, supported ? perf.now() : Date.now())
17
+
}
13
18
}
14
19
15
20
export function endMeasure(instance: ComponentInternalInstance, type: string) {
@@ -25,6 +30,10 @@ export function endMeasure(instance: ComponentInternalInstance, type: string) {
25
30
perf.clearMarks(startTag)
26
31
perf.clearMarks(endTag)
27
32
}
33
+
34
+
if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) {
35
+
devtoolsPerfEnd(instance, type, supported ? perf.now() : Date.now())
36
+
}
28
37
}
29
38
30
39
function isSupported() {
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4