@sigma-file-manager/api 1.5.0 → 1.7.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/index.d.ts CHANGED
@@ -1,619 +1,644 @@
1
- declare global {
2
- const sigma: SigmaExtensionAPI;
3
- }
4
-
5
- export type ExtensionType = 'api' | 'iframe' | 'webview';
6
-
7
- export type ExtensionPermission
8
- = | 'contextMenu'
9
- | 'sidebar'
10
- | 'toolbar'
11
- | 'commands'
12
- | 'fs.read'
13
- | 'fs.write'
14
- | 'notifications'
15
- | 'dialogs'
16
- | 'shell'
17
- | 'clipboard'
18
- | 'openUrl';
19
-
20
- export type ExtensionActivationEvent
21
- = | 'onStartup'
22
- | 'onInstall'
23
- | 'onUninstall'
24
- | 'onEnable'
25
- | 'onDisable'
26
- | 'onUpdate'
27
- | 'onLocaleChange'
28
- | `onCommand:${string}`;
29
-
30
- export interface ExtensionPublisher {
31
- name: string;
32
- url?: string;
33
- }
34
-
35
- export interface ExtensionCommand {
36
- id: string;
37
- title: string;
38
- description?: string;
39
- icon?: string;
40
- shortcut?: string;
41
- }
42
-
43
- export interface ExtensionContextMenuCondition {
44
- selectionType?: 'single' | 'multiple' | 'any';
45
- entryType?: 'file' | 'directory' | 'any';
46
- fileExtensions?: string[];
47
- }
48
-
49
- export interface ExtensionContextMenuItem {
50
- id: string;
51
- title: string;
52
- icon?: string;
53
- when?: ExtensionContextMenuCondition;
54
- group?: string;
55
- order?: number;
56
- }
57
-
58
- export interface ExtensionSidebarItem {
59
- id: string;
60
- title: string;
61
- icon: string;
62
- order?: number;
63
- url?: string;
64
- }
65
-
66
- export interface ExtensionToolbarDropdownItem {
67
- id: string;
68
- title: string;
69
- icon?: string;
70
- commandId?: string;
71
- separator?: boolean;
72
- }
73
-
74
- export interface ExtensionToolbarDropdown {
75
- id: string;
76
- title: string;
77
- icon?: string;
78
- items: ExtensionToolbarDropdownItem[];
79
- }
80
-
81
- export type ExtensionConfigurationPropertyType = 'string' | 'number' | 'boolean' | 'array';
82
-
83
- export interface ExtensionConfigurationProperty {
84
- type: ExtensionConfigurationPropertyType;
85
- default?: unknown;
86
- description?: string;
87
- enum?: (string | number)[];
88
- enumDescriptions?: string[];
89
- minimum?: number;
90
- maximum?: number;
91
- minLength?: number;
92
- maxLength?: number;
93
- items?: {
94
- type: 'string' | 'number';
95
- };
96
- }
97
-
98
- export interface ExtensionConfiguration {
99
- title?: string;
100
- properties: Record<string, ExtensionConfigurationProperty>;
101
- }
102
-
103
- export type ExtensionKeybindingWhen
104
- = | 'always'
105
- | 'fileSelected'
106
- | 'directorySelected'
107
- | 'singleSelected'
108
- | 'multipleSelected'
109
- | 'navigatorFocused';
110
-
111
- export interface ExtensionKeybinding {
112
- command: string;
113
- key: string;
114
- when?: ExtensionKeybindingWhen;
115
- }
116
-
117
- export interface ExtensionContributions {
118
- commands?: ExtensionCommand[];
119
- contextMenu?: ExtensionContextMenuItem[];
120
- sidebar?: ExtensionSidebarItem[];
121
- toolbar?: ExtensionToolbarDropdown[];
122
- configuration?: ExtensionConfiguration;
123
- keybindings?: ExtensionKeybinding[];
124
- }
125
-
126
- export interface ExtensionEngines {
127
- sigmaFileManager: string;
128
- }
129
-
130
- export type PlatformOS = 'windows' | 'macos' | 'linux';
131
- export type PlatformArch = 'x64' | 'arm64';
132
-
133
- export interface ManifestBinaryAsset {
134
- platform: PlatformOS;
135
- arch?: PlatformArch[];
136
- downloadUrl: string;
137
- integrity: string;
138
- archive?: boolean;
139
- executable?: string;
140
- }
141
-
142
- export interface ManifestBinaryDefinition {
143
- id: string;
144
- name: string;
145
- version: string;
146
- executable?: string;
147
- repository?: string;
148
- platforms?: PlatformOS[];
149
- assets: ManifestBinaryAsset[];
150
- }
151
-
152
- export interface ExtensionManifest {
153
- id: string;
154
- name: string;
155
- previousName?: string;
156
- version: string;
157
- publisher?: ExtensionPublisher;
158
- repository: string;
159
- license: string;
160
- icon?: string;
161
- banner?: string;
162
- categories?: string[];
163
- tags?: string[];
164
- extensionType: ExtensionType;
165
- main: string;
166
- permissions: ExtensionPermission[];
167
- activationEvents?: ExtensionActivationEvent[];
168
- contributes?: ExtensionContributions;
169
- platforms?: PlatformOS[];
170
- binaries?: ManifestBinaryDefinition[];
171
- engines: ExtensionEngines;
172
- }
173
-
174
- export interface Disposable {
175
- dispose(): void;
176
- }
177
-
178
- export interface ContextMenuContext {
179
- selectedEntries: {
180
- path: string;
181
- name: string;
182
- isDirectory: boolean;
183
- size?: number;
184
- extension?: string;
185
- }[];
186
- }
187
-
188
- export interface NotificationOptions {
189
- title: string;
190
- subtitle?: string;
191
- description?: string;
192
- type?: 'info' | 'success' | 'warning' | 'error';
193
- duration?: number;
194
- }
195
-
196
- export interface DialogOptions {
197
- title: string;
198
- message: string;
199
- type?: 'info' | 'confirm' | 'prompt';
200
- confirmText?: string;
201
- cancelText?: string;
202
- defaultValue?: string;
203
- }
204
-
205
- export interface DialogResult {
206
- confirmed: boolean;
207
- value?: string;
208
- }
209
-
210
- export type ProgressLocation = 'notification' | 'statusBar';
211
-
212
- export interface ProgressOptions {
213
- subtitle: string;
214
- location?: ProgressLocation;
215
- cancellable?: boolean;
216
- }
217
-
218
- export interface ProgressReport {
219
- subtitle?: string;
220
- description?: string;
221
- increment?: number;
222
- value?: number;
223
- }
224
-
225
- export interface Progress {
226
- report(value: ProgressReport): void;
227
- }
228
-
229
- export interface CancellationToken {
230
- readonly isCancellationRequested: boolean;
231
- onCancellationRequested(listener: () => void): Disposable;
232
- }
233
-
234
- export interface ExtensionDirEntry {
235
- path: string;
236
- name: string;
237
- isDirectory: boolean;
238
- size?: number;
239
- modifiedAt?: number;
240
- }
241
-
242
- export interface ExtensionScopedDirectory {
243
- path: string;
244
- permissions: ('read' | 'write')[];
245
- grantedAt: number;
246
- }
247
-
248
- export interface ExtensionContextEntry {
249
- path: string;
250
- name: string;
251
- isDirectory: boolean;
252
- isFile: boolean;
253
- size: number;
254
- extension: string | null;
255
- createdAt: number;
256
- modifiedAt: number;
257
- }
258
-
259
- export interface BuiltinCommandInfo {
260
- id: string;
261
- title: string;
262
- description: string;
263
- }
264
-
265
- export interface FileDialogFilter {
266
- name: string;
267
- extensions: string[];
268
- }
269
-
270
- export interface OpenFileDialogOptions {
271
- title?: string;
272
- defaultPath?: string;
273
- filters?: FileDialogFilter[];
274
- multiple?: boolean;
275
- directory?: boolean;
276
- }
277
-
278
- export interface SaveFileDialogOptions {
279
- title?: string;
280
- defaultPath?: string;
281
- filters?: FileDialogFilter[];
282
- }
283
-
284
- export interface BinaryInfo {
285
- id: string;
286
- path: string;
287
- version?: string;
288
- storageVersion?: string | null;
289
- repository?: string;
290
- downloadUrl?: string;
291
- latestVersion?: string;
292
- hasUpdate?: boolean;
293
- latestCheckedAt?: number;
294
- installedAt: number;
295
- }
296
-
297
- export type UIElementType
298
- = | 'input'
299
- | 'select'
300
- | 'checkbox'
301
- | 'textarea'
302
- | 'button'
303
- | 'separator'
304
- | 'text'
305
- | 'image'
306
- | 'skeleton'
307
- | 'alert'
308
- | 'previewCard'
309
- | 'previewCardSkeleton';
310
-
311
- export interface UISelectOption {
312
- value: string;
313
- label: string;
314
- }
315
-
316
- export interface UIElement {
317
- type: UIElementType;
318
- id?: string;
319
- label?: string;
320
- placeholder?: string;
321
- value?: string | boolean | number;
322
- options?: UISelectOption[];
323
- rows?: number;
324
- variant?: 'primary' | 'secondary' | 'danger';
325
- tone?: 'info' | 'success' | 'warning' | 'error';
326
- size?: 'xs' | 'sm' | 'default' | 'lg';
327
- disabled?: boolean;
328
- subtitle?: string;
329
- }
330
-
331
- export interface KeyboardShortcut {
332
- key: string;
333
- modifiers?: ('ctrl' | 'shift' | 'alt' | 'meta')[];
334
- }
335
-
336
- export interface ModalButton {
337
- id: string;
338
- label: string;
339
- variant?: 'primary' | 'secondary' | 'danger';
340
- shortcut?: KeyboardShortcut;
341
- }
342
-
343
- export interface ModalOptions {
344
- title: string;
345
- width?: number;
346
- content: UIElement[];
347
- buttons?: ModalButton[];
348
- }
349
-
350
- export interface ModalHandle {
351
- onSubmit(callback: (values: Record<string, unknown>, buttonId: string) => void | boolean | Promise<void | boolean>): void;
352
- onClose(callback: () => void): void;
353
- onValueChange(callback: (elementId: string, value: unknown, allValues: Record<string, unknown>) => void): void;
354
- close(): void;
355
- updateElement(id: string, updates: Partial<UIElement>): void;
356
- setContent(content: UIElement[]): void;
357
- setButtons(buttons: ModalButton[]): void;
358
- getValues(): Record<string, unknown>;
359
- }
360
-
361
- export interface ToolbarRenderHandle {
362
- unmount(): void;
363
- }
364
-
365
- export interface PlatformInfo {
366
- os: PlatformOS;
367
- arch: string;
368
- pathSeparator: string;
369
- isWindows: boolean;
370
- isMacos: boolean;
371
- isLinux: boolean;
372
- }
373
-
374
- export interface SigmaExtensionAPI {
375
- i18n: {
376
- t(key: string, params?: Record<string, string | number>): string;
377
- mergeMessages(messages: Record<string, Record<string, string>>): void;
378
- mergeFromPath(basePath: string): Promise<void>;
379
- extensionT(key: string, params?: Record<string, string | number>, fallback?: string): string;
380
- formatMessage(template: string, params?: Record<string, string | number>): string;
381
- createExtensionTranslator(
382
- messages: Record<string, string>,
383
- ): (key: string, params?: Record<string, string | number>) => string;
384
- };
385
- contextMenu: {
386
- registerItem(
387
- item: ExtensionContextMenuItem,
388
- handler: (context: ContextMenuContext) => Promise<void> | void
389
- ): Disposable;
390
- };
391
- sidebar: {
392
- registerPage(page: ExtensionSidebarItem): Disposable;
393
- };
394
- toolbar: {
395
- registerDropdown(
396
- dropdown: ExtensionToolbarDropdown,
397
- handlers: Record<string, () => Promise<void> | void>
398
- ): Disposable;
399
- };
400
- commands: {
401
- registerCommand(
402
- command: ExtensionCommand,
403
- handler: (...args: unknown[]) => Promise<unknown> | unknown
404
- ): Disposable;
405
- executeCommand(commandId: string, ...args: unknown[]): Promise<unknown>;
406
- getBuiltinCommands(): BuiltinCommandInfo[];
407
- };
408
- context: {
409
- getCurrentPath(): string | null;
410
- getSelectedEntries(): ExtensionContextEntry[];
411
- getAppVersion(): Promise<string>;
412
- getDownloadsDir(): Promise<string>;
413
- getPicturesDir(): Promise<string>;
414
- openUrl(url: string): Promise<void>;
415
- onPathChange(callback: (path: string | null) => void): Disposable;
416
- onSelectionChange(callback: (entries: ExtensionContextEntry[]) => void): Disposable;
417
- };
418
- fs: {
419
- readFile(path: string): Promise<Uint8Array>;
420
- writeFile(path: string, data: Uint8Array): Promise<void>;
421
- readDir(path: string): Promise<ExtensionDirEntry[]>;
422
- exists(path: string): Promise<boolean>;
423
- downloadFile(url: string, path: string): Promise<void>;
424
- private: {
425
- readFile(relativePath: string): Promise<Uint8Array>;
426
- writeFile(relativePath: string, data: Uint8Array): Promise<void>;
427
- readDir(relativePath?: string): Promise<ExtensionDirEntry[]>;
428
- exists(relativePath: string): Promise<boolean>;
429
- resolvePath(relativePath: string): Promise<string>;
430
- };
431
- storage: {
432
- readFile(relativePath: string): Promise<Uint8Array>;
433
- writeFile(relativePath: string, data: Uint8Array): Promise<void>;
434
- readDir(relativePath?: string): Promise<ExtensionDirEntry[]>;
435
- exists(relativePath: string): Promise<boolean>;
436
- resolvePath(relativePath: string): Promise<string>;
437
- importFile(sourcePath: string, targetRelativePath: string): Promise<string>;
438
- deleteFile(relativePath: string): Promise<void>;
439
- };
440
- scoped: {
441
- requestDirectoryAccess(options?: {
442
- permission?: 'read' | 'write' | 'readWrite';
443
- title?: string;
444
- defaultPath?: string;
445
- }): Promise<{
446
- granted: boolean;
447
- path?: string;
448
- permissions?: ('read' | 'write')[];
449
- }>;
450
- getDirectories(): Promise<ExtensionScopedDirectory[]>;
451
- readFile(path: string): Promise<Uint8Array>;
452
- writeFile(path: string, data: Uint8Array): Promise<void>;
453
- readDir(path: string): Promise<ExtensionDirEntry[]>;
454
- exists(path: string): Promise<boolean>;
455
- };
456
- };
457
- ui: {
458
- showNotification(options: NotificationOptions): void;
459
- showDialog(options: DialogOptions): Promise<DialogResult>;
460
- copyText(text: string): Promise<void>;
461
- /**
462
- * Writes data to the clipboard. Supported MIME types: `image/png`, `text/html`, `text/plain`.
463
- * When `text/html` is provided alongside `text/plain`, the plain text is used as fallback.
464
- * Writes the first supported representation found across items (image/png > text/html > text/plain).
465
- * Throws if only unsupported types are provided.
466
- */
467
- clipboardWrite(items: Record<string, Uint8Array>[]): Promise<void>;
468
- withProgress<T>(
469
- options: ProgressOptions,
470
- task: (progress: Progress, token: CancellationToken) => Promise<T>
471
- ): Promise<T>;
472
- createModal(options: ModalOptions): ModalHandle;
473
- showModal(options: ModalOptions): Promise<Record<string, unknown> | null>;
474
- input(options: {
475
- id: string;
476
- label?: string;
477
- placeholder?: string;
478
- value?: string;
479
- disabled?: boolean;
480
- }): UIElement;
481
- select(options: {
482
- id: string;
483
- label?: string;
484
- placeholder?: string;
485
- options: UISelectOption[];
486
- value?: string;
487
- disabled?: boolean;
488
- }): UIElement;
489
- checkbox(options: {
490
- id: string;
491
- label?: string;
492
- checked?: boolean;
493
- disabled?: boolean;
494
- }): UIElement;
495
- textarea(options: {
496
- id: string;
497
- label?: string;
498
- placeholder?: string;
499
- value?: string;
500
- rows?: number;
501
- disabled?: boolean;
502
- }): UIElement;
503
- separator(): UIElement;
504
- text(content: string): UIElement;
505
- alert(options: {
506
- title: string;
507
- description?: string;
508
- tone?: 'info' | 'success' | 'warning' | 'error';
509
- }): UIElement;
510
- image(options: {
511
- id?: string;
512
- src: string;
513
- alt?: string;
514
- }): UIElement;
515
- previewCard(options: {
516
- thumbnail: string;
517
- title: string;
518
- subtitle?: string;
519
- }): UIElement;
520
- previewCardSkeleton(): UIElement;
521
- skeleton(options?: {
522
- id?: string;
523
- width?: number;
524
- height?: number;
525
- }): UIElement;
526
- button(options: {
527
- id: string;
528
- label: string;
529
- variant?: 'primary' | 'secondary' | 'danger';
530
- size?: 'xs' | 'sm' | 'default' | 'lg';
531
- disabled?: boolean;
532
- }): UIElement;
533
- renderToolbar(
534
- container: HTMLElement,
535
- elements: UIElement[],
536
- onButtonClick?: (buttonId: string) => void
537
- ): ToolbarRenderHandle;
538
- };
539
- dialog: {
540
- openFile(options?: OpenFileDialogOptions): Promise<string | string[] | null>;
541
- saveFile(options?: SaveFileDialogOptions): Promise<string | null>;
542
- };
543
- shell: {
544
- run(
545
- commandPath: string,
546
- args?: string[]
547
- ): Promise<{
548
- code: number;
549
- stdout: string;
550
- stderr: string;
551
- }>;
552
- runWithProgress(
553
- commandPath: string,
554
- args: string[] | undefined,
555
- onProgress?: (payload: {
556
- taskId: string;
557
- line: string;
558
- isStderr: boolean;
559
- }) => void
560
- ): Promise<{
561
- taskId: string;
562
- result: Promise<{
563
- code: number;
564
- stdout: string;
565
- stderr: string;
566
- }>;
567
- cancel: () => Promise<void>;
568
- }>;
569
- renamePartFilesToTs(directory: string): Promise<number>;
570
- };
571
- settings: {
572
- get<T>(key: string): Promise<T | undefined>;
573
- set<T>(key: string, value: T): Promise<void>;
574
- getAll(): Promise<Record<string, unknown>>;
575
- reset(key: string): Promise<void>;
576
- onChange(key: string, callback: (newValue: unknown, oldValue: unknown) => void): Disposable;
577
- };
578
- storage: {
579
- get<T>(key: string): Promise<T | undefined>;
580
- set<T>(key: string, value: T): Promise<void>;
581
- remove(key: string): Promise<void>;
582
- };
583
- platform: {
584
- readonly os: PlatformOS;
585
- readonly arch: string;
586
- readonly pathSeparator: string;
587
- readonly isWindows: boolean;
588
- readonly isMacos: boolean;
589
- readonly isLinux: boolean;
590
- joinPath(...segments: string[]): string;
591
- };
592
- path: {
593
- dirname(filePath: string): string;
594
- basename(filePath: string, suffix?: string): string;
595
- extname(filePath: string): string;
596
- };
597
- runtime: {
598
- isExtensionInstallCancelledError(error: unknown): boolean;
599
- };
600
- binary: {
601
- getPath(id: string): Promise<string | null>;
602
- isInstalled(id: string): Promise<boolean>;
603
- getInfo(id: string): Promise<BinaryInfo | null>;
604
- };
605
- }
606
-
607
- export interface ExtensionActivationContext {
608
- extensionId: string;
609
- extensionPath: string;
610
- storagePath: string;
611
- activationEvent: ExtensionActivationEvent;
612
- }
613
-
614
- export interface ExtensionModule {
615
- activate?(context: ExtensionActivationContext): Promise<void> | void;
616
- deactivate?(): Promise<void> | void;
617
- }
618
-
619
- export {};
1
+ declare global {
2
+ const sigma: SigmaExtensionAPI;
3
+ }
4
+
5
+ export type ExtensionType = 'api' | 'iframe' | 'webview';
6
+
7
+ /** Flat key–value map for one extension locale file (for example `locales/en.json`). */
8
+ export type ExtensionLocaleStrings = Record<string, string>;
9
+
10
+ export type ExtensionPermission
11
+ = | 'contextMenu'
12
+ | 'sidebar'
13
+ | 'toolbar'
14
+ | 'commands'
15
+ | 'fs.read'
16
+ | 'fs.write'
17
+ | 'notifications'
18
+ | 'dialogs'
19
+ | 'shell'
20
+ | 'clipboard'
21
+ | 'openUrl';
22
+
23
+ export type ExtensionActivationEvent
24
+ = | 'onStartup'
25
+ | 'onInstall'
26
+ | 'onUninstall'
27
+ | 'onEnable'
28
+ | 'onDisable'
29
+ | 'onUpdate'
30
+ | 'onLocaleChange'
31
+ | `onCommand:${string}`;
32
+
33
+ export interface ExtensionPublisher {
34
+ name: string;
35
+ url?: string;
36
+ }
37
+
38
+ export interface ExtensionCommand {
39
+ id: string;
40
+ title: string;
41
+ description?: string;
42
+ icon?: string;
43
+ shortcut?: string;
44
+ }
45
+
46
+ export interface ExtensionContextMenuCondition {
47
+ selectionType?: 'single' | 'multiple' | 'any';
48
+ entryType?: 'file' | 'directory' | 'any';
49
+ fileExtensions?: string[];
50
+ }
51
+
52
+ export interface ExtensionContextMenuItem {
53
+ id: string;
54
+ title: string;
55
+ icon?: string;
56
+ when?: ExtensionContextMenuCondition;
57
+ group?: string;
58
+ order?: number;
59
+ }
60
+
61
+ export interface ExtensionSidebarItem {
62
+ id: string;
63
+ title: string;
64
+ icon: string;
65
+ order?: number;
66
+ url?: string;
67
+ shortcutCommandId?: string;
68
+ }
69
+
70
+ export interface ExtensionToolbarDropdownItem {
71
+ id: string;
72
+ title: string;
73
+ icon?: string;
74
+ commandId?: string;
75
+ separator?: boolean;
76
+ }
77
+
78
+ export interface ExtensionToolbarDropdown {
79
+ id: string;
80
+ title: string;
81
+ icon?: string;
82
+ items: ExtensionToolbarDropdownItem[];
83
+ }
84
+
85
+ export type ExtensionConfigurationPropertyType = 'string' | 'number' | 'boolean' | 'array';
86
+
87
+ export interface ExtensionConfigurationProperty {
88
+ type: ExtensionConfigurationPropertyType;
89
+ default?: unknown;
90
+ description?: string;
91
+ enum?: (string | number)[];
92
+ enumDescriptions?: string[];
93
+ minimum?: number;
94
+ maximum?: number;
95
+ minLength?: number;
96
+ maxLength?: number;
97
+ items?: {
98
+ type: 'string' | 'number';
99
+ };
100
+ }
101
+
102
+ export interface ExtensionConfiguration {
103
+ title?: string;
104
+ properties: Record<string, ExtensionConfigurationProperty>;
105
+ }
106
+
107
+ export type ExtensionThemeBase = 'light' | 'dark';
108
+
109
+ export interface ExtensionThemeContribution {
110
+ id: string;
111
+ title: string;
112
+ description?: string;
113
+ baseTheme: ExtensionThemeBase;
114
+ variables: Record<`--${string}`, string>;
115
+ }
116
+
117
+ export type ExtensionKeybindingWhen
118
+ = | 'always'
119
+ | 'fileSelected'
120
+ | 'directorySelected'
121
+ | 'singleSelected'
122
+ | 'multipleSelected'
123
+ | 'navigatorFocused';
124
+
125
+ export interface ExtensionKeybinding {
126
+ command: string;
127
+ key: string;
128
+ when?: ExtensionKeybindingWhen;
129
+ }
130
+
131
+ export interface ExtensionContributions {
132
+ commands?: ExtensionCommand[];
133
+ contextMenu?: ExtensionContextMenuItem[];
134
+ sidebar?: ExtensionSidebarItem[];
135
+ toolbar?: ExtensionToolbarDropdown[];
136
+ themes?: ExtensionThemeContribution[];
137
+ configuration?: ExtensionConfiguration;
138
+ keybindings?: ExtensionKeybinding[];
139
+ }
140
+
141
+ export interface ExtensionEngines {
142
+ sigmaFileManager: string;
143
+ }
144
+
145
+ export type PlatformOS = 'windows' | 'macos' | 'linux';
146
+ export type PlatformArch = 'x64' | 'arm64';
147
+
148
+ export interface ManifestBinaryAsset {
149
+ platform: PlatformOS;
150
+ arch?: PlatformArch[];
151
+ downloadUrl: string;
152
+ integrity: string;
153
+ archive?: boolean;
154
+ executable?: string;
155
+ }
156
+
157
+ export interface ManifestBinaryDefinition {
158
+ id: string;
159
+ name: string;
160
+ version: string;
161
+ executable?: string;
162
+ repository?: string;
163
+ platforms?: PlatformOS[];
164
+ assets: ManifestBinaryAsset[];
165
+ }
166
+
167
+ export type ExtensionManifestMediaType = 'image' | 'video';
168
+
169
+ export interface ExtensionManifestMediaItem {
170
+ title: string;
171
+ src: string;
172
+ type: ExtensionManifestMediaType;
173
+ }
174
+
175
+ export interface ExtensionManifest {
176
+ id: string;
177
+ name: string;
178
+ previousName?: string;
179
+ version: string;
180
+ publisher?: ExtensionPublisher;
181
+ repository: string;
182
+ license: string;
183
+ icon?: string;
184
+ banner?: string;
185
+ media?: ExtensionManifestMediaItem[];
186
+ categories?: string[];
187
+ tags?: string[];
188
+ extensionType: ExtensionType;
189
+ main?: string;
190
+ permissions: ExtensionPermission[];
191
+ activationEvents?: ExtensionActivationEvent[];
192
+ contributes?: ExtensionContributions;
193
+ platforms?: PlatformOS[];
194
+ binaries?: ManifestBinaryDefinition[];
195
+ engines: ExtensionEngines;
196
+ }
197
+
198
+ export interface Disposable {
199
+ dispose(): void;
200
+ }
201
+
202
+ export interface ContextMenuContext {
203
+ selectedEntries: {
204
+ path: string;
205
+ name: string;
206
+ isDirectory: boolean;
207
+ size?: number;
208
+ extension?: string;
209
+ }[];
210
+ }
211
+
212
+ export interface NotificationOptions {
213
+ title: string;
214
+ subtitle?: string;
215
+ description?: string;
216
+ type?: 'info' | 'success' | 'warning' | 'error';
217
+ duration?: number;
218
+ }
219
+
220
+ export interface DialogOptions {
221
+ title: string;
222
+ message: string;
223
+ type?: 'info' | 'confirm' | 'prompt';
224
+ confirmText?: string;
225
+ cancelText?: string;
226
+ defaultValue?: string;
227
+ }
228
+
229
+ export interface DialogResult {
230
+ confirmed: boolean;
231
+ value?: string;
232
+ }
233
+
234
+ export type ProgressLocation = 'notification' | 'statusBar';
235
+
236
+ export interface ProgressOptions {
237
+ subtitle: string;
238
+ location?: ProgressLocation;
239
+ cancellable?: boolean;
240
+ }
241
+
242
+ export interface ProgressReport {
243
+ subtitle?: string;
244
+ description?: string;
245
+ increment?: number;
246
+ value?: number;
247
+ }
248
+
249
+ export interface Progress {
250
+ report(value: ProgressReport): void;
251
+ }
252
+
253
+ export interface CancellationToken {
254
+ readonly isCancellationRequested: boolean;
255
+ onCancellationRequested(listener: () => void): Disposable;
256
+ }
257
+
258
+ export interface ExtensionDirEntry {
259
+ path: string;
260
+ name: string;
261
+ isDirectory: boolean;
262
+ size?: number;
263
+ modifiedAt?: number;
264
+ }
265
+
266
+ export interface ExtensionScopedDirectory {
267
+ path: string;
268
+ permissions: ('read' | 'write')[];
269
+ grantedAt: number;
270
+ }
271
+
272
+ export interface ExtensionContextEntry {
273
+ path: string;
274
+ name: string;
275
+ isDirectory: boolean;
276
+ isFile: boolean;
277
+ size: number;
278
+ extension: string | null;
279
+ createdAt: number;
280
+ modifiedAt: number;
281
+ }
282
+
283
+ export interface BuiltinCommandInfo {
284
+ id: string;
285
+ title: string;
286
+ description: string;
287
+ }
288
+
289
+ export interface FileDialogFilter {
290
+ name: string;
291
+ extensions: string[];
292
+ }
293
+
294
+ export interface OpenFileDialogOptions {
295
+ title?: string;
296
+ defaultPath?: string;
297
+ filters?: FileDialogFilter[];
298
+ multiple?: boolean;
299
+ directory?: boolean;
300
+ }
301
+
302
+ export interface SaveFileDialogOptions {
303
+ title?: string;
304
+ defaultPath?: string;
305
+ filters?: FileDialogFilter[];
306
+ }
307
+
308
+ export interface BinaryInfo {
309
+ id: string;
310
+ path: string;
311
+ version?: string;
312
+ storageVersion?: string | null;
313
+ repository?: string;
314
+ downloadUrl?: string;
315
+ latestVersion?: string;
316
+ hasUpdate?: boolean;
317
+ latestCheckedAt?: number;
318
+ installedAt: number;
319
+ }
320
+
321
+ export type UIElementType
322
+ = | 'input'
323
+ | 'select'
324
+ | 'checkbox'
325
+ | 'textarea'
326
+ | 'button'
327
+ | 'separator'
328
+ | 'text'
329
+ | 'image'
330
+ | 'skeleton'
331
+ | 'alert'
332
+ | 'previewCard'
333
+ | 'previewCardSkeleton';
334
+
335
+ export interface UISelectOption {
336
+ value: string;
337
+ label: string;
338
+ }
339
+
340
+ export interface UIElement {
341
+ type: UIElementType;
342
+ id?: string;
343
+ label?: string;
344
+ placeholder?: string;
345
+ value?: string | boolean | number;
346
+ options?: UISelectOption[];
347
+ rows?: number;
348
+ variant?: 'primary' | 'secondary' | 'danger';
349
+ tone?: 'info' | 'success' | 'warning' | 'error';
350
+ size?: 'xs' | 'sm' | 'default' | 'lg';
351
+ disabled?: boolean;
352
+ subtitle?: string;
353
+ }
354
+
355
+ export interface KeyboardShortcut {
356
+ key: string;
357
+ modifiers?: ('ctrl' | 'shift' | 'alt' | 'meta')[];
358
+ }
359
+
360
+ export interface ModalButton {
361
+ id: string;
362
+ label: string;
363
+ variant?: 'primary' | 'secondary' | 'danger';
364
+ shortcut?: KeyboardShortcut;
365
+ }
366
+
367
+ export interface ModalOptions {
368
+ title: string;
369
+ width?: number;
370
+ content: UIElement[];
371
+ buttons?: ModalButton[];
372
+ }
373
+
374
+ export interface ModalHandle {
375
+ onSubmit(callback: (values: Record<string, unknown>, buttonId: string) => void | boolean | Promise<void | boolean>): void;
376
+ onClose(callback: () => void): void;
377
+ onValueChange(callback: (elementId: string, value: unknown, allValues: Record<string, unknown>) => void): void;
378
+ close(): void;
379
+ updateElement(id: string, updates: Partial<UIElement>): void;
380
+ setContent(content: UIElement[]): void;
381
+ setButtons(buttons: ModalButton[]): void;
382
+ getValues(): Record<string, unknown>;
383
+ }
384
+
385
+ export interface ToolbarRenderHandle {
386
+ unmount(): void;
387
+ }
388
+
389
+ export interface PlatformInfo {
390
+ os: PlatformOS;
391
+ arch: string;
392
+ pathSeparator: string;
393
+ isWindows: boolean;
394
+ isMacos: boolean;
395
+ isLinux: boolean;
396
+ }
397
+
398
+ export interface SigmaExtensionAPI {
399
+ i18n: {
400
+ t(key: string, params?: Record<string, string | number>): string;
401
+ mergeMessages(messages: Record<string, Record<string, string>>): void;
402
+ mergeFromPath(basePath: string): Promise<void>;
403
+ /**
404
+ * Resolves extension-localized strings under `extensions.<extensionId>.<key>`.
405
+ * When no translation exists, this returns `fallback` if provided, otherwise the original `key`.
406
+ */
407
+ extensionT(key: string, params?: Record<string, string | number>, fallback?: string): string;
408
+ formatMessage(template: string, params?: Record<string, string | number>): string;
409
+ };
410
+ contextMenu: {
411
+ registerItem(
412
+ item: ExtensionContextMenuItem,
413
+ handler: (context: ContextMenuContext) => Promise<void> | void
414
+ ): Disposable;
415
+ };
416
+ sidebar: {
417
+ registerPage(page: ExtensionSidebarItem): Disposable;
418
+ };
419
+ toolbar: {
420
+ registerDropdown(
421
+ dropdown: ExtensionToolbarDropdown,
422
+ handlers: Record<string, () => Promise<void> | void>
423
+ ): Disposable;
424
+ };
425
+ commands: {
426
+ registerCommand(
427
+ command: ExtensionCommand,
428
+ handler: (...args: unknown[]) => Promise<unknown> | unknown
429
+ ): Disposable;
430
+ executeCommand(commandId: string, ...args: unknown[]): Promise<unknown>;
431
+ getBuiltinCommands(): BuiltinCommandInfo[];
432
+ };
433
+ context: {
434
+ getCurrentPath(): string | null;
435
+ getSelectedEntries(): ExtensionContextEntry[];
436
+ getAppVersion(): Promise<string>;
437
+ getDownloadsDir(): Promise<string>;
438
+ getPicturesDir(): Promise<string>;
439
+ openUrl(url: string): Promise<void>;
440
+ onPathChange(callback: (path: string | null) => void): Disposable;
441
+ onSelectionChange(callback: (entries: ExtensionContextEntry[]) => void): Disposable;
442
+ };
443
+ fs: {
444
+ readFile(path: string): Promise<Uint8Array>;
445
+ writeFile(path: string, data: Uint8Array): Promise<void>;
446
+ readDir(path: string): Promise<ExtensionDirEntry[]>;
447
+ exists(path: string): Promise<boolean>;
448
+ downloadFile(url: string, path: string): Promise<void>;
449
+ private: {
450
+ readFile(relativePath: string): Promise<Uint8Array>;
451
+ writeFile(relativePath: string, data: Uint8Array): Promise<void>;
452
+ readDir(relativePath?: string): Promise<ExtensionDirEntry[]>;
453
+ exists(relativePath: string): Promise<boolean>;
454
+ resolvePath(relativePath: string): Promise<string>;
455
+ };
456
+ storage: {
457
+ readFile(relativePath: string): Promise<Uint8Array>;
458
+ writeFile(relativePath: string, data: Uint8Array): Promise<void>;
459
+ readDir(relativePath?: string): Promise<ExtensionDirEntry[]>;
460
+ exists(relativePath: string): Promise<boolean>;
461
+ resolvePath(relativePath: string): Promise<string>;
462
+ importFile(sourcePath: string, targetRelativePath: string): Promise<string>;
463
+ deleteFile(relativePath: string): Promise<void>;
464
+ };
465
+ scoped: {
466
+ requestDirectoryAccess(options?: {
467
+ permission?: 'read' | 'write' | 'readWrite';
468
+ title?: string;
469
+ defaultPath?: string;
470
+ }): Promise<{
471
+ granted: boolean;
472
+ path?: string;
473
+ permissions?: ('read' | 'write')[];
474
+ }>;
475
+ getDirectories(): Promise<ExtensionScopedDirectory[]>;
476
+ readFile(path: string): Promise<Uint8Array>;
477
+ writeFile(path: string, data: Uint8Array): Promise<void>;
478
+ readDir(path: string): Promise<ExtensionDirEntry[]>;
479
+ exists(path: string): Promise<boolean>;
480
+ };
481
+ };
482
+ ui: {
483
+ showNotification(options: NotificationOptions): void;
484
+ showDialog(options: DialogOptions): Promise<DialogResult>;
485
+ copyText(text: string): Promise<void>;
486
+ /**
487
+ * Writes data to the clipboard. Supported MIME types: `image/png`, `text/html`, `text/plain`.
488
+ * When `text/html` is provided alongside `text/plain`, the plain text is used as fallback.
489
+ * Writes the first supported representation found across items (image/png > text/html > text/plain).
490
+ * Throws if only unsupported types are provided.
491
+ */
492
+ clipboardWrite(items: Record<string, Uint8Array>[]): Promise<void>;
493
+ withProgress<T>(
494
+ options: ProgressOptions,
495
+ task: (progress: Progress, token: CancellationToken) => Promise<T>
496
+ ): Promise<T>;
497
+ createModal(options: ModalOptions): ModalHandle;
498
+ showModal(options: ModalOptions): Promise<Record<string, unknown> | null>;
499
+ input(options: {
500
+ id: string;
501
+ label?: string;
502
+ placeholder?: string;
503
+ value?: string;
504
+ disabled?: boolean;
505
+ }): UIElement;
506
+ select(options: {
507
+ id: string;
508
+ label?: string;
509
+ placeholder?: string;
510
+ options: UISelectOption[];
511
+ value?: string;
512
+ disabled?: boolean;
513
+ }): UIElement;
514
+ checkbox(options: {
515
+ id: string;
516
+ label?: string;
517
+ checked?: boolean;
518
+ disabled?: boolean;
519
+ }): UIElement;
520
+ textarea(options: {
521
+ id: string;
522
+ label?: string;
523
+ placeholder?: string;
524
+ value?: string;
525
+ rows?: number;
526
+ disabled?: boolean;
527
+ }): UIElement;
528
+ separator(): UIElement;
529
+ text(content: string): UIElement;
530
+ alert(options: {
531
+ title: string;
532
+ description?: string;
533
+ tone?: 'info' | 'success' | 'warning' | 'error';
534
+ }): UIElement;
535
+ image(options: {
536
+ id?: string;
537
+ src: string;
538
+ alt?: string;
539
+ }): UIElement;
540
+ previewCard(options: {
541
+ thumbnail: string;
542
+ title: string;
543
+ subtitle?: string;
544
+ }): UIElement;
545
+ previewCardSkeleton(): UIElement;
546
+ skeleton(options?: {
547
+ id?: string;
548
+ width?: number;
549
+ height?: number;
550
+ }): UIElement;
551
+ button(options: {
552
+ id: string;
553
+ label: string;
554
+ variant?: 'primary' | 'secondary' | 'danger';
555
+ size?: 'xs' | 'sm' | 'default' | 'lg';
556
+ disabled?: boolean;
557
+ }): UIElement;
558
+ renderToolbar(
559
+ container: HTMLElement,
560
+ elements: UIElement[],
561
+ onButtonClick?: (buttonId: string) => void
562
+ ): ToolbarRenderHandle;
563
+ };
564
+ dialog: {
565
+ openFile(options?: OpenFileDialogOptions): Promise<string | string[] | null>;
566
+ saveFile(options?: SaveFileDialogOptions): Promise<string | null>;
567
+ };
568
+ shell: {
569
+ run(
570
+ commandPath: string,
571
+ args?: string[]
572
+ ): Promise<{
573
+ code: number;
574
+ stdout: string;
575
+ stderr: string;
576
+ }>;
577
+ runWithProgress(
578
+ commandPath: string,
579
+ args: string[] | undefined,
580
+ onProgress?: (payload: {
581
+ taskId: string;
582
+ line: string;
583
+ isStderr: boolean;
584
+ }) => void
585
+ ): Promise<{
586
+ taskId: string;
587
+ result: Promise<{
588
+ code: number;
589
+ stdout: string;
590
+ stderr: string;
591
+ }>;
592
+ cancel: () => Promise<void>;
593
+ }>;
594
+ renamePartFilesToTs(directory: string): Promise<number>;
595
+ };
596
+ settings: {
597
+ get<T>(key: string): Promise<T | undefined>;
598
+ set<T>(key: string, value: T): Promise<void>;
599
+ getAll(): Promise<Record<string, unknown>>;
600
+ reset(key: string): Promise<void>;
601
+ onChange(key: string, callback: (newValue: unknown, oldValue: unknown) => void): Disposable;
602
+ };
603
+ storage: {
604
+ get<T>(key: string): Promise<T | undefined>;
605
+ set<T>(key: string, value: T): Promise<void>;
606
+ remove(key: string): Promise<void>;
607
+ };
608
+ platform: {
609
+ readonly os: PlatformOS;
610
+ readonly arch: string;
611
+ readonly pathSeparator: string;
612
+ readonly isWindows: boolean;
613
+ readonly isMacos: boolean;
614
+ readonly isLinux: boolean;
615
+ joinPath(...segments: string[]): string;
616
+ };
617
+ path: {
618
+ dirname(filePath: string): string;
619
+ basename(filePath: string, suffix?: string): string;
620
+ extname(filePath: string): string;
621
+ };
622
+ runtime: {
623
+ isExtensionInstallCancelledError(error: unknown): boolean;
624
+ };
625
+ binary: {
626
+ getPath(id: string): Promise<string | null>;
627
+ isInstalled(id: string): Promise<boolean>;
628
+ getInfo(id: string): Promise<BinaryInfo | null>;
629
+ };
630
+ }
631
+
632
+ export interface ExtensionActivationContext {
633
+ extensionId: string;
634
+ extensionPath: string;
635
+ storagePath: string;
636
+ activationEvent: ExtensionActivationEvent;
637
+ }
638
+
639
+ export interface ExtensionModule {
640
+ activate?(context: ExtensionActivationContext): Promise<void> | void;
641
+ deactivate?(): Promise<void> | void;
642
+ }
643
+
644
+ export {};