@fluixi/compiler 1.0.0-alpha.82 → 1.0.0-alpha.84

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 (188) 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.mjs +41 -1
  4. package/dist/analyze/intrinsics.cjs +80 -1
  5. package/dist/analyze/intrinsics.d.cts +66 -0
  6. package/dist/analyze/intrinsics.mjs +59 -1
  7. package/dist/analyze/paren.cjs +134 -0
  8. package/dist/analyze/paren.d.cts +23 -0
  9. package/dist/analyze/paren.d.ts +24 -0
  10. package/dist/analyze/paren.d.ts.map +1 -0
  11. package/dist/analyze/paren.js +168 -0
  12. package/dist/analyze/paren.mjs +113 -0
  13. package/dist/analyze/props-destructure.cjs +226 -1
  14. package/dist/analyze/props-destructure.d.cts +83 -0
  15. package/dist/analyze/props-destructure.mjs +205 -1
  16. package/dist/analyze/reactive-bindings.cjs +190 -1
  17. package/dist/analyze/reactive-bindings.d.cts +42 -0
  18. package/dist/analyze/reactive-bindings.mjs +167 -1
  19. package/dist/analyze/reactive-expr.cjs +38 -1
  20. package/dist/analyze/reactive-expr.d.cts +38 -0
  21. package/dist/analyze/reactive-expr.mjs +17 -1
  22. package/dist/analyze/static-graph.cjs +811 -0
  23. package/dist/analyze/static-graph.d.cts +102 -0
  24. package/dist/analyze/static-graph.d.ts +103 -0
  25. package/dist/analyze/static-graph.d.ts.map +1 -0
  26. package/dist/analyze/static-graph.js +869 -0
  27. package/dist/analyze/static-graph.mjs +793 -0
  28. package/dist/babel-NRW4EFTG.mjs +636 -0
  29. package/dist/chunk-3YKZ4GNH.mjs +11 -0
  30. package/dist/chunk-EZR7NZOY.mjs +1718 -0
  31. package/dist/chunk-FSSWUXUR.mjs +16 -0
  32. package/dist/chunk-MJV3UXIL.mjs +158 -0
  33. package/dist/chunk-R2VHAZAX.mjs +1078 -0
  34. package/dist/codegen/backend.cjs +18 -1
  35. package/dist/codegen/backend.d.cts +35 -0
  36. package/dist/codegen/backends/imperative.cjs +542 -1
  37. package/dist/codegen/backends/imperative.d.cts +11 -0
  38. package/dist/codegen/backends/imperative.d.ts.map +1 -1
  39. package/dist/codegen/backends/imperative.js +68 -13
  40. package/dist/codegen/backends/imperative.mjs +519 -1
  41. package/dist/codegen/contract.cjs +52 -1
  42. package/dist/codegen/contract.d.cts +24 -0
  43. package/dist/codegen/contract.mjs +31 -1
  44. package/dist/codegen/partial-template.cjs +176 -1
  45. package/dist/codegen/partial-template.d.cts +61 -0
  46. package/dist/codegen/partial-template.mjs +153 -1
  47. package/dist/codegen/serialize-static.cjs +125 -1
  48. package/dist/codegen/serialize-static.d.cts +38 -0
  49. package/dist/codegen/serialize-static.d.ts +16 -0
  50. package/dist/codegen/serialize-static.d.ts.map +1 -1
  51. package/dist/codegen/serialize-static.js +25 -0
  52. package/dist/codegen/serialize-static.mjs +104 -1
  53. package/dist/frontend/babel/build-ir-lit.cjs +1509 -1
  54. package/dist/frontend/babel/build-ir-lit.d.cts +26 -0
  55. package/dist/frontend/babel/build-ir-lit.mjs +1478 -1
  56. package/dist/frontend/babel/build-ir.cjs +1524 -1
  57. package/dist/frontend/babel/build-ir.d.cts +35 -0
  58. package/dist/frontend/babel/build-ir.mjs +1495 -1
  59. package/dist/frontend/babel/index.cjs +2186 -1
  60. package/dist/frontend/babel/index.d.cts +33 -0
  61. package/dist/frontend/babel/index.mjs +2156 -1
  62. package/dist/frontend/babel/lower-template.cjs +1507 -1
  63. package/dist/frontend/babel/lower-template.d.cts +23 -0
  64. package/dist/frontend/babel/lower-template.mjs +1478 -1
  65. package/dist/frontend/babel/plugin.cjs +2132 -1
  66. package/dist/frontend/babel/plugin.d.cts +95 -0
  67. package/dist/frontend/babel/plugin.mjs +2103 -1
  68. package/dist/frontend/babel/server-functions.cjs +110 -1
  69. package/dist/frontend/babel/server-functions.d.cts +10 -0
  70. package/dist/frontend/babel/server-functions.mjs +89 -1
  71. package/dist/frontend/babel/types.cjs +18 -1
  72. package/dist/frontend/babel/types.d.cts +33 -0
  73. package/dist/frontend/types.cjs +18 -1
  74. package/dist/frontend/types.d.cts +25 -0
  75. package/dist/frontend/vocabulary.cjs +98 -0
  76. package/dist/frontend/vocabulary.d.cts +79 -0
  77. package/dist/frontend/vocabulary.d.ts +80 -0
  78. package/dist/frontend/vocabulary.d.ts.map +1 -0
  79. package/dist/frontend/vocabulary.js +124 -0
  80. package/dist/frontend/vocabulary.mjs +77 -0
  81. package/dist/index.cjs +1594 -13
  82. package/dist/index.d.cts +27 -0
  83. package/dist/index.d.ts.map +1 -1
  84. package/dist/index.js +3 -0
  85. package/dist/index.mjs +1574 -13
  86. package/dist/integrations.cjs +4307 -25
  87. package/dist/integrations.d.cts +215 -0
  88. package/dist/integrations.d.ts +16 -0
  89. package/dist/integrations.d.ts.map +1 -1
  90. package/dist/integrations.js +21 -2
  91. package/dist/integrations.mjs +531 -17
  92. package/dist/ir/nodes.cjs +18 -1
  93. package/dist/ir/nodes.d.cts +168 -0
  94. package/dist/ir/nodes.d.ts +46 -0
  95. package/dist/ir/nodes.d.ts.map +1 -1
  96. package/dist/lower/compile-template.cjs +1356 -1
  97. package/dist/lower/compile-template.d.cts +69 -0
  98. package/dist/lower/compile-template.d.ts +12 -0
  99. package/dist/lower/compile-template.d.ts.map +1 -1
  100. package/dist/lower/compile-template.js +5 -1
  101. package/dist/lower/compile-template.mjs +1336 -1
  102. package/dist/lower/jsx.cjs +529 -1
  103. package/dist/lower/jsx.d.cts +25 -0
  104. package/dist/lower/jsx.d.ts +2 -0
  105. package/dist/lower/jsx.d.ts.map +1 -1
  106. package/dist/lower/jsx.js +27 -4
  107. package/dist/lower/jsx.mjs +506 -1
  108. package/dist/lower/template.cjs +1061 -1
  109. package/dist/lower/template.d.cts +53 -0
  110. package/dist/lower/template.d.ts +14 -1
  111. package/dist/lower/template.d.ts.map +1 -1
  112. package/dist/lower/template.js +106 -19
  113. package/dist/lower/template.mjs +1042 -1
  114. package/dist/lower/text.cjs +42 -1
  115. package/dist/lower/text.d.cts +10 -0
  116. package/dist/lower/text.mjs +21 -1
  117. package/dist/optimize/analyze-static.cjs +112 -1
  118. package/dist/optimize/analyze-static.d.cts +39 -0
  119. package/dist/optimize/analyze-static.mjs +91 -1
  120. package/dist/optimize/collapse-strategies.cjs +90 -1
  121. package/dist/optimize/collapse-strategies.d.cts +30 -0
  122. package/dist/optimize/collapse-strategies.mjs +67 -1
  123. package/dist/options.cjs +33 -1
  124. package/dist/options.d.cts +39 -0
  125. package/dist/options.mjs +12 -1
  126. package/dist/resolve/builtins.cjs +73 -1
  127. package/dist/resolve/builtins.d.cts +68 -0
  128. package/dist/resolve/builtins.mjs +53 -1
  129. package/dist/resolve/component-globals.cjs +233 -13
  130. package/dist/resolve/component-globals.d.cts +80 -0
  131. package/dist/resolve/component-globals.mjs +210 -13
  132. package/dist/resolve/component-resolver.cjs +80 -1
  133. package/dist/resolve/component-resolver.d.cts +68 -0
  134. package/dist/resolve/component-resolver.mjs +59 -1
  135. package/dist/resolve/load-directive.cjs +93 -1
  136. package/dist/resolve/load-directive.d.cts +53 -0
  137. package/dist/resolve/load-directive.mjs +72 -1
  138. package/dist/resolve/resolve-ir.cjs +108 -1
  139. package/dist/resolve/resolve-ir.d.cts +53 -0
  140. package/dist/resolve/resolve-ir.mjs +85 -1
  141. package/dist/resolve/write-globals.cjs +318 -13
  142. package/dist/resolve/write-globals.d.cts +30 -0
  143. package/dist/resolve/write-globals.mjs +297 -13
  144. package/dist/server-fns-4ZXN6DYU.mjs +78 -0
  145. package/dist/server-functions-V6D6DRIA.mjs +82 -0
  146. package/dist/transform/bindings.cjs +71 -1
  147. package/dist/transform/bindings.d.cts +16 -0
  148. package/dist/transform/bindings.mjs +50 -1
  149. package/dist/transform/index.cjs +2732 -8
  150. package/dist/transform/index.d.cts +15 -0
  151. package/dist/transform/index.mjs +3773 -17
  152. package/dist/transform/intrinsics.cjs +216 -3
  153. package/dist/transform/intrinsics.d.cts +21 -0
  154. package/dist/transform/intrinsics.mjs +193 -3
  155. package/dist/transform/props.cjs +441 -3
  156. package/dist/transform/props.d.cts +45 -0
  157. package/dist/transform/props.mjs +1482 -12
  158. package/dist/transform/server-fn-id.cjs +35 -1
  159. package/dist/transform/server-fn-id.d.cts +9 -0
  160. package/dist/transform/server-fn-id.mjs +14 -1
  161. package/dist/transform/server-fns.cjs +114 -2
  162. package/dist/transform/server-fns.d.cts +12 -0
  163. package/dist/transform/server-fns.mjs +1155 -11
  164. package/dist/transform/source-locations.cjs +330 -0
  165. package/dist/transform/source-locations.d.cts +43 -0
  166. package/dist/transform/source-locations.d.ts +44 -0
  167. package/dist/transform/source-locations.d.ts.map +1 -0
  168. package/dist/transform/source-locations.js +238 -0
  169. package/dist/transform/source-locations.mjs +307 -0
  170. package/dist/transform/templates.cjs +2701 -7
  171. package/dist/transform/templates.d.cts +69 -0
  172. package/dist/transform/templates.d.ts +12 -4
  173. package/dist/transform/templates.d.ts.map +1 -1
  174. package/dist/transform/templates.js +72 -7
  175. package/dist/transform/templates.mjs +3743 -16
  176. package/dist/transform-BT4MMASR.mjs +893 -0
  177. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  178. package/package.json +6 -5
  179. package/dist/babel-4JUDAR2G.mjs +0 -1
  180. package/dist/chunk-3SAEGOMQ.mjs +0 -1
  181. package/dist/chunk-IBRM4W7I.mjs +0 -10
  182. package/dist/chunk-OHHZCYIQ.mjs +0 -1
  183. package/dist/chunk-PVR2SN3B.mjs +0 -1
  184. package/dist/chunk-QUIYULS2.mjs +0 -1
  185. package/dist/chunk-YR3SAEO7.mjs +0 -1
  186. package/dist/server-fns-6QM243HC.mjs +0 -2
  187. package/dist/server-functions-E3LKCZ4R.mjs +0 -1
  188. package/dist/transform-5WC4FWJE.mjs +0 -8
