synabun 2.4.1 → 2.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +50 -0
- package/README.md +1 -1
- package/docs/browser-extension-bridge.md +46 -6
- package/lib/data-home-files.js +4 -2
- package/lib/first-launch-protection.js +8 -2
- package/lib/release-npm-ci.mjs +23 -1
- package/lib/update-snapshot.js +11 -4
- package/mcp-server/dist/http.d.ts.map +1 -1
- package/mcp-server/dist/http.js +25 -2
- package/mcp-server/dist/http.js.map +1 -1
- package/mcp-server/dist/index.d.ts.map +1 -1
- package/mcp-server/dist/index.js +62 -17
- package/mcp-server/dist/index.js.map +1 -1
- package/mcp-server/dist/services/browser-bench.d.ts +22 -22
- package/mcp-server/dist/services/memory-maintenance.d.ts +1 -0
- package/mcp-server/dist/services/memory-maintenance.d.ts.map +1 -1
- package/mcp-server/dist/services/memory-maintenance.js +34 -45
- package/mcp-server/dist/services/memory-maintenance.js.map +1 -1
- package/mcp-server/dist/services/memory-migration-copy.d.ts +144 -0
- package/mcp-server/dist/services/memory-migration-copy.d.ts.map +1 -0
- package/mcp-server/dist/services/memory-migration-copy.js +467 -0
- package/mcp-server/dist/services/memory-migration-copy.js.map +1 -0
- package/mcp-server/dist/services/memory-migration-worker.d.ts +2 -0
- package/mcp-server/dist/services/memory-migration-worker.d.ts.map +1 -0
- package/mcp-server/dist/services/memory-migration-worker.js +60 -0
- package/mcp-server/dist/services/memory-migration-worker.js.map +1 -0
- package/mcp-server/dist/services/memory-retrieval.d.ts +4 -0
- package/mcp-server/dist/services/memory-retrieval.d.ts.map +1 -1
- package/mcp-server/dist/services/memory-retrieval.js +188 -40
- package/mcp-server/dist/services/memory-retrieval.js.map +1 -1
- package/mcp-server/dist/services/memory-schema.d.ts +58 -2
- package/mcp-server/dist/services/memory-schema.d.ts.map +1 -1
- package/mcp-server/dist/services/memory-schema.js +190 -13
- package/mcp-server/dist/services/memory-schema.js.map +1 -1
- package/mcp-server/dist/services/memory-sessions.d.ts +19 -1
- package/mcp-server/dist/services/memory-sessions.d.ts.map +1 -1
- package/mcp-server/dist/services/memory-sessions.js +56 -20
- package/mcp-server/dist/services/memory-sessions.js.map +1 -1
- package/mcp-server/dist/services/memory-verification.d.ts.map +1 -1
- package/mcp-server/dist/services/memory-verification.js +8 -5
- package/mcp-server/dist/services/memory-verification.js.map +1 -1
- package/mcp-server/dist/services/neural-interface.d.ts +5 -0
- package/mcp-server/dist/services/neural-interface.d.ts.map +1 -1
- package/mcp-server/dist/services/neural-interface.js +19 -2
- package/mcp-server/dist/services/neural-interface.js.map +1 -1
- package/mcp-server/dist/services/retrieval-reader-worker.d.ts +2 -0
- package/mcp-server/dist/services/retrieval-reader-worker.d.ts.map +1 -0
- package/mcp-server/dist/services/retrieval-reader-worker.js +76 -0
- package/mcp-server/dist/services/retrieval-reader-worker.js.map +1 -0
- package/mcp-server/dist/services/retrieval-reader.d.ts +38 -0
- package/mcp-server/dist/services/retrieval-reader.d.ts.map +1 -0
- package/mcp-server/dist/services/retrieval-reader.js +145 -0
- package/mcp-server/dist/services/retrieval-reader.js.map +1 -0
- package/mcp-server/dist/services/sqlite-write.d.ts +14 -0
- package/mcp-server/dist/services/sqlite-write.d.ts.map +1 -0
- package/mcp-server/dist/services/sqlite-write.js +94 -0
- package/mcp-server/dist/services/sqlite-write.js.map +1 -0
- package/mcp-server/dist/services/sqlite.d.ts +39 -0
- package/mcp-server/dist/services/sqlite.d.ts.map +1 -1
- package/mcp-server/dist/services/sqlite.js +249 -8
- package/mcp-server/dist/services/sqlite.js.map +1 -1
- package/mcp-server/dist/services/tool-catalog.d.ts +1 -1
- package/mcp-server/dist/services/typesafe-config.d.ts +7 -1
- package/mcp-server/dist/services/typesafe-config.d.ts.map +1 -1
- package/mcp-server/dist/services/typesafe-config.js +32 -10
- package/mcp-server/dist/services/typesafe-config.js.map +1 -1
- package/mcp-server/dist/services/typesafe.d.ts.map +1 -1
- package/mcp-server/dist/services/typesafe.js +9 -7
- package/mcp-server/dist/services/typesafe.js.map +1 -1
- package/mcp-server/dist/services/vector-cache.d.ts +32 -0
- package/mcp-server/dist/services/vector-cache.d.ts.map +1 -1
- package/mcp-server/dist/services/vector-cache.js +161 -8
- package/mcp-server/dist/services/vector-cache.js.map +1 -1
- package/mcp-server/dist/tools/agent-definition.d.ts +2 -2
- package/mcp-server/dist/tools/agents.d.ts +11 -7
- package/mcp-server/dist/tools/agents.d.ts.map +1 -1
- package/mcp-server/dist/tools/agents.js +27 -9
- package/mcp-server/dist/tools/agents.js.map +1 -1
- package/mcp-server/dist/tools/browser-advanced.d.ts +1 -1
- package/mcp-server/dist/tools/browser-advanced.d.ts.map +1 -1
- package/mcp-server/dist/tools/browser-advanced.js +10 -3
- package/mcp-server/dist/tools/browser-advanced.js.map +1 -1
- package/mcp-server/dist/tools/browser-extension-setup.d.ts +5 -0
- package/mcp-server/dist/tools/browser-extension-setup.d.ts.map +1 -0
- package/mcp-server/dist/tools/browser-extension-setup.js +29 -0
- package/mcp-server/dist/tools/browser-extension-setup.js.map +1 -0
- package/mcp-server/dist/tools/browser-interact.d.ts.map +1 -1
- package/mcp-server/dist/tools/browser-interact.js +6 -1
- package/mcp-server/dist/tools/browser-interact.js.map +1 -1
- package/mcp-server/dist/tools/fb-groups.d.ts +2 -2
- package/mcp-server/dist/tools/skill-tools.d.ts +4 -4
- package/mcp-server/dist/tools/tool-groups.d.ts +1 -1
- package/mcp-server/package-lock.json +5 -5
- package/mcp-server/package.json +1 -1
- package/mcp-server/src/http.ts +20 -2
- package/mcp-server/src/index.ts +59 -17
- package/mcp-server/src/services/memory-maintenance.ts +31 -28
- package/mcp-server/src/services/memory-migration-copy.ts +419 -0
- package/mcp-server/src/services/memory-migration-worker.ts +55 -0
- package/mcp-server/src/services/memory-retrieval.ts +173 -32
- package/mcp-server/src/services/memory-schema.ts +194 -12
- package/mcp-server/src/services/memory-sessions.ts +54 -21
- package/mcp-server/src/services/memory-verification.ts +7 -4
- package/mcp-server/src/services/neural-interface.ts +22 -2
- package/mcp-server/src/services/retrieval-reader-worker.ts +67 -0
- package/mcp-server/src/services/retrieval-reader.ts +131 -0
- package/mcp-server/src/services/sqlite-write.ts +60 -0
- package/mcp-server/src/services/sqlite.ts +246 -8
- package/mcp-server/src/services/typesafe-config.ts +25 -6
- package/mcp-server/src/services/typesafe.ts +9 -7
- package/mcp-server/src/services/vector-cache.ts +154 -9
- package/mcp-server/src/tools/agents.ts +26 -9
- package/mcp-server/src/tools/browser-advanced.ts +10 -3
- package/mcp-server/src/tools/browser-extension-setup.ts +36 -0
- package/mcp-server/src/tools/browser-interact.ts +5 -1
- package/neural-interface/i18n/en.json +313 -2
- package/neural-interface/i18n/pt-BR.json +321 -10
- package/neural-interface/lib/agents/split.js +32 -4
- package/neural-interface/lib/assistant-api.js +52 -8
- package/neural-interface/lib/assistant-brains/claude.js +2 -0
- package/neural-interface/lib/assistant-brains/opencode.js +121 -7
- package/neural-interface/lib/assistant-catalog.js +2 -2
- package/neural-interface/lib/assistant-config.js +0 -7
- package/neural-interface/lib/assistant-dispatch.js +281 -95
- package/neural-interface/lib/assistant-envelope.js +40 -0
- package/neural-interface/lib/assistant-persona.js +16 -4
- package/neural-interface/lib/assistant-pricing.js +65 -14
- package/neural-interface/lib/assistant-router.js +131 -47
- package/neural-interface/lib/assistant-run-wait.js +45 -28
- package/neural-interface/lib/assistant-runtime.js +133 -42
- package/neural-interface/lib/backup-contents.js +158 -0
- package/neural-interface/lib/backup-crypto-io.js +330 -0
- package/neural-interface/lib/backup-crypto-worker.js +130 -0
- package/neural-interface/lib/backup-crypto.js +525 -0
- package/neural-interface/lib/backup-download.js +268 -0
- package/neural-interface/lib/backup-encryption.js +318 -0
- package/neural-interface/lib/backup-groups.js +287 -0
- package/neural-interface/lib/backup-restore-session.js +176 -0
- package/neural-interface/lib/backup-restore-stage.js +60 -0
- package/neural-interface/lib/backup-service.js +788 -233
- package/neural-interface/lib/backup-zip-reader.js +30 -18
- package/neural-interface/lib/backup-zip-writer.js +34 -10
- package/neural-interface/lib/browser-extension-adapter.js +89 -15
- package/neural-interface/lib/browser-extension-archive.js +149 -0
- package/neural-interface/lib/browser-extension-bridge.js +24 -10
- package/neural-interface/lib/browser-extension-folder.js +596 -76
- package/neural-interface/lib/browser-extension-package.js +200 -0
- package/neural-interface/lib/browser-extension-pin.js +84 -0
- package/neural-interface/lib/browser-extension-pin.json +33 -0
- package/{browser-extension/protocol.js → neural-interface/lib/browser-extension-protocol.js} +91 -6
- package/neural-interface/lib/browser-extension-setup.js +105 -18
- package/neural-interface/lib/claude-agent-bridge.js +1 -0
- package/neural-interface/lib/claude-session-cleanup.js +5 -1
- package/neural-interface/lib/cli-install.js +23 -3
- package/neural-interface/lib/cli-update-planner.js +171 -9
- package/neural-interface/lib/client-diagnostics.js +42 -0
- package/neural-interface/lib/confined-fs.js +7 -2
- package/neural-interface/lib/coordination/README.md +8 -2
- package/neural-interface/lib/coordination/contract.js +161 -0
- package/neural-interface/lib/coordination/database.js +999 -0
- package/neural-interface/lib/coordination/operations.js +436 -0
- package/neural-interface/lib/coordination/service.js +68 -537
- package/neural-interface/lib/coordination/storage-worker.js +101 -0
- package/neural-interface/lib/coordination/store.js +219 -1111
- package/neural-interface/lib/db.js +70 -32
- package/neural-interface/lib/health-count.js +37 -0
- package/neural-interface/lib/loop-stall.js +139 -0
- package/neural-interface/lib/maritaca/client.js +2 -2
- package/neural-interface/lib/maritaca/models.js +12 -17
- package/neural-interface/lib/maritaca/opencode.js +4 -2
- package/neural-interface/lib/memory-api.js +9 -1
- package/neural-interface/lib/memory-session-capture.js +42 -10
- package/neural-interface/lib/memory-store-gate.js +313 -0
- package/neural-interface/lib/memory-store-migrate.js +65 -0
- package/neural-interface/lib/memory-timers.js +7 -7
- package/neural-interface/lib/native-loop-providers.js +23 -17
- package/neural-interface/lib/native-loop-runtime.js +48 -9
- package/neural-interface/lib/opencode-build-preflight.js +18 -1
- package/neural-interface/lib/opencode-native-boundary.js +69 -8
- package/neural-interface/lib/opencode-provider-view.js +14 -3
- package/neural-interface/lib/opencode-shell-read.js +107 -0
- package/neural-interface/lib/opencode-stop-failures.js +40 -0
- package/neural-interface/lib/opencode-turn-release.js +173 -0
- package/neural-interface/lib/opencode-v2-client.js +4 -1
- package/neural-interface/lib/opencode-v2-ws-requests.js +65 -1
- package/neural-interface/lib/opencode2-client.js +343 -7
- package/neural-interface/lib/opencode2-translate.js +161 -4
- package/neural-interface/lib/recall-impact.js +122 -0
- package/neural-interface/lib/scratch-evidence.js +420 -0
- package/neural-interface/lib/scratch-process-guard.js +139 -0
- package/neural-interface/lib/scratch-references.js +279 -0
- package/neural-interface/lib/scratch-retention-core.js +385 -0
- package/neural-interface/lib/scratch-retention-worker.js +37 -0
- package/neural-interface/lib/scratch-retention.js +151 -0
- package/neural-interface/lib/session-cache-builder.js +31 -43
- package/neural-interface/lib/session-cache-worker.js +157 -0
- package/neural-interface/lib/session-indexer.js +28 -21
- package/neural-interface/lib/session-search-index.js +85 -0
- package/neural-interface/lib/skills/creation.js +1 -1
- package/neural-interface/lib/sqlite-integrity-worker.js +3 -1
- package/neural-interface/lib/style-guide/store.js +43 -3
- package/neural-interface/lib/system-restore.js +50 -0
- package/neural-interface/lib/teams/api.js +15 -6
- package/neural-interface/lib/teams/claims.js +67 -31
- package/neural-interface/lib/teams/index.js +7 -7
- package/neural-interface/lib/teams/integration.js +40 -40
- package/neural-interface/lib/teams/landing.js +6 -6
- package/neural-interface/lib/teams/recovery.js +24 -23
- package/neural-interface/lib/teams/scheduler.js +194 -95
- package/neural-interface/lib/teams/state.js +14 -14
- package/neural-interface/lib/teams/worktrees.js +27 -27
- package/neural-interface/lib/terminal-token-redaction.js +83 -0
- package/neural-interface/lib/whatsapp/bridge.js +54 -7
- package/neural-interface/lib/worker-confinement.js +47 -2
- package/neural-interface/lib/worker-mcp-channel.js +2 -0
- package/neural-interface/lib/worker-resume.js +5 -0
- package/neural-interface/lib/worker-stop.js +86 -0
- package/neural-interface/package-lock.json +5 -5
- package/neural-interface/package.json +1 -1
- package/neural-interface/public/extension-setup.html +5 -2
- package/neural-interface/public/index.html +233 -24
- package/neural-interface/public/onboarding.html +259 -34
- package/neural-interface/public/shared/agents/studio/ax-library.js +0 -6
- package/neural-interface/public/shared/agents/studio/ax-main.js +14 -7
- package/neural-interface/public/shared/agy/agy-options.js +11 -0
- package/neural-interface/public/shared/agy/agy-panel.js +67 -20
- package/neural-interface/public/shared/agy/agy-styles.js +14 -12
- package/neural-interface/public/shared/agy/agy-tabs-logic.js +4 -1
- package/neural-interface/public/shared/api.js +1 -1
- package/neural-interface/public/shared/assistant/asst-api.js +28 -3
- package/neural-interface/public/shared/assistant/asst-brain-picker.js +13 -6
- package/neural-interface/public/shared/assistant/asst-control.js +2 -0
- package/neural-interface/public/shared/assistant/asst-motion-gate.js +78 -4
- package/neural-interface/public/shared/assistant/asst-panel.js +87 -3
- package/neural-interface/public/shared/assistant/asst-rack-styles.js +27 -0
- package/neural-interface/public/shared/assistant/asst-render.js +243 -44
- package/neural-interface/public/shared/assistant/asst-route.js +100 -21
- package/neural-interface/public/shared/assistant/asst-routes-editor.js +1 -1
- package/neural-interface/public/shared/assistant/asst-shell-logic.js +200 -0
- package/neural-interface/public/shared/assistant/asst-shell.js +111 -0
- package/neural-interface/public/shared/assistant/asst-sidepanel.js +4 -2
- package/neural-interface/public/shared/assistant/asst-state.js +11 -0
- package/neural-interface/public/shared/assistant/asst-styles.js +11 -23
- package/neural-interface/public/shared/assistant/route-identity.js +2 -1
- package/neural-interface/public/shared/cdx/cdx-render.js +9 -0
- package/neural-interface/public/shared/cdx/cdx-settings.js +3 -1
- package/neural-interface/public/shared/cdx/cdx-styles.js +6 -0
- package/neural-interface/public/shared/cdx/cdx-tabs.js +54 -9
- package/neural-interface/public/shared/client-diagnostics.js +94 -0
- package/neural-interface/public/shared/cp/cp-markdown.js +7 -2
- package/neural-interface/public/shared/cp/cp-styles.js +1 -1
- package/neural-interface/public/shared/effort-i18n.js +118 -0
- package/neural-interface/public/shared/extension-setup/es-page.js +10 -4
- package/neural-interface/public/shared/extension-setup/es-view.js +25 -10
- package/neural-interface/public/shared/html-shell.js +4 -52
- package/neural-interface/public/shared/loading-diagnostic-entry.js +64 -0
- package/neural-interface/public/shared/memory-store-wait.js +52 -0
- package/neural-interface/public/shared/morelogin-profile-field.js +1 -1
- package/neural-interface/public/shared/mtc/mtc-logic.js +2 -1
- package/neural-interface/public/shared/mtc/mtc-panel.js +25 -3
- package/neural-interface/public/shared/mtc/mtc-styles.js +13 -12
- package/neural-interface/public/shared/ocp-v2/ocp-v2-childpanel.js +7 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-events.js +5 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-location-logic.js +109 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-manager.js +1 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-modelpicker.js +8 -1
- package/neural-interface/public/shared/ocp-v2/ocp-v2-panel.js +152 -8
- package/neural-interface/public/shared/ocp-v2/ocp-v2-rehydrate.js +7 -1
- package/neural-interface/public/shared/ocp-v2/ocp-v2-render.js +53 -4
- package/neural-interface/public/shared/ocp-v2/ocp-v2-send.js +52 -6
- package/neural-interface/public/shared/ocp-v2/ocp-v2-session-actions.js +22 -2
- package/neural-interface/public/shared/ocp-v2/ocp-v2-shell-block.js +165 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-shell-logic.js +346 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-shell.js +108 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-state.js +49 -3
- package/neural-interface/public/shared/ocp-v2/ocp-v2-styles.js +67 -93
- package/neural-interface/public/shared/ocp-v2/ocp-v2-tools-logic.js +20 -5
- package/neural-interface/public/shared/ocp-v2/ocp-v2-tools.js +7 -1
- package/neural-interface/public/shared/ocp-v2/ocp-v2-variantpicker.js +17 -6
- package/neural-interface/public/shared/ocp-v2/ocp-v2-ws.js +7 -2
- package/neural-interface/public/shared/output-format.js +294 -0
- package/neural-interface/public/shared/provider-icons.js +6 -0
- package/neural-interface/public/shared/schedules-view.js +2 -1
- package/neural-interface/public/shared/server-presence.js +77 -0
- package/neural-interface/public/shared/settings/settings-backup-contents.js +241 -0
- package/neural-interface/public/shared/settings/settings-backup-download.js +298 -0
- package/neural-interface/public/shared/settings/settings-backup-encryption-pane.js +335 -0
- package/neural-interface/public/shared/settings/settings-backup-encryption.js +545 -0
- package/neural-interface/public/shared/settings/settings-browser-extension.js +54 -12
- package/neural-interface/public/shared/settings/settings-ia.js +1 -1
- package/neural-interface/public/shared/shell-stop-view.js +83 -0
- package/neural-interface/public/shared/skills/studio/sx-geometry.js +12 -3
- package/neural-interface/public/shared/skills/studio/sx-main.js +14 -7
- package/neural-interface/public/shared/studio-attention.js +6 -0
- package/neural-interface/public/shared/styles.css +341 -437
- package/neural-interface/public/shared/tour/tour-actor.js +14 -3
- package/neural-interface/public/shared/transcript-rows.js +28 -3
- package/neural-interface/public/shared/tray-auto-close.js +49 -6
- package/neural-interface/public/shared/ui-agents.js +1 -2
- package/neural-interface/public/shared/ui-automation-studio.js +168 -108
- package/neural-interface/public/shared/ui-claude-panel.js +62 -65
- package/neural-interface/public/shared/ui-loading.js +124 -17
- package/neural-interface/public/shared/ui-native-loop-router.js +52 -0
- package/neural-interface/public/shared/ui-navbar.js +2 -1
- package/neural-interface/public/shared/ui-output.js +533 -0
- package/neural-interface/public/shared/ui-schedules-studio.js +165 -128
- package/neural-interface/public/shared/ui-scroll-follow.js +101 -6
- package/neural-interface/public/shared/ui-sessions.js +2 -2
- package/neural-interface/public/shared/ui-settings-entry.js +18 -0
- package/neural-interface/public/shared/ui-settings.js +224 -65
- package/neural-interface/public/shared/ui-sidepanel-tray.js +3 -2
- package/neural-interface/public/shared/ui-tooltip.js +16 -0
- package/neural-interface/public/shared/ui-tutorial.js +5 -6
- package/neural-interface/public/shared/ui-worker-end.js +27 -8
- package/neural-interface/public/shared/worker-end.js +9 -4
- package/neural-interface/public/variant/2d/main.js +5 -0
- package/neural-interface/public/variant/3d/app.js +10 -0
- package/neural-interface/public/variant/3d/main.js +5 -1
- package/neural-interface/scripts/scratch-retention.mjs +20 -0
- package/neural-interface/server.js +725 -173
- package/npm-shrinkwrap.json +5 -5
- package/package.json +1 -2
- package/scripts/restore-data-home-from-backup.mjs +175 -8
- package/setup.js +18 -4
- package/browser-extension/content.js +0 -189
- package/browser-extension/engine.js +0 -508
- package/browser-extension/icons/icon-128.png +0 -0
- package/browser-extension/icons/icon-16.png +0 -0
- package/browser-extension/icons/icon-32.png +0 -0
- package/browser-extension/icons/icon-48.png +0 -0
- package/browser-extension/icons/status-off-16.png +0 -0
- package/browser-extension/icons/status-off-32.png +0 -0
- package/browser-extension/icons/status-off-48.png +0 -0
- package/browser-extension/icons/status-on-16.png +0 -0
- package/browser-extension/icons/status-on-32.png +0 -0
- package/browser-extension/icons/status-on-48.png +0 -0
- package/browser-extension/manifest.json +0 -56
- package/browser-extension/popup-strings.js +0 -250
- package/browser-extension/popup-view.js +0 -151
- package/browser-extension/popup.css +0 -166
- package/browser-extension/popup.html +0 -108
- package/browser-extension/popup.js +0 -359
- package/browser-extension/service-worker.js +0 -275
- package/browser-extension/setup-content.js +0 -36
- package/browser-extension/tokens.css +0 -326
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
<!doctype html><html lang="en"><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>SynaBun Browser Bridge</title><link rel="stylesheet" href="tokens.css"><link rel="stylesheet" href="popup.css"><body>
|
|
2
|
-
<!-- The toolbar popup (docs/design/browser-extension: "Extension popup"). Am I connected, what may agents use, which
|
|
3
|
-
tabs do they hold. Every word comes from popup-strings.js in the browser's language (popup.js fills it in); what
|
|
4
|
-
the popup shows is decided by popup-view.js. -->
|
|
5
|
-
<div class="popup" id="popup" data-state="loading" aria-busy="true">
|
|
6
|
-
<header class="p-head">
|
|
7
|
-
<div class="p-brand"><img src="icons/icon-32.png" alt="" width="32" height="32"><div class="p-brand-text"><strong>SynaBun</strong><small id="p-brand-sub"></small></div></div>
|
|
8
|
-
<button type="button" class="p-icon-btn" id="p-open-app" data-action="open-app" aria-label="Open SynaBun" title="Open SynaBun"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M7 17 17 7M8 7h9v9"></path></svg></button>
|
|
9
|
-
</header>
|
|
10
|
-
|
|
11
|
-
<section class="p-section p-top" aria-labelledby="p-status-title">
|
|
12
|
-
<div class="p-status" id="p-status" data-tone="">
|
|
13
|
-
<span class="p-status-symbol" aria-hidden="true">
|
|
14
|
-
<svg class="p-sym" data-sym="good" viewBox="0 0 24 24"><path d="m5 12 4 4 10-10"></path></svg>
|
|
15
|
-
<svg class="p-sym" data-sym="warn" viewBox="0 0 24 24"><path d="M9 5v14M15 5v14"></path></svg>
|
|
16
|
-
<svg class="p-sym" data-sym="sync" viewBox="0 0 24 24"><path d="M20 7a9 9 0 0 0-15-1L2 9m0-6v6h6M4 17a9 9 0 0 0 15 1l3-3m0 6v-6h-6"></path></svg>
|
|
17
|
-
<svg class="p-sym" data-sym="bad" viewBox="0 0 24 24"><path d="m12 3 10 18H2L12 3ZM12 9v5M12 17h.01"></path></svg>
|
|
18
|
-
<svg class="p-sym" data-sym="link" viewBox="0 0 24 24"><path d="M10 14a4 4 0 0 0 5.66 0l3-3a4 4 0 0 0-5.66-5.66l-1 1M14 10a4 4 0 0 0-5.66 0l-3 3a4 4 0 0 0 5.66 5.66l1-1"></path></svg>
|
|
19
|
-
</span>
|
|
20
|
-
<div class="p-status-body">
|
|
21
|
-
<h1 class="p-status-title" id="p-status-title" tabindex="-1"></h1>
|
|
22
|
-
<p class="p-status-help" id="p-status-help"></p>
|
|
23
|
-
<div class="p-actions" id="p-status-actions" hidden><button type="button" class="p-btn p-btn-primary" id="p-primary" hidden></button></div>
|
|
24
|
-
</div>
|
|
25
|
-
</div>
|
|
26
|
-
|
|
27
|
-
<div class="p-mode" id="p-mode" hidden>
|
|
28
|
-
<span class="p-label" id="p-mode-label"></span>
|
|
29
|
-
<div class="p-dropdown" id="p-mode-dropdown">
|
|
30
|
-
<button type="button" class="p-dropdown-trigger" id="p-mode-trigger" role="combobox" aria-haspopup="listbox" aria-expanded="false" aria-controls="p-mode-list" aria-labelledby="p-mode-label p-mode-value"><span id="p-mode-value"></span><svg viewBox="0 0 24 24" aria-hidden="true"><path d="m6 9 6 6 6-6"></path></svg></button>
|
|
31
|
-
<div class="p-dropdown-menu" id="p-mode-list" role="listbox" aria-labelledby="p-mode-label" hidden>
|
|
32
|
-
<div class="p-dropdown-item" role="option" id="p-mode-full" data-value="full" aria-selected="true"></div>
|
|
33
|
-
<div class="p-dropdown-item" role="option" id="p-mode-restricted" data-value="restricted" aria-selected="false"></div>
|
|
34
|
-
</div>
|
|
35
|
-
</div>
|
|
36
|
-
<p class="p-mode-help" id="p-mode-help"></p>
|
|
37
|
-
</div>
|
|
38
|
-
</section>
|
|
39
|
-
|
|
40
|
-
<section class="p-section" id="p-activity" aria-labelledby="p-activity-title" hidden>
|
|
41
|
-
<div class="p-section-title"><h2 id="p-activity-title" tabindex="-1"></h2><span id="p-activity-count"></span></div>
|
|
42
|
-
<p class="p-caption" id="p-activity-summary"></p>
|
|
43
|
-
<div class="p-tab-list" id="p-groups"></div>
|
|
44
|
-
<div class="p-empty" id="p-empty" hidden>
|
|
45
|
-
<svg viewBox="0 0 24 24" aria-hidden="true"><rect x="3" y="7" width="15" height="13" rx="2"></rect><path d="M7 3h12a2 2 0 0 1 2 2v11M3 11h15"></path></svg>
|
|
46
|
-
<h3 id="p-empty-title"></h3><p id="p-empty-help"></p>
|
|
47
|
-
</div>
|
|
48
|
-
<p class="p-helper" id="p-activity-help"></p>
|
|
49
|
-
</section>
|
|
50
|
-
|
|
51
|
-
<section class="p-section" id="p-shared" aria-labelledby="p-shared-title" hidden>
|
|
52
|
-
<h2 id="p-shared-title"></h2>
|
|
53
|
-
<div class="p-list" id="p-sites"></div>
|
|
54
|
-
<div class="p-empty" id="p-shared-empty" hidden><h3 id="p-shared-empty-title"></h3><p id="p-shared-empty-help"></p></div>
|
|
55
|
-
<h3 class="p-subhead" id="p-waiting-title" hidden></h3>
|
|
56
|
-
<div class="p-list" id="p-waiting"></div>
|
|
57
|
-
<div class="p-actions"><button type="button" class="p-btn p-btn-primary" id="share" data-action="share"></button><button type="button" class="p-btn" id="site" data-action="site"></button></div>
|
|
58
|
-
<label class="p-check"><input type="checkbox" id="newTabs"><span id="p-newtabs-label"></span></label>
|
|
59
|
-
</section>
|
|
60
|
-
|
|
61
|
-
<details class="p-details" id="p-files" hidden>
|
|
62
|
-
<summary id="p-files-summary"></summary>
|
|
63
|
-
<div class="p-details-body">
|
|
64
|
-
<label class="p-check"><input type="checkbox" id="downloads"><span id="p-downloads-label"></span></label>
|
|
65
|
-
<p id="p-download-note"></p>
|
|
66
|
-
<p class="p-notice" id="p-downloads-denied" role="status" hidden></p>
|
|
67
|
-
<h3 id="p-upload-title"></h3>
|
|
68
|
-
<p id="p-upload-help"></p>
|
|
69
|
-
<p id="p-limits"></p>
|
|
70
|
-
<details class="p-details p-details-nested" id="p-connection">
|
|
71
|
-
<summary id="p-connection-summary"></summary>
|
|
72
|
-
<p class="p-details-body"><span id="p-bridge-label"></span> <code id="p-bridge"></code></p>
|
|
73
|
-
</details>
|
|
74
|
-
</div>
|
|
75
|
-
</details>
|
|
76
|
-
|
|
77
|
-
<details class="p-details" id="p-pair-code" hidden>
|
|
78
|
-
<summary id="p-pair-summary"></summary>
|
|
79
|
-
<form class="p-details-body p-pair" id="pair">
|
|
80
|
-
<p id="p-pair-help"></p>
|
|
81
|
-
<label class="p-field" for="port"><span id="p-port-label"></span><input id="port" type="number" min="1024" max="65535" value="3345" inputmode="numeric"></label>
|
|
82
|
-
<label class="p-field" for="code"><span id="p-code-label"></span><input id="code" autocomplete="off" spellcheck="false" maxlength="24"></label>
|
|
83
|
-
<button class="p-btn" id="p-pair-submit" type="submit"></button>
|
|
84
|
-
</form>
|
|
85
|
-
</details>
|
|
86
|
-
|
|
87
|
-
<footer class="p-footer" id="p-footer">
|
|
88
|
-
<button type="button" class="p-btn p-btn-ghost" id="p-footer-app" data-action="open-app"></button>
|
|
89
|
-
<span class="p-footer-end">
|
|
90
|
-
<button type="button" class="p-btn p-btn-ghost" id="disconnect" data-action="confirm-disconnect" hidden></button>
|
|
91
|
-
<button type="button" class="p-btn p-btn-ghost p-btn-danger" id="revoke" data-action="confirm-revoke" hidden></button>
|
|
92
|
-
</span>
|
|
93
|
-
<div class="p-footer-end p-footer-tools">
|
|
94
|
-
<button type="button" class="p-btn p-btn-ghost" id="p-open-extensions" data-action="open-extensions"></button>
|
|
95
|
-
<button type="button" class="p-btn p-btn-ghost" id="p-reload-extension" data-action="reload-extension"></button>
|
|
96
|
-
</div>
|
|
97
|
-
</footer>
|
|
98
|
-
|
|
99
|
-
<p class="p-sr-only" id="p-live" role="status" aria-live="polite"></p>
|
|
100
|
-
<p class="p-toast" id="p-toast" role="status" aria-live="polite"></p>
|
|
101
|
-
</div>
|
|
102
|
-
|
|
103
|
-
<dialog class="p-dialog" id="p-confirm" aria-labelledby="p-confirm-title" aria-describedby="p-confirm-body">
|
|
104
|
-
<h2 id="p-confirm-title"></h2>
|
|
105
|
-
<p id="p-confirm-body"></p>
|
|
106
|
-
<div class="p-actions p-dialog-actions"><button type="button" class="p-btn" id="p-confirm-cancel" data-action="cancel-confirm"></button><button type="button" class="p-btn" id="p-confirm-ok" data-action="do-confirm"></button></div>
|
|
107
|
-
</dialog>
|
|
108
|
-
<script type="module" src="popup.js"></script></body></html>
|
|
@@ -1,359 +0,0 @@
|
|
|
1
|
-
// The toolbar popup's DOM glue (popup.html). popup-view.js decides what is shown. Bridge actions go to the service
|
|
2
|
-
// worker (docs/browser-extension-bridge.md). The popup opens its own links and reloads the extension directly.
|
|
3
|
-
// Disconnect, Revoke pairing, a mode change and removing a shared site are confirmed first. Take back is immediate
|
|
4
|
-
// and keeps the tab open.
|
|
5
|
-
import { publicOrigin, hostPattern } from './protocol.js';
|
|
6
|
-
import { popupLocale, translator } from './popup-strings.js';
|
|
7
|
-
import { popupView } from './popup-view.js';
|
|
8
|
-
|
|
9
|
-
const $ = id => document.getElementById(id);
|
|
10
|
-
const locale = popupLocale([globalThis.chrome?.i18n?.getUILanguage?.(), ...(globalThis.navigator?.languages || []), globalThis.navigator?.language].filter(Boolean));
|
|
11
|
-
const t = translator(locale);
|
|
12
|
-
const coded = code => Object.assign(new Error(code), { code });
|
|
13
|
-
|
|
14
|
-
async function ask(message) {
|
|
15
|
-
const result = await chrome.runtime.sendMessage(message);
|
|
16
|
-
if (!result?.ok) throw Object.assign(new Error(result?.error || 'EXTENSION_UNAVAILABLE'), { code: result?.code || 'EXTENSION_UNAVAILABLE' });
|
|
17
|
-
return result;
|
|
18
|
-
}
|
|
19
|
-
// Whether a pairing credential is stored: its size only, never its value. null where the browser cannot say.
|
|
20
|
-
async function storedPairing() {
|
|
21
|
-
try { const bytes = await chrome.storage.local.getBytesInUse?.('credential'); return typeof bytes === 'number' ? bytes > 0 : null; }
|
|
22
|
-
catch { return null; }
|
|
23
|
-
}
|
|
24
|
-
// SynaBun's own address, from this extension's manifest (the setup page's content script names the app's origin).
|
|
25
|
-
function appOrigin() {
|
|
26
|
-
try {
|
|
27
|
-
const own = chrome.runtime.getManifest().content_scripts || [];
|
|
28
|
-
const pattern = own.flatMap(entry => entry.js?.includes('setup-content.js') ? entry.matches || [] : [])[0];
|
|
29
|
-
if (pattern) return new URL(pattern.replace(/\*$/, '')).origin;
|
|
30
|
-
} catch {}
|
|
31
|
-
return 'http://127.0.0.1:3344';
|
|
32
|
-
}
|
|
33
|
-
const openTab = url => chrome.tabs.create({ url });
|
|
34
|
-
|
|
35
|
-
// ── the words that never change while the popup is open ──
|
|
36
|
-
function fixedText() {
|
|
37
|
-
document.documentElement.lang = locale;
|
|
38
|
-
const set = (id, key) => { const node = $(id); if (node) node.textContent = t(key); };
|
|
39
|
-
let version;
|
|
40
|
-
try { version = chrome.runtime.getManifest().version; } catch {}
|
|
41
|
-
$('p-brand-sub').textContent = version ? `${t('brandSub')} · v${version}` : t('brandSub');
|
|
42
|
-
const openApp = $('p-open-app'); openApp.setAttribute('aria-label', t('openApp')); openApp.setAttribute('title', t('openApp'));
|
|
43
|
-
set('p-footer-app', 'openApp'); set('disconnect', 'disconnect'); set('revoke', 'revoke');
|
|
44
|
-
set('p-open-extensions', 'openExtensions'); set('p-reload-extension', 'reloadExtension');
|
|
45
|
-
set('p-mode-label', 'agentAccess'); set('p-mode-full', 'full'); set('p-mode-restricted', 'restricted');
|
|
46
|
-
set('p-empty-title', 'emptyTitle'); set('p-empty-help', 'emptyHelp');
|
|
47
|
-
set('p-shared-title', 'sharedSites'); set('p-shared-empty-title', 'noShared'); set('p-shared-empty-help', 'noSharedHelp'); set('p-waiting-title', 'sharedTabs');
|
|
48
|
-
set('share', 'shareTab'); set('site', 'shareSite'); set('p-newtabs-label', 'newTabs');
|
|
49
|
-
set('p-files-summary', 'advanced'); set('p-downloads-label', 'downloads'); set('p-download-note', 'downloadNote'); set('p-downloads-denied', 'downloadsDenied');
|
|
50
|
-
set('p-upload-title', 'uploadFolder'); set('p-upload-help', 'uploadHelpPopup'); set('p-limits', 'limits');
|
|
51
|
-
set('p-connection-summary', 'details'); set('p-bridge-label', 'bridge');
|
|
52
|
-
set('p-pair-summary', 'pairCode'); set('p-pair-help', 'pairCodeHelp'); set('p-port-label', 'pairPort'); set('p-code-label', 'pairCodeLabel'); set('p-pair-submit', 'pairAction');
|
|
53
|
-
set('p-confirm-cancel', 'cancel');
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// ── state ──
|
|
57
|
-
let view = null, lastState = '', refreshing = false, portTouched = false;
|
|
58
|
-
const busy = new Set(), rowErrors = new Set();
|
|
59
|
-
|
|
60
|
-
const SYMBOLS = { connected: 'good', disconnected: 'warn', connecting: 'sync', reconnecting: 'sync', loading: 'sync', error: 'bad', unpaired: 'link' };
|
|
61
|
-
const PRIMARY_LABEL = { resume: 'reconnect', connect: 'connect', retry: 'retry', 'open-app': 'openApp' };
|
|
62
|
-
|
|
63
|
-
// Children of `container` follow `items` in order, each kept by its key so focus and scroll survive a refresh.
|
|
64
|
-
function reconcile(container, items, key, make, update) {
|
|
65
|
-
const existing = new Map([...container.children].map(el => [el.dataset.key, el]));
|
|
66
|
-
items.forEach((item, i) => {
|
|
67
|
-
const k = key(item);
|
|
68
|
-
let el = existing.get(k);
|
|
69
|
-
if (!el) { el = make(item); el.dataset.key = k; }
|
|
70
|
-
existing.delete(k);
|
|
71
|
-
update(el, item);
|
|
72
|
-
if (container.children[i] !== el) container.insertBefore(el, container.children[i] || null);
|
|
73
|
-
});
|
|
74
|
-
for (const el of existing.values()) el.remove();
|
|
75
|
-
}
|
|
76
|
-
function element(tag, className, attrs = {}) {
|
|
77
|
-
const el = document.createElement(tag);
|
|
78
|
-
if (className) el.className = className;
|
|
79
|
-
for (const [name, value] of Object.entries(attrs)) el.setAttribute(name, value);
|
|
80
|
-
return el;
|
|
81
|
-
}
|
|
82
|
-
function textOnce(node, text) { if (node.textContent !== text) node.textContent = text; }
|
|
83
|
-
|
|
84
|
-
// A tab row: its title and safe address, and one action (Take back, or Stop sharing for a shared tab nobody holds).
|
|
85
|
-
function makeRow(kind) {
|
|
86
|
-
return () => {
|
|
87
|
-
const row = element('div', 'p-row');
|
|
88
|
-
const text = element('div', 'p-row-text');
|
|
89
|
-
text.append(element('span', 'p-row-title'), element('span', 'p-row-address'));
|
|
90
|
-
const button = element('button', 'p-btn', { type: 'button', 'data-action': kind });
|
|
91
|
-
const error = element('p', 'p-row-error', { role: 'alert' }); error.hidden = true;
|
|
92
|
-
row.append(text, button, error);
|
|
93
|
-
return row;
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
function updateRow(row, tab, { kind, agent = '', disabled }) {
|
|
97
|
-
row.dataset.handle = tab.handle; row.dataset.stale = String(!!disabled);
|
|
98
|
-
const [text, button, error] = row.children;
|
|
99
|
-
const [title, address] = text.children;
|
|
100
|
-
textOnce(title, tab.title); title.setAttribute('title', tab.title);
|
|
101
|
-
textOnce(address, tab.address);
|
|
102
|
-
button.dataset.handle = tab.handle;
|
|
103
|
-
const pending = busy.has(tab.handle);
|
|
104
|
-
textOnce(button, t(pending ? 'busy' : kind === 'take-back' ? 'takeBack' : 'stopSharing'));
|
|
105
|
-
button.setAttribute('aria-label', kind === 'take-back' ? t('takeBackLabel', { title: tab.title, agent }) : t('stopSharingLabel', { title: tab.title }));
|
|
106
|
-
button.disabled = !!disabled || pending;
|
|
107
|
-
error.hidden = !rowErrors.has(tab.handle);
|
|
108
|
-
textOnce(error, rowErrors.has(tab.handle) ? t('actionError') : '');
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function render(next) {
|
|
112
|
-
view = next;
|
|
113
|
-
const popup = $('popup');
|
|
114
|
-
popup.dataset.state = view.state; popup.setAttribute('aria-busy', 'false');
|
|
115
|
-
// status
|
|
116
|
-
const status = $('p-status'); status.dataset.tone = view.tone; status.dataset.sym = SYMBOLS[view.state] || 'sync';
|
|
117
|
-
textOnce($('p-status-title'), view.title); textOnce($('p-status-help'), view.help);
|
|
118
|
-
const primary = $('p-primary');
|
|
119
|
-
primary.hidden = !view.primary; $('p-status-actions').hidden = !view.primary;
|
|
120
|
-
if (view.primary) { primary.dataset.action = view.primary; textOnce(primary, t(PRIMARY_LABEL[view.primary])); primary.className = `p-btn ${view.primary === 'open-app' ? '' : 'p-btn-primary'}`.trim(); }
|
|
121
|
-
// A connection change is announced once, never every poll.
|
|
122
|
-
if (view.state !== lastState) { lastState = view.state; $('p-live').textContent = `${t('statusLabel')}: ${view.title}`; }
|
|
123
|
-
// agent access
|
|
124
|
-
$('p-mode').hidden = !view.showMode;
|
|
125
|
-
const chosen = view.full ? 'full' : 'restricted';
|
|
126
|
-
textOnce($('p-mode-value'), t(chosen));
|
|
127
|
-
for (const option of $('p-mode-list').children) option.setAttribute('aria-selected', String(option.dataset.value === chosen));
|
|
128
|
-
textOnce($('p-mode-help'), t(view.full ? 'fullHelp' : 'restrictedHelp'));
|
|
129
|
-
// activity: the tabs agents hold, by agent
|
|
130
|
-
$('p-activity').hidden = !view.showActivity;
|
|
131
|
-
const total = view.groups.reduce((sum, g) => sum + g.tabs.length, 0);
|
|
132
|
-
textOnce($('p-activity-title'), t(view.stale ? 'pausedTabs' : 'controlled'));
|
|
133
|
-
textOnce($('p-activity-count'), total ? String(total) : '');
|
|
134
|
-
$('p-activity-summary').hidden = !total; textOnce($('p-activity-summary'), view.summary);
|
|
135
|
-
reconcile($('p-groups'), view.groups, g => g.owner, () => {
|
|
136
|
-
const group = element('div', 'p-agent');
|
|
137
|
-
const heading = element('div', 'p-agent-heading');
|
|
138
|
-
heading.append(element('span', 'p-agent-mark', { 'aria-hidden': 'true' }), element('span', 'p-agent-name'));
|
|
139
|
-
group.append(heading, element('div', 'p-agent-tabs'));
|
|
140
|
-
return group;
|
|
141
|
-
}, (group, g) => {
|
|
142
|
-
const [heading, list] = group.children;
|
|
143
|
-
textOnce(heading.children[0], g.mark); textOnce(heading.children[1], g.label);
|
|
144
|
-
reconcile(list, g.tabs, tab => tab.handle, makeRow('take-back'), (row, tab) => updateRow(row, tab, { kind: 'take-back', agent: g.label, disabled: !view.live }));
|
|
145
|
-
});
|
|
146
|
-
$('p-empty').hidden = !(view.live && !total);
|
|
147
|
-
textOnce($('p-activity-help'), t(view.stale ? 'staleHelp' : 'takeBackHelp'));
|
|
148
|
-
$('p-activity-help').hidden = !total;
|
|
149
|
-
// restricted mode: what the owner shares
|
|
150
|
-
$('p-shared').hidden = !view.showShared;
|
|
151
|
-
reconcile($('p-sites'), view.sites, site => site, () => {
|
|
152
|
-
const row = element('div', 'p-row');
|
|
153
|
-
const text = element('div', 'p-row-text'); text.append(element('code', 'p-row-title'));
|
|
154
|
-
row.append(text, element('button', 'p-btn p-btn-ghost p-btn-danger', { type: 'button', 'data-action': 'confirm-site' }));
|
|
155
|
-
return row;
|
|
156
|
-
}, (row, site) => {
|
|
157
|
-
textOnce(row.children[0].children[0], site);
|
|
158
|
-
const button = row.children[1]; button.dataset.site = site; textOnce(button, t('removeSite')); button.setAttribute('aria-label', t('removeSiteLabel', { site }));
|
|
159
|
-
});
|
|
160
|
-
reconcile($('p-waiting'), view.showShared ? view.waiting : [], tab => tab.handle, makeRow('stop-sharing'), (row, tab) => updateRow(row, tab, { kind: 'stop-sharing', disabled: !view.live }));
|
|
161
|
-
$('p-waiting-title').hidden = !view.waiting.length;
|
|
162
|
-
$('p-shared-empty').hidden = !!(view.sites.length || view.waiting.length);
|
|
163
|
-
$('newTabs').checked = view.options.allowNewTabs; $('downloads').checked = view.options.downloads;
|
|
164
|
-
// files and limits, the typed code
|
|
165
|
-
$('p-files').hidden = !view.showFiles;
|
|
166
|
-
textOnce($('p-bridge'), `127.0.0.1:${view.port}`);
|
|
167
|
-
$('p-pair-code').hidden = !view.showPairCode;
|
|
168
|
-
if (!portTouched) $('port').value = String(view.port);
|
|
169
|
-
// footer
|
|
170
|
-
$('disconnect').hidden = !view.canDisconnect;
|
|
171
|
-
$('revoke').hidden = !view.canRevoke;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
async function refresh() {
|
|
175
|
-
if (refreshing) return;
|
|
176
|
-
refreshing = true;
|
|
177
|
-
try {
|
|
178
|
-
let result = null;
|
|
179
|
-
try { result = await ask({ action: 'status' }); } catch { result = null; }
|
|
180
|
-
render(popupView(result, { paired: result ? await storedPairing() : null, t }));
|
|
181
|
-
} finally { refreshing = false; }
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
// ── feedback ──
|
|
185
|
-
let toastTimer;
|
|
186
|
-
function toast(text, tone = '') {
|
|
187
|
-
const node = $('p-toast'); node.textContent = text; node.dataset.tone = tone;
|
|
188
|
-
clearTimeout(toastTimer); toastTimer = setTimeout(() => { node.textContent = ''; }, 6000);
|
|
189
|
-
}
|
|
190
|
-
function failure(error) {
|
|
191
|
-
const code = String(error?.code || '');
|
|
192
|
-
if (code === 'SITE_DENIED') return t('siteDenied');
|
|
193
|
-
if (code === 'EXTENSION_UNAVAILABLE') return t('unavailable');
|
|
194
|
-
return t('actionFailed', { code: code || 'OPERATION_FAILED' });
|
|
195
|
-
}
|
|
196
|
-
// Runs one owner action, says how it went, and shows the worker's state after it.
|
|
197
|
-
async function run(fn, done) {
|
|
198
|
-
try { await fn(); if (done) toast(done); }
|
|
199
|
-
catch (error) { toast(failure(error), 'bad'); }
|
|
200
|
-
await refresh();
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
// ── confirmations (a styled <dialog>; Cancel has the focus first; focus returns where it came from) ──
|
|
204
|
-
const CONFIRMS = {
|
|
205
|
-
disconnect: ['disconnectTitle', 'disconnectBody', 'disconnect', 'danger'],
|
|
206
|
-
revoke: ['revokeTitle', 'revokeBody', 'revoke', 'danger'],
|
|
207
|
-
restrict: ['restrictTitle', 'restrictBody', 'restrictConfirm', 'primary'],
|
|
208
|
-
full: ['fullTitle', 'fullBody', 'fullConfirm', 'primary'],
|
|
209
|
-
site: ['removeTitle', 'removeBody', 'removeSite', 'danger'],
|
|
210
|
-
};
|
|
211
|
-
let pending = null;
|
|
212
|
-
function confirmFirst(kind, opener, action) {
|
|
213
|
-
const [title, body, ok, tone] = CONFIRMS[kind];
|
|
214
|
-
const dialog = $('p-confirm');
|
|
215
|
-
$('p-confirm-title').textContent = t(title); $('p-confirm-body').textContent = t(body);
|
|
216
|
-
const button = $('p-confirm-ok'); button.textContent = t(ok); button.className = `p-btn p-btn-${tone}`;
|
|
217
|
-
dialog.dataset.kind = kind;
|
|
218
|
-
pending = { action, opener };
|
|
219
|
-
if (typeof dialog.showModal === 'function') dialog.showModal(); else dialog.setAttribute('open', '');
|
|
220
|
-
$('p-confirm-cancel').focus();
|
|
221
|
-
}
|
|
222
|
-
function closeConfirm() {
|
|
223
|
-
const dialog = $('p-confirm'), opener = pending?.opener;
|
|
224
|
-
pending = null;
|
|
225
|
-
if (typeof dialog.close === 'function' && dialog.open) dialog.close(); else dialog.removeAttribute('open');
|
|
226
|
-
if (opener?.isConnected && !opener.hidden) opener.focus(); else $('p-status-title').focus?.();
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
// ── the mode dropdown: the app's .cc-dropdown keyboard model (never a native select) ──
|
|
230
|
-
const trigger = () => $('p-mode-trigger'), options = () => [...$('p-mode-list').children];
|
|
231
|
-
let highlighted = 0, typed = '', typedAt = 0;
|
|
232
|
-
function openMenu(open) {
|
|
233
|
-
const menu = $('p-mode-list');
|
|
234
|
-
menu.hidden = !open; trigger().setAttribute('aria-expanded', String(open));
|
|
235
|
-
if (open) highlight(options().findIndex(o => o.getAttribute('aria-selected') === 'true'));
|
|
236
|
-
else { trigger().removeAttribute('aria-activedescendant'); for (const o of options()) o.classList.remove('p-highlight'); }
|
|
237
|
-
}
|
|
238
|
-
function highlight(index) {
|
|
239
|
-
const list = options();
|
|
240
|
-
highlighted = Math.max(0, Math.min(list.length - 1, index));
|
|
241
|
-
list.forEach((o, i) => o.classList.toggle('p-highlight', i === highlighted));
|
|
242
|
-
trigger().setAttribute('aria-activedescendant', list[highlighted].id);
|
|
243
|
-
}
|
|
244
|
-
function choose(value) {
|
|
245
|
-
openMenu(false); trigger().focus();
|
|
246
|
-
const full = value === 'full';
|
|
247
|
-
if (!view || full === view.full) return;
|
|
248
|
-
confirmFirst(full ? 'full' : 'restrict', trigger(), () => run(() => ask({ action: 'mode', fullControl: full }), t('modeSaved')));
|
|
249
|
-
}
|
|
250
|
-
function menuKey(event) {
|
|
251
|
-
const open = trigger().getAttribute('aria-expanded') === 'true', list = options();
|
|
252
|
-
if (event.key === 'Tab') { if (open) openMenu(false); return; }
|
|
253
|
-
if (event.key === 'Escape') { if (open) { event.preventDefault(); openMenu(false); } return; }
|
|
254
|
-
if (['ArrowDown', 'ArrowUp', 'Home', 'End', 'PageDown', 'PageUp', 'Enter', ' '].includes(event.key)) {
|
|
255
|
-
event.preventDefault();
|
|
256
|
-
if (!open) { openMenu(true); return; }
|
|
257
|
-
if (event.key === 'Enter' || event.key === ' ') { choose(list[highlighted].dataset.value); return; }
|
|
258
|
-
const step = { ArrowDown: 1, ArrowUp: -1, PageDown: 10, PageUp: -10 }[event.key];
|
|
259
|
-
highlight(event.key === 'Home' ? 0 : event.key === 'End' ? list.length - 1 : highlighted + step);
|
|
260
|
-
return;
|
|
261
|
-
}
|
|
262
|
-
if (event.key?.length === 1 && !event.ctrlKey && !event.metaKey && !event.altKey) {
|
|
263
|
-
if (Date.now() - typedAt > 600) typed = '';
|
|
264
|
-
typedAt = Date.now(); typed += event.key.toLowerCase();
|
|
265
|
-
if (!open) openMenu(true);
|
|
266
|
-
const i = list.findIndex(o => o.textContent.toLowerCase().startsWith(typed));
|
|
267
|
-
if (i >= 0) highlight(i);
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
// ── actions ──
|
|
272
|
-
function nextFocus(button) {
|
|
273
|
-
// After a row leaves, the focus goes to the next row's action, else the previous one, else the section title.
|
|
274
|
-
const all = [...$('popup').querySelectorAll('[data-action="take-back"]')];
|
|
275
|
-
const i = all.indexOf(button);
|
|
276
|
-
return all[i + 1] || all[i - 1] || null;
|
|
277
|
-
}
|
|
278
|
-
async function takeBack(button, verb) {
|
|
279
|
-
const handle = button.dataset.handle;
|
|
280
|
-
if (!handle || busy.has(handle)) return;
|
|
281
|
-
const after = nextFocus(button);
|
|
282
|
-
busy.add(handle); rowErrors.delete(handle); render(view);
|
|
283
|
-
let ok = false;
|
|
284
|
-
try { await ask({ action: 'revokeTab', tab: handle }); ok = true; }
|
|
285
|
-
catch { rowErrors.add(handle); }
|
|
286
|
-
finally { busy.delete(handle); }
|
|
287
|
-
await refresh();
|
|
288
|
-
if (ok) {
|
|
289
|
-
toast(t(verb === 'take-back' ? 'takenBack' : 'saved'));
|
|
290
|
-
if (!button.isConnected) (after?.isConnected ? after : $('p-activity-title'))?.focus?.();
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
async function act(action, target) {
|
|
294
|
-
if (action === 'open-app') { await openTab(`${appOrigin()}/`); return; }
|
|
295
|
-
if (action === 'open-extensions') {
|
|
296
|
-
try { await openTab('chrome://extensions/'); }
|
|
297
|
-
catch { toast(t('openExtensionsFailed'), 'bad'); }
|
|
298
|
-
return;
|
|
299
|
-
}
|
|
300
|
-
if (action === 'reload-extension') {
|
|
301
|
-
try { chrome.runtime.reload(); }
|
|
302
|
-
catch { toast(t('reloadExtensionFailed'), 'bad'); }
|
|
303
|
-
return;
|
|
304
|
-
}
|
|
305
|
-
if (action === 'connect') { await openTab(`${appOrigin()}/extension-setup`); toast(t('connectOpened')); return; }
|
|
306
|
-
if (action === 'retry') { await refresh(); return; }
|
|
307
|
-
if (action === 'resume') { await run(() => ask({ action: 'resume' }), t('reconnectingToast')); return; }
|
|
308
|
-
if (action === 'confirm-disconnect') { confirmFirst('disconnect', target, () => run(() => ask({ action: 'disconnect' }), t('disconnectedToast'))); return; }
|
|
309
|
-
if (action === 'confirm-revoke') { confirmFirst('revoke', target, () => run(() => ask({ action: 'revoke' }), t('revokedToast'))); return; }
|
|
310
|
-
if (action === 'confirm-site') { const site = target.dataset.site; confirmFirst('site', target, () => run(() => ask({ action: 'revokeSite', site }), t('saved'))); return; }
|
|
311
|
-
if (action === 'take-back' || action === 'stop-sharing') { await takeBack(target, action); return; }
|
|
312
|
-
if (action === 'cancel-confirm') { closeConfirm(); return; }
|
|
313
|
-
if (action === 'do-confirm') { const next = pending?.action; closeConfirm(); if (next) await next(); return; }
|
|
314
|
-
// Restricted mode: share the browser's active tab (and its site), or only its site for new tabs. The site permission
|
|
315
|
-
// is asked in this click, as before.
|
|
316
|
-
if (action === 'share' || action === 'site') {
|
|
317
|
-
const siteOnly = action === 'site';
|
|
318
|
-
await run(async () => {
|
|
319
|
-
const tab = (await chrome.tabs.query({ active: true, currentWindow: true }))[0];
|
|
320
|
-
const site = publicOrigin(tab?.url);
|
|
321
|
-
if (!await chrome.permissions.request({ origins: [hostPattern(site)] })) throw coded('SITE_DENIED');
|
|
322
|
-
await ask({ action: 'share', tab: tab.id, siteOnly });
|
|
323
|
-
}, t(siteOnly ? 'siteToast' : 'sharedToast'));
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
function wire() {
|
|
328
|
-
document.addEventListener('click', event => {
|
|
329
|
-
const option = event.target.closest?.('[role="option"]');
|
|
330
|
-
if (option && $('p-mode-list').contains(option)) { choose(option.dataset.value); return; }
|
|
331
|
-
if (event.target.closest?.('.p-dropdown-trigger')) { openMenu(trigger().getAttribute('aria-expanded') !== 'true'); return; }
|
|
332
|
-
const target = event.target.closest?.('[data-action]');
|
|
333
|
-
if (target && !target.disabled) void act(target.dataset.action, target);
|
|
334
|
-
});
|
|
335
|
-
trigger().addEventListener('keydown', menuKey);
|
|
336
|
-
document.addEventListener('pointerdown', event => { if (!event.target.closest?.('.p-dropdown')) openMenu(false); });
|
|
337
|
-
const dialog = $('p-confirm');
|
|
338
|
-
// Escape cancels (the dialog's own cancel event); the focus goes back to the control that opened it.
|
|
339
|
-
dialog.addEventListener('cancel', event => { event.preventDefault(); closeConfirm(); });
|
|
340
|
-
for (const id of ['newTabs', 'downloads']) $(id).addEventListener('change', () => run(async () => {
|
|
341
|
-
$('p-downloads-denied').hidden = true;
|
|
342
|
-
if (id === 'downloads' && $('downloads').checked && !await chrome.permissions.request({ permissions: ['downloads'] })) {
|
|
343
|
-
$('downloads').checked = false; $('p-downloads-denied').hidden = false; $('p-files').open = true;
|
|
344
|
-
}
|
|
345
|
-
await ask({ action: 'options', options: { allowNewTabs: $('newTabs').checked, downloads: $('downloads').checked } });
|
|
346
|
-
}, t('saved')));
|
|
347
|
-
$('port').addEventListener('input', () => { portTouched = true; });
|
|
348
|
-
$('pair').addEventListener('submit', event => {
|
|
349
|
-
event.preventDefault();
|
|
350
|
-
void run(async () => { await ask({ action: 'pair', code: $('code').value, port: Number($('port').value) }); $('code').value = ''; }, t('pairStarted'));
|
|
351
|
-
});
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
fixedText();
|
|
355
|
-
wire();
|
|
356
|
-
render(popupView(undefined, { t }));
|
|
357
|
-
await refresh();
|
|
358
|
-
const timer = setInterval(() => { void refresh(); }, 1500);
|
|
359
|
-
window.addEventListener('unload', () => clearInterval(timer));
|