@tenphi/tasty 0.0.0-snapshot.bae20d4 → 0.0.0-snapshot.bbd36bd

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 (351) hide show
  1. package/README.md +309 -293
  2. package/dist/astro-CeYENy2x.js +301 -0
  3. package/dist/astro-CeYENy2x.js.map +1 -0
  4. package/dist/{ssr/async-storage.js → async-storage-DKK-wTD4.js} +17 -8
  5. package/dist/async-storage-DKK-wTD4.js.map +1 -0
  6. package/dist/babel-DWCsafYw.d.ts +83 -0
  7. package/dist/collector-B3OsM252.js +327 -0
  8. package/dist/collector-B3OsM252.js.map +1 -0
  9. package/dist/collector-BTVXj2hS.d.ts +163 -0
  10. package/dist/config-B3gPdCqd.js +12421 -0
  11. package/dist/config-B3gPdCqd.js.map +1 -0
  12. package/dist/config-LfIDmVHx.d.ts +1363 -0
  13. package/dist/context-CA8YKeMn.js +24 -0
  14. package/dist/context-CA8YKeMn.js.map +1 -0
  15. package/dist/core/index.d.ts +5 -34
  16. package/dist/core/index.js +6 -27
  17. package/dist/core-DGm0CFHP.js +1732 -0
  18. package/dist/core-DGm0CFHP.js.map +1 -0
  19. package/dist/css-resources-Cyl_axbI.js +149 -0
  20. package/dist/css-resources-Cyl_axbI.js.map +1 -0
  21. package/dist/{zero/extractor.js → css-writer-Bgowobbx.js} +188 -13
  22. package/dist/css-writer-Bgowobbx.js.map +1 -0
  23. package/dist/{ssr/format-global-rules.js → format-global-rules-DklyaXv-.js} +3 -3
  24. package/dist/format-global-rules-DklyaXv-.js.map +1 -0
  25. package/dist/{ssr/format-rules.js → format-rules-XRw9u7d4.js} +41 -7
  26. package/dist/format-rules-XRw9u7d4.js.map +1 -0
  27. package/dist/hydrate-CNOmZprz.js +37 -0
  28. package/dist/hydrate-CNOmZprz.js.map +1 -0
  29. package/dist/index-Bm9ltvdH.d.ts +1933 -0
  30. package/dist/index-BmogEzTo.d.ts +1575 -0
  31. package/dist/index.d.ts +5 -49
  32. package/dist/index.js +921 -33
  33. package/dist/index.js.map +1 -0
  34. package/dist/keyframes-DE-OE76F.js +535 -0
  35. package/dist/keyframes-DE-OE76F.js.map +1 -0
  36. package/dist/{utils/merge-styles.d.ts → merge-styles-BcLl1u_d.d.ts} +3 -3
  37. package/dist/{utils/merge-styles.js → merge-styles-DuoZEsm9.js} +4 -6
  38. package/dist/merge-styles-DuoZEsm9.js.map +1 -0
  39. package/dist/{utils/resolve-recipes.js → resolve-recipes-H9NqOQuP.js} +5 -8
  40. package/dist/resolve-recipes-H9NqOQuP.js.map +1 -0
  41. package/dist/ssr/astro-client.d.ts +1 -0
  42. package/dist/ssr/astro-client.js +19 -0
  43. package/dist/ssr/astro-client.js.map +1 -0
  44. package/dist/ssr/astro-middleware-extract-static.d.ts +11 -0
  45. package/dist/ssr/astro-middleware-extract-static.js +9 -0
  46. package/dist/ssr/astro-middleware-extract-static.js.map +1 -0
  47. package/dist/ssr/astro-middleware-extract.d.ts +11 -0
  48. package/dist/ssr/astro-middleware-extract.js +9 -0
  49. package/dist/ssr/astro-middleware-extract.js.map +1 -0
  50. package/dist/ssr/astro-middleware-static.d.ts +18 -0
  51. package/dist/ssr/astro-middleware-static.js +18 -0
  52. package/dist/ssr/astro-middleware-static.js.map +1 -0
  53. package/dist/ssr/astro-middleware.d.ts +19 -0
  54. package/dist/ssr/astro-middleware.js +19 -0
  55. package/dist/ssr/astro-middleware.js.map +1 -0
  56. package/dist/ssr/astro.d.ts +117 -11
  57. package/dist/ssr/astro.js +2 -65
  58. package/dist/ssr/index.d.ts +37 -5
  59. package/dist/ssr/index.js +7 -9
  60. package/dist/ssr/index.js.map +1 -1
  61. package/dist/ssr/next-config.d.ts +66 -0
  62. package/dist/ssr/next-config.js +115 -0
  63. package/dist/ssr/next-config.js.map +1 -0
  64. package/dist/ssr/next.d.ts +14 -7
  65. package/dist/ssr/next.js +40 -20
  66. package/dist/ssr/next.js.map +1 -1
  67. package/dist/ssr-collector-ref-COs_ioWl.js +29 -0
  68. package/dist/ssr-collector-ref-COs_ioWl.js.map +1 -0
  69. package/dist/static/index.d.ts +91 -5
  70. package/dist/static/index.js +49 -4
  71. package/dist/static/index.js.map +1 -0
  72. package/dist/static/inject.d.ts +5 -0
  73. package/dist/static/inject.js +17 -0
  74. package/dist/static/inject.js.map +1 -0
  75. package/dist/zero/babel.d.ts +2 -155
  76. package/dist/zero/babel.js +183 -51
  77. package/dist/zero/babel.js.map +1 -1
  78. package/dist/zero/index.d.ts +81 -3
  79. package/dist/zero/index.js +2 -4
  80. package/dist/zero/next.d.ts +13 -1
  81. package/dist/zero/next.js +6 -5
  82. package/dist/zero/next.js.map +1 -1
  83. package/docs/README.md +39 -0
  84. package/docs/adoption.md +72 -35
  85. package/docs/ai-agents.md +224 -0
  86. package/docs/comparison.md +88 -53
  87. package/docs/configuration.md +623 -63
  88. package/docs/debug.md +172 -342
  89. package/docs/design-system.md +83 -29
  90. package/docs/dsl.md +614 -133
  91. package/docs/getting-started.md +80 -43
  92. package/docs/injector.md +159 -53
  93. package/docs/methodology.md +178 -31
  94. package/docs/migration-v3.md +285 -0
  95. package/docs/pipeline.md +741 -0
  96. package/docs/plugins.md +353 -0
  97. package/docs/react-api.md +681 -0
  98. package/docs/runtime-benchmarks.md +351 -0
  99. package/docs/ssr.md +356 -128
  100. package/docs/styles.md +103 -32
  101. package/docs/tasty-static.md +227 -65
  102. package/package.json +83 -22
  103. package/tasty.config.ts +6 -0
  104. package/dist/_virtual/_rolldown/runtime.js +0 -8
  105. package/dist/chunks/cacheKey.js +0 -78
  106. package/dist/chunks/cacheKey.js.map +0 -1
  107. package/dist/chunks/definitions.d.ts +0 -37
  108. package/dist/chunks/definitions.js +0 -259
  109. package/dist/chunks/definitions.js.map +0 -1
  110. package/dist/chunks/renderChunk.js +0 -60
  111. package/dist/chunks/renderChunk.js.map +0 -1
  112. package/dist/config.d.ts +0 -323
  113. package/dist/config.js +0 -465
  114. package/dist/config.js.map +0 -1
  115. package/dist/debug.d.ts +0 -204
  116. package/dist/debug.js +0 -733
  117. package/dist/debug.js.map +0 -1
  118. package/dist/hooks/useGlobalStyles.d.ts +0 -30
  119. package/dist/hooks/useGlobalStyles.js +0 -83
  120. package/dist/hooks/useGlobalStyles.js.map +0 -1
  121. package/dist/hooks/useKeyframes.d.ts +0 -56
  122. package/dist/hooks/useKeyframes.js +0 -69
  123. package/dist/hooks/useKeyframes.js.map +0 -1
  124. package/dist/hooks/useProperty.d.ts +0 -79
  125. package/dist/hooks/useProperty.js +0 -114
  126. package/dist/hooks/useProperty.js.map +0 -1
  127. package/dist/hooks/useRawCSS.d.ts +0 -53
  128. package/dist/hooks/useRawCSS.js +0 -40
  129. package/dist/hooks/useRawCSS.js.map +0 -1
  130. package/dist/hooks/useStyles.d.ts +0 -45
  131. package/dist/hooks/useStyles.js +0 -249
  132. package/dist/hooks/useStyles.js.map +0 -1
  133. package/dist/injector/index.d.ts +0 -165
  134. package/dist/injector/index.js +0 -162
  135. package/dist/injector/index.js.map +0 -1
  136. package/dist/injector/injector.d.ts +0 -148
  137. package/dist/injector/injector.js +0 -430
  138. package/dist/injector/injector.js.map +0 -1
  139. package/dist/injector/sheet-manager.d.ts +0 -136
  140. package/dist/injector/sheet-manager.js +0 -729
  141. package/dist/injector/sheet-manager.js.map +0 -1
  142. package/dist/injector/types.d.ts +0 -144
  143. package/dist/keyframes/index.js +0 -206
  144. package/dist/keyframes/index.js.map +0 -1
  145. package/dist/parser/classify.js +0 -320
  146. package/dist/parser/classify.js.map +0 -1
  147. package/dist/parser/const.js +0 -33
  148. package/dist/parser/const.js.map +0 -1
  149. package/dist/parser/lru.js +0 -109
  150. package/dist/parser/lru.js.map +0 -1
  151. package/dist/parser/parser.d.ts +0 -25
  152. package/dist/parser/parser.js +0 -116
  153. package/dist/parser/parser.js.map +0 -1
  154. package/dist/parser/tokenizer.js +0 -69
  155. package/dist/parser/tokenizer.js.map +0 -1
  156. package/dist/parser/types.d.ts +0 -51
  157. package/dist/parser/types.js +0 -46
  158. package/dist/parser/types.js.map +0 -1
  159. package/dist/pipeline/conditions.d.ts +0 -134
  160. package/dist/pipeline/conditions.js +0 -406
  161. package/dist/pipeline/conditions.js.map +0 -1
  162. package/dist/pipeline/exclusive.js +0 -231
  163. package/dist/pipeline/exclusive.js.map +0 -1
  164. package/dist/pipeline/index.d.ts +0 -53
  165. package/dist/pipeline/index.js +0 -670
  166. package/dist/pipeline/index.js.map +0 -1
  167. package/dist/pipeline/materialize.js +0 -1105
  168. package/dist/pipeline/materialize.js.map +0 -1
  169. package/dist/pipeline/parseStateKey.d.ts +0 -15
  170. package/dist/pipeline/parseStateKey.js +0 -447
  171. package/dist/pipeline/parseStateKey.js.map +0 -1
  172. package/dist/pipeline/simplify.js +0 -516
  173. package/dist/pipeline/simplify.js.map +0 -1
  174. package/dist/pipeline/warnings.js +0 -18
  175. package/dist/pipeline/warnings.js.map +0 -1
  176. package/dist/plugins/okhsl-plugin.d.ts +0 -35
  177. package/dist/plugins/okhsl-plugin.js +0 -98
  178. package/dist/plugins/okhsl-plugin.js.map +0 -1
  179. package/dist/plugins/types.d.ts +0 -76
  180. package/dist/properties/index.js +0 -223
  181. package/dist/properties/index.js.map +0 -1
  182. package/dist/properties/property-type-resolver.d.ts +0 -24
  183. package/dist/properties/property-type-resolver.js +0 -91
  184. package/dist/properties/property-type-resolver.js.map +0 -1
  185. package/dist/ssr/astro.js.map +0 -1
  186. package/dist/ssr/async-storage.d.ts +0 -17
  187. package/dist/ssr/async-storage.js.map +0 -1
  188. package/dist/ssr/collect-auto-properties.js +0 -40
  189. package/dist/ssr/collect-auto-properties.js.map +0 -1
  190. package/dist/ssr/collector.d.ts +0 -85
  191. package/dist/ssr/collector.js +0 -183
  192. package/dist/ssr/collector.js.map +0 -1
  193. package/dist/ssr/context.d.ts +0 -8
  194. package/dist/ssr/context.js +0 -14
  195. package/dist/ssr/context.js.map +0 -1
  196. package/dist/ssr/format-global-rules.js.map +0 -1
  197. package/dist/ssr/format-keyframes.js +0 -70
  198. package/dist/ssr/format-keyframes.js.map +0 -1
  199. package/dist/ssr/format-property.js +0 -50
  200. package/dist/ssr/format-property.js.map +0 -1
  201. package/dist/ssr/format-rules.js.map +0 -1
  202. package/dist/ssr/hydrate.d.ts +0 -22
  203. package/dist/ssr/hydrate.js +0 -50
  204. package/dist/ssr/hydrate.js.map +0 -1
  205. package/dist/ssr/ssr-collector-ref.js +0 -12
  206. package/dist/ssr/ssr-collector-ref.js.map +0 -1
  207. package/dist/states/index.d.ts +0 -49
  208. package/dist/states/index.js +0 -169
  209. package/dist/states/index.js.map +0 -1
  210. package/dist/static/tastyStatic.d.ts +0 -46
  211. package/dist/static/tastyStatic.js +0 -31
  212. package/dist/static/tastyStatic.js.map +0 -1
  213. package/dist/static/types.d.ts +0 -49
  214. package/dist/static/types.js +0 -24
  215. package/dist/static/types.js.map +0 -1
  216. package/dist/styles/align.d.ts +0 -15
  217. package/dist/styles/align.js +0 -14
  218. package/dist/styles/align.js.map +0 -1
  219. package/dist/styles/border.d.ts +0 -25
  220. package/dist/styles/border.js +0 -114
  221. package/dist/styles/border.js.map +0 -1
  222. package/dist/styles/color.d.ts +0 -14
  223. package/dist/styles/color.js +0 -27
  224. package/dist/styles/color.js.map +0 -1
  225. package/dist/styles/createStyle.js +0 -80
  226. package/dist/styles/createStyle.js.map +0 -1
  227. package/dist/styles/dimension.js +0 -97
  228. package/dist/styles/dimension.js.map +0 -1
  229. package/dist/styles/display.d.ts +0 -37
  230. package/dist/styles/display.js +0 -67
  231. package/dist/styles/display.js.map +0 -1
  232. package/dist/styles/fade.d.ts +0 -15
  233. package/dist/styles/fade.js +0 -58
  234. package/dist/styles/fade.js.map +0 -1
  235. package/dist/styles/fill.d.ts +0 -42
  236. package/dist/styles/fill.js +0 -52
  237. package/dist/styles/fill.js.map +0 -1
  238. package/dist/styles/flow.d.ts +0 -16
  239. package/dist/styles/flow.js +0 -12
  240. package/dist/styles/flow.js.map +0 -1
  241. package/dist/styles/gap.d.ts +0 -31
  242. package/dist/styles/gap.js +0 -37
  243. package/dist/styles/gap.js.map +0 -1
  244. package/dist/styles/height.d.ts +0 -17
  245. package/dist/styles/height.js +0 -20
  246. package/dist/styles/height.js.map +0 -1
  247. package/dist/styles/index.d.ts +0 -2
  248. package/dist/styles/index.js +0 -9
  249. package/dist/styles/index.js.map +0 -1
  250. package/dist/styles/inset.d.ts +0 -52
  251. package/dist/styles/inset.js +0 -150
  252. package/dist/styles/inset.js.map +0 -1
  253. package/dist/styles/justify.d.ts +0 -15
  254. package/dist/styles/justify.js +0 -14
  255. package/dist/styles/justify.js.map +0 -1
  256. package/dist/styles/list.d.ts +0 -16
  257. package/dist/styles/list.js +0 -98
  258. package/dist/styles/list.js.map +0 -1
  259. package/dist/styles/margin.d.ts +0 -24
  260. package/dist/styles/margin.js +0 -104
  261. package/dist/styles/margin.js.map +0 -1
  262. package/dist/styles/outline.d.ts +0 -29
  263. package/dist/styles/outline.js +0 -65
  264. package/dist/styles/outline.js.map +0 -1
  265. package/dist/styles/padding.d.ts +0 -24
  266. package/dist/styles/padding.js +0 -104
  267. package/dist/styles/padding.js.map +0 -1
  268. package/dist/styles/predefined.d.ts +0 -71
  269. package/dist/styles/predefined.js +0 -238
  270. package/dist/styles/predefined.js.map +0 -1
  271. package/dist/styles/preset.d.ts +0 -47
  272. package/dist/styles/preset.js +0 -126
  273. package/dist/styles/preset.js.map +0 -1
  274. package/dist/styles/radius.d.ts +0 -14
  275. package/dist/styles/radius.js +0 -51
  276. package/dist/styles/radius.js.map +0 -1
  277. package/dist/styles/scrollbar.d.ts +0 -25
  278. package/dist/styles/scrollbar.js +0 -48
  279. package/dist/styles/scrollbar.js.map +0 -1
  280. package/dist/styles/shadow.d.ts +0 -14
  281. package/dist/styles/shadow.js +0 -24
  282. package/dist/styles/shadow.js.map +0 -1
  283. package/dist/styles/transition.d.ts +0 -14
  284. package/dist/styles/transition.js +0 -158
  285. package/dist/styles/transition.js.map +0 -1
  286. package/dist/styles/types.d.ts +0 -508
  287. package/dist/styles/width.d.ts +0 -17
  288. package/dist/styles/width.js +0 -20
  289. package/dist/styles/width.js.map +0 -1
  290. package/dist/tasty.d.ts +0 -981
  291. package/dist/tasty.js +0 -219
  292. package/dist/tasty.js.map +0 -1
  293. package/dist/types.d.ts +0 -184
  294. package/dist/utils/cache-wrapper.js +0 -22
  295. package/dist/utils/cache-wrapper.js.map +0 -1
  296. package/dist/utils/case-converter.js +0 -8
  297. package/dist/utils/case-converter.js.map +0 -1
  298. package/dist/utils/color-math.d.ts +0 -45
  299. package/dist/utils/color-math.js +0 -749
  300. package/dist/utils/color-math.js.map +0 -1
  301. package/dist/utils/color-space.d.ts +0 -5
  302. package/dist/utils/color-space.js +0 -228
  303. package/dist/utils/color-space.js.map +0 -1
  304. package/dist/utils/colors.d.ts +0 -5
  305. package/dist/utils/colors.js +0 -11
  306. package/dist/utils/colors.js.map +0 -1
  307. package/dist/utils/css-types.d.ts +0 -7
  308. package/dist/utils/dotize.d.ts +0 -26
  309. package/dist/utils/dotize.js +0 -122
  310. package/dist/utils/dotize.js.map +0 -1
  311. package/dist/utils/filter-base-props.d.ts +0 -15
  312. package/dist/utils/filter-base-props.js +0 -45
  313. package/dist/utils/filter-base-props.js.map +0 -1
  314. package/dist/utils/get-display-name.d.ts +0 -7
  315. package/dist/utils/get-display-name.js +0 -10
  316. package/dist/utils/get-display-name.js.map +0 -1
  317. package/dist/utils/has-keys.js +0 -13
  318. package/dist/utils/has-keys.js.map +0 -1
  319. package/dist/utils/is-dev-env.js +0 -19
  320. package/dist/utils/is-dev-env.js.map +0 -1
  321. package/dist/utils/is-valid-element-type.js +0 -15
  322. package/dist/utils/is-valid-element-type.js.map +0 -1
  323. package/dist/utils/merge-styles.js.map +0 -1
  324. package/dist/utils/mod-attrs.d.ts +0 -8
  325. package/dist/utils/mod-attrs.js +0 -21
  326. package/dist/utils/mod-attrs.js.map +0 -1
  327. package/dist/utils/process-tokens.d.ts +0 -21
  328. package/dist/utils/process-tokens.js +0 -91
  329. package/dist/utils/process-tokens.js.map +0 -1
  330. package/dist/utils/resolve-recipes.d.ts +0 -17
  331. package/dist/utils/resolve-recipes.js.map +0 -1
  332. package/dist/utils/selector-transform.js +0 -32
  333. package/dist/utils/selector-transform.js.map +0 -1
  334. package/dist/utils/string.js +0 -8
  335. package/dist/utils/string.js.map +0 -1
  336. package/dist/utils/styles.d.ts +0 -101
  337. package/dist/utils/styles.js +0 -223
  338. package/dist/utils/styles.js.map +0 -1
  339. package/dist/utils/typography.d.ts +0 -47
  340. package/dist/utils/typography.js +0 -43
  341. package/dist/utils/typography.js.map +0 -1
  342. package/dist/utils/warnings.d.ts +0 -16
  343. package/dist/utils/warnings.js +0 -16
  344. package/dist/utils/warnings.js.map +0 -1
  345. package/dist/zero/css-writer.d.ts +0 -45
  346. package/dist/zero/css-writer.js +0 -74
  347. package/dist/zero/css-writer.js.map +0 -1
  348. package/dist/zero/extractor.d.ts +0 -24
  349. package/dist/zero/extractor.js.map +0 -1
  350. package/docs/PIPELINE.md +0 -519
  351. package/docs/runtime.md +0 -291
