@fluentic/style 0.1.0-beta.1 → 0.1.0-beta.10

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 (491) hide show
  1. package/CHANGELOG.md +150 -2
  2. package/README.md +181 -49
  3. package/atomic/atRule/utils.ts +3 -2
  4. package/atomic/className.ts +50 -12
  5. package/atomic/debug/className/className.ts +24 -8
  6. package/atomic/element.ts +5 -2
  7. package/atomic/rule.ts +11 -5
  8. package/atomic/scope.ts +19 -0
  9. package/atomic/theme.ts +44 -3
  10. package/atomic/token.ts +7 -4
  11. package/atomic/utils/cssIdent.ts +54 -0
  12. package/atomic/utils/cssVar.ts +19 -0
  13. package/atomic/utils/debug.ts +1 -1
  14. package/atomic/utils/format.ts +1 -1
  15. package/atomic/utils/hash.ts +14 -0
  16. package/atomic/utils/selector.ts +31 -1
  17. package/atomic/var.ts +3 -2
  18. package/builder/classname/class_name_builder.ts +491 -0
  19. package/builder/classname/fns.ts +77 -0
  20. package/builder/classname/index.ts +3 -0
  21. package/builder/classname/types.ts +41 -0
  22. package/builder/data/const.ts +8 -1
  23. package/builder/data/create.ts +52 -6
  24. package/builder/data/data.ts +33 -8
  25. package/builder/data/debug.ts +1 -0
  26. package/builder/data/index.ts +0 -1
  27. package/builder/data/is.ts +26 -3
  28. package/builder/data/merge/scope.ts +38 -38
  29. package/builder/data/merge/style.ts +115 -20
  30. package/builder/data/state.ts +17 -2
  31. package/builder/extract/index.ts +1 -0
  32. package/builder/extract/sheet.ts +30 -0
  33. package/builder/extract/token.ts +30 -14
  34. package/builder/extract/utils.ts +2 -0
  35. package/builder/extract/withTokens.ts +2 -1
  36. package/builder/selector_override.noop.ts +11 -0
  37. package/builder/selector_override.ts +31 -0
  38. package/builder/selector_override_core.ts +79 -0
  39. package/builder/style_builder.ts +144 -20
  40. package/builder/style_data.ts +25 -0
  41. package/builder/style_fns.ts +57 -57
  42. package/builder/token/data.ts +30 -0
  43. package/builder/token/index.ts +3 -0
  44. package/builder/token/name.ts +54 -0
  45. package/builder/token/symbols.ts +6 -0
  46. package/builder/types/alias.ts +44 -16
  47. package/builder/types/fns.ts +24 -16
  48. package/builder/types/types.ts +37 -7
  49. package/builder/utils.ts +1 -0
  50. package/compiler/compiler/compiler.ts +88 -14
  51. package/compiler/compiler/constants.ts +6 -0
  52. package/compiler/compiler/index.ts +1 -0
  53. package/compiler/compiler/types.ts +4 -1
  54. package/compiler/cssProp.ts +21 -0
  55. package/compiler/extract/extract.ts +42 -14
  56. package/compiler/extract/types.ts +2 -0
  57. package/compiler/index.ts +1 -0
  58. package/compiler/transform/cssProp/index.ts +1 -0
  59. package/compiler/transform/cssProp/plugin.ts +161 -0
  60. package/compiler/transform/debug/plugin.ts +93 -4
  61. package/compiler/transform/debug/transform.ts +2 -1
  62. package/compiler/transform/debug/utils/debug_data.ts +73 -0
  63. package/compiler/transform/evaluator/evaluator.ts +169 -32
  64. package/compiler/transform/evaluator/tracer.ts +48 -11
  65. package/compiler/transform/extract/chain/chain.ts +1370 -162
  66. package/compiler/transform/extract/chain/extract_chain.ts +12 -4
  67. package/compiler/transform/extract/chain/types.ts +3 -1
  68. package/compiler/transform/extract/plugin.ts +64 -6
  69. package/compiler/transform/extract/transform.ts +2 -1
  70. package/compiler/transform/extract/utils/replacement.ts +72 -2
  71. package/compiler/transform/extract/utils/state.ts +3 -0
  72. package/compiler/transform/extract/utils/theme.ts +6 -6
  73. package/compiler/transform/index.ts +1 -0
  74. package/compiler/transform/syntax/isStaticStyleValue.ts +15 -9
  75. package/compiler/transform/syntax/static_ids.ts +1 -1
  76. package/compiler/utils/constants.ts +12 -5
  77. package/compiler/utils/file_resolver.ts +2 -0
  78. package/compiler/utils/import_source.ts +19 -8
  79. package/compiler/utils/imports.ts +11 -1
  80. package/config/build.ts +9 -2
  81. package/config/config/check.ts +25 -0
  82. package/config/config/css.ts +18 -1
  83. package/config/config/debug.ts +24 -1
  84. package/config/config/dev.ts +17 -1
  85. package/config/configure.ts +19 -2
  86. package/config/types.ts +7 -0
  87. package/css/index.ts +2 -0
  88. package/css/sheet.ts +152 -0
  89. package/css/styleTarget.ts +251 -0
  90. package/dev/config.ts +2 -3
  91. package/dev/utils.ts +3 -3
  92. package/dialect/extracted/index.ts +5 -0
  93. package/dialect/index.ts +1 -0
  94. package/dialect/namedTokens.ts +153 -0
  95. package/dist/adapter/preact.js +2 -0
  96. package/dist/adapter/react.js +2 -0
  97. package/dist/adapter/solid.js +2 -0
  98. package/dist/className-yhJCGT0F.js +304 -0
  99. package/dist/className-yhJCGT0F.js.map +1 -0
  100. package/dist/combine-Bww7VnSr.js +1254 -0
  101. package/dist/combine-Bww7VnSr.js.map +1 -0
  102. package/dist/compiler/index.mjs +2 -2
  103. package/dist/{compiler-DENc3a2R.mjs → compiler-C3CEGGtI.mjs} +2335 -638
  104. package/dist/compiler-C3CEGGtI.mjs.map +1 -0
  105. package/dist/config/index.js +2 -2
  106. package/dist/config-BAEzRmSJ.js +6 -0
  107. package/dist/{config-Di2VYYKV.js.map → config-BAEzRmSJ.js.map} +1 -1
  108. package/dist/config-BKP5LOkt.js +35 -0
  109. package/dist/config-BKP5LOkt.js.map +1 -0
  110. package/dist/config-C5VWvTav.js +34 -0
  111. package/dist/config-C5VWvTav.js.map +1 -0
  112. package/dist/config-CB4lm2tM.js +1 -0
  113. package/dist/config-CDjbHwb-.js +6 -0
  114. package/dist/config-CDjbHwb-.js.map +1 -0
  115. package/dist/config-DNEnHEf3.js +36 -0
  116. package/dist/config-DNEnHEf3.js.map +1 -0
  117. package/dist/createTransformElement-D8fXZ3wA.js +34 -0
  118. package/dist/createTransformElement-D8fXZ3wA.js.map +1 -0
  119. package/dist/css-BDn0epJ8.js +1339 -0
  120. package/dist/css-BDn0epJ8.js.map +1 -0
  121. package/dist/css-CFxNrYt3.js +4040 -0
  122. package/dist/css-CFxNrYt3.js.map +1 -0
  123. package/dist/css-DEYgrj76.js +524 -0
  124. package/dist/css-DEYgrj76.js.map +1 -0
  125. package/dist/{runtime-CYqNCiaM.js → css-DWBWsyxZ.js} +16 -19
  126. package/dist/css-DWBWsyxZ.js.map +1 -0
  127. package/dist/css.js +2 -2
  128. package/dist/{css_extra-oIi3UEPK.js → css_extra-nTq_Gw0E.js} +2 -2
  129. package/dist/{css_extra-DlOnsnR1.js.map → css_extra-nTq_Gw0E.js.map} +1 -1
  130. package/dist/data-CDrS1Bq4.js +785 -0
  131. package/dist/data-CDrS1Bq4.js.map +1 -0
  132. package/dist/debug-BkVbf0Cz.js +52 -0
  133. package/dist/debug-BkVbf0Cz.js.map +1 -0
  134. package/dist/{debug-n2aZQBSa.js → debug-YuhEIQVO.js} +80 -4
  135. package/dist/debug-YuhEIQVO.js.map +1 -0
  136. package/dist/dev/rsc.js +10 -9
  137. package/dist/dev/rsc.js.map +1 -1
  138. package/dist/{dev-CcphAa3R.js → dev-0imWmSVb.js} +10 -10
  139. package/dist/dev-0imWmSVb.js.map +1 -0
  140. package/dist/dev.js +1 -1
  141. package/dist/dialect/extracted/index.js +2 -0
  142. package/dist/dialect/index.js +2 -0
  143. package/dist/{elementMarker-Bu7gDAkE.js → elementMarker-kvpMjB49.js} +164 -30
  144. package/dist/elementMarker-kvpMjB49.js.map +1 -0
  145. package/dist/entry/dev/adapter/preact.js +12 -0
  146. package/dist/entry/dev/adapter/preact.js.map +1 -0
  147. package/dist/entry/dev/adapter/react.js +12 -0
  148. package/dist/entry/dev/adapter/react.js.map +1 -0
  149. package/dist/entry/dev/adapter/solid.js +12 -0
  150. package/dist/entry/dev/adapter/solid.js.map +1 -0
  151. package/dist/entry/dev/css.js +3 -3
  152. package/dist/entry/dev/jsx-dev-runtime.js +2 -1
  153. package/dist/entry/dev/jsx-runtime.js +2 -1
  154. package/dist/entry/dev.js +13 -9
  155. package/dist/entry/prod/adapter/preact.js +12 -0
  156. package/dist/entry/prod/adapter/preact.js.map +1 -0
  157. package/dist/entry/prod/adapter/react.js +12 -0
  158. package/dist/entry/prod/adapter/react.js.map +1 -0
  159. package/dist/entry/prod/adapter/solid.js +12 -0
  160. package/dist/entry/prod/adapter/solid.js.map +1 -0
  161. package/dist/entry/prod/css.js +3 -3
  162. package/dist/entry/prod/extract.js +242 -3
  163. package/dist/entry/prod/extract.js.map +1 -0
  164. package/dist/entry/prod/jsx-dev-runtime.js +2 -2
  165. package/dist/entry/prod/jsx-runtime.js +2 -2
  166. package/dist/entry/prod/runtime.js +3 -4
  167. package/dist/entry/prod.js +84 -1201
  168. package/dist/entry/prod.js.map +1 -1
  169. package/dist/entry/rsc-dev/adapter/preact.js +13 -0
  170. package/dist/entry/rsc-dev/adapter/preact.js.map +1 -0
  171. package/dist/entry/rsc-dev/adapter/react.js +13 -0
  172. package/dist/entry/rsc-dev/adapter/react.js.map +1 -0
  173. package/dist/entry/rsc-dev/adapter/solid.js +13 -0
  174. package/dist/entry/rsc-dev/adapter/solid.js.map +1 -0
  175. package/dist/entry/rsc-dev/css.js +3 -3
  176. package/dist/entry/rsc-dev/dev.js +11 -13
  177. package/dist/entry/rsc-dev/dev.js.map +1 -1
  178. package/dist/entry/rsc-dev/jsx-dev-runtime.js +2 -2
  179. package/dist/entry/rsc-dev/jsx-runtime.js +2 -2
  180. package/dist/entry/rsc-dev.js +582 -664
  181. package/dist/entry/rsc-dev.js.map +1 -1
  182. package/dist/entry/rsc-prod/adapter/preact.js +2 -0
  183. package/dist/entry/rsc-prod/adapter/react.js +2 -0
  184. package/dist/entry/rsc-prod/adapter/solid.js +2 -0
  185. package/dist/entry/rsc-prod/css.js +9 -3
  186. package/dist/entry/rsc-prod/css.js.map +1 -0
  187. package/dist/entry/rsc-prod/jsx-dev-runtime.js +2 -2
  188. package/dist/entry/rsc-prod/jsx-runtime.js +2 -2
  189. package/dist/entry/rsc-prod/runtime.js +3 -4
  190. package/dist/entry/rsc-prod.js +242 -10
  191. package/dist/entry/rsc-prod.js.map +1 -0
  192. package/dist/{styleStore-Dea_WVbr.js → env-Cz8frh6e.js} +1335 -372
  193. package/dist/env-Cz8frh6e.js.map +1 -0
  194. package/dist/getClassName-9CsXbNls.js +545 -0
  195. package/dist/getClassName-9CsXbNls.js.map +1 -0
  196. package/dist/{utils-D7FAOyg6.js → getClassName-DGm-VNDo.js} +28 -65
  197. package/dist/getClassName-DGm-VNDo.js.map +1 -0
  198. package/dist/getClassName-Dtc4yyYI.js +47 -0
  199. package/dist/getClassName-Dtc4yyYI.js.map +1 -0
  200. package/dist/{getClassName-BlvXHYuf.js → getClassName-DtkplEIt.js} +56 -14
  201. package/dist/getClassName-DtkplEIt.js.map +1 -0
  202. package/dist/global-CAc9OjKx.js +14 -0
  203. package/dist/global-CAc9OjKx.js.map +1 -0
  204. package/dist/{format-3nKBE_5t.js → hash-Cr-LCWDt.js} +51 -29
  205. package/dist/hash-Cr-LCWDt.js.map +1 -0
  206. package/dist/index.js +10 -8
  207. package/dist/jsx/jsx-dev-runtime.js +2 -2
  208. package/dist/jsx/jsx-dev-runtime.server.js +1 -1
  209. package/dist/jsx/jsx-runtime.js +2 -2
  210. package/dist/jsx/jsx-runtime.server.js +1 -1
  211. package/dist/jsx-CVxpkS04.js +39 -0
  212. package/dist/jsx-CVxpkS04.js.map +1 -0
  213. package/dist/{jsx_dev_runtime-B6xs4by8.js → jsx_dev_runtime-D068tAsT.js} +2 -3
  214. package/dist/{jsx_dev_runtime-B6xs4by8.js.map → jsx_dev_runtime-D068tAsT.js.map} +1 -1
  215. package/dist/{jsx_runtime-iHLDwpcW.js → jsx_runtime-6Qa1lmz2.js} +2 -2
  216. package/dist/{jsx_runtime-iHLDwpcW.js.map → jsx_runtime-6Qa1lmz2.js.map} +1 -1
  217. package/dist/{jsx_runtime-04xfnsi7.js → jsx_runtime-DT1Tr9cH.js} +2 -3
  218. package/dist/{jsx_runtime-04xfnsi7.js.map → jsx_runtime-DT1Tr9cH.js.map} +1 -1
  219. package/dist/{loader-B5Kw0DD-.mjs → loader-_-VjzlrX.mjs} +13 -14
  220. package/dist/loader-_-VjzlrX.mjs.map +1 -0
  221. package/dist/{misc-DCdYYyhK.mjs → misc-B76PUnWe.mjs} +11 -6
  222. package/dist/misc-B76PUnWe.mjs.map +1 -0
  223. package/dist/namedTokens-5AayGokX.js +85 -0
  224. package/dist/namedTokens-5AayGokX.js.map +1 -0
  225. package/dist/plugin/farm/index.mjs +4 -3
  226. package/dist/plugin/farm/index.mjs.map +1 -1
  227. package/dist/plugin/nextjs/index.mjs +121 -17
  228. package/dist/plugin/nextjs/index.mjs.map +1 -1
  229. package/dist/plugin/nextjs/loader.mjs +4 -4
  230. package/dist/plugin/parcel/index.cjs +2 -0
  231. package/dist/plugin/parcel/index.mjs +3 -1
  232. package/dist/plugin/parcel/optimizer.cjs +3 -2
  233. package/dist/plugin/parcel/optimizer.cjs.map +1 -1
  234. package/dist/plugin/parcel/optimizer.mjs +3 -2
  235. package/dist/plugin/parcel/optimizer.mjs.map +1 -1
  236. package/dist/plugin/parcel/resolver.cjs +1 -1
  237. package/dist/plugin/parcel/resolver.mjs +2 -2
  238. package/dist/plugin/parcel/runtime.cjs +1 -1
  239. package/dist/plugin/parcel/runtime.mjs +1 -1
  240. package/dist/plugin/parcel/transformer.cjs +1 -1
  241. package/dist/plugin/parcel/transformer.mjs +2 -2
  242. package/dist/plugin/rspack/index.mjs +3 -2
  243. package/dist/plugin/rspack/index.mjs.map +1 -1
  244. package/dist/plugin/vite/index.mjs +13 -10
  245. package/dist/plugin/vite/index.mjs.map +1 -1
  246. package/dist/plugin/webpack/index.mjs +3 -2
  247. package/dist/plugin/webpack/loader.mjs +2 -2
  248. package/dist/presets/tailwind/index.js +995 -0
  249. package/dist/presets/tailwind/index.js.map +1 -0
  250. package/dist/{assert-BGdigdr5.js → presets-DSanixJV.js} +106 -2
  251. package/dist/presets-DSanixJV.js.map +1 -0
  252. package/dist/{registry-yHLRxyoo.mjs → registry-w8ET5R7v.mjs} +2 -2
  253. package/dist/{registry-yHLRxyoo.mjs.map → registry-w8ET5R7v.mjs.map} +1 -1
  254. package/dist/resolveClassNameRuntime-CJjlUP93.js +63 -0
  255. package/dist/resolveClassNameRuntime-CJjlUP93.js.map +1 -0
  256. package/dist/{rules-9HSO1pxL.js → rules-DaMaMHgb.js} +618 -138
  257. package/dist/rules-DaMaMHgb.js.map +1 -0
  258. package/dist/scope-CZdGAnl_.js +601 -0
  259. package/dist/scope-CZdGAnl_.js.map +1 -0
  260. package/dist/selector/index.js +1 -2
  261. package/dist/server.js +17 -11
  262. package/dist/server.js.map +1 -1
  263. package/dist/{shared-CxbHR89f.mjs → shared-C_cYxNzz.mjs} +4 -4
  264. package/dist/{shared-CxbHR89f.mjs.map → shared-C_cYxNzz.mjs.map} +1 -1
  265. package/dist/{shared-CBArHB9-.cjs → shared-PK52rW6T.cjs} +2338 -635
  266. package/dist/shared-PK52rW6T.cjs.map +1 -0
  267. package/dist/sheet-CxkO1Hwt.js +7 -0
  268. package/dist/sheet-CxkO1Hwt.js.map +1 -0
  269. package/dist/{sidecar-BFakLl0X.mjs → sidecar-BhvmXYsD.mjs} +3 -3
  270. package/dist/{sidecar-BFakLl0X.mjs.map → sidecar-BhvmXYsD.mjs.map} +1 -1
  271. package/dist/style-CAhAnRni.js +1129 -0
  272. package/dist/style-CAhAnRni.js.map +1 -0
  273. package/dist/{styleStore-DyNXBcUK.js → styleStore-BzLZwpwy.js} +8 -7
  274. package/dist/styleStore-BzLZwpwy.js.map +1 -0
  275. package/dist/styleStore-DaIJ4OPV.js +58 -0
  276. package/dist/styleStore-DaIJ4OPV.js.map +1 -0
  277. package/dist/token-D33mKTka.js +138 -0
  278. package/dist/token-D33mKTka.js.map +1 -0
  279. package/dist/{trace-Bu_qOqRy.js → trace-B3dpTRJp.js} +3 -3
  280. package/dist/{trace-Bu_qOqRy.js.map → trace-B3dpTRJp.js.map} +1 -1
  281. package/dist/{trace-CU0rvNYr.js → trace-c2WmBbmX.js} +2 -2
  282. package/dist/{trace-CU0rvNYr.js.map → trace-c2WmBbmX.js.map} +1 -1
  283. package/dist/transform-DSpimwwC.js +23 -0
  284. package/dist/transform-DSpimwwC.js.map +1 -0
  285. package/dist/{utils-Bdbqn0f8.mjs → utils-DND33M6y.mjs} +3 -3
  286. package/dist/{utils-Bdbqn0f8.mjs.map → utils-DND33M6y.mjs.map} +1 -1
  287. package/dist/utils-DZK0mfmY.js +42 -0
  288. package/dist/utils-DZK0mfmY.js.map +1 -0
  289. package/dist/utils-D_XgtMtn.js +72 -0
  290. package/dist/utils-D_XgtMtn.js.map +1 -0
  291. package/dist/utils-DxCpyV2E.js +62 -0
  292. package/dist/utils-DxCpyV2E.js.map +1 -0
  293. package/dist/{utils-BbehLOby.js → utils-H1VInWpd.js} +407 -234
  294. package/dist/utils-H1VInWpd.js.map +1 -0
  295. package/dist/utils-NdisireF.mjs +182 -0
  296. package/dist/utils-NdisireF.mjs.map +1 -0
  297. package/dist/utils.js +4 -4
  298. package/dist/utils.js.map +1 -1
  299. package/dist/value-CK0-Xbov.js +160 -0
  300. package/dist/value-CK0-Xbov.js.map +1 -0
  301. package/dist/{webpack-Dh6lox2l.mjs → webpack-D7QO0bKN.mjs} +5 -5
  302. package/dist/webpack-D7QO0bKN.mjs.map +1 -0
  303. package/entry/dev/adapter/preact.ts +8 -0
  304. package/entry/dev/adapter/react.ts +8 -0
  305. package/entry/dev/adapter/solid.ts +8 -0
  306. package/entry/dev/config.ts +1 -1
  307. package/entry/dev/index.ts +1 -0
  308. package/entry/dev/jsx_dev_runtime.ts +1 -0
  309. package/entry/dev/jsx_runtime.ts +1 -0
  310. package/entry/dev/sheet.ts +4 -0
  311. package/entry/prod/adapter/preact.ts +8 -0
  312. package/entry/prod/adapter/react.ts +8 -0
  313. package/entry/prod/adapter/solid.ts +8 -0
  314. package/entry/prod/config_debug.ts +2 -0
  315. package/entry/prod/index.ts +1 -1
  316. package/entry/prod/runtime.ts +4 -2
  317. package/entry/rsc_dev/adapter/preact.ts +9 -0
  318. package/entry/rsc_dev/adapter/react.ts +9 -0
  319. package/entry/rsc_dev/adapter/solid.ts +9 -0
  320. package/entry/rsc_dev/config.ts +1 -1
  321. package/entry/rsc_dev/server.ts +1 -1
  322. package/entry/rsc_prod/adapter/preact.ts +1 -0
  323. package/entry/rsc_prod/adapter/react.ts +1 -0
  324. package/entry/rsc_prod/adapter/solid.ts +1 -0
  325. package/entry/rsc_prod/config_debug.ts +6 -0
  326. package/entry/rsc_prod/index.ts +1 -1
  327. package/entry/rsc_prod/runtime.ts +1 -1
  328. package/entry/rsc_prod/server.ts +1 -1
  329. package/entry/shared/config_debug.ts +9 -0
  330. package/entry/shared/config_dev.ts +14 -0
  331. package/entry/shared/dev.ts +11 -2
  332. package/entry/shared/utils.ts +28 -0
  333. package/jsx/types/index.ts +1 -0
  334. package/jsx/types/preact.ts +14 -0
  335. package/jsx/{types.ts → types/react.ts} +2 -2
  336. package/jsx/types/solid.ts +32 -0
  337. package/package.json +110 -8
  338. package/plugin/bundler/farm/plugin.ts +2 -0
  339. package/plugin/bundler/parcel/optimizer.ts +1 -0
  340. package/plugin/bundler/parcel/plugin.ts +2 -0
  341. package/plugin/bundler/rspack/plugin.ts +1 -0
  342. package/plugin/bundler/vite/plugin.ts +5 -9
  343. package/plugin/bundler/vite/state.ts +11 -6
  344. package/plugin/bundler/webpack/plugin.ts +2 -1
  345. package/plugin/bundler/webpack/shared/loader.ts +9 -7
  346. package/plugin/nextjs/plugin.ts +208 -15
  347. package/plugin/nextjs/types.ts +1 -2
  348. package/plugin/nextjs/utils.ts +121 -0
  349. package/plugin/utils/compiler.ts +2 -0
  350. package/plugin/utils/runtimeEntry.ts +15 -2
  351. package/presets/tailwind/classname/index.ts +2 -0
  352. package/presets/tailwind/classname/transform.ts +239 -0
  353. package/presets/tailwind/classname/types.ts +124 -0
  354. package/presets/tailwind/index.ts +5 -0
  355. package/presets/tailwind/selectors.ts +27 -0
  356. package/presets/tailwind/style/index.ts +2 -0
  357. package/presets/tailwind/style/transform.ts +436 -0
  358. package/presets/tailwind/style/types.ts +346 -0
  359. package/presets/tailwind/theme.ts +479 -0
  360. package/presets/tailwind/types.ts +147 -0
  361. package/runtime/adapter/utils.ts +120 -0
  362. package/runtime/core/cache/combine.ts +76 -28
  363. package/runtime/core/cache/combineRuntime.ts +4 -0
  364. package/runtime/core/cache/index.ts +2 -1
  365. package/runtime/core/cache/item.ts +32 -13
  366. package/runtime/core/cache/itemWithResolver.ts +44 -0
  367. package/runtime/core/cache/pool.ts +16 -31
  368. package/runtime/core/cache/prop.ts +10 -8
  369. package/runtime/core/cache/result.ts +2 -2
  370. package/runtime/core/cache/stateItem.ts +16 -1
  371. package/runtime/core/cache/token.ts +20 -0
  372. package/runtime/core/cache/tokenValues.ts +19 -11
  373. package/runtime/core/combinedStyle.ts +4 -4
  374. package/runtime/extract/combineStyle.ts +211 -0
  375. package/runtime/extract/getClassName.ts +55 -23
  376. package/runtime/extract/index.ts +4 -2
  377. package/runtime/extract/token.ts +41 -0
  378. package/runtime/extract/tokenResolver.ts +17 -0
  379. package/runtime/index.ts +8 -1
  380. package/runtime/rsc/getClassName.ts +4 -0
  381. package/runtime/rsc/observer.ts +4 -0
  382. package/runtime/rsc/styleStore.ts +18 -7
  383. package/runtime/sheet/rule.ts +16 -12
  384. package/runtime/sheet/rules.ts +8 -3
  385. package/runtime/style/scope.ts +0 -24
  386. package/runtime/style/style.ts +181 -6
  387. package/runtime/types.ts +6 -4
  388. package/sheet/dev/dev_layer.ts +18 -7
  389. package/sheet/dev/dev_sort.ts +45 -11
  390. package/sheet/prod.ts +18 -7
  391. package/sheet/types.ts +2 -0
  392. package/sheet/utils/layer.ts +33 -0
  393. package/style/classname.ts +47 -0
  394. package/style/important.ts +19 -0
  395. package/style/index.ts +3 -0
  396. package/style/style.ts +47 -16
  397. package/style/theme.ts +4 -3
  398. package/style/token.ts +26 -21
  399. package/style/tokens.ts +18 -12
  400. package/style/transform.ts +41 -2
  401. package/style/types.ts +6 -4
  402. package/style/utils/expose.ts +4 -3
  403. package/style/value.ts +26 -11
  404. package/style/valueRef.ts +1 -1
  405. package/style/weight.ts +21 -0
  406. package/utils/global.ts +1 -3
  407. package/utils/hash.ts +4 -0
  408. package/utils/symbol.ts +3 -0
  409. package/atomic/layer/README.md +0 -116
  410. package/atomic/utils/css.ts +0 -49
  411. package/dist/assert-BGdigdr5.js.map +0 -1
  412. package/dist/className-C1Ht5Wvv.js +0 -144
  413. package/dist/className-C1Ht5Wvv.js.map +0 -1
  414. package/dist/className-DC2Cq8p3.js +0 -251
  415. package/dist/className-DC2Cq8p3.js.map +0 -1
  416. package/dist/compiler-DENc3a2R.mjs.map +0 -1
  417. package/dist/config-BryWDfQX.js +0 -25
  418. package/dist/config-BryWDfQX.js.map +0 -1
  419. package/dist/config-DKHXWhe1.js +0 -1
  420. package/dist/config-Di2VYYKV.js +0 -6
  421. package/dist/config-DloHOG6I.js +0 -13
  422. package/dist/config-DloHOG6I.js.map +0 -1
  423. package/dist/css-BowBszUt.js +0 -243
  424. package/dist/css-BowBszUt.js.map +0 -1
  425. package/dist/css-ByOrugEX.js +0 -805
  426. package/dist/css-ByOrugEX.js.map +0 -1
  427. package/dist/css-DcazYor9.js +0 -235
  428. package/dist/css-DcazYor9.js.map +0 -1
  429. package/dist/css_extra-DlOnsnR1.js +0 -8
  430. package/dist/css_extra-oIi3UEPK.js.map +0 -1
  431. package/dist/data-BsqOa5br.js +0 -473
  432. package/dist/data-BsqOa5br.js.map +0 -1
  433. package/dist/debug-BAw63qX6.js +0 -15
  434. package/dist/debug-BAw63qX6.js.map +0 -1
  435. package/dist/debug-DGki_v7g.js +0 -15
  436. package/dist/debug-DGki_v7g.js.map +0 -1
  437. package/dist/debug-n2aZQBSa.js.map +0 -1
  438. package/dist/dev-CcphAa3R.js.map +0 -1
  439. package/dist/dev-DfBbuLeE.js +0 -71
  440. package/dist/dev-DfBbuLeE.js.map +0 -1
  441. package/dist/elementMarker-Bu7gDAkE.js.map +0 -1
  442. package/dist/extract-CzWJeQi8.js +0 -121
  443. package/dist/extract-CzWJeQi8.js.map +0 -1
  444. package/dist/extract-DEwSDJ9Z.js +0 -2
  445. package/dist/format-3nKBE_5t.js.map +0 -1
  446. package/dist/getClassName-BlvXHYuf.js.map +0 -1
  447. package/dist/global-CvfmFLsK.js +0 -11
  448. package/dist/global-CvfmFLsK.js.map +0 -1
  449. package/dist/jsx-CwTeyUxr.js +0 -39
  450. package/dist/jsx-CwTeyUxr.js.map +0 -1
  451. package/dist/jsx-D2BksHSv.js +0 -38
  452. package/dist/jsx-D2BksHSv.js.map +0 -1
  453. package/dist/layer-D1SaH07m.js +0 -94
  454. package/dist/layer-D1SaH07m.js.map +0 -1
  455. package/dist/loader-B5Kw0DD-.mjs.map +0 -1
  456. package/dist/misc-DCdYYyhK.mjs.map +0 -1
  457. package/dist/presets-BhXa232U.js +0 -108
  458. package/dist/presets-BhXa232U.js.map +0 -1
  459. package/dist/property-CnLFt5kx.js +0 -406
  460. package/dist/property-CnLFt5kx.js.map +0 -1
  461. package/dist/rules-9HSO1pxL.js.map +0 -1
  462. package/dist/runtime-CYqNCiaM.js.map +0 -1
  463. package/dist/shared-CBArHB9-.cjs.map +0 -1
  464. package/dist/style-B-6jHipw.js +0 -5
  465. package/dist/style-B1UUqjj5.js +0 -743
  466. package/dist/style-B1UUqjj5.js.map +0 -1
  467. package/dist/style-DgHbdbdF.js +0 -752
  468. package/dist/style-DgHbdbdF.js.map +0 -1
  469. package/dist/style-v2bf70TZ.js +0 -1269
  470. package/dist/style-v2bf70TZ.js.map +0 -1
  471. package/dist/styleStore-Dea_WVbr.js.map +0 -1
  472. package/dist/styleStore-DyNXBcUK.js.map +0 -1
  473. package/dist/token-CKXUECuU.js +0 -76
  474. package/dist/token-CKXUECuU.js.map +0 -1
  475. package/dist/token-u_tM-mtg.js +0 -204
  476. package/dist/token-u_tM-mtg.js.map +0 -1
  477. package/dist/utils-BbehLOby.js.map +0 -1
  478. package/dist/utils-CEaq_c-A.mjs +0 -97
  479. package/dist/utils-CEaq_c-A.mjs.map +0 -1
  480. package/dist/utils-CWNHx4EC.js +0 -170
  481. package/dist/utils-CWNHx4EC.js.map +0 -1
  482. package/dist/utils-D7FAOyg6.js.map +0 -1
  483. package/dist/value-BR4e2MKt.js +0 -910
  484. package/dist/value-BR4e2MKt.js.map +0 -1
  485. package/dist/value-E8rEv2Oe.js +0 -136
  486. package/dist/value-E8rEv2Oe.js.map +0 -1
  487. package/dist/valueRef-lshFk1Cs.js +0 -16
  488. package/dist/valueRef-lshFk1Cs.js.map +0 -1
  489. package/dist/webpack-Dh6lox2l.mjs.map +0 -1
  490. package/dist/withTokens-LRidu3Vc.js +0 -95
  491. package/dist/withTokens-LRidu3Vc.js.map +0 -1
