@pantoken/rust 0.1.20 → 0.1.22
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 +10 -4
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +3 -2
- package/package.json +7 -6
package/README.md
CHANGED
|
@@ -33,10 +33,16 @@ pantoken generate rust --format iced --out src/tokens.rs
|
|
|
33
33
|
|
|
34
34
|
## Output
|
|
35
35
|
|
|
36
|
-
A single Rust module of
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
A single Rust module of typed colours and dimensions, prefixed with `use egui::Color32;` or
|
|
37
|
+
`use iced::Color;` to match the chosen format. Iced colours and dimensions are `pub const`s;
|
|
38
|
+
egui colours are `pub fn color_name() -> Color32` accessors because `Color32` constructors are not
|
|
39
|
+
`const`, while dimensions remain `pub const f32`. Web-rendered Rust UIs (Tauri, Dioxus-web, Leptos,
|
|
40
|
+
Yew) render to HTML/CSS — use `@pantoken/css` there, not this package.
|
|
41
|
+
|
|
42
|
+
## Compatibility
|
|
43
|
+
|
|
44
|
+
`vp run @pantoken/rust#check:compatibility` compiles generated egui and iced modules with Rust 1.95.0,
|
|
45
|
+
egui 0.36.2, and iced_core 0.14.0.
|
|
40
46
|
|
|
41
47
|
## API
|
|
42
48
|
|
package/dist/index.d.mts
CHANGED
|
@@ -23,7 +23,7 @@ export interface RustOptions {
|
|
|
23
23
|
* import { byTheme } from "@pantoken/tokens";
|
|
24
24
|
*
|
|
25
25
|
* const source = toRust(byTheme("rebrand"));
|
|
26
|
-
* // "use egui::Color32;\npub
|
|
26
|
+
* // "use egui::Color32;\npub fn color_background_brand() -> Color32 { Color32::from_rgb(…) }"
|
|
27
27
|
* ```
|
|
28
28
|
*
|
|
29
29
|
* @example iced (Color), dark mode
|
package/dist/index.mjs
CHANGED
|
@@ -56,7 +56,7 @@ function colorLiteral(format, rgb) {
|
|
|
56
56
|
* import { byTheme } from "@pantoken/tokens";
|
|
57
57
|
*
|
|
58
58
|
* const source = toRust(byTheme("rebrand"));
|
|
59
|
-
* // "use egui::Color32;\npub
|
|
59
|
+
* // "use egui::Color32;\npub fn color_background_brand() -> Color32 { Color32::from_rgb(…) }"
|
|
60
60
|
* ```
|
|
61
61
|
*
|
|
62
62
|
* @example iced (Color), dark mode
|
|
@@ -83,7 +83,8 @@ function toRust(tokens, options = {}) {
|
|
|
83
83
|
const rgb = hexToRgb(leaf.value);
|
|
84
84
|
if (!rgb) continue;
|
|
85
85
|
const { ty, expr } = colorLiteral(format, rgb);
|
|
86
|
-
lines.push(`pub
|
|
86
|
+
if (format === "egui") lines.push(`pub fn ${constant.toLowerCase()}() -> ${ty} { ${expr} }`);
|
|
87
|
+
else lines.push(`pub const ${constant}: ${ty} = ${expr};`);
|
|
87
88
|
} else if (leaf.type === "dimension" || leaf.type === "number") {
|
|
88
89
|
const n = dimension(leaf.value);
|
|
89
90
|
if (n === void 0) continue;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pantoken/rust",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.22",
|
|
4
4
|
"description": "Emit Instructure design tokens as Rust constants for egui (Color32) or iced (Color).",
|
|
5
5
|
"homepage": "https://pantoken.app",
|
|
6
6
|
"bugs": "https://github.com/thedannywahl/pantoken/issues",
|
|
@@ -24,13 +24,13 @@
|
|
|
24
24
|
"provenance": true
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@pantoken/core": "0.
|
|
28
|
-
"@pantoken/model": "0.
|
|
29
|
-
"@pantoken/tokens": "0.
|
|
30
|
-
"@pantoken/utils": "1.1
|
|
27
|
+
"@pantoken/core": "0.6.1",
|
|
28
|
+
"@pantoken/model": "0.5.0",
|
|
29
|
+
"@pantoken/tokens": "0.8.0",
|
|
30
|
+
"@pantoken/utils": "1.2.1"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@types/node": "^26.6.
|
|
33
|
+
"@types/node": "^26.6.3",
|
|
34
34
|
"typescript": "^7.0.2",
|
|
35
35
|
"vite": "npm:@voidzero-dev/vite-plus-core@1.0.0-rc.0",
|
|
36
36
|
"vite-plus": "1.0.0-rc.0"
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
"node": ">=22.18.0"
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
|
+
"check:compatibility": "node scripts/check-compatibility.ts",
|
|
42
43
|
"dev": "vp pack --watch",
|
|
43
44
|
"test": "vp test",
|
|
44
45
|
"check": "vp check"
|