zyzz 0.0.0 → 0.0.3

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 (683) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +380 -0
  3. package/dist/Config.d.ts +170 -0
  4. package/dist/Config.d.ts.map +1 -0
  5. package/dist/Config.js +249 -0
  6. package/dist/Config.js.map +1 -0
  7. package/dist/Props.d.ts +7 -0
  8. package/dist/Props.d.ts.map +1 -0
  9. package/dist/Props.js +3 -0
  10. package/dist/Props.js.map +1 -0
  11. package/dist/Style.d.ts +170 -0
  12. package/dist/Style.d.ts.map +1 -0
  13. package/dist/Style.js +325 -0
  14. package/dist/Style.js.map +1 -0
  15. package/dist/Theme.d.ts +157 -0
  16. package/dist/Theme.d.ts.map +1 -0
  17. package/dist/Theme.js +273 -0
  18. package/dist/Theme.js.map +1 -0
  19. package/dist/babel/NativeEdits.d.ts +8 -0
  20. package/dist/babel/NativeEdits.d.ts.map +1 -0
  21. package/dist/babel/NativeEdits.js +233 -0
  22. package/dist/babel/NativeEdits.js.map +1 -0
  23. package/dist/babel/NativeJsx.d.ts +10 -0
  24. package/dist/babel/NativeJsx.d.ts.map +1 -0
  25. package/dist/babel/NativeJsx.js +204 -0
  26. package/dist/babel/NativeJsx.js.map +1 -0
  27. package/dist/babel/index.d.ts +51 -0
  28. package/dist/babel/index.d.ts.map +1 -0
  29. package/dist/babel/index.js +220 -0
  30. package/dist/babel/index.js.map +1 -0
  31. package/dist/cli/index.d.ts +3 -0
  32. package/dist/cli/index.d.ts.map +1 -0
  33. package/dist/cli/index.js +178 -0
  34. package/dist/cli/index.js.map +1 -0
  35. package/dist/compiler/Graph.d.ts +64 -0
  36. package/dist/compiler/Graph.d.ts.map +1 -0
  37. package/dist/compiler/Graph.js +1111 -0
  38. package/dist/compiler/Graph.js.map +1 -0
  39. package/dist/compiler/Native.d.ts +53 -0
  40. package/dist/compiler/Native.d.ts.map +1 -0
  41. package/dist/compiler/Native.js +617 -0
  42. package/dist/compiler/Native.js.map +1 -0
  43. package/dist/compiler/Source.d.ts +167 -0
  44. package/dist/compiler/Source.d.ts.map +1 -0
  45. package/dist/compiler/Source.js +1012 -0
  46. package/dist/compiler/Source.js.map +1 -0
  47. package/dist/compiler/Transform.d.ts +57 -0
  48. package/dist/compiler/Transform.d.ts.map +1 -0
  49. package/dist/compiler/Transform.js +886 -0
  50. package/dist/compiler/Transform.js.map +1 -0
  51. package/dist/compiler/index.d.ts +13 -0
  52. package/dist/compiler/index.d.ts.map +1 -0
  53. package/dist/compiler/index.js +13 -0
  54. package/dist/compiler/index.js.map +1 -0
  55. package/dist/compiler/internal/Applications.d.ts +35 -0
  56. package/dist/compiler/internal/Applications.d.ts.map +1 -0
  57. package/dist/compiler/internal/Applications.js +248 -0
  58. package/dist/compiler/internal/Applications.js.map +1 -0
  59. package/dist/compiler/internal/AtRules.d.ts +8 -0
  60. package/dist/compiler/internal/AtRules.d.ts.map +1 -0
  61. package/dist/compiler/internal/AtRules.js +180 -0
  62. package/dist/compiler/internal/AtRules.js.map +1 -0
  63. package/dist/compiler/internal/Catalogs.d.ts +19 -0
  64. package/dist/compiler/internal/Catalogs.d.ts.map +1 -0
  65. package/dist/compiler/internal/Catalogs.js +68 -0
  66. package/dist/compiler/internal/Catalogs.js.map +1 -0
  67. package/dist/compiler/internal/ColorProfiles.d.ts +3 -0
  68. package/dist/compiler/internal/ColorProfiles.d.ts.map +1 -0
  69. package/dist/compiler/internal/ColorProfiles.js +84 -0
  70. package/dist/compiler/internal/ColorProfiles.js.map +1 -0
  71. package/dist/compiler/internal/CompositionBindings.d.ts +16 -0
  72. package/dist/compiler/internal/CompositionBindings.d.ts.map +1 -0
  73. package/dist/compiler/internal/CompositionBindings.js +89 -0
  74. package/dist/compiler/internal/CompositionBindings.js.map +1 -0
  75. package/dist/compiler/internal/Compositions.d.ts +32 -0
  76. package/dist/compiler/internal/Compositions.d.ts.map +1 -0
  77. package/dist/compiler/internal/Compositions.js +464 -0
  78. package/dist/compiler/internal/Compositions.js.map +1 -0
  79. package/dist/compiler/internal/Configurations.d.ts +21 -0
  80. package/dist/compiler/internal/Configurations.d.ts.map +1 -0
  81. package/dist/compiler/internal/Configurations.js +171 -0
  82. package/dist/compiler/internal/Configurations.js.map +1 -0
  83. package/dist/compiler/internal/Contract.d.ts +27 -0
  84. package/dist/compiler/internal/Contract.d.ts.map +1 -0
  85. package/dist/compiler/internal/Contract.js +607 -0
  86. package/dist/compiler/internal/Contract.js.map +1 -0
  87. package/dist/compiler/internal/Contributions.d.ts +54 -0
  88. package/dist/compiler/internal/Contributions.d.ts.map +1 -0
  89. package/dist/compiler/internal/Contributions.js +1109 -0
  90. package/dist/compiler/internal/Contributions.js.map +1 -0
  91. package/dist/compiler/internal/Descriptors.d.ts +15 -0
  92. package/dist/compiler/internal/Descriptors.d.ts.map +1 -0
  93. package/dist/compiler/internal/Descriptors.js +183 -0
  94. package/dist/compiler/internal/Descriptors.js.map +1 -0
  95. package/dist/compiler/internal/Dynamic.d.ts +14 -0
  96. package/dist/compiler/internal/Dynamic.d.ts.map +1 -0
  97. package/dist/compiler/internal/Dynamic.js +172 -0
  98. package/dist/compiler/internal/Dynamic.js.map +1 -0
  99. package/dist/compiler/internal/Edits.d.ts +12 -0
  100. package/dist/compiler/internal/Edits.d.ts.map +1 -0
  101. package/dist/compiler/internal/Edits.js +5 -0
  102. package/dist/compiler/internal/Edits.js.map +1 -0
  103. package/dist/compiler/internal/Expression.d.ts +12 -0
  104. package/dist/compiler/internal/Expression.d.ts.map +1 -0
  105. package/dist/compiler/internal/Expression.js +98 -0
  106. package/dist/compiler/internal/Expression.js.map +1 -0
  107. package/dist/compiler/internal/Functions.d.ts +5 -0
  108. package/dist/compiler/internal/Functions.d.ts.map +1 -0
  109. package/dist/compiler/internal/Functions.js +191 -0
  110. package/dist/compiler/internal/Functions.js.map +1 -0
  111. package/dist/compiler/internal/Identifiers.d.ts +9 -0
  112. package/dist/compiler/internal/Identifiers.d.ts.map +1 -0
  113. package/dist/compiler/internal/Identifiers.js +106 -0
  114. package/dist/compiler/internal/Identifiers.js.map +1 -0
  115. package/dist/compiler/internal/Keyframes.d.ts +5 -0
  116. package/dist/compiler/internal/Keyframes.d.ts.map +1 -0
  117. package/dist/compiler/internal/Keyframes.js +51 -0
  118. package/dist/compiler/internal/Keyframes.js.map +1 -0
  119. package/dist/compiler/internal/Namespaces.d.ts +17 -0
  120. package/dist/compiler/internal/Namespaces.d.ts.map +1 -0
  121. package/dist/compiler/internal/Namespaces.js +265 -0
  122. package/dist/compiler/internal/Namespaces.js.map +1 -0
  123. package/dist/compiler/internal/NativeBindings.d.ts +74 -0
  124. package/dist/compiler/internal/NativeBindings.d.ts.map +1 -0
  125. package/dist/compiler/internal/NativeBindings.js +117 -0
  126. package/dist/compiler/internal/NativeBindings.js.map +1 -0
  127. package/dist/compiler/internal/PackedStyles.d.ts +35 -0
  128. package/dist/compiler/internal/PackedStyles.d.ts.map +1 -0
  129. package/dist/compiler/internal/PackedStyles.js +345 -0
  130. package/dist/compiler/internal/PackedStyles.js.map +1 -0
  131. package/dist/compiler/internal/Properties.d.ts +5 -0
  132. package/dist/compiler/internal/Properties.d.ts.map +1 -0
  133. package/dist/compiler/internal/Properties.js +82 -0
  134. package/dist/compiler/internal/Properties.js.map +1 -0
  135. package/dist/compiler/internal/RecipeConditions.d.ts +41 -0
  136. package/dist/compiler/internal/RecipeConditions.d.ts.map +1 -0
  137. package/dist/compiler/internal/RecipeConditions.js +82 -0
  138. package/dist/compiler/internal/RecipeConditions.js.map +1 -0
  139. package/dist/compiler/internal/RecipePayloads.d.ts +31 -0
  140. package/dist/compiler/internal/RecipePayloads.d.ts.map +1 -0
  141. package/dist/compiler/internal/RecipePayloads.js +99 -0
  142. package/dist/compiler/internal/RecipePayloads.js.map +1 -0
  143. package/dist/compiler/internal/Recipes.d.ts +32 -0
  144. package/dist/compiler/internal/Recipes.d.ts.map +1 -0
  145. package/dist/compiler/internal/Recipes.js +339 -0
  146. package/dist/compiler/internal/Recipes.js.map +1 -0
  147. package/dist/compiler/internal/Relative.d.ts +19 -0
  148. package/dist/compiler/internal/Relative.d.ts.map +1 -0
  149. package/dist/compiler/internal/Relative.js +62 -0
  150. package/dist/compiler/internal/Relative.js.map +1 -0
  151. package/dist/compiler/internal/Scope.d.ts +10 -0
  152. package/dist/compiler/internal/Scope.d.ts.map +1 -0
  153. package/dist/compiler/internal/Scope.js +28 -0
  154. package/dist/compiler/internal/Scope.js.map +1 -0
  155. package/dist/compiler/internal/Selectors.d.ts +12 -0
  156. package/dist/compiler/internal/Selectors.d.ts.map +1 -0
  157. package/dist/compiler/internal/Selectors.js +265 -0
  158. package/dist/compiler/internal/Selectors.js.map +1 -0
  159. package/dist/compiler/internal/Static.d.ts +39 -0
  160. package/dist/compiler/internal/Static.d.ts.map +1 -0
  161. package/dist/compiler/internal/Static.js +532 -0
  162. package/dist/compiler/internal/Static.js.map +1 -0
  163. package/dist/compiler/internal/Stylesheets.d.ts +47 -0
  164. package/dist/compiler/internal/Stylesheets.d.ts.map +1 -0
  165. package/dist/compiler/internal/Stylesheets.js +272 -0
  166. package/dist/compiler/internal/Stylesheets.js.map +1 -0
  167. package/dist/compiler/internal/Syntax.d.ts +17 -0
  168. package/dist/compiler/internal/Syntax.d.ts.map +1 -0
  169. package/dist/compiler/internal/Syntax.js +19 -0
  170. package/dist/compiler/internal/Syntax.js.map +1 -0
  171. package/dist/compiler/internal/Themes.d.ts +158 -0
  172. package/dist/compiler/internal/Themes.d.ts.map +1 -0
  173. package/dist/compiler/internal/Themes.js +1169 -0
  174. package/dist/compiler/internal/Themes.js.map +1 -0
  175. package/dist/compiler/internal/Variables.d.ts +31 -0
  176. package/dist/compiler/internal/Variables.d.ts.map +1 -0
  177. package/dist/compiler/internal/Variables.js +376 -0
  178. package/dist/compiler/internal/Variables.js.map +1 -0
  179. package/dist/compiler/internal/ViewTransitions.d.ts +3 -0
  180. package/dist/compiler/internal/ViewTransitions.d.ts.map +1 -0
  181. package/dist/compiler/internal/ViewTransitions.js +68 -0
  182. package/dist/compiler/internal/ViewTransitions.js.map +1 -0
  183. package/dist/cx.d.ts +18 -0
  184. package/dist/cx.d.ts.map +1 -0
  185. package/dist/cx.js +60 -0
  186. package/dist/cx.js.map +1 -0
  187. package/dist/default.d.ts +3225 -0
  188. package/dist/default.d.ts.map +1 -0
  189. package/dist/default.js +547 -0
  190. package/dist/default.js.map +7 -0
  191. package/dist/default.js.zyzz.json +1 -0
  192. package/dist/index.d.ts +21 -0
  193. package/dist/index.d.ts.map +1 -0
  194. package/dist/index.js +19 -0
  195. package/dist/index.js.map +1 -0
  196. package/dist/internal/Authoring.d.ts +26 -0
  197. package/dist/internal/Authoring.d.ts.map +1 -0
  198. package/dist/internal/Authoring.js +134 -0
  199. package/dist/internal/Authoring.js.map +1 -0
  200. package/dist/internal/Binding.d.ts +64 -0
  201. package/dist/internal/Binding.d.ts.map +1 -0
  202. package/dist/internal/Binding.js +27 -0
  203. package/dist/internal/Binding.js.map +1 -0
  204. package/dist/internal/BindingDomains.d.ts +11 -0
  205. package/dist/internal/BindingDomains.d.ts.map +1 -0
  206. package/dist/internal/BindingDomains.js +459 -0
  207. package/dist/internal/BindingDomains.js.map +1 -0
  208. package/dist/internal/Cascade.d.ts +45 -0
  209. package/dist/internal/Cascade.d.ts.map +1 -0
  210. package/dist/internal/Cascade.js +165 -0
  211. package/dist/internal/Cascade.js.map +1 -0
  212. package/dist/internal/Compound.d.ts +132 -0
  213. package/dist/internal/Compound.d.ts.map +1 -0
  214. package/dist/internal/Compound.js +2 -0
  215. package/dist/internal/Compound.js.map +1 -0
  216. package/dist/internal/Condition.d.ts +33 -0
  217. package/dist/internal/Condition.d.ts.map +1 -0
  218. package/dist/internal/Condition.js +180 -0
  219. package/dist/internal/Condition.js.map +1 -0
  220. package/dist/internal/Corner.d.ts +9 -0
  221. package/dist/internal/Corner.d.ts.map +1 -0
  222. package/dist/internal/Corner.js +14 -0
  223. package/dist/internal/Corner.js.map +1 -0
  224. package/dist/internal/FunctionSyntax.d.ts +27 -0
  225. package/dist/internal/FunctionSyntax.d.ts.map +1 -0
  226. package/dist/internal/FunctionSyntax.js +91 -0
  227. package/dist/internal/FunctionSyntax.js.map +1 -0
  228. package/dist/internal/FunctionValue.d.ts +19 -0
  229. package/dist/internal/FunctionValue.d.ts.map +1 -0
  230. package/dist/internal/FunctionValue.js +2 -0
  231. package/dist/internal/FunctionValue.js.map +1 -0
  232. package/dist/internal/Geometry.d.ts +8 -0
  233. package/dist/internal/Geometry.d.ts.map +1 -0
  234. package/dist/internal/Geometry.js +2 -0
  235. package/dist/internal/Geometry.js.map +1 -0
  236. package/dist/internal/Grid.d.ts +15 -0
  237. package/dist/internal/Grid.d.ts.map +1 -0
  238. package/dist/internal/Grid.js +2 -0
  239. package/dist/internal/Grid.js.map +1 -0
  240. package/dist/internal/Identifier.d.ts +15 -0
  241. package/dist/internal/Identifier.d.ts.map +1 -0
  242. package/dist/internal/Identifier.js +2 -0
  243. package/dist/internal/Identifier.js.map +1 -0
  244. package/dist/internal/Identity.d.ts +16 -0
  245. package/dist/internal/Identity.d.ts.map +1 -0
  246. package/dist/internal/Identity.js +78 -0
  247. package/dist/internal/Identity.js.map +1 -0
  248. package/dist/internal/Lexical.d.ts +89 -0
  249. package/dist/internal/Lexical.d.ts.map +1 -0
  250. package/dist/internal/Lexical.js +15 -0
  251. package/dist/internal/Lexical.js.map +1 -0
  252. package/dist/internal/Literal.d.ts +3459 -0
  253. package/dist/internal/Literal.d.ts.map +1 -0
  254. package/dist/internal/Literal.js +3371 -0
  255. package/dist/internal/Literal.js.map +1 -0
  256. package/dist/internal/NativeProperties.d.ts +596 -0
  257. package/dist/internal/NativeProperties.d.ts.map +1 -0
  258. package/dist/internal/NativeProperties.js +2 -0
  259. package/dist/internal/NativeProperties.js.map +1 -0
  260. package/dist/internal/Numeric.d.ts +23 -0
  261. package/dist/internal/Numeric.d.ts.map +1 -0
  262. package/dist/internal/Numeric.js +2 -0
  263. package/dist/internal/Numeric.js.map +1 -0
  264. package/dist/internal/Query.d.ts +15 -0
  265. package/dist/internal/Query.d.ts.map +1 -0
  266. package/dist/internal/Query.js +58 -0
  267. package/dist/internal/Query.js.map +1 -0
  268. package/dist/internal/Recipe.d.ts +17 -0
  269. package/dist/internal/Recipe.d.ts.map +1 -0
  270. package/dist/internal/Recipe.js +2 -0
  271. package/dist/internal/Recipe.js.map +1 -0
  272. package/dist/internal/RuleReference.d.ts +23 -0
  273. package/dist/internal/RuleReference.d.ts.map +1 -0
  274. package/dist/internal/RuleReference.js +65 -0
  275. package/dist/internal/RuleReference.js.map +1 -0
  276. package/dist/internal/Scheme.d.ts +12 -0
  277. package/dist/internal/Scheme.d.ts.map +1 -0
  278. package/dist/internal/Scheme.js +16 -0
  279. package/dist/internal/Scheme.js.map +1 -0
  280. package/dist/internal/Shorthands.d.ts +20 -0
  281. package/dist/internal/Shorthands.d.ts.map +1 -0
  282. package/dist/internal/Shorthands.js +50 -0
  283. package/dist/internal/Shorthands.js.map +1 -0
  284. package/dist/internal/Targets.d.ts +43 -0
  285. package/dist/internal/Targets.d.ts.map +1 -0
  286. package/dist/internal/Targets.js +60 -0
  287. package/dist/internal/Targets.js.map +1 -0
  288. package/dist/internal/Token.d.ts +104 -0
  289. package/dist/internal/Token.d.ts.map +1 -0
  290. package/dist/internal/Token.js +162 -0
  291. package/dist/internal/Token.js.map +1 -0
  292. package/dist/internal/Tuple.d.ts +23 -0
  293. package/dist/internal/Tuple.d.ts.map +1 -0
  294. package/dist/internal/Tuple.js +2 -0
  295. package/dist/internal/Tuple.js.map +1 -0
  296. package/dist/internal/Typography.d.ts +23 -0
  297. package/dist/internal/Typography.d.ts.map +1 -0
  298. package/dist/internal/Typography.js +18 -0
  299. package/dist/internal/Typography.js.map +1 -0
  300. package/dist/internal/Value.d.ts +74 -0
  301. package/dist/internal/Value.d.ts.map +1 -0
  302. package/dist/internal/Value.js +60 -0
  303. package/dist/internal/Value.js.map +1 -0
  304. package/dist/metro/Graph.d.ts +8 -0
  305. package/dist/metro/Graph.d.ts.map +1 -0
  306. package/dist/metro/Graph.js +63 -0
  307. package/dist/metro/Graph.js.map +1 -0
  308. package/dist/metro/Watch.d.ts +21 -0
  309. package/dist/metro/Watch.d.ts.map +1 -0
  310. package/dist/metro/Watch.js +51 -0
  311. package/dist/metro/Watch.js.map +1 -0
  312. package/dist/metro/index.d.ts +30 -0
  313. package/dist/metro/index.d.ts.map +1 -0
  314. package/dist/metro/index.js +52 -0
  315. package/dist/metro/index.js.map +1 -0
  316. package/dist/metro/transformer.d.ts +21 -0
  317. package/dist/metro/transformer.d.ts.map +1 -0
  318. package/dist/metro/transformer.js +71 -0
  319. package/dist/metro/transformer.js.map +1 -0
  320. package/dist/next/index.d.ts +18 -0
  321. package/dist/next/index.d.ts.map +1 -0
  322. package/dist/next/index.js +92 -0
  323. package/dist/next/index.js.map +1 -0
  324. package/dist/next/loader.d.ts +16 -0
  325. package/dist/next/loader.d.ts.map +1 -0
  326. package/dist/next/loader.js +282 -0
  327. package/dist/next/loader.js.map +1 -0
  328. package/dist/node/Host.d.ts +80 -0
  329. package/dist/node/Host.d.ts.map +1 -0
  330. package/dist/node/Host.js +882 -0
  331. package/dist/node/Host.js.map +1 -0
  332. package/dist/node/index.d.ts +7 -0
  333. package/dist/node/index.d.ts.map +1 -0
  334. package/dist/node/index.js +7 -0
  335. package/dist/node/index.js.map +1 -0
  336. package/dist/react-native/Host.d.ts +76 -0
  337. package/dist/react-native/Host.d.ts.map +1 -0
  338. package/dist/react-native/Host.js +209 -0
  339. package/dist/react-native/Host.js.map +1 -0
  340. package/dist/react-native/StyleSheet.d.ts +226 -0
  341. package/dist/react-native/StyleSheet.d.ts.map +1 -0
  342. package/dist/react-native/StyleSheet.js +606 -0
  343. package/dist/react-native/StyleSheet.js.map +1 -0
  344. package/dist/react-native/Variants.d.ts +38 -0
  345. package/dist/react-native/Variants.d.ts.map +1 -0
  346. package/dist/react-native/Variants.js +66 -0
  347. package/dist/react-native/Variants.js.map +1 -0
  348. package/dist/react-native/index.d.ts +8 -0
  349. package/dist/react-native/index.d.ts.map +1 -0
  350. package/dist/react-native/index.js +8 -0
  351. package/dist/react-native/index.js.map +1 -0
  352. package/dist/react-native/internal/Color.d.ts +7 -0
  353. package/dist/react-native/internal/Color.d.ts.map +1 -0
  354. package/dist/react-native/internal/Color.js +93 -0
  355. package/dist/react-native/internal/Color.js.map +1 -0
  356. package/dist/react-native/internal/NativeSchema.d.ts +5138 -0
  357. package/dist/react-native/internal/NativeSchema.d.ts.map +1 -0
  358. package/dist/react-native/internal/NativeSchema.js +3097 -0
  359. package/dist/react-native/internal/NativeSchema.js.map +1 -0
  360. package/dist/react-native/internal/Scalar.d.ts +95 -0
  361. package/dist/react-native/internal/Scalar.d.ts.map +1 -0
  362. package/dist/react-native/internal/Scalar.js +199 -0
  363. package/dist/react-native/internal/Scalar.js.map +1 -0
  364. package/dist/react-native/internal/Values.d.ts +5 -0
  365. package/dist/react-native/internal/Values.d.ts.map +1 -0
  366. package/dist/react-native/internal/Values.js +65 -0
  367. package/dist/react-native/internal/Values.js.map +1 -0
  368. package/dist/react-native/react.d.ts +22 -0
  369. package/dist/react-native/react.d.ts.map +1 -0
  370. package/dist/react-native/react.js +26 -0
  371. package/dist/react-native/react.js.map +1 -0
  372. package/dist/reset.css +244 -0
  373. package/dist/runtime/Appearance.d.ts +55 -0
  374. package/dist/runtime/Appearance.d.ts.map +1 -0
  375. package/dist/runtime/Appearance.js +84 -0
  376. package/dist/runtime/Appearance.js.map +1 -0
  377. package/dist/runtime/Composition.d.ts +46 -0
  378. package/dist/runtime/Composition.d.ts.map +1 -0
  379. package/dist/runtime/Composition.js +52 -0
  380. package/dist/runtime/Composition.js.map +1 -0
  381. package/dist/runtime/CompositionHtml.d.ts +15 -0
  382. package/dist/runtime/CompositionHtml.d.ts.map +1 -0
  383. package/dist/runtime/CompositionHtml.js +20 -0
  384. package/dist/runtime/CompositionHtml.js.map +1 -0
  385. package/dist/runtime/ConditionalRecipe.d.ts +30 -0
  386. package/dist/runtime/ConditionalRecipe.d.ts.map +1 -0
  387. package/dist/runtime/ConditionalRecipe.js +39 -0
  388. package/dist/runtime/ConditionalRecipe.js.map +1 -0
  389. package/dist/runtime/Dynamic.d.ts +19 -0
  390. package/dist/runtime/Dynamic.d.ts.map +1 -0
  391. package/dist/runtime/Dynamic.js +22 -0
  392. package/dist/runtime/Dynamic.js.map +1 -0
  393. package/dist/runtime/Html.d.ts +32 -0
  394. package/dist/runtime/Html.d.ts.map +1 -0
  395. package/dist/runtime/Html.js +63 -0
  396. package/dist/runtime/Html.js.map +1 -0
  397. package/dist/runtime/Native.d.ts +48 -0
  398. package/dist/runtime/Native.d.ts.map +1 -0
  399. package/dist/runtime/Native.js +78 -0
  400. package/dist/runtime/Native.js.map +1 -0
  401. package/dist/runtime/NativeContext.d.ts +17 -0
  402. package/dist/runtime/NativeContext.d.ts.map +1 -0
  403. package/dist/runtime/NativeContext.js +47 -0
  404. package/dist/runtime/NativeContext.js.map +1 -0
  405. package/dist/runtime/NativeDynamic.d.ts +47 -0
  406. package/dist/runtime/NativeDynamic.d.ts.map +1 -0
  407. package/dist/runtime/NativeDynamic.js +141 -0
  408. package/dist/runtime/NativeDynamic.js.map +1 -0
  409. package/dist/runtime/PayloadRecipe.d.ts +22 -0
  410. package/dist/runtime/PayloadRecipe.d.ts.map +1 -0
  411. package/dist/runtime/PayloadRecipe.js +59 -0
  412. package/dist/runtime/PayloadRecipe.js.map +1 -0
  413. package/dist/runtime/Props.d.ts +21 -0
  414. package/dist/runtime/Props.d.ts.map +1 -0
  415. package/dist/runtime/Props.js +17 -0
  416. package/dist/runtime/Props.js.map +1 -0
  417. package/dist/runtime/Recipe.d.ts +52 -0
  418. package/dist/runtime/Recipe.d.ts.map +1 -0
  419. package/dist/runtime/Recipe.js +30 -0
  420. package/dist/runtime/Recipe.js.map +1 -0
  421. package/dist/runtime/Selection.d.ts +31 -0
  422. package/dist/runtime/Selection.d.ts.map +1 -0
  423. package/dist/runtime/Selection.js +30 -0
  424. package/dist/runtime/Selection.js.map +1 -0
  425. package/dist/runtime/Variable.d.ts +6 -0
  426. package/dist/runtime/Variable.d.ts.map +1 -0
  427. package/dist/runtime/Variable.js +10 -0
  428. package/dist/runtime/Variable.js.map +1 -0
  429. package/dist/runtime/index.d.ts +33 -0
  430. package/dist/runtime/index.d.ts.map +1 -0
  431. package/dist/runtime/index.js +33 -0
  432. package/dist/runtime/index.js.map +1 -0
  433. package/dist/styleFunction.d.ts +72 -0
  434. package/dist/styleFunction.d.ts.map +1 -0
  435. package/dist/styleFunction.js +18 -0
  436. package/dist/styleFunction.js.map +1 -0
  437. package/dist/themes/LICENSE.tailwind +21 -0
  438. package/dist/variable.d.ts +50 -0
  439. package/dist/variable.d.ts.map +1 -0
  440. package/dist/variable.js +20 -0
  441. package/dist/variable.js.map +1 -0
  442. package/dist/variants.d.ts +84 -0
  443. package/dist/variants.d.ts.map +1 -0
  444. package/dist/variants.js +21 -0
  445. package/dist/variants.js.map +1 -0
  446. package/dist/vite/index.d.ts +24 -0
  447. package/dist/vite/index.d.ts.map +1 -0
  448. package/dist/vite/index.js +1089 -0
  449. package/dist/vite/index.js.map +1 -0
  450. package/dist/web/Css.d.ts +81 -0
  451. package/dist/web/Css.d.ts.map +1 -0
  452. package/dist/web/Css.js +593 -0
  453. package/dist/web/Css.js.map +1 -0
  454. package/dist/web/colorProfile.d.ts +28 -0
  455. package/dist/web/colorProfile.d.ts.map +1 -0
  456. package/dist/web/colorProfile.js +8 -0
  457. package/dist/web/colorProfile.js.map +1 -0
  458. package/dist/web/counterStyle.d.ts +48 -0
  459. package/dist/web/counterStyle.d.ts.map +1 -0
  460. package/dist/web/counterStyle.js +8 -0
  461. package/dist/web/counterStyle.js.map +1 -0
  462. package/dist/web/cssFunction.d.ts +80 -0
  463. package/dist/web/cssFunction.d.ts.map +1 -0
  464. package/dist/web/cssFunction.js +18 -0
  465. package/dist/web/cssFunction.js.map +1 -0
  466. package/dist/web/customMedia.d.ts +12 -0
  467. package/dist/web/customMedia.d.ts.map +1 -0
  468. package/dist/web/customMedia.js +7 -0
  469. package/dist/web/customMedia.js.map +1 -0
  470. package/dist/web/fontFace.d.ts +26 -0
  471. package/dist/web/fontFace.d.ts.map +1 -0
  472. package/dist/web/fontFace.js +7 -0
  473. package/dist/web/fontFace.js.map +1 -0
  474. package/dist/web/fontFeatureValues.d.ts +40 -0
  475. package/dist/web/fontFeatureValues.d.ts.map +1 -0
  476. package/dist/web/fontFeatureValues.js +7 -0
  477. package/dist/web/fontFeatureValues.js.map +1 -0
  478. package/dist/web/fontPaletteValues.d.ts +21 -0
  479. package/dist/web/fontPaletteValues.d.ts.map +1 -0
  480. package/dist/web/fontPaletteValues.js +9 -0
  481. package/dist/web/fontPaletteValues.js.map +1 -0
  482. package/dist/web/global.d.ts +19 -0
  483. package/dist/web/global.d.ts.map +1 -0
  484. package/dist/web/global.js +6 -0
  485. package/dist/web/global.js.map +1 -0
  486. package/dist/web/importCss.d.ts +18 -0
  487. package/dist/web/importCss.d.ts.map +1 -0
  488. package/dist/web/importCss.js +7 -0
  489. package/dist/web/importCss.js.map +1 -0
  490. package/dist/web/index.d.ts +22 -0
  491. package/dist/web/index.d.ts.map +1 -0
  492. package/dist/web/index.js +22 -0
  493. package/dist/web/index.js.map +1 -0
  494. package/dist/web/internal/Block.d.ts +18 -0
  495. package/dist/web/internal/Block.d.ts.map +1 -0
  496. package/dist/web/internal/Block.js +13 -0
  497. package/dist/web/internal/Block.js.map +1 -0
  498. package/dist/web/internal/ClassName.d.ts +19 -0
  499. package/dist/web/internal/ClassName.d.ts.map +1 -0
  500. package/dist/web/internal/ClassName.js +77 -0
  501. package/dist/web/internal/ClassName.js.map +1 -0
  502. package/dist/web/internal/Context.d.ts +11 -0
  503. package/dist/web/internal/Context.d.ts.map +1 -0
  504. package/dist/web/internal/Context.js +2 -0
  505. package/dist/web/internal/Context.js.map +1 -0
  506. package/dist/web/internal/Contributions.d.ts +70 -0
  507. package/dist/web/internal/Contributions.d.ts.map +1 -0
  508. package/dist/web/internal/Contributions.js +109 -0
  509. package/dist/web/internal/Contributions.js.map +1 -0
  510. package/dist/web/internal/Namespace.d.ts +13 -0
  511. package/dist/web/internal/Namespace.d.ts.map +1 -0
  512. package/dist/web/internal/Namespace.js +13 -0
  513. package/dist/web/internal/Namespace.js.map +1 -0
  514. package/dist/web/internal/Themes.d.ts +13 -0
  515. package/dist/web/internal/Themes.d.ts.map +1 -0
  516. package/dist/web/internal/Themes.js +96 -0
  517. package/dist/web/internal/Themes.js.map +1 -0
  518. package/dist/web/keyframes.d.ts +14 -0
  519. package/dist/web/keyframes.d.ts.map +1 -0
  520. package/dist/web/keyframes.js +8 -0
  521. package/dist/web/keyframes.js.map +1 -0
  522. package/dist/web/layers.d.ts +4 -0
  523. package/dist/web/layers.d.ts.map +1 -0
  524. package/dist/web/layers.js +7 -0
  525. package/dist/web/layers.js.map +1 -0
  526. package/dist/web/namespace.d.ts +14 -0
  527. package/dist/web/namespace.d.ts.map +1 -0
  528. package/dist/web/namespace.js +7 -0
  529. package/dist/web/namespace.js.map +1 -0
  530. package/dist/web/page.d.ts +38 -0
  531. package/dist/web/page.d.ts.map +1 -0
  532. package/dist/web/page.js +7 -0
  533. package/dist/web/page.js.map +1 -0
  534. package/dist/web/positionTry.d.ts +14 -0
  535. package/dist/web/positionTry.d.ts.map +1 -0
  536. package/dist/web/positionTry.js +9 -0
  537. package/dist/web/positionTry.js.map +1 -0
  538. package/dist/web/property.d.ts +24 -0
  539. package/dist/web/property.d.ts.map +1 -0
  540. package/dist/web/property.js +7 -0
  541. package/dist/web/property.js.map +1 -0
  542. package/dist/web/viewTransition.d.ts +29 -0
  543. package/dist/web/viewTransition.d.ts.map +1 -0
  544. package/dist/web/viewTransition.js +7 -0
  545. package/dist/web/viewTransition.js.map +1 -0
  546. package/package.json +136 -10
  547. package/src/Config.ts +691 -0
  548. package/src/Props.ts +8 -0
  549. package/src/Style.ts +812 -0
  550. package/src/Theme.ts +784 -0
  551. package/src/babel/NativeEdits.ts +273 -0
  552. package/src/babel/NativeJsx.ts +260 -0
  553. package/src/babel/index.ts +332 -0
  554. package/src/cli/index.ts +196 -0
  555. package/src/compiler/Graph.ts +1586 -0
  556. package/src/compiler/Native.ts +801 -0
  557. package/src/compiler/Source.ts +1579 -0
  558. package/src/compiler/Transform.ts +1241 -0
  559. package/src/compiler/index.ts +12 -0
  560. package/src/compiler/internal/Applications.ts +378 -0
  561. package/src/compiler/internal/AtRules.ts +202 -0
  562. package/src/compiler/internal/Catalogs.ts +114 -0
  563. package/src/compiler/internal/ColorProfiles.ts +93 -0
  564. package/src/compiler/internal/CompositionBindings.ts +120 -0
  565. package/src/compiler/internal/Compositions.ts +629 -0
  566. package/src/compiler/internal/Configurations.ts +244 -0
  567. package/src/compiler/internal/Contract.ts +860 -0
  568. package/src/compiler/internal/Contributions.ts +1507 -0
  569. package/src/compiler/internal/Descriptors.ts +238 -0
  570. package/src/compiler/internal/Dynamic.ts +266 -0
  571. package/src/compiler/internal/Edits.ts +13 -0
  572. package/src/compiler/internal/Expression.ts +135 -0
  573. package/src/compiler/internal/Functions.ts +206 -0
  574. package/src/compiler/internal/Identifiers.ts +124 -0
  575. package/src/compiler/internal/Keyframes.ts +62 -0
  576. package/src/compiler/internal/Namespaces.ts +296 -0
  577. package/src/compiler/internal/NativeBindings.ts +151 -0
  578. package/src/compiler/internal/PackedStyles.ts +464 -0
  579. package/src/compiler/internal/Properties.ts +121 -0
  580. package/src/compiler/internal/RecipeConditions.ts +139 -0
  581. package/src/compiler/internal/RecipePayloads.ts +132 -0
  582. package/src/compiler/internal/Recipes.ts +531 -0
  583. package/src/compiler/internal/Relative.ts +87 -0
  584. package/src/compiler/internal/Scope.ts +36 -0
  585. package/src/compiler/internal/Selectors.ts +334 -0
  586. package/src/compiler/internal/Static.ts +783 -0
  587. package/src/compiler/internal/Stylesheets.ts +361 -0
  588. package/src/compiler/internal/Syntax.ts +31 -0
  589. package/src/compiler/internal/Themes.ts +1794 -0
  590. package/src/compiler/internal/Variables.ts +497 -0
  591. package/src/compiler/internal/ViewTransitions.ts +82 -0
  592. package/src/cx.ts +98 -0
  593. package/src/default.ts +1177 -0
  594. package/src/index.ts +20 -0
  595. package/src/internal/Authoring.ts +199 -0
  596. package/src/internal/Binding.ts +187 -0
  597. package/src/internal/BindingDomains.ts +458 -0
  598. package/src/internal/Cascade.ts +165 -0
  599. package/src/internal/Compound.ts +522 -0
  600. package/src/internal/Condition.ts +283 -0
  601. package/src/internal/Corner.ts +17 -0
  602. package/src/internal/FunctionSyntax.ts +271 -0
  603. package/src/internal/FunctionValue.ts +96 -0
  604. package/src/internal/Geometry.ts +30 -0
  605. package/src/internal/Grid.ts +67 -0
  606. package/src/internal/Identifier.ts +14 -0
  607. package/src/internal/Identity.ts +89 -0
  608. package/src/internal/Lexical.ts +202 -0
  609. package/src/internal/Literal.ts +3820 -0
  610. package/src/internal/NativeProperties.ts +936 -0
  611. package/src/internal/Numeric.ts +77 -0
  612. package/src/internal/Query.ts +87 -0
  613. package/src/internal/Recipe.ts +17 -0
  614. package/src/internal/RuleReference.ts +102 -0
  615. package/src/internal/Scheme.ts +20 -0
  616. package/src/internal/Shorthands.ts +122 -0
  617. package/src/internal/Targets.ts +162 -0
  618. package/src/internal/Token.ts +380 -0
  619. package/src/internal/Tuple.ts +29 -0
  620. package/src/internal/Typography.ts +51 -0
  621. package/src/internal/Value.ts +320 -0
  622. package/src/metro/Graph.ts +78 -0
  623. package/src/metro/Watch.ts +88 -0
  624. package/src/metro/index.ts +99 -0
  625. package/src/metro/transformer.ts +97 -0
  626. package/src/next/index.ts +114 -0
  627. package/src/next/loader.ts +369 -0
  628. package/src/node/Host.ts +1204 -0
  629. package/src/node/index.ts +6 -0
  630. package/src/react-native/Host.ts +289 -0
  631. package/src/react-native/StyleSheet.ts +1084 -0
  632. package/src/react-native/Variants.ts +122 -0
  633. package/src/react-native/index.ts +7 -0
  634. package/src/react-native/internal/Color.ts +110 -0
  635. package/src/react-native/internal/NativeSchema.ts +3096 -0
  636. package/src/react-native/internal/Scalar.ts +253 -0
  637. package/src/react-native/internal/Values.ts +87 -0
  638. package/src/react-native/react.ts +47 -0
  639. package/src/reset.css +244 -0
  640. package/src/runtime/Appearance.ts +155 -0
  641. package/src/runtime/Composition.ts +87 -0
  642. package/src/runtime/CompositionHtml.ts +38 -0
  643. package/src/runtime/ConditionalRecipe.ts +70 -0
  644. package/src/runtime/Dynamic.ts +51 -0
  645. package/src/runtime/Html.ts +91 -0
  646. package/src/runtime/Native.ts +144 -0
  647. package/src/runtime/NativeContext.ts +74 -0
  648. package/src/runtime/NativeDynamic.ts +246 -0
  649. package/src/runtime/PayloadRecipe.ts +96 -0
  650. package/src/runtime/Props.ts +33 -0
  651. package/src/runtime/Recipe.ts +74 -0
  652. package/src/runtime/Selection.ts +82 -0
  653. package/src/runtime/Variable.ts +15 -0
  654. package/src/runtime/index.ts +45 -0
  655. package/src/styleFunction.ts +138 -0
  656. package/src/themes/LICENSE.tailwind +21 -0
  657. package/src/variable.ts +105 -0
  658. package/src/variants.ts +218 -0
  659. package/src/vite/index.ts +1473 -0
  660. package/src/web/Css.ts +801 -0
  661. package/src/web/colorProfile.ts +60 -0
  662. package/src/web/counterStyle.ts +82 -0
  663. package/src/web/cssFunction.ts +181 -0
  664. package/src/web/customMedia.ts +16 -0
  665. package/src/web/fontFace.ts +41 -0
  666. package/src/web/fontFeatureValues.ts +79 -0
  667. package/src/web/fontPaletteValues.ts +42 -0
  668. package/src/web/global.ts +39 -0
  669. package/src/web/importCss.ts +23 -0
  670. package/src/web/index.ts +22 -0
  671. package/src/web/internal/Block.ts +29 -0
  672. package/src/web/internal/ClassName.ts +112 -0
  673. package/src/web/internal/Context.ts +16 -0
  674. package/src/web/internal/Contributions.ts +219 -0
  675. package/src/web/internal/Namespace.ts +21 -0
  676. package/src/web/internal/Themes.ts +133 -0
  677. package/src/web/keyframes.ts +43 -0
  678. package/src/web/layers.ts +6 -0
  679. package/src/web/namespace.ts +19 -0
  680. package/src/web/page.ts +140 -0
  681. package/src/web/positionTry.ts +71 -0
  682. package/src/web/property.ts +35 -0
  683. package/src/web/viewTransition.ts +89 -0
