mac-helper 0.3.0 → 0.4.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/lib/app.js +3 -3
- package/lib/chrome.js +2 -2
- package/lib/dialog.js +12 -6
- package/lib/finder.d.ts +0 -8
- package/lib/finder.js +37 -27
- package/lib/system-events.js +2 -6
- package/package.json +35 -37
- package/src/app.ts +2 -2
- package/src/chrome.ts +3 -3
- package/src/dialog.ts +13 -8
- package/src/finder.ts +40 -24
- package/src/iterm.ts +1 -1
- package/src/system-events.ts +2 -6
package/lib/app.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isAppRunning = isAppRunning;
|
|
4
|
-
const
|
|
4
|
+
const node_child_process_1 = require("node:child_process");
|
|
5
5
|
/**
|
|
6
6
|
* file path based process running detect.
|
|
7
7
|
* for vscode, process name = `Code`, file is `Visual Studio Code.app`, the `Visual Studio Code` should be passed
|
|
8
8
|
*/
|
|
9
|
-
|
|
9
|
+
function isAppRunning(appName) {
|
|
10
10
|
return new Promise((resolve, reject) => {
|
|
11
|
-
(0,
|
|
11
|
+
(0, node_child_process_1.exec)(`ps -ax -o command`, (err, stdout, stderr) => {
|
|
12
12
|
if (err)
|
|
13
13
|
return reject(err);
|
|
14
14
|
const lines = stdout
|
package/lib/chrome.js
CHANGED
|
@@ -12,8 +12,8 @@ async function getChromeActiveTab() {
|
|
|
12
12
|
return await (0, run_1.run)(() => {
|
|
13
13
|
const app = Application('Google Chrome');
|
|
14
14
|
app.includeStandardAdditions = true;
|
|
15
|
-
const
|
|
16
|
-
const tab =
|
|
15
|
+
const win = (app.windows() || []).find((w) => !w.minimized());
|
|
16
|
+
const tab = win?.activeTab();
|
|
17
17
|
return {
|
|
18
18
|
url: tab?.url(),
|
|
19
19
|
title: tab?.title(),
|
package/lib/dialog.js
CHANGED
|
@@ -8,12 +8,18 @@ exports.dialog = {
|
|
|
8
8
|
chooseMultipleFromList,
|
|
9
9
|
};
|
|
10
10
|
async function prompt(label, defaultValue = '') {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
// if cancel dialog, will throw error
|
|
12
|
+
try {
|
|
13
|
+
return ((await (0, run_1.run)((label) => {
|
|
14
|
+
const app = Application.currentApplication();
|
|
15
|
+
app.includeStandardAdditions = true;
|
|
16
|
+
const response = app.displayDialog(label, { defaultAnswer: '' });
|
|
17
|
+
return response.textReturned;
|
|
18
|
+
}, label)) || defaultValue);
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return defaultValue;
|
|
22
|
+
}
|
|
17
23
|
}
|
|
18
24
|
async function runOnCurrentApp(method, ...args) {
|
|
19
25
|
return await (0, run_1.run)((method, ...args) => {
|
package/lib/finder.d.ts
CHANGED
|
@@ -15,16 +15,8 @@ export declare const QSpace: {
|
|
|
15
15
|
allSelected(): Promise<string[]>;
|
|
16
16
|
singleSelected(): Promise<string | undefined>;
|
|
17
17
|
};
|
|
18
|
-
/**
|
|
19
|
-
* impls
|
|
20
|
-
*/
|
|
21
|
-
export declare function getPathFinderSelected(): Promise<string[]>;
|
|
22
|
-
export declare function setPathFinderSelected(filePaths: string[]): Promise<void>;
|
|
23
|
-
export declare function getFinderSelected(): Promise<string[]>;
|
|
24
|
-
export declare function setFinderSelected(filePaths: string[]): Promise<void>;
|
|
25
18
|
export type QSpaceFileItem = {
|
|
26
19
|
id: () => string;
|
|
27
20
|
name: () => string;
|
|
28
21
|
urlstr: () => string;
|
|
29
22
|
};
|
|
30
|
-
export declare function getQSpaceSelected(): Promise<string[]>;
|
package/lib/finder.js
CHANGED
|
@@ -1,51 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.QSpace = exports.Finder = exports.PathFinder = void 0;
|
|
4
|
-
|
|
5
|
-
exports.setPathFinderSelected = setPathFinderSelected;
|
|
6
|
-
exports.getFinderSelected = getFinderSelected;
|
|
7
|
-
exports.setFinderSelected = setFinderSelected;
|
|
8
|
-
exports.getQSpaceSelected = getQSpaceSelected;
|
|
4
|
+
const node_url_1 = require("node:url");
|
|
9
5
|
const run_1 = require("@jxa/run");
|
|
10
|
-
const url_1 = require("url");
|
|
11
6
|
const app_1 = require("./app");
|
|
12
7
|
/**
|
|
13
8
|
* `App` named epxorts
|
|
14
9
|
*/
|
|
15
10
|
exports.PathFinder = {
|
|
16
|
-
|
|
17
|
-
return
|
|
11
|
+
allSelected() {
|
|
12
|
+
return PathFinder_allSelected();
|
|
18
13
|
},
|
|
19
|
-
|
|
20
|
-
return (
|
|
14
|
+
singleSelected() {
|
|
15
|
+
return PathFinder_singleSelected();
|
|
21
16
|
},
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
setSelected(filePaths) {
|
|
18
|
+
return PathFinder_setSelected(filePaths);
|
|
24
19
|
},
|
|
25
20
|
};
|
|
26
21
|
exports.Finder = {
|
|
27
|
-
|
|
28
|
-
return
|
|
22
|
+
allSelected() {
|
|
23
|
+
return Finder_allSelected();
|
|
29
24
|
},
|
|
30
25
|
async singleSelected() {
|
|
31
|
-
return (await
|
|
26
|
+
return (await Finder_allSelected())[0];
|
|
32
27
|
},
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
setSelected(filePaths) {
|
|
29
|
+
return Finder_setSelected(filePaths);
|
|
35
30
|
},
|
|
36
31
|
};
|
|
37
32
|
exports.QSpace = {
|
|
38
|
-
|
|
39
|
-
return
|
|
33
|
+
allSelected() {
|
|
34
|
+
return QSpace_allSelected();
|
|
40
35
|
},
|
|
41
36
|
async singleSelected() {
|
|
42
|
-
return (await
|
|
37
|
+
return (await QSpace_allSelected())[0];
|
|
43
38
|
},
|
|
44
39
|
};
|
|
45
40
|
/**
|
|
46
41
|
* impls
|
|
47
42
|
*/
|
|
48
|
-
|
|
43
|
+
/* #region PathFinder */
|
|
44
|
+
async function PathFinder_allSelected() {
|
|
49
45
|
if (!(await (0, app_1.isAppRunning)('Path Finder'))) {
|
|
50
46
|
return [];
|
|
51
47
|
}
|
|
@@ -55,28 +51,41 @@ async function getPathFinderSelected() {
|
|
|
55
51
|
});
|
|
56
52
|
return filePaths;
|
|
57
53
|
}
|
|
58
|
-
async function
|
|
54
|
+
async function PathFinder_singleSelected() {
|
|
55
|
+
if (!(await (0, app_1.isAppRunning)('Path Finder'))) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const firstFilePath = await (0, run_1.run)(() => {
|
|
59
|
+
const app = Application('Path Finder');
|
|
60
|
+
const arr = (app.selection() || []).map((x) => x.posixPath());
|
|
61
|
+
return arr[0];
|
|
62
|
+
});
|
|
63
|
+
return firstFilePath;
|
|
64
|
+
}
|
|
65
|
+
async function PathFinder_setSelected(filePaths) {
|
|
59
66
|
await (0, run_1.run)((filePaths) => {
|
|
60
67
|
const app = Application('Path Finder');
|
|
61
68
|
app.select(filePaths);
|
|
62
69
|
}, filePaths);
|
|
63
70
|
}
|
|
64
|
-
|
|
71
|
+
/* #endregion */
|
|
72
|
+
/* #region Finder */
|
|
73
|
+
async function Finder_allSelected() {
|
|
65
74
|
const urls = await (0, run_1.run)(() => {
|
|
66
75
|
const app = Application('Finder');
|
|
67
76
|
const selection = app.selection();
|
|
68
77
|
return (selection || []).map((x) => x.url());
|
|
69
78
|
});
|
|
70
|
-
return urls.map((u) => (0,
|
|
79
|
+
return urls.map((u) => (0, node_url_1.fileURLToPath)(u));
|
|
71
80
|
}
|
|
72
|
-
async function
|
|
81
|
+
async function Finder_setSelected(filePaths) {
|
|
73
82
|
await (0, run_1.run)((filePaths) => {
|
|
74
83
|
const app = Application('Finder');
|
|
75
84
|
app.select(filePaths.map((f) => Path(f)));
|
|
76
85
|
app.activate();
|
|
77
86
|
}, filePaths);
|
|
78
87
|
}
|
|
79
|
-
async function
|
|
88
|
+
async function QSpace_allSelected() {
|
|
80
89
|
if (!(await (0, app_1.isAppRunning)('QSpace Pro'))) {
|
|
81
90
|
return [];
|
|
82
91
|
}
|
|
@@ -85,8 +94,9 @@ async function getQSpaceSelected() {
|
|
|
85
94
|
const selection = (app.selectedItems() || []).map((x) => x.urlstr());
|
|
86
95
|
return selection;
|
|
87
96
|
});
|
|
88
|
-
return urls.map((u) => (0,
|
|
97
|
+
return urls.map((u) => (0, node_url_1.fileURLToPath)(u));
|
|
89
98
|
}
|
|
99
|
+
/* #endregion */
|
|
90
100
|
// ;(async () => {
|
|
91
101
|
// console.log(await getQSpaceSelected())
|
|
92
102
|
// })()
|
package/lib/system-events.js
CHANGED
|
@@ -8,9 +8,7 @@ async function isAppRunning(appName) {
|
|
|
8
8
|
return await (0, run_1.run)((appName) => {
|
|
9
9
|
const app = Application('System Events');
|
|
10
10
|
app.includeStandardAdditions = true;
|
|
11
|
-
const runningAppNames = app
|
|
12
|
-
.processes()
|
|
13
|
-
.map((p) => p.name());
|
|
11
|
+
const runningAppNames = app.processes().map((p) => p.name());
|
|
14
12
|
return runningAppNames.includes(appName);
|
|
15
13
|
}, appName);
|
|
16
14
|
}
|
|
@@ -18,9 +16,7 @@ async function getRunningAppNames() {
|
|
|
18
16
|
return await (0, run_1.run)(() => {
|
|
19
17
|
const app = Application('System Events');
|
|
20
18
|
app.includeStandardAdditions = true;
|
|
21
|
-
const runningAppNames = app
|
|
22
|
-
.processes()
|
|
23
|
-
.map((p) => p.name());
|
|
19
|
+
const runningAppNames = app.processes().map((p) => p.name());
|
|
24
20
|
return runningAppNames;
|
|
25
21
|
});
|
|
26
22
|
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mac-helper",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"packageManager": "pnpm@10.12.1+sha512.f0dda8580f0ee9481c5c79a1d927b9164f2c478e90992ad268bbb2465a736984391d6333d2c327913578b2804af33474ca554ba29c04a8b13060a717675ae3ac",
|
|
4
5
|
"description": "useful helper for macOS",
|
|
5
|
-
"
|
|
6
|
-
|
|
6
|
+
"keywords": [
|
|
7
|
+
"mac",
|
|
8
|
+
"helper",
|
|
9
|
+
"mac-helper"
|
|
10
|
+
],
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"homepage": "https://github.com/magicdawn/mac-helper#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/magicdawn/mac-helper/issues"
|
|
15
|
+
},
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+ssh://git@github.com/magicdawn/mac-helper.git"
|
|
19
|
+
},
|
|
20
|
+
"author": "magicdawn",
|
|
7
21
|
"files": [
|
|
8
22
|
"lib/",
|
|
9
23
|
"src/"
|
|
10
24
|
],
|
|
25
|
+
"main": "lib/index.js",
|
|
26
|
+
"types": "lib/index.d.ts",
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"registry": "https://registry.npmjs.org"
|
|
29
|
+
},
|
|
11
30
|
"scripts": {
|
|
12
31
|
"prepare": "husky",
|
|
13
32
|
"test": "vitest run --globals --testTimeout=30000",
|
|
@@ -18,21 +37,6 @@
|
|
|
18
37
|
"build": "rm -rf lib; rm tsconfig.tsbuildinfo; tsc",
|
|
19
38
|
"prepublishOnly": "pnpm test && pnpm build"
|
|
20
39
|
},
|
|
21
|
-
"repository": {
|
|
22
|
-
"type": "git",
|
|
23
|
-
"url": "git+ssh://git@github.com/magicdawn/mac-helper.git"
|
|
24
|
-
},
|
|
25
|
-
"keywords": [
|
|
26
|
-
"mac",
|
|
27
|
-
"helper",
|
|
28
|
-
"mac-helper"
|
|
29
|
-
],
|
|
30
|
-
"author": "magicdawn",
|
|
31
|
-
"license": "MIT",
|
|
32
|
-
"bugs": {
|
|
33
|
-
"url": "https://github.com/magicdawn/mac-helper/issues"
|
|
34
|
-
},
|
|
35
|
-
"homepage": "https://github.com/magicdawn/mac-helper#readme",
|
|
36
40
|
"dependencies": {
|
|
37
41
|
"@jxa/run": "^1.4.0"
|
|
38
42
|
},
|
|
@@ -40,41 +44,35 @@
|
|
|
40
44
|
"@jxa/global-type": "^1.4.0",
|
|
41
45
|
"@jxa/sdef-to-dts": "^1.4.0",
|
|
42
46
|
"@jxa/types": "^1.4.0",
|
|
47
|
+
"@magicdawn/eslint-config": "^1.5.4",
|
|
43
48
|
"@magicdawn/prettier-config": "^0.1.0",
|
|
44
|
-
"@swc/core": "1.11.24",
|
|
45
49
|
"@types/fs-extra": "^11.0.4",
|
|
46
|
-
"@types/
|
|
47
|
-
"@
|
|
48
|
-
"@typescript-eslint/eslint-plugin": "^8.32.0",
|
|
49
|
-
"@typescript-eslint/parser": "^8.32.0",
|
|
50
|
-
"@vitest/coverage-v8": "^3.1.3",
|
|
50
|
+
"@types/node": "^24.0.1",
|
|
51
|
+
"@vitest/coverage-v8": "^3.2.3",
|
|
51
52
|
"delay": "^6.0.0",
|
|
52
|
-
"eslint": "^9.
|
|
53
|
+
"eslint": "^9.28.0",
|
|
53
54
|
"eslint-config-prettier": "^10.1.5",
|
|
54
55
|
"fs-extra": "^11.3.0",
|
|
55
56
|
"husky": "^9.1.7",
|
|
56
57
|
"jxa-common-used": "^0.0.3",
|
|
57
|
-
"lint-staged": "^16.
|
|
58
|
+
"lint-staged": "^16.1.0",
|
|
58
59
|
"prettier": "^3.5.3",
|
|
59
60
|
"should": "^13.2.3",
|
|
60
61
|
"typescript": "^5.8.3",
|
|
61
|
-
"vitest": "^3.
|
|
62
|
+
"vitest": "^3.2.3"
|
|
62
63
|
},
|
|
63
|
-
"publishConfig": {
|
|
64
|
-
"registry": "https://registry.npmjs.org"
|
|
65
|
-
},
|
|
66
|
-
"lint-staged": {
|
|
67
|
-
"*.{js,jsx,ts,tsx,less,md}": [
|
|
68
|
-
"prettier --write"
|
|
69
|
-
]
|
|
70
|
-
},
|
|
71
|
-
"packageManager": "pnpm@10.10.0+sha512.d615db246fe70f25dcfea6d8d73dee782ce23e2245e3c4f6f888249fb568149318637dca73c2c5c8ef2a4ca0d5657fb9567188bfab47f566d1ee6ce987815c39",
|
|
72
64
|
"pnpm": {
|
|
73
65
|
"onlyBuiltDependencies": [
|
|
74
66
|
"@swc/core",
|
|
75
67
|
"core-js",
|
|
76
68
|
"es5-ext",
|
|
77
|
-
"esbuild"
|
|
69
|
+
"esbuild",
|
|
70
|
+
"unrs-resolver"
|
|
71
|
+
]
|
|
72
|
+
},
|
|
73
|
+
"lint-staged": {
|
|
74
|
+
"*.{js,jsx,ts,tsx,less,md}": [
|
|
75
|
+
"prettier --write"
|
|
78
76
|
]
|
|
79
77
|
}
|
|
80
78
|
}
|
package/src/app.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { exec } from 'child_process'
|
|
1
|
+
import { exec } from 'node:child_process'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* file path based process running detect.
|
|
5
5
|
* for vscode, process name = `Code`, file is `Visual Studio Code.app`, the `Visual Studio Code` should be passed
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
export
|
|
8
|
+
export function isAppRunning(appName: string): Promise<boolean> {
|
|
9
9
|
return new Promise((resolve, reject) => {
|
|
10
10
|
exec(`ps -ax -o command`, (err, stdout, stderr) => {
|
|
11
11
|
if (err) return reject(err)
|
package/src/chrome.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { run } from '@jxa/run'
|
|
2
|
-
import {
|
|
2
|
+
import type { GoogleChrome } from 'jxa-common-used'
|
|
3
3
|
|
|
4
4
|
export type ActiveTab = { url: string; title: string }
|
|
5
5
|
|
|
@@ -14,8 +14,8 @@ export async function getChromeActiveTab(): Promise<ActiveTab> {
|
|
|
14
14
|
const app = Application<GoogleChrome>('Google Chrome')
|
|
15
15
|
app.includeStandardAdditions = true
|
|
16
16
|
|
|
17
|
-
const
|
|
18
|
-
const tab =
|
|
17
|
+
const win = (app.windows() || []).find((w) => !w.minimized())
|
|
18
|
+
const tab = win?.activeTab()
|
|
19
19
|
return {
|
|
20
20
|
url: tab?.url(),
|
|
21
21
|
title: tab?.title(),
|
package/src/dialog.ts
CHANGED
|
@@ -8,14 +8,19 @@ export const dialog = {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
async function prompt(label: string, defaultValue = ''): Promise<string> {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
// if cancel dialog, will throw error
|
|
12
|
+
try {
|
|
13
|
+
return (
|
|
14
|
+
(await run((label) => {
|
|
15
|
+
const app = Application.currentApplication()
|
|
16
|
+
app.includeStandardAdditions = true
|
|
17
|
+
const response = app.displayDialog(label, { defaultAnswer: '' })
|
|
18
|
+
return response.textReturned
|
|
19
|
+
}, label)) || defaultValue
|
|
20
|
+
)
|
|
21
|
+
} catch {
|
|
22
|
+
return defaultValue
|
|
23
|
+
}
|
|
19
24
|
}
|
|
20
25
|
|
|
21
26
|
type AppMethod = 'chooseFromList'
|
package/src/finder.ts
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url'
|
|
1
2
|
import { run as jxaRun } from '@jxa/run'
|
|
2
|
-
import { type PathFinder as PathFinderType } from 'jxa-common-used'
|
|
3
|
-
import { fileURLToPath } from 'url'
|
|
4
3
|
import { isAppRunning } from './app'
|
|
4
|
+
import type { PathFinder as PathFinderType } from 'jxa-common-used'
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* `App` named epxorts
|
|
8
8
|
*/
|
|
9
9
|
export const PathFinder = {
|
|
10
|
-
|
|
11
|
-
return
|
|
10
|
+
allSelected() {
|
|
11
|
+
return PathFinder_allSelected()
|
|
12
12
|
},
|
|
13
|
-
|
|
14
|
-
return (
|
|
13
|
+
singleSelected() {
|
|
14
|
+
return PathFinder_singleSelected()
|
|
15
15
|
},
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
setSelected(filePaths: string[]) {
|
|
17
|
+
return PathFinder_setSelected(filePaths)
|
|
18
18
|
},
|
|
19
19
|
}
|
|
20
20
|
export const Finder = {
|
|
21
|
-
|
|
22
|
-
return
|
|
21
|
+
allSelected() {
|
|
22
|
+
return Finder_allSelected()
|
|
23
23
|
},
|
|
24
24
|
async singleSelected(): Promise<string | undefined> {
|
|
25
|
-
return (await
|
|
25
|
+
return (await Finder_allSelected())[0]
|
|
26
26
|
},
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
setSelected(filePaths: string[]) {
|
|
28
|
+
return Finder_setSelected(filePaths)
|
|
29
29
|
},
|
|
30
30
|
}
|
|
31
31
|
export const QSpace = {
|
|
32
|
-
|
|
33
|
-
return
|
|
32
|
+
allSelected() {
|
|
33
|
+
return QSpace_allSelected()
|
|
34
34
|
},
|
|
35
35
|
async singleSelected(): Promise<string | undefined> {
|
|
36
|
-
return (await
|
|
36
|
+
return (await QSpace_allSelected())[0]
|
|
37
37
|
},
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
41
|
* impls
|
|
42
42
|
*/
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
/* #region PathFinder */
|
|
44
|
+
async function PathFinder_allSelected() {
|
|
45
45
|
if (!(await isAppRunning('Path Finder'))) {
|
|
46
46
|
return []
|
|
47
47
|
}
|
|
@@ -52,14 +52,28 @@ export async function getPathFinderSelected() {
|
|
|
52
52
|
return filePaths
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
async function PathFinder_singleSelected(): Promise<string | undefined> {
|
|
56
|
+
if (!(await isAppRunning('Path Finder'))) {
|
|
57
|
+
return
|
|
58
|
+
}
|
|
59
|
+
const firstFilePath: string | undefined = await jxaRun(() => {
|
|
60
|
+
const app = Application<PathFinderType>('Path Finder')
|
|
61
|
+
const arr = (app.selection() || []).map((x) => x.posixPath())
|
|
62
|
+
return arr[0]
|
|
63
|
+
})
|
|
64
|
+
return firstFilePath
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async function PathFinder_setSelected(filePaths: string[]) {
|
|
56
68
|
await jxaRun((filePaths: string[]) => {
|
|
57
69
|
const app = Application<PathFinderType>('Path Finder')
|
|
58
70
|
app.select(filePaths)
|
|
59
71
|
}, filePaths)
|
|
60
72
|
}
|
|
73
|
+
/* #endregion */
|
|
61
74
|
|
|
62
|
-
|
|
75
|
+
/* #region Finder */
|
|
76
|
+
async function Finder_allSelected() {
|
|
63
77
|
const urls: string[] = await jxaRun(() => {
|
|
64
78
|
const app = Application('Finder')
|
|
65
79
|
const selection = app.selection()
|
|
@@ -67,16 +81,17 @@ export async function getFinderSelected() {
|
|
|
67
81
|
})
|
|
68
82
|
return urls.map((u) => fileURLToPath(u))
|
|
69
83
|
}
|
|
70
|
-
|
|
71
|
-
export async function setFinderSelected(filePaths: string[]) {
|
|
84
|
+
async function Finder_setSelected(filePaths: string[]) {
|
|
72
85
|
await jxaRun((filePaths: string[]) => {
|
|
73
86
|
const app = Application('Finder')
|
|
74
87
|
app.select(filePaths.map((f) => Path(f)))
|
|
75
88
|
app.activate()
|
|
76
89
|
}, filePaths)
|
|
77
90
|
}
|
|
91
|
+
/* #endregion */
|
|
78
92
|
|
|
79
|
-
|
|
93
|
+
/* #region QSpace */
|
|
94
|
+
// file item n [inh. item] : A file item.
|
|
80
95
|
// properties
|
|
81
96
|
// - id (text, r/o) : The unique identifier of the item.
|
|
82
97
|
// - name (text, r/o) : The name of the file.
|
|
@@ -90,7 +105,7 @@ export type QSpaceFileItem = {
|
|
|
90
105
|
urlstr: () => string
|
|
91
106
|
}
|
|
92
107
|
|
|
93
|
-
|
|
108
|
+
async function QSpace_allSelected() {
|
|
94
109
|
if (!(await isAppRunning('QSpace Pro'))) {
|
|
95
110
|
return []
|
|
96
111
|
}
|
|
@@ -101,6 +116,7 @@ export async function getQSpaceSelected() {
|
|
|
101
116
|
})
|
|
102
117
|
return urls.map((u) => fileURLToPath(u))
|
|
103
118
|
}
|
|
119
|
+
/* #endregion */
|
|
104
120
|
|
|
105
121
|
// ;(async () => {
|
|
106
122
|
// console.log(await getQSpaceSelected())
|
package/src/iterm.ts
CHANGED
package/src/system-events.ts
CHANGED
|
@@ -9,9 +9,7 @@ async function isAppRunning(appName: string): Promise<boolean> {
|
|
|
9
9
|
return await run((appName) => {
|
|
10
10
|
const app = Application<SystemEvents.SystemEvents.Application>('System Events')
|
|
11
11
|
app.includeStandardAdditions = true
|
|
12
|
-
const runningAppNames: string[] = app
|
|
13
|
-
.processes()
|
|
14
|
-
.map((p: SystemEvents.SystemEvents.Process) => p.name())
|
|
12
|
+
const runningAppNames: string[] = app.processes().map((p: SystemEvents.SystemEvents.Process) => p.name())
|
|
15
13
|
return runningAppNames.includes(appName)
|
|
16
14
|
}, appName)
|
|
17
15
|
}
|
|
@@ -20,9 +18,7 @@ async function getRunningAppNames(): Promise<string[]> {
|
|
|
20
18
|
return await run(() => {
|
|
21
19
|
const app = Application<SystemEvents.SystemEvents.Application>('System Events')
|
|
22
20
|
app.includeStandardAdditions = true
|
|
23
|
-
const runningAppNames: string[] = app
|
|
24
|
-
.processes()
|
|
25
|
-
.map((p: SystemEvents.SystemEvents.Process) => p.name())
|
|
21
|
+
const runningAppNames: string[] = app.processes().map((p: SystemEvents.SystemEvents.Process) => p.name())
|
|
26
22
|
return runningAppNames
|
|
27
23
|
})
|
|
28
24
|
}
|