@owdproject/core 3.1.4 → 3.3.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 +697 -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 +267 -0
  22. package/dist/types.d.mts +7 -0
  23. package/module.ts +69 -32
  24. package/package.json +81 -22
  25. package/runtime/components/{Core/Application/CoreApplicationRender.vue → Desktop/Application/DesktopApplicationRender.vue} +4 -2
  26. package/runtime/components/Desktop/Application/DesktopApplicationWindowsRender.vue +38 -0
  27. package/runtime/components/{Core/Window/CoreWindow.vue → Desktop/Window/DesktopWindow.vue} +42 -8
  28. package/runtime/components/{Core/Window/CoreWindowNav.vue → Desktop/Window/DesktopWindowNav.vue} +26 -8
  29. package/runtime/composables/useApplicationManager.ts +19 -14
  30. package/runtime/composables/useDesktopManager.ts +33 -9
  31. package/runtime/composables/useWorkspaceManager.ts +41 -0
  32. package/runtime/{core → internal}/controllers/ApplicationController.ts +114 -24
  33. package/runtime/{core → internal}/controllers/WindowController.ts +4 -9
  34. package/runtime/plugins/02.desktop-register-desktop-apps.client.ts +17 -0
  35. package/runtime/stores/storeApplicationMeta.ts +56 -12
  36. package/runtime/stores/storeDesktop.ts +68 -2
  37. package/runtime/stores/storeDesktopDefaultApps.ts +2 -2
  38. package/runtime/stores/storeDesktopWorkspace.ts +14 -2
  39. package/runtime/utils/captureElementToCanvas.ts +21 -0
  40. package/runtime/utils/explorerEntryPath.ts +10 -0
  41. package/runtime/utils/resolveDesktopConfigPath.ts +52 -0
  42. package/runtime/utils/splitDesktopUserConfig.ts +85 -0
  43. package/runtime/utils/utilCommon.ts +0 -32
  44. package/runtime/utils/utilDesktop.ts +27 -2
  45. package/runtime/utils/validateDesktopUserConfig.ts +44 -0
  46. package/types/index.d.ts +45 -12
  47. package/CHANGELOG.md +0 -25
  48. package/project.json +0 -4
  49. package/runtime/components/Core/Application/CoreApplicationWindowsRender.vue +0 -19
  50. package/runtime/components/Core/Explorer/CoreExplorerFile.vue +0 -76
  51. package/runtime/components/Core/Explorer/CoreExplorerFolder.vue +0 -10
  52. package/runtime/stores/storeApplication.ts +0 -236
  53. package/test/basic.test.ts +0 -15
  54. package/test/fixtures/basic/app.vue +0 -5
  55. package/test/fixtures/basic/nuxt.config.ts +0 -5
  56. package/test/fixtures/basic/package.json +0 -5
  57. package/tsconfig.app.json +0 -31
  58. package/tsconfig.json +0 -12
  59. package/tsconfig.spec.json +0 -37
  60. package/vitest.config.ts +0 -24
  61. /package/runtime/components/{Core/Background/CoreBackground.vue → Desktop/Background/DesktopBackground.vue} +0 -0
  62. /package/runtime/components/{Core/Desktop/CoreDesktop.vue → Desktop/Core/DesktopCore.vue} +0 -0
  63. /package/runtime/components/{Core/Time/CoreTime.vue → Desktop/Time/DesktopTime.vue} +0 -0
  64. /package/runtime/components/{Core/Window/CoreWindowContent.vue → Desktop/Window/DesktopWindowContent.vue} +0 -0
