@raycast/api 1.25.6 → 1.26.3

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/bin/arm64/ray CHANGED
Binary file
package/bin/x86/ray CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raycast/api",
3
- "version": "1.25.6",
3
+ "version": "1.26.3",
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",
@@ -13,4 +13,4 @@
13
13
  "bin": {
14
14
  "ray": "./bin/ray"
15
15
  }
16
- }
16
+ }
package/types/index.d.ts CHANGED
@@ -225,30 +225,6 @@ export function clearClipboard(): Promise<void>;
225
225
  * @category Clipboard
226
226
  */
227
227
  export function pasteText(text: string): Promise<void>;
228
- /**
229
- * Gets the selected text of the frontmost application.
230
- *
231
- * @throws An error when no text is selected in the frontmost application.
232
- * @returns Returns a promise that resolves with the selected text.
233
- *
234
- * @example
235
- * ```typescript
236
- *
237
- *
238
- * export default async () => {
239
- * try {
240
- * const selectedText = await getSelectedText();
241
- * const transformedText = selectedText.toUpperCase();
242
- * await pasteText(transformedText);
243
- * } catch (error) {
244
- * await showToast(ToastStyle.Failure, "Cannot transform text", String(error));
245
- * }
246
- * };
247
- * ```
248
- *
249
- * @category Clipboard
250
- */
251
- export function getSelectedText(): Promise<string>;
252
228
  /**
253
229
  * A keyboard shortcut is defined by one or more modifier keys (command, control, etc.) and a single key equivalent (a character or special key).
254
230
  * See {@link KeyModifier} and {@link KeyEquivalent} for supported values.
@@ -2756,6 +2732,66 @@ export interface PreferenceValues {
2756
2732
  * @category Preferences
2757
2733
  */
2758
2734
  export function getPreferenceValues<Values extends PreferenceValues = PreferenceValues>(): Values;
2735
+ /**
2736
+ * Gets the selected text of the frontmost application.
2737
+ *
2738
+ * @throws An error when no text is selected in the frontmost application.
2739
+ * @returns Returns a promise that resolves with the selected text.
2740
+ *
2741
+ * @example
2742
+ * ```typescript
2743
+ *
2744
+ *
2745
+ * export default async () => {
2746
+ * try {
2747
+ * const selectedText = await getSelectedText();
2748
+ * const transformedText = selectedText.toUpperCase();
2749
+ * await pasteText(transformedText);
2750
+ * } catch (error) {
2751
+ * await showToast(ToastStyle.Failure, "Cannot transform text", String(error));
2752
+ * }
2753
+ * };
2754
+ * ```
2755
+ *
2756
+ * @category Environment
2757
+ */
2758
+ export function getSelectedText(): Promise<string>;
2759
+ /**
2760
+ * Holds data about a File System item. Use the {@link getSelectedFinderItems} method to retrieve values.
2761
+ *
2762
+ * @category Environment
2763
+ */
2764
+ export interface FileSystemItem {
2765
+ /**
2766
+ * The path to the item
2767
+ */
2768
+ path: string;
2769
+ }
2770
+ /**
2771
+ * Gets the selected items from Finder.
2772
+ *
2773
+ * @throws An error when Finder is not the frontmost application.
2774
+ * @returns Returns a promise that resolves with the selected file system items.
2775
+ *
2776
+ * @example
2777
+ * ```typescript
2778
+ *
2779
+ *
2780
+ * export default async () => {
2781
+ * try {
2782
+ * const selectedItems = await getSelectedFinderItems();
2783
+ * if (selectedItems.length) {
2784
+ * await pasteText(selectedItems[0].path);
2785
+ * }
2786
+ * } catch (error) {
2787
+ * await showToast(ToastStyle.Failure, "Cannot copy file path", String(error));
2788
+ * }
2789
+ * };
2790
+ * ```
2791
+ *
2792
+ * @category Environment
2793
+ */
2794
+ export function getSelectedFinderItems(): Promise<FileSystemItem[]>;
2759
2795
 
2760
2796
 
2761
2797
  /**
@@ -2897,6 +2933,149 @@ export function useNavigation(): Navigation;
2897
2933
  * @subcategory Rendering
2898
2934
  */
2899
2935
  export function render(nodeToRender: ReactNode): void;
