@tenphi/tasty 2.0.3 → 2.0.4

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 (322) hide show
  1. package/dist/{ssr/async-storage.js → async-storage-B7_o6FKt.js} +2 -2
  2. package/dist/async-storage-B7_o6FKt.js.map +1 -0
  3. package/dist/{ssr/collector.d.ts → collector-CkZ517g4.d.ts} +3 -3
  4. package/dist/{ssr/collector.js → collector-DXqvGOb1.js} +5 -10
  5. package/dist/collector-DXqvGOb1.js.map +1 -0
  6. package/dist/config-5jzS6k6B.js +10005 -0
  7. package/dist/config-5jzS6k6B.js.map +1 -0
  8. package/dist/config-DknGsfMo.d.ts +857 -0
  9. package/dist/{ssr/context.js → context-CkSg-kDT.js} +11 -3
  10. package/dist/context-CkSg-kDT.js.map +1 -0
  11. package/dist/core/index.d.ts +5 -34
  12. package/dist/core/index.js +5 -26
  13. package/dist/core-CtU6-9OC.js +1507 -0
  14. package/dist/core-CtU6-9OC.js.map +1 -0
  15. package/dist/{zero/extractor.js → css-writer-DHkX0JuE.js} +74 -11
  16. package/dist/css-writer-DHkX0JuE.js.map +1 -0
  17. package/dist/{ssr/format-global-rules.js → format-global-rules-Dbc_1tc3.js} +2 -2
  18. package/dist/format-global-rules-Dbc_1tc3.js.map +1 -0
  19. package/dist/format-rules-DH13ewDu.js +143 -0
  20. package/dist/format-rules-DH13ewDu.js.map +1 -0
  21. package/dist/{ssr/hydrate.js → hydrate-C1Gv-DoS.js} +3 -3
  22. package/dist/hydrate-C1Gv-DoS.js.map +1 -0
  23. package/dist/{styles/types.d.ts → index-PzENbpAq.d.ts} +701 -5
  24. package/dist/index-o7zV2yCr.d.ts +1561 -0
  25. package/dist/index.d.ts +5 -51
  26. package/dist/index.js +728 -35
  27. package/dist/index.js.map +1 -0
  28. package/dist/keyframes-b7X3UxDV.js +587 -0
  29. package/dist/keyframes-b7X3UxDV.js.map +1 -0
  30. package/dist/{utils/merge-styles.d.ts → merge-styles-C7KTy7MY.d.ts} +3 -3
  31. package/dist/{utils/merge-styles.js → merge-styles-Tgo3BbL2.js} +3 -4
  32. package/dist/merge-styles-Tgo3BbL2.js.map +1 -0
  33. package/dist/{utils/resolve-recipes.js → resolve-recipes-Ca2-5CxM.js} +4 -6
  34. package/dist/resolve-recipes-Ca2-5CxM.js.map +1 -0
  35. package/dist/ssr/astro-client.js +1 -1
  36. package/dist/ssr/astro.js +4 -4
  37. package/dist/ssr/index.d.ts +44 -4
  38. package/dist/ssr/index.js +4 -4
  39. package/dist/ssr/next.d.ts +1 -1
  40. package/dist/ssr/next.js +6 -6
  41. package/dist/ssr/next.js.map +1 -1
  42. package/dist/static/index.d.ts +91 -5
  43. package/dist/static/index.js +49 -3
  44. package/dist/static/index.js.map +1 -0
  45. package/dist/zero/babel.d.ts +1 -1
  46. package/dist/zero/babel.js +10 -6
  47. package/dist/zero/babel.js.map +1 -1
  48. package/dist/zero/index.d.ts +67 -3
  49. package/dist/zero/index.js +1 -2
  50. package/package.json +3 -3
  51. package/dist/_virtual/_rolldown/runtime.js +0 -7
  52. package/dist/chunks/cacheKey.d.ts +0 -1
  53. package/dist/chunks/cacheKey.js +0 -77
  54. package/dist/chunks/cacheKey.js.map +0 -1
  55. package/dist/chunks/definitions.d.ts +0 -37
  56. package/dist/chunks/definitions.js +0 -258
  57. package/dist/chunks/definitions.js.map +0 -1
  58. package/dist/chunks/index.d.ts +0 -1
  59. package/dist/chunks/renderChunk.d.ts +0 -1
  60. package/dist/chunks/renderChunk.js +0 -59
  61. package/dist/chunks/renderChunk.js.map +0 -1
  62. package/dist/compute-styles.d.ts +0 -31
  63. package/dist/compute-styles.js +0 -322
  64. package/dist/compute-styles.js.map +0 -1
  65. package/dist/config.d.ts +0 -407
  66. package/dist/config.js +0 -591
  67. package/dist/config.js.map +0 -1
  68. package/dist/counter-style/index.js +0 -51
  69. package/dist/counter-style/index.js.map +0 -1
  70. package/dist/debug.d.ts +0 -89
  71. package/dist/debug.js +0 -453
  72. package/dist/debug.js.map +0 -1
  73. package/dist/font-face/index.js +0 -63
  74. package/dist/font-face/index.js.map +0 -1
  75. package/dist/hooks/index.d.ts +0 -7
  76. package/dist/hooks/useCounterStyle.d.ts +0 -36
  77. package/dist/hooks/useCounterStyle.js +0 -65
  78. package/dist/hooks/useCounterStyle.js.map +0 -1
  79. package/dist/hooks/useFontFace.d.ts +0 -45
  80. package/dist/hooks/useFontFace.js +0 -66
  81. package/dist/hooks/useFontFace.js.map +0 -1
  82. package/dist/hooks/useGlobalStyles.d.ts +0 -46
  83. package/dist/hooks/useGlobalStyles.js +0 -88
  84. package/dist/hooks/useGlobalStyles.js.map +0 -1
  85. package/dist/hooks/useKeyframes.d.ts +0 -58
  86. package/dist/hooks/useKeyframes.js +0 -55
  87. package/dist/hooks/useKeyframes.js.map +0 -1
  88. package/dist/hooks/useProperty.d.ts +0 -81
  89. package/dist/hooks/useProperty.js +0 -96
  90. package/dist/hooks/useProperty.js.map +0 -1
  91. package/dist/hooks/useRawCSS.d.ts +0 -22
  92. package/dist/hooks/useRawCSS.js +0 -103
  93. package/dist/hooks/useRawCSS.js.map +0 -1
  94. package/dist/hooks/useStyles.d.ts +0 -40
  95. package/dist/hooks/useStyles.js +0 -31
  96. package/dist/hooks/useStyles.js.map +0 -1
  97. package/dist/injector/index.d.ts +0 -182
  98. package/dist/injector/index.js +0 -185
  99. package/dist/injector/index.js.map +0 -1
  100. package/dist/injector/injector.d.ts +0 -198
  101. package/dist/injector/injector.js +0 -651
  102. package/dist/injector/injector.js.map +0 -1
  103. package/dist/injector/sheet-manager.d.ts +0 -132
  104. package/dist/injector/sheet-manager.js +0 -699
  105. package/dist/injector/sheet-manager.js.map +0 -1
  106. package/dist/injector/types.d.ts +0 -235
  107. package/dist/keyframes/index.js +0 -206
  108. package/dist/keyframes/index.js.map +0 -1
  109. package/dist/parser/classify.js +0 -319
  110. package/dist/parser/classify.js.map +0 -1
  111. package/dist/parser/const.js +0 -60
  112. package/dist/parser/const.js.map +0 -1
  113. package/dist/parser/lru.js +0 -109
  114. package/dist/parser/lru.js.map +0 -1
  115. package/dist/parser/parser.d.ts +0 -25
  116. package/dist/parser/parser.js +0 -115
  117. package/dist/parser/parser.js.map +0 -1
  118. package/dist/parser/tokenizer.js +0 -69
  119. package/dist/parser/tokenizer.js.map +0 -1
  120. package/dist/parser/types.d.ts +0 -51
  121. package/dist/parser/types.js +0 -46
  122. package/dist/parser/types.js.map +0 -1
  123. package/dist/pipeline/conditions.d.ts +0 -134
  124. package/dist/pipeline/conditions.js +0 -406
  125. package/dist/pipeline/conditions.js.map +0 -1
  126. package/dist/pipeline/exclusive.js +0 -389
  127. package/dist/pipeline/exclusive.js.map +0 -1
  128. package/dist/pipeline/index.d.ts +0 -55
  129. package/dist/pipeline/index.js +0 -749
  130. package/dist/pipeline/index.js.map +0 -1
  131. package/dist/pipeline/materialize-contradictions.js +0 -125
  132. package/dist/pipeline/materialize-contradictions.js.map +0 -1
  133. package/dist/pipeline/materialize.js +0 -1038
  134. package/dist/pipeline/materialize.js.map +0 -1
  135. package/dist/pipeline/parseStateKey.d.ts +0 -15
  136. package/dist/pipeline/parseStateKey.js +0 -446
  137. package/dist/pipeline/parseStateKey.js.map +0 -1
  138. package/dist/pipeline/simplify.js +0 -725
  139. package/dist/pipeline/simplify.js.map +0 -1
  140. package/dist/pipeline/warnings.js +0 -18
  141. package/dist/pipeline/warnings.js.map +0 -1
  142. package/dist/plugins/index.d.ts +0 -2
  143. package/dist/plugins/okhsl-plugin.d.ts +0 -35
  144. package/dist/plugins/okhsl-plugin.js +0 -97
  145. package/dist/plugins/okhsl-plugin.js.map +0 -1
  146. package/dist/plugins/types.d.ts +0 -87
  147. package/dist/properties/index.js +0 -222
  148. package/dist/properties/index.js.map +0 -1
  149. package/dist/properties/property-type-resolver.d.ts +0 -24
  150. package/dist/properties/property-type-resolver.js +0 -90
  151. package/dist/properties/property-type-resolver.js.map +0 -1
  152. package/dist/rsc-cache.js +0 -79
  153. package/dist/rsc-cache.js.map +0 -1
  154. package/dist/ssr/async-storage.d.ts +0 -17
  155. package/dist/ssr/async-storage.js.map +0 -1
  156. package/dist/ssr/collect-auto-properties.js +0 -58
  157. package/dist/ssr/collect-auto-properties.js.map +0 -1
  158. package/dist/ssr/collector.js.map +0 -1
  159. package/dist/ssr/context.js.map +0 -1
  160. package/dist/ssr/format-global-rules.js.map +0 -1
  161. package/dist/ssr/format-keyframes.js +0 -69
  162. package/dist/ssr/format-keyframes.js.map +0 -1
  163. package/dist/ssr/format-property.js +0 -49
  164. package/dist/ssr/format-property.js.map +0 -1
  165. package/dist/ssr/format-rules.js +0 -73
  166. package/dist/ssr/format-rules.js.map +0 -1
  167. package/dist/ssr/hydrate.d.ts +0 -29
  168. package/dist/ssr/hydrate.js.map +0 -1
  169. package/dist/ssr/ssr-collector-ref.js +0 -29
  170. package/dist/ssr/ssr-collector-ref.js.map +0 -1
  171. package/dist/states/index.d.ts +0 -49
  172. package/dist/states/index.js +0 -170
  173. package/dist/states/index.js.map +0 -1
  174. package/dist/static/tastyStatic.d.ts +0 -46
  175. package/dist/static/tastyStatic.js +0 -30
  176. package/dist/static/tastyStatic.js.map +0 -1
  177. package/dist/static/types.d.ts +0 -49
  178. package/dist/static/types.js +0 -24
  179. package/dist/static/types.js.map +0 -1
  180. package/dist/styles/border.d.ts +0 -25
  181. package/dist/styles/border.js +0 -120
  182. package/dist/styles/border.js.map +0 -1
  183. package/dist/styles/color.d.ts +0 -14
  184. package/dist/styles/color.js +0 -26
  185. package/dist/styles/color.js.map +0 -1
  186. package/dist/styles/const.js +0 -17
  187. package/dist/styles/const.js.map +0 -1
  188. package/dist/styles/createStyle.js +0 -79
  189. package/dist/styles/createStyle.js.map +0 -1
  190. package/dist/styles/dimension.js +0 -109
  191. package/dist/styles/dimension.js.map +0 -1
  192. package/dist/styles/directional.js +0 -133
  193. package/dist/styles/directional.js.map +0 -1
  194. package/dist/styles/display.d.ts +0 -30
  195. package/dist/styles/display.js +0 -73
  196. package/dist/styles/display.js.map +0 -1
  197. package/dist/styles/fade.d.ts +0 -15
  198. package/dist/styles/fade.js +0 -62
  199. package/dist/styles/fade.js.map +0 -1
  200. package/dist/styles/fill.d.ts +0 -42
  201. package/dist/styles/fill.js +0 -51
  202. package/dist/styles/fill.js.map +0 -1
  203. package/dist/styles/flow.d.ts +0 -16
  204. package/dist/styles/flow.js +0 -12
  205. package/dist/styles/flow.js.map +0 -1
  206. package/dist/styles/gap.d.ts +0 -31
  207. package/dist/styles/gap.js +0 -38
  208. package/dist/styles/gap.js.map +0 -1
  209. package/dist/styles/height.d.ts +0 -17
  210. package/dist/styles/height.js +0 -19
  211. package/dist/styles/height.js.map +0 -1
  212. package/dist/styles/index.d.ts +0 -1
  213. package/dist/styles/index.js +0 -8
  214. package/dist/styles/index.js.map +0 -1
  215. package/dist/styles/inset.d.ts +0 -24
  216. package/dist/styles/inset.js +0 -34
  217. package/dist/styles/inset.js.map +0 -1
  218. package/dist/styles/list.d.ts +0 -16
  219. package/dist/styles/list.js +0 -100
  220. package/dist/styles/list.js.map +0 -1
  221. package/dist/styles/margin.d.ts +0 -24
  222. package/dist/styles/margin.js +0 -32
  223. package/dist/styles/margin.js.map +0 -1
  224. package/dist/styles/outline.d.ts +0 -29
  225. package/dist/styles/outline.js +0 -55
  226. package/dist/styles/outline.js.map +0 -1
  227. package/dist/styles/padding.d.ts +0 -24
  228. package/dist/styles/padding.js +0 -32
  229. package/dist/styles/padding.js.map +0 -1
  230. package/dist/styles/placement.d.ts +0 -37
  231. package/dist/styles/placement.js +0 -74
  232. package/dist/styles/placement.js.map +0 -1
  233. package/dist/styles/predefined.d.ts +0 -71
  234. package/dist/styles/predefined.js +0 -237
  235. package/dist/styles/predefined.js.map +0 -1
  236. package/dist/styles/preset.d.ts +0 -52
  237. package/dist/styles/preset.js +0 -127
  238. package/dist/styles/preset.js.map +0 -1
  239. package/dist/styles/radius.d.ts +0 -12
  240. package/dist/styles/radius.js +0 -83
  241. package/dist/styles/radius.js.map +0 -1
  242. package/dist/styles/scrollMargin.d.ts +0 -24
  243. package/dist/styles/scrollMargin.js +0 -32
  244. package/dist/styles/scrollMargin.js.map +0 -1
  245. package/dist/styles/scrollbar.d.ts +0 -25
  246. package/dist/styles/scrollbar.js +0 -51
  247. package/dist/styles/scrollbar.js.map +0 -1
  248. package/dist/styles/shadow.d.ts +0 -14
  249. package/dist/styles/shadow.js +0 -25
  250. package/dist/styles/shadow.js.map +0 -1
  251. package/dist/styles/shared.js +0 -17
  252. package/dist/styles/shared.js.map +0 -1
  253. package/dist/styles/transition.d.ts +0 -14
  254. package/dist/styles/transition.js +0 -159
  255. package/dist/styles/transition.js.map +0 -1
  256. package/dist/styles/width.d.ts +0 -17
  257. package/dist/styles/width.js +0 -19
  258. package/dist/styles/width.js.map +0 -1
  259. package/dist/tasty.d.ts +0 -134
  260. package/dist/tasty.js +0 -248
  261. package/dist/tasty.js.map +0 -1
  262. package/dist/types.d.ts +0 -184
  263. package/dist/utils/cache-wrapper.js +0 -21
  264. package/dist/utils/cache-wrapper.js.map +0 -1
  265. package/dist/utils/case-converter.js +0 -8
  266. package/dist/utils/case-converter.js.map +0 -1
  267. package/dist/utils/color-math.d.ts +0 -46
  268. package/dist/utils/color-math.js +0 -749
  269. package/dist/utils/color-math.js.map +0 -1
  270. package/dist/utils/color-space.d.ts +0 -5
  271. package/dist/utils/color-space.js +0 -228
  272. package/dist/utils/color-space.js.map +0 -1
  273. package/dist/utils/colors.d.ts +0 -5
  274. package/dist/utils/colors.js +0 -10
  275. package/dist/utils/colors.js.map +0 -1
  276. package/dist/utils/css-types.d.ts +0 -7
  277. package/dist/utils/deps-equal.js +0 -15
  278. package/dist/utils/deps-equal.js.map +0 -1
  279. package/dist/utils/dotize.d.ts +0 -26
  280. package/dist/utils/dotize.js +0 -122
  281. package/dist/utils/dotize.js.map +0 -1
  282. package/dist/utils/filter-base-props.d.ts +0 -15
  283. package/dist/utils/filter-base-props.js +0 -45
  284. package/dist/utils/filter-base-props.js.map +0 -1
  285. package/dist/utils/get-display-name.d.ts +0 -7
  286. package/dist/utils/get-display-name.js +0 -10
  287. package/dist/utils/get-display-name.js.map +0 -1
  288. package/dist/utils/has-keys.js +0 -13
  289. package/dist/utils/has-keys.js.map +0 -1
  290. package/dist/utils/hash.js +0 -14
  291. package/dist/utils/hash.js.map +0 -1
  292. package/dist/utils/is-dev-env.js +0 -19
  293. package/dist/utils/is-dev-env.js.map +0 -1
  294. package/dist/utils/is-valid-element-type.js +0 -15
  295. package/dist/utils/is-valid-element-type.js.map +0 -1
  296. package/dist/utils/merge-styles.js.map +0 -1
  297. package/dist/utils/mod-attrs.d.ts +0 -6
  298. package/dist/utils/mod-attrs.js +0 -20
  299. package/dist/utils/mod-attrs.js.map +0 -1
  300. package/dist/utils/process-tokens.d.ts +0 -17
  301. package/dist/utils/process-tokens.js +0 -83
  302. package/dist/utils/process-tokens.js.map +0 -1
  303. package/dist/utils/resolve-recipes.d.ts +0 -17
  304. package/dist/utils/resolve-recipes.js.map +0 -1
  305. package/dist/utils/selector-transform.js +0 -32
  306. package/dist/utils/selector-transform.js.map +0 -1
  307. package/dist/utils/string.js +0 -8
  308. package/dist/utils/string.js.map +0 -1
  309. package/dist/utils/styles.d.ts +0 -99
  310. package/dist/utils/styles.js +0 -220
  311. package/dist/utils/styles.js.map +0 -1
  312. package/dist/utils/typography.d.ts +0 -58
  313. package/dist/utils/typography.js +0 -51
  314. package/dist/utils/typography.js.map +0 -1
  315. package/dist/utils/warnings.d.ts +0 -16
  316. package/dist/utils/warnings.js +0 -16
  317. package/dist/utils/warnings.js.map +0 -1
  318. package/dist/zero/css-writer.d.ts +0 -45
  319. package/dist/zero/css-writer.js +0 -73
  320. package/dist/zero/css-writer.js.map +0 -1
  321. package/dist/zero/extractor.d.ts +0 -24
  322. package/dist/zero/extractor.js.map +0 -1
