@owdproject/core 3.0.0-alpha.7 → 3.0.0-alpha.9

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.
package/README.md CHANGED
@@ -56,52 +56,48 @@ export default defineDesktopConfig({
56
56
 
57
57
  ## Themes
58
58
  Themes allow you to customize the look and feel of your Open Web Desktop instance.
59
+ You can explore available themes, ranging from popular OS designs to fully custom creations, at [topics/owd-themes](https://github.com/topics/owd-themes).
59
60
 
60
61
  ### Install a new theme
61
- You can install a new theme by defining it as a Nuxt.js layer in `nuxt.config.ts`.
62
+ You can install a new theme by defining it in the `owd.config.ts` configuration.
62
63
  Themes can be loaded from a local path or directly from a GitHub repository.
63
64
 
64
- **1. Using a local theme:**
65
+ #### Using a local theme
65
66
 
66
- Clone it first in a folder of your project like `./desktop/theme/theme-win95`.
67
+ Clone it first in a folder of your project like `./desktop/theme/theme-gnome`.
67
68
 
68
69
  ```bash
69
- git clone git@github.com:owdproject/theme-win95.git ./desktop/theme/theme-win95
70
+ git clone git@github.com:owdproject/theme-gnome.git ./desktop/theme/theme-gnome
70
71
  ```
71
72
 
72
- Then specify the path theme in the `nuxt.config.ts` configuration:
73
+ Then specify the path theme in `owd.config.ts`:
73
74
 
74
75
  ```typescript
75
- // nuxt.config.ts
76
- export default defineNuxtConfig({
77
- modules: [
78
- "@owdproject/core",
79
- ],
80
-
81
- extends: [
82
- "./desktop/theme/theme-win95"
83
- ],
84
-
76
+ // owd.config.ts
77
+ export default defineDesktopConfig({
78
+ theme: './dev/themes/theme-gnome', // define here the theme you just cloned
79
+ apps: [
85
80
  ...
86
81
  ```
87
82
 
88
- **2. Using a theme from GitHub:**
83
+ #### Using a theme package
84
+
85
+ Use npm to install the theme package as a dependency of your Open Web Desktop client:
86
+
87
+ ```bash
88
+ npm install @owdproject/theme-gnome
89
+ ```
89
90
 
90
- To use a theme directly specifying a GitHub repository, use this format: `github:<username>/<repository>`:
91
+ Then specify the path theme in `owd.config.ts`:
91
92
 
92
93
  ```typescript
93
- // nuxt.config.ts
94
- export default defineNuxtConfig({
95
- modules: [
96
- "@owdproject/core",
97
- ],
98
-
99
- extends: [
100
- "github:owdproject/theme-gnome",
101
- { install: true }
102
- ],
103
-
104
- ...
94
+ // owd.config.ts
95
+ import {defineDesktopConfig} from "@owdproject/core/runtime/utils/utilDesktop"
96
+
97
+ export default defineDesktopConfig({
98
+ theme: '@owdproject/theme-gnome', // define here the theme you just installed
99
+ apps: [
100
+ ...
105
101
  ```
106
102
 
107
103
  ## Contributing
@@ -143,10 +139,10 @@ npm run dev
143
139
  This will launch Open Web Desktop in development mode, allowing you to test your changes and see them reflected in real-time.
144
140
  The dev server will be available at http://localhost:3000.
145
141
 
146
- ## Getting Involved
142
+ ## Sponsoring
147
143
 
148
144
  Open Web Desktop is a vast project. The code has been totally rewritten and is now actively being developed, but your support is what makes it all possible. If you're enjoying it and want to see more, consider donating. Your contribution helps keep the project alive and awesome.
149
145
 
150
- ### License
146
+ ## License
151
147
 
152
148
  Open Web Desktop is released under the [GNU General Public License v3](LICENSE).
package/index.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import {defineNuxtModule, createResolver, addComponentsDir, addImportsDir, installModule, addPlugin} from '@nuxt/kit'
2
- import {useDesktopManager} from './runtime/composables/useDesktopManager'
2
+ import {deepMerge} from '@owdproject/core/runtime/utils/utilCommon'
3
3
  import pkg from './package.json'
4
4
 
5
5
  export default defineNuxtModule({
@@ -9,24 +9,43 @@ export default defineNuxtModule({
9
9
  },
10
10
  async setup(options, nuxt) {
11
11
  const {resolve} = createResolver(import.meta.url)
12
- const desktopManager = useDesktopManager()
13
12
 
14
- await import(nuxt.options.rootDir + '/owd.config.ts')
13
+ const desktopConfig = (await import(nuxt.options.rootDir + '/owd.config.ts')).default
15
14
 
16
- // set core version to runtime variables
15
+ // set core version to runtime config
17
16
 
18
17
  nuxt.options.runtimeConfig.public.coreVersion = pkg.version
19
18
 
20
19
  {
21
20
 
21
+ // install open web desktop theme
22
+
23
+ if (desktopConfig.theme) {
24
+ await installModule(desktopConfig.theme)
25
+ }
26
+
27
+ // install open web desktop modules
28
+
29
+ if (desktopConfig.modules) {
30
+ for (const modulePath of desktopConfig.modules) {
31
+ await installModule(modulePath)
32
+ }
33
+ }
34
+
22
35
  // install open web desktop apps
23
36
 
24
- if (desktopManager.config.apps) {
25
- for (const appPath of desktopManager.config.apps) {
37
+ if (desktopConfig.apps) {
38
+ for (const appPath of desktopConfig.apps) {
26
39
  await installModule(appPath)
27
40
  }
28
41
  }
29
42
 
43
+ // assign open web desktop config to runtime config
44
+ nuxt.options.runtimeConfig.public.desktop = deepMerge(
45
+ nuxt.options.runtimeConfig.public.desktop,
46
+ desktopConfig
47
+ )
48
+
30
49
  }
31
50
 
32
51
  {
@@ -157,15 +176,16 @@ export default defineNuxtModule({
157
176
 
158
177
  export * from './runtime/composables/useAppEntries'
159
178
  export * from './runtime/composables/useApplicationManager'
160
- export * from './runtime/composables/useApplicationState'
161
179
  export * from './runtime/composables/useDesktopManager'
162
180
  export * from './runtime/composables/useTerminalManager'
163
- export * from './runtime/utils/utilsApp'
164
- export * from './runtime/utils/utilsCommon'
165
- export * from './runtime/utils/utilsDebug'
166
- export * from './runtime/utils/utilsDesktop'
167
- export * from './runtime/utils/utilsTerminal'
168
- export * from './runtime/utils/utilsWindow'
181
+ export * from './runtime/utils/utilApp'
182
+ export * from './runtime/utils/utilCommon'
183
+ export * from './runtime/utils/utilDebug'
184
+ export * from './runtime/utils/utilDesktop'
185
+ export * from './runtime/utils/utilTerminal'
186
+ export * from './runtime/utils/utilWindow'
187
+ export * from './runtime/stores/storeApplicationMeta'
188
+ export * from './runtime/stores/storeApplicationWindows'
169
189
  export * from './runtime/stores/storeDesktop'
170
190
  export * from './runtime/stores/storeDesktopVolume'
171
191
  export * from './runtime/stores/storeDesktopWindow'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@owdproject/core",
3
- "version": "3.0.0-alpha.7",
3
+ "version": "3.0.0-alpha.9",
4
4
  "description": "Open Web Desktop core",
5
5
  "keywords": [
6
6
  "web",
@@ -43,5 +43,8 @@
43
43
  "sanitize.css": "^13.0.0",
44
44
  "sass": "^1.86.0",
45
45
  "vue-resizable": "^2.1.7"
46
+ },
47
+ "resolutions": {
48
+ "vite": "^6.3.2"
46
49
  }
47
50
  }
@@ -1,5 +1,6 @@
1
1
  <script setup lang="ts">
2
2
  import {onMounted, onUnmounted} from "vue"
3
+ import {useRuntimeConfig} from "nuxt/app"
3
4
  import {computed, toRaw} from "@vue/reactivity"
4
5
  import {useDesktopManager} from "../../../composables/useDesktopManager"
5
6
  import {useApplicationManager} from "../../../composables/useApplicationManager"
@@ -10,16 +11,21 @@ const props = withDefaults(defineProps<{
10
11
  windows?: DesktopWindowsConfig
11
12
  systemBar?: DesktopSystemBarConfig
12
13
  dockBar?: DesktopDockBarConfig
14
+ workspaces?: DesktopWorkspacesConfig
13
15
  }>(), {
14
16
  windows: {
15
17
  position: 'fixed',
16
18
  },
17
19
  systemBar: {},
18
20
  dockBar: {},
21
+ workspaces: {},
19
22
  })
20
23
 
24
+ // todo move to owd initialization
25
+
21
26
  const desktopManager = useDesktopManager()
22
27
  const applicationManager = useApplicationManager()
28
+ const runtimeConfig = useRuntimeConfig()
23
29
 
24
30
  // create firsts workspaces if not available
25
31
  const desktopStore = useDesktopStore()
@@ -33,11 +39,14 @@ if (desktopStore.$persistedState) {
33
39
  desktopWorkspaceStore.setupWorkspaces()
34
40
  }
35
41
 
42
+ desktopManager.setConfig(runtimeConfig.public.desktop)
43
+
36
44
  // override desktop configurations
37
45
  desktopManager.setConfig({
38
46
  windows: toRaw(props.windows),
39
- systemBar: toRaw( props.systemBar),
47
+ systemBar: toRaw(props.systemBar),
40
48
  dockBar: toRaw(props.dockBar),
49
+ workspaces: toRaw(props.workspaces),
41
50
  })
42
51
 
43
52
  // desktop resize
@@ -1,8 +1,8 @@
1
1
  <script setup lang="ts">
2
2
  import {ref,provide} from 'vue'
3
3
  import {computed} from "@vue/reactivity"
4
- import {useDesktopManager} from "../../../composables/useDesktopManager"
5
- import {handleWindowControllerProps} from "../../../utils/utilsWindow"
4
+ import {useDesktopManager} from "@owdproject/core/runtime/composables/useDesktopManager"
5
+ import {handleWindowControllerProps} from "@owdproject/core/runtime/utils/utilWindow"
6
6
 
7
7
  const props = defineProps<{
8
8
  window?: IWindowController
@@ -1,10 +1,11 @@
1
1
  import {nanoid} from "nanoid";
2
2
  import {WindowController} from "./WindowController";
3
3
  import {useApplicationManager} from "../../composables/useApplicationManager"
4
- import {useApplicationState} from "../../composables/useApplicationState"
4
+ import {useApplicationWindowsStore} from "../../stores/storeApplicationWindows"
5
+ import {useApplicationMetaStore} from "../../stores/storeApplicationMeta"
5
6
  import {useTerminalManager} from "../../composables/useTerminalManager"
6
7
  import {useDesktopManager} from "../../composables/useDesktopManager"
7
- import {debugLog, debugError} from "../../utils/utilsDebug"
8
+ import {debugLog, debugError} from "../../utils/utilDebug"
8
9
  import {useDesktopWorkspaceStore} from "../../stores/storeDesktopWorkspace"
9
10
  import {reactive} from '@vue/reactivity'
10
11
 
@@ -31,7 +32,8 @@ export class ApplicationController implements IApplicationController {
31
32
 
32
33
  this.id = id
33
34
  this.config = config
34
- this.store = useApplicationState(id)
35
+ this.storeWindows = useApplicationWindowsStore(id)
36
+ this.storeMeta = useApplicationMetaStore(id)
35
37
  }
36
38
 
37
39
  public async initApplication(): Promise<void> {
@@ -67,12 +69,16 @@ export class ApplicationController implements IApplicationController {
67
69
 
68
70
  // store
69
71
 
70
- if (this.store.$persistedState) {
71
- await this.store.$persistedState.isReady()
72
+ if (this.storeWindows.$persistedState) {
73
+ await this.storeWindows.$persistedState.isReady()
74
+ }
75
+
76
+ if (this.storeMeta.$persistedState) {
77
+ await this.storeMeta.$persistedState.isReady()
72
78
  }
73
79
 
74
80
  // set default meta values
75
- this.store.meta = this.config.meta ?? {}
81
+ // this.storeMeta.meta = this.config.meta ?? {}
76
82
 
77
83
  // restore application state
78
84
  await this.restoreApplication()
@@ -94,7 +100,7 @@ export class ApplicationController implements IApplicationController {
94
100
  await this.config.onRestore(this)
95
101
  }
96
102
 
97
- if (!this.store.windows || Object.keys(this.store.windows).length === 0) {
103
+ if (!this.storeWindows.windows || Object.keys(this.storeWindows.windows).length === 0) {
98
104
  return false
99
105
  }
100
106
 
@@ -106,8 +112,8 @@ export class ApplicationController implements IApplicationController {
106
112
  }
107
113
 
108
114
  private restoreWindows() {
109
- Object.keys(this.store.windows).map(windowId => {
110
- const windowStore: WindowStoredState | undefined = this.store.windows[windowId]
115
+ Object.keys(this.storeWindows.windows).map(windowId => {
116
+ const windowStore: WindowStoredState | undefined = this.storeWindows.windows[windowId]
111
117
 
112
118
  if (windowStore) {
113
119
  this.openWindow(windowStore.model, windowStore, {isRestoring: true})
@@ -138,7 +144,7 @@ export class ApplicationController implements IApplicationController {
138
144
  ? window.scrollY + windowConfig.position.y
139
145
  : window.scrollY + centerY
140
146
 
141
- this.store.windows[windowId] = {
147
+ this.storeWindows.windows[windowId] = {
142
148
  model,
143
149
  state: {
144
150
  id: windowId,
@@ -153,7 +159,7 @@ export class ApplicationController implements IApplicationController {
153
159
  }
154
160
  }
155
161
 
156
- windowStoredState = this.store.windows[windowId]
162
+ windowStoredState = this.storeWindows.windows[windowId]
157
163
 
158
164
  } else {
159
165
 
@@ -186,7 +192,7 @@ export class ApplicationController implements IApplicationController {
186
192
  }
187
193
 
188
194
  public closeWindow(windowId: string) {
189
- delete this.store.windows[windowId];
195
+ delete this.storeWindows.windows[windowId];
190
196
  this.windows.delete(windowId);
191
197
 
192
198
  if (this.windows.size === 0) {
@@ -195,7 +201,7 @@ export class ApplicationController implements IApplicationController {
195
201
  }
196
202
 
197
203
  public closeAllWindows() {
198
- this.store.windows = {}
204
+ this.storeWindows.windows = {}
199
205
  this.windows.clear()
200
206
  }
201
207
 
@@ -210,7 +216,7 @@ export class ApplicationController implements IApplicationController {
210
216
  // meta
211
217
 
212
218
  get meta() {
213
- return this.store.meta
219
+ return this.storeMeta.meta
214
220
  }
215
221
 
216
222
  getMeta(key: string) {
@@ -1,6 +1,6 @@
1
- import {useApplicationManager} from '../../composables/useApplicationManager'
2
- import {useDesktopWindowStore} from '../../stores/storeDesktopWindow'
3
- import {deepClone} from '../../utils/utilsCommon'
1
+ import {useApplicationManager} from '@owdproject/core/runtime/composables/useApplicationManager'
2
+ import {useDesktopWindowStore} from '@owdproject/core/runtime/stores/storeDesktopWindow'
3
+ import {deepClone} from '@owdproject/core/runtime/utils/utilCommon'
4
4
  import {markRaw} from '@vue/reactivity'
5
5
  import {defineAsyncComponent} from "vue"
6
6
 
@@ -1,8 +1,8 @@
1
1
  import type {Reactive} from "@vue/reactivity"
2
2
  import {reactive, markRaw} from "@vue/reactivity"
3
3
  import {ApplicationController} from "../controllers/ApplicationController";
4
- import {normalizeApplicationConfig} from "../../utils/utilsApp"
5
- import {debugLog} from "../../utils/utilsDebug"
4
+ import {normalizeApplicationConfig} from "../../utils/utilApp"
5
+ import {debugLog} from "../../utils/utilDebug"
6
6
 
7
7
  export class ApplicationManager implements IApplicationManager {
8
8
  public apps = reactive(
@@ -1,7 +1,8 @@
1
- import {deepMerge} from "../../utils/utilsCommon"
1
+ import {deepMerge} from "@owdproject/core/runtime/utils/utilCommon"
2
2
 
3
3
  export class DesktopManager {
4
4
  public config: DesktopConfig = {} as DesktopConfig
5
+
5
6
  private defaultApps: DefaultAppsConfig = {}
6
7
 
7
8
  constructor() {
@@ -30,7 +31,7 @@ export class DesktopManager {
30
31
 
31
32
  private loadDefaultAppsFromConfig() {
32
33
  if (this.config.defaultApps) {
33
- this.defaultApps = { ...this.config.defaultApps }
34
+ this.defaultApps = {...this.config.defaultApps}
34
35
  }
35
36
  }
36
37
  }
@@ -1,5 +1,5 @@
1
1
  import {useApplicationManager} from "../../composables/useApplicationManager"
2
- import {debugLog} from "../../utils/utilsDebug"
2
+ import {debugLog} from "../../utils/utilDebug"
3
3
 
4
4
  export class TerminalManager {
5
5
  private commands: Map<string, TerminalCommand> = new Map()
@@ -0,0 +1,11 @@
1
+ import {defineStore} from "pinia"
2
+
3
+ export const useApplicationMetaStore = (appId: string, states: any = {}) => {
4
+ return defineStore(`owd/application/${appId}/meta`, () => {
5
+ return states
6
+ }, {
7
+ persistedState: {
8
+ persist: true
9
+ },
10
+ })
11
+ }
@@ -1,15 +1,12 @@
1
1
  import {defineStore} from "pinia"
2
2
  import {ref} from "@vue/reactivity"
3
3
 
4
- export const useApplicationState = (appId: string) => {
5
- return defineStore(`owd/application/${appId}`, () => {
6
- const meta: Ref<any> = ref({})
7
-
4
+ export const useApplicationWindowsStore = (appId: string) => {
5
+ return defineStore(`owd/application/${appId}/windows`, () => {
8
6
  const windows: Ref<{[windowId: string]: WindowStoredState}> = ref({})
9
7
 
10
8
  return {
11
9
  windows,
12
- meta,
13
10
  }
14
11
  }, {
15
12
  persistedState: {
@@ -7,7 +7,5 @@ export function defineDesktopApp(config: ApplicationConfig) {
7
7
  }
8
8
 
9
9
  export function defineDesktopConfig(config: DesktopConfig) {
10
- const desktopManager = useDesktopManager()
11
- desktopManager.setConfig(config)
12
- return true
10
+ return config
13
11
  }
package/types/owd.d.ts CHANGED
@@ -276,13 +276,17 @@ interface IDesktopManager {
276
276
  }
277
277
 
278
278
  interface DesktopConfig {
279
- name?: string
280
- compatibility?: string
279
+ theme?: string
280
+ modules?: string[]
281
281
  apps?: string[]
282
+
283
+ name?: string
282
284
  defaultApps?: DefaultAppsConfig
283
285
  features?: string[]
286
+
284
287
  systemBar?: DesktopSystemBarConfig
285
288
  dockBar?: DesktopDockBarConfig
289
+ workspaces?: DesktopWorkspacesConfig
286
290
  }
287
291
 
288
292
  interface DesktopWindowsConfig {
@@ -300,6 +304,10 @@ interface DesktopSystemBarConfig {
300
304
  startButton?: boolean
301
305
  }
302
306
 
307
+ interface DesktopWorkspacesConfig {
308
+ enabled?: boolean
309
+ }
310
+
303
311
  // TERMINAL
304
312
 
305
313
  type TerminalCommand = {
package/types/index.d.ts DELETED
@@ -1,9 +0,0 @@
1
- declare module 'nuxt/schema' {
2
- interface AppConfig {
3
- owd: {
4
- apps: string[]
5
- }
6
- }
7
- }
8
-
9
- export {}
File without changes
File without changes
File without changes
File without changes