@timmo001/groundwork-report 0.9.38 → 0.9.40

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@timmo001/groundwork-report",
3
- "version": "0.9.38",
3
+ "version": "0.9.40",
4
4
  "description": "Groundwork's report page: one self-contained HTML file built from blocks, with every theme and the desktop's Omarchy theme",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -35,8 +35,8 @@
35
35
  "format:check": "prettier --check ."
36
36
  },
37
37
  "dependencies": {
38
- "@timmo001/groundwork-tokens": "0.9.38",
39
- "@timmo001/groundwork-ui": "0.9.38",
38
+ "@timmo001/groundwork-tokens": "0.9.40",
39
+ "@timmo001/groundwork-ui": "0.9.40",
40
40
  "effect": "4.1.2"
41
41
  },
42
42
  "devDependencies": {
package/src/assets.ts CHANGED
@@ -17,17 +17,21 @@ import type { ReportAssets } from "./page.ts";
17
17
 
18
18
  /** Bundles the page script and reads the themes' CSS. */
19
19
  export const reportAssets = async (): Promise<ReportAssets> => {
20
- const build = await Bun.build({
21
- entrypoints: [fileURLToPath(import.meta.resolve("./client.ts"))],
22
- target: "browser",
23
- format: "esm",
24
- minify: true,
25
- });
20
+ // The CLI rather than `Bun.build`, which can't run inside a macro while
21
+ // the bundler waits on it
22
+ const build = Bun.spawnSync([
23
+ process.execPath,
24
+ "build",
25
+ fileURLToPath(import.meta.resolve("./client.ts")),
26
+ "--target=browser",
27
+ "--format=esm",
28
+ "--minify",
29
+ ]);
26
30
 
27
- const [output] = build.outputs;
28
-
29
- if (!build.success || output === undefined) {
30
- throw new AggregateError(build.logs, "The report script didn't build");
31
+ if (!build.success) {
32
+ throw new Error(
33
+ `The report script didn't build:\n${build.stderr.toString()}`,
34
+ );
31
35
  }
32
36
 
33
37
  const css = await Bun.file(
@@ -36,5 +40,5 @@ export const reportAssets = async (): Promise<ReportAssets> => {
36
40
  ),
37
41
  ).text();
38
42
 
39
- return { css, script: await output.text() };
43
+ return { css, script: build.stdout.toString() };
40
44
  };
package/src/desktop.ts CHANGED
@@ -10,17 +10,16 @@
10
10
  *
11
11
  * @module
12
12
  */
13
- import { Result } from "effect";
13
+ import { Result, Schema } from "effect";
14
14
 
15
15
  import { readDesktopThemes } from "@timmo001/groundwork-tokens/desktop-themes";
16
16
  import { readOmarchyTheme } from "@timmo001/groundwork-tokens/omarchy-current";
17
- import { optionalThemeChoices } from "@timmo001/groundwork-tokens/page";
17
+ import { optionalThemeDocuments } from "@timmo001/groundwork-tokens/choices";
18
18
  import {
19
19
  omarchyTheme,
20
- parseTheme,
21
20
  type OmarchyCurrentTheme,
22
21
  } from "@timmo001/groundwork-tokens/runtime";
23
- import type { MappedTheme } from "@timmo001/groundwork-tokens";
22
+ import { MappedTheme } from "@timmo001/groundwork-tokens";
24
23
 
25
24
  /** What `readReportThemes` found, to spread into `reportPage`'s options. */
26
25
  export interface ReportThemes {
@@ -28,26 +27,18 @@ export interface ReportThemes {
28
27
  readonly desktop: readonly MappedTheme[];
29
28
  }
30
29
 
31
- /** The optional themes' documents, to drop desktop themes that match them. */
32
- const optionalThemes = async () => {
33
- const documents: MappedTheme[] = [];
30
+ const decodeMapped = Schema.decodeUnknownResult(MappedTheme);
34
31
 
35
- for (const { id } of optionalThemeChoices) {
36
- const file = await Bun.file(
37
- Bun.fileURLToPath(
38
- import.meta.resolve(`@timmo001/groundwork-tokens/themes/${id}.json`),
39
- ),
40
- ).text();
41
-
42
- const parsed = parseTheme(file);
43
-
44
- if (Result.isSuccess(parsed) && parsed.success.kind === "mapped") {
45
- documents.push(parsed.success);
46
- }
47
- }
32
+ /**
33
+ * The optional themes' documents, to drop desktop themes that match them.
34
+ * They come bundled rather than read from disk, so this works in an app
35
+ * compiled to one binary.
36
+ */
37
+ const optionalThemes = optionalThemeDocuments.flatMap((document) => {
38
+ const decoded = decodeMapped(document);
48
39
 
49
- return documents;
50
- };
40
+ return Result.isSuccess(decoded) ? [decoded.success] : [];
41
+ });
51
42
 
52
43
  /**
53
44
  * Reads the Omarchy theme in use and every other theme on the machine, the
@@ -55,18 +46,15 @@ const optionalThemes = async () => {
55
46
  * terminal following Omarchy doesn't show twice.
56
47
  */
57
48
  export const readReportThemes = async (): Promise<ReportThemes> => {
58
- const [omarchy, optional] = await Promise.all([
59
- readOmarchyTheme(),
60
- optionalThemes(),
61
- ]);
49
+ const omarchy = await readOmarchyTheme();
62
50
 
63
51
  const current =
64
52
  omarchy === null ? undefined : omarchyTheme(omarchy.colors, omarchy.name);
65
53
 
66
54
  const existing =
67
55
  current !== undefined && Result.isSuccess(current)
68
- ? [...optional, current.success]
69
- : optional;
56
+ ? [...optionalThemes, current.success]
57
+ : optionalThemes;
70
58
 
71
59
  return {
72
60
  omarchy,
package/src/page.ts CHANGED
@@ -7,7 +7,8 @@
7
7
  */
8
8
  import type { MappedTheme } from "@timmo001/groundwork-tokens";
9
9
  import type { OmarchyCurrentTheme } from "@timmo001/groundwork-tokens/runtime";
10
- import { themeBootScript } from "@timmo001/groundwork-tokens/page";
10
+ // From `choices`, not `page`, so a CLI without the DOM lib type-checks it
11
+ import { themeBootScript } from "@timmo001/groundwork-tokens/choices";
11
12
 
12
13
  import { html, raw, type Content } from "./html.ts";
13
14
  import { reportCss } from "./styles.ts";