diff --git a/GEMINI.md b/GEMINI.md new file mode 100644 index 0000000..adb1402 --- /dev/null +++ b/GEMINI.md @@ -0,0 +1,19 @@ +# Dockmark - Self-hosted personal bookmark, workspace, and browser command launcher + +TypeScript ^7.0.2 + React ^19.2.8 + Vite ^8.2.2 + Cloudflare Workers & D1 (Wrangler 4.131.1, @cloudflare/vite-plugin ^1.54.7) + WXT ^0.21.4 + + +apps/ - Deployable web app, Cloudflare Worker API, and browser extensions (2 subdirectories: web/, extension/) +packages/ - Shared domain contracts, settings normalization, i18n, search, and URL policy (1 subdirectory: core/) +scripts/ - Release packaging, Cloudflare deploy/migration helpers, and Chromium smoke suites (14 scripts) +docs/ - Architecture, API, security, roadmap, and Firefox validation specifications (1 subdirectory: brand/) + + + +package.json - npm workspace root scripts for dev, build, typecheck, extension packaging, D1 migrations, and smoke tests +tsconfig.base.json - Strict ES2022 bundler TypeScript configuration (strict, exactOptionalPropertyTypes, verbatimModuleSyntax, noUncheckedIndexedAccess) +wrangler.jsonc - Cloudflare Workers entry (apps/web/worker/router.ts), SPA asset serving, and D1 database binding (DB) +.editorconfig - Cross-editor indentation, charset, and newline formatting rules + + +[PROTOCOL]: Update this header on change, then check GEMINI.md diff --git a/README.md b/README.md index ddcb91e..13f0ddf 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,14 @@ Dockmark is web-first: bookmarks, reusable Workspaces, temporary Sessions and co The Web app resolves the favicon dynamically so it follows the active System / Light / Dark appearance. The static SVG above documents the canonical mark: dark mode uses the `#0a0f0c` Dockmark surface with the soft green mark, while light mode uses the paired `#f4f7f5` surface with dark green ink. -> Status: **v0.9.0** — reviewed page metadata, server-side public URL health checks, redirect review, conservative cleanup, persisted health history and extension-only local/private URL checks with explicit per-host permission are implemented. Browser sync remains review-gated: no silent background bookmark mutation. +> Status: **v1.6.0** — bilingual **English (`en`) & Simplified Chinese (`zh-CN`)** localization synced across Web, Extension Popup, New Tab, and AI organization, paired with a compact tool-grade UI overhaul (Spotlight launcher dashboard, category/collection filter pills, state-aware 3-tab extension workbench with searchable Open Tabs, reviewed capture Inbox, Smart Collections, Duplicate Review, Change Journal, and Firefox MV3 support). Browser sync remains review-gated: no silent background bookmark mutation. + +## Bilingual UI & Redesigned Workspace (v1.6.0) + +- **English (`en`) & Simplified Chinese (`zh-CN`)**: Choose `System / English / 简体中文` in **Settings → Appearance & Language** (`外观与语言`), or switch in one click from the Web utility bar, Public Page header, Extension Popup settings drawer, or New Tab topbar. Private workspace preferences sync via `/api/settings/appearance` (`dockmarkLocaleV1`), while the Public Page (`/`) keeps visitor language local (`dockmarkPublicLocaleV1`) without mutating owner data. +- **Locale-aware AI Organization**: `/api/ai/organize` follows the active UI language (`en` or `zh-CN`) so suggested descriptions and tags match your workspace locale while preserving recognizable product and repository names. +- **Compact High-Efficiency UI**: Both Web Launcher (`/app`) and local-first New Tab focus immediately on the Spotlight command bar (`!g` Search · `@` Smart Collection · `#` Tag), paired with one-click Category/Collection filter pills, favicon/monogram bookmark cards, and launchable Workspace cards. +- **State-Aware Extension Workbench**: The 384px Popup transitions from a focused two-step connect/pair wizard to a 3-tab daily workbench (**Capture** with searchable Open Tabs, **Multi-Tab** reviewed capture, and **Sessions**) with Theme/Language controls tucked inside the collapsible settings drawer. ## Deploy to Cloudflare diff --git a/apps/extension/GEMINI.md b/apps/extension/GEMINI.md new file mode 100644 index 0000000..d6c1057 --- /dev/null +++ b/apps/extension/GEMINI.md @@ -0,0 +1,40 @@ +# apps/extension/ +> L2 | Parent: ../../GEMINI.md + +Member list +package.json: Extension workspace package manifest (`@dockmark/extension` v1.6.0), WXT build/zip scripts for Chrome, New Tab variant, and Firefox MV3. +wxt.config.ts: WXT MV3 manifest generator for Chrome and Firefox; sets `default_locale: "en"`, localized `__MSG_*__` descriptions, optional `bookmarks`/host permissions, `Alt+Shift+D` command, and `d` omnibox keyword. +tsconfig.json: TypeScript compiler configuration extending `.wxt/tsconfig.json`. +entrypoints/background.ts: MV3 service worker handling Web bridge registration, tab activation, Workspace/Session restore, native bookmark sync/writeback, and local health dispatch. +entrypoints/popup/index.html: HTML shell for the 384px extension popup workbench. +entrypoints/popup/main.tsx: State-aware React 19 popup workbench with header status pill, setup wizard / 3-tab daily segmented views (Capture + searchable Open Tabs, Multi-Tab, Sessions), and settings drawer toggle. +entrypoints/popup/api.ts: Popup domain types, storage keys, URL/monogram helpers, Bearer-authenticated `requestJson`, and best-effort remote appearance/locale sync. +entrypoints/popup/OpenTabsPanel.tsx: Real-time filterable Open Tabs list with host monograms, `Current`/`Switch` pills, and keyboard navigation across all open tabs. +entrypoints/popup/SessionsPanel.tsx: Sessions tab view for saving the current window as a cloud Session and restoring recent cloud Sessions. +entrypoints/popup/SetupWizard.tsx: Two-step onboarding card for connecting the Dockmark server origin and exchanging a one-time pairing code. +entrypoints/popup/SettingsDrawer.tsx: Collapsible settings view housing Theme/Language segmented controls, server reconnect, device unpair, and optional native bookmarks toggle. +entrypoints/popup/ReviewedCapture.tsx: Multi-tab capture review panel with normalized URL dedup summary (`New`/`Existing`/`Repeated`), batch selection, and Inbox save. +entrypoints/popup/style.css: Compact dark/light forest-sage styling for the 384px popup workbench. +entrypoints/local-health-permission/index.html: HTML shell for the single-host local health permission prompt. +entrypoints/local-health-permission/main.ts: Scoped local/private hostname permission prompt with light/dark theme detection and EN/zh-CN localization. +entrypoints/local-health-permission/style.css: Dark/light forest-sage styling for the local health permission page. +lib/ext-locale.ts: Shared extension theme (`dockmarkAppearanceV1`) and locale (`dockmarkLocaleV1`) persistence, DOM application, and `browser.storage.local` reactive sync built on `@dockmark/core`. +lib/local-health.ts: Local/private bookmark HTTP probe runner that gates host checks behind single-hostname `optional_host_permissions`. +lib/launcher-access.ts: Global `Alt+Shift+D` launcher opener and `d + Space` omnibox search over cached local snapshots. +public/dockmark-bridge.js: Content script bridging trusted Dockmark Web pages to `background.ts` via `window.postMessage`. +public/_locales/en/messages.json: English MV3 manifest localization catalog (`extDescription`, `cmdOpenLauncher`, `newtabDescription`). +public/_locales/zh_CN/messages.json: Simplified Chinese MV3 manifest localization catalog (`extDescription`, `cmdOpenLauncher`, `newtabDescription`). +public/newtab.html: Local-first New Tab launcher page with compact topbar, Spotlight command bar, syntax hints, filterable Bookmarks panel, and Workspaces panel. +public/newtab.css: Compact dark/light forest-sage styling for the New Tab launcher, domain monograms, filter pills, and workspace mode indicators. +public/newtab-theme.js: Head-loaded theme bootstrapper synchronizing `dockmarkAppearanceV1` across `localStorage` and `chrome.storage.local`. +public/newtab-i18n.js: Head-loaded EN/zh-CN localization runtime (`window.dockmarkI18n`) synchronizing `dockmarkLocaleV1` and translating static/dynamic New Tab copy. +public/newtab-auth.js: Fetch wrapper injecting `Authorization: Bearer` for paired `/api/*` requests and routing `#manage` clicks to `/app`. +public/newtab.js: Core New Tab launcher state, snapshot rendering, Category/`@Collection` filter pills, theme/locale quick toggles, and command execution. +public/newtab-library-cache.js: Single-pass cloud refresh override caching bookmarks, tags, Smart Collections, Inbox IDs, Sessions, appearance, and locale atomically. +public/newtab-search.js: Local-first `#tag` filtering, Smart Collection search, and `@Collection` browsing layer over `buildResults`. +public/newtab-ux.js: Bare `!` bang suggestions, Session search/restore, Shift/Ctrl+Enter open modifiers, `/` focus shortcut, and launcher focus messaging. +public/newtab-parity.js: Canonical Web Launcher result ranking, eight-result cap with default Search slot, localized result-kind badges, and Escape-to-blur. +public/newtab-icon.svg: Adaptive light/dark `D·` SVG favicon for extension pages. +public/icons/: Packaged PNG extension icons (`dockmark-16.png`, `dockmark-32.png`, `dockmark-48.png`, `dockmark-128.png`). + +[PROTOCOL]: Update this header on change, then check GEMINI.md diff --git a/apps/extension/entrypoints/local-health-permission/index.html b/apps/extension/entrypoints/local-health-permission/index.html index ca22396..ce248df 100644 --- a/apps/extension/entrypoints/local-health-permission/index.html +++ b/apps/extension/entrypoints/local-health-permission/index.html @@ -3,7 +3,7 @@ - + Dockmark · Local health access diff --git a/apps/extension/entrypoints/local-health-permission/main.ts b/apps/extension/entrypoints/local-health-permission/main.ts index 1890805..68bb539 100644 --- a/apps/extension/entrypoints/local-health-permission/main.ts +++ b/apps/extension/entrypoints/local-health-permission/main.ts @@ -1,10 +1,29 @@ +/** + * [INPUT]: depends on browser from wxt/browser; depends on LOCAL_HEALTH_PENDING_KEY from ../../lib/local-health; depends on ext-locale helpers from ../../lib/ext-locale + * [OUTPUT]: renders the scoped single-host local health permission prompt with light/dark theme and EN/zh-CN localization + * [POS]: standalone extension entrypoint opened by lib/local-health.ts when a local/private bookmark needs explicit browser host permission + * [PROTOCOL]: Update this header on change, then check GEMINI.md + */ import { browser } from "wxt/browser"; +import { + applyExtensionAppearance, + applyExtensionLocale, + hydrateExtensionPreferences, + readLocalAppearance, + readLocalLocalePreference, + subscribeExtensionPreferences, + tx, + type ResolvedLocale, +} from "../../lib/ext-locale"; import { LOCAL_HEALTH_PENDING_KEY, type PendingLocalHealthPermission, } from "../../lib/local-health"; import "./style.css"; +applyExtensionAppearance(readLocalAppearance(), false); +let currentLocale: ResolvedLocale = applyExtensionLocale(readLocalLocalePreference(), false).locale; + const root = document.getElementById("root"); if (!root) throw new Error("Missing #root"); const appRoot = root; @@ -14,6 +33,14 @@ let busy = false; let message: string | null = null; let error: string | null = null; +function syncDocumentTitle() { + document.title = tx( + currentLocale, + "Dockmark · Local health access", + "Dockmark · 本地健康检查权限", + ); +} + async function closeCurrentTab() { const tab = await browser.tabs.getCurrent(); if (tab?.id != null) await browser.tabs.remove(tab.id); @@ -21,29 +48,53 @@ async function closeCurrentTab() { } function render() { - appRoot.innerHTML = ""; + syncDocumentTitle(); + appRoot.replaceChildren(); + const main = document.createElement("main"); main.className = "permission-shell"; const card = document.createElement("section"); card.className = "permission-card"; - const eyebrow = document.createElement("p"); + + const brandBar = document.createElement("div"); + brandBar.className = "brand-bar"; + const mark = document.createElement("span"); + mark.className = "brand-mark"; + mark.textContent = "D·"; + const brandName = document.createElement("strong"); + brandName.textContent = "Dockmark"; + const eyebrow = document.createElement("span"); eyebrow.className = "eyebrow"; - eyebrow.textContent = "LOCAL HEALTH CHECK"; + eyebrow.textContent = tx(currentLocale, "Local health check", "本地健康检查"); + brandBar.append(mark, brandName, eyebrow); + const title = document.createElement("h1"); - title.textContent = pending ? "Allow this local host?" : "No local host is waiting."; + title.textContent = pending + ? tx(currentLocale, "Allow this local host?", "允许访问此本地主机?") + : tx(currentLocale, "No local host is waiting.", "当前没有待授权的本地主机。"); + const intro = document.createElement("p"); intro.className = "intro"; intro.textContent = pending - ? "Dockmark requests access only to the exact local hostname needed for the bookmark you chose to check. It does not request access to every website." - : "Return to Dockmark Settings → Metadata & Health and choose Check locally on a local-only bookmark."; - card.append(eyebrow, title, intro); + ? tx( + currentLocale, + "Dockmark requests access only to the exact local hostname needed for the bookmark you chose to check. It does not request access to every website.", + "Dockmark 仅向浏览器申请访问你选择检查的这一个本地主机名,不会请求访问所有网站。", + ) + : tx( + currentLocale, + "Return to Dockmark Settings → Metadata & Health and choose Check locally on a local-only bookmark.", + "请返回 Dockmark 设置 → 元数据与健康检查,在仅本地可访问的书签上选择“本地检查”。", + ); + + card.append(brandBar, title, intro); if (pending) { const host = document.createElement("div"); host.className = "host-card"; const label = document.createElement("small"); - label.textContent = "Requested host permission"; + label.textContent = tx(currentLocale, "Requested host permission", "申请的主机权限"); const strong = document.createElement("strong"); strong.textContent = pending.pattern; const url = document.createElement("span"); @@ -53,29 +104,40 @@ function render() { const privacy = document.createElement("p"); privacy.className = "privacy-note"; - privacy.textContent = "The permission is granted by the browser to this extension. Dockmark's Worker still never fetches local/private URLs."; + privacy.textContent = tx( + currentLocale, + "Granted by your browser to this extension only. Dockmark's Worker never fetches local or private URLs.", + "此权限仅由浏览器授予当前扩展,Dockmark 云端 Worker 始终不会请求本地或内网地址。", + ); card.append(privacy); const actions = document.createElement("div"); actions.className = "actions"; const cancel = document.createElement("button"); + cancel.type = "button"; cancel.className = "secondary"; - cancel.textContent = "Cancel"; + cancel.textContent = tx(currentLocale, "Cancel", "取消"); cancel.disabled = busy; cancel.addEventListener("click", () => void cancelPending()); + const allow = document.createElement("button"); + allow.type = "button"; allow.className = "primary"; - allow.textContent = busy ? "Waiting for browser…" : "Allow this host"; + allow.textContent = busy + ? tx(currentLocale, "Waiting for browser…", "等待浏览器确认…") + : tx(currentLocale, "Allow this host", "允许此主机"); allow.disabled = busy; allow.addEventListener("click", () => void grantPending()); + actions.append(cancel, allow); card.append(actions); } else { const actions = document.createElement("div"); actions.className = "actions"; const close = document.createElement("button"); + close.type = "button"; close.className = "primary"; - close.textContent = "Close"; + close.textContent = tx(currentLocale, "Close", "关闭"); close.addEventListener("click", () => void closeCurrentTab()); actions.append(close); card.append(actions); @@ -96,30 +158,42 @@ async function loadPending() { const stored = await browser.storage.local.get(LOCAL_HEALTH_PENDING_KEY); const value = stored[LOCAL_HEALTH_PENDING_KEY]; pending = value && typeof value === "object" && !Array.isArray(value) - ? value as PendingLocalHealthPermission + ? (value as PendingLocalHealthPermission) : null; render(); } async function grantPending() { if (!pending || busy) return; + const targetPattern = pending.pattern; busy = true; message = null; error = null; render(); try { - const granted = await browser.permissions.request({ origins: [pending.pattern] }); + // Keep permissions.request synchronous from the click gesture with no await before it. + const granted = await browser.permissions.request({ origins: [targetPattern] }); if (!granted) { - error = "The browser did not grant this host permission."; + error = tx( + currentLocale, + "The browser did not grant this host permission.", + "浏览器未授予此主机权限。", + ); return; } await browser.storage.local.remove(LOCAL_HEALTH_PENDING_KEY); await browser.runtime.sendMessage({ type: "dockmark:local-health-permission-updated" }).catch(() => undefined); pending = null; - message = "Host access granted. Return to Dockmark and run Check locally again."; + message = tx( + currentLocale, + "Host access granted. Return to Dockmark and run Check locally again.", + "已授予主机访问权限。请返回 Dockmark 重新运行本地检查。", + ); window.setTimeout(() => void closeCurrentTab(), 900); } catch (caught) { - error = caught instanceof Error ? caught.message : "Could not grant host permission."; + error = caught instanceof Error + ? caught.message + : tx(currentLocale, "Could not grant host permission.", "无法授予主机权限。"); } finally { busy = false; render(); @@ -130,16 +204,29 @@ async function cancelPending() { if (busy) return; await browser.storage.local.remove(LOCAL_HEALTH_PENDING_KEY); pending = null; - message = "Request cancelled."; + message = tx(currentLocale, "Request cancelled.", "已取消授权请求。"); render(); window.setTimeout(() => void closeCurrentTab(), 350); } +subscribeExtensionPreferences({ + onLocale: (_pref, locale) => { + currentLocale = locale; + render(); + }, +}); + browser.storage.onChanged.addListener((changes, areaName) => { if (areaName === "local" && changes[LOCAL_HEALTH_PENDING_KEY]) void loadPending(); }); -void loadPending().catch((caught) => { - error = caught instanceof Error ? caught.message : "Could not load the pending host permission."; +void (async () => { + const hydrated = await hydrateExtensionPreferences(); + currentLocale = hydrated.locale; + await loadPending(); +})().catch((caught) => { + error = caught instanceof Error + ? caught.message + : tx(currentLocale, "Could not load the pending host permission.", "无法加载待授权的主机权限。"); render(); }); diff --git a/apps/extension/entrypoints/local-health-permission/style.css b/apps/extension/entrypoints/local-health-permission/style.css index a710542..eac6867 100644 --- a/apps/extension/entrypoints/local-health-permission/style.css +++ b/apps/extension/entrypoints/local-health-permission/style.css @@ -1,55 +1,263 @@ :root { - color-scheme: dark; + color-scheme: light dark; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; --dm-bg: #0a0f0c; --dm-surface: #0f1512; --dm-surface-raised: #121915; --dm-surface-hover: #17201b; + --dm-surface-selected: #1d2a23; --dm-border: #26302b; --dm-border-strong: #34403a; --dm-text: #edf3ef; --dm-text-soft: #a9b4ad; - --dm-text-muted: #75817a; + --dm-text-muted: #84918a; --dm-accent: #91bc9f; --dm-accent-strong: #b8e0c5; - --dm-focus-ring: rgba(145, 188, 159, .16); + --dm-focus-ring: rgba(145, 188, 159, .18); --dm-success-border: #355442; --dm-success-bg: #101a14; --dm-success-text: #a9d1b5; --dm-danger-border: #5a3734; --dm-danger-bg: #211413; - --dm-danger-text: #d4a09c; + --dm-danger-text: #d7a09d; + --dm-shadow: 0 20px 64px rgba(0, 0, 0, .36); background: var(--dm-bg); color: var(--dm-text); } + * { box-sizing: border-box; } ::selection { color: #f6fbf8; background: #315f47; } + body { margin: 0; min-width: 320px; min-height: 100vh; - background: radial-gradient(circle at 50% 0%, rgba(99,159,126,.14), transparent 32rem), var(--dm-bg); + background: radial-gradient(circle at 50% 0%, rgba(99, 159, 126, .12), transparent 28rem), var(--dm-bg); } + button { font: inherit; } button:focus-visible { outline: 2px solid var(--dm-accent); outline-offset: 2px; } -.permission-shell { display: grid; place-items: center; min-height: 100vh; padding: 32px; } -.permission-card { width: min(560px, 100%); padding: 28px; border: 1px solid var(--dm-border); border-radius: 22px; background: rgba(15,21,18,.96); box-shadow: 0 24px 90px rgba(0,0,0,.34); } -.eyebrow { margin: 0 0 10px; color: var(--dm-accent); font-size: 10px; font-weight: 750; letter-spacing: .16em; } -h1 { margin: 0 0 12px; font-size: clamp(30px, 6vw, 48px); line-height: 1.02; letter-spacing: -.045em; } -.intro, .privacy-note { color: var(--dm-text-muted); font-size: 13px; line-height: 1.65; } -.host-card { display: grid; gap: 5px; margin: 22px 0 12px; padding: 15px; border: 1px solid var(--dm-border-strong); border-radius: 14px; background: var(--dm-surface); } -.host-card small { color: var(--dm-text-muted); font-size: 9px; text-transform: uppercase; letter-spacing: .09em; } -.host-card strong { color: var(--dm-accent-strong); font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; } -.host-card span { color: var(--dm-text-soft); font-size: 11px; overflow-wrap: anywhere; } -.privacy-note { margin: 12px 0 0; } -.actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 24px; } -.primary, .secondary { min-height: 40px; padding: 0 14px; border-radius: 10px; cursor: pointer; transition: border-color .12s ease, background .12s ease, color .12s ease; } -.primary { border: 1px solid #7ea88d; background: var(--dm-accent); color: #0a100d; font-weight: 700; } -.primary:hover:not(:disabled) { border-color: #a7cfb3; background: #a1c9ad; } -.secondary { border: 1px solid var(--dm-border-strong); background: var(--dm-surface-hover); color: #c0cbc5; } -.secondary:hover:not(:disabled) { border-color: #4e6859; background: #1d2a23; color: var(--dm-text); } -.primary:disabled, .secondary:disabled { opacity: .5; cursor: default; } -.notice { margin-top: 18px; padding: 11px 13px; border-radius: 10px; font-size: 12px; line-height: 1.5; } -.notice.success { border: 1px solid var(--dm-success-border); background: var(--dm-success-bg); color: var(--dm-success-text); } -.notice.error { border: 1px solid var(--dm-danger-border); background: var(--dm-danger-bg); color: var(--dm-danger-text); } -@media (max-width: 520px) { .permission-shell { padding: 16px; } .permission-card { padding: 22px; } .actions { flex-direction: column-reverse; } .actions button { width: 100%; } } + +.permission-shell { + display: grid; + place-items: center; + min-height: 100vh; + padding: 24px; +} + +.permission-card { + width: min(480px, 100%); + padding: 24px; + border: 1px solid var(--dm-border); + border-radius: 16px; + background: var(--dm-surface-raised); + box-shadow: var(--dm-shadow); +} + +.brand-bar { + display: flex; + align-items: center; + gap: 8px; + margin-bottom: 16px; +} + +.brand-mark { + display: grid; + place-items: center; + width: 24px; + height: 24px; + border: 1px solid var(--dm-border-strong); + border-radius: 7px; + background: var(--dm-surface-hover); + color: var(--dm-accent-strong); + font-size: 11px; + font-weight: 760; + letter-spacing: -.08em; +} + +.brand-bar strong { + font-size: 13px; + font-weight: 650; + letter-spacing: -.015em; +} + +.eyebrow { + margin-left: auto; + padding: 3px 8px; + border: 1px solid var(--dm-border); + border-radius: 999px; + background: var(--dm-surface); + color: var(--dm-accent); + font-size: 10px; + font-weight: 620; + letter-spacing: .04em; +} + +h1 { + margin: 0 0 8px; + font-size: 22px; + font-weight: 680; + line-height: 1.2; + letter-spacing: -.03em; +} + +.intro, +.privacy-note { + margin: 0; + color: var(--dm-text-muted); + font-size: 12px; + line-height: 1.55; +} + +.host-card { + display: grid; + gap: 4px; + margin: 16px 0 12px; + padding: 12px 14px; + border: 1px solid var(--dm-border-strong); + border-radius: 11px; + background: var(--dm-surface); +} + +.host-card small { + color: var(--dm-text-muted); + font-size: 10px; + font-weight: 600; + letter-spacing: .04em; + text-transform: uppercase; +} + +.host-card strong { + color: var(--dm-accent-strong); + font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; + overflow-wrap: anywhere; +} + +.host-card span { + color: var(--dm-text-soft); + font-size: 11px; + overflow-wrap: anywhere; +} + +.actions { + display: flex; + justify-content: flex-end; + gap: 8px; + margin-top: 18px; +} + +.primary, +.secondary { + min-height: 36px; + padding: 0 14px; + border-radius: 9px; + font-size: 12px; + cursor: pointer; + transition: border-color .12s ease, background .12s ease, color .12s ease; +} + +.primary { + border: 1px solid #7ea88d; + background: var(--dm-accent); + color: #0a100d; + font-weight: 650; +} + +.primary:hover:not(:disabled) { + border-color: #a7cfb3; + background: #a1c9ad; +} + +.secondary { + border: 1px solid var(--dm-border-strong); + background: var(--dm-surface-hover); + color: var(--dm-text-soft); +} + +.secondary:hover:not(:disabled) { + border-color: #4e6859; + background: var(--dm-surface-selected); + color: var(--dm-text); +} + +.primary:disabled, +.secondary:disabled { + opacity: .48; + cursor: default; +} + +.notice { + margin-top: 14px; + padding: 9px 11px; + border-radius: 9px; + font-size: 11px; + line-height: 1.45; +} + +.notice.success { + border: 1px solid var(--dm-success-border); + background: var(--dm-success-bg); + color: var(--dm-success-text); +} + +.notice.error { + border: 1px solid var(--dm-danger-border); + background: var(--dm-danger-bg); + color: var(--dm-danger-text); +} + +html[data-theme="light"] { + --dm-bg: #f4f7f5; + --dm-surface: #edf2ef; + --dm-surface-raised: #ffffff; + --dm-surface-hover: #e7efea; + --dm-surface-selected: #dceae1; + --dm-border: #d1ddd6; + --dm-border-strong: #b7c9bf; + --dm-text: #173126; + --dm-text-soft: #465e53; + --dm-text-muted: #5c7066; + --dm-accent: #4f8063; + --dm-accent-strong: #315f47; + --dm-focus-ring: rgba(79, 128, 99, .14); + --dm-success-border: #a8cbb5; + --dm-success-bg: #eef8f1; + --dm-success-text: #315f47; + --dm-danger-border: #e1b8b4; + --dm-danger-bg: #fff3f2; + --dm-danger-text: #9f4e49; + --dm-shadow: 0 20px 64px rgba(31, 56, 44, .1); +} + +html[data-theme="light"] body { + background: radial-gradient(circle at 50% 0%, rgba(79, 128, 99, .1), transparent 28rem), var(--dm-bg); +} + +html[data-theme="light"] .primary { + border-color: #4f8063; + color: #f8fffa; +} + +html[data-theme="light"] .primary:hover:not(:disabled) { + border-color: #3f6d52; + background: #427055; +} + +html[data-theme="light"] .secondary { + border-color: var(--dm-border); + background: #ffffff; + color: var(--dm-text-soft); +} + +html[data-theme="light"] .secondary:hover:not(:disabled) { + border-color: #9ec0ac; + background: var(--dm-surface-selected); + color: var(--dm-text); +} + +@media (max-width: 520px) { + .permission-shell { padding: 14px; } + .permission-card { padding: 18px; } + .actions { flex-direction: column-reverse; } + .actions button { width: 100%; } +} diff --git a/apps/extension/entrypoints/popup/OpenTabsPanel.tsx b/apps/extension/entrypoints/popup/OpenTabsPanel.tsx new file mode 100644 index 0000000..2030c34 --- /dev/null +++ b/apps/extension/entrypoints/popup/OpenTabsPanel.tsx @@ -0,0 +1,111 @@ +/** + * [INPUT]: depends on React hooks; depends on browser from wxt/browser; depends on TabSummary, hostLabel, hostMonogram from ./api; depends on tx and ResolvedLocale from ../../lib/ext-locale + * [OUTPUT]: exports OpenTabsPanel component providing real-time filterable open-tab switching with keyboard navigation + * [POS]: searchable open-tabs view rendered in Capture tab and local-only mode of apps/extension/entrypoints/popup + * [PROTOCOL]: Update this header on change, then check GEMINI.md + */ +import { useEffect, useMemo, useState, type KeyboardEvent } from "react"; +import { browser } from "wxt/browser"; +import { tx, type ResolvedLocale } from "../../lib/ext-locale"; +import { hostLabel, hostMonogram, type TabSummary } from "./api"; + +export function OpenTabsPanel({ + tabs, + locale, +}: { + tabs: TabSummary[]; + locale: ResolvedLocale; +}) { + const [query, setQuery] = useState(""); + const [selectedIndex, setSelectedIndex] = useState(0); + + const filteredTabs = useMemo(() => { + const needle = query.trim().toLocaleLowerCase(); + if (!needle) return tabs; + const terms = needle.split(/\s+/).filter(Boolean); + return tabs.filter((tab) => { + const haystack = `${tab.title || ""} ${tab.url || ""}`.toLocaleLowerCase(); + return terms.every((term) => haystack.includes(term)); + }); + }, [tabs, query]); + + useEffect(() => { + setSelectedIndex(0); + }, [query, filteredTabs.length]); + + function activateTab(tab: TabSummary | undefined) { + if (tab?.id == null) return; + void browser.runtime.sendMessage({ type: "dockmark:activate-tab", tabId: tab.id }); + } + + function handleKeyDown(event: KeyboardEvent) { + if (!filteredTabs.length) return; + if (event.key === "ArrowDown") { + event.preventDefault(); + setSelectedIndex((index) => (index + 1) % filteredTabs.length); + } else if (event.key === "ArrowUp") { + event.preventDefault(); + setSelectedIndex((index) => (index - 1 + filteredTabs.length) % filteredTabs.length); + } else if (event.key === "Enter") { + event.preventDefault(); + activateTab(filteredTabs[selectedIndex] ?? filteredTabs[0]); + } else if (event.key === "Escape" && query) { + event.preventDefault(); + setQuery(""); + } + } + + return ( +
+
+ {tx(locale, "Open tabs", "打开的标签页")} + {query.trim() ? `${filteredTabs.length} / ${tabs.length}` : tabs.length} +
+
+ setQuery(event.target.value)} + onKeyDown={handleKeyDown} + placeholder={tx( + locale, + `Filter ${tabs.length} open tabs… (Enter to switch)`, + `筛选 ${tabs.length} 个打开的标签页…(回车切换)`, + )} + aria-label={tx(locale, "Filter open tabs", "筛选打开的标签页")} + /> +
+
+ {filteredTabs.map((tab, index) => ( + + ))} + {!filteredTabs.length && ( +

+ {query.trim() + ? tx(locale, "No matching tabs.", "没有匹配的标签页。") + : tx(locale, "No open tabs found.", "未检测到打开的标签页。")} +

+ )} +
+
+ ); +} diff --git a/apps/extension/entrypoints/popup/ReviewedCapture.tsx b/apps/extension/entrypoints/popup/ReviewedCapture.tsx index 08f1443..d518a5d 100644 --- a/apps/extension/entrypoints/popup/ReviewedCapture.tsx +++ b/apps/extension/entrypoints/popup/ReviewedCapture.tsx @@ -1,79 +1,32 @@ +/** + * [INPUT]: depends on React hooks; depends on browser from wxt/browser; depends on api helpers from ./api; depends on tx and ResolvedLocale from ../../lib/ext-locale + * [OUTPUT]: exports ReviewedCapture component for batch-reviewing and saving open window tabs to Dockmark Inbox + * [POS]: Multi-Tab capture workbench panel inside apps/extension/entrypoints/popup + * [PROTOCOL]: Update this header on change, then check GEMINI.md + */ import { useMemo, useState } from "react"; import { browser } from "wxt/browser"; +import { tx, type ResolvedLocale } from "../../lib/ext-locale"; +import { + apiUrl, + hostLabel, + hostMonogram, + requestJson, + type BatchResponse, + type ReviewItem, + type ReviewResponse, + type SavableTab, +} from "./api"; -const TOKEN_KEY = "dockmarkDeviceToken"; - -type CaptureTab = { - id?: number; - title: string; - url: string; - pinned: boolean; - active: boolean; -}; - -type CaptureBookmark = { - id: string; - title: string; - url: string; - categoryName?: string; - inboxAt?: string; -}; - -type ReviewItem = { - index: number; - title: string; - url: string; - state: "new" | "duplicate" | "selection-duplicate"; - duplicateOf?: number; - duplicateState?: "inbox" | "library"; - bookmark?: CaptureBookmark; -}; - -type ReviewResponse = { - items: ReviewItem[]; -}; - -type BatchResponse = { - result: "batch"; - createdCount: number; - duplicateCount: number; - skippedCount: number; -}; - -class DockmarkRequestError extends Error { - constructor(readonly status: number, message: string) { - super(message); - } -} - -function apiUrl(origin: string, path: string) { - return new URL(path, `${origin}/`).toString(); -} - -function hostLabel(value: string) { - try { - return new URL(value).host; - } catch { - return value; - } -} - -async function requestJson(url: string, init: RequestInit = {}): Promise { - const headers = new Headers(init.headers); - headers.set("accept", "application/json"); - if (init.body) headers.set("content-type", "application/json"); - const stored = await browser.storage.local.get(TOKEN_KEY); - const token = typeof stored[TOKEN_KEY] === "string" ? stored[TOKEN_KEY] : ""; - if (token) headers.set("authorization", `Bearer ${token}`); - const response = await fetch(url, { ...init, headers, cache: "no-store" }); - const body = await response.json().catch(() => ({})) as T & { error?: { message?: string } }; - if (!response.ok) { - throw new DockmarkRequestError(response.status, body.error?.message ?? `Dockmark request failed (${response.status}).`); - } - return body; -} - -export function ReviewedCapture({ serverUrl, tabs }: { serverUrl: string; tabs: CaptureTab[] }) { +export function ReviewedCapture({ + serverUrl, + tabs, + locale, +}: { + serverUrl: string; + tabs: SavableTab[]; + locale: ResolvedLocale; +}) { const [review, setReview] = useState(null); const [selected, setSelected] = useState>(() => new Set()); const [busy, setBusy] = useState(false); @@ -85,7 +38,7 @@ export function ReviewedCapture({ serverUrl, tabs }: { serverUrl: string; tabs: try { dockmarkOrigin = new URL(serverUrl).origin; } catch { - return [] as CaptureTab[]; + return [] as SavableTab[]; } return tabs .filter((tab) => { @@ -99,8 +52,14 @@ export function ReviewedCapture({ serverUrl, tabs }: { serverUrl: string; tabs: }, [serverUrl, tabs]); const newItems = useMemo(() => review?.filter((item) => item.state === "new") ?? [], [review]); - const duplicateCount = useMemo(() => review?.filter((item) => item.state === "duplicate").length ?? 0, [review]); - const repeatedCount = useMemo(() => review?.filter((item) => item.state === "selection-duplicate").length ?? 0, [review]); + const duplicateCount = useMemo( + () => review?.filter((item) => item.state === "duplicate").length ?? 0, + [review], + ); + const repeatedCount = useMemo( + () => review?.filter((item) => item.state === "selection-duplicate").length ?? 0, + [review], + ); const selectedItems = useMemo( () => newItems.filter((item) => selected.has(item.index)), [newItems, selected], @@ -113,7 +72,11 @@ export function ReviewedCapture({ serverUrl, tabs }: { serverUrl: string; tabs: try { await action(); } catch (caught) { - setError(caught instanceof Error ? caught.message : "Something went wrong."); + setError( + caught instanceof Error + ? caught.message + : tx(locale, "Something went wrong.", "操作失败,请重试。"), + ); } finally { setBusy(false); } @@ -121,7 +84,15 @@ export function ReviewedCapture({ serverUrl, tabs }: { serverUrl: string; tabs: async function reviewWindowTabs() { await run(async () => { - if (!reviewableTabs.length) throw new Error("This window has no HTTP/HTTPS tabs outside Dockmark to review."); + if (!reviewableTabs.length) { + throw new Error( + tx( + locale, + "No HTTP/HTTPS tabs outside Dockmark to review.", + "当前窗口没有除 Dockmark 外的可审查网页标签页。", + ), + ); + } const result = await requestJson(apiUrl(serverUrl, "/api/capture/review"), { method: "POST", body: JSON.stringify({ @@ -139,7 +110,9 @@ export function ReviewedCapture({ serverUrl, tabs }: { serverUrl: string; tabs: async function applyReviewedCapture() { await run(async () => { - if (!selectedItems.length) throw new Error("Select at least one new tab before saving."); + if (!selectedItems.length) { + throw new Error(tx(locale, "Select at least one new tab before saving.", "请至少选择一个新标签页再保存。")); + } const result = await requestJson(apiUrl(serverUrl, "/api/capture/batch"), { method: "POST", body: JSON.stringify({ @@ -151,8 +124,16 @@ export function ReviewedCapture({ serverUrl, tabs }: { serverUrl: string; tabs: setSelected(new Set()); setNotice( changedDuringReview - ? `Saved ${result.createdCount} tabs to Inbox; ${changedDuringReview} were skipped after a final duplicate recheck.` - : `Saved ${result.createdCount} reviewed tabs to Dockmark Inbox.`, + ? tx( + locale, + `Saved ${result.createdCount} to Inbox (${changedDuringReview} skipped as duplicates).`, + `已保存 ${result.createdCount} 条到收件箱,跳过 ${changedDuringReview} 条重复项。`, + ) + : tx( + locale, + `Saved ${result.createdCount} tabs to Inbox.`, + `已保存 ${result.createdCount} 个标签页到收件箱。`, + ), ); }); } @@ -171,48 +152,102 @@ export function ReviewedCapture({ serverUrl, tabs }: { serverUrl: string; tabs: } return ( -
+
- Reviewed multi-tab capture - {reviewableTabs.length} eligible + {tx(locale, "Multi-tab capture", "批量收录窗口标签页")} + + {tx(locale, `${reviewableTabs.length} eligible`, `${reviewableTabs.length} 个可收录`)} +
+ {!review ? ( <> -

Review the current window first. Dockmark checks exact normalized URLs without writing anything, then you choose which new tabs are allowed into Inbox.

- ) : ( <>
- {newItems.length} new - {duplicateCount} existing - {repeatedCount} repeated + + {newItems.length} + {tx(locale, "New", "新增")} + + + {duplicateCount} + {tx(locale, "Existing", "已存在")} + + + {repeatedCount} + {tx(locale, "Repeated", "窗口重复")} +
+
- - + + + + {tx(locale, `${selectedItems.length} selected`, `已选 ${selectedItems.length} 项`)} +
+
{review.map((item) => { const selectable = item.state === "new"; const existingLabel = item.duplicateState === "inbox" - ? "Already in Inbox" + ? tx(locale, "In Inbox", "已在收件箱") : item.duplicateState === "library" - ? item.bookmark?.categoryName ?? "Already in library" + ? item.bookmark?.categoryName ?? tx(locale, "In library", "已在书签库") : item.state === "selection-duplicate" - ? `Repeated tab · same as #${(item.duplicateOf ?? 0) + 1}` - : "New"; + ? tx(locale, `Same as #${(item.duplicateOf ?? 0) + 1}`, `与第 ${(item.duplicateOf ?? 0) + 1} 项重复`) + : tx(locale, "New", "新增"); return ( -
+
- - +
)} + {(notice || error) && (
{error ?? notice} - {!error && } + {!error && ( + + )}
)}
diff --git a/apps/extension/entrypoints/popup/SessionsPanel.tsx b/apps/extension/entrypoints/popup/SessionsPanel.tsx new file mode 100644 index 0000000..e384c99 --- /dev/null +++ b/apps/extension/entrypoints/popup/SessionsPanel.tsx @@ -0,0 +1,86 @@ +/** + * [INPUT]: depends on SessionSummary from ./api; depends on tx and ResolvedLocale from ../../lib/ext-locale + * [OUTPUT]: exports SessionsPanel component for saving the active browser window and restoring recent cloud Sessions + * [POS]: Sessions tab panel inside apps/extension/entrypoints/popup + * [PROTOCOL]: Update this header on change, then check GEMINI.md + */ +import { tx, type ResolvedLocale } from "../../lib/ext-locale"; +import type { SessionSummary } from "./api"; + +interface SessionsPanelProps { + locale: ResolvedLocale; + sessionName: string; + savableTabCount: number; + sessions: SessionSummary[]; + busy: boolean; + onSessionNameChange: (value: string) => void; + onSaveWindow: () => void; + onRestoreSession: (session: SessionSummary) => void; +} + +export function SessionsPanel(props: SessionsPanelProps) { + const { locale } = props; + + return ( +
+
+
+ {tx(locale, "Save current window", "保存当前窗口")} + + {tx(locale, `${props.savableTabCount} tabs`, `${props.savableTabCount} 个标签页`)} + +
+
+ props.onSessionNameChange(event.target.value)} + maxLength={120} + aria-label={tx(locale, "Session name", "会话名称")} + /> + +
+
+ +
+
+ {tx(locale, "Recent sessions", "最近会话")} + {props.sessions.length} +
+
+ {props.sessions.map((session) => ( + + ))} + {!props.sessions.length && ( +

{tx(locale, "No cloud sessions yet.", "暂无云端会话。")}

+ )} +
+
+
+ ); +} diff --git a/apps/extension/entrypoints/popup/SettingsDrawer.tsx b/apps/extension/entrypoints/popup/SettingsDrawer.tsx new file mode 100644 index 0000000..a4a2a24 --- /dev/null +++ b/apps/extension/entrypoints/popup/SettingsDrawer.tsx @@ -0,0 +1,212 @@ +/** + * [INPUT]: depends on tx and preference types from ../../lib/ext-locale + * [OUTPUT]: exports SettingsDrawer component for theme, language, server connection, pairing, and native bookmarks permission + * [POS]: collapsible settings panel inside apps/extension/entrypoints/popup + * [PROTOCOL]: Update this header on change, then check GEMINI.md + */ +import { + tx, + type AppearancePreference, + type LocalePreference, + type ResolvedLocale, +} from "../../lib/ext-locale"; + +interface SettingsDrawerProps { + locale: ResolvedLocale; + localePreference: LocalePreference; + appearance: AppearancePreference; + serverUrl: string; + deviceLabel: string; + pairCode: string; + connected: boolean; + paired: boolean; + bookmarkAccess: boolean; + initializing: boolean; + busy: boolean; + onServerUrlChange: (value: string) => void; + onDeviceLabelChange: (value: string) => void; + onPairCodeChange: (value: string) => void; + onConnect: () => void; + onPairDevice: () => void; + onUnpairLocal: () => void; + onToggleBookmarkAccess: () => void; + onSelectAppearance: (value: AppearancePreference) => void; + onSelectLocale: (value: LocalePreference) => void; + onClose: () => void; +} + +const APPEARANCE_OPTIONS: Array<{ value: AppearancePreference; en: string; zh: string }> = [ + { value: "system", en: "System", zh: "跟随系统" }, + { value: "light", en: "Light", zh: "浅色" }, + { value: "dark", en: "Dark", zh: "深色" }, +]; + +const LOCALE_OPTIONS: Array<{ value: LocalePreference; en: string; zh: string }> = [ + { value: "system", en: "System", zh: "跟随浏览器" }, + { value: "en", en: "English", zh: "English" }, + { value: "zh-CN", en: "简体中文", zh: "简体中文" }, +]; + +export function SettingsDrawer(props: SettingsDrawerProps) { + const { locale } = props; + + return ( +
+
+ {tx(locale, "Extension settings", "扩展设置")} + +
+ +
+
+
+ {tx(locale, "Theme", "外观主题")} + {tx(locale, "Syncs with Web & New Tab", "与网页及新标签页同步")} +
+
+ {APPEARANCE_OPTIONS.map((option) => ( + + ))} +
+
+ +
+
+ {tx(locale, "Language", "界面语言")} +
+
+ {LOCALE_OPTIONS.map((option) => ( + + ))} +
+
+
+ +
+
+ {tx(locale, "Dockmark server", "Dockmark 服务器")} + + {props.connected + ? props.paired + ? tx(locale, "Paired", "已配对") + : tx(locale, "Connected", "已连接") + : props.initializing + ? tx(locale, "Checking", "检查中") + : tx(locale, "Local", "仅本地")} + +
+ props.onServerUrlChange(event.target.value)} + placeholder="https://dockmark.example.com" + inputMode="url" + aria-label={tx(locale, "Dockmark Server URL", "Dockmark 服务器地址")} + /> +
+ props.onDeviceLabelChange(event.target.value)} + placeholder={tx(locale, "Main MacBook", "主力设备")} + aria-label={tx(locale, "Device Label", "设备名称")} + /> + +
+ + {props.connected && ( +
+
+ {tx(locale, "Device pairing", "设备配对")} + + {props.paired ? tx(locale, "Active", "已授权") : tx(locale, "Required", "待配对")} + +
+ {props.paired ? ( +
+

+ {tx( + locale, + "Revocable token for launcher cache, Inbox capture, and Sessions.", + "可随时撤销的设备令牌,用于启动台缓存、收件箱收录与会话保存。", + )} +

+ +
+ ) : ( +
+ props.onPairCodeChange(event.target.value.toUpperCase())} + placeholder="ABCD-EFGH-JK" + autoComplete="off" + aria-label={tx(locale, "Pairing Code", "配对码")} + /> + +
+ )} +
+ )} +
+ +
+
+ {tx(locale, "Native bookmarks", "浏览器原生书签")} + + {props.bookmarkAccess ? tx(locale, "Enabled", "已开启") : tx(locale, "Optional", "可选")} + +
+
+

+ {tx( + locale, + "Optional permission for reviewed bookmark import and explicit Web writeback.", + "可选权限:仅用于审查导入浏览器书签,以及你在网页端显式触发的回写。", + )} +

+ +
+
+
+ ); +} diff --git a/apps/extension/entrypoints/popup/SetupWizard.tsx b/apps/extension/entrypoints/popup/SetupWizard.tsx new file mode 100644 index 0000000..f0a5902 --- /dev/null +++ b/apps/extension/entrypoints/popup/SetupWizard.tsx @@ -0,0 +1,102 @@ +/** + * [INPUT]: depends on tx and ResolvedLocale from ../../lib/ext-locale + * [OUTPUT]: exports SetupWizard component guiding server connection and one-time device pairing + * [POS]: onboarding surface in apps/extension/entrypoints/popup shown when the extension is unconnected or unpaired + * [PROTOCOL]: Update this header on change, then check GEMINI.md + */ +import { tx, type ResolvedLocale } from "../../lib/ext-locale"; + +interface SetupWizardProps { + locale: ResolvedLocale; + serverUrl: string; + deviceLabel: string; + pairCode: string; + connected: boolean; + initializing: boolean; + busy: boolean; + onServerUrlChange: (value: string) => void; + onDeviceLabelChange: (value: string) => void; + onPairCodeChange: (value: string) => void; + onConnect: () => void; + onPairDevice: () => void; +} + +export function SetupWizard(props: SetupWizardProps) { + const { locale, connected } = props; + + return ( +
+
+ {tx(locale, "Connect Dockmark", "连接 Dockmark")} + + {tx( + locale, + "Two quick steps to enable Quick Capture, Sessions, and launcher sync.", + "两步完成连接,开启快速收录、会话保存与启动台同步。", + )} + +
+ +
+
+ {connected ? "✓" : "1"} + {tx(locale, "Connect server URL", "连接服务器地址")} + {connected ? tx(locale, "Connected", "已连接") : tx(locale, "Step 1", "步骤 1")} +
+ props.onServerUrlChange(event.target.value)} + placeholder="https://dockmark.example.com" + inputMode="url" + aria-label={tx(locale, "Dockmark Server URL", "Dockmark 服务器地址")} + /> +
+ props.onDeviceLabelChange(event.target.value)} + placeholder={tx(locale, "Main browser", "主力浏览器")} + aria-label={tx(locale, "Device Label", "设备名称")} + /> + +
+
+ +
+
+ 2 + {tx(locale, "Pair this browser", "配对当前浏览器")} + {tx(locale, "Settings → Security", "设置 → 安全")} +
+
+ props.onPairCodeChange(event.target.value.toUpperCase())} + placeholder="ABCD-EFGH-JK" + autoComplete="off" + disabled={!connected || props.busy} + aria-label={tx(locale, "One-time Pairing Code", "一次性配对码")} + /> + +
+
+
+ ); +} diff --git a/apps/extension/entrypoints/popup/api.ts b/apps/extension/entrypoints/popup/api.ts new file mode 100644 index 0000000..5dbd20a --- /dev/null +++ b/apps/extension/entrypoints/popup/api.ts @@ -0,0 +1,161 @@ +/** + * [INPUT]: depends on browser from wxt/browser; depends on AppearancePreference and LocalePreference from ../../lib/ext-locale + * [OUTPUT]: exports popup domain types, storage key constants, URL/monogram helpers, authenticated requestJson, and remote appearance sync + * [POS]: shared API and domain utilities for apps/extension/entrypoints/popup components + * [PROTOCOL]: Update this header on change, then check GEMINI.md + */ +import { browser } from "wxt/browser"; +import type { AppearancePreference, LocalePreference } from "../../lib/ext-locale"; + +export const SERVER_KEY = "dockmarkServerUrl"; +export const DEVICE_KEY = "dockmarkDeviceLabel"; +export const TOKEN_KEY = "dockmarkDeviceToken"; + +export type TabSummary = { + id?: number; + title: string; + url?: string; + pinned: boolean; + active: boolean; +}; + +export type SavableTab = TabSummary & { url: string }; + +export type SessionItem = { + id: string; + title: string; + url: string; + pinned: boolean; + position: number; +}; + +export type SessionSummary = { + id: string; + name: string; + sourceDevice?: string; + createdAt: string; + items: SessionItem[]; +}; + +export type CaptureBookmark = { + id: string; + title: string; + url: string; + categoryId?: string; + categoryName?: string; + inboxAt?: string; +}; + +export type CaptureResult = { + result: "created" | "duplicate"; + bookmark: CaptureBookmark; + duplicateState?: "inbox" | "library"; +}; + +export type ReviewItem = { + index: number; + title: string; + url: string; + state: "new" | "duplicate" | "selection-duplicate"; + duplicateOf?: number; + duplicateState?: "inbox" | "library"; + bookmark?: CaptureBookmark; +}; + +export type ReviewResponse = { + items: ReviewItem[]; +}; + +export type BatchResponse = { + result: "batch"; + createdCount: number; + duplicateCount: number; + skippedCount: number; +}; + +export type RemoteAppearanceResponse = { + settings?: { + preference?: AppearancePreference; + locale?: LocalePreference; + }; +}; + +export class DockmarkRequestError extends Error { + constructor(readonly status: number, message: string) { + super(message); + } +} + +export function normalizeServerUrl(value: string) { + const url = new URL(value.trim()); + if (url.protocol !== "http:" && url.protocol !== "https:") { + throw new Error("Dockmark URL must use HTTP or HTTPS."); + } + return url.origin; +} + +export function hostPattern(origin: string) { + return `${origin}/*`; +} + +export function apiUrl(origin: string, path: string) { + return new URL(path, `${origin}/`).toString(); +} + +export function hostLabel(value: string | undefined) { + if (!value) return ""; + try { + const parsed = new URL(value); + return parsed.host || parsed.protocol.replace(/:$/, ""); + } catch { + return value; + } +} + +export function hostMonogram(value: string | undefined, fallbackTitle?: string) { + const host = hostLabel(value).replace(/^www\./i, ""); + const source = host || fallbackTitle || "D"; + const match = source.match(/[A-Za-z0-9\u4e00-\u9fff]/); + return (match?.[0] ?? "D").toUpperCase(); +} + +export async function requestJson( + url: string, + init: RequestInit = {}, + includeDeviceToken = true, +): Promise { + const headers = new Headers(init.headers); + headers.set("accept", "application/json"); + if (init.body) headers.set("content-type", "application/json"); + if (includeDeviceToken) { + const stored = await browser.storage.local.get(TOKEN_KEY); + const token = typeof stored[TOKEN_KEY] === "string" ? stored[TOKEN_KEY] : ""; + if (token) headers.set("authorization", `Bearer ${token}`); + } + const response = await fetch(url, { ...init, headers, cache: "no-store" }); + const body = (await response.json().catch(() => ({}))) as T & { + error?: { message?: string }; + }; + if (!response.ok) { + throw new DockmarkRequestError( + response.status, + body.error?.message ?? `Dockmark request failed (${response.status}).`, + ); + } + return body; +} + +export async function patchRemoteAppearance( + origin: string, + payload: { preference?: AppearancePreference; locale?: LocalePreference }, +) { + if (!origin) return; + try { + await requestJson(apiUrl(origin, "/api/settings/appearance"), { + method: "PATCH", + body: JSON.stringify(payload), + }); + } catch { + // Cloud appearance sync is best-effort; local storage remains authoritative offline. + } +} diff --git a/apps/extension/entrypoints/popup/main.tsx b/apps/extension/entrypoints/popup/main.tsx index b460369..c579254 100644 --- a/apps/extension/entrypoints/popup/main.tsx +++ b/apps/extension/entrypoints/popup/main.tsx @@ -1,137 +1,76 @@ +/** + * [INPUT]: depends on React 19, browser from wxt/browser, ext-locale helpers from ../../lib/ext-locale, and popup submodules (api, OpenTabsPanel, ReviewedCapture, SessionsPanel, SettingsDrawer, SetupWizard) + * [OUTPUT]: mounts the state-aware Dockmark browser extension popup workbench (384px) with EN/zh-CN localization and light/dark themes + * [POS]: primary popup UI entrypoint in apps/extension/entrypoints/popup + * [PROTOCOL]: Update this header on change, then check GEMINI.md + */ import { StrictMode, useEffect, useMemo, useState } from "react"; import { createRoot } from "react-dom/client"; import { browser } from "wxt/browser"; +import { + applyExtensionAppearance, + applyExtensionLocale, + hydrateExtensionPreferences, + readLocalAppearance, + readLocalLocalePreference, + subscribeExtensionPreferences, + tx, + type AppearancePreference, + type LocalePreference, + type ResolvedLocale, +} from "../../lib/ext-locale"; +import { + DEVICE_KEY, + DockmarkRequestError, + SERVER_KEY, + TOKEN_KEY, + apiUrl, + hostLabel, + hostMonogram, + hostPattern, + normalizeServerUrl, + patchRemoteAppearance, + requestJson, + type CaptureResult, + type RemoteAppearanceResponse, + type SavableTab, + type SessionSummary, + type TabSummary, +} from "./api"; +import { OpenTabsPanel } from "./OpenTabsPanel"; import { ReviewedCapture } from "./ReviewedCapture"; +import { SessionsPanel } from "./SessionsPanel"; +import { SettingsDrawer } from "./SettingsDrawer"; +import { SetupWizard } from "./SetupWizard"; import "./style.css"; -// The popup shares the Dockmark appearance preference with New Tab and Web, so it -// resolves the same storage key instead of staying pinned to dark. -const APPEARANCE_KEY = "dockmarkAppearanceV1"; - -function applyAppearance(preference: string, persist = true) { - const normalized = preference === "light" || preference === "dark" || preference === "system" ? preference : "system"; - const theme = normalized === "system" - ? (matchMedia("(prefers-color-scheme: light)").matches ? "light" : "dark") - : normalized; - document.documentElement.dataset.appearance = normalized; - document.documentElement.dataset.theme = theme; - document.documentElement.style.colorScheme = theme; - const meta = document.querySelector('meta[name="theme-color"]'); - if (meta) meta.setAttribute("content", theme === "light" ? "#f4f7f5" : "#0a0f0c"); - if (persist) localStorage.setItem(APPEARANCE_KEY, normalized); - return normalized; -} +const initialAppearance = applyExtensionAppearance(readLocalAppearance(), false); +const initialLocaleState = applyExtensionLocale(readLocalLocalePreference(), false); -applyAppearance(localStorage.getItem(APPEARANCE_KEY) ?? "system", false); -matchMedia("(prefers-color-scheme: light)").addEventListener("change", () => { - applyAppearance(localStorage.getItem(APPEARANCE_KEY) ?? "system", false); -}); - -type TabSummary = { - id?: number; - title: string; - url?: string; - pinned: boolean; - active: boolean; -}; - -type SessionItem = { - id: string; - title: string; - url: string; - pinned: boolean; - position: number; -}; - -type SessionSummary = { - id: string; - name: string; - sourceDevice?: string; - createdAt: string; - items: SessionItem[]; -}; - -type CaptureBookmark = { - id: string; - title: string; - url: string; - categoryId?: string; - categoryName?: string; - inboxAt?: string; -}; - -type CaptureResult = { - result: "created" | "duplicate"; - bookmark: CaptureBookmark; - duplicateState?: "inbox" | "library"; -}; - -const SERVER_KEY = "dockmarkServerUrl"; -const DEVICE_KEY = "dockmarkDeviceLabel"; -const TOKEN_KEY = "dockmarkDeviceToken"; - -class DockmarkRequestError extends Error { - constructor(readonly status: number, message: string) { - super(message); - } -} +type WorkbenchTab = "capture" | "multitab" | "sessions"; -function defaultSessionName() { - return `Window · ${new Intl.DateTimeFormat(undefined, { +function defaultSessionName(locale: ResolvedLocale) { + const formatted = new Intl.DateTimeFormat(locale === "zh-CN" ? "zh-CN" : "en-US", { month: "short", day: "numeric", hour: "2-digit", minute: "2-digit", - }).format(new Date())}`; -} - -function normalizeServerUrl(value: string) { - const url = new URL(value.trim()); - if (url.protocol !== "http:" && url.protocol !== "https:") { - throw new Error("Dockmark URL must use HTTP or HTTPS."); - } - return url.origin; -} - -function hostPattern(origin: string) { - return `${origin}/*`; -} - -function apiUrl(origin: string, path: string) { - return new URL(path, `${origin}/`).toString(); -} - -function hostLabel(value: string) { - try { - return new URL(value).host; - } catch { - return value; - } -} - -async function requestJson(url: string, init: RequestInit = {}, includeDeviceToken = true): Promise { - const headers = new Headers(init.headers); - headers.set("accept", "application/json"); - if (init.body) headers.set("content-type", "application/json"); - if (includeDeviceToken) { - const stored = await browser.storage.local.get(TOKEN_KEY); - const token = typeof stored[TOKEN_KEY] === "string" ? stored[TOKEN_KEY] : ""; - if (token) headers.set("authorization", `Bearer ${token}`); - } - const response = await fetch(url, { ...init, headers, cache: "no-store" }); - const body = await response.json().catch(() => ({})) as T & { error?: { message?: string } }; - if (!response.ok) { - throw new DockmarkRequestError(response.status, body.error?.message ?? `Dockmark request failed (${response.status}).`); - } - return body; + }).format(new Date()); + return tx(locale, `Window · ${formatted}`, `窗口 · ${formatted}`); } function Popup() { + const [appearance, setAppearance] = useState(initialAppearance); + const [localePreference, setLocalePreference] = useState(initialLocaleState.preference); + const [locale, setLocale] = useState(initialLocaleState.locale); + const [activeTab, setActiveTab] = useState("capture"); + const [settingsOpen, setSettingsOpen] = useState(false); + const [tabs, setTabs] = useState([]); const [serverUrl, setServerUrl] = useState(""); const [deviceLabel, setDeviceLabel] = useState("Main browser"); const [pairCode, setPairCode] = useState(""); - const [sessionName, setSessionName] = useState(defaultSessionName); + const [sessionName, setSessionName] = useState(() => defaultSessionName(initialLocaleState.locale)); const [sessions, setSessions] = useState([]); const [captureResult, setCaptureResult] = useState(null); const [connected, setConnected] = useState(false); @@ -143,7 +82,7 @@ function Popup() { const [error, setError] = useState(null); const savableTabs = useMemo( - () => tabs.filter((tab): tab is TabSummary & { url: string } => Boolean(tab.url && /^https?:\/\//i.test(tab.url))), + () => tabs.filter((tab): tab is SavableTab => Boolean(tab.url && /^https?:\/\//i.test(tab.url))), [tabs], ); const activeSavableTab = useMemo( @@ -153,16 +92,30 @@ function Popup() { useEffect(() => { let cancelled = false; + const unsubscribe = subscribeExtensionPreferences({ + onAppearance: (pref) => { if (!cancelled) setAppearance(pref); }, + onLocale: (pref, resolved) => { + if (!cancelled) { + setLocalePreference(pref); + setLocale(resolved); + } + }, + }); void (async () => { try { - const [openTabs, hasBookmarks, stored] = await Promise.all([ + const [hydrated, openTabs, hasBookmarks, stored] = await Promise.all([ + hydrateExtensionPreferences(), browser.runtime.sendMessage({ type: "dockmark:get-open-tabs" }), browser.permissions.contains({ permissions: ["bookmarks"] }), browser.storage.local.get([SERVER_KEY, DEVICE_KEY, TOKEN_KEY]), ]); if (cancelled) return; + setAppearance(hydrated.appearance); + setLocalePreference(hydrated.localePreference); + setLocale(hydrated.locale); + setSessionName(defaultSessionName(hydrated.locale)); setTabs((openTabs as TabSummary[]) ?? []); setBookmarkAccess(hasBookmarks); @@ -183,6 +136,7 @@ function Popup() { try { await refreshSessions(storedServer); if (!cancelled) setPaired(true); + void syncAppearanceFromServer(storedServer, () => cancelled); } catch (caught) { if (caught instanceof DockmarkRequestError && (caught.status === 401 || caught.status === 403)) { await browser.storage.local.remove(TOKEN_KEY); @@ -204,9 +158,25 @@ function Popup() { return () => { cancelled = true; + unsubscribe(); }; }, []); + async function syncAppearanceFromServer(origin: string, isCancelled: () => boolean) { + try { + const payload = await requestJson(apiUrl(origin, "/api/settings/appearance")); + if (isCancelled() || !payload?.settings) return; + if (payload.settings.preference) setAppearance(applyExtensionAppearance(payload.settings.preference, true)); + if (payload.settings.locale) { + const applied = applyExtensionLocale(payload.settings.locale, true); + setLocalePreference(applied.preference); + setLocale(applied.locale); + } + } catch { + // Cloud appearance read is best-effort. + } + } + async function refreshSessions(origin = serverUrl) { if (!origin) return; const payload = await requestJson<{ sessions: SessionSummary[] }>(apiUrl(origin, "/api/sessions")); @@ -220,7 +190,7 @@ function Popup() { try { await action(); } catch (caught) { - setError(caught instanceof Error ? caught.message : "Something went wrong."); + setError(caught instanceof Error ? caught.message : tx(locale, "Something went wrong.", "操作失败,请重试。")); } finally { setBusy(false); } @@ -234,11 +204,9 @@ function Popup() { try { const origin = normalizeServerUrl(serverUrl); - - // Firefox requires permissions.request to run directly from the user gesture. - // Do not await storage or any other async work before this request. + // Call permissions.request synchronously on user gesture with no await beforehand. const granted = await browser.permissions.request({ origins: [hostPattern(origin)] }); - if (!granted) throw new Error("Dockmark site access was not granted."); + if (!granted) throw new Error(tx(locale, "Dockmark site access was not granted.", "未授予 Dockmark 站点访问权限。")); const stored = await browser.storage.local.get([SERVER_KEY, TOKEN_KEY]); const previousOrigin = typeof stored[SERVER_KEY] === "string" ? stored[SERVER_KEY] : ""; @@ -253,9 +221,7 @@ function Popup() { await browser.storage.local.set({ [SERVER_KEY]: origin, [DEVICE_KEY]: label }); setServerUrl(origin); setDeviceLabel(label); - await browser.runtime.sendMessage({ type: "dockmark:configure-bridge", origin }); - if (previousOrigin && previousOrigin !== origin) { await browser.permissions.remove({ origins: [hostPattern(previousOrigin)] }).catch(() => false); } @@ -265,7 +231,7 @@ function Popup() { try { await refreshSessions(origin); setPaired(true); - setStatus("Connected and paired. Browser bridge, Quick Capture and private cloud access are ready."); + setStatus(tx(locale, "Connected and paired.", "已连接并完成配对。")); return; } catch (caught) { if (caught instanceof DockmarkRequestError && (caught.status === 401 || caught.status === 403)) { @@ -276,9 +242,9 @@ function Popup() { } } } - setStatus("Site access connected. Create a pairing code in Dockmark Settings → Security, then enter it below for private cloud access."); + setStatus(tx(locale, "Site access granted. Enter a pairing code from Settings → Security.", "站点权限已连接,请输入设置 → 安全中的一次性配对码。")); } catch (caught) { - setError(caught instanceof Error ? caught.message : "Something went wrong."); + setError(caught instanceof Error ? caught.message : tx(locale, "Something went wrong.", "操作失败,请重试。")); } finally { setBusy(false); } @@ -286,24 +252,23 @@ function Popup() { async function pairDevice() { await run(async () => { - if (!connected) throw new Error("Connect this Dockmark origin first."); + if (!connected) throw new Error(tx(locale, "Connect this Dockmark origin first.", "请先连接 Dockmark 服务器。")); const code = pairCode.trim(); - if (!code) throw new Error("Enter the pairing code from Dockmark Settings → Security."); + if (!code) throw new Error(tx(locale, "Enter the pairing code from Settings → Security.", "请输入设置 → 安全中的配对码。")); const label = deviceLabel.trim() || "Main browser"; const result = await requestJson<{ token: string; device: { id: string; name: string } }>( apiUrl(serverUrl, "/api/auth/pair/exchange"), - { - method: "POST", - body: JSON.stringify({ code, name: label }), - }, + { method: "POST", body: JSON.stringify({ code, name: label }) }, false, ); await browser.storage.local.set({ [TOKEN_KEY]: result.token, [DEVICE_KEY]: label }); setDeviceLabel(label); setPairCode(""); setPaired(true); + setSettingsOpen(false); await refreshSessions(); - setStatus(`Paired as “${result.device.name}”. Quick Capture and private cloud Session save are enabled.`); + void syncAppearanceFromServer(serverUrl, () => false); + setStatus(tx(locale, `Paired as “${result.device.name}”.`, `已配对设备“${result.device.name}”。`)); }); } @@ -313,214 +278,249 @@ function Popup() { setPaired(false); setSessions([]); setCaptureResult(null); - setStatus("Removed this device token locally. To invalidate a copied token everywhere, revoke this device from Dockmark Settings → Security."); + setStatus(tx(locale, "Removed local device token. Revoke in Settings → Security to invalidate copies.", "已清除本地设备令牌。如需彻底作废,请在设置 → 安全中撤销该设备。")); }); } - async function enableBookmarkAccess() { - await run(async () => { - const granted = await browser.permissions.request({ permissions: ["bookmarks"] }); - if (!granted) throw new Error("Native bookmark access was not granted."); - setBookmarkAccess(true); - setStatus("Native bookmark access enabled. Dockmark can review imports and mapping changes, and can update a mapped bookmark title/URL only after an explicit Web review action."); - }); + async function toggleBookmarkAccess() { + setBusy(true); + setStatus(null); + setError(null); + try { + if (bookmarkAccess) { + const removed = await browser.permissions.remove({ permissions: ["bookmarks"] }); + setBookmarkAccess(!removed); + setStatus(removed ? tx(locale, "Native bookmark access disabled.", "已关闭浏览器原生书签权限。") : tx(locale, "Native bookmark access is still enabled.", "浏览器原生书签权限仍处于开启状态。")); + } else { + const granted = await browser.permissions.request({ permissions: ["bookmarks"] }); + if (!granted) throw new Error(tx(locale, "Native bookmark access was not granted.", "未授予浏览器原生书签权限。")); + setBookmarkAccess(true); + setStatus(tx(locale, "Native bookmark access enabled.", "已开启浏览器原生书签权限。")); + } + } catch (caught) { + setError(caught instanceof Error ? caught.message : tx(locale, "Something went wrong.", "操作失败,请重试。")); + } finally { + setBusy(false); + } } - async function disableBookmarkAccess() { - await run(async () => { - const removed = await browser.permissions.remove({ permissions: ["bookmarks"] }); - setBookmarkAccess(!removed); - setStatus(removed ? "Native bookmark access disabled." : "Native bookmark access is still enabled."); - }); + function handleSelectAppearance(next: AppearancePreference) { + const applied = applyExtensionAppearance(next, true); + setAppearance(applied); + if (connected && paired && serverUrl) void patchRemoteAppearance(serverUrl, { preference: applied }); + } + + function handleSelectLocale(next: LocalePreference) { + const applied = applyExtensionLocale(next, true); + setLocalePreference(applied.preference); + setLocale(applied.locale); + if (connected && paired && serverUrl) void patchRemoteAppearance(serverUrl, { locale: applied.preference }); } async function saveCurrentTab() { await run(async () => { - if (!connected) throw new Error("Connect the extension to your Dockmark site first."); - if (!paired) throw new Error("Pair this extension before using Quick Capture."); - if (!activeSavableTab?.url) throw new Error("The current tab is not an HTTP/HTTPS page that Dockmark can save."); + if (!connected) throw new Error(tx(locale, "Connect the extension to Dockmark first.", "请先连接 Dockmark 服务器。")); + if (!paired) throw new Error(tx(locale, "Pair this extension before Quick Capture.", "请先配对设备后再使用快速收录。")); + if (!activeSavableTab?.url) throw new Error(tx(locale, "Current tab is not a savable HTTP/HTTPS page.", "当前标签页不是可收录的 HTTP/HTTPS 网页。")); if (new URL(activeSavableTab.url).origin === normalizeServerUrl(serverUrl)) { - throw new Error("Dockmark does not capture its own management page."); + throw new Error(tx(locale, "Dockmark does not capture its own management page.", "Dockmark 不会收录自身的管理页面。")); } - const result = await requestJson(apiUrl(serverUrl, "/api/capture/bookmark"), { method: "POST", - body: JSON.stringify({ - title: activeSavableTab.title || activeSavableTab.url, - url: activeSavableTab.url, - }), + body: JSON.stringify({ title: activeSavableTab.title || activeSavableTab.url, url: activeSavableTab.url }), }); setCaptureResult(result); - if (result.result === "created") { - setStatus("Saved current tab to Dockmark Inbox. Review and file it from Web → Inbox."); - } else { - setStatus(null); - } + setStatus(result.result === "created" ? tx(locale, "Saved to Inbox.", "已保存到收件箱。") : null); }); } - async function openCaptureReview() { - const path = captureResult?.duplicateState === "library" ? "/app" : "/app/inbox"; - await browser.tabs.create({ url: apiUrl(serverUrl, path), active: true }); - } - async function saveWindow() { await run(async () => { - if (!connected) throw new Error("Connect the extension to your Dockmark site first."); - if (!paired) throw new Error("Pair this extension before saving private cloud Sessions."); - if (!savableTabs.length) throw new Error("This window has no HTTP/HTTPS tabs to save."); + if (!connected) throw new Error(tx(locale, "Connect the extension to Dockmark first.", "请先连接 Dockmark 服务器。")); + if (!paired) throw new Error(tx(locale, "Pair this extension before saving Sessions.", "请先配对设备后再保存会话。")); + if (!savableTabs.length) throw new Error(tx(locale, "This window has no HTTP/HTTPS tabs to save.", "当前窗口没有可保存的 HTTP/HTTPS 标签页。")); const name = sessionName.trim(); - if (!name) throw new Error("Give this session a name."); - + if (!name) throw new Error(tx(locale, "Give this session a name.", "请输入会话名称。")); await requestJson<{ session: SessionSummary }>(apiUrl(serverUrl, "/api/sessions"), { method: "POST", body: JSON.stringify({ name, sourceDevice: deviceLabel.trim() || "Main browser", - items: savableTabs.map((tab, position) => ({ - title: tab.title || tab.url, - url: tab.url, - pinned: tab.pinned, - position, - })), + items: savableTabs.map((tab, position) => ({ title: tab.title || tab.url, url: tab.url, pinned: tab.pinned, position })), }), }); - await refreshSessions(); - setSessionName(defaultSessionName()); - setStatus(`Saved ${savableTabs.length} tabs.`); + setSessionName(defaultSessionName(locale)); + setStatus(tx(locale, `Saved ${savableTabs.length} tabs as Session.`, `已将 ${savableTabs.length} 个标签页保存为会话。`)); }); } async function restoreSession(session: SessionSummary) { await run(async () => { - const result = await browser.runtime.sendMessage({ + const result = (await browser.runtime.sendMessage({ type: "dockmark:restore-session", - items: [...session.items] - .sort((a, b) => a.position - b.position) - .map((item) => ({ url: item.url, pinned: item.pinned })), - }) as { opened?: number } | undefined; - setStatus(`Restored ${result?.opened ?? session.items.length} tabs.`); + items: [...session.items].sort((a, b) => a.position - b.position).map((item) => ({ url: item.url, pinned: item.pinned })), + })) as { opened?: number } | undefined; + const count = result?.opened ?? session.items.length; + setStatus(tx(locale, `Restored ${count} tabs.`, `已恢复 ${count} 个标签页。`)); }); } - return ( -
-
-
DockmarkBrowser bridge
- {tabs.length} tabs -
+ const connectionLabel = connected + ? paired ? tx(locale, "Paired", "已配对") : tx(locale, "Connected", "已连接") + : initializing ? tx(locale, "Checking", "检查中") : tx(locale, "Local", "仅本地"); + const isDailyReady = connected && paired; -
-
- Dockmark site - {connected ? paired ? "Paired" : "Connected" : initializing ? "Checking" : "Local only"} -
- { setServerUrl(event.target.value); setConnected(false); setPaired(false); setCaptureResult(null); }} placeholder="https://dockmark.example.com" inputMode="url" /> -
- setDeviceLabel(event.target.value)} placeholder="Main MacBook" /> - + return ( +
+
+
+ +
+ Dockmark + +