feat: child webview

This commit is contained in:
reya 2024-03-16 15:05:06 +07:00
parent 16e6d234e5
commit 46cc01e0ee
37 changed files with 1686 additions and 1403 deletions

View File

@ -18,17 +18,17 @@
"@radix-ui/react-dialog": "^1.0.5",
"@radix-ui/react-dropdown-menu": "^2.0.6",
"@radix-ui/react-popover": "^1.0.7",
"@tanstack/query-sync-storage-persister": "^5.24.1",
"@tanstack/react-query": "^5.24.1",
"@tanstack/react-query-persist-client": "^5.24.1",
"@tanstack/react-router": "^1.18.1",
"i18next": "^23.10.0",
"@tanstack/query-sync-storage-persister": "^5.28.4",
"@tanstack/react-query": "^5.28.4",
"@tanstack/react-query-persist-client": "^5.28.4",
"@tanstack/react-router": "^1.20.0",
"i18next": "^23.10.1",
"i18next-resources-to-backend": "^1.2.0",
"nostr-tools": "^2.3.1",
"react": "^18.2.0",
"react-currency-input-field": "^3.8.0",
"react-dom": "^18.2.0",
"react-i18next": "^14.0.5",
"react-i18next": "^14.1.0",
"slate": "^0.101.5",
"slate-react": "^0.101.6",
"sonner": "^1.4.3",
@ -38,17 +38,17 @@
"@lume/tailwindcss": "workspace:^",
"@lume/tsconfig": "workspace:^",
"@lume/types": "workspace:^",
"@tanstack/router-devtools": "^1.18.1",
"@tanstack/router-vite-plugin": "^1.18.1",
"@types/react": "^18.2.61",
"@types/react-dom": "^18.2.19",
"@tanstack/router-devtools": "^1.20.0",
"@tanstack/router-vite-plugin": "^1.20.0",
"@types/react": "^18.2.66",
"@types/react-dom": "^18.2.22",
"@vitejs/plugin-react-swc": "^3.6.0",
"autoprefixer": "^10.4.18",
"postcss": "^8.4.35",
"tailwindcss": "^3.4.1",
"typescript": "^5.3.3",
"vite": "^5.1.4",
"typescript": "^5.4.2",
"vite": "^5.1.6",
"vite-plugin-top-level-await": "^1.4.1",
"vite-tsconfig-paths": "^4.3.1"
"vite-tsconfig-paths": "^4.3.2"
}
}

View File

@ -1,23 +1,36 @@
import { Newsfeed } from "@/components/newsfeed";
import { LumeColumn } from "@lume/types";
import { Column } from "@lume/ui";
import { createLazyFileRoute } from "@tanstack/react-router";
import { VList } from "virtua";
import { useState } from "react";
const DEFAULT_COLUMNS: LumeColumn[] = [
{ name: "Tauri v2", content: "https://beta.tauri.app" },
{ name: "Tauri v1", content: "https://tauri.app" },
{ name: "Lume", content: "https://lume.nu" },
{ name: "Snort", content: "https://snort.social" },
];
export const Route = createLazyFileRoute("/$account/home")({
component: Screen,
});
function Screen() {
const [isScroll, setIsScroll] = useState(false);
return (
<div className="relative h-full w-full">
<VList
className="scrollbar-none h-full w-full overflow-x-auto pb-2 pt-1.5 focus:outline-none"
itemSize={420}
tabIndex={0}
horizontal
<div
onScroll={() => setIsScroll((state) => !state)}
className="flex h-full w-full flex-nowrap gap-3 overflow-x-auto px-3 pb-3 pt-1.5 focus:outline-none"
>
<Newsfeed />
<div className="mx-2 h-full w-[420px] rounded-xl bg-white">todo!</div>
</VList>
{DEFAULT_COLUMNS.map((column, index) => (
<Column
key={column.name + index}
column={column}
isScroll={isScroll}
/>
))}
</div>
</div>
);
}

View File

@ -12,13 +12,13 @@
"dependencies": {
"@astrojs/check": "^0.4.1",
"@astrojs/tailwind": "^5.1.0",
"@fontsource/geist-mono": "^5.0.1",
"astro": "^4.4.9",
"@fontsource/geist-mono": "^5.0.2",
"astro": "^4.5.5",
"astro-seo-meta": "^4.1.0",
"astro-seo-schema": "^4.0.0",
"schema-dts": "^1.1.2",
"tailwindcss": "^3.4.1",
"typescript": "^5.3.3"
"typescript": "^5.4.2"
},
"devDependencies": {
"@tailwindcss/typography": "^0.5.10"

View File

@ -11,27 +11,27 @@
"tauri": "tauri"
},
"devDependencies": {
"@biomejs/biome": "^1.5.3",
"@tauri-apps/cli": "2.0.0-beta.6",
"turbo": "^1.12.4"
"@biomejs/biome": "^1.6.1",
"@tauri-apps/cli": "2.0.0-beta.9",
"turbo": "^1.12.5"
},
"packageManager": "pnpm@8.9.0",
"engines": {
"node": ">=18"
},
"dependencies": {
"@tauri-apps/api": "2.0.0-beta.3",
"@tauri-apps/plugin-autostart": "2.0.0-beta.1",
"@tauri-apps/plugin-clipboard-manager": "2.0.0-beta.1",
"@tauri-apps/plugin-dialog": "2.0.0-beta.1",
"@tauri-apps/plugin-fs": "2.0.0-beta.1",
"@tauri-apps/plugin-http": "2.0.0-beta.1",
"@tauri-apps/plugin-notification": "2.0.0-beta.1",
"@tauri-apps/plugin-os": "2.0.0-beta.1",
"@tauri-apps/plugin-process": "2.0.0-beta.1",
"@tauri-apps/plugin-shell": "2.0.0-beta.1",
"@tauri-apps/plugin-sql": "2.0.0-beta.1",
"@tauri-apps/plugin-updater": "2.0.0-beta.1",
"@tauri-apps/plugin-upload": "2.0.0-beta.1"
"@tauri-apps/api": "2.0.0-beta.5",
"@tauri-apps/plugin-autostart": "2.0.0-beta.2",
"@tauri-apps/plugin-clipboard-manager": "2.0.0-beta.2",
"@tauri-apps/plugin-dialog": "2.0.0-beta.2",
"@tauri-apps/plugin-fs": "2.0.0-beta.2",
"@tauri-apps/plugin-http": "2.0.0-beta.2",
"@tauri-apps/plugin-notification": "2.0.0-beta.2",
"@tauri-apps/plugin-os": "2.0.0-beta.2",
"@tauri-apps/plugin-process": "2.0.0-beta.2",
"@tauri-apps/plugin-shell": "2.0.0-beta.2",
"@tauri-apps/plugin-sql": "2.0.0-beta.2",
"@tauri-apps/plugin-updater": "2.0.0-beta.2",
"@tauri-apps/plugin-upload": "2.0.0-beta.2"
}
}

