@tenphi/tasty 0.0.0-snapshot.2dc73be → 0.0.0-snapshot.2ea241d

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 (326) hide show
  1. package/README.md +298 -250
  2. package/dist/{ssr/async-storage.js → async-storage-B7_o6FKt.js} +17 -8
  3. package/dist/async-storage-B7_o6FKt.js.map +1 -0
  4. package/dist/collector-Crs9kGJW.js +243 -0
  5. package/dist/collector-Crs9kGJW.js.map +1 -0
  6. package/dist/{ssr/collector.d.ts → collector-osfWTeRd.d.ts} +38 -15
  7. package/dist/config-BaxtQMS3.js +10464 -0
  8. package/dist/config-BaxtQMS3.js.map +1 -0
  9. package/dist/config-BoZDUHW5.d.ts +945 -0
  10. package/dist/context-CkSg-kDT.js +24 -0
  11. package/dist/context-CkSg-kDT.js.map +1 -0
  12. package/dist/core/index.d.ts +5 -33
  13. package/dist/core/index.js +6 -26
  14. package/dist/core-CmxaoZ-N.js +1598 -0
  15. package/dist/core-CmxaoZ-N.js.map +1 -0
  16. package/dist/{zero/extractor.js → css-writer-CPy_cbFJ.js} +149 -13
  17. package/dist/css-writer-CPy_cbFJ.js.map +1 -0
  18. package/dist/{ssr/format-global-rules.js → format-global-rules-Dbc_1tc3.js} +3 -3
  19. package/dist/format-global-rules-Dbc_1tc3.js.map +1 -0
  20. package/dist/format-rules-CPirO_Mj.js +143 -0
  21. package/dist/format-rules-CPirO_Mj.js.map +1 -0
  22. package/dist/hydrate-CVn-A_3y.js +45 -0
  23. package/dist/hydrate-CVn-A_3y.js.map +1 -0
  24. package/dist/index-B_k47mc_.d.ts +1655 -0
  25. package/dist/index-tcHuMPFt.d.ts +1286 -0
  26. package/dist/index.d.ts +5 -48
  27. package/dist/index.js +731 -32
  28. package/dist/index.js.map +1 -0
  29. package/dist/keyframes-vpzoVdUR.js +588 -0
  30. package/dist/keyframes-vpzoVdUR.js.map +1 -0
  31. package/dist/{utils/merge-styles.d.ts → merge-styles-BMWcH6MF.d.ts} +3 -3
  32. package/dist/{utils/merge-styles.js → merge-styles-BzQutdAK.js} +4 -6
  33. package/dist/merge-styles-BzQutdAK.js.map +1 -0
  34. package/dist/{utils/resolve-recipes.js → resolve-recipes-DgH8A3Nn.js} +5 -8
  35. package/dist/resolve-recipes-DgH8A3Nn.js.map +1 -0
  36. package/dist/ssr/astro-client.d.ts +1 -0
  37. package/dist/ssr/astro-client.js +19 -0
  38. package/dist/ssr/astro-client.js.map +1 -0
  39. package/dist/ssr/astro-middleware.d.ts +15 -0
  40. package/dist/ssr/astro-middleware.js +19 -0
  41. package/dist/ssr/astro-middleware.js.map +1 -0
  42. package/dist/ssr/astro.d.ts +78 -10
  43. package/dist/ssr/astro.js +116 -32
  44. package/dist/ssr/astro.js.map +1 -1
  45. package/dist/ssr/index.d.ts +44 -5
  46. package/dist/ssr/index.js +7 -9
  47. package/dist/ssr/index.js.map +1 -1
  48. package/dist/ssr/next.d.ts +7 -6
  49. package/dist/ssr/next.js +18 -14
  50. package/dist/ssr/next.js.map +1 -1
  51. package/dist/static/index.d.ts +91 -5
  52. package/dist/static/index.js +49 -4
  53. package/dist/static/index.js.map +1 -0
  54. package/dist/static/inject.d.ts +5 -0
  55. package/dist/static/inject.js +17 -0
  56. package/dist/static/inject.js.map +1 -0
  57. package/dist/zero/babel.d.ts +49 -95
  58. package/dist/zero/babel.js +203 -48
  59. package/dist/zero/babel.js.map +1 -1
  60. package/dist/zero/index.d.ts +67 -3
  61. package/dist/zero/index.js +2 -4
  62. package/dist/zero/next.d.ts +28 -1
  63. package/dist/zero/next.js +70 -15
  64. package/dist/zero/next.js.map +1 -1
  65. package/docs/README.md +31 -0
  66. package/docs/adoption.md +298 -0
  67. package/docs/comparison.md +419 -0
  68. package/docs/configuration.md +239 -12
  69. package/docs/debug.md +155 -340
  70. package/docs/design-system.md +436 -0
  71. package/docs/dsl.md +690 -0
  72. package/docs/getting-started.md +217 -0
  73. package/docs/injector.md +45 -29
  74. package/docs/methodology.md +642 -0
  75. package/docs/pipeline.md +699 -0
  76. package/docs/react-api.md +581 -0
  77. package/docs/ssr.md +156 -84
  78. package/docs/styles.md +50 -26
  79. package/docs/tasty-static.md +194 -23
  80. package/package.json +30 -14
  81. package/tasty.config.ts +1 -0
  82. package/dist/_virtual/_rolldown/runtime.js +0 -8
  83. package/dist/chunks/cacheKey.js +0 -70
  84. package/dist/chunks/cacheKey.js.map +0 -1
  85. package/dist/chunks/definitions.d.ts +0 -37
  86. package/dist/chunks/definitions.js +0 -259
  87. package/dist/chunks/definitions.js.map +0 -1
  88. package/dist/chunks/renderChunk.js +0 -61
  89. package/dist/chunks/renderChunk.js.map +0 -1
  90. package/dist/config.d.ts +0 -288
  91. package/dist/config.js +0 -417
  92. package/dist/config.js.map +0 -1
  93. package/dist/debug.d.ts +0 -204
  94. package/dist/debug.js +0 -733
  95. package/dist/debug.js.map +0 -1
  96. package/dist/hooks/useGlobalStyles.d.ts +0 -30
  97. package/dist/hooks/useGlobalStyles.js +0 -83
  98. package/dist/hooks/useGlobalStyles.js.map +0 -1
  99. package/dist/hooks/useKeyframes.d.ts +0 -56
  100. package/dist/hooks/useKeyframes.js +0 -69
  101. package/dist/hooks/useKeyframes.js.map +0 -1
  102. package/dist/hooks/useProperty.d.ts +0 -79
  103. package/dist/hooks/useProperty.js +0 -114
  104. package/dist/hooks/useProperty.js.map +0 -1
  105. package/dist/hooks/useRawCSS.d.ts +0 -53
  106. package/dist/hooks/useRawCSS.js +0 -40
  107. package/dist/hooks/useRawCSS.js.map +0 -1
  108. package/dist/hooks/useStyles.d.ts +0 -45
  109. package/dist/hooks/useStyles.js +0 -248
  110. package/dist/hooks/useStyles.js.map +0 -1
  111. package/dist/injector/index.d.ts +0 -165
  112. package/dist/injector/index.js +0 -162
  113. package/dist/injector/index.js.map +0 -1
  114. package/dist/injector/injector.d.ts +0 -148
  115. package/dist/injector/injector.js +0 -436
  116. package/dist/injector/injector.js.map +0 -1
  117. package/dist/injector/sheet-manager.d.ts +0 -136
  118. package/dist/injector/sheet-manager.js +0 -729
  119. package/dist/injector/sheet-manager.js.map +0 -1
  120. package/dist/injector/types.d.ts +0 -144
  121. package/dist/keyframes/index.js +0 -206
  122. package/dist/keyframes/index.js.map +0 -1
  123. package/dist/parser/classify.js +0 -319
  124. package/dist/parser/classify.js.map +0 -1
  125. package/dist/parser/const.js +0 -33
  126. package/dist/parser/const.js.map +0 -1
  127. package/dist/parser/lru.js +0 -109
  128. package/dist/parser/lru.js.map +0 -1
  129. package/dist/parser/parser.d.ts +0 -25
  130. package/dist/parser/parser.js +0 -116
  131. package/dist/parser/parser.js.map +0 -1
  132. package/dist/parser/tokenizer.js +0 -69
  133. package/dist/parser/tokenizer.js.map +0 -1
  134. package/dist/parser/types.d.ts +0 -51
  135. package/dist/parser/types.js +0 -46
  136. package/dist/parser/types.js.map +0 -1
  137. package/dist/pipeline/conditions.d.ts +0 -134
  138. package/dist/pipeline/conditions.js +0 -406
  139. package/dist/pipeline/conditions.js.map +0 -1
  140. package/dist/pipeline/exclusive.js +0 -231
  141. package/dist/pipeline/exclusive.js.map +0 -1
  142. package/dist/pipeline/index.d.ts +0 -53
  143. package/dist/pipeline/index.js +0 -660
  144. package/dist/pipeline/index.js.map +0 -1
  145. package/dist/pipeline/materialize.js +0 -856
  146. package/dist/pipeline/materialize.js.map +0 -1
  147. package/dist/pipeline/parseStateKey.d.ts +0 -15
  148. package/dist/pipeline/parseStateKey.js +0 -451
  149. package/dist/pipeline/parseStateKey.js.map +0 -1
  150. package/dist/pipeline/simplify.js +0 -516
  151. package/dist/pipeline/simplify.js.map +0 -1
  152. package/dist/pipeline/warnings.js +0 -18
  153. package/dist/pipeline/warnings.js.map +0 -1
  154. package/dist/plugins/okhsl-plugin.d.ts +0 -35
  155. package/dist/plugins/okhsl-plugin.js +0 -371
  156. package/dist/plugins/okhsl-plugin.js.map +0 -1
  157. package/dist/plugins/types.d.ts +0 -69
  158. package/dist/properties/index.js +0 -236
  159. package/dist/properties/index.js.map +0 -1
  160. package/dist/properties/property-type-resolver.d.ts +0 -24
  161. package/dist/properties/property-type-resolver.js +0 -87
  162. package/dist/properties/property-type-resolver.js.map +0 -1
  163. package/dist/ssr/async-storage.d.ts +0 -17
  164. package/dist/ssr/async-storage.js.map +0 -1
  165. package/dist/ssr/collect-auto-properties.js +0 -40
  166. package/dist/ssr/collect-auto-properties.js.map +0 -1
  167. package/dist/ssr/collector.js +0 -173
  168. package/dist/ssr/collector.js.map +0 -1
  169. package/dist/ssr/context.d.ts +0 -8
  170. package/dist/ssr/context.js +0 -14
  171. package/dist/ssr/context.js.map +0 -1
  172. package/dist/ssr/format-global-rules.js.map +0 -1
  173. package/dist/ssr/format-keyframes.js +0 -70
  174. package/dist/ssr/format-keyframes.js.map +0 -1
  175. package/dist/ssr/format-property.js +0 -48
  176. package/dist/ssr/format-property.js.map +0 -1
  177. package/dist/ssr/format-rules.js +0 -70
  178. package/dist/ssr/format-rules.js.map +0 -1
  179. package/dist/ssr/hydrate.d.ts +0 -22
  180. package/dist/ssr/hydrate.js +0 -50
  181. package/dist/ssr/hydrate.js.map +0 -1
  182. package/dist/ssr/ssr-collector-ref.js +0 -12
  183. package/dist/ssr/ssr-collector-ref.js.map +0 -1
  184. package/dist/states/index.d.ts +0 -49
  185. package/dist/states/index.js +0 -416
  186. package/dist/states/index.js.map +0 -1
  187. package/dist/static/tastyStatic.d.ts +0 -46
  188. package/dist/static/tastyStatic.js +0 -31
  189. package/dist/static/tastyStatic.js.map +0 -1
  190. package/dist/static/types.d.ts +0 -49
  191. package/dist/static/types.js +0 -24
  192. package/dist/static/types.js.map +0 -1
  193. package/dist/styles/align.d.ts +0 -15
  194. package/dist/styles/align.js +0 -14
  195. package/dist/styles/align.js.map +0 -1
  196. package/dist/styles/border.d.ts +0 -25
  197. package/dist/styles/border.js +0 -114
  198. package/dist/styles/border.js.map +0 -1
  199. package/dist/styles/color.d.ts +0 -14
  200. package/dist/styles/color.js +0 -23
  201. package/dist/styles/color.js.map +0 -1
  202. package/dist/styles/createStyle.js +0 -77
  203. package/dist/styles/createStyle.js.map +0 -1
  204. package/dist/styles/dimension.js +0 -97
  205. package/dist/styles/dimension.js.map +0 -1
  206. package/dist/styles/display.d.ts +0 -37
  207. package/dist/styles/display.js +0 -67
  208. package/dist/styles/display.js.map +0 -1
  209. package/dist/styles/fade.d.ts +0 -15
  210. package/dist/styles/fade.js +0 -58
  211. package/dist/styles/fade.js.map +0 -1
  212. package/dist/styles/fill.d.ts +0 -42
  213. package/dist/styles/fill.js +0 -52
  214. package/dist/styles/fill.js.map +0 -1
  215. package/dist/styles/flow.d.ts +0 -16
  216. package/dist/styles/flow.js +0 -12
  217. package/dist/styles/flow.js.map +0 -1
  218. package/dist/styles/gap.d.ts +0 -31
  219. package/dist/styles/gap.js +0 -37
  220. package/dist/styles/gap.js.map +0 -1
  221. package/dist/styles/height.d.ts +0 -17
  222. package/dist/styles/height.js +0 -20
  223. package/dist/styles/height.js.map +0 -1
  224. package/dist/styles/index.d.ts +0 -2
  225. package/dist/styles/index.js +0 -9
  226. package/dist/styles/index.js.map +0 -1
  227. package/dist/styles/inset.d.ts +0 -52
  228. package/dist/styles/inset.js +0 -150
  229. package/dist/styles/inset.js.map +0 -1
  230. package/dist/styles/justify.d.ts +0 -15
  231. package/dist/styles/justify.js +0 -14
  232. package/dist/styles/justify.js.map +0 -1
  233. package/dist/styles/list.d.ts +0 -16
  234. package/dist/styles/list.js +0 -98
  235. package/dist/styles/list.js.map +0 -1
  236. package/dist/styles/margin.d.ts +0 -24
  237. package/dist/styles/margin.js +0 -104
  238. package/dist/styles/margin.js.map +0 -1
  239. package/dist/styles/outline.d.ts +0 -29
  240. package/dist/styles/outline.js +0 -65
  241. package/dist/styles/outline.js.map +0 -1
  242. package/dist/styles/padding.d.ts +0 -24
  243. package/dist/styles/padding.js +0 -104
  244. package/dist/styles/padding.js.map +0 -1
  245. package/dist/styles/predefined.d.ts +0 -71
  246. package/dist/styles/predefined.js +0 -238
  247. package/dist/styles/predefined.js.map +0 -1
  248. package/dist/styles/preset.d.ts +0 -47
  249. package/dist/styles/preset.js +0 -126
  250. package/dist/styles/preset.js.map +0 -1
  251. package/dist/styles/radius.d.ts +0 -14
  252. package/dist/styles/radius.js +0 -51
  253. package/dist/styles/radius.js.map +0 -1
  254. package/dist/styles/scrollbar.d.ts +0 -25
  255. package/dist/styles/scrollbar.js +0 -48
  256. package/dist/styles/scrollbar.js.map +0 -1
  257. package/dist/styles/shadow.d.ts +0 -14
  258. package/dist/styles/shadow.js +0 -24
  259. package/dist/styles/shadow.js.map +0 -1
  260. package/dist/styles/transition.d.ts +0 -14
  261. package/dist/styles/transition.js +0 -158
  262. package/dist/styles/transition.js.map +0 -1
  263. package/dist/styles/types.d.ts +0 -495
  264. package/dist/styles/width.d.ts +0 -17
  265. package/dist/styles/width.js +0 -20
  266. package/dist/styles/width.js.map +0 -1
  267. package/dist/tasty.d.ts +0 -981
  268. package/dist/tasty.js +0 -206
  269. package/dist/tasty.js.map +0 -1
  270. package/dist/tokens/typography.d.ts +0 -19
  271. package/dist/tokens/typography.js +0 -237
  272. package/dist/tokens/typography.js.map +0 -1
  273. package/dist/types.d.ts +0 -184
  274. package/dist/utils/cache-wrapper.js +0 -26
  275. package/dist/utils/cache-wrapper.js.map +0 -1
  276. package/dist/utils/case-converter.js +0 -8
  277. package/dist/utils/case-converter.js.map +0 -1
  278. package/dist/utils/colors.d.ts +0 -5
  279. package/dist/utils/colors.js +0 -9
  280. package/dist/utils/colors.js.map +0 -1
  281. package/dist/utils/css-types.d.ts +0 -7
  282. package/dist/utils/dotize.d.ts +0 -26
  283. package/dist/utils/dotize.js +0 -122
  284. package/dist/utils/dotize.js.map +0 -1
  285. package/dist/utils/filter-base-props.d.ts +0 -15
  286. package/dist/utils/filter-base-props.js +0 -45
  287. package/dist/utils/filter-base-props.js.map +0 -1
  288. package/dist/utils/get-display-name.d.ts +0 -7
  289. package/dist/utils/get-display-name.js +0 -10
  290. package/dist/utils/get-display-name.js.map +0 -1
  291. package/dist/utils/hsl-to-rgb.js +0 -38
  292. package/dist/utils/hsl-to-rgb.js.map +0 -1
  293. package/dist/utils/is-dev-env.js +0 -19
  294. package/dist/utils/is-dev-env.js.map +0 -1
  295. package/dist/utils/is-valid-element-type.js +0 -15
  296. package/dist/utils/is-valid-element-type.js.map +0 -1
  297. package/dist/utils/merge-styles.js.map +0 -1
  298. package/dist/utils/mod-attrs.d.ts +0 -8
  299. package/dist/utils/mod-attrs.js +0 -21
  300. package/dist/utils/mod-attrs.js.map +0 -1
  301. package/dist/utils/okhsl-to-rgb.js +0 -296
  302. package/dist/utils/okhsl-to-rgb.js.map +0 -1
  303. package/dist/utils/process-tokens.d.ts +0 -31
  304. package/dist/utils/process-tokens.js +0 -171
  305. package/dist/utils/process-tokens.js.map +0 -1
  306. package/dist/utils/resolve-recipes.d.ts +0 -17
  307. package/dist/utils/resolve-recipes.js.map +0 -1
  308. package/dist/utils/selector-transform.js +0 -32
  309. package/dist/utils/selector-transform.js.map +0 -1
  310. package/dist/utils/string.js +0 -8
  311. package/dist/utils/string.js.map +0 -1
  312. package/dist/utils/styles.d.ts +0 -177
  313. package/dist/utils/styles.js +0 -730
  314. package/dist/utils/styles.js.map +0 -1
  315. package/dist/utils/typography.d.ts +0 -36
  316. package/dist/utils/typography.js +0 -53
  317. package/dist/utils/typography.js.map +0 -1
  318. package/dist/utils/warnings.d.ts +0 -16
  319. package/dist/utils/warnings.js +0 -16
  320. package/dist/utils/warnings.js.map +0 -1
  321. package/dist/zero/css-writer.d.ts +0 -45
  322. package/dist/zero/css-writer.js +0 -74
  323. package/dist/zero/css-writer.js.map +0 -1
  324. package/dist/zero/extractor.d.ts +0 -24
  325. package/dist/zero/extractor.js.map +0 -1
  326. package/docs/usage.md +0 -695
