@owdproject/core 3.0.0-alpha.1 → 3.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.
package/index.ts CHANGED
@@ -1,10 +1,155 @@
1
+ import {defineNuxtModule, createResolver, addComponentsDir, addImportsDir, installModule} from '@nuxt/kit'
2
+ import pkg from '../package.json'
3
+
4
+ export default defineNuxtModule({
5
+ meta: {
6
+ name: 'owd-core',
7
+ },
8
+ async setup(options, nuxt) {
9
+ const {resolve} = createResolver(import.meta.url);
10
+
11
+ // set core version to runtime variables
12
+
13
+ nuxt.options.runtimeConfig.public.coreVersion = pkg.version
14
+
15
+ // configure nuxt plugins
16
+
17
+ nuxt.options.primevue = nuxt.options.primevue || {};
18
+ nuxt.options.primevue.options = nuxt.options.primevue.options || {};
19
+ nuxt.options.primevue.options.theme = nuxt.options.primevue.options.theme || {};
20
+
21
+ {
22
+
23
+ // install tailwind
24
+
25
+ nuxt.options.modules.push('@nuxtjs/tailwindcss')
26
+ await installModule("@nuxtjs/tailwindcss", {
27
+ viewer: false,
28
+ })
29
+
30
+ }
31
+
32
+ {
33
+
34
+ // install primevue
35
+
36
+ nuxt.options.modules.push('@primevue/nuxt-module')
37
+ await installModule("@primevue/nuxt-module")
38
+
39
+ }
40
+
41
+ {
42
+
43
+ // install pinia
44
+
45
+ nuxt.options.modules.push('@pinia/nuxt')
46
+ await installModule("@pinia/nuxt")
47
+
48
+ }
49
+
50
+ {
51
+
52
+ // install @nuxt/fonts
53
+
54
+ nuxt.options.modules.push('@nuxt/fonts')
55
+ await installModule("@nuxt/fonts")
56
+
57
+ }
58
+
59
+ {
60
+
61
+ // install @nuxt/icon
62
+
63
+ nuxt.options.modules.push('@nuxt/icon')
64
+ await installModule("@nuxt/icon", {
65
+ clientBundle: {
66
+ scan: true,
67
+ sizeLimitKb: 256,
68
+ },
69
+ })
70
+
71
+ }
72
+
73
+ {
74
+
75
+ // install @vueuse/nuxt
76
+
77
+ nuxt.options.modules.push('@vueuse/nuxt')
78
+ await installModule("@vueuse/nuxt")
79
+
80
+ }
81
+
82
+ {
83
+
84
+ // install @nuxtjs/i18n
85
+
86
+ nuxt.options.modules.push('@nuxtjs/i18n')
87
+ await installModule("@nuxtjs/i18n")
88
+
89
+ }
90
+
91
+ {
92
+
93
+ // configure scss for vite
94
+
95
+ nuxt.hook('vite:extendConfig', (viteConfig) => {
96
+ viteConfig.css = viteConfig.css || {}
97
+ viteConfig.css.preprocessorOptions = viteConfig.css.preprocessorOptions || {}
98
+ viteConfig.css.preprocessorOptions.scss = {
99
+ api: 'modern-compiler',
100
+ }
101
+ })
102
+
103
+ }
104
+
105
+ {
106
+
107
+ // add css
108
+
109
+ nuxt.options.css.push('sanitize.css')
110
+
111
+ }
112
+
113
+ {
114
+
115
+ // add runtime components
116
+
117
+ addComponentsDir({
118
+ path: resolve("./runtime/components"),
119
+ prefix: "",
120
+ global: true,
121
+ })
122
+
123
+ }
124
+
125
+ {
126
+
127
+ nuxt.options.plugins.push(
128
+ resolve('./runtime/plugins/resize.client.ts'),
129
+ )
130
+
131
+ addImportsDir(resolve('./runtime/composables'))
132
+ addImportsDir(resolve('./runtime/core'))
133
+ addImportsDir(resolve('./runtime/stores'))
134
+ addImportsDir(resolve('./runtime/utils'))
135
+
136
+ }
137
+
138
+ }
139
+ })
140
+
1
141
  export * from './runtime/composables/useAppEntries'
2
142
  export * from './runtime/composables/useApplicationManager'
3
143
  export * from './runtime/composables/useApplicationState'
4
144
  export * from './runtime/composables/useDesktopManager'
5
145
  export * from './runtime/composables/useTerminalManager'
146
+ export * from './runtime/utils/utilsApp'
6
147
  export * from './runtime/utils/utilsCommon'
