cssints 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +178 -2
- package/dist/author-types-C1AhsnrT.d.mts +80 -0
- package/dist/check.d.mts +22 -0
- package/dist/check.mjs +37 -0
- package/dist/color-BYIxVLlS.mjs +29 -0
- package/dist/color-C8OzjAeg.mjs +2 -0
- package/dist/contrast-BUKVao74.mjs +83 -0
- package/dist/derived.d.mts +14 -0
- package/dist/derived.mjs +391 -0
- package/dist/errors-D4ZbcwRo.d.mts +32 -0
- package/dist/frame-BoBKjgBB.mjs +92 -0
- package/dist/frame.d.mts +72 -0
- package/dist/frame.mjs +2 -0
- package/dist/index.d.mts +34 -0
- package/dist/index.mjs +1132 -0
- package/dist/instrument-Bdtk2INz.mjs +172 -0
- package/dist/lib-2OEIfPAE.d.mts +9 -0
- package/dist/lowered-CeoXbm0P.mjs +28 -0
- package/dist/node-CdhAGmF3.d.mts +229 -0
- package/dist/parent-vars.d.mts +13 -0
- package/dist/parent-vars.mjs +65 -0
- package/dist/plugin-types.d.mts +377 -0
- package/dist/plugin.d.mts +3 -0
- package/dist/plugin.mjs +30 -0
- package/dist/registry-n9JCX4pl.mjs +72 -0
- package/dist/runtime-CTvuM-Hm.d.mts +5 -0
- package/dist/runtime.d.mts +18 -0
- package/dist/runtime.mjs +21 -0
- package/dist/scope-oWEaWE9n.d.mts +2095 -0
- package/dist/sheet-CO7a-mdA.mjs +756 -0
- package/dist/surface.d.mts +228 -0
- package/dist/surface.mjs +101 -0
- package/dist/theme-BGEbFAYh.mjs +906 -0
- package/dist/theme-types-DHdtTZhz.d.mts +1803 -0
- package/dist/trace-otlp-CbKFDsn9.mjs +14 -0
- package/dist/tui-types.d.mts +181 -0
- package/dist/tui.d.mts +30 -0
- package/dist/tui.mjs +399 -0
- package/dist/types.d.mts +2 -0
- package/dist/vite.d.mts +118 -0
- package/dist/vite.mjs +980 -0
- package/docs/API.md +1148 -0
- package/package.json +81 -4
- package/skills/cssints/SKILL.md +200 -0
- package/skills/cssints/references/errors.md +85 -0
- package/skills/cssints/references/plugins.md +91 -0
- package/skills/cssints/references/tokens.md +91 -0
- package/skills/cssints-plugin/SKILL.md +177 -0
- package/skills/cssints-plugin/references/table.md +124 -0
- package/skills/cssints-plugin/references/testing.md +122 -0
package/dist/derived.mjs
ADDED
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
//#region src/derived.ts
|
|
2
|
+
/** The custom property of :root that carries the data (derived-data.ts writes it). */
|
|
3
|
+
const KEY = "--_derived";
|
|
4
|
+
const mul = (m, v) => [
|
|
5
|
+
0,
|
|
6
|
+
3,
|
|
7
|
+
6
|
|
8
|
+
].map((r) => v.reduce((s, x, k) => s + m[r + k] * x, 0));
|
|
9
|
+
const lin = (c) => {
|
|
10
|
+
const a = Math.abs(c);
|
|
11
|
+
return (a <= .04045 ? a / 12.92 : ((a + .055) / 1.055) ** 2.4) * Math.sign(c);
|
|
12
|
+
};
|
|
13
|
+
const gam = (c) => {
|
|
14
|
+
const a = Math.abs(c);
|
|
15
|
+
return (a <= .0031308 ? a * 12.92 : 1.055 * a ** (1 / 2.4) - .055) * Math.sign(c);
|
|
16
|
+
};
|
|
17
|
+
const rad = Math.PI / 180;
|
|
18
|
+
const rect = ([l, c, h]) => [
|
|
19
|
+
l,
|
|
20
|
+
c * Math.cos(h * rad),
|
|
21
|
+
c * Math.sin(h * rad)
|
|
22
|
+
];
|
|
23
|
+
const polar = ([l, a, b]) => {
|
|
24
|
+
const h = Math.atan2(b, a) / rad;
|
|
25
|
+
return [
|
|
26
|
+
l,
|
|
27
|
+
Math.hypot(a, b),
|
|
28
|
+
h < 0 ? h + 360 : h
|
|
29
|
+
];
|
|
30
|
+
};
|
|
31
|
+
const LMS = [
|
|
32
|
+
.4122214708,
|
|
33
|
+
.5363325363,
|
|
34
|
+
.0514459929,
|
|
35
|
+
.2119034982,
|
|
36
|
+
.6806995451,
|
|
37
|
+
.1073969566,
|
|
38
|
+
.0883024619,
|
|
39
|
+
.2817188376,
|
|
40
|
+
.6299787005
|
|
41
|
+
];
|
|
42
|
+
const OK = [
|
|
43
|
+
.2104542553,
|
|
44
|
+
.793617785,
|
|
45
|
+
-.0040720468,
|
|
46
|
+
1.9779984951,
|
|
47
|
+
-2.428592205,
|
|
48
|
+
.4505937099,
|
|
49
|
+
.0259040371,
|
|
50
|
+
.7827717662,
|
|
51
|
+
-.808675766
|
|
52
|
+
];
|
|
53
|
+
const LMS_I = [
|
|
54
|
+
4.0767416621,
|
|
55
|
+
-3.3077115913,
|
|
56
|
+
.2309699292,
|
|
57
|
+
-1.2684380046,
|
|
58
|
+
2.6097574011,
|
|
59
|
+
-.3413193965,
|
|
60
|
+
-.0041960863,
|
|
61
|
+
-.7034186147,
|
|
62
|
+
1.707614701
|
|
63
|
+
];
|
|
64
|
+
const OK_I = [
|
|
65
|
+
1,
|
|
66
|
+
.3963377774,
|
|
67
|
+
.2158037573,
|
|
68
|
+
1,
|
|
69
|
+
-.1055613458,
|
|
70
|
+
-.0638541728,
|
|
71
|
+
1,
|
|
72
|
+
-.0894841775,
|
|
73
|
+
-1.291485548
|
|
74
|
+
];
|
|
75
|
+
const XYZ = [
|
|
76
|
+
.436065743,
|
|
77
|
+
.385151469,
|
|
78
|
+
.143078454,
|
|
79
|
+
.222493192,
|
|
80
|
+
.716887054,
|
|
81
|
+
.0606197905,
|
|
82
|
+
.0139239045,
|
|
83
|
+
.0970812857,
|
|
84
|
+
.714099358
|
|
85
|
+
];
|
|
86
|
+
const XYZ_I = [
|
|
87
|
+
3.13413576,
|
|
88
|
+
-1.61738568,
|
|
89
|
+
-.49066242,
|
|
90
|
+
-.978795456,
|
|
91
|
+
1.91625419,
|
|
92
|
+
.0334429841,
|
|
93
|
+
.071955413,
|
|
94
|
+
-.228976675,
|
|
95
|
+
1.40538601
|
|
96
|
+
];
|
|
97
|
+
const D50 = [
|
|
98
|
+
.9642956764295677,
|
|
99
|
+
1,
|
|
100
|
+
.8251046025104602
|
|
101
|
+
];
|
|
102
|
+
const E = 216 / 24389;
|
|
103
|
+
const K = 24389 / 27;
|
|
104
|
+
const to = {
|
|
105
|
+
"srgb-linear": (c) => c,
|
|
106
|
+
srgb: (c) => c.map(lin),
|
|
107
|
+
oklab: (c) => mul(LMS_I, mul(OK_I, c).map((v) => v ** 3)),
|
|
108
|
+
oklch: (c) => to.oklab(rect(c)),
|
|
109
|
+
lab: ([l, a, b]) => {
|
|
110
|
+
const y = (l + 16) / 116;
|
|
111
|
+
const f = [
|
|
112
|
+
a / 500 + y,
|
|
113
|
+
y,
|
|
114
|
+
y - b / 200
|
|
115
|
+
];
|
|
116
|
+
return mul(XYZ_I, f.map((v, i) => D50[i] * (v ** 3 > E ? v ** 3 : (116 * v - 16) / K)));
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
const from = {
|
|
120
|
+
"srgb-linear": (c) => c,
|
|
121
|
+
srgb: (c) => c.map(gam),
|
|
122
|
+
oklab: (c) => mul(OK, mul(LMS, c).map(Math.cbrt)),
|
|
123
|
+
oklch: (c) => polar(from.oklab(c)),
|
|
124
|
+
lab: (c) => {
|
|
125
|
+
const f = mul(XYZ, c).map((v, i) => {
|
|
126
|
+
const x = v / D50[i];
|
|
127
|
+
return x > E ? Math.cbrt(x) : (K * x + 16) / 116;
|
|
128
|
+
});
|
|
129
|
+
return [
|
|
130
|
+
116 * f[1] - 16,
|
|
131
|
+
500 * (f[0] - f[1]),
|
|
132
|
+
200 * (f[1] - f[2])
|
|
133
|
+
];
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
const conv = (c, s) => c.s === s ? c : {
|
|
137
|
+
s,
|
|
138
|
+
c: from[s](to[c.s](c.c)),
|
|
139
|
+
a: c.a
|
|
140
|
+
};
|
|
141
|
+
const SPEC = {
|
|
142
|
+
srgb: ["rgb", [
|
|
143
|
+
1,
|
|
144
|
+
1,
|
|
145
|
+
1
|
|
146
|
+
]],
|
|
147
|
+
"srgb-linear": ["rgb", [
|
|
148
|
+
1,
|
|
149
|
+
1,
|
|
150
|
+
1
|
|
151
|
+
]],
|
|
152
|
+
oklab: ["lab", [
|
|
153
|
+
1,
|
|
154
|
+
.4,
|
|
155
|
+
.4
|
|
156
|
+
]],
|
|
157
|
+
oklch: ["lch", [
|
|
158
|
+
1,
|
|
159
|
+
.4,
|
|
160
|
+
360
|
|
161
|
+
]],
|
|
162
|
+
lab: ["lab", [
|
|
163
|
+
100,
|
|
164
|
+
125,
|
|
165
|
+
125
|
|
166
|
+
]]
|
|
167
|
+
};
|
|
168
|
+
const NAMED = {
|
|
169
|
+
black: "#000",
|
|
170
|
+
white: "#fff",
|
|
171
|
+
transparent: "#0000"
|
|
172
|
+
};
|
|
173
|
+
const TOKEN = /[+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?(?:%|deg)?|#\w+|(?:--|-?)[a-z_][\w-]*|[^\s]/gi;
|
|
174
|
+
const fail = (x) => {
|
|
175
|
+
throw new Error(x);
|
|
176
|
+
};
|
|
177
|
+
const hex = (x) => {
|
|
178
|
+
const h = x.slice(1);
|
|
179
|
+
if (![
|
|
180
|
+
3,
|
|
181
|
+
4,
|
|
182
|
+
6,
|
|
183
|
+
8
|
|
184
|
+
].includes(h.length) || /[^\da-f]/i.test(h)) return fail(x);
|
|
185
|
+
const n = h.length < 5 ? h.replace(/./g, "$&$&") : h;
|
|
186
|
+
const byte = (i) => parseInt(n.slice(i, i + 2), 16) / 255;
|
|
187
|
+
return {
|
|
188
|
+
s: "srgb",
|
|
189
|
+
c: [
|
|
190
|
+
byte(0),
|
|
191
|
+
byte(2),
|
|
192
|
+
byte(4)
|
|
193
|
+
],
|
|
194
|
+
a: n.length > 6 ? byte(6) : 1
|
|
195
|
+
};
|
|
196
|
+
};
|
|
197
|
+
const evaluate = (text, get = (n) => fail(n)) => {
|
|
198
|
+
const t = text.match(TOKEN) ?? [];
|
|
199
|
+
let i = 0;
|
|
200
|
+
let pct = 1;
|
|
201
|
+
let env = {};
|
|
202
|
+
const next = () => t[i++] ?? fail(t[i - 2]);
|
|
203
|
+
const want = (s) => {
|
|
204
|
+
if (next() !== s) fail(t[i - 1]);
|
|
205
|
+
};
|
|
206
|
+
const input = () => {
|
|
207
|
+
want("(");
|
|
208
|
+
const v = get(next());
|
|
209
|
+
want(")");
|
|
210
|
+
return v;
|
|
211
|
+
};
|
|
212
|
+
const list = () => {
|
|
213
|
+
want("(");
|
|
214
|
+
const out = [sum()];
|
|
215
|
+
while (t[i] === ",") {
|
|
216
|
+
i++;
|
|
217
|
+
out.push(sum());
|
|
218
|
+
}
|
|
219
|
+
want(")");
|
|
220
|
+
return out;
|
|
221
|
+
};
|
|
222
|
+
const atom = () => {
|
|
223
|
+
const x = next();
|
|
224
|
+
if (/^[+-]?[\d.]/.test(x)) return parseFloat(x) * (x.endsWith("%") ? pct / 100 : 1);
|
|
225
|
+
if (x === "(") {
|
|
226
|
+
const v = sum();
|
|
227
|
+
want(")");
|
|
228
|
+
return v;
|
|
229
|
+
}
|
|
230
|
+
if (x === "calc") return atom();
|
|
231
|
+
if (x === "-") return -atom();
|
|
232
|
+
if (x === "clamp") {
|
|
233
|
+
const [lo, v, hi] = list();
|
|
234
|
+
return Math.max(lo, Math.min(v, hi));
|
|
235
|
+
}
|
|
236
|
+
if (x === "min") return Math.min(...list());
|
|
237
|
+
if (x === "max") return Math.max(...list());
|
|
238
|
+
if (x === "var") {
|
|
239
|
+
const v = input();
|
|
240
|
+
return typeof v === "string" && v ? Number(v) : fail(x);
|
|
241
|
+
}
|
|
242
|
+
if (x === "none") return 0;
|
|
243
|
+
return Object.hasOwn(env, x) ? env[x] : fail(x);
|
|
244
|
+
};
|
|
245
|
+
const prod = () => {
|
|
246
|
+
let v = atom();
|
|
247
|
+
for (let o = t[i]; o === "*" || o === "/"; o = t[i]) {
|
|
248
|
+
i++;
|
|
249
|
+
v = o === "*" ? v * atom() : v / atom();
|
|
250
|
+
}
|
|
251
|
+
return v;
|
|
252
|
+
};
|
|
253
|
+
const sum = () => {
|
|
254
|
+
let v = prod();
|
|
255
|
+
for (let o = t[i]; o === "+" || o === "-"; o = t[i]) {
|
|
256
|
+
i++;
|
|
257
|
+
v += o === "+" ? prod() : -prod();
|
|
258
|
+
}
|
|
259
|
+
return v;
|
|
260
|
+
};
|
|
261
|
+
const fn = (f) => {
|
|
262
|
+
want("(");
|
|
263
|
+
const origin = t[i] === "from" ? (i++, col()) : void 0;
|
|
264
|
+
const space = f === "color" ? next() : f === "rgb" || f === "rgba" ? "srgb" : f;
|
|
265
|
+
if (!Object.hasOwn(SPEC, space)) return fail(f === "color" ? space : f);
|
|
266
|
+
const [names, base] = SPEC[space];
|
|
267
|
+
const k = f[0] === "r" ? 255 : 1;
|
|
268
|
+
const src = origin && conv(origin, space);
|
|
269
|
+
env = src ? {
|
|
270
|
+
alpha: src.a,
|
|
271
|
+
...Object.fromEntries([...names].map((n, j) => [n, src.c[j] * k]))
|
|
272
|
+
} : {};
|
|
273
|
+
const c = base.map((b, j) => {
|
|
274
|
+
if (j && t[i] === ",") i++;
|
|
275
|
+
pct = b * k;
|
|
276
|
+
return atom() / k;
|
|
277
|
+
});
|
|
278
|
+
let a = 1;
|
|
279
|
+
if (t[i] === "/" || t[i] === ",") {
|
|
280
|
+
i++;
|
|
281
|
+
pct = 1;
|
|
282
|
+
a = Math.min(1, Math.max(0, atom()));
|
|
283
|
+
}
|
|
284
|
+
want(")");
|
|
285
|
+
return {
|
|
286
|
+
s: space,
|
|
287
|
+
c,
|
|
288
|
+
a
|
|
289
|
+
};
|
|
290
|
+
};
|
|
291
|
+
const mix = () => {
|
|
292
|
+
want("(");
|
|
293
|
+
want("in");
|
|
294
|
+
const s = next();
|
|
295
|
+
if (s === "oklch" || !Object.hasOwn(SPEC, s)) return fail(s);
|
|
296
|
+
want(",");
|
|
297
|
+
const one = () => {
|
|
298
|
+
return [conv(col(), s), t[i]?.endsWith("%") ? parseFloat(next()) : void 0];
|
|
299
|
+
};
|
|
300
|
+
const [a, p] = one();
|
|
301
|
+
want(",");
|
|
302
|
+
const [b, q] = one();
|
|
303
|
+
want(")");
|
|
304
|
+
const x = p ?? 100 - (q ?? 50);
|
|
305
|
+
const y = q ?? 100 - x;
|
|
306
|
+
if (x + y !== 100) return fail("color-mix");
|
|
307
|
+
const al = (a.a * x + b.a * y) / 100;
|
|
308
|
+
return {
|
|
309
|
+
s,
|
|
310
|
+
c: a.c.map((v, j) => al ? (v * a.a * x + b.c[j] * b.a * y) / 100 / al : 0),
|
|
311
|
+
a: al
|
|
312
|
+
};
|
|
313
|
+
};
|
|
314
|
+
const col = () => {
|
|
315
|
+
const x = next();
|
|
316
|
+
if (x.startsWith("#")) return hex(x);
|
|
317
|
+
if (NAMED[x]) return hex(NAMED[x]);
|
|
318
|
+
if (x === "var") {
|
|
319
|
+
const v = input();
|
|
320
|
+
return typeof v === "string" ? evaluate(v, get) : v;
|
|
321
|
+
}
|
|
322
|
+
return x === "color-mix" ? mix() : fn(x);
|
|
323
|
+
};
|
|
324
|
+
const out = col();
|
|
325
|
+
if (i < t.length) fail(t[i]);
|
|
326
|
+
return out;
|
|
327
|
+
};
|
|
328
|
+
const css = (c) => {
|
|
329
|
+
const [r, g, b] = conv(c, "srgb").c.map((v) => Math.round(Math.min(1, Math.max(0, v)) * 255));
|
|
330
|
+
return `rgb(${r} ${g} ${b}${c.a < 1 ? ` / ${+c.a.toFixed(3)}` : ""})`;
|
|
331
|
+
};
|
|
332
|
+
var derived_default = () => {
|
|
333
|
+
if (typeof document === "undefined") return;
|
|
334
|
+
const root = document.documentElement;
|
|
335
|
+
const cs = getComputedStyle(root);
|
|
336
|
+
const written = /* @__PURE__ */ new Map();
|
|
337
|
+
let observer;
|
|
338
|
+
let raw = "";
|
|
339
|
+
let data;
|
|
340
|
+
let names;
|
|
341
|
+
const read = () => {
|
|
342
|
+
const v = cs.getPropertyValue(KEY).trim();
|
|
343
|
+
if (!v || v === raw) return !!v;
|
|
344
|
+
raw = v;
|
|
345
|
+
data = JSON.parse(v.slice(1, -1).replace(/\\(.)/g, "$1"));
|
|
346
|
+
names = [.../* @__PURE__ */ new Set([...Object.keys(data.b), ...data.t.flatMap(([, x]) => Object.keys(x))])];
|
|
347
|
+
return true;
|
|
348
|
+
};
|
|
349
|
+
const update = () => {
|
|
350
|
+
read();
|
|
351
|
+
const tpl = new Map(Object.entries(data.b));
|
|
352
|
+
for (const [cond, v] of data.t) if (cond.startsWith("@") ? matchMedia(cond.slice(6)).matches : root.matches(cond)) for (const n in v) if (v[n]) tpl.set(n, v[n]);
|
|
353
|
+
else tpl.delete(n);
|
|
354
|
+
for (const n of names) if (!tpl.has(n) && written.delete(n)) root.style.removeProperty(n);
|
|
355
|
+
const done = /* @__PURE__ */ new Map();
|
|
356
|
+
const get = (n) => {
|
|
357
|
+
let v = done.get(n);
|
|
358
|
+
if (v === void 0) {
|
|
359
|
+
const t = tpl.get(n);
|
|
360
|
+
done.set(n, v = t === void 0 ? cs.getPropertyValue(n).trim() || fail(n) : evaluate(t, get));
|
|
361
|
+
}
|
|
362
|
+
return v;
|
|
363
|
+
};
|
|
364
|
+
const next = [...tpl.keys()].map((n) => {
|
|
365
|
+
try {
|
|
366
|
+
return [n, css(get(n))];
|
|
367
|
+
} catch {
|
|
368
|
+
return [n, void 0];
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
for (const [n, v] of next) if (v === void 0) {
|
|
372
|
+
if (written.delete(n)) root.style.removeProperty(n);
|
|
373
|
+
} else if (written.get(n) !== v) {
|
|
374
|
+
written.set(n, v);
|
|
375
|
+
root.style.setProperty(n, v);
|
|
376
|
+
}
|
|
377
|
+
observer.takeRecords();
|
|
378
|
+
};
|
|
379
|
+
const go = () => {
|
|
380
|
+
if (!read()) return false;
|
|
381
|
+
if (data.p.every((p) => CSS.supports("color", p))) return true;
|
|
382
|
+
observer = new MutationObserver(update);
|
|
383
|
+
observer.observe(root, { attributes: true });
|
|
384
|
+
for (const [cond] of data.t) if (cond.startsWith("@")) matchMedia(cond.slice(6)).addEventListener("change", update);
|
|
385
|
+
update();
|
|
386
|
+
return true;
|
|
387
|
+
};
|
|
388
|
+
if (!go()) addEventListener("load", go, { once: true });
|
|
389
|
+
};
|
|
390
|
+
//#endregion
|
|
391
|
+
export { KEY, css, derived_default as default, evaluate };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//#region src/errors.d.ts
|
|
2
|
+
declare const MacroError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
3
|
+
readonly _tag: "MacroError";
|
|
4
|
+
} & Readonly<A>;
|
|
5
|
+
/** A css.* call, cv(), or a value in it is wrong. `file`, `site` (index) and `offset` name the call site, when known. */
|
|
6
|
+
declare class MacroError extends MacroError_base<{
|
|
7
|
+
readonly message: string;
|
|
8
|
+
readonly file?: string;
|
|
9
|
+
readonly site?: number;
|
|
10
|
+
readonly offset?: number;
|
|
11
|
+
readonly cause?: unknown;
|
|
12
|
+
}> {}
|
|
13
|
+
declare const ImportError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
14
|
+
readonly _tag: "ImportError";
|
|
15
|
+
} & Readonly<A>;
|
|
16
|
+
/** `import ... from "cssints"` without the attribute names something that only exists at build time. */
|
|
17
|
+
declare class ImportError extends ImportError_base<{
|
|
18
|
+
readonly message: string;
|
|
19
|
+
readonly file: string;
|
|
20
|
+
readonly offset: number;
|
|
21
|
+
}> {}
|
|
22
|
+
declare const ContrastError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
23
|
+
readonly _tag: "ContrastError";
|
|
24
|
+
} & Readonly<A>;
|
|
25
|
+
/** cssints/check `contrast`: a colour that has no contrast (one it cannot read, or a translucent one). */
|
|
26
|
+
declare class ContrastError extends ContrastError_base<{
|
|
27
|
+
readonly message: string;
|
|
28
|
+
/** The colour as given. */
|
|
29
|
+
readonly colour: string;
|
|
30
|
+
}> {}
|
|
31
|
+
//#endregion
|
|
32
|
+
export { ImportError as n, MacroError as r, ContrastError as t };
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { scope } from "cssints/plugin";
|
|
2
|
+
//#region src/frame.ts
|
|
3
|
+
const registered = (names) => names.map((n) => `@property --_${n} { syntax: "<length>"; inherits: false; initial-value: 0px; }`).join("\n");
|
|
4
|
+
const inner = "max(var(--_x) - var(--_p) - var(--_b), 0px)";
|
|
5
|
+
const outer = (parent) => `max(var(${parent}, calc(var(--_r) + var(--_m))) - var(--_m), 0px)`;
|
|
6
|
+
const css = `
|
|
7
|
+
& {
|
|
8
|
+
padding: var(--_p);
|
|
9
|
+
margin: var(--_m);
|
|
10
|
+
border: var(--_b) solid;
|
|
11
|
+
border-radius: var(--_x);
|
|
12
|
+
}
|
|
13
|
+
@container (style(--_c: e)) or (not style(--_c)) {
|
|
14
|
+
& { --_c: o; --_x: ${outer("--_e")}; --_o: ${inner}; }
|
|
15
|
+
}
|
|
16
|
+
@container style(--_c: o) {
|
|
17
|
+
& { --_c: e; --_x: ${outer("--_o")}; --_e: ${inner}; }
|
|
18
|
+
}`;
|
|
19
|
+
const fallback = `
|
|
20
|
+
:root[data-cssints-poly] & {
|
|
21
|
+
--_u: calc(var(--_r) + var(--_m));
|
|
22
|
+
--_i: max(max(var(--_u) - var(--_m), 0px) - var(--_p) - var(--_b), 0px);
|
|
23
|
+
--_t: var(--_i);
|
|
24
|
+
border-radius: max(var(--_u) - var(--_m), 0px);
|
|
25
|
+
transition: --_t 1ms;
|
|
26
|
+
}`;
|
|
27
|
+
const length = "<length [0,∞]>";
|
|
28
|
+
/**
|
|
29
|
+
* `frame().radius(t.radius.lg).padding(4).border("1px").margin(2)`: a box whose radius follows from the frames around it
|
|
30
|
+
* (`radius` is the radius of the outermost frame; inside, it is the parent's inner radius less the margin). `padding` and
|
|
31
|
+
* `margin` take a step of the spacing scale; each method once. It stands for `padding`, `margin`, `border-radius` and the
|
|
32
|
+
* border widths and styles, so mixing it with them in one `cn()` is a build error (border colours are fine).
|
|
33
|
+
*/
|
|
34
|
+
const frameScope = scope("frame", {
|
|
35
|
+
core: {
|
|
36
|
+
css,
|
|
37
|
+
atProperty: registered([
|
|
38
|
+
"r",
|
|
39
|
+
"p",
|
|
40
|
+
"b",
|
|
41
|
+
"m",
|
|
42
|
+
"u",
|
|
43
|
+
"i",
|
|
44
|
+
"t"
|
|
45
|
+
]),
|
|
46
|
+
requires: ["css.at-rules.property", "css.types.max"]
|
|
47
|
+
},
|
|
48
|
+
fallback: {
|
|
49
|
+
polyfills: ["css.at-rules.container.style_queries_for_custom_properties"],
|
|
50
|
+
parentVars: [{
|
|
51
|
+
marker: "&",
|
|
52
|
+
read: "--_i",
|
|
53
|
+
write: "--_u",
|
|
54
|
+
watch: "--_t"
|
|
55
|
+
}],
|
|
56
|
+
css: fallback
|
|
57
|
+
},
|
|
58
|
+
noBox: {
|
|
59
|
+
props: [/^(padding|margin)(-|$)/, /^border(?!.*color)/],
|
|
60
|
+
message: "frame() sets padding, margin, border-radius and the border: use its methods"
|
|
61
|
+
},
|
|
62
|
+
frame: {
|
|
63
|
+
uses: [
|
|
64
|
+
"core",
|
|
65
|
+
"fallback",
|
|
66
|
+
"noBox"
|
|
67
|
+
],
|
|
68
|
+
chain: {
|
|
69
|
+
radius: {
|
|
70
|
+
args: length,
|
|
71
|
+
emit: (v) => [["--_r", v]]
|
|
72
|
+
},
|
|
73
|
+
padding: {
|
|
74
|
+
args: length,
|
|
75
|
+
spacing: true,
|
|
76
|
+
emit: (v) => [["--_p", v]]
|
|
77
|
+
},
|
|
78
|
+
border: {
|
|
79
|
+
args: length,
|
|
80
|
+
emit: (v) => [["--_b", v]]
|
|
81
|
+
},
|
|
82
|
+
margin: {
|
|
83
|
+
args: "<length>",
|
|
84
|
+
spacing: true,
|
|
85
|
+
emit: (v) => [["--_m", v]]
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
const { frame } = frameScope.export();
|
|
91
|
+
//#endregion
|
|
92
|
+
export { frameScope as n, frame as t };
|
package/dist/frame.d.mts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
//#region src/frame.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* `frame().radius(t.radius.lg).padding(4).border("1px").margin(2)`: a box whose radius follows from the frames around it
|
|
4
|
+
* (`radius` is the radius of the outermost frame; inside, it is the parent's inner radius less the margin). `padding` and
|
|
5
|
+
* `margin` take a step of the spacing scale; each method once. It stands for `padding`, `margin`, `border-radius` and the
|
|
6
|
+
* border widths and styles, so mixing it with them in one `cn()` is a build error (border colours are fine).
|
|
7
|
+
*/
|
|
8
|
+
export declare const frameScope: import("cssints/plugin").Scope<"frame", {
|
|
9
|
+
readonly core: {
|
|
10
|
+
readonly css: string;
|
|
11
|
+
readonly atProperty: string;
|
|
12
|
+
readonly requires: ["css.at-rules.property", "css.types.max"];
|
|
13
|
+
};
|
|
14
|
+
readonly fallback: {
|
|
15
|
+
readonly polyfills: ["css.at-rules.container.style_queries_for_custom_properties"];
|
|
16
|
+
readonly parentVars: [{
|
|
17
|
+
readonly marker: "&";
|
|
18
|
+
readonly read: "--_i";
|
|
19
|
+
readonly write: "--_u";
|
|
20
|
+
readonly watch: "--_t";
|
|
21
|
+
}];
|
|
22
|
+
readonly css: "\n:root[data-cssints-poly] & {\n --_u: calc(var(--_r) + var(--_m));\n --_i: max(max(var(--_u) - var(--_m), 0px) - var(--_p) - var(--_b), 0px);\n --_t: var(--_i);\n border-radius: max(var(--_u) - var(--_m), 0px);\n transition: --_t 1ms;\n}";
|
|
23
|
+
};
|
|
24
|
+
readonly noBox: {
|
|
25
|
+
readonly props: [RegExp, RegExp];
|
|
26
|
+
readonly message: "frame() sets padding, margin, border-radius and the border: use its methods";
|
|
27
|
+
};
|
|
28
|
+
readonly frame: {
|
|
29
|
+
readonly uses: readonly ["core", "fallback", "noBox"];
|
|
30
|
+
readonly chain: {
|
|
31
|
+
readonly radius: {
|
|
32
|
+
readonly args: "<length [0,∞]>";
|
|
33
|
+
readonly emit: (v: string) => [string, string][];
|
|
34
|
+
};
|
|
35
|
+
readonly padding: {
|
|
36
|
+
readonly args: "<length [0,∞]>";
|
|
37
|
+
readonly spacing: true;
|
|
38
|
+
readonly emit: (v: string) => [string, string][];
|
|
39
|
+
};
|
|
40
|
+
readonly border: {
|
|
41
|
+
readonly args: "<length [0,∞]>";
|
|
42
|
+
readonly emit: (v: string) => [string, string][];
|
|
43
|
+
};
|
|
44
|
+
readonly margin: {
|
|
45
|
+
readonly args: "<length>";
|
|
46
|
+
readonly spacing: true;
|
|
47
|
+
readonly emit: (v: string) => [string, string][];
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
}>;
|
|
52
|
+
export declare const frame: () => import("cssints/plugin").Chain<"frame", {
|
|
53
|
+
readonly radius: {
|
|
54
|
+
readonly args: "<length [0,∞]>";
|
|
55
|
+
readonly emit: (v: string) => [string, string][];
|
|
56
|
+
};
|
|
57
|
+
readonly padding: {
|
|
58
|
+
readonly args: "<length [0,∞]>";
|
|
59
|
+
readonly spacing: true;
|
|
60
|
+
readonly emit: (v: string) => [string, string][];
|
|
61
|
+
};
|
|
62
|
+
readonly border: {
|
|
63
|
+
readonly args: "<length [0,∞]>";
|
|
64
|
+
readonly emit: (v: string) => [string, string][];
|
|
65
|
+
};
|
|
66
|
+
readonly margin: {
|
|
67
|
+
readonly args: "<length>";
|
|
68
|
+
readonly spacing: true;
|
|
69
|
+
readonly emit: (v: string) => [string, string][];
|
|
70
|
+
};
|
|
71
|
+
}, {}>;
|
|
72
|
+
//#endregion
|
package/dist/frame.mjs
ADDED
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { a as Kernel } from "./author-types-C1AhsnrT.mjs";
|
|
2
|
+
import { n as cx } from "./runtime-CTvuM-Hm.mjs";
|
|
3
|
+
import { n as At, t as CssNode } from "./node-CdhAGmF3.mjs";
|
|
4
|
+
import { t as Fallback } from "./lib-2OEIfPAE.mjs";
|
|
5
|
+
import { CSS, CSSColorValue, CSSImageValue, CSSStyleValue, CSSUnitValue } from "@cssints/css-grammar/values";
|
|
6
|
+
//#region src/macro.d.ts
|
|
7
|
+
export declare const firstThatWorks: (...values: unknown[]) => Fallback;
|
|
8
|
+
export declare class CSSAtRuleValue extends CSSStyleValue {
|
|
9
|
+
readonly kernel: Kernel;
|
|
10
|
+
readonly name: string;
|
|
11
|
+
constructor(name: string, kernel: Kernel);
|
|
12
|
+
toString(): string;
|
|
13
|
+
}
|
|
14
|
+
export declare const keyframes: (steps: unknown) => CSSAtRuleValue;
|
|
15
|
+
export declare const positionTry: (...args: unknown[]) => CSSAtRuleValue | CssNode;
|
|
16
|
+
export declare const cn: (...args: unknown[]) => CssNode;
|
|
17
|
+
export declare const flex: (...args: unknown[]) => CssNode;
|
|
18
|
+
export declare const grid: (...args: unknown[]) => CssNode;
|
|
19
|
+
type Styles = Record<string, Record<string, unknown>>;
|
|
20
|
+
interface CvConfig {
|
|
21
|
+
base?: unknown;
|
|
22
|
+
variants?: Styles;
|
|
23
|
+
defaultVariants?: Record<string, string | boolean>;
|
|
24
|
+
compoundVariants?: Record<string, string | boolean | CssNode>[];
|
|
25
|
+
}
|
|
26
|
+
export declare const cv: (config: CvConfig) => ((props?: Record<string, string | boolean | undefined>) => string) & {
|
|
27
|
+
__cv: CvConfig;
|
|
28
|
+
};
|
|
29
|
+
export declare const css: Record<string, unknown>;
|
|
30
|
+
export declare function __at(file: string, site: number, offset: number): At;
|
|
31
|
+
export declare const __unseen: (file: string, site: number) => boolean;
|
|
32
|
+
export declare function __site(at: At, value: unknown): unknown;
|
|
33
|
+
//#endregion
|
|
34
|
+
export { CSS, CSSColorValue, CSSImageValue, CSSStyleValue, CSSUnitValue, cx };
|