View File

@ -4,7 +4,7 @@
"private": true,
"main": "./src/index.ts",
"dependencies": {
"@getalby/sdk": "^3.3.1",
"@getalby/sdk": "^3.4.0",
"@lume/icons": "workspace:^",
"@lume/utils": "workspace:^",
"@radix-ui/react-avatar": "^1.0.4",
@ -14,8 +14,8 @@
"@radix-ui/react-hover-card": "^1.0.7",
"@radix-ui/react-popover": "^1.0.7",
"@radix-ui/react-tooltip": "^1.0.7",
"@tanstack/react-query": "^5.24.1",
"@tanstack/react-router": "^1.18.1",
"@tanstack/react-query": "^5.28.4",
"@tanstack/react-router": "^1.20.0",
"get-urls": "^12.1.0",
"media-chrome": "^2.2.5",
"minidenticons": "^4.2.1",
@ -24,7 +24,7 @@
"re-resizable": "^6.9.11",
"react": "^18.2.0",
"react-currency-input-field": "^3.8.0",
"react-i18next": "^14.0.5",
"react-i18next": "^14.1.0",
"react-string-replace": "^1.1.1",
"sonner": "^1.4.3",
"string-strip-html": "^13.4.6",
@ -34,8 +34,8 @@
"@lume/tailwindcss": "workspace:^",
"@lume/tsconfig": "workspace:^",
"@lume/types": "workspace:^",
"@types/react": "^18.2.61",
"@types/react": "^18.2.66",
"tailwindcss": "^3.4.1",
"typescript": "^5.3.3"
"typescript": "^5.4.2"
}
}

View File

@ -8,7 +8,7 @@
},
"devDependencies": {
"@lume/tsconfig": "workspace:*",
"@types/react": "^18.2.61",
"typescript": "^5.3.3"
"@types/react": "^18.2.66",
"typescript": "^5.4.2"
}
}

View File

@ -8,7 +8,7 @@
"@lume/icons": "workspace:^",
"@lume/ui": "workspace:^",
"@lume/utils": "workspace:^",
"@tanstack/react-query": "^5.24.1",
"@tanstack/react-query": "^5.28.4",
"react": "^18.2.0",
"sonner": "^1.4.3",
"virtua": "^0.27.5"
@ -17,8 +17,8 @@
"@lume/tailwindcss": "workspace:^",
"@lume/tsconfig": "workspace:^",
"@lume/types": "workspace:^",
"@types/react": "^18.2.61",
"@types/react": "^18.2.66",
"tailwindcss": "^3.4.1",
"typescript": "^5.3.3"
"typescript": "^5.4.2"
}
}

View File

@ -8,7 +8,7 @@
"@lume/icons": "workspace:^",
"@lume/ui": "workspace:^",
"@lume/utils": "workspace:^",
"@tanstack/react-query": "^5.24.1",
"@tanstack/react-query": "^5.28.4",
"react": "^18.2.0",
"sonner": "^1.4.3",
"virtua": "^0.27.5"
@ -17,8 +17,8 @@
"@lume/tailwindcss": "workspace:^",
"@lume/tsconfig": "workspace:^",
"@lume/types": "workspace:^",
"@types/react": "^18.2.61",
"@types/react": "^18.2.66",
"tailwindcss": "^3.4.1",
"typescript": "^5.3.3"
"typescript": "^5.4.2"
}
}

View File

@ -8,7 +8,7 @@
"@lume/icons": "workspace:^",
"@lume/ui": "workspace:^",
"@lume/utils": "workspace:^",
"@tanstack/react-query": "^5.24.1",
"@tanstack/react-query": "^5.28.4",
"react": "^18.2.0",
"sonner": "^1.4.3",
"virtua": "^0.27.5"
@ -17,8 +17,8 @@
"@lume/tailwindcss": "workspace:^",
"@lume/tsconfig": "workspace:^",
"@lume/types": "workspace:^",
"@types/react": "^18.2.61",
"@types/react": "^18.2.66",
"tailwindcss": "^3.4.1",
"typescript": "^5.3.3"
"typescript": "^5.4.2"
}
}

View File

@ -8,7 +8,7 @@
"@lume/icons": "workspace:^",
"@lume/ui": "workspace:^",
"@lume/utils": "workspace:^",
"@tanstack/react-query": "^5.24.1",
"@tanstack/react-query": "^5.28.4",
"react": "^18.2.0",
"sonner": "^1.4.3",
"virtua": "^0.27.5"
@ -17,8 +17,8 @@
"@lume/tailwindcss": "workspace:^",
"@lume/tsconfig": "workspace:^",
"@lume/types": "workspace:^",
"@types/react": "^18.2.61",
"@types/react": "^18.2.66",
"tailwindcss": "^3.4.1",
"typescript": "^5.3.3"
"typescript": "^5.4.2"
}
}

View File

