Internals

Dialog provider

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

Archive · OWD 3.x for Nuxt. This page describes the previous Nuxt integration. For OWD 4.x, see the current Nuxt guide.

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-nuxt-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.ts — DesktopDialogProvider:
    • 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-nuxt-primevue)

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

  1. Registers @primevue/nuxt-module
  2. Runs a client plugin that **provide**s createDesktopDialogs(useConfirm())
await installModule('@owdproject/kit-nuxt-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-nuxt-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-nuxt-primevue.