@owdproject/core 3.3.1 → 3.4.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 (92) hide show
  1. package/CHANGELOG.md +98 -0
  2. package/DESKTOP_KERNEL.md +232 -0
  3. package/MIGRATION_3.3.2.md +23 -0
  4. package/MIGRATION_3.4.md +126 -0
  5. package/PLAYGROUND.md +91 -0
  6. package/README.md +13 -80
  7. package/dist/module.d.mts +2 -2
  8. package/dist/module.json +3 -3
  9. package/dist/module.mjs +74 -88
  10. package/index.ts +6 -3
  11. package/kit/authoring.ts +340 -0
  12. package/kit/defineDesktopApp.ts +56 -0
  13. package/module.ts +64 -84
  14. package/package.json +70 -41
  15. package/runtime/components/{Desktop/Application/DesktopApplicationRender.vue → Application/DesktopCoreApplicationRender.vue} +2 -2
  16. package/runtime/components/{Desktop/Application/DesktopApplicationWindowsRender.vue → Application/DesktopCoreApplicationWindowsRender.vue} +1 -1
  17. package/runtime/components/core/DesktopCore.vue +43 -0
  18. package/runtime/components/{Desktop/Window/DesktopWindow.vue → window/DesktopCoreWindow.vue} +17 -6
  19. package/runtime/components/window/DesktopCoreWindowSnapHintsBase.vue +74 -0
  20. package/runtime/components/workspace/DesktopCoreWorkspaceEdgeHintsBase.vue +84 -0
  21. package/runtime/composables/useBlockNonInputContextMenu.ts +30 -0
  22. package/runtime/composables/useDesktopConfig.ts +8 -0
  23. package/runtime/composables/useDesktopDialogs.ts +16 -0
  24. package/runtime/composables/useDesktopExtension.ts +8 -0
  25. package/runtime/composables/useDesktopManager.ts +2 -0
  26. package/runtime/composables/useDesktopManifest.ts +17 -0
  27. package/runtime/composables/useDesktopSession.ts +27 -0
  28. package/runtime/composables/useDesktopShellIdentity.ts +99 -0
  29. package/runtime/composables/useDesktopShellOptions.ts +36 -0
  30. package/runtime/composables/useDesktopShellReady.ts +7 -0
  31. package/runtime/composables/useDesktopWorkArea.ts +93 -0
  32. package/runtime/composables/useTerminalManager.ts +102 -9
  33. package/runtime/composables/useToggleWindowMaximize.ts +35 -0
  34. package/runtime/composables/useWindowDragHandlers.ts +47 -0
  35. package/runtime/composables/useWindowSnapDrop.ts +112 -0
  36. package/runtime/composables/useWorkspaceEdgeDrop.ts +176 -0
  37. package/runtime/composables/useWorkspaceManager.ts +26 -0
  38. package/runtime/composables/useWorkspaceOverviewCapture.ts +92 -0
  39. package/runtime/composables/useWorkspaceOverviewLiveScale.ts +151 -0
  40. package/runtime/constants/desktopShellKeys.ts +12 -0
  41. package/runtime/constants/shellLayout.ts +5 -0
  42. package/runtime/dialogs/desktopDialogProvider.ts +73 -0
  43. package/runtime/internal/controllers/ApplicationController.ts +8 -2
  44. package/runtime/internal/controllers/WindowController.ts +93 -8
  45. package/runtime/plugins/01.desktop-shell-init.client.ts +28 -0
  46. package/runtime/plugins/02.desktop-register-desktop-apps.client.ts +2 -6
  47. package/runtime/stores/storeApplicationMeta.ts +2 -1
  48. package/runtime/stores/storeApplicationWindows.ts +2 -1
  49. package/runtime/stores/storeDesktop.ts +17 -57
  50. package/runtime/stores/storeDesktopDefaultApps.ts +2 -1
  51. package/runtime/stores/storeDesktopVolume.ts +2 -1
  52. package/runtime/stores/storeDesktopWindow.ts +20 -2
  53. package/runtime/stores/storeDesktopWorkspace.ts +31 -1
  54. package/runtime/stores/storeIds.ts +35 -0
  55. package/runtime/types/desktopMenu.ts +10 -0
  56. package/runtime/utils/initDesktopShell.ts +80 -0
  57. package/runtime/utils/migratePersistedStoreIds.ts +57 -0
  58. package/runtime/utils/utilApp.ts +0 -12
  59. package/runtime/utils/{captureElementToCanvas.ts → utilCaptureElementToCanvas.ts} +1 -1
  60. package/runtime/utils/utilDetectSnapZone.ts +57 -0
  61. package/runtime/utils/utilWindowLayout.ts +82 -0
  62. package/runtime/utils/utilWindowMaximizeLayout.ts +44 -0
  63. package/runtime/utils/utilWorkspaceWindows.ts +33 -0
  64. package/types/index.d.ts +125 -14
  65. package/bin/cli.js +0 -395
  66. package/bin/desktop.js +0 -5
  67. package/bin/lib/catalog.js +0 -293
  68. package/bin/lib/config.js +0 -109
  69. package/bin/lib/desktopConfig.js +0 -56
  70. package/bin/lib/generateTemplate.js +0 -389
  71. package/bin/lib/install.js +0 -408
  72. package/bin/lib/migrateModulePlayground.config.mjs +0 -164
  73. package/bin/lib/migrateModulePlayground.mjs +0 -313
  74. package/bin/lib/npmVersions.js +0 -124
  75. package/bin/lib/playgroundContext.js +0 -188
  76. package/bin/lib/scaffold.js +0 -197
  77. package/bin/lib/status.js +0 -289
  78. package/bin/lib/validateModule.js +0 -697
  79. package/bin/lib/workspace.js +0 -182
  80. package/bin/owd.js +0 -5
  81. package/bin/tui.js +0 -1379
  82. package/runtime/components/Desktop/Core/DesktopCore.vue +0 -90
  83. package/runtime/utils/explorerEntryPath.ts +0 -10
  84. package/runtime/utils/resolveDesktopConfigPath.ts +0 -52
  85. package/runtime/utils/splitDesktopUserConfig.ts +0 -85
  86. package/runtime/utils/utilDesktop.ts +0 -35
  87. package/runtime/utils/validateDesktopUserConfig.ts +0 -44
  88. /package/runtime/components/{Desktop/Background/DesktopBackground.vue → background/DesktopCoreBackground.vue} +0 -0
  89. /package/runtime/components/{Desktop/Time/DesktopTime.vue → time/DesktopCoreTime.vue} +0 -0
  90. /package/runtime/components/{Desktop/Window/DesktopWindowContent.vue → window/DesktopCoreWindowContent.vue} +0 -0
  91. /package/runtime/components/{Desktop/Window/DesktopWindowNav.vue → window/DesktopCoreWindowNav.vue} +0 -0
  92. /package/runtime/utils/{utilWindow.ts → utilWindowControllerAdapter.ts} +0 -0
