@tenphi/tasty 0.0.0-snapshot.b7bfdb1 → 0.0.0-snapshot.b9638e2

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 (86) hide show
  1. package/dist/astro-B-GRlMsD.js +301 -0
  2. package/dist/astro-B-GRlMsD.js.map +1 -0
  3. package/dist/{babel-Brsw7Ax_.d.ts → babel-Co7AQYZi.d.ts} +2 -2
  4. package/dist/{collector-0YO-P1vW.d.ts → collector-DcFus-on.d.ts} +77 -11
  5. package/dist/collector-lSNHiyV4.js +507 -0
  6. package/dist/collector-lSNHiyV4.js.map +1 -0
  7. package/dist/{config-DsqqkmUs.js → config-0BOip6sG.js} +279 -42
  8. package/dist/config-0BOip6sG.js.map +1 -0
  9. package/dist/{config-CscQCTAM.d.ts → config-CX1uhP_J.d.ts} +64 -14
  10. package/dist/core/index.d.ts +4 -4
  11. package/dist/core/index.js +5 -5
  12. package/dist/{core-KVEKOhEi.js → core-9-MlDDty.js} +323 -80
  13. package/dist/core-9-MlDDty.js.map +1 -0
  14. package/dist/css-resources-Cyl_axbI.js +149 -0
  15. package/dist/css-resources-Cyl_axbI.js.map +1 -0
  16. package/dist/{css-writer-Cdrh5gHj.js → css-writer-Cqwf5R9j.js} +3 -3
  17. package/dist/{css-writer-Cdrh5gHj.js.map → css-writer-Cqwf5R9j.js.map} +1 -1
  18. package/dist/{format-rules-CHNmNGhw.js → format-rules-BDyJWLM4.js} +22 -32
  19. package/dist/format-rules-BDyJWLM4.js.map +1 -0
  20. package/dist/{hydrate-DJhwbWq4.js → hydrate-BO7AdF5u.js} +2 -2
  21. package/dist/{hydrate-DJhwbWq4.js.map → hydrate-BO7AdF5u.js.map} +1 -1
  22. package/dist/{index-BR9as3qn.d.ts → index-DTR1j9lI.d.ts} +14 -12
  23. package/dist/{index-BmogEzTo.d.ts → index-DilKPhLV.d.ts} +9 -1
  24. package/dist/index.d.ts +4 -4
  25. package/dist/index.js +42 -26
  26. package/dist/index.js.map +1 -1
  27. package/dist/{keyframes-CQY-i8dO.js → keyframes-WdECyw4q.js} +25 -3
  28. package/dist/keyframes-WdECyw4q.js.map +1 -0
  29. package/dist/{merge-styles-BcLl1u_d.d.ts → merge-styles-DYO-_fVF.d.ts} +2 -2
  30. package/dist/{merge-styles-voA8J__3.js → merge-styles-a4-oNeJL.js} +2 -2
  31. package/dist/{merge-styles-voA8J__3.js.map → merge-styles-a4-oNeJL.js.map} +1 -1
  32. package/dist/precompile/index.d.ts +11 -0
  33. package/dist/precompile/index.js +67 -0
  34. package/dist/precompile/index.js.map +1 -0
  35. package/dist/precompile/register.d.ts +13 -0
  36. package/dist/precompile/register.js +2 -0
  37. package/dist/register-B_l2owXe.js +164 -0
  38. package/dist/register-B_l2owXe.js.map +1 -0
  39. package/dist/{resolve-recipes-BP2NqOtQ.js → resolve-recipes-C7bE_z63.js} +3 -3
  40. package/dist/{resolve-recipes-BP2NqOtQ.js.map → resolve-recipes-C7bE_z63.js.map} +1 -1
  41. package/dist/ssr/astro-client.js +1 -1
  42. package/dist/ssr/astro-middleware-extract-static.d.ts +11 -0
  43. package/dist/ssr/astro-middleware-extract-static.js +9 -0
  44. package/dist/ssr/astro-middleware-extract-static.js.map +1 -0
  45. package/dist/ssr/astro-middleware-extract.d.ts +11 -0
  46. package/dist/ssr/astro-middleware-extract.js +9 -0
  47. package/dist/ssr/astro-middleware-extract.js.map +1 -0
  48. package/dist/ssr/astro-middleware-static.d.ts +3 -1
  49. package/dist/ssr/astro-middleware-static.js +1 -1
  50. package/dist/ssr/astro-middleware.d.ts +3 -1
  51. package/dist/ssr/astro-middleware.js +1 -1
  52. package/dist/ssr/astro.d.ts +45 -3
  53. package/dist/ssr/astro.js +1 -156
  54. package/dist/ssr/index.d.ts +2 -2
  55. package/dist/ssr/index.js +3 -3
  56. package/dist/ssr/index.js.map +1 -1
  57. package/dist/ssr/next-config.d.ts +66 -0
  58. package/dist/ssr/next-config.js +115 -0
  59. package/dist/ssr/next-config.js.map +1 -0
  60. package/dist/ssr/next.d.ts +9 -2
  61. package/dist/ssr/next.js +26 -9
  62. package/dist/ssr/next.js.map +1 -1
  63. package/dist/ssr-collector-ref-COs_ioWl.js +29 -0
  64. package/dist/ssr-collector-ref-COs_ioWl.js.map +1 -0
  65. package/dist/static/index.d.ts +2 -2
  66. package/dist/static/index.js +1 -1
  67. package/dist/types-DoTCVFsG.d.ts +65 -0
  68. package/dist/zero/babel.d.ts +1 -1
  69. package/dist/zero/babel.js +4 -4
  70. package/dist/zero/babel.js.map +1 -1
  71. package/dist/zero/index.d.ts +1 -1
  72. package/dist/zero/index.js +1 -1
  73. package/dist/zero/next.d.ts +1 -1
  74. package/docs/README.md +3 -1
  75. package/docs/debug.md +11 -4
  76. package/docs/precompile.md +172 -0
  77. package/docs/runtime-benchmarks.md +10 -1
  78. package/docs/ssr.md +179 -20
  79. package/package.json +37 -8
  80. package/dist/collector-DJqx7XO0.js +0 -304
  81. package/dist/collector-DJqx7XO0.js.map +0 -1
  82. package/dist/config-DsqqkmUs.js.map +0 -1
  83. package/dist/core-KVEKOhEi.js.map +0 -1
  84. package/dist/format-rules-CHNmNGhw.js.map +0 -1
  85. package/dist/keyframes-CQY-i8dO.js.map +0 -1
  86. package/dist/ssr/astro.js.map +0 -1
