@tenphi/tasty 2.11.1 → 2.11.2

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 (46) hide show
  1. package/dist/{collector-AHZaBSv8.js → collector-D0cgyN6N.js} +13 -7
  2. package/dist/collector-D0cgyN6N.js.map +1 -0
  3. package/dist/{collector-DYA5AOwr.d.ts → collector-yqgjGje7.d.ts} +10 -4
  4. package/dist/{config-BtK9fUaz.d.ts → config-V0XC9iz_.d.ts} +15 -2
  5. package/dist/{config-YDAcLaVf.js → config-_cYm9LPl.js} +68 -15
  6. package/dist/config-_cYm9LPl.js.map +1 -0
  7. package/dist/core/index.d.ts +4 -4
  8. package/dist/core/index.js +5 -5
  9. package/dist/{core-CS4bzqGu.js → core-DdjoZG0r.js} +21 -7
  10. package/dist/core-DdjoZG0r.js.map +1 -0
  11. package/dist/{css-writer-BXSANVrq.js → css-writer-DTUwLjgD.js} +3 -3
  12. package/dist/{css-writer-BXSANVrq.js.map → css-writer-DTUwLjgD.js.map} +1 -1
  13. package/dist/{format-rules-CYriCDwq.js → format-rules-Bu_qoamZ.js} +2 -2
  14. package/dist/{format-rules-CYriCDwq.js.map → format-rules-Bu_qoamZ.js.map} +1 -1
  15. package/dist/{hydrate-GVTorHpU.js → hydrate-CKk-rgmY.js} +2 -2
  16. package/dist/{hydrate-GVTorHpU.js.map → hydrate-CKk-rgmY.js.map} +1 -1
  17. package/dist/{index-BYtnj_gA.d.ts → index-BjnGYI5D.d.ts} +15 -7
  18. package/dist/{index-B9ih23uv.d.ts → index-tRick_JW.d.ts} +12 -1
  19. package/dist/index.d.ts +4 -4
  20. package/dist/index.js +122 -51
  21. package/dist/index.js.map +1 -1
  22. package/dist/{keyframes-CtcSlw4k.js → keyframes-5LJYS8_P.js} +2 -2
  23. package/dist/{keyframes-CtcSlw4k.js.map → keyframes-5LJYS8_P.js.map} +1 -1
  24. package/dist/{merge-styles-D4ITH4bc.js → merge-styles-Blrs8kLM.js} +2 -2
  25. package/dist/{merge-styles-D4ITH4bc.js.map → merge-styles-Blrs8kLM.js.map} +1 -1
  26. package/dist/{merge-styles-BZV-XAwX.d.ts → merge-styles-DDss7wRH.d.ts} +2 -2
  27. package/dist/{resolve-recipes-llr0COs8.js → resolve-recipes-DR5cSG3X.js} +3 -3
  28. package/dist/{resolve-recipes-llr0COs8.js.map → resolve-recipes-DR5cSG3X.js.map} +1 -1
  29. package/dist/ssr/astro-client.js +1 -1
  30. package/dist/ssr/astro.js +3 -3
  31. package/dist/ssr/index.d.ts +1 -1
  32. package/dist/ssr/index.js +3 -3
  33. package/dist/ssr/next.d.ts +1 -1
  34. package/dist/ssr/next.js +4 -4
  35. package/dist/static/index.d.ts +2 -2
  36. package/dist/static/index.js +1 -1
  37. package/dist/zero/babel.d.ts +1 -1
  38. package/dist/zero/babel.js +4 -4
  39. package/dist/zero/index.d.ts +1 -1
  40. package/dist/zero/index.js +1 -1
  41. package/docs/injector.md +15 -0
  42. package/docs/react-api.md +21 -2
  43. package/package.json +4 -4
  44. package/dist/collector-AHZaBSv8.js.map +0 -1
  45. package/dist/config-YDAcLaVf.js.map +0 -1
  46. package/dist/core-CS4bzqGu.js.map +0 -1
