@raycast/api 1.36.1 → 1.37.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/api.d.ts CHANGED
@@ -107,6 +107,12 @@ export declare namespace Action {
107
107
  */
108
108
  export type Props = TrashProps;
109
109
  }
110
+ export namespace ToggleQuickLook {
111
+ /**
112
+ * Props of the {@link Action.ToggleQuickLook} React component.
113
+ */
114
+ export type Props = ToggleQuickLookProps;
115
+ }
110
116
  }
111
117
 
112
118
  /**
@@ -500,6 +506,108 @@ export declare interface Application {
500
506
  bundleId?: string;
501
507
  }
502
508
 
509
+ /**
510
+ * Caching abstraction that stores data on disk and supports LRU (least recently used) access.
511
+ * Since extensions can only consume up to a max. heap memory size, the cache only maintains a lightweight index in memory
512
+ * and stores the actual data in separate files on disk in the extension's support directory.
513
+ *
514
+ * The Cache class provides CRUD-style methods (get, set, remove) to update and retrieve data synchronously based on a key.
515
+ * The data must be a string and it is up to the client to decide which serialization format to use.
516
+ * (A typical use case would be to use JSON.stringify and JSON.parse.)
517
+ *
518
+ * @remarks By default, the cache is shared between the commands of an extension. Use {@link Cache.Options} to configure
519
+ * a `namespace` per command if needed (for example, set it to `environment.commandName`).
520
+ *
521
+ * @example
522
+ * ```typescript
523
+ * import { Cache } from "@raycast/api";
524
+ *
525
+ * const cache = new Cache();
526
+ * cache.set("items", JSON.stringify([{ id: "1", title: "Item 1" }]));
527
+ * console.log(JSON.parse(cache.get("items")));
528
+ * ```
529
+ */
530
+ export declare class Cache {
531
+ static get STORAGE_DIRECTORY_NAME(): string;
532
+ static get DEFAULT_CAPACITY(): number;
533
+ private directory;
534
+ private namespace?;
535
+ private capacity;
536
+ private journal;
537
+ private storage;
538
+ private subscribers;
539
+ constructor(options?: Cache.Options);
540
+ /**
541
+ * @returns the full path to the directory where the data is stored on disk.
542
+ */
543
+ get storageDirectory(): string;
544
+ /**
545
+ * @returns the data for the given key. If there is no data for the key, `undefined` is returned.
546
+ * @remarks If you want to just check for the existence of a key, use {@link has}.
547
+ */
548
+ get(key: string): string | undefined;
549
+ /**
550
+ * @returns `true` if data for the key exists, `false` otherwise.
551
+ * @remarks You can use this method to check for entries without affecting the LRU access.
552
+ */
553
+ has(key: string): boolean;
554
+ /**
555
+ * @returns `true` if the cache is empty, `false` otherwise.
556
+ */
557
+ get isEmpty(): boolean;
558
+ /**
559
+ * Sets the data for the given key.
560
+ * If the data exceeds the configured `capacity`, the least recently used entries are removed.
561
+ * This also notifies registered subscribers (see {@link subscribe}).
562
+ */
563
+ set(key: string, data: string): void;
564
+ /**
565
+ * Removes the data for the given key.
566
+ * This also notifies registered subscribers (see {@link subscribe}).
567
+ * @returns `true` if data for the key was removed, `false` otherwise.
568
+ */
569
+ remove(key: string): boolean;
570
+ /**
571
+ * Clears all stored data.
572
+ * This also notifies registered subscribers (see {@link subscribe}) unless the `notifySubscribers` option is set to `false`.
573
+ */
574
+ clear(options?: {
575
+ notifySubscribers: boolean;
576
+ }): void;
577
+ /**
578
+ * Registers a new subscriber that gets notified when cache data is set or removed.
579
+ * @returns a function that can be used to remove the subscriber.
580
+ */
581
+ subscribe(subscription: Cache.Subscriber): Cache.Subscription;
582
+ private maintainCapacity;
583
+ private notifySubscribers;
584
+ }
585
+
586
+ export declare namespace Cache {
587
+ /**
588
+ * The options for creating a new {@link Cache}.
589
+ */
590
+ export interface Options {
591
+ /**
592
+ * If set, the Cache will be namespaced via a subdirectory.
593
+ * This can be useful to separate the caches for individual commands of an extension.
594
+ * By default, the cache is shared between the commands of an extension.
595
+ */
596
+ namespace?: string;
597
+ /**
598
+ * The parent directory for the cache data.
599
+ */
600
+ directory?: string;
601
+ /**
602
+ * The capacity in bytes. If the stored data exceeds the capacity, the least recently used data is removed.
603
+ * @default 10000000 (10 MB)
604
+ */
605
+ capacity?: number;
606
+ }
607
+ export type Subscriber = (key: string | undefined, data: string | undefined) => void;
608
+ export type Subscription = () => void;
609
+ }
610
+
503
611
  /**
504
612
  * See {@link Form.Checkbox}
505
613
  */
