Skip to content

Commit b86e6f1

Browse files
committed
expose startCapture, endCapture
1 parent 8aab458 commit b86e6f1

1 file changed

Lines changed: 18 additions & 7 deletions

File tree

src/ui/main.tsx

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import ReactDOM from 'react-dom/client';
33
import App from './components/App/App';
44
import { uiStateHelper } from './contexts/UIStateContext';
5-
import { spector2 as capture } from '../capture';
5+
import { spector2 as capture, spector2 } from '../capture';
66

77
let initialized = false;
88

@@ -24,17 +24,28 @@ export async function captureFrame() {
2424
uiStateHelper.addTrace(trace);
2525
}
2626

27+
export function startCapture() {
28+
if (spector2.tracing) {
29+
throw new Error('already tracing');
30+
}
31+
spector2.startTracing();
32+
}
33+
34+
export async function endCapture() {
35+
if (!spector2.tracing) {
36+
throw new Error('not tracing');
37+
}
38+
const trace = spector2.endTracing();
39+
uiStateHelper.addTrace(trace);
40+
}
41+
2742
init();
2843
uiStateHelper.registerAPI({
2944
playTo(replay, id) {
3045
// TBD: reply the given 'replay' to the specified id
3146
console.log(replay, id);
3247
},
33-
startCapture() {
34-
// TBD: Capture until stop capture is called
35-
},
36-
endCapture() {
37-
// TBD: Stop Capturing
38-
},
48+
startCapture,
49+
endCapture,
3950
captureFrame,
4051
});

0 commit comments

Comments
 (0)