@owdproject/core 3.1.2 → 3.1.4-beta.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 (50) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +9 -10
  3. package/bin/owd.js +14 -14
  4. package/index.ts +5 -2
  5. package/module.ts +64 -55
  6. package/package.json +19 -17
  7. package/project.json +4 -0
  8. package/runtime/components/Core/Application/CoreApplicationRender.vue +6 -5
  9. package/runtime/components/Core/Application/CoreApplicationWindowsRender.vue +8 -8
  10. package/runtime/components/Core/Background/CoreBackground.vue +1 -1
  11. package/runtime/components/Core/Desktop/CoreDesktop.vue +23 -20
  12. package/runtime/components/Core/Explorer/CoreExplorerFile.vue +47 -38
  13. package/runtime/components/Core/Explorer/CoreExplorerFolder.vue +0 -1
  14. package/runtime/components/Core/Time/CoreTime.vue +10 -7
  15. package/runtime/components/Core/Window/CoreWindow.vue +46 -34
  16. package/runtime/components/Core/Window/CoreWindowContent.vue +3 -5
  17. package/runtime/components/Core/Window/CoreWindowNav.vue +12 -7
  18. package/runtime/composables/useApplicationEntries.ts +51 -0
  19. package/runtime/composables/useApplicationManager.ts +3 -3
  20. package/runtime/composables/useClipboardFs.ts +11 -11
  21. package/runtime/composables/useDesktopManager.ts +2 -2
  22. package/runtime/composables/useTerminalManager.ts +3 -3
  23. package/runtime/core/controllers/ApplicationController.ts +211 -200
  24. package/runtime/core/controllers/WindowController.ts +349 -312
  25. package/runtime/core/managers/ApplicationManager.ts +240 -196
  26. package/runtime/core/managers/DesktopManager.ts +35 -25
  27. package/runtime/core/managers/TerminalManager.ts +36 -32
  28. package/runtime/plugins/resize.client.ts +4 -4
  29. package/runtime/stores/storeApplication.ts +235 -0
  30. package/runtime/stores/storeApplicationMeta.ts +12 -8
  31. package/runtime/stores/storeApplicationWindows.ts +16 -12
  32. package/runtime/stores/storeDesktop.ts +33 -29
  33. package/runtime/stores/storeDesktopVolume.ts +12 -12
  34. package/runtime/stores/storeDesktopWindow.ts +13 -13
  35. package/runtime/stores/storeDesktopWorkspace.ts +35 -31
  36. package/runtime/utils/utilApp.ts +27 -22
  37. package/runtime/utils/utilCommon.ts +43 -43
  38. package/runtime/utils/utilDebug.ts +17 -17
  39. package/runtime/utils/utilDesktop.ts +4 -4
  40. package/runtime/utils/utilTerminal.ts +6 -5
  41. package/runtime/utils/utilWindow.ts +11 -11
  42. package/test/fixtures/basic/app.vue +1 -2
  43. package/test/fixtures/basic/nuxt.config.ts +1 -3
  44. package/tsconfig.app.json +1 -1
  45. package/tsconfig.json +1 -1
  46. package/types/index.d.ts +235 -207
  47. package/vitest.config.ts +3 -3
  48. package/.editorconfig +0 -12
  49. package/eslint.config.mjs +0 -30
  50. package/runtime/composables/useAppEntries.ts +0 -36
@@ -1,17 +1,18 @@
1
1
  <script setup lang="ts">
2
- import {ref, onMounted, onUnmounted} from 'vue'
3
- import {computed} from "@vue/reactivity"
4
- import {useI18n} from "vue-i18n"
2
+ import { ref, onMounted, onUnmounted } from 'vue'
3
+ import { computed } from '@vue/reactivity'
4
+ import { useI18n } from 'vue-i18n'
5
5
 
6
6
  const date: Ref<Date> = ref(new Date())
7
- const {locale} = useI18n()
7
+ const { locale } = useI18n()
8
8
 
9
9
  let minuteTimeout: any
10
10
 