@@ -2,13 +2,14 @@ import type { NextConfig } from 'next';
2
2
  import { PHASE_DEVELOPMENT_SERVER } from 'next/constants';
3
3
  import fs from 'node:fs';
4
4
  import path from 'node:path';
5
- import type { Compiler, RuleSetRule } from 'webpack';
5
+ import type { Compilation, Compiler, RuleSetRule } from 'webpack';
6
6
  import type { BuildConfig, BuildDevConfig } from '../../config/build';
7
7
  import { isPromiseLike } from '../../utils/object';
8
8
  import {
9
9
  BUNDLE_CSS_FILE,
10
10
  createCompilerId,
11
11
  createFileCssCache,
12
+ createFileCssContentHash,
12
13
  createPluginCompiler,
13
14
  DEFAULT_TRANSFORM_EXCLUDE,
14
15
  DEFAULT_TRANSFORM_INCLUDE,
@@ -42,6 +43,7 @@ import {
42
43
  createNextBuildConfig,
43
44
  createNextBuildDevConfig,
44
45
  createNextConfigHash,
46
+ createSerializableImportSources,
45
47
  getNextCacheDir,
46
48
  getNextPrecollectCacheSubdir,
47
49
  getTransformLoaderPath,
@@ -49,15 +51,16 @@ import {
49
51
  type NextLoaderState,
50
52
  nextRegistry,
51
53
  removeUndefinedValues,
52
- replaceCssMarkerAsset,
53
54
  resolveNextCompilerOptions,
55
+ replaceCssMarkerAsset,
54
56
  } from './utils';
55
57
 
58
+ export { CssPropPresets } from '../utils';
59
+ export type { CompilerCssPropOptions } from '../utils';
60
+
56
61
  export default plugin;
57
62
 
58
63
  const TURBOPACK_TRANSFORM_EXTENSIONS: readonly string[] = ['*.ts', '*.tsx', '*.js', '*.jsx'];
59
- const clearedPrecollectCacheRoots = new Set<string>();
60
-
61
64
  type NextPhaseState = {
62
65
  buildConfig: BuildConfig;
63
66
  buildDevConfig: BuildDevConfig | null;
@@ -107,17 +110,20 @@ function createNextConfig(
107
110
  phaseState.configHash = createNextConfigHash(
108
111
  phaseState.buildConfig,
109
112
  phaseState.dev,
113
+ options.importSources,
110
114
  );
111
115
 
112
116
  let sidecar: SourcemapSidecar | null = null;
113
117
 
114
118
  if (dev) {
115
- const route: SidecarRouteHandler = () => ({
119
+ const getDevCss = () => cssCache.getCss({
120
+ ...phaseState.buildConfig.css,
121
+ configHash: phaseState.configHash,
122
+ });
123
+
124
+ const route: SidecarRouteHandler = async () => ({
116
125
  contentType: 'text/css; charset=utf-8',
117
- body: cssCache.getCss({
118
- ...phaseState.buildConfig.css,
119
- configHash: phaseState.configHash,
120
- }),
126
+ body: await waitForDevCss(getDevCss),
121
127
  });
122
128
 
123
129
  sidecar = getSourcemapSidecar({
@@ -143,6 +149,22 @@ function createNextConfig(
143
149
  : finish();
144
150
  }
145
151
 
152
+ async function waitForDevCss(getCss: () => string) {
153
+ let css = getCss();
154
+ if (css) return css;
155
+
156
+ const deadline = Date.now() + 5000;
157
+
158
+ while (Date.now() < deadline) {
159
+ await new Promise((resolve) => setTimeout(resolve, 25));
160
+
161
+ css = getCss();
162
+ if (css) return css;
163
+ }
164
+
165
+ return css;
166
+ }
167
+
146
168
  function createFluenticNextConfigResolved(
147
169
  nextConfig: NextConfig,
148
170
  options: PluginOptions,
@@ -159,7 +181,7 @@ function createFluenticNextConfigResolved(
159
181
  const projectDir = process.cwd();
160
182
 
161
183
  const devCssHref = dev && sidecar
162
- ? sidecar.getRouteUrl(DEV_CSS_ROUTE)
184
+ ? DEV_CSS_ROUTE
163
185
  : null;
164
186
 
165
187
  const turbopackCompilerId = createCompilerId(NEXT_COMPILER_IDS.turbopack);
@@ -201,6 +223,7 @@ function createFluenticNextConfigResolved(
201
223
  return {
202
224
  ...nextConfig,
203
225
  env: nextConfig.env,
226
+ rewrites: createNextRewrites(nextConfig.rewrites, dev && sidecar ? sidecar : null),
204
227
  compiler: {
205
228
  ...originalCompiler,
206
229
  define: {
@@ -243,6 +266,7 @@ function createFluenticNextConfigResolved(
243
266
  cssAliases: turbopackCssAliases,
244
267
  dev,
245
268
  devCssHref,
269
+ options,
246
270
  projectDir,
247
271
  }),
248
272
  webpack(config: WebpackConfiguration, context: WebpackConfigContext) {
@@ -299,6 +323,7 @@ function createFluenticNextConfigResolved(
299
323
  cssOutput: options.cssOutput,
300
324
  cssCache,
301
325
  dev: context.dev,
326
+ filter: state.filter,
302
327
  sidecar,
303
328
  });
304
329
 
@@ -307,6 +332,45 @@ function createFluenticNextConfigResolved(
307
332
  };
308
333
  }
309
334
 
335
+ function createNextRewrites(
336
+ originalRewrites: NextConfig['rewrites'],
337
+ sidecar: SourcemapSidecar | null,
338
+ ): NextConfig['rewrites'] {
339
+ if (!sidecar) return originalRewrites;
340
+
341
+ return async () => {
342
+ await sidecar.ensureStarted();
343
+
344
+ const devCssRewrite = {
345
+ source: DEV_CSS_ROUTE,
346
+ destination: sidecar.getRouteUrl(DEV_CSS_ROUTE),
347
+ };
348
+
349
+ const original = await originalRewrites?.();
350
+
351
+ if (!original) {
352
+ return {
353
+ beforeFiles: [devCssRewrite],
354
+ afterFiles: [],
355
+ fallback: [],
356
+ };
357
+ }
358
+
359
+ if (Array.isArray(original)) {
360
+ return {
361
+ beforeFiles: [devCssRewrite],
362
+ afterFiles: original,
363
+ fallback: [],
364
+ };
365
+ }
366
+
367
+ return {
368
+ ...original,
369
+ beforeFiles: [devCssRewrite, ...(original.beforeFiles ?? [])],
370
+ };
371
+ };
372
+ }
373
+
310
374
  function getImportableCssCacheDir(projectDir: string) {
311
375
  return path.join(projectDir, PLUGIN_CACHE_DIR);
312
376
  }
@@ -322,6 +386,7 @@ function createTurbopackConfig(
322
386
  cssAliases: Record<string, string>;
323
387
  dev: boolean;
324
388
  devCssHref: string | null;
389
+ options: PluginOptions;
325
390
  projectDir: string;
326
391
  },
327
392
  ): TurbopackConfig {
@@ -351,12 +416,16 @@ function mergeTurbopackRules(
351
416
  cssAliases: Record<string, string>;
352
417
  dev: boolean;
353
418
  devCssHref: string | null;
419
+ options: PluginOptions;
354
420
  projectDir: string;
355
421
  },
356
422
  ): TurbopackRules {
423
+ const compilerOptions = createSerializableTurbopackCompilerOptions(args.options);
424
+
357
425
  const loaderItem: TurbopackLoaderItem = {
358
426
  loader: LOADER_IMPORT_PATH,
359
427
  options: removeUndefinedValues({
428
+ ...compilerOptions,
360
429
  buildConfig: args.buildConfig,
361
430
  buildDevConfig: args.buildDevConfig,
362
431
  cacheDir: args.cacheDir,
@@ -379,6 +448,55 @@ function mergeTurbopackRules(
379
448
  return nextRules as TurbopackRules;
380
449
  }
381
450
 
451
+ function createSerializableTurbopackCompilerOptions(
452
+ options: PluginOptions,
453
+ ): Partial<PluginOptions> {
454
+ return removeUndefinedValues({
455
+ css: options.css,
456
+ cssProp: options.cssProp,
457
+ dev: options.dev,
458
+ hoist: options.hoist,
459
+ importSources: createSerializableTurbopackImportSources(options.importSources),
460
+ });
461
+ }
462
+
463
+ function createSerializableTurbopackImportSources(
464
+ importSources: PluginOptions['importSources'],
465
+ ): PluginOptions['importSources'] | undefined {
466
+ const serialized = createSerializableImportSources(importSources);
467
+ if (!serialized) return undefined;
468
+
469
+ const result = serialized.filter((entry) => isSerializableLoaderValue(entry));
470
+ return result.length ? result : undefined;
471
+ }
472
+
473
+ function isSerializableLoaderValue(value: unknown): boolean {
474
+ if (value === null) return true;
475
+
476
+ const valueType = typeof value;
477
+
478
+ if (
479
+ valueType === 'string' ||
480
+ valueType === 'number' ||
481
+ valueType === 'boolean'
482
+ ) {
483
+ return true;
484
+ }
485
+
486
+ if (valueType !== 'object') return false;
487
+
488
+ if (Array.isArray(value)) {
489
+ return value.every((item) => isSerializableLoaderValue(item));
490
+ }
491
+
492
+ const prototype = Object.getPrototypeOf(value);
493
+ if (prototype !== Object.prototype && prototype !== null) return false;
494
+
495
+ return Object.values(value as Record<string, unknown>).every((item) =>
496
+ isSerializableLoaderValue(item),
497
+ );
498
+ }
499
+
382
500
  function prependTurbopackLoader(rule: unknown, loader: TurbopackLoaderItem) {
383
501
  if (!rule || typeof rule !== 'object' || Array.isArray(rule)) {
384
502
  return { loaders: [loader] };
@@ -475,6 +593,7 @@ function addLifecyclePlugin(
475
593
  cssOutput: PluginCssOutputOptions | undefined;
476
594
  cssCache: ReturnType<typeof createFileCssCache>;
477
595
  dev: boolean;
596
+ filter: NextLoaderState['filter'];
478
597
  sidecar: SourcemapSidecar | null;
479
598
  },
480
599
  ) {
@@ -482,11 +601,6 @@ function addLifecyclePlugin(
482
601
  apply(webpackCompiler: Compiler) {
483
602
  webpackCompiler.hooks.beforeRun.tapPromise(PLUGIN_NAME, async () => {
484
603
  await args.sidecar?.ensureStarted();
485
-
486
- if (!args.dev && !clearedPrecollectCacheRoots.has(args.cssCache.rootDir)) {
487
- clearedPrecollectCacheRoots.add(args.cssCache.rootDir);
488
- args.cssCache.clear();
489
- }
490
604
  });
491
605
 
492
606
  webpackCompiler.hooks.watchRun.tapPromise(PLUGIN_NAME, async (watchCompiler) => {
@@ -507,6 +621,8 @@ function addLifecyclePlugin(
507
621
  stage: webpackCompiler.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS,
508
622
  },
509
623
  async () => {
624
+ precollectProductionCssFromCompilation(args, compilation, webpackCompiler);
625
+
510
626
  const css = await transformCssOutput(
511
627
  args.cssCache.getCss({
512
628
  ...args.buildConfig.css,
@@ -530,3 +646,80 @@ function addLifecyclePlugin(
530
646
  },
531
647
  });
532
648
  }
649
+
650
+ function precollectProductionCssFromCompilation(
651
+ args: {
652
+ configHash: string;
653
+ compiler: NextLoaderState['compiler'];
654
+ cssCache: ReturnType<typeof createFileCssCache>;
655
+ dev: boolean;
656
+ filter: NextLoaderState['filter'];
657
+ },
658
+ compilation: Compilation,
659
+ webpackCompiler: Compiler,
660
+ ) {
661
+ if (args.dev) return;
662
+
663
+ const existingCss = args.cssCache.getCss({
664
+ configHash: args.configHash,
665
+ });
666
+
667
+ if (existingCss) return;
668
+
669
+ const files = getCompilationSourceFiles(compilation, webpackCompiler.context, args.filter);
670
+
671
+ for (const filePath of files) {
672
+ let code: string;
673
+
674
+ try {
675
+ code = fs.readFileSync(filePath, 'utf8');
676
+ } catch {
677
+ continue;
678
+ }
679
+
680
+ const result = args.compiler.compileExtract({
681
+ code,
682
+ filePath,
683
+ sourcemap: null,
684
+ });
685
+
686
+ if (!result) continue;
687
+
688
+ args.cssCache.setFileCss({
689
+ filePath,
690
+ contentHash: createFileCssContentHash(code),
691
+ configHash: args.configHash,
692
+ rules: result.rules,
693
+ });
694
+ }
695
+ }
696
+
697
+ function getCompilationSourceFiles(
698
+ compilation: Compilation,
699
+ projectDir: string,
700
+ filter: NextLoaderState['filter'],
701
+ ) {
702
+ const files = new Set<string>();
703
+ const dependencies = compilation.fileDependencies ?? new Set<string>();
704
+
705
+ for (const filePath of dependencies) {
706
+ if (!isProjectSourceFile(filePath, projectDir, filter)) continue;
707
+ files.add(path.normalize(filePath));
708
+ }
709
+
710
+ return [...files].sort();
711
+ }
712
+
713
+ function isProjectSourceFile(
714
+ filePath: string,
715
+ projectDir: string,
716
+ filter: NextLoaderState['filter'],
717
+ ) {
718
+ if (!path.isAbsolute(filePath)) return false;
719
+ if (!filePath.startsWith(projectDir + path.sep)) return false;
720
+ if (filePath.includes(`${path.sep}.next${path.sep}`)) return false;
721
+ if (filePath.includes(`${path.sep}.git${path.sep}`)) return false;
722
+ if (!filter(filePath)) return false;
723
+
724
+ return true;
725
+ }
@@ -1,5 +1,4 @@
1
1
  import type { NextConfig } from 'next';
2
- import type { PHASE_TYPE } from 'next/constants';
3
2
  import type { OmitProps } from '../../utils/type';
4
3
  import type { PluginOptions as BasePluginOptions } from '../utils';
5
4
 
@@ -12,7 +11,7 @@ export type NextConfigContext = {
12
11
  };
13
12
 
14
13
  export type NextConfigFunction = (
15
- phase: PHASE_TYPE,
14
+ phase: string,
16
15
  context: NextConfigContext,
17
16
  ) => MaybePromise<NextConfig>;
18
17
 
@@ -1,10 +1,14 @@
1
1
  import { createHash } from 'node:crypto';
2
+ import fs from 'node:fs';
2
3
  import { createRequire } from 'node:module';
3
4
  import path from 'node:path';
5
+ import { fileURLToPath } from 'node:url';
4
6
  import type { Compilation, Compiler, WebpackPluginInstance } from 'webpack';
5
7
  import type { Compiler as PluginCompiler } from '../../compiler';
8
+ import type { ImportSource } from '../../compiler/utils/import_source';
6
9
  import { normalizePath } from '../../compiler/utils/path';
7
10
  import type { BuildConfig, BuildDevConfig } from '../../config/build';
11
+ import { getStyleFnMeta } from '../../style/style';
8
12
  import { createWebpackRegistry } from '../bundler/webpack/shared/registry';
9
13
  import type { FileCssCache } from '../utils/cache';
10
14
  import type { PluginOptions as BasePluginOptions } from '../utils/compiler';
@@ -69,15 +73,132 @@ export function createNextBuildDevConfig(options: PluginOptions): BuildDevConfig
69
73
  export function createNextConfigHash(
70
74
  buildConfig: BuildConfig,
71
75
  dev: boolean,
76
+ importSources?: readonly ImportSource[] | null,
72
77
  ) {
73
78
  const values = [
79
+ createPackageCacheIdentity(),
74
80
  dev ? 'dev' : 'prod',
75
81
  buildConfig.hoist ? 'hoist' : 'no-hoist',
82
+ JSON.stringify(createSerializableImportSources(importSources)),
76
83
  ];
77
84
 
78
85
  return createHash('sha256').update(values.join('\0')).digest('hex');
79
86
  }
80
87
 
88
+ function createPackageCacheIdentity() {
89
+ const require = createRequire(import.meta.url);
90
+ let entryPath = '';
91
+
92
+ try {
93
+ entryPath = require.resolve('@fluentic/style/plugin/nextjs');
94
+ } catch {
95
+ entryPath = fileURLToPath(import.meta.url);
96
+ }
97
+
98
+ const packageInfo = findPackageInfo(entryPath);
99
+ const parts = [
100
+ packageInfo.version,
101
+ normalizePath(packageInfo.packageRoot),
102
+ normalizePath(entryPath),
103
+ getStatIdentity(packageInfo.packageJsonPath),
104
+ getStatIdentity(entryPath),
105
+ ];
106
+
107
+ return parts.join('\0');
108
+ }
109
+
110
+ function findPackageInfo(entryPath: string) {
111
+ let current = path.dirname(entryPath);
112
+
113
+ while (true) {
114
+ const packageJsonPath = path.join(current, 'package.json');
115
+
116
+ try {
117
+ const pkg = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')) as {
118
+ name?: string;
119
+ version?: string;
120
+ };
121
+
122
+ if (pkg.name === '@fluentic/style') {
123
+ return {
124
+ packageRoot: current,
125
+ packageJsonPath,
126
+ version: pkg.version ?? '',
127
+ };
128
+ }
129
+ } catch {
130
+ // Keep walking toward the filesystem root.
131
+ }
132
+
133
+ const parent = path.dirname(current);
134
+ if (parent === current) break;
135
+ current = parent;
136
+ }
137
+
138
+ return {
139
+ packageRoot: path.dirname(entryPath),
140
+ packageJsonPath: '',
141
+ version: '',
142
+ };
143
+ }
144
+
145
+ function getStatIdentity(filePath: string) {
146
+ if (!filePath) return '';
147
+
148
+ try {
149
+ const stat = fs.statSync(filePath);
150
+ return `${stat.size}:${stat.mtimeMs}`;
151
+ } catch {
152
+ return '';
153
+ }
154
+ }
155
+
156
+ export function createSerializableImportSources(
157
+ importSources: readonly ImportSource[] | null | undefined,
158
+ ): ImportSource[] | undefined {
159
+ if (!importSources?.length) return undefined;
160
+
161
+ const result: ImportSource[] = [];
162
+
163
+ for (const entry of importSources) {
164
+ if (entry.check) continue;
165
+
166
+ const source = serializeImportSourcePattern(entry.source);
167
+ const name = entry.name;
168
+ const meta = entry.meta ?? (entry.styleFn ? getStyleFnMeta(entry.styleFn) : null);
169
+
170
+ if (!meta) continue;
171
+ if (entry.source !== undefined && source === undefined) continue;
172
+
173
+ result.push(removeUndefinedValues({
174
+ source,
175
+ name,
176
+ meta,
177
+ }));
178
+ }
179
+
180
+ return result.length ? result : undefined;
181
+ }
182
+
183
+ function serializeImportSourcePattern(
184
+ source: ImportSource['source'],
185
+ ): string | string[] | undefined {
186
+ if (source === undefined) return undefined;
187
+
188
+ if (Array.isArray(source)) {
189
+ const result: string[] = [];
190
+
191
+ for (const item of source) {
192
+ if (typeof item !== 'string') return undefined;
193
+ result.push(item);
194
+ }
195
+
196
+ return result;
197
+ }
198
+
199
+ return typeof source === 'string' ? source : undefined;
200
+ }
201
+
81
202
  export function resolveNextCompilerOptions(
82
203
  options: PluginOptions,
83
204
  sidecar: SourcemapSidecar | null,
@@ -7,6 +7,8 @@ import { createTransformFilter, normalizeModuleId, type TransformFilterOptions }
7
7
  import type { BundlerSourceMap } from './sourcemap';
8
8
 
9
9
  export type PluginCssOptions = CompilerCssOptions;
10
+ export { CssPropPresets } from '../../compiler';
11
+ export type { CompilerCssPropOptions } from '../../compiler';
10
12
 
11
13
  export type PluginOptions = CompilerOptions & TransformFilterOptions & {
12
14
  cacheDir?: string;
@@ -10,12 +10,13 @@ export function getStyleRuntimeMode(dev: boolean, rsc = false): CompilerRuntimeM
10
10
  return dev ? CompilerRuntimeMode.Dev : CompilerRuntimeMode.Prod;
11
11
  }
12
12
 
13
- export function getPluginBuildConfig(options: PluginOptions): BuildConfig {
13
+ export function getPluginBuildConfig(options: PluginOptions, dev = false): BuildConfig {
14
14
  const css: CompilerCssOptions = hasBuildConfig(options.css) ? options.css! : {};
15
15
 
16
16
  return {
17
- hoist: options.hoist !== false,
17
+ hoist: !dev && options.hoist !== false,
18
18
  css,
19
+ check: options.check,
19
20
  };
20
21
  }
21
22
 
@@ -55,3 +56,15 @@ export function getStyleEntryDefines(
55
56
 
56
57
  return defines;
57
58
  }
59
+
60
+ export function createStyleEntryGlobalSource(
61
+ buildConfig: BuildConfig,
62
+ buildDevConfig: BuildDevConfig | null,
63
+ sidecarUrl: string | null,
64
+ ) {
65
+ const defines = getStyleEntryDefines(buildConfig, buildDevConfig, sidecarUrl, false);
66
+
67
+ return Object.entries(defines)
68
+ .map(([key, value]) => `globalThis[${JSON.stringify(key)}] = ${JSON.stringify(value)};`)
69
+ .join('\n');
70
+ }
@@ -0,0 +1,2 @@
1
+ export * from './transform';
2
+ export type * from './types';