@fluixi/compiler 1.0.0-alpha.100

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 (303) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +131 -0
  3. package/dist/analyze/expr-shape.cjs +62 -0
  4. package/dist/analyze/expr-shape.d.cts +14 -0
  5. package/dist/analyze/expr-shape.d.ts +15 -0
  6. package/dist/analyze/expr-shape.d.ts.map +1 -0
  7. package/dist/analyze/expr-shape.js +37 -0
  8. package/dist/analyze/expr-shape.mjs +41 -0
  9. package/dist/analyze/intrinsics.cjs +112 -0
  10. package/dist/analyze/intrinsics.d.cts +80 -0
  11. package/dist/analyze/intrinsics.d.ts +81 -0
  12. package/dist/analyze/intrinsics.d.ts.map +1 -0
  13. package/dist/analyze/intrinsics.js +126 -0
  14. package/dist/analyze/intrinsics.mjs +91 -0
  15. package/dist/analyze/paren.cjs +134 -0
  16. package/dist/analyze/paren.d.cts +23 -0
  17. package/dist/analyze/paren.d.ts +24 -0
  18. package/dist/analyze/paren.d.ts.map +1 -0
  19. package/dist/analyze/paren.js +168 -0
  20. package/dist/analyze/paren.mjs +113 -0
  21. package/dist/analyze/props-destructure.cjs +226 -0
  22. package/dist/analyze/props-destructure.d.cts +83 -0
  23. package/dist/analyze/props-destructure.d.ts +84 -0
  24. package/dist/analyze/props-destructure.d.ts.map +1 -0
  25. package/dist/analyze/props-destructure.js +272 -0
  26. package/dist/analyze/props-destructure.mjs +205 -0
  27. package/dist/analyze/reactive-bindings.cjs +210 -0
  28. package/dist/analyze/reactive-bindings.d.cts +42 -0
  29. package/dist/analyze/reactive-bindings.d.ts +43 -0
  30. package/dist/analyze/reactive-bindings.d.ts.map +1 -0
  31. package/dist/analyze/reactive-bindings.js +191 -0
  32. package/dist/analyze/reactive-bindings.mjs +187 -0
  33. package/dist/analyze/reactive-expr.cjs +38 -0
  34. package/dist/analyze/reactive-expr.d.cts +38 -0
  35. package/dist/analyze/reactive-expr.d.ts +39 -0
  36. package/dist/analyze/reactive-expr.d.ts.map +1 -0
  37. package/dist/analyze/reactive-expr.js +31 -0
  38. package/dist/analyze/reactive-expr.mjs +17 -0
  39. package/dist/analyze/static-graph.cjs +831 -0
  40. package/dist/analyze/static-graph.d.cts +102 -0
  41. package/dist/analyze/static-graph.d.ts +103 -0
  42. package/dist/analyze/static-graph.d.ts.map +1 -0
  43. package/dist/analyze/static-graph.js +871 -0
  44. package/dist/analyze/static-graph.mjs +813 -0
  45. package/dist/babel-I6BUWUCU.mjs +636 -0
  46. package/dist/chunk-3AICWNF7.mjs +92 -0
  47. package/dist/chunk-6CWJWGE2.mjs +2170 -0
  48. package/dist/chunk-C3XPDB4Y.mjs +16 -0
  49. package/dist/chunk-GX5XV6Z7.mjs +190 -0
  50. package/dist/chunk-HXEXPWJ2.mjs +999 -0
  51. package/dist/chunk-NU3W67UZ.mjs +584 -0
  52. package/dist/chunk-SKAVY75W.mjs +11 -0
  53. package/dist/codegen/backend.cjs +18 -0
  54. package/dist/codegen/backend.d.cts +35 -0
  55. package/dist/codegen/backend.d.ts +36 -0
  56. package/dist/codegen/backend.d.ts.map +1 -0
  57. package/dist/codegen/backend.js +1 -0
  58. package/dist/codegen/backend.mjs +0 -0
  59. package/dist/codegen/backends/imperative.cjs +577 -0
  60. package/dist/codegen/backends/imperative.d.cts +11 -0
  61. package/dist/codegen/backends/imperative.d.ts +12 -0
  62. package/dist/codegen/backends/imperative.d.ts.map +1 -0
  63. package/dist/codegen/backends/imperative.js +362 -0
  64. package/dist/codegen/backends/imperative.mjs +554 -0
  65. package/dist/codegen/contract.cjs +52 -0
  66. package/dist/codegen/contract.d.cts +24 -0
  67. package/dist/codegen/contract.d.ts +25 -0
  68. package/dist/codegen/contract.d.ts.map +1 -0
  69. package/dist/codegen/contract.js +30 -0
  70. package/dist/codegen/contract.mjs +31 -0
  71. package/dist/codegen/partial-template.cjs +176 -0
  72. package/dist/codegen/partial-template.d.cts +61 -0
  73. package/dist/codegen/partial-template.d.ts +62 -0
  74. package/dist/codegen/partial-template.d.ts.map +1 -0
  75. package/dist/codegen/partial-template.js +0 -0
  76. package/dist/codegen/partial-template.mjs +153 -0
  77. package/dist/codegen/serialize-static.cjs +125 -0
  78. package/dist/codegen/serialize-static.d.cts +38 -0
  79. package/dist/codegen/serialize-static.d.ts +39 -0
  80. package/dist/codegen/serialize-static.d.ts.map +1 -0
  81. package/dist/codegen/serialize-static.js +165 -0
  82. package/dist/codegen/serialize-static.mjs +104 -0
  83. package/dist/frontend/babel/build-ir-lit.cjs +1933 -0
  84. package/dist/frontend/babel/build-ir-lit.d.cts +26 -0
  85. package/dist/frontend/babel/build-ir-lit.d.ts +27 -0
  86. package/dist/frontend/babel/build-ir-lit.d.ts.map +1 -0
  87. package/dist/frontend/babel/build-ir-lit.js +13 -0
  88. package/dist/frontend/babel/build-ir-lit.mjs +1902 -0
  89. package/dist/frontend/babel/build-ir.cjs +1948 -0
  90. package/dist/frontend/babel/build-ir.d.cts +35 -0
  91. package/dist/frontend/babel/build-ir.d.ts +36 -0
  92. package/dist/frontend/babel/build-ir.d.ts.map +1 -0
  93. package/dist/frontend/babel/build-ir.js +124 -0
  94. package/dist/frontend/babel/build-ir.mjs +1919 -0
  95. package/dist/frontend/babel/index.cjs +2610 -0
  96. package/dist/frontend/babel/index.d.cts +33 -0
  97. package/dist/frontend/babel/index.d.ts +34 -0
  98. package/dist/frontend/babel/index.d.ts.map +1 -0
  99. package/dist/frontend/babel/index.js +65 -0
  100. package/dist/frontend/babel/index.mjs +2580 -0
  101. package/dist/frontend/babel/lower-template.cjs +1931 -0
  102. package/dist/frontend/babel/lower-template.d.cts +23 -0
  103. package/dist/frontend/babel/lower-template.d.ts +24 -0
  104. package/dist/frontend/babel/lower-template.d.ts.map +1 -0
  105. package/dist/frontend/babel/lower-template.js +64 -0
  106. package/dist/frontend/babel/lower-template.mjs +1902 -0
  107. package/dist/frontend/babel/plugin.cjs +2556 -0
  108. package/dist/frontend/babel/plugin.d.cts +95 -0
  109. package/dist/frontend/babel/plugin.d.ts +96 -0
  110. package/dist/frontend/babel/plugin.d.ts.map +1 -0
  111. package/dist/frontend/babel/plugin.js +523 -0
  112. package/dist/frontend/babel/plugin.mjs +2527 -0
  113. package/dist/frontend/babel/server-functions.cjs +110 -0
  114. package/dist/frontend/babel/server-functions.d.cts +10 -0
  115. package/dist/frontend/babel/server-functions.d.ts +11 -0
  116. package/dist/frontend/babel/server-functions.d.ts.map +1 -0
  117. package/dist/frontend/babel/server-functions.js +81 -0
  118. package/dist/frontend/babel/server-functions.mjs +89 -0
  119. package/dist/frontend/babel/types.cjs +18 -0
  120. package/dist/frontend/babel/types.d.cts +33 -0
  121. package/dist/frontend/babel/types.d.ts +34 -0
  122. package/dist/frontend/babel/types.d.ts.map +1 -0
  123. package/dist/frontend/babel/types.js +1 -0
  124. package/dist/frontend/babel/types.mjs +0 -0
  125. package/dist/frontend/types.cjs +18 -0
  126. package/dist/frontend/types.d.cts +25 -0
  127. package/dist/frontend/types.d.ts +26 -0
  128. package/dist/frontend/types.d.ts.map +1 -0
  129. package/dist/frontend/types.js +1 -0
  130. package/dist/frontend/types.mjs +0 -0
  131. package/dist/frontend/vocabulary.cjs +98 -0
  132. package/dist/frontend/vocabulary.d.cts +79 -0
  133. package/dist/frontend/vocabulary.d.ts +80 -0
  134. package/dist/frontend/vocabulary.d.ts.map +1 -0
  135. package/dist/frontend/vocabulary.js +124 -0
  136. package/dist/frontend/vocabulary.mjs +77 -0
  137. package/dist/index.cjs +1957 -0
  138. package/dist/index.d.cts +27 -0
  139. package/dist/index.d.ts +28 -0
  140. package/dist/index.d.ts.map +1 -0
  141. package/dist/index.js +38 -0
  142. package/dist/index.mjs +1949 -0
  143. package/dist/integrations.cjs +5705 -0
  144. package/dist/integrations.d.cts +215 -0
  145. package/dist/integrations.d.ts +216 -0
  146. package/dist/integrations.d.ts.map +1 -0
  147. package/dist/integrations.js +566 -0
  148. package/dist/integrations.mjs +810 -0
  149. package/dist/ir/nodes.cjs +18 -0
  150. package/dist/ir/nodes.d.cts +168 -0
  151. package/dist/ir/nodes.d.ts +169 -0
  152. package/dist/ir/nodes.d.ts.map +1 -0
  153. package/dist/ir/nodes.js +1 -0
  154. package/dist/ir/nodes.mjs +0 -0
  155. package/dist/lower/compile-template.cjs +1670 -0
  156. package/dist/lower/compile-template.d.cts +82 -0
  157. package/dist/lower/compile-template.d.ts +83 -0
  158. package/dist/lower/compile-template.d.ts.map +1 -0
  159. package/dist/lower/compile-template.js +79 -0
  160. package/dist/lower/compile-template.mjs +1662 -0
  161. package/dist/lower/entities.cjs +288 -0
  162. package/dist/lower/entities.d.cts +1 -0
  163. package/dist/lower/entities.d.ts +2 -0
  164. package/dist/lower/entities.d.ts.map +1 -0
  165. package/dist/lower/entities.js +54 -0
  166. package/dist/lower/entities.mjs +267 -0
  167. package/dist/lower/jsx.cjs +1101 -0
  168. package/dist/lower/jsx.d.cts +33 -0
  169. package/dist/lower/jsx.d.ts +34 -0
  170. package/dist/lower/jsx.d.ts.map +1 -0
  171. package/dist/lower/jsx.js +414 -0
  172. package/dist/lower/jsx.mjs +1078 -0
  173. package/dist/lower/template.cjs +1354 -0
  174. package/dist/lower/template.d.cts +53 -0
  175. package/dist/lower/template.d.ts +54 -0
  176. package/dist/lower/template.d.ts.map +1 -0
  177. package/dist/lower/template.js +542 -0
  178. package/dist/lower/template.mjs +1335 -0
  179. package/dist/lower/text.cjs +42 -0
  180. package/dist/lower/text.d.cts +10 -0
  181. package/dist/lower/text.d.ts +11 -0
  182. package/dist/lower/text.d.ts.map +1 -0
  183. package/dist/lower/text.js +31 -0
  184. package/dist/lower/text.mjs +21 -0
  185. package/dist/optimize/analyze-static.cjs +112 -0
  186. package/dist/optimize/analyze-static.d.cts +39 -0
  187. package/dist/optimize/analyze-static.d.ts +40 -0
  188. package/dist/optimize/analyze-static.d.ts.map +1 -0
  189. package/dist/optimize/analyze-static.js +131 -0
  190. package/dist/optimize/analyze-static.mjs +91 -0
  191. package/dist/optimize/collapse-strategies.cjs +90 -0
  192. package/dist/optimize/collapse-strategies.d.cts +30 -0
  193. package/dist/optimize/collapse-strategies.d.ts +31 -0
  194. package/dist/optimize/collapse-strategies.d.ts.map +1 -0
  195. package/dist/optimize/collapse-strategies.js +33 -0
  196. package/dist/optimize/collapse-strategies.mjs +67 -0
  197. package/dist/options.cjs +33 -0
  198. package/dist/options.d.cts +39 -0
  199. package/dist/options.d.ts +40 -0
  200. package/dist/options.d.ts.map +1 -0
  201. package/dist/options.js +8 -0
  202. package/dist/options.mjs +12 -0
  203. package/dist/resolve/builtins.cjs +73 -0
  204. package/dist/resolve/builtins.d.cts +68 -0
  205. package/dist/resolve/builtins.d.ts +69 -0
  206. package/dist/resolve/builtins.d.ts.map +1 -0
  207. package/dist/resolve/builtins.js +64 -0
  208. package/dist/resolve/builtins.mjs +53 -0
  209. package/dist/resolve/component-globals.cjs +272 -0
  210. package/dist/resolve/component-globals.d.cts +88 -0
  211. package/dist/resolve/component-globals.d.ts +89 -0
  212. package/dist/resolve/component-globals.d.ts.map +1 -0
  213. package/dist/resolve/component-globals.js +160 -0
  214. package/dist/resolve/component-globals.mjs +249 -0
  215. package/dist/resolve/component-resolver.cjs +80 -0
  216. package/dist/resolve/component-resolver.d.cts +68 -0
  217. package/dist/resolve/component-resolver.d.ts +69 -0
  218. package/dist/resolve/component-resolver.d.ts.map +1 -0
  219. package/dist/resolve/component-resolver.js +95 -0
  220. package/dist/resolve/component-resolver.mjs +59 -0
  221. package/dist/resolve/load-directive.cjs +93 -0
  222. package/dist/resolve/load-directive.d.cts +53 -0
  223. package/dist/resolve/load-directive.d.ts +54 -0
  224. package/dist/resolve/load-directive.d.ts.map +1 -0
  225. package/dist/resolve/load-directive.js +93 -0
  226. package/dist/resolve/load-directive.mjs +72 -0
  227. package/dist/resolve/resolve-ir.cjs +108 -0
  228. package/dist/resolve/resolve-ir.d.cts +53 -0
  229. package/dist/resolve/resolve-ir.d.ts +54 -0
  230. package/dist/resolve/resolve-ir.d.ts.map +1 -0
  231. package/dist/resolve/resolve-ir.js +58 -0
  232. package/dist/resolve/resolve-ir.mjs +85 -0
  233. package/dist/resolve/write-globals.cjs +383 -0
  234. package/dist/resolve/write-globals.d.cts +36 -0
  235. package/dist/resolve/write-globals.d.ts +37 -0
  236. package/dist/resolve/write-globals.d.ts.map +1 -0
  237. package/dist/resolve/write-globals.js +169 -0
  238. package/dist/resolve/write-globals.mjs +362 -0
  239. package/dist/server-fns-VZLHMQTC.mjs +79 -0
  240. package/dist/server-functions-UAZKOLZW.mjs +82 -0
  241. package/dist/transform/bindings.cjs +71 -0
  242. package/dist/transform/bindings.d.cts +16 -0
  243. package/dist/transform/bindings.d.ts +17 -0
  244. package/dist/transform/bindings.d.ts.map +1 -0
  245. package/dist/transform/bindings.js +69 -0
  246. package/dist/transform/bindings.mjs +50 -0
  247. package/dist/transform/index.cjs +3837 -0
  248. package/dist/transform/index.d.cts +15 -0
  249. package/dist/transform/index.d.ts +16 -0
  250. package/dist/transform/index.d.ts.map +1 -0
  251. package/dist/transform/index.js +12 -0
  252. package/dist/transform/index.mjs +4882 -0
  253. package/dist/transform/intrinsics.cjs +261 -0
  254. package/dist/transform/intrinsics.d.cts +33 -0
  255. package/dist/transform/intrinsics.d.ts +34 -0
  256. package/dist/transform/intrinsics.d.ts.map +1 -0
  257. package/dist/transform/intrinsics.js +120 -0
  258. package/dist/transform/intrinsics.mjs +238 -0
  259. package/dist/transform/props.cjs +441 -0
  260. package/dist/transform/props.d.cts +45 -0
  261. package/dist/transform/props.d.ts +46 -0
  262. package/dist/transform/props.d.ts.map +1 -0
  263. package/dist/transform/props.js +221 -0
  264. package/dist/transform/props.mjs +1487 -0
  265. package/dist/transform/server-fn-id.cjs +35 -0
  266. package/dist/transform/server-fn-id.d.cts +9 -0
  267. package/dist/transform/server-fn-id.d.ts +10 -0
  268. package/dist/transform/server-fn-id.d.ts.map +1 -0
  269. package/dist/transform/server-fn-id.js +18 -0
  270. package/dist/transform/server-fn-id.mjs +14 -0
  271. package/dist/transform/server-fns.cjs +114 -0
  272. package/dist/transform/server-fns.d.cts +12 -0
  273. package/dist/transform/server-fns.d.ts +13 -0
  274. package/dist/transform/server-fns.d.ts.map +1 -0
  275. package/dist/transform/server-fns.js +94 -0
  276. package/dist/transform/server-fns.mjs +1160 -0
  277. package/dist/transform/source-locations.cjs +393 -0
  278. package/dist/transform/source-locations.d.cts +48 -0
  279. package/dist/transform/source-locations.d.ts +49 -0
  280. package/dist/transform/source-locations.d.ts.map +1 -0
  281. package/dist/transform/source-locations.js +303 -0
  282. package/dist/transform/source-locations.mjs +370 -0
  283. package/dist/transform/styles.cjs +606 -0
  284. package/dist/transform/styles.d.cts +237 -0
  285. package/dist/transform/styles.d.ts +238 -0
  286. package/dist/transform/styles.d.ts.map +1 -0
  287. package/dist/transform/styles.js +743 -0
  288. package/dist/transform/styles.mjs +671 -0
  289. package/dist/transform/templates.cjs +3806 -0
  290. package/dist/transform/templates.d.cts +82 -0
  291. package/dist/transform/templates.d.ts +83 -0
  292. package/dist/transform/templates.d.ts.map +1 -0
  293. package/dist/transform/templates.js +613 -0
  294. package/dist/transform/templates.mjs +4852 -0
  295. package/dist/transform-3W45L3EA.mjs +951 -0
  296. package/dist/tsconfig.lib.tsbuildinfo +1 -0
  297. package/dist/vite-styles.cjs +223 -0
  298. package/dist/vite-styles.d.cts +68 -0
  299. package/dist/vite-styles.d.ts +69 -0
  300. package/dist/vite-styles.d.ts.map +1 -0
  301. package/dist/vite-styles.js +241 -0
  302. package/dist/vite-styles.mjs +214 -0
  303. package/package.json +141 -0
