@tenphi/tasty 2.7.0 → 2.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/{collector-BWvvN7_y.js → collector-BEF4F_PE.js} +3 -3
  2. package/dist/{collector-BWvvN7_y.js.map → collector-BEF4F_PE.js.map} +1 -1
  3. package/dist/{collector-osfWTeRd.d.ts → collector-CpU85p2G.d.ts} +2 -2
  4. package/dist/{config-BoZDUHW5.d.ts → config-3h7BtX4l.d.ts} +2 -2
  5. package/dist/{config-DF2QZQEW.js → config-BDnvK42H.js} +165 -43
  6. package/dist/config-BDnvK42H.js.map +1 -0
  7. package/dist/core/index.d.ts +5 -5
  8. package/dist/core/index.js +6 -6
  9. package/dist/{core-BbdGIKAK.js → core-BiFQGi4v.js} +5 -5
  10. package/dist/{core-BbdGIKAK.js.map → core-BiFQGi4v.js.map} +1 -1
  11. package/dist/{css-writer-Bh05D6KI.js → css-writer-4IMPW4i1.js} +3 -3
  12. package/dist/{css-writer-Bh05D6KI.js.map → css-writer-4IMPW4i1.js.map} +1 -1
  13. package/dist/{format-rules-DCI2lomx.js → format-rules-DrpEA0CZ.js} +2 -2
  14. package/dist/{format-rules-DCI2lomx.js.map → format-rules-DrpEA0CZ.js.map} +1 -1
  15. package/dist/{hydrate-DsFfFPVK.js → hydrate-DItCQmmZ.js} +2 -2
  16. package/dist/{hydrate-DsFfFPVK.js.map → hydrate-DItCQmmZ.js.map} +1 -1
  17. package/dist/{index-tcHuMPFt.d.ts → index-BsJz5xBF.d.ts} +2 -2
  18. package/dist/{index-D-OA_O6i.d.ts → index-C_SRmAWj.d.ts} +193 -163
  19. package/dist/index.d.ts +5 -5
  20. package/dist/index.js +7 -7
  21. package/dist/{keyframes-Dg95rDpN.js → keyframes-DYGxQPjN.js} +2 -2
  22. package/dist/{keyframes-Dg95rDpN.js.map → keyframes-DYGxQPjN.js.map} +1 -1
  23. package/dist/{merge-styles-BMWcH6MF.d.ts → merge-styles-BzOwGOGC.d.ts} +2 -2
  24. package/dist/{merge-styles-Bnn6j_SA.js → merge-styles-oU4CfZY7.js} +2 -2
  25. package/dist/{merge-styles-Bnn6j_SA.js.map → merge-styles-oU4CfZY7.js.map} +1 -1
  26. package/dist/{resolve-recipes-CBQaQ3tD.js → resolve-recipes-PwM-R6Jc.js} +3 -3
  27. package/dist/{resolve-recipes-CBQaQ3tD.js.map → resolve-recipes-PwM-R6Jc.js.map} +1 -1
  28. package/dist/ssr/astro-client.js +1 -1
  29. package/dist/ssr/astro.js +3 -3
  30. package/dist/ssr/index.d.ts +1 -1
  31. package/dist/ssr/index.js +3 -3
  32. package/dist/ssr/next.d.ts +1 -1
  33. package/dist/ssr/next.js +4 -4
  34. package/dist/static/index.d.ts +2 -2
  35. package/dist/static/index.js +1 -1
  36. package/dist/zero/babel.d.ts +1 -1
  37. package/dist/zero/babel.js +4 -4
  38. package/dist/zero/index.d.ts +1 -1
  39. package/dist/zero/index.js +1 -1
  40. package/docs/dsl.md +1 -1
  41. package/package.json +1 -1
  42. package/dist/config-DF2QZQEW.js.map +0 -1
@@ -1,5 +1,5 @@
1
- import { F as fontFaceContentHash, I as formatFontFaceRule, M as formatCounterStyleRule, S as renderStyles, a as getGlobalCounterStyle, d as getNamePrefix, dt as makeCounterStyleName, ft as makeKeyframeName, gt as hashString, i as getGlobalConfigTokens, mt as validateNamePrefix, o as getGlobalFontFace, r as getEffectiveProperties, u as getGlobalStyles, ut as makeClassName } from "./config-DF2QZQEW.js";
2
- import { n as formatPropertyCSS, t as formatRules } from "./format-rules-DCI2lomx.js";
1
+ import { F as fontFaceContentHash, I as formatFontFaceRule, M as formatCounterStyleRule, S as renderStyles, a as getGlobalCounterStyle, d as getNamePrefix, ft as makeClassName, gt as validateNamePrefix, i as getGlobalConfigTokens, mt as makeKeyframeName, o as getGlobalFontFace, pt as makeCounterStyleName, r as getEffectiveProperties, u as getGlobalStyles, vt as hashString } from "./config-BDnvK42H.js";
2
+ import { n as formatPropertyCSS, t as formatRules } from "./format-rules-DrpEA0CZ.js";
3
3
  import { t as formatGlobalRules } from "./format-global-rules-Dbc_1tc3.js";
4
4
  //#region src/ssr/collector.ts
