@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
@@ -1,47 +0,0 @@
1
- export class DesktopManager {
2
- private defaultApps: DefaultAppsConfig = {}
3
-
4
- constructor() {}
5
-
6
- get config(): DesktopConfig {
7
- const runtimeConfig = useRuntimeConfig()
8
-
9
- return runtimeConfig.public.desktop
10
- }
11
-
12
- public hasFeature(featureName: string) {
13
- return this.config.features?.indexOf(featureName) !== -1
14
- }
15
-
16
- public setConfig(config: DesktopConfig) {
17
- const runtimeConfig = useRuntimeConfig()
18
-
19
- runtimeConfig.public.desktop = deepMerge(
20
- runtimeConfig.public.desktop,
21
- config
22
- ) as DesktopConfig
23
-
24
- this.loadDefaultAppsFromConfig()
25
- }
26
-
27
- public setDefaultApp(
28
- feature: string,
29
- application: IApplicationController,
30
- command: string,
31
- ) {
32
- this.defaultApps[feature] = {
33
- application,
34
- command,
35
- }
36
- }
37
-
38
- public getDefaultApp(feature: string): DefaultAppConfig {
39
- return this.defaultApps[feature] as DefaultAppConfig
40
- }
41
-
42
- private loadDefaultAppsFromConfig() {
43
- if (this.config.defaultApps) {
44
- this.defaultApps = { ...this.config.defaultApps }
45
- }
46
- }
47
- }
@@ -1,48 +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
- public addCommand(command: TerminalCommand) {
10
- for (const existingCommand of this.commands.keys()) {
11
- if (
12
- existingCommand.startsWith(command.name) ||
13
- command.name.startsWith(existingCommand)
14
- ) {
15
- throw new Error(`Command prefix conflict with "${existingCommand}"`)
16
- }
17
- }
18
-
19
- this.commands.set(command.name, command)
20
- debugLog(
21
- `Registered terminal command: ${command.name} → ${command.applicationId}`,
22
- )
23
- }
24
-
25
- public listCommands(): string[] {
26
- return Array.from(this.commands.keys())
27
- }
28
-
29
- public async execCommand(input: string): Promise<CommandOutput | void> {
30
- const applicationManager = useApplicationManager()
31
-
32
- const [name, ...args] = input.trim().split(/\s+/)
33
-
34
- if (!name) {
35
- return
36
- }
37
-
38
- if (!this.commands.has(name)) {
39
- return {
40
- message: `Command "${name}" not found`,
41
- }
42
- }
43
-
44
- const application = this.commands.get(name)!
45
-
46
- return applicationManager.execAppCommand(application.applicationId, input)
47
- }
48
- }
@@ -1,235 +0,0 @@
1
- import { defineStore } from 'pinia'
2
- import { reactive, ref, computed } from 'vue'
3
- import { nanoid } from 'nanoid'
4
- import { WindowController } from '../core/controllers/WindowController'
5
- import { useApplicationManager } from '../composables/useApplicationManager'
6
- import { useApplicationWindowsStore } from './storeApplicationWindows'
7
- import { useApplicationMetaStore } from './storeApplicationMeta'
8
- import { useTerminalManager } from '../composables/useTerminalManager'
9
- import { useDesktopManager } from '../composables/useDesktopManager'
10
- import { useDesktopWorkspaceStore } from './storeDesktopWorkspace'
11
- import { debugLog, debugError } from '../utils/utilDebug'
12
-
13
- interface WindowStoredState {
14
- model: string
15
- state: any
16
- meta?: any
17
- }
18
-
19
- export const useApplicationStore = function(applicationId: string, applicationConfig: ApplicationConfig) {
20
- return defineStore(`owd/application/${applicationId}`, () => {
21
- // reactive state
22
- const windows = reactive(new Map<string, WindowController>())
23
- const isRunning = ref<boolean>(false)
24
-
25
- // composables e stores esterni
26
- const applicationManager = useApplicationManager()
27
- const terminalManager = useTerminalManager()
28
- const desktopManager = useDesktopManager()
29
- const desktopWorkspaceStore = useDesktopWorkspaceStore()
30
-
31
- // stores figli
32
- let storeWindows: ReturnType<typeof useApplicationWindowsStore>
33
- let storeMeta: ReturnType<typeof useApplicationMetaStore>
34
-
35
- // init application
36
- async function initApplication() {
37
- storeWindows = useApplicationWindowsStore(applicationId)
38
- storeMeta = useApplicationMetaStore(applicationId)
39
-
40
- // Fornisci applicazione di default se presente
41
- if (applicationConfig.provides) {
42
- const existingDefault = desktopManager.getDefaultApp(
43
- applicationConfig.provides.name,
44
- )
45
- if (!existingDefault) {
46
- desktopManager.setDefaultApp(
47
- applicationConfig.provides.name,
48
- store, // store o qualcosa che rappresenta questa app?
49
- applicationConfig.entries![applicationConfig.provides.entry]!,
50
- )
51
- debugLog(
52
- `${applicationConfig.title} set as predefined app for "${applicationConfig.provides.name}"`,
53
- )
54
- }
55
- }
56
-
57
- // registra comandi terminale
58
- if (applicationConfig.commands) {
59
- for (const commandKey of Object.keys(applicationConfig.commands)) {
60
- terminalManager.addCommand({
61
- applicationId,
62
- name: commandKey,
63
- })
64
- }
65
- }
66
-
67
- if (storeWindows.$persistedState) await storeWindows.$persistedState.isReady()
68
- if (storeMeta.$persistedState) await storeMeta.$persistedState.isReady()
69
-
70
- await restoreApplication()
71
-
72
- if (typeof applicationConfig.onReady === 'function') {
73
- applicationConfig.onReady(store)
74
- }
75
- }
76
-
77
- // restore
78
- async function restoreApplication() {
79
- if (typeof applicationConfig.onRestore === 'function') {
80
- await applicationConfig.onRestore(store)
81
- }
82
-
83
- if (!storeWindows.windows || Object.keys(storeWindows.windows).length === 0) {
84
- return false
85
- }
86
-
87
- restoreWindows()
88
- setRunning(true)
89
- return true
90
- }
91
-
92
- function restoreWindows() {
93
- Object.keys(storeWindows.windows).forEach((windowId) => {
94
- const windowStore = storeWindows.windows[windowId]
95
- if (windowStore) {
96
- openWindow(windowStore.model, windowStore, { isRestoring: true })
97
- }
98
- })
99
- debugLog('Windows restored', windows)
100
- }
101
-
102
- // open window
103
- function openWindow(
104
- model: string,
105
- windowStoredState?: WindowStoredState,
106
- meta?: any,
107
- ): WindowController | undefined {
108
- if (!applicationConfig.windows || !applicationConfig.windows.hasOwnProperty(model)) {
109
- debugError(`Window model "${model}" not found`)
110
- return
111
- }
112
-
113
- let windowId: string
114
-
115
- if (!windowStoredState) {
116
- windowId = `${model}-${nanoid(6)}`
117
- const windowConfig = applicationConfig.windows[model] as WindowConfig
118
- const screenHeight = window.innerHeight
119
- const centerY = (screenHeight - Number(windowConfig.size.height)) / 2
120
- const positionY =
121
- windowConfig.position?.y !== undefined
122
- ? window.scrollY + windowConfig.position.y
123
- : window.scrollY + centerY
124
-
125
- storeWindows.windows[windowId] = {
126
- model,
127
- state: {
128
- id: windowId,
129
- active: true,
130
- focused: false,
131
- position: {
132
- x: windowConfig.position?.x,
133
- y: positionY,
134
- },
135
- createdAt: +new Date(),
136
- workspace: desktopWorkspaceStore.active,
137
- },
138
- meta,
139
- }
140
-
141
- windowStoredState = storeWindows.windows[windowId]
142
- } else {
143
- windowId = windowStoredState.state.id
144
- }
145
-
146
- const windowConfig = applicationConfig.windows[model] as WindowConfig
147
- const windowController = new WindowController(store, model, windowConfig, windowStoredState!)
148
-
149
- if (!meta?.isRestoring) {
150
- windowController.actions.bringToFront()
151
- }
152
-
153
- windows.set(windowId, windowController)
154
- setRunning(true)
155
-
156
- return windowController
157
- }
158
-
159
- // close window
160
- function closeWindow(windowId: string) {
161
- delete storeWindows.windows[windowId]
162
- windows.delete(windowId)
163
-
164
- if (windows.size === 0) {
165
- applicationManager.closeApp(applicationId)
166
- }
167
- }
168
-
169
- // close all windows
170
- function closeAllWindows() {
171
- storeWindows.windows = {}
172
- windows.clear()
173
- }
174
-
175
- // getters
176
- const windowsOpened = computed(() => windows)
177
-
178
- function getWindowById(id: string) {
179
- return windows.get(id)
180
- }
181
-
182
- function getWindowsByModel(model: string) {
183
- return Array.from(windows.values()).filter((w) => w.model === model)
184
- }
185
-
186
- function getFirstWindowByModel(model: string) {
187
- return Array.from(windows.values()).find((w) => w.model === model)
188
- }
189
-
190
- function setRunning(value: boolean) {
191
- isRunning.value = value
192
- }
193
-
194
- // meta management
195
- const meta = computed(() => storeMeta.meta)
196
-
197
- function getMeta(key: string) {
198
- return meta.value[key]
199
- }
200
-
201
- function setMeta(key: string, value: any) {
202
- storeMeta.meta[key] = value
203
- }
204
-
205
- // command exec
206
- async function execCommand(command: string) {
207
- return applicationManager.execAppCommand(applicationId, command)
208
- }
209
-
210
- const store = {
211
- id: applicationId,
212
- config: applicationConfig,
213
- storeWindows,
214
- storeMeta,
215
- windows,
216
- isRunning,
217
- initApplication,
218
- restoreApplication,
219
- openWindow,
220
- closeWindow,
221
- closeAllWindows,
222
- windowsOpened,
223
- getWindowById,
224
- getWindowsByModel,
225
- getFirstWindowByModel,
226
- setRunning,
227
- meta,
228
- getMeta,
229
- setMeta,
230
- execCommand,
231
- }
232
-
233
- return store
234
- })()
235
- }
@@ -1,15 +0,0 @@
1
- import { fileURLToPath } from 'node:url'
2
- import { describe, it, expect } from 'vitest'
3
- import { setup, $fetch } from '@nuxt/test-utils/e2e'
4
-
5
- describe('ssr', async () => {
6
- await setup({
7
- rootDir: fileURLToPath(new URL('./fixtures/basic', import.meta.url)),
8
- })
9
-
10
- it('renders the index page', async () => {
11
- // Get response to a server-rendered page with `$fetch`.
12
- const html = await $fetch('/')
13
- expect(html).toContain('<div>basic</div>')
14
- })
15
- })
@@ -1,5 +0,0 @@
1
- <template>
2
- <div>basic</div>
3
- </template>
4
-
5
- <script setup></script>
@@ -1,5 +0,0 @@
1
- import MyModule from '../../../module'
2
-
3
- export default defineNuxtConfig({
4
- modules: [MyModule],
5
- })
@@ -1,5 +0,0 @@
1
- {
2
- "private": true,
3
- "name": "basic",
4
- "type": "module"
5
- }
package/tsconfig.app.json DELETED
@@ -1,31 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.base.json",
3
- "compilerOptions": {
4
- "outDir": "dist",
5
- "rootDir": "runtime",
6
- "jsx": "preserve",
7
- "jsxImportSource": "vue",
8
- "resolveJsonModule": true,
9
- "tsBuildInfoFile": "dist/tsconfig.app.tsbuildinfo"
10
- },
11
- "include": [".nuxt/nuxt.d.ts", "runtime/**/*", "types/index.d.ts"],
12
- "exclude": [
13
- "out-tsc",
14
- "dist",
15
- "vite.config.ts",
16
- "vite.config.mts",
17
- "vitest.config.ts",
18
- "vitest.config.mts",
19
- "runtime/**/*.test.ts",
20
- "runtime/**/*.spec.ts",
21
- "runtime/**/*.test.tsx",
22
- "runtime/**/*.spec.tsx",
23
- "runtime/**/*.test.js",
24
- "runtime/**/*.spec.js",
25
- "runtime/**/*.test.jsx",
26
- "runtime/**/*.spec.jsx",
27
- "eslint.config.js",
28
- "eslint.config.cjs",
29
- "eslint.config.mjs"
30
- ]
31
- }
package/tsconfig.json DELETED
@@ -1,12 +0,0 @@
1
- {
2
- "files": [],
3
- "references": [
4
- {
5
- "path": "./tsconfig.app.json"
6
- },
7
- {
8
- "path": "./tsconfig.spec.json"
9
- }
10
- ],
11
- "extends": "../../tsconfig.base.json"
12
- }
@@ -1,37 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.base.json",
3
- "compilerOptions": {
4
- "outDir": "./out-tsc/vitest",
5
- "types": [
6
- "vitest/globals",
7
- "vitest/importMeta",
8
- "vite/client",
9
- "node",
10
- "vitest"
11
- ],
12
- "jsx": "preserve",
13
- "jsxImportSource": "vue",
14
- "resolveJsonModule": true
15
- },
16
- "include": [
17
- ".nuxt/nuxt.d.ts",
18
- "vite.config.ts",
19
- "vite.config.mts",
20
- "vitest.config.ts",
21
- "vitest.config.mts",
22
- "runtime/**/*.test.ts",
23
- "runtime/**/*.spec.ts",
24
- "runtime/**/*.test.tsx",
25
- "runtime/**/*.spec.tsx",
26
- "runtime/**/*.test.js",
27
- "runtime/**/*.spec.js",
28
- "runtime/**/*.test.jsx",
29
- "runtime/**/*.spec.jsx",
30
- "runtime/**/*.d.ts"
31
- ],
32
- "references": [
33
- {
34
- "path": "./tsconfig.app.json"
35
- }
36
- ]
37
- }
package/vitest.config.ts DELETED
@@ -1,24 +0,0 @@
1
- /// <reference types='vitest' />
2
- import { defineConfig } from 'vite'
3
- import vue from '@vitejs/plugin-vue'
4
-
5
- export default defineConfig(() => ({
6
- root: __dirname,
7
- cacheDir: '../../node_modules/.vite/packages/core',
8
- plugins: [vue()],
9
- // Uncomment this if you are using workers.
10
- // worker: {
11
- // plugins: [ nxViteTsPaths() ],
12
- // },
13
- test: {
14
- watch: false,
15
- globals: true,
16
- environment: 'jsdom',
17
- include: ['{src,tests}/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
18
- reporters: ['default'],
19
- coverage: {
20
- reportsDirectory: './test-output/vitest/coverage',
21
- provider: 'v8' as const,
22
- },
23
- },
24
- }))