cssints 0.0.0-stage → 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.
Files changed (148) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +188 -2
  3. package/dist/author-types-C1AhsnrT.d.mts +80 -0
  4. package/dist/check.d.mts +22 -0
  5. package/dist/check.mjs +37 -0
  6. package/dist/color-BYIxVLlS.mjs +29 -0
  7. package/dist/color-C8OzjAeg.mjs +2 -0
  8. package/dist/contrast-DhK69Xak.mjs +83 -0
  9. package/dist/derived.d.mts +14 -0
  10. package/dist/derived.mjs +391 -0
  11. package/dist/errors-D4ZbcwRo.d.mts +32 -0
  12. package/dist/frame-BoBKjgBB.mjs +92 -0
  13. package/dist/frame.d.mts +72 -0
  14. package/dist/frame.mjs +2 -0
  15. package/dist/group-common-9zpBxfUF.d.mts +1 -0
  16. package/dist/group-types-9ttphdku.d.mts +55 -0
  17. package/dist/groups/compositing-2.d.mts +20 -0
  18. package/dist/groups/css-align-3.d.mts +29 -0
  19. package/dist/groups/css-anchor-position-1.d.mts +49 -0
  20. package/dist/groups/css-anchor-position-2.d.mts +50 -0
  21. package/dist/groups/css-animations-1.d.mts +28 -0
  22. package/dist/groups/css-animations-2.d.mts +29 -0
  23. package/dist/groups/css-backgrounds-3.d.mts +27 -0
  24. package/dist/groups/css-backgrounds-4.d.mts +29 -0
  25. package/dist/groups/css-borders-4.d.mts +95 -0
  26. package/dist/groups/css-box-4.d.mts +38 -0
  27. package/dist/groups/css-break-4.d.mts +23 -0
  28. package/dist/groups/css-cascade-5.d.mts +18 -0
  29. package/dist/groups/css-cascade-6.d.mts +18 -0
  30. package/dist/groups/css-color-4.d.mts +29 -0
  31. package/dist/groups/css-color-5.d.mts +32 -0
  32. package/dist/groups/css-color-6.d.mts +32 -0
  33. package/dist/groups/css-color-adjust-1.d.mts +20 -0
  34. package/dist/groups/css-color-hdr-1.d.mts +19 -0
  35. package/dist/groups/css-conditional-3.d.mts +17 -0
  36. package/dist/groups/css-conditional-4.d.mts +17 -0
  37. package/dist/groups/css-conditional-5.d.mts +22 -0
  38. package/dist/groups/css-contain-2.d.mts +19 -0
  39. package/dist/groups/css-content-3.d.mts +23 -0
  40. package/dist/groups/css-counter-styles-3.d.mts +16 -0
  41. package/dist/groups/css-display-4.d.mts +22 -0
  42. package/dist/groups/css-easing-2.d.mts +18 -0
  43. package/dist/groups/css-env-1.d.mts +16 -0
  44. package/dist/groups/css-flexbox-1.d.mts +24 -0
  45. package/dist/groups/css-fonts-4.d.mts +46 -0
  46. package/dist/groups/css-fonts-5.d.mts +44 -0
  47. package/dist/groups/css-forms-1.d.mts +19 -0
  48. package/dist/groups/css-gaps-1.d.mts +21 -0
  49. package/dist/groups/css-gcpm-3.d.mts +20 -0
  50. package/dist/groups/css-gcpm-4.d.mts +20 -0
  51. package/dist/groups/css-grid-2.d.mts +34 -0
  52. package/dist/groups/css-grid-3.d.mts +34 -0
  53. package/dist/groups/css-images-3.d.mts +25 -0
  54. package/dist/groups/css-images-4.d.mts +32 -0
  55. package/dist/groups/css-images-5.d.mts +33 -0
  56. package/dist/groups/css-inline-3.d.mts +28 -0
  57. package/dist/groups/css-lists-3.d.mts +26 -0
  58. package/dist/groups/css-logical-1.d.mts +35 -0
  59. package/dist/groups/css-masking-1.d.mts +37 -0
  60. package/dist/groups/css-multicol-2.d.mts +24 -0
  61. package/dist/groups/css-overflow-3.d.mts +28 -0
  62. package/dist/groups/css-overflow-4.d.mts +29 -0
  63. package/dist/groups/css-overflow-5.d.mts +31 -0
  64. package/dist/groups/css-overscroll-1.d.mts +22 -0
  65. package/dist/groups/css-page-3.d.mts +18 -0
  66. package/dist/groups/css-page-floats-3.d.mts +19 -0
  67. package/dist/groups/css-position-3.d.mts +29 -0
  68. package/dist/groups/css-position-4.d.mts +30 -0
  69. package/dist/groups/css-rhythm-1.d.mts +18 -0
  70. package/dist/groups/css-round-display-1.d.mts +16 -0
  71. package/dist/groups/css-ruby-1.d.mts +21 -0
  72. package/dist/groups/css-scroll-anchoring-1.d.mts +18 -0
  73. package/dist/groups/css-scroll-snap-1.d.mts +42 -0
  74. package/dist/groups/css-scroll-snap-2.d.mts +43 -0
  75. package/dist/groups/css-scrollbars-1.d.mts +19 -0
  76. package/dist/groups/css-shapes-1.d.mts +27 -0
  77. package/dist/groups/css-shapes-2.d.mts +27 -0
  78. package/dist/groups/css-size-adjust-1.d.mts +18 -0
  79. package/dist/groups/css-sizing-3.d.mts +34 -0
  80. package/dist/groups/css-sizing-4.d.mts +33 -0
  81. package/dist/groups/css-speech-1.d.mts +18 -0
  82. package/dist/groups/css-tables-3.d.mts +22 -0
  83. package/dist/groups/css-text-3.d.mts +36 -0
  84. package/dist/groups/css-text-4.d.mts +40 -0
  85. package/dist/groups/css-text-decor-3.d.mts +30 -0
  86. package/dist/groups/css-text-decor-4.d.mts +31 -0
  87. package/dist/groups/css-transforms-1.d.mts +31 -0
  88. package/dist/groups/css-transforms-2.d.mts +48 -0
  89. package/dist/groups/css-transitions-1.d.mts +22 -0
  90. package/dist/groups/css-transitions-2.d.mts +23 -0
  91. package/dist/groups/css-ui-4.d.mts +35 -0
  92. package/dist/groups/css-values-4.d.mts +38 -0
  93. package/dist/groups/css-values-5.d.mts +43 -0
  94. package/dist/groups/css-variables-2.d.mts +6 -0
  95. package/dist/groups/css-view-transitions-2.d.mts +20 -0
  96. package/dist/groups/css-viewport.d.mts +18 -0
  97. package/dist/groups/css-will-change-1.d.mts +18 -0
  98. package/dist/groups/css-writing-modes-4.d.mts +22 -0
  99. package/dist/groups/css2.d.mts +19 -0
  100. package/dist/groups/fill-stroke-3.d.mts +27 -0
  101. package/dist/groups/filter-effects-1.d.mts +32 -0
  102. package/dist/groups/filter-effects-2.d.mts +33 -0
  103. package/dist/groups/limited-availability.d.mts +2 -0
  104. package/dist/groups/mediaqueries-4.d.mts +16 -0
  105. package/dist/groups/mediaqueries-5.d.mts +16 -0
  106. package/dist/groups/motion-1.d.mts +24 -0
  107. package/dist/groups/newly-available.d.mts +631 -0
  108. package/dist/groups/not-discouraged.d.mts +727 -0
  109. package/dist/groups/scroll-animations-1.d.mts +30 -0
  110. package/dist/groups/selectors-4.d.mts +54 -0
  111. package/dist/groups/selectors-5.d.mts +54 -0
  112. package/dist/groups/widely-available.d.mts +616 -0
  113. package/dist/index.d.mts +48 -0
  114. package/dist/index.mjs +1269 -0
  115. package/dist/instrument-gCazujmb.mjs +1624 -0
  116. package/dist/lowered-D2KusPLp.mjs +28 -0
  117. package/dist/node-OJ_w_Usj.d.mts +233 -0
  118. package/dist/parent-vars.d.mts +13 -0
  119. package/dist/parent-vars.mjs +65 -0
  120. package/dist/plugin-types.d.mts +377 -0
  121. package/dist/plugin.d.mts +3 -0
  122. package/dist/plugin.mjs +30 -0
  123. package/dist/registry-CTumHB8p.mjs +73 -0
  124. package/dist/runtime-Dt4Tm0Q7.d.mts +19 -0
  125. package/dist/runtime.d.mts +18 -0
  126. package/dist/runtime.mjs +25 -0
  127. package/dist/scope-ZVhUxQH1.d.mts +2101 -0
  128. package/dist/sheet-BKsMTa0c.mjs +757 -0
  129. package/dist/surface.d.mts +228 -0
  130. package/dist/surface.mjs +101 -0
  131. package/dist/theme-BsP2E4LB.mjs +929 -0
  132. package/dist/theme-types-Bqv0Ggz_.d.mts +1808 -0
  133. package/dist/trace-otlp-CbKFDsn9.mjs +14 -0
  134. package/dist/tui-types.d.mts +181 -0
  135. package/dist/tui.d.mts +23 -0
  136. package/dist/tui.mjs +427 -0
  137. package/dist/types.d.mts +2 -0
  138. package/dist/vite.d.mts +134 -0
  139. package/dist/vite.mjs +977 -0
  140. package/docs/API.md +1193 -0
  141. package/package.json +85 -4
  142. package/skills/cssints/SKILL.md +203 -0
  143. package/skills/cssints/references/errors.md +86 -0
  144. package/skills/cssints/references/plugins.md +91 -0
  145. package/skills/cssints/references/tokens.md +91 -0
  146. package/skills/cssints-plugin/SKILL.md +177 -0
  147. package/skills/cssints-plugin/references/table.md +124 -0
  148. package/skills/cssints-plugin/references/testing.md +122 -0
