@tenphi/tasty 0.0.0-snapshot.e4aff73 → 0.0.0-snapshot.e4e4347

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 (360) hide show
  1. package/README.md +441 -362
  2. package/dist/babel-types-BKDTT4--.d.ts +18 -0
  3. package/dist/chunks/async-storage-f9j9JRtq.js +37 -0
  4. package/dist/chunks/async-storage-f9j9JRtq.js.map +1 -0
  5. package/dist/chunks/build-config-5d8WlQbq.js +60 -0
  6. package/dist/chunks/build-config-5d8WlQbq.js.map +1 -0
  7. package/dist/chunks/collector-CjCak4iE.js +210 -0
  8. package/dist/chunks/collector-CjCak4iE.js.map +1 -0
  9. package/dist/chunks/config-engine-uOFYZidB.js +272 -0
  10. package/dist/chunks/config-engine-uOFYZidB.js.map +1 -0
  11. package/dist/chunks/config-file-DlZXJMj8.js +25 -0
  12. package/dist/chunks/config-file-DlZXJMj8.js.map +1 -0
  13. package/dist/chunks/css-definitions-ubrHP97m.js +910 -0
  14. package/dist/chunks/css-definitions-ubrHP97m.js.map +1 -0
  15. package/dist/chunks/css-resources-P7IBUUZs.js +142 -0
  16. package/dist/chunks/css-resources-P7IBUUZs.js.map +1 -0
  17. package/dist/{debug.js → chunks/debug-CJ31U_WE.js} +197 -149
  18. package/dist/chunks/debug-CJ31U_WE.js.map +1 -0
  19. package/dist/chunks/dsl-DYSJc1-T.js +1383 -0
  20. package/dist/chunks/dsl-DYSJc1-T.js.map +1 -0
  21. package/dist/chunks/hydration-TRcz5vnk.js +41 -0
  22. package/dist/chunks/hydration-TRcz5vnk.js.map +1 -0
  23. package/dist/chunks/react-runtime-CyyCI02N.js +689 -0
  24. package/dist/chunks/react-runtime-CyyCI02N.js.map +1 -0
  25. package/dist/chunks/runtime-engine-BQmOu5-W.js +2432 -0
  26. package/dist/chunks/runtime-engine-BQmOu5-W.js.map +1 -0
  27. package/dist/chunks/runtime-state-DEsyUMU-.js +152 -0
  28. package/dist/chunks/runtime-state-DEsyUMU-.js.map +1 -0
  29. package/dist/{utils/merge-styles.js → chunks/shared-utils-y-HjvPN4.js} +61 -58
  30. package/dist/chunks/shared-utils-y-HjvPN4.js.map +1 -0
  31. package/dist/chunks/style-engine-BX2LshDZ.js +5466 -0
  32. package/dist/chunks/style-engine-BX2LshDZ.js.map +1 -0
  33. package/dist/chunks/zero-engine-Dw0P4yGM.js +310 -0
  34. package/dist/chunks/zero-engine-Dw0P4yGM.js.map +1 -0
  35. package/dist/collector-CTU-nl0g.d.ts +164 -0
  36. package/dist/config-CcxqSZI2.d.ts +1368 -0
  37. package/dist/core/index.d.ts +5 -34
  38. package/dist/core/index.js +9 -27
  39. package/dist/hydrate-CRyjjAyl.d.ts +22 -0
  40. package/dist/index-xtey-KDu.d.ts +1950 -0
  41. package/dist/index.d.ts +5 -49
  42. package/dist/index.js +11 -34
  43. package/dist/{utils/merge-styles.d.ts → merge-styles-DSkVc6CD.d.ts} +3 -4
  44. package/dist/ssr/astro-client.d.ts +1 -0
  45. package/dist/ssr/astro-client.js +6 -0
  46. package/dist/ssr/astro-client.js.map +1 -0
  47. package/dist/ssr/astro-middleware-extract-static.d.ts +10 -0
  48. package/dist/ssr/astro-middleware-extract-static.js +9 -0
  49. package/dist/ssr/astro-middleware-extract-static.js.map +1 -0
  50. package/dist/ssr/astro-middleware-extract.d.ts +10 -0
  51. package/dist/ssr/astro-middleware-extract.js +9 -0
  52. package/dist/ssr/astro-middleware-extract.js.map +1 -0
  53. package/dist/ssr/astro-middleware-static.d.ts +17 -0
  54. package/dist/ssr/astro-middleware-static.js +7 -0
  55. package/dist/ssr/astro-middleware-static.js.map +1 -0
  56. package/dist/ssr/astro-middleware.d.ts +18 -0
  57. package/dist/ssr/astro-middleware.js +7 -0
  58. package/dist/ssr/astro-middleware.js.map +1 -0
  59. package/dist/ssr/astro.d.ts +110 -12
  60. package/dist/ssr/astro.js +206 -50
  61. package/dist/ssr/astro.js.map +1 -1
  62. package/dist/ssr/client.d.ts +2 -0
  63. package/dist/ssr/client.js +2 -0
  64. package/dist/ssr/index.d.ts +17 -5
  65. package/dist/ssr/index.js +7 -9
  66. package/dist/ssr/index.js.map +1 -1
  67. package/dist/ssr/next-config.d.ts +64 -0
  68. package/dist/ssr/next-config.js +123 -0
  69. package/dist/ssr/next-config.js.map +1 -0
  70. package/dist/ssr/next.d.ts +13 -12
  71. package/dist/ssr/next.js +40 -51
  72. package/dist/ssr/next.js.map +1 -1
  73. package/dist/static/index.d.ts +90 -5
  74. package/dist/static/index.js +31 -4
  75. package/dist/static/index.js.map +1 -0
  76. package/dist/static/inject.d.ts +4 -0
  77. package/dist/static/inject.js +17 -0
  78. package/dist/static/inject.js.map +1 -0
  79. package/dist/types-DJEM_BOJ.d.ts +1567 -0
  80. package/dist/zero/babel.d.ts +20 -108
  81. package/dist/zero/babel.js +211 -142
  82. package/dist/zero/babel.js.map +1 -1
  83. package/dist/zero/index.d.ts +135 -3
  84. package/dist/zero/index.js +23 -3
  85. package/dist/zero/index.js.map +1 -0
  86. package/dist/zero/next.d.ts +16 -5
  87. package/dist/zero/next.js +8 -42
  88. package/dist/zero/next.js.map +1 -1
  89. package/docs/README.md +23 -12
  90. package/docs/adoption.md +72 -37
  91. package/docs/ai-agents.md +255 -0
  92. package/docs/comparison.md +83 -54
  93. package/docs/configuration.md +764 -74
  94. package/docs/debug.md +39 -24
  95. package/docs/design-system.md +187 -37
  96. package/docs/dsl.md +711 -164
  97. package/docs/getting-started.md +132 -52
  98. package/docs/injector.md +197 -90
  99. package/docs/methodology.md +154 -48
  100. package/docs/migration-v3.md +285 -0
  101. package/docs/pipeline.md +768 -0
  102. package/docs/plugins.md +333 -0
  103. package/docs/react-api.md +742 -0
  104. package/docs/runtime-benchmarks.md +388 -0
  105. package/docs/ssr.md +403 -149
  106. package/docs/styles.md +200 -45
  107. package/docs/tasty-static.md +354 -99
  108. package/package.json +153 -35
  109. package/tasty.config.ts +6 -0
  110. package/dist/_virtual/_rolldown/runtime.js +0 -8
  111. package/dist/chunks/cacheKey.js +0 -78
  112. package/dist/chunks/cacheKey.js.map +0 -1
  113. package/dist/chunks/definitions.d.ts +0 -37
  114. package/dist/chunks/definitions.js +0 -259
  115. package/dist/chunks/definitions.js.map +0 -1
  116. package/dist/chunks/renderChunk.js +0 -60
  117. package/dist/chunks/renderChunk.js.map +0 -1
  118. package/dist/config.d.ts +0 -323
  119. package/dist/config.js +0 -465
  120. package/dist/config.js.map +0 -1
  121. package/dist/debug.d.ts +0 -89
  122. package/dist/debug.js.map +0 -1
  123. package/dist/hooks/useGlobalStyles.d.ts +0 -30
  124. package/dist/hooks/useGlobalStyles.js +0 -83
  125. package/dist/hooks/useGlobalStyles.js.map +0 -1
  126. package/dist/hooks/useKeyframes.d.ts +0 -56
  127. package/dist/hooks/useKeyframes.js +0 -69
  128. package/dist/hooks/useKeyframes.js.map +0 -1
  129. package/dist/hooks/useProperty.d.ts +0 -79
  130. package/dist/hooks/useProperty.js +0 -114
  131. package/dist/hooks/useProperty.js.map +0 -1
  132. package/dist/hooks/useRawCSS.d.ts +0 -53
  133. package/dist/hooks/useRawCSS.js +0 -40
  134. package/dist/hooks/useRawCSS.js.map +0 -1
  135. package/dist/hooks/useStyles.d.ts +0 -45
  136. package/dist/hooks/useStyles.js +0 -249
  137. package/dist/hooks/useStyles.js.map +0 -1
  138. package/dist/injector/index.d.ts +0 -165
  139. package/dist/injector/index.js +0 -162
  140. package/dist/injector/index.js.map +0 -1
  141. package/dist/injector/injector.d.ts +0 -148
  142. package/dist/injector/injector.js +0 -430
  143. package/dist/injector/injector.js.map +0 -1
  144. package/dist/injector/sheet-manager.d.ts +0 -136
  145. package/dist/injector/sheet-manager.js +0 -729
  146. package/dist/injector/sheet-manager.js.map +0 -1
  147. package/dist/injector/types.d.ts +0 -144
  148. package/dist/keyframes/index.js +0 -206
  149. package/dist/keyframes/index.js.map +0 -1
  150. package/dist/parser/classify.js +0 -320
  151. package/dist/parser/classify.js.map +0 -1
  152. package/dist/parser/const.js +0 -33
  153. package/dist/parser/const.js.map +0 -1
  154. package/dist/parser/lru.js +0 -109
  155. package/dist/parser/lru.js.map +0 -1
  156. package/dist/parser/parser.d.ts +0 -25
  157. package/dist/parser/parser.js +0 -116
  158. package/dist/parser/parser.js.map +0 -1
  159. package/dist/parser/tokenizer.js +0 -69
  160. package/dist/parser/tokenizer.js.map +0 -1
  161. package/dist/parser/types.d.ts +0 -51
  162. package/dist/parser/types.js +0 -46
  163. package/dist/parser/types.js.map +0 -1
  164. package/dist/pipeline/conditions.d.ts +0 -134
  165. package/dist/pipeline/conditions.js +0 -406
  166. package/dist/pipeline/conditions.js.map +0 -1
  167. package/dist/pipeline/exclusive.js +0 -231
  168. package/dist/pipeline/exclusive.js.map +0 -1
  169. package/dist/pipeline/index.d.ts +0 -53
  170. package/dist/pipeline/index.js +0 -681
  171. package/dist/pipeline/index.js.map +0 -1
  172. package/dist/pipeline/materialize.js +0 -1105
  173. package/dist/pipeline/materialize.js.map +0 -1
  174. package/dist/pipeline/parseStateKey.d.ts +0 -15
  175. package/dist/pipeline/parseStateKey.js +0 -447
  176. package/dist/pipeline/parseStateKey.js.map +0 -1
  177. package/dist/pipeline/simplify.js +0 -516
  178. package/dist/pipeline/simplify.js.map +0 -1
  179. package/dist/pipeline/warnings.js +0 -18
  180. package/dist/pipeline/warnings.js.map +0 -1
  181. package/dist/plugins/okhsl-plugin.d.ts +0 -35
  182. package/dist/plugins/okhsl-plugin.js +0 -98
  183. package/dist/plugins/okhsl-plugin.js.map +0 -1
  184. package/dist/plugins/types.d.ts +0 -76
  185. package/dist/properties/index.js +0 -223
  186. package/dist/properties/index.js.map +0 -1
  187. package/dist/properties/property-type-resolver.d.ts +0 -24
  188. package/dist/properties/property-type-resolver.js +0 -91
  189. package/dist/properties/property-type-resolver.js.map +0 -1
  190. package/dist/ssr/async-storage.d.ts +0 -17
  191. package/dist/ssr/async-storage.js +0 -35
  192. package/dist/ssr/async-storage.js.map +0 -1
  193. package/dist/ssr/collect-auto-properties.js +0 -40
  194. package/dist/ssr/collect-auto-properties.js.map +0 -1
  195. package/dist/ssr/collector.d.ts +0 -85
  196. package/dist/ssr/collector.js +0 -183
  197. package/dist/ssr/collector.js.map +0 -1
  198. package/dist/ssr/context.d.ts +0 -8
  199. package/dist/ssr/context.js +0 -14
  200. package/dist/ssr/context.js.map +0 -1
  201. package/dist/ssr/format-global-rules.js +0 -22
  202. package/dist/ssr/format-global-rules.js.map +0 -1
  203. package/dist/ssr/format-keyframes.js +0 -70
  204. package/dist/ssr/format-keyframes.js.map +0 -1
  205. package/dist/ssr/format-property.js +0 -50
  206. package/dist/ssr/format-property.js.map +0 -1
  207. package/dist/ssr/format-rules.js +0 -70
  208. package/dist/ssr/format-rules.js.map +0 -1
  209. package/dist/ssr/hydrate.d.ts +0 -22
  210. package/dist/ssr/hydrate.js +0 -50
  211. package/dist/ssr/hydrate.js.map +0 -1
  212. package/dist/ssr/ssr-collector-ref.js +0 -12
  213. package/dist/ssr/ssr-collector-ref.js.map +0 -1
  214. package/dist/states/index.d.ts +0 -49
  215. package/dist/states/index.js +0 -169
  216. package/dist/states/index.js.map +0 -1
  217. package/dist/static/tastyStatic.d.ts +0 -46
  218. package/dist/static/tastyStatic.js +0 -31
  219. package/dist/static/tastyStatic.js.map +0 -1
  220. package/dist/static/types.d.ts +0 -49
  221. package/dist/static/types.js +0 -24
  222. package/dist/static/types.js.map +0 -1
  223. package/dist/styles/align.d.ts +0 -15
  224. package/dist/styles/align.js +0 -14
  225. package/dist/styles/align.js.map +0 -1
  226. package/dist/styles/border.d.ts +0 -25
  227. package/dist/styles/border.js +0 -114
  228. package/dist/styles/border.js.map +0 -1
  229. package/dist/styles/color.d.ts +0 -14
  230. package/dist/styles/color.js +0 -27
  231. package/dist/styles/color.js.map +0 -1
  232. package/dist/styles/createStyle.js +0 -80
  233. package/dist/styles/createStyle.js.map +0 -1
  234. package/dist/styles/dimension.js +0 -97
  235. package/dist/styles/dimension.js.map +0 -1
  236. package/dist/styles/display.d.ts +0 -37
  237. package/dist/styles/display.js +0 -67
  238. package/dist/styles/display.js.map +0 -1
  239. package/dist/styles/fade.d.ts +0 -15
  240. package/dist/styles/fade.js +0 -58
  241. package/dist/styles/fade.js.map +0 -1
  242. package/dist/styles/fill.d.ts +0 -42
  243. package/dist/styles/fill.js +0 -52
  244. package/dist/styles/fill.js.map +0 -1
  245. package/dist/styles/flow.d.ts +0 -16
  246. package/dist/styles/flow.js +0 -12
  247. package/dist/styles/flow.js.map +0 -1
  248. package/dist/styles/gap.d.ts +0 -31
  249. package/dist/styles/gap.js +0 -37
  250. package/dist/styles/gap.js.map +0 -1
  251. package/dist/styles/height.d.ts +0 -17
  252. package/dist/styles/height.js +0 -20
  253. package/dist/styles/height.js.map +0 -1
  254. package/dist/styles/index.d.ts +0 -2
  255. package/dist/styles/index.js +0 -9
  256. package/dist/styles/index.js.map +0 -1
  257. package/dist/styles/inset.d.ts +0 -52
  258. package/dist/styles/inset.js +0 -150
  259. package/dist/styles/inset.js.map +0 -1
  260. package/dist/styles/justify.d.ts +0 -15
  261. package/dist/styles/justify.js +0 -14
  262. package/dist/styles/justify.js.map +0 -1
  263. package/dist/styles/list.d.ts +0 -16
  264. package/dist/styles/list.js +0 -98
  265. package/dist/styles/list.js.map +0 -1
  266. package/dist/styles/margin.d.ts +0 -24
  267. package/dist/styles/margin.js +0 -104
  268. package/dist/styles/margin.js.map +0 -1
  269. package/dist/styles/outline.d.ts +0 -29
  270. package/dist/styles/outline.js +0 -65
  271. package/dist/styles/outline.js.map +0 -1
  272. package/dist/styles/padding.d.ts +0 -24
  273. package/dist/styles/padding.js +0 -104
  274. package/dist/styles/padding.js.map +0 -1
  275. package/dist/styles/predefined.d.ts +0 -71
  276. package/dist/styles/predefined.js +0 -238
  277. package/dist/styles/predefined.js.map +0 -1
  278. package/dist/styles/preset.d.ts +0 -47
  279. package/dist/styles/preset.js +0 -126
  280. package/dist/styles/preset.js.map +0 -1
  281. package/dist/styles/radius.d.ts +0 -14
  282. package/dist/styles/radius.js +0 -51
  283. package/dist/styles/radius.js.map +0 -1
  284. package/dist/styles/scrollbar.d.ts +0 -25
  285. package/dist/styles/scrollbar.js +0 -48
  286. package/dist/styles/scrollbar.js.map +0 -1
  287. package/dist/styles/shadow.d.ts +0 -14
  288. package/dist/styles/shadow.js +0 -24
  289. package/dist/styles/shadow.js.map +0 -1
  290. package/dist/styles/transition.d.ts +0 -14
  291. package/dist/styles/transition.js +0 -158
  292. package/dist/styles/transition.js.map +0 -1
  293. package/dist/styles/types.d.ts +0 -523
  294. package/dist/styles/width.d.ts +0 -17
  295. package/dist/styles/width.js +0 -20
  296. package/dist/styles/width.js.map +0 -1
  297. package/dist/tasty.d.ts +0 -114
  298. package/dist/tasty.js +0 -232
  299. package/dist/tasty.js.map +0 -1
  300. package/dist/types.d.ts +0 -184
  301. package/dist/utils/cache-wrapper.js +0 -22
  302. package/dist/utils/cache-wrapper.js.map +0 -1
  303. package/dist/utils/case-converter.js +0 -8
  304. package/dist/utils/case-converter.js.map +0 -1
  305. package/dist/utils/color-math.d.ts +0 -46
  306. package/dist/utils/color-math.js +0 -749
  307. package/dist/utils/color-math.js.map +0 -1
  308. package/dist/utils/color-space.d.ts +0 -5
  309. package/dist/utils/color-space.js +0 -229
  310. package/dist/utils/color-space.js.map +0 -1
  311. package/dist/utils/colors.d.ts +0 -5
  312. package/dist/utils/colors.js +0 -11
  313. package/dist/utils/colors.js.map +0 -1
  314. package/dist/utils/css-types.d.ts +0 -7
  315. package/dist/utils/dotize.d.ts +0 -26
  316. package/dist/utils/dotize.js +0 -122
  317. package/dist/utils/dotize.js.map +0 -1
  318. package/dist/utils/filter-base-props.d.ts +0 -15
  319. package/dist/utils/filter-base-props.js +0 -45
  320. package/dist/utils/filter-base-props.js.map +0 -1
  321. package/dist/utils/get-display-name.d.ts +0 -7
  322. package/dist/utils/get-display-name.js +0 -10
  323. package/dist/utils/get-display-name.js.map +0 -1
  324. package/dist/utils/has-keys.js +0 -13
  325. package/dist/utils/has-keys.js.map +0 -1
  326. package/dist/utils/is-dev-env.js +0 -19
  327. package/dist/utils/is-dev-env.js.map +0 -1
  328. package/dist/utils/is-valid-element-type.js +0 -15
  329. package/dist/utils/is-valid-element-type.js.map +0 -1
  330. package/dist/utils/merge-styles.js.map +0 -1
  331. package/dist/utils/mod-attrs.d.ts +0 -8
  332. package/dist/utils/mod-attrs.js +0 -21
  333. package/dist/utils/mod-attrs.js.map +0 -1
  334. package/dist/utils/process-tokens.d.ts +0 -21
  335. package/dist/utils/process-tokens.js +0 -91
  336. package/dist/utils/process-tokens.js.map +0 -1
  337. package/dist/utils/resolve-recipes.d.ts +0 -17
  338. package/dist/utils/resolve-recipes.js +0 -147
  339. package/dist/utils/resolve-recipes.js.map +0 -1
  340. package/dist/utils/selector-transform.js +0 -32
  341. package/dist/utils/selector-transform.js.map +0 -1
  342. package/dist/utils/string.js +0 -8
  343. package/dist/utils/string.js.map +0 -1
  344. package/dist/utils/styles.d.ts +0 -101
  345. package/dist/utils/styles.js +0 -223
  346. package/dist/utils/styles.js.map +0 -1
  347. package/dist/utils/typography.d.ts +0 -47
  348. package/dist/utils/typography.js +0 -43
  349. package/dist/utils/typography.js.map +0 -1
  350. package/dist/utils/warnings.d.ts +0 -16
  351. package/dist/utils/warnings.js +0 -16
  352. package/dist/utils/warnings.js.map +0 -1
  353. package/dist/zero/css-writer.d.ts +0 -45
  354. package/dist/zero/css-writer.js +0 -74
  355. package/dist/zero/css-writer.js.map +0 -1
  356. package/dist/zero/extractor.d.ts +0 -24
  357. package/dist/zero/extractor.js +0 -215
  358. package/dist/zero/extractor.js.map +0 -1
  359. package/docs/PIPELINE.md +0 -519
  360. package/docs/runtime.md +0 -397
