@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.
- package/CHANGELOG.md +25 -0
- package/README.md +6 -7
- package/bin/owd.js +14 -14
- package/index.ts +5 -2
- package/module.ts +78 -61
- package/package.json +19 -17
- package/project.json +4 -0
- package/runtime/components/Core/Application/CoreApplicationRender.vue +6 -5
- package/runtime/components/Core/Application/CoreApplicationWindowsRender.vue +8 -8
- package/runtime/components/Core/Background/CoreBackground.vue +1 -1
- package/runtime/components/Core/Desktop/CoreDesktop.vue +31 -24
- package/runtime/components/Core/Explorer/CoreExplorerFile.vue +47 -38
- package/runtime/components/Core/Explorer/CoreExplorerFolder.vue +0 -1
- package/runtime/components/Core/Time/CoreTime.vue +10 -7
- package/runtime/components/Core/Window/CoreWindow.vue +49 -35
- package/runtime/components/Core/Window/CoreWindowContent.vue +3 -5
- package/runtime/components/Core/Window/CoreWindowNav.vue +12 -7
- package/runtime/composables/useApplicationEntries.ts +51 -0
- package/runtime/composables/useApplicationManager.ts +278 -5
- package/runtime/composables/useDesktopManager.ts +22 -4
- package/runtime/composables/useTerminalManager.ts +63 -4
- package/runtime/core/controllers/ApplicationController.ts +203 -192
- package/runtime/core/controllers/WindowController.ts +342 -334
- package/runtime/plugins/resize.client.ts +4 -4
- package/runtime/stores/storeApplication.ts +236 -0
- package/runtime/stores/storeApplicationMeta.ts +12 -8
- package/runtime/stores/storeApplicationWindows.ts +16 -12
- package/runtime/stores/storeDesktop.ts +35 -29
- package/runtime/stores/storeDesktopDefaultApps.ts +53 -0
- package/runtime/stores/storeDesktopVolume.ts +12 -12
- package/runtime/stores/storeDesktopWindow.ts +13 -13
- package/runtime/stores/storeDesktopWorkspace.ts +35 -31
- package/runtime/utils/utilApp.ts +27 -22
- package/runtime/utils/utilCommon.ts +43 -43
- package/runtime/utils/utilDebug.ts +17 -17
- package/runtime/utils/utilDesktop.ts +4 -4
- package/runtime/utils/utilTerminal.ts +6 -5
- package/runtime/utils/utilWindow.ts +11 -11
- package/test/fixtures/basic/app.vue +1 -2
- package/test/fixtures/basic/nuxt.config.ts +1 -3
- package/tsconfig.app.json +1 -1
- package/tsconfig.json +1 -1
- package/types/index.d.ts +235 -207
- package/vitest.config.ts +3 -3
- package/eslint.config.mjs +0 -30
- package/runtime/composables/useAppEntries.ts +0 -36
- package/runtime/composables/useClipboardFs.ts +0 -25
- package/runtime/core/managers/ApplicationManager.ts +0 -237
- package/runtime/core/managers/DesktopManager.ts +0 -37
- 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
|
-
}
|