Client & CLI

Migrate themes, apps, and modules (3.3.2)

Agent-oriented checklist to adopt defineDesktopModule, defineDesktopTheme, desktop.config merge, and runtime composables.

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

Use this page when updating @owdproject/* themes, apps, or extension modules after @owdproject/core 3.3.2. It supersedes patterns from 3.3.0 (splitDesktopUserConfig, manual defu on public.desktop, appConfig.terminal, unknown-key warnings).

References in this monorepo: @owdproject/module-nuxt-fs (defineDesktopModule, types/desktop.d.ts), app-nuxt-terminal (same; apps live under /apps locally and may be gitignored).


Agent quick checklist

Run these greps on the package you migrate:

# Legacy patterns to remove or replace
rg "defineNuxtModule" src/module.ts
rg "splitDesktopUserConfig|DESKTOP_RUNTIME_KEYS|unknown desktop key" .
rg "runtimeConfig\.public\.desktop\.\w+\s*=" src/module.ts
rg "defu\(.*desktop" src/module.ts
rg "appConfig\.(terminal|fs|desktop\.\w+)" .
rg "from '@owdproject/core'" src/module.ts   # prefer subpath for defineDesktopModule

# After migration
rg "defineDesktopModule|defineDesktopTheme" src/module.ts
StepAction
1Bump peerDependencies['@owdproject/core'] to ^3.3.2 (or workspace:* in monorepo).
2module.ts: extension module or app with configKey → defineDesktopModule; theme → defineDesktopTheme.
3Remove manual public.desktop[configKey] = … / defu in module.ts (handled by core).
4Add types/desktop.d.ts with declare module 'nuxt/schema' { interface DesktopConfig { … } }.
5Vue/runtime: read config from useRuntimeConfig().public.desktop.<key> or useDesktopExtension('key') (auto-import), not appConfig.<key>.
6Keep runtime/plugin.ts → defineDesktopApp unchanged (apps only).
7module.ts imports: defineDesktopModule from @owdproject/core/runtime/utils/defineDesktopModule (not main barrel).
8Run pnpm exec nuxt-module-build build --stub in package, then nuxt prepare in playground/desktop.

What changed in core (mental model)

Before (3.3.0)After (3.3.2)
splitDesktopUserConfig split install vs runtime keysFull desktop.config → runtimeConfig.public.desktop (+ coreVersion)
Warnings on fs, terminal, custom keysWarnings only on Nuxt-like keys (ssr, vite, …)
Each package hand-merged defu on public.desktop.fsdefineDesktopModule + installDesktopPackage pass desktop[configKey] into Nuxt
Themes hand-defu(public.desktop, options)Prefer defineDesktopTheme (same defu semantics)
Some apps wrote appConfig.terminalSingle namespace: public.desktop.terminal

defineDesktopApp is unchanged: it registers the program in the shell (windows, entries, commands). defineDesktopModule only wraps the Nuxt module layer.


Extension modules (@owdproject/module-*)

When: package has meta.configKey (e.g. fs, persistence) and is listed under modules: in desktop.config.ts.

Before

import { defineNuxtModule } from '@nuxt/kit'
import { defu } from 'defu'

export default defineNuxtModule({
  meta: { name: 'owd-module-fs', configKey: 'fs' },
  defaults: { mounts: { '/home': 'WebStorage' } },
  async setup(options, nuxt) {
    nuxt.options.runtimeConfig.public.desktop ??= {}
    nuxt.options.runtimeConfig.public.desktop.fs = defu(
      nuxt.options.runtimeConfig.public.desktop.fs ?? {},
      options,
    )
    // …plugins, transpile, etc.
  },
})

After

import { addPlugin, createResolver } from '@nuxt/kit'
import { defineDesktopModule } from '@owdproject/core/kit/authoring'

export default defineDesktopModule({
  meta: { name: 'owd-module-fs', configKey: 'fs' },
  defaults: { mounts: { '/home': 'WebStorage' } },
  async setup(_options, nuxt) {
    const { resolve } = createResolver(import.meta.url)
    // merged config already on public.desktop.fs — do not assign again
    addPlugin({ src: resolve('./runtime/plugin'), mode: 'client' })
  },
})

Types — types/desktop.d.ts

declare module 'nuxt/schema' {
  interface DesktopConfig {
    fs?: {
      mounts?: Record<string, string>
      // …shape of your defaults + user overrides
    }
  }
}
export {}

Ensure package.json includes types/desktop.d.ts in files / TypeScript include.

Runtime consumers

// Preferred (auto-imported in apps that use @owdproject/core)
const fsConfig = useDesktopExtension('fs')

// Or explicit
const { public: { desktop } } = useRuntimeConfig()

Optional guards:

if (hasDesktopModule('@owdproject/module-nuxt-fs').value) { … }

Desktop apps (@owdproject/app-*)

Apps are two layers:

LayerAPIFile
Nuxt module (components, Tailwind, optional configKey)defineDesktopModulesrc/module.ts
Desktop program registrationdefineDesktopAppsrc/runtime/plugin.ts

App with consumer config (configKey: 'terminal')

Same migration as extension modules for module.ts. Do not remove defineDesktopApp from plugin.ts.

// src/runtime/plugin.ts — unchanged pattern
import { defineNuxtPlugin } from 'nuxt/app'
import { defineDesktopApp } from '@owdproject/core/runtime/utils/utilDesktop'
import config from './app.config'

export default defineNuxtPlugin({
  name: 'owd-app-terminal-register',
  async setup() {
    if (import.meta.server) return
    await defineDesktopApp(config)
  },
})

App without configKey

If the app only registers UI and has no desktop.config namespace, you may keep defineNuxtModule — no defineDesktopModule required. Most published apps with settings use a configKey.

Vue components

<script setup lang="ts">
const runtimeConfig = useRuntimeConfig()
const terminal = computed(() => runtimeConfig.public.desktop.terminal)
</script>

<template>
  <Terminal :prompt="terminal?.prompt" :welcomeMessage="terminal?.welcomeMessage" />
</template>

Do not read appConfig.terminal or appConfig.desktop.terminal for bootstrap config (legacy).


Themes (@owdproject/theme-*)

When: package is theme: in desktop.config.ts; shell defaults (systemBar, workspaces, name, …).

Before (manual defu)

import { defineNuxtModule } from '@nuxt/kit'
import { defu } from 'defu'

export default defineNuxtModule({
  meta: { name: 'owd-theme-paper', configKey: 'desktop' },
  defaults: { name: 'paper', systemBar: { enabled: true } },
  async setup(options, nuxt) {
    nuxt.options.runtimeConfig.public ??= {}
    nuxt.options.runtimeConfig.public.desktop = defu(
      nuxt.options.runtimeConfig.public.desktop ?? {},
      options,
    )
    // addComponentsDir, registerTailwindPath, …
  },
})

After

import { createResolver, addComponentsDir } from '@nuxt/kit'
import { defineDesktopTheme } from '@owdproject/core/kit/authoring'
import { registerTailwindPath } from '@owdproject/core'

export default defineDesktopTheme({
  meta: { name: 'owd-theme-paper' },
  defaults: { name: 'paper', systemBar: { enabled: true } },
  async setup(_options, nuxt) {
    const { resolve } = createResolver(import.meta.url)
    addComponentsDir({ path: resolve('./runtime/components'), global: true })
    registerTailwindPath(nuxt, resolve('./runtime/components/**/*.{vue,mjs,ts}'))
  },
})

