@tenphi/tasty 0.0.0-snapshot.0003ae6

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 (104) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +685 -0
  3. package/dist/babel-rZcEwPLM.d.ts +82 -0
  4. package/dist/chunks/async-storage-CG5HnUT5.js +20 -0
  5. package/dist/chunks/async-storage-CG5HnUT5.js.map +1 -0
  6. package/dist/chunks/build-config-_cm7XDZ0.js +42 -0
  7. package/dist/chunks/build-config-_cm7XDZ0.js.map +1 -0
  8. package/dist/chunks/collector-DZh0frqA.js +208 -0
  9. package/dist/chunks/collector-DZh0frqA.js.map +1 -0
  10. package/dist/chunks/config-engine-B9arIU78.js +272 -0
  11. package/dist/chunks/config-engine-B9arIU78.js.map +1 -0
  12. package/dist/chunks/css-definitions-LxHlQWqa.js +876 -0
  13. package/dist/chunks/css-definitions-LxHlQWqa.js.map +1 -0
  14. package/dist/chunks/css-resources-P7IBUUZs.js +142 -0
  15. package/dist/chunks/css-resources-P7IBUUZs.js.map +1 -0
  16. package/dist/chunks/debug-Cp6kyH_o.js +502 -0
  17. package/dist/chunks/debug-Cp6kyH_o.js.map +1 -0
  18. package/dist/chunks/dsl-MW8TZusz.js +1377 -0
  19. package/dist/chunks/dsl-MW8TZusz.js.map +1 -0
  20. package/dist/chunks/hydration-TRcz5vnk.js +41 -0
  21. package/dist/chunks/hydration-TRcz5vnk.js.map +1 -0
  22. package/dist/chunks/react-runtime-DFK-u-KU.js +562 -0
  23. package/dist/chunks/react-runtime-DFK-u-KU.js.map +1 -0
  24. package/dist/chunks/runtime-engine-BNE2KUiS.js +2412 -0
  25. package/dist/chunks/runtime-engine-BNE2KUiS.js.map +1 -0
  26. package/dist/chunks/runtime-state-BsBWQeBn.js +127 -0
  27. package/dist/chunks/runtime-state-BsBWQeBn.js.map +1 -0
  28. package/dist/chunks/shared-utils-CGMsLq--.js +148 -0
  29. package/dist/chunks/shared-utils-CGMsLq--.js.map +1 -0
  30. package/dist/chunks/style-engine-BuW7q07d.js +5260 -0
  31. package/dist/chunks/style-engine-BuW7q07d.js.map +1 -0
  32. package/dist/chunks/zero-engine-DzsBXgfk.js +275 -0
  33. package/dist/chunks/zero-engine-DzsBXgfk.js.map +1 -0
  34. package/dist/collector-w4mBj5gd.d.ts +164 -0
  35. package/dist/config-CZWCzBr6.d.ts +1349 -0
  36. package/dist/core/index.d.ts +5 -0
  37. package/dist/core/index.js +9 -0
  38. package/dist/index-G9JuwM9p.d.ts +1920 -0
  39. package/dist/index.d.ts +5 -0
  40. package/dist/index.js +11 -0
  41. package/dist/merge-styles-VXwJ0Frr.d.ts +6 -0
  42. package/dist/ssr/astro-client.d.ts +1 -0
  43. package/dist/ssr/astro-client.js +6 -0
  44. package/dist/ssr/astro-client.js.map +1 -0
  45. package/dist/ssr/astro-middleware-extract-static.d.ts +10 -0
  46. package/dist/ssr/astro-middleware-extract-static.js +9 -0
  47. package/dist/ssr/astro-middleware-extract-static.js.map +1 -0
  48. package/dist/ssr/astro-middleware-extract.d.ts +10 -0
  49. package/dist/ssr/astro-middleware-extract.js +9 -0
  50. package/dist/ssr/astro-middleware-extract.js.map +1 -0
  51. package/dist/ssr/astro-middleware-static.d.ts +17 -0
  52. package/dist/ssr/astro-middleware-static.js +7 -0
  53. package/dist/ssr/astro-middleware-static.js.map +1 -0
  54. package/dist/ssr/astro-middleware.d.ts +18 -0
  55. package/dist/ssr/astro-middleware.js +7 -0
  56. package/dist/ssr/astro-middleware.js.map +1 -0
  57. package/dist/ssr/astro.d.ts +127 -0
  58. package/dist/ssr/astro.js +221 -0
  59. package/dist/ssr/astro.js.map +1 -0
  60. package/dist/ssr/index.d.ts +36 -0
  61. package/dist/ssr/index.js +10 -0
  62. package/dist/ssr/index.js.map +1 -0
  63. package/dist/ssr/next-config.d.ts +64 -0
  64. package/dist/ssr/next-config.js +128 -0
  65. package/dist/ssr/next-config.js.map +1 -0
  66. package/dist/ssr/next.d.ts +46 -0
  67. package/dist/ssr/next.js +60 -0
  68. package/dist/ssr/next.js.map +1 -0
  69. package/dist/static/index.d.ts +90 -0
  70. package/dist/static/index.js +32 -0
  71. package/dist/static/index.js.map +1 -0
  72. package/dist/static/inject.d.ts +4 -0
  73. package/dist/static/inject.js +17 -0
  74. package/dist/static/inject.js.map +1 -0
  75. package/dist/types-JEY8PVYP.d.ts +1567 -0
  76. package/dist/zero/babel.d.ts +2 -0
  77. package/dist/zero/babel.js +412 -0
  78. package/dist/zero/babel.js.map +1 -0
  79. package/dist/zero/index.d.ts +80 -0
  80. package/dist/zero/index.js +2 -0
  81. package/dist/zero/next.d.ts +84 -0
  82. package/dist/zero/next.js +112 -0
  83. package/dist/zero/next.js.map +1 -0
  84. package/docs/README.md +39 -0
  85. package/docs/adoption.md +323 -0
  86. package/docs/ai-agents.md +250 -0
  87. package/docs/comparison.md +448 -0
  88. package/docs/configuration.md +839 -0
  89. package/docs/debug.md +332 -0
  90. package/docs/design-system.md +455 -0
  91. package/docs/dsl.md +1065 -0
  92. package/docs/getting-started.md +240 -0
  93. package/docs/injector.md +634 -0
  94. package/docs/methodology.md +648 -0
  95. package/docs/migration-v3.md +285 -0
  96. package/docs/pipeline.md +765 -0
  97. package/docs/plugins.md +353 -0
  98. package/docs/react-api.md +683 -0
  99. package/docs/runtime-benchmarks.md +388 -0
  100. package/docs/ssr.md +610 -0
  101. package/docs/styles.md +715 -0
  102. package/docs/tasty-static.md +582 -0
  103. package/package.json +314 -0
  104. package/tasty.config.ts +20 -0
