zyzz 0.0.0 → 0.0.2

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 (678) 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 +167 -0
  12. package/dist/Style.d.ts.map +1 -0
  13. package/dist/Style.js +284 -0
  14. package/dist/Style.js.map +1 -0
  15. package/dist/Theme.d.ts +154 -0
  16. package/dist/Theme.d.ts.map +1 -0
  17. package/dist/Theme.js +257 -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 +165 -0
  44. package/dist/compiler/Source.d.ts.map +1 -0
  45. package/dist/compiler/Source.js +990 -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 +884 -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 +600 -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 +2008 -0
  188. package/dist/default.d.ts.map +1 -0
  189. package/dist/default.js +243 -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 +49 -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/Value.d.ts +74 -0
  297. package/dist/internal/Value.d.ts.map +1 -0
  298. package/dist/internal/Value.js +60 -0
  299. package/dist/internal/Value.js.map +1 -0
  300. package/dist/metro/Graph.d.ts +8 -0
  301. package/dist/metro/Graph.d.ts.map +1 -0
  302. package/dist/metro/Graph.js +63 -0
  303. package/dist/metro/Graph.js.map +1 -0
  304. package/dist/metro/Watch.d.ts +21 -0
  305. package/dist/metro/Watch.d.ts.map +1 -0
  306. package/dist/metro/Watch.js +51 -0
  307. package/dist/metro/Watch.js.map +1 -0
  308. package/dist/metro/index.d.ts +30 -0
  309. package/dist/metro/index.d.ts.map +1 -0
  310. package/dist/metro/index.js +52 -0
  311. package/dist/metro/index.js.map +1 -0
  312. package/dist/metro/transformer.d.ts +21 -0
  313. package/dist/metro/transformer.d.ts.map +1 -0
  314. package/dist/metro/transformer.js +71 -0
  315. package/dist/metro/transformer.js.map +1 -0
  316. package/dist/next/index.d.ts +18 -0
  317. package/dist/next/index.d.ts.map +1 -0
  318. package/dist/next/index.js +92 -0
  319. package/dist/next/index.js.map +1 -0
  320. package/dist/next/loader.d.ts +16 -0
  321. package/dist/next/loader.d.ts.map +1 -0
  322. package/dist/next/loader.js +282 -0
  323. package/dist/next/loader.js.map +1 -0
  324. package/dist/node/Host.d.ts +80 -0
  325. package/dist/node/Host.d.ts.map +1 -0
  326. package/dist/node/Host.js +882 -0
  327. package/dist/node/Host.js.map +1 -0
  328. package/dist/node/index.d.ts +7 -0
  329. package/dist/node/index.d.ts.map +1 -0
  330. package/dist/node/index.js +7 -0
  331. package/dist/node/index.js.map +1 -0
  332. package/dist/react-native/Host.d.ts +76 -0
  333. package/dist/react-native/Host.d.ts.map +1 -0
  334. package/dist/react-native/Host.js +209 -0
  335. package/dist/react-native/Host.js.map +1 -0
  336. package/dist/react-native/StyleSheet.d.ts +226 -0
  337. package/dist/react-native/StyleSheet.d.ts.map +1 -0
  338. package/dist/react-native/StyleSheet.js +606 -0
  339. package/dist/react-native/StyleSheet.js.map +1 -0
  340. package/dist/react-native/Variants.d.ts +38 -0
  341. package/dist/react-native/Variants.d.ts.map +1 -0
  342. package/dist/react-native/Variants.js +66 -0
  343. package/dist/react-native/Variants.js.map +1 -0
  344. package/dist/react-native/index.d.ts +8 -0
  345. package/dist/react-native/index.d.ts.map +1 -0
  346. package/dist/react-native/index.js +8 -0
  347. package/dist/react-native/index.js.map +1 -0
  348. package/dist/react-native/internal/Color.d.ts +7 -0
  349. package/dist/react-native/internal/Color.d.ts.map +1 -0
  350. package/dist/react-native/internal/Color.js +93 -0
  351. package/dist/react-native/internal/Color.js.map +1 -0
  352. package/dist/react-native/internal/NativeSchema.d.ts +5138 -0
  353. package/dist/react-native/internal/NativeSchema.d.ts.map +1 -0
  354. package/dist/react-native/internal/NativeSchema.js +3097 -0
  355. package/dist/react-native/internal/NativeSchema.js.map +1 -0
  356. package/dist/react-native/internal/Scalar.d.ts +95 -0
  357. package/dist/react-native/internal/Scalar.d.ts.map +1 -0
  358. package/dist/react-native/internal/Scalar.js +199 -0
  359. package/dist/react-native/internal/Scalar.js.map +1 -0
  360. package/dist/react-native/internal/Values.d.ts +5 -0
  361. package/dist/react-native/internal/Values.d.ts.map +1 -0
  362. package/dist/react-native/internal/Values.js +65 -0
  363. package/dist/react-native/internal/Values.js.map +1 -0
  364. package/dist/react-native/react.d.ts +22 -0
  365. package/dist/react-native/react.d.ts.map +1 -0
  366. package/dist/react-native/react.js +26 -0
  367. package/dist/react-native/react.js.map +1 -0
  368. package/dist/reset.css +244 -0
  369. package/dist/runtime/Appearance.d.ts +55 -0
  370. package/dist/runtime/Appearance.d.ts.map +1 -0
  371. package/dist/runtime/Appearance.js +84 -0
  372. package/dist/runtime/Appearance.js.map +1 -0
  373. package/dist/runtime/Composition.d.ts +46 -0
  374. package/dist/runtime/Composition.d.ts.map +1 -0
  375. package/dist/runtime/Composition.js +52 -0
  376. package/dist/runtime/Composition.js.map +1 -0
  377. package/dist/runtime/CompositionHtml.d.ts +15 -0
  378. package/dist/runtime/CompositionHtml.d.ts.map +1 -0
  379. package/dist/runtime/CompositionHtml.js +20 -0
  380. package/dist/runtime/CompositionHtml.js.map +1 -0
  381. package/dist/runtime/ConditionalRecipe.d.ts +30 -0
  382. package/dist/runtime/ConditionalRecipe.d.ts.map +1 -0
  383. package/dist/runtime/ConditionalRecipe.js +39 -0
  384. package/dist/runtime/ConditionalRecipe.js.map +1 -0
  385. package/dist/runtime/Dynamic.d.ts +19 -0
  386. package/dist/runtime/Dynamic.d.ts.map +1 -0
  387. package/dist/runtime/Dynamic.js +22 -0
  388. package/dist/runtime/Dynamic.js.map +1 -0
  389. package/dist/runtime/Html.d.ts +32 -0
  390. package/dist/runtime/Html.d.ts.map +1 -0
  391. package/dist/runtime/Html.js +63 -0
  392. package/dist/runtime/Html.js.map +1 -0
  393. package/dist/runtime/Native.d.ts +48 -0
  394. package/dist/runtime/Native.d.ts.map +1 -0
  395. package/dist/runtime/Native.js +78 -0
  396. package/dist/runtime/Native.js.map +1 -0
  397. package/dist/runtime/NativeContext.d.ts +17 -0
  398. package/dist/runtime/NativeContext.d.ts.map +1 -0
  399. package/dist/runtime/NativeContext.js +47 -0
  400. package/dist/runtime/NativeContext.js.map +1 -0
  401. package/dist/runtime/NativeDynamic.d.ts +47 -0
  402. package/dist/runtime/NativeDynamic.d.ts.map +1 -0
  403. package/dist/runtime/NativeDynamic.js +141 -0
  404. package/dist/runtime/NativeDynamic.js.map +1 -0
  405. package/dist/runtime/PayloadRecipe.d.ts +22 -0
  406. package/dist/runtime/PayloadRecipe.d.ts.map +1 -0
  407. package/dist/runtime/PayloadRecipe.js +59 -0
  408. package/dist/runtime/PayloadRecipe.js.map +1 -0
  409. package/dist/runtime/Props.d.ts +21 -0
  410. package/dist/runtime/Props.d.ts.map +1 -0
  411. package/dist/runtime/Props.js +17 -0
  412. package/dist/runtime/Props.js.map +1 -0
  413. package/dist/runtime/Recipe.d.ts +52 -0
  414. package/dist/runtime/Recipe.d.ts.map +1 -0
  415. package/dist/runtime/Recipe.js +30 -0
  416. package/dist/runtime/Recipe.js.map +1 -0
  417. package/dist/runtime/Selection.d.ts +31 -0
  418. package/dist/runtime/Selection.d.ts.map +1 -0
  419. package/dist/runtime/Selection.js +30 -0
  420. package/dist/runtime/Selection.js.map +1 -0
  421. package/dist/runtime/Variable.d.ts +6 -0
  422. package/dist/runtime/Variable.d.ts.map +1 -0
  423. package/dist/runtime/Variable.js +10 -0
  424. package/dist/runtime/Variable.js.map +1 -0
  425. package/dist/runtime/index.d.ts +33 -0
  426. package/dist/runtime/index.d.ts.map +1 -0
  427. package/dist/runtime/index.js +33 -0
  428. package/dist/runtime/index.js.map +1 -0
  429. package/dist/styleFunction.d.ts +72 -0
  430. package/dist/styleFunction.d.ts.map +1 -0
  431. package/dist/styleFunction.js +18 -0
  432. package/dist/styleFunction.js.map +1 -0
  433. package/dist/themes/LICENSE.tailwind +21 -0
  434. package/dist/variable.d.ts +50 -0
  435. package/dist/variable.d.ts.map +1 -0
  436. package/dist/variable.js +20 -0
  437. package/dist/variable.js.map +1 -0
  438. package/dist/variants.d.ts +84 -0
  439. package/dist/variants.d.ts.map +1 -0
  440. package/dist/variants.js +21 -0
  441. package/dist/variants.js.map +1 -0
  442. package/dist/vite/index.d.ts +24 -0
  443. package/dist/vite/index.d.ts.map +1 -0
  444. package/dist/vite/index.js +1089 -0
  445. package/dist/vite/index.js.map +1 -0
  446. package/dist/web/Css.d.ts +81 -0
  447. package/dist/web/Css.d.ts.map +1 -0
  448. package/dist/web/Css.js +593 -0
  449. package/dist/web/Css.js.map +1 -0
  450. package/dist/web/colorProfile.d.ts +28 -0
  451. package/dist/web/colorProfile.d.ts.map +1 -0
  452. package/dist/web/colorProfile.js +8 -0
  453. package/dist/web/colorProfile.js.map +1 -0
  454. package/dist/web/counterStyle.d.ts +48 -0
  455. package/dist/web/counterStyle.d.ts.map +1 -0
  456. package/dist/web/counterStyle.js +8 -0
  457. package/dist/web/counterStyle.js.map +1 -0
  458. package/dist/web/cssFunction.d.ts +80 -0
  459. package/dist/web/cssFunction.d.ts.map +1 -0
  460. package/dist/web/cssFunction.js +18 -0
  461. package/dist/web/cssFunction.js.map +1 -0
  462. package/dist/web/customMedia.d.ts +12 -0
  463. package/dist/web/customMedia.d.ts.map +1 -0
  464. package/dist/web/customMedia.js +7 -0
  465. package/dist/web/customMedia.js.map +1 -0
  466. package/dist/web/fontFace.d.ts +26 -0
  467. package/dist/web/fontFace.d.ts.map +1 -0
  468. package/dist/web/fontFace.js +7 -0
  469. package/dist/web/fontFace.js.map +1 -0
  470. package/dist/web/fontFeatureValues.d.ts +40 -0
  471. package/dist/web/fontFeatureValues.d.ts.map +1 -0
  472. package/dist/web/fontFeatureValues.js +7 -0
  473. package/dist/web/fontFeatureValues.js.map +1 -0
  474. package/dist/web/fontPaletteValues.d.ts +21 -0
  475. package/dist/web/fontPaletteValues.d.ts.map +1 -0
  476. package/dist/web/fontPaletteValues.js +9 -0
  477. package/dist/web/fontPaletteValues.js.map +1 -0
  478. package/dist/web/global.d.ts +19 -0
  479. package/dist/web/global.d.ts.map +1 -0
  480. package/dist/web/global.js +6 -0
  481. package/dist/web/global.js.map +1 -0
  482. package/dist/web/importCss.d.ts +18 -0
  483. package/dist/web/importCss.d.ts.map +1 -0
  484. package/dist/web/importCss.js +7 -0
  485. package/dist/web/importCss.js.map +1 -0
  486. package/dist/web/index.d.ts +22 -0
  487. package/dist/web/index.d.ts.map +1 -0
  488. package/dist/web/index.js +22 -0
  489. package/dist/web/index.js.map +1 -0
  490. package/dist/web/internal/Block.d.ts +18 -0
  491. package/dist/web/internal/Block.d.ts.map +1 -0
  492. package/dist/web/internal/Block.js +13 -0
  493. package/dist/web/internal/Block.js.map +1 -0
  494. package/dist/web/internal/ClassName.d.ts +19 -0
  495. package/dist/web/internal/ClassName.d.ts.map +1 -0
  496. package/dist/web/internal/ClassName.js +77 -0
  497. package/dist/web/internal/ClassName.js.map +1 -0
  498. package/dist/web/internal/Context.d.ts +11 -0
  499. package/dist/web/internal/Context.d.ts.map +1 -0
  500. package/dist/web/internal/Context.js +2 -0
  501. package/dist/web/internal/Context.js.map +1 -0
  502. package/dist/web/internal/Contributions.d.ts +70 -0
  503. package/dist/web/internal/Contributions.d.ts.map +1 -0
  504. package/dist/web/internal/Contributions.js +109 -0
  505. package/dist/web/internal/Contributions.js.map +1 -0
  506. package/dist/web/internal/Namespace.d.ts +13 -0
  507. package/dist/web/internal/Namespace.d.ts.map +1 -0
  508. package/dist/web/internal/Namespace.js +13 -0
  509. package/dist/web/internal/Namespace.js.map +1 -0
  510. package/dist/web/internal/Themes.d.ts +13 -0
  511. package/dist/web/internal/Themes.d.ts.map +1 -0
  512. package/dist/web/internal/Themes.js +96 -0
  513. package/dist/web/internal/Themes.js.map +1 -0
  514. package/dist/web/keyframes.d.ts +14 -0
  515. package/dist/web/keyframes.d.ts.map +1 -0
  516. package/dist/web/keyframes.js +8 -0
  517. package/dist/web/keyframes.js.map +1 -0
  518. package/dist/web/layers.d.ts +4 -0
  519. package/dist/web/layers.d.ts.map +1 -0
  520. package/dist/web/layers.js +7 -0
  521. package/dist/web/layers.js.map +1 -0
  522. package/dist/web/namespace.d.ts +14 -0
  523. package/dist/web/namespace.d.ts.map +1 -0
  524. package/dist/web/namespace.js +7 -0
  525. package/dist/web/namespace.js.map +1 -0
  526. package/dist/web/page.d.ts +38 -0
  527. package/dist/web/page.d.ts.map +1 -0
  528. package/dist/web/page.js +7 -0
  529. package/dist/web/page.js.map +1 -0
  530. package/dist/web/positionTry.d.ts +14 -0
  531. package/dist/web/positionTry.d.ts.map +1 -0
  532. package/dist/web/positionTry.js +9 -0
  533. package/dist/web/positionTry.js.map +1 -0
  534. package/dist/web/property.d.ts +24 -0
  535. package/dist/web/property.d.ts.map +1 -0
  536. package/dist/web/property.js +7 -0
  537. package/dist/web/property.js.map +1 -0
  538. package/dist/web/viewTransition.d.ts +29 -0
  539. package/dist/web/viewTransition.d.ts.map +1 -0
  540. package/dist/web/viewTransition.js +7 -0
  541. package/dist/web/viewTransition.js.map +1 -0
  542. package/package.json +136 -10
  543. package/src/Config.ts +690 -0
  544. package/src/Props.ts +8 -0
  545. package/src/Style.ts +748 -0
  546. package/src/Theme.ts +713 -0
  547. package/src/babel/NativeEdits.ts +273 -0
  548. package/src/babel/NativeJsx.ts +260 -0
  549. package/src/babel/index.ts +332 -0
  550. package/src/cli/index.ts +196 -0
  551. package/src/compiler/Graph.ts +1586 -0
  552. package/src/compiler/Native.ts +801 -0
  553. package/src/compiler/Source.ts +1550 -0
  554. package/src/compiler/Transform.ts +1235 -0
  555. package/src/compiler/index.ts +12 -0
  556. package/src/compiler/internal/Applications.ts +378 -0
  557. package/src/compiler/internal/AtRules.ts +202 -0
  558. package/src/compiler/internal/Catalogs.ts +114 -0
  559. package/src/compiler/internal/ColorProfiles.ts +93 -0
  560. package/src/compiler/internal/CompositionBindings.ts +120 -0
  561. package/src/compiler/internal/Compositions.ts +629 -0
  562. package/src/compiler/internal/Configurations.ts +244 -0
  563. package/src/compiler/internal/Contract.ts +846 -0
  564. package/src/compiler/internal/Contributions.ts +1507 -0
  565. package/src/compiler/internal/Descriptors.ts +238 -0
  566. package/src/compiler/internal/Dynamic.ts +266 -0
  567. package/src/compiler/internal/Edits.ts +13 -0
  568. package/src/compiler/internal/Expression.ts +135 -0
  569. package/src/compiler/internal/Functions.ts +206 -0
  570. package/src/compiler/internal/Identifiers.ts +124 -0
  571. package/src/compiler/internal/Keyframes.ts +62 -0
  572. package/src/compiler/internal/Namespaces.ts +296 -0
  573. package/src/compiler/internal/NativeBindings.ts +151 -0
  574. package/src/compiler/internal/PackedStyles.ts +464 -0
  575. package/src/compiler/internal/Properties.ts +121 -0
  576. package/src/compiler/internal/RecipeConditions.ts +139 -0
  577. package/src/compiler/internal/RecipePayloads.ts +132 -0
  578. package/src/compiler/internal/Recipes.ts +531 -0
  579. package/src/compiler/internal/Relative.ts +87 -0
  580. package/src/compiler/internal/Scope.ts +36 -0
  581. package/src/compiler/internal/Selectors.ts +334 -0
  582. package/src/compiler/internal/Static.ts +783 -0
  583. package/src/compiler/internal/Stylesheets.ts +361 -0
  584. package/src/compiler/internal/Syntax.ts +31 -0
  585. package/src/compiler/internal/Themes.ts +1794 -0
  586. package/src/compiler/internal/Variables.ts +497 -0
  587. package/src/compiler/internal/ViewTransitions.ts +82 -0
  588. package/src/cx.ts +98 -0
  589. package/src/default.ts +484 -0
  590. package/src/index.ts +20 -0
  591. package/src/internal/Authoring.ts +199 -0
  592. package/src/internal/Binding.ts +187 -0
  593. package/src/internal/BindingDomains.ts +458 -0
  594. package/src/internal/Cascade.ts +165 -0
  595. package/src/internal/Compound.ts +522 -0
  596. package/src/internal/Condition.ts +283 -0
  597. package/src/internal/Corner.ts +17 -0
  598. package/src/internal/FunctionSyntax.ts +271 -0
  599. package/src/internal/FunctionValue.ts +96 -0
  600. package/src/internal/Geometry.ts +30 -0
  601. package/src/internal/Grid.ts +67 -0
  602. package/src/internal/Identifier.ts +14 -0
  603. package/src/internal/Identity.ts +89 -0
  604. package/src/internal/Lexical.ts +202 -0
  605. package/src/internal/Literal.ts +3820 -0
  606. package/src/internal/NativeProperties.ts +936 -0
  607. package/src/internal/Numeric.ts +77 -0
  608. package/src/internal/Query.ts +87 -0
  609. package/src/internal/Recipe.ts +17 -0
  610. package/src/internal/RuleReference.ts +102 -0
  611. package/src/internal/Scheme.ts +20 -0
  612. package/src/internal/Shorthands.ts +120 -0
  613. package/src/internal/Targets.ts +162 -0
  614. package/src/internal/Token.ts +380 -0
  615. package/src/internal/Tuple.ts +29 -0
  616. package/src/internal/Value.ts +320 -0
  617. package/src/metro/Graph.ts +78 -0
  618. package/src/metro/Watch.ts +88 -0
  619. package/src/metro/index.ts +99 -0
  620. package/src/metro/transformer.ts +97 -0
  621. package/src/next/index.ts +114 -0
  622. package/src/next/loader.ts +369 -0
  623. package/src/node/Host.ts +1204 -0
  624. package/src/node/index.ts +6 -0
  625. package/src/react-native/Host.ts +289 -0
  626. package/src/react-native/StyleSheet.ts +1084 -0
  627. package/src/react-native/Variants.ts +122 -0
  628. package/src/react-native/index.ts +7 -0
  629. package/src/react-native/internal/Color.ts +110 -0
  630. package/src/react-native/internal/NativeSchema.ts +3096 -0
  631. package/src/react-native/internal/Scalar.ts +253 -0
  632. package/src/react-native/internal/Values.ts +87 -0
  633. package/src/react-native/react.ts +47 -0
  634. package/src/reset.css +244 -0
  635. package/src/runtime/Appearance.ts +155 -0
  636. package/src/runtime/Composition.ts +87 -0
  637. package/src/runtime/CompositionHtml.ts +38 -0
  638. package/src/runtime/ConditionalRecipe.ts +70 -0
  639. package/src/runtime/Dynamic.ts +51 -0
  640. package/src/runtime/Html.ts +91 -0
  641. package/src/runtime/Native.ts +144 -0
  642. package/src/runtime/NativeContext.ts +74 -0
  643. package/src/runtime/NativeDynamic.ts +246 -0
  644. package/src/runtime/PayloadRecipe.ts +96 -0
  645. package/src/runtime/Props.ts +33 -0
  646. package/src/runtime/Recipe.ts +74 -0
  647. package/src/runtime/Selection.ts +82 -0
  648. package/src/runtime/Variable.ts +15 -0
  649. package/src/runtime/index.ts +45 -0
  650. package/src/styleFunction.ts +138 -0
  651. package/src/themes/LICENSE.tailwind +21 -0
  652. package/src/variable.ts +105 -0
  653. package/src/variants.ts +218 -0
  654. package/src/vite/index.ts +1473 -0
  655. package/src/web/Css.ts +801 -0
  656. package/src/web/colorProfile.ts +60 -0
  657. package/src/web/counterStyle.ts +82 -0
  658. package/src/web/cssFunction.ts +181 -0
  659. package/src/web/customMedia.ts +16 -0
  660. package/src/web/fontFace.ts +41 -0
  661. package/src/web/fontFeatureValues.ts +79 -0
  662. package/src/web/fontPaletteValues.ts +42 -0
  663. package/src/web/global.ts +39 -0
  664. package/src/web/importCss.ts +23 -0
  665. package/src/web/index.ts +22 -0
  666. package/src/web/internal/Block.ts +29 -0
  667. package/src/web/internal/ClassName.ts +112 -0
  668. package/src/web/internal/Context.ts +16 -0
  669. package/src/web/internal/Contributions.ts +219 -0
  670. package/src/web/internal/Namespace.ts +21 -0
  671. package/src/web/internal/Themes.ts +133 -0
  672. package/src/web/keyframes.ts +43 -0
  673. package/src/web/layers.ts +6 -0
  674. package/src/web/namespace.ts +19 -0
  675. package/src/web/page.ts +140 -0
  676. package/src/web/positionTry.ts +71 -0
  677. package/src/web/property.ts +35 -0
  678. package/src/web/viewTransition.ts +89 -0
