@tenphi/tasty 0.0.0-snapshot.f144f3c → 0.0.0-snapshot.f164b44

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 (124) hide show
  1. package/README.md +408 -385
  2. package/dist/babel-types-BOABQvEI.d.ts +16 -0
  3. package/dist/chunks/async-storage-CzSKAyrI.js +36 -0
  4. package/dist/chunks/async-storage-CzSKAyrI.js.map +1 -0
  5. package/dist/chunks/build-config-gH3yWcDL.js +59 -0
  6. package/dist/chunks/build-config-gH3yWcDL.js.map +1 -0
  7. package/dist/chunks/{collector-HR9noXq_.js → collector-Dfs575jY.js} +9 -118
  8. package/dist/chunks/collector-Dfs575jY.js.map +1 -0
  9. package/dist/chunks/{config-engine-DabuZ55f.js → config-engine-C7OUmM1J.js} +21 -83
  10. package/dist/chunks/config-engine-C7OUmM1J.js.map +1 -0
  11. package/dist/chunks/config-file-BX3F_61U.js +24 -0
  12. package/dist/chunks/config-file-BX3F_61U.js.map +1 -0
  13. package/dist/chunks/{css-definitions-z79zG4t4.js → css-definitions-BkdTqT7G.js} +146 -479
  14. package/dist/chunks/css-definitions-BkdTqT7G.js.map +1 -0
  15. package/dist/chunks/{css-resources-Cyl_axbI.js → css-resources-C0zT36nQ.js} +3 -11
  16. package/dist/chunks/{css-resources-Cyl_axbI.js.map → css-resources-C0zT36nQ.js.map} +1 -1
  17. package/dist/chunks/{debug-FLjTrfFW.js → debug-BJfa2m9o.js} +68 -143
  18. package/dist/chunks/debug-BJfa2m9o.js.map +1 -0
  19. package/dist/chunks/{dsl-BVhxBy6V.js → dsl-BAwiOznp.js} +220 -693
  20. package/dist/chunks/dsl-BAwiOznp.js.map +1 -0
  21. package/dist/chunks/{hydration-CLdVKcH2.js → hydration-DEmoq1sQ.js} +3 -23
  22. package/dist/chunks/{hydration-CLdVKcH2.js.map → hydration-DEmoq1sQ.js.map} +1 -1
  23. package/dist/chunks/react-runtime-B8YqpFx7.js +678 -0
  24. package/dist/chunks/react-runtime-B8YqpFx7.js.map +1 -0
  25. package/dist/chunks/{runtime-engine-BYEGKOF1.js → runtime-engine-CHNH2nGy.js} +130 -1164
  26. package/dist/chunks/runtime-engine-CHNH2nGy.js.map +1 -0
  27. package/dist/chunks/{runtime-state-icjb9GAD.js → runtime-state-BxLKsQzs.js} +30 -18
  28. package/dist/chunks/runtime-state-BxLKsQzs.js.map +1 -0
  29. package/dist/chunks/{shared-utils-OIg0N_dp.js → shared-utils-CYgOs2mp.js} +34 -72
  30. package/dist/chunks/shared-utils-CYgOs2mp.js.map +1 -0
  31. package/dist/chunks/{style-engine-C34heV9d.js → style-engine-DkKH-TqL.js} +1083 -2430
  32. package/dist/chunks/style-engine-DkKH-TqL.js.map +1 -0
  33. package/dist/chunks/{zero-engine-DkyjChVU.js → zero-engine-BpDeQsNO.js} +67 -149
  34. package/dist/chunks/zero-engine-BpDeQsNO.js.map +1 -0
  35. package/dist/{collector-hl5KNH7k.d.ts → collector-BN6hCWIx.d.ts} +2 -7
  36. package/dist/{config-DWL1ZYue.d.ts → config-Chmu-PnP.d.ts} +42 -51
  37. package/dist/core/index.d.ts +5 -5
  38. package/dist/core/index.js +9 -9
  39. package/dist/hydrate-CTh8SGd9.d.ts +20 -0
  40. package/dist/{index-CYLgmbWy.d.ts → index-szujmf6W.d.ts} +197 -320
  41. package/dist/index.d.ts +5 -5
  42. package/dist/index.js +10 -10
  43. package/dist/merge-styles-Cx25bpax.d.ts +4 -0
  44. package/dist/ssr/astro-client.d.ts +1 -1
  45. package/dist/ssr/astro-client.js +2 -16
  46. package/dist/ssr/astro-client.js.map +1 -1
  47. package/dist/ssr/astro-middleware-extract-static.d.ts +1 -4
  48. package/dist/ssr/astro-middleware-extract-static.js +0 -1
  49. package/dist/ssr/astro-middleware-extract.d.ts +1 -4
  50. package/dist/ssr/astro-middleware-extract.js +0 -1
  51. package/dist/ssr/astro-middleware-static.d.ts +1 -4
  52. package/dist/ssr/astro-middleware-static.js +1 -13
  53. package/dist/ssr/astro-middleware-static.js.map +1 -1
  54. package/dist/ssr/astro-middleware.d.ts +1 -4
  55. package/dist/ssr/astro-middleware.js +1 -14
  56. package/dist/ssr/astro-middleware.js.map +1 -1
  57. package/dist/ssr/astro.d.ts +8 -18
  58. package/dist/ssr/astro.js +9 -90
  59. package/dist/ssr/astro.js.map +1 -1
  60. package/dist/ssr/client.d.ts +2 -0
  61. package/dist/ssr/client.js +1 -0
  62. package/dist/ssr/index.d.ts +5 -27
  63. package/dist/ssr/index.js +6 -7
  64. package/dist/ssr/index.js.map +1 -1
  65. package/dist/ssr/next-config.d.ts +4 -7
  66. package/dist/ssr/next-config.js +21 -34
  67. package/dist/ssr/next-config.js.map +1 -1
  68. package/dist/ssr/next.d.ts +3 -11
  69. package/dist/ssr/next.js +7 -38
  70. package/dist/ssr/next.js.map +1 -1
  71. package/dist/static/index.d.ts +8 -13
  72. package/dist/static/index.js +6 -26
  73. package/dist/static/index.js.map +1 -1
  74. package/dist/static/inject.d.ts +1 -4
  75. package/dist/static/inject.js +1 -2
  76. package/dist/{types-jKZNpias.d.ts → types-DbMN-Yyn.d.ts} +23 -94
  77. package/dist/zero/babel.d.ts +71 -2
  78. package/dist/zero/babel.js +73 -140
  79. package/dist/zero/babel.js.map +1 -1
  80. package/dist/zero/index.d.ts +61 -12
  81. package/dist/zero/index.js +24 -2
  82. package/dist/zero/index.js.map +1 -0
  83. package/dist/zero/next.d.ts +5 -7
  84. package/dist/zero/next.js +4 -40
  85. package/dist/zero/next.js.map +1 -1
  86. package/docs/README.md +4 -1
  87. package/docs/adoption.md +25 -17
  88. package/docs/ai-agents.md +66 -36
  89. package/docs/comparison.md +9 -8
  90. package/docs/configuration.md +204 -70
  91. package/docs/debug.md +3 -2
  92. package/docs/design-system.md +129 -15
  93. package/docs/dsl.md +327 -117
  94. package/docs/getting-started.md +81 -22
  95. package/docs/injector.md +41 -40
  96. package/docs/methodology.md +48 -23
  97. package/docs/migration-v3.md +3 -3
  98. package/docs/pipeline.md +55 -28
  99. package/docs/plugins.md +22 -42
  100. package/docs/react-api.md +76 -11
  101. package/docs/runtime-benchmarks.md +116 -79
  102. package/docs/ssr.md +92 -66
  103. package/docs/styles.md +127 -23
  104. package/docs/tasty-static.md +176 -58
  105. package/package.json +64 -50
  106. package/tasty.config.ts +1 -0
  107. package/dist/babel-Zs1Q03qt.d.ts +0 -83
  108. package/dist/chunks/async-storage-DKK-wTD4.js +0 -44
  109. package/dist/chunks/async-storage-DKK-wTD4.js.map +0 -1
  110. package/dist/chunks/build-config-fM2Tf2dv.js +0 -45
  111. package/dist/chunks/build-config-fM2Tf2dv.js.map +0 -1
  112. package/dist/chunks/collector-HR9noXq_.js.map +0 -1
  113. package/dist/chunks/config-engine-DabuZ55f.js.map +0 -1
  114. package/dist/chunks/css-definitions-z79zG4t4.js.map +0 -1
  115. package/dist/chunks/debug-FLjTrfFW.js.map +0 -1
  116. package/dist/chunks/dsl-BVhxBy6V.js.map +0 -1
  117. package/dist/chunks/react-runtime-v7wWFkFD.js +0 -882
  118. package/dist/chunks/react-runtime-v7wWFkFD.js.map +0 -1
  119. package/dist/chunks/runtime-engine-BYEGKOF1.js.map +0 -1
  120. package/dist/chunks/runtime-state-icjb9GAD.js.map +0 -1
  121. package/dist/chunks/shared-utils-OIg0N_dp.js.map +0 -1
  122. package/dist/chunks/style-engine-C34heV9d.js.map +0 -1
  123. package/dist/chunks/zero-engine-DkyjChVU.js.map +0 -1
  124. package/dist/merge-styles-C_oMoJVd.d.ts +0 -7
