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
|
@@ -31,7 +31,11 @@ export function createStickyScrollController(container, options = {}) {
|
|
|
31
31
|
let frameId = 0;
|
|
32
32
|
let generation = 0;
|
|
33
33
|
let touchY = null;
|
|
34
|
+
let pointerDown = false;
|
|
35
|
+
let pointerScrolled = false;
|
|
34
36
|
let lastScrollTop = container.scrollTop;
|
|
37
|
+
let lastScrollHeight = null;
|
|
38
|
+
let lastClientHeight = null;
|
|
35
39
|
|
|
36
40
|
const distanceFromBottom = () => Math.max(
|
|
37
41
|
0,
|
|
@@ -60,6 +64,8 @@ export function createStickyScrollController(container, options = {}) {
|
|
|
60
64
|
container.scrollTop = container.scrollHeight;
|
|
61
65
|
}
|
|
62
66
|
lastScrollTop = container.scrollTop;
|
|
67
|
+
lastScrollHeight = container.scrollHeight;
|
|
68
|
+
lastClientHeight = container.clientHeight;
|
|
63
69
|
};
|
|
64
70
|
|
|
65
71
|
// A transcript inside a closed side panel is not drawn (ui-sidepanel-windows.js: data-sp-visible="false",
|
|
@@ -127,25 +133,83 @@ export function createStickyScrollController(container, options = {}) {
|
|
|
127
133
|
if (hasScrollableContent()) setFollowing(false);
|
|
128
134
|
};
|
|
129
135
|
|
|
136
|
+
const onPointerDown = (event) => {
|
|
137
|
+
if (event?.target && event.target !== container) return;
|
|
138
|
+
pointerDown = true;
|
|
139
|
+
pointerScrolled = false;
|
|
140
|
+
};
|
|
141
|
+
const onPointerUp = () => {
|
|
142
|
+
if (!pointerDown) return;
|
|
143
|
+
const scrolled = pointerScrolled;
|
|
144
|
+
pointerDown = false;
|
|
145
|
+
pointerScrolled = false;
|
|
146
|
+
if (disposed || !active || !scrolled) return;
|
|
147
|
+
if (!following && refreshPosition()) scrollToBottom();
|
|
148
|
+
};
|
|
149
|
+
|
|
130
150
|
const onScroll = () => {
|
|
131
151
|
const nextScrollTop = container.scrollTop;
|
|
132
|
-
const
|
|
152
|
+
const nextScrollHeight = container.scrollHeight;
|
|
153
|
+
const nextClientHeight = container.clientHeight;
|
|
154
|
+
if (pointerDown) pointerScrolled = true;
|
|
155
|
+
const prevScrollTop = lastScrollTop;
|
|
156
|
+
const prevScrollHeight = lastScrollHeight;
|
|
157
|
+
const prevClientHeight = lastClientHeight;
|
|
158
|
+
const movedUp = nextScrollTop < prevScrollTop - 1;
|
|
133
159
|
lastScrollTop = nextScrollTop;
|
|
134
|
-
|
|
135
|
-
|
|
160
|
+
lastScrollHeight = nextScrollHeight;
|
|
161
|
+
lastClientHeight = nextClientHeight;
|
|
162
|
+
|
|
163
|
+
const remaining = Math.max(0, nextScrollHeight - nextScrollTop - nextClientHeight);
|
|
164
|
+
if (movedUp && remaining > 1) {
|
|
165
|
+
const maxShrankBy = (prevScrollHeight != null && prevClientHeight != null)
|
|
166
|
+
? Math.max(0, (prevScrollHeight - prevClientHeight) - (nextScrollHeight - nextClientHeight))
|
|
167
|
+
: 0;
|
|
168
|
+
const clientGrewBy = prevClientHeight != null ? Math.max(0, nextClientHeight - prevClientHeight) : 0;
|
|
169
|
+
const layoutShrink = Math.max(maxShrankBy, clientGrewBy);
|
|
170
|
+
// A layout shrink (composer collapsing, top rows pruned/collapsed, streamed row
|
|
171
|
+
// replaced, or zoom) makes the engine clamp scrollTop downward without user intent.
|
|
172
|
+
// Keep following when no user pointer/wheel/key/touch gesture is active and either a
|
|
173
|
+
// follow frame is already queued from the mutation/resize or the shrinkage accounts
|
|
174
|
+
// for the drop.
|
|
175
|
+
const clampedByLayout = following && !pointerDown && (
|
|
176
|
+
frameId !== 0
|
|
177
|
+
|| (layoutShrink > 0 && (prevScrollTop - nextScrollTop) <= layoutShrink + 2)
|
|
178
|
+
);
|
|
179
|
+
if (!clampedByLayout) {
|
|
180
|
+
setFollowing(false);
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
// Never yank the scrollbar out of the user's hand mid-drag; wait for release or true bottom.
|
|
185
|
+
if (pointerDown) {
|
|
186
|
+
if (remaining <= 1) setFollowing(true);
|
|
136
187
|
return;
|
|
137
188
|
}
|
|
138
189
|
// A scroll event caused by writeBottom() may arrive after more streamed
|
|
139
190
|
// content has already increased scrollHeight. In that case the viewport
|
|
140
191
|
// is temporarily far from the new bottom without having moved upward.
|
|
141
192
|
// Preserve follow mode so the queued mutation/resize frame can catch up.
|
|
193
|
+
if (following) {
|
|
194
|
+
if (remaining > 0.5) scrollToBottom();
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
// Detached: only a scroll back down near the bottom follows again. An animated key or wheel scroll upward
|
|
198
|
+
// (WebKit's PageUp / ArrowUp) can step 1 px or less, under movedUp's 1 px; treating that step as "near the
|
|
199
|
+
// bottom" re-attached and the follow frame snapped the reader back, cancelling their scroll.
|
|
200
|
+
if (nextScrollTop < prevScrollTop) return;
|
|
142
201
|
if (refreshPosition()) scrollToBottom();
|
|
143
202
|
};
|
|
144
203
|
const onWheel = (event) => {
|
|
145
204
|
if (event.deltaY < 0) detachForUpwardIntent();
|
|
146
205
|
};
|
|
147
206
|
const onKeyDown = (event) => {
|
|
148
|
-
if (
|
|
207
|
+
if (
|
|
208
|
+
event.key === 'PageUp'
|
|
209
|
+
|| event.key === 'ArrowUp'
|
|
210
|
+
|| event.key === 'Home'
|
|
211
|
+
|| (event.key === ' ' && event.shiftKey)
|
|
212
|
+
) {
|
|
149
213
|
detachForUpwardIntent();
|
|
150
214
|
}
|
|
151
215
|
};
|
|
@@ -156,14 +220,27 @@ export function createStickyScrollController(container, options = {}) {
|
|
|
156
220
|
touchY = nextY;
|
|
157
221
|
};
|
|
158
222
|
const onTouchEnd = () => { touchY = null; };
|
|
223
|
+
const fonts = container.ownerDocument?.fonts;
|
|
224
|
+
const onFontsDone = () => { if (!disposed) scrollToBottom(); };
|
|
159
225
|
|
|
160
226
|
container.addEventListener('scroll', onScroll, { passive: true });
|
|
161
227
|
container.addEventListener('wheel', onWheel, { passive: true });
|
|
162
228
|
container.addEventListener('keydown', onKeyDown);
|
|
229
|
+
container.addEventListener('pointerdown', onPointerDown, { passive: true });
|
|
230
|
+
container.addEventListener('mousedown', onPointerDown, { passive: true });
|
|
163
231
|
container.addEventListener('touchstart', onTouchStart, { passive: true });
|
|
164
232
|
container.addEventListener('touchmove', onTouchMove, { passive: true });
|
|
165
233
|
container.addEventListener('touchend', onTouchEnd, { passive: true });
|
|
166
234
|
container.addEventListener('touchcancel', onTouchEnd, { passive: true });
|
|
235
|
+
if (typeof view?.addEventListener === 'function') {
|
|
236
|
+
view.addEventListener('pointerup', onPointerUp, { passive: true });
|
|
237
|
+
view.addEventListener('pointercancel', onPointerUp, { passive: true });
|
|
238
|
+
view.addEventListener('mouseup', onPointerUp, { passive: true });
|
|
239
|
+
view.addEventListener('blur', onPointerUp, { passive: true });
|
|
240
|
+
}
|
|
241
|
+
if (typeof fonts?.addEventListener === 'function') {
|
|
242
|
+
fonts.addEventListener('loadingdone', onFontsDone);
|
|
243
|
+
}
|
|
167
244
|
|
|
168
245
|
const ResizeObserverCtor = view.ResizeObserver || globalThis.ResizeObserver;
|
|
169
246
|
const MutationObserverCtor = view.MutationObserver || globalThis.MutationObserver;
|
|
@@ -184,7 +261,12 @@ export function createStickyScrollController(container, options = {}) {
|
|
|
184
261
|
for (const child of current) {
|
|
185
262
|
if (observedChildren.has(child)) continue;
|
|
186
263
|
observedChildren.add(child);
|
|
187
|
-
|
|
264
|
+
// Observe border-box so row padding/border changes also trigger bottom lock.
|
|
265
|
+
try {
|
|
266
|
+
resizeObserver.observe(child, { box: 'border-box' });
|
|
267
|
+
} catch {
|
|
268
|
+
resizeObserver.observe(child);
|
|
269
|
+
}
|
|
188
270
|
}
|
|
189
271
|
};
|
|
190
272
|
resizeObserver?.observe(container);
|
|
@@ -203,7 +285,7 @@ export function createStickyScrollController(container, options = {}) {
|
|
|
203
285
|
childList: true,
|
|
204
286
|
characterData: true,
|
|
205
287
|
attributes: true,
|
|
206
|
-
attributeFilter: ['class', 'hidden', 'open', 'style'],
|
|
288
|
+
attributeFilter: ['class', 'hidden', 'open', 'style', 'data-state', 'aria-expanded', 'aria-hidden'],
|
|
207
289
|
});
|
|
208
290
|
|
|
209
291
|
const controller = {
|
|
@@ -222,6 +304,8 @@ export function createStickyScrollController(container, options = {}) {
|
|
|
222
304
|
destroy() {
|
|
223
305
|
if (disposed) return;
|
|
224
306
|
disposed = true;
|
|
307
|
+
pointerDown = false;
|
|
308
|
+
pointerScrolled = false;
|
|
225
309
|
cancelScheduled();
|
|
226
310
|
stopWaitingForHost();
|
|
227
311
|
resizeObserver?.disconnect();
|
|
@@ -230,10 +314,21 @@ export function createStickyScrollController(container, options = {}) {
|
|
|
230
314
|
container.removeEventListener('scroll', onScroll);
|
|
231
315
|
container.removeEventListener('wheel', onWheel);
|
|
232
316
|
container.removeEventListener('keydown', onKeyDown);
|
|
317
|
+
container.removeEventListener('pointerdown', onPointerDown);
|
|
318
|
+
container.removeEventListener('mousedown', onPointerDown);
|
|
233
319
|
container.removeEventListener('touchstart', onTouchStart);
|
|
234
320
|
container.removeEventListener('touchmove', onTouchMove);
|
|
235
321
|
container.removeEventListener('touchend', onTouchEnd);
|
|
236
322
|
container.removeEventListener('touchcancel', onTouchEnd);
|
|
323
|
+
if (typeof view?.removeEventListener === 'function') {
|
|
324
|
+
view.removeEventListener('pointerup', onPointerUp);
|
|
325
|
+
view.removeEventListener('pointercancel', onPointerUp);
|
|
326
|
+
view.removeEventListener('mouseup', onPointerUp);
|
|
327
|
+
view.removeEventListener('blur', onPointerUp);
|
|
328
|
+
}
|
|
329
|
+
if (typeof fonts?.removeEventListener === 'function') {
|
|
330
|
+
fonts.removeEventListener('loadingdone', onFontsDone);
|
|
331
|
+
}
|
|
237
332
|
controllers.delete(container);
|
|
238
333
|
},
|
|
239
334
|
};
|
|
@@ -953,7 +953,7 @@ async function stopLoop(terminalSessionId, sessionId) {
|
|
|
953
953
|
await fetch('/api/loop/stop', {
|
|
954
954
|
method: 'POST',
|
|
955
955
|
headers: { 'Content-Type': 'application/json' },
|
|
956
|
-
body: JSON.stringify({ terminalSessionId }),
|
|
956
|
+
body: JSON.stringify({ terminalSessionId, action: 'stop' }),
|
|
957
957
|
});
|
|
958
958
|
await refreshSessions();
|
|
959
959
|
} catch {}
|
|
@@ -972,7 +972,7 @@ async function clearAllLoops() {
|
|
|
972
972
|
await fetch('/api/loop/stop', {
|
|
973
973
|
method: 'POST',
|
|
974
974
|
headers: { 'Content-Type': 'application/json' },
|
|
975
|
-
body: JSON.stringify({}),
|
|
975
|
+
body: JSON.stringify({ action: 'stop' }),
|
|
976
976
|
});
|
|
977
977
|
await refreshSessions();
|
|
978
978
|
} catch {}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
// and the skin are iface-config.js.
|
|
9
9
|
|
|
10
10
|
import { on } from './state.js';
|
|
11
|
+
import { t } from './i18n.js';
|
|
11
12
|
import { registerAction } from './ui-keybinds.js';
|
|
12
13
|
import { registerLaunchPrefetch } from './launch-prefetch.js';
|
|
13
14
|
import { prefetchSettingsData, refreshSettingsData } from './settings/settings-data.js';
|
|
@@ -25,6 +26,13 @@ function reopenWanted() {
|
|
|
25
26
|
try { return !!globalThis.sessionStorage?.getItem(SETTINGS_REOPEN_KEY); } catch { return false; }
|
|
26
27
|
}
|
|
27
28
|
|
|
29
|
+
/** settings-backup-encryption.js's RESTORE_OUTCOME_KEY: a restore that finished with problems, not yet read by the owner. */
|
|
30
|
+
export const RESTORE_OUTCOME_KEY = 'synabun-restore-outcome';
|
|
31
|
+
|
|
32
|
+
function restoreOutcomeWaiting() {
|
|
33
|
+
try { return !!globalThis.sessionStorage?.getItem(RESTORE_OUTCOME_KEY); } catch { return false; }
|
|
34
|
+
}
|
|
35
|
+
|
|
28
36
|
let _initialized = false;
|
|
29
37
|
export function initSettings() {
|
|
30
38
|
if (_initialized) return;
|
|
@@ -43,6 +51,16 @@ export function initSettings() {
|
|
|
43
51
|
// A language change reloaded the app: open Settings again where the user was, once the rest of the app has started.
|
|
44
52
|
if (reopenWanted()) setTimeout(() => { settingsModule.call('reopenSettingsAfterReload', []); }, 0);
|
|
45
53
|
|
|
54
|
+
// A restore that finished with problems, and the reload or restart after it: its message is still owed. Its module
|
|
55
|
+
// loads only then.
|
|
56
|
+
if (restoreOutcomeWaiting()) {
|
|
57
|
+
setTimeout(() => {
|
|
58
|
+
import('./settings/settings-backup-encryption-pane.js')
|
|
59
|
+
.then(({ showWaitingRestoreOutcome }) => showWaitingRestoreOutcome({ tx: t }))
|
|
60
|
+
.catch((error) => console.warn('[settings] could not show the restore outcome:', error?.message));
|
|
61
|
+
}, 0);
|
|
62
|
+
}
|
|
63
|
+
|
|
46
64
|
// Launch: what Settings is built from, and its search index (the English names too), read and made once the
|
|
47
65
|
// page has painted, so the first open and the first search wait for nothing. The index needs the window's module:
|
|
48
66
|
// this step is what loads it in idle time.
|
|
@@ -43,6 +43,10 @@ import { initI18n, isReady as i18nReady, SUPPORTED_LOCALES, LOCALE_NAMES, SYSTEM
|
|
|
43
43
|
import { wireSettingsShell, wireSettingsSearch, collectSearchRows, revealSettingsTarget, followSettingsTarget, onSettingsTakeover, applyStoredSections, storeSectionState } from './settings/settings-shell.js';
|
|
44
44
|
import { buildSettingsSearchIndex } from './settings/settings-search.js';
|
|
45
45
|
import { prefetchSettingsData, readSettingsData, refreshSettingsData } from './settings/settings-data.js';
|
|
46
|
+
import { BACKUP_BROWSER_URL, createBackupDownloadController, createBackupEndWatcher, describeBackupDownload } from './settings/settings-backup-download.js';
|
|
47
|
+
import { createBackupContentsController, describeBackupContents, describeRestoreContents } from './settings/settings-backup-contents.js';
|
|
48
|
+
import { applyEncryptedRestore, clearRestoreOutcome, describeEncryptedRestore, describeRestoreCreated, discardEncryptedRestore, previewErrorMessage, restoreErrorMessage, restorePartialCodes, saveRestoreOutcome } from './settings/settings-backup-encryption.js';
|
|
49
|
+
import { askRestorePassword, backupEncryptionHTML, backupHistoryHTML, openRestoreOutcomeDialog, RESTORE_DIALOG_CLASS, wireBackupEncryption } from './settings/settings-backup-encryption-pane.js';
|
|
46
50
|
import { registerLaunchPrefetch } from './launch-prefetch.js';
|
|
47
51
|
// ═══════════════════════════════════════════
|
|
48
52
|
// UI-SETTINGS — Settings modal with shared tabs + variant tab injection
|
|
@@ -511,13 +515,40 @@ function buildServerTab(settings, connections = []) {
|
|
|
511
515
|
id: 'stg-sec-backups', section: 'memory_backups.backups',
|
|
512
516
|
status: kit.pill('', { id: 'auto-backup-pill', state: 'off' }),
|
|
513
517
|
body: `
|
|
518
|
+
${kit.subhead(kit.te('settings.redesign.server.backupContentsTitle'), { id: 'sys-backup-contents-title' })}
|
|
519
|
+
<div class="stg-help" id="sys-backup-contents-help">${kit.te('settings.redesign.server.backupContentsHelp')}</div>
|
|
520
|
+
<div id="sys-backup-contents-rows" role="group" aria-labelledby="sys-backup-contents-title"></div>
|
|
521
|
+
<div class="stg-field" id="sys-backup-contents-summary" style="display:none">
|
|
522
|
+
<div class="stg-help" id="sys-backup-contents-total" role="status" aria-live="polite"></div>
|
|
523
|
+
<div class="stg-help" id="sys-backup-contents-warning" role="alert" style="display:none;color:var(--stg-warn)"></div>
|
|
524
|
+
<div class="stg-help" id="sys-backup-contents-never"></div>
|
|
525
|
+
<div class="stg-action-row">
|
|
526
|
+
<button type="button" class="cc-copy-btn stg-text-btn" id="sys-backup-contents-refresh">${kit.te('settings.redesign.server.backupContentsRefresh')}</button>
|
|
527
|
+
</div>
|
|
528
|
+
</div>
|
|
529
|
+
<div class="stg-help" id="sys-backup-contents-note" role="status" aria-live="polite" style="display:none;color:var(--accent-dim)"></div>
|
|
530
|
+
|
|
531
|
+
${backupEncryptionHTML(kit)}
|
|
532
|
+
|
|
514
533
|
${kit.subhead(kit.te('settings.redesign.server.fullBackup'))}
|
|
534
|
+
<div class="stg-field stg-inline-field">
|
|
535
|
+
<label for="sys-backup-folder">${kit.te('settings.redesign.server.backupFolderLabel')}</label>
|
|
536
|
+
<div class="stg-input-row">
|
|
537
|
+
<input type="text" id="sys-backup-folder" placeholder="${kit.te('settings.redesign.server.folderPlaceholder')}" readonly autocomplete="off" spellcheck="false" aria-describedby="sys-backup-folder-help">
|
|
538
|
+
<button type="button" class="stg-action-btn compact" id="sys-backup-browse" disabled>${kit.te('settings.redesign.server.backupFolderChoose')}</button>
|
|
539
|
+
</div>
|
|
540
|
+
<div class="stg-help" id="sys-backup-folder-help">${kit.te('settings.redesign.server.backupFolderHelp')}</div>
|
|
541
|
+
<div class="stg-help" id="sys-backup-folder-note" role="status" aria-live="polite" style="display:none;color:var(--accent-dim)"></div>
|
|
542
|
+
</div>
|
|
515
543
|
<div class="stg-field" ${kit.inv('GEN007')}>
|
|
516
544
|
<div class="stg-action-row">
|
|
517
545
|
<button type="button" class="stg-action-btn" id="sys-backup-btn" aria-describedby="sys-backup-btn-help">
|
|
518
546
|
${buttonIcon('<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/>')}
|
|
519
547
|
${kit.L('GEN007')}
|
|
520
548
|
</button>
|
|
549
|
+
<button type="button" class="stg-action-btn compact" id="sys-backup-cancel" style="display:none">${kit.te('settings.redesign.server.backupCancel')}</button>
|
|
550
|
+
<button type="button" class="stg-action-btn compact" id="sys-backup-reveal" style="display:none">${kit.te('settings.redesign.server.backupReveal')}</button>
|
|
551
|
+
<button type="button" class="cc-copy-btn stg-text-btn" id="sys-backup-browser" title="${kit.te('settings.redesign.server.backupBrowserDownloadHelp')}" style="display:none">${kit.te('settings.redesign.server.backupBrowserDownload')}</button>
|
|
521
552
|
</div>
|
|
522
553
|
${kit.help('GEN007', { forId: 'sys-backup-btn' })}
|
|
523
554
|
</div>
|
|
@@ -527,7 +558,7 @@ function buildServerTab(settings, connections = []) {
|
|
|
527
558
|
${buttonIcon('<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" y1="3" x2="12" y2="15"/>')}
|
|
528
559
|
${kit.L('GEN008')}
|
|
529
560
|
</button>
|
|
530
|
-
<input type="file" id="sys-restore-file" ${kit.inv('GEN009')} accept=".zip" style="display:none" aria-label="${kit.L('GEN009')}" title="${kit.H('GEN009')}">
|
|
561
|
+
<input type="file" id="sys-restore-file" ${kit.inv('GEN009')} accept=".zip,.enc" style="display:none" aria-label="${kit.L('GEN009')}" title="${kit.H('GEN009')}">
|
|
531
562
|
</div>
|
|
532
563
|
${kit.help('GEN008', { forId: 'sys-restore-btn' })}
|
|
533
564
|
</div>
|
|
@@ -536,6 +567,8 @@ function buildServerTab(settings, connections = []) {
|
|
|
536
567
|
<span id="sys-backup-text"></span>
|
|
537
568
|
</div>
|
|
538
569
|
|
|
570
|
+
${backupHistoryHTML(kit)}
|
|
571
|
+
|
|
539
572
|
${kit.subhead(kit.te('settings.redesign.server.autoBackup'))}
|
|
540
573
|
${kit.toggleField('GEN010', kit.switchInput('auto-backup-toggle'), { forId: 'auto-backup-toggle' })}
|
|
541
574
|
<div id="auto-backup-options" style="display:none">
|
|
@@ -4249,54 +4282,132 @@ async function openSettingsModalNow(options = {}) {
|
|
|
4249
4282
|
});
|
|
4250
4283
|
}
|
|
4251
4284
|
|
|
4285
|
+
// Password protection and the list of recent backups (settings/settings-backup-encryption*.js). The list is read
|
|
4286
|
+
// again when a backup made from this page ends (below) and when the password protection changes (in the pane).
|
|
4287
|
+
const backupEncryption = wireBackupEncryption(overlay, kit);
|
|
4288
|
+
const backupEnded = createBackupEndWatcher();
|
|
4289
|
+
|
|
4252
4290
|
// ── System Backup & Restore handlers ──
|
|
4253
4291
|
|
|
4254
4292
|
const backupBtn = overlay.querySelector('#sys-backup-btn');
|
|
4255
4293
|
const restoreBtn = overlay.querySelector('#sys-restore-btn');
|
|
4256
4294
|
const restoreFileInput = overlay.querySelector('#sys-restore-file');
|
|
4257
4295
|
|
|
4296
|
+
// Download full backup: the server builds the archive in the chosen folder and this row follows it
|
|
4297
|
+
// (settings/settings-backup-download.js decides, lib/backup-download.js does). Nothing of it passes through the page.
|
|
4258
4298
|
if (backupBtn) {
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
const blob = await res.blob();
|
|
4279
|
-
const disposition = res.headers.get('content-disposition') || '';
|
|
4280
|
-
const filenameMatch = disposition.match(/filename="?([^"]+)"?/);
|
|
4281
|
-
const filename = filenameMatch ? filenameMatch[1] : 'synabun-backup.zip';
|
|
4282
|
-
|
|
4283
|
-
// Trigger download
|
|
4284
|
-
const url = URL.createObjectURL(blob);
|
|
4299
|
+
const folderInput = overlay.querySelector('#sys-backup-folder');
|
|
4300
|
+
const folderNote = overlay.querySelector('#sys-backup-folder-note');
|
|
4301
|
+
const browseBtn = overlay.querySelector('#sys-backup-browse');
|
|
4302
|
+
const revealBtn = overlay.querySelector('#sys-backup-reveal');
|
|
4303
|
+
const cancelBtn = overlay.querySelector('#sys-backup-cancel');
|
|
4304
|
+
const browserBtn = overlay.querySelector('#sys-backup-browser');
|
|
4305
|
+
const statusEl = overlay.querySelector('#sys-backup-status');
|
|
4306
|
+
const statusDot = overlay.querySelector('#sys-backup-dot');
|
|
4307
|
+
const statusText = overlay.querySelector('#sys-backup-text');
|
|
4308
|
+
const origHTML = backupBtn.innerHTML;
|
|
4309
|
+
// A page opened on another computer than the server cannot reach the folder: it keeps the browser's download.
|
|
4310
|
+
const pageHost = String(typeof location !== 'undefined' && location ? location.hostname || '' : '').replace(/^\[|\]$/g, '');
|
|
4311
|
+
const remotePage = !!pageHost && !['localhost', '127.0.0.1', '::1'].includes(pageHost);
|
|
4312
|
+
|
|
4313
|
+
const backupDownload = createBackupDownloadController({
|
|
4314
|
+
fetch: (...args) => fetch(...args),
|
|
4315
|
+
alive: () => overlay.isConnected !== false,
|
|
4316
|
+
// The browser's own download manager writes the response to disk as it arrives; no Blob in the page.
|
|
4317
|
+
browserDownload: () => {
|
|
4285
4318
|
const a = document.createElement('a');
|
|
4286
|
-
a.href =
|
|
4319
|
+
a.href = BACKUP_BROWSER_URL; a.download = '';
|
|
4287
4320
|
document.body.appendChild(a); a.click(); a.remove();
|
|
4288
|
-
|
|
4321
|
+
},
|
|
4322
|
+
render: (model) => {
|
|
4323
|
+
const row = describeBackupDownload(model, { tx: kit.tx });
|
|
4324
|
+
if (folderInput) folderInput.value = row.folder;
|
|
4325
|
+
if (folderNote) { folderNote.textContent = row.folderNote || ''; folderNote.style.display = row.folderNote ? '' : 'none'; }
|
|
4326
|
+
if (browseBtn) browseBtn.disabled = !row.canChoose || row.waiting;
|
|
4327
|
+
if (cancelBtn) cancelBtn.style.display = row.canCancel ? '' : 'none';
|
|
4328
|
+
if (revealBtn) revealBtn.style.display = row.canReveal ? '' : 'none';
|
|
4329
|
+
if (browserBtn) browserBtn.style.display = remotePage && !row.viaBrowser ? '' : 'none';
|
|
4330
|
+
backupBtn.disabled = row.waiting;
|
|
4331
|
+
if (row.running) backupBtn.textContent = kit.tx('settings.redesign.server.creatingBackup');
|
|
4332
|
+
else backupBtn.innerHTML = origHTML;
|
|
4333
|
+
if (row.status) {
|
|
4334
|
+
statusEl.style.display = 'flex';
|
|
4335
|
+
statusDot.className = row.status.dot ? `wiz-status-dot ${row.status.dot}` : 'wiz-status-dot';
|
|
4336
|
+
statusText.textContent = row.status.text;
|
|
4337
|
+
}
|
|
4338
|
+
// The backup that just ended is in the folder now: Recent backups shows it without Settings being reopened.
|
|
4339
|
+
if (backupEnded(model)) backupEncryption.refreshHistory();
|
|
4340
|
+
},
|
|
4341
|
+
});
|
|
4289
4342
|
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
4295
|
-
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
|
|
4343
|
+
backupBtn.addEventListener('click', () => backupDownload.start());
|
|
4344
|
+
if (browseBtn) browseBtn.addEventListener('click', () => backupDownload.choose(kit.tx('settings.redesign.server.backupFolderPrompt')));
|
|
4345
|
+
if (revealBtn) revealBtn.addEventListener('click', () => backupDownload.reveal());
|
|
4346
|
+
if (cancelBtn) cancelBtn.addEventListener('click', () => backupDownload.cancel());
|
|
4347
|
+
if (browserBtn) browserBtn.addEventListener('click', () => backupDownload.downloadInBrowser());
|
|
4348
|
+
backupDownload.load();
|
|
4349
|
+
}
|
|
4350
|
+
|
|
4351
|
+
// What to back up: one switch per group with its size (settings/settings-backup-contents.js decides,
|
|
4352
|
+
// lib/backup-contents.js keeps the choice and measures on a worker thread). The rows are drawn from the server's
|
|
4353
|
+
// answer; a server from before these routes gets no rows and one line that says a restart is missing.
|
|
4354
|
+
const contentsRows = overlay.querySelector('#sys-backup-contents-rows');
|
|
4355
|
+
if (contentsRows) {
|
|
4356
|
+
const summary = overlay.querySelector('#sys-backup-contents-summary');
|
|
4357
|
+
const totalEl = overlay.querySelector('#sys-backup-contents-total');
|
|
4358
|
+
const warningEl = overlay.querySelector('#sys-backup-contents-warning');
|
|
4359
|
+
const neverEl = overlay.querySelector('#sys-backup-contents-never');
|
|
4360
|
+
const noteEl = overlay.querySelector('#sys-backup-contents-note');
|
|
4361
|
+
const refreshBtn = overlay.querySelector('#sys-backup-contents-refresh');
|
|
4362
|
+
const helpEl = overlay.querySelector('#sys-backup-contents-help');
|
|
4363
|
+
const kindState = { irreplaceable: 'ok', regenerable: 'off', temporary: 'off' };
|
|
4364
|
+
let drawn = '';
|
|
4365
|
+
|
|
4366
|
+
const backupContents = createBackupContentsController({
|
|
4367
|
+
fetch: (...args) => fetch(...args),
|
|
4368
|
+
alive: () => overlay.isConnected !== false,
|
|
4369
|
+
render: (model) => {
|
|
4370
|
+
const list = describeBackupContents(model, { tx: kit.tx });
|
|
4371
|
+
if (helpEl) helpEl.style.display = list.available ? '' : 'none';
|
|
4372
|
+
// The rows are built once per set of groups; after that only what changed is written, so a switch that has
|
|
4373
|
+
// the keyboard keeps it while the sizes arrive.
|
|
4374
|
+
const shape = list.rows.map(row => row.id).join(',');
|
|
4375
|
+
if (shape !== drawn) {
|
|
4376
|
+
drawn = shape;
|
|
4377
|
+
contentsRows.innerHTML = list.rows.map((row) => {
|
|
4378
|
+
const id = `sys-backup-group-${row.id}`;
|
|
4379
|
+
return `
|
|
4380
|
+
<div class="stg-toggle-field" data-backup-group="${kit.esc(row.id)}">
|
|
4381
|
+
<div class="stg-toggle-text">
|
|
4382
|
+
<label class="stg-toggle-label" for="${id}" id="${id}-label">${kit.esc(row.label)} ${kit.pill(kit.esc(row.kindLabel), { state: kindState[row.kind] || 'off' })}</label>
|
|
4383
|
+
<div class="stg-help" id="${id}-help">${kit.esc(row.help)}</div>
|
|
4384
|
+
<div class="stg-help" data-backup-size aria-live="polite"></div>
|
|
4385
|
+
</div>
|
|
4386
|
+
<div class="stg-toggle-control">${kit.switchInput(id, { checked: row.enabled, attrs: `data-backup-group="${kit.esc(row.id)}"` })}</div>
|
|
4387
|
+
</div>`;
|
|
4388
|
+
}).join('');
|
|
4389
|
+
}
|
|
4390
|
+
for (const row of list.rows) {
|
|
4391
|
+
const field = contentsRows.querySelector(`.stg-toggle-field[data-backup-group="${row.id}"]`);
|
|
4392
|
+
const input = field?.querySelector('input[type="checkbox"]');
|
|
4393
|
+
if (input) { input.checked = row.enabled; input.disabled = row.busy; }
|
|
4394
|
+
const size = field?.querySelector('[data-backup-size]');
|
|
4395
|
+
if (size) size.textContent = row.size || (list.measuring ? kit.tx('settings.redesign.server.backupContentsMeasuring') : '');
|
|
4396
|
+
}
|
|
4397
|
+
if (summary) summary.style.display = list.available ? '' : 'none';
|
|
4398
|
+
if (totalEl) totalEl.textContent = list.total ? [list.total, list.everything].filter(Boolean).join(' ') : (list.measuring ? kit.tx('settings.redesign.server.backupContentsMeasuring') : '');
|
|
4399
|
+
if (warningEl) { warningEl.textContent = list.warning || ''; warningEl.style.display = list.warning ? '' : 'none'; }
|
|
4400
|
+
if (neverEl) neverEl.textContent = list.never || '';
|
|
4401
|
+
if (refreshBtn) refreshBtn.disabled = list.measuring;
|
|
4402
|
+
if (noteEl) { noteEl.textContent = list.note || ''; noteEl.style.display = list.note ? '' : 'none'; }
|
|
4403
|
+
},
|
|
4404
|
+
});
|
|
4405
|
+
contentsRows.addEventListener('change', (e) => {
|
|
4406
|
+
const input = e.target.closest?.('input[data-backup-group]');
|
|
4407
|
+
if (input) backupContents.toggle(input.dataset.backupGroup, input.checked);
|
|
4299
4408
|
});
|
|
4409
|
+
if (refreshBtn) refreshBtn.addEventListener('click', () => backupContents.refresh());
|
|
4410
|
+
backupContents.load();
|
|
4300
4411
|
}
|
|
4301
4412
|
|
|
4302
4413
|
if (restoreBtn && restoreFileInput) {
|
|
@@ -4325,32 +4436,55 @@ async function openSettingsModalNow(options = {}) {
|
|
|
4325
4436
|
body: file,
|
|
4326
4437
|
});
|
|
4327
4438
|
if (!previewRes.ok) {
|
|
4328
|
-
let
|
|
4329
|
-
try {
|
|
4330
|
-
|
|
4439
|
+
let body = null;
|
|
4440
|
+
try { body = await previewRes.json(); } catch {}
|
|
4441
|
+
// Told by the refusal's code in this page's language, never by the server's sentence (English, and it can hold a path).
|
|
4442
|
+
throw Object.assign(new Error(previewErrorMessage(body, { tx: kit.tx, fallback: kit.tx('settings.redesign.server.invalidBackup2') })), { translated: true });
|
|
4331
4443
|
}
|
|
4332
|
-
|
|
4333
|
-
|
|
4444
|
+
let preview = await previewRes.json();
|
|
4334
4445
|
statusEl.style.display = 'none';
|
|
4335
4446
|
|
|
4336
|
-
|
|
4447
|
+
// An encrypted backup says nothing of what it holds until its password opened it. The file stays staged on
|
|
4448
|
+
// the server, so a mistyped password costs no second upload.
|
|
4449
|
+
let stagedUploadId = null;
|
|
4450
|
+
if (preview.encrypted && preview.locked) {
|
|
4451
|
+
preview = await askRestorePassword(preview, { kit });
|
|
4452
|
+
if (!preview) return;
|
|
4453
|
+
stagedUploadId = preview.uploadId;
|
|
4454
|
+
}
|
|
4455
|
+
const { manifest: m, contents } = preview;
|
|
4456
|
+
const closeConfirm = () => {
|
|
4457
|
+
if (stagedUploadId) discardEncryptedRestore((...args) => fetch(...args), stagedUploadId);
|
|
4458
|
+
confirmOverlay.remove();
|
|
4459
|
+
};
|
|
4460
|
+
|
|
4461
|
+
// A server from before the groups sends the whole manifest (its file list) and says nothing of groups.
|
|
4462
|
+
const fileCount = Number.isFinite(m.fileCount) ? m.fileCount : (m.files || []).length;
|
|
4337
4463
|
const hasDb = !!m.database;
|
|
4464
|
+
// What this backup holds, by group, and what a restore of it therefore leaves as it is now.
|
|
4465
|
+
const holds = describeRestoreContents(contents, { tx: kit.tx });
|
|
4466
|
+
const holdsLines = holds ? [holds.stateOnly, holds.contains, holds.missing].filter(Boolean) : [];
|
|
4467
|
+
// An encrypted backup: the date its header carries, which the password's keys vouched for. An older backup of
|
|
4468
|
+
// the owner's opens just as well, so the date is what says which one this is.
|
|
4469
|
+
const madeLine = describeEncryptedRestore(preview, { tx: kit.tx });
|
|
4470
|
+
// When it was made and, only when the backup says so, on which computer.
|
|
4471
|
+
const createdLine = describeRestoreCreated(m, { tx: kit.tx });
|
|
4338
4472
|
|
|
4339
4473
|
const confirmOverlay = document.createElement('div');
|
|
4340
4474
|
confirmOverlay.className = 'tag-delete-overlay';
|
|
4341
4475
|
confirmOverlay.style.zIndex = '300100';
|
|
4342
4476
|
confirmOverlay.innerHTML = `
|
|
4343
|
-
<div class="tag-delete-modal settings-modal" style="max-width:500px;text-align:left">
|
|
4344
|
-
<h3 style="margin-bottom:4px">${kit.te('settings.redesign.server.restoreBackup')}</h3>
|
|
4345
|
-
|
|
4346
|
-
${kit.th('settings.redesign.server.createdOn', { value: new Date(m.created).toLocaleString() })} ${escapeHtml(m.hostname || kit.tx('settings.redesign.server.unknown'))}
|
|
4347
|
-
</p>
|
|
4477
|
+
<div class="tag-delete-modal settings-modal ${RESTORE_DIALOG_CLASS}" role="dialog" aria-modal="true" aria-labelledby="sys-restore-confirm-title" style="max-width:500px;text-align:left">
|
|
4478
|
+
<h3 id="sys-restore-confirm-title" style="margin-bottom:4px">${kit.te('settings.redesign.server.restoreBackup')}</h3>
|
|
4479
|
+
${createdLine ? `<p id="sys-restore-created" style="font-size:11px;color:var(--t-muted);margin-bottom:12px">${escapeHtml(createdLine)}</p>` : ''}
|
|
4348
4480
|
<div style="font-size:12px;margin-bottom:8px">
|
|
4349
4481
|
<strong>${fileCount}</strong> ${kit.te('settings.redesign.server.configFiles')}
|
|
4350
4482
|
${hasDb ? `<br><strong>${kit.te('settings.redesign.server.database')}</strong> ${kit.te('settings.redesign.server.memoryDbIncluded')}` : ''}
|
|
4351
4483
|
</div>
|
|
4484
|
+
${madeLine ? `<div id="sys-restore-encrypted-made" style="font-size:12px;margin-bottom:8px">${escapeHtml(madeLine)}</div>` : ''}
|
|
4485
|
+
${holdsLines.length ? `<div id="sys-restore-contents" style="font-size:12px;margin-bottom:8px">${holdsLines.map(line => `<div>${escapeHtml(line)}</div>`).join('')}</div>` : ''}
|
|
4352
4486
|
<p style="font-size:11px;color:var(--accent-dim);margin-bottom:12px">
|
|
4353
|
-
${kit.te('settings.redesign.server.thisWillOverwriteYourCurrentEnv')}
|
|
4487
|
+
${holds ? kit.te('settings.redesign.server.restoreOverwritesContained') : kit.te('settings.redesign.server.thisWillOverwriteYourCurrentEnv')}
|
|
4354
4488
|
</p>
|
|
4355
4489
|
<div class="tag-delete-modal-actions">
|
|
4356
4490
|
<button class="action-btn action-btn--ghost" id="sys-restore-cancel">${kit.te('settings.redesign.server.cancel')}</button>
|
|
@@ -4366,9 +4500,9 @@ async function openSettingsModalNow(options = {}) {
|
|
|
4366
4500
|
</div>`;
|
|
4367
4501
|
document.body.appendChild(confirmOverlay);
|
|
4368
4502
|
|
|
4369
|
-
confirmOverlay.querySelector('#sys-restore-cancel').addEventListener('click',
|
|
4503
|
+
confirmOverlay.querySelector('#sys-restore-cancel').addEventListener('click', closeConfirm);
|
|
4370
4504
|
confirmOverlay.addEventListener('click', (ev) => {
|
|
4371
|
-
if (ev.target === confirmOverlay
|
|
4505
|
+
if (ev.target === confirmOverlay && !confirmOverlay.querySelector('#sys-restore-confirm').disabled) closeConfirm();
|
|
4372
4506
|
});
|
|
4373
4507
|
|
|
4374
4508
|
confirmOverlay.querySelector('#sys-restore-confirm').addEventListener('click', async () => {
|
|
@@ -4384,17 +4518,39 @@ async function openSettingsModalNow(options = {}) {
|
|
|
4384
4518
|
progressText.textContent = kit.tx('settings.redesign.server.applyingBackup');
|
|
4385
4519
|
|
|
4386
4520
|
try {
|
|
4387
|
-
|
|
4388
|
-
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4395
|
-
|
|
4521
|
+
let result;
|
|
4522
|
+
if (stagedUploadId) {
|
|
4523
|
+
// The staged file is used once: whatever the answer, the server has let go of it.
|
|
4524
|
+
const uploadId = stagedUploadId;
|
|
4525
|
+
stagedUploadId = null;
|
|
4526
|
+
const answer = await applyEncryptedRestore((...args) => fetch(...args), uploadId, 'full');
|
|
4527
|
+
if (!answer.ok) throw Object.assign(new Error(restoreErrorMessage(answer.body, { tx: kit.tx })), { translated: true });
|
|
4528
|
+
result = answer.body;
|
|
4529
|
+
} else {
|
|
4530
|
+
const restoreRes = await fetch('/api/system/restore?mode=full', {
|
|
4531
|
+
method: 'POST',
|
|
4532
|
+
headers: { 'Content-Type': 'application/zip' },
|
|
4533
|
+
body: file,
|
|
4534
|
+
});
|
|
4535
|
+
if (!restoreRes.ok) {
|
|
4536
|
+
// By the refusal's code, in this page's language: the server's sentence can hold a path. An old server sends none: the generic sentence.
|
|
4537
|
+
let body = null;
|
|
4538
|
+
try { body = await restoreRes.json(); } catch {}
|
|
4539
|
+
throw Object.assign(new Error(restoreErrorMessage(body, { tx: kit.tx })), { translated: true });
|
|
4540
|
+
}
|
|
4541
|
+
// A 200 that cannot be read may still have written: it counts as a restore with problems, below.
|
|
4542
|
+
try { result = await restoreRes.json(); } catch { result = null; }
|
|
4543
|
+
}
|
|
4544
|
+
// A 200 can carry problems (results.errors): never "Done". Kept in this tab, because a restart reloads the page.
|
|
4545
|
+
const partialCodes = restorePartialCodes(result);
|
|
4546
|
+
if (partialCodes) {
|
|
4547
|
+
const outcome = { codes: partialCodes, restart: result?.restart === true };
|
|
4548
|
+
saveRestoreOutcome(outcome);
|
|
4549
|
+
confirmOverlay.remove();
|
|
4550
|
+
openRestoreOutcomeDialog(outcome, { tx: kit.tx, restarting: outcome.restart, offerReload: !outcome.restart });
|
|
4551
|
+
return;
|
|
4396
4552
|
}
|
|
4397
|
-
|
|
4553
|
+
clearRestoreOutcome();
|
|
4398
4554
|
const restoredFileCount = result.results?.files?.length || 0;
|
|
4399
4555
|
|
|
4400
4556
|
progressDot.className = 'wiz-status-dot green';
|
|
@@ -4415,14 +4571,17 @@ async function openSettingsModalNow(options = {}) {
|
|
|
4415
4571
|
});
|
|
4416
4572
|
} catch (err) {
|
|
4417
4573
|
progressDot.className = 'wiz-status-dot red';
|
|
4418
|
-
progressText.textContent = err.message;
|
|
4574
|
+
progressText.textContent = err.translated ? err.message : restoreErrorMessage(null, { tx: kit.tx });
|
|
4419
4575
|
confirmBtn.textContent = kit.tx('settings.redesign.server.restore');
|
|
4420
|
-
|
|
4576
|
+
// An encrypted upload was used by that attempt: another one starts from choosing the file.
|
|
4577
|
+
confirmBtn.disabled = !!preview.encrypted;
|
|
4421
4578
|
}
|
|
4422
4579
|
});
|
|
4423
4580
|
} catch (err) {
|
|
4581
|
+
statusEl.style.display = 'flex';
|
|
4424
4582
|
statusDot.className = 'wiz-status-dot red';
|
|
4425
|
-
|
|
4583
|
+
// A server from before the finished encryption: the file is not at fault, a restart is missing.
|
|
4584
|
+
statusText.textContent = err.needsRestart || err.translated ? err.message : kit.tx('settings.redesign.server.invalidBackup2');
|
|
4426
4585
|
}
|
|
4427
4586
|
});
|
|
4428
4587
|
}
|