@@ -0,0 +1,261 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/transform/intrinsics.ts
21
+ var intrinsics_exports = {};
22
+ __export(intrinsics_exports, {
23
+ avoidBindingClashes: () => avoidBindingClashes,
24
+ collectIntrinsicEdits: () => collectIntrinsicEdits,
25
+ intrinsicImports: () => intrinsicImports
26
+ });
27
+ module.exports = __toCommonJS(intrinsics_exports);
28
+
29
+ // src/analyze/intrinsics.ts
30
+ var REACTIVE_MODULE = "@fluixi/reactive/signal";
31
+ var INTRINSICS = {
32
+ $signal: { export: "signal", module: REACTIVE_MODULE, returns: "signal-handle" },
33
+ $memo: { export: "memo", module: REACTIVE_MODULE, returns: "memo-handle" },
34
+ $effect: { export: "effect", module: REACTIVE_MODULE, returns: "effect" },
35
+ $store: { export: "store", module: "@fluixi/reactive/store", returns: "store-handle" },
36
+ $resource: { export: "resource", module: REACTIVE_MODULE, returns: "resource-handle" },
37
+ $cachedResource: { export: "cachedResource", module: "@fluixi/reactive/cached-resource", returns: "resource-handle" },
38
+ // No short runtime form for these yet, so the intrinsic stands for the `create*`
39
+ // name. Still worth having: no import to write, and when a shorter form is
40
+ // designed, the change is this line rather than a compiler pass.
41
+ $selector: { export: "createSelector", module: REACTIVE_MODULE, returns: "memo-accessor" },
42
+ $deferred: { export: "createDeferred", module: REACTIVE_MODULE, returns: "memo-accessor" },
43
+ // Not value constructors, but the compiler has to know them: they change what a read
44
+ // does. `untrack` suppresses dependency collection, which is exactly the kind of thing
45
+ // dependency analysis must not guess at.
46
+ $untrack: { export: "untrack", module: REACTIVE_MODULE, returns: "plain" },
47
+ $untrackStore: { export: "untrackStore", module: "@fluixi/reactive/store", returns: "plain" },
48
+ // Scopes, scheduling and lifecycle: no value to classify, but the same authoring promise,
49
+ // no import to write. `$cleanup` registers a callback on the current owner (`onCleanup`).
50
+ $batch: { export: "batch", module: REACTIVE_MODULE, returns: "plain" },
51
+ $cleanup: { export: "onCleanup", module: REACTIVE_MODULE, returns: "plain" },
52
+ $root: { export: "root", module: REACTIVE_MODULE, returns: "plain" },
53
+ $context: { export: "context", module: REACTIVE_MODULE, returns: "plain" },
54
+ $renderEffect: { export: "renderEffect", module: REACTIVE_MODULE, returns: "effect" },
55
+ $computed: { export: "computed", module: REACTIVE_MODULE, returns: "effect" },
56
+ // Storage for where the code runs, and a signal kept in it. `$persisted` is a signal
57
+ // handle as far as reads go: the same accessor with `set` on it.
58
+ $storage: { export: "useStorage", module: "@fluixi/core/storage", returns: "plain" },
59
+ $asyncStorage: { export: "useAsyncStorage", module: "@fluixi/core/storage", returns: "plain" },
60
+ $persisted: { export: "persisted", module: "@fluixi/core/storage", returns: "signal-handle" },
61
+ // An environment variable, public or server-only; the browser build refuses a secret.
62
+ $env: { export: "env", module: "@fluixi/start/env", returns: "plain" }
63
+ };
64
+ var RUNTIME_PRIMITIVES = {
65
+ signal: "signal-handle",
66
+ memo: "memo-handle",
67
+ effect: "effect",
68
+ store: "store-handle",
69
+ createSignal: ["signal-accessor", "signal-setter"],
70
+ createMemo: "memo-accessor",
71
+ createEffect: "effect",
72
+ createRenderEffect: "effect",
73
+ renderEffect: "effect",
74
+ computed: "effect",
75
+ createStore: "reactive-object",
76
+ resource: "resource-handle",
77
+ cachedResource: "resource-handle",
78
+ createResource: "reactive-object",
79
+ createSelector: "memo-accessor",
80
+ createDeferred: "memo-accessor"
81
+ };
82
+ var PRIMITIVE_MODULES = [
83
+ "@fluixi/reactive",
84
+ "@fluixi/reactive/signal",
85
+ "@fluixi/reactive/store",
86
+ "@fluixi/reactive/cached-resource",
87
+ "@fluixi/core"
88
+ ];
89
+ var INTRINSIC_CALL = new RegExp(`\\$(?:${Object.keys(INTRINSICS).map((n) => n.slice(1)).join("|")})\\s*\\(`);
90
+ function isIntrinsicName(name) {
91
+ return Object.prototype.hasOwnProperty.call(INTRINSICS, name);
92
+ }
93
+ function isPrimitiveModule(source) {
94
+ return PRIMITIVE_MODULES.includes(source);
95
+ }
96
+
97
+ // src/analyze/reactive-bindings.ts
98
+ function patternNames(node, out) {
99
+ if (!node) return;
100
+ switch (node.type) {
101
+ case "Identifier":
102
+ out.add(node.name);
103
+ return;
104
+ case "ObjectPattern":
105
+ for (const p of node.properties ?? []) {
106
+ if (p.type === "RestElement") patternNames(p.argument, out);
107
+ else patternNames(p.value, out);
108
+ }
109
+ return;
110
+ case "ArrayPattern":
111
+ for (const e of node.elements ?? []) patternNames(e, out);
112
+ return;
113
+ case "AssignmentPattern":
114
+ patternNames(node.left, out);
115
+ return;
116
+ case "RestElement":
117
+ patternNames(node.argument, out);
118
+ return;
119
+ }
120
+ }
121
+ function walk(root, visit) {
122
+ if (!root || typeof root !== "object" || typeof root.type !== "string") return;
123
+ visit(root);
124
+ for (const key of Object.keys(root)) {
125
+ if (key === "loc" || key === "leadingComments" || key === "trailingComments") continue;
126
+ const value = root[key];
127
+ if (Array.isArray(value)) for (const item of value) walk(item, visit);
128
+ else if (value && typeof value === "object") walk(value, visit);
129
+ }
130
+ }
131
+ function calledPrimitive(node, bindings) {
132
+ if (node.type !== "CallExpression") return void 0;
133
+ const callee = node.callee;
134
+ if (callee?.type !== "Identifier") return void 0;
135
+ const name = callee.name;
136
+ const imported = bindings.primitives.get(name);
137
+ if (imported) return imported;
138
+ const intrinsic = INTRINSICS[name];
139
+ if (intrinsic && !bindings.shadowed.has(name)) return intrinsic.returns;
140
+ return void 0;
141
+ }
142
+ function classify(id, returns, kinds) {
143
+ if (Array.isArray(returns)) {
144
+ if (id.type === "ArrayPattern") {
145
+ id.elements.forEach((element, index) => {
146
+ const kind = returns[index];
147
+ if (element?.type === "Identifier" && kind) kinds.set(element.name, kind);
148
+ });
149
+ }
150
+ return;
151
+ }
152
+ if (id.type === "Identifier") kinds.set(id.name, returns);
153
+ }
154
+ function resolveReactiveBindings(program) {
155
+ const bindings = { kinds: /* @__PURE__ */ new Map(), primitives: /* @__PURE__ */ new Map(), shadowed: /* @__PURE__ */ new Set() };
156
+ const root = program;
157
+ walk(root, (node) => {
158
+ const names = /* @__PURE__ */ new Set();
159
+ if (node.type === "VariableDeclarator") patternNames(node.id, names);
160
+ else if (node.type === "FunctionDeclaration" || node.type === "ClassDeclaration") patternNames(node.id, names);
161
+ else if (node.type === "ImportDefaultSpecifier" || node.type === "ImportNamespaceSpecifier") patternNames(node.local, names);
162
+ else if (node.type === "ImportSpecifier") patternNames(node.local, names);
163
+ else if (node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression" || node.type === "FunctionDeclaration") {
164
+ for (const p of node.params ?? []) patternNames(p, names);
165
+ }
166
+ for (const name of names) if (INTRINSICS[name]) bindings.shadowed.add(name);
167
+ });
168
+ for (const statement of root.body ?? []) {
169
+ if (statement.type !== "ImportDeclaration") continue;
170
+ if (!isPrimitiveModule(statement.source?.value)) continue;
171
+ for (const specifier of statement.specifiers ?? []) {
172
+ if (specifier.type !== "ImportSpecifier") continue;
173
+ const importedNode = specifier.imported;
174
+ const imported = importedNode.type === "Identifier" ? importedNode.name : importedNode.value;
175
+ const returns = RUNTIME_PRIMITIVES[imported];
176
+ if (returns) bindings.primitives.set(specifier.local.name, returns);
177
+ }
178
+ }
179
+ walk(root, (node) => {
180
+ if (node.type !== "VariableDeclarator" || !node.init) return;
181
+ const returns = calledPrimitive(node.init, bindings);
182
+ if (returns) classify(node.id, returns, bindings.kinds);
183
+ });
184
+ return bindings;
185
+ }
186
+
187
+ // src/transform/intrinsics.ts
188
+ function walk2(root, visit) {
189
+ if (!root || typeof root !== "object" || typeof root.type !== "string") return;
190
+ visit(root);
191
+ for (const key of Object.keys(root)) {
192
+ if (key === "loc" || key === "leadingComments" || key === "trailingComments") continue;
193
+ const value = root[key];
194
+ if (Array.isArray(value)) for (const item of value) walk2(item, visit);
195
+ else if (value && typeof value === "object") walk2(value, visit);
196
+ }
197
+ }
198
+ function collectIntrinsicEdits(program) {
199
+ const edits = [];
200
+ const diagnostics = [];
201
+ const imports = /* @__PURE__ */ new Map();
202
+ const reported = /* @__PURE__ */ new Set();
203
+ const { shadowed } = resolveReactiveBindings(program);
204
+ walk2(program, (node) => {
205
+ if (node.type !== "CallExpression") return;
206
+ const callee = node.callee;
207
+ if (callee?.type !== "Identifier") return;
208
+ const name = callee.name;
209
+ if (!isIntrinsicName(name)) return;
210
+ if (shadowed.has(name)) {
211
+ if (!reported.has(name)) {
212
+ reported.add(name);
213
+ diagnostics.push({
214
+ name,
215
+ message: `${name} is reserved for the compiler, and this module binds it. The call keeps your binding's meaning; rename it to use the intrinsic.`,
216
+ start: callee.start
217
+ });
218
+ }
219
+ return;
220
+ }
221
+ const intrinsic = INTRINSICS[name];
222
+ edits.push({ start: callee.start, end: callee.end, code: intrinsic.export });
223
+ const forModule = imports.get(intrinsic.module) ?? /* @__PURE__ */ new Set();
224
+ forModule.add(intrinsic.export);
225
+ imports.set(intrinsic.module, forModule);
226
+ });
227
+ return { edits, diagnostics, imports };
228
+ }
229
+ function avoidBindingClashes(program, result, bound) {
230
+ const importedAsIs = /* @__PURE__ */ new Set();
231
+ for (const stmt of program.body ?? []) {
232
+ if (stmt.type !== "ImportDeclaration") continue;
233
+ const module2 = stmt.source.value;
234
+ for (const spec of stmt.specifiers ?? []) {
235
+ if (spec.type !== "ImportSpecifier") continue;
236
+ const imported = spec.imported.name ?? spec.imported.value;
237
+ if (imported === spec.local.name && result.imports.get(module2)?.has(imported)) {
238
+ importedAsIs.add(imported);
239
+ }
240
+ }
241
+ }
242
+ const aliases = /* @__PURE__ */ new Map();
243
+ for (const names of result.imports.values()) {
244
+ for (const name of names) if (bound.has(name) && !importedAsIs.has(name)) aliases.set(name, `__fx_${name}`);
245
+ }
246
+ if (!aliases.size) return;
247
+ for (const edit of result.edits) {
248
+ const alias = aliases.get(edit.code);
249
+ if (alias) edit.code = alias;
250
+ }
251
+ result.aliases = aliases;
252
+ }
253
+ function intrinsicImports(result, bound) {
254
+ const lines = [];
255
+ for (const [module2, names] of [...result.imports].sort(([a], [b]) => a.localeCompare(b))) {
256
+ const wanted = [...names].filter((name) => result.aliases?.has(name) || !bound.has(name)).sort().map((name) => result.aliases?.has(name) ? `${name} as ${result.aliases.get(name)}` : name);
257
+ if (wanted.length) lines.push(`import { ${wanted.join(", ")} } from ${JSON.stringify(module2)};`);
258
+ }
259
+ return lines.length ? `${lines.join("\n")}
260
+ ` : "";
261
+ }
@@ -0,0 +1,33 @@
1
+ export interface IntrinsicEdit {
2
+ start: number;
3
+ end: number;
4
+ code: string;
5
+ }
6
+ export interface IntrinsicDiagnostic {
7
+ /** The `$` name the module bound itself. */
8
+ name: string;
9
+ message: string;
10
+ start: number;
11
+ }
12
+ export interface IntrinsicsResult {
13
+ edits: IntrinsicEdit[];
14
+ diagnostics: IntrinsicDiagnostic[];
15
+ /** Runtime exports the rewritten code needs, by module. */
16
+ imports: Map<string, Set<string>>;
17
+ /** Runtime exports imported under another name, because the module binds theirs. */
18
+ aliases?: Map<string, string>;
19
+ }
20
+ /** Find the `$` calls in a module and say what they compile to. */
21
+ export declare function collectIntrinsicEdits(program: unknown): IntrinsicsResult;
22
+ /**
23
+ * Point a rewritten call past a local binding of the same name.
24
+ *
25
+ * `$env('X')` becomes `env('X')`, and the import of `env` used to be skipped when the module
26
+ * already bound `env`, on the assumption that it was the same import. A config module with its
27
+ * own `const env = {…}` is common, and there the call reached the app's object instead. Such a
28
+ * name is now imported under a private alias. A module that imports that very export from that
29
+ * very module keeps the old behaviour: the binding is the runtime already.
30
+ */
31
+ export declare function avoidBindingClashes(program: unknown, result: IntrinsicsResult, bound: Set<string>): void;
32
+ /** The import statements a result needs, minus anything the module already binds. */
33
+ export declare function intrinsicImports(result: IntrinsicsResult, bound: Set<string>): string;
@@ -0,0 +1,34 @@
1
+ export interface IntrinsicEdit {
2
+ start: number;
3
+ end: number;
4
+ code: string;
5
+ }
6
+ export interface IntrinsicDiagnostic {
7
+ /** The `$` name the module bound itself. */
8
+ name: string;
9
+ message: string;
10
+ start: number;
11
+ }
12
+ export interface IntrinsicsResult {
13
+ edits: IntrinsicEdit[];
14
+ diagnostics: IntrinsicDiagnostic[];
15
+ /** Runtime exports the rewritten code needs, by module. */
16
+ imports: Map<string, Set<string>>;
17
+ /** Runtime exports imported under another name, because the module binds theirs. */
18
+ aliases?: Map<string, string>;
19
+ }
20
+ /** Find the `$` calls in a module and say what they compile to. */
21
+ export declare function collectIntrinsicEdits(program: unknown): IntrinsicsResult;
22
+ /**
23
+ * Point a rewritten call past a local binding of the same name.
24
+ *
25
+ * `$env('X')` becomes `env('X')`, and the import of `env` used to be skipped when the module
26
+ * already bound `env`, on the assumption that it was the same import. A config module with its
27
+ * own `const env = {…}` is common, and there the call reached the app's object instead. Such a
28
+ * name is now imported under a private alias. A module that imports that very export from that
29
+ * very module keeps the old behaviour: the binding is the runtime already.
30
+ */
31
+ export declare function avoidBindingClashes(program: unknown, result: IntrinsicsResult, bound: Set<string>): void;
32
+ /** The import statements a result needs, minus anything the module already binds. */
33
+ export declare function intrinsicImports(result: IntrinsicsResult, bound: Set<string>): string;
34
+ //# sourceMappingURL=intrinsics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intrinsics.d.ts","sourceRoot":"","sources":["../../src/transform/intrinsics.ts"],"names":[],"mappings":"AAwBA,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,mBAAmB;IAClC,4CAA4C;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,aAAa,EAAE,CAAC;IACvB,WAAW,EAAE,mBAAmB,EAAE,CAAC;IACnC,2DAA2D;IAC3D,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;IAClC,oFAAoF;IACpF,OAAO,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC/B;AAaD,mEAAmE;AACnE,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,gBAAgB,CAuCxE;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,IAAI,CAwBxG;AAED,qFAAqF;AACrF,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,EAAE,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,MAAM,CAUrF"}
@@ -0,0 +1,120 @@
1
+ /**
2
+ * Compile the `$` intrinsics into the runtime calls they stand for.
3
+ *
4
+ * const [count, setCount] = $signal(0);
5
+ * → const [count, setCount] = createSignal(0); + the import
6
+ *
7
+ * Only the callee is rewritten, so arguments keep the author's text and the span stays
8
+ * put: `$signal(0)` and `createSignal(0)` map to the same place. Imports are collected
9
+ * from what the module actually used, so a file with one `$signal` gets one import.
10
+ *
11
+ * A module that binds `$signal` itself keeps its own meaning and is reported instead;
12
+ * the compiler quietly rewriting code that means something else is the one outcome
13
+ * worth failing over.
14
+ */
15
+ import { INTRINSICS, isIntrinsicName } from '../analyze/intrinsics.js';
16
+ import { resolveReactiveBindings } from '../analyze/reactive-bindings.js';
17
+ function walk(root, visit) {
18
+ if (!root || typeof root !== 'object' || typeof root.type !== 'string')
19
+ return;
20
+ visit(root);
21
+ for (const key of Object.keys(root)) {
22
+ if (key === 'loc' || key === 'leadingComments' || key === 'trailingComments')
23
+ continue;
24
+ const value = root[key];
25
+ if (Array.isArray(value))
26
+ for (const item of value)
27
+ walk(item, visit);
28
+ else if (value && typeof value === 'object')
29
+ walk(value, visit);
30
+ }
31
+ }
32
+ /** Find the `$` calls in a module and say what they compile to. */
33
+ export function collectIntrinsicEdits(program) {
34
+ const edits = [];
35
+ const diagnostics = [];
36
+ const imports = new Map();
37
+ const reported = new Set();
38
+ const { shadowed } = resolveReactiveBindings(program);
39
+ walk(program, (node) => {
40
+ if (node.type !== 'CallExpression')
41
+ return;
42
+ const callee = node.callee;
43
+ if (callee?.type !== 'Identifier')
44
+ return;
45
+ const name = callee.name;
46
+ if (!isIntrinsicName(name))
47
+ return;
48
+ if (shadowed.has(name)) {
49
+ if (!reported.has(name)) {
50
+ reported.add(name);
51
+ diagnostics.push({
52
+ name,
53
+ message: `${name} is reserved for the compiler, and this module binds it. The call keeps your binding's meaning; rename it to use the intrinsic.`,
54
+ start: callee.start,
55
+ });
56
+ }
57
+ return;
58
+ }
59
+ const intrinsic = INTRINSICS[name];
60
+ // The callee only. Arguments are untouched, so a template or JSX inside one is still
61
+ // compiled by the pass that owns it.
62
+ edits.push({ start: callee.start, end: callee.end, code: intrinsic.export });
63
+ const forModule = imports.get(intrinsic.module) ?? new Set();
64
+ forModule.add(intrinsic.export);
65
+ imports.set(intrinsic.module, forModule);
66
+ });
67
+ return { edits, diagnostics, imports };
68
+ }
69
+ /**
70
+ * Point a rewritten call past a local binding of the same name.
71
+ *
72
+ * `$env('X')` becomes `env('X')`, and the import of `env` used to be skipped when the module
73
+ * already bound `env`, on the assumption that it was the same import. A config module with its
74
+ * own `const env = {…}` is common, and there the call reached the app's object instead. Such a
75
+ * name is now imported under a private alias. A module that imports that very export from that
76
+ * very module keeps the old behaviour: the binding is the runtime already.
77
+ */
78
+ export function avoidBindingClashes(program, result, bound) {
79
+ const importedAsIs = new Set();
80
+ for (const stmt of program.body ?? []) {
81
+ if (stmt.type !== 'ImportDeclaration')
82
+ continue;
83
+ const module = stmt.source.value;
84
+ for (const spec of stmt.specifiers ?? []) {
85
+ if (spec.type !== 'ImportSpecifier')
86
+ continue;
87
+ const imported = (spec.imported.name ?? spec.imported.value);
88
+ if (imported === spec.local.name && result.imports.get(module)?.has(imported)) {
89
+ importedAsIs.add(imported);
90
+ }
91
+ }
92
+ }
93
+ const aliases = new Map();
94
+ for (const names of result.imports.values()) {
95
+ for (const name of names)
96
+ if (bound.has(name) && !importedAsIs.has(name))
97
+ aliases.set(name, `__fx_${name}`);
98
+ }
99
+ if (!aliases.size)
100
+ return;
101
+ for (const edit of result.edits) {
102
+ const alias = aliases.get(edit.code);
103
+ if (alias)
104
+ edit.code = alias;
105
+ }
106
+ result.aliases = aliases;
107
+ }
108
+ /** The import statements a result needs, minus anything the module already binds. */
109
+ export function intrinsicImports(result, bound) {
110
+ const lines = [];
111
+ for (const [module, names] of [...result.imports].sort(([a], [b]) => a.localeCompare(b))) {
112
+ const wanted = [...names]
113
+ .filter((name) => result.aliases?.has(name) || !bound.has(name))
114
+ .sort()
115
+ .map((name) => (result.aliases?.has(name) ? `${name} as ${result.aliases.get(name)}` : name));
116
+ if (wanted.length)
117
+ lines.push(`import { ${wanted.join(', ')} } from ${JSON.stringify(module)};`);
118
+ }
119
+ return lines.length ? `${lines.join('\n')}\n` : '';
120
+ }