-
-
Notifications
You must be signed in to change notification settings - Fork 170
/
index.js
85 lines (68 loc) · 2.1 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import process from 'node:process';
import {
activeWindowSync as activeWindowSyncMacOS,
openWindowsSync as openWindowsSyncMacOS,
} from './lib/macos.js';
import {
activeWindowSync as activeWindowSyncLinux,
openWindowsSync as openWindowsSyncLinux,
} from './lib/linux.js';
import {
activeWindowSync as activeWindowSyncWindows,
openWindowsSync as openWindowsSyncWindows,
} from './lib/windows.js';
export async function activeWindow(options) {
if (process.platform === 'darwin') {
const {activeWindow} = await import('./lib/macos.js');
return activeWindow(options);
}
if (process.platform === 'linux') {
const {activeWindow} = await import('./lib/linux.js');
return activeWindow(options);
}
if (process.platform === 'win32') {
const {activeWindow} = await import('./lib/windows.js');
return activeWindow(options);
}
throw new Error('macOS, Linux, and Windows only');
}
export function activeWindowSync(options) {
if (process.platform === 'darwin') {
return activeWindowSyncMacOS(options);
}
if (process.platform === 'linux') {
return activeWindowSyncLinux(options);
}
if (process.platform === 'win32') {
return activeWindowSyncWindows(options);
}
throw new Error('macOS, Linux, and Windows only');
}
export async function openWindows(options) {
if (process.platform === 'darwin') {
const {openWindows} = await import('./lib/macos.js');
return openWindows(options);
}
if (process.platform === 'linux') {
const {openWindows} = await import('./lib/linux.js');
return openWindows(options);
}
if (process.platform === 'win32') {
const {openWindows} = await import('./lib/windows.js');
return openWindows(options);
}
throw new Error('macOS, Linux, and Windows only');
}
export function openWindowsSync(options) {
if (process.platform === 'darwin') {
return openWindowsSyncMacOS(options);
}
if (process.platform === 'linux') {
return openWindowsSyncLinux(options);
}
if (process.platform === 'win32') {
return openWindowsSyncWindows(options);
}
throw new Error('macOS, Linux, and Windows only');
}
// Note to self: The `main` field in package.json is requried for pre-gyp.