@@ -0,0 +1,1241 @@
1
+ /**
2
+ * Rewrites extracted style calls into executable modules with CSS and source maps.
3
+ * @module
4
+ */
5
+ import * as Edits from './internal/Edits.js'
6
+ import * as Token from '../internal/Token.js'
7
+ import * as Applications from './internal/Applications.js'
8
+ import type * as Ast from '@oxc-project/types'
9
+ import * as Css from '../web/Css.js'
10
+ import * as Expression from './internal/Expression.js'
11
+ import MagicString from 'magic-string'
12
+ import * as Mapping from '@jridgewell/gen-mapping'
13
+ import * as Namespaces from './internal/Namespaces.js'
14
+ import * as Scheme from '../internal/Scheme.js'
15
+ import * as Syntax from './internal/Syntax.js'
16
+ import * as Source from './Source.js'
17
+ import type * as Style from '../Style.js'
18
+ import * as Themes from './internal/Themes.js'
19
+ import * as Walker from 'oxc-walker'
20
+
21
+ /**
22
+ * Rewrites literal web styles and local themes without evaluation or file access.
23
+ * Direct no-argument applications become props; other definitions become callables.
24
+ * CSS retains ordered composition and receives module-scoped class identities.
25
+ * @param options - Source text and a stable package-relative module identity.
26
+ * @returns Rewritten TypeScript/JSX and CSS with separate version-three maps.
27
+ * @throws {Source.ExtractError} If the source is outside the supported literal subset.
28
+ * @throws {Css.CompileError} If literal CSS compilation fails.
29
+ */
30
+ export function compile(options: compile.Options): compile.ReturnType {
31
+ if (options.target === 'native')
32
+ throw new Error('Use Native.compile for native source output.')
33
+ const extracted =
34
+ options[Themes.context]?.extracted ?? Source.extract(options)
35
+
36
+ const portable = options.compiler === false
37
+ const portableNames: Record<string, string> = {}
38
+ if (portable) {
39
+ for (const call of extracted.calls) {
40
+ if (!call.portable)
41
+ throw new Error(
42
+ 'CSS-only output requires an explicit id for dynamic styles, variants, and compositions.',
43
+ )
44
+ portableNames[call.name] = call.portable
45
+ }
46
+ for (const [name, theme] of Object.entries(extracted.themes))
47
+ if (
48
+ (Object.keys(theme[Token.definition].values).length ||
49
+ extracted.themeCalls.some(
50
+ (call) =>
51
+ (call.name === name ||
52
+ Object.values(call.members ?? {}).includes(name)) &&
53
+ (!call.options ||
54
+ Object.hasOwn(call.options, 'themes') ||
55
+ Object.hasOwn(call.options, 'theme')),
56
+ )) &&
57
+ !theme[Token.definition].contract[Token.identity]?.startsWith('id-')
58
+ )
59
+ throw new Error(
60
+ 'CSS-only themes require an explicit id on Config.create or Theme.define.',
61
+ )
62
+ for (const call of extracted.contributionCalls ?? [])
63
+ if (
64
+ call.name &&
65
+ !/^(?:--)?z-(?:k|counterstyle|positiontry|colorprofile|fontpalettevalues|custommedia|cssfunction)id-/.test(
66
+ call.name,
67
+ )
68
+ )
69
+ throw new Error(
70
+ 'CSS-only named stylesheet declarations require an explicit id.',
71
+ )
72
+ for (const call of extracted.variableCalls ?? [])
73
+ if (
74
+ Object.values(call.slots).some(
75
+ (slot) => !slot.name.startsWith('--z-vid-'),
76
+ )
77
+ )
78
+ throw new Error('CSS-only output requires an explicit variable id.')
79
+ }
80
+
81
+ if (portable) {
82
+ function selectors(style: Style.NamedStyle) {
83
+ for (const rule of style.rules ?? []) {
84
+ if (
85
+ rule.condition &&
86
+ !rule.condition.startsWith('@') &&
87
+ /\.z-style-(?!id-)/.test(rule.condition)
88
+ )
89
+ throw new Error(
90
+ 'CSS-only selector references require an explicit style id.',
91
+ )
92
+ selectors(rule.style)
93
+ }
94
+ }
95
+ for (const style of extracted.styles.styles) selectors(style)
96
+ }
97
+
98
+ const module = new MagicString(options.source)
99
+ const program = Syntax.parse(options).program
100
+
101
+ for (const call of extracted.contributionCalls ?? [])
102
+ module.overwrite(
103
+ call.start,
104
+ call.end,
105
+ (() => {
106
+ const typed = /\.[cm]?tsx?$/.test(options.moduleId)
107
+ if (call.kind === 'cssFunction')
108
+ return `((...args${typed ? ': readonly (string | number)[]' : ''}) => ${JSON.stringify(call.name + '(')} + args.map(value => typeof value === 'string' && value.includes(',') && !value.trimStart().startsWith('{') ? '{' + value + '}' : value).join(',') + ')')${typed ? ` as import('zyzz/web').cssFunction.Reference<${JSON.stringify(call.function?.parameters ?? [])}, ${JSON.stringify(call.function?.returns ?? '*')}>` : ''}`
109
+ if (call.kind === 'customMedia')
110
+ return `${JSON.stringify(`@media (${call.name})`)}${typed ? ` as unknown as import('zyzz/web').customMedia.Reference` : ''}`
111
+ if (!call.name) return 'void 0'
112
+ return `${JSON.stringify(call.name)}${call.kind === 'keyframes' || !typed ? '' : ` as import('zyzz/web').${call.kind}.Reference`}`
113
+ })(),
114
+ )
115
+
116
+ type Span = Pick<Ast.Node, 'end' | 'start'>
117
+
118
+ const applications = new Map<number, { end: number; folded: boolean }>()
119
+ const calls = new Map(extracted.calls.map((call) => [call.start, call]))
120
+ const definitions = new Map<number, Ast.ObjectExpression>()
121
+ const unusedSelections = new Set<number>()
122
+ const identifiers = new Map<string, Span[]>()
123
+
124
+ const localApplications = Applications.create(program, extracted.calls)
125
+
126
+ Walker.walk(program, {
127
+ enter(node, parent) {
128
+ localApplications?.enter(node, parent)
129
+
130
+ if (
131
+ node.type === 'VariableDeclarator' &&
132
+ node.init &&
133
+ node.id.type === 'ObjectPattern' &&
134
+ node.id.properties.every(
135
+ (property) =>
136
+ property.type === 'Property' &&
137
+ (property.key.type === 'Identifier'
138
+ ? property.key.name
139
+ : property.key.type === 'Literal'
140
+ ? property.key.value
141
+ : undefined) !== 'themes',
142
+ )
143
+ )
144
+ unusedSelections.add(Expression.unwrap(node.init).start)
145
+
146
+ if (node.type === 'Identifier') {
147
+ const references = identifiers.get(node.name) ?? []
148
+
149
+ references.push(node)
150
+ identifiers.set(node.name, references)
151
+ }
152
+
153
+ if (node.type !== 'CallExpression') return
154
+
155
+ const call = calls.get(node.start)
156
+ if (!call || node.end !== call.end) return
157
+
158
+ const folded =
159
+ !!call.composition ||
160
+ (!call.recipe &&
161
+ !call.slots &&
162
+ parent?.type === 'CallExpression' &&
163
+ parent.callee === node &&
164
+ !parent.optional &&
165
+ parent.arguments.length === 0)
166
+
167
+ applications.set(call.start, {
168
+ end: folded && !call.composition ? parent!.end : call.end,
169
+ folded,
170
+ })
171
+
172
+ let argument = node.arguments[0]
173
+ ? Expression.unwrap(node.arguments[0])
174
+ : undefined
175
+
176
+ if (argument?.type === 'ArrowFunctionExpression')
177
+ argument = Expression.unwrap(argument.body) as Ast.Expression
178
+
179
+ if (call.body) definitions.set(call.start, call.body)
180
+ else if (argument?.type === 'ObjectExpression')
181
+ definitions.set(call.start, argument)
182
+ },
183
+ })
184
+
185
+ // Scheme rules accompany modules whose runtime helpers can apply a scheme class.
186
+ const schemes =
187
+ options.schemes ??
188
+ Boolean(
189
+ extracted.themeAppearances?.length ||
190
+ extracted.themeScripts?.length ||
191
+ extracted.themeSelections?.length,
192
+ )
193
+
194
+ const emitted = Css.compile({
195
+ development: options.development,
196
+ scope: options.moduleId,
197
+ composition: options.composition,
198
+ cssOutput: options.cssOutput,
199
+ names: portable ? portableNames : undefined,
200
+ schemes,
201
+ // Keep definition positions stable while removing proven unreachable rules.
202
+ // CSS-only consumers retain executable authoring, and development keeps slots.
203
+ styles: (() => {
204
+ if (portable || options.development) return extracted.styles
205
+
206
+ const dead = localApplications?.dead()
207
+ if (!dead?.size) return extracted.styles
208
+
209
+ return {
210
+ styles: extracted.styles.styles.map((style) =>
211
+ dead.has(style.name)
212
+ ? { cssOutput: style.cssOutput, declarations: [], name: style.name }
213
+ : style,
214
+ ),
215
+ }
216
+ })(),
217
+ contributions: extracted.contributions,
218
+ themes: Object.keys(extracted.themes).length ? extracted.themes : undefined,
219
+ })
220
+
221
+ let runtime = '__zyzzProps'
222
+
223
+ while (identifiers.has(runtime)) runtime += '_'
224
+
225
+ let html = '__zyzzHtml'
226
+
227
+ while (identifiers.has(html)) html += '_'
228
+
229
+ let usesHtml = false
230
+ let conditionalRecipe = '__zyzzConditionalRecipe'
231
+ while (identifiers.has(conditionalRecipe)) conditionalRecipe += '_'
232
+ let usesConditionalRecipe = false
233
+ let payloadRecipe = '__zyzzPayloadRecipe'
234
+ while (identifiers.has(payloadRecipe)) payloadRecipe += '_'
235
+ let usesPayloadRecipe = false
236
+ let recipe = '__zyzzRecipe'
237
+ while (identifiers.has(recipe)) recipe += '_'
238
+ let usesRecipe = false
239
+ let compositionHtml = '__zyzzCompositionHtml'
240
+ while (identifiers.has(compositionHtml)) compositionHtml += '_'
241
+ let usesCompositionHtml = false
242
+ const preparedHtml = new Set(
243
+ extracted.calls.flatMap((call) =>
244
+ call.output === 'html'
245
+ ? (call.runtimeComposition ?? []).map((input) => input.name)
246
+ : [],
247
+ ),
248
+ )
249
+ function prepareExport(link: Themes.Link) {
250
+ if (link.style?.output === 'html') {
251
+ const call = extracted.calls.find(
252
+ (call) => call.identity === link.binding,
253
+ )
254
+ if (call) preparedHtml.add(call.name)
255
+ }
256
+ for (const member of Object.values(link.members ?? {}))
257
+ prepareExport(member)
258
+ }
259
+ for (const link of Object.values(extracted.themeExports ?? {}))
260
+ prepareExport(link)
261
+ let composition = '__zyzzComposition'
262
+ while (identifiers.has(composition)) composition += '_'
263
+ let usesComposition = false
264
+ const compositions: string[] = []
265
+ const compositionArguments = new Map<string, string>()
266
+
267
+ let appearance = '__zyzzAppearance'
268
+
269
+ while (identifiers.has(appearance)) appearance += '_'
270
+
271
+ let usesAppearance = false
272
+ let selection = '__zyzzSelection'
273
+
274
+ while (identifiers.has(selection)) selection += '_'
275
+
276
+ let usesSelection = false
277
+
278
+ let variables = '__zyzzVariable'
279
+
280
+ while (identifiers.has(variables)) variables += '_'
281
+
282
+ for (const call of extracted.variableCalls ?? [])
283
+ module.overwrite(
284
+ call.start,
285
+ call.end,
286
+ `${variables}.create(${JSON.stringify(call.slots.value)})`,
287
+ )
288
+
289
+ const first = extracted.calls[0]
290
+ const scope = first ? first.name.slice(6, first.name.lastIndexOf('-')) : ''
291
+ const identities = new Map(
292
+ extracted.calls
293
+ .filter((call) => call.identity)
294
+ .map((call) => [call.name, call.identity!]),
295
+ )
296
+
297
+ const modes = new Map(
298
+ extracted.styles.styles.map((style) => [style.name, style.cssOutput]),
299
+ )
300
+ const ownersByClass = new Map<string, string | false>()
301
+ for (const [style, value] of Object.entries(emitted.classes))
302
+ for (const name of value.split(' ').filter(Boolean))
303
+ ownersByClass.set(name, ownersByClass.has(name) ? false : style)
304
+
305
+ const names = new Map<string, string>()
306
+
307
+ for (const classes of Object.values(emitted.classes))
308
+ for (const name of classes.split(' ').filter(Boolean))
309
+ names.set(
310
+ name,
311
+ (() => {
312
+ const owner = ownersByClass.get(name)
313
+ const identity = owner && identities.get(owner)
314
+ if (
315
+ (modes.get(owner || '') ?? options.cssOutput) === 'grouped' &&
316
+ options.composition === 'independent' &&
317
+ name.startsWith('g_') &&
318
+ identity &&
319
+ !identity.includes(' ')
320
+ )
321
+ return identity
322
+ if (name.startsWith('g_')) return `g_${scope}_${name.slice(2)}`
323
+ return name.startsWith('z_base')
324
+ ? `z-${scope}-${name.slice(2)}`
325
+ : name
326
+ })(),
327
+ )
328
+
329
+ const classes = Object.freeze(
330
+ Object.fromEntries(
331
+ Object.entries(emitted.classes).map(([name, value]) => [
332
+ name,
333
+ [
334
+ ...new Set([
335
+ ...value
336
+ .split(' ')
337
+ .filter(Boolean)
338
+ .map((part) => names.get(part)!),
339
+ ...(identities.has(name) &&
340
+ (!portable || portableNames[name]?.startsWith('z-compose-'))
341
+ ? [
342
+ portable
343
+ ? identities
344
+ .get(name)!
345
+ .split(' ')
346
+ .filter((name) => name.startsWith('z-style-id-'))
347
+ .join(' ')
348
+ : identities.get(name)!,
349
+ ]
350
+ : []),
351
+ ]),
352
+ ].join(' '),
353
+ ]),
354
+ ),
355
+ )
356
+
357
+ let callable = false
358
+
359
+ const composed = (node: Span) =>
360
+ extracted.calls.some(
361
+ (call) =>
362
+ call.composition && call.start < node.start && node.end <= call.end,
363
+ )
364
+ // Rewrite contained expressions before their enclosing composition reads them.
365
+ const rewrites = [...extracted.calls].sort((a, b) =>
366
+ a.start < b.start && a.end >= b.end
367
+ ? 1
368
+ : b.start < a.start && b.end >= a.end
369
+ ? -1
370
+ : a.start - b.start,
371
+ )
372
+ for (const call of rewrites) {
373
+ if (call.compositionCase || composed(call)) continue
374
+ const application = applications.get(call.start)!
375
+ const props = `{${call.output === 'html' ? 'class' : 'className'}:${JSON.stringify(classes[call.name])}}`
376
+
377
+ const composeHtml = call.output === 'html' && preparedHtml.has(call.name)
378
+ if (composeHtml) usesCompositionHtml = true
379
+ const replacement = (() => {
380
+ if (call.runtimeComposition) {
381
+ const helper = call.output === 'html' ? compositionHtml : composition
382
+ if (call.output === 'html') usesCompositionHtml = true
383
+ else usesComposition = true
384
+ let factory = `${composition}${call.start}`
385
+ while (identifiers.has(factory)) factory += '_'
386
+ const inputs = call.runtimeComposition.map((input) => ({
387
+ className:
388
+ classes[input.name] ??
389
+ options[Themes.context]?.styleClasses?.[input.name] ??
390
+ '',
391
+ condition: input.condition,
392
+ owners: input.owners,
393
+ }))
394
+ compositions.push(
395
+ `const ${factory}=/*#__PURE__*/${helper}.create(${JSON.stringify({ className: classes[call.name], cases: call.compositionCases?.map((name) => classes[name]!), inputs })});`,
396
+ )
397
+ return `${factory}(${call.runtimeComposition
398
+ .map((input) => {
399
+ const key = `${input.start}:${input.end}`
400
+ const value =
401
+ compositionArguments.get(key) ??
402
+ module.slice(input.start, input.end)
403
+ compositionArguments.set(key, value)
404
+ return value
405
+ })
406
+ .join(',')})`
407
+ }
408
+ if (call.composition)
409
+ return call.composition.reduceRight(
410
+ (result, guard) =>
411
+ `((${guard}${/\.[cm]?tsx?$/.test(options.moduleId) ? ' as unknown' : ''})?${result}:${guard}())`,
412
+ composeHtml
413
+ ? `${compositionHtml}.from({className:${JSON.stringify(classes[call.name])}})`
414
+ : `(${props})`,
415
+ )
416
+ if (call.recipe) {
417
+ const helper = call.recipe.conditions?.length
418
+ ? conditionalRecipe
419
+ : recipe
420
+ if (call.recipe.conditions?.length) usesConditionalRecipe = true
421
+ else usesRecipe = true
422
+
423
+ const payload = !!call.recipe.payloads?.length
424
+ if (payload) usesPayloadRecipe = true
425
+ const selection = `${helper}.create(${JSON.stringify({ axes: call.recipe.axes, defaults: call.recipe.defaults, conditions: call.recipe.conditions, className: classes[call.name], ...(!payload && call.output === 'html' && !composeHtml ? { html: true } : {}) })})`
426
+ const value = payload
427
+ ? `${payloadRecipe}.create({...${JSON.stringify({ ...call.recipe, html: call.output === 'html' && !composeHtml })},select:${selection}})`
428
+ : selection
429
+ const bound = composeHtml ? `${compositionHtml}.bind(${value})` : value
430
+ const axes = Object.entries(call.recipe.axes)
431
+ .map(
432
+ ([axis, choices]) =>
433
+ `${JSON.stringify(axis)}:{${choices.map((choice) => `${JSON.stringify(choice)}:${call.recipeTypes?.[axis]?.[choice] ? `(values:${call.recipeTypes[axis]![choice]})=>{}` : '{}'}`).join(';')}}`,
434
+ )
435
+ .join(';')
436
+ const conditions = call.recipe.conditions
437
+ ?.map((name) => `${JSON.stringify(name)}:unknown`)
438
+ .join(';')
439
+ const type = `import('zyzz').variants.ReturnType<{variants:{${axes}}${conditions ? `;conditions:{${conditions}}` : ''}}${call.output === 'html' ? ',"html"' : ''}>`
440
+ return /\.[cm]?tsx?$/.test(options.moduleId)
441
+ ? `(${bound} as ${type})`
442
+ : bound
443
+ }
444
+ if (call.slots) {
445
+ const type = `import('zyzz').style.Dynamic<${call.valuesType}${call.output === 'html' ? ',"html"' : ''}>`
446
+ const typed = /\.[cm]?tsx?$/.test(options.moduleId)
447
+ const slots = Object.entries(call.slots)
448
+
449
+ const reads = slots
450
+ .map(
451
+ ([key], index) =>
452
+ `const v${index}=input[${JSON.stringify(key)}]${typed ? ' as string | number' : ''};`,
453
+ )
454
+ .join('')
455
+
456
+ const assignments = slots
457
+ .map(
458
+ ([, slot], index) =>
459
+ `${JSON.stringify(slot.name)}:v${index}===''?' ':v${index}`,
460
+ )
461
+ .join(',')
462
+
463
+ const className = JSON.stringify(classes[call.name])
464
+ const value = `(input${typed ? `:Parameters<${type}>[0]` : ''})=>{${reads}const external=input.className;const style=input.style;return {className:external?${className}+" "+external:${className},style:{...input.variables,...style,${assignments}}}}`
465
+ const result = composeHtml
466
+ ? `${compositionHtml}.bind(${value})`
467
+ : call.output === 'html'
468
+ ? `${html}.bind(${value})`
469
+ : `(${value})`
470
+
471
+ if (call.output === 'html' && !composeHtml) usesHtml = true
472
+
473
+ return typed ? `(${result} as ${type})` : result
474
+ }
475
+
476
+ if (application.folded)
477
+ return composeHtml
478
+ ? `${compositionHtml}.from({className:${JSON.stringify(classes[call.name])}})`
479
+ : `(${props})`
480
+
481
+ if (call.output === 'html') {
482
+ if (composeHtml) {
483
+ callable = true
484
+ return `(${compositionHtml}.bind(${runtime}.create({className:${JSON.stringify(classes[call.name])}}))${/\.[cm]?tsx?$/.test(options.moduleId) ? " as import('zyzz').style.ReturnType<'html'>" : ''})`
485
+ }
486
+ usesHtml = true
487
+
488
+ return `${html}.create({className:${JSON.stringify(classes[call.name])}})`
489
+ }
490
+
491
+ return `${runtime}.create(${props})`
492
+ })()
493
+
494
+ module.overwrite(call.start, application.end, replacement)
495
+
496
+ if (
497
+ !call.recipe &&
498
+ !call.slots &&
499
+ !call.runtimeComposition &&
500
+ !application.folded &&
501
+ call.output !== 'html'
502
+ )
503
+ callable = true
504
+ }
505
+
506
+ for (const application of localApplications?.find() ?? []) {
507
+ if (
508
+ extracted.calls.some(
509
+ (call) =>
510
+ call.output === 'html' &&
511
+ call.runtimeComposition?.some(
512
+ (input) => input.applicationStart === application.start,
513
+ ),
514
+ )
515
+ )
516
+ continue
517
+ if (
518
+ extracted.calls.some(
519
+ (call) =>
520
+ (call.composition || call.runtimeComposition) &&
521
+ call.start < application.start &&
522
+ application.end <= call.end,
523
+ )
524
+ )
525
+ continue
526
+ const className = JSON.stringify(classes[application.name])
527
+
528
+ const key =
529
+ extracted.calls.find((call) => call.name === application.name)?.output ===
530
+ 'html'
531
+ ? 'class'
532
+ : 'className'
533
+
534
+ // Keep a callable guard so bundlers also retain failures before initialization.
535
+ module.overwrite(
536
+ application.start,
537
+ application.end,
538
+ `(${options.source.slice(application.start, application.calleeEnd)}?{${key}:${className}}:${options.source.slice(application.start, application.calleeEnd)}())`,
539
+ )
540
+ }
541
+
542
+ for (const call of extracted.themeCalls) {
543
+ const scope = (name: string) => ({ className: emitted.themes[name] })
544
+
545
+ const props = (() => {
546
+ if (!call.members)
547
+ return `{className:${JSON.stringify(emitted.themes[call.name])}}`
548
+
549
+ const script = extracted.themeScripts?.includes(call.name)
550
+ const root = extracted.themeAppearances?.includes(call.name)
551
+
552
+ if (script || root) usesAppearance = true
553
+
554
+ // Helpers are emitted only when referenced; both share the configured storage key.
555
+ const storage = call.options?.storageKey
556
+ const helpers = (entries: string, defaultTheme?: string) => {
557
+ const scriptOptions = storage
558
+ ? `,${JSON.stringify({ storageKey: storage })}`
559
+ : ''
560
+ const rootOptions =
561
+ storage || defaultTheme
562
+ ? `,${JSON.stringify({ ...(defaultTheme ? { defaultTheme } : {}), ...(storage ? { storageKey: storage } : {}) })}`
563
+ : ''
564
+
565
+ return `${root ? `appearance:${appearance}.root(${entries}${rootOptions}),` : ''}${script ? `script:${appearance}.create(${entries}${scriptOptions}),` : ''}`
566
+ }
567
+
568
+ if (call.options?.themes) {
569
+ const catalog = Object.fromEntries(
570
+ Object.entries(call.members)
571
+ .filter(([key]) => (JSON.parse(key) as string[]).length === 2)
572
+ .map(([key, name]) => [
573
+ (JSON.parse(key) as string[])[1]!,
574
+ emitted.themes[name],
575
+ ]),
576
+ )
577
+
578
+ const entries = JSON.stringify(Object.entries(catalog))
579
+ const defaultTheme =
580
+ typeof call.options.defaultTheme === 'string'
581
+ ? call.options.defaultTheme
582
+ : undefined
583
+ if (unusedSelections.has(call.start))
584
+ return `{${helpers(entries, defaultTheme)}theme:${JSON.stringify(scope(call.members['["theme"]']!))}}`
585
+
586
+ usesSelection = true
587
+
588
+ return `{${helpers(entries, defaultTheme)}theme:${JSON.stringify(scope(call.members['["theme"]']!))},themes:/*#__PURE__*/${selection}.create(${entries},${call.options.output === 'html'})}`
589
+ }
590
+
591
+ if (Object.hasOwn(call.members, '["theme"]'))
592
+ return `{${helpers('[]')}theme:${JSON.stringify(scope(call.members['["theme"]']!))}}`
593
+
594
+ return script || root ? `{${helpers('[]').slice(0, -1)}}` : '{}'
595
+ })()
596
+
597
+ const assertion = /\.[cm]?tsx?$/.test(options.moduleId)
598
+ ? ` as ${call.type ?? `import('zyzz').Theme.Definition<${call.tokenType}>`}`
599
+ : ''
600
+
601
+ module.overwrite(call.start, call.end, `(${props}${assertion})`)
602
+ }
603
+
604
+ for (const alias of extracted.themeAliases) {
605
+ if (alias.retained) {
606
+ if (/\.[cm]?tsx?$/.test(options.moduleId))
607
+ module.overwrite(
608
+ alias.start,
609
+ alias.end,
610
+ `(${options.source.slice(alias.start, alias.end)} as ${alias.type ?? `import('zyzz').Theme.Definition<${alias.tokenType}>`})`,
611
+ )
612
+
613
+ continue
614
+ }
615
+
616
+ const member = alias.recipe ? 'variants' : 'style'
617
+ const members = [...new Set(alias.bindings ?? [member])]
618
+ const value = alias.destructured
619
+ ? `{${members.map((member) => `${member}:undefined`).join(',')}}`
620
+ : 'undefined'
621
+ const type =
622
+ alias.type ?? `import('zyzz').Theme.Definition<${alias.tokenType}>`
623
+ const assertion = /\.[cm]?tsx?$/.test(options.moduleId)
624
+ ? ` as unknown as ${alias.destructured ? `{${members.map((member) => `readonly ${member}:${type}['${member}']`).join(';')}}` : `${type}['${member}']`}`
625
+ : ''
626
+
627
+ module.overwrite(alias.start, alias.end, `(${value}${assertion})`)
628
+ }
629
+
630
+ const replacements = [
631
+ ...extracted.calls.map((call) => ({
632
+ end: applications.get(call.start)!.end,
633
+ start: call.start,
634
+ })),
635
+ ...(extracted.contributionCalls ?? []),
636
+ ...(extracted.variableCalls ?? []),
637
+ ...extracted.themeAliases,
638
+ ...extracted.themeCalls,
639
+ ].sort((a, b) => a.start - b.start)
640
+
641
+ function replaced(reference: Span) {
642
+ let low = 0
643
+ let high = replacements.length
644
+
645
+ while (low < high) {
646
+ const middle = (low + high) >>> 1
647
+
648
+ if (replacements[middle]!.start <= reference.start) low = middle + 1
649
+ else high = middle
650
+ }
651
+
652
+ const call = replacements[low - 1]
653
+
654
+ return call !== undefined && reference.end <= call.end
655
+ }
656
+
657
+ for (const reference of extracted.staticThemeReferences ?? [])
658
+ if (!replaced(reference))
659
+ module.overwrite(
660
+ reference.start,
661
+ reference.end,
662
+ JSON.stringify(reference.value),
663
+ )
664
+
665
+ for (const reference of extracted.themeReferences)
666
+ if (!replaced(reference))
667
+ module.overwrite(
668
+ reference.start,
669
+ reference.end,
670
+ JSON.stringify(emitted.themes[reference.name]),
671
+ )
672
+
673
+ replacements.push(
674
+ ...extracted.themeReferences,
675
+ ...(extracted.staticThemeReferences ?? []),
676
+ )
677
+ replacements.sort((a, b) => a.start - b.start)
678
+
679
+ for (const node of program.body) {
680
+ if (
681
+ node.type !== 'ImportDeclaration' ||
682
+ !['zyzz', 'zyzz/web'].includes(node.source.value)
683
+ )
684
+ continue
685
+
686
+ const removed = new Set<Ast.ImportDeclaration['specifiers'][number]>()
687
+
688
+ for (const specifier of node.specifiers) {
689
+ if (
690
+ node.importKind === 'type' ||
691
+ specifier.type !== 'ImportSpecifier' ||
692
+ specifier.importKind === 'type' ||
693
+ !(
694
+ node.source.value === 'zyzz'
695
+ ? ['Config', 'cx', 'style', 'Theme', 'variable', 'variants']
696
+ : [
697
+ 'Css',
698
+ 'cssFunction',
699
+ 'customMedia',
700
+ 'importCss',
701
+ 'namespace',
702
+ 'colorProfile',
703
+ 'counterStyle',
704
+ 'fontPaletteValues',
705
+ 'fontFeatureValues',
706
+ 'page',
707
+ 'property',
708
+ 'viewTransition',
709
+ 'global',
710
+ 'fontFace',
711
+ 'keyframes',
712
+ 'layers',
713
+ 'positionTry',
714
+ ]
715
+ ).includes(
716
+ specifier.imported.type === 'Identifier'
717
+ ? specifier.imported.name
718
+ : specifier.imported.value,
719
+ )
720
+ )
721
+ continue
722
+
723
+ // Conservative retention also protects type queries and shadowed references.
724
+ const remaining = identifiers
725
+ .get(specifier.local.name)
726
+ ?.some(
727
+ (reference) =>
728
+ !(reference.start >= node.start && reference.end <= node.end) &&
729
+ !replaced(reference),
730
+ )
731
+
732
+ if (!remaining) removed.add(specifier)
733
+ }
734
+
735
+ if (!removed.size) continue
736
+
737
+ const retained = node.specifiers.filter(
738
+ (specifier) => !removed.has(specifier),
739
+ )
740
+
741
+ if (!retained.length) module.remove(node.start, node.end)
742
+ else if (
743
+ retained.every((specifier) => specifier.type !== 'ImportSpecifier')
744
+ ) {
745
+ module.overwrite(
746
+ node.start,
747
+ node.source.start,
748
+ `import ${retained.map((specifier) => options.source.slice(specifier.start, specifier.end)).join(', ')} from `,
749
+ )
750
+ } else {
751
+ // Preserve the import source, attributes, and untouched specifier spelling.
752
+ for (let index = 0; index < node.specifiers.length; index++) {
753
+ const specifier = node.specifiers[index]!
754
+ if (!removed.has(specifier)) continue
755
+
756
+ const next = node.specifiers[index + 1]
757
+ const previous = node.specifiers[index - 1]
758
+
759
+ if (next) module.remove(specifier.start, next.start)
760
+ else if (previous) module.remove(previous.end, specifier.end)
761
+ }
762
+ }
763
+ }
764
+
765
+ if (
766
+ callable ||
767
+ usesRecipe ||
768
+ usesComposition ||
769
+ usesCompositionHtml ||
770
+ usesConditionalRecipe ||
771
+ usesPayloadRecipe ||
772
+ usesHtml ||
773
+ usesSelection ||
774
+ usesAppearance ||
775
+ extracted.variableCalls?.length
776
+ ) {
777
+ // Insertion after a hashbang keeps executable module syntax intact.
778
+ let offset = options.source.startsWith('#!')
779
+ ? options.source.indexOf('\n') + 1
780
+ : 0
781
+
782
+ for (const node of program.body) {
783
+ if (node.type !== 'ExpressionStatement' || !node.directive) break
784
+
785
+ offset = node.end
786
+ }
787
+
788
+ if (compositions.length)
789
+ module.appendLeft(offset, '\n' + compositions.join('\n') + '\n')
790
+
791
+ module.appendLeft(
792
+ offset,
793
+ `\nimport { ${[usesAppearance ? `Appearance as ${appearance}` : '', usesComposition ? `Composition as ${composition}` : '', usesCompositionHtml ? `CompositionHtml as ${compositionHtml}` : '', usesConditionalRecipe ? `ConditionalRecipe as ${conditionalRecipe}` : '', usesHtml ? `Html as ${html}` : '', usesPayloadRecipe ? `PayloadRecipe as ${payloadRecipe}` : '', callable ? `Props as ${runtime}` : '', usesRecipe ? `Recipe as ${recipe}` : '', usesSelection ? `Selection as ${selection}` : '', extracted.variableCalls?.length ? `Variable as ${variables}` : ''].filter(Boolean).join(', ')} } from 'zyzz/runtime';\n`,
794
+ )
795
+ }
796
+
797
+ const cssMap = new Mapping.GenMapping({ file: `${options.moduleId}.css` })
798
+
799
+ Mapping.setSourceContent(cssMap, options.moduleId, options.source)
800
+
801
+ const lines = [0]
802
+
803
+ for (let index = 0; index < options.source.length; index++)
804
+ if (options.source[index] === '\n') lines.push(index + 1)
805
+
806
+ function position(offset: number) {
807
+ let low = 0
808
+ let high = lines.length
809
+
810
+ while (low + 1 < high) {
811
+ const middle = (low + high) >>> 1
812
+
813
+ if (lines[middle]! <= offset) low = middle
814
+ else high = middle
815
+ }
816
+
817
+ return { column: offset - lines[low]!, line: low + 1 }
818
+ }
819
+
820
+ const owners = new Map<string, Source.Call>()
821
+
822
+ for (const call of extracted.calls)
823
+ for (const name of emitted.classes[call.name]!.split(' '))
824
+ if (!owners.has(name)) owners.set(name, call)
825
+
826
+ const styles = new Map(
827
+ extracted.styles.styles.map((style) => [style.name, style]),
828
+ )
829
+
830
+ const themeOwners = new Map(
831
+ extracted.themeCalls.flatMap((call) =>
832
+ [...new Set([call.name, ...Object.values(call.members ?? {})])].map(
833
+ (name) => [emitted.themes[name], { ...call, name }] as const,
834
+ ),
835
+ ),
836
+ )
837
+
838
+ const linkedOwners = new Map(
839
+ Object.entries(options[Themes.context]?.owners ?? {}).map(
840
+ ([key, owner]) => [emitted.themes[key], owner],
841
+ ),
842
+ )
843
+
844
+ // Literal and scalar-theme rules each occupy one line at this boundary.
845
+ const prefix = emitted.contributionCss ?? ''
846
+ const contributions = (extracted.contributions ?? []).map(
847
+ (definition, index) => ({
848
+ definition,
849
+ start: extracted.contributionStarts?.[index],
850
+ }),
851
+ )
852
+ const rank = (kind: string) =>
853
+ kind === 'import' ? 0 : kind === 'namespace' ? 1 : 2
854
+ const layered = contributions.find(
855
+ (value) =>
856
+ value.definition.kind === 'layers' && value.definition.names.length > 0,
857
+ )
858
+ let contributionLine = 1
859
+ if (layered) {
860
+ if (layered.start !== undefined)
861
+ Mapping.addMapping(cssMap, {
862
+ generated: { line: contributionLine, column: 0 },
863
+ original: position(layered.start),
864
+ source: options.moduleId,
865
+ })
866
+ contributionLine++
867
+ }
868
+ for (const contribution of contributions.toSorted(
869
+ (a, b) => rank(a.definition.kind) - rank(b.definition.kind),
870
+ )) {
871
+ if (contribution.definition.kind === 'layers') continue
872
+ const rendered =
873
+ Css.compile({
874
+ styles: { styles: [] },
875
+ contributions: [contribution.definition],
876
+ themes: Object.keys(extracted.themes).length
877
+ ? extracted.themes
878
+ : undefined,
879
+ }).contributionCss ?? ''
880
+ if (!rendered) continue
881
+ for (const _ of rendered.split('\n')) {
882
+ if (contribution.start !== undefined)
883
+ Mapping.addMapping(cssMap, {
884
+ generated: { line: contributionLine, column: 0 },
885
+ original: position(contribution.start),
886
+ source: options.moduleId,
887
+ })
888
+ contributionLine++
889
+ }
890
+ }
891
+ const declarationOwners = new Map<string, Set<number>>()
892
+ const scoped = emitted.scopedCss ?? emitted.css
893
+
894
+ const css = [
895
+ prefix,
896
+ (scoped ? scoped.split('\n') : [])
897
+ .map((rule, index) => {
898
+ const line = index + 1 + (prefix ? prefix.split('\n').length : 0)
899
+ const brace = rule.indexOf('{')
900
+ const name = rule.slice(1, brace)
901
+ const linkedOwner = linkedOwners.get(name)
902
+
903
+ if (linkedOwner) {
904
+ const lines = linkedOwner.source
905
+ .slice(0, linkedOwner.call.start)
906
+ .split('\n')
907
+
908
+ Mapping.setSourceContent(
909
+ cssMap,
910
+ linkedOwner.moduleId,
911
+ linkedOwner.source,
912
+ )
913
+ Mapping.addMapping(cssMap, {
914
+ generated: { column: 0, line },
915
+ name: linkedOwner.call.name,
916
+ original: { line: lines.length, column: lines.at(-1)!.length },
917
+ source: linkedOwner.moduleId,
918
+ })
919
+
920
+ return rule
921
+ }
922
+
923
+ const themeOwner = themeOwners.get(name)
924
+
925
+ if (themeOwner) {
926
+ Mapping.addMapping(cssMap, {
927
+ generated: { column: 0, line },
928
+ name: themeOwner.name,
929
+ original: position(themeOwner.start),
930
+ source: options.moduleId,
931
+ })
932
+
933
+ return rule
934
+ }
935
+
936
+ if (Object.values(emitted.themes).includes(name)) {
937
+ // Packed theme declarations have no authored source in this graph.
938
+ Mapping.addMapping(cssMap, { generated: { column: 0, line } })
939
+
940
+ return rule
941
+ }
942
+
943
+ if (Object.values(Scheme.classes).includes(name)) {
944
+ // Scheme selection rules accompany the scopes and have no authored source.
945
+ Mapping.addMapping(cssMap, { generated: { column: 0, line } })
946
+
947
+ return rule
948
+ }
949
+
950
+ const selector = `.${names.get(name)!}`
951
+ const call = owners.get(name)!
952
+
953
+ Mapping.addMapping(cssMap, {
954
+ generated: { column: 0, line },
955
+ name: call.name,
956
+ original: position(call.start),
957
+ source: options.moduleId,
958
+ })
959
+
960
+ const body = rule.slice(brace)
961
+ const style = styles.get(call.name)!
962
+
963
+ function declarations(
964
+ style: Style.NamedStyle,
965
+ ): readonly Style.Declaration[] {
966
+ return style.rules
967
+ ? style.rules.flatMap((rule) => declarations(rule.style))
968
+ : style.declarations
969
+ }
970
+
971
+ const conditionNodes: Extract<Ast.Node, { type: 'Property' }>[] = []
972
+
973
+ function locations(node: Ast.ObjectExpression): readonly Ast.Node[] {
974
+ return node.properties.flatMap((property) => {
975
+ if (property.type !== 'Property') return []
976
+
977
+ const value = Expression.unwrap(property.value)
978
+
979
+ if (value.type === 'ObjectExpression') {
980
+ const key =
981
+ property.key.type === 'Identifier'
982
+ ? property.key.name
983
+ : property.key.type === 'Literal'
984
+ ? property.key.value
985
+ : undefined
986
+ if (key !== 'selectors') conditionNodes.push(property)
987
+
988
+ return locations(value)
989
+ }
990
+
991
+ const key =
992
+ property.key.type === 'Identifier'
993
+ ? property.key.name
994
+ : property.key.type === 'Literal'
995
+ ? String(property.key.value)
996
+ : ''
997
+
998
+ if (key === 'typography' && call.typography?.has(property.start))
999
+ return Array.from(
1000
+ { length: call.typography.get(property.start)! },
1001
+ () => property,
1002
+ )
1003
+
1004
+ const authoredLocations: readonly Ast.Node[] =
1005
+ value.type === 'ArrayExpression'
1006
+ ? value.elements.filter(
1007
+ (node): node is NonNullable<typeof node> => node !== null,
1008
+ )
1009
+ : [property]
1010
+
1011
+ return (call.shorthands?.[key] ?? [key]).flatMap(
1012
+ () => authoredLocations,
1013
+ )
1014
+ })
1015
+ }
1016
+
1017
+ const ordered = declarations(style)
1018
+ const authored = locations(call.body ?? definitions.get(call.start)!)
1019
+ const openers = new Map<number, number>()
1020
+ const conditionStarts = declarationStarts(body, true, openers)
1021
+ const conditions: string[] = []
1022
+
1023
+ function collectConditions(style: Style.NamedStyle) {
1024
+ for (const rule of style.rules ?? []) {
1025
+ if (rule.condition !== undefined) conditions.push(rule.condition)
1026
+
1027
+ collectConditions(rule.style)
1028
+ }
1029
+ }
1030
+
1031
+ collectConditions(style)
1032
+ let conditionCursor = 0
1033
+
1034
+ for (const start of conditionStarts) {
1035
+ const condition = body.slice(start, openers.get(start))
1036
+ const index = conditions.indexOf(condition, conditionCursor)
1037
+ const node = conditionNodes[index]
1038
+ if (!node) continue
1039
+
1040
+ conditionCursor = index + 1
1041
+ Mapping.addMapping(cssMap, {
1042
+ generated: { column: selector.length + start, line },
1043
+ name: options.source.slice(node.key.start, node.key.end),
1044
+ original: position(node.key.start),
1045
+ source: options.moduleId,
1046
+ })
1047
+ }
1048
+
1049
+ const starts = declarationStarts(body)
1050
+ const used = declarationOwners.get(call.name) ?? new Set<number>()
1051
+ declarationOwners.set(call.name, used)
1052
+ let cursor = 1
1053
+
1054
+ for (
1055
+ let propertyIndex = 0;
1056
+ propertyIndex < ordered.length;
1057
+ propertyIndex++
1058
+ ) {
1059
+ if (used.has(propertyIndex)) continue
1060
+ const declaration = ordered[propertyIndex]!
1061
+ const text = `${declaration.property.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`)}:`
1062
+ const start =
1063
+ starts.find(
1064
+ (start) => start >= cursor && body.startsWith(text, start),
1065
+ ) ?? -1
1066
+ if (start < 0) continue
1067
+
1068
+ const location = authored[propertyIndex]!
1069
+ used.add(propertyIndex)
1070
+
1071
+ Mapping.addMapping(cssMap, {
1072
+ generated: { column: selector.length + start, line },
1073
+ name: declaration.property,
1074
+ original: position(location.start),
1075
+ source: options.moduleId,
1076
+ })
1077
+ cursor = start + text.length
1078
+ }
1079
+
1080
+ return selector + body
1081
+ })
1082
+ .join('\n'),
1083
+ ]
1084
+ .filter(Boolean)
1085
+ .join('\n')
1086
+
1087
+ const map = (portable ? new MagicString(options.source) : module).generateMap(
1088
+ {
1089
+ hires: true,
1090
+ includeContent: true,
1091
+ source: options.moduleId,
1092
+ },
1093
+ )
1094
+
1095
+ const namespaced = Namespaces.rewrite(
1096
+ css,
1097
+ extracted.namespaces ?? [],
1098
+ Mapping.toEncodedMap(cssMap),
1099
+ true,
1100
+ )
1101
+ return Object.freeze({
1102
+ classes,
1103
+ code: portable ? options.source : module.toString(),
1104
+ css: namespaced.css,
1105
+ cssMap: namespaced.map ?? Mapping.toEncodedMap(cssMap),
1106
+ map: {
1107
+ file: options.moduleId,
1108
+ mappings: map.mappings,
1109
+ names: map.names,
1110
+ sources: map.sources,
1111
+ sourcesContent: map.sourcesContent!,
1112
+ version: 3 as const,
1113
+ },
1114
+ themes: emitted.themes,
1115
+ })
1116
+ }
1117
+
1118
+ /** Source transform contracts. */
1119
+ export declare namespace compile {
1120
+ /** Public failures from extraction and target compilation. */
1121
+ type ErrorType = Css.CompileError | Source.ExtractError
1122
+ /** Supplied module identity and source; no file loading occurs. */
1123
+ type Options = Source.extract.Options & {
1124
+ /** Disable source rewriting while emitting CSS for runtime authoring. Defaults to true. */
1125
+ readonly compiler?: boolean | undefined
1126
+ /** Whether compiled applications can be combined with one another. */
1127
+ readonly composition?: Css.compile.Options['composition']
1128
+ /** Default CSS representation for definitions without an explicit mode. */
1129
+ readonly cssOutput?: Css.compile.Options['cssOutput']
1130
+ /** Stable declaration names for CSS-only development updates. */
1131
+ readonly development?: boolean | undefined
1132
+ /**
1133
+ * Emit the `color-scheme` selection classes beside the theme scopes.
1134
+ * Defaults to this module's own selector, root, and script references.
1135
+ */
1136
+ readonly schemes?: boolean | undefined
1137
+ }
1138
+
1139
+ /** Executable module and stylesheet artifacts; TypeScript/JSX lowering belongs to the host. */
1140
+ type ReturnType = {
1141
+ /** Internal native node replacements, when supplied by the graph adapter. */
1142
+ readonly [Edits.key]?: readonly Edits.Edit[] | undefined
1143
+ /** Module-scoped class lists keyed by extracted definition identity. */
1144
+ readonly classes: Readonly<Record<string, string>>
1145
+ /** Rewritten source with imports for surviving props callables. */
1146
+ readonly code: string
1147
+ /** Ordered, unminified stylesheet text. */
1148
+ readonly css: string
1149
+ /** Standard stylesheet map with authored selector/declaration locations. */
1150
+ readonly cssMap: Mapping.EncodedSourceMap
1151
+ /** Standard rewritten-module map, including original source content. */
1152
+ readonly map: Mapping.EncodedSourceMap
1153
+ /** Stable scope classes keyed by local module/binding identity. */
1154
+ readonly themes: Readonly<Record<string, string>>
1155
+ }
1156
+ }
1157
+
1158
+ /** Locates emitted declarations while skipping selectors, conditions, and quoted CSS data. */
1159
+ function declarationStarts(
1160
+ body: string,
1161
+ conditions = false,
1162
+ openers?: Map<number, number>,
1163
+ ): readonly number[] {
1164
+ const starts: number[] = []
1165
+ let start = 0
1166
+ let depth = 0
1167
+ let blocks = 0
1168
+ let custom = false
1169
+ let quote = ''
1170
+
1171
+ for (let index = 0; index < body.length; index++) {
1172
+ const char = body[index]!
1173
+
1174
+ if (char === '\\') {
1175
+ index++
1176
+ continue
1177
+ }
1178
+
1179
+ if (quote) {
1180
+ if (char === quote) quote = ''
1181
+
1182
+ continue
1183
+ }
1184
+
1185
+ if (char === '"' || char === "'") {
1186
+ quote = char
1187
+ continue
1188
+ }
1189
+
1190
+ if (char === '/' && body[index + 1] === '*') {
1191
+ const end = body.indexOf('*/', index + 2)
1192
+
1193
+ if (end < 0) break
1194
+
1195
+ index = end + 1
1196
+ continue
1197
+ }
1198
+
1199
+ if (char === '(' || char === '[') {
1200
+ depth++
1201
+ continue
1202
+ }
1203
+
1204
+ if (char === ')' || char === ']') {
1205
+ depth--
1206
+ continue
1207
+ }
1208
+
1209
+ if (depth) continue
1210
+
1211
+ if (char === ':' && body.slice(start, index).trimStart().startsWith('--'))
1212
+ custom = true
1213
+
1214
+ if (char === '{') {
1215
+ if (custom) blocks++
1216
+ else {
1217
+ if (conditions && index > start) {
1218
+ starts.push(start)
1219
+ openers?.set(start, index)
1220
+ }
1221
+
1222
+ start = index + 1
1223
+ }
1224
+ } else if (char === '}') {
1225
+ if (blocks) blocks--
1226
+ else {
1227
+ start = index + 1
1228
+ custom = false
1229
+ }
1230
+ } else if (char === ';' && !blocks) {
1231
+ while (/\s/.test(body[start] ?? '') && start < index) start++
1232
+
1233
+ if (!conditions) starts.push(start)
1234
+
1235
+ start = index + 1
1236
+ custom = false
1237
+ }
1238
+ }
1239
+
1240
+ return starts
1241
+ }