@@ -1,8 +0,0 @@
1
- //#region \0rolldown/runtime.js
2
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { get: (a, b) => (typeof require !== "undefined" ? require : a)[b] }) : x)(function(x) {
3
- if (typeof require !== "undefined") return require.apply(this, arguments);
4
- throw Error("Calling `require` for \"" + x + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
5
- });
6
-
7
- //#endregion
8
- export { __require };
@@ -1,78 +0,0 @@
1
- import { extractLocalPredefinedStates, extractPredefinedStateRefs } from "../states/index.js";
2
-
3
- //#region src/chunks/cacheKey.ts
4
- /**
5
- * Chunk-specific cache key generation.
6
- *
7
- * Generates cache keys that only include styles relevant to a specific chunk,
8
- * enabling more granular caching and reuse.
9
- *
10
- * Enhanced to support predefined states:
11
- * - Global predefined states don't affect cache keys (constant across app)
12
- * - Local predefined states only affect cache keys if referenced in the chunk
13
- */
14
- const _stableStringifyCache = /* @__PURE__ */ new WeakMap();
15
- /**
16
- * Recursively serialize a value with sorted keys for stable output.
17
- * This ensures that {a: 1, b: 2} and {b: 2, a: 1} produce the same string.
18
- * Uses a WeakMap cache for object values to avoid re-serializing the same references.
19
- */
20
- function stableStringify(value) {
21
- if (value === null) return "null";
22
- if (value === void 0) return "undefined";
23
- if (typeof value !== "object") return JSON.stringify(value);
24
- const cached = _stableStringifyCache.get(value);
25
- if (cached !== void 0) return cached;
26
- let result;
27
- if (Array.isArray(value)) result = "[" + value.map(stableStringify).join(",") + "]";
28
- else {
29
- const obj = value;
30
- const sortedKeys = Object.keys(obj).sort();
31
- const parts = [];
32
- for (const key of sortedKeys) if (obj[key] !== void 0) parts.push(`${JSON.stringify(key)}:${stableStringify(obj[key])}`);
33
- result = "{" + parts.join(",") + "}";
34
- }
35
- _stableStringifyCache.set(value, result);
36
- return result;
37
- }
38
- /**
39
- * Generate a cache key for a specific chunk.
40
- *
41
- * Only includes the styles that belong to this chunk, allowing
42
- * chunks to be cached independently.
43
- *
44
- * Also includes relevant local predefined states that are referenced
45
- * by this chunk's styles.
46
- *
47
- * @param styles - The full styles object
48
- * @param chunkName - Name of the chunk
49
- * @param styleKeys - Keys of styles belonging to this chunk
50
- * @returns A stable cache key string
51
- */
52
- function generateChunkCacheKey(styles, chunkName, styleKeys) {
53
- const parts = [chunkName];
54
- let chunkStylesStr = "";
55
- for (const key of styleKeys) {
56
- const value = styles[key];
57
- if (value !== void 0) {
58
- const serialized = stableStringify(value);
59
- parts.push(`${key}:${serialized}`);
60
- chunkStylesStr += serialized;
61
- }
62
- }
63
- const localStates = extractLocalPredefinedStates(styles);
64
- if (Object.keys(localStates).length > 0) {
65
- const referencedStates = extractPredefinedStateRefs(chunkStylesStr);
66
- const relevantLocalStates = [];
67
- for (const stateName of referencedStates) if (localStates[stateName]) relevantLocalStates.push(`${stateName}=${localStates[stateName]}`);
68
- if (relevantLocalStates.length > 0) {
69
- relevantLocalStates.sort();
70
- parts.unshift(`[states:${relevantLocalStates.join("|")}]`);
71
- }
72
- }
73
- return parts.join("\0");
74
- }
75
-
76
- //#endregion
77
- export { generateChunkCacheKey };
78
- //# sourceMappingURL=cacheKey.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cacheKey.js","names":[],"sources":["../../src/chunks/cacheKey.ts"],"sourcesContent":["/**\n * Chunk-specific cache key generation.\n *\n * Generates cache keys that only include styles relevant to a specific chunk,\n * enabling more granular caching and reuse.\n *\n * Enhanced to support predefined states:\n * - Global predefined states don't affect cache keys (constant across app)\n * - Local predefined states only affect cache keys if referenced in the chunk\n */\n\nimport {\n extractLocalPredefinedStates,\n extractPredefinedStateRefs,\n} from '../states';\nimport type { Styles } from '../styles/types';\n\nconst _stableStringifyCache = new WeakMap<object, string>();\n\n/**\n * Recursively serialize a value with sorted keys for stable output.\n * This ensures that {a: 1, b: 2} and {b: 2, a: 1} produce the same string.\n * Uses a WeakMap cache for object values to avoid re-serializing the same references.\n */\nfunction stableStringify(value: unknown): string {\n if (value === null) {\n return 'null';\n }\n if (value === undefined) {\n return 'undefined';\n }\n if (typeof value !== 'object') {\n return JSON.stringify(value);\n }\n\n const cached = _stableStringifyCache.get(value as object);\n if (cached !== undefined) return cached;\n\n let result: string;\n if (Array.isArray(value)) {\n result = '[' + value.map(stableStringify).join(',') + ']';\n } else {\n const obj = value as Record<string, unknown>;\n const sortedKeys = Object.keys(obj).sort();\n const parts: string[] = [];\n for (const key of sortedKeys) {\n if (obj[key] !== undefined) {\n parts.push(`${JSON.stringify(key)}:${stableStringify(obj[key])}`);\n }\n }\n result = '{' + parts.join(',') + '}';\n }\n\n _stableStringifyCache.set(value as object, result);\n return result;\n}\n\n/**\n * Generate a cache key for a specific chunk.\n *\n * Only includes the styles that belong to this chunk, allowing\n * chunks to be cached independently.\n *\n * Also includes relevant local predefined states that are referenced\n * by this chunk's styles.\n *\n * @param styles - The full styles object\n * @param chunkName - Name of the chunk\n * @param styleKeys - Keys of styles belonging to this chunk\n * @returns A stable cache key string\n */\nexport function generateChunkCacheKey(\n styles: Styles,\n chunkName: string,\n styleKeys: string[],\n): string {\n // Start with chunk name for namespace separation\n const parts: string[] = [chunkName];\n\n // styleKeys are already sorted by categorizeStyleKeys\n let chunkStylesStr = '';\n\n for (const key of styleKeys) {\n const value = styles[key];\n if (value !== undefined) {\n // Use stable stringify for consistent serialization regardless of key order\n const serialized = stableStringify(value);\n parts.push(`${key}:${serialized}`);\n chunkStylesStr += serialized;\n }\n }\n\n // Extract local predefined states from the full styles object\n const localStates = extractLocalPredefinedStates(styles);\n\n // Only include local predefined states that are actually referenced in this chunk\n if (Object.keys(localStates).length > 0) {\n const referencedStates = extractPredefinedStateRefs(chunkStylesStr);\n const relevantLocalStates: string[] = [];\n\n for (const stateName of referencedStates) {\n if (localStates[stateName]) {\n relevantLocalStates.push(`${stateName}=${localStates[stateName]}`);\n }\n }\n\n // Add relevant local states to the cache key (sorted for stability)\n if (relevantLocalStates.length > 0) {\n relevantLocalStates.sort();\n parts.unshift(`[states:${relevantLocalStates.join('|')}]`);\n }\n }\n\n // Use null character as separator (safe, not in JSON output)\n return parts.join('\\0');\n}\n"],"mappings":";;;;;;;;;;;;;AAiBA,MAAM,wCAAwB,IAAI,SAAyB;;;;;;AAO3D,SAAS,gBAAgB,OAAwB;AAC/C,KAAI,UAAU,KACZ,QAAO;AAET,KAAI,UAAU,OACZ,QAAO;AAET,KAAI,OAAO,UAAU,SACnB,QAAO,KAAK,UAAU,MAAM;CAG9B,MAAM,SAAS,sBAAsB,IAAI,MAAgB;AACzD,KAAI,WAAW,OAAW,QAAO;CAEjC,IAAI;AACJ,KAAI,MAAM,QAAQ,MAAM,CACtB,UAAS,MAAM,MAAM,IAAI,gBAAgB,CAAC,KAAK,IAAI,GAAG;MACjD;EACL,MAAM,MAAM;EACZ,MAAM,aAAa,OAAO,KAAK,IAAI,CAAC,MAAM;EAC1C,MAAM,QAAkB,EAAE;AAC1B,OAAK,MAAM,OAAO,WAChB,KAAI,IAAI,SAAS,OACf,OAAM,KAAK,GAAG,KAAK,UAAU,IAAI,CAAC,GAAG,gBAAgB,IAAI,KAAK,GAAG;AAGrE,WAAS,MAAM,MAAM,KAAK,IAAI,GAAG;;AAGnC,uBAAsB,IAAI,OAAiB,OAAO;AAClD,QAAO;;;;;;;;;;;;;;;;AAiBT,SAAgB,sBACd,QACA,WACA,WACQ;CAER,MAAM,QAAkB,CAAC,UAAU;CAGnC,IAAI,iBAAiB;AAErB,MAAK,MAAM,OAAO,WAAW;EAC3B,MAAM,QAAQ,OAAO;AACrB,MAAI,UAAU,QAAW;GAEvB,MAAM,aAAa,gBAAgB,MAAM;AACzC,SAAM,KAAK,GAAG,IAAI,GAAG,aAAa;AAClC,qBAAkB;;;CAKtB,MAAM,cAAc,6BAA6B,OAAO;AAGxD,KAAI,OAAO,KAAK,YAAY,CAAC,SAAS,GAAG;EACvC,MAAM,mBAAmB,2BAA2B,eAAe;EACnE,MAAM,sBAAgC,EAAE;AAExC,OAAK,MAAM,aAAa,iBACtB,KAAI,YAAY,WACd,qBAAoB,KAAK,GAAG,UAAU,GAAG,YAAY,aAAa;AAKtE,MAAI,oBAAoB,SAAS,GAAG;AAClC,uBAAoB,MAAM;AAC1B,SAAM,QAAQ,WAAW,oBAAoB,KAAK,IAAI,CAAC,GAAG;;;AAK9D,QAAO,MAAM,KAAK,KAAK"}
@@ -1,37 +0,0 @@
1
- //#region src/chunks/definitions.d.ts
2
- declare const CHUNK_NAMES: {
3
- /** Special chunk for styles that cannot be split (e.g., @starting-style) */readonly COMBINED: "combined";
4
- readonly SUBCOMPONENTS: "subcomponents";
5
- readonly APPEARANCE: "appearance";
6
- readonly FONT: "font";
7
- readonly DIMENSION: "dimension";
8
- readonly DISPLAY: "display";
9
- readonly LAYOUT: "layout";
10
- readonly POSITION: "position";
11
- readonly MISC: "misc";
12
- };
13
- type ChunkName = (typeof CHUNK_NAMES)[keyof typeof CHUNK_NAMES];
14
- /**
15
- * Pre-computed map for O(1) style-to-chunk lookup.
16
- * Built once at module load time.
17
- */
18
- declare const STYLE_TO_CHUNK: Map<string, ChunkName>;
19
- interface ChunkInfo {
20
- /** Name of the chunk */
21
- name: ChunkName | string;
22
- /** Style keys belonging to this chunk */
23
- styleKeys: string[];
24
- }
25
- /**
26
- * Categorize style keys into chunks.
27
- *
28
- * Returns chunks in a deterministic order (by CHUNK_ORDER) regardless
29
- * of the order of keys in the input styles object.
30
- *
31
- * @param styles - The styles object to categorize
32
- * @returns Map of chunk name to array of style keys in that chunk (in priority order)
33
- */
34
- declare function categorizeStyleKeys(styles: Record<string, unknown>): Map<string, string[]>;
35
- //#endregion
36
- export { CHUNK_NAMES, ChunkInfo, ChunkName, STYLE_TO_CHUNK, categorizeStyleKeys };
37
- //# sourceMappingURL=definitions.d.ts.map
@@ -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"}