@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
@@ -0,0 +1,182 @@
1
+ import { existsSync, readFileSync, mkdirSync, writeFileSync } from 'node:fs'
2
+ import { dirname, join } from 'node:path'
3
+ import { execSync } from 'node:child_process'
4
+ import {
5
+ resolveDesktopConfigPath,
6
+ desktopConfigWritePath,
7
+ } from './desktopConfig.js'
8
+
9
+ export const SCOPE = '@owdproject/'
10
+
11
+ /** Not loadable via desktop.config `modules` (core is the shell). */
12
+ export const DESKTOP_NON_INSTALLABLE = new Set([
13
+ '@owdproject/core',
14
+ ])
15
+
16
+ /** Installed documentation modules (current + deprecated package name). */
17
+ export const DOCS_MODULE_PACKAGES = [
18
+ '@owdproject/module-docs',
19
+ '@owdproject/docs',
20
+ ]
21
+
22
+ export function hasDocsModuleInstalled(config, deps = {}) {
23
+ return DOCS_MODULE_PACKAGES.some(
24
+ (name) => config?.modules?.includes(name) || deps[name],
25
+ )
26
+ }
27
+
28
+ export function docsBasePathFromConfig(config) {
29
+ const base = config?.docs?.basePath
30
+ if (typeof base === 'string' && base.startsWith('/')) return base
31
+ return '/docs'
32
+ }
33
+
34
+ /** Theme-internal UI kits — pulled in by themes, not listed as desktop modules. */
35
+ export function isDesktopKitPackage(pkgName) {
36
+ const short = pkgName.startsWith(SCOPE) ? pkgName.slice(SCOPE.length) : pkgName
37
+ return short.startsWith('kit-')
38
+ }
39
+
40
+ /** Scaffold / blueprint packages — not loadable desktop modules. */
41
+ export function isDesktopTemplatePackage(pkgName) {
42
+ const short = pkgName.startsWith(SCOPE) ? pkgName.slice(SCOPE.length) : pkgName
43
+ return short.endsWith('-template')
44
+ }
45
+
46
+ export function isInstallableDesktopModule(pkgName) {
47
+ return (
48
+ !DESKTOP_NON_INSTALLABLE.has(pkgName) &&
49
+ !isDesktopKitPackage(pkgName) &&
50
+ !isDesktopTemplatePackage(pkgName)
51
+ )
52
+ }
53
+
54
+ export const KINDS = {
55
+ app: {
56
+ label: 'Apps',
57
+ topic: 'owd-apps',
58
+ workspaceDir: 'apps',
59
+ configKey: 'apps',
60
+ nx: 'desktop:install-app',
61
+ },
62
+ module: {
63
+ label: 'Modules',
64
+ topic: 'owd-modules',
65
+ workspaceDir: 'packages',
66
+ configKey: 'modules',
67
+ nx: 'desktop:install-module',
68
+ },
69
+ theme: {
70
+ label: 'Themes',
71
+ topic: 'owd-themes',
72
+ workspaceDir: 'themes',
73
+ configKey: 'theme',
74
+ nx: 'desktop:install-theme',
75
+ },
76
+ }
77
+
78
+ export function findWorkspaceRoot(startDir = process.cwd()) {
79
+ let dir = startDir
80
+ for (;;) {
81
+ if (
82
+ existsSync(join(dir, 'pnpm-workspace.yaml')) &&
83
+ existsSync(join(dir, 'nx.json'))
84
+ ) {
85
+ return dir
86
+ }
87
+ const parent = dirname(dir)
88
+ if (parent === dir) return null
89
+ dir = parent
90
+ }
91
+ }
92
+
93
+ export function desktopMetaDir(workspaceRoot) {
94
+ return join(workspaceRoot, '.desktop')
95
+ }
96
+
97
+ export function settingsPath(workspaceRoot) {
98
+ return join(desktopMetaDir(workspaceRoot), 'settings.json')
99
+ }
100
+
101
+ /** @typedef {'npm' | 'workspace'} InstallMode */
102
+
103
+ export function normalizeInstallMode(value) {
104
+ if (value === 'workspace' || value === 'dev') return 'workspace'
105
+ return 'npm'
106
+ }
107
+
108
+ export function isWorkspaceInstallMode(settings) {
109
+ return normalizeInstallMode(settings?.installMode) === 'workspace'
110
+ }
111
+
112
+ export function loadSettings(workspaceRoot) {
113
+ const defaults = {
114
+ devPort: 3000,
115
+ githubUser: null,
116
+ githubOrgs: ['owdproject'],
117
+ installMode: /** @type {InstallMode} */ ('npm'),
118
+ }
119
+
120
+ try {
121
+ const path = settingsPath(workspaceRoot)
122
+ if (!existsSync(path)) {
123
+ return { ...defaults, ...detectGithubUser(), installMode: 'npm' }
124
+ }
125
+ const merged = { ...defaults, ...detectGithubUser(), ...JSON.parse(readFileSync(path, 'utf8')) }
126
+ merged.installMode = normalizeInstallMode(merged.installMode)
127
+ return merged
128
+ } catch {
129
+ return { ...defaults, ...detectGithubUser(), installMode: 'npm' }
130
+ }
131
+ }
132
+
133
+ function detectGithubUser() {
134
+ const fromEnv = process.env.OWD_GITHUB_USER?.trim()
135
+ if (fromEnv) return { githubUser: fromEnv }
136
+
137
+ try {
138
+ const user = execSync('git config --get github.user || git config --get user.username', {
139
+ encoding: 'utf8',
140
+ stdio: ['ignore', 'pipe', 'ignore'],
141
+ }).trim()
142
+ if (user) return { githubUser: user }
143
+ } catch {
144
+ /* ignore */
145
+ }
146
+
147
+ return {}
148
+ }
149
+
150
+ export function saveSettings(workspaceRoot, settings) {
151
+ const dir = desktopMetaDir(workspaceRoot)
152
+ mkdirSync(dir, { recursive: true })
153
+ writeFileSync(settingsPath(workspaceRoot), JSON.stringify(settings, null, 2) + '\n')
154
+ }
155
+
156
+ export function desktopPaths(workspaceRoot) {
157
+ const desktop = join(workspaceRoot, 'desktop')
158
+ const resolved = resolveDesktopConfigPath(desktop)
159
+ const configWrite = desktopConfigWritePath(desktop)
160
+
161
+ return {
162
+ desktop,
163
+ config: resolved?.path ?? configWrite,
164
+ configWrite,
165
+ configLegacy: resolved?.legacy ?? false,
166
+ packageJson: join(desktop, 'package.json'),
167
+ }
168
+ }
169
+
170
+ export function shortName(pkgName) {
171
+ return pkgName.startsWith(SCOPE) ? pkgName.slice(SCOPE.length) : pkgName
172
+ }
173
+
174
+ export function fullName(short) {
175
+ return short.startsWith(SCOPE) ? short : `${SCOPE}${short}`
176
+ }
177
+
178
+ export function inferKind(shortName) {
179
+ if (shortName.startsWith('app-')) return 'app'
180
+ if (shortName.startsWith('theme-')) return 'theme'
181
+ return 'module'
182
+ }
package/bin/owd.js CHANGED
@@ -1,28 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { spawn } from 'child_process'
3
+ import { runCli } from './cli.js'
4
4
 
5
- const [, , cmd, pkgName, ...rest] = process.argv
6
-
7
- const commandMap = {
8
- 'install-app': 'desktop:install-app',
9
- 'install-module': 'desktop:install-module',
10
- 'install-theme': 'desktop:install-theme',
11
- }
12
-
13
- if (!commandMap[cmd]) {
14
- console.error(`Unknown command: ${cmd}`)
15
- process.exit(1)
16
- }
17
-
18
- if (!pkgName) {
19
- console.error('Missing package name (e.g., @owdproject/package)')
20
- process.exit(1)
21
- }
22
-
23
- const nxArgs = ['run', commandMap[cmd], `--name=${pkgName}`, ...rest]
24
-
25
- const child = spawn('pnpm', ['nx', ...nxArgs], {
26
- stdio: 'inherit',
27
- shell: true,
28
- })
5
+ await runCli('owd', process.argv.slice(2), { deprecated: true })