cssints 0.1.0 → 0.2.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 +21 -11
- package/dist/check.mjs +2 -2
- package/dist/{contrast-BUKVao74.mjs → contrast-DhK69Xak.mjs} +2 -2
- package/dist/group-common-9zpBxfUF.d.mts +1 -0
- package/dist/group-types-9ttphdku.d.mts +55 -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.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.d.mts +616 -0
- package/dist/index.d.mts +19 -5
- package/dist/index.mjs +150 -13
- package/dist/instrument-gCazujmb.mjs +1624 -0
- package/dist/{lowered-CeoXbm0P.mjs → lowered-D2KusPLp.mjs} +1 -1
- package/dist/{node-CdhAGmF3.d.mts → node-OJ_w_Usj.d.mts} +4 -0
- package/dist/plugin-types.d.mts +1 -1
- package/dist/plugin.d.mts +1 -1
- package/dist/{registry-n9JCX4pl.mjs → registry-CTumHB8p.mjs} +2 -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-ZVhUxQH1.d.mts} +10 -4
- package/dist/{sheet-CO7a-mdA.mjs → sheet-BKsMTa0c.mjs} +2 -1
- package/dist/surface.d.mts +1 -1
- package/dist/{theme-BGEbFAYh.mjs → theme-BsP2E4LB.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 +17 -1
- package/dist/vite.mjs +9 -12
- package/docs/API.md +75 -30
- package/package.json +6 -2
- package/skills/cssints/SKILL.md +12 -9
- package/skills/cssints/references/errors.md +8 -7
- package/skills/cssints-plugin/SKILL.md +1 -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-CTumHB8p.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-BsP2E4LB.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-BKsMTa0c.mjs";
|
|
4
|
+
import { n as loweredOf } from "./lowered-D2KusPLp.mjs";
|
|
5
|
+
import { n as CX_CALL, s as groups$1, t as CV_CALL } from "./instrument-gCazujmb.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,102 @@ 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 hit = (c, own, text) => text.match(WORDS)?.find((w) => own?.has(w) || c.fn.has(w) || c.unit?.test(w));
|
|
120
|
+
const said = (w) => w.endsWith("(") ? `${w.slice(0, -1)}()` : w;
|
|
121
|
+
const refuse = (c, label, w) => fail(`cssints: ${label}: "${said(w)}" is not in cssints/${c.id}`);
|
|
122
|
+
const guard = (c, n) => {
|
|
123
|
+
for (const [prop, value, , fallbacks] of n.__cssints) {
|
|
124
|
+
const own = c.kw.get(prop);
|
|
125
|
+
for (const v of fallbacks ? [value, ...fallbacks] : [value]) {
|
|
126
|
+
const w = hit(c, own, v);
|
|
127
|
+
if (w) throw refuse(c, prop, w);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return n;
|
|
131
|
+
};
|
|
132
|
+
const chained = (c, n) => new Proxy(n, { get: (t, k) => {
|
|
133
|
+
const v = Reflect.get(t, k);
|
|
134
|
+
if (typeof k !== "string" || k in t || typeof v !== "function") return v;
|
|
135
|
+
return (...args) => {
|
|
136
|
+
const next = guard(c, v(...args));
|
|
137
|
+
const prop = next.__cssints.at(-1)?.[0];
|
|
138
|
+
if (prop && !c.props.has(prop)) throw fail(`cssints: ${prop} is not in cssints/${c.id} (.${k}())`);
|
|
139
|
+
return chained(c, next);
|
|
140
|
+
};
|
|
141
|
+
} });
|
|
142
|
+
const texts = (q) => typeof q === "string" ? [q] : q && typeof q === "object" ? Object.values(q).flatMap(texts) : [];
|
|
143
|
+
const wrap = (c, name, member) => {
|
|
144
|
+
const fn = member;
|
|
145
|
+
if (CONDITIONS.includes(name)) return (...qs) => {
|
|
146
|
+
const kind = name;
|
|
147
|
+
for (const q of qs.flatMap(texts)) {
|
|
148
|
+
const w = hit(c, c.query[kind], q);
|
|
149
|
+
if (w) throw refuse(c, `@${kind}`, w);
|
|
150
|
+
}
|
|
151
|
+
return fn(...qs);
|
|
152
|
+
};
|
|
153
|
+
if (!(name in PROPS) || typeof member !== "function") return member;
|
|
154
|
+
return (...args) => {
|
|
155
|
+
const made = fn(...args);
|
|
156
|
+
if (!isNode(made)) return made;
|
|
157
|
+
return name in CONTEXTS ? chained(c, guard(c, made)) : guard(c, made);
|
|
158
|
+
};
|
|
159
|
+
};
|
|
160
|
+
/**
|
|
161
|
+
* The members of an export group.
|
|
162
|
+
* @param {Record<string, unknown>} css `css` of macro.ts, passed in so that this file imports no engine module
|
|
163
|
+
* @param {string} id the group: `widely-available`, `css-grid-2`, ...
|
|
164
|
+
* @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
|
|
165
|
+
*/
|
|
166
|
+
const groupOf = (css, id) => {
|
|
167
|
+
if (id === "limited-availability") return css;
|
|
168
|
+
const c = compiled$1.get(id) ?? compiled$1.set(id, compile$1(id)).get(id);
|
|
169
|
+
return new Proxy(css, { get: (t, k) => {
|
|
170
|
+
if (typeof k !== "string") return Reflect.get(t, k);
|
|
171
|
+
if (TIED.has(k) && !c.members.has(k)) return () => {
|
|
172
|
+
throw fail(`cssints: ${k} is not in cssints/${id}`);
|
|
173
|
+
};
|
|
174
|
+
return wrap(c, k, t[k]);
|
|
175
|
+
} });
|
|
176
|
+
};
|
|
177
|
+
//#endregion
|
|
82
178
|
//#region src/scope-engine.ts
|
|
83
179
|
const NAME$1 = /^[a-z][a-z0-9-]*$/;
|
|
84
180
|
const KEY = /^[A-Za-z][\w-]*$/;
|
|
@@ -131,7 +227,7 @@ const check = (plugin, label, grammar, value) => {
|
|
|
131
227
|
};
|
|
132
228
|
const valueOf = (plugin, label, args, spacing = false) => {
|
|
133
229
|
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(...)
|
|
230
|
+
if (args.some(isNode)) throw failIn(plugin, `cssints: ${label}() takes values, not styles; merge styles with cn(...)`);
|
|
135
231
|
const [only] = args;
|
|
136
232
|
return spacing && args.length === 1 && typeof only === "number" ? `${only * .25}rem` : args.join(" ");
|
|
137
233
|
};
|
|
@@ -544,7 +640,11 @@ const engine = {
|
|
|
544
640
|
};
|
|
545
641
|
//#endregion
|
|
546
642
|
//#region src/runtime.ts
|
|
547
|
-
|
|
643
|
+
function _cx(drops, ...a) {
|
|
644
|
+
const on = a.flat(Infinity).filter(Boolean).join(" ").split(" ");
|
|
645
|
+
const gone = drops.flatMap(([by, c]) => on.includes(by) ? c.split(" ") : []);
|
|
646
|
+
return on.filter((c) => c && !gone.includes(c)).join(" ");
|
|
647
|
+
}
|
|
548
648
|
function _cv(config) {
|
|
549
649
|
return (props = {}) => {
|
|
550
650
|
const out = [config.base];
|
|
@@ -634,9 +734,9 @@ const keyframes = (steps) => {
|
|
|
634
734
|
};
|
|
635
735
|
const positionTryProp = member("positionTry");
|
|
636
736
|
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(
|
|
737
|
+
const cn = (...all) => {
|
|
738
|
+
const args = all.filter(Boolean);
|
|
739
|
+
return node(toDecls("cn", args), carried(args));
|
|
640
740
|
};
|
|
641
741
|
const flex = member("flex");
|
|
642
742
|
const grid = member("grid");
|
|
@@ -1018,6 +1118,37 @@ const cv = (config) => {
|
|
|
1018
1118
|
};
|
|
1019
1119
|
return Object.assign((props) => (built[0] ??= build())(props), { __cv: config });
|
|
1020
1120
|
};
|
|
1121
|
+
const isGroup = (v) => Predicate.hasProperty(v, "__cnGroup");
|
|
1122
|
+
const headOf = Effect.fnUntraced(function* ({ __cnGroup: { statics, parts } }, at) {
|
|
1123
|
+
const { nodes } = yield* Registry;
|
|
1124
|
+
const merged = cn(...statics.map(([, s]) => s));
|
|
1125
|
+
const where = /* @__PURE__ */ new Map();
|
|
1126
|
+
for (const [pos, s] of statics) if (isNode(s)) for (const d of s.__cssints) where.set(d, pos);
|
|
1127
|
+
const all = nodes.get(at.file) ?? nodes.set(at.file, /* @__PURE__ */ new Map()).get(at.file);
|
|
1128
|
+
all.set(at.site, merged.__cssints);
|
|
1129
|
+
const drops = yield* Effect.try({
|
|
1130
|
+
try: () => dropsOf([...merged.__cssints.map((decl) => ({
|
|
1131
|
+
at: where.get(decl),
|
|
1132
|
+
decl,
|
|
1133
|
+
conditional: false
|
|
1134
|
+
})), ...parts.flatMap(([pos, site]) => (all.get(site) ?? []).map((decl) => ({
|
|
1135
|
+
at: pos,
|
|
1136
|
+
decl,
|
|
1137
|
+
conditional: true
|
|
1138
|
+
})))]),
|
|
1139
|
+
catch: (e) => {
|
|
1140
|
+
if (e instanceof MacroError) return e;
|
|
1141
|
+
throw e;
|
|
1142
|
+
}
|
|
1143
|
+
});
|
|
1144
|
+
const classes = yield* classesOf(merged, at);
|
|
1145
|
+
return `${CX_CALL}${Formatter.formatJson(drops)}, ${classes ? `${Formatter.formatJson(classes)}, ` : ""}`;
|
|
1146
|
+
});
|
|
1147
|
+
const __cnGroup = (statics, parts) => ({ __cnGroup: {
|
|
1148
|
+
statics,
|
|
1149
|
+
parts
|
|
1150
|
+
} });
|
|
1151
|
+
const __nocn = () => void 0;
|
|
1021
1152
|
const named = {
|
|
1022
1153
|
cn,
|
|
1023
1154
|
firstThatWorks,
|
|
@@ -1044,6 +1175,7 @@ const named = {
|
|
|
1044
1175
|
};
|
|
1045
1176
|
const css = new Proxy(named, { get: (t, k) => Object.hasOwn(t, k) ? t[k] : member(String(k)) });
|
|
1046
1177
|
named.css = css;
|
|
1178
|
+
const __group = (id) => groupOf(css, id);
|
|
1047
1179
|
const kernelCss = new Proxy({
|
|
1048
1180
|
...named,
|
|
1049
1181
|
nest,
|
|
@@ -1078,6 +1210,7 @@ const isPluginValue = Predicate.isObjectKeyword;
|
|
|
1078
1210
|
const replacementOf = Effect.fnUntraced(function* (at, value) {
|
|
1079
1211
|
if (isNode(value)) return Formatter.formatJson(yield* classesOf(value, at));
|
|
1080
1212
|
if (isCv(value)) return `${CV_CALL}${yield* cvOf(value.__cv, at)})`;
|
|
1213
|
+
if (isGroup(value)) return yield* headOf(value, at);
|
|
1081
1214
|
if (isStyle(value)) return yield* inlineOf(value);
|
|
1082
1215
|
const tokens = tokensOf(value);
|
|
1083
1216
|
if (tokens !== void 0) return tokens;
|
|
@@ -1100,6 +1233,10 @@ const recordSite = Effect.fnUntraced(function* (at, value) {
|
|
|
1100
1233
|
const { sites } = yield* Registry;
|
|
1101
1234
|
const replacement = yield* replacementOf(at, value).pipe(Effect.mapError(located(at)));
|
|
1102
1235
|
if (replacement === void 0) return value;
|
|
1236
|
+
if (isNode(value)) {
|
|
1237
|
+
const { nodes } = yield* Registry;
|
|
1238
|
+
(nodes.get(at.file) ?? nodes.set(at.file, /* @__PURE__ */ new Map()).get(at.file)).set(at.site, value.__cssints);
|
|
1239
|
+
}
|
|
1103
1240
|
if (!sites.has(at.file)) sites.set(at.file, /* @__PURE__ */ new Map());
|
|
1104
1241
|
sites.get(at.file).set(at.site, replacement);
|
|
1105
1242
|
return value;
|
|
@@ -1129,4 +1266,4 @@ function __site(at, value) {
|
|
|
1129
1266
|
return exit.value;
|
|
1130
1267
|
}
|
|
1131
1268
|
//#endregion
|
|
1132
|
-
export { CSS, CSSAtRuleValue, CSSColorValue, CSSImageValue, CSSStyleValue, CSSUnitValue, __at, __site, __unseen, cn, css, cv,
|
|
1269
|
+
export { CSS, CSSAtRuleValue, CSSColorValue, CSSImageValue, CSSStyleValue, CSSUnitValue, __at, __cnGroup, __group, __nocn, __site, __unseen, _cv, _cx, cn, css, cv, firstThatWorks, flex, grid, keyframes, positionTry };
|