@owdproject/core 3.0.0-alpha.9 → 3.1.1

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.
@@ -0,0 +1,25 @@
1
+ import { ref } from 'vue';
2
+
3
+ type ClipboardOperation = 'copy' | 'cut';
4
+
5
+ const clipboardPath = ref<string | null>(null);
6
+ const clipboardType = ref<ClipboardOperation | null>(null);
7
+
8
+ export function useClipboardFs() {
9
+ function setClipboard(path: string, type: ClipboardOperation) {
10
+ clipboardPath.value = path;
11
+ clipboardType.value = type;
12
+ }
13
+
14
+ function clearClipboard() {
15
+ clipboardPath.value = null;
16
+ clipboardType.value = null;
17
+ }
18
+
19
+ return {
20
+ clipboardPath,
21
+ clipboardType,
22
+ setClipboard,
23
+ clearClipboard,
24
+ };
25
+ }
@@ -156,7 +156,8 @@ export class ApplicationController implements IApplicationController {
156
156
  },
157
157
  createdAt: +new Date(),
158
158
  workspace: desktopWorkspaceStore.active
159
- }
159
+ },
160
+ meta
160
161
  }
161
162
 
162
163
  windowStoredState = this.storeWindows.windows[windowId]
@@ -209,6 +210,14 @@ export class ApplicationController implements IApplicationController {
209
210
  return this.windows;
210
211
  }
211
212
 
213
+ public getWindowsByModel(model: string): IWindowController[] {
214
+ return Array.from(this.windows.values()).filter(w => w.model === model)
215
+ }
216
+
217
+ public getFirstWindowByModel(model: string): IWindowController | undefined {
218
+ return Array.from(this.windows.values()).find(w => w.model === model)
219
+ }
220
+
212
221
  public setRunning(value: boolean): void {
213
222
  this.isRunning = value
214
223
  }
@@ -1,6 +1,6 @@
1
- import {useApplicationManager} from '@owdproject/core/runtime/composables/useApplicationManager'
2
- import {useDesktopWindowStore} from '@owdproject/core/runtime/stores/storeDesktopWindow'
3
- import {deepClone} from '@owdproject/core/runtime/utils/utilCommon'
1
+ import {useApplicationManager} from '../../composables/useApplicationManager'
2
+ import {useDesktopWindowStore} from '../../stores/storeDesktopWindow'
3
+ import {deepClone} from '../../utils/utilCommon'
4
4
  import {markRaw} from '@vue/reactivity'
5
5
  import {defineAsyncComponent} from "vue"
6
6
 
@@ -48,7 +48,6 @@ export class WindowController implements IWindowController {
48
48
 
49
49
  public override: WindowOverride = {}
50
50
 
51
- public meta: any = {}
52
51
  private storedState: WindowStoredState
53
52
 
54
53
  constructor(
@@ -166,6 +165,12 @@ export class WindowController implements IWindowController {
166
165
  }
167
166
  }
168
167
 
168
+ // meta
169
+
170
+ get meta() {
171
+ return this.storedState.meta
172
+ }
173
+
169
174
  // position
170
175
 
171
176
  private setPosition(data: { x: number, y: number}) {
@@ -422,4 +427,4 @@ export class WindowController implements IWindowController {
422
427
  resetTitleOverride: this.resetTitleOverride.bind(this),
423
428
  }
424
429
  }
425
- }
430
+ }
@@ -1,4 +1,4 @@
1
- import {deepMerge} from "@owdproject/core/runtime/utils/utilCommon"
1
+ import {deepMerge} from "../../utils/utilCommon"
2
2
 
3
3
  export class DesktopManager {
4
4
  public config: DesktopConfig = {} as DesktopConfig
@@ -34,4 +34,4 @@ export class DesktopManager {
34
34
  this.defaultApps = {...this.config.defaultApps}
35
35
  }
36
36
  }
37
- }
37
+ }
@@ -32,11 +32,13 @@ export class TerminalManager {
32
32
  }
33
33
 
34
34
  if (!this.commands.has(name)) {
35
- throw new Error(`Command "${name}" not found`)
35
+ return {
36
+ message: `Command "${name}" not found`
37
+ }
36
38
  }
37
39
 
38
- const cmd = this.commands.get(name)!
40
+ const application = this.commands.get(name)!
39
41
 
40
- return applicationManager.execAppCommand(cmd.applicationId, input)
42
+ return applicationManager.execAppCommand(application.applicationId, input)
41
43
  }
42
- }
44
+ }
@@ -1,5 +1,5 @@
1
1
  import {defineStore} from "pinia"
