@owdproject/core 3.1.3 → 3.1.4

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 (50) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +6 -7
  3. package/bin/owd.js +14 -14
  4. package/index.ts +5 -2
  5. package/module.ts +78 -61
  6. package/package.json +19 -17
  7. package/project.json +4 -0
  8. package/runtime/components/Core/Application/CoreApplicationRender.vue +6 -5
  9. package/runtime/components/Core/Application/CoreApplicationWindowsRender.vue +8 -8
  10. package/runtime/components/Core/Background/CoreBackground.vue +1 -1
  11. package/runtime/components/Core/Desktop/CoreDesktop.vue +31 -24
  12. package/runtime/components/Core/Explorer/CoreExplorerFile.vue +47 -38
  13. package/runtime/components/Core/Explorer/CoreExplorerFolder.vue +0 -1
  14. package/runtime/components/Core/Time/CoreTime.vue +10 -7
  15. package/runtime/components/Core/Window/CoreWindow.vue +49 -35
  16. package/runtime/components/Core/Window/CoreWindowContent.vue +3 -5
  17. package/runtime/components/Core/Window/CoreWindowNav.vue +12 -7
  18. package/runtime/composables/useApplicationEntries.ts +51 -0
  19. package/runtime/composables/useApplicationManager.ts +278 -5
  20. package/runtime/composables/useDesktopManager.ts +22 -4
  21. package/runtime/composables/useTerminalManager.ts +63 -4
  22. package/runtime/core/controllers/ApplicationController.ts +203 -192
  23. package/runtime/core/controllers/WindowController.ts +342 -334
  24. package/runtime/plugins/resize.client.ts +4 -4
  25. package/runtime/stores/storeApplication.ts +236 -0
  26. package/runtime/stores/storeApplicationMeta.ts +12 -8
  27. package/runtime/stores/storeApplicationWindows.ts +16 -12
  28. package/runtime/stores/storeDesktop.ts +35 -29
  29. package/runtime/stores/storeDesktopDefaultApps.ts +53 -0
  30. package/runtime/stores/storeDesktopVolume.ts +12 -12
  31. package/runtime/stores/storeDesktopWindow.ts +13 -13
  32. package/runtime/stores/storeDesktopWorkspace.ts +35 -31
  33. package/runtime/utils/utilApp.ts +27 -22
  34. package/runtime/utils/utilCommon.ts +43 -43
  35. package/runtime/utils/utilDebug.ts +17 -17
  36. package/runtime/utils/utilDesktop.ts +4 -4
  37. package/runtime/utils/utilTerminal.ts +6 -5
  38. package/runtime/utils/utilWindow.ts +11 -11
  39. package/test/fixtures/basic/app.vue +1 -2
  40. package/test/fixtures/basic/nuxt.config.ts +1 -3
  41. package/tsconfig.app.json +1 -1
  42. package/tsconfig.json +1 -1
  43. package/types/index.d.ts +235 -207
  44. package/vitest.config.ts +3 -3
  45. package/eslint.config.mjs +0 -30
  46. package/runtime/composables/useAppEntries.ts +0 -36
  47. package/runtime/composables/useClipboardFs.ts +0 -25
  48. package/runtime/core/managers/ApplicationManager.ts +0 -237
  49. package/runtime/core/managers/DesktopManager.ts +0 -37
  50. package/runtime/core/managers/TerminalManager.ts +0 -44
