@owdproject/core 3.1.4-beta.0 → 3.2.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 (64) hide show
  1. package/README.md +6 -6
  2. package/bin/cli.js +395 -0
  3. package/bin/desktop.js +5 -0
  4. package/bin/lib/catalog.js +293 -0
  5. package/bin/lib/config.js +109 -0
  6. package/bin/lib/desktopConfig.js +56 -0
  7. package/bin/lib/generateTemplate.js +389 -0
  8. package/bin/lib/install.js +408 -0
  9. package/bin/lib/migrateModulePlayground.config.mjs +164 -0
  10. package/bin/lib/migrateModulePlayground.mjs +313 -0
  11. package/bin/lib/npmVersions.js +124 -0
  12. package/bin/lib/playgroundContext.js +188 -0
  13. package/bin/lib/scaffold.js +197 -0
  14. package/bin/lib/status.js +289 -0
  15. package/bin/lib/validateModule.js +683 -0
  16. package/bin/lib/workspace.js +182 -0
  17. package/bin/owd.js +2 -25
  18. package/bin/tui.js +1379 -0
  19. package/dist/module.d.mts +13 -0
  20. package/dist/module.json +9 -0
  21. package/dist/module.mjs +219 -0
  22. package/dist/types.d.mts +7 -0
  23. package/module.ts +53 -19
  24. package/package.json +78 -22
  25. package/runtime/components/Core/Application/CoreApplicationRender.vue +3 -1
  26. package/runtime/components/Core/Application/CoreApplicationWindowsRender.vue +28 -7
  27. package/runtime/components/Core/Desktop/CoreDesktop.vue +11 -7
  28. package/runtime/components/Core/Window/CoreWindow.vue +45 -9
  29. package/runtime/components/Core/Window/CoreWindowNav.vue +26 -8
  30. package/runtime/composables/useApplicationEntries.ts +1 -1
  31. package/runtime/composables/useApplicationManager.ts +282 -4
  32. package/runtime/composables/useDesktopManager.ts +46 -4
  33. package/runtime/composables/useOwdDialogs.ts +13 -0
  34. package/runtime/composables/useTerminalManager.ts +62 -3
  35. package/runtime/composables/useWorkspaceOverview.ts +41 -0
  36. package/runtime/core/controllers/ApplicationController.ts +120 -30
  37. package/runtime/core/controllers/WindowController.ts +5 -10
  38. package/runtime/dialogs/owdDialogProvider.ts +81 -0
  39. package/runtime/plugins/01.owd-dialogs-fallback.ts +15 -0
  40. package/runtime/stores/storeApplicationMeta.ts +56 -12
  41. package/runtime/stores/storeDesktop.ts +79 -0
  42. package/runtime/stores/storeDesktopDefaultApps.ts +53 -0
  43. package/runtime/stores/storeDesktopExplorer.ts +74 -0
  44. package/runtime/stores/storeDesktopWorkspace.ts +14 -2
  45. package/runtime/utils/captureElementToCanvas.ts +21 -0
  46. package/runtime/utils/explorerEntryPath.ts +10 -0
  47. package/runtime/utils/resolveDesktopConfigPath.ts +52 -0
  48. package/runtime/utils/validateOwdUserConfig.ts +44 -0
  49. package/types/index.d.ts +64 -12
  50. package/CHANGELOG.md +0 -25
  51. package/project.json +0 -4
  52. package/runtime/composables/useClipboardFs.ts +0 -25
  53. package/runtime/core/managers/ApplicationManager.ts +0 -281
  54. package/runtime/core/managers/DesktopManager.ts +0 -47
  55. package/runtime/core/managers/TerminalManager.ts +0 -48
  56. package/runtime/stores/storeApplication.ts +0 -235
  57. package/test/basic.test.ts +0 -15
  58. package/test/fixtures/basic/app.vue +0 -5
  59. package/test/fixtures/basic/nuxt.config.ts +0 -5
  60. package/test/fixtures/basic/package.json +0 -5
  61. package/tsconfig.app.json +0 -31
  62. package/tsconfig.json +0 -12
  63. package/tsconfig.spec.json +0 -37
  64. package/vitest.config.ts +0 -24
