@owdproject/nuxt 0.0.0-stage → 4.0.0-alpha.3

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 (169) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +77 -2
  3. package/dist/kit/authoring.d.ts +96 -0
  4. package/dist/kit/authoring.js +260 -0
  5. package/dist/kit/defineDesktopApp.d.ts +1 -0
  6. package/dist/kit/defineDesktopApp.js +1 -0
  7. package/dist/kit/defineDesktopPlugin.d.ts +1 -0
  8. package/dist/kit/defineDesktopPlugin.js +1 -0
  9. package/dist/module.d.mts +239 -0
  10. package/dist/module.json +12 -0
  11. package/dist/module.mjs +681 -0
  12. package/dist/runtime/components/Application/DesktopCoreApplicationRender.d.vue.ts +6 -0
  13. package/dist/runtime/components/Application/DesktopCoreApplicationRender.vue +18 -0
  14. package/dist/runtime/components/Application/DesktopCoreApplicationRender.vue.d.ts +6 -0
  15. package/dist/runtime/components/Application/DesktopCoreApplicationWindowsRender.d.vue.ts +9 -0
  16. package/dist/runtime/components/Application/DesktopCoreApplicationWindowsRender.vue +31 -0
  17. package/dist/runtime/components/Application/DesktopCoreApplicationWindowsRender.vue.d.ts +9 -0
  18. package/dist/runtime/components/DesktopCore.d.vue.ts +19 -0
  19. package/dist/runtime/components/DesktopCore.vue +37 -0
  20. package/dist/runtime/components/DesktopCore.vue.d.ts +19 -0
  21. package/dist/runtime/components/background/DesktopCoreBackground.d.vue.ts +13 -0
  22. package/dist/runtime/components/background/DesktopCoreBackground.vue +16 -0
  23. package/dist/runtime/components/background/DesktopCoreBackground.vue.d.ts +13 -0
  24. package/dist/runtime/components/time/DesktopCoreTime.d.vue.ts +3 -0
  25. package/dist/runtime/components/time/DesktopCoreTime.vue +44 -0
  26. package/dist/runtime/components/time/DesktopCoreTime.vue.d.ts +3 -0
  27. package/dist/runtime/components/window/DesktopCoreWindow.d.vue.ts +49 -0
  28. package/dist/runtime/components/window/DesktopCoreWindow.vue +403 -0
  29. package/dist/runtime/components/window/DesktopCoreWindow.vue.d.ts +49 -0
  30. package/dist/runtime/components/window/DesktopCoreWindowContent.d.vue.ts +13 -0
  31. package/dist/runtime/components/window/DesktopCoreWindowContent.vue +34 -0
  32. package/dist/runtime/components/window/DesktopCoreWindowContent.vue.d.ts +13 -0
  33. package/dist/runtime/components/window/DesktopCoreWindowNav.d.vue.ts +13 -0
  34. package/dist/runtime/components/window/DesktopCoreWindowNav.vue +54 -0
  35. package/dist/runtime/components/window/DesktopCoreWindowNav.vue.d.ts +13 -0
  36. package/dist/runtime/components/window/DesktopCoreWindowSnapHintsBase.d.vue.ts +19 -0
  37. package/dist/runtime/components/window/DesktopCoreWindowSnapHintsBase.vue +46 -0
  38. package/dist/runtime/components/window/DesktopCoreWindowSnapHintsBase.vue.d.ts +19 -0
  39. package/dist/runtime/components/workspace/DesktopCoreWorkspaceEdgeHintsBase.d.vue.ts +24 -0
  40. package/dist/runtime/components/workspace/DesktopCoreWorkspaceEdgeHintsBase.vue +50 -0
  41. package/dist/runtime/components/workspace/DesktopCoreWorkspaceEdgeHintsBase.vue.d.ts +24 -0
  42. package/dist/runtime/composables/application/state.d.ts +1 -0
  43. package/dist/runtime/composables/application/state.js +2 -0
  44. package/dist/runtime/composables/application/useDesktopApplicationDefine.d.ts +4 -0
  45. package/dist/runtime/composables/application/useDesktopApplicationDefine.js +36 -0
  46. package/dist/runtime/composables/application/useDesktopApplicationExec.d.ts +3 -0
  47. package/dist/runtime/composables/application/useDesktopApplicationExec.js +26 -0
  48. package/dist/runtime/composables/application/useDesktopApplicationProcess.d.ts +24 -0
  49. package/dist/runtime/composables/application/useDesktopApplicationProcess.js +140 -0
  50. package/dist/runtime/composables/application/useDesktopApplicationRegistry.d.ts +11 -0
  51. package/dist/runtime/composables/application/useDesktopApplicationRegistry.js +60 -0
  52. package/dist/runtime/composables/useApplicationEntries.d.ts +5 -0
  53. package/dist/runtime/composables/useApplicationEntries.js +10 -0
  54. package/dist/runtime/composables/useApplicationManager.d.ts +16 -0
  55. package/dist/runtime/composables/useApplicationManager.js +30 -0
  56. package/dist/runtime/composables/useBlockNonInputContextMenu.d.ts +5 -0
  57. package/dist/runtime/composables/useBlockNonInputContextMenu.js +19 -0
  58. package/dist/runtime/composables/useDesktop.d.ts +210 -0
  59. package/dist/runtime/composables/useDesktop.js +52 -0
  60. package/dist/runtime/composables/useDesktopApplication.d.ts +34 -0
  61. package/dist/runtime/composables/useDesktopApplication.js +17 -0
  62. package/dist/runtime/composables/useDesktopCommands.d.ts +12 -0
  63. package/dist/runtime/composables/useDesktopCommands.js +348 -0
  64. package/dist/runtime/composables/useDesktopConfig.d.ts +3 -0
  65. package/dist/runtime/composables/useDesktopConfig.js +10 -0
  66. package/dist/runtime/composables/useDesktopDefaultApps.d.ts +15 -0
  67. package/dist/runtime/composables/useDesktopDefaultApps.js +21 -0
  68. package/dist/runtime/composables/useDesktopDialogs.d.ts +5 -0
  69. package/dist/runtime/composables/useDesktopDialogs.js +8 -0
  70. package/dist/runtime/composables/useDesktopDrag.d.ts +1 -0
  71. package/dist/runtime/composables/useDesktopDrag.js +1 -0
  72. package/dist/runtime/composables/useDesktopHooks.d.ts +15 -0
  73. package/dist/runtime/composables/useDesktopHooks.js +12 -0
  74. package/dist/runtime/composables/useDesktopIPC.d.ts +35 -0
  75. package/dist/runtime/composables/useDesktopIPC.js +72 -0
  76. package/dist/runtime/composables/useDesktopIdentity.d.ts +22 -0
  77. package/dist/runtime/composables/useDesktopIdentity.js +65 -0
  78. package/dist/runtime/composables/useDesktopManifest.d.ts +6 -0
  79. package/dist/runtime/composables/useDesktopManifest.js +17 -0
  80. package/dist/runtime/composables/useDesktopNotification.d.ts +13 -0
  81. package/dist/runtime/composables/useDesktopNotification.js +13 -0
  82. package/dist/runtime/composables/useDesktopResize.d.ts +1 -0
  83. package/dist/runtime/composables/useDesktopResize.js +1 -0
  84. package/dist/runtime/composables/useDesktopSession.d.ts +4 -0
  85. package/dist/runtime/composables/useDesktopSession.js +17 -0
  86. package/dist/runtime/composables/useDesktopShellIdentity.d.ts +1 -0
  87. package/dist/runtime/composables/useDesktopShellIdentity.js +3 -0
  88. package/dist/runtime/composables/useDesktopShellOptions.d.ts +5 -0
  89. package/dist/runtime/composables/useDesktopShellOptions.js +18 -0
  90. package/dist/runtime/composables/useDesktopTray.d.ts +5 -0
  91. package/dist/runtime/composables/useDesktopTray.js +10 -0
  92. package/dist/runtime/composables/useDesktopVolume.d.ts +4 -0
  93. package/dist/runtime/composables/useDesktopVolume.js +9 -0
  94. package/dist/runtime/composables/useDesktopWorkArea.d.ts +1 -0
  95. package/dist/runtime/composables/useDesktopWorkArea.js +3 -0
  96. package/dist/runtime/composables/useDesktopWorkarea.d.ts +12 -0
  97. package/dist/runtime/composables/useDesktopWorkarea.js +72 -0
  98. package/dist/runtime/composables/useTerminalManager.d.ts +15 -0
  99. package/dist/runtime/composables/useTerminalManager.js +9 -0
  100. package/dist/runtime/composables/useToggleWindowMaximize.d.ts +1 -0
  101. package/dist/runtime/composables/useToggleWindowMaximize.js +12 -0
  102. package/dist/runtime/composables/useWindowDragHandlers.d.ts +7 -0
  103. package/dist/runtime/composables/useWindowDragHandlers.js +7 -0
  104. package/dist/runtime/composables/window/useDesktopWindow.d.ts +14 -0
  105. package/dist/runtime/composables/window/useDesktopWindow.js +192 -0
  106. package/dist/runtime/composables/window/useDesktopWindowSnapDrop.d.ts +13 -0
  107. package/dist/runtime/composables/window/useDesktopWindowSnapDrop.js +78 -0
  108. package/dist/runtime/composables/workspace/useDesktopWorkspaceEdgeDrop.d.ts +25 -0
  109. package/dist/runtime/composables/workspace/useDesktopWorkspaceEdgeDrop.js +119 -0
  110. package/dist/runtime/composables/workspace/useDesktopWorkspaceManager.d.ts +8 -0
  111. package/dist/runtime/composables/workspace/useDesktopWorkspaceManager.js +46 -0
  112. package/dist/runtime/composables/workspace/useDesktopWorkspaceOverviewCapture.d.ts +20 -0
  113. package/dist/runtime/composables/workspace/useDesktopWorkspaceOverviewCapture.js +60 -0
  114. package/dist/runtime/composables/workspace/useDesktopWorkspaceOverviewLiveScale.d.ts +31 -0
  115. package/dist/runtime/composables/workspace/useDesktopWorkspaceOverviewLiveScale.js +92 -0
  116. package/dist/runtime/constants/desktopShellKeys.d.ts +5 -0
  117. package/dist/runtime/constants/desktopShellKeys.js +2 -0
  118. package/dist/runtime/constants/shellLayout.d.ts +4 -0
  119. package/dist/runtime/constants/shellLayout.js +2 -0
  120. package/dist/runtime/dialogs/desktopDialogProvider.d.ts +6 -0
  121. package/dist/runtime/dialogs/desktopDialogProvider.js +12 -0
  122. package/dist/runtime/internal/controllers/ApplicationController.d.ts +37 -0
  123. package/dist/runtime/internal/controllers/ApplicationController.js +434 -0
  124. package/dist/runtime/internal/controllers/WindowController.d.ts +83 -0
  125. package/dist/runtime/internal/controllers/WindowController.js +435 -0
  126. package/dist/runtime/plugins/01.desktop-shell-init.client.d.ts +2 -0
  127. package/dist/runtime/plugins/01.desktop-shell-init.client.js +18 -0
  128. package/dist/runtime/plugins/02.desktop-register-desktop-apps.client.d.ts +2 -0
  129. package/dist/runtime/plugins/02.desktop-register-desktop-apps.client.js +7 -0
  130. package/dist/runtime/stores/storeApplicationMeta.d.ts +2 -0
  131. package/dist/runtime/stores/storeApplicationMeta.js +20 -0
  132. package/dist/runtime/stores/storeApplicationWindows.d.ts +2 -0
  133. package/dist/runtime/stores/storeApplicationWindows.js +33 -0
  134. package/dist/runtime/stores/storeDesktop.d.ts +17 -0
  135. package/dist/runtime/stores/storeDesktop.js +16 -0
  136. package/dist/runtime/stores/storeDesktopDefaultApps.d.ts +8 -0
  137. package/dist/runtime/stores/storeDesktopDefaultApps.js +21 -0
  138. package/dist/runtime/stores/storeDesktopTray.d.ts +6 -0
  139. package/dist/runtime/stores/storeDesktopTray.js +21 -0
  140. package/dist/runtime/stores/storeDesktopVolume.d.ts +4 -0
  141. package/dist/runtime/stores/storeDesktopVolume.js +12 -0
  142. package/dist/runtime/stores/storeDesktopWorkspace.d.ts +26 -0
  143. package/dist/runtime/stores/storeDesktopWorkspace.js +91 -0
  144. package/dist/runtime/stores/storeNotification.d.ts +27 -0
  145. package/dist/runtime/stores/storeNotification.js +55 -0
  146. package/dist/runtime/types/index.d.ts +1 -0
  147. package/dist/runtime/types/index.js +1 -0
  148. package/dist/runtime/utils/defineDesktopApp.d.ts +2 -0
  149. package/dist/runtime/utils/defineDesktopApp.js +5 -0
  150. package/dist/runtime/utils/defineDesktopPlugin.d.ts +19 -0
  151. package/dist/runtime/utils/defineDesktopPlugin.js +29 -0
  152. package/dist/runtime/utils/utilApp.d.ts +2 -0
  153. package/dist/runtime/utils/utilApp.js +9 -0
  154. package/dist/runtime/utils/utilCaptureElementToCanvas.d.ts +1 -0
  155. package/dist/runtime/utils/utilCaptureElementToCanvas.js +21 -0
  156. package/dist/runtime/utils/utilDebug.d.ts +4 -0
  157. package/dist/runtime/utils/utilDebug.js +24 -0
  158. package/dist/runtime/utils/utilDetectSnapZone.d.ts +1 -0
  159. package/dist/runtime/utils/utilDetectSnapZone.js +5 -0
  160. package/dist/runtime/utils/utilWindowControllerAdapter.d.ts +2 -0
  161. package/dist/runtime/utils/utilWindowControllerAdapter.js +151 -0
  162. package/dist/runtime/utils/utilWindowLayout.d.ts +4 -0
  163. package/dist/runtime/utils/utilWindowLayout.js +34 -0
  164. package/dist/runtime/utils/utilWorkspaceWindows.d.ts +2 -0
  165. package/dist/runtime/utils/utilWorkspaceWindows.js +12 -0
  166. package/dist/types/index.d.ts +156 -0
  167. package/dist/types/index.js +1 -0
  168. package/dist/types.d.mts +2 -0
  169. package/package.json +145 -4