2936
+
2937
+ /**
2938
+ * Creates and shows a confirmation Alert with the given options.
2939
+ *
2940
+ * @param options - The options used to create the Alert.
2941
+ * @returns A promise that resolves to a boolean when the user takes an action.
2942
+ * It will be `true` for the primary Action, `false` for the dismiss Action.
2943
+ *
2944
+ * @example
2945
+ * ```typescript
2946
+ *
2947
+ *
2948
+ * export default async () => {
2949
+ * if (await confirmAlert({ title: "Are you sure?" })) {
2950
+ * // do something
2951
+ * }
2952
+ * };
2953
+ * ```
2954
+ *
2955
+ * @category User Interface
2956
+ * @subcategory Alert
2957
+ */
2958
+ export function confirmAlert(options: AlertOptions): Promise<boolean>;
2959
+ /**
2960
+ * The options to create an {@link Alert}.
2961
+ *
2962
+ * @example
2963
+ * ```typescript
2964
+ *
2965
+ *
2966
+ * export default async () => {
2967
+ * const options: AlertOptions = {
2968
+ * title: "Finished cooking",
2969
+ * message: "Delicious pasta for lunch",
2970
+ * primaryAction: {
2971
+ * title: 'Do something',
2972
+ * onAction: () => {
2973
+ * console.log("The alert action has been triggered")
2974
+ * }
2975
+ * }
2976
+ * };
2977
+ * const alert = new Alert(options);
2978
+ * await alert.show();
2979
+ * };
2980
+ * ```
2981
+ *
2982
+ * @category User Interface
2983
+ * @subcategory Alert
2984
+ */
2985
+ export interface AlertOptions {
2986
+ /**
2987
+ * The icon of an alert to illustrate the action. Displayed on the top.
2988
+ */
2989
+ icon?: ImageLike;
2990
+ /**
2991
+ * The title of an alert. Displayed below the icon.
2992
+ */
2993
+ title: string;
2994
+ /**
2995
+ * An additional message for an Alert. Useful to show more information, e.g. a confirmation message for a destructive action.
2996
+ */
2997
+ message?: string;
2998
+ /**
2999
+ * The primary Action the user can take.
3000
+ */
3001
+ primaryAction?: AlertActionOptions;
3002
+ /**
3003
+ * The Action to dismiss the alert. There usually shouldn't be any side effects when the user takes this action.
3004
+ */
3005
+ dismissAction?: AlertActionOptions;
3006
+ }
3007
+ /**
3008
+ * The options to create an {@link Alert} Action.
3009
+ *
3010
+ * @category User Interface
3011
+ * @subcategory Alert
3012
+ */
3013
+ export interface AlertActionOptions {
3014
+ /**
3015
+ * The title of the action.
3016
+ */
3017
+ title: string;
3018
+ /**
3019
+ * The style of the action.
3020
+ */
3021
+ style?: AlertActionStyle;
3022
+ /**
3023
+ * A callback called when the action is triggered.
3024
+ */
3025
+ onAction?: () => void;
3026
+ }
3027
+ /**
3028
+ * Defines the visual style of an Action of the Alert.
3029
+ *
3030
+ * @remarks
3031
+ * Use {@link AlertActionStyle.Default} for confirmations of a positive action.
3032
+ * Use {@link AlertActionStyle.Destructive} for confirmations of a destructive action (eg. deleting a file).
3033
+ *
3034
+ * @category User Interface
3035
+ * @subcategory Alert
3036
+ */
3037
+ export enum AlertActionStyle {
3038
+ Default = "DEFAULT",
3039
+ Cancel = "CANCEL",
3040
+ Destructive = "DESTRUCTIVE"
3041
+ }
3042
+ /**
3043
+ * Union type for the supported color types.
3044
+ *
3045
+ * @remark
3046
+ * Besides the {@link Color}, you can use any of the following color formats:
3047
+ * - HEX, e.g `#FF0000`
3048
+ * - Short HEX, e.g. `#F00`
3049
+ * - RGBA, e.g. `rgb(255, 0, 0)`
3050
+ * - RGBA Percentage, e.g. `rgb(255, 0, 0, 1.0)`
3051
+ * - HSL, e.g. `hsla(200, 20%, 33%, 0.2)`
3052
+ * - Keywords, e.g. `red`
3053
+ *
3054
+ * Colors different to the built-in ones (see {@link Color}) will be dynamically adjusted to fit the contrast.
3055
+ *
3056
+ * @example
3057
+ * ```typescript
3058
+ *
3059
+ *
3060
+ * export default function Command() {
3061
+ * return (
3062
+ * <List>
3063
+ * <List.Item title="Built-in color" icon={{ source: Icon.Circle, tintColor: Color.Red }} />
3064
+ * <List.Item title="HEX" icon={{ source: Icon.Circle, tintColor: "#FF0000" }} />
3065
+ * <List.Item title="Short HEX" icon={{ source: Icon.Circle, tintColor: "#F00" }} />
3066
+ * <List.Item title="RGBA" icon={{ source: Icon.Circle, tintColor: "rgb(255, 0, 0)" }} />
3067
+ * <List.Item title="RGBA Percentage" icon={{ source: Icon.Circle, tintColor: "rgb(255, 0, 0, 1.0)" }} />
3068
+ * <List.Item title="HSL" icon={{ source: Icon.Circle, tintColor: "hsla(200, 20%, 33%, 0.2)" }} />
3069
+ * <List.Item title="Keywords" icon={{ source: Icon.Circle, tintColor: "red" }} />
3070
+ * </List>
3071
+ * );
3072
+ * };
3073
+ * ```
3074
+ *
3075
+ * @category User Interface
3076
+ * @subcategory Colors
3077
+ */
3078
+ export type ColorLike = Color | DynamicColor | string;
2900
3079
  /**
2901
3080
  * The standard colors. Use this colors for consistency.
2902
3081
  *
@@ -2960,7 +3139,7 @@ export enum Color {
2960
3139
  * @category User Interface
2961
3140
  * @subcategory Colors
2962
3141
  */
