@gtk-js/theme-mactahoe 0.0.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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,15 @@
1
+ # @gtk-js/theme-mactahoe
2
+
3
+ ## 0.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 0982123: Bump all packages past burned npm versions
8
+ - Updated dependencies [0982123]
9
+ - @gtk-js/gtk-css@0.1.1
10
+
11
+ ## 0.0.1
12
+
13
+ ### Patch Changes
14
+
15
+ - @gtk-js/gtk-css@0.2.0
package/build.ts ADDED
@@ -0,0 +1,105 @@
1
+ import { compileGtkCSS } from "@gtk-js/gtk-css/compile";
2
+ import { XMLParser } from "fast-xml-parser";
3
+ import { mkdirSync, readFileSync, unlinkSync, writeFileSync } from "fs";
4
+
5
+ const upstreamDir = new URL("../../upstream/mactahoe-gtk-theme/src", import.meta.url).pathname;
6
+
7
+ const outDir = new URL("dist/", import.meta.url).pathname;
8
+ mkdirSync(outDir, { recursive: true });
9
+
10
+ const sassDir = `${upstreamDir}/sass`;
11
+
12
+ // Parse gtk.gresource.xml to build a map of virtual CSS url() paths → physical file paths.
13
+ // The gresource XML lists paths relative to gtk-4.0/, and make_gresource_xml.sh maps them:
14
+ // assets/ → src/assets/gtk/common-assets/assets/
15
+ // windows-assets/ → src/assets/gtk/windows-assets/titlebutton/
16
+ const gresourceXml = readFileSync(`${upstreamDir}/main/gtk-4.0/gtk.gresource.xml`, "utf8");
17
+ const parsed = new XMLParser({ isArray: () => true }).parse(gresourceXml);
18
+ const assetMap = new Map<string, string>();
19
+ const files: string[] = parsed?.gresources?.[0]?.gresource?.[0]?.file ?? [];
20
+ for (const virtualPath of files) {
21
+ if (!virtualPath.endsWith(".png")) continue;
22
+ const filename = virtualPath.split("/").pop()!;
23
+ let physicalPath: string;
24
+ if (virtualPath.startsWith("windows-assets/")) {
25
+ physicalPath = `${upstreamDir}/assets/gtk/windows-assets/titlebutton/${filename}`;
26
+ } else if (virtualPath.startsWith("assets/")) {
27
+ physicalPath = `${upstreamDir}/assets/gtk/common-assets/assets/${filename}`;
28
+ } else {
29
+ continue;
30
+ }
31
+ assetMap.set(virtualPath, physicalPath);
32
+ }
33
+
34
+ const accents = ["default"] as const;
35
+ const schemes = ["light", "dark"] as const;
36
+
37
+ const themeOptionsContent = `
38
+ $sidebar_size: 200px;
39
+ $nautilus_style: 'stable';
40
+ $panel_style: 'default';
41
+ $panel_opacity: 0.15;
42
+ $showapps_button: 'bigsur';
43
+ $panel_size: 'default';
44
+ $font_size: 'normal';
45
+ $activities: 'default';
46
+ $panel_font: 'white';
47
+ $max_window_style: 'square';
48
+ $monterey: 'false';
49
+ $darker: 'false';
50
+ $blur: 'false';
51
+ $desktop: 'default';
52
+ $scale: 'default';
53
+ $shell_version: 'old';
54
+ $scaling_factor: '2';
55
+ $menu_shadow: 'default';
56
+ `;
57
+
58
+ const results: Record<string, string> = {};
59
+
60
+ for (const scheme of schemes) {
61
+ const scssEntry = `${upstreamDir}/main/gtk-4.0/gtk-${scheme === "light" ? "Light" : "Dark"}.scss`;
62
+
63
+ for (const accent of accents) {
64
+ const themeValue = accent === "default" ? "default" : accent;
65
+
66
+ const gtkBaseContent = `
67
+ $laptop: 'true';
68
+ $trans: 'false';
69
+ $theme: '${themeValue}';
70
+ $scheme: 'standard';
71
+ $gnome_version: 'old';
72
+ $accent_type: 'default';
73
+ `;
74
+
75
+ writeFileSync(`${sassDir}/_theme-options-temp.scss`, themeOptionsContent);
76
+ writeFileSync(`${sassDir}/_gtk-base-temp.scss`, gtkBaseContent);
77
+
78
+ try {
79
+ const css = await compileGtkCSS(scssEntry, { scheme, assetMap });
80
+ const key = `${scheme}_${accent}`;
81
+ results[key] = css;
82
+ process.stdout.write(` ${key}: ${css.length}b\n`);
83
+ } finally {
84
+ try {
85
+ unlinkSync(`${sassDir}/_theme-options-temp.scss`);
86
+ } catch {}
87
+ try {
88
+ unlinkSync(`${sassDir}/_gtk-base-temp.scss`);
89
+ } catch {}
90
+ }
91
+ }
92
+ }
93
+
94
+ // Write individual CSS files
95
+ for (const [key, css] of Object.entries(results)) {
96
+ writeFileSync(`${outDir}${key}.css`, css);
97
+ }
98
+
99
+ // Write JS index that exports all variants as named string constants
100
+ const indexLines = Object.keys(results).map(
101
+ (key) => `export { default as ${key} } from "./${key}.css" with { type: "text" };`,
102
+ );
103
+ writeFileSync(`${outDir}index.ts`, indexLines.join("\n") + "\n");
104
+
105
+ console.log(`Built ${Object.keys(results).length} MacTahoe variants.`);