Skip to content

Commit bf5db9e

Browse files
committed
feat: toggle timeline recording
1 parent db49152 commit bf5db9e

File tree

4 files changed

+48
-1
lines changed

4 files changed

+48
-1
lines changed

packages/app-backend-core/src/timeline-marker.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import type { BackendContext, TimelineMarker } from '@vue-devtools/app-backend-api'
2-
import { BridgeEvents } from '@vue-devtools/shared-utils'
2+
import { BridgeEvents, SharedData } from '@vue-devtools/shared-utils'
33
import type { TimelineMarkerOptions } from '@vue/devtools-api'
44
import { isPerformanceSupported } from '@vue/devtools-api'
55
import { dateThreshold, perfTimeDiff } from './timeline'
66

77
export async function addTimelineMarker(options: TimelineMarkerOptions, ctx: BackendContext) {
8+
if (!SharedData.timelineRecording) {
9+
return
10+
}
811
if (!ctx.currentAppRecord) {
912
options.all = true
1013
}
@@ -20,6 +23,9 @@ export async function addTimelineMarker(options: TimelineMarkerOptions, ctx: Bac
2023
}
2124

2225
export async function sendTimelineMarkers(ctx: BackendContext) {
26+
if (!SharedData.timelineRecording) {
27+
return
28+
}
2329
if (!ctx.currentAppRecord) {
2430
return
2531
}

packages/app-backend-core/src/timeline.ts

+9
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@ export async function sendTimelineLayers(ctx: BackendContext) {
138138
}
139139

140140
export async function addTimelineEvent(options: TimelineEventOptions, app: App, ctx: BackendContext) {
141+
if (!SharedData.timelineRecording) {
142+
return
143+
}
141144
const appId = app ? getAppRecordId(app) : null
142145
const isAllApps = options.all || !app || appId == null
143146

@@ -195,6 +198,9 @@ export async function clearTimeline(ctx: BackendContext) {
195198
}
196199

197200
export async function sendTimelineEventData(id: ID, ctx: BackendContext) {
201+
if (!SharedData.timelineRecording) {
202+
return
203+
}
198204
let data = null
199205
const eventData = ctx.timelineEventMap.get(id)
200206
if (eventData) {
@@ -224,6 +230,9 @@ export function removeLayersForApp(app: App, ctx: BackendContext) {
224230
}
225231

226232
export function sendTimelineLayerEvents(appId: string, layerId: string, ctx: BackendContext) {
233+
if (!SharedData.timelineRecording) {
234+
return
235+
}
227236
const app = ctx.appRecords.find(ar => ar.id === appId)?.options.app
228237
if (!app) {
229238
return

packages/app-frontend/src/features/timeline/Timeline.vue

+30
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,18 @@ export default defineComponent({
415415
</div>
416416
</VueDropdown>
417417

418+
<VueButton
419+
v-tooltip="$shared.timelineRecording ? 'Stop recording' : 'Start recording'"
420+
class="icon-button flat"
421+
:class="{
422+
'recording-btn': $shared.timelineRecording,
423+
}"
424+
icon-left="fiber_manual_record"
425+
@click="$shared.timelineRecording = !$shared.timelineRecording"
426+
>
427+
<div v-if="$shared.timelineRecording" class="absolute inset-2.5 rounded-full recording-shadow" />
428+
</VueButton>
429+
418430
<VueButton
419431
v-tooltip="'Clear all timelines'"
420432
class="icon-button flat"
@@ -424,6 +436,10 @@ export default defineComponent({
424436

425437
<div class="flex-1" />
426438

439+
<div v-if="!$shared.timelineRecording" class="text-gray-500 dark:text-gray-400 text-xs px-2">
440+
Not recording
441+
</div>
442+
427443
<VueDropdown
428444
placement="bottom-end"
429445
>
@@ -595,4 +611,18 @@ export default defineComponent({
595611
@apply w-3.5 h-3.5 mr-0 left-0 right-0 !important;
596612
}
597613
}
614+
615+
.recording-btn {
616+
:deep(.vue-ui-icon) {
617+
@apply animate-pulse duration-1000;
618+
619+
svg {
620+
fill: theme('colors.red.500') !important;
621+
}
622+
}
623+
}
624+
625+
.recording-shadow {
626+
box-shadow: theme('colors.red.500') 0 0 8px;
627+
}
598628
</style>

packages/shared-utils/src/shared-data.ts

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const internalSharedData = {
2222
vuexAutoload: false,
2323
vuexGroupGettersByModule: true,
2424
showMenuScrollTip: true,
25+
timelineRecording: false,
2526
timelineTimeGrid: true,
2627
timelineScreenshots: false,
2728
menuStepScrolling: isMac,
@@ -49,6 +50,7 @@ const persisted = [
4950
'vuexGroupGettersByModule',
5051
'timeFormat',
5152
'showMenuScrollTip',
53+
'timelineRecording',
5254
'timelineTimeGrid',
5355
'timelineScreenshots',
5456
'menuStepScrolling',

0 commit comments

Comments
 (0)