@@ -1,5 +1,5 @@
1
- import { F as fontFaceContentHash, I as formatFontFaceRule, M as formatCounterStyleRule, S as renderStyles, a as getGlobalCounterStyle, d as getNamePrefix, ft as makeClassName, gt as validateNamePrefix, i as getGlobalConfigTokens, mt as makeKeyframeName, o as getGlobalFontFace, pt as makeCounterStyleName, r as getEffectiveProperties, u as getGlobalStyles, vt as hashString } from "./config-YDAcLaVf.js";
2
- import { n as formatPropertyCSS, t as formatRules } from "./format-rules-CYriCDwq.js";
1
+ import { F as fontFaceContentHash, I as formatFontFaceRule, M as formatCounterStyleRule, S as renderStyles, a as getGlobalCounterStyle, d as getNamePrefix, ft as makeClassName, gt as validateNamePrefix, i as getGlobalConfigTokens, mt as makeKeyframeName, o as getGlobalFontFace, pt as makeCounterStyleName, r as getEffectiveProperties, u as getGlobalStyles, vt as hashString } from "./config-_cYm9LPl.js";
2
+ import { n as formatPropertyCSS, t as formatRules } from "./format-rules-Bu_qoamZ.js";
3
3
  import { t as formatGlobalRules } from "./format-global-rules-DklyaXv-.js";
4
4
  //#region src/ssr/collector.ts
5
5
  /**
@@ -161,15 +161,21 @@ var ServerStyleCollector = class {
161
161
  }
162
162
  /**
163
163
  * Record global styles (from useGlobalStyles). Deduplicated by key.
164
+ *
165
+ * Pass `replace` for slot-keyed entries (an explicit `id`), where the last
166
+ * write must win to match the client's update-tracking behavior.
164
167
  */