@@ -0,0 +1,377 @@
1
+ import { A as Wrap, G as types_d_exports, im as CheckIn, om as Part, sm as Style, t as CheckOverrides } from "./theme-types-Bqv0Ggz_.mjs";
2
+ import { CSSStyleValue } from "@cssints/css-grammar/values";
3
+ import { Grammar, TokenType } from "@cssints/css-grammar/token";
4
+ import { ValidSelector } from "@cssints/css-grammar/query";
5
+ //#region src/author-types.d.ts
6
+ /** A declaration a member emits: property and value (a custom property, `--_r`, is allowed). */
7
+ type Decl = readonly [prop: string, value: string];
8
+ /** A feature of `@mdn/browser-compat-data`: `css.at-rules.container.style_queries_for_custom_properties`. */
9
+ type BcdKey = `css.${string}`;
10
+ /**
11
+ * Global rules, registered once by `key` (`name@version`) in layer `_.k`; `atProperty` (the `@property` rules of its
12
+ * custom properties) goes at the top of the sheet. A target lacking a `requires` feature gets a support warning, never an
13
+ * error; `{ key, exact: true }` also counts a partial implementation as lacking (relative colour, whose channel scales
14
+ * differ in Chrome 119-121 and Safari 16.4-17.6). Two members share a kernel by pointing at the same object; the same key with other CSS is a build error, as is
15
+ * a custom property or a marker that two keys share.
16
+ */
17
+ interface Kernel {
18
+ key: string;
19
+ css: string;
20
+ atProperty?: string;
21
+ requires?: (BcdKey | {
22
+ key: BcdKey;
23
+ exact: true;
24
+ })[];
25
+ }
26
+ /**
27
+ * A global rule a member contributes. It is identified by its content (`layer` and `css`): the same rule from two
28
+ * styles is one, an edit of it replaces the old one, and it is in the sheet of the modules whose styles carry it, until
29
+ * they stop. It goes to layer `_.k` with the kernels. Unlike a kernel, two globals **may** declare the same custom
30
+ * property: a look sets the same `--color-*` in several source layers, which is the point of fill-through. Use it for a
31
+ * rule that is not a class.
32
+ */
33
+ interface GlobalRule {
34
+ css: string;
35
+ /**
36
+ * A top-level `@layer` of this name to put the rule in (a rule that must beat the engine's `:root` fallbacks). The
37
+ * layer must be declared: by `layers` of the same `Made`, or by `layers()` in a module this one imports. Omitted:
38
+ * layer `_.k`.
39
+ */
40
+ layer?: string;
41
+ }
42
+ /**
43
+ * A theme a member contributes, as `createGlobalTheme(tokens, selector, overrides, { layer, scope })` makes one: the
44
+ * same checks (the paths and values of `overrides` against the types of `tokens`, a layer that is declared), the
45
+ * aliases that depend on an override declared again, and `check.contrast` reads it. `tokens` is a token set of
46
+ * `createTokens()` that the member got from its caller (a closure: the arguments of a member are joined into one string).
47
+ */
48
+ interface ThemeRule {
49
+ tokens: object;
50
+ overrides: object;
51
+ selector: string;
52
+ layer?: string;
53
+ /** A selector: the rule goes inside `@scope (<scope>) { ... }`. */
54
+ scope?: string;
55
+ }
56
+ /** One element family of a runtime: the nearest `marker` ancestor's computed `read` is copied into `write`. */
57
+ interface ParentVar$1 {
58
+ marker: string;
59
+ read: `--${string}`;
60
+ write: `--${string}`;
61
+ /** A property that changes when a CSS condition (`:hover`, a media query) changes `read`: its transition re-runs the copy. */
62
+ watch?: `--${string}`;
63
+ }
64
+ /**
65
+ * The runtime half of a member. The client module that holds a site with the member imports
66
+ * `virtual:cssints/runtime/<name>`, which is empty unless a browserslist target lacks a feature in `polyfills` (and, with
67
+ * `parentVars`, has `@property`, which the script stands on); then it imports `script`, configures `cssints/parent-vars`,
68
+ * and `css` (the fallback rules) is added to the sheet in layer `_.k`. A `requires` of the member's kernel that is in
69
+ * `polyfills` warns only for the targets the runtime does not reach.
70
+ */
71
+ interface Runtime {
72
+ polyfills: BcdKey[];
73
+ parentVars?: ParentVar$1[];
74
+ css?: string;
75
+ /** The plugin's browser script, a module specifier the app resolves (`"@cssints/balance/runtime"`): imported, never evaluated at build time. */
76
+ script?: string;
77
+ }
78
+ /** A build error when one `cn()` holds the member's marker and a property listed here (a name, or a pattern). */
79
+ interface Conflict {
80
+ props: (string | RegExp)[];
81
+ message: string;
82
+ }
83
+ //#endregion
84
+ //#region src/scope.d.ts
85
+ /** A selector of `nest()`: one with `&`, the kernel's class (`& > *`, `& p`, `:root:has(&)`, `.x &`); the build reads the rest. */
86
+ type NestSelector<S extends string> = S extends `${string}&${string}` ? S : `nest(): "${S}" has no &`;
87
+ /** What only a kernel written as styles has, besides all of "cssints". */
88
+ interface KernelCss {
89
+ /**
90
+ * `nest("& > *")(flexGrow(1))`: styles under a selector around the kernel's class (`._k > *`, `:root:has(._k)`). A
91
+ * condition inside applies to its subject (`& > *:hover`), one around it to the element (`._k:hover > *`,
92
+ * `:root:has(._k:hover)`). One condition. When the subject is another element (`&` not in the last compound), what it
93
+ * sets is not the element's, so a member's derived conflicts leave it out; `.x &` is the element's.
94
+ */
95
+ nest: <const S extends string>(selector: NestSelector<S>) => Wrap;
96
+ /**
97
+ * `vars({ "--_gap": "1rem" })`: custom properties on the element (`--_x` is `--<scope>-x`), values not checked. A
98
+ * `keyframes()` or `positionTry()` name is a value too: its rule goes with the kernel. Not part of derived conflicts.
99
+ */
100
+ vars: (set: {
101
+ readonly [name: `--${string}`]: string | number | CSSStyleValue;
102
+ }) => Style;
103
+ }
104
+ /** The `css` a kernel written as styles is handed: all of "cssints", as user code has it, and `nest` and `vars`. */
105
+ type Css = typeof types_d_exports & KernelCss;
106
+ /**
107
+ * A kernel: global CSS printed once, bound to a class. `&` stands for the class the engine mints for it (`&(mod.key)`: the
108
+ * class of the kernel `key` of an embedded scope `mod`), `--_x` for the custom property `--<scope>-x`. `css` is verbatim
109
+ * CSS, or styles (`(css) => css.outline("var(--_w)", "solid")`: declarations checked like a user's, printed as `&{...}`).
110
+ */
111
+ interface KernelDef {
112
+ css: string | ((css: Css) => Style | readonly Style[]);
113
+ atProperty?: string;
114
+ requires?: (BcdKey | {
115
+ key: BcdKey;
116
+ exact: true;
117
+ })[];
118
+ }
119
+ /** A static global rule; `layer` is a top-level layer that `layers` declares (a contract's name: never namespaced). */
120
+ interface GlobalDef {
121
+ rule: string;
122
+ layer?: string;
123
+ }
124
+ /** Top-level layers to declare, in order: after the engine's layers, or with `before: true` before them (below every class). */
125
+ interface LayersDef {
126
+ layers: readonly string[];
127
+ before?: boolean;
128
+ }
129
+ interface ParentVar {
130
+ marker: "&";
131
+ read: `--_${string}`;
132
+ write: `--_${string}`;
133
+ watch?: `--_${string}`;
134
+ }
135
+ /** The browser half, delivered when a target lacks a polyfilled feature (`virtual:cssints/runtime/<scope>.<entry>`); `&` is the marker of the member's first kernel. */
136
+ interface RuntimeDef {
137
+ polyfills: BcdKey[];
138
+ parentVars?: ParentVar[];
139
+ css?: string;
140
+ /** A module specifier the app resolves (a package subpath, `"@cssints/balance/runtime"`): imported when a target lacks a polyfilled feature. */
141
+ script?: string;
142
+ }
143
+ /** A build error when one `cn()` holds the member's marker and a property listed here (a name, or a pattern). */
144
+ interface ConflictDef {
145
+ props: (string | RegExp)[];
146
+ message: string;
147
+ }
148
+ /** A token set the scope owns: its paths become syntax aliases (`<brand.color.accent>` is the token's type). */
149
+ interface TokensDef {
150
+ tokens: object;
151
+ }
152
+ /** One method of a chain. `args: ""` takes no value; a lone number is a spacing step with `spacing`. */
153
+ interface MethodDef<G extends string = string, Sp extends boolean = boolean, X extends string = string> {
154
+ readonly args: G;
155
+ readonly spacing?: Sp;
156
+ readonly excludes?: readonly X[];
157
+ readonly emit: (value: string) => Decl[];
158
+ }
159
+ declare const typed: unique symbol;
160
+ /** An argument whose type is TypeScript's, not CSS's (`arg<"home" | "star">()`); the member's `build` checks it at build time. */
161
+ interface Typed<T> {
162
+ readonly [typed]: T;
163
+ }
164
+ /** `arg<T>()`: one value of the TypeScript type `T`. */
165
+ export declare const arg: <T>() => Typed<T>;
166
+ /** One argument: a grammar (aliases of the table allowed), `"$tokens"` (a token set), `"$overrides"` (values for the paths of the `$tokens` before it), `"$selector"` (a CSS selector list) or `arg<T>()`. */
167
+ type Leaf = string | Typed<unknown>;
168
+ /** An object argument of named leaves (`"key?"` is optional). */
169
+ interface RecordDef {
170
+ readonly [key: string]: Leaf;
171
+ }
172
+ /**
173
+ * What a call takes: a grammar (the parts, joined by a space, as a property takes them), `arg<T>()`, or a tuple of
174
+ * positional arguments, each a `Leaf` or one `RecordDef` (an object; it may be left out when all its keys are optional).
175
+ */
176
+ type ArgsDef = Leaf | readonly (Leaf | RecordDef)[];
177
+ /** What a member's build gives: declarations, and what else it needs by name (`uses`), globals, themes and layers. */
178
+ interface Made {
179
+ decls?: Decl[];
180
+ /** Entries of the table (kernels, globals, layers, runtimes, conflicts) chosen by this call; `module.entry` for an embedded scope. */
181
+ uses?: readonly string[];
182
+ /** A rule that is not a class: identified by its content, forgotten with the file that made it. */
183
+ globals?: {
184
+ css: string;
185
+ layer?: string;
186
+ }[];
187
+ /** As `createGlobalTheme(tokens, selector, overrides, { layer, scope })`: registered like any theme. */
188
+ themes?: {
189
+ tokens: object;
190
+ overrides: object;
191
+ selector: string;
192
+ layer?: string;
193
+ scope?: string;
194
+ }[];
195
+ /** Top-level layers to declare, in order: a list, printed after the engine's layers, or `{ layers, before: true }`. */
196
+ layers?: readonly string[] | LayersDef;
197
+ }
198
+ interface ChainDef {
199
+ chain: {
200
+ readonly [method: string]: MethodDef;
201
+ };
202
+ uses?: readonly string[];
203
+ /** Every style of the member carries the group marker `_g-<scope>`, which `within(state, "<scope>")` reads. */
204
+ group?: true;
205
+ }
206
+ /** A member that takes arguments and gives declarations: its function is the entry of the same name in `.build()`. */
207
+ interface CallDef {
208
+ args: ArgsDef;
209
+ uses?: readonly string[];
210
+ /** Every style of the member carries the group marker `_g-<scope>`, which `within(state, "<scope>")` reads. */
211
+ group?: true;
212
+ }
213
+ /**
214
+ * A member computed at build time into a value. `value` gets the arguments in an array: a grammar's parts as text, one by
215
+ * one; a tuple's arguments or `arg<T>()` as `build` would, which needs `fn({ args, value })` to type them. `label` names
216
+ * the member in its errors (the key by default).
217
+ */
218
+ interface ValueDef {
219
+ args: ArgsDef;
220
+ value(parts: string[]): string | CSSStyleValue;
221
+ label?: string;
222
+ }
223
+ /**
224
+ * A value member whose `args` is a tuple or `arg<T>()`: `value` gets the arguments as a call member's `build` does. A
225
+ * table cannot type `value` from the `args` beside it (as `build()` does for call members); this call can.
226
+ */
227
+ export declare const fn: <const D extends ArgsDef, R extends string | CSSStyleValue, const L extends string = never>(def: {
228
+ args: D;
229
+ label?: L;
230
+ value: (args: Params<D>) => R;
231
+ }) => {
232
+ args: D;
233
+ label?: L;
234
+ value(args: never): R;
235
+ };
236
+ interface ModuleLike {
237
+ readonly "~scope": string;
238
+ readonly "~table": object;
239
+ readonly "~aliases": object;
240
+ readonly "~usable": string;
241
+ }
242
+ type Entry = string | ModuleLike | ChainDef | CallDef | ValueDef | KernelDef | GlobalDef | LayersDef | RuntimeDef | ConflictDef | TokensDef;
243
+ interface Table {
244
+ readonly [key: string]: Entry;
245
+ }
246
+ type Kind<K, V> = V extends string ? K extends `-${string}` ? "prop" : "alias" : V extends ModuleLike ? "module" : V extends {
247
+ chain: unknown;
248
+ } ? "chain" : V extends {
249
+ args: unknown;
250
+ value: unknown;
251
+ } ? "value" : V extends {
252
+ args: unknown;
253
+ } ? "call" : V extends {
254
+ tokens: unknown;
255
+ } ? "tokens" : V extends {
256
+ polyfills: unknown;
257
+ } ? "runtime" : V extends {
258
+ props: unknown;
259
+ } ? "conflicts" : V extends {
260
+ rule: unknown;
261
+ } ? "global" : V extends {
262
+ layers: unknown;
263
+ } ? "layers" : V extends {
264
+ css: unknown;
265
+ } ? "kernel" : never;
266
+ type Strip<K> = K extends `#${infer R}` ? R : K;
267
+ type Private<K> = K extends `#${string}` ? true : false;
268
+ type Usable = "kernel" | "global" | "layers" | "runtime" | "conflicts";
269
+ type Camel<S extends string> = S extends `-${infer H}` ? Camel<H> : S extends `${infer A}-${infer B}` ? `${A}${Capitalize<Camel<B>>}` : S;
270
+ /** `<name>` of the table in place, as a group; what is not an alias of the table is left to mdn. The runtime `expand` does the same. */
271
+ type Expand<G extends string, A, D extends 0[] = []> = D["length"] extends 6 ? G : G extends `${infer Pre}<${infer N}>${infer Post}` ? N extends keyof A ? A[N] extends (infer S extends string) ? `${Pre}[ ${Expand<S, A, [...D, 0]>} ]${Expand<Post, A, D>}` : G : `${Pre}<${N}>${Expand<Post, A, D>}` : G;
272
+ type Own<T> = { [K in keyof T & string as Kind<K, T[K]> extends "alias" ? Strip<K> : never]: T[K]; };
273
+ type Resolved<A> = { [N in keyof A]: A[N] extends string ? Expand<A[N], A> : never; };
274
+ type Paths<X, P extends string = ""> = { [K in keyof X & string]: X[K] extends {
275
+ readonly "~token": infer Kd extends TokenType;
276
+ } ? { [Q in `${P}${K}`]: Grammar<Kd>; } : Paths<X[K], `${P}${K}.`>; }[keyof X & string];
277
+ type Flat<U> = (U extends unknown ? (x: U) => void : never) extends ((x: infer I) => void) ? I : never;
278
+ type ModAliases<T> = Flat<{ [K in keyof T & string]: Kind<K, T[K]> extends "module" ? T[K] extends {
279
+ "~aliases": infer MA;
280
+ } ? { [N in keyof MA & string as `${K}.${N}`]: MA[N]; } : never : Kind<K, T[K]> extends "tokens" ? T[K] extends {
281
+ tokens: infer X;
282
+ } ? Flat<Paths<X, `${K}.`>> : never : never; }[keyof T & string]>;
283
+ type AliasesOf<T> = Own<T> & ModAliases<T>;
284
+ type Public<T> = Resolved<{ [K in keyof Own<T> as Private<K> extends true ? never : K]: Own<T>[K]; }>;
285
+ type UsableOf<T> = { [K in keyof T & string]: Kind<K, T[K]> extends Usable ? Strip<K> : Kind<K, T[K]> extends "module" ? T[K] extends {
286
+ "~usable": infer U extends string;
287
+ } ? `${K}.${U}` : never : never; }[keyof T & string];
288
+ type PublicUsable<T> = { [K in keyof T & string]: Private<K> extends true ? never : Kind<K, T[K]> extends Usable ? K : Kind<K, T[K]> extends "module" ? T[K] extends {
289
+ "~usable": infer U extends string;
290
+ } ? `${K}.${U}` : never : never; }[keyof T & string];
291
+ type Excluded<X extends string> = string extends X ? never : X;
292
+ /** The chain of a context: each method is checked against its grammar and leaves the chain, so it is used once. */
293
+ type Chain<L extends string, M, A> = Style & { readonly [K in keyof M & string]: M[K] extends MethodDef<infer G, infer Sp, infer X> ? string extends G ? (...parts: [`${L}.${K}: the grammar is not a literal type: write it as const`]) => never : G extends "" ? () => Chain<L, Omit<M, K | Excluded<X>>, A> : <const P extends readonly Part[]>(...parts: CheckIn<`${L}.${K}`, Expand<G, A>, boolean extends Sp ? false : Sp, P>) => Chain<L, Omit<M, K | Excluded<X>>, A> : never; };
294
+ type Err<Why extends string> = {
295
+ readonly $error: Why;
296
+ };
297
+ type Gram<L extends string, G extends string, V extends Part> = CheckIn<L, G, false, [V]>[0] extends (infer R) ? [V] extends [R] ? V : R extends string ? Err<R> : never : never;
298
+ type Req<D> = { [K in keyof D as K extends `${string}?` ? never : K]: unknown; };
299
+ type DefOf<D, K> = K extends keyof D ? D[K] : `${K & string}?` extends keyof D ? D[`${K & string}?`] : never;
300
+ type One<L extends string, A, S, V, Tok> = S extends "$tokens" ? V extends object ? V : Err<`${L}: expected a token set (createTokens)`> : S extends "$overrides" ? [Tok] extends [never] ? Err<`${L}: "$overrides" needs a "$tokens" before it`> : CheckOverrides<Tok, V> : S extends "$selector" ? V extends string ? ValidSelector<V> extends V ? V : Err<ValidSelector<V>> : Err<`${L}: expected a selector`> : S extends string ? V extends Part ? Gram<L, Expand<S, A>, V> : Err<`${L}: expected a value`> : S extends Typed<infer T> ? V extends T ? V : Err<`${L}: wrong type`> : V extends object ? { [K in keyof V]: One<`${L}.${K & string}`, A, DefOf<S, K>, V[K], never>; } & Req<S> : Err<`${L}: expected an object`>;
301
+ type TokensAt<D extends readonly unknown[], P extends readonly unknown[]> = D extends readonly [infer H, ...infer R] ? H extends "$tokens" ? P extends readonly [infer X, ...unknown[]] ? X : never : P extends readonly [unknown, ...infer Q] ? TokensAt<R, Q> : never : never;
302
+ type CheckAll<L extends string, A, D extends readonly unknown[], P extends readonly unknown[]> = { [K in keyof P]: K extends keyof D ? One<L, A, D[K], P[K], TokensAt<D, P>> : P[K]; };
303
+ type Arity<D extends readonly unknown[]> = D extends readonly [...infer R, infer Last] ? Last extends string | Typed<unknown> ? { readonly [K in keyof D]: unknown; } : [keyof Req<Last>] extends [never] ? readonly [...{ [K in keyof R]: unknown; }, unknown?] : { readonly [K in keyof D]: unknown; } : readonly [];
304
+ type Param<Def> = Def extends "$tokens" ? object : Def extends "$overrides" ? {
305
+ readonly [group: string]: unknown;
306
+ } : Def extends "$selector" ? string : Def extends string ? string : Def extends Typed<infer T> ? T : { -readonly [K in keyof Def as K extends `${string}?` ? never : K]: Param<Def[K]>; } & { -readonly [K in keyof Def as K extends `${infer R}?` ? R : never]?: Param<Def[K]>; };
307
+ type Params<D> = D extends string ? [value: string] : D extends Typed<infer T> ? [value: T] : D extends readonly unknown[] ? D extends readonly [...infer R, infer Last] ? Last extends string | Typed<unknown> ? { -readonly [K in keyof D]: Param<D[K]>; } : [keyof Req<Last>] extends [never] ? [...{ -readonly [K in keyof R]: Param<R[K]>; }, Param<Last>] : { -readonly [K in keyof D]: Param<D[K]>; } : [] : never;
308
+ type Callable<L extends string, D, A, R> = D extends string ? <const P extends readonly Part[]>(...parts: CheckIn<L, Expand<D, A>, false, P>) => R : D extends Typed<infer X> ? (value: X) => R : D extends readonly unknown[] ? <const P extends Arity<D>>(...args: P & CheckAll<L, A, D, P>) => R : never;
309
+ type Label<K extends string, V> = V extends {
310
+ label?: infer L;
311
+ } ? NonNullable<L> extends (infer S extends string) ? [S] extends [never] ? K : S : K : K;
312
+ type Opaque<R> = R extends string ? string : R;
313
+ type MemberOf<K extends string, V, A> = Kind<K, V> extends "chain" ? V extends {
314
+ chain: infer M;
315
+ } ? () => Chain<K, M, A> : never : Kind<K, V> extends "call" ? V extends {
316
+ args: infer D;
317
+ } ? Callable<K, D, A, Style> : never : Kind<K, V> extends "value" ? V extends {
318
+ args: infer D;
319
+ value: (args: never) => infer R;
320
+ } ? Callable<Label<K, V>, D, A, Opaque<R>> : never : Kind<K, V> extends "prop" ? V extends (infer G extends string) ? <const P extends readonly Part[]>(...parts: CheckIn<K, Expand<G, A>, false, P>) => Style : never : never;
321
+ /** What `.export()` gives: the members of the table, typed from it (a `-prefixed` property is camel-cased, an embedded scope nests). */
322
+ type Members<T> = { [K in keyof T & string as Private<K> extends true ? never : Kind<K, T[K]> extends "chain" | "call" | "value" ? K : Kind<K, T[K]> extends "prop" ? Camel<K> : Kind<K, T[K]> extends "module" ? K : never]: Kind<K, T[K]> extends "module" ? T[K] extends {
323
+ "~scope": string;
324
+ "~table": infer MT;
325
+ } ? Members<MT> : never : MemberOf<K, T[K], AliasesOf<T>>; };
326
+ type Bad<Why extends string> = {
327
+ readonly $error: `cssints: ${Why}`;
328
+ };
329
+ type BadUses<N extends string, T, V> = V extends {
330
+ uses: readonly (infer U extends string)[];
331
+ } ? [Exclude<U, UsableOf<T>>] extends [never] ? unknown : Bad<`${N}: uses ${Exclude<U, UsableOf<T>>}, which is not a kernel, global, layers, runtime or conflicts of this scope`> : unknown;
332
+ type Clash<N extends string, T, K> = K extends `#${infer R}` ? R extends keyof T ? Bad<`${N}: ${K} and ${R} share a name: rename one`> : unknown : unknown;
333
+ type BadValue<N extends string, K, V> = V extends {
334
+ args: infer D;
335
+ value: (args: infer P) => unknown;
336
+ } ? D extends string ? unknown : [P] extends [never] ? unknown : Bad<`${N}: ${K & string}: a value member with a tuple or arg<T>() is written fn({ args, value })`> : unknown;
337
+ type Valid<N extends string, T> = { readonly [K in keyof T]: BadUses<N, T, T[K]> & Clash<N, T, K> & BadValue<N, K, T[K]>; };
338
+ type CallKeys<T> = { [K in keyof T & string]: Kind<K, T[K]> extends "call" ? K : never; }[keyof T & string];
339
+ type ArgsOf<E> = E extends {
340
+ args: infer D;
341
+ } ? D : never;
342
+ /** The `build` of each call member, typed from its `args`. */
343
+ type Impl<T> = { readonly [K in CallKeys<T>]: (...args: Params<ArgsOf<T[K]>>) => Made; };
344
+ interface Scope<N extends string, T> {
345
+ readonly "~scope": N;
346
+ readonly "~table": T;
347
+ /** The public aliases, resolved: what an embedding scope reads as `<key.alias>`. */
348
+ readonly "~aliases": Public<T>;
349
+ readonly "~usable": PublicUsable<T>;
350
+ readonly name: N;
351
+ /** The typed members of the table: `export const { ring } = scope("ring", { ... }).export()`. */
352
+ export(): Members<T>;
353
+ }
354
+ /** A scope with call members (`args`) is not usable until `.build()` gives the function of each: typed from its `args`. */
355
+ interface Pending<N extends string, T> {
356
+ build(impl: Impl<T>): Scope<N, T>;
357
+ }
358
+ /**
359
+ * A plugin is a scope: `scope("name", table)`. The table holds, by shape: syntax aliases (a string), typed properties (a
360
+ * `-vendor-prop` key with a grammar), kernels, static globals, layers, runtimes, conflicts, token sets and embedded scopes,
361
+ * and the members (`chain`, `args` + `build`, `args` + `value`). A key starting `#` is private. Everything it declares is
362
+ * namespaced by `name`, which is unique in the process (`cssints` and `derived` are reserved).
363
+ */
364
+ export declare function scope<const N extends string, const T extends Table>(name: N, table: T & Valid<N, T>): [CallKeys<T>] extends [never] ? Scope<N, T> : Pending<N, T>;
365
+ /**
366
+ * The build's targets that lack one of the BCD keys, as browserslist names them (`["firefox 140"]`), by the rules of the
367
+ * support warnings (`partial_implementation` lacks); empty when every target has them all. Build time, like `scope()`.
368
+ */
369
+ export declare const lacking: (...keys: BcdKey[]) => string[];
370
+ /**
371
+ * Tells the engine that the module being evaluated read the file at `path` (relative to the working directory): in dev, an
372
+ * edit of the file runs that module again, as an edit of a module it imports does; in `vite build --watch`, it is a watched
373
+ * file. Build time, like `scope()`: in a member's functions or in the plugin's own.
374
+ */
375
+ export declare const dependsOn: (path: string) => void;
376
+ //#endregion
377
+ export type { ArgsDef, Chain, Conflict, Css, Decl, Entry, GlobalRule, Impl, Kernel, KernelDef, Made, Members, Part, Pending, Runtime, Scope, Style, Table, ThemeRule, Typed };
@@ -0,0 +1,3 @@
1
+ import { _ as lacking, a as Entry, b as Style, c as Made, d as Scope, f as Table, g as fn, h as dependsOn, i as Css, l as Members, m as arg, n as ArgsDef, o as Impl, p as Typed, r as Chain, s as KernelDef, u as Pending, v as scope, y as Part } from "./scope-ZVhUxQH1.mjs";
2
+ import { a as Kernel, i as GlobalRule, n as Conflict, o as Runtime, r as Decl, s as ThemeRule } from "./author-types-C1AhsnrT.mjs";
3
+ export { type ArgsDef, type Chain, type Conflict, type Css, type Decl, type Entry, type GlobalRule, type Impl, type Kernel, type KernelDef, type Made, type Members, type Part, type Pending, type Runtime, type Scope, type Style, type Table, type ThemeRule, type Typed, arg, dependsOn, fn, lacking, scope };
@@ -0,0 +1,30 @@
1
+ //#region src/scope.ts
2
+ /** `arg<T>()`: one value of the TypeScript type `T`. */
3
+ const arg = () => ({ "~arg": 1 });
4
+ /**
5
+ * A value member whose `args` is a tuple or `arg<T>()`: `value` gets the arguments as a call member's `build` does. A
6
+ * table cannot type `value` from the `args` beside it (as `build()` does for call members); this call can.
7
+ */
8
+ const fn = (def) => def;
9
+ /** The engine, once the library is loaded (the prepended import of every module with sites loads it before any plugin module runs). */
10
+ const engine = () => {
11
+ const e = globalThis.__cssints?.engine;
12
+ if (!e) throw new Error("cssints: the plugin helpers run at build time, once the cssints library is loaded");
13
+ return e;
14
+ };
15
+ function scope(name, table) {
16
+ return engine().scope(name, table);
17
+ }
18
+ /**
19
+ * The build's targets that lack one of the BCD keys, as browserslist names them (`["firefox 140"]`), by the rules of the
20
+ * support warnings (`partial_implementation` lacks); empty when every target has them all. Build time, like `scope()`.
21
+ */
22
+ const lacking = (...keys) => engine().lacking(keys);
23
+ /**
24
+ * Tells the engine that the module being evaluated read the file at `path` (relative to the working directory): in dev, an
25
+ * edit of the file runs that module again, as an edit of a module it imports does; in `vite build --watch`, it is a watched
26
+ * file. Build time, like `scope()`: in a member's functions or in the plugin's own.
27
+ */
28
+ const dependsOn = (path) => engine().dependsOn(path);
29
+ //#endregion
30
+ export { arg, dependsOn, fn, lacking, scope };
@@ -0,0 +1,73 @@
1
+ import { Context, Data } from "effect";
2
+ //#region src/errors.ts
3
+ /** A css.* call, cv(), or a value in it is wrong. `file`, `site` (index) and `offset` name the call site, when known. */
4
+ var MacroError = class extends Data.TaggedError("MacroError") {};
5
+ /** A plugin member was called wrongly, or its styles conflict. `pluginName` is the member's name; the call site as in MacroError. */
6
+ var MemberError = class extends Data.TaggedError("MemberError") {};
7
+ /** `import ... from "cssints"` without the attribute names something that only exists at build time. */
8
+ var ImportError = class extends Data.TaggedError("ImportError") {};
9
+ /** Evaluating the module threw something that is not a MacroError, or did not finish in time. */
10
+ var EvalError = class extends Data.TaggedError("EvalError") {};
11
+ /** The module ran, but a site of it did not report a replacement. */
12
+ var SiteMissingError = class extends Data.TaggedError("SiteMissingError") {};
13
+ /** Vite refused something the plugin asked of it: the private server, the CSS pipeline. */
14
+ var HookError = class extends Data.TaggedError("HookError") {};
15
+ /** cssints/check `contrast`: a colour that has no contrast (one it cannot read, or a translucent one). */
16
+ var ContrastError = class extends Data.TaggedError("ContrastError") {};
17
+ //#endregion
18
+ //#region src/registry.ts
19
+ const registry = globalThis.__cssints ??= {
20
+ sites: /* @__PURE__ */ new Map(),
21
+ nodes: /* @__PURE__ */ new Map(),
22
+ rules: /* @__PURE__ */ new Map(),
23
+ globals: /* @__PURE__ */ new Map(),
24
+ layers: /* @__PURE__ */ new Map(),
25
+ kernels: /* @__PURE__ */ new Map(),
26
+ runtimes: /* @__PURE__ */ new Map(),
27
+ scopes: /* @__PURE__ */ new Map(),
28
+ userProps: /* @__PURE__ */ new Set(),
29
+ seen: /* @__PURE__ */ new Map(),
30
+ properties: /* @__PURE__ */ new Map(),
31
+ defs: /* @__PURE__ */ new Map(),
32
+ themed: /* @__PURE__ */ new Map(),
33
+ checks: /* @__PURE__ */ new Map(),
34
+ gen: 0,
35
+ tokens: 0,
36
+ warnings: [],
37
+ warned: /* @__PURE__ */ new Set(),
38
+ lowered: /* @__PURE__ */ new Map(),
39
+ files: /* @__PURE__ */ new Set()
40
+ };
41
+ const warn = (state, key, message, at = state.at) => {
42
+ const k = `${at?.file ?? ""}\0${key}`;
43
+ if (state.warned.has(k)) return;
44
+ state.warned.add(k);
45
+ state.warnings.push({
46
+ message,
47
+ at
48
+ });
49
+ };
50
+ const forgetWarnings = (files) => {
51
+ if (!files) return registry.warned.clear();
52
+ const prefixes = files.map((f) => `${f}\0`);
53
+ for (const k of registry.warned) if (prefixes.some((p) => k.startsWith(p))) registry.warned.delete(k);
54
+ };
55
+ const Registry = Context.Reference("cssints/Registry", { defaultValue: () => registry });
56
+ const unuse = (entries, file) => {
57
+ for (const [k, e] of entries) if (e.users.delete(file) && !e.users.size) entries.delete(k);
58
+ };
59
+ const forgetKernels = (file) => {
60
+ for (const entries of [
61
+ registry.kernels,
62
+ registry.runtimes,
63
+ registry.globals,
64
+ registry.layers
65
+ ]) unuse(entries, file);
66
+ };
67
+ const forget = (file) => {
68
+ forgetKernels(file);
69
+ for (const themed of [registry.themed, registry.terminal?.themed ?? /* @__PURE__ */ new Map()]) for (const [k, t] of themed) if (t.file === file) themed.delete(k);
70
+ for (const [k, c] of registry.checks) if (c.at.file === file) registry.checks.delete(k);
71
+ };
72
+ //#endregion
73
+ export { registry as a, EvalError as c, MacroError as d, MemberError as f, forgetWarnings as i, HookError as l, forget as n, warn as o, SiteMissingError as p, forgetKernels as r, ContrastError as s, Registry as t, ImportError as u };
@@ -0,0 +1,19 @@
1
+ //#region src/runtime.d.ts
2
+ type ClassValue = string | false | null | undefined | 0 | ClassValue[];
3
+ declare function _cx(drops: [string, string][], ...a: ClassValue[]): string;
4
+ interface CvRuntimeConfig {
5
+ base: string;
6
+ variants: Record<string, Record<string, string>>;
7
+ defaultVariants: Record<string, string | boolean>;
8
+ /** The base classes a variant value replaces (it sets the same property): dropped while that value is active. */
9
+ drops?: Record<string, Record<string, string>>;
10
+ /** Added when every variant in `when` has that value; `drops` are the base and variant classes it replaces. */
11
+ compound?: {
12
+ when: Record<string, string>;
13
+ class: string;
14
+ drops?: string;
15
+ }[];
16
+ }
17
+ declare function _cv(config: CvRuntimeConfig): (props?: Record<string, string | boolean | undefined>) => string;
18
+ //#endregion
19
+ export { _cv as n, _cx as r, ClassValue as t };
@@ -0,0 +1,18 @@
1
+ //#region src/runtime.d.ts
2
+ export type ClassValue = string | false | null | undefined | 0 | ClassValue[];
3
+ export declare function _cx(drops: [string, string][], ...a: ClassValue[]): string;
4
+ export interface CvRuntimeConfig {
5
+ base: string;
6
+ variants: Record<string, Record<string, string>>;
7
+ defaultVariants: Record<string, string | boolean>;
8
+ /** The base classes a variant value replaces (it sets the same property): dropped while that value is active. */
9
+ drops?: Record<string, Record<string, string>>;
10
+ /** Added when every variant in `when` has that value; `drops` are the base and variant classes it replaces. */
11
+ compound?: {
12
+ when: Record<string, string>;
13
+ class: string;
14
+ drops?: string;
15
+ }[];
16
+ }
17
+ export declare function _cv(config: CvRuntimeConfig): (props?: Record<string, string | boolean | undefined>) => string;
18
+ //#endregion
@@ -0,0 +1,25 @@
1
+ //#region src/runtime.ts
2
+ function _cx(drops, ...a) {
3
+ const on = a.flat(Infinity).filter(Boolean).join(" ").split(" ");
4
+ const gone = drops.flatMap(([by, c]) => on.includes(by) ? c.split(" ") : []);
5
+ return on.filter((c) => c && !gone.includes(c)).join(" ");
6
+ }
7
+ function _cv(config) {
8
+ return (props = {}) => {
9
+ const out = [config.base];
10
+ const gone = [];
11
+ const val = {};
12
+ const take = (c, d) => {
13
+ if (c) out.push(c);
14
+ if (c && d) gone.push(...d.split(" "));
15
+ };
16
+ for (const name in config.variants) {
17
+ const v = val[name] = String(props[name] ?? config.defaultVariants[name]);
18
+ take(config.variants[name][v], config.drops?.[name]?.[v]);
19
+ }
20
+ for (const m of config.compound ?? []) if (Object.keys(m.when).every((k) => val[k] === m.when[k])) take(m.class, m.drops);
21
+ return out.join(" ").split(" ").filter((c) => c && !gone.includes(c)).join(" ");
22
+ };
23
+ }
24
+ //#endregion
25
+ export { _cv, _cx };