@tenphi/tasty 0.0.0-snapshot.08a6610
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/LICENSE +21 -0
- package/README.md +666 -0
- package/dist/_virtual/_rolldown/runtime.js +8 -0
- package/dist/chunks/cacheKey.js +70 -0
- package/dist/chunks/cacheKey.js.map +1 -0
- package/dist/chunks/definitions.d.ts +37 -0
- package/dist/chunks/definitions.js +259 -0
- package/dist/chunks/definitions.js.map +1 -0
- package/dist/chunks/renderChunk.js +61 -0
- package/dist/chunks/renderChunk.js.map +1 -0
- package/dist/config.d.ts +311 -0
- package/dist/config.js +458 -0
- package/dist/config.js.map +1 -0
- package/dist/core/index.d.ts +32 -0
- package/dist/core/index.js +26 -0
- package/dist/debug.d.ts +204 -0
- package/dist/debug.js +733 -0
- package/dist/debug.js.map +1 -0
- package/dist/hooks/useGlobalStyles.d.ts +30 -0
- package/dist/hooks/useGlobalStyles.js +83 -0
- package/dist/hooks/useGlobalStyles.js.map +1 -0
- package/dist/hooks/useKeyframes.d.ts +56 -0
- package/dist/hooks/useKeyframes.js +69 -0
- package/dist/hooks/useKeyframes.js.map +1 -0
- package/dist/hooks/useProperty.d.ts +79 -0
- package/dist/hooks/useProperty.js +114 -0
- package/dist/hooks/useProperty.js.map +1 -0
- package/dist/hooks/useRawCSS.d.ts +53 -0
- package/dist/hooks/useRawCSS.js +40 -0
- package/dist/hooks/useRawCSS.js.map +1 -0
- package/dist/hooks/useStyles.d.ts +45 -0
- package/dist/hooks/useStyles.js +248 -0
- package/dist/hooks/useStyles.js.map +1 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.js +33 -0
- package/dist/injector/index.d.ts +165 -0
- package/dist/injector/index.js +162 -0
- package/dist/injector/index.js.map +1 -0
- package/dist/injector/injector.d.ts +148 -0
- package/dist/injector/injector.js +430 -0
- package/dist/injector/injector.js.map +1 -0
- package/dist/injector/sheet-manager.d.ts +136 -0
- package/dist/injector/sheet-manager.js +729 -0
- package/dist/injector/sheet-manager.js.map +1 -0
- package/dist/injector/types.d.ts +144 -0
- package/dist/keyframes/index.js +206 -0
- package/dist/keyframes/index.js.map +1 -0
- package/dist/parser/classify.js +319 -0
- package/dist/parser/classify.js.map +1 -0
- package/dist/parser/const.js +33 -0
- package/dist/parser/const.js.map +1 -0
- package/dist/parser/lru.js +109 -0
- package/dist/parser/lru.js.map +1 -0
- package/dist/parser/parser.d.ts +25 -0
- package/dist/parser/parser.js +116 -0
- package/dist/parser/parser.js.map +1 -0
- package/dist/parser/tokenizer.js +69 -0
- package/dist/parser/tokenizer.js.map +1 -0
- package/dist/parser/types.d.ts +51 -0
- package/dist/parser/types.js +46 -0
- package/dist/parser/types.js.map +1 -0
- package/dist/pipeline/conditions.d.ts +134 -0
- package/dist/pipeline/conditions.js +406 -0
- package/dist/pipeline/conditions.js.map +1 -0
- package/dist/pipeline/exclusive.js +231 -0
- package/dist/pipeline/exclusive.js.map +1 -0
- package/dist/pipeline/index.d.ts +53 -0
- package/dist/pipeline/index.js +660 -0
- package/dist/pipeline/index.js.map +1 -0
- package/dist/pipeline/materialize.js +856 -0
- package/dist/pipeline/materialize.js.map +1 -0
- package/dist/pipeline/parseStateKey.d.ts +15 -0
- package/dist/pipeline/parseStateKey.js +451 -0
- package/dist/pipeline/parseStateKey.js.map +1 -0
- package/dist/pipeline/simplify.js +516 -0
- package/dist/pipeline/simplify.js.map +1 -0
- package/dist/pipeline/warnings.js +18 -0
- package/dist/pipeline/warnings.js.map +1 -0
- package/dist/plugins/okhsl-plugin.d.ts +35 -0
- package/dist/plugins/okhsl-plugin.js +371 -0
- package/dist/plugins/okhsl-plugin.js.map +1 -0
- package/dist/plugins/types.d.ts +76 -0
- package/dist/properties/index.js +236 -0
- package/dist/properties/index.js.map +1 -0
- package/dist/properties/property-type-resolver.d.ts +24 -0
- package/dist/properties/property-type-resolver.js +91 -0
- package/dist/properties/property-type-resolver.js.map +1 -0
- package/dist/ssr/astro.d.ts +29 -0
- package/dist/ssr/astro.js +65 -0
- package/dist/ssr/astro.js.map +1 -0
- package/dist/ssr/async-storage.d.ts +17 -0
- package/dist/ssr/async-storage.js +35 -0
- package/dist/ssr/async-storage.js.map +1 -0
- package/dist/ssr/collect-auto-properties.js +40 -0
- package/dist/ssr/collect-auto-properties.js.map +1 -0
- package/dist/ssr/collector.d.ts +85 -0
- package/dist/ssr/collector.js +183 -0
- package/dist/ssr/collector.js.map +1 -0
- package/dist/ssr/context.d.ts +8 -0
- package/dist/ssr/context.js +14 -0
- package/dist/ssr/context.js.map +1 -0
- package/dist/ssr/format-global-rules.js +22 -0
- package/dist/ssr/format-global-rules.js.map +1 -0
- package/dist/ssr/format-keyframes.js +70 -0
- package/dist/ssr/format-keyframes.js.map +1 -0
- package/dist/ssr/format-property.js +48 -0
- package/dist/ssr/format-property.js.map +1 -0
- package/dist/ssr/format-rules.js +70 -0
- package/dist/ssr/format-rules.js.map +1 -0
- package/dist/ssr/hydrate.d.ts +22 -0
- package/dist/ssr/hydrate.js +50 -0
- package/dist/ssr/hydrate.js.map +1 -0
- package/dist/ssr/index.d.ts +5 -0
- package/dist/ssr/index.js +12 -0
- package/dist/ssr/index.js.map +1 -0
- package/dist/ssr/next.d.ts +45 -0
- package/dist/ssr/next.js +71 -0
- package/dist/ssr/next.js.map +1 -0
- package/dist/ssr/ssr-collector-ref.js +12 -0
- package/dist/ssr/ssr-collector-ref.js.map +1 -0
- package/dist/states/index.d.ts +49 -0
- package/dist/states/index.js +416 -0
- package/dist/states/index.js.map +1 -0
- package/dist/static/index.d.ts +5 -0
- package/dist/static/index.js +5 -0
- package/dist/static/tastyStatic.d.ts +46 -0
- package/dist/static/tastyStatic.js +31 -0
- package/dist/static/tastyStatic.js.map +1 -0
- package/dist/static/types.d.ts +49 -0
- package/dist/static/types.js +24 -0
- package/dist/static/types.js.map +1 -0
- package/dist/styles/align.d.ts +15 -0
- package/dist/styles/align.js +14 -0
- package/dist/styles/align.js.map +1 -0
- package/dist/styles/border.d.ts +25 -0
- package/dist/styles/border.js +114 -0
- package/dist/styles/border.js.map +1 -0
- package/dist/styles/color.d.ts +14 -0
- package/dist/styles/color.js +23 -0
- package/dist/styles/color.js.map +1 -0
- package/dist/styles/createStyle.js +77 -0
- package/dist/styles/createStyle.js.map +1 -0
- package/dist/styles/dimension.js +97 -0
- package/dist/styles/dimension.js.map +1 -0
- package/dist/styles/display.d.ts +37 -0
- package/dist/styles/display.js +67 -0
- package/dist/styles/display.js.map +1 -0
- package/dist/styles/fade.d.ts +15 -0
- package/dist/styles/fade.js +58 -0
- package/dist/styles/fade.js.map +1 -0
- package/dist/styles/fill.d.ts +42 -0
- package/dist/styles/fill.js +52 -0
- package/dist/styles/fill.js.map +1 -0
- package/dist/styles/flow.d.ts +16 -0
- package/dist/styles/flow.js +12 -0
- package/dist/styles/flow.js.map +1 -0
- package/dist/styles/gap.d.ts +31 -0
- package/dist/styles/gap.js +37 -0
- package/dist/styles/gap.js.map +1 -0
- package/dist/styles/height.d.ts +17 -0
- package/dist/styles/height.js +20 -0
- package/dist/styles/height.js.map +1 -0
- package/dist/styles/index.d.ts +2 -0
- package/dist/styles/index.js +9 -0
- package/dist/styles/index.js.map +1 -0
- package/dist/styles/inset.d.ts +52 -0
- package/dist/styles/inset.js +150 -0
- package/dist/styles/inset.js.map +1 -0
- package/dist/styles/justify.d.ts +15 -0
- package/dist/styles/justify.js +14 -0
- package/dist/styles/justify.js.map +1 -0
- package/dist/styles/list.d.ts +16 -0
- package/dist/styles/list.js +98 -0
- package/dist/styles/list.js.map +1 -0
- package/dist/styles/margin.d.ts +24 -0
- package/dist/styles/margin.js +104 -0
- package/dist/styles/margin.js.map +1 -0
- package/dist/styles/outline.d.ts +29 -0
- package/dist/styles/outline.js +65 -0
- package/dist/styles/outline.js.map +1 -0
- package/dist/styles/padding.d.ts +24 -0
- package/dist/styles/padding.js +104 -0
- package/dist/styles/padding.js.map +1 -0
- package/dist/styles/predefined.d.ts +71 -0
- package/dist/styles/predefined.js +238 -0
- package/dist/styles/predefined.js.map +1 -0
- package/dist/styles/preset.d.ts +47 -0
- package/dist/styles/preset.js +126 -0
- package/dist/styles/preset.js.map +1 -0
- package/dist/styles/radius.d.ts +14 -0
- package/dist/styles/radius.js +51 -0
- package/dist/styles/radius.js.map +1 -0
- package/dist/styles/scrollbar.d.ts +25 -0
- package/dist/styles/scrollbar.js +48 -0
- package/dist/styles/scrollbar.js.map +1 -0
- package/dist/styles/shadow.d.ts +14 -0
- package/dist/styles/shadow.js +24 -0
- package/dist/styles/shadow.js.map +1 -0
- package/dist/styles/transition.d.ts +14 -0
- package/dist/styles/transition.js +158 -0
- package/dist/styles/transition.js.map +1 -0
- package/dist/styles/types.d.ts +508 -0
- package/dist/styles/width.d.ts +17 -0
- package/dist/styles/width.js +20 -0
- package/dist/styles/width.js.map +1 -0
- package/dist/tasty.d.ts +981 -0
- package/dist/tasty.js +206 -0
- package/dist/tasty.js.map +1 -0
- package/dist/types.d.ts +184 -0
- package/dist/utils/cache-wrapper.js +26 -0
- package/dist/utils/cache-wrapper.js.map +1 -0
- package/dist/utils/case-converter.js +8 -0
- package/dist/utils/case-converter.js.map +1 -0
- package/dist/utils/colors.d.ts +5 -0
- package/dist/utils/colors.js +9 -0
- package/dist/utils/colors.js.map +1 -0
- package/dist/utils/css-types.d.ts +7 -0
- package/dist/utils/dotize.d.ts +26 -0
- package/dist/utils/dotize.js +122 -0
- package/dist/utils/dotize.js.map +1 -0
- package/dist/utils/filter-base-props.d.ts +15 -0
- package/dist/utils/filter-base-props.js +45 -0
- package/dist/utils/filter-base-props.js.map +1 -0
- package/dist/utils/get-display-name.d.ts +7 -0
- package/dist/utils/get-display-name.js +10 -0
- package/dist/utils/get-display-name.js.map +1 -0
- package/dist/utils/hsl-to-rgb.js +38 -0
- package/dist/utils/hsl-to-rgb.js.map +1 -0
- package/dist/utils/is-dev-env.js +19 -0
- package/dist/utils/is-dev-env.js.map +1 -0
- package/dist/utils/is-valid-element-type.js +15 -0
- package/dist/utils/is-valid-element-type.js.map +1 -0
- package/dist/utils/merge-styles.d.ts +7 -0
- package/dist/utils/merge-styles.js +146 -0
- package/dist/utils/merge-styles.js.map +1 -0
- package/dist/utils/mod-attrs.d.ts +8 -0
- package/dist/utils/mod-attrs.js +21 -0
- package/dist/utils/mod-attrs.js.map +1 -0
- package/dist/utils/okhsl-to-rgb.js +296 -0
- package/dist/utils/okhsl-to-rgb.js.map +1 -0
- package/dist/utils/process-tokens.d.ts +31 -0
- package/dist/utils/process-tokens.js +171 -0
- package/dist/utils/process-tokens.js.map +1 -0
- package/dist/utils/resolve-recipes.d.ts +17 -0
- package/dist/utils/resolve-recipes.js +147 -0
- package/dist/utils/resolve-recipes.js.map +1 -0
- package/dist/utils/selector-transform.js +32 -0
- package/dist/utils/selector-transform.js.map +1 -0
- package/dist/utils/string.js +8 -0
- package/dist/utils/string.js.map +1 -0
- package/dist/utils/styles.d.ts +177 -0
- package/dist/utils/styles.js +730 -0
- package/dist/utils/styles.js.map +1 -0
- package/dist/utils/typography.d.ts +47 -0
- package/dist/utils/typography.js +43 -0
- package/dist/utils/typography.js.map +1 -0
- package/dist/utils/warnings.d.ts +16 -0
- package/dist/utils/warnings.js +16 -0
- package/dist/utils/warnings.js.map +1 -0
- package/dist/zero/babel.d.ts +147 -0
- package/dist/zero/babel.js +331 -0
- package/dist/zero/babel.js.map +1 -0
- package/dist/zero/css-writer.d.ts +45 -0
- package/dist/zero/css-writer.js +74 -0
- package/dist/zero/css-writer.js.map +1 -0
- package/dist/zero/extractor.d.ts +24 -0
- package/dist/zero/extractor.js +215 -0
- package/dist/zero/extractor.js.map +1 -0
- package/dist/zero/index.d.ts +3 -0
- package/dist/zero/index.js +4 -0
- package/dist/zero/next.d.ts +74 -0
- package/dist/zero/next.js +129 -0
- package/dist/zero/next.js.map +1 -0
- package/docs/adoption.md +286 -0
- package/docs/comparison.md +413 -0
- package/docs/configuration.md +242 -0
- package/docs/debug.md +505 -0
- package/docs/design-system.md +401 -0
- package/docs/dsl.md +540 -0
- package/docs/getting-started.md +201 -0
- package/docs/injector.md +528 -0
- package/docs/methodology.md +501 -0
- package/docs/runtime.md +291 -0
- package/docs/ssr.md +382 -0
- package/docs/styles.md +574 -0
- package/docs/tasty-static.md +421 -0
- package/package.json +209 -0
- package/tasty.config.ts +14 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.js","names":[],"sources":["../../src/utils/styles.ts"],"sourcesContent":["import { StyleParser } from '../parser/parser';\nimport { okhslFunc } from '../plugins/okhsl-plugin';\nimport { createStateParserContext, parseAdvancedState } from '../states';\nimport type { Styles } from '../styles/types';\n\nimport { cacheWrapper } from './cache-wrapper';\nimport { camelToKebab } from './case-converter';\nimport { hslToRgb } from './hsl-to-rgb';\nimport { okhslToRgb } from './okhsl-to-rgb';\n\nimport type { ProcessedStyle, StyleDetails } from '../parser/types';\nimport type {\n AtRuleContext,\n ParsedAdvancedState,\n StateParserContext,\n} from '../states';\n\nexport type StyleValue<T = string> = T | boolean | number | null | undefined;\n\n/**\n * Normalize a color token value.\n * - Boolean `true` is converted to `'transparent'`\n * - Boolean `false` returns `null` (signals the token should be skipped)\n * - Other values are returned as-is\n *\n * @param value - The raw token value\n * @returns Normalized value or null if the token should be skipped\n */\nexport function normalizeColorTokenValue<T>(\n value: T | boolean,\n): T | 'transparent' | null {\n if (value === true) {\n return 'transparent';\n }\n if (value === false) {\n return null;\n }\n return value as T;\n}\n\nexport type StyleValueStateMap<T = string> = Record<\n string,\n StyleValue<T> | '@inherit'\n>;\n\n/**\n * Combined type for style values that can be either a direct value or a state map.\n * Use this for component props that accept style values.\n */\nexport type StylePropValue<T = string> = StyleValue<T> | StyleValueStateMap<T>;\n\nexport type ComputeModel = string | number;\n\nexport type CSSMap = { $?: string | string[] } & Record<\n string,\n string | string[]\n>;\n\nexport type StyleHandlerResult = CSSMap | CSSMap[] | void;\n\nexport type RawStyleHandler = (value: StyleValueStateMap) => StyleHandlerResult;\n\nexport type StyleHandler = RawStyleHandler & {\n __lookupStyles: string[];\n};\n\n/**\n * Handler definition forms for configure() and plugins.\n * - Function only: lookup styles inferred from key name\n * - Single property tuple: ['styleName', handler]\n * - Multi-property tuple: [['style1', 'style2'], handler]\n */\nexport type StyleHandlerDefinition =\n | RawStyleHandler\n | [string, RawStyleHandler]\n | [string[], RawStyleHandler];\n\nexport interface StyleStateData {\n model?: ComputeModel;\n tokens?: string[];\n value: StyleValue | StyleValueStateMap | StyleStateData;\n /** The list of mods to apply */\n mods: string[];\n /** The list of **not** mods to apply (e.g. `:not(:hover)`) */\n notMods: string[];\n /** Advanced states (media queries, container queries, etc.) */\n advancedStates?: ParsedAdvancedState[];\n /** At-rule context for CSS generation */\n atRuleContext?: AtRuleContext;\n /** Own mods for sub-element states (from @own()) - applied to sub-element selector */\n ownMods?: string[];\n /** Negated own mods for sub-element states */\n negatedOwnMods?: string[];\n}\n\nexport interface ParsedColor {\n color?: string;\n name?: string;\n opacity?: number;\n}\n\nexport type StyleStateDataList = StyleStateData[];\n\nexport type StyleStateDataListMap = Record<string, StyleStateDataList>;\n\nexport type StyleMap = Record<string, StyleValue | StyleValueStateMap>;\n\nexport type StyleStateMap = Record<string, StyleStateData>;\n\nconst devMode = process.env.NODE_ENV !== 'production';\n\n// Precompiled regex patterns for parseColor optimization\n// Match var(--name-color...) and extract the name, regardless of fallbacks\nconst COLOR_VAR_PATTERN = /var\\(--([a-z0-9-]+)-color/;\nconst COLOR_VAR_RGB_PATTERN = /var\\(--([a-z0-9-]+)-color-rgb/;\nconst RGB_ALPHA_PATTERN = /\\/\\s*([0-9.]+)\\)/;\nconst SIMPLE_COLOR_PATTERNS = [\n /^#[0-9a-fA-F]{3,8}$/, // Hex colors: #fff, #ffffff, #ffff, #ffffffff\n /^rgb\\(/, // RGB/RGBA functions\n /^hsl\\(/, // HSL/HSLA functions\n /^lch\\(/, // LCH color functions\n /^oklch\\(/, // OKLCH color functions\n /^okhsl\\(/, // OKHSL color functions\n /^var\\(--[a-z0-9-]+-color/, // CSS custom properties for colors\n /^currentColor$/, // CSS currentColor keyword\n /^transparent$/, // CSS transparent keyword\n];\n\n// Rate limiting for dev warnings to avoid spam\nlet colorWarningCount = 0;\nconst MAX_COLOR_WARNINGS = 10;\n\nexport const CUSTOM_UNITS = {\n r: '6px',\n cr: '10px',\n bw: '1px',\n ow: '3px',\n x: '8px',\n fs: 'var(--font-size)',\n lh: 'var(--line-height)',\n sf: function sf(num: number) {\n return `minmax(0, ${num}fr)`;\n },\n};\n\nexport const DIRECTIONS = ['top', 'right', 'bottom', 'left'];\n\n// Lazy-initialized to break the circular dependency:\n// parser.ts → classify.ts → utils/styles.ts → parser.ts\nlet __tastyParser: StyleParser | null = null;\n\nfunction getOrCreateParser(): StyleParser {\n if (!__tastyParser) {\n __tastyParser = new StyleParser({ units: CUSTOM_UNITS });\n __tastyParser.setFuncs(__tastyFuncs);\n }\n return __tastyParser;\n}\n\n// Registry for user-provided custom functions that the parser can call.\n// It is updated through the `customFunc` helper exported below.\n// okhsl is registered as a built-in function so it works regardless of\n// tree-shaking or module initialization order.\nconst __tastyFuncs: Record<string, (groups: StyleDetails[]) => string> = {\n okhsl: okhslFunc,\n};\n\nexport function customFunc(\n name: string,\n fn: (groups: StyleDetails[]) => string,\n) {\n __tastyFuncs[name] = fn;\n getOrCreateParser().setFuncs(__tastyFuncs);\n}\n\n/**\n * Get the global StyleParser instance.\n * Used by configure() to apply parser configuration.\n */\nexport function getGlobalParser(): StyleParser {\n return getOrCreateParser();\n}\n\n/**\n * Get the current custom functions registry.\n * Used by configure() to merge with new functions.\n */\nexport function getGlobalFuncs(): Record<\n string,\n (groups: StyleDetails[]) => string\n> {\n return __tastyFuncs;\n}\n\n// ============================================================================\n// Global Predefined Tokens\n// ============================================================================\n\n/**\n * Storage for predefined tokens that are replaced during style parsing.\n * Keys are token names (with $ or # prefix), values are pre-processed CSS values.\n */\nlet __globalPredefinedTokens: Record<string, string> | null = null;\n\n/**\n * Set global predefined tokens.\n * Called from configure() after processing token values.\n * Merges with existing tokens (new tokens override existing ones with same key).\n * Keys are normalized to lowercase (parser lowercases input before classification).\n * @internal\n */\nexport function setGlobalPredefinedTokens(\n tokens: Record<string, string>,\n): void {\n // Normalize keys to lowercase for case-insensitive matching\n const normalizedTokens: Record<string, string> = {};\n for (const [key, value] of Object.entries(tokens)) {\n const lowerKey = key.toLowerCase();\n const lowerValue = value.toLowerCase();\n\n // Warn if trying to use bare #current to define other color tokens\n // #current represents currentcolor which cannot be used as a base for recursive token resolution\n // Note: #current.5 (with opacity) is allowed since it resolves to a concrete color-mix value\n if (lowerKey.startsWith('#') && lowerValue === '#current') {\n console.warn(\n `Tasty: Using #current to define color token \"${key}\" is not supported. ` +\n `The #current token represents currentcolor which cannot be used as a base for other tokens.`,\n );\n continue; // Skip this token\n }\n\n normalizedTokens[lowerKey] = value;\n }\n // Merge with existing tokens (consistent with how states, units, funcs are handled)\n __globalPredefinedTokens = __globalPredefinedTokens\n ? { ...__globalPredefinedTokens, ...normalizedTokens }\n : normalizedTokens;\n // Clear parser cache since token values affect parsing\n getOrCreateParser().clearCache();\n}\n\n/**\n * Get the current global predefined tokens.\n * Returns null if no tokens are configured.\n */\nexport function getGlobalPredefinedTokens(): Record<string, string> | null {\n return __globalPredefinedTokens;\n}\n\n/**\n * Reset global predefined tokens.\n * Used for testing.\n * @internal\n */\nexport function resetGlobalPredefinedTokens(): void {\n __globalPredefinedTokens = null;\n // Clear parser cache since token availability affects parsing\n getOrCreateParser().clearCache();\n}\n\n/**\n *\n * @param {String} value\n * @param {Number} mode\n * @returns {Object<String,String|Array>}\n */\nexport function parseStyle(value: StyleValue): ProcessedStyle {\n let str: string;\n\n if (typeof value === 'string') {\n str = value;\n } else if (typeof value === 'number') {\n str = String(value);\n } else {\n // boolean, null, undefined, objects etc. → empty string\n str = '';\n }\n\n return getOrCreateParser().process(str);\n}\n\n/**\n * Parse color. Find it value, name and opacity.\n * Optimized to avoid heavy parseStyle calls for simple color patterns.\n */\nexport function parseColor(val: string, ignoreError = false): ParsedColor {\n // Early return for non-strings or empty values\n if (typeof val !== 'string') {\n val = String(val ?? '');\n }\n\n val = val.trim();\n if (!val) return {};\n\n // Fast path: Check if it's a simple color pattern that doesn't need full parsing\n const isSimpleColor = SIMPLE_COLOR_PATTERNS.some((pattern) =>\n pattern.test(val),\n );\n\n let firstColor: string;\n if (isSimpleColor) {\n // For simple colors, use the value directly without parsing\n firstColor = val;\n } else {\n const processed = parseStyle(val);\n const extractedColor = processed.groups.find((g) => g.colors.length)\n ?.colors[0];\n\n if (!extractedColor) {\n // Rate-limited warning to avoid spam\n if (!ignoreError && devMode && colorWarningCount < MAX_COLOR_WARNINGS) {\n console.warn('CubeUIKit: unable to parse color:', val);\n colorWarningCount++;\n if (colorWarningCount === MAX_COLOR_WARNINGS) {\n console.warn(\n 'CubeUIKit: color parsing warnings will be suppressed from now on',\n );\n }\n }\n return {};\n }\n\n firstColor = extractedColor;\n }\n\n // Extract color name (if present) from variable pattern using precompiled regex\n let nameMatch = firstColor.match(COLOR_VAR_PATTERN);\n if (!nameMatch) {\n nameMatch = firstColor.match(COLOR_VAR_RGB_PATTERN);\n }\n\n let opacity: number | undefined;\n if (\n firstColor.startsWith('rgb') ||\n firstColor.startsWith('hsl') ||\n firstColor.startsWith('lch') ||\n firstColor.startsWith('oklch') ||\n firstColor.startsWith('okhsl')\n ) {\n const alphaMatch = firstColor.match(RGB_ALPHA_PATTERN);\n if (alphaMatch) {\n const v = parseFloat(alphaMatch[1]);\n if (!isNaN(v)) opacity = v * 100;\n }\n }\n\n return {\n color: firstColor,\n name: nameMatch ? nameMatch[1] : undefined,\n opacity,\n };\n}\n\n/**\n * CSS named color keywords → hex values.\n * Lazy-initialized on first use to avoid up-front cost.\n */\nlet _namedColorHex: Map<string, string> | null = null;\n\nfunction getNamedColorHex(): Map<string, string> {\n if (_namedColorHex) return _namedColorHex;\n _namedColorHex = new Map([\n ['aliceblue', '#f0f8ff'],\n ['antiquewhite', '#faebd7'],\n ['aqua', '#00ffff'],\n ['aquamarine', '#7fffd4'],\n ['azure', '#f0ffff'],\n ['beige', '#f5f5dc'],\n ['bisque', '#ffe4c4'],\n ['black', '#000000'],\n ['blanchedalmond', '#ffebcd'],\n ['blue', '#0000ff'],\n ['blueviolet', '#8a2be2'],\n ['brown', '#a52a2a'],\n ['burlywood', '#deb887'],\n ['cadetblue', '#5f9ea0'],\n ['chartreuse', '#7fff00'],\n ['chocolate', '#d2691e'],\n ['coral', '#ff7f50'],\n ['cornflowerblue', '#6495ed'],\n ['cornsilk', '#fff8dc'],\n ['crimson', '#dc143c'],\n ['cyan', '#00ffff'],\n ['darkblue', '#00008b'],\n ['darkcyan', '#008b8b'],\n ['darkgoldenrod', '#b8860b'],\n ['darkgray', '#a9a9a9'],\n ['darkgreen', '#006400'],\n ['darkgrey', '#a9a9a9'],\n ['darkkhaki', '#bdb76b'],\n ['darkmagenta', '#8b008b'],\n ['darkolivegreen', '#556b2f'],\n ['darkorange', '#ff8c00'],\n ['darkorchid', '#9932cc'],\n ['darkred', '#8b0000'],\n ['darksalmon', '#e9967a'],\n ['darkseagreen', '#8fbc8f'],\n ['darkslateblue', '#483d8b'],\n ['darkslategray', '#2f4f4f'],\n ['darkslategrey', '#2f4f4f'],\n ['darkturquoise', '#00ced1'],\n ['darkviolet', '#9400d3'],\n ['deeppink', '#ff1493'],\n ['deepskyblue', '#00bfff'],\n ['dimgray', '#696969'],\n ['dimgrey', '#696969'],\n ['dodgerblue', '#1e90ff'],\n ['firebrick', '#b22222'],\n ['floralwhite', '#fffaf0'],\n ['forestgreen', '#228b22'],\n ['fuchsia', '#ff00ff'],\n ['gainsboro', '#dcdcdc'],\n ['ghostwhite', '#f8f8ff'],\n ['gold', '#ffd700'],\n ['goldenrod', '#daa520'],\n ['gray', '#808080'],\n ['green', '#008000'],\n ['greenyellow', '#adff2f'],\n ['grey', '#808080'],\n ['honeydew', '#f0fff0'],\n ['hotpink', '#ff69b4'],\n ['indianred', '#cd5c5c'],\n ['indigo', '#4b0082'],\n ['ivory', '#fffff0'],\n ['khaki', '#f0e68c'],\n ['lavender', '#e6e6fa'],\n ['lavenderblush', '#fff0f5'],\n ['lawngreen', '#7cfc00'],\n ['lemonchiffon', '#fffacd'],\n ['lightblue', '#add8e6'],\n ['lightcoral', '#f08080'],\n ['lightcyan', '#e0ffff'],\n ['lightgoldenrodyellow', '#fafad2'],\n ['lightgray', '#d3d3d3'],\n ['lightgreen', '#90ee90'],\n ['lightgrey', '#d3d3d3'],\n ['lightpink', '#ffb6c1'],\n ['lightsalmon', '#ffa07a'],\n ['lightseagreen', '#20b2aa'],\n ['lightskyblue', '#87cefa'],\n ['lightslategray', '#778899'],\n ['lightslategrey', '#778899'],\n ['lightsteelblue', '#b0c4de'],\n ['lightyellow', '#ffffe0'],\n ['lime', '#00ff00'],\n ['limegreen', '#32cd32'],\n ['linen', '#faf0e6'],\n ['magenta', '#ff00ff'],\n ['maroon', '#800000'],\n ['mediumaquamarine', '#66cdaa'],\n ['mediumblue', '#0000cd'],\n ['mediumorchid', '#ba55d3'],\n ['mediumpurple', '#9370db'],\n ['mediumseagreen', '#3cb371'],\n ['mediumslateblue', '#7b68ee'],\n ['mediumspringgreen', '#00fa9a'],\n ['mediumturquoise', '#48d1cc'],\n ['mediumvioletred', '#c71585'],\n ['midnightblue', '#191970'],\n ['mintcream', '#f5fffa'],\n ['mistyrose', '#ffe4e1'],\n ['moccasin', '#ffe4b5'],\n ['navajowhite', '#ffdead'],\n ['navy', '#000080'],\n ['oldlace', '#fdf5e6'],\n ['olive', '#808000'],\n ['olivedrab', '#6b8e23'],\n ['orange', '#ffa500'],\n ['orangered', '#ff4500'],\n ['orchid', '#da70d6'],\n ['palegoldenrod', '#eee8aa'],\n ['palegreen', '#98fb98'],\n ['paleturquoise', '#afeeee'],\n ['palevioletred', '#db7093'],\n ['papayawhip', '#ffefd5'],\n ['peachpuff', '#ffdab9'],\n ['peru', '#cd853f'],\n ['pink', '#ffc0cb'],\n ['plum', '#dda0dd'],\n ['powderblue', '#b0e0e6'],\n ['purple', '#800080'],\n ['rebeccapurple', '#663399'],\n ['red', '#ff0000'],\n ['rosybrown', '#bc8f8f'],\n ['royalblue', '#4169e1'],\n ['saddlebrown', '#8b4513'],\n ['salmon', '#fa8072'],\n ['sandybrown', '#f4a460'],\n ['seagreen', '#2e8b57'],\n ['seashell', '#fff5ee'],\n ['sienna', '#a0522d'],\n ['silver', '#c0c0c0'],\n ['skyblue', '#87ceeb'],\n ['slateblue', '#6a5acd'],\n ['slategray', '#708090'],\n ['slategrey', '#708090'],\n ['snow', '#fffafa'],\n ['springgreen', '#00ff7f'],\n ['steelblue', '#4682b4'],\n ['tan', '#d2b48c'],\n ['teal', '#008080'],\n ['thistle', '#d8bfd8'],\n ['tomato', '#ff6347'],\n ['turquoise', '#40e0d0'],\n ['violet', '#ee82ee'],\n ['wheat', '#f5deb3'],\n ['white', '#ffffff'],\n ['whitesmoke', '#f5f5f5'],\n ['yellow', '#ffff00'],\n ['yellowgreen', '#9acd32'],\n ]);\n return _namedColorHex;\n}\n\nexport function strToRgb(\n color: string,\n _ignoreAlpha = false,\n): string | null | undefined {\n if (!color) return undefined;\n\n if (color.startsWith('rgb')) return color;\n\n if (color.startsWith('#')) return hexToRgb(color);\n\n if (color.startsWith('okhsl(')) return okhslToRgb(color);\n\n if (color.startsWith('hsl')) return hslToRgb(color);\n\n // Named CSS colors\n const namedHex = getNamedColorHex().get(color.toLowerCase());\n if (namedHex) return hexToRgb(namedHex);\n\n return null;\n}\n\n/**\n * Extract RGB values from an rgb()/rgba() string.\n * Supports all modern CSS syntax variations:\n * - Comma-separated: rgb(255, 128, 0)\n * - Space-separated: rgb(255 128 0)\n * - Fractional: rgb(128.5, 64.3, 32.1)\n * - Percentages: rgb(50%, 25%, 75%)\n * - Slash alpha notation: rgb(255 128 0 / 0.5)\n *\n * Returns array of RGB values (0-255 range), converting percentages as needed.\n */\nexport function getRgbValuesFromRgbaString(str: string): number[] {\n // Extract content inside rgb()/rgba()\n const match = str.match(/rgba?\\(([^)]+)\\)/i);\n if (!match) return [];\n\n const inner = match[1].trim();\n // Split by slash first (for alpha), then handle color components\n const [colorPart] = inner.split('/');\n // Split by comma or whitespace\n const parts = colorPart\n .trim()\n .split(/[,\\s]+/)\n .filter(Boolean);\n\n return parts.slice(0, 3).map((part) => {\n part = part.trim();\n if (part.endsWith('%')) {\n // Convert percentage to 0-255 range\n return (parseFloat(part) / 100) * 255;\n }\n return parseFloat(part);\n });\n}\n\nexport function hexToRgb(hex: string): string | null {\n const matched = hex\n .replace(\n /^#?([a-f\\d])([a-f\\d])([a-f\\d])$/i,\n (_m: string, r: string, g: string, b: string) =>\n '#' + r + r + g + g + b + b,\n )\n .substring(1)\n .match(/.{2}/g);\n\n if (!matched) return null;\n\n const rgba = matched.map(\n (x: string, i: number) => parseInt(x, 16) * (i === 3 ? 1 / 255 : 1),\n );\n\n if (rgba.some((v) => Number.isNaN(v))) {\n return null;\n }\n\n if (rgba.length >= 3) {\n return `rgb(${rgba.slice(0, 3).join(' ')}${rgba.length > 3 ? ` / ${rgba[3]}` : ''})`;\n }\n\n return null;\n}\n\nexport function filterMods(mods: string[], allowedMods: string[]): string[] {\n return mods.filter((mod) => allowedMods.includes(mod));\n}\n\nexport function extendStyles(\n defaultStyles?: Record<string, unknown> | null,\n newStyles?: Record<string, unknown> | null,\n): Record<string, unknown> {\n let styles: Record<string, unknown> = {};\n\n if (!defaultStyles) {\n if (!newStyles) {\n return styles;\n }\n } else {\n styles = Object.assign({}, defaultStyles);\n }\n\n if (newStyles) {\n Object.keys(newStyles).forEach((key) => {\n if (newStyles[key] != null) {\n styles[key] = newStyles[key];\n }\n });\n }\n\n return styles;\n}\n\n/**\n * Split properties into style and non-style properties.\n * @param props - Component prop map.\n * @param [styleList] - List of all style properties.\n * @param [defaultStyles] - Default style map of the component.\n * @param [propMap] - Props to style alias map.\n * @param [ignoreList] - A list of properties to ignore.\n */\nexport function extractStyles(\n props: Record<string, unknown>,\n styleList: readonly string[] = [],\n defaultStyles?: Styles,\n propMap?: Record<string, string>,\n ignoreList: readonly string[] = [],\n): Styles {\n const styles: Styles = {\n ...defaultStyles,\n ...(ignoreList.includes('styles')\n ? undefined\n : props.styles && typeof props.styles === 'object'\n ? (props.styles as Styles)\n : undefined),\n };\n\n Object.keys(props).forEach((prop) => {\n const propName = propMap ? propMap[prop] || prop : prop;\n const value = props[prop];\n\n if (ignoreList && ignoreList.includes(prop)) {\n // do nothing\n } else if (styleList.includes(propName)) {\n styles[propName] = value as Styles[keyof Styles];\n }\n }, {});\n\n return styles;\n}\n\n// Enhanced regex that includes advanced state patterns\n// Matches: operators, parentheses, @media(...), @(...), @root(...), @own(...), @starting, @predefined,\n// value mods, boolean mods, pseudo-classes, classes, attribute selectors\nconst STATES_REGEXP =\n /([&|!^])|([()])|(@media:[a-z]+)|(@media\\([^)]+\\))|(@root\\([^)]+\\))|(@own\\([^)]+\\))|(@\\([^)]+\\))|(@starting)|(@[A-Za-z][A-Za-z0-9-]*)|([a-z][a-z0-9-]+=(?:\"[^\"]*\"|'[^']*'|[^\\s&|!^()]+))|([a-z][a-z0-9-]+)|(:[a-z][a-z0-9-]+\\([^)]+\\)|:[a-z][a-z0-9-]+)|(\\.[a-z][a-z0-9-]+)|(\\[[^\\]]+])/gi;\n\n/**\n * Check if a token is an advanced state (starts with @)\n */\nexport function isAdvancedStateToken(token: string): boolean {\n return token.startsWith('@') || token.startsWith('!@');\n}\nexport const STATE_OPERATORS = {\n NOT: '!',\n AND: '&',\n OR: '|',\n XOR: '^',\n};\n\nexport const STATE_OPERATOR_LIST = ['!', '&', '|', '^'];\n\n/**\n * Convert state notation tokens to a compute model (string, or nested [op, lhs, rhs]).\n */\nfunction convertTokensToComputeUnits(tokens: unknown[]): unknown {\n if (tokens.length === 1) {\n return tokens[0];\n }\n\n const hasLength = (x: unknown): x is string | unknown[] =>\n typeof x === 'string' || Array.isArray(x);\n\n STATE_OPERATOR_LIST.forEach((operator) => {\n let i;\n\n while ((i = tokens.indexOf(operator)) !== -1) {\n const token = tokens[i];\n\n if (token === '!') {\n const next = tokens[i + 1];\n if (next !== undefined && hasLength(next) && next.length !== 1) {\n tokens.splice(i, 2, ['!', next]);\n } else {\n tokens.splice(i, 1);\n }\n } else {\n const prev = tokens[i - 1];\n const next = tokens[i + 1];\n if (\n prev !== undefined &&\n next !== undefined &&\n hasLength(prev) &&\n hasLength(next) &&\n prev.length !== 1 &&\n next.length !== 1\n ) {\n tokens.splice(i - 1, 3, [token, prev, next]);\n } else {\n tokens.splice(i, 1);\n }\n }\n }\n });\n\n return tokens.length === 1 ? tokens[0] : tokens;\n}\n\n/**\n * Replace commas with | only outside of parentheses.\n * This preserves commas in advanced states like @(card, w < 600px)\n */\nfunction replaceCommasOutsideParens(str: string): string {\n let result = '';\n let depth = 0;\n\n for (const char of str) {\n if (char === '(') {\n depth++;\n result += char;\n } else if (char === ')') {\n depth--;\n result += char;\n } else if (char === ',' && depth === 0) {\n // Only replace commas at the top level (outside parentheses)\n result += '|';\n } else {\n result += char;\n }\n }\n\n return result;\n}\n\n/**\n * Parse state notation and return tokens, modifiers and compute model.\n */\nfunction parseStateNotationInner(\n notation: string,\n value: StyleValue | StyleValueStateMap | StyleStateData,\n): StyleStateData {\n const tokens = replaceCommasOutsideParens(notation).match(STATES_REGEXP);\n\n if (!tokens || !tokens.length) {\n return {\n model: undefined,\n mods: [],\n notMods: [],\n tokens: [],\n value,\n };\n } else if (tokens.length === 1) {\n return {\n model: tokens[0],\n mods: tokens.slice(0),\n notMods: [],\n tokens,\n value,\n };\n }\n\n const mods: string[] = [];\n\n const operations: unknown[][] = [[]];\n let list = operations[0];\n let position = 0;\n let operation: unknown[];\n\n tokens.forEach((token) => {\n switch (token) {\n case '(':\n operation = [];\n position++;\n list = operations[position] = operation;\n break;\n case ')':\n position--;\n operations[position].push(\n convertTokensToComputeUnits(list as unknown[]),\n );\n list = operations[position];\n break;\n default:\n if (token.length > 1) {\n if (!mods.includes(token)) {\n mods.push(token);\n }\n }\n list.push(token);\n }\n });\n\n while (position) {\n position--;\n operations[position].push(convertTokensToComputeUnits(list as unknown[]));\n list = operations[position];\n }\n\n return {\n tokens,\n mods,\n notMods: [],\n model: convertTokensToComputeUnits(operations[0] as unknown[]) as\n | ComputeModel\n | undefined,\n value,\n };\n}\n\nexport const parseStateNotation = cacheWrapper(parseStateNotationInner);\n\n/**\n * Build an AtRuleContext from parsed advanced states\n */\nexport function buildAtRuleContext(\n advancedStates: ParsedAdvancedState[],\n negatedStates: Set<string>,\n): AtRuleContext | undefined {\n if (advancedStates.length === 0) return undefined;\n\n const ctx: AtRuleContext = {};\n\n for (const state of advancedStates) {\n const isNegated = negatedStates.has(state.raw);\n\n switch (state.type) {\n case 'media': {\n if (!ctx.media) ctx.media = [];\n let mediaCondition = '';\n\n if (state.mediaType) {\n // @media:print, @media:screen, etc.\n mediaCondition = state.mediaType;\n } else if (state.condition) {\n // @media(width < 920px)\n mediaCondition = `(${state.condition})`;\n }\n\n if (mediaCondition) {\n if (isNegated) {\n ctx.media.push(`not ${mediaCondition}`);\n } else {\n ctx.media.push(mediaCondition);\n }\n }\n break;\n }\n\n case 'container': {\n if (!ctx.container) ctx.container = [];\n let condition = state.condition;\n if (isNegated) {\n condition = `not (${condition})`;\n }\n ctx.container.push({\n name: state.containerName,\n condition,\n });\n break;\n }\n\n case 'root': {\n if (!ctx.rootStates) ctx.rootStates = [];\n // Parse the condition to generate the proper selector\n const rootSelector = buildRootSelector(state.condition, isNegated);\n ctx.rootStates.push(rootSelector);\n break;\n }\n\n case 'starting': {\n if (!isNegated) {\n ctx.startingStyle = true;\n }\n break;\n }\n\n // 'own' and 'predefined' are handled differently (selector-based, not at-rule)\n // 'modifier' is a regular state\n }\n }\n\n // Return undefined if no at-rules were added\n if (\n !ctx.media?.length &&\n !ctx.container?.length &&\n !ctx.rootStates?.length &&\n !ctx.startingStyle\n ) {\n return undefined;\n }\n\n return ctx;\n}\n\n/**\n * Build a root state selector from a condition\n */\nfunction buildRootSelector(condition: string, isNegated: boolean): string {\n // Handle different condition formats:\n // - theme=dark -> [data-theme=\"dark\"]\n // - .className -> .className\n // - [attr] -> [attr]\n // - booleanMod -> [data-boolean-mod]\n\n let selector: string;\n\n if (condition.startsWith('.')) {\n // Class selector\n selector = condition;\n } else if (condition.startsWith('[')) {\n // Attribute selector\n selector = condition;\n } else if (condition.includes('=')) {\n // Value mod: theme=dark -> [data-theme=\"dark\"]\n const [key, value] = condition.split('=');\n selector = `[data-${camelToKebab(key.trim())}=\"${value.trim()}\"]`;\n } else {\n // Boolean mod: camelCase -> [data-camel-case]\n selector = `[data-${camelToKebab(condition)}]`;\n }\n\n if (isNegated) {\n return `:not(${selector})`;\n }\n return selector;\n}\n\n/**\n * Parse state notation and return tokens, modifiers and compute model.\n * Enhanced to detect and extract advanced states.\n */\nexport function styleStateMapToStyleStateDataList(\n styleStateMap: StyleStateMap | StyleValue | StyleValueStateMap,\n parserContext?: StateParserContext,\n): { states: StyleStateDataList; mods: string[]; hasAdvancedStates: boolean } {\n if (typeof styleStateMap !== 'object' || !styleStateMap) {\n return {\n states: [\n {\n model: undefined,\n mods: [],\n notMods: [],\n value: styleStateMap,\n },\n ],\n mods: [],\n hasAdvancedStates: false,\n };\n }\n\n const stateDataList: StyleStateDataList = [];\n let hasAdvancedStates = false;\n\n Object.keys(styleStateMap).forEach((stateNotation) => {\n const state = parseStateNotation(\n stateNotation,\n styleStateMap[stateNotation],\n );\n\n // Check if this state contains any advanced states\n const advancedStates: ParsedAdvancedState[] = [];\n const negatedAdvancedStates = new Set<string>();\n const regularMods: string[] = [];\n const ownMods: string[] = [];\n const negatedOwnMods: string[] = [];\n\n // Scan tokens for advanced states\n if (state.tokens) {\n let isNegated = false;\n for (const token of state.tokens) {\n if (token === '!') {\n isNegated = true;\n continue;\n }\n\n if (isAdvancedStateToken(token)) {\n hasAdvancedStates = true;\n const ctx = parserContext || createStateParserContext(undefined);\n const parsed = parseAdvancedState(token, ctx);\n advancedStates.push(parsed);\n\n // Handle @own states specially - extract condition as ownMod\n if (parsed.type === 'own' && parsed.condition) {\n if (isNegated) {\n negatedOwnMods.push(parsed.condition);\n } else {\n ownMods.push(parsed.condition);\n }\n } else if (isNegated) {\n negatedAdvancedStates.add(token);\n }\n isNegated = false;\n } else if (\n token.length > 1 &&\n !['&', '|', '^', '(', ')'].includes(token)\n ) {\n regularMods.push(token);\n isNegated = false;\n } else {\n isNegated = false;\n }\n }\n }\n\n // If there are advanced states, build the atRuleContext\n if (advancedStates.length > 0) {\n state.advancedStates = advancedStates;\n state.atRuleContext = buildAtRuleContext(\n advancedStates,\n negatedAdvancedStates,\n );\n // Filter mods to only include regular mods (not advanced states)\n state.mods = regularMods;\n }\n\n // Store own mods for sub-element selector generation\n if (ownMods.length > 0) {\n state.ownMods = ownMods;\n }\n if (negatedOwnMods.length > 0) {\n state.negatedOwnMods = negatedOwnMods;\n }\n\n stateDataList.push(state);\n });\n\n stateDataList.reverse();\n\n let initialState;\n\n const allMods: string[] = stateDataList.reduce((all: string[], state) => {\n if (!state.mods.length && !state.advancedStates?.length) {\n initialState = state;\n } else {\n state.mods.forEach((mod) => {\n if (!all.includes(mod)) {\n all.push(mod);\n }\n });\n }\n\n return all;\n }, []);\n\n if (!initialState) {\n stateDataList.push({\n mods: [],\n notMods: allMods,\n value: true,\n });\n }\n\n return { states: stateDataList, mods: allMods, hasAdvancedStates };\n}\n\nexport const COMPUTE_FUNC_MAP: Record<\n string,\n (a: unknown, b?: unknown) => unknown\n> = {\n '!': (a: unknown) => !a,\n '^': (a: unknown, b?: unknown) => (a && !b) || (!a && b),\n '|': (a: unknown, b?: unknown) => a || b,\n '&': (a: unknown, b?: unknown) => a && b,\n};\n\n/**\n * Compute a result based on a model and incoming map.\n */\nexport function computeState(\n computeModel: ComputeModel,\n valueMap:\n | (number | boolean)[]\n | Record<string, boolean>\n | ((...args: unknown[]) => unknown),\n) {\n if (!computeModel) return true;\n\n const map = valueMap as Record<string | number, unknown>;\n\n if (!Array.isArray(computeModel)) {\n if (typeof valueMap === 'function') {\n return !!valueMap(computeModel);\n } else {\n return !!map[computeModel];\n }\n }\n\n const func = COMPUTE_FUNC_MAP[computeModel[0]];\n\n if (!func) {\n console.warn(\n 'CubeUIKit: unexpected compute method in the model',\n computeModel,\n );\n // return false;\n }\n\n let a: unknown = computeModel[1];\n\n if (typeof a === 'object') {\n a = !!computeState(a as unknown as ComputeModel, valueMap);\n } else if (typeof valueMap === 'function') {\n a = !!valueMap(a);\n } else {\n a = !!map[a as string | number];\n }\n\n if (computeModel.length === 2) {\n return func(a);\n }\n\n let b: unknown = computeModel[2];\n\n if (typeof b === 'object') {\n b = !!computeState(b as unknown as ComputeModel, valueMap);\n } else if (typeof valueMap === 'function') {\n b = !!valueMap(b);\n } else {\n b = !!map[b as string | number];\n }\n\n return !!func(a, b);\n}\n\nconst _innerCache = new WeakMap();\n\nexport function stringifyStyles(styles: unknown): string {\n if (styles == null || typeof styles !== 'object') return '';\n const obj = styles as Record<string, unknown>;\n const keys = Object.keys(obj).sort();\n const parts: string[] = [];\n for (const k of keys) {\n const v = obj[k];\n if (v === undefined || typeof v === 'function' || typeof v === 'symbol')\n continue;\n\n const c0 = k.charCodeAt(0);\n const needsInnerSort =\n ((c0 >= 65 && c0 <= 90) || c0 === 38) &&\n v &&\n typeof v === 'object' &&\n !Array.isArray(v);\n\n let sv: string;\n if (needsInnerSort) {\n sv = _innerCache.get(v);\n if (sv === undefined) {\n const innerObj = v as Record<string, unknown>;\n const innerKeys = Object.keys(innerObj).sort();\n const innerParts: string[] = [];\n for (const ik of innerKeys) {\n const ivs = JSON.stringify(innerObj[ik]);\n if (ivs !== undefined)\n innerParts.push(JSON.stringify(ik) + ':' + ivs);\n }\n sv = '{' + innerParts.join(',') + '}';\n _innerCache.set(v, sv);\n }\n } else {\n sv = JSON.stringify(v);\n }\n parts.push(JSON.stringify(k) + ':' + sv);\n }\n return '{' + parts.join(',') + '}';\n}\n"],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AAC,MAAM;CACpC,MAAM,QAAkB,EAAE;AAC1B,MAAK,MAAM,KAAK,MAAM;EACpB,MAAM,IAAI,IAAI;AACd,MAAI,MAAM,UAAa,OAAO,MAAM,cAAc,OAAO,MAAM,SAC7D;EAEF,MAAM,KAAK,EAAE,WAAW,EAAE;EAC1B,MAAM,kBACF,MAAM,MAAM,MAAM,MAAO,OAAO,OAClC,KACA,OAAO,MAAM,YACb,CAAC,MAAM,QAAQ,EAAE;EAEnB,IAAI;AACJ,MAAI,gBAAgB;AAClB,QAAK,YAAY,IAAI,EAAE;AACvB,OAAI,OAAO,QAAW;IACpB,MAAM,WAAW;IACjB,MAAM,YAAY,OAAO,KAAK,SAAS,CAAC,MAAM;IAC9C,MAAM,aAAuB,EAAE;AAC/B,SAAK,MAAM,MAAM,WAAW;KAC1B,MAAM,MAAM,KAAK,UAAU,SAAS,IAAI;AACxC,SAAI,QAAQ,OACV,YAAW,KAAK,KAAK,UAAU,GAAG,GAAG,MAAM,IAAI;;AAEnD,SAAK,MAAM,WAAW,KAAK,IAAI,GAAG;AAClC,gBAAY,IAAI,GAAG,GAAG;;QAGxB,MAAK,KAAK,UAAU,EAAE;AAExB,QAAM,KAAK,KAAK,UAAU,EAAE,GAAG,MAAM,GAAG;;AAE1C,QAAO,MAAM,MAAM,KAAK,IAAI,GAAG"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { ConfigTokens } from "../styles/types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/typography.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Typography preset configuration.
|
|
6
|
+
* Each preset defines font properties that get expanded into CSS custom properties.
|
|
7
|
+
*
|
|
8
|
+
* Use with `generateTypographyTokens()` to create typography tokens for your design system.
|
|
9
|
+
*/
|
|
10
|
+
interface TypographyPreset {
|
|
11
|
+
fontSize: string;
|
|
12
|
+
lineHeight: string;
|
|
13
|
+
letterSpacing?: string;
|
|
14
|
+
fontWeight: string | number;
|
|
15
|
+
boldFontWeight?: string | number;
|
|
16
|
+
iconSize?: string;
|
|
17
|
+
textTransform?: string;
|
|
18
|
+
fontFamily?: string;
|
|
19
|
+
fontStyle?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Generate typography tokens with $ prefix for CSS custom properties.
|
|
23
|
+
*
|
|
24
|
+
* Each preset generates the following CSS custom properties:
|
|
25
|
+
* - `${name}-font-size`
|
|
26
|
+
* - `${name}-line-height`
|
|
27
|
+
* - `${name}-letter-spacing`
|
|
28
|
+
* - `${name}-font-weight`
|
|
29
|
+
* - `${name}-bold-font-weight` (if defined)
|
|
30
|
+
* - `${name}-icon-size` (if defined)
|
|
31
|
+
* - `${name}-text-transform` (if defined)
|
|
32
|
+
* - `${name}-font-family` (if defined)
|
|
33
|
+
* - `${name}-font-style` (if defined)
|
|
34
|
+
*
|
|
35
|
+
* @param presets - Typography presets object
|
|
36
|
+
* @returns ConfigTokens object with $ prefixed keys
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* const customTokens = generateTypographyTokens({
|
|
40
|
+
* myHeading: { fontSize: '24px', lineHeight: '32px', fontWeight: '700' },
|
|
41
|
+
* body: { fontSize: '16px', lineHeight: '24px', fontWeight: '400' },
|
|
42
|
+
* });
|
|
43
|
+
*/
|
|
44
|
+
declare function generateTypographyTokens(presets: Record<string, TypographyPreset>): ConfigTokens;
|
|
45
|
+
//#endregion
|
|
46
|
+
export { TypographyPreset, generateTypographyTokens };
|
|
47
|
+
//# sourceMappingURL=typography.d.ts.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
//#region src/utils/typography.ts
|
|
2
|
+
/**
|
|
3
|
+
* Generate typography tokens with $ prefix for CSS custom properties.
|
|
4
|
+
*
|
|
5
|
+
* Each preset generates the following CSS custom properties:
|
|
6
|
+
* - `${name}-font-size`
|
|
7
|
+
* - `${name}-line-height`
|
|
8
|
+
* - `${name}-letter-spacing`
|
|
9
|
+
* - `${name}-font-weight`
|
|
10
|
+
* - `${name}-bold-font-weight` (if defined)
|
|
11
|
+
* - `${name}-icon-size` (if defined)
|
|
12
|
+
* - `${name}-text-transform` (if defined)
|
|
13
|
+
* - `${name}-font-family` (if defined)
|
|
14
|
+
* - `${name}-font-style` (if defined)
|
|
15
|
+
*
|
|
16
|
+
* @param presets - Typography presets object
|
|
17
|
+
* @returns ConfigTokens object with $ prefixed keys
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* const customTokens = generateTypographyTokens({
|
|
21
|
+
* myHeading: { fontSize: '24px', lineHeight: '32px', fontWeight: '700' },
|
|
22
|
+
* body: { fontSize: '16px', lineHeight: '24px', fontWeight: '400' },
|
|
23
|
+
* });
|
|
24
|
+
*/
|
|
25
|
+
function generateTypographyTokens(presets) {
|
|
26
|
+
const tokens = {};
|
|
27
|
+
for (const [name, preset] of Object.entries(presets)) {
|
|
28
|
+
tokens[`$${name}-font-size`] = preset.fontSize;
|
|
29
|
+
tokens[`$${name}-line-height`] = preset.lineHeight;
|
|
30
|
+
tokens[`$${name}-letter-spacing`] = preset.letterSpacing ?? "0";
|
|
31
|
+
tokens[`$${name}-font-weight`] = preset.fontWeight;
|
|
32
|
+
if (preset.boldFontWeight !== void 0) tokens[`$${name}-bold-font-weight`] = preset.boldFontWeight;
|
|
33
|
+
if (preset.iconSize !== void 0) tokens[`$${name}-icon-size`] = preset.iconSize;
|
|
34
|
+
if (preset.textTransform !== void 0) tokens[`$${name}-text-transform`] = preset.textTransform;
|
|
35
|
+
if (preset.fontFamily !== void 0) tokens[`$${name}-font-family`] = preset.fontFamily;
|
|
36
|
+
if (preset.fontStyle !== void 0) tokens[`$${name}-font-style`] = preset.fontStyle;
|
|
37
|
+
}
|
|
38
|
+
return tokens;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
export { generateTypographyTokens };
|
|
43
|
+
//# sourceMappingURL=typography.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typography.js","names":[],"sources":["../../src/utils/typography.ts"],"sourcesContent":["import type { ConfigTokens } from '../styles/types';\n\n/**\n * Typography preset configuration.\n * Each preset defines font properties that get expanded into CSS custom properties.\n *\n * Use with `generateTypographyTokens()` to create typography tokens for your design system.\n */\nexport interface TypographyPreset {\n fontSize: string;\n lineHeight: string;\n letterSpacing?: string;\n fontWeight: string | number;\n boldFontWeight?: string | number;\n iconSize?: string;\n textTransform?: string;\n fontFamily?: string;\n fontStyle?: string;\n}\n\n/**\n * Generate typography tokens with $ prefix for CSS custom properties.\n *\n * Each preset generates the following CSS custom properties:\n * - `${name}-font-size`\n * - `${name}-line-height`\n * - `${name}-letter-spacing`\n * - `${name}-font-weight`\n * - `${name}-bold-font-weight` (if defined)\n * - `${name}-icon-size` (if defined)\n * - `${name}-text-transform` (if defined)\n * - `${name}-font-family` (if defined)\n * - `${name}-font-style` (if defined)\n *\n * @param presets - Typography presets object\n * @returns ConfigTokens object with $ prefixed keys\n *\n * @example\n * const customTokens = generateTypographyTokens({\n * myHeading: { fontSize: '24px', lineHeight: '32px', fontWeight: '700' },\n * body: { fontSize: '16px', lineHeight: '24px', fontWeight: '400' },\n * });\n */\nexport function generateTypographyTokens(\n presets: Record<string, TypographyPreset>,\n): ConfigTokens {\n const tokens: Record<`$${string}`, string | number> = {};\n\n for (const [name, preset] of Object.entries(presets)) {\n tokens[`$${name}-font-size`] = preset.fontSize;\n tokens[`$${name}-line-height`] = preset.lineHeight;\n tokens[`$${name}-letter-spacing`] = preset.letterSpacing ?? '0';\n tokens[`$${name}-font-weight`] = preset.fontWeight;\n\n if (preset.boldFontWeight !== undefined) {\n tokens[`$${name}-bold-font-weight`] = preset.boldFontWeight;\n }\n\n if (preset.iconSize !== undefined) {\n tokens[`$${name}-icon-size`] = preset.iconSize;\n }\n\n if (preset.textTransform !== undefined) {\n tokens[`$${name}-text-transform`] = preset.textTransform;\n }\n\n if (preset.fontFamily !== undefined) {\n tokens[`$${name}-font-family`] = preset.fontFamily;\n }\n\n if (preset.fontStyle !== undefined) {\n tokens[`$${name}-font-style`] = preset.fontStyle;\n }\n }\n\n return tokens as ConfigTokens;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA2CA,SAAgB,yBACd,SACc;CACd,MAAM,SAAgD,EAAE;AAExD,MAAK,MAAM,CAAC,MAAM,WAAW,OAAO,QAAQ,QAAQ,EAAE;AACpD,SAAO,IAAI,KAAK,eAAe,OAAO;AACtC,SAAO,IAAI,KAAK,iBAAiB,OAAO;AACxC,SAAO,IAAI,KAAK,oBAAoB,OAAO,iBAAiB;AAC5D,SAAO,IAAI,KAAK,iBAAiB,OAAO;AAExC,MAAI,OAAO,mBAAmB,OAC5B,QAAO,IAAI,KAAK,sBAAsB,OAAO;AAG/C,MAAI,OAAO,aAAa,OACtB,QAAO,IAAI,KAAK,eAAe,OAAO;AAGxC,MAAI,OAAO,kBAAkB,OAC3B,QAAO,IAAI,KAAK,oBAAoB,OAAO;AAG7C,MAAI,OAAO,eAAe,OACxB,QAAO,IAAI,KAAK,iBAAiB,OAAO;AAG1C,MAAI,OAAO,cAAc,OACvB,QAAO,IAAI,KAAK,gBAAgB,OAAO;;AAI3C,QAAO"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region src/utils/warnings.d.ts
|
|
2
|
+
declare function warn(...args: unknown[]): void;
|
|
3
|
+
declare function deprecationWarning(condition: unknown, {
|
|
4
|
+
property,
|
|
5
|
+
name,
|
|
6
|
+
betterAlternative,
|
|
7
|
+
reason
|
|
8
|
+
}: {
|
|
9
|
+
property: string;
|
|
10
|
+
name: string;
|
|
11
|
+
betterAlternative: (() => string) | string;
|
|
12
|
+
reason?: (() => string) | string;
|
|
13
|
+
}): void;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { deprecationWarning, warn };
|
|
16
|
+
//# sourceMappingURL=warnings.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region src/utils/warnings.ts
|
|
2
|
+
const PREFIX = "Tasty";
|
|
3
|
+
function warn(...args) {
|
|
4
|
+
console.warn(`${PREFIX}:`, ...args);
|
|
5
|
+
}
|
|
6
|
+
function deprecationWarning(condition, { property, name, betterAlternative, reason }) {
|
|
7
|
+
if (condition) return;
|
|
8
|
+
console.group(`⚠️ ${PREFIX}: Deprecation in ${name}`);
|
|
9
|
+
warn(`"${property}" is deprecated, consider better alternative: ${typeof betterAlternative === "function" ? betterAlternative() : betterAlternative}`);
|
|
10
|
+
if (reason) warn(`Reason: ${typeof reason === "function" ? reason() : reason}`);
|
|
11
|
+
console.groupEnd();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
export { deprecationWarning, warn };
|
|
16
|
+
//# sourceMappingURL=warnings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"warnings.js","names":[],"sources":["../../src/utils/warnings.ts"],"sourcesContent":["/* eslint-disable no-console */\nconst PREFIX = 'Tasty';\n\nexport function warn(...args: unknown[]) {\n console.warn(`${PREFIX}:`, ...args);\n}\n\nexport function deprecationWarning(\n condition: unknown,\n {\n property,\n name,\n betterAlternative,\n reason,\n }: {\n property: string;\n name: string;\n betterAlternative: (() => string) | string;\n reason?: (() => string) | string;\n },\n) {\n if (condition) return;\n\n if (process.env.NODE_ENV === 'production') {\n return warn(\n `DEPRECATION ${name} \"${property}\" -> ${\n typeof betterAlternative === 'function'\n ? betterAlternative()\n : betterAlternative\n }`,\n );\n }\n\n // we can make deprecations even better if we add the md syntax in the console.\n // anyway, everything down below will be stripped in the production build\n console.group(`⚠️ ${PREFIX}: Deprecation in ${name}`);\n warn(\n `\"${property}\" is deprecated, consider better alternative: ${\n typeof betterAlternative === 'function'\n ? betterAlternative()\n : betterAlternative\n }`,\n );\n if (reason) {\n warn(`Reason: ${typeof reason === 'function' ? reason() : reason}`);\n }\n console.groupEnd();\n}\n"],"mappings":";AACA,MAAM,SAAS;AAEf,SAAgB,KAAK,GAAG,MAAiB;AACvC,SAAQ,KAAK,GAAG,OAAO,IAAI,GAAG,KAAK;;AAGrC,SAAgB,mBACd,WACA,EACE,UACA,MACA,mBACA,UAOF;AACA,KAAI,UAAW;AAcf,SAAQ,MAAM,MAAM,OAAO,mBAAmB,OAAO;AACrD,MACE,IAAI,SAAS,gDACX,OAAO,sBAAsB,aACzB,mBAAmB,GACnB,oBAEP;AACD,KAAI,OACF,MAAK,WAAW,OAAO,WAAW,aAAa,QAAQ,GAAG,SAAS;AAErE,SAAQ,UAAU"}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { KeyframesSteps } from "../injector/types.js";
|
|
2
|
+
import { StyleDetails, UnitHandler } from "../parser/types.js";
|
|
3
|
+
import { StyleHandlerDefinition } from "../utils/styles.js";
|
|
4
|
+
import { ConfigTokens, RecipeStyles } from "../styles/types.js";
|
|
5
|
+
import { TastyPlugin } from "../plugins/types.js";
|
|
6
|
+
import * as _babel_core0 from "@babel/core";
|
|
7
|
+
import { PluginPass } from "@babel/core";
|
|
8
|
+
|
|
9
|
+
//#region src/zero/babel.d.ts
|
|
10
|
+
/**
|
|
11
|
+
* Build-time configuration for zero-runtime mode.
|
|
12
|
+
* Subset of TastyConfig that applies at build time.
|
|
13
|
+
*/
|
|
14
|
+
interface TastyZeroConfig {
|
|
15
|
+
/**
|
|
16
|
+
* Global predefined states for advanced state mapping.
|
|
17
|
+
* Example: { '@mobile': '@media(w < 768px)', '@dark': '@root(theme=dark)' }
|
|
18
|
+
*/
|
|
19
|
+
states?: Record<string, string>;
|
|
20
|
+
/**
|
|
21
|
+
* Enable development mode features: source comments in generated CSS.
|
|
22
|
+
* Default: false
|
|
23
|
+
*/
|
|
24
|
+
devMode?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Parser LRU cache size (default: 1000).
|
|
27
|
+
* Larger values improve performance for builds with many unique style values.
|
|
28
|
+
*/
|
|
29
|
+
parserCacheSize?: number;
|
|
30
|
+
/**
|
|
31
|
+
* Custom units for the style parser (merged with built-in units).
|
|
32
|
+
* Units transform numeric values like `2x` → `calc(2 * var(--gap))`.
|
|
33
|
+
* @example { em: 'em', vw: 'vw', custom: (n) => `${n * 10}px` }
|
|
34
|
+
*/
|
|
35
|
+
units?: Record<string, string | UnitHandler>;
|
|
36
|
+
/**
|
|
37
|
+
* Custom functions for the style parser (merged with existing).
|
|
38
|
+
* Functions process parsed style groups and return CSS values.
|
|
39
|
+
* @example { myFunc: (groups) => groups.map(g => g.output).join(' ') }
|
|
40
|
+
*/
|
|
41
|
+
funcs?: Record<string, (groups: StyleDetails[]) => string>;
|
|
42
|
+
/**
|
|
43
|
+
* Plugins that extend tasty with custom functions, units, states, and handlers.
|
|
44
|
+
* Plugins are processed in order, with later plugins overriding earlier ones.
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* import { okhslPlugin } from '@tenphi/tasty';
|
|
48
|
+
*
|
|
49
|
+
* // babel.config.js
|
|
50
|
+
* module.exports = {
|
|
51
|
+
* plugins: [
|
|
52
|
+
* ['@tenphi/tasty/babel-plugin', {
|
|
53
|
+
* config: { plugins: [okhslPlugin()] }
|
|
54
|
+
* }]
|
|
55
|
+
* ]
|
|
56
|
+
* };
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
plugins?: TastyPlugin[];
|
|
60
|
+
/**
|
|
61
|
+
* Global keyframes definitions for static extraction.
|
|
62
|
+
* Keys are animation names, values are keyframes step definitions.
|
|
63
|
+
* @example { fadeIn: { from: { opacity: 0 }, to: { opacity: 1 } } }
|
|
64
|
+
*/
|
|
65
|
+
keyframes?: Record<string, KeyframesSteps>;
|
|
66
|
+
/**
|
|
67
|
+
* Custom style handlers that transform style properties into CSS declarations.
|
|
68
|
+
* Handlers replace built-in handlers for the same style name.
|
|
69
|
+
* @example
|
|
70
|
+
* ```ts
|
|
71
|
+
* handlers: {
|
|
72
|
+
* fill: ({ fill }) => fill ? { 'background-color': fill } : undefined,
|
|
73
|
+
* elevation: ({ elevation }) => ({
|
|
74
|
+
* 'box-shadow': `0 ${elevation}px ${elevation * 2}px rgba(0,0,0,0.1)`,
|
|
75
|
+
* }),
|
|
76
|
+
* }
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
handlers?: Record<string, StyleHandlerDefinition>;
|
|
80
|
+
/**
|
|
81
|
+
* Design tokens injected as CSS custom properties on `:root`.
|
|
82
|
+
* Values are parsed through the Tasty DSL. Supports state maps.
|
|
83
|
+
* @example { '$gap': '4px', '#primary': { '': '#purple', '@dark': '#light-purple' } }
|
|
84
|
+
*/
|
|
85
|
+
tokens?: ConfigTokens;
|
|
86
|
+
/**
|
|
87
|
+
* Predefined tokens replaced during style parsing (parse-time substitution).
|
|
88
|
+
* Use `$name` for custom properties and `#name` for color tokens.
|
|
89
|
+
* @example { $spacing: '2x', '#accent': '#purple' }
|
|
90
|
+
*/
|
|
91
|
+
replaceTokens?: Record<`$${string}` | `#${string}`, string | number>;
|
|
92
|
+
/**
|
|
93
|
+
* Predefined style recipes -- named style bundles that can be applied via `recipe` style property.
|
|
94
|
+
* Recipe values are flat tasty styles (no sub-element keys).
|
|
95
|
+
* @example
|
|
96
|
+
* ```ts
|
|
97
|
+
* recipes: {
|
|
98
|
+
* card: { padding: '4x', fill: '#surface', radius: '1r', border: true },
|
|
99
|
+
* elevated: { shadow: '2x 2x 4x #shadow' },
|
|
100
|
+
* }
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
recipes?: Record<string, RecipeStyles>;
|
|
104
|
+
/**
|
|
105
|
+
* Automatically infer and register CSS @property declarations from values.
|
|
106
|
+
* @default true
|
|
107
|
+
*/
|
|
108
|
+
autoPropertyTypes?: boolean;
|
|
109
|
+
}
|
|
110
|
+
interface TastyZeroBabelOptions {
|
|
111
|
+
/** Output path for generated CSS (default: 'tasty.css') */
|
|
112
|
+
output?: string;
|
|
113
|
+
/**
|
|
114
|
+
* Tasty configuration for build-time processing.
|
|
115
|
+
* Can be a static object or a factory function that returns fresh config.
|
|
116
|
+
* A factory is called on each plugin invocation, enabling hot reload
|
|
117
|
+
* of config values that depend on external files (e.g. theme tokens).
|
|
118
|
+
*/
|
|
119
|
+
config?: TastyZeroConfig | (() => TastyZeroConfig);
|
|
120
|
+
/**
|
|
121
|
+
* Absolute path to a TypeScript/JavaScript module that default-exports
|
|
122
|
+
* a `TastyZeroConfig` object. The module is loaded via jiti on each
|
|
123
|
+
* plugin invocation, enabling hot reload when the file changes.
|
|
124
|
+
*
|
|
125
|
+
* This option is JSON-serializable and is the primary way Turbopack
|
|
126
|
+
* passes config to the Babel plugin (since Turbopack loader options
|
|
127
|
+
* must be plain primitives/objects/arrays).
|
|
128
|
+
*
|
|
129
|
+
* When both `config` and `configFile` are set, `config` takes precedence.
|
|
130
|
+
*
|
|
131
|
+
* @example '/absolute/path/to/tasty-zero.config.ts'
|
|
132
|
+
*/
|
|
133
|
+
configFile?: string;
|
|
134
|
+
/**
|
|
135
|
+
* Absolute file paths whose content affects the generated CSS.
|
|
136
|
+
* When any of these files change, babel-loader invalidates its cache
|
|
137
|
+
* and re-runs the plugin with fresh config values.
|
|
138
|
+
*
|
|
139
|
+
* Typically includes theme files that define Glaze palettes or token values.
|
|
140
|
+
* Paths must be absolute (resolved by the Next.js wrapper).
|
|
141
|
+
*/
|
|
142
|
+
configDeps?: string[];
|
|
143
|
+
}
|
|
144
|
+
declare const _default: (api: object, options: TastyZeroBabelOptions | null | undefined, dirname: string) => _babel_core0.PluginObj<PluginPass>;
|
|
145
|
+
//#endregion
|
|
146
|
+
export { TastyZeroBabelOptions, TastyZeroConfig, _default as default };
|
|
147
|
+
//# sourceMappingURL=babel.d.ts.map
|