@tenphi/tasty 2.0.3 → 2.0.4
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/{ssr/async-storage.js → async-storage-B7_o6FKt.js} +2 -2
- package/dist/async-storage-B7_o6FKt.js.map +1 -0
- package/dist/{ssr/collector.d.ts → collector-CkZ517g4.d.ts} +3 -3
- package/dist/{ssr/collector.js → collector-DXqvGOb1.js} +5 -10
- package/dist/collector-DXqvGOb1.js.map +1 -0
- package/dist/config-5jzS6k6B.js +10005 -0
- package/dist/config-5jzS6k6B.js.map +1 -0
- package/dist/config-DknGsfMo.d.ts +857 -0
- package/dist/{ssr/context.js → context-CkSg-kDT.js} +11 -3
- package/dist/context-CkSg-kDT.js.map +1 -0
- package/dist/core/index.d.ts +5 -34
- package/dist/core/index.js +5 -26
- package/dist/core-CtU6-9OC.js +1507 -0
- package/dist/core-CtU6-9OC.js.map +1 -0
- package/dist/{zero/extractor.js → css-writer-DHkX0JuE.js} +74 -11
- package/dist/css-writer-DHkX0JuE.js.map +1 -0
- package/dist/{ssr/format-global-rules.js → format-global-rules-Dbc_1tc3.js} +2 -2
- package/dist/format-global-rules-Dbc_1tc3.js.map +1 -0
- package/dist/format-rules-DH13ewDu.js +143 -0
- package/dist/format-rules-DH13ewDu.js.map +1 -0
- package/dist/{ssr/hydrate.js → hydrate-C1Gv-DoS.js} +3 -3
- package/dist/hydrate-C1Gv-DoS.js.map +1 -0
- package/dist/{styles/types.d.ts → index-PzENbpAq.d.ts} +701 -5
- package/dist/index-o7zV2yCr.d.ts +1561 -0
- package/dist/index.d.ts +5 -51
- package/dist/index.js +728 -35
- package/dist/index.js.map +1 -0
- package/dist/keyframes-b7X3UxDV.js +587 -0
- package/dist/keyframes-b7X3UxDV.js.map +1 -0
- package/dist/{utils/merge-styles.d.ts → merge-styles-C7KTy7MY.d.ts} +3 -3
- package/dist/{utils/merge-styles.js → merge-styles-Tgo3BbL2.js} +3 -4
- package/dist/merge-styles-Tgo3BbL2.js.map +1 -0
- package/dist/{utils/resolve-recipes.js → resolve-recipes-Ca2-5CxM.js} +4 -6
- package/dist/resolve-recipes-Ca2-5CxM.js.map +1 -0
- package/dist/ssr/astro-client.js +1 -1
- package/dist/ssr/astro.js +4 -4
- package/dist/ssr/index.d.ts +44 -4
- package/dist/ssr/index.js +4 -4
- package/dist/ssr/next.d.ts +1 -1
- package/dist/ssr/next.js +6 -6
- package/dist/ssr/next.js.map +1 -1
- package/dist/static/index.d.ts +91 -5
- package/dist/static/index.js +49 -3
- package/dist/static/index.js.map +1 -0
- package/dist/zero/babel.d.ts +1 -1
- package/dist/zero/babel.js +10 -6
- package/dist/zero/babel.js.map +1 -1
- package/dist/zero/index.d.ts +67 -3
- package/dist/zero/index.js +1 -2
- package/package.json +3 -3
- package/dist/_virtual/_rolldown/runtime.js +0 -7
- package/dist/chunks/cacheKey.d.ts +0 -1
- package/dist/chunks/cacheKey.js +0 -77
- package/dist/chunks/cacheKey.js.map +0 -1
- package/dist/chunks/definitions.d.ts +0 -37
- package/dist/chunks/definitions.js +0 -258
- package/dist/chunks/definitions.js.map +0 -1
- package/dist/chunks/index.d.ts +0 -1
- package/dist/chunks/renderChunk.d.ts +0 -1
- package/dist/chunks/renderChunk.js +0 -59
- package/dist/chunks/renderChunk.js.map +0 -1
- package/dist/compute-styles.d.ts +0 -31
- package/dist/compute-styles.js +0 -322
- package/dist/compute-styles.js.map +0 -1
- package/dist/config.d.ts +0 -407
- package/dist/config.js +0 -591
- package/dist/config.js.map +0 -1
- package/dist/counter-style/index.js +0 -51
- package/dist/counter-style/index.js.map +0 -1
- package/dist/debug.d.ts +0 -89
- package/dist/debug.js +0 -453
- package/dist/debug.js.map +0 -1
- package/dist/font-face/index.js +0 -63
- package/dist/font-face/index.js.map +0 -1
- package/dist/hooks/index.d.ts +0 -7
- package/dist/hooks/useCounterStyle.d.ts +0 -36
- package/dist/hooks/useCounterStyle.js +0 -65
- package/dist/hooks/useCounterStyle.js.map +0 -1
- package/dist/hooks/useFontFace.d.ts +0 -45
- package/dist/hooks/useFontFace.js +0 -66
- package/dist/hooks/useFontFace.js.map +0 -1
- package/dist/hooks/useGlobalStyles.d.ts +0 -46
- package/dist/hooks/useGlobalStyles.js +0 -88
- package/dist/hooks/useGlobalStyles.js.map +0 -1
- package/dist/hooks/useKeyframes.d.ts +0 -58
- package/dist/hooks/useKeyframes.js +0 -55
- package/dist/hooks/useKeyframes.js.map +0 -1
- package/dist/hooks/useProperty.d.ts +0 -81
- package/dist/hooks/useProperty.js +0 -96
- package/dist/hooks/useProperty.js.map +0 -1
- package/dist/hooks/useRawCSS.d.ts +0 -22
- package/dist/hooks/useRawCSS.js +0 -103
- package/dist/hooks/useRawCSS.js.map +0 -1
- package/dist/hooks/useStyles.d.ts +0 -40
- package/dist/hooks/useStyles.js +0 -31
- package/dist/hooks/useStyles.js.map +0 -1
- package/dist/injector/index.d.ts +0 -182
- package/dist/injector/index.js +0 -185
- package/dist/injector/index.js.map +0 -1
- package/dist/injector/injector.d.ts +0 -198
- package/dist/injector/injector.js +0 -651
- package/dist/injector/injector.js.map +0 -1
- package/dist/injector/sheet-manager.d.ts +0 -132
- package/dist/injector/sheet-manager.js +0 -699
- package/dist/injector/sheet-manager.js.map +0 -1
- package/dist/injector/types.d.ts +0 -235
- package/dist/keyframes/index.js +0 -206
- package/dist/keyframes/index.js.map +0 -1
- package/dist/parser/classify.js +0 -319
- package/dist/parser/classify.js.map +0 -1
- package/dist/parser/const.js +0 -60
- package/dist/parser/const.js.map +0 -1
- package/dist/parser/lru.js +0 -109
- package/dist/parser/lru.js.map +0 -1
- package/dist/parser/parser.d.ts +0 -25
- package/dist/parser/parser.js +0 -115
- package/dist/parser/parser.js.map +0 -1
- package/dist/parser/tokenizer.js +0 -69
- package/dist/parser/tokenizer.js.map +0 -1
- package/dist/parser/types.d.ts +0 -51
- package/dist/parser/types.js +0 -46
- package/dist/parser/types.js.map +0 -1
- package/dist/pipeline/conditions.d.ts +0 -134
- package/dist/pipeline/conditions.js +0 -406
- package/dist/pipeline/conditions.js.map +0 -1
- package/dist/pipeline/exclusive.js +0 -389
- package/dist/pipeline/exclusive.js.map +0 -1
- package/dist/pipeline/index.d.ts +0 -55
- package/dist/pipeline/index.js +0 -749
- package/dist/pipeline/index.js.map +0 -1
- package/dist/pipeline/materialize-contradictions.js +0 -125
- package/dist/pipeline/materialize-contradictions.js.map +0 -1
- package/dist/pipeline/materialize.js +0 -1038
- package/dist/pipeline/materialize.js.map +0 -1
- package/dist/pipeline/parseStateKey.d.ts +0 -15
- package/dist/pipeline/parseStateKey.js +0 -446
- package/dist/pipeline/parseStateKey.js.map +0 -1
- package/dist/pipeline/simplify.js +0 -725
- package/dist/pipeline/simplify.js.map +0 -1
- package/dist/pipeline/warnings.js +0 -18
- package/dist/pipeline/warnings.js.map +0 -1
- package/dist/plugins/index.d.ts +0 -2
- package/dist/plugins/okhsl-plugin.d.ts +0 -35
- package/dist/plugins/okhsl-plugin.js +0 -97
- package/dist/plugins/okhsl-plugin.js.map +0 -1
- package/dist/plugins/types.d.ts +0 -87
- package/dist/properties/index.js +0 -222
- package/dist/properties/index.js.map +0 -1
- package/dist/properties/property-type-resolver.d.ts +0 -24
- package/dist/properties/property-type-resolver.js +0 -90
- package/dist/properties/property-type-resolver.js.map +0 -1
- package/dist/rsc-cache.js +0 -79
- package/dist/rsc-cache.js.map +0 -1
- package/dist/ssr/async-storage.d.ts +0 -17
- package/dist/ssr/async-storage.js.map +0 -1
- package/dist/ssr/collect-auto-properties.js +0 -58
- package/dist/ssr/collect-auto-properties.js.map +0 -1
- package/dist/ssr/collector.js.map +0 -1
- package/dist/ssr/context.js.map +0 -1
- package/dist/ssr/format-global-rules.js.map +0 -1
- package/dist/ssr/format-keyframes.js +0 -69
- package/dist/ssr/format-keyframes.js.map +0 -1
- package/dist/ssr/format-property.js +0 -49
- package/dist/ssr/format-property.js.map +0 -1
- package/dist/ssr/format-rules.js +0 -73
- package/dist/ssr/format-rules.js.map +0 -1
- package/dist/ssr/hydrate.d.ts +0 -29
- package/dist/ssr/hydrate.js.map +0 -1
- package/dist/ssr/ssr-collector-ref.js +0 -29
- package/dist/ssr/ssr-collector-ref.js.map +0 -1
- package/dist/states/index.d.ts +0 -49
- package/dist/states/index.js +0 -170
- package/dist/states/index.js.map +0 -1
- package/dist/static/tastyStatic.d.ts +0 -46
- package/dist/static/tastyStatic.js +0 -30
- package/dist/static/tastyStatic.js.map +0 -1
- package/dist/static/types.d.ts +0 -49
- package/dist/static/types.js +0 -24
- package/dist/static/types.js.map +0 -1
- package/dist/styles/border.d.ts +0 -25
- package/dist/styles/border.js +0 -120
- package/dist/styles/border.js.map +0 -1
- package/dist/styles/color.d.ts +0 -14
- package/dist/styles/color.js +0 -26
- package/dist/styles/color.js.map +0 -1
- package/dist/styles/const.js +0 -17
- package/dist/styles/const.js.map +0 -1
- package/dist/styles/createStyle.js +0 -79
- package/dist/styles/createStyle.js.map +0 -1
- package/dist/styles/dimension.js +0 -109
- package/dist/styles/dimension.js.map +0 -1
- package/dist/styles/directional.js +0 -133
- package/dist/styles/directional.js.map +0 -1
- package/dist/styles/display.d.ts +0 -30
- package/dist/styles/display.js +0 -73
- package/dist/styles/display.js.map +0 -1
- package/dist/styles/fade.d.ts +0 -15
- package/dist/styles/fade.js +0 -62
- package/dist/styles/fade.js.map +0 -1
- package/dist/styles/fill.d.ts +0 -42
- package/dist/styles/fill.js +0 -51
- package/dist/styles/fill.js.map +0 -1
- package/dist/styles/flow.d.ts +0 -16
- package/dist/styles/flow.js +0 -12
- package/dist/styles/flow.js.map +0 -1
- package/dist/styles/gap.d.ts +0 -31
- package/dist/styles/gap.js +0 -38
- package/dist/styles/gap.js.map +0 -1
- package/dist/styles/height.d.ts +0 -17
- package/dist/styles/height.js +0 -19
- package/dist/styles/height.js.map +0 -1
- package/dist/styles/index.d.ts +0 -1
- package/dist/styles/index.js +0 -8
- package/dist/styles/index.js.map +0 -1
- package/dist/styles/inset.d.ts +0 -24
- package/dist/styles/inset.js +0 -34
- package/dist/styles/inset.js.map +0 -1
- package/dist/styles/list.d.ts +0 -16
- package/dist/styles/list.js +0 -100
- package/dist/styles/list.js.map +0 -1
- package/dist/styles/margin.d.ts +0 -24
- package/dist/styles/margin.js +0 -32
- package/dist/styles/margin.js.map +0 -1
- package/dist/styles/outline.d.ts +0 -29
- package/dist/styles/outline.js +0 -55
- package/dist/styles/outline.js.map +0 -1
- package/dist/styles/padding.d.ts +0 -24
- package/dist/styles/padding.js +0 -32
- package/dist/styles/padding.js.map +0 -1
- package/dist/styles/placement.d.ts +0 -37
- package/dist/styles/placement.js +0 -74
- package/dist/styles/placement.js.map +0 -1
- package/dist/styles/predefined.d.ts +0 -71
- package/dist/styles/predefined.js +0 -237
- package/dist/styles/predefined.js.map +0 -1
- package/dist/styles/preset.d.ts +0 -52
- package/dist/styles/preset.js +0 -127
- package/dist/styles/preset.js.map +0 -1
- package/dist/styles/radius.d.ts +0 -12
- package/dist/styles/radius.js +0 -83
- package/dist/styles/radius.js.map +0 -1
- package/dist/styles/scrollMargin.d.ts +0 -24
- package/dist/styles/scrollMargin.js +0 -32
- package/dist/styles/scrollMargin.js.map +0 -1
- package/dist/styles/scrollbar.d.ts +0 -25
- package/dist/styles/scrollbar.js +0 -51
- package/dist/styles/scrollbar.js.map +0 -1
- package/dist/styles/shadow.d.ts +0 -14
- package/dist/styles/shadow.js +0 -25
- package/dist/styles/shadow.js.map +0 -1
- package/dist/styles/shared.js +0 -17
- package/dist/styles/shared.js.map +0 -1
- package/dist/styles/transition.d.ts +0 -14
- package/dist/styles/transition.js +0 -159
- package/dist/styles/transition.js.map +0 -1
- package/dist/styles/width.d.ts +0 -17
- package/dist/styles/width.js +0 -19
- package/dist/styles/width.js.map +0 -1
- package/dist/tasty.d.ts +0 -134
- package/dist/tasty.js +0 -248
- package/dist/tasty.js.map +0 -1
- package/dist/types.d.ts +0 -184
- package/dist/utils/cache-wrapper.js +0 -21
- package/dist/utils/cache-wrapper.js.map +0 -1
- package/dist/utils/case-converter.js +0 -8
- package/dist/utils/case-converter.js.map +0 -1
- package/dist/utils/color-math.d.ts +0 -46
- package/dist/utils/color-math.js +0 -749
- package/dist/utils/color-math.js.map +0 -1
- package/dist/utils/color-space.d.ts +0 -5
- package/dist/utils/color-space.js +0 -228
- package/dist/utils/color-space.js.map +0 -1
- package/dist/utils/colors.d.ts +0 -5
- package/dist/utils/colors.js +0 -10
- package/dist/utils/colors.js.map +0 -1
- package/dist/utils/css-types.d.ts +0 -7
- package/dist/utils/deps-equal.js +0 -15
- package/dist/utils/deps-equal.js.map +0 -1
- package/dist/utils/dotize.d.ts +0 -26
- package/dist/utils/dotize.js +0 -122
- package/dist/utils/dotize.js.map +0 -1
- package/dist/utils/filter-base-props.d.ts +0 -15
- package/dist/utils/filter-base-props.js +0 -45
- package/dist/utils/filter-base-props.js.map +0 -1
- package/dist/utils/get-display-name.d.ts +0 -7
- package/dist/utils/get-display-name.js +0 -10
- package/dist/utils/get-display-name.js.map +0 -1
- package/dist/utils/has-keys.js +0 -13
- package/dist/utils/has-keys.js.map +0 -1
- package/dist/utils/hash.js +0 -14
- package/dist/utils/hash.js.map +0 -1
- package/dist/utils/is-dev-env.js +0 -19
- package/dist/utils/is-dev-env.js.map +0 -1
- package/dist/utils/is-valid-element-type.js +0 -15
- package/dist/utils/is-valid-element-type.js.map +0 -1
- package/dist/utils/merge-styles.js.map +0 -1
- package/dist/utils/mod-attrs.d.ts +0 -6
- package/dist/utils/mod-attrs.js +0 -20
- package/dist/utils/mod-attrs.js.map +0 -1
- package/dist/utils/process-tokens.d.ts +0 -17
- package/dist/utils/process-tokens.js +0 -83
- package/dist/utils/process-tokens.js.map +0 -1
- package/dist/utils/resolve-recipes.d.ts +0 -17
- package/dist/utils/resolve-recipes.js.map +0 -1
- package/dist/utils/selector-transform.js +0 -32
- package/dist/utils/selector-transform.js.map +0 -1
- package/dist/utils/string.js +0 -8
- package/dist/utils/string.js.map +0 -1
- package/dist/utils/styles.d.ts +0 -99
- package/dist/utils/styles.js +0 -220
- package/dist/utils/styles.js.map +0 -1
- package/dist/utils/typography.d.ts +0 -58
- package/dist/utils/typography.js +0 -51
- package/dist/utils/typography.js.map +0 -1
- package/dist/utils/warnings.d.ts +0 -16
- package/dist/utils/warnings.js +0 -16
- package/dist/utils/warnings.js.map +0 -1
- package/dist/zero/css-writer.d.ts +0 -45
- package/dist/zero/css-writer.js +0 -73
- package/dist/zero/css-writer.js.map +0 -1
- package/dist/zero/extractor.d.ts +0 -24
- package/dist/zero/extractor.js.map +0 -1
|
@@ -1,389 +0,0 @@
|
|
|
1
|
-
import { and, isCompoundCondition, not, or, trueCondition } from "./conditions.js";
|
|
2
|
-
import { simplifyCondition } from "./simplify.js";
|
|
3
|
-
//#region src/pipeline/exclusive.ts
|
|
4
|
-
/**
|
|
5
|
-
* Build exclusive conditions for a list of parsed style entries.
|
|
6
|
-
*
|
|
7
|
-
* The entries should be ordered by priority (highest priority first).
|
|
8
|
-
*
|
|
9
|
-
* For each entry, we compute:
|
|
10
|
-
* exclusiveCondition = condition & !prior[0] & !prior[1] & ...
|
|
11
|
-
*
|
|
12
|
-
* This ensures exactly one condition matches at any time.
|
|
13
|
-
*
|
|
14
|
-
* Example:
|
|
15
|
-
* Input (ordered highest to lowest priority):
|
|
16
|
-
* A: value1 (priority 2)
|
|
17
|
-
* B: value2 (priority 1)
|
|
18
|
-
* C: value3 (priority 0)
|
|
19
|
-
*
|
|
20
|
-
* Output:
|
|
21
|
-
* A: A
|
|
22
|
-
* B: B & !A
|
|
23
|
-
* C: C & !A & !B
|
|
24
|
-
*
|
|
25
|
-
* @param entries Parsed style entries ordered by priority (highest first)
|
|
26
|
-
* @returns Entries with exclusive conditions, filtered to remove impossible ones
|
|
27
|
-
*/
|
|
28
|
-
function buildExclusiveConditions(entries) {
|
|
29
|
-
const result = [];
|
|
30
|
-
const priorConditions = [];
|
|
31
|
-
for (const entry of entries) {
|
|
32
|
-
let exclusive = entry.condition;
|
|
33
|
-
for (const prior of priorConditions) if (prior.kind !== "true") exclusive = and(exclusive, not(prior));
|
|
34
|
-
const simplified = simplifyCondition(exclusive);
|
|
35
|
-
if (simplified.kind === "false") continue;
|
|
36
|
-
result.push({
|
|
37
|
-
...entry,
|
|
38
|
-
exclusiveCondition: simplified
|
|
39
|
-
});
|
|
40
|
-
if (entry.condition.kind !== "true") priorConditions.push(entry.condition);
|
|
41
|
-
}
|
|
42
|
-
return result;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Parse style entries from a value mapping object.
|
|
46
|
-
*
|
|
47
|
-
* @param styleKey The style key (e.g., 'padding')
|
|
48
|
-
* @param valueMap The value mapping { '': '2x', 'compact': '1x', '@media(w < 768px)': '0.5x' }
|
|
49
|
-
* @param parseCondition Function to parse state keys into conditions
|
|
50
|
-
* @returns Parsed entries ordered by priority (highest first)
|
|
51
|
-
*/
|
|
52
|
-
function parseStyleEntries(styleKey, valueMap, parseCondition) {
|
|
53
|
-
const entries = [];
|
|
54
|
-
Object.keys(valueMap).forEach((stateKey, index) => {
|
|
55
|
-
const value = valueMap[stateKey];
|
|
56
|
-
const condition = stateKey === "" ? trueCondition() : parseCondition(stateKey);
|
|
57
|
-
entries.push({
|
|
58
|
-
styleKey,
|
|
59
|
-
stateKey,
|
|
60
|
-
value,
|
|
61
|
-
condition,
|
|
62
|
-
priority: index
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
entries.reverse();
|
|
66
|
-
return entries;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Merge parsed entries that share the same value.
|
|
70
|
-
*
|
|
71
|
-
* When multiple **non-default** state keys map to the same value, their
|
|
72
|
-
* conditions can be combined with OR and treated as a single entry.
|
|
73
|
-
* This must happen **before** exclusive expansion and OR branch splitting
|
|
74
|
-
* to avoid combinatorial explosion and duplicate CSS output.
|
|
75
|
-
*
|
|
76
|
-
* Default (TRUE) entries are **never** merged with non-default entries.
|
|
77
|
-
* Merging `TRUE | X` collapses to `TRUE`, destroying the non-default
|
|
78
|
-
* condition's participation in exclusive building. That causes
|
|
79
|
-
* intermediate-priority states to lose their `:not(X)` negation,
|
|
80
|
-
* breaking mutual exclusivity when X and an intermediate state are
|
|
81
|
-
* both active. Stage 6 `mergeByValue` handles combining rules with
|
|
82
|
-
* identical CSS output after exclusive conditions are correctly built.
|
|
83
|
-
*
|
|
84
|
-
* Example: `{ '@dark': 'red', '@dark & @hc': 'red' }` merges into a
|
|
85
|
-
* single entry with condition `@dark | (@dark & @hc)` = `@dark`.
|
|
86
|
-
*
|
|
87
|
-
* Entries are ordered highest-priority-first. The merged entry keeps the
|
|
88
|
-
* highest priority of the group.
|
|
89
|
-
*/
|
|
90
|
-
function mergeEntriesByValue(entries) {
|
|
91
|
-
if (entries.length <= 1) return entries;
|
|
92
|
-
const groups = /* @__PURE__ */ new Map();
|
|
93
|
-
for (const entry of entries) {
|
|
94
|
-
const valueKey = serializeValue(entry.value);
|
|
95
|
-
const group = groups.get(valueKey);
|
|
96
|
-
if (group) {
|
|
97
|
-
group.entries.push(entry);
|
|
98
|
-
group.maxPriority = Math.max(group.maxPriority, entry.priority);
|
|
99
|
-
} else groups.set(valueKey, {
|
|
100
|
-
entries: [entry],
|
|
101
|
-
maxPriority: entry.priority
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
if (groups.size === entries.length) return entries;
|
|
105
|
-
const merged = [];
|
|
106
|
-
for (const [, group] of groups) {
|
|
107
|
-
if (group.entries.length === 1) {
|
|
108
|
-
merged.push(group.entries[0]);
|
|
109
|
-
continue;
|
|
110
|
-
}
|
|
111
|
-
const defaultEntries = group.entries.filter((e) => e.condition.kind === "true");
|
|
112
|
-
const nonDefaultEntries = group.entries.filter((e) => e.condition.kind !== "true");
|
|
113
|
-
for (const entry of defaultEntries) merged.push(entry);
|
|
114
|
-
if (nonDefaultEntries.length === 1) merged.push(nonDefaultEntries[0]);
|
|
115
|
-
else if (nonDefaultEntries.length >= 2) {
|
|
116
|
-
const combinedCondition = simplifyCondition(or(...nonDefaultEntries.map((e) => e.condition)));
|
|
117
|
-
const combinedStateKey = nonDefaultEntries.map((e) => e.stateKey).join(" | ");
|
|
118
|
-
merged.push({
|
|
119
|
-
styleKey: nonDefaultEntries[0].styleKey,
|
|
120
|
-
stateKey: combinedStateKey,
|
|
121
|
-
value: nonDefaultEntries[0].value,
|
|
122
|
-
condition: combinedCondition,
|
|
123
|
-
priority: group.maxPriority
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
merged.sort((a, b) => b.priority - a.priority);
|
|
128
|
-
return merged;
|
|
129
|
-
}
|
|
130
|
-
function serializeValue(value) {
|
|
131
|
-
if (value === null || value === void 0) return "null";
|
|
132
|
-
if (typeof value === "string" || typeof value === "number") return String(value);
|
|
133
|
-
return JSON.stringify(value);
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Eliminate redundant state dimensions from a value map.
|
|
137
|
-
*
|
|
138
|
-
* When a value map contains compound AND state keys (e.g. `@dark & @hc`),
|
|
139
|
-
* checks whether any state atom is a "don't-care" variable — i.e. the
|
|
140
|
-
* value is the same whether that atom is present or absent. Redundant
|
|
141
|
-
* atoms are removed from all keys and duplicate entries are collapsed.
|
|
142
|
-
*
|
|
143
|
-
* This runs **before** condition parsing so that downstream stages
|
|
144
|
-
* (`mergeEntriesByValue`, `buildExclusiveConditions`, materialization)
|
|
145
|
-
* never see the irrelevant dimension, producing simpler, smaller CSS.
|
|
146
|
-
*
|
|
147
|
-
* Only pure top-level AND combinations are eligible. Keys that contain
|
|
148
|
-
* `|`, `^`, or `,` at the top level are treated as opaque single atoms.
|
|
149
|
-
*
|
|
150
|
-
* @example
|
|
151
|
-
* { '': A, '@dark': B, '@hc': A, '@dark & @hc': B }
|
|
152
|
-
* // @hc is redundant → { '': A, '@dark': B }
|
|
153
|
-
*/
|
|
154
|
-
function extractCompoundStates(valueMap) {
|
|
155
|
-
const keys = Object.keys(valueMap);
|
|
156
|
-
if (keys.length < 3 || !keys.some((k) => k.includes("&"))) return valueMap;
|
|
157
|
-
const entries = keys.map((key) => {
|
|
158
|
-
return {
|
|
159
|
-
atoms: splitTopLevelAnd(key) ?? [key],
|
|
160
|
-
value: valueMap[key]
|
|
161
|
-
};
|
|
162
|
-
});
|
|
163
|
-
const allAtoms = /* @__PURE__ */ new Set();
|
|
164
|
-
for (const e of entries) for (const a of e.atoms) allAtoms.add(a);
|
|
165
|
-
const redundant = /* @__PURE__ */ new Set();
|
|
166
|
-
for (const atom of allAtoms) if (isAtomRedundant(entries, atom)) redundant.add(atom);
|
|
167
|
-
if (redundant.size === 0) return valueMap;
|
|
168
|
-
const newMap = {};
|
|
169
|
-
for (const e of entries) {
|
|
170
|
-
const newKey = e.atoms.filter((a) => !redundant.has(a)).join(" & ");
|
|
171
|
-
if (!(newKey in newMap)) newMap[newKey] = e.value;
|
|
172
|
-
}
|
|
173
|
-
return newMap;
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Split a state key by top-level `&` operators.
|
|
177
|
-
*
|
|
178
|
-
* Returns `null` if the key contains `|`, `^`, or `,` at the top level
|
|
179
|
-
* (making it ineligible for atom-level extraction).
|
|
180
|
-
* Returns `[]` for the empty string (default key).
|
|
181
|
-
*/
|
|
182
|
-
function splitTopLevelAnd(key) {
|
|
183
|
-
if (key === "") return [];
|
|
184
|
-
const parts = [];
|
|
185
|
-
let depth = 0;
|
|
186
|
-
let current = "";
|
|
187
|
-
for (const ch of key) {
|
|
188
|
-
if (ch === "(" || ch === "[") depth++;
|
|
189
|
-
else if (ch === ")" || ch === "]") depth--;
|
|
190
|
-
if (depth === 0) {
|
|
191
|
-
if (ch === "&") {
|
|
192
|
-
const trimmed = current.trim();
|
|
193
|
-
if (trimmed) parts.push(trimmed);
|
|
194
|
-
current = "";
|
|
195
|
-
continue;
|
|
196
|
-
}
|
|
197
|
-
if (ch === "|" || ch === "^" || ch === ",") return null;
|
|
198
|
-
}
|
|
199
|
-
current += ch;
|
|
200
|
-
}
|
|
201
|
-
const trimmed = current.trim();
|
|
202
|
-
if (trimmed) parts.push(trimmed);
|
|
203
|
-
return parts;
|
|
204
|
-
}
|
|
205
|
-
/**
|
|
206
|
-
* An atom is redundant when every entry that contains it has a matching
|
|
207
|
-
* partner (same remaining atoms, atom absent) with the same value.
|
|
208
|
-
*/
|
|
209
|
-
function isAtomRedundant(entries, atom) {
|
|
210
|
-
const withAtom = entries.filter((e) => e.atoms.includes(atom));
|
|
211
|
-
if (withAtom.length === 0) return false;
|
|
212
|
-
for (const wa of withAtom) {
|
|
213
|
-
const remaining = wa.atoms.filter((a) => a !== atom);
|
|
214
|
-
const pair = entries.find((e) => !e.atoms.includes(atom) && e.atoms.length === remaining.length && remaining.every((r) => e.atoms.includes(r)));
|
|
215
|
-
if (!pair) return false;
|
|
216
|
-
if (serializeValue(wa.value) !== serializeValue(pair.value)) return false;
|
|
217
|
-
}
|
|
218
|
-
return true;
|
|
219
|
-
}
|
|
220
|
-
/**
|
|
221
|
-
* Check if a value is a style value mapping (object with state keys)
|
|
222
|
-
*/
|
|
223
|
-
function isValueMapping(value) {
|
|
224
|
-
return value !== null && typeof value === "object" && !Array.isArray(value) && !(value instanceof Date);
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* Expand OR conditions in parsed entries into multiple exclusive entries.
|
|
228
|
-
*
|
|
229
|
-
* For an entry with condition `A | B | C`, this creates 3 entries:
|
|
230
|
-
* - condition: A
|
|
231
|
-
* - condition: B & !A
|
|
232
|
-
* - condition: C & !A & !B
|
|
233
|
-
*
|
|
234
|
-
* This ensures OR branches are mutually exclusive BEFORE the main
|
|
235
|
-
* exclusive condition building pass.
|
|
236
|
-
*
|
|
237
|
-
* @param entries Parsed entries (may contain OR conditions)
|
|
238
|
-
* @returns Expanded entries with OR branches made exclusive
|
|
239
|
-
*/
|
|
240
|
-
function expandOrConditions(entries) {
|
|
241
|
-
const result = [];
|
|
242
|
-
for (const entry of entries) {
|
|
243
|
-
const expanded = expandSingleEntry(entry);
|
|
244
|
-
result.push(...expanded);
|
|
245
|
-
}
|
|
246
|
-
return result;
|
|
247
|
-
}
|
|
248
|
-
/**
|
|
249
|
-
* Expand a single entry's OR condition into multiple exclusive entries.
|
|
250
|
-
*
|
|
251
|
-
* Note: branches are NOT sorted by at-rule context here (unlike the
|
|
252
|
-
* `expandExclusiveOrs` pass below). User-authored ORs in state keys aren't
|
|
253
|
-
* the product of De Morgan negation, so each branch is expected to render
|
|
254
|
-
* independently in its own scope and at-rule sort isn't load-bearing.
|
|
255
|
-
* The post-build pass needs the sort because it has to preserve at-rule
|
|
256
|
-
* wrapping across branches that came from negating a compound at-rule.
|
|
257
|
-
*/
|
|
258
|
-
function expandSingleEntry(entry) {
|
|
259
|
-
const orBranches = collectOrBranches(entry.condition);
|
|
260
|
-
if (orBranches.length <= 1) return [entry];
|
|
261
|
-
const result = [];
|
|
262
|
-
const priorBranches = [];
|
|
263
|
-
for (let i = 0; i < orBranches.length; i++) {
|
|
264
|
-
const branch = orBranches[i];
|
|
265
|
-
let exclusiveBranch = branch;
|
|
266
|
-
for (const prior of priorBranches) exclusiveBranch = and(exclusiveBranch, not(prior));
|
|
267
|
-
const simplified = simplifyCondition(exclusiveBranch);
|
|
268
|
-
if (simplified.kind === "false") {
|
|
269
|
-
priorBranches.push(branch);
|
|
270
|
-
continue;
|
|
271
|
-
}
|
|
272
|
-
result.push({
|
|
273
|
-
...entry,
|
|
274
|
-
stateKey: `${entry.stateKey}[${i}]`,
|
|
275
|
-
condition: simplified
|
|
276
|
-
});
|
|
277
|
-
priorBranches.push(branch);
|
|
278
|
-
}
|
|
279
|
-
return result;
|
|
280
|
-
}
|
|
281
|
-
/**
|
|
282
|
-
* Collect top-level OR branches from a condition.
|
|
283
|
-
*
|
|
284
|
-
* For `A | B | C`, returns [A, B, C]
|
|
285
|
-
* For `A & B`, returns [A & B] (single branch)
|
|
286
|
-
* For `A | (B & C)`, returns [A, B & C]
|
|
287
|
-
*/
|
|
288
|
-
function collectOrBranches(condition) {
|
|
289
|
-
if (condition.kind === "true" || condition.kind === "false") return [condition];
|
|
290
|
-
if (isCompoundCondition(condition) && condition.operator === "OR") {
|
|
291
|
-
const branches = [];
|
|
292
|
-
for (const child of condition.children) branches.push(...collectOrBranches(child));
|
|
293
|
-
return branches;
|
|
294
|
-
}
|
|
295
|
-
return [condition];
|
|
296
|
-
}
|
|
297
|
-
/**
|
|
298
|
-
* Expand OR conditions in exclusive entries AFTER buildExclusiveConditions.
|
|
299
|
-
*
|
|
300
|
-
* This handles ORs that arise from De Morgan expansion during negation:
|
|
301
|
-
* !(A & B) = !A | !B
|
|
302
|
-
*
|
|
303
|
-
* These ORs need to be made exclusive to avoid overlapping CSS rules:
|
|
304
|
-
* !A | !B → !A | (A & !B)
|
|
305
|
-
*
|
|
306
|
-
* This is logically equivalent but ensures each branch has proper context.
|
|
307
|
-
*
|
|
308
|
-
* Example:
|
|
309
|
-
* Input: { "": V1, "@supports(...) & :has()": V2 }
|
|
310
|
-
* V2's exclusive = @supports & :has
|
|
311
|
-
* V1's exclusive = !(@supports & :has) = !@supports | !:has
|
|
312
|
-
*
|
|
313
|
-
* Without this fix: V1 gets two rules:
|
|
314
|
-
* - @supports (not ...) → V1 ✓
|
|
315
|
-
* - :not(:has()) → V1 ✗ (missing @supports context!)
|
|
316
|
-
*
|
|
317
|
-
* With this fix: V1 gets two exclusive rules:
|
|
318
|
-
* - @supports (not ...) → V1 ✓
|
|
319
|
-
* - @supports (...) { :not(:has()) } → V1 ✓ (proper context!)
|
|
320
|
-
*/
|
|
321
|
-
function expandExclusiveOrs(entries) {
|
|
322
|
-
const result = [];
|
|
323
|
-
for (const entry of entries) {
|
|
324
|
-
const expanded = expandExclusiveConditionOrs(entry);
|
|
325
|
-
result.push(...expanded);
|
|
326
|
-
}
|
|
327
|
-
return result;
|
|
328
|
-
}
|
|
329
|
-
/**
|
|
330
|
-
* Check if a condition involves at-rules (media, container, supports, starting)
|
|
331
|
-
*/
|
|
332
|
-
function hasAtRuleContext(node) {
|
|
333
|
-
if (node.kind === "true" || node.kind === "false") return false;
|
|
334
|
-
if (node.kind === "state") return node.type === "media" || node.type === "container" || node.type === "supports" || node.type === "starting";
|
|
335
|
-
if (node.kind === "compound") return node.children.some(hasAtRuleContext);
|
|
336
|
-
return false;
|
|
337
|
-
}
|
|
338
|
-
/**
|
|
339
|
-
* Sort OR branches to prioritize at-rule conditions first.
|
|
340
|
-
*
|
|
341
|
-
* This is critical for correct CSS generation. For `!A | !B` where A is at-rule
|
|
342
|
-
* and B is modifier, we want:
|
|
343
|
-
* - Branch 0: !A (at-rule negation - covers "no @supports/media" case)
|
|
344
|
-
* - Branch 1: A & !B (modifier negation with at-rule context)
|
|
345
|
-
*
|
|
346
|
-
* If we process in wrong order (!B first), we'd get:
|
|
347
|
-
* - Branch 0: !B (modifier negation WITHOUT at-rule context - WRONG!)
|
|
348
|
-
* - Branch 1: B & !A (at-rule negation with modifier - incomplete coverage)
|
|
349
|
-
*/
|
|
350
|
-
function sortOrBranchesForExpansion(branches) {
|
|
351
|
-
return [...branches].sort((a, b) => {
|
|
352
|
-
const aHasAtRule = hasAtRuleContext(a);
|
|
353
|
-
const bHasAtRule = hasAtRuleContext(b);
|
|
354
|
-
if (aHasAtRule && !bHasAtRule) return -1;
|
|
355
|
-
if (!aHasAtRule && bHasAtRule) return 1;
|
|
356
|
-
return 0;
|
|
357
|
-
});
|
|
358
|
-
}
|
|
359
|
-
/**
|
|
360
|
-
* Expand ORs in a single entry's exclusive condition
|
|
361
|
-
*/
|
|
362
|
-
function expandExclusiveConditionOrs(entry) {
|
|
363
|
-
let orBranches = collectOrBranches(entry.exclusiveCondition);
|
|
364
|
-
if (orBranches.length <= 1) return [entry];
|
|
365
|
-
orBranches = sortOrBranchesForExpansion(orBranches);
|
|
366
|
-
const result = [];
|
|
367
|
-
const priorBranches = [];
|
|
368
|
-
for (let i = 0; i < orBranches.length; i++) {
|
|
369
|
-
const branch = orBranches[i];
|
|
370
|
-
let exclusiveBranch = branch;
|
|
371
|
-
for (const prior of priorBranches) exclusiveBranch = and(exclusiveBranch, not(prior));
|
|
372
|
-
const simplified = simplifyCondition(exclusiveBranch);
|
|
373
|
-
if (simplified.kind === "false") {
|
|
374
|
-
priorBranches.push(branch);
|
|
375
|
-
continue;
|
|
376
|
-
}
|
|
377
|
-
result.push({
|
|
378
|
-
...entry,
|
|
379
|
-
stateKey: `${entry.stateKey}[or:${i}]`,
|
|
380
|
-
exclusiveCondition: simplified
|
|
381
|
-
});
|
|
382
|
-
priorBranches.push(branch);
|
|
383
|
-
}
|
|
384
|
-
return result;
|
|
385
|
-
}
|
|
386
|
-
//#endregion
|
|
387
|
-
export { buildExclusiveConditions, expandExclusiveOrs, expandOrConditions, extractCompoundStates, isValueMapping, mergeEntriesByValue, parseStyleEntries };
|
|
388
|
-
|
|
389
|
-
//# sourceMappingURL=exclusive.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exclusive.js","names":[],"sources":["../../src/pipeline/exclusive.ts"],"sourcesContent":["/**\n * Exclusive Condition Builder\n *\n * Transforms parsed style entries into exclusive conditions.\n * Each entry's condition is ANDed with the negation of all higher-priority conditions,\n * ensuring exactly one condition matches at any given time.\n */\n\nimport type { StyleValue } from '../utils/styles';\n\nimport type { ConditionNode } from './conditions';\nimport { and, isCompoundCondition, not, or, trueCondition } from './conditions';\nimport { simplifyCondition } from './simplify';\n\n// ============================================================================\n// Types\n// ============================================================================\n\n/**\n * Parsed style entry with condition\n */\nexport interface ParsedStyleEntry {\n styleKey: string; // e.g., 'padding', 'fill'\n stateKey: string; // Original key: '', 'compact', '@media(w < 768px)'\n value: StyleValue; // The style value (before handler processing)\n condition: ConditionNode; // Parsed condition tree\n priority: number; // Order in original object (higher = higher priority)\n}\n\n/**\n * Style entry with exclusive condition\n */\nexport interface ExclusiveStyleEntry extends ParsedStyleEntry {\n exclusiveCondition: ConditionNode; // condition & !higherPriorityConditions\n}\n\n// ============================================================================\n// Main Function\n// ============================================================================\n\n/**\n * Build exclusive conditions for a list of parsed style entries.\n *\n * The entries should be ordered by priority (highest priority first).\n *\n * For each entry, we compute:\n * exclusiveCondition = condition & !prior[0] & !prior[1] & ...\n *\n * This ensures exactly one condition matches at any time.\n *\n * Example:\n * Input (ordered highest to lowest priority):\n * A: value1 (priority 2)\n * B: value2 (priority 1)\n * C: value3 (priority 0)\n *\n * Output:\n * A: A\n * B: B & !A\n * C: C & !A & !B\n *\n * @param entries Parsed style entries ordered by priority (highest first)\n * @returns Entries with exclusive conditions, filtered to remove impossible ones\n */\nexport function buildExclusiveConditions(\n entries: ParsedStyleEntry[],\n): ExclusiveStyleEntry[] {\n const result: ExclusiveStyleEntry[] = [];\n const priorConditions: ConditionNode[] = [];\n\n for (const entry of entries) {\n // Build: condition & !prior[0] & !prior[1] & ...\n let exclusive: ConditionNode = entry.condition;\n\n for (const prior of priorConditions) {\n // Skip negating \"always true\" (default state) - it would become \"always false\"\n if (prior.kind !== 'true') {\n exclusive = and(exclusive, not(prior));\n }\n }\n\n // Simplify the exclusive condition\n const simplified = simplifyCondition(exclusive);\n\n // Skip impossible conditions (simplified to FALSE)\n if (simplified.kind === 'false') {\n continue;\n }\n\n result.push({\n ...entry,\n exclusiveCondition: simplified,\n });\n\n // Add non-default conditions to prior list for subsequent entries\n if (entry.condition.kind !== 'true') {\n priorConditions.push(entry.condition);\n }\n }\n\n return result;\n}\n\n/**\n * Parse style entries from a value mapping object.\n *\n * @param styleKey The style key (e.g., 'padding')\n * @param valueMap The value mapping { '': '2x', 'compact': '1x', '@media(w < 768px)': '0.5x' }\n * @param parseCondition Function to parse state keys into conditions\n * @returns Parsed entries ordered by priority (highest first)\n */\nexport function parseStyleEntries(\n styleKey: string,\n valueMap: Record<string, StyleValue>,\n parseCondition: (stateKey: string) => ConditionNode,\n): ParsedStyleEntry[] {\n const entries: ParsedStyleEntry[] = [];\n const keys = Object.keys(valueMap);\n\n keys.forEach((stateKey, index) => {\n const value = valueMap[stateKey];\n const condition =\n stateKey === '' ? trueCondition() : parseCondition(stateKey);\n\n entries.push({\n styleKey,\n stateKey,\n value,\n condition,\n priority: index,\n });\n });\n\n // Reverse so highest priority (last in object) comes first for exclusive building\n // buildExclusiveConditions expects highest priority first\n entries.reverse();\n\n return entries;\n}\n\n/**\n * Merge parsed entries that share the same value.\n *\n * When multiple **non-default** state keys map to the same value, their\n * conditions can be combined with OR and treated as a single entry.\n * This must happen **before** exclusive expansion and OR branch splitting\n * to avoid combinatorial explosion and duplicate CSS output.\n *\n * Default (TRUE) entries are **never** merged with non-default entries.\n * Merging `TRUE | X` collapses to `TRUE`, destroying the non-default\n * condition's participation in exclusive building. That causes\n * intermediate-priority states to lose their `:not(X)` negation,\n * breaking mutual exclusivity when X and an intermediate state are\n * both active. Stage 6 `mergeByValue` handles combining rules with\n * identical CSS output after exclusive conditions are correctly built.\n *\n * Example: `{ '@dark': 'red', '@dark & @hc': 'red' }` merges into a\n * single entry with condition `@dark | (@dark & @hc)` = `@dark`.\n *\n * Entries are ordered highest-priority-first. The merged entry keeps the\n * highest priority of the group.\n */\nexport function mergeEntriesByValue(\n entries: ParsedStyleEntry[],\n): ParsedStyleEntry[] {\n if (entries.length <= 1) return entries;\n\n const groups = new Map<\n string,\n { entries: ParsedStyleEntry[]; maxPriority: number }\n >();\n\n for (const entry of entries) {\n const valueKey = serializeValue(entry.value);\n const group = groups.get(valueKey);\n if (group) {\n group.entries.push(entry);\n group.maxPriority = Math.max(group.maxPriority, entry.priority);\n } else {\n groups.set(valueKey, { entries: [entry], maxPriority: entry.priority });\n }\n }\n\n // If no merges possible, return as-is\n if (groups.size === entries.length) return entries;\n\n const merged: ParsedStyleEntry[] = [];\n for (const [, group] of groups) {\n if (group.entries.length === 1) {\n merged.push(group.entries[0]);\n continue;\n }\n\n // Separate default (TRUE) entries from non-default entries.\n // Default entries must stay separate so that non-default conditions\n // participate in exclusive building and block intermediate states.\n const defaultEntries = group.entries.filter(\n (e) => e.condition.kind === 'true',\n );\n const nonDefaultEntries = group.entries.filter(\n (e) => e.condition.kind !== 'true',\n );\n\n // Keep default entries as-is\n for (const entry of defaultEntries) {\n merged.push(entry);\n }\n\n // Merge only non-default entries\n if (nonDefaultEntries.length === 1) {\n merged.push(nonDefaultEntries[0]);\n } else if (nonDefaultEntries.length >= 2) {\n const combinedCondition = simplifyCondition(\n or(...nonDefaultEntries.map((e) => e.condition)),\n );\n\n const combinedStateKey = nonDefaultEntries\n .map((e) => e.stateKey)\n .join(' | ');\n\n merged.push({\n styleKey: nonDefaultEntries[0].styleKey,\n stateKey: combinedStateKey,\n value: nonDefaultEntries[0].value,\n condition: combinedCondition,\n priority: group.maxPriority,\n });\n }\n }\n\n // Re-sort by priority (highest first)\n merged.sort((a, b) => b.priority - a.priority);\n\n return merged;\n}\n\nfunction serializeValue(value: StyleValue): string {\n if (value === null || value === undefined) return 'null';\n if (typeof value === 'string' || typeof value === 'number') {\n return String(value);\n }\n return JSON.stringify(value);\n}\n\n// ============================================================================\n// Compound State Extraction\n// ============================================================================\n\n/**\n * Eliminate redundant state dimensions from a value map.\n *\n * When a value map contains compound AND state keys (e.g. `@dark & @hc`),\n * checks whether any state atom is a \"don't-care\" variable — i.e. the\n * value is the same whether that atom is present or absent. Redundant\n * atoms are removed from all keys and duplicate entries are collapsed.\n *\n * This runs **before** condition parsing so that downstream stages\n * (`mergeEntriesByValue`, `buildExclusiveConditions`, materialization)\n * never see the irrelevant dimension, producing simpler, smaller CSS.\n *\n * Only pure top-level AND combinations are eligible. Keys that contain\n * `|`, `^`, or `,` at the top level are treated as opaque single atoms.\n *\n * @example\n * { '': A, '@dark': B, '@hc': A, '@dark & @hc': B }\n * // @hc is redundant → { '': A, '@dark': B }\n */\nexport function extractCompoundStates(\n valueMap: Record<string, StyleValue>,\n): Record<string, StyleValue> {\n const keys = Object.keys(valueMap);\n\n if (keys.length < 3 || !keys.some((k) => k.includes('&'))) {\n return valueMap;\n }\n\n const entries = keys.map((key) => {\n const atoms = splitTopLevelAnd(key);\n return {\n // null means the key has non-AND operators; treat the whole key\n // as a single opaque atom so it never matches partial pairs.\n atoms: atoms ?? [key],\n value: valueMap[key],\n };\n });\n\n const allAtoms = new Set<string>();\n for (const e of entries) {\n for (const a of e.atoms) allAtoms.add(a);\n }\n\n const redundant = new Set<string>();\n for (const atom of allAtoms) {\n if (isAtomRedundant(entries, atom)) {\n redundant.add(atom);\n }\n }\n\n if (redundant.size === 0) return valueMap;\n\n const newMap: Record<string, StyleValue> = {};\n for (const e of entries) {\n const filtered = e.atoms.filter((a) => !redundant.has(a));\n const newKey = filtered.join(' & ');\n if (!(newKey in newMap)) {\n newMap[newKey] = e.value;\n }\n }\n\n return newMap;\n}\n\n/**\n * Split a state key by top-level `&` operators.\n *\n * Returns `null` if the key contains `|`, `^`, or `,` at the top level\n * (making it ineligible for atom-level extraction).\n * Returns `[]` for the empty string (default key).\n */\nfunction splitTopLevelAnd(key: string): string[] | null {\n if (key === '') return [];\n\n const parts: string[] = [];\n let depth = 0;\n let current = '';\n\n for (const ch of key) {\n if (ch === '(' || ch === '[') depth++;\n else if (ch === ')' || ch === ']') depth--;\n\n if (depth === 0) {\n if (ch === '&') {\n const trimmed = current.trim();\n if (trimmed) parts.push(trimmed);\n current = '';\n continue;\n }\n if (ch === '|' || ch === '^' || ch === ',') {\n return null;\n }\n }\n\n current += ch;\n }\n\n const trimmed = current.trim();\n if (trimmed) parts.push(trimmed);\n\n return parts;\n}\n\n/**\n * An atom is redundant when every entry that contains it has a matching\n * partner (same remaining atoms, atom absent) with the same value.\n */\nfunction isAtomRedundant(\n entries: { atoms: string[]; value: StyleValue }[],\n atom: string,\n): boolean {\n const withAtom = entries.filter((e) => e.atoms.includes(atom));\n if (withAtom.length === 0) return false;\n\n for (const wa of withAtom) {\n const remaining = wa.atoms.filter((a) => a !== atom);\n\n const pair = entries.find(\n (e) =>\n !e.atoms.includes(atom) &&\n e.atoms.length === remaining.length &&\n remaining.every((r) => e.atoms.includes(r)),\n );\n\n if (!pair) return false;\n if (serializeValue(wa.value) !== serializeValue(pair.value)) return false;\n }\n\n return true;\n}\n\n/**\n * Check if a value is a style value mapping (object with state keys)\n */\nexport function isValueMapping(\n value: StyleValue | Record<string, StyleValue>,\n): value is Record<string, StyleValue> {\n return (\n value !== null &&\n typeof value === 'object' &&\n !Array.isArray(value) &&\n !(value instanceof Date)\n );\n}\n\n// ============================================================================\n// OR Expansion\n// ============================================================================\n\n/**\n * Expand OR conditions in parsed entries into multiple exclusive entries.\n *\n * For an entry with condition `A | B | C`, this creates 3 entries:\n * - condition: A\n * - condition: B & !A\n * - condition: C & !A & !B\n *\n * This ensures OR branches are mutually exclusive BEFORE the main\n * exclusive condition building pass.\n *\n * @param entries Parsed entries (may contain OR conditions)\n * @returns Expanded entries with OR branches made exclusive\n */\nexport function expandOrConditions(\n entries: ParsedStyleEntry[],\n): ParsedStyleEntry[] {\n const result: ParsedStyleEntry[] = [];\n\n for (const entry of entries) {\n const expanded = expandSingleEntry(entry);\n result.push(...expanded);\n }\n\n return result;\n}\n\n/**\n * Expand a single entry's OR condition into multiple exclusive entries.\n *\n * Note: branches are NOT sorted by at-rule context here (unlike the\n * `expandExclusiveOrs` pass below). User-authored ORs in state keys aren't\n * the product of De Morgan negation, so each branch is expected to render\n * independently in its own scope and at-rule sort isn't load-bearing.\n * The post-build pass needs the sort because it has to preserve at-rule\n * wrapping across branches that came from negating a compound at-rule.\n */\nfunction expandSingleEntry(entry: ParsedStyleEntry): ParsedStyleEntry[] {\n const orBranches = collectOrBranches(entry.condition);\n\n // If no OR (single branch), return as-is\n if (orBranches.length <= 1) {\n return [entry];\n }\n\n // Make each OR branch exclusive from prior branches\n const result: ParsedStyleEntry[] = [];\n const priorBranches: ConditionNode[] = [];\n\n for (let i = 0; i < orBranches.length; i++) {\n const branch = orBranches[i];\n\n // Build: branch & !prior[0] & !prior[1] & ...\n let exclusiveBranch: ConditionNode = branch;\n for (const prior of priorBranches) {\n exclusiveBranch = and(exclusiveBranch, not(prior));\n }\n\n // Simplify to detect impossible combinations\n const simplified = simplifyCondition(exclusiveBranch);\n\n // Skip impossible branches\n if (simplified.kind === 'false') {\n priorBranches.push(branch);\n continue;\n }\n\n result.push({\n ...entry,\n stateKey: `${entry.stateKey}[${i}]`, // Mark as expanded branch\n condition: simplified,\n // Keep same priority - all branches from same entry have same priority\n });\n\n priorBranches.push(branch);\n }\n\n return result;\n}\n\n/**\n * Collect top-level OR branches from a condition.\n *\n * For `A | B | C`, returns [A, B, C]\n * For `A & B`, returns [A & B] (single branch)\n * For `A | (B & C)`, returns [A, B & C]\n */\nfunction collectOrBranches(condition: ConditionNode): ConditionNode[] {\n if (condition.kind === 'true' || condition.kind === 'false') {\n return [condition];\n }\n\n if (isCompoundCondition(condition) && condition.operator === 'OR') {\n // Flatten nested ORs\n const branches: ConditionNode[] = [];\n for (const child of condition.children) {\n branches.push(...collectOrBranches(child));\n }\n return branches;\n }\n\n // Not an OR - return as single branch\n return [condition];\n}\n\n// ============================================================================\n// Post-Build OR Expansion (for De Morgan ORs)\n// ============================================================================\n\n/**\n * Expand OR conditions in exclusive entries AFTER buildExclusiveConditions.\n *\n * This handles ORs that arise from De Morgan expansion during negation:\n * !(A & B) = !A | !B\n *\n * These ORs need to be made exclusive to avoid overlapping CSS rules:\n * !A | !B → !A | (A & !B)\n *\n * This is logically equivalent but ensures each branch has proper context.\n *\n * Example:\n * Input: { \"\": V1, \"@supports(...) & :has()\": V2 }\n * V2's exclusive = @supports & :has\n * V1's exclusive = !(@supports & :has) = !@supports | !:has\n *\n * Without this fix: V1 gets two rules:\n * - @supports (not ...) → V1 ✓\n * - :not(:has()) → V1 ✗ (missing @supports context!)\n *\n * With this fix: V1 gets two exclusive rules:\n * - @supports (not ...) → V1 ✓\n * - @supports (...) { :not(:has()) } → V1 ✓ (proper context!)\n */\nexport function expandExclusiveOrs(\n entries: ExclusiveStyleEntry[],\n): ExclusiveStyleEntry[] {\n const result: ExclusiveStyleEntry[] = [];\n\n for (const entry of entries) {\n const expanded = expandExclusiveConditionOrs(entry);\n result.push(...expanded);\n }\n\n return result;\n}\n\n/**\n * Check if a condition involves at-rules (media, container, supports, starting)\n */\nfunction hasAtRuleContext(node: ConditionNode): boolean {\n if (node.kind === 'true' || node.kind === 'false') {\n return false;\n }\n\n if (node.kind === 'state') {\n // These condition types generate at-rules\n return (\n node.type === 'media' ||\n node.type === 'container' ||\n node.type === 'supports' ||\n node.type === 'starting'\n );\n }\n\n if (node.kind === 'compound') {\n return node.children.some(hasAtRuleContext);\n }\n\n return false;\n}\n\n/**\n * Sort OR branches to prioritize at-rule conditions first.\n *\n * This is critical for correct CSS generation. For `!A | !B` where A is at-rule\n * and B is modifier, we want:\n * - Branch 0: !A (at-rule negation - covers \"no @supports/media\" case)\n * - Branch 1: A & !B (modifier negation with at-rule context)\n *\n * If we process in wrong order (!B first), we'd get:\n * - Branch 0: !B (modifier negation WITHOUT at-rule context - WRONG!)\n * - Branch 1: B & !A (at-rule negation with modifier - incomplete coverage)\n */\nfunction sortOrBranchesForExpansion(\n branches: ConditionNode[],\n): ConditionNode[] {\n return [...branches].sort((a, b) => {\n const aHasAtRule = hasAtRuleContext(a);\n const bHasAtRule = hasAtRuleContext(b);\n\n // At-rule conditions come first\n if (aHasAtRule && !bHasAtRule) return -1;\n if (!aHasAtRule && bHasAtRule) return 1;\n\n // Same type - keep original order (stable sort)\n return 0;\n });\n}\n\n/**\n * Expand ORs in a single entry's exclusive condition\n */\nfunction expandExclusiveConditionOrs(\n entry: ExclusiveStyleEntry,\n): ExclusiveStyleEntry[] {\n let orBranches = collectOrBranches(entry.exclusiveCondition);\n\n // If no OR (single branch), return as-is\n if (orBranches.length <= 1) {\n return [entry];\n }\n\n // Sort branches so at-rule conditions come first\n // This ensures proper context inheritance during expansion\n orBranches = sortOrBranchesForExpansion(orBranches);\n\n // Make each OR branch exclusive from prior branches\n const result: ExclusiveStyleEntry[] = [];\n const priorBranches: ConditionNode[] = [];\n\n for (let i = 0; i < orBranches.length; i++) {\n const branch = orBranches[i];\n\n // Build: branch & !prior[0] & !prior[1] & ...\n // This transforms: !A | !B → !A, !B & !!A = !A, (A & !B)\n let exclusiveBranch: ConditionNode = branch;\n for (const prior of priorBranches) {\n exclusiveBranch = and(exclusiveBranch, not(prior));\n }\n\n // Simplify to detect impossible combinations and clean up double negations\n const simplified = simplifyCondition(exclusiveBranch);\n\n // Skip impossible branches\n if (simplified.kind === 'false') {\n priorBranches.push(branch);\n continue;\n }\n\n result.push({\n ...entry,\n stateKey: `${entry.stateKey}[or:${i}]`, // Mark as expanded OR branch\n exclusiveCondition: simplified,\n });\n\n priorBranches.push(branch);\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAgEA,SAAgB,yBACd,SACuB;CACvB,MAAM,SAAgC,EAAE;CACxC,MAAM,kBAAmC,EAAE;AAE3C,MAAK,MAAM,SAAS,SAAS;EAE3B,IAAI,YAA2B,MAAM;AAErC,OAAK,MAAM,SAAS,gBAElB,KAAI,MAAM,SAAS,OACjB,aAAY,IAAI,WAAW,IAAI,MAAM,CAAC;EAK1C,MAAM,aAAa,kBAAkB,UAAU;AAG/C,MAAI,WAAW,SAAS,QACtB;AAGF,SAAO,KAAK;GACV,GAAG;GACH,oBAAoB;GACrB,CAAC;AAGF,MAAI,MAAM,UAAU,SAAS,OAC3B,iBAAgB,KAAK,MAAM,UAAU;;AAIzC,QAAO;;;;;;;;;;AAWT,SAAgB,kBACd,UACA,UACA,gBACoB;CACpB,MAAM,UAA8B,EAAE;AACzB,QAAO,KAAK,SAAS,CAE7B,SAAS,UAAU,UAAU;EAChC,MAAM,QAAQ,SAAS;EACvB,MAAM,YACJ,aAAa,KAAK,eAAe,GAAG,eAAe,SAAS;AAE9D,UAAQ,KAAK;GACX;GACA;GACA;GACA;GACA,UAAU;GACX,CAAC;GACF;AAIF,SAAQ,SAAS;AAEjB,QAAO;;;;;;;;;;;;;;;;;;;;;;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EAAE;EACtC,MAAM,aAAa,iBAAiB,EAAE;AAGtC,MAAI,cAAc,CAAC,WAAY,QAAO;AACtC,MAAI,CAAC,cAAc,WAAY,QAAO;AAGtC,SAAO;GACP;;;;;AAMJ,SAAS,4BACP,OACuB;CACvB,IAAI,aAAa,kBAAkB,MAAM,mBAAmB;AAG5D,KAAI,WAAW,UAAU,EACvB,QAAO,CAAC,MAAM;AAKhB,cAAa,2BAA2B,WAAW;CAGnD,MAAM,SAAgC,EAAE;CACxC,MAAM,gBAAiC,EAAE;AAEzC,MAAK,IAAI,IAAI,GAAG,IAAI,WAAW,QAAQ,KAAK;EAC1C,MAAM,SAAS,WAAW;EAI1B,IAAI,kBAAiC;AACrC,OAAK,MAAM,SAAS,cAClB,mBAAkB,IAAI,iBAAiB,IAAI,MAAM,CAAC;EAIpD,MAAM,aAAa,kBAAkB,gBAAgB;AAGrD,MAAI,WAAW,SAAS,SAAS;AAC/B,iBAAc,KAAK,OAAO;AAC1B;;AAGF,SAAO,KAAK;GACV,GAAG;GACH,UAAU,GAAG,MAAM,SAAS,MAAM,EAAE;GACpC,oBAAoB;GACrB,CAAC;AAEF,gBAAc,KAAK,OAAO;;AAG5B,QAAO"}
|
package/dist/pipeline/index.d.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { Styles } from "../styles/types.js";
|
|
2
|
-
import { ConditionNode } from "./conditions.js";
|
|
3
|
-
import { parseStateKey } from "./parseStateKey.js";
|
|
4
|
-
|
|
5
|
-
//#region src/pipeline/index.d.ts
|
|
6
|
-
/**
|
|
7
|
-
* Matches the old StyleResult interface for backward compatibility
|
|
8
|
-
*/
|
|
9
|
-
interface StyleResult {
|
|
10
|
-
selector: string;
|
|
11
|
-
declarations: string;
|
|
12
|
-
atRules?: string[];
|
|
13
|
-
needsClassName?: boolean;
|
|
14
|
-
rootPrefix?: string;
|
|
15
|
-
/** When true, declarations are wrapped in @starting-style { ... } inside the selector rule */
|
|
16
|
-
startingStyle?: boolean;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Matches the old RenderResult interface for backward compatibility
|
|
20
|
-
*/
|
|
21
|
-
interface RenderResult {
|
|
22
|
-
rules: StyleResult[];
|
|
23
|
-
className?: string;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Check if a key is a CSS selector
|
|
27
|
-
*/
|
|
28
|
-
declare function isSelector(key: string): boolean;
|
|
29
|
-
/**
|
|
30
|
-
* Options for renderStyles when using direct selector mode.
|
|
31
|
-
*/
|
|
32
|
-
interface RenderStylesOptions {
|
|
33
|
-
/**
|
|
34
|
-
* Whether to double the class selector for increased specificity.
|
|
35
|
-
* When true, `.myClass` becomes `.myClass.myClass` for higher specificity.
|
|
36
|
-
*
|
|
37
|
-
* @default false - User-provided selectors are not doubled.
|
|
38
|
-
*
|
|
39
|
-
* Note: This only applies when a classNameOrSelector is provided.
|
|
40
|
-
* When renderStyles returns RenderResult with needsClassName=true,
|
|
41
|
-
* the injector handles doubling automatically.
|
|
42
|
-
*/
|
|
43
|
-
doubleSelector?: boolean;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Render styles to CSS rules.
|
|
47
|
-
*
|
|
48
|
-
* When called without classNameOrSelector, returns RenderResult with needsClassName=true.
|
|
49
|
-
* When called with a selector/className string, returns StyleResult[] for direct injection.
|
|
50
|
-
*/
|
|
51
|
-
declare function renderStyles(styles?: Styles, classNameOrSelector?: undefined, options?: undefined, pipelineCacheKey?: string): RenderResult;
|
|
52
|
-
declare function renderStyles(styles: Styles | undefined, classNameOrSelector: string, options?: RenderStylesOptions): StyleResult[];
|
|
53
|
-
//#endregion
|
|
54
|
-
export { RenderResult, StyleResult, isSelector, renderStyles };
|
|
55
|
-
//# sourceMappingURL=index.d.ts.map
|