2
- import {ref} from "@vue/reactivity"
2
+ import {ref} from "vue"
3
3
 
4
4
  export const useApplicationWindowsStore = (appId: string) => {
5
5
  return defineStore(`owd/application/${appId}/windows`, () => {
@@ -1,5 +1,5 @@
1
1
  import {defineStore} from "pinia"
2
- import {ref} from "@vue/reactivity"
2
+ import {ref} from "vue"
3
3
 
4
4
  export const useDesktopStore = defineStore('owd/desktop', () => {
5
5
  const state = ref<{
@@ -24,7 +24,7 @@ export const useDesktopStore = defineStore('owd/desktop', () => {
24
24
  master: 100,
25
25
  },
26
26
  window: {
27
- positionZ: 10
27
+ positionZ: 0
28
28
  }
29
29
  })
30
30
 
@@ -36,4 +36,4 @@ export const useDesktopStore = defineStore('owd/desktop', () => {
36
36
  persistedState: {
37
37
  persist: true
38
38
  },
39
- })
39
+ })
@@ -1,6 +1,6 @@
1
1
  import {defineStore} from "pinia"
2
- import {computed} from "@vue/reactivity"
3
- import {useDesktopStore} from "../stores/storeDesktop"
2
+ import {computed} from "vue"
3
+ import {useDesktopStore} from "./storeDesktop"
4
4
 
5
5
  export const useDesktopVolumeStore = defineStore('owd/desktop/volume', () => {
6
6
  const desktopStore = useDesktopStore()
@@ -15,4 +15,4 @@ export const useDesktopVolumeStore = defineStore('owd/desktop/volume', () => {
15
15
  master,
16
16
  setMasterVolume
17
17
  }
18
- })
18
+ })
@@ -1,6 +1,6 @@
1
1
  import {defineStore} from "pinia"
2
- import {computed} from "@vue/reactivity"
3
- import {useDesktopStore} from "../stores/storeDesktop"
2
+ import {computed} from "vue"
3
+ import {useDesktopStore} from "./storeDesktop"
4
4
 
5
5
  export const useDesktopWindowStore = defineStore('owd/desktop/window', () => {
6
6
  const desktopStore = useDesktopStore()
@@ -17,4 +17,4 @@ export const useDesktopWindowStore = defineStore('owd/desktop/window', () => {
17
17
  positionZ,
18
18
  incrementPositionZ
19
19
  }
20
- })
20
+ })
@@ -1,7 +1,7 @@
1
1
  import {defineStore} from "pinia"
2
- import {computed} from "@vue/reactivity"
2
+ import {computed} from "vue"
3
+ import {useDesktopStore} from "./storeDesktop"
3
4
  import {nanoid} from "nanoid";
4
- import {useDesktopStore} from "../stores/storeDesktop"
5
5
 
6
6
  export const useDesktopWorkspaceStore = defineStore('owd/desktop/workspace', () => {
7
7
  const desktopStore = useDesktopStore()
@@ -56,4 +56,4 @@ export const useDesktopWorkspaceStore = defineStore('owd/desktop/workspace', ()
56
56
  setOverview,
57
57
  setWorkspace,
58
58
  }
59
- })
59
+ })
@@ -23,11 +23,10 @@ export function normalizeApplicationConfig(config: ApplicationConfig): Applicati
23
23
  }
24
24
 
25
25
  export function registerTailwindPath(nuxt: Nuxt, path: string) {
26
- nuxt.options.runtimeConfig = nuxt.options.runtimeConfig || {}
27
- nuxt.options.runtimeConfig.owd = nuxt.options.runtimeConfig.owd || {}
28
- nuxt.options.runtimeConfig.owd.tailwindPaths = nuxt.options.runtimeConfig.owd.tailwindPaths || []
26
+ nuxt.options.runtimeConfig.app.owd = nuxt.options.runtimeConfig.app.owd || {}
27
+ nuxt.options.runtimeConfig.app.owd.tailwindPaths = nuxt.options.runtimeConfig.app.owd.tailwindPaths || []
29
28
 
30
- if (!nuxt.options.runtimeConfig.owd.tailwindPaths.includes(path)) {
31
- nuxt.options.runtimeConfig.owd.tailwindPaths.push(path)
29
+ if (!nuxt.options.runtimeConfig.app.owd.tailwindPaths.includes(path)) {
30
+ nuxt.options.runtimeConfig.app.owd.tailwindPaths.push(path)
32
31
  }
33
- }
32
+ }
@@ -2,7 +2,7 @@ export function deepClone<T>(obj: T): T {
2
2
  return JSON.parse(JSON.stringify(obj))
3
3
  }