@@ -0,0 +1,507 @@
1
+ import { At as getEffectiveDefinition, Ct as makeClassName, Dt as validateNamePrefix, Kt as parseFunctionName, L as renderStyles, Mt as normalizePropertyDefinition, Ot as hashString, Q as getRegisteredPrecompiledDependencies, Tt as makeKeyframeName, Wt as formatFunctionRule, Z as getPrecompiledRevision, a as getGlobalCounterStyles, ct as formatFontFaceRule, d as getGlobalStyles, f as getNamePrefix, i as getGlobalConfigTokens, it as formatCounterStyleRule, o as getGlobalFontFaces, r as getEffectiveProperties, s as getGlobalFunctions, st as fontFaceContentHash, wt as makeCounterStyleName } from "./config-0BOip6sG.js";
2
+ import { n as formatRulesWithStats, r as formatPropertyCSS } from "./format-rules-BDyJWLM4.js";
3
+ import { t as formatGlobalRules } from "./format-global-rules-DklyaXv-.js";
4
+ //#region src/ssr/collector.ts
5
+ /**
6
+ * ServerStyleCollector — server-safe style collector for SSR.
7
+ *
8
+ * Accumulates CSS rules and cache metadata during server rendering.
9
+ * This is the server-side counterpart to StyleInjector: it allocates
10
+ * hash-based class names using the configured `namePrefix` (defaults
11
+ * to `'t'`), formats CSS rules into text, and tracks rendered class
12
+ * names for lightweight client transfer.
13
+ *
14
+ * One instance is created per HTTP request. Concurrent requests
15
+ * each get their own collector (via AsyncLocalStorage or React context).
16
+ */
17
+ function artifactId(kind, key, css) {
18
+ const content = `${kind}\0${key}\0${css}`;
19
+ return `${kind}:${hashString(content)}:${content.length.toString(36)}`;
20
+ }
21
+ var ServerStyleCollector = class {
22
+ chunks = /* @__PURE__ */ new Map();
23
+ chunkRuleCounts = /* @__PURE__ */ new Map();
24
+ cacheKeyToClassName = /* @__PURE__ */ new Map();
25
+ flushedKeys = /* @__PURE__ */ new Set();
26
+ propertyRules = /* @__PURE__ */ new Map();
27
+ flushedPropertyKeys = /* @__PURE__ */ new Set();
28
+ keyframeRules = /* @__PURE__ */ new Map();
29
+ flushedKeyframeKeys = /* @__PURE__ */ new Set();
30
+ globalStyles = /* @__PURE__ */ new Map();
31
+ flushedGlobalKeys = /* @__PURE__ */ new Set();
32
+ rawCSS = /* @__PURE__ */ new Map();
33
+ flushedRawKeys = /* @__PURE__ */ new Set();
34
+ fontFaceRules = /* @__PURE__ */ new Map();
35
+ flushedFontFaceKeys = /* @__PURE__ */ new Set();
36
+ counterStyleRules = /* @__PURE__ */ new Map();
37
+ flushedCounterStyleKeys = /* @__PURE__ */ new Set();
38
+ functionRules = /* @__PURE__ */ new Map();
39
+ flushedFunctionKeys = /* @__PURE__ */ new Set();
40
+ keyframesCounter = 0;
41
+ counterStyleCounter = 0;
42
+ internalsCollected = false;
43
+ namePrefix;
44
+ artifactSources = /* @__PURE__ */ new Map();
45
+ precompiledChunks = /* @__PURE__ */ new Map();
46
+ precompiledProperties = /* @__PURE__ */ new Map();
47
+ precompiledKeyframes = /* @__PURE__ */ new Map();
48
+ precompiledFontFaces = /* @__PURE__ */ new Set();
49
+ precompiledCounterStyles = /* @__PURE__ */ new Map();
50
+ precompiledFunctions = /* @__PURE__ */ new Set();
51
+ precompiledRSCKeys = /* @__PURE__ */ new Set();
52
+ appliedPrecompiledRevision = -1;
53
+ externalProperties = /* @__PURE__ */ new Set();
54
+ externalKeyframes = /* @__PURE__ */ new Set();
55
+ externalFontFaces = /* @__PURE__ */ new Set();
56
+ externalCounterStyles = /* @__PURE__ */ new Set();
57
+ externalFunctions = /* @__PURE__ */ new Set();
58
+ precompileRecording = false;
59
+ /**
60
+ * @param namePrefix - Optional override for the configured prefix.
61
+ * Defaults to the value from `configure({ namePrefix })` (or `'t'`).
62
+ * Pass an explicit prefix when constructing a collector outside the
63
+ * normal configure() lifecycle (e.g. in tests). Validated eagerly
64
+ * so misconfiguration fails before any CSS is collected.
65
+ */
66
+ constructor(namePrefix) {
67
+ if (namePrefix !== void 0) validateNamePrefix(namePrefix);
68
+ this.namePrefix = namePrefix ?? getNamePrefix();
69
+ this.applyRegisteredPrecompiledDependencies();
70
+ }
71
+ sourceKey(kind, key) {
72
+ return `${kind}\0${key}`;
73
+ }
74
+ setSource(kind, key, source) {
75
+ this.artifactSources.set(this.sourceKey(kind, key), source);
76
+ }
77
+ /** Pick up manifests registered after this collector was constructed. */
78
+ applyRegisteredPrecompiledDependencies() {
79
+ const revision = getPrecompiledRevision();
80
+ if (revision === this.appliedPrecompiledRevision) return;
81
+ this.appliedPrecompiledRevision = revision;
82
+ this.externalProperties.clear();
83
+ this.externalKeyframes.clear();
84
+ this.externalFontFaces.clear();
85
+ this.externalCounterStyles.clear();
86
+ this.externalFunctions.clear();
87
+ if (this.precompileRecording) return;
88
+ const dependencies = getRegisteredPrecompiledDependencies(this.namePrefix);
89
+ for (const item of dependencies.properties) this.externalProperties.add(item.name);
90
+ for (const item of dependencies.keyframes) this.externalKeyframes.add(item.contentKey);
91
+ for (const hash of dependencies.fontFaces) this.externalFontFaces.add(hash);
92
+ for (const item of dependencies.counterStyles) this.externalCounterStyles.add(item.name);
93
+ for (const name of dependencies.functions) this.externalFunctions.add(name);
94
+ }
95
+ generateClassName(cacheKey) {
96
+ return makeClassName(this.namePrefix, hashString(cacheKey));
97
+ }
98
+ /** @internal Enable build-time chunk lookup metadata collection. */
99
+ enablePrecompileRecording() {
100
+ this.precompileRecording = true;
101
+ this.externalProperties.clear();
102
+ this.externalKeyframes.clear();
103
+ this.externalFontFaces.clear();
104
+ this.externalCounterStyles.clear();
105
+ this.externalFunctions.clear();
106
+ }
107
+ /** @internal Whether this collector is producing a catalog artifact. */
108
+ isPrecompileRecording() {
109
+ return this.precompileRecording;
110
+ }
111
+ /**
112
+ * Collect internal @property rules and :root token defaults.
113
+ * Mirrors markStylesGenerated() from the client-side injector.
114
+ * Called automatically on first chunk collection; idempotent.
115
+ *
116
+ * Internals are always emitted here — the RSC path deliberately
117
+ * defers to SSR so that tokens appear exactly once per page in
118
+ * <style data-tasty-ssr> (avoiding duplication of large token sets).
119
+ */
120
+ collectInternals() {
121
+ if (this.internalsCollected) return;
122
+ this.internalsCollected = true;
123
+ for (const [token, definition] of Object.entries(getEffectiveProperties())) {
124
+ const css = formatPropertyCSS(token, definition);
125
+ if (css) {
126
+ const effective = getEffectiveDefinition(token, definition);
127
+ this.collectProperty(`__prop:${token}`, css, {
128
+ source: "config",
129
+ cssName: effective.isValid ? effective.cssName : void 0,
130
+ normalizedDefinition: effective.isValid ? normalizePropertyDefinition(effective.definition) : void 0
131
+ });
132
+ }
133
+ }
134
+ const tokenStyles = getGlobalConfigTokens();
135
+ if (tokenStyles && Object.keys(tokenStyles).length > 0) {
136
+ const tokenRules = renderStyles(tokenStyles, ":root");
137
+ if (tokenRules.length > 0) {
138
+ const css = formatGlobalRules(tokenRules);
139
+ if (css) this.collectGlobalStyles("__global:tokens", css, false, { source: "config" });
140
+ }
141
+ }
142
+ const globalFF = getGlobalFontFaces();
143
+ if (globalFF) for (const [family, input] of Object.entries(globalFF)) {
144
+ const descriptors = Array.isArray(input) ? input : [input];
145
+ for (const desc of descriptors) {
146
+ const hash = fontFaceContentHash(family, desc);
147
+ const css = formatFontFaceRule(family, desc);
148
+ this.collectFontFace(hash, css, { source: "config" });
149
+ }
150
+ }
151
+ const globalCS = getGlobalCounterStyles();
152
+ if (globalCS) for (const [name, descriptors] of Object.entries(globalCS)) {
153
+ const css = formatCounterStyleRule(name, descriptors);
154
+ this.collectCounterStyle(name, css, {
155
+ weak: true,
156
+ source: "config"
157
+ });
158
+ }
159
+ const globalFn = getGlobalFunctions();
160
+ if (globalFn) for (const [name, definition] of Object.entries(globalFn)) {
161
+ const css = formatFunctionRule(name, definition);
162
+ this.collectFunction(parseFunctionName(name), css, {
163
+ weak: true,
164
+ source: "config"
165
+ });
166
+ }
167
+ const globalStyles = getGlobalStyles();
168
+ if (globalStyles) {
169
+ for (const [selector, styles] of Object.entries(globalStyles)) if (Object.keys(styles).length > 0) {
170
+ const rules = renderStyles(styles, selector);
171
+ if (rules.length > 0) {
172
+ const css = formatGlobalRules(rules);
173
+ if (css) this.collectGlobalStyles(`__global:styles:${selector}`, css, false, { source: "config" });
174
+ }
175
+ }
176
+ }
177
+ }
178
+ /**
179
+ * Allocate a className for a cache key, server-side.
180
+ * Mirrors StyleInjector.allocateClassName but without DOM access.
181
+ */
182
+ allocateClassName(cacheKey) {
183
+ const existing = this.cacheKeyToClassName.get(cacheKey);
184
+ if (existing) return {
185
+ className: existing,
186
+ isNewAllocation: false
187
+ };
188
+ const className = this.generateClassName(cacheKey);
189
+ this.cacheKeyToClassName.set(cacheKey, className);
190
+ return {
191
+ className,
192
+ isNewAllocation: true
193
+ };
194
+ }
195
+ /**
196
+ * Record CSS rules for a chunk.
197
+ * Called by useStyles during server render.
198
+ */
199
+ collectChunk(cacheKey, className, rules) {
200
+ if (this.chunks.has(cacheKey)) return;
201
+ const { css, ruleCount } = formatRulesWithStats(rules, className);
202
+ if (css) {
203
+ this.chunks.set(cacheKey, css);
204
+ this.chunkRuleCounts.set(cacheKey, ruleCount);
205
+ this.setSource("chunk", cacheKey, "component");
206
+ }
207
+ }
208
+ /** Record the pre-render lookup key corresponding to a collected chunk. */
209
+ recordPrecompiledChunk(lookupKey, className, animations) {
210
+ if (!this.precompiledChunks.has(lookupKey)) this.precompiledChunks.set(lookupKey, {
211
+ lookupKey,
212
+ className,
213
+ animations: [...animations]
214
+ });
215
+ }
216
+ /**
217
+ * Record a @property rule. Deduplicated by name.
218
+ */
219
+ collectProperty(name, css, options) {
220
+ if (options?.cssName && this.externalProperties.has(options.cssName)) return;
221
+ if (!this.propertyRules.has(name)) {
222
+ this.propertyRules.set(name, css);
223
+ this.setSource("property", name, options?.source ?? "component");
224
+ } else if ((options?.source ?? "component") === "component") this.setSource("property", name, "component");
225
+ if ((options?.source ?? "component") === "component" && options?.cssName && options.normalizedDefinition !== void 0) {
226
+ this.precompiledProperties.set(options.cssName, {
227
+ name: options.cssName,
228
+ definition: options.normalizedDefinition
229
+ });
230
+ if (options.rscKey) this.precompiledRSCKeys.add(options.rscKey);
231
+ }
232
+ }
233
+ /**
234
+ * Record a @keyframes rule. Deduplicated by name.
235
+ */
236
+ collectKeyframes(name, css, options) {
237
+ if (options?.contentKey && this.externalKeyframes.has(options.contentKey)) return;
238
+ if (!this.keyframeRules.has(name)) {
239
+ this.keyframeRules.set(name, css);
240
+ this.setSource("keyframes", name, options?.source ?? "component");
241
+ } else if ((options?.source ?? "component") === "component") this.setSource("keyframes", name, "component");
242
+ if ((options?.source ?? "component") === "component" && options?.contentKey) {
243
+ const existing = this.precompiledKeyframes.get(options.contentKey);
244
+ const rscKeys = new Set(existing?.rscKeys ?? []);
245
+ for (const key of options.rscKeys ?? []) rscKeys.add(key);
246
+ this.precompiledKeyframes.set(options.contentKey, {
247
+ name,
248
+ contentKey: options.contentKey,
249
+ rscKeys: [...rscKeys]
250
+ });
251
+ }
252
+ }
253
+ /**
254
+ * Allocate a keyframe name for SSR. Uses provided name or generates one.
255
+ */
256
+ allocateKeyframeName(providedName) {
257
+ return providedName ?? makeKeyframeName(this.namePrefix, String(this.keyframesCounter++));
258
+ }
259
+ /**
260
+ * Record a @font-face rule. Deduplicated by key (content hash).
261
+ */
262
+ collectFontFace(key, css, options) {
263
+ if (this.externalFontFaces.has(key)) return;
264
+ if (!this.fontFaceRules.has(key)) {
265
+ this.fontFaceRules.set(key, css);
266
+ this.setSource("font-face", key, options?.source ?? "component");
267
+ } else if ((options?.source ?? "component") === "component") this.setSource("font-face", key, "component");
268
+ if ((options?.source ?? "component") === "component") {
269
+ this.precompiledFontFaces.add(key);
270
+ this.precompiledRSCKeys.add(`__ff:${key}`);
271
+ }
272
+ }
273
+ /**
274
+ * Record a @counter-style rule. Deduplicated by name and overrides an
275
+ * existing rule by default. Pass `weak: true` for global `configure()`
276
+ * definitions, which never clobber an existing rule.
277
+ */
278
+ collectCounterStyle(name, css, options) {
279
+ if (this.externalCounterStyles.has(name)) return;
280
+ const source = options?.source ?? "component";
281
+ const existing = this.counterStyleRules.get(name);
282
+ if (existing === void 0) {
283
+ this.counterStyleRules.set(name, css);
284
+ this.setSource("counter-style", name, source);
285
+ if (source === "component") this.precompiledCounterStyles.set(name, {
286
+ name,
287
+ rscKeys: [...options?.rscKeys ?? []]
288
+ });
289
+ return;
290
+ }
291
+ if (source === "component") {
292
+ this.precompiledCounterStyles.set(name, {
293
+ name,
294
+ rscKeys: [...options?.rscKeys ?? []]
295
+ });
296
+ if (existing === css) this.setSource("counter-style", name, "component");
297
+ }
298
+ if (options?.weak || existing === css) return;
299
+ this.counterStyleRules.set(name, css);
300
+ this.setSource("counter-style", name, source);
301
+ if (source === "component") this.precompiledCounterStyles.set(name, {
302
+ name,
303
+ rscKeys: [...options?.rscKeys ?? []]
304
+ });
305
+ this.flushedCounterStyleKeys.delete(name);
306
+ }
307
+ /**
308
+ * Record a @function rule. Deduplicated by CSS function name and overrides an
309
+ * existing rule by default. Pass `weak: true` for global `configure()`
310
+ * definitions, which never clobber an existing rule.
311
+ */
312
+ collectFunction(name, css, options) {
313
+ if (this.externalFunctions.has(name)) return;
314
+ const source = options?.source ?? "component";
315
+ const existing = this.functionRules.get(name);
316
+ if (existing === void 0) {
317
+ this.functionRules.set(name, css);
318
+ this.setSource("function", name, source);
319
+ if (source === "component") {
320
+ this.precompiledFunctions.add(name);
321
+ this.precompiledRSCKeys.add(`__func:${name}`);
322
+ }
323
+ return;
324
+ }
325
+ if (source === "component") {
326
+ this.precompiledFunctions.add(name);
327
+ this.precompiledRSCKeys.add(`__func:${name}`);
328
+ if (existing === css) this.setSource("function", name, "component");
329
+ }
330
+ if (options?.weak || existing === css) return;
331
+ this.functionRules.set(name, css);
332
+ this.setSource("function", name, source);
333
+ if (source === "component") {
334
+ this.precompiledFunctions.add(name);
335
+ this.precompiledRSCKeys.add(`__func:${name}`);
336
+ }
337
+ this.flushedFunctionKeys.delete(name);
338
+ }
339
+ /**
340
+ * Allocate a counter-style name for SSR. Uses provided name or generates one.
341
+ */
342
+ allocateCounterStyleName(providedName) {
343
+ return providedName ?? makeCounterStyleName(this.namePrefix, String(this.counterStyleCounter++));
344
+ }
345
+ /**
346
+ * Record global styles (from useGlobalStyles). Deduplicated by key.
347
+ *
348
+ * Pass `replace` for slot-keyed entries (an explicit `id`), where the last
349
+ * write must win to match the client's update-tracking behavior.
350
+ */
351
+ collectGlobalStyles(key, css, replace, options) {
352
+ if (replace || !this.globalStyles.has(key)) {
353
+ this.globalStyles.set(key, css);
354
+ this.setSource("global", key, options?.source ?? "global");
355
+ }
356
+ }
357
+ /**
358
+ * Record raw CSS text (from useRawCSS). Deduplicated by key.
359
+ *
360
+ * Pass `replace` for slot-keyed entries (an explicit `id`), where the last
361
+ * write must win to match the client's update-tracking behavior.
362
+ */
363
+ collectRawCSS(key, css, replace, options) {
364
+ if (replace || !this.rawCSS.has(key)) {
365
+ this.rawCSS.set(key, css);
366
+ this.setSource("raw", key, options?.source ?? "global");
367
+ }
368
+ }
369
+ getPrecompiledChunks() {
370
+ return [...this.precompiledChunks.values()];
371
+ }
372
+ getPrecompiledDependencies() {
373
+ return {
374
+ properties: [...this.precompiledProperties.values()],
375
+ keyframes: [...this.precompiledKeyframes.values()],
376
+ fontFaces: [...this.precompiledFontFaces],
377
+ counterStyles: [...this.precompiledCounterStyles.values()],
378
+ functions: [...this.precompiledFunctions],
379
+ rscKeys: [...this.precompiledRSCKeys]
380
+ };
381
+ }
382
+ /** @internal Structural top-level rule count for component artifacts. */
383
+ getPrecompiledRuleCount() {
384
+ const isComponent = (kind, key) => (this.artifactSources.get(this.sourceKey(kind, key)) ?? "component") === "component";
385
+ let count = 0;
386
+ for (const key of this.propertyRules.keys()) if (isComponent("property", key)) count++;
387
+ for (const key of this.fontFaceRules.keys()) if (isComponent("font-face", key)) count++;
388
+ for (const key of this.counterStyleRules.keys()) if (isComponent("counter-style", key)) count++;
389
+ for (const key of this.functionRules.keys()) if (isComponent("function", key)) count++;
390
+ for (const key of this.chunks.keys()) if (isComponent("chunk", key)) count += this.chunkRuleCounts.get(key) ?? 0;
391
+ for (const key of this.keyframeRules.keys()) if (isComponent("keyframes", key)) count++;
392
+ return count;
393
+ }
394
+ /**
395
+ * Return the collected CSS as structured, ordered artifacts.
396
+ *
397
+ * Artifact boundaries are part of the collector output so build tools never
398
+ * need to split or parse CSS text. IDs include the logical collection key
399
+ * and content, making them stable across equivalent page renders while a CSS
400
+ * change always produces a different ID.
401
+ */
402
+ getArtifacts() {
403
+ const artifacts = [];
404
+ const append = (kind, entries) => {
405
+ for (const [key, css] of entries) artifacts.push({
406
+ id: artifactId(kind, key, css),
407
+ kind,
408
+ css,
409
+ order: artifacts.length,
410
+ source: this.artifactSources.get(this.sourceKey(kind, key)) ?? "component"
411
+ });
412
+ };
413
+ append("property", this.propertyRules);
414
+ append("font-face", this.fontFaceRules);
415
+ append("counter-style", this.counterStyleRules);
416
+ append("function", this.functionRules);
417
+ append("raw", this.rawCSS);
418
+ append("global", this.globalStyles);
419
+ append("chunk", this.chunks);
420
+ append("keyframes", this.keyframeRules);
421
+ return artifacts;
422
+ }
423
+ /**
424
+ * Extract all CSS collected so far as a single string.
425
+ * Includes @property and @keyframes rules.
426
+ * Used for non-streaming SSR (renderToString).
427
+ */
428
+ getCSS() {
429
+ return this.getArtifacts().map(({ css }) => css).join("\n");
430
+ }
431
+ /**
432
+ * Flush only newly collected CSS since the last flush.
433
+ * Used for streaming SSR (renderToPipeableStream + useServerInsertedHTML).
434
+ */
435
+ flushCSS() {
436
+ const parts = [];
437
+ for (const [name, css] of this.propertyRules) if (!this.flushedPropertyKeys.has(name)) {
438
+ parts.push(css);
439
+ this.flushedPropertyKeys.add(name);
440
+ }
441
+ for (const [key, css] of this.fontFaceRules) if (!this.flushedFontFaceKeys.has(key)) {
442
+ parts.push(css);
443
+ this.flushedFontFaceKeys.add(key);
444
+ }
445
+ for (const [key, css] of this.counterStyleRules) if (!this.flushedCounterStyleKeys.has(key)) {
446
+ parts.push(css);
447
+ this.flushedCounterStyleKeys.add(key);
448
+ }
449
+ for (const [key, css] of this.functionRules) if (!this.flushedFunctionKeys.has(key)) {
450
+ parts.push(css);
451
+ this.flushedFunctionKeys.add(key);
452
+ }
453
+ for (const [key, css] of this.rawCSS) if (!this.flushedRawKeys.has(key)) {
454
+ parts.push(css);
455
+ this.flushedRawKeys.add(key);
456
+ }
457
+ for (const [key, css] of this.globalStyles) if (!this.flushedGlobalKeys.has(key)) {
458
+ parts.push(css);
459
+ this.flushedGlobalKeys.add(key);
460
+ }
461
+ for (const [key, css] of this.chunks) if (!this.flushedKeys.has(key)) {
462
+ parts.push(css);
463
+ this.flushedKeys.add(key);
464
+ }
465
+ for (const [name, css] of this.keyframeRules) if (!this.flushedKeyframeKeys.has(name)) {
466
+ parts.push(css);
467
+ this.flushedKeyframeKeys.add(name);
468
+ }
469
+ return parts.join("\n");
470
+ }
471
+ flushedClassNames = /* @__PURE__ */ new Set();
472
+ /**
473
+ * Return class names rendered since the last call (for streaming).
474
+ * Used to emit lightweight class-list scripts for client hydration.
475
+ */
476
+ getRenderedClassNames() {
477
+ const names = [];
478
+ for (const className of this.cacheKeyToClassName.values()) if (!this.flushedClassNames.has(className)) {
479
+ this.flushedClassNames.add(className);
480
+ names.push(className);
481
+ }
482
+ return names;
483
+ }
484
+ };
485
+ /**
486
+ * Factory for creating a {@link ServerStyleCollector} instance.
487
+ *
488
+ * Canonical functional entry point; the `ServerStyleCollector` class remains
489
+ * exported for advanced/internal use.
490
+ *
491
+ * @param namePrefix - Optional override for the configured class-name prefix.
492
+ * Defaults to the value from `configure({ namePrefix })` (or `'t'`).
493
+ *
494
+ * @example
495
+ * ```ts
496
+ * import { createServerStyleCollector } from '@tenphi/tasty/ssr';
497
+ *
498
+ * const collector = createServerStyleCollector();
499
+ * ```
500
+ */
501
+ function createServerStyleCollector(namePrefix) {
502
+ return new ServerStyleCollector(namePrefix);
503
+ }
504
+ //#endregion
505
+ export { createServerStyleCollector as n, ServerStyleCollector as t };
506
+
507
+ //# sourceMappingURL=collector-lSNHiyV4.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collector-lSNHiyV4.js","names":[],"sources":["../src/ssr/collector.ts"],"sourcesContent":["/**\n * ServerStyleCollector — server-safe style collector for SSR.\n *\n * Accumulates CSS rules and cache metadata during server rendering.\n * This is the server-side counterpart to StyleInjector: it allocates\n * hash-based class names using the configured `namePrefix` (defaults\n * to `'t'`), formats CSS rules into text, and tracks rendered class\n * names for lightweight client transfer.\n *\n * One instance is created per HTTP request. Concurrent requests\n * each get their own collector (via AsyncLocalStorage or React context).\n */\n\nimport {\n getEffectiveProperties,\n getGlobalStyles,\n getGlobalCounterStyles,\n getGlobalFontFaces,\n getGlobalFunctions,\n getGlobalConfigTokens,\n getNamePrefix,\n} from '../config';\nimport { formatCounterStyleRule } from '../counter-style';\nimport { fontFaceContentHash, formatFontFaceRule } from '../font-face';\nimport { formatFunctionRule, parseFunctionName } from '../functions';\nimport { renderStyles } from '../pipeline';\nimport type { StyleResult } from '../pipeline';\nimport {\n getEffectiveDefinition,\n normalizePropertyDefinition,\n} from '../properties';\nimport { hashString } from '../utils/hash';\nimport {\n makeClassName,\n makeCounterStyleName,\n makeKeyframeName,\n validateNamePrefix,\n} from '../utils/name-prefix';\nimport { formatPropertyCSS } from './format-property';\nimport { formatGlobalRules } from './format-global-rules';\nimport { formatRulesWithStats } from './format-rules';\nimport {\n getPrecompiledRevision,\n getRegisteredPrecompiledDependencies,\n} from '../precompile/runtime';\nimport type {\n PrecompiledCounterStyleCacheEntry,\n PrecompiledKeyframeCacheEntry,\n PrecompiledPropertyCacheEntry,\n TastyPrecompiledChunk,\n TastyPrecompiledDependencies,\n TastyStyleArtifactSource,\n} from '../precompile/types';\n\nexport type ServerStyleArtifactKind =\n | 'property'\n | 'font-face'\n | 'counter-style'\n | 'function'\n | 'raw'\n | 'global'\n | 'chunk'\n | 'keyframes';\n\nexport interface ServerStyleArtifact {\n /** Stable identifier derived from the artifact kind, logical key, and CSS. */\n id: string;\n kind: ServerStyleArtifactKind;\n css: string;\n /** Zero-based position in the collector's final cascade order. */\n order: number;\n /** Origin of the rule. */\n source: TastyStyleArtifactSource;\n}\n\ninterface CollectArtifactOptions {\n source?: TastyStyleArtifactSource;\n}\n\ninterface CollectPropertyOptions extends CollectArtifactOptions {\n cssName?: string;\n normalizedDefinition?: string;\n rscKey?: string;\n}\n\ninterface CollectKeyframesOptions extends CollectArtifactOptions {\n contentKey?: string;\n rscKeys?: readonly string[];\n}\n\ninterface CollectCounterStyleOptions extends CollectArtifactOptions {\n weak?: boolean;\n rscKeys?: readonly string[];\n}\n\nfunction artifactId(kind: ServerStyleArtifactKind, key: string, css: string) {\n const content = `${kind}\\0${key}\\0${css}`;\n return `${kind}:${hashString(content)}:${content.length.toString(36)}`;\n}\n\nexport class ServerStyleCollector {\n private chunks = new Map<string, string>();\n private chunkRuleCounts = new Map<string, number>();\n private cacheKeyToClassName = new Map<string, string>();\n private flushedKeys = new Set<string>();\n private propertyRules = new Map<string, string>();\n private flushedPropertyKeys = new Set<string>();\n private keyframeRules = new Map<string, string>();\n private flushedKeyframeKeys = new Set<string>();\n private globalStyles = new Map<string, string>();\n private flushedGlobalKeys = new Set<string>();\n private rawCSS = new Map<string, string>();\n private flushedRawKeys = new Set<string>();\n private fontFaceRules = new Map<string, string>();\n private flushedFontFaceKeys = new Set<string>();\n private counterStyleRules = new Map<string, string>();\n private flushedCounterStyleKeys = new Set<string>();\n private functionRules = new Map<string, string>();\n private flushedFunctionKeys = new Set<string>();\n private keyframesCounter = 0;\n private counterStyleCounter = 0;\n private internalsCollected = false;\n private namePrefix: string;\n private artifactSources = new Map<string, TastyStyleArtifactSource>();\n private precompiledChunks = new Map<string, TastyPrecompiledChunk>();\n private precompiledProperties = new Map<\n string,\n PrecompiledPropertyCacheEntry\n >();\n private precompiledKeyframes = new Map<\n string,\n PrecompiledKeyframeCacheEntry\n >();\n private precompiledFontFaces = new Set<string>();\n private precompiledCounterStyles = new Map<\n string,\n PrecompiledCounterStyleCacheEntry\n >();\n private precompiledFunctions = new Set<string>();\n private precompiledRSCKeys = new Set<string>();\n private appliedPrecompiledRevision = -1;\n private externalProperties = new Set<string>();\n private externalKeyframes = new Set<string>();\n private externalFontFaces = new Set<string>();\n private externalCounterStyles = new Set<string>();\n private externalFunctions = new Set<string>();\n private precompileRecording = false;\n\n /**\n * @param namePrefix - Optional override for the configured prefix.\n * Defaults to the value from `configure({ namePrefix })` (or `'t'`).\n * Pass an explicit prefix when constructing a collector outside the\n * normal configure() lifecycle (e.g. in tests). Validated eagerly\n * so misconfiguration fails before any CSS is collected.\n */\n constructor(namePrefix?: string) {\n if (namePrefix !== undefined) {\n validateNamePrefix(namePrefix);\n }\n this.namePrefix = namePrefix ?? getNamePrefix();\n this.applyRegisteredPrecompiledDependencies();\n }\n\n private sourceKey(kind: ServerStyleArtifactKind, key: string): string {\n return `${kind}\\0${key}`;\n }\n\n private setSource(\n kind: ServerStyleArtifactKind,\n key: string,\n source: TastyStyleArtifactSource,\n ): void {\n this.artifactSources.set(this.sourceKey(kind, key), source);\n }\n\n /** Pick up manifests registered after this collector was constructed. */\n applyRegisteredPrecompiledDependencies(): void {\n const revision = getPrecompiledRevision();\n if (revision === this.appliedPrecompiledRevision) return;\n this.appliedPrecompiledRevision = revision;\n\n this.externalProperties.clear();\n this.externalKeyframes.clear();\n this.externalFontFaces.clear();\n this.externalCounterStyles.clear();\n this.externalFunctions.clear();\n\n // Catalog generation deliberately records a self-contained artifact even\n // when another package registered precompiled styles in this process.\n if (this.precompileRecording) return;\n\n const dependencies = getRegisteredPrecompiledDependencies(this.namePrefix);\n for (const item of dependencies.properties) {\n this.externalProperties.add(item.name);\n }\n for (const item of dependencies.keyframes) {\n this.externalKeyframes.add(item.contentKey);\n }\n for (const hash of dependencies.fontFaces) this.externalFontFaces.add(hash);\n for (const item of dependencies.counterStyles) {\n this.externalCounterStyles.add(item.name);\n }\n for (const name of dependencies.functions) this.externalFunctions.add(name);\n }\n\n private generateClassName(cacheKey: string): string {\n return makeClassName(this.namePrefix, hashString(cacheKey));\n }\n\n /** @internal Enable build-time chunk lookup metadata collection. */\n enablePrecompileRecording(): void {\n this.precompileRecording = true;\n // A catalog build must be self-contained even if this process previously\n // registered another package's manifest.\n this.externalProperties.clear();\n this.externalKeyframes.clear();\n this.externalFontFaces.clear();\n this.externalCounterStyles.clear();\n this.externalFunctions.clear();\n }\n\n /** @internal Whether this collector is producing a catalog artifact. */\n isPrecompileRecording(): boolean {\n return this.precompileRecording;\n }\n\n /**\n * Collect internal @property rules and :root token defaults.\n * Mirrors markStylesGenerated() from the client-side injector.\n * Called automatically on first chunk collection; idempotent.\n *\n * Internals are always emitted here — the RSC path deliberately\n * defers to SSR so that tokens appear exactly once per page in\n * <style data-tasty-ssr> (avoiding duplication of large token sets).\n */\n collectInternals(): void {\n if (this.internalsCollected) return;\n this.internalsCollected = true;\n\n for (const [token, definition] of Object.entries(\n getEffectiveProperties(),\n )) {\n const css = formatPropertyCSS(token, definition);\n if (css) {\n const effective = getEffectiveDefinition(token, definition);\n this.collectProperty(`__prop:${token}`, css, {\n source: 'config',\n cssName: effective.isValid ? effective.cssName : undefined,\n normalizedDefinition: effective.isValid\n ? normalizePropertyDefinition(effective.definition)\n : undefined,\n });\n }\n }\n\n const tokenStyles = getGlobalConfigTokens();\n if (tokenStyles && Object.keys(tokenStyles).length > 0) {\n const tokenRules = renderStyles(tokenStyles, ':root') as StyleResult[];\n if (tokenRules.length > 0) {\n const css = formatGlobalRules(tokenRules);\n if (css) {\n this.collectGlobalStyles('__global:tokens', css, false, {\n source: 'config',\n });\n }\n }\n }\n\n const globalFF = getGlobalFontFaces();\n if (globalFF) {\n for (const [family, input] of Object.entries(globalFF)) {\n const descriptors = Array.isArray(input) ? input : [input];\n for (const desc of descriptors) {\n const hash = fontFaceContentHash(family, desc);\n const css = formatFontFaceRule(family, desc);\n this.collectFontFace(hash, css, { source: 'config' });\n }\n }\n }\n\n const globalCS = getGlobalCounterStyles();\n if (globalCS) {\n for (const [name, descriptors] of Object.entries(globalCS)) {\n const css = formatCounterStyleRule(name, descriptors);\n this.collectCounterStyle(name, css, {\n weak: true,\n source: 'config',\n });\n }\n }\n\n const globalFn = getGlobalFunctions();\n if (globalFn) {\n for (const [name, definition] of Object.entries(globalFn)) {\n const css = formatFunctionRule(name, definition);\n this.collectFunction(parseFunctionName(name), css, {\n weak: true,\n source: 'config',\n });\n }\n }\n\n const globalStyles = getGlobalStyles();\n if (globalStyles) {\n for (const [selector, styles] of Object.entries(globalStyles)) {\n if (Object.keys(styles).length > 0) {\n const rules = renderStyles(styles, selector) as StyleResult[];\n if (rules.length > 0) {\n const css = formatGlobalRules(rules);\n if (css) {\n this.collectGlobalStyles(\n `__global:styles:${selector}`,\n css,\n false,\n { source: 'config' },\n );\n }\n }\n }\n }\n }\n }\n\n /**\n * Allocate a className for a cache key, server-side.\n * Mirrors StyleInjector.allocateClassName but without DOM access.\n */\n allocateClassName(cacheKey: string): {\n className: string;\n isNewAllocation: boolean;\n } {\n const existing = this.cacheKeyToClassName.get(cacheKey);\n if (existing) {\n return { className: existing, isNewAllocation: false };\n }\n\n const className = this.generateClassName(cacheKey);\n this.cacheKeyToClassName.set(cacheKey, className);\n\n return { className, isNewAllocation: true };\n }\n\n /**\n * Record CSS rules for a chunk.\n * Called by useStyles during server render.\n */\n collectChunk(\n cacheKey: string,\n className: string,\n rules: StyleResult[],\n ): void {\n if (this.chunks.has(cacheKey)) return;\n const { css, ruleCount } = formatRulesWithStats(rules, className);\n if (css) {\n this.chunks.set(cacheKey, css);\n this.chunkRuleCounts.set(cacheKey, ruleCount);\n this.setSource('chunk', cacheKey, 'component');\n }\n }\n\n /** Record the pre-render lookup key corresponding to a collected chunk. */\n recordPrecompiledChunk(\n lookupKey: string,\n className: string,\n animations: readonly string[],\n ): void {\n if (!this.precompiledChunks.has(lookupKey)) {\n this.precompiledChunks.set(lookupKey, {\n lookupKey,\n className,\n animations: [...animations],\n });\n }\n }\n\n /**\n * Record a @property rule. Deduplicated by name.\n */\n collectProperty(\n name: string,\n css: string,\n options?: CollectPropertyOptions,\n ): void {\n if (options?.cssName && this.externalProperties.has(options.cssName))\n return;\n if (!this.propertyRules.has(name)) {\n this.propertyRules.set(name, css);\n this.setSource('property', name, options?.source ?? 'component');\n } else if ((options?.source ?? 'component') === 'component') {\n this.setSource('property', name, 'component');\n }\n if (\n (options?.source ?? 'component') === 'component' &&\n options?.cssName &&\n options.normalizedDefinition !== undefined\n ) {\n this.precompiledProperties.set(options.cssName, {\n name: options.cssName,\n definition: options.normalizedDefinition,\n });\n if (options.rscKey) this.precompiledRSCKeys.add(options.rscKey);\n }\n }\n\n /**\n * Record a @keyframes rule. Deduplicated by name.\n */\n collectKeyframes(\n name: string,\n css: string,\n options?: CollectKeyframesOptions,\n ): void {\n if (options?.contentKey && this.externalKeyframes.has(options.contentKey)) {\n return;\n }\n if (!this.keyframeRules.has(name)) {\n this.keyframeRules.set(name, css);\n this.setSource('keyframes', name, options?.source ?? 'component');\n } else if ((options?.source ?? 'component') === 'component') {\n this.setSource('keyframes', name, 'component');\n }\n if (\n (options?.source ?? 'component') === 'component' &&\n options?.contentKey\n ) {\n const existing = this.precompiledKeyframes.get(options.contentKey);\n const rscKeys = new Set(existing?.rscKeys ?? []);\n for (const key of options.rscKeys ?? []) rscKeys.add(key);\n this.precompiledKeyframes.set(options.contentKey, {\n name,\n contentKey: options.contentKey,\n rscKeys: [...rscKeys],\n });\n }\n }\n\n /**\n * Allocate a keyframe name for SSR. Uses provided name or generates one.\n */\n allocateKeyframeName(providedName?: string): string {\n return (\n providedName ??\n makeKeyframeName(this.namePrefix, String(this.keyframesCounter++))\n );\n }\n\n /**\n * Record a @font-face rule. Deduplicated by key (content hash).\n */\n collectFontFace(\n key: string,\n css: string,\n options?: CollectArtifactOptions,\n ): void {\n if (this.externalFontFaces.has(key)) return;\n if (!this.fontFaceRules.has(key)) {\n this.fontFaceRules.set(key, css);\n this.setSource('font-face', key, options?.source ?? 'component');\n } else if ((options?.source ?? 'component') === 'component') {\n this.setSource('font-face', key, 'component');\n }\n if ((options?.source ?? 'component') === 'component') {\n this.precompiledFontFaces.add(key);\n this.precompiledRSCKeys.add(`__ff:${key}`);\n }\n }\n\n /**\n * Record a @counter-style rule. Deduplicated by name and overrides an\n * existing rule by default. Pass `weak: true` for global `configure()`\n * definitions, which never clobber an existing rule.\n */\n collectCounterStyle(\n name: string,\n css: string,\n options?: CollectCounterStyleOptions,\n ): void {\n if (this.externalCounterStyles.has(name)) return;\n const source = options?.source ?? 'component';\n const existing = this.counterStyleRules.get(name);\n if (existing === undefined) {\n this.counterStyleRules.set(name, css);\n this.setSource('counter-style', name, source);\n if (source === 'component') {\n this.precompiledCounterStyles.set(name, {\n name,\n rscKeys: [...(options?.rscKeys ?? [])],\n });\n }\n return;\n }\n if (source === 'component') {\n this.precompiledCounterStyles.set(name, {\n name,\n rscKeys: [...(options?.rscKeys ?? [])],\n });\n if (existing === css) this.setSource('counter-style', name, 'component');\n }\n if (options?.weak || existing === css) return;\n this.counterStyleRules.set(name, css);\n this.setSource('counter-style', name, source);\n if (source === 'component') {\n this.precompiledCounterStyles.set(name, {\n name,\n rscKeys: [...(options?.rscKeys ?? [])],\n });\n }\n // If a rule with this name was already flushed (streaming), allow the\n // overriding rule to be flushed again so it wins by source order.\n this.flushedCounterStyleKeys.delete(name);\n }\n\n /**\n * Record a @function rule. Deduplicated by CSS function name and overrides an\n * existing rule by default. Pass `weak: true` for global `configure()`\n * definitions, which never clobber an existing rule.\n */\n collectFunction(\n name: string,\n css: string,\n options?: { weak?: boolean; source?: TastyStyleArtifactSource },\n ): void {\n if (this.externalFunctions.has(name)) return;\n const source = options?.source ?? 'component';\n const existing = this.functionRules.get(name);\n if (existing === undefined) {\n this.functionRules.set(name, css);\n this.setSource('function', name, source);\n if (source === 'component') {\n this.precompiledFunctions.add(name);\n this.precompiledRSCKeys.add(`__func:${name}`);\n }\n return;\n }\n if (source === 'component') {\n this.precompiledFunctions.add(name);\n this.precompiledRSCKeys.add(`__func:${name}`);\n if (existing === css) this.setSource('function', name, 'component');\n }\n if (options?.weak || existing === css) return;\n this.functionRules.set(name, css);\n this.setSource('function', name, source);\n if (source === 'component') {\n this.precompiledFunctions.add(name);\n this.precompiledRSCKeys.add(`__func:${name}`);\n }\n // If a rule with this name was already flushed (streaming), allow the\n // overriding rule to be flushed again so it wins by source order.\n this.flushedFunctionKeys.delete(name);\n }\n\n /**\n * Allocate a counter-style name for SSR. Uses provided name or generates one.\n */\n allocateCounterStyleName(providedName?: string): string {\n return (\n providedName ??\n makeCounterStyleName(this.namePrefix, String(this.counterStyleCounter++))\n );\n }\n\n /**\n * Record global styles (from useGlobalStyles). Deduplicated by key.\n *\n * Pass `replace` for slot-keyed entries (an explicit `id`), where the last\n * write must win to match the client's update-tracking behavior.\n */\n collectGlobalStyles(\n key: string,\n css: string,\n replace?: boolean,\n options?: CollectArtifactOptions,\n ): void {\n if (replace || !this.globalStyles.has(key)) {\n this.globalStyles.set(key, css);\n this.setSource('global', key, options?.source ?? 'global');\n }\n }\n\n /**\n * Record raw CSS text (from useRawCSS). Deduplicated by key.\n *\n * Pass `replace` for slot-keyed entries (an explicit `id`), where the last\n * write must win to match the client's update-tracking behavior.\n */\n collectRawCSS(\n key: string,\n css: string,\n replace?: boolean,\n options?: CollectArtifactOptions,\n ): void {\n if (replace || !this.rawCSS.has(key)) {\n this.rawCSS.set(key, css);\n this.setSource('raw', key, options?.source ?? 'global');\n }\n }\n\n getPrecompiledChunks(): TastyPrecompiledChunk[] {\n return [...this.precompiledChunks.values()];\n }\n\n getPrecompiledDependencies(): TastyPrecompiledDependencies {\n return {\n properties: [...this.precompiledProperties.values()],\n keyframes: [...this.precompiledKeyframes.values()],\n fontFaces: [...this.precompiledFontFaces],\n counterStyles: [...this.precompiledCounterStyles.values()],\n functions: [...this.precompiledFunctions],\n rscKeys: [...this.precompiledRSCKeys],\n };\n }\n\n /** @internal Structural top-level rule count for component artifacts. */\n getPrecompiledRuleCount(): number {\n const isComponent = (kind: ServerStyleArtifactKind, key: string) =>\n (this.artifactSources.get(this.sourceKey(kind, key)) ?? 'component') ===\n 'component';\n\n let count = 0;\n for (const key of this.propertyRules.keys()) {\n if (isComponent('property', key)) count++;\n }\n for (const key of this.fontFaceRules.keys()) {\n if (isComponent('font-face', key)) count++;\n }\n for (const key of this.counterStyleRules.keys()) {\n if (isComponent('counter-style', key)) count++;\n }\n for (const key of this.functionRules.keys()) {\n if (isComponent('function', key)) count++;\n }\n for (const key of this.chunks.keys()) {\n if (isComponent('chunk', key)) {\n count += this.chunkRuleCounts.get(key) ?? 0;\n }\n }\n for (const key of this.keyframeRules.keys()) {\n if (isComponent('keyframes', key)) count++;\n }\n\n return count;\n }\n\n /**\n * Return the collected CSS as structured, ordered artifacts.\n *\n * Artifact boundaries are part of the collector output so build tools never\n * need to split or parse CSS text. IDs include the logical collection key\n * and content, making them stable across equivalent page renders while a CSS\n * change always produces a different ID.\n */\n getArtifacts(): ServerStyleArtifact[] {\n const artifacts: ServerStyleArtifact[] = [];\n\n const append = (\n kind: ServerStyleArtifactKind,\n entries: Iterable<[string, string]>,\n ) => {\n for (const [key, css] of entries) {\n artifacts.push({\n id: artifactId(kind, key, css),\n kind,\n css,\n order: artifacts.length,\n source:\n this.artifactSources.get(this.sourceKey(kind, key)) ?? 'component',\n });\n }\n };\n\n append('property', this.propertyRules);\n append('font-face', this.fontFaceRules);\n append('counter-style', this.counterStyleRules);\n append('function', this.functionRules);\n append('raw', this.rawCSS);\n append('global', this.globalStyles);\n append('chunk', this.chunks);\n append('keyframes', this.keyframeRules);\n\n return artifacts;\n }\n\n /**\n * Extract all CSS collected so far as a single string.\n * Includes @property and @keyframes rules.\n * Used for non-streaming SSR (renderToString).\n */\n getCSS(): string {\n return this.getArtifacts()\n .map(({ css }) => css)\n .join('\\n');\n }\n\n /**\n * Flush only newly collected CSS since the last flush.\n * Used for streaming SSR (renderToPipeableStream + useServerInsertedHTML).\n */\n flushCSS(): string {\n const parts: string[] = [];\n\n for (const [name, css] of this.propertyRules) {\n if (!this.flushedPropertyKeys.has(name)) {\n parts.push(css);\n this.flushedPropertyKeys.add(name);\n }\n }\n\n for (const [key, css] of this.fontFaceRules) {\n if (!this.flushedFontFaceKeys.has(key)) {\n parts.push(css);\n this.flushedFontFaceKeys.add(key);\n }\n }\n\n for (const [key, css] of this.counterStyleRules) {\n if (!this.flushedCounterStyleKeys.has(key)) {\n parts.push(css);\n this.flushedCounterStyleKeys.add(key);\n }\n }\n\n for (const [key, css] of this.functionRules) {\n if (!this.flushedFunctionKeys.has(key)) {\n parts.push(css);\n this.flushedFunctionKeys.add(key);\n }\n }\n\n for (const [key, css] of this.rawCSS) {\n if (!this.flushedRawKeys.has(key)) {\n parts.push(css);\n this.flushedRawKeys.add(key);\n }\n }\n\n for (const [key, css] of this.globalStyles) {\n if (!this.flushedGlobalKeys.has(key)) {\n parts.push(css);\n this.flushedGlobalKeys.add(key);\n }\n }\n\n for (const [key, css] of this.chunks) {\n if (!this.flushedKeys.has(key)) {\n parts.push(css);\n this.flushedKeys.add(key);\n }\n }\n\n for (const [name, css] of this.keyframeRules) {\n if (!this.flushedKeyframeKeys.has(name)) {\n parts.push(css);\n this.flushedKeyframeKeys.add(name);\n }\n }\n\n return parts.join('\\n');\n }\n\n private flushedClassNames = new Set<string>();\n\n /**\n * Return class names rendered since the last call (for streaming).\n * Used to emit lightweight class-list scripts for client hydration.\n */\n getRenderedClassNames(): string[] {\n const names: string[] = [];\n for (const className of this.cacheKeyToClassName.values()) {\n if (!this.flushedClassNames.has(className)) {\n this.flushedClassNames.add(className);\n names.push(className);\n }\n }\n return names;\n }\n}\n\n/**\n * Factory for creating a {@link ServerStyleCollector} instance.\n *\n * Canonical functional entry point; the `ServerStyleCollector` class remains\n * exported for advanced/internal use.\n *\n * @param namePrefix - Optional override for the configured class-name prefix.\n * Defaults to the value from `configure({ namePrefix })` (or `'t'`).\n *\n * @example\n * ```ts\n * import { createServerStyleCollector } from '@tenphi/tasty/ssr';\n *\n * const collector = createServerStyleCollector();\n * ```\n */\nexport function createServerStyleCollector(\n namePrefix?: string,\n): ServerStyleCollector {\n return new ServerStyleCollector(namePrefix);\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA+FA,SAAS,WAAW,MAA+B,KAAa,KAAa;CAC3E,MAAM,UAAU,GAAG,KAAK,IAAI,IAAI,IAAI;CACpC,OAAO,GAAG,KAAK,GAAG,WAAW,OAAO,EAAE,GAAG,QAAQ,OAAO,SAAS,EAAE;AACrE;AAEA,IAAa,uBAAb,MAAkC;CAChC,yBAAiB,IAAI,IAAoB;CACzC,kCAA0B,IAAI,IAAoB;CAClD,sCAA8B,IAAI,IAAoB;CACtD,8BAAsB,IAAI,IAAY;CACtC,gCAAwB,IAAI,IAAoB;CAChD,sCAA8B,IAAI,IAAY;CAC9C,gCAAwB,IAAI,IAAoB;CAChD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