@domicile-desktop/sdk 0.0.0-alpha-e65a671664c9 → 0.0.0-alpha-72766efee05a

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -243,6 +243,26 @@ export declare const WEBVIEW_DEVICE_REQUEST_CHANGE_EVENT = "domicile-device-requ
243
243
  * page navigated. Answering it afterward throws. Carries no payload. Bubbles.
244
244
  */
245
245
  export declare const WEBVIEW_DEVICE_REQUEST_WITHDRAWN_EVENT = "domicile-device-request-withdrawn";
246
+ /**
247
+ * Fired when the page calls `alert()`, `confirm()` or `prompt()`. The page is
248
+ * paused until it is answered. Bubbles.
249
+ *
250
+ * The browser draws no dialog. Call `preventDefault()` to handle it, then
251
+ * answer with {@link DomicileDialogEvent.accept} or
252
+ * {@link DomicileDialogEvent.dismiss}. If no listener calls `preventDefault()`,
253
+ * the dialog is dismissed: `confirm()` returns false and `prompt()` null. One
254
+ * dialog is open at a time.
255
+ */
256
+ export declare const WEBVIEW_DIALOG_EVENT = "domicile-dialog";
257
+ /**
258
+ * Fired when the browser drops the open {@link WEBVIEW_DIALOG_EVENT}
259
+ * unanswered, for example because the page navigated or closed. Answering it
260
+ * afterward throws. Carries no payload. Bubbles.
261
+ */
262
+ export declare const WEBVIEW_DIALOG_WITHDRAWN_EVENT = "domicile-dialog-withdrawn";
263
+ /** The dialogs a page can open, as {@link DomicileDialogEvent.dialogType}. */
264
+ export declare const WEBVIEW_DIALOG_TYPES: readonly ["alert", "confirm", "prompt"];
265
+ export type WebViewDialogType = (typeof WEBVIEW_DIALOG_TYPES)[number];
246
266
  /** A site's stored choice for a permission. `ask` prompts the shell. */
247
267
  export declare const WEBVIEW_PERMISSION_SETTINGS: readonly ["ask", "allow", "block"];
248
268
  export type WebViewPermissionSetting = (typeof WEBVIEW_PERMISSION_SETTINGS)[number];
@@ -503,6 +523,34 @@ declare global {
503
523
  /** Give the page no device. */
504
524
  cancel(): void;
505
525
  }
526
+ /**
527
+ * The {@link WEBVIEW_DIALOG_EVENT} event. The engine defines it in
528
+ * `domicile_dialog_event.idl`.
529
+ */
530
+ interface DomicileDialogEvent extends Event {
531
+ /**
532
+ * One of {@link WEBVIEW_DIALOG_TYPES}. External data; parse it at the
533
+ * boundary.
534
+ */
535
+ readonly dialogType: string;
536
+ /**
537
+ * The calling frame's site, such as `https://example.com`, or `null` for
538
+ * one with no site.
539
+ */
540
+ readonly origin: string;
541
+ /** The text the page passed. */
542
+ readonly message: string;
543
+ /** `prompt()`'s initial text. Empty for the others. */
544
+ readonly defaultValue: string;
545
+ /**
546
+ * OK. `value` is what `prompt()` returns; the others ignore it. Answering
547
+ * twice, or after {@link WEBVIEW_DIALOG_WITHDRAWN_EVENT}, throws an
548
+ * `InvalidStateError`.
549
+ */
550
+ accept(value?: string): void;
551
+ /** Cancel. An alert has only OK; either closes it. */
552
+ dismiss(): void;
553
+ }
506
554
  /**
507
555
  * Types `addEventListener` for the events that carry data. Merged into
508
556
  * `HTMLElementEventMap` because `HTMLWebViewElement` has no event map of its
@@ -514,5 +562,6 @@ declare global {
514
562
  "domicile-context-menu": DomicileContextMenuEvent;
515
563
  "domicile-permission-request": DomicilePermissionRequestEvent;
516
564
  "domicile-device-request": DomicileDeviceRequestEvent;
565
+ "domicile-dialog": DomicileDialogEvent;
517
566
  }
518
567
  }
@@ -284,5 +284,24 @@ export const WEBVIEW_DEVICE_REQUEST_CHANGE_EVENT = "domicile-device-request-chan
284
284
  * page navigated. Answering it afterward throws. Carries no payload. Bubbles.
285
285
  */
286
286
  export const WEBVIEW_DEVICE_REQUEST_WITHDRAWN_EVENT = "domicile-device-request-withdrawn";
287
+ /**
288
+ * Fired when the page calls `alert()`, `confirm()` or `prompt()`. The page is
289
+ * paused until it is answered. Bubbles.
290
+ *
291
+ * The browser draws no dialog. Call `preventDefault()` to handle it, then
292
+ * answer with {@link DomicileDialogEvent.accept} or
293
+ * {@link DomicileDialogEvent.dismiss}. If no listener calls `preventDefault()`,
294
+ * the dialog is dismissed: `confirm()` returns false and `prompt()` null. One
295
+ * dialog is open at a time.
296
+ */
297
+ export const WEBVIEW_DIALOG_EVENT = "domicile-dialog";
298
+ /**
299
+ * Fired when the browser drops the open {@link WEBVIEW_DIALOG_EVENT}
300
+ * unanswered, for example because the page navigated or closed. Answering it
301
+ * afterward throws. Carries no payload. Bubbles.
302
+ */
303
+ export const WEBVIEW_DIALOG_WITHDRAWN_EVENT = "domicile-dialog-withdrawn";
304
+ /** The dialogs a page can open, as {@link DomicileDialogEvent.dialogType}. */
305
+ export const WEBVIEW_DIALOG_TYPES = ["alert", "confirm", "prompt"];
287
306
  /** A site's stored choice for a permission. `ask` prompts the shell. */
288
307
  export const WEBVIEW_PERMISSION_SETTINGS = ["ask", "allow", "block"];
package/package.json CHANGED
@@ -120,7 +120,7 @@
120
120
  "test:unit": "bun test"
121
121
  },
122
122
  "type": "module",
123
- "version": "0.0.0-alpha-e65a671664c9",
123
+ "version": "0.0.0-alpha-72766efee05a",
124
124
  "repository": {
125
125
  "type": "git",
126
126
  "url": "git+https://github.com/cprussin/domicile.git",