@tenphi/tasty 0.1.0

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 (359) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +236 -0
  3. package/dist/_virtual/_rolldown/runtime.mjs +7 -0
  4. package/dist/chunks/cacheKey.d.ts +1 -0
  5. package/dist/chunks/cacheKey.js +70 -0
  6. package/dist/chunks/cacheKey.js.map +1 -0
  7. package/dist/chunks/cacheKey.mjs +70 -0
  8. package/dist/chunks/cacheKey.mjs.map +1 -0
  9. package/dist/chunks/definitions.d.ts +37 -0
  10. package/dist/chunks/definitions.js +260 -0
  11. package/dist/chunks/definitions.js.map +1 -0
  12. package/dist/chunks/definitions.mjs +260 -0
  13. package/dist/chunks/definitions.mjs.map +1 -0
  14. package/dist/chunks/index.d.ts +3 -0
  15. package/dist/chunks/renderChunk.d.ts +2 -0
  16. package/dist/chunks/renderChunk.js +61 -0
  17. package/dist/chunks/renderChunk.js.map +1 -0
  18. package/dist/chunks/renderChunk.mjs +61 -0
  19. package/dist/chunks/renderChunk.mjs.map +1 -0
  20. package/dist/config.d.ts +279 -0
  21. package/dist/config.js +400 -0
  22. package/dist/config.js.map +1 -0
  23. package/dist/config.mjs +231 -0
  24. package/dist/config.mjs.map +1 -0
  25. package/dist/css-writer.d.mts +45 -0
  26. package/dist/css-writer.mjs +74 -0
  27. package/dist/css-writer.mjs.map +1 -0
  28. package/dist/debug.d.ts +204 -0
  29. package/dist/debug.js +733 -0
  30. package/dist/debug.js.map +1 -0
  31. package/dist/extractor.d.mts +24 -0
  32. package/dist/extractor.mjs +150 -0
  33. package/dist/extractor.mjs.map +1 -0
  34. package/dist/hooks/index.d.ts +5 -0
  35. package/dist/hooks/useGlobalStyles.d.ts +27 -0
  36. package/dist/hooks/useGlobalStyles.js +56 -0
  37. package/dist/hooks/useGlobalStyles.js.map +1 -0
  38. package/dist/hooks/useKeyframes.d.ts +56 -0
  39. package/dist/hooks/useKeyframes.js +54 -0
  40. package/dist/hooks/useKeyframes.js.map +1 -0
  41. package/dist/hooks/useProperty.d.ts +79 -0
  42. package/dist/hooks/useProperty.js +91 -0
  43. package/dist/hooks/useProperty.js.map +1 -0
  44. package/dist/hooks/useRawCSS.d.ts +53 -0
  45. package/dist/hooks/useRawCSS.js +28 -0
  46. package/dist/hooks/useRawCSS.js.map +1 -0
  47. package/dist/hooks/useStyles.d.ts +40 -0
  48. package/dist/hooks/useStyles.js +169 -0
  49. package/dist/hooks/useStyles.js.map +1 -0
  50. package/dist/index.d.ts +38 -0
  51. package/dist/index.js +30 -0
  52. package/dist/injector/index.d.ts +157 -0
  53. package/dist/injector/index.js +154 -0
  54. package/dist/injector/index.js.map +1 -0
  55. package/dist/injector/injector.d.ts +139 -0
  56. package/dist/injector/injector.js +404 -0
  57. package/dist/injector/injector.js.map +1 -0
  58. package/dist/injector/injector.mjs +404 -0
  59. package/dist/injector/injector.mjs.map +1 -0
  60. package/dist/injector/sheet-manager.d.ts +127 -0
  61. package/dist/injector/sheet-manager.js +714 -0
  62. package/dist/injector/sheet-manager.js.map +1 -0
  63. package/dist/injector/sheet-manager.mjs +714 -0
  64. package/dist/injector/sheet-manager.mjs.map +1 -0
  65. package/dist/injector/types.d.mts +18 -0
  66. package/dist/injector/types.d.ts +135 -0
  67. package/dist/keyframes/index.js +206 -0
  68. package/dist/keyframes/index.js.map +1 -0
  69. package/dist/keyframes/index.mjs +156 -0
  70. package/dist/keyframes/index.mjs.map +1 -0
  71. package/dist/parser/classify.js +319 -0
  72. package/dist/parser/classify.js.map +1 -0
  73. package/dist/parser/classify.mjs +319 -0
  74. package/dist/parser/classify.mjs.map +1 -0
  75. package/dist/parser/const.js +33 -0
  76. package/dist/parser/const.js.map +1 -0
  77. package/dist/parser/const.mjs +33 -0
  78. package/dist/parser/const.mjs.map +1 -0
  79. package/dist/parser/lru.js +109 -0
  80. package/dist/parser/lru.js.map +1 -0
  81. package/dist/parser/lru.mjs +109 -0
  82. package/dist/parser/lru.mjs.map +1 -0
  83. package/dist/parser/parser.d.ts +25 -0
  84. package/dist/parser/parser.js +116 -0
  85. package/dist/parser/parser.js.map +1 -0
  86. package/dist/parser/parser.mjs +116 -0
  87. package/dist/parser/parser.mjs.map +1 -0
  88. package/dist/parser/tokenizer.js +69 -0
  89. package/dist/parser/tokenizer.js.map +1 -0
  90. package/dist/parser/tokenizer.mjs +69 -0
  91. package/dist/parser/tokenizer.mjs.map +1 -0
  92. package/dist/parser/types.d.mts +37 -0
  93. package/dist/parser/types.d.ts +46 -0
  94. package/dist/parser/types.js +46 -0
  95. package/dist/parser/types.js.map +1 -0
  96. package/dist/parser/types.mjs +46 -0
  97. package/dist/parser/types.mjs.map +1 -0
  98. package/dist/pipeline/conditions.js +377 -0
  99. package/dist/pipeline/conditions.js.map +1 -0
  100. package/dist/pipeline/conditions.mjs +377 -0
  101. package/dist/pipeline/conditions.mjs.map +1 -0
  102. package/dist/pipeline/exclusive.d.ts +1 -0
  103. package/dist/pipeline/exclusive.js +231 -0
  104. package/dist/pipeline/exclusive.js.map +1 -0
  105. package/dist/pipeline/exclusive.mjs +231 -0
  106. package/dist/pipeline/exclusive.mjs.map +1 -0
  107. package/dist/pipeline/index.d.ts +53 -0
  108. package/dist/pipeline/index.js +641 -0
  109. package/dist/pipeline/index.js.map +1 -0
  110. package/dist/pipeline/index.mjs +635 -0
  111. package/dist/pipeline/index.mjs.map +1 -0
  112. package/dist/pipeline/materialize.js +821 -0
  113. package/dist/pipeline/materialize.js.map +1 -0
  114. package/dist/pipeline/materialize.mjs +821 -0
  115. package/dist/pipeline/materialize.mjs.map +1 -0
  116. package/dist/pipeline/parseStateKey.d.ts +1 -0
  117. package/dist/pipeline/parseStateKey.js +418 -0
  118. package/dist/pipeline/parseStateKey.js.map +1 -0
  119. package/dist/pipeline/parseStateKey.mjs +418 -0
  120. package/dist/pipeline/parseStateKey.mjs.map +1 -0
  121. package/dist/pipeline/simplify.js +557 -0
  122. package/dist/pipeline/simplify.js.map +1 -0
  123. package/dist/pipeline/simplify.mjs +557 -0
  124. package/dist/pipeline/simplify.mjs.map +1 -0
  125. package/dist/plugins/index.d.ts +2 -0
  126. package/dist/plugins/okhsl-plugin.d.ts +35 -0
  127. package/dist/plugins/okhsl-plugin.js +371 -0
  128. package/dist/plugins/okhsl-plugin.js.map +1 -0
  129. package/dist/plugins/okhsl-plugin.mjs +345 -0
  130. package/dist/plugins/okhsl-plugin.mjs.map +1 -0
  131. package/dist/plugins/types.d.mts +49 -0
  132. package/dist/plugins/types.d.ts +69 -0
  133. package/dist/properties/index.js +158 -0
  134. package/dist/properties/index.js.map +1 -0
  135. package/dist/properties/index.mjs +141 -0
  136. package/dist/properties/index.mjs.map +1 -0
  137. package/dist/states/index.d.ts +45 -0
  138. package/dist/states/index.js +389 -0
  139. package/dist/states/index.js.map +1 -0
  140. package/dist/states/index.mjs +161 -0
  141. package/dist/states/index.mjs.map +1 -0
  142. package/dist/static/index.d.ts +5 -0
  143. package/dist/static/index.js +5 -0
  144. package/dist/static/tastyStatic.d.ts +46 -0
  145. package/dist/static/tastyStatic.js +31 -0
  146. package/dist/static/tastyStatic.js.map +1 -0
  147. package/dist/static/types.d.ts +49 -0
  148. package/dist/static/types.js +24 -0
  149. package/dist/static/types.js.map +1 -0
  150. package/dist/styles/align.d.ts +15 -0
  151. package/dist/styles/align.js +14 -0
  152. package/dist/styles/align.js.map +1 -0
  153. package/dist/styles/align.mjs +14 -0
  154. package/dist/styles/align.mjs.map +1 -0
  155. package/dist/styles/border.d.ts +25 -0
  156. package/dist/styles/border.js +114 -0
  157. package/dist/styles/border.js.map +1 -0
  158. package/dist/styles/border.mjs +114 -0
  159. package/dist/styles/border.mjs.map +1 -0
  160. package/dist/styles/color.d.ts +14 -0
  161. package/dist/styles/color.js +23 -0
  162. package/dist/styles/color.js.map +1 -0
  163. package/dist/styles/color.mjs +23 -0
  164. package/dist/styles/color.mjs.map +1 -0
  165. package/dist/styles/createStyle.js +77 -0
  166. package/dist/styles/createStyle.js.map +1 -0
  167. package/dist/styles/createStyle.mjs +77 -0
  168. package/dist/styles/createStyle.mjs.map +1 -0
  169. package/dist/styles/dimension.js +97 -0
  170. package/dist/styles/dimension.js.map +1 -0
  171. package/dist/styles/dimension.mjs +97 -0
  172. package/dist/styles/dimension.mjs.map +1 -0
  173. package/dist/styles/display.d.ts +37 -0
  174. package/dist/styles/display.js +67 -0
  175. package/dist/styles/display.js.map +1 -0
  176. package/dist/styles/display.mjs +67 -0
  177. package/dist/styles/display.mjs.map +1 -0
  178. package/dist/styles/fade.d.ts +15 -0
  179. package/dist/styles/fade.js +58 -0
  180. package/dist/styles/fade.js.map +1 -0
  181. package/dist/styles/fade.mjs +58 -0
  182. package/dist/styles/fade.mjs.map +1 -0
  183. package/dist/styles/fill.d.ts +44 -0
  184. package/dist/styles/fill.js +51 -0
  185. package/dist/styles/fill.js.map +1 -0
  186. package/dist/styles/fill.mjs +51 -0
  187. package/dist/styles/fill.mjs.map +1 -0
  188. package/dist/styles/flow.d.ts +16 -0
  189. package/dist/styles/flow.js +12 -0
  190. package/dist/styles/flow.js.map +1 -0
  191. package/dist/styles/flow.mjs +12 -0
  192. package/dist/styles/flow.mjs.map +1 -0
  193. package/dist/styles/gap.d.ts +31 -0
  194. package/dist/styles/gap.js +37 -0
  195. package/dist/styles/gap.js.map +1 -0
  196. package/dist/styles/gap.mjs +37 -0
  197. package/dist/styles/gap.mjs.map +1 -0
  198. package/dist/styles/height.d.ts +17 -0
  199. package/dist/styles/height.js +20 -0
  200. package/dist/styles/height.js.map +1 -0
  201. package/dist/styles/height.mjs +20 -0
  202. package/dist/styles/height.mjs.map +1 -0
  203. package/dist/styles/index.d.ts +2 -0
  204. package/dist/styles/index.js +9 -0
  205. package/dist/styles/index.js.map +1 -0
  206. package/dist/styles/index.mjs +9 -0
  207. package/dist/styles/index.mjs.map +1 -0
  208. package/dist/styles/inset.d.ts +50 -0
  209. package/dist/styles/inset.js +142 -0
  210. package/dist/styles/inset.js.map +1 -0
  211. package/dist/styles/inset.mjs +142 -0
  212. package/dist/styles/inset.mjs.map +1 -0
  213. package/dist/styles/justify.d.ts +15 -0
  214. package/dist/styles/justify.js +14 -0
  215. package/dist/styles/justify.js.map +1 -0
  216. package/dist/styles/justify.mjs +14 -0
  217. package/dist/styles/justify.mjs.map +1 -0
  218. package/dist/styles/list.d.ts +16 -0
  219. package/dist/styles/list.js +98 -0
  220. package/dist/styles/list.js.map +1 -0
  221. package/dist/styles/margin.d.ts +28 -0
  222. package/dist/styles/margin.js +96 -0
  223. package/dist/styles/margin.js.map +1 -0
  224. package/dist/styles/margin.mjs +96 -0
  225. package/dist/styles/margin.mjs.map +1 -0
  226. package/dist/styles/outline.d.ts +29 -0
  227. package/dist/styles/outline.js +65 -0
  228. package/dist/styles/outline.js.map +1 -0
  229. package/dist/styles/outline.mjs +65 -0
  230. package/dist/styles/outline.mjs.map +1 -0
  231. package/dist/styles/padding.d.ts +28 -0
  232. package/dist/styles/padding.js +96 -0
  233. package/dist/styles/padding.js.map +1 -0
  234. package/dist/styles/padding.mjs +96 -0
  235. package/dist/styles/padding.mjs.map +1 -0
  236. package/dist/styles/predefined.d.ts +74 -0
  237. package/dist/styles/predefined.js +241 -0
  238. package/dist/styles/predefined.js.map +1 -0
  239. package/dist/styles/predefined.mjs +232 -0
  240. package/dist/styles/predefined.mjs.map +1 -0
  241. package/dist/styles/preset.d.ts +47 -0
  242. package/dist/styles/preset.js +126 -0
  243. package/dist/styles/preset.js.map +1 -0
  244. package/dist/styles/preset.mjs +126 -0
  245. package/dist/styles/preset.mjs.map +1 -0
  246. package/dist/styles/radius.d.ts +14 -0
  247. package/dist/styles/radius.js +51 -0
  248. package/dist/styles/radius.js.map +1 -0
  249. package/dist/styles/radius.mjs +51 -0
  250. package/dist/styles/radius.mjs.map +1 -0
  251. package/dist/styles/scrollbar.d.ts +21 -0
  252. package/dist/styles/scrollbar.js +105 -0
  253. package/dist/styles/scrollbar.js.map +1 -0
  254. package/dist/styles/scrollbar.mjs +105 -0
  255. package/dist/styles/scrollbar.mjs.map +1 -0
  256. package/dist/styles/shadow.d.ts +14 -0
  257. package/dist/styles/shadow.js +24 -0
  258. package/dist/styles/shadow.js.map +1 -0
  259. package/dist/styles/shadow.mjs +24 -0
  260. package/dist/styles/shadow.mjs.map +1 -0
  261. package/dist/styles/styledScrollbar.d.ts +47 -0
  262. package/dist/styles/styledScrollbar.js +38 -0
  263. package/dist/styles/styledScrollbar.js.map +1 -0
  264. package/dist/styles/styledScrollbar.mjs +38 -0
  265. package/dist/styles/styledScrollbar.mjs.map +1 -0
  266. package/dist/styles/transition.d.ts +14 -0
  267. package/dist/styles/transition.js +138 -0
  268. package/dist/styles/transition.js.map +1 -0
  269. package/dist/styles/transition.mjs +138 -0
  270. package/dist/styles/transition.mjs.map +1 -0
  271. package/dist/styles/types.d.mts +492 -0
  272. package/dist/styles/types.d.ts +496 -0
  273. package/dist/styles/width.d.ts +17 -0
  274. package/dist/styles/width.js +20 -0
  275. package/dist/styles/width.js.map +1 -0
  276. package/dist/styles/width.mjs +20 -0
  277. package/dist/styles/width.mjs.map +1 -0
  278. package/dist/tasty.d.ts +983 -0
  279. package/dist/tasty.js +191 -0
  280. package/dist/tasty.js.map +1 -0
  281. package/dist/tokens/typography.d.ts +19 -0
  282. package/dist/tokens/typography.js +237 -0
  283. package/dist/tokens/typography.js.map +1 -0
  284. package/dist/types.d.ts +182 -0
  285. package/dist/utils/cache-wrapper.js +26 -0
  286. package/dist/utils/cache-wrapper.js.map +1 -0
  287. package/dist/utils/cache-wrapper.mjs +26 -0
  288. package/dist/utils/cache-wrapper.mjs.map +1 -0
  289. package/dist/utils/case-converter.js +8 -0
  290. package/dist/utils/case-converter.js.map +1 -0
  291. package/dist/utils/case-converter.mjs +8 -0
  292. package/dist/utils/case-converter.mjs.map +1 -0
  293. package/dist/utils/colors.d.ts +5 -0
  294. package/dist/utils/colors.js +9 -0
  295. package/dist/utils/colors.js.map +1 -0
  296. package/dist/utils/dotize.d.ts +26 -0
  297. package/dist/utils/dotize.js +122 -0
  298. package/dist/utils/dotize.js.map +1 -0
  299. package/dist/utils/filter-base-props.d.ts +15 -0
  300. package/dist/utils/filter-base-props.js +45 -0
  301. package/dist/utils/filter-base-props.js.map +1 -0
  302. package/dist/utils/get-display-name.d.ts +7 -0
  303. package/dist/utils/get-display-name.js +10 -0
  304. package/dist/utils/get-display-name.js.map +1 -0
  305. package/dist/utils/hsl-to-rgb.js +38 -0
  306. package/dist/utils/hsl-to-rgb.js.map +1 -0
  307. package/dist/utils/hsl-to-rgb.mjs +38 -0
  308. package/dist/utils/hsl-to-rgb.mjs.map +1 -0
  309. package/dist/utils/is-dev-env.js +19 -0
  310. package/dist/utils/is-dev-env.js.map +1 -0
  311. package/dist/utils/is-dev-env.mjs +19 -0
  312. package/dist/utils/is-dev-env.mjs.map +1 -0
  313. package/dist/utils/merge-styles.d.ts +7 -0
  314. package/dist/utils/merge-styles.js +146 -0
  315. package/dist/utils/merge-styles.js.map +1 -0
  316. package/dist/utils/merge-styles.mjs +146 -0
  317. package/dist/utils/merge-styles.mjs.map +1 -0
  318. package/dist/utils/mod-attrs.d.ts +8 -0
  319. package/dist/utils/mod-attrs.js +21 -0
  320. package/dist/utils/mod-attrs.js.map +1 -0
  321. package/dist/utils/okhsl-to-rgb.js +296 -0
  322. package/dist/utils/okhsl-to-rgb.js.map +1 -0
  323. package/dist/utils/okhsl-to-rgb.mjs +296 -0
  324. package/dist/utils/okhsl-to-rgb.mjs.map +1 -0
  325. package/dist/utils/process-tokens.d.ts +31 -0
  326. package/dist/utils/process-tokens.js +171 -0
  327. package/dist/utils/process-tokens.js.map +1 -0
  328. package/dist/utils/process-tokens.mjs +28 -0
  329. package/dist/utils/process-tokens.mjs.map +1 -0
  330. package/dist/utils/resolve-recipes.d.ts +17 -0
  331. package/dist/utils/resolve-recipes.js +143 -0
  332. package/dist/utils/resolve-recipes.js.map +1 -0
  333. package/dist/utils/resolve-recipes.mjs +143 -0
  334. package/dist/utils/resolve-recipes.mjs.map +1 -0
  335. package/dist/utils/string.js +8 -0
  336. package/dist/utils/string.js.map +1 -0
  337. package/dist/utils/string.mjs +8 -0
  338. package/dist/utils/string.mjs.map +1 -0
  339. package/dist/utils/styles.d.mts +18 -0
  340. package/dist/utils/styles.d.ts +183 -0
  341. package/dist/utils/styles.js +585 -0
  342. package/dist/utils/styles.js.map +1 -0
  343. package/dist/utils/styles.mjs +346 -0
  344. package/dist/utils/styles.mjs.map +1 -0
  345. package/dist/utils/typography.d.ts +36 -0
  346. package/dist/utils/typography.js +53 -0
  347. package/dist/utils/typography.js.map +1 -0
  348. package/dist/utils/warnings.d.ts +16 -0
  349. package/dist/utils/warnings.js +16 -0
  350. package/dist/utils/warnings.js.map +1 -0
  351. package/dist/zero/babel.d.mts +108 -0
  352. package/dist/zero/babel.mjs +282 -0
  353. package/dist/zero/babel.mjs.map +1 -0
  354. package/dist/zero/index.d.mts +3 -0
  355. package/dist/zero/index.mjs +4 -0
  356. package/dist/zero/next.d.mts +60 -0
  357. package/dist/zero/next.mjs +78 -0
  358. package/dist/zero/next.mjs.map +1 -0
  359. package/package.json +127 -0
