@texturehq/edges 1.3.0 → 1.3.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.
@@ -0,0 +1,95 @@
1
+ /**
2
+ * Generate viz-runtime.css from Style Dictionary output
3
+ *
4
+ * WORKAROUND: Tailwind 4's @theme directive filters out viz color variables,
5
+ * so we extract them and create a separate runtime file with plain :root and
6
+ * .theme-dark blocks.
7
+ *
8
+ * This script should run after Style Dictionary generates the token files.
9
+ */
10
+
11
+ import fs from "fs";
12
+ import path from "path";
13
+
14
+ const GENERATED_DIR = "src/generated";
15
+ const LIGHT_TOKENS = path.join(GENERATED_DIR, "tailwind-tokens-light.css");
16
+ const DARK_TOKENS = path.join(GENERATED_DIR, "tailwind-tokens-dark.css");
17
+ const OUTPUT_FILE = path.join(GENERATED_DIR, "viz-runtime.css");
18
+
19
+ /**
20
+ * Extract viz color variables from a CSS file
21
+ */
22
+ function extractVizColors(cssContent) {
23
+ const vizColorRegex = /^\s*(--color-viz-[^:]+:\s*[^;]+;)\s*$/gm;
24
+ const matches = [];
25
+ let match;
26
+
27
+ while ((match = vizColorRegex.exec(cssContent)) !== null) {
28
+ matches.push(match[1]);
29
+ }
30
+
31
+ return matches;
32
+ }
33
+
34
+ /**
35
+ * Generate the viz-runtime.css file
36
+ */
37
+ function generateVizRuntime() {
38
+ console.log("🎨 Generating viz-runtime.css...");
39
+
40
+ // Read token files
41
+ const lightContent = fs.readFileSync(LIGHT_TOKENS, "utf8");
42
+ const darkContent = fs.readFileSync(DARK_TOKENS, "utf8");
43
+
44
+ // Extract viz colors
45
+ const lightVizColors = extractVizColors(lightContent);
46
+ const darkVizColors = extractVizColors(darkContent);
47
+
48
+ if (lightVizColors.length === 0) {
49
+ console.warn("⚠️ No viz colors found in light theme tokens");
50
+ }
51
+
52
+ if (darkVizColors.length === 0) {
53
+ console.warn("⚠️ No viz colors found in dark theme tokens");
54
+ }
55
+
56
+ // Generate output
57
+ const output = `/**
58
+ * Data Visualization Color Palette - Runtime Override
59
+ *
60
+ * WORKAROUND: These variables are defined here instead of in tailwind-tokens-*.css
61
+ * because Tailwind 4's @theme directive filters them out (similar issue as data-* prefix).
62
+ *
63
+ * AUTO-GENERATED by scripts/generate-viz-runtime.js
64
+ * DO NOT EDIT MANUALLY - Edit tokens/base/data-visualization.json instead.
65
+ *
66
+ * To customize dark mode viz colors, edit the "viz" section in tokens/themes/dark.json
67
+ */
68
+
69
+ /* Light theme (default) */
70
+ :root {
71
+ ${lightVizColors.map((color) => ` ${color}`).join("\n")}
72
+ }
73
+
74
+ /* Dark theme */
75
+ .theme-dark {
76
+ ${darkVizColors.map((color) => ` ${color}`).join("\n")}
77
+ }
78
+ `;
79
+
80
+ // Write output
81
+ fs.writeFileSync(OUTPUT_FILE, output, "utf8");
82
+
83
+ console.log(`✅ Generated ${OUTPUT_FILE}`);
84
+ console.log(` - Light theme: ${lightVizColors.length} variables`);
85
+ console.log(` - Dark theme: ${darkVizColors.length} variables`);
86
+ }
87
+
88
+ // Run the script
89
+ try {
90
+ generateVizRuntime();
91
+ } catch (error) {
92
+ console.error("❌ Error generating viz-runtime.css:", error);
93
+ process.exit(1);
94
+ }
95
+