@tenphi/tasty 0.0.0-snapshot.fa94a5a → 0.0.0-snapshot.fc19da9

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 (372) hide show
  1. package/README.md +437 -362
  2. package/dist/babel-types-DpUCD2L_.d.ts +18 -0
  3. package/dist/chunks/async-storage-f9j9JRtq.js +37 -0
  4. package/dist/chunks/async-storage-f9j9JRtq.js.map +1 -0
  5. package/dist/chunks/build-config-BDLYGmKn.js +60 -0
  6. package/dist/chunks/build-config-BDLYGmKn.js.map +1 -0
  7. package/dist/chunks/collector-DqcB0UUT.js +210 -0
  8. package/dist/chunks/collector-DqcB0UUT.js.map +1 -0
  9. package/dist/chunks/config-engine-CGIMO2PV.js +272 -0
  10. package/dist/chunks/config-engine-CGIMO2PV.js.map +1 -0
  11. package/dist/chunks/config-file-DlZXJMj8.js +25 -0
  12. package/dist/chunks/config-file-DlZXJMj8.js.map +1 -0
  13. package/dist/chunks/css-definitions-BibU6ZnP.js +904 -0
  14. package/dist/chunks/css-definitions-BibU6ZnP.js.map +1 -0
  15. package/dist/chunks/css-resources-P7IBUUZs.js +142 -0
  16. package/dist/chunks/css-resources-P7IBUUZs.js.map +1 -0
  17. package/dist/{debug.js → chunks/debug-BzYPQ0H2.js} +197 -149
  18. package/dist/chunks/debug-BzYPQ0H2.js.map +1 -0
  19. package/dist/chunks/dsl-DRhFWQzo.js +1378 -0
  20. package/dist/chunks/dsl-DRhFWQzo.js.map +1 -0
  21. package/dist/chunks/hydration-TRcz5vnk.js +41 -0
  22. package/dist/chunks/hydration-TRcz5vnk.js.map +1 -0
  23. package/dist/chunks/react-runtime-B2e-Wha-.js +689 -0
  24. package/dist/chunks/react-runtime-B2e-Wha-.js.map +1 -0
  25. package/dist/chunks/runtime-engine-yeyCAx2e.js +2431 -0
  26. package/dist/chunks/runtime-engine-yeyCAx2e.js.map +1 -0
  27. package/dist/chunks/runtime-state-C0u1jp-Q.js +141 -0
  28. package/dist/chunks/runtime-state-C0u1jp-Q.js.map +1 -0
  29. package/dist/{utils/merge-styles.js → chunks/shared-utils-y-HjvPN4.js} +61 -58
  30. package/dist/chunks/shared-utils-y-HjvPN4.js.map +1 -0
  31. package/dist/chunks/style-engine-D35rvcdB.js +5420 -0
  32. package/dist/chunks/style-engine-D35rvcdB.js.map +1 -0
  33. package/dist/chunks/zero-engine-DpkieEPZ.js +310 -0
  34. package/dist/chunks/zero-engine-DpkieEPZ.js.map +1 -0
  35. package/dist/collector-D4POJ53X.d.ts +164 -0
  36. package/dist/config-DvPUj4cw.d.ts +1364 -0
  37. package/dist/core/index.d.ts +5 -34
  38. package/dist/core/index.js +9 -27
  39. package/dist/hydrate-CRyjjAyl.d.ts +22 -0
  40. package/dist/index-DC4q-xDq.d.ts +1946 -0
  41. package/dist/index.d.ts +5 -51
  42. package/dist/index.js +11 -36
  43. package/dist/{utils/merge-styles.d.ts → merge-styles-Jb5iZ-Jf.d.ts} +3 -4
  44. package/dist/ssr/astro-client.d.ts +1 -0
  45. package/dist/ssr/astro-client.js +6 -0
  46. package/dist/ssr/astro-client.js.map +1 -0
  47. package/dist/ssr/astro-middleware-extract-static.d.ts +10 -0
  48. package/dist/ssr/astro-middleware-extract-static.js +9 -0
  49. package/dist/ssr/astro-middleware-extract-static.js.map +1 -0
  50. package/dist/ssr/astro-middleware-extract.d.ts +10 -0
  51. package/dist/ssr/astro-middleware-extract.js +9 -0
  52. package/dist/ssr/astro-middleware-extract.js.map +1 -0
  53. package/dist/ssr/astro-middleware-static.d.ts +17 -0
  54. package/dist/ssr/astro-middleware-static.js +7 -0
  55. package/dist/ssr/astro-middleware-static.js.map +1 -0
  56. package/dist/ssr/astro-middleware.d.ts +18 -0
  57. package/dist/ssr/astro-middleware.js +7 -0
  58. package/dist/ssr/astro-middleware.js.map +1 -0
  59. package/dist/ssr/astro.d.ts +110 -12
  60. package/dist/ssr/astro.js +206 -50
  61. package/dist/ssr/astro.js.map +1 -1
  62. package/dist/ssr/client.d.ts +2 -0
  63. package/dist/ssr/client.js +2 -0
  64. package/dist/ssr/index.d.ts +17 -5
  65. package/dist/ssr/index.js +7 -9
  66. package/dist/ssr/index.js.map +1 -1
  67. package/dist/ssr/next-config.d.ts +64 -0
  68. package/dist/ssr/next-config.js +123 -0
  69. package/dist/ssr/next-config.js.map +1 -0
  70. package/dist/ssr/next.d.ts +13 -12
  71. package/dist/ssr/next.js +40 -51
  72. package/dist/ssr/next.js.map +1 -1
  73. package/dist/static/index.d.ts +90 -5
  74. package/dist/static/index.js +31 -4
  75. package/dist/static/index.js.map +1 -0
  76. package/dist/static/inject.d.ts +4 -0
  77. package/dist/static/inject.js +17 -0
  78. package/dist/static/inject.js.map +1 -0
  79. package/dist/types-ZbF2_6LV.d.ts +1567 -0
  80. package/dist/zero/babel.d.ts +20 -120
  81. package/dist/zero/babel.js +189 -148
  82. package/dist/zero/babel.js.map +1 -1
  83. package/dist/zero/index.d.ts +117 -3
  84. package/dist/zero/index.js +23 -3
  85. package/dist/zero/index.js.map +1 -0
  86. package/dist/zero/next.d.ts +16 -5
  87. package/dist/zero/next.js +8 -42
  88. package/dist/zero/next.js.map +1 -1
  89. package/docs/README.md +23 -12
  90. package/docs/adoption.md +72 -37
  91. package/docs/ai-agents.md +252 -0
  92. package/docs/comparison.md +83 -54
  93. package/docs/configuration.md +698 -81
  94. package/docs/debug.md +39 -24
  95. package/docs/design-system.md +174 -41
  96. package/docs/dsl.md +615 -197
  97. package/docs/getting-started.md +132 -52
  98. package/docs/injector.md +195 -90
  99. package/docs/methodology.md +153 -47
  100. package/docs/migration-v3.md +285 -0
  101. package/docs/pipeline.md +768 -0
  102. package/docs/plugins.md +333 -0
  103. package/docs/react-api.md +703 -0
  104. package/docs/runtime-benchmarks.md +388 -0
  105. package/docs/ssr.md +395 -149
  106. package/docs/styles.md +194 -45
  107. package/docs/tasty-static.md +327 -101
  108. package/package.json +153 -35
  109. package/tasty.config.ts +6 -0
  110. package/dist/_virtual/_rolldown/runtime.js +0 -8
  111. package/dist/chunks/cacheKey.js +0 -78
  112. package/dist/chunks/cacheKey.js.map +0 -1
  113. package/dist/chunks/definitions.d.ts +0 -37
  114. package/dist/chunks/definitions.js +0 -259
  115. package/dist/chunks/definitions.js.map +0 -1
  116. package/dist/chunks/renderChunk.js +0 -60
  117. package/dist/chunks/renderChunk.js.map +0 -1
  118. package/dist/config.d.ts +0 -366
  119. package/dist/config.js +0 -504
  120. package/dist/config.js.map +0 -1
  121. package/dist/counter-style/index.js +0 -51
  122. package/dist/counter-style/index.js.map +0 -1
  123. package/dist/debug.d.ts +0 -89
  124. package/dist/debug.js.map +0 -1
  125. package/dist/font-face/index.js +0 -63
  126. package/dist/font-face/index.js.map +0 -1
  127. package/dist/hooks/resolve-ssr-collector.js +0 -15
  128. package/dist/hooks/resolve-ssr-collector.js.map +0 -1
  129. package/dist/hooks/useCounterStyle.d.ts +0 -50
  130. package/dist/hooks/useCounterStyle.js +0 -47
  131. package/dist/hooks/useCounterStyle.js.map +0 -1
  132. package/dist/hooks/useFontFace.d.ts +0 -43
  133. package/dist/hooks/useFontFace.js +0 -71
  134. package/dist/hooks/useFontFace.js.map +0 -1
  135. package/dist/hooks/useGlobalStyles.d.ts +0 -30
  136. package/dist/hooks/useGlobalStyles.js +0 -79
  137. package/dist/hooks/useGlobalStyles.js.map +0 -1
  138. package/dist/hooks/useKeyframes.d.ts +0 -56
  139. package/dist/hooks/useKeyframes.js +0 -65
  140. package/dist/hooks/useKeyframes.js.map +0 -1
  141. package/dist/hooks/useProperty.d.ts +0 -79
  142. package/dist/hooks/useProperty.js +0 -110
  143. package/dist/hooks/useProperty.js.map +0 -1
  144. package/dist/hooks/useRawCSS.d.ts +0 -53
  145. package/dist/hooks/useRawCSS.js +0 -36
  146. package/dist/hooks/useRawCSS.js.map +0 -1
  147. package/dist/hooks/useStyles.d.ts +0 -45
  148. package/dist/hooks/useStyles.js +0 -270
  149. package/dist/hooks/useStyles.js.map +0 -1
  150. package/dist/injector/index.d.ts +0 -183
  151. package/dist/injector/index.js +0 -180
  152. package/dist/injector/index.js.map +0 -1
  153. package/dist/injector/injector.d.ts +0 -166
  154. package/dist/injector/injector.js +0 -465
  155. package/dist/injector/injector.js.map +0 -1
  156. package/dist/injector/sheet-manager.d.ts +0 -136
  157. package/dist/injector/sheet-manager.js +0 -731
  158. package/dist/injector/sheet-manager.js.map +0 -1
  159. package/dist/injector/types.d.ts +0 -204
  160. package/dist/keyframes/index.js +0 -206
  161. package/dist/keyframes/index.js.map +0 -1
  162. package/dist/parser/classify.js +0 -320
  163. package/dist/parser/classify.js.map +0 -1
  164. package/dist/parser/const.js +0 -33
  165. package/dist/parser/const.js.map +0 -1
  166. package/dist/parser/lru.js +0 -109
  167. package/dist/parser/lru.js.map +0 -1
  168. package/dist/parser/parser.d.ts +0 -25
  169. package/dist/parser/parser.js +0 -116
  170. package/dist/parser/parser.js.map +0 -1
  171. package/dist/parser/tokenizer.js +0 -69
  172. package/dist/parser/tokenizer.js.map +0 -1
  173. package/dist/parser/types.d.ts +0 -51
  174. package/dist/parser/types.js +0 -46
  175. package/dist/parser/types.js.map +0 -1
  176. package/dist/pipeline/conditions.d.ts +0 -134
  177. package/dist/pipeline/conditions.js +0 -406
  178. package/dist/pipeline/conditions.js.map +0 -1
  179. package/dist/pipeline/exclusive.js +0 -231
  180. package/dist/pipeline/exclusive.js.map +0 -1
  181. package/dist/pipeline/index.d.ts +0 -53
  182. package/dist/pipeline/index.js +0 -699
  183. package/dist/pipeline/index.js.map +0 -1
  184. package/dist/pipeline/materialize.js +0 -1105
  185. package/dist/pipeline/materialize.js.map +0 -1
  186. package/dist/pipeline/parseStateKey.d.ts +0 -15
  187. package/dist/pipeline/parseStateKey.js +0 -447
  188. package/dist/pipeline/parseStateKey.js.map +0 -1
  189. package/dist/pipeline/simplify.js +0 -516
  190. package/dist/pipeline/simplify.js.map +0 -1
  191. package/dist/pipeline/warnings.js +0 -18
  192. package/dist/pipeline/warnings.js.map +0 -1
  193. package/dist/plugins/okhsl-plugin.d.ts +0 -35
  194. package/dist/plugins/okhsl-plugin.js +0 -98
  195. package/dist/plugins/okhsl-plugin.js.map +0 -1
  196. package/dist/plugins/types.d.ts +0 -76
  197. package/dist/properties/index.js +0 -223
  198. package/dist/properties/index.js.map +0 -1
  199. package/dist/properties/property-type-resolver.d.ts +0 -24
  200. package/dist/properties/property-type-resolver.js +0 -91
  201. package/dist/properties/property-type-resolver.js.map +0 -1
  202. package/dist/ssr/async-storage.d.ts +0 -17
  203. package/dist/ssr/async-storage.js +0 -35
  204. package/dist/ssr/async-storage.js.map +0 -1
  205. package/dist/ssr/collect-auto-properties.js +0 -40
  206. package/dist/ssr/collect-auto-properties.js.map +0 -1
  207. package/dist/ssr/collector.d.ts +0 -102
  208. package/dist/ssr/collector.js +0 -227
  209. package/dist/ssr/collector.js.map +0 -1
  210. package/dist/ssr/context.d.ts +0 -8
  211. package/dist/ssr/context.js +0 -14
  212. package/dist/ssr/context.js.map +0 -1
  213. package/dist/ssr/format-global-rules.js +0 -22
  214. package/dist/ssr/format-global-rules.js.map +0 -1
  215. package/dist/ssr/format-keyframes.js +0 -70
  216. package/dist/ssr/format-keyframes.js.map +0 -1
  217. package/dist/ssr/format-property.js +0 -50
  218. package/dist/ssr/format-property.js.map +0 -1
  219. package/dist/ssr/format-rules.js +0 -70
  220. package/dist/ssr/format-rules.js.map +0 -1
  221. package/dist/ssr/hydrate.d.ts +0 -22
  222. package/dist/ssr/hydrate.js +0 -50
  223. package/dist/ssr/hydrate.js.map +0 -1
  224. package/dist/ssr/ssr-collector-ref.js +0 -12
  225. package/dist/ssr/ssr-collector-ref.js.map +0 -1
  226. package/dist/states/index.d.ts +0 -49
  227. package/dist/states/index.js +0 -171
  228. package/dist/states/index.js.map +0 -1
  229. package/dist/static/tastyStatic.d.ts +0 -46
  230. package/dist/static/tastyStatic.js +0 -31
  231. package/dist/static/tastyStatic.js.map +0 -1
  232. package/dist/static/types.d.ts +0 -49
  233. package/dist/static/types.js +0 -24
  234. package/dist/static/types.js.map +0 -1
  235. package/dist/styles/align.d.ts +0 -15
  236. package/dist/styles/align.js +0 -14
  237. package/dist/styles/align.js.map +0 -1
  238. package/dist/styles/border.d.ts +0 -25
  239. package/dist/styles/border.js +0 -114
  240. package/dist/styles/border.js.map +0 -1
  241. package/dist/styles/color.d.ts +0 -14
  242. package/dist/styles/color.js +0 -27
  243. package/dist/styles/color.js.map +0 -1
  244. package/dist/styles/createStyle.js +0 -80
  245. package/dist/styles/createStyle.js.map +0 -1
  246. package/dist/styles/dimension.js +0 -97
  247. package/dist/styles/dimension.js.map +0 -1
  248. package/dist/styles/display.d.ts +0 -37
  249. package/dist/styles/display.js +0 -67
  250. package/dist/styles/display.js.map +0 -1
  251. package/dist/styles/fade.d.ts +0 -15
  252. package/dist/styles/fade.js +0 -58
  253. package/dist/styles/fade.js.map +0 -1
  254. package/dist/styles/fill.d.ts +0 -42
  255. package/dist/styles/fill.js +0 -52
  256. package/dist/styles/fill.js.map +0 -1
  257. package/dist/styles/flow.d.ts +0 -16
  258. package/dist/styles/flow.js +0 -12
  259. package/dist/styles/flow.js.map +0 -1
  260. package/dist/styles/gap.d.ts +0 -31
  261. package/dist/styles/gap.js +0 -37
  262. package/dist/styles/gap.js.map +0 -1
  263. package/dist/styles/height.d.ts +0 -17
  264. package/dist/styles/height.js +0 -20
  265. package/dist/styles/height.js.map +0 -1
  266. package/dist/styles/index.d.ts +0 -2
  267. package/dist/styles/index.js +0 -9
  268. package/dist/styles/index.js.map +0 -1
  269. package/dist/styles/inset.d.ts +0 -52
  270. package/dist/styles/inset.js +0 -150
  271. package/dist/styles/inset.js.map +0 -1
  272. package/dist/styles/justify.d.ts +0 -15
  273. package/dist/styles/justify.js +0 -14
  274. package/dist/styles/justify.js.map +0 -1
  275. package/dist/styles/list.d.ts +0 -16
  276. package/dist/styles/list.js +0 -98
  277. package/dist/styles/list.js.map +0 -1
  278. package/dist/styles/margin.d.ts +0 -24
  279. package/dist/styles/margin.js +0 -104
  280. package/dist/styles/margin.js.map +0 -1
  281. package/dist/styles/outline.d.ts +0 -29
  282. package/dist/styles/outline.js +0 -65
  283. package/dist/styles/outline.js.map +0 -1
  284. package/dist/styles/padding.d.ts +0 -24
  285. package/dist/styles/padding.js +0 -104
  286. package/dist/styles/padding.js.map +0 -1
  287. package/dist/styles/predefined.d.ts +0 -71
  288. package/dist/styles/predefined.js +0 -238
  289. package/dist/styles/predefined.js.map +0 -1
  290. package/dist/styles/preset.d.ts +0 -47
  291. package/dist/styles/preset.js +0 -112
  292. package/dist/styles/preset.js.map +0 -1
  293. package/dist/styles/radius.d.ts +0 -14
  294. package/dist/styles/radius.js +0 -51
  295. package/dist/styles/radius.js.map +0 -1
  296. package/dist/styles/scrollbar.d.ts +0 -25
  297. package/dist/styles/scrollbar.js +0 -48
  298. package/dist/styles/scrollbar.js.map +0 -1
  299. package/dist/styles/shadow.d.ts +0 -14
  300. package/dist/styles/shadow.js +0 -24
  301. package/dist/styles/shadow.js.map +0 -1
  302. package/dist/styles/transition.d.ts +0 -14
  303. package/dist/styles/transition.js +0 -158
  304. package/dist/styles/transition.js.map +0 -1
  305. package/dist/styles/types.d.ts +0 -545
  306. package/dist/styles/width.d.ts +0 -17
  307. package/dist/styles/width.js +0 -20
  308. package/dist/styles/width.js.map +0 -1
  309. package/dist/tasty.d.ts +0 -119
  310. package/dist/tasty.js +0 -232
  311. package/dist/tasty.js.map +0 -1
  312. package/dist/types.d.ts +0 -184
  313. package/dist/utils/cache-wrapper.js +0 -22
  314. package/dist/utils/cache-wrapper.js.map +0 -1
  315. package/dist/utils/case-converter.js +0 -8
  316. package/dist/utils/case-converter.js.map +0 -1
  317. package/dist/utils/color-math.d.ts +0 -46
  318. package/dist/utils/color-math.js +0 -749
  319. package/dist/utils/color-math.js.map +0 -1
  320. package/dist/utils/color-space.d.ts +0 -5
  321. package/dist/utils/color-space.js +0 -229
  322. package/dist/utils/color-space.js.map +0 -1
  323. package/dist/utils/colors.d.ts +0 -5
  324. package/dist/utils/colors.js +0 -11
  325. package/dist/utils/colors.js.map +0 -1
  326. package/dist/utils/css-types.d.ts +0 -7
  327. package/dist/utils/dotize.d.ts +0 -26
  328. package/dist/utils/dotize.js +0 -122
  329. package/dist/utils/dotize.js.map +0 -1
  330. package/dist/utils/filter-base-props.d.ts +0 -15
  331. package/dist/utils/filter-base-props.js +0 -45
  332. package/dist/utils/filter-base-props.js.map +0 -1
  333. package/dist/utils/get-display-name.d.ts +0 -7
  334. package/dist/utils/get-display-name.js +0 -10
  335. package/dist/utils/get-display-name.js.map +0 -1
  336. package/dist/utils/has-keys.js +0 -13
  337. package/dist/utils/has-keys.js.map +0 -1
  338. package/dist/utils/is-dev-env.js +0 -19
  339. package/dist/utils/is-dev-env.js.map +0 -1
  340. package/dist/utils/is-valid-element-type.js +0 -15
  341. package/dist/utils/is-valid-element-type.js.map +0 -1
  342. package/dist/utils/merge-styles.js.map +0 -1
  343. package/dist/utils/mod-attrs.d.ts +0 -8
  344. package/dist/utils/mod-attrs.js +0 -21
  345. package/dist/utils/mod-attrs.js.map +0 -1
  346. package/dist/utils/process-tokens.d.ts +0 -21
  347. package/dist/utils/process-tokens.js +0 -91
  348. package/dist/utils/process-tokens.js.map +0 -1
  349. package/dist/utils/resolve-recipes.d.ts +0 -17
  350. package/dist/utils/resolve-recipes.js +0 -147
  351. package/dist/utils/resolve-recipes.js.map +0 -1
  352. package/dist/utils/selector-transform.js +0 -32
  353. package/dist/utils/selector-transform.js.map +0 -1
  354. package/dist/utils/string.js +0 -8
  355. package/dist/utils/string.js.map +0 -1
  356. package/dist/utils/styles.d.ts +0 -101
  357. package/dist/utils/styles.js +0 -223
  358. package/dist/utils/styles.js.map +0 -1
  359. package/dist/utils/typography.d.ts +0 -47
  360. package/dist/utils/typography.js +0 -43
  361. package/dist/utils/typography.js.map +0 -1
  362. package/dist/utils/warnings.d.ts +0 -16
  363. package/dist/utils/warnings.js +0 -16
  364. package/dist/utils/warnings.js.map +0 -1
  365. package/dist/zero/css-writer.d.ts +0 -45
  366. package/dist/zero/css-writer.js +0 -74
  367. package/dist/zero/css-writer.js.map +0 -1
  368. package/dist/zero/extractor.d.ts +0 -24
  369. package/dist/zero/extractor.js +0 -267
  370. package/dist/zero/extractor.js.map +0 -1
  371. package/docs/PIPELINE.md +0 -519
  372. package/docs/runtime.md +0 -485
