mac-helper 0.1.1 → 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 CHANGED
@@ -2,8 +2,9 @@
2
2
 
3
3
  > useful helper for macOS
4
4
 
5
- [![Build Status](https://img.shields.io/github/actions/workflow/status/magicdawn/mac-helper/ci.yml?style=flat-square&branch=main)](https://github.com/magicdawn/mac-helper/actions/workflows/ci.yml)
6
- [![Coverage Status](https://img.shields.io/codecov/c/github/magicdawn/mac-helper.svg?style=flat-square)](https://codecov.io/gh/magicdawn/mac-helper)
5
+ <!-- [![Build Status](https://img.shields.io/github/actions/workflow/status/magicdawn/mac-helper/ci.yml?style=flat-square&branch=main)](https://github.com/magicdawn/mac-helper/actions/workflows/ci.yml)
6
+ [![Coverage Status](https://img.shields.io/codecov/c/github/magicdawn/mac-helper.svg?style=flat-square)](https://codecov.io/gh/magicdawn/mac-helper) -->
7
+
7
8
  [![npm version](https://img.shields.io/npm/v/mac-helper.svg?style=flat-square)](https://www.npmjs.com/package/mac-helper)
8
9
  [![npm downloads](https://img.shields.io/npm/dm/mac-helper.svg?style=flat-square)](https://www.npmjs.com/package/mac-helper)
9
10
  [![npm license](https://img.shields.io/npm/l/mac-helper.svg?style=flat-square)](http://magicdawn.mit-license.org)
@@ -16,8 +17,8 @@ $ pnpm add mac-helper
16
17
 
17
18
  ## API
18
19
 
19
- ```js
20
- const MacHelper = require('mac-helper')
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
- export declare function getPathFinderSelected(): Promise<string[]>;
2
- export declare function getFinderSelected(): Promise<string[]>;
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.Finder = exports.PathFinder = exports.getFinderSelected = exports.getPathFinderSelected = void 0;
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,23 +50,15 @@ async function getFinderSelected() {
20
50
  return urls.map((u) => (0, url_1.fileURLToPath)(u));
21
51
  }
22
52
  exports.getFinderSelected = getFinderSelected;
23
- exports.PathFinder = {
24
- async allSelected() {
25
- return getPathFinderSelected();
26
- },
27
- async singleSelected() {
28
- return (await getPathFinderSelected())[0];
29
- },
30
- };
31
- exports.Finder = {
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 getPathFinderSelect())
41
- // console.log(await getPathFinderSelects())
63
+ // console.log(await getQSpaceSelected())
42
64
  // })()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mac-helper",
3
- "version": "0.1.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",
@@ -9,9 +9,10 @@
9
9
  "src/"
10
10
  ],
11
11
  "scripts": {
12
- "test": "mocha",
13
12
  "prepare": "husky install",
14
- "test-cover": "nyc --reporter=lcov --reporter=text mocha",
13
+ "test": "vitest run --globals",
14
+ "test:dev": "vitest --globals",
15
+ "test-cover": "vitest run --globals --coverage",
15
16
  "dev": "tsc -w --incremental",
16
17
  "build": "rm -rf lib; rm tsconfig.tsbuildinfo; tsc",
17
18
  "prepublishOnly": "pnpm test && pnpm build"
@@ -38,27 +39,26 @@
38
39
  "@jxa/global-type": "^1.3.6",
39
40
  "@jxa/sdef-to-dts": "^1.3.6",
40
41
  "@jxa/types": "^1.3.6",
41
- "@magicdawn/prettier-config": "^0.0.2",
42
- "@swc/core": "^1.3.55",
43
- "@types/fs-extra": "^11.0.1",
44
- "@types/mocha": "^10.0.1",
45
- "@types/node": "^18.16.1",
46
- "@typescript-eslint/eslint-plugin": "^5.59.1",
47
- "@typescript-eslint/parser": "^5.59.1",
48
- "delay": "^5.0.0",
49
- "eslint": "^8.39.0",
50
- "eslint-config-prettier": "^8.8.0",
51
- "fs-extra": "^11.1.1",
52
- "husky": "^8.0.3",
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",
53
55
  "jxa-common-used": "^0.0.3",
54
- "lint-staged": "^13.2.2",
55
- "mocha": "^10.2.0",
56
- "nyc": "^15.1.0",
57
- "prettier": "^2.8.8",
56
+ "lint-staged": "^15.2.2",
57
+ "prettier": "^3.2.5",
58
58
  "should": "^13.2.3",
59
- "typescript": "^5.0.4"
59
+ "typescript": "^5.4.5",
60
+ "vitest": "^1.5.2"
60
61
  },
61
- "packageManager": "pnpm@7.17.0",
62
62
  "publishConfig": {
63
63
  "registry": "https://registry.npmjs.org"
64
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,25 +51,29 @@ export async function getFinderSelected() {
19
51
  return urls.map((u) => fileURLToPath(u))
20
52
  }
21
53
 
22
- export const PathFinder = {
23
- async allSelected() {
24
- return getPathFinderSelected()
25
- },
26
- async singleSelected(): Promise<string | undefined> {
27
- return (await getPathFinderSelected())[0]
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 const Finder = {
32
- async allSelected() {
33
- return getFinderSelected()
34
- },
35
- async singleSelected(): Promise<string | undefined> {
36
- return (await getFinderSelected())[0]
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 getPathFinderSelect())
42
- // console.log(await getPathFinderSelects())
78
+ // console.log(await getQSpaceSelected())
43
79
  // })()