diff --git a/apps/desktop2/src/components/column.tsx b/apps/desktop2/src/components/column.tsx
index 74a655e7..72b170ea 100644
--- a/apps/desktop2/src/components/column.tsx
+++ b/apps/desktop2/src/components/column.tsx
@@ -4,14 +4,14 @@ import { cn } from "@lume/utils";
import { invoke } from "@tauri-apps/api/core";
import { listen } from "@tauri-apps/api/event";
import { getCurrent } from "@tauri-apps/api/webviewWindow";
-import { useCallback, useEffect, useRef, useState } from "react";
+import { memo, useCallback, useEffect, useRef, useState } from "react";
type WindowEvent = {
scroll: boolean;
resize: boolean;
};
-export function Column({
+export const Column = memo(function Column({
column,
account,
}: {
@@ -98,7 +98,7 @@ export function Column({
);
-}
+});
function Header({ label, name }: { label: string; name: string }) {
const [title, setTitle] = useState(name);
diff --git a/apps/desktop2/src/components/conversation.tsx b/apps/desktop2/src/components/conversation.tsx
index 03743c0a..18d2f7a9 100644
--- a/apps/desktop2/src/components/conversation.tsx
+++ b/apps/desktop2/src/components/conversation.tsx
@@ -1,10 +1,10 @@
-import { ThreadIcon } from "@lume/icons";
import { Note } from "@/components/note";
-import { cn } from "@lume/utils";
+import { ThreadIcon } from "@lume/icons";
import type { LumeEvent } from "@lume/system";
-import { useMemo } from "react";
+import { cn } from "@lume/utils";
+import { memo, useMemo } from "react";
-export function Conversation({
+export const Conversation = memo(function Conversation({
event,
className,
}: {
@@ -44,4 +44,4 @@ export function Conversation({
);
-}
+});
diff --git a/apps/desktop2/src/components/quote.tsx b/apps/desktop2/src/components/quote.tsx
index b5a753f0..728e96c9 100644
--- a/apps/desktop2/src/components/quote.tsx
+++ b/apps/desktop2/src/components/quote.tsx
@@ -1,9 +1,10 @@
-import { QuoteIcon } from "@lume/icons";
import { Note } from "@/components/note";
-import { cn } from "@lume/utils";
+import { QuoteIcon } from "@lume/icons";
import type { LumeEvent } from "@lume/system";
+import { cn } from "@lume/utils";
+import { memo } from "react";
-export function Quote({
+export const Quote = memo(function Quote({
event,
className,
}: {
@@ -40,4 +41,4 @@ export function Quote({
);
-}
+});
diff --git a/apps/desktop2/src/components/repost.tsx b/apps/desktop2/src/components/repost.tsx
index 5dc24891..4b9868a4 100644
--- a/apps/desktop2/src/components/repost.tsx
+++ b/apps/desktop2/src/components/repost.tsx
@@ -1,11 +1,12 @@
-import { Spinner } from "@lume/ui";
import { Note } from "@/components/note";
import { User } from "@/components/user";
+import { type LumeEvent, NostrQuery } from "@lume/system";
+import { Spinner } from "@lume/ui";
import { cn } from "@lume/utils";
import { useQuery } from "@tanstack/react-query";
-import { type LumeEvent, NostrQuery } from "@lume/system";
+import { memo } from "react";
-export function RepostNote({
+export const RepostNote = memo(function RepostNote({
event,
className,
}: {
@@ -78,4 +79,4 @@ export function RepostNote({
)}
);
-}
+});
diff --git a/apps/desktop2/src/components/text.tsx b/apps/desktop2/src/components/text.tsx
index badce3b1..f35d4c1d 100644
--- a/apps/desktop2/src/components/text.tsx
+++ b/apps/desktop2/src/components/text.tsx
@@ -1,14 +1,17 @@
-import { cn } from "@lume/utils";
import { Note } from "@/components/note";
import type { LumeEvent } from "@lume/system";
+import { cn } from "@lume/utils";
+import { memo } from "react";
-export function TextNote({
+export const TextNote = memo(function TextNote({
event,
className,
}: {
event: LumeEvent;
className?: string;
}) {
+ console.log("Rendered at: ", event.id, new Date().toLocaleTimeString());
+
return (
);
-}
+});
diff --git a/packages/system/src/commands.ts b/packages/system/src/commands.ts
index 15156262..93883838 100644
--- a/packages/system/src/commands.ts
+++ b/packages/system/src/commands.ts
@@ -1,734 +1,517 @@
-// This file was generated by [tauri-specta](https://github.com/oscartbeaumont/tauri-specta). Do not edit this file manually.
-/** user-defined commands **/
+ // This file was generated by [tauri-specta](https://github.com/oscartbeaumont/tauri-specta). Do not edit this file manually.
-export const commands = {
- async getRelays(): Promise> {
- try {
- return { status: "ok", data: await TAURI_INVOKE("get_relays") };
- } catch (e) {
- if (e instanceof Error) throw e;
- else return { status: "error", error: e as any };
- }
- },
- async connectRelay(relay: string): Promise> {
- try {
- return {
- status: "ok",
- data: await TAURI_INVOKE("connect_relay", { relay }),
- };
- } catch (e) {
- if (e instanceof Error) throw e;
- else return { status: "error", error: e as any };
- }
- },
- async removeRelay(relay: string): Promise> {
- try {
- return {
- status: "ok",
- data: await TAURI_INVOKE("remove_relay", { relay }),
- };
- } catch (e) {
- if (e instanceof Error) throw e;
- else return { status: "error", error: e as any };
- }
- },
- async getBootstrapRelays(): Promise> {
- try {
- return { status: "ok", data: await TAURI_INVOKE("get_bootstrap_relays") };
- } catch (e) {
- if (e instanceof Error) throw e;
- else return { status: "error", error: e as any };
- }
- },
- async saveBootstrapRelays(relays: string): Promise> {
- try {
- return {
- status: "ok",
- data: await TAURI_INVOKE("save_bootstrap_relays", { relays }),
- };
- } catch (e) {
- if (e instanceof Error) throw e;
- else return { status: "error", error: e as any };
- }
- },
- async getAccounts(): Promise> {
- try {
- return { status: "ok", data: await TAURI_INVOKE("get_accounts") };
- } catch (e) {
- if (e instanceof Error) throw e;
- else return { status: "error", error: e as any };
- }
- },
- async createAccount(): Promise> {
- try {
- return { status: "ok", data: await TAURI_INVOKE("create_account") };
- } catch (e) {
- if (e instanceof Error) throw e;
- else return { status: "error", error: e as any };
- }
- },
- async saveAccount(
- nsec: string,
- password: string,
- ): Promise> {
- try {
- return {
- status: "ok",
- data: await TAURI_INVOKE("save_account", { nsec, password }),
- };
- } catch (e) {
- if (e instanceof Error) throw e;
- else return { status: "error", error: e as any };
- }
- },
- async getEncryptedKey(
- npub: string,
- password: string,
- ): Promise> {
- try {
- return {
- status: "ok",
- data: await TAURI_INVOKE("get_encrypted_key", { npub, password }),
- };
- } catch (e) {
- if (e instanceof Error) throw e;
- else return { status: "error", error: e as any };
- }
- },
- async getPrivateKey(npub: string): Promise> {
- try {
- return {
- status: "ok",
- data: await TAURI_INVOKE("get_private_key", { npub }),
- };
- } catch (e) {
- if (e instanceof Error) throw e;
- else return { status: "error", error: e as any };
- }
- },
- async connectRemoteAccount(uri: string): Promise> {
- try {
- return {
- status: "ok",
- data: await TAURI_INVOKE("connect_remote_account", { uri }),
- };
- } catch (e) {
- if (e instanceof Error) throw e;
- else return { status: "error", error: e as any };
- }
- },
- async loadAccount(
- npub: string,
- bunker: string | null,
- ): Promise> {
- try {
- return {
- status: "ok",
- data: await TAURI_INVOKE("load_account", { npub, bunker }),
- };
- } catch (e) {
- if (e instanceof Error) throw e;
- else return { status: "error", error: e as any };
- }
- },
- async getCurrentProfile(): Promise> {
- try {
- return { status: "ok", data: await TAURI_INVOKE("get_current_profile") };
- } catch (e) {
- if (e instanceof Error) throw e;
- else return { status: "error", error: e as any };
- }
- },
- async getProfile(id: string): Promise> {
- try {
- return { status: "ok", data: await TAURI_INVOKE("get_profile", { id }) };
- } catch (e) {
- if (e instanceof Error) throw e;
- else return { status: "error", error: e as any };
- }
- },
- async getContactList(): Promise> {
- try {
- return { status: "ok", data: await TAURI_INVOKE("get_contact_list") };
- } catch (e) {
- if (e instanceof Error) throw e;
- else return { status: "error", error: e as any };
- }
- },
- async setContactList(publicKeys: string[]): Promise> {
- try {
- return {
- status: "ok",
- data: await TAURI_INVOKE("set_contact_list", { publicKeys }),
- };
- } catch (e) {
- if (e instanceof Error) throw e;
- else return { status: "error", error: e as any };
- }
- },
- async createProfile(
- name: string,
- displayName: string,
- about: string,
- picture: string,
- banner: string,
- nip05: string,
- lud16: string,
- website: string,
- ): Promise> {
- try {
- return {
- status: "ok",
- data: await TAURI_INVOKE("create_profile", {
- name,
- displayName,
- about,
- picture,
- banner,
- nip05,
- lud16,
- website,
- }),
- };
- } catch (e) {
- if (e instanceof Error) throw e;
- else return { status: "error", error: e as any };
- }
- },
- async isContactListEmpty(): Promise> {
- try {
- return {
- status: "ok",
- data: await TAURI_INVOKE("is_contact_list_empty"),
- };
- } catch (e) {
- if (e instanceof Error) throw e;
- else return { status: "error", error: e as any };
- }
- },
- async checkContact(hex: string): Promise> {
- try {
- return {
- status: "ok",
- data: await TAURI_INVOKE("check_contact", { hex }),
- };
- } catch (e) {
- if (e instanceof Error) throw e;
- else return { status: "error", error: e as any };
- }
- },
- async toggleContact(
- hex: string,
- alias: string | null,
- ): Promise> {
- try {
- return {
- status: "ok",
- data: await TAURI_INVOKE("toggle_contact", { hex, alias }),
- };
- } catch (e) {
- if (e instanceof Error) throw e;
- else return { status: "error", error: e as any };
- }
- },
- async getNstore(key: string): Promise> {
- try {
- return { status: "ok", data: await TAURI_INVOKE("get_nstore", { key }) };
- } catch (e) {
- if (e instanceof Error) throw e;
- else return { status: "error", error: e as any };
- }
- },
- async setNstore(
- key: string,
- content: string,
- ): Promise> {
- try {
- return {
- status: "ok",
- data: await TAURI_INVOKE("set_nstore", { key, content }),
- };
- } catch (e) {
- if (e instanceof Error) throw e;
- else return { status: "error", error: e as any };
- }
- },
- async setWallet(uri: string): Promise> {
- try {
- return { status: "ok", data: await TAURI_INVOKE("set_wallet", { uri }) };
- } catch (e) {
- if (e instanceof Error) throw e;
- else return { status: "error", error: e as any };
- }
- },
- async loadWallet(): Promise> {
- try {
- return { status: "ok", data: await TAURI_INVOKE("load_wallet") };
- } catch (e) {
- if (e instanceof Error) throw e;
- else return { status: "error", error: e as any };
- }
- },
- async removeWallet(): Promise> {
- try {
- return { status: "ok", data: await TAURI_INVOKE("remove_wallet") };
- } catch (e) {
- if (e instanceof Error) throw e;
- else return { status: "error", error: e as any };
- }
- },
- async zapProfile(
- id: string,
- amount: string,
- message: string,
- ): Promise> {
- try {
- return {
- status: "ok",
- data: await TAURI_INVOKE("zap_profile", { id, amount, message }),
- };
- } catch (e) {
- if (e instanceof Error) throw e;
- else return { status: "error", error: e as any };
- }
- },
- async zapEvent(
- id: string,
- amount: string,
- message: string,
- ): Promise> {
- try {
- return {
- status: "ok",
- data: await TAURI_INVOKE("zap_event", { id, amount, message }),
- };
- } catch (e) {
- if (e instanceof Error) throw e;
- else return { status: "error", error: e as any };
- }
- },
- async friendToFriend(npub: string): Promise> {
- try {
- return {
- status: "ok",
- data: await TAURI_INVOKE("friend_to_friend", { npub }),
- };
- } catch (e) {
- if (e instanceof Error) throw e;
- else return { status: "error", error: e as any };
- }
- },
- async getNotifications(): Promise> {
- try {
- return { status: "ok", data: await TAURI_INVOKE("get_notifications") };
- } catch (e) {
- if (e instanceof Error) throw e;
- else return { status: "error", error: e as any };
- }
- },
- async getSettings(): Promise> {
- try {
- return { status: "ok", data: await TAURI_INVOKE("get_settings") };
- } catch (e) {
- if (e instanceof Error) throw e;
- else return { status: "error", error: e as any };
- }
- },
- async setNewSettings(settings: string): Promise> {
- try {
- return {
- status: "ok",
- data: await TAURI_INVOKE("set_new_settings", { settings }),
- };
- } catch (e) {
- if (e instanceof Error) throw e;
- else return { status: "error", error: e as any };
- }
- },
- async verifyNip05(
- key: string,
- nip05: string,
- ): Promise> {
- try {
- return {
- status: "ok",
- data: await TAURI_INVOKE("verify_nip05", { key, nip05 }),
- };
- } catch (e) {
- if (e instanceof Error) throw e;
- else return { status: "error", error: e as any };
- }
- },
- async getEventMeta(content: string): Promise> {
- try {
- return {
- status: "ok",
- data: await TAURI_INVOKE("get_event_meta", { content }),
- };
- } catch (e) {
- if (e instanceof Error) throw e;
- else return { status: "error", error: e as any };
- }
- },
- async getEvent(id: string): Promise> {
- try {
- return { status: "ok", data: await TAURI_INVOKE("get_event", { id }) };
- } catch (e) {
- if (e instanceof Error) throw e;
- else return { status: "error", error: e as any };
- }
- },
- async getEventFrom(
- id: string,
- relayHint: string,
- ): Promise> {
- try {
- return {
- status: "ok",
- data: await TAURI_INVOKE("get_event_from", { id, relayHint }),
- };
- } catch (e) {
- if (e instanceof Error) throw e;
- else return { status: "error", error: e as any };
- }
- },
- async getReplies(id: string): Promise> {
- try {
- return { status: "ok", data: await TAURI_INVOKE("get_replies", { id }) };
- } catch (e) {
- if (e instanceof Error) throw e;
- else return { status: "error", error: e as any };
- }
- },
- async listenEventReply(id: string): Promise> {
- try {
- return {
- status: "ok",
- data: await TAURI_INVOKE("listen_event_reply", { id }),
- };
- } catch (e) {
- if (e instanceof Error) throw e;
- else return { status: "error", error: e as any };
- }
- },
- async unlistenEventReply(id: string): Promise> {
- try {
- return {
- status: "ok",
- data: await TAURI_INVOKE("unlisten_event_reply", { id }),
- };
- } catch (e) {
- if (e instanceof Error) throw e;
- else return { status: "error", error: e as any };
- }
- },
- async getEventsBy(
- publicKey: string,
- asOf: string | null,
- ): Promise> {
- try {
- return {
- status: "ok",
- data: await TAURI_INVOKE("get_events_by", { publicKey, asOf }),
- };
- } catch (e) {
- if (e instanceof Error) throw e;
- else return { status: "error", error: e as any };
- }
- },
- async getLocalEvents(
- until: string | null,
- ): Promise> {
- try {
- return {
- status: "ok",
- data: await TAURI_INVOKE("get_local_events", { until }),
- };
- } catch (e) {
- if (e instanceof Error) throw e;
- else return { status: "error", error: e as any };
- }
- },
- async getGroupEvents(
- publicKeys: string[],
- until: string | null,
- ): Promise> {
- try {
- return {
- status: "ok",
- data: await TAURI_INVOKE("get_group_events", { publicKeys, until }),
- };
- } catch (e) {
- if (e instanceof Error) throw e;
- else return { status: "error", error: e as any };
- }
- },
- async getGlobalEvents(
- until: string | null,
- ): Promise> {
- try {
- return {
- status: "ok",
- data: await TAURI_INVOKE("get_global_events", { until }),
- };
- } catch (e) {
- if (e instanceof Error) throw e;
- else return { status: "error", error: e as any };
- }
- },
- async getHashtagEvents(
- hashtags: string[],
- until: string | null,
- ): Promise> {
- try {
- return {
- status: "ok",
- data: await TAURI_INVOKE("get_hashtag_events", { hashtags, until }),
- };
- } catch (e) {
- if (e instanceof Error) throw e;
- else return { status: "error", error: e as any };
- }
- },
- async publish(
- content: string,
- warning: string | null,
- difficulty: number | null,
- ): Promise> {
- try {
- return {
- status: "ok",
- data: await TAURI_INVOKE("publish", { content, warning, difficulty }),
- };
- } catch (e) {
- if (e instanceof Error) throw e;
- else return { status: "error", error: e as any };
- }
- },
- async reply(
- content: string,
- to: string,
- root: string | null,
- ): Promise> {
- try {
- return {
- status: "ok",
- data: await TAURI_INVOKE("reply", { content, to, root }),
- };
- } catch (e) {
- if (e instanceof Error) throw e;
- else return { status: "error", error: e as any };
- }
- },
- async repost(raw: string): Promise> {
- try {
- return { status: "ok", data: await TAURI_INVOKE("repost", { raw }) };
- } catch (e) {
- if (e instanceof Error) throw e;
- else return { status: "error", error: e as any };
- }
- },
- async eventToBech32(id: string): Promise> {
- try {
- return {
- status: "ok",
- data: await TAURI_INVOKE("event_to_bech32", { id }),
- };
- } catch (e) {
- if (e instanceof Error) throw e;
- else return { status: "error", error: e as any };
- }
- },
- async userToBech32(user: string): Promise> {
- try {
- return {
- status: "ok",
- data: await TAURI_INVOKE("user_to_bech32", { user }),
- };
- } catch (e) {
- if (e instanceof Error) throw e;
- else return { status: "error", error: e as any };
- }
- },
- async showInFolder(path: string): Promise {
- await TAURI_INVOKE("show_in_folder", { path });
- },
- async createColumn(column: Column): Promise> {
- try {
- return {
- status: "ok",
- data: await TAURI_INVOKE("create_column", { column }),
- };
- } catch (e) {
- if (e instanceof Error) throw e;
- else return { status: "error", error: e as any };
- }
- },
- async closeColumn(label: string): Promise> {
- try {
- return {
- status: "ok",
- data: await TAURI_INVOKE("close_column", { label }),
- };
- } catch (e) {
- if (e instanceof Error) throw e;
- else return { status: "error", error: e as any };
- }
- },
- async repositionColumn(
- label: string,
- x: number,
- y: number,
- ): Promise> {
- try {
- return {
- status: "ok",
- data: await TAURI_INVOKE("reposition_column", { label, x, y }),
- };
- } catch (e) {
- if (e instanceof Error) throw e;
- else return { status: "error", error: e as any };
- }
- },
- async resizeColumn(
- label: string,
- width: number,
- height: number,
- ): Promise> {
- try {
- return {
- status: "ok",
- data: await TAURI_INVOKE("resize_column", { label, width, height }),
- };
- } catch (e) {
- if (e instanceof Error) throw e;
- else return { status: "error", error: e as any };
- }
- },
- async openWindow(window: Window): Promise> {
- try {
- return {
- status: "ok",
- data: await TAURI_INVOKE("open_window", { window }),
- };
- } catch (e) {
- if (e instanceof Error) throw e;
- else return { status: "error", error: e as any };
- }
- },
- async openMainWindow(): Promise {
- await TAURI_INVOKE("open_main_window");
- },
- async setBadge(count: number): Promise {
- await TAURI_INVOKE("set_badge", { count });
- },
-};
+ /** user-defined commands **/
-/** user-defined events **/
+ export const commands = {
+async getRelays() : Promise> {
+try {
+ return { status: "ok", data: await TAURI_INVOKE("get_relays") };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
+async connectRelay(relay: string) : Promise> {
+try {
+ return { status: "ok", data: await TAURI_INVOKE("connect_relay", { relay }) };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
+async removeRelay(relay: string) : Promise> {
+try {
+ return { status: "ok", data: await TAURI_INVOKE("remove_relay", { relay }) };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
+async getBootstrapRelays() : Promise> {
+try {
+ return { status: "ok", data: await TAURI_INVOKE("get_bootstrap_relays") };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
+async saveBootstrapRelays(relays: string) : Promise> {
+try {
+ return { status: "ok", data: await TAURI_INVOKE("save_bootstrap_relays", { relays }) };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
+async getAccounts() : Promise> {
+try {
+ return { status: "ok", data: await TAURI_INVOKE("get_accounts") };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
+async createAccount() : Promise> {
+try {
+ return { status: "ok", data: await TAURI_INVOKE("create_account") };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
+async saveAccount(nsec: string, password: string) : Promise> {
+try {
+ return { status: "ok", data: await TAURI_INVOKE("save_account", { nsec, password }) };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
+async getEncryptedKey(npub: string, password: string) : Promise> {
+try {
+ return { status: "ok", data: await TAURI_INVOKE("get_encrypted_key", { npub, password }) };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
+async getPrivateKey(npub: string) : Promise> {
+try {
+ return { status: "ok", data: await TAURI_INVOKE("get_private_key", { npub }) };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
+async connectRemoteAccount(uri: string) : Promise> {
+try {
+ return { status: "ok", data: await TAURI_INVOKE("connect_remote_account", { uri }) };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
+async loadAccount(npub: string, bunker: string | null) : Promise> {
+try {
+ return { status: "ok", data: await TAURI_INVOKE("load_account", { npub, bunker }) };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
+async getCurrentProfile() : Promise> {
+try {
+ return { status: "ok", data: await TAURI_INVOKE("get_current_profile") };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
+async getProfile(id: string) : Promise> {
+try {
+ return { status: "ok", data: await TAURI_INVOKE("get_profile", { id }) };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
+async getContactList() : Promise> {
+try {
+ return { status: "ok", data: await TAURI_INVOKE("get_contact_list") };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
+async setContactList(publicKeys: string[]) : Promise> {
+try {
+ return { status: "ok", data: await TAURI_INVOKE("set_contact_list", { publicKeys }) };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
+async createProfile(name: string, displayName: string, about: string, picture: string, banner: string, nip05: string, lud16: string, website: string) : Promise> {
+try {
+ return { status: "ok", data: await TAURI_INVOKE("create_profile", { name, displayName, about, picture, banner, nip05, lud16, website }) };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
+async isContactListEmpty() : Promise> {
+try {
+ return { status: "ok", data: await TAURI_INVOKE("is_contact_list_empty") };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
+async checkContact(hex: string) : Promise> {
+try {
+ return { status: "ok", data: await TAURI_INVOKE("check_contact", { hex }) };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
+async toggleContact(hex: string, alias: string | null) : Promise> {
+try {
+ return { status: "ok", data: await TAURI_INVOKE("toggle_contact", { hex, alias }) };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
+async getNstore(key: string) : Promise> {
+try {
+ return { status: "ok", data: await TAURI_INVOKE("get_nstore", { key }) };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
+async setNstore(key: string, content: string) : Promise> {
+try {
+ return { status: "ok", data: await TAURI_INVOKE("set_nstore", { key, content }) };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
+async setWallet(uri: string) : Promise> {
+try {
+ return { status: "ok", data: await TAURI_INVOKE("set_wallet", { uri }) };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
+async loadWallet() : Promise> {
+try {
+ return { status: "ok", data: await TAURI_INVOKE("load_wallet") };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
+async removeWallet() : Promise> {
+try {
+ return { status: "ok", data: await TAURI_INVOKE("remove_wallet") };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
+async zapProfile(id: string, amount: string, message: string) : Promise> {
+try {
+ return { status: "ok", data: await TAURI_INVOKE("zap_profile", { id, amount, message }) };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
+async zapEvent(id: string, amount: string, message: string) : Promise> {
+try {
+ return { status: "ok", data: await TAURI_INVOKE("zap_event", { id, amount, message }) };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
+async friendToFriend(npub: string) : Promise> {
+try {
+ return { status: "ok", data: await TAURI_INVOKE("friend_to_friend", { npub }) };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
+async getNotifications() : Promise> {
+try {
+ return { status: "ok", data: await TAURI_INVOKE("get_notifications") };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
+async getSettings() : Promise> {
+try {
+ return { status: "ok", data: await TAURI_INVOKE("get_settings") };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
+async setNewSettings(settings: string) : Promise> {
+try {
+ return { status: "ok", data: await TAURI_INVOKE("set_new_settings", { settings }) };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
+async verifyNip05(key: string, nip05: string) : Promise> {
+try {
+ return { status: "ok", data: await TAURI_INVOKE("verify_nip05", { key, nip05 }) };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
+async getEventMeta(content: string) : Promise> {
+try {
+ return { status: "ok", data: await TAURI_INVOKE("get_event_meta", { content }) };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
+async getEvent(id: string) : Promise> {
+try {
+ return { status: "ok", data: await TAURI_INVOKE("get_event", { id }) };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
+async getEventFrom(id: string, relayHint: string) : Promise> {
+try {
+ return { status: "ok", data: await TAURI_INVOKE("get_event_from", { id, relayHint }) };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
+async getReplies(id: string) : Promise> {
+try {
+ return { status: "ok", data: await TAURI_INVOKE("get_replies", { id }) };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
+async listenEventReply(id: string) : Promise> {
+try {
+ return { status: "ok", data: await TAURI_INVOKE("listen_event_reply", { id }) };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
+async unlistenEventReply(id: string) : Promise> {
+try {
+ return { status: "ok", data: await TAURI_INVOKE("unlisten_event_reply", { id }) };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
+async getEventsBy(publicKey: string, asOf: string | null) : Promise> {
+try {
+ return { status: "ok", data: await TAURI_INVOKE("get_events_by", { publicKey, asOf }) };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
+async getLocalEvents(until: string | null) : Promise> {
+try {
+ return { status: "ok", data: await TAURI_INVOKE("get_local_events", { until }) };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
+async getGroupEvents(publicKeys: string[], until: string | null) : Promise> {
+try {
+ return { status: "ok", data: await TAURI_INVOKE("get_group_events", { publicKeys, until }) };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
+async getGlobalEvents(until: string | null) : Promise> {
+try {
+ return { status: "ok", data: await TAURI_INVOKE("get_global_events", { until }) };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
+async getHashtagEvents(hashtags: string[], until: string | null) : Promise> {
+try {
+ return { status: "ok", data: await TAURI_INVOKE("get_hashtag_events", { hashtags, until }) };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
+async publish(content: string, warning: string | null, difficulty: number | null) : Promise> {
+try {
+ return { status: "ok", data: await TAURI_INVOKE("publish", { content, warning, difficulty }) };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
+async reply(content: string, to: string, root: string | null) : Promise> {
+try {
+ return { status: "ok", data: await TAURI_INVOKE("reply", { content, to, root }) };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
+async repost(raw: string) : Promise> {
+try {
+ return { status: "ok", data: await TAURI_INVOKE("repost", { raw }) };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
+async eventToBech32(id: string) : Promise> {
+try {
+ return { status: "ok", data: await TAURI_INVOKE("event_to_bech32", { id }) };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
+async userToBech32(user: string) : Promise> {
+try {
+ return { status: "ok", data: await TAURI_INVOKE("user_to_bech32", { user }) };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
+async showInFolder(path: string) : Promise {
+await TAURI_INVOKE("show_in_folder", { path });
+},
+async createColumn(column: Column) : Promise> {
+try {
+ return { status: "ok", data: await TAURI_INVOKE("create_column", { column }) };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
+async closeColumn(label: string) : Promise> {
+try {
+ return { status: "ok", data: await TAURI_INVOKE("close_column", { label }) };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
+async repositionColumn(label: string, x: number, y: number) : Promise> {
+try {
+ return { status: "ok", data: await TAURI_INVOKE("reposition_column", { label, x, y }) };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
+async resizeColumn(label: string, width: number, height: number) : Promise> {
+try {
+ return { status: "ok", data: await TAURI_INVOKE("resize_column", { label, width, height }) };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
+async openWindow(window: Window) : Promise> {
+try {
+ return { status: "ok", data: await TAURI_INVOKE("open_window", { window }) };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
+async openMainWindow() : Promise {
+await TAURI_INVOKE("open_main_window");
+},
+async setBadge(count: number) : Promise {
+await TAURI_INVOKE("set_badge", { count });
+}
+}
-/** user-defined statics **/
+ /** user-defined events **/
+
+
+
+ /** user-defined statics **/
+
+
/** user-defined types **/
-export type Account = { npub: string; nsec: string };
-export type Column = {
- label: string;
- url: string;
- x: number;
- y: number;
- width: number;
- height: number;
-};
-export type Meta = {
- content: string;
- images: string[];
- videos: string[];
- events: string[];
- mentions: string[];
- hashtags: string[];
-};
-export type Relays = {
- connected: string[];
- read: string[] | null;
- write: string[] | null;
- both: string[] | null;
-};
-export type RichEvent = { raw: string; parsed: Meta | null };
-export type Settings = {
- proxy: string | null;
- image_resize_service: string | null;
- use_relay_hint: boolean;
- content_warning: boolean;
- display_avatar: boolean;
- display_zap_button: boolean;
- display_repost_button: boolean;
- display_media: boolean;
-};
-export type Window = {
- label: string;
- title: string;
- url: string;
- width: number;
- height: number;
- maximizable: boolean;
- minimizable: boolean;
- hidden_title: boolean;
-};
+export type Account = { npub: string; nsec: string }
+export type Column = { label: string; url: string; x: number; y: number; width: number; height: number }
+export type Meta = { content: string; images: string[]; videos: string[]; events: string[]; mentions: string[]; hashtags: string[] }
+export type Relays = { connected: string[]; read: string[] | null; write: string[] | null; both: string[] | null }
+export type RichEvent = { raw: string; parsed: Meta | null }
+export type Settings = { proxy: string | null; image_resize_service: string | null; use_relay_hint: boolean; content_warning: boolean; display_avatar: boolean; display_zap_button: boolean; display_repost_button: boolean; display_media: boolean }
+export type Window = { label: string; title: string; url: string; width: number; height: number; maximizable: boolean; minimizable: boolean; hidden_title: boolean }
/** tauri-specta globals **/
-import { invoke as TAURI_INVOKE } from "@tauri-apps/api/core";
+ import { invoke as TAURI_INVOKE } from "@tauri-apps/api/core";
import * as TAURI_API_EVENT from "@tauri-apps/api/event";
import { type WebviewWindow as __WebviewWindow__ } from "@tauri-apps/api/webviewWindow";
type __EventObj__ = {
- listen: (
- cb: TAURI_API_EVENT.EventCallback,
- ) => ReturnType>;
- once: (
- cb: TAURI_API_EVENT.EventCallback,
- ) => ReturnType>;
- emit: T extends null
- ? (payload?: T) => ReturnType
- : (payload: T) => ReturnType;
+ listen: (
+ cb: TAURI_API_EVENT.EventCallback
+ ) => ReturnType>;
+ once: (
+ cb: TAURI_API_EVENT.EventCallback
+ ) => ReturnType>;
+ emit: T extends null
+ ? (payload?: T) => ReturnType
+ : (payload: T) => ReturnType;
};
export type Result =
- | { status: "ok"; data: T }
- | { status: "error"; error: E };
+ | { status: "ok"; data: T }
+ | { status: "error"; error: E };
function __makeEvents__>(
- mappings: Record,
+ mappings: Record
) {
- return new Proxy(
- {} as unknown as {
- [K in keyof T]: __EventObj__ & {
- (handle: __WebviewWindow__): __EventObj__;
- };
- },
- {
- get: (_, event) => {
- const name = mappings[event as keyof T];
+ return new Proxy(
+ {} as unknown as {
+ [K in keyof T]: __EventObj__ & {
+ (handle: __WebviewWindow__): __EventObj__;
+ };
+ },
+ {
+ get: (_, event) => {
+ const name = mappings[event as keyof T];
- return new Proxy((() => {}) as any, {
- apply: (_, __, [window]: [__WebviewWindow__]) => ({
- listen: (arg: any) => window.listen(name, arg),
- once: (arg: any) => window.once(name, arg),
- emit: (arg: any) => window.emit(name, arg),
- }),
- get: (_, command: keyof __EventObj__) => {
- switch (command) {
- case "listen":
- return (arg: any) => TAURI_API_EVENT.listen(name, arg);
- case "once":
- return (arg: any) => TAURI_API_EVENT.once(name, arg);
- case "emit":
- return (arg: any) => TAURI_API_EVENT.emit(name, arg);
- }
- },
- });
- },
- },
- );
+ return new Proxy((() => {}) as any, {
+ apply: (_, __, [window]: [__WebviewWindow__]) => ({
+ listen: (arg: any) => window.listen(name, arg),
+ once: (arg: any) => window.once(name, arg),
+ emit: (arg: any) => window.emit(name, arg),
+ }),
+ get: (_, command: keyof __EventObj__) => {
+ switch (command) {
+ case "listen":
+ return (arg: any) => TAURI_API_EVENT.listen(name, arg);
+ case "once":
+ return (arg: any) => TAURI_API_EVENT.once(name, arg);
+ case "emit":
+ return (arg: any) => TAURI_API_EVENT.emit(name, arg);
+ }
+ },
+ });
+ },
+ }
+ );
}
+
+
\ No newline at end of file