@@ -1055,6 +1163,34 @@ declare interface ConvenienceActions {
1055
1163
  * ```
1056
1164
  */
1057
1165
  CreateQuicklink: typeof CreateQuicklink;
1166
+ /**
1167
+ * Action that toggles the Quick Look to preview a file.
1168
+ *
1169
+ * @example
1170
+ * ```typescript
1171
+ * import { ActionPanel, List, Action } from "@raycast/api";
1172
+ *
1173
+ * export default function Command() {
1174
+ * return (
1175
+ * <List>
1176
+ * <List.Item
1177
+ * title="Preview me"
1178
+ * actions={
1179
+ * <ActionPanel>
1180
+ * <Action.ToggleQuickLook
1181
+ * name="Some file"
1182
+ * path="~/Downloads/Raycast.dmg"
1183
+ * shortcut={{ modifiers: ["cmd"], key: "y" }}
1184
+ * />
1185
+ * </ActionPanel>
1186
+ * }
1187
+ * />
1188
+ * </ List>
1189
+ * );
1190
+ * }
1191
+ * ```
1192
+ */
1193
+ ToggleQuickLook: typeof ToggleQuickLook;
1058
1194
  }
1059
1195
 
1060
1196
  /**
@@ -2007,6 +2143,18 @@ export declare namespace Form {
2007
2143
  export type Value = FormValue_2;
2008
2144
  export type Values = FormValues_2;
2009
2145
  export type Props = FormProps_2;
2146
+ /**
2147
+ * An interface describing event in callbacks {@link Form.Item.Props.onFocus} and {@link Form.Item.Props.onBlur}
2148
+ */
2149
+ export type Event<T extends FormValue_2> = FormEvent<T>;
2150
+ export namespace Event {
2151
+ /**
2152
+ * Types of Form event {@link Form.Event}
2153
+ * * `focus` - the type will be returned for the event of {@link Form.Item.Props.onFocus} callback
2154
+ * * `blur` - the type will be returned for the event of {@link Form.Item.Props.onBlur} callback
2155
+ */
2156
+ export type Type = FormEventType;
2157
+ }
2010
2158
  /**
2011
2159
  * A Ref Type for the {@link Form.TextField}.
2012
2160
  * Use refs to control your Form by calling `Form.TextField.focus()` or `Form.TextField.reset()` functions.
@@ -2637,9 +2785,37 @@ export declare interface FormDropdownSectionProps extends Form.Dropdown.Section.
2637
2785
 
2638
2786
  /**
2639
2787
  * An interface describing Form events in callbacks
2640
- * @beta
2788
+ *
2789
+ * @example
2790
+ * ```typescript
2791
+ *import { Form } from "@raycast/api";
2792
+ *
2793
+ *export default function Main() {
2794
+ * return (
2795
+ * <Form>
2796
+ * <Form.TextField id="textField" title="Text Field" onBlur={logEvent} onFocus={logEvent} />
2797
+ * <Form.TextArea id="textArea" title="Text Area" onBlur={logEvent} onFocus={logEvent} />
2798
+ * <Form.Dropdown id="dropdown" title="Dropdown" onBlur={logEvent} onFocus={logEvent}>
2799
+ * {[1, 2, 3, 4, 5, 6, 7].map((num) => (
2800
+ * <Form.Dropdown.Item value={String(num)} title={String(num)} key={num} />
2801
+ * ))}
2802
+ * </Form.Dropdown>
2803
+ * <Form.TagPicker id="tagPicker" title="Tag Picker" onBlur={logEvent} onFocus={logEvent}>
2804
+ * {[1, 2, 3, 4, 5, 6, 7].map((num) => (
2805
+ * <Form.TagPicker.Item value={String(num)} title={String(num)} key={num} />
2806
+ * ))}
2807
+ * </Form.TagPicker>
2808
+ * </Form>
2809
+ * );
2810
+ *}
2811
+ *
2812
+ *function logEvent(event: Form.Event) {
2813
+ * console.log(`Event '${event.type}' has happened for '${event.target.id}'. Current 'value': '${event.target.value}'`);
2814
+ *}
2815
+ *
2816
+ * ```
2641
2817
  */
2642
- declare interface FormEvent<T extends FormValue_2> {
2818
+ declare type FormEvent<T extends FormValue_2> = {
2643
2819
  /**
2644
2820
  * An interface containing target data related to the event
2645
2821
  */
@@ -2653,7 +2829,18 @@ declare interface FormEvent<T extends FormValue_2> {
2653
2829
  */
2654
2830
  value?: T;
2655
2831
  };
2656
- }
2832
+ /**
2833
+ * A type of event
2834
+ */
2835
+ type: FormEventType;
2836
+ };
2837
+
2838
+ /**
2839
+ * Types of Form event ({@link Form.Event}).
2840
+ * * `focus` will be returned for the event of {@link Form.Item.Props.onFocus} callback
2841
+ * * `blur` will be returned for the event of {@link Form.Item.Props.onBlur} callback
2842
+ */
2843
+ declare type FormEventType = "focus" | "blur";
2657
2844
 
2658
2845
  /**
2659
2846
  * @deprecated Use {@link Form.ItemProps} instead.
@@ -2678,6 +2865,11 @@ declare interface FormItemProps_2<T extends FormValue_2> {
2678
2865
  * An optional info message to describe the form item. It appears on the right side of the item with an info icon. When the icon is hovered, the info message is shown.
2679
2866
  */
2680
2867
  info?: string;
2868
+ /**
2869
+ * An optional error message to show the form item validation issues.
2870
+ * If the `error` is present, the Form Item will be highlighted with red border and will show an error message on the right.
2871
+ */
2872
+ error?: string;
2681
2873
  /**
2682
2874
  * Indicates whether the value of the item should be persisted after submitting, and restored next time the form is rendered.
2683
2875
  */
@@ -2704,11 +2896,13 @@ declare interface FormItemProps_2<T extends FormValue_2> {
2704
2896
  */
2705
2897
  onChange?: (newValue: T) => void;
2706
2898
  /**
2707
- * The callback which will be triggered when the item loses focus.
2708
- * The `event` object contains data with {@link FormItemProps.id} and current {@link FormItemProps.value} for the item.
2709
- * @beta
2899
+ * The callback that will be triggered when the item loses its focus.
2710
2900
  */
2711
2901
  onBlur?: (event: FormEvent<T>) => void;
2902
+ /**
2903
+ * The callback which will be triggered should be called when the item is focused.
2904
+ */
2905
+ onFocus?: (event: FormEvent<T>) => void;
2712
2906
  }
2713
2907
 
2714
2908
  /**
@@ -2786,6 +2980,17 @@ declare interface FormItemRef {
2786
2980
  reset: () => void;
2787
2981
  }
2788
2982
 
2983
+ /**
2984
+ * An interface describing top-level props for Form drafts
2985
+ */
2986
+ export declare interface FormLaunchProps {
2987
+ /**
2988
+ * When a user enters the command via a draft, this object will contain the user inputs that were saved as a draft.
2989
+ * Use its values to populate the initial state for your Form.
2990
+ */
2991
+ draftValues?: Form.Values;
2992
+ }
2993
+
2789
2994
  declare interface FormMembers {
2790
2995
  /**
2791
2996
  * A form item with a checkbox.
@@ -3227,6 +3432,11 @@ export declare interface FormProps extends Form.Props {
3227
3432
  * Props of the {@link Form} React component.
3228
3433
  */
3229
3434
  declare interface FormProps_2 extends ActionsInterface, NavigationChildInterface {
3435
+ /**
3436
+ * Defines whether the Form.Items values will be preserved when user exits the screen.
3437
+ * @defaultValue `false`
3438
+ */
3439
+ enableDrafts?: boolean;
3230
3440
  /**
3231
3441
  * The Form.Item elements of the form.
3232
3442
  */
@@ -3648,7 +3858,7 @@ declare interface GridMembers {
3648
3858
  * export default function Command() {
3649
3859
  * return (
3650
3860
  * <Grid>
3651
- * <Grid.Item icon={Icon.Star} title="Augustiner Helles" subtitle="0,5 Liter" accessories={[{ text: "Germany" }]} />
3861
+ * <Grid.Item icon={Icon.Star} title="Augustiner Helles" subtitle="0,5 Liter" />
3652
3862
  * </Grid>
3653
3863
  * );
3654
3864
  * }
@@ -4053,11 +4263,17 @@ declare const Item: FunctionComponent<ItemProps> & ItemMembers;
4053
4263
  */
4054
4264
  declare const Item_2: FunctionComponent<ItemProps_2>;
4055
4265
 
4056
- declare interface ItemAccessory {
4266
+ declare type ItemAccessory = ({
4057
4267
  /**
4058
4268
  * An optional text that will be used as the label.
4059
4269
  */
4060
4270
  text?: string | undefined | null;
4271
+ } | {
4272
+ /**
4273
+ * An optional Date that will be used as the label. The date is formatted relatively to the current time (for example `new Date()` will be displayed as `"now"`, yesterday's Date will be displayed as "1d", etc.).
4274
+ */
4275
+ date?: Date | undefined | null;
4276
+ }) & {
4061
4277
  /**
4062
4278
  * An optional {@link Image.ImageLike} that will be used as the icon.
4063
4279
  * @remarks
@@ -4068,7 +4284,7 @@ declare interface ItemAccessory {
4068
4284
  * An optional tooltip shown when the accessory is hovered.
4069
4285
  */
4070
4286
  tooltip?: string | undefined | null;
4071
- }
4287
+ };
4072
4288
 
4073
4289
  declare interface ItemMembers {
4074
4290
  /**
@@ -4146,6 +4362,16 @@ declare interface ItemProps extends ActionsInterface {
4146
4362
  * The `List.Item.Detail` to be rendered in the right side area when the parent List is showing details and the item is selected.
4147
4363
  */
4148
4364
  detail?: ReactNode;
4365
+ /**
4366
+ * Optional information to preview files with Quick Look. Toggle the preview ith {@link Action.ToggleQuickLook}.
4367
+ *
4368
+ * @remarks
4369
+ * If no `name` is specified, the file name of the given path is used.
4370
+ */
4371
+ quickLook?: {
4372
+ name?: string | null;
4373
+ path: string;
4374
+ };
4149
4375
  }
4150
4376
 
4151
4377
  declare interface ItemProps_2 extends ActionsInterface {
@@ -4155,31 +4381,42 @@ declare interface ItemProps_2 extends ActionsInterface {
4155
4381
  */
4156
4382
  id?: string;
4157
4383
  /**
4158
- * An image, optionally with a tooltip, representing the content of the grid item.
4384
+ * An image or color, optionally with a tooltip, representing the content of the grid item.
4159
4385
  */
4160
4386
  content: Image.ImageLike | {
4161
- value: Image.ImageLike;
4387
+ color: Color.ColorLike;
4388
+ } | {
4389
+ value: Image.ImageLike | {
4390
+ color: Color.ColorLike;
4391
+ };
4162
4392
  tooltip: string;
4163
4393
  };
4164
4394
  /**
4165
- * The main title displayed for that item, optionally with a tooltip.
4395
+ * An optional title displayed below the content.
4166
4396
  */
4167
- title?: string | {
4168
- value: string;
4169
- tooltip: string;
4170
- };
4397
+ title?: string;
4171
4398
  /**
4172
- * An optional subtitle displayed next to the main title, optionally with a tooltip.
4399
+ * An optional subtitle displayed below the title.
4173
4400
  */
4174
- subtitle?: string | {
4175
- value: string;
4176
- tooltip: string;
4177
- };
4401
+ subtitle?: string;
4178
4402
  /**
4179
4403
  * An optional property used for providing additional indexable strings for search.
4180
4404
  * When filtering the list in Raycast through the search bar, the keywords will be searched in addition to the title.
4181
4405
  */
4182
4406
  keywords?: string[];
4407
+ /**
4408
+ * Optional information to preview files with Quick Look. Toggle the preview ith {@link Action.ToggleQuickLook}.
4409
+ *
4410
+ * @remarks
4411
+ * If no `name` is specified, the file name of the given path is used.
4412
+ */
4413
+ quickLook?: {
4414
+ name?: string | null;
4415
+ path: string;
4416
+ };
4417
+ /**
4418
+ * An {@link ActionPanel} that will be updated for the selected grid item.
4419
+ */
4183
4420
  actions?: ReactNode | null;
4184
4421
  }
4185
4422
 
@@ -4298,6 +4535,11 @@ declare interface LabelProps_2 {
4298
4535
  text?: string;
4299
4536
  }
4300
4537
 
4538
+ /**
4539
+ * The top-level props that a Command receives on launch
4540
+ */
4541
+ export declare type LaunchProps = FormLaunchProps;
4542
+
4301
4543
  /**
4302
4544
  * See {@link Detail.Metadata.Link}
4303
4545
  */
@@ -5964,6 +6206,23 @@ declare interface SubmenuProps {
5964
6206
  * Use {@link ActionPanel.Submenu} as parent when specifying sub-menu's children to make code is more readable.
5965
6207
  */
5966
6208
  children?: ReactNode;
6209
+ /**
6210
+ * Callback that is triggered when the Submenu is opened.
6211
+ *
6212
+ * This callback can be used to fetch its content lazily:
6213
+ * ```js
6214
+ * function LazySubmenu() {
6215
+ * const [content, setContent] = useState(null)
6216
+ *
6217
+ * return (
6218
+ * <ActionPanel.Submenu onOpen={() => fetchSubmenuContent().then(setContent)}>
6219
+ * {content}
6220
+ * </ActionPanel.Submenu>
6221
+ * )
6222
+ * }
6223
+ * ```
6224
+ */
6225
+ onOpen?: () => void;
5967
6226
  }
5968
6227
 
5969
6228
  /**
@@ -6147,6 +6406,12 @@ declare interface TextAreaProps extends FormItemProps_2<string> {
6147
6406
  * Placeholder text shown in the text area.
6148
6407
  */
6149
6408
  placeholder?: string;
6409
+ /**
6410
+ * Whether markdown will be highlighted in the TextArea or not.
6411
+ * When enabled, markdown shortcuts starts to work for the TextArea (pressing `⌘ + B` will add `**bold**` around the selected text, `⌘ + I` will make the selected text italic, etc.)
6412
+ * @defaultValue `false`
6413
+ */
6414
+ enableMarkdown?: boolean;
6150
6415
  }
6151
6416
 
6152
6417
  /**
@@ -6332,6 +6597,34 @@ export declare interface ToastOptions extends Toast.Options {
6332
6597
  */
6333
6598
  export declare const ToastStyle: typeof Toast.Style;
6334
6599
 
6600
+ /**
6601
+ * See {@link Action.ToggleQuickLook}
6602
+ */
6603
+ declare const ToggleQuickLook: FunctionComponent<ToggleQuickLookProps>;
6604
+
6605
+ /**
6606
+ * See {@link Action.Open.Props}
6607
+ */
6608
+ declare interface ToggleQuickLookProps {
6609
+ /**
6610
+ * The title for the action.
6611
+ * @defaultValue `"Quick Look"`
6612
+ */
6613
+ title?: string;
6614
+ /**
6615
+ * The icon displayed for the action.
6616
+ * @defaultValue {@link Icon.Eye}
6617
+ */
6618
+ icon?: Image.ImageLike;
6619
+ /**
6620
+ * The keyboard shortcut for the action.
6621
+ *
6622
+ * @remarks
6623
+ * The recommended system-wide keyboard shortcut is "⌘ + Y".
6624
+ */
6625
+ shortcut?: Keyboard.Shortcut;
6626
+ }
6627
+
6335
6628
  /**
6336
6629
  * See {@link Action.Trash}
6337
6630
  */
package/bin/arm64/ray CHANGED
Binary file
package/bin/x86/ray CHANGED
Binary file
package/package.json CHANGED
@@ -1,14 +1,16 @@
1
1
  {
2
2
  "name": "@raycast/api",
3
- "version": "1.36.1",
3
+ "version": "1.37.0",
4
4
  "description": "Build extensions for Raycast with React and Node.js.",
5
5
  "author": "Raycast Technologies Ltd.",
6
6
  "homepage": "https://developers.raycast.com",
7
7
  "license": "MIT",
8
8
  "types": "types/index.d.ts",
9
- "peerDependencies": {
10
- "react": "17.0.2",
11
- "react-reconciler": "0.26.2"
9
+ "dependencies": {
10
+ "@types/node": "16.10.3",
11
+ "@types/react": "18.0.9",
12
+ "react": "18.1.0",
13
+ "react-reconciler": "0.28.0"
12
14
  },
13
15
  "bin": {
14
16
  "ray": "./bin/ray"
package/types/index.d.ts CHANGED
@@ -107,6 +107,12 @@ export declare namespace Action {
107
107
  */
108
108
  export type Props = TrashProps;
109
109
  }
110
+ export namespace ToggleQuickLook {
111
+ /**
112
+ * Props of the {@link Action.ToggleQuickLook} React component.
113
+ */
114
+ export type Props = ToggleQuickLookProps;
115
+ }
110
116
  }
111
117
 
112
118
  /**
@@ -500,6 +506,108 @@ export declare interface Application {
500
506
  bundleId?: string;
501
507
  }
502
508
 
509
+ /**
510
+ * Caching abstraction that stores data on disk and supports LRU (least recently used) access.
511
+ * Since extensions can only consume up to a max. heap memory size, the cache only maintains a lightweight index in memory
512
+ * and stores the actual data in separate files on disk in the extension's support directory.
513
+ *
514
+ * The Cache class provides CRUD-style methods (get, set, remove) to update and retrieve data synchronously based on a key.
515
+ * The data must be a string and it is up to the client to decide which serialization format to use.
516
+ * (A typical use case would be to use JSON.stringify and JSON.parse.)
517
+ *
518
+ * @remarks By default, the cache is shared between the commands of an extension. Use {@link Cache.Options} to configure
519
+ * a `namespace` per command if needed (for example, set it to `environment.commandName`).
520
+ *
521
+ * @example
522
+ * ```typescript
523
+ * import { Cache } from "@raycast/api";
524
+ *
525
+ * const cache = new Cache();
526
+ * cache.set("items", JSON.stringify([{ id: "1", title: "Item 1" }]));
527
+ * console.log(JSON.parse(cache.get("items")));
528
+ * ```
529
+ */
530
+ export declare class Cache {
531
+ static get STORAGE_DIRECTORY_NAME(): string;
532
+ static get DEFAULT_CAPACITY(): number;
533
+ private directory;
534
+ private namespace?;
535
+ private capacity;
536
+ private journal;
537
+ private storage;
538
+ private subscribers;
539
+ constructor(options?: Cache.Options);
540
+ /**
541
+ * @returns the full path to the directory where the data is stored on disk.
542
+ */
543
+ get storageDirectory(): string;
544
+ /**
545
+ * @returns the data for the given key. If there is no data for the key, `undefined` is returned.
546
+ * @remarks If you want to just check for the existence of a key, use {@link has}.
547
+ */
548
+ get(key: string): string | undefined;
549
+ /**
550
+ * @returns `true` if data for the key exists, `false` otherwise.
551
+ * @remarks You can use this method to check for entries without affecting the LRU access.
552
+ */
553
+ has(key: string): boolean;
554
+ /**
555
+ * @returns `true` if the cache is empty, `false` otherwise.
556
+ */
557
+ get isEmpty(): boolean;
558
+ /**
559
+ * Sets the data for the given key.
560
+ * If the data exceeds the configured `capacity`, the least recently used entries are removed.
561
+ * This also notifies registered subscribers (see {@link subscribe}).
562
+ */
563
+ set(key: string, data: string): void;
564
+ /**
565
+ * Removes the data for the given key.
566
+ * This also notifies registered subscribers (see {@link subscribe}).
567
+ * @returns `true` if data for the key was removed, `false` otherwise.
568
+ */
569
+ remove(key: string): boolean;
570
+ /**
571
+ * Clears all stored data.
572
+ * This also notifies registered subscribers (see {@link subscribe}) unless the `notifySubscribers` option is set to `false`.
573
+ */
574
+ clear(options?: {
575
+ notifySubscribers: boolean;
576
+ }): void;
577
+ /**
578
+ * Registers a new subscriber that gets notified when cache data is set or removed.
579
+ * @returns a function that can be used to remove the subscriber.
580
+ */
581
+ subscribe(subscription: Cache.Subscriber): Cache.Subscription;
582
+ private maintainCapacity;
583
+ private notifySubscribers;
584
+ }
585
+
586
+ export declare namespace Cache {
587
+ /**
588
+ * The options for creating a new {@link Cache}.
589
+ */
590
+ export interface Options {
591
+ /**
592
+ * If set, the Cache will be namespaced via a subdirectory.
593
+ * This can be useful to separate the caches for individual commands of an extension.
594
+ * By default, the cache is shared between the commands of an extension.
595
+ */
596
+ namespace?: string;
597
+ /**
598
+ * The parent directory for the cache data.
599
+ */
600
+ directory?: string;
601
+ /**
602
+ * The capacity in bytes. If the stored data exceeds the capacity, the least recently used data is removed.
603
+ * @default 10000000 (10 MB)
604
+ */
605
+ capacity?: number;
606
+ }
607
+ export type Subscriber = (key: string | undefined, data: string | undefined) => void;
608
+ export type Subscription = () => void;
609
+ }
610
+
503
611
  /**
504
612
  * See {@link Form.Checkbox}
505
613
  */
@@ -1055,6 +1163,34 @@ declare interface ConvenienceActions {
1055
1163
  * ```
1056
1164
  */
1057
1165
  CreateQuicklink: typeof CreateQuicklink;
1166
+ /**
1167
+ * Action that toggles the Quick Look to preview a file.
1168
+ *
1169
+ * @example
1170
+ * ```typescript
1171
+ * import { ActionPanel, List, Action } from "@raycast/api";
1172
+ *
1173
+ * export default function Command() {
1174
+ * return (
1175
+ * <List>
1176
+ * <List.Item
1177
+ * title="Preview me"
1178
+ * actions={
1179
+ * <ActionPanel>
1180
+ * <Action.ToggleQuickLook
1181
+ * name="Some file"
1182
+ * path="~/Downloads/Raycast.dmg"
1183
+ * shortcut={{ modifiers: ["cmd"], key: "y" }}
1184
+ * />
1185
+ * </ActionPanel>
1186
+ * }
1187
+ * />
1188
+ * </ List>
1189
+ * );
1190
+ * }
1191
+ * ```
1192
+ */
1193
+ ToggleQuickLook: typeof ToggleQuickLook;
1058
1194
  }