@@ -1,27 +1,541 @@
1
- import{a as h}from"./chunk-QUIYULS2.mjs";import{a as C,f as M}from"./chunk-YR3SAEO7.mjs";import{a as j}from"./chunk-3SAEGOMQ.mjs";import{mkdirSync as U,readFileSync as w,writeFileSync as X}from"node:fs";import{dirname as E,relative as F,sep as k,resolve as b}from"node:path";var V=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 x(e){return`_${e.replace(/[^A-Za-z0-9]/g,"_")}`}function O(e,t={}){let{available:n,builtins:s=!0,intrinsics:r=!0,generator:i="@fluixi/compiler",specifier:a=o=>o}=t,l=[...e];s&&l.push({components:M()});let c=C(l),d=n?new Set(n):void 0,p=[],f=[],R=[],y=new Map;for(let o of[...c.names()].sort()){let u=c.resolve(o);if(!u)continue;let m=H(u.module);V.has(o)?f.push(o):d&&m&&!d.has(m)?R.push(o):(p.push(o),y.set(o,u))}let _=r?[...new Set(Object.values(h).map(o=>o.module))]:[],T=[...new Set([...p.map(o=>y.get(o).module),..._])].sort().map(o=>`import * as ${x(o)} from '${a(o)}';`),L=p.map(o=>{let u=y.get(o),m=x(u.module);return u.export==="default"?` const ${o}: typeof ${m}.default;`:` export import ${o} = ${m}.${u.export};`}),B=f.length>0?`//
1
+ /*! @fluixi/compiler v1.0.0-alpha.84 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
2
+ import {
3
+ INTRINSICS,
4
+ builtinComponentMap,
5
+ createComponentResolver
6
+ } from "./chunk-MJV3UXIL.mjs";
7
+ import {
8
+ __require
9
+ } from "./chunk-3YKZ4GNH.mjs";
10
+
11
+ // src/resolve/write-globals.ts
12
+ import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
13
+ import { dirname, relative, sep, resolve as resolvePath } from "node:path";
14
+
15
+ // src/resolve/component-globals.ts
16
+ var DOM_GLOBALS = /* @__PURE__ */ new Set([
17
+ "Text",
18
+ "Image",
19
+ "Option",
20
+ "Audio",
21
+ "Comment",
22
+ "Range",
23
+ "Selection",
24
+ "Notification",
25
+ "Event",
26
+ "Document",
27
+ "Element",
28
+ "Node",
29
+ "Screen",
30
+ "Window",
31
+ "Location",
32
+ "History",
33
+ "Storage",
34
+ "Response",
35
+ "Request",
36
+ "Headers"
37
+ ]);
38
+ function packageOf(specifier) {
39
+ if (specifier.startsWith(".") || specifier.startsWith("/")) return void 0;
40
+ if (/^[~@]\//.test(specifier)) return void 0;
41
+ const parts = specifier.split("/");
42
+ return specifier.startsWith("@") ? parts.slice(0, 2).join("/") : parts[0];
43
+ }
44
+ function namespaceAlias(module) {
45
+ return `_${module.replace(/[^A-Za-z0-9]/g, "_")}`;
46
+ }
47
+ function componentGlobals(rules, options = {}) {
48
+ const {
49
+ available: availableList,
50
+ builtins = true,
51
+ intrinsics = true,
52
+ generator = "@fluixi/compiler",
53
+ specifier = (module) => module
54
+ } = options;
55
+ const all = [...rules];
56
+ if (builtins) {
57
+ all.push({ components: builtinComponentMap() });
58
+ }
59
+ const resolver = createComponentResolver(all);
60
+ const available = availableList ? new Set(availableList) : void 0;
61
+ const declared = [];
62
+ const shadowedByDom = [];
63
+ const unavailable = [];
64
+ const resolved = /* @__PURE__ */ new Map();
65
+ for (const name of [...resolver.names()].sort()) {
66
+ const target = resolver.resolve(name);
67
+ if (!target) continue;
68
+ const pkg = packageOf(target.module);
69
+ if (DOM_GLOBALS.has(name)) shadowedByDom.push(name);
70
+ else if (available && pkg && !available.has(pkg)) unavailable.push(name);
71
+ else {
72
+ declared.push(name);
73
+ resolved.set(name, target);
74
+ }
75
+ }
76
+ const intrinsicModules = intrinsics ? [...new Set(Object.values(INTRINSICS).map((i) => i.module))] : [];
77
+ const modules = [
78
+ .../* @__PURE__ */ new Set([...declared.map((name) => resolved.get(name).module), ...intrinsicModules])
79
+ ].sort();
80
+ const imports = modules.map(
81
+ (m) => `import * as ${namespaceAlias(m)} from '${specifier(m)}';`
82
+ );
83
+ const lines = declared.map((name) => {
84
+ const target = resolved.get(name);
85
+ const ns = namespaceAlias(target.module);
86
+ return target.export === "default" ? ` const ${name}: typeof ${ns}.default;` : ` export import ${name} = ${ns}.${target.export};`;
87
+ });
88
+ const note = shadowedByDom.length > 0 ? `//
2
89
  // Import these explicitly — lib.dom already declares the name, so an ambient
3
90
  // declaration cannot win:
4
- `+f.map(o=>{let u=c.resolve(o)?.module;return`// import { ${o} } from '${u?a(u):""}';
5
- `}).join(""):"",J=r?Object.entries(h).map(([o,u])=>` const ${o}: typeof ${x(u.module)}.${u.export};`):[],g=e.filter(o=>"match"in o).length,q=g>0?`//
6
- // ${g} pattern rule${g===1?"":"s"} cannot be declared:
91
+ ` + shadowedByDom.map((n) => {
92
+ const module = resolver.resolve(n)?.module;
93
+ return `// import { ${n} } from '${module ? specifier(module) : ""}';
94
+ `;
95
+ }).join("") : "";
96
+ const intrinsicLines = intrinsics ? Object.entries(INTRINSICS).map(
97
+ ([name, intrinsic]) => ` const ${name}: typeof ${namespaceAlias(intrinsic.module)}.${intrinsic.export};`
98
+ ) : [];
99
+ const patternRules = rules.filter((rule) => "match" in rule).length;
100
+ const patternNote = patternRules > 0 ? `//
101
+ // ${patternRules} pattern rule${patternRules === 1 ? "" : "s"} cannot be declared:
7
102
  // a pattern matches unboundedly many names, so there is no list to emit. Those
8
103
  // tags still resolve at build time; declare them by hand if the editor needs them.
9
- `:"";return{source:`// GENERATED by ${i} — do not edit.
104
+ ` : "";
105
+ const source = `// GENERATED by ${generator} — do not edit.
10
106
  //
11
107
  // The components \`resolve\` supplies without an import. This describes what the
12
108
  // compiler already does; it does not enable it.
13
- `+B+q+(T.length>0?`
14
- ${T.join(`
15
- `)}
16
- `:`
17
- `)+`
109
+ ` + note + patternNote + (imports.length > 0 ? `
110
+ ${imports.join("\n")}
111
+ ` : "\n") + `
18
112
  declare global {
19
- ${[...L,...J].join(`
20
- `)}
113
+ ${[...lines, ...intrinsicLines].join("\n")}
114
+ }
115
+ `;
116
+ return { source, declared, shadowedByDom, unavailable, patternRules };
117
+ }
118
+
119
+ // src/resolve/write-globals.ts
120
+ var GENERATED_MARKER = "GENERATED by @fluixi/compiler";
121
+ var DEFAULT_GLOBALS_PATH = "fluixi.d.ts";
122
+ function coveredByInclude(root, target) {
123
+ let config;
124
+ try {
125
+ const raw = readFileSync(resolvePath(root, "tsconfig.json"), "utf8");
126
+ config = JSON.parse(raw.replace(/^\s*\/\/.*$/gm, ""));
127
+ } catch {
128
+ return void 0;
129
+ }
130
+ if (config.extends !== void 0) return void 0;
131
+ if (!Array.isArray(config.include)) return true;
132
+ const relative2 = relativePosix(root, target);
133
+ return config.include.some((entry) => {
134
+ if (typeof entry !== "string") return false;
135
+ const pattern = entry.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*\*\//g, "(?:.*/)?").replace(/\*/g, "[^/]*");
136
+ return new RegExp(`^${pattern}(?:/.*)?$`).test(relative2);
137
+ });
138
+ }
139
+ function relativePosix(from, to) {
140
+ return relative(from, to).split(sep).join("/");
141
+ }
142
+ function forTypeScript(module, outDir, root) {
143
+ if (!module.startsWith("/")) return module;
144
+ const absolute = resolvePath(root, module.slice(1));
145
+ let rel = relative(outDir, absolute).split(sep).join("/");
146
+ if (!rel.startsWith(".")) rel = `./${rel}`;
147
+ return rel.replace(/\.(tsx|ts|jsx|mts|cts)$/, ".js");
148
+ }
149
+ function projectDependencies(root) {
150
+ try {
151
+ const manifest = JSON.parse(readFileSync(resolvePath(root, "package.json"), "utf8"));
152
+ return [
153
+ ...Object.keys(manifest.dependencies ?? {}),
154
+ ...Object.keys(manifest.devDependencies ?? {}),
155
+ ...Object.keys(manifest.peerDependencies ?? {})
156
+ ];
157
+ } catch {
158
+ return void 0;
159
+ }
160
+ }
161
+ function writeComponentGlobals(options, root) {
162
+ if (options.globals === false) return { status: "skipped", reason: "disabled" };
163
+ const rules = options.resolve ?? [];
164
+ const target = resolvePath(root, options.globals ?? DEFAULT_GLOBALS_PATH);
165
+ let existing;
166
+ try {
167
+ existing = readFileSync(target, "utf8");
168
+ } catch {
169
+ existing = void 0;
170
+ }
171
+ if (existing !== void 0 && !existing.includes(GENERATED_MARKER)) {
172
+ return { status: "skipped", reason: "foreign-file", path: target };
173
+ }
174
+ const { source, declared } = componentGlobals(rules, {
175
+ available: projectDependencies(root),
176
+ specifier: (module) => forTypeScript(module, dirname(target), root)
177
+ });
178
+ if (existing === source) {
179
+ return {
180
+ status: "unchanged",
181
+ path: target,
182
+ declared: declared.length,
183
+ warning: warnIfUnreachable(root, target)
184
+ };
185
+ }
186
+ mkdirSync(dirname(target), { recursive: true });
187
+ writeFileSync(target, source);
188
+ return {
189
+ status: "written",
190
+ path: target,
191
+ declared: declared.length,
192
+ warning: warnIfUnreachable(root, target)
193
+ };
194
+ }
195
+ function warnIfUnreachable(root, target) {
196
+ if (coveredByInclude(root, target) !== false) return void 0;
197
+ const relative2 = relativePosix(root, target);
198
+ 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".`;
199
+ }
200
+
201
+ // src/integrations.ts
202
+ import { readdirSync, readFileSync as readFileSync2 } from "node:fs";
203
+ import { join as _join } from "node:path";
204
+ async function createBabelPlugin(options = {}) {
205
+ let pluginModule = null;
206
+ try {
207
+ pluginModule = await import("./babel-NRW4EFTG.mjs");
208
+ } catch (e) {
209
+ console.warn("Could not load the babel front-end:", e);
210
+ }
211
+ return {
212
+ name: "babel-fluixi-jsx",
213
+ plugin: pluginModule ? pluginModule.default || pluginModule : null,
214
+ // Provide options mapping
215
+ getOptions() {
216
+ return {
217
+ importSource: options.importSource || "@fluixi/jsx",
218
+ development: options.development || false,
219
+ delegateEvents: options.delegateEvents !== false,
220
+ ...options.format ? { format: options.format } : {},
221
+ // Forwarded explicitly: getOptions() is an allowlist, so an option missing
222
+ // here is silently dropped rather than rejected.
223
+ ...options.resolve ? { resolve: options.resolve } : {},
224
+ ...options.templateClone !== void 0 ? { templateClone: options.templateClone } : {},
225
+ ...options.partialTemplates !== void 0 ? { partialTemplates: options.partialTemplates } : {},
226
+ ...options.litTag ? { litTag: options.litTag } : {},
227
+ ...options.signalModule ? { signalModule: options.signalModule } : {},
228
+ ...options.controlFlowModule ? { controlFlowModule: options.controlFlowModule } : {},
229
+ ...options.routerModule ? { routerModule: options.routerModule } : {},
230
+ ...options.reactiveModule ? { reactiveModule: options.reactiveModule } : {}
231
+ };
232
+ }
233
+ };
234
+ }
235
+ function createTypeScriptTransformer(options = {}) {
236
+ const ts = tryRequire("typescript");
237
+ if (!ts) {
238
+ console.warn("TypeScript not found, transformer unavailable");
239
+ return (context) => (sourceFile) => sourceFile;
240
+ }
241
+ return (context) => {
242
+ const visitor = (node) => {
243
+ if (ts.isJsxElement(node) || ts.isJsxSelfClosingElement(node)) {
244
+ return transformTSJSXNode(node, options, ts);
245
+ }
246
+ return ts.visitEachChild(node, visitor, context);
247
+ };
248
+ return (sourceFile) => {
249
+ return ts.visitNode(sourceFile, visitor);
250
+ };
251
+ };
252
+ }
253
+ function transformTSJSXNode(node, options, ts) {
254
+ return node;
21
255
  }