@@ -23,13 +23,23 @@ export const useDesktopWorkspaceStore = defineStore(
23
23
  function setupWorkspaces() {
24
24
  if (desktopStore.state.workspace.list.length === 0) {
25
25
  createWorkspace()
26
- desktopStore.state.workspace.active = desktopStore.state.workspace
27
- .list[0] as string
28
26
  }
29
27
 
30
28
  if (desktopStore.state.workspace.list.length === 1) {
31
29
  createWorkspace()
32
30
  }
31
+
32
+ const list = desktopStore.state.workspace.list
33
+ const active = desktopStore.state.workspace.active
34
+ if (!active || !list.includes(active)) {
35
+ desktopStore.state.workspace.active = list[0] ?? ''
36
+ }
37
+ }
38
+
39
+ /** Id of the workspace new windows should use (after setupWorkspaces). */
40
+ function resolveActiveWorkspaceId(): string {
41
+ setupWorkspaces()
42
+ return desktopStore.state.workspace.active || desktopStore.state.workspace.list[0] || ''
33
43
  }
34
44
 
35
45
  function setOverview(value: boolean) {
@@ -56,8 +66,10 @@ export const useDesktopWorkspaceStore = defineStore(
56
66
  list,
57
67
  workspaceActiveIndex,
58
68
  setupWorkspaces,
69
+ resolveActiveWorkspaceId,
59
70
  setOverview,
60
71
  setWorkspace,
72
+ createWorkspace,
61
73
  }
62
74
  },
63
75
  )
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Renders a DOM subtree to a canvas via html2canvas (optional dependency).
3
+ * Used for workspace thumbnails / previews; returns null if capture fails or html2canvas is missing.
4
+ */
5
+ export async function captureElementToCanvas(
6
+ element: HTMLElement | null | undefined,
7
+ options?: Record<string, unknown>,
8
+ ): Promise<HTMLCanvasElement | null> {
9
+ if (!element || typeof window === 'undefined') {
10
+ return null
11
+ }
12
+ try {
13
+ const { default: html2canvas } = await import('html2canvas')
14
+ return await html2canvas(element, {
15
+ allowTaint: true,
16
+ ...(options as object),
17
+ })
18
+ } catch {
19
+ return null
20
+ }
21
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Absolute path for a listing entry under `basePath` (virtual FS paths).
3
+ * Avoids `//fileName` when `basePath` is `/` or has trailing slashes.
4
+ */
5
+ export function explorerEntryAbsolutePath(basePath: string, fileName: string): string {
6
+ const normalizedBase = (basePath ?? '/').replace(/\/+$/, '') || '/'
7
+ const tail = fileName.replace(/^\/+/, '')
8
+ if (normalizedBase === '/') return `/${tail}`
9
+ return `${normalizedBase}/${tail}`
10
+ }
@@ -0,0 +1,52 @@
1
+ import { existsSync } from 'node:fs'
2
+ import { join } from 'node:path'
3
+
4
+ export const DESKTOP_CONFIG_FILENAME = 'desktop.config.ts'
5
+ export const LEGACY_DESKTOP_CONFIG_FILENAME = 'owd.config.ts'
6
+
7
+ export const LEGACY_CONFIG_DEPRECATION =
8
+ '[@owdproject/core] owd.config.ts is deprecated and kept only for backward compatibility; rename to desktop.config.ts (required from @owdproject/core 3.2).'
9
+
10
+ export type ResolvedDesktopConfigPath = {
11
+ path: string
12
+ file: string
13
+ legacy: boolean
14
+ }
15
+
16
+ export function resolveDesktopConfigPath(
17
+ rootDir: string,
18
+ ): ResolvedDesktopConfigPath | null {
19
+ const desktopPath = join(rootDir, DESKTOP_CONFIG_FILENAME)
20
+ const legacyPath = join(rootDir, LEGACY_DESKTOP_CONFIG_FILENAME)
21
+ const hasDesktop = existsSync(desktopPath)
22
+ const hasLegacy = existsSync(legacyPath)
23
+
24
+ if (hasDesktop && hasLegacy) {
25
+ console.warn(
26
+ '[@owdproject/core] Both desktop.config.ts and owd.config.ts exist; using desktop.config.ts. Remove owd.config.ts.',
27
+ )
28
+ return { path: desktopPath, file: DESKTOP_CONFIG_FILENAME, legacy: false }
29
+ }
30
+
31
+ if (hasDesktop) {
32
+ return { path: desktopPath, file: DESKTOP_CONFIG_FILENAME, legacy: false }
33
+ }
34
+
35
+ if (hasLegacy) {
36
+ return {
37
+ path: legacyPath,
38
+ file: LEGACY_DESKTOP_CONFIG_FILENAME,
39
+ legacy: true,
40
+ }
41
+ }
42
+
43
+ return null
44
+ }
45
+
46
+ export function warnLegacyDesktopConfig(
47
+ resolved: ResolvedDesktopConfigPath | null | undefined,
48
+ ): void {
49
+ if (resolved?.legacy) {
50
+ console.warn(LEGACY_CONFIG_DEPRECATION)
51
+ }
52
+ }
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Runtime validation for the object exported from `desktop.config.ts`
3
+ * (or legacy `owd.config.ts`).
4
+ */
5
+ export function assertValidOwdUserConfig(
6
+ config: unknown,
7
+ configFile = 'desktop.config.ts',
8
+ ): void {
9
+ if (!config || typeof config !== 'object' || Array.isArray(config)) {
10
+ throw new Error(
11
+ `[@owdproject/core] ${configFile} must default-export a non-array object from defineDesktopConfig({ ... }).`,
12
+ )
13
+ }
14
+
15
+ const c = config as Record<string, unknown>
16
+
17
+ if (c.theme != null && typeof c.theme !== 'string') {
18
+ throw new Error(
19
+ `[@owdproject/core] ${configFile}: \`theme\` must be a string (npm package name of the theme module).`,
20
+ )
21
+ }
22
+
23
+ if (c.apps !== undefined) {
24
+ if (
25
+ !Array.isArray(c.apps) ||
26
+ !(c.apps as unknown[]).every((item) => typeof item === 'string')
27
+ ) {
28
+ throw new Error(
29
+ `[@owdproject/core] ${configFile}: \`apps\` must be an array of strings (Nuxt module package names).`,
30
+ )
31
+ }
32
+ }
33
+
34
+ if (c.modules !== undefined) {
35
+ if (
36
+ !Array.isArray(c.modules) ||
37
+ !(c.modules as unknown[]).every((item) => typeof item === 'string')
38
+ ) {
39
+ throw new Error(
40
+ `[@owdproject/core] ${configFile}: \`modules\` must be an array of strings (Nuxt module package names).`,
41
+ )
42
+ }
43
+ }
44
+ }
package/types/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { Nuxt } from '@nuxt/schema'
2
+ import type { ShallowRef } from 'vue'
2
3
  import { useApplicationManager } from '../runtime/composables/useApplicationManager'
3
4
 
4
5
  declare module 'nuxt/schema' {
@@ -16,7 +17,7 @@ interface IApplicationManager {
16
17
 
17
18
  get appsRunning(): Reactive<IApplicationController[]>
18
19
 
19
- get windowsOpened(): Reactive<IWindowController[]>
20
+ get windowsOpened(): Reactive<Map<string, IWindowController>>
20
21
 
21
22
  get appCategories(): string[]
22
23
 
@@ -84,7 +85,8 @@ interface IApplicationController {
84
85
  get meta(): { [key: string]: any }
85
86
 
86
87
  store: Pinia
87
- windows: Reactive<Map<string, IWindowController>>
88
+ windows: Map<string, IWindowController>
89
+ openWindowCount: ShallowRef<number>
88
90
 
89
91
  isRunning: boolean
90
92
 
@@ -116,7 +118,7 @@ interface IApplicationController {
116
118
  get windowsOpened(): Reactive<Map<string, IWindowController>>
117
119
  }
118
120
 
119
- interface IWindowController {
121
+ export interface IWindowController {
120
122
  application: IApplicationController
121
123
  instanced: boolean
122
124
  model: string
@@ -134,6 +136,8 @@ interface IWindowController {
134
136
  // sizes
135
137
  get size(): WindowSize
136
138
 
139
+ get position(): WindowPosition | undefined
140
+
137
141
  // minimize
138
142
  get isMinimizable(): boolean
139
143
 
@@ -179,14 +183,27 @@ interface IWindowController {
179
183
  setTitleOverride(title: string | undefined): void
180
184
  resetTitleOverride(): void
181
185
  }
186
+
187
+ /** Payload restored with window state (e.g. explorer cwd in `path`). */
188
+ get meta(): { path?: string } & Record<string, unknown>
189
+
190
+ /** Chrome menu model (e.g. PrimeVue Menubar). */
191
+ menu: unknown[]
192
+
193
+ setMenu(menu: unknown[]): void
194
+
195
+ destroy(): boolean
196
+
197
+ /** Set by module-fs when an explorer surface mounts on this window. */
198
+ fsExplorer?: any
182
199
  }
183
200
 
184
- interface WindowContent {
201
+ export interface WindowContent {
185
202
  padded?: boolean
186
203
  centered?: boolean
187
204
  }
188
205
 
189
- interface WindowConfig {
206
+ export interface WindowConfig {
190
207
  title?: string
191
208
  category?: string
192
209
  icon?: string
@@ -309,15 +326,28 @@ type ApplicationEntryVisibility = 'primary' | 'secondary' | 'hidden'
309
326
  // DESKTOP
310
327
 
311
328
  interface IDesktopManager {
312
- defaultApps: DefaultAppsConfig
329
+ defaultApps: import('vue').ComputedRef<Record<string, DefaultAppConfig>>
313
330
 
314
- getDefaultApp(feature: string)
331
+ getDefaultApp(feature: string): DefaultAppConfig | undefined
315
332
 
316
333
  setDefaultApp(
317
334
  feature: string,
318
335
  application: IApplicationController,
319
- command: ApplicationCommand,
320
- )
336
+ entry: string,
337
+ ): void
338
+ }
339
+
340
+ interface DocsModuleUserSourceConfig {
341
+ cwd: string
342
+ prefix?: string
343
+ include?: string
344
+ exclude?: string[]
345
+ }
346
+
347
+ interface DocsModuleConfig {
348
+ basePath?: string
349
+ title?: string
350
+ sources?: DocsModuleUserSourceConfig[]
321
351
  }
322
352
 
323
353
  interface DesktopConfig {
@@ -325,15 +355,36 @@ interface DesktopConfig {
325
355
  modules?: string[]
326
356
  apps?: string[]
327
357
 
328
- name?: stringThis
358
+ docs?: DocsModuleConfig
359
+
360
+ name?: string
329
361
  defaultApps?: DefaultAppsConfig
330
362
  features?: string[]
363
+ explorer?: DesktopExplorerConfig
331
364
 
332
365
  systemBar?: DesktopSystemBarConfig
333
366
  dockBar?: DesktopDockBarConfig
334
367
  workspaces?: DesktopWorkspacesConfig
335
368
  }
336
369
 
370
+ interface DesktopExplorerFolderConfig {
371
+ id: string
372
+ label: string
373
+ path: string
374
+ icon?: string
375
+ }
376
+
377
+ interface DesktopExplorerConfig {
378
+ quickAccess?: DesktopExplorerFolderConfig[]
379
+ quickAccessExtra?: DesktopExplorerFolderConfig[]
380
+ quickAccessOverride?: DesktopExplorerFolderConfig[]
381
+ specialFolders?: DesktopExplorerFolderConfig[]
382
+ specialFoldersExtra?: DesktopExplorerFolderConfig[]
383
+ specialFoldersOverride?: DesktopExplorerFolderConfig[]
384
+ /** Friendly labels for ZenFS mount points shown under “This PC” (paths → label). */
385
+ mountLabels?: Record<string, string>
386
+ }
387
+
337
388
  interface DesktopWindowsConfig {
338
389
  position: 'relative' | 'absolute' | 'fixed'
339
390
  }
@@ -375,9 +426,10 @@ interface DefaultAppsConfig {
375
426
  [key: string]: DefaultAppConfig
376
427
  }
377
428
 
429
+ /** Stored default for a feature: which app and which entry key to use. */
378
430
  interface DefaultAppConfig {
379
- application: IApplicationController
380
- entry: ApplicationEntry
431
+ applicationId: string
432
+ entry: string
381
433
  }
382
434
 
383
435
  export function defineDesktopApp(config: ApplicationConfig)
package/CHANGELOG.md DELETED
@@ -1,25 +0,0 @@
1
- ## 3.1.4 (2025-05-22)
2
-
3
- ### 🚀 Features
4
-
5
- - Allow apps to have a menu ([4bfea74](https://github.com/owdproject/client/commit/4bfea74))
6
- - Add methods to better handle window changes ([54d1346](https://github.com/owdproject/client/commit/54d1346))
7
- - Check if owd.config.ts is available and valid ([4920302](https://github.com/owdproject/client/commit/4920302))
8
- - Add fit-parent to CoreWindow.vue ([59e068c](https://github.com/owdproject/client/commit/59e068c))
9
- - Add focus() to WindowController and set methods as public (deprecate actions) ([710f7be](https://github.com/owdproject/client/commit/710f7be))
10
- - Add owd global command ([f98c74c](https://github.com/owdproject/client/commit/f98c74c))
11
- - Add useClipboardFs.ts composable ([cf934f4](https://github.com/owdproject/client/commit/cf934f4))
12
- - Add window utils in ApplicationController.ts ([ffc97d0](https://github.com/owdproject/client/commit/ffc97d0))
13
- - Export most used functions from core ([6635af7](https://github.com/owdproject/client/commit/6635af7))
14
- - Merge owd.config.ts with nuxt.config.ts in module.ts ([069243c](https://github.com/owdproject/client/commit/069243c))
15
- - Implement basic owd.config.ts ([d052552](https://github.com/owdproject/client/commit/d052552))
16
- - Rewrite project ([cbbd45d](https://github.com/owdproject/client/commit/cbbd45d))
17
-
18
- ### 🩹 Fixes
19
-
20
- - Add key on CoreApplicationWindowsRender v-for ([d2e8e3c](https://github.com/owdproject/client/commit/d2e8e3c))
21
- - Check if entries property is set before normalizing in utilApp.ts ([6092c33](https://github.com/owdproject/client/commit/6092c33))
22
- - Add missing min-width ([aa0c1b5](https://github.com/owdproject/client/commit/aa0c1b5))
23
- - Minor improvements ([7f79208](https://github.com/owdproject/client/commit/7f79208))
24
- - Fix imports ([44740cd](https://github.com/owdproject/client/commit/44740cd))
25
- - Set window starting positionZ to 0 ([b99352e](https://github.com/owdproject/client/commit/b99352e))
package/project.json DELETED
@@ -1,4 +0,0 @@
1
- {
2
- "name": "core",
3
- "version": "3.1.3"
4
- }
@@ -1,25 +0,0 @@
1
- import { ref } from 'vue'
2
-
3
- type ClipboardOperation = 'copy' | 'cut'
4
-
5
- const clipboardFiles = ref<string[]>([])
6
- const clipboardType = ref<ClipboardOperation | null>(null)
7
-
8
- export function useClipboardFs() {
9
- function setClipboard(paths: string[], type: ClipboardOperation) {
10
- clipboardFiles.value = paths
11
- clipboardType.value = type
12
- }
13
-
14
- function clearClipboard() {
15
- clipboardFiles.value = []
16
- clipboardType.value = null
17
- }
18
-
19
- return {
20
- clipboardFiles,
21
- clipboardType,
22
- setClipboard,
23
- clearClipboard,
24
- }
25
- }
@@ -1,281 +0,0 @@
1
- import type { Reactive } from '@vue/reactivity'
2
- import { reactive, markRaw } from '@vue/reactivity'
3
- import { ApplicationController } from '../controllers/ApplicationController'
4
- import { normalizeApplicationConfig } from '../../utils/utilApp'
5
- import { debugLog } from '../../utils/utilDebug'
6
- import * as shellwords from 'shellwords'
7
- import yargsParser from 'yargs-parser'
8
-
9
- export class ApplicationManager implements IApplicationManager {
10
- public apps = reactive(new Map<string, IApplicationController>())
11
-
12
- constructor() {}
13
-
14
- /**
15
- * Define new application
16
- *
17
- * @param id
18
- * @param config
19
- */
20
- public async defineApp(id: string, config: ApplicationConfig) {
21
- if (this.isAppDefined(id)) {
22
- debugLog(`App "${id}" is already defined`)
23
- return this.getAppById(id)!
24
- }
25
-
26
- const normalizedConfig = normalizeApplicationConfig(config)
27
- const applicationConfig = markRaw(normalizedConfig)
28
-
29
- const applicationController: IApplicationController = new ApplicationController(id, applicationConfig)
30
- await applicationController.initApplication()
31
-
32
- this.apps.set(id, applicationController)
33
-
34
- return applicationController
35
- }
36
-
37
- /**
38
- * Check if app has been defned
39
- *
40
- * @param {string} id
41
- */
42
- public isAppDefined(id: string) {
43
- return this.getAppById(id)
44
- }
45
-
46
- /**
47
- * Retrieves an app instance by its unique identifier
48
- *
49
- * @param {string} id
50
- */
51
- public getAppById(id: string) {
52
- return this.apps.get(id)
53
- }
54
-
55
- /**
56
- * Check if app is running
57
- *
58
- * @param {string} id
59
- */
60
- public isAppRunning(id: string) {
61
- if (!this.isAppDefined(id)) {
62
- throw Error(`App "${id}" is not defined`)
63
- }
64
-
65
- const applicationController: IApplicationController = this.getAppById(id)!
66
-
67
- if (!applicationController.isRunning) {
68
- return false
69
- }
70
-
71
- return true
72
- }
73
-
74
- /**
75
- * Launch app entry
76
- *
77
- * @param id
78
- * @param entryKey
79
- */
80
- public async launchAppEntry(
81
- id: string,
82
- entryKey: string,
83
- ): Promise<IApplicationController | undefined | void> {
84
- if (!this.isAppDefined(id)) {
85
- throw Error(`App "${id}" is not defined`)
86
- }
87
-
88
- const applicationController: IApplicationController = this.getAppById(id)!
89
-
90
- if (
91
- applicationController.config.entries &&
92
- !applicationController.config.entries.hasOwnProperty(entryKey)
93
- ) {
94
- throw Error(`App entry "${entryKey}" is not defined in ${id} application`)
95
- }
96
-
97
- const entry: ApplicationEntry = applicationController.config.entries[entryKey]!
98
-
99
- await this.execAppCommand(applicationController.id, entry.command)
100
- }
101
-
102
- /**
103
- * Run app command
104
- *
105
- * @param id
106
- * @param rawCommand
107
- */
108
- public async execAppCommand(
109
- id: string,
110
- rawCommand: string,
111
- ): Promise<CommandOutput> {
112
- if (!this.isAppDefined(id)) {
113
- throw Error(`App "${id}" is not defined`)
114
- }
115
-
116
- const applicationController: IApplicationController = this.getAppById(id)!
117
-
118
- const args = shellwords.split(rawCommand)
119
- const parsed = yargsParser(args)
120
- const command: string = parsed._[0]
121
-
122
- if (
123
- applicationController.config.commands &&
124
- !applicationController.config.commands.hasOwnProperty(command)
125
- ) {
126
- throw Error(
127
- `App command "${command}" is not defined in ${id} application`,
128
- )
129
- }
130
-
131
- const commandFn: any = applicationController.config.commands![command]
132
-
133
- const commandOutput = await commandFn(
134
- applicationController,
135
- parsed,
136
- )
137
-
138
- applicationController.setRunning(true)
139
-
140
- return commandOutput
141
- }
142
-
143
- /**
144
- * Close application
145
- *
146
- * @param id
147
- */
148
- public closeApp(id: string) {
149
- if (!this.isAppDefined(id)) {
150
- throw Error(`App "${id}" is not defined`)
151
- }
152
-
153
- const applicationController: IApplicationController = this.getAppById(id)!
154
-
155
- applicationController.closeAllWindows()
156
- applicationController.setRunning(false)
157
- }
158
-
159
- /**
160
- * Array of available menu entries for system bars, docks
161
- */
162
- public get appsEntries() {
163
- const entries: Reactive<ApplicationEntryWithInherited[]> = reactive([])
164
-
165
- for (const applicationController of this.apps.values()) {
166
- if (!applicationController.config.entries) {
167
- continue
168
- }
169
-
170
- for (const entryKey of Object.keys(
171
- applicationController.config.entries,
172
- )) {
173
- const entry: ApplicationEntry =
174
- applicationController.config.entries[entryKey]!
175
-
176
- entries.push({
177
- application: applicationController,
178
- title:
179
- entry.title !== undefined
180
- ? entry.title
181
- : applicationController.config.title,
182
- icon:
183
- entry.icon !== undefined
184
- ? entry.icon
185
- : applicationController.config.icon,
186
- category:
187
- entry.category !== undefined
188
- ? entry.category
189
- : applicationController.config.category,
190
- visibility: entry.visibility ?? 'primary',
191
- command: entry.command,
192
- })
193
- }
194
- }
195
-
196
- return entries
197
- }
198
-
199
- /**
200
- * Array of opened windows for system bars, docks
201
- */
202
- public get windowsOpened() {
203
- const windows: Reactive<Map<string, IWindowController>[]> = reactive([])
204
-
205
- for (const applicationController of this.apps.values()) {
206
- if (applicationController.isRunning) {
207
- windows.push(...applicationController.windows)
208
- }
209
- }
210
-
211
- return windows
212
- }
213
-
214
- /**
215
- * Array of opened windows for system bars, docks
216
- */
217
- public get appsRunning() {
218
- const applications: Reactive<IApplicationController[]> = reactive([])
219
-
220
- for (const applicationController of this.apps.values()) {
221
- if (applicationController.isRunning) {
222
- applications.push(applicationController)
223
- }
224
- }
225
-
226
- return applications
227
- }
228
-
229
- public getWindowOpenedId(windowId: string) {
230
- const mapWindowFound: Map<string, IWindowController> | undefined =
231
- this.windowsOpened.find((window: any) => {
232
- return window[1].state.id === windowId
233
- })
234
-
235
- if (mapWindowFound) {
236
- // @ts-ignore
237
- return mapWindowFound[1] as IWindowController
238
- }
239
- }
240
-
241
- /**
242
- * Gets all unique categories from the installed apps
243
- */
244
- public get appCategories(): string[] {
245
- const categories = new Set<string>()
246
-
247
- for (const applicationController of this.apps.values()) {
248
- if (applicationController.config.category) {
249
- categories.add(applicationController.config.category)
250
- }
251
- }
252
- return Array.from(categories).sort()
253
- }
254
-
255
- /**
256
- * Gets the apps ordered by category
257
- */
258
- public get appsByCategory(): {
259
- [category: string]: IApplicationController[]
260
- } {
261
- const categorizedApps: {
262
- [category: string]: IApplicationController[]
263
- } = {}
264
-
265
- for (const applicationController of this.apps.values()) {
266
- const category = applicationController.config.category || 'other'
267
- if (!categorizedApps[category]) {
268
- categorizedApps[category] = []
269
- }
270
- categorizedApps[category].push(applicationController)
271
- }
272
-
273
- for (const category in categorizedApps) {
274
- categorizedApps[category]!.sort((a, b) =>
275
- a.config.title.localeCompare(b.config.title),
276
- )
277
- }
278
-
279
- return categorizedApps
280
- }
281
- }