@owdproject/core 3.3.1 → 3.4.0

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 (92) hide show
  1. package/CHANGELOG.md +98 -0
  2. package/DESKTOP_KERNEL.md +232 -0
  3. package/MIGRATION_3.3.2.md +23 -0
  4. package/MIGRATION_3.4.md +126 -0
  5. package/PLAYGROUND.md +91 -0
  6. package/README.md +13 -80
  7. package/dist/module.d.mts +2 -2
  8. package/dist/module.json +3 -3
  9. package/dist/module.mjs +74 -88
  10. package/index.ts +6 -3
  11. package/kit/authoring.ts +340 -0
  12. package/kit/defineDesktopApp.ts +56 -0
  13. package/module.ts +64 -84
  14. package/package.json +70 -41
  15. package/runtime/components/{Desktop/Application/DesktopApplicationRender.vue → Application/DesktopCoreApplicationRender.vue} +2 -2
  16. package/runtime/components/{Desktop/Application/DesktopApplicationWindowsRender.vue → Application/DesktopCoreApplicationWindowsRender.vue} +1 -1
  17. package/runtime/components/core/DesktopCore.vue +43 -0
  18. package/runtime/components/{Desktop/Window/DesktopWindow.vue → window/DesktopCoreWindow.vue} +17 -6
  19. package/runtime/components/window/DesktopCoreWindowSnapHintsBase.vue +74 -0
  20. package/runtime/components/workspace/DesktopCoreWorkspaceEdgeHintsBase.vue +84 -0
  21. package/runtime/composables/useBlockNonInputContextMenu.ts +30 -0
  22. package/runtime/composables/useDesktopConfig.ts +8 -0
  23. package/runtime/composables/useDesktopDialogs.ts +16 -0
  24. package/runtime/composables/useDesktopExtension.ts +8 -0
  25. package/runtime/composables/useDesktopManager.ts +2 -0
  26. package/runtime/composables/useDesktopManifest.ts +17 -0
  27. package/runtime/composables/useDesktopSession.ts +27 -0
  28. package/runtime/composables/useDesktopShellIdentity.ts +99 -0
  29. package/runtime/composables/useDesktopShellOptions.ts +36 -0
  30. package/runtime/composables/useDesktopShellReady.ts +7 -0
  31. package/runtime/composables/useDesktopWorkArea.ts +93 -0
  32. package/runtime/composables/useTerminalManager.ts +102 -9
  33. package/runtime/composables/useToggleWindowMaximize.ts +35 -0
  34. package/runtime/composables/useWindowDragHandlers.ts +47 -0
  35. package/runtime/composables/useWindowSnapDrop.ts +112 -0
  36. package/runtime/composables/useWorkspaceEdgeDrop.ts +176 -0
  37. package/runtime/composables/useWorkspaceManager.ts +26 -0
  38. package/runtime/composables/useWorkspaceOverviewCapture.ts +92 -0
  39. package/runtime/composables/useWorkspaceOverviewLiveScale.ts +151 -0
  40. package/runtime/constants/desktopShellKeys.ts +12 -0
  41. package/runtime/constants/shellLayout.ts +5 -0
  42. package/runtime/dialogs/desktopDialogProvider.ts +73 -0
  43. package/runtime/internal/controllers/ApplicationController.ts +8 -2
  44. package/runtime/internal/controllers/WindowController.ts +93 -8
  45. package/runtime/plugins/01.desktop-shell-init.client.ts +28 -0
  46. package/runtime/plugins/02.desktop-register-desktop-apps.client.ts +2 -6
  47. package/runtime/stores/storeApplicationMeta.ts +2 -1
  48. package/runtime/stores/storeApplicationWindows.ts +2 -1
  49. package/runtime/stores/storeDesktop.ts +17 -57
  50. package/runtime/stores/storeDesktopDefaultApps.ts +2 -1
  51. package/runtime/stores/storeDesktopVolume.ts +2 -1
  52. package/runtime/stores/storeDesktopWindow.ts +20 -2
  53. package/runtime/stores/storeDesktopWorkspace.ts +31 -1
  54. package/runtime/stores/storeIds.ts +35 -0
  55. package/runtime/types/desktopMenu.ts +10 -0
  56. package/runtime/utils/initDesktopShell.ts +80 -0
  57. package/runtime/utils/migratePersistedStoreIds.ts +57 -0
  58. package/runtime/utils/utilApp.ts +0 -12
  59. package/runtime/utils/{captureElementToCanvas.ts → utilCaptureElementToCanvas.ts} +1 -1
  60. package/runtime/utils/utilDetectSnapZone.ts +57 -0
  61. package/runtime/utils/utilWindowLayout.ts +82 -0
  62. package/runtime/utils/utilWindowMaximizeLayout.ts +44 -0
  63. package/runtime/utils/utilWorkspaceWindows.ts +33 -0
  64. package/types/index.d.ts +125 -14
  65. package/bin/cli.js +0 -395
  66. package/bin/desktop.js +0 -5
  67. package/bin/lib/catalog.js +0 -293
  68. package/bin/lib/config.js +0 -109
  69. package/bin/lib/desktopConfig.js +0 -56
  70. package/bin/lib/generateTemplate.js +0 -389
  71. package/bin/lib/install.js +0 -408
  72. package/bin/lib/migrateModulePlayground.config.mjs +0 -164
  73. package/bin/lib/migrateModulePlayground.mjs +0 -313
  74. package/bin/lib/npmVersions.js +0 -124
  75. package/bin/lib/playgroundContext.js +0 -188
  76. package/bin/lib/scaffold.js +0 -197
  77. package/bin/lib/status.js +0 -289
  78. package/bin/lib/validateModule.js +0 -697
  79. package/bin/lib/workspace.js +0 -182
  80. package/bin/owd.js +0 -5
  81. package/bin/tui.js +0 -1379
  82. package/runtime/components/Desktop/Core/DesktopCore.vue +0 -90
  83. package/runtime/utils/explorerEntryPath.ts +0 -10
  84. package/runtime/utils/resolveDesktopConfigPath.ts +0 -52
  85. package/runtime/utils/splitDesktopUserConfig.ts +0 -85
  86. package/runtime/utils/utilDesktop.ts +0 -35
  87. package/runtime/utils/validateDesktopUserConfig.ts +0 -44
  88. /package/runtime/components/{Desktop/Background/DesktopBackground.vue → background/DesktopCoreBackground.vue} +0 -0
  89. /package/runtime/components/{Desktop/Time/DesktopTime.vue → time/DesktopCoreTime.vue} +0 -0
  90. /package/runtime/components/{Desktop/Window/DesktopWindowContent.vue → window/DesktopCoreWindowContent.vue} +0 -0
  91. /package/runtime/components/{Desktop/Window/DesktopWindowNav.vue → window/DesktopCoreWindowNav.vue} +0 -0
  92. /package/runtime/utils/{utilWindow.ts → utilWindowControllerAdapter.ts} +0 -0
