@tenphi/tasty 0.0.0-snapshot.b1f3c1d → 0.0.0-snapshot.b26c0fb

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 (68) hide show
  1. package/README.md +4 -1
  2. package/dist/async-storage-B7_o6FKt.js.map +1 -1
  3. package/dist/{collector-C4sagPeG.js → collector-BMEQCkCn.js} +24 -11
  4. package/dist/collector-BMEQCkCn.js.map +1 -0
  5. package/dist/{collector-LuU1vZ68.d.ts → collector-osfWTeRd.d.ts} +12 -2
  6. package/dist/{config-vuCRkBWX.d.ts → config-BoZDUHW5.d.ts} +65 -4
  7. package/dist/{config-BovFXQil.js → config-eiremPHv.js} +1647 -1322
  8. package/dist/config-eiremPHv.js.map +1 -0
  9. package/dist/context-CkSg-kDT.js.map +1 -1
  10. package/dist/core/index.d.ts +5 -5
  11. package/dist/core/index.js +6 -6
  12. package/dist/{core-CpKZ2RrZ.js → core-2WW5vub2.js} +18 -12
  13. package/dist/core-2WW5vub2.js.map +1 -0
  14. package/dist/{css-writer-BYgviy4G.js → css-writer-BL5_AeZQ.js} +28 -6
  15. package/dist/css-writer-BL5_AeZQ.js.map +1 -0
  16. package/dist/format-global-rules-Dbc_1tc3.js.map +1 -1
  17. package/dist/{format-rules-BBK7s2il.js → format-rules-DcFFQceU.js} +2 -2
  18. package/dist/{format-rules-BBK7s2il.js.map → format-rules-DcFFQceU.js.map} +1 -1
  19. package/dist/{hydrate-DN98QICD.js → hydrate-B6SjFHhj.js} +2 -2
  20. package/dist/{hydrate-DN98QICD.js.map → hydrate-B6SjFHhj.js.map} +1 -1
  21. package/dist/{index-ZRxZWzlj.d.ts → index-CZ3WFJih.d.ts} +114 -21
  22. package/dist/{index-dUtwpOux.d.ts → index-tcHuMPFt.d.ts} +22 -2
  23. package/dist/index.d.ts +5 -5
  24. package/dist/index.js +10 -10
  25. package/dist/index.js.map +1 -1
  26. package/dist/{keyframes-Bzl_6mN0.js → keyframes-iG6UhjrP.js} +3 -2
  27. package/dist/keyframes-iG6UhjrP.js.map +1 -0
  28. package/dist/{merge-styles-BjdI0NVL.js → merge-styles-3il_ClCF.js} +2 -2
  29. package/dist/{merge-styles-BjdI0NVL.js.map → merge-styles-3il_ClCF.js.map} +1 -1
  30. package/dist/{merge-styles-CtDJMhpJ.d.ts → merge-styles-BMWcH6MF.d.ts} +2 -2
  31. package/dist/{resolve-recipes-9zJQojHT.js → resolve-recipes-B3MSkfFQ.js} +3 -3
  32. package/dist/{resolve-recipes-9zJQojHT.js.map → resolve-recipes-B3MSkfFQ.js.map} +1 -1
  33. package/dist/ssr/astro-client.js +1 -1
  34. package/dist/ssr/astro-client.js.map +1 -1
  35. package/dist/ssr/astro-middleware.js.map +1 -1
  36. package/dist/ssr/astro.d.ts +1 -12
  37. package/dist/ssr/astro.js +3 -3
  38. package/dist/ssr/astro.js.map +1 -1
  39. package/dist/ssr/index.d.ts +1 -1
  40. package/dist/ssr/index.js +3 -3
  41. package/dist/ssr/next.d.ts +1 -1
  42. package/dist/ssr/next.js +4 -4
  43. package/dist/ssr/next.js.map +1 -1
  44. package/dist/static/index.d.ts +2 -2
  45. package/dist/static/index.js +1 -1
  46. package/dist/static/index.js.map +1 -1
  47. package/dist/static/inject.js.map +1 -1
  48. package/dist/zero/babel.d.ts +1 -1
  49. package/dist/zero/babel.js +16 -8
  50. package/dist/zero/babel.js.map +1 -1
  51. package/dist/zero/index.d.ts +1 -1
  52. package/dist/zero/index.js +1 -1
  53. package/dist/zero/next.js.map +1 -1
  54. package/docs/configuration.md +44 -0
  55. package/docs/dsl.md +14 -13
  56. package/docs/methodology.md +26 -0
  57. package/docs/pipeline.md +40 -14
  58. package/docs/react-api.md +24 -0
  59. package/docs/ssr.md +5 -3
  60. package/docs/styles.md +9 -7
  61. package/docs/tasty-static.md +15 -0
  62. package/package.json +18 -9
  63. package/tasty.config.ts +1 -0
  64. package/dist/collector-C4sagPeG.js.map +0 -1
  65. package/dist/config-BovFXQil.js.map +0 -1
  66. package/dist/core-CpKZ2RrZ.js.map +0 -1
  67. package/dist/css-writer-BYgviy4G.js.map +0 -1
  68. package/dist/keyframes-Bzl_6mN0.js.map +0 -1
