cssints 0.3.1 → 0.5.0
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 +3 -2
- package/dist/check.mjs +2 -2
- package/dist/clay-types.d.mts +232 -0
- package/dist/clay.d.mts +40 -0
- package/dist/clay.mjs +577 -0
- package/dist/{contrast-B49XCnVX.mjs → contrast-DLi4pp25.mjs} +2 -2
- package/dist/group-common-3PAVTxpd.d.mts +1 -0
- package/dist/{group-types-9ttphdku.d.mts → group-types-Dn9CIR8J.d.mts} +1 -1
- package/dist/groups/baseline-2015/with-downstream.d.mts +3 -3
- package/dist/groups/baseline-2015.d.mts +3 -3
- package/dist/groups/baseline-2016/with-downstream.d.mts +3 -3
- package/dist/groups/baseline-2016.d.mts +3 -3
- package/dist/groups/baseline-2017/with-downstream.d.mts +3 -3
- package/dist/groups/baseline-2017.d.mts +3 -3
- package/dist/groups/baseline-2018/with-downstream.d.mts +3 -3
- package/dist/groups/baseline-2018.d.mts +3 -3
- package/dist/groups/baseline-2019/with-downstream.d.mts +3 -3
- package/dist/groups/baseline-2019.d.mts +3 -3
- package/dist/groups/baseline-2020/with-downstream.d.mts +3 -3
- package/dist/groups/baseline-2020.d.mts +3 -3
- package/dist/groups/baseline-2021/with-downstream.d.mts +3 -3
- package/dist/groups/baseline-2021.d.mts +3 -3
- package/dist/groups/baseline-2022/with-downstream.d.mts +3 -3
- package/dist/groups/baseline-2022.d.mts +3 -3
- package/dist/groups/baseline-2023/with-downstream.d.mts +3 -3
- package/dist/groups/baseline-2023.d.mts +3 -3
- package/dist/groups/baseline-2024/with-downstream.d.mts +3 -3
- package/dist/groups/baseline-2024.d.mts +3 -3
- package/dist/groups/baseline-2025/with-downstream.d.mts +3 -3
- package/dist/groups/baseline-2025.d.mts +3 -3
- package/dist/groups/baseline-2026/with-downstream.d.mts +1 -1
- package/dist/groups/baseline-2026.d.mts +1 -1
- package/dist/groups/compositing-2.d.mts +3 -3
- package/dist/groups/css-align-3.d.mts +3 -3
- package/dist/groups/css-anchor-position-1.d.mts +3 -3
- package/dist/groups/css-anchor-position-2.d.mts +3 -3
- package/dist/groups/css-animations-1.d.mts +3 -3
- package/dist/groups/css-animations-2.d.mts +3 -3
- package/dist/groups/css-backgrounds-3.d.mts +3 -3
- package/dist/groups/css-backgrounds-4.d.mts +3 -3
- package/dist/groups/css-borders-4.d.mts +3 -3
- package/dist/groups/css-box-4.d.mts +3 -3
- package/dist/groups/css-break-4.d.mts +3 -3
- package/dist/groups/css-cascade-5.d.mts +3 -3
- package/dist/groups/css-cascade-6.d.mts +3 -3
- package/dist/groups/css-color-4.d.mts +3 -3
- package/dist/groups/css-color-5.d.mts +3 -3
- package/dist/groups/css-color-6.d.mts +3 -3
- package/dist/groups/css-color-adjust-1.d.mts +3 -3
- package/dist/groups/css-color-hdr-1.d.mts +3 -3
- package/dist/groups/css-conditional-3.d.mts +3 -3
- package/dist/groups/css-conditional-4.d.mts +3 -3
- package/dist/groups/css-conditional-5.d.mts +3 -3
- package/dist/groups/css-contain-2.d.mts +3 -3
- package/dist/groups/css-content-3.d.mts +3 -3
- package/dist/groups/css-counter-styles-3.d.mts +3 -3
- package/dist/groups/css-display-4.d.mts +3 -3
- package/dist/groups/css-easing-2.d.mts +3 -3
- package/dist/groups/css-env-1.d.mts +3 -3
- package/dist/groups/css-flexbox-1.d.mts +3 -3
- package/dist/groups/css-fonts-4.d.mts +3 -3
- package/dist/groups/css-fonts-5.d.mts +3 -3
- package/dist/groups/css-forms-1.d.mts +3 -3
- package/dist/groups/css-gaps-1.d.mts +3 -3
- package/dist/groups/css-gcpm-3.d.mts +3 -3
- package/dist/groups/css-gcpm-4.d.mts +3 -3
- package/dist/groups/css-grid-2.d.mts +3 -3
- package/dist/groups/css-grid-3.d.mts +3 -3
- package/dist/groups/css-images-3.d.mts +3 -3
- package/dist/groups/css-images-4.d.mts +3 -3
- package/dist/groups/css-images-5.d.mts +3 -3
- package/dist/groups/css-inline-3.d.mts +3 -3
- package/dist/groups/css-lists-3.d.mts +3 -3
- package/dist/groups/css-logical-1.d.mts +3 -3
- package/dist/groups/css-masking-1.d.mts +3 -3
- package/dist/groups/css-multicol-2.d.mts +3 -3
- package/dist/groups/css-overflow-3.d.mts +3 -3
- package/dist/groups/css-overflow-4.d.mts +3 -3
- package/dist/groups/css-overflow-5.d.mts +3 -3
- package/dist/groups/css-overscroll-1.d.mts +3 -3
- package/dist/groups/css-page-3.d.mts +3 -3
- package/dist/groups/css-page-floats-3.d.mts +3 -3
- package/dist/groups/css-position-3.d.mts +3 -3
- package/dist/groups/css-position-4.d.mts +3 -3
- package/dist/groups/css-rhythm-1.d.mts +3 -3
- package/dist/groups/css-round-display-1.d.mts +3 -3
- package/dist/groups/css-ruby-1.d.mts +3 -3
- package/dist/groups/css-scroll-anchoring-1.d.mts +3 -3
- package/dist/groups/css-scroll-snap-1.d.mts +3 -3
- package/dist/groups/css-scroll-snap-2.d.mts +3 -3
- package/dist/groups/css-scrollbars-1.d.mts +3 -3
- package/dist/groups/css-shapes-1.d.mts +3 -3
- package/dist/groups/css-shapes-2.d.mts +3 -3
- package/dist/groups/css-size-adjust-1.d.mts +3 -3
- package/dist/groups/css-sizing-3.d.mts +3 -3
- package/dist/groups/css-sizing-4.d.mts +3 -3
- package/dist/groups/css-speech-1.d.mts +3 -3
- package/dist/groups/css-tables-3.d.mts +3 -3
- package/dist/groups/css-text-3.d.mts +3 -3
- package/dist/groups/css-text-4.d.mts +3 -3
- package/dist/groups/css-text-decor-3.d.mts +3 -3
- package/dist/groups/css-text-decor-4.d.mts +3 -3
- package/dist/groups/css-transforms-1.d.mts +3 -3
- package/dist/groups/css-transforms-2.d.mts +3 -3
- package/dist/groups/css-transitions-1.d.mts +3 -3
- package/dist/groups/css-transitions-2.d.mts +3 -3
- package/dist/groups/css-ui-4.d.mts +3 -3
- package/dist/groups/css-values-4.d.mts +3 -3
- package/dist/groups/css-values-5.d.mts +3 -3
- package/dist/groups/css-variables-2.d.mts +2 -2
- package/dist/groups/css-view-transitions-2.d.mts +3 -3
- package/dist/groups/css-viewport.d.mts +3 -3
- package/dist/groups/css-will-change-1.d.mts +3 -3
- package/dist/groups/css-writing-modes-4.d.mts +3 -3
- package/dist/groups/css2.d.mts +3 -3
- package/dist/groups/fill-stroke-3.d.mts +3 -3
- package/dist/groups/filter-effects-1.d.mts +3 -3
- package/dist/groups/filter-effects-2.d.mts +3 -3
- package/dist/groups/limited-availability.d.mts +1 -1
- package/dist/groups/mediaqueries-4.d.mts +3 -3
- package/dist/groups/mediaqueries-5.d.mts +3 -3
- package/dist/groups/motion-1.d.mts +3 -3
- package/dist/groups/newly-available/with-downstream.d.mts +3 -3
- package/dist/groups/newly-available.d.mts +3 -3
- package/dist/groups/not-discouraged.d.mts +3 -3
- package/dist/groups/scroll-animations-1.d.mts +3 -3
- package/dist/groups/selectors-4.d.mts +2 -2
- package/dist/groups/selectors-5.d.mts +2 -2
- package/dist/groups/widely-available/with-downstream.d.mts +3 -3
- package/dist/groups/widely-available.d.mts +3 -3
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +12 -5
- package/dist/{instrument-BqIZpbIU.mjs → instrument-C7Am_dJ3.mjs} +1 -1
- package/dist/{lowered-aJVapQT6.mjs → lowered-CKSYUc0i.mjs} +1 -1
- package/dist/{node-OJ_w_Usj.d.mts → node-BABEZ2oF.d.mts} +6 -0
- package/dist/plugin-types.d.mts +1 -1
- package/dist/plugin.d.mts +1 -1
- package/dist/{registry-BUSEO32-.mjs → registry-ByrYF2v5.mjs} +5 -1
- package/dist/{scope-INuJD4RT.d.mts → scope-1R_Np2Mj.d.mts} +5 -6
- package/dist/{sheet-BeHdq4xt.mjs → sheet-BT2R1wk_.mjs} +2 -2
- package/dist/surface.d.mts +1 -1
- package/dist/{theme-SlQ73rFL.mjs → theme-WGcgMD4V.mjs} +7 -5
- package/dist/{theme-types-Bqv0Ggz_.d.mts → theme-types-BY0mRf3K.d.mts} +5 -6
- package/dist/tui-types.d.mts +1 -1
- package/dist/tui.mjs +4 -4
- package/dist/types.d.mts +1 -1
- package/dist/vite.d.mts +1 -1
- package/dist/vite.mjs +4 -4
- package/docs/API.md +134 -2
- package/package.json +6 -2
- package/skills/cssints/references/plugins.md +12 -0
- package/dist/group-common-9zpBxfUF.d.mts +0 -1
package/dist/clay.mjs
ADDED
|
@@ -0,0 +1,577 @@
|
|
|
1
|
+
import { a as registry } from "./registry-ByrYF2v5.mjs";
|
|
2
|
+
import { a as createTokens$1, i as createGlobalTheme$1, j as fail, s as sets } from "./theme-WGcgMD4V.mjs";
|
|
3
|
+
import { n as valueOf, t as together } from "./contrast-DLi4pp25.mjs";
|
|
4
|
+
import { n as parseColor } from "./color-BYIxVLlS.mjs";
|
|
5
|
+
import { Formatter, Predicate } from "effect";
|
|
6
|
+
import { clampRgb, formatHex } from "culori/fn";
|
|
7
|
+
//#region src/clay.ts
|
|
8
|
+
const tables = registry.clayTokens ??= {
|
|
9
|
+
properties: /* @__PURE__ */ new Map(),
|
|
10
|
+
defs: /* @__PURE__ */ new Map(),
|
|
11
|
+
themed: /* @__PURE__ */ new Map()
|
|
12
|
+
};
|
|
13
|
+
const inClay = (f) => (...args) => {
|
|
14
|
+
const web = {
|
|
15
|
+
properties: registry.properties,
|
|
16
|
+
defs: registry.defs,
|
|
17
|
+
themed: registry.themed
|
|
18
|
+
};
|
|
19
|
+
Object.assign(registry, tables);
|
|
20
|
+
try {
|
|
21
|
+
return f(...args);
|
|
22
|
+
} finally {
|
|
23
|
+
Object.assign(registry, web);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const createTokens = inClay((...args) => {
|
|
27
|
+
const root = createTokens$1(...args);
|
|
28
|
+
sets.get(root).clay = true;
|
|
29
|
+
return root;
|
|
30
|
+
});
|
|
31
|
+
const IDENT = /^[A-Za-z]\w*$/;
|
|
32
|
+
const createGlobalTheme = inClay((...args) => {
|
|
33
|
+
if (args.length !== 3 || typeof args[1] !== "string" || !IDENT.test(args[1])) throw fail(`cssints: createGlobalTheme(tokens, name, overrides) of cssints/clay takes its tokens, a name that is a C identifier (header() names a themed declaration <style>_<name>) and the values to set, got the name ${say(args[1])}`);
|
|
34
|
+
return createGlobalTheme$1(...args);
|
|
35
|
+
});
|
|
36
|
+
const STATES = [
|
|
37
|
+
":hover",
|
|
38
|
+
":focus",
|
|
39
|
+
":active"
|
|
40
|
+
];
|
|
41
|
+
const isClay = (v) => !!v && typeof v === "object" && Array.isArray(v.__clay) && !("__fonts" in v);
|
|
42
|
+
const node = (entries) => ({ __clay: entries });
|
|
43
|
+
const say = (v) => typeof v === "string" ? `"${v}"` : Formatter.formatJson(v);
|
|
44
|
+
const PX = /^(\d+\.?\d*|\.\d+)(px)?$/;
|
|
45
|
+
const PERCENT = /^(\d+\.?\d*|\.\d+)%$/;
|
|
46
|
+
const px = (prop, v) => {
|
|
47
|
+
const m = typeof v === "string" ? PX.exec(v) : null;
|
|
48
|
+
const n = typeof v === "number" ? v : m ? Number(m[1]) : NaN;
|
|
49
|
+
if (Number.isFinite(n) && n >= 0) return n;
|
|
50
|
+
throw fail(`cssints: ${prop}: unexpected ${say(v)}, expected a number of pixels (a number or "Npx", not negative)`);
|
|
51
|
+
};
|
|
52
|
+
const whole = (prop, v) => {
|
|
53
|
+
const n = px(prop, v);
|
|
54
|
+
if (Number.isInteger(n) && n <= 65535) return n;
|
|
55
|
+
throw fail(`cssints: ${prop}: ${say(v)} is not a whole number of pixels (Clay stores it as uint16_t)`);
|
|
56
|
+
};
|
|
57
|
+
const size = (prop, v) => {
|
|
58
|
+
if (v === "auto" || v === "stretch") return v;
|
|
59
|
+
if (typeof v === "string" && PERCENT.test(v)) return v;
|
|
60
|
+
return px(prop, v);
|
|
61
|
+
};
|
|
62
|
+
const keyword = (...words) => (prop, v) => {
|
|
63
|
+
if (typeof v === "string" && words.includes(v)) return v;
|
|
64
|
+
throw fail(`cssints: ${prop}: unexpected ${say(v)}, expected ${words.join(" | ")}`);
|
|
65
|
+
};
|
|
66
|
+
const VAR = /var\((--[\w-]+)\)/g;
|
|
67
|
+
const NOT_A_COLOUR = "is not a colour Clay can draw (a name, hex, rgb(), hsl(), oklch() or a colour token of the createTokens of cssints/clay; not currentColor or light-dark())";
|
|
68
|
+
const colour = (prop, u) => {
|
|
69
|
+
const v = String(u);
|
|
70
|
+
for (const [, name] of v.matchAll(VAR)) {
|
|
71
|
+
const def = tables.defs.get(name);
|
|
72
|
+
if (!def) throw fail(`cssints: ${prop}: ${name} is no token of the createTokens of cssints/clay`);
|
|
73
|
+
if (def.kind !== "color" && v === `var(${name})`) throw fail(`cssints: ${prop}: ${def.path} is a ${def.kind} token, not a colour`);
|
|
74
|
+
}
|
|
75
|
+
if (!v.includes("var(")) rgba(prop, v);
|
|
76
|
+
return v;
|
|
77
|
+
};
|
|
78
|
+
const one = (key, read) => (prop, parts) => {
|
|
79
|
+
if (parts.length !== 1) throw fail(`cssints: ${prop} takes one value, got ${parts.length}`);
|
|
80
|
+
return [[key, read(prop, parts[0])]];
|
|
81
|
+
};
|
|
82
|
+
const COLOURS = /* @__PURE__ */ new Set([
|
|
83
|
+
"backgroundColor",
|
|
84
|
+
"color",
|
|
85
|
+
"borderColor"
|
|
86
|
+
]);
|
|
87
|
+
const sides = (keys, read) => (prop, parts) => {
|
|
88
|
+
if (parts.length < 1 || parts.length > 4) throw fail(`cssints: ${prop} takes 1 to 4 values, got ${parts.length}`);
|
|
89
|
+
const v = parts.map((p) => read(prop, p));
|
|
90
|
+
const at = [
|
|
91
|
+
v[0],
|
|
92
|
+
v[1] ?? v[0],
|
|
93
|
+
v[2] ?? v[0],
|
|
94
|
+
v[3] ?? v[1] ?? v[0]
|
|
95
|
+
];
|
|
96
|
+
return keys.map((k, i) => [k, at[i]]);
|
|
97
|
+
};
|
|
98
|
+
const pair = (start, end) => (prop, parts) => {
|
|
99
|
+
if (parts.length < 1 || parts.length > 2) throw fail(`cssints: ${prop} takes 1 or 2 values, got ${parts.length}`);
|
|
100
|
+
const v = parts.map((x) => whole(prop, x));
|
|
101
|
+
return [[start, v[0]], [end, v[1] ?? v[0]]];
|
|
102
|
+
};
|
|
103
|
+
const POINTS = [
|
|
104
|
+
"left",
|
|
105
|
+
"center",
|
|
106
|
+
"right"
|
|
107
|
+
].flatMap((x) => [
|
|
108
|
+
"top",
|
|
109
|
+
"center",
|
|
110
|
+
"bottom"
|
|
111
|
+
].map((y) => `${x} ${y}`));
|
|
112
|
+
const FLOAT_OPTIONS = [
|
|
113
|
+
"attach",
|
|
114
|
+
"parent",
|
|
115
|
+
"root",
|
|
116
|
+
"offset",
|
|
117
|
+
"expand",
|
|
118
|
+
"zIndex",
|
|
119
|
+
"capture",
|
|
120
|
+
"clip"
|
|
121
|
+
];
|
|
122
|
+
const SIGNED = /^-?(?:\d+\.?\d*|\.\d+)(?:px)?$/;
|
|
123
|
+
const offset = (prop, v) => {
|
|
124
|
+
const n = typeof v === "number" ? v : typeof v === "string" && SIGNED.test(v) ? Number.parseFloat(v) : NaN;
|
|
125
|
+
if (Number.isFinite(n)) return n;
|
|
126
|
+
throw fail(`cssints: ${prop}: unexpected ${say(v)}, expected a number of pixels (a number or "Npx")`);
|
|
127
|
+
};
|
|
128
|
+
const clayId = (id) => {
|
|
129
|
+
const h = Array.from(id, (ch) => ch.charCodeAt(0)).reduce((acc, byte) => {
|
|
130
|
+
const sum = acc + byte >>> 0;
|
|
131
|
+
const mixed = sum + (sum << 10) >>> 0;
|
|
132
|
+
return (mixed ^ mixed >>> 6) >>> 0;
|
|
133
|
+
}, 0);
|
|
134
|
+
const a = h + (h << 3) >>> 0;
|
|
135
|
+
const b = (a ^ a >>> 11) >>> 0;
|
|
136
|
+
return b + (b << 15) + 1 >>> 0;
|
|
137
|
+
};
|
|
138
|
+
const options = (prop, v, keys) => {
|
|
139
|
+
if (typeof v !== "object" || v === null || Array.isArray(v)) throw fail(`cssints: ${prop}: unexpected ${say(v)}, expected { ${keys.join(", ")} }`);
|
|
140
|
+
const bad = Object.keys(v).find((k) => !keys.includes(k));
|
|
141
|
+
if (bad !== void 0) throw fail(`cssints: ${prop}: unexpected ${say(bad)}, expected ${keys.join(" | ")}`);
|
|
142
|
+
return v;
|
|
143
|
+
};
|
|
144
|
+
const upper = (v) => String(v).toUpperCase().replace(" ", "_");
|
|
145
|
+
const floating = (prop, parts) => {
|
|
146
|
+
if (parts.length > 1) throw fail(`cssints: ${prop} takes one object of options, got ${parts.length} values`);
|
|
147
|
+
const o = options(prop, parts[0] ?? {}, FLOAT_OPTIONS);
|
|
148
|
+
const out = [["float", 1]];
|
|
149
|
+
const set = (k, v) => out.push([k, v]);
|
|
150
|
+
if (o.parent !== void 0 && o.root) throw fail(`cssints: ${prop}: parent and root are two places to attach to`);
|
|
151
|
+
if (o.parent !== void 0) {
|
|
152
|
+
if (typeof o.parent !== "string" || !/^[\x20-\x7e]+$/.test(o.parent)) throw fail(`cssints: ${prop}.parent: unexpected ${say(o.parent)}, expected the non-empty ASCII string of the parent's CLAY_ID()`);
|
|
153
|
+
set("floatTo", "ELEMENT_WITH_ID");
|
|
154
|
+
set("floatParentId", clayId(o.parent));
|
|
155
|
+
}
|
|
156
|
+
if (o.root !== void 0 && typeof o.root !== "boolean") throw fail(`cssints: ${prop}.root: unexpected ${say(o.root)}, expected true | false`);
|
|
157
|
+
if (o.root) set("floatTo", "ROOT");
|
|
158
|
+
if (o.attach !== void 0) {
|
|
159
|
+
const a = options(`${prop}.attach`, o.attach, ["element", "parent"]);
|
|
160
|
+
for (const k of ["element", "parent"]) if (a[k] !== void 0) set(`float${k === "element" ? "Element" : "Parent"}`, upper(keyword(...POINTS)(`${prop}.attach.${k}`, a[k])));
|
|
161
|
+
}
|
|
162
|
+
for (const [name, read] of [["offset", offset], ["expand", px]]) {
|
|
163
|
+
if (o[name] === void 0) continue;
|
|
164
|
+
const keys = name === "offset" ? ["x", "y"] : ["width", "height"];
|
|
165
|
+
const v = options(`${prop}.${name}`, o[name], keys);
|
|
166
|
+
for (const k of keys) if (v[k] !== void 0) set(`float${name === "offset" ? "Offset" : "Expand"}${k[0].toUpperCase()}${k.slice(1)}`, read(`${prop}.${name}.${k}`, v[k]));
|
|
167
|
+
}
|
|
168
|
+
if (o.zIndex !== void 0) {
|
|
169
|
+
if (!Number.isInteger(o.zIndex) || Math.abs(o.zIndex) > 32767) throw fail(`cssints: ${prop}.zIndex: unexpected ${say(o.zIndex)}, expected a whole number (Clay stores it as int16_t)`);
|
|
170
|
+
set("floatZIndex", o.zIndex);
|
|
171
|
+
}
|
|
172
|
+
if (o.capture !== void 0) {
|
|
173
|
+
if (typeof o.capture !== "boolean") throw fail(`cssints: ${prop}.capture: unexpected ${say(o.capture)}, expected true | false`);
|
|
174
|
+
set("floatCapture", o.capture ? "CAPTURE" : "PASSTHROUGH");
|
|
175
|
+
}
|
|
176
|
+
if (o.clip !== void 0) set("floatClip", keyword("none", "parent")(`${prop}.clip`, o.clip) === "none" ? "NONE" : "ATTACHED_PARENT");
|
|
177
|
+
return out;
|
|
178
|
+
};
|
|
179
|
+
const IMAGE_OPTIONS = [
|
|
180
|
+
"width",
|
|
181
|
+
"height",
|
|
182
|
+
"fit"
|
|
183
|
+
];
|
|
184
|
+
const imageOf = (prop, parts) => {
|
|
185
|
+
if (parts.length < 1 || parts.length > 2) throw fail(`cssints: ${prop} takes the path of an image and its { width, height, fit }, got ${parts.length} values`);
|
|
186
|
+
const src = parts[0];
|
|
187
|
+
if (typeof src !== "string" || !src || /\p{Cc}/u.test(src)) throw fail(`cssints: ${prop}: unexpected ${say(src)}, expected the path of an image (a string, not empty, no control characters)`);
|
|
188
|
+
const o = options(prop, parts[1] ?? {}, IMAGE_OPTIONS);
|
|
189
|
+
if (o.width === void 0 || o.height === void 0) throw fail(`cssints: ${prop}: unexpected ${say(parts[1] ?? {})}, expected the image's width and height in pixels`);
|
|
190
|
+
const w = whole(`${prop}.width`, o.width);
|
|
191
|
+
const h = whole(`${prop}.height`, o.height);
|
|
192
|
+
if (!w || !h) throw fail(`cssints: ${prop}: unexpected ${say(w)}x${say(h)}, expected a positive whole number of pixels for each side`);
|
|
193
|
+
return [
|
|
194
|
+
["imageSrc", src],
|
|
195
|
+
["width", w],
|
|
196
|
+
["height", h],
|
|
197
|
+
["aspectRatio", keyword("fill", "contain")(`${prop}.fit`, o.fit ?? "fill") === "contain" ? w / h : 0]
|
|
198
|
+
];
|
|
199
|
+
};
|
|
200
|
+
const PADDING = [
|
|
201
|
+
"paddingTop",
|
|
202
|
+
"paddingRight",
|
|
203
|
+
"paddingBottom",
|
|
204
|
+
"paddingLeft"
|
|
205
|
+
];
|
|
206
|
+
const BORDER = [
|
|
207
|
+
"borderTop",
|
|
208
|
+
"borderRight",
|
|
209
|
+
"borderBottom",
|
|
210
|
+
"borderLeft"
|
|
211
|
+
];
|
|
212
|
+
const RADIUS = [
|
|
213
|
+
"topLeft",
|
|
214
|
+
"topRight",
|
|
215
|
+
"bottomRight",
|
|
216
|
+
"bottomLeft"
|
|
217
|
+
];
|
|
218
|
+
const ALIGN = [
|
|
219
|
+
"flex-start",
|
|
220
|
+
"start",
|
|
221
|
+
"center",
|
|
222
|
+
"flex-end",
|
|
223
|
+
"end"
|
|
224
|
+
];
|
|
225
|
+
const MEMBERS = {
|
|
226
|
+
backgroundColor: one("backgroundColor", colour),
|
|
227
|
+
bg: one("backgroundColor", colour),
|
|
228
|
+
color: one("color", colour),
|
|
229
|
+
borderColor: one("borderColor", colour),
|
|
230
|
+
width: one("width", size),
|
|
231
|
+
height: one("height", size),
|
|
232
|
+
padding: sides(PADDING, whole),
|
|
233
|
+
p: sides(PADDING, whole),
|
|
234
|
+
paddingInline: pair("paddingLeft", "paddingRight"),
|
|
235
|
+
paddingBlock: pair("paddingTop", "paddingBottom"),
|
|
236
|
+
...Object.fromEntries([
|
|
237
|
+
"Top",
|
|
238
|
+
"Right",
|
|
239
|
+
"Bottom",
|
|
240
|
+
"Left"
|
|
241
|
+
].flatMap((s) => [[`padding${s}`, one(`padding${s}`, whole)], [`p${s[0].toLowerCase()}`, one(`padding${s}`, whole)]])),
|
|
242
|
+
gap: one("gap", whole),
|
|
243
|
+
flexDirection: one("flexDirection", keyword("row", "column")),
|
|
244
|
+
justifyContent: one("justifyContent", keyword(...ALIGN)),
|
|
245
|
+
alignItems: one("alignItems", keyword(...ALIGN)),
|
|
246
|
+
borderRadius: sides(RADIUS, px),
|
|
247
|
+
borderWidth: sides(BORDER, whole),
|
|
248
|
+
border: (prop, parts) => {
|
|
249
|
+
if (parts.length !== 2) throw fail(`cssints: ${prop} takes a width and a colour, got ${parts.length} values`);
|
|
250
|
+
const w = whole(prop, parts[0]);
|
|
251
|
+
return [...BORDER.map((k) => [k, w]), ["borderColor", colour(prop, parts[1])]];
|
|
252
|
+
},
|
|
253
|
+
overflow: one("overflow", keyword("visible", "hidden")),
|
|
254
|
+
fontSize: one("fontSize", whole),
|
|
255
|
+
letterSpacing: one("letterSpacing", whole),
|
|
256
|
+
lineHeight: one("lineHeight", whole),
|
|
257
|
+
textAlign: one("textAlign", keyword("left", "center", "right")),
|
|
258
|
+
whiteSpace: one("whiteSpace", keyword("normal", "pre-line", "nowrap")),
|
|
259
|
+
float: floating,
|
|
260
|
+
image: imageOf
|
|
261
|
+
};
|
|
262
|
+
const member = (name, build) => (...parts) => {
|
|
263
|
+
if (parts.some(isClay)) throw fail(`cssints: ${name}: a style is not a value`);
|
|
264
|
+
return node(build(name, parts).map(([k, v]) => [
|
|
265
|
+
k,
|
|
266
|
+
v,
|
|
267
|
+
""
|
|
268
|
+
]));
|
|
269
|
+
};
|
|
270
|
+
const stylesOf = (what, styles) => {
|
|
271
|
+
const bad = styles.find((s) => !isClay(s));
|
|
272
|
+
if (bad !== void 0 || !styles.length) throw fail(`cssints: ${what} takes styles of cssints/clay, got ${bad === void 0 ? "nothing" : say(bad)}`);
|
|
273
|
+
return styles.flatMap((s) => s.__clay);
|
|
274
|
+
};
|
|
275
|
+
/**
|
|
276
|
+
* Merges styles in argument order: a later prop wins.
|
|
277
|
+
*
|
|
278
|
+
* @returns {ClayNode} the merged style
|
|
279
|
+
*/
|
|
280
|
+
const cn = (...styles) => node(stylesOf("cn()", styles));
|
|
281
|
+
const state = (s) => (...styles) => node(stylesOf(s, styles).map(([k, v, inner]) => {
|
|
282
|
+
if (inner) throw fail(`cssints: ${s} wraps ${inner}: Clay states do not nest (one state per style)`);
|
|
283
|
+
return [
|
|
284
|
+
k,
|
|
285
|
+
v,
|
|
286
|
+
s
|
|
287
|
+
];
|
|
288
|
+
}));
|
|
289
|
+
const hover = state(":hover");
|
|
290
|
+
const focus = state(":focus");
|
|
291
|
+
const active = state(":active");
|
|
292
|
+
/**
|
|
293
|
+
* The fonts of the app, in the order of its font array: `fonts("Roboto", "Mono").Mono` is a style that sets Clay's
|
|
294
|
+
* `fontId` to 1, and header() prints the order as an enum, `<name>_Mono`.
|
|
295
|
+
*
|
|
296
|
+
* @returns {Record<string, unknown>} a style per font, by name, and the list
|
|
297
|
+
*/
|
|
298
|
+
const fonts = (...names) => {
|
|
299
|
+
const bad = names.find((n) => typeof n !== "string" || !IDENT.test(n));
|
|
300
|
+
if (bad !== void 0 || !names.length) throw fail(`cssints: fonts() takes the names of the app's fonts in order, each a C identifier, got ${bad === void 0 ? "nothing" : say(bad)}`);
|
|
301
|
+
const twice = names.find((n, i) => names.indexOf(n) !== i);
|
|
302
|
+
if (twice !== void 0) throw fail(`cssints: fonts(): ${say(twice)} is there twice`);
|
|
303
|
+
return {
|
|
304
|
+
__clay: [],
|
|
305
|
+
__fonts: names,
|
|
306
|
+
...Object.fromEntries(names.map((n, i) => [String(n), node([[
|
|
307
|
+
"fontId",
|
|
308
|
+
i,
|
|
309
|
+
""
|
|
310
|
+
]])]))
|
|
311
|
+
};
|
|
312
|
+
};
|
|
313
|
+
const { backgroundColor, bg, color, borderColor, width, height, padding, p, paddingInline, paddingBlock, paddingTop, paddingRight, paddingBottom, paddingLeft, pt, pr, pb, pl, gap, flexDirection, justifyContent, alignItems, borderRadius, borderWidth, border, overflow, fontSize, letterSpacing, lineHeight, textAlign, whiteSpace, float, image } = Object.fromEntries(Object.entries(MEMBERS).map(([k, b]) => [k, member(k, b)]));
|
|
314
|
+
const rgba = (prop, text, values) => {
|
|
315
|
+
const flat = text.replace(VAR, (m, n) => valueOf(tables, n, values) ?? m);
|
|
316
|
+
const c = flat.includes("var(") ? void 0 : parseColor(flat);
|
|
317
|
+
if (!c) throw fail(`cssints: ${prop}: ${say(text)}${flat === text ? "" : ` (${say(flat)} here)`} ${NOT_A_COLOUR}`);
|
|
318
|
+
const hex = formatHex(clampRgb(c));
|
|
319
|
+
const [r, g, b] = [
|
|
320
|
+
1,
|
|
321
|
+
3,
|
|
322
|
+
5
|
|
323
|
+
].map((i) => Number.parseInt(hex.slice(i, i + 2), 16));
|
|
324
|
+
return {
|
|
325
|
+
r,
|
|
326
|
+
g,
|
|
327
|
+
b,
|
|
328
|
+
a: Math.round((c.alpha ?? 1) * 255)
|
|
329
|
+
};
|
|
330
|
+
};
|
|
331
|
+
const axis = (v) => v === "auto" ? { type: "FIT" } : v === "stretch" ? { type: "GROW" } : typeof v === "string" ? {
|
|
332
|
+
type: "PERCENT",
|
|
333
|
+
percent: Number.parseFloat(v) / 100
|
|
334
|
+
} : {
|
|
335
|
+
type: "FIXED",
|
|
336
|
+
min: v,
|
|
337
|
+
max: v
|
|
338
|
+
};
|
|
339
|
+
const X = {
|
|
340
|
+
start: "LEFT",
|
|
341
|
+
center: "CENTER",
|
|
342
|
+
end: "RIGHT"
|
|
343
|
+
};
|
|
344
|
+
const Y = {
|
|
345
|
+
start: "TOP",
|
|
346
|
+
center: "CENTER",
|
|
347
|
+
end: "BOTTOM"
|
|
348
|
+
};
|
|
349
|
+
const edge = (v) => v === "center" ? "center" : String(v).endsWith("end") ? "end" : "start";
|
|
350
|
+
const FLOATING = [
|
|
351
|
+
"float",
|
|
352
|
+
"floatTo",
|
|
353
|
+
"floatElement",
|
|
354
|
+
"floatParent",
|
|
355
|
+
"floatParentId",
|
|
356
|
+
"floatOffsetX",
|
|
357
|
+
"floatOffsetY",
|
|
358
|
+
"floatExpandWidth",
|
|
359
|
+
"floatExpandHeight",
|
|
360
|
+
"floatZIndex",
|
|
361
|
+
"floatCapture",
|
|
362
|
+
"floatClip"
|
|
363
|
+
];
|
|
364
|
+
const floatingOf = (p) => {
|
|
365
|
+
const has = (...ks) => ks.some((k) => p.has(k));
|
|
366
|
+
const to = p.get("floatTo") ?? "PARENT";
|
|
367
|
+
if (to === "ROOT" && p.get("floatClip") === "ATTACHED_PARENT") throw fail(`cssints: float: clip "parent" does nothing on a float attached to the root (it has no clipping parent)`);
|
|
368
|
+
return {
|
|
369
|
+
...has("floatOffsetX", "floatOffsetY") && { offset: {
|
|
370
|
+
x: p.get("floatOffsetX") ?? 0,
|
|
371
|
+
y: p.get("floatOffsetY") ?? 0
|
|
372
|
+
} },
|
|
373
|
+
...has("floatExpandWidth", "floatExpandHeight") && { expand: {
|
|
374
|
+
width: p.get("floatExpandWidth") ?? 0,
|
|
375
|
+
height: p.get("floatExpandHeight") ?? 0
|
|
376
|
+
} },
|
|
377
|
+
...to === "ELEMENT_WITH_ID" && { parentId: p.get("floatParentId") },
|
|
378
|
+
...p.has("floatZIndex") && { zIndex: p.get("floatZIndex") },
|
|
379
|
+
...has("floatElement", "floatParent") && { attachPoints: {
|
|
380
|
+
element: p.get("floatElement") ?? "LEFT_TOP",
|
|
381
|
+
parent: p.get("floatParent") ?? "LEFT_TOP"
|
|
382
|
+
} },
|
|
383
|
+
...p.has("floatCapture") && { pointerCaptureMode: p.get("floatCapture") },
|
|
384
|
+
attachTo: to,
|
|
385
|
+
...p.has("floatClip") && { clipTo: p.get("floatClip") }
|
|
386
|
+
};
|
|
387
|
+
};
|
|
388
|
+
const shapeOf = (entries, values) => {
|
|
389
|
+
const p = new Map(entries.map(([k, v]) => [k, v]));
|
|
390
|
+
const colourOf = (k) => rgba(k, String(p.get(k)), values);
|
|
391
|
+
const out = {};
|
|
392
|
+
const layout = {};
|
|
393
|
+
const get = (k) => p.get(k);
|
|
394
|
+
if (get("width") !== void 0 || get("height") !== void 0) layout.sizing = {
|
|
395
|
+
...get("width") !== void 0 && { width: axis(get("width")) },
|
|
396
|
+
...get("height") !== void 0 && { height: axis(get("height")) }
|
|
397
|
+
};
|
|
398
|
+
if (PADDING.some((k) => p.has(k))) layout.padding = {
|
|
399
|
+
left: get("paddingLeft") ?? 0,
|
|
400
|
+
right: get("paddingRight") ?? 0,
|
|
401
|
+
top: get("paddingTop") ?? 0,
|
|
402
|
+
bottom: get("paddingBottom") ?? 0
|
|
403
|
+
};
|
|
404
|
+
if (p.has("gap")) layout.childGap = get("gap");
|
|
405
|
+
const column = get("flexDirection") === "column";
|
|
406
|
+
if (p.has("flexDirection")) layout.layoutDirection = column ? "TOP_TO_BOTTOM" : "LEFT_TO_RIGHT";
|
|
407
|
+
const main = get("justifyContent"), cross = get("alignItems");
|
|
408
|
+
if (main !== void 0 || cross !== void 0) {
|
|
409
|
+
const [x, y] = column ? [cross, main] : [main, cross];
|
|
410
|
+
layout.childAlignment = {
|
|
411
|
+
...x !== void 0 && { x: X[edge(x)] },
|
|
412
|
+
...y !== void 0 && { y: Y[edge(y)] }
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
if (Object.keys(layout).length) out.layout = layout;
|
|
416
|
+
if (p.has("backgroundColor")) out.backgroundColor = colourOf("backgroundColor");
|
|
417
|
+
if (RADIUS.some((k) => p.has(k))) out.cornerRadius = Object.fromEntries(RADIUS.map((k) => [k, get(k) ?? 0]));
|
|
418
|
+
if (BORDER.some((k) => p.has(k)) || p.has("borderColor")) out.border = {
|
|
419
|
+
...p.has("borderColor") && { color: colourOf("borderColor") },
|
|
420
|
+
width: {
|
|
421
|
+
left: get("borderLeft") ?? 0,
|
|
422
|
+
right: get("borderRight") ?? 0,
|
|
423
|
+
top: get("borderTop") ?? 0,
|
|
424
|
+
bottom: get("borderBottom") ?? 0
|
|
425
|
+
}
|
|
426
|
+
};
|
|
427
|
+
if (p.has("overflow")) out.clip = get("overflow") === "hidden" ? HIDDEN : VISIBLE;
|
|
428
|
+
if (FLOATING.some((k) => p.has(k))) out.floating = floatingOf(p);
|
|
429
|
+
if (p.has("imageSrc")) out.image = { imageData: get("imageSrc") };
|
|
430
|
+
if (p.get("aspectRatio")) out.aspectRatio = { aspectRatio: get("aspectRatio") };
|
|
431
|
+
const text = {};
|
|
432
|
+
if (p.has("color")) text.textColor = colourOf("color");
|
|
433
|
+
for (const k of [
|
|
434
|
+
"fontId",
|
|
435
|
+
"fontSize",
|
|
436
|
+
"letterSpacing",
|
|
437
|
+
"lineHeight"
|
|
438
|
+
]) if (p.has(k)) text[k] = get(k);
|
|
439
|
+
if (p.has("textAlign")) text.textAlignment = String(get("textAlign")).toUpperCase();
|
|
440
|
+
const wrap = get("whiteSpace");
|
|
441
|
+
if (wrap !== void 0) text.wrapMode = wrap === "nowrap" ? "NONE" : wrap === "pre-line" ? "NEWLINES" : "WORDS";
|
|
442
|
+
if (Object.keys(text).length) out.text = text;
|
|
443
|
+
return out;
|
|
444
|
+
};
|
|
445
|
+
const HIDDEN = {
|
|
446
|
+
horizontal: 1,
|
|
447
|
+
vertical: 1
|
|
448
|
+
};
|
|
449
|
+
const VISIBLE = {
|
|
450
|
+
horizontal: 0,
|
|
451
|
+
vertical: 0
|
|
452
|
+
};
|
|
453
|
+
const isLeaf = (v) => typeof v !== "object" || Object.hasOwn(v, "r") || Object.hasOwn(v, "type");
|
|
454
|
+
const pick = (full, mask) => Object.fromEntries(Object.keys(mask).map((k) => [k, isLeaf(mask[k]) ? full[k] : pick(full[k], mask[k])]));
|
|
455
|
+
const diff = (a, b) => {
|
|
456
|
+
const out = {};
|
|
457
|
+
for (const [k, v] of Object.entries(a)) if (isLeaf(v)) {
|
|
458
|
+
if (Formatter.formatJson(v) !== Formatter.formatJson(b[k])) out[k] = v;
|
|
459
|
+
} else {
|
|
460
|
+
const d = diff(v, b[k]);
|
|
461
|
+
if (Object.keys(d).length) out[k] = d;
|
|
462
|
+
}
|
|
463
|
+
return out;
|
|
464
|
+
};
|
|
465
|
+
const merge = (a, b) => {
|
|
466
|
+
const out = { ...a };
|
|
467
|
+
for (const [k, v] of Object.entries(b)) out[k] = isLeaf(v) || out[k] === void 0 ? v : merge(out[k], v);
|
|
468
|
+
return out;
|
|
469
|
+
};
|
|
470
|
+
const literalOf = (n, values) => {
|
|
471
|
+
const base = n.__clay.filter((e) => !e[2]);
|
|
472
|
+
const out = shapeOf(base, values);
|
|
473
|
+
for (const s of STATES) {
|
|
474
|
+
const own = n.__clay.filter((e) => e[2] === s);
|
|
475
|
+
if (!own.length) continue;
|
|
476
|
+
const mask = shapeOf([...base.filter((e) => e[0] === "flexDirection"), ...own], values);
|
|
477
|
+
const overlay = pick(shapeOf([...base, ...own], values), mask);
|
|
478
|
+
const layout = overlay.layout;
|
|
479
|
+
if (layout && !own.some((e) => e[0] === "flexDirection")) {
|
|
480
|
+
delete layout.layoutDirection;
|
|
481
|
+
if (!Object.keys(layout).length) delete overlay.layout;
|
|
482
|
+
}
|
|
483
|
+
out[s] = overlay;
|
|
484
|
+
}
|
|
485
|
+
return out;
|
|
486
|
+
};
|
|
487
|
+
const replacement = (n) => {
|
|
488
|
+
const out = literalOf(n);
|
|
489
|
+
if (!n.__clay.some(([k, v]) => COLOURS.has(k) && String(v).includes("var("))) return out;
|
|
490
|
+
const themes = {};
|
|
491
|
+
for (const { label, values } of together({
|
|
492
|
+
themed: tables.themed,
|
|
493
|
+
layers: registry.layers
|
|
494
|
+
})) {
|
|
495
|
+
const d = diff(literalOf(n, values), out);
|
|
496
|
+
if (Object.keys(d).length) themes[label] = d;
|
|
497
|
+
}
|
|
498
|
+
if (Object.keys(themes).length) out.themes = themes;
|
|
499
|
+
return out;
|
|
500
|
+
};
|
|
501
|
+
registry.clay = (v) => {
|
|
502
|
+
if (Predicate.hasProperty(v, "__fonts")) return `(${Formatter.formatJson({ fonts: v.__fonts })})`;
|
|
503
|
+
return isClay(v) ? `(${Formatter.formatJson(replacement(v))})` : void 0;
|
|
504
|
+
};
|
|
505
|
+
const ENUM = {
|
|
506
|
+
type: (v) => `CLAY__SIZING_TYPE_${v}`,
|
|
507
|
+
layoutDirection: (v) => `CLAY_${v}`,
|
|
508
|
+
x: (v) => `CLAY_ALIGN_X_${v}`,
|
|
509
|
+
y: (v) => `CLAY_ALIGN_Y_${v}`,
|
|
510
|
+
textAlignment: (v) => `CLAY_TEXT_ALIGN_${v}`,
|
|
511
|
+
wrapMode: (v) => `CLAY_TEXT_WRAP_${v}`,
|
|
512
|
+
element: (v) => `CLAY_ATTACH_POINT_${v}`,
|
|
513
|
+
parent: (v) => `CLAY_ATTACH_POINT_${v}`,
|
|
514
|
+
pointerCaptureMode: (v) => `CLAY_POINTER_CAPTURE_MODE_${v}`,
|
|
515
|
+
attachTo: (v) => `CLAY_ATTACH_TO_${v}`,
|
|
516
|
+
clipTo: (v) => `CLAY_CLIP_TO_${v}`
|
|
517
|
+
};
|
|
518
|
+
const cString = (s) => `"${s.replace(/[\\"]/g, "\\$&")}"`;
|
|
519
|
+
const c = (key, v) => {
|
|
520
|
+
if (typeof v === "number") return key === "parentId" ? `${v}u` : String(v);
|
|
521
|
+
if (typeof v === "string") return key === "imageData" ? `(void *)${cString(v)}` : ENUM[key](v);
|
|
522
|
+
if (v.type !== void 0) return `{ .size = { ${v.percent !== void 0 ? `.percent = ${c("", v.percent)}` : `.minMax = { ${c("", v.min ?? 0)}, ${c("", v.max ?? 0)} }`} }, .type = ${c("type", v.type)} }`;
|
|
523
|
+
return `{ ${Object.entries(v).map(([k, x]) => `.${k} = ${c(k, x)}`).join(", ")} }`;
|
|
524
|
+
};
|
|
525
|
+
const SHAPE = /* @__PURE__ */ new Set([
|
|
526
|
+
"layout",
|
|
527
|
+
"backgroundColor",
|
|
528
|
+
"cornerRadius",
|
|
529
|
+
"border",
|
|
530
|
+
"clip",
|
|
531
|
+
"floating",
|
|
532
|
+
"image",
|
|
533
|
+
"aspectRatio",
|
|
534
|
+
"text",
|
|
535
|
+
"themes",
|
|
536
|
+
...STATES
|
|
537
|
+
]);
|
|
538
|
+
const isShape = (v) => !!v && typeof v === "object" && Object.keys(v).every((k) => SHAPE.has(k)) && !Formatter.formatJson(v).includes("\"var(");
|
|
539
|
+
/**
|
|
540
|
+
* The styles of a module as C: a `Clay_ElementDeclaration` per export, and a `Clay_TextElementConfig` named
|
|
541
|
+
* `<name>_text` for one that sets text props, for `CLAY(id, name)` and `CLAY_TEXT(s, name_text)`. A state is a whole
|
|
542
|
+
* declaration of its own, `<name>_hover` (`_focus`, `_active`, and `<name>_hover_text`); a theme is a whole set of
|
|
543
|
+
* them again, its name last (`<name>_<theme>`, `<name>_hover_<theme>`, `<name>_text_<theme>`), for every style once
|
|
544
|
+
* the module has a theme, so a page picks a theme by appending its name. The fonts of `fonts()` are an enum, `<name>_<font>`, in their order.
|
|
545
|
+
*
|
|
546
|
+
* @param {Record<string, unknown>} styles the exports of a built module of cssints/clay styles
|
|
547
|
+
* @returns {string} a C header that includes clay.h
|
|
548
|
+
*/
|
|
549
|
+
const header = (styles) => {
|
|
550
|
+
const lines = [
|
|
551
|
+
"// Generated by cssints/clay. Do not edit.",
|
|
552
|
+
"#pragma once",
|
|
553
|
+
"",
|
|
554
|
+
"#include \"clay.h\"",
|
|
555
|
+
""
|
|
556
|
+
];
|
|
557
|
+
const print = (name, all, theme = "") => {
|
|
558
|
+
const { themes: _, ...v } = all;
|
|
559
|
+
const base = Object.fromEntries(Object.entries(v).filter(([k]) => !STATES.includes(k)));
|
|
560
|
+
for (const [suffix, shape] of [["", base], ...STATES.flatMap((s) => v[s] ? [[`_${s.slice(1)}`, merge(base, v[s])]] : [])]) {
|
|
561
|
+
const { text, ...decl } = shape;
|
|
562
|
+
if (Object.keys(decl).length) lines.push(`static const Clay_ElementDeclaration ${name}${suffix}${theme} = ${c("", decl)};`);
|
|
563
|
+
if (text) lines.push(`static const Clay_TextElementConfig ${name}${suffix}_text${theme} = ${c("", text)};`);
|
|
564
|
+
}
|
|
565
|
+
};
|
|
566
|
+
const shapes = Object.entries(styles).filter((e) => isShape(e[1]));
|
|
567
|
+
for (const [name, v] of Object.entries(styles)) if (Predicate.hasProperty(v, "fonts") && Array.isArray(v.fonts) && Object.keys(v).length === 1) lines.push(`enum { ${v.fonts.map((f, i) => `${name}_${String(f)} = ${i}`).join(", ")} };`);
|
|
568
|
+
for (const [name, v] of shapes) print(name, v);
|
|
569
|
+
const names = [...new Set(shapes.flatMap(([, v]) => Object.keys(v.themes ?? {})))];
|
|
570
|
+
for (const theme of names) {
|
|
571
|
+
lines.push("", `// theme ${theme}`);
|
|
572
|
+
for (const [name, v] of shapes) print(name, merge(v, v.themes?.[theme] ?? {}), `_${theme}`);
|
|
573
|
+
}
|
|
574
|
+
return `${lines.join("\n")}\n`;
|
|
575
|
+
};
|
|
576
|
+
//#endregion
|
|
577
|
+
export { active, alignItems, backgroundColor, bg, border, borderColor, borderRadius, borderWidth, cn, color, createGlobalTheme, createTokens, flexDirection, float, focus, fontSize, fonts, gap, header, height, hover, image, justifyContent, letterSpacing, lineHeight, overflow, p, padding, paddingBlock, paddingBottom, paddingInline, paddingLeft, paddingRight, paddingTop, pb, pl, pr, pt, textAlign, whiteSpace, width };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as registry, d as MacroError, o as warn } from "./registry-
|
|
2
|
-
import { l as layerStatements } from "./sheet-
|
|
1
|
+
import { a as registry, d as MacroError, o as warn } from "./registry-ByrYF2v5.mjs";
|
|
2
|
+
import { l as layerStatements } from "./sheet-BT2R1wk_.mjs";
|
|
3
3
|
import { Effect } from "effect";
|
|
4
4
|
//#region src/contrast.ts
|
|
5
5
|
const VAR = /var\((--[^\s,)]+)\)/g;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./theme-types-BY0mRf3K.mjs";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $p as Fn, Qp as CheckMath, Xp as Arg, Zp as CheckFn, am as Fallback, cm as Text, em as Result, om as Part, rm as Check, sm as Style, tm as Text$1 } from "./theme-types-
|
|
1
|
+
import { $p as Fn, Qp as CheckMath, Xp as Arg, Zp as CheckFn, am as Fallback, cm as Text, em as Result, om as Part, rm as Check, sm as Style, tm as Text$1 } from "./theme-types-BY0mRf3K.mjs";
|
|
2
2
|
import { properties } from "@cssints/css-grammar/mdn";
|
|
3
3
|
import { CSSStyleValue } from "@cssints/css-grammar/values";
|
|
4
4
|
import { QueryKind, ValidQuery } from "@cssints/css-grammar/query";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { A as Wrap, C as Keyframes, D as QueryWrap, F as cv, H as style, I as firstThatWorks, J as FlexMethods, K as within, L as global, M as cn, O as StateWrap, R as group, S as CvValue, T as PositionTry, W as token, _ as CSSStyleValue, a as DtcgUnit, am as Fallback, b as CvConfig, c as Tokens, d as createTokens, f as layers, g as CSSImageValue, h as CSSColorValue, i as DtcgShadow, j as attr, k as Steps, l as check, m as CSS, n as DtcgColor, o as DtcgValue, om as Part, p as AttrOp, q as ClassValue, r as DtcgCubicBezier, s as Overrides, sm as Style, t as CheckOverrides, u as createGlobalTheme, v as CSSUnitValue, x as CvProps, z as keyframes } from "../../theme-types-
|
|
2
|
-
import { a as GProp, r as GLayout, t as GCondition } from "../../group-types-
|
|
3
|
-
import "../../group-common-
|
|
1
|
+
import { A as Wrap, C as Keyframes, D as QueryWrap, F as cv, H as style, I as firstThatWorks, J as FlexMethods, K as within, L as global, M as cn, O as StateWrap, R as group, S as CvValue, T as PositionTry, W as token, _ as CSSStyleValue, a as DtcgUnit, am as Fallback, b as CvConfig, c as Tokens, d as createTokens, f as layers, g as CSSImageValue, h as CSSColorValue, i as DtcgShadow, j as attr, k as Steps, l as check, m as CSS, n as DtcgColor, o as DtcgValue, om as Part, p as AttrOp, q as ClassValue, r as DtcgCubicBezier, s as Overrides, sm as Style, t as CheckOverrides, u as createGlobalTheme, v as CSSUnitValue, x as CvProps, z as keyframes } from "../../theme-types-BY0mRf3K.mjs";
|
|
2
|
+
import { a as GProp, r as GLayout, t as GCondition } from "../../group-types-Dn9CIR8J.mjs";
|
|
3
|
+
import "../../group-common-3PAVTxpd.mjs";
|
|
4
4
|
import { active, alignContent, alignItems, alignSelf, animation, animationDelay, animationDirection, animationDuration, animationFillMode, animationIterationCount, animationName, animationPlayState, animationTimingFunction, attrFn, backgroundAttachment, backgroundClip, backgroundColor, backgroundImage, backgroundOrigin, backgroundPosition, backgroundRepeat, backgroundSize, bg, border, borderBottom, borderBottomColor, borderBottomLeftRadius, borderBottomRightRadius, borderBottomStyle, borderBottomWidth, borderCollapse, borderColor, borderImage, borderImageOutset, borderImageSlice, borderImageSource, borderImageWidth, borderLeft, borderLeftColor, borderLeftStyle, borderLeftWidth, borderRadius, borderRight, borderRightColor, borderRightStyle, borderRightWidth, borderSpacing, borderStyle, borderTop, borderTopColor, borderTopLeftRadius, borderTopRightRadius, borderTopStyle, borderTopWidth, borderWidth, bottom, boxShadow, boxSizing, calc, captionSide, checked, clear, color, colorFn, columnGap, content, counter, counterIncrement, counterReset, counters, cubicBezier, direction, disabled, display, empty, emptyCells, enabled, firstChild, firstOfType, flexBasis, flexDirection, flexGrow, flexShrink, flexWrap, float, floodColor, floodOpacity, focus, font, fontFamily, fontSize, fontStyle, fontWeight, height, hover, hsl, hsla, image, inRange, indeterminate, invalid, justifyContent, lastChild, lastOfType, left, letterSpacing, lightingColor, lineHeight, linearGradient, link, listStyle, listStyleImage, listStylePosition, listStyleType, m, margin, marginBottom, marginLeft, marginRight, marginTop, matrix, matrix3d, maxHeight, maxWidth, mb, minHeight, minWidth, ml, mr, mt, onlyChild, onlyOfType, opacity, optional, order, outOfRange, outlineColor, outlineStyle, outlineWidth, overflow, overflowX, overflowY, p, padding, paddingBottom, paddingLeft, paddingRight, paddingTop, pb, perspective, perspectiveFn, perspectiveOrigin, pl, pointerEvents, position, pr, pt, quotes, radialGradient, repeatingLinearGradient, repeatingRadialGradient, required, rgb, rgba, right, root, rotate3d, rotateFn, rotateX, rotateY, rotateZ, scale3d, scaleFn, scaleX, scaleY, scaleZ, skew, skewX, skewY, steps, supports, tableLayout, target, textAlign, textIndent, textOverflow, textShadow, textTransform, top, transform, transformOrigin, transformStyle, transition, transitionDelay, transitionDuration, transitionProperty, transitionTimingFunction, translate3d, translateFn, translateX, translateY, translateZ, unicodeBidi, url, valid, verticalAlign, visibility, visited, width, wordBreak, wordSpacing, zIndex } from "../baseline-2015.mjs";
|
|
5
5
|
import { properties } from "@cssints/css-grammar/mdn";
|
|
6
6
|
//#region src/groups/baseline-2015/with-downstream.d.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { A as Wrap, C as Keyframes, D as QueryWrap, F as cv, H as style, I as firstThatWorks, J as FlexMethods, K as within, L as global, M as cn, O as StateWrap, R as group, S as CvValue, T as PositionTry, W as token, _ as CSSStyleValue, a as DtcgUnit, am as Fallback, b as CvConfig, c as Tokens, d as createTokens, f as layers, g as CSSImageValue, h as CSSColorValue, i as DtcgShadow, j as attr, k as Steps, l as check, m as CSS, n as DtcgColor, o as DtcgValue, om as Part, p as AttrOp, q as ClassValue, r as DtcgCubicBezier, s as Overrides, sm as Style, t as CheckOverrides, u as createGlobalTheme, v as CSSUnitValue, x as CvProps, z as keyframes } from "../theme-types-
|
|
2
|
-
import { a as GProp, i as GMath, n as GFn, r as GLayout, t as GCondition } from "../group-types-
|
|
3
|
-
import "../group-common-
|
|
1
|
+
import { A as Wrap, C as Keyframes, D as QueryWrap, F as cv, H as style, I as firstThatWorks, J as FlexMethods, K as within, L as global, M as cn, O as StateWrap, R as group, S as CvValue, T as PositionTry, W as token, _ as CSSStyleValue, a as DtcgUnit, am as Fallback, b as CvConfig, c as Tokens, d as createTokens, f as layers, g as CSSImageValue, h as CSSColorValue, i as DtcgShadow, j as attr, k as Steps, l as check, m as CSS, n as DtcgColor, o as DtcgValue, om as Part, p as AttrOp, q as ClassValue, r as DtcgCubicBezier, s as Overrides, sm as Style, t as CheckOverrides, u as createGlobalTheme, v as CSSUnitValue, x as CvProps, z as keyframes } from "../theme-types-BY0mRf3K.mjs";
|
|
2
|
+
import { a as GProp, i as GMath, n as GFn, r as GLayout, t as GCondition } from "../group-types-Dn9CIR8J.mjs";
|
|
3
|
+
import "../group-common-3PAVTxpd.mjs";
|
|
4
4
|
import { properties } from "@cssints/css-grammar/mdn";
|
|
5
5
|
//#region src/groups/baseline-2015.d.ts
|
|
6
6
|
type B = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { A as Wrap, C as Keyframes, D as QueryWrap, F as cv, H as style, I as firstThatWorks, J as FlexMethods, K as within, L as global, M as cn, O as StateWrap, R as group, S as CvValue, T as PositionTry, W as token, _ as CSSStyleValue, a as DtcgUnit, am as Fallback, b as CvConfig, c as Tokens, d as createTokens, f as layers, g as CSSImageValue, h as CSSColorValue, i as DtcgShadow, j as attr, k as Steps, l as check, m as CSS, n as DtcgColor, o as DtcgValue, om as Part, p as AttrOp, q as ClassValue, r as DtcgCubicBezier, s as Overrides, sm as Style, t as CheckOverrides, u as createGlobalTheme, v as CSSUnitValue, x as CvProps, z as keyframes } from "../../theme-types-
|
|
2
|
-
import { a as GProp, r as GLayout, t as GCondition } from "../../group-types-
|
|
3
|
-
import "../../group-common-
|
|
1
|
+
import { A as Wrap, C as Keyframes, D as QueryWrap, F as cv, H as style, I as firstThatWorks, J as FlexMethods, K as within, L as global, M as cn, O as StateWrap, R as group, S as CvValue, T as PositionTry, W as token, _ as CSSStyleValue, a as DtcgUnit, am as Fallback, b as CvConfig, c as Tokens, d as createTokens, f as layers, g as CSSImageValue, h as CSSColorValue, i as DtcgShadow, j as attr, k as Steps, l as check, m as CSS, n as DtcgColor, o as DtcgValue, om as Part, p as AttrOp, q as ClassValue, r as DtcgCubicBezier, s as Overrides, sm as Style, t as CheckOverrides, u as createGlobalTheme, v as CSSUnitValue, x as CvProps, z as keyframes } from "../../theme-types-BY0mRf3K.mjs";
|
|
2
|
+
import { a as GProp, r as GLayout, t as GCondition } from "../../group-types-Dn9CIR8J.mjs";
|
|
3
|
+
import "../../group-common-3PAVTxpd.mjs";
|
|
4
4
|
import { WebkitTextFillColor, active, alignContent, alignItems, alignSelf, animation, animationDelay, animationDirection, animationDuration, animationFillMode, animationIterationCount, animationName, animationPlayState, animationTimingFunction, attrFn, backgroundAttachment, backgroundClip, backgroundColor, backgroundImage, backgroundOrigin, backgroundPosition, backgroundRepeat, backgroundSize, bg, blur, border, borderBottom, borderBottomColor, borderBottomLeftRadius, borderBottomRightRadius, borderBottomStyle, borderBottomWidth, borderCollapse, borderColor, borderImage, borderImageOutset, borderImageRepeat, borderImageSlice, borderImageSource, borderImageWidth, borderLeft, borderLeftColor, borderLeftStyle, borderLeftWidth, borderRadius, borderRight, borderRightColor, borderRightStyle, borderRightWidth, borderSpacing, borderStyle, borderTop, borderTopColor, borderTopLeftRadius, borderTopRightRadius, borderTopStyle, borderTopWidth, borderWidth, bottom, boxShadow, boxSizing, brightness, calc, captionSide, checked, clear, color, colorFn, columnGap, columnWidth, content, contrast, counter, counterIncrement, counterReset, counters, cubicBezier, direction, disabled, display, dropShadow, empty, emptyCells, enabled, filter, firstChild, firstOfType, flexBasis, flexDirection, flexGrow, flexShrink, flexWrap, float, floodColor, floodOpacity, focus, font, fontFamily, fontSize, fontStyle, fontWeight, grayscale, height, hover, hsl, hsla, hueRotate, image, inRange, indeterminate, invalid, invert, justifyContent, justifyItems, lastChild, lastOfType, left, letterSpacing, lightingColor, lineHeight, linearGradient, link, listStyle, listStyleImage, listStylePosition, listStyleType, m, margin, marginBottom, marginLeft, marginRight, marginTop, matrix, matrix3d, maxHeight, maxWidth, mb, minHeight, minWidth, ml, mr, mt, onlyChild, onlyOfType, opacity, opacityFn, optional, order, outOfRange, outlineColor, outlineStyle, outlineWidth, overflow, overflowX, overflowY, p, padding, paddingBottom, paddingLeft, paddingRight, paddingTop, pb, perspective, perspectiveFn, perspectiveOrigin, pl, pointerEvents, position, pr, pt, quotes, radialGradient, repeatingLinearGradient, repeatingRadialGradient, required, rgb, rgba, right, root, rotate3d, rotateFn, rotateX, rotateY, rotateZ, saturate, scale3d, scaleFn, scaleX, scaleY, scaleZ, sepia, skew, skewX, skewY, steps, supports, tableLayout, target, textAlign, textAnchor, textIndent, textOverflow, textShadow, textTransform, top, transform, transformOrigin, transformStyle, transition, transitionDelay, transitionDuration, transitionProperty, transitionTimingFunction, translate3d, translateFn, translateX, translateY, translateZ, unicodeBidi, url, valid, verticalAlign, visibility, visited, width, wordBreak, wordSpacing, zIndex } from "../baseline-2016.mjs";
|
|
5
5
|
import { properties } from "@cssints/css-grammar/mdn";
|
|
6
6
|
//#region src/groups/baseline-2016/with-downstream.d.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { A as Wrap, C as Keyframes, D as QueryWrap, F as cv, H as style, I as firstThatWorks, J as FlexMethods, K as within, L as global, M as cn, O as StateWrap, R as group, S as CvValue, T as PositionTry, W as token, _ as CSSStyleValue, a as DtcgUnit, am as Fallback, b as CvConfig, c as Tokens, d as createTokens, f as layers, g as CSSImageValue, h as CSSColorValue, i as DtcgShadow, j as attr, k as Steps, l as check, m as CSS, n as DtcgColor, o as DtcgValue, om as Part, p as AttrOp, q as ClassValue, r as DtcgCubicBezier, s as Overrides, sm as Style, t as CheckOverrides, u as createGlobalTheme, v as CSSUnitValue, x as CvProps, z as keyframes } from "../theme-types-
|
|
2
|
-
import { a as GProp, i as GMath, n as GFn, r as GLayout, t as GCondition } from "../group-types-
|
|
3
|
-
import "../group-common-
|
|
1
|
+
import { A as Wrap, C as Keyframes, D as QueryWrap, F as cv, H as style, I as firstThatWorks, J as FlexMethods, K as within, L as global, M as cn, O as StateWrap, R as group, S as CvValue, T as PositionTry, W as token, _ as CSSStyleValue, a as DtcgUnit, am as Fallback, b as CvConfig, c as Tokens, d as createTokens, f as layers, g as CSSImageValue, h as CSSColorValue, i as DtcgShadow, j as attr, k as Steps, l as check, m as CSS, n as DtcgColor, o as DtcgValue, om as Part, p as AttrOp, q as ClassValue, r as DtcgCubicBezier, s as Overrides, sm as Style, t as CheckOverrides, u as createGlobalTheme, v as CSSUnitValue, x as CvProps, z as keyframes } from "../theme-types-BY0mRf3K.mjs";
|
|
2
|
+
import { a as GProp, i as GMath, n as GFn, r as GLayout, t as GCondition } from "../group-types-Dn9CIR8J.mjs";
|
|
3
|
+
import "../group-common-3PAVTxpd.mjs";
|
|
4
4
|
import { properties } from "@cssints/css-grammar/mdn";
|
|
5
5
|
//#region src/groups/baseline-2016.d.ts
|
|
6
6
|
type B = {
|