5
5
  /**
@@ -240,4 +240,4 @@ var ServerStyleCollector = class {
240
240
  //#endregion
241
241
  export { ServerStyleCollector as t };
242
242
 
243
- //# sourceMappingURL=collector-BWvvN7_y.js.map
243
+ //# sourceMappingURL=collector-BEF4F_PE.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"collector-BWvvN7_y.js","names":[],"sources":["../src/ssr/collector.ts"],"sourcesContent":["/**\n * ServerStyleCollector — server-safe style collector for SSR.\n *\n * Accumulates CSS rules and cache metadata during server rendering.\n * This is the server-side counterpart to StyleInjector: it allocates\n * hash-based class names using the configured `namePrefix` (defaults\n * to `'t'`), formats CSS rules into text, and tracks rendered class\n * names for lightweight client transfer.\n *\n * One instance is created per HTTP request. Concurrent requests\n * each get their own collector (via AsyncLocalStorage or React context).\n */\n\nimport {\n getEffectiveProperties,\n getGlobalStyles,\n getGlobalCounterStyle,\n getGlobalFontFace,\n getGlobalConfigTokens,\n getNamePrefix,\n} from '../config';\nimport { formatCounterStyleRule } from '../counter-style';\nimport { fontFaceContentHash, formatFontFaceRule } from '../font-face';\nimport { renderStyles } from '../pipeline';\nimport type { StyleResult } from '../pipeline';\nimport { hashString } from '../utils/hash';\nimport {\n makeClassName,\n makeCounterStyleName,\n makeKeyframeName,\n validateNamePrefix,\n} from '../utils/name-prefix';\nimport { formatPropertyCSS } from './format-property';\nimport { formatGlobalRules } from './format-global-rules';\nimport { formatRules } from './format-rules';\n\nexport class ServerStyleCollector {\n private chunks = new Map<string, string>();\n private cacheKeyToClassName = new Map<string, string>();\n private flushedKeys = new Set<string>();\n private propertyRules = new Map<string, string>();\n private flushedPropertyKeys = new Set<string>();\n private keyframeRules = new Map<string, string>();\n private flushedKeyframeKeys = new Set<string>();\n private globalStyles = new Map<string, string>();\n private flushedGlobalKeys = new Set<string>();\n private rawCSS = new Map<string, string>();\n private flushedRawKeys = new Set<string>();\n private fontFaceRules = new Map<string, string>();\n private flushedFontFaceKeys = new Set<string>();\n private counterStyleRules = new Map<string, string>();\n private flushedCounterStyleKeys = new Set<string>();\n private keyframesCounter = 0;\n private counterStyleCounter = 0;\n private internalsCollected = false;\n private namePrefix: string;\n\n /**\n * @param namePrefix - Optional override for the configured prefix.\n * Defaults to the value from `configure({ namePrefix })` (or `'t'`).\n * Pass an explicit prefix when constructing a collector outside the\n * normal configure() lifecycle (e.g. in tests). Validated eagerly\n * so misconfiguration fails before any CSS is collected.\n */\n constructor(namePrefix?: string) {\n if (namePrefix !== undefined) {\n validateNamePrefix(namePrefix);\n }\n this.namePrefix = namePrefix ?? getNamePrefix();\n }\n\n private generateClassName(cacheKey: string): string {\n return makeClassName(this.namePrefix, hashString(cacheKey));\n }\n\n /**\n * Collect internal @property rules and :root token defaults.\n * Mirrors markStylesGenerated() from the client-side injector.\n * Called automatically on first chunk collection; idempotent.\n *\n * Internals are always emitted here — the RSC path deliberately\n * defers to SSR so that tokens appear exactly once per page in\n * <style data-tasty-ssr> (avoiding duplication of large token sets).\n */\n collectInternals(): void {\n if (this.internalsCollected) return;\n this.internalsCollected = true;\n\n for (const [token, definition] of Object.entries(\n getEffectiveProperties(),\n )) {\n const css = formatPropertyCSS(token, definition);\n if (css) {\n this.collectProperty(`__prop:${token}`, css);\n }\n }\n\n const tokenStyles = getGlobalConfigTokens();\n if (tokenStyles && Object.keys(tokenStyles).length > 0) {\n const tokenRules = renderStyles(tokenStyles, ':root') as StyleResult[];\n if (tokenRules.length > 0) {\n const css = formatGlobalRules(tokenRules);\n if (css) {\n this.collectGlobalStyles('__global:tokens', css);\n }\n }\n }\n\n const globalFF = getGlobalFontFace();\n if (globalFF) {\n for (const [family, input] of Object.entries(globalFF)) {\n const descriptors = Array.isArray(input) ? input : [input];\n for (const desc of descriptors) {\n const hash = fontFaceContentHash(family, desc);\n const css = formatFontFaceRule(family, desc);\n this.collectFontFace(hash, css);\n }\n }\n }\n\n const globalCS = getGlobalCounterStyle();\n if (globalCS) {\n for (const [name, descriptors] of Object.entries(globalCS)) {\n const css = formatCounterStyleRule(name, descriptors);\n this.collectCounterStyle(name, css);\n }\n }\n\n const globalStyles = getGlobalStyles();\n if (globalStyles) {\n for (const [selector, styles] of Object.entries(globalStyles)) {\n if (Object.keys(styles).length > 0) {\n const rules = renderStyles(styles, selector) as StyleResult[];\n if (rules.length > 0) {\n const css = formatGlobalRules(rules);\n if (css) {\n this.collectGlobalStyles(`__global:styles:${selector}`, css);\n }\n }\n }\n }\n }\n }\n\n /**\n * Allocate a className for a cache key, server-side.\n * Mirrors StyleInjector.allocateClassName but without DOM access.\n */\n allocateClassName(cacheKey: string): {\n className: string;\n isNewAllocation: boolean;\n } {\n const existing = this.cacheKeyToClassName.get(cacheKey);\n if (existing) {\n return { className: existing, isNewAllocation: false };\n }\n\n const className = this.generateClassName(cacheKey);\n this.cacheKeyToClassName.set(cacheKey, className);\n\n return { className, isNewAllocation: true };\n }\n\n /**\n * Record CSS rules for a chunk.\n * Called by useStyles during server render.\n */\n collectChunk(\n cacheKey: string,\n className: string,\n rules: StyleResult[],\n ): void {\n if (this.chunks.has(cacheKey)) return;\n const css = formatRules(rules, className);\n if (css) {\n this.chunks.set(cacheKey, css);\n }\n }\n\n /**\n * Record a @property rule. Deduplicated by name.\n */\n collectProperty(name: string, css: string): void {\n if (!this.propertyRules.has(name)) {\n this.propertyRules.set(name, css);\n }\n }\n\n /**\n * Record a @keyframes rule. Deduplicated by name.\n */\n collectKeyframes(name: string, css: string): void {\n if (!this.keyframeRules.has(name)) {\n this.keyframeRules.set(name, css);\n }\n }\n\n /**\n * Allocate a keyframe name for SSR. Uses provided name or generates one.\n */\n allocateKeyframeName(providedName?: string): string {\n return (\n providedName ??\n makeKeyframeName(this.namePrefix, String(this.keyframesCounter++))\n );\n }\n\n /**\n * Record a @font-face rule. Deduplicated by key (content hash).\n */\n collectFontFace(key: string, css: string): void {\n if (!this.fontFaceRules.has(key)) {\n this.fontFaceRules.set(key, css);\n }\n }\n\n /**\n * Record a @counter-style rule. Deduplicated by name.\n */\n collectCounterStyle(name: string, css: string): void {\n if (!this.counterStyleRules.has(name)) {\n this.counterStyleRules.set(name, css);\n }\n }\n\n /**\n * Allocate a counter-style name for SSR. Uses provided name or generates one.\n */\n allocateCounterStyleName(providedName?: string): string {\n return (\n providedName ??\n makeCounterStyleName(this.namePrefix, String(this.counterStyleCounter++))\n );\n }\n\n /**\n * Record global styles (from useGlobalStyles). Deduplicated by key.\n */\n collectGlobalStyles(key: string, css: string): void {\n if (!this.globalStyles.has(key)) {\n this.globalStyles.set(key, css);\n }\n }\n\n /**\n * Record raw CSS text (from useRawCSS). Deduplicated by key.\n */\n collectRawCSS(key: string, css: string): void {\n if (!this.rawCSS.has(key)) {\n this.rawCSS.set(key, css);\n }\n }\n\n /**\n * Extract all CSS collected so far as a single string.\n * Includes @property and @keyframes rules.\n * Used for non-streaming SSR (renderToString).\n */\n getCSS(): string {\n const parts: string[] = [];\n\n for (const css of this.propertyRules.values()) {\n parts.push(css);\n }\n\n for (const css of this.fontFaceRules.values()) {\n parts.push(css);\n }\n\n for (const css of this.counterStyleRules.values()) {\n parts.push(css);\n }\n\n for (const css of this.rawCSS.values()) {\n parts.push(css);\n }\n\n for (const css of this.globalStyles.values()) {\n parts.push(css);\n }\n\n for (const css of this.chunks.values()) {\n parts.push(css);\n }\n\n for (const css of this.keyframeRules.values()) {\n parts.push(css);\n }\n\n return parts.join('\\n');\n }\n\n /**\n * Flush only newly collected CSS since the last flush.\n * Used for streaming SSR (renderToPipeableStream + useServerInsertedHTML).\n */\n flushCSS(): string {\n const parts: string[] = [];\n\n for (const [name, css] of this.propertyRules) {\n if (!this.flushedPropertyKeys.has(name)) {\n parts.push(css);\n this.flushedPropertyKeys.add(name);\n }\n }\n\n for (const [key, css] of this.fontFaceRules) {\n if (!this.flushedFontFaceKeys.has(key)) {\n parts.push(css);\n this.flushedFontFaceKeys.add(key);\n }\n }\n\n for (const [key, css] of this.counterStyleRules) {\n if (!this.flushedCounterStyleKeys.has(key)) {\n parts.push(css);\n this.flushedCounterStyleKeys.add(key);\n }\n }\n\n for (const [key, css] of this.rawCSS) {\n if (!this.flushedRawKeys.has(key)) {\n parts.push(css);\n this.flushedRawKeys.add(key);\n }\n }\n\n for (const [key, css] of this.globalStyles) {\n if (!this.flushedGlobalKeys.has(key)) {\n parts.push(css);\n this.flushedGlobalKeys.add(key);\n }\n }\n\n for (const [key, css] of this.chunks) {\n if (!this.flushedKeys.has(key)) {\n parts.push(css);\n this.flushedKeys.add(key);\n }\n }\n\n for (const [name, css] of this.keyframeRules) {\n if (!this.flushedKeyframeKeys.has(name)) {\n parts.push(css);\n this.flushedKeyframeKeys.add(name);\n }\n }\n\n return parts.join('\\n');\n }\n\n private flushedClassNames = new Set<string>();\n\n /**\n * Return class names rendered since the last call (for streaming).\n * Used to emit lightweight class-list scripts for client hydration.\n */\n getRenderedClassNames(): string[] {\n const names: string[] = [];\n for (const className of this.cacheKeyToClassName.values()) {\n if (!this.flushedClassNames.has(className)) {\n this.flushedClassNames.add(className);\n names.push(className);\n }\n }\n return names;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAoCA,IAAa,uBAAb,MAAkC;CAChC,yBAAiB,IAAI,KAAqB;CAC1C,sCAA8B,IAAI,KAAqB;CACvD,8BAAsB,IAAI,KAAa;CACvC,gCAAwB,IAAI,KAAqB;CACjD,sCAA8B,IAAI,KAAa;CAC/C,gCAAwB,IAAI,KAAqB;CACjD,sCAA8B,IAAI,KAAa;CAC/C,+BAAuB,IAAI,KAAqB;CAChD,oCAA4B,IAAI,KAAa;CAC7C,yBAAiB,IAAI,KAAqB;CAC1C,iCAAyB,IAAI,KAAa;CAC1C,gCAAwB,IAAI,KAAqB;CACjD,sCAA8B,IAAI,KAAa;CAC/C,oCAA4B,IAAI,KAAqB;CACrD,0CAAkC,IAAI,KAAa;CACn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KAAK,mBAC5B,IAAI,CAAC,KAAK,wBAAwB,IAAI,IAAI,EAAE;GAC1C,MAAM,KAAK,IAAI;GACf,KAAK,wBAAwB,IAAI,IAAI;;EAIzC,KAAK,MAAM,CAAC,KAAK,QAAQ,KAAK,QAC5B,IAAI,CAAC,KAAK,eAAe,IAAI,IAAI,EAAE;GACjC,MAAM,KAAK,IAAI;GACf,KAAK,eAAe,IAAI,IAAI;;EAIhC,KAAK,MAAM,CAAC,KAAK,QAAQ,KAAK,cAC5B,IAAI,CAAC,KAAK,kBAAkB,IAAI,IAAI,EAAE;GACpC,MAAM,KAAK,IAAI;GACf,KAAK,kBAAkB,IAAI,IAAI;;EAInC,KAAK,MAAM,CAAC,KAAK,QAAQ,KAAK,QAC5B,IAAI,CAAC,KAAK,YAAY,IAAI,IAAI,EAAE;GAC9B,MAAM,KAAK,IAAI;GACf,KAAK,YAAY,IAAI,IAAI;;EAI7B,KAAK,MAAM,CAAC,MAAM,QAAQ,KAAK,eAC7B,IAAI,CAAC,KAAK,oBAAoB,IAAI,KAAK,EAAE;GACvC,MAAM,KAAK,IAAI;GACf,KAAK,oBAAoB,IAAI,KAAK;;EAItC,OAAO,MAAM,KAAK,KAAK;;CAGzB,oCAA4B,IAAI,KAAa;;;;;CAM7C,wBAAkC;EAChC,MAAM,QAAkB,EAAE;EAC1B,KAAK,MAAM,aAAa,KAAK,oBAAoB,QAAQ,EACvD,IAAI,CAAC,KAAK,kBAAkB,IAAI,UAAU,EAAE;GAC1C,KAAK,kBAAkB,IAAI,UAAU;GACrC,MAAM,KAAK,UAAU;;EAGzB,OAAO"}
1
+ {"version":3,"file":"collector-BEF4F_PE.js","names":[],"sources":["../src/ssr/collector.ts"],"sourcesContent":["/**\n * ServerStyleCollector — server-safe style collector for SSR.\n *\n * Accumulates CSS rules and cache metadata during server rendering.\n * This is the server-side counterpart to StyleInjector: it allocates\n * hash-based class names using the configured `namePrefix` (defaults\n * to `'t'`), formats CSS rules into text, and tracks rendered class\n * names for lightweight client transfer.\n *\n * One instance is created per HTTP request. Concurrent requests\n * each get their own collector (via AsyncLocalStorage or React context).\n */\n\nimport {\n getEffectiveProperties,\n getGlobalStyles,\n getGlobalCounterStyle,\n getGlobalFontFace,\n getGlobalConfigTokens,\n getNamePrefix,\n} from '../config';\nimport { formatCounterStyleRule } from '../counter-style';\nimport { fontFaceContentHash, formatFontFaceRule } from '../font-face';\nimport { renderStyles } from '../pipeline';\nimport type { StyleResult } from '../pipeline';\nimport { hashString } from '../utils/hash';\nimport {\n makeClassName,\n makeCounterStyleName,\n makeKeyframeName,\n validateNamePrefix,\n} from '../utils/name-prefix';\nimport { formatPropertyCSS } from './format-property';\nimport { formatGlobalRules } from './format-global-rules';\nimport { formatRules } from './format-rules';\n\nexport class ServerStyleCollector {\n private chunks = new Map<string, string>();\n private cacheKeyToClassName = new Map<string, string>();\n private flushedKeys = new Set<string>();\n private propertyRules = new Map<string, string>();\n private flushedPropertyKeys = new Set<string>();\n private keyframeRules = new Map<string, string>();\n private flushedKeyframeKeys = new Set<string>();\n private globalStyles = new Map<string, string>();\n private flushedGlobalKeys = new Set<string>();\n private rawCSS = new Map<string, string>();\n private flushedRawKeys = new Set<string>();\n private fontFaceRules = new Map<string, string>();\n private flushedFontFaceKeys = new Set<string>();\n private counterStyleRules = new Map<string, string>();\n private flushedCounterStyleKeys = new Set<string>();\n private keyframesCounter = 0;\n private counterStyleCounter = 0;\n private internalsCollected = false;\n private namePrefix: string;\n\n /**\n * @param namePrefix - Optional override for the configured prefix.\n * Defaults to the value from `configure({ namePrefix })` (or `'t'`).\n * Pass an explicit prefix when constructing a collector outside the\n * normal configure() lifecycle (e.g. in tests). Validated eagerly\n * so misconfiguration fails before any CSS is collected.\n */\n constructor(namePrefix?: string) {\n if (namePrefix !== undefined) {\n validateNamePrefix(namePrefix);\n }\n this.namePrefix = namePrefix ?? getNamePrefix();\n }\n\n private generateClassName(cacheKey: string): string {\n return makeClassName(this.namePrefix, hashString(cacheKey));\n }\n\n /**\n * Collect internal @property rules and :root token defaults.\n * Mirrors markStylesGenerated() from the client-side injector.\n * Called automatically on first chunk collection; idempotent.\n *\n * Internals are always emitted here — the RSC path deliberately\n * defers to SSR so that tokens appear exactly once per page in\n * <style data-tasty-ssr> (avoiding duplication of large token sets).\n */\n collectInternals(): void {\n if (this.internalsCollected) return;\n this.internalsCollected = true;\n\n for (const [token, definition] of Object.entries(\n getEffectiveProperties(),\n )) {\n const css = formatPropertyCSS(token, definition);\n if (css) {\n this.collectProperty(`__prop:${token}`, css);\n }\n }\n\n const tokenStyles = getGlobalConfigTokens();\n if (tokenStyles && Object.keys(tokenStyles).length > 0) {\n const tokenRules = renderStyles(tokenStyles, ':root') as StyleResult[];\n if (tokenRules.length > 0) {\n const css = formatGlobalRules(tokenRules);\n if (css) {\n this.collectGlobalStyles('__global:tokens', css);\n }\n }\n }\n\n const globalFF = getGlobalFontFace();\n if (globalFF) {\n for (const [family, input] of Object.entries(globalFF)) {\n const descriptors = Array.isArray(input) ? input : [input];\n for (const desc of descriptors) {\n const hash = fontFaceContentHash(family, desc);\n const css = formatFontFaceRule(family, desc);\n this.collectFontFace(hash, css);\n }\n }\n }\n\n const globalCS = getGlobalCounterStyle();\n if (globalCS) {\n for (const [name, descriptors] of Object.entries(globalCS)) {\n const css = formatCounterStyleRule(name, descriptors);\n this.collectCounterStyle(name, css);\n }\n }\n\n const globalStyles = getGlobalStyles();\n if (globalStyles) {\n for (const [selector, styles] of Object.entries(globalStyles)) {\n if (Object.keys(styles).length > 0) {\n const rules = renderStyles(styles, selector) as StyleResult[];\n if (rules.length > 0) {\n const css = formatGlobalRules(rules);\n if (css) {\n this.collectGlobalStyles(`__global:styles:${selector}`, css);\n }\n }\n }\n }\n }\n }\n\n /**\n * Allocate a className for a cache key, server-side.\n * Mirrors StyleInjector.allocateClassName but without DOM access.\n */\n allocateClassName(cacheKey: string): {\n className: string;\n isNewAllocation: boolean;\n } {\n const existing = this.cacheKeyToClassName.get(cacheKey);\n if (existing) {\n return { className: existing, isNewAllocation: false };\n }\n\n const className = this.generateClassName(cacheKey);\n this.cacheKeyToClassName.set(cacheKey, className);\n\n return { className, isNewAllocation: true };\n }\n\n /**\n * Record CSS rules for a chunk.\n * Called by useStyles during server render.\n */\n collectChunk(\n cacheKey: string,\n className: string,\n rules: StyleResult[],\n ): void {\n if (this.chunks.has(cacheKey)) return;\n const css = formatRules(rules, className);\n if (css) {\n this.chunks.set(cacheKey, css);\n }\n }\n\n /**\n * Record a @property rule. Deduplicated by name.\n */\n collectProperty(name: string, css: string): void {\n if (!this.propertyRules.has(name)) {\n this.propertyRules.set(name, css);\n }\n }\n\n /**\n * Record a @keyframes rule. Deduplicated by name.\n */\n collectKeyframes(name: string, css: string): void {\n if (!this.keyframeRules.has(name)) {\n this.keyframeRules.set(name, css);\n }\n }\n\n /**\n * Allocate a keyframe name for SSR. Uses provided name or generates one.\n */\n allocateKeyframeName(providedName?: string): string {\n return (\n providedName ??\n makeKeyframeName(this.namePrefix, String(this.keyframesCounter++))\n );\n }\n\n /**\n * Record a @font-face rule. Deduplicated by key (content hash).\n */\n collectFontFace(key: string, css: string): void {\n if (!this.fontFaceRules.has(key)) {\n this.fontFaceRules.set(key, css);\n }\n }\n\n /**\n * Record a @counter-style rule. Deduplicated by name.\n */\n collectCounterStyle(name: string, css: string): void {\n if (!this.counterStyleRules.has(name)) {\n this.counterStyleRules.set(name, css);\n }\n }\n\n /**\n * Allocate a counter-style name for SSR. Uses provided name or generates one.\n */\n allocateCounterStyleName(providedName?: string): string {\n return (\n providedName ??\n makeCounterStyleName(this.namePrefix, String(this.counterStyleCounter++))\n );\n }\n\n /**\n * Record global styles (from useGlobalStyles). Deduplicated by key.\n */\n collectGlobalStyles(key: string, css: string): void {\n if (!this.globalStyles.has(key)) {\n this.globalStyles.set(key, css);\n }\n }\n\n /**\n * Record raw CSS text (from useRawCSS). Deduplicated by key.\n */\n collectRawCSS(key: string, css: string): void {\n if (!this.rawCSS.has(key)) {\n this.rawCSS.set(key, css);\n }\n }\n\n /**\n * Extract all CSS collected so far as a single string.\n * Includes @property and @keyframes rules.\n * Used for non-streaming SSR (renderToString).\n */\n getCSS(): string {\n const parts: string[] = [];\n\n for (const css of this.propertyRules.values()) {\n parts.push(css);\n }\n\n for (const css of this.fontFaceRules.values()) {\n parts.push(css);\n }\n\n for (const css of this.counterStyleRules.values()) {\n parts.push(css);\n }\n\n for (const css of this.rawCSS.values()) {\n parts.push(css);\n }\n\n for (const css of this.globalStyles.values()) {\n parts.push(css);\n }\n\n for (const css of this.chunks.values()) {\n parts.push(css);\n }\n\n for (const css of this.keyframeRules.values()) {\n parts.push(css);\n }\n\n return parts.join('\\n');\n }\n\n /**\n * Flush only newly collected CSS since the last flush.\n * Used for streaming SSR (renderToPipeableStream + useServerInsertedHTML).\n */\n flushCSS(): string {\n const parts: string[] = [];\n\n for (const [name, css] of this.propertyRules) {\n if (!this.flushedPropertyKeys.has(name)) {\n parts.push(css);\n this.flushedPropertyKeys.add(name);\n }\n }\n\n for (const [key, css] of this.fontFaceRules) {\n if (!this.flushedFontFaceKeys.has(key)) {\n parts.push(css);\n this.flushedFontFaceKeys.add(key);\n }\n }\n\n for (const [key, css] of this.counterStyleRules) {\n if (!this.flushedCounterStyleKeys.has(key)) {\n parts.push(css);\n this.flushedCounterStyleKeys.add(key);\n }\n }\n\n for (const [key, css] of this.rawCSS) {\n if (!this.flushedRawKeys.has(key)) {\n parts.push(css);\n this.flushedRawKeys.add(key);\n }\n }\n\n for (const [key, css] of this.globalStyles) {\n if (!this.flushedGlobalKeys.has(key)) {\n parts.push(css);\n this.flushedGlobalKeys.add(key);\n }\n }\n\n for (const [key, css] of this.chunks) {\n if (!this.flushedKeys.has(key)) {\n parts.push(css);\n this.flushedKeys.add(key);\n }\n }\n\n for (const [name, css] of this.keyframeRules) {\n if (!this.flushedKeyframeKeys.has(name)) {\n parts.push(css);\n this.flushedKeyframeKeys.add(name);\n }\n }\n\n return parts.join('\\n');\n }\n\n private flushedClassNames = new Set<string>();\n\n /**\n * Return class names rendered since the last call (for streaming).\n * Used to emit lightweight class-list scripts for client hydration.\n */\n getRenderedClassNames(): string[] {\n const names: string[] = [];\n for (const className of this.cacheKeyToClassName.values()) {\n if (!this.flushedClassNames.has(className)) {\n this.flushedClassNames.add(className);\n names.push(className);\n }\n }\n return names;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAoCA,IAAa,uBAAb,MAAkC;CAChC,yBAAiB,IAAI,KAAqB;CAC1C,sCAA8B,IAAI,KAAqB;CACvD,8BAAsB,IAAI,KAAa;CACvC,gCAAwB,IAAI,KAAqB;CACjD,sCAA8B,IAAI,KAAa;CAC/C,gCAAwB,IAAI,KAAqB;CACjD,sCAA8B,IAAI,KAAa;CAC/C,+BAAuB,IAAI,KAAqB;CAChD,oCAA4B,IAAI,KAAa;CAC7C,yBAAiB,IAAI,KAAqB;CAC1C,iCAAyB,IAAI,KAAa;CAC1C,gCAAwB,IAAI,KAAqB;CACjD,sCAA8B,IAAI,KAAa;CAC/C,oCAA4B,IAAI,KAAqB;CACrD,0CAAkC,IAAI,KAAa;CACnD,mBAA2B;CAC3B,sBAA8B;CAC9B,qBAA6B;CAC7B;;;;;;;;CASA,YAAY,YAAqB;EAC/B,IAAI,eAAe,KAAA,GACjB,mBAAmB,WAAW;EAEhC,KAAK,aAAa,cAAc,eAAe;;CAGjD,kBAA0B,UAA0B;EAClD,OAAO,cAAc,KAAK,YAAY,WAAW,SAAS,CAAC;;;;;;;;;;;CAY7D,mBAAyB;EACvB,IAAI,KAAK,oBAAoB;EAC7B,KAAK,qBAAqB;EAE1B,KAAK,MAAM,CAAC,OAAO,eAAe,OAAO,QACvC,wBAAwB,CACzB,EAAE;GACD,MAAM,MAAM,kBAAkB,OAAO,WAAW;GAChD,IAAI,KACF,KAAK,gBAAgB,UAAU,SAAS,IAAI;;EAIhD,MAAM,cAAc,uBAAuB;EAC3C,IAAI,eAAe,OAAO,KAAK,YAAY,CAAC,SAAS,GAAG;GAC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K,YAAY,IAAI,IAAI;;EAI7B,KAAK,MAAM,CAAC,MAAM,QAAQ,KAAK,eAC7B,IAAI,CAAC,KAAK,oBAAoB,IAAI,KAAK,EAAE;GACvC,MAAM,KAAK,IAAI;GACf,KAAK,oBAAoB,IAAI,KAAK;;EAItC,OAAO,MAAM,KAAK,KAAK;;CAGzB,oCAA4B,IAAI,KAAa;;;;;CAM7C,wBAAkC;EAChC,MAAM,QAAkB,EAAE;EAC1B,KAAK,MAAM,aAAa,KAAK,oBAAoB,QAAQ,EACvD,IAAI,CAAC,KAAK,kBAAkB,IAAI,UAAU,EAAE;GAC1C,KAAK,kBAAkB,IAAI,UAAU;GACrC,MAAM,KAAK,UAAU;;EAGzB,OAAO"}
@@ -1,4 +1,4 @@
1
- import { n as StyleResult } from "./index-tcHuMPFt.js";
1
+ import { n as StyleResult } from "./index-BsJz5xBF.js";
2
2
 
3
3
  //#region src/ssr/collector.d.ts
4
4
  declare class ServerStyleCollector {
@@ -105,4 +105,4 @@ declare class ServerStyleCollector {
105
105
  }
106
106
  //#endregion
107
107
  export { ServerStyleCollector as t };
108
- //# sourceMappingURL=collector-osfWTeRd.d.ts.map
108
+ //# sourceMappingURL=collector-CpU85p2G.d.ts.map
@@ -1,4 +1,4 @@
1
- import { Ct as RawCSSResult, Dt as StyleInjectorConfig, Et as SheetInfo, M as StyleHandlerDefinition, Ot as StyleRule, St as PropertyDefinition, Tt as RuleInfo, b as Styles, bt as KeyframesResult, ct as CacheMetrics, dt as FontFaceDescriptors, ft as FontFaceInput, gt as InjectResult, h as ConfigTokens, ht as GlobalInjectResult, it as StyleDetails, lt as CounterStyleDescriptors, mt as GCOptions, n as StyleResult, ot as UnitHandler, pt as GCConfig, v as RecipeStyles, wt as RootRegistry, xt as KeyframesSteps, yt as KeyframesInfo } from "./index-tcHuMPFt.js";
1
+ import { Ct as RawCSSResult, Dt as StyleInjectorConfig, Et as SheetInfo, M as StyleHandlerDefinition, Ot as StyleRule, St as PropertyDefinition, Tt as RuleInfo, b as Styles, bt as KeyframesResult, ct as CacheMetrics, dt as FontFaceDescriptors, ft as FontFaceInput, gt as InjectResult, h as ConfigTokens, ht as GlobalInjectResult, it as StyleDetails, lt as CounterStyleDescriptors, mt as GCOptions, n as StyleResult, ot as UnitHandler, pt as GCConfig, v as RecipeStyles, wt as RootRegistry, xt as KeyframesSteps, yt as KeyframesInfo } from "./index-BsJz5xBF.js";
2
2
 
3
3
  //#region src/injector/sheet-manager.d.ts
4
4
  declare class SheetManager {
@@ -942,4 +942,4 @@ declare function getNamePrefix(): string;
942
942
  declare function resetConfig(): void;
943
943
  //#endregion
944
944
  export { SheetManager as S, TypographyPreset as _, getGlobalFontFace as a, ColorSpace as b, getNamePrefix as c, hasStylesGenerated as d, isConfigLocked as f, TastyPluginFactory as g, TastyPlugin as h, getGlobalCounterStyle as i, hasGlobalKeyframes as l, resetConfig as m, configure as n, getGlobalKeyframes as o, isTestEnvironment as p, getConfig as r, getGlobalRecipes as s, TastyConfig as t, hasGlobalRecipes as u, TypographyTokenValue as v, StyleInjector as x, generateTypographyTokens as y };
945
- //# sourceMappingURL=config-BoZDUHW5.d.ts.map
945
+ //# sourceMappingURL=config-3h7BtX4l.d.ts.map
@@ -453,7 +453,19 @@ const K2 = .03;
453
453
  const K3 = (1 + K1) / (1 + K2);
454
454
  const clamp$1 = (value, min, max) => Math.max(Math.min(value, max), min);
455
455
  const constrainAngle = (angle) => (angle % 360 + 360) % 360;
456
+ const toe = (x) => .5 * (K3 * x - K1 + Math.sqrt((K3 * x - K1) * (K3 * x - K1) + 4 * K2 * K3 * x));
456
457
  const toeInv = (x) => (x ** 2 + K1 * x) / (K3 * (x + K2));
458
+ const OKHST_REF_EPS = .05;
459
+ function yToL(y) {
460
+ return toe(Math.cbrt(Math.max(0, y)));
461
+ }
462
+ function yFromTone(t, eps = OKHST_REF_EPS) {
463
+ const den = Math.log(1 + eps) - Math.log(eps);
464
+ return Math.exp(t / 100 * den + Math.log(eps)) - eps;
465
+ }
466
+ function fromTone(t, eps = OKHST_REF_EPS) {
467
+ return yToL(yFromTone(t, eps));
468
+ }
457
469
  const oklabToLinearSrgb = (lab) => {
458
470
  const L = lab[0];
459
471
  const a = lab[1];
@@ -745,6 +757,16 @@ function okhslToSrgb(h, s, l) {
745
757
  ];
746
758
  }
747
759
  /**
760
+ * OKHST to sRGB (0-1 range).
761
+ * @param h - Hue in degrees (0-360)
762
+ * @param s - Saturation (0-1)
763
+ * @param t - Tone (0-1)
764
+ * @returns sRGB values in 0-1 range, clamped to gamut
765
+ */
766
+ function okhstToSrgb(h, s, t) {
767
+ return okhslToSrgb(h, clamp$1(s, 0, 1), clamp$1(fromTone(t * 100), 0, 1));
768
+ }
769
+ /**
748
770
  * OKLCH to sRGB (0-255 range).
749
771
  * @param L - Lightness (0-1)
750
772
  * @param C - Chroma (typically 0-0.4)
@@ -1024,7 +1046,7 @@ function getRgbValuesFromRgbaString(str) {
1024
1046
  }
1025
1047
  /**
1026
1048
  * Convert any recognized color string to an `rgb()` CSS string.
1027
- * Handles hex, `okhsl()`, `hsl()`/`hsla()`, named CSS colors,
1049
+ * Handles hex, `okhsl()`, `okhst()`, `hsl()`/`hsla()`, named CSS colors,
1028
1050
  * and `rgb()`/`rgba()` pass-through.
1029
1051
  */
1030
1052
  function strToRgb(color, _ignoreAlpha = false) {
@@ -1033,6 +1055,7 @@ function strToRgb(color, _ignoreAlpha = false) {
1033
1055
  if (color.startsWith("#")) return hexToRgb(color);
1034
1056
  if (color.startsWith("oklch(")) return oklchStringToRgb(color);
1035
1057
  if (color.startsWith("okhsl(")) return okhslStringToRgb(color);
1058
+ if (color.startsWith("okhst(")) return okhstStringToRgb(color);
1036
1059
  if (color.startsWith("hsl")) return hslStringToRgb(color);
1037
1060
  const namedHex = getNamedColorHex().get(color.toLowerCase());
1038
1061
  if (namedHex) return hexToRgb(namedHex);
@@ -1097,6 +1120,34 @@ function okhslStringToRgb(okhslStr) {
1097
1120
  return `rgb(${r255} ${g255} ${b255})`;
1098
1121
  }
1099
1122
  /**
1123
+ * Convert an `okhst()` color string to an `rgb()`/`rgba()` CSS string.
1124
+ * Supports deg/turn/rad hue units and percentage saturation/tone.
1125
+ */
1126
+ function okhstStringToRgb(okhstStr) {
1127
+ const match = okhstStr.match(/okhst\(([^)]+)\)/i);
1128
+ if (!match) return null;
1129
+ const [colorPart, alphaPart] = match[1].trim().split("/");
1130
+ const parts = colorPart.trim().split(/[,\s]+/).filter(Boolean);
1131
+ if (parts.length < 3) return null;
1132
+ let h = parseFloat(parts[0]);
1133
+ const hueStr = parts[0].toLowerCase();
1134
+ if (hueStr.endsWith("turn")) h = parseFloat(hueStr) * 360;
1135
+ else if (hueStr.endsWith("rad")) h = parseFloat(hueStr) * 180 / Math.PI;
1136
+ else if (hueStr.endsWith("deg")) h = parseFloat(hueStr);
1137
+ const parsePercent = (val) => {
1138
+ const num = parseFloat(val);
1139
+ return val.includes("%") ? num / 100 : num;
1140
+ };
1141
+ const s = Math.max(0, Math.min(1, parsePercent(parts[1])));
1142
+ const t = Math.max(0, Math.min(1, parsePercent(parts[2])));
1143
+ const [r, g, b] = okhstToSrgb(h, s, t);
1144
+ const r255 = Math.round(Math.max(0, Math.min(1, r)) * 255);
1145
+ const g255 = Math.round(Math.max(0, Math.min(1, g)) * 255);
1146
+ const b255 = Math.round(Math.max(0, Math.min(1, b)) * 255);
1147
+ if (alphaPart) return `rgba(${r255}, ${g255}, ${b255}, ${parseFloat(alphaPart.trim())})`;
1148
+ return `rgb(${r255} ${g255} ${b255})`;
1149
+ }
1150
+ /**
1100
1151
  * Convert an `oklch()` color string to an `rgb()`/`rgba()` CSS string.
1101
1152
  * Supports deg/turn/rad hue units and percentage lightness.
1102
1153
  */
@@ -1269,6 +1320,17 @@ function resolveToRgbaValues(color) {
1269
1320
  parsed.alpha
1270
1321
  ];
1271
1322
  }
1323
+ if (trimmed.startsWith("okhst(")) {
1324
+ const parsed = parseColorFuncArgs(trimmed, "okhst");
1325
+ if (!parsed) return null;
1326
+ const [r, g, b] = okhstToSrgb(parseHue(parsed.parts[0]), clamp01(parsePercent(parsed.parts[1])), clamp01(parsePercent(parsed.parts[2])));
1327
+ return [
1328
+ clamp01(r) * 255,
1329
+ clamp01(g) * 255,
1330
+ clamp01(b) * 255,
1331
+ parsed.alpha
1332
+ ];
1333
+ }
1272
1334
  const fallback = strToRgb(trimmed);
1273
1335
  if (fallback) {
1274
1336
  if (fallback !== trimmed) return resolveToRgbaValues(fallback);
@@ -1602,7 +1664,7 @@ function classify(raw, opts, recurse) {
1602
1664
  if (baseToken in predefinedTokens) {
1603
1665
  const resolvedValue = predefinedTokens[baseToken];
1604
1666
  if (resolvedValue.startsWith("#")) return classify(`${resolvedValue.toLowerCase()}.${rawAlpha}`, opts, recurse);
1605
- const funcMatch = resolvedValue.match(/^(rgba?|hsla?|hwb|oklab|oklch|lab|lch|color|okhsl|device-cmyk|gray|color-mix|color-contrast)\((.+)\)$/i);
1667
+ const funcMatch = resolvedValue.match(/^(rgba?|hsla?|hwb|oklab|oklch|lab|lch|color|okhsl|okhst|device-cmyk|gray|color-mix|color-contrast)\((.+)\)$/i);
1606
1668
  if (funcMatch) {
1607
1669
  const [, funcName, args] = funcMatch;
1608
1670
  let alpha;
@@ -1983,20 +2045,7 @@ var StyleParser = class {
1983
2045
  }
1984
2046
  };
1985
2047
  //#endregion
1986
- //#region src/plugins/okhsl-plugin.ts
1987
- /**
1988
- * OKHSL Plugin for Tasty
1989
- *
1990
- * Converts OKHSL color syntax to RGB notation.
1991
- * Supports angle units: deg, turn, rad, or unitless (degrees).
1992
- *
1993
- * Examples:
1994
- * okhsl(240.5 50% 50%)
1995
- * okhsl(240.5deg 50% 50%)
1996
- * okhsl(0.25turn 50% 50%)
1997
- * okhsl(1.57rad 50% 50%)
1998
- */
1999
- const conversionCache = new Lru(500);
2048
+ //#region src/plugins/color-func.ts
2000
2049
  const clamp = (value, min, max) => Math.max(Math.min(value, max), min);
2001
2050
  /**
2002
2051
  * Parse an angle value with optional unit.
@@ -2022,32 +2071,56 @@ const parsePercentage = (value) => {
2022
2071
  return value.includes("%") ? num / 100 : num;
2023
2072
  };
2024
2073
  /**
2074
+ * Creates a color function handler for the tasty parser.
2075
+ * @param name The name of the color space (e.g., 'okhsl', 'okhst')
2076
+ * @param channelLabel The label for the channels in warnings (e.g., 'H S L')
2077
+ * @param convert A function that converts the parsed H, C2, C3 values to sRGB [r, g, b] (0-1)
2078
+ */
2079
+ function createColorFunc(name, channelLabel, convert) {
2080
+ const conversionCache = new Lru(500);
2081
+ return (groups) => {
2082
+ if (groups.length === 0 || groups[0].all.length < 3) {
2083
+ console.warn(`[${name}] Expected 3 values (${channelLabel}), got:`, groups);
2084
+ return "rgb(0% 0% 0%)";
2085
+ }
2086
+ const group = groups[0];
2087
+ const tokens = group.all;
2088
+ const alpha = group.parts.length > 1 && group.parts[1].all.length > 0 ? group.parts[1].output : void 0;
2089
+ const cacheKey = tokens.slice(0, 3).join(" ") + (alpha ? ` / ${alpha}` : "");
2090
+ const cached = conversionCache.get(cacheKey);
2091
+ if (cached) return cached;
2092
+ const h = parseAngle(tokens[0]);
2093
+ const c2 = parsePercentage(tokens[1]);
2094
+ const c3 = parsePercentage(tokens[2]);
2095
+ const [r, g, b] = convert(h, clamp(c2, 0, 1), clamp(c3, 0, 1));
2096
+ const format = (n) => {
2097
+ const pct = n * 100;
2098
+ return parseFloat(pct.toFixed(1)).toString() + "%";
2099
+ };
2100
+ const result = alpha ? `rgb(${format(r)} ${format(g)} ${format(b)} / ${alpha})` : `rgb(${format(r)} ${format(g)} ${format(b)})`;
2101
+ conversionCache.set(cacheKey, result);
2102
+ return result;
2103
+ };
2104
+ }
2105
+ //#endregion
2106
+ //#region src/plugins/okhsl-plugin.ts
2107
+ /**
2108
+ * OKHSL Plugin for Tasty
2109
+ *
2110
+ * Converts OKHSL color syntax to RGB notation.
2111
+ * Supports angle units: deg, turn, rad, or unitless (degrees).
2112
+ *
2113
+ * Examples:
2114
+ * okhsl(240.5 50% 50%)
2115
+ * okhsl(240.5deg 50% 50%)
2116
+ * okhsl(0.25turn 50% 50%)
2117
+ * okhsl(1.57rad 50% 50%)
2118
+ */
2119
+ /**
2025
2120
  * The okhsl function handler for tasty parser.
2026
2121
  * Receives parsed style groups and returns an RGB color string.
2027
2122
  */
2028
- const okhslFunc = (groups) => {
2029
- if (groups.length === 0 || groups[0].all.length < 3) {
2030
- console.warn("[okhsl] Expected 3 values (H S L), got:", groups);
2031
- return "rgb(0% 0% 0%)";
2032
- }
2033
- const group = groups[0];
2034
- const tokens = group.all;
2035
- const alpha = group.parts.length > 1 && group.parts[1].all.length > 0 ? group.parts[1].output : void 0;
2036
- const cacheKey = tokens.slice(0, 3).join(" ") + (alpha ? ` / ${alpha}` : "");
2037
- const cached = conversionCache.get(cacheKey);
2038
- if (cached) return cached;
2039
- const h = parseAngle(tokens[0]);
2040
- const s = parsePercentage(tokens[1]);
2041
- const l = parsePercentage(tokens[2]);
2042
- const [r, g, b] = okhslToSrgb(h, clamp(s, 0, 1), clamp(l, 0, 1));
2043
- const format = (n) => {
2044
- const pct = n * 100;
2045
- return parseFloat(pct.toFixed(1)).toString() + "%";
2046
- };
2047
- const result = alpha ? `rgb(${format(r)} ${format(g)} ${format(b)} / ${alpha})` : `rgb(${format(r)} ${format(g)} ${format(b)})`;
2048
- conversionCache.set(cacheKey, result);
2049
- return result;
2050
- };
2123
+ const okhslFunc = createColorFunc("okhsl", "H S L", okhslToSrgb);
2051
2124
  /**
2052
2125
  * OKHSL Plugin for Tasty.
2053
2126
  *
@@ -2075,6 +2148,52 @@ const okhslPlugin = () => ({
2075
2148
  funcs: { okhsl: okhslFunc }
2076
2149
  });
2077
2150
  //#endregion
2151
+ //#region src/plugins/okhst-plugin.ts
2152
+ /**
2153
+ * OKHST Plugin for Tasty
2154
+ *
2155
+ * Converts OKHST color syntax to RGB notation.
2156
+ * OKHST is OKHSL with the lightness axis replaced by a contrast-uniform tone axis.
2157
+ * Supports angle units: deg, turn, rad, or unitless (degrees).
2158
+ *
2159
+ * Examples:
2160
+ * okhst(240.5 50% 50%)
2161
+ * okhst(240.5deg 50% 50%)
2162
+ * okhst(0.25turn 50% 50%)
2163
+ * okhst(1.57rad 50% 50%)
2164
+ */
2165
+ /**
2166
+ * The okhst function handler for tasty parser.
2167
+ * Receives parsed style groups and returns an RGB color string.
2168
+ */
2169
+ const okhstFunc = createColorFunc("okhst", "H S T", okhstToSrgb);
2170
+ /**
2171
+ * OKHST Plugin for Tasty.
2172
+ *
2173
+ * Adds support for the `okhst()` color function in tasty styles.
2174
+ *
2175
+ * @example
2176
+ * ```ts
2177
+ * import { configure } from '@tenphi/tasty';
2178
+ * import { okhstPlugin } from '@tenphi/tasty';
2179
+ *
2180
+ * configure({
2181
+ * plugins: [okhstPlugin()],
2182
+ * });
2183
+ *
2184
+ * // Now you can use okhst in styles:
2185
+ * const Box = tasty({
2186
+ * styles: {
2187
+ * fill: 'okhst(240 50% 50%)',
2188
+ * },
2189
+ * });
2190
+ * ```
2191
+ */
2192
+ const okhstPlugin = () => ({
2193
+ name: "okhst",
2194
+ funcs: { okhst: okhstFunc }
2195
+ });
2196
+ //#endregion
2078
2197
  //#region src/utils/styles.ts
2079
2198
  /**
2080
2199
  * Normalize a color token value.
@@ -2101,7 +2220,7 @@ function isSimpleColorFast(val) {
2101
2220
  case 114: return val.charCodeAt(1) === 103 && val.charCodeAt(2) === 98;
2102
2221
  case 104: return val.charCodeAt(1) === 115 && val.charCodeAt(2) === 108;
2103
2222
  case 108: return val.charCodeAt(1) === 99 && val.charCodeAt(2) === 104;
2104
- case 111: return val.startsWith("oklch(") || val.startsWith("okhsl(");
2223
+ case 111: return val.startsWith("oklch(") || val.startsWith("okhsl(") || val.startsWith("okhst(");
2105
2224
  case 118: return RE_VAR_COLOR.test(val);
2106
2225
  case 99: return val === "currentColor" || val === "currentcolor";
2107
2226
  case 116: return val === "transparent";
@@ -2134,7 +2253,10 @@ function getOrCreateParser() {
2134
2253
  }
2135
2254
  return __tastyParser;
2136
2255
  }
2137
- const __tastyFuncs = { okhsl: okhslFunc };
2256
+ const __tastyFuncs = {
2257
+ okhsl: okhslFunc,
2258
+ okhst: okhstFunc
2259
+ };
2138
2260
  function customFunc(name, fn) {
2139
2261
  __tastyFuncs[name] = fn;
2140
2262
  getOrCreateParser().setFuncs(__tastyFuncs);
@@ -10706,6 +10828,6 @@ function resetConfig() {
10706
10828
  delete storage[GLOBAL_INJECTOR_KEY];
10707
10829
  }
10708
10830
  //#endregion
10709
- export { parseColor as $, StyleInjector as A, hasLocalProperties as At, styleHandlers as B, parseStateKey as C, getRgbValuesFromRgbaString as Ct, extractPredefinedStateRefs as D, Lru as Dt, extractLocalPredefinedStates as E, strToRgb as Et, fontFaceContentHash as F, CUSTOM_UNITS as G, warn as H, formatFontFaceRule as I, filterMods as J, DIRECTIONS as K, hasLocalFontFace as L, formatCounterStyleRule as M, hasLocalCounterStyle as N, getGlobalPredefinedStates as O, extractLocalProperties as Ot, extractLocalFontFace as P, normalizeColorTokenValue as Q, SheetManager as R, renderStyles as S, getNamedColorHex as St, createStateParserContext as T, hslToRgbValues as Tt, createStyle as U, deprecationWarning as V, PropertyTypeResolver as W, getGlobalParser as X, getGlobalFuncs as Y, getGlobalPredefinedTokens as Z, markStylesGenerated as _, colorInitialValueToComponents as _t, getGlobalCounterStyle as a, okhslPlugin as at, hasPipelineCacheEntry as b, getColorSpaceSuffix as bt, getGlobalKeyframes as c, DEFAULT_NAME_PREFIX as ct, getNamePrefix as d, makeCounterStyleName as dt, parseStyle as et, hasGlobalKeyframes as f, makeKeyframeName as ft, isTestEnvironment as g, hashString as gt, isConfigLocked as h, isDevEnv as ht, getGlobalConfigTokens as i, okhslFunc as it, extractLocalCounterStyle as j, parsePropertyToken as jt, setGlobalPredefinedStates as k, getEffectiveDefinition as kt, getGlobalRecipes as l, DEFAULT_ZERO_NAME_PREFIX as lt, hasStylesGenerated as m, validateNamePrefix as mt, getConfig as n, setGlobalPredefinedTokens as nt, getGlobalFontFace as o, StyleParser as ot, hasGlobalRecipes as p, tastyClassRegex as pt, customFunc as q, getEffectiveProperties as r, stringifyStyles as rt, getGlobalInjector as s, Bucket as st, configure as t, resetGlobalPredefinedTokens as tt, getGlobalStyles as u, makeClassName as ut, resetConfig as v, getColorSpaceComponents as vt, camelToKebab as w, hexToRgb as wt, isSelector as x, getComponentPropertySyntax as xt, generateTypographyTokens as y, getColorSpaceFunc as yt, STYLE_HANDLER_MAP as z };
10831
+ export { parseColor as $, StyleInjector as A, extractLocalProperties as At, styleHandlers as B, parseStateKey as C, getComponentPropertySyntax as Ct, extractPredefinedStateRefs as D, hslToRgbValues as Dt, extractLocalPredefinedStates as E, hexToRgb as Et, fontFaceContentHash as F, CUSTOM_UNITS as G, warn as H, formatFontFaceRule as I, filterMods as J, DIRECTIONS as K, hasLocalFontFace as L, formatCounterStyleRule as M, hasLocalProperties as Mt, hasLocalCounterStyle as N, parsePropertyToken as Nt, getGlobalPredefinedStates as O, strToRgb as Ot, extractLocalFontFace as P, normalizeColorTokenValue as Q, SheetManager as R, renderStyles as S, getColorSpaceSuffix as St, createStateParserContext as T, getRgbValuesFromRgbaString as Tt, createStyle as U, deprecationWarning as V, PropertyTypeResolver as W, getGlobalParser as X, getGlobalFuncs as Y, getGlobalPredefinedTokens as Z, markStylesGenerated as _, isDevEnv as _t, getGlobalCounterStyle as a, okhstPlugin as at, hasPipelineCacheEntry as b, getColorSpaceComponents as bt, getGlobalKeyframes as c, StyleParser as ct, getNamePrefix as d, DEFAULT_ZERO_NAME_PREFIX as dt, parseStyle as et, hasGlobalKeyframes as f, makeClassName as ft, isTestEnvironment as g, validateNamePrefix as gt, isConfigLocked as h, tastyClassRegex as ht, getGlobalConfigTokens as i, okhstFunc as it, extractLocalCounterStyle as j, getEffectiveDefinition as jt, setGlobalPredefinedStates as k, Lru as kt, getGlobalRecipes as l, Bucket as lt, hasStylesGenerated as m, makeKeyframeName as mt, getConfig as n, setGlobalPredefinedTokens as nt, getGlobalFontFace as o, okhslFunc as ot, hasGlobalRecipes as p, makeCounterStyleName as pt, customFunc as q, getEffectiveProperties as r, stringifyStyles as rt, getGlobalInjector as s, okhslPlugin as st, configure as t, resetGlobalPredefinedTokens as tt, getGlobalStyles as u, DEFAULT_NAME_PREFIX as ut, resetConfig as v, hashString as vt, camelToKebab as w, getNamedColorHex as wt, isSelector as x, getColorSpaceFunc as xt, generateTypographyTokens as y, colorInitialValueToComponents as yt, STYLE_HANDLER_MAP as z };
10710
10832
 
10711
- //# sourceMappingURL=config-DF2QZQEW.js.map
10833
+ //# sourceMappingURL=config-BDnvK42H.js.map