muon-ui 0.1.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.
- package/LICENSE +21 -0
- package/README.md +84 -0
- package/dist/build-CCuZpajl.cjs +2083 -0
- package/dist/build-CCuZpajl.cjs.map +1 -0
- package/dist/cli.cjs +122 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/index.cjs +9 -0
- package/dist/index.mjs +9 -0
- package/dist/native/linux64/muon-bootstrap +0 -0
- package/dist/native/linux64/muon-prepare +0 -0
- package/dist/native/linuxarm/muon-bootstrap +0 -0
- package/dist/native/linuxarm/muon-prepare +0 -0
- package/dist/native/linuxarm64/muon-bootstrap +0 -0
- package/dist/native/linuxarm64/muon-prepare +0 -0
- package/dist/native/windows32/muon-bootstrap.exe +0 -0
- package/dist/native/windows32/muon-prepare.exe +0 -0
- package/dist/native/windows64/muon-bootstrap.exe +0 -0
- package/dist/native/windows64/muon-prepare.exe +0 -0
- package/dist/runtime/linux64/THIRD_PARTY_NOTICES.md +223 -0
- package/dist/runtime/linux64/libcardio.so +0 -0
- package/dist/runtime/linux64/libmuon-ui.so +0 -0
- package/dist/runtime/linux64/muon-core +0 -0
- package/dist/runtime/linuxarm/THIRD_PARTY_NOTICES.md +223 -0
- package/dist/runtime/linuxarm/libcardio.so +0 -0
- package/dist/runtime/linuxarm/libmuon-ui.so +0 -0
- package/dist/runtime/linuxarm/muon-core +0 -0
- package/dist/runtime/linuxarm64/THIRD_PARTY_NOTICES.md +223 -0
- package/dist/runtime/linuxarm64/libcardio.so +0 -0
- package/dist/runtime/linuxarm64/libmuon-ui.so +0 -0
- package/dist/runtime/linuxarm64/muon-core +0 -0
- package/dist/runtime/windows32/THIRD_PARTY_NOTICES.md +223 -0
- package/dist/runtime/windows32/libcardio.dll +0 -0
- package/dist/runtime/windows32/libmuon-ui.dll +0 -0
- package/dist/runtime/windows32/muon-core.exe +0 -0
- package/dist/runtime/windows64/THIRD_PARTY_NOTICES.md +223 -0
- package/dist/runtime/windows64/libcardio.dll +0 -0
- package/dist/runtime/windows64/libmuon-ui.dll +0 -0
- package/dist/runtime/windows64/muon-core.exe +0 -0
- package/dist/vite.cjs +242 -0
- package/dist/vite.cjs.map +1 -0
- package/dist/vite.mjs +2251 -0
- package/dist/vite.mjs.map +1 -0
- package/images/muon-120.png +0 -0
- package/images/vscode.png +0 -0
- package/muon.d.ts +1039 -0
- package/package.json +91 -0
- package/vite.d.ts +98 -0
package/muon.d.ts
ADDED
|
@@ -0,0 +1,1039 @@
|
|
|
1
|
+
// muon - Multi-platform GUI application framework that uses CEF as its backend
|
|
2
|
+
// Copyright (c) Kouji Matsui. (@kekyo@mi.kekyo.net)
|
|
3
|
+
// Under MIT.
|
|
4
|
+
// https://github.com/kekyo/muon
|
|
5
|
+
|
|
6
|
+
export {};
|
|
7
|
+
|
|
8
|
+
declare global {
|
|
9
|
+
/** Browser window object extended with the Muon host API. */
|
|
10
|
+
interface Window {
|
|
11
|
+
/** Host APIs exposed by Muon to pages that pass the plugin allow policy. */
|
|
12
|
+
readonly muon: MuonApi;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** Host APIs exposed by Muon to the main page. */
|
|
16
|
+
interface MuonApi {
|
|
17
|
+
/** Browser and native window operations for the current Muon window. */
|
|
18
|
+
readonly browser: MuonBrowserApi;
|
|
19
|
+
/** Bootstrap update controls exposed by Muon. */
|
|
20
|
+
readonly bootstrap: MuonBootstrapApi;
|
|
21
|
+
/** Environment information exposed by Muon. */
|
|
22
|
+
readonly environments: MuonEnvironmentsApi;
|
|
23
|
+
/** Child process execution operations exposed by Muon. */
|
|
24
|
+
readonly executor: MuonExecutorApi;
|
|
25
|
+
/** Filesystem operations exposed by the built-in Muon filesystem plugin. */
|
|
26
|
+
readonly fs: MuonFsApi;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** CEF version selection policy used by muon-bootstrap. */
|
|
30
|
+
type MuonCefVersionPolicy =
|
|
31
|
+
| "tested"
|
|
32
|
+
| "same-major-latest"
|
|
33
|
+
| "compat-latest"
|
|
34
|
+
| "exact";
|
|
35
|
+
|
|
36
|
+
/** Bootstrap settings used on the next muon-bootstrap startup. */
|
|
37
|
+
interface MuonBootstrapSettings {
|
|
38
|
+
/** CEF version selection policy. */
|
|
39
|
+
readonly cefVersionPolicy?: MuonCefVersionPolicy;
|
|
40
|
+
/** Exact CEF version used when cefVersionPolicy is exact. */
|
|
41
|
+
readonly cefExactVersion?: string;
|
|
42
|
+
/** Minimum seconds between automatic CEF catalog refresh attempts. */
|
|
43
|
+
readonly catalogRefreshIntervalSeconds?: number;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Partial bootstrap settings update. */
|
|
47
|
+
interface MuonBootstrapSettingsPatch {
|
|
48
|
+
/** CEF version selection policy, or null to use defaultVersionPolicy. */
|
|
49
|
+
readonly cefVersionPolicy?: MuonCefVersionPolicy | null;
|
|
50
|
+
/** Exact CEF version used when cefVersionPolicy is exact, or null to clear. */
|
|
51
|
+
readonly cefExactVersion?: string | null;
|
|
52
|
+
/** Minimum seconds between automatic CEF catalog refresh attempts, or null to use the default. */
|
|
53
|
+
readonly catalogRefreshIntervalSeconds?: number | null;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Bootstrap update controls exposed by Muon. */
|
|
57
|
+
interface MuonBootstrapApi {
|
|
58
|
+
/**
|
|
59
|
+
* Return bootstrap settings used by the next muon-bootstrap startup.
|
|
60
|
+
*
|
|
61
|
+
* @returns A promise for the effective bootstrap settings.
|
|
62
|
+
*/
|
|
63
|
+
readonly getSettings: () => Promise<MuonBootstrapSettings>;
|
|
64
|
+
/**
|
|
65
|
+
* Update bootstrap settings used by the next muon-bootstrap startup.
|
|
66
|
+
*
|
|
67
|
+
* @param settings - Partial settings to persist. Null values clear explicit settings.
|
|
68
|
+
* @returns A promise that resolves when settings are written.
|
|
69
|
+
*/
|
|
70
|
+
readonly setSettings: (
|
|
71
|
+
settings?: MuonBootstrapSettingsPatch,
|
|
72
|
+
) => Promise<void>;
|
|
73
|
+
/**
|
|
74
|
+
* Request a CEF catalog refresh on the next muon-bootstrap startup.
|
|
75
|
+
*
|
|
76
|
+
* @returns A promise that resolves when the refresh request is persisted.
|
|
77
|
+
*/
|
|
78
|
+
readonly triggerUpdate: () => Promise<void>;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Browser and native window operations for the current Muon window. */
|
|
82
|
+
interface MuonBrowserApi {
|
|
83
|
+
/**
|
|
84
|
+
* Reload the current page.
|
|
85
|
+
*
|
|
86
|
+
* @returns A promise that resolves after the reload request is submitted.
|
|
87
|
+
* @remarks The page context can be destroyed by navigation before callers
|
|
88
|
+
* can observe promise settlement.
|
|
89
|
+
*/
|
|
90
|
+
readonly reload: () => Promise<void>;
|
|
91
|
+
/**
|
|
92
|
+
* Reload the current page while ignoring cached data.
|
|
93
|
+
*
|
|
94
|
+
* @returns A promise that resolves after the hard reload request is submitted.
|
|
95
|
+
* @remarks The page context can be destroyed by navigation before callers
|
|
96
|
+
* can observe promise settlement.
|
|
97
|
+
*/
|
|
98
|
+
readonly hardReload: () => Promise<void>;
|
|
99
|
+
/**
|
|
100
|
+
* Toggle fullscreen mode for the current browser window.
|
|
101
|
+
*
|
|
102
|
+
* @returns A promise that resolves when the fullscreen toggle is requested.
|
|
103
|
+
*/
|
|
104
|
+
readonly toggleFullscreen: () => Promise<void>;
|
|
105
|
+
/**
|
|
106
|
+
* Enter fullscreen mode for the current browser window.
|
|
107
|
+
*
|
|
108
|
+
* @returns A promise that resolves when fullscreen mode is requested.
|
|
109
|
+
*/
|
|
110
|
+
readonly enterFullscreen: () => Promise<void>;
|
|
111
|
+
/**
|
|
112
|
+
* Exit fullscreen mode for the current browser window.
|
|
113
|
+
*
|
|
114
|
+
* @returns A promise that resolves when leaving fullscreen is requested.
|
|
115
|
+
*/
|
|
116
|
+
readonly exitFullscreen: () => Promise<void>;
|
|
117
|
+
/**
|
|
118
|
+
* Increase the current page zoom level.
|
|
119
|
+
*
|
|
120
|
+
* @returns A promise that resolves when the zoom change is requested.
|
|
121
|
+
*/
|
|
122
|
+
readonly zoomIn: () => Promise<void>;
|
|
123
|
+
/**
|
|
124
|
+
* Decrease the current page zoom level.
|
|
125
|
+
*
|
|
126
|
+
* @returns A promise that resolves when the zoom change is requested.
|
|
127
|
+
*/
|
|
128
|
+
readonly zoomOut: () => Promise<void>;
|
|
129
|
+
/**
|
|
130
|
+
* Reset the current page zoom level.
|
|
131
|
+
*
|
|
132
|
+
* @returns A promise that resolves when the zoom reset is requested.
|
|
133
|
+
*/
|
|
134
|
+
readonly resetZoom: () => Promise<void>;
|
|
135
|
+
/**
|
|
136
|
+
* Show the current browser window.
|
|
137
|
+
*
|
|
138
|
+
* @returns A promise that resolves when showing the window is requested.
|
|
139
|
+
*/
|
|
140
|
+
readonly show: () => Promise<void>;
|
|
141
|
+
/**
|
|
142
|
+
* Hide the current browser window.
|
|
143
|
+
*
|
|
144
|
+
* @returns A promise that resolves when hiding the window is requested.
|
|
145
|
+
*/
|
|
146
|
+
readonly hide: () => Promise<void>;
|
|
147
|
+
/**
|
|
148
|
+
* Focus and activate the current browser window.
|
|
149
|
+
*
|
|
150
|
+
* @returns A promise that resolves when focusing the window is requested.
|
|
151
|
+
*/
|
|
152
|
+
readonly focus: () => Promise<void>;
|
|
153
|
+
/**
|
|
154
|
+
* Deactivate the current browser window.
|
|
155
|
+
*
|
|
156
|
+
* @returns A promise that resolves when blurring the window is requested.
|
|
157
|
+
*/
|
|
158
|
+
readonly blur: () => Promise<void>;
|
|
159
|
+
/**
|
|
160
|
+
* Minimize the current browser window.
|
|
161
|
+
*
|
|
162
|
+
* @returns A promise that resolves when minimizing the window is requested.
|
|
163
|
+
*/
|
|
164
|
+
readonly minimize: () => Promise<void>;
|
|
165
|
+
/**
|
|
166
|
+
* Maximize the current browser window.
|
|
167
|
+
*
|
|
168
|
+
* @returns A promise that resolves when maximizing the window is requested.
|
|
169
|
+
*/
|
|
170
|
+
readonly maximize: () => Promise<void>;
|
|
171
|
+
/**
|
|
172
|
+
* Restore the current browser window from minimized or maximized state.
|
|
173
|
+
*
|
|
174
|
+
* @returns A promise that resolves when restoring the window is requested.
|
|
175
|
+
*/
|
|
176
|
+
readonly restore: () => Promise<void>;
|
|
177
|
+
/**
|
|
178
|
+
* Close the current browser window.
|
|
179
|
+
*
|
|
180
|
+
* @returns A promise that resolves after the close request is submitted.
|
|
181
|
+
* @remarks Modal filesystem dialogs owned by this browser are aborted before
|
|
182
|
+
* closing. The page context can be destroyed before callers can observe
|
|
183
|
+
* promise settlement.
|
|
184
|
+
*/
|
|
185
|
+
readonly close: () => Promise<void>;
|
|
186
|
+
/**
|
|
187
|
+
* Shut down the Muon process.
|
|
188
|
+
*
|
|
189
|
+
* @param exitCode - Process exit code. Omit to use `0`.
|
|
190
|
+
* @returns A promise that resolves after the shutdown request is submitted.
|
|
191
|
+
*/
|
|
192
|
+
readonly shutdown: (exitCode?: number) => Promise<void>;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Filesystem operations exposed by the built-in Muon filesystem plugin.
|
|
197
|
+
*
|
|
198
|
+
* @remarks Linux accepts local paths or GIO/GVfs URI values for filesystem
|
|
199
|
+
* location arguments. Other platforms accept local filesystem paths.
|
|
200
|
+
*/
|
|
201
|
+
interface MuonFsApi {
|
|
202
|
+
/**
|
|
203
|
+
* Read a file as binary data.
|
|
204
|
+
*
|
|
205
|
+
* @param path - Filesystem path, or a URI on Linux, to read.
|
|
206
|
+
* @param options - Optional read range and abort signal.
|
|
207
|
+
* @returns A promise for an `ArrayBuffer` containing the selected bytes.
|
|
208
|
+
* @remarks `options.position` and `options.length` must be non-negative
|
|
209
|
+
* safe integers. When `position` is past the end of the file, the returned
|
|
210
|
+
* buffer is empty.
|
|
211
|
+
*/
|
|
212
|
+
readonly readFile: (
|
|
213
|
+
path: string,
|
|
214
|
+
options?: MuonFsReadFileOptions,
|
|
215
|
+
) => Promise<ArrayBuffer>;
|
|
216
|
+
/**
|
|
217
|
+
* Write binary data to a file.
|
|
218
|
+
*
|
|
219
|
+
* @param path - Filesystem path, or a URI on Linux, to write.
|
|
220
|
+
* @param data - Binary data to write.
|
|
221
|
+
* @param options - Optional write offset and abort signal.
|
|
222
|
+
* @returns A promise that resolves when the write completes.
|
|
223
|
+
* @remarks Omitting `options.position` replaces the whole file. Supplying
|
|
224
|
+
* `options.position` writes at that byte offset and creates the file when it
|
|
225
|
+
* does not exist.
|
|
226
|
+
*/
|
|
227
|
+
readonly writeFile: (
|
|
228
|
+
path: string,
|
|
229
|
+
data: BufferSource,
|
|
230
|
+
options?: MuonFsWriteFileOptions,
|
|
231
|
+
) => Promise<void>;
|
|
232
|
+
/**
|
|
233
|
+
* Read a UTF-8 text file.
|
|
234
|
+
*
|
|
235
|
+
* @param path - Filesystem path, or a URI on Linux, to read.
|
|
236
|
+
* @param encoding - Text encoding. Only `"utf8"` and `"utf-8"` are supported.
|
|
237
|
+
* @param options - Optional abort signal.
|
|
238
|
+
* @returns A promise for the decoded text.
|
|
239
|
+
* @remarks The file must contain valid UTF-8 text without NUL bytes.
|
|
240
|
+
*/
|
|
241
|
+
readonly readTextFile: (
|
|
242
|
+
path: string,
|
|
243
|
+
encoding: "utf8" | "utf-8",
|
|
244
|
+
options?: MuonFsOperationOptions,
|
|
245
|
+
) => Promise<string>;
|
|
246
|
+
/**
|
|
247
|
+
* Write a UTF-8 text file.
|
|
248
|
+
*
|
|
249
|
+
* @param path - Filesystem path, or a URI on Linux, to write.
|
|
250
|
+
* @param data - Text to write.
|
|
251
|
+
* @param encoding - Text encoding. Only `"utf8"` and `"utf-8"` are supported.
|
|
252
|
+
* @param options - Optional abort signal.
|
|
253
|
+
* @returns A promise that resolves when the write completes.
|
|
254
|
+
* @remarks The whole file is replaced.
|
|
255
|
+
*/
|
|
256
|
+
readonly writeTextFile: (
|
|
257
|
+
path: string,
|
|
258
|
+
data: string,
|
|
259
|
+
encoding: "utf8" | "utf-8",
|
|
260
|
+
options?: MuonFsOperationOptions,
|
|
261
|
+
) => Promise<void>;
|
|
262
|
+
/**
|
|
263
|
+
* Return metadata for a path, following symbolic links.
|
|
264
|
+
*
|
|
265
|
+
* @param path - Filesystem path, or a URI on Linux, to inspect.
|
|
266
|
+
* @param options - Optional abort signal.
|
|
267
|
+
* @returns A promise for filesystem metadata.
|
|
268
|
+
* @remarks Rejects when the path does not exist.
|
|
269
|
+
*/
|
|
270
|
+
readonly stat: (
|
|
271
|
+
path: string,
|
|
272
|
+
options?: MuonFsOperationOptions,
|
|
273
|
+
) => Promise<MuonFsStats>;
|
|
274
|
+
/**
|
|
275
|
+
* Return metadata for a path without following symbolic links.
|
|
276
|
+
*
|
|
277
|
+
* @param path - Filesystem path, or a URI on Linux, to inspect.
|
|
278
|
+
* @param options - Optional abort signal.
|
|
279
|
+
* @returns A promise for filesystem metadata.
|
|
280
|
+
* @remarks A symbolic link is reported as type `"symlink"` instead of the
|
|
281
|
+
* target entry type.
|
|
282
|
+
*/
|
|
283
|
+
readonly lstat: (
|
|
284
|
+
path: string,
|
|
285
|
+
options?: MuonFsOperationOptions,
|
|
286
|
+
) => Promise<MuonFsStats>;
|
|
287
|
+
/**
|
|
288
|
+
* Return whether a path exists.
|
|
289
|
+
*
|
|
290
|
+
* @param path - Filesystem path, or a URI on Linux, to check.
|
|
291
|
+
* @param options - Optional abort signal.
|
|
292
|
+
* @returns A promise for `true` when the path exists and can be inspected.
|
|
293
|
+
* @remarks Filesystem errors are reported as `false`.
|
|
294
|
+
*/
|
|
295
|
+
readonly exists: (
|
|
296
|
+
path: string,
|
|
297
|
+
options?: MuonFsOperationOptions,
|
|
298
|
+
) => Promise<boolean>;
|
|
299
|
+
/**
|
|
300
|
+
* Return whether a path is accessible for the requested modes.
|
|
301
|
+
*
|
|
302
|
+
* @param path - Filesystem path, or a URI on Linux, to check.
|
|
303
|
+
* @param options - Optional access modes and abort signal.
|
|
304
|
+
* @returns A promise for `true` when all requested modes are allowed.
|
|
305
|
+
* @remarks Omitting `options.mode` checks existence only. Permission checks
|
|
306
|
+
* are based on filesystem permission bits.
|
|
307
|
+
*/
|
|
308
|
+
readonly access: (
|
|
309
|
+
path: string,
|
|
310
|
+
options?: MuonFsAccessOptions,
|
|
311
|
+
) => Promise<boolean>;
|
|
312
|
+
/**
|
|
313
|
+
* Read directory entry names.
|
|
314
|
+
*
|
|
315
|
+
* @param path - Directory path, or a URI on Linux, to read.
|
|
316
|
+
* @param options - Optional directory read options and abort signal.
|
|
317
|
+
* @returns A promise for entry names relative to `path`.
|
|
318
|
+
* @remarks This overload is selected when `withFileTypes` is omitted or false.
|
|
319
|
+
*/
|
|
320
|
+
readdir(
|
|
321
|
+
path: string,
|
|
322
|
+
options?: MuonFsReadDirectoryOptions & { withFileTypes?: false },
|
|
323
|
+
): Promise<string[]>;
|
|
324
|
+
/**
|
|
325
|
+
* Read directory entries with metadata helpers.
|
|
326
|
+
*
|
|
327
|
+
* @param path - Directory path, or a URI on Linux, to read.
|
|
328
|
+
* @param options - Directory read options with `withFileTypes: true`.
|
|
329
|
+
* @returns A promise for directory entries with metadata helper methods.
|
|
330
|
+
*/
|
|
331
|
+
readdir(
|
|
332
|
+
path: string,
|
|
333
|
+
options: MuonFsReadDirectoryOptions & { withFileTypes: true },
|
|
334
|
+
): Promise<MuonFsDirent[]>;
|
|
335
|
+
/**
|
|
336
|
+
* Create a directory.
|
|
337
|
+
*
|
|
338
|
+
* @param path - Directory path, or a URI on Linux, to create.
|
|
339
|
+
* @param options - Optional recursive flag and abort signal.
|
|
340
|
+
* @returns A promise that resolves when the directory is created.
|
|
341
|
+
* @remarks With `recursive: false` or omitted, rejects if the path already
|
|
342
|
+
* exists or a parent is missing.
|
|
343
|
+
*/
|
|
344
|
+
readonly mkdir: (
|
|
345
|
+
path: string,
|
|
346
|
+
options?: MuonFsMakeDirectoryOptions,
|
|
347
|
+
) => Promise<void>;
|
|
348
|
+
/**
|
|
349
|
+
* Remove a file or directory.
|
|
350
|
+
*
|
|
351
|
+
* @param path - Filesystem path, or a URI on Linux, to remove.
|
|
352
|
+
* @param options - Optional recursive, force, and abort options.
|
|
353
|
+
* @returns A promise that resolves when removal completes.
|
|
354
|
+
* @remarks Directories require `recursive: true`. `force: true` suppresses a
|
|
355
|
+
* missing-path error.
|
|
356
|
+
*/
|
|
357
|
+
readonly rm: (path: string, options?: MuonFsRemoveOptions) => Promise<void>;
|
|
358
|
+
/**
|
|
359
|
+
* Remove a file or symbolic link.
|
|
360
|
+
*
|
|
361
|
+
* @param path - File or symbolic link path, or a URI on Linux, to remove.
|
|
362
|
+
* @param options - Optional abort signal.
|
|
363
|
+
* @returns A promise that resolves when removal completes.
|
|
364
|
+
* @remarks Rejects when `path` is a directory.
|
|
365
|
+
*/
|
|
366
|
+
readonly unlink: (
|
|
367
|
+
path: string,
|
|
368
|
+
options?: MuonFsOperationOptions,
|
|
369
|
+
) => Promise<void>;
|
|
370
|
+
/**
|
|
371
|
+
* Remove an empty directory.
|
|
372
|
+
*
|
|
373
|
+
* @param path - Directory path, or a URI on Linux, to remove.
|
|
374
|
+
* @param options - Optional abort signal.
|
|
375
|
+
* @returns A promise that resolves when the directory is removed.
|
|
376
|
+
* @remarks Rejects when `path` is not an empty directory.
|
|
377
|
+
*/
|
|
378
|
+
readonly rmdir: (
|
|
379
|
+
path: string,
|
|
380
|
+
options?: MuonFsOperationOptions,
|
|
381
|
+
) => Promise<void>;
|
|
382
|
+
/**
|
|
383
|
+
* Rename or move a path.
|
|
384
|
+
*
|
|
385
|
+
* @param oldPath - Existing filesystem path, or a URI on Linux.
|
|
386
|
+
* @param newPath - Destination filesystem path, or a URI on Linux.
|
|
387
|
+
* @param options - Optional abort signal.
|
|
388
|
+
* @returns A promise that resolves when the path is renamed.
|
|
389
|
+
*/
|
|
390
|
+
readonly rename: (
|
|
391
|
+
oldPath: string,
|
|
392
|
+
newPath: string,
|
|
393
|
+
options?: MuonFsOperationOptions,
|
|
394
|
+
) => Promise<void>;
|
|
395
|
+
/**
|
|
396
|
+
* Copy a regular file.
|
|
397
|
+
*
|
|
398
|
+
* @param source - Existing regular file path, or a URI on Linux.
|
|
399
|
+
* @param destination - Destination file path, or a URI on Linux.
|
|
400
|
+
* @param options - Optional overwrite flag and abort signal.
|
|
401
|
+
* @returns A promise that resolves when the copy completes.
|
|
402
|
+
* @remarks Rejects when `source` is not a regular file. Existing
|
|
403
|
+
* destinations are replaced unless `options.overwrite` is false.
|
|
404
|
+
*/
|
|
405
|
+
readonly copyFile: (
|
|
406
|
+
source: string,
|
|
407
|
+
destination: string,
|
|
408
|
+
options?: MuonFsCopyFileOptions,
|
|
409
|
+
) => Promise<void>;
|
|
410
|
+
/**
|
|
411
|
+
* Append binary data to a file.
|
|
412
|
+
*
|
|
413
|
+
* @param path - Filesystem path, or a URI on Linux, to append to.
|
|
414
|
+
* @param data - Binary data to append.
|
|
415
|
+
* @param options - Optional abort signal.
|
|
416
|
+
* @returns A promise that resolves when append completes.
|
|
417
|
+
* @remarks Creates the file when it does not exist.
|
|
418
|
+
*/
|
|
419
|
+
readonly appendFile: (
|
|
420
|
+
path: string,
|
|
421
|
+
data: BufferSource,
|
|
422
|
+
options?: MuonFsOperationOptions,
|
|
423
|
+
) => Promise<void>;
|
|
424
|
+
/**
|
|
425
|
+
* Append UTF-8 text to a file.
|
|
426
|
+
*
|
|
427
|
+
* @param path - Filesystem path, or a URI on Linux, to append to.
|
|
428
|
+
* @param data - Text to append.
|
|
429
|
+
* @param encoding - Text encoding. Only `"utf8"` and `"utf-8"` are supported.
|
|
430
|
+
* @param options - Optional abort signal.
|
|
431
|
+
* @returns A promise that resolves when append completes.
|
|
432
|
+
* @remarks Creates the file when it does not exist.
|
|
433
|
+
*/
|
|
434
|
+
readonly appendTextFile: (
|
|
435
|
+
path: string,
|
|
436
|
+
data: string,
|
|
437
|
+
encoding: "utf8" | "utf-8",
|
|
438
|
+
options?: MuonFsOperationOptions,
|
|
439
|
+
) => Promise<void>;
|
|
440
|
+
/** Truncate or extend a file. */
|
|
441
|
+
readonly truncate: {
|
|
442
|
+
/**
|
|
443
|
+
* Truncate or extend a file to the requested byte length.
|
|
444
|
+
*
|
|
445
|
+
* @param path - File path, or a URI on Linux, to resize.
|
|
446
|
+
* @param length - Target byte length. Omit to truncate to zero bytes.
|
|
447
|
+
* @param options - Optional abort signal.
|
|
448
|
+
* @returns A promise that resolves when the file size is updated.
|
|
449
|
+
* @remarks `length` must be a non-negative safe integer.
|
|
450
|
+
*/
|
|
451
|
+
(
|
|
452
|
+
path: string,
|
|
453
|
+
length?: number,
|
|
454
|
+
options?: MuonFsOperationOptions,
|
|
455
|
+
): Promise<void>;
|
|
456
|
+
/**
|
|
457
|
+
* Truncate a file to zero bytes using operation options as the second argument.
|
|
458
|
+
*
|
|
459
|
+
* @param path - File path, or a URI on Linux, to resize.
|
|
460
|
+
* @param options - Optional abort signal.
|
|
461
|
+
* @returns A promise that resolves when the file is truncated to zero bytes.
|
|
462
|
+
*/
|
|
463
|
+
(path: string, options: MuonFsOperationOptions): Promise<void>;
|
|
464
|
+
};
|
|
465
|
+
/**
|
|
466
|
+
* Resolve a path to its canonical absolute path.
|
|
467
|
+
*
|
|
468
|
+
* @param path - Filesystem path, or a URI on Linux, to resolve.
|
|
469
|
+
* @param options - Optional abort signal.
|
|
470
|
+
* @returns A promise for the canonical absolute path.
|
|
471
|
+
* @remarks Rejects when the path or a path component does not exist.
|
|
472
|
+
*/
|
|
473
|
+
readonly realpath: (
|
|
474
|
+
path: string,
|
|
475
|
+
options?: MuonFsOperationOptions,
|
|
476
|
+
) => Promise<string>;
|
|
477
|
+
/**
|
|
478
|
+
* Read the target of a symbolic link.
|
|
479
|
+
*
|
|
480
|
+
* @param path - Symbolic link path, or a URI on Linux, to inspect.
|
|
481
|
+
* @param options - Optional abort signal.
|
|
482
|
+
* @returns A promise for the symbolic link target path.
|
|
483
|
+
*/
|
|
484
|
+
readonly readlink: (
|
|
485
|
+
path: string,
|
|
486
|
+
options?: MuonFsOperationOptions,
|
|
487
|
+
) => Promise<string>;
|
|
488
|
+
/** Create a symbolic link. */
|
|
489
|
+
readonly symlink: {
|
|
490
|
+
/**
|
|
491
|
+
* Create a symbolic link.
|
|
492
|
+
*
|
|
493
|
+
* @param target - Link target path string.
|
|
494
|
+
* @param path - Symbolic link path, or a URI on Linux, to create.
|
|
495
|
+
* @param type - Symbolic link kind. Omit to create a file link.
|
|
496
|
+
* @param options - Optional abort signal.
|
|
497
|
+
* @returns A promise that resolves when the link is created.
|
|
498
|
+
* @remarks `"dir"` and `"junction"` create a directory link. On Linux,
|
|
499
|
+
* only `path` is interpreted as a path-or-URI location; `target` is the
|
|
500
|
+
* symlink target string.
|
|
501
|
+
*/
|
|
502
|
+
(
|
|
503
|
+
target: string,
|
|
504
|
+
path: string,
|
|
505
|
+
type?: MuonFsSymlinkType,
|
|
506
|
+
options?: MuonFsOperationOptions,
|
|
507
|
+
): Promise<void>;
|
|
508
|
+
/**
|
|
509
|
+
* Create a file symbolic link using operation options as the third argument.
|
|
510
|
+
*
|
|
511
|
+
* @param target - Link target path string.
|
|
512
|
+
* @param path - Symbolic link path, or a URI on Linux, to create.
|
|
513
|
+
* @param options - Optional abort signal.
|
|
514
|
+
* @returns A promise that resolves when the link is created.
|
|
515
|
+
* @remarks On Linux, only `path` is interpreted as a path-or-URI
|
|
516
|
+
* location; `target` is the symlink target string.
|
|
517
|
+
*/
|
|
518
|
+
(
|
|
519
|
+
target: string,
|
|
520
|
+
path: string,
|
|
521
|
+
options: MuonFsOperationOptions,
|
|
522
|
+
): Promise<void>;
|
|
523
|
+
};
|
|
524
|
+
/**
|
|
525
|
+
* Watch a path for changes until the returned watcher is closed.
|
|
526
|
+
*
|
|
527
|
+
* @param path - File or directory path, or a URI on Linux, to watch.
|
|
528
|
+
* @param listener - Listener invoked for change, rename, and error events.
|
|
529
|
+
* @param options - Optional abort signal.
|
|
530
|
+
* @returns A promise for a watcher handle.
|
|
531
|
+
* @remarks Muon currently watches by polling snapshots. Listener exceptions
|
|
532
|
+
* and rejected promises are ignored. Aborting before the watcher is created
|
|
533
|
+
* rejects; aborting after creation closes the watcher.
|
|
534
|
+
*/
|
|
535
|
+
readonly watch: (
|
|
536
|
+
path: string,
|
|
537
|
+
listener: MuonFsWatchListener,
|
|
538
|
+
options?: MuonFsOperationOptions,
|
|
539
|
+
) => Promise<MuonFsWatcher>;
|
|
540
|
+
/** Native filesystem dialogs exposed by the built-in Muon filesystem plugin. */
|
|
541
|
+
readonly dialogs: MuonFsDialogsApi;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
/** Native filesystem dialogs exposed by the built-in Muon filesystem plugin. */
|
|
545
|
+
interface MuonFsDialogsApi {
|
|
546
|
+
/**
|
|
547
|
+
* Show a native file open dialog and return the selected local path or URI.
|
|
548
|
+
*
|
|
549
|
+
* @param options - Optional native dialog options and abort signal.
|
|
550
|
+
* @returns A promise for the selected path or URI, or `null` when canceled.
|
|
551
|
+
* @remarks GTK can return URI values when `options.gtk.localOnly` is false.
|
|
552
|
+
*/
|
|
553
|
+
readonly selectFile: (
|
|
554
|
+
options?: MuonFsOpenDialogOptions,
|
|
555
|
+
) => Promise<string | null>;
|
|
556
|
+
/**
|
|
557
|
+
* Show a native multi-file open dialog and return selected local paths or URIs.
|
|
558
|
+
*
|
|
559
|
+
* @param options - Optional native dialog options and abort signal.
|
|
560
|
+
* @returns A promise for selected paths or URIs, or an empty array when canceled.
|
|
561
|
+
* @remarks GTK can return URI values when `options.gtk.localOnly` is false.
|
|
562
|
+
*/
|
|
563
|
+
readonly selectFiles: (
|
|
564
|
+
options?: MuonFsOpenDialogOptions,
|
|
565
|
+
) => Promise<string[]>;
|
|
566
|
+
/**
|
|
567
|
+
* Show a native directory selection dialog and return the selected local path or URI.
|
|
568
|
+
*
|
|
569
|
+
* @param options - Optional native dialog options and abort signal.
|
|
570
|
+
* @returns A promise for the selected path or URI, or `null` when canceled.
|
|
571
|
+
* @remarks GTK can return URI values when `options.gtk.localOnly` is false.
|
|
572
|
+
*/
|
|
573
|
+
readonly selectDirectory: (
|
|
574
|
+
options?: MuonFsOpenDialogOptions,
|
|
575
|
+
) => Promise<string | null>;
|
|
576
|
+
/**
|
|
577
|
+
* Show a native multi-directory selection dialog and return selected local paths or URIs.
|
|
578
|
+
*
|
|
579
|
+
* @param options - Optional native dialog options and abort signal.
|
|
580
|
+
* @returns A promise for selected paths or URIs, or an empty array when canceled.
|
|
581
|
+
* @remarks GTK can return URI values when `options.gtk.localOnly` is false.
|
|
582
|
+
*/
|
|
583
|
+
readonly selectDirectories: (
|
|
584
|
+
options?: MuonFsOpenDialogOptions,
|
|
585
|
+
) => Promise<string[]>;
|
|
586
|
+
/**
|
|
587
|
+
* Show a native save dialog and return the selected local path or URI.
|
|
588
|
+
*
|
|
589
|
+
* @param options - Optional native dialog options and abort signal.
|
|
590
|
+
* @returns A promise for the selected path or URI, or `null` when canceled.
|
|
591
|
+
* @remarks The dialog only returns a path or URI; it does not create or
|
|
592
|
+
* overwrite the file.
|
|
593
|
+
*/
|
|
594
|
+
readonly selectSaveFile: (
|
|
595
|
+
options?: MuonFsSaveDialogOptions,
|
|
596
|
+
) => Promise<string | null>;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
/** Options shared by built-in filesystem operations. */
|
|
600
|
+
interface MuonFsOperationOptions {
|
|
601
|
+
/**
|
|
602
|
+
* Signal used to abort the filesystem operation.
|
|
603
|
+
*
|
|
604
|
+
* @remarks If the signal is already aborted, the operation rejects with the
|
|
605
|
+
* signal reason or an `AbortError`. If it aborts while the operation is
|
|
606
|
+
* pending, Muon requests native cancellation when possible.
|
|
607
|
+
*/
|
|
608
|
+
readonly signal?: AbortSignal;
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
/** Options for reading a binary file. */
|
|
612
|
+
interface MuonFsReadFileOptions extends MuonFsOperationOptions {
|
|
613
|
+
/**
|
|
614
|
+
* Byte offset where reading starts.
|
|
615
|
+
*
|
|
616
|
+
* @remarks Must be a non-negative safe integer. Defaults to `0`.
|
|
617
|
+
*/
|
|
618
|
+
readonly position?: number;
|
|
619
|
+
/**
|
|
620
|
+
* Maximum number of bytes to read.
|
|
621
|
+
*
|
|
622
|
+
* @remarks Must be a non-negative safe integer. Omit to read through the end
|
|
623
|
+
* of the file.
|
|
624
|
+
*/
|
|
625
|
+
readonly length?: number;
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
/** Options for writing a binary file. */
|
|
629
|
+
interface MuonFsWriteFileOptions extends MuonFsOperationOptions {
|
|
630
|
+
/**
|
|
631
|
+
* Byte offset where writing starts.
|
|
632
|
+
*
|
|
633
|
+
* @remarks Must be a non-negative safe integer. Omit to replace the whole file.
|
|
634
|
+
*/
|
|
635
|
+
readonly position?: number;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
/** Access modes checked by Muon filesystem access. */
|
|
639
|
+
type MuonFsAccessMode = "read" | "write" | "execute";
|
|
640
|
+
|
|
641
|
+
/** Options for checking path accessibility. */
|
|
642
|
+
interface MuonFsAccessOptions extends MuonFsOperationOptions {
|
|
643
|
+
/**
|
|
644
|
+
* Requested access modes.
|
|
645
|
+
*
|
|
646
|
+
* @remarks Omit to check only existence. Every listed mode must be allowed
|
|
647
|
+
* for `access()` to return true.
|
|
648
|
+
*/
|
|
649
|
+
readonly mode?: readonly MuonFsAccessMode[];
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
/** Options for reading a directory. */
|
|
653
|
+
interface MuonFsReadDirectoryOptions extends MuonFsOperationOptions {
|
|
654
|
+
/**
|
|
655
|
+
* Return entries with metadata helpers instead of names.
|
|
656
|
+
*
|
|
657
|
+
* @remarks Use `true` to select the `MuonFsDirent[]` overload.
|
|
658
|
+
*/
|
|
659
|
+
readonly withFileTypes?: boolean;
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
/** Options for creating a directory. */
|
|
663
|
+
interface MuonFsMakeDirectoryOptions extends MuonFsOperationOptions {
|
|
664
|
+
/**
|
|
665
|
+
* Create parent directories as needed.
|
|
666
|
+
*
|
|
667
|
+
* @remarks Defaults to false.
|
|
668
|
+
*/
|
|
669
|
+
readonly recursive?: boolean;
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
/** Options for removing a path. */
|
|
673
|
+
interface MuonFsRemoveOptions extends MuonFsOperationOptions {
|
|
674
|
+
/**
|
|
675
|
+
* Remove directory trees recursively.
|
|
676
|
+
*
|
|
677
|
+
* @remarks Defaults to false.
|
|
678
|
+
*/
|
|
679
|
+
readonly recursive?: boolean;
|
|
680
|
+
/**
|
|
681
|
+
* Do not fail when the path is missing.
|
|
682
|
+
*
|
|
683
|
+
* @remarks Defaults to false.
|
|
684
|
+
*/
|
|
685
|
+
readonly force?: boolean;
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
/** Options for copying a regular file. */
|
|
689
|
+
interface MuonFsCopyFileOptions extends MuonFsOperationOptions {
|
|
690
|
+
/** Replace an existing destination file. Defaults to true. */
|
|
691
|
+
readonly overwrite?: boolean;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
/** File type filter shown in native file dialogs. */
|
|
695
|
+
interface MuonFsDialogFilter {
|
|
696
|
+
/** Human-readable filter name. */
|
|
697
|
+
readonly name: string;
|
|
698
|
+
/**
|
|
699
|
+
* File extensions accepted by this filter.
|
|
700
|
+
*
|
|
701
|
+
* @remarks Entries may be plain extensions such as "png", dotted
|
|
702
|
+
* extensions such as ".png", wildcard patterns such as "*.png", or "*".
|
|
703
|
+
*/
|
|
704
|
+
readonly extensions: readonly string[];
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
/** GTK-specific native dialog options. */
|
|
708
|
+
interface MuonFsGtkDialogOptions {
|
|
709
|
+
/**
|
|
710
|
+
* Restrict selection to local files.
|
|
711
|
+
*
|
|
712
|
+
* @remarks Defaults to false so GTK/GVfs locations can return URI values.
|
|
713
|
+
*/
|
|
714
|
+
readonly localOnly?: boolean;
|
|
715
|
+
/**
|
|
716
|
+
* Allow creating folders from save and folder chooser dialogs.
|
|
717
|
+
*
|
|
718
|
+
* @remarks Applies only when supported by the GTK backend.
|
|
719
|
+
*/
|
|
720
|
+
readonly createFolders?: boolean;
|
|
721
|
+
/**
|
|
722
|
+
* Additional GTK MIME type filters.
|
|
723
|
+
*
|
|
724
|
+
* @remarks Entries must be non-empty strings.
|
|
725
|
+
*/
|
|
726
|
+
readonly mimeTypes?: readonly string[];
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
/** Win32-specific native dialog options. */
|
|
730
|
+
interface MuonFsWin32DialogOptions {
|
|
731
|
+
/** Force selections to filesystem-backed shell items. */
|
|
732
|
+
readonly forceFilesystem?: boolean;
|
|
733
|
+
/** Return shortcut/link items themselves instead of their targets. */
|
|
734
|
+
readonly noDereferenceLinks?: boolean;
|
|
735
|
+
/** Do not add selected locations to the recent documents list. */
|
|
736
|
+
readonly dontAddToRecent?: boolean;
|
|
737
|
+
/** Allow paths that do not pass normal shell validation. */
|
|
738
|
+
readonly noValidate?: boolean;
|
|
739
|
+
/** Restrict typed filenames to the configured file types. */
|
|
740
|
+
readonly strictFileTypes?: boolean;
|
|
741
|
+
/** Require selected paths to exist. */
|
|
742
|
+
readonly pathMustExist?: boolean;
|
|
743
|
+
/** Require selected files to exist. */
|
|
744
|
+
readonly fileMustExist?: boolean;
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
/** Common options for native filesystem dialogs. */
|
|
748
|
+
interface MuonFsDialogOptions extends MuonFsOperationOptions {
|
|
749
|
+
/** Dialog title. */
|
|
750
|
+
readonly title?: string;
|
|
751
|
+
/**
|
|
752
|
+
* Initial path or URI shown by the dialog.
|
|
753
|
+
*
|
|
754
|
+
* @remarks GTK accepts GVfs URI values when gtk.localOnly is false.
|
|
755
|
+
*/
|
|
756
|
+
readonly defaultPath?: string;
|
|
757
|
+
/** Accept button label. */
|
|
758
|
+
readonly buttonLabel?: string;
|
|
759
|
+
/**
|
|
760
|
+
* Whether to disable the calling browser view while the dialog is open.
|
|
761
|
+
*
|
|
762
|
+
* @remarks Defaults to true.
|
|
763
|
+
*/
|
|
764
|
+
readonly modal?: boolean;
|
|
765
|
+
/** Show hidden files when supported by the backend. */
|
|
766
|
+
readonly showHidden?: boolean;
|
|
767
|
+
/**
|
|
768
|
+
* File filters shown by the dialog.
|
|
769
|
+
*
|
|
770
|
+
* @remarks Every filter requires a non-empty name and at least one extension.
|
|
771
|
+
*/
|
|
772
|
+
readonly filters?: readonly MuonFsDialogFilter[];
|
|
773
|
+
/** GTK-specific dialog flags. */
|
|
774
|
+
readonly gtk?: MuonFsGtkDialogOptions;
|
|
775
|
+
/** Win32-specific dialog flags. */
|
|
776
|
+
readonly win32?: MuonFsWin32DialogOptions;
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
/** Options for open and directory selection dialogs. */
|
|
780
|
+
interface MuonFsOpenDialogOptions extends MuonFsDialogOptions {}
|
|
781
|
+
|
|
782
|
+
/** Options for save file dialogs. */
|
|
783
|
+
interface MuonFsSaveDialogOptions extends MuonFsDialogOptions {
|
|
784
|
+
/** Initial file name shown by the save dialog. */
|
|
785
|
+
readonly defaultName?: string;
|
|
786
|
+
/** Ask before replacing an existing file. Defaults to true. */
|
|
787
|
+
readonly confirmOverwrite?: boolean;
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
/** Filesystem entry type reported by Muon. */
|
|
791
|
+
type MuonFsEntryType =
|
|
792
|
+
| "file"
|
|
793
|
+
| "directory"
|
|
794
|
+
| "symlink"
|
|
795
|
+
| "blockDevice"
|
|
796
|
+
| "characterDevice"
|
|
797
|
+
| "fifo"
|
|
798
|
+
| "socket"
|
|
799
|
+
| "other";
|
|
800
|
+
|
|
801
|
+
/** Metadata returned for filesystem entries. */
|
|
802
|
+
interface MuonFsStats {
|
|
803
|
+
/** Entry type. */
|
|
804
|
+
readonly type: MuonFsEntryType;
|
|
805
|
+
/** Entry size in bytes for regular files, otherwise zero. */
|
|
806
|
+
readonly size: number;
|
|
807
|
+
/** Last modification time as milliseconds since the Unix epoch. */
|
|
808
|
+
readonly mtimeMs: number;
|
|
809
|
+
/** Whether no write permission bits are set. */
|
|
810
|
+
readonly readonly: boolean;
|
|
811
|
+
/**
|
|
812
|
+
* Return whether this entry is a regular file.
|
|
813
|
+
*
|
|
814
|
+
* @returns `true` when `type` is `"file"`.
|
|
815
|
+
*/
|
|
816
|
+
readonly isFile: () => boolean;
|
|
817
|
+
/**
|
|
818
|
+
* Return whether this entry is a directory.
|
|
819
|
+
*
|
|
820
|
+
* @returns `true` when `type` is `"directory"`.
|
|
821
|
+
*/
|
|
822
|
+
readonly isDirectory: () => boolean;
|
|
823
|
+
/**
|
|
824
|
+
* Return whether this entry is a symbolic link.
|
|
825
|
+
*
|
|
826
|
+
* @returns `true` when `type` is `"symlink"`.
|
|
827
|
+
*/
|
|
828
|
+
readonly isSymbolicLink: () => boolean;
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
/** Directory entry with metadata helpers. */
|
|
832
|
+
interface MuonFsDirent extends MuonFsStats {
|
|
833
|
+
/** Entry name relative to the listed directory. */
|
|
834
|
+
readonly name: string;
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
/** Symbolic link creation mode. */
|
|
838
|
+
type MuonFsSymlinkType = "file" | "dir" | "junction";
|
|
839
|
+
|
|
840
|
+
/** Filesystem watch event delivered to a watch listener. */
|
|
841
|
+
interface MuonFsWatchEvent {
|
|
842
|
+
/** Event kind. */
|
|
843
|
+
readonly eventType: "rename" | "change" | "error";
|
|
844
|
+
/** Changed entry name, or null for the watched path itself. */
|
|
845
|
+
readonly filename: string | null;
|
|
846
|
+
/** Error message when eventType is error. */
|
|
847
|
+
readonly message?: string;
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
/**
|
|
851
|
+
* Listener invoked for filesystem watch events.
|
|
852
|
+
*
|
|
853
|
+
* @param event - Watch event emitted by Muon.
|
|
854
|
+
* @returns Ignored by Muon. Rejected promises are ignored.
|
|
855
|
+
*/
|
|
856
|
+
type MuonFsWatchListener = (event: MuonFsWatchEvent) => void | Promise<void>;
|
|
857
|
+
|
|
858
|
+
/** Active filesystem watcher. */
|
|
859
|
+
interface MuonFsWatcher {
|
|
860
|
+
/**
|
|
861
|
+
* Stop watching.
|
|
862
|
+
*
|
|
863
|
+
* @returns A promise that resolves after the watcher is closed.
|
|
864
|
+
* @remarks Calling `close()` more than once is allowed.
|
|
865
|
+
*/
|
|
866
|
+
readonly close: () => Promise<void>;
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
/** Runtime metadata for the current Muon process. */
|
|
870
|
+
interface MuonRuntimeInfo {
|
|
871
|
+
/** Runtime package name. */
|
|
872
|
+
readonly name: string;
|
|
873
|
+
/** Native executable file name included in the runtime payload. */
|
|
874
|
+
readonly executableName: string;
|
|
875
|
+
/** Muon runtime target name. */
|
|
876
|
+
readonly target: string;
|
|
877
|
+
/** muon-core build identity. */
|
|
878
|
+
readonly muonCore: MuonCoreRuntimeInfo;
|
|
879
|
+
/** CEF build selected when muon-core was built. */
|
|
880
|
+
readonly cefReference: MuonCefReferenceInfo;
|
|
881
|
+
/** CEF build loaded by the current process. */
|
|
882
|
+
readonly cefRuntime: MuonCefRuntimeInfo;
|
|
883
|
+
/** Runtime payload entries copied with muon-core. */
|
|
884
|
+
readonly corePayload: readonly string[];
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
/** muon-core build identity. */
|
|
888
|
+
interface MuonCoreRuntimeInfo {
|
|
889
|
+
/** muon-core package version embedded at build time. */
|
|
890
|
+
readonly version: string;
|
|
891
|
+
/** Git commit hash embedded at build time. */
|
|
892
|
+
readonly gitCommitHash: string;
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
/** CEF build selected when muon-core was built. */
|
|
896
|
+
interface MuonCefReferenceInfo {
|
|
897
|
+
/** CEF binary distribution version. */
|
|
898
|
+
readonly version: string;
|
|
899
|
+
/** CEF binary distribution kind. */
|
|
900
|
+
readonly distribution: string;
|
|
901
|
+
/** Stable CEF API version used by muon-core. */
|
|
902
|
+
readonly apiVersion: number;
|
|
903
|
+
/** Platform API hash for the selected CEF API version. */
|
|
904
|
+
readonly apiHash: string;
|
|
905
|
+
/** Downloadable CEF artifact metadata. */
|
|
906
|
+
readonly artifact: MuonCefArtifactInfo;
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
/** CEF artifact metadata used by muon prepare. */
|
|
910
|
+
interface MuonCefArtifactInfo {
|
|
911
|
+
/** CEF archive file name. */
|
|
912
|
+
readonly fileName: string;
|
|
913
|
+
/** CEF archive download URL. */
|
|
914
|
+
readonly url: string;
|
|
915
|
+
/** Expected SHA-1 digest for the CEF archive. */
|
|
916
|
+
readonly sha1: string;
|
|
917
|
+
/** Expected CEF archive size in bytes. */
|
|
918
|
+
readonly size: number;
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
/** CEF build loaded by the current Muon process. */
|
|
922
|
+
interface MuonCefRuntimeInfo {
|
|
923
|
+
/** Runtime CEF version reported by libcef. */
|
|
924
|
+
readonly version: string;
|
|
925
|
+
/** Runtime CEF API version configured by libcef. */
|
|
926
|
+
readonly apiVersion: number;
|
|
927
|
+
/** Runtime platform API hash for the configured CEF API version. */
|
|
928
|
+
readonly apiHash: string;
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
/** Environment information exposed by Muon. */
|
|
932
|
+
interface MuonEnvironmentsApi {
|
|
933
|
+
/**
|
|
934
|
+
* Return the current process environment variables.
|
|
935
|
+
*
|
|
936
|
+
* @returns A promise for a key-value map of environment variables.
|
|
937
|
+
*/
|
|
938
|
+
readonly getVariables: () => Promise<Record<string, string>>;
|
|
939
|
+
/**
|
|
940
|
+
* Return the command line captured when the current Muon process started.
|
|
941
|
+
*
|
|
942
|
+
* @returns A promise for the process command line, including `argv[0]` when available.
|
|
943
|
+
*/
|
|
944
|
+
readonly getCommandLine: () => Promise<string[]>;
|
|
945
|
+
/**
|
|
946
|
+
* Return the native Muon process id.
|
|
947
|
+
*
|
|
948
|
+
* @returns A promise for the current process id.
|
|
949
|
+
*/
|
|
950
|
+
readonly getProcessId: () => Promise<number>;
|
|
951
|
+
/**
|
|
952
|
+
* Return runtime metadata for the current Muon process.
|
|
953
|
+
*
|
|
954
|
+
* @returns A promise for build-time muon-core metadata and runtime CEF metadata.
|
|
955
|
+
*/
|
|
956
|
+
readonly getRuntimeInfo: () => Promise<MuonRuntimeInfo>;
|
|
957
|
+
/**
|
|
958
|
+
* Return whether the current Muon application starts with the user session.
|
|
959
|
+
*
|
|
960
|
+
* @returns A promise for the autostart state, or `undefined` when unknown.
|
|
961
|
+
* @remarks The active launch source selects the platform backend. Muon uses
|
|
962
|
+
* XDG Autostart on POSIX desktop environments and the current user's Run
|
|
963
|
+
* registry entry on Windows.
|
|
964
|
+
*/
|
|
965
|
+
readonly getAutostart: () => Promise<boolean | undefined>;
|
|
966
|
+
/**
|
|
967
|
+
* Enable or disable startup with the user session.
|
|
968
|
+
*
|
|
969
|
+
* @param enabled - Whether autostart should be enabled.
|
|
970
|
+
* @returns A promise that resolves when the platform backend updates the setting.
|
|
971
|
+
*/
|
|
972
|
+
readonly setAutostart: (enabled: boolean) => Promise<void>;
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
/** Child process execution operations exposed by Muon. */
|
|
976
|
+
interface MuonExecutorApi {
|
|
977
|
+
/**
|
|
978
|
+
* Spawn a child process without invoking a shell.
|
|
979
|
+
*
|
|
980
|
+
* @param options - Process launch options.
|
|
981
|
+
* @returns A promise for the completed child process result.
|
|
982
|
+
* @remarks The promise resolves even when the child exits with a non-zero
|
|
983
|
+
* exit code. It rejects only when the process cannot be launched or the
|
|
984
|
+
* options are invalid.
|
|
985
|
+
*/
|
|
986
|
+
readonly spawn: (
|
|
987
|
+
options: MuonExecutorSpawnOptions,
|
|
988
|
+
) => Promise<MuonExecutorSpawnResult>;
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
/** Options for spawning a child process through Muon. */
|
|
992
|
+
interface MuonExecutorSpawnOptions {
|
|
993
|
+
/**
|
|
994
|
+
* Executable path or executable name resolved through `PATH`.
|
|
995
|
+
*
|
|
996
|
+
* @remarks Required, non-empty, and must not contain NUL.
|
|
997
|
+
*/
|
|
998
|
+
readonly command: string;
|
|
999
|
+
/**
|
|
1000
|
+
* Command line arguments passed as separate values.
|
|
1001
|
+
*
|
|
1002
|
+
* @remarks Values are not interpreted by a shell and must not contain NUL.
|
|
1003
|
+
*/
|
|
1004
|
+
readonly args?: readonly string[];
|
|
1005
|
+
/**
|
|
1006
|
+
* UTF-8 text written to the child process stdin.
|
|
1007
|
+
*
|
|
1008
|
+
* @remarks Omit or use an empty string to close stdin without writing data.
|
|
1009
|
+
*/
|
|
1010
|
+
readonly stdin?: string;
|
|
1011
|
+
/**
|
|
1012
|
+
* Working directory used for the child process.
|
|
1013
|
+
*
|
|
1014
|
+
* @remarks Must not contain NUL. On POSIX, failure to change directory makes
|
|
1015
|
+
* the child exit with code `126`.
|
|
1016
|
+
*/
|
|
1017
|
+
readonly cwd?: string;
|
|
1018
|
+
/**
|
|
1019
|
+
* Environment variable overrides for the child process.
|
|
1020
|
+
*
|
|
1021
|
+
* @remarks Entries are merged with the current process environment. Keys
|
|
1022
|
+
* must be non-empty and must not contain `=` or NUL; values must not contain
|
|
1023
|
+
* NUL.
|
|
1024
|
+
*/
|
|
1025
|
+
readonly env?: Record<string, string>;
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
/** Completed child process result. */
|
|
1029
|
+
interface MuonExecutorSpawnResult {
|
|
1030
|
+
/** Child process id. */
|
|
1031
|
+
readonly processId: number;
|
|
1032
|
+
/** Child process exit code. */
|
|
1033
|
+
readonly exitCode: number;
|
|
1034
|
+
/** Captured UTF-8 stdout text. */
|
|
1035
|
+
readonly stdout: string;
|
|
1036
|
+
/** Captured UTF-8 stderr text. */
|
|
1037
|
+
readonly stderr: string;
|
|
1038
|
+
}
|
|
1039
|
+
}
|