@fluixi/compiler 1.0.0-alpha.83 → 1.0.0-alpha.85

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 (241) hide show
  1. package/dist/analyze/expr-shape.cjs +62 -1
  2. package/dist/analyze/expr-shape.d.cts +14 -0
  3. package/dist/analyze/expr-shape.d.ts +2 -2
  4. package/dist/analyze/expr-shape.js +1 -1
  5. package/dist/analyze/expr-shape.mjs +41 -1
  6. package/dist/analyze/intrinsics.cjs +80 -1
  7. package/dist/analyze/intrinsics.d.cts +66 -0
  8. package/dist/analyze/intrinsics.d.ts +7 -7
  9. package/dist/analyze/intrinsics.d.ts.map +1 -1
  10. package/dist/analyze/intrinsics.js +3 -3
  11. package/dist/analyze/intrinsics.mjs +59 -1
  12. package/dist/analyze/paren.cjs +134 -0
  13. package/dist/analyze/paren.d.cts +23 -0
  14. package/dist/analyze/paren.d.ts +24 -0
  15. package/dist/analyze/paren.d.ts.map +1 -0
  16. package/dist/analyze/paren.js +168 -0
  17. package/dist/analyze/paren.mjs +113 -0
  18. package/dist/analyze/props-destructure.cjs +226 -1
  19. package/dist/analyze/props-destructure.d.cts +83 -0
  20. package/dist/analyze/props-destructure.d.ts +3 -3
  21. package/dist/analyze/props-destructure.d.ts.map +1 -1
  22. package/dist/analyze/props-destructure.js +4 -4
  23. package/dist/analyze/props-destructure.mjs +205 -1
  24. package/dist/analyze/reactive-bindings.cjs +190 -1
  25. package/dist/analyze/reactive-bindings.d.cts +42 -0
  26. package/dist/analyze/reactive-bindings.d.ts +1 -1
  27. package/dist/analyze/reactive-bindings.js +2 -2
  28. package/dist/analyze/reactive-bindings.mjs +167 -1
  29. package/dist/analyze/reactive-expr.cjs +38 -1
  30. package/dist/analyze/reactive-expr.d.cts +38 -0
  31. package/dist/analyze/reactive-expr.d.ts +4 -4
  32. package/dist/analyze/reactive-expr.d.ts.map +1 -1
  33. package/dist/analyze/reactive-expr.js +2 -2
  34. package/dist/analyze/reactive-expr.mjs +17 -1
  35. package/dist/analyze/static-graph.cjs +811 -1
  36. package/dist/analyze/static-graph.d.cts +102 -0
  37. package/dist/analyze/static-graph.d.ts +1 -1
  38. package/dist/analyze/static-graph.d.ts.map +1 -1
  39. package/dist/analyze/static-graph.js +11 -11
  40. package/dist/analyze/static-graph.mjs +793 -1
  41. package/dist/babel-TGY76XJ7.mjs +636 -0
  42. package/dist/chunk-4PLHS2FP.mjs +158 -0
  43. package/dist/chunk-6DB5FXS4.mjs +1718 -0
  44. package/dist/chunk-F74GFKSL.mjs +16 -0
  45. package/dist/chunk-G6QC2WRJ.mjs +11 -0
  46. package/dist/chunk-RUDJDZAA.mjs +1078 -0
  47. package/dist/codegen/backend.cjs +18 -1
  48. package/dist/codegen/backend.d.cts +35 -0
  49. package/dist/codegen/backends/imperative.cjs +542 -1
  50. package/dist/codegen/backends/imperative.d.cts +11 -0
  51. package/dist/codegen/backends/imperative.d.ts +1 -1
  52. package/dist/codegen/backends/imperative.d.ts.map +1 -1
  53. package/dist/codegen/backends/imperative.js +24 -20
  54. package/dist/codegen/backends/imperative.mjs +519 -1
  55. package/dist/codegen/contract.cjs +52 -1
  56. package/dist/codegen/contract.d.cts +24 -0
  57. package/dist/codegen/contract.d.ts +2 -2
  58. package/dist/codegen/contract.js +2 -2
  59. package/dist/codegen/contract.mjs +31 -1
  60. package/dist/codegen/partial-template.cjs +176 -1
  61. package/dist/codegen/partial-template.d.cts +61 -0
  62. package/dist/codegen/partial-template.d.ts +4 -4
  63. package/dist/codegen/partial-template.js +0 -0
  64. package/dist/codegen/partial-template.mjs +153 -1
  65. package/dist/codegen/serialize-static.cjs +125 -1
  66. package/dist/codegen/serialize-static.d.cts +38 -0
  67. package/dist/codegen/serialize-static.d.ts +3 -3
  68. package/dist/codegen/serialize-static.js +6 -6
  69. package/dist/codegen/serialize-static.mjs +104 -1
  70. package/dist/frontend/babel/build-ir-lit.cjs +1509 -1
  71. package/dist/frontend/babel/build-ir-lit.d.cts +26 -0
  72. package/dist/frontend/babel/build-ir-lit.d.ts +2 -2
  73. package/dist/frontend/babel/build-ir-lit.mjs +1478 -1
  74. package/dist/frontend/babel/build-ir.cjs +1524 -1
  75. package/dist/frontend/babel/build-ir.d.cts +35 -0
  76. package/dist/frontend/babel/build-ir.d.ts +2 -2
  77. package/dist/frontend/babel/build-ir.js +2 -2
  78. package/dist/frontend/babel/build-ir.mjs +1495 -1
  79. package/dist/frontend/babel/index.cjs +2186 -1
  80. package/dist/frontend/babel/index.d.cts +33 -0
  81. package/dist/frontend/babel/index.d.ts +1 -1
  82. package/dist/frontend/babel/index.js +1 -1
  83. package/dist/frontend/babel/index.mjs +2156 -1
  84. package/dist/frontend/babel/lower-template.cjs +1507 -1
  85. package/dist/frontend/babel/lower-template.d.cts +23 -0
  86. package/dist/frontend/babel/lower-template.d.ts +1 -1
  87. package/dist/frontend/babel/lower-template.js +2 -2
  88. package/dist/frontend/babel/lower-template.mjs +1478 -1
  89. package/dist/frontend/babel/plugin.cjs +2132 -1
  90. package/dist/frontend/babel/plugin.d.cts +95 -0
  91. package/dist/frontend/babel/plugin.d.ts +5 -5
  92. package/dist/frontend/babel/plugin.d.ts.map +1 -1
  93. package/dist/frontend/babel/plugin.js +14 -14
  94. package/dist/frontend/babel/plugin.mjs +2103 -1
  95. package/dist/frontend/babel/server-functions.cjs +110 -1
  96. package/dist/frontend/babel/server-functions.d.cts +10 -0
  97. package/dist/frontend/babel/server-functions.mjs +89 -1
  98. package/dist/frontend/babel/types.cjs +18 -1
  99. package/dist/frontend/babel/types.d.cts +33 -0
  100. package/dist/frontend/types.cjs +18 -1
  101. package/dist/frontend/types.d.cts +25 -0
  102. package/dist/frontend/vocabulary.cjs +98 -0
  103. package/dist/frontend/vocabulary.d.cts +79 -0
  104. package/dist/frontend/vocabulary.d.ts +80 -0
  105. package/dist/frontend/vocabulary.d.ts.map +1 -0
  106. package/dist/frontend/vocabulary.js +124 -0
  107. package/dist/frontend/vocabulary.mjs +77 -0
  108. package/dist/index.cjs +1595 -14
  109. package/dist/index.d.cts +27 -0
  110. package/dist/index.d.ts +1 -1
  111. package/dist/index.js +4 -4
  112. package/dist/index.mjs +1575 -14
  113. package/dist/integrations.cjs +4312 -26
  114. package/dist/integrations.d.cts +215 -0
  115. package/dist/integrations.d.ts +9 -9
  116. package/dist/integrations.d.ts.map +1 -1
  117. package/dist/integrations.js +29 -8
  118. package/dist/integrations.mjs +536 -18
  119. package/dist/ir/nodes.cjs +18 -1
  120. package/dist/ir/nodes.d.cts +168 -0
  121. package/dist/ir/nodes.d.ts +6 -6
  122. package/dist/lower/compile-template.cjs +1356 -1
  123. package/dist/lower/compile-template.d.cts +69 -0
  124. package/dist/lower/compile-template.d.ts +3 -3
  125. package/dist/lower/compile-template.js +1 -1
  126. package/dist/lower/compile-template.mjs +1336 -1
  127. package/dist/lower/jsx.cjs +529 -1
  128. package/dist/lower/jsx.d.cts +25 -0
  129. package/dist/lower/jsx.d.ts +1 -1
  130. package/dist/lower/jsx.d.ts.map +1 -1
  131. package/dist/lower/jsx.js +6 -5
  132. package/dist/lower/jsx.mjs +506 -1
  133. package/dist/lower/template.cjs +1061 -1
  134. package/dist/lower/template.d.cts +53 -0
  135. package/dist/lower/template.d.ts +3 -3
  136. package/dist/lower/template.d.ts.map +1 -1
  137. package/dist/lower/template.js +12 -11
  138. package/dist/lower/template.mjs +1042 -1
  139. package/dist/lower/text.cjs +42 -1
  140. package/dist/lower/text.d.cts +10 -0
  141. package/dist/lower/text.d.ts +2 -2
  142. package/dist/lower/text.d.ts.map +1 -1
  143. package/dist/lower/text.js +2 -2
  144. package/dist/lower/text.mjs +21 -1
  145. package/dist/optimize/analyze-static.cjs +112 -1
  146. package/dist/optimize/analyze-static.d.cts +39 -0
  147. package/dist/optimize/analyze-static.d.ts +2 -2
  148. package/dist/optimize/analyze-static.js +2 -2
  149. package/dist/optimize/analyze-static.mjs +91 -1
  150. package/dist/optimize/collapse-strategies.cjs +90 -1
  151. package/dist/optimize/collapse-strategies.d.cts +30 -0
  152. package/dist/optimize/collapse-strategies.d.ts +3 -3
  153. package/dist/optimize/collapse-strategies.mjs +67 -1
  154. package/dist/options.cjs +33 -1
  155. package/dist/options.d.cts +39 -0
  156. package/dist/options.d.ts +2 -2
  157. package/dist/options.mjs +12 -1
  158. package/dist/resolve/builtins.cjs +73 -1
  159. package/dist/resolve/builtins.d.cts +68 -0
  160. package/dist/resolve/builtins.d.ts +8 -8
  161. package/dist/resolve/builtins.d.ts.map +1 -1
  162. package/dist/resolve/builtins.js +4 -4
  163. package/dist/resolve/builtins.mjs +53 -1
  164. package/dist/resolve/component-globals.cjs +234 -14
  165. package/dist/resolve/component-globals.d.cts +80 -0
  166. package/dist/resolve/component-globals.d.ts +5 -5
  167. package/dist/resolve/component-globals.js +10 -10
  168. package/dist/resolve/component-globals.mjs +211 -14
  169. package/dist/resolve/component-resolver.cjs +80 -1
  170. package/dist/resolve/component-resolver.d.cts +68 -0
  171. package/dist/resolve/component-resolver.d.ts +3 -3
  172. package/dist/resolve/component-resolver.d.ts.map +1 -1
  173. package/dist/resolve/component-resolver.js +3 -3
  174. package/dist/resolve/component-resolver.mjs +59 -1
  175. package/dist/resolve/load-directive.cjs +93 -1
  176. package/dist/resolve/load-directive.d.cts +53 -0
  177. package/dist/resolve/load-directive.d.ts +5 -5
  178. package/dist/resolve/load-directive.js +6 -6
  179. package/dist/resolve/load-directive.mjs +72 -1
  180. package/dist/resolve/resolve-ir.cjs +108 -1
  181. package/dist/resolve/resolve-ir.d.cts +53 -0
  182. package/dist/resolve/resolve-ir.d.ts +6 -6
  183. package/dist/resolve/resolve-ir.d.ts.map +1 -1
  184. package/dist/resolve/resolve-ir.js +1 -1
  185. package/dist/resolve/resolve-ir.mjs +85 -1
  186. package/dist/resolve/write-globals.cjs +319 -14
  187. package/dist/resolve/write-globals.d.cts +30 -0
  188. package/dist/resolve/write-globals.js +2 -2
  189. package/dist/resolve/write-globals.mjs +298 -14
  190. package/dist/server-fns-ZYWQTSZU.mjs +78 -0
  191. package/dist/server-functions-PCERFA7A.mjs +82 -0
  192. package/dist/transform/bindings.cjs +71 -1
  193. package/dist/transform/bindings.d.cts +16 -0
  194. package/dist/transform/bindings.d.ts +1 -1
  195. package/dist/transform/bindings.js +1 -1
  196. package/dist/transform/bindings.mjs +50 -1
  197. package/dist/transform/index.cjs +2732 -8
  198. package/dist/transform/index.d.cts +15 -0
  199. package/dist/transform/index.mjs +3773 -17
  200. package/dist/transform/intrinsics.cjs +216 -3
  201. package/dist/transform/intrinsics.d.cts +21 -0
  202. package/dist/transform/intrinsics.js +1 -1
  203. package/dist/transform/intrinsics.mjs +193 -3
  204. package/dist/transform/props.cjs +441 -3
  205. package/dist/transform/props.d.cts +45 -0
  206. package/dist/transform/props.d.ts +1 -1
  207. package/dist/transform/props.d.ts.map +1 -1
  208. package/dist/transform/props.js +4 -4
  209. package/dist/transform/props.mjs +1482 -12
  210. package/dist/transform/server-fn-id.cjs +35 -1
  211. package/dist/transform/server-fn-id.d.cts +9 -0
  212. package/dist/transform/server-fn-id.d.ts +1 -1
  213. package/dist/transform/server-fn-id.js +2 -2
  214. package/dist/transform/server-fn-id.mjs +14 -1
  215. package/dist/transform/server-fns.cjs +114 -2
  216. package/dist/transform/server-fns.d.cts +12 -0
  217. package/dist/transform/server-fns.js +3 -3
  218. package/dist/transform/server-fns.mjs +1155 -11
  219. package/dist/transform/source-locations.cjs +330 -1
  220. package/dist/transform/source-locations.d.cts +43 -0
  221. package/dist/transform/source-locations.d.ts +1 -1
  222. package/dist/transform/source-locations.js +5 -5
  223. package/dist/transform/source-locations.mjs +307 -1
  224. package/dist/transform/templates.cjs +2701 -7
  225. package/dist/transform/templates.d.cts +69 -0
  226. package/dist/transform/templates.d.ts +2 -2
  227. package/dist/transform/templates.d.ts.map +1 -1
  228. package/dist/transform/templates.js +7 -7
  229. package/dist/transform/templates.mjs +3743 -16
  230. package/dist/transform-RWDTQUF5.mjs +893 -0
  231. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  232. package/package.json +6 -5
  233. package/dist/babel-VXKH6MRQ.mjs +0 -1
  234. package/dist/chunk-3SAEGOMQ.mjs +0 -1
  235. package/dist/chunk-5KMMN5QP.mjs +0 -1
  236. package/dist/chunk-IBRM4W7I.mjs +0 -10
  237. package/dist/chunk-OHHZCYIQ.mjs +0 -1
  238. package/dist/chunk-YKZ54NVE.mjs +0 -1
  239. package/dist/server-fns-6QM243HC.mjs +0 -2
  240. package/dist/server-functions-E3LKCZ4R.mjs +0 -1
  241. package/dist/transform-C4ZXRVGP.mjs +0 -8
