Skip to content

armgit / bento

Public Imported from GitHub
0

Bento, the office suite that fits in a file

home/webext: Save a copy and exports open beside the document (#657)

nyblnetc3e6f90aedc6
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index e4f8c454..84253e29 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -721,6 +721,13 @@ jobs:
# the browser's own picker — never to nothing.
run: node scripts/test-webext-filegrant.ts
+ - name: WebExtension save-as rig
+ # "Save a copy" and exports answered in the extension's own window, so
+ # they can land beside the document. The page supplies a name, never a
+ # place; a write lands only where the person chose and only for the
+ # document that asked; a beside-name is never a path or the original.
+ run: node scripts/test-webext-saveas.ts
+
- name: WebExtension localisation rig
# Every failure mode of a message catalogue is silent: a key the code
# uses but English lacks renders as the key name, a locale missing a key
diff --git a/home/webext/_locales/ar/messages.json b/home/webext/_locales/ar/messages.json
index d95593d0..2e4e2357 100644
--- a/home/webext/_locales/ar/messages.json
+++ b/home/webext/_locales/ar/messages.json
@@ -628,5 +628,41 @@
},
"tdGrantFolder": {
"message": "حفظ كل ما في ”$1“ دون سؤال…"
+ },
+ "saTitleCopy": {
+ "message": "حفظ نسخة"
+ },
+ "saTitleShare": {
+ "message": "حفظ الملف المُصدَّر"
+ },
+ "saName": {
+ "message": "اسم الملف"
+ },
+ "saBeside": {
+ "message": "حفظ بجانب “$1”"
+ },
+ "saChoose": {
+ "message": "اختيار مجلد…"
+ },
+ "saCancel": {
+ "message": "إلغاء"
+ },
+ "saExists": {
+ "message": "“$1” موجود بالفعل. احفظ مرة أخرى لاستبداله."
+ },
+ "saIsOriginal": {
+ "message": "هذا هو اسم المستند المفتوح نفسه — اختر اسمًا آخر."
+ },
+ "saBadName": {
+ "message": "استخدم اسم ملف بلا شرطات مائلة."
+ },
+ "saLapsed": {
+ "message": "انتهى الوصول إلى هذا المجلد. اختر مجلدًا بدلًا من ذلك، أو جدّده من المكتبة."
+ },
+ "saGone": {
+ "message": "لم يعد هذا الحفظ قيد الانتظار. أغلق هذه النافذة واحفظ مرة أخرى."
+ },
+ "saTaken": {
+ "message": "“$1” موجود بالفعل. اختر اسمًا مختلفًا."
}
}
diff --git a/home/webext/_locales/bn/messages.json b/home/webext/_locales/bn/messages.json
index 0f698476..2149e891 100644
--- a/home/webext/_locales/bn/messages.json
+++ b/home/webext/_locales/bn/messages.json
@@ -628,5 +628,41 @@
},
"tdGrantFolder": {
"message": "“$1”-এর সবকিছু না জিজ্ঞেস করে সংরক্ষণ করুন…"
+ },
+ "saTitleCopy": {
+ "message": "একটি কপি সংরক্ষণ করুন"
+ },
+ "saTitleShare": {
+ "message": "রপ্তানি করা ফাইল সংরক্ষণ করুন"
+ },
+ "saName": {
+ "message": "ফাইলের নাম"
+ },
+ "saBeside": {
+ "message": "“$1”-এর পাশে সংরক্ষণ করুন"
+ },
+ "saChoose": {
+ "message": "একটি ফোল্ডার বেছে নিন…"
+ },
+ "saCancel": {
+ "message": "বাতিল"
+ },
+ "saExists": {
+ "message": "“$1” আগে থেকেই আছে। প্রতিস্থাপন করতে আবার সংরক্ষণ করুন।"
+ },
+ "saIsOriginal": {
+ "message": "এটি খোলা নথিরই নাম — অন্য একটি বেছে নিন।"
+ },
+ "saBadName": {
+ "message": "স্ল্যাশ ছাড়া একটি ফাইলের নাম দিন।"
+ },
+ "saLapsed": {
+ "message": "এই ফোল্ডারে অ্যাক্সেসের মেয়াদ শেষ। এর বদলে একটি ফোল্ডার বেছে নিন, অথবা লাইব্রেরি থেকে নবায়ন করুন।"
+ },
+ "saGone": {
+ "message": "এই সংরক্ষণ আর অপেক্ষায় নেই। উইন্ডোটি বন্ধ করে আবার সংরক্ষণ করুন।"
+ },
+ "saTaken": {
+ "message": "“$1” আগে থেকেই আছে। অন্য একটি নাম বেছে নিন।"
}
}
diff --git a/home/webext/_locales/da/messages.json b/home/webext/_locales/da/messages.json
index 9fea53c8..80f49870 100644
--- a/home/webext/_locales/da/messages.json
+++ b/home/webext/_locales/da/messages.json
@@ -628,5 +628,41 @@
},
"tdGrantFolder": {
"message": "Gem alt i “$1” uden at spørge…"
+ },
+ "saTitleCopy": {
+ "message": "Gem en kopi"
+ },
+ "saTitleShare": {
+ "message": "Gem den eksporterede fil"
+ },
+ "saName": {
+ "message": "Filnavn"
+ },
+ "saBeside": {
+ "message": "Gem ved siden af “$1”"
+ },
+ "saChoose": {
+ "message": "Vælg en mappe …"
+ },
+ "saCancel": {
+ "message": "Annuller"
+ },
+ "saExists": {
+ "message": "“$1” findes allerede. Gem igen for at erstatte den."
+ },
+ "saIsOriginal": {
+ "message": "Det er det åbne dokuments eget navn – vælg et andet."
+ },
+ "saBadName": {
+ "message": "Brug et filnavn uden skråstreger."
+ },
+ "saLapsed": {
+ "message": "Adgangen til mappen er udløbet. Vælg en mappe i stedet, eller forny den i biblioteket."
+ },
+ "saGone": {
+ "message": "Denne gemning venter ikke længere. Luk vinduet, og gem igen."
+ },
+ "saTaken": {
+ "message": "“$1” findes allerede. Vælg et andet navn."
}
}
diff --git a/home/webext/_locales/de/messages.json b/home/webext/_locales/de/messages.json
index c0a6dde8..cf04608f 100644
--- a/home/webext/_locales/de/messages.json
+++ b/home/webext/_locales/de/messages.json
@@ -661,5 +661,41 @@
},
"tdGrantFolder": {
"message": "Alles in „$1“ ohne Nachfrage speichern …"
+ },
+ "saTitleCopy": {
+ "message": "Kopie speichern"
+ },
+ "saTitleShare": {
+ "message": "Exportierte Datei speichern"
+ },
+ "saName": {
+ "message": "Dateiname"
+ },
+ "saBeside": {
+ "message": "Neben „$1“ speichern"
+ },
+ "saChoose": {
+ "message": "Ordner wählen …"
+ },
+ "saCancel": {
+ "message": "Abbrechen"
+ },
+ "saExists": {
+ "message": "„$1“ ist schon vorhanden. Erneut speichern, um es zu ersetzen."
+ },
+ "saIsOriginal": {
+ "message": "Das ist der Name des geöffneten Dokuments – bitte einen anderen wählen."
+ },
+ "saBadName": {
+ "message": "Bitte einen Dateinamen ohne Schrägstriche verwenden."
+ },
+ "saLapsed": {
+ "message": "Der Zugriff auf diesen Ordner ist abgelaufen. Wählen Sie stattdessen einen Ordner oder erneuern Sie ihn in der Bibliothek."
+ },
+ "saGone": {
+ "message": "Dieses Speichern wartet nicht mehr. Fenster schließen und erneut speichern."
+ },
+ "saTaken": {
+ "message": "„$1“ ist schon vorhanden. Bitte einen anderen Namen wählen."
}
}
diff --git a/home/webext/_locales/en/messages.json b/home/webext/_locales/en/messages.json
index 7038e5e7..2ee8b306 100644
--- a/home/webext/_locales/en/messages.json
+++ b/home/webext/_locales/en/messages.json
@@ -734,5 +734,53 @@
"tdGrantFolder": {
"message": "Save everything in “$1” without asking…",
"description": "Side panel button: grant the active document's folder. $1 folder name."
+ },
+ "saTitleCopy": {
+ "message": "Save a copy",
+ "description": "Save-as window title for “Save a copy…”."
+ },
+ "saTitleShare": {
+ "message": "Save the exported file",
+ "description": "Save-as window title for an export (view-only copy, presentation package, invite, template)."
+ },
+ "saName": {
+ "message": "File name",
+ "description": "Save-as window: label of the file name field."
+ },
+ "saBeside": {
+ "message": "Save next to “$1”",
+ "description": "Save-as window primary button: save into the open document's own folder. $1 is the open document's file name."
+ },
+ "saChoose": {
+ "message": "Choose a folder…",
+ "description": "Save-as window button: open a picker to choose where to save."
+ },
+ "saCancel": {
+ "message": "Cancel",
+ "description": "Save-as window: cancel button."
+ },
+ "saExists": {
+ "message": "“$1” is already there. Save again to replace it.",
+ "description": "Save-as window: the chosen name exists in the document's folder; a second click replaces it. $1 file name."
+ },
+ "saIsOriginal": {
+ "message": "That is the open document's own name — choose another.",
+ "description": "Save-as window: the person typed the open document's file name for the copy."
+ },
+ "saBadName": {
+ "message": "Use a file name without slashes.",
+ "description": "Save-as window: the typed name is empty or has a path in it."
+ },
+ "saLapsed": {
+ "message": "Access to this folder has lapsed. Choose a folder instead, or renew it in the library.",
+ "description": "Save-as window: the folder grant needs renewing and the browser did not renew it here."
+ },
+ "saGone": {
+ "message": "This save is no longer waiting. Close this window and save again.",
+ "description": "Save-as window: the request expired or the document closed."
+ },
+ "saTaken": {
+ "message": "“$1” is already there. Choose a different name.",
+ "description": "Save-as window: the suggested name (not typed by the person) is already taken in that folder; it is never replaced. $1 file name."
}
}
diff --git a/home/webext/_locales/es/messages.json b/home/webext/_locales/es/messages.json
index fe64ea74..e1ae46ce 100644
--- a/home/webext/_locales/es/messages.json
+++ b/home/webext/_locales/es/messages.json
@@ -661,5 +661,41 @@
},
"tdGrantFolder": {
"message": "Guardar todo en «$1» sin preguntar…"
+ },
+ "saTitleCopy": {
+ "message": "Guardar una copia"
+ },
+ "saTitleShare": {
+ "message": "Guardar el archivo exportado"
+ },
+ "saName": {
+ "message": "Nombre del archivo"
+ },
+ "saBeside": {
+ "message": "Guardar junto a «$1»"
+ },
+ "saChoose": {
+ "message": "Elegir una carpeta…"
+ },
+ "saCancel": {
+ "message": "Cancelar"
+ },
+ "saExists": {
+ "message": "«$1» ya existe. Vuelve a guardar para reemplazarlo."
+ },
+ "saIsOriginal": {
+ "message": "Ese es el nombre del propio documento abierto: elige otro."
+ },
+ "saBadName": {
+ "message": "Usa un nombre de archivo sin barras."
+ },
+ "saLapsed": {
+ "message": "El acceso a esta carpeta ha caducado. Elige otra carpeta o renuévalo en la biblioteca."
+ },
+ "saGone": {
+ "message": "Este guardado ya no está en espera. Cierra esta ventana y vuelve a guardar."
+ },
+ "saTaken": {
+ "message": "«$1» ya existe. Elige otro nombre."
}
}
diff --git a/home/webext/_locales/fa/messages.json b/home/webext/_locales/fa/messages.json
index 97c6e851..ef1082b7 100644
--- a/home/webext/_locales/fa/messages.json
+++ b/home/webext/_locales/fa/messages.json
@@ -628,5 +628,41 @@
},
"tdGrantFolder": {
"message": "ذخیرهٔ همه‌چیز در «$1» بدون پرسش…"
+ },
+ "saTitleCopy": {
+ "message": "ذخیرهٔ یک نسخه"
+ },
+ "saTitleShare": {
+ "message": "ذخیرهٔ فایل خروجی"
+ },
+ "saName": {
+ "message": "نام فایل"
+ },
+ "saBeside": {
+ "message": "ذخیره کنار «$1»"
+ },
+ "saChoose": {
+ "message": "انتخاب پوشه…"
+ },
+ "saCancel": {
+ "message": "لغو"
+ },
+ "saExists": {
+ "message": "«$1» از قبل وجود دارد. برای جایگزینی دوباره ذخیره کنید."
+ },
+ "saIsOriginal": {
+ "message": "این نام خود سند باز است — نام دیگری انتخاب کنید."
+ },
+ "saBadName": {
+ "message": "نام فایلی بدون اسلش به کار ببرید."
+ },
+ "saLapsed": {
+ "message": "دسترسی به این پوشه منقضی شده است. به‌جای آن پوشه‌ای انتخاب کنید یا از کتابخانه تمدیدش کنید."
+ },
+ "saGone": {
+ "message": "این ذخیره دیگر در انتظار نیست. پنجره را ببندید و دوباره ذخیره کنید."
+ },
+ "saTaken": {
+ "message": "«$1» از قبل وجود دارد. نام دیگری انتخاب کنید."
}
}
diff --git a/home/webext/_locales/fi/messages.json b/home/webext/_locales/fi/messages.json
index 6daf96fc..4486232b 100644
--- a/home/webext/_locales/fi/messages.json
+++ b/home/webext/_locales/fi/messages.json
@@ -628,5 +628,41 @@
},
"tdGrantFolder": {
"message": "Tallenna kaikki kansiossa ”$1” kysymättä…"
+ },
+ "saTitleCopy": {
+ "message": "Tallenna kopio"
+ },
+ "saTitleShare": {
+ "message": "Tallenna viety tiedosto"
+ },
+ "saName": {
+ "message": "Tiedoston nimi"
+ },
+ "saBeside": {
+ "message": "Tallenna tiedoston ”$1” viereen"
+ },
+ "saChoose": {
+ "message": "Valitse kansio…"
+ },
+ "saCancel": {
+ "message": "Peruuta"
+ },
+ "saExists": {
+ "message": "”$1” on jo olemassa. Tallenna uudelleen korvataksesi sen."
+ },
+ "saIsOriginal": {
+ "message": "Se on avoimen asiakirjan oma nimi – valitse toinen."
+ },
+ "saBadName": {
+ "message": "Käytä tiedostonimeä ilman kauttaviivoja."
+ },
+ "saLapsed": {
+ "message": "Kansion käyttöoikeus on vanhentunut. Valitse kansio tai uusi oikeus kirjastossa."
+ },
+ "saGone": {
+ "message": "Tämä tallennus ei enää odota. Sulje ikkuna ja tallenna uudelleen."
+ },
+ "saTaken": {
+ "message": "”$1” on jo olemassa. Valitse toinen nimi."
}
}
diff --git a/home/webext/_locales/fil/messages.json b/home/webext/_locales/fil/messages.json
index c01a41da..ed00d85d 100644
--- a/home/webext/_locales/fil/messages.json
+++ b/home/webext/_locales/fil/messages.json
@@ -628,5 +628,41 @@
},
"tdGrantFolder": {
"message": "I-save ang lahat sa “$1” nang hindi nagtatanong…"
+ },
+ "saTitleCopy": {
+ "message": "Mag-save ng kopya"
+ },
+ "saTitleShare": {
+ "message": "I-save ang na-export na file"
+ },
+ "saName": {
+ "message": "Pangalan ng file"
+ },
+ "saBeside": {
+ "message": "I-save katabi ng “$1”"
+ },
+ "saChoose": {
+ "message": "Pumili ng folder…"
+ },
+ "saCancel": {
+ "message": "Kanselahin"
+ },
+ "saExists": {
+ "message": "Mayroon nang “$1”. I-save muli para palitan ito."
+ },
+ "saIsOriginal": {
+ "message": "Iyan ang mismong pangalan ng bukas na dokumento — pumili ng iba."
+ },
+ "saBadName": {
+ "message": "Gumamit ng pangalan ng file na walang slash."
+ },
+ "saLapsed": {
+ "message": "Nag-expire na ang access sa folder na ito. Pumili na lang ng folder, o i-renew ito sa library."
+ },
+ "saGone": {
+ "message": "Hindi na naghihintay ang pag-save na ito. Isara ang window at mag-save muli."
+ },
+ "saTaken": {
+ "message": "Mayroon nang “$1”. Pumili ng ibang pangalan."
}
}
diff --git a/home/webext/_locales/fr/messages.json b/home/webext/_locales/fr/messages.json
index b5c4de60..b31a9e42 100644
--- a/home/webext/_locales/fr/messages.json
+++ b/home/webext/_locales/fr/messages.json
@@ -661,5 +661,41 @@
},
"tdGrantFolder": {
"message": "Tout enregistrer dans « $1 » sans demander…"
+ },
+ "saTitleCopy": {
+ "message": "Enregistrer une copie"
+ },
+ "saTitleShare": {
+ "message": "Enregistrer le fichier exporté"
+ },
+ "saName": {
+ "message": "Nom du fichier"
+ },
+ "saBeside": {
+ "message": "Enregistrer à côté de « $1 »"
+ },
+ "saChoose": {
+ "message": "Choisir un dossier…"
+ },
+ "saCancel": {
+ "message": "Annuler"
+ },
+ "saExists": {
+ "message": "« $1 » existe déjà. Enregistrez de nouveau pour le remplacer."
+ },
+ "saIsOriginal": {
+ "message": "C’est le nom du document ouvert lui-même : choisissez-en un autre."
+ },
+ "saBadName": {
+ "message": "Utilisez un nom de fichier sans barres obliques."
+ },
+ "saLapsed": {
+ "message": "L’accès à ce dossier a expiré. Choisissez plutôt un dossier, ou renouvelez-le dans la bibliothèque."
+ },
+ "saGone": {
+ "message": "Cet enregistrement n’est plus en attente. Fermez cette fenêtre et enregistrez de nouveau."
+ },
+ "saTaken": {
+ "message": "« $1 » existe déjà. Choisissez un autre nom."
}
}
diff --git a/home/webext/_locales/he/messages.json b/home/webext/_locales/he/messages.json
index afe9b18e..17d8e1f6 100644
--- a/home/webext/_locales/he/messages.json
+++ b/home/webext/_locales/he/messages.json
@@ -628,5 +628,41 @@
},
"tdGrantFolder": {
"message": "לשמור הכול ב־„$1” בלי לשאול…"
+ },
+ "saTitleCopy": {
+ "message": "שמירת עותק"
+ },
+ "saTitleShare": {
+ "message": "שמירת הקובץ המיוצא"
+ },
+ "saName": {
+ "message": "שם הקובץ"
+ },
+ "saBeside": {
+ "message": "שמירה לצד „$1”"
+ },
+ "saChoose": {
+ "message": "בחירת תיקייה…"
+ },
+ "saCancel": {
+ "message": "ביטול"
+ },
+ "saExists": {
+ "message": "„$1” כבר קיים. יש לשמור שוב כדי להחליף אותו."
+ },
+ "saIsOriginal": {
+ "message": "זה השם של המסמך הפתוח עצמו — יש לבחור שם אחר."
+ },
+ "saBadName": {
+ "message": "יש להשתמש בשם קובץ בלי לוכסנים."
+ },
+ "saLapsed": {
+ "message": "הגישה לתיקייה הזו פגה. אפשר לבחור תיקייה במקום, או לחדש אותה בספרייה."
+ },
+ "saGone": {
+ "message": "השמירה הזו כבר לא ממתינה. יש לסגור את החלון ולשמור שוב."
+ },
+ "saTaken": {
+ "message": "„$1” כבר קיים. יש לבחור שם אחר."
}
}
diff --git a/home/webext/_locales/hi/messages.json b/home/webext/_locales/hi/messages.json
index 1454474d..f1986a6e 100644
--- a/home/webext/_locales/hi/messages.json
+++ b/home/webext/_locales/hi/messages.json
@@ -628,5 +628,41 @@
},
"tdGrantFolder": {
"message": "“$1” में सब कुछ बिना पूछे सहेजें…"
+ },
+ "saTitleCopy": {
+ "message": "एक कॉपी सहेजें"
+ },
+ "saTitleShare": {
+ "message": "निर्यात की गई फ़ाइल सहेजें"
+ },
+ "saName": {
+ "message": "फ़ाइल का नाम"
+ },
+ "saBeside": {
+ "message": "“$1” के बगल में सहेजें"
+ },
+ "saChoose": {
+ "message": "फ़ोल्डर चुनें…"
+ },
+ "saCancel": {
+ "message": "रद्द करें"
+ },
+ "saExists": {
+ "message": "“$1” पहले से मौजूद है। बदलने के लिए फिर से सहेजें।"
+ },
+ "saIsOriginal": {
+ "message": "यह खुले दस्तावेज़ का ही नाम है — कोई दूसरा चुनें।"
+ },
+ "saBadName": {
+ "message": "बिना स्लैश वाला फ़ाइल नाम इस्तेमाल करें।"
+ },
+ "saLapsed": {
+ "message": "इस फ़ोल्डर की पहुँच खत्म हो गई है। इसके बजाय कोई फ़ोल्डर चुनें, या लाइब्रेरी में इसे नवीनीकृत करें।"
+ },
+ "saGone": {
+ "message": "यह सहेजना अब प्रतीक्षा में नहीं है। यह विंडो बंद करें और फिर से सहेजें।"
+ },
+ "saTaken": {
+ "message": "“$1” पहले से मौजूद है। कोई दूसरा नाम चुनें।"
}
}
diff --git a/home/webext/_locales/id/messages.json b/home/webext/_locales/id/messages.json
index eda84488..e0e4f0fd 100644
--- a/home/webext/_locales/id/messages.json
+++ b/home/webext/_locales/id/messages.json
@@ -628,5 +628,41 @@
},
"tdGrantFolder": {
"message": "Simpan semua di “$1” tanpa bertanya…"
+ },
+ "saTitleCopy": {
+ "message": "Simpan salinan"
+ },
+ "saTitleShare": {
+ "message": "Simpan file ekspor"
+ },
+ "saName": {
+ "message": "Nama file"
+ },
+ "saBeside": {
+ "message": "Simpan di samping “$1”"
+ },
+ "saChoose": {
+ "message": "Pilih folder…"
+ },
+ "saCancel": {
+ "message": "Batal"
+ },
+ "saExists": {
+ "message": "“$1” sudah ada. Simpan lagi untuk menggantinya."
+ },
+ "saIsOriginal": {
+ "message": "Itu nama dokumen yang sedang terbuka — pilih nama lain."
+ },
+ "saBadName": {
+ "message": "Gunakan nama file tanpa garis miring."
+ },
+ "saLapsed": {
+ "message": "Akses ke folder ini sudah habis. Pilih folder lain, atau perbarui di pustaka."
+ },
+ "saGone": {
+ "message": "Penyimpanan ini tidak lagi menunggu. Tutup jendela ini lalu simpan lagi."
+ },
+ "saTaken": {
+ "message": "“$1” sudah ada. Pilih nama lain."
}
}
diff --git a/home/webext/_locales/it/messages.json b/home/webext/_locales/it/messages.json
index 32c896e7..9c50f972 100644
--- a/home/webext/_locales/it/messages.json
+++ b/home/webext/_locales/it/messages.json
@@ -661,5 +661,41 @@
},
"tdGrantFolder": {
"message": "Salva tutto in «$1» senza chiedere…"
+ },
+ "saTitleCopy": {
+ "message": "Salva una copia"
+ },
+ "saTitleShare": {
+ "message": "Salva il file esportato"
+ },
+ "saName": {
+ "message": "Nome del file"
+ },
+ "saBeside": {
+ "message": "Salva accanto a «$1»"
+ },
+ "saChoose": {
+ "message": "Scegli una cartella…"
+ },
+ "saCancel": {
+ "message": "Annulla"
+ },
+ "saExists": {
+ "message": "«$1» esiste già. Salva di nuovo per sostituirlo."
+ },
+ "saIsOriginal": {
+ "message": "È il nome del documento aperto: scegline un altro."
+ },
+ "saBadName": {
+ "message": "Usa un nome di file senza barre."
+ },
+ "saLapsed": {
+ "message": "L’accesso a questa cartella è scaduto. Scegli invece una cartella o rinnovalo nella libreria."
+ },
+ "saGone": {
+ "message": "Questo salvataggio non è più in attesa. Chiudi la finestra e salva di nuovo."
+ },
+ "saTaken": {
+ "message": "«$1» esiste già. Scegli un altro nome."
}
}
diff --git a/home/webext/_locales/ja/messages.json b/home/webext/_locales/ja/messages.json
index 09a14ce5..a2edd9fe 100644
--- a/home/webext/_locales/ja/messages.json
+++ b/home/webext/_locales/ja/messages.json
@@ -661,5 +661,41 @@
},
"tdGrantFolder": {
"message": "「$1」内はすべて確認なしで保存…"
+ },
+ "saTitleCopy": {
+ "message": "コピーを保存"
+ },
+ "saTitleShare": {
+ "message": "書き出したファイルを保存"
+ },
+ "saName": {
+ "message": "ファイル名"
+ },
+ "saBeside": {
+ "message": "「$1」と同じ場所に保存"
+ },
+ "saChoose": {
+ "message": "フォルダを選択…"
+ },
+ "saCancel": {
+ "message": "キャンセル"
+ },
+ "saExists": {
+ "message": "「$1」はすでにあります。置き換えるにはもう一度保存してください。"
+ },
+ "saIsOriginal": {
+ "message": "開いているドキュメント自身の名前です。別の名前を選んでください。"
+ },
+ "saBadName": {
+ "message": "スラッシュを含まないファイル名にしてください。"
+ },
+ "saLapsed": {
+ "message": "このフォルダへのアクセスが切れています。フォルダを選ぶか、ライブラリで更新してください。"
+ },
+ "saGone": {
+ "message": "この保存は待機していません。ウィンドウを閉じて、もう一度保存してください。"
+ },
+ "saTaken": {
+ "message": "「$1」はすでにあります。別の名前を選んでください。"
}
}
diff --git a/home/webext/_locales/ko/messages.json b/home/webext/_locales/ko/messages.json
index 5ef10adb..961462cb 100644
--- a/home/webext/_locales/ko/messages.json
+++ b/home/webext/_locales/ko/messages.json
@@ -628,5 +628,41 @@
},
"tdGrantFolder": {
"message": "“$1”의 모든 것을 묻지 않고 저장…"
+ },
+ "saTitleCopy": {
+ "message": "사본 저장"
+ },
+ "saTitleShare": {
+ "message": "내보낸 파일 저장"
+ },
+ "saName": {
+ "message": "파일 이름"
+ },
+ "saBeside": {
+ "message": "“$1” 옆에 저장"
+ },
+ "saChoose": {
+ "message": "폴더 선택…"
+ },
+ "saCancel": {
+ "message": "취소"
+ },
+ "saExists": {
+ "message": "“$1” 파일이 이미 있습니다. 바꾸려면 다시 저장하세요."
+ },
+ "saIsOriginal": {
+ "message": "열려 있는 문서와 같은 이름입니다. 다른 이름을 고르세요."
+ },
+ "saBadName": {
+ "message": "슬래시가 없는 파일 이름을 사용하세요."
+ },
+ "saLapsed": {
+ "message": "이 폴더에 대한 접근 권한이 만료되었습니다. 대신 폴더를 고르거나 라이브러리에서 갱신하세요."
+ },
+ "saGone": {
+ "message": "이 저장은 더 이상 대기 중이 아닙니다. 창을 닫고 다시 저장하세요."
+ },
+ "saTaken": {
+ "message": "“$1” 파일이 이미 있습니다. 다른 이름을 고르세요."
}
}
diff --git a/home/webext/_locales/ms/messages.json b/home/webext/_locales/ms/messages.json
index 8370c7be..966a3dee 100644
--- a/home/webext/_locales/ms/messages.json
+++ b/home/webext/_locales/ms/messages.json
@@ -628,5 +628,41 @@
},
"tdGrantFolder": {
"message": "Simpan semua dalam “$1” tanpa bertanya…"
+ },
+ "saTitleCopy": {
+ "message": "Simpan salinan"
+ },
+ "saTitleShare": {
+ "message": "Simpan fail yang dieksport"
+ },
+ "saName": {
+ "message": "Nama fail"
+ },
+ "saBeside": {
+ "message": "Simpan di sebelah “$1”"
+ },
+ "saChoose": {
+ "message": "Pilih folder…"
+ },
+ "saCancel": {
+ "message": "Batal"
+ },
+ "saExists": {
+ "message": "“$1” sudah ada. Simpan sekali lagi untuk menggantikannya."
+ },
+ "saIsOriginal": {
+ "message": "Itu nama dokumen yang sedang dibuka — pilih nama lain."
+ },
+ "saBadName": {
+ "message": "Gunakan nama fail tanpa garis condong."
+ },
+ "saLapsed": {
+ "message": "Akses ke folder ini telah tamat. Pilih folder lain, atau perbaharuinya dalam pustaka."
+ },
+ "saGone": {
+ "message": "Simpanan ini tidak lagi menunggu. Tutup tetingkap ini dan simpan sekali lagi."
+ },
+ "saTaken": {
+ "message": "“$1” sudah ada. Pilih nama lain."
}
}
diff --git a/home/webext/_locales/nb/messages.json b/home/webext/_locales/nb/messages.json
index bf8cbe5b..467f5fbf 100644
--- a/home/webext/_locales/nb/messages.json
+++ b/home/webext/_locales/nb/messages.json
@@ -628,5 +628,41 @@
},
"tdGrantFolder": {
"message": "Lagre alt i «$1» uten å spørre …"
+ },
+ "saTitleCopy": {
+ "message": "Lagre en kopi"
+ },
+ "saTitleShare": {
+ "message": "Lagre den eksporterte filen"
+ },
+ "saName": {
+ "message": "Filnavn"
+ },
+ "saBeside": {
+ "message": "Lagre ved siden av «$1»"
+ },
+ "saChoose": {
+ "message": "Velg en mappe …"
+ },
+ "saCancel": {
+ "message": "Avbryt"
+ },
+ "saExists": {
+ "message": "«$1» finnes allerede. Lagre igjen for å erstatte den."
+ },
+ "saIsOriginal": {
+ "message": "Det er navnet på dokumentet som er åpent – velg et annet."
+ },
+ "saBadName": {
+ "message": "Bruk et filnavn uten skråstreker."
+ },
+ "saLapsed": {
+ "message": "Tilgangen til mappen har utløpt. Velg en mappe i stedet, eller forny den i biblioteket."
+ },
+ "saGone": {
+ "message": "Denne lagringen venter ikke lenger. Lukk vinduet og lagre på nytt."
+ },
+ "saTaken": {
+ "message": "«$1» finnes allerede. Velg et annet navn."
}
}
diff --git a/home/webext/_locales/nl/messages.json b/home/webext/_locales/nl/messages.json
index d1aa8165..f5ba53d2 100644
--- a/home/webext/_locales/nl/messages.json
+++ b/home/webext/_locales/nl/messages.json
@@ -628,5 +628,41 @@
},
"tdGrantFolder": {
"message": "Alles in “$1” opslaan zonder vragen…"
+ },
+ "saTitleCopy": {
+ "message": "Kopie opslaan"
+ },
+ "saTitleShare": {
+ "message": "Geëxporteerd bestand opslaan"
+ },
+ "saName": {
+ "message": "Bestandsnaam"
+ },
+ "saBeside": {
+ "message": "Opslaan naast ‘$1’"
+ },
+ "saChoose": {
+ "message": "Kies een map…"
+ },
+ "saCancel": {
+ "message": "Annuleren"
+ },
+ "saExists": {
+ "message": "‘$1’ bestaat al. Sla opnieuw op om het te vervangen."
+ },
+ "saIsOriginal": {
+ "message": "Dat is de naam van het geopende document zelf — kies een andere."
+ },
+ "saBadName": {
+ "message": "Gebruik een bestandsnaam zonder schuine strepen."
+ },
+ "saLapsed": {
+ "message": "De toegang tot deze map is verlopen. Kies in plaats daarvan een map, of vernieuw de toegang in de bibliotheek."
+ },
+ "saGone": {
+ "message": "Deze opslag wacht niet meer. Sluit dit venster en sla opnieuw op."
+ },
+ "saTaken": {
+ "message": "‘$1’ bestaat al. Kies een andere naam."
}
}
diff --git a/home/webext/_locales/pl/messages.json b/home/webext/_locales/pl/messages.json
index 56277af3..2088dd03 100644
--- a/home/webext/_locales/pl/messages.json
+++ b/home/webext/_locales/pl/messages.json
@@ -628,5 +628,41 @@
},
"tdGrantFolder": {
"message": "Zapisuj wszystko w „$1” bez pytania…"
+ },
+ "saTitleCopy": {
+ "message": "Zapisz kopię"
+ },
+ "saTitleShare": {
+ "message": "Zapisz wyeksportowany plik"
+ },
+ "saName": {
+ "message": "Nazwa pliku"
+ },
+ "saBeside": {
+ "message": "Zapisz obok „$1”"
+ },
+ "saChoose": {
+ "message": "Wybierz folder…"
+ },
+ "saCancel": {
+ "message": "Anuluj"
+ },
+ "saExists": {
+ "message": "„$1” już istnieje. Zapisz ponownie, aby go zastąpić."
+ },
+ "saIsOriginal": {
+ "message": "To nazwa otwartego dokumentu — wybierz inną."
+ },
+ "saBadName": {
+ "message": "Użyj nazwy pliku bez ukośników."
+ },
+ "saLapsed": {
+ "message": "Dostęp do tego folderu wygasł. Wybierz folder albo odnów dostęp w bibliotece."
+ },
+ "saGone": {
+ "message": "To zapisywanie już nie czeka. Zamknij okno i zapisz ponownie."
+ },
+ "saTaken": {
+ "message": "„$1” już istnieje. Wybierz inną nazwę."
}
}
diff --git a/home/webext/_locales/pt_BR/messages.json b/home/webext/_locales/pt_BR/messages.json
index 8f94ff02..2aa4567e 100644
--- a/home/webext/_locales/pt_BR/messages.json
+++ b/home/webext/_locales/pt_BR/messages.json
@@ -661,5 +661,41 @@
},
"tdGrantFolder": {
"message": "Salvar tudo em “$1” sem perguntar…"
+ },
+ "saTitleCopy": {
+ "message": "Salvar uma cópia"
+ },
+ "saTitleShare": {
+ "message": "Salvar o arquivo exportado"
+ },
+ "saName": {
+ "message": "Nome do arquivo"
+ },
+ "saBeside": {
+ "message": "Salvar ao lado de “$1”"
+ },
+ "saChoose": {
+ "message": "Escolher uma pasta…"
+ },
+ "saCancel": {
+ "message": "Cancelar"
+ },
+ "saExists": {
+ "message": "“$1” já existe. Salve de novo para substituí-lo."
+ },
+ "saIsOriginal": {
+ "message": "Esse é o nome do próprio documento aberto — escolha outro."
+ },
+ "saBadName": {
+ "message": "Use um nome de arquivo sem barras."
+ },
+ "saLapsed": {
+ "message": "O acesso a esta pasta expirou. Escolha uma pasta ou renove o acesso na biblioteca."
+ },
+ "saGone": {
+ "message": "Este salvamento não está mais aguardando. Feche esta janela e salve de novo."
+ },
+ "saTaken": {
+ "message": "“$1” já existe. Escolha outro nome."
}
}
diff --git a/home/webext/_locales/ru/messages.json b/home/webext/_locales/ru/messages.json
index 882fee3c..5b2914e0 100644
--- a/home/webext/_locales/ru/messages.json
+++ b/home/webext/_locales/ru/messages.json
@@ -628,5 +628,41 @@
},
"tdGrantFolder": {
"message": "Сохранять всё в «$1» без вопросов…"
+ },
+ "saTitleCopy": {
+ "message": "Сохранить копию"
+ },
+ "saTitleShare": {
+ "message": "Сохранить экспортированный файл"
+ },
+ "saName": {
+ "message": "Имя файла"
+ },
+ "saBeside": {
+ "message": "Сохранить рядом с «$1»"
+ },
+ "saChoose": {
+ "message": "Выбрать папку…"
+ },
+ "saCancel": {
+ "message": "Отмена"
+ },
+ "saExists": {
+ "message": "«$1» уже существует. Сохраните ещё раз, чтобы заменить."
+ },
+ "saIsOriginal": {
+ "message": "Это имя самого открытого документа — выберите другое."
+ },
+ "saBadName": {
+ "message": "Используйте имя файла без косых черт."
+ },
+ "saLapsed": {
+ "message": "Доступ к этой папке истёк. Выберите папку или обновите доступ в библиотеке."
+ },
+ "saGone": {
+ "message": "Это сохранение больше не ожидает. Закройте окно и сохраните снова."
+ },
+ "saTaken": {
+ "message": "«$1» уже существует. Выберите другое имя."
}
}
diff --git a/home/webext/_locales/sv/messages.json b/home/webext/_locales/sv/messages.json
index 87989c11..bdb5a622 100644
--- a/home/webext/_locales/sv/messages.json
+++ b/home/webext/_locales/sv/messages.json
@@ -628,5 +628,41 @@
},
"tdGrantFolder": {
"message": "Spara allt i ”$1” utan att fråga…"
+ },
+ "saTitleCopy": {
+ "message": "Spara en kopia"
+ },
+ "saTitleShare": {
+ "message": "Spara den exporterade filen"
+ },
+ "saName": {
+ "message": "Filnamn"
+ },
+ "saBeside": {
+ "message": "Spara bredvid ”$1”"
+ },
+ "saChoose": {
+ "message": "Välj en mapp …"
+ },
+ "saCancel": {
+ "message": "Avbryt"
+ },
+ "saExists": {
+ "message": "”$1” finns redan. Spara igen för att ersätta den."
+ },
+ "saIsOriginal": {
+ "message": "Det är det öppna dokumentets eget namn – välj ett annat."
+ },
+ "saBadName": {
+ "message": "Använd ett filnamn utan snedstreck."
+ },
+ "saLapsed": {
+ "message": "Åtkomsten till mappen har gått ut. Välj en mapp i stället, eller förnya den i biblioteket."
+ },
+ "saGone": {
+ "message": "Den här sparningen väntar inte längre. Stäng fönstret och spara igen."
+ },
+ "saTaken": {
+ "message": "”$1” finns redan. Välj ett annat namn."
}
}
diff --git a/home/webext/_locales/th/messages.json b/home/webext/_locales/th/messages.json
index 9260f696..b09c98a4 100644
--- a/home/webext/_locales/th/messages.json
+++ b/home/webext/_locales/th/messages.json
@@ -628,5 +628,41 @@
},
"tdGrantFolder": {
"message": "บันทึกทุกอย่างใน “$1” โดยไม่ต้องถาม…"
+ },
+ "saTitleCopy": {
+ "message": "บันทึกสำเนา"
+ },
+ "saTitleShare": {
+ "message": "บันทึกไฟล์ที่ส่งออก"
+ },
+ "saName": {
+ "message": "ชื่อไฟล์"
+ },
+ "saBeside": {
+ "message": "บันทึกไว้ข้าง “$1”"
+ },
+ "saChoose": {
+ "message": "เลือกโฟลเดอร์…"
+ },
+ "saCancel": {
+ "message": "ยกเลิก"
+ },
+ "saExists": {
+ "message": "มี “$1” อยู่แล้ว บันทึกอีกครั้งเพื่อแทนที่"
+ },
+ "saIsOriginal": {
+ "message": "นั่นคือชื่อของเอกสารที่เปิดอยู่ — เลือกชื่ออื่น"
+ },
+ "saBadName": {
+ "message": "ใช้ชื่อไฟล์ที่ไม่มีเครื่องหมายทับ"
+ },
+ "saLapsed": {
+ "message": "สิทธิ์เข้าถึงโฟลเดอร์นี้หมดอายุแล้ว เลือกโฟลเดอร์แทน หรือต่ออายุในคลัง"
+ },
+ "saGone": {
+ "message": "การบันทึกนี้ไม่ได้รออยู่แล้ว ปิดหน้าต่างนี้แล้วบันทึกอีกครั้ง"
+ },
+ "saTaken": {
+ "message": "มี “$1” อยู่แล้ว เลือกชื่ออื่น"
}
}
diff --git a/home/webext/_locales/tr/messages.json b/home/webext/_locales/tr/messages.json
index efa634b8..bd45b2cb 100644
--- a/home/webext/_locales/tr/messages.json
+++ b/home/webext/_locales/tr/messages.json
@@ -628,5 +628,41 @@
},
"tdGrantFolder": {
"message": "“$1” içindeki her şeyi sormadan kaydet…"
+ },
+ "saTitleCopy": {
+ "message": "Kopya kaydet"
+ },
+ "saTitleShare": {
+ "message": "Dışa aktarılan dosyayı kaydet"
+ },
+ "saName": {
+ "message": "Dosya adı"
+ },
+ "saBeside": {
+ "message": "“$1” dosyasının yanına kaydet"
+ },
+ "saChoose": {
+ "message": "Klasör seç…"
+ },
+ "saCancel": {
+ "message": "İptal"
+ },
+ "saExists": {
+ "message": "“$1” zaten var. Değiştirmek için yeniden kaydedin."
+ },
+ "saIsOriginal": {
+ "message": "Bu, açık belgenin kendi adı — başka bir ad seçin."
+ },
+ "saBadName": {
+ "message": "Eğik çizgi içermeyen bir dosya adı kullanın."
+ },
+ "saLapsed": {
+ "message": "Bu klasöre erişimin süresi doldu. Bunun yerine bir klasör seçin ya da kütüphaneden yenileyin."
+ },
+ "saGone": {
+ "message": "Bu kaydetme artık beklemiyor. Pencereyi kapatıp yeniden kaydedin."
+ },
+ "saTaken": {
+ "message": "“$1” zaten var. Başka bir ad seçin."
}
}
diff --git a/home/webext/_locales/uk/messages.json b/home/webext/_locales/uk/messages.json
index e83428fe..4cc67b19 100644
--- a/home/webext/_locales/uk/messages.json
+++ b/home/webext/_locales/uk/messages.json
@@ -628,5 +628,41 @@
},
"tdGrantFolder": {
"message": "Зберігати все в «$1» без запитань…"
+ },
+ "saTitleCopy": {
+ "message": "Зберегти копію"
+ },
+ "saTitleShare": {
+ "message": "Зберегти експортований файл"
+ },
+ "saName": {
+ "message": "Назва файлу"
+ },
+ "saBeside": {
+ "message": "Зберегти поруч із «$1»"
+ },
+ "saChoose": {
+ "message": "Вибрати папку…"
+ },
+ "saCancel": {
+ "message": "Скасувати"
+ },
+ "saExists": {
+ "message": "«$1» вже існує. Збережіть ще раз, щоб замінити."
+ },
+ "saIsOriginal": {
+ "message": "Це назва самого відкритого документа — виберіть іншу."
+ },
+ "saBadName": {
+ "message": "Використайте назву файлу без скісних рисок."
+ },
+ "saLapsed": {
+ "message": "Доступ до цієї папки минув. Виберіть папку або поновіть доступ у бібліотеці."
+ },
+ "saGone": {
+ "message": "Це збереження вже не очікує. Закрийте вікно й збережіть ще раз."
+ },
+ "saTaken": {
+ "message": "«$1» вже існує. Виберіть іншу назву."
}
}
diff --git a/home/webext/_locales/ur/messages.json b/home/webext/_locales/ur/messages.json
index 3f714b95..0fa34b71 100644
--- a/home/webext/_locales/ur/messages.json
+++ b/home/webext/_locales/ur/messages.json
@@ -628,5 +628,41 @@
},
"tdGrantFolder": {
"message": "”$1“ میں سب کچھ بغیر پوچھے محفوظ کریں…"
+ },
+ "saTitleCopy": {
+ "message": "ایک کاپی محفوظ کریں"
+ },
+ "saTitleShare": {
+ "message": "برآمد شدہ فائل محفوظ کریں"
+ },
+ "saName": {
+ "message": "فائل کا نام"
+ },
+ "saBeside": {
+ "message": "“$1” کے ساتھ محفوظ کریں"
+ },
+ "saChoose": {
+ "message": "فولڈر منتخب کریں…"
+ },
+ "saCancel": {
+ "message": "منسوخ کریں"
+ },
+ "saExists": {
+ "message": "“$1” پہلے سے موجود ہے۔ بدلنے کے لیے دوبارہ محفوظ کریں۔"
+ },
+ "saIsOriginal": {
+ "message": "یہ کھلی دستاویز کا اپنا نام ہے — کوئی اور منتخب کریں۔"
+ },
+ "saBadName": {
+ "message": "سلیش کے بغیر فائل کا نام استعمال کریں۔"
+ },
+ "saLapsed": {
+ "message": "اس فولڈر تک رسائی ختم ہو گئی ہے۔ اس کے بجائے فولڈر منتخب کریں، یا لائبریری میں اسے تجدید کریں۔"
+ },
+ "saGone": {
+ "message": "یہ محفوظ کرنا اب منتظر نہیں۔ یہ ونڈو بند کر کے دوبارہ محفوظ کریں۔"
+ },
+ "saTaken": {
+ "message": "“$1” پہلے سے موجود ہے۔ کوئی دوسرا نام منتخب کریں۔"
}
}
diff --git a/home/webext/_locales/vi/messages.json b/home/webext/_locales/vi/messages.json
index 5f621270..14fbea4a 100644
--- a/home/webext/_locales/vi/messages.json
+++ b/home/webext/_locales/vi/messages.json
@@ -628,5 +628,41 @@
},
"tdGrantFolder": {
"message": "Lưu mọi thứ trong “$1” mà không hỏi…"
+ },
+ "saTitleCopy": {
+ "message": "Lưu một bản sao"
+ },
+ "saTitleShare": {
+ "message": "Lưu tệp đã xuất"
+ },
+ "saName": {
+ "message": "Tên tệp"
+ },
+ "saBeside": {
+ "message": "Lưu cạnh “$1”"
+ },
+ "saChoose": {
+ "message": "Chọn thư mục…"
+ },
+ "saCancel": {
+ "message": "Hủy"
+ },
+ "saExists": {
+ "message": "“$1” đã có. Lưu lần nữa để thay thế."
+ },
+ "saIsOriginal": {
+ "message": "Đó là tên của chính tài liệu đang mở — hãy chọn tên khác."
+ },
+ "saBadName": {
+ "message": "Dùng tên tệp không có dấu gạch chéo."
+ },
+ "saLapsed": {
+ "message": "Quyền truy cập thư mục này đã hết hạn. Hãy chọn thư mục khác, hoặc gia hạn trong thư viện."
+ },
+ "saGone": {
+ "message": "Lần lưu này không còn chờ nữa. Đóng cửa sổ này và lưu lại."
+ },
+ "saTaken": {
+ "message": "“$1” đã có. Hãy chọn tên khác."
}
}
diff --git a/home/webext/_locales/zh_CN/messages.json b/home/webext/_locales/zh_CN/messages.json
index ab2c2c84..1f2280f5 100644
--- a/home/webext/_locales/zh_CN/messages.json
+++ b/home/webext/_locales/zh_CN/messages.json
@@ -661,5 +661,41 @@
},
"tdGrantFolder": {
"message": "“$1”中的所有内容不再询问直接保存……"
+ },
+ "saTitleCopy": {
+ "message": "保存副本"
+ },
+ "saTitleShare": {
+ "message": "保存导出的文件"
+ },
+ "saName": {
+ "message": "文件名"
+ },
+ "saBeside": {
+ "message": "保存到“$1”旁边"
+ },
+ "saChoose": {
+ "message": "选择文件夹…"
+ },
+ "saCancel": {
+ "message": "取消"
+ },
+ "saExists": {
+ "message": "“$1”已存在。再次保存即可替换。"
+ },
+ "saIsOriginal": {
+ "message": "这是已打开文档本身的名称——请换一个。"
+ },
+ "saBadName": {
+ "message": "请使用不含斜杠的文件名。"
+ },
+ "saLapsed": {
+ "message": "对此文件夹的访问已失效。请改为选择文件夹,或在资料库中续期。"
+ },
+ "saGone": {
+ "message": "此次保存已不再等待。请关闭此窗口后重新保存。"
+ },
+ "saTaken": {
+ "message": "“$1”已存在。请换一个名称。"
}
}
diff --git a/home/webext/_locales/zh_TW/messages.json b/home/webext/_locales/zh_TW/messages.json
index e3fc2409..ecc68fad 100644
--- a/home/webext/_locales/zh_TW/messages.json
+++ b/home/webext/_locales/zh_TW/messages.json
@@ -661,5 +661,41 @@
},
"tdGrantFolder": {
"message": "「$1」中的所有內容不再詢問直接儲存……"
+ },
+ "saTitleCopy": {
+ "message": "儲存副本"
+ },
+ "saTitleShare": {
+ "message": "儲存匯出的檔案"
+ },
+ "saName": {
+ "message": "檔案名稱"
+ },
+ "saBeside": {
+ "message": "儲存到「$1」旁邊"
+ },
+ "saChoose": {
+ "message": "選擇資料夾…"
+ },
+ "saCancel": {
+ "message": "取消"
+ },
+ "saExists": {
+ "message": "「$1」已存在。再次儲存即可取代。"
+ },
+ "saIsOriginal": {
+ "message": "這是已開啟文件本身的名稱——請換一個。"
+ },
+ "saBadName": {
+ "message": "請使用不含斜線的檔名。"
+ },
+ "saLapsed": {
+ "message": "對此資料夾的存取已失效。請改為選擇資料夾,或在資料庫中續期。"
+ },
+ "saGone": {
+ "message": "此次儲存已不再等待。請關閉此視窗後重新儲存。"
+ },
+ "saTaken": {
+ "message": "「$1」已存在。請換一個名稱。"
}
}
diff --git a/home/webext/src/background.js b/home/webext/src/background.js
index 9e28bf9c..5a2a9a09 100644
--- a/home/webext/src/background.js
+++ b/home/webext/src/background.js
@@ -37,6 +37,7 @@ import { t } from './i18n.js'
import { pathFromSender, locateIn } from './route.js'
import { resolveFileGrant, dropFileGrant, declined, downloadsDir, downloadsRelative, writeViaDownloads, downloadsUnusable, setDownloadsUnusable, defaultDeps as defaultFileGrantDeps } from './filegrant.js'
import { recentOpened } from './db.js'
+import * as saveas from './saveas.js'
/** Same-named files the extension knows at OTHER paths: opened documents and the library's last scan. */
async function knownTwins(path) {
@@ -415,6 +416,67 @@ function offerAnswered(sender, msg) {
return { ok: true }
}
+// ---------------------------------------------------------------- save as
+//
+// "Save a copy…" and exports (saveas.js): the page's picker call, answered in
+// the extension's own window so it can open beside the document. The path is
+// the sender's, top frame only; the window is the only one that may answer.
+
+const saveasWaiting = new Map() // token → resolve(true|false)
+const saveasPaths = new Set() // documents with a save-as window open
+const SAVEAS_WAIT_MS = 170000
+
+/** The sender's own path — top frame only, like every store and save op. */
+const topPath = (sender) => (sender?.frameId === 0 ? pathFromSender(sender) : null)
+
+export function saveasDeps(sender, deps = {}) {
+ return {
+ db: deps.db ?? saveas.idb(),
+ now: deps.now ?? (() => Date.now()),
+ token: deps.token ?? (() => crypto.randomUUID()),
+ // the document's OWN folder, when a folder grant reaches it by route
+ folderOf: deps.folderOf ?? (async () => {
+ const r = await resolve(sender)
+ return r.ok && Array.isArray(r.rel) ? parentOf(r.dir, r.rel) : null
+ }),
+ // the document's own file, so "never the original" compares FILES, not names
+ docHandle: deps.docHandle ?? (async () => {
+ const r = await resolve(sender)
+ return r.ok ? r.handle : null
+ }),
+ busy: deps.busy ?? ((path) => saveasPaths.has(path)),
+ openWindow: deps.openWindow ?? ((token, path) => new Promise((resolve) => {
+ saveasPaths.add(path)
+ const done = (v) => { saveasPaths.delete(path); resolve(v) }
+ saveasWaiting.set(token, done)
+ const url = new URL(chrome.runtime.getURL('src/saveas.html'))
+ url.searchParams.set('token', token)
+ chrome.windows.create({ url: url.href, type: 'popup', width: 480, height: 330, focused: true })
+ .catch(() => { saveasWaiting.delete(token); done(null) })
+ setTimeout(() => { if (saveasWaiting.get(token) === done) { saveasWaiting.delete(token); done(false) } }, SAVEAS_WAIT_MS)
+ })),
+ }
+}
+
+const isSaveasWindow = (sender) => sender?.id === chrome.runtime.id && typeof sender.url === 'string'
+ && sender.url.startsWith(chrome.runtime.getURL('src/saveas.html'))
+
+function saveasAnswered(sender, msg) {
+ if (!isSaveasWindow(sender)) return { ok: false, reason: 'not the save-as window' }
+ const done = saveasWaiting.get(msg.token)
+ if (done) { saveasWaiting.delete(msg.token); done(msg.chosen === true) }
+ return { ok: true }
+}
+
+function watchSaveasWindow(port) {
+ if (!isSaveasWindow(port.sender)) { port.disconnect(); return }
+ const token = port.name.slice('saveas:'.length)
+ port.onDisconnect.addListener(() => {
+ const done = saveasWaiting.get(token)
+ if (done) { saveasWaiting.delete(token); done(false) }
+ })
+}
+
// `chrome` is absent when this module is loaded by the test rig, which imports
// the logic above and never needs the listener.
if (typeof chrome !== 'undefined' && chrome.runtime?.onMessage) {
@@ -434,6 +496,10 @@ if (typeof chrome !== 'undefined' && chrome.runtime?.onMessage) {
: msg?.op === 'save.rebadge' ? (async () => { const tabs = await chrome.tabs.query({ url: 'file:///*.bento.html' }).catch(() => []); for (const tb of tabs) await badgeTab(tb.id, { url: tb.url, frameId: 0, tab: tb }); return { ok: true } })()
: msg?.op === 'write' ? write(sender, msg.payload?.text ?? '')
: msg?.op === 'backup' ? backup(sender, msg.payload?.text ?? '', msg.payload?.name)
+ : msg?.op === 'saveas' ? saveas.ask(topPath(sender), msg.payload, saveasDeps(sender))
+ : msg?.op === 'saveas.write' ? saveas.write(topPath(sender), msg.payload, saveasDeps(sender))
+ : msg?.op === 'saveas.answered' ? Promise.resolve(saveasAnswered(sender, msg))
+ : msg?.op === 'saveas.drop' ? saveas.drop(topPath(sender), msg.payload, saveasDeps(sender))
: Promise.resolve({ ok: false, reason: 'unknown op' })
run.then((r) => {
sendResponse(r)
@@ -448,6 +514,7 @@ if (typeof chrome !== 'undefined' && chrome.runtime?.onMessage) {
chrome.runtime.onConnect.addListener((port) => {
if (port.name.startsWith('filegrant:')) watchOfferWindow(port)
+ else if (port.name.startsWith('saveas:')) watchSaveasWindow(port)
})
// The worker restarts constantly; the badge has to survive that, and startup
@@ -462,6 +529,7 @@ if (typeof chrome !== 'undefined' && chrome.runtime?.onMessage) {
// would cost the `alarms` permission for a courtesy. Store installs are never
// asked — `checkForUpdate` returns immediately for them.
chrome.runtime.onStartup?.addListener(() => void checkForUpdate())
+ chrome.runtime.onStartup?.addListener(() => { void saveas.gc(saveasDeps(null)).catch(() => {}) })
chrome.runtime.onInstalled?.addListener(() => void checkForUpdate())
void reportLapsed()
diff --git a/home/webext/src/page-bridge.js b/home/webext/src/page-bridge.js
index 6e32b83b..165e7d0e 100644
--- a/home/webext/src/page-bridge.js
+++ b/home/webext/src/page-bridge.js
@@ -146,7 +146,7 @@
* directions where "are you at least version N" does not.
*/
Object.defineProperty(window, '__bentoHost', {
- value: Object.freeze({ name: 'home/webext', ops: Object.freeze(['claim', 'write', 'backup']) }),
+ value: Object.freeze({ name: 'home/webext', ops: Object.freeze(['claim', 'write', 'backup', 'saveas']) }),
writable: false, configurable: false, enumerable: false,
})
@@ -207,6 +207,13 @@
isSameEntry: async () => false,
})
+ // Save-as tokens this document holds; they end when it unloads (saveas.js drop).
+ const saveTokens = new Set()
+ window.addEventListener('pagehide', () => {
+ for (const token of saveTokens) window.postMessage({ [CH]: true, dir: 'req', id: `drop-${token}`, op: 'saveas.drop', payload: { token } }, '*')
+ saveTokens.clear()
+ })
+
window.showSaveFilePicker = async (opts = {}) => {
if (wantsBackup(opts)) {
// No `claim` round trip: the backup does not exist yet, so there is
@@ -218,6 +225,23 @@
// exists to remove. `save.ts` catches the throw and downloads instead.
return handleOver(opts.suggestedName, 'backup', { name: opts.suggestedName })
}
+ // Only in a person's gesture, like the browser's own picker: a document
+ // cannot open the extension's window unprompted to lure clicks.
+ // (`userActivation` is shared with the content script's world.)
+ const activated = window.navigator?.userActivation?.isActive === true
+ if ((opts?.id === 'bento-copy' || opts?.id === 'bento-share') && activated) {
+ // "Save a copy…" and exports: the extension asks in its own window,
+ // which can open beside this document (saveas.js). Cancelled there is
+ // cancelled here; no answer at all is the browser's own picker.
+ const r = await ask('saveas', { id: opts.id, name: opts.suggestedName }, 180000)
+ if (r?.ok && typeof r.token === 'string') {
+ saveTokens.add(r.token)
+ return handleOver(r.name, 'saveas.write', { token: r.token })
+ }
+ if (r?.cancelled) throw new DOMException('The user aborted a request.', 'AbortError')
+ if (native) return native(forNative(opts))
+ throw new DOMException('No file picker available', 'AbortError')
+ }
if (!wantsOpenFile(opts)) {
if (native) return native(forNative(opts))
throw new DOMException('No file picker available', 'AbortError')
diff --git a/home/webext/src/saveas-window.js b/home/webext/src/saveas-window.js
new file mode 100644
index 00000000..856c4ba2
--- /dev/null
+++ b/home/webext/src/saveas-window.js
@@ -0,0 +1,117 @@
+// SPDX-License-Identifier: MIT
+// Copyright (c) 2026 The Bento authors
+//
+// The save-as window (saveas.js has the whole story). It reads the record the
+// worker made, offers "Save next to <document>" when the extension reaches
+// the document's folder, and "Choose a folder…" — a picker that opens in that
+// folder, or the nearest one the extension holds. The picker runs HERE, in
+// this window's click: a page cannot be given a handle, and the page's own
+// picker has nowhere better to start than Downloads.
+
+import { t, localize, initI18n } from './i18n.js'
+import { idb, readRecord, choose, besideName, replaceDecision, EXT } from './saveas.js'
+import { startInFor } from './grantflow.js'
+
+const q = new URLSearchParams(location.search)
+const token = q.get('token') ?? ''
+const db = idb()
+
+await initI18n()
+localize()
+const rec = await readRecord(token, db)
+const status = document.getElementById('status')
+const file = document.getElementById('file')
+const besideBtn = document.getElementById('beside')
+const chooseBtn = document.getElementById('choose')
+
+// A port whose disconnect is this window closing unanswered: the worker then
+// answers the waiting page "cancelled" instead of holding it.
+try { chrome.runtime.connect({ name: `saveas:${token}` }) } catch { /* fine */ }
+const answer = async (chosen) => {
+ try { await chrome.runtime.sendMessage({ op: 'saveas.answered', token, chosen }) } catch { /* worker gone */ }
+ window.close()
+}
+
+if (!rec) {
+ status.textContent = t('saGone')
+ besideBtn.hidden = true
+ chooseBtn.disabled = true
+} else {
+ const original = rec.path.split('/').pop()
+ // literal keys, so the catalogue rig can see every one is used
+ document.getElementById('title').textContent = rec.purpose === 'copy' ? t('saTitleCopy') : t('saTitleShare')
+ document.getElementById('name').textContent = original
+ document.getElementById('path').textContent = rec.path
+ file.value = rec.name
+ // select the stem, like the browser's own dialog, so typing replaces the name only
+ const stem = rec.name.toLowerCase().endsWith(EXT) ? rec.name.length - EXT.length : rec.name.length
+ file.focus()
+ file.setSelectionRange(0, stem)
+ if (rec.dir) {
+ besideBtn.hidden = false
+ besideBtn.textContent = t('saBeside', original)
+ } else {
+ // the picker is the only way: make it the primary action
+ chooseBtn.classList.add('primary')
+ }
+ let confirmReplace = null // the name the person was warned about
+ // Only a name the PERSON typed may replace a file: the suggestion is the
+ // page's, and the page must never be able to aim this window at a sibling.
+ const edited = () => file.value.trim() !== rec.name
+ const nameOrSay = () => {
+ const r = besideName(file.value, original)
+ if (!r.ok) status.textContent = r.reason === 'is-original' ? t('saIsOriginal') : t('saBadName')
+ return r.ok ? r.name : null
+ }
+ file.addEventListener('input', () => { status.textContent = ''; confirmReplace = null })
+
+ besideBtn.onclick = async () => {
+ const name = nameOrSay()
+ if (!name) return
+ besideBtn.disabled = true
+ try {
+ if (await rec.dir.queryPermission({ mode: 'readwrite' }) !== 'granted'
+ && await rec.dir.requestPermission({ mode: 'readwrite' }) !== 'granted') {
+ status.textContent = t('saLapsed')
+ besideBtn.disabled = false
+ return
+ }
+ let exists = true
+ try { await rec.dir.getFileHandle(name) } catch (e) { exists = e?.name !== 'NotFoundError' }
+ const d = replaceDecision({ exists, edited: edited(), confirmed: confirmReplace === name })
+ if (d === 'refuse' || d === 'confirm') {
+ confirmReplace = d === 'confirm' ? name : null
+ status.textContent = d === 'confirm' ? t('saExists', name) : t('saTaken', name)
+ besideBtn.disabled = false
+ return
+ }
+ if (await choose(token, { kind: 'beside', name, replace: d === 'replace' }, db)) await answer(true)
+ else status.textContent = t('saGone')
+ } catch (e) { status.textContent = e?.message || String(e) }
+ besideBtn.disabled = false
+ }
+
+ chooseBtn.onclick = async () => {
+ const name = nameOrSay() ?? rec.name
+ chooseBtn.disabled = true
+ try {
+ const startIn = rec.dir ?? await startInFor(rec.path)
+ const handle = await window.showSaveFilePicker({
+ suggestedName: name,
+ startIn,
+ // the browser remembers the last folder per id; copies and exports apart
+ id: rec.purpose === 'copy' ? 'bento-copy' : 'bento-share',
+ types: [{ description: 'Bento', accept: { 'text/html': [EXT] } }],
+ })
+ if (await choose(token, { kind: 'handle', handle, name: handle.name }, db)) await answer(true)
+ else status.textContent = t('saGone')
+ } catch (e) {
+ if (e?.name !== 'AbortError') status.textContent = e?.message || String(e)
+ }
+ chooseBtn.disabled = false
+ }
+ // Enter = the primary action
+ file.addEventListener('keydown', (e) => { if (e.key === 'Enter') (rec.dir ? besideBtn : chooseBtn).click() })
+}
+document.getElementById('cancel').onclick = () => void answer(false)
+addEventListener('keydown', (e) => { if (e.key === 'Escape') void answer(false) })
diff --git a/home/webext/src/saveas.html b/home/webext/src/saveas.html
new file mode 100644
index 00000000..dac1c446
--- /dev/null
+++ b/home/webext/src/saveas.html
@@ -0,0 +1,35 @@
+<!doctype html>
+<meta charset="utf-8">
+<title>bento/home</title>
+<link rel="icon" href="../icons/icon.svg">
+<link rel="stylesheet" href="ui.css">
+<!-- Blocking, and before the body: stamps the theme so the FIRST paint is right. -->
+<script src="theme.js"></script>
+<style>
+ /* "Save a copy…" and exports (saveas.js): a name, and where — beside the
+ * document in one click, or a folder chosen in a picker that opens near it. */
+ body { padding: 20px 22px; display: flex; flex-direction: column; gap: 12px; min-height: 100vh;
+ box-sizing: border-box }
+ h1 { font-size: 16px; margin: 0; line-height: 1.3 }
+ .file { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 8px;
+ background: var(--hover); min-width: 0 }
+ .file b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
+ .file small { color: var(--dim); font-size: 12px; white-space: nowrap; overflow: hidden;
+ text-overflow: ellipsis; direction: ltr; unicode-bidi: isolate; text-align: start }
+ label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--dim) }
+ input { font: inherit; font-size: 14px; padding: 7px 9px; border-radius: 6px; border: 1px solid var(--line);
+ background: var(--panel); color: var(--ink); direction: ltr; unicode-bidi: isolate }
+ .actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; margin-top: auto; flex-wrap: wrap }
+ .actions .cancel { margin-inline-end: auto }
+ .status { font-size: 12px; color: var(--dim); margin: 0; min-height: 1.2em }
+</style>
+<h1 id="title"></h1>
+<div class="file"><b id="name"></b><small id="path"></small></div>
+<label><span data-i18n="saName"></span><input id="file" spellcheck="false" autocomplete="off"></label>
+<p class="status" id="status" role="status"></p>
+<div class="actions">
+ <button class="btn link cancel" id="cancel" data-i18n="saCancel"></button>
+ <button class="btn" id="choose" data-i18n="saChoose"></button>
+ <button class="btn primary" id="beside" hidden></button>
+</div>
+<script type="module" src="saveas-window.js"></script>
diff --git a/home/webext/src/saveas.js b/home/webext/src/saveas.js
new file mode 100644
index 00000000..57789266
--- /dev/null
+++ b/home/webext/src/saveas.js
@@ -0,0 +1,242 @@
+// SPDX-License-Identifier: MIT
+// Copyright (c) 2026 The Bento authors
+//
+// "Save a copy…" and exports, answered by the extension so they start BESIDE
+// the document instead of in Downloads.
+//
+// WHY THE PAGE CANNOT DO THIS ITSELF. A double-clicked document has no file
+// handle, and a picker's `startIn` takes a handle, never a path. So the
+// browser's own dialog opens wherever it last was — usually Downloads. The
+// extension knows where the document lives (`sender.url`, stamped by the
+// browser) and often holds a handle for its folder. A handle cannot cross
+// into the page (it would land in the one origin every local file shares), so
+// the dialog runs in the extension's own small window instead.
+//
+// THE KERNEL IS UNCHANGED. save.ts already tells hosts what a picker call is
+// for, by its `id` (pickerIdFor): `bento-copy` for "Save a copy…",
+// `bento-share` for every export. page-bridge.js sends those here; ⌘S
+// (`bento-doc`) and backups never come this way.
+//
+// THE FLOW
+// page showSaveFilePicker({id:'bento-copy', suggestedName})
+// → `saveas` {name, purpose} (waits while the window is open)
+// worker opens src/saveas.html with a token; records { path, purpose, name,
+// dir } in this module's IndexedDB — `dir` is the document's own
+// folder when a folder grant reaches it
+// window "Save next to <document>" (one click, into `dir`), or "Choose a
+// folder…" (the picker, opening in `dir` or the nearest folder the
+// extension holds). Its choice is written to the record.
+// page gets { ok, token, name } and a handle whose close() sends
+// `saveas.write` {token, text}; the worker writes the chosen file.
+//
+// WHAT HOLDS IT
+// · The record is bound to the path of the document that asked. A write
+// with that token from any other document is refused.
+// · The page supplies only a NAME, and only as a suggestion: the person
+// sees it and can change it. A beside-name is a single file name ending
+// .bento.html, never the open document's own, and an existing file is
+// replaced only after the person says so in the window.
+// · Nothing is written until the page sends bytes, and only to the place
+// the person chose.
+// · A copy's token stays valid for that document's later writes: save.ts
+// makes a "Save a copy…" target the next ⌘S, as the browser's own picker
+// does. An export's is spent by its one write. Either ends when the
+// document unloads (`drop`), or after KEEP_MS.
+// · The suggestion never arrives aimed at an existing file (freshName); an
+// existing file is replaced only for a name the person typed, after a
+// warning, and that choice is checked again at write time.
+//
+// Pure: storage, folder resolution and the window come in as `deps`, so
+// scripts/test-webext-saveas.ts runs the real logic in node.
+
+export const PURPOSES = Object.freeze({ 'bento-copy': 'copy', 'bento-share': 'share' })
+export const EXT = '.bento.html'
+/** A record (and its handle) outlives the window by this much; swept on startup. */
+export const KEEP_MS = 24 * 3600 * 1000
+
+/**
+ * A name the window may create beside the document. `{ ok, name }` or
+ * `{ ok:false, reason }`. The compound extension is appended to a bare name,
+ * as the browser's own picker does for `accept: ['.bento.html']`.
+ */
+/**
+ * Characters a file name may not carry: path separators, controls, and the
+ * invisible FORMAT characters (bidi overrides and isolates, zero-width) — with
+ * those, "report\u202Elmth.bento.html" displays as something it is not.
+ */
+const BAD_CHARS = /[/\\\u0000-\u001f\u007f\u200b-\u200f\u202a-\u202e\u2066-\u2069\ufeff]/
+
+/** The same name as far as a file system may care: Unicode-normalised (NFC) and case-folded. */
+export const sameName = (a, b) => String(a).normalize('NFC').toLowerCase() === String(b).normalize('NFC').toLowerCase()
+
+export function besideName(proposed, original) {
+ let n = String(proposed ?? '').trim()
+ if (!n) return { ok: false, reason: 'empty' }
+ if (BAD_CHARS.test(n) || n === '.' || n === '..') return { ok: false, reason: 'bad-name' }
+ if (!n.toLowerCase().endsWith(EXT)) n = n.replace(/\.html?$/i, '') + EXT
+ if (n.length > 200) return { ok: false, reason: 'bad-name' }
+ if (original && sameName(n, original)) return { ok: false, reason: 'is-original' }
+ return { ok: true, name: n }
+}
+
+/** Is there a file of this name in `dir`? */
+async function exists(dir, name) {
+ try { await dir.getFileHandle(name); return true } catch (e) { return e?.name !== 'NotFoundError' }
+}
+
+/**
+ * A name that is FREE in `dir`: the suggestion, or "<stem> copy", "<stem> copy 2"…
+ * The page chooses the suggestion, so it must never arrive aimed at a file
+ * that is already there: a hostile document could name a sibling deck and
+ * have two clicks replace it. Replacing is only ever for a name the PERSON typed.
+ */
+export async function freshName(dir, name, original) {
+ if (!dir || !(await exists(dir, name))) return name
+ const stem = name.slice(0, -EXT.length).replace(/ copy( \d+)?$/, '')
+ for (let i = 1; i < 100; i++) {
+ const n = `${stem} copy${i > 1 ? ` ${i}` : ''}${EXT}`
+ if (!sameName(n, original) && !(await exists(dir, n))) return n
+ }
+ return name
+}
+
+/**
+ * The window's rule for a beside-name that already exists: 'ok' (free),
+ * 'refuse' (the page's suggestion, untouched — never replaced), 'confirm'
+ * (the person typed it — warn first), 'replace' (warned, and they clicked again).
+ */
+export function replaceDecision({ exists: there, edited, confirmed }) {
+ if (!there) return 'ok'
+ if (!edited) return 'refuse'
+ return confirmed ? 'replace' : 'confirm'
+}
+
+/** The page's suggestion, made safe to SHOW (it is never used as a path). */
+export function suggestion(name, original) {
+ const r = besideName(String(name ?? '').split(/[/\\]/).pop(), original)
+ return r.ok ? r.name : (String(original ?? 'Untitled').replace(/\.bento\.html?$/i, '') + ' copy' + EXT)
+}
+
+/**
+ * The page asked. Opens the window and waits for it; returns what the page
+ * gets: `{ ok, token, name }`, `{ ok:false, cancelled:true }`, or `{ ok:false,
+ * reason }` — the last means "use the browser's own picker".
+ */
+export async function ask(path, payload, deps) {
+ if (!path) return { ok: false, reason: 'not a document' }
+ const purpose = PURPOSES[payload?.id]
+ if (!purpose) return { ok: false, reason: 'not a save-as' }
+ // One window per document at a time: a page cannot stack them up.
+ if (deps.busy?.(path)) return { ok: false, cancelled: true }
+ const original = path.split('/').pop()
+ const name = suggestion(payload?.name, original)
+ let dir = null
+ try { dir = await deps.folderOf() } catch { dir = null }
+ const shown = dir ? await freshName(dir, name, original) : name
+ const token = deps.token()
+ await deps.db.put(token, { path, purpose, name: shown, dir, choice: null, at: deps.now() })
+ const answered = await deps.openWindow(token, path)
+ const rec = await deps.db.get(token)
+ if (!answered || !rec?.choice) {
+ await deps.db.del(token)
+ return answered === null ? { ok: false, reason: 'window unavailable' } : { ok: false, cancelled: true }
+ }
+ return { ok: true, token, name: rec.choice.name }
+}
+
+/** The page's bytes, for the place the person chose. */
+export async function write(path, payload, deps) {
+ if (!path) return { ok: false, reason: 'not a document' }
+ const token = payload?.token
+ if (typeof token !== 'string' || typeof payload?.text !== 'string') return { ok: false, reason: 'bad request' }
+ const rec = await deps.db.get(token)
+ if (!rec?.choice) return { ok: false, reason: 'no such save' }
+ if (rec.path !== path) return { ok: false, reason: 'not this document\'s save' }
+ try {
+ let h
+ if (rec.choice.kind === 'beside') {
+ if (!rec.dir) return { ok: false, reason: 'no folder' }
+ const ok = besideName(rec.choice.name, path.split('/').pop())
+ if (!ok.ok) return { ok: false, reason: ok.reason }
+ if (await rec.dir.queryPermission({ mode: 'readwrite' }) !== 'granted') return { ok: false, reason: 'folder grant needs renewing' }
+ let there = null
+ try { there = await rec.dir.getFileHandle(ok.name) } catch (e) { if (e?.name !== 'NotFoundError') throw e }
+ if (there) {
+ // never the open document, compared as FILES (NFD vs NFC, case) when its handle is known
+ const doc = await deps.docHandle?.().catch(() => null)
+ if (doc && await there.isSameEntry(doc)) return { ok: false, reason: 'is-original' }
+ // an existing file is replaced only when the person chose to, in the window;
+ // later writes of a "Save a copy" (save.ts's next ⌘S target) are to our own file
+ if (!rec.written && rec.choice.replace !== true) return { ok: false, reason: 'exists' }
+ }
+ h = there ?? await rec.dir.getFileHandle(ok.name, { create: true })
+ } else if (rec.choice.kind === 'handle') {
+ h = rec.choice.handle
+ if (await h.queryPermission({ mode: 'readwrite' }) !== 'granted') return { ok: false, reason: 'permission lapsed' }
+ } else {
+ return { ok: false, reason: 'no such save' }
+ }
+ const w = await h.createWritable()
+ await w.write(payload.text)
+ await w.close()
+ // An export is written once: save.ts never makes it a later ⌘S target (that
+ // would overwrite a view-only or invite copy with the full document). A
+ // copy IS the next ⌘S target, so its record stays for this session.
+ if (rec.purpose === 'share') await deps.db.del(token)
+ else await deps.db.put(token, { ...rec, written: true, at: deps.now() })
+ return { ok: true, name: h.name, bytes: payload.text.length }
+ } catch (e) {
+ return { ok: false, reason: `${e?.name}: ${e?.message}` }
+ }
+}
+
+/** The document is going away: its saves end with it. Only the document that made them may drop them. */
+export async function drop(path, payload, deps) {
+ const rec = typeof payload?.token === 'string' ? await deps.db.get(payload.token) : null
+ if (rec && path && rec.path === path) await deps.db.del(payload.token)
+ return { ok: true }
+}
+
+/** Records older than KEEP_MS. */
+export async function gc(deps) {
+ const cut = deps.now() - KEEP_MS
+ for (const [k, v] of await deps.db.all()) if (!v?.at || v.at < cut) await deps.db.del(k)
+}
+
+/** The window's helpers: the record, and storing the person's choice. */
+export async function readRecord(token, db) { return db.get(token) }
+export async function choose(token, choice, db) {
+ const rec = await db.get(token)
+ if (!rec) return false
+ await db.put(token, { ...rec, choice })
+ return true
+}
+
+/** Its own small database: handles are structured-cloneable into IndexedDB, not into chrome.storage. */
+export function idb(name = 'bento-saveas') {
+ const open = () => new Promise((res, rej) => {
+ const r = indexedDB.open(name, 1)
+ r.onupgradeneeded = () => { if (!r.result.objectStoreNames.contains('rec')) r.result.createObjectStore('rec') }
+ r.onsuccess = () => res(r.result)
+ r.onerror = () => rej(r.error)
+ })
+ const run = async (mode, fn) => {
+ const d = await open()
+ return new Promise((res, rej) => {
+ const t = d.transaction('rec', mode)
+ const req = fn(t.objectStore('rec'))
+ t.oncomplete = () => res(req?.result)
+ t.onerror = () => rej(t.error)
+ })
+ }
+ return {
+ get: (k) => run('readonly', (s) => s.get(k)).then((v) => v ?? null),
+ put: (k, v) => run('readwrite', (s) => s.put(v, k)).then(() => {}),
+ del: (k) => run('readwrite', (s) => s.delete(k)).then(() => {}),
+ all: async () => {
+ const keys = await run('readonly', (s) => s.getAllKeys())
+ const vals = await run('readonly', (s) => s.getAll())
+ return (keys ?? []).map((k, i) => [k, vals[i]])
+ },
+ }
+}
diff --git a/scripts/qa-webext-packed.mjs b/scripts/qa-webext-packed.mjs
new file mode 100644
index 00000000..5478d21c
--- /dev/null
+++ b/scripts/qa-webext-packed.mjs
@@ -0,0 +1,219 @@
+#!/usr/bin/env node
+// SPDX-License-Identifier: MIT
+// Copyright (c) 2026 The Bento authors
+// bento/home — the scripted half of the pre-release QA pass.
+//
+// node scripts/qa-webext-packed.mjs # CHROME_PATH to pick a build
+//
+// WHAT THIS IS. Not a CI rig. It checks the thing the store would ship: it runs
+// the PACKAGE (scripts/pack-webext.mjs → dist/bento-home-<v>.zip, unzipped
+// as-is), not the source tree, in a FRESH profile — so a file the pack step
+// left out, a string missing from a catalogue, or a page that throws on first
+// load shows up here and not in a reviewer's hands.
+//
+// WHAT IT CHECKS
+// 1. the service worker starts, with no errors
+// 2. every extension page opens with no errors and no untranslated text,
+// and is screenshotted for a human to look at
+// 3. (file access OFF — the store-install state — is manual; see below)
+// 4. with file access on: a document gets the bridge with every op, and the
+// library lists it once opened
+// 5. ⌘S with nothing granted opens the one-time offer window
+// 6. "Save a copy" inside a click opens the save-as window, and Cancel
+// reaches the page as AbortError; outside a click, no window
+//
+// WHAT IT CANNOT CHECK (the manual half — see the store-listing draft's QA list):
+// the file-access-off onboarding (see "THE FRESH-INSTALL STATE"); any OS file picker (granting a folder, choosing a file), so saving in place,
+// the blocked-folder path and lapsed grants; the assistant against real
+// providers; a store install's update silence (an unpacked load is
+// installType 'development'); Windows.
+//
+// Branded Google Chrome ignores --load-extension since 137; use Chrome for
+// Testing or Chromium (CHROME_PATH), or the newest build in ~/.cache/puppeteer.
+
+import { execFileSync } from 'node:child_process'
+import { mkdtempSync, writeFileSync, readdirSync, existsSync, mkdirSync } from 'node:fs'
+import { tmpdir, homedir } from 'node:os'
+import { join, dirname } from 'node:path'
+import { fileURLToPath } from 'node:url'
+
+const root = join(dirname(fileURLToPath(import.meta.url)), '..')
+const { chromium } = await import(process.env.PLAYWRIGHT_MODULE || 'playwright')
+
+function chromePath() {
+ if (process.env.CHROME_PATH) return process.env.CHROME_PATH
+ const base = join(homedir(), '.cache/puppeteer/chrome')
+ if (!existsSync(base)) return undefined
+ const builds = readdirSync(base).sort().reverse()
+ for (const b of builds) {
+ for (const p of [
+ `chrome-mac-arm64/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing`,
+ `chrome-mac-x64/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing`,
+ 'chrome-linux64/chrome', 'chrome-win64/chrome.exe',
+ ]) if (existsSync(join(base, b, p))) return join(base, b, p)
+ }
+ return undefined
+}
+
+let failures = 0
+let checks = 0
+const ok = (cond, msg) => {
+ checks++
+ if (!cond) { failures++; console.log(` FAIL ${msg}`) } else console.log(` ok ${msg}`)
+}
+
+// ---- the package, as shipped ------------------------------------------------
+console.log('\n— the package')
+execFileSync('node', [join(root, 'scripts/pack-webext.mjs')], { stdio: 'pipe' })
+const zips = readdirSync(join(root, 'dist')).filter((f) => /^bento-home-.*\.zip$/.test(f)).sort()
+const zip = join(root, 'dist', zips.at(-1))
+const work = mkdtempSync(join(tmpdir(), 'bento-home-qa-'))
+const ext = join(work, 'ext')
+mkdirSync(ext)
+execFileSync('unzip', ['-q', zip, '-d', ext])
+ok(existsSync(join(ext, 'manifest.json')), `unzipped ${zips.at(-1)}`)
+const shots = join(work, 'screens')
+mkdirSync(shots)
+
+// a document to open: the bridge matches *.bento.html; the runtime gate needs ≥1.0.15
+const docDir = join(work, 'Decks')
+mkdirSync(docDir)
+const docPath = join(docDir, 'QA deck.bento.html')
+writeFileSync(docPath, `<!doctype html><meta charset="utf-8"><title>QA deck</title>
+<script>window.__bentoRuntime = '9.9.9'</script>
+<button id="copy">Save a copy</button><button id="doc">Save</button><pre id="out"></pre>
+<script>
+ const out = (s) => { document.getElementById('out').textContent = s }
+ document.getElementById('copy').onclick = () => window.showSaveFilePicker({ id: 'bento-copy', suggestedName: 'QA deck.bento.html' })
+ .then((h) => out('handle ' + h.name), (e) => out('error ' + e.name))
+ document.getElementById('doc').onclick = () => window.showSaveFilePicker({ id: 'bento-doc', suggestedName: 'QA deck.bento.html' })
+ .then((h) => out('handle ' + h.name), (e) => out('error ' + e.name))
+</script>`)
+const docUrl = 'file://' + docPath.split('/').map(encodeURIComponent).join('/')
+
+// ---- a fresh profile ----------------------------------------------------------
+const ctx = await chromium.launchPersistentContext(join(work, 'profile'), {
+ executablePath: chromePath(),
+ headless: true,
+ args: [`--disable-extensions-except=${ext}`, `--load-extension=${ext}`],
+})
+const errors = []
+ctx.on('weberror', (e) => errors.push(String(e.error())))
+
+console.log('\n— the service worker')
+let [sw] = ctx.serviceWorkers()
+if (!sw) sw = await ctx.waitForEvent('serviceworker', { timeout: 15000 }).catch(() => null)
+ok(!!sw, 'starts')
+const id = sw ? new URL(sw.url()).host : ''
+const swErrors = []
+sw?.on('console', (m) => { if (m.type() === 'error') swErrors.push(m.text()) })
+
+console.log('\n— every extension page')
+const pages = ['src/home.html', 'src/panel.html', 'src/consent.html?doc=x&host=example&model=m&nonce=n',
+ 'src/filegrant.html?path=/Users/you/Decks/QA%20deck.bento.html&token=t', 'src/saveas.html?token=none']
+for (const p of pages) {
+ // pages belong to features; a build without one simply does not ship it
+ if (!existsSync(join(ext, p.split('?')[0]))) { console.log(` info ${p.split('?')[0]} not in this build`); continue }
+ const page = await ctx.newPage()
+ const pageErrors = []
+ page.on('pageerror', (e) => pageErrors.push(e.message))
+ page.on('console', (m) => {
+ // the library PROBES file:// paths to find folders (place.js); a miss is
+ // the expected answer, which Chrome logs as a failed load
+ if (m.type() === 'error' && !(m.location()?.url ?? '').startsWith('file://')) pageErrors.push(`${m.text()} @ ${m.location()?.url ?? ''}`)
+ })
+ await page.goto(`chrome-extension://${id}/${p}`)
+ await page.waitForTimeout(800)
+ const text = await page.evaluate(() => document.body.innerText)
+ const empty = await page.evaluate(() => [...document.querySelectorAll('[data-i18n]')].filter((e) => !e.textContent.trim() && !e.hidden && !e.closest('[hidden]')).map((e) => e.dataset.i18n))
+ const name = p.split('?')[0].split('/').pop()
+ await page.screenshot({ path: join(shots, `${name}.png`), fullPage: true })
+ ok(pageErrors.length === 0, `${name}: no errors${pageErrors.length ? ` — ${pageErrors.slice(0, 2).join(' | ')}` : ''}`)
+ ok(!/__MSG_|\$\d/.test(text) && empty.length === 0, `${name}: every string translated${empty.length ? ` — empty: ${empty.join(', ')}` : ''}`)
+ await page.close()
+}
+
+// THE FRESH-INSTALL STATE (file access OFF) is not reachable here: a
+// command-line-loaded extension starts with it ON, and switching it through
+// chrome://extensions reloads the extension, which Chrome then disables as an
+// unsupported developer extension (measured, Chrome for Testing 154). The
+// onboarding for it stays on the manual list: a store-style install.
+
+console.log('\n— file access on')
+{
+ const page = await ctx.newPage()
+ await page.goto(docUrl)
+ await page.waitForTimeout(800)
+ const ops = await page.evaluate(() => window.__bentoHost?.ops ?? null)
+ ok(Array.isArray(ops), `a document now gets the bridge (ops: ${ops?.join(', ')})`)
+ for (const op of ['claim', 'write', 'backup', 'saveas']) ok(ops?.includes(op), `bridge op ${op}`)
+ if (ops) {
+ // the build under test decides whether these exist; report, never fail
+ for (const op of ['assistant', 'store']) console.log(` info bridge op ${op}: ${ops.includes(op) ? 'present' : 'absent in this build'}`)
+ }
+
+ console.log('\n— save-as, from inside a click')
+ const waitWin = ctx.waitForEvent('page', { timeout: 8000 }).catch(() => null)
+ await page.click('#copy')
+ const win = await waitWin
+ await win?.waitForURL(/saveas\.html/, { timeout: 5000 }).catch(() => {})
+ ok(!!win && /saveas\.html/.test(win.url()), 'Save a copy opens the extension\'s save-as window')
+ if (win) {
+ await win.waitForLoadState()
+ await win.waitForTimeout(600)
+ await win.screenshot({ path: join(shots, 'saveas-window.png') })
+ const title = await win.evaluate(() => document.getElementById('title')?.textContent)
+ ok(title === 'Save a copy', `titled "${title}"`)
+ ok(await win.evaluate(() => document.getElementById('beside').hidden), 'no "Save next to" without a folder grant (the picker is the only way)')
+ await win.click('#cancel')
+ await page.waitForFunction(() => document.getElementById('out').textContent !== '', null, { timeout: 5000 }).catch(() => {})
+ ok((await page.textContent('#out')) === 'error AbortError', 'Cancel reaches the page as AbortError (save.ts: cancelled)')
+ }
+ // outside a click: no window
+ // (the browser's own picker then refuses for want of a gesture; nothing to await)
+ let stray = null
+ const onPage = (p) => { stray = p }
+ ctx.on('page', onPage)
+ const probe = await ctx.newPage()
+ await probe.goto(docUrl)
+ await probe.waitForTimeout(500)
+ // Playwright's evaluate runs AS a user gesture, so the call is made from a
+ // timer after Chrome's transient activation (5s) has run out
+ await probe.evaluate(() => { setTimeout(() => { window.__qaActive = navigator.userActivation.isActive; window.showSaveFilePicker({ id: 'bento-copy', suggestedName: 'x.bento.html' }).catch(() => {}) }, 6000) })
+ await new Promise((r) => setTimeout(r, 8000))
+ ok(await probe.evaluate(() => window.__qaActive === false), 'the page really had no activation when it asked')
+ ctx.off('page', onPage)
+ ok(!stray || !/saveas\.html/.test(stray.url()), 'with no click in progress, no extension window opens')
+ await probe.close().catch(() => {})
+
+ console.log('\n— ⌘S with nothing granted')
+ const waitOffer = ctx.waitForEvent('page', { timeout: 8000 }).catch(() => null)
+ await page.click('#doc')
+ const offer = await waitOffer
+ await offer?.waitForURL(/filegrant\.html/, { timeout: 5000 }).catch(() => {})
+ ok(!!offer && /filegrant\.html/.test(offer.url()), 'opens the one-time offer window')
+ if (offer) {
+ await offer.waitForLoadState()
+ await offer.waitForTimeout(600)
+ await offer.screenshot({ path: join(shots, 'offer-window.png') })
+ ok(/QA deck/.test(await offer.evaluate(() => document.body.innerText)), 'naming the document')
+ await offer.close()
+ }
+ await page.close()
+
+ console.log('\n— the library remembers what was opened')
+ const lib = await ctx.newPage()
+ await lib.goto(`chrome-extension://${id}/src/home.html`)
+ await lib.waitForTimeout(1200)
+ ok(/QA deck/.test(await lib.evaluate(() => document.body.innerText)), 'the opened document is listed')
+ await lib.screenshot({ path: join(shots, 'library.png'), fullPage: true })
+ await lib.close()
+}
+
+ok(swErrors.length === 0, `the service worker logged no errors${swErrors.length ? ` — ${swErrors.slice(0, 2).join(' | ')}` : ''}`)
+ok(errors.length === 0, `no uncaught errors anywhere${errors.length ? ` — ${errors.slice(0, 2).join(' | ')}` : ''}`)
+await ctx.close()
+
+console.log(`\nscreenshots: ${shots}`)
+console.log(`${checks - failures}/${checks} checks passed`)
+process.exit(failures ? 1 : 0)
diff --git a/scripts/test-webext-bridge.ts b/scripts/test-webext-bridge.ts
index 9b9e8c5f..c5ead114 100644
--- a/scripts/test-webext-bridge.ts
+++ b/scripts/test-webext-bridge.ts
@@ -33,13 +33,25 @@ function ok(cond: boolean, msg: string) {
}
/** A window just real enough to load the bridge into. */
-function load(opts: { version?: string; pathname?: string } = {}) {
+function load(opts: { version?: string; pathname?: string; reply?: Record<string, any>; activated?: boolean } = {}) {
const nativeCalls: any[] = []
const posted: any[] = []
+ const listeners: any[] = []
+ // The extension's answers, by op. `saveas` is answered "not a document" by
+ // default — the extension declining — so a copy or an export reaches the
+ // native picker the way it does with no extension at all.
+ const reply = { saveas: { ok: false, reason: 'not a document' }, ...opts.reply }
const win: any = {
+ // a person's click is in progress unless a test says otherwise
+ navigator: { userActivation: { isActive: opts.activated ?? true } },
location: { pathname: opts.pathname ?? '/Users/x/Decks/Q3.bento.html' },
- addEventListener() {},
- postMessage(msg: any) { posted.push(msg) },
+ addEventListener(type: string, f: any) { if (type === 'message') listeners.push(f) },
+ postMessage(msg: any) {
+ posted.push(msg)
+ if (msg?.dir === 'req' && msg.op in reply) {
+ setTimeout(() => { for (const f of listeners) f({ source: win, data: { __bento_tray__: true, dir: 'res', id: msg.id, result: reply[msg.op] } }) }, 0)
+ }
+ },
showSaveFilePicker(o: any) { nativeCalls.push(o); return Promise.resolve({ __native: true }) },
bento: opts.version ? { updates: { version: opts.version } } : undefined,
}
@@ -163,6 +175,36 @@ for (const [version, trusted] of [
ok(nativeCalls.length === 1, 'a copy reaches the native picker')
}
+// ---- "Save a copy…" and exports: the extension's own window ----------------
+// saveas.js. The page asks; the extension's window answers with where the
+// person chose. Chosen → a handle that writes through the extension; cancelled
+// there → cancelled here (no second dialog); declined → the native picker.
+{
+ const { win, nativeCalls, posted } = load({ version: '1.0.15', reply: { saveas: { ok: true, token: 'tok-1', name: 'Q3 copy.bento.html' }, 'saveas.write': { ok: true, name: 'Q3 copy.bento.html', bytes: 5 } } })
+ const h = await win.showSaveFilePicker({ id: 'bento-copy', suggestedName: 'Q3.bento.html' })
+ const ask = posted.find((m) => m.op === 'saveas')
+ ok(nativeCalls.length === 0 && h?.name === 'Q3 copy.bento.html' && ask?.payload?.id === 'bento-copy' && ask?.payload?.name === 'Q3.bento.html', 'a copy the person placed in the extension\'s window returns its handle — no native dialog')
+ const w = await h.createWritable(); await w.write(new Blob(['hello'])); await w.close()
+ const wr = posted.find((m) => m.op === 'saveas.write')
+ ok(wr?.payload?.token === 'tok-1' && wr?.payload?.text === 'hello' && !('path' in (wr?.payload ?? {})), 'its writes carry the token and the bytes — never a path')
+}
+{
+ const { win, nativeCalls } = load({ version: '1.0.15', reply: { saveas: { ok: false, cancelled: true } } })
+ let err: any = null
+ await win.showSaveFilePicker({ id: 'bento-share', suggestedName: 'Q3-view.bento.html' }).catch((e: any) => { err = e })
+ ok(err?.name === 'AbortError' && nativeCalls.length === 0, 'cancelled in the window is AbortError — save.ts\'s "cancelled", and no second dialog')
+}
+{
+ const { win } = load({ version: '1.0.15' })
+ ok((win as any).__bentoHost.ops.includes('saveas'), 'the host announces saveas')
+}
+{
+ const { win, nativeCalls, posted } = load({ version: '1.0.15', activated: false, reply: { saveas: { ok: true, token: 't', name: 'n.bento.html' } } })
+ await win.showSaveFilePicker({ id: 'bento-copy', suggestedName: 'Q3.bento.html' }).catch(() => {})
+ ok(!posted.some((m) => m.op === 'saveas') && nativeCalls.length === 1, 'with no user activation the extension\'s window is never asked for — the browser\'s own picker decides, as it would without us')
+}
+
+
// ---- 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
diff --git a/scripts/test-webext-saveas.ts b/scripts/test-webext-saveas.ts
new file mode 100644
index 00000000..fe4d0c99
--- /dev/null
+++ b/scripts/test-webext-saveas.ts
@@ -0,0 +1,229 @@
+#!/usr/bin/env node
+// SPDX-License-Identifier: MIT
+// Copyright (c) 2026 The Bento authors
+// home/webext "Save a copy…" / export rig.
+//
+// node scripts/test-webext-saveas.ts
+//
+// WHAT THIS PROVES. A copy or an export is answered by the extension's own
+// window, so it can land beside the document instead of in Downloads. The
+// properties: the page supplies a NAME, never a place; a write lands only
+// where the person chose, and only for the document that asked; a beside-name
+// can never be a path or the open document itself; cancelling is cancelling;
+// and no window, no answer, means the browser's own picker. The real
+// saveas.js runs here.
+
+import { readFileSync } from 'node:fs'
+import { join, dirname } from 'node:path'
+import { fileURLToPath } from 'node:url'
+
+const root = join(dirname(fileURLToPath(import.meta.url)), '..')
+const SRC = join(root, 'home/webext/src')
+const sa = await import('../home/webext/src/saveas.js')
+
+let failures = 0
+let checks = 0
+function ok(cond: boolean, msg: string) {
+ checks++
+ if (!cond) { failures++; console.log(` FAIL ${msg}`) }
+ else console.log(` ok ${msg}`)
+}
+
+/** A folder handle with the methods saveas.js uses; files are name → text. */
+function folder(name: string, files: Record<string, string> = {}, perm = 'granted') {
+ const fileHandle = (n: string) => ({
+ name: n, kind: 'file',
+ queryPermission: async () => perm,
+ createWritable: async () => { let buf = ''; return { write: async (t: string) => { buf += t }, close: async () => { files[n] = buf } } },
+ })
+ return {
+ name, kind: 'directory', files,
+ queryPermission: async () => perm,
+ getFileHandle: async (n: string, o: any = {}) => {
+ if (!(n in files) && !o.create) { const e: any = new Error('nf'); e.name = 'NotFoundError'; throw e }
+ return fileHandle(n)
+ },
+ fileHandle,
+ }
+}
+const memdb = () => {
+ const m = new Map<string, any>()
+ return { m, get: async (k: string) => m.get(k) ?? null, put: async (k: string, v: any) => { m.set(k, v) }, del: async (k: string) => { m.delete(k) }, all: async () => [...m.entries()] }
+}
+let clock = Date.UTC(2026, 9, 9)
+let shown = ''
+let n = 0
+const DOC = '/Users/you/Decks/Q3.bento.html'
+const OTHER = '/Users/you/Decks/Other.bento.html'
+
+/** deps whose window "does" what `person` says, by writing the record the way saveas-window.js does. */
+const depsFor = (opts: { dir?: any; person?: (token: string, db: any) => Promise<boolean | null> } = {}) => {
+ const db = memdb()
+ return {
+ db, now: () => clock, token: () => `tok-${++n}`,
+ folderOf: async () => opts.dir ?? null,
+ openWindow: async (token: string) => (opts.person ? opts.person(token, db) : false),
+ }
+}
+
+console.log('\n— names: a suggestion to show, a beside-name to create')
+{
+ ok(sa.besideName('Q3 copy', 'Q3.bento.html').name === 'Q3 copy.bento.html', 'a bare name gets .bento.html, as the browser\'s picker would')
+ ok(sa.besideName('Q3 view.html', 'Q3.bento.html').name === 'Q3 view.bento.html', 'a plain .html becomes .bento.html')
+ for (const bad of ['../x', 'a/b.bento.html', 'a\\b', '', ' ', '..', 'x\u0000y'])
+ ok(!sa.besideName(bad, 'Q3.bento.html').ok, `refused: ${JSON.stringify(bad)}`)
+ ok(sa.besideName('q3.BENTO.html', 'Q3.bento.html').reason === 'is-original', 'the open document\'s own name (any case) is refused')
+ ok(sa.suggestion('../../etc/evil.bento.html', 'Q3.bento.html') === 'evil.bento.html', 'a page\'s suggestion is reduced to a name before it is even shown')
+ ok(sa.suggestion('Q3.bento.html', 'Q3.bento.html') === 'Q3 copy.bento.html', 'suggesting the original name itself falls back to "<name> copy"')
+}
+
+console.log('\n— asking: only copies and exports, only for a document')
+{
+ const d = depsFor()
+ ok((await sa.ask(null, { id: 'bento-copy', name: 'x' }, d)).reason === 'not a document', 'no path (not a top-frame file://) → not a document → the page uses its own picker')
+ for (const id of ['bento-doc', 'bento-backup', 'other', undefined])
+ ok((await sa.ask(DOC, { id, name: 'x' }, d)).reason === 'not a save-as', `${id} is not a save-as (⌘S and backups never come here)`)
+ ok(d.db.m.size === 0, 'and nothing was recorded for any of them')
+}
+
+console.log('\n— beside the document, in one click')
+{
+ const dir = folder('Decks', { 'Q3.bento.html': 'ORIGINAL' })
+ const d = depsFor({ dir, person: async (t, db) => sa.choose(t, { kind: 'beside', name: 'Q3 copy.bento.html' }, db) })
+ const r = await sa.ask(DOC, { id: 'bento-copy', name: 'Q3.bento.html' }, d)
+ ok(r.ok && r.name === 'Q3 copy.bento.html' && typeof r.token === 'string', 'the window\'s choice comes back as a token and a name')
+ const rec = await d.db.get(r.token)
+ ok(rec.path === DOC && rec.purpose === 'copy' && rec.dir === dir, 'the record binds the token to the asking document and its own folder')
+ const w = await sa.write(DOC, { token: r.token, text: 'COPY' }, d)
+ ok(w.ok && dir.files['Q3 copy.bento.html'] === 'COPY' && dir.files['Q3.bento.html'] === 'ORIGINAL', 'the copy lands beside the original; the original is untouched')
+ ok((await sa.write(DOC, { token: r.token, text: 'COPY 2' }, d)).ok && dir.files['Q3 copy.bento.html'] === 'COPY 2', 'and the next save to it (save.ts makes the copy the ⌘S target) writes it again')
+ ok((await sa.write(OTHER, { token: r.token, text: 'EVIL' }, d)).reason === 'not this document\'s save' && dir.files['Q3 copy.bento.html'] === 'COPY 2', 'another document holding the token writes nothing')
+ ok((await sa.write(null, { token: r.token, text: 'EVIL' }, d)).reason === 'not a document', 'a sender with no path (a sub-frame) writes nothing')
+ ok((await sa.write(DOC, { token: 'tok-guess', text: 'x' }, d)).reason === 'no such save', 'an unknown token writes nothing')
+ // a record tampered to name the original is still refused at the write
+ await d.db.put(r.token, { ...rec, choice: { kind: 'beside', name: 'Q3.bento.html' } })
+ ok((await sa.write(DOC, { token: r.token, text: 'CLOBBER' }, d)).reason === 'is-original' && dir.files['Q3.bento.html'] === 'ORIGINAL', 'a beside-write can never replace the open document, even from a bad record')
+ await d.db.put(r.token, { ...rec, choice: { kind: 'beside', name: '../escape.bento.html' } })
+ ok(!(await sa.write(DOC, { token: r.token, text: 'x' }, d)).ok && !('../escape.bento.html' in dir.files), 'nor climb out of the folder')
+}
+{
+ const dir = folder('Decks', {}, 'prompt')
+ const d = depsFor({ dir, person: async (t, db) => sa.choose(t, { kind: 'beside', name: 'X.bento.html' }, db) })
+ const r = await sa.ask(DOC, { id: 'bento-share', name: 'X.bento.html' }, d)
+ ok((await sa.write(DOC, { token: r.token, text: 'x' }, d)).reason === 'folder grant needs renewing' && !('X.bento.html' in dir.files), 'a lapsed folder grant writes nothing and says why')
+}
+
+console.log('\n— a folder the person chose in the picker')
+{
+ const elsewhere = folder('Exports')
+ const picked = elsewhere.fileHandle('Q3-view.bento.html')
+ const d = depsFor({ person: async (t, db) => sa.choose(t, { kind: 'handle', handle: picked, name: picked.name }, db) })
+ const r = await sa.ask(DOC, { id: 'bento-share', name: 'Q3-view.bento.html' }, d)
+ ok(r.ok && r.name === 'Q3-view.bento.html' && (await d.db.get(r.token)).dir === null, 'with no folder grant there is no "beside", only the picker')
+ ok((await sa.write(DOC, { token: r.token, text: 'VIEW' }, d)).ok && elsewhere.files['Q3-view.bento.html'] === 'VIEW', 'the bytes land in the picked file')
+}
+
+console.log('\n— cancelling, and no window at all')
+{
+ const d = depsFor({ dir: folder('Decks'), person: async () => false })
+ const r = await sa.ask(DOC, { id: 'bento-copy', name: 'x' }, d)
+ ok(!r.ok && r.cancelled === true && d.db.m.size === 0, 'closing or cancelling the window is "cancelled" (no native dialog after it), and the record is gone')
+ const d2 = depsFor({ dir: folder('Decks'), person: async () => true })
+ ok((await sa.ask(DOC, { id: 'bento-copy', name: 'x' }, d2)).cancelled === true, 'a window that answered without recording a choice is also cancelled')
+ const d3 = depsFor({ person: async () => null })
+ const r3 = await sa.ask(DOC, { id: 'bento-copy', name: 'x' }, d3)
+ ok(!r3.ok && !r3.cancelled && r3.reason === 'window unavailable', 'a window that could not open is NOT cancelled — the page falls to its own picker')
+}
+
+console.log('\n— names that only look different, and invisible characters')
+{
+ ok(sa.besideName('Cafe\u0301 plan.bento.html', 'Caf\u00e9 plan.bento.html').reason === 'is-original', 'NFD vs NFC of the open document\'s name is the open document (APFS treats them as one file)')
+ for (const c of ['\u202e', '\u200b', '\u200e', '\u2066', '\ufeff'])
+ ok(sa.besideName(`report${c}lmth.bento.html`, 'Q3.bento.html').reason === 'bad-name', `a name carrying U+${c.codePointAt(0)!.toString(16).toUpperCase()} is refused`)
+}
+
+console.log('\n— a page cannot aim the window at an existing file')
+{
+ const dir = folder('Decks', { 'Q3.bento.html': 'ORIGINAL', 'Board.bento.html': 'BOARD', 'Board copy.bento.html': 'B2' })
+ const d = depsFor({ dir, person: async () => false })
+ await sa.ask(DOC, { id: 'bento-share', name: 'Board.bento.html' }, { ...d, openWindow: async (t: string) => { shown = (await d.db.get(t)).name; return false } })
+ ok(shown === 'Board copy 2.bento.html', `a suggestion naming an existing sibling arrives as a fresh name (${shown})`)
+ ok(sa.replaceDecision({ exists: true, edited: false, confirmed: true }) === 'refuse', 'the page\'s suggestion, untouched, is never replaced — even on a second click')
+ ok(sa.replaceDecision({ exists: true, edited: true, confirmed: false }) === 'confirm' && sa.replaceDecision({ exists: true, edited: true, confirmed: true }) === 'replace', 'a name the person typed is replaced only after a warning and a second click')
+ ok(sa.replaceDecision({ exists: false, edited: false, confirmed: false }) === 'ok', 'a free name just saves')
+ // and the write enforces it, whatever the record says
+ const d2 = depsFor({ dir, person: async (t, db) => sa.choose(t, { kind: 'beside', name: 'Board.bento.html' }, db) })
+ const r = await sa.ask(DOC, { id: 'bento-copy', name: 'x' }, d2)
+ ok((await sa.write(DOC, { token: r.token, text: 'EVIL' }, d2)).reason === 'exists' && dir.files['Board.bento.html'] === 'BOARD', 'a beside-write onto an existing file without the person\'s replace choice is refused at the write')
+ const d3 = depsFor({ dir, person: async (t, db) => sa.choose(t, { kind: 'beside', name: 'Board.bento.html', replace: true }, db) })
+ const r3 = await sa.ask(DOC, { id: 'bento-copy', name: 'x' }, d3)
+ ok((await sa.write(DOC, { token: r3.token, text: 'CHOSEN' }, d3)).ok && dir.files['Board.bento.html'] === 'CHOSEN', 'with it, the file is replaced')
+}
+{
+ // compared as FILES: a name the string check cannot see is still the open document
+ const dir = folder('Decks', { 'Cafe\u0301.bento.html': 'ORIGINAL' })
+ const docH = { isSameEntry: async () => true }
+ const there = await dir.getFileHandle('Cafe\u0301.bento.html')
+ ;(dir as any).getFileHandle = async (n: string, o: any = {}) => { const h: any = await (folder('x', dir.files) as any).getFileHandle(n, o); h.isSameEntry = async (x: any) => x === docH; return h }
+ const d = { ...depsFor({ dir, person: async (t: string, db: any) => sa.choose(t, { kind: 'beside', name: 'Other.bento.html', replace: true }, db) }), docHandle: async () => docH }
+ const r = await sa.ask('/Users/you/Decks/Odd.bento.html', { id: 'bento-copy', name: 'x' }, d)
+ const rec = await d.db.get(r.token)
+ await d.db.put(r.token, { ...rec, choice: { kind: 'beside', name: 'Cafe\u0301.bento.html', replace: true } })
+ ok((await sa.write('/Users/you/Decks/Odd.bento.html', { token: r.token, text: 'CLOBBER' }, d)).reason === 'is-original' && dir.files['Cafe\u0301.bento.html'] === 'ORIGINAL', 'a target that isSameEntry with the open document is refused, even with a replace choice')
+ void there
+}
+
+console.log('\n— lifetimes: an export is written once; a document\'s saves end with it')
+{
+ const dir = folder('Decks', { 'Q3.bento.html': 'ORIGINAL' })
+ const d = depsFor({ dir, person: async (t, db) => sa.choose(t, { kind: 'beside', name: 'Q3 view.bento.html' }, db) })
+ const r = await sa.ask(DOC, { id: 'bento-share', name: 'Q3 view.bento.html' }, d)
+ ok((await sa.write(DOC, { token: r.token, text: 'VIEW' }, d)).ok, 'an export writes')
+ ok((await sa.write(DOC, { token: r.token, text: 'FULL DOC' }, d)).reason === 'no such save' && dir.files['Q3 view.bento.html'] === 'VIEW', 'and its token is spent: nothing can later overwrite the view-only copy through it')
+ const dc = depsFor({ dir, person: async (t, db) => sa.choose(t, { kind: 'beside', name: 'Q3 copy.bento.html' }, db) })
+ const rc = await sa.ask(DOC, { id: 'bento-copy', name: 'x' }, dc)
+ await sa.write(DOC, { token: rc.token, text: 'C1' }, dc)
+ await sa.drop(OTHER, { token: rc.token }, dc)
+ ok(dc.db.m.has(rc.token), 'another document cannot drop this one\'s save')
+ await sa.drop(DOC, { token: rc.token }, dc)
+ ok(!dc.db.m.has(rc.token), 'the document unloading drops its save')
+}
+
+console.log('\n— one window per document')
+{
+ const open = new Set<string>()
+ let windows = 0
+ let release: any
+ const d = { ...depsFor(), busy: (p: string) => open.has(p), openWindow: (_t: string, p: string) => { windows++; open.add(p); return new Promise((r) => { release = () => { open.delete(p); r(false) } }) } }
+ const first = sa.ask(DOC, { id: 'bento-copy', name: 'x' }, d)
+ await new Promise((r) => setTimeout(r, 0))
+ const second: any = await Promise.race([sa.ask(DOC, { id: 'bento-share', name: 'y' }, d), new Promise((r) => setTimeout(() => r({ hung: true }), 200))])
+ ok(second.cancelled === true && windows === 1, 'a second ask from the same document while its window is open opens nothing')
+ const other = sa.ask(OTHER, { id: 'bento-copy', name: 'z' }, { ...d, openWindow: async () => { windows++; return false } })
+ await other
+ ok(windows === 2, 'another document still gets its own')
+ release(); await Promise.race([first, new Promise((r) => setTimeout(r, 200))])
+}
+
+console.log('\n— the sweep')
+{
+ const d = depsFor()
+ await d.db.put('old', { path: DOC, at: clock - sa.KEEP_MS - 1 })
+ await d.db.put('new', { path: DOC, at: clock })
+ await sa.gc(d)
+ ok(!d.db.m.has('old') && d.db.m.has('new'), `records older than ${sa.KEEP_MS / 3600000}h are swept, fresh ones kept`)
+}
+
+console.log('\n— the wiring')
+{
+ const bg = readFileSync(join(SRC, 'background.js'), 'utf8')
+ ok(/op === 'saveas' \? saveas\.ask\(topPath\(sender\)/.test(bg) && /op === 'saveas\.write' \? saveas\.write\(topPath\(sender\)/.test(bg), 'the worker passes only the sender\'s own top-frame path')
+ ok(/const topPath = \(sender\) => \(sender\?\.frameId === 0 \? pathFromSender\(sender\) : null\)/.test(bg), 'topPath is top frame only')
+ ok(/function saveasAnswered[\s\S]{0,120}isSaveasWindow\(sender\)/.test(bg), 'only the save-as window may answer')
+ const win = readFileSync(join(SRC, 'saveas-window.js'), 'utf8')
+ ok(/showSaveFilePicker\(\{[\s\S]{0,80}startIn,/.test(win) && /startIn = rec\.dir \?\? await startInFor\(rec\.path\)/.test(win), 'the picker opens in the document\'s folder, or the nearest one held')
+ ok(/replaceDecision\(\{ exists, edited: edited\(\), confirmed: confirmReplace === name \}\)/.test(win) && /kind: 'beside', name, replace: d === 'replace'/.test(win), 'the window decides with replaceDecision and records the person\'s replace choice (enforced again at write time, below)')
+}
+
+console.log(`\n${checks - failures}/${checks} checks passed`)
+process.exit(failures ? 1 : 0)