@owdproject/core 3.3.1 → 4.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/README.md +91 -59
- package/dist/dom/index.d.mts +65 -0
- package/dist/dom/index.d.ts +65 -0
- package/dist/dom/index.mjs +224 -0
- package/dist/events/index.d.mts +70 -0
- package/dist/events/index.d.ts +70 -0
- package/dist/events/index.mjs +3 -0
- package/dist/index.d.mts +73 -0
- package/dist/index.d.ts +73 -0
- package/dist/index.mjs +115 -0
- package/dist/layout/index.d.mts +41 -0
- package/dist/layout/index.d.ts +41 -0
- package/dist/layout/index.mjs +64 -0
- package/dist/machines/index.d.mts +31 -0
- package/dist/machines/index.d.ts +31 -0
- package/dist/machines/index.mjs +2 -0
- package/dist/managers/index.d.mts +117 -0
- package/dist/managers/index.d.ts +117 -0
- package/dist/managers/index.mjs +6 -0
- package/dist/session/index.d.mts +57 -0
- package/dist/session/index.d.ts +57 -0
- package/dist/session/index.mjs +65 -0
- package/dist/shared/core.B0B0KfVK.mjs +865 -0
- package/dist/shared/core.B1XxB289.mjs +239 -0
- package/dist/shared/core.B3mp7ztE.mjs +237 -0
- package/dist/shared/core.BOvFdEVQ.d.ts +114 -0
- package/dist/shared/core.CsDFgGnX.mjs +40 -0
- package/dist/shared/core.Di1eFcr_.d.mts +114 -0
- package/dist/shared/core.Pd_Ogt4g.mjs +101 -0
- package/dist/shared/core.b3Xldzyu.mjs +29 -0
- package/dist/types/index.d.mts +266 -0
- package/dist/types/index.d.ts +266 -0
- package/dist/types/index.mjs +1 -0
- package/package.json +60 -87
- package/bin/cli.js +0 -395
- package/bin/desktop.js +0 -5
- package/bin/lib/catalog.js +0 -293
- package/bin/lib/config.js +0 -109
- package/bin/lib/desktopConfig.js +0 -56
- package/bin/lib/generateTemplate.js +0 -389
- package/bin/lib/install.js +0 -408
- package/bin/lib/migrateModulePlayground.config.mjs +0 -164
- package/bin/lib/migrateModulePlayground.mjs +0 -313
- package/bin/lib/npmVersions.js +0 -124
- package/bin/lib/playgroundContext.js +0 -188
- package/bin/lib/scaffold.js +0 -197
- package/bin/lib/status.js +0 -289
- package/bin/lib/validateModule.js +0 -697
- package/bin/lib/workspace.js +0 -182
- package/bin/owd.js +0 -5
- package/bin/tui.js +0 -1379
- package/dist/module.d.mts +0 -13
- package/dist/module.json +0 -9
- package/dist/module.mjs +0 -268
- package/dist/types.d.mts +0 -7
- package/index.ts +0 -5
- package/module.ts +0 -223
- package/runtime/components/Desktop/Application/DesktopApplicationRender.vue +0 -20
- package/runtime/components/Desktop/Application/DesktopApplicationWindowsRender.vue +0 -38
- package/runtime/components/Desktop/Background/DesktopBackground.vue +0 -16
- package/runtime/components/Desktop/Core/DesktopCore.vue +0 -90
- package/runtime/components/Desktop/Time/DesktopTime.vue +0 -56
- package/runtime/components/Desktop/Window/DesktopWindow.vue +0 -204
- package/runtime/components/Desktop/Window/DesktopWindowContent.vue +0 -28
- package/runtime/components/Desktop/Window/DesktopWindowNav.vue +0 -66
- package/runtime/composables/useApplicationEntries.ts +0 -51
- package/runtime/composables/useApplicationManager.ts +0 -285
- package/runtime/composables/useDesktopManager.ts +0 -49
- package/runtime/composables/useTerminalManager.ts +0 -66
- package/runtime/composables/useWorkspaceManager.ts +0 -41
- package/runtime/internal/controllers/ApplicationController.ts +0 -345
- package/runtime/internal/controllers/WindowController.ts +0 -462
- package/runtime/plugins/02.desktop-register-desktop-apps.client.ts +0 -17
- package/runtime/plugins/resize.client.ts +0 -6
- package/runtime/stores/storeApplicationMeta.ts +0 -59
- package/runtime/stores/storeApplicationWindows.ts +0 -20
- package/runtime/stores/storeDesktop.ts +0 -111
- package/runtime/stores/storeDesktopDefaultApps.ts +0 -53
- package/runtime/stores/storeDesktopVolume.ts +0 -18
- package/runtime/stores/storeDesktopWindow.ts +0 -20
- package/runtime/stores/storeDesktopWorkspace.ts +0 -75
- package/runtime/utils/captureElementToCanvas.ts +0 -21
- package/runtime/utils/explorerEntryPath.ts +0 -10
- package/runtime/utils/resolveDesktopConfigPath.ts +0 -52
- package/runtime/utils/splitDesktopUserConfig.ts +0 -85
- package/runtime/utils/utilApp.ts +0 -37
- package/runtime/utils/utilCommon.ts +0 -26
- package/runtime/utils/utilDebug.ts +0 -30
- package/runtime/utils/utilDesktop.ts +0 -35
- package/runtime/utils/utilTerminal.ts +0 -6
- package/runtime/utils/utilWindow.ts +0 -15
- package/runtime/utils/validateDesktopUserConfig.ts +0 -44
- package/types/index.d.ts +0 -420
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { computed } from 'vue'
|
|
2
|
-
import { useAppConfig } from 'nuxt/app'
|
|
3
|
-
import { defu } from 'defu'
|
|
4
|
-
import { useDesktopStore } from '../stores/storeDesktop'
|
|
5
|
-
import { useDesktopDefaultAppsStore } from '../stores/storeDesktopDefaultApps'
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Desktop Manager composable (singleton pattern via Pinia + app config).
|
|
9
|
-
* Agnostic of any theme: merges runtime shell config and exposes default-app routing.
|
|
10
|
-
*/
|
|
11
|
-
export function useDesktopManager() {
|
|
12
|
-
const appConfig = useAppConfig()
|
|
13
|
-
const desktopStore = useDesktopStore()
|
|
14
|
-
const defaultAppsStore = useDesktopDefaultAppsStore()
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Merges and sets the desktop config at runtime (shell geometry, feature flags, etc.).
|
|
18
|
-
*/
|
|
19
|
-
function setConfig(newConfig: DesktopConfig) {
|
|
20
|
-
appConfig.desktop = defu(
|
|
21
|
-
newConfig,
|
|
22
|
-
(appConfig.desktop ?? {}) as DesktopConfig,
|
|
23
|
-
) as DesktopConfig
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/** Map of feature name → default app handler (e.g. terminal, browser). */
|
|
27
|
-
const defaultApps = computed(
|
|
28
|
-
() => desktopStore.state.defaultApps,
|
|
29
|
-
)
|
|
30
|
-
|
|
31
|
-
function getDefaultApp(feature: string) {
|
|
32
|
-
return defaultAppsStore.getDefaultApp(feature)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function setDefaultApp(
|
|
36
|
-
feature: string,
|
|
37
|
-
application: IApplicationController,
|
|
38
|
-
entry: string,
|
|
39
|
-
) {
|
|
40
|
-
defaultAppsStore.setDefaultApp(feature, application, entry)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return {
|
|
44
|
-
setConfig,
|
|
45
|
-
defaultApps,
|
|
46
|
-
getDefaultApp,
|
|
47
|
-
setDefaultApp,
|
|
48
|
-
}
|
|
49
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { useApplicationManager } from './useApplicationManager'
|
|
2
|
-
import { debugLog } from '../utils/utilDebug'
|
|
3
|
-
|
|
4
|
-
const commands = new Map<string, TerminalCommand>()
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Terminal Manager Composable (Singleton)
|
|
8
|
-
*/
|
|
9
|
-
export function useTerminalManager() {
|
|
10
|
-
/**
|
|
11
|
-
* Add a new terminal command
|
|
12
|
-
*
|
|
13
|
-
* @param command
|
|
14
|
-
*/
|
|
15
|
-
const addCommand = (command: TerminalCommand) => {
|
|
16
|
-
for (const existingCommand of commands.keys()) {
|
|
17
|
-
if (
|
|
18
|
-
existingCommand.startsWith(command.name) ||
|
|
19
|
-
command.name.startsWith(existingCommand)
|
|
20
|
-
) {
|
|
21
|
-
throw new Error(`Command prefix conflict with "${existingCommand}"`)
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
commands.set(command.name, command)
|
|
26
|
-
debugLog(`Registered terminal command: ${command.name} → ${command.applicationId}`)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* List all registered command names
|
|
31
|
-
*/
|
|
32
|
-
const listCommands = (): string[] => {
|
|
33
|
-
return Array.from(commands.keys())
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Execute a terminal command
|
|
38
|
-
*
|
|
39
|
-
* @param input
|
|
40
|
-
*/
|
|
41
|
-
const execCommand = async (input: string): Promise<CommandOutput | void> => {
|
|
42
|
-
const applicationManager = useApplicationManager()
|
|
43
|
-
|
|
44
|
-
const [name, ...args] = input.trim().split(/\s+/)
|
|
45
|
-
|
|
46
|
-
if (!name) {
|
|
47
|
-
return
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (!commands.has(name)) {
|
|
51
|
-
return {
|
|
52
|
-
message: `Command "${name}" not found`,
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const application = commands.get(name)!
|
|
57
|
-
|
|
58
|
-
return applicationManager.execAppCommand(application.applicationId, input)
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return {
|
|
62
|
-
addCommand,
|
|
63
|
-
listCommands,
|
|
64
|
-
execCommand,
|
|
65
|
-
}
|
|
66
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { useEventListener } from '@vueuse/core'
|
|
2
|
-
import { useApplicationManager } from './useApplicationManager'
|
|
3
|
-
import { useDesktopWorkspaceStore } from '../stores/storeDesktopWorkspace'
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Keyboard + HTML5 drop handlers for workspace management (move windows between desktops).
|
|
7
|
-
*/
|
|
8
|
-
export function useWorkspaceManager() {
|
|
9
|
-
const applicationManager = useApplicationManager()
|
|
10
|
-
const desktopWorkspaceStore = useDesktopWorkspaceStore()
|
|
11
|
-
|
|
12
|
-
useEventListener(window, 'keydown', (e: KeyboardEvent) => {
|
|
13
|
-
if (e.key !== 'Escape') return
|
|
14
|
-
if (!desktopWorkspaceStore.overview) return
|
|
15
|
-
desktopWorkspaceStore.setOverview(false)
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
function onWorkspaceDragOver(e: DragEvent) {
|
|
19
|
-
if (!desktopWorkspaceStore.overview) return
|
|
20
|
-
e.preventDefault()
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function onWorkspaceDrop(e: DragEvent, workspaceId: string) {
|
|
24
|
-
e.preventDefault()
|
|
25
|
-
if (!desktopWorkspaceStore.overview) return
|
|
26
|
-
|
|
27
|
-
const raw =
|
|
28
|
-
e.dataTransfer?.getData('text/plain') ||
|
|
29
|
-
e.dataTransfer?.getData('text') ||
|
|
30
|
-
''
|
|
31
|
-
if (!raw) return
|
|
32
|
-
|
|
33
|
-
const win = applicationManager.getWindowOpenedId(raw)
|
|
34
|
-
win?.actions.setWorkspace(workspaceId)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return {
|
|
38
|
-
onWorkspaceDragOver,
|
|
39
|
-
onWorkspaceDrop,
|
|
40
|
-
}
|
|
41
|
-
}
|
|
@@ -1,345 +0,0 @@
|
|
|
1
|
-
import { nanoid } from 'nanoid'
|
|
2
|
-
import { WindowController } from './WindowController'
|
|
3
|
-
import { useApplicationManager } from '../../composables/useApplicationManager'
|
|
4
|
-
import { useApplicationWindowsStore } from '../../stores/storeApplicationWindows'
|
|
5
|
-
import { useApplicationMetaStore } from '../../stores/storeApplicationMeta'
|
|
6
|
-
import { useTerminalManager } from '../../composables/useTerminalManager'
|
|
7
|
-
import { debugLog, debugError } from '../../utils/utilDebug'
|
|
8
|
-
import { useDesktopDefaultAppsStore } from '../../stores/storeDesktopDefaultApps'
|
|
9
|
-
import { useDesktopWorkspaceStore } from '../../stores/storeDesktopWorkspace'
|
|
10
|
-
import { useDesktopWindowStore } from '../../stores/storeDesktopWindow'
|
|
11
|
-
import { shallowRef } from 'vue'
|
|
12
|
-
import { unref } from 'vue'
|
|
13
|
-
|
|
14
|
-
export class ApplicationController implements IApplicationController {
|
|
15
|
-
private readonly applicationManager: IApplicationManager
|
|
16
|
-
private readonly terminalManager: ITerminalManager
|
|
17
|
-
|
|
18
|
-
public readonly id
|
|
19
|
-
public readonly config
|
|
20
|
-
public readonly storeWindows
|
|
21
|
-
|
|
22
|
-
private readonly _windows = shallowRef(new Map<string, IWindowController>())
|
|
23
|
-
|
|
24
|
-
/** Reactive window count for Vue (class getters are not tracked). */
|
|
25
|
-
public readonly openWindowCount = shallowRef(0)
|
|
26
|
-
|
|
27
|
-
get windows(): Map<string, IWindowController> {
|
|
28
|
-
return this._windows.value
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
private replaceWindows(
|
|
32
|
-
mutator: (next: Map<string, IWindowController>) => void,
|
|
33
|
-
) {
|
|
34
|
-
const next = new Map(this._windows.value)
|
|
35
|
-
mutator(next)
|
|
36
|
-
this._windows.value = next
|
|
37
|
-
this.openWindowCount.value = next.size
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
public isRunning = false
|
|
41
|
-
|
|
42
|
-
constructor(id: string, config: ApplicationConfig) {
|
|
43
|
-
this.applicationManager = useApplicationManager()
|
|
44
|
-
this.terminalManager = useTerminalManager()
|
|
45
|
-
|
|
46
|
-
this.id = id
|
|
47
|
-
this.config = config
|
|
48
|
-
this.storeWindows = useApplicationWindowsStore(id)
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/** Lazy meta store — app modules should register state via `useApplicationMetaStore` before `defineDesktopApp`. */
|
|
52
|
-
get storeMeta() {
|
|
53
|
-
return useApplicationMetaStore(this.id)()
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
public async initApplication(): Promise<void> {
|
|
57
|
-
const desktopDefaultAppsStore = useDesktopDefaultAppsStore()
|
|
58
|
-
|
|
59
|
-
// provides
|
|
60
|
-
|
|
61
|
-
// set as default app for specific purposes
|
|
62
|
-
// todo improve this and move it in a store
|
|
63
|
-
if (this.config.provides) {
|
|
64
|
-
const existingDefault = desktopDefaultAppsStore.getDefaultApp(
|
|
65
|
-
this.config.provides.name,
|
|
66
|
-
)
|
|
67
|
-
|
|
68
|
-
if (!existingDefault) {
|
|
69
|
-
desktopDefaultAppsStore.setDefaultApp(
|
|
70
|
-
this.config.provides.name,
|
|
71
|
-
this,
|
|
72
|
-
this.config.provides.entry,
|
|
73
|
-
)
|
|
74
|
-
|
|
75
|
-
debugLog(
|
|
76
|
-
`${this.config.title} has been set as predefined app for "${this.config.provides.name}"`,
|
|
77
|
-
)
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// terminal
|
|
82
|
-
|
|
83
|
-
if (this.config.commands) {
|
|
84
|
-
for (const commandKey of Object.keys(this.config.commands)) {
|
|
85
|
-
this.terminalManager.addCommand({
|
|
86
|
-
applicationId: this.id,
|
|
87
|
-
name: commandKey,
|
|
88
|
-
})
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// store
|
|
93
|
-
|
|
94
|
-
if (this.storeWindows.$persistedState) {
|
|
95
|
-
await this.storeWindows.$persistedState.isReady()
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
if (this.storeMeta.$persistedState) {
|
|
99
|
-
await this.storeMeta.$persistedState.isReady()
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// set default meta values
|
|
103
|
-
// this.storeMeta.meta = this.config.meta ?? {}
|
|
104
|
-
|
|
105
|
-
// restore application state
|
|
106
|
-
await this.restoreApplication()
|
|
107
|
-
|
|
108
|
-
// once app is defined, always run "onReady"
|
|
109
|
-
if (typeof this.config.onReady === 'function') {
|
|
110
|
-
// todo transform in hook
|
|
111
|
-
this.config.onReady(this)
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* App always tries to restore previous windows
|
|
117
|
-
* and returns a boolean if it succeeded
|
|
118
|
-
*/
|
|
119
|
-
public async restoreApplication() {
|
|
120
|
-
if (typeof this.config.onRestore === 'function') {
|
|
121
|
-
// todo transform in hook
|
|
122
|
-
await this.config.onRestore(this)
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
if (
|
|
126
|
-
!this.storeWindows.windows ||
|
|
127
|
-
Object.keys(this.storeWindows.windows).length === 0
|
|
128
|
-
) {
|
|
129
|
-
return false
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
this.restoreWindows()
|
|
133
|
-
|
|
134
|
-
this.setRunning(true)
|
|
135
|
-
|
|
136
|
-
return true
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
private restoreWindows() {
|
|
140
|
-
Object.keys(this.storeWindows.windows).map((windowId) => {
|
|
141
|
-
const windowStore: WindowStoredState | undefined =
|
|
142
|
-
this.storeWindows.windows[windowId]
|
|
143
|
-
|
|
144
|
-
if (windowStore) {
|
|
145
|
-
this.openWindow(windowStore.model, windowStore, {
|
|
146
|
-
isRestoring: true,
|
|
147
|
-
})
|
|
148
|
-
}
|
|
149
|
-
})
|
|
150
|
-
|
|
151
|
-
this.normalizeWindowFocus()
|
|
152
|
-
|
|
153
|
-
debugLog('Windows have been restored', this.windows)
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
/** Ensure a single focused window after restore or stale persisted state. */
|
|
157
|
-
private normalizeWindowFocus() {
|
|
158
|
-
if (this.windows.size === 0) {
|
|
159
|
-
return
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
let topWindow: IWindowController | undefined
|
|
163
|
-
let topZ = -Infinity
|
|
164
|
-
|
|
165
|
-
for (const window of this.windows.values()) {
|
|
166
|
-
window.setFocus(false)
|
|
167
|
-
const z = window.state.position?.z ?? 0
|
|
168
|
-
if (z >= topZ) {
|
|
169
|
-
topZ = z
|
|
170
|
-
topWindow = window
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
topWindow?.setFocus(true)
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
public openWindow(
|
|
178
|
-
model: string,
|
|
179
|
-
windowStoredState: WindowStoredState | undefined,
|
|
180
|
-
meta?: any,
|
|
181
|
-
) {
|
|
182
|
-
const desktopWorkspaceStore = useDesktopWorkspaceStore()
|
|
183
|
-
|
|
184
|
-
if (!this.config.windows || !this.config.windows.hasOwnProperty(model)) {
|
|
185
|
-
debugError(`Window model "${model}" not found`)
|
|
186
|
-
return
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
if (!windowStoredState && this.config.singleton) {
|
|
190
|
-
const existing = this.getFirstWindowByModel(model)
|
|
191
|
-
if (existing) {
|
|
192
|
-
if (meta && typeof meta === 'object') {
|
|
193
|
-
Object.assign(existing.meta, meta)
|
|
194
|
-
}
|
|
195
|
-
if (!meta?.isRestoring) {
|
|
196
|
-
existing.actions.setActive(true)
|
|
197
|
-
existing.actions.bringToFront()
|
|
198
|
-
}
|
|
199
|
-
return existing
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
let windowId: string
|
|
204
|
-
|
|
205
|
-
if (!windowStoredState) {
|
|
206
|
-
windowId = `${model}-${nanoid(6)}`
|
|
207
|
-
|
|
208
|
-
const windowConfig: WindowConfig = this.config.windows[
|
|
209
|
-
model
|
|
210
|
-
] as WindowConfig
|
|
211
|
-
const screenHeight = window.innerHeight
|
|
212
|
-
const configHeight = windowConfig.size?.height
|
|
213
|
-
const layoutHeight =
|
|
214
|
-
typeof configHeight === 'number'
|
|
215
|
-
? configHeight
|
|
216
|
-
: typeof configHeight === 'string' && /^\d+$/.test(configHeight)
|
|
217
|
-
? Number(configHeight)
|
|
218
|
-
: 240
|
|
219
|
-
const centerY = (screenHeight - layoutHeight) / 2
|
|
220
|
-
const positionY =
|
|
221
|
-
windowConfig.position?.y !== undefined
|
|
222
|
-
? window.scrollY + windowConfig.position.y
|
|
223
|
-
: window.scrollY + centerY
|
|
224
|
-
const cascadeStep = 40
|
|
225
|
-
const cascadeOffset = this.getWindowsByModel(model).length * cascadeStep
|
|
226
|
-
const baseX = windowConfig.position?.x ?? 100
|
|
227
|
-
const desktopWindowStore = useDesktopWindowStore()
|
|
228
|
-
const initialZ = desktopWindowStore.incrementPositionZ()
|
|
229
|
-
|
|
230
|
-
const nextWindows = {
|
|
231
|
-
...this.storeWindows.windows,
|
|
232
|
-
[windowId]: {
|
|
233
|
-
model,
|
|
234
|
-
state: {
|
|
235
|
-
id: windowId,
|
|
236
|
-
active: true,
|
|
237
|
-
focused: false,
|
|
238
|
-
position: {
|
|
239
|
-
x: baseX + cascadeOffset,
|
|
240
|
-
y: positionY + cascadeOffset,
|
|
241
|
-
z: initialZ,
|
|
242
|
-
},
|
|
243
|
-
createdAt: +new Date(),
|
|
244
|
-
workspace: desktopWorkspaceStore.resolveActiveWorkspaceId(),
|
|
245
|
-
},
|
|
246
|
-
meta,
|
|
247
|
-
},
|
|
248
|
-
}
|
|
249
|
-
this.storeWindows.windows = nextWindows
|
|
250
|
-
|
|
251
|
-
windowStoredState = this.storeWindows.windows[windowId]
|
|
252
|
-
} else {
|
|
253
|
-
// restore previous id if state is defined
|
|
254
|
-
windowId =
|
|
255
|
-
windowStoredState.state?.id ??
|
|
256
|
-
Object.keys(this.storeWindows.windows).find(
|
|
257
|
-
(key) => this.storeWindows.windows[key] === windowStoredState,
|
|
258
|
-
) ??
|
|
259
|
-
`${model}-restored`
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
const windowConfig = this.config.windows[model] as WindowConfig
|
|
263
|
-
|
|
264
|
-
const windowController = new WindowController(
|
|
265
|
-
this,
|
|
266
|
-
model,
|
|
267
|
-
windowConfig,
|
|
268
|
-
windowStoredState!,
|
|
269
|
-
)
|
|
270
|
-
|
|
271
|
-
if (!meta?.isRestoring) {
|
|
272
|
-
windowController.actions.bringToFront()
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
this.replaceWindows((next) => {
|
|
276
|
-
next.set(windowId, windowController)
|
|
277
|
-
})
|
|
278
|
-
|
|
279
|
-
this.setRunning(true)
|
|
280
|
-
|
|
281
|
-
return windowController
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
public closeWindow(windowId: string) {
|
|
285
|
-
if (this.storeWindows.windows[windowId]) {
|
|
286
|
-
const nextWindows = { ...this.storeWindows.windows }
|
|
287
|
-
delete nextWindows[windowId]
|
|
288
|
-
this.storeWindows.windows = nextWindows
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
this.replaceWindows((next) => {
|
|
292
|
-
next.delete(windowId)
|
|
293
|
-
})
|
|
294
|
-
|
|
295
|
-
if (this.openWindowCount.value === 0) {
|
|
296
|
-
this.applicationManager.closeApp(this.id)
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
public closeAllWindows() {
|
|
301
|
-
this.storeWindows.windows = {}
|
|
302
|
-
this._windows.value = new Map()
|
|
303
|
-
this.openWindowCount.value = 0
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
get windowsOpened() {
|
|
307
|
-
return this.windows
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
public getWindowById(id: string): IWindowController[] {
|
|
311
|
-
return this.windows.get(id)
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
public getWindowsByModel(model: string): IWindowController[] {
|
|
315
|
-
return Array.from(this.windows.values()).filter((w) => w.model === model)
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
public getFirstWindowByModel(model: string): IWindowController | undefined {
|
|
319
|
-
return Array.from(this.windows.values()).find((w) => w.model === model)
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
public setRunning(value: boolean): void {
|
|
323
|
-
this.isRunning = value
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
// meta
|
|
327
|
-
|
|
328
|
-
get meta() {
|
|
329
|
-
return this.storeMeta.meta
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
getMeta(key: string) {
|
|
333
|
-
return this.meta[key]
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
setMeta(key: string, value: any) {
|
|
337
|
-
this.meta[key] = value
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
// commands
|
|
341
|
-
|
|
342
|
-
async execCommand(command: string): Promise<CommandOutput | void> {
|
|
343
|
-
return this.applicationManager.execAppCommand(this.id, command)
|
|
344
|
-
}
|
|
345
|
-
}
|