@ -8,7 +8,7 @@
"@lume/icons": "workspace:^",
"@lume/ui": "workspace:^",
"@lume/utils": "workspace:^",
"@tanstack/react-query": "^5.24.1",
"@tanstack/react-query": "^5.28.4",
"react": "^18.2.0",
"sonner": "^1.4.3",
"virtua": "^0.27.5"
@ -17,8 +17,8 @@
"@lume/tailwindcss": "workspace:^",
"@lume/tsconfig": "workspace:^",
"@lume/types": "workspace:^",
"@types/react": "^18.2.61",
"@types/react": "^18.2.66",
"tailwindcss": "^3.4.1",
"typescript": "^5.3.3"
"typescript": "^5.4.2"
}
}

View File

@ -8,7 +8,7 @@
"@lume/icons": "workspace:^",
"@lume/ui": "workspace:^",
"@lume/utils": "workspace:^",
"@tanstack/react-query": "^5.24.1",
"@tanstack/react-query": "^5.28.4",
"react": "^18.2.0",
"sonner": "^1.4.3",
"virtua": "^0.27.5"
@ -17,8 +17,8 @@
"@lume/tailwindcss": "workspace:^",
"@lume/tsconfig": "workspace:^",
"@lume/types": "workspace:^",
"@types/react": "^18.2.61",
"@types/react": "^18.2.66",
"tailwindcss": "^3.4.1",
"typescript": "^5.3.3"
"typescript": "^5.4.2"
}
}

View File

@ -8,7 +8,7 @@
"@lume/icons": "workspace:^",
"@lume/ui": "workspace:^",
"@lume/utils": "workspace:^",
"@tanstack/react-query": "^5.24.1",
"@tanstack/react-query": "^5.28.4",
"react": "^18.2.0",
"sonner": "^1.4.3",
"virtua": "^0.27.5"
@ -17,8 +17,8 @@
"@lume/tailwindcss": "workspace:^",
"@lume/tsconfig": "workspace:^",
"@lume/types": "workspace:^",
"@types/react": "^18.2.61",
"@types/react": "^18.2.66",
"tailwindcss": "^3.4.1",
"typescript": "^5.3.3"
"typescript": "^5.4.2"
}
}

View File

@ -8,7 +8,7 @@
"@lume/icons": "workspace:^",
"@lume/ui": "workspace:^",
"@lume/utils": "workspace:^",
"@tanstack/react-query": "^5.24.1",
"@tanstack/react-query": "^5.28.4",
"react": "^18.2.0",
"sonner": "^1.4.3",
"virtua": "^0.27.5"
@ -17,8 +17,8 @@
"@lume/tailwindcss": "workspace:^",
"@lume/tsconfig": "workspace:^",
"@lume/types": "workspace:^",
"@types/react": "^18.2.61",
"@types/react": "^18.2.66",
"tailwindcss": "^3.4.1",
"typescript": "^5.3.3"
"typescript": "^5.4.2"
}
}

View File

@ -8,7 +8,7 @@
"@lume/icons": "workspace:^",
"@lume/ui": "workspace:^",
"@lume/utils": "workspace:^",
"@tanstack/react-query": "^5.24.1",
"@tanstack/react-query": "^5.28.4",
"react": "^18.2.0",
"sonner": "^1.4.3",
"virtua": "^0.27.5"
@ -17,8 +17,8 @@
"@lume/tailwindcss": "workspace:^",
"@lume/tsconfig": "workspace:^",
"@lume/types": "workspace:^",
"@types/react": "^18.2.61",
"@types/react": "^18.2.66",
"tailwindcss": "^3.4.1",
"typescript": "^5.3.3"
"typescript": "^5.4.2"
}
}

View File

@ -8,7 +8,7 @@
"@lume/icons": "workspace:^",
"@lume/ui": "workspace:^",
"@lume/utils": "workspace:^",
"@tanstack/react-query": "^5.24.1",
"@tanstack/react-query": "^5.28.4",
"react": "^18.2.0",
"sonner": "^1.4.3",
"virtua": "^0.27.5"
@ -17,8 +17,8 @@
"@lume/tailwindcss": "workspace:^",
"@lume/tsconfig": "workspace:^",
"@lume/types": "workspace:^",
"@types/react": "^18.2.61",
"@types/react": "^18.2.66",
"tailwindcss": "^3.4.1",
"typescript": "^5.3.3"
"typescript": "^5.4.2"
}
}

View File

@ -8,15 +8,15 @@
"@lume/icons": "workspace:^",
"@lume/ui": "workspace:^",
"@lume/utils": "workspace:^",
"@tanstack/react-query": "^5.24.1",
"@tanstack/react-query": "^5.28.4",
"react": "^18.2.0"
},
"devDependencies": {
"@lume/tailwindcss": "workspace:^",
"@lume/tsconfig": "workspace:^",
"@lume/types": "workspace:^",
"@types/react": "^18.2.61",
"@types/react": "^18.2.66",
"tailwindcss": "^3.4.1",
"typescript": "^5.3.3"
"typescript": "^5.4.2"
}
}

View File

@ -1,3 +1,5 @@
import { type Webview } from "@tauri-apps/api/webview";
export interface Settings {
autoupdate: boolean;
nsecbunker: boolean;
@ -81,9 +83,16 @@ export interface RichContent {
}
export interface LumeColumn {
id: number;
title: string;
content: string;
name: string;
description?: string;
author?: string;
logo?: string;
x?: number;
y?: number;
width?: number;
height?: number;
window?: Webview;
}
export interface Opengraph {

View File

@ -9,6 +9,6 @@
"access": "public"
},
"devDependencies": {
"typescript": "^5.3.3"
"typescript": "^5.4.2"
}
}

View File