1059
1195
 
1060
1196
  /**
@@ -2007,6 +2143,18 @@ export declare namespace Form {
2007
2143
  export type Value = FormValue_2;
2008
2144
  export type Values = FormValues_2;
2009
2145
  export type Props = FormProps_2;
2146
+ /**
2147
+ * An interface describing event in callbacks {@link Form.Item.Props.onFocus} and {@link Form.Item.Props.onBlur}
2148
+ */
2149
+ export type Event<T extends FormValue_2> = FormEvent<T>;
2150
+ export namespace Event {
2151
+ /**
2152
+ * Types of Form event {@link Form.Event}
2153
+ * * `focus` - the type will be returned for the event of {@link Form.Item.Props.onFocus} callback
2154
+ * * `blur` - the type will be returned for the event of {@link Form.Item.Props.onBlur} callback
2155
+ */
2156
+ export type Type = FormEventType;
2157
+ }
2010
2158
  /**
2011
2159
  * A Ref Type for the {@link Form.TextField}.
2012
2160
  * Use refs to control your Form by calling `Form.TextField.focus()` or `Form.TextField.reset()` functions.
@@ -2635,6 +2783,65 @@ export declare const FormDropdownSection: typeof Form.Dropdown.Section;
2635
2783
  export declare interface FormDropdownSectionProps extends Form.Dropdown.Section.Props {
2636
2784
  }
2637
2785
 
2786
+ /**
2787
+ * An interface describing Form events in callbacks
2788
+ *
2789
+ * @example
2790
+ * ```typescript
2791
+ *import { Form } from "@raycast/api";
2792
+ *
2793
+ *export default function Main() {
2794
+ * return (
2795
+ * <Form>
2796
+ * <Form.TextField id="textField" title="Text Field" onBlur={logEvent} onFocus={logEvent} />
2797
+ * <Form.TextArea id="textArea" title="Text Area" onBlur={logEvent} onFocus={logEvent} />
2798
+ * <Form.Dropdown id="dropdown" title="Dropdown" onBlur={logEvent} onFocus={logEvent}>
2799
+ * {[1, 2, 3, 4, 5, 6, 7].map((num) => (
2800
+ * <Form.Dropdown.Item value={String(num)} title={String(num)} key={num} />
2801
+ * ))}
2802
+ * </Form.Dropdown>
2803
+ * <Form.TagPicker id="tagPicker" title="Tag Picker" onBlur={logEvent} onFocus={logEvent}>
2804
+ * {[1, 2, 3, 4, 5, 6, 7].map((num) => (
2805
+ * <Form.TagPicker.Item value={String(num)} title={String(num)} key={num} />
2806
+ * ))}
2807
+ * </Form.TagPicker>
2808
+ * </Form>
2809
+ * );
2810
+ *}
2811
+ *
2812
+ *function logEvent(event: Form.Event) {
2813
+ * console.log(`Event '${event.type}' has happened for '${event.target.id}'. Current 'value': '${event.target.value}'`);
2814
+ *}
2815
+ *
2816
+ * ```
2817
+ */
2818
+ declare type FormEvent<T extends FormValue_2> = {
2819
+ /**
2820
+ * An interface containing target data related to the event
2821
+ */
2822
+ target: {
2823
+ /**
2824
+ * The {@link FormItemProps.id} of Form item where the event has happened
2825
+ */
2826
+ id: string;
2827
+ /**
2828
+ * The current {@link FormItemProps.value} of Form item where the event has happened
2829
+ */
2830
+ value?: T;
2831
+ };
2832
+ /**
2833
+ * A type of event
2834
+ */
2835
+ type: FormEventType;
2836
+ };
2837
+
2838
+ /**
2839
+ * Types of Form event ({@link Form.Event}).
2840
+ * * `focus` will be returned for the event of {@link Form.Item.Props.onFocus} callback
2841
+ * * `blur` will be returned for the event of {@link Form.Item.Props.onBlur} callback
2842
+ */
2843
+ declare type FormEventType = "focus" | "blur";
2844
+
2638
2845
  /**
2639
2846
  * @deprecated Use {@link Form.ItemProps} instead.
2640
2847
  */
