forked from microsoft/vscode-copilot-chat
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogRecordingTypes.ts
More file actions
70 lines (48 loc) · 2.99 KB
/
logRecordingTypes.ts
File metadata and controls
70 lines (48 loc) · 2.99 KB
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
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
/// !!! NOTE: copied over from src/platform/workspaceRecorder/common/workspaceLog.ts
export type LogDocumentId = number;
export type LogEntry =
| HeaderLogEntry
| ApplicationStartLogEntry
| DocumentSetContentLogEntry
| DocumentStoreContentLogEntry
| DocumentRestoreContentLogEntry
| DocumentOpenedLogEntry
| DocumentClosedLogEntry
| DocumentChangedLogEntry
| DocumentFocusChangedLogEntry
| DocumentSelectionChangedLogEntry
| DocumentEncounteredLogEntry
| MetaLogEntry
| BookmarkLogEntry
| DocumentEventLogEntry
| EventLogEntry;
export type DocumentLogEntry = { id: LogDocumentId; time: number };
export namespace DocumentLogEntry {
export function is(entry: unknown): entry is DocumentLogEntry {
return !!entry && typeof entry === 'object' && 'id' in entry && 'time' in entry;
}
}
/** First entry of the log */
export type HeaderLogEntry = { documentType: "workspaceRecording@1.0"; kind: 'header'; repoRootUri: string; time: number; uuid: string };
export type ApplicationStartLogEntry = { kind: 'applicationStart'; time: number };
export type DocumentSetContentLogEntry = DocumentLogEntry & { kind: 'setContent'; content: string; /* if undefined, is 0 */ v: number | undefined };
export type DocumentStoreContentLogEntry = DocumentLogEntry & { kind: 'storeContent'; contentId: string; /* if undefined, is 0 */ v: number | undefined };
/** Can only restore from a content id set by any previous store content log entry */
export type DocumentRestoreContentLogEntry = DocumentLogEntry & { kind: 'restoreContent'; contentId: string; /* if undefined, is 0 */ v: number | undefined };
export type DocumentOpenedLogEntry = DocumentLogEntry & { kind: 'opened' };
export type DocumentClosedLogEntry = DocumentLogEntry & { kind: 'closed' };
export type DocumentChangedLogEntry = DocumentLogEntry & { kind: 'changed'; edit: ISerializedEdit; v: number };
export type DocumentFocusChangedLogEntry = DocumentLogEntry & { kind: 'focused' };
export type DocumentSelectionChangedLogEntry = DocumentLogEntry & { kind: 'selectionChanged'; selection: ISerializedOffsetRange[] };
export type DocumentEncounteredLogEntry = DocumentLogEntry & { kind: 'documentEncountered'; relativePath: string };
export type DocumentEventLogEntry = DocumentLogEntry & { kind: 'documentEvent'; data: unknown };
export type EventLogEntry = { kind: 'event'; time: number; data: unknown };
export type MetaLogEntry = { kind: 'meta'; data: unknown | { repoRootUri: string } };
export type BookmarkLogEntry = { kind: 'bookmark'; time: number };
// Edit functions
export type ISerializedOffsetRange = [start: number, endEx: number];
export type ISerializedEdit = [start: number, endEx: number, text: string][];