@domicile-desktop/system-apps 0.0.0-alpha-47cc305304ed → 0.0.0-alpha-df0645efcaa6

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
@@ -33,7 +33,7 @@ const editors = findApps(apps, "edit", 50);
33
33
  | `./mime-apps` | A content type's default applications from every `mimeapps.list`, the desktop's own (`domicile-mimeapps.list`) first. |
34
34
  | `./openers` | The applications that open a file, its default first, and the argv each opens it with. The type comes from shared-mime-info's `mime/globs2`, by name. |
35
35
  | `./omit` | Desktop file IDs left out, as globs. |
36
- | `./app-icons` | Icon names resolved in `hicolor` and `pixmaps` to `data:` URLs (PNG, SVG, 128 KiB at most). |
36
+ | `./app-icons` | Icon names resolved in `hicolor` (`apps`, or the contexts given) and `pixmaps` to `data:` URLs (PNG, SVG, 128 KiB at most). |
37
37
  | `./favicon`, `./curl`, `./favicons` | A bookmark's icon: picked from the page, fetched with `curl`, kept and retried. |
38
38
  | `./fake-system` | A `System` over an in-memory tree, for tests. |
39
39
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "dependencies": {
3
3
  "@cprussin/option-result": "^2.0.1",
4
- "@domicile-desktop/sdk": "0.0.0-alpha-47cc305304ed",
4
+ "@domicile-desktop/sdk": "0.0.0-alpha-df0645efcaa6",
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.",
@@ -48,5 +48,5 @@
48
48
  "test:unit": "bun test"
49
49
  },
50
50
  "type": "module",
51
- "version": "0.0.0-alpha-47cc305304ed"
51
+ "version": "0.0.0-alpha-df0645efcaa6"
52
52
  }
package/src/app-icons.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  // Desktop-entry icon names resolved to `data:` URLs, for `Icon` and
2
2
  // `X-Domicile-Preview`.
3
3
  //
4
- // Follows the icon theme spec: `icons/hicolor/<size>/apps/<name>.<ext>` under
5
- // each data directory, then `pixmaps/<name>.<ext>`. Only `hicolor` is
4
+ // Follows the icon theme spec: `icons/hicolor/<size>/<context>/<name>.<ext>`
5
+ // under each data directory, then `pixmaps/<name>.<ext>`. Only `hicolor` is
6
6
  // searched: every application installs into it and every theme inherits it.
7
7
 
8
8
  import type { Option, Result } from "@cprussin/option-result";
@@ -48,8 +48,9 @@ export type IconLookup = (
48
48
  type Listed = { dir: string; names: ReadonlySet<string> };
49
49
 
50
50
  /**
51
- * Icons under `dataDirs`, highest priority first. An absolute name is read as
52
- * a file, as the spec allows.
51
+ * Icons under `dataDirs`, highest priority first, in `contexts` (theme
52
+ * subdirectories such as `apps` or `status`) in order. An absolute name is
53
+ * read as a file, as the spec allows.
53
54
  *
54
55
  * Lists the theme's directories once, on the first lookup, and each name
55
56
  * once. Make a new lookup to see newly installed icons.
@@ -57,6 +58,7 @@ type Listed = { dir: string; names: ReadonlySet<string> };
57
58
  export const appIcons = (
58
59
  system: System,
59
60
  dataDirs: readonly string[],
61
+ contexts: readonly string[] = ["apps"],
60
62
  ): IconLookup => {
61
63
  let listed: Promise<Result<Listed[], SystemError>> | undefined;
62
64
  const looked = new Map<
@@ -66,7 +68,7 @@ export const appIcons = (
66
68
  return (name) => {
67
69
  const known = looked.get(name);
68
70
  if (known === undefined) {
69
- listed ??= listings(system, dataDirs);
71
+ listed ??= listings(system, dataDirs, contexts);
70
72
  const lookup = name.startsWith("/")
71
73
  ? read(system, name)
72
74
  : listed.then((dirs) =>
@@ -84,9 +86,10 @@ export const appIcons = (
84
86
  const listings = async (
85
87
  system: System,
86
88
  dataDirs: readonly string[],
89
+ contexts: readonly string[],
87
90
  ): Promise<Result<Listed[], SystemError>> => {
88
91
  const themed = allOk(
89
- await Promise.all(dataDirs.map((dir) => themeDirs(system, dir))),
92
+ await Promise.all(dataDirs.map((dir) => themeDirs(system, dir, contexts))),
90
93
  ).map((dirs) => dirs.flat());
91
94
  const pixmaps = dataDirs.map((dir) => `${dir}/pixmaps`);
92
95
  return themed.andThenAsync(async (dirs) =>
@@ -105,16 +108,19 @@ const listings = async (
105
108
  );
106
109
  };
107
110
 
108
- /** `hicolor`'s `apps` directories under `dataDir`, by preferred size. */
111
+ /** `hicolor`'s `contexts` directories under `dataDir`, by preferred size. */
109
112
  const themeDirs = async (
110
113
  system: System,
111
114
  dataDir: string,
115
+ contexts: readonly string[],
112
116
  ): Promise<Result<string[], SystemError>> => {
113
117
  const theme = `${dataDir}/icons/hicolor`;
114
118
  return orAbsent(await system.readDir(theme), []).map((entries) => {
115
119
  const sizes = new Set(entries.map((entry) => entry.name));
116
- return SIZES.filter((size) => sizes.has(size)).map(
117
- (size) => `${theme}/${size}/apps`,
120
+ return contexts.flatMap((context) =>
121
+ SIZES.filter((size) => sizes.has(size)).map(
122
+ (size) => `${theme}/${size}/${context}`,
123
+ ),
118
124
  );
119
125
  });
120
126
  };