Debian Codegraph @

html_renderer/src/components/TimelineView.svelte

raw
1 <script lang="ts">
2 import { derived } from "svelte/store";
3 import Frame, { SELF_TIME_FRAME_IDENTIFIER } from "../lib/model/Frame";
4 import type Session from "../lib/model/Session";
5 import { applyProcessors } from "../lib/model/modelUtil";
6 import { viewOptionsTimeline } from "../lib/settings";
7 import TimelineCanvasView from "./TimelineCanvasView";
8 import { remove_first_pyinstrument_frames_processor, remove_importlib, remove_tracebackhide, type ProcessorOptions } from "../lib/model/processors";
9 import { onDestroy } from "svelte";
10
11 export let session: Session
12 const config = derived([viewOptionsTimeline], ([viewOptionsTimeline]) => {
13 const processors = [
14 viewOptionsTimeline.removeImportlib ? remove_importlib : null,
15 viewOptionsTimeline.removeTracebackHide ? remove_tracebackhide : null,
16 viewOptionsTimeline.removePyinstrument ? remove_first_pyinstrument_frames_processor : null,
17 ].filter(p => p !== null)
18 const options = {} as ProcessorOptions
19 return {processors, options}
20 })
21
22 let rootFrame: Frame|null
23 $: rootFrame = applyProcessors(session.rootFrame?.cloneDeep() ?? null, $config.processors, $config.options)
24
25 let rootElement: HTMLDivElement|null = null
26 let timelineCanvasView: TimelineCanvasView|null = null
27
28 $: if (rootElement) {
29 timelineCanvasView = new TimelineCanvasView(rootElement)
30 }
31 onDestroy(() => {
32 timelineCanvasView?.destroy()
33 })
34
35 $: if (rootFrame && timelineCanvasView) {
36 timelineCanvasView.setRootFrame(rootFrame)
37 }
38 </script>
39
40 <div class="timeline" bind:this={rootElement}>
41
42 </div>
43
44 <style lang="scss">
45 .timeline {
46 position: absolute;
47 top: 0;
48 bottom: 0;
49 left: 0;
50 right: 0;
51 overflow: hidden;
52 user-select: none;
53 }
54 </style>