@@ -1,90 +0,0 @@
1
- <script setup lang="ts">
2
- import { onBeforeMount, onMounted, onUnmounted } from 'vue'
3
- import { useAppConfig, useRuntimeConfig } from 'nuxt/app'
4
- import { computed, toRaw } from '@vue/reactivity'
5
- import { useDesktopManager } from '../../../composables/useDesktopManager'
6
- import { useDesktopStore } from '../../../stores/storeDesktop'
7
- import { useDesktopDefaultAppsStore } from '../../../stores/storeDesktopDefaultApps'
8
- import { useDesktopWorkspaceStore } from '../../../stores/storeDesktopWorkspace'
9
-
10
- const props = withDefaults(
11
- defineProps<{
12
- windows?: DesktopWindowsConfig
13
- systemBar?: DesktopSystemBarConfig
14
- dockBar?: DesktopDockBarConfig
15
- workspaces?: DesktopWorkspacesConfig
16
- }>(),
17
- {
18
- windows: {
19
- position: 'fixed',
20
- },
21
- systemBar: {},
22
- dockBar: {},
23
- workspaces: {},
24
- },
25
- )
26
-
27
- // todo move to owd initialization
28
- // perhaps in a plugin
29
-
30
- const appConfig = useAppConfig()
31
- const desktopManager = useDesktopManager()
32
- const desktopDefaultAppsStore = useDesktopDefaultAppsStore()
33
- const runtimeConfig = useRuntimeConfig()
34
-
35
- // create firsts workspaces if not available
36
- const desktopStore = useDesktopStore()
37
- const desktopWorkspaceStore = useDesktopWorkspaceStore()
38
-
39
- if (desktopStore.$persistedState) {
40
- desktopStore.$persistedState.isReady().then(() => {
41
- desktopWorkspaceStore.setupWorkspaces()
42
- })
43
- } else {
44
- desktopWorkspaceStore.setupWorkspaces()
45
- }
46
-
47
- // override desktop configurations
48
- desktopManager.setConfig({
49
- windows: toRaw(props.windows),
50
- systemBar: toRaw(props.systemBar),
51
- dockBar: toRaw(props.dockBar),
52
- workspaces: toRaw(props.workspaces),
53
- })
54
-
55
- // desktop resize
56
- // todo move to composable
57
-
58
- onMounted(() => window.addEventListener('resize', handleDesktopResize))
59
- onUnmounted(() => window.removeEventListener('resize', handleDesktopResize))
60
-
61
- function handleDesktopResize() {
62
- //store.dispatch('core/window/windowsAdjustPosition')
63
- }
64
-
65
- const classes = computed(() => {
66
- const list = ['owd-desktop']
67
-
68
- list.push(`owd-desktop--${appConfig.desktop.name}`)
69
-
70
- return list
71
- })
72
-
73
- onBeforeMount(() => {
74
- desktopDefaultAppsStore.loadDefaultAppsFromConfig(runtimeConfig)
75
- })
76
- </script>
77
-
78
- <template>
79
- <div :class="classes">
80
- <slot />
81
- </div>
82
- </template>
83
-
84
- <style scoped lang="scss">
85
- .owd-desktop {
86
- width: 100vw;
87
- height: 100dvh;
88
- user-select: none;
89
- }
90
- </style>
@@ -1,10 +0,0 @@
1
- /**
2
- * Absolute path for a listing entry under `basePath` (virtual FS paths).
3
- * Avoids `//fileName` when `basePath` is `/` or has trailing slashes.
4
- */
5
- export function explorerEntryAbsolutePath(basePath: string, fileName: string): string {
6
- const normalizedBase = (basePath ?? '/').replace(/\/+$/, '') || '/'
7
- const tail = fileName.replace(/^\/+/, '')
8
- if (normalizedBase === '/') return `/${tail}`
9
- return `${normalizedBase}/${tail}`
10
- }
@@ -1,52 +0,0 @@
1
- import { existsSync } from 'node:fs'
2
- import { join } from 'node:path'
3
-
4
- export const DESKTOP_CONFIG_FILENAME = 'desktop.config.ts'
5
- export const LEGACY_DESKTOP_CONFIG_FILENAME = 'owd.config.ts'
6
-
7
- export const LEGACY_CONFIG_DEPRECATION =
8
- '[@owdproject/core] owd.config.ts is deprecated and kept only for backward compatibility; rename to desktop.config.ts (required from @owdproject/core 3.2).'
9
-
10
- export type ResolvedDesktopConfigPath = {
11
- path: string
12
- file: string
13
- legacy: boolean
14
- }
15
-
16
- export function resolveDesktopConfigPath(
17
- rootDir: string,
18
- ): ResolvedDesktopConfigPath | null {
19
- const desktopPath = join(rootDir, DESKTOP_CONFIG_FILENAME)
20
- const legacyPath = join(rootDir, LEGACY_DESKTOP_CONFIG_FILENAME)
21
- const hasDesktop = existsSync(desktopPath)
22
- const hasLegacy = existsSync(legacyPath)
23
-
24
- if (hasDesktop && hasLegacy) {
25
- console.warn(
26
- '[@owdproject/core] Both desktop.config.ts and owd.config.ts exist; using desktop.config.ts. Remove owd.config.ts.',
27
- )
28
- return { path: desktopPath, file: DESKTOP_CONFIG_FILENAME, legacy: false }
29
- }
30
-
31
- if (hasDesktop) {
32
- return { path: desktopPath, file: DESKTOP_CONFIG_FILENAME, legacy: false }
33
- }
34
-
35
- if (hasLegacy) {
36
- return {
37
- path: legacyPath,
38
- file: LEGACY_DESKTOP_CONFIG_FILENAME,
39
- legacy: true,
40
- }
41
- }
42
-
43
- return null
44
- }
45
-
46
- export function warnLegacyDesktopConfig(
47
- resolved: ResolvedDesktopConfigPath | null | undefined,
48
- ): void {
49
- if (resolved?.legacy) {
50
- console.warn(LEGACY_CONFIG_DEPRECATION)
51
- }
52
- }
@@ -1,85 +0,0 @@
1
- /**
2
- * Keys consumed by {@link @owdproject/core} module setup (install order).
3
- * Must not be spread onto `_nuxt.options`.
4
- */
5
- export const DESKTOP_MODULE_KEYS = ['theme', 'apps', 'modules'] as const
6
-
7
- /**
8
- * Known desktop shell keys merged into `runtimeConfig.public.desktop` / `appConfig.desktop`.
9
- * Additional keys are merged with a dev warning (extensions, theme overrides).
10
- */
11
- export const DESKTOP_RUNTIME_KEYS = new Set([
12
- ...DESKTOP_MODULE_KEYS,
13
- 'docs',
14
- 'name',
15
- 'defaultApps',
16
- 'features',
17
- 'explorer',
18
- 'systemBar',
19
- 'dockBar',
20
- 'workspaces',
21
- ])
22
-
23
- /** Nuxt top-level option names — warn if present in desktop.config (likely misconfiguration). */
24
- const NUXT_OPTION_KEYS = new Set([
25
- 'ssr',
26
- 'modules',
27
- 'devtools',
28
- 'vite',
29
- 'nitro',
30
- 'runtimeConfig',
31
- 'app',
32
- 'appConfig',
33
- 'css',
34
- 'plugins',
35
- 'hooks',
36
- 'extends',
37
- 'compatibilityDate',
38
- 'experimental',
39
- 'future',
40
- 'i18n',
41
- 'tailwindcss',
42
- 'primevue',
43
- ])
44
-
45
- export type SplitDesktopUserConfigResult = {
46
- theme?: string
47
- apps?: string[]
48
- modules?: string[]
49
- desktopRuntime: Record<string, unknown>
50
- }
51
-
52
- export function splitDesktopUserConfig(
53
- config: Record<string, unknown>,
54
- configFile = 'desktop.config.ts',
55
- ): SplitDesktopUserConfigResult {
56
- const theme =
57
- typeof config.theme === 'string' ? config.theme : undefined
58
- const apps = Array.isArray(config.apps)
59
- ? (config.apps as string[])
60
- : undefined
61
- const modules = Array.isArray(config.modules)
62
- ? (config.modules as string[])
63
- : undefined
64
-
65
- const desktopRuntime: Record<string, unknown> = {}
66
-
67
- for (const [key, value] of Object.entries(config)) {
68
- if (DESKTOP_MODULE_KEYS.includes(key as (typeof DESKTOP_MODULE_KEYS)[number])) {
69
- continue
70
- }
71
- desktopRuntime[key] = value
72
-
73
- if (NUXT_OPTION_KEYS.has(key)) {
74
- console.warn(
75
- `[@owdproject/core] ${configFile}: key "${key}" looks like a Nuxt option and is ignored for _nuxt.options. Move it to nuxt.config.ts; shell values belong under defineDesktopConfig({ systemBar, workspaces, ... }).`,
76
- )
77
- } else if (!DESKTOP_RUNTIME_KEYS.has(key)) {
78
- console.warn(
79
- `[@owdproject/core] ${configFile}: unknown desktop key "${key}" — merged into runtimeConfig.public.desktop only.`,
80
- )
81
- }
82
- }
83
-
84
- return { theme, apps, modules, desktopRuntime }
85
- }
@@ -1,35 +0,0 @@
1
- import { getActivePinia } from 'pinia'
2
- import { useApplicationManager } from '../composables/useApplicationManager'
3
-
4
- const pendingDesktopApps: ApplicationConfig[] = []
5
-
6
- /**
7
- * Register a desktop app. Queues until Pinia is active when theme/app plugins
8
- * run before @pinia/nuxt (e.g. published apps using `app:created`).
9
- */
10
- export async function defineDesktopApp(config: ApplicationConfig) {
11
- if (import.meta.server) return undefined
12
-
13
- if (getActivePinia()) {
14
- const applicationManager = useApplicationManager()
15
- return applicationManager.defineApp(config.id, config)
16
- }
17
-
18
- pendingDesktopApps.push(config)
19
- return undefined
20
- }
21
-
22
- export async function flushPendingDesktopApps() {
23
- if (pendingDesktopApps.length === 0 || !getActivePinia()) return
24
-
25
- const queue = pendingDesktopApps.splice(0, pendingDesktopApps.length)
26
- const applicationManager = useApplicationManager()
27
-
28
- for (const config of queue) {
29
- await applicationManager.defineApp(config.id, config)
30
- }
31
- }
32
-
33
- export function defineDesktopConfig(config: DesktopConfig) {
34
- return config
35
- }
@@ -1,44 +0,0 @@
1
- /**
2
- * Runtime validation for the object exported from `desktop.config.ts`
3
- * (or legacy `owd.config.ts`).
4
- */
5
- export function assertValidDesktopUserConfig(
6
- config: unknown,
7
- configFile = 'desktop.config.ts',
8
- ): void {
9
- if (!config || typeof config !== 'object' || Array.isArray(config)) {
10
- throw new Error(
11
- `[@owdproject/core] ${configFile} must default-export a non-array object from defineDesktopConfig({ ... }).`,
12
- )
13
- }
14
-
15
- const c = config as Record<string, unknown>
16
-
17
- if (c.theme != null && typeof c.theme !== 'string') {
18
- throw new Error(
19
- `[@owdproject/core] ${configFile}: \`theme\` must be a string (npm package name of the theme module).`,
20
- )
21
- }
22
-
23
- if (c.apps !== undefined) {
24
- if (
25
- !Array.isArray(c.apps) ||
26
- !(c.apps as unknown[]).every((item) => typeof item === 'string')
27
- ) {
28
- throw new Error(
29
- `[@owdproject/core] ${configFile}: \`apps\` must be an array of strings (Nuxt module package names).`,
30
- )
31
- }
32
- }
33
-
34
- if (c.modules !== undefined) {
35
- if (
36
- !Array.isArray(c.modules) ||
37
- !(c.modules as unknown[]).every((item) => typeof item === 'string')
38
- ) {
39
- throw new Error(
40
- `[@owdproject/core] ${configFile}: \`modules\` must be an array of strings (Nuxt module package names).`,
41
- )
42
- }
43
- }
44
- }