@@ -1,259 +0,0 @@
1
- import { isSelector } from "../pipeline/index.js";
2
-
3
- //#region src/chunks/definitions.ts
4
- /**
5
- * Style chunk definitions for CSS chunking optimization.
6
- *
7
- * Styles are grouped into chunks based on:
8
- * 1. Handler dependencies - styles that share a handler MUST be in the same chunk
9
- * 2. Logical grouping - related styles grouped for better cache reuse
10
- *
11
- * See STYLE_CHUNKING_SPEC.md for detailed rationale.
12
- *
13
- * ============================================================================
14
- * ⚠️ CRITICAL ARCHITECTURAL CONSTRAINT: NO CROSS-CHUNK HANDLER DEPENDENCIES
15
- * ============================================================================
16
- *
17
- * Style handlers declare their dependencies via `__lookupStyles` array.
18
- * This creates a dependency graph where handlers read multiple style props.
19
- *
20
- * **ALL styles in a handler's `__lookupStyles` MUST be in the SAME chunk.**
21
- *
22
- * Why this matters:
23
- * 1. Each chunk computes a cache key from ONLY its own style values
24
- * 2. If a handler reads a style from another chunk, that value isn't in the cache key
25
- * 3. Changing the cross-chunk style won't invalidate this chunk's cache
26
- * 4. Result: stale CSS output or incorrect cache hits
27
- *
28
- * Example of a violation:
29
- * ```
30
- * // flowStyle.__lookupStyles = ['display', 'flow']
31
- * // If 'display' is in DISPLAY chunk and 'flow' is in LAYOUT chunk:
32
- * // - User sets { display: 'grid', flow: 'column' }
33
- * // - LAYOUT chunk caches CSS with flow=column, display=grid
34
- * // - User changes to { display: 'flex', flow: 'column' }
35
- * // - LAYOUT chunk cache key unchanged (only has 'flow')
36
- * // - Returns stale CSS computed with display=grid!
37
- * ```
38
- *
39
- * Before adding/moving styles, verify:
40
- * 1. Find all handlers that use this style (grep for the style name in __lookupStyles)
41
- * 2. Ensure ALL styles from each handler's __lookupStyles are in the same chunk
42
- * ============================================================================
43
- */
44
- /**
45
- * Appearance chunk - visual styling with independent handlers
46
- */
47
- const APPEARANCE_CHUNK_STYLES = [
48
- "fill",
49
- "color",
50
- "opacity",
51
- "border",
52
- "radius",
53
- "outline",
54
- "outlineOffset",
55
- "shadow",
56
- "fade"
57
- ];
58
- /**
59
- * Font chunk - typography styles
60
- *
61
- * Handler dependencies (all styles in each handler MUST stay in this chunk):
62
- * ⚠️ presetStyle: preset, fontSize, lineHeight, letterSpacing, textTransform,
63
- * fontWeight, fontStyle, font
64
- */
65
- const FONT_CHUNK_STYLES = [
66
- "preset",
67
- "font",
68
- "fontWeight",
69
- "fontStyle",
70
- "fontSize",
71
- "lineHeight",
72
- "letterSpacing",
73
- "textTransform",
74
- "fontFamily",
75
- "textAlign",
76
- "textDecoration",
77
- "wordBreak",
78
- "wordWrap",
79
- "boldFontWeight"
80
- ];
81
- /**
82
- * Dimension chunk - sizing and spacing
83
- *
84
- * Handler dependencies (all styles in each handler MUST stay in this chunk):
85
- * ⚠️ paddingStyle: padding, paddingTop/Right/Bottom/Left, paddingBlock/Inline
86
- * ⚠️ marginStyle: margin, marginTop/Right/Bottom/Left, marginBlock/Inline
87
- * ⚠️ widthStyle: width, minWidth, maxWidth
88
- * ⚠️ heightStyle: height, minHeight, maxHeight
89
- */
90
- const DIMENSION_CHUNK_STYLES = [
91
- "padding",
92
- "paddingTop",
93
- "paddingRight",
94
- "paddingBottom",
95
- "paddingLeft",
96
- "paddingBlock",
97
- "paddingInline",
98
- "margin",
99
- "marginTop",
100
- "marginRight",
101
- "marginBottom",
102
- "marginLeft",
103
- "marginBlock",
104
- "marginInline",
105
- "width",
106
- "minWidth",
107
- "maxWidth",
108
- "height",
109
- "minHeight",
110
- "maxHeight",
111
- "flexBasis",
112
- "flexGrow",
113
- "flexShrink",
114
- "flex"
115
- ];
116
- /**
117
- * Display chunk - display mode, layout flow, text overflow, and scrollbar
118
- *
119
- * Handler dependencies (all styles in each handler MUST stay in this chunk):
120
- * ⚠️ displayStyle: display, hide, textOverflow, overflow, whiteSpace
121
- * ⚠️ flowStyle: display, flow
122
- * ⚠️ gapStyle: display, flow, gap
123
- * ⚠️ scrollbarStyle: scrollbar, overflow
124
- */
125
- const DISPLAY_CHUNK_STYLES = [
126
- "display",
127
- "hide",
128
- "textOverflow",
129
- "overflow",
130
- "whiteSpace",
131
- "flow",
132
- "gap",
133
- "scrollbar"
134
- ];
135
- /**
136
- * Layout chunk - flex/grid alignment and grid templates
137
- *
138
- * Note: flow and gap are in DISPLAY chunk due to handler dependencies
139
- * (flowStyle and gapStyle both require 'display' prop).
140
- */
141
- const LAYOUT_CHUNK_STYLES = [
142
- "placeItems",
143
- "placeContent",
144
- "alignItems",
145
- "alignContent",
146
- "justifyItems",
147
- "justifyContent",
148
- "align",
149
- "justify",
150
- "place",
151
- "columnGap",
152
- "rowGap",
153
- "gridColumns",
154
- "gridRows",
155
- "gridTemplate",
156
- "gridAreas",
157
- "gridAutoFlow",
158
- "gridAutoColumns",
159
- "gridAutoRows"
160
- ];
161
- /**
162
- * Position chunk - element positioning
163
- *
164
- * Handler dependencies (all styles in each handler MUST stay in this chunk):
165
- * ⚠️ insetStyle: inset, insetBlock, insetInline, top, right, bottom, left
166
- */
167
- const POSITION_CHUNK_STYLES = [
168
- "position",
169
- "inset",
170
- "insetBlock",
171
- "insetInline",
172
- "top",
173
- "right",
174
- "bottom",
175
- "left",
176
- "zIndex",
177
- "gridArea",
178
- "gridColumn",
179
- "gridRow",
180
- "order",
181
- "placeSelf",
182
- "alignSelf",
183
- "justifySelf",
184
- "transform",
185
- "transition",
186
- "animation"
187
- ];
188
- const CHUNK_NAMES = {
189
- COMBINED: "combined",
190
- SUBCOMPONENTS: "subcomponents",
191
- APPEARANCE: "appearance",
192
- FONT: "font",
193
- DIMENSION: "dimension",
194
- DISPLAY: "display",
195
- LAYOUT: "layout",
196
- POSITION: "position",
197
- MISC: "misc"
198
- };
199
- /**
200
- * Pre-computed map for O(1) style-to-chunk lookup.
201
- * Built once at module load time.
202
- */
203
- const STYLE_TO_CHUNK = /* @__PURE__ */ new Map();
204
- function populateStyleToChunkMap() {
205
- for (const style of APPEARANCE_CHUNK_STYLES) STYLE_TO_CHUNK.set(style, CHUNK_NAMES.APPEARANCE);
206
- for (const style of FONT_CHUNK_STYLES) STYLE_TO_CHUNK.set(style, CHUNK_NAMES.FONT);
207
- for (const style of DIMENSION_CHUNK_STYLES) STYLE_TO_CHUNK.set(style, CHUNK_NAMES.DIMENSION);
208
- for (const style of DISPLAY_CHUNK_STYLES) STYLE_TO_CHUNK.set(style, CHUNK_NAMES.DISPLAY);
209
- for (const style of LAYOUT_CHUNK_STYLES) STYLE_TO_CHUNK.set(style, CHUNK_NAMES.LAYOUT);
210
- for (const style of POSITION_CHUNK_STYLES) STYLE_TO_CHUNK.set(style, CHUNK_NAMES.POSITION);
211
- }
212
- populateStyleToChunkMap();
213
- /**
214
- * Chunk processing order. This ensures deterministic className allocation
215
- * regardless of style key order in the input.
216
- */
217
- const CHUNK_ORDER = [
218
- CHUNK_NAMES.APPEARANCE,
219
- CHUNK_NAMES.FONT,
220
- CHUNK_NAMES.DIMENSION,
221
- CHUNK_NAMES.DISPLAY,
222
- CHUNK_NAMES.LAYOUT,
223
- CHUNK_NAMES.POSITION,
224
- CHUNK_NAMES.MISC,
225
- CHUNK_NAMES.SUBCOMPONENTS
226
- ];
227
- new Map(CHUNK_ORDER.map((name, index) => [name, index]));
228
- /**
229
- * Categorize style keys into chunks.
230
- *
231
- * Returns chunks in a deterministic order (by CHUNK_ORDER) regardless
232
- * of the order of keys in the input styles object.
233
- *
234
- * @param styles - The styles object to categorize
235
- * @returns Map of chunk name to array of style keys in that chunk (in priority order)
236
- */
237
- function categorizeStyleKeys(styles) {
238
- const chunkData = {};
239
- const keys = Object.keys(styles);
240
- for (const key of keys) {
241
- if (key === "$" || key === "@keyframes" || key === "@properties" || key === "recipe") continue;
242
- if (isSelector(key)) {
243
- if (!chunkData[CHUNK_NAMES.SUBCOMPONENTS]) chunkData[CHUNK_NAMES.SUBCOMPONENTS] = [];
244
- chunkData[CHUNK_NAMES.SUBCOMPONENTS].push(key);
245
- } else {
246
- const chunkName = STYLE_TO_CHUNK.get(key) ?? CHUNK_NAMES.MISC;
247
- if (!chunkData[chunkName]) chunkData[chunkName] = [];
248
- chunkData[chunkName].push(key);
249
- }
250
- }
251
- const orderedChunks = /* @__PURE__ */ new Map();
252
- for (const chunkName of CHUNK_ORDER) if (chunkData[chunkName] && chunkData[chunkName].length > 0) orderedChunks.set(chunkName, chunkData[chunkName].sort());
253
- for (const chunkName of Object.keys(chunkData)) if (!orderedChunks.has(chunkName)) orderedChunks.set(chunkName, chunkData[chunkName].sort());
254
- return orderedChunks;
255
- }
256
-
257
- //#endregion
258
- export { CHUNK_NAMES, STYLE_TO_CHUNK, categorizeStyleKeys };
259
- //# sourceMappingURL=definitions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"definitions.js","names":[],"sources":["../../src/chunks/definitions.ts"],"sourcesContent":["/**\n * Style chunk definitions for CSS chunking optimization.\n *\n * Styles are grouped into chunks based on:\n * 1. Handler dependencies - styles that share a handler MUST be in the same chunk\n * 2. Logical grouping - related styles grouped for better cache reuse\n *\n * See STYLE_CHUNKING_SPEC.md for detailed rationale.\n *\n * ============================================================================\n * ⚠️ CRITICAL ARCHITECTURAL CONSTRAINT: NO CROSS-CHUNK HANDLER DEPENDENCIES\n * ============================================================================\n *\n * Style handlers declare their dependencies via `__lookupStyles` array.\n * This creates a dependency graph where handlers read multiple style props.\n *\n * **ALL styles in a handler's `__lookupStyles` MUST be in the SAME chunk.**\n *\n * Why this matters:\n * 1. Each chunk computes a cache key from ONLY its own style values\n * 2. If a handler reads a style from another chunk, that value isn't in the cache key\n * 3. Changing the cross-chunk style won't invalidate this chunk's cache\n * 4. Result: stale CSS output or incorrect cache hits\n *\n * Example of a violation:\n * ```\n * // flowStyle.__lookupStyles = ['display', 'flow']\n * // If 'display' is in DISPLAY chunk and 'flow' is in LAYOUT chunk:\n * // - User sets { display: 'grid', flow: 'column' }\n * // - LAYOUT chunk caches CSS with flow=column, display=grid\n * // - User changes to { display: 'flex', flow: 'column' }\n * // - LAYOUT chunk cache key unchanged (only has 'flow')\n * // - Returns stale CSS computed with display=grid!\n * ```\n *\n * Before adding/moving styles, verify:\n * 1. Find all handlers that use this style (grep for the style name in __lookupStyles)\n * 2. Ensure ALL styles from each handler's __lookupStyles are in the same chunk\n * ============================================================================\n */\n\nimport { isSelector } from '../pipeline';\n\n// ============================================================================\n// Chunk Style Lists\n// ============================================================================\n\n/**\n * Appearance chunk - visual styling with independent handlers\n */\nexport const APPEARANCE_CHUNK_STYLES = [\n 'fill', // fillStyle (independent)\n 'color', // colorStyle (independent)\n 'opacity', // independent\n 'border', // borderStyle (independent)\n 'radius', // radiusStyle (independent)\n 'outline', // outlineStyle: outline ↔ outlineOffset\n 'outlineOffset', // outlineStyle: outline ↔ outlineOffset\n 'shadow', // shadowStyle (independent)\n 'fade', // fadeStyle (independent)\n] as const;\n\n/**\n * Font chunk - typography styles\n *\n * Handler dependencies (all styles in each handler MUST stay in this chunk):\n * ⚠️ presetStyle: preset, fontSize, lineHeight, letterSpacing, textTransform,\n * fontWeight, fontStyle, font\n */\nexport const FONT_CHUNK_STYLES = [\n // All from presetStyle handler - MUST stay together\n 'preset',\n 'font',\n 'fontWeight',\n 'fontStyle',\n 'fontSize',\n 'lineHeight',\n 'letterSpacing',\n 'textTransform',\n // Independent text styles grouped for cohesion\n 'fontFamily', // independent alias (logical grouping with font styles)\n 'textAlign',\n 'textDecoration',\n 'wordBreak',\n 'wordWrap',\n 'boldFontWeight',\n] as const;\n\n/**\n * Dimension chunk - sizing and spacing\n *\n * Handler dependencies (all styles in each handler MUST stay in this chunk):\n * ⚠️ paddingStyle: padding, paddingTop/Right/Bottom/Left, paddingBlock/Inline\n * ⚠️ marginStyle: margin, marginTop/Right/Bottom/Left, marginBlock/Inline\n * ⚠️ widthStyle: width, minWidth, maxWidth\n * ⚠️ heightStyle: height, minHeight, maxHeight\n */\nexport const DIMENSION_CHUNK_STYLES = [\n // All from paddingStyle handler - MUST stay together\n 'padding',\n 'paddingTop',\n 'paddingRight',\n 'paddingBottom',\n 'paddingLeft',\n 'paddingBlock',\n 'paddingInline',\n // All from marginStyle handler - MUST stay together\n 'margin',\n 'marginTop',\n 'marginRight',\n 'marginBottom',\n 'marginLeft',\n 'marginBlock',\n 'marginInline',\n // widthStyle handler - MUST stay together\n 'width',\n 'minWidth',\n 'maxWidth',\n // heightStyle handler - MUST stay together\n 'height',\n 'minHeight',\n 'maxHeight',\n 'flexBasis',\n 'flexGrow',\n 'flexShrink',\n 'flex',\n] as const;\n\n/**\n * Display chunk - display mode, layout flow, text overflow, and scrollbar\n *\n * Handler dependencies (all styles in each handler MUST stay in this chunk):\n * ⚠️ displayStyle: display, hide, textOverflow, overflow, whiteSpace\n * ⚠️ flowStyle: display, flow\n * ⚠️ gapStyle: display, flow, gap\n * ⚠️ scrollbarStyle: scrollbar, overflow\n */\nexport const DISPLAY_CHUNK_STYLES = [\n // displayStyle handler\n 'display',\n 'hide',\n 'textOverflow',\n 'overflow', // also used by scrollbarStyle\n 'whiteSpace',\n // flowStyle handler (requires display)\n 'flow',\n // gapStyle handler (requires display, flow)\n 'gap',\n // scrollbarStyle handler (requires overflow)\n 'scrollbar',\n] as const;\n\n/**\n * Layout chunk - flex/grid alignment and grid templates\n *\n * Note: flow and gap are in DISPLAY chunk due to handler dependencies\n * (flowStyle and gapStyle both require 'display' prop).\n */\nexport const LAYOUT_CHUNK_STYLES = [\n // Alignment styles (all independent handlers)\n 'placeItems',\n 'placeContent',\n 'alignItems',\n 'alignContent',\n 'justifyItems',\n 'justifyContent',\n 'align', // alignStyle (independent)\n 'justify', // justifyStyle (independent)\n 'place', // placeStyle (independent)\n 'columnGap',\n 'rowGap',\n // Grid template styles\n 'gridColumns',\n 'gridRows',\n 'gridTemplate',\n 'gridAreas',\n 'gridAutoFlow',\n 'gridAutoColumns',\n 'gridAutoRows',\n] as const;\n\n/**\n * Position chunk - element positioning\n *\n * Handler dependencies (all styles in each handler MUST stay in this chunk):\n * ⚠️ insetStyle: inset, insetBlock, insetInline, top, right, bottom, left\n */\nexport const POSITION_CHUNK_STYLES = [\n 'position',\n // All from insetStyle handler - MUST stay together\n 'inset',\n 'insetBlock',\n 'insetInline',\n 'top',\n 'right',\n 'bottom',\n 'left',\n 'zIndex',\n 'gridArea',\n 'gridColumn',\n 'gridRow',\n 'order',\n 'placeSelf',\n 'alignSelf',\n 'justifySelf',\n 'transform',\n 'transition',\n 'animation',\n] as const;\n\n// ============================================================================\n// Chunk Names\n// ============================================================================\n\nexport const CHUNK_NAMES = {\n /** Special chunk for styles that cannot be split (e.g., @starting-style) */\n COMBINED: 'combined',\n SUBCOMPONENTS: 'subcomponents',\n APPEARANCE: 'appearance',\n FONT: 'font',\n DIMENSION: 'dimension',\n DISPLAY: 'display',\n LAYOUT: 'layout',\n POSITION: 'position',\n MISC: 'misc',\n} as const;\n\nexport type ChunkName = (typeof CHUNK_NAMES)[keyof typeof CHUNK_NAMES];\n\n// ============================================================================\n// Style-to-Chunk Lookup Map (O(1) categorization)\n// ============================================================================\n\n/**\n * Pre-computed map for O(1) style-to-chunk lookup.\n * Built once at module load time.\n */\nexport const STYLE_TO_CHUNK = new Map<string, ChunkName>();\n\n// Populate the lookup map\nfunction populateStyleToChunkMap() {\n for (const style of APPEARANCE_CHUNK_STYLES) {\n STYLE_TO_CHUNK.set(style, CHUNK_NAMES.APPEARANCE);\n }\n for (const style of FONT_CHUNK_STYLES) {\n STYLE_TO_CHUNK.set(style, CHUNK_NAMES.FONT);\n }\n for (const style of DIMENSION_CHUNK_STYLES) {\n STYLE_TO_CHUNK.set(style, CHUNK_NAMES.DIMENSION);\n }\n for (const style of DISPLAY_CHUNK_STYLES) {\n STYLE_TO_CHUNK.set(style, CHUNK_NAMES.DISPLAY);\n }\n for (const style of LAYOUT_CHUNK_STYLES) {\n STYLE_TO_CHUNK.set(style, CHUNK_NAMES.LAYOUT);\n }\n for (const style of POSITION_CHUNK_STYLES) {\n STYLE_TO_CHUNK.set(style, CHUNK_NAMES.POSITION);\n }\n}\n\n// Initialize at module load\npopulateStyleToChunkMap();\n\n// ============================================================================\n// Chunk Priority Order\n// ============================================================================\n\n/**\n * Chunk processing order. This ensures deterministic className allocation\n * regardless of style key order in the input.\n */\nconst CHUNK_ORDER: readonly string[] = [\n CHUNK_NAMES.APPEARANCE,\n CHUNK_NAMES.FONT,\n CHUNK_NAMES.DIMENSION,\n CHUNK_NAMES.DISPLAY,\n CHUNK_NAMES.LAYOUT,\n CHUNK_NAMES.POSITION,\n CHUNK_NAMES.MISC,\n CHUNK_NAMES.SUBCOMPONENTS,\n] as const;\n\n/**\n * Map from chunk name to its priority index for sorting.\n */\nconst _CHUNK_PRIORITY = new Map<string, number>(\n CHUNK_ORDER.map((name, index) => [name, index]),\n);\n\n// ============================================================================\n// Chunk Info Interface\n// ============================================================================\n\nexport interface ChunkInfo {\n /** Name of the chunk */\n name: ChunkName | string;\n /** Style keys belonging to this chunk */\n styleKeys: string[];\n}\n\n// ============================================================================\n// Style Categorization\n// ============================================================================\n\n/**\n * Categorize style keys into chunks.\n *\n * Returns chunks in a deterministic order (by CHUNK_ORDER) regardless\n * of the order of keys in the input styles object.\n *\n * @param styles - The styles object to categorize\n * @returns Map of chunk name to array of style keys in that chunk (in priority order)\n */\nexport function categorizeStyleKeys(\n styles: Record<string, unknown>,\n): Map<string, string[]> {\n // First pass: collect keys into chunks (unordered)\n const chunkData: Record<string, string[]> = {};\n const keys = Object.keys(styles);\n\n for (const key of keys) {\n // Skip the $ helper key (used for selector combinators)\n // Skip @keyframes and @properties (processed separately in useStyles)\n // Skip recipe (resolved before pipeline by resolveRecipes)\n if (\n key === '$' ||\n key === '@keyframes' ||\n key === '@properties' ||\n key === 'recipe'\n ) {\n continue;\n }\n\n if (isSelector(key)) {\n // All selectors go into the subcomponents chunk\n if (!chunkData[CHUNK_NAMES.SUBCOMPONENTS]) {\n chunkData[CHUNK_NAMES.SUBCOMPONENTS] = [];\n }\n chunkData[CHUNK_NAMES.SUBCOMPONENTS].push(key);\n } else {\n // Look up the chunk for this style, default to misc\n const chunkName = STYLE_TO_CHUNK.get(key) ?? CHUNK_NAMES.MISC;\n if (!chunkData[chunkName]) {\n chunkData[chunkName] = [];\n }\n chunkData[chunkName].push(key);\n }\n }\n\n // Second pass: build ordered Map based on CHUNK_ORDER\n const orderedChunks = new Map<string, string[]>();\n\n // Add chunks in priority order\n for (const chunkName of CHUNK_ORDER) {\n if (chunkData[chunkName] && chunkData[chunkName].length > 0) {\n // Sort keys within chunk for consistent cache key generation\n orderedChunks.set(chunkName, chunkData[chunkName].sort());\n }\n }\n\n // Handle any unknown chunks (shouldn't happen, but be defensive)\n for (const chunkName of Object.keys(chunkData)) {\n if (!orderedChunks.has(chunkName)) {\n orderedChunks.set(chunkName, chunkData[chunkName].sort());\n }\n }\n\n return orderedChunks;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA,MAAa,0BAA0B;CACrC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;;;;;;;;AASD,MAAa,oBAAoB;CAE/B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACD;;;;;;;;;;AAWD,MAAa,yBAAyB;CAEpC;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;;;;;;;;;;AAWD,MAAa,uBAAuB;CAElC;CACA;CACA;CACA;CACA;CAEA;CAEA;CAEA;CACD;;;;;;;AAQD,MAAa,sBAAsB;CAEjC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;;;;;;;AAQD,MAAa,wBAAwB;CACnC;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAMD,MAAa,cAAc;CAEzB,UAAU;CACV,eAAe;CACf,YAAY;CACZ,MAAM;CACN,WAAW;CACX,SAAS;CACT,QAAQ;CACR,UAAU;CACV,MAAM;CACP;;;;;AAYD,MAAa,iCAAiB,IAAI,KAAwB;AAG1D,SAAS,0BAA0B;AACjC,MAAK,MAAM,SAAS,wBAClB,gBAAe,IAAI,OAAO,YAAY,WAAW;AAEnD,MAAK,MAAM,SAAS,kBAClB,gBAAe,IAAI,OAAO,YAAY,KAAK;AAE7C,MAAK,MAAM,SAAS,uBAClB,gBAAe,IAAI,OAAO,YAAY,UAAU;AAElD,MAAK,MAAM,SAAS,qBAClB,gBAAe,IAAI,OAAO,YAAY,QAAQ;AAEhD,MAAK,MAAM,SAAS,oBAClB,gBAAe,IAAI,OAAO,YAAY,OAAO;AAE/C,MAAK,MAAM,SAAS,sBAClB,gBAAe,IAAI,OAAO,YAAY,SAAS;;AAKnD,yBAAyB;;;;;AAUzB,MAAM,cAAiC;CACrC,YAAY;CACZ,YAAY;CACZ,YAAY;CACZ,YAAY;CACZ,YAAY;CACZ,YAAY;CACZ,YAAY;CACZ,YAAY;CACb;AAKuB,IAAI,IAC1B,YAAY,KAAK,MAAM,UAAU,CAAC,MAAM,MAAM,CAAC,CAChD;;;;;;;;;;AA0BD,SAAgB,oBACd,QACuB;CAEvB,MAAM,YAAsC,EAAE;CAC9C,MAAM,OAAO,OAAO,KAAK,OAAO;AAEhC,MAAK,MAAM,OAAO,MAAM;AAItB,MACE,QAAQ,OACR,QAAQ,gBACR,QAAQ,iBACR,QAAQ,SAER;AAGF,MAAI,WAAW,IAAI,EAAE;AAEnB,OAAI,CAAC,UAAU,YAAY,eACzB,WAAU,YAAY,iBAAiB,EAAE;AAE3C,aAAU,YAAY,eAAe,KAAK,IAAI;SACzC;GAEL,MAAM,YAAY,eAAe,IAAI,IAAI,IAAI,YAAY;AACzD,OAAI,CAAC,UAAU,WACb,WAAU,aAAa,EAAE;AAE3B,aAAU,WAAW,KAAK,IAAI;;;CAKlC,MAAM,gCAAgB,IAAI,KAAuB;AAGjD,MAAK,MAAM,aAAa,YACtB,KAAI,UAAU,cAAc,UAAU,WAAW,SAAS,EAExD,eAAc,IAAI,WAAW,UAAU,WAAW,MAAM,CAAC;AAK7D,MAAK,MAAM,aAAa,OAAO,KAAK,UAAU,CAC5C,KAAI,CAAC,cAAc,IAAI,UAAU,CAC/B,eAAc,IAAI,WAAW,UAAU,WAAW,MAAM,CAAC;AAI7D,QAAO"}
@@ -1,60 +0,0 @@
1
- import { extractLocalPredefinedStates } from "../states/index.js";
2
- import { hasPipelineCacheEntry, renderStyles } from "../pipeline/index.js";
3
- import { CHUNK_NAMES } from "./definitions.js";
4
-
5
- //#region src/chunks/renderChunk.ts
6
- /**
7
- * Build a filtered styles object for a regular chunk.
8
- */
9
- function buildFilteredStyles(styles, styleKeys) {
10
- const localPredefinedStates = extractLocalPredefinedStates(styles);
11
- const filteredStyles = {};
12
- for (const [key, value] of Object.entries(localPredefinedStates)) filteredStyles[key] = value;
13
- for (const key of styleKeys) {
14
- const value = styles[key];
15
- if (value !== void 0) filteredStyles[key] = value;
16
- }
17
- return filteredStyles;
18
- }
19
- /**
20
- * Build a filtered styles object for the subcomponents chunk.
21
- */
22
- function buildSubcomponentFilteredStyles(styles, selectorKeys) {
23
- const localPredefinedStates = extractLocalPredefinedStates(styles);
24
- const filteredStyles = {};
25
- for (const [key, value] of Object.entries(localPredefinedStates)) filteredStyles[key] = value;
26
- for (const key of selectorKeys) {
27
- const value = styles[key];
28
- if (value !== void 0) filteredStyles[key] = value;
29
- }
30
- if (styles.$ !== void 0) filteredStyles.$ = styles.$;
31
- return filteredStyles;
32
- }
33
- /**
34
- * Render styles for a specific chunk.
35
- *
36
- * On pipeline cache hit, avoids building the filtered styles object entirely.
37
- * Only constructs it on cache miss when the pipeline actually needs the styles.
38
- *
39
- * IMPORTANT: Local predefined states (e.g., '@mobile': '@media(w < 600px)')
40
- * are always included in the filtered styles, regardless of which chunk is
41
- * being rendered. This ensures that state references like '@mobile' in any
42
- * chunk can be properly resolved by the pipeline.
43
- *
44
- * @param styles - The full styles object
45
- * @param chunkName - Name of the chunk being rendered
46
- * @param styleKeys - Keys of styles belonging to this chunk
47
- * @returns RenderResult with rules for this chunk
48
- */
49
- function renderStylesForChunk(styles, chunkName, styleKeys, pipelineCacheKey) {
50
- if (styleKeys.length === 0) return {
51
- rules: [],
52
- className: ""
53
- };
54
- if (pipelineCacheKey && hasPipelineCacheEntry(pipelineCacheKey)) return renderStyles(void 0, void 0, void 0, pipelineCacheKey);
55
- return renderStyles(chunkName === CHUNK_NAMES.SUBCOMPONENTS ? buildSubcomponentFilteredStyles(styles, styleKeys) : buildFilteredStyles(styles, styleKeys), void 0, void 0, pipelineCacheKey);
56
- }
57
-
58
- //#endregion
59
- export { renderStylesForChunk };
60
- //# sourceMappingURL=renderChunk.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"renderChunk.js","names":[],"sources":["../../src/chunks/renderChunk.ts"],"sourcesContent":["/**\n * Chunk-specific style rendering.\n *\n * Renders styles for a specific chunk by filtering the styles object\n * to only include relevant keys before passing to renderStyles.\n */\n\nimport type { RenderResult } from '../pipeline';\nimport { hasPipelineCacheEntry, renderStyles } from '../pipeline';\nimport { extractLocalPredefinedStates } from '../states';\nimport type { Styles } from '../styles/types';\n\nimport { CHUNK_NAMES } from './definitions';\n\n/**\n * Build a filtered styles object for a regular chunk.\n */\nfunction buildFilteredStyles(styles: Styles, styleKeys: string[]): Styles {\n const localPredefinedStates = extractLocalPredefinedStates(styles);\n const filteredStyles: Styles = {};\n\n for (const [key, value] of Object.entries(localPredefinedStates)) {\n filteredStyles[key] = value;\n }\n\n for (const key of styleKeys) {\n const value = styles[key];\n if (value !== undefined) {\n filteredStyles[key] = value;\n }\n }\n\n return filteredStyles;\n}\n\n/**\n * Build a filtered styles object for the subcomponents chunk.\n */\nfunction buildSubcomponentFilteredStyles(\n styles: Styles,\n selectorKeys: string[],\n): Styles {\n const localPredefinedStates = extractLocalPredefinedStates(styles);\n const filteredStyles: Styles = {};\n\n for (const [key, value] of Object.entries(localPredefinedStates)) {\n filteredStyles[key] = value;\n }\n\n for (const key of selectorKeys) {\n const value = styles[key];\n if (value !== undefined) {\n filteredStyles[key] = value;\n }\n }\n\n if (styles.$ !== undefined) {\n filteredStyles.$ = styles.$;\n }\n\n return filteredStyles;\n}\n\n/**\n * Render styles for a specific chunk.\n *\n * On pipeline cache hit, avoids building the filtered styles object entirely.\n * Only constructs it on cache miss when the pipeline actually needs the styles.\n *\n * IMPORTANT: Local predefined states (e.g., '@mobile': '@media(w < 600px)')\n * are always included in the filtered styles, regardless of which chunk is\n * being rendered. This ensures that state references like '@mobile' in any\n * chunk can be properly resolved by the pipeline.\n *\n * @param styles - The full styles object\n * @param chunkName - Name of the chunk being rendered\n * @param styleKeys - Keys of styles belonging to this chunk\n * @returns RenderResult with rules for this chunk\n */\nexport function renderStylesForChunk(\n styles: Styles,\n chunkName: string,\n styleKeys: string[],\n pipelineCacheKey?: string,\n): RenderResult {\n if (styleKeys.length === 0) {\n return { rules: [], className: '' };\n }\n\n // Fast path: skip building filteredStyles when pipeline has a cached result\n if (pipelineCacheKey && hasPipelineCacheEntry(pipelineCacheKey)) {\n return renderStyles(undefined, undefined, undefined, pipelineCacheKey);\n }\n\n // Cache miss: build filtered styles and run pipeline\n const filteredStyles =\n chunkName === CHUNK_NAMES.SUBCOMPONENTS\n ? buildSubcomponentFilteredStyles(styles, styleKeys)\n : buildFilteredStyles(styles, styleKeys);\n\n return renderStyles(filteredStyles, undefined, undefined, pipelineCacheKey);\n}\n"],"mappings":";;;;;;;;AAiBA,SAAS,oBAAoB,QAAgB,WAA6B;CACxE,MAAM,wBAAwB,6BAA6B,OAAO;CAClE,MAAM,iBAAyB,EAAE;AAEjC,MAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,sBAAsB,CAC9D,gBAAe,OAAO;AAGxB,MAAK,MAAM,OAAO,WAAW;EAC3B,MAAM,QAAQ,OAAO;AACrB,MAAI,UAAU,OACZ,gBAAe,OAAO;;AAI1B,QAAO;;;;;AAMT,SAAS,gCACP,QACA,cACQ;CACR,MAAM,wBAAwB,6BAA6B,OAAO;CAClE,MAAM,iBAAyB,EAAE;AAEjC,MAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,sBAAsB,CAC9D,gBAAe,OAAO;AAGxB,MAAK,MAAM,OAAO,cAAc;EAC9B,MAAM,QAAQ,OAAO;AACrB,MAAI,UAAU,OACZ,gBAAe,OAAO;;AAI1B,KAAI,OAAO,MAAM,OACf,gBAAe,IAAI,OAAO;AAG5B,QAAO;;;;;;;;;;;;;;;;;;AAmBT,SAAgB,qBACd,QACA,WACA,WACA,kBACc;AACd,KAAI,UAAU,WAAW,EACvB,QAAO;EAAE,OAAO,EAAE;EAAE,WAAW;EAAI;AAIrC,KAAI,oBAAoB,sBAAsB,iBAAiB,CAC7D,QAAO,aAAa,QAAW,QAAW,QAAW,iBAAiB;AASxE,QAAO,aAJL,cAAc,YAAY,gBACtB,gCAAgC,QAAQ,UAAU,GAClD,oBAAoB,QAAQ,UAAU,EAER,QAAW,QAAW,iBAAiB"}
package/dist/config.d.ts DELETED
@@ -1,323 +0,0 @@
1
- import { KeyframesSteps, PropertyDefinition } from "./injector/types.js";
2
- import { StyleDetails, UnitHandler } from "./parser/types.js";
3
- import { StyleHandlerDefinition } from "./utils/styles.js";
4
- import { ConfigTokens, RecipeStyles } from "./styles/types.js";
5
- import { StyleInjector } from "./injector/injector.js";
6
- import { ColorSpace } from "./utils/color-space.js";
7
- import { TastyPlugin } from "./plugins/types.js";
8
-
9
- //#region src/config.d.ts
10
- /**
11
- * Configuration options for the Tasty style system
12
- */
13
- interface TastyConfig {
14
- /** CSP nonce for style elements */
15
- nonce?: string;
16
- /** Maximum rules per stylesheet (default: 8192) */
17
- maxRulesPerSheet?: number;
18
- /** Threshold for bulk cleanup of unused styles (default: 500) */
19
- unusedStylesThreshold?: number;
20
- /** Delay before bulk cleanup in ms, ignored if idleCleanup is true (default: 5000) */
21
- bulkCleanupDelay?: number;
22
- /** Use requestIdleCallback for cleanup when available (default: true) */
23
- idleCleanup?: boolean;
24
- /** Force text injection mode, auto-detected in test environments (default: auto) */
25
- forceTextInjection?: boolean;
26
- /** Enable development mode features: performance metrics and debug info (default: auto) */
27
- devMode?: boolean;
28
- /**
29
- * Ratio of unused styles to delete per bulk cleanup run (0..1).
30
- * Defaults to 0.5 (oldest half) to reduce risk of removing styles
31
- * that may be restored shortly after being marked unused.
32
- */
33
- bulkCleanupBatchRatio?: number;
34
- /**
35
- * Minimum age (in ms) a style must remain unused before eligible for deletion.
36
- * Helps avoid races during rapid mount/unmount cycles. Default: 10000ms.
37
- */
38
- unusedStylesMinAgeMs?: number;
39
- /**
40
- * Global predefined states for advanced state mapping.
41
- * These are state aliases that can be used in any component.
42
- * Example: { '@mobile': '@media(w < 920px)', '@dark': '@root(theme=dark)' }
43
- */
44
- states?: Record<string, string>;
45
- /**
46
- * Parser LRU cache size (default: 1000).
47
- * Larger values improve performance for apps with many unique style values.
48
- */
49
- parserCacheSize?: number;
50
- /**
51
- * Custom units for the style parser (merged with built-in units).
52
- * Units transform numeric values like `2x` → `calc(2 * var(--gap))`.
53
- * @example { em: 'em', vw: 'vw', custom: (n) => `${n * 10}px` }
54
- */
55
- units?: Record<string, string | UnitHandler>;
56
- /**
57
- * Custom functions for the style parser (merged with existing).
58
- * Functions process parsed style groups and return CSS values.
59
- * @example { myFunc: (groups) => groups.map(g => g.output).join(' ') }
60
- */
61
- funcs?: Record<string, (groups: StyleDetails[]) => string>;
62
- /**
63
- * Color space used for decomposed color token companion variables.
64
- * Controls the CSS function and suffix for alpha composition.
65
- *
66
- * - `'rgb'` — suffix `-rgb`, e.g. `rgb(var(--name-color-rgb) / .5)`
67
- * - `'hsl'` — suffix `-hsl`, e.g. `hsl(var(--name-color-hsl) / .5)`
68
- * - `'oklch'` — suffix `-oklch`, e.g. `oklch(var(--name-color-oklch) / .5)`
69
- *
70
- * @default 'oklch'
71
- */
72
- colorSpace?: ColorSpace;
73
- /**
74
- * Automatically infer and register CSS @property declarations
75
- * from custom property values found in styles, keyframes, and global config.
76
- * Covers all types: \<color\>, \<number\>, \<length\>, \<angle\>, \<percentage\>, \<time\>.
77
- * When false, only explicitly declared @properties are registered.
78
- * @default true
79
- */
80
- autoPropertyTypes?: boolean;
81
- /**
82
- * Plugins that extend tasty with custom functions, units, or states.
83
- * Plugins are processed in order, with later plugins overriding earlier ones.
84
- * @example
85
- * ```ts
86
- * import { okhslPlugin } from '@tenphi/tasty';
87
- *
88
- * configure({
89
- * plugins: [okhslPlugin()],
90
- * });
91
- * ```
92
- */
93
- plugins?: TastyPlugin[];
94
- /**
95
- * Global keyframes definitions that can be referenced by animation names in styles.
96
- * Keys are animation names, values are keyframes step definitions.
97
- * Keyframes are only injected when actually used in styles.
98
- * @example
99
- * ```ts
100
- * configure({
101
- * keyframes: {
102
- * fadeIn: { from: { opacity: 0 }, to: { opacity: 1 } },
103
- * pulse: { '0%, 100%': { transform: 'scale(1)' }, '50%': { transform: 'scale(1.05)' } },
104
- * },
105
- * });
106
- * ```
107
- */
108
- keyframes?: Record<string, KeyframesSteps>;
109
- /**
110
- * Global CSS @property definitions for custom properties.
111
- * Keys use tasty token syntax ($name for properties, #name for colors).
112
- * Properties are only injected when the component using them is rendered.
113
- *
114
- * For color tokens (#name), `syntax: '<color>'` is auto-set and
115
- * `initialValue` defaults to `'transparent'` if not specified.
116
- *
117
- * @example
118
- * ```ts
119
- * configure({
120
- * properties: {
121
- * '$rotation': { syntax: '<angle>', initialValue: '0deg' },
122
- * '$scale': { syntax: '<number>', inherits: false, initialValue: 1 },
123
- * '#accent': { initialValue: 'purple' }, // syntax: '<color>' auto-set
124
- * },
125
- * });
126
- *
127
- * // Now use in styles - properties are registered when component renders:
128
- * const Spinner = tasty({
129
- * styles: {
130
- * transform: 'rotate($rotation)',
131
- * transition: '$$rotation 0.3s', // outputs: --rotation 0.3s
132
- * },
133
- * });
134
- * ```
135
- */
136
- properties?: Record<string, PropertyDefinition>;
137
- /**
138
- * Custom style handlers that transform style properties into CSS declarations.
139
- * Handlers replace built-in handlers for the same style name.
140
- * @example
141
- * ```ts
142
- * import { styleHandlers } from '@tenphi/tasty';
143
- *
144
- * configure({
145
- * handlers: {
146
- * // Override fill with custom behavior
147
- * fill: ({ fill }) => {
148
- * if (fill?.startsWith('gradient:')) {
149
- * return { background: fill.slice(9) };
150
- * }
151
- * return styleHandlers.fill({ fill });
152
- * },
153
- * // Add new custom style
154
- * elevation: ({ elevation }) => {
155
- * const level = parseInt(elevation) || 1;
156
- * return {
157
- * 'box-shadow': `0 ${level * 2}px ${level * 4}px rgba(0,0,0,0.1)`,
158
- * 'z-index': String(level * 100),
159
- * };
160
- * },
161
- * },
162
- * });
163
- * ```
164
- */
165
- handlers?: Record<string, StyleHandlerDefinition>;
166
- /**
167
- * Design tokens injected as CSS custom properties on `:root`.
168
- * Values are parsed through the Tasty DSL. Supports state maps
169
- * for responsive/theme-aware tokens.
170
- *
171
- * - `$name` keys become `--name` CSS custom properties
172
- * - `#name` keys become `--name-color` and `--name-color-{colorSpace}` properties
173
- *
174
- * Tokens are injected once when the first style is rendered.
175
- *
176
- * @example
177
- * ```ts
178
- * configure({
179
- * tokens: {
180
- * '$gap': '4px',
181
- * '#primary': {
182
- * '': '#purple',
183
- * '@dark': '#light-purple',
184
- * },
185
- * },
186
- * });
187
- * ```
188
- */
189
- tokens?: ConfigTokens;
190
- /**
191
- * Predefined tokens that are replaced during style parsing (parse-time substitution).
192
- * Use `$name` for custom properties and `#name` for color tokens.
193
- * Values are substituted inline before CSS generation, unlike `tokens` which
194
- * inject CSS custom properties on `:root`.
195
- *
196
- * For color tokens (#name), boolean `true` is converted to `transparent`.
197
- *
198
- * @example
199
- * ```ts
200
- * configure({
201
- * replaceTokens: {
202
- * $spacing: '2x',
203
- * '#accent': '#purple',
204
- * '#overlay': true, // → transparent
205
- * },
206
- * });
207
- *
208
- * // Now use in styles - tokens are replaced at parse time:
209
- * const Card = tasty({
210
- * styles: {
211
- * padding: '$spacing', // → calc(2 * var(--gap))
212
- * fill: '#accent', // → var(--purple-color)
213
- * },
214
- * });
215
- * ```
216
- */
217
- replaceTokens?: Record<`$${string}`, string | number | boolean> & Record<`#${string}`, string | number | boolean>;
218
- /**
219
- * Predefined style recipes -- named style bundles that can be applied via `recipe` style property.
220
- * Recipe values are flat tasty styles (no sub-element keys). They may contain base styles,
221
- * tokens (`$name`/`#name` definitions), local states, `@keyframes`, and `@properties`.
222
- *
223
- * Components reference recipes via: `recipe: 'name1 name2'` in their styles.
224
- * Use `/` to separate base recipes from post recipes: `recipe: 'base1 base2 / post1'`.
225
- * Use `none` to skip base recipes: `recipe: 'none / post1'`.
226
- * Resolution order: `base_recipes → component styles → post_recipes`.
227
- *
228
- * Recipes cannot reference other recipes.
229
- *
230
- * @example
231
- * ```ts
232
- * configure({
233
- * recipes: {
234
- * card: { padding: '4x', fill: '#surface', radius: '1r', border: true },
235
- * elevated: { shadow: '2x 2x 4x #shadow' },
236
- * },
237
- * });
238
- *
239
- * // Usage in styles:
240
- * const Card = tasty({
241
- * styles: {
242
- * recipe: 'card elevated',
243
- * color: '#text', // Overrides recipe values
244
- * },
245
- * });
246
- * ```
247
- */
248
- recipes?: Record<string, RecipeStyles>;
249
- }
250
- declare const GLOBAL_INJECTOR_KEY = "__TASTY_GLOBAL_INJECTOR__";
251
- declare global {
252
- interface Window {
253
- [GLOBAL_INJECTOR_KEY]?: StyleInjector;
254
- }
255
- var __TASTY_GLOBAL_INJECTOR__: StyleInjector | undefined;
256
- }
257
- /**
258
- * Detect if we're running in a test environment
259
- */
260
- declare function isTestEnvironment(): boolean;
261
- /**
262
- * Check if styles have been generated (configuration is locked)
263
- */
264
- declare function hasStylesGenerated(): boolean;
265
- /**
266
- * Check if any global keyframes are configured.
267
- * Uses a pre-computed flag to avoid Object.keys() allocation on every call.
268
- */
269
- declare function hasGlobalKeyframes(): boolean;
270
- /**
271
- * Get global keyframes configuration.
272
- * Returns null if no keyframes configured (fast path for zero-overhead).
273
- */
274
- declare function getGlobalKeyframes(): Record<string, KeyframesSteps> | null;
275
- /**
276
- * Check if any global recipes are configured.
277
- * Fast path: returns false if no recipes were ever set.
278
- */
279
- declare function hasGlobalRecipes(): boolean;
280
- /**
281
- * Get global recipes configuration.
282
- * Returns null if no recipes configured (fast path for zero-overhead).
283
- */
284
- declare function getGlobalRecipes(): Record<string, RecipeStyles> | null;
285
- /**
286
- * Check if configuration is locked (styles have been generated)
287
- */
288
- declare function isConfigLocked(): boolean;
289
- /**
290
- * Configure the Tasty style system.
291
- *
292
- * Must be called BEFORE any styles are generated (before first render that uses tasty).
293
- * After styles are generated, configuration is locked and calls to configure() will
294
- * emit a warning and be ignored.
295
- *
296
- * @example
297
- * ```ts
298
- * import { configure } from '@tenphi/tasty';
299
- *
300
- * // Configure before app renders
301
- * configure({
302
- * nonce: 'abc123',
303
- * states: {
304
- * '@mobile': '@media(w < 768px)',
305
- * '@dark': '@root(theme=dark)',
306
- * },
307
- * });
308
- * ```
309
- */
310
- declare function configure(config?: Partial<TastyConfig>): void;
311
- /**
312
- * Get the current configuration.
313
- * If not configured, returns default configuration.
314
- */
315
- declare function getConfig(): TastyConfig;
316
- /**
317
- * Reset configuration (for testing only).
318
- * Clears the global injector and allows reconfiguration.
319
- */
320
- declare function resetConfig(): void;
321
- //#endregion
322
- export { TastyConfig, configure, getConfig, getGlobalKeyframes, getGlobalRecipes, hasGlobalKeyframes, hasGlobalRecipes, hasStylesGenerated, isConfigLocked, isTestEnvironment, resetConfig };
323
- //# sourceMappingURL=config.d.ts.map