@tenphi/tasty 0.0.0-snapshot.1c5dff6 → 0.0.0-snapshot.1f1c00a

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 (331) hide show
  1. package/README.md +377 -238
  2. package/dist/babel-rZcEwPLM.d.ts +82 -0
  3. package/dist/chunks/async-storage-CG5HnUT5.js +20 -0
  4. package/dist/chunks/async-storage-CG5HnUT5.js.map +1 -0
  5. package/dist/chunks/build-config-CL4eRu2z.js +42 -0
  6. package/dist/chunks/build-config-CL4eRu2z.js.map +1 -0
  7. package/dist/chunks/collector-D2ARGT2L.js +208 -0
  8. package/dist/chunks/collector-D2ARGT2L.js.map +1 -0
  9. package/dist/chunks/config-engine-DEmmPPdp.js +272 -0
  10. package/dist/chunks/config-engine-DEmmPPdp.js.map +1 -0
  11. package/dist/chunks/css-definitions-DotDkIXt.js +876 -0
  12. package/dist/chunks/css-definitions-DotDkIXt.js.map +1 -0
  13. package/dist/chunks/css-resources-P7IBUUZs.js +142 -0
  14. package/dist/chunks/css-resources-P7IBUUZs.js.map +1 -0
  15. package/dist/chunks/debug-D8pg9RGI.js +502 -0
  16. package/dist/chunks/debug-D8pg9RGI.js.map +1 -0
  17. package/dist/chunks/dsl-DRhFWQzo.js +1378 -0
  18. package/dist/chunks/dsl-DRhFWQzo.js.map +1 -0
  19. package/dist/chunks/hydration-TRcz5vnk.js +41 -0
  20. package/dist/chunks/hydration-TRcz5vnk.js.map +1 -0
  21. package/dist/chunks/react-runtime-BpxlOTbO.js +562 -0
  22. package/dist/chunks/react-runtime-BpxlOTbO.js.map +1 -0
  23. package/dist/chunks/runtime-engine-CKFXUH-A.js +2416 -0
  24. package/dist/chunks/runtime-engine-CKFXUH-A.js.map +1 -0
  25. package/dist/chunks/runtime-state-BxaLhVdP.js +127 -0
  26. package/dist/chunks/runtime-state-BxaLhVdP.js.map +1 -0
  27. package/dist/{utils/merge-styles.js → chunks/shared-utils-y-HjvPN4.js} +61 -58
  28. package/dist/chunks/shared-utils-y-HjvPN4.js.map +1 -0
  29. package/dist/chunks/style-engine-BBbBuSkT.js +5260 -0
  30. package/dist/chunks/style-engine-BBbBuSkT.js.map +1 -0
  31. package/dist/{zero/extractor.js → chunks/zero-engine-gJrKBRiw.js} +126 -66
  32. package/dist/chunks/zero-engine-gJrKBRiw.js.map +1 -0
  33. package/dist/collector-w4mBj5gd.d.ts +164 -0
  34. package/dist/config-CZWCzBr6.d.ts +1349 -0
  35. package/dist/core/index.d.ts +5 -33
  36. package/dist/core/index.js +9 -26
  37. package/dist/index-G9JuwM9p.d.ts +1920 -0
  38. package/dist/index.d.ts +5 -48
  39. package/dist/index.js +11 -33
  40. package/dist/{utils/merge-styles.d.ts → merge-styles-VXwJ0Frr.d.ts} +3 -4
  41. package/dist/ssr/astro-client.d.ts +1 -0
  42. package/dist/ssr/astro-client.js +6 -0
  43. package/dist/ssr/astro-client.js.map +1 -0
  44. package/dist/ssr/astro-middleware-extract-static.d.ts +10 -0
  45. package/dist/ssr/astro-middleware-extract-static.js +9 -0
  46. package/dist/ssr/astro-middleware-extract-static.js.map +1 -0
  47. package/dist/ssr/astro-middleware-extract.d.ts +10 -0
  48. package/dist/ssr/astro-middleware-extract.js +9 -0
  49. package/dist/ssr/astro-middleware-extract.js.map +1 -0
  50. package/dist/ssr/astro-middleware-static.d.ts +17 -0
  51. package/dist/ssr/astro-middleware-static.js +7 -0
  52. package/dist/ssr/astro-middleware-static.js.map +1 -0
  53. package/dist/ssr/astro-middleware.d.ts +18 -0
  54. package/dist/ssr/astro-middleware.js +7 -0
  55. package/dist/ssr/astro-middleware.js.map +1 -0
  56. package/dist/ssr/astro.d.ts +127 -0
  57. package/dist/ssr/astro.js +221 -0
  58. package/dist/ssr/astro.js.map +1 -0
  59. package/dist/ssr/index.d.ts +36 -0
  60. package/dist/ssr/index.js +10 -0
  61. package/dist/ssr/index.js.map +1 -0
  62. package/dist/ssr/next-config.d.ts +64 -0
  63. package/dist/ssr/next-config.js +128 -0
  64. package/dist/ssr/next-config.js.map +1 -0
  65. package/dist/ssr/next.d.ts +46 -0
  66. package/dist/ssr/next.js +60 -0
  67. package/dist/ssr/next.js.map +1 -0
  68. package/dist/static/index.d.ts +90 -5
  69. package/dist/static/index.js +31 -4
  70. package/dist/static/index.js.map +1 -0
  71. package/dist/static/inject.d.ts +4 -0
  72. package/dist/static/inject.js +17 -0
  73. package/dist/static/inject.js.map +1 -0
  74. package/dist/types-JEY8PVYP.d.ts +1567 -0
  75. package/dist/zero/babel.d.ts +2 -113
  76. package/dist/zero/babel.js +230 -106
  77. package/dist/zero/babel.js.map +1 -1
  78. package/dist/zero/index.d.ts +80 -3
  79. package/dist/zero/index.js +2 -4
  80. package/dist/zero/next.d.ts +57 -33
  81. package/dist/zero/next.js +93 -59
  82. package/dist/zero/next.js.map +1 -1
  83. package/docs/README.md +39 -0
  84. package/docs/adoption.md +323 -0
  85. package/docs/ai-agents.md +250 -0
  86. package/docs/comparison.md +448 -0
  87. package/docs/configuration.md +684 -56
  88. package/docs/debug.md +170 -343
  89. package/docs/design-system.md +455 -0
  90. package/docs/dsl.md +1065 -0
  91. package/docs/getting-started.md +240 -0
  92. package/docs/injector.md +159 -53
  93. package/docs/methodology.md +648 -0
  94. package/docs/migration-v3.md +285 -0
  95. package/docs/pipeline.md +765 -0
  96. package/docs/plugins.md +353 -0
  97. package/docs/react-api.md +683 -0
  98. package/docs/runtime-benchmarks.md +388 -0
  99. package/docs/ssr.md +610 -0
  100. package/docs/styles.md +211 -63
  101. package/docs/tasty-static.md +273 -67
  102. package/package.json +182 -58
  103. package/tasty.config.ts +6 -0
  104. package/dist/_virtual/_rolldown/runtime.js +0 -8
  105. package/dist/chunks/cacheKey.js +0 -70
  106. package/dist/chunks/cacheKey.js.map +0 -1
  107. package/dist/chunks/definitions.d.ts +0 -37
  108. package/dist/chunks/definitions.js +0 -260
  109. package/dist/chunks/definitions.js.map +0 -1
  110. package/dist/chunks/renderChunk.js +0 -61
  111. package/dist/chunks/renderChunk.js.map +0 -1
  112. package/dist/config.d.ts +0 -288
  113. package/dist/config.js +0 -403
  114. package/dist/config.js.map +0 -1
  115. package/dist/debug.d.ts +0 -204
  116. package/dist/debug.js +0 -733
  117. package/dist/debug.js.map +0 -1
  118. package/dist/hooks/useGlobalStyles.d.ts +0 -27
  119. package/dist/hooks/useGlobalStyles.js +0 -56
  120. package/dist/hooks/useGlobalStyles.js.map +0 -1
  121. package/dist/hooks/useKeyframes.d.ts +0 -56
  122. package/dist/hooks/useKeyframes.js +0 -54
  123. package/dist/hooks/useKeyframes.js.map +0 -1
  124. package/dist/hooks/useProperty.d.ts +0 -79
  125. package/dist/hooks/useProperty.js +0 -91
  126. package/dist/hooks/useProperty.js.map +0 -1
  127. package/dist/hooks/useRawCSS.d.ts +0 -53
  128. package/dist/hooks/useRawCSS.js +0 -28
  129. package/dist/hooks/useRawCSS.js.map +0 -1
  130. package/dist/hooks/useStyles.d.ts +0 -40
  131. package/dist/hooks/useStyles.js +0 -169
  132. package/dist/hooks/useStyles.js.map +0 -1
  133. package/dist/injector/index.d.ts +0 -157
  134. package/dist/injector/index.js +0 -154
  135. package/dist/injector/index.js.map +0 -1
  136. package/dist/injector/injector.d.ts +0 -139
  137. package/dist/injector/injector.js +0 -417
  138. package/dist/injector/injector.js.map +0 -1
  139. package/dist/injector/sheet-manager.d.ts +0 -135
  140. package/dist/injector/sheet-manager.js +0 -728
  141. package/dist/injector/sheet-manager.js.map +0 -1
  142. package/dist/injector/types.d.ts +0 -144
  143. package/dist/keyframes/index.js +0 -206
  144. package/dist/keyframes/index.js.map +0 -1
  145. package/dist/parser/classify.js +0 -319
  146. package/dist/parser/classify.js.map +0 -1
  147. package/dist/parser/const.js +0 -33
  148. package/dist/parser/const.js.map +0 -1
  149. package/dist/parser/lru.js +0 -109
  150. package/dist/parser/lru.js.map +0 -1
  151. package/dist/parser/parser.d.ts +0 -25
  152. package/dist/parser/parser.js +0 -116
  153. package/dist/parser/parser.js.map +0 -1
  154. package/dist/parser/tokenizer.js +0 -69
  155. package/dist/parser/tokenizer.js.map +0 -1
  156. package/dist/parser/types.d.ts +0 -51
  157. package/dist/parser/types.js +0 -46
  158. package/dist/parser/types.js.map +0 -1
  159. package/dist/pipeline/conditions.d.ts +0 -134
  160. package/dist/pipeline/conditions.js +0 -406
  161. package/dist/pipeline/conditions.js.map +0 -1
  162. package/dist/pipeline/exclusive.js +0 -231
  163. package/dist/pipeline/exclusive.js.map +0 -1
  164. package/dist/pipeline/index.d.ts +0 -53
  165. package/dist/pipeline/index.js +0 -660
  166. package/dist/pipeline/index.js.map +0 -1
  167. package/dist/pipeline/materialize.js +0 -856
  168. package/dist/pipeline/materialize.js.map +0 -1
  169. package/dist/pipeline/parseStateKey.d.ts +0 -15
  170. package/dist/pipeline/parseStateKey.js +0 -451
  171. package/dist/pipeline/parseStateKey.js.map +0 -1
  172. package/dist/pipeline/simplify.js +0 -516
  173. package/dist/pipeline/simplify.js.map +0 -1
  174. package/dist/pipeline/warnings.js +0 -18
  175. package/dist/pipeline/warnings.js.map +0 -1
  176. package/dist/plugins/okhsl-plugin.d.ts +0 -35
  177. package/dist/plugins/okhsl-plugin.js +0 -371
  178. package/dist/plugins/okhsl-plugin.js.map +0 -1
  179. package/dist/plugins/types.d.ts +0 -69
  180. package/dist/properties/index.js +0 -221
  181. package/dist/properties/index.js.map +0 -1
  182. package/dist/properties/property-type-resolver.d.ts +0 -24
  183. package/dist/properties/property-type-resolver.js +0 -83
  184. package/dist/properties/property-type-resolver.js.map +0 -1
  185. package/dist/states/index.d.ts +0 -49
  186. package/dist/states/index.js +0 -416
  187. package/dist/states/index.js.map +0 -1
  188. package/dist/static/tastyStatic.d.ts +0 -46
  189. package/dist/static/tastyStatic.js +0 -31
  190. package/dist/static/tastyStatic.js.map +0 -1
  191. package/dist/static/types.d.ts +0 -49
  192. package/dist/static/types.js +0 -24
  193. package/dist/static/types.js.map +0 -1
  194. package/dist/styles/align.d.ts +0 -15
  195. package/dist/styles/align.js +0 -14
  196. package/dist/styles/align.js.map +0 -1
  197. package/dist/styles/border.d.ts +0 -25
  198. package/dist/styles/border.js +0 -114
  199. package/dist/styles/border.js.map +0 -1
  200. package/dist/styles/color.d.ts +0 -14
  201. package/dist/styles/color.js +0 -23
  202. package/dist/styles/color.js.map +0 -1
  203. package/dist/styles/createStyle.js +0 -77
  204. package/dist/styles/createStyle.js.map +0 -1
  205. package/dist/styles/dimension.js +0 -97
  206. package/dist/styles/dimension.js.map +0 -1
  207. package/dist/styles/display.d.ts +0 -37
  208. package/dist/styles/display.js +0 -67
  209. package/dist/styles/display.js.map +0 -1
  210. package/dist/styles/fade.d.ts +0 -15
  211. package/dist/styles/fade.js +0 -58
  212. package/dist/styles/fade.js.map +0 -1
  213. package/dist/styles/fill.d.ts +0 -42
  214. package/dist/styles/fill.js +0 -52
  215. package/dist/styles/fill.js.map +0 -1
  216. package/dist/styles/flow.d.ts +0 -16
  217. package/dist/styles/flow.js +0 -12
  218. package/dist/styles/flow.js.map +0 -1
  219. package/dist/styles/gap.d.ts +0 -31
  220. package/dist/styles/gap.js +0 -37
  221. package/dist/styles/gap.js.map +0 -1
  222. package/dist/styles/height.d.ts +0 -17
  223. package/dist/styles/height.js +0 -20
  224. package/dist/styles/height.js.map +0 -1
  225. package/dist/styles/index.d.ts +0 -2
  226. package/dist/styles/index.js +0 -9
  227. package/dist/styles/index.js.map +0 -1
  228. package/dist/styles/inset.d.ts +0 -52
  229. package/dist/styles/inset.js +0 -150
  230. package/dist/styles/inset.js.map +0 -1
  231. package/dist/styles/justify.d.ts +0 -15
  232. package/dist/styles/justify.js +0 -14
  233. package/dist/styles/justify.js.map +0 -1
  234. package/dist/styles/list.d.ts +0 -16
  235. package/dist/styles/list.js +0 -98
  236. package/dist/styles/list.js.map +0 -1
  237. package/dist/styles/margin.d.ts +0 -24
  238. package/dist/styles/margin.js +0 -104
  239. package/dist/styles/margin.js.map +0 -1
  240. package/dist/styles/outline.d.ts +0 -29
  241. package/dist/styles/outline.js +0 -65
  242. package/dist/styles/outline.js.map +0 -1
  243. package/dist/styles/padding.d.ts +0 -24
  244. package/dist/styles/padding.js +0 -104
  245. package/dist/styles/padding.js.map +0 -1
  246. package/dist/styles/predefined.d.ts +0 -73
  247. package/dist/styles/predefined.js +0 -241
  248. package/dist/styles/predefined.js.map +0 -1
  249. package/dist/styles/preset.d.ts +0 -47
  250. package/dist/styles/preset.js +0 -126
  251. package/dist/styles/preset.js.map +0 -1
  252. package/dist/styles/radius.d.ts +0 -14
  253. package/dist/styles/radius.js +0 -51
  254. package/dist/styles/radius.js.map +0 -1
  255. package/dist/styles/scrollbar.d.ts +0 -23
  256. package/dist/styles/scrollbar.js +0 -34
  257. package/dist/styles/scrollbar.js.map +0 -1
  258. package/dist/styles/shadow.d.ts +0 -14
  259. package/dist/styles/shadow.js +0 -24
  260. package/dist/styles/shadow.js.map +0 -1
  261. package/dist/styles/styledScrollbar.d.ts +0 -47
  262. package/dist/styles/styledScrollbar.js +0 -38
  263. package/dist/styles/styledScrollbar.js.map +0 -1
  264. package/dist/styles/transition.d.ts +0 -14
  265. package/dist/styles/transition.js +0 -158
  266. package/dist/styles/transition.js.map +0 -1
  267. package/dist/styles/types.d.ts +0 -498
  268. package/dist/styles/width.d.ts +0 -17
  269. package/dist/styles/width.js +0 -20
  270. package/dist/styles/width.js.map +0 -1
  271. package/dist/tasty.d.ts +0 -982
  272. package/dist/tasty.js +0 -206
  273. package/dist/tasty.js.map +0 -1
  274. package/dist/tokens/typography.d.ts +0 -19
  275. package/dist/tokens/typography.js +0 -237
  276. package/dist/tokens/typography.js.map +0 -1
  277. package/dist/types.d.ts +0 -184
  278. package/dist/utils/cache-wrapper.js +0 -26
  279. package/dist/utils/cache-wrapper.js.map +0 -1
  280. package/dist/utils/case-converter.js +0 -8
  281. package/dist/utils/case-converter.js.map +0 -1
  282. package/dist/utils/colors.d.ts +0 -5
  283. package/dist/utils/colors.js +0 -9
  284. package/dist/utils/colors.js.map +0 -1
  285. package/dist/utils/css-types.d.ts +0 -7
  286. package/dist/utils/dotize.d.ts +0 -26
  287. package/dist/utils/dotize.js +0 -122
  288. package/dist/utils/dotize.js.map +0 -1
  289. package/dist/utils/filter-base-props.d.ts +0 -15
  290. package/dist/utils/filter-base-props.js +0 -45
  291. package/dist/utils/filter-base-props.js.map +0 -1
  292. package/dist/utils/get-display-name.d.ts +0 -7
  293. package/dist/utils/get-display-name.js +0 -10
  294. package/dist/utils/get-display-name.js.map +0 -1
  295. package/dist/utils/hsl-to-rgb.js +0 -38
  296. package/dist/utils/hsl-to-rgb.js.map +0 -1
  297. package/dist/utils/is-dev-env.js +0 -19
  298. package/dist/utils/is-dev-env.js.map +0 -1
  299. package/dist/utils/is-valid-element-type.js +0 -15
  300. package/dist/utils/is-valid-element-type.js.map +0 -1
  301. package/dist/utils/merge-styles.js.map +0 -1
  302. package/dist/utils/mod-attrs.d.ts +0 -8
  303. package/dist/utils/mod-attrs.js +0 -21
  304. package/dist/utils/mod-attrs.js.map +0 -1
  305. package/dist/utils/okhsl-to-rgb.js +0 -296
  306. package/dist/utils/okhsl-to-rgb.js.map +0 -1
  307. package/dist/utils/process-tokens.d.ts +0 -31
  308. package/dist/utils/process-tokens.js +0 -171
  309. package/dist/utils/process-tokens.js.map +0 -1
  310. package/dist/utils/resolve-recipes.d.ts +0 -17
  311. package/dist/utils/resolve-recipes.js +0 -147
  312. package/dist/utils/resolve-recipes.js.map +0 -1
  313. package/dist/utils/selector-transform.js +0 -32
  314. package/dist/utils/selector-transform.js.map +0 -1
  315. package/dist/utils/string.js +0 -8
  316. package/dist/utils/string.js.map +0 -1
  317. package/dist/utils/styles.d.ts +0 -177
  318. package/dist/utils/styles.js +0 -730
  319. package/dist/utils/styles.js.map +0 -1
  320. package/dist/utils/typography.d.ts +0 -36
  321. package/dist/utils/typography.js +0 -53
  322. package/dist/utils/typography.js.map +0 -1
  323. package/dist/utils/warnings.d.ts +0 -16
  324. package/dist/utils/warnings.js +0 -16
  325. package/dist/utils/warnings.js.map +0 -1
  326. package/dist/zero/css-writer.d.ts +0 -45
  327. package/dist/zero/css-writer.js +0 -74
  328. package/dist/zero/css-writer.js.map +0 -1
  329. package/dist/zero/extractor.d.ts +0 -24
  330. package/dist/zero/extractor.js.map +0 -1
  331. package/docs/usage.md +0 -695
