@stacksjs/desktop 0.2.6 → 0.2.9
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/autolaunch.d.ts +20 -0
- package/dist/hotkeys.d.ts +76 -0
- package/dist/index.d.ts +67 -0
- package/dist/index.js +877 -18
- package/dist/index.js.map +9 -4
- package/dist/power.d.ts +79 -0
- package/dist/preferences.d.ts +48 -0
- package/dist/timer.d.ts +128 -0
- package/package.json +1 -1
|
@@ -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
|
+
}
|
|
@@ -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
|
@@ -73,6 +73,28 @@ export type {
|
|
|
73
73
|
WindowOptions,
|
|
74
74
|
} from './types';
|
|
75
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';
|
|
76
98
|
/**
|
|
77
99
|
* @stacksjs/desktop
|
|
78
100
|
*
|
|
@@ -217,3 +239,48 @@ export {
|
|
|
217
239
|
resetDesktopConfig,
|
|
218
240
|
setDesktopConfig,
|
|
219
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';
|