@@ -1,699 +0,0 @@
1
- import { PropertyTypeResolver } from "../properties/property-type-resolver.js";
2
- import { createStyle } from "../styles/createStyle.js";
3
- import { STYLE_HANDLER_MAP } from "../styles/index.js";
4
- //#region src/injector/sheet-manager.ts
5
- var SheetManager = class {
6
- rootRegistries = /* @__PURE__ */ new WeakMap();
7
- /** Strong set of active roots so background GC can iterate them all */
8
- activeRoots = /* @__PURE__ */ new Set();
9
- config;
10
- /** Dedicated style elements for raw CSS per root */
11
- rawStyleElements = /* @__PURE__ */ new WeakMap();
12
- /** Tracking for raw CSS blocks per root */
13
- rawCSSBlocks = /* @__PURE__ */ new WeakMap();
14
- /** Counter for generating unique raw CSS IDs */
15
- rawCSSCounter = 0;
16
- constructor(config) {
17
- this.config = config;
18
- }
19
- /**
20
- * Get or create registry for a root (Document or ShadowRoot)
21
- */
22
- getRegistry(root) {
23
- let registry = this.rootRegistries.get(root);
24
- if (!registry) {
25
- const metrics = this.config.devMode ? {
26
- hits: 0,
27
- misses: 0,
28
- bulkCleanups: 0,
29
- totalInsertions: 0,
30
- totalUnused: 0,
31
- stylesCleanedUp: 0,
32
- cleanupHistory: [],
33
- startTime: Date.now()
34
- } : void 0;
35
- registry = {
36
- sheets: [],
37
- refCounts: /* @__PURE__ */ new Map(),
38
- rules: /* @__PURE__ */ new Map(),
39
- cacheKeyToClassName: /* @__PURE__ */ new Map(),
40
- ruleTextSet: /* @__PURE__ */ new Set(),
41
- metrics,
42
- keyframesCache: /* @__PURE__ */ new Map(),
43
- keyframesNameToContent: /* @__PURE__ */ new Map(),
44
- keyframesCounter: 0,
45
- injectedProperties: /* @__PURE__ */ new Map(),
46
- injectedFontFaces: /* @__PURE__ */ new Set(),
47
- injectedCounterStyles: /* @__PURE__ */ new Set(),
48
- globalRules: /* @__PURE__ */ new Map(),
49
- propertyTypeResolver: new PropertyTypeResolver(),
50
- usageMap: /* @__PURE__ */ new Map(),
51
- touchCount: 0,
52
- serverClassSyncIndex: 0,
53
- rscStylesScanned: false
54
- };
55
- this.rootRegistries.set(root, registry);
56
- this.activeRoots.add(root);
57
- }
58
- return registry;
59
- }
60
- /** Return all roots with active registries (for background GC sweep). */
61
- getActiveRoots() {
62
- return this.activeRoots;
63
- }
64
- /** Check whether any roots have active registries. */
65
- hasActiveRoots() {
66
- return this.activeRoots.size > 0;
67
- }
68
- /** Remove registries for ShadowRoots whose host has been detached from the DOM. */
69
- pruneDisconnectedRoots() {
70
- const toPrune = [];
71
- for (const root of this.activeRoots) if (root !== document && !root.host?.isConnected) toPrune.push(root);
72
- for (const root of toPrune) this.cleanup(root);
73
- }
74
- /**
75
- * Create a new stylesheet for the registry
76
- */
77
- createSheet(registry, root) {
78
- const sheetInfo = {
79
- sheet: this.createStyleElement(root),
80
- ruleCount: 0,
81
- holes: []
82
- };
83
- registry.sheets.push(sheetInfo);
84
- return sheetInfo;
85
- }
86
- /**
87
- * Create a style element and append to document
88
- */
89
- createStyleElement(root) {
90
- const style = root.createElement?.("style") || document.createElement("style");
91
- if (this.config.nonce) style.nonce = this.config.nonce;
92
- style.setAttribute("data-tasty", "");
93
- if ("head" in root && root.head) root.head.appendChild(style);
94
- else if ("appendChild" in root) root.appendChild(style);
95
- else document.head.appendChild(style);
96
- if (!style.isConnected && !this.config.forceTextInjection) console.error("SheetManager: Style element failed to connect to DOM!", {
97
- parentNode: style.parentNode?.nodeName,
98
- isConnected: style.isConnected
99
- });
100
- return style;
101
- }
102
- /**
103
- * Insert CSS rules as a single block
104
- */
105
- insertRule(registry, flattenedRules, className, root) {
106
- let targetSheet = this.findAvailableSheet(registry, root);
107
- if (!targetSheet) targetSheet = this.createSheet(registry, root);
108
- const sheetIndex = registry.sheets.indexOf(targetSheet);
109
- try {
110
- const groupedRules = [];
111
- const groupMap = /* @__PURE__ */ new Map();
112
- const atKey = (at) => at && at.length ? at.join("|") : "";
113
- flattenedRules.forEach((r) => {
114
- const key = `${atKey(r.atRules)}||${r.selector}||${r.startingStyle ? "1" : "0"}`;
115
- const existing = groupMap.get(key);
116
- if (existing) existing.declarations = existing.declarations ? `${existing.declarations} ${r.declarations}` : r.declarations;
117
- else {
118
- groupMap.set(key, {
119
- idx: groupedRules.length,
120
- selector: r.selector,
121
- atRules: r.atRules,
122
- startingStyle: r.startingStyle,
123
- declarations: r.declarations
124
- });
125
- groupedRules.push({ ...r });
126
- }
127
- });
128
- groupMap.forEach((val) => {
129
- groupedRules[val.idx] = {
130
- selector: val.selector,
131
- atRules: val.atRules,
132
- startingStyle: val.startingStyle,
133
- declarations: val.declarations
134
- };
135
- });
136
- const insertedRuleTexts = [];
137
- const insertedIndices = [];
138
- let currentRuleIndex = this.findAvailableRuleIndex(targetSheet);
139
- let firstInsertedIndex = null;
140
- let lastInsertedIndex = null;
141
- for (const rule of groupedRules) {
142
- const declarations = rule.declarations;
143
- const innerContent = rule.startingStyle ? `@starting-style { ${declarations} }` : declarations;
144
- const baseRule = `${rule.selector} { ${innerContent} }`;
145
- let fullRule = baseRule;
146
- if (rule.atRules && rule.atRules.length > 0) fullRule = rule.atRules.reduce((css, atRule) => `${atRule} { ${css} }`, baseRule);
147
- const styleElement = targetSheet.sheet;
148
- const styleSheet = styleElement.sheet;
149
- if (styleSheet && !this.config.forceTextInjection) {
150
- const maxIndex = styleSheet.cssRules.length;
151
- const atomicRuleIndex = this.findAvailableRuleIndex(targetSheet);
152
- const safeIndex = Math.min(Math.max(0, atomicRuleIndex), maxIndex);
153
- const splitSelectorsSafely = (selectorList) => {
154
- const parts = [];
155
- let buf = "";
156
- let depthSq = 0;
157
- let depthPar = 0;
158
- let inStr = "";
159
- for (let i = 0; i < selectorList.length; i++) {
160
- const ch = selectorList[i];
161
- if (inStr) {
162
- if (ch === inStr && selectorList[i - 1] !== "\\") inStr = "";
163
- buf += ch;
164
- continue;
165
- }
166
- if (ch === "\"" || ch === "'") {
167
- inStr = ch;
168
- buf += ch;
169
- continue;
170
- }
171
- if (ch === "[") depthSq++;
172
- else if (ch === "]") depthSq = Math.max(0, depthSq - 1);
173
- else if (ch === "(") depthPar++;
174
- else if (ch === ")") depthPar = Math.max(0, depthPar - 1);
175
- if (ch === "," && depthSq === 0 && depthPar === 0) {
176
- const part = buf.trim();
177
- if (part) parts.push(part);
178
- buf = "";
179
- } else buf += ch;
180
- }
181
- const tail = buf.trim();
182
- if (tail) parts.push(tail);
183
- return parts;
184
- };
185
- try {
186
- styleSheet.insertRule(fullRule, safeIndex);
187
- targetSheet.ruleCount++;
188
- insertedIndices.push(safeIndex);
189
- if (firstInsertedIndex == null) firstInsertedIndex = safeIndex;
190
- lastInsertedIndex = safeIndex;
191
- currentRuleIndex = safeIndex + 1;
192
- } catch (e) {
193
- const selectors = splitSelectorsSafely(rule.selector);
194
- if (selectors.length > 1) {
195
- let anyInserted = false;
196
- for (const sel of selectors) {
197
- const singleBase = `${sel} { ${declarations} }`;
198
- let singleRule = singleBase;
199
- if (rule.atRules && rule.atRules.length > 0) singleRule = rule.atRules.reduce((css, atRule) => `${atRule} { ${css} }`, singleBase);
200
- try {
201
- const maxIdx = styleSheet.cssRules.length;
202
- const atomicIdx = this.findAvailableRuleIndex(targetSheet);
203
- const idx = Math.min(Math.max(0, atomicIdx), maxIdx);
204
- styleSheet.insertRule(singleRule, idx);
205
- targetSheet.ruleCount++;
206
- insertedIndices.push(idx);
207
- if (firstInsertedIndex == null) firstInsertedIndex = idx;
208
- lastInsertedIndex = idx;
209
- currentRuleIndex = idx + 1;
210
- anyInserted = true;
211
- } catch (singleErr) {
212
- console.warn("[tasty] Browser rejected CSS rule:", singleRule, singleErr);
213
- }
214
- }
215
- if (!anyInserted) {}
216
- } else console.warn("[tasty] Browser rejected CSS rule:", fullRule, e);
217
- }
218
- } else {
219
- const atomicRuleIndex = this.findAvailableRuleIndex(targetSheet);
220
- styleElement.textContent = (styleElement.textContent || "") + "\n" + fullRule;
221
- targetSheet.ruleCount++;
222
- insertedIndices.push(atomicRuleIndex);
223
- if (firstInsertedIndex == null) firstInsertedIndex = atomicRuleIndex;
224
- lastInsertedIndex = atomicRuleIndex;
225
- currentRuleIndex = atomicRuleIndex + 1;
226
- }
227
- if (!styleElement.parentNode && !this.config.forceTextInjection) console.error("SheetManager: Style element is NOT in DOM! This is the problem!", {
228
- className,
229
- ruleIndex: currentRuleIndex
230
- });
231
- if (this.config.devMode) {
232
- insertedRuleTexts.push(fullRule);
233
- try {
234
- registry.ruleTextSet.add(fullRule);
235
- } catch {}
236
- }
237
- }
238
- if (insertedIndices.length === 0) return null;
239
- return {
240
- className,
241
- ruleIndex: firstInsertedIndex ?? 0,
242
- sheetIndex,
243
- cssText: this.config.devMode ? insertedRuleTexts : void 0,
244
- endRuleIndex: lastInsertedIndex ?? firstInsertedIndex ?? 0,
245
- indices: insertedIndices
246
- };
247
- } catch (error) {
248
- console.warn("Failed to insert CSS rules:", error, {
249
- flattenedRules,
250
- className
251
- });
252
- return null;
253
- }
254
- }
255
- /**
256
- * Insert global CSS rules
257
- */
258
- insertGlobalRule(registry, flattenedRules, globalKey, root) {
259
- const ruleInfo = this.insertRule(registry, flattenedRules, globalKey, root);
260
- if (ruleInfo) registry.globalRules.set(globalKey, ruleInfo);
261
- return ruleInfo;
262
- }
263
- /**
264
- * Delete a global CSS rule by key
265
- */
266
- deleteGlobalRule(registry, globalKey) {
267
- const ruleInfo = registry.globalRules.get(globalKey);
268
- if (!ruleInfo) return;
269
- this.deleteRule(registry, ruleInfo);
270
- registry.globalRules.delete(globalKey);
271
- }
272
- /**
273
- * Adjust rule indices after deletion to account for shifting
274
- */
275
- adjustIndicesAfterDeletion(registry, sheetIndex, startIdx, endIdx, deleteCount, deletedRuleInfo, deletedIndices) {
276
- try {
277
- const sortedDeleted = deletedIndices && deletedIndices.length > 0 ? [...deletedIndices].sort((a, b) => a - b) : null;
278
- const countDeletedBefore = (sorted, idx) => {
279
- let shift = 0;
280
- for (const delIdx of sorted) if (delIdx < idx) shift++;
281
- else break;
282
- return shift;
283
- };
284
- const adjustRuleInfo = (info) => {
285
- if (info === deletedRuleInfo) return;
286
- if (info.sheetIndex !== sheetIndex) return;
287
- if (!info.indices || info.indices.length === 0) return;
288
- if (sortedDeleted) info.indices = info.indices.map((idx) => {
289
- return idx - countDeletedBefore(sortedDeleted, idx);
290
- });
291
- else info.indices = info.indices.map((idx) => idx > endIdx ? Math.max(0, idx - deleteCount) : idx);
292
- if (info.indices.length > 0) {
293
- info.ruleIndex = Math.min(...info.indices);
294
- info.endRuleIndex = Math.max(...info.indices);
295
- }
296
- };
297
- for (const info of registry.rules.values()) adjustRuleInfo(info);
298
- for (const info of registry.globalRules.values()) adjustRuleInfo(info);
299
- for (const entry of registry.keyframesCache.values()) {
300
- const ki = entry.info;
301
- if (ki.sheetIndex !== sheetIndex) continue;
302
- if (sortedDeleted) {
303
- const shift = countDeletedBefore(sortedDeleted, ki.ruleIndex);
304
- if (shift > 0) ki.ruleIndex = Math.max(0, ki.ruleIndex - shift);
305
- } else if (ki.ruleIndex > endIdx) ki.ruleIndex = Math.max(0, ki.ruleIndex - deleteCount);
306
- }
307
- } catch {}
308
- }
309
- /**
310
- * Delete a CSS rule from the sheet
311
- */
312
- deleteRule(registry, ruleInfo) {
313
- const sheet = registry.sheets[ruleInfo.sheetIndex];
314
- if (!sheet) return;
315
- try {
316
- const texts = this.config.devMode && Array.isArray(ruleInfo.cssText) ? ruleInfo.cssText.slice() : [];
317
- const styleSheet = sheet.sheet.sheet;
318
- if (styleSheet) {
319
- const rules = styleSheet.cssRules;
320
- if (ruleInfo.indices && ruleInfo.indices.length > 0) {
321
- const sortedIndices = [...ruleInfo.indices].sort((a, b) => b - a);
322
- const deletedIndices = [];
323
- for (const idx of sortedIndices) if (idx >= 0 && idx < styleSheet.cssRules.length) try {
324
- styleSheet.deleteRule(idx);
325
- deletedIndices.push(idx);
326
- } catch (e) {
327
- console.warn(`Failed to delete rule at index ${idx}:`, e);
328
- }
329
- sheet.ruleCount = Math.max(0, sheet.ruleCount - deletedIndices.length);
330
- if (deletedIndices.length > 0) this.adjustIndicesAfterDeletion(registry, ruleInfo.sheetIndex, Math.min(...deletedIndices), Math.max(...deletedIndices), deletedIndices.length, ruleInfo, deletedIndices);
331
- } else {
332
- const startIdx = Math.max(0, ruleInfo.ruleIndex);
333
- const endIdx = Math.min(rules.length - 1, Number.isFinite(ruleInfo.endRuleIndex) ? ruleInfo.endRuleIndex : startIdx);
334
- if (Number.isFinite(startIdx) && endIdx >= startIdx) {
335
- const deleteCount = endIdx - startIdx + 1;
336
- for (let idx = endIdx; idx >= startIdx; idx--) {
337
- if (idx < 0 || idx >= styleSheet.cssRules.length) continue;
338
- styleSheet.deleteRule(idx);
339
- }
340
- sheet.ruleCount = Math.max(0, sheet.ruleCount - deleteCount);
341
- this.adjustIndicesAfterDeletion(registry, ruleInfo.sheetIndex, startIdx, endIdx, deleteCount, ruleInfo);
342
- }
343
- }
344
- }
345
- if (this.config.devMode && texts.length) try {
346
- for (const text of texts) registry.ruleTextSet.delete(text);
347
- } catch {}
348
- } catch (error) {
349
- console.warn("Failed to delete CSS rule:", error);
350
- }
351
- }
352
- /**
353
- * Find a sheet with available space or return null
354
- */
355
- findAvailableSheet(registry, _root) {
356
- const maxRules = this.config.maxRulesPerSheet;
357
- if (!maxRules) return registry.sheets[registry.sheets.length - 1] || null;
358
- for (const sheet of registry.sheets) if (sheet.ruleCount < maxRules) return sheet;
359
- return null;
360
- }
361
- /**
362
- * Find an available rule index in the sheet
363
- */
364
- findAvailableRuleIndex(sheet) {
365
- return sheet.ruleCount;
366
- }
367
- /**
368
- * Force cleanup of unused styles
369
- */
370
- forceCleanup(registry) {
371
- this.performBulkCleanup(registry);
372
- }
373
- /**
374
- * Perform bulk cleanup of all unused styles (refCount = 0).
375
- */
376
- performBulkCleanup(registry) {
377
- const cleanupStartTime = Date.now();
378
- const unusedClassNames = Array.from(registry.refCounts.entries()).filter(([className, refCount]) => refCount === 0 && !registry.usageMap.has(className)).map(([className]) => className);
379
- if (unusedClassNames.length === 0) return;
380
- const selected = unusedClassNames.map((className) => {
381
- const ruleInfo = registry.rules.get(className);
382
- return ruleInfo ? {
383
- className,
384
- ruleInfo
385
- } : null;
386
- }).filter((entry) => entry != null);
387
- let cleanedUpCount = 0;
388
- let totalCssSize = 0;
389
- let totalRulesDeleted = 0;
390
- const rulesBySheet = /* @__PURE__ */ new Map();
391
- for (const { className, ruleInfo } of selected) {
392
- const sheetIndex = ruleInfo.sheetIndex;
393
- if (this.config.devMode && Array.isArray(ruleInfo.cssText)) {
394
- const cssSize = ruleInfo.cssText.reduce((total, css) => total + css.length, 0);
395
- totalCssSize += cssSize;
396
- totalRulesDeleted += ruleInfo.cssText.length;
397
- }
398
- if (!rulesBySheet.has(sheetIndex)) rulesBySheet.set(sheetIndex, []);
399
- rulesBySheet.get(sheetIndex).push({
400
- className,
401
- ruleInfo
402
- });
403
- }
404
- for (const [_sheetIndex, rulesInSheet] of rulesBySheet) {
405
- rulesInSheet.sort((a, b) => b.ruleInfo.ruleIndex - a.ruleInfo.ruleIndex);
406
- for (const { className, ruleInfo } of rulesInSheet) {
407
- if ((registry.refCounts.get(className) || 0) > 0) continue;
408
- if (registry.rules.get(className) !== ruleInfo) continue;
409
- const sheetInfo = registry.sheets[ruleInfo.sheetIndex];
410
- if (!sheetInfo || !sheetInfo.sheet) continue;
411
- const styleSheet = sheetInfo.sheet.sheet;
412
- if (!styleSheet) continue;
413
- const maxRuleIndex = styleSheet.cssRules.length - 1;
414
- const startIdx = ruleInfo.ruleIndex;
415
- const endIdx = ruleInfo.endRuleIndex ?? ruleInfo.ruleIndex;
416
- if (startIdx < 0 || endIdx > maxRuleIndex || startIdx > endIdx) continue;
417
- this.deleteRule(registry, ruleInfo);
418
- registry.rules.delete(className);
419
- registry.refCounts.delete(className);
420
- const keysToDelete = [];
421
- for (const [key, mappedClassName] of registry.cacheKeyToClassName.entries()) if (mappedClassName === className) keysToDelete.push(key);
422
- for (const key of keysToDelete) registry.cacheKeyToClassName.delete(key);
423
- cleanedUpCount++;
424
- }
425
- }
426
- if (registry.metrics) {
427
- registry.metrics.bulkCleanups++;
428
- registry.metrics.stylesCleanedUp += cleanedUpCount;
429
- registry.metrics.cleanupHistory.push({
430
- timestamp: cleanupStartTime,
431
- classesDeleted: cleanedUpCount,
432
- cssSize: totalCssSize,
433
- rulesDeleted: totalRulesDeleted
434
- });
435
- }
436
- }
437
- /**
438
- * Get total number of rules across all sheets
439
- */
440
- getTotalRuleCount(registry) {
441
- return registry.sheets.reduce((total, sheet) => total + sheet.ruleCount - sheet.holes.length, 0);
442
- }
443
- /**
444
- * Get CSS text from all sheets (for SSR)
445
- */
446
- getCssText(registry) {
447
- const cssChunks = [];
448
- for (const sheet of registry.sheets) try {
449
- const styleElement = sheet.sheet;
450
- if (styleElement.textContent) cssChunks.push(styleElement.textContent);
451
- else if (styleElement.sheet) {
452
- const rules = Array.from(styleElement.sheet.cssRules);
453
- cssChunks.push(rules.map((rule) => rule.cssText).join("\n"));
454
- }
455
- } catch (error) {
456
- console.warn("Failed to read CSS from sheet:", error);
457
- }
458
- return cssChunks.join("\n");
459
- }
460
- /**
461
- * Get cache performance metrics
462
- */
463
- getMetrics(registry) {
464
- if (!registry.metrics) return null;
465
- const unusedRulesCount = Array.from(registry.refCounts.values()).filter((count) => count === 0).length;
466
- return {
467
- ...registry.metrics,
468
- unusedHits: unusedRulesCount
469
- };
470
- }
471
- /**
472
- * Reset cache performance metrics
473
- */
474
- resetMetrics(registry) {
475
- if (registry.metrics) registry.metrics = {
476
- hits: 0,
477
- misses: 0,
478
- bulkCleanups: 0,
479
- totalInsertions: 0,
480
- totalUnused: 0,
481
- stylesCleanedUp: 0,
482
- cleanupHistory: [],
483
- startTime: Date.now()
484
- };
485
- }
486
- /**
487
- * Convert keyframes steps to CSS string.
488
- * Public so the SSR collector can format keyframes without DOM access.
489
- * Returns both the CSS text and a combined declarations string for property type scanning.
490
- */
491
- stepsToCSS(steps) {
492
- const rules = [];
493
- const allDeclarations = [];
494
- for (const [key, value] of Object.entries(steps)) {
495
- if (typeof value === "string") {
496
- rules.push(`${key} { ${value.trim()} }`);
497
- allDeclarations.push(value.trim());
498
- continue;
499
- }
500
- const styleMap = value || {};
501
- const styleNames = Object.keys(styleMap).sort();
502
- const handlerQueue = [];
503
- const seenHandlers = /* @__PURE__ */ new Set();
504
- styleNames.forEach((styleName) => {
505
- let handlers = STYLE_HANDLER_MAP[styleName];
506
- if (!handlers) handlers = STYLE_HANDLER_MAP[styleName] = [createStyle(styleName)];
507
- handlers.forEach((handler) => {
508
- if (!seenHandlers.has(handler)) {
509
- seenHandlers.add(handler);
510
- handlerQueue.push(handler);
511
- }
512
- });
513
- });
514
- const declarationPairs = [];
515
- handlerQueue.forEach((handler) => {
516
- const result = handler(handler.__lookupStyles.reduce((acc, name) => {
517
- const v = styleMap[name];
518
- if (v !== void 0) acc[name] = v;
519
- return acc;
520
- }, {}));
521
- if (!result) return;
522
- (Array.isArray(result) ? result : [result]).forEach((cssMap) => {
523
- if (!cssMap || typeof cssMap !== "object") return;
524
- const { $: _$, ...props } = cssMap;
525
- Object.entries(props).forEach(([prop, val]) => {
526
- if (val == null || val === "") return;
527
- if (Array.isArray(val)) val.forEach((v) => {
528
- if (v != null && v !== "") declarationPairs.push({
529
- prop,
530
- value: String(v)
531
- });
532
- });
533
- else declarationPairs.push({
534
- prop,
535
- value: String(val)
536
- });
537
- });
538
- });
539
- });
540
- const declarations = declarationPairs.map((d) => `${d.prop}: ${d.value}`).join("; ");
541
- rules.push(`${key} { ${declarations.trim()} }`);
542
- allDeclarations.push(declarations);
543
- }
544
- return {
545
- css: rules.join(" "),
546
- declarations: allDeclarations.join("; ")
547
- };
548
- }
549
- /**
550
- * Insert keyframes rule.
551
- * Returns the KeyframesInfo and the raw declarations string for property type scanning.
552
- */
553
- insertKeyframes(registry, steps, name, root) {
554
- let targetSheet = this.findAvailableSheet(registry, root);
555
- if (!targetSheet) targetSheet = this.createSheet(registry, root);
556
- const ruleIndex = this.findAvailableRuleIndex(targetSheet);
557
- const sheetIndex = registry.sheets.indexOf(targetSheet);
558
- try {
559
- const { css: cssSteps, declarations } = this.stepsToCSS(steps);
560
- const fullRule = `@keyframes ${name} { ${cssSteps} }`;
561
- const styleElement = targetSheet.sheet;
562
- const styleSheet = styleElement.sheet;
563
- if (styleSheet && !this.config.forceTextInjection) {
564
- const safeIndex = Math.min(Math.max(0, ruleIndex), styleSheet.cssRules.length);
565
- styleSheet.insertRule(fullRule, safeIndex);
566
- } else styleElement.textContent = (styleElement.textContent || "") + "\n" + fullRule;
567
- targetSheet.ruleCount++;
568
- return {
569
- info: {
570
- name,
571
- ruleIndex,
572
- sheetIndex,
573
- cssText: this.config.devMode ? fullRule : void 0
574
- },
575
- declarations
576
- };
577
- } catch (error) {
578
- console.warn("Failed to insert keyframes:", error);
579
- return null;
580
- }
581
- }
582
- /**
583
- * Delete keyframes rule
584
- */
585
- deleteKeyframes(registry, info) {
586
- const sheet = registry.sheets[info.sheetIndex];
587
- if (!sheet) return;
588
- try {
589
- const styleSheet = sheet.sheet.sheet;
590
- if (styleSheet) {
591
- if (info.ruleIndex >= 0 && info.ruleIndex < styleSheet.cssRules.length) {
592
- styleSheet.deleteRule(info.ruleIndex);
593
- sheet.ruleCount = Math.max(0, sheet.ruleCount - 1);
594
- this.adjustIndicesAfterDeletion(registry, info.sheetIndex, info.ruleIndex, info.ruleIndex, 1, {
595
- className: "",
596
- ruleIndex: info.ruleIndex,
597
- sheetIndex: info.sheetIndex
598
- }, [info.ruleIndex]);
599
- }
600
- }
601
- } catch (error) {
602
- console.warn("Failed to delete keyframes:", error);
603
- }
604
- }
605
- /**
606
- * Clean up resources for a root
607
- */
608
- cleanup(root) {
609
- const registry = this.rootRegistries.get(root);
610
- if (!registry) return;
611
- for (const sheet of registry.sheets) try {
612
- const styleElement = sheet.sheet;
613
- if (styleElement.parentNode) styleElement.parentNode.removeChild(styleElement);
614
- } catch (error) {
615
- console.warn("Failed to cleanup sheet:", error);
616
- }
617
- this.rootRegistries.delete(root);
618
- this.activeRoots.delete(root);
619
- const rawStyleElement = this.rawStyleElements.get(root);
620
- if (rawStyleElement?.parentNode) rawStyleElement.parentNode.removeChild(rawStyleElement);
621
- this.rawStyleElements.delete(root);
622
- this.rawCSSBlocks.delete(root);
623
- }
624
- /**
625
- * Get or create a dedicated style element for raw CSS
626
- * Raw CSS is kept separate from tasty-managed sheets to avoid index conflicts
627
- */
628
- getOrCreateRawStyleElement(root) {
629
- let styleElement = this.rawStyleElements.get(root);
630
- if (!styleElement) {
631
- styleElement = root.createElement?.("style") || document.createElement("style");
632
- if (this.config.nonce) styleElement.nonce = this.config.nonce;
633
- styleElement.setAttribute("data-tasty-raw", "");
634
- if ("head" in root && root.head) root.head.appendChild(styleElement);
635
- else if ("appendChild" in root) root.appendChild(styleElement);
636
- else document.head.appendChild(styleElement);
637
- this.rawStyleElements.set(root, styleElement);
638
- this.rawCSSBlocks.set(root, /* @__PURE__ */ new Map());
639
- }
640
- return styleElement;
641
- }
642
- /**
643
- * Inject raw CSS text directly without parsing
644
- * Returns a dispose function to remove the injected CSS
645
- */
646
- injectRawCSS(css, root) {
647
- if (!css.trim()) return { dispose: () => {} };
648
- const styleElement = this.getOrCreateRawStyleElement(root);
649
- const blocksMap = this.rawCSSBlocks.get(root);
650
- const id = `raw_${this.rawCSSCounter++}`;
651
- const currentContent = styleElement.textContent || "";
652
- const startOffset = currentContent.length;
653
- const cssWithNewline = (currentContent ? "\n" : "") + css;
654
- const endOffset = startOffset + cssWithNewline.length;
655
- styleElement.textContent = currentContent + cssWithNewline;
656
- const info = {
657
- id,
658
- css,
659
- startOffset,
660
- endOffset
661
- };
662
- blocksMap.set(id, info);
663
- return { dispose: () => {
664
- this.disposeRawCSS(id, root);
665
- } };
666
- }
667
- /**
668
- * Remove a raw CSS block by ID
669
- */
670
- disposeRawCSS(id, root) {
671
- const styleElement = this.rawStyleElements.get(root);
672
- const blocksMap = this.rawCSSBlocks.get(root);
673
- if (!styleElement || !blocksMap) return;
674
- if (!blocksMap.get(id)) return;
675
- blocksMap.delete(id);
676
- const remainingBlocks = Array.from(blocksMap.values());
677
- if (remainingBlocks.length === 0) styleElement.textContent = "";
678
- else {
679
- remainingBlocks.sort((a, b) => a.startOffset - b.startOffset);
680
- styleElement.textContent = remainingBlocks.map((block) => block.css).join("\n");
681
- let offset = 0;
682
- for (const block of remainingBlocks) {
683
- block.startOffset = offset;
684
- block.endOffset = offset + block.css.length;
685
- offset = block.endOffset + 1;
686
- }
687
- }
688
- }
689
- /**
690
- * Get the raw CSS content for SSR
691
- */
692
- getRawCSSText(root) {
693
- return this.rawStyleElements.get(root)?.textContent || "";
694
- }
695
- };
696
- //#endregion
697
- export { SheetManager };
698
-
699
- //# sourceMappingURL=sheet-manager.js.map