@ -4,7 +4,7 @@
"private": true,
"main": "./src/index.ts",
"dependencies": {
"@getalby/sdk": "^3.3.1",
"@getalby/sdk": "^3.4.0",
"@lume/ark": "workspace:^",
"@lume/icons": "workspace:^",
"@lume/utils": "workspace:^",
@ -18,9 +18,9 @@
"@radix-ui/react-hover-card": "^1.0.7",
"@radix-ui/react-popover": "^1.0.7",
"@radix-ui/react-tooltip": "^1.0.7",
"@tanstack/react-query": "^5.24.1",
"@tanstack/react-router": "^1.18.1",
"framer-motion": "^11.0.8",
"@tanstack/react-query": "^5.28.4",
"@tanstack/react-router": "^1.20.0",
"framer-motion": "^11.0.14",
"get-urls": "^12.1.0",
"media-chrome": "^2.2.5",
"minidenticons": "^4.2.1",
@ -32,7 +32,7 @@
"react-dom": "^18.2.0",
"react-hook-form": "^7.51.0",
"react-hotkeys-hook": "^4.5.0",
"react-i18next": "^14.0.5",
"react-i18next": "^14.1.0",
"react-string-replace": "^1.1.1",
"slate": "^0.101.5",
"slate-react": "^0.101.6",
@ -46,8 +46,8 @@
"@lume/tailwindcss": "workspace:^",
"@lume/tsconfig": "workspace:^",
"@lume/types": "workspace:^",
"@types/react": "^18.2.61",
"@types/react": "^18.2.66",
"tailwindcss": "^3.4.1",
"typescript": "^5.3.3"
"typescript": "^5.4.2"
}
}

View File

@ -0,0 +1,89 @@
import { useCallback, useEffect, useMemo, useRef } from "react";
import {
LogicalPosition,
LogicalSize,
getCurrent,
} from "@tauri-apps/api/window";
import { Webview } from "@tauri-apps/api/webview";
import { LumeColumn } from "@lume/types";
import { useDebouncedCallback } from "use-debounce";
export function Column({
column,
isScroll,
}: {
column: LumeColumn;
isScroll: boolean;
}) {
const mainWindow = useMemo(() => getCurrent(), []);
const childWindow = useRef<Webview>(null);
const divRef = useRef<HTMLDivElement>(null);
const initialRect = useRef<DOMRect>(null);
const handleResize = useDebouncedCallback(() => {
const newRect = divRef.current.getBoundingClientRect();
if (initialRect.current.height !== newRect.height) {
childWindow.current.setSize(
new LogicalSize(newRect.width, newRect.height),
);
}
}, 800);
const trackResize = useCallback(async () => {
const unlisten = await mainWindow.onResized(() => {
handleResize();
});
return () => {
if (unlisten) unlisten();
};
}, []);
useEffect(() => {
if (isScroll) {
const newRect = divRef.current.getBoundingClientRect();
childWindow.current.setPosition(
new LogicalPosition(newRect.x, newRect.y),
);
}
}, [isScroll]);
useEffect(() => {
if (!mainWindow) return;
if (!divRef.current) return;
if (childWindow.current) return;
// get element dimension
const rect = divRef.current.getBoundingClientRect();
// create new webview
initialRect.current = rect;
childWindow.current = new Webview(
mainWindow,
column.name.toLowerCase().replace(/\W/g, ""),
{
url: column.content,
x: rect.x,
y: rect.y,
width: rect.width,
height: rect.height,
transparent: true,
userAgent: "Lume/4.0",
},
);
// track window resize event
trackResize();
}, []);
return (
<div className="shadow-primary relative flex h-full w-[420px] shrink-0 flex-col rounded-xl bg-white dark:bg-black">
<div className="flex h-11 w-full shrink-0 items-center justify-center gap-2 border-b border-neutral-100 dark:border-neutral-900">
<div className="inline-flex items-center gap-1.5">
<div className="text-[13px] font-medium">{column.name}</div>
</div>
</div>
<div ref={divRef} className="flex-1" />
<div className="h-6 w-full shrink-0 border-t border-neutral-100 dark:border-neutral-900" />
</div>
);
}

View File

@ -1,16 +0,0 @@
import { cn } from "@lume/utils";
import { ReactNode } from "react";
export function ColumnContent({
children,
className,
}: {
children: ReactNode;
className?: string;
}) {
return (
<div className={cn("flex-1 overflow-y-auto overflow-x-hidden", className)}>
{children}
</div>
);
}

View File

@ -1,82 +0,0 @@
import {
ChevronDownIcon,
MoveLeftIcon,
MoveRightIcon,
RefreshIcon,
TrashIcon,
} from "@lume/icons";
import { cn } from "@lume/utils";
import * as DropdownMenu from "@radix-ui/react-dropdown-menu";
import { useTranslation } from "react-i18next";
export function ColumnHeader({
title,
className,
}: {
title: string;
className?: string;
}) {
const { t } = useTranslation();
return (
<DropdownMenu.Root>
<div
className={cn(
"flex h-11 w-full shrink-0 items-center justify-center gap-2 border-b border-neutral-100 dark:border-neutral-900",
className,
)}
>
<DropdownMenu.Trigger asChild>
<div className="inline-flex items-center gap-1.5">
<div className="text-[13px] font-medium">{title}</div>
<ChevronDownIcon className="size-5" />
</div>
</DropdownMenu.Trigger>
<DropdownMenu.Portal>
<DropdownMenu.Content
sideOffset={5}
className="flex w-[200px] flex-col overflow-hidden rounded-2xl bg-white/50 p-2 ring-1 ring-black/10 backdrop-blur-2xl focus:outline-none dark:bg-black/50 dark:ring-white/10"
>
<DropdownMenu.Item asChild>
<button
type="button"
className="inline-flex h-9 items-center gap-3 rounded-lg px-3 text-sm font-medium text-black/70 hover:bg-black/10 hover:text-black focus:outline-none dark:text-white/70 dark:hover:bg-white/10 dark:hover:text-white"
>
<RefreshIcon className="size-4" />
{t("global.refresh")}
</button>
</DropdownMenu.Item>
<DropdownMenu.Item asChild>
<button
type="button"
className="inline-flex h-9 items-center gap-3 rounded-lg px-3 text-sm font-medium text-black/70 hover:bg-black/10 hover:text-black focus:outline-none dark:text-white/70 dark:hover:bg-white/10 dark:hover:text-white"
>
<MoveLeftIcon className="size-4" />
{t("global.moveLeft")}
</button>
</DropdownMenu.Item>
<DropdownMenu.Item asChild>
<button
type="button"
className="inline-flex h-9 items-center gap-3 rounded-lg px-3 text-sm font-medium text-black/70 hover:bg-black/10 hover:text-black focus:outline-none dark:text-white/70 dark:hover:bg-white/10 dark:hover:text-white"
>
<MoveRightIcon className="size-4" />
{t("global.moveRight")}
</button>
</DropdownMenu.Item>
<DropdownMenu.Separator className="my-1 h-px bg-black/10 dark:bg-white/10" />
<DropdownMenu.Item asChild>
<button
type="button"
className="inline-flex h-9 items-center gap-3 rounded-lg px-3 text-sm font-medium text-red-500 hover:bg-red-500 hover:text-red-50 focus:outline-none"
>
<TrashIcon className="size-4" />
{t("global.delete")}
</button>
</DropdownMenu.Item>
</DropdownMenu.Content>
</DropdownMenu.Portal>
</div>
</DropdownMenu.Root>
);
}

