zyzz 0.0.28 → 0.0.29

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
@@ -1,14 +1,6 @@
1
- import MagicString from 'magic-string';
2
- import * as Source from './Source.js';
1
+ import * as Context from './internal/Context.js';
3
2
  import * as Edits from './internal/Edits.js';
4
- import * as NativeBindings from './internal/NativeBindings.js';
5
- import * as NativeMedia from './internal/NativeMedia.js';
6
- import * as NativeVars from './internal/NativeVars.js';
7
- import * as Themes from './internal/Themes.js';
8
- import * as StyleSheet from '../react-native/StyleSheet.js';
9
- import * as Syntax from './internal/Syntax.js';
10
- import * as Variants from '../react-native/Variants.js';
11
- import * as Walker from 'oxc-walker';
3
+ import * as Results from './internal/Results.js';
12
4
  /**
13
5
  * Compiles local styles, variants, and variable reads for an explicit native target.
14
6
  * @param options - Shared source, destination mappings, and selected set/scheme.
@@ -18,718 +10,22 @@ import * as Walker from 'oxc-walker';
18
10
  * @throws {StyleSheet.CompileError} For unsupported native declaration values.
19
11
  */
20
12
  export function compile(options) {
21
- const typed = !options[Edits.runtime] && /\.[cm]?tsx?$/.test(options.moduleId);
22
- const extracted = options[Themes.context]?.extracted ??
23
- Source.extract({
24
- moduleId: options.moduleId,
25
- source: options.source,
26
- target: 'native',
27
- [Themes.context]: options[Themes.context],
28
- });
29
- if (extracted.contributions?.length ||
30
- extracted.variableCalls?.length ||
31
- extracted.themeReferences.length ||
32
- extracted.themeSelections?.length ||
33
- (!options.contextual &&
34
- (extracted.themeAppearances?.length || extracted.themeScripts?.length)))
35
- throw new CompileError('Native static modules do not support CSS contributions, variables, or web set controls.');
36
- const parsed = options[Themes.context]?.parsed ?? Syntax.parse(options);
37
- const names = new Set(options[Themes.context]?.identifiers);
38
- if (!options[Themes.context]?.identifiers)
39
- Walker.walk(parsed.program, {
40
- enter(node) {
41
- if (node.type === 'Identifier')
42
- names.add(node.name);
43
- },
44
- });
45
- let helper = '__zyzzNative';
46
- while ([
47
- helper,
48
- `${helper}Context`,
49
- `${helper}Dynamic`,
50
- `${helper}Static`,
51
- `${helper}Vars`,
52
- ].some((name) => names.has(name)))
53
- helper += '_';
54
- let dynamicHelper = `${helper}Dynamic`;
55
- while (names.has(dynamicHelper))
56
- dynamicHelper += '_';
57
- const module = new MagicString(options.source);
58
- const edits = [];
59
- function overwrite(start, end, code, expression = false) {
60
- edits.push({ start, end, code, expression });
61
- module.overwrite(start, end, code);
62
- }
63
- const recipes = Object.create(null);
64
- let dynamic = false;
65
- let finite = false;
66
- const contexts = new Map();
67
- const compiledCalls = new WeakMap();
68
- const factories = new Map();
69
- const literals = new Map();
70
- const initializers = new Map();
71
- const stylesByName = new Map();
72
- for (const style of extracted.styles.styles) {
73
- const styles = stylesByName.get(style.name);
74
- if (styles)
75
- styles.push(style);
76
- else
77
- stylesByName.set(style.name, [style]);
78
- }
79
- const staticTables = new Map();
80
- if (extracted.nativeVars?.length)
81
- StyleSheet.compile({
82
- fonts: options.fonts,
83
- platform: options.platform,
84
- styles: { styles: [] },
85
- units: options.units,
86
- });
87
- const shared = options[NativeVars.shared];
88
- const variables = new Map(shared?.definitions);
89
- const imports = new Set();
90
- for (const read of extracted.nativeVars ?? []) {
91
- const imported = shared?.reads.get(read.start);
92
- if (imported) {
93
- if (imported.source)
94
- imports.add(`import {${imported.name}} from ${JSON.stringify(imported.source)};`);
95
- const type = typed
96
- ? ` as typeof ${options.source.slice(read.start, read.end)}`
97
- : '';
98
- overwrite(read.start, read.end, `(${imported.name}${type})`, true);
99
- continue;
100
- }
101
- const definition = (() => {
102
- try {
103
- return NativeVars.compile({
104
- ...read,
105
- fonts: options.fonts,
106
- units: options.units,
107
- });
108
- }
109
- catch (error) {
110
- throw new CompileError(error.message);
111
- }
112
- })();
113
- const key = JSON.stringify(definition);
114
- let name = variables.get(key);
115
- if (!name) {
116
- name = `${helper}Vars${variables.size}`;
117
- while (names.has(name))
118
- name += '_';
119
- names.add(name);
120
- variables.set(key, name);
121
- }
122
- const type = typed
123
- ? ` as typeof ${options.source.slice(read.start, read.end)}`
124
- : '';
125
- overwrite(read.start, read.end, `(${name}${type})`, true);
126
- }
127
- if (options.contextual) {
128
- const groups = new Map();
129
- for (const call of extracted.calls) {
130
- if (call.recipe ||
131
- call.staticRecipe ||
132
- call.dynamicRecipe ||
133
- call.slots ||
134
- call.output === 'html')
135
- continue;
136
- const vars = call.nativeContext?.vars ?? options.vars;
137
- try {
138
- if (NativeMedia.prepare(stylesByName.get(call.name) ?? [], vars, options))
139
- continue;
140
- }
141
- catch (error) {
142
- throw new CompileError(error.message);
143
- }
144
- const group = groups.get(vars);
145
- if (group)
146
- group.push(call);
147
- else
148
- groups.set(vars, [call]);
149
- }
150
- for (const [vars, calls] of groups) {
151
- if (calls.length < 2)
152
- continue;
153
- try {
154
- const compiled = StyleSheet.compile({
155
- fonts: options.fonts,
156
- platform: options.platform,
157
- styles: {
158
- styles: calls.map((call) => ({
159
- name: call.name,
160
- declarations: [],
161
- rules: (stylesByName.get(call.name) ?? []).map((style) => ({
162
- style,
163
- })),
164
- })),
165
- },
166
- vars,
167
- units: options.units,
168
- });
169
- for (const call of calls) {
170
- const styles = Object.fromEntries(Object.entries(compiled.styles).map(([set, schemes]) => [
171
- set,
172
- Object.freeze({
173
- light: Object.freeze({ '0': schemes.light[call.name] }),
174
- dark: Object.freeze({ '0': schemes.dark[call.name] }),
175
- }),
176
- ]));
177
- staticTables.set(call, Object.freeze({
178
- axes: Object.freeze({}),
179
- defaults: Object.freeze({}),
180
- styles: Object.freeze(styles),
181
- }));
182
- }
183
- }
184
- catch (error) {
185
- // Recompile failures individually to retain authored error order and paths.
186
- if (!(error instanceof StyleSheet.CompileError))
187
- throw error;
188
- }
189
- }
190
- }
191
- for (const call of extracted.calls) {
192
- if ((call.recipe && !call.staticRecipe && !call.dynamicRecipe) ||
193
- call.output === 'html')
194
- throw new CompileError('Native source compilation does not support named conditions or HTML output.');
195
- const recipe = call.staticRecipe ??
196
- call.dynamicRecipe ?? {
197
- axes: {},
198
- defaults: {},
199
- rules: [
200
- {
201
- matches: [],
202
- value: {
203
- styles: stylesByName.get(call.name) ?? [],
204
- },
205
- },
206
- ],
207
- };
208
- overwrite(call.start, call.end, callable(recipe, call.name, call, options, staticTables.get(call)), true);
209
- }
210
- function create(name, data) {
211
- const literal = JSON.stringify(data);
212
- if (!options[Edits.runtime] || extracted.calls.length < 2)
213
- return `${name}.create(${literal})`;
214
- const key = `${name}:${literal}`;
215
- const cached = literals.get(key);
216
- if (cached)
217
- return cached;
218
- const values = [];
219
- const structure = literal.replace(/"(?:[^"\\]|\\.)*"|-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?|true|false|null/g, (value, offset) => {
220
- // Serialized property names precede colons; only value tokens become parameters.
221
- if (literal[offset + value.length] === ':')
222
- return value;
223
- const parameter = `v${values.length}`;
224
- values.push(value);
225
- return parameter;
226
- });
227
- const expression = `${name}.create(${structure})`;
228
- const value = values.length > 64
229
- ? `${name}.create(${literal})`
230
- : factory(expression, values);
231
- literals.set(key, value);
232
- return value;
233
- }
234
- function factory(expression, values) {
235
- let definition = factories.get(expression);
236
- if (!definition) {
237
- let name = `${helper}Factory${factories.size}`;
238
- while (names.has(name))
239
- name += '_';
240
- names.add(name);
241
- definition = { name, parameters: values.map((_, index) => `v${index}`) };
242
- factories.set(expression, definition);
243
- }
244
- const value = `${definition.name}(${values.join(',')})`;
245
- initializers.set(value, { name: definition.name, values });
246
- return value;
247
- }
248
- function callable(recipe, name, call, contextOptions = options, compiled, bindings) {
249
- const program = Object.keys(recipe.axes).length > 0 ||
250
- call?.slots ||
251
- call?.recipe?.payloads?.length;
252
- if (contextOptions.contextual) {
253
- const vars = call?.nativeContext?.vars ?? contextOptions.vars;
254
- const media = (() => {
255
- try {
256
- return NativeMedia.prepare(recipe.rules.flatMap((rule) => rule.value.styles), vars, contextOptions);
257
- }
258
- catch (error) {
259
- throw new CompileError(error.message);
260
- }
261
- })();
262
- if (media) {
263
- const profiles = media.selections.map((selection) => {
264
- const selected = media.select(selection);
265
- const next = {
266
- ...recipe,
267
- rules: recipe.rules.map((rule) => ({
268
- ...rule,
269
- value: {
270
- ...rule.value,
271
- styles: rule.value.styles.map(selected.style),
272
- },
273
- })),
274
- };
275
- const source = call?.nativeContext
276
- ? {
277
- ...call,
278
- nativeContext: {
279
- ...call.nativeContext,
280
- vars: selected.vars,
281
- },
282
- }
283
- : call;
284
- const value = callable(next, name, source, {
285
- ...contextOptions,
286
- vars: selected.vars,
287
- });
288
- return `${JSON.stringify(selection)}:${value}`;
289
- });
290
- // A single static table cannot represent the responsive callable.
291
- delete recipes[name];
292
- return `${helper}Context.responsive(${JSON.stringify(media.queries)},{${profiles.join(',')}})`;
293
- }
294
- if (!program)
295
- compiled ??= Variants.compile({
296
- recipe,
297
- fonts: contextOptions.fonts,
298
- platform: contextOptions.platform,
299
- vars,
300
- units: contextOptions.units,
301
- });
302
- else {
303
- try {
304
- bindings = NativeBindings.prepare(recipe, call ?? {}, {
305
- ...contextOptions,
306
- vars,
307
- });
308
- }
309
- catch (error) {
310
- if (error instanceof StyleSheet.CompileError)
311
- throw error;
312
- throw new CompileError(error.message);
313
- }
314
- }
315
- const defaultVars = call?.nativeContext?.defaultVars ?? contextOptions.set ?? 'default';
316
- const tables = new Map();
317
- const alternatives = (vars ? Object.keys(vars) : ['default']).map((set) => ({
318
- set,
319
- schemes: ['light', 'dark'].map((colorScheme) => {
320
- const value = callable(recipe, name, call, {
321
- ...contextOptions,
322
- contextual: false,
323
- vars,
324
- set,
325
- colorScheme,
326
- }, compiled, bindings);
327
- if (!tables.has(value))
328
- tables.set(value, `${helper}Table${tables.size}`);
329
- return { colorScheme, value };
330
- }),
331
- }));
332
- const entries = alternatives.map(({ set, schemes }) => `${JSON.stringify(set)}:{${schemes.map(({ colorScheme, value }) => `${JSON.stringify(colorScheme)}:${tables.get(value)}`).join(',')}}`);
333
- const parameters = [...tables.values()].map((name, index) => typed ? `${name}:T${index}` : name);
334
- const types = typed
335
- ? `<${parameters.map((_, index) => `const T${index} extends (input:never)=>import('zyzz/runtime').Native.Props<object>`).join(',')},>`
336
- : '';
337
- const expression = `${types}(${parameters.join(',')})=>${helper}Context.create({${entries.join(',')}},${JSON.stringify(defaultVars)})`;
338
- let context = contexts.get(expression);
339
- if (!context) {
340
- context = `${helper}ContextFactory${contexts.size}`;
341
- while (names.has(context))
342
- context += '_';
343
- names.add(context);
344
- contexts.set(expression, context);
345
- }
346
- const inputs = [...tables.keys()].map((value) => initializers.get(value));
347
- if (inputs.every((input) => input !== undefined)) {
348
- const values = [];
349
- const arguments_ = inputs.map((input) => {
350
- const parameters = input.values.map((value) => {
351
- const parameter = `v${values.length}`;
352
- values.push(value);
353
- return parameter;
354
- });
355
- return `${input.name}(${parameters.join(',')})`;
356
- });
357
- if (values.length <= 64)
358
- return factory(`${context}(${arguments_.join(',')})`, values);
359
- }
360
- return `${context}(${[...tables.keys()].join(',')})`;
361
- }
362
- const axes = Object.entries(recipe.axes)
363
- .map(([axis, choices]) => `${JSON.stringify(axis)}:readonly ${JSON.stringify(choices)}`)
364
- .join(';');
365
- if (program) {
366
- const scalar = !!(call?.slots || call?.recipe?.payloads?.length);
367
- dynamic ||= scalar;
368
- finite ||= !scalar;
369
- const compiled = (() => {
370
- try {
371
- const compiled = NativeBindings.compile(recipe, call ?? {}, contextOptions, bindings);
372
- return scalar ? compiled : NativeBindings.finite(compiled);
373
- }
374
- catch (error) {
375
- if (error instanceof StyleSheet.CompileError)
376
- throw error;
377
- throw new CompileError(error.message);
378
- }
379
- })();
380
- const value = create(scalar ? dynamicHelper : `${helper}Static`, compiled);
381
- if (!typed)
382
- return value;
383
- if (!call?.slots && !call?.recipe?.payloads?.length)
384
- return `(${value} as import('zyzz/runtime').Native.Callable<{${axes}}>)`;
385
- let input = call.valuesType ?? '{}';
386
- if (call.recipe) {
387
- input = `{${Object.entries(recipe.axes)
388
- .map(([axis, choices]) => {
389
- const types = choices.map((choice) => call.recipeTypes?.[axis]?.[choice]
390
- ? `{${JSON.stringify(choice)}:${call.recipeTypes[axis][choice]}}`
391
- : choice === 'true' || choice === 'false'
392
- ? choice
393
- : JSON.stringify(choice));
394
- return `${JSON.stringify(axis)}?:${types.join('|')}|null|undefined`;
395
- })
396
- .join(';')}}`;
397
- }
398
- return `(${value} as import('zyzz/runtime').NativeDynamic.${call.recipe ? 'RecipeCallable' : 'Callable'}<${input}>)`;
399
- }
400
- compiled ??= Variants.compile({
401
- recipe,
402
- fonts: contextOptions.fonts,
403
- platform: contextOptions.platform,
404
- vars: contextOptions.vars,
405
- units: contextOptions.units,
406
- });
407
- recipes[name] = compiled;
408
- const styles = StyleSheet.select(compiled.styles, {
409
- set: contextOptions.set ?? 'default',
410
- colorScheme: contextOptions.colorScheme,
411
- });
412
- const cached = compiledCalls.get(compiled);
413
- const value = cached &&
414
- Object.keys(cached.styles).length === Object.keys(styles).length &&
415
- Object.entries(styles).every(([name, style]) => cached.styles[name] === style)
416
- ? cached.value
417
- : create(helper, {
418
- axes: compiled.axes,
419
- defaults: compiled.defaults,
420
- styles,
421
- });
422
- if (options.contextual)
423
- compiledCalls.set(compiled, { styles, value });
424
- if (!typed)
425
- return value;
426
- return `(${value} as import('zyzz/runtime').Native.Callable<{${axes}}>)`;
427
- }
428
- const packed = [];
429
- const explicit = new Set();
430
- function binding(node) {
431
- if (node.type === 'Identifier')
432
- explicit.add(node.name);
433
- else if (node.type === 'ObjectPattern')
434
- for (const property of node.properties)
435
- binding(property.type === 'RestElement' ? property.argument : property.value);
436
- else if (node.type === 'ArrayPattern')
437
- for (const element of node.elements) {
438
- if (element)
439
- binding(element);
440
- }
441
- else if (node.type === 'AssignmentPattern')
442
- binding(node.left);
443
- else if (node.type === 'RestElement')
444
- binding(node.argument);
445
- }
446
- for (const statement of parsed.program.body) {
447
- if (statement.type !== 'ExportNamedDeclaration' ||
448
- statement.exportKind === 'type')
449
- continue;
450
- for (const specifier of statement.specifiers)
451
- if (specifier.exportKind !== 'type')
452
- explicit.add(specifier.exported.type === 'Identifier'
453
- ? specifier.exported.name
454
- : specifier.exported.value);
455
- const declaration = statement.declaration;
456
- if (declaration?.type === 'VariableDeclaration') {
457
- for (const item of declaration.declarations)
458
- binding(item.id);
459
- }
460
- else if (declaration &&
461
- 'id' in declaration &&
462
- declaration.id?.type === 'Identifier')
463
- explicit.add(declaration.id.name);
464
- }
465
- for (const statement of parsed.program.body) {
466
- if ((statement.type !== 'ImportDeclaration' &&
467
- statement.type !== 'ExportNamedDeclaration' &&
468
- statement.type !== 'ExportAllDeclaration') ||
469
- !statement.source)
470
- continue;
471
- if ((statement.type === 'ImportDeclaration' &&
472
- statement.importKind === 'type') ||
473
- (statement.type !== 'ImportDeclaration' &&
474
- statement.exportKind === 'type'))
475
- continue;
476
- const specifier = statement.source.value;
477
- const exports = options[Themes.context]?.libraries?.[specifier];
478
- if (!exports)
479
- continue;
480
- let imported;
481
- function original() {
482
- if (imported)
483
- return imported;
484
- imported = `${helper}Namespace${packed.length}`;
485
- while (names.has(imported))
486
- imported += '_';
487
- names.add(imported);
488
- packed.push(`import * as ${imported} from ${JSON.stringify(specifier)};`);
489
- return imported;
490
- }
491
- function overlay(original, expression) {
492
- let overrides = `${helper}Members${packed.length}`;
493
- while (names.has(overrides))
494
- overrides += '_';
495
- names.add(overrides);
496
- packed.push(`const ${overrides}=${expression};`);
497
- // Getter descriptors retain live bindings outside the recipe contract.
498
- return `Object.freeze(Object.defineProperties({...${original},...${overrides}},Object.fromEntries(Object.keys(${original}).filter(key=>!Object.hasOwn(${overrides},key)).map(key=>[key,{get:()=>Reflect.get(${original},key)}]))))`;
499
- }
500
- function value(name, link = exports[name], input, path = [name]) {
501
- if (!link || link.kind !== 'style-reference')
502
- return undefined;
503
- if (link.members) {
504
- const source = input ?? `${original()}[${JSON.stringify(name)}]`;
505
- const expression = `{${Object.entries(link.members)
506
- .map(([member, link]) => `[${JSON.stringify(member)}]:${value(`${name}.${member}`, link, `${source}[${JSON.stringify(member)}]`, [...path, member])}`)
507
- .join(',')}}`;
508
- return overlay(source, expression);
509
- }
510
- const recipe = link.style?.staticRecipe ?? link.style?.dynamic?.recipe;
511
- if (!recipe ||
512
- link.style?.output ||
513
- (link.style?.slots.length && !link.style.dynamic))
514
- throw new CompileError(`Packed native callable ${name} requires a static recipe contract.`);
515
- const expression = callable(recipe, `${specifier}:${name}`, {
516
- nativeContext: link.style?.nativeContext,
517
- ...(link.style?.dynamic
518
- ? {
519
- slots: link.style.dynamic.slots,
520
- recipe: {
521
- axes: recipe.axes,
522
- defaults: recipe.defaults,
523
- payloads: link.style.dynamic.payloads,
524
- defaultPayloads: link.style.dynamic.defaultPayloads,
525
- },
526
- }
527
- : {}),
528
- });
529
- if (!link.style?.dynamic || !typed)
530
- return expression;
531
- const type = `typeof import(${JSON.stringify(specifier)})${path
532
- .map((part) => `[${JSON.stringify(part)}]`)
533
- .join('')}`;
534
- return `(${expression} as import('zyzz/runtime').NativeDynamic.From<${type}>)`;
535
- }
536
- function namespace() {
537
- if (!Object.values(exports).some((link) => link.kind === 'style-reference'))
538
- return undefined;
539
- const imported = original();
540
- const members = Object.keys(exports).flatMap((name) => {
541
- const expression = value(name, exports[name], `${imported}[${JSON.stringify(name)}]`);
542
- return expression === undefined
543
- ? []
544
- : [`[${JSON.stringify(name)}]:${expression}`];
545
- });
546
- return overlay(imported, `{${members.join(',')}}`);
547
- }
548
- if (statement.type === 'ExportAllDeclaration') {
549
- if (statement.exported) {
550
- const expression = namespace();
551
- if (expression === undefined)
552
- continue;
553
- let local = `${helper}Export${packed.length}`;
554
- while (names.has(local))
555
- local += '_';
556
- names.add(local);
557
- const name = statement.exported.type === 'Identifier'
558
- ? statement.exported.name
559
- : statement.exported.value;
560
- packed.push(`const ${local}=${expression};export {${local} as ${JSON.stringify(name)}};`);
561
- overwrite(statement.start, statement.end, '');
562
- continue;
563
- }
564
- for (const name of Object.keys(exports)) {
565
- if (name === 'default' || explicit.has(name))
566
- continue;
567
- const expression = value(name);
568
- if (expression === undefined)
569
- continue;
570
- explicit.add(name);
571
- let local = `${helper}Export${packed.length}`;
572
- while (names.has(local))
573
- local += '_';
574
- names.add(local);
575
- packed.push(`const ${local}=${expression};export {${local} as ${JSON.stringify(name)}};`);
576
- }
577
- continue;
578
- }
579
- const kept = [];
580
- for (const specifier of statement.specifiers) {
581
- if (specifier.type === 'ImportNamespaceSpecifier') {
582
- const expression = namespace();
583
- if (expression === undefined) {
584
- packed.push(`import * as ${specifier.local.name} from ${JSON.stringify(statement.source.value)};`);
585
- }
586
- else
587
- packed.push(`const ${specifier.local.name}=${expression};`);
588
- continue;
589
- }
590
- if ((specifier.type === 'ImportSpecifier' &&
591
- specifier.importKind === 'type') ||
592
- (specifier.type === 'ExportSpecifier' &&
593
- specifier.exportKind === 'type')) {
594
- kept.push(options.source.slice(specifier.start, specifier.end));
595
- continue;
596
- }
597
- const imported = specifier.type === 'ImportDefaultSpecifier'
598
- ? 'default'
599
- : specifier.type === 'ImportSpecifier'
600
- ? specifier.imported
601
- : specifier.local;
602
- const name = typeof imported === 'string'
603
- ? imported
604
- : imported.type === 'Identifier'
605
- ? imported.name
606
- : imported.value;
607
- const expression = value(name);
608
- if (expression === undefined) {
609
- if (specifier.type === 'ImportDefaultSpecifier')
610
- kept.push(`default as ${specifier.local.name}`);
611
- else
612
- kept.push(options.source.slice(specifier.start, specifier.end));
613
- continue;
614
- }
615
- if (specifier.type === 'ExportSpecifier') {
616
- let local = `${helper}Export${packed.length}`;
617
- while (names.has(local))
618
- local += '_';
619
- names.add(local);
620
- const exported = specifier.exported.type === 'Identifier'
621
- ? specifier.exported.name
622
- : specifier.exported.value;
623
- packed.push(`const ${local}=${expression};export {${local} as ${JSON.stringify(exported)}};`);
624
- }
625
- else
626
- packed.push(`const ${specifier.local.name}=${expression};`);
627
- }
628
- const keyword = statement.type === 'ImportDeclaration' ? 'import' : 'export';
629
- overwrite(statement.start, statement.end, kept.length
630
- ? `${keyword} {${kept.join(',')}} from ${JSON.stringify(statement.source.value)};`
631
- : `import ${JSON.stringify(statement.source.value)};`);
632
- }
633
- const compositions = [];
634
- for (const statement of parsed.program.body) {
635
- if (statement.type === 'ExportAllDeclaration' &&
636
- statement.source.value === 'zyzz' &&
637
- statement.exportKind !== 'type')
638
- throw new CompileError('Native modules require named re-exports from zyzz.');
639
- if (statement.type === 'ExportNamedDeclaration' &&
640
- statement.source?.value === 'zyzz' &&
641
- statement.exportKind !== 'type') {
642
- const cx = statement.specifiers.filter((specifier) => specifier.exportKind !== 'type' &&
643
- (specifier.local.type === 'Identifier'
644
- ? specifier.local.name
645
- : specifier.local.value) === 'cx');
646
- if (!cx.length)
647
- continue;
648
- let binding = `${helper}Compose`;
649
- while (names.has(binding))
650
- binding += '_';
651
- names.add(binding);
652
- compositions.push(`const ${binding}=${helper}.compose;`);
653
- const kept = statement.specifiers
654
- .filter((specifier) => !cx.includes(specifier))
655
- .map((specifier) => options.source.slice(specifier.start, specifier.end));
656
- const exports = cx.map((specifier) => `${binding} as ${options.source.slice(specifier.exported.start, specifier.exported.end)}`);
657
- overwrite(statement.start, statement.end, `${kept.length ? `export {${kept.join(',')}} from 'zyzz';` : ''}export {${exports.join(',')}};`);
658
- continue;
659
- }
660
- if (statement.type !== 'ImportDeclaration' ||
661
- statement.source.value !== 'zyzz' ||
662
- statement.importKind === 'type')
663
- continue;
664
- const cx = statement.specifiers.filter((specifier) => specifier.type === 'ImportSpecifier' &&
665
- specifier.importKind !== 'type' &&
666
- (specifier.imported.type === 'Identifier'
667
- ? specifier.imported.name
668
- : specifier.imported.value) === 'cx');
669
- if (!cx.length)
670
- continue;
671
- compositions.push(...cx.map((specifier) => `const ${specifier.local.name}=${helper}.compose;`));
672
- const kept = statement.specifiers.filter((specifier) => !cx.includes(specifier));
673
- const named = kept
674
- .filter((specifier) => specifier.type === 'ImportSpecifier')
675
- .map((specifier) => options.source.slice(specifier.start, specifier.end));
676
- const other = kept
677
- .filter((specifier) => specifier.type !== 'ImportSpecifier')
678
- .map((specifier) => options.source.slice(specifier.start, specifier.end));
679
- const imports = [
680
- ...other,
681
- ...(named.length ? [`{${named.join(',')}}`] : []),
682
- ];
683
- overwrite(statement.start, statement.end, imports.length ? `import ${imports.join(',')} from 'zyzz';` : '');
684
- }
685
- if (extracted.calls.length ||
686
- compositions.length ||
687
- packed.length ||
688
- variables.size ||
689
- imports.size) {
690
- let offset = 0;
691
- if (options.source.startsWith('#!')) {
692
- const newline = /\r\n|[\n\r\u2028\u2029]/.exec(options.source);
693
- offset = newline
694
- ? newline.index + newline[0].length
695
- : options.source.length;
696
- }
697
- for (const node of parsed.program.body) {
698
- if (node.type !== 'ExpressionStatement' || !node.directive)
699
- break;
700
- offset = node.end;
701
- }
702
- const prelude = `\nimport {Native as ${helper}${dynamic ? `,NativeDynamic as ${dynamicHelper}` : ''}${finite ? `,NativeStatic as ${helper}Static` : ''}${options.contextual ? `,NativeContext as ${helper}Context` : ''}${variables.size ? `,NativeVars as ${helper}Vars` : ''}} from 'zyzz/runtime';\n${[...factories].map(([expression, factory]) => `const ${factory.name}=(${factory.parameters.join(',')})=>${expression};`).join('\n')}\n${[...contexts].map(([expression, name]) => `const ${name}=${expression};`).join('\n')}\n${[...variables].map(([value, name]) => `${shared?.definitions.has(value) ? 'export ' : ''}const ${name}=${helper}Vars.create(JSON.parse(${JSON.stringify(value)}));`).join('\n')}\n${[...imports, ...compositions, ...packed].join('\n')}\n`;
703
- module.appendLeft(offset, prelude);
704
- edits.push({ start: offset, end: offset, code: prelude, expression: false });
705
- }
706
- return output(module, {
707
- edits,
13
+ const output = Results.call('native.compile', {
14
+ ...Results.native(options),
15
+ context: options[Context.key] === true,
708
16
  moduleId: options.moduleId,
709
- recipes: Object.freeze(recipes),
17
+ source: options.source,
710
18
  });
19
+ return {
20
+ [Edits.key]: output.edits,
21
+ code: output.code,
22
+ map: output.map,
23
+ recipes: Results.frozen(output.recipes),
24
+ };
711
25
  }
712
26
  /** An unsupported native source feature. */
713
27
  export class CompileError extends Error {
714
28
  /** Stable namespaced diagnostic name. */
715
29
  name = 'Native.CompileError';
716
30
  }
717
- // Keep lazy maps independent of the compiler's parser trees and extracted styles.
718
- function output(module, options) {
719
- let sourceMap;
720
- return {
721
- [Edits.key]: options.edits,
722
- code: module.toString(),
723
- get map() {
724
- return (sourceMap ??= module
725
- .generateMap({
726
- hires: true,
727
- includeContent: true,
728
- source: options.moduleId,
729
- })
730
- .toString());
731
- },
732
- recipes: options.recipes,
733
- };
734
- }
735
31
  //# sourceMappingURL=Native.js.map