@tenphi/tasty 0.0.0-snapshot.12940ba

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 (242) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +464 -0
  3. package/dist/_virtual/_rolldown/runtime.js +8 -0
  4. package/dist/chunks/cacheKey.d.ts +1 -0
  5. package/dist/chunks/cacheKey.js +70 -0
  6. package/dist/chunks/cacheKey.js.map +1 -0
  7. package/dist/chunks/definitions.d.ts +37 -0
  8. package/dist/chunks/definitions.js +260 -0
  9. package/dist/chunks/definitions.js.map +1 -0
  10. package/dist/chunks/index.d.ts +3 -0
  11. package/dist/chunks/renderChunk.d.ts +2 -0
  12. package/dist/chunks/renderChunk.js +61 -0
  13. package/dist/chunks/renderChunk.js.map +1 -0
  14. package/dist/config.d.ts +280 -0
  15. package/dist/config.js +403 -0
  16. package/dist/config.js.map +1 -0
  17. package/dist/debug.d.ts +204 -0
  18. package/dist/debug.js +733 -0
  19. package/dist/debug.js.map +1 -0
  20. package/dist/hooks/index.d.ts +5 -0
  21. package/dist/hooks/useGlobalStyles.d.ts +27 -0
  22. package/dist/hooks/useGlobalStyles.js +56 -0
  23. package/dist/hooks/useGlobalStyles.js.map +1 -0
  24. package/dist/hooks/useKeyframes.d.ts +56 -0
  25. package/dist/hooks/useKeyframes.js +54 -0
  26. package/dist/hooks/useKeyframes.js.map +1 -0
  27. package/dist/hooks/useProperty.d.ts +79 -0
  28. package/dist/hooks/useProperty.js +91 -0
  29. package/dist/hooks/useProperty.js.map +1 -0
  30. package/dist/hooks/useRawCSS.d.ts +53 -0
  31. package/dist/hooks/useRawCSS.js +28 -0
  32. package/dist/hooks/useRawCSS.js.map +1 -0
  33. package/dist/hooks/useStyles.d.ts +40 -0
  34. package/dist/hooks/useStyles.js +169 -0
  35. package/dist/hooks/useStyles.js.map +1 -0
  36. package/dist/index.d.ts +38 -0
  37. package/dist/index.js +30 -0
  38. package/dist/injector/index.d.ts +157 -0
  39. package/dist/injector/index.js +154 -0
  40. package/dist/injector/index.js.map +1 -0
  41. package/dist/injector/injector.d.ts +139 -0
  42. package/dist/injector/injector.js +404 -0
  43. package/dist/injector/injector.js.map +1 -0
  44. package/dist/injector/sheet-manager.d.ts +127 -0
  45. package/dist/injector/sheet-manager.js +714 -0
  46. package/dist/injector/sheet-manager.js.map +1 -0
  47. package/dist/injector/types.d.ts +135 -0
  48. package/dist/keyframes/index.js +206 -0
  49. package/dist/keyframes/index.js.map +1 -0
  50. package/dist/parser/classify.js +319 -0
  51. package/dist/parser/classify.js.map +1 -0
  52. package/dist/parser/const.js +33 -0
  53. package/dist/parser/const.js.map +1 -0
  54. package/dist/parser/index.d.ts +3 -0
  55. package/dist/parser/index.js +4 -0
  56. package/dist/parser/lru.js +109 -0
  57. package/dist/parser/lru.js.map +1 -0
  58. package/dist/parser/parser.d.ts +25 -0
  59. package/dist/parser/parser.js +116 -0
  60. package/dist/parser/parser.js.map +1 -0
  61. package/dist/parser/tokenizer.js +69 -0
  62. package/dist/parser/tokenizer.js.map +1 -0
  63. package/dist/parser/types.d.ts +51 -0
  64. package/dist/parser/types.js +46 -0
  65. package/dist/parser/types.js.map +1 -0
  66. package/dist/pipeline/conditions.js +398 -0
  67. package/dist/pipeline/conditions.js.map +1 -0
  68. package/dist/pipeline/exclusive.d.ts +1 -0
  69. package/dist/pipeline/exclusive.js +231 -0
  70. package/dist/pipeline/exclusive.js.map +1 -0
  71. package/dist/pipeline/index.d.ts +53 -0
  72. package/dist/pipeline/index.js +642 -0
  73. package/dist/pipeline/index.js.map +1 -0
  74. package/dist/pipeline/materialize.js +894 -0
  75. package/dist/pipeline/materialize.js.map +1 -0
  76. package/dist/pipeline/parseStateKey.d.ts +1 -0
  77. package/dist/pipeline/parseStateKey.js +439 -0
  78. package/dist/pipeline/parseStateKey.js.map +1 -0
  79. package/dist/pipeline/simplify.js +557 -0
  80. package/dist/pipeline/simplify.js.map +1 -0
  81. package/dist/plugins/index.d.ts +2 -0
  82. package/dist/plugins/okhsl-plugin.d.ts +35 -0
  83. package/dist/plugins/okhsl-plugin.js +371 -0
  84. package/dist/plugins/okhsl-plugin.js.map +1 -0
  85. package/dist/plugins/types.d.ts +69 -0
  86. package/dist/properties/index.js +158 -0
  87. package/dist/properties/index.js.map +1 -0
  88. package/dist/states/index.d.ts +45 -0
  89. package/dist/states/index.js +416 -0
  90. package/dist/states/index.js.map +1 -0
  91. package/dist/static/index.d.ts +5 -0
  92. package/dist/static/index.js +5 -0
  93. package/dist/static/tastyStatic.d.ts +46 -0
  94. package/dist/static/tastyStatic.js +31 -0
  95. package/dist/static/tastyStatic.js.map +1 -0
  96. package/dist/static/types.d.ts +49 -0
  97. package/dist/static/types.js +24 -0
  98. package/dist/static/types.js.map +1 -0
  99. package/dist/styles/align.d.ts +15 -0
  100. package/dist/styles/align.js +14 -0
  101. package/dist/styles/align.js.map +1 -0
  102. package/dist/styles/border.d.ts +25 -0
  103. package/dist/styles/border.js +114 -0
  104. package/dist/styles/border.js.map +1 -0
  105. package/dist/styles/color.d.ts +14 -0
  106. package/dist/styles/color.js +23 -0
  107. package/dist/styles/color.js.map +1 -0
  108. package/dist/styles/createStyle.js +77 -0
  109. package/dist/styles/createStyle.js.map +1 -0
  110. package/dist/styles/dimension.js +97 -0
  111. package/dist/styles/dimension.js.map +1 -0
  112. package/dist/styles/display.d.ts +37 -0
  113. package/dist/styles/display.js +67 -0
  114. package/dist/styles/display.js.map +1 -0
  115. package/dist/styles/fade.d.ts +15 -0
  116. package/dist/styles/fade.js +58 -0
  117. package/dist/styles/fade.js.map +1 -0
  118. package/dist/styles/fill.d.ts +44 -0
  119. package/dist/styles/fill.js +51 -0
  120. package/dist/styles/fill.js.map +1 -0
  121. package/dist/styles/flow.d.ts +16 -0
  122. package/dist/styles/flow.js +12 -0
  123. package/dist/styles/flow.js.map +1 -0
  124. package/dist/styles/gap.d.ts +31 -0
  125. package/dist/styles/gap.js +37 -0
  126. package/dist/styles/gap.js.map +1 -0
  127. package/dist/styles/height.d.ts +17 -0
  128. package/dist/styles/height.js +20 -0
  129. package/dist/styles/height.js.map +1 -0
  130. package/dist/styles/index.d.ts +2 -0
  131. package/dist/styles/index.js +9 -0
  132. package/dist/styles/index.js.map +1 -0
  133. package/dist/styles/inset.d.ts +50 -0
  134. package/dist/styles/inset.js +142 -0
  135. package/dist/styles/inset.js.map +1 -0
  136. package/dist/styles/justify.d.ts +15 -0
  137. package/dist/styles/justify.js +14 -0
  138. package/dist/styles/justify.js.map +1 -0
  139. package/dist/styles/list.d.ts +16 -0
  140. package/dist/styles/list.js +98 -0
  141. package/dist/styles/list.js.map +1 -0
  142. package/dist/styles/margin.d.ts +28 -0
  143. package/dist/styles/margin.js +96 -0
  144. package/dist/styles/margin.js.map +1 -0
  145. package/dist/styles/outline.d.ts +29 -0
  146. package/dist/styles/outline.js +65 -0
  147. package/dist/styles/outline.js.map +1 -0
  148. package/dist/styles/padding.d.ts +28 -0
  149. package/dist/styles/padding.js +96 -0
  150. package/dist/styles/padding.js.map +1 -0
  151. package/dist/styles/predefined.d.ts +74 -0
  152. package/dist/styles/predefined.js +241 -0
  153. package/dist/styles/predefined.js.map +1 -0
  154. package/dist/styles/preset.d.ts +47 -0
  155. package/dist/styles/preset.js +126 -0
  156. package/dist/styles/preset.js.map +1 -0
  157. package/dist/styles/radius.d.ts +14 -0
  158. package/dist/styles/radius.js +51 -0
  159. package/dist/styles/radius.js.map +1 -0
  160. package/dist/styles/scrollbar.d.ts +21 -0
  161. package/dist/styles/scrollbar.js +105 -0
  162. package/dist/styles/scrollbar.js.map +1 -0
  163. package/dist/styles/shadow.d.ts +14 -0
  164. package/dist/styles/shadow.js +24 -0
  165. package/dist/styles/shadow.js.map +1 -0
  166. package/dist/styles/styledScrollbar.d.ts +47 -0
  167. package/dist/styles/styledScrollbar.js +38 -0
  168. package/dist/styles/styledScrollbar.js.map +1 -0
  169. package/dist/styles/transition.d.ts +14 -0
  170. package/dist/styles/transition.js +138 -0
  171. package/dist/styles/transition.js.map +1 -0
  172. package/dist/styles/types.d.ts +498 -0
  173. package/dist/styles/width.d.ts +17 -0
  174. package/dist/styles/width.js +20 -0
  175. package/dist/styles/width.js.map +1 -0
  176. package/dist/tasty.d.ts +983 -0
  177. package/dist/tasty.js +191 -0
  178. package/dist/tasty.js.map +1 -0
  179. package/dist/tokens/typography.d.ts +19 -0
  180. package/dist/tokens/typography.js +237 -0
  181. package/dist/tokens/typography.js.map +1 -0
  182. package/dist/types.d.ts +182 -0
  183. package/dist/utils/cache-wrapper.js +26 -0
  184. package/dist/utils/cache-wrapper.js.map +1 -0
  185. package/dist/utils/case-converter.js +8 -0
  186. package/dist/utils/case-converter.js.map +1 -0
  187. package/dist/utils/colors.d.ts +5 -0
  188. package/dist/utils/colors.js +9 -0
  189. package/dist/utils/colors.js.map +1 -0
  190. package/dist/utils/dotize.d.ts +26 -0
  191. package/dist/utils/dotize.js +122 -0
  192. package/dist/utils/dotize.js.map +1 -0
  193. package/dist/utils/filter-base-props.d.ts +15 -0
  194. package/dist/utils/filter-base-props.js +45 -0
  195. package/dist/utils/filter-base-props.js.map +1 -0
  196. package/dist/utils/get-display-name.d.ts +7 -0
  197. package/dist/utils/get-display-name.js +10 -0
  198. package/dist/utils/get-display-name.js.map +1 -0
  199. package/dist/utils/hsl-to-rgb.js +38 -0
  200. package/dist/utils/hsl-to-rgb.js.map +1 -0
  201. package/dist/utils/is-dev-env.js +19 -0
  202. package/dist/utils/is-dev-env.js.map +1 -0
  203. package/dist/utils/merge-styles.d.ts +7 -0
  204. package/dist/utils/merge-styles.js +146 -0
  205. package/dist/utils/merge-styles.js.map +1 -0
  206. package/dist/utils/mod-attrs.d.ts +8 -0
  207. package/dist/utils/mod-attrs.js +21 -0
  208. package/dist/utils/mod-attrs.js.map +1 -0
  209. package/dist/utils/okhsl-to-rgb.js +296 -0
  210. package/dist/utils/okhsl-to-rgb.js.map +1 -0
  211. package/dist/utils/process-tokens.d.ts +31 -0
  212. package/dist/utils/process-tokens.js +171 -0
  213. package/dist/utils/process-tokens.js.map +1 -0
  214. package/dist/utils/resolve-recipes.d.ts +17 -0
  215. package/dist/utils/resolve-recipes.js +147 -0
  216. package/dist/utils/resolve-recipes.js.map +1 -0
  217. package/dist/utils/string.js +8 -0
  218. package/dist/utils/string.js.map +1 -0
  219. package/dist/utils/styles.d.ts +183 -0
  220. package/dist/utils/styles.js +585 -0
  221. package/dist/utils/styles.js.map +1 -0
  222. package/dist/utils/typography.d.ts +36 -0
  223. package/dist/utils/typography.js +53 -0
  224. package/dist/utils/typography.js.map +1 -0
  225. package/dist/utils/warnings.d.ts +16 -0
  226. package/dist/utils/warnings.js +16 -0
  227. package/dist/utils/warnings.js.map +1 -0
  228. package/dist/zero/babel.d.ts +108 -0
  229. package/dist/zero/babel.js +282 -0
  230. package/dist/zero/babel.js.map +1 -0
  231. package/dist/zero/css-writer.d.ts +45 -0
  232. package/dist/zero/css-writer.js +74 -0
  233. package/dist/zero/css-writer.js.map +1 -0
  234. package/dist/zero/extractor.d.ts +25 -0
  235. package/dist/zero/extractor.js +150 -0
  236. package/dist/zero/extractor.js.map +1 -0
  237. package/dist/zero/index.d.ts +3 -0
  238. package/dist/zero/index.js +4 -0
  239. package/dist/zero/next.d.ts +60 -0
  240. package/dist/zero/next.js +78 -0
  241. package/dist/zero/next.js.map +1 -0
  242. package/package.json +133 -0