package/docs/debug.md ADDED
@@ -0,0 +1,332 @@
1
+ # Tasty Debug Utilities
2
+
3
+ Runtime CSS inspection and diagnostics for the Tasty styling system. Inspect injected styles, measure cache performance, analyze style chunks, and troubleshoot CSS issues — all from the browser console.
4
+
5
+ ---
6
+
7
+ ## Overview
8
+
9
+ `tastyDebug` is a diagnostic object that exposes Tasty's runtime CSS state. It is designed for development use and can be installed on `window` explicitly when needed.
10
+
11
+ All methods **log to the console by default**. Pass `{ raw: true }` to suppress logging and only return data.
12
+
13
+ > **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
+
15
+ ---
16
+
17
+ ## Quick Start
18
+
19
+ ```typescript
20
+ import { tastyDebug } from '@tenphi/tasty';
21
+ tastyDebug.install();
22
+
23
+ // Print a quick-start guide
24
+ tastyDebug.help();
25
+
26
+ // Get a comprehensive overview (logged automatically)
27
+ tastyDebug.summary();
28
+
29
+ // See all active CSS
30
+ tastyDebug.css('active');
31
+
32
+ // Inspect a specific element
33
+ tastyDebug.inspect('.my-button');
34
+
35
+ // Silent mode — return data only, no console output
36
+ const data = tastyDebug.summary({ raw: true });
37
+ ```
38
+
39
+ ---
40
+
41
+ ## Options
42
+
43
+ All methods accept a shared options object:
44
+
45
+ ```typescript
46
+ interface DebugOptions {
47
+ root?: Document | ShadowRoot; // Target root (default: document)
48
+ raw?: boolean; // Suppress console logging (default: false)
49
+ }
50
+ ```
51
+
52
+ When `raw` is `false` (the default), results are logged to the console **and** returned. When `raw` is `true`, results are returned silently.
53
+
54
+ ### Environments Without a DOM
55
+
56
+ `tastyDebug` reads the document, so on a server — SSR, a Node REPL, a test
57
+ runner in the `node` environment — there is nothing for it to read. Every
58
+ method returns its empty result (`''`, an empty `InspectResult`, a summary of
59
+ zeroes, `metrics: null`) instead of throwing, and explains itself once with a
60
+ console warning. `{ raw: true }` suppresses that warning along with the rest of
61
+ the logging.
62
+
63
+ To see the styles a server render produced, read the `ServerStyleCollector`
64
+ instead — `collector.getCSS()` and `collector.getRenderedClassNames()`. See
65
+ [SSR](./ssr.md).
66
+
67
+ ---
68
+
69
+ ## API Reference
70
+
71
+ ### `css(target, opts?): string`
72
+
73
+ Retrieves CSS text for a given target. Logs the result with rule count and size.
74
+
75
+ **Targets:**
76
+
77
+ | Target | Description |
78
+ |---|---|
79
+ | `'all'` | All tasty CSS (component + global + raw) |
80
+ | `'active'` | CSS for classes currently in the DOM |
81
+ | `'unused'` | CSS for injected classes no element carries (cached but not rendered) |
82
+ | `'global'` | Only global CSS (from `injectGlobal`) |
83
+ | `'page'` | All CSS on the page (including non-tasty) |
84
+ | `'t3a5f'` | CSS for a specific tasty class (class names are `t` + base36 hash) |
85
+ | `['t3a5f', 't9k2']` | CSS for multiple tasty classes |
86
+ | `'.my-button'` | CSS affecting a DOM element (by selector) |
87
+ | `element` | CSS affecting a DOM element (by reference) |
88
+
89
+ **Extra options:**
90
+
91
+ ```typescript
92
+ interface CSSOptions extends DebugOptions {
93
+ prettify?: boolean; // Format output (default: true)
94
+ source?: boolean; // Read original CSS instead of live CSSOM (default: false, dev-mode only)
95
+ }
96
+ ```
97
+
98
+ ```typescript
99
+ // Active CSS with stats
100
+ tastyDebug.css('active');
101
+
102
+ // Specific class, silent
103
+ const css = tastyDebug.css('t3a5f', { raw: true });
104
+
105
+ // Compare original vs browser-parsed CSS (dev mode only)
106
+ tastyDebug.css('t3a5f'); // live CSSOM
107
+ tastyDebug.css('t3a5f', { source: true }); // original output
108
+
109
+ // Shadow DOM
110
+ tastyDebug.css('all', { root: shadowRoot });
111
+ ```
112
+
113
+ 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.
114
+
115
+ ---
116
+
117
+ ### `inspect(target, opts?): InspectResult`
118
+
119
+ Inspects a DOM element and returns detailed information about its tasty styles, including chunk assignments.
120
+
121
+ ```typescript
122
+ interface InspectResult {
123
+ element?: Element | null;
124
+ classes: string[]; // Tasty classes on the element
125
+ chunks: DebugChunkInfo[]; // Chunk assignment per class
126
+ css: string; // Prettified CSS
127
+ size: number; // CSS size in characters
128
+ rules: number; // Number of CSS rule blocks
129
+ }
130
+
131
+ interface DebugChunkInfo {
132
+ className: string;
133
+ chunkName: string | null; // e.g., 'appearance', 'font', 'dimension'
134
+ }
135
+ ```
136
+
137
+ ```typescript
138
+ tastyDebug.inspect('.my-card');
139
+ // Logs: inspect div — 3 classes, 5 rules, 1.2KB
140
+ // Chunks: t3a5f→appearance, t9k2→font, tb71→dimension
141
+
142
+ // Silent
143
+ const result = tastyDebug.inspect('.my-card', { raw: true });
144
+ console.log(result.classes); // ['t3a5f', 't9k2', 'tb71']
145
+ console.log(result.rules); // 5
146
+ ```
147
+
148
+ ---
149
+
150
+ ### `summary(opts?): Summary`
151
+
152
+ One-shot overview of the entire Tasty CSS state. Logs a compact report.
153
+
154
+ ```typescript
155
+ interface Summary {
156
+ activeClasses: string[];
157
+ unusedClasses: string[];
158
+ totalStyledClasses: string[];
159
+
160
+ activeCSSSize: number;
161
+ unusedCSSSize: number;
162
+ globalCSSSize: number;
163
+ rawCSSSize: number;
164
+ keyframesCSSSize: number;
165
+ propertyCSSSize: number;
166
+ totalCSSSize: number;
167
+
168
+ activeRuleCount: number;
169
+ unusedRuleCount: number;
170
+ globalRuleCount: number;
171
+ rawRuleCount: number;
172
+ keyframesRuleCount: number;
173
+ propertyRuleCount: number;
174
+ totalRuleCount: number;
175
+
176
+ metrics: CacheMetrics | null;
177
+ definedProperties: string[];
178
+ definedKeyframes: { name: string; refCount: number }[];
179
+ chunkBreakdown: ChunkBreakdown;
180
+ }
181
+ ```
182
+
183
+ ```typescript
184
+ // Logged automatically
185
+ tastyDebug.summary();
186
+ // Output:
187
+ // Active: 42 classes, 186 rules, 12.4KB
188
+ // Unused: 3 classes, 8 rules, 0.5KB
189
+ // Global: 12 rules, 1.1KB
190
+ // Total: 45 classes, 206 rules, 14.0KB
191
+ // Cache: 94.2% hit rate (312 lookups)
192
+
193
+ // Silent
194
+ const s = tastyDebug.summary({ raw: true });
195
+ console.log(s.totalRuleCount); // 206
196
+ ```
197
+
198
+ ---
199
+
200
+ ### `chunks(opts?): ChunkBreakdown`
201
+
202
+ Breakdown of styles by chunk type.
203
+
204
+ ```typescript
205
+ interface ChunkBreakdown {
206
+ byChunk: Record<string, {
207
+ classes: string[];
208
+ cssSize: number;
209
+ ruleCount: number;
210
+ }>;
211
+ totalChunkTypes: number;
212
+ totalClasses: number;
213
+ }
214
+ ```
215
+
216
+ ```typescript
217
+ tastyDebug.chunks();
218
+ // Output:
219
+ // appearance: 24 cls, 48 rules, 3.2KB
220
+ // font: 18 cls, 18 rules, 1.1KB
221
+ // dimension: 31 cls, 45 rules, 2.4KB
222
+ ```
223
+
224
+ Chunk types: `combined`, `appearance`, `font`, `dimension`, `display`, `layout`, `position`, `misc`, `subcomponents`.
225
+
226
+ ---
227
+
228
+ ### `cache(opts?): CacheStatus`
229
+
230
+ Cache state and performance metrics.
231
+
232
+ ```typescript
233
+ interface CacheStatus {
234
+ classes: {
235
+ active: string[];
236
+ unused: string[];
237
+ all: string[];
238
+ };
239
+ metrics: CacheMetrics | null;
240
+ }
241
+ ```
242
+
243
+ ```typescript
244
+ tastyDebug.cache();
245
+ // Output:
246
+ // Active: 42, Unused: 3
247
+ // Hits: 294, Misses: 18, Rate: 94.2%
248
+ ```
249
+
250
+ ---
251
+
252
+ ### `cleanup(opts?): void`
253
+
254
+ Removes every injected style that is neither carried by an element nor pinned by
255
+ an outstanding `inject()` handle — the same set `summary()` reports as unused.
256
+ Equivalent to `gc({ force: true })`.
257
+
258
+ ```typescript
259
+ tastyDebug.cleanup();
260
+ tastyDebug.cleanup({ root: shadowRoot });
261
+ ```
262
+
263
+ ---
264
+
265
+ ### `help(): void`
266
+
267
+ Prints a quick-start guide to the console.
268
+
269
+ ```typescript
270
+ tastyDebug.help();
271
+ ```
272
+
273
+ ---
274
+
275
+ ### `install(): void`
276
+
277
+ Attaches `tastyDebug` to `window.tastyDebug`.
278
+
279
+ ```typescript
280
+ import { tastyDebug } from '@tenphi/tasty';
281
+ tastyDebug.install();
282
+ ```
283
+
284
+ ---
285
+
286
+ ## Shadow DOM Support
287
+
288
+ All methods accept a `root` option to target a Shadow DOM:
289
+
290
+ ```typescript
291
+ const shadowRoot = host.shadowRoot;
292
+ tastyDebug.css('all', { root: shadowRoot });
293
+ tastyDebug.inspect('.shadow-component', { root: shadowRoot });
294
+ tastyDebug.summary({ root: shadowRoot });
295
+ ```
296
+
297
+ ---
298
+
299
+ ## Common Workflows
300
+
301
+ ### Debugging a component's styles
302
+
303
+ ```typescript
304
+ // 1. Inspect the element
305
+ tastyDebug.inspect('.my-button');
306
+
307
+ // 2. See CSS for a specific class
308
+ tastyDebug.css('t3a5f');
309
+
310
+ // 3. Compare original vs browser-parsed (dev mode)
311
+ tastyDebug.css('t3a5f', { source: true });
312
+ ```
313
+
314
+ ### Checking cache efficiency
315
+
316
+ ```typescript
317
+ const { metrics } = tastyDebug.cache({ raw: true });
318
+ if (metrics) {
319
+ const total = metrics.hits + metrics.misses;
320
+ const rate = total > 0 ? ((metrics.hits / total) * 100).toFixed(1) : 0;
321
+ console.log(`Cache hit rate: ${rate}%`);
322
+ }
323
+ ```
324
+
325
+ ### Monitoring CSS growth
326
+
327
+ ```typescript
328
+ const s = tastyDebug.summary({ raw: true });
329
+ console.log(`Total: ${s.totalRuleCount} rules, ${(s.totalCSSSize / 1024).toFixed(1)}KB`);
330
+ console.log(`Active: ${s.activeRuleCount} rules`);
331
+ console.log(`Unused: ${s.unusedRuleCount} rules`);
332
+ ```