@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,42 @@
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/lower/text.ts
21
+ var text_exports = {};
22
+ __export(text_exports, {
23
+ cleanTemplateText: () => cleanTemplateText
24
+ });
25
+ module.exports = __toCommonJS(text_exports);
26
+ function cleanTemplateText(value) {
27
+ const lines = value.split(/\r\n|\n|\r/);
28
+ let lastNonEmpty = 0;
29
+ for (let i = 0; i < lines.length; i++) {
30
+ if (/[^ \t]/.test(lines[i])) lastNonEmpty = i;
31
+ }
32
+ let out = "";
33
+ for (let i = 0; i < lines.length; i++) {
34
+ let line = lines[i].replace(/\t/g, " ");
35
+ if (i !== 0) line = line.replace(/^ +/, "");
36
+ if (i !== lines.length - 1) line = line.replace(/ +$/, "");
37
+ if (!line) continue;
38
+ if (i !== lastNonEmpty) line += " ";
39
+ out += line;
40
+ }
41
+ return out;
42
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Whitespace handling for template text runs.
3
+ *
4
+ * JSX and `` html`...` `` collapse a text run the same way, the rule came from
5
+ * JSX and the template syntax adopted it so an author moving between the two
6
+ * gets the same output. It is pure string work with no parser in it, so it lives
7
+ * here rather than in a front-end, where both can reach it and neither owns it.
8
+ */
9
+ /** Canonical JSX text cleaning: kept identical to plugin.ts cleanTemplateText. */
10
+ export declare function cleanTemplateText(value: string): string;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Whitespace handling for template text runs.
3
+ *
4
+ * JSX and `` html`...` `` collapse a text run the same way, the rule came from
5
+ * JSX and the template syntax adopted it so an author moving between the two
6
+ * gets the same output. It is pure string work with no parser in it, so it lives
7
+ * here rather than in a front-end, where both can reach it and neither owns it.
8
+ */
9
+ /** Canonical JSX text cleaning: kept identical to plugin.ts cleanTemplateText. */
10
+ export declare function cleanTemplateText(value: string): string;
11
+ //# sourceMappingURL=text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/lower/text.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,kFAAkF;AAClF,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAgBvD"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Whitespace handling for template text runs.
3
+ *
4
+ * JSX and `` html`...` `` collapse a text run the same way, the rule came from
5
+ * JSX and the template syntax adopted it so an author moving between the two
6
+ * gets the same output. It is pure string work with no parser in it, so it lives
7
+ * here rather than in a front-end, where both can reach it and neither owns it.
8
+ */
9
+ /** Canonical JSX text cleaning: kept identical to plugin.ts cleanTemplateText. */
10
+ export function cleanTemplateText(value) {
11
+ const lines = value.split(/\r\n|\n|\r/);
12
+ let lastNonEmpty = 0;
13
+ for (let i = 0; i < lines.length; i++) {
14
+ if (/[^ \t]/.test(lines[i]))
15
+ lastNonEmpty = i;
16
+ }
17
+ let out = '';
18
+ for (let i = 0; i < lines.length; i++) {
19
+ let line = lines[i].replace(/\t/g, ' ');
20
+ if (i !== 0)
21
+ line = line.replace(/^ +/, '');
22
+ if (i !== lines.length - 1)
23
+ line = line.replace(/ +$/, '');
24
+ if (!line)
25
+ continue;
26
+ if (i !== lastNonEmpty)
27
+ line += ' ';
28
+ out += line;
29
+ }
30
+ return out;
31
+ }
@@ -0,0 +1,21 @@
1
+ // src/lower/text.ts
2
+ function cleanTemplateText(value) {
3
+ const lines = value.split(/\r\n|\n|\r/);
4
+ let lastNonEmpty = 0;
5
+ for (let i = 0; i < lines.length; i++) {
6
+ if (/[^ \t]/.test(lines[i])) lastNonEmpty = i;
7
+ }
8
+ let out = "";
9
+ for (let i = 0; i < lines.length; i++) {
10
+ let line = lines[i].replace(/\t/g, " ");
11
+ if (i !== 0) line = line.replace(/^ +/, "");
12
+ if (i !== lines.length - 1) line = line.replace(/ +$/, "");
13
+ if (!line) continue;
14
+ if (i !== lastNonEmpty) line += " ";
15
+ out += line;
16
+ }
17
+ return out;
18
+ }
19
+ export {
20
+ cleanTemplateText
21
+ };
@@ -0,0 +1,112 @@
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/optimize/analyze-static.ts
21
+ var analyze_static_exports = {};
22
+ __export(analyze_static_exports, {
23
+ analyzeStatic: () => analyzeStatic,
24
+ staticRoots: () => staticRoots
25
+ });
26
+ module.exports = __toCommonJS(analyze_static_exports);
27
+ function propReason(prop) {
28
+ switch (prop.kind) {
29
+ case "event":
30
+ return "event";
31
+ case "ref":
32
+ return "ref";
33
+ case "spread":
34
+ return "spread";
35
+ case "class":
36
+ case "style":
37
+ return "class-or-style-directive";
38
+ case "attr":
39
+ case "prop":
40
+ if (prop.reactive) return "reactive-prop";
41
+ if (prop.expr !== void 0) return "expression-prop";
42
+ return void 0;
43
+ /* c8 ignore next 2 */
44
+ default:
45
+ return "expression-prop";
46
+ }
47
+ }
48
+ function analyzeStatic(root) {
49
+ const staticElements = [];
50
+ const reasons = /* @__PURE__ */ new Map();
51
+ const visit = (node) => {
52
+ switch (node.kind) {
53
+ case "text":
54
+ return true;
55
+ case "expr":
56
+ return false;
57
+ case "component":
58
+ case "control":
59
+ for (const child of node.children) visit(child);
60
+ return false;
61
+ case "fragment":
62
+ for (const child of node.children) visit(child);
63
+ return false;
64
+ case "element": {
65
+ let childrenStatic = true;
66
+ for (const child of node.children) {
67
+ if (!visit(child)) childrenStatic = false;
68
+ }
69
+ let reason;
70
+ for (const prop of node.props) {
71
+ reason = propReason(prop);
72
+ if (reason) break;
73
+ }
74
+ if (!reason && !childrenStatic) {
75
+ reason = childReason(node);
76
+ }
77
+ node.static = !reason;
78
+ if (reason) reasons.set(node, reason);
79
+ else staticElements.push(node);
80
+ return node.static;
81
+ }
82
+ /* c8 ignore next 2 */
83
+ default:
84
+ return false;
85
+ }
86
+ };
87
+ for (const node of Array.isArray(root) ? root : [root]) visit(node);
88
+ return { staticElements, reasons };
89
+ }
90
+ function childReason(node) {
91
+ for (const child of node.children) {
92
+ if (child.kind === "expr") return "expression-child";
93
+ if (child.kind === "component") return "component-child";
94
+ if (child.kind === "control") return "control-child";
95
+ if (child.kind === "element" && !child.static) return "expression-child";
96
+ if (child.kind === "fragment") return "expression-child";
97
+ }
98
+ return "expression-child";
99
+ }
100
+ function staticRoots(root) {
101
+ const roots = [];
102
+ const visit = (node) => {
103
+ if (node.kind === "element" && node.static) {
104
+ roots.push(node);
105
+ return;
106
+ }
107
+ const children = node.children;
108
+ if (children) for (const child of children) visit(child);
109
+ };
110
+ for (const node of Array.isArray(root) ? root : [root]) visit(node);
111
+ return roots;
112
+ }
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Static analysis: mark the element subtrees that never change after creation.
3
+ *
4
+ * A static subtree can be built once as an HTML string and cloned per instance, instead
5
+ * of constructed an element at a time. That is the difference between one `cloneNode`
6
+ * and N `createElement` + N `spread` calls: measured at 2.1x faster for a three-element
7
+ * row and 2.4x for a nine-element card, with the gap widening as components grow.
8
+ *
9
+ * `IRElement.static` has existed since the IR was written, documented as
10
+ * "subtree has no dynamic parts → hoistable (template-clone)", but was hardcoded `false`
11
+ * with no producer. This is the producer.
12
+ *
13
+ * The analysis is deliberately conservative: marking something static that is not is a
14
+ * correctness bug (a shared DOM node across renders), while missing one is only a lost
15
+ * optimisation. Anything not positively known to be inert makes its whole ancestry
16
+ * dynamic.
17
+ */
18
+ import type { IRNode, IRElement } from '../ir/nodes.cjs';
19
+ /** Why a subtree could not be treated as static. Useful for diagnostics and tests. */
20
+ export type DynamicReason = 'reactive-prop' | 'expression-prop' | 'event' | 'ref' | 'spread' | 'class-or-style-directive' | 'expression-child' | 'component-child' | 'control-child';
21
+ export interface StaticReport {
22
+ /** Elements marked static, in visit order. */
23
+ staticElements: IRElement[];
24
+ /** Why each non-static element was rejected, keyed by the element node. */
25
+ reasons: Map<IRElement, DynamicReason>;
26
+ }
27
+ /**
28
+ * Mark every static element in the tree, returning what was decided.
29
+ *
30
+ * Mutates `IRElement.static` in place, since that field is the contract codegen reads.
31
+ */
32
+ export declare function analyzeStatic(root: IRNode | IRNode[]): StaticReport;
33
+ /**
34
+ * The outermost static elements: the roots worth turning into templates.
35
+ *
36
+ * Cloning a static child of a static parent is wasted: the parent's template already
37
+ * contains it.
38
+ */
39
+ export declare function staticRoots(root: IRNode | IRNode[]): IRElement[];
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Static analysis: mark the element subtrees that never change after creation.
3
+ *
4
+ * A static subtree can be built once as an HTML string and cloned per instance, instead
5
+ * of constructed an element at a time. That is the difference between one `cloneNode`
6
+ * and N `createElement` + N `spread` calls: measured at 2.1x faster for a three-element
7
+ * row and 2.4x for a nine-element card, with the gap widening as components grow.
8
+ *
9
+ * `IRElement.static` has existed since the IR was written, documented as
10
+ * "subtree has no dynamic parts → hoistable (template-clone)", but was hardcoded `false`
11
+ * with no producer. This is the producer.
12
+ *
13
+ * The analysis is deliberately conservative: marking something static that is not is a
14
+ * correctness bug (a shared DOM node across renders), while missing one is only a lost
15
+ * optimisation. Anything not positively known to be inert makes its whole ancestry
16
+ * dynamic.
17
+ */
18
+ import type { IRNode, IRElement } from '../ir/nodes.js';
19
+ /** Why a subtree could not be treated as static. Useful for diagnostics and tests. */
20
+ export type DynamicReason = 'reactive-prop' | 'expression-prop' | 'event' | 'ref' | 'spread' | 'class-or-style-directive' | 'expression-child' | 'component-child' | 'control-child';
21
+ export interface StaticReport {
22
+ /** Elements marked static, in visit order. */
23
+ staticElements: IRElement[];
24
+ /** Why each non-static element was rejected, keyed by the element node. */
25
+ reasons: Map<IRElement, DynamicReason>;
26
+ }
27
+ /**
28
+ * Mark every static element in the tree, returning what was decided.
29
+ *
30
+ * Mutates `IRElement.static` in place, since that field is the contract codegen reads.
31
+ */
32
+ export declare function analyzeStatic(root: IRNode | IRNode[]): StaticReport;
33
+ /**
34
+ * The outermost static elements: the roots worth turning into templates.
35
+ *
36
+ * Cloning a static child of a static parent is wasted: the parent's template already
37
+ * contains it.
38
+ */
39
+ export declare function staticRoots(root: IRNode | IRNode[]): IRElement[];
40
+ //# sourceMappingURL=analyze-static.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analyze-static.d.ts","sourceRoot":"","sources":["../../src/optimize/analyze-static.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAU,MAAM,gBAAgB,CAAC;AAEhE,sFAAsF;AACtF,MAAM,MAAM,aAAa,GACrB,eAAe,GACf,iBAAiB,GACjB,OAAO,GACP,KAAK,GACL,QAAQ,GACR,0BAA0B,GAC1B,kBAAkB,GAClB,iBAAiB,GACjB,eAAe,CAAC;AAEpB,MAAM,WAAW,YAAY;IAC3B,8CAA8C;IAC9C,cAAc,EAAE,SAAS,EAAE,CAAC;IAC5B,2EAA2E;IAC3E,OAAO,EAAE,GAAG,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;CACxC;AA+BD;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,YAAY,CA2DnE;AAeD;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,EAAE,CAchE"}
@@ -0,0 +1,131 @@
1
+ /**
2
+ * A prop is inert only when it is a plain attribute or property with a literal value.
3
+ *
4
+ * `expr` means arbitrary JS, which may read a signal or allocate, so it is dynamic even
5
+ * when `reactive` is false: a non-reactive expression still has to run per instance.
6
+ */
7
+ function propReason(prop) {
8
+ switch (prop.kind) {
9
+ case 'event':
10
+ return 'event';
11
+ case 'ref':
12
+ return 'ref';
13
+ case 'spread':
14
+ return 'spread';
15
+ case 'class':
16
+ case 'style':
17
+ // classList/style objects are built from expressions even when they look literal.
18
+ return 'class-or-style-directive';
19
+ case 'attr':
20
+ case 'prop':
21
+ if (prop.reactive)
22
+ return 'reactive-prop';
23
+ if (prop.expr !== undefined)
24
+ return 'expression-prop';
25
+ return undefined;
26
+ /* c8 ignore next 2 */
27
+ default:
28
+ return 'expression-prop';
29
+ }
30
+ }
31
+ /**
32
+ * Mark every static element in the tree, returning what was decided.
33
+ *
34
+ * Mutates `IRElement.static` in place, since that field is the contract codegen reads.
35
+ */
36
+ export function analyzeStatic(root) {
37
+ const staticElements = [];
38
+ const reasons = new Map();
39
+ /** Returns whether `node` is static, marking elements bottom-up. */
40
+ const visit = (node) => {
41
+ switch (node.kind) {
42
+ case 'text':
43
+ return true;
44
+ case 'expr':
45
+ // A hole is dynamic even when it is not reactive: its value is computed.
46
+ return false;
47
+ case 'component':
48
+ case 'control':
49
+ // Both produce their own subtree at runtime, so an ancestor cannot be cloned
50
+ // wholesale. Still walk in, so nested elements are marked for their own sake.
51
+ for (const child of node.children)
52
+ visit(child);
53
+ return false;
54
+ case 'fragment':
55
+ // A fragment is not an element and cannot itself be cloned, but its children
56
+ // can be considered independently.
57
+ for (const child of node.children)
58
+ visit(child);
59
+ return false;
60
+ case 'element': {
61
+ // Children are visited first and unconditionally, so a static subtree nested
62
+ // under a dynamic parent is still marked and can be cloned on its own.
63
+ let childrenStatic = true;
64
+ for (const child of node.children) {
65
+ if (!visit(child))
66
+ childrenStatic = false;
67
+ }
68
+ let reason;
69
+ for (const prop of node.props) {
70
+ reason = propReason(prop);
71
+ if (reason)
72
+ break;
73
+ }
74
+ if (!reason && !childrenStatic) {
75
+ reason = childReason(node);
76
+ }
77
+ node.static = !reason;
78
+ if (reason)
79
+ reasons.set(node, reason);
80
+ else
81
+ staticElements.push(node);
82
+ return node.static;
83
+ }
84
+ /* c8 ignore next 2 */
85
+ default:
86
+ return false;
87
+ }
88
+ };
89
+ for (const node of Array.isArray(root) ? root : [root])
90
+ visit(node);
91
+ return { staticElements, reasons };
92
+ }
93
+ /** The most specific reason a child made its parent dynamic. */
94
+ function childReason(node) {
95
+ for (const child of node.children) {
96
+ if (child.kind === 'expr')
97
+ return 'expression-child';
98
+ if (child.kind === 'component')
99
+ return 'component-child';
100
+ if (child.kind === 'control')
101
+ return 'control-child';
102
+ if (child.kind === 'element' && !child.static)
103
+ return 'expression-child';
104
+ if (child.kind === 'fragment')
105
+ return 'expression-child';
106
+ }
107
+ /* c8 ignore next */
108
+ return 'expression-child';
109
+ }
110
+ /**
111
+ * The outermost static elements: the roots worth turning into templates.
112
+ *
113
+ * Cloning a static child of a static parent is wasted: the parent's template already
114
+ * contains it.
115
+ */
116
+ export function staticRoots(root) {
117
+ const roots = [];
118
+ const visit = (node) => {
119
+ if (node.kind === 'element' && node.static) {
120
+ roots.push(node);
121
+ return; // its subtree is inside this template
122
+ }
123
+ const children = node.children;
124
+ if (children)
125
+ for (const child of children)
126
+ visit(child);
127
+ };
128
+ for (const node of Array.isArray(root) ? root : [root])
129
+ visit(node);
130
+ return roots;
131
+ }
@@ -0,0 +1,91 @@
1
+ // src/optimize/analyze-static.ts
2
+ function propReason(prop) {
3
+ switch (prop.kind) {
4
+ case "event":
5
+ return "event";
6
+ case "ref":
7
+ return "ref";
8
+ case "spread":
9
+ return "spread";
10
+ case "class":
11
+ case "style":
12
+ return "class-or-style-directive";
13
+ case "attr":
14
+ case "prop":
15
+ if (prop.reactive) return "reactive-prop";
16
+ if (prop.expr !== void 0) return "expression-prop";
17
+ return void 0;
18
+ /* c8 ignore next 2 */
19
+ default:
20
+ return "expression-prop";
21
+ }
22
+ }
23
+ function analyzeStatic(root) {
24
+ const staticElements = [];
25
+ const reasons = /* @__PURE__ */ new Map();
26
+ const visit = (node) => {
27
+ switch (node.kind) {
28
+ case "text":
29
+ return true;
30
+ case "expr":
31
+ return false;
32
+ case "component":
33
+ case "control":
34
+ for (const child of node.children) visit(child);
35
+ return false;
36
+ case "fragment":
37
+ for (const child of node.children) visit(child);
38
+ return false;
39
+ case "element": {
40
+ let childrenStatic = true;
41
+ for (const child of node.children) {
42
+ if (!visit(child)) childrenStatic = false;
43
+ }
44
+ let reason;
45
+ for (const prop of node.props) {
46
+ reason = propReason(prop);
47
+ if (reason) break;
48
+ }
49
+ if (!reason && !childrenStatic) {
50
+ reason = childReason(node);
51
+ }
52
+ node.static = !reason;
53
+ if (reason) reasons.set(node, reason);
54
+ else staticElements.push(node);
55
+ return node.static;
56
+ }
57
+ /* c8 ignore next 2 */
58
+ default:
59
+ return false;
60
+ }
61
+ };
62
+ for (const node of Array.isArray(root) ? root : [root]) visit(node);
63
+ return { staticElements, reasons };
64
+ }
65
+ function childReason(node) {
66
+ for (const child of node.children) {
67
+ if (child.kind === "expr") return "expression-child";
68
+ if (child.kind === "component") return "component-child";
69
+ if (child.kind === "control") return "control-child";
70
+ if (child.kind === "element" && !child.static) return "expression-child";
71
+ if (child.kind === "fragment") return "expression-child";
72
+ }
73
+ return "expression-child";
74
+ }
75
+ function staticRoots(root) {
76
+ const roots = [];
77
+ const visit = (node) => {
78
+ if (node.kind === "element" && node.static) {
79
+ roots.push(node);
80
+ return;
81
+ }
82
+ const children = node.children;
83
+ if (children) for (const child of children) visit(child);
84
+ };
85
+ for (const node of Array.isArray(root) ? root : [root]) visit(node);
86
+ return roots;
87
+ }
88
+ export {
89
+ analyzeStatic,
90
+ staticRoots
91
+ };
@@ -0,0 +1,90 @@
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/optimize/collapse-strategies.ts
21
+ var collapse_strategies_exports = {};
22
+ __export(collapse_strategies_exports, {
23
+ collapseStrategies: () => collapseStrategies
24
+ });
25
+ module.exports = __toCommonJS(collapse_strategies_exports);
26
+
27
+ // src/resolve/load-directive.ts
28
+ function isDeferred(strategy) {
29
+ return strategy.kind !== "eager" && strategy.kind !== "never";
30
+ }
31
+
32
+ // src/resolve/builtins.ts
33
+ var DOM_CONTROL_FLOW = [
34
+ "Show",
35
+ "For",
36
+ "Index",
37
+ "Switch",
38
+ "Match",
39
+ "Portal",
40
+ "Dynamic",
41
+ "ErrorBoundary"
42
+ ];
43
+ var CORE_CONTROL_FLOW = ["Suspense", "SuspenseList", "Await"];
44
+ var ROUTER_COMPONENTS = ["Router", "Outlet", "Redirect", "Link"];
45
+ var BUILTIN_COMPONENTS = [
46
+ ...DOM_CONTROL_FLOW,
47
+ ...CORE_CONTROL_FLOW,
48
+ ...ROUTER_COMPONENTS
49
+ ];
50
+ var RESERVED_COMPONENTS = /* @__PURE__ */ new Set([
51
+ ...DOM_CONTROL_FLOW,
52
+ ...CORE_CONTROL_FLOW
53
+ ]);
54
+
55
+ // src/resolve/resolve-ir.ts
56
+ function walk(root, visit) {
57
+ const nodes = Array.isArray(root) ? root : [root];
58
+ for (const node of nodes) {
59
+ visit(node);
60
+ const children = node.children;
61
+ if (children) walk(children, visit);
62
+ }
63
+ }
64
+
65
+ // src/optimize/collapse-strategies.ts
66
+ function collapseStrategies(root) {
67
+ const components = [];
68
+ walk(root, (node) => {
69
+ if (node.kind === "component" && node.source) components.push(node);
70
+ });
71
+ const eager = /* @__PURE__ */ new Set();
72
+ const never = /* @__PURE__ */ new Set();
73
+ for (const node of components) {
74
+ const { module: module2, loading } = node.source;
75
+ if (loading.kind === "eager") eager.add(module2);
76
+ if (loading.kind === "never") never.add(module2);
77
+ }
78
+ const collapsed = /* @__PURE__ */ new Map();
79
+ for (const node of components) {
80
+ const source = node.source;
81
+ if (!isDeferred(source.loading)) continue;
82
+ if (!eager.has(source.module)) continue;
83
+ source.loading = { kind: "eager" };
84
+ collapsed.set(source.module, (collapsed.get(source.module) ?? 0) + 1);
85
+ }
86
+ return {
87
+ collapsed,
88
+ conflicted: [...never].filter((m) => eager.has(m))
89
+ };
90
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Strategy collapsing: demote a deferred reference whose module is already present.
3
+ *
4
+ * This is not a nice-to-have. Without it the naive feature is a regression: if a module
5
+ * is referenced eagerly anywhere in the compilation unit, it is in the parent chunk
6
+ * already, so a `load:visible` boundary elsewhere adds a wrapper, a promise and a
7
+ * re-render in order to fetch nothing. The bytes are paid twice, once in the chunk,
8
+ * once in the deferral machinery: and the component renders later than it needs to.
9
+ *
10
+ * Collapsing runs per module, not per component name, because a chunk is a module:
11
+ * `<Button>` eager and `<ButtonGroup load:visible>` from the same package means the
12
+ * package is already loaded, so deferring the second buys nothing.
13
+ *
14
+ * `never` is not collapsed. It means "no client code at all", which is a statement about
15
+ * what should exist rather than about when to fetch it; an eager sibling does not make a
16
+ * server-only component suddenly belong in the client bundle. That combination is
17
+ * contradictory and reported instead.
18
+ */
19
+ import type { IRNode } from '../ir/nodes.cjs';
20
+ export interface CollapseReport {
21
+ /** Modules demoted to eager, with the reference count that was demoted. */
22
+ collapsed: Map<string, number>;
23
+ /**
24
+ * Modules referenced both as `load:never` and in a way that needs client code.
25
+ * Contradictory rather than optimisable, so it is reported and left alone.
26
+ */
27
+ conflicted: string[];
28
+ }
29
+ /** Demote deferred references to modules that are already in the chunk. */
30
+ export declare function collapseStrategies(root: IRNode | IRNode[]): CollapseReport;