@owdproject/core 3.0.0-alpha.8 → 3.1.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 (34) hide show
  1. package/.editorconfig +12 -0
  2. package/README.md +21 -2
  3. package/eslint.config.mjs +30 -0
  4. package/module.ts +176 -0
  5. package/package.json +21 -19
  6. package/runtime/components/Core/Desktop/CoreDesktop.vue +1 -1
  7. package/runtime/components/Core/Window/CoreWindow.vue +2 -2
  8. package/runtime/core/controllers/ApplicationController.ts +20 -14
  9. package/runtime/core/controllers/WindowController.ts +2 -2
  10. package/runtime/core/managers/ApplicationManager.ts +2 -2
  11. package/runtime/core/managers/DesktopManager.ts +2 -2
  12. package/runtime/core/managers/TerminalManager.ts +1 -1
  13. package/runtime/stores/storeApplicationMeta.ts +11 -0
  14. package/runtime/{composables/useApplicationState.ts → stores/storeApplicationWindows.ts} +3 -6
  15. package/runtime/stores/storeDesktop.ts +3 -3
  16. package/runtime/stores/storeDesktopVolume.ts +3 -3
  17. package/runtime/stores/storeDesktopWindow.ts +3 -3
  18. package/runtime/stores/storeDesktopWorkspace.ts +3 -3
  19. package/runtime/utils/{utilsApp.ts → utilApp.ts} +5 -6
  20. package/runtime/utils/{utilsCommon.ts → utilCommon.ts} +2 -2
  21. package/test/basic.test.ts +15 -0
  22. package/test/fixtures/basic/app.vue +6 -0
  23. package/test/fixtures/basic/nuxt.config.ts +7 -0
  24. package/test/fixtures/basic/package.json +5 -0
  25. package/tsconfig.app.json +31 -0
  26. package/tsconfig.json +11 -2
  27. package/tsconfig.spec.json +37 -0
  28. package/types/{owd.d.ts → index.d.ts} +11 -1
  29. package/vitest.config.ts +24 -0
  30. package/index.ts +0 -191
  31. /package/runtime/utils/{utilsDebug.ts → utilDebug.ts} +0 -0
  32. /package/runtime/utils/{utilsDesktop.ts → utilDesktop.ts} +0 -0
  33. /package/runtime/utils/{utilsTerminal.ts → utilTerminal.ts} +0 -0
  34. /package/runtime/utils/{utilsWindow.ts → utilWindow.ts} +0 -0
package/.editorconfig ADDED
@@ -0,0 +1,12 @@
1
+ root = true
2
+
3
+ [*]
4
+ indent_size = 2
5
+ indent_style = space
6
+ end_of_line = lf
7
+ charset = utf-8
8
+ trim_trailing_whitespace = true
9
+ insert_final_newline = true
10
+
11
+ [*.md]
12
+ trim_trailing_whitespace = false
package/README.md CHANGED
@@ -6,6 +6,11 @@
6
6
  A framework for building web-based desktop experiences.
7
7
  </h3>
8
8
 
9
+ [![npm version][npm-version-src]][npm-version-href]
10
+ [![npm downloads][npm-downloads-src]][npm-downloads-href]
11
+ [![License][license-src]][license-href]
12
+ [![Nuxt][nuxt-src]][nuxt-href]
13
+
9
14
  ## Overview
10
15
  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.
11
16
 
@@ -92,7 +97,7 @@ Then specify the path theme in `owd.config.ts`:
92
97
 