@@ -1,10 +0,0 @@
1
- <template>
2
- <CoreExplorerFile class="owd-explorer-folder">
3
- <slot />
4
- </CoreExplorerFile>
5
- </template>
6
-
7
- <style scoped lang="scss">
8
- .owd-explorer-folder {
9
- }
10
- </style>
@@ -1,236 +0,0 @@
1
- // actually unused
2
-
3
- import { defineStore } from 'pinia'
4
- import { reactive, ref, computed } from 'vue'
5
- import { nanoid } from 'nanoid'
6
- import { WindowController } from '../core/controllers/WindowController'
7
- import { useApplicationManager } from '../composables/useApplicationManager'
8
- import { useApplicationWindowsStore } from './storeApplicationWindows'
9
- import { useApplicationMetaStore } from './storeApplicationMeta'
10
- import { useTerminalManager } from '../composables/useTerminalManager'
11
- import { useDesktopDefaultAppsStore } from './storeDesktopDefaultApps'
12
- import { useDesktopWorkspaceStore } from './storeDesktopWorkspace'
13
- import { debugLog, debugError } from '../utils/utilDebug'
14
-
15
- interface WindowStoredState {
16
- model: string
17
- state: any
18
- meta?: any
19
- }
20
-
21
- export const useApplicationStore = function(applicationId: string, applicationConfig: ApplicationConfig) {
22
- return defineStore(`owd/application/${applicationId}`, () => {
23
- // reactive state
24
- const windows = reactive(new Map<string, WindowController>())
25
- const isRunning = ref<boolean>(false)
26
-
27
- // composables and external stores
28
- const applicationManager = useApplicationManager()
29
- const terminalManager = useTerminalManager()
30
- const desktopDefaultAppsStore = useDesktopDefaultAppsStore()
31
- const desktopWorkspaceStore = useDesktopWorkspaceStore()
32
-
33
- let storeWindows: ReturnType<typeof useApplicationWindowsStore>
34
- let storeMeta: ReturnType<typeof useApplicationMetaStore>
35
-
36
- // init application
37
- async function initApplication() {
38
- storeWindows = useApplicationWindowsStore(applicationId)
39
- storeMeta = useApplicationMetaStore(applicationId)
40
-
41
- // set default app
42
- if (applicationConfig.provides) {
43
- const existingDefault = desktopDefaultAppsStore.getDefaultApp(
44
- applicationConfig.provides.name,
45
- )
46
- if (!existingDefault) {
47
- desktopDefaultAppsStore.setDefaultApp(
48
- applicationConfig.provides.name,
49
- store, // store o qualcosa che rappresenta questa app?
50
- applicationConfig.entries![applicationConfig.provides.entry]!,
51
- )
52
- debugLog(
53
- `${applicationConfig.title} set as predefined app for "${applicationConfig.provides.name}"`,
54
- )
55
- }
56
- }
57
-
58
- // register terminal commands
59
- if (applicationConfig.commands) {
60
- for (const commandKey of Object.keys(applicationConfig.commands)) {
61
- terminalManager.addCommand({
62
- applicationId,
63
- name: commandKey,
64
- })
65
- }
66
- }
67
-
68
- if (storeWindows.$persistedState) await storeWindows.$persistedState.isReady()
69
- if (storeMeta.$persistedState) await storeMeta.$persistedState.isReady()
70
-
71
- await restoreApplication()
72
-
73
- if (typeof applicationConfig.onReady === 'function') {
74
- applicationConfig.onReady(store)
75
- }
76
- }
77
-
78
- // restore
79
- async function restoreApplication() {
80
- if (typeof applicationConfig.onRestore === 'function') {
81
- await applicationConfig.onRestore(store)
82
- }
83
-
84
- if (!storeWindows.windows || Object.keys(storeWindows.windows).length === 0) {
85
- return false
86
- }
87
-
88
- restoreWindows()
89
- setRunning(true)
90
- return true
91
- }
92
-
93
- function restoreWindows() {
94
- Object.keys(storeWindows.windows).forEach((windowId) => {
95
- const windowStore = storeWindows.windows[windowId]
96
- if (windowStore) {
97
- openWindow(windowStore.model, windowStore, { isRestoring: true })
98
- }
99
- })
100
- debugLog('Windows restored', windows)
101
- }
102
-
103
- // open window
104
- function openWindow(
105
- model: string,
106
- windowStoredState?: WindowStoredState,
107
- meta?: any,
108
- ): WindowController | undefined {
109
- if (!applicationConfig.windows || !applicationConfig.windows.hasOwnProperty(model)) {
110
- debugError(`Window model "${model}" not found`)
111
- return
112
- }
113
-
114
- let windowId: string
115
-
116
- if (!windowStoredState) {
117
- windowId = `${model}-${nanoid(6)}`
118
- const windowConfig = applicationConfig.windows[model] as WindowConfig
119
- const screenHeight = window.innerHeight
120
- const centerY = (screenHeight - Number(windowConfig.size.height)) / 2
121
- const positionY =
122
- windowConfig.position?.y !== undefined
123
- ? window.scrollY + windowConfig.position.y
124
- : window.scrollY + centerY
125
-
126
- storeWindows.windows[windowId] = {
127
- model,
128
- state: {
129
- id: windowId,
130
- active: true,
131
- focused: false,
132
- position: {
133
- x: windowConfig.position?.x,
134
- y: positionY,
135
- },
136
- createdAt: +new Date(),
137
- workspace: desktopWorkspaceStore.active,
138
- },
139
- meta,
140
- }
141
-
142
- windowStoredState = storeWindows.windows[windowId]
143
- } else {
144
- windowId = windowStoredState.state.id
145
- }
146
-
147
- const windowConfig = applicationConfig.windows[model] as WindowConfig
148
- const windowController = new WindowController(store, model, windowConfig, windowStoredState!)
149
-
150
- if (!meta?.isRestoring) {
151
- windowController.actions.bringToFront()
152
- }
153
-
154
- windows.set(windowId, windowController)
155
- setRunning(true)
156
-
157
- return windowController
158
- }
159
-
160
- // close window
161
- function closeWindow(windowId: string) {
162
- delete storeWindows.windows[windowId]
163
- windows.delete(windowId)
164
-
165
- if (windows.size === 0) {
166
- applicationManager.closeApp(applicationId)
167
- }
168
- }
169
-
170
- // close all windows
171
- function closeAllWindows() {
172
- storeWindows.windows = {}
173
- windows.clear()
174
- }
175
-
176
- // getters
177
- const windowsOpened = computed(() => windows)
178
-
179
- function getWindowById(id: string) {
180
- return windows.get(id)
181
- }
182
-
183
- function getWindowsByModel(model: string) {
184
- return Array.from(windows.values()).filter((w) => w.model === model)
185
- }
186
-
187
- function getFirstWindowByModel(model: string) {
188
- return Array.from(windows.values()).find((w) => w.model === model)
189
- }
190
-
191
- function setRunning(value: boolean) {
192
- isRunning.value = value
193
- }
194
-
195
- // meta management
196
- const meta = computed(() => storeMeta.meta)
197
-
198
- function getMeta(key: string) {
199
- return meta.value[key]
200
- }
201
-
202
- function setMeta(key: string, value: any) {
203
- storeMeta.meta[key] = value
204
- }
205
-
206
- // command exec
207
- async function execCommand(command: string) {
208
- return applicationManager.execAppCommand(applicationId, command)
209
- }
210
-
211
- const store = {
212
- id: applicationId,
213
- config: applicationConfig,
214
- storeWindows,
215
- storeMeta,
216
- windows,
217
- isRunning,
218
- initApplication,
219
- restoreApplication,
220
- openWindow,
221
- closeWindow,
222
- closeAllWindows,
223
- windowsOpened,
224
- getWindowById,
225
- getWindowsByModel,
226
- getFirstWindowByModel,
227
- setRunning,
228
- meta,
229
- getMeta,
230
- setMeta,
231
- execCommand,
232
- }
233
-
234
- return store
235
- })()
236
- }
@@ -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
- }))