7
148
  export * from './runtime/utils/utilsDebug'
8
149
  export * from './runtime/utils/utilsDesktop'
9
150
  export * from './runtime/utils/utilsTerminal'
10
- export * from './runtime/utils/utilsWindow'
151
+ export * from './runtime/utils/utilsWindow'
152
+ export * from './runtime/stores/storeDesktop'
153
+ export * from './runtime/stores/storeDesktopVolume'
154
+ export * from './runtime/stores/storeDesktopWindow'
155
+ export * from './runtime/stores/storeDesktopWorkspace'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@owdproject/core",
3
- "version": "3.0.0-alpha.1",
3
+ "version": "3.0.0-alpha.3",
4
4
  "description": "Open Web Desktop core",
5
5
  "keywords": [
6
6
  "web",
@@ -12,6 +12,5 @@
12
12
  right: 0;
13
13
  bottom: 0;
14
14
  background-color: var(--owd-background-color);
15
- z-index: -1;
16
15
  }
17
16
  </style>
@@ -116,7 +116,6 @@ const classes = computed(() => {
116
116
  :class="classes"
117
117
  :width="windowController?.state.size?.width"
118
118
  :height="windowController?.state.size?.height"
119
- :min-width="windowController?.state.size?.minWidth"
120
119
  :min-height="windowController?.state.size?.minHeight"
121
120
  :max-width="windowController?.state.size?.maxWidth"
122
121
  :max-height="windowController?.state.size?.maxHeight"
@@ -12,7 +12,7 @@ const classes = computed(() => {
12
12
  }
13
13
 
14
14
  if (windowContent?.padded) {
15
- list.push('p-2')
15
+ list.push('owd-window__content--padded')
16
16
  }
17
17
 
18
18
  return list
@@ -1,21 +1,36 @@
1
1
  import {useApplicationManager} from './useApplicationManager'
2
2
  import {computed} from "@vue/reactivity"
3
3
 
4
+ type SortBy = 'title' | 'category' | ((a: ApplicationEntryWithInherited, b: ApplicationEntryWithInherited) => number)
5
+ type Visibility = 'primary' | 'all' | ((entry: ApplicationEntryWithInherited) => boolean)
6
+
4
7
  export function useAppEntries() {
5
8
  const applicationManager = useApplicationManager()
6
9
 
7
- const sortedAppEntries = function(sortBy: 'title'): Ref<ApplicationEntryWithInherited[]> {
10
+ const sortedAppEntries = function(
11
+ sortBy: SortBy = 'title',
12
+ visibility: Visibility = 'primary'
13
+ ): Ref<ApplicationEntryWithInherited[]> {
8
14
  return computed(() => {
9
15
  const currentEntries = [...applicationManager.appsEntries]
10
16
 
11
- if (sortBy === 'title') {
12
- currentEntries.sort((a, b) => (a.title || '').localeCompare(b.title || ''))
13
- } else if (sortBy === 'category') {
14
- currentEntries.sort((a, b) => (a.category || '').localeCompare(b.category || ''))
15
- }
16
- return currentEntries
17
+ // filtering
18
+ const filtered = typeof visibility === 'function'
19
+ ? currentEntries.filter(visibility)
20
+ : visibility === 'primary'
21
+ ? currentEntries.filter(e => e.visibility !== 'secondary')
22
+ : currentEntries
23
+
24
+ // sorting
25
+ const sorted = typeof sortBy === 'function'
26
+ ? filtered.sort(sortBy)
27
+ : sortBy === 'title'
28
+ ? filtered.sort((a, b) => (a.title || '').localeCompare(b.title || ''))
29
+ : filtered.sort((a, b) => (a.category || '').localeCompare(b.category || ''))
30
+
31
+ return sorted
17
32
  })
18
33
  }
19
34
 
20
35
  return { sortedAppEntries }
21
- }
36
+ }
@@ -189,7 +189,6 @@ export class ApplicationController implements IApplicationController {
189
189
  // meta
190
190
 
191
191
  get meta() {
192
- console.log('META', this.id, this.store.meta)
193
192
  return this.store.meta
194
193
  }
195
194
 
@@ -203,7 +202,7 @@ export class ApplicationController implements IApplicationController {
203
202
 
204
203
  // commands
205
204
 
206
- async execCommand(input: string): Promise<CommandOutput | void> {
207
- await this.applicationManager.execAppCommand(this.id, input)
205
+ async execCommand(command: string): Promise<CommandOutput | void> {
206
+ await this.applicationManager.execAppCommand(this.id, command)
208
207
  }
209
208
  }
@@ -1,6 +1,7 @@
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"
4
5
  import {debugLog} from "../../utils/utilsDebug"
5
6
 
6
7
  export class ApplicationManager implements IApplicationManager {
@@ -34,18 +35,12 @@ export class ApplicationManager implements IApplicationManager {
34
35
  return this.apps.get(id)!;
35
36
  }
36
37
 
37
- if (!config.version) config.version = 'unknown'
38
- if (!config.description) config.description = ''
39
- if (!config.category) config.category = 'other'
40
-
41
- const applicationConfig = markRaw(config)
38
+ const normalizedConfig = normalizeApplicationConfig(config)
39
+ const applicationConfig = markRaw(normalizedConfig)
42
40
 
43
41
  const applicationController: IApplicationController = new ApplicationController(id, applicationConfig)
44
-
45
- // finalize application setup doing other async operations
46
42
  await applicationController.initApplication()
47
43
 
48
- // define application
49
44
  this.apps.set(id, applicationController)
50
45
 
51
46
  return applicationController
@@ -98,8 +93,6 @@ export class ApplicationManager implements IApplicationManager {
98
93
 
99
94
  const entry: ApplicationEntry = applicationController.config.entries[entryKey]!
100
95
 
101
- console.log('dio cane', entry)
102
-
103
96
  await this.execAppCommand(applicationController.id, entry.command)
104
97
  }
105
98
 
@@ -116,17 +109,16 @@ export class ApplicationManager implements IApplicationManager {
116
109
 
117
110
  const applicationController: IApplicationController = this.apps.get(id)!
118
111
 
119
- if (applicationController.config.commands && !applicationController.config.commands.hasOwnProperty(command)) {
112
+ const commandSplit: string[] = command.split(" ")
113
+ const baseCommand = commandSplit[0] as keyof typeof applicationController.config.commands
114
+
115
+ if (applicationController.config.commands && !applicationController.config.commands.hasOwnProperty(baseCommand)) {
120
116
  throw Error(`App command "${command}" is not defined in ${id} application`);
121
117
  }
122
118
 
123
- const commandSplit: string[] = command.split(" ")
124
-
125
- const commandFn: any = applicationController.config.commands![
126
- commandSplit[0] as keyof typeof applicationController.config.commands
127
- ]
119
+ const commandFn: any = applicationController.config.commands![baseCommand]
128
120
 
129
- commandFn(applicationController, commandSplit.shift())
121
+ commandFn(applicationController, commandSplit.slice(1))
130
122
 
131
123
  applicationController.setRunning(true)
132
124
 
@@ -168,6 +160,7 @@ export class ApplicationManager implements IApplicationManager {
168
160
  title: entry.title !== undefined ? entry.title : applicationController.config.title,
169
161
  icon: entry.icon !== undefined ? entry.icon : applicationController.config.icon,
170
162
  category: entry.category !== undefined ? entry.category : applicationController.config.category,
163
+ visibility: entry.visibility,
171
164
  command: entry.command
172
165
  })
173
166
  }
@@ -12,6 +12,7 @@ export const useDesktopVolumeStore = defineStore('owd/desktop/volume', () => {
12
12
  }
13
13
 
14
14
  return {
15
- master
15
+ master,
16
+ setMasterVolume
16
17
  }
17
18
  })
@@ -0,0 +1,21 @@
1
+ export function normalizeApplicationConfig(config: ApplicationConfig): ApplicationConfig {
2
+ const normalizedEntries: Record<string, ApplicationEntry> = {}
3
+
4
+ for (const [key, entry] of Object.entries(config.entries)) {
5
+ normalizedEntries[key] = {
6
+ ...entry,
7
+ title: entry.title ?? config.title,
8
+ icon: entry.icon ?? config.icon,
9
+ category: entry.category ?? config.category,
10
+ visibility: entry.visibility ?? 'primary',
11
+ }
12
+ }
13
+
14
+ return {
15
+ ...config,
16
+ version: config.version ?? 'unknown',
17
+ description: config.description ?? '',
18
+ category: config.category ?? 'other',
19
+ entries: normalizedEntries,
20
+ }
21
+ }
package/types/owd.d.ts CHANGED
@@ -1,20 +1,27 @@
1
1
  interface IApplicationManager {
2
2
  apps: Map<string, IApplicationController>
3
- appsRunning: Reactive<IApplicationController>
4
3
 
5
4
  importApps()
6
5
 
7
6
  get appsEntries(): Reactive<ApplicationEntry[]>
8
- get windowsOpened(): Reactive<IWindowController>
7
+
8
+ get appsRunning(): Reactive<IApplicationController[]>
9
+
10
+ get windowsOpened(): Reactive<IWindowController[]>
11
+
9
12
  get appCategories(): string[]
13
+
10
14
  get appsByCategory(): { [category: string]: IApplicationController[] }
11
15
 
12
16
  defineApp(appId: string, config: ApplicationConfig): Promise<IApplicationController>
17
+
13
18
  closeApp(id: string): void
14
19
 
20
+ launchAppEntry(appId: string, entry: string): Promise<IApplicationController | undefined>
15
21
  execAppCommand(appId: string, command: string): Promise<IApplicationController | undefined>
16
22
 
17
23
  isAppDefined(id: string): boolean
24
+
18
25
  isAppRunning(id: string): boolean
19
26
  }
20
27
 
@@ -36,8 +43,11 @@ interface ApplicationConfig {
36
43
  commands?: { [key: string]: ApplicationCommand }
37
44
 
38
45
  onReady?(app: IApplicationController): void | Promise<void>
46
+
39
47
  onLaunch?(app: IApplicationController): void | Promise<void>
48
+
40
49
  onRestore?(app: IApplicationController): void | Promise<void>
50
+
41
51
  onClose?(app: IApplicationController): void | Promise<void>
42
52
  }
43
53
 
@@ -48,17 +58,21 @@ interface ApplicationConfigProvide {
48
58
 
49
59
  type IApplicationMeta = { [key: string]: any }
50
60
 
51
- interface IApplicationController {
61
+ interface sIApplicationController {
52
62
  id: string
53
63
  config: ApplicationConfig
64
+
54
65
  get meta(): { [key: string]: any }
66
+
55
67
  store: Pinia
56
68
  windows: Reactive<Map<string, IWindowController>>
57
69
 
58
70
  isRunning: boolean
71
+
59
72
  setRunning(value: boolean): void
60
73
 
61
74
  initApplication(): Promise<void>
75
+
62
76
  restoreApplication(): Promise<boolean>
63
77
 
64
78
  openWindow(model: string, windowStoredState?: WindowStoredState, meta?: {
@@ -66,8 +80,11 @@ interface IApplicationController {
66
80
  })
67
81
 
68
82
  closeWindow(windowId: string): void
83
+
69
84
  closeAllWindows(): void
70
85
 
86
+ execCommand(command: string)
87
+
71
88
  get windowsOpened(): Reactive<Map<string, IWindowController>>
72
89
  }
73
90
 
@@ -78,11 +95,13 @@ interface IWindowController {
78
95
 
79
96
  config: WindowConfig
80
97
  override: WindowOverride
98
+
81
99
  get state(): WindowState
82
100
 
83
101
  // common
84
102
  get title(): string
85
- get icon(): string|undefined
103
+
104
+ get icon(): string | undefined
86
105
 
87
106
  // sizes
88
107
  get width(): WindowSizeValue
@@ -139,7 +158,7 @@ interface IWindowController {
139
158
  setWorkspace(workspaceId: string)
140
159
 
141
160
  // override
142
- setTitleOverride(title: string|undefined): void
161
+ setTitleOverride(title: string | undefined): void
143
162
  resetTitleOverride(): void
144
163
  }
145
164
  }
@@ -186,8 +205,8 @@ interface WindowStoredState {
186
205
  }
187
206
 
188
207
  interface WindowOverride {
189
- title?: undefined|string
190
- icon?: undefined|string
208
+ title?: undefined | string
209
+ icon?: undefined | string
191
210
  }
192
211
 
193
212
  interface WindowState {
@@ -240,25 +259,31 @@ interface WindowPosition {
240
259
  z?: number
241
260
  }
242
261
 
243
- type WindowSizeValue = number|string|undefined
262
+ type WindowSizeValue = number | string | undefined
244
263
 
245
264
  interface ApplicationEntry {
246
265
  title?: string
247
266
  icon?: string
248
267
  category?: string
268
+ visibility?: ApplicationEntryVisibility
249
269
  command: string | any
250
270
  }
251
271
 
272
+
252
273
  interface ApplicationEntryWithInherited extends ApplicationEntry {
253
274
  application: IApplicationController
275
+ visibility: ApplicationEntryVisibility
254
276
  }
255
277
 
278
+ type ApplicationEntryVisibility = 'primary' | 'secondary' | 'hidden'
279
+
256
280
  // DESKTOP
257
281
 
258
282
  interface IDesktopManager {
259
283
  defaultApps: DefaultAppsConfig
260
284
 
261
285
  getDefaultApp(feature: string)
286
+
262
287
  setDefaultApp(feature: string, application: IApplicationController, entry: ApplicationEntry)
263
288
  }
264
289
 
@@ -304,6 +329,7 @@ interface DefaultAppsConfig {
304
329
  terminal?: DefaultAppConfig
305
330
  browser?: DefaultAppConfig
306
331
  editor?: DefaultAppConfig
332
+
307
333
  [key: string]: DefaultAppConfig
308
334
  }
309
335
 
package/module/index.ts DELETED
@@ -1,144 +0,0 @@
1
- import {defineNuxtModule, createResolver, addComponentsDir, addImportsDir, installModule} from '@nuxt/kit'
2
- import pkg from '../package.json'
3
- import path from "path";
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 variables
13
-
14
- nuxt.options.runtimeConfig.public.coreVersion = pkg.version
15
-
16
- // configure nuxt plugins
17
-
18
- nuxt.options.primevue = nuxt.options.primevue || {};
19
- nuxt.options.primevue.options = nuxt.options.primevue.options || {};
20
- nuxt.options.primevue.options.theme = nuxt.options.primevue.options.theme || {};
21
- nuxt.options.primevue.options.theme.options = {
22
- cssLayer: false
23
- };
24
-
25
- {
26
-
27
- // install tailwind
28
-
29
- nuxt.options.modules.push('@nuxtjs/tailwindcss')
30
- await installModule("@nuxtjs/tailwindcss", {
31
- viewer: false,
32
- //configPath: resolve(runtimeDir, "tailwind.config"),
33
- })
34
-
35
- }
36
-
37
- {
38
-
39
- // install primevue
40
-
41
- nuxt.options.modules.push('@primevue/nuxt-module')
42
- await installModule("@primevue/nuxt-module")
43
-
44
- }
45
-
46
- {
47
-
48
- // install pinia
49
-
50
- nuxt.options.modules.push('@pinia/nuxt')
51
- await installModule("@pinia/nuxt")
52
-
53
- }
54
-
55
- {
56
-
57
- // install @nuxt/fonts
58
-
59
- nuxt.options.modules.push('@nuxt/fonts')
60
- await installModule("@nuxt/fonts")
61
-
62
- }
63
-
64
- {
65
-
66
- // install @nuxt/icon
67
-
68
- nuxt.options.modules.push('@nuxt/icon')
69
- await installModule("@nuxt/icon", {
70
- clientBundle: {
71
- scan: true,
72
- sizeLimitKb: 256,
73
- },
74
- })
75
-
76
- }
77
-
78
- {
79
-
80
- // install @vueuse/nuxt
81
-
82
- nuxt.options.modules.push('@vueuse/nuxt')
83
- await installModule("@vueuse/nuxt")
84
-
85
- }
86
-
87
- {
88
-
89
- // install @nuxtjs/i18n
90
-
91
- nuxt.options.modules.push('@nuxtjs/i18n')
92
- await installModule("@nuxtjs/i18n")
93
-
94
- }
95
-
96
- {
97
-
98
- // configure scss for vite
99
-
100
- nuxt.hook('vite:extendConfig', (viteConfig) => {
101
- viteConfig.css = viteConfig.css || {}
102
- viteConfig.css.preprocessorOptions = viteConfig.css.preprocessorOptions || {}
103
- viteConfig.css.preprocessorOptions.scss = {
104
- api: 'modern-compiler',
105
- }
106
- })
107
-
108
- }
109
-
110
- {
111
-
112
- // add css
113
-
114
- nuxt.options.css.push('sanitize.css')
115
-
116
- }
117
-
118
- {
119
-
120
- // add runtime components
121
-
122
- addComponentsDir({
123
- path: resolve("../runtime/components"),
124
- prefix: "",
125
- global: true,
126
- })
127
-
128
- }
129
-
130
- {
131
-
132
- nuxt.options.plugins.push(
133
- resolve('../runtime/plugins/resize.client.ts'),
134
- )
135
-
136
- addImportsDir(resolve('../runtime/composables'))
137
- addImportsDir(resolve('../runtime/core'))
138
- addImportsDir(resolve('../runtime/stores'))
139
- addImportsDir(resolve('../runtime/utils'))
140
-
141
- }
142
-
143
- }
144
- })