4
4
 
5
- export function deepEqual(obj1, obj2) {
5
+ export function deepEqual(obj1: any, obj2: any) {
6
6
  const keys1 = Object.keys(obj1);
7
7
  const keys2 = Object.keys(obj2);
8
8
  if (keys1.length !== keys2.length) {
@@ -55,4 +55,4 @@ export function deepMerge<T>(target: T, source: Partial<T>): T {
55
55
  }
56
56
 
57
57
  return source as T
58
- }
58
+ }
@@ -1,5 +1,4 @@
1
1
  import {useApplicationManager} from "../composables/useApplicationManager";
2
- import {useDesktopManager} from "../composables/useDesktopManager";
3
2
 
4
3
  export function defineDesktopApp(config: ApplicationConfig) {
5
4
  const applicationManager = useApplicationManager()
@@ -8,4 +7,4 @@ export function defineDesktopApp(config: ApplicationConfig) {
8
7
 
9
8
  export function defineDesktopConfig(config: DesktopConfig) {
10
9
  return config
11
- }
10
+ }
@@ -0,0 +1,15 @@
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
+ })
@@ -0,0 +1,6 @@
1
+ <template>
2
+ <div>basic</div>
3
+ </template>
4
+
5
+ <script setup>
6
+ </script>
@@ -0,0 +1,7 @@
1
+ import MyModule from '../../../module'
2
+
3
+ export default defineNuxtConfig({
4
+ modules: [
5
+ MyModule,
6
+ ],
7
+ })
@@ -0,0 +1,5 @@
1
+ {
2
+ "private": true,
3
+ "name": "basic",
4
+ "type": "module"
5
+ }
@@ -0,0 +1,31 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "outDir": "dist",
5
+ "rootDir": "src",
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 CHANGED
@@ -1,3 +1,12 @@
1
1
  {
2
- "extends": "../.nuxt/tsconfig.json",
3
- }
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
+ }
@@ -0,0 +1,37 @@
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
+ }
@@ -1,3 +1,14 @@
1
+ import type { Nuxt } from '@nuxt/schema';
2
+ import { useApplicationManager } from '../runtime/composables/useApplicationManager';
3
+
4
+ declare module 'nuxt/schema' {
5
+ interface PublicRuntimeConfig {
6
+ owd: {
7
+ tailwindPaths: []
8
+ };
9
+ }
10
+ }
11
+
1
12
  interface IApplicationManager {
2
13
  apps: Map<string, IApplicationController>
3
14
 
@@ -16,7 +27,7 @@ interface IApplicationManager {
16
27
  closeApp(id: string): void
17
28
 
18
29
  launchAppEntry(id: string, entry: string): Promise<IApplicationController | undefined | void>
19
- execAppCommand(id: string, command: string): Promise<CommandOutput | void>
30
+ execAppCommand(id: string, command: string, meta: undefined | any): Promise<CommandOutput | void>
20
31
 
21
32
  isAppDefined(id: string): boolean
22
33
 
@@ -73,7 +84,11 @@ interface IApplicationController {
73
84
 
74
85
  restoreApplication(): Promise<boolean>
75
86
 
76
- openWindow(model: string, windowStoredState?: WindowStoredState, meta?: {
87
+ getWindowsByModel(model: string): IWindowController[]
88
+
89
+ getFirstWindowByModel(model: string): IWindowController | undefined
90
+
91
+ openWindow(model: string, windowStoredState?: WindowStoredState, options?: {
77
92
  isRestoring?: boolean
78
93
  })
79
94
 
@@ -83,6 +98,7 @@ interface IApplicationController {
83
98
 
84
99
  execCommand(command: string): Promise<CommandOutput | void>
85
100
 
101
+ // deprecated
86
102
  get windowsOpened(): Reactive<Map<string, IWindowController>>
87
103
  }
88
104
 
@@ -191,6 +207,7 @@ interface WindowConfig {
191
207
  interface WindowStoredState {
192
208
  model: string,
193
209
  state: WindowState
210
+ meta: any
194
211
  }
195
212
 
196
213
  interface WindowOverride {
@@ -333,4 +350,10 @@ interface DefaultAppsConfig {
333
350
  interface DefaultAppConfig {
334
351
  application: IApplicationController
335
352
  entry: ApplicationEntry
336
- }
353
+ }
354
+
355
+ export function defineDesktopApp(config: ApplicationConfig)
356
+ export function defineDesktopConfig(config: DesktopConfig)
357
+ export function registerTailwindPath(nuxt: Nuxt, path: string): void;
358
+
359
+ export {}
@@ -0,0 +1,24 @@
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
+ }));