@tenphi/tasty 0.0.0-snapshot.fdb16ea → 0.0.0-snapshot.fde6cf3

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 (87) hide show
  1. package/dist/astro-Dj8YpRd7.js +301 -0
  2. package/dist/astro-Dj8YpRd7.js.map +1 -0
  3. package/dist/{babel-CMYf4JZ2.d.ts → babel-Cbp2C2bj.d.ts} +2 -2
  4. package/dist/{collector-Ctn5s74s.d.ts → collector-DBY6liC2.d.ts} +94 -11
  5. package/dist/collector-NjmUiB8f.js +529 -0
  6. package/dist/collector-NjmUiB8f.js.map +1 -0
  7. package/dist/{config-B23gZrfP.js → config-Bd2vOF0Z.js} +454 -105
  8. package/dist/config-Bd2vOF0Z.js.map +1 -0
  9. package/dist/{config-CZx8_DCu.d.ts → config-CA7iAlEI.d.ts} +112 -22
  10. package/dist/core/index.d.ts +5 -5
  11. package/dist/core/index.js +6 -6
  12. package/dist/{core-B1tyn69d.js → core-ClInK6YG.js} +386 -107
  13. package/dist/core-ClInK6YG.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-CvAxkR6S.js → css-writer-BDQXG9Jo.js} +3 -3
  17. package/dist/{css-writer-CvAxkR6S.js.map → css-writer-BDQXG9Jo.js.map} +1 -1
  18. package/dist/{format-rules-BCTWVvcS.js → format-rules-CGhgoVLR.js} +22 -32
  19. package/dist/format-rules-CGhgoVLR.js.map +1 -0
  20. package/dist/{hydrate-BCPvkJj3.js → hydrate-CqbxwVh_.js} +2 -2
  21. package/dist/{hydrate-BCPvkJj3.js.map → hydrate-CqbxwVh_.js.map} +1 -1
  22. package/dist/{index-B3o0aCYV.d.ts → index-C8RFYeFW.d.ts} +61 -12
  23. package/dist/{index-CsvB0EXZ.d.ts → index-FpYK0H5g.d.ts} +49 -8
  24. package/dist/index.d.ts +5 -5
  25. package/dist/index.js +43 -27
  26. package/dist/index.js.map +1 -1
  27. package/dist/{keyframes-Dxdx3KOo.js → keyframes-BjfNVhaB.js} +45 -3
  28. package/dist/keyframes-BjfNVhaB.js.map +1 -0
  29. package/dist/{merge-styles-DJTSfz_M.d.ts → merge-styles-BQv7d3fx.d.ts} +2 -2
  30. package/dist/{merge-styles-C-uwpoNW.js → merge-styles-BbJhjesV.js} +2 -2
  31. package/dist/{merge-styles-C-uwpoNW.js.map → merge-styles-BbJhjesV.js.map} +1 -1
  32. package/dist/precompile/index.d.ts +11 -0
  33. package/dist/precompile/index.js +72 -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-BkC-8Zuy.js +333 -0
  38. package/dist/register-BkC-8Zuy.js.map +1 -0
  39. package/dist/{resolve-recipes-BuOvSEa2.js → resolve-recipes-B2Sf36AH.js} +3 -3
  40. package/dist/{resolve-recipes-BuOvSEa2.js.map → resolve-recipes-B2Sf36AH.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-Bo5ePLZh.d.ts +111 -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 +17 -6
  76. package/docs/injector.md +23 -3
  77. package/docs/precompile.md +202 -0
  78. package/docs/runtime-benchmarks.md +143 -72
  79. package/docs/ssr.md +179 -20
  80. package/package.json +44 -10
  81. package/dist/collector-DMSR6ANK.js +0 -304
  82. package/dist/collector-DMSR6ANK.js.map +0 -1
  83. package/dist/config-B23gZrfP.js.map +0 -1
  84. package/dist/core-B1tyn69d.js.map +0 -1
  85. package/dist/format-rules-BCTWVvcS.js.map +0 -1
  86. package/dist/keyframes-Dxdx3KOo.js.map +0 -1
  87. package/dist/ssr/astro.js.map +0 -1
@@ -0,0 +1,529 @@
1
+ import { $ as getRegisteredPrecompiledDependencies, Et as makeKeyframeName, Gt as formatFunctionRule, Nt as normalizePropertyDefinition, Ot as validateNamePrefix, Q as getPrecompiledRevision, R as renderStyles, Tt as makeCounterStyleName, a as getGlobalConfigTokens, at as formatCounterStyleRule, c as getGlobalFunctions, ct as fontFaceContentHash, f as getGlobalStyles, i as getEffectiveProperties, jt as getEffectiveDefinition, kt as hashString, lt as formatFontFaceRule, o as getGlobalCounterStyles, p as getNamePrefix, qt as parseFunctionName, s as getGlobalFontFaces, wt as makeClassName } from "./config-Bd2vOF0Z.js";
2
+ import { n as formatRulesWithStats, r as formatPropertyCSS } from "./format-rules-CGhgoVLR.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
+ }
70
+ sourceKey(kind, key) {
71
+ return `${kind}\0${key}`;
72
+ }
73
+ setSource(kind, key, source) {
74
+ this.artifactSources.set(this.sourceKey(kind, key), source);
75
+ }
76
+ /**
77
+ * Pick up manifests registered after this collector was constructed.
78
+ *
79
+ * Deliberately not called from the constructor. Reading the registered
80
+ * dependencies is what validates the catalogs against the host's
81
+ * configuration, and registration is a side-effect import that routinely
82
+ * runs before the host's own `configure()` call — so a collector built in
83
+ * between would validate against defaults and permanently drop a catalog
84
+ * that matches once configuration is installed.
85
+ *
86
+ * Instead every method that consults an `external*` set calls this first, so
87
+ * the seed lands at whichever style-producing operation happens to come
88
+ * first. That gate belongs here rather than at the call sites: the standalone
89
+ * at-rule hooks (`useKeyframes`, `useCounterStyle`, `useFontFace`) go
90
+ * straight to `collect*` and never reach `collectInternals()`, so a catalog's
91
+ * standalone rule would otherwise be emitted a second time during SSR.
92
+ * After the first call this is an integer comparison.
93
+ */
94
+ applyRegisteredPrecompiledDependencies() {
95
+ const revision = getPrecompiledRevision();
96
+ if (revision === this.appliedPrecompiledRevision) return;
97
+ this.appliedPrecompiledRevision = revision;
98
+ this.externalProperties.clear();
99
+ this.externalKeyframes.clear();
100
+ this.externalFontFaces.clear();
101
+ this.externalCounterStyles.clear();
102
+ this.externalFunctions.clear();
103
+ if (this.precompileRecording) return;
104
+ const dependencies = getRegisteredPrecompiledDependencies(this.namePrefix);
105
+ for (const item of dependencies.properties) this.externalProperties.add(item.name);
106
+ for (const item of dependencies.keyframes) this.externalKeyframes.add(item.contentKey);
107
+ for (const hash of dependencies.fontFaces) this.externalFontFaces.add(hash);
108
+ for (const item of dependencies.counterStyles) this.externalCounterStyles.add(item.name);
109
+ for (const name of dependencies.functions) this.externalFunctions.add(name);
110
+ }
111
+ generateClassName(cacheKey) {
112
+ return makeClassName(this.namePrefix, hashString(cacheKey));
113
+ }
114
+ /** @internal Enable build-time chunk lookup metadata collection. */
115
+ enablePrecompileRecording() {
116
+ this.precompileRecording = true;
117
+ this.externalProperties.clear();
118
+ this.externalKeyframes.clear();
119
+ this.externalFontFaces.clear();
120
+ this.externalCounterStyles.clear();
121
+ this.externalFunctions.clear();
122
+ }
123
+ /** @internal Whether this collector is producing a catalog artifact. */
124
+ isPrecompileRecording() {
125
+ return this.precompileRecording;
126
+ }
127
+ /**
128
+ * Collect internal @property rules and :root token defaults.
129
+ * Mirrors markStylesGenerated() from the client-side injector.
130
+ * Called automatically on first chunk collection; idempotent.
131
+ *
132
+ * Internals are always emitted here — the RSC path deliberately
133
+ * defers to SSR so that tokens appear exactly once per page in
134
+ * <style data-tasty-ssr> (avoiding duplication of large token sets).
135
+ */
136
+ collectInternals() {
137
+ if (this.internalsCollected) return;
138
+ this.internalsCollected = true;
139
+ this.applyRegisteredPrecompiledDependencies();
140
+ for (const [token, definition] of Object.entries(getEffectiveProperties())) {
141
+ const css = formatPropertyCSS(token, definition);
142
+ if (css) {
143
+ const effective = getEffectiveDefinition(token, definition);
144
+ this.collectProperty(`__prop:${token}`, css, {
145
+ source: "config",
146
+ cssName: effective.isValid ? effective.cssName : void 0,
147
+ normalizedDefinition: effective.isValid ? normalizePropertyDefinition(effective.definition) : void 0
148
+ });
149
+ }
150
+ }
151
+ const tokenStyles = getGlobalConfigTokens();
152
+ if (tokenStyles && Object.keys(tokenStyles).length > 0) {
153
+ const tokenRules = renderStyles(tokenStyles, ":root");
154
+ if (tokenRules.length > 0) {
155
+ const css = formatGlobalRules(tokenRules);
156
+ if (css) this.collectGlobalStyles("__global:tokens", css, false, { source: "config" });
157
+ }
158
+ }
159
+ const globalFF = getGlobalFontFaces();
160
+ if (globalFF) for (const [family, input] of Object.entries(globalFF)) {
161
+ const descriptors = Array.isArray(input) ? input : [input];
162
+ for (const desc of descriptors) {
163
+ const hash = fontFaceContentHash(family, desc);
164
+ const css = formatFontFaceRule(family, desc);
165
+ this.collectFontFace(hash, css, { source: "config" });
166
+ }
167
+ }
168
+ const globalCS = getGlobalCounterStyles();
169
+ if (globalCS) for (const [name, descriptors] of Object.entries(globalCS)) {
170
+ const css = formatCounterStyleRule(name, descriptors);
171
+ this.collectCounterStyle(name, css, {
172
+ weak: true,
173
+ source: "config"
174
+ });
175
+ }
176
+ const globalFn = getGlobalFunctions();
177
+ if (globalFn) for (const [name, definition] of Object.entries(globalFn)) {
178
+ const css = formatFunctionRule(name, definition);
179
+ this.collectFunction(parseFunctionName(name), css, {
180
+ weak: true,
181
+ source: "config"
182
+ });
183
+ }
184
+ const globalStyles = getGlobalStyles();
185
+ if (globalStyles) {
186
+ for (const [selector, styles] of Object.entries(globalStyles)) if (Object.keys(styles).length > 0) {
187
+ const rules = renderStyles(styles, selector);
188
+ if (rules.length > 0) {
189
+ const css = formatGlobalRules(rules);
190
+ if (css) this.collectGlobalStyles(`__global:styles:${selector}`, css, false, { source: "config" });
191
+ }
192
+ }
193
+ }
194
+ }
195
+ /**
196
+ * Allocate a className for a cache key, server-side.
197
+ * Mirrors StyleInjector.allocateClassName but without DOM access.
198
+ */
199
+ allocateClassName(cacheKey) {
200
+ const existing = this.cacheKeyToClassName.get(cacheKey);
201
+ if (existing) return {
202
+ className: existing,
203
+ isNewAllocation: false
204
+ };
205
+ const className = this.generateClassName(cacheKey);
206
+ this.cacheKeyToClassName.set(cacheKey, className);
207
+ return {
208
+ className,
209
+ isNewAllocation: true
210
+ };
211
+ }
212
+ /**
213
+ * Record CSS rules for a chunk.
214
+ * Called by useStyles during server render.
215
+ */
216
+ collectChunk(cacheKey, className, rules) {
217
+ if (this.chunks.has(cacheKey)) return;
218
+ const { css, ruleCount } = formatRulesWithStats(rules, className);
219
+ if (css) {
220
+ this.chunks.set(cacheKey, css);
221
+ this.chunkRuleCounts.set(cacheKey, ruleCount);
222
+ this.setSource("chunk", cacheKey, "component");
223
+ }
224
+ }
225
+ /** Record the pre-render lookup key corresponding to a collected chunk. */
226
+ recordPrecompiledChunk(lookupKey, className, animations) {
227
+ if (!this.precompiledChunks.has(lookupKey)) this.precompiledChunks.set(lookupKey, {
228
+ lookupKey,
229
+ className,
230
+ animations: [...animations]
231
+ });
232
+ }
233
+ /**
234
+ * Record a @property rule. Deduplicated by name.
235
+ */
236
+ collectProperty(name, css, options) {
237
+ this.applyRegisteredPrecompiledDependencies();
238
+ if (options?.cssName && this.externalProperties.has(options.cssName)) return;
239
+ if (!this.propertyRules.has(name)) {
240
+ this.propertyRules.set(name, css);
241
+ this.setSource("property", name, options?.source ?? "component");
242
+ } else if ((options?.source ?? "component") === "component") this.setSource("property", name, "component");
243
+ if ((options?.source ?? "component") === "component" && options?.cssName && options.normalizedDefinition !== void 0) {
244
+ this.precompiledProperties.set(options.cssName, {
245
+ name: options.cssName,
246
+ definition: options.normalizedDefinition
247
+ });
248
+ if (options.rscKey) this.precompiledRSCKeys.add(options.rscKey);
249
+ }
250
+ }
251
+ /**
252
+ * Record a @keyframes rule. Deduplicated by name.
253
+ */
254
+ collectKeyframes(name, css, options) {
255
+ this.applyRegisteredPrecompiledDependencies();
256
+ if (options?.contentKey && this.externalKeyframes.has(options.contentKey)) return;
257
+ if (!this.keyframeRules.has(name)) {
258
+ this.keyframeRules.set(name, css);
259
+ this.setSource("keyframes", name, options?.source ?? "component");
260
+ } else if ((options?.source ?? "component") === "component") this.setSource("keyframes", name, "component");
261
+ if ((options?.source ?? "component") === "component" && options?.contentKey) {
262
+ const existing = this.precompiledKeyframes.get(options.contentKey);
263
+ const rscKeys = new Set(existing?.rscKeys ?? []);
264
+ for (const key of options.rscKeys ?? []) rscKeys.add(key);
265
+ this.precompiledKeyframes.set(options.contentKey, {
266
+ name,
267
+ contentKey: options.contentKey,
268
+ rscKeys: [...rscKeys]
269
+ });
270
+ }
271
+ }
272
+ /**
273
+ * Allocate a keyframe name for SSR. Uses provided name or generates one.
274
+ */
275
+ allocateKeyframeName(providedName) {
276
+ return providedName ?? makeKeyframeName(this.namePrefix, String(this.keyframesCounter++));
277
+ }
278
+ /**
279
+ * Record a @font-face rule. Deduplicated by key (content hash).
280
+ */
281
+ collectFontFace(key, css, options) {
282
+ this.applyRegisteredPrecompiledDependencies();
283
+ if (this.externalFontFaces.has(key)) return;
284
+ if (!this.fontFaceRules.has(key)) {
285
+ this.fontFaceRules.set(key, css);
286
+ this.setSource("font-face", key, options?.source ?? "component");
287
+ } else if ((options?.source ?? "component") === "component") this.setSource("font-face", key, "component");
288
+ if ((options?.source ?? "component") === "component") {
289
+ this.precompiledFontFaces.add(key);
290
+ this.precompiledRSCKeys.add(`__ff:${key}`);
291
+ }
292
+ }
293
+ /**
294
+ * Record a @counter-style rule. Deduplicated by name and overrides an
295
+ * existing rule by default. Pass `weak: true` for global `configure()`
296
+ * definitions, which never clobber an existing rule.
297
+ */
298
+ collectCounterStyle(name, css, options) {
299
+ this.applyRegisteredPrecompiledDependencies();
300
+ if (this.externalCounterStyles.has(name)) return;
301
+ const source = options?.source ?? "component";
302
+ const existing = this.counterStyleRules.get(name);
303
+ if (existing === void 0) {
304
+ this.counterStyleRules.set(name, css);
305
+ this.setSource("counter-style", name, source);
306
+ if (source === "component") this.precompiledCounterStyles.set(name, {
307
+ name,
308
+ rscKeys: [...options?.rscKeys ?? []]
309
+ });
310
+ return;
311
+ }
312
+ if (source === "component") {
313
+ this.precompiledCounterStyles.set(name, {
314
+ name,
315
+ rscKeys: [...options?.rscKeys ?? []]
316
+ });
317
+ if (existing === css) this.setSource("counter-style", name, "component");
318
+ }
319
+ if (options?.weak || existing === css) return;
320
+ this.counterStyleRules.set(name, css);
321
+ this.setSource("counter-style", name, source);
322
+ if (source === "component") this.precompiledCounterStyles.set(name, {
323
+ name,
324
+ rscKeys: [...options?.rscKeys ?? []]
325
+ });
326
+ this.flushedCounterStyleKeys.delete(name);
327
+ }
328
+ /**
329
+ * Record a @function rule. Deduplicated by CSS function name and overrides an
330
+ * existing rule by default. Pass `weak: true` for global `configure()`
331
+ * definitions, which never clobber an existing rule.
332
+ */
333
+ collectFunction(name, css, options) {
334
+ this.applyRegisteredPrecompiledDependencies();
335
+ if (this.externalFunctions.has(name)) return;
336
+ const source = options?.source ?? "component";
337
+ const existing = this.functionRules.get(name);
338
+ if (existing === void 0) {
339
+ this.functionRules.set(name, css);
340
+ this.setSource("function", name, source);
341
+ if (source === "component") {
342
+ this.precompiledFunctions.add(name);
343
+ this.precompiledRSCKeys.add(`__func:${name}`);
344
+ }
345
+ return;
346
+ }
347
+ if (source === "component") {
348
+ this.precompiledFunctions.add(name);
349
+ this.precompiledRSCKeys.add(`__func:${name}`);
350
+ if (existing === css) this.setSource("function", name, "component");
351
+ }
352
+ if (options?.weak || existing === css) return;
353
+ this.functionRules.set(name, css);
354
+ this.setSource("function", name, source);
355
+ if (source === "component") {
356
+ this.precompiledFunctions.add(name);
357
+ this.precompiledRSCKeys.add(`__func:${name}`);
358
+ }
359
+ this.flushedFunctionKeys.delete(name);
360
+ }
361
+ /**
362
+ * Allocate a counter-style name for SSR. Uses provided name or generates one.
363
+ */
364
+ allocateCounterStyleName(providedName) {
365
+ return providedName ?? makeCounterStyleName(this.namePrefix, String(this.counterStyleCounter++));
366
+ }
367
+ /**
368
+ * Record global styles (from useGlobalStyles). Deduplicated by key.
369
+ *
370
+ * Pass `replace` for slot-keyed entries (an explicit `id`), where the last
371
+ * write must win to match the client's update-tracking behavior.
372
+ */
373
+ collectGlobalStyles(key, css, replace, options) {
374
+ if (replace || !this.globalStyles.has(key)) {
375
+ this.globalStyles.set(key, css);
376
+ this.setSource("global", key, options?.source ?? "global");
377
+ }
378
+ }
379
+ /**
380
+ * Record raw CSS text (from useRawCSS). Deduplicated by key.
381
+ *
382
+ * Pass `replace` for slot-keyed entries (an explicit `id`), where the last
383
+ * write must win to match the client's update-tracking behavior.
384
+ */
385
+ collectRawCSS(key, css, replace, options) {
386
+ if (replace || !this.rawCSS.has(key)) {
387
+ this.rawCSS.set(key, css);
388
+ this.setSource("raw", key, options?.source ?? "global");
389
+ }
390
+ }
391
+ getPrecompiledChunks() {
392
+ return [...this.precompiledChunks.values()];
393
+ }
394
+ getPrecompiledDependencies() {
395
+ return {
396
+ properties: [...this.precompiledProperties.values()],
397
+ keyframes: [...this.precompiledKeyframes.values()],
398
+ fontFaces: [...this.precompiledFontFaces],
399
+ counterStyles: [...this.precompiledCounterStyles.values()],
400
+ functions: [...this.precompiledFunctions],
401
+ rscKeys: [...this.precompiledRSCKeys]
402
+ };
403
+ }
404
+ /** @internal Structural top-level rule count for component artifacts. */
405
+ getPrecompiledRuleCount() {
406
+ const isComponent = (kind, key) => (this.artifactSources.get(this.sourceKey(kind, key)) ?? "component") === "component";
407
+ let count = 0;
408
+ for (const key of this.propertyRules.keys()) if (isComponent("property", key)) count++;
409
+ for (const key of this.fontFaceRules.keys()) if (isComponent("font-face", key)) count++;
410
+ for (const key of this.counterStyleRules.keys()) if (isComponent("counter-style", key)) count++;
411
+ for (const key of this.functionRules.keys()) if (isComponent("function", key)) count++;
412
+ for (const key of this.chunks.keys()) if (isComponent("chunk", key)) count += this.chunkRuleCounts.get(key) ?? 0;
413
+ for (const key of this.keyframeRules.keys()) if (isComponent("keyframes", key)) count++;
414
+ return count;
415
+ }
416
+ /**
417
+ * Return the collected CSS as structured, ordered artifacts.
418
+ *
419
+ * Artifact boundaries are part of the collector output so build tools never
420
+ * need to split or parse CSS text. IDs include the logical collection key
421
+ * and content, making them stable across equivalent page renders while a CSS
422
+ * change always produces a different ID.
423
+ */
424
+ getArtifacts() {
425
+ const artifacts = [];
426
+ const append = (kind, entries) => {
427
+ for (const [key, css] of entries) artifacts.push({
428
+ id: artifactId(kind, key, css),
429
+ kind,
430
+ css,
431
+ order: artifacts.length,
432
+ source: this.artifactSources.get(this.sourceKey(kind, key)) ?? "component"
433
+ });
434
+ };
435
+ append("property", this.propertyRules);
436
+ append("font-face", this.fontFaceRules);
437
+ append("counter-style", this.counterStyleRules);
438
+ append("function", this.functionRules);
439
+ append("raw", this.rawCSS);
440
+ append("global", this.globalStyles);
441
+ append("chunk", this.chunks);
442
+ append("keyframes", this.keyframeRules);
443
+ return artifacts;
444
+ }
445
+ /**
446
+ * Extract all CSS collected so far as a single string.
447
+ * Includes @property and @keyframes rules.
448
+ * Used for non-streaming SSR (renderToString).
449
+ */
450
+ getCSS() {
451
+ return this.getArtifacts().map(({ css }) => css).join("\n");
452
+ }
453
+ /**
454
+ * Flush only newly collected CSS since the last flush.
455
+ * Used for streaming SSR (renderToPipeableStream + useServerInsertedHTML).
456
+ */
457
+ flushCSS() {
458
+ const parts = [];
459
+ for (const [name, css] of this.propertyRules) if (!this.flushedPropertyKeys.has(name)) {
460
+ parts.push(css);
461
+ this.flushedPropertyKeys.add(name);
462
+ }
463
+ for (const [key, css] of this.fontFaceRules) if (!this.flushedFontFaceKeys.has(key)) {
464
+ parts.push(css);
465
+ this.flushedFontFaceKeys.add(key);
466
+ }
467
+ for (const [key, css] of this.counterStyleRules) if (!this.flushedCounterStyleKeys.has(key)) {
468
+ parts.push(css);
469
+ this.flushedCounterStyleKeys.add(key);
470
+ }
471
+ for (const [key, css] of this.functionRules) if (!this.flushedFunctionKeys.has(key)) {
472
+ parts.push(css);
473
+ this.flushedFunctionKeys.add(key);
474
+ }
475
+ for (const [key, css] of this.rawCSS) if (!this.flushedRawKeys.has(key)) {
476
+ parts.push(css);
477
+ this.flushedRawKeys.add(key);
478
+ }
479
+ for (const [key, css] of this.globalStyles) if (!this.flushedGlobalKeys.has(key)) {
480
+ parts.push(css);
481
+ this.flushedGlobalKeys.add(key);
482
+ }
483
+ for (const [key, css] of this.chunks) if (!this.flushedKeys.has(key)) {
484
+ parts.push(css);
485
+ this.flushedKeys.add(key);
486
+ }
487
+ for (const [name, css] of this.keyframeRules) if (!this.flushedKeyframeKeys.has(name)) {
488
+ parts.push(css);
489
+ this.flushedKeyframeKeys.add(name);
490
+ }
491
+ return parts.join("\n");
492
+ }
493
+ flushedClassNames = /* @__PURE__ */ new Set();
494
+ /**
495
+ * Return class names rendered since the last call (for streaming).
496
+ * Used to emit lightweight class-list scripts for client hydration.
497
+ */
498
+ getRenderedClassNames() {
499
+ const names = [];
500
+ for (const className of this.cacheKeyToClassName.values()) if (!this.flushedClassNames.has(className)) {
501
+ this.flushedClassNames.add(className);
502
+ names.push(className);
503
+ }
504
+ return names;
505
+ }
506
+ };
507
+ /**
508
+ * Factory for creating a {@link ServerStyleCollector} instance.
509
+ *
510
+ * Canonical functional entry point; the `ServerStyleCollector` class remains
511
+ * exported for advanced/internal use.
512
+ *
513
+ * @param namePrefix - Optional override for the configured class-name prefix.
514
+ * Defaults to the value from `configure({ namePrefix })` (or `'t'`).
515
+ *
516
+ * @example
517
+ * ```ts
518
+ * import { createServerStyleCollector } from '@tenphi/tasty/ssr';
519
+ *
520
+ * const collector = createServerStyleCollector();
521
+ * ```
522
+ */
523
+ function createServerStyleCollector(namePrefix) {
524
+ return new ServerStyleCollector(namePrefix);
525
+ }
526
+ //#endregion
527
+ export { createServerStyleCollector as n, ServerStyleCollector as t };
528
+
529
+ //# sourceMappingURL=collector-NjmUiB8f.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collector-NjmUiB8f.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 }\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 /**\n * Pick up manifests registered after this collector was constructed.\n *\n * Deliberately not called from the constructor. Reading the registered\n * dependencies is what validates the catalogs against the host's\n * configuration, and registration is a side-effect import that routinely\n * runs before the host's own `configure()` call — so a collector built in\n * between would validate against defaults and permanently drop a catalog\n * that matches once configuration is installed.\n *\n * Instead every method that consults an `external*` set calls this first, so\n * the seed lands at whichever style-producing operation happens to come\n * first. That gate belongs here rather than at the call sites: the standalone\n * at-rule hooks (`useKeyframes`, `useCounterStyle`, `useFontFace`) go\n * straight to `collect*` and never reach `collectInternals()`, so a catalog's\n * standalone rule would otherwise be emitted a second time during SSR.\n * After the first call this is an integer comparison.\n */\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 this.applyRegisteredPrecompiledDependencies();\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 this.applyRegisteredPrecompiledDependencies();\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 this.applyRegisteredPrecompiledDependencies();\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 this.applyRegisteredPrecompiledDependencies();\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 this.applyRegisteredPrecompiledDependencies();\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 this.applyRegisteredPrecompiledDependencies();\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,sCAA8B,IAAI,IAAY;CAC9C,+BAAuB,IAAI,IAAoB;CAC/C,oCAA4B,IAAI,IAAY;CAC5C,yB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