@blastlauncher/runtime 1.0.1 → 3.0.0-alpha.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.
Files changed (110) hide show
  1. package/README.md +5 -0
  2. package/dist/api/action-panel.d.ts +134 -0
  3. package/dist/api/action-panel.js +36 -0
  4. package/dist/api/action.d.ts +386 -0
  5. package/dist/api/action.js +260 -0
  6. package/dist/api/ai-browser.d.ts +423 -0
  7. package/dist/api/ai-browser.js +113 -0
  8. package/dist/api/ai-decide.d.ts +41 -0
  9. package/dist/api/ai-decide.js +62 -0
  10. package/dist/api/applications.d.ts +13 -0
  11. package/dist/api/applications.js +48 -0
  12. package/dist/api/cache.d.ts +27 -0
  13. package/dist/api/cache.js +126 -0
  14. package/dist/api/capability.d.ts +14 -0
  15. package/dist/api/capability.js +30 -0
  16. package/dist/api/clipboard.d.ts +57 -0
  17. package/dist/api/clipboard.js +83 -0
  18. package/dist/api/detail.d.ts +33 -0
  19. package/dist/api/detail.js +11 -0
  20. package/dist/api/diagnostics.d.ts +16 -0
  21. package/dist/api/diagnostics.js +26 -0
  22. package/dist/api/dropdown.d.ts +17 -0
  23. package/dist/api/dropdown.js +48 -0
  24. package/dist/api/enums.generated.d.ts +750 -0
  25. package/dist/api/enums.generated.js +719 -0
  26. package/dist/api/environment.d.ts +44 -0
  27. package/dist/api/environment.js +61 -0
  28. package/dist/api/feedback.d.ts +94 -0
  29. package/dist/api/feedback.js +228 -0
  30. package/dist/api/form.d.ts +162 -0
  31. package/dist/api/form.js +345 -0
  32. package/dist/api/grid.d.ts +293 -0
  33. package/dist/api/grid.js +36 -0
  34. package/dist/api/implemented.d.ts +53 -0
  35. package/dist/api/implemented.js +43 -0
  36. package/dist/api/index.d.ts +612 -0
  37. package/dist/api/index.js +82 -0
  38. package/dist/api/keyboard.d.ts +182 -0
  39. package/dist/api/keyboard.js +107 -0
  40. package/dist/api/launch.d.ts +40 -0
  41. package/dist/api/launch.js +27 -0
  42. package/dist/api/legacy.d.ts +9 -0
  43. package/dist/api/legacy.js +25 -0
  44. package/dist/api/list.d.ts +291 -0
  45. package/dist/api/list.js +28 -0
  46. package/dist/api/menu-bar.d.ts +54 -0
  47. package/dist/api/menu-bar.js +30 -0
  48. package/dist/api/metadata.d.ts +62 -0
  49. package/dist/api/metadata.js +33 -0
  50. package/dist/api/navigation.d.ts +36 -0
  51. package/dist/api/navigation.js +99 -0
  52. package/dist/api/oauth.d.ts +84 -0
  53. package/dist/api/oauth.js +125 -0
  54. package/dist/api/open.d.ts +18 -0
  55. package/dist/api/open.js +36 -0
  56. package/dist/api/preferences.d.ts +43 -0
  57. package/dist/api/preferences.js +41 -0
  58. package/dist/api/selection.d.ts +10 -0
  59. package/dist/api/selection.js +31 -0
  60. package/dist/api/slot.d.ts +7 -0
  61. package/dist/api/slot.js +11 -0
  62. package/dist/api/storage.d.ts +24 -0
  63. package/dist/api/storage.js +45 -0
  64. package/dist/api/types.d.ts +46 -0
  65. package/dist/api/types.js +5 -0
  66. package/dist/api/unsupported.d.ts +18 -0
  67. package/dist/api/unsupported.generated.d.ts +1255 -0
  68. package/dist/api/unsupported.generated.js +56 -0
  69. package/dist/api/unsupported.js +65 -0
  70. package/dist/api/window-management.d.ts +97 -0
  71. package/dist/api/window-management.js +164 -0
  72. package/dist/api/window.d.ts +16 -0
  73. package/dist/api/window.js +32 -0
  74. package/dist/main.d.ts +1 -0
  75. package/dist/main.js +339 -0
  76. package/dist/provider.d.ts +8 -0
  77. package/dist/provider.js +107 -0
  78. package/dist/reconciler/index.d.ts +9 -0
  79. package/dist/reconciler/index.js +186 -0
  80. package/dist/reconciler/serialize.d.ts +3 -0
  81. package/dist/reconciler/serialize.js +53 -0
  82. package/dist/reconciler/types.d.ts +8 -0
  83. package/dist/reconciler/types.js +1 -0
  84. package/package.json +32 -23
  85. package/.eslintrc.js +0 -6
  86. package/CHANGELOG.md +0 -10
  87. package/dist/App.d.ts +0 -5
  88. package/dist/App.js +0 -10
  89. package/dist/components/CommandList/index.d.ts +0 -1
  90. package/dist/components/CommandList/index.js +0 -20
  91. package/dist/components/CommandList/utils.d.ts +0 -1
  92. package/dist/components/CommandList/utils.js +0 -24
  93. package/dist/index.d.ts +0 -1
  94. package/dist/index.js +0 -11
  95. package/dist/utils/connectDevtools.d.ts +0 -1
  96. package/dist/utils/connectDevtools.js +0 -11
  97. package/dist/utils/run.d.ts +0 -4
  98. package/dist/utils/run.js +0 -12
  99. package/dist/utils/window.d.ts +0 -0
  100. package/dist/utils/window.js +0 -2
  101. package/src/@types/raycast.d.ts +0 -4
  102. package/src/@types/react-devtools-core.d.ts +0 -19
  103. package/src/App.tsx +0 -18
  104. package/src/components/CommandList/index.tsx +0 -27
  105. package/src/components/CommandList/utils.ts +0 -26
  106. package/src/index.ts +0 -13
  107. package/src/utils/connectDevtools.ts +0 -8
  108. package/src/utils/run.ts +0 -7
  109. package/src/utils/window.js +0 -1
  110. package/tsconfig.json +0 -10
