@opensumi/ide-core-common 2.21.13 → 2.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (159) hide show
  1. package/lib/command.d.ts +15 -5
  2. package/lib/command.d.ts.map +1 -1
  3. package/lib/command.js +11 -1
  4. package/lib/command.js.map +1 -1
  5. package/lib/const/application.d.ts +6 -1
  6. package/lib/const/application.d.ts.map +1 -1
  7. package/lib/const/application.js +8 -3
  8. package/lib/const/application.js.map +1 -1
  9. package/lib/declare.d.ts +2 -2
  10. package/lib/declare.d.ts.map +1 -1
  11. package/lib/editor.d.ts +4 -0
  12. package/lib/editor.d.ts.map +1 -1
  13. package/lib/electron.d.ts +1 -1
  14. package/lib/electron.d.ts.map +1 -1
  15. package/lib/event-bus/event-bus-types.d.ts +1 -1
  16. package/lib/event-bus/event-bus-types.d.ts.map +1 -1
  17. package/lib/event-bus/event-bus.js.map +1 -1
  18. package/lib/event-bus/event-decorator.js.map +1 -1
  19. package/lib/extension.schema.d.ts +1 -1
  20. package/lib/extension.schema.d.ts.map +1 -1
  21. package/lib/hash-calculate/WASMInterface.d.ts +2 -2
  22. package/lib/hash-calculate/WASMInterface.d.ts.map +1 -1
  23. package/lib/hash-calculate/hash-calculate.js.map +1 -1
  24. package/lib/hash-calculate/util.d.ts +2 -2
  25. package/lib/hash-calculate/util.d.ts.map +1 -1
  26. package/lib/json-schema.d.ts +9 -0
  27. package/lib/json-schema.d.ts.map +1 -1
  28. package/lib/keyboard/keymap.d.ts +1 -1
  29. package/lib/keyboard/keymap.d.ts.map +1 -1
  30. package/lib/localize.d.ts +1 -1
  31. package/lib/localize.d.ts.map +1 -1
  32. package/lib/log.d.ts +2 -2
  33. package/lib/log.d.ts.map +1 -1
  34. package/lib/mime.d.ts +6 -6
  35. package/lib/module.js.map +1 -1
  36. package/lib/preferences/preference-schema.d.ts +13 -3
  37. package/lib/preferences/preference-schema.d.ts.map +1 -1
  38. package/lib/preferences/preference-schema.js +11 -1
  39. package/lib/preferences/preference-schema.js.map +1 -1
  40. package/lib/preferences/preference-scope.d.ts +8 -1
  41. package/lib/preferences/preference-scope.d.ts.map +1 -1
  42. package/lib/preferences/preference-scope.js +11 -2
  43. package/lib/preferences/preference-scope.js.map +1 -1
  44. package/lib/problem-matcher.d.ts +1 -1
  45. package/lib/problem-matcher.d.ts.map +1 -1
  46. package/lib/problem-matcher.js.map +1 -1
  47. package/lib/problem-pattern.d.ts +4 -2
  48. package/lib/problem-pattern.d.ts.map +1 -1
  49. package/lib/problem-pattern.js +24 -1
  50. package/lib/problem-pattern.js.map +1 -1
  51. package/lib/reference.d.ts +2 -1
  52. package/lib/reference.d.ts.map +1 -1
  53. package/lib/reference.js +11 -6
  54. package/lib/reference.js.map +1 -1
  55. package/lib/reporter.js.map +1 -1
  56. package/lib/storage.d.ts +1 -1
  57. package/lib/storage.d.ts.map +1 -1
  58. package/lib/storage.js.map +1 -1
  59. package/lib/task-definition.js.map +1 -1
  60. package/lib/types/common.d.ts +1 -1
  61. package/lib/types/common.d.ts.map +1 -1
  62. package/lib/types/editor.d.ts +2 -2
  63. package/lib/types/editor.d.ts.map +1 -1
  64. package/lib/types/file-watch.d.ts +1 -1
  65. package/lib/types/file-watch.d.ts.map +1 -1
  66. package/lib/types/markers/markers-manager.d.ts.map +1 -1
  67. package/lib/types/markers/markers-manager.js +4 -10
  68. package/lib/types/markers/markers-manager.js.map +1 -1
  69. package/lib/types/markers/markers.d.ts +2 -0
  70. package/lib/types/markers/markers.d.ts.map +1 -1
  71. package/lib/types/markers/markers.js.map +1 -1
  72. package/package.json +7 -6
  73. package/src/LifeCyclePhase.ts +6 -0
  74. package/src/application-error.ts +77 -0
  75. package/src/application-props.ts +28 -0
  76. package/src/application.lifecycle.ts +15 -0
  77. package/src/browser-fs/ensure-dir.ts +46 -0
  78. package/src/browser-fs/util.ts +52 -0
  79. package/src/clipboard.ts +31 -0
  80. package/src/command.ts +726 -0
  81. package/src/commands/terminal.ts +0 -0
  82. package/src/comparers.ts +152 -0
  83. package/src/connection.ts +7 -0
  84. package/src/const/application.ts +11 -0
  85. package/src/const/index.ts +1 -0
  86. package/src/contribution-provider.ts +47 -0
  87. package/src/credential.ts +21 -0
  88. package/src/crypto.ts +8 -0
  89. package/src/declare.ts +3 -0
  90. package/src/di-helper/domain-helper.ts +48 -0
  91. package/src/di-helper/index.ts +1 -0
  92. package/src/editor.ts +6 -0
  93. package/src/electron.ts +168 -0
  94. package/src/env.ts +1 -0
  95. package/src/event-bus/basic-event.ts +3 -0
  96. package/src/event-bus/event-bus-types.ts +68 -0
  97. package/src/event-bus/event-bus.ts +57 -0
  98. package/src/event-bus/event-decorator.ts +32 -0
  99. package/src/event-bus/index.ts +4 -0
  100. package/src/extension.schema.ts +16 -0
  101. package/src/hash-calculate/WASMInterface.ts +266 -0
  102. package/src/hash-calculate/hash-calculate.ts +53 -0
  103. package/src/hash-calculate/lockedCreate.ts +17 -0
  104. package/src/hash-calculate/md5.wasm.json +1 -0
  105. package/src/hash-calculate/mutex.ts +30 -0
  106. package/src/hash-calculate/util.ts +190 -0
  107. package/src/id-generator.ts +15 -0
  108. package/src/index.ts +39 -0
  109. package/src/json-schema.ts +80 -0
  110. package/src/keyboard/index.ts +2 -0
  111. package/src/keyboard/keyboard-layout-provider.ts +46 -0
  112. package/src/keyboard/keymap.ts +224 -0
  113. package/src/line-text.ts +93 -0
  114. package/src/localize.ts +203 -0
  115. package/src/log.ts +338 -0
  116. package/src/markdown.ts +8 -0
  117. package/src/menu.ts +31 -0
  118. package/src/mime.ts +8 -0
  119. package/src/mocks/electron/browserMock.ts +10 -0
  120. package/src/mocks/electron/ipcRenderer.ts +30 -0
  121. package/src/module.ts +31 -0
  122. package/src/network.ts +47 -0
  123. package/src/node/cli.ts +5 -0
  124. package/src/node/port.ts +134 -0
  125. package/src/preferences/index.ts +2 -0
  126. package/src/preferences/preference-schema.ts +122 -0
  127. package/src/preferences/preference-scope.ts +65 -0
  128. package/src/problem-matcher.ts +389 -0
  129. package/src/problem-pattern.ts +574 -0
  130. package/src/range.ts +24 -0
  131. package/src/reference.ts +141 -0
  132. package/src/reporter.ts +64 -0
  133. package/src/settings/general.ts +5 -0
  134. package/src/settings/index.ts +3 -0
  135. package/src/settings/search.ts +7 -0
  136. package/src/settings/terminal.ts +9 -0
  137. package/src/storage.ts +99 -0
  138. package/src/task-definition.ts +172 -0
  139. package/src/theme.ts +7 -0
  140. package/src/types/accessibility.ts +4 -0
  141. package/src/types/application.ts +14 -0
  142. package/src/types/authentication.ts +120 -0
  143. package/src/types/common.ts +14 -0
  144. package/src/types/dnd.ts +8 -0
  145. package/src/types/editor.ts +246 -0
  146. package/src/types/extension.ts +96 -0
  147. package/src/types/file-watch.ts +100 -0
  148. package/src/types/file.ts +262 -0
  149. package/src/types/index.ts +15 -0
  150. package/src/types/markdown.ts +10 -0
  151. package/src/types/markers/index.ts +2 -0
  152. package/src/types/markers/markers-manager.ts +392 -0
  153. package/src/types/markers/markers.ts +125 -0
  154. package/src/types/message.ts +6 -0
  155. package/src/types/reporter.ts +96 -0
  156. package/src/types/statusbar.ts +6 -0
  157. package/src/types/string.ts +3 -0
  158. package/src/utils/index.ts +1 -0
  159. package/src/utils/ipc.ts +28 -0