package/README.md CHANGED
@@ -1,89 +1,22 @@
1
- <p align="center">
2
- <img width="160" height="160" src="https://avatars.githubusercontent.com/u/65117737?s=160&v=4" />
3
- </p>
4
- <h1 align="center">Open Web Desktop</h1>
5
- <h3 align="center">
6
- A modular framework for building web-based desktop experiences.
7
- </h3>
1
+ # 📦 OWD Core
8
2
 
9
- ## Overview
3
+ > The kernel and runtime engine for Open Web Desktop
10
4
 
11
- Open Web Desktop (OWD) is a framework designed to provide a simple environment for building web-based desktop experiences. It's built with TypeScript on top of the Nuxt.js framework.
12
-
13
- [Demo](https://atproto-os.pages.dev/) · [Community](https://discord.gg/zPNaN2HAaA) · [Documentation](https://owdproject.org/)
5
+ This package provides the core logic, Vue components, and Nuxt module required to run an Open Web Desktop experience.
14
6
 
15
7
  ## Features
16
8
 
17
- - Fully extendable through themes, apps, and modules
18
- - Bundled with popular Vue.js libraries like Pinia and VueUse
19
- - Designed to make the most of the Nuxt.js ecosystem
20
- - Styled with PrimeVue and Tailwind for a consistent UI
21
- - Fully localizable with nuxt-i18n support
22
-
23
- ## Getting started
24
-
25
- Bootstrap a new project by running:
26
-
27
- ```bash
28
- npm create owd
29
- ```
30
-
31
- Once the process is done, you can start to develop:
32
-
33
- ```bash
34
- cd owd-client
35
-
36
- # Run the dev server with hot-reload
37
- pnpm install
38
- pnpm run dev
39
-
40
- # Build for production
41
- pnpm run generate
42
- ```
43
-
44
- ## Extend your desktop
45
-
46
- Thanks to Tailwind and PrimeVue, you can create custom themes from scratch and ensure a consistent look across all apps. Each theme defines its own style, making your desktop both cohesive and uniquely yours.
47
-
48
- [Applications](https://github.com/topics/owd-apps) · [Modules](https://github.com/topics/owd-modules) · [Themes](https://github.com/topics/owd-themes)
49
-
50
- ### 🧩 Install an app
51
-
52
- Discover apps by searching the [owd-apps](https://github.com/topics/owd-apps) tag on GitHub.
53
-
54
- For example, to add the To-do app:
55
-
56
- ```bash
57
- desktop add app-todo
58
- ```
59
-
60
- Shipped with `@owdproject/core` (`bin/desktop.js`). The `owd` binary is a deprecated alias.
61
-
62
- ### 🧩 Install a module
63
-
64
- Discover modules by searching the [owd-modules](https://github.com/topics/owd-modules) tag on GitHub.
65
-
66
- For example, to add Pinia persistence backed by IndexedDB (`idb-keyval`):
67
-
68
- ```bash
69
- desktop add module-pinia-idb
70
- ```
71
-
72
- ### 🖥️ Install a theme
73
-
74
- Themes are full desktop environments that style all UI components independently, using [PrimeVue](https://primevue.org/).
75
- Each theme provides a unique look and feel while maintaining consistent functionality across all applications.
76
-
77
- Discover themes by searching the [owd-themes](https://github.com/topics/owd-themes) tag on GitHub.
78
-
79
- ```bash
80
- desktop add theme-gnome
81
- ```
9
+ - **Window Management**: Z-index handling, focusing, and lifecycle.
10
+ - **Runtime Components**: \`DesktopCore\`, \`DesktopWindow\`, and more.
11
+ - **State Management**: Pinia stores for workspaces, applications, and settings.
12
+ - **Nuxt Integration**: Seamless module for Nuxt 3/4.
82
13
 
83
- ## Sponsors
14
+ ## Installation
84
15
 
85
- Be the first to support this project and help us keep it growing! [Sponsor the project](https://github.com/sponsors/owdproject)
16
+ \`\`\`bash
17
+ pnpm add @owdproject/core
18
+ \`\`\`
86
19
 
87
- ## License
20
+ ---
88
21
 
89
- Open Web Desktop is released under the [MIT License](LICENSE).
22
+ Licensed under [MIT](./LICENSE)
package/dist/module.d.mts CHANGED
@@ -1,6 +1,6 @@
1
- import * as _nuxt_schema from '@nuxt/schema';
1
+ import * as nuxt_schema from 'nuxt/schema';
2
2
 
3
- declare const _default: _nuxt_schema.NuxtModule<{
3
+ declare const _default: nuxt_schema.NuxtModule<{
4
4
  theme: string;
5
5
  apps: never[];
6
6
  modules: never[];
package/dist/module.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "desktop",
3
- "configKey": "owd",
4
- "version": "3.3.1",
3
+ "configKey": "desktop",
4
+ "version": "3.4.0",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
- "unbuild": "3.6.1"
7
+ "unbuild": "unknown"
8
8
  }
9
9
  }
package/dist/module.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { defineNuxtModule, createResolver, installModule, addComponentsDir, addPlugin, addImportsDir } from '@nuxt/kit';
1
+ import { installModule, defineNuxtModule, createResolver, resolvePath, addComponentsDir, addPlugin, addImportsDir } from '@nuxt/kit';
2
2
  import { defu } from 'defu';
3
3
  import { existsSync } from 'node:fs';
4
4
  import { join } from 'node:path';
@@ -30,7 +30,6 @@ function assertValidDesktopUserConfig(config, configFile = "desktop.config.ts")
30
30
  }
31
31
  }
32
32
  }
33
-
34
33
  const DESKTOP_CONFIG_FILENAME = "desktop.config.ts";
35
34
  const LEGACY_DESKTOP_CONFIG_FILENAME = "owd.config.ts";
36
35
  const LEGACY_CONFIG_DEPRECATION = "[@owdproject/core] owd.config.ts is deprecated and kept only for backward compatibility; rename to desktop.config.ts (required from @owdproject/core 3.2).";
@@ -62,22 +61,8 @@ function warnLegacyDesktopConfig(resolved) {
62
61
  console.warn(LEGACY_CONFIG_DEPRECATION);
63
62
  }
64
63
  }
65
-
66
- const DESKTOP_MODULE_KEYS = ["theme", "apps", "modules"];
67
- const DESKTOP_RUNTIME_KEYS = /* @__PURE__ */ new Set([
68
- ...DESKTOP_MODULE_KEYS,
69
- "docs",
70
- "name",
71
- "defaultApps",
72
- "features",
73
- "explorer",
74
- "systemBar",
75
- "dockBar",
76
- "workspaces"
77
- ]);
78
64
  const NUXT_OPTION_KEYS = /* @__PURE__ */ new Set([
79
65
  "ssr",
80
- "modules",
81
66
  "devtools",
82
67
  "vite",
83
68
  "nitro",
@@ -95,63 +80,56 @@ const NUXT_OPTION_KEYS = /* @__PURE__ */ new Set([
95
80
  "tailwindcss",
96
81
  "primevue"
97
82
  ]);
98
- function splitDesktopUserConfig(config, configFile = "desktop.config.ts") {
99
- const theme = typeof config.theme === "string" ? config.theme : void 0;
100
- const apps = Array.isArray(config.apps) ? config.apps : void 0;
101
- const modules = Array.isArray(config.modules) ? config.modules : void 0;
102
- const desktopRuntime = {};
103
- for (const [key, value] of Object.entries(config)) {
104
- if (DESKTOP_MODULE_KEYS.includes(key)) {
105
- continue;
106
- }
107
- desktopRuntime[key] = value;
83
+ function warnDesktopConfigKeys(config, configFile = "desktop.config.ts") {
84
+ for (const key of Object.keys(config)) {
108
85
  if (NUXT_OPTION_KEYS.has(key)) {
109
86
  console.warn(
110
87
  `[@owdproject/core] ${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, ... }).`
111
88
  );
112
- } else if (!DESKTOP_RUNTIME_KEYS.has(key)) {
113
- console.warn(
114
- `[@owdproject/core] ${configFile}: unknown desktop key "${key}" \u2014 merged into runtimeConfig.public.desktop only.`
115
- );
116
89
  }
117
90
  }
118
- return { theme, apps, modules, desktopRuntime };
91
+ }
92
+ function readConfigKey(mod) {
93
+ const key = mod?.meta?.configKey ?? mod?.default?.meta?.configKey;
94
+ return typeof key === "string" && key.length > 0 ? key : void 0;
95
+ }
96
+ async function loadModuleDescriptor(modulePath) {
97
+ try {
98
+ const imported = await import(modulePath);
99
+ return imported.default ?? imported;
100
+ } catch (e) {
101
+ console.warn(`[@owdproject/core] Failed to load module descriptor for "${modulePath}":`, e.message || e);
102
+ return void 0;
103
+ }
104
+ }
105
+ async function installDesktopPackage(nuxt, modulePath, desktop) {
106
+ const descriptor = await loadModuleDescriptor(modulePath);
107
+ const configKey = readConfigKey(descriptor);
108
+ if (configKey && desktop) {
109
+ const slice = desktop[configKey];
110
+ const inline = slice && typeof slice === "object" && !Array.isArray(slice) ? slice : {};
111
+ await installModule(modulePath, inline);
112
+ return;
113
+ }
114
+ await installModule(modulePath);
119
115
  }
120
116
 
121
- const version = "3.3.1";
117
+ const version = "3.4.0";
122
118
  const pkg = {
123
119
  version: version};
124
120
 
125
- function primevueModuleDependency(nuxt) {
126
- const existing = nuxt.options.primevue ?? {};
127
- const components = { ...existing.components ?? {} };
128
- const include = components.include;
129
- if (include && include !== "*" && Array.isArray(include) && !include.includes("ConfirmDialog")) {
130
- components.include = [...include, "ConfirmDialog"];
131
- }
132
- return {
133
- defaults: defu(
134
- {
135
- options: { theme: {} },
136
- components
137
- },
138
- existing
139
- )
140
- };
141
- }
142
121
  const module$1 = defineNuxtModule({
143
122
  meta: {
144
123
  name: "desktop",
145
- configKey: "owd"
124
+ configKey: "desktop"
146
125
  },
147
126
  defaults: {
148
127
  theme: "@owdproject/theme-nova",
149
128
  apps: [],
150
129
  modules: []
151
130
  },
152
- moduleDependencies: (nuxt) => ({
131
+ moduleDependencies: {
153
132
  "@pinia/nuxt": {},
154
- "@primevue/nuxt-module": primevueModuleDependency(nuxt),
155
133
  "@nuxt/fonts": {},
156
134
  "@nuxt/icon": {
157
135
  defaults: {
@@ -163,9 +141,14 @@ const module$1 = defineNuxtModule({
163
141
  },
164
142
  "@vueuse/nuxt": {},
165
143
  "@nuxtjs/i18n": {}
166
- }),
144
+ },
167
145
  async setup(_options, _nuxt) {
168
146
  const { resolve } = createResolver(import.meta.url);
147
+ let resolvedNanoid = null;
148
+ try {
149
+ resolvedNanoid = await resolvePath("nanoid", { url: import.meta.url });
150
+ } catch (e) {
151
+ }
169
152
  _nuxt.options.experimental = {
170
153
  ..._nuxt.options.experimental,
171
154
  viteEnvironmentApi: _nuxt.options.experimental?.viteEnvironmentApi ?? true
@@ -178,6 +161,8 @@ const module$1 = defineNuxtModule({
178
161
  throw new Error(`[@owdproject/core] Cannot find desktop.config.ts in ${_nuxt.options.rootDir}. ${hint}`);
179
162
  }
180
163
  warnLegacyDesktopConfig(resolvedConfig);
164
+ _nuxt.options.watch ??= [];
165
+ _nuxt.options.watch.push(resolvedConfig.path);
181
166
  try {
182
167
  clientConfig = (await import(resolvedConfig.path)).default;
183
168
  } catch (e) {
@@ -191,48 +176,41 @@ const module$1 = defineNuxtModule({
191
176
  if (!clientConfig.theme) {
192
177
  clientConfig.theme = "@owdproject/theme-nova";
193
178
  }
194
- const {
195
- theme: configTheme,
196
- apps: configApps,
197
- modules: configModules,
198
- desktopRuntime
199
- } = splitDesktopUserConfig(
200
- clientConfig,
201
- resolvedConfig.file
202
- );
203
- clientConfig.theme = configTheme ?? clientConfig.theme;
204
- if (configApps) clientConfig.apps = configApps;
205
- if (configModules) clientConfig.modules = configModules;
206
- _nuxt.options.runtimeConfig.public.desktop = defu(
207
- desktopRuntime,
208
- { coreVersion: pkg.version }
209
- );
179
+ const configRecord = clientConfig;
180
+ warnDesktopConfigKeys(configRecord, resolvedConfig.file);
181
+ const desktop = defu(configRecord, { coreVersion: pkg.version });
182
+ _nuxt.options.runtimeConfig.public.desktop = desktop;
210
183
  {
211
- if (clientConfig.theme) {
212
- await installModule(clientConfig.theme);
184
+ if (desktop.theme) {
185
+ try {
186
+ await installDesktopPackage(_nuxt, desktop.theme, desktop);
187
+ } catch (e) {
188
+ const msg = e instanceof Error ? e.message : String(e);
189
+ console.warn(`[@owdproject/core] Warning: Could not load theme "${desktop.theme}". Details: ${msg}`);
190
+ }
213
191
  }
214
- if (clientConfig.modules && Array.isArray(clientConfig.modules)) {
215
- for (const modulePath of clientConfig.modules) {
216
- await installModule(modulePath);
192
+ if (Array.isArray(desktop.modules)) {
193
+ for (const modulePath of desktop.modules) {
194
+ try {
195
+ await installDesktopPackage(_nuxt, modulePath, desktop);
196
+ } catch (e) {
197
+ const msg = e instanceof Error ? e.message : String(e);
198
+ console.warn(`[@owdproject/core] Warning: Could not load module "${modulePath}". Details: ${msg}`);
199
+ }
217
200
  }
218
201
  }
219
- if (clientConfig.apps && Array.isArray(clientConfig.apps)) {
220
- for (const appPath of clientConfig.apps) {
221
- await installModule(appPath);
202
+ if (Array.isArray(desktop.apps)) {
203
+ for (const appPath of desktop.apps) {
204
+ try {
205
+ await installDesktopPackage(_nuxt, appPath, desktop);
206
+ } catch (e) {
207
+ const msg = e instanceof Error ? e.message : String(e);
208
+ console.warn(`[@owdproject/core] Warning: Could not load app "${appPath}". Details: ${msg}`);
209
+ }
222
210
  }
223
211
  }
224
212
  }
225
213
  _nuxt.options.appConfig.desktop = _nuxt.options.runtimeConfig.public.desktop;
226
- {
227
- const tailwindPaths = _nuxt.options.runtimeConfig.app.owd?.tailwindPaths || [];
228
- tailwindPaths.push("./runtime/components/**/*.{vue,mjs,ts}");
229
- _nuxt.options.tailwindcss = _nuxt.options.tailwindcss || {};
230
- _nuxt.options.tailwindcss.config = _nuxt.options.tailwindcss.config || {};
231
- _nuxt.options.tailwindcss.config.content = tailwindPaths;
232
- await installModule("@nuxtjs/tailwindcss", {
233
- viewer: false
234
- });
235
- }
236
214
  {
237
215
  _nuxt.hook("vite:extendConfig", (viteConfig) => {
238
216
  viteConfig.css = viteConfig.css || {};
@@ -240,6 +218,11 @@ const module$1 = defineNuxtModule({
240
218
  viteConfig.css.preprocessorOptions.scss = {
241
219
  api: "modern-compiler"
242
220
  };
221
+ viteConfig.optimizeDeps = viteConfig.optimizeDeps || {};
222
+ viteConfig.optimizeDeps.include = viteConfig.optimizeDeps.include || [];
223
+ if (resolvedNanoid && !viteConfig.optimizeDeps.include.includes(resolvedNanoid)) {
224
+ viteConfig.optimizeDeps.include.push(resolvedNanoid);
225
+ }
243
226
  });
244
227
  }
245
228
  {
@@ -248,13 +231,16 @@ const module$1 = defineNuxtModule({
248
231
  {
249
232
  addComponentsDir({
250
233
  path: resolve("./runtime/components"),
251
- prefix: "",
234
+ prefix: "Desktop",
252
235
  pathPrefix: false,
253
236
  global: true
254
237
  });
255
238
  }
256
239
  {
257
240
  addPlugin(resolve("./runtime/plugins/resize.client.ts"));
241
+ addPlugin(
242
+ resolve("./runtime/plugins/01.desktop-shell-init.client.ts")
243
+ );
258
244
  addPlugin(
259
245
  resolve("./runtime/plugins/02.desktop-register-desktop-apps.client.ts")
260
246
  );
package/index.ts CHANGED
@@ -1,5 +1,8 @@
1
+ export { defineDesktopApp } from './kit/defineDesktopApp'
1
2
  export {
2
- defineDesktopApp,
3
3
  defineDesktopConfig,
4
- } from './runtime/utils/utilDesktop'
5
- export { registerTailwindPath } from './runtime/utils/utilApp'
4
+ defineDesktopModule,
5
+ defineDesktopTheme,
6
+ mergeDesktopExtensionConfig,
7
+ setDesktopExtensionConfig,
8
+ } from './kit/authoring'