2963
- interface DynamicColor {
3142
+ export interface DynamicColor {
2964
3143
  /**
2965
3144
  * The color which is used in light theme.
2966
3145
  *
@@ -2988,44 +3167,6 @@ interface DynamicColor {
2988
3167
  */
2989
3168
  adjustContrast?: boolean;
2990
3169
  }
2991
- /**
2992
- * Union type for the supported color types.
2993
- *
2994
- * @remark
2995
- * Besides the {@link Color}, you can use any of the following color formats:
2996
- * - HEX, e.g `#FF0000`
2997
- * - Short HEX, e.g. `#F00`
2998
- * - RGBA, e.g. `rgb(255, 0, 0)`
2999
- * - RGBA Percentage, e.g. `rgb(255, 0, 0, 1.0)`
3000
- * - HSL, e.g. `hsla(200, 20%, 33%, 0.2)`
3001
- * - Keywords, e.g. `red`
3002
- *
3003
- * Colors different to the built-in ones (see {@link Color}) will be dynamically adjusted to fit the contrast.
3004
- *
3005
- * @example
3006
- * ```typescript
3007
- *
3008
- *
3009
- * export default function Command() {
3010
- * return (
3011
- * <List>
3012
- * <List.Item title="Built-in color" icon={{ source: Icon.Circle, tintColor: Color.Red }} />
3013
- * <List.Item title="HEX" icon={{ source: Icon.Circle, tintColor: "#FF0000" }} />
3014
- * <List.Item title="Short HEX" icon={{ source: Icon.Circle, tintColor: "#F00" }} />
3015
- * <List.Item title="RGBA" icon={{ source: Icon.Circle, tintColor: "rgb(255, 0, 0)" }} />
3016
- * <List.Item title="RGBA Percentage" icon={{ source: Icon.Circle, tintColor: "rgb(255, 0, 0, 1.0)" }} />
3017
- * <List.Item title="HSL" icon={{ source: Icon.Circle, tintColor: "hsla(200, 20%, 33%, 0.2)" }} />
3018
- * <List.Item title="Keywords" icon={{ source: Icon.Circle, tintColor: "red" }} />
3019
- * </List>
3020
- * );
3021
- * };
3022
- * ```
3023
- *
3024
- * @category User Interface
3025
- * @subcategory Colors
3026
- */
3027
- export type ColorLike = DynamicColor | Color | string;
3028
- export {};
3029
3170
  /**
3030
3171
  * List of built-in icons that can be used for actions or list items.
3031
3172
  *
@@ -3116,7 +3257,7 @@ export enum Icon {
3116
3257
  */
3117
3258
  export interface FileIcon {
3118
3259
  /**
3119
- * The path to a file or folder to get it's icon from.
3260
+ * The path to a file or folder to get its icon from.
3120
3261
  */
3121
3262
  fileIcon: string;
3122
3263
  }
@@ -3252,6 +3393,7 @@ export enum ImageMask {
3252
3393
  */
3253
3394
  RoundedRectangle = "roundedRectangle"
3254
3395
  }
3396
+
3255
3397
  /**
3256
3398
  * A Toast with a certain style, title, and message.
3257
3399
  *
@@ -3279,17 +3421,23 @@ export enum ImageMask {
3279
3421
  */
3280
3422
  export class Toast {
3281
3423
  private options;
3282
- constructor(options: ToastOptions);
3424
+ private id;
3425
+ private callbacks;
3426
+ constructor(props: ToastOptions);
3283
3427
  get style(): ToastStyle;
3284
3428
  set style(style: ToastStyle);
3285
3429
  get title(): string;
3286
3430
  set title(title: string);
3287
3431
  get message(): string | undefined;
3288
3432
  set message(message: string | undefined);
3433
+ get primaryAction(): ToastActionOptions | undefined;
3434
+ set primaryAction(action: ToastActionOptions | undefined);
3435
+ get secondaryAction(): ToastActionOptions | undefined;
3436
+ set secondaryAction(action: ToastActionOptions | undefined);
3289
3437
  /**
3290
3438
  * Shows the Toast.
3291
3439
  *
3292
- * @returns A promise that resolves when toast is shown.
3440
+ * @returns A promise that resolves when the toast is shown.
3293
3441
  */
3294
3442
  show(): Promise<void>;
3295
3443
  /**
@@ -3312,6 +3460,12 @@ export class Toast {
3312
3460
  * style: ToastStyle.Success,
3313
3461
  * title: "Finished cooking",
3314
3462
  * message: "Delicious pasta for lunch",
3463
+ * primaryAction: {
3464
+ * title: 'Do something',
3465
+ * onAction: () => {
3466
+ * console.log("The toast action has been triggered")
3467
+ * }
3468
+ * }
3315
3469
  * };
3316
3470
  * const toast = new Toast(options);
3317
3471
  * await toast.show();
@@ -3331,9 +3485,37 @@ export interface ToastOptions {
3331
3485
  */
3332
3486
  title: string;
3333
3487
  /**
3334
- * An additional message for the toast. Useful to show more information, e.g. an identifier of a newly create asset
3488
+ * An additional message for the toast. Useful to show more information, e.g. an identifier of a newly created asset.
3335
3489
  */
3336
3490
  message?: string;
3491
+ /**
3492
+ * The primary Action the user can take when hovering on the Toast.
3493
+ */
3494
+ primaryAction?: ToastActionOptions;
3495
+ /**
3496
+ * The secondary Action the user can take when hovering on the Toast.
3497
+ */
3498
+ secondaryAction?: ToastActionOptions;
3499
+ }
3500
+ /**
3501
+ * The options to create a {@link Toast} Action.
3502
+ *
3503
+ * @category User Interface
3504
+ * @subcategory Toast
3505
+ */
3506
+ export interface ToastActionOptions {
3507
+ /**
3508
+ * The title of the action.
3509
+ */
3510
+ title: string;
3511
+ /**
3512
+ * The keyboard shortcut for the action.
3513
+ */
3514
+ shortcut?: KeyboardShortcut;
3515
+ /**
3516
+ * A callback called when the action is triggered.
3517
+ */
3518
+ onAction: () => void;
3337
3519
  }
3338
3520
  /**
3339
3521
  * Defines the visual style of the Toast.
@@ -3352,7 +3534,7 @@ export enum ToastStyle {
3352
3534
  Animated = "ANIMATED"
3353
3535
  }
3354
3536
  /**
3355
- * Creates and shows a Toast with the the given style, title, and message.
3537
+ * Creates and shows a Toast with the given style, title, and message.
3356
3538
  *
3357
3539
  * @param style - The visual style of the Toast.
3358
3540
  * @param title - The title that will be displayed in the Toast.