@@ -1,50 +1,31 @@
1
- import { F as RE_NUMBER, I as RE_RAW_UNIT, o as customFunction, p as parseStyle } from "./dsl-BVhxBy6V.js";
2
- import { C as STYLE_HANDLER_MAP, k as createStyle } from "./style-engine-C34heV9d.js";
3
- //#region src/functions/index.ts
1
+ import { R as RE_NUMBER, a as customFunction, p as parseStyle, z as RE_RAW_UNIT } from "./dsl-BAwiOznp.js";
2
+ import { M as createStyle, T as STYLE_HANDLER_MAP, j as scanAnimationNames } from "./style-engine-DkKH-TqL.js";
3
+ // src/functions/index.ts
4
4
  const FUNCTION_KEY = "@function";
5
- /** Descriptor keys that are not local-variable declarations. */
6
- const RESERVED_KEYS = new Set([
5
+ const RESERVED_KEYS = /* @__PURE__ */ new Set([
7
6
  "args",
8
7
  "returns",
9
8
  "result"
10
9
  ]);
11
- /**
12
- * Check if styles object has a local @function definition.
13
- */
14
10
  function hasLocalFunctions(styles) {
15
11
  return FUNCTION_KEY in styles;
16
12
  }
17
- /**
18
- * Extract local @function definitions from a styles object.
19
- * Returns null if none (fast path).
20
- */
21
13
  function extractLocalFunctions(styles) {
22
14
  const functions = styles[FUNCTION_KEY];
23
15
  if (!functions || typeof functions !== "object") return null;
24
16
  return functions;
25
17
  }
26
- /**
27
- * Parse a function name token into its CSS custom name.
28
- * Accepts `$$name`, `$name`, `--name`, or bare `name` → `--name`.
29
- */
30
18
  function parseFunctionName(token) {
31
19
  if (token.startsWith("$$")) return `--${token.slice(2)}`;
32
20
  if (token.startsWith("$")) return `--${token.slice(1)}`;
33
21
  if (token.startsWith("--")) return token;
34
22
  return `--${token}`;
35
23
  }
36
- /**
37
- * Parse a parameter / local-variable name token into its CSS custom name.
38
- * Accepts `$name`, `--name`, or bare `name` → `--name`.
39
- */
40
24
  function parseParamName(token) {
41
25
  if (token.startsWith("$")) return `--${token.slice(1)}`;
42
26
  if (token.startsWith("--")) return token;
43
27
  return `--${token}`;
44
28
  }
45
- /**
46
- * Format a single parameter (`--name <type>: default`).
47
- */
48
29
  function formatParameter(token, param) {
49
30
  const name = parseParamName(token);
50
31
  if (param === true) return name;
@@ -54,9 +35,6 @@ function formatParameter(token, param) {
54
35
  if (param.default !== void 0) out += `: ${parseStyle(param.default).output}`;
55
36
  return out;
56
37
  }
57
- /**
58
- * Format the function prelude: `@function --name(params) returns <type>`.
59
- */
60
38
  function formatFunctionPrelude(name, args, returns) {
61
39
  const cssName = parseFunctionName(name);
62
40
  let params = "";
@@ -65,9 +43,6 @@ function formatFunctionPrelude(name, args, returns) {
65
43
  const returnsPart = returns ? ` returns ${returns}` : "";
66
44
  return `@function ${cssName}(${params})${returnsPart}`;
67
45
  }
68
- /**
69
- * Format the inner declarations of a @function rule (local variables + result).
70
- */
71
46
  function formatFunctionDeclarations(def) {
72
47
  const parts = [];
73
48
  for (const key of Object.keys(def)) {
@@ -79,28 +54,15 @@ function formatFunctionDeclarations(def) {
79
54
  parts.push(`result: ${parseStyle(def.result).output};`);
80
55
  return parts.join(" ");
81
56
  }
82
- /**
83
- * Format a complete @function rule as CSS.
84
- */
85
57
  function formatFunctionRule(name, def) {
86
58
  return `${formatFunctionPrelude(name, def.args, def.returns)} { ${formatFunctionDeclarations(def)} }`;
87
59
  }
88
- /** A key is a CSS-function key when it carries the `$`/`--` prefix. */
89
60
  function isCssFunctionKey(key) {
90
61
  return key.startsWith("$") || key.startsWith("--");
91
62
  }
92
- /** Discriminate a unified `functions` entry by its value type. */
93
63
  function isParseFunction(value) {
94
64
  return typeof value === "function";
95
65
  }
96
- /**
97
- * Split the unified `functions` map into the two internal registries:
98
- * - `parseFuncs`: JS parse functions (bare keys).
99
- * - `functionDefs`: declarative CSS `@function` definitions (`$$` keys).
100
- *
101
- * Entries whose key prefix does not match the value type are reported via
102
- * `onMismatch` and skipped.
103
- */
104
66
  function splitFunctions(map, onMismatch) {
105
67
  const parseFuncs = {};
106
68
  const functionDefs = {};
@@ -129,14 +91,6 @@ function escapeRegExp(str) {
129
91
  return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
130
92
  }
131
93
  const paramBareName = (token) => parseParamName(token).slice(2);
132
- /**
133
- * Rewrite `var(--name)` references for declared parameter/local names to a
134
- * collision-resistant, function-scoped prefix. This guarantees that later
135
- * value substitution only ever targets the function's own variables and can
136
- * never accidentally match a real element-level `var(--name)` introduced by an
137
- * argument value (e.g. the `--gap` used by Tasty units). Blanket prefix — no
138
- * exact-collision detection.
139
- */
140
94
  function prefixDeclaredVars(template, declared, prefixOf) {
141
95
  let out = template;
142
96
  for (const bare of declared) {
@@ -145,11 +99,6 @@ function prefixDeclaredVars(template, declared, prefixOf) {
145
99
  }
146
100
  return out;
147
101
  }
148
- /**
149
- * Replace the prefixed `var(--<prefixed>)` / `var(--<prefixed>, fallback)`
150
- * references with their mapped values, iterating so that local variables that
151
- * reference parameters (or other locals) resolve fully.
152
- */
153
102
  function substituteVars(template, valueMap) {
154
103
  let out = template;
155
104
  for (let iter = 0; iter < 30; iter++) {
@@ -165,17 +114,7 @@ function substituteVars(template, valueMap) {
165
114
  }
166
115
  return out;
167
116
  }
168
- /** Function names currently being expanded, to guard against recursion cycles. */
169
117
  const inProgress = /* @__PURE__ */ new Set();
170
- /**
171
- * Compile a declarative `@function` definition into a parse-function closure
172
- * that fully inlines the call into plain CSS (the `@function` polyfill).
173
- *
174
- * Parameters and local variables are substituted directly with their values,
175
- * so no function-internal custom properties are emitted (collisions are
176
- * structurally impossible). Self/mutually-recursive functions are not expanded:
177
- * the cycle guard bails and the call is left untouched.
178
- */
179
118
  function compileFunctionClosure(name, def) {
180
119
  const cssName = parseFunctionName(name);
181
120
  const prefixOf = (bare) => `tf-${cssName.slice(2)}-${bare}`;
@@ -223,13 +162,7 @@ function compileFunctionClosure(name, def) {
223
162
  }
224
163
  };
225
164
  }
226
- /** CSS function name -> serialized definition, to dedupe polyfill registration. */
227
165
  const registeredFunctionDefs = /* @__PURE__ */ new Map();
228
- /**
229
- * Register a declarative `@function` as a parse-function closure so the parser
230
- * inlines its call sites. Deduplicated by name + definition; a later, different
231
- * definition of the same name overrides the previous one (local wins).
232
- */
233
166
  function registerFunctionPolyfill(name, definition) {
234
167
  const cssName = parseFunctionName(name);
235
168
  const serialized = JSON.stringify(definition);
@@ -237,139 +170,28 @@ function registerFunctionPolyfill(name, definition) {
237
170
  registeredFunctionDefs.set(cssName, serialized);
238
171
  customFunction(cssName, compileFunctionClosure(name, definition));
239
172
  }
240
- /** Register all local `@function` definitions from a styles object (polyfill). */
241
173
  function registerLocalFunctionPolyfills(styles) {
242
174
  const local = extractLocalFunctions(styles);
243
175
  if (!local) return;
244
176
  for (const [name, definition] of Object.entries(local)) registerFunctionPolyfill(name, definition);
245
177
  }
246
- /** Clear polyfill registration bookkeeping (used by resetConfig in tests). */
247
178
  function resetFunctionPolyfills() {
248
179
  registeredFunctionDefs.clear();
249
180
  }
250
- //#endregion
251
- //#region src/properties/defaults.ts
252
- /**
253
- * Default properties shipped with Tasty.
254
- *
255
- * Kept with the property formatter so runtime and build-time configuration
256
- * paths can share the same list without importing the browser runtime.
257
- */
258
- const DEFAULT_PROPERTIES = {
259
- "#tasty-second-fill": {
260
- inherits: false,
261
- initialValue: "transparent"
262
- },
263
- "#current": {
264
- inherits: true,
265
- initialValue: "currentcolor"
266
- },
267
- "#white": {
268
- inherits: true,
269
- initialValue: "rgb(255 255 255)"
270
- },
271
- "#black": {
272
- inherits: true,
273
- initialValue: "rgb(0 0 0)"
274
- },
275
- "#clear": {
276
- inherits: true,
277
- initialValue: "transparent"
278
- },
279
- "#border": {
280
- inherits: true,
281
- initialValue: "rgb(0 0 0)"
282
- },
283
- $gap: {
284
- syntax: "<length>",
285
- inherits: true,
286
- initialValue: "4px"
287
- },
288
- $radius: {
289
- syntax: "<length>",
290
- inherits: true,
291
- initialValue: "6px"
292
- },
293
- "$border-width": {
294
- syntax: "<length>",
295
- inherits: true,
296
- initialValue: "1px"
297
- },
298
- "$outline-width": {
299
- syntax: "<length>",
300
- inherits: true,
301
- initialValue: "3px"
302
- },
303
- $transition: {
304
- syntax: "<time>",
305
- inherits: true,
306
- initialValue: "80ms"
307
- },
308
- "$sharp-radius": {
309
- syntax: "<length>",
310
- inherits: true,
311
- initialValue: "0px"
312
- },
313
- "$bold-font-weight": {
314
- syntax: "<number>",
315
- inherits: true,
316
- initialValue: "700"
317
- },
318
- "$font-sans-fallback": {
319
- syntax: "*",
320
- inherits: true,
321
- initialValue: "system-ui, -apple-system, \"Segoe UI\", Roboto, Helvetica, Arial, \"Apple Color Emoji\", \"Segoe UI Emoji\", sans-serif"
322
- },
323
- "$font-mono-fallback": {
324
- syntax: "*",
325
- inherits: true,
326
- initialValue: "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace"
327
- }
328
- };
329
- //#endregion
330
- //#region src/properties/index.ts
181
+ // src/properties/index.ts
331
182
  const PROPERTIES_KEY = "@property";
332
- /**
333
- * Valid CSS custom property name pattern (after the -- prefix).
334
- * Must start with a letter or underscore, followed by letters, digits, hyphens, or underscores.
335
- */
336
183
  const VALID_PROPERTY_NAME_PATTERN = /^[a-z_][a-z0-9-_]*$/i;
337
- /**
338
- * Validate a CSS custom property name (the part after --).
339
- * Returns true if the name is valid for use as a CSS custom property.
340
- */
341
184
  function isValidPropertyName(name) {
342
185
  return VALID_PROPERTY_NAME_PATTERN.test(name);
343
186
  }
344
- /**
345
- * Check if styles object has local @property definition.
346
- * Fast path: single property lookup.
347
- */
348
187
  function hasLocalProperties(styles) {
349
188
  return PROPERTIES_KEY in styles;
350
189
  }
351
- /**
352
- * Extract local @property from styles object.
353
- * Returns null if no local properties (fast path).
354
- */
355
190
  function extractLocalProperties(styles) {
356
191
  const properties = styles[PROPERTIES_KEY];
357
192
  if (!properties || typeof properties !== "object") return null;
358
193
  return properties;
359
194
  }
360
- /**
361
- * Parse a property token name and return the CSS property name and whether it's a color.
362
- * Supports tasty token syntax and validates the property name.
363
- *
364
- * Token formats:
365
- * - `$name` → { cssName: '--name', isColor: false }
366
- * - `#name` → { cssName: '--name-color', isColor: true }
367
- * - `--name` → { cssName: '--name', isColor: false } (legacy, auto-detect color by suffix)
368
- * - `name` → { cssName: '--name', isColor: false } (legacy)
369
- *
370
- * @param token - The property token to parse
371
- * @returns Parsed result with cssName, isColor, isValid, and optional error
372
- */
373
195
  function parsePropertyToken(token) {
374
196
  if (!token || typeof token !== "string") return {
375
197
  cssName: "",
@@ -413,31 +235,23 @@ function parsePropertyToken(token) {
413
235
  isValid: true
414
236
  };
415
237
  }
416
- /**
417
- * Normalize a property definition to a consistent string representation.
418
- * Used for comparing definitions to detect type conflicts.
419
- *
420
- * Only `syntax` and `inherits` are compared — `initialValue` is intentionally
421
- * excluded because different components may set different defaults for the
422
- * same typed property (e.g. auto-inferred `0px` vs explicit `6px`).
423
- *
424
- * Keys are sorted alphabetically to ensure consistent comparison:
425
- * { inherits: true, syntax: '<color>' } === { syntax: '<color>', inherits: true }
426
- */
238
+ function indexPropertiesByName(properties) {
239
+ const index = /* @__PURE__ */ new Map();
240
+ for (const [token, definition] of Object.entries(properties)) {
241
+ const parsed = parsePropertyToken(token);
242
+ if (parsed.isValid) index.set(parsed.cssName, {
243
+ token,
244
+ definition
245
+ });
246
+ }
247
+ return index;
248
+ }
427
249
  function normalizePropertyDefinition(def) {
428
250
  const normalized = {};
429
251
  if (def.inherits !== void 0) normalized.inherits = def.inherits;
430
252
  if (def.syntax !== void 0) normalized.syntax = def.syntax;
431
253
  return JSON.stringify(normalized);
432
254
  }
433
- /**
434
- * Get the effective property definition for a token.
435
- * For color tokens (#name), auto-sets syntax to '<color>' and defaults initialValue to 'transparent'.
436
- *
437
- * @param token - Property token ($name, #name, --name, or plain name)
438
- * @param userDefinition - User-provided definition options
439
- * @returns Effective definition with cssName, definition, isValid, and optional error
440
- */
441
255
  function getEffectiveDefinition(token, userDefinition) {
442
256
  const parsed = parsePropertyToken(token);
443
257
  if (!parsed.isValid) return {
@@ -512,16 +326,6 @@ for (const u of TIME_UNITS) UNIT_TO_SYNTAX[u] = {
512
326
  syntax: "<time>",
513
327
  initialValue: "0s"
514
328
  };
515
- /**
516
- * Infer CSS @property syntax from a concrete value.
517
- * Detects numeric types: \<number\>, \<length-percentage\>, \<angle\>, \<time\>.
518
- * Length and percentage values both map to \<length-percentage\> for maximum flexibility.
519
- * Color properties are handled separately via the #name token convention
520
- * (--name-color gets \<color\> syntax automatically in getEffectiveDefinition).
521
- *
522
- * @param value - The CSS value to infer from (e.g. '10px', '1', '45deg')
523
- * @returns Inferred syntax and initial value, or null if not inferable
524
- */
525
329
  function inferSyntaxFromValue(value) {
526
330
  if (!value || typeof value !== "string") return null;
527
331
  const trimmed = value.trim();
@@ -535,135 +339,122 @@ function inferSyntaxFromValue(value) {
535
339
  }
536
340
  const unitMatch = trimmed.match(RE_RAW_UNIT);
537
341
  if (unitMatch) {
538
- const mapping = UNIT_TO_SYNTAX[unitMatch[2]];
342
+ const unit = unitMatch[2];
343
+ const mapping = UNIT_TO_SYNTAX[unit];
539
344
  if (mapping) return mapping;
540
345
  }
541
346
  return null;
542
347
  }
543
- //#endregion
544
- //#region src/utils/hash.ts
545
- /**
546
- * Fast string hash (djb2) for deduplication keys.
547
- * Not cryptographic — just collision-resistant enough for cache keys.
548
- */
348
+ // src/properties/defaults.ts
349
+ const DEFAULT_PROPERTIES = {
350
+ "#tasty-second-fill": {
351
+ inherits: false,
352
+ initialValue: "transparent"
353
+ },
354
+ "#current": {
355
+ inherits: true,
356
+ initialValue: "currentcolor"
357
+ },
358
+ "#white": {
359
+ inherits: true,
360
+ initialValue: "rgb(255 255 255)"
361
+ },
362
+ "#black": {
363
+ inherits: true,
364
+ initialValue: "rgb(0 0 0)"
365
+ },
366
+ "#border": {
367
+ inherits: true,
368
+ initialValue: "currentcolor"
369
+ },
370
+ "#outline": {
371
+ inherits: true,
372
+ initialValue: "currentcolor"
373
+ },
374
+ $gap: {
375
+ syntax: "<length>",
376
+ inherits: true,
377
+ initialValue: "8px"
378
+ },
379
+ $radius: {
380
+ syntax: "<length>",
381
+ inherits: true,
382
+ initialValue: "6px"
383
+ },
384
+ "$border-width": {
385
+ syntax: "<length>",
386
+ inherits: true,
387
+ initialValue: "1px"
388
+ },
389
+ "$outline-width": {
390
+ syntax: "<length>",
391
+ inherits: true,
392
+ initialValue: "3px"
393
+ },
394
+ $transition: {
395
+ syntax: "<time>",
396
+ inherits: true,
397
+ initialValue: "80ms"
398
+ },
399
+ "$sharp-radius": {
400
+ syntax: "<length>",
401
+ inherits: true,
402
+ initialValue: "0px"
403
+ },
404
+ "$bold-font-weight": {
405
+ syntax: "<number>",
406
+ inherits: true,
407
+ initialValue: "700"
408
+ },
409
+ "$font-sans-fallback": {
410
+ syntax: "*",
411
+ inherits: true,
412
+ initialValue: "system-ui, -apple-system, \"Segoe UI\", Roboto, Helvetica, Arial, \"Apple Color Emoji\", \"Segoe UI Emoji\", sans-serif"
413
+ },
414
+ "$font-mono-fallback": {
415
+ syntax: "*",
416
+ inherits: true,
417
+ initialValue: "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace"
418
+ }
419
+ };
420
+ // src/utils/hash.ts
549
421
  function hashString(str) {
550
422
  let hash = 5381;
551
423
  for (let i = 0; i < str.length; i++) hash = (hash << 5) + hash + str.charCodeAt(i) | 0;
552
424
  return (hash >>> 0).toString(36);
553
425
  }
554
- //#endregion
555
- //#region src/utils/name-prefix.ts
556
- /**
557
- * Name prefix utilities for generated identifiers.
558
- *
559
- * Tasty generates three kinds of identifiers from content hashes:
560
- * - class names (used in DOM `class` attribute)
561
- * - keyframe names (used in CSS `animation`)
562
- * - counter-style names (used in CSS `list-style-type`)
563
- *
564
- * All three derive from a single configurable prefix so that an app
565
- * can namespace every identifier under one string. Discriminator letters
566
- * (`k`, `c`) keep the three kinds visually distinct in devtools — they
567
- * are not required for correctness (CSS keeps these in separate
568
- * namespaces), only for readability.
569
- *
570
- * The runtime / SSR / RSC paths must agree on the prefix; otherwise the
571
- * client-side hash for a given style will not match the server-rendered
572
- * class and hydration breaks. The zero-runtime build path uses a
573
- * different default (`'ts'`) so its classes can't collide with runtime
574
- * (`'t'`) classes when both are loaded on the same page.
575
- */
576
- /** Default prefix used by the runtime / SSR / RSC paths. */
426
+ // src/utils/name-prefix.ts
577
427
  const DEFAULT_NAME_PREFIX = "t";
578
- /** Default prefix used by the zero-runtime (`tastyStatic`) build path. */
579
428
  const DEFAULT_ZERO_NAME_PREFIX = "ts";
580
- /**
581
- * Allowed shape: starts with a letter or underscore, then letters/
582
- * digits/underscore/hyphen. Length capped at 32 to keep generated
583
- * names sane. Matches the CSS identifier rules for the common case
584
- * while keeping the surface conservative.
585
- */
586
429
  const NAME_PREFIX_PATTERN = /^[a-zA-Z_][a-zA-Z0-9_-]{0,31}$/;
587
- /**
588
- * Validate a `namePrefix` value.
589
- * Throws a TypeError with a descriptive message on invalid input so
590
- * misconfiguration fails loudly at `configure()` time rather than
591
- * surfacing later as broken hydration.
592
- */
593
430
  function validateNamePrefix(prefix) {
594
431
  if (typeof prefix !== "string") throw new TypeError(`[Tasty] namePrefix must be a string, got ${typeof prefix}.`);
595
432
  if (!NAME_PREFIX_PATTERN.test(prefix)) throw new TypeError(`[Tasty] namePrefix "${prefix}" is invalid. It must start with a letter (a-z, A-Z) or "_", contain only letters, digits, "_" or "-", and be 1-32 characters long. Examples: "t", "ts", "myapp-", "_foo".`);
596
433
  }
597
- /**
598
- * Build a class name: `${prefix}${hash}`.
599
- * The hash is appended verbatim — supply a separator inside the prefix
600
- * itself if you want one (e.g. `'myapp-'`).
601
- */
602
434
  function makeClassName(prefix, hash) {
603
435
  return `${prefix}${hash}`;
604
436
  }
605
- /**
606
- * Build a keyframe name: `${prefix}k${suffix}`.
607
- * The `k` discriminator keeps keyframe names visually distinct from
608
- * class names sharing the same prefix. `suffix` is typically a content
609
- * hash but may be a counter for ad-hoc allocation.
610
- */
611
437
  function makeKeyframeName(prefix, suffix) {
612
438
  return `${prefix}k${suffix}`;
613
439
  }
614
- /**
615
- * Build a counter-style name: `${prefix}c${suffix}`.
616
- * The `c` discriminator keeps counter-style names visually distinct
617
- * from class names sharing the same prefix.
618
- */
619
440
  function makeCounterStyleName(prefix, suffix) {
620
441
  return `${prefix}c${suffix}`;
621
442
  }
622
- /** Escape a string for safe inclusion in a regex literal. */
623
443
  function escapeRegex(str) {
624
444
  return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
625
445
  }
626
- /**
627
- * Regex matching any tasty class for the given prefix.
628
- * Used by the runtime GC's DOM scan and class-allocation bookkeeping.
629
- */
630
446
  function tastyClassRegex(prefix) {
631
447
  return new RegExp(`^${escapeRegex(prefix)}[a-z0-9]+$`);
632
448
  }
633
- /**
634
- * Global regex extracting tasty class names from RSC-inlined CSS.
635
- * Looks for the doubled-specificity pattern `.cls.cls` that
636
- * `formatRules()` always emits, which makes extraction reliable.
637
- */
638
449
  function rscClassRegexGlobal(prefix) {
639
450
  return new RegExp(`\\.(${escapeRegex(prefix)}[a-z0-9]+)\\.\\1`, "g");
640
451
  }
641
- //#endregion
642
- //#region src/properties/property-type-resolver.ts
643
- /**
644
- * PropertyTypeResolver
645
- *
646
- * Automatically infers CSS @property types from custom property values.
647
- * Supports deferred resolution for var() reference chains of arbitrary depth.
648
- */
649
- /**
650
- * One `--name: value` declaration, with the surrounding whitespace dropped.
651
- *
652
- * The value is anchored on `\S` at both ends so no two quantifiers can claim
653
- * the same character. A lazy `(.+?)\s*$` is quadratic on a value of nothing
654
- * but spaces — every split point gets tried (CodeQL `js/polynomial-redos`).
655
- */
452
+ // src/properties/property-type-resolver.ts
656
453
  const CUSTOM_PROP_DECL = /^\s*(--[a-z0-9_-]+)\s*:\s*(\S|\S.*\S)\s*$/i;
657
454
  const SINGLE_VAR_REF = /^var\((--[a-z0-9_-]+)\)$/i;
658
455
  var PropertyTypeResolver = class {
659
- /** propName → the prop it depends on */
660
456
  pendingDeps = /* @__PURE__ */ new Map();
661
- /** propName → list of props waiting on it */
662
457
  reverseDeps = /* @__PURE__ */ new Map();
663
- /**
664
- * Scan CSS declarations and auto-register @property for custom properties
665
- * whose types can be inferred from their values.
666
- */
667
458
  scanDeclarations(declarations, isPropertyDefined, registerProperty) {
668
459
  if (!declarations.includes("--")) return;
669
460
  const parts = declarations.split(/;+/);
@@ -731,19 +522,11 @@ var PropertyTypeResolver = class {
731
522
  return !SINGLE_VAR_REF.test(value);
732
523
  }
733
524
  };
734
- //#endregion
735
- //#region src/font-face/index.ts
525
+ // src/font-face/index.ts
736
526
  const FONT_FACE_KEY = "@font-face";
737
- /**
738
- * Check if styles object has local @font-face definition.
739
- */
740
527
  function hasLocalFontFace(styles) {
741
528
  return FONT_FACE_KEY in styles;
742
529
  }
743
- /**
744
- * Extract local @font-face from styles object.
745
- * Returns null if no local font faces (fast path).
746
- */
747
530
  function extractLocalFontFace(styles) {
748
531
  const fontFace = styles[FONT_FACE_KEY];
749
532
  if (!fontFace || typeof fontFace !== "object") return null;
@@ -762,10 +545,6 @@ const FONT_FACE_DESCRIPTOR_MAP = {
762
545
  fontFeatureSettings: "font-feature-settings",
763
546
  fontVariationSettings: "font-variation-settings"
764
547
  };
765
- /**
766
- * Format the inner declarations of a @font-face rule (no wrapper).
767
- * Used by the injector which needs selector and declarations separately.
768
- */
769
548
  function formatFontFaceDeclarations(family, descriptors) {
770
549
  const parts = [];
771
550
  parts.push(`font-family: "${family}";`);
@@ -776,34 +555,20 @@ function formatFontFaceDeclarations(family, descriptors) {
776
555
  }
777
556
  return parts.join(" ");
778
557
  }
779
- /**
780
- * Format a single @font-face rule as CSS.
781
- */
782
558
  function formatFontFaceRule(family, descriptors) {
783
559
  return `@font-face { ${formatFontFaceDeclarations(family, descriptors)} }`;
784
560
  }
785
- /**
786
- * Generate a content hash for deduplication of a single font-face rule.
787
- */
788
561
  function fontFaceContentHash(family, descriptors) {
789
562
  return JSON.stringify({
790
563
  family,
791
564
  ...descriptors
792
565
  });
793
566
  }
794
- //#endregion
795
- //#region src/counter-style/index.ts
567
+ // src/counter-style/index.ts
796
568
  const COUNTER_STYLE_KEY = "@counter-style";
797
- /**
798
- * Check if styles object has local @counter-style definition.
799
- */
800
569
  function hasLocalCounterStyle(styles) {
801
570
  return COUNTER_STYLE_KEY in styles;
802
571
  }
803
- /**
804
- * Extract local @counter-style from styles object.
805
- * Returns null if no local counter styles (fast path).
806
- */
807
572
  function extractLocalCounterStyle(styles) {
808
573
  const counterStyle = styles[COUNTER_STYLE_KEY];
809
574
  if (!counterStyle || typeof counterStyle !== "object") return null;
@@ -821,10 +586,6 @@ const COUNTER_STYLE_DESCRIPTOR_MAP = {
821
586
  fallback: "fallback",
822
587
  speakAs: "speak-as"
823
588
  };
824
- /**
825
- * Format the inner declarations of a @counter-style rule (no wrapper).
826
- * Used by the injector which needs selector and declarations separately.
827
- */
828
589
  function formatCounterStyleDeclarations(descriptors) {
829
590
  const parts = [];
830
591
  for (const [key, cssName] of Object.entries(COUNTER_STYLE_DESCRIPTOR_MAP)) {
@@ -833,49 +594,19 @@ function formatCounterStyleDeclarations(descriptors) {
833
594
  }
834
595
  return parts.join(" ");
835
596
  }
836
- /**
837
- * Format a @counter-style rule as CSS.
838
- */
839
597
  function formatCounterStyleRule(name, descriptors) {
840
598
  return `@counter-style ${name} { ${formatCounterStyleDeclarations(descriptors)} }`;
841
599
  }
842
- //#endregion
843
- //#region src/keyframes/index.ts
600
+ // src/keyframes/index.ts
844
601
  const KEYFRAMES_KEY = "@keyframes";
845
- /**
846
- * Pattern to extract animation names from CSS animation property values.
847
- * Animation name is typically the first identifier in the shorthand.
848
- * Handles: "fadeIn 300ms ease-in", "pulse 1s infinite", etc.
849
- *
850
- * CSS animation shorthand order (all optional except name):
851
- * animation: name | duration | timing | delay | iteration | direction | fill-mode | play-state
852
- *
853
- * Animation names must:
854
- * - Start with a letter, underscore, or hyphen (but not a digit or CSS keyword)
855
- * - Not be CSS keywords: none, initial, inherit, unset, revert
856
- */
857
- const NON_NAME_KEYWORDS = new Set("none initial inherit unset revert auto normal running paused reverse alternate alternate-reverse forwards backwards both ease linear ease-in ease-out ease-in-out step-start step-end".split(" "));
858
- /**
859
- * Check if styles object has local @keyframes definition.
860
- * Fast path: single property lookup.
861
- */
862
602
  function hasLocalKeyframes(styles) {
863
603
  return KEYFRAMES_KEY in styles;
864
604
  }
865
- /**
866
- * Extract local @keyframes from styles object.
867
- * Returns null if no local keyframes (fast path).
868
- */
869
605
  function extractLocalKeyframes(styles) {
870
606
  const keyframes = styles[KEYFRAMES_KEY];
871
607
  if (!keyframes || typeof keyframes !== "object") return null;
872
608
  return keyframes;
873
609
  }
874
- /**
875
- * Merge local and global keyframes.
876
- * Local keyframes take priority over global.
877
- * Returns null if no keyframes exist (fast path).
878
- */
879
610
  function mergeKeyframes(local, global) {
880
611
  if (!local && !global) return null;
881
612
  if (!local) return global;
@@ -885,41 +616,9 @@ function mergeKeyframes(local, global) {
885
616
  ...local
886
617
  };
887
618
  }
888
- /**
889
- * Extract animation name from a single animation value.
890
- * Returns null if no valid name found.
891
- *
892
- * Examples:
893
- * - "fadeIn 300ms ease-in" → "fadeIn"
894
- * - "1s pulse infinite" → "pulse" (name can be anywhere)
895
- * - "none" → null (CSS keyword)
896
- * - "300ms ease-in" → null (no name, just duration/timing)
897
- */
898
- function extractAnimationNameFromValue(value) {
899
- for (const part of value.trim().split(/\s+/)) {
900
- const lower = part.toLowerCase();
901
- if (NON_NAME_KEYWORDS.has(lower)) continue;
902
- if (part === "infinite" || /^(?:-?[\d.]+m?s|\d+|(?:cubic-bezier|steps)\()/i.test(part)) continue;
903
- const match = /^([a-zA-Z_-][a-zA-Z0-9_-]*)/.exec(part);
904
- if (match) return match[1];
905
- }
906
- return null;
907
- }
908
- /**
909
- * Extract all animation names from an animation property value.
910
- * Handles multiple animations separated by commas.
911
- *
912
- * Example: "fadeIn 300ms, slideIn 500ms ease-out" → ["fadeIn", "slideIn"]
913
- */
914
619
  function collectAnimationNamesFromValue(value, names) {
915
- for (const animation of value.split(",")) {
916
- const name = extractAnimationNameFromValue(animation);
917
- if (name) names.add(name);
918
- }
620
+ for (const item of scanAnimationNames(value)) if (item) names.add(item.name);
919
621
  }
920
- /**
921
- * Extract animation names from a style value (handles mappings and arrays).
922
- */
923
622
  function extractAnimationNamesFromStyleValue(value, names) {
924
623
  if (typeof value === "string") collectAnimationNamesFromValue(value, names);
925
624
  else if (Array.isArray(value)) for (const v of value) extractAnimationNamesFromStyleValue(v, names);
@@ -933,39 +632,19 @@ function collectAnimationNamesFromStyles(styles, names) {
933
632
  if ((key.startsWith("&") || key.startsWith(".") || /^[A-Z]/.test(key)) && value && typeof value === "object") collectAnimationNamesFromStyles(value, names);
934
633
  }
935
634
  }
936
- /**
937
- * Extract all animation names referenced in styles.
938
- * Scans 'animation' and 'animationName' properties including in state mappings.
939
- * Returns empty set if no animation properties found (fast path).
940
- */
941
635
  function extractAnimationNamesFromStyles(styles) {
942
636
  const names = /* @__PURE__ */ new Set();
943
637
  collectAnimationNamesFromStyles(styles, names);
944
638
  return names;
945
639
  }
946
- /**
947
- * The name a local `@keyframes` block is emitted under.
948
- *
949
- * Content-addressed, and a pure function of what was authored: the same steps
950
- * always produce the same name, and different steps under the same authored
951
- * name cannot collide. That is what lets the server and the client agree —
952
- * a name handed out by whichever injector happened to see the definition first
953
- * depends on run order, so the two would disagree on both the animation name
954
- * and the class that references it.
955
- */
956
640
  function resolveKeyframesName(authored, steps) {
957
641
  return `${authored}-${hashString(JSON.stringify(steps))}`;
958
642
  }
959
- /**
960
- * The emitted name for every local `@keyframes` in `styles`, by authored name.
961
- * Pure — the server, the RSC pass and the client all reach the same answer.
962
- */
963
643
  function resolveKeyframesNames(used) {
964
644
  const names = /* @__PURE__ */ new Map();
965
645
  for (const [authored, steps] of Object.entries(used)) names.set(authored, resolveKeyframesName(authored, steps));
966
646
  return names;
967
647
  }
968
- /** Replace local animation names and collect the definitions each rule uses. */
969
648
  function replaceAnimationNames(declarations, nameMap, usedNames) {
970
649
  if (nameMap.size === 0 || !declarations.includes("animation")) return declarations;
971
650
  const parts = declarations.split(";");
@@ -992,9 +671,6 @@ function replaceAnimationNames(declarations, nameMap, usedNames) {
992
671
  }
993
672
  return modified ? parts.join(";") : declarations;
994
673
  }
995
- /**
996
- * Replace a word in a string (word boundary aware, no regex).
997
- */
998
674
  function replaceWord(str, word, replacement) {
999
675
  let result = str;
1000
676
  let idx = 0;
@@ -1015,10 +691,6 @@ function findWord(str, word, from = 0) {
1015
691
  }
1016
692
  return -1;
1017
693
  }
1018
- /**
1019
- * Filter keyframes to only those that are actually used.
1020
- * Returns null if no keyframes are used (fast path).
1021
- */
1022
694
  function filterUsedKeyframes(keyframes, usedNames) {
1023
695
  if (!keyframes || usedNames.size === 0) return null;
1024
696
  const used = {};
@@ -1029,14 +701,38 @@ function filterUsedKeyframes(keyframes, usedNames) {
1029
701
  }
1030
702
  return hasAny ? used : null;
1031
703
  }
1032
- //#endregion
1033
- //#region src/ssr/format-property.ts
1034
- /**
1035
- * Format a single @property rule as a CSS string.
1036
- *
1037
- * Returns the full `@property --name { ... }` text, or empty string
1038
- * if the token is invalid.
1039
- */
704
+ function resolveSelectorKeyframes(styles, rules, globalKeyframes) {
705
+ const usedNames = extractAnimationNamesFromStyles(styles);
706
+ if (usedNames.size === 0) return {
707
+ rules,
708
+ keyframes: null
709
+ };
710
+ const used = filterUsedKeyframes(mergeKeyframes(hasLocalKeyframes(styles) ? extractLocalKeyframes(styles) : null, globalKeyframes), usedNames);
711
+ if (!used) return {
712
+ rules,
713
+ keyframes: null
714
+ };
715
+ const names = resolveKeyframesNames(used);
716
+ const referenced = /* @__PURE__ */ new Set();
717
+ const renamed = rules.map((rule) => {
718
+ const declarations = replaceAnimationNames(rule.declarations, names, referenced);
719
+ return declarations === rule.declarations ? rule : {
720
+ ...rule,
721
+ declarations
722
+ };
723
+ });
724
+ if (referenced.size === 0) return {
725
+ rules,
726
+ keyframes: null
727
+ };
728
+ const keyframes = /* @__PURE__ */ new Map();
729
+ for (const [authored, steps] of Object.entries(used)) if (referenced.has(authored)) keyframes.set(names.get(authored), steps);
730
+ return {
731
+ rules: renamed,
732
+ keyframes
733
+ };
734
+ }
735
+ // src/ssr/format-property.ts
1040
736
  function formatPropertyCSS(token, definition) {
1041
737
  const result = getEffectiveDefinition(token, definition);
1042
738
  if (!result.isValid) return "";
@@ -1059,17 +755,14 @@ function buildPropertyRule(cssName, definition) {
1059
755
  }
1060
756
  return `@property ${cssName} { ${parts.join(" ").trim()} }`;
1061
757
  }
1062
- //#endregion
1063
- //#region src/ssr/format-keyframes.ts
1064
- /**
1065
- * Convert keyframes steps to a CSS string.
1066
- * Replicates SheetManager.stepsToCSS() without the class instance.
1067
- */
1068
- function stepsToCSS(steps) {
758
+ // src/ssr/format-keyframes.ts
759
+ function formatKeyframesSteps(steps) {
1069
760
  const rules = [];
761
+ const allDeclarations = [];
1070
762
  for (const [key, value] of Object.entries(steps)) {
1071
763
  if (typeof value === "string") {
1072
764
  rules.push(`${key} { ${value.trim()} }`);
765
+ allDeclarations.push(value.trim());
1073
766
  continue;
1074
767
  }
1075
768
  const styleMap = value || {};
@@ -1114,21 +807,17 @@ function stepsToCSS(steps) {
1114
807
  });
1115
808
  const declarations = declarationPairs.map((d) => `${d.prop}: ${d.value}`).join("; ");
1116
809
  rules.push(`${key} { ${declarations.trim()} }`);
810
+ if (declarations) allDeclarations.push(declarations);
1117
811
  }
1118
- return rules.join(" ");
812
+ return {
813
+ css: rules.join(" "),
814
+ declarations: allDeclarations.join("; ")
815
+ };
1119
816
  }
1120
- /**
1121
- * Format a @keyframes rule as a CSS string.
1122
- */
1123
817
  function formatKeyframesCSS(name, steps) {
1124
- return `@keyframes ${name} { ${stepsToCSS(steps)} }`;
1125
- }
1126
- //#endregion
1127
- //#region src/ssr/format-rules.ts
1128
- /**
1129
- * Resolve selectors for a rule, applying className-based specificity doubling
1130
- * and rootPrefix handling. Mirrors the logic in StyleInjector.inject().
1131
- */
818
+ return `@keyframes ${name} { ${formatKeyframesSteps(steps).css} }`;
819
+ }
820
+ // src/ssr/format-rules.ts
1132
821
  function resolveSelector(rule, className) {
1133
822
  let selector = rule.selector;
1134
823
  if (rule.needsClassName) {
@@ -1142,10 +831,6 @@ function resolveSelector(rule, className) {
1142
831
  }
1143
832
  return selector;
1144
833
  }
1145
- /**
1146
- * Group rules by selector + at-rules + startingStyle and merge their declarations.
1147
- * Mirrors the grouping logic in SheetManager.insertRule().
1148
- */
1149
834
  function groupRules(rules) {
1150
835
  const groupMap = /* @__PURE__ */ new Map();
1151
836
  const order = [];
@@ -1166,15 +851,6 @@ function groupRules(rules) {
1166
851
  }
1167
852
  return order.map((key) => groupMap.get(key));
1168
853
  }
1169
- /**
1170
- * Format an array of StyleResult rules into a CSS text string.
1171
- *
1172
- * Applies className-based specificity doubling (.cls.cls),
1173
- * groups rules by selector + at-rules, and wraps with at-rule blocks.
1174
- *
1175
- * Produces the same CSS text as SheetManager.insertRule() would insert
1176
- * into the DOM, but as a plain string suitable for SSR output.
1177
- */
1178
854
  function formatRules(rules, className) {
1179
855
  if (rules.length === 0) return "";
1180
856
  const grouped = groupRules(rules.map((rule) => ({
@@ -1193,27 +869,19 @@ function formatRules(rules, className) {
1193
869
  }
1194
870
  return cssRules.join("\n");
1195
871
  }
1196
- //#endregion
1197
- //#region src/ssr/format-global-rules.ts
1198
- /**
1199
- * Format an array of global StyleResult rules into a CSS text string.
1200
- *
1201
- * Rules already have their full selectors applied by renderStyles().
1202
- * Handles rootPrefix prepending and at-rule wrapping.
1203
- */
872
+ // src/ssr/format-global-rules.ts
1204
873
  function formatGlobalRules(rules) {
1205
874
  if (rules.length === 0) return "";
1206
875
  const cssRules = [];
1207
876
  for (const rule of rules) {
1208
- const baseRule = `${rule.rootPrefix ? `${rule.rootPrefix} ${rule.selector}` : rule.selector} { ${rule.declarations} }`;
877
+ const baseRule = `${rule.rootPrefix ? `${rule.rootPrefix} ${rule.selector}` : rule.selector} { ${rule.startingStyle ? `@starting-style { ${rule.declarations} }` : rule.declarations} }`;
1209
878
  let fullRule = baseRule;
1210
879
  if (rule.atRules && rule.atRules.length > 0) fullRule = rule.atRules.reduce((css, atRule) => `${atRule} { ${css} }`, baseRule);
1211
880
  cssRules.push(fullRule);
1212
881
  }
1213
882
  return cssRules.join("\n");
1214
883
  }
1215
- //#endregion
1216
- //#region src/ssr/artifacts.ts
884
+ // src/ssr/artifacts.ts
1217
885
  function createServerStyleArtifact(kind, key, css, order) {
1218
886
  const content = `${kind}\0${key}\0${css}`;
1219
887
  return {
@@ -1223,7 +891,6 @@ function createServerStyleArtifact(kind, key, css, order) {
1223
891
  order
1224
892
  };
1225
893
  }
1226
- //#endregion
1227
- export { validateNamePrefix as A, formatFunctionPrelude as B, DEFAULT_NAME_PREFIX as C, makeKeyframeName as D, makeCounterStyleName as E, normalizePropertyDefinition as F, registerLocalFunctionPolyfills as G, hasLocalFunctions as H, parsePropertyToken as I, resetFunctionPolyfills as K, DEFAULT_PROPERTIES as L, extractLocalProperties as M, getEffectiveDefinition as N, rscClassRegexGlobal as O, hasLocalProperties as P, extractLocalFunctions as R, PropertyTypeResolver as S, makeClassName as T, parseFunctionName as U, formatFunctionRule as V, registerFunctionPolyfill as W, extractLocalFontFace as _, formatPropertyCSS as a, formatFontFaceRule as b, filterUsedKeyframes as c, replaceAnimationNames as d, resolveKeyframesNames as f, hasLocalCounterStyle as g, formatCounterStyleRule as h, formatKeyframesCSS as i, hashString as j, tastyClassRegex as k, hasLocalKeyframes as l, formatCounterStyleDeclarations as m, formatGlobalRules as n, extractAnimationNamesFromStyles as o, extractLocalCounterStyle as p, splitFunctions as q, formatRules as r, extractLocalKeyframes as s, createServerStyleArtifact as t, mergeKeyframes as u, fontFaceContentHash as v, DEFAULT_ZERO_NAME_PREFIX as w, hasLocalFontFace as x, formatFontFaceDeclarations as y, formatFunctionDeclarations as z };
894
+ export { rscClassRegexGlobal as A, parsePropertyToken as B, hasLocalFontFace as C, makeClassName as D, DEFAULT_ZERO_NAME_PREFIX as E, extractLocalProperties as F, hasLocalFunctions as G, formatFunctionDeclarations as H, getEffectiveDefinition as I, registerLocalFunctionPolyfills as J, parseFunctionName as K, hasLocalProperties as L, validateNamePrefix as M, hashString as N, makeCounterStyleName as O, DEFAULT_PROPERTIES as P, indexPropertiesByName as R, formatFontFaceRule as S, DEFAULT_NAME_PREFIX as T, formatFunctionPrelude as U, extractLocalFunctions as V, formatFunctionRule as W, splitFunctions as X, resetFunctionPolyfills as Y, formatCounterStyleRule as _, formatKeyframesSteps as a, fontFaceContentHash as b, extractLocalKeyframes as c, mergeKeyframes as d, replaceAnimationNames as f, formatCounterStyleDeclarations as g, extractLocalCounterStyle as h, formatKeyframesCSS as i, tastyClassRegex as j, makeKeyframeName as k, filterUsedKeyframes as l, resolveSelectorKeyframes as m, formatGlobalRules as n, formatPropertyCSS as o, resolveKeyframesNames as p, registerFunctionPolyfill as q, formatRules as r, extractAnimationNamesFromStyles as s, createServerStyleArtifact as t, hasLocalKeyframes as u, hasLocalCounterStyle as v, PropertyTypeResolver as w, formatFontFaceDeclarations as x, extractLocalFontFace as y, normalizePropertyDefinition as z };
1228
895
 
1229
- //# sourceMappingURL=css-definitions-z79zG4t4.js.map
896
+ //# sourceMappingURL=css-definitions-BkdTqT7G.js.map