22
- `,declared:p,shadowedByDom:f,unavailable:R,patternRules:g}}var z="GENERATED by @fluixi/compiler",K="fluixi.d.ts";function Z(e,t){let n;try{let r=w(b(e,"tsconfig.json"),"utf8");n=JSON.parse(r.replace(/^\s*\/\/.*$/gm,""))}catch{return}if(n.extends!==void 0)return;if(!Array.isArray(n.include))return!0;let s=A(e,t);return n.include.some(r=>{if(typeof r!="string")return!1;let i=r.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*\//g,"(?:.*/)?").replace(/\*/g,"[^/]*");return new RegExp(`^${i}(?:/.*)?$`).test(s)})}function A(e,t){return F(e,t).split(k).join("/")}function Q(e,t,n){if(!e.startsWith("/"))return e;let s=b(n,e.slice(1)),r=F(t,s).split(k).join("/");return r.startsWith(".")||(r=`./${r}`),r.replace(/\.(tsx|ts|jsx|mts|cts)$/,".js")}function Y(e){try{let t=JSON.parse(w(b(e,"package.json"),"utf8"));return[...Object.keys(t.dependencies??{}),...Object.keys(t.devDependencies??{}),...Object.keys(t.peerDependencies??{})]}catch{return}}function G(e,t){if(e.globals===!1)return{status:"skipped",reason:"disabled"};let n=e.resolve??[],s=b(t,e.globals??K),r;try{r=w(s,"utf8")}catch{r=void 0}if(r!==void 0&&!r.includes(z))return{status:"skipped",reason:"foreign-file",path:s};let{source:i,declared:a}=O(n,{available:Y(t),specifier:l=>Q(l,E(s),t)});return r===i?{status:"unchanged",path:s,declared:a.length,warning:D(t,s)}:(U(E(s),{recursive:!0}),X(s,i),{status:"written",path:s,declared:a.length,warning:D(t,s)})}function D(e,t){if(Z(e,t)!==!1)return;let n=A(e,t);return`[fluixi] ${n} is not covered by "include" in tsconfig.json, so TypeScript will ignore it and every resolved component stays "Cannot find name". Add "${n}" to "include".`}import{readdirSync as ce,readFileSync as pe}from"node:fs";import{join as N}from"node:path";async function $(e={}){let t=null;try{t=await import("./babel-4JUDAR2G.mjs")}catch(n){console.warn("Could not load the babel front-end:",n)}return{name:"babel-fluixi-jsx",plugin:t?t.default||t:null,getOptions(){return{importSource:e.importSource||"@fluixi/jsx",development:e.development||!1,delegateEvents:e.delegateEvents!==!1,...e.format?{format:e.format}:{},...e.resolve?{resolve:e.resolve}:{},...e.templateClone!==void 0?{templateClone:e.templateClone}:{},...e.partialTemplates!==void 0?{partialTemplates:e.partialTemplates}:{},...e.litTag?{litTag:e.litTag}:{},...e.signalModule?{signalModule:e.signalModule}:{},...e.controlFlowModule?{controlFlowModule:e.controlFlowModule}:{},...e.routerModule?{routerModule:e.routerModule}:{},...e.reactiveModule?{reactiveModule:e.reactiveModule}:{}}}}}function ee(e={}){let t=ne("typescript");return t?n=>{let s=r=>t.isJsxElement(r)||t.isJsxSelfClosingElement(r)?te(r,e,t):t.visitEachChild(r,s,n);return r=>t.visitNode(r,s)}:(console.warn("TypeScript not found, transformer unavailable"),n=>s=>s)}function te(e,t,n){return e}function ne(e){try{return j(e)}catch{return null}}var re={"@fluixi/core/router-next":"is now @fluixi/core/router","@fluixi/core/rx":"is gone — import signals and effects from @fluixi/reactive, or the server primitives it resolved to under node from @fluixi/core/server"};function se(e={}){return{name:"vite-fluixi-jsx",enforce:"pre",config(){return{esbuild:{jsx:"automatic",jsxImportSource:e.importSource||"@fluixi/jsx"}}},configResolved(t){let n=G(e,t?.root??process.cwd());n.warning&&console.warn(n.warning)},resolveId(t,n){let s=re[t];if(!s)return null;throw new Error(`[fluixi] ${t} ${s}`+(n?`
23
- imported by ${n}`:""))},async transform(t,n){if(!/\.(jsx|tsx|ts)$/i.test(n))return null;if(!e.babel)return v(t,n,e);let s=await $(e);try{let r=await import("@babel/core").catch(()=>null);if(!r)throw new Error(`[fluixi] @babel/core is required to compile ${n} but could not be loaded. Install it alongside @fluixi/compiler.`);let i=/\.tsx$/.test(n),a=/\.ts$/.test(n),l=[],c=[];if(i||a){let p=await import("@babel/preset-typescript").then(f=>f.default||f).catch(()=>null);p&&l.push([p,{isTSX:i,allExtensions:!0,jsxPragma:"jsx",jsxPragmaFrag:"Fragment",onlyRemoveTypeImports:!0}])}s&&s.plugin?c.push([s.plugin,s.getOptions()]):console.warn("[createVitePlugin] custom babel plugin not found");let d=await r.transformAsync(t,{filename:n,configFile:!1,babelrc:!1,presets:l,plugins:c,sourceMaps:e.sourceMaps!==!1});return{code:d?.code||t,map:d?.map}}catch(r){throw r}}}}function oe(e){return{resolve:e.resolve,litTag:e.litTag,templateClone:e.templateClone,partialTemplates:e.partialTemplates,runtimeModule:e.signalModule,controlFlowModule:e.controlFlowModule,routerModule:e.routerModule,reactiveModule:e.reactiveModule,propsDestructure:e.propsDestructure}}async function ie(e,t,n){if(n.propsDestructure===!1)return e;let{transformProps:s}=await import("./transform-5WC4FWJE.mjs"),r=s(e,t);return I({propsDiagnostics:r.diagnostics},t),r.rewritten>0?r.code:e}var P=new Set;function I(e,t){let n=e,s=r=>{let i=`${t}\0${r}`;P.has(i)||(P.add(i),console.warn(`[fluixi] ${t}: ${r}`))};for(let r of n?.unresolvedDiagnostics??[])s(r.message);for(let r of n?.loadDiagnostics??[])s(r.message);for(let r of n?.intrinsicDiagnostics??[])s(r.message);for(let r of n?.propsDiagnostics??[])s(`\`${r.name}\` was left destructured: ${r.message}. It reads once instead of tracking.`)}async function v(e,t,n){if(!n.babel){let{transformTemplates:l}=await import("./transform-5WC4FWJE.mjs"),c=l(e,t,oe(n));return I(c,t),c}let s=await ie(e,t,n),r=await import("@babel/core").catch(()=>null),i=await $(n);if(!r||!i.plugin)throw new Error(`[fluixi] babel: true needs @babel/core, which could not be loaded for ${t}. Install it, or drop the option to use the built-in compiler.`);let a=await r.transformAsync(s,{filename:t,configFile:!1,babelrc:!1,plugins:[[i.plugin,i.getOptions()]],sourceMaps:n.sourceMaps!==!1});return a?.code?{code:a.code,map:a.map}:null}function ae(e={}){return async function(t){let n=this.async();v(t,this.resourcePath,e).then(s=>{n(null,s?.code,s?.map)}).catch(s=>{n(s)})}}function le(e={}){return{name:"rollup-fluixi-jsx",async transform(t,n){return/\.[jt]sx?$/.test(n)?v(t,n,e):null}}}function ue(e={}){return{name:"esbuild-fluixi-jsx",setup(t){t.onLoad({filter:/\.[jt]sx?$/},async n=>{let{readFileSync:s}=await import("node:fs"),r=s(n.path,"utf8");try{return{contents:(await v(r,n.path,e))?.code??r,loader:n.path.endsWith("x")?"tsx":"ts"}}catch(i){return{errors:[{text:`Transform error: ${i}`}]}}})}}}var S="virtual:fluixi-server-fns";function W(e,t=[]){let n;try{n=ce(e,{withFileTypes:!0})}catch{return t}for(let s of n){if(s.name==="node_modules"||s.name==="dist"||s.name.startsWith("."))continue;let r=N(e,s.name);if(s.isDirectory())W(r,t);else if(/\.[jt]sx?$/.test(s.name))try{pe(r,"utf8").includes("use server")&&t.push(r)}catch{}}return t}function Te(e={}){let t=process.cwd();return{name:"fluixi-server-functions",enforce:"pre",configResolved(n){t=n.root||t},resolveId(n){return n===S||n==="@fluixi/start/server-fns"?"\0"+S:null},load(n){if(n!=="\0"+S)return null;let s=W(N(t,"src")),r=`import '@fluixi/start/server-fn-setup';
24
- `,i=s.map(l=>`import ${JSON.stringify(l)};`).join(`
25
- `);return r+i+`
256
+ function tryRequire(moduleName) {
257
+ try {
258
+ return __require(moduleName);
259
+ } catch (e) {
260
+ return null;
261
+ }
262
+ }
263
+ var RETIRED_SUBPATHS = {
264
+ "@fluixi/core/router-next": "is now @fluixi/core/router",
265
+ "@fluixi/core/rx": "is gone — import signals and effects from @fluixi/reactive, or the server primitives it resolved to under node from @fluixi/core/server"
266
+ };
267
+ function createVitePlugin(options = {}) {
268
+ return {
269
+ name: "vite-fluixi-jsx",
270
+ enforce: "pre",
271
+ config() {
272
+ return {
273
+ esbuild: {
274
+ jsx: "automatic",
275
+ jsxImportSource: options.importSource || "@fluixi/jsx"
276
+ }
277
+ };
278
+ },
279
+ // Written once per build, and on dev-server start, rather than per transform: the
280
+ // set of resolvable names comes from config, so nothing a file does can change it.
281
+ configResolved(config) {
282
+ const outcome = writeComponentGlobals(options, config?.root ?? process.cwd());
283
+ if (outcome.warning) console.warn(outcome.warning);
284
+ },
285
+ // A subpath we retired resolves to nothing, and the bundler reports that as
286
+ // `Missing "./x" specifier`, which names neither the replacement nor the file
287
+ // that asked. Answer it here, where the rename is known.
288
+ resolveId(id, importer) {
289
+ const moved = RETIRED_SUBPATHS[id];
290
+ if (!moved) return null;
291
+ throw new Error(
292
+ `[fluixi] ${id} ${moved}` + (importer ? `
293
+ imported by ${importer}` : "")
294
+ );
295
+ },
296
+ async transform(code, id) {
297
+ if (!/\.(jsx|tsx|ts)$/i.test(id)) {
298
+ return null;
299
+ }
300
+ if (!options.babel) return compileModule(code, id, options);
301
+ const babelPlugin = await createBabelPlugin(options);
302
+ try {
303
+ const babel = await import("@babel/core").catch(() => null);
304
+ if (!babel) {
305
+ throw new Error(
306
+ `[fluixi] @babel/core is required to compile ${id} but could not be loaded. Install it alongside @fluixi/compiler.`
307
+ );
308
+ }
309
+ const isTSX = /\.tsx$/.test(id);
310
+ const isTS = /\.ts$/.test(id);
311
+ const presets = [];
312
+ const plugins = [];
313
+ if (isTSX || isTS) {
314
+ const tsPreset = await import("@babel/preset-typescript").then((m) => m.default || m).catch(() => null);
315
+ if (tsPreset) {
316
+ presets.push([
317
+ tsPreset,
318
+ {
319
+ isTSX,
320
+ allExtensions: true,
321
+ // Important: preserve JSX so our plugin can transform it
322
+ jsxPragma: "jsx",
323
+ jsxPragmaFrag: "Fragment",
324
+ onlyRemoveTypeImports: true
325
+ }
326
+ ]);
327
+ }
328
+ }
329
+ if (babelPlugin && babelPlugin.plugin) {
330
+ plugins.push([babelPlugin.plugin, babelPlugin.getOptions()]);
331
+ } else {
332
+ console.warn("[createVitePlugin] custom babel plugin not found");
333
+ }
334
+ const result = await babel.transformAsync(code, {
335
+ filename: id,
336
+ configFile: false,
337
+ babelrc: false,
338
+ presets,
339
+ plugins,
340
+ sourceMaps: options.sourceMaps !== false
341
+ });
342
+ return {
343
+ code: result?.code || code,
344
+ map: result?.map
345
+ };
346
+ } catch (e) {
347
+ throw e;
348
+ }
349
+ }
350
+ };
351
+ }
352
+ function marks(options, id) {
353
+ if (options.sourceLocations !== true) return false;
354
+ if (options.sourceLocationsExternal) return true;
355
+ if (!id || id.includes("/node_modules/")) return false;
356
+ const root = options.sourceRoot;
357
+ if (!root) return true;
358
+ const base = root.endsWith("/") ? root : `${root}/`;
359
+ return id.startsWith(base);
360
+ }
361
+ function transformOptions(options, id) {
362
+ return {
363
+ resolve: options.resolve,
364
+ litTag: options.litTag,
365
+ sourceLocations: marks(options, id),
366
+ sourceRoot: options.sourceRoot,
367
+ templateClone: options.templateClone,
368
+ partialTemplates: options.partialTemplates,
369
+ runtimeModule: options.signalModule,
370
+ controlFlowModule: options.controlFlowModule,
371
+ routerModule: options.routerModule,
372
+ reactiveModule: options.reactiveModule,
373
+ propsDestructure: options.propsDestructure
374
+ };
375
+ }
376
+ async function rewriteProps(code, id, options) {
377
+ if (options.propsDestructure === false) return code;
378
+ const { transformProps } = await import("./transform-BT4MMASR.mjs");
379
+ const result = transformProps(code, id);
380
+ reportDiagnostics({ propsDiagnostics: result.diagnostics }, id);
381
+ return result.rewritten > 0 ? result.code : code;
382
+ }
383
+ var reported = /* @__PURE__ */ new Set();
384
+ function reportDiagnostics(result, id) {
385
+ const r = result;
386
+ const say = (message) => {
387
+ const key = `${id}\0${message}`;
388
+ if (reported.has(key)) return;
389
+ reported.add(key);
390
+ console.warn(`[fluixi] ${id}: ${message}`);
391
+ };
392
+ for (const d of r?.unresolvedDiagnostics ?? []) say(d.message);
393
+ for (const d of r?.loadDiagnostics ?? []) say(d.message);
394
+ for (const d of r?.intrinsicDiagnostics ?? []) say(d.message);
395
+ for (const d of r?.propsDiagnostics ?? []) {
396
+ say(`\`${d.name}\` was left destructured: ${d.message}. It reads once instead of tracking.`);
397
+ }
398
+ }
399
+ async function compileModule(code, id, options) {
400
+ if (!options.babel) {
401
+ const { transformTemplates } = await import("./transform-BT4MMASR.mjs");
402
+ const result2 = transformTemplates(code, id, transformOptions(options, id));
403
+ reportDiagnostics(result2, id);
404
+ return result2;
405
+ }
406
+ const source = await rewriteProps(code, id, options);
407
+ const babel = await import("@babel/core").catch(() => null);
408
+ const plugin = await createBabelPlugin(options);
409
+ if (!babel || !plugin.plugin) {
410
+ throw new Error(
411
+ `[fluixi] babel: true needs @babel/core, which could not be loaded for ${id}. Install it, or drop the option to use the built-in compiler.`
412
+ );
413
+ }
414
+ const result = await babel.transformAsync(source, {
415
+ filename: id,
416
+ configFile: false,
417
+ babelrc: false,
418
+ plugins: [[plugin.plugin, plugin.getOptions()]],
419
+ sourceMaps: options.sourceMaps !== false
420
+ });
421
+ return result?.code ? { code: result.code, map: result.map } : null;
422
+ }
423
+ function createWebpackLoader(options = {}) {
424
+ return async function(source) {
425
+ const callback = this.async();
426
+ compileModule(source, this.resourcePath, options).then((result) => {
427
+ callback(null, result?.code, result?.map);
428
+ }).catch((err) => {
429
+ callback(err);
430
+ });
431
+ };
432
+ }
433
+ function createRollupPlugin(options = {}) {
434
+ return {
435
+ name: "rollup-fluixi-jsx",
436
+ async transform(code, id) {
437
+ if (!/\.[jt]sx?$/.test(id)) return null;
438
+ return compileModule(code, id, options);
439
+ }
440
+ };
441
+ }
442
+ function createESBuildPlugin(options = {}) {
443
+ return {
444
+ name: "esbuild-fluixi-jsx",
445
+ setup(build) {
446
+ build.onLoad({ filter: /\.[jt]sx?$/ }, async (args) => {
447
+ const { readFileSync: readFileSync3 } = await import("node:fs");
448
+ const source = readFileSync3(args.path, "utf8");
449
+ try {
450
+ const result = await compileModule(source, args.path, options);
451
+ return {
452
+ contents: result?.code ?? source,
453
+ loader: args.path.endsWith("x") ? "tsx" : "ts"
454
+ };
455
+ } catch (e) {
456
+ return {
457
+ errors: [
458
+ {
459
+ text: `Transform error: ${e}`
460
+ }
461
+ ]
462
+ };
463
+ }
464
+ });
465
+ }
466
+ };
467
+ }
468
+ var SERVER_FNS_VMOD = "virtual:fluixi-server-fns";
469
+ function findServerFnModules(dir, out = []) {
470
+ let entries;
471
+ try {
472
+ entries = readdirSync(dir, { withFileTypes: true });
473
+ } catch {
474
+ return out;
475
+ }
476
+ for (const e of entries) {
477
+ if (e.name === "node_modules" || e.name === "dist" || e.name.startsWith(".")) continue;
478
+ const full = _join(dir, e.name);
479
+ if (e.isDirectory()) findServerFnModules(full, out);
480
+ else if (/\.[jt]sx?$/.test(e.name)) {
481
+ try {
482
+ if (readFileSync2(full, "utf8").includes("use server")) out.push(full);
483
+ } catch {
484
+ }
485
+ }
486
+ }
487
+ return out;
488
+ }
489
+ function serverFunctionsVitePlugin(options = {}) {
490
+ let root = process.cwd();
491
+ return {
492
+ name: "fluixi-server-functions",
493
+ enforce: "pre",
494
+ configResolved(config) {
495
+ root = config.root || root;
496
+ },
497
+ resolveId(id) {
498
+ return id === SERVER_FNS_VMOD || id === "@fluixi/start/server-fns" ? "\0" + SERVER_FNS_VMOD : null;
499
+ },
500
+ load(id) {
501
+ if (id !== "\0" + SERVER_FNS_VMOD) return null;
502
+ const mods = findServerFnModules(_join(root, "src"));
503
+ const setup = `import '@fluixi/start/server-fn-setup';
504
+ `;
505
+ const imports = mods.map((m) => `import ${JSON.stringify(m)};`).join("\n");
506
+ const dispatcher = `
26
507
  export { isServerFnRequest, handleServerFn } from '@fluixi/start/server-fn';
27
- `},async transform(n,s,r){if(!/\.[jt]sx?$/.test(s)||!n.includes("use server"))return null;let i={ssr:!!r?.ssr,filename:s,root:t};if(e.babel){let{transformServerFunctions:l}=await import("./server-functions-E3LKCZ4R.mjs");return l(n,i)}let{transformServerFns:a}=await import("./server-fns-6QM243HC.mjs");return a(n,i)}}}var je={createBabelPlugin:$,createTypeScriptTransformer:ee,createVitePlugin:se,createWebpackLoader:ae,createRollupPlugin:le,createESBuildPlugin:ue};export{$ as createBabelPlugin,ue as createESBuildPlugin,le as createRollupPlugin,ee as createTypeScriptTransformer,se as createVitePlugin,ae as createWebpackLoader,je as default,Te as serverFunctionsVitePlugin};
508
+ `;
509
+ return setup + imports + dispatcher;
510
+ },
511
+ async transform(code, id, opts) {
512
+ if (!/\.[jt]sx?$/.test(id)) return null;
513
+ if (!code.includes("use server")) return null;
514
+ const args = { ssr: !!opts?.ssr, filename: id, root };
515
+ if (options.babel) {
516
+ const { transformServerFunctions } = await import("./server-functions-V6D6DRIA.mjs");
517
+ return transformServerFunctions(code, args);
518
+ }
519
+ const { transformServerFns } = await import("./server-fns-4ZXN6DYU.mjs");
520
+ return transformServerFns(code, args);
521
+ }
522
+ };
523
+ }
524
+ var integrations_default = {
525
+ createBabelPlugin,
526
+ createTypeScriptTransformer,
527
+ createVitePlugin,
528
+ createWebpackLoader,
529
+ createRollupPlugin,
530
+ createESBuildPlugin
531
+ };
532
+ export {
533
+ createBabelPlugin,
534
+ createESBuildPlugin,
535
+ createRollupPlugin,
536
+ createTypeScriptTransformer,
537
+ createVitePlugin,
538
+ createWebpackLoader,
539
+ integrations_default as default,
540
+ serverFunctionsVitePlugin
541
+ };
package/dist/ir/nodes.cjs CHANGED
@@ -1 +1,18 @@
1
- "use strict";var t=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var l=(o,e,a,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of p(e))!c.call(o,r)&&r!==a&&t(o,r,{get:()=>e[r],enumerable:!(n=i(e,r))||n.enumerable});return o};var d=o=>l(t({},"__esModule",{value:!0}),o);var s={};module.exports=d(s);
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 __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+
16
+ // src/ir/nodes.ts
17
+ var nodes_exports = {};
18
+ module.exports = __toCommonJS(nodes_exports);