@fluixi/compiler 1.0.0-alpha.83 → 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 (163) 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 -1
  23. package/dist/analyze/static-graph.d.cts +102 -0
  24. package/dist/analyze/static-graph.mjs +793 -1
  25. package/dist/babel-NRW4EFTG.mjs +636 -0
  26. package/dist/chunk-3YKZ4GNH.mjs +11 -0
  27. package/dist/chunk-EZR7NZOY.mjs +1718 -0
  28. package/dist/chunk-FSSWUXUR.mjs +16 -0
  29. package/dist/chunk-MJV3UXIL.mjs +158 -0
  30. package/dist/chunk-R2VHAZAX.mjs +1078 -0
  31. package/dist/codegen/backend.cjs +18 -1
  32. package/dist/codegen/backend.d.cts +35 -0
  33. package/dist/codegen/backends/imperative.cjs +542 -1
  34. package/dist/codegen/backends/imperative.d.cts +11 -0
  35. package/dist/codegen/backends/imperative.d.ts.map +1 -1
  36. package/dist/codegen/backends/imperative.js +12 -8
  37. package/dist/codegen/backends/imperative.mjs +519 -1
  38. package/dist/codegen/contract.cjs +52 -1
  39. package/dist/codegen/contract.d.cts +24 -0
  40. package/dist/codegen/contract.mjs +31 -1
  41. package/dist/codegen/partial-template.cjs +176 -1
  42. package/dist/codegen/partial-template.d.cts +61 -0
  43. package/dist/codegen/partial-template.mjs +153 -1
  44. package/dist/codegen/serialize-static.cjs +125 -1
  45. package/dist/codegen/serialize-static.d.cts +38 -0
  46. package/dist/codegen/serialize-static.mjs +104 -1
  47. package/dist/frontend/babel/build-ir-lit.cjs +1509 -1
  48. package/dist/frontend/babel/build-ir-lit.d.cts +26 -0
  49. package/dist/frontend/babel/build-ir-lit.mjs +1478 -1
  50. package/dist/frontend/babel/build-ir.cjs +1524 -1
  51. package/dist/frontend/babel/build-ir.d.cts +35 -0
  52. package/dist/frontend/babel/build-ir.mjs +1495 -1
  53. package/dist/frontend/babel/index.cjs +2186 -1
  54. package/dist/frontend/babel/index.d.cts +33 -0
  55. package/dist/frontend/babel/index.mjs +2156 -1
  56. package/dist/frontend/babel/lower-template.cjs +1507 -1
  57. package/dist/frontend/babel/lower-template.d.cts +23 -0
  58. package/dist/frontend/babel/lower-template.mjs +1478 -1
  59. package/dist/frontend/babel/plugin.cjs +2132 -1
  60. package/dist/frontend/babel/plugin.d.cts +95 -0
  61. package/dist/frontend/babel/plugin.mjs +2103 -1
  62. package/dist/frontend/babel/server-functions.cjs +110 -1
  63. package/dist/frontend/babel/server-functions.d.cts +10 -0
  64. package/dist/frontend/babel/server-functions.mjs +89 -1
  65. package/dist/frontend/babel/types.cjs +18 -1
  66. package/dist/frontend/babel/types.d.cts +33 -0
  67. package/dist/frontend/types.cjs +18 -1
  68. package/dist/frontend/types.d.cts +25 -0
  69. package/dist/frontend/vocabulary.cjs +98 -0
  70. package/dist/frontend/vocabulary.d.cts +79 -0
  71. package/dist/frontend/vocabulary.d.ts +80 -0
  72. package/dist/frontend/vocabulary.d.ts.map +1 -0
  73. package/dist/frontend/vocabulary.js +124 -0
  74. package/dist/frontend/vocabulary.mjs +77 -0
  75. package/dist/index.cjs +1594 -13
  76. package/dist/index.d.cts +27 -0
  77. package/dist/index.mjs +1574 -13
  78. package/dist/integrations.cjs +4307 -25
  79. package/dist/integrations.d.cts +215 -0
  80. package/dist/integrations.mjs +531 -17
  81. package/dist/ir/nodes.cjs +18 -1
  82. package/dist/ir/nodes.d.cts +168 -0
  83. package/dist/lower/compile-template.cjs +1356 -1
  84. package/dist/lower/compile-template.d.cts +69 -0
  85. package/dist/lower/compile-template.mjs +1336 -1
  86. package/dist/lower/jsx.cjs +529 -1
  87. package/dist/lower/jsx.d.cts +25 -0
  88. package/dist/lower/jsx.d.ts.map +1 -1
  89. package/dist/lower/jsx.js +2 -1
  90. package/dist/lower/jsx.mjs +506 -1
  91. package/dist/lower/template.cjs +1061 -1
  92. package/dist/lower/template.d.cts +53 -0
  93. package/dist/lower/template.d.ts.map +1 -1
  94. package/dist/lower/template.js +5 -4
  95. package/dist/lower/template.mjs +1042 -1
  96. package/dist/lower/text.cjs +42 -1
  97. package/dist/lower/text.d.cts +10 -0
  98. package/dist/lower/text.mjs +21 -1
  99. package/dist/optimize/analyze-static.cjs +112 -1
  100. package/dist/optimize/analyze-static.d.cts +39 -0
  101. package/dist/optimize/analyze-static.mjs +91 -1
  102. package/dist/optimize/collapse-strategies.cjs +90 -1
  103. package/dist/optimize/collapse-strategies.d.cts +30 -0
  104. package/dist/optimize/collapse-strategies.mjs +67 -1
  105. package/dist/options.cjs +33 -1
  106. package/dist/options.d.cts +39 -0
  107. package/dist/options.mjs +12 -1
  108. package/dist/resolve/builtins.cjs +73 -1
  109. package/dist/resolve/builtins.d.cts +68 -0
  110. package/dist/resolve/builtins.mjs +53 -1
  111. package/dist/resolve/component-globals.cjs +233 -13
  112. package/dist/resolve/component-globals.d.cts +80 -0
  113. package/dist/resolve/component-globals.mjs +210 -13
  114. package/dist/resolve/component-resolver.cjs +80 -1
  115. package/dist/resolve/component-resolver.d.cts +68 -0
  116. package/dist/resolve/component-resolver.mjs +59 -1
  117. package/dist/resolve/load-directive.cjs +93 -1
  118. package/dist/resolve/load-directive.d.cts +53 -0
  119. package/dist/resolve/load-directive.mjs +72 -1
  120. package/dist/resolve/resolve-ir.cjs +108 -1
  121. package/dist/resolve/resolve-ir.d.cts +53 -0
  122. package/dist/resolve/resolve-ir.mjs +85 -1
  123. package/dist/resolve/write-globals.cjs +318 -13
  124. package/dist/resolve/write-globals.d.cts +30 -0
  125. package/dist/resolve/write-globals.mjs +297 -13
  126. package/dist/server-fns-4ZXN6DYU.mjs +78 -0
  127. package/dist/server-functions-V6D6DRIA.mjs +82 -0
  128. package/dist/transform/bindings.cjs +71 -1
  129. package/dist/transform/bindings.d.cts +16 -0
  130. package/dist/transform/bindings.mjs +50 -1
  131. package/dist/transform/index.cjs +2732 -8
  132. package/dist/transform/index.d.cts +15 -0
  133. package/dist/transform/index.mjs +3773 -17
  134. package/dist/transform/intrinsics.cjs +216 -3
  135. package/dist/transform/intrinsics.d.cts +21 -0
  136. package/dist/transform/intrinsics.mjs +193 -3
  137. package/dist/transform/props.cjs +441 -3
  138. package/dist/transform/props.d.cts +45 -0
  139. package/dist/transform/props.mjs +1482 -12
  140. package/dist/transform/server-fn-id.cjs +35 -1
  141. package/dist/transform/server-fn-id.d.cts +9 -0
  142. package/dist/transform/server-fn-id.mjs +14 -1
  143. package/dist/transform/server-fns.cjs +114 -2
  144. package/dist/transform/server-fns.d.cts +12 -0
  145. package/dist/transform/server-fns.mjs +1155 -11
  146. package/dist/transform/source-locations.cjs +330 -1
  147. package/dist/transform/source-locations.d.cts +43 -0
  148. package/dist/transform/source-locations.mjs +307 -1
  149. package/dist/transform/templates.cjs +2701 -7
  150. package/dist/transform/templates.d.cts +69 -0
  151. package/dist/transform/templates.mjs +3743 -16
  152. package/dist/transform-BT4MMASR.mjs +893 -0
  153. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  154. package/package.json +6 -5
  155. package/dist/babel-VXKH6MRQ.mjs +0 -1
  156. package/dist/chunk-3SAEGOMQ.mjs +0 -1
  157. package/dist/chunk-5KMMN5QP.mjs +0 -1
  158. package/dist/chunk-IBRM4W7I.mjs +0 -10
  159. package/dist/chunk-OHHZCYIQ.mjs +0 -1
  160. package/dist/chunk-YKZ54NVE.mjs +0 -1
  161. package/dist/server-fns-6QM243HC.mjs +0 -2
  162. package/dist/server-functions-E3LKCZ4R.mjs +0 -1
  163. package/dist/transform-C4ZXRVGP.mjs +0 -8
