zyzz 0.0.28 → 0.0.30

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 (302) hide show
  1. package/binding/wasi/wasi-worker.mjs +186 -0
  2. package/binding/wasi/zyzz.wasi.cjs +2302 -0
  3. package/binding/wasi/zyzz.wasm32-wasi.wasm +0 -0
  4. package/binding/zyzz.linux-x64-gnu.node +0 -0
  5. package/dist/babel/index.d.ts.map +1 -1
  6. package/dist/babel/index.js +2 -4
  7. package/dist/babel/index.js.map +1 -1
  8. package/dist/babel/internal/Compilation.d.ts +0 -1
  9. package/dist/babel/internal/Compilation.d.ts.map +1 -1
  10. package/dist/compiler/Graph.d.ts +14 -11
  11. package/dist/compiler/Graph.d.ts.map +1 -1
  12. package/dist/compiler/Graph.js +57 -1442
  13. package/dist/compiler/Graph.js.map +1 -1
  14. package/dist/compiler/Native.d.ts +7 -9
  15. package/dist/compiler/Native.d.ts.map +1 -1
  16. package/dist/compiler/Native.js +12 -716
  17. package/dist/compiler/Native.js.map +1 -1
  18. package/dist/compiler/Source.d.ts +122 -24
  19. package/dist/compiler/Source.d.ts.map +1 -1
  20. package/dist/compiler/Source.js +10 -1267
  21. package/dist/compiler/Source.js.map +1 -1
  22. package/dist/compiler/Transform.d.ts +4 -3
  23. package/dist/compiler/Transform.d.ts.map +1 -1
  24. package/dist/compiler/Transform.js +13 -961
  25. package/dist/compiler/Transform.js.map +1 -1
  26. package/dist/compiler/internal/AtRules.d.ts +5 -1
  27. package/dist/compiler/internal/AtRules.d.ts.map +1 -1
  28. package/dist/compiler/internal/AtRules.js +12 -106
  29. package/dist/compiler/internal/AtRules.js.map +1 -1
  30. package/dist/compiler/internal/Context.d.ts +11 -0
  31. package/dist/compiler/internal/Context.d.ts.map +1 -0
  32. package/dist/compiler/internal/Context.js +11 -0
  33. package/dist/compiler/internal/Context.js.map +1 -0
  34. package/dist/compiler/internal/Results.d.ts +148 -0
  35. package/dist/compiler/internal/Results.d.ts.map +1 -0
  36. package/dist/compiler/internal/Results.js +259 -0
  37. package/dist/compiler/internal/Results.js.map +1 -0
  38. package/dist/compiler/internal/Syntax.d.ts +0 -2
  39. package/dist/compiler/internal/Syntax.d.ts.map +1 -1
  40. package/dist/compiler/internal/Syntax.js +0 -2
  41. package/dist/compiler/internal/Syntax.js.map +1 -1
  42. package/dist/compiler/internal/Wire.d.ts +17 -0
  43. package/dist/compiler/internal/Wire.d.ts.map +1 -0
  44. package/dist/compiler/internal/Wire.js +795 -0
  45. package/dist/compiler/internal/Wire.js.map +1 -0
  46. package/dist/internal/Addon.d.ts +28 -0
  47. package/dist/internal/Addon.d.ts.map +1 -0
  48. package/dist/internal/Addon.js +87 -0
  49. package/dist/internal/Addon.js.map +1 -0
  50. package/dist/internal/Literal.d.ts +4 -1
  51. package/dist/internal/Literal.d.ts.map +1 -1
  52. package/dist/internal/Literal.js +4 -2
  53. package/dist/internal/Literal.js.map +1 -1
  54. package/dist/internal/Token.d.ts +2 -1
  55. package/dist/internal/Token.d.ts.map +1 -1
  56. package/dist/internal/Token.js +2 -2
  57. package/dist/internal/Token.js.map +1 -1
  58. package/dist/internal/Vlq.d.ts +14 -0
  59. package/dist/internal/Vlq.d.ts.map +1 -0
  60. package/dist/internal/Vlq.js +47 -0
  61. package/dist/internal/Vlq.js.map +1 -0
  62. package/dist/internal/Wasm.d.ts +22 -0
  63. package/dist/internal/Wasm.d.ts.map +1 -0
  64. package/dist/internal/Wasm.js +83 -0
  65. package/dist/internal/Wasm.js.map +1 -0
  66. package/dist/metro/Graph.d.ts +0 -1
  67. package/dist/metro/Graph.d.ts.map +1 -1
  68. package/dist/metro/transformer.d.ts.map +1 -1
  69. package/dist/metro/transformer.js +0 -1
  70. package/dist/metro/transformer.js.map +1 -1
  71. package/dist/next/internal/Project.d.ts.map +1 -1
  72. package/dist/next/internal/Project.js +2 -5
  73. package/dist/next/internal/Project.js.map +1 -1
  74. package/dist/node/Host.d.ts.map +1 -1
  75. package/dist/node/Host.js +0 -2
  76. package/dist/node/Host.js.map +1 -1
  77. package/dist/node/internal/Contracts.d.ts.map +1 -1
  78. package/dist/node/internal/Contracts.js +3 -7
  79. package/dist/node/internal/Contracts.js.map +1 -1
  80. package/dist/node/internal/Snapshot.d.ts +0 -1
  81. package/dist/node/internal/Snapshot.d.ts.map +1 -1
  82. package/dist/node/internal/Snapshot.js +0 -6
  83. package/dist/node/internal/Snapshot.js.map +1 -1
  84. package/dist/runtime/Composition.d.ts +2 -3
  85. package/dist/runtime/Composition.d.ts.map +1 -1
  86. package/dist/runtime/Composition.js +51 -30
  87. package/dist/runtime/Composition.js.map +1 -1
  88. package/dist/runtime/Recipe.d.ts.map +1 -1
  89. package/dist/runtime/Recipe.js +16 -12
  90. package/dist/runtime/Recipe.js.map +1 -1
  91. package/dist/unplugin/index.d.ts.map +1 -1
  92. package/dist/unplugin/index.js +3 -6
  93. package/dist/unplugin/index.js.map +1 -1
  94. package/dist/vite/index.d.ts.map +1 -1
  95. package/dist/vite/index.js +696 -201
  96. package/dist/vite/index.js.map +1 -1
  97. package/dist/web/Css.d.ts +8 -3
  98. package/dist/web/Css.d.ts.map +1 -1
  99. package/dist/web/Css.js +5 -721
  100. package/dist/web/Css.js.map +1 -1
  101. package/dist/web/internal/Block.d.ts +0 -2
  102. package/dist/web/internal/Block.d.ts.map +1 -1
  103. package/dist/web/internal/Block.js +1 -12
  104. package/dist/web/internal/Block.js.map +1 -1
  105. package/dist/web/internal/ClassName.d.ts +23 -18
  106. package/dist/web/internal/ClassName.d.ts.map +1 -1
  107. package/dist/web/internal/ClassName.js +26 -55
  108. package/dist/web/internal/ClassName.js.map +1 -1
  109. package/dist/web/internal/Contributions.d.ts +3 -5
  110. package/dist/web/internal/Contributions.d.ts.map +1 -1
  111. package/dist/web/internal/Contributions.js +0 -45
  112. package/dist/web/internal/Contributions.js.map +1 -1
  113. package/dist/web/internal/Engine.browser.d.ts +8 -0
  114. package/dist/web/internal/Engine.browser.d.ts.map +1 -0
  115. package/dist/web/internal/Engine.browser.js +42 -0
  116. package/dist/web/internal/Engine.browser.js.map +1 -0
  117. package/dist/web/internal/Engine.d.ts +9 -0
  118. package/dist/web/internal/Engine.d.ts.map +1 -0
  119. package/dist/web/internal/Engine.js +14 -0
  120. package/dist/web/internal/Engine.js.map +1 -0
  121. package/dist/web/internal/Themes.d.ts +1 -9
  122. package/dist/web/internal/Themes.d.ts.map +1 -1
  123. package/dist/web/internal/Themes.js +3 -221
  124. package/dist/web/internal/Themes.js.map +1 -1
  125. package/dist/web/internal/Wasm.generated.d.ts +4 -0
  126. package/dist/web/internal/Wasm.generated.d.ts.map +1 -0
  127. package/dist/web/internal/Wasm.generated.js +4 -0
  128. package/dist/web/internal/Wasm.generated.js.map +1 -0
  129. package/dist/web/internal/Wire.d.ts +19 -0
  130. package/dist/web/internal/Wire.d.ts.map +1 -0
  131. package/dist/web/internal/Wire.js +387 -0
  132. package/dist/web/internal/Wire.js.map +1 -0
  133. package/package.json +20 -1
  134. package/src/babel/index.ts +2 -5
  135. package/src/babel/internal/Compilation.ts +0 -1
  136. package/src/compiler/Graph.ts +89 -1930
  137. package/src/compiler/Native.ts +18 -871
  138. package/src/compiler/Source.ts +144 -1803
  139. package/src/compiler/Transform.ts +16 -1315
  140. package/src/compiler/internal/AtRules.ts +27 -115
  141. package/src/compiler/internal/Context.ts +11 -0
  142. package/src/compiler/internal/Results.ts +406 -0
  143. package/src/compiler/internal/Syntax.ts +0 -3
  144. package/src/compiler/internal/Wire.ts +1045 -0
  145. package/src/internal/Addon.ts +118 -0
  146. package/src/internal/Literal.ts +4 -2
  147. package/src/internal/Token.ts +2 -2
  148. package/src/internal/Vlq.ts +59 -0
  149. package/src/internal/Wasm.ts +111 -0
  150. package/src/metro/transformer.ts +0 -1
  151. package/src/next/internal/Project.ts +2 -9
  152. package/src/node/Host.ts +0 -2
  153. package/src/node/internal/Contracts.ts +3 -7
  154. package/src/node/internal/Snapshot.ts +0 -8
  155. package/src/runtime/Composition.ts +48 -25
  156. package/src/runtime/Recipe.ts +21 -14
  157. package/src/unplugin/index.ts +6 -6
  158. package/src/vite/index.ts +922 -221
  159. package/src/web/Css.ts +12 -908
  160. package/src/web/internal/Block.ts +0 -14
  161. package/src/web/internal/ClassName.ts +52 -85
  162. package/src/web/internal/Contributions.ts +3 -59
  163. package/src/web/internal/Engine.browser.ts +51 -0
  164. package/src/web/internal/Engine.ts +17 -0
  165. package/src/web/internal/Themes.ts +3 -279
  166. package/src/web/internal/Wasm.generated.ts +3 -0
  167. package/src/web/internal/Wire.ts +466 -0
  168. package/src/web/internal/wasm.d.ts +9 -0
  169. package/dist/compiler/internal/Applications.d.ts +0 -55
  170. package/dist/compiler/internal/Applications.d.ts.map +0 -1
  171. package/dist/compiler/internal/Applications.js +0 -393
  172. package/dist/compiler/internal/Applications.js.map +0 -1
  173. package/dist/compiler/internal/ColorProfiles.d.ts +0 -3
  174. package/dist/compiler/internal/ColorProfiles.d.ts.map +0 -1
  175. package/dist/compiler/internal/ColorProfiles.js +0 -84
  176. package/dist/compiler/internal/ColorProfiles.js.map +0 -1
  177. package/dist/compiler/internal/CompositionBindings.d.ts +0 -16
  178. package/dist/compiler/internal/CompositionBindings.d.ts.map +0 -1
  179. package/dist/compiler/internal/CompositionBindings.js +0 -89
  180. package/dist/compiler/internal/CompositionBindings.js.map +0 -1
  181. package/dist/compiler/internal/Compositions.d.ts +0 -37
  182. package/dist/compiler/internal/Compositions.d.ts.map +0 -1
  183. package/dist/compiler/internal/Compositions.js +0 -494
  184. package/dist/compiler/internal/Compositions.js.map +0 -1
  185. package/dist/compiler/internal/Configurations.d.ts +0 -26
  186. package/dist/compiler/internal/Configurations.d.ts.map +0 -1
  187. package/dist/compiler/internal/Configurations.js +0 -259
  188. package/dist/compiler/internal/Configurations.js.map +0 -1
  189. package/dist/compiler/internal/Contract.d.ts +0 -30
  190. package/dist/compiler/internal/Contract.d.ts.map +0 -1
  191. package/dist/compiler/internal/Contract.js +0 -753
  192. package/dist/compiler/internal/Contract.js.map +0 -1
  193. package/dist/compiler/internal/Contributions.d.ts +0 -54
  194. package/dist/compiler/internal/Contributions.d.ts.map +0 -1
  195. package/dist/compiler/internal/Contributions.js +0 -1151
  196. package/dist/compiler/internal/Contributions.js.map +0 -1
  197. package/dist/compiler/internal/Descriptors.d.ts +0 -15
  198. package/dist/compiler/internal/Descriptors.d.ts.map +0 -1
  199. package/dist/compiler/internal/Descriptors.js +0 -192
  200. package/dist/compiler/internal/Descriptors.js.map +0 -1
  201. package/dist/compiler/internal/Dynamic.d.ts +0 -14
  202. package/dist/compiler/internal/Dynamic.d.ts.map +0 -1
  203. package/dist/compiler/internal/Dynamic.js +0 -175
  204. package/dist/compiler/internal/Dynamic.js.map +0 -1
  205. package/dist/compiler/internal/Expression.d.ts +0 -19
  206. package/dist/compiler/internal/Expression.d.ts.map +0 -1
  207. package/dist/compiler/internal/Expression.js +0 -164
  208. package/dist/compiler/internal/Expression.js.map +0 -1
  209. package/dist/compiler/internal/Functions.d.ts +0 -5
  210. package/dist/compiler/internal/Functions.d.ts.map +0 -1
  211. package/dist/compiler/internal/Functions.js +0 -191
  212. package/dist/compiler/internal/Functions.js.map +0 -1
  213. package/dist/compiler/internal/Keyframes.d.ts +0 -5
  214. package/dist/compiler/internal/Keyframes.d.ts.map +0 -1
  215. package/dist/compiler/internal/Keyframes.js +0 -51
  216. package/dist/compiler/internal/Keyframes.js.map +0 -1
  217. package/dist/compiler/internal/Names.d.ts +0 -5
  218. package/dist/compiler/internal/Names.d.ts.map +0 -1
  219. package/dist/compiler/internal/Names.js +0 -37
  220. package/dist/compiler/internal/Names.js.map +0 -1
  221. package/dist/compiler/internal/NativeBindings.d.ts +0 -72
  222. package/dist/compiler/internal/NativeBindings.d.ts.map +0 -1
  223. package/dist/compiler/internal/NativeBindings.js +0 -171
  224. package/dist/compiler/internal/NativeBindings.js.map +0 -1
  225. package/dist/compiler/internal/NativeMedia.d.ts +0 -14
  226. package/dist/compiler/internal/NativeMedia.d.ts.map +0 -1
  227. package/dist/compiler/internal/NativeMedia.js +0 -287
  228. package/dist/compiler/internal/NativeMedia.js.map +0 -1
  229. package/dist/compiler/internal/NativeVars.d.ts +0 -28
  230. package/dist/compiler/internal/NativeVars.d.ts.map +0 -1
  231. package/dist/compiler/internal/NativeVars.js +0 -160
  232. package/dist/compiler/internal/NativeVars.js.map +0 -1
  233. package/dist/compiler/internal/PackedStyles.d.ts +0 -37
  234. package/dist/compiler/internal/PackedStyles.d.ts.map +0 -1
  235. package/dist/compiler/internal/PackedStyles.js +0 -344
  236. package/dist/compiler/internal/PackedStyles.js.map +0 -1
  237. package/dist/compiler/internal/Properties.d.ts +0 -5
  238. package/dist/compiler/internal/Properties.d.ts.map +0 -1
  239. package/dist/compiler/internal/Properties.js +0 -82
  240. package/dist/compiler/internal/Properties.js.map +0 -1
  241. package/dist/compiler/internal/RecipeConditions.d.ts +0 -41
  242. package/dist/compiler/internal/RecipeConditions.d.ts.map +0 -1
  243. package/dist/compiler/internal/RecipeConditions.js +0 -82
  244. package/dist/compiler/internal/RecipeConditions.js.map +0 -1
  245. package/dist/compiler/internal/RecipePayloads.d.ts +0 -31
  246. package/dist/compiler/internal/RecipePayloads.d.ts.map +0 -1
  247. package/dist/compiler/internal/RecipePayloads.js +0 -99
  248. package/dist/compiler/internal/RecipePayloads.js.map +0 -1
  249. package/dist/compiler/internal/Recipes.d.ts +0 -32
  250. package/dist/compiler/internal/Recipes.d.ts.map +0 -1
  251. package/dist/compiler/internal/Recipes.js +0 -339
  252. package/dist/compiler/internal/Recipes.js.map +0 -1
  253. package/dist/compiler/internal/Selectors.d.ts +0 -13
  254. package/dist/compiler/internal/Selectors.d.ts.map +0 -1
  255. package/dist/compiler/internal/Selectors.js +0 -280
  256. package/dist/compiler/internal/Selectors.js.map +0 -1
  257. package/dist/compiler/internal/Static.d.ts +0 -39
  258. package/dist/compiler/internal/Static.d.ts.map +0 -1
  259. package/dist/compiler/internal/Static.js +0 -534
  260. package/dist/compiler/internal/Static.js.map +0 -1
  261. package/dist/compiler/internal/Themes.d.ts +0 -190
  262. package/dist/compiler/internal/Themes.d.ts.map +0 -1
  263. package/dist/compiler/internal/Themes.js +0 -1577
  264. package/dist/compiler/internal/Themes.js.map +0 -1
  265. package/dist/compiler/internal/Vars.d.ts +0 -33
  266. package/dist/compiler/internal/Vars.d.ts.map +0 -1
  267. package/dist/compiler/internal/Vars.js +0 -387
  268. package/dist/compiler/internal/Vars.js.map +0 -1
  269. package/dist/compiler/internal/ViewTransitions.d.ts +0 -3
  270. package/dist/compiler/internal/ViewTransitions.d.ts.map +0 -1
  271. package/dist/compiler/internal/ViewTransitions.js +0 -68
  272. package/dist/compiler/internal/ViewTransitions.js.map +0 -1
  273. package/dist/internal/Cascade.d.ts +0 -74
  274. package/dist/internal/Cascade.d.ts.map +0 -1
  275. package/dist/internal/Cascade.js +0 -210
  276. package/dist/internal/Cascade.js.map +0 -1
  277. package/src/compiler/internal/Applications.ts +0 -610
  278. package/src/compiler/internal/ColorProfiles.ts +0 -93
  279. package/src/compiler/internal/CompositionBindings.ts +0 -120
  280. package/src/compiler/internal/Compositions.ts +0 -678
  281. package/src/compiler/internal/Configurations.ts +0 -349
  282. package/src/compiler/internal/Contract.ts +0 -1028
  283. package/src/compiler/internal/Contributions.ts +0 -1561
  284. package/src/compiler/internal/Descriptors.ts +0 -242
  285. package/src/compiler/internal/Dynamic.ts +0 -275
  286. package/src/compiler/internal/Expression.ts +0 -218
  287. package/src/compiler/internal/Functions.ts +0 -206
  288. package/src/compiler/internal/Keyframes.ts +0 -62
  289. package/src/compiler/internal/Names.ts +0 -48
  290. package/src/compiler/internal/NativeBindings.ts +0 -235
  291. package/src/compiler/internal/NativeMedia.ts +0 -342
  292. package/src/compiler/internal/NativeVars.ts +0 -231
  293. package/src/compiler/internal/PackedStyles.ts +0 -473
  294. package/src/compiler/internal/Properties.ts +0 -121
  295. package/src/compiler/internal/RecipeConditions.ts +0 -139
  296. package/src/compiler/internal/RecipePayloads.ts +0 -132
  297. package/src/compiler/internal/Recipes.ts +0 -531
  298. package/src/compiler/internal/Selectors.ts +0 -353
  299. package/src/compiler/internal/Static.ts +0 -784
  300. package/src/compiler/internal/Themes.ts +0 -2398
  301. package/src/compiler/internal/Vars.ts +0 -516
  302. package/src/compiler/internal/ViewTransitions.ts +0 -82
