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.
@@ -0,0 +1,8 @@
1
+ export type ActiveTab = {
2
+ url: string;
3
+ title: string;
4
+ };
5
+ export declare const Chrome: {
6
+ getActiveTab(): Promise<ActiveTab>;
7
+ };
8
+ export declare function getChromeActiveTab(): Promise<ActiveTab>;
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
@@ -37,6 +37,5 @@ exports.Finder = {
37
37
  },
38
38
  };
39
39
  // ;(async () => {
40
- // console.log(await getPathFinderSelect())
41
- // console.log(await getPathFinderSelects())
40
+ // console.log(await PathFinder.allSelected())
42
41
  // })()
package/lib/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export * from './chrome';
2
+ export * from './dialog';
1
3
  export * from './finder';
2
4
  export * from './iterm';
3
- export * from './dialog';
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.0",
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-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"
@@ -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": "^1.3.40",
43
- "@types/fs-extra": "^11.0.1",
43
+ "@swc/core": "1.3.78",
44
+ "@types/fs-extra": "^11.0.2",
44
45
  "@types/mocha": "^10.0.1",
45
- "@types/node": "^18.15.3",
46
- "@typescript-eslint/eslint-plugin": "^5.55.0",
47
- "@typescript-eslint/parser": "^5.55.0",
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.36.0",
50
- "eslint-config-prettier": "^8.7.0",
51
- "fs-extra": "^11.1.0",
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.2",
54
- "lint-staged": "^13.2.0",
55
- "mocha": "^10.2.0",
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": "^4.9.5"
59
+ "typescript": "^5.2.2",
60
+ "vitest": "^0.34.4"
60
61
  },
61
- "packageManager": "pnpm@7.17.0",
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
@@ -38,6 +38,5 @@ export const Finder = {
38
38
  }
39
39
 
40
40
  // ;(async () => {
41
- // console.log(await getPathFinderSelect())
42
- // console.log(await getPathFinderSelects())
41
+ // console.log(await PathFinder.allSelected())
43
42
  // })()
package/src/index.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  /// <reference types='@jxa/global-type' />
2
2
  /// <reference types='@jxa/types' />
3
3
 
4
+ export * from './chrome'
5
+ export * from './dialog'
4
6
  export * from './finder'
5
7
  export * from './iterm'
6
- export * from './dialog'