@tenphi/tasty 0.0.0-snapshot.b3fbcbb → 0.0.0-snapshot.b3fc70b

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