|
1 | 1 | import { BackendContext, AppRecord } from '@vue-devtools/app-backend-api' |
2 | 2 | import { BridgeEvents, HookEvents, stringify, SharedData } from '@vue-devtools/shared-utils' |
3 | | -import { App, ID, TimelineEventOptions, WithId, now } from '@vue/devtools-api' |
| 3 | +import { App, ID, TimelineEventOptions, WithId, now, isPerformanceSupported } from '@vue/devtools-api' |
4 | 4 | import { hook } from './global-hook' |
5 | 5 | import { getAppRecord, getAppRecordId } from './app' |
6 | 6 | import { builtinLayers } from './timeline-builtins' |
@@ -156,10 +156,18 @@ export async function addTimelineEvent (options: TimelineEventOptions, app: App, |
156 | 156 | } |
157 | 157 | } |
158 | 158 |
|
| 159 | +const initialTime = Date.now() |
| 160 | +export const dateThreshold = initialTime - 1_000_000 |
| 161 | +export const perfTimeDiff = initialTime - now() |
| 162 | + |
159 | 163 | function mapTimelineEvent (eventData: TimelineEventOptions & WithId) { |
| 164 | + let time = eventData.event.time |
| 165 | + if (isPerformanceSupported() && time < dateThreshold) { |
| 166 | + time += perfTimeDiff |
| 167 | + } |
160 | 168 | return { |
161 | 169 | id: eventData.id, |
162 | | - time: Math.round(eventData.event.time * 1000), |
| 170 | + time: Math.round(time * 1000), |
163 | 171 | logType: eventData.event.logType, |
164 | 172 | groupId: eventData.event.groupId, |
165 | 173 | title: eventData.event.title, |
|
0 commit comments