@kud/qobuz-cli 0.5.0 → 0.5.1

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/dist/index.js CHANGED
@@ -380,43 +380,7 @@ var open = defineCommand6({
380
380
 
381
381
  // src/commands/playback.ts
382
382
  import { defineCommand as defineCommand7 } from "citty";
383
-
384
- // src/media-key.ts
385
- import { execFile as execFile2 } from "child_process";
386
- import { existsSync } from "fs";
387
- import { dirname, join } from "path";
388
- import { fileURLToPath } from "url";
389
- import { promisify as promisify2 } from "util";
390
- var exec2 = promisify2(execFile2);
391
- var findPackageRoot = () => {
392
- let dir = dirname(fileURLToPath(import.meta.url));
393
- while (!existsSync(join(dir, "package.json"))) {
394
- const parent = dirname(dir);
395
- if (parent === dir)
396
- throw new Error("could not locate the qobuz-cli package root");
397
- dir = parent;
398
- }
399
- return dir;
400
- };
401
- var root = findPackageRoot();
402
- var source = join(root, "native", "media-key.swift");
403
- var binary = join(root, "native", "media-key");
404
- var ensureBinary = async () => {
405
- if (!existsSync(binary)) await exec2("swiftc", ["-O", source, "-o", binary]);
406
- return binary;
407
- };
408
- var sendMediaKey = async (key) => {
409
- const bin = await ensureBinary();
410
- try {
411
- await exec2(bin, [key]);
412
- } catch (error) {
413
- throw new Error(
414
- (error.stderr ?? String(error)).trim()
415
- );
416
- }
417
- };
418
-
419
- // src/commands/playback.ts
383
+ import { sendMediaKey } from "@kud/macos-media-keys";
420
384
  var playbackCommand = (name, description, key) => defineCommand7({
421
385
  meta: { name, description },
422
386
  run: async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kud/qobuz-cli",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "Command-line interface for Qobuz — search, library, and quick-open in the app",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -12,12 +12,10 @@
12
12
  "qobuz": "./dist/index.js"
13
13
  },
14
14
  "files": [
15
- "dist",
16
- "native/media-key.swift"
15
+ "dist"
17
16
  ],
18
17
  "scripts": {
19
- "build": "npm run build:native && tsup",
20
- "build:native": "swiftc -O native/media-key.swift -o native/media-key",
18
+ "build": "tsup",
21
19
  "dev": "tsx src/index.ts",
22
20
  "typecheck": "tsc --noEmit"
23
21
  },
@@ -25,6 +23,7 @@
25
23
  "node": ">=20"
26
24
  },
27
25
  "dependencies": {
26
+ "@kud/macos-media-keys": "0.1.0",
28
27
  "@kud/qobuz": "0.5.0",
29
28
  "citty": "0.2.2"
30
29
  },
@@ -1,53 +0,0 @@
1
- import ApplicationServices
2
- import Cocoa
3
-
4
- // IOKit ev_keymap.h media key codes.
5
- let keyCodes: [String: Int32] = [
6
- "play": 16, // NX_KEYTYPE_PLAY — play/pause toggle
7
- "next": 17, // NX_KEYTYPE_NEXT — skip to next track
8
- "previous": 18, // NX_KEYTYPE_PREVIOUS — skip to previous track
9
- "forward": 19, // NX_KEYTYPE_FAST — fast-forward within the track
10
- "rewind": 20, // NX_KEYTYPE_REWIND — rewind within the track
11
- ]
12
-
13
- func postMediaKey(_ key: Int32) {
14
- func send(down: Bool) {
15
- let flags = NSEvent.ModifierFlags(rawValue: down ? 0xA00 : 0xB00)
16
- let data1 = Int((key << 16) | (down ? 0xA00 : 0xB00))
17
- let event = NSEvent.otherEvent(
18
- with: .systemDefined,
19
- location: .zero,
20
- modifierFlags: flags,
21
- timestamp: 0,
22
- windowNumber: 0,
23
- context: nil,
24
- subtype: 8,
25
- data1: data1,
26
- data2: -1
27
- )
28
- event?.cgEvent?.post(tap: .cghidEventTap)
29
- }
30
- send(down: true)
31
- usleep(1000)
32
- send(down: false)
33
- }
34
-
35
- let fail = { (message: String, code: Int32) in
36
- FileHandle.standardError.write(Data("\(message)\n".utf8))
37
- exit(code)
38
- }
39
-
40
- guard let name = CommandLine.arguments.dropFirst().first, let key = keyCodes[name] else {
41
- fail("usage: media-key <play|next|previous|forward|rewind>", 64)
42
- exit(64)
43
- }
44
-
45
- guard AXIsProcessTrusted() else {
46
- fail(
47
- "not authorized — grant your terminal Accessibility access in System Settings → Privacy & Security → Accessibility",
48
- 77
49
- )
50
- exit(77)
51
- }
52
-
53
- postMediaKey(key)