From bf5db9eaa30b36a62d192339f525215e9f7714bd Mon Sep 17 00:00:00 2001 From: Guillaume Chau Date: Mon, 5 Feb 2024 12:16:33 +0100 Subject: [PATCH] feat: toggle timeline recording --- .../app-backend-core/src/timeline-marker.ts | 8 ++++- packages/app-backend-core/src/timeline.ts | 9 ++++++ .../src/features/timeline/Timeline.vue | 30 +++++++++++++++++++ packages/shared-utils/src/shared-data.ts | 2 ++ 4 files changed, 48 insertions(+), 1 deletion(-) diff --git a/packages/app-backend-core/src/timeline-marker.ts b/packages/app-backend-core/src/timeline-marker.ts index 95546fd82..8ac048e27 100644 --- a/packages/app-backend-core/src/timeline-marker.ts +++ b/packages/app-backend-core/src/timeline-marker.ts @@ -1,10 +1,13 @@ import type { BackendContext, TimelineMarker } from '@vue-devtools/app-backend-api' -import { BridgeEvents } from '@vue-devtools/shared-utils' +import { BridgeEvents, SharedData } from '@vue-devtools/shared-utils' import type { TimelineMarkerOptions } from '@vue/devtools-api' import { isPerformanceSupported } from '@vue/devtools-api' import { dateThreshold, perfTimeDiff } from './timeline' export async function addTimelineMarker(options: TimelineMarkerOptions, ctx: BackendContext) { + if (!SharedData.timelineRecording) { + return + } if (!ctx.currentAppRecord) { options.all = true } @@ -20,6 +23,9 @@ export async function addTimelineMarker(options: TimelineMarkerOptions, ctx: Bac } export async function sendTimelineMarkers(ctx: BackendContext) { + if (!SharedData.timelineRecording) { + return + } if (!ctx.currentAppRecord) { return } diff --git a/packages/app-backend-core/src/timeline.ts b/packages/app-backend-core/src/timeline.ts index 3d8fcbba8..b67b58eeb 100644 --- a/packages/app-backend-core/src/timeline.ts +++ b/packages/app-backend-core/src/timeline.ts @@ -138,6 +138,9 @@ export async function sendTimelineLayers(ctx: BackendContext) { } export async function addTimelineEvent(options: TimelineEventOptions, app: App, ctx: BackendContext) { + if (!SharedData.timelineRecording) { + return + } const appId = app ? getAppRecordId(app) : null const isAllApps = options.all || !app || appId == null @@ -195,6 +198,9 @@ export async function clearTimeline(ctx: BackendContext) { } export async function sendTimelineEventData(id: ID, ctx: BackendContext) { + if (!SharedData.timelineRecording) { + return + } let data = null const eventData = ctx.timelineEventMap.get(id) if (eventData) { @@ -224,6 +230,9 @@ export function removeLayersForApp(app: App, ctx: BackendContext) { } export function sendTimelineLayerEvents(appId: string, layerId: string, ctx: BackendContext) { + if (!SharedData.timelineRecording) { + return + } const app = ctx.appRecords.find(ar => ar.id === appId)?.options.app if (!app) { return diff --git a/packages/app-frontend/src/features/timeline/Timeline.vue b/packages/app-frontend/src/features/timeline/Timeline.vue index 64781441c..81f5b32f3 100644 --- a/packages/app-frontend/src/features/timeline/Timeline.vue +++ b/packages/app-frontend/src/features/timeline/Timeline.vue @@ -415,6 +415,18 @@ export default defineComponent({ + +
+ + +
+ Not recording +
+ @@ -595,4 +611,18 @@ export default defineComponent({ @apply w-3.5 h-3.5 mr-0 left-0 right-0 !important; } } + +.recording-btn { + :deep(.vue-ui-icon) { + @apply animate-pulse duration-1000; + + svg { + fill: theme('colors.red.500') !important; + } + } +} + +.recording-shadow { + box-shadow: theme('colors.red.500') 0 0 8px; +} diff --git a/packages/shared-utils/src/shared-data.ts b/packages/shared-utils/src/shared-data.ts index 1fa37b0bf..4987dbf44 100644 --- a/packages/shared-utils/src/shared-data.ts +++ b/packages/shared-utils/src/shared-data.ts @@ -22,6 +22,7 @@ const internalSharedData = { vuexAutoload: false, vuexGroupGettersByModule: true, showMenuScrollTip: true, + timelineRecording: false, timelineTimeGrid: true, timelineScreenshots: false, menuStepScrolling: isMac, @@ -49,6 +50,7 @@ const persisted = [ 'vuexGroupGettersByModule', 'timeFormat', 'showMenuScrollTip', + 'timelineRecording', 'timelineTimeGrid', 'timelineScreenshots', 'menuStepScrolling',