11
11
  onMounted(() => {
12
12
  function scheduleNextMinute() {
13
13
  const now = new Date()
14
- const millisecondsToNextMinute = (60 - now.getSeconds()) * 1000 - now.getMilliseconds()
14
+ const millisecondsToNextMinute =
15
+ (60 - now.getSeconds()) * 1000 - now.getMilliseconds()
15
16
  minuteTimeout = setTimeout(() => {
16
17
  date.value = new Date()
17
18
  scheduleNextMinute()
@@ -44,10 +45,12 @@ const time = computed(() => {
44
45
 
45
46
  if (minutes.length === 1) minutes = `0${minutes}`
46
47
 
47
- return locale.value === 'it' ? `${hours}:${minutes}` : `${hours}:${minutes} ${period}`
48
+ return locale.value === 'it'
49
+ ? `${hours}:${minutes}`
50
+ : `${hours}:${minutes} ${period}`
48
51
  })
49
52
  </script>
50
53
 
51
54
  <template>
52
55
  <time class="owd-time" v-text="time" />
53
- </template>
56
+ </template>
@@ -1,8 +1,8 @@
1
1
  <script setup lang="ts">
2
- import {ref,provide} from 'vue'
3
- import {computed} from "@vue/reactivity"
4
- import {useDesktopManager} from "@owdproject/core/runtime/composables/useDesktopManager"
5
- import {handleWindowControllerProps} from "@owdproject/core/runtime/utils/utilWindow"
2
+ import { ref, provide } from 'vue'
3
+ import { computed } from '@vue/reactivity'
4
+ import { useDesktopManager } from '@owdproject/core/runtime/composables/useDesktopManager'
5
+ import { handleWindowControllerProps } from '@owdproject/core/runtime/utils/utilWindow'
6
6
 
7
7
  const props = defineProps<{
8
8
  window?: IWindowController
@@ -24,11 +24,13 @@ const emit = defineEmits([
24
24
  'restore',
25
25
  'maximize',
26
26
  'unmaximize',
27
- 'toggle-maximize'
27
+ 'toggle-maximize',
28
28
  ])
29
29
 
30
30
  const desktopManager = useDesktopManager() // used in <style v-bind>
31
- const windowController: IWindowController = handleWindowControllerProps(props.window)
31
+ const windowController: IWindowController = handleWindowControllerProps(
32
+ props.window,
33
+ )
32
34
 
33
35
  provide<IWindowController>('windowController', windowController)
34
36
  provide<WindowContent>('windowContent', props.content ?? {})
@@ -54,7 +56,7 @@ function onWindowDragMove(data: any) {
54
56
  function onWindowDragEnd(data: { left: number; top: number }) {
55
57
  windowController?.actions?.setPosition({
56
58
  x: data.left,
57
- y: data.top
59
+ y: data.top,
58
60
  })
59
61
 
60
62
  isDragging.value = false
@@ -75,17 +77,22 @@ function onWindowResizeMove(data: any) {
75
77
  /**
76
78
  * Window end resize event
77
79
  */
78
- function onWindowResizeEnd(data: { left: number; top: number, width: number, height: number }) {
80
+ function onWindowResizeEnd(data: {
81
+ left: number
82
+ top: number
83
+ width: number
84
+ height: number
85
+ }) {
79
86
  isResizing.value = false
80
87
 
81
88
  windowController?.actions?.setPosition({
82
89
  x: data.left,
83
- y: data.top
90
+ y: data.top,
84
91
  })
85
92
 
86
93
  windowController?.actions?.setSize({
87
94
  width: data.width,
88
- height: data.height
95
+ height: data.height,
89
96
  })
90
97
 
91
98
  emit('resize:end', data)
@@ -112,29 +119,33 @@ const classes = computed(() => {
112
119
 
113
120
  <template>
114
121
  <vue-resizable
115
- ref="windowResizableController"
116
- :class="classes"
117
- :width="windowController?.size.width"
118
- :height="windowController?.size.height"
119
- :min-height="windowController?.size.minHeight"
120
- :max-width="windowController?.size.maxWidth"
121
- :max-height="windowController?.size.maxHeight"
122
- :left="windowController?.position?.x"
123
- :top="windowController?.position?.y"
124
- :active="windowController?.isResizable ? undefined : []"
125
- @drag:start="onWindowDragStart"
126
- @drag:move="onWindowDragMove"
127
- @drag:end="onWindowDragEnd"
128
- @resize:start="onWindowResizeStart"
129
- @resize:move="onWindowResizeMove"
130
- @resize:end="onWindowResizeEnd"
131
- :style="{zIndex: windowController?.position?.z}"
132
- :drag-selector="windowController?.isDraggable ? '.owd-window-nav__draggable' : '.owd-window-nav__draggable-none'"
133
- @pointerdown="onWindowPointerDown"
122
+ ref="windowResizableController"
123
+ :class="classes"
124
+ :width="windowController?.size.width"
125
+ :height="windowController?.size.height"
126
+ :min-width="windowController?.size.minWidth"
127
+ :min-height="windowController?.size.minHeight"
128
+ :max-width="windowController?.size.maxWidth"
129
+ :max-height="windowController?.size.maxHeight"
130
+ :left="windowController?.position?.x"
131
+ :top="windowController?.position?.y"
132
+ :active="windowController?.isResizable ? undefined : []"
133
+ fit-parent
134
+ @drag:start="onWindowDragStart"
135
+ @drag:move="onWindowDragMove"
136
+ @drag:end="onWindowDragEnd"
137
+ @resize:start="onWindowResizeStart"
138
+ @resize:move="onWindowResizeMove"
139
+ @resize:end="onWindowResizeEnd"
140
+ :style="{ zIndex: windowController?.position?.z }"
141
+ :drag-selector="
142
+ windowController?.isDraggable
143
+ ? '.owd-window-nav__draggable'
144
+ : '.owd-window-nav__draggable-none'
145
+ "
146
+ @pointerdown="onWindowPointerDown"
134
147
  >
135
-
136
- <slot/>
137
-
148
+ <slot />
138
149
  </vue-resizable>
139
150
  </template>
140
151
 
@@ -142,7 +153,8 @@ const classes = computed(() => {
142
153
  .owd-window {
143
154
  position: v-bind('desktopManager.config.windows.position');
144
155
 
145
- &--dragging, &--resizing {
156
+ &--dragging,
157
+ &--resizing {
146
158
  :deep(.owd-window__content) {
147
159
  pointer-events: none;
148
160
  }
@@ -153,4 +165,4 @@ const classes = computed(() => {
153
165
  height: 100%;
154
166
  }
155
167
  }
156
- </style>
168
+ </style>
@@ -1,6 +1,6 @@
1
1
  <script setup lang="ts">
2
- import {inject} from "vue"
3
- import {computed} from "@vue/reactivity"
2
+ import { inject } from 'vue'
3
+ import { computed } from '@vue/reactivity'
4
4
 
5
5
  const windowContent = inject<WindowContent>('windowContent')
6
6
 
@@ -25,6 +25,4 @@ const classes = computed(() => {
25
25
  </div>
26
26
  </template>
27
27
 
28
- <style scoped lang="scss">
29
-
30
- </style>
28
+ <style scoped lang="scss"></style>
@@ -1,17 +1,23 @@
1
1
  <script setup lang="ts">
2
- import {inject} from "vue"
3
- import {computed} from "@vue/reactivity"
2
+ import { inject } from 'vue'
3
+ import { computed } from '@vue/reactivity'
4
4
 
5
5
  const windowController = inject<IWindowController>('windowController')
6
6
 
7
7
  const classes = computed(() => {
8
8
  const list = ['owd-window-nav']
9
9
 
10
- if (typeof windowController?.state.active === 'undefined' || !!windowController?.state.active) {
10
+ if (
11
+ typeof windowController?.state.active === 'undefined' ||
12
+ !!windowController?.state.active
13
+ ) {
11
14
  list.push('owd-window-nav--active')
12
15
  }
13
16
 
14
- if (typeof windowController?.state.focused === 'undefined' || !!windowController?.state.focused) {
17
+ if (
18
+ typeof windowController?.state.focused === 'undefined' ||
19
+ !!windowController?.state.focused
20
+ ) {
15
21
  list.push('owd-window-nav--focused')
16
22
  }
17
23
 
@@ -21,10 +27,9 @@ const classes = computed(() => {
21
27
 
22
28
  <template>
23
29
  <div :class="classes">
24
- <div class="owd-window-nav__draggable"/>
25
-
26
- <slot/>
30
+ <div class="owd-window-nav__draggable" />
27
31
 
32
+ <slot />
28
33
  </div>
29
34
  </template>
30
35
 
@@ -0,0 +1,51 @@
1
+ import { useApplicationManager } from './useApplicationManager'
2
+ import { computed } from '@vue/reactivity'
3
+
4
+ type SortBy =
5
+ | 'title'
6
+ | 'category'
7
+ | ((
8
+ a: ApplicationEntryWithInherited,
9
+ b: ApplicationEntryWithInherited,
10
+ ) => number)
11
+ type Visibility =
12
+ | 'primary'
13
+ | 'all'
14
+ | ((entry: ApplicationEntryWithInherited) => boolean)
15
+
16
+ export function useApplicationEntries() {
17
+ const applicationManager = useApplicationManager()
18
+
19
+ const sortedAppEntries = function (
20
+ sortBy: SortBy = 'title',
21
+ visibility: Visibility = 'primary',
22
+ ): Ref<ApplicationEntryWithInherited[]> {
23
+ return computed(() => {
24
+ const currentEntries = [...applicationManager.appsEntries]
25
+
26
+ // filtering
27
+ const filtered =
28
+ typeof visibility === 'function'
29
+ ? currentEntries.filter(visibility)
30
+ : visibility === 'primary'
31
+ ? currentEntries.filter((e) => e.visibility !== 'secondary')
32
+ : currentEntries
33
+
34
+ // sorting
35
+ const sorted =
36
+ typeof sortBy === 'function'
37
+ ? filtered.sort(sortBy)
38
+ : sortBy === 'title'
39
+ ? filtered.sort((a, b) =>
40
+ (a.title || '').localeCompare(b.title || ''),
41
+ )
42
+ : filtered.sort((a, b) =>
43
+ (a.category || '').localeCompare(b.category || ''),
44
+ )
45
+
46
+ return sorted
47
+ })
48
+ }
49
+
50
+ return { sortedAppEntries }
51
+ }
@@ -1,7 +1,7 @@
1
- import {ApplicationManager} from "../core/managers/ApplicationManager";
1
+ import { ApplicationManager } from '../core/managers/ApplicationManager'
2
2
 
3
3
  const applicationManager = new ApplicationManager()
4
4
 
5
5
  export function useApplicationManager(): IApplicationManager {
6
- return applicationManager
7
- }
6
+ return applicationManager
7
+ }
@@ -1,25 +1,25 @@
1
- import { ref } from 'vue';
1
+ import { ref } from 'vue'
2
2
 
3
- type ClipboardOperation = 'copy' | 'cut';
3
+ type ClipboardOperation = 'copy' | 'cut'
4
4
 
5
- const clipboardPath = ref<string | null>(null);
6
- const clipboardType = ref<ClipboardOperation | null>(null);
5
+ const clipboardFiles = ref<string[]>([])
6
+ const clipboardType = ref<ClipboardOperation | null>(null)
7
7
 
8
8
  export function useClipboardFs() {
9
- function setClipboard(path: string, type: ClipboardOperation) {
10
- clipboardPath.value = path;
11
- clipboardType.value = type;
9
+ function setClipboard(paths: string[], type: ClipboardOperation) {
10
+ clipboardFiles.value = paths
11
+ clipboardType.value = type
12
12
  }
13
13
 
14
14
  function clearClipboard() {
15
- clipboardPath.value = null;
16
- clipboardType.value = null;
15
+ clipboardFiles.value = []
16
+ clipboardType.value = null
17
17
  }
18
18
 
19
19
  return {
20
- clipboardPath,
20
+ clipboardFiles,
21
21
  clipboardType,
22
22
  setClipboard,
23
23
  clearClipboard,
24
- };
24
+ }
25
25
  }
@@ -1,7 +1,7 @@
1
- import {DesktopManager} from "../core/managers/DesktopManager";
1
+ import { DesktopManager } from '../core/managers/DesktopManager'
2
2
 
3
3
  const desktopManager = new DesktopManager()
4
4
 
5
5
  export function useDesktopManager() {
6
- return desktopManager
6
+ return desktopManager
7
7
  }
@@ -1,7 +1,7 @@
1
- import {TerminalManager} from "../core/managers/TerminalManager";
1
+ import { TerminalManager } from '../core/managers/TerminalManager'
2
2
 
3
3
  const terminalManager = new TerminalManager()
4
4
 
5
5
  export function useTerminalManager() {
6
- return terminalManager
7
- }
6
+ return terminalManager
7
+ }