@owdproject/nuxt 0.0.0-stage → 4.0.0-alpha.3

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.
Files changed (169) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +77 -2
  3. package/dist/kit/authoring.d.ts +96 -0
  4. package/dist/kit/authoring.js +260 -0
  5. package/dist/kit/defineDesktopApp.d.ts +1 -0
  6. package/dist/kit/defineDesktopApp.js +1 -0
  7. package/dist/kit/defineDesktopPlugin.d.ts +1 -0
  8. package/dist/kit/defineDesktopPlugin.js +1 -0
  9. package/dist/module.d.mts +239 -0
  10. package/dist/module.json +12 -0
  11. package/dist/module.mjs +681 -0
  12. package/dist/runtime/components/Application/DesktopCoreApplicationRender.d.vue.ts +6 -0
  13. package/dist/runtime/components/Application/DesktopCoreApplicationRender.vue +18 -0
  14. package/dist/runtime/components/Application/DesktopCoreApplicationRender.vue.d.ts +6 -0
  15. package/dist/runtime/components/Application/DesktopCoreApplicationWindowsRender.d.vue.ts +9 -0
  16. package/dist/runtime/components/Application/DesktopCoreApplicationWindowsRender.vue +31 -0
  17. package/dist/runtime/components/Application/DesktopCoreApplicationWindowsRender.vue.d.ts +9 -0
  18. package/dist/runtime/components/DesktopCore.d.vue.ts +19 -0
  19. package/dist/runtime/components/DesktopCore.vue +37 -0
  20. package/dist/runtime/components/DesktopCore.vue.d.ts +19 -0
  21. package/dist/runtime/components/background/DesktopCoreBackground.d.vue.ts +13 -0
  22. package/dist/runtime/components/background/DesktopCoreBackground.vue +16 -0
  23. package/dist/runtime/components/background/DesktopCoreBackground.vue.d.ts +13 -0
  24. package/dist/runtime/components/time/DesktopCoreTime.d.vue.ts +3 -0
  25. package/dist/runtime/components/time/DesktopCoreTime.vue +44 -0
  26. package/dist/runtime/components/time/DesktopCoreTime.vue.d.ts +3 -0
  27. package/dist/runtime/components/window/DesktopCoreWindow.d.vue.ts +49 -0
  28. package/dist/runtime/components/window/DesktopCoreWindow.vue +403 -0
  29. package/dist/runtime/components/window/DesktopCoreWindow.vue.d.ts +49 -0
  30. package/dist/runtime/components/window/DesktopCoreWindowContent.d.vue.ts +13 -0
  31. package/dist/runtime/components/window/DesktopCoreWindowContent.vue +34 -0
  32. package/dist/runtime/components/window/DesktopCoreWindowContent.vue.d.ts +13 -0
  33. package/dist/runtime/components/window/DesktopCoreWindowNav.d.vue.ts +13 -0
  34. package/dist/runtime/components/window/DesktopCoreWindowNav.vue +54 -0
  35. package/dist/runtime/components/window/DesktopCoreWindowNav.vue.d.ts +13 -0
  36. package/dist/runtime/components/window/DesktopCoreWindowSnapHintsBase.d.vue.ts +19 -0
  37. package/dist/runtime/components/window/DesktopCoreWindowSnapHintsBase.vue +46 -0
  38. package/dist/runtime/components/window/DesktopCoreWindowSnapHintsBase.vue.d.ts +19 -0
  39. package/dist/runtime/components/workspace/DesktopCoreWorkspaceEdgeHintsBase.d.vue.ts +24 -0
  40. package/dist/runtime/components/workspace/DesktopCoreWorkspaceEdgeHintsBase.vue +50 -0
  41. package/dist/runtime/components/workspace/DesktopCoreWorkspaceEdgeHintsBase.vue.d.ts +24 -0
  42. package/dist/runtime/composables/application/state.d.ts +1 -0
  43. package/dist/runtime/composables/application/state.js +2 -0
  44. package/dist/runtime/composables/application/useDesktopApplicationDefine.d.ts +4 -0
  45. package/dist/runtime/composables/application/useDesktopApplicationDefine.js +36 -0
  46. package/dist/runtime/composables/application/useDesktopApplicationExec.d.ts +3 -0
  47. package/dist/runtime/composables/application/useDesktopApplicationExec.js +26 -0
  48. package/dist/runtime/composables/application/useDesktopApplicationProcess.d.ts +24 -0
  49. package/dist/runtime/composables/application/useDesktopApplicationProcess.js +140 -0
  50. package/dist/runtime/composables/application/useDesktopApplicationRegistry.d.ts +11 -0
  51. package/dist/runtime/composables/application/useDesktopApplicationRegistry.js +60 -0
  52. package/dist/runtime/composables/useApplicationEntries.d.ts +5 -0
  53. package/dist/runtime/composables/useApplicationEntries.js +10 -0
  54. package/dist/runtime/composables/useApplicationManager.d.ts +16 -0
  55. package/dist/runtime/composables/useApplicationManager.js +30 -0
  56. package/dist/runtime/composables/useBlockNonInputContextMenu.d.ts +5 -0
  57. package/dist/runtime/composables/useBlockNonInputContextMenu.js +19 -0
  58. package/dist/runtime/composables/useDesktop.d.ts +210 -0
  59. package/dist/runtime/composables/useDesktop.js +52 -0
  60. package/dist/runtime/composables/useDesktopApplication.d.ts +34 -0
  61. package/dist/runtime/composables/useDesktopApplication.js +17 -0
  62. package/dist/runtime/composables/useDesktopCommands.d.ts +12 -0
  63. package/dist/runtime/composables/useDesktopCommands.js +348 -0
  64. package/dist/runtime/composables/useDesktopConfig.d.ts +3 -0
  65. package/dist/runtime/composables/useDesktopConfig.js +10 -0
  66. package/dist/runtime/composables/useDesktopDefaultApps.d.ts +15 -0
  67. package/dist/runtime/composables/useDesktopDefaultApps.js +21 -0
  68. package/dist/runtime/composables/useDesktopDialogs.d.ts +5 -0
  69. package/dist/runtime/composables/useDesktopDialogs.js +8 -0
  70. package/dist/runtime/composables/useDesktopDrag.d.ts +1 -0
  71. package/dist/runtime/composables/useDesktopDrag.js +1 -0
  72. package/dist/runtime/composables/useDesktopHooks.d.ts +15 -0
  73. package/dist/runtime/composables/useDesktopHooks.js +12 -0
  74. package/dist/runtime/composables/useDesktopIPC.d.ts +35 -0
  75. package/dist/runtime/composables/useDesktopIPC.js +72 -0
  76. package/dist/runtime/composables/useDesktopIdentity.d.ts +22 -0
  77. package/dist/runtime/composables/useDesktopIdentity.js +65 -0
  78. package/dist/runtime/composables/useDesktopManifest.d.ts +6 -0
  79. package/dist/runtime/composables/useDesktopManifest.js +17 -0
  80. package/dist/runtime/composables/useDesktopNotification.d.ts +13 -0
  81. package/dist/runtime/composables/useDesktopNotification.js +13 -0
  82. package/dist/runtime/composables/useDesktopResize.d.ts +1 -0
  83. package/dist/runtime/composables/useDesktopResize.js +1 -0
  84. package/dist/runtime/composables/useDesktopSession.d.ts +4 -0
  85. package/dist/runtime/composables/useDesktopSession.js +17 -0
  86. package/dist/runtime/composables/useDesktopShellIdentity.d.ts +1 -0
  87. package/dist/runtime/composables/useDesktopShellIdentity.js +3 -0
  88. package/dist/runtime/composables/useDesktopShellOptions.d.ts +5 -0
  89. package/dist/runtime/composables/useDesktopShellOptions.js +18 -0
  90. package/dist/runtime/composables/useDesktopTray.d.ts +5 -0
  91. package/dist/runtime/composables/useDesktopTray.js +10 -0
  92. package/dist/runtime/composables/useDesktopVolume.d.ts +4 -0
  93. package/dist/runtime/composables/useDesktopVolume.js +9 -0
  94. package/dist/runtime/composables/useDesktopWorkArea.d.ts +1 -0
  95. package/dist/runtime/composables/useDesktopWorkArea.js +3 -0
  96. package/dist/runtime/composables/useDesktopWorkarea.d.ts +12 -0
  97. package/dist/runtime/composables/useDesktopWorkarea.js +72 -0
  98. package/dist/runtime/composables/useTerminalManager.d.ts +15 -0
  99. package/dist/runtime/composables/useTerminalManager.js +9 -0
  100. package/dist/runtime/composables/useToggleWindowMaximize.d.ts +1 -0
  101. package/dist/runtime/composables/useToggleWindowMaximize.js +12 -0
  102. package/dist/runtime/composables/useWindowDragHandlers.d.ts +7 -0
  103. package/dist/runtime/composables/useWindowDragHandlers.js +7 -0
  104. package/dist/runtime/composables/window/useDesktopWindow.d.ts +14 -0
  105. package/dist/runtime/composables/window/useDesktopWindow.js +192 -0
  106. package/dist/runtime/composables/window/useDesktopWindowSnapDrop.d.ts +13 -0
  107. package/dist/runtime/composables/window/useDesktopWindowSnapDrop.js +78 -0
  108. package/dist/runtime/composables/workspace/useDesktopWorkspaceEdgeDrop.d.ts +25 -0
  109. package/dist/runtime/composables/workspace/useDesktopWorkspaceEdgeDrop.js +119 -0
  110. package/dist/runtime/composables/workspace/useDesktopWorkspaceManager.d.ts +8 -0
  111. package/dist/runtime/composables/workspace/useDesktopWorkspaceManager.js +46 -0
  112. package/dist/runtime/composables/workspace/useDesktopWorkspaceOverviewCapture.d.ts +20 -0
  113. package/dist/runtime/composables/workspace/useDesktopWorkspaceOverviewCapture.js +60 -0
  114. package/dist/runtime/composables/workspace/useDesktopWorkspaceOverviewLiveScale.d.ts +31 -0
  115. package/dist/runtime/composables/workspace/useDesktopWorkspaceOverviewLiveScale.js +92 -0
  116. package/dist/runtime/constants/desktopShellKeys.d.ts +5 -0
  117. package/dist/runtime/constants/desktopShellKeys.js +2 -0
  118. package/dist/runtime/constants/shellLayout.d.ts +4 -0
  119. package/dist/runtime/constants/shellLayout.js +2 -0
  120. package/dist/runtime/dialogs/desktopDialogProvider.d.ts +6 -0
  121. package/dist/runtime/dialogs/desktopDialogProvider.js +12 -0
  122. package/dist/runtime/internal/controllers/ApplicationController.d.ts +37 -0
  123. package/dist/runtime/internal/controllers/ApplicationController.js +434 -0
  124. package/dist/runtime/internal/controllers/WindowController.d.ts +83 -0
  125. package/dist/runtime/internal/controllers/WindowController.js +435 -0
  126. package/dist/runtime/plugins/01.desktop-shell-init.client.d.ts +2 -0
  127. package/dist/runtime/plugins/01.desktop-shell-init.client.js +18 -0
  128. package/dist/runtime/plugins/02.desktop-register-desktop-apps.client.d.ts +2 -0
  129. package/dist/runtime/plugins/02.desktop-register-desktop-apps.client.js +7 -0
  130. package/dist/runtime/stores/storeApplicationMeta.d.ts +2 -0
  131. package/dist/runtime/stores/storeApplicationMeta.js +20 -0
  132. package/dist/runtime/stores/storeApplicationWindows.d.ts +2 -0
  133. package/dist/runtime/stores/storeApplicationWindows.js +33 -0
  134. package/dist/runtime/stores/storeDesktop.d.ts +17 -0
  135. package/dist/runtime/stores/storeDesktop.js +16 -0
  136. package/dist/runtime/stores/storeDesktopDefaultApps.d.ts +8 -0
  137. package/dist/runtime/stores/storeDesktopDefaultApps.js +21 -0
  138. package/dist/runtime/stores/storeDesktopTray.d.ts +6 -0
  139. package/dist/runtime/stores/storeDesktopTray.js +21 -0
  140. package/dist/runtime/stores/storeDesktopVolume.d.ts +4 -0
  141. package/dist/runtime/stores/storeDesktopVolume.js +12 -0
  142. package/dist/runtime/stores/storeDesktopWorkspace.d.ts +26 -0
  143. package/dist/runtime/stores/storeDesktopWorkspace.js +91 -0
  144. package/dist/runtime/stores/storeNotification.d.ts +27 -0
  145. package/dist/runtime/stores/storeNotification.js +55 -0
  146. package/dist/runtime/types/index.d.ts +1 -0
  147. package/dist/runtime/types/index.js +1 -0
  148. package/dist/runtime/utils/defineDesktopApp.d.ts +2 -0
  149. package/dist/runtime/utils/defineDesktopApp.js +5 -0
  150. package/dist/runtime/utils/defineDesktopPlugin.d.ts +19 -0
  151. package/dist/runtime/utils/defineDesktopPlugin.js +29 -0
  152. package/dist/runtime/utils/utilApp.d.ts +2 -0
  153. package/dist/runtime/utils/utilApp.js +9 -0
  154. package/dist/runtime/utils/utilCaptureElementToCanvas.d.ts +1 -0
  155. package/dist/runtime/utils/utilCaptureElementToCanvas.js +21 -0
  156. package/dist/runtime/utils/utilDebug.d.ts +4 -0
  157. package/dist/runtime/utils/utilDebug.js +24 -0
  158. package/dist/runtime/utils/utilDetectSnapZone.d.ts +1 -0
  159. package/dist/runtime/utils/utilDetectSnapZone.js +5 -0
  160. package/dist/runtime/utils/utilWindowControllerAdapter.d.ts +2 -0
  161. package/dist/runtime/utils/utilWindowControllerAdapter.js +151 -0
  162. package/dist/runtime/utils/utilWindowLayout.d.ts +4 -0
  163. package/dist/runtime/utils/utilWindowLayout.js +34 -0
  164. package/dist/runtime/utils/utilWorkspaceWindows.d.ts +2 -0
  165. package/dist/runtime/utils/utilWorkspaceWindows.js +12 -0
  166. package/dist/types/index.d.ts +156 -0
  167. package/dist/types/index.js +1 -0
  168. package/dist/types.d.mts +2 -0
  169. package/package.json +145 -4
