cssints 0.1.0 → 0.3.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 +107 -53
- package/dist/check.mjs +2 -2
- package/dist/{contrast-BUKVao74.mjs → contrast-B49XCnVX.mjs} +2 -2
- package/dist/devtools-link-D2YxsJKZ.mjs +94 -0
- package/dist/devtools-link.d.mts +55 -0
- package/dist/devtools-link.mjs +2 -0
- package/dist/group-common-9zpBxfUF.d.mts +1 -0
- package/dist/group-types-9ttphdku.d.mts +55 -0
- package/dist/groups/baseline-2015/with-downstream.d.mts +81 -0
- package/dist/groups/baseline-2015.d.mts +291 -0
- package/dist/groups/baseline-2016/with-downstream.d.mts +86 -0
- package/dist/groups/baseline-2016.d.mts +310 -0
- package/dist/groups/baseline-2017/with-downstream.d.mts +94 -0
- package/dist/groups/baseline-2017.d.mts +365 -0
- package/dist/groups/baseline-2018/with-downstream.d.mts +94 -0
- package/dist/groups/baseline-2018.d.mts +368 -0
- package/dist/groups/baseline-2019/with-downstream.d.mts +97 -0
- package/dist/groups/baseline-2019.d.mts +375 -0
- package/dist/groups/baseline-2020/with-downstream.d.mts +112 -0
- package/dist/groups/baseline-2020.d.mts +480 -0
- package/dist/groups/baseline-2021/with-downstream.d.mts +125 -0
- package/dist/groups/baseline-2021.d.mts +536 -0
- package/dist/groups/baseline-2022/with-downstream.d.mts +126 -0
- package/dist/groups/baseline-2022.d.mts +562 -0
- package/dist/groups/baseline-2023/with-downstream.d.mts +120 -0
- package/dist/groups/baseline-2023.d.mts +606 -0
- package/dist/groups/baseline-2024/with-downstream.d.mts +627 -0
- package/dist/groups/baseline-2024.d.mts +632 -0
- package/dist/groups/baseline-2025/with-downstream.d.mts +628 -0
- package/dist/groups/baseline-2025.d.mts +640 -0
- package/dist/groups/baseline-2026/with-downstream.d.mts +3 -0
- package/dist/groups/baseline-2026.d.mts +3 -0
- package/dist/groups/compositing-2.d.mts +20 -0
- package/dist/groups/css-align-3.d.mts +29 -0
- package/dist/groups/css-anchor-position-1.d.mts +49 -0
- package/dist/groups/css-anchor-position-2.d.mts +50 -0
- package/dist/groups/css-animations-1.d.mts +28 -0
- package/dist/groups/css-animations-2.d.mts +29 -0
- package/dist/groups/css-backgrounds-3.d.mts +27 -0
- package/dist/groups/css-backgrounds-4.d.mts +29 -0
- package/dist/groups/css-borders-4.d.mts +95 -0
- package/dist/groups/css-box-4.d.mts +38 -0
- package/dist/groups/css-break-4.d.mts +23 -0
- package/dist/groups/css-cascade-5.d.mts +18 -0
- package/dist/groups/css-cascade-6.d.mts +18 -0
- package/dist/groups/css-color-4.d.mts +29 -0
- package/dist/groups/css-color-5.d.mts +32 -0
- package/dist/groups/css-color-6.d.mts +32 -0
- package/dist/groups/css-color-adjust-1.d.mts +20 -0
- package/dist/groups/css-color-hdr-1.d.mts +19 -0
- package/dist/groups/css-conditional-3.d.mts +17 -0
- package/dist/groups/css-conditional-4.d.mts +17 -0
- package/dist/groups/css-conditional-5.d.mts +22 -0
- package/dist/groups/css-contain-2.d.mts +19 -0
- package/dist/groups/css-content-3.d.mts +23 -0
- package/dist/groups/css-counter-styles-3.d.mts +16 -0
- package/dist/groups/css-display-4.d.mts +22 -0
- package/dist/groups/css-easing-2.d.mts +18 -0
- package/dist/groups/css-env-1.d.mts +16 -0
- package/dist/groups/css-flexbox-1.d.mts +24 -0
- package/dist/groups/css-fonts-4.d.mts +46 -0
- package/dist/groups/css-fonts-5.d.mts +44 -0
- package/dist/groups/css-forms-1.d.mts +19 -0
- package/dist/groups/css-gaps-1.d.mts +21 -0
- package/dist/groups/css-gcpm-3.d.mts +20 -0
- package/dist/groups/css-gcpm-4.d.mts +20 -0
- package/dist/groups/css-grid-2.d.mts +34 -0
- package/dist/groups/css-grid-3.d.mts +34 -0
- package/dist/groups/css-images-3.d.mts +25 -0
- package/dist/groups/css-images-4.d.mts +32 -0
- package/dist/groups/css-images-5.d.mts +33 -0
- package/dist/groups/css-inline-3.d.mts +28 -0
- package/dist/groups/css-lists-3.d.mts +26 -0
- package/dist/groups/css-logical-1.d.mts +35 -0
- package/dist/groups/css-masking-1.d.mts +37 -0
- package/dist/groups/css-multicol-2.d.mts +24 -0
- package/dist/groups/css-overflow-3.d.mts +28 -0
- package/dist/groups/css-overflow-4.d.mts +29 -0
- package/dist/groups/css-overflow-5.d.mts +31 -0
- package/dist/groups/css-overscroll-1.d.mts +22 -0
- package/dist/groups/css-page-3.d.mts +18 -0
- package/dist/groups/css-page-floats-3.d.mts +19 -0
- package/dist/groups/css-position-3.d.mts +29 -0
- package/dist/groups/css-position-4.d.mts +30 -0
- package/dist/groups/css-rhythm-1.d.mts +18 -0
- package/dist/groups/css-round-display-1.d.mts +16 -0
- package/dist/groups/css-ruby-1.d.mts +21 -0
- package/dist/groups/css-scroll-anchoring-1.d.mts +18 -0
- package/dist/groups/css-scroll-snap-1.d.mts +42 -0
- package/dist/groups/css-scroll-snap-2.d.mts +43 -0
- package/dist/groups/css-scrollbars-1.d.mts +19 -0
- package/dist/groups/css-shapes-1.d.mts +27 -0
- package/dist/groups/css-shapes-2.d.mts +27 -0
- package/dist/groups/css-size-adjust-1.d.mts +18 -0
- package/dist/groups/css-sizing-3.d.mts +34 -0
- package/dist/groups/css-sizing-4.d.mts +33 -0
- package/dist/groups/css-speech-1.d.mts +18 -0
- package/dist/groups/css-tables-3.d.mts +22 -0
- package/dist/groups/css-text-3.d.mts +36 -0
- package/dist/groups/css-text-4.d.mts +40 -0
- package/dist/groups/css-text-decor-3.d.mts +30 -0
- package/dist/groups/css-text-decor-4.d.mts +31 -0
- package/dist/groups/css-transforms-1.d.mts +31 -0
- package/dist/groups/css-transforms-2.d.mts +48 -0
- package/dist/groups/css-transitions-1.d.mts +22 -0
- package/dist/groups/css-transitions-2.d.mts +23 -0
- package/dist/groups/css-ui-4.d.mts +35 -0
- package/dist/groups/css-values-4.d.mts +38 -0
- package/dist/groups/css-values-5.d.mts +43 -0
- package/dist/groups/css-variables-2.d.mts +6 -0
- package/dist/groups/css-view-transitions-2.d.mts +20 -0
- package/dist/groups/css-viewport.d.mts +18 -0
- package/dist/groups/css-will-change-1.d.mts +18 -0
- package/dist/groups/css-writing-modes-4.d.mts +22 -0
- package/dist/groups/css2.d.mts +19 -0
- package/dist/groups/fill-stroke-3.d.mts +27 -0
- package/dist/groups/filter-effects-1.d.mts +32 -0
- package/dist/groups/filter-effects-2.d.mts +33 -0
- package/dist/groups/limited-availability.d.mts +2 -0
- package/dist/groups/mediaqueries-4.d.mts +16 -0
- package/dist/groups/mediaqueries-5.d.mts +16 -0
- package/dist/groups/motion-1.d.mts +24 -0
- package/dist/groups/newly-available/with-downstream.d.mts +632 -0
- package/dist/groups/newly-available.d.mts +631 -0
- package/dist/groups/not-discouraged.d.mts +727 -0
- package/dist/groups/scroll-animations-1.d.mts +30 -0
- package/dist/groups/selectors-4.d.mts +54 -0
- package/dist/groups/selectors-5.d.mts +54 -0
- package/dist/groups/widely-available/with-downstream.d.mts +121 -0
- package/dist/groups/widely-available.d.mts +616 -0
- package/dist/index.d.mts +19 -5
- package/dist/index.mjs +166 -14
- package/dist/instrument-BqIZpbIU.mjs +3956 -0
- package/dist/{lowered-CeoXbm0P.mjs → lowered-aJVapQT6.mjs} +1 -1
- package/dist/{node-CdhAGmF3.d.mts → node-OJ_w_Usj.d.mts} +4 -0
- package/dist/plugin-types.d.mts +8 -1
- package/dist/plugin.d.mts +2 -2
- package/dist/plugin.mjs +8 -1
- package/dist/{registry-n9JCX4pl.mjs → registry-BUSEO32-.mjs} +8 -1
- package/dist/runtime-Dt4Tm0Q7.d.mts +19 -0
- package/dist/runtime.d.mts +1 -1
- package/dist/runtime.mjs +6 -2
- package/dist/{scope-oWEaWE9n.d.mts → scope-INuJD4RT.d.mts} +18 -5
- package/dist/{sheet-CO7a-mdA.mjs → sheet-BeHdq4xt.mjs} +2 -1
- package/dist/surface.d.mts +1 -1
- package/dist/{theme-BGEbFAYh.mjs → theme-SlQ73rFL.mjs} +31 -8
- package/dist/{theme-types-DHdtTZhz.d.mts → theme-types-Bqv0Ggz_.d.mts} +11 -6
- package/dist/tui-types.d.mts +1 -1
- package/dist/tui.d.mts +1 -8
- package/dist/tui.mjs +35 -7
- package/dist/types.d.mts +1 -1
- package/dist/vite.d.mts +20 -2
- package/dist/vite.mjs +90 -41
- package/docs/API.md +519 -251
- package/package.json +10 -2
- package/skills/cssints/SKILL.md +12 -9
- package/skills/cssints/references/errors.md +8 -7
- package/skills/cssints-plugin/SKILL.md +3 -1
- package/dist/instrument-Bdtk2INz.mjs +0 -172
- package/dist/lib-2OEIfPAE.d.mts +0 -9
- package/dist/runtime-CTvuM-Hm.d.mts +0 -5
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { a as Kernel } from "./author-types-C1AhsnrT.mjs";
|
|
2
|
-
import { n as
|
|
3
|
-
import { n as At, t as CssNode } from "./node-
|
|
4
|
-
import { t as Fallback } from "./lib-2OEIfPAE.mjs";
|
|
2
|
+
import { n as _cv, r as _cx } from "./runtime-Dt4Tm0Q7.mjs";
|
|
3
|
+
import { n as At, t as CssNode } from "./node-OJ_w_Usj.mjs";
|
|
5
4
|
import { CSS, CSSColorValue, CSSImageValue, CSSStyleValue, CSSUnitValue } from "@cssints/css-grammar/values";
|
|
5
|
+
import { Effect } from "effect";
|
|
6
|
+
//#region src/lib.d.ts
|
|
7
|
+
/** What firstThatWorks() builds: its values as text, the wanted one first. */
|
|
8
|
+
interface Fallback {
|
|
9
|
+
__fallback: string[];
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
6
12
|
//#region src/macro.d.ts
|
|
7
13
|
export declare const firstThatWorks: (...values: unknown[]) => Fallback;
|
|
8
14
|
export declare class CSSAtRuleValue extends CSSStyleValue {
|
|
@@ -13,7 +19,7 @@ export declare class CSSAtRuleValue extends CSSStyleValue {
|
|
|
13
19
|
}
|
|
14
20
|
export declare const keyframes: (steps: unknown) => CSSAtRuleValue;
|
|
15
21
|
export declare const positionTry: (...args: unknown[]) => CSSAtRuleValue | CssNode;
|
|
16
|
-
export declare const cn: (...
|
|
22
|
+
export declare const cn: (...all: unknown[]) => CssNode;
|
|
17
23
|
export declare const flex: (...args: unknown[]) => CssNode;
|
|
18
24
|
export declare const grid: (...args: unknown[]) => CssNode;
|
|
19
25
|
type Styles = Record<string, Record<string, unknown>>;
|
|
@@ -26,9 +32,17 @@ interface CvConfig {
|
|
|
26
32
|
export declare const cv: (config: CvConfig) => ((props?: Record<string, string | boolean | undefined>) => string) & {
|
|
27
33
|
__cv: CvConfig;
|
|
28
34
|
};
|
|
35
|
+
export declare const __cnGroup: (statics: [number, unknown][], parts: [number, number][]) => {
|
|
36
|
+
__cnGroup: {
|
|
37
|
+
statics: [number, unknown][];
|
|
38
|
+
parts: [number, number][];
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
export declare const __nocn: () => undefined;
|
|
29
42
|
export declare const css: Record<string, unknown>;
|
|
43
|
+
export declare const __group: (id: string) => Record<string, unknown>;
|
|
30
44
|
export declare function __at(file: string, site: number, offset: number): At;
|
|
31
45
|
export declare const __unseen: (file: string, site: number) => boolean;
|
|
32
46
|
export declare function __site(at: At, value: unknown): unknown;
|
|
33
47
|
//#endregion
|
|
34
|
-
export { CSS, CSSColorValue, CSSImageValue, CSSStyleValue, CSSUnitValue,
|
|
48
|
+
export { CSS, CSSColorValue, CSSImageValue, CSSStyleValue, CSSUnitValue, _cv, _cx };
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { a as registry, d as MacroError, f as MemberError, o as warn, r as forgetKernels, t as Registry } from "./registry-
|
|
2
|
-
import { A as
|
|
3
|
-
import { D as relation, S as addRuntime, _ as addKernel, i as byOrder, n as addGlobal, r as addLayers, y as kernelWarnings } from "./sheet-
|
|
4
|
-
import { n as loweredOf } from "./lowered-
|
|
5
|
-
import { t as CV_CALL } from "./instrument-
|
|
1
|
+
import { a as registry, d as MacroError, f as MemberError, o as warn, r as forgetKernels, t as Registry } from "./registry-BUSEO32-.mjs";
|
|
2
|
+
import { A as camel, C as hashClass, D as settled, E as minWidth, F as probed, M as failIn, N as isNode, O as toDecls, P as node, S as edge, T as merged, _ as PSEUDOS, a as createTokens, b as checkVars, c as tokensOf, d as style, f as token, g as PROPS, h as LAYER, i as createGlobalTheme, j as fail, k as VAR, l as CSSTokenValue, m as FUNCTIONS, n as addTheme, o as isDone, p as CONTEXTS, r as check$1, t as DONE, u as isStyle, v as carried, w as isFallback, x as dropsOf, y as chainDecl } from "./theme-SlQ73rFL.mjs";
|
|
3
|
+
import { D as relation, S as addRuntime, _ as addKernel, i as byOrder, n as addGlobal, r as addLayers, y as kernelWarnings } from "./sheet-BeHdq4xt.mjs";
|
|
4
|
+
import { n as loweredOf } from "./lowered-aJVapQT6.mjs";
|
|
5
|
+
import { c as groups$1, n as CX_CALL, t as CV_CALL } from "./instrument-BqIZpbIU.mjs";
|
|
6
6
|
import { checkDeclarationNow, checkQuery, checkSelector, checkValueNow, isDeclarationError } from "@cssints/css-grammar/check";
|
|
7
7
|
import { lackingOf, messageOf } from "@cssints/css-grammar/support";
|
|
8
8
|
import { CSS, CSSColorValue, CSSImageValue, CSSStyleValue, CSSStyleValue as CSSStyleValue$1, CSSUnitValue } from "@cssints/css-grammar/values";
|
|
@@ -30,7 +30,7 @@ const OPERATORS = /* @__PURE__ */ new Set([
|
|
|
30
30
|
"*",
|
|
31
31
|
"/"
|
|
32
32
|
]);
|
|
33
|
-
const isGroup = (p) => Array.isArray(p);
|
|
33
|
+
const isGroup$1 = (p) => Array.isArray(p);
|
|
34
34
|
const build = (member, name) => {
|
|
35
35
|
const { sep, math } = functions[name];
|
|
36
36
|
const grammar = math ? MATH : `<${name}()>`;
|
|
@@ -40,7 +40,7 @@ const build = (member, name) => {
|
|
|
40
40
|
else if (typeof p !== "number" && !(p instanceof CSSStyleValue$1)) throw fail(`cssints: ${member}() takes strings, numbers and Typed OM values (tokens, other calls), got ${Formatter.formatJson(p)}`);
|
|
41
41
|
return String(p);
|
|
42
42
|
};
|
|
43
|
-
const texts = parts.map((p, i) => isGroup(p) ? p.map(atom).join(" ") : name === "var" && !i && p instanceof CSSTokenValue ? p.name : atom(p));
|
|
43
|
+
const texts = parts.map((p, i) => isGroup$1(p) ? p.map(atom).join(" ") : name === "var" && !i && p instanceof CSSTokenValue ? p.name : atom(p));
|
|
44
44
|
const join = (ts) => ts.reduce((acc, t, i) => i ? `${acc}${OPERATORS.has(t) || OPERATORS.has(ts[i - 1]) ? " " : sep}${t}` : t, "");
|
|
45
45
|
const value = `${name}(${join(texts)})`;
|
|
46
46
|
const first = parts[0];
|
|
@@ -79,6 +79,116 @@ const checkText = (label, grammar, text, where) => {
|
|
|
79
79
|
/** The members of `css` that are functions, by name. */
|
|
80
80
|
const fns = Object.fromEntries(Object.entries(FUNCTIONS).map(([member, name]) => [member, build(member, name)]));
|
|
81
81
|
//#endregion
|
|
82
|
+
//#region src/group.ts
|
|
83
|
+
const CONDITIONS = [
|
|
84
|
+
"media",
|
|
85
|
+
"container",
|
|
86
|
+
"supports"
|
|
87
|
+
];
|
|
88
|
+
const TIED = /* @__PURE__ */ new Set([
|
|
89
|
+
...Object.keys(PROPS),
|
|
90
|
+
...Object.keys(FUNCTIONS),
|
|
91
|
+
...Object.keys(PSEUDOS),
|
|
92
|
+
...CONDITIONS,
|
|
93
|
+
"keyframes",
|
|
94
|
+
"positionTry"
|
|
95
|
+
]);
|
|
96
|
+
const WORDS = /[^ ,)/:;"'<>=+*[\]{}!#%.⟨⟩&|\n\t(]+\(?/g;
|
|
97
|
+
const words = (s) => new Set(s ? s.split(" ") : []);
|
|
98
|
+
const groups = new Map(Object.entries(groups$1));
|
|
99
|
+
const compiled$1 = /* @__PURE__ */ new Map();
|
|
100
|
+
const compile$1 = (id) => {
|
|
101
|
+
const g = groups.get(id);
|
|
102
|
+
if (!g) throw fail(`cssints: no export group cssints/${id}`);
|
|
103
|
+
const members = words(g.members);
|
|
104
|
+
const units = g.ban.unit ? g.ban.unit.split(" ") : [];
|
|
105
|
+
return {
|
|
106
|
+
id,
|
|
107
|
+
members,
|
|
108
|
+
props: new Set([...members].flatMap((m) => PROPS[m] ? [PROPS[m]] : [])),
|
|
109
|
+
kw: new Map(Object.entries(g.ban.kw).map(([p, ws]) => [p, words(ws)])),
|
|
110
|
+
fn: new Set((g.ban.fn ? g.ban.fn.split(" ") : []).map((f) => `${f}(`)),
|
|
111
|
+
unit: units.length ? new RegExp(`^[0-9]+(?:e[0-9]+)?(?:${units.toSorted((a, b) => b.length - a.length).join("|")})$`) : void 0,
|
|
112
|
+
query: {
|
|
113
|
+
media: words(g.ban.media),
|
|
114
|
+
container: words(g.ban.container),
|
|
115
|
+
supports: words(g.ban.supports)
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
const of = (id) => compiled$1.get(id) ?? compiled$1.set(id, compile$1(id)).get(id);
|
|
120
|
+
const hit = (c, own, text) => text.match(WORDS)?.find((w) => own?.has(w) || c.fn.has(w) || c.unit?.test(w));
|
|
121
|
+
const said = (w) => w.endsWith("(") ? `${w.slice(0, -1)}()` : w;
|
|
122
|
+
const refuse = (c, label, w) => fail(`cssints: ${label}: "${said(w)}" is not in cssints/${c.id}`);
|
|
123
|
+
const guard = (c, n) => {
|
|
124
|
+
for (const [prop, value, , fallbacks] of n.__cssints) {
|
|
125
|
+
const own = c.kw.get(prop);
|
|
126
|
+
for (const v of fallbacks ? [value, ...fallbacks] : [value]) {
|
|
127
|
+
const w = hit(c, own, v);
|
|
128
|
+
if (w) throw refuse(c, prop, w);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return n;
|
|
132
|
+
};
|
|
133
|
+
const chained = (c, n) => new Proxy(n, { get: (t, k) => {
|
|
134
|
+
const v = Reflect.get(t, k);
|
|
135
|
+
if (typeof k !== "string" || k in t || typeof v !== "function") return v;
|
|
136
|
+
return (...args) => {
|
|
137
|
+
const next = guard(c, v(...args));
|
|
138
|
+
const prop = next.__cssints.at(-1)?.[0];
|
|
139
|
+
if (prop && !c.props.has(prop)) throw fail(`cssints: ${prop} is not in cssints/${c.id} (.${k}())`);
|
|
140
|
+
return chained(c, next);
|
|
141
|
+
};
|
|
142
|
+
} });
|
|
143
|
+
const texts = (q) => typeof q === "string" ? [q] : q && typeof q === "object" ? Object.values(q).flatMap(texts) : [];
|
|
144
|
+
const wrap = (c, name, member) => {
|
|
145
|
+
const fn = member;
|
|
146
|
+
if (CONDITIONS.includes(name)) return (...qs) => {
|
|
147
|
+
const kind = name;
|
|
148
|
+
for (const q of qs.flatMap(texts)) {
|
|
149
|
+
const w = hit(c, c.query[kind], q);
|
|
150
|
+
if (w) throw refuse(c, `@${kind}`, w);
|
|
151
|
+
}
|
|
152
|
+
return fn(...qs);
|
|
153
|
+
};
|
|
154
|
+
if (!(name in PROPS) || typeof member !== "function") return member;
|
|
155
|
+
return (...args) => {
|
|
156
|
+
const made = fn(...args);
|
|
157
|
+
if (!isNode(made)) return made;
|
|
158
|
+
return name in CONTEXTS ? chained(c, guard(c, made)) : guard(c, made);
|
|
159
|
+
};
|
|
160
|
+
};
|
|
161
|
+
/**
|
|
162
|
+
* The members of an export group.
|
|
163
|
+
* @param {Record<string, unknown>} css `css` of macro.ts, passed in so that this file imports no engine module
|
|
164
|
+
* @param {string} id the group: `widely-available`, `css-grid-2`, ...
|
|
165
|
+
* @returns {Record<string, unknown>} `css` with the members of the group, as they are, and the ones it has not throwing, naming the group, when called
|
|
166
|
+
*/
|
|
167
|
+
const groupOf = (css, id) => {
|
|
168
|
+
if (id === "limited-availability") return css;
|
|
169
|
+
const c = of(id);
|
|
170
|
+
return new Proxy(css, { get: (t, k) => {
|
|
171
|
+
if (typeof k !== "string") return Reflect.get(t, k);
|
|
172
|
+
if (TIED.has(k) && !c.members.has(k)) return () => {
|
|
173
|
+
throw fail(`cssints: ${k} is not in cssints/${id}`);
|
|
174
|
+
};
|
|
175
|
+
return wrap(c, k, t[k]);
|
|
176
|
+
} });
|
|
177
|
+
};
|
|
178
|
+
const KNOWN = new Set(Object.values(PROPS));
|
|
179
|
+
/**
|
|
180
|
+
* Whether a declaration is in an export group: the group has the property, and the value holds no word it bans.
|
|
181
|
+
* @param {string} id the group: `widely-available`, `baseline-2022/with-downstream`, `css-grid-2`, ...
|
|
182
|
+
* @param {string} property the CSS name: `text-wrap`
|
|
183
|
+
* @param {string} value the value as written: `balance`
|
|
184
|
+
* @returns {boolean} true for a property cssints has no member for (`--x`, `-webkit-text-size-adjust`)
|
|
185
|
+
*/
|
|
186
|
+
const inGroup = (id, property, value) => {
|
|
187
|
+
if (id === "limited-availability") return true;
|
|
188
|
+
const c = of(id);
|
|
189
|
+
return (c.props.has(property) || !KNOWN.has(property)) && !hit(c, c.kw.get(property), value);
|
|
190
|
+
};
|
|
191
|
+
//#endregion
|
|
82
192
|
//#region src/scope-engine.ts
|
|
83
193
|
const NAME$1 = /^[a-z][a-z0-9-]*$/;
|
|
84
194
|
const KEY = /^[A-Za-z][\w-]*$/;
|
|
@@ -131,7 +241,7 @@ const check = (plugin, label, grammar, value) => {
|
|
|
131
241
|
};
|
|
132
242
|
const valueOf = (plugin, label, args, spacing = false) => {
|
|
133
243
|
if (!args.length) throw failIn(plugin, `cssints: ${label}() expects a value`);
|
|
134
|
-
if (args.some(isNode)) throw failIn(plugin, `cssints: ${label}() takes values, not styles; merge styles with cn(...)
|
|
244
|
+
if (args.some(isNode)) throw failIn(plugin, `cssints: ${label}() takes values, not styles; merge styles with cn(...)`);
|
|
135
245
|
const [only] = args;
|
|
136
246
|
return spacing && args.length === 1 && typeof only === "number" ? `${only * .25}rem` : args.join(" ");
|
|
137
247
|
};
|
|
@@ -540,11 +650,16 @@ const dependsOn = (path) => {
|
|
|
540
650
|
const engine = {
|
|
541
651
|
scope,
|
|
542
652
|
lacking: lacking$1,
|
|
543
|
-
dependsOn
|
|
653
|
+
dependsOn,
|
|
654
|
+
inGroup
|
|
544
655
|
};
|
|
545
656
|
//#endregion
|
|
546
657
|
//#region src/runtime.ts
|
|
547
|
-
|
|
658
|
+
function _cx(drops, ...a) {
|
|
659
|
+
const on = a.flat(Infinity).filter(Boolean).join(" ").split(" ");
|
|
660
|
+
const gone = drops.flatMap(([by, c]) => on.includes(by) ? c.split(" ") : []);
|
|
661
|
+
return on.filter((c) => c && !gone.includes(c)).join(" ");
|
|
662
|
+
}
|
|
548
663
|
function _cv(config) {
|
|
549
664
|
return (props = {}) => {
|
|
550
665
|
const out = [config.base];
|
|
@@ -634,9 +749,9 @@ const keyframes = (steps) => {
|
|
|
634
749
|
};
|
|
635
750
|
const positionTryProp = member("positionTry");
|
|
636
751
|
const positionTry = (...args) => args.length === 1 && isNode(args[0]) ? atRule("position-try", "--pt-", blockOf("positionTry()", args[0], POSITION_TRY)) : positionTryProp(...args);
|
|
637
|
-
const cn = (...
|
|
638
|
-
const
|
|
639
|
-
return node(
|
|
752
|
+
const cn = (...all) => {
|
|
753
|
+
const args = all.filter(Boolean);
|
|
754
|
+
return node(toDecls("cn", args), carried(args));
|
|
640
755
|
};
|
|
641
756
|
const flex = member("flex");
|
|
642
757
|
const grid = member("grid");
|
|
@@ -1018,6 +1133,37 @@ const cv = (config) => {
|
|
|
1018
1133
|
};
|
|
1019
1134
|
return Object.assign((props) => (built[0] ??= build())(props), { __cv: config });
|
|
1020
1135
|
};
|
|
1136
|
+
const isGroup = (v) => Predicate.hasProperty(v, "__cnGroup");
|
|
1137
|
+
const headOf = Effect.fnUntraced(function* ({ __cnGroup: { statics, parts } }, at) {
|
|
1138
|
+
const { nodes } = yield* Registry;
|
|
1139
|
+
const merged = cn(...statics.map(([, s]) => s));
|
|
1140
|
+
const where = /* @__PURE__ */ new Map();
|
|
1141
|
+
for (const [pos, s] of statics) if (isNode(s)) for (const d of s.__cssints) where.set(d, pos);
|
|
1142
|
+
const all = nodes.get(at.file) ?? nodes.set(at.file, /* @__PURE__ */ new Map()).get(at.file);
|
|
1143
|
+
all.set(at.site, merged.__cssints);
|
|
1144
|
+
const drops = yield* Effect.try({
|
|
1145
|
+
try: () => dropsOf([...merged.__cssints.map((decl) => ({
|
|
1146
|
+
at: where.get(decl),
|
|
1147
|
+
decl,
|
|
1148
|
+
conditional: false
|
|
1149
|
+
})), ...parts.flatMap(([pos, site]) => (all.get(site) ?? []).map((decl) => ({
|
|
1150
|
+
at: pos,
|
|
1151
|
+
decl,
|
|
1152
|
+
conditional: true
|
|
1153
|
+
})))]),
|
|
1154
|
+
catch: (e) => {
|
|
1155
|
+
if (e instanceof MacroError) return e;
|
|
1156
|
+
throw e;
|
|
1157
|
+
}
|
|
1158
|
+
});
|
|
1159
|
+
const classes = yield* classesOf(merged, at);
|
|
1160
|
+
return `${CX_CALL}${Formatter.formatJson(drops)}, ${classes ? `${Formatter.formatJson(classes)}, ` : ""}`;
|
|
1161
|
+
});
|
|
1162
|
+
const __cnGroup = (statics, parts) => ({ __cnGroup: {
|
|
1163
|
+
statics,
|
|
1164
|
+
parts
|
|
1165
|
+
} });
|
|
1166
|
+
const __nocn = () => void 0;
|
|
1021
1167
|
const named = {
|
|
1022
1168
|
cn,
|
|
1023
1169
|
firstThatWorks,
|
|
@@ -1044,6 +1190,7 @@ const named = {
|
|
|
1044
1190
|
};
|
|
1045
1191
|
const css = new Proxy(named, { get: (t, k) => Object.hasOwn(t, k) ? t[k] : member(String(k)) });
|
|
1046
1192
|
named.css = css;
|
|
1193
|
+
const __group = (id) => groupOf(css, id);
|
|
1047
1194
|
const kernelCss = new Proxy({
|
|
1048
1195
|
...named,
|
|
1049
1196
|
nest,
|
|
@@ -1078,6 +1225,7 @@ const isPluginValue = Predicate.isObjectKeyword;
|
|
|
1078
1225
|
const replacementOf = Effect.fnUntraced(function* (at, value) {
|
|
1079
1226
|
if (isNode(value)) return Formatter.formatJson(yield* classesOf(value, at));
|
|
1080
1227
|
if (isCv(value)) return `${CV_CALL}${yield* cvOf(value.__cv, at)})`;
|
|
1228
|
+
if (isGroup(value)) return yield* headOf(value, at);
|
|
1081
1229
|
if (isStyle(value)) return yield* inlineOf(value);
|
|
1082
1230
|
const tokens = tokensOf(value);
|
|
1083
1231
|
if (tokens !== void 0) return tokens;
|
|
@@ -1100,6 +1248,10 @@ const recordSite = Effect.fnUntraced(function* (at, value) {
|
|
|
1100
1248
|
const { sites } = yield* Registry;
|
|
1101
1249
|
const replacement = yield* replacementOf(at, value).pipe(Effect.mapError(located(at)));
|
|
1102
1250
|
if (replacement === void 0) return value;
|
|
1251
|
+
if (isNode(value)) {
|
|
1252
|
+
const { nodes } = yield* Registry;
|
|
1253
|
+
(nodes.get(at.file) ?? nodes.set(at.file, /* @__PURE__ */ new Map()).get(at.file)).set(at.site, value.__cssints);
|
|
1254
|
+
}
|
|
1103
1255
|
if (!sites.has(at.file)) sites.set(at.file, /* @__PURE__ */ new Map());
|
|
1104
1256
|
sites.get(at.file).set(at.site, replacement);
|
|
1105
1257
|
return value;
|
|
@@ -1129,4 +1281,4 @@ function __site(at, value) {
|
|
|
1129
1281
|
return exit.value;
|
|
1130
1282
|
}
|
|
1131
1283
|
//#endregion
|
|
1132
|
-
export { CSS, CSSAtRuleValue, CSSColorValue, CSSImageValue, CSSStyleValue, CSSUnitValue, __at, __site, __unseen, cn, css, cv,
|
|
1284
|
+
export { CSS, CSSAtRuleValue, CSSColorValue, CSSImageValue, CSSStyleValue, CSSUnitValue, __at, __cnGroup, __group, __nocn, __site, __unseen, _cv, _cx, cn, css, cv, firstThatWorks, flex, grid, keyframes, positionTry };
|