@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,393 @@
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/source-locations.ts
21
+ var source_locations_exports = {};
22
+ __export(source_locations_exports, {
23
+ CLASS_MARKER: () => CLASS_MARKER,
24
+ COMPONENT_MARKER: () => COMPONENT_MARKER,
25
+ HOLE_MARKER: () => HOLE_MARKER,
26
+ PROPS_MARKER: () => PROPS_MARKER,
27
+ SOURCE_MARKER: () => SOURCE_MARKER,
28
+ collectSourceEdits: () => collectSourceEdits,
29
+ markHole: () => markHole,
30
+ markProps: () => markProps,
31
+ mayHaveSourceMarks: () => mayHaveSourceMarks
32
+ });
33
+ module.exports = __toCommonJS(source_locations_exports);
34
+
35
+ // src/analyze/intrinsics.ts
36
+ var REACTIVE_MODULE = "@fluixi/reactive/signal";
37
+ var INTRINSICS = {
38
+ $signal: { export: "signal", module: REACTIVE_MODULE, returns: "signal-handle" },
39
+ $memo: { export: "memo", module: REACTIVE_MODULE, returns: "memo-handle" },
40
+ $effect: { export: "effect", module: REACTIVE_MODULE, returns: "effect" },
41
+ $store: { export: "store", module: "@fluixi/reactive/store", returns: "store-handle" },
42
+ $resource: { export: "resource", module: REACTIVE_MODULE, returns: "resource-handle" },
43
+ $cachedResource: { export: "cachedResource", module: "@fluixi/reactive/cached-resource", returns: "resource-handle" },
44
+ // No short runtime form for these yet, so the intrinsic stands for the `create*`
45
+ // name. Still worth having: no import to write, and when a shorter form is
46
+ // designed, the change is this line rather than a compiler pass.
47
+ $selector: { export: "createSelector", module: REACTIVE_MODULE, returns: "memo-accessor" },
48
+ $deferred: { export: "createDeferred", module: REACTIVE_MODULE, returns: "memo-accessor" },
49
+ // Not value constructors, but the compiler has to know them: they change what a read
50
+ // does. `untrack` suppresses dependency collection, which is exactly the kind of thing
51
+ // dependency analysis must not guess at.
52
+ $untrack: { export: "untrack", module: REACTIVE_MODULE, returns: "plain" },
53
+ $untrackStore: { export: "untrackStore", module: "@fluixi/reactive/store", returns: "plain" },
54
+ // Scopes, scheduling and lifecycle: no value to classify, but the same authoring promise,
55
+ // no import to write. `$cleanup` registers a callback on the current owner (`onCleanup`).
56
+ $batch: { export: "batch", module: REACTIVE_MODULE, returns: "plain" },
57
+ $cleanup: { export: "onCleanup", module: REACTIVE_MODULE, returns: "plain" },
58
+ $root: { export: "root", module: REACTIVE_MODULE, returns: "plain" },
59
+ $context: { export: "context", module: REACTIVE_MODULE, returns: "plain" },
60
+ $renderEffect: { export: "renderEffect", module: REACTIVE_MODULE, returns: "effect" },
61
+ $computed: { export: "computed", module: REACTIVE_MODULE, returns: "effect" },
62
+ // Storage for where the code runs, and a signal kept in it. `$persisted` is a signal
63
+ // handle as far as reads go: the same accessor with `set` on it.
64
+ $storage: { export: "useStorage", module: "@fluixi/core/storage", returns: "plain" },
65
+ $asyncStorage: { export: "useAsyncStorage", module: "@fluixi/core/storage", returns: "plain" },
66
+ $persisted: { export: "persisted", module: "@fluixi/core/storage", returns: "signal-handle" },
67
+ // An environment variable, public or server-only; the browser build refuses a secret.
68
+ $env: { export: "env", module: "@fluixi/start/env", returns: "plain" }
69
+ };
70
+ var RUNTIME_PRIMITIVES = {
71
+ signal: "signal-handle",
72
+ memo: "memo-handle",
73
+ effect: "effect",
74
+ store: "store-handle",
75
+ createSignal: ["signal-accessor", "signal-setter"],
76
+ createMemo: "memo-accessor",
77
+ createEffect: "effect",
78
+ createRenderEffect: "effect",
79
+ renderEffect: "effect",
80
+ computed: "effect",
81
+ createStore: "reactive-object",
82
+ resource: "resource-handle",
83
+ cachedResource: "resource-handle",
84
+ createResource: "reactive-object",
85
+ createSelector: "memo-accessor",
86
+ createDeferred: "memo-accessor"
87
+ };
88
+ var PRIMITIVE_MODULES = [
89
+ "@fluixi/reactive",
90
+ "@fluixi/reactive/signal",
91
+ "@fluixi/reactive/store",
92
+ "@fluixi/reactive/cached-resource",
93
+ "@fluixi/core"
94
+ ];
95
+ var INTRINSIC_CALL = new RegExp(`\\$(?:${Object.keys(INTRINSICS).map((n) => n.slice(1)).join("|")})\\s*\\(`);
96
+ function isIntrinsicName(name) {
97
+ return Object.prototype.hasOwnProperty.call(INTRINSICS, name);
98
+ }
99
+ function isPrimitiveModule(source) {
100
+ return PRIMITIVE_MODULES.includes(source);
101
+ }
102
+
103
+ // src/analyze/reactive-bindings.ts
104
+ function patternNames(node, out) {
105
+ if (!node) return;
106
+ switch (node.type) {
107
+ case "Identifier":
108
+ out.add(node.name);
109
+ return;
110
+ case "ObjectPattern":
111
+ for (const p of node.properties ?? []) {
112
+ if (p.type === "RestElement") patternNames(p.argument, out);
113
+ else patternNames(p.value, out);
114
+ }
115
+ return;
116
+ case "ArrayPattern":
117
+ for (const e of node.elements ?? []) patternNames(e, out);
118
+ return;
119
+ case "AssignmentPattern":
120
+ patternNames(node.left, out);
121
+ return;
122
+ case "RestElement":
123
+ patternNames(node.argument, out);
124
+ return;
125
+ }
126
+ }
127
+ function walk(root, visit) {
128
+ if (!root || typeof root !== "object" || typeof root.type !== "string") return;
129
+ visit(root);
130
+ for (const key of Object.keys(root)) {
131
+ if (key === "loc" || key === "leadingComments" || key === "trailingComments") continue;
132
+ const value = root[key];
133
+ if (Array.isArray(value)) for (const item of value) walk(item, visit);
134
+ else if (value && typeof value === "object") walk(value, visit);
135
+ }
136
+ }
137
+ function calledPrimitive(node, bindings) {
138
+ if (node.type !== "CallExpression") return void 0;
139
+ const callee = node.callee;
140
+ if (callee?.type !== "Identifier") return void 0;
141
+ const name = callee.name;
142
+ const imported = bindings.primitives.get(name);
143
+ if (imported) return imported;
144
+ const intrinsic = INTRINSICS[name];
145
+ if (intrinsic && !bindings.shadowed.has(name)) return intrinsic.returns;
146
+ return void 0;
147
+ }
148
+ function classify(id, returns, kinds) {
149
+ if (Array.isArray(returns)) {
150
+ if (id.type === "ArrayPattern") {
151
+ id.elements.forEach((element, index) => {
152
+ const kind = returns[index];
153
+ if (element?.type === "Identifier" && kind) kinds.set(element.name, kind);
154
+ });
155
+ }
156
+ return;
157
+ }
158
+ if (id.type === "Identifier") kinds.set(id.name, returns);
159
+ }
160
+ function resolveReactiveBindings(program) {
161
+ const bindings = { kinds: /* @__PURE__ */ new Map(), primitives: /* @__PURE__ */ new Map(), shadowed: /* @__PURE__ */ new Set() };
162
+ const root = program;
163
+ walk(root, (node) => {
164
+ const names = /* @__PURE__ */ new Set();
165
+ if (node.type === "VariableDeclarator") patternNames(node.id, names);
166
+ else if (node.type === "FunctionDeclaration" || node.type === "ClassDeclaration") patternNames(node.id, names);
167
+ else if (node.type === "ImportDefaultSpecifier" || node.type === "ImportNamespaceSpecifier") patternNames(node.local, names);
168
+ else if (node.type === "ImportSpecifier") patternNames(node.local, names);
169
+ else if (node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression" || node.type === "FunctionDeclaration") {
170
+ for (const p of node.params ?? []) patternNames(p, names);
171
+ }
172
+ for (const name of names) if (INTRINSICS[name]) bindings.shadowed.add(name);
173
+ });
174
+ for (const statement of root.body ?? []) {
175
+ if (statement.type !== "ImportDeclaration") continue;
176
+ if (!isPrimitiveModule(statement.source?.value)) continue;
177
+ for (const specifier of statement.specifiers ?? []) {
178
+ if (specifier.type !== "ImportSpecifier") continue;
179
+ const importedNode = specifier.imported;
180
+ const imported = importedNode.type === "Identifier" ? importedNode.name : importedNode.value;
181
+ const returns = RUNTIME_PRIMITIVES[imported];
182
+ if (returns) bindings.primitives.set(specifier.local.name, returns);
183
+ }
184
+ }
185
+ walk(root, (node) => {
186
+ if (node.type !== "VariableDeclarator" || !node.init) return;
187
+ const returns = calledPrimitive(node.init, bindings);
188
+ if (returns) classify(node.id, returns, bindings.kinds);
189
+ });
190
+ return bindings;
191
+ }
192
+
193
+ // src/transform/source-locations.ts
194
+ var SOURCE_MARKER = "__fx_source";
195
+ var COMPONENT_MARKER = "__fx_component";
196
+ var CLASS_MARKER = "__fx_class";
197
+ var HOLE_MARKER = "__fx_hole";
198
+ var markHole = (accessor, line, column, name) => `(globalThis.${HOLE_MARKER} ?? ((f) => f))(${accessor},${line},${column}${name === void 0 ? "" : `,${JSON.stringify(name)}`})`;
199
+ var PROPS_MARKER = "__fx_props";
200
+ var markProps = (object, at) => `(globalThis.${PROPS_MARKER} ?? ((p) => p))(${object},${JSON.stringify(at)})`;
201
+ var RUNTIME_PRIMITIVES2 = /* @__PURE__ */ new Set([
202
+ "signal",
203
+ "memo",
204
+ "effect",
205
+ "store",
206
+ "resource",
207
+ "watch",
208
+ "createSignal",
209
+ "createMemo",
210
+ "createEffect",
211
+ "createStore",
212
+ "createResource"
213
+ ]);
214
+ function mayHaveSourceMarks(code) {
215
+ for (const name of RUNTIME_PRIMITIVES2) {
216
+ if (code.includes(name)) return true;
217
+ }
218
+ if (code.includes("$signal") || code.includes("$memo") || code.includes("$effect") || code.includes("$store")) return true;
219
+ return /\bclass\b[^{;]*\bextends\b/.test(code);
220
+ }
221
+ var SINGLE_STATEMENT_PARENTS = /* @__PURE__ */ new Set([
222
+ "IfStatement",
223
+ "ForStatement",
224
+ "ForInStatement",
225
+ "ForOfStatement",
226
+ "WhileStatement",
227
+ "DoWhileStatement",
228
+ "LabeledStatement",
229
+ "WithStatement"
230
+ ]);
231
+ function isLoneBranch(statement, parent) {
232
+ if (!parent || statement.type === "BlockStatement") return false;
233
+ return SINGLE_STATEMENT_PARENTS.has(parent.type);
234
+ }
235
+ function isExport(node) {
236
+ return node.type === "ExportNamedDeclaration" || node.type === "ExportDefaultDeclaration";
237
+ }
238
+ var CLASS_FIELDS = /* @__PURE__ */ new Set(["PropertyDefinition", "ClassProperty", "ClassPrivateProperty", "AccessorProperty"]);
239
+ function isStatement(node) {
240
+ return node.type.endsWith("Statement") || node.type === "VariableDeclaration";
241
+ }
242
+ function walk2(node, visit, stack = []) {
243
+ if (!node || typeof node.type !== "string") return;
244
+ visit(node, stack);
245
+ stack.push(node);
246
+ for (const key of Object.keys(node)) {
247
+ if (key === "loc" || key === "parent") continue;
248
+ const value = node[key];
249
+ if (Array.isArray(value)) {
250
+ for (const child of value) walk2(child, visit, stack);
251
+ } else if (value && typeof value.type === "string") {
252
+ walk2(value, visit, stack);
253
+ }
254
+ }
255
+ stack.pop();
256
+ }
257
+ function nameFor(stack) {
258
+ const declarator = stack[stack.length - 1];
259
+ if (declarator && CLASS_FIELDS.has(declarator.type)) {
260
+ const key = declarator.key;
261
+ if (key?.type === "Identifier" || key?.type === "PrivateIdentifier" || key?.type === "PrivateName") {
262
+ const name = key.name ?? key.id?.name;
263
+ return name;
264
+ }
265
+ return void 0;
266
+ }
267
+ if (declarator?.type !== "VariableDeclarator") return void 0;
268
+ const id = declarator.id;
269
+ if (id?.type === "Identifier") return id.name;
270
+ if (id?.type === "ArrayPattern") {
271
+ const first = id.elements?.[0];
272
+ if (first?.type === "Identifier") return first.name;
273
+ }
274
+ return void 0;
275
+ }
276
+ function componentName(node) {
277
+ if (node.type === "FunctionDeclaration") {
278
+ const name = node.id?.name;
279
+ return name && name[0] === name[0]?.toUpperCase() ? name : void 0;
280
+ }
281
+ if (node.type === "VariableDeclarator") {
282
+ const id = node.id;
283
+ const init = node.init;
284
+ if (id?.type !== "Identifier" || !init) return void 0;
285
+ if (init.type !== "ArrowFunctionExpression" && init.type !== "FunctionExpression") return void 0;
286
+ const name = id.name;
287
+ return name[0] === name[0]?.toUpperCase() ? name : void 0;
288
+ }
289
+ return void 0;
290
+ }
291
+ function collectSourceEdits(program, filename) {
292
+ const edits = [];
293
+ const claimed = /* @__PURE__ */ new Set();
294
+ const { primitives, shadowed } = resolveReactiveBindings(program);
295
+ walk2(program, (node, stack) => {
296
+ const component = componentName(node);
297
+ if (component) {
298
+ const at = node.loc?.start;
299
+ let end2 = node.end;
300
+ for (let i = stack.length - 1; i >= 0; i--) {
301
+ const up = stack[i];
302
+ if (up.type !== "VariableDeclaration" && up.type !== "ExportNamedDeclaration" && up.type !== "ExportDefaultDeclaration") {
303
+ break;
304
+ }
305
+ end2 = up.end;
306
+ }
307
+ if (at) {
308
+ edits.push({
309
+ start: end2,
310
+ end: end2,
311
+ code: `;globalThis.${COMPONENT_MARKER}?.(${JSON.stringify(component)},${JSON.stringify(filename)},${at.line},${at.column});`
312
+ });
313
+ }
314
+ }
315
+ if ((node.type === "ClassDeclaration" || node.type === "ClassExpression") && node.superClass && !node.declare) {
316
+ const at = node.loc?.start;
317
+ const body = node.body;
318
+ if (at && body) {
319
+ edits.push({
320
+ start: body.start + 1,
321
+ end: body.start + 1,
322
+ code: `static{globalThis.${CLASS_MARKER}?.(this,${JSON.stringify(filename)},${at.line},${at.column});}`
323
+ });
324
+ }
325
+ }
326
+ if (node.type !== "CallExpression") return;
327
+ const callee = node.callee;
328
+ if (callee?.type !== "Identifier") return;
329
+ const name = callee.name;
330
+ const intrinsic = isIntrinsicName(name) && !shadowed.has(name) ? INTRINSICS[name] : void 0;
331
+ const imported = primitives.has(name) || RUNTIME_PRIMITIVES2.has(name);
332
+ if (!intrinsic && !imported) return;
333
+ const position = node.loc?.start;
334
+ if (!position) return;
335
+ for (let i = stack.length - 1; i >= 0; i--) {
336
+ const up = stack[i];
337
+ if (isStatement(up)) break;
338
+ if (CLASS_FIELDS.has(up.type)) {
339
+ if (claimed.has(node.start)) return;
340
+ claimed.add(node.start);
341
+ const label2 = nameFor(stack);
342
+ const own = !up.static;
343
+ const args2 = [
344
+ JSON.stringify(filename),
345
+ String(position.line),
346
+ String(position.column),
347
+ label2 ? JSON.stringify(label2) : own ? "undefined" : void 0,
348
+ own ? "this" : void 0
349
+ ].filter((a) => a !== void 0).join(",");
350
+ edits.push({ start: node.start, end: node.start, code: `(globalThis.${SOURCE_MARKER}?.(${args2}),` });
351
+ edits.push({ start: node.end, end: node.end, code: ")" });
352
+ return;
353
+ }
354
+ }
355
+ let statement;
356
+ let parent;
357
+ let index = -1;
358
+ for (let i = stack.length - 1; i >= 0; i--) {
359
+ if (isStatement(stack[i]) || isExport(stack[i])) {
360
+ statement = stack[i];
361
+ parent = stack[i - 1];
362
+ index = i;
363
+ break;
364
+ }
365
+ }
366
+ if (!statement) return;
367
+ let start = statement.start;
368
+ let end = statement.end;
369
+ for (let i = index - 1; i >= 0; i--) {
370
+ if (!isExport(stack[i])) break;
371
+ start = stack[i].start;
372
+ end = stack[i].end;
373
+ parent = stack[i - 1];
374
+ }
375
+ if (claimed.has(start)) return;
376
+ claimed.add(start);
377
+ const label = nameFor(stack);
378
+ const args = [
379
+ JSON.stringify(filename),
380
+ String(position.line),
381
+ String(position.column),
382
+ label ? JSON.stringify(label) : void 0
383
+ ].filter((a) => a !== void 0).join(",");
384
+ const mark = `globalThis.${SOURCE_MARKER}?.(${args});`;
385
+ if (isLoneBranch(statement, parent)) {
386
+ edits.push({ start, end: start, code: `{${mark}` });
387
+ edits.push({ start: end, end, code: "}" });
388
+ return;
389
+ }
390
+ edits.push({ start, end: start, code: mark });
391
+ });
392
+ return { edits, marked: edits.length };
393
+ }
@@ -0,0 +1,48 @@
1
+ export interface SourceEdit {
2
+ start: number;
3
+ end: number;
4
+ code: string;
5
+ }
6
+ export interface SourceLocationsResult {
7
+ edits: SourceEdit[];
8
+ /** How many creation sites were marked. */
9
+ marked: number;
10
+ }
11
+ /** Installed by @fluixi/devtools; undefined everywhere else. */
12
+ export declare const SOURCE_MARKER = "__fx_source";
13
+ /** Where a component was declared. Keyed by name, since that is all the runtime carries. */
14
+ export declare const COMPONENT_MARKER = "__fx_component";
15
+ /**
16
+ * Where a class that extends another was declared, keyed by the class itself: a custom
17
+ * element's definition, which the runtime can only reach through `element.constructor`.
18
+ */
19
+ export declare const CLASS_MARKER = "__fx_class";
20
+ /**
21
+ * Where one reactive hole was written. This one wraps: the position has to travel with the
22
+ * accessor to wherever the dom wires it up. A template is emitted as one overwrite, so the
23
+ * source map has a single entry for the root and every hole traces back to it.
24
+ *
25
+ * `?? (f => f)` and not `?.()`: the value is the accessor, and returning undefined would
26
+ * delete the binding.
27
+ */
28
+ export declare const HOLE_MARKER = "__fx_hole";
29
+ /**
30
+ * `_(() => x(), 9, 25)`, or the accessor untouched when nothing is watching.
31
+ *
32
+ * `name` is the source text the value came from, for a `ref` where knowing which variable
33
+ * holds the element is the whole question.
34
+ */
35
+ export declare const markHole: (accessor: string, line: number, column: number, name?: string) => string;
36
+ /**
37
+ * Where each prop of a component tag was written.
38
+ *
39
+ * The props object is built as getters, so nothing in it can carry a position of its own.
40
+ * The marker takes the object and a name-to-position map, and hands the object straight
41
+ * back: devtools keeps the map, and a build without it passes the object through.
42
+ */
43
+ export declare const PROPS_MARKER = "__fx_props";
44
+ /** `_({ get a() {…} }, {"a":[9,25]})`, or the object untouched when nothing is watching. */
45
+ export declare const markProps: (object: string, at: Record<string, [number, number]>) => string;
46
+ /** Whether a module has anything to mark: a primitive call or a subclass. Cheap enough to run before parsing. */
47
+ export declare function mayHaveSourceMarks(code: string): boolean;
48
+ export declare function collectSourceEdits(program: unknown, filename: string): SourceLocationsResult;
@@ -0,0 +1,49 @@
1
+ export interface SourceEdit {
2
+ start: number;
3
+ end: number;
4
+ code: string;
5
+ }
6
+ export interface SourceLocationsResult {
7
+ edits: SourceEdit[];
8
+ /** How many creation sites were marked. */
9
+ marked: number;
10
+ }
11
+ /** Installed by @fluixi/devtools; undefined everywhere else. */
12
+ export declare const SOURCE_MARKER = "__fx_source";
13
+ /** Where a component was declared. Keyed by name, since that is all the runtime carries. */
14
+ export declare const COMPONENT_MARKER = "__fx_component";
15
+ /**
16
+ * Where a class that extends another was declared, keyed by the class itself: a custom
17
+ * element's definition, which the runtime can only reach through `element.constructor`.
18
+ */
19
+ export declare const CLASS_MARKER = "__fx_class";
20
+ /**
21
+ * Where one reactive hole was written. This one wraps: the position has to travel with the
22
+ * accessor to wherever the dom wires it up. A template is emitted as one overwrite, so the
23
+ * source map has a single entry for the root and every hole traces back to it.
24
+ *
25
+ * `?? (f => f)` and not `?.()`: the value is the accessor, and returning undefined would
26
+ * delete the binding.
27
+ */
28
+ export declare const HOLE_MARKER = "__fx_hole";
29
+ /**
30
+ * `_(() => x(), 9, 25)`, or the accessor untouched when nothing is watching.
31
+ *
32
+ * `name` is the source text the value came from, for a `ref` where knowing which variable
33
+ * holds the element is the whole question.
34
+ */
35
+ export declare const markHole: (accessor: string, line: number, column: number, name?: string) => string;
36
+ /**
37
+ * Where each prop of a component tag was written.
38
+ *
39
+ * The props object is built as getters, so nothing in it can carry a position of its own.
40
+ * The marker takes the object and a name-to-position map, and hands the object straight
41
+ * back: devtools keeps the map, and a build without it passes the object through.
42
+ */
43
+ export declare const PROPS_MARKER = "__fx_props";
44
+ /** `_({ get a() {…} }, {"a":[9,25]})`, or the object untouched when nothing is watching. */
45
+ export declare const markProps: (object: string, at: Record<string, [number, number]>) => string;
46
+ /** Whether a module has anything to mark: a primitive call or a subclass. Cheap enough to run before parsing. */
47
+ export declare function mayHaveSourceMarks(code: string): boolean;
48
+ export declare function collectSourceEdits(program: unknown, filename: string): SourceLocationsResult;
49
+ //# sourceMappingURL=source-locations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source-locations.d.ts","sourceRoot":"","sources":["../../src/transform/source-locations.ts"],"names":[],"mappings":"AA6BA,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,2CAA2C;IAC3C,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,gEAAgE;AAChE,eAAO,MAAM,aAAa,gBAAgB,CAAC;AAE3C,4FAA4F;AAC5F,eAAO,MAAM,gBAAgB,mBAAmB,CAAC;AAEjD;;;GAGG;AACH,eAAO,MAAM,YAAY,eAAe,CAAC;AAEzC;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,cAAc,CAAC;AAEvC;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GACnB,UAAU,MAAM,EAChB,MAAM,MAAM,EACZ,QAAQ,MAAM,EACd,OAAO,MAAM,KACZ,MAGE,CAAC;AAEN;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,eAAe,CAAC;AAEzC,4FAA4F;AAC5F,eAAO,MAAM,SAAS,GAAI,QAAQ,MAAM,EAAE,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,KAAG,MACF,CAAC;AAQhF,iHAAiH;AACjH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAOxD;AAmFD,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,qBAAqB,CA6J5F"}