File size: 2,704 Bytes
4d70170
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import type { Ref } from 'vue'
import { ref } from 'vue'
import type { ID } from '@vue/devtools-api'
import type * as PIXI from 'pixi.js-legacy'

export interface TimelineEventFromBackend {
  id: number
  time: number
  logType: 'default' | 'warning' | 'error'
  groupId: ID
  title: string
  subtitle: string
}

export interface EventGroup {
  id: ID
  events: TimelineEvent[]
  firstEvent: TimelineEvent
  lastEvent: TimelineEvent
  duration: number
  nonReactiveDuration: number
  y: number
  oldSize?: number
  oldSelected?: boolean
}

export interface EventScreenshot {
  id: number
  time: number
  image: string
  events: TimelineEvent[]
}

export interface TimelineEvent extends TimelineEventFromBackend {
  layer: Layer
  appId: string | 'all'
  group: EventGroup
  screenshot: EventScreenshot
  container: PIXI.Container
  g: PIXI.Graphics
  groupG: PIXI.Graphics
  groupT: PIXI.BitmapText
  groupText: string
  forcePositionUpdate?: boolean
}

export interface LayerFromBackend {
  id: string
  label: string
  color: number
  appId?: string
  pluginId?: string
  groupsOnly?: boolean
  skipScreenshots?: boolean
  ignoreNoDurationGroups?: boolean
}

export interface Layer extends LayerFromBackend {
  events: TimelineEvent[]
  eventsMap: Record<TimelineEvent['id'], TimelineEvent>
  groups: EventGroup[]
  groupsMap: Record<EventGroup['id'], EventGroup>
  groupPositionCache: Record<number, EventGroup[]>
  height: number
  newHeight: number
  lastInspectedEvent: TimelineEvent
  loaded: boolean
}

export interface MarkerFromBackend {
  id: string
  appId: string
  all?: boolean
  time: number
  label: string
  color: number
}

export interface TimelineMarker extends MarkerFromBackend {
  x: number
}

export const startTime = ref(0)
export const endTime = ref(0)
export const minTime = ref(0)
export const maxTime = ref(0)

export const timelineIsEmpty = ref(true)

export const cursorTime = ref<number>(null)

export const layersPerApp: Ref<{ [appId: string]: Layer[] }> = ref({})
export const hiddenLayersPerApp: Ref<{ [appId: string]: Layer['id'][] }> = ref({})
export const vScrollPerApp: Ref<{ [appId: string]: number }> = ref({})

export const selectedEvent: Ref<TimelineEvent> = ref(null)
export const selectedLayer: Ref<Layer> = ref(null)
export const hoverLayerId: Ref<Layer['id']> = ref(null)

export const inspectedEvent: Ref<TimelineEvent> = ref(null)
export const inspectedEventData = ref(null)
export const inspectedEventPendingId: Ref<TimelineEvent['id']> = ref(null)

export const screenshots: Ref<EventScreenshot[]> = ref([])

export const markersAllApps: Ref<TimelineMarker[]> = ref([])
export const markersPerApp: Ref<{ [appId: string]: TimelineMarker[] }> = ref({})