fashionable 0.2.0 → 0.4.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/dist/calc/index.d.mts +1 -1
- package/dist/calc/index.mjs +1 -1
- package/dist/data/index.d.mts +2 -208
- package/dist/data/index.mjs +73 -54
- package/dist/data/index.mjs.map +1 -1
- package/dist/declaration/index.d.mts +1 -1
- package/dist/declaration/index.mjs +9 -28
- package/dist/declaration/index.mjs.map +1 -1
- package/dist/fontFace/index.d.mts +1 -1
- package/dist/property/index.d.mts +1 -1
- package/dist/property/index.mjs +1 -1
- package/dist/property/index.mjs.map +1 -1
- package/dist/query/index.d.mts +1 -1
- package/dist/query/index.mjs +137 -3
- package/dist/query/index.mjs.map +1 -1
- package/dist/rule/index.d.mts +1 -1
- package/dist/rule/index.mjs +45 -33
- package/dist/rule/index.mjs.map +1 -1
- package/dist/selector/index.d.mts +1 -1
- package/dist/selector/index.mjs +117 -21
- package/dist/selector/index.mjs.map +1 -1
- package/dist/shared/{calc-Cih4o2r7.mjs → calc-Uwbxd7CS.mjs} +233 -165
- package/dist/shared/calc-Uwbxd7CS.mjs.map +1 -0
- package/dist/shared/{color.internal-Dts5ycTm.mjs → color.internal-CxjlaRqR.mjs} +48 -13
- package/dist/shared/color.internal-CxjlaRqR.mjs.map +1 -0
- package/dist/shared/declaration-CqRm38oZ.d.mts +264 -0
- package/dist/shared/declaration.internal-bHzvbanA.mjs +121 -0
- package/dist/shared/declaration.internal-bHzvbanA.mjs.map +1 -0
- package/dist/shared/{fontFaceRule-C7nYgH6X.d.mts → fontFaceRule-BOgUM4PF.d.mts} +3 -3
- package/dist/shared/index-D-hVWDgZ.d.mts +2289 -0
- package/dist/shared/mediaQuery-VDIAHnM1.d.mts +333 -0
- package/dist/shared/{mediaQuery.internal-B6iuMd75.mjs → mediaQuery.internal-CKTmLVxL.mjs} +70 -6
- package/dist/shared/mediaQuery.internal-CKTmLVxL.mjs.map +1 -0
- package/dist/shared/{mediaRule-BDB4WCYy.d.mts → mediaRule-2K7Ggwe4.d.mts} +169 -105
- package/dist/shared/{propertyRule-BbkFh9b9.d.mts → propertyRule-B9ii0mv4.d.mts} +56 -21
- package/dist/shared/{propertyRule.internal-Bc_HrfcL.mjs → propertyRule.internal-ncYCWUar.mjs} +31 -4
- package/dist/shared/propertyRule.internal-ncYCWUar.mjs.map +1 -0
- package/dist/shared/{ruleSet.internal-DodzVMUU.mjs → ruleSet.internal-Cj4yIYFI.mjs} +31 -18
- package/dist/shared/ruleSet.internal-Cj4yIYFI.mjs.map +1 -0
- package/dist/shared/selector-BkxnzX_6.d.mts +615 -0
- package/dist/shared/{selector.internal-ESe9s0IH.mjs → selector.internal-B3iu_RpX.mjs} +144 -30
- package/dist/shared/selector.internal-B3iu_RpX.mjs.map +1 -0
- package/dist/shared/{utils-BKm298I-.d.mts → utils-DpN6qr94.d.mts} +4 -4
- package/dist/shared/var.internal-DSxAzEFN.mjs +119 -0
- package/dist/shared/var.internal-DSxAzEFN.mjs.map +1 -0
- package/dist/stylesheet/index.d.mts +93 -60
- package/dist/stylesheet/index.mjs +111 -35
- package/dist/stylesheet/index.mjs.map +1 -1
- package/dist/utils.d.mts +1 -1
- package/dist/utils.mjs.map +1 -1
- package/dist/var/index.d.mts +2 -0
- package/dist/var/index.mjs +177 -0
- package/dist/var/index.mjs.map +1 -0
- package/package.json +8 -2
- package/dist/shared/calc-Cih4o2r7.mjs.map +0 -1
- package/dist/shared/color-BvNJ2YqL.d.mts +0 -590
- package/dist/shared/color.internal-Dts5ycTm.mjs.map +0 -1
- package/dist/shared/declaration-1DlO_ltT.d.mts +0 -166
- package/dist/shared/declaration.internal-wLB4ssxC.mjs +0 -73
- package/dist/shared/declaration.internal-wLB4ssxC.mjs.map +0 -1
- package/dist/shared/index-BvtwY4FQ.d.mts +0 -841
- package/dist/shared/mediaQuery-BYR1z-iD.d.mts +0 -145
- package/dist/shared/mediaQuery.internal-B6iuMd75.mjs.map +0 -1
- package/dist/shared/propertyRule.internal-Bc_HrfcL.mjs.map +0 -1
- package/dist/shared/ruleSet.internal-DodzVMUU.mjs.map +0 -1
- package/dist/shared/selector-HZY-W6l6.d.mts +0 -346
- package/dist/shared/selector.internal-ESe9s0IH.mjs.map +0 -1
package/dist/query/index.mjs
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import { t as __exportAll } from "../shared/rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
-
import { a as
|
|
2
|
+
import { a as getMinWidth$1, c as hasMinWidth$1, d as isMediaQuery$1, f as maxWidth$1, h as render$1, i as getMaxWidth$1, l as hasPrefersColorScheme$1, m as prefersColorScheme$1, o as getPrefersColorScheme$1, p as minWidth$1, r as equals$1, s as hasMaxWidth$1, t as and$1 } from "../shared/mediaQuery.internal-CKTmLVxL.mjs";
|
|
3
3
|
//#region src/query/mediaQuery.ts
|
|
4
4
|
var mediaQuery_exports = /* @__PURE__ */ __exportAll({
|
|
5
5
|
and: () => and,
|
|
6
6
|
equals: () => equals,
|
|
7
|
+
getMaxWidth: () => getMaxWidth,
|
|
8
|
+
getMinWidth: () => getMinWidth,
|
|
9
|
+
getPrefersColorScheme: () => getPrefersColorScheme,
|
|
10
|
+
hasMaxWidth: () => hasMaxWidth,
|
|
11
|
+
hasMinWidth: () => hasMinWidth,
|
|
12
|
+
hasPrefersColorScheme: () => hasPrefersColorScheme,
|
|
7
13
|
isMediaQuery: () => isMediaQuery,
|
|
14
|
+
maxWidth: () => maxWidth,
|
|
8
15
|
minWidth: () => minWidth,
|
|
9
16
|
prefersColorScheme: () => prefersColorScheme,
|
|
10
17
|
render: () => render
|
|
@@ -23,8 +30,11 @@ const isMediaQuery = isMediaQuery$1;
|
|
|
23
30
|
/**
|
|
24
31
|
* Creates a viewport-width lower bound.
|
|
25
32
|
*
|
|
33
|
+
* The result carries the `MinWidth` brand, so `getMinWidth` returns a
|
|
34
|
+
* bare `number` on it and on any conjunction built from it.
|
|
35
|
+
*
|
|
26
36
|
* @param px - The threshold in CSS pixels. Must be a non-negative finite number.
|
|
27
|
-
* @returns A one-feature `MediaQuery`.
|
|
37
|
+
* @returns A one-feature `MediaQuery`, branded `MinWidth`.
|
|
28
38
|
* @throws `Error` when `px` is negative or not finite.
|
|
29
39
|
* @example
|
|
30
40
|
* ```ts
|
|
@@ -35,15 +45,139 @@ const isMediaQuery = isMediaQuery$1;
|
|
|
35
45
|
*/
|
|
36
46
|
const minWidth = minWidth$1;
|
|
37
47
|
/**
|
|
48
|
+
* Creates a viewport-width upper bound.
|
|
49
|
+
*
|
|
50
|
+
* The result carries the `MaxWidth` brand, so `getMaxWidth` returns a
|
|
51
|
+
* bare `number` on it and on any conjunction built from it.
|
|
52
|
+
*
|
|
53
|
+
* @param px - The threshold in CSS pixels. Must be a non-negative finite number.
|
|
54
|
+
* @returns A one-feature `MediaQuery`, branded `MaxWidth`.
|
|
55
|
+
* @throws `Error` when `px` is negative or not finite.
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* MediaQuery.render(MediaQuery.maxWidth(1024)) // '(max-width: 1024px)'
|
|
59
|
+
* MediaQuery.render(MediaQuery.maxWidth(1024), { mediaSyntax: 'range' }) // '(width <= 1024px)'
|
|
60
|
+
* ```
|
|
61
|
+
* @since 0.3.0
|
|
62
|
+
*/
|
|
63
|
+
const maxWidth = maxWidth$1;
|
|
64
|
+
/**
|
|
38
65
|
* Creates a `prefers-color-scheme` condition.
|
|
39
66
|
*
|
|
67
|
+
* The result carries the `PrefersColorScheme` brand, so
|
|
68
|
+
* `getPrefersColorScheme` returns a guaranteed scheme on it and on any
|
|
69
|
+
* conjunction built from it.
|
|
70
|
+
*
|
|
40
71
|
* @param scheme - The scheme to match, `'dark'` or `'light'`.
|
|
41
|
-
* @returns A one-feature `MediaQuery`.
|
|
72
|
+
* @returns A one-feature `MediaQuery`, branded `PrefersColorScheme`.
|
|
42
73
|
* @since 0.1.0
|
|
43
74
|
*/
|
|
44
75
|
const prefersColorScheme = prefersColorScheme$1;
|
|
45
76
|
const and = and$1;
|
|
46
77
|
/**
|
|
78
|
+
* Gets the query's `min-width` threshold.
|
|
79
|
+
*
|
|
80
|
+
* The return type keys on the `MinWidth` brand. Where the type proves a
|
|
81
|
+
* `min-width` feature is present — `minWidth`'s result, any conjunction
|
|
82
|
+
* keeping its brand, or a query narrowed by `hasMinWidth` — the result is
|
|
83
|
+
* a bare `number`. On any other query it is `number | undefined`.
|
|
84
|
+
*
|
|
85
|
+
* When several `min-width` features stack, the largest threshold is
|
|
86
|
+
* returned — the conjunction's effective lower bound, since every
|
|
87
|
+
* feature must hold.
|
|
88
|
+
*
|
|
89
|
+
* @param query - The query to read.
|
|
90
|
+
* @returns The largest `min-width` threshold in CSS pixels, or `undefined` when an unbranded query carries no `min-width` feature.
|
|
91
|
+
* @example
|
|
92
|
+
* ```ts
|
|
93
|
+
* MediaQuery.getMinWidth(MediaQuery.minWidth(768)) // 768
|
|
94
|
+
* MediaQuery.getMinWidth(MediaQuery.prefersColorScheme('dark')) // undefined
|
|
95
|
+
* MediaQuery.minWidth(768).pipe(
|
|
96
|
+
* MediaQuery.and(MediaQuery.minWidth(1024)),
|
|
97
|
+
* MediaQuery.getMinWidth,
|
|
98
|
+
* ) // 1024
|
|
99
|
+
* ```
|
|
100
|
+
* @since 0.3.0
|
|
101
|
+
*/
|
|
102
|
+
const getMinWidth = getMinWidth$1;
|
|
103
|
+
/**
|
|
104
|
+
* Gets the query's `max-width` threshold.
|
|
105
|
+
*
|
|
106
|
+
* The return type keys on the `MaxWidth` brand. Where the type proves a
|
|
107
|
+
* `max-width` feature is present — `maxWidth`'s result, any conjunction
|
|
108
|
+
* keeping its brand, or a query narrowed by `hasMaxWidth` — the result is
|
|
109
|
+
* a bare `number`. On any other query it is `number | undefined`.
|
|
110
|
+
*
|
|
111
|
+
* When several `max-width` features stack, the smallest threshold is
|
|
112
|
+
* returned — the conjunction's effective upper bound, since every
|
|
113
|
+
* feature must hold.
|
|
114
|
+
*
|
|
115
|
+
* @param query - The query to read.
|
|
116
|
+
* @returns The smallest `max-width` threshold in CSS pixels, or `undefined` when an unbranded query carries no `max-width` feature.
|
|
117
|
+
* @example
|
|
118
|
+
* ```ts
|
|
119
|
+
* MediaQuery.getMaxWidth(MediaQuery.maxWidth(1024)) // 1024
|
|
120
|
+
* MediaQuery.getMaxWidth(MediaQuery.minWidth(768)) // undefined
|
|
121
|
+
* ```
|
|
122
|
+
* @since 0.3.0
|
|
123
|
+
*/
|
|
124
|
+
const getMaxWidth = getMaxWidth$1;
|
|
125
|
+
/**
|
|
126
|
+
* Gets the query's `prefers-color-scheme` value.
|
|
127
|
+
*
|
|
128
|
+
* The return type keys on the `PrefersColorScheme` brand. Where the type
|
|
129
|
+
* proves the feature is present, the result is a bare `'dark' | 'light'`.
|
|
130
|
+
* On any other query it may also be `undefined`.
|
|
131
|
+
*
|
|
132
|
+
* A query holding both schemes matches nothing; the accessor then
|
|
133
|
+
* returns `'dark'`, the alphabetically first in canonical order.
|
|
134
|
+
*
|
|
135
|
+
* @param query - The query to read.
|
|
136
|
+
* @returns The required scheme, or `undefined` when an unbranded query carries no `prefers-color-scheme` feature.
|
|
137
|
+
* @example
|
|
138
|
+
* ```ts
|
|
139
|
+
* MediaQuery.getPrefersColorScheme(MediaQuery.prefersColorScheme('dark')) // 'dark'
|
|
140
|
+
* MediaQuery.getPrefersColorScheme(MediaQuery.minWidth(768)) // undefined
|
|
141
|
+
* ```
|
|
142
|
+
* @since 0.3.0
|
|
143
|
+
*/
|
|
144
|
+
const getPrefersColorScheme = getPrefersColorScheme$1;
|
|
145
|
+
/**
|
|
146
|
+
* Checks if the query carries a `min-width` feature, narrowing its type
|
|
147
|
+
* to `MediaQuery<MinWidth>` so `getMinWidth` returns a bare `number`.
|
|
148
|
+
*
|
|
149
|
+
* @param query - The query to check.
|
|
150
|
+
* @returns `true` if a `min-width` feature is present, `false` otherwise.
|
|
151
|
+
* @example
|
|
152
|
+
* ```ts
|
|
153
|
+
* declare const query: MediaQuery.MediaQuery
|
|
154
|
+
* if (MediaQuery.hasMinWidth(query)) {
|
|
155
|
+
* MediaQuery.getMinWidth(query) // number, not number | undefined
|
|
156
|
+
* }
|
|
157
|
+
* ```
|
|
158
|
+
* @since 0.3.0
|
|
159
|
+
*/
|
|
160
|
+
const hasMinWidth = hasMinWidth$1;
|
|
161
|
+
/**
|
|
162
|
+
* Checks if the query carries a `max-width` feature, narrowing its type
|
|
163
|
+
* to `MediaQuery<MaxWidth>` so `getMaxWidth` returns a bare `number`.
|
|
164
|
+
*
|
|
165
|
+
* @param query - The query to check.
|
|
166
|
+
* @returns `true` if a `max-width` feature is present, `false` otherwise.
|
|
167
|
+
* @since 0.3.0
|
|
168
|
+
*/
|
|
169
|
+
const hasMaxWidth = hasMaxWidth$1;
|
|
170
|
+
/**
|
|
171
|
+
* Checks if the query carries a `prefers-color-scheme` feature, narrowing
|
|
172
|
+
* its type to `MediaQuery<PrefersColorScheme>` so `getPrefersColorScheme`
|
|
173
|
+
* returns a guaranteed scheme.
|
|
174
|
+
*
|
|
175
|
+
* @param query - The query to check.
|
|
176
|
+
* @returns `true` if a `prefers-color-scheme` feature is present, `false` otherwise.
|
|
177
|
+
* @since 0.3.0
|
|
178
|
+
*/
|
|
179
|
+
const hasPrefersColorScheme = hasPrefersColorScheme$1;
|
|
180
|
+
/**
|
|
47
181
|
* Renders the query as CSS text: features in canonical order —
|
|
48
182
|
* `min-width` ascending, then `prefers-color-scheme` — joined with
|
|
49
183
|
* ` and `. The `mediaSyntax` option picks the width-feature spelling
|
package/dist/query/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["internal.isMediaQuery","internal.minWidth","internal.prefersColorScheme","internal.and","internal.render","internal.equals"],"sources":["../../src/query/mediaQuery.ts"],"sourcesContent":["import type { Pipeable } from '#util'\nimport type { MediaQueryTypeId } from './mediaQuery.internal.ts'\nimport * as internal from './mediaQuery.internal.ts'\n\n/**\n * A media query: a canonically ordered, deduplicated and-set of media\n * features.\n *\n * Feature constructors (`minWidth`, `prefersColorScheme`) return\n * one-feature queries; `and` merges. Conjunction is commutative and\n * idempotent, so construction sorts features canonically and drops exact\n * duplicates — structurally equal queries compare equal however they\n * were built. The canonical order is stable public API: `min-width`\n * features first (ascending by threshold), then `prefers-color-scheme`\n * (schemes alphabetically). Distinct features always all render, even\n * when one subsumes another (`minWidth(768)` and `minWidth(1024)`):\n * simplification changes no meaning but is not this type's job.\n *\n * `or` and `not` become new node kinds when a consumer needs them.\n *\n * @since 0.1.0\n */\nexport interface MediaQuery extends Pipeable {\n readonly [MediaQueryTypeId]: MediaQueryTypeId\n}\n\n/**\n * Options for `render` — and the base of the library's render-options\n * family: every other module's `RenderOptions` extends this interface\n * (directly or through `Declaration.RenderOptions` and\n * `RuleSet.RenderOptions`), so an options object built for a bigger\n * renderer is accepted by every smaller one. A key means the same thing\n * wherever it appears; renderers ignore inherited keys that don't apply\n * to them.\n *\n * @since 0.1.0\n */\nexport interface RenderOptions {\n /**\n * The width-feature spelling: classic prefix syntax\n * (`(min-width: 768px)`, the default) or modern range syntax\n * (`(width >= 768px)`). Text only — the model is semantic and the two\n * spellings mean the same thing.\n */\n readonly mediaSyntax?: 'prefix' | 'range'\n}\n\n/**\n * Checks if a value is a `MediaQuery`.\n *\n * True only for values built by this module's constructors, which carry\n * the brand.\n *\n * @param u - The value to check.\n * @returns `true` if the value is a `MediaQuery`, `false` otherwise.\n * @since 0.1.0\n */\nexport const isMediaQuery: (u: unknown) => u is MediaQuery = internal.isMediaQuery\n\n/**\n * Creates a viewport-width lower bound.\n *\n * @param px - The threshold in CSS pixels. Must be a non-negative finite number.\n * @returns A one-feature `MediaQuery`.\n * @throws `Error` when `px` is negative or not finite.\n * @example\n * ```ts\n * MediaQuery.render(MediaQuery.minWidth(768)) // '(min-width: 768px)'\n * MediaQuery.render(MediaQuery.minWidth(768), { mediaSyntax: 'range' }) // '(width >= 768px)'\n * ```\n * @since 0.1.0\n */\nexport const minWidth: (px: number) => MediaQuery = internal.minWidth\n\n/**\n * Creates a `prefers-color-scheme` condition.\n *\n * @param scheme - The scheme to match, `'dark'` or `'light'`.\n * @returns A one-feature `MediaQuery`.\n * @since 0.1.0\n */\nexport const prefersColorScheme: (scheme: 'dark' | 'light') => MediaQuery =\n internal.prefersColorScheme\n\nexport const and: {\n /**\n * Returns a function that conjoins `that` with its argument.\n *\n * @param that - The query to merge in.\n * @returns A function producing the conjunction.\n * @since 0.1.0\n */\n (that: MediaQuery): (self: MediaQuery) => MediaQuery\n /**\n * Conjoins two queries: the result matches where both match. Features\n * re-sort into canonical order and exact duplicates collapse, so `and`\n * is commutative and idempotent.\n *\n * @param self - The first query.\n * @param that - The second query.\n * @returns The conjunction.\n * @example\n * ```ts\n * MediaQuery.minWidth(1280).pipe(\n * MediaQuery.and(MediaQuery.prefersColorScheme('dark')),\n * MediaQuery.render,\n * ) // '(min-width: 1280px) and (prefers-color-scheme: dark)'\n * ```\n * @since 0.1.0\n */\n (self: MediaQuery, that: MediaQuery): MediaQuery\n} = internal.and\n\n/**\n * Renders the query as CSS text: features in canonical order —\n * `min-width` ascending, then `prefers-color-scheme` — joined with\n * ` and `. The `mediaSyntax` option picks the width-feature spelling\n * (default `'prefix'`).\n *\n * @param query - The query to render.\n * @param options - Optional syntax selection.\n * @returns Deterministic CSS text, without the `@media ` prefix.\n * @since 0.1.0\n */\nexport const render: (query: MediaQuery, options?: RenderOptions) => string = internal.render\n\nexport const equals: {\n /**\n * Returns a function that checks structural equality against `that`.\n *\n * @param that - The query to compare against.\n * @returns A function testing its argument for structural equality with `that`.\n * @since 0.1.0\n */\n (that: MediaQuery): (self: MediaQuery) => boolean\n /**\n * Structural equality over canonically ordered features: two queries\n * built from the same conditions compare equal regardless of\n * construction order.\n *\n * @param self - The first query.\n * @param that - The second query.\n * @returns `true` if the queries are structurally equal.\n * @since 0.1.0\n */\n (self: MediaQuery, that: MediaQuery): boolean\n} = internal.equals\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAyDA,MAAa,eAAgDA;;;;;;;;;;;;;;AAe7D,MAAa,WAAuCC;;;;;;;;AASpD,MAAa,qBACXC;AAEF,MAAa,MA2BTC;;;;;;;;;;;;AAaJ,MAAa,SAAiEC;AAE9E,MAAa,SAoBTC"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["internal.isMediaQuery","internal.minWidth","internal.maxWidth","internal.prefersColorScheme","internal.and","internal.getMinWidth","internal.getMaxWidth","internal.getPrefersColorScheme","internal.hasMinWidth","internal.hasMaxWidth","internal.hasPrefersColorScheme","internal.render","internal.equals"],"sources":["../../src/query/mediaQuery.ts"],"sourcesContent":["import type { Pipeable } from '#util'\nimport type { MediaQueryFeatures, MediaQueryTypeId } from './mediaQuery.internal.ts'\nimport * as internal from './mediaQuery.internal.ts'\n\ndeclare const MinWidthId: unique symbol\ndeclare const MaxWidthId: unique symbol\ndeclare const PrefersColorSchemeId: unique symbol\n\n/**\n * A media query: a canonically ordered, deduplicated and-set of media\n * features.\n *\n * Feature constructors (`minWidth`, `maxWidth`, `prefersColorScheme`)\n * return one-feature queries; `and` merges. Conjunction is commutative\n * and idempotent, so construction sorts features canonically and drops\n * exact duplicates — structurally equal queries compare equal however\n * they were built. The canonical order is stable public API: `min-width`\n * features first (ascending by threshold), then `max-width` (ascending),\n * then `prefers-color-scheme` (schemes alphabetically). Distinct features\n * always all render, even when one subsumes another (`minWidth(768)` and\n * `minWidth(1024)`): simplification changes no meaning but is not this\n * type's job.\n *\n * `Features` records, as intersected type-level brands, which feature\n * kinds are known to be present. It defaults to `unknown` — no claims.\n * Constructors brand their result (`minWidth` returns\n * `MediaQuery<MinWidth>`), `and` keeps both sides' brands, the `has*`\n * guards recover a brand from a plain query at runtime, and the `get*`\n * accessors key their return type on it to drop `undefined`. Brands are\n * type-level only: a query is identical at runtime whatever its type\n * knows.\n *\n * `or` and `not` become new node kinds when a consumer needs them.\n *\n * @since 0.1.0\n */\nexport interface MediaQuery<out Features = unknown> extends Pipeable {\n readonly [MediaQueryTypeId]: MediaQueryTypeId\n readonly [MediaQueryFeatures]?: Features\n}\n\n/**\n * The brand of a query known to carry a `min-width` feature. `minWidth`\n * stamps it, `and` keeps it through conjunction, `hasMinWidth` recovers\n * it at runtime, and `getMinWidth` returns a guaranteed `number` where it\n * is present. Composes by intersection with the other feature brands.\n *\n * @since 0.3.0\n */\nexport type MinWidth = { readonly [MinWidthId]: 'minWidth' }\n\n/**\n * The brand of a query known to carry a `max-width` feature. `maxWidth`\n * stamps it, `and` keeps it through conjunction, `hasMaxWidth` recovers\n * it at runtime, and `getMaxWidth` returns a guaranteed `number` where it\n * is present. Composes by intersection with the other feature brands.\n *\n * @since 0.3.0\n */\nexport type MaxWidth = { readonly [MaxWidthId]: 'maxWidth' }\n\n/**\n * The brand of a query known to carry a `prefers-color-scheme` feature.\n * `prefersColorScheme` stamps it, `and` keeps it through conjunction,\n * `hasPrefersColorScheme` recovers it at runtime, and\n * `getPrefersColorScheme` returns a guaranteed scheme where it is\n * present. Composes by intersection with the other feature brands.\n *\n * @since 0.3.0\n */\nexport type PrefersColorScheme = { readonly [PrefersColorSchemeId]: 'prefersColorScheme' }\n\n/**\n * Options for `render` — and the base of the library's render-options\n * family: every other module's `RenderOptions` extends this interface\n * (directly or through `Declaration.RenderOptions` and\n * `RuleSet.RenderOptions`), so an options object built for a bigger\n * renderer is accepted by every smaller one. A key means the same thing\n * wherever it appears; renderers ignore inherited keys that don't apply\n * to them.\n *\n * @since 0.1.0\n */\nexport interface RenderOptions {\n /**\n * The width-feature spelling: classic prefix syntax\n * (`(min-width: 768px)`, the default) or modern range syntax\n * (`(width >= 768px)`). Text only — the model is semantic and the two\n * spellings mean the same thing.\n */\n readonly mediaSyntax?: 'prefix' | 'range'\n}\n\n/**\n * Checks if a value is a `MediaQuery`.\n *\n * True only for values built by this module's constructors, which carry\n * the brand.\n *\n * @param u - The value to check.\n * @returns `true` if the value is a `MediaQuery`, `false` otherwise.\n * @since 0.1.0\n */\nexport const isMediaQuery: (u: unknown) => u is MediaQuery = internal.isMediaQuery\n\n/**\n * Creates a viewport-width lower bound.\n *\n * The result carries the `MinWidth` brand, so `getMinWidth` returns a\n * bare `number` on it and on any conjunction built from it.\n *\n * @param px - The threshold in CSS pixels. Must be a non-negative finite number.\n * @returns A one-feature `MediaQuery`, branded `MinWidth`.\n * @throws `Error` when `px` is negative or not finite.\n * @example\n * ```ts\n * MediaQuery.render(MediaQuery.minWidth(768)) // '(min-width: 768px)'\n * MediaQuery.render(MediaQuery.minWidth(768), { mediaSyntax: 'range' }) // '(width >= 768px)'\n * ```\n * @since 0.1.0\n */\nexport const minWidth: (px: number) => MediaQuery<MinWidth> = internal.minWidth\n\n/**\n * Creates a viewport-width upper bound.\n *\n * The result carries the `MaxWidth` brand, so `getMaxWidth` returns a\n * bare `number` on it and on any conjunction built from it.\n *\n * @param px - The threshold in CSS pixels. Must be a non-negative finite number.\n * @returns A one-feature `MediaQuery`, branded `MaxWidth`.\n * @throws `Error` when `px` is negative or not finite.\n * @example\n * ```ts\n * MediaQuery.render(MediaQuery.maxWidth(1024)) // '(max-width: 1024px)'\n * MediaQuery.render(MediaQuery.maxWidth(1024), { mediaSyntax: 'range' }) // '(width <= 1024px)'\n * ```\n * @since 0.3.0\n */\nexport const maxWidth: (px: number) => MediaQuery<MaxWidth> = internal.maxWidth\n\n/**\n * Creates a `prefers-color-scheme` condition.\n *\n * The result carries the `PrefersColorScheme` brand, so\n * `getPrefersColorScheme` returns a guaranteed scheme on it and on any\n * conjunction built from it.\n *\n * @param scheme - The scheme to match, `'dark'` or `'light'`.\n * @returns A one-feature `MediaQuery`, branded `PrefersColorScheme`.\n * @since 0.1.0\n */\nexport const prefersColorScheme: (scheme: 'dark' | 'light') => MediaQuery<PrefersColorScheme> =\n internal.prefersColorScheme\n\nexport const and: {\n /**\n * Returns a function that conjoins `that` with its argument.\n *\n * @param that - The query to merge in.\n * @returns A function producing the conjunction.\n * @since 0.1.0\n */\n <B>(that: MediaQuery<B>): <A>(self: MediaQuery<A>) => MediaQuery<A & B>\n /**\n * Conjoins two queries: the result matches where both match. Features\n * re-sort into canonical order and exact duplicates collapse, so `and`\n * is commutative and idempotent.\n *\n * Known features intersect: the result keeps every brand either side\n * carries, so a `MinWidth` query stays `MinWidth` through conjunction.\n *\n * @param self - The first query.\n * @param that - The second query.\n * @returns The conjunction, branded with both sides' known features.\n * @example\n * ```ts\n * MediaQuery.minWidth(1280).pipe(\n * MediaQuery.and(MediaQuery.prefersColorScheme('dark')),\n * MediaQuery.render,\n * ) // '(min-width: 1280px) and (prefers-color-scheme: dark)'\n * ```\n * @since 0.1.0\n */\n <A, B>(self: MediaQuery<A>, that: MediaQuery<B>): MediaQuery<A & B>\n} = internal.and\n\n/**\n * Gets the query's `min-width` threshold.\n *\n * The return type keys on the `MinWidth` brand. Where the type proves a\n * `min-width` feature is present — `minWidth`'s result, any conjunction\n * keeping its brand, or a query narrowed by `hasMinWidth` — the result is\n * a bare `number`. On any other query it is `number | undefined`.\n *\n * When several `min-width` features stack, the largest threshold is\n * returned — the conjunction's effective lower bound, since every\n * feature must hold.\n *\n * @param query - The query to read.\n * @returns The largest `min-width` threshold in CSS pixels, or `undefined` when an unbranded query carries no `min-width` feature.\n * @example\n * ```ts\n * MediaQuery.getMinWidth(MediaQuery.minWidth(768)) // 768\n * MediaQuery.getMinWidth(MediaQuery.prefersColorScheme('dark')) // undefined\n * MediaQuery.minWidth(768).pipe(\n * MediaQuery.and(MediaQuery.minWidth(1024)),\n * MediaQuery.getMinWidth,\n * ) // 1024\n * ```\n * @since 0.3.0\n */\nexport const getMinWidth: <T>(\n query: MediaQuery<T>,\n) => T extends MinWidth ? number : number | undefined = internal.getMinWidth\n\n/**\n * Gets the query's `max-width` threshold.\n *\n * The return type keys on the `MaxWidth` brand. Where the type proves a\n * `max-width` feature is present — `maxWidth`'s result, any conjunction\n * keeping its brand, or a query narrowed by `hasMaxWidth` — the result is\n * a bare `number`. On any other query it is `number | undefined`.\n *\n * When several `max-width` features stack, the smallest threshold is\n * returned — the conjunction's effective upper bound, since every\n * feature must hold.\n *\n * @param query - The query to read.\n * @returns The smallest `max-width` threshold in CSS pixels, or `undefined` when an unbranded query carries no `max-width` feature.\n * @example\n * ```ts\n * MediaQuery.getMaxWidth(MediaQuery.maxWidth(1024)) // 1024\n * MediaQuery.getMaxWidth(MediaQuery.minWidth(768)) // undefined\n * ```\n * @since 0.3.0\n */\nexport const getMaxWidth: <T>(\n query: MediaQuery<T>,\n) => T extends MaxWidth ? number : number | undefined = internal.getMaxWidth\n\n/**\n * Gets the query's `prefers-color-scheme` value.\n *\n * The return type keys on the `PrefersColorScheme` brand. Where the type\n * proves the feature is present, the result is a bare `'dark' | 'light'`.\n * On any other query it may also be `undefined`.\n *\n * A query holding both schemes matches nothing; the accessor then\n * returns `'dark'`, the alphabetically first in canonical order.\n *\n * @param query - The query to read.\n * @returns The required scheme, or `undefined` when an unbranded query carries no `prefers-color-scheme` feature.\n * @example\n * ```ts\n * MediaQuery.getPrefersColorScheme(MediaQuery.prefersColorScheme('dark')) // 'dark'\n * MediaQuery.getPrefersColorScheme(MediaQuery.minWidth(768)) // undefined\n * ```\n * @since 0.3.0\n */\nexport const getPrefersColorScheme: <T>(\n query: MediaQuery<T>,\n) => T extends PrefersColorScheme ? 'dark' | 'light' : 'dark' | 'light' | undefined =\n internal.getPrefersColorScheme\n\n/**\n * Checks if the query carries a `min-width` feature, narrowing its type\n * to `MediaQuery<MinWidth>` so `getMinWidth` returns a bare `number`.\n *\n * @param query - The query to check.\n * @returns `true` if a `min-width` feature is present, `false` otherwise.\n * @example\n * ```ts\n * declare const query: MediaQuery.MediaQuery\n * if (MediaQuery.hasMinWidth(query)) {\n * MediaQuery.getMinWidth(query) // number, not number | undefined\n * }\n * ```\n * @since 0.3.0\n */\nexport const hasMinWidth: (query: MediaQuery) => query is MediaQuery<MinWidth> =\n internal.hasMinWidth\n\n/**\n * Checks if the query carries a `max-width` feature, narrowing its type\n * to `MediaQuery<MaxWidth>` so `getMaxWidth` returns a bare `number`.\n *\n * @param query - The query to check.\n * @returns `true` if a `max-width` feature is present, `false` otherwise.\n * @since 0.3.0\n */\nexport const hasMaxWidth: (query: MediaQuery) => query is MediaQuery<MaxWidth> =\n internal.hasMaxWidth\n\n/**\n * Checks if the query carries a `prefers-color-scheme` feature, narrowing\n * its type to `MediaQuery<PrefersColorScheme>` so `getPrefersColorScheme`\n * returns a guaranteed scheme.\n *\n * @param query - The query to check.\n * @returns `true` if a `prefers-color-scheme` feature is present, `false` otherwise.\n * @since 0.3.0\n */\nexport const hasPrefersColorScheme: (query: MediaQuery) => query is MediaQuery<PrefersColorScheme> =\n internal.hasPrefersColorScheme\n\n/**\n * Renders the query as CSS text: features in canonical order —\n * `min-width` ascending, then `prefers-color-scheme` — joined with\n * ` and `. The `mediaSyntax` option picks the width-feature spelling\n * (default `'prefix'`).\n *\n * @param query - The query to render.\n * @param options - Optional syntax selection.\n * @returns Deterministic CSS text, without the `@media ` prefix.\n * @since 0.1.0\n */\nexport const render: (query: MediaQuery, options?: RenderOptions) => string = internal.render\n\nexport const equals: {\n /**\n * Returns a function that checks structural equality against `that`.\n *\n * @param that - The query to compare against.\n * @returns A function testing its argument for structural equality with `that`.\n * @since 0.1.0\n */\n (that: MediaQuery): (self: MediaQuery) => boolean\n /**\n * Structural equality over canonically ordered features: two queries\n * built from the same conditions compare equal regardless of\n * construction order.\n *\n * @param self - The first query.\n * @param that - The second query.\n * @returns `true` if the queries are structurally equal.\n * @since 0.1.0\n */\n (self: MediaQuery, that: MediaQuery): boolean\n} = internal.equals\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuGA,MAAa,eAAgDA;;;;;;;;;;;;;;;;;AAkB7D,MAAa,WAAiDC;;;;;;;;;;;;;;;;;AAkB9D,MAAa,WAAiDC;;;;;;;;;;;;AAa9D,MAAa,qBACXC;AAEF,MAAa,MA8BTC;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BJ,MAAa,cAE2CC;;;;;;;;;;;;;;;;;;;;;;AAuBxD,MAAa,cAE2CC;;;;;;;;;;;;;;;;;;;;AAqBxD,MAAa,wBAGXC;;;;;;;;;;;;;;;;AAiBF,MAAa,cACXC;;;;;;;;;AAUF,MAAa,cACXC;;;;;;;;;;AAWF,MAAa,wBACXC;;;;;;;;;;;;AAaF,MAAa,SAAiEC;AAE9E,MAAa,SAoBTC"}
|
package/dist/rule/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as ruleSet_d_exports, n as mediaRule_d_exports, s as styleRule_d_exports } from "../shared/mediaRule-2K7Ggwe4.mjs";
|
|
2
2
|
export { mediaRule_d_exports as MediaRule, ruleSet_d_exports as RuleSet, styleRule_d_exports as StyleRule };
|
package/dist/rule/index.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { t as __exportAll } from "../shared/rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
-
import { _ as equals$3, a as forMediaQuery$1, b as refs
|
|
2
|
+
import { _ as equals$3, a as forMediaQuery$1, b as refs, c as isRuleSet$1, d as render$4, f as equals$5, g as render$5, h as refs$2, i as equals$4, l as make$4, m as make$5, n as concat$1, o as forSelector$1, p as isStyleRule$1, r as empty$1, s as isEmpty$1, t as append$1, u as refs$1, v as isMediaRule$1, x as render$3, y as make$3 } from "../shared/ruleSet.internal-Cj4yIYFI.mjs";
|
|
3
3
|
//#region src/rule/mediaRule.ts
|
|
4
4
|
var mediaRule_exports = /* @__PURE__ */ __exportAll({
|
|
5
5
|
equals: () => equals$2,
|
|
6
6
|
isMediaRule: () => isMediaRule,
|
|
7
7
|
make: () => make$2,
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
render: () => render$2,
|
|
9
|
+
vars: () => vars$2
|
|
10
10
|
});
|
|
11
11
|
/**
|
|
12
12
|
* Checks if a value is a `MediaRule`.
|
|
@@ -20,11 +20,11 @@ var mediaRule_exports = /* @__PURE__ */ __exportAll({
|
|
|
20
20
|
*/
|
|
21
21
|
const isMediaRule = isMediaRule$1;
|
|
22
22
|
/**
|
|
23
|
-
* Creates a
|
|
23
|
+
* Creates a `@media` rule.
|
|
24
24
|
*
|
|
25
25
|
* @param query - The media query gating the block.
|
|
26
|
-
* @param block - The rule's block.
|
|
27
|
-
* @returns A `MediaRule` carrying the block's
|
|
26
|
+
* @param block - The rule's block. Declarations make the rule nested-only; a block of closed style rules makes it top-level-capable.
|
|
27
|
+
* @returns A `MediaRule` carrying the block's variable names and requirements.
|
|
28
28
|
* @example
|
|
29
29
|
* ```ts
|
|
30
30
|
* MediaRule.make(
|
|
@@ -36,14 +36,14 @@ const isMediaRule = isMediaRule$1;
|
|
|
36
36
|
*/
|
|
37
37
|
const make$2 = make$3;
|
|
38
38
|
/**
|
|
39
|
-
* The rule's unbound
|
|
39
|
+
* The rule's unbound variable names — the block's, since a query
|
|
40
40
|
* contributes none.
|
|
41
41
|
*
|
|
42
42
|
* @param rule - The rule to inspect.
|
|
43
|
-
* @returns The set of unbound
|
|
43
|
+
* @returns The set of unbound variable names.
|
|
44
44
|
* @since 0.1.0
|
|
45
45
|
*/
|
|
46
|
-
const
|
|
46
|
+
const vars$2 = refs;
|
|
47
47
|
/**
|
|
48
48
|
* Renders the rule in nested form: `@media query { ... }`, the body as
|
|
49
49
|
* `RuleSet.render` emits it, one level deeper — declarations directly
|
|
@@ -51,13 +51,15 @@ const refs$2 = refs$3;
|
|
|
51
51
|
* style rule (CSSNestedDeclarations). A rule whose block is empty
|
|
52
52
|
* renders as the empty string.
|
|
53
53
|
*
|
|
54
|
+
* Nested style rules render as indented sub-blocks with `&` kept
|
|
55
|
+
* verbatim — native CSS nesting is the output shape.
|
|
56
|
+
*
|
|
54
57
|
* A fragment renderer: whole sheets render via `Stylesheet.render`,
|
|
55
58
|
* which emits each rule's media in this same nested shape.
|
|
56
59
|
*
|
|
57
60
|
* @param rule - The rule to render.
|
|
58
61
|
* @param options - Optional indentation unit, precision context, and media syntax.
|
|
59
62
|
* @returns Deterministic CSS text.
|
|
60
|
-
* @throws `Error` when the block nests a style rule — selector composition (`&`) is a later extension, not part of v1 rendering.
|
|
61
63
|
* @example
|
|
62
64
|
* ```ts
|
|
63
65
|
* MediaRule.render(
|
|
@@ -80,8 +82,8 @@ var ruleSet_exports = /* @__PURE__ */ __exportAll({
|
|
|
80
82
|
isEmpty: () => isEmpty,
|
|
81
83
|
isRuleSet: () => isRuleSet,
|
|
82
84
|
make: () => make$1,
|
|
83
|
-
|
|
84
|
-
|
|
85
|
+
render: () => render$1,
|
|
86
|
+
vars: () => vars$1
|
|
85
87
|
});
|
|
86
88
|
/**
|
|
87
89
|
* Checks if a value is a `RuleSet`.
|
|
@@ -116,11 +118,11 @@ const isEmpty = isEmpty$1;
|
|
|
116
118
|
* Creates a rule set holding the given members, in the given order.
|
|
117
119
|
*
|
|
118
120
|
* @param members - Declarations and nested rules, in authored order.
|
|
119
|
-
* @returns A `RuleSet` whose `
|
|
121
|
+
* @returns A `RuleSet` whose `Vars` unions the members' variable names and whose `Requires` unions their requirement contributions.
|
|
120
122
|
* @example
|
|
121
123
|
* ```ts
|
|
122
124
|
* const block = RuleSet.make(
|
|
123
|
-
* Declaration.make('--depth', Calc.
|
|
125
|
+
* Declaration.make('--depth', Calc.var('depth')),
|
|
124
126
|
* Declaration.make('color', 'oklch(0.7 0.1 250)'),
|
|
125
127
|
* ) // RuleSet<'depth'>
|
|
126
128
|
* ```
|
|
@@ -132,27 +134,29 @@ const concat = concat$1;
|
|
|
132
134
|
const forSelector = forSelector$1;
|
|
133
135
|
const forMediaQuery = forMediaQuery$1;
|
|
134
136
|
/**
|
|
135
|
-
* The block's unbound
|
|
137
|
+
* The block's unbound variable names, unioned across members —
|
|
136
138
|
* including everything nested rules contribute.
|
|
137
139
|
*
|
|
138
140
|
* @param set - The block to inspect.
|
|
139
|
-
* @returns The set of unbound
|
|
141
|
+
* @returns The set of unbound variable names.
|
|
140
142
|
* @since 0.1.0
|
|
141
143
|
*/
|
|
142
|
-
const
|
|
144
|
+
const vars$1 = refs$1;
|
|
143
145
|
/**
|
|
144
146
|
* Renders the block's body — the text between a rule's braces, without
|
|
145
|
-
* the braces: one line per declaration, nested `@media` rules
|
|
146
|
-
* indented sub-blocks, in member order. Empty
|
|
147
|
-
* whose blocks are empty) render as the empty
|
|
147
|
+
* the braces: one line per declaration, nested `@media` and style rules
|
|
148
|
+
* as indented sub-blocks (`&` kept verbatim), in member order. Empty
|
|
149
|
+
* blocks (and nested rules whose blocks are empty) render as the empty
|
|
150
|
+
* string.
|
|
148
151
|
*
|
|
149
152
|
* A fragment renderer: use it to compose blocks the model does not
|
|
150
|
-
* represent. Whole sheets render via `Stylesheet.render
|
|
153
|
+
* represent. Whole sheets render via `Stylesheet.render`, and the binder
|
|
154
|
+
* invariant on nested selectors is `StyleRule.make`'s — a free-standing
|
|
155
|
+
* block renders without it.
|
|
151
156
|
*
|
|
152
157
|
* @param set - The block to render.
|
|
153
158
|
* @param options - Optional indentation unit, precision context, and media syntax.
|
|
154
159
|
* @returns Deterministic CSS text.
|
|
155
|
-
* @throws `Error` when the block nests a style rule — selector composition (`&`) is a later extension, not part of v1 rendering.
|
|
156
160
|
* @example
|
|
157
161
|
* ```ts
|
|
158
162
|
* RuleSet.render(RuleSet.make(Declaration.make('--depth', 4), Declaration.make('color', 'red')))
|
|
@@ -168,8 +172,8 @@ var styleRule_exports = /* @__PURE__ */ __exportAll({
|
|
|
168
172
|
equals: () => equals,
|
|
169
173
|
isStyleRule: () => isStyleRule,
|
|
170
174
|
make: () => make,
|
|
171
|
-
|
|
172
|
-
|
|
175
|
+
render: () => render,
|
|
176
|
+
vars: () => vars
|
|
173
177
|
});
|
|
174
178
|
/**
|
|
175
179
|
* Checks if a value is a `StyleRule`.
|
|
@@ -185,32 +189,41 @@ const isStyleRule = isStyleRule$1;
|
|
|
185
189
|
/**
|
|
186
190
|
* Creates a style rule.
|
|
187
191
|
*
|
|
188
|
-
*
|
|
192
|
+
* The binder check runs here: every style rule nested in `block` —
|
|
193
|
+
* directly, or inside its `@media` blocks — must reference `&` in its
|
|
194
|
+
* selector, because this rule's selector is what that `&` reads. CSS
|
|
195
|
+
* would silently prepend a descendant `&` instead; the model rejects
|
|
196
|
+
* the shape rather than rewriting the authored selector.
|
|
197
|
+
*
|
|
198
|
+
* @param selector - The selector the block applies to. References `&` exactly when this rule itself nests.
|
|
189
199
|
* @param block - The rule's block.
|
|
190
|
-
* @returns A `StyleRule` carrying the block's
|
|
200
|
+
* @returns A `StyleRule` carrying the block's variable names and the selector's requirements.
|
|
201
|
+
* @throws `Error` when a style rule nested in `block` has a selector that does not reference `&`.
|
|
191
202
|
* @example
|
|
192
203
|
* ```ts
|
|
193
204
|
* StyleRule.make(
|
|
194
205
|
* Selector.root,
|
|
195
|
-
* RuleSet.make(Declaration.make('--depth', Calc.
|
|
206
|
+
* RuleSet.make(Declaration.make('--depth', Calc.var('depth'))),
|
|
196
207
|
* ) // StyleRule<'depth'>
|
|
197
208
|
* ```
|
|
198
209
|
* @since 0.1.0
|
|
199
210
|
*/
|
|
200
211
|
const make = make$5;
|
|
201
212
|
/**
|
|
202
|
-
* The rule's unbound
|
|
213
|
+
* The rule's unbound variable names — the block's, since a selector
|
|
203
214
|
* contributes none.
|
|
204
215
|
*
|
|
205
216
|
* @param rule - The rule to inspect.
|
|
206
|
-
* @returns The set of unbound
|
|
217
|
+
* @returns The set of unbound variable names.
|
|
207
218
|
* @since 0.1.0
|
|
208
219
|
*/
|
|
209
|
-
const
|
|
220
|
+
const vars = refs$2;
|
|
210
221
|
/**
|
|
211
222
|
* Renders the rule in nested form: `selector { ... }`, the body as
|
|
212
|
-
* `RuleSet.render` emits it, one level deeper.
|
|
213
|
-
*
|
|
223
|
+
* `RuleSet.render` emits it, one level deeper. Nested style rules render
|
|
224
|
+
* as indented sub-blocks with `&` kept verbatim — native CSS nesting is
|
|
225
|
+
* the output shape. A rule whose block is empty renders as the empty
|
|
226
|
+
* string.
|
|
214
227
|
*
|
|
215
228
|
* A fragment renderer: whole sheets render via `Stylesheet.render`,
|
|
216
229
|
* which emits each rule in this same nested shape.
|
|
@@ -218,7 +231,6 @@ const refs = refs$5;
|
|
|
218
231
|
* @param rule - The rule to render.
|
|
219
232
|
* @param options - Optional indentation unit, precision context, and media syntax.
|
|
220
233
|
* @returns Deterministic CSS text.
|
|
221
|
-
* @throws `Error` when the block nests a style rule — selector composition (`&`) is a later extension, not part of v1 rendering.
|
|
222
234
|
* @example
|
|
223
235
|
* ```ts
|
|
224
236
|
* StyleRule.render(StyleRule.make(Selector.root, RuleSet.make(Declaration.make('--depth', 4))))
|
package/dist/rule/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["internal.isMediaRule","make","internal.make","refs","internal.refs","render","internal.render","equals","internal.equals","internal.isRuleSet","internal.empty","internal.isEmpty","make","internal.make","internal.append","internal.concat","internal.forSelector","internal.forMediaQuery","refs","internal.refs","render","internal.render","equals","internal.equals","internal.isStyleRule","internal.make","internal.refs","internal.render","internal.equals"],"sources":["../../src/rule/mediaRule.ts","../../src/rule/ruleSet.ts","../../src/rule/styleRule.ts"],"sourcesContent":["import type { MediaQuery } from '#query/mediaQuery'\nimport type { Pipeable } from '#util'\nimport type { MediaRuleTypeId } from './mediaRule.internal.ts'\nimport * as internal from './mediaRule.internal.ts'\nimport type { RenderOptions as RuleSetRenderOptions, RuleSet } from './ruleSet.ts'\n\n/**\n * A nested `@media` rule: a media query and the block it gates.\n *\n * This is the nested form — a member of an enclosing style rule's block,\n * per the CSSNestedDeclarations grammar — not a top-level `@media`\n * statement. Media enters the model inside a style rule\n * (`:root { @media ... { ... } }`) and renders there, nested. The `Refs`\n * parameter is the block's.\n *\n * Construct via `make`.\n *\n * @since 0.1.0\n */\nexport interface MediaRule<out Refs extends string = string> extends Pipeable {\n readonly [MediaRuleTypeId]: MediaRuleTypeId\n /**\n * The media query gating the block.\n */\n readonly query: MediaQuery\n /**\n * The rule's block.\n */\n readonly block: RuleSet<Refs>\n}\n\n/**\n * Checks if a value is a `MediaRule`.\n *\n * True only for values built by this module's constructors, which carry\n * the brand.\n *\n * @param u - The value to check.\n * @returns `true` if the value is a `MediaRule`, `false` otherwise.\n * @since 0.1.0\n */\nexport const isMediaRule: (u: unknown) => u is MediaRule<string> = internal.isMediaRule\n\n/**\n * Creates a nested `@media` rule.\n *\n * @param query - The media query gating the block.\n * @param block - The rule's block.\n * @returns A `MediaRule` carrying the block's reference names.\n * @example\n * ```ts\n * MediaRule.make(\n * MediaQuery.prefersColorScheme('dark'),\n * RuleSet.make(Declaration.make('--scheme', 'dark')),\n * )\n * ```\n * @since 0.1.0\n */\nexport const make: <Refs extends string>(\n query: MediaQuery,\n block: RuleSet<Refs>,\n) => MediaRule<Refs> = internal.make\n\n/**\n * The rule's unbound reference names — the block's, since a query\n * contributes none.\n *\n * @param rule - The rule to inspect.\n * @returns The set of unbound reference names.\n * @since 0.1.0\n */\nexport const refs: <Refs extends string>(rule: MediaRule<Refs>) => ReadonlySet<Refs> = internal.refs\n\n/**\n * Options for `render` — the block renderers' shared shape,\n * `RuleSet.RenderOptions`, unchanged.\n *\n * @since 0.1.0\n */\nexport type RenderOptions = RuleSetRenderOptions\n\n/**\n * Renders the rule in nested form: `@media query { ... }`, the body as\n * `RuleSet.render` emits it, one level deeper — declarations directly\n * inside the query block, the shape a media rule takes nested in a\n * style rule (CSSNestedDeclarations). A rule whose block is empty\n * renders as the empty string.\n *\n * A fragment renderer: whole sheets render via `Stylesheet.render`,\n * which emits each rule's media in this same nested shape.\n *\n * @param rule - The rule to render.\n * @param options - Optional indentation unit, precision context, and media syntax.\n * @returns Deterministic CSS text.\n * @throws `Error` when the block nests a style rule — selector composition (`&`) is a later extension, not part of v1 rendering.\n * @example\n * ```ts\n * MediaRule.render(\n * MediaRule.make(MediaQuery.minWidth(768), RuleSet.make(Declaration.make('--gutter', 24))),\n * ) // '@media (min-width: 768px) {\\n\\t--gutter: 24;\\n}'\n * ```\n * @since 0.1.0\n */\nexport const render: (rule: MediaRule<string>, options?: RenderOptions) => string = internal.render\n\nexport const equals: {\n /**\n * Returns a function that checks structural equality against `that`.\n *\n * @param that - The rule to compare against.\n * @returns A function testing its argument for structural equality with `that`.\n * @since 0.1.0\n */\n (that: MediaRule<string>): (self: MediaRule<string>) => boolean\n /**\n * Structural equality: queries compare as in `MediaQuery.equals`\n * (canonically ordered features), blocks as in `RuleSet.equals`\n * (members in order).\n *\n * @param self - The first rule.\n * @param that - The second rule.\n * @returns `true` if the rules are structurally equal.\n * @since 0.1.0\n */\n (self: MediaRule<string>, that: MediaRule<string>): boolean\n} = internal.equals\n","import type {\n Declaration,\n RenderOptions as DeclarationRenderOptions,\n} from '#declaration/declaration'\nimport type { MediaQuery } from '#query/mediaQuery'\nimport type { Selector } from '#selector/selector'\nimport type { Pipeable } from '#util'\nimport type { MediaRule } from './mediaRule.ts'\nimport type { RuleSetTypeId } from './ruleSet.internal.ts'\nimport * as internal from './ruleSet.internal.ts'\nimport type { StyleRule } from './styleRule.ts'\n\n/**\n * An ordered block of rule members — the nesting unit of the rule layer.\n *\n * Member order is preserved exactly as authored: never sorted, never\n * deduplicated. A block's order is cascade behavior, and since\n * CSSNestedDeclarations shipped (late 2024), declarations trailing a\n * nested rule keep their source position rather than hoisting above it —\n * so what you append is what renders.\n *\n * The `Refs` parameter unions the members' unbound reference names, as on\n * `Calc`; `refs` is the runtime set.\n *\n * Construct via `make` (or `empty` and `append`).\n *\n * @since 0.1.0\n */\nexport interface RuleSet<out Refs extends string = string> extends Pipeable {\n readonly [RuleSetTypeId]: RuleSetTypeId\n /**\n * The block's members, in authored order.\n */\n readonly members: ReadonlyArray<Member<Refs>>\n}\n\n/**\n * The forms a rule block may contain: declarations, nested style rules,\n * and nested `@media` rules.\n *\n * Deliberately absent are the declaration-block at-rules (`@font-face`,\n * `@property`) — the CSS grammar keeps them at the top level, so this\n * union keeps them out of blocks at the type level.\n *\n * @since 0.1.0\n */\nexport type Member<Refs extends string = string> =\n | Declaration<Refs>\n | StyleRule<Refs>\n | MediaRule<Refs>\n\n/**\n * The unbound reference names of a `Member`, or the union of them for a\n * union of members — the type-level counterpart of `refs`, used by the\n * container constructors to thread their members' names into the result.\n *\n * @since 0.1.0\n */\nexport type MemberRefs<M extends Member<string>> =\n M extends Declaration<infer R>\n ? R\n : M extends StyleRule<infer R>\n ? R\n : M extends MediaRule<infer R>\n ? R\n : never\n\n/**\n * Checks if a value is a `RuleSet`.\n *\n * True only for values built by this module's constructors, which carry\n * the brand.\n *\n * @param u - The value to check.\n * @returns `true` if the value is a `RuleSet`, `false` otherwise.\n * @since 0.1.0\n */\nexport const isRuleSet: (u: unknown) => u is RuleSet<string> = internal.isRuleSet\n\n/**\n * The empty block — the identity for `concat`.\n *\n * @since 0.1.0\n */\nexport const empty: RuleSet<never> = internal.empty\n\n/**\n * Checks if the block has no members.\n *\n * Structural emptiness only: a non-empty block can still *render* as the\n * empty string, when every member is a nested rule whose block renders\n * empty.\n *\n * @param set - The block to inspect.\n * @returns `true` if the block has no members.\n * @since 0.2.0\n */\nexport const isEmpty: (set: RuleSet<string>) => boolean = internal.isEmpty\n\n/**\n * Creates a rule set holding the given members, in the given order.\n *\n * @param members - Declarations and nested rules, in authored order.\n * @returns A `RuleSet` whose `Refs` unions the members' reference names.\n * @example\n * ```ts\n * const block = RuleSet.make(\n * Declaration.make('--depth', Calc.ref('depth')),\n * Declaration.make('color', 'oklch(0.7 0.1 250)'),\n * ) // RuleSet<'depth'>\n * ```\n * @since 0.1.0\n */\nexport const make: <Members extends ReadonlyArray<Member<string>>>(\n ...members: Members\n) => RuleSet<MemberRefs<Members[number]>> = internal.make\n\nexport const append: {\n /**\n * Returns a function that appends `member` to its argument's block.\n *\n * @param member - The member to append.\n * @returns A function producing the extended block.\n * @since 0.1.0\n */\n <M extends Member<string>>(\n member: M,\n ): <Refs extends string>(self: RuleSet<Refs>) => RuleSet<Refs | MemberRefs<M>>\n /**\n * Returns a function that appends the style rule `selector { block }`\n * to its argument's block.\n *\n * @param selector - The nested rule's selector.\n * @param block - The nested rule's block.\n * @returns A function producing the extended block.\n * @since 0.1.0\n */\n <B extends string>(\n selector: Selector,\n block: RuleSet<B>,\n ): <Refs extends string>(self: RuleSet<Refs>) => RuleSet<Refs | B>\n /**\n * Returns a function that appends the media rule `@media query { block }`\n * to its argument's block.\n *\n * @param query - The nested rule's media query.\n * @param block - The nested rule's block.\n * @returns A function producing the extended block.\n * @since 0.1.0\n */\n <B extends string>(\n query: MediaQuery,\n block: RuleSet<B>,\n ): <Refs extends string>(self: RuleSet<Refs>) => RuleSet<Refs | B>\n /**\n * Appends a member at the end of the block. The result is a new set;\n * the original is untouched.\n *\n * @param self - The block to extend.\n * @param member - The member to append.\n * @returns The extended block, with the member's reference names joined in.\n * @example\n * ```ts\n * RuleSet.empty.pipe(\n * RuleSet.append(Declaration.make('color', 'red')),\n * RuleSet.append(Declaration.make('--depth', Calc.ref('depth'))),\n * ) // RuleSet<'depth'>\n * ```\n * @since 0.1.0\n */\n <Refs extends string, M extends Member<string>>(\n self: RuleSet<Refs>,\n member: M,\n ): RuleSet<Refs | MemberRefs<M>>\n /**\n * Appends a nested style rule from its parts — sugar for\n * `append(self, StyleRule.make(selector, block))`, so blocks compose\n * without naming `StyleRule` at the call site.\n *\n * @param self - The block to extend.\n * @param selector - The nested rule's selector.\n * @param block - The nested rule's block.\n * @returns The extended block, with the nested block's reference names joined in.\n * @example\n * ```ts\n * RuleSet.empty.pipe(RuleSet.append(Selector.class('btn'), RuleSet.make(Declaration.make('color', 'red'))))\n * ```\n * @since 0.1.0\n */\n <Refs extends string, B extends string>(\n self: RuleSet<Refs>,\n selector: Selector,\n block: RuleSet<B>,\n ): RuleSet<Refs | B>\n /**\n * Appends a nested media rule from its parts — sugar for\n * `append(self, MediaRule.make(query, block))`, so blocks compose\n * without naming `MediaRule` at the call site.\n *\n * @param self - The block to extend.\n * @param query - The nested rule's media query.\n * @param block - The nested rule's block.\n * @returns The extended block, with the nested block's reference names joined in.\n * @example\n * ```ts\n * RuleSet.make(Declaration.make('--gutter', 16)).pipe(\n * RuleSet.append(MediaQuery.minWidth(768), RuleSet.make(Declaration.make('--gutter', 24))),\n * )\n * ```\n * @since 0.1.0\n */\n <Refs extends string, B extends string>(\n self: RuleSet<Refs>,\n query: MediaQuery,\n block: RuleSet<B>,\n ): RuleSet<Refs | B>\n} = internal.append\n\nexport const concat: {\n /**\n * Returns a function that appends `that`'s members after its argument's.\n *\n * @param that - The block whose members come second.\n * @returns A function producing the concatenated block.\n * @since 0.1.0\n */\n <B extends string>(that: RuleSet<B>): <A extends string>(self: RuleSet<A>) => RuleSet<A | B>\n /**\n * Concatenates two blocks: `self`'s members followed by `that`'s, order\n * preserved on both sides. No deduplication happens here — repeated\n * declarations are legal CSS and their repetition is cascade behavior.\n *\n * @param self - The block whose members come first.\n * @param that - The block whose members come second.\n * @returns The concatenated block, with both sides' reference names unioned.\n * @since 0.1.0\n */\n <A extends string, B extends string>(self: RuleSet<A>, that: RuleSet<B>): RuleSet<A | B>\n} = internal.concat\n\nexport const forSelector: {\n /**\n * Returns a function that wraps its argument as the block of a style\n * rule applying to `selector`.\n *\n * @param selector - The selector the resulting rule's block applies to.\n * @returns A function that takes a block and returns the style rule applying it to `selector`.\n * @since 0.2.0\n */\n (selector: Selector): <Refs extends string>(self: RuleSet<Refs>) => StyleRule<Refs>\n /**\n * Lifts a block into a style rule applying to `selector` — sugar for\n * `StyleRule.make(selector, self)` with the arguments flipped, so a\n * block built up through `pipe` caps off as a rule without naming\n * `StyleRule` at the call site. The rule carries the block's reference\n * names unchanged; a selector contributes none.\n *\n * @param self - The block the rule applies.\n * @param selector - The selector the block applies to.\n * @returns The style rule pairing `selector` with the block.\n * @example\n * ```ts\n * RuleSet.make(Declaration.make('--depth', Calc.ref('depth'))).pipe(\n * RuleSet.forSelector(Selector.root),\n * ) // StyleRule<'depth'>\n * ```\n * @since 0.2.0\n */\n <Refs extends string>(self: RuleSet<Refs>, selector: Selector): StyleRule<Refs>\n} = internal.forSelector\n\nexport const forMediaQuery: {\n /**\n * Returns a function that wraps its argument as the block of a nested\n * `@media` rule gated by `query`.\n *\n * @param query - The media query gating the resulting rule's block.\n * @returns A function that takes a block and returns the media rule gating it by `query`.\n * @since 0.2.0\n */\n (query: MediaQuery): <Refs extends string>(self: RuleSet<Refs>) => MediaRule<Refs>\n /**\n * Lifts a block into a nested `@media` rule gated by `query` — sugar\n * for `MediaRule.make(query, self)` with the arguments flipped, so a\n * block built up through `pipe` caps off as a rule without naming\n * `MediaRule` at the call site. The rule carries the block's reference\n * names unchanged; a query contributes none.\n *\n * @param self - The block the rule gates.\n * @param query - The media query gating the block.\n * @returns The media rule pairing `query` with the block.\n * @example\n * ```ts\n * RuleSet.make(Declaration.make('--gutter', Calc.ref('gutter'))).pipe(\n * RuleSet.forMediaQuery(MediaQuery.minWidth(768)),\n * ) // MediaRule<'gutter'>\n * ```\n * @since 0.2.0\n */\n <Refs extends string>(self: RuleSet<Refs>, query: MediaQuery): MediaRule<Refs>\n} = internal.forMediaQuery\n\n/**\n * The block's unbound reference names, unioned across members —\n * including everything nested rules contribute.\n *\n * @param set - The block to inspect.\n * @returns The set of unbound reference names.\n * @since 0.1.0\n */\nexport const refs: <Refs extends string>(set: RuleSet<Refs>) => ReadonlySet<Refs> = internal.refs\n\n/**\n * Options for `render`, extending `Declaration.RenderOptions` (and\n * through it the family base, `MediaQuery.RenderOptions`) with the\n * indentation unit — the block renderers' shared shape, which\n * `StyleRule.render` and `MediaRule.render` take unchanged.\n *\n * @since 0.1.0\n */\nexport interface RenderOptions extends DeclarationRenderOptions {\n /**\n * The indentation unit, applied once per nesting level. Defaults to a\n * tab.\n */\n readonly indent?: string\n}\n\n/**\n * Renders the block's body — the text between a rule's braces, without\n * the braces: one line per declaration, nested `@media` rules as\n * indented sub-blocks, in member order. Empty blocks (and nested rules\n * whose blocks are empty) render as the empty string.\n *\n * A fragment renderer: use it to compose blocks the model does not\n * represent. Whole sheets render via `Stylesheet.render`.\n *\n * @param set - The block to render.\n * @param options - Optional indentation unit, precision context, and media syntax.\n * @returns Deterministic CSS text.\n * @throws `Error` when the block nests a style rule — selector composition (`&`) is a later extension, not part of v1 rendering.\n * @example\n * ```ts\n * RuleSet.render(RuleSet.make(Declaration.make('--depth', 4), Declaration.make('color', 'red')))\n * // '--depth: 4;\\ncolor: red;'\n * ```\n * @since 0.1.0\n */\nexport const render: (set: RuleSet<string>, options?: RenderOptions) => string = internal.render\n\nexport const equals: {\n /**\n * Returns a function that checks structural equality against `that`.\n *\n * @param that - The block to compare against.\n * @returns A function testing its argument for structural equality with `that`.\n * @since 0.1.0\n */\n (that: RuleSet<string>): (self: RuleSet<string>) => boolean\n /**\n * Structural equality over members, in order. Order participates —\n * `make(a, b)` and `make(b, a)` are different blocks, because they\n * cascade differently.\n *\n * @param self - The first block.\n * @param that - The second block.\n * @returns `true` if the blocks are structurally equal.\n * @since 0.1.0\n */\n (self: RuleSet<string>, that: RuleSet<string>): boolean\n} = internal.equals\n","import type { Selector } from '#selector/selector'\nimport type { Pipeable } from '#util'\nimport type { RenderOptions as RuleSetRenderOptions, RuleSet } from './ruleSet.ts'\nimport type { StyleRuleTypeId } from './styleRule.internal.ts'\nimport * as internal from './styleRule.internal.ts'\n\n/**\n * A style rule: a compound selector and the block it applies.\n *\n * The block is a full `RuleSet`, so a style rule holds declarations and\n * nested `@media` rules in one authored order. The `Refs` parameter is\n * the block's — a selector contributes no reference names.\n *\n * Construct via `make`.\n *\n * @since 0.1.0\n */\nexport interface StyleRule<out Refs extends string = string> extends Pipeable {\n readonly [StyleRuleTypeId]: StyleRuleTypeId\n /**\n * The compound selector the block applies to.\n */\n readonly selector: Selector\n /**\n * The rule's block.\n */\n readonly block: RuleSet<Refs>\n}\n\n/**\n * Checks if a value is a `StyleRule`.\n *\n * True only for values built by this module's constructors, which carry\n * the brand.\n *\n * @param u - The value to check.\n * @returns `true` if the value is a `StyleRule`, `false` otherwise.\n * @since 0.1.0\n */\nexport const isStyleRule: (u: unknown) => u is StyleRule<string> = internal.isStyleRule\n\n/**\n * Creates a style rule.\n *\n * @param selector - The compound selector the block applies to.\n * @param block - The rule's block.\n * @returns A `StyleRule` carrying the block's reference names.\n * @example\n * ```ts\n * StyleRule.make(\n * Selector.root,\n * RuleSet.make(Declaration.make('--depth', Calc.ref('depth'))),\n * ) // StyleRule<'depth'>\n * ```\n * @since 0.1.0\n */\nexport const make: <Refs extends string>(\n selector: Selector,\n block: RuleSet<Refs>,\n) => StyleRule<Refs> = internal.make\n\n/**\n * The rule's unbound reference names — the block's, since a selector\n * contributes none.\n *\n * @param rule - The rule to inspect.\n * @returns The set of unbound reference names.\n * @since 0.1.0\n */\nexport const refs: <Refs extends string>(rule: StyleRule<Refs>) => ReadonlySet<Refs> = internal.refs\n\n/**\n * Options for `render` — the block renderers' shared shape,\n * `RuleSet.RenderOptions`, unchanged.\n *\n * @since 0.1.0\n */\nexport type RenderOptions = RuleSetRenderOptions\n\n/**\n * Renders the rule in nested form: `selector { ... }`, the body as\n * `RuleSet.render` emits it, one level deeper. A rule whose block is\n * empty renders as the empty string.\n *\n * A fragment renderer: whole sheets render via `Stylesheet.render`,\n * which emits each rule in this same nested shape.\n *\n * @param rule - The rule to render.\n * @param options - Optional indentation unit, precision context, and media syntax.\n * @returns Deterministic CSS text.\n * @throws `Error` when the block nests a style rule — selector composition (`&`) is a later extension, not part of v1 rendering.\n * @example\n * ```ts\n * StyleRule.render(StyleRule.make(Selector.root, RuleSet.make(Declaration.make('--depth', 4))))\n * // ':root {\\n\\t--depth: 4;\\n}'\n * ```\n * @since 0.1.0\n */\nexport const render: (rule: StyleRule<string>, options?: RenderOptions) => string = internal.render\n\nexport const equals: {\n /**\n * Returns a function that checks structural equality against `that`.\n *\n * @param that - The rule to compare against.\n * @returns A function testing its argument for structural equality with `that`.\n * @since 0.1.0\n */\n (that: StyleRule<string>): (self: StyleRule<string>) => boolean\n /**\n * Structural equality: selectors compare as in `Selector.equals`\n * (canonically ordered parts), blocks as in `RuleSet.equals` (members\n * in order).\n *\n * @param self - The first rule.\n * @param that - The second rule.\n * @returns `true` if the rules are structurally equal.\n * @since 0.1.0\n */\n (self: StyleRule<string>, that: StyleRule<string>): boolean\n} = internal.equals\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAyCA,MAAa,cAAsDA;;;;;;;;;;;;;;;;AAiBnE,MAAaC,SAGUC;;;;;;;;;AAUvB,MAAaC,SAA0EC;;;;;;;;;;;;;;;;;;;;;;;AAgCvF,MAAaC,WAAuEC;AAEpF,MAAaC,WAoBTC;;;;;;;;;;;;;;;;;;;;;;;;;;AChDJ,MAAa,YAAkDC;;;;;;AAO/D,MAAa,QAAwBC;;;;;;;;;;;;AAarC,MAAa,UAA6CC;;;;;;;;;;;;;;;AAgB1D,MAAaC,SAE+BC;AAE5C,MAAa,SAmGTC;AAEJ,MAAa,SAoBTC;AAEJ,MAAa,cA6BTC;AAEJ,MAAa,gBA6BTC;;;;;;;;;AAUJ,MAAaC,SAAuEC;;;;;;;;;;;;;;;;;;;;;AAsCpF,MAAaC,WAAoEC;AAEjF,MAAaC,WAoBTC;;;;;;;;;;;;;;;;;;;;AC3UJ,MAAa,cAAsDC;;;;;;;;;;;;;;;;AAiBnE,MAAa,OAGUC;;;;;;;;;AAUvB,MAAa,OAA0EC;;;;;;;;;;;;;;;;;;;;AA6BvF,MAAa,SAAuEC;AAEpF,MAAa,SAoBTC"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["internal.isMediaRule","make","internal.make","vars","internal.refs","render","internal.render","equals","internal.equals","internal.isRuleSet","internal.empty","internal.isEmpty","make","internal.make","internal.append","internal.concat","internal.forSelector","internal.forMediaQuery","vars","internal.refs","render","internal.render","equals","internal.equals","internal.isStyleRule","internal.make","internal.refs","internal.render","internal.equals"],"sources":["../../src/rule/mediaRule.ts","../../src/rule/ruleSet.ts","../../src/rule/styleRule.ts"],"sourcesContent":["import type { MediaQuery } from '#query/mediaQuery'\nimport type { Requirement } from '#selector/selector'\nimport type { Pipeable } from '#util'\nimport type { Var } from '#var'\nimport type { MediaRuleTypeId } from './mediaRule.internal.ts'\nimport * as internal from './mediaRule.internal.ts'\nimport type { RenderOptions as RuleSetRenderOptions, RuleSet } from './ruleSet.ts'\n\n/**\n * A `@media` rule: a media query and the block it gates.\n *\n * The usual position is nested — a member of an enclosing style rule's\n * block, holding declarations that apply to that rule's selector, per\n * the CSSNestedDeclarations grammar. A media rule whose block holds only\n * closed style rules may instead sit at a stylesheet's top level, the\n * authored `@media { selector { ... } }` grouping. The `Vars` parameter\n * is the block's.\n *\n * `Requires` is the block's too — a media rule has no selector of its\n * own, so it is transparent to the requirements channel. Bare\n * declarations put `Parent` in the block's requirements, which is what\n * confines a declaration-bearing media rule to nested position:\n * `Stylesheet`'s node union takes `MediaRule<Vars, never>`.\n *\n * Construct via `make`.\n *\n * @since 0.1.0\n */\nexport interface MediaRule<\n out Vars extends Var.Any = Var.Any,\n out Requires extends Requirement = Requirement,\n> extends Pipeable {\n readonly [MediaRuleTypeId]: MediaRuleTypeId\n /**\n * The media query gating the block.\n */\n readonly query: MediaQuery\n /**\n * The rule's block.\n */\n readonly block: RuleSet<Vars, Requires>\n}\n\n/**\n * Checks if a value is a `MediaRule`.\n *\n * True only for values built by this module's constructors, which carry\n * the brand.\n *\n * @param u - The value to check.\n * @returns `true` if the value is a `MediaRule`, `false` otherwise.\n * @since 0.1.0\n */\nexport const isMediaRule: (u: unknown) => u is MediaRule<Var.Any> = internal.isMediaRule\n\n/**\n * Creates a `@media` rule.\n *\n * @param query - The media query gating the block.\n * @param block - The rule's block. Declarations make the rule nested-only; a block of closed style rules makes it top-level-capable.\n * @returns A `MediaRule` carrying the block's variable names and requirements.\n * @example\n * ```ts\n * MediaRule.make(\n * MediaQuery.prefersColorScheme('dark'),\n * RuleSet.make(Declaration.make('--scheme', 'dark')),\n * )\n * ```\n * @since 0.1.0\n */\nexport const make: <Vars extends Var.Any, Requires extends Requirement>(\n query: MediaQuery,\n block: RuleSet<Vars, Requires>,\n) => MediaRule<Vars, Requires> = internal.make\n\n/**\n * The rule's unbound variable names — the block's, since a query\n * contributes none.\n *\n * @param rule - The rule to inspect.\n * @returns The set of unbound variable names.\n * @since 0.1.0\n */\nexport const vars: <Vars extends Var.Any>(rule: MediaRule<Vars>) => ReadonlySet<Var.Name<Vars>> =\n internal.refs\n\n/**\n * Options for `render` — the block renderers' shared shape,\n * `RuleSet.RenderOptions`, unchanged.\n *\n * @since 0.1.0\n */\nexport type RenderOptions = RuleSetRenderOptions\n\n/**\n * Renders the rule in nested form: `@media query { ... }`, the body as\n * `RuleSet.render` emits it, one level deeper — declarations directly\n * inside the query block, the shape a media rule takes nested in a\n * style rule (CSSNestedDeclarations). A rule whose block is empty\n * renders as the empty string.\n *\n * Nested style rules render as indented sub-blocks with `&` kept\n * verbatim — native CSS nesting is the output shape.\n *\n * A fragment renderer: whole sheets render via `Stylesheet.render`,\n * which emits each rule's media in this same nested shape.\n *\n * @param rule - The rule to render.\n * @param options - Optional indentation unit, precision context, and media syntax.\n * @returns Deterministic CSS text.\n * @example\n * ```ts\n * MediaRule.render(\n * MediaRule.make(MediaQuery.minWidth(768), RuleSet.make(Declaration.make('--gutter', 24))),\n * ) // '@media (min-width: 768px) {\\n\\t--gutter: 24;\\n}'\n * ```\n * @since 0.1.0\n */\nexport const render: (rule: MediaRule<Var.Any>, options?: RenderOptions) => string = internal.render\n\nexport const equals: {\n /**\n * Returns a function that checks structural equality against `that`.\n *\n * @param that - The rule to compare against.\n * @returns A function testing its argument for structural equality with `that`.\n * @since 0.1.0\n */\n (that: MediaRule<Var.Any>): (self: MediaRule<Var.Any>) => boolean\n /**\n * Structural equality: queries compare as in `MediaQuery.equals`\n * (canonically ordered features), blocks as in `RuleSet.equals`\n * (members in order).\n *\n * @param self - The first rule.\n * @param that - The second rule.\n * @returns `true` if the rules are structurally equal.\n * @since 0.1.0\n */\n (self: MediaRule<Var.Any>, that: MediaRule<Var.Any>): boolean\n} = internal.equals\n","import type {\n Declaration,\n RenderOptions as DeclarationRenderOptions,\n} from '#declaration/declaration'\nimport type { MediaQuery } from '#query/mediaQuery'\nimport type { Parent, Requirement, Selector } from '#selector/selector'\nimport type { Pipeable } from '#util'\nimport type { Var } from '#var'\nimport type { MediaRule } from './mediaRule.ts'\nimport type { RuleSetTypeId } from './ruleSet.internal.ts'\nimport * as internal from './ruleSet.internal.ts'\nimport type { StyleRule } from './styleRule.ts'\n\n/**\n * An ordered block of rule members — the nesting unit of the rule layer.\n *\n * Member order is preserved exactly as authored: never sorted, never\n * deduplicated. A block's order is cascade behavior, and since\n * CSSNestedDeclarations shipped (late 2024), declarations trailing a\n * nested rule keep their source position rather than hoisting above it —\n * so what you append is what renders.\n *\n * The `Vars` parameter unions the members' unbound variable names, as on\n * `Calc`; `vars` is the runtime set.\n *\n * The `Requires` parameter unions the members' context requirements\n * (`Selector.Requirement`, section 4.4 of `docs/design.md`): `Parent`\n * from every bare declaration and from every nested rule whose selector\n * references `&`. A style rule discharges its block's requirements\n * against its own selector; a block of closed style rules and nothing\n * else is `RuleSet<Vars, never>`, the only form a top-level `@media`\n * block may take.\n *\n * Construct via `make` (or `empty` and `append`).\n *\n * @since 0.1.0\n */\nexport interface RuleSet<\n out Vars extends Var.Any = Var.Any,\n out Requires extends Requirement = Requirement,\n> extends Pipeable {\n readonly [RuleSetTypeId]: RuleSetTypeId\n /**\n * The block's members, in authored order.\n */\n readonly members: ReadonlyArray<Member<Vars, Requires>>\n}\n\n/**\n * The forms a rule block may contain: declarations, nested style rules,\n * and nested `@media` rules. `Requires` bounds the rule arms'\n * requirements; `MemberRequires` computes a member's contribution.\n *\n * Deliberately absent are the declaration-block at-rules (`@font-face`,\n * `@property`) — the CSS grammar keeps them at the top level, so this\n * union keeps them out of blocks at the type level.\n *\n * @since 0.1.0\n */\nexport type Member<Vars extends Var.Any = Var.Any, Requires extends Requirement = Requirement> =\n | Declaration<Vars>\n | StyleRule<Vars, Requires>\n | MediaRule<Vars, Requires>\n\n/**\n * The unbound variable names of a `Member`, or the union of them for a\n * union of members — the type-level counterpart of `vars`, used by the\n * container constructors to thread their members' names into the result.\n *\n * @since 0.1.0\n */\nexport type MemberVars<M extends Member<Var.Any>> =\n M extends Declaration<infer R>\n ? R\n : M extends StyleRule<infer R, Requirement>\n ? R\n : M extends MediaRule<infer R, Requirement>\n ? R\n : never\n\n/**\n * The requirement contribution of a `Member`, or the union of them for a\n * union of members — the type-level counterpart of the containers'\n * `Requires` parameter, used by the constructors to thread member\n * requirements into the result.\n *\n * A bare declaration contributes `Parent`: without a host selector it\n * has no subject. A style rule contributes its selector's requirements —\n * its block's are its own to discharge. A media rule is transparent and\n * contributes its block's.\n *\n * @since 0.4.0\n */\nexport type MemberRequires<M extends Member<Var.Any>> =\n M extends Declaration<Var.Any>\n ? Parent\n : M extends StyleRule<Var.Any, infer R>\n ? R\n : M extends MediaRule<Var.Any, infer R>\n ? R\n : never\n\n/**\n * Checks if a value is a `RuleSet`.\n *\n * True only for values built by this module's constructors, which carry\n * the brand.\n *\n * @param u - The value to check.\n * @returns `true` if the value is a `RuleSet`, `false` otherwise.\n * @since 0.1.0\n */\nexport const isRuleSet: (u: unknown) => u is RuleSet<Var.Any> = internal.isRuleSet\n\n/**\n * The empty block — the identity for `concat`.\n *\n * @since 0.1.0\n */\nexport const empty: RuleSet<never, never> = internal.empty\n\n/**\n * Checks if the block has no members.\n *\n * Structural emptiness only: a non-empty block can still *render* as the\n * empty string, when every member is a nested rule whose block renders\n * empty.\n *\n * @param set - The block to inspect.\n * @returns `true` if the block has no members.\n * @since 0.2.0\n */\nexport const isEmpty: (set: RuleSet<Var.Any>) => boolean = internal.isEmpty\n\n/**\n * Creates a rule set holding the given members, in the given order.\n *\n * @param members - Declarations and nested rules, in authored order.\n * @returns A `RuleSet` whose `Vars` unions the members' variable names and whose `Requires` unions their requirement contributions.\n * @example\n * ```ts\n * const block = RuleSet.make(\n * Declaration.make('--depth', Calc.var('depth')),\n * Declaration.make('color', 'oklch(0.7 0.1 250)'),\n * ) // RuleSet<'depth'>\n * ```\n * @since 0.1.0\n */\nexport const make: <Members extends ReadonlyArray<Member<Var.Any>>>(\n ...members: Members\n) => RuleSet<MemberVars<Members[number]>, MemberRequires<Members[number]>> = internal.make\n\nexport const append: {\n /**\n * Returns a function that appends `member` to its argument's block.\n *\n * @param member - The member to append.\n * @returns A function producing the extended block.\n * @since 0.1.0\n */\n <M extends Member<Var.Any>>(\n member: M,\n ): <Vars extends Var.Any, Requires extends Requirement>(\n self: RuleSet<Vars, Requires>,\n ) => RuleSet<Vars | MemberVars<M>, Requires | MemberRequires<M>>\n /**\n * Returns a function that appends the style rule `selector { block }`\n * to its argument's block.\n *\n * @param selector - The nested rule's selector. Must reference `&` by the time an enclosing rule binds the block.\n * @param block - The nested rule's block.\n * @returns A function producing the extended block.\n * @since 0.1.0\n */\n <B extends Var.Any, S extends Requirement>(\n selector: Selector<S>,\n block: RuleSet<B>,\n ): <Vars extends Var.Any, Requires extends Requirement>(\n self: RuleSet<Vars, Requires>,\n ) => RuleSet<Vars | B, Requires | S>\n /**\n * Returns a function that appends the media rule `@media query { block }`\n * to its argument's block.\n *\n * @param query - The nested rule's media query.\n * @param block - The nested rule's block.\n * @returns A function producing the extended block.\n * @since 0.1.0\n */\n <B extends Var.Any, BR extends Requirement>(\n query: MediaQuery,\n block: RuleSet<B, BR>,\n ): <Vars extends Var.Any, Requires extends Requirement>(\n self: RuleSet<Vars, Requires>,\n ) => RuleSet<Vars | B, Requires | BR>\n /**\n * Appends a member at the end of the block. The result is a new set;\n * the original is untouched.\n *\n * @param self - The block to extend.\n * @param member - The member to append.\n * @returns The extended block, with the member's variable names joined in.\n * @example\n * ```ts\n * RuleSet.empty.pipe(\n * RuleSet.append(Declaration.make('color', 'red')),\n * RuleSet.append(Declaration.make('--depth', Calc.var('depth'))),\n * ) // RuleSet<'depth'>\n * ```\n * @since 0.1.0\n */\n <Vars extends Var.Any, Requires extends Requirement, M extends Member<Var.Any>>(\n self: RuleSet<Vars, Requires>,\n member: M,\n ): RuleSet<Vars | MemberVars<M>, Requires | MemberRequires<M>>\n /**\n * Appends a nested style rule from its parts — sugar for\n * `append(self, StyleRule.make(selector, block))`, so blocks compose\n * without naming `StyleRule` at the call site.\n *\n * The nested rule's selector must reference `&` (`Selector.nest`) by\n * the time an enclosing rule binds this block — `StyleRule.make`\n * enforces it there, as the binder.\n *\n * @param self - The block to extend.\n * @param selector - The nested rule's selector.\n * @param block - The nested rule's block.\n * @returns The extended block, with the nested block's variable names joined in.\n * @throws `Error` when a style rule nested in `block` has a selector that does not reference `&`.\n * @example\n * ```ts\n * RuleSet.empty.pipe(\n * RuleSet.append(\n * Selector.and(Selector.nest, Selector.pseudoClass('hover')),\n * RuleSet.make(Declaration.make('color', 'red')),\n * ),\n * )\n * ```\n * @since 0.1.0\n */\n <Vars extends Var.Any, Requires extends Requirement, B extends Var.Any, S extends Requirement>(\n self: RuleSet<Vars, Requires>,\n selector: Selector<S>,\n block: RuleSet<B>,\n ): RuleSet<Vars | B, Requires | S>\n /**\n * Appends a nested media rule from its parts — sugar for\n * `append(self, MediaRule.make(query, block))`, so blocks compose\n * without naming `MediaRule` at the call site.\n *\n * @param self - The block to extend.\n * @param query - The nested rule's media query.\n * @param block - The nested rule's block.\n * @returns The extended block, with the nested block's variable names joined in.\n * @example\n * ```ts\n * RuleSet.make(Declaration.make('--gutter', 16)).pipe(\n * RuleSet.append(MediaQuery.minWidth(768), RuleSet.make(Declaration.make('--gutter', 24))),\n * )\n * ```\n * @since 0.1.0\n */\n <Vars extends Var.Any, Requires extends Requirement, B extends Var.Any, BR extends Requirement>(\n self: RuleSet<Vars, Requires>,\n query: MediaQuery,\n block: RuleSet<B, BR>,\n ): RuleSet<Vars | B, Requires | BR>\n} = internal.append\n\nexport const concat: {\n /**\n * Returns a function that appends `that`'s members after its argument's.\n *\n * @param that - The block whose members come second.\n * @returns A function producing the concatenated block.\n * @since 0.1.0\n */\n <B extends Var.Any, BR extends Requirement>(\n that: RuleSet<B, BR>,\n ): <A extends Var.Any, AR extends Requirement>(self: RuleSet<A, AR>) => RuleSet<A | B, AR | BR>\n /**\n * Concatenates two blocks: `self`'s members followed by `that`'s, order\n * preserved on both sides. No deduplication happens here — repeated\n * declarations are legal CSS and their repetition is cascade behavior.\n *\n * @param self - The block whose members come first.\n * @param that - The block whose members come second.\n * @returns The concatenated block, with both sides' variable names and requirements unioned.\n * @since 0.1.0\n */\n <A extends Var.Any, AR extends Requirement, B extends Var.Any, BR extends Requirement>(\n self: RuleSet<A, AR>,\n that: RuleSet<B, BR>,\n ): RuleSet<A | B, AR | BR>\n} = internal.concat\n\nexport const forSelector: {\n /**\n * Returns a function that wraps its argument as the block of a style\n * rule applying to `selector`.\n *\n * @param selector - The selector the resulting rule's block applies to.\n * @returns A function that takes a block and returns the style rule applying it to `selector`.\n * @since 0.2.0\n */\n <S extends Requirement>(\n selector: Selector<S>,\n ): <Vars extends Var.Any>(self: RuleSet<Vars>) => StyleRule<Vars, S>\n /**\n * Lifts a block into a style rule applying to `selector` — sugar for\n * `StyleRule.make(selector, self)` with the arguments flipped, so a\n * block built up through `pipe` caps off as a rule without naming\n * `StyleRule` at the call site. The rule carries the block's variable\n * names unchanged; its requirements are the selector's, the block's\n * discharged. The binder check runs here, as in `StyleRule.make`.\n *\n * @param self - The block the rule applies.\n * @param selector - The selector the block applies to.\n * @returns The style rule pairing `selector` with the block.\n * @throws `Error` when a style rule nested in `self` has a selector that does not reference `&`.\n * @example\n * ```ts\n * RuleSet.make(Declaration.make('--depth', Calc.var('depth'))).pipe(\n * RuleSet.forSelector(Selector.root),\n * ) // StyleRule<'depth'>\n * ```\n * @since 0.2.0\n */\n <Vars extends Var.Any, S extends Requirement>(\n self: RuleSet<Vars>,\n selector: Selector<S>,\n ): StyleRule<Vars, S>\n} = internal.forSelector\n\nexport const forMediaQuery: {\n /**\n * Returns a function that wraps its argument as the block of a nested\n * `@media` rule gated by `query`.\n *\n * @param query - The media query gating the resulting rule's block.\n * @returns A function that takes a block and returns the media rule gating it by `query`.\n * @since 0.2.0\n */\n (\n query: MediaQuery,\n ): <Vars extends Var.Any, Requires extends Requirement>(\n self: RuleSet<Vars, Requires>,\n ) => MediaRule<Vars, Requires>\n /**\n * Lifts a block into a `@media` rule gated by `query` — sugar for\n * `MediaRule.make(query, self)` with the arguments flipped, so a block\n * built up through `pipe` caps off as a rule without naming\n * `MediaRule` at the call site. The rule carries the block's variable\n * names and requirements unchanged; a query contributes neither.\n *\n * @param self - The block the rule gates.\n * @param query - The media query gating the block.\n * @returns The media rule pairing `query` with the block.\n * @example\n * ```ts\n * RuleSet.make(Declaration.make('--gutter', Calc.var('gutter'))).pipe(\n * RuleSet.forMediaQuery(MediaQuery.minWidth(768)),\n * ) // MediaRule<'gutter'>\n * ```\n * @since 0.2.0\n */\n <Vars extends Var.Any, Requires extends Requirement>(\n self: RuleSet<Vars, Requires>,\n query: MediaQuery,\n ): MediaRule<Vars, Requires>\n} = internal.forMediaQuery\n\n/**\n * The block's unbound variable names, unioned across members —\n * including everything nested rules contribute.\n *\n * @param set - The block to inspect.\n * @returns The set of unbound variable names.\n * @since 0.1.0\n */\nexport const vars: <Vars extends Var.Any>(set: RuleSet<Vars>) => ReadonlySet<Var.Name<Vars>> =\n internal.refs\n\n/**\n * Options for `render`, extending `Declaration.RenderOptions` (and\n * through it the family base, `MediaQuery.RenderOptions`) with the\n * indentation unit — the block renderers' shared shape, which\n * `StyleRule.render` and `MediaRule.render` take unchanged.\n *\n * @since 0.1.0\n */\nexport interface RenderOptions extends DeclarationRenderOptions {\n /**\n * The indentation unit, applied once per nesting level. Defaults to a\n * tab.\n */\n readonly indent?: string\n}\n\n/**\n * Renders the block's body — the text between a rule's braces, without\n * the braces: one line per declaration, nested `@media` and style rules\n * as indented sub-blocks (`&` kept verbatim), in member order. Empty\n * blocks (and nested rules whose blocks are empty) render as the empty\n * string.\n *\n * A fragment renderer: use it to compose blocks the model does not\n * represent. Whole sheets render via `Stylesheet.render`, and the binder\n * invariant on nested selectors is `StyleRule.make`'s — a free-standing\n * block renders without it.\n *\n * @param set - The block to render.\n * @param options - Optional indentation unit, precision context, and media syntax.\n * @returns Deterministic CSS text.\n * @example\n * ```ts\n * RuleSet.render(RuleSet.make(Declaration.make('--depth', 4), Declaration.make('color', 'red')))\n * // '--depth: 4;\\ncolor: red;'\n * ```\n * @since 0.1.0\n */\nexport const render: (set: RuleSet<Var.Any>, options?: RenderOptions) => string = internal.render\n\nexport const equals: {\n /**\n * Returns a function that checks structural equality against `that`.\n *\n * @param that - The block to compare against.\n * @returns A function testing its argument for structural equality with `that`.\n * @since 0.1.0\n */\n (that: RuleSet<Var.Any>): (self: RuleSet<Var.Any>) => boolean\n /**\n * Structural equality over members, in order. Order participates —\n * `make(a, b)` and `make(b, a)` are different blocks, because they\n * cascade differently.\n *\n * @param self - The first block.\n * @param that - The second block.\n * @returns `true` if the blocks are structurally equal.\n * @since 0.1.0\n */\n (self: RuleSet<Var.Any>, that: RuleSet<Var.Any>): boolean\n} = internal.equals\n","import type { Requirement, Selector } from '#selector/selector'\nimport type { Pipeable } from '#util'\nimport type { Var } from '#var'\nimport type { RenderOptions as RuleSetRenderOptions, RuleSet } from './ruleSet.ts'\nimport type { StyleRuleTypeId } from './styleRule.internal.ts'\nimport * as internal from './styleRule.internal.ts'\n\n/**\n * A style rule: a selector and the block it applies.\n *\n * The block is a full `RuleSet`, so a style rule holds declarations,\n * nested style rules, and nested `@media` rules in one authored order.\n * The rule is selector nesting's binder: `&` in a nested rule's selector\n * reads this rule's selector. The `Vars` parameter is the block's — a\n * selector contributes no variable names.\n *\n * `Requires` is the *selector's* requirements, not the block's: the\n * binder discharges everything its block needs, so the rule needs a\n * parent exactly when its own selector references `&`. It defaults to\n * `never` — the closed, top-level form — because that is the form\n * consumer annotations usually name.\n *\n * Construct via `make`.\n *\n * @since 0.1.0\n */\nexport interface StyleRule<\n out Vars extends Var.Any = Var.Any,\n out Requires extends Requirement = never,\n> extends Pipeable {\n readonly [StyleRuleTypeId]: StyleRuleTypeId\n /**\n * The selector the block applies to. References `&` exactly when the\n * rule nests inside another rule's block.\n */\n readonly selector: Selector<Requires>\n /**\n * The rule's block.\n */\n readonly block: RuleSet<Vars>\n}\n\n/**\n * Checks if a value is a `StyleRule`.\n *\n * True only for values built by this module's constructors, which carry\n * the brand.\n *\n * @param u - The value to check.\n * @returns `true` if the value is a `StyleRule`, `false` otherwise.\n * @since 0.1.0\n */\nexport const isStyleRule: (u: unknown) => u is StyleRule<Var.Any, Requirement> =\n internal.isStyleRule\n\n/**\n * Creates a style rule.\n *\n * The binder check runs here: every style rule nested in `block` —\n * directly, or inside its `@media` blocks — must reference `&` in its\n * selector, because this rule's selector is what that `&` reads. CSS\n * would silently prepend a descendant `&` instead; the model rejects\n * the shape rather than rewriting the authored selector.\n *\n * @param selector - The selector the block applies to. References `&` exactly when this rule itself nests.\n * @param block - The rule's block.\n * @returns A `StyleRule` carrying the block's variable names and the selector's requirements.\n * @throws `Error` when a style rule nested in `block` has a selector that does not reference `&`.\n * @example\n * ```ts\n * StyleRule.make(\n * Selector.root,\n * RuleSet.make(Declaration.make('--depth', Calc.var('depth'))),\n * ) // StyleRule<'depth'>\n * ```\n * @since 0.1.0\n */\nexport const make: <Vars extends Var.Any, S extends Requirement>(\n selector: Selector<S>,\n block: RuleSet<Vars>,\n) => StyleRule<Vars, S> = internal.make\n\n/**\n * The rule's unbound variable names — the block's, since a selector\n * contributes none.\n *\n * @param rule - The rule to inspect.\n * @returns The set of unbound variable names.\n * @since 0.1.0\n */\nexport const vars: <Vars extends Var.Any>(\n rule: StyleRule<Vars, Requirement>,\n) => ReadonlySet<Var.Name<Vars>> = internal.refs\n\n/**\n * Options for `render` — the block renderers' shared shape,\n * `RuleSet.RenderOptions`, unchanged.\n *\n * @since 0.1.0\n */\nexport type RenderOptions = RuleSetRenderOptions\n\n/**\n * Renders the rule in nested form: `selector { ... }`, the body as\n * `RuleSet.render` emits it, one level deeper. Nested style rules render\n * as indented sub-blocks with `&` kept verbatim — native CSS nesting is\n * the output shape. A rule whose block is empty renders as the empty\n * string.\n *\n * A fragment renderer: whole sheets render via `Stylesheet.render`,\n * which emits each rule in this same nested shape.\n *\n * @param rule - The rule to render.\n * @param options - Optional indentation unit, precision context, and media syntax.\n * @returns Deterministic CSS text.\n * @example\n * ```ts\n * StyleRule.render(StyleRule.make(Selector.root, RuleSet.make(Declaration.make('--depth', 4))))\n * // ':root {\\n\\t--depth: 4;\\n}'\n * ```\n * @since 0.1.0\n */\nexport const render: (rule: StyleRule<Var.Any, Requirement>, options?: RenderOptions) => string =\n internal.render\n\nexport const equals: {\n /**\n * Returns a function that checks structural equality against `that`.\n *\n * @param that - The rule to compare against.\n * @returns A function testing its argument for structural equality with `that`.\n * @since 0.1.0\n */\n (that: StyleRule<Var.Any, Requirement>): (self: StyleRule<Var.Any, Requirement>) => boolean\n /**\n * Structural equality: selectors compare as in `Selector.equals`\n * (canonically ordered parts), blocks as in `RuleSet.equals` (members\n * in order).\n *\n * @param self - The first rule.\n * @param that - The second rule.\n * @returns `true` if the rules are structurally equal.\n * @since 0.1.0\n */\n (self: StyleRule<Var.Any, Requirement>, that: StyleRule<Var.Any, Requirement>): boolean\n} = internal.equals\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAqDA,MAAa,cAAuDA;;;;;;;;;;;;;;;;AAiBpE,MAAaC,SAGoBC;;;;;;;;;AAUjC,MAAaC,SACXC;;;;;;;;;;;;;;;;;;;;;;;;;AAkCF,MAAaC,WAAwEC;AAErF,MAAaC,WAoBTC;;;;;;;;;;;;;;;;;;;;;;;;;;AC5BJ,MAAa,YAAmDC;;;;;;AAOhE,MAAa,QAA+BC;;;;;;;;;;;;AAa5C,MAAa,UAA8CC;;;;;;;;;;;;;;;AAgB3D,MAAaC,SAEgEC;AAE7E,MAAa,SAmHTC;AAEJ,MAAa,SAyBTC;AAEJ,MAAa,cAoCTC;AAEJ,MAAa,gBAoCTC;;;;;;;;;AAUJ,MAAaC,SACXC;;;;;;;;;;;;;;;;;;;;;;;AAwCF,MAAaC,WAAqEC;AAElF,MAAaC,WAoBTC;;;;;;;;;;;;;;;;;;;;ACvYJ,MAAa,cACXC;;;;;;;;;;;;;;;;;;;;;;;AAwBF,MAAa,OAGaC;;;;;;;;;AAU1B,MAAa,OAEsBC;;;;;;;;;;;;;;;;;;;;;AA8BnC,MAAa,SACXC;AAEF,MAAa,SAoBTC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as specificity_d_exports, i as selector_d_exports } from "../shared/selector-BkxnzX_6.mjs";
|
|
2
2
|
export { selector_d_exports as Selector, specificity_d_exports as Specificity };
|