Skip to content

armgit / bento

Public Imported from GitHub
0

Bento, the office suite that fits in a file

A self-update should not be the one save that interrupts (#298)

nyblnet802804b6b364
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 00d2be25..2d1bcf17 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,18 @@ pre-1.0.
## [Unreleased]
+- **Updating a file no longer interrupts you.** With Bento Tray installed and a
+ folder granted, "Update this file" now finishes without a single dialog. The
+ backup it leaves behind is saved **beside your document** instead of being
+ downloaded — so the copy you would roll back to sits next to the thing it
+ backs up, rather than in your downloads folder. Without the extension it is
+ still a download, exactly as before.
+
+ Two things caused the prompt. The backup was handed to the browser's download
+ machinery, which asks where to put things if you have told Chrome to; and an
+ update of a double-clicked file described itself to the extension as an
+ export, so the extension — correctly — refused to write it for you.
+
## [1.0.17] — 2026-08-10
- **Security: update this file. A deck could run code hidden in its own
diff --git a/docs/DECISIONS.md b/docs/DECISIONS.md
index 5c65ece6..7829cd9d 100644
--- a/docs/DECISIONS.md
+++ b/docs/DECISIONS.md
@@ -2247,3 +2247,66 @@ too, at the single point where it returns.
payload 72KB → 79KB). Most of it is the finding messages, which are the
product: a code with no explanation is not actionable. Anyone tempted to shrink
this should shorten prose, not drop checks.
+
+---
+
+## 2026-08-14 — a self-update must not be the one save that interrupts
+
+**Reported against 1.0.16**, with tray/webext installed and a folder granted:
+⌘S saved with no dialog, and then "Update this file" put up a macOS save panel
+for `Tray_Test.v1.0.16-backup.bento.html` into ~/Downloads.
+
+The update itself was fine — it had rewritten the file in place, silently,
+through the extension. The dialog was the ROLLBACK COPY, which `applyUpdateInPlace`
+handed to `downloadFile`, and downloads prompt for anyone with Chrome's *"ask
+where to save each file"* enabled. So the flow's only interruption was for a
+file the author never asked for, in the middle of the one operation whose whole
+selling point is that it does not interrupt.
+
+Two things were wrong, and only the first was visible.
+
+**A backup belongs beside what it backs up.** Even silent, ~/Downloads is the
+wrong place: detached from the document, one per update, and a rollback you have
+to go hunting for is a poor rollback. With a host, it now goes in the folder
+already granted, next to the original. Without one it is still a download —
+the alternative there is a picker, which is strictly worse than the status quo
+for the majority case, and the majority case is no extension at all.
+
+**The no-handle path was declaring the wrong intent.** `writeUpdatedFileAs`
+hard-coded `share`, so a document opened by double-clicking — no handle, the
+ordinary case — told every host "a new file the author will choose" about a save
+that is overwriting the document on screen. The host correctly declined and the
+author got a picker. Same class as the 2026-08-02 finding that produced
+`pickerIdFor`: intent has to be explicit in the call, because it cannot be
+recovered from anything else in it. `applyUpdateInPlace` now sends `in-place`,
+and `canUpdateInPlace` stops meaning "we hold a handle" — a host needs none.
+
+**Hosts announce capabilities, not presence** (`window.__bentoHost.ops`,
+`save.ts hostCan`). Presence is not a useful question: `showSaveFilePicker`
+exists in Chrome regardless, and a host that declines looks exactly like one
+that is absent. A host that announced itself but did not know `bento-backup`
+would have passed the request to the native picker — producing the very dialog
+this removes, and only for the people who installed the thing meant to remove
+it. Decks and hosts version independently in both directions.
+
+**The new op is the only one that creates a file**, so it is the only place the
+page contributes to a name. Held down from both ends: the name must be visibly
+derived from the sender's own (`backupNameFor` — no separator survives, and it
+may not equal the original), and an existing file is never overwritten. The
+directory comes from the sender's resolved path, never the payload. Worst case
+for a hostile document is one predictably-named copy of ITSELF inside a granted
+folder.
+
+**Guards.** `scripts/test-savepurpose.ts` pins the update path's purpose (both
+new assertions verified to FAIL against the previous commit — a gate never seen
+failing is not a gate). `scripts/test-webext-background.ts` covers the name
+rules, create-only, the nested-directory case, and that every refusal applying
+to a write applies to a backup. `scripts/test-webext-bridge.ts` covers the
+announcement, that a page cannot forge it, and that a backup never reaches the
+native picker.
+
+*Found while fixing this:* the bridge rig stubbed `Blob` as `class {}`, which
+satisfied the `instanceof` branch but has no `.text()` — so every `close()`
+rejected and the half of the bridge that actually sends bytes had never been
+exercised, across 24 green checks. Mocks shaped to make a test pass test the
+mock.
diff --git a/kernel/src/save.ts b/kernel/src/save.ts
index fe45f5f4..c238b027 100644
--- a/kernel/src/save.ts
+++ b/kernel/src/save.ts
@@ -528,8 +528,11 @@ export const canWriteInPlace = () => hasFsAccess()
* · `copy` — "Save a copy…". A second file, chosen by the author.
* · `share` — a suffixed export: view-only, presentation package, invite,
* template. Deliberately a new file, and never the ⌘S target.
+ * · `backup` — the rollback copy a self-update leaves behind. Belongs BESIDE
+ * the document it backs up, and is the one save the author never
+ * asked for, so it is also the one that must never interrupt.
*/
-export type SavePurpose = 'in-place' | 'copy' | 'share'
+export type SavePurpose = 'in-place' | 'copy' | 'share' | 'backup'
/**
* The picker `id` for a purpose — and, incidentally, the only signal a HOST has
@@ -550,7 +553,35 @@ export type SavePurpose = 'in-place' | 'copy' | 'share'
* recovered from anything else in it.
*/
export const pickerIdFor = (purpose: SavePurpose): string =>
- purpose === 'in-place' ? 'bento-doc' : purpose === 'copy' ? 'bento-copy' : 'bento-share'
+ purpose === 'in-place' ? 'bento-doc'
+ : purpose === 'copy' ? 'bento-copy'
+ : purpose === 'backup' ? 'bento-backup'
+ : 'bento-share'
+
+/**
+ * Is a HOST polyfilling the picker — tray/ios, tray/webext — rather than the
+ * browser's own?
+ *
+ * The kernel cannot infer this. `showSaveFilePicker` exists either way, and a
+ * host that declines a request is indistinguishable from one that is not there:
+ * both end in the native dialog. So a host that can do more than the bare
+ * contract announces itself, and this is the only thing the kernel reads.
+ *
+ * It gates exactly one decision — see `writeBackupBeside`. Nothing else may
+ * branch on it: every in-place path must keep working when it is false, because
+ * that is the plain-browser case and it is the majority one.
+ *
+ * PRESENCE IS NOT ENOUGH, so this asks about a named capability. A host that
+ * announced itself but did not recognise `bento-backup` would pass the request
+ * through to the native picker — producing exactly the dialog this exists to
+ * remove, and only for people who installed the host. Decks outlive host
+ * versions in both directions; neither side may assume the other is current.
+ */
+export const hostCan = (op: string): boolean => {
+ const host = (window as any).__bentoHost
+ return !!host && Array.isArray(host.ops) && host.ops.includes(op)
+ && typeof (window as any).showSaveFilePicker === 'function'
+}
async function pickHandle(
doc: KernelDoc, suffix = '', suggestedName?: string, purpose: SavePurpose = 'in-place',
@@ -683,13 +714,18 @@ export async function writeUpdatedFile(html: string): Promise<void> {
export async function writeUpdatedFileAs(
html: string,
doc: KernelDoc,
- opts: { suffix?: string; keepHandle?: boolean; suggestedName?: string } = {},
+ opts: { suffix?: string; keepHandle?: boolean; suggestedName?: string; purpose?: SavePurpose } = {},
): Promise<boolean> {
if (!hasFsAccess()) {
downloadFile(html, opts.suggestedName ?? suggestedFileName(doc, opts.suffix))
return true
}
- const handle = await pickHandle(doc, opts.suffix, opts.suggestedName, 'share')
+ // `share` is the right default — every caller but one is an export. The
+ // exception is the self-update, which is overwriting the open document and
+ // must say so: a host reads only the picker id, and `bento-share` tells it
+ // "a new file the author will choose", so it correctly declines and the
+ // author gets a dialog for the one save that should never need one.
+ const handle = await pickHandle(doc, opts.suffix, opts.suggestedName, opts.purpose ?? 'share')
if (!handle) return false
// Share/export artifacts must NOT become the ⌘S target — otherwise the next
// save would overwrite e.g. a view-only copy with the FULL document (owner
@@ -698,3 +734,47 @@ export async function writeUpdatedFileAs(
await writeHandle(handle, html)
return true
}
+
+/**
+ * Leave the rollback copy an in-place update depends on.
+ *
+ * WHY THIS IS NOT JUST `downloadFile`. It was, and the backup landed in
+ * ~/Downloads: detached from the document it backs up, one per update, and — for
+ * anyone with Chrome's "ask where to save each file" enabled — behind a save
+ * dialog. Reported 2026-08-14 against 1.0.16. That is the wrong outcome twice
+ * over: an update that rewrites the file in place, silently, ended with the one
+ * prompt in the flow being for a file the author never asked for, and the
+ * rollback it produced was somewhere they would have to go hunting for.
+ *
+ * With a host, the backup goes where it belongs — beside the original, inside
+ * the folder already granted. The host derives the directory itself, from the
+ * sender's own resolved path; `name` is only ever validated against that, never
+ * trusted as a path. See tray/webext/src/background.js `backup`.
+ *
+ * Without a host this stays a download, because the alternative is a picker and
+ * a picker is strictly worse than the status quo for the majority case.
+ *
+ * Never throws: a backup that fails must not take the update down with it. The
+ * caller decides what to tell the author, which is why the outcome comes back
+ * as a value.
+ */
+export async function writeBackupBeside(html: string, name: string): Promise<'beside' | 'downloaded'> {
+ if (hostCan('backup')) {
+ try {
+ const handle = await (window as any).showSaveFilePicker({
+ suggestedName: name,
+ id: pickerIdFor('backup'),
+ types: [{ description: appConfig().appName, accept: { 'text/html': ['.html'] } }],
+ })
+ if (handle) {
+ await writeHandle(handle, html)
+ return 'beside'
+ }
+ } catch {
+ // Declined, cancelled, or the grant lapsed. Fall through — a backup in
+ // Downloads is a worse place, not a lost one.
+ }
+ }
+ downloadFile(html, name)
+ return 'downloaded'
+}
diff --git a/kernel/src/update.ts b/kernel/src/update.ts
index e7ec0374..9d449cd8 100644
--- a/kernel/src/update.ts
+++ b/kernel/src/update.ts
@@ -23,7 +23,7 @@ import type { KernelDoc } from './doc.ts'
import { appConfig } from './app.ts'
import {
serializeDocInto, serializeAuto, suggestedFileName, downloadFile, openedFileName, fileBase,
- hasFileHandle, writeUpdatedFile, writeUpdatedFileAs,
+ hasFileHandle, writeUpdatedFile, writeUpdatedFileAs, writeBackupBeside, hostCan,
} from './save.ts'
import { lsDel, lsGet, lsSet } from './storage.ts'
@@ -285,34 +285,73 @@ export async function applyUpdate(release: ReleaseInfo, doc: KernelDoc): Promise
downloadFile(await buildUpdatedFile(release, doc), openedFileName() ?? suggestedFileName(doc))
}
-/** Can we rewrite the open file directly (a FS Access handle is held)? */
-export const canUpdateInPlace = hasFileHandle
+/**
+ * Can we rewrite the open file directly, with no destination prompt?
+ *
+ * Two ways to be able to. A held FS Access handle is the browser's own, earned
+ * by an earlier save. A HOST needs no handle at all: it resolves the file from
+ * the page's own URL against a folder the author granted once, which is the
+ * whole reason a double-clicked document can be written without a picker.
+ *
+ * This only decides what the button PROMISES ("Update this file" vs "…"), so
+ * being wrong is a mislabelled button rather than a lost file — but it was
+ * wrong in the direction that undersells: with a host installed and no handle
+ * yet, it offered to ask where to save something it could simply write.
+ */
+export const canUpdateInPlace = (): boolean => hasFileHandle() || hostCan('write')
+
+/** What an in-place update actually did with the rollback copy. */
+export type InPlaceOutcome = { backup: 'beside' | 'downloaded' | 'none' }
/**
* Update the file on disk, then a reload boots the new app with this document.
*
- * With a held handle: download a backup of the current version first, then
- * overwrite the file in place silently.
+ * A rollback copy of the CURRENT version is written first, whenever the update
+ * itself is going to be silent — see `writeBackupBeside` for where it lands and
+ * why that stopped being a download.
+ *
+ * With a held handle: overwrite the file in place.
*
* Without a handle (e.g. the file was double-clicked open — the browser grants
- * no handle on open): use a save picker AND KEEP the resulting handle, so this
- * update and every later one can rewrite the file in place. The picker is
+ * no handle on open): fall to a save picker AND KEEP the resulting handle, so
+ * this update and every later one can rewrite the file in place. The picker is
* pre-filled with the open file's own NAME (taken from the document URL); its
* DIRECTORY still cannot be set — the API accepts a handle, never a path — so
* the caller must still tell the user to overwrite the file they have open.
- * Once they do, it is a one-time grant. Returns false if cancelled.
+ *
+ * That path declares `in-place`, and the distinction is not cosmetic. It is
+ * overwriting the document on screen, which is what `in-place` means, and a
+ * host reads the picker id and nothing else. Sending `share` here — as this did
+ * — told every host "a new file the author will choose", so the one save that
+ * should never need a dialog was the one that always got one.
+ *
+ * Returns null if the picker was cancelled.
*/
-export async function applyUpdateInPlace(release: ReleaseInfo, doc: KernelDoc): Promise<boolean> {
+export async function applyUpdateInPlace(
+ release: ReleaseInfo, doc: KernelDoc,
+): Promise<InPlaceOutcome | null> {
const html = await buildUpdatedFile(release, doc)
// Both names below follow the OPEN FILE, not the deck title: the backup sits
// beside the original, and the picker opens pre-filled with the very file the
// user is being asked to overwrite.
const current = openedFileName()
+ const base = fileBase(current ?? suggestedFileName(doc))
+
+ // Only back up when the write that follows is going to happen without asking.
+ // On a plain browser with no handle the author is about to CHOOSE a
+ // destination, and may well choose a new file — the original survives on its
+ // own, and an unasked-for download on top of that is noise.
+ const silent = hasFileHandle() || hostCan('write')
+ const backup = silent
+ ? await writeBackupBeside(await serializeAuto(doc), `${base}.v${APP_VERSION}-backup.bento.html`)
+ : 'none'
+
if (hasFileHandle()) {
- const base = fileBase(current ?? suggestedFileName(doc))
- downloadFile(await serializeAuto(doc), `${base}.v${APP_VERSION}-backup.bento.html`)
await writeUpdatedFile(html)
- return true
+ return { backup }
}
- return writeUpdatedFileAs(html, doc, { keepHandle: true, suggestedName: current ?? undefined })
+ const written = await writeUpdatedFileAs(html, doc, {
+ keepHandle: true, suggestedName: current ?? undefined, purpose: 'in-place',
+ })
+ return written ? { backup } : null
}
diff --git a/scripts/test-savepurpose.ts b/scripts/test-savepurpose.ts
index 9a2eff16..0aefe463 100644
--- a/scripts/test-savepurpose.ts
+++ b/scripts/test-savepurpose.ts
@@ -18,6 +18,7 @@
// value, every host silently loses the ability to tell them apart — and finds
// out the way we did.
+import { readFileSync } from 'node:fs'
import { pickerIdFor, type SavePurpose } from '../kernel/src/save.ts'
let failures = 0
@@ -28,7 +29,7 @@ function ok(cond: boolean, msg: string) {
else console.log(` ok ${msg}`)
}
-const purposes: SavePurpose[] = ['in-place', 'copy', 'share']
+const purposes: SavePurpose[] = ['in-place', 'copy', 'share', 'backup']
const ids = purposes.map(pickerIdFor)
ok(new Set(ids).size === purposes.length,
@@ -39,8 +40,26 @@ ok(pickerIdFor('copy') !== pickerIdFor('in-place'),
'a copy is distinguishable from an in-place save — the case that overwrote a file')
ok(pickerIdFor('share') !== pickerIdFor('in-place'),
'a share export is distinguishable from an in-place save')
+ok(pickerIdFor('backup') !== pickerIdFor('in-place'),
+ 'a backup is distinguishable from the file it backs up — it is a NEW file beside it')
ok(ids.every((id) => /^[a-z0-9-]+$/.test(id) && id.length <= 32),
'ids are plain and short enough for the picker to accept')
+// ---------------------------------------------------------- the update path
+// The self-update is the ONE caller of writeUpdatedFileAs that is overwriting
+// the document on screen rather than exporting a new file. It hard-coded
+// `share` for both, so a host was told "the author will choose a destination"
+// about a save that should never have shown a dialog — reported against 1.0.16,
+// with the extension installed and the folder granted.
+//
+// Read as source, because the branch is unreachable without a DOM and a picker.
+// A weak assertion on the right line beats a strong one on a mock of it.
+const updateSrc = readFileSync(new URL('../kernel/src/update.ts', import.meta.url), 'utf8')
+const call = updateSrc.slice(updateSrc.indexOf('writeUpdatedFileAs(html'))
+ok(/purpose:\s*'in-place'/.test(call.slice(0, 300)),
+ 'applyUpdateInPlace declares in-place, so a host recognises it and writes without asking')
+ok(!/writeUpdatedFileAs\(html, doc, \{ keepHandle: true, suggestedName: [^}]*\}\)/.test(updateSrc),
+ 'the update no longer falls through to the default share purpose')
+
console.log(`\n${checks - failures}/${checks} checks passed`)
if (failures) process.exit(1)
diff --git a/scripts/test-webext-background.ts b/scripts/test-webext-background.ts
index 81399ba9..02d8bbec 100644
--- a/scripts/test-webext-background.ts
+++ b/scripts/test-webext-background.ts
@@ -24,7 +24,7 @@
// Both are checked by construction here: a write is issued with no preceding
// claim at all, which is exactly what a service worker restart looks like.
-import { pathFromSender, findByName, claim, write, resolve } from '../tray/webext/src/background.js'
+import { pathFromSender, findByName, claim, write, resolve, backup, backupNameFor } from '../tray/webext/src/background.js'
let failures = 0
let checks = 0
@@ -69,6 +69,20 @@ function dirHandle(tree: Record<string, any>, perm = 'granted', base: string[] =
// only children at or below this directory resolve
return base.every((seg, i) => rel[i] === seg) ? rel.slice(base.length) : null
},
+ /** Real API: throws NotFoundError when absent, which `backup` relies on. */
+ async getDirectoryHandle(name: string) {
+ const v = tree[name]
+ if (!v || v.kind) throw Object.assign(new Error(name), { name: 'NotFoundError' })
+ return dirHandle(v, perm, [...base, name])
+ },
+ async getFileHandle(name: string, opts?: { create?: boolean }) {
+ const v = tree[name]
+ if (v && v.kind === 'file') return v
+ if (!opts?.create) throw Object.assign(new Error(name), { name: 'NotFoundError' })
+ const h = fileHandle(name, [...base, name])
+ tree[name] = h
+ return h
+ },
async *entries() {
for (const [k, v] of Object.entries(tree)) {
yield [k, typeof v === 'object' && !v.kind ? dirHandle(v, perm, [...base, k]) : v] as const
@@ -192,5 +206,85 @@ const deps = (tree: Record<string, any>, perm = 'granted') => ({
ok(r.ok === false, 'a file buried past the depth limit is declined, not searched forever')
}
+// ---- 6. the backup op ------------------------------------------------------
+// This is the only op that CREATES a file, so it is the only one where the page
+// contributes to a name. Everything below is about keeping that contribution
+// from meaning anything: the name must be visibly derived from the sender's own
+// file, and an existing file is never replaced.
+{
+ const own = 'Q3.bento.html'
+ ok(backupNameFor(own, 'Q3.v1.0.16-backup.bento.html') === 'Q3.v1.0.16-backup.bento.html',
+ 'the ordinary backup name is accepted')
+ for (const [bad, why] of [
+ ['../../../etc/passwd', 'a traversal'],
+ ['/etc/Q3.bento.html', 'an absolute path'],
+ ['Q3/x.bento.html', 'a subdirectory'],
+ ['Q3.bento.html', 'the original itself'],
+ ['Other.v1-backup.bento.html', 'a name derived from a DIFFERENT file'],
+ ['Q3.v1-backup.txt', 'a non-document extension'],
+ ['Q3.v1 backup.bento.html', 'a name with a space'],
+ ['Q3..bento.html', 'an embedded NUL'],
+ ] as const) {
+ ok(backupNameFor(own, bad) === null, `${why} is refused (${JSON.stringify(bad)})`)
+ }
+ ok(backupNameFor(own, `Q3.${'x'.repeat(200)}.bento.html`) === null,
+ 'an absurdly long name is refused')
+ ok(backupNameFor(own, undefined as any) === null, 'a missing name is refused')
+}
+{
+ written.clear()
+ const tree: Record<string, any> = { 'Q3.bento.html': fileHandle('Q3.bento.html') }
+ const r = await backup(senderFor('/Users/x/Decks/Q3.bento.html'), 'old bytes',
+ 'Q3.v1.0.16-backup.bento.html', deps(tree))
+ ok(r.ok === true, 'a backup beside the sender\'s own file is written')
+ ok(written.get('Q3.v1.0.16-backup.bento.html') === 'old bytes', 'and carries the old version')
+ ok(written.get('Q3.bento.html') === undefined, 'and the original is untouched')
+}
+{
+ // create-only: the second update of the same version must not clobber
+ written.clear()
+ const tree: Record<string, any> = {
+ 'Q3.bento.html': fileHandle('Q3.bento.html'),
+ 'Q3.v1.0.16-backup.bento.html': fileHandle('Q3.v1.0.16-backup.bento.html'),
+ }
+ const r = await backup(senderFor('/Users/x/Decks/Q3.bento.html'), 'new bytes',
+ 'Q3.v1.0.16-backup.bento.html', deps(tree))
+ ok(r.ok === false && /already exists/.test(r.reason!),
+ 'an existing file is never overwritten by a backup')
+ ok(written.size === 0, 'and nothing was written')
+}
+{
+ // the backup lands in the sender's OWN subfolder, not the grant root
+ written.clear()
+ const tree: Record<string, any> = {
+ Clients: { 'Q3.bento.html': fileHandle('Q3.bento.html', ['Clients', 'Q3.bento.html']) },
+ }
+ const r = await backup(senderFor('/Users/x/Decks/Clients/Q3.bento.html'), 'old bytes',
+ 'Q3.v1.0.16-backup.bento.html', deps(tree))
+ ok(r.ok === true, 'a nested document backs up successfully')
+ ok(tree.Clients['Q3.v1.0.16-backup.bento.html'] !== undefined,
+ 'and the backup sits beside it, not at the grant root')
+ ok(tree['Q3.v1.0.16-backup.bento.html'] === undefined, 'the grant root is untouched')
+}
+{
+ // every refusal that applies to a write applies here too — this op resolves
+ // through exactly the same gate, and must not have grown a way around it
+ written.clear()
+ const tree: Record<string, any> = {
+ Clients: { 'Q3.bento.html': fileHandle('Q3.bento.html', ['Clients', 'Q3.bento.html']) },
+ }
+ const r = await backup(senderFor('/Users/x/Desktop/Q3.bento.html'), 'attacker bytes',
+ 'Q3.v1-backup.bento.html', deps(tree))
+ ok(r.ok === false, 'a backup from a same-named file elsewhere is refused')
+ ok(written.size === 0, 'and nothing was written')
+}
+{
+ written.clear()
+ const r = await backup({ url: 'https://evil.example/Q3.bento.html' }, 'x',
+ 'Q3.v1-backup.bento.html', deps({ 'Q3.bento.html': fileHandle('Q3.bento.html') }))
+ ok(r.ok === false && /not a local file/.test(r.reason!), 'an http page cannot create a backup')
+ ok(written.size === 0, 'and nothing was written')
+}
+
console.log(`\n${checks - failures}/${checks} checks passed`)
if (failures) process.exit(1)
diff --git a/scripts/test-webext-bridge.ts b/scripts/test-webext-bridge.ts
index 8c0aafe3..d22cc5d0 100644
--- a/scripts/test-webext-bridge.ts
+++ b/scripts/test-webext-bridge.ts
@@ -44,7 +44,10 @@ function load(opts: { version?: string; pathname?: string } = {}) {
bento: opts.version ? { updates: { version: opts.version } } : undefined,
}
const ctx: any = createContext({
- window: win, setTimeout, clearTimeout, Date, Math, JSON, Promise, Blob: class {},
+ // A REAL Blob. It was a bare `class {}`, which was enough for the
+ // `instanceof` branch but has no `.text()` — so every close() rejected and
+ // the half of the bridge that actually sends bytes was never exercised.
+ window: win, setTimeout, clearTimeout, Date, Math, JSON, Promise, Blob,
DOMException: class extends Error { constructor(m: string, n: string) { super(m); this.name = n } },
FileSystemHandle: class {},
crypto: { randomUUID: () => 'x' },
@@ -70,6 +73,7 @@ for (const [id, shouldDefer] of [
['bento-copy', true],
['bento-share', true],
['bento-doc', false],
+ ['bento-backup', false],
] as const) {
const { win, nativeCalls, posted } = load({ version: '1.0.15' })
const p = win.showSaveFilePicker({ id, suggestedName: 'Q3.bento.html' })
@@ -77,9 +81,16 @@ for (const [id, shouldDefer] of [
const deferred = nativeCalls.length === 1
ok(deferred === shouldDefer,
`${id} ${shouldDefer ? 'defers to the native picker' : 'is claimed by the host'}`)
- if (!shouldDefer) {
+ if (id === 'bento-doc') {
ok(posted.some((m) => m.op === 'claim'), 'bento-doc asks the extension to claim the file')
}
+ if (id === 'bento-backup') {
+ // Nothing to claim: the backup does not exist yet, so resolution happens at
+ // the write. What matters is that it never reaches the native picker —
+ // falling through would prompt for a file the author never asked to save,
+ // which is the interruption this whole path exists to remove.
+ ok(!posted.some((m) => m.op === 'claim'), 'a backup does not claim — there is no file yet to resolve')
+ }
p.catch(() => {})
}
@@ -120,5 +131,57 @@ for (const [version, trusted] of [
ok(nativeCalls.length === 1, 'a copy reaches the native picker')
}
+// ---- the host announces what it can do -------------------------------------
+// `showSaveFilePicker` existing proves nothing — Chrome has it anyway, and a
+// host that declines looks exactly like one that is absent, since both end at
+// the native dialog. So the kernel reads `__bentoHost.ops` before taking a path
+// it can only take with help. Presence alone would be the wrong test: a host
+// that announced itself but did not know `bento-backup` would pass the request
+// through to the native picker and produce the very dialog this removes.
+{
+ const { win } = load({ version: '1.0.15' })
+ const host = (win as any).__bentoHost
+ ok(!!host && Array.isArray(host.ops), 'the host announces itself with a capability list')
+ ok(host.ops.includes('backup'), 'and names the backup op the kernel gates on')
+ ok(host.ops.includes('write'), 'and the write op the update path gates on')
+ // A document is untrusted content sharing this realm; it must not be able to
+ // fake a capability the extension does not have, nor hide one it does.
+ try { (win as any).__bentoHost = { ops: ['everything'] } } catch { /* strict mode */ }
+ ok((win as any).__bentoHost.ops.includes('backup') && !(win as any).__bentoHost.ops.includes('everything'),
+ 'and a page cannot overwrite the announcement')
+}
+
+// ---- a backup writes through the host, never the picker --------------------
+{
+ const { win, nativeCalls, posted } = load({ version: '1.0.15' })
+ const h = await win.showSaveFilePicker({ id: 'bento-backup', suggestedName: 'Q3.v1.0.16-backup.bento.html' })
+ ok(nativeCalls.length === 0, 'a backup never reaches the native picker')
+ ok(h?.name === 'Q3.v1.0.16-backup.bento.html', 'and yields a handle named for the backup')
+ const w = await h.createWritable()
+ await w.write('old bytes')
+ // close() serialises the chunks through Blob.text(), which is async — one
+ // tick is not enough, and a rig that checks too early reports the bridge
+ // broken when it is merely mid-flight.
+ const closing = w.close().catch(() => {})
+ await new Promise((r) => setTimeout(r, 20))
+ const req = posted.find((m: any) => m.op === 'backup')
+ ok(!!req, 'closing the writable sends a backup op')
+ ok(req?.payload?.name === 'Q3.v1.0.16-backup.bento.html',
+ 'carrying the proposed name, which the extension validates against the sender\'s own file')
+ ok(req?.payload?.text === 'old bytes', 'and the bytes to write')
+ closing.catch(() => {})
+}
+
+// ---- an old runtime never sends bento-backup, so it never sees this path ----
+{
+ const { win, nativeCalls } = load({ version: '1.0.11' })
+ // The id did not exist before the runtime that sends it, so unlike bento-doc
+ // there is no ambiguous legacy meaning to guard against — but a deck that
+ // does not send it must still behave exactly as it does today.
+ win.showSaveFilePicker({ id: 'bento-doc', suggestedName: 'Q3.bento.html' }).catch(() => {})
+ await new Promise((r) => setTimeout(r, 0))
+ ok(nativeCalls.length === 1, 'a pre-1.0.15 deck still gets the browser picker, unchanged')
+}
+
console.log(`\n${checks - failures}/${checks} checks passed`)
if (failures) process.exit(1)
diff --git a/slides/src/editor/editor.ts b/slides/src/editor/editor.ts
index 19364a16..e4d3e84f 100644
--- a/slides/src/editor/editor.ts
+++ b/slides/src/editor/editor.ts
@@ -12,6 +12,7 @@ import {
paginates, inLinearFlow,
type ChartElement, type ShapeKind, type Slide, type SlideElement, type TableElement } from '../model'
import { THEME_CHOICES, setTheme, themeChoice } from '../../../kernel/src/theme.ts'
+import type { InPlaceOutcome } from '../update'
import { APP_VERSION, applyUpdate, applyUpdateInPlace, autoCheckEnabled, canUpdateInPlace, checkForUpdates, compareVersions, offlineEnabled, setAutoCheck, setOffline } from '../update'
import { CHART_PRESETS } from '../charts'
import { renderSlide, renderThumbnail } from '../render'
@@ -2842,7 +2843,7 @@ export class Editor {
}
const actions = div('ed-about-actions')
const fail = (err: any) => { status.textContent = t('Update failed: {m}', { m: String(err?.message ?? err) }) }
- const done = () => {
+ const done = (outcome: InPlaceOutcome) => {
status.textContent = ''
const after = div('ed-about-update')
status.appendChild(after)
@@ -2850,9 +2851,14 @@ export class Editor {
ok.textContent = t('Updated to v{v} on disk.', { v: release.version })
after.appendChild(ok)
const note = div('ed-about-notes')
- note.textContent = canUpdateInPlace()
- ? t('This window is still running v{v} — reload to finish. A v{v} backup was downloaded.', { v: APP_VERSION })
- : t("This window is still running v{v}. If you overwrote the file that's open here, reload; otherwise open the file you saved.", { v: APP_VERSION })
+ // Say where the rollback actually went. It lands beside the document
+ // with a host installed and in the downloads folder without one, and
+ // a backup nobody can find is not much of a backup.
+ note.textContent = outcome.backup === 'beside'
+ ? t('This window is still running v{v} — reload to finish. A v{v} backup was saved beside this file.', { v: APP_VERSION })
+ : outcome.backup === 'downloaded'
+ ? t('This window is still running v{v} — reload to finish. A v{v} backup was downloaded.', { v: APP_VERSION })
+ : t("This window is still running v{v}. If you overwrote the file that's open here, reload; otherwise open the file you saved.", { v: APP_VERSION })
after.appendChild(note)
const reloadB = document.createElement('button')
reloadB.className = 'ed-btn ed-btn-primary'
@@ -2896,7 +2902,7 @@ export class Editor {
try {
this.session?.stampInto(this.store.doc)
const written = await applyUpdateInPlace(release, this.store.doc)
- if (written) done()
+ if (written) done(written)
else { inPlaceB.disabled = false; inPlaceB.textContent = t('Update this file…') }
} catch (err: any) { fail(err) }
})
diff --git a/slides/src/i18n/de.ts b/slides/src/i18n/de.ts
index ba1076b6..684b59b4 100644
--- a/slides/src/i18n/de.ts
+++ b/slides/src/i18n/de.ts
@@ -206,6 +206,7 @@ export const de: Catalog = {
"This browser can’t rewrite files in place — a fresh copy went to Downloads": "Dieser Browser kann Dateien nicht direkt überschreiben — eine neue Kopie liegt in Downloads",
"This document": "Dieses Dokument",
"This file carries its own app — it works offline, forever, as is.": "Diese Datei trägt ihre eigene App — sie funktioniert offline, für immer, so wie sie ist.",
+ "This window is still running v{v} — reload to finish. A v{v} backup was saved beside this file.": "Dieses Fenster läuft noch mit v{v} — zum Abschließen neu laden. Ein v{v}-Backup wurde neben dieser Datei gespeichert.",
"This window is still running v{v} — reload to finish. A v{v} backup was downloaded.": "Dieses Fenster läuft noch mit v{v} — zum Abschließen neu laden. Ein v{v}-Backup wurde heruntergeladen.",
"This window is still running v{v}. If you overwrote the file that's open here, reload; otherwise open the file you saved.": "Dieses Fenster läuft noch mit v{v}. Wenn Sie die geöffnete Datei überschrieben haben, neu laden; andernfalls die gespeicherte Datei öffnen.",
"This window keeps running v{v} until you open the downloaded file.": "Dieses Fenster bleibt bei v{v}, bis Sie die heruntergeladene Datei öffnen.",
diff --git a/slides/src/i18n/es.ts b/slides/src/i18n/es.ts
index 7bc6da18..88b2428f 100644
--- a/slides/src/i18n/es.ts
+++ b/slides/src/i18n/es.ts
@@ -206,6 +206,7 @@ export const es: Catalog = {
"This browser can’t rewrite files in place — a fresh copy went to Downloads": "Este navegador no puede reescribir archivos en el sitio — una copia nueva fue a Descargas",
"This document": "Este documento",
"This file carries its own app — it works offline, forever, as is.": "Este archivo lleva su propia aplicación — funciona sin conexión, para siempre, tal cual.",
+ "This window is still running v{v} — reload to finish. A v{v} backup was saved beside this file.": "Esta ventana sigue en v{v} — recarga para terminar. Se guardó una copia de seguridad v{v} junto a este archivo.",
"This window is still running v{v} — reload to finish. A v{v} backup was downloaded.": "Esta ventana sigue en v{v} — recarga para terminar. Se descargó una copia de seguridad v{v}.",
"This window is still running v{v}. If you overwrote the file that's open here, reload; otherwise open the file you saved.": "Esta ventana sigue en v{v}. Si sobrescribiste el archivo abierto aquí, recarga; si no, abre el archivo que guardaste.",
"This window keeps running v{v} until you open the downloaded file.": "Esta ventana seguirá en v{v} hasta que abras el archivo descargado.",
diff --git a/slides/src/i18n/fr.ts b/slides/src/i18n/fr.ts
index 646c181e..5782cd12 100644
--- a/slides/src/i18n/fr.ts
+++ b/slides/src/i18n/fr.ts
@@ -206,6 +206,7 @@ export const fr: Catalog = {
"This browser can’t rewrite files in place — a fresh copy went to Downloads": "Ce navigateur ne peut pas réécrire les fichiers sur place — une copie est allée dans Téléchargements",
"This document": "Ce document",
"This file carries its own app — it works offline, forever, as is.": "Ce fichier embarque sa propre application — il fonctionne hors ligne, pour toujours, tel quel.",
+ "This window is still running v{v} — reload to finish. A v{v} backup was saved beside this file.": "Cette fenêtre tourne encore en v{v} — rechargez pour terminer. Une sauvegarde v{v} a été enregistrée à côté de ce fichier.",
"This window is still running v{v} — reload to finish. A v{v} backup was downloaded.": "Cette fenêtre tourne encore en v{v} — rechargez pour terminer. Une sauvegarde v{v} a été téléchargée.",
"This window is still running v{v}. If you overwrote the file that's open here, reload; otherwise open the file you saved.": "Cette fenêtre tourne encore en v{v}. Si vous avez écrasé le fichier ouvert ici, rechargez ; sinon ouvrez le fichier enregistré.",
"This window keeps running v{v} until you open the downloaded file.": "Cette fenêtre reste en v{v} jusqu'à l'ouverture du fichier téléchargé.",
diff --git a/slides/src/i18n/it.ts b/slides/src/i18n/it.ts
index 1ca8413f..f1a1edb0 100644
--- a/slides/src/i18n/it.ts
+++ b/slides/src/i18n/it.ts
@@ -206,6 +206,7 @@ export const it: Catalog = {
"This browser can’t rewrite files in place — a fresh copy went to Downloads": "Questo browser non può riscrivere i file sul posto — una nuova copia è in Download",
"This document": "Questo documento",
"This file carries its own app — it works offline, forever, as is.": "Questo file porta con sé la propria app — funziona offline, per sempre, così com'è.",
+ "This window is still running v{v} — reload to finish. A v{v} backup was saved beside this file.": "Questa finestra esegue ancora la v{v} — ricarica per completare. Un backup v{v} è stato salvato accanto a questo file.",
"This window is still running v{v} — reload to finish. A v{v} backup was downloaded.": "Questa finestra esegue ancora la v{v} — ricarica per completare. È stato scaricato un backup v{v}.",
"This window is still running v{v}. If you overwrote the file that's open here, reload; otherwise open the file you saved.": "Questa finestra esegue ancora la v{v}. Se hai sovrascritto il file aperto qui, ricarica; altrimenti apri il file salvato.",
"This window keeps running v{v} until you open the downloaded file.": "Questa finestra resta alla v{v} finché non apri il file scaricato.",
diff --git a/slides/src/i18n/ja.ts b/slides/src/i18n/ja.ts
index 619d0a6c..960a2c05 100644
--- a/slides/src/i18n/ja.ts
+++ b/slides/src/i18n/ja.ts
@@ -206,6 +206,7 @@ export const ja: Catalog = {
"This browser can’t rewrite files in place — a fresh copy went to Downloads": "このブラウザはファイルの直接書き換えに未対応 — 新しいコピーをダウンロードしました",
"This document": "このドキュメント",
"This file carries its own app — it works offline, forever, as is.": "このファイルはアプリを内蔵しています — オフラインでも、ずっと、このまま動きます。",
+ "This window is still running v{v} — reload to finish. A v{v} backup was saved beside this file.": "このウィンドウはまだ v{v} で動作中 — 再読込で完了します。v{v} のバックアップをこのファイルの隣に保存しました。",
"This window is still running v{v} — reload to finish. A v{v} backup was downloaded.": "このウィンドウはまだ v{v} で動作中 — 再読込で完了します。v{v} のバックアップをダウンロード済み。",
"This window is still running v{v}. If you overwrote the file that's open here, reload; otherwise open the file you saved.": "このウィンドウはまだ v{v} で動作中。開いているファイルを上書きした場合は再読込を。別に保存した場合はそのファイルを開いてください。",
"This window keeps running v{v} until you open the downloaded file.": "ダウンロードしたファイルを開くまで、このウィンドウは v{v} のままです。",
diff --git a/slides/src/i18n/packed.ts b/slides/src/i18n/packed.ts
index 7d862882..473d115e 100644
--- a/slides/src/i18n/packed.ts
+++ b/slides/src/i18n/packed.ts
@@ -217,6 +217,7 @@ export const PACKED: Record<string, ReadonlyArray<string | 0>> = {
"This browser can’t rewrite files in place — a fresh copy went to Downloads": ["このブラウザはファイルの直接書き換えに未対応 — 新しいコピーをダウンロードしました","此浏览器无法就地改写文件 — 新副本已存入下载","此瀏覽器無法就地改寫檔案 — 新副本已存入下載項目","Este navegador no puede reescribir archivos en el sitio — una copia nueva fue a Descargas","Ce navigateur ne peut pas réécrire les fichiers sur place — une copie est allée dans Téléchargements","Dieser Browser kann Dateien nicht direkt überschreiben — eine neue Kopie liegt in Downloads","Questo browser non può riscrivere i file sul posto — una nuova copia è in Download","Este navegador não consegue regravar arquivos no lugar — uma nova cópia foi para Downloads"],
"This document": ["このドキュメント","此文档","此文件","Este documento","Ce document","Dieses Dokument","Questo documento","Este documento"],
"This file carries its own app — it works offline, forever, as is.": ["このファイルはアプリを内蔵しています — オフラインでも、ずっと、このまま動きます。","此文件自带应用 — 离线可用,永久如此。","此檔案自帶應用程式 — 離線可用,永遠如此。","Este archivo lleva su propia aplicación — funciona sin conexión, para siempre, tal cual.","Ce fichier embarque sa propre application — il fonctionne hors ligne, pour toujours, tel quel.","Diese Datei trägt ihre eigene App — sie funktioniert offline, für immer, so wie sie ist.","Questo file porta con sé la propria app — funziona offline, per sempre, così com'è.","Este arquivo carrega o próprio aplicativo — funciona offline, para sempre, do jeito que está."],
+ "This window is still running v{v} — reload to finish. A v{v} backup was saved beside this file.": ["このウィンドウはまだ v{v} で動作中 — 再読込で完了します。v{v} のバックアップをこのファイルの隣に保存しました。","此窗口仍在运行 v{v} — 重新加载以完成。已在此文件旁保存 v{v} 备份。","此視窗仍在執行 v{v} — 重新載入以完成。已在此檔案旁儲存 v{v} 備份。","Esta ventana sigue en v{v} — recarga para terminar. Se guardó una copia de seguridad v{v} junto a este archivo.","Cette fenêtre tourne encore en v{v} — rechargez pour terminer. Une sauvegarde v{v} a été enregistrée à côté de ce fichier.","Dieses Fenster läuft noch mit v{v} — zum Abschließen neu laden. Ein v{v}-Backup wurde neben dieser Datei gespeichert.","Questa finestra esegue ancora la v{v} — ricarica per completare. Un backup v{v} è stato salvato accanto a questo file.","Esta janela ainda está executando a v{v} — recarregue para concluir. Um backup da v{v} foi salvo ao lado deste arquivo."],
"This window is still running v{v} — reload to finish. A v{v} backup was downloaded.": ["このウィンドウはまだ v{v} で動作中 — 再読込で完了します。v{v} のバックアップをダウンロード済み。","此窗口仍在运行 v{v} — 重新加载以完成。已下载 v{v} 备份。","此視窗仍在執行 v{v} — 重新載入以完成。已下載 v{v} 備份。","Esta ventana sigue en v{v} — recarga para terminar. Se descargó una copia de seguridad v{v}.","Cette fenêtre tourne encore en v{v} — rechargez pour terminer. Une sauvegarde v{v} a été téléchargée.","Dieses Fenster läuft noch mit v{v} — zum Abschließen neu laden. Ein v{v}-Backup wurde heruntergeladen.","Questa finestra esegue ancora la v{v} — ricarica per completare. È stato scaricato un backup v{v}.","Esta janela ainda está executando a v{v} — recarregue para concluir. Um backup da v{v} foi baixado."],
"This window is still running v{v}. If you overwrote the file that's open here, reload; otherwise open the file you saved.": ["このウィンドウはまだ v{v} で動作中。開いているファイルを上書きした場合は再読込を。別に保存した場合はそのファイルを開いてください。","此窗口仍在运行 v{v}。若覆盖了当前打开的文件请重新加载;否则请打开您保存的文件。","此視窗仍在執行 v{v}。若已覆寫目前開啟的檔案請重新載入;否則請開啟您儲存的檔案。","Esta ventana sigue en v{v}. Si sobrescribiste el archivo abierto aquí, recarga; si no, abre el archivo que guardaste.","Cette fenêtre tourne encore en v{v}. Si vous avez écrasé le fichier ouvert ici, rechargez ; sinon ouvrez le fichier enregistré.","Dieses Fenster läuft noch mit v{v}. Wenn Sie die geöffnete Datei überschrieben haben, neu laden; andernfalls die gespeicherte Datei öffnen.","Questa finestra esegue ancora la v{v}. Se hai sovrascritto il file aperto qui, ricarica; altrimenti apri il file salvato.","Esta janela ainda está executando a v{v}. Se você sobrescreveu o arquivo aberto aqui, recarregue; caso contrário, abra o arquivo que salvou."],
"This window keeps running v{v} until you open the downloaded file.": ["ダウンロードしたファイルを開くまで、このウィンドウは v{v} のままです。","在打开下载的文件之前,此窗口将继续运行 v{v}。","在開啟下載的檔案之前,此視窗會維持在 v{v}。","Esta ventana seguirá en v{v} hasta que abras el archivo descargado.","Cette fenêtre reste en v{v} jusqu'à l'ouverture du fichier téléchargé.","Dieses Fenster bleibt bei v{v}, bis Sie die heruntergeladene Datei öffnen.","Questa finestra resta alla v{v} finché non apri il file scaricato.","Esta janela continua executando a v{v} até você abrir o arquivo baixado."],
diff --git a/slides/src/i18n/packs/ar.ts b/slides/src/i18n/packs/ar.ts
index a753be4f..ce06bdd9 100644
--- a/slides/src/i18n/packs/ar.ts
+++ b/slides/src/i18n/packs/ar.ts
@@ -224,6 +224,7 @@ export const strings: Catalog = {
"This browser can’t rewrite files in place — a fresh copy went to Downloads": "هذا المتصفح لا يستطيع إعادة كتابة الملفات في مكانها — نُزّلت نسخة جديدة إلى مجلد التنزيلات",
"This document": "هذا المستند",
"This file carries its own app — it works offline, forever, as is.": "هذا الملف يحمل تطبيقه بداخله — يعمل دون اتصال، إلى الأبد، كما هو.",
+ "This window is still running v{v} — reload to finish. A v{v} backup was saved beside this file.": "لا تزال هذه النافذة تعمل بالإصدار {v} — أعِد التحميل لإتمام العملية. وقد حُفظت نسخة احتياطية من الإصدار {v} بجوار هذا الملف.",
"This window is still running v{v} — reload to finish. A v{v} backup was downloaded.": "لا تزال هذه النافذة تعمل بالإصدار {v} — أعِد التحميل لإتمام العملية. وقد نُزّلت نسخة احتياطية من الإصدار {v}.",
"This window is still running v{v}. If you overwrote the file that's open here, reload; otherwise open the file you saved.": "لا تزال هذه النافذة تعمل بالإصدار {v}. إذا كنت قد استبدلت الملف المفتوح هنا فأعِد التحميل، وإلا فافتح الملف الذي حفظته.",
"This window keeps running v{v} until you open the downloaded file.": "تظل هذه النافذة تعمل بالإصدار {v} حتى تفتح الملف الذي نزّلته.",
diff --git a/slides/src/i18n/packs/bn.ts b/slides/src/i18n/packs/bn.ts
index 3704451a..3153161e 100644
--- a/slides/src/i18n/packs/bn.ts
+++ b/slides/src/i18n/packs/bn.ts
@@ -227,6 +227,7 @@ export const strings: Catalog = {
"This browser can’t rewrite files in place — a fresh copy went to Downloads": "এই ব্রাউজার ফাইলকে তার নিজের জায়গায় নতুন করে লিখতে পারে না — একটি নতুন কপি Downloads-এ গেছে",
"This document": "এই ডকুমেন্ট",
"This file carries its own app — it works offline, forever, as is.": "এই ফাইল নিজের অ্যাপ নিজেই বয়ে নিয়ে চলে — যেমন আছে তেমনই, অফলাইনে, চিরকাল কাজ করে।",
+ "This window is still running v{v} — reload to finish. A v{v} backup was saved beside this file.": "এই উইন্ডোতে এখনো v{v} চলছে — শেষ করতে রিলোড করুন। v{v}-এর একটি ব্যাকআপ এই ফাইলের পাশে সংরক্ষিত হয়েছে।",
"This window is still running v{v} — reload to finish. A v{v} backup was downloaded.": "এই উইন্ডোতে এখনো v{v} চলছে — শেষ করতে রিলোড করুন। v{v}-এর একটি ব্যাকআপ ডাউনলোড হয়েছে।",
"This window is still running v{v}. If you overwrote the file that's open here, reload; otherwise open the file you saved.": "এই উইন্ডোতে এখনো v{v} চলছে। এখানে খোলা ফাইলটির উপরেই যদি লিখে থাকেন, তবে রিলোড করুন; নাহলে যে ফাইলটি সেভ করেছেন সেটি খুলুন।",
"This window keeps running v{v} until you open the downloaded file.": "ডাউনলোড করা ফাইলটি না খোলা পর্যন্ত এই উইন্ডোতে v{v} চলতেই থাকবে।",
diff --git a/slides/src/i18n/packs/da.ts b/slides/src/i18n/packs/da.ts
index c3ef3b20..c4ee4f37 100644
--- a/slides/src/i18n/packs/da.ts
+++ b/slides/src/i18n/packs/da.ts
@@ -216,6 +216,7 @@ export const strings: Catalog = {
"This browser can’t rewrite files in place — a fresh copy went to Downloads": "Denne browser kan ikke overskrive filer direkte — en ny kopi er lagt i Downloads",
"This document": "Dette dokument",
"This file carries its own app — it works offline, forever, as is.": "Denne fil har sin egen app med — den virker offline, for altid, som den er.",
+ "This window is still running v{v} — reload to finish. A v{v} backup was saved beside this file.": "Dette vindue kører stadig v{v} — genindlæs for at gøre det færdigt. En sikkerhedskopi af v{v} blev gemt ved siden af denne fil.",
"This window is still running v{v} — reload to finish. A v{v} backup was downloaded.": "Dette vindue kører stadig v{v} — genindlæs for at gøre det færdigt. En sikkerhedskopi af v{v} blev hentet.",
"This window is still running v{v}. If you overwrote the file that's open here, reload; otherwise open the file you saved.": "Dette vindue kører stadig v{v}. Hvis du overskrev den fil, der er åben her, så genindlæs; ellers åbn den fil, du gemte.",
"This window keeps running v{v} until you open the downloaded file.": "Dette vindue bliver ved med at køre v{v}, indtil du åbner den hentede fil.",
diff --git a/slides/src/i18n/packs/fa.ts b/slides/src/i18n/packs/fa.ts
index 75832eaf..c438347c 100644
--- a/slides/src/i18n/packs/fa.ts
+++ b/slides/src/i18n/packs/fa.ts
@@ -220,6 +220,7 @@ export const strings: Catalog = {
"This browser can’t rewrite files in place — a fresh copy went to Downloads": "این مرورگر نمی‌تواند فایل‌ها را در جای خود بازنویسی کند — یک نسخهٔ تازه در پوشهٔ دانلودها ذخیره شد",
"This document": "همین سند",
"This file carries its own app — it works offline, forever, as is.": "این فایل برنامهٔ خودش را همراه دارد — بدون اینترنت، برای همیشه، همین‌طور که هست کار می‌کند.",
+ "This window is still running v{v} — reload to finish. A v{v} backup was saved beside this file.": "این پنجره هنوز نسخهٔ {v} را اجرا می‌کند — برای پایان کار دوباره بارگذاری کنید. یک پشتیبان از نسخهٔ {v} کنار این پرونده ذخیره شد.",
"This window is still running v{v} — reload to finish. A v{v} backup was downloaded.": "این پنجره هنوز نسخهٔ {v} را اجرا می‌کند — برای پایان کار دوباره بارگذاری کنید. یک پشتیبان از نسخهٔ {v} دانلود شد.",
"This window is still running v{v}. If you overwrote the file that's open here, reload; otherwise open the file you saved.": "این پنجره هنوز نسخهٔ {v} را اجرا می‌کند. اگر فایلِ باز در اینجا را بازنویسی کرده‌اید، دوباره بارگذاری کنید؛ در غیر این صورت فایلی را که ذخیره کردید باز کنید.",
"This window keeps running v{v} until you open the downloaded file.": "این پنجره تا وقتی فایل دانلودشده را باز نکنید، همچنان نسخهٔ {v} را اجرا می‌کند.",
diff --git a/slides/src/i18n/packs/fi.ts b/slides/src/i18n/packs/fi.ts
index b83ea254..97b5ec1f 100644
--- a/slides/src/i18n/packs/fi.ts
+++ b/slides/src/i18n/packs/fi.ts
@@ -221,6 +221,7 @@ export const strings: Catalog = {
"This browser can’t rewrite files in place — a fresh copy went to Downloads": "Tämä selain ei voi korvata tiedostoja suoraan — uusi kopio ladattiin Lataukset-kansioon",
"This document": "Tämä asiakirja",
"This file carries its own app — it works offline, forever, as is.": "Tämä tiedosto kantaa oman sovelluksensa — se toimii offline-tilassa, ikuisesti, sellaisenaan.",
+ "This window is still running v{v} — reload to finish. A v{v} backup was saved beside this file.": "Tässä ikkunassa on yhä käytössä versio v{v} — viimeistele lataamalla uudelleen. Versiosta v{v} tallennettiin varmuuskopio tämän tiedoston viereen.",
"This window is still running v{v} — reload to finish. A v{v} backup was downloaded.": "Tässä ikkunassa on yhä käytössä versio v{v} — viimeistele lataamalla uudelleen. Versiosta v{v} ladattiin varmuuskopio.",
"This window is still running v{v}. If you overwrote the file that's open here, reload; otherwise open the file you saved.": "Tässä ikkunassa on yhä käytössä versio v{v}. Jos korvasit tässä avoinna olevan tiedoston, lataa uudelleen; muussa tapauksessa avaa tallentamasi tiedosto.",
"This window keeps running v{v} until you open the downloaded file.": "Tässä ikkunassa on käytössä versio v{v}, kunnes avaat ladatun tiedoston.",
diff --git a/slides/src/i18n/packs/he.ts b/slides/src/i18n/packs/he.ts
index 69274d42..13f0c121 100644
--- a/slides/src/i18n/packs/he.ts
+++ b/slides/src/i18n/packs/he.ts
@@ -217,6 +217,7 @@ export const strings: Catalog = {
"This browser can’t rewrite files in place — a fresh copy went to Downloads": "הדפדפן הזה אינו יכול לשכתב קבצים במקומם — עותק חדש נשמר בתיקיית ההורדות",
"This document": "המסמך הזה",
"This file carries its own app — it works offline, forever, as is.": "הקובץ הזה נושא בתוכו את היישום שלו — הוא עובד גם ללא חיבור, לתמיד, כמו שהוא.",
+ "This window is still running v{v} — reload to finish. A v{v} backup was saved beside this file.": "החלון הזה עדיין מריץ את גרסה {v} — טענו מחדש כדי לסיים. גיבוי של גרסה {v} נשמר לצד הקובץ הזה.",
"This window is still running v{v} — reload to finish. A v{v} backup was downloaded.": "החלון הזה עדיין מריץ את גרסה {v} — טענו מחדש כדי לסיים. גיבוי של גרסה {v} הורד.",
"This window is still running v{v}. If you overwrote the file that's open here, reload; otherwise open the file you saved.": "החלון הזה עדיין מריץ את גרסה {v}. אם שכתבתם את הקובץ הפתוח כאן, טענו מחדש; אחרת פתחו את הקובץ ששמרתם.",
"This window keeps running v{v} until you open the downloaded file.": "החלון הזה ימשיך להריץ את גרסה {v} עד שתפתחו את הקובץ שהורד.",
diff --git a/slides/src/i18n/packs/hi.ts b/slides/src/i18n/packs/hi.ts
index aff17d13..386c1338 100644
--- a/slides/src/i18n/packs/hi.ts
+++ b/slides/src/i18n/packs/hi.ts
@@ -224,6 +224,7 @@ export const strings: Catalog = {
"This browser can’t rewrite files in place — a fresh copy went to Downloads": "यह ब्राउज़र फ़ाइलों को उसी जगह दोबारा नहीं लिख सकता — एक नई कॉपी Downloads में चली गई",
"This document": "यह दस्तावेज़",
"This file carries its own app — it works offline, forever, as is.": "यह फ़ाइल अपना ऐप ख़ुद साथ लेकर चलती है — यह जैसी है वैसी ही, हमेशा, ऑफ़लाइन काम करती है।",
+ "This window is still running v{v} — reload to finish. A v{v} backup was saved beside this file.": "यह विंडो अब भी v{v} चला रही है — पूरा करने के लिए दोबारा लोड करें। v{v} का बैकअप इस फ़ाइल के बगल में सहेजा गया।",
"This window is still running v{v} — reload to finish. A v{v} backup was downloaded.": "यह विंडो अब भी v{v} चला रही है — पूरा करने के लिए दोबारा लोड करें। v{v} का बैकअप डाउनलोड हो गया।",
"This window is still running v{v}. If you overwrote the file that's open here, reload; otherwise open the file you saved.": "यह विंडो अब भी v{v} चला रही है। अगर यहां खुली हुई फ़ाइल को ही बदला है, तो दोबारा लोड करें; वरना जो फ़ाइल सेव की है उसे खोलें।",
"This window keeps running v{v} until you open the downloaded file.": "जब तक आप डाउनलोड की गई फ़ाइल नहीं खोलते, यह विंडो v{v} ही चलाती रहेगी।",
diff --git a/slides/src/i18n/packs/id.ts b/slides/src/i18n/packs/id.ts
index 9c66825d..2de01f9b 100644
--- a/slides/src/i18n/packs/id.ts
+++ b/slides/src/i18n/packs/id.ts
@@ -214,6 +214,7 @@ export const strings: Catalog = {
"This browser can’t rewrite files in place — a fresh copy went to Downloads": "Browser ini tidak dapat menulis ulang file di tempatnya — salinan baru dikirim ke folder Unduhan",
"This document": "Dokumen ini",
"This file carries its own app — it works offline, forever, as is.": "File ini membawa aplikasinya sendiri — berfungsi offline, selamanya, apa adanya.",
+ "This window is still running v{v} — reload to finish. A v{v} backup was saved beside this file.": "Jendela ini masih menjalankan v{v} — muat ulang untuk menyelesaikannya. Cadangan v{v} disimpan di samping berkas ini.",
"This window is still running v{v} — reload to finish. A v{v} backup was downloaded.": "Jendela ini masih menjalankan v{v} — muat ulang untuk menyelesaikannya. Cadangan v{v} telah diunduh.",
"This window is still running v{v}. If you overwrote the file that's open here, reload; otherwise open the file you saved.": "Jendela ini masih menjalankan v{v}. Jika Anda menimpa file yang terbuka di sini, muat ulang; jika tidak, buka file yang Anda simpan.",
"This window keeps running v{v} until you open the downloaded file.": "Jendela ini tetap menjalankan v{v} sampai Anda membuka file yang diunduh.",
diff --git a/slides/src/i18n/packs/ko.ts b/slides/src/i18n/packs/ko.ts
index 4dd08277..cb443a95 100644
--- a/slides/src/i18n/packs/ko.ts
+++ b/slides/src/i18n/packs/ko.ts
@@ -200,6 +200,7 @@ export const strings: Catalog = {
"This browser can’t rewrite files in place — a fresh copy went to Downloads": "이 브라우저는 파일을 제자리에 다시 쓸 수 없습니다 — 새 사본이 다운로드 폴더에 저장되었습니다",
"This document": "이 문서",
"This file carries its own app — it works offline, forever, as is.": "이 파일은 자체 앱을 담고 있습니다 — 지금 이 상태 그대로 오프라인에서 영원히 동작합니다.",
+ "This window is still running v{v} — reload to finish. A v{v} backup was saved beside this file.": "이 창은 아직 v{v}를 실행 중입니다 — 다시 불러와 마무리하세요. v{v} 백업이 이 파일 옆에 저장되었습니다.",
"This window is still running v{v} — reload to finish. A v{v} backup was downloaded.": "이 창은 아직 v{v}를 실행 중입니다 — 다시 불러와 마무리하세요. v{v} 백업이 다운로드되었습니다.",
"This window is still running v{v}. If you overwrote the file that's open here, reload; otherwise open the file you saved.": "이 창은 아직 v{v}를 실행 중입니다. 여기 열린 파일을 덮어썼다면 다시 불러오고, 그렇지 않으면 저장한 파일을 여세요.",
"This window keeps running v{v} until you open the downloaded file.": "다운로드한 파일을 열기 전까지 이 창은 계속 v{v}를 실행합니다.",
diff --git a/slides/src/i18n/packs/ms.ts b/slides/src/i18n/packs/ms.ts
index 5ee5738d..a412938f 100644
--- a/slides/src/i18n/packs/ms.ts
+++ b/slides/src/i18n/packs/ms.ts
@@ -217,6 +217,7 @@ export const strings: Catalog = {
"This browser can’t rewrite files in place — a fresh copy went to Downloads": "Pelayar ini tidak dapat menulis semula fail di tempatnya — salinan baharu dihantar ke folder Muat Turun",
"This document": "Dokumen ini",
"This file carries its own app — it works offline, forever, as is.": "Fail ini membawa aplikasinya sendiri — ia berfungsi luar talian, selama-lamanya, sebagaimana adanya.",
+ "This window is still running v{v} — reload to finish. A v{v} backup was saved beside this file.": "Tetingkap ini masih menjalankan v{v} — muat semula untuk menyelesaikannya. Sandaran v{v} disimpan di sebelah fail ini.",
"This window is still running v{v} — reload to finish. A v{v} backup was downloaded.": "Tetingkap ini masih menjalankan v{v} — muat semula untuk menyelesaikannya. Sandaran v{v} telah dimuat turun.",
"This window is still running v{v}. If you overwrote the file that's open here, reload; otherwise open the file you saved.": "Tetingkap ini masih menjalankan v{v}. Jika anda menimpa fail yang terbuka di sini, muat semula; jika tidak, buka fail yang anda simpan.",
"This window keeps running v{v} until you open the downloaded file.": "Tetingkap ini terus menjalankan v{v} sehingga anda membuka fail yang dimuat turun.",
diff --git a/slides/src/i18n/packs/nb.ts b/slides/src/i18n/packs/nb.ts
index 754c1c29..b7bbd1a7 100644
--- a/slides/src/i18n/packs/nb.ts
+++ b/slides/src/i18n/packs/nb.ts
@@ -218,6 +218,7 @@ export const strings: Catalog = {
"This browser can’t rewrite files in place — a fresh copy went to Downloads": "Denne nettleseren kan ikke skrive over filer direkte — en ny kopi er lagt i Nedlastinger",
"This document": "Dette dokumentet",
"This file carries its own app — it works offline, forever, as is.": "Denne filen har med seg sin egen app — den virker offline, for alltid, som den er.",
+ "This window is still running v{v} — reload to finish. A v{v} backup was saved beside this file.": "Dette vinduet kjører fortsatt v{v} — last inn på nytt for å fullføre. En sikkerhetskopi av v{v} ble lagret ved siden av denne filen.",
"This window is still running v{v} — reload to finish. A v{v} backup was downloaded.": "Dette vinduet kjører fortsatt v{v} — last inn på nytt for å fullføre. En sikkerhetskopi av v{v} ble lastet ned.",
"This window is still running v{v}. If you overwrote the file that's open here, reload; otherwise open the file you saved.": "Dette vinduet kjører fortsatt v{v}. Hvis du skrev over filen som er åpen her, laster du inn på nytt; ellers åpner du filen du lagret.",
"This window keeps running v{v} until you open the downloaded file.": "Dette vinduet fortsetter å kjøre v{v} til du åpner den nedlastede filen.",
diff --git a/slides/src/i18n/packs/nl.ts b/slides/src/i18n/packs/nl.ts
index de69b619..1c6120ba 100644
--- a/slides/src/i18n/packs/nl.ts
+++ b/slides/src/i18n/packs/nl.ts
@@ -212,6 +212,7 @@ export const strings: Catalog = {
"This browser can’t rewrite files in place — a fresh copy went to Downloads": "Deze browser kan bestanden niet ter plekke overschrijven — er staat een nieuwe kopie in Downloads",
"This document": "Dit document",
"This file carries its own app — it works offline, forever, as is.": "Dit bestand draagt zijn eigen app bij zich — het werkt offline, voor altijd, zoals het is.",
+ "This window is still running v{v} — reload to finish. A v{v} backup was saved beside this file.": "Dit venster draait nog v{v} — laad opnieuw om af te ronden. Er is een back-up van v{v} naast dit bestand opgeslagen.",
"This window is still running v{v} — reload to finish. A v{v} backup was downloaded.": "Dit venster draait nog v{v} — laad opnieuw om af te ronden. Er is een back-up van v{v} gedownload.",
"This window is still running v{v}. If you overwrote the file that's open here, reload; otherwise open the file you saved.": "Dit venster draait nog v{v}. Heb je het bestand overschreven dat hier openstaat, laad dan opnieuw; open anders het bestand dat je hebt opgeslagen.",
"This window keeps running v{v} until you open the downloaded file.": "Dit venster blijft v{v} draaien totdat je het gedownloade bestand opent.",
diff --git a/slides/src/i18n/packs/pl.ts b/slides/src/i18n/packs/pl.ts
index 0dcadb90..dc3dffef 100644
--- a/slides/src/i18n/packs/pl.ts
+++ b/slides/src/i18n/packs/pl.ts
@@ -215,6 +215,7 @@ export const strings: Catalog = {
"This browser can’t rewrite files in place — a fresh copy went to Downloads": "Ta przeglądarka nie potrafi nadpisywać plików w miejscu — świeża kopia trafiła do Pobranych",
"This document": "Ten dokument",
"This file carries its own app — it works offline, forever, as is.": "Ten plik niesie własną aplikację — działa offline, na zawsze, taki jaki jest.",
+ "This window is still running v{v} — reload to finish. A v{v} backup was saved beside this file.": "To okno wciąż działa na wersji v{v} — przeładuj je, aby dokończyć. Kopię zapasową wersji v{v} zapisano obok tego pliku.",
"This window is still running v{v} — reload to finish. A v{v} backup was downloaded.": "To okno wciąż działa na wersji v{v} — przeładuj je, aby dokończyć. Pobrano kopię zapasową wersji v{v}.",
"This window is still running v{v}. If you overwrote the file that's open here, reload; otherwise open the file you saved.": "To okno wciąż działa na wersji v{v}. Jeśli nadpisano plik otwarty tutaj, przeładuj je; w przeciwnym razie otwórz zapisany plik.",
"This window keeps running v{v} until you open the downloaded file.": "To okno działa dalej na wersji v{v}, dopóki nie otworzysz pobranego pliku.",
diff --git a/slides/src/i18n/packs/ru.ts b/slides/src/i18n/packs/ru.ts
index cbb75704..0f4629a3 100644
--- a/slides/src/i18n/packs/ru.ts
+++ b/slides/src/i18n/packs/ru.ts
@@ -216,6 +216,7 @@ export const strings: Catalog = {
"This browser can’t rewrite files in place — a fresh copy went to Downloads": "Этот браузер не может перезаписывать файлы на месте — новая копия отправлена в папку «Загрузки»",
"This document": "Этот документ",
"This file carries its own app — it works offline, forever, as is.": "Этот файл несёт в себе собственное приложение — он работает без сети, всегда, как есть.",
+ "This window is still running v{v} — reload to finish. A v{v} backup was saved beside this file.": "В этом окне по-прежнему работает v{v} — перезагрузите, чтобы завершить. Резервная копия v{v} сохранена рядом с этим файлом.",
"This window is still running v{v} — reload to finish. A v{v} backup was downloaded.": "В этом окне по-прежнему работает v{v} — перезагрузите, чтобы завершить. Резервная копия v{v} скачана.",
"This window is still running v{v}. If you overwrote the file that's open here, reload; otherwise open the file you saved.": "В этом окне по-прежнему работает v{v}. Если вы перезаписали открытый здесь файл, перезагрузите страницу; иначе откройте сохранённый файл.",
"This window keeps running v{v} until you open the downloaded file.": "В этом окне продолжит работать v{v}, пока вы не откроете скачанный файл.",
diff --git a/slides/src/i18n/packs/sv.ts b/slides/src/i18n/packs/sv.ts
index 3ee05c0b..b80ce292 100644
--- a/slides/src/i18n/packs/sv.ts
+++ b/slides/src/i18n/packs/sv.ts
@@ -213,6 +213,7 @@ export const strings: Catalog = {
"This browser can’t rewrite files in place — a fresh copy went to Downloads": "Den här webbläsaren kan inte skriva om filer på plats — en ny kopia hamnade i Hämtade filer",
"This document": "Det här dokumentet",
"This file carries its own app — it works offline, forever, as is.": "Den här filen bär med sig sin egen app — den fungerar offline, för alltid, precis som den är.",
+ "This window is still running v{v} — reload to finish. A v{v} backup was saved beside this file.": "Det här fönstret kör fortfarande v{v} — läs om sidan för att slutföra. En säkerhetskopia av v{v} sparades bredvid den här filen.",
"This window is still running v{v} — reload to finish. A v{v} backup was downloaded.": "Det här fönstret kör fortfarande v{v} — läs om sidan för att slutföra. En säkerhetskopia av v{v} laddades ned.",
"This window is still running v{v}. If you overwrote the file that's open here, reload; otherwise open the file you saved.": "Det här fönstret kör fortfarande v{v}. Om du skrev över filen som är öppen här läser du om sidan; annars öppnar du filen du sparade.",
"This window keeps running v{v} until you open the downloaded file.": "Det här fönstret fortsätter köra v{v} tills du öppnar den nedladdade filen.",
diff --git a/slides/src/i18n/packs/th.ts b/slides/src/i18n/packs/th.ts
index f6ca3d35..602d1e9d 100644
--- a/slides/src/i18n/packs/th.ts
+++ b/slides/src/i18n/packs/th.ts
@@ -218,6 +218,7 @@ export const strings: Catalog = {
"This browser can’t rewrite files in place — a fresh copy went to Downloads": "เบราว์เซอร์นี้เขียนทับไฟล์ในที่เดิมไม่ได้ — สำเนาใหม่ถูกบันทึกไว้ในโฟลเดอร์ดาวน์โหลด",
"This document": "เอกสารนี้",
"This file carries its own app — it works offline, forever, as is.": "ไฟล์นี้พกแอปของตัวเองมาด้วย — ใช้งานออฟไลน์ได้ตลอดไปในสภาพนี้",
+ "This window is still running v{v} — reload to finish. A v{v} backup was saved beside this file.": "หน้าต่างนี้ยังใช้ v{v} อยู่ — โหลดซ้ำเพื่อให้เสร็จสมบูรณ์ ระบบบันทึกไฟล์สำรอง v{v} ไว้ข้างไฟล์นี้แล้ว",
"This window is still running v{v} — reload to finish. A v{v} backup was downloaded.": "หน้าต่างนี้ยังใช้ v{v} อยู่ — โหลดซ้ำเพื่อให้เสร็จสมบูรณ์ ระบบดาวน์โหลดไฟล์สำรอง v{v} ไว้แล้ว",
"This window is still running v{v}. If you overwrote the file that's open here, reload; otherwise open the file you saved.": "หน้าต่างนี้ยังใช้ v{v} อยู่ ถ้าคุณเขียนทับไฟล์ที่เปิดอยู่นี้แล้ว ให้โหลดซ้ำ ถ้าไม่ใช่ ให้เปิดไฟล์ที่เพิ่งบันทึก",
"This window keeps running v{v} until you open the downloaded file.": "หน้าต่างนี้จะใช้ v{v} ต่อไปจนกว่าคุณจะเปิดไฟล์ที่ดาวน์โหลดมา",
diff --git a/slides/src/i18n/packs/tk.ts b/slides/src/i18n/packs/tk.ts
index 30e06cd2..0fe637c5 100644
--- a/slides/src/i18n/packs/tk.ts
+++ b/slides/src/i18n/packs/tk.ts
@@ -237,6 +237,7 @@ export const strings: Catalog = {
"This browser can’t rewrite files in place — a fresh copy went to Downloads": "Bu brauzer faýllaryň üstüne gönüden-göni ýazyp bilmeýär — täze nusga Ýüklemeler bukjasyna gitdi",
"This document": "Şu resminama",
"This file carries its own app — it works offline, forever, as is.": "Şu faýl öz programmasyny özi bilen göterýär — ol internetsiz, hemişelik, şu durşuna işleýär.",
+ "This window is still running v{v} — reload to finish. A v{v} backup was saved beside this file.": "Bu penjire heniz v{v} wersiýasynda işleýär — tamamlamak üçin gaýtadan ýükläň. v{v} ätiýaçlyk nusgasy şu faýlyň ýanynda saklandy.",
"This window is still running v{v} — reload to finish. A v{v} backup was downloaded.": "Bu penjire heniz v{v} wersiýasynda işleýär — tamamlamak üçin gaýtadan ýükläň. v{v} ätiýaçlyk nusgasy ýüklenip alyndy.",
"This window is still running v{v}. If you overwrote the file that's open here, reload; otherwise open the file you saved.": "Bu penjire heniz v{v} wersiýasynda işleýär. Şu ýerde açyk duran faýlyň üstüne ýazan bolsaňyz, gaýtadan ýükläň; bolmasa saklan faýlyňyzy açyň.",
"This window keeps running v{v} until you open the downloaded file.": "Ýüklenip alnan faýly açýançaňyz bu penjire v{v} wersiýasynda işlemegini dowam eder.",
diff --git a/slides/src/i18n/packs/tl.ts b/slides/src/i18n/packs/tl.ts
index a783692c..72887116 100644
--- a/slides/src/i18n/packs/tl.ts
+++ b/slides/src/i18n/packs/tl.ts
@@ -227,6 +227,7 @@ export const strings: Catalog = {
"This browser can’t rewrite files in place — a fresh copy went to Downloads": "Hindi kayang i-rewrite nang direkta ng browser na ito ang mga file — may bagong kopyang napunta sa Downloads",
"This document": "Ang dokumentong ito",
"This file carries its own app — it works offline, forever, as is.": "Dala ng file na ito ang sarili nitong app — gumagana ito offline, habambuhay, kung ano ang nandito.",
+ "This window is still running v{v} — reload to finish. A v{v} backup was saved beside this file.": "Tumatakbo pa rin sa v{v} ang window na ito — i-reload para matapos. Na-save ang isang backup na v{v} katabi ng file na ito.",
"This window is still running v{v} — reload to finish. A v{v} backup was downloaded.": "Tumatakbo pa rin sa v{v} ang window na ito — i-reload para matapos. Na-download ang isang backup na v{v}.",
"This window is still running v{v}. If you overwrote the file that's open here, reload; otherwise open the file you saved.": "Tumatakbo pa rin sa v{v} ang window na ito. Kung na-overwrite mo ang file na bukas dito, i-reload; kung hindi, buksan ang file na na-save mo.",
"This window keeps running v{v} until you open the downloaded file.": "Mananatiling tumatakbo sa v{v} ang window na ito hangga’t hindi mo binubuksan ang na-download na file.",
diff --git a/slides/src/i18n/packs/tr.ts b/slides/src/i18n/packs/tr.ts
index 84bc0c95..e3412310 100644
--- a/slides/src/i18n/packs/tr.ts
+++ b/slides/src/i18n/packs/tr.ts
@@ -215,6 +215,7 @@ export const strings: Catalog = {
"This browser can’t rewrite files in place — a fresh copy went to Downloads": "Bu tarayıcı dosyaların üzerine yerinde yazamaz — yeni bir kopya İndirilenler klasörüne kaydedildi",
"This document": "Bu belge",
"This file carries its own app — it works offline, forever, as is.": "Bu dosya kendi uygulamasını taşır — çevrimdışı, sonsuza dek, olduğu gibi çalışır.",
+ "This window is still running v{v} — reload to finish. A v{v} backup was saved beside this file.": "Bu pencere hâlâ v{v} sürümünü çalıştırıyor — bitirmek için yeniden yükleyin. v{v} yedeği bu dosyanın yanına kaydedildi.",
"This window is still running v{v} — reload to finish. A v{v} backup was downloaded.": "Bu pencere hâlâ v{v} sürümünü çalıştırıyor — bitirmek için yeniden yükleyin. v{v} yedeği indirildi.",
"This window is still running v{v}. If you overwrote the file that's open here, reload; otherwise open the file you saved.": "Bu pencere hâlâ v{v} sürümünü çalıştırıyor. Burada açık olan dosyanın üzerine yazdıysanız yeniden yükleyin; yazmadıysanız kaydettiğiniz dosyayı açın.",
"This window keeps running v{v} until you open the downloaded file.": "İndirilen dosyayı açana kadar bu pencere v{v} sürümünü çalıştırmayı sürdürür.",
diff --git a/slides/src/i18n/packs/uk.ts b/slides/src/i18n/packs/uk.ts
index 2bbf4700..a32eb818 100644
--- a/slides/src/i18n/packs/uk.ts
+++ b/slides/src/i18n/packs/uk.ts
@@ -224,6 +224,7 @@ export const strings: Catalog = {
"This browser can’t rewrite files in place — a fresh copy went to Downloads": "Цей браузер не може перезаписувати файли на місці — нову копію збережено до Завантажень",
"This document": "Цей документ",
"This file carries its own app — it works offline, forever, as is.": "Цей файл несе власний застосунок — він працює автономно, завжди, як є.",
+ "This window is still running v{v} — reload to finish. A v{v} backup was saved beside this file.": "Це вікно досі працює на v{v} — перезавантажте, щоб завершити. Резервну копію v{v} збережено поряд із цим файлом.",
"This window is still running v{v} — reload to finish. A v{v} backup was downloaded.": "Це вікно досі працює на v{v} — перезавантажте, щоб завершити. Резервну копію v{v} завантажено.",
"This window is still running v{v}. If you overwrote the file that's open here, reload; otherwise open the file you saved.": "Це вікно досі працює на v{v}. Якщо ви перезаписали файл, відкритий тут, перезавантажте; інакше відкрийте збережений файл.",
"This window keeps running v{v} until you open the downloaded file.": "Це вікно працюватиме на v{v}, доки ви не відкриєте завантажений файл.",
diff --git a/slides/src/i18n/packs/ur.ts b/slides/src/i18n/packs/ur.ts
index bc1ab91a..867a00e6 100644
--- a/slides/src/i18n/packs/ur.ts
+++ b/slides/src/i18n/packs/ur.ts
@@ -234,6 +234,7 @@ export const strings: Catalog = {
"This browser can’t rewrite files in place — a fresh copy went to Downloads": "یہ براؤزر فائلوں کو اپنی جگہ پر دوبارہ نہیں لکھ سکتا — تازہ نقل ڈاؤن لوڈز میں چلی گئی",
"This document": "یہ دستاویز",
"This file carries its own app — it works offline, forever, as is.": "یہ فائل اپنی ایپ خود ساتھ رکھتی ہے — یہ آف لائن، ہمیشہ، جوں کی توں چلتی ہے۔",
+ "This window is still running v{v} — reload to finish. A v{v} backup was saved beside this file.": "یہ ونڈو اب بھی ورژن {v} چلا رہی ہے — مکمل کرنے کے لیے دوبارہ لوڈ کریں۔ ورژن {v} کا بیک اپ اس فائل کے پہلو میں محفوظ ہو گیا ہے۔",
"This window is still running v{v} — reload to finish. A v{v} backup was downloaded.": "یہ ونڈو اب بھی ورژن {v} چلا رہی ہے — مکمل کرنے کے لیے دوبارہ لوڈ کریں۔ ورژن {v} کا بیک اپ ڈاؤن لوڈ ہو گیا ہے۔",
"This window is still running v{v}. If you overwrote the file that's open here, reload; otherwise open the file you saved.": "یہ ونڈو اب بھی ورژن {v} چلا رہی ہے۔ اگر آپ نے یہاں کھلی ہوئی فائل ہی پر لکھ دیا ہے تو دوبارہ لوڈ کریں؛ ورنہ وہ فائل کھولیں جو آپ نے محفوظ کی۔",
"This window keeps running v{v} until you open the downloaded file.": "یہ ونڈو اُس وقت تک ورژن {v} چلاتی رہے گی جب تک آپ ڈاؤن لوڈ کی گئی فائل نہ کھولیں۔",
diff --git a/slides/src/i18n/packs/vi.ts b/slides/src/i18n/packs/vi.ts
index 80772b8e..43e2052b 100644
--- a/slides/src/i18n/packs/vi.ts
+++ b/slides/src/i18n/packs/vi.ts
@@ -214,6 +214,7 @@ export const strings: Catalog = {
"This browser can’t rewrite files in place — a fresh copy went to Downloads": "Trình duyệt này không ghi đè trực tiếp được tệp — một bản sao mới đã được lưu vào thư mục Tải xuống",
"This document": "Tài liệu này",
"This file carries its own app — it works offline, forever, as is.": "Tệp này mang theo ứng dụng của chính nó — nó hoạt động ngoại tuyến, mãi mãi, nguyên trạng.",
+ "This window is still running v{v} — reload to finish. A v{v} backup was saved beside this file.": "Cửa sổ này vẫn đang chạy phiên bản v{v} — hãy tải lại để hoàn tất. Một bản sao lưu v{v} đã được lưu bên cạnh tệp này.",
"This window is still running v{v} — reload to finish. A v{v} backup was downloaded.": "Cửa sổ này vẫn đang chạy phiên bản v{v} — hãy tải lại để hoàn tất. Một bản sao lưu v{v} đã được tải xuống.",
"This window is still running v{v}. If you overwrote the file that's open here, reload; otherwise open the file you saved.": "Cửa sổ này vẫn đang chạy phiên bản v{v}. Nếu bạn đã ghi đè lên tệp đang mở ở đây, hãy tải lại; nếu không, hãy mở tệp bạn vừa lưu.",
"This window keeps running v{v} until you open the downloaded file.": "Cửa sổ này vẫn chạy phiên bản v{v} cho đến khi bạn mở tệp vừa tải xuống.",
diff --git a/slides/src/i18n/pt.ts b/slides/src/i18n/pt.ts
index 088a38e7..2e49bee8 100644
--- a/slides/src/i18n/pt.ts
+++ b/slides/src/i18n/pt.ts
@@ -198,6 +198,7 @@ export const pt: Catalog = {
"This browser can’t rewrite files in place — a fresh copy went to Downloads": "Este navegador não consegue regravar arquivos no lugar — uma nova cópia foi para Downloads",
"This document": "Este documento",
"This file carries its own app — it works offline, forever, as is.": "Este arquivo carrega o próprio aplicativo — funciona offline, para sempre, do jeito que está.",
+ "This window is still running v{v} — reload to finish. A v{v} backup was saved beside this file.": "Esta janela ainda está executando a v{v} — recarregue para concluir. Um backup da v{v} foi salvo ao lado deste arquivo.",
"This window is still running v{v} — reload to finish. A v{v} backup was downloaded.": "Esta janela ainda está executando a v{v} — recarregue para concluir. Um backup da v{v} foi baixado.",
"This window is still running v{v}. If you overwrote the file that's open here, reload; otherwise open the file you saved.": "Esta janela ainda está executando a v{v}. Se você sobrescreveu o arquivo aberto aqui, recarregue; caso contrário, abra o arquivo que salvou.",
"This window keeps running v{v} until you open the downloaded file.": "Esta janela continua executando a v{v} até você abrir o arquivo baixado.",
diff --git a/slides/src/i18n/zh-Hans.ts b/slides/src/i18n/zh-Hans.ts
index d24730b2..daec4464 100644
--- a/slides/src/i18n/zh-Hans.ts
+++ b/slides/src/i18n/zh-Hans.ts
@@ -206,6 +206,7 @@ export const zhHans: Catalog = {
"This browser can’t rewrite files in place — a fresh copy went to Downloads": "此浏览器无法就地改写文件 — 新副本已存入下载",
"This document": "此文档",
"This file carries its own app — it works offline, forever, as is.": "此文件自带应用 — 离线可用,永久如此。",
+ "This window is still running v{v} — reload to finish. A v{v} backup was saved beside this file.": "此窗口仍在运行 v{v} — 重新加载以完成。已在此文件旁保存 v{v} 备份。",
"This window is still running v{v} — reload to finish. A v{v} backup was downloaded.": "此窗口仍在运行 v{v} — 重新加载以完成。已下载 v{v} 备份。",
"This window is still running v{v}. If you overwrote the file that's open here, reload; otherwise open the file you saved.": "此窗口仍在运行 v{v}。若覆盖了当前打开的文件请重新加载;否则请打开您保存的文件。",
"This window keeps running v{v} until you open the downloaded file.": "在打开下载的文件之前,此窗口将继续运行 v{v}。",
diff --git a/slides/src/i18n/zh-Hant.ts b/slides/src/i18n/zh-Hant.ts
index 53497480..7c7d77d4 100644
--- a/slides/src/i18n/zh-Hant.ts
+++ b/slides/src/i18n/zh-Hant.ts
@@ -206,6 +206,7 @@ export const zhHant: Catalog = {
"This browser can’t rewrite files in place — a fresh copy went to Downloads": "此瀏覽器無法就地改寫檔案 — 新副本已存入下載項目",
"This document": "此文件",
"This file carries its own app — it works offline, forever, as is.": "此檔案自帶應用程式 — 離線可用,永遠如此。",
+ "This window is still running v{v} — reload to finish. A v{v} backup was saved beside this file.": "此視窗仍在執行 v{v} — 重新載入以完成。已在此檔案旁儲存 v{v} 備份。",
"This window is still running v{v} — reload to finish. A v{v} backup was downloaded.": "此視窗仍在執行 v{v} — 重新載入以完成。已下載 v{v} 備份。",
"This window is still running v{v}. If you overwrote the file that's open here, reload; otherwise open the file you saved.": "此視窗仍在執行 v{v}。若已覆寫目前開啟的檔案請重新載入;否則請開啟您儲存的檔案。",
"This window keeps running v{v} until you open the downloaded file.": "在開啟下載的檔案之前,此視窗會維持在 v{v}。",
diff --git a/tray/README.md b/tray/README.md
index f1805a90..0c68e97d 100644
--- a/tray/README.md
+++ b/tray/README.md
@@ -53,6 +53,7 @@ destroy a file:
| `bento-doc` | ⌘S — overwrite the document being edited | write in place, silently |
| `bento-copy` | "Save a copy…" — a second file the author chooses | **must** let the author choose |
| `bento-share` | a suffixed export: view-only, presentation package, invite, template | **must** let the author choose |
+| `bento-backup` | the rollback copy a self-update leaves behind | write **beside the open document**, silently — see below |
Before this existed, ⌘S and "Save a copy…" reached the picker with
byte-identical arguments, so a host could not distinguish them. One that guessed
@@ -110,6 +111,49 @@ Do **not** infer this by comparing `suggestedName` to the open filename. Bento
derives that name from the deck TITLE, so it rarely matches — an early version
of this bridge did exactly that and prompted on every single save.
+### Announcing what a host can do
+
+A host that can do more than the bare contract says so on the page:
+
+```js
+window.__bentoHost = { name: 'tray/webext', ops: ['claim', 'write', 'backup'] }
+```
+
+`kernel/src/save.ts hostCan(op)` reads it, and it is the ONLY thing the kernel
+reads about a host. `showSaveFilePicker` existing proves nothing — Chrome has it
+on `file://` anyway — and a host that declines a request is indistinguishable
+from one that is not installed, because both end at the native dialog. So a path
+that is only worth taking with help has to ask first.
+
+Capabilities, not a version number, in both directions: a document can be years
+older or newer than the host it meets. A host that announced only its presence
+and then did not recognise `bento-backup` would pass the request through to the
+native picker and produce a dialog **only** for people who installed the host,
+which is the opposite of the point.
+
+Set it non-writable. The document is untrusted content sharing that realm, and
+it must not be able to claim a capability the host does not have.
+
+### `bento-backup`, the only op that CREATES a file
+
+Every other op writes a file that already exists and that the sender IS. This
+one makes a new one, so the page contributes to a name — and that contribution
+is kept from meaning anything:
+
+- the name must be **visibly derived from the sender's own file**: same base,
+ `.bento.html`, and nothing between but `[A-Za-z0-9._-]`. No separator can
+ survive, so nothing escapes the directory.
+- it may not equal the original. Without that check the "backup" is the file.
+- **create-only**: an existing file is never replaced.
+- the directory is the host's to determine, from the sender's own resolved
+ path — never from the payload.
+
+Worst case for a hostile document: one predictably-named copy of itself in a
+folder the author granted, which is what the feature does when it works.
+
+If a host cannot do this, it must not announce `backup`; the kernel then falls
+back to downloading the rollback copy, which is where it used to go.
+
## Two implementation details that carry weight
- **The document is served through a custom scheme** (`bento-tray://`), never
diff --git a/tray/webext/src/background.js b/tray/webext/src/background.js
index 36901501..d9981daf 100644
--- a/tray/webext/src/background.js
+++ b/tray/webext/src/background.js
@@ -137,7 +137,79 @@ export async function resolve(sender, deps = {}) {
return { ok: false, reason: `${name} in the granted folder is a different file` }
}
- return { ok: true, name, handle: hits[0], within: suffix }
+ return { ok: true, name, handle: hits[0], within: suffix, dir, rel }
+}
+
+/**
+ * The directory a resolved file actually sits in.
+ *
+ * `rel` is the file's path segments relative to the grant root, so its parent is
+ * the grant walked down every segment but the last. Re-walked from the grant
+ * rather than remembered, for the same reason as everything else here: a service
+ * worker can be evicted between two messages.
+ */
+async function parentOf(dir, rel) {
+ let cur = dir
+ for (const seg of rel.slice(0, -1)) cur = await cur.getDirectoryHandle(seg)
+ return cur
+}
+
+/**
+ * Is `proposed` a name this sender is allowed to create beside itself?
+ *
+ * The page supplies it, so it is untrusted, and it is about to become a
+ * filename in somebody's folder. Rather than sanitising toward safety — which
+ * invites arguments about what was missed — this only accepts names that are
+ * transparently derived from the sender's OWN file: same base, our extension,
+ * and nothing in between but the characters a version string is made of.
+ *
+ * A separator therefore cannot survive, so no name can escape the directory,
+ * and the sender can only ever write near itself. `!== own` is the one that
+ * matters most: without it the "backup" is the original.
+ */
+export function backupNameFor(own, proposed) {
+ if (typeof proposed !== 'string' || proposed.length > 128) return null
+ if (!/^[A-Za-z0-9._-]+$/.test(proposed)) return null // no / \ .. NUL, no spaces
+ if (!/\.bento\.html$/i.test(proposed)) return null
+ if (proposed === own) return null
+ const base = own.replace(/\.bento\.html$/i, '')
+ return proposed.startsWith(`${base}.`) ? proposed : null
+}
+
+/**
+ * Write a rollback copy beside the sender's own file.
+ *
+ * NEW AUTHORITY, deliberately narrow. Every other op writes a file that already
+ * exists and that the sender IS; this one creates a file. The blast radius is
+ * held down from both ends: the name must be derived from the sender's own
+ * (`backupNameFor`), and an existing file is never overwritten. So the worst a
+ * hostile document can do is leave one predictably-named copy of ITSELF in a
+ * folder the author granted — which is what the feature does when it works.
+ */
+export async function backup(sender, text, name, deps) {
+ const r = await resolve(sender, deps)
+ if (!r.ok) return { ok: false, reason: r.reason }
+
+ const safe = backupNameFor(r.name, name)
+ if (!safe) return { ok: false, reason: 'not a backup name for this file' }
+
+ try {
+ const parent = await parentOf(r.dir, r.rel)
+ // Create-only. `getFileHandle` without `create` throws NotFoundError when
+ // the name is free — that throw is the success case, and anything else
+ // means something is already there and is not ours to replace.
+ let taken = true
+ try { await parent.getFileHandle(safe) } catch (e) { taken = e?.name !== 'NotFoundError' }
+ if (taken) return { ok: false, reason: `${safe} already exists` }
+
+ const h = await parent.getFileHandle(safe, { create: true })
+ const w = await h.createWritable()
+ await w.write(text)
+ await w.close()
+ return { ok: true, name: safe, bytes: text.length }
+ } catch (e) {
+ return { ok: false, reason: `${e.name}: ${e.message}` }
+ }
}
/** Can this sender's file be written in place? Resolves; writes nothing. */
@@ -166,6 +238,7 @@ if (typeof chrome !== 'undefined' && chrome.runtime?.onMessage) {
chrome.runtime.onMessage.addListener((msg, sender, sendResponse) => {
const run = msg?.op === 'claim' ? claim(sender)
: msg?.op === 'write' ? write(sender, msg.payload?.text ?? '')
+ : msg?.op === 'backup' ? backup(sender, msg.payload?.text ?? '', msg.payload?.name)
: Promise.resolve({ ok: false, reason: 'unknown op' })
run.then(sendResponse, (e) => sendResponse({ ok: false, reason: String(e?.message || e) }))
return true // async response
diff --git a/tray/webext/src/options.html b/tray/webext/src/options.html
index bc074611..22561172 100644
--- a/tray/webext/src/options.html
+++ b/tray/webext/src/options.html
@@ -17,6 +17,7 @@
Grant the folder your decks live in, once. After that, ⌘S on a deck you opened
by double-clicking writes straight back to the file — no destination prompt.
</p>
-<p><button id="pick">Choose your decks folder…</button> <button id="check">Check</button></p>
+<p><button id="renew" hidden>Renew access to this folder</button>
+ <button id="pick">Choose your decks folder…</button> <button id="check">Check</button></p>
<div id="state">…</div>
<script type="module" src="options.js"></script>
diff --git a/tray/webext/src/options.js b/tray/webext/src/options.js
index af5b1d14..ff985048 100644
--- a/tray/webext/src/options.js
+++ b/tray/webext/src/options.js
@@ -11,6 +11,7 @@
import { getGrant, putGrant, status } from './status.js'
const el = document.getElementById('state')
+const renewB = document.getElementById('renew')
const esc = (s) => String(s).replace(/[&<>]/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;' }[c]))
async function report() {
@@ -39,9 +40,16 @@ async function report() {
? `<b>Folder: ${esc(s.folder)}</b> — ready, but nothing saves in place until file access is on.`
: `<b class="ok">Folder: ${esc(s.folder)}</b> — decks in here save in place, with no dialog.`)
} else {
+ // The HANDLE is still here — that is how we know the folder's name. Only
+ // the permission lapsed, and Chrome takes that back with one confirmation
+ // on the handle we already hold. Sending people back through
+ // showDirectoryPicker made them re-find the folder every time, which is a
+ // filesystem browse to answer a yes/no question.
lines.push(`<b class="bad">Folder: ${esc(s.folder)} — needs renewing.</b> ` +
- 'The grant lapses whenever the extension restarts. Choose it again to restore it.')
+ 'Chrome drops the permission when the extension restarts. ' +
+ '<b>Renew</b> restores it in one click — you do not have to find the folder again.')
}
+ renewB.hidden = !(s.folder && s.permission !== 'granted')
el.innerHTML = lines.map((l) => `<p>${l}</p>`).join('')
}
@@ -56,6 +64,28 @@ document.getElementById('pick').onclick = async () => {
el.innerHTML = `<p><b class="bad">${esc(e.name)}</b>: ${esc(e.message)}</p>`
}
}
+/**
+ * Take the permission back on the folder we already hold.
+ *
+ * `requestPermission` needs a user gesture, which is why this is a button and
+ * not something `report()` does on load — and why the service worker must never
+ * attempt it (`background.js resolve` queries only). A click here is the
+ * gesture; Chrome shows one Allow/Block confirmation naming the folder.
+ *
+ * The handle is re-put afterwards for the same reason it is stored at all: the
+ * grant that matters is the one the service worker reads, and re-writing it is
+ * cheap insurance against a handle that has been replaced rather than renewed.
+ */
+renewB.onclick = async () => {
+ try {
+ const dir = await getGrant()
+ if (!dir) return report() // nothing to renew — the pick button is the answer
+ const perm = await dir.requestPermission({ mode: 'readwrite' })
+ if (perm === 'granted') await putGrant(dir)
+ await report()
+ } catch (e) {
+ el.innerHTML = `<p><b class="bad">${esc(e.name)}</b>: ${esc(e.message)}</p>`
+ }
+}
document.getElementById('check').onclick = report
void report()
-void getGrant // referenced so the import is obviously intentional
diff --git a/tray/webext/src/page-bridge.js b/tray/webext/src/page-bridge.js
index 54ef9212..6ebc617d 100644
--- a/tray/webext/src/page-bridge.js
+++ b/tray/webext/src/page-bridge.js
@@ -104,6 +104,31 @@
const wantsOpenFile = (opts) => opts?.id === 'bento-doc' && runtimeAtLeast(ID_SINCE)
+ /**
+ * A backup, which is a NEW file beside the open one — so `wantsOpenFile` is
+ * the wrong question and its version gate does not apply. `bento-backup` did
+ * not exist before the runtime that sends it, so unlike `bento-doc` the id
+ * cannot arrive from a deck that meant something else by it.
+ */
+ const wantsBackup = (opts) => opts?.id === 'bento-backup'
+
+ /**
+ * Tell the document what this host can do.
+ *
+ * `showSaveFilePicker` alone says nothing: it exists in Chrome anyway, and a
+ * host that declines is indistinguishable from a host that is absent, since
+ * both end at the native dialog. So the kernel reads this before choosing a
+ * path it can only take with help — today just the backup (`save.ts hostCan`).
+ *
+ * Capabilities, not a version number. A deck can be years older or newer than
+ * the extension it meets, and asking "can you do X" survives that in both
+ * directions where "are you at least version N" does not.
+ */
+ Object.defineProperty(window, '__bentoHost', {
+ value: Object.freeze({ name: 'tray/webext', ops: Object.freeze(['claim', 'write', 'backup']) }),
+ writable: false, configurable: false, enumerable: false,
+ })
+
/**
* Options safe to hand to the NATIVE picker.
*
@@ -126,7 +151,41 @@
return out
}
+ /** The handle shape save.ts needs, over one round trip at close(). */
+ const handleOver = (name, op, extra = {}) => ({
+ name,
+ kind: 'file',
+ createWritable: async () => {
+ const chunks = []
+ return {
+ async write(data) { chunks.push(data) },
+ async close() {
+ const blob = chunks.length === 1 && chunks[0] instanceof Blob ? chunks[0] : new Blob(chunks)
+ const text = await blob.text()
+ const res = await ask(op, { text, ...extra })
+ if (!res?.ok) throw new DOMException(res?.reason || 'write failed', 'NotAllowedError')
+ console.info('[bento-tray]', op, res.name ?? name, `(${res.bytes} bytes)`)
+ },
+ }
+ },
+ // save.ts re-queries permission on a retained handle; a host-backed handle
+ // is granted for as long as the folder grant stands.
+ queryPermission: async () => 'granted',
+ requestPermission: async () => 'granted',
+ isSameEntry: async () => false,
+ })
+
window.showSaveFilePicker = async (opts = {}) => {
+ if (wantsBackup(opts)) {
+ // No `claim` round trip: the backup does not exist yet, so there is
+ // nothing to resolve until the write itself. The extension validates the
+ // name against the sender's own file at that point.
+ //
+ // And NO native fallback here. Falling through would open a picker for a
+ // file the author never asked to save — the exact interruption this path
+ // exists to remove. `save.ts` catches the throw and downloads instead.
+ return handleOver(opts.suggestedName, 'backup', { name: opts.suggestedName })
+ }
if (!wantsOpenFile(opts)) {
if (native) return native(forNative(opts))
throw new DOMException('No file picker available', 'AbortError')
@@ -150,29 +209,6 @@
if (native) return native(forNative(opts))
throw new DOMException('No writable location', 'AbortError')
}
- return {
- name: claim.name,
- kind: 'file',
- createWritable: async () => {
- const chunks = []
- return {
- async write(data) { chunks.push(data) },
- async close() {
- const blob = chunks.length === 1 && chunks[0] instanceof Blob
- ? chunks[0]
- : new Blob(chunks)
- const text = await blob.text()
- const res = await ask('write', { text })
- if (!res?.ok) throw new DOMException(res?.reason || 'write failed', 'NotAllowedError')
- console.info('[bento-tray] wrote', claim.name, `(${res.bytes} bytes) in place`)
- },
- }
- },
- // save.ts re-queries permission on a retained handle; a host-backed handle
- // is granted for as long as the folder grant stands.
- queryPermission: async () => 'granted',
- requestPermission: async () => 'granted',
- isSameEntry: async () => false,
- }
+ return handleOver(claim.name, 'write')
}
})()
diff --git a/tray/webext/src/popup.js b/tray/webext/src/popup.js
index 04dc8413..74857d2f 100644
--- a/tray/webext/src/popup.js
+++ b/tray/webext/src/popup.js
@@ -34,7 +34,7 @@ const folder = s.permission === 'granted'
: 'Decks in here save in place, with no dialog.')
: s.folder
? row('bad', `Folder: ${esc(s.folder)} — needs renewing`,
- 'The grant lapses whenever the extension restarts. One click in Settings restores it.')
+ 'Chrome drops the permission when the extension restarts. <b>Renew</b> in Settings restores it in one click — the folder is still remembered.')
: row('meh', 'No folder yet', 'Choose the folder your decks live in, once.')
document.getElementById('rows').innerHTML = files + folder