@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
package/bin/arm64/ray CHANGED
Binary file
package/bin/x86/ray CHANGED
Binary file
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@raycast/api",
3
- "version": "1.27.1",
3
+ "version": "1.29.1",
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
- "types": "types/index.d.ts",
8
+ "types": "types/api/index.d.ts",
9
9
  "peerDependencies": {
10
10
  "react": "17.0.2",
11
11
  "react-reconciler": "0.26.2"
@@ -0,0 +1,171 @@
1
+ /// <reference types="node" />
2
+ import { PathLike } from "fs";
3
+ /**
4
+ * Closes the main Raycast window.
5
+ *
6
+ * @param options - Can be used to clear the root search. Defaults to not clearing the root search after
7
+ * the window was closed.
8
+ * @returns A Promise that resolves when the main window is closed.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * import { closeMainWindow } from "@raycast/api";
13
+ * import { setTimeout } from "timers/promises";
14
+ *
15
+ * export default async () => {
16
+ * await setTimeout(1000);
17
+ * await closeMainWindow({ clearRootSearch: true });
18
+ * };
19
+ * ```
20
+ */
21
+ export declare function closeMainWindow(options?: {
22
+ clearRootSearch?: boolean;
23
+ }): Promise<void>;
24
+ /**
25
+ * Pops the navigation stack back to root search.
26
+ *
27
+ * @param options - Can be used to clear the search bar. Defaults to clearing the search bar after popped to root.
28
+ * @returns A Promise that resolves when Raycast popped to root.
29
+ *
30
+ * @example
31
+ * ```typescript
32
+ * import { Detail, popToRoot } from "@raycast/api";
33
+ * import { useEffect } from "react";
34
+ * import { setTimeout } from "timers";
35
+ *
36
+ * export default function Command() {
37
+ * useEffect(() => {
38
+ * setTimeout(() => {
39
+ * popToRoot({ clearSearchBar: true });
40
+ * }, 3000);
41
+ * }, []);
42
+ *
43
+ * return <Detail markdown="See you soon 👋" />;
44
+ * }
45
+ * ```
46
+ */
47
+ export declare function popToRoot(options?: {
48
+ clearSearchBar?: boolean;
49
+ }): Promise<void>;
50
+ /**
51
+ * Clear the text in the search bar.
52
+ *
53
+ * @param options - Can be used to force scrolling to the top. Defaults to scrolling to the top after the
54
+ * the search bar was cleared.
55
+ * @returns A Promise that resolves when the search bar is cleared.
56
+ */
57
+ export declare function clearSearchBar(options?: {
58
+ forceScrollToTop?: boolean;
59
+ }): Promise<void>;
60
+ /**
61
+ * Utils
62
+ */
63
+ /**
64
+ * Shows a file or directory in the Finder.
65
+ *
66
+ * @param path - The path to show in the Finder.
67
+ * @returns A Promise that resolves when the item is revealed in the Finder.
68
+ *
69
+ * @example
70
+ * ```typescript
71
+ * import { showInFinder } from "@raycast/api"
72
+ * import { homedir } from "os"
73
+ * import { join } from "path"
74
+ * showInFinder(join(homedir(), "Downloads"))
75
+ * ```
76
+ */
77
+ export declare function showInFinder(path: PathLike): Promise<void>;
78
+ /**
79
+ * Moves a file or directory to the Trash.
80
+ *
81
+ * @param paths - The item or items to move to the trash.
82
+ * @returns A Promise that resolves when all files are moved to the trash.
83
+ *
84
+ * @example
85
+ * ```typescript
86
+ * import { trash } from "@raycast/api";
87
+ * import { writeFile } from "fs/promises";
88
+ * import { homedir } from "os";
89
+ *
90
+ * export default async () => {
91
+ * const file = `${homedir()}/Desktop/yolo.txt`;
92
+ * await writeFile(file, "I will be deleted soon!");
93
+ * await trash(file);
94
+ * };
95
+ * ```
96
+ */
97
+ export declare function trash(path: PathLike | PathLike[]): Promise<void>;
98
+ /**
99
+ * An object that represents a locally installed application on the system.
100
+ *
101
+ * @remarks
102
+ * It can be used to open files or folders in a specific application. Use {@link getApplications} or
103
+ * {@link getDefaultApplication} to get applications that can open a specific file or folder.
104
+ */
105
+ export interface Application {
106
+ /**
107
+ * The display name of the application.
108
+ */
109
+ name: string;
110
+ /**
111
+ * The absolute path to the application bundle, e.g. `/Applications/Raycast.app`,
112
+ */
113
+ path: string;
114
+ /**
115
+ * The bundle identifier of the application, e.g. `com.raycast.macos`.
116
+ */
117
+ bundleId?: string;
118
+ }
119
+ /**
120
+ * Returns all applications that can open the file.
121
+ *
122
+ * @param path The path of the file or folder to get the applications for. If no path is specified, all installed applications are returned.
123
+ * @returns An array of {@link Application}.
124
+ *
125
+ * @example
126
+ * ```typescript
127
+ * import { getApplications } from "@raycast/api";
128
+ *
129
+ * export default async () => {
130
+ * const installedApplications = await getApplications();
131
+ * console.log("The following applications are installed on your Mac:");
132
+ * console.log(installedApplications.map((a) => a.name).join(", "));
133
+ * };
134
+ * ```
135
+ */
136
+ export declare function getApplications(path?: PathLike): Promise<Application[]>;
137
+ /**
138
+ * Returns the default application that the file would be opened with.
139
+ *
140
+ * @param path The path of the file or folder to get the default application for.
141
+ * @returns The default {@link Application} that would open the file. Throws an error if no application was found.
142
+ *
143
+ * @example
144
+ * ```typescript
145
+ * import { getDefaultApplication } from "@raycast/api";
146
+ *
147
+ * export default async () => {
148
+ * const defaultApplication = await getDefaultApplication(__filename);
149
+ * console.log(`Default application for JavaScript is: ${defaultApplication.name}`);
150
+ * };
151
+ * ```
152
+ */
153
+ export declare function getDefaultApplication(path: PathLike): Promise<Application>;
154
+ /**
155
+ * Opens a target with the default application or specified application.
156
+ *
157
+ * @param target The file, folder or URL to open.
158
+ * @param application The application name to use for opening the file. If no application is specified, the default application as determined by the system
159
+ * is used to open the specified file. Note that you can use the application name, app identifier, or absolute path to the app.
160
+ * @returns A Promise that resolves when the target has been opened.
161
+ *
162
+ * @example
163
+ * ```typescript
164
+ * import { open } from "@raycast/api";
165
+ *
166
+ * export default async () => {
167
+ * await open("https://www.raycast.com", "com.google.Chrome");
168
+ * };
169
+ * ```
170
+ */
171
+ export declare function open(target: string, application?: Application | string): Promise<void>;
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Copies text to the clipboard.
3
+ *
4
+ * @param text - The text to copy to the clipboard.
5
+ * @returns A Promise that resolves when the text is copied to the clipboard.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * import { Clipboard } from "@raycast/api";
10
+ *
11
+ * export default async () => {
12
+ * await Clipboard.copy("https://raycast.com");
13
+ * };
14
+ * ```
15
+ */
16
+ export declare function copy(text: string): Promise<void>;
17
+ /**
18
+ * Clears the current clipboard contents.
19
+ *
20
+ * @returns A Promise that resolves when the clipboard is cleared.
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * import { Clipboard } from "@raycast/api";
25
+ *
26
+ * export default async () => {
27
+ * await Clipboard.clear();
28
+ * };
29
+ * ```
30
+ */
31
+ export declare function clear(): Promise<void>;
32
+ /**
33
+ * Pastes text to the current selection of the frontmost application.
34
+ *
35
+ * @param text - The text to insert at the cursor.
36
+ * @returns A Promise that resolves when the text is pasted.
37
+ *
38
+ * @example
39
+ * ```typescript
40
+ * import { Clipboard } from "@raycast/api";
41
+ *
42
+ * export default async () => {
43
+ * await Clipboard.paste("I really like Raycast's API");
44
+ * };
45
+ * ```
46
+ */
47
+ export declare function paste(text: string): Promise<void>;
@@ -0,0 +1,4 @@
1
+ export * from "./app";
2
+ export * as Clipboard from "./clipboard";
3
+ export * as Keyboard from "./keyboard";
4
+ export * as LocalStorage from "./localStorage";
@@ -0,0 +1,56 @@
1
+ /**
2
+ * A keyboard shortcut is defined by one or more modifier keys (command, control, etc.) and a single key equivalent (a character or special key).
3
+ * See {@link KeyModifier} and {@link KeyEquivalent} for supported values.
4
+ *
5
+ * @example
6
+ * ```typescript
7
+ * import { ActionPanel, Detail, Action } from "@raycast/api";
8
+ *
9
+ * export default function Command() {
10
+ * return (
11
+ * <Detail markdown="Let's play some games 👾" actions={
12
+ * <ActionPanel title="Game controls">
13
+ * <Action
14
+ * title="Up"
15
+ * shortcut={{ modifiers: ["opt"], key: "arrowUp" }}
16
+ * onAction={() => console.log("Go up")}
17
+ * />
18
+ * <Action
19
+ * title="Down"
20
+ * shortcut={{ modifiers: ["opt"], key: "arrowDown" }}
21
+ * onAction={() => console.log("Go down")}
22
+ * />
23
+ * <Action
24
+ * title="Left"
25
+ * shortcut={{ modifiers: ["opt"], key: "arrowLeft" }}
26
+ * onAction={() => console.log("Go left")}
27
+ * />
28
+ * <Action
29
+ * title="Right"
30
+ * shortcut={{ modifiers: ["opt"], key: "arrowRight" }}
31
+ * onAction={() => console.log("Go right")}
32
+ * />
33
+ * </ActionPanel>}
34
+ * />
35
+ * );
36
+ * }
37
+ * ```
38
+ */
39
+ export interface Shortcut {
40
+ /**
41
+ * The modifier keys of the keyboard shortcut.
42
+ */
43
+ modifiers: KeyModifier[];
44
+ /**
45
+ * The key of the keyboard shortcut.
46
+ */
47
+ key: KeyEquivalent;
48
+ }
49
+ /**
50
+ * Modifier of a {@link Shortcut}
51
+ */
52
+ export declare type KeyModifier = "cmd" | "ctrl" | "opt" | "shift";
53
+ /**
54
+ * KeyEquivalent of a {@link Shortcut}
55
+ */
56
+ export declare type KeyEquivalent = "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z" | "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "." | "," | ";" | "=" | "+" | "-" | "[" | "]" | "{" | "}" | "«" | "»" | "(" | ")" | "/" | "\\" | "'" | "`" | "§" | "^" | "@" | "$" | "return" | "delete" | "deleteForward" | "tab" | "arrowUp" | "arrowDown" | "arrowLeft" | "arrowRight" | "pageUp" | "pageDown" | "home" | "end" | "space" | "escape" | "enter" | "backspace";
@@ -0,0 +1,117 @@
1
+ /**
2
+ * Retrieve all stored values in the local storage of an extension.
3
+ *
4
+ * @returns A Promise that resolves with an object containing all {@link Values}.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * import { LocalStorage } from "@raycast/api";
9
+ *
10
+ * interface Values {
11
+ * todo: string;
12
+ * priority: number;
13
+ * }
14
+ *
15
+ * export default async () => {
16
+ * const items = await LocalStorage.allItems<Values>();
17
+ * console.log(`Local storage item count: ${Object.entries(items).length}`);
18
+ * };
19
+ * ```
20
+ */
21
+ export declare function allItems<T extends Values = Values>(): Promise<T>;
22
+ /**
23
+ * Retrieve the stored value for the given key.
24
+ *
25
+ * @param key - The key you want to retrieve the value of.
26
+ * @returns A Promise that resolves with the stored value for the given key. If the key does not exist, `undefined` is returned.
27
+ *
28
+ * @example
29
+ * ```typescript
30
+ * import { LocalStorage } from "@raycast/api";
31
+ *
32
+ * export default async () => {
33
+ * const item = await LocalStorage.getItem<string>("favorite-fruit");
34
+ * console.log(item);
35
+ * };
36
+ * ```
37
+ */
38
+ export declare function getItem<T extends Value = Value>(key: string): Promise<T | undefined>;
39
+ /**
40
+ * Stores a value for the given key.
41
+ *
42
+ * @param key - The key you want to create or update the value of.
43
+ * @param value - The value you want to create or update for the given key.
44
+ * @returns A Promise that resolves when the value is stored.
45
+ *
46
+ * @example
47
+ * ```typescript
48
+ * import { LocalStorage } from "@raycast/api";
49
+ *
50
+ * export default async () => {
51
+ * await LocalStorage.setItem("favorite-fruit", "cherry");
52
+ * };
53
+ * ```
54
+ */
55
+ export declare function setItem(key: string, value: Value): Promise<void>;
56
+ /**
57
+ * Removes the stored value for the given key.
58
+ *
59
+ * @param key - The key you want to remove the value of.
60
+ * @returns A Promise that resolves when the value is removed.
61
+ *
62
+ * @example
63
+ * ```typescript
64
+ * import { LocalStorage } from "@raycast/api";
65
+ *
66
+ * export default async () => {
67
+ * await LocalStorage.removeItem("favorite-fruit");
68
+ * };
69
+ * ```
70
+ */
71
+ export declare function removeItem(key: string): Promise<void>;
72
+ /**
73
+ * Removes all stored values of an extension.
74
+ *
75
+ * @returns A Promise that resolves when all values are removed.
76
+ *
77
+ * @example
78
+ * ```typescript
79
+ * import { LocalStorage } from "@raycast/api";
80
+ *
81
+ * export default async () => {
82
+ * await LocalStorage.clear();
83
+ * };
84
+ * ```
85
+ */
86
+ export declare function clear(): Promise<void>;
87
+ /**
88
+ * Supported storage value types.
89
+ *
90
+ * @example
91
+ * ```typescript
92
+ * import { LocalStorage } from "@raycast/api";
93
+ *
94
+ * export default async () => {
95
+ * // string
96
+ * await LocalStorage.setItem("favorite-fruit", "cherry");
97
+ *
98
+ * // number
99
+ * await LocalStorage.setItem("fruit-basket-count", 3);
100
+ *
101
+ * // boolean
102
+ * await LocalStorage.setItem("fruit-eaten-today", true);
103
+ * };
104
+ * ```
105
+ */
106
+ export declare type Value = string | number | boolean;
107
+ /**
108
+ * Values of local storage items.
109
+ *
110
+ * > For type-safe values, you can define your own interface. Use the keys of the local storage items as the property names.
111
+ */
112
+ export interface Values {
113
+ /**
114
+ * The local storage value of a given key.
115
+ */
116
+ [key: string]: any;
117
+ }