@owdproject/core 3.3.1 → 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 (93) hide show
  1. package/README.md +91 -59
  2. package/dist/dom/index.d.mts +65 -0
  3. package/dist/dom/index.d.ts +65 -0
  4. package/dist/dom/index.mjs +224 -0
  5. package/dist/events/index.d.mts +70 -0
  6. package/dist/events/index.d.ts +70 -0
  7. package/dist/events/index.mjs +3 -0
  8. package/dist/index.d.mts +73 -0
  9. package/dist/index.d.ts +73 -0
  10. package/dist/index.mjs +115 -0
  11. package/dist/layout/index.d.mts +41 -0
  12. package/dist/layout/index.d.ts +41 -0
  13. package/dist/layout/index.mjs +64 -0
  14. package/dist/machines/index.d.mts +31 -0
  15. package/dist/machines/index.d.ts +31 -0
  16. package/dist/machines/index.mjs +2 -0
  17. package/dist/managers/index.d.mts +117 -0
  18. package/dist/managers/index.d.ts +117 -0
  19. package/dist/managers/index.mjs +6 -0
  20. package/dist/session/index.d.mts +57 -0
  21. package/dist/session/index.d.ts +57 -0
  22. package/dist/session/index.mjs +65 -0
  23. package/dist/shared/core.B0B0KfVK.mjs +865 -0
  24. package/dist/shared/core.B1XxB289.mjs +239 -0
  25. package/dist/shared/core.B3mp7ztE.mjs +237 -0
  26. package/dist/shared/core.BOvFdEVQ.d.ts +114 -0
  27. package/dist/shared/core.CsDFgGnX.mjs +40 -0
  28. package/dist/shared/core.Di1eFcr_.d.mts +114 -0
  29. package/dist/shared/core.Pd_Ogt4g.mjs +101 -0
  30. package/dist/shared/core.b3Xldzyu.mjs +29 -0
  31. package/dist/types/index.d.mts +266 -0
  32. package/dist/types/index.d.ts +266 -0
  33. package/dist/types/index.mjs +1 -0
  34. package/package.json +60 -87
  35. package/bin/cli.js +0 -395
  36. package/bin/desktop.js +0 -5
  37. package/bin/lib/catalog.js +0 -293
  38. package/bin/lib/config.js +0 -109
  39. package/bin/lib/desktopConfig.js +0 -56
  40. package/bin/lib/generateTemplate.js +0 -389
  41. package/bin/lib/install.js +0 -408
  42. package/bin/lib/migrateModulePlayground.config.mjs +0 -164
  43. package/bin/lib/migrateModulePlayground.mjs +0 -313
  44. package/bin/lib/npmVersions.js +0 -124
  45. package/bin/lib/playgroundContext.js +0 -188
  46. package/bin/lib/scaffold.js +0 -197
  47. package/bin/lib/status.js +0 -289
  48. package/bin/lib/validateModule.js +0 -697
  49. package/bin/lib/workspace.js +0 -182
  50. package/bin/owd.js +0 -5
  51. package/bin/tui.js +0 -1379
  52. package/dist/module.d.mts +0 -13
  53. package/dist/module.json +0 -9
  54. package/dist/module.mjs +0 -268
  55. package/dist/types.d.mts +0 -7
  56. package/index.ts +0 -5
  57. package/module.ts +0 -223
  58. package/runtime/components/Desktop/Application/DesktopApplicationRender.vue +0 -20
  59. package/runtime/components/Desktop/Application/DesktopApplicationWindowsRender.vue +0 -38
  60. package/runtime/components/Desktop/Background/DesktopBackground.vue +0 -16
  61. package/runtime/components/Desktop/Core/DesktopCore.vue +0 -90
  62. package/runtime/components/Desktop/Time/DesktopTime.vue +0 -56
  63. package/runtime/components/Desktop/Window/DesktopWindow.vue +0 -204
  64. package/runtime/components/Desktop/Window/DesktopWindowContent.vue +0 -28
  65. package/runtime/components/Desktop/Window/DesktopWindowNav.vue +0 -66
  66. package/runtime/composables/useApplicationEntries.ts +0 -51
  67. package/runtime/composables/useApplicationManager.ts +0 -285
  68. package/runtime/composables/useDesktopManager.ts +0 -49
  69. package/runtime/composables/useTerminalManager.ts +0 -66
  70. package/runtime/composables/useWorkspaceManager.ts +0 -41
  71. package/runtime/internal/controllers/ApplicationController.ts +0 -345
  72. package/runtime/internal/controllers/WindowController.ts +0 -462
  73. package/runtime/plugins/02.desktop-register-desktop-apps.client.ts +0 -17
  74. package/runtime/plugins/resize.client.ts +0 -6
  75. package/runtime/stores/storeApplicationMeta.ts +0 -59
  76. package/runtime/stores/storeApplicationWindows.ts +0 -20
  77. package/runtime/stores/storeDesktop.ts +0 -111
  78. package/runtime/stores/storeDesktopDefaultApps.ts +0 -53
  79. package/runtime/stores/storeDesktopVolume.ts +0 -18
  80. package/runtime/stores/storeDesktopWindow.ts +0 -20
  81. package/runtime/stores/storeDesktopWorkspace.ts +0 -75
  82. package/runtime/utils/captureElementToCanvas.ts +0 -21
  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/utilApp.ts +0 -37
  87. package/runtime/utils/utilCommon.ts +0 -26
  88. package/runtime/utils/utilDebug.ts +0 -30
  89. package/runtime/utils/utilDesktop.ts +0 -35
  90. package/runtime/utils/utilTerminal.ts +0 -6
  91. package/runtime/utils/utilWindow.ts +0 -15
  92. package/runtime/utils/validateDesktopUserConfig.ts +0 -44
  93. package/types/index.d.ts +0 -420
