mirror of
https://github.com/ByteAtATime/raycast-linux.git
synced 2025-12-23 10:11:57 +00:00
feat: add storage api to protocol
This commit is contained in:
parent
1c9dfd4bdc
commit
ecb583d256
1 changed files with 44 additions and 0 deletions
|
|
@ -9,6 +9,11 @@ type RustRequest =
|
|||
| { type: "cacheRemove"; namespace: string; key: string }
|
||||
| { type: "cacheClear"; namespace: string }
|
||||
| { type: "cacheIsEmpty"; namespace: string }
|
||||
| { type: "localStorageSet"; namespace: string; key: string; data: string }
|
||||
| { type: "localStorageGet"; namespace: string; key: string }
|
||||
| { type: "localStorageRemove"; namespace: string; key: string }
|
||||
| { type: "localStorageClear"; namespace: string }
|
||||
| { type: "localStorageAll"; namespace: string }
|
||||
| { type: "pop" }
|
||||
| { type: "openExtensionPreferences" }
|
||||
| { type: "openCommandPreferences" };
|
||||
|
|
@ -99,6 +104,45 @@ export const cacheIsEmpty = async (namespace: string): Promise<boolean> => {
|
|||
return result as boolean;
|
||||
};
|
||||
|
||||
export const localStorageSet = async (
|
||||
namespace: string,
|
||||
key: string,
|
||||
data: string
|
||||
): Promise<void> => {
|
||||
await sendRequest({ type: "localStorageSet", namespace, key, data });
|
||||
};
|
||||
|
||||
export const localStorageGet = async (
|
||||
namespace: string,
|
||||
key: string
|
||||
): Promise<string | null> => {
|
||||
const result = await sendRequest({ type: "localStorageGet", namespace, key });
|
||||
return result as string | null;
|
||||
};
|
||||
|
||||
export const localStorageRemove = async (
|
||||
namespace: string,
|
||||
key: string
|
||||
): Promise<boolean> => {
|
||||
const result = await sendRequest({
|
||||
type: "localStorageRemove",
|
||||
namespace,
|
||||
key,
|
||||
});
|
||||
return result as boolean;
|
||||
};
|
||||
|
||||
export const localStorageClear = async (namespace: string): Promise<void> => {
|
||||
await sendRequest({ type: "localStorageClear", namespace });
|
||||
};
|
||||
|
||||
export const localStorageAll = async (
|
||||
namespace: string
|
||||
): Promise<Record<string, string>> => {
|
||||
const result = await sendRequest({ type: "localStorageAll", namespace });
|
||||
return result as Record<string, string>;
|
||||
};
|
||||
|
||||
export const pop = async (): Promise<void> => {
|
||||
await sendRequest({ type: "pop" });
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue