Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ulixee
GitHub Repository: ulixee/secret-agent
Path: blob/main/core/models/FocusEventsTable.ts
1028 views
1
import { Database as SqliteDatabase } from 'better-sqlite3';
2
import SqliteTable from '@secret-agent/commons/SqliteTable';
3
import { FocusEventType, IFocusEvent } from '@secret-agent/interfaces/IFocusEvent';
4
5
export default class FocusEventsTable extends SqliteTable<IFocusRecord> {
6
constructor(readonly db: SqliteDatabase) {
7
super(db, 'FocusEvents', [
8
['tabId', 'INTEGER'],
9
['frameId', 'INTEGER'],
10
['event', 'INTEGER'],
11
['targetNodeId', 'INTEGER'],
12
['relatedTargetNodeId', 'INTEGER'],
13
['timestamp', 'INTEGER'],
14
]);
15
}
16
17
public insert(tabId: number, frameId: number, commandId: number, focusEvent: IFocusEvent) {
18
const [type, targetNodeId, relatedTargetNodeId, timestamp] = focusEvent;
19
const record = [tabId, frameId, type, targetNodeId, relatedTargetNodeId, timestamp];
20
this.queuePendingInsert(record);
21
}
22
}
23
24
export interface IFocusRecord {
25
tabId: number;
26
frameId: number;
27
event: FocusEventType;
28
targetNodeId?: number;
29
relatedTargetNodeId?: number;
30
timestamp: number;
31
}
32
33