package/docs/debug.md CHANGED
@@ -6,11 +6,13 @@ Runtime CSS inspection and diagnostics for the Tasty styling system. Inspect inj
6
6
 
7
7
  ## Overview
8
8
 
9
- `tastyDebug` is a diagnostic object that exposes every aspect of Tasty's runtime CSS state. It is designed for development use: inspecting which CSS is active, what's cached, how chunks are distributed, and whether cleanup is working as expected.
9
+ `tastyDebug` is a diagnostic object that exposes Tasty's runtime CSS state. It is designed for development use but can be manually installed in production for debugging.
10
10
 
11
- In development mode (`isDevEnv()` returns `true`), `tastyDebug` is automatically installed on `window.tastyDebug`. In production, you can install it manually when needed.
11
+ In development mode (`isDevEnv()` returns `true`), `tastyDebug` is automatically installed on `window.tastyDebug`. In production, install it manually when needed.
12
12
 
13
- > **Note:** This is a development/debugging tool. It does not affect style generation or application behavior.
13
+ All methods **log to the console by default**. Pass `{ raw: true }` to suppress logging and only return data.
14
+
15
+ > **Note (2.0.0+):** Class names use a content-addressed base36 hash format (e.g. `t3a5f`) instead of the previous sequential `t{number}` format. Cross-environment hydration reads the rendered class list from `window.__TASTY__` (the legacy `window.__TASTY_SSR_CACHE__` global was removed in 2.0.0).
14
16
 
