@raycast/api 1.27.1 → 1.29.1

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.
Files changed (91) hide show
  1. package/bin/arm64/ray +0 -0
  2. package/bin/x86/ray +0 -0
  3. package/package.json +2 -2
  4. package/types/api/app/app.d.ts +171 -0
  5. package/types/api/app/clipboard.d.ts +47 -0
  6. package/types/api/app/index.d.ts +4 -0
  7. package/types/api/app/keyboard.d.ts +56 -0
  8. package/types/api/app/localStorage.d.ts +117 -0
  9. package/types/api/components/ActionPanel.d.ts +297 -0
  10. package/types/api/components/Detail.d.ts +40 -0
  11. package/types/api/components/Form.d.ts +992 -0
  12. package/types/api/components/List.d.ts +275 -0
  13. package/types/api/components/actions/Action.d.ts +454 -0
  14. package/types/api/components/actions/CopyToClipboardAction.d.ts +40 -0
  15. package/types/api/components/actions/CreateQuicklinkAction.d.ts +42 -0
  16. package/types/api/components/actions/CreateSnippetAction.d.ts +40 -0
  17. package/types/api/components/actions/OpenAction.d.ts +47 -0
  18. package/types/api/components/actions/OpenInBrowserAction.d.ts +43 -0
  19. package/types/api/components/actions/OpenWithAction.d.ts +40 -0
  20. package/types/api/components/actions/PasteAction.d.ts +40 -0
  21. package/types/api/components/actions/PushAction.d.ts +38 -0
  22. package/types/api/components/actions/ShowInFinderAction.d.ts +42 -0
  23. package/types/api/components/actions/SubmitFormAction.d.ts +35 -0
  24. package/types/api/components/actions/TrashAction.d.ts +43 -0
  25. package/types/api/components/actions/index.d.ts +1 -0
  26. package/types/api/components/index.d.ts +5 -0
  27. package/types/api/components/propTypes.d.ts +1 -0
  28. package/types/api/components/types.d.ts +30 -0
  29. package/types/api/deprecated.d.ts +410 -0
  30. package/types/api/environment/environment.d.ts +48 -0
  31. package/types/api/environment/index.d.ts +3 -0
  32. package/types/api/environment/preferences.d.ts +31 -0
  33. package/types/api/environment/workspace.d.ts +62 -0
  34. package/types/api/hooks/index.d.ts +1 -0
  35. package/types/api/hooks/useNavigation.d.ts +66 -0
  36. package/types/api/index.d.ts +6 -0
  37. package/types/api/internal/comm/index.d.ts +1 -0
  38. package/types/api/internal/components/ErrorBoundary.d.ts +1 -0
  39. package/types/api/internal/components/Navigation.d.ts +1 -0
  40. package/types/api/internal/components/Root.d.ts +1 -0
  41. package/types/api/internal/components/index.d.ts +4 -0
  42. package/types/api/internal/components/portal/components/portal/Portal.d.ts +4 -0
  43. package/types/api/internal/components/portal/components/portal/index.d.ts +1 -0
  44. package/types/api/internal/components/portal/components/portalHost/PortalHost.d.ts +4 -0
  45. package/types/api/internal/components/portal/components/portalHost/index.d.ts +1 -0
  46. package/types/api/internal/components/portal/components/portalProvider/PortalProvider.d.ts +4 -0
  47. package/types/api/internal/components/portal/components/portalProvider/index.d.ts +1 -0
  48. package/types/api/internal/components/portal/contexts/index.d.ts +1 -0
  49. package/types/api/internal/components/portal/contexts/portal.d.ts +5 -0
  50. package/types/api/internal/components/portal/hooks/index.d.ts +2 -0
  51. package/types/api/internal/components/portal/hooks/usePortal.d.ts +8 -0
  52. package/types/api/internal/components/portal/hooks/usePortalState.d.ts +1 -0
  53. package/types/api/internal/components/portal/index.d.ts +5 -0
  54. package/types/api/internal/components/portal/state/constants.d.ts +9 -0
  55. package/types/api/internal/components/portal/state/index.d.ts +3 -0
  56. package/types/api/internal/components/portal/state/reducer.d.ts +3 -0
  57. package/types/api/internal/components/portal/utilities/logger.d.ts +9 -0
  58. package/types/api/internal/devtools/index.d.ts +1 -0
  59. package/types/api/internal/devtools/react.d.ts +1 -0
  60. package/types/api/internal/hooks/index.d.ts +2 -0
  61. package/types/api/internal/hooks/useActionPanel.d.ts +1 -0
  62. package/types/api/internal/hooks/useId.d.ts +1 -0
  63. package/types/api/internal/index.d.ts +6 -0
  64. package/types/api/internal/rendering/callbacks.d.ts +1 -0
  65. package/types/api/internal/rendering/index.d.ts +6 -0
  66. package/types/api/internal/rendering/logger.d.ts +1 -0
  67. package/types/api/internal/rendering/node-builders/actions.d.ts +3 -0
  68. package/types/api/internal/rendering/node-builders/detail.d.ts +1 -0
  69. package/types/api/internal/rendering/node-builders/forms.d.ts +1 -0
  70. package/types/api/internal/rendering/node-builders/keyboard.d.ts +1 -0
  71. package/types/api/internal/rendering/node-builders/list.d.ts +2 -0
  72. package/types/api/internal/rendering/node-builders/navigationStack.d.ts +1 -0
  73. package/types/api/internal/rendering/node-builders/root.d.ts +1 -0
  74. package/types/api/internal/rendering/node-builders/types.d.ts +1 -0
  75. package/types/api/internal/rendering/node-builders/utils.d.ts +1 -0
  76. package/types/api/internal/rendering/reconciler.d.ts +1 -0
  77. package/types/api/internal/rendering/renderer.d.ts +1 -0
  78. package/types/api/internal/utils/ids.d.ts +1 -0
  79. package/types/api/internal/utils/index.d.ts +1 -0
  80. package/types/api/ui/color.d.ts +115 -0
  81. package/types/api/ui/errors.d.ts +1 -0
  82. package/types/api/ui/feedback/alert.d.ts +97 -0
  83. package/types/api/ui/feedback/hud.d.ts +16 -0
  84. package/types/api/ui/feedback/index.d.ts +3 -0
  85. package/types/api/ui/feedback/toast.d.ts +174 -0
  86. package/types/api/ui/icon.d.ts +88 -0
  87. package/types/api/ui/image.d.ts +162 -0
  88. package/types/api/ui/index.d.ts +5 -0
  89. package/types/core/message-types.d.ts +17 -0
  90. package/types/core/preferences.d.ts +69 -0
  91. package/types/index.d.ts +2777 -2536
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Holds data about the environment the command is running in. Use the global {@link environment} object to retrieve values.
3
+ */
4
+ export interface Environment {
5
+ /**
6
+ * The version of the main Raycast app
7
+ */
8
+ raycastVersion: string;
9
+ /**
10
+ * The name of the extension, as specified in package.json
11
+ */
12
+ extensionName: string;
13
+ /**
14
+ * The name of the launched command, as specified in package.json
15
+ */
16
+ commandName: string;
17
+ /**
18
+ * The absolute path to the assets directory of the extension.
19
+ *
20
+ * @remarks
21
+ * This directory is used internally to load icons, images, and other bundled assets.
22
+ */
23
+ assetsPath: string;
24
+ /**
25
+ * The absolute path for the support directory of an extension. Use it to read and write files related to your extension or command.
26
+ */
27
+ supportPath: string;
28
+ /**
29
+ * Indicates whether the command is a development command (vs. an installed command from the Store).
30
+ */
31
+ isDevelopment: boolean;
32
+ }
33
+ /**
34
+ * Contains environment values such as the Raycast version, extension info, and paths.
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * import { environment } from "@raycast/api";
39
+ *
40
+ * console.log(`Raycast version: ${environment.raycastVersion}`);
41
+ * console.log(`Extension name: ${environment.extensionName}`);
42
+ * console.log(`Command name: ${environment.commandName}`);
43
+ * console.log(`Assets path: ${environment.assetsPath}`);
44
+ * console.log(`Support path: ${environment.supportPath}`);
45
+ * console.log(`Is development mode: ${environment.isDevelopment}`);
46
+ * ```
47
+ */
48
+ export declare const environment: Environment;
@@ -0,0 +1,3 @@
1
+ export * from "./environment";
2
+ export * from "./preferences";
3
+ export * from "./workspace";
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Values of preference items.
3
+ */
4
+ export interface PreferenceValues {
5
+ [name: string]: any;
6
+ }
7
+ /**
8
+ * A function to access the preference values that have been passed to the command.
9
+ *
10
+ * @returns An object with the preference names as property key and the typed value as property value.
11
+ *
12
+ * @remarks
13
+ * Each preference name is mapped to its value and the defined default values are used as fallback values.
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * import { getPreferenceValues } from "@raycast/api";
18
+ *
19
+ * interface Preferences {
20
+ * name: string;
21
+ * bodyWeight?: string;
22
+ * bodyHeight?: string;
23
+ * }
24
+ *
25
+ * export default async () => {
26
+ * const preferences = getPreferenceValues<Preferences>();
27
+ * console.log(preferences);
28
+ * };
29
+ * ```
30
+ */
31
+ export declare function getPreferenceValues<Values extends PreferenceValues = PreferenceValues>(): Values;
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Gets the selected text of the frontmost application.
3
+ *
4
+ * @throws An error when no text is selected in the frontmost application.
5
+ * @returns A Promise that resolves with the selected text.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * import { getSelectedText, Clipboard, showToast, Toast } from "@raycast/api";
10
+ *
11
+ * export default async () => {
12
+ * try {
13
+ * const selectedText = await getSelectedText();
14
+ * const transformedText = selectedText.toUpperCase();
15
+ * await Clipboard.paste(transformedText);
16
+ * } catch (error) {
17
+ * await showToast({
18
+ * style: Toast.Style.Failure,
19
+ * title: "Cannot transform text",
20
+ * message: String(error)
21
+ * });
22
+ * }
23
+ * };
24
+ * ```
25
+ */
26
+ export declare function getSelectedText(): Promise<string>;
27
+ /**
28
+ * Holds data about a File System item. Use the {@link getSelectedFinderItems} method to retrieve values.
29
+ */
30
+ export interface FileSystemItem {
31
+ /**
32
+ * The path to the item
33
+ */
34
+ path: string;
35
+ }
36
+ /**
37
+ * Gets the selected items from Finder.
38
+ *
39
+ * @throws An error when Finder is not the frontmost application.
40
+ * @returns A Promise that resolves with the selected file system items.
41
+ *
42
+ * @example
43
+ * ```typescript
44
+ * import { getSelectedFinderItems, Clipboard, showToast, Toast } from "@raycast/api";
45
+ *
46
+ * export default async () => {
47
+ * try {
48
+ * const selectedItems = await getSelectedFinderItems();
49
+ * if (selectedItems.length) {
50
+ * await Clipboard.paste(selectedItems[0].path);
51
+ * }
52
+ * } catch (error) {
53
+ * await showToast({
54
+ * style: Toast.Style.Failure,
55
+ * title: "Cannot copy file path",
56
+ * message: String(error)
57
+ * });
58
+ * }
59
+ * };
60
+ * ```
61
+ */
62
+ export declare function getSelectedFinderItems(): Promise<FileSystemItem[]>;
@@ -0,0 +1 @@
1
+ export * from "./useNavigation";
@@ -0,0 +1,66 @@
1
+ import { ReactNode } from "react";
2
+ /**
3
+ * Return type of the {@link useNavigation} hook to perform push and pop actions.
4
+ */
5
+ export interface Navigation {
6
+ /**
7
+ * Push a new view component to the navigation stack.
8
+ *
9
+ * @param component - The React component to push to the navigation stack.
10
+ */
11
+ push: (component: ReactNode) => void;
12
+ /**
13
+ * Pop current view component from the navigation stack.
14
+ */
15
+ pop: () => void;
16
+ }
17
+ /**
18
+ * A hook that lets you push and pop view components in the navigation stack.
19
+ *
20
+ * @remarks
21
+ * You most likely won't use this hook too often. To push a new component, use the {@link PushAction}.
22
+ * When a user presses `ESC`, we automatically push to the previous component.
23
+ *
24
+ * @returns A {@link Navigation} object with {@link Navigation.push} and {@link Navigation.pop} functions.
25
+ * Use the functions to alter the navigation stack.
26
+ *
27
+ * @example
28
+ * ```typescript
29
+ * import { ActionPanel, Detail, useNavigation, Action } from "@raycast/api";
30
+ *
31
+ * function Ping() {
32
+ * const { push } = useNavigation();
33
+ *
34
+ * return (
35
+ * <Detail
36
+ * markdown="Ping"
37
+ * actions={
38
+ * <ActionPanel>
39
+ * <Action title="Push" onAction={() => push(<Pong />)} />
40
+ * </ActionPanel>
41
+ * }
42
+ * />
43
+ * );
44
+ * }
45
+ *
46
+ * function Pong() {
47
+ * const { pop } = useNavigation();
48
+ *
49
+ * return (
50
+ * <Detail
51
+ * markdown="Pong"
52
+ * actions={
53
+ * <ActionPanel>
54
+ * <Action title="Pop" onAction={pop} />
55
+ * </ActionPanel>
56
+ * }
57
+ * />
58
+ * );
59
+ * }
60
+ *
61
+ * export default function Command() {
62
+ * return <Ping />;
63
+ * }
64
+ * ```
65
+ */
66
+ export declare function useNavigation(): Navigation;
@@ -0,0 +1,6 @@
1
+ export * from "./app";
2
+ export * from "./components";
3
+ export * from "./environment";
4
+ export * from "./hooks";
5
+ export * from "./ui";
6
+ export * from "./deprecated";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ export * from "./portal";
2
+ export * from "./ErrorBoundary";
3
+ export * from "./Navigation";
4
+ export * from "./Root";
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import type { PortalProps } from './types';
3
+ declare const Portal: import("react").MemoExoticComponent<({ name: _providedName, hostName, handleOnMount, handleOnUnmount, children, }: PortalProps) => any>;
4
+ export default Portal;
@@ -0,0 +1 @@
1
+ export { default } from './Portal';
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import type { PortalHostProps } from './types';
3
+ declare const PortalHost: React.MemoExoticComponent<({ name }: PortalHostProps) => JSX.Element>;
4
+ export default PortalHost;
@@ -0,0 +1 @@
1
+ export { default } from './PortalHost';
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import type { PortalProviderProps } from './types';
3
+ declare const PortalProvider: React.MemoExoticComponent<({ children }: PortalProviderProps) => JSX.Element>;
4
+ export default PortalProvider;
@@ -0,0 +1 @@
1
+ export { default } from './PortalProvider';
@@ -0,0 +1 @@
1
+ export { PortalDispatchContext, PortalStateContext } from './portal';
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import type { ActionTypes } from '../state';
3
+ import type { PortalType } from '../types';
4
+ export declare const PortalStateContext: import("react").Context<Record<string, PortalType[]>>;
5
+ export declare const PortalDispatchContext: import("react").Context<import("react").Dispatch<ActionTypes>>;
@@ -0,0 +1,2 @@
1
+ export { usePortal } from './usePortal';
2
+ export { usePortalState } from './usePortalState';
@@ -0,0 +1,8 @@
1
+ import { ReactNode } from 'react';
2
+ export declare const usePortal: (hostName?: string) => {
3
+ registerHost: () => void;
4
+ deregisterHost: () => void;
5
+ addPortal: (name: string, node: ReactNode) => void;
6
+ updatePortal: (name: string, node: ReactNode) => void;
7
+ removePortal: (name: string) => void;
8
+ };
@@ -0,0 +1 @@
1
+ export declare const usePortalState: (hostName: string) => import("../types").PortalType[];
@@ -0,0 +1,5 @@
1
+ export { default as Portal } from './components/portal';
2
+ export { default as PortalHost } from './components/portalHost';
3
+ export { default as PortalProvider } from './components/portalProvider';
4
+ export { usePortal } from './hooks/usePortal';
5
+ export { enableLogging } from './utilities/logger';
@@ -0,0 +1,9 @@
1
+ declare enum ACTIONS {
2
+ REGISTER_HOST = 0,
3
+ DEREGISTER_HOST = 1,
4
+ ADD_PORTAL = 2,
5
+ UPDATE_PORTAL = 3,
6
+ REMOVE_PORTAL = 4
7
+ }
8
+ declare const INITIAL_STATE: {};
9
+ export { ACTIONS, INITIAL_STATE };
@@ -0,0 +1,3 @@
1
+ export { reducer } from './reducer';
2
+ export { ACTIONS, INITIAL_STATE } from './constants';
3
+ export type { ActionTypes } from './types';
@@ -0,0 +1,3 @@
1
+ import type { PortalType } from '../types';
2
+ import type { ActionTypes } from './types';
3
+ export declare const reducer: (state: Record<string, Array<PortalType>>, action: ActionTypes) => Record<string, PortalType[]>;
@@ -0,0 +1,9 @@
1
+ interface PrintOptions {
2
+ component?: string;
3
+ method?: string;
4
+ params?: Record<string, any> | string | number | boolean;
5
+ }
6
+ declare type Print = (options: PrintOptions) => void;
7
+ declare const enableLogging: () => void;
8
+ declare let print: Print;
9
+ export { print, enableLogging };
@@ -0,0 +1 @@
1
+ export * from "./react";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from "./useId";
2
+ export * from "./useActionPanel";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ export * from "./comm";
2
+ export * from "./components";
3
+ export * from "./devtools";
4
+ export * from "./hooks";
5
+ export * from "./rendering";
6
+ export * from "./utils";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ export * from "./renderer";
2
+ export { apiCallbacks } from "./callbacks";
3
+ export * from "./reconciler";
4
+ export type { FormValueModel } from "./node-builders/forms";
5
+ export { wrapImageIfNeeded } from "./node-builders/utils";
6
+ export { specialKeys } from "./node-builders/keyboard";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import { RaycastElement } from "./types";
2
+ export declare function appendActionPanelChildElement(actionPanelElement: RaycastElement, childElement: RaycastElement): void;
3
+ export declare function appendActionPanelSubmenuChildElement(actionPanelElement: RaycastElement, childElement: RaycastElement): void;
@@ -0,0 +1,2 @@
1
+ import { RaycastElement } from "./types";
2
+ export declare function appendListChildElement(listElement: RaycastElement, childElement: RaycastElement): void;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export * from "./ids";
@@ -0,0 +1,115 @@
1
+ /**
2
+ * The standard colors. Use those colors for consistency.
3
+ *
4
+ * @remarks
5
+ * The colors automatically adapt to the Raycast theme (light or dark).
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * import { Color, Icon, List } from "@raycast/api";
10
+ *
11
+ * export default function Command() {
12
+ * return (
13
+ * <List>
14
+ * <List.Item title="Blue" icon={{ source: Icon.Circle, tintColor: Color.Blue }} />
15
+ * <List.Item title="Green" icon={{ source: Icon.Circle, tintColor: Color.Green }} />
16
+ * <List.Item title="Brown" icon={{ source: Icon.Circle, tintColor: Color.Brown }} />
17
+ * <List.Item title="Magenta" icon={{ source: Icon.Circle, tintColor: Color.Magenta }} />
18
+ * <List.Item title="Orange" icon={{ source: Icon.Circle, tintColor: Color.Orange }} />
19
+ * <List.Item title="Purple" icon={{ source: Icon.Circle, tintColor: Color.Purple }} />
20
+ * <List.Item title="Red" icon={{ source: Icon.Circle, tintColor: Color.Red }} />
21
+ * <List.Item title="Yellow" icon={{ source: Icon.Circle, tintColor: Color.Yellow }} />
22
+ * <List.Item title="PrimaryText" icon={{ source: Icon.Circle, tintColor: Color.PrimaryText }} />
23
+ * <List.Item title="SecondaryText" icon={{ source: Icon.Circle, tintColor: Color.SecondaryText }} />
24
+ * </List>
25
+ * );
26
+ * };
27
+ * ```
28
+ */
29
+ export declare enum Color {
30
+ Blue = "raycast-blue",
31
+ Brown = "raycast-brown",
32
+ Green = "raycast-green",
33
+ Magenta = "raycast-magenta",
34
+ Orange = "raycast-orange",
35
+ Purple = "raycast-purple",
36
+ Red = "raycast-red",
37
+ Yellow = "raycast-yellow",
38
+ PrimaryText = "raycast-primary-text",
39
+ SecondaryText = "raycast-secondary-text"
40
+ }
41
+ export declare namespace Color {
42
+ /**
43
+ * Union type for the supported color types.
44
+ *
45
+ * {@link Color.Raw} will be dynamically adjusted to achieve high contrast with the Raycast user interface.
46
+ *
47
+ * @example
48
+ * ```typescript
49
+ * import { Color, Icon, List } from "@raycast/api";
50
+ *
51
+ * export default function Command() {
52
+ * return (
53
+ * <List>
54
+ * <List.Item title="Built-in color" icon={{ source: Icon.Circle, tintColor: Color.Red }} />
55
+ * <List.Item title="HEX" icon={{ source: Icon.Circle, tintColor: "#FF0000" }} />
56
+ * <List.Item title="Short HEX" icon={{ source: Icon.Circle, tintColor: "#F00" }} />
57
+ * <List.Item title="RGBA" icon={{ source: Icon.Circle, tintColor: "rgb(255, 0, 0)" }} />
58
+ * <List.Item title="RGBA Percentage" icon={{ source: Icon.Circle, tintColor: "rgb(255, 0, 0, 1.0)" }} />
59
+ * <List.Item title="HSL" icon={{ source: Icon.Circle, tintColor: "hsla(200, 20%, 33%, 0.2)" }} />
60
+ * <List.Item title="Keywords" icon={{ source: Icon.Circle, tintColor: "red" }} />
61
+ * </List>
62
+ * );
63
+ * };
64
+ * ```
65
+ */
66
+ type ColorLike = Color | Color.Dynamic | Color.Raw;
67
+ /**
68
+ * A dynamic color applies different colors depending on the active Raycast theme.
69
+ *
70
+ * @example
71
+ * ```typescript
72
+ * import { Color, Icon, List } from "@raycast/api";
73
+ *
74
+ * export default function Command() {
75
+ * return (
76
+ * <List>
77
+ * <List.Item title="Dynamic Tint Color" icon={{ source: Icon.Circle, tintColor: { light: "#FF01FF", dark: "#FFFF50", adjustContrast: true } }} />
78
+ * <List.Item title="Dynamic Tint Color" icon={{ source: Icon.Circle, tintColor: { light: "#FF01FF", dark: "#FFFF50" } }} />
79
+ * </List>
80
+ * );
81
+ * };
82
+ * ```
83
+ */
84
+ interface Dynamic {
85
+ /**
86
+ * The color which is used in light theme.
87
+ */
88
+ light: Color.Raw;
89
+ /**
90
+ * The color which is used in dark theme.
91
+ */
92
+ dark: Color.Raw;
93
+ /**
94
+ * Enables dynamic contrast adjustment for light and dark theme color.
95
+ *
96
+ * @remarks
97
+ * Colors different to the built-in {@link Color} can be dynamically adjusted to achieve high contrast with the
98
+ * Raycast user interface. This makes it easy to guarantee a good look and feel when you aren't in control of the
99
+ * color, e.g. get it via a network request.
100
+ *
101
+ * @defaultValue false
102
+ */
103
+ adjustContrast?: boolean;
104
+ }
105
+ /**
106
+ * You can use any of the following color formats:
107
+ * - HEX, e.g `#FF0000`
108
+ * - Short HEX, e.g. `#F00`
109
+ * - RGBA, e.g. `rgb(255, 0, 0)`
110
+ * - RGBA Percentage, e.g. `rgb(255, 0, 0, 1.0)`
111
+ * - HSL, e.g. `hsla(200, 20%, 33%, 0.2)`
112
+ * - Keywords, e.g. `red`
113
+ */
114
+ type Raw = string;
115
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,97 @@
1
+ import { Image } from "../image";
2
+ /**
3
+ * Creates and shows a confirmation Alert with the given options.
4
+ *
5
+ * @param options - The options used to create the Alert.
6
+ * @returns A Promise that resolves to a boolean when the user triggers one of the actions.
7
+ * It will be `true` for the primary Action, `false` for the dismiss Action.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * import { confirmAlert } from "@raycast/api";
12
+ *
13
+ * export default async () => {
14
+ * if (await confirmAlert({ title: "Are you sure?" })) {
15
+ * // do something
16
+ * }
17
+ * };
18
+ * ```
19
+ */
20
+ export declare function confirmAlert(options: Alert.Options): Promise<boolean>;
21
+ export declare namespace Alert {
22
+ /**
23
+ * The options to create an {@link Alert}.
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * import { confimrAlert, Alert } from "@raycast/api";
28
+ *
29
+ * export default async () => {
30
+ * const options: Alert.Options = {
31
+ * title: "Finished cooking",
32
+ * message: "Delicious pasta for lunch",
33
+ * primaryAction: {
34
+ * title: 'Do something',
35
+ * onAction: () => {
36
+ * // while you can register a handler for an action, it's more elegant
37
+ * // to use the `if (await confirmAlert(...)) { ... }` pattern
38
+ * console.log("The alert action has been triggered")
39
+ * }
40
+ * }
41
+ * };
42
+ * await confirmAlert(options);
43
+ * };
44
+ * ```
45
+ */
46
+ interface Options {
47
+ /**
48
+ * The icon of an alert to illustrate the action. Displayed on the top.
49
+ */
50
+ icon?: Image.ImageLike;
51
+ /**
52
+ * The title of an alert. Displayed below the icon.
53
+ */
54
+ title: string;
55
+ /**
56
+ * An additional message for an Alert. Useful to show more information, e.g. a confirmation message for a destructive action.
57
+ */
58
+ message?: string;
59
+ /**
60
+ * The primary Action the user can take.
61
+ */
62
+ primaryAction?: ActionOptions;
63
+ /**
64
+ * The Action to dismiss the alert. There usually shouldn't be any side effects when the user takes this action.
65
+ */
66
+ dismissAction?: ActionOptions;
67
+ }
68
+ /**
69
+ * The options to create an {@link Alert} Action.
70
+ */
71
+ interface ActionOptions {
72
+ /**
73
+ * The title of the action.
74
+ */
75
+ title: string;
76
+ /**
77
+ * The style of the action.
78
+ */
79
+ style?: ActionStyle;
80
+ /**
81
+ * A callback called when the action is triggered.
82
+ */
83
+ onAction?: () => void;
84
+ }
85
+ /**
86
+ * Defines the visual style of an Action of the Alert.
87
+ *
88
+ * @remarks
89
+ * Use {@link Alert.ActionStyle.Default} for confirmations of a positive action.
90
+ * Use {@link Alert.ActionStyle.Destructive} for confirmations of a destructive action (eg. deleting a file).
91
+ */
92
+ enum ActionStyle {
93
+ Default = "DEFAULT",
94
+ Cancel = "CANCEL",
95
+ Destructive = "DESTRUCTIVE"
96
+ }
97
+ }