@@ -0,0 +1,239 @@
1
+ import { g as globalDesktopHooks, a as globalIPCBus } from './core.Pd_Ogt4g.mjs';
2
+
3
+ function shellEscape(str) {
4
+ if (str === "") {
5
+ return "''";
6
+ }
7
+ return `${str.replace(/'/g, `'\\''`)}`;
8
+ }
9
+ function padEnd(str, len) {
10
+ return str.length >= len ? str : str + " ".repeat(len - str.length);
11
+ }
12
+ function formatDuration(ms) {
13
+ const totalSec = Math.max(0, Math.floor(ms / 1e3));
14
+ const m = Math.floor(totalSec / 60);
15
+ const s = totalSec % 60;
16
+ return `${String(m).padStart(2, "0")}m ${String(s).padStart(2, "0")}s`;
17
+ }
18
+ function parseCommandLine(input) {
19
+ const trimmed = input.trim();
20
+ if (!trimmed) {
21
+ return { name: "", args: [] };
22
+ }
23
+ const [name = "", ...args] = trimmed.split(/\s+/);
24
+ return { name, args };
25
+ }
26
+
27
+ class DesktopKeybindings {
28
+ windowManager;
29
+ workareaProvider;
30
+ customHandlers = /* @__PURE__ */ new Map();
31
+ isListening = false;
32
+ listenerRef;
33
+ constructor(windowManager, options) {
34
+ this.windowManager = windowManager;
35
+ this.workareaProvider = options?.workareaProvider;
36
+ }
37
+ register(shortcut, handler) {
38
+ this.customHandlers.set(shortcut.toLowerCase(), handler);
39
+ return this;
40
+ }
41
+ listen() {
42
+ if (typeof window === "undefined" || this.isListening) {
43
+ return () => this.stop();
44
+ }
45
+ this.isListening = true;
46
+ this.listenerRef = (e) => this.handleKeyDown(e);
47
+ window.addEventListener("keydown", this.listenerRef);
48
+ return () => this.stop();
49
+ }
50
+ stop() {
51
+ if (typeof window !== "undefined" && this.listenerRef) {
52
+ window.removeEventListener("keydown", this.listenerRef);
53
+ }
54
+ this.isListening = false;
55
+ }
56
+ handleKeyDown(e) {
57
+ const activeEl = document.activeElement;
58
+ if (activeEl && (activeEl.tagName === "INPUT" || activeEl.tagName === "TEXTAREA" || activeEl.isContentEditable)) {
59
+ return;
60
+ }
61
+ const isMetaOrCtrl = e.metaKey || e.ctrlKey;
62
+ const isAlt = e.altKey;
63
+ const isShift = e.shiftKey;
64
+ const key = e.key.toLowerCase();
65
+ if (isAlt && key === "tab") {
66
+ e.preventDefault();
67
+ this.cycleWindowFocus(isShift ? "backward" : "forward");
68
+ return;
69
+ }
70
+ if (isMetaOrCtrl) {
71
+ const focused = this.windowManager.focusedWindow;
72
+ const workarea = this.workareaProvider?.() ?? {
73
+ x: 0,
74
+ y: 0,
75
+ width: typeof window !== "undefined" ? window.innerWidth : 1920,
76
+ height: typeof window !== "undefined" ? window.innerHeight : 1080
77
+ };
78
+ if (key === "arrowleft" && focused) {
79
+ e.preventDefault();
80
+ this.windowManager.snapWindow(focused.id, "left-half", workarea);
81
+ return;
82
+ }
83
+ if (key === "arrowright" && focused) {
84
+ e.preventDefault();
85
+ this.windowManager.snapWindow(focused.id, "right-half", workarea);
86
+ return;
87
+ }
88
+ if (key === "arrowup" && focused) {
89
+ e.preventDefault();
90
+ if (!focused.state.maximized) {
91
+ focused.maximize();
92
+ }
93
+ return;
94
+ }
95
+ if (key === "arrowdown" && focused) {
96
+ e.preventDefault();
97
+ if (focused.state.maximized) {
98
+ focused.unmaximize();
99
+ } else {
100
+ focused.minimize();
101
+ }
102
+ return;
103
+ }
104
+ if (key === "w" && focused && !e.shiftKey) {
105
+ e.preventDefault();
106
+ this.windowManager.closeWindow(focused.id);
107
+ return;
108
+ }
109
+ }
110
+ }
111
+ cycleWindowFocus(direction) {
112
+ const activeWindows = Array.from(this.windowManager.getSnapshot()).filter((w) => w.active);
113
+ if (activeWindows.length <= 1) return;
114
+ const focusedId = this.windowManager.focusedWindow?.id;
115
+ const currentIndex = activeWindows.findIndex((w) => w.id === focusedId);
116
+ let nextIndex = 0;
117
+ if (direction === "forward") {
118
+ nextIndex = (currentIndex + 1) % activeWindows.length;
119
+ } else {
120
+ nextIndex = (currentIndex - 1 + activeWindows.length) % activeWindows.length;
121
+ }
122
+ const nextWin = activeWindows[nextIndex];
123
+ if (nextWin) {
124
+ this.windowManager.focusWindow(nextWin.id);
125
+ }
126
+ }
127
+ }
128
+
129
+ class DesktopCommands {
130
+ commands = /* @__PURE__ */ new Map();
131
+ snapshotCache = Object.freeze([]);
132
+ subscribers = /* @__PURE__ */ new Set();
133
+ hooks;
134
+ ipc;
135
+ constructor(options) {
136
+ this.hooks = options?.hooks ?? globalDesktopHooks;
137
+ this.ipc = options?.ipc ?? globalIPCBus;
138
+ }
139
+ getSnapshot() {
140
+ return this.snapshotCache;
141
+ }
142
+ subscribe(callback) {
143
+ this.subscribers.add(callback);
144
+ callback(this.getSnapshot());
145
+ return () => {
146
+ this.subscribers.delete(callback);
147
+ };
148
+ }
149
+ notify() {
150
+ this.snapshotCache = Object.freeze(
151
+ Array.from(this.commands.values()).map(({ handler: _h, ...meta }) => Object.freeze({ ...meta }))
152
+ );
153
+ const snapshot = this.getSnapshot();
154
+ for (const sub of this.subscribers) {
155
+ try {
156
+ sub(snapshot);
157
+ } catch {
158
+ }
159
+ }
160
+ }
161
+ register(command, handler) {
162
+ this.commands.set(command.name, {
163
+ ...command,
164
+ handler
165
+ });
166
+ this.notify();
167
+ return () => {
168
+ this.unregister(command.name);
169
+ };
170
+ }
171
+ unregister(name) {
172
+ const deleted = this.commands.delete(name);
173
+ if (deleted) {
174
+ this.notify();
175
+ }
176
+ return deleted;
177
+ }
178
+ has(name) {
179
+ return this.commands.has(name);
180
+ }
181
+ getCommands() {
182
+ return this.getSnapshot();
183
+ }
184
+ async exec(input) {
185
+ const { name, args } = parseCommandLine(input);
186
+ if (!name) return void 0;
187
+ const execCtx = {
188
+ input,
189
+ commandName: name,
190
+ args,
191
+ cancel: false,
192
+ overrideOutput: void 0
193
+ };
194
+ await this.hooks.callHook("command:before-exec", execCtx);
195
+ if (execCtx.cancel) {
196
+ return execCtx.overrideOutput ?? {
197
+ message: `Command "${name}" execution cancelled by policy.`,
198
+ isError: true
199
+ };
200
+ }
201
+ const registered = this.commands.get(name);
202
+ if (!registered) {
203
+ const notFoundOutput = {
204
+ message: `${name}: command not found`,
205
+ isError: true
206
+ };
207
+ await this.hooks.callHook("command:after-exec", {
208
+ input,
209
+ commandName: name,
210
+ output: notFoundOutput
211
+ });
212
+ return notFoundOutput;
213
+ }
214
+ try {
215
+ const result = await registered.handler(args, input);
216
+ const output = typeof result === "string" ? { message: result, isError: false } : result;
217
+ this.ipc.emit("command:executed", { command: name, args }, { source: "commands" });
218
+ await this.hooks.callHook("command:after-exec", {
219
+ input,
220
+ commandName: name,
221
+ output
222
+ });
223
+ return output;
224
+ } catch (err) {
225
+ const errorOutput = {
226
+ message: err?.message || String(err),
227
+ isError: true
228
+ };
229
+ await this.hooks.callHook("command:after-exec", {
230
+ input,
231
+ commandName: name,
232
+ output: errorOutput
233
+ });
234
+ return errorOutput;
235
+ }
236
+ }
237
+ }
238
+
239
+ export { DesktopCommands as D, DesktopKeybindings as a, parseCommandLine as b, formatDuration as f, padEnd as p, shellEscape as s };
@@ -0,0 +1,237 @@
1
+ import { createMachine, assign } from 'xstate';
2
+
3
+ const windowMachine = createMachine({
4
+ id: "window",
5
+ initial: "normal",
6
+ context: ({ input }) => ({
7
+ wasMaximized: false,
8
+ config: input?.config
9
+ }),
10
+ states: {
11
+ normal: {
12
+ entry: assign({ wasMaximized: false }),
13
+ initial: "focused",
14
+ states: {
15
+ focused: {
16
+ initial: "idle",
17
+ states: {
18
+ idle: {
19
+ on: {
20
+ DRAG_START: "dragging",
21
+ RESIZE_START: "resizing"
22
+ }
23
+ },
24
+ dragging: {
25
+ on: {
26
+ DRAG_END: "idle",
27
+ SNAP_DROP: "idle"
28
+ }
29
+ },
30
+ resizing: {
31
+ on: {
32
+ RESIZE_END: "idle"
33
+ }
34
+ }
35
+ },
36
+ on: {
37
+ BLUR: "unfocused",
38
+ MAXIMIZE: "#window.maximized.focused",
39
+ MINIMIZE: "#window.minimized"
40
+ }
41
+ },
42
+ unfocused: {
43
+ on: {
44
+ FOCUS: "focused",
45
+ MAXIMIZE: "#window.maximized.unfocused",
46
+ MINIMIZE: "#window.minimized"
47
+ }
48
+ }
49
+ },
50
+ on: {
51
+ DESTROY: "closed"
52
+ }
53
+ },
54
+ maximized: {
55
+ entry: assign({ wasMaximized: true }),
56
+ initial: "focused",
57
+ states: {
58
+ focused: {
59
+ on: {
60
+ BLUR: "unfocused",
61
+ RESTORE: "#window.normal.focused",
62
+ MINIMIZE: "#window.minimized"
63
+ }
64
+ },
65
+ unfocused: {
66
+ on: {
67
+ FOCUS: "focused",
68
+ RESTORE: "#window.normal.unfocused",
69
+ MINIMIZE: "#window.minimized"
70
+ }
71
+ }
72
+ },
73
+ on: {
74
+ DESTROY: "closed"
75
+ }
76
+ },
77
+ minimized: {
78
+ on: {
79
+ RESTORE: [
80
+ {
81
+ target: "maximized.focused",
82
+ guard: ({ context }) => context.wasMaximized
83
+ },
84
+ {
85
+ target: "normal.focused"
86
+ }
87
+ ],
88
+ DESTROY: "closed"
89
+ }
90
+ },
91
+ closed: {
92
+ type: "final"
93
+ }
94
+ }
95
+ });
96
+
97
+ const applicationMachine = createMachine({
98
+ id: "application",
99
+ initial: "idle",
100
+ context: ({ input }) => ({
101
+ id: input?.id ?? "",
102
+ config: input?.config,
103
+ windowCount: 0
104
+ }),
105
+ states: {
106
+ idle: {
107
+ on: {
108
+ LAUNCH: "initializing",
109
+ RESTORE: "initializing",
110
+ OPEN_WINDOW: {
111
+ target: "running.active",
112
+ actions: assign({
113
+ windowCount: ({ context }) => context.windowCount + 1
114
+ })
115
+ }
116
+ }
117
+ },
118
+ initializing: {
119
+ on: {
120
+ INITIALIZED: [
121
+ {
122
+ target: "running.active",
123
+ guard: ({ context }) => context.windowCount > 0
124
+ },
125
+ {
126
+ target: "ready"
127
+ }
128
+ ],
129
+ OPEN_WINDOW: {
130
+ actions: assign({
131
+ windowCount: ({ context }) => context.windowCount + 1
132
+ })
133
+ },
134
+ INIT_FAILED: "error"
135
+ }
136
+ },
137
+ ready: {
138
+ on: {
139
+ LAUNCH: "running.active",
140
+ START_PROCESS: "running.active",
141
+ OPEN_WINDOW: {
142
+ target: "running.active",
143
+ actions: assign({
144
+ windowCount: ({ context }) => context.windowCount + 1
145
+ })
146
+ },
147
+ CLOSE_APP: "terminating"
148
+ }
149
+ },
150
+ running: {
151
+ initial: "active",
152
+ states: {
153
+ active: {
154
+ on: {
155
+ MINIMIZE_ALL: "suspended",
156
+ SUSPEND: "suspended",
157
+ SIGSTOP: "suspended",
158
+ CLOSE_WINDOW: [
159
+ {
160
+ target: "#application.terminating",
161
+ guard: ({ context }) => context.windowCount - 1 <= 0,
162
+ actions: assign({
163
+ windowCount: () => 0
164
+ })
165
+ },
166
+ {
167
+ actions: assign({
168
+ windowCount: ({ context }) => Math.max(0, context.windowCount - 1)
169
+ })
170
+ }
171
+ ],
172
+ OPEN_WINDOW: {
173
+ actions: assign({
174
+ windowCount: ({ context }) => context.windowCount + 1
175
+ })
176
+ }
177
+ }
178
+ },
179
+ suspended: {
180
+ on: {
181
+ RESTORE_WINDOW: "active",
182
+ RESUME: "active",
183
+ SIGCONT: "active",
184
+ LAUNCH: "active",
185
+ OPEN_WINDOW: {
186
+ target: "active",
187
+ actions: assign({
188
+ windowCount: ({ context }) => context.windowCount + 1
189
+ })
190
+ },
191
+ CLOSE_WINDOW: [
192
+ {
193
+ target: "#application.terminating",
194
+ guard: ({ context }) => context.windowCount - 1 <= 0,
195
+ actions: assign({
196
+ windowCount: () => 0
197
+ })
198
+ },
199
+ {
200
+ actions: assign({
201
+ windowCount: ({ context }) => Math.max(0, context.windowCount - 1)
202
+ })
203
+ }
204
+ ]
205
+ }
206
+ }
207
+ },
208
+ on: {
209
+ CLOSE_APP: "terminating",
210
+ SIGTERM: "terminating",
211
+ SIGKILL: "terminating"
212
+ }
213
+ },
214
+ terminating: {
215
+ entry: assign({
216
+ windowCount: () => 0
217
+ }),
218
+ on: {
219
+ TERMINATED: "ready"
220
+ }
221
+ },
222
+ error: {
223
+ on: {
224
+ RESET: "ready",
225
+ LAUNCH: "running.active",
226
+ OPEN_WINDOW: {
227
+ target: "running.active",
228
+ actions: assign({
229
+ windowCount: ({ context }) => context.windowCount + 1
230
+ })
231
+ }
232
+ }
233
+ }
234
+ }
235
+ });
236
+
237
+ export { applicationMachine as a, windowMachine as w };
@@ -0,0 +1,114 @@
1
+ import { Hookable } from 'hookable';
2
+ import { DesktopKernelEvent, DesktopRuntimeHooks, WindowConfig, WindowState, WindowLayout, DesktopWorkareaRect, SpatialTransform } from '../types/index.js';
3
+
4
+ type EventHandler = (event: DesktopKernelEvent) => void;
5
+ declare class CoreIPCBus {
6
+ private readonly maxEvents;
7
+ private events;
8
+ private readonly listeners;
9
+ private eventCounter;
10
+ private subscribers;
11
+ constructor(options?: {
12
+ maxEvents?: number;
13
+ });
14
+ emit(channel: string, payload?: any, options?: {
15
+ source?: string;
16
+ severity?: 'info' | 'warn' | 'error';
17
+ }): DesktopKernelEvent;
18
+ on(channel: string, handler: EventHandler): () => void;
19
+ off(channel: string, handler: EventHandler): void;
20
+ getEvents(): DesktopKernelEvent[];
21
+ getActiveChannels(): string[];
22
+ clear(): void;
23
+ subscribe(callback: (events: DesktopKernelEvent[]) => void): () => void;
24
+ }
25
+ declare const globalIPCBus: CoreIPCBus;
26
+
27
+ declare class WindowInstance {
28
+ readonly id: string;
29
+ readonly model: string;
30
+ readonly applicationId?: string;
31
+ config: WindowConfig;
32
+ state: WindowState;
33
+ meta: Record<string, any>;
34
+ private actor;
35
+ private isDisposed;
36
+ private subscribers;
37
+ constructor(options: {
38
+ id: string;
39
+ model: string;
40
+ applicationId?: string;
41
+ config: WindowConfig;
42
+ initialState?: Partial<WindowState>;
43
+ meta?: Record<string, any>;
44
+ workspace?: string;
45
+ });
46
+ private updateState;
47
+ getSnapshot(): WindowState;
48
+ subscribe(callback: (snapshot: WindowState) => void): () => void;
49
+ private notify;
50
+ get stateValue(): string;
51
+ setPosition(data: {
52
+ x: number;
53
+ y: number;
54
+ z?: number;
55
+ }): void;
56
+ setSize(data: {
57
+ width: number;
58
+ height: number;
59
+ }): void;
60
+ setFocus(value: boolean): void;
61
+ minimize(): boolean;
62
+ unminimize(): boolean;
63
+ maximize(): boolean;
64
+ unmaximize(): boolean;
65
+ toggleMaximize(): boolean;
66
+ startDrag(): void;
67
+ stopDrag(): void;
68
+ startResize(): void;
69
+ stopResize(): void;
70
+ setLayout(layout: WindowLayout, workarea?: DesktopWorkareaRect): boolean;
71
+ clearLayout(): boolean;
72
+ saveBoundsBeforeLayout(): void;
73
+ setWorkspace(workspaceId: string): void;
74
+ get workspace(): string;
75
+ setSpatialTransform(transform: SpatialTransform): void;
76
+ get spatial(): SpatialTransform | undefined;
77
+ dispose(): void;
78
+ }
79
+ declare class WindowManager {
80
+ private windows;
81
+ private snapshotCache;
82
+ private zIndexCounter;
83
+ private subscribers;
84
+ private hooks;
85
+ private ipc;
86
+ constructor(options?: {
87
+ hooks?: Hookable<DesktopRuntimeHooks>;
88
+ ipc?: CoreIPCBus;
89
+ });
90
+ getSnapshot(): WindowInstance[];
91
+ subscribe(callback: (windows: WindowInstance[]) => void): () => void;
92
+ private notify;
93
+ get(id: string): WindowInstance | undefined;
94
+ get focusedWindow(): WindowInstance | undefined;
95
+ incrementZIndex(): number;
96
+ addWindow(instance: WindowInstance): void;
97
+ createWindow(options: {
98
+ id: string;
99
+ model: string;
100
+ applicationId?: string;
101
+ config: WindowConfig;
102
+ initialState?: Partial<WindowState>;
103
+ meta?: Record<string, any>;
104
+ workspace?: string;
105
+ }): WindowInstance;
106
+ focusWindow(id: string): void;
107
+ closeWindow(id: string): boolean;
108
+ closeAllWindows(): void;
109
+ tileWindows(mode: "horizontal" | "vertical" | "grid" | undefined, workarea: DesktopWorkareaRect, workspaceId?: string, gap?: number): number;
110
+ setSpatialTransform(windowId: string, transform: SpatialTransform): void;
111
+ }
112
+
113
+ export { CoreIPCBus as C, WindowManager as W, WindowInstance as a, globalIPCBus as g };
114
+ export type { EventHandler as E };
@@ -0,0 +1,40 @@
1
+ function workareaBottom(workarea) {
2
+ return workarea.y + workarea.height;
3
+ }
4
+ function workareaRight(workarea) {
5
+ return workarea.x + workarea.width;
6
+ }
7
+ function computeSnapRect(zone, workarea) {
8
+ const { x, y, width, height } = workarea;
9
+ const halfW = Math.floor(width / 2);
10
+ const halfH = Math.floor(height / 2);
11
+ switch (zone) {
12
+ case "maximize":
13
+ return { x, y, width, height };
14
+ case "left-half":
15
+ return { x, y, width: halfW, height };
16
+ case "right-half":
17
+ return { x: x + halfW, y, width: width - halfW, height };
18
+ case "bottom-half":
19
+ return { x, y: y + halfH, width, height: height - halfH };
20
+ case "top-left":
21
+ return { x, y, width: halfW, height: halfH };
22
+ case "top-right":
23
+ return { x: x + halfW, y, width: width - halfW, height: halfH };
24
+ case "bottom-left":
25
+ return { x, y: y + halfH, width: halfW, height: height - halfH };
26
+ case "bottom-right":
27
+ return {
28
+ x: x + halfW,
29
+ y: y + halfH,
30
+ width: width - halfW,
31
+ height: height - halfH
32
+ };
33
+ default: {
34
+ const _exhaustive = zone;
35
+ return _exhaustive;
36
+ }
37
+ }
38
+ }
39
+
40
+ export { workareaRight as a, computeSnapRect as c, workareaBottom as w };