@@ -0,0 +1,272 @@
1
+ import { c as getGlobalParser, g as setGlobalPredefinedTokens, r as CUSTOM_UNITS, s as getGlobalParseFunctions, u as normalizeColorTokenValue } from "./dsl-DRhFWQzo.js";
2
+ import { n as isSelector, o as isDevEnv, t as mergeStyles } from "./shared-utils-y-HjvPN4.js";
3
+ import { W as registerFunctionPolyfill, q as splitFunctions } from "./css-definitions-DotDkIXt.js";
4
+ import { D as registerHandler, E as normalizeHandlerDefinition, H as setGlobalPredefinedStates, J as setGlobalPolyfillsState, W as isFunctionsPolyfillEnabled } from "./style-engine-BBbBuSkT.js";
5
+ //#region src/utils/typography.ts
6
+ const RESERVED_PRESET_NAMES = /* @__PURE__ */ new Set([
7
+ "strong",
8
+ "bold",
9
+ "italic",
10
+ "icon",
11
+ "tight"
12
+ ]);
13
+ function generateTypographyTokens(presets) {
14
+ const tokens = {};
15
+ for (const [name, preset] of Object.entries(presets)) {
16
+ if (RESERVED_PRESET_NAMES.has(name)) throw new Error(`Invalid typography preset name "${name}". This name is reserved as a preset modifier.`);
17
+ tokens[`$${name}-font-size`] = preset.fontSize;
18
+ tokens[`$${name}-line-height`] = preset.lineHeight;
19
+ tokens[`$${name}-letter-spacing`] = preset.letterSpacing ?? "normal";
20
+ tokens[`$${name}-font-weight`] = preset.fontWeight;
21
+ if (preset.boldFontWeight !== void 0) tokens[`$${name}-bold-font-weight`] = preset.boldFontWeight;
22
+ if (preset.iconSize !== void 0) tokens[`$${name}-icon-size`] = preset.iconSize;
23
+ if (preset.textTransform !== void 0) tokens[`$${name}-text-transform`] = preset.textTransform;
24
+ if (preset.fontFamily !== void 0) tokens[`$${name}-font-family`] = preset.fontFamily;
25
+ if (preset.fontStyle !== void 0) tokens[`$${name}-font-style`] = preset.fontStyle;
26
+ }
27
+ return tokens;
28
+ }
29
+ //#endregion
30
+ //#region src/config-normalize.ts
31
+ function applyStyleConfig(config, normalized, warnOnce) {
32
+ const tokenKeys = new Set(Object.keys(normalized.tokens));
33
+ for (const key of Object.keys(normalized.replaceTokens)) if (tokenKeys.has(key)) warnOnce(`token-conflict-${key}`, `[Tasty] Token "${key}" is defined in both \`tokens\` and \`replaceTokens\`. \`replaceTokens\` performs parse-time substitution, so the \`tokens\` CSS custom property will be injected but never used by Tasty styles. Remove it from one of the two.`);
34
+ if (config.colorSpace) warnOnce("colorSpace-deprecated", "[Tasty] configure({ colorSpace }) no longer has any effect and will be removed in the next major. Colors are emitted as authored, and opacity is applied with relative color syntax, which reads a color's channels in the browser. To address channels yourself, write `oklch(from var(--name-color) l c h)` against the token.");
35
+ if (Object.keys(normalized.states).length > 0) setGlobalPredefinedStates(normalized.states);
36
+ const parser = getGlobalParser();
37
+ if (config.parserCacheSize !== void 0) parser.updateOptions({ cacheSize: config.parserCacheSize });
38
+ if (Object.keys(normalized.units).length > 0) {
39
+ const currentUnits = parser.getUnits() ?? CUSTOM_UNITS;
40
+ parser.setUnits({
41
+ ...currentUnits,
42
+ ...normalized.units
43
+ });
44
+ }
45
+ if (config.polyfills) setGlobalPolyfillsState(config.polyfills);
46
+ const { parseFuncs, functionDefs } = splitFunctions(normalized.functions, (key, kind) => {
47
+ warnOnce(`functions-mismatch-${key}`, kind === "expected-definition" ? `[Tasty] functions["${key}"]: a "$$"-prefixed key denotes a CSS @function and expects a definition object, but received a function. Entry ignored.` : `[Tasty] functions["${key}"]: a bare key denotes a parse function and expects a function value, but received an object. Did you mean "$$${key}"? Entry ignored.`);
48
+ });
49
+ if (Object.keys(parseFuncs).length > 0) {
50
+ const currentFuncs = getGlobalParseFunctions();
51
+ parser.setFunctions({
52
+ ...currentFuncs,
53
+ ...parseFuncs
54
+ });
55
+ Object.assign(currentFuncs, parseFuncs);
56
+ }
57
+ if (isFunctionsPolyfillEnabled()) for (const [name, definition] of Object.entries(functionDefs)) registerFunctionPolyfill(name, definition);
58
+ for (const [name, definition] of Object.entries(normalized.handlers)) {
59
+ const handler = normalizeHandlerDefinition(name, definition);
60
+ registerHandler(handler, {
61
+ key: name,
62
+ source: normalized.handlerSources.get(name)
63
+ });
64
+ }
65
+ if (Object.keys(normalized.replaceTokens).length > 0) {
66
+ const processedTokens = {};
67
+ for (const [key, value] of Object.entries(normalized.replaceTokens)) if (key.startsWith("#")) {
68
+ const normalizedValue = normalizeColorTokenValue(value);
69
+ if (normalizedValue === null) continue;
70
+ processedTokens[key] = String(normalizedValue);
71
+ } else if (value !== false) processedTokens[key] = String(value);
72
+ setGlobalPredefinedTokens(processedTokens);
73
+ }
74
+ return functionDefs;
75
+ }
76
+ function mergeRecord(target, source) {
77
+ return source ? {
78
+ ...target,
79
+ ...source
80
+ } : target;
81
+ }
82
+ function mergeSourcedRecord(target, source, sources, pluginName) {
83
+ if (!source) return target;
84
+ const label = pluginName === void 0 ? "configure()" : `plugin "${pluginName}"`;
85
+ for (const key of Object.keys(source)) sources.set(key, label);
86
+ return {
87
+ ...target,
88
+ ...source
89
+ };
90
+ }
91
+ function normalizeConfig(config) {
92
+ let states = {};
93
+ let units = {};
94
+ let functions = {};
95
+ let handlers = {};
96
+ const handlerSources = /* @__PURE__ */ new Map();
97
+ let propHandlers = {};
98
+ const propHandlerSources = /* @__PURE__ */ new Map();
99
+ const baseStyleProps = [];
100
+ let properties = {};
101
+ let keyframes = {};
102
+ let fontFaces = {};
103
+ let counterStyles = {};
104
+ let replaceTokens = {};
105
+ let tokens = {};
106
+ let recipes = {};
107
+ let presets = {};
108
+ const globalStyles = {};
109
+ for (const plugin of config.plugins ?? []) {
110
+ states = mergeRecord(states, plugin.states);
111
+ units = mergeRecord(units, plugin.units);
112
+ functions = mergeRecord(functions, plugin.functions);
113
+ handlers = mergeSourcedRecord(handlers, plugin.handlers, handlerSources, plugin.name);
114
+ propHandlers = mergeSourcedRecord(propHandlers, plugin.propHandlers, propHandlerSources, plugin.name);
115
+ if (plugin.baseStyleProps) baseStyleProps.push(...plugin.baseStyleProps);
116
+ properties = mergeRecord(properties, plugin.properties);
117
+ keyframes = mergeRecord(keyframes, plugin.keyframes);
118
+ fontFaces = mergeRecord(fontFaces, plugin.fontFaces);
119
+ counterStyles = mergeRecord(counterStyles, plugin.counterStyles);
120
+ replaceTokens = mergeRecord(replaceTokens, plugin.replaceTokens);
121
+ tokens = mergeRecord(tokens, plugin.tokens);
122
+ recipes = mergeRecord(recipes, plugin.recipes);
123
+ presets = mergeRecord(presets, plugin.presets);
124
+ mergeGlobalStyles(globalStyles, plugin.globalStyles);
125
+ }
126
+ states = mergeRecord(states, config.states);
127
+ units = mergeRecord(units, config.units);
128
+ functions = mergeRecord(functions, config.functions);
129
+ handlers = mergeSourcedRecord(handlers, config.handlers, handlerSources);
130
+ propHandlers = mergeSourcedRecord(propHandlers, config.propHandlers, propHandlerSources);
131
+ if (config.baseStyleProps) baseStyleProps.push(...config.baseStyleProps);
132
+ properties = mergeRecord(properties, config.properties);
133
+ keyframes = mergeRecord(keyframes, config.keyframes);
134
+ fontFaces = mergeRecord(fontFaces, config.fontFaces);
135
+ counterStyles = mergeRecord(counterStyles, config.counterStyles);
136
+ replaceTokens = mergeRecord(replaceTokens, config.replaceTokens);
137
+ presets = mergeRecord(presets, config.presets);
138
+ if (Object.keys(presets).length > 0) tokens = {
139
+ ...generateTypographyTokens(presets),
140
+ ...tokens
141
+ };
142
+ tokens = mergeRecord(tokens, config.tokens);
143
+ recipes = mergeRecord(recipes, config.recipes);
144
+ mergeGlobalStyles(globalStyles, config.globalStyles);
145
+ return {
146
+ states,
147
+ units,
148
+ functions,
149
+ handlers,
150
+ handlerSources,
151
+ propHandlers,
152
+ propHandlerSources,
153
+ baseStyleProps,
154
+ properties,
155
+ keyframes,
156
+ fontFaces,
157
+ counterStyles,
158
+ replaceTokens,
159
+ tokens,
160
+ recipes,
161
+ globalStyles
162
+ };
163
+ }
164
+ function mergeGlobalStyles(target, source) {
165
+ if (!source) return;
166
+ for (const [selector, styles] of Object.entries(source)) target[selector] = target[selector] ? {
167
+ ...target[selector],
168
+ ...styles
169
+ } : styles;
170
+ }
171
+ //#endregion
172
+ //#region src/utils/resolve-recipes-core.ts
173
+ const devMode = isDevEnv();
174
+ function parseRecipeNames(value) {
175
+ const empty = {
176
+ base: null,
177
+ post: null
178
+ };
179
+ if (typeof value !== "string") return empty;
180
+ const trimmed = value.trim();
181
+ if (trimmed === "") return empty;
182
+ const slashIndex = trimmed.indexOf("/");
183
+ if (slashIndex === -1) {
184
+ if (trimmed === "none") return empty;
185
+ return {
186
+ base: splitNames(trimmed),
187
+ post: null
188
+ };
189
+ }
190
+ const basePart = trimmed.slice(0, slashIndex);
191
+ const postPart = trimmed.slice(slashIndex + 1);
192
+ return {
193
+ base: basePart.trim() === "none" ? null : splitNames(basePart),
194
+ post: splitNames(postPart)
195
+ };
196
+ }
197
+ function splitNames(s) {
198
+ const names = s.split(/\s+/).filter(Boolean);
199
+ return names.length > 0 ? names : null;
200
+ }
201
+ function collectRecipeStyles(names, recipes) {
202
+ let merged = {};
203
+ for (const name of names) {
204
+ const recipeStyles = recipes[name];
205
+ if (!recipeStyles) {
206
+ if (devMode) console.warn(`[Tasty] Recipe "${name}" not found. Make sure it is defined in configure({ recipes: { ... } }).`);
207
+ continue;
208
+ }
209
+ merged = {
210
+ ...merged,
211
+ ...recipeStyles
212
+ };
213
+ }
214
+ return merged;
215
+ }
216
+ function resolveRecipesForLevel(styles, recipes) {
217
+ if (!("recipe" in styles)) return null;
218
+ const { base, post } = parseRecipeNames(styles.recipe);
219
+ const { recipe: _recipe, ...allRest } = styles;
220
+ const flatStyles = {};
221
+ const selectorStyles = {};
222
+ for (const key of Object.keys(allRest)) if (isSelector(key)) selectorStyles[key] = allRest[key];
223
+ else flatStyles[key] = allRest[key];
224
+ if (!base && !post) return allRest;
225
+ let result;
226
+ if (base) {
227
+ const baseStyles = collectRecipeStyles(base, recipes);
228
+ result = mergeStyles(baseStyles, flatStyles);
229
+ } else result = { ...flatStyles };
230
+ if (post) {
231
+ const postStyles = collectRecipeStyles(post, recipes);
232
+ result = mergeStyles(result, postStyles);
233
+ }
234
+ for (const key of Object.keys(selectorStyles)) result[key] = selectorStyles[key];
235
+ return result;
236
+ }
237
+ function resolveRecipesWith(styles, recipes) {
238
+ if (!recipes) return styles;
239
+ let changed = false;
240
+ const topResolved = resolveRecipesForLevel(styles, recipes);
241
+ let result;
242
+ if (topResolved) {
243
+ changed = true;
244
+ result = topResolved;
245
+ } else result = styles;
246
+ const keys = Object.keys(result);
247
+ for (const key of keys) {
248
+ if (!isSelector(key)) continue;
249
+ const subStyles = result[key];
250
+ if (!subStyles || typeof subStyles !== "object" || Array.isArray(subStyles)) continue;
251
+ const subRecord = subStyles;
252
+ if (!("recipe" in subRecord)) continue;
253
+ const subResolved = resolveRecipesForLevel(subRecord, recipes);
254
+ if (subResolved) {
255
+ if (!changed) {
256
+ changed = true;
257
+ result = { ...styles };
258
+ }
259
+ Object.defineProperty(result, key, {
260
+ configurable: true,
261
+ enumerable: true,
262
+ value: subResolved,
263
+ writable: true
264
+ });
265
+ }
266
+ }
267
+ return changed ? result : styles;
268
+ }
269
+ //#endregion
270
+ export { generateTypographyTokens as i, applyStyleConfig as n, normalizeConfig as r, resolveRecipesWith as t };
271
+
272
+ //# sourceMappingURL=config-engine-DEmmPPdp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-engine-DEmmPPdp.js","names":[],"sources":["../../src/utils/typography.ts","../../src/config-normalize.ts","../../src/utils/resolve-recipes-core.ts"],"sourcesContent":["import type { ConfigTokens } from '../styles/types';\n\nconst RESERVED_PRESET_NAMES = new Set([\n 'strong',\n 'bold',\n 'italic',\n 'icon',\n 'tight',\n]);\n\n/**\n * A typography token value: plain value or a state map for responsive/theme-aware presets.\n *\n * @example\n * // Plain value\n * fontWeight: '400'\n * // State map\n * fontWeight: { '': '400', '@dark': '300' }\n */\nexport type TypographyTokenValue =\n | string\n | number\n | Record<string, string | number | undefined | null | '@inherit'>;\n\n/**\n * Typography preset configuration.\n * Each preset defines font properties that get expanded into CSS custom properties.\n * All fields accept plain values or state maps for responsive/theme-aware tokens.\n *\n * Use with `generateTypographyTokens()` to create typography tokens for your design system.\n */\nexport interface TypographyPreset {\n fontSize: TypographyTokenValue;\n lineHeight: TypographyTokenValue;\n letterSpacing?: TypographyTokenValue;\n fontWeight: TypographyTokenValue;\n boldFontWeight?: TypographyTokenValue;\n iconSize?: TypographyTokenValue;\n textTransform?: TypographyTokenValue;\n fontFamily?: TypographyTokenValue;\n fontStyle?: TypographyTokenValue;\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: ConfigTokens = {} as ConfigTokens;\n\n for (const [name, preset] of Object.entries(presets)) {\n if (RESERVED_PRESET_NAMES.has(name)) {\n throw new Error(\n `Invalid typography preset name \"${name}\". This name is reserved as a preset modifier.`,\n );\n }\n\n tokens[`$${name}-font-size`] = preset.fontSize;\n tokens[`$${name}-line-height`] = preset.lineHeight;\n tokens[`$${name}-letter-spacing`] = preset.letterSpacing ?? 'normal';\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;\n}\n","/**\n * Configuration processing shared by runtime and build-time paths.\n *\n * Plugins are folded first and direct configuration wins. Keeping this step\n * independent from the DOM injector lets zero-runtime tooling reuse the exact\n * same precedence and style-engine setup without loading browser infrastructure.\n */\n\nimport { registerFunctionPolyfill, splitFunctions } from './functions';\nimport {\n isFunctionsPolyfillEnabled,\n setGlobalPolyfillsState,\n} from './config-state';\nimport { setGlobalPredefinedStates } from './states';\nimport {\n normalizeHandlerDefinition,\n registerHandler,\n} from './styles/predefined';\nimport {\n CUSTOM_UNITS,\n getGlobalParseFunctions,\n getGlobalParser,\n normalizeColorTokenValue,\n setGlobalPredefinedTokens,\n} from './utils/styles';\nimport { generateTypographyTokens } from './utils/typography';\n\nimport type { TastyConfig } from './config';\nimport type { FunctionsConfig } from './functions';\nimport type {\n CounterStyleDescriptors,\n FontFaceInput,\n FunctionDefinition,\n KeyframesSteps,\n PropertyDefinition,\n} from './injector/types';\nimport type { UnitHandler } from './parser/types';\nimport type { PropHandlerDefinition } from './prop-handlers';\nimport type { ConfigTokens, RecipeStyles, Styles } from './styles/types';\nimport type { StyleHandlerDefinition } from './utils/styles';\nimport type { TypographyPreset } from './utils/typography';\n\nexport interface NormalizedConfig {\n states: Record<string, string>;\n units: Record<string, string | UnitHandler>;\n functions: FunctionsConfig;\n handlers: Record<string, StyleHandlerDefinition>;\n handlerSources: Map<string, string>;\n propHandlers: Record<string, PropHandlerDefinition>;\n propHandlerSources: Map<string, string>;\n baseStyleProps: string[];\n properties: Record<string, PropertyDefinition>;\n keyframes: Record<string, KeyframesSteps>;\n fontFaces: Record<string, FontFaceInput>;\n counterStyles: Record<string, CounterStyleDescriptors>;\n replaceTokens: Record<string, string | number | boolean>;\n tokens: ConfigTokens;\n recipes: Record<string, RecipeStyles>;\n globalStyles: Record<string, Styles>;\n}\n\ntype WarnOnce = (key: string, message: string) => void;\n\n/** Apply parser and style-engine configuration shared by every renderer. */\nexport function applyStyleConfig(\n config: Partial<TastyConfig>,\n normalized: NormalizedConfig,\n warnOnce: WarnOnce,\n): Record<string, FunctionDefinition> {\n const tokenKeys = new Set(Object.keys(normalized.tokens));\n for (const key of Object.keys(normalized.replaceTokens)) {\n if (tokenKeys.has(key)) {\n warnOnce(\n `token-conflict-${key}`,\n `[Tasty] Token \"${key}\" is defined in both \\`tokens\\` and \\`replaceTokens\\`. ` +\n `\\`replaceTokens\\` performs parse-time substitution, so the \\`tokens\\` ` +\n `CSS custom property will be injected but never used by Tasty styles. ` +\n `Remove it from one of the two.`,\n );\n }\n }\n\n if (config.colorSpace) {\n warnOnce(\n 'colorSpace-deprecated',\n '[Tasty] configure({ colorSpace }) no longer has any effect and will be ' +\n 'removed in the next major. Colors are emitted as authored, and opacity ' +\n \"is applied with relative color syntax, which reads a color's channels \" +\n 'in the browser. To address channels yourself, write ' +\n '`oklch(from var(--name-color) l c h)` against the token.',\n );\n }\n\n if (Object.keys(normalized.states).length > 0) {\n setGlobalPredefinedStates(normalized.states);\n }\n\n const parser = getGlobalParser();\n if (config.parserCacheSize !== undefined) {\n parser.updateOptions({ cacheSize: config.parserCacheSize });\n }\n if (Object.keys(normalized.units).length > 0) {\n const currentUnits = parser.getUnits() ?? CUSTOM_UNITS;\n parser.setUnits({ ...currentUnits, ...normalized.units });\n }\n\n if (config.polyfills) setGlobalPolyfillsState(config.polyfills);\n\n const { parseFuncs, functionDefs } = splitFunctions(\n normalized.functions,\n (key, kind) => {\n warnOnce(\n `functions-mismatch-${key}`,\n kind === 'expected-definition'\n ? `[Tasty] functions[\"${key}\"]: a \"$$\"-prefixed key denotes a CSS @function ` +\n `and expects a definition object, but received a function. Entry ignored.`\n : `[Tasty] functions[\"${key}\"]: a bare key denotes a parse function and ` +\n `expects a function value, but received an object. ` +\n `Did you mean \"$$${key}\"? Entry ignored.`,\n );\n },\n );\n\n if (Object.keys(parseFuncs).length > 0) {\n const currentFuncs = getGlobalParseFunctions();\n parser.setFunctions({ ...currentFuncs, ...parseFuncs });\n Object.assign(currentFuncs, parseFuncs);\n }\n\n if (isFunctionsPolyfillEnabled()) {\n for (const [name, definition] of Object.entries(functionDefs)) {\n registerFunctionPolyfill(name, definition);\n }\n }\n\n for (const [name, definition] of Object.entries(normalized.handlers)) {\n const handler = normalizeHandlerDefinition(name, definition);\n registerHandler(handler, {\n key: name,\n source: normalized.handlerSources.get(name),\n });\n }\n\n if (Object.keys(normalized.replaceTokens).length > 0) {\n const processedTokens: Record<string, string> = {};\n for (const [key, value] of Object.entries(normalized.replaceTokens)) {\n if (key.startsWith('#')) {\n const normalizedValue = normalizeColorTokenValue(value);\n if (normalizedValue === null) continue;\n processedTokens[key] = String(normalizedValue);\n } else if (value !== false) {\n processedTokens[key] = String(value);\n }\n }\n setGlobalPredefinedTokens(processedTokens);\n }\n\n return functionDefs;\n}\n\n/** Merge an optional configuration record into an accumulated record. */\nfunction mergeRecord<T extends object>(target: T, source?: Partial<T>): T {\n return source ? { ...target, ...source } : target;\n}\n\n/** Merge a named extension record and retain where each winning entry came from. */\nfunction mergeSourcedRecord<T>(\n target: Record<string, T>,\n source: Record<string, T> | undefined,\n sources: Map<string, string>,\n pluginName?: string,\n): Record<string, T> {\n if (!source) return target;\n\n const label =\n pluginName === undefined ? 'configure()' : `plugin \"${pluginName}\"`;\n for (const key of Object.keys(source)) sources.set(key, label);\n\n return { ...target, ...source };\n}\n\nexport function normalizeConfig(\n config: Partial<TastyConfig>,\n): NormalizedConfig {\n let states: Record<string, string> = {};\n let units: Record<string, string | UnitHandler> = {};\n let functions: FunctionsConfig = {};\n let handlers: Record<string, StyleHandlerDefinition> = {};\n const handlerSources = new Map<string, string>();\n let propHandlers: Record<string, PropHandlerDefinition> = {};\n const propHandlerSources = new Map<string, string>();\n const baseStyleProps: string[] = [];\n let properties: Record<string, PropertyDefinition> = {};\n let keyframes: Record<string, KeyframesSteps> = {};\n let fontFaces: Record<string, FontFaceInput> = {};\n let counterStyles: Record<string, CounterStyleDescriptors> = {};\n let replaceTokens: Record<string, string | number | boolean> = {};\n let tokens: ConfigTokens = {} as ConfigTokens;\n let recipes: Record<string, RecipeStyles> = {};\n let presets: Record<string, TypographyPreset> = {};\n const globalStyles: Record<string, Styles> = {};\n\n for (const plugin of config.plugins ?? []) {\n states = mergeRecord(states, plugin.states);\n units = mergeRecord(units, plugin.units);\n functions = mergeRecord(functions, plugin.functions);\n handlers = mergeSourcedRecord(\n handlers,\n plugin.handlers,\n handlerSources,\n plugin.name,\n );\n propHandlers = mergeSourcedRecord(\n propHandlers,\n plugin.propHandlers,\n propHandlerSources,\n plugin.name,\n );\n if (plugin.baseStyleProps) baseStyleProps.push(...plugin.baseStyleProps);\n properties = mergeRecord(properties, plugin.properties);\n keyframes = mergeRecord(keyframes, plugin.keyframes);\n fontFaces = mergeRecord(fontFaces, plugin.fontFaces);\n counterStyles = mergeRecord(counterStyles, plugin.counterStyles);\n replaceTokens = mergeRecord(replaceTokens, plugin.replaceTokens);\n tokens = mergeRecord(tokens, plugin.tokens);\n recipes = mergeRecord(recipes, plugin.recipes);\n presets = mergeRecord(presets, plugin.presets);\n mergeGlobalStyles(globalStyles, plugin.globalStyles);\n }\n\n states = mergeRecord(states, config.states);\n units = mergeRecord(units, config.units);\n functions = mergeRecord(functions, config.functions);\n handlers = mergeSourcedRecord(handlers, config.handlers, handlerSources);\n propHandlers = mergeSourcedRecord(\n propHandlers,\n config.propHandlers,\n propHandlerSources,\n );\n if (config.baseStyleProps) baseStyleProps.push(...config.baseStyleProps);\n properties = mergeRecord(properties, config.properties);\n keyframes = mergeRecord(keyframes, config.keyframes);\n fontFaces = mergeRecord(fontFaces, config.fontFaces);\n counterStyles = mergeRecord(counterStyles, config.counterStyles);\n replaceTokens = mergeRecord(replaceTokens, config.replaceTokens);\n presets = mergeRecord(presets, config.presets);\n\n if (Object.keys(presets).length > 0) {\n tokens = { ...generateTypographyTokens(presets), ...tokens };\n }\n\n tokens = mergeRecord(tokens, config.tokens);\n recipes = mergeRecord(recipes, config.recipes);\n mergeGlobalStyles(globalStyles, config.globalStyles);\n\n return {\n states,\n units,\n functions,\n handlers,\n handlerSources,\n propHandlers,\n propHandlerSources,\n baseStyleProps,\n properties,\n keyframes,\n fontFaces,\n counterStyles,\n replaceTokens,\n tokens,\n recipes,\n globalStyles,\n };\n}\n\nfunction mergeGlobalStyles(\n target: Record<string, Styles>,\n source?: Record<string, Styles>,\n): void {\n if (!source) return;\n\n for (const [selector, styles] of Object.entries(source)) {\n target[selector] = target[selector]\n ? { ...target[selector], ...styles }\n : styles;\n }\n}\n","/**\n * Recipe resolution utility.\n *\n * Resolves `recipe` style properties by looking up predefined recipe styles\n * from global configuration and merging them with the component's own styles.\n *\n * Resolution order per level (top-level and each sub-element independently):\n * base_recipe_1 base_recipe_2 → component styles → post_recipe_1 post_recipe_2\n *\n * The `/` separator splits base recipes (before component styles)\n * from post recipes (after component styles). All merges use mergeStyles\n * semantics: primitives and state maps with '' key fully replace;\n * state maps without '' key extend the existing value.\n *\n * Returns the same object reference if no recipes are present (zero overhead).\n */\n\nimport type { RecipeStyles, Styles } from '../styles/types';\n\nimport { isDevEnv } from './is-dev-env';\nimport { isSelector } from './is-selector';\nimport { mergeStyles } from './merge-styles';\n\nconst devMode = isDevEnv();\n\ninterface ParsedRecipeGroups {\n base: string[] | null;\n post: string[] | null;\n}\n\n/**\n * Parse a recipe string into base and post recipe name groups.\n *\n * Syntax: `'base1 base2 / post1 post2'`\n * - Names are space-separated within each group\n * - `/` separates base (before component) from post (after component) groups\n * - `/` is optional; if absent, all names are base\n * - `none` as the sole base value means \"no base recipes\"\n *\n * Returns `{ base: null, post: null }` if the string is empty or invalid.\n */\nfunction parseRecipeNames(value: unknown): ParsedRecipeGroups {\n const empty: ParsedRecipeGroups = { base: null, post: null };\n\n if (typeof value !== 'string') return empty;\n const trimmed = value.trim();\n if (trimmed === '') return empty;\n\n const slashIndex = trimmed.indexOf('/');\n\n if (slashIndex === -1) {\n if (trimmed === 'none') return empty;\n const names = splitNames(trimmed);\n return { base: names, post: null };\n }\n\n const basePart = trimmed.slice(0, slashIndex);\n const postPart = trimmed.slice(slashIndex + 1);\n\n return {\n base: basePart.trim() === 'none' ? null : splitNames(basePart),\n post: splitNames(postPart),\n };\n}\n\nfunction splitNames(s: string): string[] | null {\n const names = s.split(/\\s+/).filter(Boolean);\n return names.length > 0 ? names : null;\n}\n\n/**\n * Collect merged styles for a list of recipe names.\n * Each recipe is flat-spread on top of the previous.\n */\nfunction collectRecipeStyles(\n names: string[],\n recipes: Record<string, RecipeStyles>,\n): Record<string, unknown> {\n let merged: Record<string, unknown> = {};\n\n for (const name of names) {\n const recipeStyles = recipes[name];\n\n if (!recipeStyles) {\n if (devMode) {\n console.warn(\n `[Tasty] Recipe \"${name}\" not found. ` +\n `Make sure it is defined in configure({ recipes: { ... } }).`,\n );\n }\n continue;\n }\n\n merged = { ...merged, ...(recipeStyles as Record<string, unknown>) };\n }\n\n return merged;\n}\n\n/**\n * Resolve recipe references in a flat styles object (no sub-elements).\n * Returns null if no `recipe` key is present.\n *\n * Resolution: base recipes → component styles → post recipes (all via mergeStyles)\n */\nfunction resolveRecipesForLevel(\n styles: Record<string, unknown>,\n recipes: Record<string, RecipeStyles>,\n): Record<string, unknown> | null {\n if (!('recipe' in styles)) return null;\n\n const { base, post } = parseRecipeNames(styles.recipe);\n\n // Separate selector keys (sub-elements) from flat style properties.\n // mergeStyles handles selectors with its own semantics (e.g. false = delete),\n // but at this level we only want recipe merging on flat properties.\n\n const { recipe: _recipe, ...allRest } = styles;\n const flatStyles: Record<string, unknown> = {};\n const selectorStyles: Record<string, unknown> = {};\n\n for (const key of Object.keys(allRest)) {\n if (isSelector(key)) {\n selectorStyles[key] = allRest[key];\n } else {\n flatStyles[key] = allRest[key];\n }\n }\n\n if (!base && !post) {\n return allRest;\n }\n\n // 1. Merge base recipes, then component styles on top (via mergeStyles)\n let result: Record<string, unknown>;\n\n if (base) {\n const baseStyles = collectRecipeStyles(base, recipes);\n result = mergeStyles(baseStyles as Styles, flatStyles as Styles) as Record<\n string,\n unknown\n >;\n } else {\n result = { ...flatStyles };\n }\n\n // 2. Apply post recipes via mergeStyles (state map extend semantics)\n if (post) {\n const postStyles = collectRecipeStyles(post, recipes);\n result = mergeStyles(result as Styles, postStyles as Styles) as Record<\n string,\n unknown\n >;\n }\n\n // Re-attach selector keys unchanged\n for (const key of Object.keys(selectorStyles)) {\n result[key] = selectorStyles[key];\n }\n\n return result;\n}\n\n/**\n * Resolve all `recipe` style properties in a styles object.\n *\n * Handles both top-level and sub-element recipe references.\n * Returns the same object reference if no recipes are present anywhere\n * (zero overhead for the common case).\n *\n * @param styles - The styles object potentially containing `recipe` keys\n * @returns Resolved styles with recipe values merged in, or the original object if unchanged\n */\nexport function resolveRecipesWith(\n styles: Styles,\n recipes: Record<string, RecipeStyles> | null,\n): Styles {\n // Fast path: no recipes configured\n if (!recipes) return styles;\n\n let changed = false;\n\n // Resolve top-level recipe\n const topResolved = resolveRecipesForLevel(\n styles as Record<string, unknown>,\n recipes,\n );\n\n let result: Record<string, unknown>;\n\n if (topResolved) {\n changed = true;\n result = topResolved;\n } else {\n // Keep reference; a shallow copy is deferred until a sub-element actually changes\n result = styles as Record<string, unknown>;\n }\n\n // Resolve sub-element recipes\n const keys = Object.keys(result);\n\n for (const key of keys) {\n if (!isSelector(key)) continue;\n\n const subStyles = result[key];\n\n if (\n !subStyles ||\n typeof subStyles !== 'object' ||\n Array.isArray(subStyles)\n ) {\n continue;\n }\n\n const subRecord = subStyles as Record<string, unknown>;\n\n if (!('recipe' in subRecord)) continue;\n\n const subResolved = resolveRecipesForLevel(subRecord, recipes);\n\n if (subResolved) {\n if (!changed) {\n // First change in sub-elements -- need to shallow-copy the top level\n changed = true;\n result = { ...(styles as Record<string, unknown>) };\n }\n // Define an own data property so even an untrusted key cannot invoke an\n // inherited setter such as Object.prototype.__proto__.\n Object.defineProperty(result, key, {\n configurable: true,\n enumerable: true,\n value: subResolved,\n writable: true,\n });\n }\n }\n\n return changed ? (result as Styles) : styles;\n}\n"],"mappings":";;;;;AAEA,MAAM,wCAAwB,IAAI,IAAI;CACpC;CACA;CACA;CACA;CACA;AACF,CAAC;AA0DD,SAAgB,yBACd,SACc;CACd,MAAM,SAAuB,CAAC;CAE9B,KAAK,MAAM,CAAC,MAAM,WAAW,OAAO,QAAQ,OAAO,GAAG;EACpD,IAAI,sBAAsB,IAAI,IAAI,GAChC,MAAM,IAAI,MACR,mCAAmC,KAAK,+CAC1C;EAGF,OAAO,IAAI,KAAK,eAAe,OAAO;EACtC,OAAO,IAAI,KAAK,iBAAiB,OAAO;EACxC,OAAO,IAAI,KAAK,oBAAoB,OAAO,iBAAiB;EAC5D,OAAO,IAAI,KAAK,iBAAiB,OAAO;EAExC,IAAI,OAAO,mBAAmB,KAAA,GAC5B,OAAO,IAAI,KAAK,sBAAsB,OAAO;EAG/C,IAAI,OAAO,aAAa,KAAA,GACtB,OAAO,IAAI,KAAK,eAAe,OAAO;EAGxC,IAAI,OAAO,kBAAkB,KAAA,GAC3B,OAAO,IAAI,KAAK,oBAAoB,OAAO;EAG7C,IAAI,OAAO,eAAe,KAAA,GACxB,OAAO,IAAI,KAAK,iBAAiB,OAAO;EAG1C,IAAI,OAAO,cAAc,KAAA,GACvB,OAAO,IAAI,KAAK,gBAAgB,OAAO;CAE3C;CAEA,OAAO;AACT;;;ACzCA,SAAgB,iBACd,QACA,YACA,UACoC;CACpC,MAAM,YAAY,IAAI,IAAI,OAAO,KAAK,WAAW,MAAM,CAAC;CACxD,KAA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