93
98
  ```typescript
94
99
  // owd.config.ts
95
- import {defineDesktopConfig} from "@owdproject/core/runtime/utils/utilsDesktop"
100
+ import {defineDesktopConfig} from "@owdproject/core/runtime/utils/utilDesktop"
96
101
 
97
102
  export default defineDesktopConfig({
98
103
  theme: '@owdproject/theme-gnome', // define here the theme you just installed
@@ -145,4 +150,18 @@ Open Web Desktop is a vast project. The code has been totally rewritten and is n
145
150
 
146
151
  ## License
147
152
 
148
- Open Web Desktop is released under the [GNU General Public License v3](LICENSE).
153
+ Open Web Desktop is released under the [GNU General Public License v3](LICENSE).
154
+
155
+
156
+ <!-- Badges -->
157
+ [npm-version-src]: https://img.shields.io/npm/v/my-module/latest.svg?style=flat&colorA=020420&colorB=00DC82
158
+ [npm-version-href]: https://npmjs.com/package/my-module
159
+
160
+ [npm-downloads-src]: https://img.shields.io/npm/dm/my-module.svg?style=flat&colorA=020420&colorB=00DC82
161
+ [npm-downloads-href]: https://npm.chart.dev/my-module
162
+
163
+ [license-src]: https://img.shields.io/npm/l/my-module.svg?style=flat&colorA=020420&colorB=00DC82
164
+ [license-href]: https://npmjs.com/package/my-module
165
+
166
+ [nuxt-src]: https://img.shields.io/badge/Nuxt-020420?logo=nuxt.js
167
+ [nuxt-href]: https://nuxt.com
@@ -0,0 +1,30 @@
1
+ import { FlatCompat } from '@eslint/eslintrc';
2
+ import { dirname } from 'path';
3
+ import { fileURLToPath } from 'url';
4
+ import js from '@eslint/js';
5
+ import baseConfig from '../../eslint.config.mjs';
6
+ const compat = new FlatCompat({
7
+ baseDirectory: dirname(fileURLToPath(import.meta.url)),
8
+ recommendedConfig: js.configs.recommended,
9
+ });
10
+
11
+ export default [
12
+ ...baseConfig,
13
+ {
14
+ files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx', '**/*.vue'],
15
+ // Override or add rules here
16
+ rules: {},
17
+ },
18
+ //...compat.extends('@nuxt/eslint-config'),
19
+ {
20
+ files: ['**/*.vue'],
21
+ languageOptions: {
22
+ parserOptions: {
23
+ parser: await import('@typescript-eslint/parser'),
24
+ },
25
+ },
26
+ },
27
+ {
28
+ ignores: ['.nuxt/**', '.output/**', 'node_modules'],
29
+ },
30
+ ];
package/module.ts ADDED
@@ -0,0 +1,176 @@
1
+ import {defineNuxtModule, createResolver, addComponentsDir, addImportsDir, installModule, addPlugin} from '@nuxt/kit'
2
+ import {deepMerge} from './runtime/utils/utilCommon'
3
+ import pkg from './package.json'
4
+
5
+ export default defineNuxtModule({
6
+ meta: {
7
+ name: 'owd-core',
8
+ },
9
+ async setup(_options, _nuxt) {
10
+ const {resolve} = createResolver(import.meta.url)
11
+
12
+ // set core version to runtime config
13
+
14
+ const desktopConfig = (await import(_nuxt.options.rootDir + '/owd.config.ts')).default
15
+
16
+ // set core version to runtime config
17
+
18
+ _nuxt.options.runtimeConfig.public.coreVersion = pkg.version
19
+
20
+ {
21
+
22
+ // install open web desktop theme
23
+
24
+ if (desktopConfig.theme) {
25
+ await installModule(desktopConfig.theme)
26
+ }
27
+
28
+ // install open web desktop modules
29
+
30
+ if (desktopConfig.modules) {
31
+ for (const modulePath of desktopConfig.modules) {
32
+ await installModule(modulePath)
33
+ }
34
+ }
35
+
36
+ // install open web desktop apps
37
+
38
+ if (desktopConfig.apps) {
39
+ for (const appPath of desktopConfig.apps) {
40
+ await installModule(appPath)
41
+ }
42
+ }
43
+
44
+ // assign open web desktop config to runtime config
45
+ _nuxt.options.runtimeConfig.public.desktop = deepMerge(
46
+ _nuxt.options.runtimeConfig.public.desktop,
47
+ desktopConfig
48
+ )
49
+
50
+ }
51
+
52
+ {
53
+
54
+ // install primevue
55
+
56
+ _nuxt.options.primevue = _nuxt.options.primevue || {};
57
+ _nuxt.options.primevue.options = _nuxt.options.primevue.options || {};
58
+ _nuxt.options.primevue.options.theme = _nuxt.options.primevue.options.theme || {};
59
+
60
+ await installModule("@primevue/nuxt-module")
61
+
62
+ }
63
+
64
+ {
65
+
66
+ // install tailwind
67
+
68
+ const tailwindPaths = _nuxt.options.runtimeConfig.app.owd?.tailwindPaths || []
69
+ tailwindPaths.push('./runtime/components/**/*.{vue,mjs,ts}') // Aggiungi sempre questo al core
70
+
71
+ _nuxt.options.tailwindcss = _nuxt.options.tailwindcss || {}
72
+ _nuxt.options.tailwindcss.config = _nuxt.options.tailwindcss.config || {}
73
+ // @ts-ignore
74
+ _nuxt.options.tailwindcss.config.content = tailwindPaths
75
+
76
+ await installModule('@nuxtjs/tailwindcss', {
77
+ viewer: false,
78
+ })
79
+
80
+ }
81
+
82
+ {
83
+
84
+ // install pinia
85
+
86
+ await installModule("@pinia/nuxt")
87
+
88
+ }
89
+
90
+ {
91
+
92
+ // install @nuxt/fonts
93
+
94
+ await installModule("@nuxt/fonts")
95
+
96
+ }
97
+
98
+ {
99
+
100
+ // install @nuxt/icon
101
+
102
+ await installModule("@nuxt/icon", {
103
+ clientBundle: {
104
+ scan: true,
105
+ sizeLimitKb: 256,
106
+ },
107
+ })
108
+
109
+ }
110
+
111
+ {
112
+
113
+ // install @vueuse/nuxt
114
+
115
+ await installModule("@vueuse/nuxt")
116
+
117
+ }
118
+
119
+ {
120
+
121
+ // install @nuxtjs/i18n
122
+
123
+ await installModule("@nuxtjs/i18n")
124
+
125
+ }
126
+
127
+ {
128
+
129
+ // configure scss for vite
130
+
131
+ _nuxt.hook('vite:extendConfig', (viteConfig) => {
132
+ viteConfig.css = viteConfig.css || {}
133
+ viteConfig.css.preprocessorOptions = viteConfig.css.preprocessorOptions || {}
134
+ viteConfig.css.preprocessorOptions.scss = {
135
+ api: 'modern-compiler',
136
+ }
137
+ })
138
+
139
+ }
140
+
141
+ {
142
+
143
+ // add css
144
+
145
+ _nuxt.options.css.push('sanitize.css')
146
+
147
+ }
148
+
149
+ {
150
+
151
+ // add components
152
+
153
+ addComponentsDir({
154
+ path: resolve("./runtime/components"),
155
+ prefix: "",
156
+ global: true,
157
+ })
158
+
159
+ }
160
+
161
+ {
162
+
163
+ // install plugins
164
+
165
+ addPlugin(resolve('./runtime/plugins/resize.client.ts'))
166
+
167
+ // add other files
168
+
169
+ addImportsDir(resolve('./runtime/composables'))
170
+ addImportsDir(resolve('./runtime/core'))
171
+ addImportsDir(resolve('./runtime/stores'))
172
+ addImportsDir(resolve('./runtime/utils'))
173
+
174
+ }
175
+ }
176
+ })
package/package.json CHANGED
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "name": "@owdproject/core",
3
- "version": "3.0.0-alpha.8",
4
- "description": "Open Web Desktop core",
3
+ "version": "3.1.0",
5
4
  "keywords": [
6
5
  "web",
7
6
  "desktop",
@@ -20,28 +19,31 @@
20
19
  },
21
20
  "license": "GPL-3.0-or-later",
22
21
  "author": {
23
- "name": "dxlliv",
24
- "url": "https://github.com/dxlliv"
22
+ "name": "Open Web Desktop Team",
23
+ "url": "https://github.com/owdproject"
25
24
  },
25
+ "type": "module",
26
+ "types": "types/index.d.ts",
26
27
  "dependencies": {
27
- "@nuxt/fonts": "^0.11.0",
28
- "@nuxt/icon": "^1.11.0",
29
- "@nuxtjs/i18n": "^9.4.0",
30
- "@nuxtjs/tailwindcss": "^6.13.2",
31
- "@pinia/nuxt": "^0.10.1",
32
- "@primeuix/themes": "^1.0.0",
33
- "@primevue/forms": "^4.3.3",
34
- "@primevue/nuxt-module": "^4.3.3",
35
- "@vueuse/components": "^13.0.0",
36
- "@vueuse/core": "^13.0.0",
37
- "@vueuse/nuxt": "^13.0.0",
38
- "memfs": "^4.17.0",
28
+ "@nuxt/kit": "^3.17.2",
29
+ "@nuxt/fonts": "^0.11.3",
30
+ "@nuxt/icon": "^1.12.0",
31
+ "@nuxtjs/i18n": "^9.5.4",
32
+ "@nuxtjs/tailwindcss": "^6.14.0",
33
+ "@pinia/nuxt": "^0.11.0",
34
+ "@primeuix/themes": "^1.1.1",
35
+ "@primevue/forms": "^4.3.4",
36
+ "@primevue/nuxt-module": "^4.3.4",
37
+ "@vueuse/components": "^13.1.0",
38
+ "@vueuse/core": "^13.1.0",
39
+ "@vueuse/nuxt": "^13.1.0",
40
+ "memfs": "^4.17.1",
39
41
  "mitt": "^3.0.1",
40
42
  "nanoid": "^5.1.5",
41
- "nuxt": "^3.16.1",
42
- "pinia": "^3.0.1",
43
+ "nuxt": "^3.17.2",
44
+ "pinia": "^3.0.2",
43
45
  "sanitize.css": "^13.0.0",
44
- "sass": "^1.86.0",
46
+ "sass": "^1.88.0",
45
47
  "vue-resizable": "^2.1.7"
46
48
  },
47
49
  "resolutions": {
@@ -80,4 +80,4 @@ const classes = computed(() => {
80
80
  height: 100dvh;
81
81
  user-select: none;
82
82
  }
83
- </style>
83
+ </style>
@@ -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
1
  import {useApplicationManager} from '../../composables/useApplicationManager'
2
2
  import {useDesktopWindowStore} from '../../stores/storeDesktopWindow'
3
- import {deepClone} from '../../utils/utilsCommon'
3
+ import {deepClone} from '../../utils/utilCommon'
4
4
  import {markRaw} from '@vue/reactivity'
5
5
  import {defineAsyncComponent} from "vue"
6
6
 
@@ -422,4 +422,4 @@ export class WindowController implements IWindowController {
422
422
  resetTitleOverride: this.resetTitleOverride.bind(this),
423
423
  }
424
424
  }
425
- }
425
+ }
@@ -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,4 +1,4 @@
1
- import {deepMerge} from "../../utils/utilsCommon"
1
+ import {deepMerge} from "../../utils/utilCommon"
2
2
 
3
3
  export class DesktopManager {
4
4
  public config: DesktopConfig = {} as DesktopConfig
@@ -34,4 +34,4 @@ export class DesktopManager {
34
34
  this.defaultApps = {...this.config.defaultApps}
35
35
  }
36
36
  }
37
- }
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
- import {ref} from "@vue/reactivity"
3
-
4
- export const useApplicationState = (appId: string) => {
5
- return defineStore(`owd/application/${appId}`, () => {
6
- const meta: Ref<any> = ref({})
2
+ import {ref} from "vue"
7
3
 
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: {
@@ -1,5 +1,5 @@
1
1
  import {defineStore} from "pinia"
2
- import {ref} from "@vue/reactivity"
2
+ import {ref} from "vue"
3
3
 
4
4
  export const useDesktopStore = defineStore('owd/desktop', () => {
5
5
  const state = ref<{
@@ -24,7 +24,7 @@ export const useDesktopStore = defineStore('owd/desktop', () => {
24
24
  master: 100,
25
25
  },
26
26
  window: {
27
- positionZ: 10
27
+ positionZ: 0
28
28
  }
29
29
  })
30
30
 
@@ -36,4 +36,4 @@ export const useDesktopStore = defineStore('owd/desktop', () => {
36
36
  persistedState: {
37
37
  persist: true
38
38
  },
39
- })
39
+ })
@@ -1,6 +1,6 @@
1
1
  import {defineStore} from "pinia"
2
- import {computed} from "@vue/reactivity"
3
- import {useDesktopStore} from "../stores/storeDesktop"
2
+ import {computed} from "vue"
3
+ import {useDesktopStore} from "./storeDesktop"
4
4
 
5
5
  export const useDesktopVolumeStore = defineStore('owd/desktop/volume', () => {
6
6
  const desktopStore = useDesktopStore()
@@ -15,4 +15,4 @@ export const useDesktopVolumeStore = defineStore('owd/desktop/volume', () => {
15
15
  master,
16
16
  setMasterVolume
17
17
  }
18
- })
18
+ })
@@ -1,6 +1,6 @@
1
1
  import {defineStore} from "pinia"
2
- import {computed} from "@vue/reactivity"
3
- import {useDesktopStore} from "../stores/storeDesktop"
2
+ import {computed} from "vue"
3
+ import {useDesktopStore} from "./storeDesktop"
4
4
 
5
5
  export const useDesktopWindowStore = defineStore('owd/desktop/window', () => {
6
6
  const desktopStore = useDesktopStore()
@@ -17,4 +17,4 @@ export const useDesktopWindowStore = defineStore('owd/desktop/window', () => {
17
17
  positionZ,
18
18
  incrementPositionZ
19
19
  }
20
- })
20
+ })
@@ -1,7 +1,7 @@
1
1
  import {defineStore} from "pinia"
2
- import {computed} from "@vue/reactivity"
2
+ import {computed} from "vue"
3
+ import {useDesktopStore} from "./storeDesktop"
3
4
  import {nanoid} from "nanoid";
4
- import {useDesktopStore} from "../stores/storeDesktop"
5
5
 
6
6
  export const useDesktopWorkspaceStore = defineStore('owd/desktop/workspace', () => {
7
7
  const desktopStore = useDesktopStore()
@@ -56,4 +56,4 @@ export const useDesktopWorkspaceStore = defineStore('owd/desktop/workspace', ()
56
56
  setOverview,
57
57
  setWorkspace,
58
58
  }
59
- })
59
+ })
@@ -23,11 +23,10 @@ export function normalizeApplicationConfig(config: ApplicationConfig): Applicati
23
23
  }
24
24
 
25
25
  export function registerTailwindPath(nuxt: Nuxt, path: string) {
26
- nuxt.options.runtimeConfig = nuxt.options.runtimeConfig || {}
27
- nuxt.options.runtimeConfig.owd = nuxt.options.runtimeConfig.owd || {}
28
- nuxt.options.runtimeConfig.owd.tailwindPaths = nuxt.options.runtimeConfig.owd.tailwindPaths || []
26
+ nuxt.options.runtimeConfig.app.owd = nuxt.options.runtimeConfig.app.owd || {}
27
+ nuxt.options.runtimeConfig.app.owd.tailwindPaths = nuxt.options.runtimeConfig.app.owd.tailwindPaths || []
29
28
 
30
- if (!nuxt.options.runtimeConfig.owd.tailwindPaths.includes(path)) {
31
- nuxt.options.runtimeConfig.owd.tailwindPaths.push(path)
29
+ if (!nuxt.options.runtimeConfig.app.owd.tailwindPaths.includes(path)) {
30
+ nuxt.options.runtimeConfig.app.owd.tailwindPaths.push(path)
32
31
  }
33
- }
32
+ }
@@ -2,7 +2,7 @@ export function deepClone<T>(obj: T): T {
2
2
  return JSON.parse(JSON.stringify(obj))
3
3
  }
4
4
 
5
- export function deepEqual(obj1, obj2) {
5
+ export function deepEqual(obj1: any, obj2: any) {
6
6
  const keys1 = Object.keys(obj1);
7
7
  const keys2 = Object.keys(obj2);
8
8
  if (keys1.length !== keys2.length) {
@@ -55,4 +55,4 @@ export function deepMerge<T>(target: T, source: Partial<T>): T {
55
55
  }
56
56
 
57
57
  return source as T
58
- }
58
+ }
@@ -0,0 +1,15 @@
1
+ import { fileURLToPath } from 'node:url'
2
+ import { describe, it, expect } from 'vitest'
3
+ import { setup, $fetch } from '@nuxt/test-utils/e2e'
4
+
5
+ describe('ssr', async () => {
6
+ await setup({
7
+ rootDir: fileURLToPath(new URL('./fixtures/basic', import.meta.url)),
8
+ })
9
+
10
+ it('renders the index page', async () => {
11
+ // Get response to a server-rendered page with `$fetch`.
12
+ const html = await $fetch('/')
13
+ expect(html).toContain('<div>basic</div>')
14
+ })
15
+ })
@@ -0,0 +1,6 @@
1
+ <template>
2
+ <div>basic</div>
3
+ </template>
4
+
5
+ <script setup>
6
+ </script>
@@ -0,0 +1,7 @@
1
+ import MyModule from '../../../module'
2
+
3
+ export default defineNuxtConfig({
4
+ modules: [
5
+ MyModule,
6
+ ],
7
+ })
@@ -0,0 +1,5 @@
1
+ {
2
+ "private": true,
3
+ "name": "basic",
4
+ "type": "module"
5
+ }
@@ -0,0 +1,31 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "outDir": "dist",
5
+ "rootDir": "src",
6
+ "jsx": "preserve",
7
+ "jsxImportSource": "vue",
8
+ "resolveJsonModule": true,
9
+ "tsBuildInfoFile": "dist/tsconfig.app.tsbuildinfo"
10
+ },
11
+ "include": [".nuxt/nuxt.d.ts", "runtime/**/*", "types/index.d.ts"],
12
+ "exclude": [
13
+ "out-tsc",
14
+ "dist",
15
+ "vite.config.ts",
16
+ "vite.config.mts",
17
+ "vitest.config.ts",
18
+ "vitest.config.mts",
19
+ "runtime/**/*.test.ts",
20
+ "runtime/**/*.spec.ts",
21
+ "runtime/**/*.test.tsx",
22
+ "runtime/**/*.spec.tsx",
23
+ "runtime/**/*.test.js",
24
+ "runtime/**/*.spec.js",
25
+ "runtime/**/*.test.jsx",
26
+ "runtime/**/*.spec.jsx",
27
+ "eslint.config.js",
28
+ "eslint.config.cjs",
29
+ "eslint.config.mjs"
30
+ ]
31
+ }
package/tsconfig.json CHANGED
@@ -1,3 +1,12 @@
1
1
  {
2
- "extends": "../.nuxt/tsconfig.json",
3
- }
2
+ "files": [],
3
+ "references": [
4
+ {
5
+ "path": "./tsconfig.app.json"
6
+ },
7
+ {
8
+ "path": "./tsconfig.spec.json"
9
+ },
10
+ ],
11
+ "extends": "../../tsconfig.base.json"
12
+ }
@@ -0,0 +1,37 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "outDir": "./out-tsc/vitest",
5
+ "types": [
6
+ "vitest/globals",
7
+ "vitest/importMeta",
8
+ "vite/client",
9
+ "node",
10
+ "vitest"
11
+ ],
12
+ "jsx": "preserve",
13
+ "jsxImportSource": "vue",
14
+ "resolveJsonModule": true
15
+ },
16
+ "include": [
17
+ ".nuxt/nuxt.d.ts",
18
+ "vite.config.ts",
19
+ "vite.config.mts",
20
+ "vitest.config.ts",
21
+ "vitest.config.mts",
22
+ "runtime/**/*.test.ts",
23
+ "runtime/**/*.spec.ts",
24
+ "runtime/**/*.test.tsx",
25
+ "runtime/**/*.spec.tsx",
26
+ "runtime/**/*.test.js",
27
+ "runtime/**/*.spec.js",
28
+ "runtime/**/*.test.jsx",
29
+ "runtime/**/*.spec.jsx",
30
+ "runtime/**/*.d.ts"
31
+ ],
32
+ "references": [
33
+ {
34
+ "path": "./tsconfig.app.json"
35
+ }
36
+ ]
37
+ }
@@ -1,3 +1,11 @@
1
+ declare module 'nuxt/schema' {
2
+ interface PublicRuntimeConfig {
3
+ owd: {
4
+ tailwindPaths: []
5
+ };
6
+ }
7
+ }
8
+
1
9
  interface IApplicationManager {
2
10
  apps: Map<string, IApplicationController>
3
11
 
@@ -333,4 +341,6 @@ interface DefaultAppsConfig {
333
341
  interface DefaultAppConfig {
334
342
  application: IApplicationController
335
343
  entry: ApplicationEntry
336
- }
344
+ }
345
+
346
+ export {}
@@ -0,0 +1,24 @@
1
+ /// <reference types='vitest' />
2
+ import { defineConfig } from 'vite';
3
+ import vue from '@vitejs/plugin-vue';
4
+
5
+ export default defineConfig(() => ({
6
+ root: __dirname,
7
+ cacheDir: '../../node_modules/.vite/packages/core',
8
+ plugins: [vue()],
9
+ // Uncomment this if you are using workers.
10
+ // worker: {
11
+ // plugins: [ nxViteTsPaths() ],
12
+ // },
13
+ test: {
14
+ watch: false,
15
+ globals: true,
16
+ environment: 'jsdom',
17
+ include: ['{src,tests}/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
18
+ reporters: ['default'],
19
+ coverage: {
20
+ reportsDirectory: './test-output/vitest/coverage',
21
+ provider: 'v8' as const,
22
+ },
23
+ },
24
+ }));
package/index.ts DELETED
@@ -1,191 +0,0 @@
1
- import {defineNuxtModule, createResolver, addComponentsDir, addImportsDir, installModule, addPlugin} from '@nuxt/kit'
2
- import {deepMerge} from '@owdproject/core/runtime/utils/utilsCommon'
3
- import pkg from './package.json'
4
-
5
- export default defineNuxtModule({
6
- meta: {
7
- name: 'owd-core',
8
- priority: 9999,
9
- },
10
- async setup(options, nuxt) {
11
- const {resolve} = createResolver(import.meta.url)
12
-
13
- const desktopConfig = (await import(nuxt.options.rootDir + '/owd.config.ts')).default
14
-
15
- // set core version to runtime config
16
-
17
- nuxt.options.runtimeConfig.public.coreVersion = pkg.version
18
-
19
- {
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
-
35
- // install open web desktop apps
36
-
37
- if (desktopConfig.apps) {
38
- for (const appPath of desktopConfig.apps) {
39
- await installModule(appPath)
40
- }
41
- }
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
-
49
- }
50
-
51
- {
52
-
53
- // install primevue
54
-
55
- nuxt.options.primevue = nuxt.options.primevue || {};
56
- nuxt.options.primevue.options = nuxt.options.primevue.options || {};
57
- nuxt.options.primevue.options.theme = nuxt.options.primevue.options.theme || {};
58
-
59
- await installModule("@primevue/nuxt-module")
60
-
61
- }
62
-
63
- {
64
-
65
- // install tailwind
66
-
67
- const tailwindPaths = nuxt.options.runtimeConfig?.owd?.tailwindPaths || []
68
- tailwindPaths.push('./runtime/components/**/*.{vue,mjs,ts}') // Aggiungi sempre questo al core
69
-
70
- nuxt.options.tailwindcss = nuxt.options.tailwindcss || {}
71
- nuxt.options.tailwindcss.config = nuxt.options.tailwindcss.config || {}
72
- // @ts-ignore
73
- nuxt.options.tailwindcss.config.content = tailwindPaths
74
-
75
- await installModule('@nuxtjs/tailwindcss', {
76
- viewer: false,
77
- })
78
-
79
- }
80
-
81
- {
82
-
83
- // install pinia
84
-
85
- await installModule("@pinia/nuxt")
86
-
87
- }
88
-
89
- {
90
-
91
- // install @nuxt/fonts
92
-
93
- await installModule("@nuxt/fonts")
94
-
95
- }
96
-
97
- {
98
-
99
- // install @nuxt/icon
100
-
101
- await installModule("@nuxt/icon", {
102
- clientBundle: {
103
- scan: true,
104
- sizeLimitKb: 256,
105
- },
106
- })
107
-
108
- }
109
-
110
- {
111
-
112
- // install @vueuse/nuxt
113
-
114
- await installModule("@vueuse/nuxt")
115
-
116
- }
117
-
118
- {
119
-
120
- // install @nuxtjs/i18n
121
-
122
- await installModule("@nuxtjs/i18n")
123
-
124
- }
125
-
126
- {
127
-
128
- // configure scss for vite
129
-
130
- nuxt.hook('vite:extendConfig', (viteConfig) => {
131
- viteConfig.css = viteConfig.css || {}
132
- viteConfig.css.preprocessorOptions = viteConfig.css.preprocessorOptions || {}
133
- viteConfig.css.preprocessorOptions.scss = {
134
- api: 'modern-compiler',
135
- }
136
- })
137
-
138
- }
139
-
140
- {
141
-
142
- // add css
143
-
144
- nuxt.options.css.push('sanitize.css')
145
-
146
- }
147
-
148
- {
149
-
150
- // add components
151
-
152
- addComponentsDir({
153
- path: resolve("./runtime/components"),
154
- prefix: "",
155
- global: true,
156
- })
157
-
158
- }
159
-
160
- {
161
-
162
- // install plugins
163
-
164
- addPlugin(resolve('./runtime/plugins/resize.client.ts'))
165
-
166
- // add other files
167
-
168
- addImportsDir(resolve('./runtime/composables'))
169
- addImportsDir(resolve('./runtime/core'))
170
- addImportsDir(resolve('./runtime/stores'))
171
- addImportsDir(resolve('./runtime/utils'))
172
-
173
- }
174
- }
175
- })
176
-
177
- export * from './runtime/composables/useAppEntries'
178
- export * from './runtime/composables/useApplicationManager'
179
- export * from './runtime/composables/useApplicationState'
180
- export * from './runtime/composables/useDesktopManager'
181
- export * from './runtime/composables/useTerminalManager'
182
- export * from './runtime/utils/utilsApp'
183
- export * from './runtime/utils/utilsCommon'
184
- export * from './runtime/utils/utilsDebug'
185
- export * from './runtime/utils/utilsDesktop'
186
- export * from './runtime/utils/utilsTerminal'
187
- export * from './runtime/utils/utilsWindow'
188
- export * from './runtime/stores/storeDesktop'
189
- export * from './runtime/stores/storeDesktopVolume'
190
- export * from './runtime/stores/storeDesktopWindow'
191
- export * from './runtime/stores/storeDesktopWorkspace'
File without changes
File without changes