165
- collectGlobalStyles(key, css) {
166
- if (!this.globalStyles.has(key)) this.globalStyles.set(key, css);
168
+ collectGlobalStyles(key, css, replace) {
169
+ if (replace || !this.globalStyles.has(key)) this.globalStyles.set(key, css);
167
170
  }
168
171
  /**
169
172
  * Record raw CSS text (from useRawCSS). Deduplicated by key.
173
+ *
174
+ * Pass `replace` for slot-keyed entries (an explicit `id`), where the last
175
+ * write must win to match the client's update-tracking behavior.
170
176
  */
171
- collectRawCSS(key, css) {
172
- if (!this.rawCSS.has(key)) this.rawCSS.set(key, css);
177
+ collectRawCSS(key, css, replace) {
178
+ if (replace || !this.rawCSS.has(key)) this.rawCSS.set(key, css);
173
179
  }
174
180
  /**
175
181
  * Extract all CSS collected so far as a single string.
@@ -240,4 +246,4 @@ var ServerStyleCollector = class {
240
246
  //#endregion
241
247
  export { ServerStyleCollector as t };
242
248
 
243
- //# sourceMappingURL=collector-AHZaBSv8.js.map
249
+ //# sourceMappingURL=collector-D0cgyN6N.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collector-D0cgyN6N.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 * 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(key: string, css: string, replace?: boolean): void {\n if (replace || !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 * 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(key: string, css: string, replace?: boolean): void {\n if (replace || !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,IAAoB;CACzC,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,yBAAiB,IAAI,IAAoB;CACzC,iCAAyB,IAAI,IAAY;CACzC,gCAAwB,IAAI,IAAoB;CAChD,sCAA8B,IAAI,IAAY;CAC9C,oCAA4B,IAAI,IAAoB;CACpD,0CAAkC,IAAI,IAAY;CAClD,mBAA2B;CAC3B,sBAA8B;CAC9B,qBAA6B;CAC7B;;;;;;;;CASA,YAAY,YAAqB;EAC/B,IAAI,eAAe,KAAA,GACjB,mBAAmB,UAAU;EAE/B,KAAK,aAAa,cAAc,cAAc;CAChD;CAEA,kBAA0B,UAA0B;EAClD,OAAO,cAAc,KAAK,YAAY,WAAW,QAAQ,CAAC;CAC5D;;;;;;;;;;CAWA,mBAAyB;EACvB,IAAI,KAAK,oBAAoB;EAC7B,KAAK,qBAAqB;EAE1B,KAAK,MAAM,CAAC,OAAO,eAAe,OAAO,QACvC,uBAAuB,CACzB,GAAG;GACD,MAA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K,eAAe,IAAI,GAAG;EAC7B;EAGF,KAAK,MAAM,CAAC,KAAK,QAAQ,KAAK,cAC5B,IAAI,CAAC,KAAK,kBAAkB,IAAI,GAAG,GAAG;GACpC,MAAM,KAAK,GAAG;GACd,KAAK,kBAAkB,IAAI,GAAG;EAChC;EAGF,KAAK,MAAM,CAAC,KAAK,QAAQ,KAAK,QAC5B,IAAI,CAAC,KAAK,YAAY,IAAI,GAAG,GAAG;GAC9B,MAAM,KAAK,GAAG;GACd,KAAK,YAAY,IAAI,GAAG;EAC1B;EAGF,KAAK,MAAM,CAAC,MAAM,QAAQ,KAAK,eAC7B,IAAI,CAAC,KAAK,oBAAoB,IAAI,IAAI,GAAG;GACvC,MAAM,KAAK,GAAG;GACd,KAAK,oBAAoB,IAAI,IAAI;EACnC;EAGF,OAAO,MAAM,KAAK,IAAI;CACxB;CAEA,oCAA4B,IAAI,IAAY;;;;;CAM5C,wBAAkC;EAChC,MAAM,QAAkB,CAAC;EACzB,KAAK,MAAM,aAAa,KAAK,oBAAoB,OAAO,GACtD,IAAI,CAAC,KAAK,kBAAkB,IAAI,SAAS,GAAG;GAC1C,KAAK,kBAAkB,IAAI,SAAS;GACpC,MAAM,KAAK,SAAS;EACtB;EAEF,OAAO;CACT;AACF"}
@@ -1,4 +1,4 @@
1
- import { n as StyleResult } from "./index-B9ih23uv.js";
1
+ import { n as StyleResult } from "./index-tRick_JW.js";
2
2
 
3
3
  //#region src/ssr/collector.d.ts
4
4
  declare class ServerStyleCollector {
@@ -79,12 +79,18 @@ declare class ServerStyleCollector {
79
79
  allocateCounterStyleName(providedName?: string): string;
80
80
  /**
81
81
  * Record global styles (from useGlobalStyles). Deduplicated by key.
82
+ *
83
+ * Pass `replace` for slot-keyed entries (an explicit `id`), where the last
84
+ * write must win to match the client's update-tracking behavior.
82
85
  */
83
- collectGlobalStyles(key: string, css: string): void;
86
+ collectGlobalStyles(key: string, css: string, replace?: boolean): void;
84
87
  /**
85
88
  * Record raw CSS text (from useRawCSS). Deduplicated by key.
89
+ *
90
+ * Pass `replace` for slot-keyed entries (an explicit `id`), where the last
91
+ * write must win to match the client's update-tracking behavior.
86
92
  */
87
- collectRawCSS(key: string, css: string): void;
93
+ collectRawCSS(key: string, css: string, replace?: boolean): void;
88
94
  /**
89
95
  * Extract all CSS collected so far as a single string.
90
96
  * Includes @property and @keyframes rules.
@@ -105,4 +111,4 @@ declare class ServerStyleCollector {
105
111
  }
106
112
  //#endregion
107
113
  export { ServerStyleCollector as t };
108
- //# sourceMappingURL=collector-DYA5AOwr.d.ts.map
114
+ //# sourceMappingURL=collector-yqgjGje7.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-B9ih23uv.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-tRick_JW.js";
2
2
 
3
3
  //#region src/injector/sheet-manager.d.ts
4
4
  declare class SheetManager {
@@ -20,6 +20,19 @@ declare class SheetManager {
20
20
  * abstracting away adopted vs style-element modes.
21
21
  */
22
22
  getCSSSheet(sheetInfo: SheetInfo): CSSStyleSheet | null;
23
+ /**
24
+ * Record an inserted rule text at its rule index (text mode only).
25
+ *
26
+ * `textRules` mirrors the sheet's rule order. `textContent` cannot be edited
27
+ * rule-by-rule the way CSSOM can, so keeping the texts is what makes
28
+ * deletion possible at all in this mode.
29
+ */
30
+ private trackTextRule;
31
+ /**
32
+ * Remove rule indices from a text-mode sheet and rewrite the element's text.
33
+ * Returns the indices that were actually removed.
34
+ */
35
+ private deleteTextRules;
23
36
  /**
24
37
  * Determine the injection mode for a root.
25
38
  * ShadowRoot uses adopted stylesheets when supported; Document uses <style> elements.
@@ -942,4 +955,4 @@ declare function getNamePrefix(): string;
942
955
  declare function resetConfig(): void;
943
956
  //#endregion
944
957
  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-BtK9fUaz.d.ts.map
958
+ //# sourceMappingURL=config-V0XC9iz_.d.ts.map
@@ -4275,6 +4275,31 @@ var SheetManager = class {
4275
4275
  return sheetInfo.sheet?.sheet ?? null;
4276
4276
  }
4277
4277
  /**
4278
+ * Record an inserted rule text at its rule index (text mode only).
4279
+ *
4280
+ * `textRules` mirrors the sheet's rule order. `textContent` cannot be edited
4281
+ * rule-by-rule the way CSSOM can, so keeping the texts is what makes
4282
+ * deletion possible at all in this mode.
4283
+ */
4284
+ trackTextRule(sheet, ruleIndex, ruleText) {
4285
+ if (!sheet.textMode) return;
4286
+ const rules = sheet.textRules ??= [];
4287
+ while (rules.length < ruleIndex) rules.push("");
4288
+ rules[ruleIndex] = ruleText;
4289
+ }
4290
+ /**
4291
+ * Remove rule indices from a text-mode sheet and rewrite the element's text.
4292
+ * Returns the indices that were actually removed.
4293
+ */
4294
+ deleteTextRules(sheet, indices) {
4295
+ const rules = sheet.textRules;
4296
+ if (!rules) return [];
4297
+ const removed = [...new Set(indices)].filter((idx) => idx >= 0 && idx < rules.length).sort((a, b) => b - a);
4298
+ for (const idx of removed) rules.splice(idx, 1);
4299
+ if (removed.length > 0 && sheet.sheet) sheet.sheet.textContent = rules.length ? "\n" + rules.join("\n") : "";
4300
+ return removed;
4301
+ }
4302
+ /**
4278
4303
  * Determine the injection mode for a root.
4279
4304
  * ShadowRoot uses adopted stylesheets when supported; Document uses <style> elements.
4280
4305
  */
@@ -4356,10 +4381,14 @@ var SheetManager = class {
4356
4381
  registry.sheets.push(sheetInfo);
4357
4382
  return sheetInfo;
4358
4383
  }
4384
+ const sheet = this.createStyleElement(root);
4385
+ const textMode = this.config.forceTextInjection === true || sheet.sheet == null;
4359
4386
  const sheetInfo = {
4360
- sheet: this.createStyleElement(root),
4387
+ sheet,
4361
4388
  ruleCount: 0,
4362
- holes: []
4389
+ holes: [],
4390
+ textMode,
4391
+ ...textMode ? { textRules: [] } : {}
4363
4392
  };
4364
4393
  registry.sheets.push(sheetInfo);
4365
4394
  return sheetInfo;
@@ -4427,7 +4456,7 @@ var SheetManager = class {
4427
4456
  if (rule.atRules && rule.atRules.length > 0) fullRule = rule.atRules.reduce((css, atRule) => `${atRule} { ${css} }`, baseRule);
4428
4457
  const styleElement = targetSheet.sheet;
4429
4458
  const styleSheet = this.getCSSSheet(targetSheet);
4430
- if (styleSheet && !this.config.forceTextInjection) {
4459
+ if (!targetSheet.textMode && styleSheet) {
4431
4460
  const maxIndex = styleSheet.cssRules.length;
4432
4461
  const atomicRuleIndex = this.findAvailableRuleIndex(targetSheet);
4433
4462
  const safeIndex = Math.min(Math.max(0, atomicRuleIndex), maxIndex);
@@ -4498,6 +4527,7 @@ var SheetManager = class {
4498
4527
  }
4499
4528
  } else if (styleElement) {
4500
4529
  const atomicRuleIndex = this.findAvailableRuleIndex(targetSheet);
4530
+ this.trackTextRule(targetSheet, atomicRuleIndex, fullRule);
4501
4531
  styleElement.textContent = (styleElement.textContent || "") + "\n" + fullRule;
4502
4532
  targetSheet.ruleCount++;
4503
4533
  insertedIndices.push(atomicRuleIndex);
@@ -4596,7 +4626,21 @@ var SheetManager = class {
4596
4626
  try {
4597
4627
  const texts = this.config.devMode && Array.isArray(ruleInfo.cssText) ? ruleInfo.cssText.slice() : [];
4598
4628
  const styleSheet = this.getCSSSheet(sheet);
4599
- if (styleSheet) {
4629
+ if (sheet.textMode) {
4630
+ let targetIndices;
4631
+ if (ruleInfo.indices && ruleInfo.indices.length > 0) targetIndices = ruleInfo.indices;
4632
+ else {
4633
+ const startIdx = Math.max(0, ruleInfo.ruleIndex);
4634
+ const endIdx = Math.min((sheet.textRules?.length ?? 0) - 1, Number.isFinite(ruleInfo.endRuleIndex) ? ruleInfo.endRuleIndex : startIdx);
4635
+ targetIndices = [];
4636
+ for (let idx = startIdx; idx <= endIdx; idx++) targetIndices.push(idx);
4637
+ }
4638
+ const deletedIndices = this.deleteTextRules(sheet, targetIndices);
4639
+ if (deletedIndices.length > 0) {
4640
+ sheet.ruleCount = Math.max(0, sheet.ruleCount - deletedIndices.length);
4641
+ this.adjustIndicesAfterDeletion(registry, ruleInfo.sheetIndex, Math.min(...deletedIndices), Math.max(...deletedIndices), deletedIndices.length, ruleInfo, deletedIndices);
4642
+ }
4643
+ } else if (styleSheet) {
4600
4644
  const rules = styleSheet.cssRules;
4601
4645
  if (ruleInfo.indices && ruleInfo.indices.length > 0) {
4602
4646
  const sortedIndices = [...ruleInfo.indices].sort((a, b) => b - a);
@@ -4721,8 +4765,8 @@ var SheetManager = class {
4721
4765
  const sheetInfo = registry.sheets[ruleInfo.sheetIndex];
4722
4766
  if (!sheetInfo || !sheetInfo.sheet && !sheetInfo.constructableSheet) continue;
4723
4767
  const styleSheet = this.getCSSSheet(sheetInfo);
4724
- if (!styleSheet) continue;
4725
- const maxRuleIndex = styleSheet.cssRules.length - 1;
4768
+ if (!sheetInfo.textMode && !styleSheet) continue;
4769
+ const maxRuleIndex = (sheetInfo.textMode ? sheetInfo.textRules?.length ?? 0 : styleSheet?.cssRules.length ?? 0) - 1;
4726
4770
  const startIdx = ruleInfo.ruleIndex;
4727
4771
  const endIdx = ruleInfo.endRuleIndex ?? ruleInfo.ruleIndex;
4728
4772
  if (startIdx < 0 || endIdx > maxRuleIndex || startIdx > endIdx) continue;
@@ -4876,10 +4920,13 @@ var SheetManager = class {
4876
4920
  const { css: cssSteps, declarations } = this.stepsToCSS(steps);
4877
4921
  const fullRule = `@keyframes ${name} { ${cssSteps} }`;
4878
4922
  const styleSheet = this.getCSSSheet(targetSheet);
4879
- if (styleSheet && !this.config.forceTextInjection) {
4923
+ if (!targetSheet.textMode && styleSheet) {
4880
4924
  const safeIndex = Math.min(Math.max(0, ruleIndex), styleSheet.cssRules.length);
4881
4925
  styleSheet.insertRule(fullRule, safeIndex);
4882
- } else if (targetSheet.sheet) targetSheet.sheet.textContent = (targetSheet.sheet.textContent || "") + "\n" + fullRule;
4926
+ } else if (targetSheet.sheet) {
4927
+ this.trackTextRule(targetSheet, ruleIndex, fullRule);
4928
+ targetSheet.sheet.textContent = (targetSheet.sheet.textContent || "") + "\n" + fullRule;
4929
+ }
4883
4930
  targetSheet.ruleCount++;
4884
4931
  return {
4885
4932
  info: {
@@ -4903,15 +4950,21 @@ var SheetManager = class {
4903
4950
  if (!sheet) return;
4904
4951
  try {
4905
4952
  const styleSheet = this.getCSSSheet(sheet);
4906
- if (styleSheet) {
4953
+ const adjustIndices = () => this.adjustIndicesAfterDeletion(registry, info.sheetIndex, info.ruleIndex, info.ruleIndex, 1, {
4954
+ className: "",
4955
+ ruleIndex: info.ruleIndex,
4956
+ sheetIndex: info.sheetIndex
4957
+ }, [info.ruleIndex]);
4958
+ if (sheet.textMode) {
4959
+ if (this.deleteTextRules(sheet, [info.ruleIndex]).length > 0) {
4960
+ sheet.ruleCount = Math.max(0, sheet.ruleCount - 1);
4961
+ adjustIndices();
4962
+ }
4963
+ } else if (styleSheet) {
4907
4964
  if (info.ruleIndex >= 0 && info.ruleIndex < styleSheet.cssRules.length) {
4908
4965
  styleSheet.deleteRule(info.ruleIndex);
4909
4966
  sheet.ruleCount = Math.max(0, sheet.ruleCount - 1);
4910
- this.adjustIndicesAfterDeletion(registry, info.sheetIndex, info.ruleIndex, info.ruleIndex, 1, {
4911
- className: "",
4912
- ruleIndex: info.ruleIndex,
4913
- sheetIndex: info.sheetIndex
4914
- }, [info.ruleIndex]);
4967
+ adjustIndices();
4915
4968
  }
4916
4969
  }
4917
4970
  } catch (error) {
@@ -10978,4 +11031,4 @@ function resetConfig() {
10978
11031
  //#endregion
10979
11032
  export { parseColor as $, StyleInjector as A, extractLocalProperties as At, styleHandlers as B, parseStateKey as C, getComponentPropertySyntax as Ct, extractPredefinedStateRefs as D, hslToRgbValues as Dt, extractLocalPredefinedStates as E, hexToRgb as Et, fontFaceContentHash as F, CUSTOM_UNITS as G, warn as H, formatFontFaceRule as I, filterMods as J, DIRECTIONS as K, hasLocalFontFace as L, formatCounterStyleRule as M, hasLocalProperties as Mt, hasLocalCounterStyle as N, parsePropertyToken as Nt, getGlobalPredefinedStates as O, strToRgb as Ot, extractLocalFontFace as P, normalizeColorTokenValue as Q, SheetManager as R, renderStyles as S, getColorSpaceSuffix as St, createStateParserContext as T, getRgbValuesFromRgbaString as Tt, createStyle as U, deprecationWarning as V, PropertyTypeResolver as W, getGlobalParser as X, getGlobalFuncs as Y, getGlobalPredefinedTokens as Z, markStylesGenerated as _, isDevEnv as _t, getGlobalCounterStyle as a, okhstPlugin as at, hasPipelineCacheEntry as b, getColorSpaceComponents as bt, getGlobalKeyframes as c, StyleParser as ct, getNamePrefix as d, DEFAULT_ZERO_NAME_PREFIX as dt, parseStyle as et, hasGlobalKeyframes as f, makeClassName as ft, isTestEnvironment as g, validateNamePrefix as gt, isConfigLocked as h, tastyClassRegex as ht, getGlobalConfigTokens as i, okhstFunc as it, extractLocalCounterStyle as j, getEffectiveDefinition as jt, setGlobalPredefinedStates as k, Lru as kt, getGlobalRecipes as l, Bucket as lt, hasStylesGenerated as m, makeKeyframeName as mt, getConfig as n, setGlobalPredefinedTokens as nt, getGlobalFontFace as o, okhslFunc as ot, hasGlobalRecipes as p, makeCounterStyleName as pt, customFunc as q, getEffectiveProperties as r, stringifyStyles as rt, getGlobalInjector as s, okhslPlugin as st, configure as t, resetGlobalPredefinedTokens as tt, getGlobalStyles as u, DEFAULT_NAME_PREFIX as ut, resetConfig as v, hashString as vt, camelToKebab as w, getNamedColorHex as wt, isSelector as x, getColorSpaceFunc as xt, generateTypographyTokens as y, colorInitialValueToComponents as yt, STYLE_HANDLER_MAP as z };
10980
11033
 
10981
- //# sourceMappingURL=config-YDAcLaVf.js.map
11034
+ //# sourceMappingURL=config-_cYm9LPl.js.map