Internals

Dialog provider

Shared alert, confirm, and prompt API in core; PrimeVue implementation in kit-primevue.

OWD standardizes how code asks for user confirmation or input, not which widget library renders it. Themes keep their own look (Win95, Win11, GNOME, Nova, …); shared code (module-fs, apps) calls a small provider instead of hard-coding window.confirm or PrimeVue.

Contract (core)

The interface lives in @owdproject/core:

  • packages/core/runtime/dialogs/desktopDialogProvider.tsDesktopDialogProvider:
    • confirm(options)Promise<boolean>
    • alert(message, options?)Promise<void>
    • prompt(message, defaultValue?)Promise<string | null>
  • Injection key: DESKTOP_DIALOG_PROVIDER_KEY

Using the API

import { useDesktopDialogs } from '@owdproject/core/runtime/composables/useDesktopDialogs'

const dialogs = useDesktopDialogs()
const ok = await dialogs.confirm({
  title: 'Delete items',
  message: 'Send 3 items to the Recycle Bin?',
  acceptLabel: 'Yes',
  rejectLabel: 'No',
})

Pass already translated strings from vue-i18n. Optional extras on confirm carries theme-specific payloads (e.g. Win95 delete dialog { toTrash: boolean }).

Fallback

If no theme provider is registered, useDesktopDialogs falls back to window.confirm / alert / prompt. On the server, confirm resolves to false and prompt to null.

PrimeVue implementation (kit-primevue)

Demo themes install @owdproject/kit-primevue, which:

  1. Registers @primevue/nuxt-module
  2. Runs a client plugin that **provide**s createDesktopDialogs(useConfirm())
await installModule('@owdproject/kit-primevue')

Themes mount <ConfirmDialog /> groups (delete, about, …) with their own templates/CSS.

Explicit imports (optional):

import { DESKTOP_DIALOG_PROVIDER_KEY } from '@owdproject/core/runtime/constants/desktopShellKeys'
import { createDesktopDialogs } from '@owdproject/kit-primevue/runtime/dialogs/createDesktopDialogs'

Custom PV themes can replace the plugin and still implement DesktopDialogProvider.

Non-PrimeVue themes

Implement DesktopDialogProvider (Vuetify, Nuxt UI, native <dialog>, …) and provide it on DESKTOP_DIALOG_PROVIDER_KEY in a client plugin. Do not require kit-primevue.