@@ -1 +1,73 @@
1
- "use strict";var l=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var M=(o,t)=>{for(var e in t)l(o,e,{get:t[e],enumerable:!0})},O=(o,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of m(t))!d.call(o,n)&&n!==e&&l(o,n,{get:()=>t[n],enumerable:!(s=a(t,n))||s.enumerable});return o};var f=o=>O(l({},"__esModule",{value:!0}),o);var E={};M(E,{BUILTIN_COMPONENTS:()=>R,CORE_CONTROL_FLOW:()=>u,DOM_CONTROL_FLOW:()=>i,RESERVED_COMPONENTS:()=>x,ROUTER_COMPONENTS:()=>c,builtinComponentMap:()=>p,builtinComponents:()=>C,routerComponents:()=>g});module.exports=f(E);var i=["Show","For","Index","Switch","Match","Portal","Dynamic","ErrorBoundary"],u=["Suspense","SuspenseList","Await"],c=["Router","Outlet","Redirect","Link"],R=[...i,...u,...c],x=new Set([...i,...u]);function p(o={}){let{controlFlowModule:t="@fluixi/dom",coreModule:e="@fluixi/core",routerModule:s="@fluixi/core/router"}=o,n={};for(let r of i)n[r]=t;for(let r of u)n[r]=e;for(let r of c)n[r]=s;return n}function C(o={}){return{components:p(o)}}function g(o){let t=o??"@fluixi/core/router";return{components:Object.fromEntries(c.map(e=>[e,t]))}}
1
+ /*! @fluixi/compiler v1.0.0-alpha.84 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
2
+ "use strict";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/resolve/builtins.ts
22
+ var builtins_exports = {};
23
+ __export(builtins_exports, {
24
+ BUILTIN_COMPONENTS: () => BUILTIN_COMPONENTS,
25
+ CORE_CONTROL_FLOW: () => CORE_CONTROL_FLOW,
26
+ DOM_CONTROL_FLOW: () => DOM_CONTROL_FLOW,
27
+ RESERVED_COMPONENTS: () => RESERVED_COMPONENTS,
28
+ ROUTER_COMPONENTS: () => ROUTER_COMPONENTS,
29
+ builtinComponentMap: () => builtinComponentMap,
30
+ builtinComponents: () => builtinComponents,
31
+ routerComponents: () => routerComponents
32
+ });
33
+ module.exports = __toCommonJS(builtins_exports);
34
+ var DOM_CONTROL_FLOW = [
35
+ "Show",
36
+ "For",
37
+ "Index",
38
+ "Switch",
39
+ "Match",
40
+ "Portal",
41
+ "Dynamic",
42
+ "ErrorBoundary"
43
+ ];
44
+ var CORE_CONTROL_FLOW = ["Suspense", "SuspenseList", "Await"];
45
+ var ROUTER_COMPONENTS = ["Router", "Outlet", "Redirect", "Link"];
46
+ var BUILTIN_COMPONENTS = [
47
+ ...DOM_CONTROL_FLOW,
48
+ ...CORE_CONTROL_FLOW,
49
+ ...ROUTER_COMPONENTS
50
+ ];
51
+ var RESERVED_COMPONENTS = /* @__PURE__ */ new Set([
52
+ ...DOM_CONTROL_FLOW,
53
+ ...CORE_CONTROL_FLOW
54
+ ]);
55
+ function builtinComponentMap(modules = {}) {
56
+ const {
57
+ controlFlowModule = "@fluixi/dom",
58
+ coreModule = "@fluixi/core",
59
+ routerModule = "@fluixi/core/router"
60
+ } = modules;
61
+ const map = {};
62
+ for (const name of DOM_CONTROL_FLOW) map[name] = controlFlowModule;
63
+ for (const name of CORE_CONTROL_FLOW) map[name] = coreModule;
64
+ for (const name of ROUTER_COMPONENTS) map[name] = routerModule;
65
+ return map;
66
+ }
67
+ function builtinComponents(modules = {}) {
68
+ return { components: builtinComponentMap(modules) };
69
+ }
70
+ function routerComponents(routerModule) {
71
+ const module2 = routerModule ?? "@fluixi/core/router";
72
+ return { components: Object.fromEntries(ROUTER_COMPONENTS.map((n) => [n, module2])) };
73
+ }
@@ -0,0 +1,68 @@
1
+ /**
2
+ * The components the compiler supplies without an import, as data.
3
+ *
4
+ * Two different things have always been bundled into one hardcoded `Set` per group:
5
+ * *which module a name comes from*, and *whether the name has special lowering*. Only
6
+ * the first is interesting outside the compiler, and every tool needs it — the TS
7
+ * plugin, to resolve `<Show>` for hover and go-to-definition; the language server, to
8
+ * complete and validate tags inside `` html`…` ``; a codemod, to materialise imports.
9
+ * Having no published source, `@fluixi/ts-plugin` duplicated the list and pinned it
10
+ * with a test that fails when the two drift.
11
+ *
12
+ * So the names live here, shaped as {@link ComponentMapRule} so they compose with
13
+ * user-configured `resolve` rules, and the compiler keeps its own sets for the parts
14
+ * that are genuinely about codegen.
15
+ *
16
+ * The split matters: control-flow names cannot become ordinary rules. `Show`, `For`,
17
+ * `Index` and `Match` read a reactive *value* prop inside their own tracking scope, so
18
+ * the compiler emits that prop as a getter — without it `each={items()}` snapshots once
19
+ * and never updates. They are also exempted from `createMemo` wrapping and may be
20
+ * replaced outright by `optimizeControlFlowComponent`. A rule only injects an import,
21
+ * so converting them would keep the import and silently drop the reactivity.
22
+ *
23
+ * Router components have no such behaviour — every reference to them in the plugin is
24
+ * import plumbing — so they are a plain rule.
25
+ */
26
+ import type { ComponentMapRule } from './component-resolver.cjs';
27
+ /** Where the built-in groups come from when the host does not override the module. */
28
+ export interface BuiltinModules {
29
+ /** Control flow that lives in the DOM package. Default `@fluixi/dom`. */
30
+ controlFlowModule?: string;
31
+ /** Control flow that only exists in core. Default `@fluixi/core`. */
32
+ coreModule?: string;
33
+ /** Router components. Default `@fluixi/core/router`. */
34
+ routerModule?: string;
35
+ }
36
+ /** Control flow lowered against the DOM runtime. */
37
+ export declare const DOM_CONTROL_FLOW: readonly ["Show", "For", "Index", "Switch", "Match", "Portal", "Dynamic", "ErrorBoundary"];
38
+ /** Control flow that only `@fluixi/core` exports — importing it from dom resolves to nothing. */
39
+ export declare const CORE_CONTROL_FLOW: readonly ["Suspense", "SuspenseList", "Await"];
40
+ /**
41
+ * Router components.
42
+ *
43
+ * `Routes` is not a component (routing is `<Router routes={…}>`) and `lazy` is a call
44
+ * rather than a tag, so neither can be supplied this way.
45
+ */
46
+ export declare const ROUTER_COMPONENTS: readonly ["Router", "Outlet", "Redirect", "Link"];
47
+ /** Every name the compiler supplies without an import. */
48
+ export declare const BUILTIN_COMPONENTS: readonly string[];
49
+ /**
50
+ * Names whose meaning is fixed by the compiler and cannot be reassigned by a rule.
51
+ *
52
+ * A rule naming one of these is a silent no-op — the compiler matches the built-in
53
+ * first and the tag renders control flow instead of the intended component, with no
54
+ * error. Rule authors should check against this set and report rather than emit.
55
+ */
56
+ export declare const RESERVED_COMPONENTS: ReadonlySet<string>;
57
+ /** Name → module for every built-in, honouring host module overrides. */
58
+ export declare function builtinComponentMap(modules?: BuiltinModules): Record<string, string>;
59
+ /**
60
+ * The built-ins as a resolver rule, for tools that want one uniform lookup.
61
+ *
62
+ * Note this is the *naming* half only. Feeding it to the compiler would not make
63
+ * control flow work through resolution — the compiler still recognises those names
64
+ * itself, for the codegen reasons above.
65
+ */
66
+ export declare function builtinComponents(modules?: BuiltinModules): ComponentMapRule;
67
+ /** Just the router group as a rule — the one group that is purely an import. */
68
+ export declare function routerComponents(routerModule?: string): ComponentMapRule;
@@ -1 +1,53 @@
1
- var s=["Show","For","Index","Switch","Match","Portal","Dynamic","ErrorBoundary"],i=["Suspense","SuspenseList","Await"],u=["Router","Outlet","Redirect","Link"],p=[...s,...i,...u],a=new Set([...s,...i]);function l(o={}){let{controlFlowModule:e="@fluixi/dom",coreModule:r="@fluixi/core",routerModule:c="@fluixi/core/router"}=o,n={};for(let t of s)n[t]=e;for(let t of i)n[t]=r;for(let t of u)n[t]=c;return n}function m(o={}){return{components:l(o)}}function d(o){let e=o??"@fluixi/core/router";return{components:Object.fromEntries(u.map(r=>[r,e]))}}export{p as BUILTIN_COMPONENTS,i as CORE_CONTROL_FLOW,s as DOM_CONTROL_FLOW,a as RESERVED_COMPONENTS,u as ROUTER_COMPONENTS,l as builtinComponentMap,m as builtinComponents,d as routerComponents};
1
+ /*! @fluixi/compiler v1.0.0-alpha.84 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
2
+
3
+ // src/resolve/builtins.ts
4
+ var DOM_CONTROL_FLOW = [
5
+ "Show",
6
+ "For",
7
+ "Index",
8
+ "Switch",
9
+ "Match",
10
+ "Portal",
11
+ "Dynamic",
12
+ "ErrorBoundary"
13
+ ];
14
+ var CORE_CONTROL_FLOW = ["Suspense", "SuspenseList", "Await"];
15
+ var ROUTER_COMPONENTS = ["Router", "Outlet", "Redirect", "Link"];
16
+ var BUILTIN_COMPONENTS = [
17
+ ...DOM_CONTROL_FLOW,
18
+ ...CORE_CONTROL_FLOW,
19
+ ...ROUTER_COMPONENTS
20
+ ];
21
+ var RESERVED_COMPONENTS = /* @__PURE__ */ new Set([
22
+ ...DOM_CONTROL_FLOW,
23
+ ...CORE_CONTROL_FLOW
24
+ ]);
25
+ function builtinComponentMap(modules = {}) {
26
+ const {
27
+ controlFlowModule = "@fluixi/dom",
28
+ coreModule = "@fluixi/core",
29
+ routerModule = "@fluixi/core/router"
30
+ } = modules;
31
+ const map = {};
32
+ for (const name of DOM_CONTROL_FLOW) map[name] = controlFlowModule;
33
+ for (const name of CORE_CONTROL_FLOW) map[name] = coreModule;
34
+ for (const name of ROUTER_COMPONENTS) map[name] = routerModule;
35
+ return map;
36
+ }
37
+ function builtinComponents(modules = {}) {
38
+ return { components: builtinComponentMap(modules) };
39
+ }
40
+ function routerComponents(routerModule) {
41
+ const module = routerModule ?? "@fluixi/core/router";
42
+ return { components: Object.fromEntries(ROUTER_COMPONENTS.map((n) => [n, module])) };
43
+ }
44
+ export {
45
+ BUILTIN_COMPONENTS,
46
+ CORE_CONTROL_FLOW,
47
+ DOM_CONTROL_FLOW,
48
+ RESERVED_COMPONENTS,
49
+ ROUTER_COMPONENTS,
50
+ builtinComponentMap,
51
+ builtinComponents,
52
+ routerComponents
53
+ };
@@ -1,22 +1,242 @@
1
- "use strict";var C=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var P=Object.prototype.hasOwnProperty;var k=(e,t)=>{for(var r in t)C(e,r,{get:t[r],enumerable:!0})},A=(e,t,r,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of D(t))!P.call(e,n)&&n!==r&&C(e,n,{get:()=>t[n],enumerable:!(c=_(t,n))||c.enumerable});return e};var B=e=>A(C({},"__esModule",{value:!0}),e);var H={};k(H,{componentGlobals:()=>V});module.exports=B(H);var G=e=>"components"in e;function S(e,t){return e.replace(/\$(\d+)/g,(r,c)=>t[Number(c)]??r)}function W(e,t){return typeof t=="string"?{module:t,export:e}:t}function $(e=[]){let t=new Map,r=[],c=[];for(let s of e){if(!G(s)){c.push(s);continue}for(let[i,a]of Object.entries(s.components)){let u=W(i,a),m=t.get(i);if(m&&m.module!==u.module){let d=r.find(R=>R.name===i);d?d.modules.push(u.module):r.push({name:i,modules:[m.module,u.module]});continue}t.set(i,u)}}let n=new Map;return{resolve:s=>{if(n.has(s))return n.get(s);let i=t.get(s);if(!i)for(let a of c){let u=s.match(new RegExp(a.match.source,a.match.flags.replace("g","")));if(u){i={module:S(a.module,u),export:a.export?S(a.export,u):s};break}}return n.set(s,i),i},names:()=>[...t.keys()],conflicts:()=>r}}var b=["Show","For","Index","Switch","Match","Portal","Dynamic","ErrorBoundary"],M=["Suspense","SuspenseList","Await"],E=["Router","Outlet","Redirect","Link"],J=[...b,...M,...E],Q=new Set([...b,...M]);function I(e={}){let{controlFlowModule:t="@fluixi/dom",coreModule:r="@fluixi/core",routerModule:c="@fluixi/core/router"}=e,n={};for(let p of b)n[p]=t;for(let p of M)n[p]=r;for(let p of E)n[p]=c;return n}var f="@fluixi/reactive/signal",h={$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 Y=new RegExp(`\\$(?:${Object.keys(h).map(e=>e.slice(1)).join("|")})\\s*\\(`);var F=new Set(["Text","Image","Option","Audio","Comment","Range","Selection","Notification","Event","Document","Element","Node","Screen","Window","Location","History","Storage","Response","Request","Headers"]);function U(e){if(e.startsWith(".")||e.startsWith("/")||/^[~@]\//.test(e))return;let t=e.split("/");return e.startsWith("@")?t.slice(0,2).join("/"):t[0]}function y(e){return`_${e.replace(/[^A-Za-z0-9]/g,"_")}`}function V(e,t={}){let{available:r,builtins:c=!0,intrinsics:n=!0,generator:p="@fluixi/compiler",specifier:s=o=>o}=t,i=[...e];c&&i.push({components:I()});let a=$(i),u=r?new Set(r):void 0,m=[],d=[],R=[],v=new Map;for(let o of[...a.names()].sort()){let l=a.resolve(o);if(!l)continue;let g=U(l.module);F.has(o)?d.push(o):u&&g&&!u.has(g)?R.push(o):(m.push(o),v.set(o,l))}let w=n?[...new Set(Object.values(h).map(o=>o.module))]:[],O=[...new Set([...m.map(o=>v.get(o).module),...w])].sort().map(o=>`import * as ${y(o)} from '${s(o)}';`),N=m.map(o=>{let l=v.get(o),g=y(l.module);return l.export==="default"?` const ${o}: typeof ${g}.default;`:` export import ${o} = ${g}.${l.export};`}),T=d.length>0?`//
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/resolve/component-globals.ts
21
+ var component_globals_exports = {};
22
+ __export(component_globals_exports, {
23
+ componentGlobals: () => componentGlobals
24
+ });
25
+ module.exports = __toCommonJS(component_globals_exports);
26
+
27
+ // src/resolve/component-resolver.ts
28
+ var isMapRule = (rule) => "components" in rule;
29
+ function substitute(template, match) {
30
+ return template.replace(/\$(\d+)/g, (whole, index) => {
31
+ const group = match[Number(index)];
32
+ return group ?? whole;
33
+ });
34
+ }
35
+ function normalise(name, entry) {
36
+ return typeof entry === "string" ? { module: entry, export: name } : entry;
37
+ }
38
+ function createComponentResolver(rules = []) {
39
+ const exact = /* @__PURE__ */ new Map();
40
+ const conflicts = [];
41
+ const patterns = [];
42
+ for (const rule of rules) {
43
+ if (!isMapRule(rule)) {
44
+ patterns.push(rule);
45
+ continue;
46
+ }
47
+ for (const [name, entry] of Object.entries(rule.components)) {
48
+ const resolved = normalise(name, entry);
49
+ const existing = exact.get(name);
50
+ if (existing && existing.module !== resolved.module) {
51
+ const conflict = conflicts.find((c) => c.name === name);
52
+ if (conflict) conflict.modules.push(resolved.module);
53
+ else conflicts.push({ name, modules: [existing.module, resolved.module] });
54
+ continue;
55
+ }
56
+ exact.set(name, resolved);
57
+ }
58
+ }
59
+ const cache = /* @__PURE__ */ new Map();
60
+ const resolve = (name) => {
61
+ if (cache.has(name)) return cache.get(name);
62
+ let result = exact.get(name);
63
+ if (!result) {
64
+ for (const rule of patterns) {
65
+ const match = name.match(new RegExp(rule.match.source, rule.match.flags.replace("g", "")));
66
+ if (!match) continue;
67
+ result = {
68
+ module: substitute(rule.module, match),
69
+ export: rule.export ? substitute(rule.export, match) : name
70
+ };
71
+ break;
72
+ }
73
+ }
74
+ cache.set(name, result);
75
+ return result;
76
+ };
77
+ return {
78
+ resolve,
79
+ names: () => [...exact.keys()],
80
+ conflicts: () => conflicts
81
+ };
82
+ }
83
+
84
+ // src/resolve/builtins.ts
85
+ var DOM_CONTROL_FLOW = [
86
+ "Show",
87
+ "For",
88
+ "Index",
89
+ "Switch",
90
+ "Match",
91
+ "Portal",
92
+ "Dynamic",
93
+ "ErrorBoundary"
94
+ ];
95
+ var CORE_CONTROL_FLOW = ["Suspense", "SuspenseList", "Await"];
96
+ var ROUTER_COMPONENTS = ["Router", "Outlet", "Redirect", "Link"];
97
+ var BUILTIN_COMPONENTS = [
98
+ ...DOM_CONTROL_FLOW,
99
+ ...CORE_CONTROL_FLOW,
100
+ ...ROUTER_COMPONENTS
101
+ ];
102
+ var RESERVED_COMPONENTS = /* @__PURE__ */ new Set([
103
+ ...DOM_CONTROL_FLOW,
104
+ ...CORE_CONTROL_FLOW
105
+ ]);
106
+ function builtinComponentMap(modules = {}) {
107
+ const {
108
+ controlFlowModule = "@fluixi/dom",
109
+ coreModule = "@fluixi/core",
110
+ routerModule = "@fluixi/core/router"
111
+ } = modules;
112
+ const map = {};
113
+ for (const name of DOM_CONTROL_FLOW) map[name] = controlFlowModule;
114
+ for (const name of CORE_CONTROL_FLOW) map[name] = coreModule;
115
+ for (const name of ROUTER_COMPONENTS) map[name] = routerModule;
116
+ return map;
117
+ }
118
+
119
+ // src/analyze/intrinsics.ts
120
+ var REACTIVE_MODULE = "@fluixi/reactive/signal";
121
+ var INTRINSICS = {
122
+ $signal: { export: "signal", module: REACTIVE_MODULE, returns: "signal-handle" },
123
+ $memo: { export: "memo", module: REACTIVE_MODULE, returns: "memo-handle" },
124
+ $effect: { export: "effect", module: REACTIVE_MODULE, returns: "effect" },
125
+ $store: { export: "store", module: "@fluixi/reactive/store", returns: "store-handle" },
126
+ $resource: { export: "resource", module: REACTIVE_MODULE, returns: "resource-handle" },
127
+ // No short runtime form for these yet, so the intrinsic stands for the `create*`
128
+ // name. Still worth having — no import to write — and when a shorter form is
129
+ // designed, the change is this line rather than a compiler pass.
130
+ $selector: { export: "createSelector", module: REACTIVE_MODULE, returns: "memo-accessor" },
131
+ $deferred: { export: "createDeferred", module: REACTIVE_MODULE, returns: "memo-accessor" },
132
+ // Not value constructors, but the compiler has to know them: they change what a read
133
+ // does. `untrack` suppresses dependency collection, which is exactly the kind of thing
134
+ // dependency analysis must not guess at.
135
+ $untrack: { export: "untrack", module: REACTIVE_MODULE, returns: "plain" },
136
+ $untrackStore: { export: "untrackStore", module: "@fluixi/reactive/store", returns: "plain" }
137
+ };
138
+ var INTRINSIC_CALL = new RegExp(`\\$(?:${Object.keys(INTRINSICS).map((n) => n.slice(1)).join("|")})\\s*\\(`);
139
+
140
+ // src/resolve/component-globals.ts
141
+ var DOM_GLOBALS = /* @__PURE__ */ new Set([
142
+ "Text",
143
+ "Image",
144
+ "Option",
145
+ "Audio",
146
+ "Comment",
147
+ "Range",
148
+ "Selection",
149
+ "Notification",
150
+ "Event",
151
+ "Document",
152
+ "Element",
153
+ "Node",
154
+ "Screen",
155
+ "Window",
156
+ "Location",
157
+ "History",
158
+ "Storage",
159
+ "Response",
160
+ "Request",
161
+ "Headers"
162
+ ]);
163
+ function packageOf(specifier) {
164
+ if (specifier.startsWith(".") || specifier.startsWith("/")) return void 0;
165
+ if (/^[~@]\//.test(specifier)) return void 0;
166
+ const parts = specifier.split("/");
167
+ return specifier.startsWith("@") ? parts.slice(0, 2).join("/") : parts[0];
168
+ }
169
+ function namespaceAlias(module2) {
170
+ return `_${module2.replace(/[^A-Za-z0-9]/g, "_")}`;
171
+ }
172
+ function componentGlobals(rules, options = {}) {
173
+ const {
174
+ available: availableList,
175
+ builtins = true,
176
+ intrinsics = true,
177
+ generator = "@fluixi/compiler",
178
+ specifier = (module2) => module2
179
+ } = options;
180
+ const all = [...rules];
181
+ if (builtins) {
182
+ all.push({ components: builtinComponentMap() });
183
+ }
184
+ const resolver = createComponentResolver(all);
185
+ const available = availableList ? new Set(availableList) : void 0;
186
+ const declared = [];
187
+ const shadowedByDom = [];
188
+ const unavailable = [];
189
+ const resolved = /* @__PURE__ */ new Map();
190
+ for (const name of [...resolver.names()].sort()) {
191
+ const target = resolver.resolve(name);
192
+ if (!target) continue;
193
+ const pkg = packageOf(target.module);
194
+ if (DOM_GLOBALS.has(name)) shadowedByDom.push(name);
195
+ else if (available && pkg && !available.has(pkg)) unavailable.push(name);
196
+ else {
197
+ declared.push(name);
198
+ resolved.set(name, target);
199
+ }
200
+ }
201
+ const intrinsicModules = intrinsics ? [...new Set(Object.values(INTRINSICS).map((i) => i.module))] : [];
202
+ const modules = [
203
+ .../* @__PURE__ */ new Set([...declared.map((name) => resolved.get(name).module), ...intrinsicModules])
204
+ ].sort();
205
+ const imports = modules.map(
206
+ (m) => `import * as ${namespaceAlias(m)} from '${specifier(m)}';`
207
+ );
208
+ const lines = declared.map((name) => {
209
+ const target = resolved.get(name);
210
+ const ns = namespaceAlias(target.module);
211
+ return target.export === "default" ? ` const ${name}: typeof ${ns}.default;` : ` export import ${name} = ${ns}.${target.export};`;
212
+ });
213
+ const note = shadowedByDom.length > 0 ? `//
2
214
  // Import these explicitly — lib.dom already declares the name, so an ambient
3
215
  // declaration cannot win:
4
- `+d.map(o=>{let l=a.resolve(o)?.module;return`// import { ${o} } from '${l?s(l):""}';
5
- `}).join(""):"",L=n?Object.entries(h).map(([o,l])=>` const ${o}: typeof ${y(l.module)}.${l.export};`):[],x=e.filter(o=>"match"in o).length,j=x>0?`//
6
- // ${x} pattern rule${x===1?"":"s"} cannot be declared:
216
+ ` + shadowedByDom.map((n) => {
217
+ const module2 = resolver.resolve(n)?.module;
218
+ return `// import { ${n} } from '${module2 ? specifier(module2) : ""}';
219
+ `;
220
+ }).join("") : "";
221
+ const intrinsicLines = intrinsics ? Object.entries(INTRINSICS).map(
222
+ ([name, intrinsic]) => ` const ${name}: typeof ${namespaceAlias(intrinsic.module)}.${intrinsic.export};`
223
+ ) : [];
224
+ const patternRules = rules.filter((rule) => "match" in rule).length;
225
+ const patternNote = patternRules > 0 ? `//
226
+ // ${patternRules} pattern rule${patternRules === 1 ? "" : "s"} cannot be declared:
7
227
  // a pattern matches unboundedly many names, so there is no list to emit. Those
8
228
  // tags still resolve at build time; declare them by hand if the editor needs them.
9
- `:"";return{source:`// GENERATED by ${p} — do not edit.
229
+ ` : "";
230
+ const source = `// GENERATED by ${generator} — do not edit.
10
231
  //
11
232
  // The components \`resolve\` supplies without an import. This describes what the
12
233
  // compiler already does; it does not enable it.
13
- `+T+j+(O.length>0?`
14
- ${O.join(`
15
- `)}
16
- `:`
17
- `)+`
234
+ ` + note + patternNote + (imports.length > 0 ? `
235
+ ${imports.join("\n")}
236
+ ` : "\n") + `
18
237
  declare global {
19
- ${[...N,...L].join(`
20
- `)}
238
+ ${[...lines, ...intrinsicLines].join("\n")}
239
+ }
240
+ `;
241
+ return { source, declared, shadowedByDom, unavailable, patternRules };
21
242
  }
22
- `,declared:m,shadowedByDom:d,unavailable:R,patternRules:x}}
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Ambient declarations for the components `resolve` supplies without an import.
3
+ *
4
+ * The compiler injects the import, so nothing in the source imports these — which leaves
5
+ * TypeScript reporting `TS2304: Cannot find name`. The code compiles and runs; the editor
6
+ * is unusable and `tsc` fails. These declarations describe what the compiler already
7
+ * does. They do not enable it.
8
+ *
9
+ * This lives next to the resolver, and takes rules rather than a flat map, because the
10
+ * resolver is the only thing that knows the whole picture: a UI library's components, the
11
+ * project's own, and the framework builtins all arrive through the same config. A
12
+ * component library cannot generate this on its own — it does not know what else the
13
+ * project resolves — which is why the generator belongs here and the library-specific CLI
14
+ * that predates it does not.
15
+ *
16
+ * Pure, like the resolver: rules in, source out, no filesystem. Writing the file is the
17
+ * caller's job (the Vite plugin does it on config resolve; a CLI can do it in CI).
18
+ */
19
+ import { type ComponentResolverRule } from './component-resolver.cjs';
20
+ export interface ComponentGlobalsOptions {
21
+ /**
22
+ * Packages the project can actually resolve — normally its declared dependencies.
23
+ *
24
+ * Declaring a component from a package the project does not depend on produces an
25
+ * unresolvable `import(...)`, and under the usual `skipLibCheck: true` that failure is
26
+ * silent: the component degrades to `any` and every prop typo type-checks, which is
27
+ * worse than the error it replaced. Omit to declare everything, which is only correct
28
+ * when every package is present.
29
+ *
30
+ * Relative and alias specifiers are never filtered — there is no package to check.
31
+ */
32
+ available?: Iterable<string>;
33
+ /**
34
+ * Declare the framework builtins (`Show`, `For`, `Portal`, `Router`, …) too.
35
+ *
36
+ * On by default because the compiler resolves them whether or not a rule mentions
37
+ * them, so declaring them is what matches reality. A real import shadows the ambient
38
+ * declaration, so this stays safe for code that imports them explicitly.
39
+ */
40
+ builtins?: boolean;
41
+ /**
42
+ * Declare the `$` reactive intrinsics (`$signal`, `$memo`, …).
43
+ *
44
+ * On by default, matching the compiler: it rewrites those calls whether or not
45
+ * anything declares them, and without the declaration the editor reports
46
+ * "Cannot find name '$signal'" for code that builds correctly.
47
+ */
48
+ intrinsics?: boolean;
49
+ /** Attribution written into the header. */
50
+ generator?: string;
51
+ /**
52
+ * Rewrite a module specifier for the file being generated.
53
+ *
54
+ * A bundler and TypeScript do not agree on every specifier: Vite resolves a
55
+ * root-absolute `/src/x.tsx` that TypeScript cannot see at all. The caller knows where
56
+ * the file will land and so is the only one able to fix that up; the generator stays
57
+ * pure and just asks.
58
+ */
59
+ specifier?: (module: string) => string;
60
+ }
61
+ export interface ComponentGlobalsResult {
62
+ /** The `.d.ts` source to write. */
63
+ source: string;
64
+ /** Components declared. */
65
+ declared: string[];
66
+ /** Left out because `lib.dom` already claims the name. */
67
+ shadowedByDom: string[];
68
+ /** Left out because the project does not depend on their package. */
69
+ unavailable: string[];
70
+ /**
71
+ * Pattern rules, which have no finite name list and so cannot be declared.
72
+ *
73
+ * `Icon(.+) -> @/icons/$1` matches unboundedly many names; the resolver answers them on
74
+ * demand but cannot enumerate them. Those tags stay manual, and the caller is told how
75
+ * many rules are in that position rather than left to wonder why nothing appeared.
76
+ */
77
+ patternRules: number;
78
+ }
79
+ /** Build the ambient `.d.ts` for the components a project's `resolve` config supplies. */
80
+ export declare function componentGlobals(rules: readonly ComponentResolverRule[], options?: ComponentGlobalsOptions): ComponentGlobalsResult;