@@ -0,0 +1,1586 @@
1
+ /**
2
+ * Links a closed graph of source modules without executing code or reading files.
3
+ * @module
4
+ */
5
+ import * as Contributions from './internal/Contributions.js'
6
+ import * as Stylesheets from './internal/Stylesheets.js'
7
+ import type * as Mapping from '@jridgewell/gen-mapping'
8
+ import * as Css from '../web/Css.js'
9
+ import * as Native from './Native.js'
10
+ import * as Edits from './internal/Edits.js'
11
+ import * as Identity from '../internal/Identity.js'
12
+ import type * as Ast from '@oxc-project/types'
13
+ import * as Parser from 'oxc-parser'
14
+ import * as Syntax from './internal/Syntax.js'
15
+ import * as Walker from 'oxc-walker'
16
+ import type * as Theme from '../Theme.js'
17
+ import * as Token from '../internal/Token.js'
18
+ import * as Contract from './internal/Contract.js'
19
+ import * as Relative from './internal/Relative.js'
20
+ import * as Themes from './internal/Themes.js'
21
+ import * as Source from './Source.js'
22
+ import * as Scope from './internal/Scope.js'
23
+ import * as Static from './internal/Static.js'
24
+ import * as Transform from './Transform.js'
25
+
26
+ /** Compiles supplied modules with shared theme contracts and dependency metadata. */
27
+ export function compile(options: compile.Options): compile.ReturnType {
28
+ return build(options).result
29
+ }
30
+
31
+ /** Input and output of graph compilation. */
32
+ export declare namespace compile {
33
+ /** Errors raised while extracting or compiling a source graph. */
34
+ type ErrorType =
35
+ | Native.compile.ErrorType
36
+ | Source.ExtractError
37
+ | Transform.compile.ErrorType
38
+
39
+ /** Source modules available for relative import resolution. */
40
+ type Options = {
41
+ /** Host syntax from the same immutable source snapshot. */
42
+ readonly [Syntax.cache]?:
43
+ | ReadonlyMap<string, Parser.ParseResult>
44
+ | undefined
45
+ /** Rewrite authoring calls. False emits CSS for unchanged source. */
46
+ readonly compiler?: boolean | undefined
47
+ /** Whether compiled applications can be combined with one another. */
48
+ readonly composition?: Css.compile.Options['composition']
49
+ /** Default CSS representation for definitions without an explicit mode. */
50
+ readonly cssOutput?: Css.compile.Options['cssOutput']
51
+ /** Serialized library contracts keyed by host-resolved module identity. Runtime modules stay external to this graph. */
52
+ readonly contracts?: Readonly<Record<string, string>> | undefined
53
+ /** Stable declaration names for CSS-only development updates. */
54
+ readonly development?: boolean | undefined
55
+ /** Host-resolved static runtime imports keyed by module ID and source specifier; null marks externals. The host owns dynamic imports when supplied. Omit for closed relative-graph resolution. */
56
+ readonly imports?:
57
+ | Readonly<Record<string, Readonly<Record<string, string | null>>>>
58
+ | undefined
59
+ /** Native output context. Omit to compile web modules and CSS. */
60
+ readonly native?:
61
+ | Omit<
62
+ Native.compile.Options,
63
+ 'moduleId' | 'source' | typeof Themes.context
64
+ >
65
+ | undefined
66
+ /** Complete source graph keyed by stable package-relative module identities. */
67
+ readonly modules: Readonly<Record<string, string>>
68
+ }
69
+
70
+ /** Compiled modules and their direct source dependencies. */
71
+ type ReturnType = {
72
+ /** Versioned compiler-only JSON per module; publish beside the compiled entrypoint as <entry>.zyzz.json. */
73
+ readonly contracts: Readonly<Record<string, string>>
74
+ /** Direct static runtime source and library-contract dependencies, keyed by module identity. */
75
+ readonly dependencies: Readonly<Record<string, readonly string[]>>
76
+ /** One eager stylesheet for all supplied modules. Load before module CSS. */
77
+ readonly sharedCss?: string | undefined
78
+ /** Source map for source-owned and packed global contributions. */
79
+ readonly sharedCssMap?: Mapping.EncodedSourceMap | undefined
80
+ /** Trusted source or contract owner for each shared asset placeholder. */
81
+ readonly sharedAssetOwners?: Readonly<Record<string, string>> | undefined
82
+ /** Portable asset targets keyed by emitted compiler URL placeholders. */
83
+ readonly sharedAssets?: Readonly<Record<string, string>> | undefined
84
+ /** Rewritten modules and their stylesheets/maps. Load the CSS for the graph together. */
85
+ readonly modules: Readonly<Record<string, Transform.compile.ReturnType>>
86
+ }
87
+ }
88
+
89
+ /** Creates an isolated compiler that retains only the last successful graph. */
90
+ export function create(): create.ReturnType {
91
+ let previous: Cache | undefined
92
+
93
+ return Object.freeze({
94
+ compile(options: compile.Options): compile.ReturnType {
95
+ const next = build(options, previous)
96
+
97
+ previous = next
98
+
99
+ return next.result
100
+ },
101
+ })
102
+ }
103
+
104
+ /** Incremental graph compiler contracts. */
105
+ export declare namespace create {
106
+ /** Explicitly owned compilation state; dropping the compiler releases its cache. */
107
+ type ReturnType = {
108
+ /** Compiles a complete source snapshot, reusing unaffected work across calls. */
109
+ readonly compile: typeof compile
110
+ }
111
+ }
112
+
113
+ type Cache = {
114
+ compiler: boolean
115
+ composition: Css.compile.Options['composition']
116
+ cssOutput: Css.compile.Options['cssOutput']
117
+
118
+ contracts: string
119
+ development: boolean
120
+ extracted: ReadonlyMap<string, Source.extract.ReturnType>
121
+ libraries: Readonly<Record<string, ReturnType<typeof Contract.read>>>
122
+ resolutions: Readonly<Record<string, string>>
123
+ native: compile.Options['native']
124
+ result: compile.ReturnType
125
+ schemes: boolean
126
+ sources: Readonly<Record<string, string>>
127
+ themes: Readonly<Record<string, Theme.Definition>>
128
+ }
129
+
130
+ function build(options: compile.Options, cache?: Cache): Cache {
131
+ if (
132
+ !!cache?.native !== !!options.native ||
133
+ cache?.native?.[Edits.runtime] !== options.native?.[Edits.runtime] ||
134
+ Object.keys(cache?.native ?? {}).length !==
135
+ Object.keys(options.native ?? {}).length ||
136
+ Object.entries(cache?.native ?? {}).some(([key, value]) => {
137
+ const next = Reflect.get(options.native ?? {}, key)
138
+ if (key !== 'fonts' && key !== 'themes' && key !== 'units')
139
+ return value !== next
140
+
141
+ return (
142
+ !!value !== !!next ||
143
+ Object.keys(value ?? {}).length !== Object.keys(next ?? {}).length ||
144
+ Object.entries(value ?? {}).some(
145
+ ([name, entry]) => Reflect.get(next ?? {}, name) !== entry,
146
+ )
147
+ )
148
+ })
149
+ )
150
+ cache = undefined
151
+ if (options.native && options.compiler === false)
152
+ throw new Native.CompileError(
153
+ 'Native graph compilation requires source rewriting.',
154
+ )
155
+ if (cache?.compiler !== (options.compiler !== false)) cache = undefined
156
+ if (cache?.cssOutput !== options.cssOutput) cache = undefined
157
+ if (cache?.composition !== options.composition) cache = undefined
158
+ const ids = Object.keys(options.modules).sort()
159
+ const programs = new Map<string, ReturnType<typeof Syntax.parse>>()
160
+ function parse(input: Syntax.parse.Options) {
161
+ const cached =
162
+ programs.get(input.moduleId) ?? options[Syntax.cache]?.get(input.moduleId)
163
+ if (cached) return cached
164
+ const parsed = Syntax.parse(input)
165
+ programs.set(input.moduleId, parsed)
166
+ return parsed
167
+ }
168
+
169
+ const contracts = JSON.stringify(
170
+ Object.entries(options.contracts ?? {}).sort(([a], [b]) =>
171
+ a.localeCompare(b),
172
+ ),
173
+ )
174
+
175
+ const resolutions = Object.fromEntries(
176
+ [...new Set([...ids, ...Object.keys(options.imports ?? {})])]
177
+ .sort()
178
+ .map((id) => [
179
+ id,
180
+ options.imports === undefined
181
+ ? 'relative'
182
+ : JSON.stringify(
183
+ Object.entries(options.imports[id] ?? {}).sort(([a], [b]) =>
184
+ a.localeCompare(b),
185
+ ),
186
+ ),
187
+ ]),
188
+ )
189
+
190
+ // File-set changes can alter extensionless resolution even without source edits.
191
+ const previous = (() => {
192
+ if (
193
+ cache &&
194
+ cache.contracts === contracts &&
195
+ cache.development === !!options.development &&
196
+ ids.length === Object.keys(cache.sources).length &&
197
+ ids.every((id) => Object.hasOwn(cache.sources, id))
198
+ ) {
199
+ return cache
200
+ }
201
+
202
+ return undefined
203
+ })()
204
+ if (
205
+ previous &&
206
+ Object.keys(resolutions).length ===
207
+ Object.keys(previous.resolutions).length &&
208
+ Object.entries(resolutions).every(
209
+ ([id, value]) => value === previous.resolutions[id],
210
+ ) &&
211
+ ids.every(
212
+ (id) =>
213
+ options.modules[id] === previous.sources[id] &&
214
+ resolutions[id] === previous.resolutions[id],
215
+ )
216
+ )
217
+ return previous
218
+
219
+ const dependencies: Record<string, readonly string[]> = Object.create(null)
220
+ const extracted = new Map<string, Source.extract.ReturnType>()
221
+ const identifiers = new Map<string, Set<string>>()
222
+ const owners: Record<string, NonNullable<Themes.Context['owners']>[string]> =
223
+ Object.create(null)
224
+ const themes: Record<string, Theme.Definition> = Object.create(null)
225
+ const visiting = new Set<string>()
226
+ const libraries: Record<
227
+ string,
228
+ ReturnType<typeof Contract.read>
229
+ > = Object.create(null)
230
+ const identities = new Map<string, Token.Contract>()
231
+ const variableSlots = new Map<
232
+ string,
233
+ { owner: string; binding: string; type: string }
234
+ >()
235
+
236
+ function validateLibraryLink(link: Themes.Link, owner: string) {
237
+ const variableOwner = owner.includes('/')
238
+ ? (link.call.variableOwner ?? owner)
239
+ : owner
240
+
241
+ for (const slot of Object.values(link.call.variables ?? {})) {
242
+ const previous = variableSlots.get(slot.name)
243
+ if (
244
+ previous &&
245
+ (previous.owner !== variableOwner ||
246
+ previous.binding !== link.binding ||
247
+ previous.type !== slot.type)
248
+ )
249
+ throw new Error(
250
+ `Conflicting packed variable identity: ${slot.name}; compile libraries with package-qualified module IDs.`,
251
+ )
252
+
253
+ variableSlots.set(slot.name, {
254
+ owner: variableOwner,
255
+ binding: link.binding,
256
+ type: slot.type,
257
+ })
258
+ }
259
+
260
+ for (const member of Object.values(link.members ?? {}))
261
+ validateLibraryLink(member, owner)
262
+ }
263
+
264
+ for (const [id, source] of Object.entries(options.contracts ?? {})) {
265
+ if (Object.hasOwn(options.modules, id))
266
+ fail(id, 'A module cannot supply both source and a library contract.')
267
+
268
+ try {
269
+ const library =
270
+ previous?.libraries[id] ?? Contract.read(source, identities, id)
271
+
272
+ for (const link of Object.values(library.links))
273
+ validateLibraryLink(link, id)
274
+
275
+ for (const [name, theme] of Object.entries(library.themes)) {
276
+ if (
277
+ themes[name] &&
278
+ Contract.write({}, { [name]: themes[name]! }) !==
279
+ Contract.write({}, { [name]: theme })
280
+ )
281
+ throw new Error(`Conflicting library theme identity: ${name}`)
282
+
283
+ themes[name] = theme
284
+ }
285
+
286
+ libraries[id] = library
287
+ } catch (error) {
288
+ fail(id, `Invalid library contract: ${(error as Error).message}`)
289
+ }
290
+ }
291
+
292
+ function fail(
293
+ moduleId: string,
294
+ message: string,
295
+ node?: Pick<Ast.Node, 'start' | 'end'>,
296
+ ): never {
297
+ throw new Source.ExtractError([
298
+ {
299
+ code: 'unsupported_syntax',
300
+ end: node?.end ?? 0,
301
+ message,
302
+ source: moduleId,
303
+ start: node?.start ?? 0,
304
+ },
305
+ ])
306
+ }
307
+
308
+ function resolve(
309
+ moduleId: string,
310
+ specifier: string,
311
+ node: Pick<Ast.Node, 'start' | 'end'> = { start: 0, end: 0 },
312
+ ): string | undefined {
313
+ if (options.imports !== undefined) {
314
+ const imports = options.imports[moduleId]
315
+
316
+ if (!imports || !Object.hasOwn(imports, specifier))
317
+ fail(moduleId, `Missing host resolution: ${specifier}`, node)
318
+
319
+ const target = imports[specifier]
320
+ if (target === null) return undefined
321
+
322
+ if (
323
+ target === undefined ||
324
+ (!Object.hasOwn(options.modules, target) &&
325
+ !Object.hasOwn(libraries, target))
326
+ )
327
+ fail(moduleId, `Missing host source module: ${specifier}`, node)
328
+
329
+ return target
330
+ }
331
+
332
+ try {
333
+ return Relative.resolve({ moduleId, modules: options.modules, specifier })
334
+ } catch (error) {
335
+ fail(moduleId, (error as Error).message, node)
336
+ }
337
+ }
338
+
339
+ const constants = new Map<string, Ast.Node | undefined>()
340
+ function constant(
341
+ moduleId: string,
342
+ name: string,
343
+ active = new Set<string>(),
344
+ ): Ast.Node | undefined {
345
+ const key = JSON.stringify([moduleId, name])
346
+ if (constants.has(key)) return constants.get(key)
347
+ if (active.has(key) || !Object.hasOwn(options.modules, moduleId))
348
+ return undefined
349
+ const next = new Set(active).add(key)
350
+ const program = parse({
351
+ moduleId,
352
+ source: options.modules[moduleId]!,
353
+ }).program
354
+ const imports: Record<string, Ast.Node> = Object.create(null)
355
+ let local = name
356
+ let exported = false
357
+ let direct: Ast.Node | undefined
358
+ const stars: string[] = []
359
+ for (const statement of program.body) {
360
+ if (
361
+ statement.type === 'ImportDeclaration' &&
362
+ statement.importKind !== 'type'
363
+ ) {
364
+ const target = resolve(moduleId, statement.source.value, statement)
365
+ if (!target) continue
366
+ for (const specifier of statement.specifiers) {
367
+ if (
368
+ specifier.type === 'ImportNamespaceSpecifier' ||
369
+ (specifier.type === 'ImportSpecifier' &&
370
+ specifier.importKind === 'type')
371
+ )
372
+ continue
373
+ const imported =
374
+ specifier.type === 'ImportDefaultSpecifier'
375
+ ? 'default'
376
+ : specifier.imported.type === 'Identifier'
377
+ ? specifier.imported.name
378
+ : specifier.imported.value
379
+ const value = constant(target, imported, next)
380
+ if (value) imports[specifier.local.name] = relocate(value, specifier)
381
+ }
382
+ }
383
+ if (statement.type === 'ExportDefaultDeclaration' && name === 'default') {
384
+ direct = statement.declaration
385
+ exported = true
386
+ }
387
+ if (
388
+ statement.type === 'ExportAllDeclaration' &&
389
+ statement.exportKind !== 'type' &&
390
+ !statement.exported &&
391
+ name !== 'default'
392
+ ) {
393
+ const target = resolve(moduleId, statement.source.value, statement)
394
+ if (target) stars.push(target)
395
+ }
396
+ if (
397
+ statement.type !== 'ExportNamedDeclaration' ||
398
+ statement.exportKind === 'type'
399
+ )
400
+ continue
401
+ if (statement.declaration?.type === 'VariableDeclaration')
402
+ exported ||= statement.declaration.declarations.some(
403
+ (value) => value.id.type === 'Identifier' && value.id.name === name,
404
+ )
405
+ for (const specifier of statement.specifiers) {
406
+ if (specifier.exportKind === 'type') continue
407
+ const alias =
408
+ specifier.exported.type === 'Identifier'
409
+ ? specifier.exported.name
410
+ : specifier.exported.value
411
+ if (alias !== name) continue
412
+ local =
413
+ specifier.local.type === 'Identifier'
414
+ ? specifier.local.name
415
+ : specifier.local.value
416
+ if (statement.source) {
417
+ const target = resolve(moduleId, statement.source.value, statement)
418
+ return target ? constant(target, local, next) : undefined
419
+ }
420
+ exported = true
421
+ }
422
+ }
423
+ if (!exported) {
424
+ const candidates = [
425
+ ...new Set(
426
+ stars
427
+ .map((target) => constant(target, name, next))
428
+ .filter((value) => value !== undefined),
429
+ ),
430
+ ]
431
+ return candidates.length === 1 ? candidates[0] : undefined
432
+ }
433
+ const scope = new Scope.Tracker({ preserveExitedScopes: true })
434
+ Walker.walk(program, { scopeTracker: scope })
435
+ scope.freeze()
436
+ let value: Ast.Node | undefined
437
+ try {
438
+ const data = Static.collect(program, scope, imports)
439
+ value = direct
440
+ ? data.normalize(direct, new Set(), new Set(), true)
441
+ : data.exported(local)
442
+ } catch {
443
+ return undefined
444
+ }
445
+ if (value && !literal(value)) value = undefined
446
+ constants.set(key, value)
447
+ return value
448
+ }
449
+
450
+ function literal(node: Ast.Node, depth = 0): boolean {
451
+ if (depth > 64) return false
452
+ if (node.type === 'Literal')
453
+ return (
454
+ node.value === null ||
455
+ ['string', 'number', 'boolean'].includes(typeof node.value)
456
+ )
457
+ if (node.type === 'UnaryExpression')
458
+ return (
459
+ ['+', '-'].includes(node.operator) &&
460
+ node.argument.type === 'Literal' &&
461
+ typeof node.argument.value === 'number'
462
+ )
463
+ if (node.type === 'TemplateLiteral') return !node.expressions.length
464
+ if (node.type === 'ArrayExpression')
465
+ return node.elements.every((value) => value && literal(value, depth + 1))
466
+ return (
467
+ node.type === 'ObjectExpression' &&
468
+ node.properties.every(
469
+ (property) =>
470
+ property.type === 'Property' &&
471
+ !property.method &&
472
+ property.kind === 'init' &&
473
+ (!property.computed || property.key.type === 'Literal') &&
474
+ literal(property.value, depth + 1),
475
+ )
476
+ )
477
+ }
478
+
479
+ function relocate(
480
+ node: Ast.Node,
481
+ span: Pick<Ast.Node, 'start' | 'end'>,
482
+ ): Ast.Node {
483
+ const copy = structuredClone(node)
484
+ Walker.walk(copy, {
485
+ enter(node) {
486
+ node.start = span.start
487
+ node.end = span.end
488
+ },
489
+ })
490
+ return copy
491
+ }
492
+
493
+ const factoryPrograms = new Map<string, Ast.Program>()
494
+ function factory(
495
+ moduleId: string,
496
+ name: string,
497
+ seen = new Set<string>(),
498
+ ): string | undefined {
499
+ if (moduleId === 'zyzz/web')
500
+ return Contributions.factories.includes(name) ? name : undefined
501
+ const key = `${moduleId}#${name}`
502
+ if (seen.has(key) || !Object.hasOwn(options.modules, moduleId))
503
+ return undefined
504
+ const next = new Set(seen).add(key)
505
+ const program =
506
+ factoryPrograms.get(moduleId) ??
507
+ Parser.parseSync('barrel.ts', options.modules[moduleId]!, {
508
+ sourceType: 'module',
509
+ }).program
510
+ factoryPrograms.set(moduleId, program)
511
+ const target = (specifier: string, node: Ast.Node) =>
512
+ specifier === 'zyzz/web' ? specifier : resolve(moduleId, specifier, node)
513
+ for (const node of program.body) {
514
+ if (node.type !== 'ExportNamedDeclaration' || node.exportKind === 'type')
515
+ continue
516
+ const declaration = node.declaration
517
+ if (
518
+ declaration?.type === 'VariableDeclaration' &&
519
+ declaration.declarations.some(
520
+ (item) => item.id.type === 'Identifier' && item.id.name === name,
521
+ )
522
+ )
523
+ return undefined
524
+ if (
525
+ (declaration?.type === 'FunctionDeclaration' ||
526
+ declaration?.type === 'ClassDeclaration') &&
527
+ declaration.id?.name === name
528
+ )
529
+ return undefined
530
+ for (const specifier of node.specifiers) {
531
+ if (specifier.exportKind === 'type') continue
532
+ const exported =
533
+ specifier.exported.type === 'Identifier'
534
+ ? specifier.exported.name
535
+ : specifier.exported.value
536
+ if (exported !== name) continue
537
+ const local =
538
+ specifier.local.type === 'Identifier'
539
+ ? specifier.local.name
540
+ : specifier.local.value
541
+ if (node.source) {
542
+ const id = target(node.source.value, node)
543
+ return id ? factory(id, local, next) : undefined
544
+ }
545
+ for (const declaration of program.body) {
546
+ if (
547
+ declaration.type !== 'ImportDeclaration' ||
548
+ declaration.importKind === 'type'
549
+ )
550
+ continue
551
+ for (const imported of declaration.specifiers) {
552
+ if (
553
+ imported.type !== 'ImportSpecifier' ||
554
+ imported.importKind === 'type' ||
555
+ imported.local.name !== local
556
+ )
557
+ continue
558
+ const id = target(declaration.source.value, declaration)
559
+ return id
560
+ ? factory(
561
+ id,
562
+ imported.imported.type === 'Identifier'
563
+ ? imported.imported.name
564
+ : imported.imported.value,
565
+ next,
566
+ )
567
+ : undefined
568
+ }
569
+ }
570
+ return undefined
571
+ }
572
+ }
573
+ for (const node of program.body) {
574
+ if (
575
+ node.type === 'ExportAllDeclaration' &&
576
+ node.exportKind !== 'type' &&
577
+ !node.exported
578
+ ) {
579
+ const id = target(node.source.value, node)
580
+ const found = id ? factory(id, name, next) : undefined
581
+ if (found) return found
582
+ }
583
+ }
584
+ return undefined
585
+ }
586
+ function visit(moduleId: string): Source.extract.ReturnType {
587
+ const cached = extracted.get(moduleId)
588
+ if (cached) return cached
589
+
590
+ if (visiting.has(moduleId))
591
+ fail(moduleId, 'Circular source dependencies are not supported yet.')
592
+
593
+ visiting.add(moduleId)
594
+
595
+ const source = options.modules[moduleId]!
596
+
597
+ if (
598
+ previous &&
599
+ source === previous.sources[moduleId] &&
600
+ resolutions[moduleId] === previous.resolutions[moduleId] &&
601
+ previous.result.dependencies[moduleId]!.every(
602
+ (target) =>
603
+ Object.hasOwn(libraries, target) ||
604
+ visit(target) === previous.extracted.get(target),
605
+ )
606
+ ) {
607
+ return retain(
608
+ moduleId,
609
+ previous.extracted.get(moduleId)!,
610
+ previous.result.dependencies[moduleId]!,
611
+ )
612
+ }
613
+
614
+ // Validate identity and syntax through the public source boundary before linking.
615
+ Source.extract({ moduleId, source: '' })
616
+
617
+ const parsed = parse({ moduleId, source })
618
+
619
+ if (parsed.errors.length) Source.extract({ moduleId, source })
620
+ factoryPrograms.set(moduleId, parsed.program)
621
+
622
+ const names = new Set<string>()
623
+ identifiers.set(moduleId, names)
624
+ Walker.walk(parsed.program, {
625
+ enter(node) {
626
+ if (node.type === 'Identifier') names.add(node.name)
627
+ if (
628
+ options.imports === undefined &&
629
+ node.type === 'ImportExpression' &&
630
+ (node.source.type !== 'Literal' ||
631
+ typeof node.source.value !== 'string' ||
632
+ node.source.value.startsWith('.'))
633
+ )
634
+ fail(
635
+ moduleId,
636
+ 'Source graph dependencies require static imports.',
637
+ node,
638
+ )
639
+ },
640
+ })
641
+
642
+ const values: Record<string, Ast.Node> = Object.create(null)
643
+ const links: Record<string, Themes.Link> = Object.create(null)
644
+ const forwarded: Record<string, Themes.Link> = Object.create(null)
645
+ const explicit = new Set<string>()
646
+ const stars: Readonly<Record<string, Themes.Link>>[] = []
647
+ const imports = new Set<string>()
648
+
649
+ function exportedBindings(node: Ast.Node) {
650
+ if (node.type === 'Identifier') explicit.add(node.name)
651
+ else if (node.type === 'ObjectPattern')
652
+ for (const property of node.properties)
653
+ exportedBindings(
654
+ property.type === 'Property' ? property.value : property.argument,
655
+ )
656
+ else if (node.type === 'ArrayPattern')
657
+ for (const element of node.elements) {
658
+ if (element) exportedBindings(element)
659
+ }
660
+ else if (node.type === 'AssignmentPattern') exportedBindings(node.left)
661
+ else if (node.type === 'RestElement') exportedBindings(node.argument)
662
+ }
663
+
664
+ for (const node of parsed.program.body) {
665
+ if (
666
+ node.type === 'ExportNamedDeclaration' &&
667
+ !node.source &&
668
+ node.exportKind !== 'type'
669
+ ) {
670
+ for (const specifier of node.specifiers)
671
+ if (specifier.exportKind !== 'type')
672
+ explicit.add(
673
+ specifier.exported.type === 'Identifier'
674
+ ? specifier.exported.name
675
+ : specifier.exported.value,
676
+ )
677
+
678
+ if (node.declaration?.type === 'VariableDeclaration')
679
+ for (const declaration of node.declaration.declarations)
680
+ exportedBindings(declaration.id)
681
+ else if (
682
+ (node.declaration?.type === 'FunctionDeclaration' ||
683
+ node.declaration?.type === 'ClassDeclaration') &&
684
+ node.declaration.id
685
+ )
686
+ explicit.add(node.declaration.id.name)
687
+ }
688
+
689
+ if (
690
+ (node.type !== 'ImportDeclaration' &&
691
+ node.type !== 'ExportNamedDeclaration' &&
692
+ node.type !== 'ExportAllDeclaration') ||
693
+ !node.source
694
+ )
695
+ continue
696
+
697
+ if (
698
+ node.type === 'ImportDeclaration'
699
+ ? node.importKind === 'type'
700
+ : node.exportKind === 'type'
701
+ )
702
+ continue
703
+
704
+ if (
705
+ 'specifiers' in node &&
706
+ node.specifiers.length &&
707
+ node.specifiers.every((specifier) =>
708
+ specifier.type === 'ImportSpecifier'
709
+ ? specifier.importKind === 'type'
710
+ : specifier.type === 'ExportSpecifier' &&
711
+ specifier.exportKind === 'type',
712
+ )
713
+ )
714
+ continue
715
+
716
+ const target = resolve(moduleId, node.source.value, node)
717
+ if (!target) continue
718
+
719
+ imports.add(target)
720
+
721
+ const contracts =
722
+ libraries[target]?.links ?? visit(target).themeExports ?? {}
723
+
724
+ function namespace(name: string): Themes.Link | undefined {
725
+ const first = Object.values(contracts)[0]
726
+ if (!first) return undefined
727
+ return {
728
+ binding: `z-style-${Identity.hash(JSON.stringify([moduleId, name]))}-namespace`,
729
+ call: { start: -1, end: -1, name: '', tokenType: '{}' },
730
+ definition: first.definition,
731
+ kind: 'style-reference',
732
+ members: contracts,
733
+ }
734
+ }
735
+
736
+ if (node.type === 'ImportDeclaration') {
737
+ for (const specifier of node.specifiers) {
738
+ if (specifier.type === 'ImportNamespaceSpecifier') {
739
+ if (
740
+ Object.values(contracts).some(
741
+ (link) => link.kind !== 'style-reference',
742
+ )
743
+ )
744
+ fail(
745
+ moduleId,
746
+ 'Import theme contracts by name; namespace imports are not supported.',
747
+ specifier,
748
+ )
749
+
750
+ const link = namespace(specifier.local.name)
751
+ if (link) links[specifier.local.name] = link
752
+ continue
753
+ }
754
+
755
+ if (
756
+ specifier.type === 'ImportSpecifier' &&
757
+ specifier.importKind === 'type'
758
+ )
759
+ continue
760
+
761
+ const name = (() => {
762
+ if (specifier.type === 'ImportDefaultSpecifier') {
763
+ return 'default'
764
+ }
765
+
766
+ if (specifier.imported.type === 'Identifier') {
767
+ return specifier.imported.name
768
+ }
769
+
770
+ return specifier.imported.value
771
+ })()
772
+
773
+ if (Object.hasOwn(contracts, name))
774
+ links[specifier.local.name] = contracts[name]!
775
+ else {
776
+ const value = constant(target, name)
777
+ if (value) values[specifier.local.name] = relocate(value, specifier)
778
+ }
779
+ }
780
+ } else if (node.type === 'ExportAllDeclaration') {
781
+ if (node.exported) {
782
+ if (
783
+ Object.values(contracts).some(
784
+ (link) => link.kind !== 'style-reference',
785
+ )
786
+ )
787
+ fail(
788
+ moduleId,
789
+ 'Namespace theme re-exports are not supported.',
790
+ node,
791
+ )
792
+ const name =
793
+ node.exported.type === 'Identifier'
794
+ ? node.exported.name
795
+ : node.exported.value
796
+ explicit.add(name)
797
+ const link = namespace(name)
798
+ if (link) forwarded[name] = link
799
+ } else stars.push(contracts)
800
+ } else {
801
+ for (const specifier of node.specifiers) {
802
+ if (specifier.exportKind === 'type') continue
803
+
804
+ const name =
805
+ specifier.local.type === 'Identifier'
806
+ ? specifier.local.name
807
+ : specifier.local.value
808
+ const exported =
809
+ specifier.exported.type === 'Identifier'
810
+ ? specifier.exported.name
811
+ : specifier.exported.value
812
+
813
+ explicit.add(exported)
814
+
815
+ if (Object.hasOwn(contracts, name))
816
+ forwarded[exported] = contracts[name]!
817
+ }
818
+ }
819
+ }
820
+ const factories: Record<string, string> = Object.create(null)
821
+ for (const node of parsed.program.body) {
822
+ if (
823
+ node.type !== 'ImportDeclaration' ||
824
+ node.importKind === 'type' ||
825
+ node.specifiers.every(
826
+ (specifier) =>
827
+ specifier.type === 'ImportSpecifier' &&
828
+ specifier.importKind === 'type',
829
+ ) ||
830
+ ['zyzz', 'zyzz/web'].includes(node.source.value)
831
+ )
832
+ continue
833
+ const target = resolve(moduleId, node.source.value, node)
834
+ if (!target) continue
835
+ for (const specifier of node.specifiers) {
836
+ if (
837
+ specifier.type !== 'ImportSpecifier' ||
838
+ specifier.importKind === 'type'
839
+ )
840
+ continue
841
+ const name =
842
+ specifier.imported.type === 'Identifier'
843
+ ? specifier.imported.name
844
+ : specifier.imported.value
845
+ const found = factory(target, name)
846
+ if (found) factories[specifier.local.name] = found
847
+ }
848
+ }
849
+
850
+ const result = Source.extract({
851
+ target: options.native ? 'native' : 'web',
852
+ compiler: options.compiler,
853
+ moduleId,
854
+ source,
855
+ [Themes.context]: { constants: values, factories, links, parsed },
856
+ })
857
+
858
+ function outputLink(link: Themes.Link): Themes.Link {
859
+ return {
860
+ ...link,
861
+ ...(link.style
862
+ ? {
863
+ style: {
864
+ ...link.style,
865
+ style: {
866
+ ...link.style.style,
867
+ cssOutput:
868
+ link.style.style.cssOutput ?? options.cssOutput ?? 'atomic',
869
+ },
870
+ },
871
+ }
872
+ : {}),
873
+ ...(link.members
874
+ ? {
875
+ members: Object.fromEntries(
876
+ Object.entries(link.members).map(([name, member]) => [
877
+ name,
878
+ outputLink(member),
879
+ ]),
880
+ ),
881
+ }
882
+ : {}),
883
+ }
884
+ }
885
+
886
+ const exports: Record<string, Themes.Link> = Object.assign(
887
+ Object.create(null),
888
+ forwarded,
889
+ Object.fromEntries(
890
+ Object.entries(result.themeExports ?? {}).map(([name, link]) => [
891
+ name,
892
+ outputLink(link),
893
+ ]),
894
+ ),
895
+ )
896
+
897
+ for (const name of Object.keys(result.themeExports ?? {}))
898
+ explicit.add(name)
899
+
900
+ for (const contracts of stars)
901
+ for (const [name, link] of Object.entries(contracts)) {
902
+ if (name === 'default' || explicit.has(name)) continue
903
+
904
+ const previous = exports[name]
905
+
906
+ if (
907
+ previous &&
908
+ (previous.binding !== link.binding || previous.kind !== link.kind)
909
+ )
910
+ fail(moduleId, `Ambiguous theme re-export: ${name}`)
911
+
912
+ exports[name] = link
913
+ }
914
+
915
+ const linked = Object.freeze({
916
+ ...result,
917
+ themeExports: Object.freeze(exports),
918
+ })
919
+
920
+ return retain(moduleId, linked, Object.freeze([...imports]))
921
+ }
922
+
923
+ function retain(
924
+ moduleId: string,
925
+ result: Source.extract.ReturnType,
926
+ imports: readonly string[],
927
+ ): Source.extract.ReturnType {
928
+ for (const call of result.variableCalls ?? [])
929
+ for (const slot of Object.values(call.slots)) {
930
+ const owner = moduleId.replace(/\.[cm]?[jt]sx?$/, '')
931
+ const previous = variableSlots.get(slot.name)
932
+
933
+ if (
934
+ previous &&
935
+ (previous.owner !== owner || previous.type !== slot.type)
936
+ )
937
+ fail(
938
+ moduleId,
939
+ `Conflicting variable identity: ${slot.name}; compile libraries with package-qualified module IDs.`,
940
+ call,
941
+ )
942
+
943
+ variableSlots.set(slot.name, {
944
+ owner,
945
+ binding: `source:${call.start}`,
946
+ type: slot.type,
947
+ })
948
+ }
949
+
950
+ extracted.set(moduleId, result)
951
+ dependencies[moduleId] = imports
952
+
953
+ for (const call of result.themeCalls)
954
+ for (const name of new Set([
955
+ call.name,
956
+ ...Object.values(call.members ?? {}),
957
+ ]))
958
+ owners[name] = {
959
+ call: { ...call, name },
960
+ moduleId,
961
+ source: options.modules[moduleId]!,
962
+ }
963
+
964
+ Object.assign(themes, result.themes)
965
+ visiting.delete(moduleId)
966
+
967
+ return result
968
+ }
969
+
970
+ for (const moduleId of ids) visit(moduleId)
971
+
972
+ if (options.native) {
973
+ const native = options.native
974
+ function packedLink(link: Themes.Link): Themes.Link {
975
+ return {
976
+ ...link,
977
+ ...(link.style
978
+ ? { style: { ...link.style, className: link.style.className ?? '' } }
979
+ : {}),
980
+ ...(link.members
981
+ ? {
982
+ members: Object.fromEntries(
983
+ Object.entries(link.members).map(([name, link]) => [
984
+ name,
985
+ packedLink(link),
986
+ ]),
987
+ ),
988
+ }
989
+ : {}),
990
+ }
991
+ }
992
+ const modules = Object.fromEntries(
993
+ ids.map((moduleId) => {
994
+ if (
995
+ previous &&
996
+ extracted.get(moduleId) === previous.extracted.get(moduleId)
997
+ )
998
+ return [moduleId, previous.result.modules[moduleId]!]
999
+
1000
+ const imported: Record<
1001
+ string,
1002
+ Readonly<Record<string, Themes.Link>>
1003
+ > = Object.create(null)
1004
+ for (const statement of parse({
1005
+ moduleId,
1006
+ source: options.modules[moduleId]!,
1007
+ }).program.body) {
1008
+ if (
1009
+ (statement.type !== 'ImportDeclaration' &&
1010
+ statement.type !== 'ExportNamedDeclaration' &&
1011
+ statement.type !== 'ExportAllDeclaration') ||
1012
+ !statement.source
1013
+ )
1014
+ continue
1015
+ if (
1016
+ (statement.type === 'ImportDeclaration' &&
1017
+ statement.importKind === 'type') ||
1018
+ (statement.type !== 'ImportDeclaration' &&
1019
+ statement.exportKind === 'type')
1020
+ )
1021
+ continue
1022
+ if (
1023
+ 'specifiers' in statement &&
1024
+ statement.specifiers.length &&
1025
+ statement.specifiers.every((specifier) =>
1026
+ specifier.type === 'ImportSpecifier'
1027
+ ? specifier.importKind === 'type'
1028
+ : specifier.type === 'ExportSpecifier' &&
1029
+ specifier.exportKind === 'type',
1030
+ )
1031
+ )
1032
+ continue
1033
+ const target = resolve(moduleId, statement.source.value, statement)
1034
+ if (target && libraries[target])
1035
+ imported[statement.source.value] = libraries[target].links
1036
+ }
1037
+ const output = Native.compile({
1038
+ ...native,
1039
+ moduleId,
1040
+ source: options.modules[moduleId]!,
1041
+ [Themes.context]: {
1042
+ parsed: parse({ moduleId, source: options.modules[moduleId]! }),
1043
+ identifiers: identifiers.get(moduleId),
1044
+ extracted: extracted.get(moduleId)!,
1045
+ libraries: imported,
1046
+ links: {},
1047
+ },
1048
+ })
1049
+ return [moduleId, nativeOutput(output)]
1050
+ }),
1051
+ )
1052
+ return {
1053
+ compiler: true,
1054
+ composition: options.composition,
1055
+ contracts,
1056
+ cssOutput: options.cssOutput,
1057
+ development: !!options.development,
1058
+ extracted,
1059
+ libraries: Object.freeze(libraries),
1060
+ native: {
1061
+ ...options.native,
1062
+ ...(options.native.fonts && { fonts: { ...options.native.fonts } }),
1063
+ ...(options.native.themes && { themes: { ...options.native.themes } }),
1064
+ ...(options.native.units && { units: { ...options.native.units } }),
1065
+ },
1066
+ resolutions: Object.freeze(resolutions),
1067
+ result: Object.freeze({
1068
+ contracts: Object.freeze(
1069
+ Object.fromEntries(
1070
+ ids
1071
+ .filter(
1072
+ (id) =>
1073
+ Object.keys(extracted.get(id)!.themeExports ?? {}).length,
1074
+ )
1075
+ .map((id) => [
1076
+ id,
1077
+ Contract.write(
1078
+ Object.fromEntries(
1079
+ Object.entries(extracted.get(id)!.themeExports ?? {}).map(
1080
+ ([name, link]) => [name, packedLink(link)],
1081
+ ),
1082
+ ),
1083
+ themes,
1084
+ [],
1085
+ id,
1086
+ ),
1087
+ ]),
1088
+ ),
1089
+ ),
1090
+ dependencies: Object.freeze(dependencies),
1091
+ modules: Object.freeze(modules),
1092
+ }),
1093
+ schemes: false,
1094
+ sources: Object.freeze({ ...options.modules }),
1095
+ themes: Object.freeze(themes),
1096
+ }
1097
+ }
1098
+
1099
+ const modules: Record<string, Transform.compile.ReturnType> =
1100
+ Object.create(null)
1101
+ const sharedThemes = Object.freeze(themes)
1102
+ const sections = new Map<string, readonly Stylesheets.Section[]>()
1103
+
1104
+ for (const id of ids) {
1105
+ const extractedModule = extracted.get(id)!
1106
+ const contributions = extractedModule.contributions ?? []
1107
+
1108
+ if (!contributions.length) {
1109
+ sections.set(id, [])
1110
+ continue
1111
+ }
1112
+
1113
+ sections.set(
1114
+ id,
1115
+ contributions.map((contribution, index) => ({
1116
+ source: id,
1117
+ namespaces: extractedModule.namespaces,
1118
+ key: String(index),
1119
+ css:
1120
+ contribution.kind === 'layers'
1121
+ ? ''
1122
+ : (Css.compile({
1123
+ styles: { styles: [] },
1124
+ themes: sharedThemes,
1125
+ contributions: [contribution],
1126
+ }).contributionCss ?? ''),
1127
+ layers: contribution.kind === 'layers' ? [contribution.names] : [],
1128
+ content: options.modules[id]!,
1129
+ start: extractedModule.contributionStarts?.[index] ?? 0,
1130
+ })),
1131
+ )
1132
+ }
1133
+
1134
+ for (const [id, library] of Object.entries(libraries))
1135
+ sections.set(
1136
+ id,
1137
+ library.stylesheets.map((section) => {
1138
+ let owner = id
1139
+
1140
+ for (const specifier of section.dependency ?? []) {
1141
+ const target = resolve(owner, specifier)
1142
+
1143
+ if (!target || !Object.hasOwn(libraries, target))
1144
+ fail(
1145
+ id,
1146
+ 'Repacked stylesheet dependencies require supplied library contracts.',
1147
+ )
1148
+
1149
+ owner = target
1150
+ }
1151
+
1152
+ return {
1153
+ ...section,
1154
+ owner,
1155
+ source: Stylesheets.resolve(owner, section.source),
1156
+ }
1157
+ }),
1158
+ )
1159
+
1160
+ const resetOwners = ids.filter(
1161
+ (id) =>
1162
+ options.modules[id]!.includes('zyzz/reset.css') &&
1163
+ parse({
1164
+ moduleId: id,
1165
+ source: options.modules[id]!,
1166
+ }).program.body.some(
1167
+ (node) =>
1168
+ node.type === 'ImportDeclaration' &&
1169
+ node.source.value === 'zyzz/reset.css',
1170
+ ),
1171
+ )
1172
+
1173
+ const layerNames = [
1174
+ ...new Set(
1175
+ ids.flatMap((id) =>
1176
+ reachable(id).flatMap((section) => section.layers.flat()),
1177
+ ),
1178
+ ),
1179
+ ].filter((name) => name !== 'reset')
1180
+
1181
+ for (const resetOwner of resetOwners) {
1182
+ const entryLayers = [
1183
+ ...new Set(
1184
+ reachable(resetOwner).flatMap((section) => section.layers.flat()),
1185
+ ),
1186
+ ].filter((name) => name !== 'reset')
1187
+
1188
+ sections.set(resetOwner, [
1189
+ {
1190
+ source: resetOwner,
1191
+ key: 'optional-reset-order',
1192
+ css: '',
1193
+ layers: entryLayers.length
1194
+ ? entryLayers.map((name) => ['reset', name])
1195
+ : [['reset']],
1196
+ },
1197
+ ...(sections.get(resetOwner) ?? []),
1198
+ ])
1199
+ }
1200
+
1201
+ function dependencyPath(from: string, to: string): readonly string[] {
1202
+ const queue = [{ id: from, path: [] as string[] }]
1203
+ const seen = new Set<string>()
1204
+
1205
+ while (queue.length) {
1206
+ const current = queue.shift()!
1207
+ if (current.id === to) return current.path
1208
+ if (seen.has(current.id)) continue
1209
+
1210
+ seen.add(current.id)
1211
+
1212
+ for (const [specifier, target] of Object.entries(
1213
+ options.imports?.[current.id] ?? {},
1214
+ ))
1215
+ if (target)
1216
+ queue.push({ id: target, path: [...current.path, specifier] })
1217
+ }
1218
+
1219
+ fail(
1220
+ from,
1221
+ 'Repacked stylesheet ownership requires a resolved dependency path.',
1222
+ )
1223
+ }
1224
+
1225
+ function reachable(
1226
+ id: string,
1227
+ visited = new Set<string>(),
1228
+ ): readonly Stylesheets.Section[] {
1229
+ if (visited.has(id)) return []
1230
+
1231
+ visited.add(id)
1232
+
1233
+ return [
1234
+ ...(dependencies[id] ?? []).flatMap((dependency) =>
1235
+ reachable(dependency, visited),
1236
+ ),
1237
+ ...(sections.get(id) ?? []),
1238
+ ]
1239
+ }
1240
+
1241
+ const sharedVisited = new Set<string>()
1242
+
1243
+ const shared = (() => {
1244
+ try {
1245
+ const sharedSections = ids.flatMap((id) => reachable(id, sharedVisited))
1246
+ const resetSource =
1247
+ resetOwners[0] ??
1248
+ sharedSections.find((section) => section.key === 'optional-reset-order')
1249
+ ?.source
1250
+
1251
+ return Stylesheets.render([
1252
+ ...(resetSource === undefined
1253
+ ? []
1254
+ : [
1255
+ {
1256
+ source: resetSource,
1257
+ key: 'optional-reset-graph-order',
1258
+ css: '',
1259
+ layers: layerNames.length
1260
+ ? layerNames.map((name) => ['reset', name])
1261
+ : [['reset']],
1262
+ },
1263
+ ]),
1264
+ ...sharedSections,
1265
+ ])
1266
+ } catch (error) {
1267
+ return fail(
1268
+ error instanceof Stylesheets.ConflictError ? error.source : ids[0]!,
1269
+ (error as Error).message,
1270
+ )
1271
+ }
1272
+ })()
1273
+
1274
+ const sharedCss = shared.css
1275
+ // Every stylesheet includes all graph scopes, including unimported alternatives.
1276
+ const names = Object.keys(themes)
1277
+ const previousNames = Object.keys(previous?.themes ?? {})
1278
+
1279
+ const sameThemes =
1280
+ previous &&
1281
+ names.length === previousNames.length &&
1282
+ names.every(
1283
+ (name, index) =>
1284
+ name === previousNames[index] && previous.themes[name] === themes[name],
1285
+ )
1286
+
1287
+ const styleClasses: Record<string, string> = Object.create(null)
1288
+ function published(link: Themes.Link) {
1289
+ if (link.style?.className !== undefined)
1290
+ styleClasses[link.binding] = link.style.className
1291
+ for (const member of Object.values(link.members ?? {})) published(member)
1292
+ }
1293
+ for (const library of Object.values(libraries))
1294
+ for (const link of Object.values(library.links)) published(link)
1295
+
1296
+ const atomicOwners = new Map<string, string>()
1297
+ function packedOwners(link: Themes.Link, moduleId: string) {
1298
+ for (const name of link.style?.className?.split(' ') ?? []) {
1299
+ if (
1300
+ !name.startsWith('z-') ||
1301
+ name.startsWith('z-style-') ||
1302
+ name.startsWith('z-content-')
1303
+ )
1304
+ continue
1305
+ if (!atomicOwners.has(name)) atomicOwners.set(name, moduleId)
1306
+ }
1307
+ for (const member of Object.values(link.members ?? {}))
1308
+ packedOwners(member, moduleId)
1309
+ }
1310
+ for (const [moduleId, library] of Object.entries(libraries))
1311
+ for (const link of Object.values(library.links))
1312
+ packedOwners(link, moduleId)
1313
+ if (options.compiler === false) {
1314
+ const identities = new Map<string, string>()
1315
+ for (const [moduleId, library] of Object.entries(libraries)) {
1316
+ function register(name: string, signature: string) {
1317
+ const previous = identities.get(name)
1318
+ if (previous !== undefined && previous !== signature)
1319
+ fail(
1320
+ moduleId,
1321
+ 'The same explicit identity is used for different definitions.',
1322
+ )
1323
+ identities.set(name, signature)
1324
+ }
1325
+ for (const [name, theme] of Object.entries(library.themes)) {
1326
+ const data = theme[Token.definition]
1327
+ if (data.contract[Token.identity]?.startsWith('id-'))
1328
+ register(`theme:${name}`, JSON.stringify(data.values))
1329
+ }
1330
+ function styles(link: Themes.Link) {
1331
+ for (const name of link.style?.className?.split(' ') ?? [])
1332
+ if (name.startsWith('z-style-id-'))
1333
+ register(name, Identity.style(link.style!.style))
1334
+ for (const member of Object.values(link.members ?? {})) styles(member)
1335
+ }
1336
+ for (const link of Object.values(library.links)) styles(link)
1337
+ }
1338
+ for (const [moduleId, module] of extracted) {
1339
+ function register(name: string, signature: string) {
1340
+ const previous = identities.get(name)
1341
+ if (previous !== undefined && previous !== signature)
1342
+ return fail(
1343
+ moduleId,
1344
+ 'The same explicit identity is used for different definitions.',
1345
+ )
1346
+ identities.set(name, signature)
1347
+ }
1348
+ for (const [name, theme] of Object.entries(module.themes)) {
1349
+ const data = theme[Token.definition]
1350
+ if (data.contract[Token.identity]?.startsWith('id-'))
1351
+ register(`theme:${name}`, JSON.stringify(data.values))
1352
+ }
1353
+ for (const contribution of module.contributions ?? [])
1354
+ if ('name' in contribution)
1355
+ register(
1356
+ `${contribution.kind}:${contribution.name}`,
1357
+ Css.compile({
1358
+ styles: { styles: [] },
1359
+ contributions: [contribution],
1360
+ }).css,
1361
+ )
1362
+ for (const call of module.calls) {
1363
+ if (!call.portable?.startsWith('z-style-id-')) continue
1364
+ const signature = Identity.style(
1365
+ module.styles.styles.find((style) => style.name === call.name)!,
1366
+ )
1367
+ const previous = identities.get(call.portable)
1368
+ if (previous !== undefined && previous !== signature)
1369
+ return fail(
1370
+ moduleId,
1371
+ 'The same explicit style id is used for different declarations.',
1372
+ )
1373
+ identities.set(call.portable, signature)
1374
+ }
1375
+ }
1376
+ }
1377
+
1378
+ // Selection anywhere in the graph applies scheme classes beside scopes every
1379
+ // stylesheet carries, so each stylesheet declares the matching color-scheme.
1380
+ const schemes = [...extracted.values()].some((module) =>
1381
+ Boolean(
1382
+ module.themeAppearances?.length ||
1383
+ module.themeScripts?.length ||
1384
+ module.themeSelections?.length,
1385
+ ),
1386
+ )
1387
+
1388
+ // Extraction visits dependencies first; their emitted classes must precede consumers.
1389
+ for (const moduleId of extracted.keys()) {
1390
+ modules[moduleId] =
1391
+ sameThemes &&
1392
+ previous!.schemes === schemes &&
1393
+ extracted.get(moduleId) === previous!.extracted.get(moduleId)
1394
+ ? previous!.result.modules[moduleId]!
1395
+ : Transform.compile({
1396
+ compiler: options.compiler,
1397
+ development: options.development,
1398
+ composition: options.composition,
1399
+ cssOutput: options.cssOutput,
1400
+ moduleId,
1401
+ schemes,
1402
+ source: options.modules[moduleId]!,
1403
+ [Themes.context]: {
1404
+ extracted: Object.freeze({
1405
+ ...extracted.get(moduleId)!,
1406
+ themes: sharedThemes,
1407
+ contributions: undefined,
1408
+ }),
1409
+ links: {},
1410
+ owners,
1411
+ styleClasses,
1412
+ },
1413
+ })
1414
+ // Module-local checks cannot detect truncated ownership hashes colliding across files.
1415
+ for (const value of Object.values(modules[moduleId]!.classes))
1416
+ for (const name of value.split(' ')) {
1417
+ if (
1418
+ options.compiler === false ||
1419
+ !name.startsWith('z-') ||
1420
+ !modules[moduleId]!.css.includes(`.${name}{`)
1421
+ )
1422
+ continue
1423
+
1424
+ const owner = atomicOwners.get(name)
1425
+ if (owner !== undefined && owner !== moduleId)
1426
+ throw new Css.CompileError([
1427
+ {
1428
+ code: 'invalid_name',
1429
+ message: `Atomic class ${name} is also owned by module ${owner}.`,
1430
+ path: [moduleId],
1431
+ },
1432
+ ])
1433
+
1434
+ atomicOwners.set(name, moduleId)
1435
+ }
1436
+
1437
+ for (const call of extracted.get(moduleId)!.calls)
1438
+ if (call.identity)
1439
+ styleClasses[call.identity] = modules[moduleId]!.classes[call.name]!
1440
+ }
1441
+
1442
+ function publishedStyle(link: Themes.Link): Themes.Link {
1443
+ return {
1444
+ ...link,
1445
+ ...(link.style
1446
+ ? {
1447
+ style: {
1448
+ ...link.style,
1449
+ className: styleClasses[link.binding] ?? link.style.className,
1450
+ },
1451
+ }
1452
+ : {}),
1453
+ ...(link.members
1454
+ ? {
1455
+ members: Object.fromEntries(
1456
+ Object.entries(link.members).map(([name, member]) => [
1457
+ name,
1458
+ publishedStyle(member),
1459
+ ]),
1460
+ ),
1461
+ }
1462
+ : {}),
1463
+ }
1464
+ }
1465
+
1466
+ // A configuration whose module uses root controls or the script publishes its
1467
+ // catalog, exported or not, so initialization restores selections it persists.
1468
+ function configurations(id: string): readonly Contract.write.Configuration[] {
1469
+ const module = extracted.get(id)!
1470
+
1471
+ return module.themeCalls
1472
+ .filter(
1473
+ (call) =>
1474
+ call.appearance &&
1475
+ call.options &&
1476
+ (module.themeAppearances?.includes(call.name) ||
1477
+ module.themeScripts?.includes(call.name)),
1478
+ )
1479
+ .map((call) => {
1480
+ const themeNames = call.options?.themes
1481
+
1482
+ return {
1483
+ identity:
1484
+ sharedThemes[call.name]?.[Token.definition].contract[
1485
+ Token.identity
1486
+ ] ?? call.name,
1487
+ ...(typeof call.options?.storageKey === 'string'
1488
+ ? { storageKey: call.options.storageKey }
1489
+ : {}),
1490
+ themes:
1491
+ themeNames && typeof themeNames === 'object'
1492
+ ? Object.keys(themeNames)
1493
+ : [],
1494
+ }
1495
+ })
1496
+ }
1497
+
1498
+ return {
1499
+ compiler: options.compiler !== false,
1500
+ composition: options.composition,
1501
+ cssOutput: options.cssOutput,
1502
+ contracts,
1503
+ development: !!options.development,
1504
+ extracted,
1505
+ libraries: Object.freeze(libraries),
1506
+ native: undefined,
1507
+ resolutions: Object.freeze(resolutions),
1508
+ result: Object.freeze({
1509
+ ...(sharedCss
1510
+ ? {
1511
+ sharedCss,
1512
+ sharedCssMap: shared.map,
1513
+ sharedAssets: shared.assets,
1514
+ sharedAssetOwners: shared.owners,
1515
+ }
1516
+ : {}),
1517
+ contracts: Object.freeze(
1518
+ Object.fromEntries(
1519
+ ids
1520
+ .filter(
1521
+ (id) =>
1522
+ Object.keys(extracted.get(id)!.themeExports ?? {}).length ||
1523
+ reachable(id).length ||
1524
+ configurations(id).length,
1525
+ )
1526
+ .map((id) => [
1527
+ id,
1528
+ Contract.write(
1529
+ Object.fromEntries(
1530
+ Object.entries(extracted.get(id)!.themeExports ?? {}).map(
1531
+ ([name, link]) => [name, publishedStyle(link)],
1532
+ ),
1533
+ ),
1534
+ sharedThemes,
1535
+ reachable(id).map((section) => ({
1536
+ ...section,
1537
+ owner: undefined,
1538
+ dependency:
1539
+ section.owner && section.owner !== id
1540
+ ? dependencyPath(id, section.owner)
1541
+ : undefined,
1542
+ source: Stylesheets.relative(
1543
+ section.owner ?? id,
1544
+ section.source,
1545
+ ),
1546
+ })),
1547
+ id,
1548
+ configurations(id),
1549
+ ),
1550
+ ]),
1551
+ ),
1552
+ ),
1553
+ dependencies: Object.freeze(dependencies),
1554
+ modules: Object.freeze(
1555
+ Object.fromEntries(ids.map((id) => [id, modules[id]!])),
1556
+ ),
1557
+ }),
1558
+ schemes,
1559
+ sources: Object.freeze({ ...options.modules }),
1560
+ themes: sharedThemes,
1561
+ }
1562
+ }
1563
+
1564
+ // A returned lazy map must not retain the graph compilation context.
1565
+ function nativeOutput(
1566
+ output: Native.compile.ReturnType,
1567
+ ): Transform.compile.ReturnType {
1568
+ let sourceMap: Mapping.EncodedSourceMap | undefined
1569
+
1570
+ return Object.freeze({
1571
+ classes: Object.freeze({}),
1572
+ [Edits.key]: output[Edits.key],
1573
+ code: output.code,
1574
+ css: '',
1575
+ cssMap: {
1576
+ version: 3 as const,
1577
+ names: [],
1578
+ sources: [],
1579
+ mappings: '',
1580
+ },
1581
+ get map() {
1582
+ return (sourceMap ??= JSON.parse(output.map) as Mapping.EncodedSourceMap)
1583
+ },
1584
+ themes: Object.freeze({}),
1585
+ })
1586
+ }