@stacksjs/desktop 0.2.5 → 0.2.8

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.
package/dist/alerts.d.ts CHANGED
@@ -27,19 +27,19 @@ export declare function showToast(options: ToastOptions): Promise<void>;
27
27
  /**
28
28
  * Show an info toast
29
29
  */
30
- export declare function showInfoToast(message: string, duration?: any): Promise<void>;
30
+ export declare function showInfoToast(message: string, duration?: number): Promise<void>;
31
31
  /**
32
32
  * Show a success toast
33
33
  */
34
- export declare function showSuccessToast(message: string, duration?: any): Promise<void>;
34
+ export declare function showSuccessToast(message: string, duration?: number): Promise<void>;
35
35
  /**
36
36
  * Show a warning toast
37
37
  */
38
- export declare function showWarningToast(message: string, duration?: any): Promise<void>;
38
+ export declare function showWarningToast(message: string, duration?: number): Promise<void>;
39
39
  /**
40
40
  * Show an error toast
41
41
  */
42
- export declare function showErrorToast(message: string, duration?: any): Promise<void>;
42
+ export declare function showErrorToast(message: string, duration?: number): Promise<void>;
43
43
  /**
44
44
  * Show a notification with title
45
45
  */
@@ -161,4 +161,4 @@ export declare const TOAST_STYLES: `
161
161
  .stx-toast.success { border-left: 4px solid #27ae60; }
162
162
  .stx-toast.warning { border-left: 4px solid #f39c12; }
163
163
  .stx-toast.error { border-left: 4px solid #e74c3c; }
164
- `;
164
+ `;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Enable or disable auto-launch on system login.
3
+ *
4
+ * On macOS, creates/removes a LaunchAgent plist.
5
+ * On Linux, creates/removes an XDG autostart .desktop file.
6
+ */
7
+ export declare function setAutoLaunch(enabled: boolean, options?: AutoLaunchOptions): Promise<void>;
8
+ /**
9
+ * Check if auto-launch is enabled for the given app.
10
+ */
11
+ export declare function isAutoLaunchEnabled(appName?: string): Promise<boolean>;
12
+ // ============================================================================
13
+ // Types
14
+ // ============================================================================
15
+ export declare interface AutoLaunchOptions {
16
+ appName?: string
17
+ appPath?: string
18
+ args?: string[]
19
+ isHidden?: boolean
20
+ }
@@ -500,19 +500,6 @@ export declare const COMPONENT_STYLES: `
500
500
  .stx-chip--error { background: #3a1a1a; }
501
501
  }