View File

@ -1,9 +0,0 @@
import { ColumnContent } from "./content";
import { ColumnHeader } from "./header";
import { ColumnRoot } from "./root";
export const Column = {
Root: ColumnRoot,
Header: ColumnHeader,
Content: ColumnContent,
};

View File

@ -1,21 +0,0 @@
import { cn } from "@lume/utils";
import { ReactNode } from "react";
export function ColumnRoot({
children,
className,
}: {
children: ReactNode;
className?: string;
}) {
return (
<div
className={cn(
"shadow-primary relative mx-2 flex h-full w-[420px] flex-col rounded-xl bg-white dark:bg-black",
className,
)}
>
{children}
</div>
);
}

View File

@ -1,7 +1,7 @@
export * from "./user";
export * from "./note";
export * from "./column";
// UI
export * from "./column";
export * from "./container";
export * from "./box";

View File

@ -8,7 +8,7 @@
"access": "public"
},
"dependencies": {
"@tanstack/react-query": "^5.24.1",
"@tanstack/react-query": "^5.28.4",
"bitcoin-units": "^1.0.0",
"clsx": "^2.1.0",
"dayjs": "^1.11.10",
@ -21,9 +21,9 @@
"devDependencies": {
"@lume/tsconfig": "workspace:^",
"@lume/types": "workspace:^",
"@types/react": "^18.2.61",
"@types/react-dom": "^18.2.19",
"@types/react": "^18.2.66",
"@types/react-dom": "^18.2.22",
"tailwind-merge": "^2.2.1",
"typescript": "^5.3.3"
"typescript": "^5.4.2"
}
}

File diff suppressed because it is too large Load Diff

