mac-helper 0.1.2 → 0.1.3
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/README.md +5 -4
- package/lib/finder.d.ts +18 -2
- package/lib/finder.js +41 -18
- package/package.json +18 -19
- package/src/finder.ts +52 -15
package/README.md
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
> useful helper for macOS
|
|
4
4
|
|
|
5
|
-
[](https://github.com/magicdawn/mac-helper/actions/workflows/ci.yml)
|
|
6
|
-
[](https://codecov.io/gh/magicdawn/mac-helper)
|
|
5
|
+
<!-- [](https://github.com/magicdawn/mac-helper/actions/workflows/ci.yml)
|
|
6
|
+
[](https://codecov.io/gh/magicdawn/mac-helper) -->
|
|
7
|
+
|
|
7
8
|
[](https://www.npmjs.com/package/mac-helper)
|
|
8
9
|
[](https://www.npmjs.com/package/mac-helper)
|
|
9
10
|
[](http://magicdawn.mit-license.org)
|
|
@@ -16,8 +17,8 @@ $ pnpm add mac-helper
|
|
|
16
17
|
|
|
17
18
|
## API
|
|
18
19
|
|
|
19
|
-
```
|
|
20
|
-
|
|
20
|
+
```ts
|
|
21
|
+
import * as MacHelper from 'mac-helper'
|
|
21
22
|
```
|
|
22
23
|
|
|
23
24
|
## Changelog
|
package/lib/finder.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* `App` named epxorts
|
|
3
|
+
*/
|
|
3
4
|
export declare const PathFinder: {
|
|
4
5
|
allSelected(): Promise<string[]>;
|
|
5
6
|
singleSelected(): Promise<string | undefined>;
|
|
@@ -8,3 +9,18 @@ export declare const Finder: {
|
|
|
8
9
|
allSelected(): Promise<string[]>;
|
|
9
10
|
singleSelected(): Promise<string | undefined>;
|
|
10
11
|
};
|
|
12
|
+
export declare const QSpace: {
|
|
13
|
+
allSelected(): Promise<string[]>;
|
|
14
|
+
singleSelected(): Promise<string | undefined>;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* impls
|
|
18
|
+
*/
|
|
19
|
+
export declare function getPathFinderSelected(): Promise<string[]>;
|
|
20
|
+
export declare function getFinderSelected(): Promise<string[]>;
|
|
21
|
+
export type QSpaceFileItem = {
|
|
22
|
+
id: () => string;
|
|
23
|
+
name: () => string;
|
|
24
|
+
urlstr: () => string;
|
|
25
|
+
};
|
|
26
|
+
export declare function getQSpaceSelected(): Promise<string[]>;
|
package/lib/finder.js
CHANGED
|
@@ -1,8 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getQSpaceSelected = exports.getFinderSelected = exports.getPathFinderSelected = exports.QSpace = exports.Finder = exports.PathFinder = void 0;
|
|
4
4
|
const run_1 = require("@jxa/run");
|
|
5
5
|
const url_1 = require("url");
|
|
6
|
+
/**
|
|
7
|
+
* `App` named epxorts
|
|
8
|
+
*/
|
|
9
|
+
exports.PathFinder = {
|
|
10
|
+
async allSelected() {
|
|
11
|
+
return getPathFinderSelected();
|
|
12
|
+
},
|
|
13
|
+
async singleSelected() {
|
|
14
|
+
return (await getPathFinderSelected())[0];
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
exports.Finder = {
|
|
18
|
+
async allSelected() {
|
|
19
|
+
return getFinderSelected();
|
|
20
|
+
},
|
|
21
|
+
async singleSelected() {
|
|
22
|
+
return (await getFinderSelected())[0];
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
exports.QSpace = {
|
|
26
|
+
async allSelected() {
|
|
27
|
+
return getQSpaceSelected();
|
|
28
|
+
},
|
|
29
|
+
async singleSelected() {
|
|
30
|
+
return (await getQSpaceSelected())[0];
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* impls
|
|
35
|
+
*/
|
|
6
36
|
async function getPathFinderSelected() {
|
|
7
37
|
const filePaths = await (0, run_1.run)(() => {
|
|
8
38
|
const app = Application('Path Finder');
|
|
@@ -20,22 +50,15 @@ async function getFinderSelected() {
|
|
|
20
50
|
return urls.map((u) => (0, url_1.fileURLToPath)(u));
|
|
21
51
|
}
|
|
22
52
|
exports.getFinderSelected = getFinderSelected;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
exports.
|
|
32
|
-
async allSelected() {
|
|
33
|
-
return getFinderSelected();
|
|
34
|
-
},
|
|
35
|
-
async singleSelected() {
|
|
36
|
-
return (await getFinderSelected())[0];
|
|
37
|
-
},
|
|
38
|
-
};
|
|
53
|
+
async function getQSpaceSelected() {
|
|
54
|
+
const urls = await (0, run_1.run)(() => {
|
|
55
|
+
const app = Application('QSpace Pro');
|
|
56
|
+
const selection = (app.selectedItems() || []).map((x) => x.urlstr());
|
|
57
|
+
return selection;
|
|
58
|
+
});
|
|
59
|
+
return urls.map((u) => (0, url_1.fileURLToPath)(u));
|
|
60
|
+
}
|
|
61
|
+
exports.getQSpaceSelected = getQSpaceSelected;
|
|
39
62
|
// ;(async () => {
|
|
40
|
-
// console.log(await
|
|
63
|
+
// console.log(await getQSpaceSelected())
|
|
41
64
|
// })()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mac-helper",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "useful helper for macOS",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -39,27 +39,26 @@
|
|
|
39
39
|
"@jxa/global-type": "^1.3.6",
|
|
40
40
|
"@jxa/sdef-to-dts": "^1.3.6",
|
|
41
41
|
"@jxa/types": "^1.3.6",
|
|
42
|
-
"@magicdawn/prettier-config": "^0.0.
|
|
43
|
-
"@swc/core": "1.
|
|
44
|
-
"@types/fs-extra": "^11.0.
|
|
45
|
-
"@types/mocha": "^10.0.
|
|
46
|
-
"@types/node": "^20.
|
|
47
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
48
|
-
"@typescript-eslint/parser": "^
|
|
49
|
-
"@vitest/coverage-v8": "^
|
|
50
|
-
"delay": "^
|
|
51
|
-
"eslint": "^
|
|
52
|
-
"eslint-config-prettier": "^9.
|
|
53
|
-
"fs-extra": "^11.
|
|
54
|
-
"husky": "^
|
|
42
|
+
"@magicdawn/prettier-config": "^0.0.3",
|
|
43
|
+
"@swc/core": "1.5.1",
|
|
44
|
+
"@types/fs-extra": "^11.0.4",
|
|
45
|
+
"@types/mocha": "^10.0.6",
|
|
46
|
+
"@types/node": "^20.12.7",
|
|
47
|
+
"@typescript-eslint/eslint-plugin": "^7.7.1",
|
|
48
|
+
"@typescript-eslint/parser": "^7.7.1",
|
|
49
|
+
"@vitest/coverage-v8": "^1.5.2",
|
|
50
|
+
"delay": "^6.0.0",
|
|
51
|
+
"eslint": "^9.1.1",
|
|
52
|
+
"eslint-config-prettier": "^9.1.0",
|
|
53
|
+
"fs-extra": "^11.2.0",
|
|
54
|
+
"husky": "^9.0.11",
|
|
55
55
|
"jxa-common-used": "^0.0.3",
|
|
56
|
-
"lint-staged": "^
|
|
57
|
-
"prettier": "^3.
|
|
56
|
+
"lint-staged": "^15.2.2",
|
|
57
|
+
"prettier": "^3.2.5",
|
|
58
58
|
"should": "^13.2.3",
|
|
59
|
-
"typescript": "^5.
|
|
60
|
-
"vitest": "^
|
|
59
|
+
"typescript": "^5.4.5",
|
|
60
|
+
"vitest": "^1.5.2"
|
|
61
61
|
},
|
|
62
|
-
"packageManager": "pnpm@8.7.5",
|
|
63
62
|
"publishConfig": {
|
|
64
63
|
"registry": "https://registry.npmjs.org"
|
|
65
64
|
},
|
package/src/finder.ts
CHANGED
|
@@ -2,6 +2,38 @@ import { run as jxaRun } from '@jxa/run'
|
|
|
2
2
|
import { type PathFinder as PathFinderType } from 'jxa-common-used'
|
|
3
3
|
import { fileURLToPath } from 'url'
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* `App` named epxorts
|
|
7
|
+
*/
|
|
8
|
+
export const PathFinder = {
|
|
9
|
+
async allSelected() {
|
|
10
|
+
return getPathFinderSelected()
|
|
11
|
+
},
|
|
12
|
+
async singleSelected(): Promise<string | undefined> {
|
|
13
|
+
return (await getPathFinderSelected())[0]
|
|
14
|
+
},
|
|
15
|
+
}
|
|
16
|
+
export const Finder = {
|
|
17
|
+
async allSelected() {
|
|
18
|
+
return getFinderSelected()
|
|
19
|
+
},
|
|
20
|
+
async singleSelected(): Promise<string | undefined> {
|
|
21
|
+
return (await getFinderSelected())[0]
|
|
22
|
+
},
|
|
23
|
+
}
|
|
24
|
+
export const QSpace = {
|
|
25
|
+
async allSelected() {
|
|
26
|
+
return getQSpaceSelected()
|
|
27
|
+
},
|
|
28
|
+
async singleSelected(): Promise<string | undefined> {
|
|
29
|
+
return (await getQSpaceSelected())[0]
|
|
30
|
+
},
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* impls
|
|
35
|
+
*/
|
|
36
|
+
|
|
5
37
|
export async function getPathFinderSelected() {
|
|
6
38
|
const filePaths: string[] = await jxaRun(() => {
|
|
7
39
|
const app = Application<PathFinderType>('Path Finder')
|
|
@@ -19,24 +51,29 @@ export async function getFinderSelected() {
|
|
|
19
51
|
return urls.map((u) => fileURLToPath(u))
|
|
20
52
|
}
|
|
21
53
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
54
|
+
// file item n [inh. item] : A file item.
|
|
55
|
+
// properties
|
|
56
|
+
// - id (text, r/o) : The unique identifier of the item.
|
|
57
|
+
// - name (text, r/o) : The name of the file.
|
|
58
|
+
// - urlstr (text, r/o) : The absolute string of URL of the file.
|
|
59
|
+
export type QSpaceFileItem = {
|
|
60
|
+
// the unique identifier of the item
|
|
61
|
+
id: () => string
|
|
62
|
+
// the name of the file
|
|
63
|
+
name: () => string
|
|
64
|
+
// the absolute string of URL of the file
|
|
65
|
+
urlstr: () => string
|
|
29
66
|
}
|
|
30
67
|
|
|
31
|
-
export
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
68
|
+
export async function getQSpaceSelected() {
|
|
69
|
+
const urls: string[] = await jxaRun(() => {
|
|
70
|
+
const app = Application('QSpace Pro')
|
|
71
|
+
const selection = (app.selectedItems() || []).map((x: QSpaceFileItem) => x.urlstr())
|
|
72
|
+
return selection
|
|
73
|
+
})
|
|
74
|
+
return urls.map((u) => fileURLToPath(u))
|
|
38
75
|
}
|
|
39
76
|
|
|
40
77
|
// ;(async () => {
|
|
41
|
-
// console.log(await
|
|
78
|
+
// console.log(await getQSpaceSelected())
|
|
42
79
|
// })()
|