502
502
  `;
503
- /**
504
- * Native Components for Desktop Applications
505
- *
506
- * This module provides TypeScript wrappers for native UI components.
507
- * Components work in both browser (web-based) and desktop (native) environments.
508
- *
509
- * Categories:
510
- * - Input: Button, TextInput, Checkbox, RadioButton, Slider, ColorPicker, DatePicker, TimePicker, Autocomplete
511
- * - Display: Label, ImageView, ProgressBar, Avatar, Badge, Chip, Card, Tooltip, Toast
512
- * - Layout: ScrollView, SplitView, Accordion, Stepper, Modal, Tabs, Dropdown
513
- * - Data: ListView, Table, TreeView, DataGrid, Chart
514
- * - Advanced: Rating, CodeEditor, MediaPlayer, FileExplorer, WebView
515
- */
516
503
  /**
517
504
  * Button component properties
518
505
  */
@@ -939,4 +926,4 @@ export declare interface WebViewProps extends ComponentProps {
939
926
  onLoad?: () => void
940
927
  onError?: (error: Error) => void
941
928
  }
942
- export type ComponentName = typeof AVAILABLE_COMPONENTS[number]
929
+ export type ComponentName = typeof AVAILABLE_COMPONENTS[number];
package/dist/dialogs.d.ts CHANGED
@@ -123,16 +123,6 @@ export declare function showWarningDialog(message: string, title?: string): Prom
123
123
  * This provides convenient wrappers around the Craft dialog bridge.
124
124
  */
125
125
  export declare function getDialogBridgeScript(): string;
126
- /**
127
- * Native Dialog Integration
128
- *
129
- * Provides native file dialogs, message boxes, and other system dialogs
130
- * using Craft's Dialog Bridge APIs.
131
- *
132
- * When running inside a Craft native window, these dialogs use the native
133
- * OS dialogs (NSOpenPanel on macOS, etc.). When running in a browser,
134
- * they fall back to web alternatives where possible.
135
- */
136
126
  /**
137
127
  * Options for opening a file dialog
138
128
  */
@@ -210,4 +200,4 @@ export declare interface ColorPickerOptions {
210
200
  export declare interface ColorPickerResult {
211
201
  canceled: boolean
212
202
  color?: string
213
- }
203
+ }
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Parse a shortcut string into its component parts.
3
+ *
4
+ * Supports formats like:
5
+ * - 'Cmd+Shift+C'
6
+ * - 'Ctrl+Alt+Delete'
7
+ * - 'Meta+K'
8
+ * - 'CmdOrCtrl+S' (Cmd on macOS, Ctrl on others)
9
+ */
10
+ export declare function parseShortcut(shortcut: string): ParsedShortcut;
11
+ /**
12
+ * Format a parsed shortcut back into a display string.
13
+ */
14
+ export declare function formatShortcut(parsed: ParsedShortcut): string;
15
+ /**
16
+ * Register a global keyboard shortcut.
17
+ *
18
+ * When running in a Craft native window, this registers a system-wide hotkey
19
+ * that works even when the app is not focused. In web mode, it falls back to
20
+ * a document-level keydown listener.
21
+ *
22
+ * @param shortcut - The keyboard shortcut (e.g., 'Cmd+Shift+C', 'CmdOrCtrl+K')
23
+ * @param handler - Function to call when the shortcut is triggered
24
+ * @returns A registration object with an `unregister()` method
25
+ */
26
+ export declare function registerHotkey(shortcut: string, handler: () => void): HotkeyRegistration;
27
+ /**
28
+ * Unregister a specific hotkey.
29
+ */
30
+ export declare function unregisterHotkey(registration: HotkeyRegistration): void;
31
+ /**
32
+ * Unregister all registered hotkeys.
33
+ */
34
+ export declare function unregisterAllHotkeys(): void;
35
+ /**
36
+ * Get all currently registered hotkeys.
37
+ */
38
+ export declare function getRegisteredHotkeys(): HotkeyRegistration[];
39
+ /**
40
+ * Global Hotkey API
41
+ *
42
+ * Register global keyboard shortcuts that work even when the app is not focused.
43
+ * Communicates with Craft's native side to register system-wide hotkeys.
44
+ * Falls back to document-level listeners in web/non-native mode.
45
+ *
46
+ * @example
47
+ * ```typescript
48
+ * import { registerHotkey, unregisterAllHotkeys } from '@stacksjs/desktop'
49
+ *
50
+ * // Register a global shortcut
51
+ * const reg = registerHotkey('Cmd+Shift+C', () => {
52
+ * console.log('Hotkey triggered!')
53
+ * })
54
+ *
55
+ * // Unregister a specific shortcut
56
+ * reg.unregister()
57
+ *
58
+ * // Unregister all shortcuts
59
+ * unregisterAllHotkeys()
60
+ * ```
61
+ */
62
+ // ============================================================================
63
+ // Types
64
+ // ============================================================================
65
+ export declare interface HotkeyRegistration {
66
+ shortcut: string
67
+ id: string
68
+ unregister(): void
69
+ }
70
+ export declare interface ParsedShortcut {
71
+ key: string
72
+ meta: boolean
73
+ ctrl: boolean
74
+ shift: boolean
75
+ alt: boolean
76
+ }
package/dist/index.d.ts CHANGED
@@ -55,6 +55,9 @@ export type {
55
55
  SaveDialogOptions,
56
56
  SaveDialogResult,
57
57
  } from './dialogs';
58
+ // =============================================================================
59
+ // Core Types
60
+ // =============================================================================
58
61
  export type {
59
62
  AlertOptions,
60
63
  ComponentProps,
@@ -70,6 +73,46 @@ export type {
70
73
  WindowOptions,
71
74
  } from './types';
72
75
  export type { DesktopConfig } from './window';
76
+ export type {
77
+ CaffeinateInstance,
78
+ CaffeinateOptions,
79
+ CaffeinateStatus,
80
+ } from './power';
81
+ export type {
82
+ Preferences,
83
+ PreferencesOptions,
84
+ } from './preferences';
85
+ export type {
86
+ AutoLaunchOptions,
87
+ } from './autolaunch';
88
+ export type {
89
+ HotkeyRegistration,
90
+ ParsedShortcut,
91
+ } from './hotkeys';
92
+ export type {
93
+ Interval,
94
+ IntervalOptions,
95
+ Timer,
96
+ TimerOptions,
97
+ } from './timer';
98
+ /**
99
+ * @stacksjs/desktop
100
+ *
101
+ * Native desktop application framework for stx
102
+ *
103
+ * This package provides a TypeScript API for creating native desktop applications
104
+ * with the stx framework. Powered by Craft (~/Code/craft).
105
+ *
106
+ * ## Features
107
+ * - Window Management: Create and control native windows
108
+ * - System Tray: Build menubar applications
109
+ * - Modals & Alerts: Native dialogs and notifications
110
+ * - 35 UI Components: Complete component library
111
+ * - Hot Reload: Development mode support
112
+ */
113
+ // =============================================================================
114
+ // Alerts / Toast Notifications
115
+ // =============================================================================
73
116
  export {
74
117
  dismissAlertById,
75
118
  dismissAllAlerts,
@@ -84,6 +127,9 @@ export {
84
127
  showWarningToast,
85
128
  TOAST_STYLES,
86
129
  } from './alerts';
130
+ // =============================================================================
131
+ // Components (35 total)
132
+ // =============================================================================
87
133
  export {
88
134
  // Component list and styles
89
135
  AVAILABLE_COMPONENTS,
@@ -133,6 +179,9 @@ export {
133
179
  createTreeView,
134
180
  createWebView,
135
181
  } from './components';
182
+ // =============================================================================
183
+ // Modal Dialogs
184
+ // =============================================================================
136
185
  export {
137
186
  alert,
138
187
  closeAllModals,
@@ -147,6 +196,9 @@ export {
147
196
  showSuccessModal,
148
197
  showWarningModal,
149
198
  } from './modals';
199
+ // =============================================================================
200
+ // System Tray / Menubar
201
+ // =============================================================================
150
202
  export {
151
203
  createMenubar,
152
204
  createSystemTray,
@@ -157,6 +209,9 @@ export {
157
209
  TRAY_MENU_STYLES,
158
210
  triggerTrayAction,
159
211
  } from './system-tray';
212
+ // =============================================================================
213
+ // Native Dialogs
214
+ // =============================================================================
160
215
  export {
161
216
  getDialogBridgeScript,
162
217
  showAlertDialog,
@@ -168,6 +223,9 @@ export {
168
223
  showSaveDialog,
169
224
  showWarningDialog,
170
225
  } from './dialogs';
226
+ // =============================================================================
227
+ // Window Management
228
+ // =============================================================================
171
229
  export {
172
230
  closeAllWindows,
173
231
  createWindow,
@@ -180,4 +238,49 @@ export {
180
238
  openDevWindow,
181
239
  resetDesktopConfig,
182
240
  setDesktopConfig,
183
- } from './window';
241
+ } from './window';
242
+ // =============================================================================
243
+ // Power Management / Caffeinate
244
+ // =============================================================================
245
+ export {
246
+ caffeinate,
247
+ decaffeinate,
248
+ formatDuration,
249
+ formatRemainingTime,
250
+ getCaffeinateStatus,
251
+ isCaffeinated,
252
+ } from './power';
253
+ // =============================================================================
254
+ // Preferences / Settings Storage
255
+ // =============================================================================
256
+ export {
257
+ createPreferences,
258
+ } from './preferences';
259
+ // =============================================================================
260
+ // Auto-Launch / Login Items
261
+ // =============================================================================
262
+ export {
263
+ isAutoLaunchEnabled,
264
+ setAutoLaunch,
265
+ } from './autolaunch';
266
+ // =============================================================================
267
+ // Global Hotkeys
268
+ // =============================================================================
269
+ export {
270
+ formatShortcut,
271
+ getRegisteredHotkeys,
272
+ parseShortcut,
273
+ registerHotkey,
274
+ unregisterAllHotkeys,
275
+ unregisterHotkey,
276
+ } from './hotkeys';
277
+ // =============================================================================
278
+ // Timer / Scheduling
279
+ // =============================================================================
280
+ export {
281
+ createInterval,
282
+ createTimer,
283
+ delay,
284
+ formatCompact,
285
+ formatTime,
286
+ } from './timer';