@@ -1,25 +0,0 @@
1
- import { ref } from 'vue';
2
-
3
- type ClipboardOperation = 'copy' | 'cut';
4
-
5
- const clipboardPath = ref<string | null>(null);
6
- const clipboardType = ref<ClipboardOperation | null>(null);
7
-
8
- export function useClipboardFs() {
9
- function setClipboard(path: string, type: ClipboardOperation) {
10
- clipboardPath.value = path;
11
- clipboardType.value = type;
12
- }
13
-
14
- function clearClipboard() {
15
- clipboardPath.value = null;
16
- clipboardType.value = null;
17
- }
18
-
19
- return {
20
- clipboardPath,
21
- clipboardType,
22
- setClipboard,
23
- clearClipboard,
24
- };
25
- }
@@ -1,237 +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
-
7
- export class ApplicationManager implements IApplicationManager {
8
- public apps = reactive(
9
- new Map<string, IApplicationController>()
10
- )
11
-
12
- constructor() {
13
- }
14
-
15
- /**
16
- * Define new application
17
- *
18
- * @param id
19
- * @param config
20
- */
21
- public async defineApp(id: string, config: ApplicationConfig) {
22
- if (this.isAppDefined(id)) {
23
- debugLog(`App "${id}" is already defined`);
24
- return this.apps.get(id)!;
25
- }
26
-
27
- const normalizedConfig = normalizeApplicationConfig(config)
28
- const applicationConfig = markRaw(normalizedConfig)
29
-
30
- const applicationController: IApplicationController = new ApplicationController(id, applicationConfig)
31
- await applicationController.initApplication()
32
-
33
- this.apps.set(id, applicationController)
34
-
35
- return applicationController
36
- }
37
-
38
- /**
39
- * Check if app has been defned
40
- *
41
- * @param id
42
- */
43
- public isAppDefined(id: string) {
44
- return this.apps.has(id)
45
- }
46
-
47
- /**
48
- * Check if app is running
49
- *
50
- * @param id
51
- */
52
- public isAppRunning(id: string) {
53
- if (!this.isAppDefined(id)) {
54
- throw Error(`App "${id}" is not defined`);
55
- }
56
-
57
- const applicationController: IApplicationController = this.apps.get(id)!
58
-
59
- if (!applicationController.isRunning) {
60
- return false
61
- }
62
-
63
- return true
64
- }
65
-
66
- /**
67
- * Launch app rntry
68
- *
69
- * @param id
70
- * @param entryKey
71
- */
72
- public async launchAppEntry(id: string, entryKey: string): Promise<IApplicationController | undefined | void> {
73
- if (!this.isAppDefined(id)) {
74
- throw Error(`App "${id}" is not defined`);
75
- }
76
-
77
- const applicationController: IApplicationController = this.apps.get(id)!
78
-
79
- if (applicationController.config.entries && !applicationController.config.entries.hasOwnProperty(entryKey)) {
80
- throw Error(`App entry "${entryKey}" is not defined in ${id} application`);
81
- }
82
-
83
- const entry: ApplicationEntry = applicationController.config.entries[entryKey]!
84
-
85
- await this.execAppCommand(applicationController.id, entry.command)
86
- }
87
-
88
- /**
89
- * Run app command
90
- *
91
- * @param id
92
- * @param command
93
- */
94
- public async execAppCommand(id: string, command: string): Promise<CommandOutput> {
95
- if (!this.isAppDefined(id)) {
96
- throw Error(`App "${id}" is not defined`);
97
- }
98
-
99
- const applicationController: IApplicationController = this.apps.get(id)!
100
-
101
- const commandSplit: string[] = command.split(" ")
102
- const baseCommand = commandSplit[0] as keyof typeof applicationController.config.commands
103
-
104
- if (applicationController.config.commands && !applicationController.config.commands.hasOwnProperty(baseCommand)) {
105
- throw Error(`App command "${command}" is not defined in ${id} application`);
106
- }
107
-
108
- const commandFn: any = applicationController.config.commands![baseCommand]
109
- const commandOutput = await commandFn(applicationController, commandSplit.slice(1))
110
-
111
- applicationController.setRunning(true)
112
-
113
- return commandOutput;
114
- }
115
-
116
- /**
117
- * Close application
118
- *
119
- * @param id
120
- */
121
- public closeApp(id: string) {
122
- if (!this.isAppDefined(id)) {
123
- throw Error(`App "${id}" is not defined`);
124
- }
125
-
126
- const applicationController: IApplicationController = this.apps.get(id)!
127
-
128
- applicationController.closeAllWindows()
129
- applicationController.setRunning(false)
130
- }
131
-
132
- /**
133
- * Array of available menu entries for system bars, docks
134
- */
135
- public get appsEntries() {
136
- const entries: Reactive<ApplicationEntryWithInherited[]> = reactive([])
137
-
138
- for (const applicationController of this.apps.values()) {
139
- if (!applicationController.config.entries) {
140
- continue
141
- }
142
-
143
- for (const entryKey of Object.keys(applicationController.config.entries)) {
144
- const entry: ApplicationEntry = applicationController.config.entries[entryKey]!
145
-
146
- entries.push({
147
- application: applicationController,
148
- title: entry.title !== undefined ? entry.title : applicationController.config.title,
149
- icon: entry.icon !== undefined ? entry.icon : applicationController.config.icon,
150
- category: entry.category !== undefined ? entry.category : applicationController.config.category,
151
- visibility: entry.visibility ?? 'primary',
152
- command: entry.command
153
- })
154
- }
155
- }
156
-
157
- return entries
158
- }
159
-
160
- /**
161
- * Array of opened windows for system bars, docks
162
- */
163
- public get windowsOpened() {
164
- const windows: Reactive<Map<string, IWindowController>[]> = reactive([])
165
-
166
- for (const applicationController of this.apps.values()) {
167
- if (applicationController.isRunning) {
168
- windows.push(...applicationController.windows)
169
- }
170
- }
171
-
172
- return windows
173
- }
174
-
175
- /**
176
- * Array of opened windows for system bars, docks
177
- */
178
- public get appsRunning() {
179
- const applications: Reactive<IApplicationController[]> = reactive([])
180
-
181
- for (const applicationController of this.apps.values()) {
182
- if (applicationController.isRunning) {
183
- applications.push(applicationController)
184
- }
185
- }
186
-
187
- return applications
188
- }
189
-
190
- public getWindowOpenedId(windowId: string) {
191
- const mapWindowFound: Map<string, IWindowController> | undefined = this.windowsOpened.find((window: any) => {
192
- return window[1].state.id === windowId
193
- })
194
-
195
- if (mapWindowFound) {
196
- // @ts-ignore
197
- return mapWindowFound[1] as IWindowController
198
- }
199
- }
200
-
201
- /**
202
- * Gets all unique categories from the installed apps
203
- */
204
- public get appCategories(): string[] {
205
- const categories = new Set<string>()
206
-
207
- for (const applicationController of this.apps.values()) {
208
- if (applicationController.config.category) {
209
- categories.add(applicationController.config.category)
210
- }
211
- }
212
- return Array.from(categories).sort()
213
- }
214
-
215
- /**
216
- * Gets the apps ordered by category
217
- */
218
- public get appsByCategory(): { [category: string]: IApplicationController[] } {
219
- const categorizedApps: { [category: string]: IApplicationController[] } = {}
220
-
221
- for (const applicationController of this.apps.values()) {
222
- const category = applicationController.config.category || 'other'
223
- if (!categorizedApps[category]) {
224
- categorizedApps[category] = []
225
- }
226
- categorizedApps[category].push(applicationController)
227
- }
228
-
229
- for (const category in categorizedApps) {
230
- categorizedApps[category]!.sort(
231
- (a, b) => a.config.title.localeCompare(b.config.title)
232
- )
233
- }
234
-
235
- return categorizedApps
236
- }
237
- }
@@ -1,37 +0,0 @@
1
- import {deepMerge} from "../../utils/utilCommon"
2
-
3
- export class DesktopManager {
4
- public config: DesktopConfig = {} as DesktopConfig
5
-
6
- private defaultApps: DefaultAppsConfig = {}
7
-
8
- constructor() {
9
-
10
- }
11
-
12
- public hasFeature(featureName: string) {
13
- return this.config.features?.indexOf(featureName) !== -1
14
- }
15
-
16
- public setConfig(config: DesktopConfig) {
17
- this.config = deepMerge(this.config, config) as DesktopConfig
18
- this.loadDefaultAppsFromConfig()
19
- }
20
-
21
- public setDefaultApp(feature: string, application: IApplicationController, entry: ApplicationEntry) {
22
- this.defaultApps[feature] = {
23
- application,
24
- entry
25
- }
26
- }
27
-
28
- public getDefaultApp(feature: string): DefaultAppConfig {
29
- return this.defaultApps[feature] as DefaultAppConfig
30
- }
31
-
32
- private loadDefaultAppsFromConfig() {
33
- if (this.config.defaultApps) {
34
- this.defaultApps = {...this.config.defaultApps}
35
- }
36
- }
37
- }
@@ -1,44 +0,0 @@
1
- import {useApplicationManager} from "../../composables/useApplicationManager"
2
- import {debugLog} from "../../utils/utilDebug"
3
-
4
- export class TerminalManager {
5
- private commands: Map<string, TerminalCommand> = new Map()
6
-
7
- constructor() {
8
- }
9
-
10
- public addCommand(command: TerminalCommand) {
11
- for (const existingCommand of this.commands.keys()) {
12
- if (existingCommand.startsWith(command.name) || command.name.startsWith(existingCommand)) {
13
- throw new Error(`Command prefix conflict with "${existingCommand}"`)
14
- }
15
- }
16
-
17
- this.commands.set(command.name, command)
18
- debugLog(`Registered terminal command: ${command.name} → ${command.applicationId}`)
19
- }
20
-
21
- public listCommands(): string[] {
22
- return Array.from(this.commands.keys())
23
- }
24
-
25
- public async execCommand(input: string): Promise<CommandOutput | void> {
26
- const applicationManager = useApplicationManager()
27
-
28
- const [name, ...args] = input.trim().split(/\s+/)
29
-
30
- if (!name) {
31
- return
32
- }
33
-
34
- if (!this.commands.has(name)) {
35
- return {
36
- message: `Command "${name}" not found`
37
- }
38
- }
39
-
40
- const application = this.commands.get(name)!
41
-
42
- return applicationManager.execAppCommand(application.applicationId, input)
43
- }
44
- }