483
src-tauri/Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -11,12 +11,12 @@ rust-version = "1.68"
tauri-build = { version = "2.0.0-beta", features = [] }
[dependencies]
nostr-sdk = { version = "0.28", features = ["sqlite"] }
nostr-sdk = { version = "0.29", features = ["sqlite"] }
tokio = { version = "1", features = ["full"] }
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
tauri = { version = "2.0.0-beta", features = [
"unstable",
"unstable",
"tray-icon",
"macos-private-api",
"native-tls-vendored",

View File

@ -30,11 +30,14 @@
"updater:allow-check",
"updater:default",
"window:allow-start-dragging",
"window:allow-create",
"store:allow-get",
"clipboard-manager:allow-write",
"clipboard-manager:allow-read",
"webview:allow-create-webview-window",
"webview:allow-create-webview",
"webview:allow-set-webview-size",
"webview:allow-set-webview-position",
"dialog:allow-open",
"fs:allow-read-file",
"shell:allow-open",

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
{"desktop-capability":{"identifier":"desktop-capability","description":"Capability for the desktop","local":true,"windows":["main","splash","editor","settings","nwc","zap-*","event-*","user-*","column-*"],"permissions":["path:default","event:default","window:default","app:default","resources:default","menu:default","tray:default","notification:allow-is-permission-granted","notification:allow-request-permission","notification:default","os:allow-locale","os:allow-platform","updater:allow-check","updater:default","window:allow-start-dragging","store:allow-get","clipboard-manager:allow-write","clipboard-manager:allow-read","webview:allow-create-webview-window","webview:allow-create-webview","dialog:allow-open","fs:allow-read-file","shell:allow-open",{"identifier":"http:default","allow":[{"url":"http://**/"},{"url":"https://**/"}]},{"identifier":"fs:allow-read-text-file","allow":[{"path":"$RESOURCE/locales/*"}]}],"platforms":["linux","macOS","windows"]}}
{"desktop-capability":{"identifier":"desktop-capability","description":"Capability for the desktop","local":true,"windows":["main","splash","editor","settings","nwc","zap-*","event-*","user-*","column-*"],"permissions":["path:default","event:default","window:default","app:default","resources:default","menu:default","tray:default","notification:allow-is-permission-granted","notification:allow-request-permission","notification:default","os:allow-locale","os:allow-platform","updater:allow-check","updater:default","window:allow-start-dragging","window:allow-create","store:allow-get","clipboard-manager:allow-write","clipboard-manager:allow-read","webview:allow-create-webview-window","webview:allow-create-webview","webview:allow-set-webview-size","webview:allow-set-webview-position","dialog:allow-open","fs:allow-read-file","shell:allow-open",{"identifier":"http:default","allow":[{"url":"http://**/"},{"url":"https://**/"}]},{"identifier":"fs:allow-read-text-file","allow":[{"path":"$RESOURCE/locales/*"}]}],"platforms":["linux","macOS","windows"]}}

View File

@ -11,6 +11,13 @@
}
]
},
{
"description": "A list of capabilities.",
"type": "array",
"items": {
"$ref": "#/definitions/Capability"
}
},
{
"description": "A list of capabilities.",
"type": "object",
@ -34,8 +41,7 @@
"type": "object",
"required": [
"identifier",
"permissions",
"windows"
"permissions"
],
"properties": {
"identifier": {
@ -86,14 +92,10 @@
},
"platforms": {
"description": "Target platforms this capability applies. By default all platforms are affected by this capability.",
"default": [
"linux",
"macOS",
"windows",
"android",
"iOS"
"type": [
"array",
"null"
],
"type": "array",
"items": {
"$ref": "#/definitions/Target"
}
@ -108,7 +110,7 @@
],
"properties": {
"urls": {
"description": "Remote domains this capability refers to. Can use glob patterns.",
"description": "Remote domains this capability refers to using the [URLPattern standard](https://urlpattern.spec.whatwg.org/).\n\n# Examples\n\n- \"https://*.mydomain.dev\": allows subdomains of mydomain.dev - \"https://mydomain.dev/api/*\": allows any subpath of mydomain.dev/api",
"type": "array",
"items": {
"type": "string"
@ -2236,32 +2238,48 @@
"items": {
"title": "ScopeEntry",
"description": "HTTP scope entry object definition.",
"type": "object",
"required": [
"url"
],
"properties": {
"url": {
"description": "A URL that can be accessed by the webview when using the HTTP APIs. The scoped URL is matched against the request URL using a glob pattern.\n\nExamples:\n\n- \"https://*\" or \"https://**\" : allows all HTTPS urls\n\n- \"https://*.github.com/tauri-apps/tauri\": allows any subdomain of \"github.com\" with the \"tauri-apps/api\" path\n\n- \"https://myapi.service.com/users/*\": allows access to any URLs that begins with \"https://myapi.service.com/users/\"",
"anyOf": [
{
"description": "A URL that can be accessed by the webview when using the HTTP APIs. Wildcards can be used following the URL pattern standard.\n\nSee [the URL Pattern spec](https://urlpattern.spec.whatwg.org/) for more information.\n\nExamples:\n\n- \"https://*\" : allows all HTTPS origin on port 443\n\n- \"https://*:*\" : allows all HTTPS origin on any port\n\n- \"https://*.github.com/tauri-apps/tauri\": allows any subdomain of \"github.com\" with the \"tauri-apps/api\" path\n\n- \"https://myapi.service.com/users/*\": allows access to any URLs that begins with \"https://myapi.service.com/users/\"",
"type": "string"
},
{
"type": "object",
"required": [
"url"
],
"properties": {
"url": {
"description": "A URL that can be accessed by the webview when using the HTTP APIs. Wildcards can be used following the URL pattern standard.\n\nSee [the URL Pattern spec](https://urlpattern.spec.whatwg.org/) for more information.\n\nExamples:\n\n- \"https://*\" : allows all HTTPS origin on port 443\n\n- \"https://*:*\" : allows all HTTPS origin on any port\n\n- \"https://*.github.com/tauri-apps/tauri\": allows any subdomain of \"github.com\" with the \"tauri-apps/api\" path\n\n- \"https://myapi.service.com/users/*\": allows access to any URLs that begins with \"https://myapi.service.com/users/\"",
"type": "string"
}
}
}
}
]
}
},
"deny": {
"items": {
"title": "ScopeEntry",
"description": "HTTP scope entry object definition.",
"type": "object",
"required": [
"url"
],
"properties": {
"url": {
"description": "A URL that can be accessed by the webview when using the HTTP APIs. The scoped URL is matched against the request URL using a glob pattern.\n\nExamples:\n\n- \"https://*\" or \"https://**\" : allows all HTTPS urls\n\n- \"https://*.github.com/tauri-apps/tauri\": allows any subdomain of \"github.com\" with the \"tauri-apps/api\" path\n\n- \"https://myapi.service.com/users/*\": allows access to any URLs that begins with \"https://myapi.service.com/users/\"",
"anyOf": [
{
"description": "A URL that can be accessed by the webview when using the HTTP APIs. Wildcards can be used following the URL pattern standard.\n\nSee [the URL Pattern spec](https://urlpattern.spec.whatwg.org/) for more information.\n\nExamples:\n\n- \"https://*\" : allows all HTTPS origin on port 443\n\n- \"https://*:*\" : allows all HTTPS origin on any port\n\n- \"https://*.github.com/tauri-apps/tauri\": allows any subdomain of \"github.com\" with the \"tauri-apps/api\" path\n\n- \"https://myapi.service.com/users/*\": allows access to any URLs that begins with \"https://myapi.service.com/users/\"",
"type": "string"
},
{
"type": "object",
"required": [
"url"
],
"properties": {
"url": {
"description": "A URL that can be accessed by the webview when using the HTTP APIs. Wildcards can be used following the URL pattern standard.\n\nSee [the URL Pattern spec](https://urlpattern.spec.whatwg.org/) for more information.\n\nExamples:\n\n- \"https://*\" : allows all HTTPS origin on port 443\n\n- \"https://*:*\" : allows all HTTPS origin on any port\n\n- \"https://*.github.com/tauri-apps/tauri\": allows any subdomain of \"github.com\" with the \"tauri-apps/api\" path\n\n- \"https://myapi.service.com/users/*\": allows access to any URLs that begins with \"https://myapi.service.com/users/\"",
"type": "string"
}
}
}
}
]
}
}
}
@ -4762,6 +4780,97 @@
"http:deny-fetch-send"
]
},
{
"description": "image:default -> Default permissions for the plugin.",
"type": "string",
"enum": [
"image:default"
]
},
{
"description": "image:allow-from-bytes -> Enables the from_bytes command without any pre-configured scope.",
"type": "string",
"enum": [
"image:allow-from-bytes"
]
},
{
"description": "image:allow-from-path -> Enables the from_path command without any pre-configured scope.",
"type": "string",
"enum": [
"image:allow-from-path"
]
},
{
"description": "image:allow-height -> Enables the height command without any pre-configured scope.",
"type": "string",
"enum": [
"image:allow-height"
]
},
{
"description": "image:allow-new -> Enables the new command without any pre-configured scope.",
"type": "string",
"enum": [
"image:allow-new"
]
},
{
"description": "image:allow-rgba -> Enables the rgba command without any pre-configured scope.",
"type": "string",
"enum": [
"image:allow-rgba"
]
},
{
"description": "image:allow-width -> Enables the width command without any pre-configured scope.",
"type": "string",
"enum": [
"image:allow-width"
]
},
{
"description": "image:deny-from-bytes -> Denies the from_bytes command without any pre-configured scope.",
"type": "string",
"enum": [
"image:deny-from-bytes"
]
},
{
"description": "image:deny-from-path -> Denies the from_path command without any pre-configured scope.",
"type": "string",
"enum": [
"image:deny-from-path"
]
},
{
"description": "image:deny-height -> Denies the height command without any pre-configured scope.",
"type": "string",
"enum": [
"image:deny-height"
]
},
{
"description": "image:deny-new -> Denies the new command without any pre-configured scope.",
"type": "string",
"enum": [
"image:deny-new"
]
},
{
"description": "image:deny-rgba -> Denies the rgba command without any pre-configured scope.",
"type": "string",
"enum": [
"image:deny-rgba"
]
},
{
"description": "image:deny-width -> Denies the width command without any pre-configured scope.",
"type": "string",
"enum": [
"image:deny-width"
]
},
{
"description": "menu:default -> Default permissions for the plugin.",
"type": "string",

View File

@ -11,6 +11,13 @@
}
]
},
{
"description": "A list of capabilities.",
"type": "array",
"items": {
"$ref": "#/definitions/Capability"
}
},
{
"description": "A list of capabilities.",
"type": "object",
@ -34,8 +41,7 @@
"type": "object",
"required": [
"identifier",
"permissions",
"windows"
"permissions"
],
"properties": {
"identifier": {
@ -86,14 +92,10 @@
},
"platforms": {
"description": "Target platforms this capability applies. By default all platforms are affected by this capability.",
"default": [
"linux",
"macOS",
"windows",
"android",
"iOS"
"type": [
"array",
"null"
],
"type": "array",
"items": {
"$ref": "#/definitions/Target"
}
@ -108,7 +110,7 @@
],
"properties": {
"urls": {
"description": "Remote domains this capability refers to. Can use glob patterns.",
"description": "Remote domains this capability refers to using the [URLPattern standard](https://urlpattern.spec.whatwg.org/).\n\n# Examples\n\n- \"https://*.mydomain.dev\": allows subdomains of mydomain.dev - \"https://mydomain.dev/api/*\": allows any subpath of mydomain.dev/api",
"type": "array",
"items": {
"type": "string"
@ -2236,32 +2238,48 @@
"items": {
"title": "ScopeEntry",
"description": "HTTP scope entry object definition.",
"type": "object",
"required": [
"url"
],
"properties": {
"url": {
"description": "A URL that can be accessed by the webview when using the HTTP APIs. The scoped URL is matched against the request URL using a glob pattern.\n\nExamples:\n\n- \"https://*\" or \"https://**\" : allows all HTTPS urls\n\n- \"https://*.github.com/tauri-apps/tauri\": allows any subdomain of \"github.com\" with the \"tauri-apps/api\" path\n\n- \"https://myapi.service.com/users/*\": allows access to any URLs that begins with \"https://myapi.service.com/users/\"",
"anyOf": [
{
"description": "A URL that can be accessed by the webview when using the HTTP APIs. Wildcards can be used following the URL pattern standard.\n\nSee [the URL Pattern spec](https://urlpattern.spec.whatwg.org/) for more information.\n\nExamples:\n\n- \"https://*\" : allows all HTTPS origin on port 443\n\n- \"https://*:*\" : allows all HTTPS origin on any port\n\n- \"https://*.github.com/tauri-apps/tauri\": allows any subdomain of \"github.com\" with the \"tauri-apps/api\" path\n\n- \"https://myapi.service.com/users/*\": allows access to any URLs that begins with \"https://myapi.service.com/users/\"",
"type": "string"
},
{
"type": "object",
"required": [
"url"
],
"properties": {
"url": {
"description": "A URL that can be accessed by the webview when using the HTTP APIs. Wildcards can be used following the URL pattern standard.\n\nSee [the URL Pattern spec](https://urlpattern.spec.whatwg.org/) for more information.\n\nExamples:\n\n- \"https://*\" : allows all HTTPS origin on port 443\n\n- \"https://*:*\" : allows all HTTPS origin on any port\n\n- \"https://*.github.com/tauri-apps/tauri\": allows any subdomain of \"github.com\" with the \"tauri-apps/api\" path\n\n- \"https://myapi.service.com/users/*\": allows access to any URLs that begins with \"https://myapi.service.com/users/\"",
"type": "string"
}
}
}
}
]
}
},
"deny": {
"items": {
"title": "ScopeEntry",
"description": "HTTP scope entry object definition.",
"type": "object",
"required": [
"url"
],
"properties": {
"url": {
"description": "A URL that can be accessed by the webview when using the HTTP APIs. The scoped URL is matched against the request URL using a glob pattern.\n\nExamples:\n\n- \"https://*\" or \"https://**\" : allows all HTTPS urls\n\n- \"https://*.github.com/tauri-apps/tauri\": allows any subdomain of \"github.com\" with the \"tauri-apps/api\" path\n\n- \"https://myapi.service.com/users/*\": allows access to any URLs that begins with \"https://myapi.service.com/users/\"",
"anyOf": [
{
"description": "A URL that can be accessed by the webview when using the HTTP APIs. Wildcards can be used following the URL pattern standard.\n\nSee [the URL Pattern spec](https://urlpattern.spec.whatwg.org/) for more information.\n\nExamples:\n\n- \"https://*\" : allows all HTTPS origin on port 443\n\n- \"https://*:*\" : allows all HTTPS origin on any port\n\n- \"https://*.github.com/tauri-apps/tauri\": allows any subdomain of \"github.com\" with the \"tauri-apps/api\" path\n\n- \"https://myapi.service.com/users/*\": allows access to any URLs that begins with \"https://myapi.service.com/users/\"",
"type": "string"
},
{
"type": "object",
"required": [
"url"
],
"properties": {
"url": {
"description": "A URL that can be accessed by the webview when using the HTTP APIs. Wildcards can be used following the URL pattern standard.\n\nSee [the URL Pattern spec](https://urlpattern.spec.whatwg.org/) for more information.\n\nExamples:\n\n- \"https://*\" : allows all HTTPS origin on port 443\n\n- \"https://*:*\" : allows all HTTPS origin on any port\n\n- \"https://*.github.com/tauri-apps/tauri\": allows any subdomain of \"github.com\" with the \"tauri-apps/api\" path\n\n- \"https://myapi.service.com/users/*\": allows access to any URLs that begins with \"https://myapi.service.com/users/\"",
"type": "string"
}
}
}
}
]
}
}
}
@ -4762,6 +4780,97 @@
"http:deny-fetch-send"
]
},
{
"description": "image:default -> Default permissions for the plugin.",
"type": "string",
"enum": [
"image:default"
]
},
{
"description": "image:allow-from-bytes -> Enables the from_bytes command without any pre-configured scope.",
"type": "string",
"enum": [
"image:allow-from-bytes"
]
},
{
"description": "image:allow-from-path -> Enables the from_path command without any pre-configured scope.",
"type": "string",
"enum": [
"image:allow-from-path"
]
},
{
"description": "image:allow-height -> Enables the height command without any pre-configured scope.",
"type": "string",
"enum": [
"image:allow-height"
]
},
{
"description": "image:allow-new -> Enables the new command without any pre-configured scope.",
"type": "string",
"enum": [
"image:allow-new"
]
},
{
"description": "image:allow-rgba -> Enables the rgba command without any pre-configured scope.",
"type": "string",
"enum": [
"image:allow-rgba"
]
},
{
"description": "image:allow-width -> Enables the width command without any pre-configured scope.",
"type": "string",
"enum": [
"image:allow-width"
]
},
{
"description": "image:deny-from-bytes -> Denies the from_bytes command without any pre-configured scope.",
"type": "string",
"enum": [
"image:deny-from-bytes"
]
},
{
"description": "image:deny-from-path -> Denies the from_path command without any pre-configured scope.",
"type": "string",
"enum": [
"image:deny-from-path"
]
},
{
"description": "image:deny-height -> Denies the height command without any pre-configured scope.",
"type": "string",
"enum": [
"image:deny-height"
]
},
{
"description": "image:deny-new -> Denies the new command without any pre-configured scope.",
"type": "string",
"enum": [
"image:deny-new"
]
},
{
"description": "image:deny-rgba -> Denies the rgba command without any pre-configured scope.",
"type": "string",
"enum": [
"image:deny-rgba"
]
},
{
"description": "image:deny-width -> Denies the width command without any pre-configured scope.",
"type": "string",
"enum": [
"image:deny-width"
]
},
{
"description": "menu:default -> Default permissions for the plugin.",
"type": "string",

View File

@ -171,43 +171,37 @@ pub async fn publish(
}
#[tauri::command]
pub async fn repost(id: &str, pubkey: &str, state: State<'_, Nostr>) -> Result<EventId, ()> {
pub async fn repost(raw: &str, state: State<'_, Nostr>) -> Result<EventId, String> {
let client = &state.client;
let public_key = PublicKey::from_str(pubkey).unwrap();
let event_id = EventId::from_hex(id).unwrap();
let event = Event::from_json(raw).unwrap();
let event = client
.repost_event(event_id, public_key)
.await
.expect("Repost failed");
Ok(event)
if let Ok(event_id) = client.repost(&event, None).await {
Ok(event_id)
} else {
Err("Repost failed".into())
}
}
#[tauri::command]
pub async fn upvote(id: &str, pubkey: &str, state: State<'_, Nostr>) -> Result<EventId, ()> {
pub async fn upvote(raw: &str, state: State<'_, Nostr>) -> Result<EventId, String> {
let client = &state.client;
let public_key = PublicKey::from_str(pubkey).unwrap();
let event_id = EventId::from_hex(id).unwrap();
let event = Event::from_json(raw).unwrap();
let event = client
.like(event_id, public_key)
.await
.expect("Upvote failed");
Ok(event)
if let Ok(event_id) = client.like(&event).await {
Ok(event_id)
} else {
Err("Upvote failed".into())
}
}
#[tauri::command]
pub async fn downvote(id: &str, pubkey: &str, state: State<'_, Nostr>) -> Result<EventId, ()> {
pub async fn downvote(raw: &str, state: State<'_, Nostr>) -> Result<EventId, String> {
let client = &state.client;
let public_key = PublicKey::from_str(pubkey).unwrap();
let event_id = EventId::from_hex(id).unwrap();
let event = Event::from_json(raw).unwrap();
let event = client
.dislike(event_id, public_key)
.await
.expect("Downvote failed");
Ok(event)
if let Ok(event_id) = client.dislike(&event).await {
Ok(event_id)
} else {
Err("Downvote failed".into())
}
}

View File

@ -161,7 +161,7 @@ pub fn event_to_bech32(id: &str, relays: Vec<String>) -> Result<String, ()> {
#[tauri::command]
pub fn user_to_bech32(key: &str, relays: Vec<String>) -> Result<String, ()> {
let pubkey = PublicKey::from_str(key).unwrap();
let profile = Nip19Profile::new(pubkey, relays);
let profile = Nip19Profile::new(pubkey, relays).unwrap();
Ok(profile.to_bech32().unwrap())
}