@@ -0,0 +1,84 @@
1
+ import type { JsonValue } from "../reconciler/index.js";
2
+ import { OAuth as enums } from "./enums.generated.js";
3
+ export type RedirectMethod = (typeof enums.RedirectMethod)[keyof typeof enums.RedirectMethod];
4
+ export type PKCEClientOptions = {
5
+ redirectMethod: RedirectMethod;
6
+ providerName: string;
7
+ providerIcon?: JsonValue;
8
+ providerId?: string;
9
+ description?: string;
10
+ revocationEndpoint?: string;
11
+ };
12
+ export type AuthorizationRequestOptions = {
13
+ endpoint: string;
14
+ clientId: string;
15
+ scope: string;
16
+ extraParameters?: Record<string, string>;
17
+ };
18
+ export type ClientIdMetadataDocumentAuthorizationRequestOptions = Omit<AuthorizationRequestOptions, "clientId"> & {
19
+ clientId?: string;
20
+ };
21
+ export type AuthorizationRequestURLParams = {
22
+ clientId?: string;
23
+ codeChallenge: string;
24
+ codeVerifier: string;
25
+ state: string;
26
+ redirectURI: string;
27
+ };
28
+ export type AuthorizationRequest = AuthorizationRequestURLParams & {
29
+ clientId: string;
30
+ toURL(): string;
31
+ };
32
+ export type AuthorizationOptions = {
33
+ url: string;
34
+ };
35
+ export type AuthorizationResponse = {
36
+ authorizationCode: string;
37
+ };
38
+ export type TokenSetOptions = {
39
+ accessToken: string;
40
+ refreshToken?: string;
41
+ idToken?: string;
42
+ expiresIn?: number;
43
+ scope?: string | string[];
44
+ };
45
+ export type TokenResponse = {
46
+ access_token: string;
47
+ refresh_token?: string;
48
+ id_token?: string;
49
+ expires_in?: number;
50
+ scope?: string | string[];
51
+ };
52
+ export type TokenSet = Omit<TokenSetOptions, "scope"> & {
53
+ scope?: string;
54
+ updatedAt: Date;
55
+ isExpired(): boolean;
56
+ };
57
+ declare class PKCEClient<M extends RedirectMethod = RedirectMethod> {
58
+ redirectMethod: M;
59
+ providerName: string;
60
+ providerIcon?: JsonValue;
61
+ providerId: string;
62
+ description?: string;
63
+ revocationEndpoint?: string;
64
+ constructor(options: PKCEClientOptions & {
65
+ redirectMethod: M;
66
+ });
67
+ authorizationRequest(this: PKCEClient<"clientIdMetadataDocument">, options: ClientIdMetadataDocumentAuthorizationRequestOptions): Promise<AuthorizationRequest>;
68
+ authorizationRequest(options: AuthorizationRequestOptions): Promise<AuthorizationRequest>;
69
+ authorize(options: AuthorizationRequest | AuthorizationOptions): Promise<AuthorizationResponse>;
70
+ setTokens(options: TokenSetOptions | TokenResponse): Promise<void>;
71
+ getTokens(): Promise<TokenSet | undefined>;
72
+ removeTokens(): Promise<void>;
73
+ }
74
+ export declare const OAuth: {
75
+ RedirectMethod: {
76
+ readonly Web: "web";
77
+ readonly App: "app";
78
+ readonly AppURI: "appURI";
79
+ readonly ClientIdMetadataDocument: "clientIdMetadataDocument";
80
+ };
81
+ clientIdMetadataDocument: string;
82
+ PKCEClient: typeof PKCEClient;
83
+ };
84
+ export {};
@@ -0,0 +1,125 @@
1
+ import { createHash, randomBytes } from "node:crypto";
2
+ import { requestCapability } from "./capability.js";
3
+ import { OAuth as enums } from "./enums.generated.js";
4
+ const clientIdMetadataDocument = "https://www.raycast.com/.well-known/oauth-client-metadata/raycast.json";
5
+ const redirects = {
6
+ web: "https://raycast.com/redirect?packageName=Extension",
7
+ app: "raycast://oauth?package_name=Extension",
8
+ appURI: "com.raycast:/oauth?package_name=Extension",
9
+ clientIdMetadataDocument: "https://raycast.com/redirect?packageName=Extension",
10
+ };
11
+ class PKCEClient {
12
+ redirectMethod;
13
+ providerName;
14
+ providerIcon;
15
+ providerId;
16
+ description;
17
+ revocationEndpoint;
18
+ constructor(options) {
19
+ this.redirectMethod = options.redirectMethod;
20
+ this.providerName = options.providerName;
21
+ this.providerId = options.providerId ?? options.providerName;
22
+ if (options.providerIcon !== undefined)
23
+ this.providerIcon = options.providerIcon;
24
+ if (options.description !== undefined)
25
+ this.description = options.description;
26
+ if (options.revocationEndpoint !== undefined)
27
+ this.revocationEndpoint = options.revocationEndpoint;
28
+ if (!redirects[this.redirectMethod])
29
+ throw new TypeError("Unknown OAuth redirect method");
30
+ }
31
+ async authorizationRequest(options) {
32
+ const clientId = options.clientId ??
33
+ (this.redirectMethod === "clientIdMetadataDocument" ? clientIdMetadataDocument : undefined);
34
+ if (!clientId)
35
+ throw new TypeError("OAuth authorizationRequest requires a clientId");
36
+ const codeVerifier = randomBytes(32).toString("base64url");
37
+ const request = {
38
+ clientId,
39
+ codeVerifier,
40
+ codeChallenge: createHash("sha256").update(codeVerifier).digest("base64url"),
41
+ state: randomBytes(32).toString("base64url"),
42
+ redirectURI: options.extraParameters?.redirect_uri ?? redirects[this.redirectMethod],
43
+ toURL() {
44
+ const url = new URL(options.endpoint);
45
+ const params = {
46
+ response_type: "code",
47
+ client_id: request.clientId,
48
+ redirect_uri: request.redirectURI,
49
+ scope: options.scope,
50
+ state: request.state,
51
+ code_challenge: request.codeChallenge,
52
+ code_challenge_method: "S256",
53
+ ...options.extraParameters,
54
+ };
55
+ for (const [key, value] of Object.entries(params))
56
+ url.searchParams.set(key, value);
57
+ return url.toString();
58
+ },
59
+ };
60
+ return request;
61
+ }
62
+ async authorize(options) {
63
+ const url = "url" in options ? options.url : options.toURL();
64
+ if (!["https:", "http:"].includes(new URL(url).protocol))
65
+ throw new TypeError("OAuth authorization URL must use HTTP or HTTPS");
66
+ const metadata = {
67
+ url,
68
+ providerName: this.providerName,
69
+ providerId: this.providerId,
70
+ redirectMethod: this.redirectMethod,
71
+ };
72
+ if (this.providerIcon !== undefined)
73
+ metadata.providerIcon = this.providerIcon;
74
+ if (this.description !== undefined)
75
+ metadata.description = this.description;
76
+ const result = await requestCapability("oauth.authorize", metadata);
77
+ if (!result ||
78
+ typeof result !== "object" ||
79
+ Array.isArray(result) ||
80
+ typeof result.authorizationCode !== "string")
81
+ throw new Error("Invalid OAuth authorization response");
82
+ return { authorizationCode: result.authorizationCode };
83
+ }
84
+ async setTokens(options) {
85
+ const values = "access_token" in options
86
+ ? {
87
+ accessToken: options.access_token,
88
+ refreshToken: options.refresh_token,
89
+ idToken: options.id_token,
90
+ expiresIn: options.expires_in,
91
+ scope: options.scope,
92
+ }
93
+ : options;
94
+ const tokens = { accessToken: values.accessToken };
95
+ for (const key of ["refreshToken", "idToken", "expiresIn", "scope"]) {
96
+ const value = values[key];
97
+ if (value !== undefined)
98
+ tokens[key] = Array.isArray(value) ? value.join(" ") : value;
99
+ }
100
+ await requestCapability("oauth.tokens.set", {
101
+ providerId: this.providerId,
102
+ tokens,
103
+ ...(this.revocationEndpoint === undefined
104
+ ? {}
105
+ : { revocationEndpoint: this.revocationEndpoint }),
106
+ });
107
+ }
108
+ async getTokens() {
109
+ const value = await requestCapability("oauth.tokens.get", { providerId: this.providerId });
110
+ if (value === null)
111
+ return undefined;
112
+ const tokens = value;
113
+ const updatedAt = new Date(tokens.updatedAt);
114
+ return {
115
+ ...tokens,
116
+ updatedAt,
117
+ isExpired: () => tokens.expiresIn !== undefined &&
118
+ Date.now() >= updatedAt.getTime() + tokens.expiresIn * 1000 - 10000,
119
+ };
120
+ }
121
+ async removeTokens() {
122
+ await requestCapability("oauth.tokens.remove", { providerId: this.providerId });
123
+ }
124
+ }
125
+ export const OAuth = { ...enums, clientIdMetadataDocument, PKCEClient };
@@ -0,0 +1,18 @@
1
+ import type { JsonValue } from "../reconciler/index.js";
2
+ /** `Application` from the declarations. */
3
+ export interface Application {
4
+ /** The display name of the application. */
5
+ name: string;
6
+ /** The localized name of the application. */
7
+ localizedName?: string;
8
+ /** The absolute path to the application bundle. */
9
+ path: string;
10
+ /** The bundle identifier of the application. */
11
+ bundleId?: string;
12
+ /** The Windows App ID of the application. */
13
+ windowsAppId?: string;
14
+ }
15
+ /** Whether the target is a link rather than a file; a `file:` URL is a file. */
16
+ export declare function isUrl(target: string): boolean;
17
+ export declare function applicationParam(application: Application | string | undefined): JsonValue | undefined;
18
+ export declare function open(target: string, application?: Application | string): Promise<void>;
@@ -0,0 +1,36 @@
1
+ import { requestCapability } from "./capability.js";
2
+ /** Whether the target is a link rather than a file; a `file:` URL is a file. */
3
+ export function isUrl(target) {
4
+ // `URL.canParse` rejects plain file paths.
5
+ if (!URL.canParse(target))
6
+ return false;
7
+ // A `file:` URL names a file, so granting `open.url` must not open it.
8
+ return new URL(target).protocol !== "file:";
9
+ }
10
+ // The host records the application as an identifier: a JSON-safe subset of the
11
+ // object, so nothing unserializable can reach the wire. Shared with the
12
+ // actions that also carry an application (`Action.Open`,
13
+ // `Action.CreateQuicklink`).
14
+ export function applicationParam(application) {
15
+ if (application === undefined)
16
+ return undefined;
17
+ if (typeof application === "string")
18
+ return application;
19
+ const param = {};
20
+ for (const field of ["name", "path", "bundleId", "windowsAppId"]) {
21
+ const value = application[field];
22
+ if (typeof value === "string")
23
+ param[field] = value;
24
+ }
25
+ return param;
26
+ }
27
+ export async function open(target, application) {
28
+ if (typeof target !== "string" || target === "")
29
+ throw new TypeError("open: target must be a non-empty string");
30
+ const url = isUrl(target);
31
+ const params = url ? { url: target } : { path: target };
32
+ const requested = applicationParam(application);
33
+ if (requested !== undefined)
34
+ params.application = requested;
35
+ await requestCapability(url ? "open.url" : "open.path", params);
36
+ }
@@ -0,0 +1,43 @@
1
+ import type { JsonValue } from "@blastlauncher/protocol";
2
+ export type PreferenceValues = Record<string, JsonValue>;
3
+ /** The preference kinds the manifest defines, exactly as the declarations list them. */
4
+ export type PreferenceType = "appPicker" | "checkbox" | "dropdown" | "password" | "textfield" | "file" | "directory";
5
+ /** `Preference`: one manifest preference item with the value this command got. */
6
+ export interface Preference {
7
+ /** The name of the preference. */
8
+ name: string;
9
+ /** The type of the preference. */
10
+ type: PreferenceType;
11
+ /** Specifies if the preference is required. */
12
+ required: boolean;
13
+ /** The title of the preference. */
14
+ title: string;
15
+ /** The description of the preference. */
16
+ description: string;
17
+ /** The value of the preference. */
18
+ value?: unknown;
19
+ /** The default value when there is no `value`. */
20
+ default?: unknown;
21
+ /** A placeholder used for text fields and passwords. */
22
+ placeholder?: string;
23
+ /** A label used for checkboxes. */
24
+ label?: string;
25
+ /** The data used for dropdowns. */
26
+ data?: unknown[];
27
+ }
28
+ /** `Preferences`: the deprecated record of preference items. */
29
+ export type Preferences = Record<string, Preference>;
30
+ /**
31
+ * The deprecated `preferences` object. It is mutated in place rather than
32
+ * replaced so extension modules that import it keep seeing the values from
33
+ * `init`; each entry's `value` is the same value `getPreferenceValues()` returns.
34
+ */
35
+ export declare const preferences: Preferences;
36
+ /** Installs the preference values from `init`. */
37
+ export declare function setPreferenceValues(next: PreferenceValues): void;
38
+ /** The preference values for this command, as a fresh shallow copy. */
39
+ export declare function getPreferenceValues<Values extends PreferenceValues = PreferenceValues>(): Values;
40
+ /** Opens Raycast's preference window and selects the current extension. */
41
+ export declare function openExtensionPreferences(): Promise<void>;
42
+ /** Opens Raycast's preference window and selects the current command. */
43
+ export declare function openCommandPreferences(): Promise<void>;
@@ -0,0 +1,41 @@
1
+ import { requestCapability } from "./capability.js";
2
+ let preferenceValues = {};
3
+ /**
4
+ * The deprecated `preferences` object. It is mutated in place rather than
5
+ * replaced so extension modules that import it keep seeing the values from
6
+ * `init`; each entry's `value` is the same value `getPreferenceValues()` returns.
7
+ */
8
+ export const preferences = {};
9
+ function installPreferences(values) {
10
+ for (const name of Object.keys(preferences))
11
+ delete preferences[name];
12
+ for (const [name, value] of Object.entries(values)) {
13
+ // `init` carries values only, so the manifest metadata the declarations
14
+ // require falls back to the preference's name and the text-field defaults.
15
+ preferences[name] = {
16
+ name,
17
+ type: "textfield",
18
+ required: false,
19
+ title: name,
20
+ description: "",
21
+ value,
22
+ };
23
+ }
24
+ }
25
+ /** Installs the preference values from `init`. */
26
+ export function setPreferenceValues(next) {
27
+ preferenceValues = next;
28
+ installPreferences(next);
29
+ }
30
+ /** The preference values for this command, as a fresh shallow copy. */
31
+ export function getPreferenceValues() {
32
+ return { ...preferenceValues };
33
+ }
34
+ /** Opens Raycast's preference window and selects the current extension. */
35
+ export async function openExtensionPreferences() {
36
+ await requestCapability("preferences.open", { scope: "extension" });
37
+ }
38
+ /** Opens Raycast's preference window and selects the current command. */
39
+ export async function openCommandPreferences() {
40
+ await requestCapability("preferences.open", { scope: "command" });
41
+ }
@@ -0,0 +1,10 @@
1
+ import type { PathLike } from "node:fs";
2
+ import type { Application } from "./open.js";
3
+ export interface FileSystemItem {
4
+ path: string;
5
+ }
6
+ export declare function getSelectedText(): Promise<string>;
7
+ export declare function getSelectedFinderItems(): Promise<FileSystemItem[]>;
8
+ export declare function getFrontmostApplication(): Promise<Application>;
9
+ export declare function showInFinder(path: PathLike): Promise<void>;
10
+ export declare function trash(path: PathLike | PathLike[]): Promise<void>;
@@ -0,0 +1,31 @@
1
+ import { pathParam, toApplication } from "./applications.js";
2
+ import { requestCapability } from "./capability.js";
3
+ export async function getSelectedText() {
4
+ const value = await requestCapability("selection.text", {});
5
+ if (typeof value !== "string")
6
+ throw new TypeError("getSelectedText: invalid host response");
7
+ if (value === "")
8
+ throw new Error("No text selected");
9
+ return value;
10
+ }
11
+ export async function getSelectedFinderItems() {
12
+ const value = await requestCapability("selection.files", {});
13
+ if (!Array.isArray(value))
14
+ throw new TypeError("getSelectedFinderItems: invalid host response");
15
+ return value.map((item) => {
16
+ if (!item || typeof item !== "object" || Array.isArray(item) || typeof item.path !== "string") {
17
+ throw new TypeError("getSelectedFinderItems: invalid FileSystemItem");
18
+ }
19
+ return { path: item.path };
20
+ });
21
+ }
22
+ export async function getFrontmostApplication() {
23
+ return toApplication(await requestCapability("applications.frontmost", {}), "getFrontmostApplication");
24
+ }
25
+ export async function showInFinder(path) {
26
+ await requestCapability("finder.show", { path: pathParam(path, "showInFinder") });
27
+ }
28
+ export async function trash(path) {
29
+ const paths = (Array.isArray(path) ? path : [path]).map((item) => pathParam(item, "trash"));
30
+ await requestCapability("trash", { paths });
31
+ }
@@ -0,0 +1,7 @@
1
+ import { type ReactNode } from "react";
2
+ /**
3
+ * Element-valued props (`actions`, `detail`, …) cannot live inside serializable
4
+ * props, so the shim renders each one as a `Slot` host child named after the
5
+ * prop, containing the element. See "Scene conventions" in docs/architecture.md.
6
+ */
7
+ export declare function slot(name: string, element: ReactNode): ReactNode;
@@ -0,0 +1,11 @@
1
+ import { createElement } from "react";
2
+ /**
3
+ * Element-valued props (`actions`, `detail`, …) cannot live inside serializable
4
+ * props, so the shim renders each one as a `Slot` host child named after the
5
+ * prop, containing the element. See "Scene conventions" in docs/architecture.md.
6
+ */
7
+ export function slot(name, element) {
8
+ if (element === null || element === undefined || typeof element === "boolean")
9
+ return null;
10
+ return createElement("Slot", { name }, element);
11
+ }
@@ -0,0 +1,24 @@
1
+ /** `LocalStorage.Value` (the deprecated `LocalStorageValue` alias). */
2
+ export type LocalStorageValue = string | number | boolean;
3
+ /** `LocalStorage.Values` (the deprecated `LocalStorageValues` alias). */
4
+ export interface LocalStorageValues {
5
+ [key: string]: LocalStorageValue;
6
+ }
7
+ declare function getItem<T extends LocalStorageValue = LocalStorageValue>(key: string): Promise<T | undefined>;
8
+ declare function setItem(key: string, value: LocalStorageValue): Promise<void>;
9
+ declare function removeItem(key: string): Promise<void>;
10
+ declare function allItems<T extends LocalStorageValues = LocalStorageValues>(): Promise<T>;
11
+ declare function clear(): Promise<void>;
12
+ export declare const LocalStorage: {
13
+ getItem: typeof getItem;
14
+ setItem: typeof setItem;
15
+ removeItem: typeof removeItem;
16
+ allItems: typeof allItems;
17
+ clear: typeof clear;
18
+ };
19
+ export declare const getLocalStorageItem: typeof getItem;
20
+ export declare const setLocalStorageItem: typeof setItem;
21
+ export declare const removeLocalStorageItem: typeof removeItem;
22
+ export declare const allLocalStorageItems: typeof allItems;
23
+ export declare const clearLocalStorage: typeof clear;
24
+ export {};
@@ -0,0 +1,45 @@
1
+ // `LocalStorage`, backed by the host's `storage.*` capabilities. Only keys and
2
+ // values cross the process boundary; the host keys the store by the session's
3
+ // extension, so the extension name never appears here or in params.
4
+ import { requestCapability } from "./capability.js";
5
+ function checkKey(key, api) {
6
+ if (typeof key !== "string" || key === "")
7
+ throw new TypeError(`${api}: key must be a non-empty string`);
8
+ return key;
9
+ }
10
+ function checkValue(value, api) {
11
+ if (typeof value !== "string" &&
12
+ !(typeof value === "number" && Number.isFinite(value)) &&
13
+ typeof value !== "boolean") {
14
+ throw new TypeError(`${api}: value must be a string, number or boolean`);
15
+ }
16
+ return value;
17
+ }
18
+ async function getItem(key) {
19
+ checkKey(key, "LocalStorage.getItem");
20
+ // The host answers `null` for a key it does not have.
21
+ const value = await requestCapability("storage.get", { key });
22
+ return (value ?? undefined);
23
+ }
24
+ async function setItem(key, value) {
25
+ checkKey(key, "LocalStorage.setItem");
26
+ checkValue(value, "LocalStorage.setItem");
27
+ await requestCapability("storage.set", { key, value });
28
+ }
29
+ async function removeItem(key) {
30
+ checkKey(key, "LocalStorage.removeItem");
31
+ await requestCapability("storage.remove", { key });
32
+ }
33
+ async function allItems() {
34
+ return (await requestCapability("storage.all", {}));
35
+ }
36
+ async function clear() {
37
+ await requestCapability("storage.clear", {});
38
+ }
39
+ export const LocalStorage = { getItem, setItem, removeItem, allItems, clear };
40
+ // Deprecated top-level aliases from the declarations.
41
+ export const getLocalStorageItem = getItem;
42
+ export const setLocalStorageItem = setItem;
43
+ export const removeLocalStorageItem = removeItem;
44
+ export const allLocalStorageItems = allItems;
45
+ export const clearLocalStorage = clear;
@@ -0,0 +1,46 @@
1
+ /** `Color.Raw`: any of the literal color formats Raycast accepts. */
2
+ export type ColorRaw = string;
3
+ /** `Color.Dynamic`: a light/dark pair with optional contrast adjustment. */
4
+ export type ColorDynamic = {
5
+ light: ColorRaw;
6
+ dark: ColorRaw;
7
+ adjustContrast?: boolean | null;
8
+ };
9
+ /** `Color.ColorLike`: a built-in color, a literal, or a dynamic pair. */
10
+ export type ColorLike = string | ColorDynamic;
11
+ /** `Image.URL` / `Image.Asset`: a remote URL or an `assets/` file name. */
12
+ export type ImagePath = string;
13
+ /** `Image.Source` / `Image.Fallback` for the light and dark themes. */
14
+ export type ImageThemeSource = {
15
+ light: ImagePath;
16
+ dark: ImagePath;
17
+ };
18
+ /** `Image.Source`: a URL, asset, icon name, emoji, or a theme-aware pair. */
19
+ export type ImageSource = ImagePath | ImageThemeSource;
20
+ /** `Image.Fallback`: the source to use when `Image.source` cannot be loaded. */
21
+ export type ImageFallback = ImagePath | ImageThemeSource;
22
+ /** The `Image` object: a source with optional fallback, mask and tint. */
23
+ export type ImageObject = {
24
+ source: ImageSource;
25
+ fallback?: ImageFallback | null;
26
+ mask?: string | null;
27
+ tintColor?: ColorLike | null;
28
+ };
29
+ /** `FileIcon`: an icon derived by the client from a file path. */
30
+ export type FileIcon = {
31
+ fileIcon: string;
32
+ };
33
+ /** `Image.ImageLike`: a URL, asset, icon, emoji, file icon or image object. */
34
+ export type ImageLike = ImagePath | FileIcon | ImageObject;
35
+ /** One platform's `Keyboard.Shortcut`, widened to what reaches the scene. */
36
+ export interface KeyShortcut {
37
+ modifiers: string[];
38
+ key: string;
39
+ }
40
+ /** `Keyboard.Shortcut`: one shortcut, or one per platform. */
41
+ export type Shortcut = KeyShortcut | {
42
+ macOS: KeyShortcut;
43
+ Windows: KeyShortcut;
44
+ /** @deprecated Use `Windows` instead. */
45
+ windows?: KeyShortcut;
46
+ };
@@ -0,0 +1,5 @@
1
+ // Types mirroring the parts of the Raycast declarations the shim implements.
2
+ // Image-likes and color-likes keep their declared shapes, so the serialized
3
+ // form stays the one extensions authored; shortcut shapes are widened to what
4
+ // reaches the scene as JSON.
5
+ export {};
@@ -0,0 +1,18 @@
1
+ export declare class UnsupportedApiError extends Error {
2
+ readonly code = "UNSUPPORTED_API";
3
+ readonly path: string;
4
+ constructor(path: string);
5
+ }
6
+ /** Present on stubs only: the unsupported path. Lets the serializer reject stub values. */
7
+ export declare const UNSUPPORTED_PATH: unique symbol;
8
+ export declare function unsupportedPath(value: unknown): string | undefined;
9
+ export type ApiStub = {
10
+ (...args: unknown[]): never;
11
+ new (...args: unknown[]): ApiStub;
12
+ [key: string]: ApiStub;
13
+ };
14
+ /** Preserve real implementations, while lazily supplying missing namespace members.
15
+ * Probe properties used by React and Promise resolution must retain normal semantics.
16
+ */
17
+ export declare function withUnsupported<T>(path: string, implemented?: T): T & Record<string, ApiStub>;
18
+ export declare function createApi<T extends object>(implemented: T): <K extends string>(path: K) => K extends keyof T ? T[K] & Record<string, ApiStub> : ApiStub;