@@ -0,0 +1,435 @@
1
+ import { markRaw, reactive, shallowRef, defineAsyncComponent } from "vue";
2
+ import { createActor } from "xstate";
3
+ import {
4
+ windowMachine,
5
+ IframeGuard
6
+ } from "@owdproject/core";
7
+ function formatWindowSnapshotValue(value) {
8
+ if (typeof value === "string") return value;
9
+ if (value && typeof value === "object") {
10
+ const entries = Object.entries(value);
11
+ if (entries.length > 0) {
12
+ const [k, v] = entries[0];
13
+ return `${k}.${formatWindowSnapshotValue(v)}`;
14
+ }
15
+ }
16
+ return "normal";
17
+ }
18
+ function deepClone(obj) {
19
+ if (obj === null || typeof obj !== "object") return obj;
20
+ return JSON.parse(JSON.stringify(obj));
21
+ }
22
+ export class WindowController {
23
+ application;
24
+ instanced = true;
25
+ model;
26
+ _stateValue = shallowRef("normal.focused.idle");
27
+ get stateValue() {
28
+ return this._stateValue.value;
29
+ }
30
+ config = {
31
+ title: "",
32
+ category: "",
33
+ component: void 0,
34
+ position: { x: 0, y: 0, z: 0 },
35
+ size: { width: void 0, height: void 0 },
36
+ minimizable: true,
37
+ maximized: false,
38
+ maximizable: true,
39
+ destroyable: true,
40
+ draggable: true,
41
+ resizable: true
42
+ };
43
+ override = reactive({});
44
+ storedState;
45
+ windowActor;
46
+ isDisposed = false;
47
+ actions;
48
+ constructor(application, model, windowConfig, windowStoredState, options) {
49
+ this.application = application;
50
+ this.model = model;
51
+ this.storedState = windowStoredState;
52
+ this.setConfig(windowConfig);
53
+ this.restoreState();
54
+ this.actions = Object.freeze({
55
+ setActive: this.setActive.bind(this),
56
+ setFocus: this.setFocus.bind(this),
57
+ bringToFront: this.focus.bind(this),
58
+ focus: this.focus.bind(this),
59
+ setPosition: this.setPosition.bind(this),
60
+ startDrag: this.startDrag.bind(this),
61
+ stopDrag: this.stopDrag.bind(this),
62
+ startResize: this.startResize.bind(this),
63
+ stopResize: this.stopResize.bind(this),
64
+ setSize: this.setSize.bind(this),
65
+ minimize: this.minimize.bind(this),
66
+ unminimize: this.unminimize.bind(this),
67
+ toggleMinimize: this.toggleMinimize.bind(this),
68
+ toggleMaximize: this.toggleMaximize.bind(this),
69
+ maximize: this.maximize.bind(this),
70
+ unmaximize: this.unmaximize.bind(this),
71
+ setLayout: this.setLayout.bind(this),
72
+ clearLayout: this.clearLayout.bind(this),
73
+ saveBoundsBeforeLayout: this.saveBoundsBeforeLayout.bind(this),
74
+ destroy: this.destroy.bind(this),
75
+ setWorkspace: this.setWorkspace.bind(this),
76
+ setTitleOverride: this.setTitleOverride.bind(this),
77
+ resetTitleOverride: this.resetTitleOverride.bind(this),
78
+ setWindowTitleOverride: this.setWindowTitleOverride.bind(this),
79
+ resetWindowTitleOverride: this.resetWindowTitleOverride.bind(this)
80
+ });
81
+ let initialValue = { normal: "unfocused" };
82
+ if (this.state.active === false) {
83
+ initialValue = "minimized";
84
+ } else if (this.state.maximized === true) {
85
+ initialValue = this.state.focused ? { maximized: "focused" } : { maximized: "unfocused" };
86
+ } else if (this.state.focused === true) {
87
+ initialValue = { normal: { focused: "idle" } };
88
+ }
89
+ this.windowActor = createActor(windowMachine, {
90
+ state: windowMachine.resolveState({
91
+ value: initialValue,
92
+ context: {
93
+ wasMaximized: !!this.state.maximized,
94
+ config: this.config
95
+ }
96
+ })
97
+ });
98
+ let wasLastMaximized = !!this.state.maximized;
99
+ this.windowActor.subscribe((snapshot) => {
100
+ if (this.isDisposed) return;
101
+ this._stateValue.value = formatWindowSnapshotValue(snapshot.value);
102
+ const isMinimized = snapshot.matches("minimized");
103
+ const isMaximized = snapshot.matches("maximized");
104
+ const isFocused = snapshot.matches("normal.focused") || snapshot.matches("maximized.focused");
105
+ const isDragging = snapshot.matches("normal.focused.dragging");
106
+ const isResizing = snapshot.matches("normal.focused.resizing");
107
+ if (this.state.active !== !isMinimized) this.state.active = !isMinimized;
108
+ if (this.state.maximized !== isMaximized) this.state.maximized = isMaximized;
109
+ if (this.state.focused !== isFocused) this.state.focused = isFocused;
110
+ if (this.state.dragging !== isDragging) this.state.dragging = isDragging;
111
+ if (this.state.resizing !== isResizing) this.state.resizing = isResizing;
112
+ if (isMaximized && !wasLastMaximized) {
113
+ this.saveBoundsBeforeLayout();
114
+ this.state.layout = "maximize";
115
+ const workarea = options?.getWorkarea?.();
116
+ if (workarea && workarea.width > 0 && workarea.height > 0) {
117
+ this.setPosition({ x: workarea.x, y: workarea.y });
118
+ this.setSize({ width: workarea.width, height: workarea.height });
119
+ }
120
+ } else if (!isMaximized && wasLastMaximized) {
121
+ if (this.state.layout === "maximize") {
122
+ this.clearLayout();
123
+ }
124
+ }
125
+ wasLastMaximized = isMaximized;
126
+ });
127
+ this.windowActor.start();
128
+ }
129
+ setConfig(config) {
130
+ if (config.component) {
131
+ this.config.component = markRaw(
132
+ typeof config.component === "function" ? defineAsyncComponent(config.component) : config.component
133
+ );
134
+ }
135
+ if (config.title) this.config.title = config.title;
136
+ if (config.icon) this.config.icon = config.icon;
137
+ if (!this.config.position) this.config.position = { x: 0, y: 0, z: 0 };
138
+ if (config.position?.x !== void 0) this.config.position.x = config.position.x;
139
+ if (config.position?.y !== void 0) this.config.position.y = config.position.y;
140
+ if (config.position?.z !== void 0) this.config.position.z = config.position.z;
141
+ if (config.size?.width !== void 0) this.config.size.width = config.size.width;
142
+ if (config.size?.height !== void 0) this.config.size.height = config.size.height;
143
+ if (config.size?.minWidth !== void 0) this.config.size.minWidth = config.size.minWidth;
144
+ if (config.size?.minHeight !== void 0) this.config.size.minHeight = config.size.minHeight;
145
+ if (config.size?.maxWidth !== void 0) this.config.size.maxWidth = config.size.maxWidth;
146
+ if (config.size?.maxHeight !== void 0) this.config.size.maxHeight = config.size.maxHeight;
147
+ if (typeof config.resizable !== "undefined") this.config.resizable = config.resizable;
148
+ if (typeof config.minimizable !== "undefined") this.config.minimizable = config.minimizable;
149
+ if (typeof config.maximizable !== "undefined") {
150
+ this.config.maximizable = config.maximizable;
151
+ } else {
152
+ this.config.maximizable = this.config.resizable !== false;
153
+ }
154
+ if (typeof config.maximized !== "undefined") this.config.maximized = config.maximized;
155
+ if (typeof config.draggable !== "undefined") this.config.draggable = config.draggable;
156
+ if (typeof config.destroyable !== "undefined") this.config.destroyable = config.destroyable;
157
+ const DEFAULT_OVERRIDABLE = {
158
+ draggable: true,
159
+ resizable: false,
160
+ position: false,
161
+ size: false,
162
+ maximized: false,
163
+ destroyable: false,
164
+ minimizable: false,
165
+ maximizable: false
166
+ };
167
+ DEFAULT_OVERRIDABLE.position = DEFAULT_OVERRIDABLE.draggable;
168
+ DEFAULT_OVERRIDABLE.size = DEFAULT_OVERRIDABLE.resizable;
169
+ DEFAULT_OVERRIDABLE.maximized = DEFAULT_OVERRIDABLE.maximizable;
170
+ this.config.overridable = {
171
+ ...DEFAULT_OVERRIDABLE,
172
+ ...config.overridable || {}
173
+ };
174
+ }
175
+ get state() {
176
+ return this.storedState.state;
177
+ }
178
+ restoreState() {
179
+ const overridable = this.config.overridable || {};
180
+ for (const key in overridable) {
181
+ if (overridable[key]) {
182
+ const stateKey = key;
183
+ if (typeof this.state[stateKey] === "undefined") {
184
+ if (typeof this.config[stateKey] === "object") {
185
+ this.state[stateKey] = deepClone(this.config[stateKey]);
186
+ } else {
187
+ this.state[stateKey] = !!this.config[stateKey];
188
+ }
189
+ }
190
+ }
191
+ }
192
+ }
193
+ get meta() {
194
+ return this.storedState.meta;
195
+ }
196
+ setPosition(data) {
197
+ if (!this.state.position) {
198
+ this.state.position = { x: 0, y: 0 };
199
+ }
200
+ this.state.position.x = Math.round(data.x);
201
+ this.state.position.y = Math.round(data.y);
202
+ }
203
+ setActive(value) {
204
+ if (this.isDisposed) return;
205
+ if (value) {
206
+ this.windowActor.send({ type: "RESTORE" });
207
+ } else {
208
+ this.windowActor.send({ type: "MINIMIZE" });
209
+ }
210
+ }
211
+ setFocus(value) {
212
+ if (this.isDisposed) return;
213
+ if (value) {
214
+ if (!this.state.focused) {
215
+ this.windowActor.send({ type: "FOCUS" });
216
+ }
217
+ } else {
218
+ if (this.state.focused) {
219
+ this.windowActor.send({ type: "BLUR" });
220
+ }
221
+ }
222
+ }
223
+ focus() {
224
+ if (this.isDisposed) return;
225
+ if (!this.state.position) {
226
+ this.state.position = { x: 0, y: 0, z: 0 };
227
+ }
228
+ if (this.application?.focusWindow) {
229
+ this.application.focusWindow(this);
230
+ } else {
231
+ this.setFocus(true);
232
+ }
233
+ }
234
+ get title() {
235
+ if (typeof this.override.title !== "undefined") return this.override.title;
236
+ if (this.config.title) return this.config.title;
237
+ return this.application?.config?.title ?? "";
238
+ }
239
+ get windowTitle() {
240
+ if (typeof this.override.windowTitle !== "undefined") return this.override.windowTitle;
241
+ return this.title;
242
+ }
243
+ get icon() {
244
+ if (typeof this.override.icon !== "undefined") return this.override.icon;
245
+ if (this.config.icon) return this.config.icon;
246
+ return this.application?.config?.icon;
247
+ }
248
+ get position() {
249
+ return this.state.position ?? this.config.position;
250
+ }
251
+ get size() {
252
+ const stateSize = this.state.size || {};
253
+ const configSize = this.config.size || {};
254
+ return {
255
+ width: stateSize.width !== void 0 ? stateSize.width : configSize.width,
256
+ height: stateSize.height !== void 0 ? stateSize.height : configSize.height,
257
+ minWidth: stateSize.minWidth !== void 0 ? stateSize.minWidth : configSize.minWidth,
258
+ maxWidth: stateSize.maxWidth !== void 0 ? stateSize.maxWidth : configSize.maxWidth,
259
+ minHeight: stateSize.minHeight !== void 0 ? stateSize.minHeight : configSize.minHeight,
260
+ maxHeight: stateSize.maxHeight !== void 0 ? stateSize.maxHeight : configSize.maxHeight
261
+ };
262
+ }
263
+ setSize(data) {
264
+ if (!this.state.size) {
265
+ this.state.size = { width: void 0, height: void 0 };
266
+ }
267
+ this.state.size.width = Math.round(data.width);
268
+ this.state.size.height = Math.round(data.height);
269
+ }
270
+ get isMinimizable() {
271
+ return this.config.overridable?.minimizable ? !!this.state.minimizable : !!this.config.minimizable;
272
+ }
273
+ minimize() {
274
+ if (this.isDisposed || !this.isMinimizable) return false;
275
+ this.windowActor.send({ type: "MINIMIZE" });
276
+ return true;
277
+ }
278
+ unminimize() {
279
+ if (this.isDisposed) return false;
280
+ this.windowActor.send({ type: "RESTORE" });
281
+ return true;
282
+ }
283
+ toggleMinimize() {
284
+ if (this.isDisposed) return;
285
+ if (this.windowActor.getSnapshot().matches("minimized")) {
286
+ this.unminimize();
287
+ this.focus();
288
+ } else if (this.state.focused) {
289
+ this.minimize();
290
+ } else {
291
+ this.focus();
292
+ }
293
+ }
294
+ get isMaximizable() {
295
+ return this.state.maximizable !== void 0 ? !!this.state.maximizable : !!this.config.maximizable;
296
+ }
297
+ get isMaximized() {
298
+ if (this.state.layout === "maximize") return true;
299
+ return this.config.overridable?.maximized ? !!this.state.maximized : !!this.config.maximized;
300
+ }
301
+ parseSizeValue(value, fallback) {
302
+ if (typeof value === "number") return value;
303
+ if (typeof value === "string") {
304
+ const parsed = Number.parseFloat(value);
305
+ if (!Number.isNaN(parsed)) return parsed;
306
+ }
307
+ return fallback;
308
+ }
309
+ saveBoundsBeforeLayout() {
310
+ if (this.state.layout && this.state.layout !== "normal") return;
311
+ const pos = this.position;
312
+ const size = this.size;
313
+ this.state.boundsBeforeLayout = {
314
+ x: pos?.x ?? 0,
315
+ y: pos?.y ?? 0,
316
+ width: this.parseSizeValue(size.width, 420),
317
+ height: this.parseSizeValue(size.height, 320)
318
+ };
319
+ }
320
+ setLayout(layout) {
321
+ if (this.isDisposed) return false;
322
+ if (layout === "normal") {
323
+ this.windowActor.send({ type: "RESTORE" });
324
+ this.clearLayout();
325
+ return true;
326
+ }
327
+ if (!this.isMaximizable) return false;
328
+ if (layout === "maximize") {
329
+ this.windowActor.send({ type: "MAXIMIZE" });
330
+ } else {
331
+ this.windowActor.send({ type: "RESTORE" });
332
+ this.saveBoundsBeforeLayout();
333
+ this.state.layout = layout;
334
+ }
335
+ return true;
336
+ }
337
+ clearLayout() {
338
+ const bounds = this.state.boundsBeforeLayout;
339
+ if (bounds) {
340
+ this.setPosition({ x: bounds.x, y: bounds.y });
341
+ this.setSize({ width: bounds.width, height: bounds.height });
342
+ delete this.state.boundsBeforeLayout;
343
+ }
344
+ this.state.layout = "normal";
345
+ this.state.maximized = false;
346
+ return true;
347
+ }
348
+ toggleMaximize() {
349
+ if (this.isDisposed || !this.isMaximizable) return false;
350
+ if (this.isMaximized) {
351
+ this.windowActor.send({ type: "RESTORE" });
352
+ } else {
353
+ this.windowActor.send({ type: "MAXIMIZE" });
354
+ }
355
+ return true;
356
+ }
357
+ maximize() {
358
+ if (this.isDisposed || !this.isMaximizable) return false;
359
+ this.windowActor.send({ type: "MAXIMIZE" });
360
+ return true;
361
+ }
362
+ unmaximize() {
363
+ if (this.isDisposed || !this.isMaximizable) return false;
364
+ this.windowActor.send({ type: "RESTORE" });
365
+ return true;
366
+ }
367
+ get isDestroyable() {
368
+ return this.config.overridable?.destroyable ? !!this.state.destroyable : !!this.config.destroyable;
369
+ }
370
+ dispose() {
371
+ if (this.isDisposed) return;
372
+ this.isDisposed = true;
373
+ try {
374
+ this.windowActor.stop();
375
+ } catch {
376
+ }
377
+ }
378
+ destroy() {
379
+ if (!this.isDestroyable) return false;
380
+ if (!this.isDisposed) {
381
+ this.windowActor.send({ type: "DESTROY" });
382
+ }
383
+ this.application?.closeWindow?.(this.state.id);
384
+ return true;
385
+ }
386
+ get isDraggable() {
387
+ return this.config.overridable?.draggable ? !!this.state.draggable : !!this.config.draggable;
388
+ }
389
+ get isResizable() {
390
+ return this.config.overridable?.resizable ? !!this.state.resizable : !!this.config.resizable;
391
+ }
392
+ setWorkspace(workspaceId) {
393
+ this.state.workspace = workspaceId;
394
+ }
395
+ startDrag() {
396
+ if (!this.isDisposed) {
397
+ IframeGuard.enable();
398
+ this.windowActor.send({ type: "DRAG_START" });
399
+ }
400
+ }
401
+ stopDrag() {
402
+ if (!this.isDisposed) {
403
+ IframeGuard.disable();
404
+ this.windowActor.send({ type: "DRAG_END" });
405
+ }
406
+ }
407
+ startResize() {
408
+ if (!this.isDisposed) {
409
+ IframeGuard.enable();
410
+ this.windowActor.send({ type: "RESIZE_START" });
411
+ }
412
+ }
413
+ stopResize() {
414
+ if (!this.isDisposed) {
415
+ IframeGuard.disable();
416
+ this.windowActor.send({ type: "RESIZE_END" });
417
+ }
418
+ }
419
+ setTitleOverride(value) {
420
+ this.override.title = value;
421
+ }
422
+ resetTitleOverride() {
423
+ this.override.title = void 0;
424
+ }
425
+ setWindowTitleOverride(value) {
426
+ this.override.windowTitle = value;
427
+ }
428
+ resetWindowTitleOverride() {
429
+ this.override.windowTitle = void 0;
430
+ }
431
+ menu = [];
432
+ setMenu(menu) {
433
+ this.menu = menu;
434
+ }
435
+ }
@@ -0,0 +1,2 @@
1
+ declare const _default: import("nuxt/app").Plugin<Record<string, unknown>> & import("nuxt/app").ObjectPlugin<Record<string, unknown>>;
2
+ export default _default;
@@ -0,0 +1,18 @@
1
+ import { defineNuxtPlugin } from "nuxt/app";
2
+ import { useDesktopStore } from "../stores/storeDesktop.js";
3
+ import { useDesktopWorkspaceStore } from "../stores/storeDesktopWorkspace.js";
4
+ import { useDesktopVolumeStore } from "../stores/storeDesktopVolume.js";
5
+ import { useDesktopNotificationStore } from "../stores/storeNotification.js";
6
+ import { useDesktopTrayStore } from "../stores/storeDesktopTray.js";
7
+ export default defineNuxtPlugin({
8
+ name: "desktop-shell-init",
9
+ dependsOn: ["pinia"],
10
+ setup() {
11
+ if (import.meta.server) return;
12
+ useDesktopStore();
13
+ useDesktopWorkspaceStore();
14
+ useDesktopVolumeStore();
15
+ useDesktopNotificationStore();
16
+ useDesktopTrayStore();
17
+ }
18
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: import("nuxt/app").Plugin<Record<string, unknown>> & import("nuxt/app").ObjectPlugin<Record<string, unknown>>;
2
+ export default _default;
@@ -0,0 +1,7 @@
1
+ import { defineNuxtPlugin } from "nuxt/app";
2
+ export default defineNuxtPlugin({
3
+ name: "desktop-register-desktop-apps",
4
+ dependsOn: ["pinia", "desktop-shell-init"],
5
+ setup() {
6
+ }
7
+ });
@@ -0,0 +1,2 @@
1
+ export declare function applicationMetaStoreId(appId: string): string;
2
+ export declare function useApplicationMetaStore(appId: string, customSetup?: () => Record<string, any>): import("pinia").SetupStoreDefinition<string, unknown>;
@@ -0,0 +1,20 @@
1
+ import { reactive } from "vue";
2
+ import { defineStore } from "pinia";
3
+ const metaStoreRegistry = /* @__PURE__ */ new Map();
4
+ export function applicationMetaStoreId(appId) {
5
+ return `desktop/application/${appId}/meta`;
6
+ }
7
+ export function useApplicationMetaStore(appId, customSetup) {
8
+ let storeFactory = metaStoreRegistry.get(appId);
9
+ if (!storeFactory) {
10
+ storeFactory = defineStore(applicationMetaStoreId(appId), () => {
11
+ if (customSetup) {
12
+ return customSetup();
13
+ }
14
+ const data = reactive({});
15
+ return { data };
16
+ });
17
+ metaStoreRegistry.set(appId, storeFactory);
18
+ }
19
+ return storeFactory;
20
+ }
@@ -0,0 +1,2 @@
1
+ export declare function applicationWindowsStoreId(appId: string): string;
2
+ export declare function useApplicationWindowsStore(appId: string): import("pinia").Store<string, Pick<unknown, never>, Pick<unknown, never>, Pick<unknown, never>>;
@@ -0,0 +1,33 @@
1
+ import { reactive } from "vue";
2
+ import { defineStore } from "pinia";
3
+ const windowsStoreRegistry = /* @__PURE__ */ new Map();
4
+ export function applicationWindowsStoreId(appId) {
5
+ return `desktop/application/${appId}/windows`;
6
+ }
7
+ export function useApplicationWindowsStore(appId) {
8
+ let storeFactory = windowsStoreRegistry.get(appId);
9
+ if (!storeFactory) {
10
+ storeFactory = defineStore(applicationWindowsStoreId(appId), () => {
11
+ const windows = reactive({});
12
+ function setWindowState(windowId, stored) {
13
+ windows[windowId] = stored;
14
+ }
15
+ function removeWindowState(windowId) {
16
+ delete windows[windowId];
17
+ }
18
+ function clearWindows() {
19
+ for (const key of Object.keys(windows)) {
20
+ delete windows[key];
21
+ }
22
+ }
23
+ return {
24
+ windows,
25
+ setWindowState,
26
+ removeWindowState,
27
+ clearWindows
28
+ };
29
+ });
30
+ windowsStoreRegistry.set(appId, storeFactory);
31
+ }
32
+ return storeFactory();
33
+ }
@@ -0,0 +1,17 @@
1
+ export interface DesktopGlobalState {
2
+ defaultApps: Record<string, {
3
+ applicationId: string;
4
+ entry: string;
5
+ }>;
6
+ positionZ: number;
7
+ }
8
+ export declare const useDesktopStore: import("pinia").SetupStoreDefinition<"desktop", {
9
+ state: {
10
+ defaultApps: Record<string, {
11
+ applicationId: string;
12
+ entry: string;
13
+ }>;
14
+ positionZ: number;
15
+ };
16
+ incrementPositionZ: () => number;
17
+ }>;
@@ -0,0 +1,16 @@
1
+ import { reactive } from "vue";
2
+ import { defineStore } from "pinia";
3
+ export const useDesktopStore = defineStore("desktop", () => {
4
+ const state = reactive({
5
+ defaultApps: {},
6
+ positionZ: 100
7
+ });
8
+ function incrementPositionZ() {
9
+ state.positionZ += 1;
10
+ return state.positionZ;
11
+ }
12
+ return {
13
+ state,
14
+ incrementPositionZ
15
+ };
16
+ });
@@ -0,0 +1,8 @@
1
+ import type { IApplicationController } from '../../types/index.js';
2
+ export declare const useDesktopDefaultAppsStore: import("pinia").SetupStoreDefinition<"desktop/default-apps", {
3
+ getDefaultApp: (feature: string) => {
4
+ applicationId: string;
5
+ entry: string;
6
+ };
7
+ setDefaultApp: (feature: string, application: IApplicationController, entry: string) => void;
8
+ }>;
@@ -0,0 +1,21 @@
1
+ import { defineStore } from "pinia";
2
+ import { useDesktopStore } from "./storeDesktop.js";
3
+ export const useDesktopDefaultAppsStore = defineStore(
4
+ "desktop/default-apps",
5
+ () => {
6
+ const desktopStore = useDesktopStore();
7
+ function getDefaultApp(feature) {
8
+ return desktopStore.state.defaultApps[feature];
9
+ }
10
+ function setDefaultApp(feature, application, entry) {
11
+ desktopStore.state.defaultApps[feature] = {
12
+ applicationId: application.id,
13
+ entry
14
+ };
15
+ }
16
+ return {
17
+ getDefaultApp,
18
+ setDefaultApp
19
+ };
20
+ }
21
+ );
@@ -0,0 +1,6 @@
1
+ import type { DesktopTrayItem } from '../../types/index.js';
2
+ export declare const useDesktopTrayStore: import("pinia").SetupStoreDefinition<"desktop/tray", {
3
+ items: import("vue").Ref<any, any>;
4
+ registerIcon: (item: DesktopTrayItem) => void;
5
+ unregisterIcon: (id: string) => void;
6
+ }>;
@@ -0,0 +1,21 @@
1
+ import { ref } from "vue";
2
+ import { defineStore } from "pinia";
3
+ export const useDesktopTrayStore = defineStore("desktop/tray", () => {
4
+ const items = ref([]);
5
+ function registerIcon(item) {
6
+ const existingIdx = items.value.findIndex((i) => i.id === item.id);
7
+ if (existingIdx >= 0) {
8
+ items.value[existingIdx] = item;
9
+ } else {
10
+ items.value.push(item);
11
+ }
12
+ }
13
+ function unregisterIcon(id) {
14
+ items.value = items.value.filter((i) => i.id !== id);
15
+ }
16
+ return {
17
+ items,
18
+ registerIcon,
19
+ unregisterIcon
20
+ };
21
+ });
@@ -0,0 +1,4 @@
1
+ export declare const useDesktopVolumeStore: import("pinia").SetupStoreDefinition<"desktop/volume", {
2
+ master: import("vue").Ref<number, number>;
3
+ setMasterVolume: (value: number) => void;
4
+ }>;
@@ -0,0 +1,12 @@
1
+ import { ref } from "vue";
2
+ import { defineStore } from "pinia";
3
+ export const useDesktopVolumeStore = defineStore("desktop/volume", () => {
4
+ const master = ref(100);
5
+ function setMasterVolume(value) {
6
+ master.value = Math.max(0, Math.min(100, value));
7
+ }
8
+ return {
9
+ master,
10
+ setMasterVolume
11
+ };
12
+ });
@@ -0,0 +1,26 @@
1
+ import type { DesktopWorkareaRect } from '../../types/index.js';
2
+ export declare const EMPTY_DESKTOP_WORKAREA: DesktopWorkareaRect;
3
+ export declare const useDesktopWorkspaceStore: import("pinia").SetupStoreDefinition<"desktop/workspace", {
4
+ list: import("vue").Ref<string[], string[]>;
5
+ active: import("vue").Ref<string, string>;
6
+ overview: import("vue").Ref<boolean, boolean>;
7
+ workarea: import("vue").Ref<{
8
+ x: number;
9
+ y: number;
10
+ width: number;
11
+ height: number;
12
+ }, DesktopWorkareaRect | {
13
+ x: number;
14
+ y: number;
15
+ width: number;
16
+ height: number;
17
+ }>;
18
+ workspaceActiveIndex: import("vue").ComputedRef<number>;
19
+ setWorkspace: (workspaceId: string) => boolean;
20
+ setOverview: (value: boolean) => void;
21
+ toggleOverview: () => void;
22
+ setWorkarea: (rect: DesktopWorkareaRect) => void;
23
+ addWorkspace: (id?: string) => string;
24
+ removeWorkspace: (workspaceId: string) => boolean;
25
+ resolveWorkspaceFallback: (removedId: string) => string | null;
26
+ }>;