defuss-desktop 0.0.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,234 @@
1
+ import * as defuss from 'defuss';
2
+ import { Props, CallChainImpl, Dequery, NodeType, Ref } from 'defuss';
3
+
4
+ declare function Desktop({ ref }: Props): any;
5
+
6
+ interface ButtonProps extends Props {
7
+ onClick?: () => void;
8
+ disabled?: boolean;
9
+ }
10
+ declare function Button({ onClick, disabled, children, ref, }: ButtonProps): any;
11
+
12
+ interface LogonScreenProps extends Props {
13
+ cDriveBasePath?: string;
14
+ showGuestUser?: boolean;
15
+ onTurnOffComputer?: () => void;
16
+ onGuestLogon?: () => void;
17
+ onUserLogonSubmit?: (userName: string, password: string) => Promise<boolean | string>;
18
+ }
19
+ type LoginForm = {
20
+ username: string;
21
+ password: string;
22
+ };
23
+ declare const LogonScreen: ({ cDriveBasePath, showGuestUser, onTurnOffComputer, onGuestLogon, onUserLogonSubmit, ref, }: LogonScreenProps) => any;
24
+
25
+ interface DefussAppConfig {
26
+ name: string;
27
+ icon: string;
28
+ main: (app: DefussApp, ...args: any[]) => void;
29
+ argv?: any[];
30
+ }
31
+ declare class DefussApp {
32
+ config: DefussAppConfig;
33
+ constructor(config: DefussAppConfig);
34
+ run(): void;
35
+ }
36
+
37
+ interface Dimensions2D {
38
+ width: number;
39
+ height: number;
40
+ }
41
+
42
+ interface DesktopIconConfig {
43
+ name: string;
44
+ icon: string;
45
+ app: DefussApp;
46
+ x?: number;
47
+ y?: number;
48
+ }
49
+ interface DesktopState {
50
+ icons: DesktopIconConfig[];
51
+ }
52
+ declare class DefussDesktopAppIcon {
53
+ config: DesktopIconConfig;
54
+ constructor(config: DesktopIconConfig);
55
+ }
56
+ type DesktopResizeCallback = (dimensions: Dimensions2D) => void;
57
+ interface CreateDesktopOptions {
58
+ icons: DefussDesktopAppIcon[];
59
+ iconSize?: "small" | "medium" | "large";
60
+ backgroundImage?: string;
61
+ backgroundImageSize?: "cover" | "contain";
62
+ backgroundRepeat?: "no-repeat" | "repeat" | "repeat-x" | "repeat-y";
63
+ backgroundPosition?: "center" | "top" | "bottom" | "left" | "right";
64
+ backgroundColor: string;
65
+ }
66
+ declare const defaultDesktopOptions: CreateDesktopOptions;
67
+ declare class DesktopManager {
68
+ options: CreateDesktopOptions;
69
+ el?: HTMLElement;
70
+ state?: DesktopState;
71
+ resizeObserver?: ResizeObserver;
72
+ resizeCallbacks: Set<DesktopResizeCallback>;
73
+ constructor(options?: CreateDesktopOptions);
74
+ init(el: HTMLElement, options?: CreateDesktopOptions): void;
75
+ render(el: HTMLElement): void;
76
+ addIcon(icon: DefussDesktopAppIcon): void;
77
+ getDimensions(): Dimensions2D;
78
+ private setupResizeObserver;
79
+ /**
80
+ * Register a callback for desktop resize events
81
+ * @param callback Function to call when desktop is resized
82
+ * @returns Unregister function to remove the callback
83
+ */
84
+ onResize(callback: DesktopResizeCallback): () => void;
85
+ }
86
+ declare const desktopManager: DesktopManager;
87
+
88
+ interface ShellProps extends Props {
89
+ desktopConfig: CreateDesktopOptions;
90
+ }
91
+ declare function Shell({ ref, desktopConfig, }: ShellProps): any;
92
+
93
+ declare const Taskbar: () => any;
94
+
95
+ declare const StartButton: () => any;
96
+
97
+ declare const StartMenu: () => any;
98
+
99
+ declare class DequeryWithWindowManager<NT> extends CallChainImpl<NT, DequeryWithWindowManager<NT> & Dequery<NT>> {
100
+ createDesktopApp(options: DefussAppConfig): PromiseLike<DefussApp>;
101
+ createDesktopAppIcon(options: DesktopIconConfig): PromiseLike<DefussDesktopAppIcon>;
102
+ }
103
+ /**
104
+ * Extended dequery function with window management capabilities.
105
+ *
106
+ * @param selector - CSS selector, element, or NodeList to query
107
+ * @param options - Optional dequery options
108
+ * @returns Extended dequery instance with createWindow and createTaskbar methods
109
+ */
110
+ declare const $: <NT = defuss.DequerySyncMethodReturnType>(selectorRefOrEl: string | NodeType | defuss.Ref<any, NodeType> | defuss.RenderInput | Function, options?: (defuss.DequeryOptions<NT> & JSX.HTMLAttributesLowerCase & {
111
+ html?: string;
112
+ text?: string;
113
+ }) | undefined) => DequeryWithWindowManager<unknown>;
114
+
115
+ interface WindowRefState {
116
+ onClose: () => void;
117
+ onMinimize: () => void;
118
+ onMaximize: () => void;
119
+ minimize: () => void;
120
+ maximize: () => void;
121
+ restore: () => void;
122
+ close: () => void;
123
+ }
124
+
125
+ interface CreateWindowOptions {
126
+ id?: string;
127
+ title?: string;
128
+ icon?: string;
129
+ width?: number;
130
+ height?: number;
131
+ x?: number;
132
+ y?: number;
133
+ minimizable?: boolean;
134
+ maximizable?: boolean;
135
+ minimized?: boolean;
136
+ maximized?: boolean;
137
+ onClose?: () => void;
138
+ onMinimize?: () => void;
139
+ onMaximize?: () => void;
140
+ resizable?: boolean;
141
+ }
142
+ interface WindowState {
143
+ id: string;
144
+ el: HTMLElement;
145
+ ref: Ref<WindowRefState>;
146
+ title: string;
147
+ icon: string;
148
+ width: number;
149
+ height: number;
150
+ prevX: number;
151
+ prevY: number;
152
+ prevWidth: number;
153
+ prevHeight: number;
154
+ originalDimensionsStored: boolean;
155
+ x: number;
156
+ y: number;
157
+ resizable: boolean;
158
+ draggable: boolean;
159
+ closeable: boolean;
160
+ minimizable: boolean;
161
+ maximizable: boolean;
162
+ minimized: boolean;
163
+ maximized: boolean;
164
+ }
165
+ declare const defaultWindowOptions: CreateWindowOptions;
166
+ declare class WindowManager {
167
+ windows: Array<WindowState>;
168
+ constructor();
169
+ onDesktopResized(dimensions: Dimensions2D): void;
170
+ getActiveWindow(): WindowState | undefined;
171
+ getWindow(id?: string): WindowState | undefined;
172
+ setActiveWindow(id: string): void;
173
+ renderWindowsActivationState(): void;
174
+ addWindow(options: CreateWindowOptions): WindowState;
175
+ updateWindow(id: string, options: Partial<WindowState>): WindowState | undefined;
176
+ closeWindow(id: string): void;
177
+ maximizeWindow(id: string): void;
178
+ minimizeWindow(id: string): void;
179
+ restoreWindow(id: string): void;
180
+ toggleTitleBarMaximizedButtonState(id: string): void;
181
+ }
182
+ declare const windowManager: WindowManager;
183
+
184
+ interface CreateTaskbarOptions {
185
+ position?: "top" | "bottom" | "left" | "right";
186
+ stateful?: boolean;
187
+ theme?: string;
188
+ size?: "small" | "medium" | "large";
189
+ }
190
+ interface TaskbarState {
191
+ position: "top" | "bottom" | "left" | "right";
192
+ theme: string;
193
+ size: "small" | "medium" | "large";
194
+ }
195
+ declare const defaultTaskbarOptions: CreateTaskbarOptions;
196
+ declare class TaskbarManager {
197
+ position: "top" | "bottom" | "left" | "right";
198
+ theme: string;
199
+ size: "small" | "medium" | "large";
200
+ constructor(options?: CreateTaskbarOptions);
201
+ getDimensions(): Dimensions2D;
202
+ }
203
+ declare const taskbarManager: TaskbarManager;
204
+
205
+ type DesktopShellTheme = "xp" | "98";
206
+ interface DesktopShellState {
207
+ taskbar: TaskbarState;
208
+ windows: Record<string, WindowState>;
209
+ }
210
+ declare class DesktopShellManager {
211
+ apps: DefussApp[];
212
+ constructor(apps?: DefussApp[]);
213
+ addApp(app: DefussApp): void;
214
+ }
215
+ declare const desktopShell: DesktopShellManager;
216
+
217
+ declare const defaultSystemSoundFilePaths: Array<string>;
218
+ declare class SoundManager {
219
+ private audioContext;
220
+ private audioCacheBuffers;
221
+ private activeSources;
222
+ init(): Promise<void>;
223
+ preload(url: Array<string> | string): Promise<AudioBuffer | AudioBuffer[]>;
224
+ play(bufferOrBufferUrl: AudioBuffer | string, options?: {
225
+ volume?: number;
226
+ loop?: boolean;
227
+ }): Promise<AudioBufferSourceNode>;
228
+ stopAllSounds(): void;
229
+ clearCache(): void;
230
+ }
231
+ declare const soundManager: SoundManager;
232
+
233
+ export { $, Button, DefussApp, DefussDesktopAppIcon, DequeryWithWindowManager, Desktop, DesktopManager, DesktopShellManager, LogonScreen, Shell, SoundManager, StartButton, StartMenu, Taskbar, TaskbarManager, WindowManager, defaultDesktopOptions, defaultSystemSoundFilePaths, defaultTaskbarOptions, defaultWindowOptions, desktopManager, desktopShell, soundManager, taskbarManager, windowManager };
234
+ export type { ButtonProps, CreateDesktopOptions, CreateTaskbarOptions, CreateWindowOptions, DefussAppConfig, DesktopIconConfig, DesktopResizeCallback, DesktopShellState, DesktopShellTheme, DesktopState, LoginForm, LogonScreenProps, ShellProps, TaskbarState, WindowState };
@@ -0,0 +1,234 @@
1
+ import * as defuss from 'defuss';
2
+ import { Props, CallChainImpl, Dequery, NodeType, Ref } from 'defuss';
3
+
4
+ declare function Desktop({ ref }: Props): any;
5
+
6
+ interface ButtonProps extends Props {
7
+ onClick?: () => void;
8
+ disabled?: boolean;
9
+ }
10
+ declare function Button({ onClick, disabled, children, ref, }: ButtonProps): any;
11
+
12
+ interface LogonScreenProps extends Props {
13
+ cDriveBasePath?: string;
14
+ showGuestUser?: boolean;
15
+ onTurnOffComputer?: () => void;
16
+ onGuestLogon?: () => void;
17
+ onUserLogonSubmit?: (userName: string, password: string) => Promise<boolean | string>;
18
+ }
19
+ type LoginForm = {
20
+ username: string;
21
+ password: string;
22
+ };
23
+ declare const LogonScreen: ({ cDriveBasePath, showGuestUser, onTurnOffComputer, onGuestLogon, onUserLogonSubmit, ref, }: LogonScreenProps) => any;
24
+
25
+ interface DefussAppConfig {
26
+ name: string;
27
+ icon: string;
28
+ main: (app: DefussApp, ...args: any[]) => void;
29
+ argv?: any[];
30
+ }
31
+ declare class DefussApp {
32
+ config: DefussAppConfig;
33
+ constructor(config: DefussAppConfig);
34
+ run(): void;
35
+ }
36
+
37
+ interface Dimensions2D {
38
+ width: number;
39
+ height: number;
40
+ }
41
+
42
+ interface DesktopIconConfig {
43
+ name: string;
44
+ icon: string;
45
+ app: DefussApp;
46
+ x?: number;
47
+ y?: number;
48
+ }
49
+ interface DesktopState {
50
+ icons: DesktopIconConfig[];
51
+ }
52
+ declare class DefussDesktopAppIcon {
53
+ config: DesktopIconConfig;
54
+ constructor(config: DesktopIconConfig);
55
+ }
56
+ type DesktopResizeCallback = (dimensions: Dimensions2D) => void;
57
+ interface CreateDesktopOptions {
58
+ icons: DefussDesktopAppIcon[];
59
+ iconSize?: "small" | "medium" | "large";
60
+ backgroundImage?: string;
61
+ backgroundImageSize?: "cover" | "contain";
62
+ backgroundRepeat?: "no-repeat" | "repeat" | "repeat-x" | "repeat-y";
63
+ backgroundPosition?: "center" | "top" | "bottom" | "left" | "right";
64
+ backgroundColor: string;
65
+ }
66
+ declare const defaultDesktopOptions: CreateDesktopOptions;
67
+ declare class DesktopManager {
68
+ options: CreateDesktopOptions;
69
+ el?: HTMLElement;
70
+ state?: DesktopState;
71
+ resizeObserver?: ResizeObserver;
72
+ resizeCallbacks: Set<DesktopResizeCallback>;
73
+ constructor(options?: CreateDesktopOptions);
74
+ init(el: HTMLElement, options?: CreateDesktopOptions): void;
75
+ render(el: HTMLElement): void;
76
+ addIcon(icon: DefussDesktopAppIcon): void;
77
+ getDimensions(): Dimensions2D;
78
+ private setupResizeObserver;
79
+ /**
80
+ * Register a callback for desktop resize events
81
+ * @param callback Function to call when desktop is resized
82
+ * @returns Unregister function to remove the callback
83
+ */
84
+ onResize(callback: DesktopResizeCallback): () => void;
85
+ }
86
+ declare const desktopManager: DesktopManager;
87
+
88
+ interface ShellProps extends Props {
89
+ desktopConfig: CreateDesktopOptions;
90
+ }
91
+ declare function Shell({ ref, desktopConfig, }: ShellProps): any;
92
+
93
+ declare const Taskbar: () => any;
94
+
95
+ declare const StartButton: () => any;
96
+
97
+ declare const StartMenu: () => any;
98
+
99
+ declare class DequeryWithWindowManager<NT> extends CallChainImpl<NT, DequeryWithWindowManager<NT> & Dequery<NT>> {
100
+ createDesktopApp(options: DefussAppConfig): PromiseLike<DefussApp>;
101
+ createDesktopAppIcon(options: DesktopIconConfig): PromiseLike<DefussDesktopAppIcon>;
102
+ }
103
+ /**
104
+ * Extended dequery function with window management capabilities.
105
+ *
106
+ * @param selector - CSS selector, element, or NodeList to query
107
+ * @param options - Optional dequery options
108
+ * @returns Extended dequery instance with createWindow and createTaskbar methods
109
+ */
110
+ declare const $: <NT = defuss.DequerySyncMethodReturnType>(selectorRefOrEl: string | NodeType | defuss.Ref<any, NodeType> | defuss.RenderInput | Function, options?: (defuss.DequeryOptions<NT> & JSX.HTMLAttributesLowerCase & {
111
+ html?: string;
112
+ text?: string;
113
+ }) | undefined) => DequeryWithWindowManager<unknown>;
114
+
115
+ interface WindowRefState {
116
+ onClose: () => void;
117
+ onMinimize: () => void;
118
+ onMaximize: () => void;
119
+ minimize: () => void;
120
+ maximize: () => void;
121
+ restore: () => void;
122
+ close: () => void;
123
+ }
124
+
125
+ interface CreateWindowOptions {
126
+ id?: string;
127
+ title?: string;
128
+ icon?: string;
129
+ width?: number;
130
+ height?: number;
131
+ x?: number;
132
+ y?: number;
133
+ minimizable?: boolean;
134
+ maximizable?: boolean;
135
+ minimized?: boolean;
136
+ maximized?: boolean;
137
+ onClose?: () => void;
138
+ onMinimize?: () => void;
139
+ onMaximize?: () => void;
140
+ resizable?: boolean;
141
+ }
142
+ interface WindowState {
143
+ id: string;
144
+ el: HTMLElement;
145
+ ref: Ref<WindowRefState>;
146
+ title: string;
147
+ icon: string;
148
+ width: number;
149
+ height: number;
150
+ prevX: number;
151
+ prevY: number;
152
+ prevWidth: number;
153
+ prevHeight: number;
154
+ originalDimensionsStored: boolean;
155
+ x: number;
156
+ y: number;
157
+ resizable: boolean;
158
+ draggable: boolean;
159
+ closeable: boolean;
160
+ minimizable: boolean;
161
+ maximizable: boolean;
162
+ minimized: boolean;
163
+ maximized: boolean;
164
+ }
165
+ declare const defaultWindowOptions: CreateWindowOptions;
166
+ declare class WindowManager {
167
+ windows: Array<WindowState>;
168
+ constructor();
169
+ onDesktopResized(dimensions: Dimensions2D): void;
170
+ getActiveWindow(): WindowState | undefined;
171
+ getWindow(id?: string): WindowState | undefined;
172
+ setActiveWindow(id: string): void;
173
+ renderWindowsActivationState(): void;
174
+ addWindow(options: CreateWindowOptions): WindowState;
175
+ updateWindow(id: string, options: Partial<WindowState>): WindowState | undefined;
176
+ closeWindow(id: string): void;
177
+ maximizeWindow(id: string): void;
178
+ minimizeWindow(id: string): void;
179
+ restoreWindow(id: string): void;
180
+ toggleTitleBarMaximizedButtonState(id: string): void;
181
+ }
182
+ declare const windowManager: WindowManager;
183
+
184
+ interface CreateTaskbarOptions {
185
+ position?: "top" | "bottom" | "left" | "right";
186
+ stateful?: boolean;
187
+ theme?: string;
188
+ size?: "small" | "medium" | "large";
189
+ }
190
+ interface TaskbarState {
191
+ position: "top" | "bottom" | "left" | "right";
192
+ theme: string;
193
+ size: "small" | "medium" | "large";
194
+ }
195
+ declare const defaultTaskbarOptions: CreateTaskbarOptions;
196
+ declare class TaskbarManager {
197
+ position: "top" | "bottom" | "left" | "right";
198
+ theme: string;
199
+ size: "small" | "medium" | "large";
200
+ constructor(options?: CreateTaskbarOptions);
201
+ getDimensions(): Dimensions2D;
202
+ }
203
+ declare const taskbarManager: TaskbarManager;
204
+
205
+ type DesktopShellTheme = "xp" | "98";
206
+ interface DesktopShellState {
207
+ taskbar: TaskbarState;
208
+ windows: Record<string, WindowState>;
209
+ }
210
+ declare class DesktopShellManager {
211
+ apps: DefussApp[];
212
+ constructor(apps?: DefussApp[]);
213
+ addApp(app: DefussApp): void;
214
+ }
215
+ declare const desktopShell: DesktopShellManager;
216
+
217
+ declare const defaultSystemSoundFilePaths: Array<string>;
218
+ declare class SoundManager {
219
+ private audioContext;
220
+ private audioCacheBuffers;
221
+ private activeSources;
222
+ init(): Promise<void>;
223
+ preload(url: Array<string> | string): Promise<AudioBuffer | AudioBuffer[]>;
224
+ play(bufferOrBufferUrl: AudioBuffer | string, options?: {
225
+ volume?: number;
226
+ loop?: boolean;
227
+ }): Promise<AudioBufferSourceNode>;
228
+ stopAllSounds(): void;
229
+ clearCache(): void;
230
+ }
231
+ declare const soundManager: SoundManager;
232
+
233
+ export { $, Button, DefussApp, DefussDesktopAppIcon, DequeryWithWindowManager, Desktop, DesktopManager, DesktopShellManager, LogonScreen, Shell, SoundManager, StartButton, StartMenu, Taskbar, TaskbarManager, WindowManager, defaultDesktopOptions, defaultSystemSoundFilePaths, defaultTaskbarOptions, defaultWindowOptions, desktopManager, desktopShell, soundManager, taskbarManager, windowManager };
234
+ export type { ButtonProps, CreateDesktopOptions, CreateTaskbarOptions, CreateWindowOptions, DefussAppConfig, DesktopIconConfig, DesktopResizeCallback, DesktopShellState, DesktopShellTheme, DesktopState, LoginForm, LogonScreenProps, ShellProps, TaskbarState, WindowState };