@@ -1,7 +1,6 @@
1
- import { isDevEnv } from "./utils/is-dev-env.js";
2
- import { CHUNK_NAMES } from "./chunks/definitions.js";
3
- import { getCssTextForNode, injector } from "./injector/index.js";
4
-
1
+ import { j as tastyClassRegex } from "./css-definitions-BibU6ZnP.js";
2
+ import { P as CHUNK_NAMES } from "./style-engine-D35rvcdB.js";
3
+ import { A as injector, H as getNamePrefix, Z as flushStyles, w as getCSSTextForNode } from "./runtime-engine-yeyCAx2e.js";
5
4
  //#region src/debug.ts
6
5
  function fmtSize(bytes) {
7
6
  return bytes > 1024 ? `${(bytes / 1024).toFixed(1)}KB` : `${bytes}B`;
@@ -10,80 +9,76 @@ function countRules(css) {
10
9
  return (css.match(/\{[^}]*\}/g) || []).length;
11
10
  }
12
11
  function sortTastyClasses(classes) {
13
- return Array.from(classes).sort((a, b) => parseInt(a.slice(1)) - parseInt(b.slice(1)));
12
+ return Array.from(classes).sort((a, b) => a.localeCompare(b));
14
13
  }
15
- function getRegistry(root = document) {
16
- return injector.instance._sheetManager?.getRegistry(root);
14
+ function defaultRoot() {
15
+ return typeof document === "undefined" ? null : document;
17
16
  }
18
- function getUnusedClasses(root = document) {
19
- const registry = getRegistry(root);
20
- if (!registry) return [];
21
- const result = [];
22
- for (const [cls, rc] of registry.refCounts) if (rc === 0) result.push(cls);
23
- return sortTastyClasses(result);
17
+ let warnedNoDom = false;
18
+ function warnNoDom(raw) {
19
+ if (raw || warnedNoDom) return;
20
+ warnedNoDom = true;
21
+ console.warn("[Tasty] tastyDebug reads the DOM and this environment has none, so the result is empty. During SSR, read the ServerStyleCollector instead.");
24
22
  }
25
- function findDomTastyClasses(root = document) {
23
+ function getRegistry(root = defaultRoot()) {
24
+ if (!root) return void 0;
25
+ flushStyles();
26
+ return injector.instance._sheetManager?.getRegistry(root);
27
+ }
28
+ function findDomTastyClasses(root = defaultRoot()) {
29
+ if (!root) return [];
26
30
  const classes = /* @__PURE__ */ new Set();
27
- (root.querySelectorAll?.("[class]") || []).forEach((el) => {
28
- const attr = el.getAttribute("class");
29
- if (attr) {
30
- for (const cls of attr.split(/\s+/)) if (/^t\d+$/.test(cls)) classes.add(cls);
31
- }
32
- });
31
+ const elements = root.querySelectorAll?.("[class]") || [];
32
+ const classRegex = tastyClassRegex(getNamePrefix());
33
+ for (const element of elements) {
34
+ const attribute = element.getAttribute("class");
35
+ if (!attribute) continue;
36
+ for (const className of attribute.split(/\s+/)) if (classRegex.test(className)) classes.add(className);
37
+ }
33
38
  return sortTastyClasses(classes);
34
39
  }
40
+ function getAllCSS(root = defaultRoot()) {
41
+ const registry = getRegistry(root);
42
+ const sheetManager = injector.instance._sheetManager;
43
+ if (!root || !registry || !sheetManager) return "";
44
+ return sheetManager.getOwnedCSSInOrder(registry, root).join("\n");
45
+ }
46
+ function cssTextForClasses(classNames, root) {
47
+ if (!root) return "";
48
+ return injector.instance.getCSSTextForClasses(classNames, { root });
49
+ }
50
+ function getInjectorMetrics(root) {
51
+ if (!root) return null;
52
+ return injector.instance.getMetrics({ root });
53
+ }
54
+ function getUnusedClasses(root = defaultRoot()) {
55
+ if (!root) return [];
56
+ return sortTastyClasses(injector.instance.getUnusedClasses({ root }));
57
+ }
58
+ function getOwnedClasses(root = defaultRoot()) {
59
+ const registry = getRegistry(root);
60
+ if (!registry) return [];
61
+ const owned = [];
62
+ for (const [className, info] of registry.rules) if (info.sheetIndex >= 0) owned.push(className);
63
+ return sortTastyClasses(owned);
64
+ }
35
65
  function prettifyCSS(css) {
36
66
  if (!css || !css.trim()) return "";
37
67
  const out = [];
38
68
  let depth = 0;
39
- const indent = () => " ".repeat(depth);
40
- let normalized = css.replace(/\s+/g, " ").trim();
41
- normalized = normalized.replace(/\s*\{\s*/g, " { ");
42
- normalized = normalized.replace(/\s*\}\s*/g, " } ");
43
- normalized = normalized.replace(/;\s*/g, "; ");
44
- const tokens = normalized.split(/\s+/);
45
- let buf = "";
46
- for (const t of tokens) if (t === "{") {
47
- const header = buf.trim();
48
- if (header) {
49
- const parts = splitOutsideParens(header, ",");
50
- if (parts.length > 1) out.push(parts.map((p, idx) => idx === 0 ? `${indent()}${p.trim()},` : `${indent()}${p.trim()}${idx < parts.length - 1 ? "," : ""}`).join("\n") + " {");
51
- else out.push(`${indent()}${header} {`);
52
- } else out.push(`${indent()}{`);
53
- depth++;
54
- buf = "";
55
- } else if (t === "}") {
56
- if (buf.trim()) {
57
- for (const decl of buf.split(";").filter((s) => s.trim())) out.push(`${indent()}${decl.trim()};`);
58
- buf = "";
59
- }
60
- depth = Math.max(0, depth - 1);
61
- out.push(`${indent()}}`);
62
- } else if (t.endsWith(";")) {
63
- buf += ` ${t}`;
64
- const full = buf.trim();
65
- if (full) out.push(`${indent()}${full}`);
66
- buf = "";
67
- } else buf += ` ${t}`;
68
- if (buf.trim()) out.push(buf.trim());
69
- return out.filter((l) => l.trim()).join("\n").replace(/\n{3,}/g, "\n\n").trim();
70
- }
71
- /** Split `str` by `sep` only when not inside parentheses */
72
- function splitOutsideParens(str, sep) {
73
- const parts = [];
74
- let depth = 0;
75
- let start = 0;
76
- for (let i = 0; i < str.length; i++) {
77
- const ch = str[i];
78
- if (ch === "(") depth++;
79
- else if (ch === ")") depth--;
80
- else if (depth === 0 && str.startsWith(sep, i)) {
81
- parts.push(str.slice(start, i));
82
- start = i + sep.length;
69
+ const lines = css.replace(/\s+/g, " ").trim().replaceAll(" {", "{").replaceAll("{", " {\n").replaceAll("}", "\n}\n").replaceAll(";", ";\n").split("\n");
70
+ for (let line of lines) {
71
+ line = line.trim();
72
+ if (!line) continue;
73
+ if (line === "}") {
74
+ const last = out.at(-1);
75
+ if (last && !/[;{}]$/.test(last)) out[out.length - 1] += ";";
76
+ depth = Math.max(0, depth - 1);
83
77
  }
78
+ out.push(`${" ".repeat(depth)}${line}`);
79
+ if (line.endsWith("{")) depth++;
84
80
  }
85
- parts.push(str.slice(start));
86
- return parts;
81
+ return out.join("\n");
87
82
  }
88
83
  function extractChunkName(cacheKey) {
89
84
  for (const part of cacheKey.split("\0")) {
@@ -92,15 +87,15 @@ function extractChunkName(cacheKey) {
92
87
  }
93
88
  return null;
94
89
  }
95
- function getChunkForClass(className, root = document) {
90
+ function getChunkForClass(className, root = defaultRoot()) {
96
91
  const registry = getRegistry(root);
97
92
  if (!registry) return null;
98
93
  for (const [key, cn] of registry.cacheKeyToClassName) if (cn === className) return extractChunkName(key);
99
94
  return null;
100
95
  }
101
- function buildChunkBreakdown(root = document) {
96
+ function buildChunkBreakdown(root = defaultRoot()) {
102
97
  const registry = getRegistry(root);
103
- if (!registry) return {
98
+ if (!root || !registry) return {
104
99
  byChunk: {},
105
100
  totalChunkTypes: 0,
106
101
  totalClasses: 0
@@ -108,36 +103,56 @@ function buildChunkBreakdown(root = document) {
108
103
  const byChunk = {};
109
104
  for (const [cacheKey, className] of registry.cacheKeyToClassName) {
110
105
  const chunk = extractChunkName(cacheKey) || "unknown";
111
- if (!byChunk[chunk]) byChunk[chunk] = {
106
+ const entry = byChunk[chunk] ??= {
112
107
  classes: [],
113
108
  cssSize: 0,
114
109
  ruleCount: 0
115
110
  };
116
- byChunk[chunk].classes.push(className);
117
- const css = injector.instance.getCssTextForClasses([className], { root });
118
- byChunk[chunk].cssSize += css.length;
119
- byChunk[chunk].ruleCount += countRules(css);
111
+ entry.classes.push(className);
112
+ const css = cssTextForClasses([className], root);
113
+ entry.cssSize += css.length;
114
+ entry.ruleCount += countRules(css);
120
115
  }
121
- for (const entry of Object.values(byChunk)) entry.classes = sortTastyClasses(entry.classes);
122
- const totalClasses = Object.values(byChunk).reduce((s, e) => s + e.classes.length, 0);
116
+ const entries = Object.values(byChunk);
117
+ for (const entry of entries) entry.classes = sortTastyClasses(entry.classes);
118
+ const totalClasses = entries.reduce((sum, entry) => {
119
+ return sum + entry.classes.length;
120
+ }, 0);
123
121
  return {
124
122
  byChunk,
125
123
  totalChunkTypes: Object.keys(byChunk).length,
126
124
  totalClasses
127
125
  };
128
126
  }
129
- function getGlobalTypeCSS(type, root = document) {
127
+ const GLOBAL_RULE_PREFIXES = {
128
+ global: "global:",
129
+ property: "property:",
130
+ fontFace: "fontface:",
131
+ counterStyle: "counterstyle:",
132
+ function: "function:"
133
+ };
134
+ function getGlobalTypeCSS(type, root = defaultRoot(), includeCSS = true) {
130
135
  const registry = getRegistry(root);
131
- if (!registry) return {
136
+ if (!root || !registry) return {
132
137
  css: "",
133
138
  ruleCount: 0,
134
139
  size: 0
135
140
  };
136
141
  const chunks = [];
142
+ const sheetManager = injector.instance._sheetManager;
137
143
  let rc = 0;
144
+ if (type === "raw") {
145
+ const css = injector.instance.getRawCSSText({ root });
146
+ return {
147
+ css: includeCSS ? prettifyCSS(css) : "",
148
+ ruleCount: sheetManager?.getRawRuleCount(root) ?? 0,
149
+ size: css.length
150
+ };
151
+ }
138
152
  if (type === "keyframes") for (const [, entry] of registry.keyframesCache) {
139
153
  const info = entry.info;
140
- const ss = registry.sheets[info.sheetIndex]?.sheet?.sheet;
154
+ const sheetInfo = registry.sheets[info.sheetIndex];
155
+ const ss = sheetInfo && sheetManager ? sheetManager.getCSSSheet(sheetInfo) : null;
141
156
  if (ss && info.ruleIndex < ss.cssRules.length) {
142
157
  const rule = ss.cssRules[info.ruleIndex];
143
158
  if (rule) {
@@ -150,10 +165,11 @@ function getGlobalTypeCSS(type, root = document) {
150
165
  }
151
166
  }
152
167
  else {
153
- const prefix = type === "global" ? "global:" : type === "raw" ? "raw:" : "property:";
168
+ const prefix = GLOBAL_RULE_PREFIXES[type];
154
169
  for (const [key, ri] of registry.globalRules) {
155
170
  if (!key.startsWith(prefix)) continue;
156
- const ss = registry.sheets[ri.sheetIndex]?.sheet?.sheet;
171
+ const sheetInfo = registry.sheets[ri.sheetIndex];
172
+ const ss = sheetInfo && sheetManager ? sheetManager.getCSSSheet(sheetInfo) : null;
157
173
  if (ss) {
158
174
  const start = Math.max(0, ri.ruleIndex);
159
175
  const end = Math.min(ss.cssRules.length - 1, ri.endRuleIndex ?? ri.ruleIndex);
@@ -172,12 +188,12 @@ function getGlobalTypeCSS(type, root = document) {
172
188
  }
173
189
  const raw = chunks.join("\n");
174
190
  return {
175
- css: prettifyCSS(raw),
191
+ css: includeCSS ? prettifyCSS(raw) : "",
176
192
  ruleCount: rc,
177
193
  size: raw.length
178
194
  };
179
195
  }
180
- function getSourceCssForClasses(classNames, root = document) {
196
+ function getSourceCssForClasses(classNames, root = defaultRoot()) {
181
197
  const registry = getRegistry(root);
182
198
  if (!registry) return null;
183
199
  const chunks = [];
@@ -191,7 +207,7 @@ function getSourceCssForClasses(classNames, root = document) {
191
207
  }
192
208
  return found ? chunks.join("\n") : null;
193
209
  }
194
- function getDefs(root = document) {
210
+ function getDefs(root = defaultRoot()) {
195
211
  const registry = getRegistry(root);
196
212
  let properties = [];
197
213
  if (registry?.injectedProperties) properties = Array.from(registry.injectedProperties.keys()).sort();
@@ -219,42 +235,51 @@ const CHUNK_ORDER = [
219
235
  CHUNK_NAMES.MISC,
220
236
  CHUNK_NAMES.SUBCOMPONENTS
221
237
  ];
238
+ function logChunkEntries(breakdown) {
239
+ for (const name of CHUNK_ORDER) {
240
+ const data = breakdown.byChunk[name];
241
+ if (data) console.log(` ${name}: ${data.classes.length} cls, ${data.ruleCount} rules, ${fmtSize(data.cssSize)}`);
242
+ }
243
+ for (const [name, data] of Object.entries(breakdown.byChunk)) if (!CHUNK_ORDER.includes(name)) console.log(` ${name}: ${data.classes.length} cls, ${data.ruleCount} rules, ${fmtSize(data.cssSize)}`);
244
+ }
222
245
  const tastyDebug = {
223
246
  css(target, opts) {
224
- const { root = document, prettify = true, raw = false, source = false } = opts || {};
247
+ const { root = defaultRoot(), prettify = true, raw = false, source = false } = opts || {};
248
+ if (!root) {
249
+ warnNoDom(raw);
250
+ return "";
251
+ }
225
252
  let css = "";
226
- if (source && typeof target === "string" && /^t\d+$/.test(target)) {
253
+ const classRegex = tastyClassRegex(getNamePrefix());
254
+ if (source && typeof target === "string" && classRegex.test(target)) {
227
255
  const src = getSourceCssForClasses([target], root);
228
256
  if (src) css = src;
229
257
  else {
230
- if (!raw) console.warn("tastyDebug: source CSS not available (requires dev mode or TASTY_DEBUG=true). Falling back to live CSSOM.");
231
- css = injector.instance.getCssTextForClasses([target], { root });
258
+ if (!raw) console.warn("[Tasty] source CSS not available (requires dev mode or TASTY_DEBUG=true). Falling back to live CSSOM.");
259
+ css = cssTextForClasses([target], root);
232
260
  }
233
261
  } else if (source && Array.isArray(target)) {
234
262
  const src = getSourceCssForClasses(target, root);
235
263
  if (src) css = src;
236
264
  else {
237
- if (!raw) console.warn("tastyDebug: source CSS not available. Falling back to live CSSOM.");
238
- css = injector.instance.getCssTextForClasses(target, { root });
265
+ if (!raw) console.warn("[Tasty] source CSS not available. Falling back to live CSSOM.");
266
+ css = cssTextForClasses(target, root);
239
267
  }
240
- } else if (typeof target === "string") if (target === "all") css = injector.instance.getCssText({ root });
241
- else if (target === "global") {
242
- css = getGlobalTypeCSS("global", root).css;
243
- return css;
244
- } else if (target === "active") {
245
- const active = findDomTastyClasses(root);
246
- css = injector.instance.getCssTextForClasses(active, { root });
247
- } else if (target === "unused") {
248
- const unused = getUnusedClasses(root);
249
- css = injector.instance.getCssTextForClasses(unused, { root });
250
- } else if (target === "page") css = getPageCSS(root);
251
- else if (/^t\d+$/.test(target)) css = injector.instance.getCssTextForClasses([target], { root });
252
- else {
253
- const el = root.querySelector?.(target);
254
- if (el) css = getCssTextForNode(el, { root });
255
- }
256
- else if (Array.isArray(target)) css = injector.instance.getCssTextForClasses(target, { root });
257
- else if (target instanceof Element) css = getCssTextForNode(target, { root });
268
+ } else if (typeof target === "string") {
269
+ if (target === "all") css = getAllCSS(root);
270
+ else if (target === "global") {
271
+ css = getGlobalTypeCSS("global", root).css;
272
+ return css;
273
+ } else if (target === "active") css = cssTextForClasses(findDomTastyClasses(root), root);
274
+ else if (target === "unused") css = cssTextForClasses(getUnusedClasses(root), root);
275
+ else if (target === "page") css = getPageCSS(root);
276
+ else if (classRegex.test(target)) css = cssTextForClasses([target], root);
277
+ else {
278
+ const el = root.querySelector?.(target);
279
+ if (el) css = getCSSTextForNode(el, { root });
280
+ }
281
+ } else if (Array.isArray(target)) css = cssTextForClasses(target, root);
282
+ else if (target instanceof Element) css = getCSSTextForNode(target, { root });
258
283
  const result = prettify ? prettifyCSS(css) : css;
259
284
  if (!raw) {
260
285
  const label = Array.isArray(target) ? `[${target.join(", ")}]` : target;
@@ -266,8 +291,9 @@ const tastyDebug = {
266
291
  return result;
267
292
  },
268
293
  inspect(target, opts) {
269
- const { root = document, raw = false } = opts || {};
270
- const element = typeof target === "string" ? root.querySelector?.(target) : target;
294
+ const { root = defaultRoot(), raw = false } = opts || {};
295
+ const element = !root ? null : typeof target === "string" ? root.querySelector?.(target) : target;
296
+ if (!root) warnNoDom(raw);
271
297
  if (!element) {
272
298
  const empty = {
273
299
  element: null,
@@ -277,15 +303,17 @@ const tastyDebug = {
277
303
  size: 0,
278
304
  rules: 0
279
305
  };
280
- if (!raw) console.warn("tastyDebug.inspect: element not found");
306
+ if (!raw && root) console.warn("[Tasty] debug.inspect: element not found");
281
307
  return empty;
282
308
  }
283
- const tastyClasses = (element.getAttribute("class") || "").split(/\s+/).filter((cls) => /^t\d+$/.test(cls));
309
+ const classList = element.getAttribute("class") || "";
310
+ const classRegex = tastyClassRegex(getNamePrefix());
311
+ const tastyClasses = classList.split(/\s+/).filter((cls) => classRegex.test(cls));
284
312
  const chunks = tastyClasses.map((className) => ({
285
313
  className,
286
314
  chunkName: getChunkForClass(className, root)
287
315
  }));
288
- const css = getCssTextForNode(element, { root });
316
+ const css = getCSSTextForNode(element, { root: root ?? void 0 });
289
317
  const rules = countRules(css);
290
318
  const result = {
291
319
  element,
@@ -308,37 +336,60 @@ const tastyDebug = {
308
336
  return result;
309
337
  },
310
338
  summary(opts) {
311
- const { root = document, raw = false } = opts || {};
339
+ const { root = defaultRoot(), raw = false } = opts || {};
340
+ if (!root) warnNoDom(raw);
312
341
  const activeClasses = findDomTastyClasses(root);
313
342
  const unusedClasses = getUnusedClasses(root);
314
- const totalStyledClasses = [...activeClasses, ...unusedClasses];
315
- const activeCSS = injector.instance.getCssTextForClasses(activeClasses, { root });
316
- const unusedCSS = injector.instance.getCssTextForClasses(unusedClasses, { root });
317
- const allCSS = injector.instance.getCssText({ root });
343
+ const ownedClasses = getOwnedClasses(root);
344
+ const totalStyledClasses = sortTastyClasses(/* @__PURE__ */ new Set([...activeClasses, ...ownedClasses]));
345
+ const unusedSet = new Set(unusedClasses);
346
+ const activeSet = new Set(activeClasses);
347
+ const hotClasses = ownedClasses.filter((className) => !activeSet.has(className) && !unusedSet.has(className));
348
+ const hotCSS = cssTextForClasses(hotClasses, root);
349
+ const activeCSS = cssTextForClasses(activeClasses, root);
350
+ const unusedCSS = cssTextForClasses(unusedClasses, root);
351
+ const allCSS = getAllCSS(root);
318
352
  const activeRuleCount = countRules(activeCSS);
319
353
  const unusedRuleCount = countRules(unusedCSS);
320
- const globalData = getGlobalTypeCSS("global", root);
321
- const rawData = getGlobalTypeCSS("raw", root);
322
- const kfData = getGlobalTypeCSS("keyframes", root);
323
- const propData = getGlobalTypeCSS("property", root);
324
- const totalRuleCount = activeRuleCount + unusedRuleCount + globalData.ruleCount + rawData.ruleCount + kfData.ruleCount + propData.ruleCount;
325
- const metrics = injector.instance.getMetrics({ root });
354
+ const globalData = getGlobalTypeCSS("global", root, false);
355
+ const rawData = getGlobalTypeCSS("raw", root, false);
356
+ const kfData = getGlobalTypeCSS("keyframes", root, false);
357
+ const propData = getGlobalTypeCSS("property", root, false);
358
+ const atRuleData = [
359
+ "fontFace",
360
+ "counterStyle",
361
+ "function"
362
+ ].reduce((total, type) => {
363
+ const data = getGlobalTypeCSS(type, root, false);
364
+ total.ruleCount += data.ruleCount;
365
+ total.size += data.size;
366
+ return total;
367
+ }, {
368
+ ruleCount: 0,
369
+ size: 0
370
+ });
371
+ const hotRuleCount = countRules(hotCSS);
372
+ const globalRuleCount = globalData.ruleCount + atRuleData.ruleCount;
373
+ const globalCSSSize = globalData.size + atRuleData.size;
374
+ const totalRuleCount = activeRuleCount + unusedRuleCount + hotRuleCount + globalRuleCount + rawData.ruleCount + kfData.ruleCount + propData.ruleCount;
375
+ const metrics = getInjectorMetrics(root);
326
376
  const defs = getDefs(root);
327
377
  const chunkBreakdown = buildChunkBreakdown(root);
328
378
  const summary = {
329
379
  activeClasses,
330
380
  unusedClasses,
381
+ hotClasses,
331
382
  totalStyledClasses,
332
383
  activeCSSSize: activeCSS.length,
333
384
  unusedCSSSize: unusedCSS.length,
334
- globalCSSSize: globalData.size,
385
+ globalCSSSize,
335
386
  rawCSSSize: rawData.size,
336
387
  keyframesCSSSize: kfData.size,
337
388
  propertyCSSSize: propData.size,
338
389
  totalCSSSize: allCSS.length,
339
390
  activeRuleCount,
340
391
  unusedRuleCount,
341
- globalRuleCount: globalData.ruleCount,
392
+ globalRuleCount,
342
393
  rawRuleCount: rawData.ruleCount,
343
394
  keyframesRuleCount: kfData.ruleCount,
344
395
  propertyRuleCount: propData.ruleCount,
@@ -352,7 +403,8 @@ const tastyDebug = {
352
403
  console.group("Tasty Summary");
353
404
  console.log(`Active: ${activeClasses.length} classes, ${activeRuleCount} rules, ${fmtSize(activeCSS.length)}`);
354
405
  console.log(`Unused: ${unusedClasses.length} classes, ${unusedRuleCount} rules, ${fmtSize(unusedCSS.length)}`);
355
- console.log(`Global: ${globalData.ruleCount} rules, ${fmtSize(globalData.size)}`);
406
+ if (hotClasses.length) console.log(`Held: ${hotClasses.length} classes, ${hotRuleCount} rules, ${fmtSize(hotCSS.length)} (not rendered, not yet collectable)`);
407
+ console.log(`Global: ${globalRuleCount} rules, ${fmtSize(globalCSSSize)}`);
356
408
  if (rawData.ruleCount) console.log(`Raw: ${rawData.ruleCount} rules, ${fmtSize(rawData.size)}`);
357
409
  if (kfData.ruleCount) console.log(`Keyframes: ${kfData.ruleCount} rules, ${fmtSize(kfData.size)}`);
358
410
  if (propData.ruleCount) console.log(`@property: ${propData.ruleCount} rules, ${fmtSize(propData.size)}`);
@@ -364,11 +416,7 @@ const tastyDebug = {
364
416
  }
365
417
  if (chunkBreakdown.totalChunkTypes > 0) {
366
418
  console.groupCollapsed(`Chunks (${chunkBreakdown.totalChunkTypes} types, ${chunkBreakdown.totalClasses} classes)`);
367
- for (const name of CHUNK_ORDER) {
368
- const d = chunkBreakdown.byChunk[name];
369
- if (d) console.log(` ${name}: ${d.classes.length} cls, ${d.ruleCount} rules, ${fmtSize(d.cssSize)}`);
370
- }
371
- for (const [name, d] of Object.entries(chunkBreakdown.byChunk)) if (!CHUNK_ORDER.includes(name)) console.log(` ${name}: ${d.classes.length} cls, ${d.ruleCount} rules, ${fmtSize(d.cssSize)}`);
419
+ logChunkEntries(chunkBreakdown);
372
420
  console.groupEnd();
373
421
  }
374
422
  if (defs.properties.length || defs.keyframes.length) console.log(`Defs: ${defs.properties.length} @property, ${defs.keyframes.length} @keyframes`);
@@ -377,29 +425,27 @@ const tastyDebug = {
377
425
  return summary;
378
426
  },
379
427
  chunks(opts) {
380
- const { root = document, raw = false } = opts || {};
428
+ const { root = defaultRoot(), raw = false } = opts || {};
429
+ if (!root) warnNoDom(raw);
381
430
  const breakdown = buildChunkBreakdown(root);
382
431
  if (!raw) {
383
432
  console.group(`Chunks (${breakdown.totalChunkTypes} types, ${breakdown.totalClasses} classes)`);
384
- for (const name of CHUNK_ORDER) {
385
- const d = breakdown.byChunk[name];
386
- if (d) console.log(` ${name}: ${d.classes.length} cls, ${d.ruleCount} rules, ${fmtSize(d.cssSize)}`);
387
- }
388
- for (const [name, d] of Object.entries(breakdown.byChunk)) if (!CHUNK_ORDER.includes(name)) console.log(` ${name}: ${d.classes.length} cls, ${d.ruleCount} rules, ${fmtSize(d.cssSize)}`);
433
+ logChunkEntries(breakdown);
389
434
  console.groupEnd();
390
435
  }
391
436
  return breakdown;
392
437
  },
393
438
  cache(opts) {
394
- const { root = document, raw = false } = opts || {};
439
+ const { root = defaultRoot(), raw = false } = opts || {};
440
+ if (!root) warnNoDom(raw);
395
441
  const active = findDomTastyClasses(root);
396
442
  const unused = getUnusedClasses(root);
397
- const metrics = injector.instance.getMetrics({ root });
443
+ const metrics = getInjectorMetrics(root);
398
444
  const status = {
399
445
  classes: {
400
446
  active,
401
447
  unused,
402
- all: [...active, ...unused]
448
+ all: sortTastyClasses(/* @__PURE__ */ new Set([...active, ...getOwnedClasses(root)]))
403
449
  },
404
450
  metrics
405
451
  };
@@ -416,14 +462,16 @@ const tastyDebug = {
416
462
  return status;
417
463
  },
418
464
  cleanup(opts) {
419
- injector.instance.cleanup(opts?.root);
465
+ const root = opts?.root ?? defaultRoot();
466
+ if (!root) return;
467
+ injector.instance.cleanup(root);
420
468
  },
421
469
  help() {
422
470
  console.log(`tastyDebug API:
423
471
  .summary() — overview (classes, rules, sizes)
424
472
  .css("active") — CSS for classes in DOM
425
- .css("t42") — CSS for a specific class
426
- .css("t42",{source:1})— original CSS before browser parsing (dev only)
473
+ .css("t3a5f") — CSS for a specific class
474
+ .css("t3a5f",{source:true}) — original CSS before browser parsing (dev only)
427
475
  .css(".selector") — CSS for a DOM element
428
476
  .inspect(".selector") — element details (classes, chunks, rules)
429
477
  .chunks() — style chunk breakdown
@@ -438,7 +486,8 @@ Options: { raw: true } suppresses logging, { root: shadowRoot } targets Shadow D
438
486
  }
439
487
  }
440
488
  };
441
- function getPageCSS(root = document) {
489
+ function getPageCSS(root = defaultRoot()) {
490
+ if (!root) return "";
442
491
  const chunks = [];
443
492
  try {
444
493
  if ("styleSheets" in root) for (const sheet of Array.from(root.styleSheets)) try {
@@ -447,8 +496,7 @@ function getPageCSS(root = document) {
447
496
  } catch {}
448
497
  return chunks.join("\n");
449
498
  }
450
- if (typeof window !== "undefined" && isDevEnv()) tastyDebug.install();
451
-
452
499
  //#endregion
453
- export { tastyDebug };
454
- //# sourceMappingURL=debug.js.map
500
+ export { tastyDebug as t };
501
+
502
+ //# sourceMappingURL=debug-BzYPQ0H2.js.map