15
17
  ---
16
18
 
@@ -24,96 +26,82 @@ tastyDebug.install();
24
26
  // Print a quick-start guide
25
27
  tastyDebug.help();
26
28
 
27
- // Get a comprehensive overview logged to the console
28
- tastyDebug.summary({ log: true });
29
+ // Get a comprehensive overview (logged automatically)
30
+ tastyDebug.summary();
29
31
 
30
- // See all active CSS (for components currently in the DOM)
31
- tastyDebug.log('active');
32
+ // See all active CSS
33
+ tastyDebug.css('active');
32
34
 
33
35
  // Inspect a specific element
34
36
  tastyDebug.inspect('.my-button');
35
37
 
36
- // Check cache hit rates
37
- tastyDebug.metrics();
38
+ // Silent mode — return data only, no console output
39
+ const data = tastyDebug.summary({ raw: true });
38
40
  ```
39
41
 
40
42
  ---
41
43
 
42
- ## Core Types
43
-
44
- ### `CSSTarget`
45
-
46
- The `target` parameter accepted by `css()`, `log()`, and related methods:
47
-
48
- ```typescript
49
- type CSSTarget =
50
- | 'all' // All tasty CSS (component + global + raw)
51
- | 'global' // Only global CSS (from injectGlobal)
52
- | 'active' // CSS for classes currently present in the DOM
53
- | 'unused' // CSS with refCount = 0 (cached but not actively used)
54
- | 'page' // ALL CSS on the page, including non-tasty stylesheets
55
- | string // A tasty class ('t123') or a CSS selector ('.my-class')
56
- | string[] // Array of tasty classes (['t0', 't5', 't12'])
57
- | Element; // A DOM element
58
- ```
59
-
60
- ### `CssOptions`
44
+ ## Options
61
45
 
62
- Common options for CSS retrieval methods:
46
+ All methods accept a shared options object:
63
47
 
64
48
  ```typescript
