theseus/js-dialog-preload.js
Local Dev 70934a7553 feat(theseus): Theseus's own prompts use the dialog sheet too
Install-this-app, remove-app, the extension install flow (install,
already installed, installed, not found, failed) and the add-on restart
question were still bare OS message boxes titled "theseus-navigator"
after page dialogs moved to the sheet. askSheet() is a drop-in for
dialog.showMessageBox with the same options and result: title as the
headline, detail under it, the caller's buttons with the default first,
an optional checkbox, and the app's or extension's icon when there is
one. Tone follows the box type (error, warning) or the wording. The
native box stays as the fallback when the browser window is not there,
and for the two synchronous cases (beforeunload, app windows).
2026-09-27 20:13:06 +02:00

9 lines
679 B
JavaScript

// Preload for the page-dialog overlay (js-dialog.html): the Theseus-drawn
// replacement for a page's alert / confirm / prompt. Main pushes one request
// at a time via `jsdialog-show`; the page answers with `jsdialog-answer`.
const { contextBridge, ipcRenderer } = require("electron");
contextBridge.exposeInMainWorld("jsdialog", {
onShow: (cb) => ipcRenderer.on("jsdialog-show", (_e, req) => cb(req)),
// value: a string for prompt(); { response, checkboxChecked } for one of Theseus's own prompts.
answer: (reqId, ok, value) => ipcRenderer.invoke("jsdialog-answer", reqId, !!ok, value == null ? null : (typeof value === "object" ? value : String(value))),
});