@tenphi/tasty 0.1.0 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -2
- package/dist/_virtual/_rolldown/runtime.js +8 -0
- package/dist/chunks/renderChunk.js.map +1 -1
- package/dist/config.js.map +1 -1
- package/dist/debug.js.map +1 -1
- package/dist/hooks/useKeyframes.js.map +1 -1
- package/dist/hooks/useRawCSS.js.map +1 -1
- package/dist/injector/injector.js.map +1 -1
- package/dist/injector/sheet-manager.js.map +1 -1
- package/dist/parser/index.d.ts +3 -0
- package/dist/parser/index.js +4 -0
- package/dist/parser/parser.js.map +1 -1
- package/dist/parser/types.d.ts +6 -1
- package/dist/pipeline/conditions.js.map +1 -1
- package/dist/pipeline/exclusive.js.map +1 -1
- package/dist/pipeline/index.js.map +1 -1
- package/dist/pipeline/materialize.js.map +1 -1
- package/dist/pipeline/parseStateKey.js.map +1 -1
- package/dist/pipeline/simplify.js.map +1 -1
- package/dist/styles/dimension.js.map +1 -1
- package/dist/styles/predefined.js.map +1 -1
- package/dist/styles/radius.js.map +1 -1
- package/dist/styles/scrollbar.js.map +1 -1
- package/dist/styles/shadow.js.map +1 -1
- package/dist/tasty.d.ts +8 -8
- package/dist/tasty.js.map +1 -1
- package/dist/utils/resolve-recipes.js.map +1 -1
- package/dist/utils/styles.js.map +1 -1
- package/dist/zero/{babel.d.mts → babel.d.ts} +6 -6
- package/dist/zero/{babel.mjs → babel.js} +6 -6
- package/dist/zero/babel.js.map +1 -0
- package/dist/{css-writer.d.mts → zero/css-writer.d.ts} +1 -1
- package/dist/{css-writer.mjs → zero/css-writer.js} +1 -1
- package/dist/zero/css-writer.js.map +1 -0
- package/dist/{extractor.d.mts → zero/extractor.d.ts} +3 -2
- package/dist/{extractor.mjs → zero/extractor.js} +6 -6
- package/dist/zero/extractor.js.map +1 -0
- package/dist/zero/index.d.ts +3 -0
- package/dist/zero/{index.mjs → index.js} +2 -2
- package/dist/zero/{next.d.mts → next.d.ts} +1 -1
- package/dist/zero/{next.mjs → next.js} +2 -2
- package/dist/zero/next.js.map +1 -0
- package/package.json +22 -23
- package/dist/_virtual/_rolldown/runtime.mjs +0 -7
- package/dist/chunks/cacheKey.mjs +0 -70
- package/dist/chunks/cacheKey.mjs.map +0 -1
- package/dist/chunks/definitions.mjs +0 -260
- package/dist/chunks/definitions.mjs.map +0 -1
- package/dist/chunks/renderChunk.mjs +0 -61
- package/dist/chunks/renderChunk.mjs.map +0 -1
- package/dist/config.mjs +0 -231
- package/dist/config.mjs.map +0 -1
- package/dist/css-writer.mjs.map +0 -1
- package/dist/extractor.mjs.map +0 -1
- package/dist/injector/injector.mjs +0 -404
- package/dist/injector/injector.mjs.map +0 -1
- package/dist/injector/sheet-manager.mjs +0 -714
- package/dist/injector/sheet-manager.mjs.map +0 -1
- package/dist/injector/types.d.mts +0 -18
- package/dist/keyframes/index.mjs +0 -156
- package/dist/keyframes/index.mjs.map +0 -1
- package/dist/parser/classify.mjs +0 -319
- package/dist/parser/classify.mjs.map +0 -1
- package/dist/parser/const.mjs +0 -33
- package/dist/parser/const.mjs.map +0 -1
- package/dist/parser/lru.mjs +0 -109
- package/dist/parser/lru.mjs.map +0 -1
- package/dist/parser/parser.mjs +0 -116
- package/dist/parser/parser.mjs.map +0 -1
- package/dist/parser/tokenizer.mjs +0 -69
- package/dist/parser/tokenizer.mjs.map +0 -1
- package/dist/parser/types.d.mts +0 -37
- package/dist/parser/types.mjs +0 -46
- package/dist/parser/types.mjs.map +0 -1
- package/dist/pipeline/conditions.mjs +0 -377
- package/dist/pipeline/conditions.mjs.map +0 -1
- package/dist/pipeline/exclusive.mjs +0 -231
- package/dist/pipeline/exclusive.mjs.map +0 -1
- package/dist/pipeline/index.mjs +0 -635
- package/dist/pipeline/index.mjs.map +0 -1
- package/dist/pipeline/materialize.mjs +0 -821
- package/dist/pipeline/materialize.mjs.map +0 -1
- package/dist/pipeline/parseStateKey.mjs +0 -418
- package/dist/pipeline/parseStateKey.mjs.map +0 -1
- package/dist/pipeline/simplify.mjs +0 -557
- package/dist/pipeline/simplify.mjs.map +0 -1
- package/dist/plugins/okhsl-plugin.mjs +0 -345
- package/dist/plugins/okhsl-plugin.mjs.map +0 -1
- package/dist/plugins/types.d.mts +0 -49
- package/dist/properties/index.mjs +0 -141
- package/dist/properties/index.mjs.map +0 -1
- package/dist/states/index.mjs +0 -161
- package/dist/states/index.mjs.map +0 -1
- package/dist/styles/align.mjs +0 -14
- package/dist/styles/align.mjs.map +0 -1
- package/dist/styles/border.mjs +0 -114
- package/dist/styles/border.mjs.map +0 -1
- package/dist/styles/color.mjs +0 -23
- package/dist/styles/color.mjs.map +0 -1
- package/dist/styles/createStyle.mjs +0 -77
- package/dist/styles/createStyle.mjs.map +0 -1
- package/dist/styles/dimension.mjs +0 -97
- package/dist/styles/dimension.mjs.map +0 -1
- package/dist/styles/display.mjs +0 -67
- package/dist/styles/display.mjs.map +0 -1
- package/dist/styles/fade.mjs +0 -58
- package/dist/styles/fade.mjs.map +0 -1
- package/dist/styles/fill.mjs +0 -51
- package/dist/styles/fill.mjs.map +0 -1
- package/dist/styles/flow.mjs +0 -12
- package/dist/styles/flow.mjs.map +0 -1
- package/dist/styles/gap.mjs +0 -37
- package/dist/styles/gap.mjs.map +0 -1
- package/dist/styles/height.mjs +0 -20
- package/dist/styles/height.mjs.map +0 -1
- package/dist/styles/index.mjs +0 -9
- package/dist/styles/index.mjs.map +0 -1
- package/dist/styles/inset.mjs +0 -142
- package/dist/styles/inset.mjs.map +0 -1
- package/dist/styles/justify.mjs +0 -14
- package/dist/styles/justify.mjs.map +0 -1
- package/dist/styles/margin.mjs +0 -96
- package/dist/styles/margin.mjs.map +0 -1
- package/dist/styles/outline.mjs +0 -65
- package/dist/styles/outline.mjs.map +0 -1
- package/dist/styles/padding.mjs +0 -96
- package/dist/styles/padding.mjs.map +0 -1
- package/dist/styles/predefined.mjs +0 -232
- package/dist/styles/predefined.mjs.map +0 -1
- package/dist/styles/preset.mjs +0 -126
- package/dist/styles/preset.mjs.map +0 -1
- package/dist/styles/radius.mjs +0 -51
- package/dist/styles/radius.mjs.map +0 -1
- package/dist/styles/scrollbar.mjs +0 -105
- package/dist/styles/scrollbar.mjs.map +0 -1
- package/dist/styles/shadow.mjs +0 -24
- package/dist/styles/shadow.mjs.map +0 -1
- package/dist/styles/styledScrollbar.mjs +0 -38
- package/dist/styles/styledScrollbar.mjs.map +0 -1
- package/dist/styles/transition.mjs +0 -138
- package/dist/styles/transition.mjs.map +0 -1
- package/dist/styles/types.d.mts +0 -492
- package/dist/styles/width.mjs +0 -20
- package/dist/styles/width.mjs.map +0 -1
- package/dist/utils/cache-wrapper.mjs +0 -26
- package/dist/utils/cache-wrapper.mjs.map +0 -1
- package/dist/utils/case-converter.mjs +0 -8
- package/dist/utils/case-converter.mjs.map +0 -1
- package/dist/utils/hsl-to-rgb.mjs +0 -38
- package/dist/utils/hsl-to-rgb.mjs.map +0 -1
- package/dist/utils/is-dev-env.mjs +0 -19
- package/dist/utils/is-dev-env.mjs.map +0 -1
- package/dist/utils/merge-styles.mjs +0 -146
- package/dist/utils/merge-styles.mjs.map +0 -1
- package/dist/utils/okhsl-to-rgb.mjs +0 -296
- package/dist/utils/okhsl-to-rgb.mjs.map +0 -1
- package/dist/utils/process-tokens.mjs +0 -28
- package/dist/utils/process-tokens.mjs.map +0 -1
- package/dist/utils/resolve-recipes.mjs +0 -143
- package/dist/utils/resolve-recipes.mjs.map +0 -1
- package/dist/utils/string.mjs +0 -8
- package/dist/utils/string.mjs.map +0 -1
- package/dist/utils/styles.d.mts +0 -18
- package/dist/utils/styles.mjs +0 -346
- package/dist/utils/styles.mjs.map +0 -1
- package/dist/zero/babel.mjs.map +0 -1
- package/dist/zero/index.d.mts +0 -3
- package/dist/zero/next.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simplify.js","names":[],"sources":["../../src/pipeline/simplify.ts"],"sourcesContent":["/**\n * Condition Simplification Engine\n *\n * Simplifies condition trees by applying boolean algebra rules,\n * detecting contradictions, merging ranges, and deduplicating terms.\n *\n * This is critical for:\n * 1. Detecting invalid combinations (A & !A → FALSE)\n * 2. Reducing CSS output size\n * 3. Producing cleaner selectors\n */\n\nimport { Lru } from '../parser/lru';\n\nimport type {\n ConditionNode,\n ContainerCondition,\n MediaCondition,\n ModifierCondition,\n NumericBound} from './conditions';\nimport {\n falseCondition,\n getConditionUniqueId,\n trueCondition,\n} from './conditions';\n\n// ============================================================================\n// Caching\n// ============================================================================\n\nconst simplifyCache = new Lru<string, ConditionNode>(5000);\n\n// ============================================================================\n// Main Simplify Function\n// ============================================================================\n\n/**\n * Simplify a condition tree aggressively.\n *\n * This applies all possible simplification rules:\n * - Boolean algebra (identity, annihilator, idempotent, absorption)\n * - Contradiction detection (A & !A → FALSE)\n * - Tautology detection (A | !A → TRUE)\n * - Range intersection for numeric queries\n * - Attribute value conflict detection\n * - Deduplication and sorting\n */\nexport function simplifyCondition(node: ConditionNode): ConditionNode {\n // Check cache\n const key = getConditionUniqueId(node);\n const cached = simplifyCache.get(key);\n if (cached) {\n return cached;\n }\n\n const result = simplifyInner(node);\n\n // Cache result\n simplifyCache.set(key, result);\n\n return result;\n}\n\n/**\n * Clear the simplify cache (for testing)\n */\nexport function clearSimplifyCache(): void {\n simplifyCache.clear();\n}\n\n// ============================================================================\n// Inner Simplification\n// ============================================================================\n\nfunction simplifyInner(node: ConditionNode): ConditionNode {\n // Base cases\n if (node.kind === 'true' || node.kind === 'false') {\n return node;\n }\n\n // State conditions - return as-is (they're already leaf nodes)\n if (node.kind === 'state') {\n return node;\n }\n\n // Compound conditions - recursively simplify\n if (node.kind === 'compound') {\n // First, recursively simplify all children\n const simplifiedChildren = node.children.map((c) => simplifyInner(c));\n\n // Then apply compound-specific simplifications\n if (node.operator === 'AND') {\n return simplifyAnd(simplifiedChildren);\n } else {\n return simplifyOr(simplifiedChildren);\n }\n }\n\n return node;\n}\n\n// ============================================================================\n// AND Simplification\n// ============================================================================\n\nfunction simplifyAnd(children: ConditionNode[]): ConditionNode {\n let terms: ConditionNode[] = [];\n\n // Flatten nested ANDs and handle TRUE/FALSE\n for (const child of children) {\n if (child.kind === 'false') {\n // AND with FALSE → FALSE\n return falseCondition();\n }\n if (child.kind === 'true') {\n // AND with TRUE → skip (identity)\n continue;\n }\n if (child.kind === 'compound' && child.operator === 'AND') {\n // Flatten nested AND\n terms.push(...child.children);\n } else {\n terms.push(child);\n }\n }\n\n // Empty → TRUE\n if (terms.length === 0) {\n return trueCondition();\n }\n\n // Single term → return it\n if (terms.length === 1) {\n return terms[0];\n }\n\n // Check for contradictions\n if (hasContradiction(terms)) {\n return falseCondition();\n }\n\n // Check for range contradictions in media/container queries\n if (hasRangeContradiction(terms)) {\n return falseCondition();\n }\n\n // Check for attribute value conflicts\n if (hasAttributeConflict(terms)) {\n return falseCondition();\n }\n\n // Check for container style query conflicts\n if (hasContainerStyleConflict(terms)) {\n return falseCondition();\n }\n\n // Remove redundant negations implied by positive terms\n // e.g., style(--variant: danger) implies NOT style(--variant: success)\n // and style(--variant: danger) implies style(--variant) (existence)\n terms = removeImpliedNegations(terms);\n\n // Deduplicate (by uniqueId)\n terms = deduplicateTerms(terms);\n\n // Try to merge numeric ranges\n terms = mergeRanges(terms);\n\n // Sort for canonical form\n terms = sortTerms(terms);\n\n // Apply absorption: A & (A | B) → A\n terms = applyAbsorptionAnd(terms);\n\n if (terms.length === 0) {\n return trueCondition();\n }\n if (terms.length === 1) {\n return terms[0];\n }\n\n return {\n kind: 'compound',\n operator: 'AND',\n children: terms,\n };\n}\n\n// ============================================================================\n// OR Simplification\n// ============================================================================\n\nfunction simplifyOr(children: ConditionNode[]): ConditionNode {\n let terms: ConditionNode[] = [];\n\n // Flatten nested ORs and handle TRUE/FALSE\n for (const child of children) {\n if (child.kind === 'true') {\n // OR with TRUE → TRUE\n return trueCondition();\n }\n if (child.kind === 'false') {\n // OR with FALSE → skip (identity)\n continue;\n }\n if (child.kind === 'compound' && child.operator === 'OR') {\n // Flatten nested OR\n terms.push(...child.children);\n } else {\n terms.push(child);\n }\n }\n\n // Empty → FALSE\n if (terms.length === 0) {\n return falseCondition();\n }\n\n // Single term → return it\n if (terms.length === 1) {\n return terms[0];\n }\n\n // Check for tautologies (A | !A)\n if (hasTautology(terms)) {\n return trueCondition();\n }\n\n // Deduplicate\n terms = deduplicateTerms(terms);\n\n // Sort for canonical form\n terms = sortTerms(terms);\n\n // Apply absorption: A | (A & B) → A\n terms = applyAbsorptionOr(terms);\n\n if (terms.length === 0) {\n return falseCondition();\n }\n if (terms.length === 1) {\n return terms[0];\n }\n\n return {\n kind: 'compound',\n operator: 'OR',\n children: terms,\n };\n}\n\n// ============================================================================\n// Contradiction Detection\n// ============================================================================\n\n/**\n * Check if any term contradicts another (A & !A)\n */\nfunction hasContradiction(terms: ConditionNode[]): boolean {\n const uniqueIds = new Set<string>();\n\n for (const term of terms) {\n if (term.kind !== 'state') continue;\n\n const id = term.uniqueId;\n // Check if negation exists\n const negatedId = term.negated ? id.slice(1) : `!${id}`;\n\n if (uniqueIds.has(negatedId)) {\n return true;\n }\n uniqueIds.add(id);\n }\n\n return false;\n}\n\n/**\n * Check for tautologies (A | !A)\n */\nfunction hasTautology(terms: ConditionNode[]): boolean {\n const uniqueIds = new Set<string>();\n\n for (const term of terms) {\n if (term.kind !== 'state') continue;\n\n const id = term.uniqueId;\n const negatedId = term.negated ? id.slice(1) : `!${id}`;\n\n if (uniqueIds.has(negatedId)) {\n return true;\n }\n uniqueIds.add(id);\n }\n\n return false;\n}\n\n// ============================================================================\n// Range Contradiction Detection\n// ============================================================================\n\n/**\n * Effective bounds computed from conditions (including negated single-bound conditions)\n */\ninterface EffectiveBounds {\n lowerBound: number | null;\n lowerInclusive: boolean;\n upperBound: number | null;\n upperInclusive: boolean;\n}\n\n/**\n * Excluded range from a negated range condition\n */\ninterface ExcludedRange {\n lower: number;\n lowerInclusive: boolean;\n upper: number;\n upperInclusive: boolean;\n}\n\n/**\n * Check for range contradictions in media/container queries\n * e.g., @media(w < 400px) & @media(w > 800px) → FALSE\n *\n * Also handles negated conditions:\n * - Single-bound negations are inverted (not (w < 600px) → w >= 600px)\n * - Range negations create excluded ranges that are checked against positive bounds\n */\nfunction hasRangeContradiction(terms: ConditionNode[]): boolean {\n // Group by dimension, separating positive and negated conditions\n const mediaByDim = new Map<\n string,\n { positive: MediaCondition[]; negated: MediaCondition[] }\n >();\n const containerByDim = new Map<\n string,\n { positive: ContainerCondition[]; negated: ContainerCondition[] }\n >();\n\n for (const term of terms) {\n if (term.kind !== 'state') continue;\n\n if (term.type === 'media' && term.subtype === 'dimension') {\n const key = term.dimension || 'width';\n if (!mediaByDim.has(key)) {\n mediaByDim.set(key, { positive: [], negated: [] });\n }\n const group = mediaByDim.get(key)!;\n if (term.negated) {\n group.negated.push(term);\n } else {\n group.positive.push(term);\n }\n }\n\n if (term.type === 'container' && term.subtype === 'dimension') {\n const key = `${term.containerName || '_'}:${term.dimension || 'width'}`;\n if (!containerByDim.has(key)) {\n containerByDim.set(key, { positive: [], negated: [] });\n }\n const group = containerByDim.get(key)!;\n if (term.negated) {\n group.negated.push(term);\n } else {\n group.positive.push(term);\n }\n }\n }\n\n // Check each dimension group for impossible ranges\n for (const group of mediaByDim.values()) {\n if (rangesAreImpossibleWithNegations(group.positive, group.negated)) {\n return true;\n }\n }\n\n for (const group of containerByDim.values()) {\n if (rangesAreImpossibleWithNegations(group.positive, group.negated)) {\n return true;\n }\n }\n\n return false;\n}\n\n/**\n * Check if conditions are impossible, including negated conditions.\n *\n * For negated single-bound conditions:\n * not (w < 600px) → w >= 600px (inverted to lower bound)\n * not (w >= 800px) → w < 800px (inverted to upper bound)\n *\n * For negated range conditions:\n * not (400px <= w < 800px) → excludes [400, 800)\n * If the effective bounds fall entirely within an excluded range, it's impossible.\n */\nfunction rangesAreImpossibleWithNegations(\n positive: (MediaCondition | ContainerCondition)[],\n negated: (MediaCondition | ContainerCondition)[],\n): boolean {\n // Start with bounds from positive conditions\n const bounds = computeEffectiveBounds(positive);\n\n // Apply inverted bounds from single-bound negated conditions\n // and collect excluded ranges from range negated conditions\n const excludedRanges: ExcludedRange[] = [];\n\n for (const cond of negated) {\n const hasLower = cond.lowerBound?.valueNumeric != null;\n const hasUpper = cond.upperBound?.valueNumeric != null;\n\n if (hasLower && hasUpper) {\n // Range negation: not (lower <= w < upper) excludes [lower, upper)\n excludedRanges.push({\n lower: cond.lowerBound!.valueNumeric!,\n lowerInclusive: cond.lowerBound!.inclusive,\n upper: cond.upperBound!.valueNumeric!,\n upperInclusive: cond.upperBound!.inclusive,\n });\n } else if (hasUpper) {\n // not (w < upper) → w >= upper (becomes lower bound)\n // not (w <= upper) → w > upper (becomes lower bound, exclusive)\n const value = cond.upperBound!.valueNumeric!;\n const inclusive = !cond.upperBound!.inclusive; // flip inclusivity\n\n if (bounds.lowerBound === null || value > bounds.lowerBound) {\n bounds.lowerBound = value;\n bounds.lowerInclusive = inclusive;\n } else if (value === bounds.lowerBound && !inclusive) {\n bounds.lowerInclusive = false;\n }\n } else if (hasLower) {\n // not (w >= lower) → w < lower (becomes upper bound)\n // not (w > lower) → w <= lower (becomes upper bound, inclusive)\n const value = cond.lowerBound!.valueNumeric!;\n const inclusive = !cond.lowerBound!.inclusive; // flip inclusivity\n\n if (bounds.upperBound === null || value < bounds.upperBound) {\n bounds.upperBound = value;\n bounds.upperInclusive = inclusive;\n } else if (value === bounds.upperBound && !inclusive) {\n bounds.upperInclusive = false;\n }\n }\n }\n\n // Check if effective bounds are impossible on their own\n if (bounds.lowerBound !== null && bounds.upperBound !== null) {\n if (bounds.lowerBound > bounds.upperBound) {\n return true;\n }\n if (\n bounds.lowerBound === bounds.upperBound &&\n (!bounds.lowerInclusive || !bounds.upperInclusive)\n ) {\n return true;\n }\n }\n\n // Check if effective bounds fall entirely within any excluded range\n if (\n bounds.lowerBound !== null &&\n bounds.upperBound !== null &&\n excludedRanges.length > 0\n ) {\n for (const excluded of excludedRanges) {\n if (boundsWithinExcludedRange(bounds, excluded)) {\n return true;\n }\n }\n }\n\n return false;\n}\n\n/**\n * Compute effective bounds from positive (non-negated) conditions\n */\nfunction computeEffectiveBounds(\n conditions: (MediaCondition | ContainerCondition)[],\n): EffectiveBounds {\n let lowerBound: number | null = null;\n let lowerInclusive = false;\n let upperBound: number | null = null;\n let upperInclusive = false;\n\n for (const cond of conditions) {\n if (cond.lowerBound?.valueNumeric != null) {\n const value = cond.lowerBound.valueNumeric;\n const inclusive = cond.lowerBound.inclusive;\n\n if (lowerBound === null || value > lowerBound) {\n lowerBound = value;\n lowerInclusive = inclusive;\n } else if (value === lowerBound && !inclusive) {\n lowerInclusive = false;\n }\n }\n\n if (cond.upperBound?.valueNumeric != null) {\n const value = cond.upperBound.valueNumeric;\n const inclusive = cond.upperBound.inclusive;\n\n if (upperBound === null || value < upperBound) {\n upperBound = value;\n upperInclusive = inclusive;\n } else if (value === upperBound && !inclusive) {\n upperInclusive = false;\n }\n }\n }\n\n return { lowerBound, lowerInclusive, upperBound, upperInclusive };\n}\n\n/**\n * Check if effective bounds fall entirely within an excluded range.\n *\n * For example:\n * Effective: [400, 800)\n * Excluded: [400, 800)\n * → bounds fall entirely within excluded range → impossible\n */\nfunction boundsWithinExcludedRange(\n bounds: EffectiveBounds,\n excluded: ExcludedRange,\n): boolean {\n if (bounds.lowerBound === null || bounds.upperBound === null) {\n return false;\n }\n\n // Check if bounds.lower >= excluded.lower\n let lowerOk = false;\n if (bounds.lowerBound > excluded.lower) {\n lowerOk = true;\n } else if (bounds.lowerBound === excluded.lower) {\n // If excluded includes lower, and bounds includes or excludes lower, it's within\n // If excluded excludes lower, bounds must also exclude it to be within\n lowerOk = excluded.lowerInclusive || !bounds.lowerInclusive;\n }\n\n // Check if bounds.upper <= excluded.upper\n let upperOk = false;\n if (bounds.upperBound < excluded.upper) {\n upperOk = true;\n } else if (bounds.upperBound === excluded.upper) {\n // If excluded includes upper, and bounds includes or excludes upper, it's within\n // If excluded excludes upper, bounds must also exclude it to be within\n upperOk = excluded.upperInclusive || !bounds.upperInclusive;\n }\n\n return lowerOk && upperOk;\n}\n\n// ============================================================================\n// Attribute Conflict Detection\n// ============================================================================\n\n/**\n * Check for attribute value conflicts\n * e.g., [data-theme=\"dark\"] & [data-theme=\"light\"] → FALSE\n * e.g., [data-theme=\"dark\"] & ![data-theme] → FALSE\n */\nfunction hasAttributeConflict(terms: ConditionNode[]): boolean {\n // Group modifiers by attribute\n const modifiersByAttr = new Map<\n string,\n { positive: ModifierCondition[]; negated: ModifierCondition[] }\n >();\n\n for (const term of terms) {\n if (term.kind !== 'state' || term.type !== 'modifier') continue;\n\n const attr = term.attribute;\n if (!modifiersByAttr.has(attr)) {\n modifiersByAttr.set(attr, { positive: [], negated: [] });\n }\n\n const group = modifiersByAttr.get(attr)!;\n if (term.negated) {\n group.negated.push(term);\n } else {\n group.positive.push(term);\n }\n }\n\n // Check each attribute for conflicts\n for (const [_attr, group] of modifiersByAttr) {\n // Multiple different values for same attribute in positive → conflict\n const positiveValues = group.positive\n .filter((m) => m.value !== undefined)\n .map((m) => m.value);\n const uniquePositiveValues = new Set(positiveValues);\n if (uniquePositiveValues.size > 1) {\n return true;\n }\n\n // Positive value + negated boolean for same attribute → conflict\n // e.g., [data-theme=\"dark\"] & ![data-theme]\n const hasPositiveValue = group.positive.some((m) => m.value !== undefined);\n const hasNegatedBoolean = group.negated.some((m) => m.value === undefined);\n if (hasPositiveValue && hasNegatedBoolean) {\n return true;\n }\n\n // Positive boolean + negated value (same value) → tautology not conflict\n // But positive value + negated same value → conflict\n for (const pos of group.positive) {\n if (pos.value !== undefined) {\n for (const neg of group.negated) {\n if (neg.value === pos.value) {\n return true; // [data-x=\"y\"] & ![data-x=\"y\"]\n }\n }\n }\n }\n }\n\n return false;\n}\n\n// ============================================================================\n// Container Style Query Conflict Detection\n// ============================================================================\n\n/**\n * Check for container style query conflicts\n * e.g., style(--variant: danger) & style(--variant: success) → FALSE\n * e.g., style(--variant: danger) & not style(--variant) → FALSE\n */\nfunction hasContainerStyleConflict(terms: ConditionNode[]): boolean {\n // Group container style queries by property (and container name)\n const styleByProp = new Map<\n string,\n { positive: ContainerCondition[]; negated: ContainerCondition[] }\n >();\n\n for (const term of terms) {\n if (\n term.kind !== 'state' ||\n term.type !== 'container' ||\n term.subtype !== 'style'\n )\n continue;\n\n const key = `${term.containerName || '_'}:${term.property}`;\n if (!styleByProp.has(key)) {\n styleByProp.set(key, { positive: [], negated: [] });\n }\n\n const group = styleByProp.get(key)!;\n if (term.negated) {\n group.negated.push(term);\n } else {\n group.positive.push(term);\n }\n }\n\n // Check each property for conflicts\n for (const [, group] of styleByProp) {\n // Multiple different values for same property in positive → conflict\n // e.g., style(--variant: danger) & style(--variant: success)\n const positiveValues = group.positive\n .filter((c) => c.propertyValue !== undefined)\n .map((c) => c.propertyValue);\n const uniquePositiveValues = new Set(positiveValues);\n if (uniquePositiveValues.size > 1) {\n return true;\n }\n\n // Positive value + negated existence → conflict\n // e.g., style(--variant: danger) & not style(--variant)\n const hasPositiveValue = group.positive.some(\n (c) => c.propertyValue !== undefined,\n );\n const hasNegatedExistence = group.negated.some(\n (c) => c.propertyValue === undefined,\n );\n if (hasPositiveValue && hasNegatedExistence) {\n return true;\n }\n\n // Positive value + negated same value → conflict\n // e.g., style(--variant: danger) & not style(--variant: danger)\n for (const pos of group.positive) {\n if (pos.propertyValue !== undefined) {\n for (const neg of group.negated) {\n if (neg.propertyValue === pos.propertyValue) {\n return true;\n }\n }\n }\n }\n }\n\n return false;\n}\n\n// ============================================================================\n// Implied Negation Removal\n// ============================================================================\n\n/**\n * Remove negations that are implied by positive terms.\n *\n * Key optimizations:\n * 1. style(--variant: danger) implies NOT style(--variant: success)\n * → If we have style(--variant: danger) & not style(--variant: success),\n * the negation is redundant and can be removed.\n *\n * 2. [data-theme=\"dark\"] implies NOT [data-theme=\"light\"]\n * → Same logic for attribute selectors.\n *\n * This produces cleaner CSS:\n * Before: @container style(--variant: danger) and (not style(--variant: success))\n * After: @container style(--variant: danger)\n */\nfunction removeImpliedNegations(terms: ConditionNode[]): ConditionNode[] {\n // Build sets of positive container style properties with specific values\n const positiveContainerStyles = new Map<string, string | undefined>();\n // key: \"containerName:property\", value: propertyValue (or undefined for existence)\n\n // Build sets of positive modifier attributes with specific values\n const positiveModifiers = new Map<string, string | undefined>();\n // key: \"attribute\", value: value (or undefined for boolean)\n\n for (const term of terms) {\n if (term.kind !== 'state' || term.negated) continue;\n\n if (term.type === 'container' && term.subtype === 'style') {\n const key = `${term.containerName || '_'}:${term.property}`;\n // Only track if we have a specific value (not just existence check)\n if (term.propertyValue !== undefined) {\n positiveContainerStyles.set(key, term.propertyValue);\n }\n }\n\n if (term.type === 'modifier' && term.value !== undefined) {\n positiveModifiers.set(term.attribute, term.value);\n }\n }\n\n // Filter out redundant negations\n return terms.filter((term) => {\n if (term.kind !== 'state' || !term.negated) return true;\n\n // Check container style negations\n if (term.type === 'container' && term.subtype === 'style') {\n const key = `${term.containerName || '_'}:${term.property}`;\n const positiveValue = positiveContainerStyles.get(key);\n\n if (positiveValue !== undefined) {\n // We have a positive style(--prop: X) for this property\n\n if (term.propertyValue === undefined) {\n // Negating existence: not style(--prop)\n // But we have style(--prop: X), which implies existence → contradiction\n // This should have been caught by hasContainerStyleConflict\n return true;\n }\n\n if (term.propertyValue !== positiveValue) {\n // Negating a different value: not style(--prop: Y)\n // We have style(--prop: X), which implies not style(--prop: Y)\n // → This negation is redundant!\n return false;\n }\n }\n }\n\n // Check modifier negations\n if (term.type === 'modifier') {\n const positiveValue = positiveModifiers.get(term.attribute);\n\n if (positiveValue !== undefined && term.value !== undefined) {\n // We have [attr=\"X\"] and this is not [attr=\"Y\"]\n if (term.value !== positiveValue) {\n // [attr=\"X\"] implies not [attr=\"Y\"] → redundant\n return false;\n }\n }\n }\n\n return true;\n });\n}\n\n// ============================================================================\n// Deduplication\n// ============================================================================\n\nfunction deduplicateTerms(terms: ConditionNode[]): ConditionNode[] {\n const seen = new Set<string>();\n const result: ConditionNode[] = [];\n\n for (const term of terms) {\n const id = getConditionUniqueId(term);\n if (!seen.has(id)) {\n seen.add(id);\n result.push(term);\n }\n }\n\n return result;\n}\n\n// ============================================================================\n// Range Merging\n// ============================================================================\n\n/**\n * Merge compatible range conditions\n * e.g., @media(w >= 400px) & @media(w <= 800px) → @media(400px <= w <= 800px)\n */\nfunction mergeRanges(terms: ConditionNode[]): ConditionNode[] {\n // Group media conditions by dimension\n const mediaByDim = new Map<\n string,\n { conditions: MediaCondition[]; indices: number[] }\n >();\n const containerByDim = new Map<\n string,\n { conditions: ContainerCondition[]; indices: number[] }\n >();\n\n terms.forEach((term, index) => {\n if (term.kind !== 'state') return;\n\n if (\n term.type === 'media' &&\n term.subtype === 'dimension' &&\n !term.negated\n ) {\n const key = term.dimension || 'width';\n if (!mediaByDim.has(key)) {\n mediaByDim.set(key, { conditions: [], indices: [] });\n }\n const group = mediaByDim.get(key)!;\n group.conditions.push(term);\n group.indices.push(index);\n }\n\n if (\n term.type === 'container' &&\n term.subtype === 'dimension' &&\n !term.negated\n ) {\n const key = `${term.containerName || '_'}:${term.dimension || 'width'}`;\n if (!containerByDim.has(key)) {\n containerByDim.set(key, { conditions: [], indices: [] });\n }\n const group = containerByDim.get(key)!;\n group.conditions.push(term);\n group.indices.push(index);\n }\n });\n\n // Track indices to remove\n const indicesToRemove = new Set<number>();\n const mergedTerms: ConditionNode[] = [];\n\n // Merge media conditions\n for (const [_dim, group] of mediaByDim) {\n if (group.conditions.length > 1) {\n const merged = mergeMediaRanges(group.conditions);\n if (merged) {\n group.indices.forEach((i) => indicesToRemove.add(i));\n mergedTerms.push(merged);\n }\n }\n }\n\n // Merge container conditions\n for (const [, group] of containerByDim) {\n if (group.conditions.length > 1) {\n const merged = mergeContainerRanges(group.conditions);\n if (merged) {\n group.indices.forEach((i) => indicesToRemove.add(i));\n mergedTerms.push(merged);\n }\n }\n }\n\n // Build result\n const result: ConditionNode[] = [];\n terms.forEach((term, index) => {\n if (!indicesToRemove.has(index)) {\n result.push(term);\n }\n });\n result.push(...mergedTerms);\n\n return result;\n}\n\nfunction mergeMediaRanges(conditions: MediaCondition[]): MediaCondition | null {\n if (conditions.length === 0) return null;\n\n let lowerBound: NumericBound | undefined;\n let upperBound: NumericBound | undefined;\n\n for (const cond of conditions) {\n if (cond.lowerBound) {\n if (\n !lowerBound ||\n (cond.lowerBound.valueNumeric ?? -Infinity) >\n (lowerBound.valueNumeric ?? -Infinity)\n ) {\n lowerBound = cond.lowerBound;\n }\n }\n if (cond.upperBound) {\n if (\n !upperBound ||\n (cond.upperBound.valueNumeric ?? Infinity) <\n (upperBound.valueNumeric ?? Infinity)\n ) {\n upperBound = cond.upperBound;\n }\n }\n }\n\n const base = conditions[0];\n\n // Build a merged condition\n const merged: MediaCondition = {\n kind: 'state',\n type: 'media',\n subtype: 'dimension',\n negated: false,\n raw: buildMergedRaw(base.dimension || 'width', lowerBound, upperBound),\n uniqueId: '', // Will be recalculated\n dimension: base.dimension,\n lowerBound,\n upperBound,\n };\n\n // Recalculate uniqueId\n const parts = ['media', 'dim', merged.dimension];\n if (lowerBound) {\n parts.push(lowerBound.inclusive ? '>=' : '>');\n parts.push(lowerBound.value);\n }\n if (upperBound) {\n parts.push(upperBound.inclusive ? '<=' : '<');\n parts.push(upperBound.value);\n }\n merged.uniqueId = parts.join(':');\n\n return merged;\n}\n\nfunction mergeContainerRanges(\n conditions: ContainerCondition[],\n): ContainerCondition | null {\n if (conditions.length === 0) return null;\n\n let lowerBound: NumericBound | undefined;\n let upperBound: NumericBound | undefined;\n\n for (const cond of conditions) {\n if (cond.lowerBound) {\n if (\n !lowerBound ||\n (cond.lowerBound.valueNumeric ?? -Infinity) >\n (lowerBound.valueNumeric ?? -Infinity)\n ) {\n lowerBound = cond.lowerBound;\n }\n }\n if (cond.upperBound) {\n if (\n !upperBound ||\n (cond.upperBound.valueNumeric ?? Infinity) <\n (upperBound.valueNumeric ?? Infinity)\n ) {\n upperBound = cond.upperBound;\n }\n }\n }\n\n const base = conditions[0];\n\n const merged: ContainerCondition = {\n kind: 'state',\n type: 'container',\n subtype: 'dimension',\n negated: false,\n raw: buildMergedRaw(base.dimension || 'width', lowerBound, upperBound),\n uniqueId: '', // Will be recalculated\n containerName: base.containerName,\n dimension: base.dimension,\n lowerBound,\n upperBound,\n };\n\n // Recalculate uniqueId\n const name = merged.containerName || '_';\n const parts = ['container', 'dim', name, merged.dimension];\n if (lowerBound) {\n parts.push(lowerBound.inclusive ? '>=' : '>');\n parts.push(lowerBound.value);\n }\n if (upperBound) {\n parts.push(upperBound.inclusive ? '<=' : '<');\n parts.push(upperBound.value);\n }\n merged.uniqueId = parts.join(':');\n\n return merged;\n}\n\nfunction buildMergedRaw(\n dimension: string,\n lowerBound?: NumericBound,\n upperBound?: NumericBound,\n): string {\n if (lowerBound && upperBound) {\n const lowerOp = lowerBound.inclusive ? '<=' : '<';\n const upperOp = upperBound.inclusive ? '<=' : '<';\n return `@media(${lowerBound.value} ${lowerOp} ${dimension} ${upperOp} ${upperBound.value})`;\n } else if (upperBound) {\n const op = upperBound.inclusive ? '<=' : '<';\n return `@media(${dimension} ${op} ${upperBound.value})`;\n } else if (lowerBound) {\n const op = lowerBound.inclusive ? '>=' : '>';\n return `@media(${dimension} ${op} ${lowerBound.value})`;\n }\n return '@media()';\n}\n\n// ============================================================================\n// Sorting\n// ============================================================================\n\nfunction sortTerms(terms: ConditionNode[]): ConditionNode[] {\n return [...terms].sort((a, b) => {\n const idA = getConditionUniqueId(a);\n const idB = getConditionUniqueId(b);\n return idA.localeCompare(idB);\n });\n}\n\n// ============================================================================\n// Absorption\n// ============================================================================\n\n/**\n * Apply absorption law for AND: A & (A | B) → A\n */\nfunction applyAbsorptionAnd(terms: ConditionNode[]): ConditionNode[] {\n // Collect all unique IDs of simple terms\n const simpleIds = new Set<string>();\n for (const term of terms) {\n if (term.kind !== 'compound') {\n simpleIds.add(getConditionUniqueId(term));\n }\n }\n\n // Filter out OR terms that are absorbed\n return terms.filter((term) => {\n if (term.kind === 'compound' && term.operator === 'OR') {\n // If any child of this OR is in simpleIds, absorb the whole OR\n for (const child of term.children) {\n if (simpleIds.has(getConditionUniqueId(child))) {\n return false; // Absorb\n }\n }\n }\n return true;\n });\n}\n\n/**\n * Apply absorption law for OR: A | (A & B) → A\n */\nfunction applyAbsorptionOr(terms: ConditionNode[]): ConditionNode[] {\n // Collect all unique IDs of simple terms\n const simpleIds = new Set<string>();\n for (const term of terms) {\n if (term.kind !== 'compound') {\n simpleIds.add(getConditionUniqueId(term));\n }\n }\n\n // Filter out AND terms that are absorbed\n return terms.filter((term) => {\n if (term.kind === 'compound' && term.operator === 'AND') {\n // If any child of this AND is in simpleIds, absorb the whole AND\n for (const child of term.children) {\n if (simpleIds.has(getConditionUniqueId(child))) {\n return false; // Absorb\n }\n }\n }\n return true;\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;AA8BA,MAAM,gBAAgB,IAAI,IAA2B,IAAK;;;;;;;;;;;;AAiB1D,SAAgB,kBAAkB,MAAoC;CAEpE,MAAM,MAAM,qBAAqB,KAAK;CACtC,MAAM,SAAS,cAAc,IAAI,IAAI;AACrC,KAAI,OACF,QAAO;CAGT,MAAM,SAAS,cAAc,KAAK;AAGlC,eAAc,IAAI,KAAK,OAAO;AAE9B,QAAO;;AAcT,SAAS,cAAc,MAAoC;AAEzD,KAAI,KAAK,SAAS,UAAU,KAAK,SAAS,QACxC,QAAO;AAIT,KAAI,KAAK,SAAS,QAChB,QAAO;AAIT,KAAI,KAAK,SAAS,YAAY;EAE5B,MAAM,qBAAqB,KAAK,SAAS,KAAK,MAAM,cAAc,EAAE,CAAC;AAGrE,MAAI,KAAK,aAAa,MACpB,QAAO,YAAY,mBAAmB;MAEtC,QAAO,WAAW,mBAAmB;;AAIzC,QAAO;;AAOT,SAAS,YAAY,UAA0C;CAC7D,IAAI,QAAyB,EAAE;AAG/B,MAAK,MAAM,SAAS,UAAU;AAC5B,M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AQ,SAAS;AAC5B,MAAI,KAAK,SAAS,cAAc,KAAK,aAAa,OAEhD;QAAK,MAAM,SAAS,KAAK,SACvB,KAAI,UAAU,IAAI,qBAAqB,MAAM,CAAC,CAC5C,QAAO;;AAIb,SAAO;GACP"}
|
|
1
|
+
{"version":3,"file":"simplify.js","names":[],"sources":["../../src/pipeline/simplify.ts"],"sourcesContent":["/**\n * Condition Simplification Engine\n *\n * Simplifies condition trees by applying boolean algebra rules,\n * detecting contradictions, merging ranges, and deduplicating terms.\n *\n * This is critical for:\n * 1. Detecting invalid combinations (A & !A → FALSE)\n * 2. Reducing CSS output size\n * 3. Producing cleaner selectors\n */\n\nimport { Lru } from '../parser/lru';\n\nimport type {\n ConditionNode,\n ContainerCondition,\n MediaCondition,\n ModifierCondition,\n NumericBound,\n} from './conditions';\nimport {\n falseCondition,\n getConditionUniqueId,\n trueCondition,\n} from './conditions';\n\n// ============================================================================\n// Caching\n// ============================================================================\n\nconst simplifyCache = new Lru<string, ConditionNode>(5000);\n\n// ============================================================================\n// Main Simplify Function\n// ============================================================================\n\n/**\n * Simplify a condition tree aggressively.\n *\n * This applies all possible simplification rules:\n * - Boolean algebra (identity, annihilator, idempotent, absorption)\n * - Contradiction detection (A & !A → FALSE)\n * - Tautology detection (A | !A → TRUE)\n * - Range intersection for numeric queries\n * - Attribute value conflict detection\n * - Deduplication and sorting\n */\nexport function simplifyCondition(node: ConditionNode): ConditionNode {\n // Check cache\n const key = getConditionUniqueId(node);\n const cached = simplifyCache.get(key);\n if (cached) {\n return cached;\n }\n\n const result = simplifyInner(node);\n\n // Cache result\n simplifyCache.set(key, result);\n\n return result;\n}\n\n/**\n * Clear the simplify cache (for testing)\n */\nexport function clearSimplifyCache(): void {\n simplifyCache.clear();\n}\n\n// ============================================================================\n// Inner Simplification\n// ============================================================================\n\nfunction simplifyInner(node: ConditionNode): ConditionNode {\n // Base cases\n if (node.kind === 'true' || node.kind === 'false') {\n return node;\n }\n\n // State conditions - return as-is (they're already leaf nodes)\n if (node.kind === 'state') {\n return node;\n }\n\n // Compound conditions - recursively simplify\n if (node.kind === 'compound') {\n // First, recursively simplify all children\n const simplifiedChildren = node.children.map((c) => simplifyInner(c));\n\n // Then apply compound-specific simplifications\n if (node.operator === 'AND') {\n return simplifyAnd(simplifiedChildren);\n } else {\n return simplifyOr(simplifiedChildren);\n }\n }\n\n return node;\n}\n\n// ============================================================================\n// AND Simplification\n// ============================================================================\n\nfunction simplifyAnd(children: ConditionNode[]): ConditionNode {\n let terms: ConditionNode[] = [];\n\n // Flatten nested ANDs and handle TRUE/FALSE\n for (const child of children) {\n if (child.kind === 'false') {\n // AND with FALSE → FALSE\n return falseCondition();\n }\n if (child.kind === 'true') {\n // AND with TRUE → skip (identity)\n continue;\n }\n if (child.kind === 'compound' && child.operator === 'AND') {\n // Flatten nested AND\n terms.push(...child.children);\n } else {\n terms.push(child);\n }\n }\n\n // Empty → TRUE\n if (terms.length === 0) {\n return trueCondition();\n }\n\n // Single term → return it\n if (terms.length === 1) {\n return terms[0];\n }\n\n // Check for contradictions\n if (hasContradiction(terms)) {\n return falseCondition();\n }\n\n // Check for range contradictions in media/container queries\n if (hasRangeContradiction(terms)) {\n return falseCondition();\n }\n\n // Check for attribute value conflicts\n if (hasAttributeConflict(terms)) {\n return falseCondition();\n }\n\n // Check for container style query conflicts\n if (hasContainerStyleConflict(terms)) {\n return falseCondition();\n }\n\n // Remove redundant negations implied by positive terms\n // e.g., style(--variant: danger) implies NOT style(--variant: success)\n // and style(--variant: danger) implies style(--variant) (existence)\n terms = removeImpliedNegations(terms);\n\n // Deduplicate (by uniqueId)\n terms = deduplicateTerms(terms);\n\n // Try to merge numeric ranges\n terms = mergeRanges(terms);\n\n // Sort for canonical form\n terms = sortTerms(terms);\n\n // Apply absorption: A & (A | B) → A\n terms = applyAbsorptionAnd(terms);\n\n if (terms.length === 0) {\n return trueCondition();\n }\n if (terms.length === 1) {\n return terms[0];\n }\n\n return {\n kind: 'compound',\n operator: 'AND',\n children: terms,\n };\n}\n\n// ============================================================================\n// OR Simplification\n// ============================================================================\n\nfunction simplifyOr(children: ConditionNode[]): ConditionNode {\n let terms: ConditionNode[] = [];\n\n // Flatten nested ORs and handle TRUE/FALSE\n for (const child of children) {\n if (child.kind === 'true') {\n // OR with TRUE → TRUE\n return trueCondition();\n }\n if (child.kind === 'false') {\n // OR with FALSE → skip (identity)\n continue;\n }\n if (child.kind === 'compound' && child.operator === 'OR') {\n // Flatten nested OR\n terms.push(...child.children);\n } else {\n terms.push(child);\n }\n }\n\n // Empty → FALSE\n if (terms.length === 0) {\n return falseCondition();\n }\n\n // Single term → return it\n if (terms.length === 1) {\n return terms[0];\n }\n\n // Check for tautologies (A | !A)\n if (hasTautology(terms)) {\n return trueCondition();\n }\n\n // Deduplicate\n terms = deduplicateTerms(terms);\n\n // Sort for canonical form\n terms = sortTerms(terms);\n\n // Apply absorption: A | (A & B) → A\n terms = applyAbsorptionOr(terms);\n\n if (terms.length === 0) {\n return falseCondition();\n }\n if (terms.length === 1) {\n return terms[0];\n }\n\n return {\n kind: 'compound',\n operator: 'OR',\n children: terms,\n };\n}\n\n// ============================================================================\n// Contradiction Detection\n// ============================================================================\n\n/**\n * Check if any term contradicts another (A & !A)\n */\nfunction hasContradiction(terms: ConditionNode[]): boolean {\n const uniqueIds = new Set<string>();\n\n for (const term of terms) {\n if (term.kind !== 'state') continue;\n\n const id = term.uniqueId;\n // Check if negation exists\n const negatedId = term.negated ? id.slice(1) : `!${id}`;\n\n if (uniqueIds.has(negatedId)) {\n return true;\n }\n uniqueIds.add(id);\n }\n\n return false;\n}\n\n/**\n * Check for tautologies (A | !A)\n */\nfunction hasTautology(terms: ConditionNode[]): boolean {\n const uniqueIds = new Set<string>();\n\n for (const term of terms) {\n if (term.kind !== 'state') continue;\n\n const id = term.uniqueId;\n const negatedId = term.negated ? id.slice(1) : `!${id}`;\n\n if (uniqueIds.has(negatedId)) {\n return true;\n }\n uniqueIds.add(id);\n }\n\n return false;\n}\n\n// ============================================================================\n// Range Contradiction Detection\n// ============================================================================\n\n/**\n * Effective bounds computed from conditions (including negated single-bound conditions)\n */\ninterface EffectiveBounds {\n lowerBound: number | null;\n lowerInclusive: boolean;\n upperBound: number | null;\n upperInclusive: boolean;\n}\n\n/**\n * Excluded range from a negated range condition\n */\ninterface ExcludedRange {\n lower: number;\n lowerInclusive: boolean;\n upper: number;\n upperInclusive: boolean;\n}\n\n/**\n * Check for range contradictions in media/container queries\n * e.g., @media(w < 400px) & @media(w > 800px) → FALSE\n *\n * Also handles negated conditions:\n * - Single-bound negations are inverted (not (w < 600px) → w >= 600px)\n * - Range negations create excluded ranges that are checked against positive bounds\n */\nfunction hasRangeContradiction(terms: ConditionNode[]): boolean {\n // Group by dimension, separating positive and negated conditions\n const mediaByDim = new Map<\n string,\n { positive: MediaCondition[]; negated: MediaCondition[] }\n >();\n const containerByDim = new Map<\n string,\n { positive: ContainerCondition[]; negated: ContainerCondition[] }\n >();\n\n for (const term of terms) {\n if (term.kind !== 'state') continue;\n\n if (term.type === 'media' && term.subtype === 'dimension') {\n const key = term.dimension || 'width';\n if (!mediaByDim.has(key)) {\n mediaByDim.set(key, { positive: [], negated: [] });\n }\n const group = mediaByDim.get(key)!;\n if (term.negated) {\n group.negated.push(term);\n } else {\n group.positive.push(term);\n }\n }\n\n if (term.type === 'container' && term.subtype === 'dimension') {\n const key = `${term.containerName || '_'}:${term.dimension || 'width'}`;\n if (!containerByDim.has(key)) {\n containerByDim.set(key, { positive: [], negated: [] });\n }\n const group = containerByDim.get(key)!;\n if (term.negated) {\n group.negated.push(term);\n } else {\n group.positive.push(term);\n }\n }\n }\n\n // Check each dimension group for impossible ranges\n for (const group of mediaByDim.values()) {\n if (rangesAreImpossibleWithNegations(group.positive, group.negated)) {\n return true;\n }\n }\n\n for (const group of containerByDim.values()) {\n if (rangesAreImpossibleWithNegations(group.positive, group.negated)) {\n return true;\n }\n }\n\n return false;\n}\n\n/**\n * Check if conditions are impossible, including negated conditions.\n *\n * For negated single-bound conditions:\n * not (w < 600px) → w >= 600px (inverted to lower bound)\n * not (w >= 800px) → w < 800px (inverted to upper bound)\n *\n * For negated range conditions:\n * not (400px <= w < 800px) → excludes [400, 800)\n * If the effective bounds fall entirely within an excluded range, it's impossible.\n */\nfunction rangesAreImpossibleWithNegations(\n positive: (MediaCondition | ContainerCondition)[],\n negated: (MediaCondition | ContainerCondition)[],\n): boolean {\n // Start with bounds from positive conditions\n const bounds = computeEffectiveBounds(positive);\n\n // Apply inverted bounds from single-bound negated conditions\n // and collect excluded ranges from range negated conditions\n const excludedRanges: ExcludedRange[] = [];\n\n for (const cond of negated) {\n const hasLower = cond.lowerBound?.valueNumeric != null;\n const hasUpper = cond.upperBound?.valueNumeric != null;\n\n if (hasLower && hasUpper) {\n // Range negation: not (lower <= w < upper) excludes [lower, upper)\n excludedRanges.push({\n lower: cond.lowerBound!.valueNumeric!,\n lowerInclusive: cond.lowerBound!.inclusive,\n upper: cond.upperBound!.valueNumeric!,\n upperInclusive: cond.upperBound!.inclusive,\n });\n } else if (hasUpper) {\n // not (w < upper) → w >= upper (becomes lower bound)\n // not (w <= upper) → w > upper (becomes lower bound, exclusive)\n const value = cond.upperBound!.valueNumeric!;\n const inclusive = !cond.upperBound!.inclusive; // flip inclusivity\n\n if (bounds.lowerBound === null || value > bounds.lowerBound) {\n bounds.lowerBound = value;\n bounds.lowerInclusive = inclusive;\n } else if (value === bounds.lowerBound && !inclusive) {\n bounds.lowerInclusive = false;\n }\n } else if (hasLower) {\n // not (w >= lower) → w < lower (becomes upper bound)\n // not (w > lower) → w <= lower (becomes upper bound, inclusive)\n const value = cond.lowerBound!.valueNumeric!;\n const inclusive = !cond.lowerBound!.inclusive; // flip inclusivity\n\n if (bounds.upperBound === null || value < bounds.upperBound) {\n bounds.upperBound = value;\n bounds.upperInclusive = inclusive;\n } else if (value === bounds.upperBound && !inclusive) {\n bounds.upperInclusive = false;\n }\n }\n }\n\n // Check if effective bounds are impossible on their own\n if (bounds.lowerBound !== null && bounds.upperBound !== null) {\n if (bounds.lowerBound > bounds.upperBound) {\n return true;\n }\n if (\n bounds.lowerBound === bounds.upperBound &&\n (!bounds.lowerInclusive || !bounds.upperInclusive)\n ) {\n return true;\n }\n }\n\n // Check if effective bounds fall entirely within any excluded range\n if (\n bounds.lowerBound !== null &&\n bounds.upperBound !== null &&\n excludedRanges.length > 0\n ) {\n for (const excluded of excludedRanges) {\n if (boundsWithinExcludedRange(bounds, excluded)) {\n return true;\n }\n }\n }\n\n return false;\n}\n\n/**\n * Compute effective bounds from positive (non-negated) conditions\n */\nfunction computeEffectiveBounds(\n conditions: (MediaCondition | ContainerCondition)[],\n): EffectiveBounds {\n let lowerBound: number | null = null;\n let lowerInclusive = false;\n let upperBound: number | null = null;\n let upperInclusive = false;\n\n for (const cond of conditions) {\n if (cond.lowerBound?.valueNumeric != null) {\n const value = cond.lowerBound.valueNumeric;\n const inclusive = cond.lowerBound.inclusive;\n\n if (lowerBound === null || value > lowerBound) {\n lowerBound = value;\n lowerInclusive = inclusive;\n } else if (value === lowerBound && !inclusive) {\n lowerInclusive = false;\n }\n }\n\n if (cond.upperBound?.valueNumeric != null) {\n const value = cond.upperBound.valueNumeric;\n const inclusive = cond.upperBound.inclusive;\n\n if (upperBound === null || value < upperBound) {\n upperBound = value;\n upperInclusive = inclusive;\n } else if (value === upperBound && !inclusive) {\n upperInclusive = false;\n }\n }\n }\n\n return { lowerBound, lowerInclusive, upperBound, upperInclusive };\n}\n\n/**\n * Check if effective bounds fall entirely within an excluded range.\n *\n * For example:\n * Effective: [400, 800)\n * Excluded: [400, 800)\n * → bounds fall entirely within excluded range → impossible\n */\nfunction boundsWithinExcludedRange(\n bounds: EffectiveBounds,\n excluded: ExcludedRange,\n): boolean {\n if (bounds.lowerBound === null || bounds.upperBound === null) {\n return false;\n }\n\n // Check if bounds.lower >= excluded.lower\n let lowerOk = false;\n if (bounds.lowerBound > excluded.lower) {\n lowerOk = true;\n } else if (bounds.lowerBound === excluded.lower) {\n // If excluded includes lower, and bounds includes or excludes lower, it's within\n // If excluded excludes lower, bounds must also exclude it to be within\n lowerOk = excluded.lowerInclusive || !bounds.lowerInclusive;\n }\n\n // Check if bounds.upper <= excluded.upper\n let upperOk = false;\n if (bounds.upperBound < excluded.upper) {\n upperOk = true;\n } else if (bounds.upperBound === excluded.upper) {\n // If excluded includes upper, and bounds includes or excludes upper, it's within\n // If excluded excludes upper, bounds must also exclude it to be within\n upperOk = excluded.upperInclusive || !bounds.upperInclusive;\n }\n\n return lowerOk && upperOk;\n}\n\n// ============================================================================\n// Attribute Conflict Detection\n// ============================================================================\n\n/**\n * Check for attribute value conflicts\n * e.g., [data-theme=\"dark\"] & [data-theme=\"light\"] → FALSE\n * e.g., [data-theme=\"dark\"] & ![data-theme] → FALSE\n */\nfunction hasAttributeConflict(terms: ConditionNode[]): boolean {\n // Group modifiers by attribute\n const modifiersByAttr = new Map<\n string,\n { positive: ModifierCondition[]; negated: ModifierCondition[] }\n >();\n\n for (const term of terms) {\n if (term.kind !== 'state' || term.type !== 'modifier') continue;\n\n const attr = term.attribute;\n if (!modifiersByAttr.has(attr)) {\n modifiersByAttr.set(attr, { positive: [], negated: [] });\n }\n\n const group = modifiersByAttr.get(attr)!;\n if (term.negated) {\n group.negated.push(term);\n } else {\n group.positive.push(term);\n }\n }\n\n // Check each attribute for conflicts\n for (const [_attr, group] of modifiersByAttr) {\n // Multiple different values for same attribute in positive → conflict\n const positiveValues = group.positive\n .filter((m) => m.value !== undefined)\n .map((m) => m.value);\n const uniquePositiveValues = new Set(positiveValues);\n if (uniquePositiveValues.size > 1) {\n return true;\n }\n\n // Positive value + negated boolean for same attribute → conflict\n // e.g., [data-theme=\"dark\"] & ![data-theme]\n const hasPositiveValue = group.positive.some((m) => m.value !== undefined);\n const hasNegatedBoolean = group.negated.some((m) => m.value === undefined);\n if (hasPositiveValue && hasNegatedBoolean) {\n return true;\n }\n\n // Positive boolean + negated value (same value) → tautology not conflict\n // But positive value + negated same value → conflict\n for (const pos of group.positive) {\n if (pos.value !== undefined) {\n for (const neg of group.negated) {\n if (neg.value === pos.value) {\n return true; // [data-x=\"y\"] & ![data-x=\"y\"]\n }\n }\n }\n }\n }\n\n return false;\n}\n\n// ============================================================================\n// Container Style Query Conflict Detection\n// ============================================================================\n\n/**\n * Check for container style query conflicts\n * e.g., style(--variant: danger) & style(--variant: success) → FALSE\n * e.g., style(--variant: danger) & not style(--variant) → FALSE\n */\nfunction hasContainerStyleConflict(terms: ConditionNode[]): boolean {\n // Group container style queries by property (and container name)\n const styleByProp = new Map<\n string,\n { positive: ContainerCondition[]; negated: ContainerCondition[] }\n >();\n\n for (const term of terms) {\n if (\n term.kind !== 'state' ||\n term.type !== 'container' ||\n term.subtype !== 'style'\n )\n continue;\n\n const key = `${term.containerName || '_'}:${term.property}`;\n if (!styleByProp.has(key)) {\n styleByProp.set(key, { positive: [], negated: [] });\n }\n\n const group = styleByProp.get(key)!;\n if (term.negated) {\n group.negated.push(term);\n } else {\n group.positive.push(term);\n }\n }\n\n // Check each property for conflicts\n for (const [, group] of styleByProp) {\n // Multiple different values for same property in positive → conflict\n // e.g., style(--variant: danger) & style(--variant: success)\n const positiveValues = group.positive\n .filter((c) => c.propertyValue !== undefined)\n .map((c) => c.propertyValue);\n const uniquePositiveValues = new Set(positiveValues);\n if (uniquePositiveValues.size > 1) {\n return true;\n }\n\n // Positive value + negated existence → conflict\n // e.g., style(--variant: danger) & not style(--variant)\n const hasPositiveValue = group.positive.some(\n (c) => c.propertyValue !== undefined,\n );\n const hasNegatedExistence = group.negated.some(\n (c) => c.propertyValue === undefined,\n );\n if (hasPositiveValue && hasNegatedExistence) {\n return true;\n }\n\n // Positive value + negated same value → conflict\n // e.g., style(--variant: danger) & not style(--variant: danger)\n for (const pos of group.positive) {\n if (pos.propertyValue !== undefined) {\n for (const neg of group.negated) {\n if (neg.propertyValue === pos.propertyValue) {\n return true;\n }\n }\n }\n }\n }\n\n return false;\n}\n\n// ============================================================================\n// Implied Negation Removal\n// ============================================================================\n\n/**\n * Remove negations that are implied by positive terms.\n *\n * Key optimizations:\n * 1. style(--variant: danger) implies NOT style(--variant: success)\n * → If we have style(--variant: danger) & not style(--variant: success),\n * the negation is redundant and can be removed.\n *\n * 2. [data-theme=\"dark\"] implies NOT [data-theme=\"light\"]\n * → Same logic for attribute selectors.\n *\n * This produces cleaner CSS:\n * Before: @container style(--variant: danger) and (not style(--variant: success))\n * After: @container style(--variant: danger)\n */\nfunction removeImpliedNegations(terms: ConditionNode[]): ConditionNode[] {\n // Build sets of positive container style properties with specific values\n const positiveContainerStyles = new Map<string, string | undefined>();\n // key: \"containerName:property\", value: propertyValue (or undefined for existence)\n\n // Build sets of positive modifier attributes with specific values\n const positiveModifiers = new Map<string, string | undefined>();\n // key: \"attribute\", value: value (or undefined for boolean)\n\n for (const term of terms) {\n if (term.kind !== 'state' || term.negated) continue;\n\n if (term.type === 'container' && term.subtype === 'style') {\n const key = `${term.containerName || '_'}:${term.property}`;\n // Only track if we have a specific value (not just existence check)\n if (term.propertyValue !== undefined) {\n positiveContainerStyles.set(key, term.propertyValue);\n }\n }\n\n if (term.type === 'modifier' && term.value !== undefined) {\n positiveModifiers.set(term.attribute, term.value);\n }\n }\n\n // Filter out redundant negations\n return terms.filter((term) => {\n if (term.kind !== 'state' || !term.negated) return true;\n\n // Check container style negations\n if (term.type === 'container' && term.subtype === 'style') {\n const key = `${term.containerName || '_'}:${term.property}`;\n const positiveValue = positiveContainerStyles.get(key);\n\n if (positiveValue !== undefined) {\n // We have a positive style(--prop: X) for this property\n\n if (term.propertyValue === undefined) {\n // Negating existence: not style(--prop)\n // But we have style(--prop: X), which implies existence → contradiction\n // This should have been caught by hasContainerStyleConflict\n return true;\n }\n\n if (term.propertyValue !== positiveValue) {\n // Negating a different value: not style(--prop: Y)\n // We have style(--prop: X), which implies not style(--prop: Y)\n // → This negation is redundant!\n return false;\n }\n }\n }\n\n // Check modifier negations\n if (term.type === 'modifier') {\n const positiveValue = positiveModifiers.get(term.attribute);\n\n if (positiveValue !== undefined && term.value !== undefined) {\n // We have [attr=\"X\"] and this is not [attr=\"Y\"]\n if (term.value !== positiveValue) {\n // [attr=\"X\"] implies not [attr=\"Y\"] → redundant\n return false;\n }\n }\n }\n\n return true;\n });\n}\n\n// ============================================================================\n// Deduplication\n// ============================================================================\n\nfunction deduplicateTerms(terms: ConditionNode[]): ConditionNode[] {\n const seen = new Set<string>();\n const result: ConditionNode[] = [];\n\n for (const term of terms) {\n const id = getConditionUniqueId(term);\n if (!seen.has(id)) {\n seen.add(id);\n result.push(term);\n }\n }\n\n return result;\n}\n\n// ============================================================================\n// Range Merging\n// ============================================================================\n\n/**\n * Merge compatible range conditions\n * e.g., @media(w >= 400px) & @media(w <= 800px) → @media(400px <= w <= 800px)\n */\nfunction mergeRanges(terms: ConditionNode[]): ConditionNode[] {\n // Group media conditions by dimension\n const mediaByDim = new Map<\n string,\n { conditions: MediaCondition[]; indices: number[] }\n >();\n const containerByDim = new Map<\n string,\n { conditions: ContainerCondition[]; indices: number[] }\n >();\n\n terms.forEach((term, index) => {\n if (term.kind !== 'state') return;\n\n if (\n term.type === 'media' &&\n term.subtype === 'dimension' &&\n !term.negated\n ) {\n const key = term.dimension || 'width';\n if (!mediaByDim.has(key)) {\n mediaByDim.set(key, { conditions: [], indices: [] });\n }\n const group = mediaByDim.get(key)!;\n group.conditions.push(term);\n group.indices.push(index);\n }\n\n if (\n term.type === 'container' &&\n term.subtype === 'dimension' &&\n !term.negated\n ) {\n const key = `${term.containerName || '_'}:${term.dimension || 'width'}`;\n if (!containerByDim.has(key)) {\n containerByDim.set(key, { conditions: [], indices: [] });\n }\n const group = containerByDim.get(key)!;\n group.conditions.push(term);\n group.indices.push(index);\n }\n });\n\n // Track indices to remove\n const indicesToRemove = new Set<number>();\n const mergedTerms: ConditionNode[] = [];\n\n // Merge media conditions\n for (const [_dim, group] of mediaByDim) {\n if (group.conditions.length > 1) {\n const merged = mergeMediaRanges(group.conditions);\n if (merged) {\n group.indices.forEach((i) => indicesToRemove.add(i));\n mergedTerms.push(merged);\n }\n }\n }\n\n // Merge container conditions\n for (const [, group] of containerByDim) {\n if (group.conditions.length > 1) {\n const merged = mergeContainerRanges(group.conditions);\n if (merged) {\n group.indices.forEach((i) => indicesToRemove.add(i));\n mergedTerms.push(merged);\n }\n }\n }\n\n // Build result\n const result: ConditionNode[] = [];\n terms.forEach((term, index) => {\n if (!indicesToRemove.has(index)) {\n result.push(term);\n }\n });\n result.push(...mergedTerms);\n\n return result;\n}\n\nfunction mergeMediaRanges(conditions: MediaCondition[]): MediaCondition | null {\n if (conditions.length === 0) return null;\n\n let lowerBound: NumericBound | undefined;\n let upperBound: NumericBound | undefined;\n\n for (const cond of conditions) {\n if (cond.lowerBound) {\n if (\n !lowerBound ||\n (cond.lowerBound.valueNumeric ?? -Infinity) >\n (lowerBound.valueNumeric ?? -Infinity)\n ) {\n lowerBound = cond.lowerBound;\n }\n }\n if (cond.upperBound) {\n if (\n !upperBound ||\n (cond.upperBound.valueNumeric ?? Infinity) <\n (upperBound.valueNumeric ?? Infinity)\n ) {\n upperBound = cond.upperBound;\n }\n }\n }\n\n const base = conditions[0];\n\n // Build a merged condition\n const merged: MediaCondition = {\n kind: 'state',\n type: 'media',\n subtype: 'dimension',\n negated: false,\n raw: buildMergedRaw(base.dimension || 'width', lowerBound, upperBound),\n uniqueId: '', // Will be recalculated\n dimension: base.dimension,\n lowerBound,\n upperBound,\n };\n\n // Recalculate uniqueId\n const parts = ['media', 'dim', merged.dimension];\n if (lowerBound) {\n parts.push(lowerBound.inclusive ? '>=' : '>');\n parts.push(lowerBound.value);\n }\n if (upperBound) {\n parts.push(upperBound.inclusive ? '<=' : '<');\n parts.push(upperBound.value);\n }\n merged.uniqueId = parts.join(':');\n\n return merged;\n}\n\nfunction mergeContainerRanges(\n conditions: ContainerCondition[],\n): ContainerCondition | null {\n if (conditions.length === 0) return null;\n\n let lowerBound: NumericBound | undefined;\n let upperBound: NumericBound | undefined;\n\n for (const cond of conditions) {\n if (cond.lowerBound) {\n if (\n !lowerBound ||\n (cond.lowerBound.valueNumeric ?? -Infinity) >\n (lowerBound.valueNumeric ?? -Infinity)\n ) {\n lowerBound = cond.lowerBound;\n }\n }\n if (cond.upperBound) {\n if (\n !upperBound ||\n (cond.upperBound.valueNumeric ?? Infinity) <\n (upperBound.valueNumeric ?? Infinity)\n ) {\n upperBound = cond.upperBound;\n }\n }\n }\n\n const base = conditions[0];\n\n const merged: ContainerCondition = {\n kind: 'state',\n type: 'container',\n subtype: 'dimension',\n negated: false,\n raw: buildMergedRaw(base.dimension || 'width', lowerBound, upperBound),\n uniqueId: '', // Will be recalculated\n containerName: base.containerName,\n dimension: base.dimension,\n lowerBound,\n upperBound,\n };\n\n // Recalculate uniqueId\n const name = merged.containerName || '_';\n const parts = ['container', 'dim', name, merged.dimension];\n if (lowerBound) {\n parts.push(lowerBound.inclusive ? '>=' : '>');\n parts.push(lowerBound.value);\n }\n if (upperBound) {\n parts.push(upperBound.inclusive ? '<=' : '<');\n parts.push(upperBound.value);\n }\n merged.uniqueId = parts.join(':');\n\n return merged;\n}\n\nfunction buildMergedRaw(\n dimension: string,\n lowerBound?: NumericBound,\n upperBound?: NumericBound,\n): string {\n if (lowerBound && upperBound) {\n const lowerOp = lowerBound.inclusive ? '<=' : '<';\n const upperOp = upperBound.inclusive ? '<=' : '<';\n return `@media(${lowerBound.value} ${lowerOp} ${dimension} ${upperOp} ${upperBound.value})`;\n } else if (upperBound) {\n const op = upperBound.inclusive ? '<=' : '<';\n return `@media(${dimension} ${op} ${upperBound.value})`;\n } else if (lowerBound) {\n const op = lowerBound.inclusive ? '>=' : '>';\n return `@media(${dimension} ${op} ${lowerBound.value})`;\n }\n return '@media()';\n}\n\n// ============================================================================\n// Sorting\n// ============================================================================\n\nfunction sortTerms(terms: ConditionNode[]): ConditionNode[] {\n return [...terms].sort((a, b) => {\n const idA = getConditionUniqueId(a);\n const idB = getConditionUniqueId(b);\n return idA.localeCompare(idB);\n });\n}\n\n// ============================================================================\n// Absorption\n// ============================================================================\n\n/**\n * Apply absorption law for AND: A & (A | B) → A\n */\nfunction applyAbsorptionAnd(terms: ConditionNode[]): ConditionNode[] {\n // Collect all unique IDs of simple terms\n const simpleIds = new Set<string>();\n for (const term of terms) {\n if (term.kind !== 'compound') {\n simpleIds.add(getConditionUniqueId(term));\n }\n }\n\n // Filter out OR terms that are absorbed\n return terms.filter((term) => {\n if (term.kind === 'compound' && term.operator === 'OR') {\n // If any child of this OR is in simpleIds, absorb the whole OR\n for (const child of term.children) {\n if (simpleIds.has(getConditionUniqueId(child))) {\n return false; // Absorb\n }\n }\n }\n return true;\n });\n}\n\n/**\n * Apply absorption law for OR: A | (A & B) → A\n */\nfunction applyAbsorptionOr(terms: ConditionNode[]): ConditionNode[] {\n // Collect all unique IDs of simple terms\n const simpleIds = new Set<string>();\n for (const term of terms) {\n if (term.kind !== 'compound') {\n simpleIds.add(getConditionUniqueId(term));\n }\n }\n\n // Filter out AND terms that are absorbed\n return terms.filter((term) => {\n if (term.kind === 'compound' && term.operator === 'AND') {\n // If any child of this AND is in simpleIds, absorb the whole AND\n for (const child of term.children) {\n if (simpleIds.has(getConditionUniqueId(child))) {\n return false; // Absorb\n }\n }\n }\n return true;\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;AA+BA,MAAM,gBAAgB,IAAI,IAA2B,IAAK;;;;;;;;;;;;AAiB1D,SAAgB,kBAAkB,MAAoC;CAEpE,MAAM,MAAM,qBAAqB,KAAK;CACtC,MAAM,SAAS,cAAc,IAAI,IAAI;AACrC,KAAI,OACF,QAAO;CAGT,MAAM,SAAS,cAAc,KAAK;AAGlC,eAAc,IAAI,KAAK,OAAO;AAE9B,QAAO;;AAcT,SAAS,cAAc,MAAoC;AAEzD,KAAI,KAAK,SAAS,UAAU,KAAK,SAAS,QACxC,QAAO;AAIT,KAAI,KAAK,SAAS,QAChB,QAAO;AAIT,KAAI,KAAK,SAAS,YAAY;EAE5B,M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AI,UAAU,IAAI,qBAAqB,MAAM,CAAC,CAC5C,QAAO;;AAIb,SAAO;GACP;;;;;AAMJ,SAAS,kBAAkB,OAAyC;CAElE,MAAM,4BAAY,IAAI,KAAa;AACnC,MAAK,MAAM,QAAQ,MACjB,KAAI,KAAK,SAAS,WAChB,WAAU,IAAI,qBAAqB,KAAK,CAAC;AAK7C,QAAO,MAAM,QAAQ,SAAS;AAC5B,MAAI,KAAK,SAAS,cAAc,KAAK,aAAa,OAEhD;QAAK,MAAM,SAAS,KAAK,SACvB,KAAI,UAAU,IAAI,qBAAqB,MAAM,CAAC,CAC5C,QAAO;;AAIb,SAAO;GACP"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dimension.js","names":[],"sources":["../../src/styles/dimension.ts"],"sourcesContent":["import { makeEmptyDetails } from '../parser/types';\nimport { parseStyle } from '../utils/styles';\n\nconst DEFAULT_MIN_SIZE = 'var(--gap)';\nconst DEFAULT_MAX_SIZE = '100%';\n\n/**\n * Parse a dimension value (string, number, or boolean) into a CSS value\n */\nfunction parseDimensionValue(\n val: string | number | boolean | undefined,\n): string | null {\n if (val == null) return null;\n if (typeof val === 'number') return `${val}px`;\n if (val === true) return 'initial';\n\n const processed = parseStyle(String(val));\n return processed.groups[0]?.values[0] || null;\n}\n\ninterface DimensionProps {\n value?: string | number | boolean;\n min?: string | number | boolean;\n max?: string | number | boolean;\n}\n\n/**\n * Creates a dimension style handler for width or height.\n *\n * Supports:\n * - Main dimension prop (width/height) with syntax for min/max\n * - Separate min/max props (minWidth/maxWidth or minHeight/maxHeight)\n *\n * Priority: Individual min/max props override values from main prop syntax\n */\nexport function dimensionStyle(name: 'width' | 'height') {\n const minStyle = `min-${name}`;\n const maxStyle = `max-${name}`;\n\n return ({ value, min, max }: DimensionProps) => {\n // If nothing is defined, return undefined\n if (value == null && min == null && max == null) return;\n\n // Handle boolean true on main value - reset all to initial\n if (value === true) {\n const styles: Record<string, string | string[]> = {\n [name]: 'auto',\n [minStyle]: 'initial',\n [maxStyle]: 'initial',\n };\n\n // Apply individual min/max overrides\n const minVal = parseDimensionValue(min);\n const maxVal = parseDimensionValue(max);\n if (minVal) styles[minStyle] = minVal;\n if (maxVal) styles[maxStyle] = maxVal;\n\n return styles;\n }\n\n const styles: Record<string, string | string[]> = {\n [name]: 'auto',\n [minStyle]: 'initial',\n [maxStyle]: 'initial',\n };\n\n // Process main dimension value\n if (value != null) {\n let val = value;\n if (typeof val === 'number') {\n val = `${val}px`;\n }\n\n val = String(val);\n\n const processed = parseStyle(val);\n const { mods, values }
|
|
1
|
+
{"version":3,"file":"dimension.js","names":[],"sources":["../../src/styles/dimension.ts"],"sourcesContent":["import { makeEmptyDetails } from '../parser/types';\nimport { parseStyle } from '../utils/styles';\n\nconst DEFAULT_MIN_SIZE = 'var(--gap)';\nconst DEFAULT_MAX_SIZE = '100%';\n\n/**\n * Parse a dimension value (string, number, or boolean) into a CSS value\n */\nfunction parseDimensionValue(\n val: string | number | boolean | undefined,\n): string | null {\n if (val == null) return null;\n if (typeof val === 'number') return `${val}px`;\n if (val === true) return 'initial';\n\n const processed = parseStyle(String(val));\n return processed.groups[0]?.values[0] || null;\n}\n\ninterface DimensionProps {\n value?: string | number | boolean;\n min?: string | number | boolean;\n max?: string | number | boolean;\n}\n\n/**\n * Creates a dimension style handler for width or height.\n *\n * Supports:\n * - Main dimension prop (width/height) with syntax for min/max\n * - Separate min/max props (minWidth/maxWidth or minHeight/maxHeight)\n *\n * Priority: Individual min/max props override values from main prop syntax\n */\nexport function dimensionStyle(name: 'width' | 'height') {\n const minStyle = `min-${name}`;\n const maxStyle = `max-${name}`;\n\n return ({ value, min, max }: DimensionProps) => {\n // If nothing is defined, return undefined\n if (value == null && min == null && max == null) return;\n\n // Handle boolean true on main value - reset all to initial\n if (value === true) {\n const styles: Record<string, string | string[]> = {\n [name]: 'auto',\n [minStyle]: 'initial',\n [maxStyle]: 'initial',\n };\n\n // Apply individual min/max overrides\n const minVal = parseDimensionValue(min);\n const maxVal = parseDimensionValue(max);\n if (minVal) styles[minStyle] = minVal;\n if (maxVal) styles[maxStyle] = maxVal;\n\n return styles;\n }\n\n const styles: Record<string, string | string[]> = {\n [name]: 'auto',\n [minStyle]: 'initial',\n [maxStyle]: 'initial',\n };\n\n // Process main dimension value\n if (value != null) {\n let val = value;\n if (typeof val === 'number') {\n val = `${val}px`;\n }\n\n val = String(val);\n\n const processed = parseStyle(val);\n const { mods, values } = processed.groups[0] ?? makeEmptyDetails();\n\n let flag = false;\n\n for (const mod of mods) {\n switch (mod) {\n case 'min':\n styles[minStyle] = values[0] || DEFAULT_MIN_SIZE;\n flag = true;\n break;\n case 'max':\n styles[maxStyle] = values[0] || DEFAULT_MAX_SIZE;\n flag = true;\n break;\n case 'fixed': {\n // Fixed modifier: set all three dimensions to the same value\n const fixedValue = values[0] || 'max-content';\n styles[minStyle] = fixedValue;\n styles[name] = fixedValue;\n styles[maxStyle] = fixedValue;\n flag = true;\n break;\n }\n default:\n break;\n }\n }\n\n if (!flag || !mods.length) {\n if (values.length === 2) {\n styles[minStyle] = values[0];\n styles[maxStyle] = values[1];\n } else if (values.length === 3) {\n styles[minStyle] = values[0];\n styles[name] = values[1];\n styles[maxStyle] = values[2];\n } else {\n styles[name] = values[0] || 'auto';\n }\n }\n\n if (styles[name] === 'stretch') {\n if (name === 'width') {\n styles[name] = [\n 'stretch',\n '-webkit-fill-available',\n '-moz-available',\n ];\n } else {\n styles[name] = 'auto';\n }\n }\n }\n\n // Apply individual min/max props (higher priority, override main prop syntax)\n const minVal = parseDimensionValue(min);\n const maxVal = parseDimensionValue(max);\n if (minVal) styles[minStyle] = minVal;\n if (maxVal) styles[maxStyle] = maxVal;\n\n return styles;\n };\n}\n"],"mappings":";;;;AAGA,MAAM,mBAAmB;AACzB,MAAM,mBAAmB;;;;AAKzB,SAAS,oBACP,KACe;AACf,KAAI,OAAO,KAAM,QAAO;AACxB,KAAI,OAAO,QAAQ,SAAU,QAAO,GAAG,IAAI;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,QAAQ,OAAO;AACtB,WAAO,YAAY,OAAO;SAE1B,QAAO,QAAQ,OAAO,MAAM;AAIhC,OAAI,OAAO,UAAU,UACnB,KAAI,SAAS,QACX,QAAO,QAAQ;IACb;IACA;IACA;IACD;OAED,QAAO,QAAQ;;EAMrB,MAAM,SAAS,oBAAoB,IAAI;EACvC,MAAM,SAAS,oBAAoB,IAAI;AACvC,MAAI,OAAQ,QAAO,YAAY;AAC/B,MAAI,OAAQ,QAAO,YAAY;AAE/B,SAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"predefined.js","names":[],"sources":["../../src/styles/predefined.ts"],"sourcesContent":["import { isDevEnv } from '../utils/is-dev-env';\nimport type {\n RawStyleHandler,\n StyleHandler,\n StyleHandlerDefinition,\n} from '../utils/styles';\n\nimport { alignStyle } from './align';\nimport { borderStyle } from './border';\nimport { colorStyle } from './color';\nimport { createStyle } from './createStyle';\nimport { displayStyle } from './display';\nimport { fadeStyle } from './fade';\nimport { fillStyle, svgFillStyle } from './fill';\nimport { flowStyle } from './flow';\n// Note: fontStyle (font.ts) and fontStyleStyle (fontStyle.ts) removed\n// Both font and fontStyle props are now handled by presetStyle\nimport { gapStyle } from './gap';\nimport { heightStyle } from './height';\nimport { insetStyle } from './inset';\nimport { justifyStyle } from './justify';\nimport { marginStyle } from './margin';\nimport { outlineStyle } from './outline';\nimport { paddingStyle } from './padding';\nimport { presetStyle } from './preset';\nimport { radiusStyle } from './radius';\nimport { scrollbarStyle } from './scrollbar';\nimport { shadowStyle } from './shadow';\nimport { styledScrollbarStyle } from './styledScrollbar';\nimport { transitionStyle } from './transition';\nimport { widthStyle } from './width';\n\nconst devMode = isDevEnv();\n\n \nconst _numberConverter = (val) => {\n if (typeof val === 'number') {\n return `${val}px`;\n }\n\n return val;\n};\nconst columnsConverter = (val) => {\n if (typeof val === 'number') {\n return 'minmax(1px, 1fr) '.repeat(val).trim();\n }\n\n return;\n};\nconst rowsConverter = (val) => {\n if (typeof val === 'number') {\n return 'auto '.repeat(val).trim();\n }\n\n return;\n};\n\ntype StyleHandlerMap = Record<string, StyleHandler[]>;\n\nexport const STYLE_HANDLER_MAP: StyleHandlerMap = {};\n\n// Store initial handler state for reset functionality\nlet initialHandlerMapSnapshot: StyleHandlerMap | null = null;\n\n/**\n * Capture a snapshot of the current STYLE_HANDLER_MAP.\n * Called after predefine() to preserve built-in handler state.\n */\nfunction captureInitialHandlerState(): void {\n initialHandlerMapSnapshot = {};\n for (const key of Object.keys(STYLE_HANDLER_MAP)) {\n // Shallow copy the array - handlers themselves are immutable\n initialHandlerMapSnapshot[key] = [...STYLE_HANDLER_MAP[key]];\n }\n}\n\n/**\n * Reset STYLE_HANDLER_MAP to the initial built-in state.\n * Called by resetConfig() to restore handlers after tests.\n */\nexport function resetHandlers(): void {\n if (!initialHandlerMapSnapshot) {\n // predefine() hasn't been called yet, nothing to reset\n return;\n }\n\n // Clear current map\n for (const key of Object.keys(STYLE_HANDLER_MAP)) {\n delete STYLE_HANDLER_MAP[key];\n }\n\n // Restore initial state\n for (const key of Object.keys(initialHandlerMapSnapshot)) {\n STYLE_HANDLER_MAP[key] = [...initialHandlerMapSnapshot[key]];\n }\n}\n\nexport function defineCustomStyle(\n names: string[] | StyleHandler,\n handler?: RawStyleHandler,\n) {\n let handlerWithLookup: StyleHandler;\n\n if (typeof names === 'function') {\n handlerWithLookup = names;\n names = handlerWithLookup.__lookupStyles;\n } else if (handler) {\n handlerWithLookup = Object.assign(handler, { __lookupStyles: names });\n } else {\n console.warn('CubeUIKit: incorrect custom style definition: ', names);\n return;\n }\n\n if (Array.isArray(names)) {\n // just to pass type checking\n names.forEach((name) => {\n if (!STYLE_HANDLER_MAP[name]) {\n STYLE_HANDLER_MAP[name] = [];\n }\n\n STYLE_HANDLER_MAP[name].push(handlerWithLookup);\n });\n }\n}\n\ntype ConverterHandler = (\n s: string | boolean | number | undefined,\n) => string | undefined;\n\nexport function defineStyleAlias(\n styleName: string,\n cssStyleName?: string,\n converter?: ConverterHandler,\n) {\n const styleHandler = createStyle(styleName, cssStyleName, converter);\n\n if (!STYLE_HANDLER_MAP[styleName]) {\n STYLE_HANDLER_MAP[styleName] = [];\n }\n\n STYLE_HANDLER_MAP[styleName].push(styleHandler);\n}\n\nexport function predefine() {\n // Style aliases\n defineStyleAlias('gridAreas', 'grid-template-areas');\n defineStyleAlias('gridColumns', 'grid-template-columns', columnsConverter);\n defineStyleAlias('gridRows', 'grid-template-rows', rowsConverter);\n defineStyleAlias('gridTemplate', 'grid-template', (val) => {\n if (typeof val !== 'string') return;\n\n return val\n .split('/')\n .map((s, i) => (i ? columnsConverter : rowsConverter)(s))\n .join('/');\n });\n // Note: outlineOffset is now handled by outlineStyle\n\n [\n displayStyle,\n transitionStyle,\n fillStyle,\n svgFillStyle,\n widthStyle,\n marginStyle,\n gapStyle,\n flowStyle,\n colorStyle,\n heightStyle,\n radiusStyle,\n borderStyle,\n shadowStyle,\n paddingStyle,\n alignStyle,\n justifyStyle,\n presetStyle,\n outlineStyle,\n // DEPRECATED: `styledScrollbar` is deprecated, use `scrollbar` instead\n styledScrollbarStyle,\n scrollbarStyle,\n fadeStyle,\n insetStyle,\n ]\n // @ts-expect-error handler type varies across built-in style handlers\n .forEach((handler) => defineCustomStyle(handler));\n\n // Capture initial state after all built-in handlers are registered\n captureInitialHandlerState();\n\n return { STYLE_HANDLER_MAP, defineCustomStyle, defineStyleAlias };\n}\n\n// ============================================================================\n// Handler Registration API (for configure())\n// ============================================================================\n\n/**\n * Normalize a handler definition to a StyleHandler with __lookupStyles.\n * - Function only: lookup styles inferred from key name\n * - [string, fn]: single lookup style\n * - [string[], fn]: multiple lookup styles\n */\nexport function normalizeHandlerDefinition(\n keyName: string,\n definition: StyleHandlerDefinition,\n): StyleHandler {\n let handler: RawStyleHandler;\n let lookupStyles: string[];\n\n if (typeof definition === 'function') {\n // Function only - lookup styles inferred from key name\n handler = definition;\n lookupStyles = [keyName];\n } else if (Array.isArray(definition)) {\n const [first, fn] = definition;\n\n if (typeof fn !== 'function') {\n throw new Error(\n `[Tasty] Invalid handler definition for \"${keyName}\". ` +\n 'Tuple must have a function as the second element: [string, function] or [string[], function].',\n );\n }\n\n handler = fn;\n\n if (typeof first === 'string') {\n // [string, fn] - single lookup style\n lookupStyles = [first];\n } else if (Array.isArray(first)) {\n // [string[], fn] - multiple lookup styles\n lookupStyles = first;\n } else {\n throw new Error(\n `[Tasty] Invalid handler definition for \"${keyName}\". ` +\n 'First element must be a string or string array.',\n );\n }\n } else {\n throw new Error(\n `[Tasty] Invalid handler definition for \"${keyName}\". ` +\n 'Expected function, [string, function], or [string[], function].',\n );\n }\n\n // Validate handler in dev mode\n validateHandler(keyName, handler, lookupStyles);\n\n // Wrap the handler to avoid mutation issues when the same function\n // is reused for multiple handler definitions. Each registration\n // gets its own function identity with its own __lookupStyles.\n const wrappedHandler = ((props) => handler(props)) as StyleHandler;\n wrappedHandler.__lookupStyles = lookupStyles;\n\n return wrappedHandler;\n}\n\n/**\n * Validate a handler definition in development mode.\n */\nfunction validateHandler(\n name: string,\n handler: RawStyleHandler,\n lookupStyles: string[],\n): void {\n if (!devMode) return;\n\n if (typeof handler !== 'function') {\n console.warn(\n `[Tasty] Handler \"${name}\" is not a function. ` +\n 'Handlers must be functions that return CSSMap, CSSMap[], or void.',\n );\n }\n\n if (\n !lookupStyles ||\n !Array.isArray(lookupStyles) ||\n lookupStyles.length === 0\n ) {\n console.warn(\n `[Tasty] Handler \"${name}\" has invalid lookupStyles. ` +\n 'Expected non-empty array of style names.',\n );\n }\n}\n\n/**\n * Validate a handler result in development mode.\n * Call this after invoking a handler to check the return value.\n */\nexport function validateHandlerResult(name: string, result: unknown): void {\n if (!devMode) return;\n if (result === undefined || result === null) return; // void is valid\n\n // Check for empty string (migration from old pattern)\n if (result === '') {\n console.warn(\n `[Tasty] Handler \"${name}\" returned empty string. ` +\n 'Return void/undefined instead for no output.',\n );\n return;\n }\n\n // Check result is object (CSSMap or CSSMap[])\n if (typeof result !== 'object') {\n console.warn(\n `[Tasty] Handler \"${name}\" returned invalid type: ${typeof result}. ` +\n 'Expected CSSMap, CSSMap[], or void.',\n );\n }\n}\n\n/**\n * Register a custom handler, replacing any existing handlers for the same lookup styles.\n * This is called by configure() to process user-defined handlers.\n *\n * When registering a handler for style X, any existing handler that processes X\n * is removed from ALL its lookup styles to prevent double-processing.\n * For example, if gapStyle handles ['display', 'flow', 'gap'] and a new handler\n * is registered for just ['gap'], gapStyle is removed from display and flow too.\n */\nexport function registerHandler(handler: StyleHandler): void {\n const lookupStyles = handler.__lookupStyles;\n\n if (!lookupStyles || lookupStyles.length === 0) {\n if (devMode) {\n console.warn(\n '[Tasty] Cannot register handler without __lookupStyles property.',\n );\n }\n return;\n }\n\n // Find and remove existing handlers that would conflict\n // A handler conflicts if it handles any of the same styles as the new handler\n const handlersToRemove = new Set<StyleHandler>();\n\n for (const styleName of lookupStyles) {\n const existing = STYLE_HANDLER_MAP[styleName];\n if (existing) {\n for (const existingHandler of existing) {\n handlersToRemove.add(existingHandler);\n }\n }\n }\n\n // Remove conflicting handlers from ALL their lookup styles\n for (const oldHandler of handlersToRemove) {\n const oldLookupStyles = oldHandler.__lookupStyles;\n if (oldLookupStyles) {\n for (const oldStyleName of oldLookupStyles) {\n const handlers = STYLE_HANDLER_MAP[oldStyleName];\n if (handlers) {\n const filtered = handlers.filter((h) => h !== oldHandler);\n if (filtered.length === 0) {\n delete STYLE_HANDLER_MAP[oldStyleName];\n } else {\n STYLE_HANDLER_MAP[oldStyleName] = filtered;\n }\n }\n }\n }\n }\n\n // Register the new handler under its lookup styles\n for (const styleName of lookupStyles) {\n const existing = STYLE_HANDLER_MAP[styleName];\n if (existing) {\n existing.push(handler);\n } else {\n STYLE_HANDLER_MAP[styleName] = [handler];\n }\n }\n}\n\n// ============================================================================\n// Wrapped Style Handlers Export\n// ============================================================================\n\n/**\n * Create a wrapped handler that can be safely called by users.\n * The wrapper preserves __lookupStyles for proper registration.\n */\nfunction wrapHandler<T extends { __lookupStyles: string[] }>(handler: T): T {\n const fn = handler as unknown as (props: unknown) => unknown;\n const wrapped = ((props: unknown) => fn(props)) as unknown as T;\n wrapped.__lookupStyles = handler.__lookupStyles;\n return wrapped;\n}\n\n/**\n * Exported object containing wrapped predefined style handlers.\n * Users can import and call these to extend or delegate to built-in behavior.\n *\n * Internal handlers use *Style suffix for searchability.\n * External API uses short names for convenience.\n *\n * @example\n * ```ts\n * import { styleHandlers, configure } from '@tenphi/tasty';\n *\n * configure({\n * handlers: {\n * fill: ({ fill }) => {\n * if (fill?.startsWith('gradient:')) {\n * return { background: fill.slice(9) };\n * }\n * return styleHandlers.fill({ fill });\n * },\n * },\n * });\n * ```\n */\nexport const styleHandlers = {\n align: wrapHandler(alignStyle),\n border: wrapHandler(borderStyle),\n color: wrapHandler(colorStyle),\n display: wrapHandler(displayStyle),\n fade: wrapHandler(fadeStyle),\n fill: wrapHandler(fillStyle),\n svgFill: wrapHandler(svgFillStyle),\n flow: wrapHandler(flowStyle),\n gap: wrapHandler(gapStyle),\n height: wrapHandler(heightStyle),\n inset: wrapHandler(insetStyle),\n justify: wrapHandler(justifyStyle),\n margin: wrapHandler(marginStyle),\n outline: wrapHandler(outlineStyle),\n padding: wrapHandler(paddingStyle),\n preset: wrapHandler(presetStyle),\n radius: wrapHandler(radiusStyle),\n scrollbar: wrapHandler(scrollbarStyle),\n shadow: wrapHandler(shadowStyle),\n styledScrollbar: wrapHandler(styledScrollbarStyle),\n transition: wrapHandler(transitionStyle),\n width: wrapHandler(widthStyle),\n} as const;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAM,UAAU,UAAU;AAU1B,MAAM,oBAAoB,QAAQ;AAChC,KAAI,OAAO,QAAQ,SACjB,QAAO,oBAAoB,OAAO,IAAI,CAAC,MAAM;;AAKjD,MAAM,iBAAiB,QAAQ;AAC7B,KAAI,OAAO,QAAQ,SACjB,QAAO,QAAQ,OAAO,IAAI,CAAC,MAAM;;AAQr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AAO,YAAY,WAAW;CAC/B"}
|
|
1
|
+
{"version":3,"file":"predefined.js","names":[],"sources":["../../src/styles/predefined.ts"],"sourcesContent":["import { isDevEnv } from '../utils/is-dev-env';\nimport type {\n RawStyleHandler,\n StyleHandler,\n StyleHandlerDefinition,\n} from '../utils/styles';\n\nimport { alignStyle } from './align';\nimport { borderStyle } from './border';\nimport { colorStyle } from './color';\nimport { createStyle } from './createStyle';\nimport { displayStyle } from './display';\nimport { fadeStyle } from './fade';\nimport { fillStyle, svgFillStyle } from './fill';\nimport { flowStyle } from './flow';\n// Note: fontStyle (font.ts) and fontStyleStyle (fontStyle.ts) removed\n// Both font and fontStyle props are now handled by presetStyle\nimport { gapStyle } from './gap';\nimport { heightStyle } from './height';\nimport { insetStyle } from './inset';\nimport { justifyStyle } from './justify';\nimport { marginStyle } from './margin';\nimport { outlineStyle } from './outline';\nimport { paddingStyle } from './padding';\nimport { presetStyle } from './preset';\nimport { radiusStyle } from './radius';\nimport { scrollbarStyle } from './scrollbar';\nimport { shadowStyle } from './shadow';\nimport { styledScrollbarStyle } from './styledScrollbar';\nimport { transitionStyle } from './transition';\nimport { widthStyle } from './width';\n\nconst devMode = isDevEnv();\n\nconst _numberConverter = (val) => {\n if (typeof val === 'number') {\n return `${val}px`;\n }\n\n return val;\n};\nconst columnsConverter = (val) => {\n if (typeof val === 'number') {\n return 'minmax(1px, 1fr) '.repeat(val).trim();\n }\n\n return;\n};\nconst rowsConverter = (val) => {\n if (typeof val === 'number') {\n return 'auto '.repeat(val).trim();\n }\n\n return;\n};\n\ntype StyleHandlerMap = Record<string, StyleHandler[]>;\n\nexport const STYLE_HANDLER_MAP: StyleHandlerMap = {};\n\n// Store initial handler state for reset functionality\nlet initialHandlerMapSnapshot: StyleHandlerMap | null = null;\n\n/**\n * Capture a snapshot of the current STYLE_HANDLER_MAP.\n * Called after predefine() to preserve built-in handler state.\n */\nfunction captureInitialHandlerState(): void {\n initialHandlerMapSnapshot = {};\n for (const key of Object.keys(STYLE_HANDLER_MAP)) {\n // Shallow copy the array - handlers themselves are immutable\n initialHandlerMapSnapshot[key] = [...STYLE_HANDLER_MAP[key]];\n }\n}\n\n/**\n * Reset STYLE_HANDLER_MAP to the initial built-in state.\n * Called by resetConfig() to restore handlers after tests.\n */\nexport function resetHandlers(): void {\n if (!initialHandlerMapSnapshot) {\n // predefine() hasn't been called yet, nothing to reset\n return;\n }\n\n // Clear current map\n for (const key of Object.keys(STYLE_HANDLER_MAP)) {\n delete STYLE_HANDLER_MAP[key];\n }\n\n // Restore initial state\n for (const key of Object.keys(initialHandlerMapSnapshot)) {\n STYLE_HANDLER_MAP[key] = [...initialHandlerMapSnapshot[key]];\n }\n}\n\nexport function defineCustomStyle(\n names: string[] | StyleHandler,\n handler?: RawStyleHandler,\n) {\n let handlerWithLookup: StyleHandler;\n\n if (typeof names === 'function') {\n handlerWithLookup = names;\n names = handlerWithLookup.__lookupStyles;\n } else if (handler) {\n handlerWithLookup = Object.assign(handler, { __lookupStyles: names });\n } else {\n console.warn('CubeUIKit: incorrect custom style definition: ', names);\n return;\n }\n\n if (Array.isArray(names)) {\n // just to pass type checking\n names.forEach((name) => {\n if (!STYLE_HANDLER_MAP[name]) {\n STYLE_HANDLER_MAP[name] = [];\n }\n\n STYLE_HANDLER_MAP[name].push(handlerWithLookup);\n });\n }\n}\n\ntype ConverterHandler = (\n s: string | boolean | number | undefined,\n) => string | undefined;\n\nexport function defineStyleAlias(\n styleName: string,\n cssStyleName?: string,\n converter?: ConverterHandler,\n) {\n const styleHandler = createStyle(styleName, cssStyleName, converter);\n\n if (!STYLE_HANDLER_MAP[styleName]) {\n STYLE_HANDLER_MAP[styleName] = [];\n }\n\n STYLE_HANDLER_MAP[styleName].push(styleHandler);\n}\n\nexport function predefine() {\n // Style aliases\n defineStyleAlias('gridAreas', 'grid-template-areas');\n defineStyleAlias('gridColumns', 'grid-template-columns', columnsConverter);\n defineStyleAlias('gridRows', 'grid-template-rows', rowsConverter);\n defineStyleAlias('gridTemplate', 'grid-template', (val) => {\n if (typeof val !== 'string') return;\n\n return val\n .split('/')\n .map((s, i) => (i ? columnsConverter : rowsConverter)(s))\n .join('/');\n });\n // Note: outlineOffset is now handled by outlineStyle\n\n [\n displayStyle,\n transitionStyle,\n fillStyle,\n svgFillStyle,\n widthStyle,\n marginStyle,\n gapStyle,\n flowStyle,\n colorStyle,\n heightStyle,\n radiusStyle,\n borderStyle,\n shadowStyle,\n paddingStyle,\n alignStyle,\n justifyStyle,\n presetStyle,\n outlineStyle,\n // DEPRECATED: `styledScrollbar` is deprecated, use `scrollbar` instead\n styledScrollbarStyle,\n scrollbarStyle,\n fadeStyle,\n insetStyle,\n ]\n // @ts-expect-error handler type varies across built-in style handlers\n .forEach((handler) => defineCustomStyle(handler));\n\n // Capture initial state after all built-in handlers are registered\n captureInitialHandlerState();\n\n return { STYLE_HANDLER_MAP, defineCustomStyle, defineStyleAlias };\n}\n\n// ============================================================================\n// Handler Registration API (for configure())\n// ============================================================================\n\n/**\n * Normalize a handler definition to a StyleHandler with __lookupStyles.\n * - Function only: lookup styles inferred from key name\n * - [string, fn]: single lookup style\n * - [string[], fn]: multiple lookup styles\n */\nexport function normalizeHandlerDefinition(\n keyName: string,\n definition: StyleHandlerDefinition,\n): StyleHandler {\n let handler: RawStyleHandler;\n let lookupStyles: string[];\n\n if (typeof definition === 'function') {\n // Function only - lookup styles inferred from key name\n handler = definition;\n lookupStyles = [keyName];\n } else if (Array.isArray(definition)) {\n const [first, fn] = definition;\n\n if (typeof fn !== 'function') {\n throw new Error(\n `[Tasty] Invalid handler definition for \"${keyName}\". ` +\n 'Tuple must have a function as the second element: [string, function] or [string[], function].',\n );\n }\n\n handler = fn;\n\n if (typeof first === 'string') {\n // [string, fn] - single lookup style\n lookupStyles = [first];\n } else if (Array.isArray(first)) {\n // [string[], fn] - multiple lookup styles\n lookupStyles = first;\n } else {\n throw new Error(\n `[Tasty] Invalid handler definition for \"${keyName}\". ` +\n 'First element must be a string or string array.',\n );\n }\n } else {\n throw new Error(\n `[Tasty] Invalid handler definition for \"${keyName}\". ` +\n 'Expected function, [string, function], or [string[], function].',\n );\n }\n\n // Validate handler in dev mode\n validateHandler(keyName, handler, lookupStyles);\n\n // Wrap the handler to avoid mutation issues when the same function\n // is reused for multiple handler definitions. Each registration\n // gets its own function identity with its own __lookupStyles.\n const wrappedHandler = ((props) => handler(props)) as StyleHandler;\n wrappedHandler.__lookupStyles = lookupStyles;\n\n return wrappedHandler;\n}\n\n/**\n * Validate a handler definition in development mode.\n */\nfunction validateHandler(\n name: string,\n handler: RawStyleHandler,\n lookupStyles: string[],\n): void {\n if (!devMode) return;\n\n if (typeof handler !== 'function') {\n console.warn(\n `[Tasty] Handler \"${name}\" is not a function. ` +\n 'Handlers must be functions that return CSSMap, CSSMap[], or void.',\n );\n }\n\n if (\n !lookupStyles ||\n !Array.isArray(lookupStyles) ||\n lookupStyles.length === 0\n ) {\n console.warn(\n `[Tasty] Handler \"${name}\" has invalid lookupStyles. ` +\n 'Expected non-empty array of style names.',\n );\n }\n}\n\n/**\n * Validate a handler result in development mode.\n * Call this after invoking a handler to check the return value.\n */\nexport function validateHandlerResult(name: string, result: unknown): void {\n if (!devMode) return;\n if (result === undefined || result === null) return; // void is valid\n\n // Check for empty string (migration from old pattern)\n if (result === '') {\n console.warn(\n `[Tasty] Handler \"${name}\" returned empty string. ` +\n 'Return void/undefined instead for no output.',\n );\n return;\n }\n\n // Check result is object (CSSMap or CSSMap[])\n if (typeof result !== 'object') {\n console.warn(\n `[Tasty] Handler \"${name}\" returned invalid type: ${typeof result}. ` +\n 'Expected CSSMap, CSSMap[], or void.',\n );\n }\n}\n\n/**\n * Register a custom handler, replacing any existing handlers for the same lookup styles.\n * This is called by configure() to process user-defined handlers.\n *\n * When registering a handler for style X, any existing handler that processes X\n * is removed from ALL its lookup styles to prevent double-processing.\n * For example, if gapStyle handles ['display', 'flow', 'gap'] and a new handler\n * is registered for just ['gap'], gapStyle is removed from display and flow too.\n */\nexport function registerHandler(handler: StyleHandler): void {\n const lookupStyles = handler.__lookupStyles;\n\n if (!lookupStyles || lookupStyles.length === 0) {\n if (devMode) {\n console.warn(\n '[Tasty] Cannot register handler without __lookupStyles property.',\n );\n }\n return;\n }\n\n // Find and remove existing handlers that would conflict\n // A handler conflicts if it handles any of the same styles as the new handler\n const handlersToRemove = new Set<StyleHandler>();\n\n for (const styleName of lookupStyles) {\n const existing = STYLE_HANDLER_MAP[styleName];\n if (existing) {\n for (const existingHandler of existing) {\n handlersToRemove.add(existingHandler);\n }\n }\n }\n\n // Remove conflicting handlers from ALL their lookup styles\n for (const oldHandler of handlersToRemove) {\n const oldLookupStyles = oldHandler.__lookupStyles;\n if (oldLookupStyles) {\n for (const oldStyleName of oldLookupStyles) {\n const handlers = STYLE_HANDLER_MAP[oldStyleName];\n if (handlers) {\n const filtered = handlers.filter((h) => h !== oldHandler);\n if (filtered.length === 0) {\n delete STYLE_HANDLER_MAP[oldStyleName];\n } else {\n STYLE_HANDLER_MAP[oldStyleName] = filtered;\n }\n }\n }\n }\n }\n\n // Register the new handler under its lookup styles\n for (const styleName of lookupStyles) {\n const existing = STYLE_HANDLER_MAP[styleName];\n if (existing) {\n existing.push(handler);\n } else {\n STYLE_HANDLER_MAP[styleName] = [handler];\n }\n }\n}\n\n// ============================================================================\n// Wrapped Style Handlers Export\n// ============================================================================\n\n/**\n * Create a wrapped handler that can be safely called by users.\n * The wrapper preserves __lookupStyles for proper registration.\n */\nfunction wrapHandler<T extends { __lookupStyles: string[] }>(handler: T): T {\n const fn = handler as unknown as (props: unknown) => unknown;\n const wrapped = ((props: unknown) => fn(props)) as unknown as T;\n wrapped.__lookupStyles = handler.__lookupStyles;\n return wrapped;\n}\n\n/**\n * Exported object containing wrapped predefined style handlers.\n * Users can import and call these to extend or delegate to built-in behavior.\n *\n * Internal handlers use *Style suffix for searchability.\n * External API uses short names for convenience.\n *\n * @example\n * ```ts\n * import { styleHandlers, configure } from '@tenphi/tasty';\n *\n * configure({\n * handlers: {\n * fill: ({ fill }) => {\n * if (fill?.startsWith('gradient:')) {\n * return { background: fill.slice(9) };\n * }\n * return styleHandlers.fill({ fill });\n * },\n * },\n * });\n * ```\n */\nexport const styleHandlers = {\n align: wrapHandler(alignStyle),\n border: wrapHandler(borderStyle),\n color: wrapHandler(colorStyle),\n display: wrapHandler(displayStyle),\n fade: wrapHandler(fadeStyle),\n fill: wrapHandler(fillStyle),\n svgFill: wrapHandler(svgFillStyle),\n flow: wrapHandler(flowStyle),\n gap: wrapHandler(gapStyle),\n height: wrapHandler(heightStyle),\n inset: wrapHandler(insetStyle),\n justify: wrapHandler(justifyStyle),\n margin: wrapHandler(marginStyle),\n outline: wrapHandler(outlineStyle),\n padding: wrapHandler(paddingStyle),\n preset: wrapHandler(presetStyle),\n radius: wrapHandler(radiusStyle),\n scrollbar: wrapHandler(scrollbarStyle),\n shadow: wrapHandler(shadowStyle),\n styledScrollbar: wrapHandler(styledScrollbarStyle),\n transition: wrapHandler(transitionStyle),\n width: wrapHandler(widthStyle),\n} as const;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAM,UAAU,UAAU;AAS1B,MAAM,oBAAoB,QAAQ;AAChC,KAAI,OAAO,QAAQ,SACjB,QAAO,oBAAoB,OAAO,IAAI,CAAC,MAAM;;AAKjD,MAAM,iBAAiB,QAAQ;AAC7B,KAAI,OAAO,QAAQ,SACjB,QAAO,QAAQ,OAAO,IAAI,CAAC,MAAM;;AAQrC,MAAa,oBAAqC,EAAE;AAGpD,IAAI,4BAAoD;;;;;AAMxD,SAAS,6BAAmC;AAC1C,6BAA4B,EAAE;AAC9B,MAAK,MAAM,OAAO,OAAO,KAAK,kBAAkB,CAE9C,2BAA0B,OAAO,CAAC,GAAG,kBAAkB,KAAK;;;;;;AAQhE,SAAgB,gBAAsB;AACpC,KAAI,CAAC,0BAEH;AAIF,MAAK,MAAM,OAAO,OAAO,KAAK,kBAAkB,CAC9C,QAAO,kBAAkB;AAI3B,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zD,QAAI,SAAS,WAAW,EACtB,QAAO,kBAAkB;QAEzB,mBAAkB,gBAAgB;;;;AAQ5C,MAAK,MAAM,aAAa,cAAc;EACpC,MAAM,WAAW,kBAAkB;AACnC,MAAI,SACF,UAAS,KAAK,QAAQ;MAEtB,mBAAkB,aAAa,CAAC,QAAQ;;;;;;;AAa9C,SAAS,YAAoD,SAAe;CAC1E,MAAM,KAAK;CACX,MAAM,YAAY,UAAmB,GAAG,MAAM;AAC9C,SAAQ,iBAAiB,QAAQ;AACjC,QAAO;;;;;;;;;;;;;;;;;;;;;;;;;AA0BT,MAAa,gBAAgB;CAC3B,OAAO,YAAY,WAAW;CAC9B,QAAQ,YAAY,YAAY;CAChC,OAAO,YAAY,WAAW;CAC9B,SAAS,YAAY,aAAa;CAClC,MAAM,YAAY,UAAU;CAC5B,MAAM,YAAY,UAAU;CAC5B,SAAS,YAAY,aAAa;CAClC,MAAM,YAAY,UAAU;CAC5B,KAAK,YAAY,SAAS;CAC1B,QAAQ,YAAY,YAAY;CAChC,OAAO,YAAY,WAAW;CAC9B,SAAS,YAAY,aAAa;CAClC,QAAQ,YAAY,YAAY;CAChC,SAAS,YAAY,aAAa;CAClC,SAAS,YAAY,aAAa;CAClC,QAAQ,YAAY,YAAY;CAChC,QAAQ,YAAY,YAAY;CAChC,WAAW,YAAY,eAAe;CACtC,QAAQ,YAAY,YAAY;CAChC,iBAAiB,YAAY,qBAAqB;CAClD,YAAY,YAAY,gBAAgB;CACxC,OAAO,YAAY,WAAW;CAC/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radius.js","names":[],"sources":["../../src/styles/radius.ts"],"sourcesContent":["import { makeEmptyDetails } from '../parser/types';\nimport { DIRECTIONS, parseStyle } from '../utils/styles';\n\nconst PROP = 'var(--radius)';\nconst SHARP = 'var(--sharp-radius)';\n\nexport function radiusStyle({ radius }) {\n if (typeof radius === 'number') {\n radius = `${radius}px`;\n }\n\n if (!radius) return;\n\n if (radius === true) radius = '1r';\n\n const processed = parseStyle(radius);\n const { mods }
|
|
1
|
+
{"version":3,"file":"radius.js","names":[],"sources":["../../src/styles/radius.ts"],"sourcesContent":["import { makeEmptyDetails } from '../parser/types';\nimport { DIRECTIONS, parseStyle } from '../utils/styles';\n\nconst PROP = 'var(--radius)';\nconst SHARP = 'var(--sharp-radius)';\n\nexport function radiusStyle({ radius }) {\n if (typeof radius === 'number') {\n radius = `${radius}px`;\n }\n\n if (!radius) return;\n\n if (radius === true) radius = '1r';\n\n const processed = parseStyle(radius);\n const { mods } = processed.groups[0] ?? makeEmptyDetails();\n let { values } = processed.groups[0] ?? makeEmptyDetails();\n\n if (mods.includes('round')) {\n values = ['9999rem'];\n } else if (mods.includes('ellipse')) {\n values = ['50%'];\n } else if (!values.length) {\n values = [PROP];\n }\n\n if (mods.includes('leaf')) {\n values = [\n values[1] || SHARP,\n values[0] || PROP,\n values[1] || SHARP,\n values[0] || PROP,\n ];\n } else if (mods.includes('backleaf')) {\n values = [\n values[0] || PROP,\n values[1] || SHARP,\n values[0] || PROP,\n values[1] || SHARP,\n ];\n } else if (mods.length) {\n const arr = ['0', '0', '0', '0'];\n\n let flag = false;\n\n DIRECTIONS.forEach((dir, i) => {\n if (!mods.includes(dir)) return;\n\n flag = true;\n\n arr[i] = values[0] || PROP;\n arr[(i + 1) % 4] = values[0] || PROP;\n });\n\n if (flag) {\n values = arr;\n }\n }\n\n return {\n 'border-radius': values.join(' '),\n };\n}\n\nradiusStyle.__lookupStyles = ['radius'];\n"],"mappings":";;;;AAGA,MAAM,OAAO;AACb,MAAM,QAAQ;AAEd,SAAgB,YAAY,EAAE,UAAU;AACtC,KAAI,OAAO,WAAW,SACpB,UAAS,GAAG,OAAO;AAGrB,KAAI,CAAC,OAAQ;AAEb,KAAI,WAAW,KAAM,UAAS;CAE9B,MAAM,YAAY,WAAW,OAAO;CACpC,MAAM,EAAE,SAAS,UAAU,OAAO,MAAM,kBAAkB;CAC1D,IAAI,EAAE,WAAW,UAAU,OAAO,MAAM,kBAAkB;AAE1D,KAAI,KAAK,SAAS,QAAQ,CACxB,UAAS,CAAC,UAAU;UACX,KAAK,SAAS,UAAU,CACjC,UAAS,CAAC,MAAM;UACP,CAAC,OAAO,OACjB,UAAS,CAAC,KAAK;AAGjB,KAAI,KAAK,SAAS,OAAO,CACvB,UAAS;EACP,OAAO,MAAM;EACb,OAAO,MAAM;EACb,OAAO,MAAM;EACb,OAAO,MAAM;EACd;UACQ,KAAK,SAAS,WAAW,CAClC,UAAS;EACP,OAAO,MAAM;EACb,OAAO,MAAM;EACb,OAAO,MAAM;EACb,OAAO,MAAM;EACd;UACQ,KAAK,QAAQ;EACtB,MAAM,MAAM;GAAC;GAAK;GAAK;GAAK;GAAI;EAEhC,IAAI,OAAO;AAEX,aAAW,SAAS,KAAK,MAAM;AAC7B,OAAI,CAAC,KAAK,SAAS,IAAI,CAAE;AAEzB,UAAO;AAEP,OAAI,KAAK,OAAO,MAAM;AACtB,QAAK,IAAI,KAAK,KAAK,OAAO,MAAM;IAChC;AAEF,MAAI,KACF,UAAS;;AAIb,QAAO,EACL,iBAAiB,OAAO,KAAK,IAAI,EAClC;;AAGH,YAAY,iBAAiB,CAAC,SAAS"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scrollbar.js","names":[],"sources":["../../src/styles/scrollbar.ts"],"sourcesContent":["import { makeEmptyDetails } from '../parser/types';\nimport { parseStyle } from '../utils/styles';\n\ninterface ScrollbarStyleProps {\n scrollbar?: string | boolean | number;\n overflow?: string;\n}\n\n/**\n * Creates cross-browser compatible scrollbar styles\n *\n * Supports both Firefox (scrollbar-width, scrollbar-color) and\n * WebKit/Chromium browsers (::-webkit-scrollbar)\n */\nexport function scrollbarStyle({ scrollbar, overflow }: ScrollbarStyleProps) {\n // Check if scrollbar is defined\n if (!scrollbar && scrollbar !== 0) return;\n\n // Support true as alias for thin\n const value = scrollbar === true || scrollbar === '' ? 'thin' : scrollbar;\n const processed = parseStyle(String(value));\n const { mods, colors, values }
|
|
1
|
+
{"version":3,"file":"scrollbar.js","names":[],"sources":["../../src/styles/scrollbar.ts"],"sourcesContent":["import { makeEmptyDetails } from '../parser/types';\nimport { parseStyle } from '../utils/styles';\n\ninterface ScrollbarStyleProps {\n scrollbar?: string | boolean | number;\n overflow?: string;\n}\n\n/**\n * Creates cross-browser compatible scrollbar styles\n *\n * Supports both Firefox (scrollbar-width, scrollbar-color) and\n * WebKit/Chromium browsers (::-webkit-scrollbar)\n */\nexport function scrollbarStyle({ scrollbar, overflow }: ScrollbarStyleProps) {\n // Check if scrollbar is defined\n if (!scrollbar && scrollbar !== 0) return;\n\n // Support true as alias for thin\n const value = scrollbar === true || scrollbar === '' ? 'thin' : scrollbar;\n const processed = parseStyle(String(value));\n const { mods, colors, values } = processed.groups[0] ?? makeEmptyDetails();\n const style = {};\n\n // Default colors for scrollbar\n const defaultThumbColor = 'var(--scrollbar-thumb-color)';\n const defaultTrackColor = 'var(--scrollbar-track-color, transparent)';\n\n // Setup default Firefox scrollbar style\n style['scrollbar-color'] = `${defaultThumbColor} transparent`;\n\n // Default scrollbar size\n const defaultSize = '8px';\n const sizeValue = values[0] || defaultSize;\n\n // Process modifiers\n if (mods.includes('thin')) {\n style['scrollbar-width'] = 'thin';\n } else if (mods.includes('none')) {\n style['scrollbar-width'] = 'none';\n // Remove scrollbar-color as it's not needed when scrollbar is hidden\n delete style['scrollbar-color'];\n // Also hide WebKit scrollbars\n style['&::-webkit-scrollbar'] = {\n width: '0px',\n height: '0px',\n display: 'none',\n };\n\n return style;\n } else if (mods.includes('auto')) {\n style['scrollbar-width'] = 'auto';\n }\n\n // Handle scrollbar gutter behavior\n if (mods.includes('stable') || mods.includes('both-edges')) {\n // scrollbar-gutter is supported in newer browsers only\n style['scrollbar-gutter'] = mods.includes('both-edges')\n ? 'stable both-edges'\n : 'stable';\n }\n\n // Custom size setup for WebKit\n if (sizeValue) {\n style['&::-webkit-scrollbar'] = {\n ...(style['&::-webkit-scrollbar'] || {}),\n width: sizeValue,\n height: sizeValue,\n };\n }\n\n // Extract colors (support up to 3: thumb, track, corner)\n // These will be used in various places throughout the function\n const thumbColor = colors && colors[0] ? colors[0] : defaultThumbColor;\n const trackColor = colors && colors[1] ? colors[1] : defaultTrackColor;\n const cornerColor = colors && colors[2] ? colors[2] : trackColor;\n\n // Apply colors if they are specified\n if (colors && colors.length) {\n // Firefox\n style['scrollbar-color'] = `${thumbColor} ${trackColor}`;\n\n // WebKit - always set these for consistency\n if (!style['&::-webkit-scrollbar']) {\n style['&::-webkit-scrollbar'] = {};\n }\n style['&::-webkit-scrollbar']['background'] = trackColor;\n\n style['&::-webkit-scrollbar-track'] = {\n ...(style['&::-webkit-scrollbar-track'] || {}),\n background: trackColor,\n };\n\n style['&::-webkit-scrollbar-thumb'] = {\n ...(style['&::-webkit-scrollbar-thumb'] || {}),\n background: thumbColor,\n };\n\n style['&::-webkit-scrollbar-corner'] = {\n ...(style['&::-webkit-scrollbar-corner'] || {}),\n background: cornerColor,\n };\n }\n\n // Handle 'always' mode: force scrollbars to show\n if (mods.includes('always')) {\n style['overflow'] = overflow || 'scroll';\n\n // Use auto for WebKit browsers since they don't support 'always'\n // This is closer to the expected behavior\n if (!style['scrollbar-gutter']) {\n style['scrollbar-gutter'] = 'stable';\n }\n\n // Ensure scrollbars appear in WebKit even with little content\n if (!style['&::-webkit-scrollbar']) {\n style['&::-webkit-scrollbar'] = {};\n }\n style['&::-webkit-scrollbar']['display'] = 'block';\n }\n\n // Enhanced 'styled' mode with better transitions and appearance\n if (mods.includes('styled')) {\n const baseTransition = [\n 'background var(--transition)',\n 'border-radius var(--transition)',\n 'box-shadow var(--transition)',\n 'width var(--transition)',\n 'height var(--transition)',\n 'border var(--transition)',\n ].join(', ');\n\n // Firefox\n style['scrollbar-width'] = style['scrollbar-width'] || 'thin';\n style['scrollbar-color'] =\n style['scrollbar-color'] || `${defaultThumbColor} ${defaultTrackColor}`;\n\n // WebKit\n style['&::-webkit-scrollbar'] = {\n width: sizeValue,\n height: sizeValue,\n transition: baseTransition,\n background: defaultTrackColor,\n ...(style['&::-webkit-scrollbar'] || {}),\n };\n\n style['&::-webkit-scrollbar-thumb'] = {\n 'border-radius': '8px',\n 'min-height': '24px',\n transition: baseTransition,\n background: defaultThumbColor,\n ...(style['&::-webkit-scrollbar-thumb'] || {}),\n };\n\n style['&::-webkit-scrollbar-track'] = {\n background: defaultTrackColor,\n transition: baseTransition,\n ...(style['&::-webkit-scrollbar-track'] || {}),\n };\n\n style['&::-webkit-scrollbar-corner'] = {\n background: defaultTrackColor,\n transition: baseTransition,\n ...(style['&::-webkit-scrollbar-corner'] || {}),\n };\n }\n\n return style;\n}\n\nscrollbarStyle.__lookupStyles = ['scrollbar', 'overflow'];\n"],"mappings":";;;;;;;;;;AAcA,SAAgB,eAAe,EAAE,WAAW,YAAiC;AAE3E,KAAI,CAAC,aAAa,cAAc,EAAG;CAGnC,MAAM,QAAQ,cAAc,QAAQ,cAAc,KAAK,SAAS;CAEhE,MAAM,EAAE,MAAM,QAAQ,WADJ,WAAW,OAAO,MAAM,CAAC,CACA,OAAO,MAAM,kBAAkB;CAC1E,MAAM,QAAQ,EAAE;CAGhB,MAAM,oBAAoB;CAC1B,MAAM,oBAAoB;AAG1B,OAAM,qBAAqB,GAAG,kBAAkB;CAIhD,MAAM,YAAY,OAAO,MADL;AAIpB,KAAI,KAAK,SAAS,OAAO,CACvB,OAAM,qBAAqB;UAClB,KAAK,SAAS,OAAO,EAAE;AAChC,QAAM,qBAAqB;AAE3B,SAAO,MAAM;AAEb,QAAM,0BAA0B;GAC9B,OAAO;GACP,QAAQ;GACR,SAAS;GACV;AAED,SAAO;YACE,KAAK,SAAS,OAAO,CAC9B,OAAM,qBAAqB;AAI7B,KAAI,KAAK,SAAS,SAAS,IAAI,KAAK,SAAS,aAAa,CAExD,OAAM,sBAAsB,KAAK,SAAS,aAAa,GACnD,sBACA;AAIN,KAAI,UACF,OAAM,0BAA0B;EAC9B,GAAI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AAiC,EAAE;GAC9C;AAED,QAAM,iCAAiC;GACrC,YAAY;GACZ,YAAY;GACZ,GAAI,MAAM,kCAAkC,EAAE;GAC/C;;AAGH,QAAO;;AAGT,eAAe,iBAAiB,CAAC,aAAa,WAAW"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shadow.js","names":[],"sources":["../../src/styles/shadow.ts"],"sourcesContent":["import { makeEmptyDetails } from '../parser/types';\nimport { parseStyle } from '../utils/styles';\n\nfunction toBoxShadow(shadow) {\n const processed = parseStyle(shadow);\n const { values, mods, colors }
|
|
1
|
+
{"version":3,"file":"shadow.js","names":[],"sources":["../../src/styles/shadow.ts"],"sourcesContent":["import { makeEmptyDetails } from '../parser/types';\nimport { parseStyle } from '../utils/styles';\n\nfunction toBoxShadow(shadow) {\n const processed = parseStyle(shadow);\n const { values, mods, colors } = processed.groups[0] ?? makeEmptyDetails();\n const mod = mods[0] || '';\n const shadowColor = (colors && colors[0]) ?? '';\n\n return [mod, ...values, shadowColor].join(' ');\n}\n\nexport function shadowStyle({ shadow }) {\n if (!shadow) return;\n\n if (shadow === true) shadow = 'var(--shadow)';\n\n return {\n 'box-shadow': shadow.split(',').map(toBoxShadow).join(','),\n };\n}\n\nshadowStyle.__lookupStyles = ['shadow'];\n"],"mappings":";;;;AAGA,SAAS,YAAY,QAAQ;CAE3B,MAAM,EAAE,QAAQ,MAAM,WADJ,WAAW,OAAO,CACO,OAAO,MAAM,kBAAkB;CAC1E,MAAM,MAAM,KAAK,MAAM;CACvB,MAAM,eAAe,UAAU,OAAO,OAAO;AAE7C,QAAO;EAAC;EAAK,GAAG;EAAQ;EAAY,CAAC,KAAK,IAAI;;AAGhD,SAAgB,YAAY,EAAE,UAAU;AACtC,KAAI,CAAC,OAAQ;AAEb,KAAI,WAAW,KAAM,UAAS;AAE9B,QAAO,EACL,cAAc,OAAO,MAAM,IAAI,CAAC,IAAI,YAAY,CAAC,KAAK,IAAI,EAC3D;;AAGH,YAAY,iBAAiB,CAAC,SAAS"}
|