@@ -0,0 +1,246 @@
1
+ /* ---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License. See License.txt in the project root for license information.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ // Some code copied and modified from https://github.com/microsoft/vscode/blob/1.44.0/src/vs/editor/common/core/position.ts
6
+
7
+ import type { ILineChange } from '@opensumi/monaco-editor-core/esm/vs/editor/common/services/editorWorker';
8
+
9
+ export interface IRange {
10
+ // from 1
11
+ startLineNumber: number;
12
+
13
+ // from 1
14
+ startColumn: number;
15
+
16
+ endLineNumber: number;
17
+
18
+ endColumn: number;
19
+ }
20
+
21
+ export interface ISelection {
22
+ /**
23
+ * The line number on which the selection has started.
24
+ */
25
+ selectionStartLineNumber: number;
26
+ /**
27
+ * The column on `selectionStartLineNumber` where the selection has started.
28
+ */
29
+ selectionStartColumn: number;
30
+ /**
31
+ * The line number on which the selection has ended.
32
+ */
33
+ positionLineNumber: number;
34
+ /**
35
+ * The column on `positionLineNumber` where the selection has ended.
36
+ */
37
+ positionColumn: number;
38
+ }
39
+
40
+ /**
41
+ * A position in the editor. This interface is suitable for serialization.
42
+ */
43
+ export interface IPosition {
44
+ /**
45
+ * line number (starts at 1)
46
+ */
47
+ readonly lineNumber: number;
48
+ /**
49
+ * column (the first character in a line is between column 1 and column 2)
50
+ */
51
+ readonly column: number;
52
+ }
53
+
54
+ /**
55
+ * A position in the editor.
56
+ */
57
+ export class Position {
58
+ /**
59
+ * line number (starts at 1)
60
+ */
61
+ public readonly lineNumber: number;
62
+ /**
63
+ * column (the first character in a line is between column 1 and column 2)
64
+ */
65
+ public readonly column: number;
66
+
67
+ constructor(lineNumber: number, column: number) {
68
+ this.lineNumber = lineNumber;
69
+ this.column = column;
70
+ }
71
+
72
+ /**
73
+ * Create a new postion from this position.
74
+ *
75
+ * @param newLineNumber new line number
76
+ * @param newColumn new column
77
+ */
78
+ with(newLineNumber: number = this.lineNumber, newColumn: number = this.column): Position {
79
+ if (newLineNumber === this.lineNumber && newColumn === this.column) {
80
+ return this;
81
+ } else {
82
+ return new Position(newLineNumber, newColumn);
83
+ }
84
+ }
85
+
86
+ /**
87
+ * Derive a new position from this position.
88
+ *
89
+ * @param deltaLineNumber line number delta
90
+ * @param deltaColumn column delta
91
+ */
92
+ delta(deltaLineNumber = 0, deltaColumn = 0): Position {
93
+ return this.with(this.lineNumber + deltaLineNumber, this.column + deltaColumn);
94
+ }
95
+
96
+ /**
97
+ * Test if this position equals other position
98
+ */
99
+ public equals(other: IPosition): boolean {
100
+ return Position.equals(this, other);
101
+ }
102
+
103
+ /**
104
+ * Test if position `a` equals position `b`
105
+ */
106
+ public static equals(a: IPosition | null, b: IPosition | null): boolean {
107
+ if (!a && !b) {
108
+ return true;
109
+ }
110
+ return !!a && !!b && a.lineNumber === b.lineNumber && a.column === b.column;
111
+ }
112
+
113
+ /**
114
+ * Test if this position is before other position.
115
+ * If the two positions are equal, the result will be false.
116
+ */
117
+ public isBefore(other: IPosition): boolean {
118
+ return Position.isBefore(this, other);
119
+ }
120
+
121
+ /**
122
+ * Test if position `a` is before position `b`.
123
+ * If the two positions are equal, the result will be false.
124
+ */
125
+ public static isBefore(a: IPosition, b: IPosition): boolean {
126
+ if (a.lineNumber < b.lineNumber) {
127
+ return true;
128
+ }
129
+ if (b.lineNumber < a.lineNumber) {
130
+ return false;
131
+ }
132
+ return a.column < b.column;
133
+ }
134
+
135
+ /**
136
+ * Test if this position is before other position.
137
+ * If the two positions are equal, the result will be true.
138
+ */
139
+ public isBeforeOrEqual(other: IPosition): boolean {
140
+ return Position.isBeforeOrEqual(this, other);
141
+ }
142
+
143
+ /**
144
+ * Test if position `a` is before position `b`.
145
+ * If the two positions are equal, the result will be true.
146
+ */
147
+ public static isBeforeOrEqual(a: IPosition, b: IPosition): boolean {
148
+ if (a.lineNumber < b.lineNumber) {
149
+ return true;
150
+ }
151
+ if (b.lineNumber < a.lineNumber) {
152
+ return false;
153
+ }
154
+ return a.column <= b.column;
155
+ }
156
+
157
+ /**
158
+ * A function that compares positions, useful for sorting
159
+ */
160
+ public static compare(a: IPosition, b: IPosition): number {
161
+ const aLineNumber = a.lineNumber | 0;
162
+ const bLineNumber = b.lineNumber | 0;
163
+
164
+ if (aLineNumber === bLineNumber) {
165
+ const aColumn = a.column | 0;
166
+ const bColumn = b.column | 0;
167
+ return aColumn - bColumn;
168
+ }
169
+
170
+ return aLineNumber - bLineNumber;
171
+ }
172
+
173
+ /**
174
+ * Clone this position.
175
+ */
176
+ public clone(): Position {
177
+ return new Position(this.lineNumber, this.column);
178
+ }
179
+
180
+ /**
181
+ * Convert to a human-readable representation.
182
+ */
183
+ public toString(): string {
184
+ return '(' + this.lineNumber + ',' + this.column + ')';
185
+ }
186
+
187
+ // ---
188
+
189
+ /**
190
+ * Create a `Position` from an `IPosition`.
191
+ */
192
+ public static lift(pos: IPosition): Position {
193
+ return new Position(pos.lineNumber, pos.column);
194
+ }
195
+
196
+ /**
197
+ * Test if `obj` is an `IPosition`.
198
+ */
199
+ public static isIPosition(obj: any): obj is IPosition {
200
+ return obj && typeof obj.lineNumber === 'number' && typeof obj.column === 'number';
201
+ }
202
+ }
203
+
204
+ export interface IEditOperation {
205
+ range: IRange;
206
+ text: string;
207
+ }
208
+
209
+ export interface IEditorDocumentEditChange {
210
+ changes: IEditOperation[];
211
+ }
212
+
213
+ export interface IEditorDocumentEOLChange {
214
+ eol: '\n' | '\r\n';
215
+ }
216
+
217
+ export type IEditorDocumentChange = IEditorDocumentEditChange | IEditorDocumentEOLChange;
218
+
219
+ export function isEditChange(change: IEditorDocumentChange): change is IEditorDocumentEditChange {
220
+ return !!(change as IEditorDocumentEditChange).changes;
221
+ }
222
+
223
+ export const enum SaveTaskErrorCause {
224
+ CANCEL = 'cancel',
225
+ USE_BY_CONTENT = 'useByContent',
226
+ }
227
+
228
+ export enum SaveTaskResponseState {
229
+ ERROR = 'error',
230
+ SUCCESS = 'success',
231
+ DIFF = 'diff',
232
+ }
233
+
234
+ export type EditorDocumentModelSaveResultState = SaveTaskResponseState;
235
+
236
+ export interface IEditorDocumentModelSaveResult {
237
+ state: EditorDocumentModelSaveResultState;
238
+
239
+ errorMessage?: string;
240
+ }
241
+
242
+ export enum SymbolTag {
243
+ Deprecated = 1,
244
+ }
245
+
246
+ export { ILineChange };
@@ -0,0 +1,96 @@
1
+ import { Uri } from '@opensumi/ide-utils';
2
+
3
+ import { BasicEvent } from '../event-bus';
4
+
5
+ export class ExtensionCandidate {
6
+ path: string;
7
+ isBuiltin: boolean;
8
+ isDevelopment: boolean;
9
+ }
10
+
11
+ export enum ExtensionConnectModeOption {
12
+ 'TCP',
13
+ 'IPC',
14
+ }
15
+
16
+ /**
17
+ * 插件进程连接时候一些配置选项
18
+ */
19
+ export interface ExtensionConnectOption {
20
+ // 两种连接模式参考 nodejs net 模块
21
+ mode: ExtensionConnectModeOption;
22
+ // 如果 mode 为 TCP,字段表示套接字应连接到的主机地址,不传默认为'localhost'
23
+ host?: string;
24
+ }
25
+
26
+ /**
27
+ * 插件 browser 层的样式表配置项
28
+ */
29
+ export interface ExtensionBrowserStyleSheet {
30
+ componentUri: string;
31
+ iconfontUri: string;
32
+ }
33
+
34
+ /**
35
+ * 将插件路径转换为 ExtensionCandidate 对象
36
+ * @param extensionPath 插件路径
37
+ * @param isDevelopment 是否为开发模式下加载的插件
38
+ */
39
+ export function asExtensionCandidate(extensionPath: string, isDevelopment = false): ExtensionCandidate {
40
+ return { path: extensionPath, isBuiltin: true, isDevelopment };
41
+ }
42
+
43
+ export interface JSONType {
44
+ [key: string]: any;
45
+ }
46
+
47
+ export interface IExtensionInfo {
48
+ /**
49
+ * package.json 里的 publisher.name
50
+ * 用于插件之前的相互调用
51
+ */
52
+ readonly id: string;
53
+ /**
54
+ * 插件市场 id
55
+ */
56
+ readonly extensionId: string;
57
+ /**
58
+ * 是否为内置插件
59
+ */
60
+ readonly isBuiltin: boolean;
61
+
62
+ /**
63
+ * 是否为开发模式
64
+ */
65
+ readonly isDevelopment?: boolean;
66
+ }
67
+
68
+ export interface IExtensionProps extends IExtensionInfo {
69
+ readonly name: string;
70
+ readonly displayName?: string;
71
+ readonly activated: boolean;
72
+ readonly enabled: boolean;
73
+ readonly packageJSON: JSONType;
74
+ readonly defaultPkgNlsJSON: JSONType | undefined;
75
+ readonly packageNlsJSON: JSONType | undefined;
76
+ readonly path: string;
77
+ readonly realPath: string;
78
+ readonly extraMetadata: JSONType;
79
+ readonly extendConfig: JSONType;
80
+ readonly enableProposedApi: boolean;
81
+ readonly isUseEnable: boolean;
82
+ readonly extensionLocation: Uri;
83
+ workerVarId?: string;
84
+ workerScriptPath?: string;
85
+ }
86
+
87
+ export class ExtensionEnabledEvent extends BasicEvent<IExtensionProps> {}
88
+
89
+ export interface IExtensionActivateEventPayload {
90
+ topic: string;
91
+ data?: any;
92
+ }
93
+
94
+ export class ExtensionActivateEvent extends BasicEvent<IExtensionActivateEventPayload> {}
95
+
96
+ export class ExtensionDidContributes extends BasicEvent<void> {}
@@ -0,0 +1,100 @@
1
+ import { URI } from '@opensumi/ide-utils';
2
+ export interface IFileSystemWatcherServer {
3
+ /**
4
+ * 根据给定参数启动文件监听
5
+ * 返回对应watcher的id
6
+ * @param {string} uri
7
+ * @param {WatchOptions} [options]
8
+ * @returns {Promise<number>}
9
+ * @memberof IFileSystemWatcherServer
10
+ */
11
+ watchFileChanges(uri: string, options?: WatchOptions): Promise<number>;
12
+
13
+ /**
14
+ * 根据给定watcher的id注销对应的文件监听
15
+ * @param {number} watcher
16
+ * @returns {Promise<void>}
17
+ * @memberof FileSystemWatcherServer
18
+ */
19
+ unwatchFileChanges(watcher: number): Promise<void>;
20
+ }
21
+
22
+ export interface FileSystemWatcherClient {
23
+ /**
24
+ * 文件监听下的文件修改时触发事件
25
+ */
26
+ onDidFilesChanged(event: DidFilesChangedParams): void;
27
+ }
28
+
29
+ export interface WatchOptions {
30
+ excludes: string[];
31
+ }
32
+
33
+ export interface DidFilesChangedParams {
34
+ changes: FileChange[];
35
+ }
36
+
37
+ export interface FileChange {
38
+ uri: string;
39
+ type: FileChangeType;
40
+ }
41
+
42
+ export namespace FileChange {
43
+ export function isUpdated(change: FileChange, uri: URI): boolean {
44
+ return change.type === FileChangeType.UPDATED && uri.toString() === change.uri;
45
+ }
46
+ export function isAdded(change: FileChange, uri: URI): boolean {
47
+ return change.type === FileChangeType.ADDED && uri.toString() === change.uri;
48
+ }
49
+ export function isDeleted(change: FileChange, uri: URI): boolean {
50
+ return change.type === FileChangeType.DELETED && URI.file(change.uri).isEqualOrParent(uri);
51
+ }
52
+ export function isAffected(change: FileChange, uri: URI): boolean {
53
+ return isDeleted(change, uri) || uri.toString() === change.uri;
54
+ }
55
+ export function isChanged(change: FileChange, uri: URI): boolean {
56
+ return !isDeleted(change, uri) && uri.toString() === change.uri;
57
+ }
58
+ }
59
+
60
+ export type FileChangeEvent = FileChange[];
61
+ export namespace FileChangeEvent {
62
+ export function isUpdated(event: FileChangeEvent, uri: URI): boolean {
63
+ return event.some((change) => FileChange.isUpdated(change, uri));
64
+ }
65
+ export function isAdded(event: FileChangeEvent, uri: URI): boolean {
66
+ return event.some((change) => FileChange.isAdded(change, uri));
67
+ }
68
+ export function isDeleted(event: FileChangeEvent, uri: URI): boolean {
69
+ return event.some((change) => FileChange.isDeleted(change, uri));
70
+ }
71
+ export function isAffected(event: FileChangeEvent, uri: URI): boolean {
72
+ return event.some((change) => FileChange.isAffected(change, uri));
73
+ }
74
+ export function isChanged(event: FileChangeEvent, uri: URI): boolean {
75
+ return !isDeleted(event, uri) && event.some((change) => FileChange.isChanged(change, uri));
76
+ }
77
+ }
78
+
79
+ export enum FileChangeType {
80
+ UPDATED = 0,
81
+ ADDED = 1,
82
+ DELETED = 2,
83
+ }
84
+
85
+ export enum VSCFileChangeType {
86
+ /**
87
+ * The contents or metadata of a file have changed.
88
+ */
89
+ Changed = 1,
90
+
91
+ /**
92
+ * A file has been created.
93
+ */
94
+ Created = 2,
95
+
96
+ /**
97
+ * A file has been deleted.
98
+ */
99
+ Deleted = 3,
100
+ }
@@ -0,0 +1,262 @@
1
+ import { Event, Uri } from '@opensumi/ide-utils';
2
+
3
+ import { FileChangeEvent } from './file-watch';
4
+
5
+ export * from './file-watch';
6
+
7
+ /**
8
+ * @deprecated please import it from '@opensumi/ide-file-service/lib/common'
9
+ * `import { IFileServiceClient } from '@opensumi/ide-file-service/lib/common';`
10
+ */
11
+ export const IFileServiceClient = Symbol('IFileServiceClient');
12
+
13
+ export interface FileStat {
14
+ /**
15
+ * 资源路径
16
+ */
17
+ uri: string;
18
+
19
+ /**
20
+ * 资源最后修改时间
21
+ */
22
+ lastModification: number;
23
+
24
+ /**
25
+ * 资源的创建时间
26
+ */
27
+ createTime?: number;
28
+
29
+ /**
30
+ * 资源是否为文件夹
31
+ */
32
+ isDirectory: boolean;
33
+
34
+ /**
35
+ * 资源是否为软连接
36
+ */
37
+ isSymbolicLink?: boolean;
38
+
39
+ /**
40
+ * 资源是否在软连接文件夹内
41
+ */
42
+ isInSymbolicDirectory?: boolean;
43
+
44
+ /**
45
+ * The children of the file stat.
46
+ * If it is `undefined` and `isDirectory` is `true`, then this file stat is unresolved.
47
+ */
48
+ children?: FileStat[];
49
+
50
+ /**
51
+ * The size of the file if known.
52
+ */
53
+ size?: number;
54
+
55
+ /**
56
+ * 同 vscode FileType
57
+ */
58
+ type?: FileType;
59
+
60
+ /**
61
+ * 当前文件是否为只读
62
+ */
63
+ readonly?: boolean;
64
+ }
65
+
66
+ export namespace FileStat {
67
+ export function is(candidate: object | undefined): candidate is FileStat {
68
+ return (
69
+ typeof candidate === 'object' &&
70
+ 'uri' in candidate &&
71
+ 'lastModification' in candidate &&
72
+ 'isDirectory' in candidate
73
+ );
74
+ }
75
+
76
+ export function equals(one: object | undefined, other: object | undefined): boolean {
77
+ if (!one || !other || !is(one) || !is(other)) {
78
+ return false;
79
+ }
80
+ return (
81
+ one.uri === other.uri && one.lastModification === other.lastModification && one.isDirectory === other.isDirectory
82
+ );
83
+ }
84
+ }
85
+
86
+ /**
87
+ * Enumeration of file types. The types `File` and `Directory` can also be
88
+ * a symbolic links, in that use `FileType.File | FileType.SymbolicLink` and
89
+ * `FileType.Directory | FileType.SymbolicLink`.
90
+ */
91
+ export enum FileType {
92
+ /**
93
+ * The file type is unknown.
94
+ */
95
+ Unknown = 0,
96
+ /**
97
+ * A regular file.
98
+ */
99
+ File = 1,
100
+ /**
101
+ * A directory.
102
+ */
103
+ Directory = 2,
104
+ /**
105
+ * A symbolic link to a file.
106
+ */
107
+ SymbolicLink = 64,
108
+ }
109
+
110
+ /**
111
+ * Compatible with vscode.FileSystemProvider
112
+ */
113
+ export interface FileSystemProvider {
114
+ readonly capabilities: FileSystemProviderCapabilities;
115
+ readonly onDidChangeCapabilities: Event<void>;
116
+
117
+ readonly readonly?: boolean;
118
+ /**
119
+ * An event to signal that a resource has been created, changed, or deleted. This
120
+ * event should fire for resources that are being [watched](#FileSystemProvider.watch)
121
+ * by clients of this provider.
122
+ *
123
+ * as Event<vscode.FileChangeEvent[]>
124
+ */
125
+ readonly onDidChangeFile: Event<FileChangeEvent>;
126
+
127
+ /**
128
+ * Subscribe to events in the file or folder denoted by `uri`.
129
+ *
130
+ * The editor will call this function for files and folders. In the latter case, the
131
+ * options differ from defaults, e.g. what files/folders to exclude from watching
132
+ * and if subfolders, sub-subfolder, etc. should be watched (`recursive`).
133
+ *
134
+ * @param uri The uri of the file to be watched.
135
+ * @param options Configures the watch.
136
+ * @returns A disposable that tells the provider to stop watching the `uri`.
137
+ */
138
+ watch(uri: Uri, options: { excludes?: string[] }): number | Promise<number>;
139
+
140
+ unwatch?(watcherId: number): void | Promise<void>;
141
+
142
+ /**
143
+ * Retrieve metadata about a file.
144
+ *
145
+ * Note that the metadata for symbolic links should be the metadata of the file they refer to.
146
+ * Still, the [SymbolicLink](#FileType.SymbolicLink)-type must be used in addition to the actual type, e.g.
147
+ * `FileType.SymbolicLink | FileType.Directory`.
148
+ *
149
+ * @param uri The uri of the file to retrieve metadata about.
150
+ * @return The file metadata about the file.
151
+ * @throws [`FileNotFound`](#FileSystemError.FileNotFound) when `uri` doesn't exist.
152
+ */
153
+ stat(uri: Uri): Promise<FileStat | void>;
154
+
155
+ /**
156
+ * Retrieve all entries of a [directory](#FileType.Directory).
157
+ *
158
+ * @param uri The uri of the folder.
159
+ * @return An array of name/type-tuples or a thenable that resolves to such.
160
+ * @throws [`FileNotFound`](#FileSystemError.FileNotFound) when `uri` doesn't exist.
161
+ */
162
+ readDirectory(uri: Uri): [string, FileType][] | Promise<[string, FileType][]>;
163
+
164
+ /**
165
+ * Create a new directory (Note, that new files are created via `write`-calls).
166
+ *
167
+ * @param uri The uri of the new folder.
168
+ * @throws [`FileNotFound`](#FileSystemError.FileNotFound) when the parent of `uri` doesn't exist, e.g. no mkdirp-logic required.
169
+ * @throws [`FileExists`](#FileSystemError.FileExists) when `uri` already exists.
170
+ * @throws [`NoPermissions`](#FileSystemError.NoPermissions) when permissions aren't sufficient.
171
+ */
172
+ createDirectory(uri: Uri): void | Promise<void | FileStat>;
173
+
174
+ /**
175
+ * Read the entire contents of a file.
176
+ *
177
+ * @param uri The uri of the file.
178
+ * @return An array of bytes or a thenable that resolves to such.
179
+ * @throws [`FileNotFound`](#FileSystemError.FileNotFound) when `uri` doesn't exist.
180
+ */
181
+ readFile(uri: Uri, encoding?: string): Uint8Array | void | Promise<Uint8Array | void>;
182
+
183
+ /**
184
+ * Write data to a file, replacing its entire contents.
185
+ *
186
+ * @param uri The uri of the file.
187
+ * @param content The new content of the file.
188
+ * @param options Defines if missing files should or must be created.
189
+ * @throws [`FileNotFound`](#FileSystemError.FileNotFound) when `uri` doesn't exist and `create` is not set.
190
+ * @throws [`FileNotFound`](#FileSystemError.FileNotFound) when the parent of `uri` doesn't exist and `create` is set, e.g. no mkdirp-logic required.
191
+ * @throws [`FileExists`](#FileSystemError.FileExists) when `uri` already exists, `create` is set but `overwrite` is not set.
192
+ * @throws [`NoPermissions`](#FileSystemError.NoPermissions) when permissions aren't sufficient.
193
+ */
194
+ writeFile(
195
+ uri: Uri,
196
+ content: Uint8Array,
197
+ options: { create: boolean; overwrite: boolean; encoding?: string },
198
+ ): void | Thenable<void | FileStat>;
199
+
200
+ /**
201
+ * Delete a file.
202
+ *
203
+ * @param uri The resource that is to be deleted.
204
+ * @param options Defines if deletion of folders is recursive.
205
+ */
206
+ delete(uri: Uri, options: { recursive: boolean; moveToTrash?: boolean }): void | Promise<void>;
207
+
208
+ /**
209
+ * Rename a file or folder.
210
+ *
211
+ * @param oldstring The existing file.
212
+ * @param newstring The new location.
213
+ * @param options Defines if existing files should be overwritten.
214
+ * @throws [`FileNotFound`](#FileSystemError.FileNotFound) when `oldstring` doesn't exist.
215
+ * @throws [`FileNotFound`](#FileSystemError.FileNotFound) when parent of `newstring` doesn't exist, e.g. no mkdirp-logic required.
216
+ * @throws [`FileExists`](#FileSystemError.FileExists) when `newstring` exists and when the `overwrite` option is not `true`.
217
+ * @throws [`NoPermissions`](#FileSystemError.NoPermissions) when permissions aren't sufficient.
218
+ */
219
+ rename(oldstring: Uri, newstring: Uri, options: { overwrite: boolean }): void | Promise<void | FileStat>;
220
+ }
221
+
222
+ export const enum FileSystemProviderCapabilities {
223
+ /**
224
+ * Provider supports unbuffered read/write.
225
+ */
226
+ FileReadWrite = 1 << 1,
227
+
228
+ /**
229
+ * Provider supports open/read/write/close low level file operations.
230
+ */
231
+ FileOpenReadWriteClose = 1 << 2,
232
+
233
+ /**
234
+ * Provider supports stream based reading.
235
+ */
236
+ FileReadStream = 1 << 4,
237
+
238
+ /**
239
+ * Provider supports copy operation.
240
+ */
241
+ FileFolderCopy = 1 << 3,
242
+
243
+ /**
244
+ * Provider is path case sensitive.
245
+ */
246
+ PathCaseSensitive = 1 << 10,
247
+
248
+ /**
249
+ * All files of the provider are readonly.
250
+ */
251
+ Readonly = 1 << 11,
252
+
253
+ /**
254
+ * Provider supports to delete via trash.
255
+ */
256
+ Trash = 1 << 12,
257
+
258
+ /**
259
+ * Provider support to unlock files for writing.
260
+ */
261
+ FileWriteUnlock = 1 << 13,
262
+ }