@aspiresys/visor 1.0.0

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/app.d.ts ADDED
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Opens a desktop application,
3
+ * executable, file, folder,
4
+ * or URL using Windows shell.
5
+ *
6
+ * Supports:
7
+ * - executable names
8
+ * - absolute paths
9
+ * - URLs
10
+ * - installed applications
11
+ *
12
+ * Uses direct spawn first for
13
+ * stability and performance.
14
+ *
15
+ * Falls back to Windows WHERE
16
+ * resolution if direct launch fails.
17
+ *
18
+ * @param target App name,
19
+ * executable, path, or URL.
20
+ *
21
+ * @example
22
+ * await openApp("notepad");
23
+ *
24
+ * @example
25
+ * await openApp("chrome.exe");
26
+ *
27
+ * @example
28
+ * await openApp(
29
+ * "C:\\Apps\\myapp.exe"
30
+ * );
31
+ */
32
+ export declare function openApp(target: string): Promise<void>;
33
+ /**
34
+ * Forcefully closes a desktop
35
+ * application using Windows taskkill.
36
+ *
37
+ * @param processName Executable name.
38
+ *
39
+ * @example
40
+ * await closeApp("notepad.exe");
41
+ *
42
+ * @example
43
+ * await closeApp("ms-teams.exe");
44
+ */
45
+ export declare function closeApp(processName: string): Promise<void>;
package/dist/app.js ADDED
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.openApp = openApp;
4
+ exports.closeApp = closeApp;
5
+ const child_process_1 = require("child_process");
6
+ const logger_1 = require("./logger");
7
+ function execAsync(command) {
8
+ return new Promise((resolve, reject) => {
9
+ (0, child_process_1.exec)(command, (error, stdout) => {
10
+ if (error) {
11
+ reject(error);
12
+ return;
13
+ }
14
+ resolve(stdout.trim());
15
+ });
16
+ });
17
+ }
18
+ /**
19
+ * Opens a desktop application,
20
+ * executable, file, folder,
21
+ * or URL using Windows shell.
22
+ *
23
+ * Supports:
24
+ * - executable names
25
+ * - absolute paths
26
+ * - URLs
27
+ * - installed applications
28
+ *
29
+ * Uses direct spawn first for
30
+ * stability and performance.
31
+ *
32
+ * Falls back to Windows WHERE
33
+ * resolution if direct launch fails.
34
+ *
35
+ * @param target App name,
36
+ * executable, path, or URL.
37
+ *
38
+ * @example
39
+ * await openApp("notepad");
40
+ *
41
+ * @example
42
+ * await openApp("chrome.exe");
43
+ *
44
+ * @example
45
+ * await openApp(
46
+ * "C:\\Apps\\myapp.exe"
47
+ * );
48
+ */
49
+ async function openApp(target) {
50
+ try {
51
+ (0, logger_1.log)(`[APP] Opening directly: ${target}`);
52
+ (0, child_process_1.exec)(`start "" "${target}"`);
53
+ await new Promise(r => setTimeout(r, 5000));
54
+ (0, logger_1.log)(`[APP] Opened directly: ${target}`);
55
+ return;
56
+ }
57
+ catch {
58
+ (0, logger_1.log)(`[APP] Direct launch failed`);
59
+ }
60
+ try {
61
+ (0, logger_1.log)(`[APP] Resolving using WHERE`);
62
+ const resolved = await execAsync(`where ${target}`);
63
+ if (!resolved) {
64
+ throw new Error(`App not found: ${target}`);
65
+ }
66
+ const firstPath = resolved
67
+ .split("\n")[0]
68
+ .trim();
69
+ (0, logger_1.log)(`[APP] Resolved path: ${firstPath}`);
70
+ (0, child_process_1.exec)(`start "" "${firstPath}"`);
71
+ await new Promise(r => setTimeout(r, 5000));
72
+ (0, logger_1.log)(`[APP] Launch successful`);
73
+ }
74
+ catch {
75
+ throw new Error(`Failed to open app: ${target}`);
76
+ }
77
+ }
78
+ /**
79
+ * Forcefully closes a desktop
80
+ * application using Windows taskkill.
81
+ *
82
+ * @param processName Executable name.
83
+ *
84
+ * @example
85
+ * await closeApp("notepad.exe");
86
+ *
87
+ * @example
88
+ * await closeApp("ms-teams.exe");
89
+ */
90
+ async function closeApp(processName) {
91
+ return new Promise((resolve, reject) => {
92
+ const command = `taskkill /IM "${processName}" /F`;
93
+ console.log(`[APP] Closing: ${processName}`);
94
+ (0, child_process_1.exec)(command, error => {
95
+ if (error) {
96
+ reject(error);
97
+ return;
98
+ }
99
+ resolve();
100
+ });
101
+ });
102
+ }
@@ -0,0 +1,5 @@
1
+ export declare const visorConfig: {
2
+ scaleFactor: number;
3
+ debug: boolean;
4
+ imagePath: string;
5
+ };
package/dist/config.js ADDED
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.visorConfig = void 0;
4
+ exports.visorConfig = {
5
+ scaleFactor: 1,
6
+ debug: true,
7
+ imagePath: ""
8
+ };