-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi-index.d.ts
8789 lines (8461 loc) · 283 KB
/
api-index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/// <reference types="node" />
import { ForwardRefExoticComponent } from 'react';
import { FunctionComponent } from 'react';
import { JSX as JSX_2 } from 'react/jsx-runtime';
import { PathLike } from 'fs';
import { ReactElement } from 'react';
import { ReactNode } from 'react';
import { RefAttributes } from 'react';
/**
* A context-specific action that can be performed by the user.
*
* @remarks
* Assign keyboard shortcuts to items to make it easier for users to perform frequently used actions.
*
* @example
* ```typescript
* import { ActionPanel, Action, List } from "@raycast/api";
*
* export default function Command() {
* return (
* <List navigationTitle="Open Pull Requests">
* <List.Item
* title="Docs: Update API Reference"
* subtitle="#1"
* actions={
* <ActionPanel title="#1 in raycast/extensions">
* <Action.OpenInBrowser url="https://github.com/raycast/extensions/pull/1" />
* <Action.CopyToClipboard title="Copy Pull Request Number" content="#1" />
* <Action title="Close Pull Request" onAction={() => console.log("Close PR #1")} />
* </ActionPanel>
* }
* />
* </List>
* );
* }
* ```
*/
export declare const Action: FunctionComponent<ActionProps> & ConvenienceActions & {
Style: typeof ActionStyle;
};
export declare namespace Action {
export type Props = ActionProps;
export type Style = ActionStyle;
export namespace CopyToClipboard {
/**
* Props of the {@link Action.CopyToClipboard} React component.
*/
export type Props = CopyToClipboardProps;
}
export namespace CreateQuicklink {
/**
* Props of the {@link Action.CreateQuicklink} React component.
*/
export type Props = CreateQuicklinkProps;
}
export namespace CreateSnippet {
/**
* Props of the {@link Action.CreateSnippet} React component.
*/
export type Props = CreateSnippetProps;
}
export namespace Open {
/**
* Props of the {@link Action.Open} React component.
*/
export type Props = OpenProps;
}
export namespace OpenInBrowser {
/**
* Props of the {@link Action.OpenInBrowser} React component.
*/
export type Props = OpenInBrowserProps;
}
export namespace OpenWith {
/**
* Props of the {@link Action.OpenWith} React component.
*/
export type Props = OpenWithProps;
}
export namespace Paste {
/**
* Props of the {@link Action.Paste} React component.
*/
export type Props = PasteProps;
}
export namespace Push {
/**
* Props of the {@link Action.Push} React component.
*/
export type Props = PushProps;
}
export namespace ShowInFinder {
/**
* Props of the {@link Action.ShowInFinder} React component.
*/
export type Props = ShowInFinderProps;
}
export namespace SubmitForm {
/**
* Props of the {@link Action.SubmitForm} React component.
*/
export type Props<T extends Form.Values> = SubmitFormProps<T>;
}
export namespace Trash {
/**
* Props of the {@link Action.Trash} React component.
*/
export type Props = TrashProps;
}
export namespace ToggleQuickLook {
/**
* Props of the {@link Action.ToggleQuickLook} React component.
*/
export type Props = ToggleQuickLookProps;
}
export namespace PickDate {
/**
* Props of the {@link Action.PickDate} React component.
*/
export type Props = PickDateProps;
/**
* The types of date components the user can pick
* * `Date` - only year, month, and day can be picked
* * `DateTime` - hour and second can be picked in addition to year, month and day
*/
export type Type = DatePickerType_2;
}
}
/**
* Exposes a list of actions that can be performed by the user.
*
* @remarks
* Often items are context-aware, e.g. based on the selected list item. Actions can be grouped into semantic
* sections and can have keyboard shortcuts assigned.
*
* The first and second action become the primary and secondary action. They automatically get the default keyboard shortcuts assigned.
* In {@link List}, {@link Grid}, and {@link Detail}, this is `↵` for the primary and `⌘` `↵` for the secondary action. In {@link Form} it's `⌘` `↵` for the primary and
* `⌘` `⇧` `↵` for the secondary.
* Keep in mind that while you can specify an alternative shortcut for the primary and secondary actions, it won't be displayed in the Action Panel.
*
* @example
* ```typescript
* import { ActionPanel, Action, List } from "@raycast/api";
*
* export default function Command() {
* return (
* <List navigationTitle="Open Pull Requests">
* <List.Item
* title="Docs: Update API Reference"
* subtitle="#1"
* actions={
* <ActionPanel title="#1 in raycast/extensions">
* <Action.OpenInBrowser url="https://github.com/raycast/extensions/pull/1" />
* <Action.CopyToClipboard
* title="Copy Pull Request URL"
* content="https://github.com/raycast/extensions/pull/1"
* />
* </ActionPanel>
* }
* />
* </List>
* );
* }
* ```
*/
export declare const ActionPanel: FunctionComponent<ActionPanelProps_2> & DeprecatedActionPanelMembers & ActionPanelMembers;
export declare namespace ActionPanel {
/**
* Props of the {@link ActionPanel} React component.
*/
export type Props = ActionPanelProps_2;
/**
* Supported children for the {@link ActionPanel} components.
*/
export type Children = ActionPanelChildren_2;
export namespace Section {
/**
* Props of the {@link ActionPanel.Section} React component.
*/
export type Props = SectionProps;
/**
* Supported children for the {@link ActionPanel.Section} component.
*/
export type Children = SectionChildren;
}
export namespace Submenu {
/**
* Props of the {@link ActionPanel.Submenu} React component.
*/
export type Props = SubmenuProps;
/**
* Supported children for the {@link ActionPanel.Submenu} components.
*/
export type Children = SubmenuChildren;
}
}
/**
* @deprecated Use {@link ActionPanel.Children} instead.
*/
export declare type ActionPanelChildren = ActionPanel.Children;
declare type ActionPanelChildren_2 = ReactElement<ActionPanel.Section.Props> | ReactElement<ActionPanel.Section.Props>[] | ActionPanel.Section.Children | null;
/**
* @deprecated Use {@link Action} instead.
*/
export declare const ActionPanelItem: FunctionComponent<ActionProps> & ConvenienceActions & {
Style: ActionStyle;
};
/**
* @deprecated Use {@link Action.Props} instead.
*/
export declare interface ActionPanelItemProps extends Action.Props {
}
declare interface ActionPanelMembers {
/**
* A group of visually separated items.
*
* @remarks
* Use sections when the {@link ActionPanel} contains a lot of actions to help guide the user to related actions.
* For example, create a section for all copy actions.
*
* @example
* ```typescript
* import { ActionPanel, Action, List } from "@raycast/api";
*
* export default function Command() {
* return (
* <List navigationTitle="Open Pull Requests">
* <List.Item
* title="Docs: Update API Reference"
* subtitle="#1"
* actions={
* <ActionPanel title="#1 in raycast/extensions">
* <ActionPanel.Section title="Copy">
* <Action.CopyToClipboard title="Copy Pull Request Number" content="#1" />
* <Action.CopyToClipboard
* title="Copy Pull Request URL"
* content="https://github.com/raycast/extensions/pull/1"
* />
* <Action.CopyToClipboard title="Copy Pull Request Title" content="Docs: Update API Reference" />
* </ActionPanel.Section>
* <ActionPanel.Section title="Danger zone">
* <Action title="Close Pull Request" onAction={() => console.log("Close PR #1")} />
* </ActionPanel.Section>
* </ActionPanel>
* }
* />
* </List>
* );
* }
* ```
*/
Section: typeof Section;
/**
* An action that replaces the current ActionPanel with its children when selected.
*
* @remarks
* This is handy when an action needs to select from a range of options. For example, to add a label to a GitHub pull request
* or an assignee to a todo.
*
* @example
* ```typescript
* import { ActionPanel, Color, Icon, List, Action } from "@raycast/api";
*
* export default function Command() {
* return (
* <List navigationTitle="Open Pull Requests">
* <List.Item
* title="Docs: Update API Reference"
* subtitle="#1"
* actions={
* <ActionPanel title="#1 in raycast/extensions">
* <ActionPanel.Submenu title="Add Label">
* <Action
* icon={{ source: Icon.Circle, tintColor: Color.Red }}
* title="Bug"
* onAction={() => console.log("Add bug label")}
* />
* <Action
* icon={{ source: Icon.Circle, tintColor: Color.Yellow }}
* title="Enhancement"
* onAction={() => console.log("Add enhancement label")}
* />
* <Action
* icon={{ source: Icon.Circle, tintColor: Color.Blue }}
* title="Help Wanted"
* onAction={() => console.log("Add help wanted label")}
* />
* </ActionPanel.Submenu>
* </ActionPanel>
* }
* />
* </List>
* );
* }
* ```
*/
Submenu: typeof Submenu;
}
/**
* @deprecated Use {@link ActionPanel.Props} instead.
*/
export declare interface ActionPanelProps extends ActionPanel.Props {
}
declare interface ActionPanelProps_2 {
/**
* Sections or Actions. If {@link Action} elements are specified, a default section is automatically created.
*/
children?: ReactNode;
/**
* The title displayed at the top of the panel
*/
title?: string;
}
/**
* @deprecated Use {@link ActionPanel.Section} instead.
*/
export declare const ActionPanelSection: typeof ActionPanel.Section;
/**
* @deprecated Use {@link ActionPanel.Section.Children} instead.
*/
export declare type ActionPanelSectionChildren = ActionPanel.Section.Children;
/**
* @deprecated Use {@link ActionPanel.Section.Props} instead.
*/
export declare interface ActionPanelSectionProps extends ActionPanel.Section.Props {
}
/**
* @deprecated No alternative :(
*/
export declare interface ActionPanelState {
/**
* @deprecated No alternative :(
*/
update: (actionPanel: ReactNode) => void;
}
/**
* @deprecated Use {@link ActionPanel.Submenu} instead.
*/
export declare const ActionPanelSubmenu: typeof ActionPanel.Submenu;
/**
* @deprecated Use {@link ActionPanel.Submenu.Props} instead.
*/
export declare interface ActionPanelSubmenuProps extends ActionPanel.Submenu.Props {
}
/**
* Props of the {@link Action} React component.
*/
declare interface ActionProps {
/**
* ID of the item.
* @deprecated - This is an internal prop which should not have been exposed. You can safely remove it.
*/
id?: string;
/**
* The title displayed for the Action.
*/
title: string;
/**
* The icon displayed for the Action.
*/
icon?: Image.ImageLike | undefined | null;
/**
* Defines the visual style of the Action.
*
* @remarks
* Use {@link Action.Style.Regular} for displaying a regular actions.
* Use {@link Action.Style.Destructive} when your action has something that user should be careful about.
* Use the confirmation {@link Alert} if the action is doing something that user cannot revert.
* @defaultValue {@link Action.Style.Regular}
*/
style?: ActionStyle;
/**
* The keyboard shortcut for the Action.
*
* @remarks
* The first and second action in an {@link ActionPanel} become the primary and secondary action. They automatically get the default keyboard shortcuts assigned.
* In {@link List}, {@link Grid} ,and {@link Detail}, this is `↵` for the primary and `⌘` `↵` for the secondary action. In {@link Form} it's `⌘` `↵` for the primary and `⌘` `⇧` `↵` for the secondary.
* Keep in mind that while you can specify an alternative shortcut for the primary and secondary actions, it won't be displayed in the Action Panel.
*/
shortcut?: Keyboard.Shortcut | undefined | null;
/**
* Callback that is triggered when the Action is selected.
*/
onAction?: () => void;
/**
* Indicates whether the Action should be focused automatically when the parent ActionPanel (or Actionpanel.Submenu) opens.
*/
autoFocus?: boolean;
}
/**
* Components that support an Action Panel.
*/
declare interface ActionsInterface {
/**
* A reference to an {@link ActionPanel}.
*/
actions?: ReactNode;
}
/**
* Defines the visual style of the Action.
*
* @remarks
* Use {@link Action.Style.Regular} for displaying a regular actions.
* Use {@link Action.Style.Destructive} when your action has something that user should be careful about.
* Use the confirmation {@link Alert} if the action is doing something that user cannot revert.
*/
declare enum ActionStyle {
Regular = "regular",
Destructive = "destructive"
}
export declare namespace AI {
/**
* Returns a prompt completion.
*
* @param prompt - The prompt to ask the AI.
* @param options - Options to control which and how the AI model should behave.
*
* @example
* ```typescript
* import { Detail, AI, LaunchProps } from "@raycast/api";
* import { usePromise } from "@raycast/utils";
* import { useState } from "react";
*
* export default function Command(props: LaunchProps<{ arguments: { prompt: string } }>) {
* const [data, setData] = useState("");
* const { isLoading } = usePromise(
* async (prompt) => {
* const stream = AI.ask(prompt);
* stream.on("data", (data) => {
* setData((x) => x + data);
* });
* await stream;
* },
* [props.arguments.prompt]
* );
*
* return <Detail isLoading={isLoading} markdown={data} />;
* }
* ```
*/
export function ask(prompt: string, options?: AskOptions): Promise<string> & {
on(event: "data", listener: (chunk: string) => void): void;
};
export type AskOptions = {
/**
* Concrete tasks, such as fixing grammar, require less creativity while open-ended questions, such as generating ideas, require more.
* If a number is passed, it needs to be in the range 0-2. For larger values, 2 will be used. For lower values, 0 will be used.
*/
creativity?: Creativity;
/**
* The AI model to use to answer to the prompt.
*/
model?: Model | __DeprecatedModelUnion;
/**
* Abort signal to cancel the request.
*/
signal?: AbortSignal;
};
/**
* Concrete tasks, such as fixing grammar, require less creativity while open-ended questions, such as generating ideas, require more.
* If a number is passed, it needs to be in the range 0-2. For larger values, 2 will be used. For lower values, 0 will be used.
*/
export type Creativity = "none" | "low" | "medium" | "high" | "maximum" | number;
/**
* The AI model to use to answer to the prompt.
* @defaultValue `AI.Model["OpenAI_GPT4o-mini"]`
*/
export enum Model {
OpenAI_GPT4 = "openai-gpt-4",
"OpenAI_GPT4-turbo" = "openai-gpt-4-turbo",
OpenAI_GPT4o = "openai-gpt-4o",
"OpenAI_GPT4o-mini" = "openai-gpt-4o-mini",
Anthropic_Claude_Haiku = "anthropic-claude-haiku",
Anthropic_Claude_Opus = "anthropic-claude-opus",
Anthropic_Claude_Sonnet = "anthropic-claude-sonnet",
MixtraL_8x7B = "mixtral-8x7b",
"Mistral_Nemo" = "mistral-nemo",
Llama3_70B = "llama3-70b",
"Llama3.3_70B" = "groq-llama-3.3-70b-versatile",
"Llama3.1_8B" = "llama3.1-8b",
"Llama3.1_405B" = "llama3.1-405b",
"Mistral_Large" = "mistral-large",
"Mistral_Small" = "mistral-small",
"Mistral_Codestral" = "mistral-codestral",
"OpenAI_o1-preview" = "openai_o1-o1-preview",
"OpenAI_o1-mini" = "openai_o1-o1-mini",
"OpenAI_o3-mini" = "openai_o1-o3-mini",
"Perplexity_Sonar" = "perplexity-sonar",
"Perplexity_Sonar_Pro" = "perplexity-sonar-pro",
"Perplexity_Sonar_Reasoning" = "perplexity-sonar-reasoning",
"Groq_DeepSeek_R1_Distill_Llama_3.3_70B" = "groq-deepseek-r1-distill-llama-70b",
"Google_Gemini_1.5_Flash" = "google-gemini-1.5-flash",
"Google_Gemini_1.5_Pro" = "google-gemini-1.5-pro",
"Google_Gemini_2.0_Flash" = "google-gemini-2.0-flash",
"Google_Gemini_2.0_Flash_Thinking" = "google-gemini-2.0-flash-thinking",
"Together_DeepSeek_R1" = "together-deepseek-ai/DeepSeek-R1",
"xAI_Grok_2" = "xai-grok-2-latest",
/** @deprecated Use `AI.Model["OpenAI_GPT4o-mini"]` instead */
"OpenAI_GPT3.5-turbo-instruct" = "openai-gpt-3.5-turbo-instruct",
/** @deprecated Use `AI.Model.Llama3_70B` instead */
Llama2_70B = "llama2-70b",
/** @deprecated Use `AI.Model.Perplexity_Llama3_Sonar_Large` instead */
Perplexity_Sonar_Medium_Online = "perplexity-sonar-medium-online",
/** @deprecated Use `AI.Model.Perplexity_Llama3_Sonar_Small` instead */
Perplexity_Sonar_Small_Online = "perplexity-sonar-small-online",
/** @deprecated Use `AI.Model.Llama3_70B` instead */
Codellama_70B_instruct = "codellama-70b-instruct",
/** @deprecated Use `AI.Model["Perplexity_Llama3.1_Sonar_Large"]` instead */
Perplexity_Llama3_Sonar_Large = "perplexity-llama-3-sonar-large-online",
/** @deprecated Use `AI.Model["Perplexity_Llama3.1_Sonar_Small"]` instead */
Perplexity_Llama3_Sonar_Small = "perplexity-llama-3-sonar-small-online",
/** @deprecated Use `AI.Model["OpenAI_GPT4o-mini"]` instead */
"OpenAI_GPT3.5-turbo" = "openai-gpt-3.5-turbo",
/** @deprecated Use `AI.Model["Llama3.3_70B"]` instead */
"Llama3.1_70B" = "llama3.1-70b",
/** @deprecated Use `AI.Model["Perplexity_Sonar_Pro"]` instead */
"Perplexity_Llama3.1_Sonar_Huge" = "perplexity-llama-3.1-sonar-huge-128k-online",
/** @deprecated Use `AI.Model["Perplexity_Sonar"]` instead */
"Perplexity_Llama3.1_Sonar_Large" = "perplexity-llama-3.1-sonar-large-128k-online",
/** @deprecated Use `AI.Model["Perplexity_Sonar"]` instead */
"Perplexity_Llama3.1_Sonar_Small" = "perplexity-llama-3.1-sonar-small-128k-online",
/** @deprecated Use `AI.Model["Mistral_Large"]` instead */
"Mistral_Large2" = "mistral-large-2"
}
/** @deprecated Use the `AI.Model` enum instead */
export type __DeprecatedModelUnion = "openai-gpt-3.5-turbo-instruct" | "openai-gpt-3.5-turbo" | "openai-gpt-4" | "openai-gpt-4-turbo" | "anthropic-claude-haiku" | "anthropic-claude-opus" | "anthropic-claude-sonnet" | "perplexity-sonar-medium-online" | "perplexity-sonar-small-online" | "llama2-70b" | "mixtral-8x7b" | "codellama-70b-instruct"
/** @deprecated */
| "gpt-3.5-turbo"
/** @deprecated */
| "gpt-3.5-turbo-instruct"
/** @deprecated */
| "gpt-4"
/** @deprecated */
| "text-davinci-003";
}
export declare namespace Alert {
/**
* The options to create an {@link Alert}.
*
* @example
* ```typescript
* import { confimrAlert, Alert } from "@raycast/api";
*
* export default async () => {
* const options: Alert.Options = {
* title: "Finished cooking",
* message: "Delicious pasta for lunch",
* primaryAction: {
* title: 'Do something',
* onAction: () => {
* // while you can register a handler for an action, it's more elegant
* // to use the `if (await confirmAlert(...)) { ... }` pattern
* console.log("The alert action has been triggered")
* }
* }
* };
* await confirmAlert(options);
* };
* ```
*/
export interface Options {
/**
* The icon of an alert to illustrate the action. Displayed on the top.
*/
icon?: Image.ImageLike;
/**
* The title of an alert. Displayed below the icon.
*/
title: string;
/**
* An additional message for an Alert. Useful to show more information, e.g. a confirmation message for a destructive action.
*/
message?: string;
/**
* The primary Action the user can take.
*/
primaryAction?: ActionOptions;
/**
* The Action to dismiss the alert. There usually shouldn't be any side effects when the user takes this action.
*/
dismissAction?: ActionOptions;
/**
* If set to true, the Alert will also display a `Do not show this message again` checkbox. When checked, the answer
* is persisted and directly returned to the extension the next time the alert should be shown, without the user
* actually seeing the alert.
*
* @remarks
* Once an alert is dismissed, a `Reset Confirmation Dialogs` button will appear in the command's settings pane,
* in case users want to reconsider their answers.
*/
rememberUserChoice?: boolean;
}
/**
* The options to create an {@link Alert} Action.
*/
export interface ActionOptions {
/**
* The title of the action.
*/
title: string;
/**
* The style of the action.
*/
style?: ActionStyle;
/**
* A callback called when the action is triggered.
*/
onAction?: () => void;
}
/**
* Defines the visual style of an Action of the Alert.
*
* @remarks
* Use {@link Alert.ActionStyle.Default} for confirmations of a positive action.
* Use {@link Alert.ActionStyle.Destructive} for confirmations of a destructive action (eg. deleting a file).
*/
export enum ActionStyle {
Default = "default",
Cancel = "cancel",
Destructive = "destructive"
}
}
/**
* @deprecated Use {@link Alert.ActionOptions} instead
*/
export declare interface AlertActionOptions extends Alert.ActionOptions {
}
/**
* @deprecated Use {@link Alert.ActionStyle} instead
*/
export declare const AlertActionStyle: typeof Alert.ActionStyle;
/**
* @deprecated Use {@link Alert.Options} instead
*/
export declare interface AlertOptions extends Alert.Options {
}
/**
* @deprecated Use {@link LocalStorage.allItems} instead
*/
export declare const allLocalStorageItems: typeof LocalStorage.allItems;
/**
* An object that represents a locally installed application on the system.
*
* @remarks
* It can be used to open files or folders in a specific application. Use {@link getApplications} or
* {@link getDefaultApplication} to get applications that can open a specific file or folder.
*/
export declare interface Application {
/**
* The display name of the application.
*/
name: string;
/**
* The localized name of the application.
*/
localizedName?: string;
/**
* The absolute path to the application bundle, e.g. `/Applications/Raycast.app`,
*/
path: string;
/**
* The bundle identifier of the application, e.g. `com.raycast.macos`.
*/
bundleId?: string;
}
/**
* A record type holding the arguments (entered in Raycast Root Search Bar) that have been passed to the command.
*/
declare interface Arguments {
/**
* The representation of arguments given that key here is the `name` defined in manifest file and value is the user's input
*/
[item: string]: any;
}
/** @deprecated Use {@link LaunchProps} directly */
export declare interface ArgumentsLaunchProps {
arguments?: Arguments;
}
export declare namespace BrowserExtension {
/**
* Get the content of an opened tab.
* @param options - Options to control which content to get.
* @returns A Promise that resolves with the content of the tab.
*
* @example
* ```typescript
* import { BrowserExtension } from "@raycast/api";
*
* export default async () => {
* const html = await BrowserExtension.getContent({ format: "html" });
* console.log(html);
* };
* ```
*/
export function getContent(options?: {
/**
* The format of the content.
*
* - `html`: `document.documentElement.outerHTML`
* - `text`: `document.body.innerText`
* - `markdown`: A heuristic to get the "content" of the document and convert it to markdown. Think of it as the "reader mode" of a browser.
*
* @defaultValue `html`
*/
format?: "html" | "text" | "markdown";
/**
* Only returns the content of the element that matches the [CSS selector](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_selectors).
*
* If the selector matches multiple elements, only the first one is returned.
* If the selector doesn't match any element, an empty string is returned.
*
* When using a CSS selector, the `format` option can not be `markdown`.
*/
cssSelector?: string;
/**
* The ID of the tab to get the content from. If not specified, the content of the active tab of the focused window is returned.
*/
tabId?: number;
}): Promise<string>;
export interface Tab {
/**
* The ID of the tab. Tab IDs are unique within a browser session.
*/
id: number;
/**
* The URL the tab is displaying.
*/
url: string;
/**
* The title of the tab. It may also be `undefined` if the tab is loading.
*/
title?: string;
/**
* The URL of the tab's [favicon](https://developer.mozilla.org/en-US/docs/Glossary/Favicon). It may also be `undefined` if the tab is loading.
*/
favicon?: string;
/**
* Whether the tab is active in its window.
* There can only be one active tab per window but if there are multiple browser windows, there can be multiple active tabs.
*/
active: boolean;
}
/**
* Get the list of browser tabs.
* @returns A Promise that resolves with the list of tabs.
*
* @example
* ```typescript
* import { BrowserExtension } from "@raycast/api";
*
* export default async () => {
* const tabs = await BrowserExtension.getTabs();
* console.log(tabs);
* };
* ```
*/
export function getTabs(): Promise<Tab[]>;
}
/**
* Caching abstraction that stores data on disk and supports LRU (least recently used) access.
* Since extensions can only consume up to a max. heap memory size, the cache only maintains a lightweight index in memory
* and stores the actual data in separate files on disk in the extension's support directory.
*
* The Cache class provides CRUD-style methods (get, set, remove) to update and retrieve data synchronously based on a key.
* The data must be a string and it is up to the client to decide which serialization format to use.
* A typical use case would be to use `JSON.stringify` and `JSON.parse`.
*
* @remarks By default, the cache is shared between the entry points of an extension. Use {@link Cache.Options} to configure
* a `namespace` per command if needed (for example, set it to `environment.commandName`).
*
* @example
* ```typescript
* import { Cache } from "@raycast/api";
*
* const cache = new Cache();
* cache.set("items", JSON.stringify([{ id: "1", title: "Item 1" }]));
* console.log(JSON.parse(cache.get("items")));
* ```
*/
export declare class Cache {
static get STORAGE_DIRECTORY_NAME(): string;
static get DEFAULT_CAPACITY(): number;
private directory;
private namespace?;
private capacity;
private journal;
private storage;
private subscribers;
constructor(options?: Cache.Options);
/**
* @returns the full path to the directory where the data is stored on disk.
*/
get storageDirectory(): string;
/**
* @returns the data for the given key. If there is no data for the key, `undefined` is returned.
* @remarks If you want to just check for the existence of a key, use {@link has}.
*/
get(key: string): string | undefined;
/**
* @returns `true` if data for the key exists, `false` otherwise.
* @remarks You can use this method to check for entries without affecting the LRU access.
*/
has(key: string): boolean;
/**
* @returns `true` if the cache is empty, `false` otherwise.
*/
get isEmpty(): boolean;
/**
* Sets the data for the given key.
* If the data exceeds the configured `capacity`, the least recently used entries are removed.
* This also notifies registered subscribers (see {@link subscribe}).
*/
set(key: string, data: string): void;
/**
* Removes the data for the given key.
* This also notifies registered subscribers (see {@link subscribe}).
* @returns `true` if data for the key was removed, `false` otherwise.
*/
remove(key: string): boolean;
/**
* Clears all stored data.
* This also notifies registered subscribers (see {@link subscribe}) unless the `notifySubscribers` option is set to `false`.
*/
clear(options?: {
notifySubscribers: boolean;
}): void;
/**
* Registers a new subscriber that gets notified when cache data is set or removed.
* @returns a function that can be called to remove the subscriber.
*/
subscribe(subscriber: Cache.Subscriber): Cache.Subscription;
private maintainCapacity;
private notifySubscribers;
}
export declare namespace Cache {
/**
* The options for creating a new {@link Cache}.
*/
export interface Options {
/**
* If set, the Cache will be namespaced via a subdirectory.
* This can be useful to separate the caches for individual commands of an extension.
* By default, the cache is shared between the commands of an extension.
*/
namespace?: string;
/**
* The parent directory for the cache data.
* @deprecated this parameter will be removed in the future – use the default directory.
*/
directory?: string;
/**
* The capacity in bytes. If the stored data exceeds the capacity, the least recently used data is removed.
* The default capacity is 10 MB.
*/
capacity?: number;
}
export type Subscriber = (key: string | undefined, data: string | undefined) => void;
export type Subscription = () => void;
}
/**
* Report the provided exception to the Developer Hub.
* This helps in handling failures gracefully while staying informed about the occurrence of the failure.
*
* @param exception - The exception you want to report.
*/
export declare function captureException(exception: unknown): void;
/**
* See {@link Form.Checkbox}
*/
declare const Checkbox: ForwardRefExoticComponent<CheckboxProps & RefAttributes<CheckboxRef>>;
/**
* See {@link Form.Checkbox.Props}
*/
declare interface CheckboxProps extends FormItemProps_2<boolean> {
/**
* The label displayed on the right side of the checkbox.
*/
label: string;
}
/**
* Form.Checkbox Ref type.
*/
declare type CheckboxRef = FormItemRef;
/**
* @deprecated Use {@link Clipboard.clear} instead
*/
export declare const clearClipboard: typeof Clipboard.clear;
/**
* @deprecated Use {@link LocalStorage.clear} instead
*/
export declare const clearLocalStorage: typeof LocalStorage.clear;
/**
* Clear the text in the search bar.
*
* @param options - Can be used to control the behaviour after the search bar is cleared.
* @returns A Promise that resolves when the search bar is cleared.
*/
export declare function clearSearchBar(options?: {
/**
* Can be used to force scrolling to the top. Defaults to scrolling to the top after the
* the search bar was cleared.
*/
forceScrollToTop?: boolean;
}): Promise<void>;
export declare namespace Clipboard {
/**
* Copies content to the clipboard.
*
* @param content - The content to copy to the clipboard.
* @param options - Options for the copy operation.
* @returns A Promise that resolves when the content is copied to the clipboard.
*
* @example
* ```typescript
* import { Clipboard } from "@raycast/api";
*
* export default async () => {
* await Clipboard.copy("https://raycast.com");
*
* const textContent: Clipboard.Content = {
* text: "https://raycast.com",
* }
*
* await Clipboard.copy(textContent);
*
* const fileContent: Clipboard.Content = {
* file: "/path/to/file.pdf",
* }
*
* await Clipboard.copy(fileContent);
*
* await Clipboard.copy("SecretPassword", { concealed: true });
* };
* ```
*/
export function copy(content: string | number | Content, options?: CopyOptions): Promise<void>;
/**
* Clears the current clipboard contents.
*
* @returns A Promise that resolves when the clipboard is cleared.
*
* @example
* ```typescript
* import { Clipboard } from "@raycast/api";
*
* export default async () => {
* await Clipboard.clear();
* };
* ```
*/
export function clear(): Promise<void>;
/**
* Pastes content to the current selection of the frontmost application.
*
* @param content - The content to insert at the cursor.