Semantics: user desktop.config.ts wins; theme defaults fill undefined only (same as before).

Conditional features in theme Vue

const hasFs = hasDesktopModule('@owdproject/module-nuxt-fs')
const fs = useDesktopExtension('fs')

Use in templates with .value on computed refs.

Kit-only modules

@owdproject/kit-theme, kit-fs, kit-explorer are plain Nuxt modules (no desktop.config namespace). No migration to defineDesktopTheme unless they start owning shell defaults.


desktop.config.ts (consumer project)

No structural change required; extension keys are first-class:

import { defineDesktopConfig } from '@owdproject/core'

export default defineDesktopConfig({
  theme: '@owdproject/theme-nuxt-nova',
  modules: ['@owdproject/module-nuxt-fs'],
  apps: ['@owdproject/app-nuxt-terminal'],
  terminal: { prompt: 'my$ ' },
  fs: { mounts: { '/home': 'WebStorage' } },
})

Import only defineDesktopConfig (and similar) from @owdproject/core main entry — not composables (see pitfalls).


Imports and exports

SymbolImport from
defineDesktopConfig, defineDesktopApp, registerTailwindPath@owdproject/core
defineDesktopModule@owdproject/core/kit/authoring
defineDesktopTheme@owdproject/core/kit/authoring
useDesktopConfig, useDesktopExtension, hasDesktop*Auto-import in Nuxt apps with core (do not add to package module.ts barrel)

Why: the main @owdproject/core entry must stay loadable from desktop.config.ts via jiti without Nuxt aliases (#imports).


Pitfalls

SymptomCauseFix
Cannot find module '#imports' during nuxt prepare / postinstallComposables exported from @owdproject/core root and pulled in by desktop.config.tsImport composables only via auto-import in Vue; keep them off index.ts
Cannot load module / stub build fails for appmodule.ts imports full @owdproject/core barrelUse subpath for defineDesktopModule
User desktop.config ignored for terminalmodule.ts assigns public.desktop.terminal = options without mergeUse defineDesktopModule; remove manual assign
hasDesktopModule always falseWrong package stringUse exact npm name: '@owdproject/module-nuxt-fs'
Types missing for desktop.fsNo augmentation fileAdd types/desktop.d.ts in extension package

Verify migration

# In the package directory
pnpm exec nuxt-module-build build --stub

# In playground or client/desktop
pnpm exec nuxt prepare
pnpm dev
  • No console warnings for valid keys fs, terminal, custom namespaces.
  • runtimeConfig.public.desktop.modules / .apps populated when set in config.
  • Playground / desktop validate passes.