65
- interface CssOptions {
66
- root?: Document | ShadowRoot; // Target root (default: document)
67
- prettify?: boolean; // Format CSS output (default: true)
68
- log?: boolean; // Auto-log to console (default: false)
49
+ interface DebugOptions {
50
+ root?: Document | ShadowRoot; // Target root (default: document)
51
+ raw?: boolean; // Suppress console logging (default: false)
69
52
  }
70
53
  ```
71
54
 
55
+ When `raw` is `false` (the default), results are logged to the console **and** returned. When `raw` is `true`, results are returned silently.
56
+
72
57
  ---
73
58
 
74
59
  ## API Reference
75
60
 
76
61
  ### `css(target, opts?): string`
77
62
 
78
- Retrieves CSS text for a given target. This is the primary method for extracting CSS from the runtime.
63
+ Retrieves CSS text for a given target. Logs the result with rule count and size.
79
64
 
80
- ```typescript
81
- // All tasty CSS
82
- tastyDebug.css('all');
65
+ **Targets:**
83
66
 
84
- // Only CSS for classes currently in the DOM
85
- tastyDebug.css('active');
86
-
87
- // CSS for unused classes (refCount = 0, still in cache)
88
- tastyDebug.css('unused');
89
-
90
- // Only global CSS (injected via injectGlobal)
91
- tastyDebug.css('global');
67
+ | Target | Description |
68
+ |---|---|
69
+ | `'all'` | All tasty CSS (component + global + raw) |
70
+ | `'active'` | CSS for classes currently in the DOM |
71
+ | `'unused'` | CSS with refCount = 0 (cached but not used) |
72
+ | `'global'` | Only global CSS (from `injectGlobal`) |
73
+ | `'page'` | All CSS on the page (including non-tasty) |
74
+ | `'t3a5f'` | CSS for a specific tasty class (class names are `t` + base36 hash) |
75
+ | `['t3a5f', 't9k2']` | CSS for multiple tasty classes |
76
+ | `'.my-button'` | CSS affecting a DOM element (by selector) |
77
+ | `element` | CSS affecting a DOM element (by reference) |
92
78
 
93
- // ALL CSS on the page (including non-tasty stylesheets)
94
- tastyDebug.css('page');
79
+ **Extra options:**
95
80
 
96
- // CSS for a specific tasty class
97
- tastyDebug.css('t42');
98
-
99
- // CSS for multiple tasty classes
100
- tastyDebug.css(['t0', 't5', 't12']);
81
+ ```typescript
82
+ interface CssOptions extends DebugOptions {
83
+ prettify?: boolean; // Format output (default: true)
84
+ source?: boolean; // Read original CSS instead of live CSSOM (default: false, dev-mode only)
85
+ }
86
+ ```
101
87
 
102
- // CSS affecting a DOM element (by selector)
103
- tastyDebug.css('.my-button');
88
+ ```typescript
89
+ // Active CSS with stats
90
+ tastyDebug.css('active');
104
91
 
105
- // CSS affecting a DOM element (by reference)
106
- const el = document.querySelector('.my-button');
107
- tastyDebug.css(el);
92
+ // Specific class, silent
93
+ const css = tastyDebug.css('t3a5f', { raw: true });
108
94
 
109
- // With options
110
- tastyDebug.css('active', { prettify: false, log: true });
95
+ // Compare original vs browser-parsed CSS (dev mode only)
96
+ tastyDebug.css('t3a5f'); // live CSSOM
97
+ tastyDebug.css('t3a5f', { source: true }); // original output
111
98
 
112
99
  // Shadow DOM
113
- const shadowRoot = host.shadowRoot;
114
100
  tastyDebug.css('all', { root: shadowRoot });
115
101
  ```
116
102
 
103
+ The `source` option reads from `RuleInfo.cssText`, which is only populated when `devMode` is active (development environment or `localStorage.TASTY_DEBUG = 'true'`). In production without debug mode, it falls back to the live CSSOM with a warning.
104
+
117
105
  ---
118
106
 
119
107
  ### `inspect(target, opts?): InspectResult`
@@ -123,309 +111,175 @@ Inspects a DOM element and returns detailed information about its tasty styles,
123
111
  ```typescript
124
112
  interface InspectResult {
125
113
  element?: Element | null;
126
- classes: string[]; // Tasty classes found on the element (e.g., ['t0', 't5'])
114
+ classes: string[]; // Tasty classes on the element
127
115
  chunks: ChunkInfo[]; // Chunk assignment per class
128
- css: string; // Prettified CSS affecting the element
116
+ css: string; // Prettified CSS
129
117
  size: number; // CSS size in characters
130
118
  rules: number; // Number of CSS rule blocks
131
119
  }
132
120
 
133
121
  interface ChunkInfo {
134
- className: string; // e.g., 't0'
122
+ className: string;
135
123
  chunkName: string | null; // e.g., 'appearance', 'font', 'dimension'
136
124
  }
137
125
  ```
138
126
 
139
127
  ```typescript
140
- // By CSS selector
141
- const result = tastyDebug.inspect('.my-card');
142
- console.log(result.classes); // ['t3', 't7', 't12']
143
- console.log(result.chunks); // [{className: 't3', chunkName: 'appearance'}, ...]
144
- console.log(result.rules); // 5
145
- console.log(result.css); // prettified CSS
146
-
147
- // By element reference
148
- const el = document.querySelector('[data-element="Title"]');
149
- tastyDebug.inspect(el);
150
-
151
- // Shadow DOM
152
- tastyDebug.inspect('.shadow-component', { root: shadowRoot });
153
- ```
154
-
155
- ---
156
-
157
- ### `cache(opts?): CacheStatus`
158
-
159
- Returns the current state of the style cache: which classes are active, which are unused, and performance metrics.
160
-
161
- ```typescript
162
- interface CacheStatus {
163
- classes: {
164
- active: string[]; // Classes with refCount > 0 and present in DOM
165
- unused: string[]; // Classes with refCount = 0 but still in cache
166
- all: string[]; // Union of active and unused
167
- };
168
- metrics: CacheMetrics | null;
169
- }
170
- ```
171
-
172
- ```typescript
173
- const status = tastyDebug.cache();
174
-
175
- console.log(status.classes.active.length); // 42
176
- console.log(status.classes.unused.length); // 8
177
- console.log(status.metrics?.hits); // 156
178
- ```
179
-
180
- ---
181
-
182
- ### `cleanup(opts?): void`
128
+ tastyDebug.inspect('.my-card');
129
+ // Logs: inspect div — 3 classes, 5 rules, 1.2KB
130
+ // Chunks: t3a5f→appearance, t9k2→font, tb71→dimension
183
131
 
184
- Forces immediate cleanup of all unused styles (those with `refCount = 0`).
185
-
186
- ```typescript
187
- tastyDebug.cleanup();
188
-
189
- // Shadow DOM
190
- tastyDebug.cleanup({ root: shadowRoot });
132
+ // Silent
133
+ const result = tastyDebug.inspect('.my-card', { raw: true });
134
+ console.log(result.classes); // ['t3a5f', 't9k2', 'tb71']
135
+ console.log(result.rules); // 5
191
136
  ```
192
137
 
193
138
  ---
194
139
 
195
- ### `metrics(opts?): CacheMetrics | null`
196
-
197
- Returns performance metrics for the style cache. Only available when `devMode` is enabled.
140
+ ### `summary(opts?): Summary`
198
141
 
199
- ```typescript
200
- interface CacheMetrics {
201
- hits: number; // Successful cache hits
202
- misses: number; // New styles injected (cache misses)
203
- bulkCleanups: number; // Number of bulk cleanup operations
204
- totalInsertions: number; // Lifetime style insertions
205
- totalUnused: number; // Total styles marked as unused
206
- stylesCleanedUp: number; // Total styles removed by cleanup
207
- startTime: number; // Metrics collection start timestamp
208
- unusedHits?: number; // Reactivations of cached unused styles
209
- cleanupHistory: {
210
- timestamp: number;
211
- classesDeleted: number;
212
- cssSize: number;
213
- rulesDeleted: number;
214
- }[];
215
- }
216
- ```
142
+ One-shot overview of the entire Tasty CSS state. Logs a compact report.
217
143
 
218
144
  ```typescript
219
- const m = tastyDebug.metrics();
145
+ interface Summary {
146
+ activeClasses: string[];
147
+ unusedClasses: string[];
148
+ totalStyledClasses: string[];
149
+
150
+ activeCSSSize: number;
151
+ unusedCSSSize: number;
152
+ globalCSSSize: number;
153
+ rawCSSSize: number;
154
+ keyframesCSSSize: number;
155
+ propertyCSSSize: number;
156
+ totalCSSSize: number;
157
+
158
+ activeRuleCount: number;
159
+ unusedRuleCount: number;
160
+ globalRuleCount: number;
161
+ rawRuleCount: number;
162
+ keyframesRuleCount: number;
163
+ propertyRuleCount: number;
164
+ totalRuleCount: number;
220
165
 
221
- if (m) {
222
- const hitRate = ((m.hits + (m.unusedHits || 0)) / (m.hits + m.misses)) * 100;
223
- console.log(`Cache hit rate: ${hitRate.toFixed(1)}%`);
224
- console.log(`Total insertions: ${m.totalInsertions}`);
225
- console.log(`Bulk cleanups: ${m.bulkCleanups}`);
166
+ metrics: CacheMetrics | null;
167
+ definedProperties: string[];
168
+ definedKeyframes: { name: string; refCount: number }[];
169
+ chunkBreakdown: ChunkBreakdown;
226
170
  }
227
171
  ```
228
172
 
229
- ### `resetMetrics(opts?): void`
230
-
231
- Resets all performance metrics counters.
232
-
233
173
  ```typescript
234
- tastyDebug.resetMetrics();
174
+ // Logged automatically
175
+ tastyDebug.summary();
176
+ // Output:
177
+ // Active: 42 classes, 186 rules, 12.4KB
178
+ // Unused: 3 classes, 8 rules, 0.5KB
179
+ // Global: 12 rules, 1.1KB
180
+ // Total: 45 classes, 206 rules, 14.0KB
181
+ // Cache: 94.2% hit rate (312 lookups)
182
+
183
+ // Silent
184
+ const s = tastyDebug.summary({ raw: true });
185
+ console.log(s.totalRuleCount); // 206
235
186
  ```
236
187
 
237
188
  ---
238
189
 
239
190
  ### `chunks(opts?): ChunkBreakdown`
240
191
 
241
- Returns a breakdown of styles by chunk type. With style chunking enabled, styles are split into logical chunks (appearance, font, dimension, etc.) for better caching and CSS reuse.
192
+ Breakdown of styles by chunk type.
242
193
 
243
194
  ```typescript
244
- const breakdown = tastyDebug.chunks();
245
-
246
- console.log(breakdown.totalChunkTypes); // 6
247
- console.log(breakdown.totalClasses); // 87
248
-
249
- for (const [chunkName, data] of Object.entries(breakdown.byChunk)) {
250
- console.log(`${chunkName}: ${data.classes.length} classes, ${data.cssSize}B`);
195
+ interface ChunkBreakdown {
196
+ byChunk: Record<string, {
197
+ classes: string[];
198
+ cssSize: number;
199
+ ruleCount: number;
200
+ }>;
201
+ totalChunkTypes: number;
202
+ totalClasses: number;
251
203
  }
252
-
253
- // Log a formatted breakdown to the console
254
- tastyDebug.chunks({ log: true });
255
- ```
256
-
257
- Chunk types: `combined` (non-chunked), `appearance`, `font`, `dimension`, `display`, `layout`, `position`, `misc`, `subcomponents`.
258
-
259
- ---
260
-
261
- ### `getGlobalTypeCSS(type, opts?): { css: string; ruleCount: number; size: number }`
262
-
263
- Retrieves CSS for a specific global injection type.
264
-
265
- ```typescript
266
- // CSS injected via injectGlobal()
267
- const global = tastyDebug.getGlobalTypeCSS('global');
268
-
269
- // CSS injected via injectRawCSS() / useRawCSS()
270
- const raw = tastyDebug.getGlobalTypeCSS('raw');
271
-
272
- // @keyframes CSS
273
- const keyframes = tastyDebug.getGlobalTypeCSS('keyframes');
274
-
275
- // @property CSS
276
- const properties = tastyDebug.getGlobalTypeCSS('property');
277
-
278
- console.log(`Global: ${global.ruleCount} rules, ${global.size}B`);
279
- console.log(`Raw: ${raw.ruleCount} rules, ${raw.size}B`);
280
- console.log(`Keyframes: ${keyframes.ruleCount} rules, ${keyframes.size}B`);
281
- console.log(`Properties: ${properties.ruleCount} rules, ${properties.size}B`);
282
204
  ```
283
205
 
284
- ---
285
-
286
- ### `defs(opts?): Definitions`
287
-
288
- Returns all defined `@property` and `@keyframes` entries.
289
-
290
206
  ```typescript
291
- interface Definitions {
292
- properties: string[]; // Defined via @property (e.g., ['--primary-color', '--gap'])
293
- keyframes: { name: string; refCount: number }[];
294
- }
207
+ tastyDebug.chunks();
208
+ // Output:
209
+ // appearance: 24 cls, 48 rules, 3.2KB
210
+ // font: 18 cls, 18 rules, 1.1KB
211
+ // dimension: 31 cls, 45 rules, 2.4KB
295
212
  ```
296
213
 
297
- ```typescript
298
- const defs = tastyDebug.defs();
299
-
300
- console.log('Properties:', defs.properties);
301
- // ['--primary-color', '--surface-color', ...]
302
-
303
- console.log('Keyframes:', defs.keyframes);
304
- // [{ name: 'fadeIn', refCount: 2 }, { name: 'pulse', refCount: 1 }]
305
- ```
214
+ Chunk types: `combined`, `appearance`, `font`, `dimension`, `display`, `layout`, `position`, `misc`, `subcomponents`.
306
215
 
307
216
  ---
308
217
 
309
- ### `summary(opts?): Summary`
218
+ ### `cache(opts?): CacheStatus`
310
219
 
311
- One-shot comprehensive overview of the entire Tasty CSS state. Returns detailed statistics and optionally logs a formatted report.
220
+ Cache state and performance metrics.
312
221
 
313
222
  ```typescript
314
- interface SummaryOptions {
315
- root?: Document | ShadowRoot;
316
- log?: boolean;
317
- includePageCSS?:
318
- | false // Do not include page-level CSS stats (default)
319
- | true // Include sizes/counts only
320
- | 'all'; // Include stats and return full page CSS string
223
+ interface CacheStatus {
224
+ classes: {
225
+ active: string[];
226
+ unused: string[];
227
+ all: string[];
228
+ };
229
+ metrics: CacheMetrics | null;
321
230
  }
322
231
  ```
323
232
 
324
- The returned `Summary` object contains:
325
-
326
- - **Classes**: `activeClasses`, `unusedClasses`, `totalStyledClasses`
327
- - **CSS sizes**: `activeCSSSize`, `unusedCSSSize`, `globalCSSSize`, `rawCSSSize`, `keyframesCSSSize`, `propertyCSSSize`, `totalCSSSize`
328
- - **CSS payloads**: `activeCSS`, `unusedCSS`, `globalCSS`, `rawCSS`, `keyframesCSS`, `propertyCSS`, `allCSS`
329
- - **Rule counts**: `globalRuleCount`, `rawRuleCount`, `keyframesRuleCount`, `propertyRuleCount`
330
- - **Page CSS** (when `includePageCSS` is set): `page.cssSize`, `page.ruleCount`, `page.stylesheetCount`, `page.skippedStylesheets`
331
- - **Metrics & definitions**: `metrics`, `definedProperties`, `definedKeyframes`, `propertyCount`, `keyframeCount`
332
- - **Cleanup summary**: `cleanupSummary.totalCleanups`, `cleanupSummary.totalClassesDeleted`, `cleanupSummary.lastCleanup`, etc.
333
- - **Chunk breakdown**: `chunkBreakdown.byChunk`, `chunkBreakdown.totalChunkTypes`
334
-
335
233
  ```typescript
336
- // Log a formatted report
337
- tastyDebug.summary({ log: true });
338
-
339
- // Get the data programmatically
340
- const s = tastyDebug.summary();
341
- console.log(`Active: ${s.activeClasses.length} classes, ${s.activeCSSSize}B`);
342
- console.log(`Unused: ${s.unusedClasses.length} classes, ${s.unusedCSSSize}B`);
343
- console.log(`Total CSS: ${s.totalCSSSize}B`);
344
-
345
- // Include page-level CSS stats
346
- const withPage = tastyDebug.summary({ includePageCSS: true });
347
- console.log(`Page CSS: ${withPage.page?.cssSize}B across ${withPage.page?.stylesheetCount} stylesheets`);
234
+ tastyDebug.cache();
235
+ // Output:
236
+ // Active: 42, Unused: 3
237
+ // Hits: 294, Misses: 18, Rate: 94.2%
348
238
  ```
349
239
 
350
240
  ---
351
241
 
352
- ### `pageCSS(opts?): string`
353
-
354
- Returns all CSS on the page across all stylesheets (not only tasty-generated CSS).
355
-
356
- ```typescript
357
- // Get all page CSS
358
- const css = tastyDebug.pageCSS();
359
-
360
- // Log it
361
- tastyDebug.pageCSS({ log: true });
362
-
363
- // Raw (unformatted)
364
- tastyDebug.pageCSS({ prettify: false });
365
-
366
- // Exclude cross-origin stylesheet placeholders
367
- tastyDebug.pageCSS({ includeCrossOrigin: false });
368
- ```
369
-
370
- ### `pageStats(opts?): PageStats`
242
+ ### `cleanup(opts?): void`
371
243
 
372
- Returns size and rule count statistics for all page CSS without extracting the full text.
244
+ Forces immediate cleanup of all unused styles (those with `refCount = 0`).
373
245
 
374
246
  ```typescript
375
- const stats = tastyDebug.pageStats();
376
- console.log(`${stats.cssSize}B across ${stats.stylesheetCount} stylesheets`);
377
- console.log(`${stats.ruleCount} rules, ${stats.skippedStylesheets} skipped (CORS)`);
247
+ tastyDebug.cleanup();
248
+ tastyDebug.cleanup({ root: shadowRoot });
378
249
  ```
379
250
 
380
251
  ---
381
252
 
382
- ### `log(target, opts?): void`
253
+ ### `help(): void`
383
254
 
384
- Logs CSS for a target to the console with formatted output, collapsible groups, and sub-element detection.
255
+ Prints a quick-start guide to the console.
385
256
 
386
257
  ```typescript
387
- // Log active CSS with stats header
388
- tastyDebug.log('active');
389
-
390
- // Log CSS for a specific class
391
- tastyDebug.log('t42');
392
-
393
- // Log with custom title
394
- tastyDebug.log('active', { title: 'Button styles' });
395
-
396
- // Log CSS for an element
397
- tastyDebug.log('.my-card');
258
+ tastyDebug.help();
398
259
  ```
399
260
 
400
- The output includes:
401
- - Rule count, line count, and byte size
402
- - Sub-element breakdown (detects `[data-element="..."]` selectors)
403
- - Full CSS in a collapsible group
404
-
405
261
  ---
406
262
 
407
- ### `help(): void`
263
+ ### `install(): void`
408
264
 
409
- Prints a quick-start guide to the console with available commands and common targets.
265
+ Attaches `tastyDebug` to `window.tastyDebug`. Called automatically in development mode.
410
266
 
411
267
  ```typescript
412
- tastyDebug.help();
268
+ import { tastyDebug } from '@tenphi/tasty';
269
+ tastyDebug.install();
413
270
  ```
414
271
 
415
272
  ---
416
273
 
417
- ### `install(): void`
274
+ ## Shadow DOM Support
418
275
 
419
- Attaches `tastyDebug` to `window.tastyDebug` for console access. Called automatically in development mode.
276
+ All methods accept a `root` option to target a Shadow DOM:
420
277
 
421
278
  ```typescript
422
- import { tastyDebug } from '@tenphi/tasty';
423
-
424
- // Manual install (e.g., in staging/production for debugging)
425
- tastyDebug.install();
426
-
427
- // Then use from the browser console:
428
- // > tastyDebug.summary({ log: true })
279
+ const shadowRoot = host.shadowRoot;
280
+ tastyDebug.css('all', { root: shadowRoot });
281
+ tastyDebug.inspect('.shadow-component', { root: shadowRoot });
282
+ tastyDebug.summary({ root: shadowRoot });
429
283
  ```
430
284
 
431
285
  ---
@@ -435,71 +289,32 @@ tastyDebug.install();
435
289
  ### Debugging a component's styles
436
290
 
437
291
  ```typescript
438
- // 1. Find the element
292
+ // 1. Inspect the element
439
293
  tastyDebug.inspect('.my-button');
440
- // → { classes: ['t3', 't7'], chunks: [...], css: '...', rules: 4 }
441
294
 
442
295
  // 2. See CSS for a specific class
443
- tastyDebug.log('t3');
296
+ tastyDebug.css('t3a5f');
444
297
 
445
- // 3. Check which chunk it belongs to
446
- tastyDebug.inspect('.my-button').chunks;
447
- // → [{ className: 't3', chunkName: 'appearance' }, { className: 't7', chunkName: 'font' }]
298
+ // 3. Compare original vs browser-parsed (dev mode)
299
+ tastyDebug.css('t3a5f', { source: true });
448
300
  ```
449
301
 
450
302
  ### Checking cache efficiency
451
303
 
452
304
  ```typescript
453
- const m = tastyDebug.metrics();
454
- const hitRate = m ? ((m.hits + (m.unusedHits || 0)) / (m.hits + m.misses)) * 100 : 0;
455
- console.log(`Hit rate: ${hitRate.toFixed(1)}%`);
456
- console.log(`Unused style reactivations: ${m?.unusedHits}`);
305
+ const { metrics } = tastyDebug.cache({ raw: true });
306
+ if (metrics) {
307
+ const total = metrics.hits + metrics.misses;
308
+ const rate = total > 0 ? ((metrics.hits / total) * 100).toFixed(1) : 0;
309
+ console.log(`Cache hit rate: ${rate}%`);
310
+ }
457
311
  ```
458
312
 
459
313
  ### Monitoring CSS growth
460
314
 
461
315
  ```typescript
462
- const s = tastyDebug.summary();
463
- console.log(`Total tasty CSS: ${(s.totalCSSSize / 1024).toFixed(1)}KB`);
464
- console.log(`Active: ${(s.activeCSSSize / 1024).toFixed(1)}KB`);
465
- console.log(`Unused (pending cleanup): ${(s.unusedCSSSize / 1024).toFixed(1)}KB`);
466
-
467
- // Compare with total page CSS
468
- const page = tastyDebug.pageStats();
469
- const ratio = ((s.totalCSSSize / page.cssSize) * 100).toFixed(1);
470
- console.log(`Tasty is ${ratio}% of total page CSS`);
471
- ```
472
-
473
- ### Analyzing chunk distribution
474
-
475
- ```typescript
476
- tastyDebug.chunks({ log: true });
477
- // → Formatted breakdown:
478
- // • appearance: 24 classes, 3.2KB, 48 rules
479
- // • font: 18 classes, 1.1KB, 18 rules
480
- // • dimension: 31 classes, 2.4KB, 45 rules
481
- // • ...
316
+ const s = tastyDebug.summary({ raw: true });
317
+ console.log(`Total: ${s.totalRuleCount} rules, ${(s.totalCSSSize / 1024).toFixed(1)}KB`);
318
+ console.log(`Active: ${s.activeRuleCount} rules`);
319
+ console.log(`Unused: ${s.unusedRuleCount} rules`);
482
320
  ```
483
-
484
- ---
485
-
486
- ## Shadow DOM Support
487
-
488
- All methods accept a `root` option to target a Shadow DOM instead of the main document:
489
-
490
- ```typescript
491
- const shadowRoot = host.shadowRoot;
492
-
493
- tastyDebug.css('all', { root: shadowRoot });
494
- tastyDebug.inspect('.shadow-component', { root: shadowRoot });
495
- tastyDebug.summary({ root: shadowRoot, log: true });
496
- tastyDebug.chunks({ root: shadowRoot, log: true });
497
- ```
498
-
499
- ---
500
-
501
- ## Integration with Tasty
502
-
503
- `tastyDebug` reads directly from the [Style Injector](./injector.md)'s internal registries. It does not inject, modify, or intercept any styles. The `cleanup()` method is the only method with side effects — it triggers the injector's garbage collection for unused styles.
504
-
505
- For most development, you'll use the [Tasty style system](./usage.md) to create components and the debug utilities to inspect the resulting CSS at runtime.