package/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Open Web Desktop Team ~ github.com/owdproject
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
20
+ IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,78 @@
1
- # Temporary Holding Version
1
+ <div align="center">
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ <h1>@owdproject/nuxt</h1>
4
+
5
+ <p>
6
+ <strong>Official Nuxt & Vue 3 Reactive Adapter for Open Web Desktop.</strong><br /><br />
7
+ Reactive composables, pointer drag/resize hooks, and WindowController<br />
8
+ bindings powered by <code>@owdproject/core</code>.
9
+ </p>
10
+
11
+ <br />
12
+
13
+ <p>
14
+ <a href="https://npmjs.com/package/@owdproject/nuxt"><img src="https://img.shields.io/npm/v/@owdproject/nuxt/alpha.svg?style=flat&colorA=020420&colorB=00DC82" alt="npm version" /></a>
15
+ <a href="https://nuxt.com"><img src="https://img.shields.io/badge/Nuxt-020420?logo=nuxt" alt="Nuxt" /></a>
16
+ <a href="https://github.com/owdproject/core/blob/main/LICENSE"><img src="https://img.shields.io/badge/License-MIT-00DC82.svg?style=flat&colorA=020420&colorB=00DC82" alt="License" /></a>
17
+ </p>
18
+
19
+ </div>
20
+
21
+ ---
22
+
23
+ ## Overview
24
+
25
+ `@owdproject/nuxt` (`4.0.0-alpha.0`) bridges [`@owdproject/core`](https://npmjs.com/package/@owdproject/core) to Vue 3 and Nuxt via `shallowRef` subscriptions, computed selectors, and automatic `onScopeDispose` cleanup.
26
+
27
+ The package includes the Nuxt module, `desktop.config.ts` support, shell components, and Vue bindings.
28
+
29
+ Register it in `nuxt.config.ts`:
30
+
31
+ ```ts
32
+ export default defineNuxtConfig({
33
+ ssr: false,
34
+ modules: ['@owdproject/nuxt'],
35
+ desktop: {
36
+ theme: '@owdproject/nuxt-theme-win95',
37
+ },
38
+ })
39
+ ```
40
+
41
+ Install the theme separately. Inline `desktop` options override `desktop.config.ts`; app and module arrays are merged.
42
+
43
+ ---
44
+
45
+ ## Quick Start
46
+
47
+ ```bash
48
+ pnpm add @owdproject/core@4.0.0-alpha.0 @owdproject/nuxt@4.0.0-alpha.0
49
+ ```
50
+
51
+ ```vue
52
+ <script setup lang="ts">
53
+ import { useDesktop, useDesktopDrag, useDesktopResize } from '@owdproject/nuxt'
54
+
55
+ const { desktop, windows, focusedWindow } = useDesktop({
56
+ workarea: { x: 0, y: 32, width: 1440, height: 868 },
57
+ })
58
+ </script>
59
+ ```
60
+
61
+ ---
62
+
63
+ ## Exported Composables & Classes
64
+
65
+ | Export | Description |
66
+ | :--- | :--- |
67
+ | **`useDesktop(instanceOrOptions?)`** | Reactive bindings for `windows`, `applications`, `workspace`, `commands`, `events`, and `focusedWindow`. |
68
+ | **`useWindowManager(manager?)`** | Reactive wrapper around a `WindowManager` instance. |
69
+ | **`useWindowInstance(instance)`** | Subscribes a single `WindowInstance` to a Vue `shallowRef<WindowState>`. |
70
+ | **`useDesktopDrag(options)`** | W3C Pointer drag composable with snap-zone detection and auto-cleanup. |
71
+ | **`useDesktopResize(options)`** | 8-directional W3C Pointer resize composable with min/max constraint enforcement. |
72
+ | **`WindowController`** | Reactive Vue wrapper around `@owdproject/core`'s `windowMachine`. |
73
+
74
+ ---
75
+
76
+ ## License
77
+
78
+ [MIT](https://opensource.org/licenses/MIT)
@@ -0,0 +1,96 @@
1
+ import type { DesktopConfig, DesktopExtensionDirs, DesktopExtensionKind, DesktopExtensionMeta, DesktopFramework } from '../types/index.js';
2
+ import { defineNuxtModule, type NuxtModule } from '@nuxt/kit';
3
+ import type { Nuxt } from '@nuxt/schema';
4
+ /** Root `desktop.config.ts` helper — keep this file free of `import.meta` for jiti. */
5
+ export declare function defineDesktopConfig(config: DesktopConfig): DesktopConfig;
6
+ /**
7
+ * Default directories a desktop distribution collects extensions from, relative to its
8
+ * root. A Nuxt desktop uses `apps/`, `modules/` and `themes/`; the monorepo keeps
9
+ * framework modules under `packages/`, so both slots are listed.
10
+ */
11
+ export declare const DESKTOP_EXTENSION_DIRS: DesktopExtensionDirs;
12
+ /**
13
+ * Parses a framework-first extension short name (`nuxt-app-todo`, `react-theme-win95`)
14
+ * into its parts. Legacy names without a framework segment (`app-todo`) are accepted
15
+ * with `framework` left undefined. Returns `null` when the kind is unknown.
16
+ */
17
+ export declare function parseDesktopExtensionName(shortName: string): {
18
+ framework?: DesktopFramework;
19
+ kind: DesktopExtensionKind;
20
+ name: string;
21
+ } | null;
22
+ /**
23
+ * Runtime validation for the object exported from `desktop.config.ts`
24
+ * (or legacy `owd.config.ts`).
25
+ */
26
+ export declare function assertValidDesktopUserConfig(config: unknown, configFile?: string): void;
27
+ export declare const DESKTOP_CONFIG_FILENAME = "desktop.config.ts";
28
+ export declare const LEGACY_DESKTOP_CONFIG_FILENAME = "owd.config.ts";
29
+ export declare const LEGACY_CONFIG_DEPRECATION = "[@owdproject/nuxt] owd.config.ts is deprecated and kept only for backward compatibility; rename to desktop.config.ts.";
30
+ export type ResolvedDesktopConfigPath = {
31
+ path: string;
32
+ file: string;
33
+ legacy: boolean;
34
+ };
35
+ export declare function resolveDesktopConfigPath(rootDir: string): ResolvedDesktopConfigPath | null;
36
+ export declare function warnLegacyDesktopConfig(resolved: ResolvedDesktopConfigPath | null | undefined): void;
37
+ /** Path used when creating or updating config from the CLI (always the new filename). */
38
+ export declare function desktopConfigWritePath(desktopDir: string): string;
39
+ /**
40
+ * Warn when desktop.config.ts contains keys that look like Nuxt options.
41
+ * Extension keys (fs, terminal, custom app namespaces) are intentionally not validated here.
42
+ */
43
+ export declare function warnDesktopConfigKeys(config: Record<string, unknown>, configFile?: string): void;
44
+ /**
45
+ * Writes a resolved extension namespace to `runtimeConfig.public.desktop[configKey]`.
46
+ * Used by {@link defineDesktopModule} after Nuxt merges inline options with module defaults.
47
+ */
48
+ export declare function setDesktopExtensionConfig(nuxt: Nuxt, configKey: string, resolved: Record<string, unknown>): void;
49
+ /**
50
+ * Merges theme or module defaults into an extension namespace on `public.desktop`.
51
+ * User values from desktop.config win over `partial` (defu: partial fills undefined only).
52
+ */
53
+ export declare function mergeDesktopExtensionConfig(nuxt: Nuxt, configKey: string, partial: Record<string, unknown>): void;
54
+ /**
55
+ * Reads the declarative extension contract (`kind`, `framework`, `adapter`, …) from a
56
+ * package's Nuxt module `meta`. Build-time only — no runtime imports. Used to keep the
57
+ * collection contract framework-agnostic across desktop distributions.
58
+ */
59
+ export declare function readExtensionMeta(modulePath: string): Promise<Partial<DesktopExtensionMeta>>;
60
+ /**
61
+ * Validates an extension contract and returns a normalized copy. Throws on an unknown
62
+ * kind/framework so misconfigured extensions fail at build time instead of at runtime.
63
+ */
64
+ export declare function assertDesktopExtensionMeta(meta: Partial<DesktopExtensionMeta>, packageName?: string): DesktopExtensionMeta;
65
+ /**
66
+ * Installs a desktop theme, module, or app package.
67
+ * When the package exposes `meta.configKey`, passes `desktop[configKey]` to `installModule`
68
+ * so Nuxt merges desktop.config with module defaults.
69
+ */
70
+ export declare function installDesktopPackage(nuxt: Nuxt, modulePath: string, desktop?: Record<string, unknown>): Promise<void>;
71
+ type DesktopModuleMeta = {
72
+ name: string;
73
+ configKey: string;
74
+ } & Partial<Omit<DesktopExtensionMeta, 'configKey'>>;
75
+ type DesktopModuleDefinition = NuxtModule<Record<string, unknown>, Record<string, unknown>, false> & {
76
+ meta: DesktopModuleMeta;
77
+ };
78
+ /**
79
+ * Nuxt module wrapper for desktop apps and extension modules (`configKey` → desktop.config namespace).
80
+ * Publishes merged options to `runtimeConfig.public.desktop[configKey]` after setup runs.
81
+ */
82
+ export declare function defineDesktopModule(definition: DesktopModuleDefinition): ReturnType<typeof defineNuxtModule>;
83
+ type DesktopThemeDefinition = NuxtModule<Record<string, unknown>, Record<string, unknown>, false>;
84
+ /**
85
+ * Nuxt module wrapper for desktop themes.
86
+ * Merges theme shell defaults into `runtimeConfig.public.desktop` (user desktop.config wins).
87
+ */
88
+ export declare function defineDesktopTheme(definition: DesktopThemeDefinition): ReturnType<typeof defineNuxtModule>;
89
+ /**
90
+ * Build-time check if a desktop module, app, or theme is registered in desktop.config.ts.
91
+ * Useful during theme or module setup hooks before Nuxt finishes installing modules.
92
+ */
93
+ export declare function hasDesktopModule(nuxt: Nuxt, packageName: string): boolean;
94
+ /** Inline Nuxt options override the file; extension arrays are merged without duplicates. */
95
+ export declare function mergeDesktopConfig(inline: DesktopConfig, file: DesktopConfig, coreVersion: string): DesktopConfig;
96
+ export {};
@@ -0,0 +1,260 @@
1
+ import { existsSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import {
4
+ defineNuxtModule,
5
+ installModule,
6
+ resolvePath
7
+ } from "@nuxt/kit";
8
+ import { defu } from "defu";
9
+ export function defineDesktopConfig(config) {
10
+ return config;
11
+ }
12
+ export const DESKTOP_EXTENSION_DIRS = {
13
+ apps: ["apps"],
14
+ modules: ["modules", "packages"],
15
+ themes: ["themes"]
16
+ };
17
+ const FRAMEWORK_SEGMENTS = [
18
+ "nuxt",
19
+ "vue",
20
+ "react",
21
+ "svelte",
22
+ "angular",
23
+ "astro"
24
+ ];
25
+ const KIND_SEGMENTS = [
26
+ "app",
27
+ "module",
28
+ "theme",
29
+ "kit"
30
+ ];
31
+ export function parseDesktopExtensionName(shortName) {
32
+ const parts = shortName.split("-");
33
+ let framework;
34
+ if (FRAMEWORK_SEGMENTS.includes(parts[0])) {
35
+ framework = parts.shift();
36
+ }
37
+ const kind = parts[0];
38
+ if (!KIND_SEGMENTS.includes(kind)) return null;
39
+ return { framework, kind, name: parts.slice(1).join("-") };
40
+ }
41
+ export function assertValidDesktopUserConfig(config, configFile = "desktop.config.ts") {
42
+ if (!config || typeof config !== "object" || Array.isArray(config)) {
43
+ throw new Error(
44
+ `[@owdproject/nuxt] ${configFile} must default-export a non-array object from defineDesktopConfig({ ... }).`
45
+ );
46
+ }
47
+ const c = config;
48
+ if (c.theme != null && typeof c.theme !== "string") {
49
+ throw new Error(
50
+ `[@owdproject/nuxt] ${configFile}: \`theme\` must be a string (npm package name or local path of the theme module).`
51
+ );
52
+ }
53
+ if (c.apps !== void 0) {
54
+ if (!Array.isArray(c.apps) || !c.apps.every((item) => typeof item === "string")) {
55
+ throw new Error(
56
+ `[@owdproject/nuxt] ${configFile}: \`apps\` must be an array of strings (Nuxt module package names or local paths).`
57
+ );
58
+ }
59
+ }
60
+ if (c.modules !== void 0) {
61
+ if (!Array.isArray(c.modules) || !c.modules.every((item) => typeof item === "string")) {
62
+ throw new Error(
63
+ `[@owdproject/nuxt] ${configFile}: \`modules\` must be an array of strings (Nuxt module package names or local paths).`
64
+ );
65
+ }
66
+ }
67
+ }
68
+ export const DESKTOP_CONFIG_FILENAME = "desktop.config.ts";
69
+ export const LEGACY_DESKTOP_CONFIG_FILENAME = "owd.config.ts";
70
+ export const LEGACY_CONFIG_DEPRECATION = "[@owdproject/nuxt] owd.config.ts is deprecated and kept only for backward compatibility; rename to desktop.config.ts.";
71
+ export function resolveDesktopConfigPath(rootDir) {
72
+ const desktopPath = join(rootDir, DESKTOP_CONFIG_FILENAME);
73
+ const legacyPath = join(rootDir, LEGACY_DESKTOP_CONFIG_FILENAME);
74
+ const hasDesktop = existsSync(desktopPath);
75
+ const hasLegacy = existsSync(legacyPath);
76
+ if (hasDesktop && hasLegacy) {
77
+ console.warn(
78
+ "[@owdproject/nuxt] Both desktop.config.ts and owd.config.ts exist; using desktop.config.ts. Remove owd.config.ts."
79
+ );
80
+ return { path: desktopPath, file: DESKTOP_CONFIG_FILENAME, legacy: false };
81
+ }
82
+ if (hasDesktop) {
83
+ return { path: desktopPath, file: DESKTOP_CONFIG_FILENAME, legacy: false };
84
+ }
85
+ if (hasLegacy) {
86
+ return {
87
+ path: legacyPath,
88
+ file: LEGACY_DESKTOP_CONFIG_FILENAME,
89
+ legacy: true
90
+ };
91
+ }
92
+ return null;
93
+ }
94
+ export function warnLegacyDesktopConfig(resolved) {
95
+ if (resolved?.legacy) {
96
+ console.warn(LEGACY_CONFIG_DEPRECATION);
97
+ }
98
+ }
99
+ export function desktopConfigWritePath(desktopDir) {
100
+ return join(desktopDir, DESKTOP_CONFIG_FILENAME);
101
+ }
102
+ const NUXT_OPTION_KEYS = /* @__PURE__ */ new Set([
103
+ "ssr",
104
+ "devtools",
105
+ "vite",
106
+ "nitro",
107
+ "runtimeConfig",
108
+ "app",
109
+ "appConfig",
110
+ "css",
111
+ "plugins",
112
+ "hooks",
113
+ "extends",
114
+ "compatibilityDate",
115
+ "experimental",
116
+ "future",
117
+ "i18n",
118
+ "tailwindcss",
119
+ "primevue"
120
+ ]);
121
+ export function warnDesktopConfigKeys(config, configFile = "desktop.config.ts") {
122
+ for (const key of Object.keys(config)) {
123
+ if (NUXT_OPTION_KEYS.has(key)) {
124
+ console.warn(
125
+ `[@owdproject/nuxt] ${configFile}: key "${key}" looks like a Nuxt option and is ignored for _nuxt.options. Move it to nuxt.config.ts; shell values belong under defineDesktopConfig({ systemBar, workspaces, ... }).`
126
+ );
127
+ }
128
+ }
129
+ }
130
+ export function setDesktopExtensionConfig(nuxt, configKey, resolved) {
131
+ const pub = nuxt.options.runtimeConfig.public ??= {};
132
+ const desktop = pub.desktop ??= {};
133
+ desktop[configKey] = resolved;
134
+ }
135
+ export function mergeDesktopExtensionConfig(nuxt, configKey, partial) {
136
+ const pub = nuxt.options.runtimeConfig.public ??= {};
137
+ const desktop = pub.desktop ??= {};
138
+ const existing = desktop[configKey];
139
+ const base = existing && typeof existing === "object" && !Array.isArray(existing) ? existing : {};
140
+ desktop[configKey] = defu(partial, base);
141
+ }
142
+ async function readConfigKey(mod) {
143
+ if (!mod) return void 0;
144
+ let meta = mod.meta ?? mod.default?.meta;
145
+ if (!meta) {
146
+ const getMeta = mod.getMeta ?? mod.default?.getMeta;
147
+ if (typeof getMeta === "function") {
148
+ try {
149
+ meta = await getMeta();
150
+ } catch (e) {
151
+ console.warn("[@owdproject/nuxt] failed to call getMeta():", e);
152
+ }
153
+ }
154
+ }
155
+ const key = meta?.configKey;
156
+ return typeof key === "string" && key.length > 0 ? key : void 0;
157
+ }
158
+ export async function readExtensionMeta(modulePath) {
159
+ const meta = (await loadModuleDescriptor(modulePath))?.meta ?? {};
160
+ return {
161
+ kind: meta.kind,
162
+ framework: meta.framework,
163
+ packageName: meta.packageName,
164
+ configKey: meta.configKey,
165
+ entry: meta.entry,
166
+ adapter: meta.adapter,
167
+ requires: meta.requires
168
+ };
169
+ }
170
+ export function assertDesktopExtensionMeta(meta, packageName = "unknown") {
171
+ if (!meta.kind || !KIND_SEGMENTS.includes(meta.kind)) {
172
+ throw new Error(
173
+ `[@owdproject/nuxt] ${packageName}: extension meta.kind must be one of ${KIND_SEGMENTS.join(", ")}.`
174
+ );
175
+ }
176
+ if (!meta.framework || !FRAMEWORK_SEGMENTS.includes(meta.framework)) {
177
+ throw new Error(
178
+ `[@owdproject/nuxt] ${packageName}: extension meta.framework must be one of ${FRAMEWORK_SEGMENTS.join(", ")}.`
179
+ );
180
+ }
181
+ return meta;
182
+ }
183
+ async function loadModuleDescriptor(modulePath) {
184
+ try {
185
+ const resolvedPath = await resolvePath(modulePath);
186
+ const imported = await import(resolvedPath);
187
+ return imported.default ?? imported;
188
+ } catch (e) {
189
+ console.warn(`[@owdproject/nuxt] loadModuleDescriptor failed for "${modulePath}":`, e);
190
+ return void 0;
191
+ }
192
+ }
193
+ export async function installDesktopPackage(nuxt, modulePath, desktop) {
194
+ const descriptor = await loadModuleDescriptor(modulePath);
195
+ const configKey = await readConfigKey(descriptor);
196
+ if (configKey && desktop) {
197
+ const slice = desktop[configKey];
198
+ const inline = slice && typeof slice === "object" && !Array.isArray(slice) ? slice : {};
199
+ await installModule(modulePath, inline);
200
+ return;
201
+ }
202
+ await installModule(modulePath);
203
+ }
204
+ export function defineDesktopModule(definition) {
205
+ const configKey = definition.meta.configKey;
206
+ if (!configKey) {
207
+ throw new Error(
208
+ '[@owdproject/nuxt] defineDesktopModule requires meta.configKey (e.g. "terminal", "fs", "audit").'
209
+ );
210
+ }
211
+ const userSetup = definition.setup;
212
+ return defineNuxtModule({
213
+ ...definition,
214
+ async setup(options, nuxt) {
215
+ setDesktopExtensionConfig(
216
+ nuxt,
217
+ configKey,
218
+ options
219
+ );
220
+ if (typeof userSetup === "function") {
221
+ return userSetup(options, nuxt);
222
+ }
223
+ }
224
+ });
225
+ }
226
+ export function defineDesktopTheme(definition) {
227
+ const userSetup = definition.setup;
228
+ return defineNuxtModule({
229
+ ...definition,
230
+ meta: {
231
+ ...definition.meta,
232
+ configKey: "desktop"
233
+ },
234
+ async setup(options, nuxt) {
235
+ const pub = nuxt.options.runtimeConfig.public ??= {};
236
+ pub.desktop = defu(
237
+ pub.desktop ?? {},
238
+ options
239
+ );
240
+ if (typeof userSetup === "function") {
241
+ return userSetup(options, nuxt);
242
+ }
243
+ }
244
+ });
245
+ }
246
+ export function hasDesktopModule(nuxt, packageName) {
247
+ const desktop = nuxt.options.runtimeConfig.public.desktop;
248
+ if (!desktop) return false;
249
+ const contains = (item) => item ? String(item).includes(packageName) : false;
250
+ return contains(desktop.theme) || (desktop.modules?.some(contains) ?? false) || (desktop.apps?.some(contains) ?? false);
251
+ }
252
+ export function mergeDesktopConfig(inline, file, coreVersion) {
253
+ assertValidDesktopUserConfig(inline, "nuxt.config.ts desktop options");
254
+ assertValidDesktopUserConfig(file);
255
+ const merged = defu(inline, file, { coreVersion });
256
+ for (const key of ["apps", "modules"]) {
257
+ if (merged[key]) merged[key] = [...new Set(merged[key])];
258
+ }
259
+ return merged;
260
+ }
@@ -0,0 +1 @@
1
+ export * from '../runtime/utils/defineDesktopApp.js';
@@ -0,0 +1 @@
1
+ export * from "../runtime/utils/defineDesktopApp";
@@ -0,0 +1 @@
1
+ export * from '../runtime/utils/defineDesktopPlugin.js';
@@ -0,0 +1 @@
1
+ export * from "../runtime/utils/defineDesktopPlugin";