@@ -1,22 +1,306 @@
1
- import{mkdirSync as K,readFileSync as S,writeFileSync as V}from"node:fs";import{dirname as N,relative as k,sep as L,resolve as h}from"node:path";var B=e=>"components"in e;function E(e,t){return e.replace(/\$(\d+)/g,(r,s)=>t[Number(s)]??r)}function F(e,t){return typeof t=="string"?{module:t,export:e}:t}function M(e=[]){let t=new Map,r=[],s=[];for(let i of e){if(!B(i)){s.push(i);continue}for(let[l,u]of Object.entries(i.components)){let p=F(l,u),d=t.get(l);if(d&&d.module!==p.module){let m=r.find(R=>R.name===l);m?m.modules.push(p.module):r.push({name:l,modules:[d.module,p.module]});continue}t.set(l,p)}}let n=new Map;return{resolve:i=>{if(n.has(i))return n.get(i);let l=t.get(i);if(!l)for(let u of s){let p=i.match(new RegExp(u.match.source,u.match.flags.replace("g","")));if(p){l={module:E(u.module,p),export:u.export?E(u.export,p):i};break}}return n.set(i,l),l},names:()=>[...t.keys()],conflicts:()=>r}}var C=["Show","For","Index","Switch","Match","Portal","Dynamic","ErrorBoundary"],y=["Suspense","SuspenseList","Await"],w=["Router","Outlet","Redirect","Link"],te=[...C,...y,...w],ne=new Set([...C,...y]);function I(e={}){let{controlFlowModule:t="@fluixi/dom",coreModule:r="@fluixi/core",routerModule:s="@fluixi/core/router"}=e,n={};for(let c of C)n[c]=t;for(let c of y)n[c]=r;for(let c of w)n[c]=s;return n}var f="@fluixi/reactive/signal",v={$signal:{export:"signal",module:f,returns:"signal-handle"},$memo:{export:"memo",module:f,returns:"memo-handle"},$effect:{export:"effect",module:f,returns:"effect"},$store:{export:"store",module:"@fluixi/reactive/store",returns:"store-handle"},$resource:{export:"resource",module:f,returns:"resource-handle"},$selector:{export:"createSelector",module:f,returns:"memo-accessor"},$deferred:{export:"createDeferred",module:f,returns:"memo-accessor"},$untrack:{export:"untrack",module:f,returns:"plain"},$untrackStore:{export:"untrackStore",module:"@fluixi/reactive/store",returns:"plain"}};var re=new RegExp(`\\$(?:${Object.keys(v).map(e=>e.slice(1)).join("|")})\\s*\\(`);var U=new Set(["Text","Image","Option","Audio","Comment","Range","Selection","Notification","Event","Document","Element","Node","Screen","Window","Location","History","Storage","Response","Request","Headers"]);function H(e){if(e.startsWith(".")||e.startsWith("/")||/^[~@]\//.test(e))return;let t=e.split("/");return e.startsWith("@")?t.slice(0,2).join("/"):t[0]}function O(e){return`_${e.replace(/[^A-Za-z0-9]/g,"_")}`}function j(e,t={}){let{available:r,builtins:s=!0,intrinsics:n=!0,generator:c="@fluixi/compiler",specifier:i=o=>o}=t,l=[...e];s&&l.push({components:I()});let u=M(l),p=r?new Set(r):void 0,d=[],m=[],R=[],b=new Map;for(let o of[...u.names()].sort()){let a=u.resolve(o);if(!a)continue;let g=H(a.module);U.has(o)?m.push(o):p&&g&&!p.has(g)?R.push(o):(d.push(o),b.set(o,a))}let D=n?[...new Set(Object.values(v).map(o=>o.module))]:[],$=[...new Set([...d.map(o=>b.get(o).module),...D])].sort().map(o=>`import * as ${O(o)} from '${i(o)}';`),_=d.map(o=>{let a=b.get(o),g=O(a.module);return a.export==="default"?` const ${o}: typeof ${g}.default;`:` export import ${o} = ${g}.${a.export};`}),G=m.length>0?`//
2
- // Import these explicitly lib.dom already declares the name, so an ambient
1
+ // src/resolve/write-globals.ts
2
+ import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
3
+ import { dirname, relative, sep, resolve as resolvePath } from "node:path";
4
+
5
+ // src/resolve/component-resolver.ts
6
+ var isMapRule = (rule) => "components" in rule;
7
+ function substitute(template, match) {
8
+ return template.replace(/\$(\d+)/g, (whole, index) => {
9
+ const group = match[Number(index)];
10
+ return group ?? whole;
11
+ });
12
+ }
13
+ function normalise(name, entry) {
14
+ return typeof entry === "string" ? { module: entry, export: name } : entry;
15
+ }
16
+ function createComponentResolver(rules = []) {
17
+ const exact = /* @__PURE__ */ new Map();
18
+ const conflicts = [];
19
+ const patterns = [];
20
+ for (const rule of rules) {
21
+ if (!isMapRule(rule)) {
22
+ patterns.push(rule);
23
+ continue;
24
+ }
25
+ for (const [name, entry] of Object.entries(rule.components)) {
26
+ const resolved = normalise(name, entry);
27
+ const existing = exact.get(name);
28
+ if (existing && existing.module !== resolved.module) {
29
+ const conflict = conflicts.find((c) => c.name === name);
30
+ if (conflict) conflict.modules.push(resolved.module);
31
+ else conflicts.push({ name, modules: [existing.module, resolved.module] });
32
+ continue;
33
+ }
34
+ exact.set(name, resolved);
35
+ }
36
+ }
37
+ const cache = /* @__PURE__ */ new Map();
38
+ const resolve = (name) => {
39
+ if (cache.has(name)) return cache.get(name);
40
+ let result = exact.get(name);
41
+ if (!result) {
42
+ for (const rule of patterns) {
43
+ const match = name.match(new RegExp(rule.match.source, rule.match.flags.replace("g", "")));
44
+ if (!match) continue;
45
+ result = {
46
+ module: substitute(rule.module, match),
47
+ export: rule.export ? substitute(rule.export, match) : name
48
+ };
49
+ break;
50
+ }
51
+ }
52
+ cache.set(name, result);
53
+ return result;
54
+ };
55
+ return {
56
+ resolve,
57
+ names: () => [...exact.keys()],
58
+ conflicts: () => conflicts
59
+ };
60
+ }
61
+
62
+ // src/resolve/builtins.ts
63
+ var DOM_CONTROL_FLOW = [
64
+ "Show",
65
+ "For",
66
+ "Index",
67
+ "Switch",
68
+ "Match",
69
+ "Portal",
70
+ "Dynamic",
71
+ "ErrorBoundary"
72
+ ];
73
+ var CORE_CONTROL_FLOW = ["Suspense", "SuspenseList", "Await"];
74
+ var ROUTER_COMPONENTS = ["Router", "Outlet", "Redirect", "Link"];
75
+ var BUILTIN_COMPONENTS = [
76
+ ...DOM_CONTROL_FLOW,
77
+ ...CORE_CONTROL_FLOW,
78
+ ...ROUTER_COMPONENTS
79
+ ];
80
+ var RESERVED_COMPONENTS = /* @__PURE__ */ new Set([
81
+ ...DOM_CONTROL_FLOW,
82
+ ...CORE_CONTROL_FLOW
83
+ ]);
84
+ function builtinComponentMap(modules = {}) {
85
+ const {
86
+ controlFlowModule = "@fluixi/dom",
87
+ coreModule = "@fluixi/core",
88
+ routerModule = "@fluixi/core/router"
89
+ } = modules;
90
+ const map = {};
91
+ for (const name of DOM_CONTROL_FLOW) map[name] = controlFlowModule;
92
+ for (const name of CORE_CONTROL_FLOW) map[name] = coreModule;
93
+ for (const name of ROUTER_COMPONENTS) map[name] = routerModule;
94
+ return map;
95
+ }
96
+
97
+ // src/analyze/intrinsics.ts
98
+ var REACTIVE_MODULE = "@fluixi/reactive/signal";
99
+ var INTRINSICS = {
100
+ $signal: { export: "signal", module: REACTIVE_MODULE, returns: "signal-handle" },
101
+ $memo: { export: "memo", module: REACTIVE_MODULE, returns: "memo-handle" },
102
+ $effect: { export: "effect", module: REACTIVE_MODULE, returns: "effect" },
103
+ $store: { export: "store", module: "@fluixi/reactive/store", returns: "store-handle" },
104
+ $resource: { export: "resource", module: REACTIVE_MODULE, returns: "resource-handle" },
105
+ // No short runtime form for these yet, so the intrinsic stands for the `create*`
106
+ // name. Still worth having: no import to write, and when a shorter form is
107
+ // designed, the change is this line rather than a compiler pass.
108
+ $selector: { export: "createSelector", module: REACTIVE_MODULE, returns: "memo-accessor" },
109
+ $deferred: { export: "createDeferred", module: REACTIVE_MODULE, returns: "memo-accessor" },
110
+ // Not value constructors, but the compiler has to know them: they change what a read
111
+ // does. `untrack` suppresses dependency collection, which is exactly the kind of thing
112
+ // dependency analysis must not guess at.
113
+ $untrack: { export: "untrack", module: REACTIVE_MODULE, returns: "plain" },
114
+ $untrackStore: { export: "untrackStore", module: "@fluixi/reactive/store", returns: "plain" }
115
+ };
116
+ var INTRINSIC_CALL = new RegExp(`\\$(?:${Object.keys(INTRINSICS).map((n) => n.slice(1)).join("|")})\\s*\\(`);
117
+
118
+ // src/resolve/component-globals.ts
119
+ var DOM_GLOBALS = /* @__PURE__ */ new Set([
120
+ "Text",
121
+ "Image",
122
+ "Option",
123
+ "Audio",
124
+ "Comment",
125
+ "Range",
126
+ "Selection",
127
+ "Notification",
128
+ "Event",
129
+ "Document",
130
+ "Element",
131
+ "Node",
132
+ "Screen",
133
+ "Window",
134
+ "Location",
135
+ "History",
136
+ "Storage",
137
+ "Response",
138
+ "Request",
139
+ "Headers"
140
+ ]);
141
+ function packageOf(specifier) {
142
+ if (specifier.startsWith(".") || specifier.startsWith("/")) return void 0;
143
+ if (/^[~@]\//.test(specifier)) return void 0;
144
+ const parts = specifier.split("/");
145
+ return specifier.startsWith("@") ? parts.slice(0, 2).join("/") : parts[0];
146
+ }
147
+ function namespaceAlias(module) {
148
+ return `_${module.replace(/[^A-Za-z0-9]/g, "_")}`;
149
+ }
150
+ function componentGlobals(rules, options = {}) {
151
+ const {
152
+ available: availableList,
153
+ builtins = true,
154
+ intrinsics = true,
155
+ generator = "@fluixi/compiler",
156
+ specifier = (module) => module
157
+ } = options;
158
+ const all = [...rules];
159
+ if (builtins) {
160
+ all.push({ components: builtinComponentMap() });
161
+ }
162
+ const resolver = createComponentResolver(all);
163
+ const available = availableList ? new Set(availableList) : void 0;
164
+ const declared = [];
165
+ const shadowedByDom = [];
166
+ const unavailable = [];
167
+ const resolved = /* @__PURE__ */ new Map();
168
+ for (const name of [...resolver.names()].sort()) {
169
+ const target = resolver.resolve(name);
170
+ if (!target) continue;
171
+ const pkg = packageOf(target.module);
172
+ if (DOM_GLOBALS.has(name)) shadowedByDom.push(name);
173
+ else if (available && pkg && !available.has(pkg)) unavailable.push(name);
174
+ else {
175
+ declared.push(name);
176
+ resolved.set(name, target);
177
+ }
178
+ }
179
+ const intrinsicModules = intrinsics ? [...new Set(Object.values(INTRINSICS).map((i) => i.module))] : [];
180
+ const modules = [
181
+ .../* @__PURE__ */ new Set([...declared.map((name) => resolved.get(name).module), ...intrinsicModules])
182
+ ].sort();
183
+ const imports = modules.map(
184
+ (m) => `import * as ${namespaceAlias(m)} from '${specifier(m)}';`
185
+ );
186
+ const lines = declared.map((name) => {
187
+ const target = resolved.get(name);
188
+ const ns = namespaceAlias(target.module);
189
+ return target.export === "default" ? ` const ${name}: typeof ${ns}.default;` : ` export import ${name} = ${ns}.${target.export};`;
190
+ });
191
+ const note = shadowedByDom.length > 0 ? `//
192
+ // Import these explicitly: lib.dom already declares the name, so an ambient
3
193
  // declaration cannot win:
4
- `+m.map(o=>{let a=u.resolve(o)?.module;return`// import { ${o} } from '${a?i(a):""}';
5
- `}).join(""):"",P=n?Object.entries(v).map(([o,a])=>` const ${o}: typeof ${O(a.module)}.${a.export};`):[],x=e.filter(o=>"match"in o).length,W=x>0?`//
6
- // ${x} pattern rule${x===1?"":"s"} cannot be declared:
194
+ ` + shadowedByDom.map((n) => {
195
+ const module = resolver.resolve(n)?.module;
196
+ return `// import { ${n} } from '${module ? specifier(module) : ""}';
197
+ `;
198
+ }).join("") : "";
199
+ const intrinsicLines = intrinsics ? Object.entries(INTRINSICS).map(
200
+ ([name, intrinsic]) => ` const ${name}: typeof ${namespaceAlias(intrinsic.module)}.${intrinsic.export};`
201
+ ) : [];
202
+ const patternRules = rules.filter((rule) => "match" in rule).length;
203
+ const patternNote = patternRules > 0 ? `//
204
+ // ${patternRules} pattern rule${patternRules === 1 ? "" : "s"} cannot be declared:
7
205
  // a pattern matches unboundedly many names, so there is no list to emit. Those
8
206
  // tags still resolve at build time; declare them by hand if the editor needs them.
9
- `:"";return{source:`// GENERATED by ${c} — do not edit.
207
+ ` : "";
208
+ const source = `// GENERATED by ${generator}, do not edit.
10
209
  //
11
210
  // The components \`resolve\` supplies without an import. This describes what the
12
211
  // compiler already does; it does not enable it.
13
- `+G+W+($.length>0?`
14
- ${$.join(`
15
- `)}
16
- `:`
17
- `)+`
212
+ ` + note + patternNote + (imports.length > 0 ? `
213
+ ${imports.join("\n")}
214
+ ` : "\n") + `
18
215
  declare global {
19
- ${[..._,...P].join(`
20
- `)}
216
+ ${[...lines, ...intrinsicLines].join("\n")}
217
+ }
218
+ `;
219
+ return { source, declared, shadowedByDom, unavailable, patternRules };
220
+ }
221
+
222
+ // src/resolve/write-globals.ts
223
+ var GENERATED_MARKER = "GENERATED by @fluixi/compiler";
224
+ var DEFAULT_GLOBALS_PATH = "fluixi.d.ts";
225
+ function coveredByInclude(root, target) {
226
+ let config;
227
+ try {
228
+ const raw = readFileSync(resolvePath(root, "tsconfig.json"), "utf8");
229
+ config = JSON.parse(raw.replace(/^\s*\/\/.*$/gm, ""));
230
+ } catch {
231
+ return void 0;
232
+ }
233
+ if (config.extends !== void 0) return void 0;
234
+ if (!Array.isArray(config.include)) return true;
235
+ const relative2 = relativePosix(root, target);
236
+ return config.include.some((entry) => {
237
+ if (typeof entry !== "string") return false;
238
+ const pattern = entry.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*\*\//g, "(?:.*/)?").replace(/\*/g, "[^/]*");
239
+ return new RegExp(`^${pattern}(?:/.*)?$`).test(relative2);
240
+ });
241
+ }
242
+ function relativePosix(from, to) {
243
+ return relative(from, to).split(sep).join("/");
244
+ }
245
+ function forTypeScript(module, outDir, root) {
246
+ if (!module.startsWith("/")) return module;
247
+ const absolute = resolvePath(root, module.slice(1));
248
+ let rel = relative(outDir, absolute).split(sep).join("/");
249
+ if (!rel.startsWith(".")) rel = `./${rel}`;
250
+ return rel.replace(/\.(tsx|ts|jsx|mts|cts)$/, ".js");
251
+ }
252
+ function projectDependencies(root) {
253
+ try {
254
+ const manifest = JSON.parse(readFileSync(resolvePath(root, "package.json"), "utf8"));
255
+ return [
256
+ ...Object.keys(manifest.dependencies ?? {}),
257
+ ...Object.keys(manifest.devDependencies ?? {}),
258
+ ...Object.keys(manifest.peerDependencies ?? {})
259
+ ];
260
+ } catch {
261
+ return void 0;
262
+ }
263
+ }
264
+ function writeComponentGlobals(options, root) {
265
+ if (options.globals === false) return { status: "skipped", reason: "disabled" };
266
+ const rules = options.resolve ?? [];
267
+ const target = resolvePath(root, options.globals ?? DEFAULT_GLOBALS_PATH);
268
+ let existing;
269
+ try {
270
+ existing = readFileSync(target, "utf8");
271
+ } catch {
272
+ existing = void 0;
273
+ }
274
+ if (existing !== void 0 && !existing.includes(GENERATED_MARKER)) {
275
+ return { status: "skipped", reason: "foreign-file", path: target };
276
+ }
277
+ const { source, declared } = componentGlobals(rules, {
278
+ available: projectDependencies(root),
279
+ specifier: (module) => forTypeScript(module, dirname(target), root)
280
+ });
281
+ if (existing === source) {
282
+ return {
283
+ status: "unchanged",
284
+ path: target,
285
+ declared: declared.length,
286
+ warning: warnIfUnreachable(root, target)
287
+ };
288
+ }
289
+ mkdirSync(dirname(target), { recursive: true });
290
+ writeFileSync(target, source);
291
+ return {
292
+ status: "written",
293
+ path: target,
294
+ declared: declared.length,
295
+ warning: warnIfUnreachable(root, target)
296
+ };
297
+ }
298
+ function warnIfUnreachable(root, target) {
299
+ if (coveredByInclude(root, target) !== false) return void 0;
300
+ const relative2 = relativePosix(root, target);
301
+ return `[fluixi] ${relative2} is not covered by "include" in tsconfig.json, so TypeScript will ignore it and every resolved component stays "Cannot find name". Add "${relative2}" to "include".`;
21
302
  }
22
- `,declared:d,shadowedByDom:m,unavailable:R,patternRules:x}}var J="GENERATED by @fluixi/compiler",q="fluixi.d.ts";function z(e,t){let r;try{let n=S(h(e,"tsconfig.json"),"utf8");r=JSON.parse(n.replace(/^\s*\/\/.*$/gm,""))}catch{return}if(r.extends!==void 0)return;if(!Array.isArray(r.include))return!0;let s=A(e,t);return r.include.some(n=>{if(typeof n!="string")return!1;let c=n.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*\//g,"(?:.*/)?").replace(/\*/g,"[^/]*");return new RegExp(`^${c}(?:/.*)?$`).test(s)})}function A(e,t){return k(e,t).split(L).join("/")}function Z(e,t,r){if(!e.startsWith("/"))return e;let s=h(r,e.slice(1)),n=k(t,s).split(L).join("/");return n.startsWith(".")||(n=`./${n}`),n.replace(/\.(tsx|ts|jsx|mts|cts)$/,".js")}function Q(e){try{let t=JSON.parse(S(h(e,"package.json"),"utf8"));return[...Object.keys(t.dependencies??{}),...Object.keys(t.devDependencies??{}),...Object.keys(t.peerDependencies??{})]}catch{return}}function me(e,t){if(e.globals===!1)return{status:"skipped",reason:"disabled"};let r=e.resolve??[],s=h(t,e.globals??q),n;try{n=S(s,"utf8")}catch{n=void 0}if(n!==void 0&&!n.includes(J))return{status:"skipped",reason:"foreign-file",path:s};let{source:c,declared:i}=j(r,{available:Q(t),specifier:l=>Z(l,N(s),t)});return n===c?{status:"unchanged",path:s,declared:i.length,warning:T(t,s)}:(K(N(s),{recursive:!0}),V(s,c),{status:"written",path:s,declared:i.length,warning:T(t,s)})}function T(e,t){if(z(e,t)!==!1)return;let r=A(e,t);return`[fluixi] ${r} is not covered by "include" in tsconfig.json, so TypeScript will ignore it and every resolved component stays "Cannot find name". Add "${r}" to "include".`}export{q as DEFAULT_GLOBALS_PATH,me as writeComponentGlobals};
303
+ export {
304
+ DEFAULT_GLOBALS_PATH,
305
+ writeComponentGlobals
306
+ };
@@ -0,0 +1,78 @@
1
+ /*! @fluixi/compiler v1.0.0-alpha.85 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
2
+ import {
3
+ MagicString
4
+ } from "./chunk-RUDJDZAA.mjs";
5
+ import {
6
+ serverFnId
7
+ } from "./chunk-F74GFKSL.mjs";
8
+ import "./chunk-G6QC2WRJ.mjs";
9
+
10
+ // src/transform/server-fns.ts
11
+ import { parse } from "@babel/parser";
12
+ var RUNTIME = "@fluixi/start/server-fn";
13
+ var FUNCTION_TYPES = /* @__PURE__ */ new Set([
14
+ "FunctionDeclaration",
15
+ "FunctionExpression",
16
+ "ArrowFunctionExpression"
17
+ ]);
18
+ function directive(node) {
19
+ if (!FUNCTION_TYPES.has(node.type)) return null;
20
+ const body = node.body;
21
+ if (!body || body.type !== "BlockStatement") return null;
22
+ for (const d of body.directives ?? []) {
23
+ if (d.value?.value === "use server") return d;
24
+ }
25
+ return null;
26
+ }
27
+ function findServerFns(node, out) {
28
+ if (!node || typeof node !== "object") return;
29
+ if (Array.isArray(node)) {
30
+ for (const child of node) findServerFns(child, out);
31
+ return;
32
+ }
33
+ if (typeof node.type === "string") {
34
+ const found = directive(node);
35
+ if (found) {
36
+ out.push({ fn: node, directive: found });
37
+ return;
38
+ }
39
+ }
40
+ for (const key of Object.keys(node)) {
41
+ if (key === "loc" || key === "leadingComments" || key === "trailingComments") continue;
42
+ findServerFns(node[key], out);
43
+ }
44
+ }
45
+ function transformServerFns(code, options) {
46
+ if (!code.includes("use server")) return null;
47
+ const ast = parse(code, {
48
+ sourceType: "module",
49
+ plugins: ["jsx", "typescript"],
50
+ errorRecovery: true
51
+ });
52
+ const found = [];
53
+ findServerFns(ast.program, found);
54
+ if (found.length === 0) return null;
55
+ const helper = options.ssr ? "$$registerServerFn" : "$$createServerReference";
56
+ const out = new MagicString(code);
57
+ found.forEach(({ fn, directive: dir }, index) => {
58
+ const id = serverFnId(options.filename, options.root, index);
59
+ const declaration = fn.type === "FunctionDeclaration";
60
+ if (!options.ssr) {
61
+ const stub = `${helper}(${JSON.stringify(id)})`;
62
+ out.overwrite(fn.start, fn.end, declaration ? `const ${fn.id.name} = ${stub};` : stub);
63
+ return;
64
+ }
65
+ out.remove(dir.start, dir.end);
66
+ out.appendLeft(fn.start, declaration ? `const ${fn.id.name} = ${helper}(${JSON.stringify(id)}, ` : `${helper}(${JSON.stringify(id)}, `);
67
+ out.appendRight(fn.end, declaration ? ");" : ")");
68
+ });
69
+ out.prepend(`import { ${helper} } from ${JSON.stringify(options.runtimeModule ?? RUNTIME)};
70
+ `);
71
+ return {
72
+ code: out.toString(),
73
+ map: out.generateMap({ source: options.filename, includeContent: true, hires: true })
74
+ };
75
+ }
76
+ export {
77
+ transformServerFns
78
+ };
@@ -0,0 +1,82 @@
1
+ /*! @fluixi/compiler v1.0.0-alpha.85 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
2
+ import {
3
+ serverFnId
4
+ } from "./chunk-F74GFKSL.mjs";
5
+ import "./chunk-G6QC2WRJ.mjs";
6
+
7
+ // src/frontend/babel/server-functions.ts
8
+ import { transformSync } from "@babel/core";
9
+ var RUNTIME = "@fluixi/start/server-fn";
10
+ function serverFunctionsBabelPlugin({ types: t }) {
11
+ return {
12
+ name: "fluixi-server-functions",
13
+ visitor: {
14
+ Program: {
15
+ enter(_path, state) {
16
+ state.fxIndex = 0;
17
+ state.fxUsed = null;
18
+ },
19
+ exit(path, state) {
20
+ if (!state.fxUsed) return;
21
+ path.unshiftContainer(
22
+ "body",
23
+ t.importDeclaration(
24
+ [t.importSpecifier(t.identifier(state.fxUsed), t.identifier(state.fxUsed))],
25
+ t.stringLiteral(state.opts.runtimeModule || RUNTIME)
26
+ )
27
+ );
28
+ }
29
+ },
30
+ "FunctionDeclaration|FunctionExpression|ArrowFunctionExpression": (path, state) => {
31
+ const body = path.node.body;
32
+ if (!t.isBlockStatement(body)) return;
33
+ const dirs = body.directives || [];
34
+ const di = dirs.findIndex((d) => d.value.value === "use server");
35
+ if (di < 0) return;
36
+ body.directives.splice(di, 1);
37
+ const id = serverFnId(
38
+ state.opts.filename || state.filename || "unknown",
39
+ state.opts.root,
40
+ state.fxIndex++
41
+ );
42
+ const ssr = !!state.opts.ssr;
43
+ const helper = ssr ? "$$registerServerFn" : "$$createServerReference";
44
+ state.fxUsed = helper;
45
+ const replacement = ssr ? t.callExpression(t.identifier(helper), [
46
+ t.stringLiteral(id),
47
+ path.isFunctionDeclaration() ? t.functionExpression(
48
+ null,
49
+ path.node.params,
50
+ body,
51
+ path.node.generator,
52
+ path.node.async
53
+ ) : path.node
54
+ ]) : t.callExpression(t.identifier(helper), [t.stringLiteral(id)]);
55
+ if (path.isFunctionDeclaration()) {
56
+ path.replaceWith(
57
+ t.variableDeclaration("const", [t.variableDeclarator(path.node.id, replacement)])
58
+ );
59
+ } else {
60
+ path.replaceWith(replacement);
61
+ }
62
+ path.skip();
63
+ }
64
+ }
65
+ };
66
+ }
67
+ function transformServerFunctions(code, opts) {
68
+ if (!code.includes("use server")) return null;
69
+ const result = transformSync(code, {
70
+ filename: opts.filename,
71
+ configFile: false,
72
+ babelrc: false,
73
+ sourceMaps: true,
74
+ parserOpts: { plugins: ["typescript", "jsx"] },
75
+ plugins: [[serverFunctionsBabelPlugin, opts]]
76
+ });
77
+ if (!result?.code) return null;
78
+ return { code: result.code, map: result.map };
79
+ }
80
+ export {
81
+ transformServerFunctions
82
+ };
@@ -1 +1,71 @@
1
- "use strict";var s=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var f=(e,t)=>{for(var a in t)s(e,a,{get:t[a],enumerable:!0})},N=(e,t,a,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of l(t))!d.call(e,n)&&n!==a&&s(e,n,{get:()=>t[n],enumerable:!(i=c(t,n))||i.enumerable});return e};var u=e=>N(s({},"__esModule",{value:!0}),e);var p={};f(p,{moduleBindings:()=>m});module.exports=u(p);function r(e,t){if(e)switch(e.type){case"Identifier":t.add(e.name);return;case"ObjectPattern":for(let a of e.properties)a.type==="RestElement"?r(a.argument,t):r(a.value,t);return;case"ArrayPattern":for(let a of e.elements)r(a,t);return;case"AssignmentPattern":r(e.left,t);return;case"RestElement":r(e.argument,t);return}}function o(e,t){switch(e.type){case"ImportDeclaration":for(let a of e.specifiers)r(a.local,t);return;case"VariableDeclaration":for(let a of e.declarations)r(a.id,t);return;case"FunctionDeclaration":case"ClassDeclaration":r(e.id,t);return;case"ExportNamedDeclaration":case"ExportDefaultDeclaration":e.declaration&&o(e.declaration,t);return}}function m(e){let t=new Set;for(let a of e.body)o(a,t);return t}
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/transform/bindings.ts
21
+ var bindings_exports = {};
22
+ __export(bindings_exports, {
23
+ moduleBindings: () => moduleBindings
24
+ });
25
+ module.exports = __toCommonJS(bindings_exports);
26
+ function patternNames(node, out) {
27
+ if (!node) return;
28
+ switch (node.type) {
29
+ case "Identifier":
30
+ out.add(node.name);
31
+ return;
32
+ case "ObjectPattern":
33
+ for (const p of node.properties) {
34
+ if (p.type === "RestElement") patternNames(p.argument, out);
35
+ else patternNames(p.value, out);
36
+ }
37
+ return;
38
+ case "ArrayPattern":
39
+ for (const e of node.elements) patternNames(e, out);
40
+ return;
41
+ case "AssignmentPattern":
42
+ patternNames(node.left, out);
43
+ return;
44
+ case "RestElement":
45
+ patternNames(node.argument, out);
46
+ return;
47
+ }
48
+ }
49
+ function declared(node, out) {
50
+ switch (node.type) {
51
+ case "ImportDeclaration":
52
+ for (const s of node.specifiers) patternNames(s.local, out);
53
+ return;
54
+ case "VariableDeclaration":
55
+ for (const d of node.declarations) patternNames(d.id, out);
56
+ return;
57
+ case "FunctionDeclaration":
58
+ case "ClassDeclaration":
59
+ patternNames(node.id, out);
60
+ return;
61
+ case "ExportNamedDeclaration":
62
+ case "ExportDefaultDeclaration":
63
+ if (node.declaration) declared(node.declaration, out);
64
+ return;
65
+ }
66
+ }
67
+ function moduleBindings(program) {
68
+ const names = /* @__PURE__ */ new Set();
69
+ for (const statement of program.body) declared(statement, names);
70
+ return names;
71
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Names bound at module scope.
3
+ *
4
+ * Injected imports are skipped when the name already exists, so a file with its
5
+ * own `Show` keeps it. Only module scope matters: a `const insert = …` inside a
6
+ * function shadows our import there but cannot collide with it, which is the same
7
+ * answer `path.scope.hasBinding` gives on the Program path.
8
+ *
9
+ * Missing a binding emits a duplicate declaration, a syntax error. Reporting one
10
+ * that isn't there drops an import the code needs. Both are loud, neither is
11
+ * subtle, and the corpus in bindings.spec.ts covers the patterns that bind.
12
+ */
13
+ /** Collect the names bound at the top level of a parsed module. */
14
+ export declare function moduleBindings(program: {
15
+ body: unknown[];
16
+ }): Set<string>;
@@ -6,7 +6,7 @@
6
6
  * function shadows our import there but cannot collide with it, which is the same
7
7
  * answer `path.scope.hasBinding` gives on the Program path.
8
8
  *
9
- * Missing a binding emits a duplicate declaration a syntax error. Reporting one
9
+ * Missing a binding emits a duplicate declaration, a syntax error. Reporting one
10
10
  * that isn't there drops an import the code needs. Both are loud, neither is
11
11
  * subtle, and the corpus in bindings.spec.ts covers the patterns that bind.
12
12
  */
@@ -6,7 +6,7 @@
6
6
  * function shadows our import there but cannot collide with it, which is the same
7
7
  * answer `path.scope.hasBinding` gives on the Program path.
8
8
  *
9
- * Missing a binding emits a duplicate declaration a syntax error. Reporting one
9
+ * Missing a binding emits a duplicate declaration, a syntax error. Reporting one
10
10
  * that isn't there drops an import the code needs. Both are loud, neither is
11
11
  * subtle, and the corpus in bindings.spec.ts covers the patterns that bind.
12
12
  */
@@ -1 +1,50 @@
1
- function r(e,t){if(e)switch(e.type){case"Identifier":t.add(e.name);return;case"ObjectPattern":for(let a of e.properties)a.type==="RestElement"?r(a.argument,t):r(a.value,t);return;case"ArrayPattern":for(let a of e.elements)r(a,t);return;case"AssignmentPattern":r(e.left,t);return;case"RestElement":r(e.argument,t);return}}function n(e,t){switch(e.type){case"ImportDeclaration":for(let a of e.specifiers)r(a.local,t);return;case"VariableDeclaration":for(let a of e.declarations)r(a.id,t);return;case"FunctionDeclaration":case"ClassDeclaration":r(e.id,t);return;case"ExportNamedDeclaration":case"ExportDefaultDeclaration":e.declaration&&n(e.declaration,t);return}}function s(e){let t=new Set;for(let a of e.body)n(a,t);return t}export{s as moduleBindings};
1
+ // src/transform/bindings.ts
2
+ function patternNames(node, out) {
3
+ if (!node) return;
4
+ switch (node.type) {
5
+ case "Identifier":
6
+ out.add(node.name);
7
+ return;
8
+ case "ObjectPattern":
9
+ for (const p of node.properties) {
10
+ if (p.type === "RestElement") patternNames(p.argument, out);
11
+ else patternNames(p.value, out);
12
+ }
13
+ return;
14
+ case "ArrayPattern":
15
+ for (const e of node.elements) patternNames(e, out);
16
+ return;
17
+ case "AssignmentPattern":
18
+ patternNames(node.left, out);
19
+ return;
20
+ case "RestElement":
21
+ patternNames(node.argument, out);
22
+ return;
23
+ }
24
+ }
25
+ function declared(node, out) {
26
+ switch (node.type) {
27
+ case "ImportDeclaration":
28
+ for (const s of node.specifiers) patternNames(s.local, out);
29
+ return;
30
+ case "VariableDeclaration":
31
+ for (const d of node.declarations) patternNames(d.id, out);
32
+ return;
33
+ case "FunctionDeclaration":
34
+ case "ClassDeclaration":
35
+ patternNames(node.id, out);
36
+ return;
37
+ case "ExportNamedDeclaration":
38
+ case "ExportDefaultDeclaration":
39
+ if (node.declaration) declared(node.declaration, out);
40
+ return;
41
+ }
42
+ }
43
+ function moduleBindings(program) {
44
+ const names = /* @__PURE__ */ new Set();
45
+ for (const statement of program.body) declared(statement, names);
46
+ return names;
47
+ }
48
+ export {
49
+ moduleBindings
50
+ };