package/dist/web/Css.js CHANGED
@@ -1,16 +1,6 @@
1
- /**
2
- * Emits deterministic CSS, class mappings, and live theme scopes from ordered styles.
3
- * @module
4
- */
5
- import * as Targets from '../internal/Targets.js';
6
1
  import * as ClassName from './internal/ClassName.js';
7
- import * as Identity from '../internal/Identity.js';
8
- import * as Contributions from './internal/Contributions.js';
9
- import * as Binding from '../internal/Binding.js';
10
- import * as Cascade from '../internal/Cascade.js';
11
- import * as Literal from '../internal/Literal.js';
12
- import * as Token from '../internal/Token.js';
13
- import * as Themes from './internal/Themes.js';
2
+ import * as Engine from './internal/Engine.js';
3
+ import * as Wire from './internal/Wire.js';
14
4
  /**
15
5
  * Emits atomic or grouped CSS without reading files or generating runtime code.
16
6
  * Shares only nonconflicting declaration domains; conflicting rules retain authored
@@ -23,711 +13,9 @@ import * as Themes from './internal/Themes.js';
23
13
  * @throws {CompileError} If declarations or themes are invalid, or class identities collide.
24
14
  */
25
15
  export function compile(options) {
26
- const labels = options[ClassName.labels] ?? options.styles[ClassName.labels];
27
- const units = options[ClassName.units] ??
28
- ClassName.registry().scope({ owner: '', qualifier: '' });
29
- options = {
30
- ...options,
31
- styles: { styles: options.styles.styles.map(Targets.web) },
32
- };
33
- let theme;
34
- const references = new Map();
35
- function isReference(value) {
36
- if (typeof value !== 'object' || value === null)
37
- return false;
38
- const previous = references.get(value);
39
- if (previous !== undefined)
40
- return previous;
41
- const result = Token.is(value);
42
- references.set(value, result);
43
- return result;
44
- }
45
- const bodies = new Map();
46
- const declarations = new Map();
47
- const declarationProperties = new Map();
48
- const serialized = new Map();
49
- // Only primitive declaration lists can be interned without erasing token identity.
50
- // Reuse their emitted bodies throughout analysis and output.
51
- const repeated = new Map();
52
- const canonicalStyles = options.styles.styles.map((style) => {
53
- if ('rules' in style ||
54
- style.declarations.some((declaration) => typeof declaration.value === 'object'))
55
- return style;
56
- const key = nested(style);
57
- const previous = repeated.get(key);
58
- if (previous)
59
- return previous;
60
- repeated.set(key, style);
61
- return style;
62
- });
63
- const analyzed = [...new Set(canonicalStyles)];
64
- const classes = Object.create(null);
65
- const diagnostics = [];
66
- const groups = new Map();
67
- const nestedComposition = options.styles.styles.some((style) => style.rules && !isolated(style));
68
- const properties = new Set();
69
- // Conditional and composed declarations join the same conflict domains.
70
- function collect(style) {
71
- for (const { property } of style.declarations)
72
- properties.add(property);
73
- for (const rule of style.rules ?? [])
74
- collect(rule.style);
75
- }
76
- for (const style of analyzed)
77
- collect(style);
78
- // Logical dimensions may alias either physical axis in inherited writing modes.
79
- // Preserve physical-only factoring when no logical dimension is authored.
80
- const logicalSizing = [...properties].some((property) => /^(min|max)?(blockSize|inlineSize)$/i.test(canonical(property)));
81
- const resets = properties.has('all');
82
- const combinedLines = new Set();
83
- for (const property of properties)
84
- if (Literal.rule(property)?.kind === 'line') {
85
- const name = canonical(property);
86
- combinedLines.add(name.startsWith('border') ? 'border' : name);
87
- }
88
- function canonical(property) {
89
- return property in Literal.aliases
90
- ? Literal.aliases[property]
91
- : property;
92
- }
93
- function domain(property) {
94
- if (resets &&
95
- !property.startsWith('--') &&
96
- property !== 'direction' &&
97
- property !== 'unicodeBidi')
98
- return 'all';
99
- if (/^marker(?:Start|Mid|End)?$/.test(property))
100
- return 'marker';
101
- if (property.startsWith('corner'))
102
- return 'cornerShape';
103
- if (property.startsWith('containIntrinsic'))
104
- return 'containIntrinsicSize';
105
- if (property.startsWith('interestDelay'))
106
- return 'interestDelay';
107
- if (property.startsWith('backgroundPosition'))
108
- return 'backgroundPosition';
109
- if (combinedLines.has('columnRule') && property.startsWith('columnRule'))
110
- return 'columnRule';
111
- if (combinedLines.has('outline') && property.startsWith('outline'))
112
- return 'outline';
113
- if (property.startsWith('borderImage'))
114
- return 'borderImage';
115
- if (property.startsWith('border')) {
116
- if (combinedLines.has('border'))
117
- return 'border';
118
- if (property.endsWith('Color')) {
119
- return 'borderColor';
120
- }
121
- if (property.endsWith('Style')) {
122
- return 'borderStyle';
123
- }
124
- if (property.endsWith('Width')) {
125
- return 'borderWidth';
126
- }
127
- return 'borderRadius';
128
- }
129
- if (['flexDirection', 'flexFlow', 'flexWrap'].includes(property))
130
- return 'flexFlow';
131
- if (/^(pageBreak|break)(After|Before|Inside)$/.test(property))
132
- return property.replace('pageBreak', 'break');
133
- if (['fontStretch', 'fontWidth'].includes(property))
134
- return 'fontWidth';
135
- if (property.startsWith('fontSynthesis'))
136
- return 'fontSynthesis';
137
- if ([
138
- 'whiteSpace',
139
- 'whiteSpaceCollapse',
140
- 'whiteSpaceTrim',
141
- 'textWrap',
142
- 'textWrapMode',
143
- 'textWrapStyle',
144
- ].includes(property))
145
- return 'whiteSpace';
146
- if (['wordWrap', 'overflowWrap'].includes(property))
147
- return 'overflowWrap';
148
- if (property.startsWith('margin')) {
149
- return 'margin';
150
- }
151
- if (property.startsWith('padding')) {
152
- return 'padding';
153
- }
154
- if (property === 'overflow' ||
155
- property === 'overflowX' ||
156
- property === 'overflowY' ||
157
- property === 'overflowBlock' ||
158
- property === 'overflowInline') {
159
- return 'overflow';
160
- }
161
- if (property.startsWith('overscrollBehavior')) {
162
- return 'overscrollBehavior';
163
- }
164
- if (property.startsWith('scrollMargin')) {
165
- return 'scrollMargin';
166
- }
167
- if (property.startsWith('scrollPadding')) {
168
- return 'scrollPadding';
169
- }
170
- if (['columnGap', 'gap', 'rowGap'].includes(property)) {
171
- return 'gap';
172
- }
173
- if (/^(inset|top$|right$|bottom$|left$)/.test(property)) {
174
- return 'inset';
175
- }
176
- if (logicalSizing &&
177
- /^(min|max)?(width|height|blockSize|inlineSize)$/i.test(property)) {
178
- if (property.startsWith('min')) {
179
- return 'min-size';
180
- }
181
- if (property.startsWith('max')) {
182
- return 'max-size';
183
- }
184
- return 'size';
185
- }
186
- return property;
187
- }
188
- const parents = new Map();
189
- function root(domain) {
190
- const parent = parents.get(domain);
191
- if (!parent)
192
- return domain;
193
- const result = root(parent);
194
- parents.set(domain, result);
195
- return result;
196
- }
197
- // Union only authored shorthands. Unrelated axes retain their original factoring.
198
- // Recursion includes nested and reset-only shorthands without parsing CSS values.
199
- function join(property, target, visited = new Set()) {
200
- if (visited.has(property))
201
- return;
202
- visited.add(property);
203
- const current = root(domain(canonical(property)));
204
- const group = root(target);
205
- if (current !== group)
206
- parents.set(current, group);
207
- if (Object.hasOwn(Cascade.shorthands, property))
208
- for (const child of Cascade.shorthands[property])
209
- join(child, target, visited);
210
- }
211
- for (const property of new Set([...properties].map(canonical)))
212
- if (Object.hasOwn(Cascade.shorthands, property))
213
- join(property, domain(property));
214
- function serialize(input) {
215
- if (typeof input !== 'object' || input === null)
216
- return input;
217
- const cached = serialized.get(input);
218
- if (cached !== undefined)
219
- return cached;
220
- const value = serializeReference(input);
221
- if (typeof value === 'string')
222
- serialized.set(input, value);
223
- return value;
224
- }
225
- function serializeReference(input) {
226
- if (Binding.is(input))
227
- return `var(${input.name})`;
228
- if (isReference(input))
229
- return (theme ??= Themes.create()).serialize(input);
230
- if (Token.isExpression(input))
231
- return input.parts
232
- .map((part) => (typeof part === 'string' ? part : serialize(part)))
233
- .join('');
234
- return input;
235
- }
236
- function declarationBody(declaration) {
237
- const previous = declarations.get(declaration);
238
- if (previous !== undefined)
239
- return previous;
240
- const { important, property, value } = declaration;
241
- let entry = declarationProperties.get(property);
242
- if (!entry) {
243
- entry = {
244
- important: new Map(),
245
- name: Literal.name(property),
246
- normal: new Map(),
247
- };
248
- declarationProperties.set(property, entry);
249
- }
250
- const values = important ? entry.important : entry.normal;
251
- let body = values.get(value);
252
- if (body === undefined) {
253
- body = `${entry.name}:${serialize(value)}${important ? '!important' : ''};`;
254
- values.set(value, body);
255
- }
256
- declarations.set(declaration, body);
257
- return body;
258
- }
259
- function nested(style) {
260
- const previous = bodies.get(style);
261
- if (previous !== undefined)
262
- return previous;
263
- const body = renderNested(style);
264
- bodies.set(style, body);
265
- return body;
266
- }
267
- function renderNested(style) {
268
- if (style.rules)
269
- return style.rules
270
- .map((rule) => {
271
- const body = nested(rule.style);
272
- return rule.condition === undefined
273
- ? body
274
- : `${rule.condition}{${body}}`;
275
- })
276
- .join('');
277
- return style.declarations.map(declarationBody).join('');
278
- }
279
- const domainsByProperty = new Map();
280
- function conflict(property) {
281
- const previous = domainsByProperty.get(property);
282
- if (previous !== undefined)
283
- return previous;
284
- const value = root(domain(canonical(property)));
285
- domainsByProperty.set(property, value);
286
- return value;
287
- }
288
- // Sharing is safe only when every use of a conflict domain has the same
289
- // declaration sequence. Conditions conservatively retain contextual identities.
290
- // Isolated class lists never combine, so atomic sharing considers ordered styles only.
291
- const ordered = new Map();
292
- const combinable = new Set();
293
- for (const [index, style] of options.styles.styles.entries())
294
- if (!isolated(style))
295
- combinable.add(canonicalStyles[index]);
296
- for (const style of analyzed) {
297
- const domains = new Map();
298
- for (const item of style.declarations) {
299
- const property = item.property;
300
- const key = conflict(property);
301
- const entry = domains.get(key) ?? { body: '', mixed: false, property };
302
- entry.body += declarationBody(item);
303
- entry.mixed ||= entry.property !== property;
304
- domains.set(key, entry);
305
- }
306
- for (const [key, entry] of domains)
307
- for (const map of combinable.has(style) ? [groups, ordered] : [groups]) {
308
- const previous = map.get(key);
309
- map.set(key, previous === false ||
310
- entry.mixed ||
311
- (previous !== undefined && previous !== entry.body)
312
- ? false
313
- : entry.body);
314
- }
315
- }
316
- const defaultMode = options.cssOutput ?? 'atomic';
317
- if (defaultMode !== 'atomic' && defaultMode !== 'grouped')
318
- throw new CompileError([
319
- {
320
- code: 'invalid_output',
321
- message: 'cssOutput must be atomic or grouped.',
322
- path: ['cssOutput'],
323
- },
324
- ]);
325
- function outputMode(style) {
326
- return Object.getOwnPropertyDescriptor(style, 'cssOutput')?.value;
327
- }
328
- function compositionMode(style) {
329
- const mode = Object.getOwnPropertyDescriptor(style, 'composition')
330
- ?.value;
331
- return mode ?? options.composition ?? 'ordered';
332
- }
333
- // Development keeps every style ordered so names survive value edits.
334
- function isolated(style) {
335
- return compositionMode(style) === 'independent' && !options.development;
336
- }
337
- // Lists declaration groups in authored order; undefined marks styles whose
338
- // nested grouped output or anonymous layers emit one opaque rule.
339
- function flatten(style, conditions = []) {
340
- if (outputMode(style) === 'grouped')
341
- return undefined;
342
- if (style.rules) {
343
- const items = [];
344
- for (const rule of style.rules) {
345
- if (rule.condition?.trim() === '@layer')
346
- return undefined;
347
- const nested = flatten(rule.style, rule.condition === undefined
348
- ? conditions
349
- : [...conditions, rule.condition]);
350
- if (!nested)
351
- return undefined;
352
- items.push(...nested);
353
- }
354
- return items;
355
- }
356
- const items = [];
357
- for (let index = 0; index < style.declarations.length;) {
358
- const property = style.declarations[index].property;
359
- let value = '';
360
- // Keep same-property fallbacks ordered; they form one semantic value.
361
- while (style.declarations[index]?.property === property) {
362
- const declaration = style.declarations[index++];
363
- value += `${Literal.name(property)}:${serialize(declaration.value)}${declaration.important ? '!important' : ''};`;
364
- }
365
- items.push({ conditions, property, value });
366
- }
367
- return items;
368
- }
369
- function byDomain(items) {
370
- const result = new Map();
371
- for (const item of items) {
372
- const key = conflict(item.property);
373
- const domain = result.get(key);
374
- if (domain)
375
- domain.push(item);
376
- else
377
- result.set(key, [item]);
378
- }
379
- return result;
380
- }
381
- function representation(style) {
382
- return [
383
- outputMode(style),
384
- style.rules?.map((rule) => representation(rule.style)),
385
- ];
386
- }
387
- function validate(style) {
388
- const mode = outputMode(style);
389
- if (mode !== undefined && mode !== 'atomic' && mode !== 'grouped')
390
- throw new CompileError([
391
- {
392
- code: 'invalid_output',
393
- message: 'cssOutput must be atomic or grouped.',
394
- path: [style.name, 'cssOutput'],
395
- },
396
- ]);
397
- for (const rule of style.rules ?? [])
398
- validate(rule.style);
399
- }
400
- for (const style of options.styles.styles)
401
- validate(style);
402
- const identities = new Map();
403
- const rules = new Map();
404
- const conditionalRules = new Map();
405
- const identical = new Map();
406
- const explicitBodies = new Map();
407
- const selectors = new Map();
408
- const explicitModes = new Set();
409
- const applications = new Map();
410
- const occurrences = new Map();
411
- for (const style of options.styles.styles)
412
- for (const declaration of style.declarations) {
413
- const key = conflict(declaration.property);
414
- occurrences.set(key, (occurrences.get(key) ?? 0) + 1);
415
- }
416
- // An ordered atomic style reuses the rules of the previous style that set a
417
- // domain to the same sequence: no differing rule sits between them.
418
- const runs = new Map();
419
- const owned = new Map();
420
- if (!options.development) {
421
- const last = new Map();
422
- for (const [index, style] of options.styles.styles.entries()) {
423
- if (isolated(style))
424
- continue;
425
- const items = (outputMode(style) ?? defaultMode) === 'atomic' &&
426
- options.names?.[style.name] === undefined
427
- ? flatten(style)
428
- : undefined;
429
- // Grouped, explicit, and opaque rules may set any domain.
430
- if (!items) {
431
- last.clear();
432
- continue;
433
- }
434
- for (const [domain, list] of byDomain(items)) {
435
- const key = JSON.stringify(list.map((item) => [item.conditions, item.value]));
436
- const previous = last.get(domain);
437
- if (previous?.key !== key) {
438
- last.set(domain, { key, owner: index });
439
- continue;
440
- }
441
- const reuse = runs.get(index) ?? new Map();
442
- reuse.set(domain, previous.owner);
443
- runs.set(index, reuse);
444
- }
445
- }
446
- }
447
- for (const [styleIndex, style] of options.styles.styles.entries()) {
448
- const mode = outputMode(style) ?? defaultMode;
449
- const independent = compositionMode(style) === 'independent' && !options.development;
450
- if (!style.name || Object.hasOwn(classes, style.name)) {
451
- diagnostics.push({
452
- code: 'invalid_name',
453
- message: 'Style names must be nonempty and unique.',
454
- path: [style.name],
455
- });
456
- continue;
457
- }
458
- const explicit = options.names?.[style.name];
459
- if (explicit !== undefined) {
460
- const body = nested(style);
461
- const previous = explicitBodies.get(explicit);
462
- if (previous !== undefined && previous !== body)
463
- diagnostics.push({
464
- code: 'identity_collision',
465
- message: 'An explicit id is used for different styles.',
466
- path: [style.name],
467
- });
468
- explicitBodies.set(explicit, body);
469
- classes[style.name] = explicit;
470
- const key = `${explicit}:${mode}`;
471
- if (explicitModes.has(key))
472
- continue;
473
- explicitModes.add(key);
474
- }
475
- const application = explicit === undefined && independent
476
- ? `${mode}:${style.rules ? JSON.stringify(representation(style)) : ''}:${nested(canonicalStyles[styleIndex])}`
477
- : undefined;
478
- if (application !== undefined && applications.has(application)) {
479
- classes[style.name] = applications.get(application);
480
- continue;
481
- }
482
- const names = explicit === undefined ? [] : [explicit];
483
- let ordinal = 0;
484
- const cssName = labels?.[style.name]?.name ?? encode(style.name);
485
- const cssNamespace = labels?.[style.name]?.namespace ??
486
- (options.scope ? Identity.name(options.scope) : undefined);
487
- let sharedRules = identical.get(cssNamespace);
488
- if (!sharedRules) {
489
- sharedRules = { atomic: new Map(), grouped: new Map() };
490
- identical.set(cssNamespace, sharedRules);
491
- }
492
- function emit(body, label, shared, output = mode, conditional) {
493
- if (!body)
494
- return undefined;
495
- const reusable = explicit === undefined &&
496
- (shared || (independent && mode === 'grouped' && output === mode));
497
- const previous = reusable ? sharedRules[output].get(body) : undefined;
498
- if (previous && !names.includes(previous)) {
499
- names.push(previous);
500
- return previous;
501
- }
502
- if (previous)
503
- shared = false;
504
- // Contextual slots preserve authored ordering; development names survive value edits.
505
- const slot = ordinal++;
506
- const identity = (() => {
507
- if (explicit !== undefined)
508
- return `${explicit}-${mode}-${encode(label)}-${slot}`;
509
- if (output === 'grouped' && mode === 'grouped') {
510
- return `z-${cssNamespace ? `${cssNamespace}-` : ''}${cssName}${slot ? `__${slot}` : ''}`;
511
- }
512
- return ClassName.create({
513
- body,
514
- context: !shared ? cssName : undefined,
515
- namespace: cssNamespace,
516
- property: label,
517
- slot: !shared ? slot : undefined,
518
- });
519
- })();
520
- const owner = mode === 'atomic' && !shared ? `${style.name}:${slot}` : undefined;
521
- if ((rules.has(identity) && rules.get(identity) !== body) ||
522
- (owner !== undefined &&
523
- identities.has(identity) &&
524
- identities.get(identity) !== owner))
525
- diagnostics.push({
526
- code: 'identity_collision',
527
- message: 'Generated class names conflict. Supply distinct config or style ids.',
528
- path: [style.name],
529
- });
530
- if (owner !== undefined)
531
- identities.set(identity, owner);
532
- rules.set(identity, body);
533
- if (conditional?.conditions.some((condition) => /^@(media|supports)\b/.test(condition)))
534
- conditionalRules.set(identity, conditional);
535
- if (explicit !== undefined)
536
- selectors.set(identity, explicit);
537
- else {
538
- if (reusable)
539
- sharedRules[output].set(body, identity);
540
- names.push(identity);
541
- }
542
- return identity;
543
- }
544
- function atoms(style, conditions = []) {
545
- if (outputMode(style) === 'grouped') {
546
- const body = conditions.reduceRight((body, condition) => `${condition}{${body}}`, nested(style));
547
- emit(body, 'style', false, 'grouped');
548
- return;
549
- }
550
- if (style.rules) {
551
- for (const rule of style.rules) {
552
- if (rule.condition?.trim() === '@layer') {
553
- // Repeating an anonymous layer would change cascade precedence.
554
- const body = [...conditions, rule.condition].reduceRight((body, condition) => `${condition}{${body}}`, nested(rule.style));
555
- emit(body, 'layer', false);
556
- continue;
557
- }
558
- atoms(rule.style, rule.condition === undefined
559
- ? conditions
560
- : [...conditions, rule.condition]);
561
- }
562
- return;
563
- }
564
- for (let index = 0; index < style.declarations.length;) {
565
- const declaration = style.declarations[index++];
566
- const property = declaration.property;
567
- const values = [declaration];
568
- // Keep same-property fallbacks ordered; they form one semantic value.
569
- while (style.declarations[index]?.property === property)
570
- values.push(style.declarations[index++]);
571
- const domain = conflict(property);
572
- const owner = runs.get(styleIndex)?.get(domain);
573
- const reused = owner === undefined ? undefined : owned.get(owner)?.get(domain);
574
- if (reused) {
575
- for (const identity of reused)
576
- if (!names.includes(identity))
577
- names.push(identity);
578
- continue;
579
- }
580
- const value = values
581
- .map(({ important, value }) => `${Literal.name(property)}:${serialize(value)}${important ? '!important' : ''};`)
582
- .join('');
583
- const body = conditions.reduceRight((body, condition) => `${condition}{${body}}`, value);
584
- const shared = !nestedComposition &&
585
- !conditions.length &&
586
- ordered.get(domain) !== false;
587
- const identity = emit(body, property, shared, mode, {
588
- conditions,
589
- value,
590
- });
591
- if (identity === undefined)
592
- continue;
593
- const domains = owned.get(styleIndex) ?? new Map();
594
- domains.set(domain, [...(domains.get(domain) ?? []), identity]);
595
- owned.set(styleIndex, domains);
596
- }
597
- }
598
- // Independent class lists never combine, so only declarations within one
599
- // conflict domain need relative order. Equal domain bodies share one rule.
600
- function share(style) {
601
- const items = flatten(style);
602
- if (!items)
603
- return atoms(style);
604
- for (const domain of byDomain(items).values()) {
605
- // Conditional rules stay contextual to keep their order against base declarations.
606
- if (domain.some((item) => item.conditions.length)) {
607
- for (const item of domain)
608
- emit(item.conditions.reduceRight((body, condition) => `${condition}{${body}}`, item.value), item.property, false, mode, item);
609
- continue;
610
- }
611
- const body = domain.map((item) => item.value).join('');
612
- const identity = units.name(body, cssNamespace);
613
- if (rules.has(identity) && rules.get(identity) !== body)
614
- diagnostics.push({
615
- code: 'identity_collision',
616
- message: 'Generated class names conflict. Supply distinct config or style ids.',
617
- path: [style.name],
618
- });
619
- rules.set(identity, body);
620
- names.push(identity);
621
- }
622
- }
623
- try {
624
- if (mode === 'grouped') {
625
- const shared = [];
626
- const local = [];
627
- for (const declaration of style.declarations) {
628
- const key = conflict(declaration.property);
629
- const reusable = !style.rules &&
630
- independent &&
631
- groups.get(key) !== false &&
632
- (occurrences.get(key) ?? 0) > 1;
633
- if (reusable)
634
- shared.push(declaration);
635
- else
636
- local.push(declaration);
637
- }
638
- if (shared.length && local.length) {
639
- emit(shared.map(declarationBody).join(''), 'shared', false);
640
- emit(local.map(declarationBody).join(''), 'style', false);
641
- }
642
- else
643
- emit(nested(style), 'style', false);
644
- }
645
- else if (explicit === undefined && independent)
646
- share(style);
647
- else
648
- atoms(style);
649
- }
650
- catch (error) {
651
- diagnostics.push({
652
- code: 'invalid_declaration',
653
- message: error.message,
654
- path: [style.name],
655
- });
656
- }
657
- classes[style.name] = [...new Set(names)].join(' ');
658
- if (application !== undefined)
659
- applications.set(application, classes[style.name]);
660
- }
661
- if (diagnostics.length)
662
- throw new CompileError(diagnostics);
663
- const contributionCss = (() => {
664
- try {
665
- return Contributions.render(options.contributions ?? [], nested);
666
- }
667
- catch (error) {
668
- throw new CompileError([
669
- {
670
- code: 'invalid_declaration',
671
- message: error.message,
672
- path: ['contributions'],
673
- },
674
- ]);
675
- }
676
- })();
677
- let scopes;
678
- try {
679
- scopes =
680
- theme || options.vars || options.schemes
681
- ? (theme ??= Themes.create()).emit(options.vars ?? {}, options.schemes ?? false, options[Themes.shared])
682
- : { classes: Object.freeze({}), css: '', resources: [], rules: [] };
683
- }
684
- catch (error) {
685
- throw new CompileError([
686
- {
687
- code: 'invalid_theme',
688
- message: error.message,
689
- path: ['vars'],
690
- },
691
- ]);
692
- }
693
- const scopedCss = [
694
- scopes.css,
695
- ...[...rules].map((entry) => {
696
- const [name, body] = entry;
697
- const selector = `.${ClassName.selector(selectors.get(name) ?? name)}`;
698
- const conditional = conditionalRules.get(name);
699
- if (!conditional ||
700
- conditional.conditions.some((condition) => condition.startsWith('@') &&
701
- !/^@(media|supports)\b/.test(condition)))
702
- return `${selector}{${body}}`;
703
- // Inactive conditions must surround the class rather than leave a matched empty wrapper.
704
- const conditions = conditional.conditions.filter((condition) => condition.startsWith('@'));
705
- const nested = conditional.conditions
706
- .filter((condition) => !condition.startsWith('@'))
707
- .reduceRight((body, condition) => `${condition}{${body}}`, conditional.value);
708
- return conditions.reduceRight((body, condition) => `${condition}{${body}}`, `${selector}{${nested}}`);
709
- }),
710
- ]
711
- .filter(Boolean)
712
- .join('\n');
713
- const result = {
714
- ...(scopes.resources.length ? { [Themes.shared]: scopes.resources } : {}),
715
- ...(contributionCss ? { contributionCss, scopedCss } : {}),
716
- [ClassName.units]: units.used,
717
- [ClassName.rules]: Object.freeze({
718
- ...Object.fromEntries(rules),
719
- ...Object.fromEntries(scopes.rules.map((rule) => [
720
- `@scope:${rule.selector.slice(1)}:${Identity.name(rule.property)}:${Identity.name(JSON.stringify(rule.conditions))}`,
721
- rule.value,
722
- ])),
723
- }),
724
- classes: Object.freeze(classes),
725
- css: [contributionCss, scopedCss].filter(Boolean).join('\n'),
726
- vars: scopes.classes,
727
- };
728
- Object.defineProperty(result, ClassName.rules, { enumerable: false });
729
- Object.defineProperty(result, ClassName.units, { enumerable: false });
730
- return Object.freeze(result);
16
+ const input = Wire.encode(options);
17
+ // A supplied unit scope receives the naming decisions the engine made against its table.
18
+ return Wire.decode(Engine.call('css.compile', input), options[ClassName.units]);
731
19
  }
732
20
  /** Aggregated literal compilation diagnostics in authored traversal order. */
733
21
  export class CompileError extends Error {
@@ -746,8 +34,4 @@ export class CompileError extends Error {
746
34
  /** Stable namespaced error identifier. */
747
35
  name = 'Css.CompileError';
748
36
  }
749
- // Encoding underscores and delimiters makes the value form injective.
750
- function encode(value) {
751
- return value.replace(/[^a-zA-Z0-9-]/g, (character) => `_${character.charCodeAt(0).toString(16)}_`);
752
- }
753
37
  //# sourceMappingURL=Css.js.map