@domicile-desktop/system-apps 1.0.0 → 1.2.0

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.
Files changed (2) hide show
  1. package/package.json +5 -5
  2. package/src/opener.ts +23 -0
package/package.json CHANGED
@@ -1,19 +1,18 @@
1
1
  {
2
2
  "dependencies": {
3
3
  "@cprussin/option-result": "^2.0.1",
4
- "@domicile-desktop/sdk": "1.0.0",
4
+ "@domicile-desktop/sdk": "2.2.0",
5
5
  "zod": "^4.5.4"
6
6
  },
7
7
  "description": "Installed applications and bookmarks for a Domicile shell's launcher, read through @domicile-desktop/sdk/system.",
8
8
  "devDependencies": {
9
9
  "@cprussin/tsconfig": "^5.0.0",
10
- "@domicile-desktop/test-support": "0.0.1",
10
+ "@domicile-desktop/test-support": "0.0.2",
11
11
  "@types/bun": "^1.4.2",
12
12
  "typescript": "^7.0.2"
13
13
  },
14
14
  "engines": {
15
- "bun": ">=1.4.2",
16
- "node": ">=24"
15
+ "bun": ">=1.4.2"
17
16
  },
18
17
  "exports": {
19
18
  "./app-icons": "./src/app-icons.ts",
@@ -31,6 +30,7 @@
31
30
  "./installed": "./src/installed.ts",
32
31
  "./mime-apps": "./src/mime-apps.ts",
33
32
  "./omit": "./src/omit.ts",
33
+ "./opener": "./src/opener.ts",
34
34
  "./openers": "./src/openers.ts",
35
35
  "./opens": "./src/opens.ts"
36
36
  },
@@ -55,5 +55,5 @@
55
55
  "test:unit": "bun test"
56
56
  },
57
57
  "type": "module",
58
- "version": "1.0.0"
58
+ "version": "1.2.0"
59
59
  }
package/src/opener.ts ADDED
@@ -0,0 +1,23 @@
1
+ // The application `domicile open` runs for a file or address.
2
+
3
+ import type { Option, Result } from "@cprussin/option-result";
4
+ import { None, Some } from "@cprussin/option-result";
5
+ import type { SystemError } from "@domicile-desktop/sdk/system";
6
+ import type { AppsDesktop } from "./apps-desktop";
7
+
8
+ /**
9
+ * The desktop file ID, without `.desktop`, of the application `domicile open`
10
+ * runs for `target`, as `domicile open --which` says: nothing when none opens
11
+ * it, or when it is a web address, which browses. A file path must be
12
+ * absolute. The `domicile` is the running desktop's own, first on its `PATH`.
13
+ */
14
+ export const opener = async (
15
+ domicile: AppsDesktop,
16
+ target: string,
17
+ ): Promise<Result<Option<string>, SystemError>> =>
18
+ (await domicile.processes.run(["domicile", "open", "--which", target])).map(
19
+ ({ code, stdout }) => {
20
+ const id = stdout.trim().replace(/\.desktop$/, "");
21
+ return code !== 0 || id === "" ? None<string>() : Some(id);
22
+ },
23
+ );