@@ -0,0 +1,157 @@
1
+ import { CacheMetrics, DisposeFunction, GlobalInjectResult, InjectResult, KeyframesCacheEntry, KeyframesInfo, KeyframesResult, KeyframesSteps, PropertyDefinition, RawCSSResult, RootRegistry, RuleInfo, SheetInfo, StyleInjectorConfig, StyleRule } from "./types.js";
2
+ import { StyleResult } from "../pipeline/index.js";
3
+ import { SheetManager } from "./sheet-manager.js";
4
+ import { StyleInjector } from "./injector.js";
5
+
6
+ //#region src/injector/index.d.ts
7
+ /**
8
+ * Allocate a className for a cacheKey without injecting styles yet
9
+ */
10
+ declare function allocateClassName(cacheKey: string, options?: {
11
+ root?: Document | ShadowRoot;
12
+ }): {
13
+ className: string;
14
+ isNewAllocation: boolean;
15
+ };
16
+ /**
17
+ * Inject styles and return className with dispose function
18
+ */
19
+ declare function inject(rules: StyleResult[], options?: {
20
+ root?: Document | ShadowRoot;
21
+ cacheKey?: string;
22
+ }): InjectResult;
23
+ /**
24
+ * Inject global rules that should not reserve tasty class names
25
+ */
26
+ declare function injectGlobal(rules: StyleResult[], options?: {
27
+ root?: Document | ShadowRoot;
28
+ }): GlobalInjectResult;
29
+ /**
30
+ * Inject raw CSS text directly without parsing
31
+ * This is a low-overhead method for injecting raw CSS that doesn't need tasty processing.
32
+ * The CSS is inserted into a separate style element to avoid conflicts with tasty's chunking.
33
+ *
34
+ * @example
35
+ * ```tsx
36
+ * // Inject raw CSS
37
+ * const { dispose } = injectRawCSS(`
38
+ * body { margin: 0; padding: 0; }
39
+ * .my-class { color: red; }
40
+ * `);
41
+ *
42
+ * // Later, remove the injected CSS
43
+ * dispose();
44
+ * ```
45
+ */
46
+ declare function injectRawCSS(css: string, options?: {
47
+ root?: Document | ShadowRoot;
48
+ }): {
49
+ dispose: () => void;
50
+ };
51
+ /**
52
+ * Get raw CSS text for SSR
53
+ */
54
+ declare function getRawCSSText(options?: {
55
+ root?: Document | ShadowRoot;
56
+ }): string;
57
+ /**
58
+ * Inject keyframes and return object with toString() and dispose()
59
+ */
60
+ declare function keyframes(steps: KeyframesSteps, nameOrOptions?: string | {
61
+ root?: Document | ShadowRoot;
62
+ name?: string;
63
+ }): KeyframesResult;
64
+ interface PropertyOptions {
65
+ /**
66
+ * CSS syntax string for the property (e.g., '<color>', '<length>', '<angle>')
67
+ * @see https://developer.mozilla.org/en-US/docs/Web/CSS/@property/syntax
68
+ */
69
+ syntax?: string;
70
+ /**
71
+ * Whether the property inherits from parent elements
72
+ * @default true
73
+ */
74
+ inherits?: boolean;
75
+ /**
76
+ * Initial value for the property
77
+ */
78
+ initialValue?: string | number;
79
+ /**
80
+ * Shadow root or document to inject into
81
+ */
82
+ root?: Document | ShadowRoot;
83
+ }
84
+ /**
85
+ * Define a CSS @property custom property.
86
+ * This enables advanced features like animating custom properties.
87
+ *
88
+ * Note: @property rules are global and persistent once defined.
89
+ * Re-registering the same property name is a no-op.
90
+ *
91
+ * @param name - The custom property name (must start with --)
92
+ * @param options - Property configuration
93
+ *
94
+ * @example
95
+ * ```ts
96
+ * // Define a color property that can be animated
97
+ * property('--my-color', {
98
+ * syntax: '<color>',
99
+ * initialValue: 'red',
100
+ * });
101
+ *
102
+ * // Define an angle property
103
+ * property('--rotation', {
104
+ * syntax: '<angle>',
105
+ * inherits: false,
106
+ * initialValue: '0deg',
107
+ * });
108
+ * ```
109
+ */
110
+ declare function property(name: string, options?: PropertyOptions): void;
111
+ /**
112
+ * Check if a CSS @property has already been defined
113
+ *
114
+ * @param name - The custom property name to check
115
+ * @param options - Options including root
116
+ */
117
+ declare function isPropertyDefined(name: string, options?: {
118
+ root?: Document | ShadowRoot;
119
+ }): boolean;
120
+ /**
121
+ * Get CSS text from all sheets (for SSR)
122
+ */
123
+ declare function getCssText(options?: {
124
+ root?: Document | ShadowRoot;
125
+ }): string;
126
+ /**
127
+ * Collect only CSS used by a rendered subtree (like jest-styled-components).
128
+ * Pass the container returned by render(...).
129
+ */
130
+ declare function getCssTextForNode(node: ParentNode | Element | DocumentFragment, options?: {
131
+ root?: Document | ShadowRoot;
132
+ }): string;
133
+ /**
134
+ * Force cleanup of unused rules
135
+ */
136
+ declare function cleanup(root?: Document | ShadowRoot): void;
137
+ /**
138
+ * Check if we're currently running in a test environment
139
+ */
140
+ declare function getIsTestEnvironment(): boolean;
141
+ /**
142
+ * Get the global injector instance for debugging
143
+ */
144
+ declare const injector: {
145
+ readonly instance: StyleInjector;
146
+ };
147
+ /**
148
+ * Destroy all resources and clean up
149
+ */
150
+ declare function destroy(root?: Document | ShadowRoot): void;
151
+ /**
152
+ * Create a new isolated injector instance
153
+ */
154
+ declare function createInjector(config?: Partial<StyleInjectorConfig>): StyleInjector;
155
+ //#endregion
156
+ export { PropertyOptions, allocateClassName, cleanup, createInjector, destroy, getCssText, getCssTextForNode, getIsTestEnvironment, getRawCSSText, inject, injectGlobal, injectRawCSS, injector, isPropertyDefined, keyframes, property };
157
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,154 @@
1
+ import { SheetManager } from "./sheet-manager.js";
2
+ import { StyleInjector } from "./injector.js";
3
+ import { getConfig, getGlobalInjector, isTestEnvironment, markStylesGenerated } from "../config.js";
4
+
5
+ //#region src/injector/index.ts
6
+ /**
7
+ * Allocate a className for a cacheKey without injecting styles yet
8
+ */
9
+ function allocateClassName(cacheKey, options) {
10
+ return getGlobalInjector().allocateClassName(cacheKey, options);
11
+ }
12
+ /**
13
+ * Inject styles and return className with dispose function
14
+ */
15
+ function inject(rules, options) {
16
+ markStylesGenerated();
17
+ return getGlobalInjector().inject(rules, options);
18
+ }
19
+ /**
20
+ * Inject global rules that should not reserve tasty class names
21
+ */
22
+ function injectGlobal(rules, options) {
23
+ return getGlobalInjector().injectGlobal(rules, options);
24
+ }
25
+ /**
26
+ * Inject raw CSS text directly without parsing
27
+ * This is a low-overhead method for injecting raw CSS that doesn't need tasty processing.
28
+ * The CSS is inserted into a separate style element to avoid conflicts with tasty's chunking.
29
+ *
30
+ * @example
31
+ * ```tsx
32
+ * // Inject raw CSS
33
+ * const { dispose } = injectRawCSS(`
34
+ * body { margin: 0; padding: 0; }
35
+ * .my-class { color: red; }
36
+ * `);
37
+ *
38
+ * // Later, remove the injected CSS
39
+ * dispose();
40
+ * ```
41
+ */
42
+ function injectRawCSS(css, options) {
43
+ return getGlobalInjector().injectRawCSS(css, options);
44
+ }
45
+ /**
46
+ * Get raw CSS text for SSR
47
+ */
48
+ function getRawCSSText(options) {
49
+ return getGlobalInjector().getRawCSSText(options);
50
+ }
51
+ /**
52
+ * Inject keyframes and return object with toString() and dispose()
53
+ */
54
+ function keyframes(steps, nameOrOptions) {
55
+ return getGlobalInjector().keyframes(steps, nameOrOptions);
56
+ }
57
+ /**
58
+ * Define a CSS @property custom property.
59
+ * This enables advanced features like animating custom properties.
60
+ *
61
+ * Note: @property rules are global and persistent once defined.
62
+ * Re-registering the same property name is a no-op.
63
+ *
64
+ * @param name - The custom property name (must start with --)
65
+ * @param options - Property configuration
66
+ *
67
+ * @example
68
+ * ```ts
69
+ * // Define a color property that can be animated
70
+ * property('--my-color', {
71
+ * syntax: '<color>',
72
+ * initialValue: 'red',
73
+ * });
74
+ *
75
+ * // Define an angle property
76
+ * property('--rotation', {
77
+ * syntax: '<angle>',
78
+ * inherits: false,
79
+ * initialValue: '0deg',
80
+ * });
81
+ * ```
82
+ */
83
+ function property(name, options) {
84
+ return getGlobalInjector().property(name, options);
85
+ }
86
+ /**
87
+ * Check if a CSS @property has already been defined
88
+ *
89
+ * @param name - The custom property name to check
90
+ * @param options - Options including root
91
+ */
92
+ function isPropertyDefined(name, options) {
93
+ return getGlobalInjector().isPropertyDefined(name, options);
94
+ }
95
+ /**
96
+ * Get CSS text from all sheets (for SSR)
97
+ */
98
+ function getCssText(options) {
99
+ return getGlobalInjector().getCssText(options);
100
+ }
101
+ /**
102
+ * Collect only CSS used by a rendered subtree (like jest-styled-components).
103
+ * Pass the container returned by render(...).
104
+ */
105
+ function getCssTextForNode(node, options) {
106
+ const classSet = /* @__PURE__ */ new Set();
107
+ const readClasses = (el) => {
108
+ const cls = el.getAttribute("class");
109
+ if (!cls) return;
110
+ for (const token of cls.split(/\s+/)) if (/^t\d+$/.test(token)) classSet.add(token);
111
+ };
112
+ if (node.getAttribute) readClasses(node);
113
+ const elements = node.querySelectorAll ? node.querySelectorAll("[class]") : [];
114
+ if (elements) elements.forEach(readClasses);
115
+ return getGlobalInjector().getCssTextForClasses(classSet, options);
116
+ }
117
+ /**
118
+ * Force cleanup of unused rules
119
+ */
120
+ function cleanup(root) {
121
+ return getGlobalInjector().cleanup(root);
122
+ }
123
+ /**
124
+ * Check if we're currently running in a test environment
125
+ */
126
+ function getIsTestEnvironment() {
127
+ return isTestEnvironment();
128
+ }
129
+ /**
130
+ * Get the global injector instance for debugging
131
+ */
132
+ const injector = { get instance() {
133
+ return getGlobalInjector();
134
+ } };
135
+ /**
136
+ * Destroy all resources and clean up
137
+ */
138
+ function destroy(root) {
139
+ return getGlobalInjector().destroy(root);
140
+ }
141
+ /**
142
+ * Create a new isolated injector instance
143
+ */
144
+ function createInjector(config = {}) {
145
+ return new StyleInjector({
146
+ ...getConfig(),
147
+ forceTextInjection: config.forceTextInjection ?? isTestEnvironment(),
148
+ ...config
149
+ });
150
+ }
151
+
152
+ //#endregion
153
+ export { allocateClassName, cleanup, createInjector, destroy, getCssText, getCssTextForNode, getIsTestEnvironment, getRawCSSText, inject, injectGlobal, injectRawCSS, injector, isPropertyDefined, keyframes, property };
154
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/injector/index.ts"],"sourcesContent":["import {\n getConfig,\n getGlobalInjector,\n isTestEnvironment,\n markStylesGenerated,\n} from '../config';\nimport type { StyleResult } from '../pipeline';\n\nimport { StyleInjector } from './injector';\nimport type {\n GlobalInjectResult,\n InjectResult,\n KeyframesResult,\n KeyframesSteps,\n StyleInjectorConfig,\n} from './types';\n\n/**\n * Allocate a className for a cacheKey without injecting styles yet\n */\nexport function allocateClassName(\n cacheKey: string,\n options?: { root?: Document | ShadowRoot },\n): { className: string; isNewAllocation: boolean } {\n return getGlobalInjector().allocateClassName(cacheKey, options);\n}\n\n/**\n * Inject styles and return className with dispose function\n */\nexport function inject(\n rules: StyleResult[],\n options?: { root?: Document | ShadowRoot; cacheKey?: string },\n): InjectResult {\n // Mark that styles have been generated (prevents configuration changes)\n markStylesGenerated();\n\n return getGlobalInjector().inject(rules, options);\n}\n\n/**\n * Inject global rules that should not reserve tasty class names\n */\nexport function injectGlobal(\n rules: StyleResult[],\n options?: { root?: Document | ShadowRoot },\n): GlobalInjectResult {\n return getGlobalInjector().injectGlobal(rules, options);\n}\n\n/**\n * Inject raw CSS text directly without parsing\n * This is a low-overhead method for injecting raw CSS that doesn't need tasty processing.\n * The CSS is inserted into a separate style element to avoid conflicts with tasty's chunking.\n *\n * @example\n * ```tsx\n * // Inject raw CSS\n * const { dispose } = injectRawCSS(`\n * body { margin: 0; padding: 0; }\n * .my-class { color: red; }\n * `);\n *\n * // Later, remove the injected CSS\n * dispose();\n * ```\n */\nexport function injectRawCSS(\n css: string,\n options?: { root?: Document | ShadowRoot },\n): { dispose: () => void } {\n return getGlobalInjector().injectRawCSS(css, options);\n}\n\n/**\n * Get raw CSS text for SSR\n */\nexport function getRawCSSText(options?: {\n root?: Document | ShadowRoot;\n}): string {\n return getGlobalInjector().getRawCSSText(options);\n}\n\n/**\n * Inject keyframes and return object with toString() and dispose()\n */\nexport function keyframes(\n steps: KeyframesSteps,\n nameOrOptions?: string | { root?: Document | ShadowRoot; name?: string },\n): KeyframesResult {\n return getGlobalInjector().keyframes(steps, nameOrOptions);\n}\n\nexport interface PropertyOptions {\n /**\n * CSS syntax string for the property (e.g., '<color>', '<length>', '<angle>')\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/@property/syntax\n */\n syntax?: string;\n /**\n * Whether the property inherits from parent elements\n * @default true\n */\n inherits?: boolean;\n /**\n * Initial value for the property\n */\n initialValue?: string | number;\n /**\n * Shadow root or document to inject into\n */\n root?: Document | ShadowRoot;\n}\n\n/**\n * Define a CSS @property custom property.\n * This enables advanced features like animating custom properties.\n *\n * Note: @property rules are global and persistent once defined.\n * Re-registering the same property name is a no-op.\n *\n * @param name - The custom property name (must start with --)\n * @param options - Property configuration\n *\n * @example\n * ```ts\n * // Define a color property that can be animated\n * property('--my-color', {\n * syntax: '<color>',\n * initialValue: 'red',\n * });\n *\n * // Define an angle property\n * property('--rotation', {\n * syntax: '<angle>',\n * inherits: false,\n * initialValue: '0deg',\n * });\n * ```\n */\nexport function property(name: string, options?: PropertyOptions): void {\n return getGlobalInjector().property(name, options);\n}\n\n/**\n * Check if a CSS @property has already been defined\n *\n * @param name - The custom property name to check\n * @param options - Options including root\n */\nexport function isPropertyDefined(\n name: string,\n options?: { root?: Document | ShadowRoot },\n): boolean {\n return getGlobalInjector().isPropertyDefined(name, options);\n}\n\n/**\n * Get CSS text from all sheets (for SSR)\n */\nexport function getCssText(options?: { root?: Document | ShadowRoot }): string {\n return getGlobalInjector().getCssText(options);\n}\n\n/**\n * Collect only CSS used by a rendered subtree (like jest-styled-components).\n * Pass the container returned by render(...).\n */\nexport function getCssTextForNode(\n node: ParentNode | Element | DocumentFragment,\n options?: { root?: Document | ShadowRoot },\n): string {\n // Collect tasty-generated class names (t<number>) from the subtree\n const classSet = new Set<string>();\n\n const readClasses = (el: Element) => {\n const cls = el.getAttribute('class');\n if (!cls) return;\n for (const token of cls.split(/\\s+/)) {\n if (/^t\\d+$/.test(token)) classSet.add(token);\n }\n };\n\n // Include node itself if it's an Element\n if ((node as Element).getAttribute) {\n readClasses(node as Element);\n }\n // Walk descendants\n const elements = (node as ParentNode).querySelectorAll\n ? (node as ParentNode).querySelectorAll('[class]')\n : ([] as unknown as NodeListOf<Element>);\n if (elements) elements.forEach(readClasses);\n\n return getGlobalInjector().getCssTextForClasses(classSet, options);\n}\n\n/**\n * Force cleanup of unused rules\n */\nexport function cleanup(root?: Document | ShadowRoot): void {\n return getGlobalInjector().cleanup(root);\n}\n\n/**\n * Check if we're currently running in a test environment\n */\nexport function getIsTestEnvironment(): boolean {\n return isTestEnvironment();\n}\n\n/**\n * Get the global injector instance for debugging\n */\nexport const injector = {\n get instance() {\n return getGlobalInjector();\n },\n};\n\n/**\n * Destroy all resources and clean up\n */\nexport function destroy(root?: Document | ShadowRoot): void {\n return getGlobalInjector().destroy(root);\n}\n\n/**\n * Create a new isolated injector instance\n */\nexport function createInjector(\n config: Partial<StyleInjectorConfig> = {},\n): StyleInjector {\n const defaultConfig = getConfig();\n\n const fullConfig: StyleInjectorConfig = {\n ...defaultConfig,\n // Auto-enable forceTextInjection in test environments\n forceTextInjection: config.forceTextInjection ?? isTestEnvironment(),\n ...config,\n };\n\n return new StyleInjector(fullConfig);\n}\n\n// Re-export types\nexport type {\n StyleInjectorConfig,\n InjectResult,\n DisposeFunction,\n RuleInfo,\n SheetInfo,\n RootRegistry,\n StyleRule,\n KeyframesInfo,\n KeyframesResult,\n KeyframesSteps,\n KeyframesCacheEntry,\n CacheMetrics,\n RawCSSResult,\n PropertyDefinition,\n} from './types';\n\nexport { StyleInjector } from './injector';\nexport { SheetManager } from './sheet-manager';\n"],"mappings":";;;;;;;;AAoBA,SAAgB,kBACd,UACA,SACiD;AACjD,QAAO,mBAAmB,CAAC,kBAAkB,UAAU,QAAQ;;;;;AAMjE,SAAgB,OACd,OACA,SACc;AAEd,sBAAqB;AAErB,QAAO,mBAAmB,CAAC,OAAO,OAAO,QAAQ;;;;;AAMnD,SAAgB,aACd,OACA,SACoB;AACpB,QAAO,mBAAmB,CAAC,aAAa,OAAO,QAAQ;;;;;;;;;;;;;;;;;;;AAoBzD,SAAgB,aACd,KACA,SACyB;AACzB,QAAO,mBAAmB,CAAC,aAAa,KAAK,QAAQ;;;;;AAMvD,SAAgB,cAAc,SAEnB;AACT,QAAO,mBAAmB,CAAC,cAAc,QAAQ;;;;;AAMnD,SAAgB,UACd,OACA,eACiB;AACjB,QAAO,mBAAmB,CAAC,UAAU,OAAO,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkD5D,SAAgB,SAAS,MAAc,SAAiC;AACtE,QAAO,mBAAmB,CAAC,SAAS,MAAM,QAAQ;;;;;;;;AASpD,SAAgB,kBACd,MACA,SACS;AACT,QAAO,mBAAmB,CAAC,kBAAkB,MAAM,QAAQ;;;;;AAM7D,SAAgB,WAAW,SAAoD;AAC7E,QAAO,mBAAmB,CAAC,WAAW,QAAQ;;;;;;AAOhD,SAAgB,kBACd,MACA,SACQ;CAER,MAAM,2BAAW,IAAI,KAAa;CAElC,MAAM,eAAe,OAAgB;EACnC,MAAM,MAAM,GAAG,aAAa,QAAQ;AACpC,MAAI,CAAC,IAAK;AACV,OAAK,MAAM,SAAS,IAAI,MAAM,MAAM,CAClC,KAAI,SAAS,KAAK,MAAM,CAAE,UAAS,IAAI,MAAM;;AAKjD,KAAK,KAAiB,aACpB,aAAY,KAAgB;CAG9B,MAAM,WAAY,KAAoB,mBACjC,KAAoB,iBAAiB,UAAU,GAC/C,EAAE;AACP,KAAI,SAAU,UAAS,QAAQ,YAAY;AAE3C,QAAO,mBAAmB,CAAC,qBAAqB,UAAU,QAAQ;;;;;AAMpE,SAAgB,QAAQ,MAAoC;AAC1D,QAAO,mBAAmB,CAAC,QAAQ,KAAK;;;;;AAM1C,SAAgB,uBAAgC;AAC9C,QAAO,mBAAmB;;;;;AAM5B,MAAa,WAAW,EACtB,IAAI,WAAW;AACb,QAAO,mBAAmB;GAE7B;;;;AAKD,SAAgB,QAAQ,MAAoC;AAC1D,QAAO,mBAAmB,CAAC,QAAQ,KAAK;;;;;AAM1C,SAAgB,eACd,SAAuC,EAAE,EAC1B;AAUf,QAAO,IAAI,cAP6B;EACtC,GAHoB,WAAW;EAK/B,oBAAoB,OAAO,sBAAsB,mBAAmB;EACpE,GAAG;EACJ,CAEmC"}
@@ -0,0 +1,139 @@
1
+ import { CacheMetrics, GlobalInjectResult, InjectResult, KeyframesResult, KeyframesSteps, PropertyDefinition, RawCSSResult, StyleInjectorConfig } from "./types.js";
2
+ import { StyleResult } from "../pipeline/index.js";
3
+ import { SheetManager } from "./sheet-manager.js";
4
+
5
+ //#region src/injector/injector.d.ts
6
+ declare class StyleInjector {
7
+ private sheetManager;
8
+ private config;
9
+ private cleanupScheduled;
10
+ private globalRuleCounter;
11
+ /** @internal — exposed for debug utilities only */
12
+ get _sheetManager(): SheetManager;
13
+ constructor(config?: StyleInjectorConfig);
14
+ /**
15
+ * Allocate a className for a cacheKey without injecting styles yet.
16
+ * This allows separating className allocation (render phase) from style injection (insertion phase).
17
+ */
18
+ allocateClassName(cacheKey: string, options?: {
19
+ root?: Document | ShadowRoot;
20
+ }): {
21
+ className: string;
22
+ isNewAllocation: boolean;
23
+ };
24
+ /**
25
+ * Inject styles from StyleResult objects
26
+ */
27
+ inject(rules: StyleResult[], options?: {
28
+ root?: Document | ShadowRoot;
29
+ cacheKey?: string;
30
+ }): InjectResult;
31
+ /**
32
+ * Inject global styles (rules without a generated tasty class selector)
33
+ * This ensures we don't reserve a tasty class name (t{number}) for global rules,
34
+ * which could otherwise collide with element-level styles and break lookups.
35
+ */
36
+ injectGlobal(rules: StyleResult[], options?: {
37
+ root?: Document | ShadowRoot;
38
+ }): GlobalInjectResult;
39
+ /**
40
+ * Inject raw CSS text directly without parsing
41
+ * This is a low-overhead alternative to createGlobalStyle for raw CSS
42
+ * The CSS is inserted into a separate style element to avoid conflicts with tasty's chunking
43
+ */
44
+ injectRawCSS(css: string, options?: {
45
+ root?: Document | ShadowRoot;
46
+ }): RawCSSResult;
47
+ /**
48
+ * Get raw CSS text for SSR
49
+ */
50
+ getRawCSSText(options?: {
51
+ root?: Document | ShadowRoot;
52
+ }): string;
53
+ /**
54
+ * Dispose of a className
55
+ */
56
+ private dispose;
57
+ /**
58
+ * Force bulk cleanup of unused styles
59
+ */
60
+ cleanup(root?: Document | ShadowRoot): void;
61
+ /**
62
+ * Get CSS text from all sheets (for SSR)
63
+ */
64
+ getCssText(options?: {
65
+ root?: Document | ShadowRoot;
66
+ }): string;
67
+ /**
68
+ * Get CSS only for the provided tasty classNames (e.g., ["t0","t3"])
69
+ */
70
+ getCssTextForClasses(classNames: Iterable<string>, options?: {
71
+ root?: Document | ShadowRoot;
72
+ }): string;
73
+ /**
74
+ * Get cache performance metrics
75
+ */
76
+ getMetrics(options?: {
77
+ root?: Document | ShadowRoot;
78
+ }): CacheMetrics | null;
79
+ /**
80
+ * Reset cache performance metrics
81
+ */
82
+ resetMetrics(options?: {
83
+ root?: Document | ShadowRoot;
84
+ }): void;
85
+ /**
86
+ * Define a CSS @property custom property.
87
+ *
88
+ * Accepts tasty token syntax for the property name:
89
+ * - `$name` → defines `--name`
90
+ * - `#name` → defines `--name-color` (auto-sets syntax: '<color>', defaults initialValue: 'transparent')
91
+ * - `--name` → defines `--name` (legacy format)
92
+ *
93
+ * Example:
94
+ * @property --rotation { syntax: "<angle>"; inherits: false; initial-value: 45deg; }
95
+ *
96
+ * Note: No caching or dispose — this defines a global property.
97
+ *
98
+ * If the same property is registered with different options, a warning is emitted
99
+ * but the original definition is preserved (CSS @property cannot be redefined).
100
+ */
101
+ property(name: string, options?: PropertyDefinition & {
102
+ root?: Document | ShadowRoot;
103
+ }): void;
104
+ /**
105
+ * Check whether a given @property name was already injected by this injector.
106
+ *
107
+ * Accepts tasty token syntax:
108
+ * - `$name` → checks `--name`
109
+ * - `#name` → checks `--name-color`
110
+ * - `--name` → checks `--name` (legacy format)
111
+ */
112
+ isPropertyDefined(name: string, options?: {
113
+ root?: Document | ShadowRoot;
114
+ }): boolean;
115
+ /**
116
+ * Inject keyframes and return object with toString() and dispose()
117
+ *
118
+ * Keyframes are cached by content (steps). If the same content is injected
119
+ * multiple times with different provided names, the first injected name is reused.
120
+ *
121
+ * If the same name is provided with different content (collision), a unique
122
+ * name is generated to avoid overwriting the existing keyframes.
123
+ */
124
+ keyframes(steps: KeyframesSteps, nameOrOptions?: string | {
125
+ root?: Document | ShadowRoot;
126
+ name?: string;
127
+ }): KeyframesResult;
128
+ /**
129
+ * Dispose keyframes
130
+ */
131
+ private disposeKeyframes;
132
+ /**
133
+ * Destroy all resources for a root
134
+ */
135
+ destroy(root?: Document | ShadowRoot): void;
136
+ }
137
+ //#endregion
138
+ export { StyleInjector };
139
+ //# sourceMappingURL=injector.d.ts.map