package/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  <p align="center">
8
8
  <strong>Deterministic styling for stateful component systems.</strong><br>
9
- A design-system styling engine that compiles component states into mutually exclusive selectors.
9
+ A design-system styling engine that compiles component states into mutually exclusive selectors, so complex components stay predictable as they evolve.
10
10
  </p>
11
11
 
12
12
  <p align="center">
@@ -23,6 +23,8 @@ It compiles state maps into **mutually exclusive selectors**, so for a given pro
23
23
 
24
24
  That is the core guarantee: component styling resolves from declared state logic, not from source-order accidents or specificity fights.
25
25
 
26
+ The practical payoff shows up later: adding states, variants, and overrides stays inside the state map instead of reopening selector logic by hand.
27
+
26
28
  Tasty fits best when you are building a design system or component library with intersecting states, variants, tokens, sub-elements, responsive rules, and extension semantics that need to stay predictable over time.
27
29
 
28
30
  On top of that foundation, Tasty gives teams a governed styling model: a CSS-like DSL, tokens, recipes, typed style props, sub-elements, and multiple rendering modes.
@@ -35,6 +37,7 @@ On top of that foundation, Tasty gives teams a governed styling model: a CSS-lik
35
37
  ## Why Tasty
36
38
 
37
39
  - **Deterministic composition, not cascade fights** — Stateful styles resolve from the state map you declared, not from selector competition. See [How It Actually Works](#how-it-actually-works).
40
+ - **Easier to extend over time** — When components gain new states, variants, or overrides, you update declared branches instead of re-deriving selector interactions by hand.
38
41
  - **Built for design-system teams** — Best fit for reusable component systems with complex state interactions.
39
42
  - **A governed styling model, not just syntax sugar** — Design-system authors define the styling language product teams consume.
40
43
  - **DSL that still feels like CSS** — Familiar property names, less selector boilerplate. Start with the [Style DSL](docs/dsl.md), then use [Style Properties](docs/styles.md) as the handler reference.
@@ -1 +1 @@
1
- {"version":3,"file":"async-storage-B7_o6FKt.js","names":[],"sources":["../src/ssr/async-storage.ts"],"sourcesContent":["/**\n * AsyncLocalStorage integration for SSR collector discovery.\n *\n * Used by Astro middleware and generic framework integrations where\n * the library cannot wrap the React tree with a context provider.\n * The middleware calls runWithCollector() around the render, and\n * useStyles() calls getSSRCollector() to find it.\n *\n * Uses globalThis to ensure the AsyncLocalStorage instance is shared\n * across module instances — frameworks like Astro may load middleware\n * and page components from separate module graphs.\n *\n * This module imports from 'node:async_hooks' — it must be excluded\n * from client bundles via the build configuration.\n */\n\nimport { AsyncLocalStorage } from 'node:async_hooks';\n\nimport type { ServerStyleCollector } from './collector';\n\nconst ALS_KEY = '__tasty_ssr_als__';\n\nfunction getSharedStorage(): AsyncLocalStorage<ServerStyleCollector> {\n const g = globalThis as Record<string, unknown>;\n if (!g[ALS_KEY]) {\n g[ALS_KEY] = new AsyncLocalStorage<ServerStyleCollector>();\n }\n return g[ALS_KEY] as AsyncLocalStorage<ServerStyleCollector>;\n}\n\n/**\n * Run a function with a ServerStyleCollector bound to the current\n * async context. All useStyles() calls within `fn` (and any async\n * continuations) will find this collector via getSSRCollector().\n */\nexport function runWithCollector<T>(\n collector: ServerStyleCollector,\n fn: () => T,\n): T {\n return getSharedStorage().run(collector, fn);\n}\n\n/**\n * Retrieve the ServerStyleCollector bound to the current async context.\n * Returns null when called outside of runWithCollector() or on the client.\n */\nexport function getSSRCollector(): ServerStyleCollector | null {\n const storage = getSharedStorage();\n if (typeof storage?.getStore !== 'function') return null;\n return storage.getStore() ?? null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAoBA,MAAM,UAAU;AAEhB,SAAS,mBAA4D;CACnE,MAAM,IAAI;AACV,KAAI,CAAC,EAAE,SACL,GAAE,WAAW,IAAI,mBAAyC;AAE5D,QAAO,EAAE;;;;;;;AAQX,SAAgB,iBACd,WACA,IACG;AACH,QAAO,kBAAkB,CAAC,IAAI,WAAW,GAAG;;;;;;AAO9C,SAAgB,kBAA+C;CAC7D,MAAM,UAAU,kBAAkB;AAClC,KAAI,OAAO,SAAS,aAAa,WAAY,QAAO;AACpD,QAAO,QAAQ,UAAU,IAAI"}
1
+ {"version":3,"file":"async-storage-B7_o6FKt.js","names":[],"sources":["../src/ssr/async-storage.ts"],"sourcesContent":["/**\n * AsyncLocalStorage integration for SSR collector discovery.\n *\n * Used by Astro middleware and generic framework integrations where\n * the library cannot wrap the React tree with a context provider.\n * The middleware calls runWithCollector() around the render, and\n * useStyles() calls getSSRCollector() to find it.\n *\n * Uses globalThis to ensure the AsyncLocalStorage instance is shared\n * across module instances — frameworks like Astro may load middleware\n * and page components from separate module graphs.\n *\n * This module imports from 'node:async_hooks' — it must be excluded\n * from client bundles via the build configuration.\n */\n\nimport { AsyncLocalStorage } from 'node:async_hooks';\n\nimport type { ServerStyleCollector } from './collector';\n\nconst ALS_KEY = '__tasty_ssr_als__';\n\nfunction getSharedStorage(): AsyncLocalStorage<ServerStyleCollector> {\n const g = globalThis as Record<string, unknown>;\n if (!g[ALS_KEY]) {\n g[ALS_KEY] = new AsyncLocalStorage<ServerStyleCollector>();\n }\n return g[ALS_KEY] as AsyncLocalStorage<ServerStyleCollector>;\n}\n\n/**\n * Run a function with a ServerStyleCollector bound to the current\n * async context. All useStyles() calls within `fn` (and any async\n * continuations) will find this collector via getSSRCollector().\n */\nexport function runWithCollector<T>(\n collector: ServerStyleCollector,\n fn: () => T,\n): T {\n return getSharedStorage().run(collector, fn);\n}\n\n/**\n * Retrieve the ServerStyleCollector bound to the current async context.\n * Returns null when called outside of runWithCollector() or on the client.\n */\nexport function getSSRCollector(): ServerStyleCollector | null {\n const storage = getSharedStorage();\n if (typeof storage?.getStore !== 'function') return null;\n return storage.getStore() ?? null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAoBA,MAAM,UAAU;AAEhB,SAAS,mBAA4D;CACnE,MAAM,IAAI;CACV,IAAI,CAAC,EAAE,UACL,EAAE,WAAW,IAAI,mBAAyC;CAE5D,OAAO,EAAE;;;;;;;AAQX,SAAgB,iBACd,WACA,IACG;CACH,OAAO,kBAAkB,CAAC,IAAI,WAAW,GAAG;;;;;;AAO9C,SAAgB,kBAA+C;CAC7D,MAAM,UAAU,kBAAkB;CAClC,IAAI,OAAO,SAAS,aAAa,YAAY,OAAO;CACpD,OAAO,QAAQ,UAAU,IAAI"}
@@ -1,5 +1,5 @@
1
- import { F as formatFontFaceRule, P as fontFaceContentHash, a as getGlobalCounterStyle, ct as hashString, i as getGlobalConfigTokens, j as formatCounterStyleRule, o as getGlobalFontFace, r as getEffectiveProperties, u as getGlobalStyles, x as renderStyles } from "./config-BovFXQil.js";
2
- import { n as formatPropertyCSS, t as formatRules } from "./format-rules-BBK7s2il.js";
1
+ import { F as fontFaceContentHash, I as formatFontFaceRule, M as formatCounterStyleRule, S as renderStyles, a as getGlobalCounterStyle, d as getNamePrefix, dt as makeCounterStyleName, ft as makeKeyframeName, gt as hashString, i as getGlobalConfigTokens, mt as validateNamePrefix, o as getGlobalFontFace, r as getEffectiveProperties, u as getGlobalStyles, ut as makeClassName } from "./config-eiremPHv.js";
2
+ import { n as formatPropertyCSS, t as formatRules } from "./format-rules-DcFFQceU.js";
3
3
  import { t as formatGlobalRules } from "./format-global-rules-Dbc_1tc3.js";
4
4
  //#region src/ssr/collector.ts
5
5
  /**
@@ -7,15 +7,13 @@ import { t as formatGlobalRules } from "./format-global-rules-Dbc_1tc3.js";
7
7
  *
8
8
  * Accumulates CSS rules and cache metadata during server rendering.
9
9
  * This is the server-side counterpart to StyleInjector: it allocates
10
- * hash-based class names (`t${hash}`), formats CSS rules into text,
11
- * and tracks rendered class names for lightweight client transfer.
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.
12
13
  *
13
14
  * One instance is created per HTTP request. Concurrent requests
14
15
  * each get their own collector (via AsyncLocalStorage or React context).
15
16
  */
16
- function generateClassName(cacheKey) {
17
- return `t${hashString(cacheKey)}`;
18
- }
19
17
  var ServerStyleCollector = class {
20
18
  chunks = /* @__PURE__ */ new Map();
21
19
  cacheKeyToClassName = /* @__PURE__ */ new Map();
@@ -35,6 +33,21 @@ var ServerStyleCollector = class {
35
33
  keyframesCounter = 0;
36
34
  counterStyleCounter = 0;
37
35
  internalsCollected = false;
36
+ namePrefix;
37
+ /**
38
+ * @param namePrefix - Optional override for the configured prefix.
39
+ * Defaults to the value from `configure({ namePrefix })` (or `'t'`).
40
+ * Pass an explicit prefix when constructing a collector outside the
41
+ * normal configure() lifecycle (e.g. in tests). Validated eagerly
42
+ * so misconfiguration fails before any CSS is collected.
43
+ */
44
+ constructor(namePrefix) {
45
+ if (namePrefix !== void 0) validateNamePrefix(namePrefix);
46
+ this.namePrefix = namePrefix ?? getNamePrefix();
47
+ }
48
+ generateClassName(cacheKey) {
49
+ return makeClassName(this.namePrefix, hashString(cacheKey));
50
+ }
38
51
  /**
39
52
  * Collect internal @property rules and :root token defaults.
40
53
  * Mirrors markStylesGenerated() from the client-side injector.
@@ -94,7 +107,7 @@ var ServerStyleCollector = class {
94
107
  className: existing,
95
108
  isNewAllocation: false
96
109
  };
97
- const className = generateClassName(cacheKey);
110
+ const className = this.generateClassName(cacheKey);
98
111
  this.cacheKeyToClassName.set(cacheKey, className);
99
112
  return {
100
113
  className,
@@ -126,7 +139,7 @@ var ServerStyleCollector = class {
126
139
  * Allocate a keyframe name for SSR. Uses provided name or generates one.
127
140
  */
128
141
  allocateKeyframeName(providedName) {
129
- return providedName ?? `k${this.keyframesCounter++}`;
142
+ return providedName ?? makeKeyframeName(this.namePrefix, String(this.keyframesCounter++));
130
143
  }
131
144
  /**
132
145
  * Record a @font-face rule. Deduplicated by key (content hash).
@@ -144,7 +157,7 @@ var ServerStyleCollector = class {
144
157
  * Allocate a counter-style name for SSR. Uses provided name or generates one.
145
158
  */
146
159
  allocateCounterStyleName(providedName) {
147
- return providedName ?? `cs${this.counterStyleCounter++}`;
160
+ return providedName ?? makeCounterStyleName(this.namePrefix, String(this.counterStyleCounter++));
148
161
  }
149
162
  /**
150
163
  * Record global styles (from useGlobalStyles). Deduplicated by key.
@@ -227,4 +240,4 @@ var ServerStyleCollector = class {
227
240
  //#endregion
228
241
  export { ServerStyleCollector as t };
229
242
 
230
- //# sourceMappingURL=collector-C4sagPeG.js.map
243
+ //# sourceMappingURL=collector-BMEQCkCn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collector-BMEQCkCn.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 getGlobalCounterStyle,\n getGlobalFontFace,\n getGlobalConfigTokens,\n getNamePrefix,\n} from '../config';\nimport { formatCounterStyleRule } from '../counter-style';\nimport { fontFaceContentHash, formatFontFaceRule } from '../font-face';\nimport { renderStyles } from '../pipeline';\nimport type { StyleResult } from '../pipeline';\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 { formatRules } from './format-rules';\n\nexport class ServerStyleCollector {\n private chunks = new Map<string, string>();\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 keyframesCounter = 0;\n private counterStyleCounter = 0;\n private internalsCollected = false;\n private namePrefix: string;\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 generateClassName(cacheKey: string): string {\n return makeClassName(this.namePrefix, hashString(cacheKey));\n }\n\n /**\n * Collect internal @property rules and :root token defaults.\n * Mirrors markStylesGenerated() from the client-side injector.\n * Called automatically on first chunk collection; idempotent.\n *\n * Internals are always emitted here — the RSC path deliberately\n * defers to SSR so that tokens appear exactly once per page in\n * <style data-tasty-ssr> (avoiding duplication of large token sets).\n */\n collectInternals(): void {\n if (this.internalsCollected) return;\n this.internalsCollected = true;\n\n for (const [token, definition] of Object.entries(\n getEffectiveProperties(),\n )) {\n const css = formatPropertyCSS(token, definition);\n if (css) {\n this.collectProperty(`__prop:${token}`, css);\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);\n }\n }\n }\n\n const globalFF = getGlobalFontFace();\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);\n }\n }\n }\n\n const globalCS = getGlobalCounterStyle();\n if (globalCS) {\n for (const [name, descriptors] of Object.entries(globalCS)) {\n const css = formatCounterStyleRule(name, descriptors);\n this.collectCounterStyle(name, css);\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(`__global:styles:${selector}`, css);\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 = formatRules(rules, className);\n if (css) {\n this.chunks.set(cacheKey, css);\n }\n }\n\n /**\n * Record a @property rule. Deduplicated by name.\n */\n collectProperty(name: string, css: string): void {\n if (!this.propertyRules.has(name)) {\n this.propertyRules.set(name, css);\n }\n }\n\n /**\n * Record a @keyframes rule. Deduplicated by name.\n */\n collectKeyframes(name: string, css: string): void {\n if (!this.keyframeRules.has(name)) {\n this.keyframeRules.set(name, css);\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(key: string, css: string): void {\n if (!this.fontFaceRules.has(key)) {\n this.fontFaceRules.set(key, css);\n }\n }\n\n /**\n * Record a @counter-style rule. Deduplicated by name.\n */\n collectCounterStyle(name: string, css: string): void {\n if (!this.counterStyleRules.has(name)) {\n this.counterStyleRules.set(name, css);\n }\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 collectGlobalStyles(key: string, css: string): void {\n if (!this.globalStyles.has(key)) {\n this.globalStyles.set(key, css);\n }\n }\n\n /**\n * Record raw CSS text (from useRawCSS). Deduplicated by key.\n */\n collectRawCSS(key: string, css: string): void {\n if (!this.rawCSS.has(key)) {\n this.rawCSS.set(key, css);\n }\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 const parts: string[] = [];\n\n for (const css of this.propertyRules.values()) {\n parts.push(css);\n }\n\n for (const css of this.fontFaceRules.values()) {\n parts.push(css);\n }\n\n for (const css of this.counterStyleRules.values()) {\n parts.push(css);\n }\n\n for (const css of this.rawCSS.values()) {\n parts.push(css);\n }\n\n for (const css of this.globalStyles.values()) {\n parts.push(css);\n }\n\n for (const css of this.chunks.values()) {\n parts.push(css);\n }\n\n for (const css of this.keyframeRules.values()) {\n parts.push(css);\n }\n\n return parts.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.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"],"mappings":";;;;;;;;;;;;;;;;AAoCA,IAAa,uBAAb,MAAkC;CAChC,yBAAiB,IAAI,KAAqB;CAC1C,sCAA8B,IAAI,KAAqB;CACvD,8BAAsB,IAAI,KAAa;CACvC,gCAAwB,IAAI,KAAqB;CACjD,sCAA8B,IAAI,KAAa;CAC/C,gCAAwB,IAAI,KAAqB;CACjD,sCAA8B,IAAI,KAAa;CAC/C,+BAAuB,IAAI,KAAqB;CAChD,oCAA4B,IAAI,KAAa;CAC7C,yBAAiB,IAAI,KAAqB;CAC1C,iCAAyB,IAAI,KAAa;CAC1C,gCAAwB,IAAI,KAAqB;CACjD,sCAA8B,IAAI,KAAa;CAC/C,oCAA4B,IAAI,KAAqB;CACrD,0CAAkC,IAAI,KAAa;CACnD,mBAA2B;CAC3B,sBAA8B;CAC9B,qBAA6B;CAC7B;;;;;;;;CASA,YAAY,YAAqB;EAC/B,IAAI,eAAe,KAAA,GACjB,mBAAmB,WAAW;EAEhC,KAAK,aAAa,c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KAAK,QAAQ,KAAK,QAC5B,IAAI,CAAC,KAAK,eAAe,IAAI,IAAI,EAAE;GACjC,MAAM,KAAK,IAAI;GACf,KAAK,eAAe,IAAI,IAAI;;EAIhC,KAAK,MAAM,CAAC,KAAK,QAAQ,KAAK,cAC5B,IAAI,CAAC,KAAK,kBAAkB,IAAI,IAAI,EAAE;GACpC,MAAM,KAAK,IAAI;GACf,KAAK,kBAAkB,IAAI,IAAI;;EAInC,KAAK,MAAM,CAAC,KAAK,QAAQ,KAAK,QAC5B,IAAI,CAAC,KAAK,YAAY,IAAI,IAAI,EAAE;GAC9B,MAAM,KAAK,IAAI;GACf,KAAK,YAAY,IAAI,IAAI;;EAI7B,KAAK,MAAM,CAAC,MAAM,QAAQ,KAAK,eAC7B,IAAI,CAAC,KAAK,oBAAoB,IAAI,KAAK,EAAE;GACvC,MAAM,KAAK,IAAI;GACf,KAAK,oBAAoB,IAAI,KAAK;;EAItC,OAAO,MAAM,KAAK,KAAK;;CAGzB,oCAA4B,IAAI,KAAa;;;;;CAM7C,wBAAkC;EAChC,MAAM,QAAkB,EAAE;EAC1B,KAAK,MAAM,aAAa,KAAK,oBAAoB,QAAQ,EACvD,IAAI,CAAC,KAAK,kBAAkB,IAAI,UAAU,EAAE;GAC1C,KAAK,kBAAkB,IAAI,UAAU;GACrC,MAAM,KAAK,UAAU;;EAGzB,OAAO"}
@@ -1,4 +1,4 @@
1
- import { n as StyleResult } from "./index-dUtwpOux.js";
1
+ import { n as StyleResult } from "./index-tcHuMPFt.js";
2
2
 
3
3
  //#region src/ssr/collector.d.ts
4
4
  declare class ServerStyleCollector {
@@ -20,6 +20,16 @@ declare class ServerStyleCollector {
20
20
  private keyframesCounter;
21
21
  private counterStyleCounter;
22
22
  private internalsCollected;
23
+ private namePrefix;
24
+ /**
25
+ * @param namePrefix - Optional override for the configured prefix.
26
+ * Defaults to the value from `configure({ namePrefix })` (or `'t'`).
27
+ * Pass an explicit prefix when constructing a collector outside the
28
+ * normal configure() lifecycle (e.g. in tests). Validated eagerly
29
+ * so misconfiguration fails before any CSS is collected.
30
+ */
31
+ constructor(namePrefix?: string);
32
+ private generateClassName;
23
33
  /**
24
34
  * Collect internal @property rules and :root token defaults.
25
35
  * Mirrors markStylesGenerated() from the client-side injector.
@@ -95,4 +105,4 @@ declare class ServerStyleCollector {
95
105
  }
96
106
  //#endregion
97
107
  export { ServerStyleCollector as t };
98
- //# sourceMappingURL=collector-LuU1vZ68.d.ts.map
108
+ //# sourceMappingURL=collector-osfWTeRd.d.ts.map
@@ -1,4 +1,4 @@
1
- import { Ct as RawCSSResult, Dt as StyleInjectorConfig, Et as SheetInfo, M as StyleHandlerDefinition, Ot as StyleRule, St as PropertyDefinition, Tt as RuleInfo, b as Styles, bt as KeyframesResult, ct as CacheMetrics, dt as FontFaceDescriptors, ft as FontFaceInput, gt as InjectResult, h as ConfigTokens, ht as GlobalInjectResult, it as StyleDetails, lt as CounterStyleDescriptors, mt as GCOptions, n as StyleResult, ot as UnitHandler, pt as GCConfig, v as RecipeStyles, wt as RootRegistry, xt as KeyframesSteps, yt as KeyframesInfo } from "./index-dUtwpOux.js";
1
+ import { Ct as RawCSSResult, Dt as StyleInjectorConfig, Et as SheetInfo, M as StyleHandlerDefinition, Ot as StyleRule, St as PropertyDefinition, Tt as RuleInfo, b as Styles, bt as KeyframesResult, ct as CacheMetrics, dt as FontFaceDescriptors, ft as FontFaceInput, gt as InjectResult, h as ConfigTokens, ht as GlobalInjectResult, it as StyleDetails, lt as CounterStyleDescriptors, mt as GCOptions, n as StyleResult, ot as UnitHandler, pt as GCConfig, v as RecipeStyles, wt as RootRegistry, xt as KeyframesSteps, yt as KeyframesInfo } from "./index-tcHuMPFt.js";
2
2
 
3
3
  //#region src/injector/sheet-manager.d.ts
4
4
  declare class SheetManager {
@@ -73,6 +73,23 @@ declare class SheetManager {
73
73
  * Find an available rule index in the sheet
74
74
  */
75
75
  findAvailableRuleIndex(sheet: SheetInfo): number;
76
+ /**
77
+ * Probe whether the underlying CSS engine supports `@property` at-rules.
78
+ * Result is cached per registry on `registry.atPropertySupported`.
79
+ *
80
+ * The probe inserts and immediately deletes a minimal known-valid rule
81
+ * (`@property --__tasty_probe__ { syntax: "*"; inherits: true; }`).
82
+ * Engines that lack `@property` support (jsdom, happy-dom) reject any
83
+ * `@property` rule including this one, so a probe failure is a reliable
84
+ * signal that further `@property` rejections are environmental noise and
85
+ * not user-authored bugs.
86
+ *
87
+ * The probe is intentionally a separate operation from the user's failing
88
+ * insertion: we don't want to leak `--__tasty_probe__` into the sheet, so
89
+ * on success we delete the probe rule immediately, leaving `ruleCount`
90
+ * and `cssRules.length` unchanged.
91
+ */
92
+ private engineSupportsAtProperty;
76
93
  /**
77
94
  * Force cleanup of unused styles
78
95
  */
@@ -161,9 +178,18 @@ declare class StyleInjector {
161
178
  private config;
162
179
  private globalRuleCounter;
163
180
  private pendingGCHandle;
181
+ private namePrefix;
182
+ private classRegex;
183
+ private rscClassRegex;
164
184
  /** @internal — exposed for debug utilities only */
165
185
  get _sheetManager(): SheetManager;
166
186
  constructor(config?: StyleInjectorConfig);
187
+ /**
188
+ * Generate a deterministic class name from a cache key using content hash.
189
+ * The same cache key always produces the same class name across environments
190
+ * with the same `namePrefix`.
191
+ */
192
+ private generateClassName;
167
193
  /**
168
194
  * Check if `className` was hydrated from server-rendered styles and,
169
195
  * if so, wire the cacheKey mapping. Returns true on hit.
@@ -268,6 +294,11 @@ declare class StyleInjector {
268
294
  property(name: string, options?: PropertyDefinition & {
269
295
  root?: Document | ShadowRoot;
270
296
  }): void;
297
+ /**
298
+ * Build and insert a single `@property` rule into the given registry.
299
+ * No-op if the property was already injected.
300
+ */
301
+ private insertPropertyRule;
271
302
  /**
272
303
  * Check whether a given @property name was already injected by this injector.
273
304
  *
@@ -314,7 +345,6 @@ declare class StyleInjector {
314
345
  * Dispose keyframes
315
346
  */
316
347
  private disposeKeyframes;
317
- private static readonly TASTY_CLASS_RE;
318
348
  /**
319
349
  * Record a render-time usage hit for one or more classNames.
320
350
  * Handles space-separated multi-chunk classNames.
@@ -551,6 +581,28 @@ interface TastyConfig {
551
581
  * ```
552
582
  */
553
583
  gc?: GCConfig;
584
+ /**
585
+ * Prefix prepended to every generated identifier (class names,
586
+ * keyframe names, counter-style names). The hash is appended verbatim,
587
+ * so include any separator inside the prefix itself (e.g. `'myapp-'`).
588
+ *
589
+ * Discriminator letters are inserted between the prefix and the hash
590
+ * for non-class names so the three kinds stay visually distinct:
591
+ * - class: `${namePrefix}${hash}` — e.g. `t1a2b3`
592
+ * - keyframe: `${namePrefix}k${hash}` — e.g. `tk1a2b3`
593
+ * - counter-style: `${namePrefix}c${hash}` — e.g. `tc1a2b3`
594
+ *
595
+ * The runtime, SSR, and RSC paths must agree on this value or
596
+ * hydration will mismatch. The zero-runtime build path defaults to
597
+ * `'ts'` (overridable via the same option) so its classes can't
598
+ * collide with runtime classes when both are loaded on the same page.
599
+ *
600
+ * Must match `^[a-zA-Z][a-zA-Z0-9_-]{0,31}$`. Locked once styles
601
+ * have been generated.
602
+ *
603
+ * @default 't'
604
+ */
605
+ namePrefix?: string;
554
606
  /**
555
607
  * Plugins that extend tasty with custom functions, units, or states.
556
608
  * Plugins are processed in order, with later plugins overriding earlier ones.
@@ -874,11 +926,20 @@ declare function configure(config?: Partial<TastyConfig>): void;
874
926
  * If not configured, returns default configuration.
875
927
  */
876
928
  declare function getConfig(): TastyConfig;
929
+ /**
930
+ * Get the configured prefix used for every generated identifier
931
+ * (class names, keyframe names, counter-style names).
932
+ *
933
+ * Falls back to the default prefix (`'t'`) when `configure()` has not
934
+ * been called yet — this matches the auto-configuration behavior used
935
+ * by the rest of the system.
936
+ */
937
+ declare function getNamePrefix(): string;
877
938
  /**
878
939
  * Reset configuration (for testing only).
879
940
  * Clears the global injector and allows reconfiguration.
880
941
  */
881
942
  declare function resetConfig(): void;
882
943
  //#endregion
883
- export { TypographyTokenValue as _, getGlobalFontFace as a, StyleInjector as b, hasGlobalKeyframes as c, isConfigLocked as d, isTestEnvironment as f, TypographyPreset as g, TastyPluginFactory as h, getGlobalCounterStyle as i, hasGlobalRecipes as l, TastyPlugin as m, configure as n, getGlobalKeyframes as o, resetConfig as p, getConfig as r, getGlobalRecipes as s, TastyConfig as t, hasStylesGenerated as u, generateTypographyTokens as v, SheetManager as x, ColorSpace as y };
884
- //# sourceMappingURL=config-vuCRkBWX.d.ts.map
944
+ export { SheetManager as S, TypographyPreset as _, getGlobalFontFace as a, ColorSpace as b, getNamePrefix as c, hasStylesGenerated as d, isConfigLocked as f, TastyPluginFactory as g, TastyPlugin as h, getGlobalCounterStyle as i, hasGlobalKeyframes as l, resetConfig as m, configure as n, getGlobalKeyframes as o, isTestEnvironment as p, getConfig as r, getGlobalRecipes as s, TastyConfig as t, hasGlobalRecipes as u, TypographyTokenValue as v, StyleInjector as x, generateTypographyTokens as y };
945
+ //# sourceMappingURL=config-BoZDUHW5.d.ts.map