mac-helper 0.1.0 → 0.1.2
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/chrome.d.ts +8 -0
- package/lib/chrome.js +23 -0
- package/lib/finder.js +1 -2
- package/lib/index.d.ts +2 -1
- package/lib/index.js +2 -1
- package/package.json +19 -18
- package/src/chrome.ts +26 -0
- package/src/finder.ts +1 -2
- package/src/index.ts +2 -1
package/lib/chrome.d.ts
ADDED
package/lib/chrome.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getChromeActiveTab = exports.Chrome = void 0;
|
|
4
|
+
const run_1 = require("@jxa/run");
|
|
5
|
+
exports.Chrome = {
|
|
6
|
+
async getActiveTab() {
|
|
7
|
+
return await getChromeActiveTab();
|
|
8
|
+
},
|
|
9
|
+
};
|
|
10
|
+
async function getChromeActiveTab() {
|
|
11
|
+
return await (0, run_1.run)(() => {
|
|
12
|
+
const app = Application('Google Chrome');
|
|
13
|
+
app.includeStandardAdditions = true;
|
|
14
|
+
const wins = (app.windows() || []).filter((w) => !w.minimized());
|
|
15
|
+
const tab = wins[0]?.activeTab();
|
|
16
|
+
return {
|
|
17
|
+
url: tab?.url(),
|
|
18
|
+
title: tab?.title(),
|
|
19
|
+
};
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
exports.getChromeActiveTab = getChromeActiveTab;
|
|
23
|
+
// getChromeActiveTab().then(console.log)
|
package/lib/finder.js
CHANGED
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -16,6 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
17
17
|
};
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
__exportStar(require("./chrome"), exports);
|
|
20
|
+
__exportStar(require("./dialog"), exports);
|
|
19
21
|
__exportStar(require("./finder"), exports);
|
|
20
22
|
__exportStar(require("./iterm"), exports);
|
|
21
|
-
__exportStar(require("./dialog"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mac-helper",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
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
|
|
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"
|
|
@@ -39,26 +40,26 @@
|
|
|
39
40
|
"@jxa/sdef-to-dts": "^1.3.6",
|
|
40
41
|
"@jxa/types": "^1.3.6",
|
|
41
42
|
"@magicdawn/prettier-config": "^0.0.2",
|
|
42
|
-
"@swc/core": "
|
|
43
|
-
"@types/fs-extra": "^11.0.
|
|
43
|
+
"@swc/core": "1.3.78",
|
|
44
|
+
"@types/fs-extra": "^11.0.2",
|
|
44
45
|
"@types/mocha": "^10.0.1",
|
|
45
|
-
"@types/node": "^
|
|
46
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
47
|
-
"@typescript-eslint/parser": "^
|
|
46
|
+
"@types/node": "^20.6.2",
|
|
47
|
+
"@typescript-eslint/eslint-plugin": "^6.7.0",
|
|
48
|
+
"@typescript-eslint/parser": "^6.7.0",
|
|
49
|
+
"@vitest/coverage-v8": "^0.34.4",
|
|
48
50
|
"delay": "^5.0.0",
|
|
49
|
-
"eslint": "^8.
|
|
50
|
-
"eslint-config-prettier": "^
|
|
51
|
-
"fs-extra": "^11.1.
|
|
51
|
+
"eslint": "^8.49.0",
|
|
52
|
+
"eslint-config-prettier": "^9.0.0",
|
|
53
|
+
"fs-extra": "^11.1.1",
|
|
52
54
|
"husky": "^8.0.3",
|
|
53
|
-
"jxa-common-used": "^0.0.
|
|
54
|
-
"lint-staged": "^
|
|
55
|
-
"
|
|
56
|
-
"nyc": "^15.1.0",
|
|
57
|
-
"prettier": "^2.8.4",
|
|
55
|
+
"jxa-common-used": "^0.0.3",
|
|
56
|
+
"lint-staged": "^14.0.1",
|
|
57
|
+
"prettier": "^3.0.3",
|
|
58
58
|
"should": "^13.2.3",
|
|
59
|
-
"typescript": "^
|
|
59
|
+
"typescript": "^5.2.2",
|
|
60
|
+
"vitest": "^0.34.4"
|
|
60
61
|
},
|
|
61
|
-
"packageManager": "pnpm@7.
|
|
62
|
+
"packageManager": "pnpm@8.7.5",
|
|
62
63
|
"publishConfig": {
|
|
63
64
|
"registry": "https://registry.npmjs.org"
|
|
64
65
|
},
|
package/src/chrome.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { run } from '@jxa/run'
|
|
2
|
+
import { type GoogleChrome } from 'jxa-common-used'
|
|
3
|
+
|
|
4
|
+
export type ActiveTab = { url: string; title: string }
|
|
5
|
+
|
|
6
|
+
export const Chrome = {
|
|
7
|
+
async getActiveTab(): Promise<ActiveTab> {
|
|
8
|
+
return await getChromeActiveTab()
|
|
9
|
+
},
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export async function getChromeActiveTab(): Promise<ActiveTab> {
|
|
13
|
+
return await run(() => {
|
|
14
|
+
const app = Application<GoogleChrome>('Google Chrome')
|
|
15
|
+
app.includeStandardAdditions = true
|
|
16
|
+
|
|
17
|
+
const wins = (app.windows() || []).filter((w) => !w.minimized())
|
|
18
|
+
const tab = wins[0]?.activeTab()
|
|
19
|
+
return {
|
|
20
|
+
url: tab?.url(),
|
|
21
|
+
title: tab?.title(),
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// getChromeActiveTab().then(console.log)
|
package/src/finder.ts
CHANGED