@@ -2658,6 +2865,11 @@ declare interface FormItemProps_2<T extends FormValue_2> {
2658
2865
  * An optional info message to describe the form item. It appears on the right side of the item with an info icon. When the icon is hovered, the info message is shown.
2659
2866
  */
2660
2867
  info?: string;
2868
+ /**
2869
+ * An optional error message to show the form item validation issues.
2870
+ * If the `error` is present, the Form Item will be highlighted with red border and will show an error message on the right.
2871
+ */
2872
+ error?: string;
2661
2873
  /**
2662
2874
  * Indicates whether the value of the item should be persisted after submitting, and restored next time the form is rendered.
2663
2875
  */
@@ -2683,7 +2895,14 @@ declare interface FormItemProps_2<T extends FormValue_2> {
2683
2895
  * The callback which will be triggered when the `value` of the item changes.
2684
2896
  */
2685
2897
  onChange?: (newValue: T) => void;
2686
-
2898
+ /**
2899
+ * The callback that will be triggered when the item loses its focus.
2900
+ */
2901
+ onBlur?: (event: FormEvent<T>) => void;
2902
+ /**
2903
+ * The callback which will be triggered should be called when the item is focused.
2904
+ */
2905
+ onFocus?: (event: FormEvent<T>) => void;
2687
2906
  }
2688
2907
 
2689
2908
  /**
@@ -2761,6 +2980,17 @@ declare interface FormItemRef {
2761
2980
  reset: () => void;
2762
2981
  }
2763
2982
 
2983
+ /**
2984
+ * An interface describing top-level props for Form drafts
2985
+ */
2986
+ export declare interface FormLaunchProps {
2987
+ /**
2988
+ * When a user enters the command via a draft, this object will contain the user inputs that were saved as a draft.
2989
+ * Use its values to populate the initial state for your Form.
2990
+ */
2991
+ draftValues?: Form.Values;
2992
+ }
2993
+
2764
2994
  declare interface FormMembers {
2765
2995
  /**
2766
2996
  * A form item with a checkbox.
@@ -3202,6 +3432,11 @@ export declare interface FormProps extends Form.Props {
3202
3432
  * Props of the {@link Form} React component.
3203
3433
  */
3204
3434
  declare interface FormProps_2 extends ActionsInterface, NavigationChildInterface {
3435
+ /**
3436
+ * Defines whether the Form.Items values will be preserved when user exits the screen.
3437
+ * @defaultValue `false`
3438
+ */
3439
+ enableDrafts?: boolean;
3205
3440
  /**
3206
3441
  * The Form.Item elements of the form.
3207
3442
  */
@@ -3623,7 +3858,7 @@ declare interface GridMembers {
3623
3858
  * export default function Command() {
3624
3859
  * return (
3625
3860
  * <Grid>
3626
- * <Grid.Item icon={Icon.Star} title="Augustiner Helles" subtitle="0,5 Liter" accessories={[{ text: "Germany" }]} />
3861
+ * <Grid.Item icon={Icon.Star} title="Augustiner Helles" subtitle="0,5 Liter" />
3627
3862
  * </Grid>
3628
3863
  * );
3629
3864
  * }
@@ -4028,11 +4263,17 @@ declare const Item: FunctionComponent<ItemProps> & ItemMembers;
4028
4263
  */
4029
4264
  declare const Item_2: FunctionComponent<ItemProps_2>;
4030
4265
 
4031
- declare interface ItemAccessory {
4266
+ declare type ItemAccessory = ({
4032
4267
  /**
4033
4268
  * An optional text that will be used as the label.
4034
4269
  */
4035
4270
  text?: string | undefined | null;
4271
+ } | {
4272
+ /**
4273
+ * An optional Date that will be used as the label. The date is formatted relatively to the current time (for example `new Date()` will be displayed as `"now"`, yesterday's Date will be displayed as "1d", etc.).
4274
+ */
4275
+ date?: Date | undefined | null;
4276
+ }) & {
4036
4277
  /**
4037
4278
  * An optional {@link Image.ImageLike} that will be used as the icon.
4038
4279
  * @remarks
@@ -4043,7 +4284,7 @@ declare interface ItemAccessory {
4043
4284
  * An optional tooltip shown when the accessory is hovered.
4044
4285
  */
4045
4286
  tooltip?: string | undefined | null;
4046
- }
4287
+ };
4047
4288
 
4048
4289
  declare interface ItemMembers {
4049
4290
  /**
@@ -4121,6 +4362,16 @@ declare interface ItemProps extends ActionsInterface {
4121
4362
  * The `List.Item.Detail` to be rendered in the right side area when the parent List is showing details and the item is selected.
4122
4363
  */
4123
4364
  detail?: ReactNode;
4365
+ /**
4366
+ * Optional information to preview files with Quick Look. Toggle the preview ith {@link Action.ToggleQuickLook}.
4367
+ *
4368
+ * @remarks
4369
+ * If no `name` is specified, the file name of the given path is used.
4370
+ */
4371
+ quickLook?: {
4372
+ name?: string | null;
4373
+ path: string;
4374
+ };
4124
4375
  }
4125
4376
 
4126
4377
  declare interface ItemProps_2 extends ActionsInterface {
@@ -4130,31 +4381,42 @@ declare interface ItemProps_2 extends ActionsInterface {
4130
4381
  */
4131
4382
  id?: string;
4132
4383
  /**
4133
- * An image, optionally with a tooltip, representing the content of the grid item.
4384
+ * An image or color, optionally with a tooltip, representing the content of the grid item.
4134
4385
  */
4135
4386
  content: Image.ImageLike | {
4136
- value: Image.ImageLike;
4387
+ color: Color.ColorLike;
4388
+ } | {
4389
+ value: Image.ImageLike | {
4390
+ color: Color.ColorLike;
4391
+ };
4137
4392
  tooltip: string;
4138
4393
  };
4139
4394
  /**
4140
- * The main title displayed for that item, optionally with a tooltip.
4395
+ * An optional title displayed below the content.
4141
4396
  */
4142
- title?: string | {
4143
- value: string;
4144
- tooltip: string;
4145
- };
4397
+ title?: string;
4146
4398
  /**
4147
- * An optional subtitle displayed next to the main title, optionally with a tooltip.
4399
+ * An optional subtitle displayed below the title.
4148
4400
  */
4149
- subtitle?: string | {
4150
- value: string;
4151
- tooltip: string;
4152
- };
4401
+ subtitle?: string;
4153
4402
  /**
4154
4403
  * An optional property used for providing additional indexable strings for search.
4155
4404
  * When filtering the list in Raycast through the search bar, the keywords will be searched in addition to the title.
4156
4405
  */
4157
4406
  keywords?: string[];
4407
+ /**
4408
+ * Optional information to preview files with Quick Look. Toggle the preview ith {@link Action.ToggleQuickLook}.
4409
+ *
4410
+ * @remarks
4411
+ * If no `name` is specified, the file name of the given path is used.
4412
+ */
4413
+ quickLook?: {
4414
+ name?: string | null;
4415
+ path: string;
4416
+ };
4417
+ /**
4418
+ * An {@link ActionPanel} that will be updated for the selected grid item.
4419
+ */
4158
4420
  actions?: ReactNode | null;
4159
4421
  }
4160
4422
 
@@ -4273,6 +4535,11 @@ declare interface LabelProps_2 {
4273
4535
  text?: string;
4274
4536
  }
4275
4537
 
4538
+ /**
4539
+ * The top-level props that a Command receives on launch
4540
+ */
4541
+ export declare type LaunchProps = FormLaunchProps;
4542
+
4276
4543
  /**
4277
4544
  * See {@link Detail.Metadata.Link}
4278
4545
  */
@@ -5939,6 +6206,23 @@ declare interface SubmenuProps {
5939
6206
  * Use {@link ActionPanel.Submenu} as parent when specifying sub-menu's children to make code is more readable.
5940
6207
  */
5941
6208
  children?: ReactNode;
6209
+ /**
6210
+ * Callback that is triggered when the Submenu is opened.
6211
+ *
6212
+ * This callback can be used to fetch its content lazily:
6213
+ * ```js
6214
+ * function LazySubmenu() {
6215
+ * const [content, setContent] = useState(null)
6216
+ *
6217
+ * return (
6218
+ * <ActionPanel.Submenu onOpen={() => fetchSubmenuContent().then(setContent)}>
6219
+ * {content}
6220
+ * </ActionPanel.Submenu>
6221
+ * )
6222
+ * }
6223
+ * ```
6224
+ */
6225
+ onOpen?: () => void;
5942
6226
  }
5943
6227
 
5944
6228
  /**
@@ -6122,6 +6406,12 @@ declare interface TextAreaProps extends FormItemProps_2<string> {
6122
6406
  * Placeholder text shown in the text area.
6123
6407
  */
6124
6408
  placeholder?: string;
6409
+ /**
6410
+ * Whether markdown will be highlighted in the TextArea or not.
6411
+ * When enabled, markdown shortcuts starts to work for the TextArea (pressing `⌘ + B` will add `**bold**` around the selected text, `⌘ + I` will make the selected text italic, etc.)
6412
+ * @defaultValue `false`
6413
+ */
6414
+ enableMarkdown?: boolean;
6125
6415
  }
6126
6416
 
6127
6417
  /**
@@ -6307,6 +6597,34 @@ export declare interface ToastOptions extends Toast.Options {
6307
6597
  */
6308
6598
  export declare const ToastStyle: typeof Toast.Style;
6309
6599
 
6600
+ /**
6601
+ * See {@link Action.ToggleQuickLook}
6602
+ */
6603
+ declare const ToggleQuickLook: FunctionComponent<ToggleQuickLookProps>;
6604
+
6605
+ /**
6606
+ * See {@link Action.Open.Props}
6607
+ */
6608
+ declare interface ToggleQuickLookProps {
6609
+ /**
6610
+ * The title for the action.
6611
+ * @defaultValue `"Quick Look"`
6612
+ */
6613
+ title?: string;
6614
+ /**
6615
+ * The icon displayed for the action.
6616
+ * @defaultValue {@link Icon.Eye}
6617
+ */
6618
+ icon?: Image.ImageLike;
6619
+ /**
6620
+ * The keyboard shortcut for the action.
6621
+ *
6622
+ * @remarks
6623
+ * The recommended system-wide keyboard shortcut is "⌘ + Y".
6624
+ */
6625
+ shortcut?: Keyboard.Shortcut;
6626
+ }
6627
+
6310
6628
  /**
6311
6629
  * See {@link Action.Trash}
6312
6630
  */