@@ -0,0 +1,260 @@
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
+ "styledScrollbar"
135
+ ];
136
+ /**
137
+ * Layout chunk - flex/grid alignment and grid templates
138
+ *
139
+ * Note: flow and gap are in DISPLAY chunk due to handler dependencies
140
+ * (flowStyle and gapStyle both require 'display' prop).
141
+ */
142
+ const LAYOUT_CHUNK_STYLES = [
143
+ "placeItems",
144
+ "placeContent",
145
+ "alignItems",
146
+ "alignContent",
147
+ "justifyItems",
148
+ "justifyContent",
149
+ "align",
150
+ "justify",
151
+ "place",
152
+ "columnGap",
153
+ "rowGap",
154
+ "gridColumns",
155
+ "gridRows",
156
+ "gridTemplate",
157
+ "gridAreas",
158
+ "gridAutoFlow",
159
+ "gridAutoColumns",
160
+ "gridAutoRows"
161
+ ];
162
+ /**
163
+ * Position chunk - element positioning
164
+ *
165
+ * Handler dependencies (all styles in each handler MUST stay in this chunk):
166
+ * ⚠️ insetStyle: inset, insetBlock, insetInline, top, right, bottom, left
167
+ */
168
+ const POSITION_CHUNK_STYLES = [
169
+ "position",
170
+ "inset",
171
+ "insetBlock",
172
+ "insetInline",
173
+ "top",
174
+ "right",
175
+ "bottom",
176
+ "left",
177
+ "zIndex",
178
+ "gridArea",
179
+ "gridColumn",
180
+ "gridRow",
181
+ "order",
182
+ "placeSelf",
183
+ "alignSelf",
184
+ "justifySelf",
185
+ "transform",
186
+ "transition",
187
+ "animation"
188
+ ];
189
+ const CHUNK_NAMES = {
190
+ COMBINED: "combined",
191
+ SUBCOMPONENTS: "subcomponents",
192
+ APPEARANCE: "appearance",
193
+ FONT: "font",
194
+ DIMENSION: "dimension",
195
+ DISPLAY: "display",
196
+ LAYOUT: "layout",
197
+ POSITION: "position",
198
+ MISC: "misc"
199
+ };
200
+ /**
201
+ * Pre-computed map for O(1) style-to-chunk lookup.
202
+ * Built once at module load time.
203
+ */
204
+ const STYLE_TO_CHUNK = /* @__PURE__ */ new Map();
205
+ function populateStyleToChunkMap() {
206
+ for (const style of APPEARANCE_CHUNK_STYLES) STYLE_TO_CHUNK.set(style, CHUNK_NAMES.APPEARANCE);
207
+ for (const style of FONT_CHUNK_STYLES) STYLE_TO_CHUNK.set(style, CHUNK_NAMES.FONT);
208
+ for (const style of DIMENSION_CHUNK_STYLES) STYLE_TO_CHUNK.set(style, CHUNK_NAMES.DIMENSION);
209
+ for (const style of DISPLAY_CHUNK_STYLES) STYLE_TO_CHUNK.set(style, CHUNK_NAMES.DISPLAY);
210
+ for (const style of LAYOUT_CHUNK_STYLES) STYLE_TO_CHUNK.set(style, CHUNK_NAMES.LAYOUT);
211
+ for (const style of POSITION_CHUNK_STYLES) STYLE_TO_CHUNK.set(style, CHUNK_NAMES.POSITION);
212
+ }
213
+ populateStyleToChunkMap();
214
+ /**
215
+ * Chunk processing order. This ensures deterministic className allocation
216
+ * regardless of style key order in the input.
217
+ */
218
+ const CHUNK_ORDER = [
219
+ CHUNK_NAMES.APPEARANCE,
220
+ CHUNK_NAMES.FONT,
221
+ CHUNK_NAMES.DIMENSION,
222
+ CHUNK_NAMES.DISPLAY,
223
+ CHUNK_NAMES.LAYOUT,
224
+ CHUNK_NAMES.POSITION,
225
+ CHUNK_NAMES.MISC,
226
+ CHUNK_NAMES.SUBCOMPONENTS
227
+ ];
228
+ new Map(CHUNK_ORDER.map((name, index) => [name, index]));
229
+ /**
230
+ * Categorize style keys into chunks.
231
+ *
232
+ * Returns chunks in a deterministic order (by CHUNK_ORDER) regardless
233
+ * of the order of keys in the input styles object.
234
+ *
235
+ * @param styles - The styles object to categorize
236
+ * @returns Map of chunk name to array of style keys in that chunk (in priority order)
237
+ */
238
+ function categorizeStyleKeys(styles) {
239
+ const chunkData = {};
240
+ const keys = Object.keys(styles);
241
+ for (const key of keys) {
242
+ if (key === "$" || key === "@keyframes" || key === "@properties" || key === "recipe") continue;
243
+ if (isSelector(key)) {
244
+ if (!chunkData[CHUNK_NAMES.SUBCOMPONENTS]) chunkData[CHUNK_NAMES.SUBCOMPONENTS] = [];
245
+ chunkData[CHUNK_NAMES.SUBCOMPONENTS].push(key);
246
+ } else {
247
+ const chunkName = STYLE_TO_CHUNK.get(key) ?? CHUNK_NAMES.MISC;
248
+ if (!chunkData[chunkName]) chunkData[chunkName] = [];
249
+ chunkData[chunkName].push(key);
250
+ }
251
+ }
252
+ const orderedChunks = /* @__PURE__ */ new Map();
253
+ for (const chunkName of CHUNK_ORDER) if (chunkData[chunkName] && chunkData[chunkName].length > 0) orderedChunks.set(chunkName, chunkData[chunkName].sort());
254
+ for (const chunkName of Object.keys(chunkData)) if (!orderedChunks.has(chunkName)) orderedChunks.set(chunkName, chunkData[chunkName].sort());
255
+ return orderedChunks;
256
+ }
257
+
258
+ //#endregion
259
+ export { CHUNK_NAMES, STYLE_TO_CHUNK, categorizeStyleKeys };
260
+ //# sourceMappingURL=definitions.js.map
@@ -0,0 +1 @@
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 'styledScrollbar', // styledScrollbarStyle (deprecated)\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;CACA;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"}
@@ -0,0 +1,3 @@
1
+ import { CHUNK_NAMES, ChunkInfo, ChunkName, STYLE_TO_CHUNK, categorizeStyleKeys } from "./definitions.js";
2
+ import "./cacheKey.js";
3
+ import "./renderChunk.js";
@@ -0,0 +1,2 @@
1
+ import "../styles/types.js";
2
+ import "../pipeline/index.js";
@@ -0,0 +1,61 @@
1
+ import { extractLocalPredefinedStates } from "../states/index.js";
2
+ import { renderStyles } from "../pipeline/index.js";
3
+ import { CHUNK_NAMES } from "./definitions.js";
4
+
5
+ //#region src/chunks/renderChunk.ts
6
+ /**
7
+ * Render styles for a specific chunk.
8
+ *
9
+ * Creates a filtered styles object containing only the keys for this chunk,
10
+ * then delegates to the existing renderStyles function.
11
+ *
12
+ * IMPORTANT: Local predefined states (e.g., '@mobile': '@media(w < 600px)')
13
+ * are always included in the filtered styles, regardless of which chunk is
14
+ * being rendered. This ensures that state references like '@mobile' in any
15
+ * chunk can be properly resolved by the pipeline.
16
+ *
17
+ * @param styles - The full styles object
18
+ * @param chunkName - Name of the chunk being rendered
19
+ * @param styleKeys - Keys of styles belonging to this chunk
20
+ * @returns RenderResult with rules for this chunk
21
+ */
22
+ function renderStylesForChunk(styles, chunkName, styleKeys) {
23
+ if (styleKeys.length === 0) return {
24
+ rules: [],
25
+ className: ""
26
+ };
27
+ if (chunkName === CHUNK_NAMES.SUBCOMPONENTS) return renderSubcomponentsChunk(styles, styleKeys);
28
+ const localPredefinedStates = extractLocalPredefinedStates(styles);
29
+ const filteredStyles = {};
30
+ for (const [key, value] of Object.entries(localPredefinedStates)) filteredStyles[key] = value;
31
+ for (const key of styleKeys) {
32
+ const value = styles[key];
33
+ if (value !== void 0) filteredStyles[key] = value;
34
+ }
35
+ return renderStyles(filteredStyles);
36
+ }
37
+ /**
38
+ * Render the subcomponents chunk.
39
+ *
40
+ * Subcomponents (selectors like Label, &::before, etc.) contain nested
41
+ * style objects that need to be preserved in their entirety.
42
+ *
43
+ * @param styles - The full styles object
44
+ * @param selectorKeys - Keys of selectors in this chunk
45
+ * @returns RenderResult with rules for all subcomponents
46
+ */
47
+ function renderSubcomponentsChunk(styles, selectorKeys) {
48
+ const localPredefinedStates = extractLocalPredefinedStates(styles);
49
+ const filteredStyles = {};
50
+ for (const [key, value] of Object.entries(localPredefinedStates)) filteredStyles[key] = value;
51
+ for (const key of selectorKeys) {
52
+ const value = styles[key];
53
+ if (value !== void 0) filteredStyles[key] = value;
54
+ }
55
+ if (styles.$ !== void 0) filteredStyles.$ = styles.$;
56
+ return renderStyles(filteredStyles);
57
+ }
58
+
59
+ //#endregion
60
+ export { renderStylesForChunk };
61
+ //# sourceMappingURL=renderChunk.js.map
@@ -0,0 +1 @@
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 { renderStyles } from '../pipeline';\nimport { extractLocalPredefinedStates } from '../states';\nimport type { Styles } from '../styles/types';\n\nimport { CHUNK_NAMES } from './definitions';\n\n/**\n * Render styles for a specific chunk.\n *\n * Creates a filtered styles object containing only the keys for this chunk,\n * then delegates to the existing renderStyles function.\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): RenderResult {\n // Empty chunk - return empty result\n if (styleKeys.length === 0) {\n return { rules: [], className: '' };\n }\n\n // For subcomponents, we need to preserve the nested structure\n if (chunkName === CHUNK_NAMES.SUBCOMPONENTS) {\n return renderSubcomponentsChunk(styles, styleKeys);\n }\n\n // Extract local predefined states from the full styles object\n // These must be included for state resolution to work across chunks\n const localPredefinedStates = extractLocalPredefinedStates(styles);\n\n // For regular chunks, create a filtered styles object\n // This is memory-efficient: we only create a shallow copy with filtered keys\n const filteredStyles: Styles = {};\n\n // First, add local predefined states so they're available for resolution\n for (const [key, value] of Object.entries(localPredefinedStates)) {\n filteredStyles[key] = value;\n }\n\n // Then add the chunk's style keys\n for (const key of styleKeys) {\n const value = styles[key];\n if (value !== undefined) {\n filteredStyles[key] = value;\n }\n }\n\n // Delegate to existing renderStyles\n return renderStyles(filteredStyles);\n}\n\n/**\n * Render the subcomponents chunk.\n *\n * Subcomponents (selectors like Label, &::before, etc.) contain nested\n * style objects that need to be preserved in their entirety.\n *\n * @param styles - The full styles object\n * @param selectorKeys - Keys of selectors in this chunk\n * @returns RenderResult with rules for all subcomponents\n */\nfunction renderSubcomponentsChunk(\n styles: Styles,\n selectorKeys: string[],\n): RenderResult {\n // Extract local predefined states from the full styles object\n // These must be included for state resolution to work in nested styles\n const localPredefinedStates = extractLocalPredefinedStates(styles);\n\n // Create a styles object containing only the selector keys\n const filteredStyles: Styles = {};\n\n // First, add local predefined states so they're available for resolution\n for (const [key, value] of Object.entries(localPredefinedStates)) {\n filteredStyles[key] = value;\n }\n\n // Then add the selector keys\n for (const key of selectorKeys) {\n const value = styles[key];\n if (value !== undefined) {\n filteredStyles[key] = value;\n }\n }\n\n // Also copy the $ helper if present (used for selector combinators)\n if (styles.$ !== undefined) {\n filteredStyles.$ = styles.$;\n }\n\n // Delegate to existing renderStyles\n return renderStyles(filteredStyles);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA8BA,SAAgB,qBACd,QACA,WACA,WACc;AAEd,KAAI,UAAU,WAAW,EACvB,QAAO;EAAE,OAAO,EAAE;EAAE,WAAW;EAAI;AAIrC,KAAI,cAAc,YAAY,cAC5B,QAAO,yBAAyB,QAAQ,UAAU;CAKpD,MAAM,wBAAwB,6BAA6B,OAAO;CAIlE,MAAM,iBAAyB,EAAE;AAGjC,MAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,sBAAsB,CAC9D,gBAAe,OAAO;AAIxB,MAAK,MAAM,OAAO,WAAW;EAC3B,MAAM,QAAQ,OAAO;AACrB,MAAI,UAAU,OACZ,gBAAe,OAAO;;AAK1B,QAAO,aAAa,eAAe;;;;;;;;;;;;AAarC,SAAS,yBACP,QACA,cACc;CAGd,MAAM,wBAAwB,6BAA6B,OAAO;CAGlE,MAAM,iBAAyB,EAAE;AAGjC,MAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,sBAAsB,CAC9D,gBAAe,OAAO;AAIxB,MAAK,MAAM,OAAO,cAAc;EAC9B,MAAM,QAAQ,OAAO;AACrB,MAAI,UAAU,OACZ,gBAAe,OAAO;;AAK1B,KAAI,OAAO,MAAM,OACf,gBAAe,IAAI,OAAO;AAI5B,QAAO,aAAa,eAAe"}
@@ -0,0 +1,280 @@
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 { RecipeStyles } from "./styles/types.js";
5
+ import { StyleInjector } from "./injector/injector.js";
6
+ import { TastyPlugin } from "./plugins/types.js";
7
+
8
+ //#region src/config.d.ts
9
+ /**
10
+ * Configuration options for the Tasty style system
11
+ */
12
+ interface TastyConfig {
13
+ /** CSP nonce for style elements */
14
+ nonce?: string;
15
+ /** Maximum rules per stylesheet (default: 8192) */
16
+ maxRulesPerSheet?: number;
17
+ /** Threshold for bulk cleanup of unused styles (default: 500) */
18
+ unusedStylesThreshold?: number;
19
+ /** Delay before bulk cleanup in ms, ignored if idleCleanup is true (default: 5000) */
20
+ bulkCleanupDelay?: number;
21
+ /** Use requestIdleCallback for cleanup when available (default: true) */
22
+ idleCleanup?: boolean;
23
+ /** Force text injection mode, auto-detected in test environments (default: auto) */
24
+ forceTextInjection?: boolean;
25
+ /** Enable development mode features: performance metrics and debug info (default: auto) */
26
+ devMode?: boolean;
27
+ /**
28
+ * Ratio of unused styles to delete per bulk cleanup run (0..1).
29
+ * Defaults to 0.5 (oldest half) to reduce risk of removing styles
30
+ * that may be restored shortly after being marked unused.
31
+ */
32
+ bulkCleanupBatchRatio?: number;
33
+ /**
34
+ * Minimum age (in ms) a style must remain unused before eligible for deletion.
35
+ * Helps avoid races during rapid mount/unmount cycles. Default: 10000ms.
36
+ */
37
+ unusedStylesMinAgeMs?: number;
38
+ /**
39
+ * Global predefined states for advanced state mapping.
40
+ * These are state aliases that can be used in any component.
41
+ * Example: { '@mobile': '@media(w < 920px)', '@dark': '@root(theme=dark)' }
42
+ */
43
+ states?: Record<string, string>;
44
+ /**
45
+ * Parser LRU cache size (default: 1000).
46
+ * Larger values improve performance for apps with many unique style values.
47
+ */
48
+ parserCacheSize?: number;
49
+ /**
50
+ * Custom units for the style parser (merged with built-in units).
51
+ * Units transform numeric values like `2x` → `calc(2 * var(--gap))`.
52
+ * @example { em: 'em', vw: 'vw', custom: (n) => `${n * 10}px` }
53
+ */
54
+ units?: Record<string, string | UnitHandler>;
55
+ /**
56
+ * Custom functions for the style parser (merged with existing).
57
+ * Functions process parsed style groups and return CSS values.
58
+ * @example { myFunc: (groups) => groups.map(g => g.output).join(' ') }
59
+ */
60
+ funcs?: Record<string, (groups: StyleDetails[]) => string>;
61
+ /**
62
+ * Plugins that extend tasty with custom functions, units, or states.
63
+ * Plugins are processed in order, with later plugins overriding earlier ones.
64
+ * @example
65
+ * ```ts
66
+ * import { okhslPlugin } from '@tenphi/tasty';
67
+ *
68
+ * configure({
69
+ * plugins: [okhslPlugin()],
70
+ * });
71
+ * ```
72
+ */
73
+ plugins?: TastyPlugin[];
74
+ /**
75
+ * Global keyframes definitions that can be referenced by animation names in styles.
76
+ * Keys are animation names, values are keyframes step definitions.
77
+ * Keyframes are only injected when actually used in styles.
78
+ * @example
79
+ * ```ts
80
+ * configure({
81
+ * keyframes: {
82
+ * fadeIn: { from: { opacity: 0 }, to: { opacity: 1 } },
83
+ * pulse: { '0%, 100%': { transform: 'scale(1)' }, '50%': { transform: 'scale(1.05)' } },
84
+ * },
85
+ * });
86
+ * ```
87
+ */
88
+ keyframes?: Record<string, KeyframesSteps>;
89
+ /**
90
+ * Global CSS @property definitions for custom properties.
91
+ * Keys use tasty token syntax ($name for properties, #name for colors).
92
+ * Properties are only injected when the component using them is rendered.
93
+ *
94
+ * For color tokens (#name), `syntax: '<color>'` is auto-set and
95
+ * `initialValue` defaults to `'transparent'` if not specified.
96
+ *
97
+ * @example
98
+ * ```ts
99
+ * configure({
100
+ * properties: {
101
+ * '$rotation': { syntax: '<angle>', initialValue: '0deg' },
102
+ * '$scale': { syntax: '<number>', inherits: false, initialValue: 1 },
103
+ * '#accent': { initialValue: 'purple' }, // syntax: '<color>' auto-set
104
+ * },
105
+ * });
106
+ *
107
+ * // Now use in styles - properties are registered when component renders:
108
+ * const Spinner = tasty({
109
+ * styles: {
110
+ * transform: 'rotate($rotation)',
111
+ * transition: '$$rotation 0.3s', // outputs: --rotation 0.3s
112
+ * },
113
+ * });
114
+ * ```
115
+ */
116
+ properties?: Record<string, PropertyDefinition>;
117
+ /**
118
+ * Custom style handlers that transform style properties into CSS declarations.
119
+ * Handlers replace built-in handlers for the same style name.
120
+ * @example
121
+ * ```ts
122
+ * import { styleHandlers } from '@tenphi/tasty';
123
+ *
124
+ * configure({
125
+ * handlers: {
126
+ * // Override fill with custom behavior
127
+ * fill: ({ fill }) => {
128
+ * if (fill?.startsWith('gradient:')) {
129
+ * return { background: fill.slice(9) };
130
+ * }
131
+ * return styleHandlers.fill({ fill });
132
+ * },
133
+ * // Add new custom style
134
+ * elevation: ({ elevation }) => {
135
+ * const level = parseInt(elevation) || 1;
136
+ * return {
137
+ * 'box-shadow': `0 ${level * 2}px ${level * 4}px rgba(0,0,0,0.1)`,
138
+ * 'z-index': String(level * 100),
139
+ * };
140
+ * },
141
+ * },
142
+ * });
143
+ * ```
144
+ */
145
+ handlers?: Record<string, StyleHandlerDefinition>;
146
+ /**
147
+ * Predefined tokens that are replaced during style parsing.
148
+ * Token values are processed through the parser (like component tokens).
149
+ * Use `$name` for custom properties and `#name` for color tokens.
150
+ *
151
+ * For color tokens (#name), boolean `true` is converted to `transparent`.
152
+ *
153
+ * @example
154
+ * ```ts
155
+ * configure({
156
+ * tokens: {
157
+ * $spacing: '2x',
158
+ * '$card-padding': '4x',
159
+ * '#accent': '#purple',
160
+ * '#surface': '#white',
161
+ * '#overlay': true, // → transparent
162
+ * },
163
+ * });
164
+ *
165
+ * // Now use in styles - tokens are replaced at parse time:
166
+ * const Card = tasty({
167
+ * styles: {
168
+ * padding: '$card-padding', // → calc(4 * var(--gap))
169
+ * fill: '#surface', // → var(--white-color)
170
+ * },
171
+ * });
172
+ * ```
173
+ */
174
+ tokens?: Record<`$${string}`, string | number | boolean> & Record<`#${string}`, string | number | boolean>;
175
+ /**
176
+ * Predefined style recipes -- named style bundles that can be applied via `recipe` style property.
177
+ * Recipe values are flat tasty styles (no sub-element keys). They may contain base styles,
178
+ * tokens (`$name`/`#name` definitions), local states, `@keyframes`, and `@properties`.
179
+ *
180
+ * Components reference recipes via: `recipe: 'name1 name2'` in their styles.
181
+ * Use `/` to separate base recipes from post recipes: `recipe: 'base1 base2 / post1'`.
182
+ * Use `none` to skip base recipes: `recipe: 'none / post1'`.
183
+ * Resolution order: `base_recipes → component styles → post_recipes`.
184
+ *
185
+ * Recipes cannot reference other recipes.
186
+ *
187
+ * @example
188
+ * ```ts
189
+ * configure({
190
+ * recipes: {
191
+ * card: { padding: '4x', fill: '#surface', radius: '1r', border: true },
192
+ * elevated: { shadow: '2x 2x 4x #shadow' },
193
+ * },
194
+ * });
195
+ *
196
+ * // Usage in styles:
197
+ * const Card = tasty({
198
+ * styles: {
199
+ * recipe: 'card elevated',
200
+ * color: '#text', // Overrides recipe values
201
+ * },
202
+ * });
203
+ * ```
204
+ */
205
+ recipes?: Record<string, RecipeStyles>;
206
+ }
207
+ declare const GLOBAL_INJECTOR_KEY = "__TASTY_GLOBAL_INJECTOR__";
208
+ declare global {
209
+ interface Window {
210
+ [GLOBAL_INJECTOR_KEY]?: StyleInjector;
211
+ }
212
+ var __TASTY_GLOBAL_INJECTOR__: StyleInjector | undefined;
213
+ }
214
+ /**
215
+ * Detect if we're running in a test environment
216
+ */
217
+ declare function isTestEnvironment(): boolean;
218
+ /**
219
+ * Check if styles have been generated (configuration is locked)
220
+ */
221
+ declare function hasStylesGenerated(): boolean;
222
+ /**
223
+ * Check if any global keyframes are configured.
224
+ * Fast path: returns false if no keyframes were ever set.
225
+ */
226
+ declare function hasGlobalKeyframes(): boolean;
227
+ /**
228
+ * Get global keyframes configuration.
229
+ * Returns null if no keyframes configured (fast path for zero-overhead).
230
+ */
231
+ declare function getGlobalKeyframes(): Record<string, KeyframesSteps> | null;
232
+ /**
233
+ * Check if any global recipes are configured.
234
+ * Fast path: returns false if no recipes were ever set.
235
+ */
236
+ declare function hasGlobalRecipes(): boolean;
237
+ /**
238
+ * Get global recipes configuration.
239
+ * Returns null if no recipes configured (fast path for zero-overhead).
240
+ */
241
+ declare function getGlobalRecipes(): Record<string, RecipeStyles> | null;
242
+ /**
243
+ * Check if configuration is locked (styles have been generated)
244
+ */
245
+ declare function isConfigLocked(): boolean;
246
+ /**
247
+ * Configure the Tasty style system.
248
+ *
249
+ * Must be called BEFORE any styles are generated (before first render that uses tasty).
250
+ * After styles are generated, configuration is locked and calls to configure() will
251
+ * emit a warning and be ignored.
252
+ *
253
+ * @example
254
+ * ```ts
255
+ * import { configure } from '@tenphi/tasty';
256
+ *
257
+ * // Configure before app renders
258
+ * configure({
259
+ * nonce: 'abc123',
260
+ * states: {
261
+ * '@mobile': '@media(w < 768px)',
262
+ * '@dark': '@root(theme=dark)',
263
+ * },
264
+ * });
265
+ * ```
266
+ */
267
+ declare function configure(config?: Partial<TastyConfig>): void;
268
+ /**
269
+ * Get the current configuration.
270
+ * If not configured, returns default configuration.
271
+ */
272
+ declare function getConfig(): TastyConfig;
273
+ /**
274
+ * Reset configuration (for testing only).
275
+ * Clears the global injector and allows reconfiguration.
276
+ */
277
+ declare function resetConfig(): void;
278
+ //#endregion
279
+ export { TastyConfig, configure, getConfig, getGlobalKeyframes, getGlobalRecipes, hasGlobalKeyframes, hasGlobalRecipes, hasStylesGenerated, isConfigLocked, isTestEnvironment, resetConfig };
280
+ //# sourceMappingURL=config.d.ts.map