@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
@@ -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;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Ambient declarations for the components `resolve` supplies without an import.
3
3
  *
4
- * The compiler injects the import, so nothing in the source imports these which leaves
4
+ * The compiler injects the import, so nothing in the source imports these, which leaves
5
5
  * TypeScript reporting `TS2304: Cannot find name`. The code compiles and runs; the editor
6
6
  * is unusable and `tsc` fails. These declarations describe what the compiler already
7
7
  * does. They do not enable it.
@@ -9,8 +9,8 @@
9
9
  * This lives next to the resolver, and takes rules rather than a flat map, because the
10
10
  * resolver is the only thing that knows the whole picture: a UI library's components, the
11
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
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
14
  * that predates it does not.
15
15
  *
16
16
  * Pure, like the resolver: rules in, source out, no filesystem. Writing the file is the
@@ -19,7 +19,7 @@
19
19
  import { type ComponentResolverRule } from './component-resolver.js';
20
20
  export interface ComponentGlobalsOptions {
21
21
  /**
22
- * Packages the project can actually resolve normally its declared dependencies.
22
+ * Packages the project can actually resolve: normally its declared dependencies.
23
23
  *
24
24
  * Declaring a component from a package the project does not depend on produces an
25
25
  * unresolvable `import(...)`, and under the usual `skipLibCheck: true` that failure is
@@ -27,7 +27,7 @@ export interface ComponentGlobalsOptions {
27
27
  * worse than the error it replaced. Omit to declare everything, which is only correct
28
28
  * when every package is present.
29
29
  *
30
- * Relative and alias specifiers are never filtered there is no package to check.
30
+ * Relative and alias specifiers are never filtered, there is no package to check.
31
31
  */
32
32
  available?: Iterable<string>;
33
33
  /**
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Ambient declarations for the components `resolve` supplies without an import.
3
3
  *
4
- * The compiler injects the import, so nothing in the source imports these which leaves
4
+ * The compiler injects the import, so nothing in the source imports these, which leaves
5
5
  * TypeScript reporting `TS2304: Cannot find name`. The code compiles and runs; the editor
6
6
  * is unusable and `tsc` fails. These declarations describe what the compiler already
7
7
  * does. They do not enable it.
@@ -9,8 +9,8 @@
9
9
  * This lives next to the resolver, and takes rules rather than a flat map, because the
10
10
  * resolver is the only thing that knows the whole picture: a UI library's components, the
11
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
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
14
  * that predates it does not.
15
15
  *
16
16
  * Pure, like the resolver: rules in, source out, no filesystem. Writing the file is the
@@ -23,7 +23,7 @@ import { INTRINSICS } from '../analyze/intrinsics.js';
23
23
  * Names `lib.dom` already declares as globals.
24
24
  *
25
25
  * An ambient `const Text` cannot beat `lib.dom`'s `var Text`, so for these the editor
26
- * would disagree with the compiler resolution still works at runtime, but the type
26
+ * would disagree with the compiler: resolution still works at runtime, but the type
27
27
  * shown would be the DOM node's. They are left out and reported instead, since importing
28
28
  * them explicitly makes both agree.
29
29
  */
@@ -68,7 +68,7 @@ export function componentGlobals(rules, options = {}) {
68
68
  const { available: availableList, builtins = true, intrinsics = true, generator = '@fluixi/compiler', specifier = (module) => module, } = options;
69
69
  const all = [...rules];
70
70
  if (builtins) {
71
- // Appended, so an explicit rule for the same name still wins the resolver is
71
+ // Appended, so an explicit rule for the same name still wins, the resolver is
72
72
  // first-match, and a project retargeting `Router` should keep its own answer.
73
73
  all.push({ components: builtinComponentMap() });
74
74
  }
@@ -107,8 +107,8 @@ export function componentGlobals(rules, options = {}) {
107
107
  // (`Button(props: ButtonProps): ComponentChild`) and go-to-definition lands on the
108
108
  // source. Both forms keep the JSDoc; the alias also keeps the shape.
109
109
  //
110
- // A default export cannot use it `import X = ns.default` is a syntax error, since
111
- // `default` is a reserved word in that position so those fall back to the `const`
110
+ // A default export cannot use it: `import X = ns.default` is a syntax error, since
111
+ // `default` is a reserved word in that position, so those fall back to the `const`
112
112
  // form, which types and documents correctly but renders as an anonymous arrow.
113
113
  const lines = declared.map((name) => {
114
114
  const target = resolved.get(name);
@@ -118,7 +118,7 @@ export function componentGlobals(rules, options = {}) {
118
118
  : ` export import ${name} = ${ns}.${target.export};`;
119
119
  });
120
120
  const note = shadowedByDom.length > 0
121
- ? `//\n// Import these explicitly lib.dom already declares the name, so an ambient\n` +
121
+ ? `//\n// Import these explicitly: lib.dom already declares the name, so an ambient\n` +
122
122
  `// declaration cannot win:\n` +
123
123
  shadowedByDom
124
124
  .map((n) => {
@@ -129,7 +129,7 @@ export function componentGlobals(rules, options = {}) {
129
129
  : '';
130
130
  // `typeof ns.signal` rather than an alias: the intrinsic is a global that stands for
131
131
  // the runtime call, so it takes the runtime's signature without claiming to be that
132
- // symbol go-to-definition on `$signal` should land on what it compiles to.
132
+ // symbol: go-to-definition on `$signal` should land on what it compiles to.
133
133
  const intrinsicLines = intrinsics
134
134
  ? Object.entries(INTRINSICS).map(([name, intrinsic]) => ` const ${name}: typeof ${namespaceAlias(intrinsic.module)}.${intrinsic.export};`)
135
135
  : [];
@@ -139,7 +139,7 @@ export function componentGlobals(rules, options = {}) {
139
139
  `// a pattern matches unboundedly many names, so there is no list to emit. Those\n` +
140
140
  `// tags still resolve at build time; declare them by hand if the editor needs them.\n`
141
141
  : '';
142
- const source = `// GENERATED by ${generator} do not edit.\n` +
142
+ const source = `// GENERATED by ${generator}, do not edit.\n` +
143
143
  `//\n` +
144
144
  `// The components \`resolve\` supplies without an import. This describes what the\n` +
145
145
  `// compiler already does; it does not enable it.\n` +
@@ -1,22 +1,219 @@
1
- var j=t=>"components"in t;function O(t,o){return t.replace(/\$(\d+)/g,(a,u)=>o[Number(u)]??a)}function _(t,o){return typeof o=="string"?{module:o,export:t}:o}function S(t=[]){let o=new Map,a=[],u=[];for(let n of t){if(!j(n)){u.push(n);continue}for(let[r,l]of Object.entries(n.components)){let c=_(r,l),m=o.get(r);if(m&&m.module!==c.module){let d=a.find(R=>R.name===r);d?d.modules.push(c.module):a.push({name:r,modules:[m.module,c.module]});continue}o.set(r,c)}}let i=new Map;return{resolve:n=>{if(i.has(n))return i.get(n);let r=o.get(n);if(!r)for(let l of u){let c=n.match(new RegExp(l.match.source,l.match.flags.replace("g","")));if(c){r={module:O(l.module,c),export:l.export?O(l.export,c):n};break}}return i.set(n,r),r},names:()=>[...o.keys()],conflicts:()=>a}}var C=["Show","For","Index","Switch","Match","Portal","Dynamic","ErrorBoundary"],b=["Suspense","SuspenseList","Await"],$=["Router","Outlet","Redirect","Link"],G=[...C,...b,...$],W=new Set([...C,...b]);function E(t={}){let{controlFlowModule:o="@fluixi/dom",coreModule:a="@fluixi/core",routerModule:u="@fluixi/core/router"}=t,i={};for(let p of C)i[p]=o;for(let p of b)i[p]=a;for(let p of $)i[p]=u;return i}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 U=new RegExp(`\\$(?:${Object.keys(h).map(t=>t.slice(1)).join("|")})\\s*\\(`);var D=new Set(["Text","Image","Option","Audio","Comment","Range","Selection","Notification","Event","Document","Element","Node","Screen","Window","Location","History","Storage","Response","Request","Headers"]);function P(t){if(t.startsWith(".")||t.startsWith("/")||/^[~@]\//.test(t))return;let o=t.split("/");return t.startsWith("@")?o.slice(0,2).join("/"):o[0]}function M(t){return`_${t.replace(/[^A-Za-z0-9]/g,"_")}`}function z(t,o={}){let{available:a,builtins:u=!0,intrinsics:i=!0,generator:p="@fluixi/compiler",specifier:n=e=>e}=o,r=[...t];u&&r.push({components:E()});let l=S(r),c=a?new Set(a):void 0,m=[],d=[],R=[],v=new Map;for(let e of[...l.names()].sort()){let s=l.resolve(e);if(!s)continue;let g=P(s.module);D.has(e)?d.push(e):c&&g&&!c.has(g)?R.push(e):(m.push(e),v.set(e,s))}let I=i?[...new Set(Object.values(h).map(e=>e.module))]:[],y=[...new Set([...m.map(e=>v.get(e).module),...I])].sort().map(e=>`import * as ${M(e)} from '${n(e)}';`),w=m.map(e=>{let s=v.get(e),g=M(s.module);return s.export==="default"?` const ${e}: typeof ${g}.default;`:` export import ${e} = ${g}.${s.export};`}),N=d.length>0?`//
2
- // Import these explicitly lib.dom already declares the name, so an ambient
1
+ // src/resolve/component-resolver.ts
2
+ var isMapRule = (rule) => "components" in rule;
3
+ function substitute(template, match) {
4
+ return template.replace(/\$(\d+)/g, (whole, index) => {
5
+ const group = match[Number(index)];
6
+ return group ?? whole;
7
+ });
8
+ }
9
+ function normalise(name, entry) {
10
+ return typeof entry === "string" ? { module: entry, export: name } : entry;
11
+ }
12
+ function createComponentResolver(rules = []) {
13
+ const exact = /* @__PURE__ */ new Map();
14
+ const conflicts = [];
15
+ const patterns = [];
16
+ for (const rule of rules) {
17
+ if (!isMapRule(rule)) {
18
+ patterns.push(rule);
19
+ continue;
20
+ }
21
+ for (const [name, entry] of Object.entries(rule.components)) {
22
+ const resolved = normalise(name, entry);
23
+ const existing = exact.get(name);
24
+ if (existing && existing.module !== resolved.module) {
25
+ const conflict = conflicts.find((c) => c.name === name);
26
+ if (conflict) conflict.modules.push(resolved.module);
27
+ else conflicts.push({ name, modules: [existing.module, resolved.module] });
28
+ continue;
29
+ }
30
+ exact.set(name, resolved);
31
+ }
32
+ }
33
+ const cache = /* @__PURE__ */ new Map();
34
+ const resolve = (name) => {
35
+ if (cache.has(name)) return cache.get(name);
36
+ let result = exact.get(name);
37
+ if (!result) {
38
+ for (const rule of patterns) {
39
+ const match = name.match(new RegExp(rule.match.source, rule.match.flags.replace("g", "")));
40
+ if (!match) continue;
41
+ result = {
42
+ module: substitute(rule.module, match),
43
+ export: rule.export ? substitute(rule.export, match) : name
44
+ };
45
+ break;
46
+ }
47
+ }
48
+ cache.set(name, result);
49
+ return result;
50
+ };
51
+ return {
52
+ resolve,
53
+ names: () => [...exact.keys()],
54
+ conflicts: () => conflicts
55
+ };
56
+ }
57
+
58
+ // src/resolve/builtins.ts
59
+ var DOM_CONTROL_FLOW = [
60
+ "Show",
61
+ "For",
62
+ "Index",
63
+ "Switch",
64
+ "Match",
65
+ "Portal",
66
+ "Dynamic",
67
+ "ErrorBoundary"
68
+ ];
69
+ var CORE_CONTROL_FLOW = ["Suspense", "SuspenseList", "Await"];
70
+ var ROUTER_COMPONENTS = ["Router", "Outlet", "Redirect", "Link"];
71
+ var BUILTIN_COMPONENTS = [
72
+ ...DOM_CONTROL_FLOW,
73
+ ...CORE_CONTROL_FLOW,
74
+ ...ROUTER_COMPONENTS
75
+ ];
76
+ var RESERVED_COMPONENTS = /* @__PURE__ */ new Set([
77
+ ...DOM_CONTROL_FLOW,
78
+ ...CORE_CONTROL_FLOW
79
+ ]);
80
+ function builtinComponentMap(modules = {}) {
81
+ const {
82
+ controlFlowModule = "@fluixi/dom",
83
+ coreModule = "@fluixi/core",
84
+ routerModule = "@fluixi/core/router"
85
+ } = modules;
86
+ const map = {};
87
+ for (const name of DOM_CONTROL_FLOW) map[name] = controlFlowModule;
88
+ for (const name of CORE_CONTROL_FLOW) map[name] = coreModule;
89
+ for (const name of ROUTER_COMPONENTS) map[name] = routerModule;
90
+ return map;
91
+ }
92
+
93
+ // src/analyze/intrinsics.ts
94
+ var REACTIVE_MODULE = "@fluixi/reactive/signal";
95
+ var INTRINSICS = {
96
+ $signal: { export: "signal", module: REACTIVE_MODULE, returns: "signal-handle" },
97
+ $memo: { export: "memo", module: REACTIVE_MODULE, returns: "memo-handle" },
98
+ $effect: { export: "effect", module: REACTIVE_MODULE, returns: "effect" },
99
+ $store: { export: "store", module: "@fluixi/reactive/store", returns: "store-handle" },
100
+ $resource: { export: "resource", module: REACTIVE_MODULE, returns: "resource-handle" },
101
+ // No short runtime form for these yet, so the intrinsic stands for the `create*`
102
+ // name. Still worth having: no import to write, and when a shorter form is
103
+ // designed, the change is this line rather than a compiler pass.
104
+ $selector: { export: "createSelector", module: REACTIVE_MODULE, returns: "memo-accessor" },
105
+ $deferred: { export: "createDeferred", module: REACTIVE_MODULE, returns: "memo-accessor" },
106
+ // Not value constructors, but the compiler has to know them: they change what a read
107
+ // does. `untrack` suppresses dependency collection, which is exactly the kind of thing
108
+ // dependency analysis must not guess at.
109
+ $untrack: { export: "untrack", module: REACTIVE_MODULE, returns: "plain" },
110
+ $untrackStore: { export: "untrackStore", module: "@fluixi/reactive/store", returns: "plain" }
111
+ };
112
+ var INTRINSIC_CALL = new RegExp(`\\$(?:${Object.keys(INTRINSICS).map((n) => n.slice(1)).join("|")})\\s*\\(`);
113
+
114
+ // src/resolve/component-globals.ts
115
+ var DOM_GLOBALS = /* @__PURE__ */ new Set([
116
+ "Text",
117
+ "Image",
118
+ "Option",
119
+ "Audio",
120
+ "Comment",
121
+ "Range",
122
+ "Selection",
123
+ "Notification",
124
+ "Event",
125
+ "Document",
126
+ "Element",
127
+ "Node",
128
+ "Screen",
129
+ "Window",
130
+ "Location",
131
+ "History",
132
+ "Storage",
133
+ "Response",
134
+ "Request",
135
+ "Headers"
136
+ ]);
137
+ function packageOf(specifier) {
138
+ if (specifier.startsWith(".") || specifier.startsWith("/")) return void 0;
139
+ if (/^[~@]\//.test(specifier)) return void 0;
140
+ const parts = specifier.split("/");
141
+ return specifier.startsWith("@") ? parts.slice(0, 2).join("/") : parts[0];
142
+ }
143
+ function namespaceAlias(module) {
144
+ return `_${module.replace(/[^A-Za-z0-9]/g, "_")}`;
145
+ }
146
+ function componentGlobals(rules, options = {}) {
147
+ const {
148
+ available: availableList,
149
+ builtins = true,
150
+ intrinsics = true,
151
+ generator = "@fluixi/compiler",
152
+ specifier = (module) => module
153
+ } = options;
154
+ const all = [...rules];
155
+ if (builtins) {
156
+ all.push({ components: builtinComponentMap() });
157
+ }
158
+ const resolver = createComponentResolver(all);
159
+ const available = availableList ? new Set(availableList) : void 0;
160
+ const declared = [];
161
+ const shadowedByDom = [];
162
+ const unavailable = [];
163
+ const resolved = /* @__PURE__ */ new Map();
164
+ for (const name of [...resolver.names()].sort()) {
165
+ const target = resolver.resolve(name);
166
+ if (!target) continue;
167
+ const pkg = packageOf(target.module);
168
+ if (DOM_GLOBALS.has(name)) shadowedByDom.push(name);
169
+ else if (available && pkg && !available.has(pkg)) unavailable.push(name);
170
+ else {
171
+ declared.push(name);
172
+ resolved.set(name, target);
173
+ }
174
+ }
175
+ const intrinsicModules = intrinsics ? [...new Set(Object.values(INTRINSICS).map((i) => i.module))] : [];
176
+ const modules = [
177
+ .../* @__PURE__ */ new Set([...declared.map((name) => resolved.get(name).module), ...intrinsicModules])
178
+ ].sort();
179
+ const imports = modules.map(
180
+ (m) => `import * as ${namespaceAlias(m)} from '${specifier(m)}';`
181
+ );
182
+ const lines = declared.map((name) => {
183
+ const target = resolved.get(name);
184
+ const ns = namespaceAlias(target.module);
185
+ return target.export === "default" ? ` const ${name}: typeof ${ns}.default;` : ` export import ${name} = ${ns}.${target.export};`;
186
+ });
187
+ const note = shadowedByDom.length > 0 ? `//
188
+ // Import these explicitly: lib.dom already declares the name, so an ambient
3
189
  // declaration cannot win:
4
- `+d.map(e=>{let s=l.resolve(e)?.module;return`// import { ${e} } from '${s?n(s):""}';
5
- `}).join(""):"",T=i?Object.entries(h).map(([e,s])=>` const ${e}: typeof ${M(s.module)}.${s.export};`):[],x=t.filter(e=>"match"in e).length,L=x>0?`//
6
- // ${x} pattern rule${x===1?"":"s"} cannot be declared:
190
+ ` + shadowedByDom.map((n) => {
191
+ const module = resolver.resolve(n)?.module;
192
+ return `// import { ${n} } from '${module ? specifier(module) : ""}';
193
+ `;
194
+ }).join("") : "";
195
+ const intrinsicLines = intrinsics ? Object.entries(INTRINSICS).map(
196
+ ([name, intrinsic]) => ` const ${name}: typeof ${namespaceAlias(intrinsic.module)}.${intrinsic.export};`
197
+ ) : [];
198
+ const patternRules = rules.filter((rule) => "match" in rule).length;
199
+ const patternNote = patternRules > 0 ? `//
200
+ // ${patternRules} pattern rule${patternRules === 1 ? "" : "s"} cannot be declared:
7
201
  // a pattern matches unboundedly many names, so there is no list to emit. Those
8
202
  // tags still resolve at build time; declare them by hand if the editor needs them.
9
- `:"";return{source:`// GENERATED by ${p} — do not edit.
203
+ ` : "";
204
+ const source = `// GENERATED by ${generator}, do not edit.
10
205
  //
11
206
  // The components \`resolve\` supplies without an import. This describes what the
12
207
  // compiler already does; it does not enable it.
13
- `+N+L+(y.length>0?`
14
- ${y.join(`
15
- `)}
16
- `:`
17
- `)+`
208
+ ` + note + patternNote + (imports.length > 0 ? `
209
+ ${imports.join("\n")}
210
+ ` : "\n") + `
18
211
  declare global {
19
- ${[...w,...T].join(`
20
- `)}
212
+ ${[...lines, ...intrinsicLines].join("\n")}
213
+ }
214
+ `;
215
+ return { source, declared, shadowedByDom, unavailable, patternRules };
21
216
  }
22
- `,declared:m,shadowedByDom:d,unavailable:R,patternRules:x}}export{z as componentGlobals};
217
+ export {
218
+ componentGlobals
219
+ };
@@ -1 +1,80 @@
1
- "use strict";var u=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var R=Object.prototype.hasOwnProperty;var C=(o,e)=>{for(var n in e)u(o,n,{get:e[n],enumerable:!0})},v=(o,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of g(e))!R.call(o,t)&&t!==n&&u(o,t,{get:()=>e[t],enumerable:!(i=d(e,t))||i.enumerable});return o};var x=o=>v(u({},"__esModule",{value:!0}),o);var y={};C(y,{createComponentResolver:()=>b});module.exports=x(y);var h=o=>"components"in o;function a(o,e){return o.replace(/\$(\d+)/g,(n,i)=>e[Number(i)]??n)}function M(o,e){return typeof e=="string"?{module:e,export:o}:e}function b(o=[]){let e=new Map,n=[],i=[];for(let r of o){if(!h(r)){i.push(r);continue}for(let[s,p]of Object.entries(r.components)){let l=M(s,p),c=e.get(s);if(c&&c.module!==l.module){let m=n.find(f=>f.name===s);m?m.modules.push(l.module):n.push({name:s,modules:[c.module,l.module]});continue}e.set(s,l)}}let t=new Map;return{resolve:r=>{if(t.has(r))return t.get(r);let s=e.get(r);if(!s)for(let p of i){let l=r.match(new RegExp(p.match.source,p.match.flags.replace("g","")));if(l){s={module:a(p.module,l),export:p.export?a(p.export,l):r};break}}return t.set(r,s),s},names:()=>[...e.keys()],conflicts:()=>n}}
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-resolver.ts
21
+ var component_resolver_exports = {};
22
+ __export(component_resolver_exports, {
23
+ createComponentResolver: () => createComponentResolver
24
+ });
25
+ module.exports = __toCommonJS(component_resolver_exports);
26
+ var isMapRule = (rule) => "components" in rule;
27
+ function substitute(template, match) {
28
+ return template.replace(/\$(\d+)/g, (whole, index) => {
29
+ const group = match[Number(index)];
30
+ return group ?? whole;
31
+ });
32
+ }
33
+ function normalise(name, entry) {
34
+ return typeof entry === "string" ? { module: entry, export: name } : entry;
35
+ }
36
+ function createComponentResolver(rules = []) {
37
+ const exact = /* @__PURE__ */ new Map();
38
+ const conflicts = [];
39
+ const patterns = [];
40
+ for (const rule of rules) {
41
+ if (!isMapRule(rule)) {
42
+ patterns.push(rule);
43
+ continue;
44
+ }
45
+ for (const [name, entry] of Object.entries(rule.components)) {
46
+ const resolved = normalise(name, entry);
47
+ const existing = exact.get(name);
48
+ if (existing && existing.module !== resolved.module) {
49
+ const conflict = conflicts.find((c) => c.name === name);
50
+ if (conflict) conflict.modules.push(resolved.module);
51
+ else conflicts.push({ name, modules: [existing.module, resolved.module] });
52
+ continue;
53
+ }
54
+ exact.set(name, resolved);
55
+ }
56
+ }
57
+ const cache = /* @__PURE__ */ new Map();
58
+ const resolve = (name) => {
59
+ if (cache.has(name)) return cache.get(name);
60
+ let result = exact.get(name);
61
+ if (!result) {
62
+ for (const rule of patterns) {
63
+ const match = name.match(new RegExp(rule.match.source, rule.match.flags.replace("g", "")));
64
+ if (!match) continue;
65
+ result = {
66
+ module: substitute(rule.module, match),
67
+ export: rule.export ? substitute(rule.export, match) : name
68
+ };
69
+ break;
70
+ }
71
+ }
72
+ cache.set(name, result);
73
+ return result;
74
+ };
75
+ return {
76
+ resolve,
77
+ names: () => [...exact.keys()],
78
+ conflicts: () => conflicts
79
+ };
80
+ }
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Compile-time component resolution.
3
+ *
4
+ * An unbound capitalised tag in a template is a name the compiler can resolve to a
5
+ * module, instead of an import the author has to write. The framework already does
6
+ * this for `Suspense`/`Portal`/`Router`, but through a hardcoded name set inside the
7
+ * Babel plugin: which cannot be extended by a UI library or an app, and cannot be
8
+ * configured per project.
9
+ *
10
+ * This is the configurable version of the same idea. It is deliberately a pure
11
+ * `name -> { module, export }` function with no filesystem access and no Babel
12
+ * dependency, because three separate consumers need exactly the same answer:
13
+ *
14
+ * - the compiler, to inject the import;
15
+ * - the TS plugin, to synthesise the import so hover/go-to-definition/rename work;
16
+ * - a codemod, to materialise imports back into source.
17
+ *
18
+ * Keeping resolution pure is what lets those three agree. Anything requiring the
19
+ * filesystem (directory conventions) belongs in a rule *builder* that produces a map,
20
+ * not in the resolver itself.
21
+ */
22
+ /** Where a resolved component comes from. */
23
+ export interface ResolvedComponent {
24
+ module: string;
25
+ /** The export name, or `default`. */
26
+ export: string;
27
+ }
28
+ /**
29
+ * An explicit name -> module map. This is what a component library ships
30
+ * (`Button -> @fluixi-ui/button`), generated from its own package list rather than
31
+ * hand-maintained.
32
+ */
33
+ export interface ComponentMapRule {
34
+ components: Record<string, string | ResolvedComponent>;
35
+ }
36
+ /**
37
+ * A pattern rule. `$1`-style references in `module`/`export` are substituted from the
38
+ * match groups, so one rule can cover a family (`Icon(.+) -> @/icons/$1`).
39
+ */
40
+ export interface ComponentPatternRule {
41
+ match: RegExp;
42
+ module: string;
43
+ /** Defaults to the tag name; use `'default'` for file-per-component layouts. */
44
+ export?: string;
45
+ }
46
+ export type ComponentResolverRule = ComponentMapRule | ComponentPatternRule;
47
+ /** Two rules claiming the same name: reported rather than silently first-wins. */
48
+ export interface ResolverConflict {
49
+ name: string;
50
+ modules: string[];
51
+ }
52
+ export interface ComponentResolver {
53
+ /** `undefined` when no rule claims the name. */
54
+ resolve: (name: string) => ResolvedComponent | undefined;
55
+ /** Every name the resolver can answer, for editor completion. */
56
+ names: () => string[];
57
+ /** Names claimed by more than one rule with different targets. */
58
+ conflicts: () => ResolverConflict[];
59
+ }
60
+ /**
61
+ * Build a resolver from rules, in order.
62
+ *
63
+ * Map rules are flattened up front so lookup is a plain object read, resolution runs
64
+ * once per component reference per compile, so it sits on the hot path of every build.
65
+ * Pattern rules are tried afterwards, in declaration order, and only when no map rule
66
+ * matched: an explicit entry should always beat a pattern.
67
+ */
68
+ export declare function createComponentResolver(rules?: readonly ComponentResolverRule[]): ComponentResolver;
@@ -4,7 +4,7 @@
4
4
  * An unbound capitalised tag in a template is a name the compiler can resolve to a
5
5
  * module, instead of an import the author has to write. The framework already does
6
6
  * this for `Suspense`/`Portal`/`Router`, but through a hardcoded name set inside the
7
- * Babel plugin which cannot be extended by a UI library or an app, and cannot be
7
+ * Babel plugin: which cannot be extended by a UI library or an app, and cannot be
8
8
  * configured per project.
9
9
  *
10
10
  * This is the configurable version of the same idea. It is deliberately a pure
@@ -44,7 +44,7 @@ export interface ComponentPatternRule {
44
44
  export?: string;
45
45
  }
46
46
  export type ComponentResolverRule = ComponentMapRule | ComponentPatternRule;
47
- /** Two rules claiming the same name reported rather than silently first-wins. */
47
+ /** Two rules claiming the same name: reported rather than silently first-wins. */
48
48
  export interface ResolverConflict {
49
49
  name: string;
50
50
  modules: string[];
@@ -60,7 +60,7 @@ export interface ComponentResolver {
60
60
  /**
61
61
  * Build a resolver from rules, in order.
62
62
  *
63
- * Map rules are flattened up front so lookup is a plain object read resolution runs
63
+ * Map rules are flattened up front so lookup is a plain object read, resolution runs
64
64
  * once per component reference per compile, so it sits on the hot path of every build.
65
65
  * Pattern rules are tried afterwards, in declaration order, and only when no map rule
66
66
  * matched: an explicit entry should always beat a pattern.
@@ -1 +1 @@
1
- {"version":3,"file":"component-resolver.d.ts","sourceRoot":"","sources":["../../src/resolve/component-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,6CAA6C;AAC7C,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,qCAAqC;IACrC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,iBAAiB,CAAC,CAAC;CACxD;AAED;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,gFAAgF;IAChF,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,qBAAqB,GAAG,gBAAgB,GAAG,oBAAoB,CAAC;AAE5E,mFAAmF;AACnF,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,iBAAiB;IAChC,gDAAgD;IAChD,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,iBAAiB,GAAG,SAAS,CAAC;IACzD,iEAAiE;IACjE,KAAK,EAAE,MAAM,MAAM,EAAE,CAAC;IACtB,kEAAkE;IAClE,SAAS,EAAE,MAAM,gBAAgB,EAAE,CAAC;CACrC;AAiBD;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,GAAE,SAAS,qBAAqB,EAAO,GAC3C,iBAAiB,CAwDnB"}
1
+ {"version":3,"file":"component-resolver.d.ts","sourceRoot":"","sources":["../../src/resolve/component-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,6CAA6C;AAC7C,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,qCAAqC;IACrC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,iBAAiB,CAAC,CAAC;CACxD;AAED;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,gFAAgF;IAChF,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,qBAAqB,GAAG,gBAAgB,GAAG,oBAAoB,CAAC;AAE5E,kFAAkF;AAClF,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,iBAAiB;IAChC,gDAAgD;IAChD,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,iBAAiB,GAAG,SAAS,CAAC;IACzD,iEAAiE;IACjE,KAAK,EAAE,MAAM,MAAM,EAAE,CAAC;IACtB,kEAAkE;IAClE,SAAS,EAAE,MAAM,gBAAgB,EAAE,CAAC;CACrC;AAiBD;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,GAAE,SAAS,qBAAqB,EAAO,GAC3C,iBAAiB,CAwDnB"}
@@ -4,7 +4,7 @@
4
4
  * An unbound capitalised tag in a template is a name the compiler can resolve to a
5
5
  * module, instead of an import the author has to write. The framework already does
6
6
  * this for `Suspense`/`Portal`/`Router`, but through a hardcoded name set inside the
7
- * Babel plugin which cannot be extended by a UI library or an app, and cannot be
7
+ * Babel plugin: which cannot be extended by a UI library or an app, and cannot be
8
8
  * configured per project.
9
9
  *
10
10
  * This is the configurable version of the same idea. It is deliberately a pure
@@ -33,7 +33,7 @@ function normalise(name, entry) {
33
33
  /**
34
34
  * Build a resolver from rules, in order.
35
35
  *
36
- * Map rules are flattened up front so lookup is a plain object read resolution runs
36
+ * Map rules are flattened up front so lookup is a plain object read, resolution runs
37
37
  * once per component reference per compile, so it sits on the hot path of every build.
38
38
  * Pattern rules are tried afterwards, in declaration order, and only when no map rule
39
39
  * matched: an explicit entry should always beat a pattern.
@@ -54,7 +54,7 @@ export function createComponentResolver(rules = []) {
54
54
  // Ambiguity is the failure mode that actually happens once a map holds
55
55
  // ~80 common words (Card, Table, Text, Link). Silently taking the first
56
56
  // rule would compile a working import of the wrong component, which is
57
- // far worse to debug than a build error so it is recorded and reported.
57
+ // far worse to debug than a build error: so it is recorded and reported.
58
58
  const conflict = conflicts.find((c) => c.name === name);
59
59
  if (conflict)
60
60
  conflict.modules.push(resolved.module);