@elurjs/kit 2.4.4

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 (255) hide show
  1. package/CHANGELOG.md +874 -0
  2. package/LICENSE +21 -0
  3. package/README.md +1330 -0
  4. package/bin/elur-kit.js +54 -0
  5. package/dist/lib/action/define.d.cts +72 -0
  6. package/dist/lib/action/define.d.ts +72 -0
  7. package/dist/lib/action/error-store.d.cts +29 -0
  8. package/dist/lib/action/error-store.d.ts +29 -0
  9. package/dist/lib/action/index.cjs +1 -0
  10. package/dist/lib/action/index.d.cts +64 -0
  11. package/dist/lib/action/index.d.ts +64 -0
  12. package/dist/lib/action/index.js +2 -0
  13. package/dist/lib/action/origin.d.cts +20 -0
  14. package/dist/lib/action/origin.d.ts +20 -0
  15. package/dist/lib/action/scan.d.cts +28 -0
  16. package/dist/lib/action/scan.d.ts +28 -0
  17. package/dist/lib/action/server.d.cts +30 -0
  18. package/dist/lib/action/server.d.ts +30 -0
  19. package/dist/lib/action-BB6N5yD-.js +111 -0
  20. package/dist/lib/action-BB6N5yD-.js.map +1 -0
  21. package/dist/lib/action-DZHihU3Z.cjs +2 -0
  22. package/dist/lib/action-DZHihU3Z.cjs.map +1 -0
  23. package/dist/lib/adapters/bun.cjs +30 -0
  24. package/dist/lib/adapters/bun.cjs.map +1 -0
  25. package/dist/lib/adapters/bun.d.cts +13 -0
  26. package/dist/lib/adapters/bun.d.ts +13 -0
  27. package/dist/lib/adapters/bun.js +65 -0
  28. package/dist/lib/adapters/bun.js.map +1 -0
  29. package/dist/lib/adapters/index.cjs +0 -0
  30. package/dist/lib/adapters/index.d.cts +30 -0
  31. package/dist/lib/adapters/index.d.ts +30 -0
  32. package/dist/lib/adapters/index.js +0 -0
  33. package/dist/lib/adapters/netlify.cjs +10 -0
  34. package/dist/lib/adapters/netlify.cjs.map +1 -0
  35. package/dist/lib/adapters/netlify.d.cts +13 -0
  36. package/dist/lib/adapters/netlify.d.ts +13 -0
  37. package/dist/lib/adapters/netlify.js +51 -0
  38. package/dist/lib/adapters/netlify.js.map +1 -0
  39. package/dist/lib/adapters/node.cjs +46 -0
  40. package/dist/lib/adapters/node.cjs.map +1 -0
  41. package/dist/lib/adapters/node.d.cts +13 -0
  42. package/dist/lib/adapters/node.d.ts +13 -0
  43. package/dist/lib/adapters/node.js +105 -0
  44. package/dist/lib/adapters/node.js.map +1 -0
  45. package/dist/lib/adapters/shared.d.cts +17 -0
  46. package/dist/lib/adapters/shared.d.ts +17 -0
  47. package/dist/lib/adapters/vercel.cjs +2 -0
  48. package/dist/lib/adapters/vercel.cjs.map +1 -0
  49. package/dist/lib/adapters/vercel.d.cts +9 -0
  50. package/dist/lib/adapters/vercel.d.ts +9 -0
  51. package/dist/lib/adapters/vercel.js +62 -0
  52. package/dist/lib/adapters/vercel.js.map +1 -0
  53. package/dist/lib/build/build.d.cts +83 -0
  54. package/dist/lib/build/build.d.ts +83 -0
  55. package/dist/lib/build/document-shell.d.cts +48 -0
  56. package/dist/lib/build/document-shell.d.ts +48 -0
  57. package/dist/lib/build/transform-source.d.cts +26 -0
  58. package/dist/lib/build/transform-source.d.ts +26 -0
  59. package/dist/lib/build/vite-build.d.cts +78 -0
  60. package/dist/lib/build/vite-build.d.ts +78 -0
  61. package/dist/lib/cache/policy.d.cts +25 -0
  62. package/dist/lib/cache/policy.d.ts +25 -0
  63. package/dist/lib/cache.d.cts +13 -0
  64. package/dist/lib/cache.d.ts +13 -0
  65. package/dist/lib/capabilities-C0TDQoMY.cjs +2 -0
  66. package/dist/lib/capabilities-C0TDQoMY.cjs.map +1 -0
  67. package/dist/lib/capabilities-C7txofmY.js +45 -0
  68. package/dist/lib/capabilities-C7txofmY.js.map +1 -0
  69. package/dist/lib/cli/commands.d.cts +15 -0
  70. package/dist/lib/cli/commands.d.ts +15 -0
  71. package/dist/lib/cli.cjs +5132 -0
  72. package/dist/lib/cli.cjs.map +1 -0
  73. package/dist/lib/cli.d.cts +30 -0
  74. package/dist/lib/cli.d.ts +30 -0
  75. package/dist/lib/cli.js +5131 -0
  76. package/dist/lib/cli.js.map +1 -0
  77. package/dist/lib/collections-Dbc8aRLf.js +233 -0
  78. package/dist/lib/collections-Dbc8aRLf.js.map +1 -0
  79. package/dist/lib/collections-VDy5g9p8.cjs +13 -0
  80. package/dist/lib/collections-VDy5g9p8.cjs.map +1 -0
  81. package/dist/lib/config/index.cjs +2 -0
  82. package/dist/lib/config/index.cjs.map +1 -0
  83. package/dist/lib/config/index.d.cts +100 -0
  84. package/dist/lib/config/index.d.ts +100 -0
  85. package/dist/lib/config/index.js +122 -0
  86. package/dist/lib/config/index.js.map +1 -0
  87. package/dist/lib/content/collections.d.cts +69 -0
  88. package/dist/lib/content/collections.d.ts +69 -0
  89. package/dist/lib/content/frontmatter.d.cts +20 -0
  90. package/dist/lib/content/frontmatter.d.ts +20 -0
  91. package/dist/lib/content/index.cjs +2 -0
  92. package/dist/lib/content/index.cjs.map +1 -0
  93. package/dist/lib/content/index.d.cts +5 -0
  94. package/dist/lib/content/index.d.ts +5 -0
  95. package/dist/lib/content/index.js +28 -0
  96. package/dist/lib/content/index.js.map +1 -0
  97. package/dist/lib/content/markdown.d.cts +6 -0
  98. package/dist/lib/content/markdown.d.ts +6 -0
  99. package/dist/lib/content/raw.d.cts +9 -0
  100. package/dist/lib/content/raw.d.ts +9 -0
  101. package/dist/lib/content/schema.d.cts +14 -0
  102. package/dist/lib/content/schema.d.ts +14 -0
  103. package/dist/lib/errors-0X7pCFNU.cjs +2 -0
  104. package/dist/lib/errors-0X7pCFNU.cjs.map +1 -0
  105. package/dist/lib/errors-ePYxDlhU.js +70 -0
  106. package/dist/lib/errors-ePYxDlhU.js.map +1 -0
  107. package/dist/lib/errors.d.cts +84 -0
  108. package/dist/lib/errors.d.ts +84 -0
  109. package/dist/lib/hydrate-8a3TbQbs.cjs +2 -0
  110. package/dist/lib/hydrate-8a3TbQbs.cjs.map +1 -0
  111. package/dist/lib/hydrate-CgZGrTxF.js +126 -0
  112. package/dist/lib/hydrate-CgZGrTxF.js.map +1 -0
  113. package/dist/lib/image/index.cjs +2 -0
  114. package/dist/lib/image/index.cjs.map +1 -0
  115. package/dist/lib/image/index.d.cts +37 -0
  116. package/dist/lib/image/index.d.ts +37 -0
  117. package/dist/lib/image/index.js +49 -0
  118. package/dist/lib/image/index.js.map +1 -0
  119. package/dist/lib/image/pipeline.d.cts +37 -0
  120. package/dist/lib/image/pipeline.d.ts +37 -0
  121. package/dist/lib/image/registry.cjs +2 -0
  122. package/dist/lib/image/registry.cjs.map +1 -0
  123. package/dist/lib/image/registry.d.cts +26 -0
  124. package/dist/lib/image/registry.d.ts +26 -0
  125. package/dist/lib/image/registry.js +23 -0
  126. package/dist/lib/image/registry.js.map +1 -0
  127. package/dist/lib/image/service.cjs +2 -0
  128. package/dist/lib/image/service.cjs.map +1 -0
  129. package/dist/lib/image/service.d.cts +164 -0
  130. package/dist/lib/image/service.d.ts +164 -0
  131. package/dist/lib/image/service.js +308 -0
  132. package/dist/lib/image/service.js.map +1 -0
  133. package/dist/lib/index.cjs +1 -0
  134. package/dist/lib/index.cjs.map +1 -0
  135. package/dist/lib/index.d.cts +38 -0
  136. package/dist/lib/index.d.ts +38 -0
  137. package/dist/lib/index.js +1 -0
  138. package/dist/lib/index.js.map +1 -0
  139. package/dist/lib/integrations/hooks.d.cts +58 -0
  140. package/dist/lib/integrations/hooks.d.ts +58 -0
  141. package/dist/lib/integrations/index.cjs +1 -0
  142. package/dist/lib/integrations/index.d.cts +18 -0
  143. package/dist/lib/integrations/index.d.ts +18 -0
  144. package/dist/lib/integrations/index.js +2 -0
  145. package/dist/lib/integrations-7dpN1RYB.js +35 -0
  146. package/dist/lib/integrations-7dpN1RYB.js.map +1 -0
  147. package/dist/lib/integrations-DDqfWjvH.cjs +2 -0
  148. package/dist/lib/integrations-DDqfWjvH.cjs.map +1 -0
  149. package/dist/lib/interpolation-plugin-Bt-KRKVY.js +365 -0
  150. package/dist/lib/interpolation-plugin-Bt-KRKVY.js.map +1 -0
  151. package/dist/lib/interpolation-plugin-CMPCDlVJ.cjs +31 -0
  152. package/dist/lib/interpolation-plugin-CMPCDlVJ.cjs.map +1 -0
  153. package/dist/lib/island/generate-entry.d.cts +27 -0
  154. package/dist/lib/island/generate-entry.d.ts +27 -0
  155. package/dist/lib/island/hydrate.d.cts +33 -0
  156. package/dist/lib/island/hydrate.d.ts +33 -0
  157. package/dist/lib/island/index.cjs +1 -0
  158. package/dist/lib/island/index.d.cts +2 -0
  159. package/dist/lib/island/index.d.ts +2 -0
  160. package/dist/lib/island/index.js +1 -0
  161. package/dist/lib/island/island.d.cts +32 -0
  162. package/dist/lib/island/island.d.ts +32 -0
  163. package/dist/lib/island/scan.d.cts +14 -0
  164. package/dist/lib/island/scan.d.ts +14 -0
  165. package/dist/lib/manifest/index.cjs +3 -0
  166. package/dist/lib/manifest/index.cjs.map +1 -0
  167. package/dist/lib/manifest/index.d.cts +18 -0
  168. package/dist/lib/manifest/index.d.ts +18 -0
  169. package/dist/lib/manifest/index.js +110 -0
  170. package/dist/lib/manifest/index.js.map +1 -0
  171. package/dist/lib/middleware/index.d.cts +56 -0
  172. package/dist/lib/middleware/index.d.ts +56 -0
  173. package/dist/lib/middleware/stream-boundary.d.cts +53 -0
  174. package/dist/lib/middleware/stream-boundary.d.ts +53 -0
  175. package/dist/lib/node-http-DRAUhO0c.js +617 -0
  176. package/dist/lib/node-http-DRAUhO0c.js.map +1 -0
  177. package/dist/lib/node-http-DhxguYyz.cjs +13 -0
  178. package/dist/lib/node-http-DhxguYyz.cjs.map +1 -0
  179. package/dist/lib/render/render-to-string.d.cts +12 -0
  180. package/dist/lib/render/render-to-string.d.ts +12 -0
  181. package/dist/lib/render/ssr-flag.d.cts +4 -0
  182. package/dist/lib/render/ssr-flag.d.ts +4 -0
  183. package/dist/lib/route-scanner-JY6YrNH5.cjs +2 -0
  184. package/dist/lib/route-scanner-JY6YrNH5.cjs.map +1 -0
  185. package/dist/lib/route-scanner-XcLId7lK.js +100 -0
  186. package/dist/lib/route-scanner-XcLId7lK.js.map +1 -0
  187. package/dist/lib/router/client.cjs +2 -0
  188. package/dist/lib/router/client.cjs.map +1 -0
  189. package/dist/lib/router/client.d.cts +47 -0
  190. package/dist/lib/router/client.d.ts +47 -0
  191. package/dist/lib/router/client.js +298 -0
  192. package/dist/lib/router/client.js.map +1 -0
  193. package/dist/lib/router/route-scanner.d.cts +50 -0
  194. package/dist/lib/router/route-scanner.d.ts +50 -0
  195. package/dist/lib/runtime/capabilities.d.cts +47 -0
  196. package/dist/lib/runtime/capabilities.d.ts +47 -0
  197. package/dist/lib/runtime/context.d.cts +140 -0
  198. package/dist/lib/runtime/context.d.ts +140 -0
  199. package/dist/lib/runtime/handler.d.cts +39 -0
  200. package/dist/lib/runtime/handler.d.ts +39 -0
  201. package/dist/lib/runtime/index.cjs +1 -0
  202. package/dist/lib/runtime/index.d.cts +6 -0
  203. package/dist/lib/runtime/index.d.ts +6 -0
  204. package/dist/lib/runtime/index.js +4 -0
  205. package/dist/lib/runtime/node-http.d.cts +2 -0
  206. package/dist/lib/runtime/node-http.d.ts +2 -0
  207. package/dist/lib/runtime/security-headers.d.cts +13 -0
  208. package/dist/lib/runtime/security-headers.d.ts +13 -0
  209. package/dist/lib/runtime/static.d.cts +1 -0
  210. package/dist/lib/runtime/static.d.ts +1 -0
  211. package/dist/lib/runtime-CrH5X-Es.cjs +2 -0
  212. package/dist/lib/runtime-CrH5X-Es.cjs.map +1 -0
  213. package/dist/lib/runtime-Ds2-wH6P.js +520 -0
  214. package/dist/lib/runtime-Ds2-wH6P.js.map +1 -0
  215. package/dist/lib/scan-CY2O9ty6.cjs +2 -0
  216. package/dist/lib/scan-CY2O9ty6.cjs.map +1 -0
  217. package/dist/lib/scan-CjMUgnsd.js +22 -0
  218. package/dist/lib/scan-CjMUgnsd.js.map +1 -0
  219. package/dist/lib/scan-DXzYtmRQ.cjs +2 -0
  220. package/dist/lib/scan-DXzYtmRQ.cjs.map +1 -0
  221. package/dist/lib/scan-Dn93ycXG.js +33 -0
  222. package/dist/lib/scan-Dn93ycXG.js.map +1 -0
  223. package/dist/lib/seo/index.cjs +10 -0
  224. package/dist/lib/seo/index.cjs.map +1 -0
  225. package/dist/lib/seo/index.d.cts +99 -0
  226. package/dist/lib/seo/index.d.ts +99 -0
  227. package/dist/lib/seo/index.js +41 -0
  228. package/dist/lib/seo/index.js.map +1 -0
  229. package/dist/lib/shared-CfqOLsKj.cjs +183 -0
  230. package/dist/lib/shared-CfqOLsKj.cjs.map +1 -0
  231. package/dist/lib/shared-DU3iQgr7.js +236 -0
  232. package/dist/lib/shared-DU3iQgr7.js.map +1 -0
  233. package/dist/lib/ssr/match.d.cts +25 -0
  234. package/dist/lib/ssr/match.d.ts +25 -0
  235. package/dist/lib/ssr/render.d.cts +62 -0
  236. package/dist/lib/ssr/render.d.ts +62 -0
  237. package/dist/lib/ssr/server.d.cts +41 -0
  238. package/dist/lib/ssr/server.d.ts +41 -0
  239. package/dist/lib/ssr/stream.d.cts +48 -0
  240. package/dist/lib/ssr/stream.d.ts +48 -0
  241. package/dist/lib/stream-CpOG052V.js +104 -0
  242. package/dist/lib/stream-CpOG052V.js.map +1 -0
  243. package/dist/lib/stream-DmZjYqHm.cjs +17 -0
  244. package/dist/lib/stream-DmZjYqHm.cjs.map +1 -0
  245. package/dist/lib/types.d.cts +97 -0
  246. package/dist/lib/types.d.ts +97 -0
  247. package/dist/lib/vite/index.cjs +2 -0
  248. package/dist/lib/vite/index.cjs.map +1 -0
  249. package/dist/lib/vite/index.d.cts +41 -0
  250. package/dist/lib/vite/index.d.ts +41 -0
  251. package/dist/lib/vite/index.js +229 -0
  252. package/dist/lib/vite/index.js.map +1 -0
  253. package/dist/lib/vite/interpolation-plugin.d.cts +64 -0
  254. package/dist/lib/vite/interpolation-plugin.d.ts +64 -0
  255. package/package.json +292 -0
@@ -0,0 +1,229 @@
1
+ import { a as e, c as t, l as n, n as r, o as i, t as a } from "../node-http-DRAUhO0c.js";
2
+ import { t as o } from "../route-scanner-XcLId7lK.js";
3
+ import { t as s } from "../scan-Dn93ycXG.js";
4
+ import { a as c, i as l, n as u, o as d, r as f, s as p, t as m } from "../interpolation-plugin-Bt-KRKVY.js";
5
+ import { n as h, t as g } from "../scan-CjMUgnsd.js";
6
+ import { s as _, t as v } from "../collections-Dbc8aRLf.js";
7
+ import { mkdir as y, writeFile as b } from "node:fs/promises";
8
+ import { dirname as x, relative as S, resolve as C } from "node:path";
9
+ //#region src/vite/index.ts
10
+ function w(t = {}) {
11
+ let n = t.appDir ?? "src/app", i = t.islandsDir ?? "src/islands", m = t.contentDir ?? "src/content", S = t.generatedEntry ?? ".elur/entry-client.ts", w = t.clientEntry ?? "/_elur/entry-client.js", A = t.lang ?? "es", j = t.hydrateImport ?? "@elurjs/kit/island", M = t.routerImport ?? "@elurjs/kit/router", N = null, P = {}, F = ".", I = null, L = {
12
+ name: "elur-kit",
13
+ enforce: "pre",
14
+ async configResolved(e) {
15
+ F = e.root;
16
+ let t = C(F, S), r = await s(C(F, i)), a = p(r, t, j, M);
17
+ await y(x(t), { recursive: !0 }), await b(t, a, "utf8");
18
+ let c = C(F, n);
19
+ N = await o(c), P = await h(c), _(C(F, m)), I = await l(F);
20
+ },
21
+ configureServer(s) {
22
+ let l = E(s, F), u = D(() => P, () => N, l), f = C(F, n);
23
+ T(s, f, C(F, i), C(F, m), F, S, j, M, () => {
24
+ N = null, P = {}, v();
25
+ }), s.middlewares.use(async (n, i, p) => {
26
+ let m = new URL(n.url ?? "/", `http://${n.headers.host ?? "localhost"}`), _ = m.pathname;
27
+ if (_ === "/__elur-js/actions" && n.method === "POST") {
28
+ try {
29
+ let e = await O(n), o = a(n, e), s = await r(o, u, t.actionSecurity);
30
+ i.writeHead(s.status, Object.fromEntries(s.headers.entries())), i.end(await s.text());
31
+ } catch (e) {
32
+ console.error("[elur-kit] action error:", e), i.writeHead(500, { "Content-Type": "text/plain; charset=utf-8" }), i.end(String(e));
33
+ }
34
+ return;
35
+ }
36
+ if (_.startsWith("/_elur/entry-client.js")) {
37
+ let e = await s.transformRequest("/.elur/entry-client.ts");
38
+ if (e) {
39
+ i.writeHead(200, {
40
+ "Content-Type": "application/javascript; charset=utf-8",
41
+ "Cache-Control": "no-store, must-revalidate"
42
+ }), i.end(e.code);
43
+ return;
44
+ }
45
+ }
46
+ let v = N ??= await o(f), y = Object.keys(P).length ? P : P = await h(f);
47
+ if (_ === "/__elur-js/render") {
48
+ let { renderPageBody: e, RouteNotFoundError: t } = await import("../stream-CpOG052V.js").then((e) => e.i);
49
+ try {
50
+ let t = m.searchParams.get("page") ?? "/", r = m.searchParams.get("search") ?? "", o = (n.headers.accept ?? "").includes("application/json"), s = a(n), { body: c, title: u, head: d, clearActionErrorCookie: f } = await e({
51
+ routes: v,
52
+ pathname: t,
53
+ searchParams: new URLSearchParams(r),
54
+ config: {
55
+ lang: A,
56
+ clientEntry: w
57
+ },
58
+ actions: g(y),
59
+ importer: l,
60
+ request: s
61
+ });
62
+ if (o) {
63
+ let e = { "Content-Type": "application/json; charset=utf-8" };
64
+ f && (e["X-Elur-Action-Clear-Cookie"] = f), i.writeHead(200, e), i.end(JSON.stringify({
65
+ title: u,
66
+ body: c,
67
+ head: d,
68
+ clearActionErrorCookie: f
69
+ }));
70
+ } else {
71
+ let e = { "Content-Type": "text/html; charset=utf-8" };
72
+ f && (e["Set-Cookie"] = f), i.writeHead(200, e), i.end(c);
73
+ }
74
+ return;
75
+ } catch (e) {
76
+ if (e instanceof t) {
77
+ i.writeHead(404, { "Content-Type": "text/plain; charset=utf-8" }), i.end("Not Found");
78
+ return;
79
+ }
80
+ console.error("[elur-kit] render endpoint error:", e), i.writeHead(500, { "Content-Type": "text/plain; charset=utf-8" }), i.end(String(e));
81
+ return;
82
+ }
83
+ }
84
+ if (!_.startsWith("/@") && !_.startsWith("/node_modules/") && !_.includes(".")) {
85
+ let t = e(_, v.api);
86
+ if (t) {
87
+ try {
88
+ let e = (await l(t.route.routePath))[n.method ?? "GET"];
89
+ if (typeof e != "function") {
90
+ i.writeHead(405, { "Content-Type": "text/plain" }), i.end(`Method not allowed: ${n.method}`);
91
+ return;
92
+ }
93
+ let r = n.method && n.method !== "GET" && n.method !== "HEAD" ? await O(n) : void 0, o = await e(a(n, r), { params: t.params });
94
+ i.writeHead(o.status, Object.fromEntries(o.headers.entries())), i.end(Buffer.from(await o.arrayBuffer()));
95
+ } catch (e) {
96
+ console.error("[elur-kit] API route error:", e), i.writeHead(500, { "Content-Type": "text/plain; charset=utf-8" }), i.end(String(e));
97
+ }
98
+ return;
99
+ }
100
+ }
101
+ let b;
102
+ if (I && c(_, I.config)) {
103
+ let e = await d(I, a(n));
104
+ if (e.kind === "response") {
105
+ i.writeHead(e.response.status, Object.fromEntries(e.response.headers.entries())), i.end(Buffer.from(await e.response.arrayBuffer()));
106
+ return;
107
+ }
108
+ b = e.headers;
109
+ }
110
+ await k(n, i, p, {
111
+ routes: v,
112
+ actions: y,
113
+ clientEntry: w,
114
+ lang: A,
115
+ ssrLoad: l,
116
+ middlewareHeaders: b
117
+ }) || p();
118
+ });
119
+ }
120
+ };
121
+ return f(t.interpolation ?? "auto") ? [L, u({
122
+ appDir: n,
123
+ islandsDir: i
124
+ })] : [L];
125
+ }
126
+ function T(e, t, n, r, i, a, o, c, l) {
127
+ let u = (e) => e.startsWith(t) || e.startsWith(n) || e.startsWith(r);
128
+ async function d() {
129
+ let t = await s(n), r = C(i, a), l = p(t, r, o, c);
130
+ await y(x(r), { recursive: !0 }), await b(r, l, "utf8");
131
+ let u = e.moduleGraph.getModuleById(r);
132
+ u && e.moduleGraph.invalidateModule(u);
133
+ }
134
+ e.watcher.on("change", async (t) => {
135
+ if (!u(t)) return;
136
+ l();
137
+ let i = e.moduleGraph.getModuleById(t);
138
+ i && e.moduleGraph.invalidateModule(i), t.startsWith(n) ? (await d(), console.log("[elur-kit] HMR reload islands after change:", t)) : t.startsWith(r) && t.endsWith(".md") ? console.log("[elur-kit] HMR content changed:", t) : (t.includes(".action.ts") || t.includes(".data.ts") || t.includes("page.ts") || t.includes("layout.ts")) && console.log("[elur-kit] HMR reload routes/actions after change:", t);
139
+ }), e.watcher.on("add", async (e) => {
140
+ u(e) && (l(), e.startsWith(n) && await d(), console.log("[elur-kit] HMR new file detected:", e));
141
+ }), e.watcher.on("unlink", async (t) => {
142
+ if (!u(t)) return;
143
+ l();
144
+ let r = e.moduleGraph.getModuleById(t);
145
+ r && e.moduleGraph.invalidateModule(r), t.startsWith(n) && await d(), console.log("[elur-kit] HMR file removed:", t);
146
+ });
147
+ }
148
+ function E(e, t) {
149
+ return (n) => {
150
+ let r = "/" + S(t, n).split("\\").join("/");
151
+ return e.ssrLoadModule(r);
152
+ };
153
+ }
154
+ function D(e, t, n) {
155
+ return async (r, a) => {
156
+ let o = e(), s = t(), c;
157
+ a && s && (c = s.pages.some((e) => e.path === a) ? a : i(a, s.pages)?.route.path ?? a);
158
+ let l = c ? o[c] : Object.values(o).find((e) => e[r]) ?? void 0, u = l ? l[r] : void 0;
159
+ if (!u) return;
160
+ let d = (await n(u))[r];
161
+ if (typeof d == "function") return d;
162
+ };
163
+ }
164
+ function O(e) {
165
+ return new Promise((t, n) => {
166
+ let r = "";
167
+ e.setEncoding("utf8"), e.on("data", (e) => {
168
+ r += e;
169
+ }), e.on("end", () => t(r)), e.on("error", n);
170
+ });
171
+ }
172
+ async function k(e, r, o, s) {
173
+ if (!s.routes) return !1;
174
+ let c = g(s.actions), l = e.url ?? "/";
175
+ if (l.includes("?") && (l = l.split("?")[0]), l.startsWith("/@") || l.startsWith("/node_modules/") || l.includes(".")) return !1;
176
+ let u = {
177
+ lang: s.lang,
178
+ clientEntry: s.clientEntry
179
+ }, d = i(l, s.routes.pages);
180
+ if (d) try {
181
+ let t = a(e);
182
+ if (s.middlewareHeaders) for (let [e, n] of Object.entries(s.middlewareHeaders)) t.headers.set(e, n);
183
+ let { html: i, clearActionErrorCookie: o } = await n({
184
+ route: d.route,
185
+ params: d.params,
186
+ searchParams: new URLSearchParams(e.url?.split("?")[1] ?? ""),
187
+ config: u,
188
+ importer: s.ssrLoad,
189
+ actions: c,
190
+ request: t
191
+ }), l = {
192
+ "Content-Type": "text/html; charset=utf-8",
193
+ "Cache-Control": "no-store, must-revalidate"
194
+ };
195
+ return o && (l["Set-Cookie"] = o), r.writeHead(200, l), r.end(i), !0;
196
+ } catch (e) {
197
+ console.error("[elur-kit] SSR render error:", e);
198
+ let n = await t({
199
+ routes: s.routes,
200
+ status: 500,
201
+ error: e,
202
+ config: u,
203
+ actions: c,
204
+ importer: s.ssrLoad
205
+ });
206
+ return n ? (r.writeHead(n.status, {
207
+ "Content-Type": "text/html; charset=utf-8",
208
+ "Cache-Control": "no-store, must-revalidate"
209
+ }), r.end(n.html)) : (r.writeHead(500, {
210
+ "Content-Type": "text/plain; charset=utf-8",
211
+ "Cache-Control": "no-store, must-revalidate"
212
+ }), r.end(String(e))), !0;
213
+ }
214
+ let f = await t({
215
+ routes: s.routes,
216
+ status: 404,
217
+ config: u,
218
+ actions: c,
219
+ importer: s.ssrLoad
220
+ });
221
+ return f ? (r.writeHead(f.status, {
222
+ "Content-Type": "text/html; charset=utf-8",
223
+ "Cache-Control": "no-store, must-revalidate"
224
+ }), r.end(f.html), !0) : !1;
225
+ }
226
+ //#endregion
227
+ export { m as coreSupportsPartialInterpolation, u as elurJsInterpolationPlugin, w as elurJsKit, f as shouldUseLegacyInterpolation };
228
+
229
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/vite/index.ts"],"sourcesContent":["import { mkdir, writeFile } from \"node:fs/promises\";\nimport { dirname, relative, resolve } from \"node:path\";\nimport type { Plugin, Connect, ViteDevServer } from \"vite\";\nimport { scanRoutes } from \"../router/route-scanner.js\";\nimport { scanActions, actionNames, type ActionRegistry } from \"../action/scan.js\";\nimport { handleActionRequest, type ActionSecurityOptions } from \"../action/server.js\";\nimport { scanIslands } from \"../island/scan.js\";\nimport { buildEntrySource } from \"../island/generate-entry.js\";\nimport { matchApiRoute, matchRoute } from \"../ssr/match.js\";\nimport { renderPage, renderErrorPage } from \"../ssr/render.js\";\nimport { setContentRoot, clearContentCache } from \"../content/collections.js\";\nimport { loadMiddleware, matchesMiddleware, runMiddleware, type LoadedMiddleware } from \"../middleware/index.js\";\nimport { elurJsInterpolationPlugin, shouldUseLegacyInterpolation, type InterpolationMode } from \"./interpolation-plugin.js\";\nimport { incomingMessageToRequest } from \"../runtime/node-http.js\";\n\nexport interface ElurJsKitViteOptions {\n /** App directory relative to Vite root (default: src/app). */\n appDir?: string;\n /** Islands directory relative to Vite root (default: src/islands). */\n islandsDir?: string;\n /** Content directory relative to Vite root (default: src/content). */\n contentDir?: string;\n /** Where to write the generated client entry (default: .elur/entry-client.ts). */\n generatedEntry?: string;\n /** Public path for the client entry module (default: /_elur/entry-client.js). */\n clientEntry?: string;\n /** HTML lang attribute (default: es). */\n lang?: string;\n /** Import specifier for hydrateIslands in the generated entry. */\n hydrateImport?: string;\n /** Import specifier for startClientRouter in the generated entry. */\n routerImport?: string;\n /** CSRF / origin policy applied to the server actions endpoint in dev. */\n actionSecurity?: ActionSecurityOptions;\n /**\n * How the legacy interpolation transform is handled (default: \"auto\").\n * With a Elur core that supports partial attribute interpolation natively\n * the transform is not applied; use \"legacy\" for migrations against older\n * cores and \"off\" to never transform.\n */\n interpolation?: InterpolationMode;\n}\n\n/**\n * Official Vite plugin for elur-kit.\n *\n * In dev mode it generates the islands entry and renders every page via SSR.\n * In production builds it can be combined with `elur-kit build` to generate\n * static HTML files.\n */\nexport function elurJsKit(options: ElurJsKitViteOptions = {}): Plugin[] {\n const appDir = options.appDir ?? \"src/app\";\n const islandsDir = options.islandsDir ?? \"src/islands\";\n const contentDir = options.contentDir ?? \"src/content\";\n const generatedEntry = options.generatedEntry ?? \".elur/entry-client.ts\";\n const clientEntry = options.clientEntry ?? \"/_elur/entry-client.js\";\n const lang = options.lang ?? \"es\";\n const hydrateImport = options.hydrateImport ?? \"@elurjs/kit/island\";\n const routerImport = options.routerImport ?? \"@elurjs/kit/router\";\n\n let routes: Awaited<ReturnType<typeof scanRoutes>> | null = null;\n let actions: ActionRegistry = {};\n let root: string = \".\";\n let middleware: LoadedMiddleware | null = null;\n\n const mainPlugin: Plugin = {\n name: \"elur-kit\",\n enforce: \"pre\",\n\n async configResolved(config) {\n root = config.root;\n const entryPath = resolve(root, generatedEntry);\n const islands = await scanIslands(resolve(root, islandsDir));\n const source = buildEntrySource(islands, entryPath, hydrateImport, routerImport);\n await mkdir(dirname(entryPath), { recursive: true });\n await writeFile(entryPath, source, \"utf8\");\n\n const appDirPath = resolve(root, appDir);\n routes = await scanRoutes(appDirPath);\n actions = await scanActions(appDirPath);\n\n // Wire up the content layer root so getCollection/getEntry resolve\n // from the user's src/content directory.\n setContentRoot(resolve(root, contentDir));\n\n // Load user middleware (src/middleware.ts) if it exists.\n middleware = await loadMiddleware(root);\n },\n\n configureServer(server) {\n const ssrLoad = createSsrLoader(server, root);\n const resolveAction = createActionResolver(() => actions, () => routes, ssrLoad);\n\n const appDirPath = resolve(root, appDir);\n const islandsDirPath = resolve(root, islandsDir);\n const contentDirPath = resolve(root, contentDir);\n setupHmr(server, appDirPath, islandsDirPath, contentDirPath, root, generatedEntry, hydrateImport, routerImport, () => {\n routes = null;\n actions = {};\n clearContentCache();\n });\n\n server.middlewares.use(async (req, res, next) => {\n const requestUrl = new URL(req.url ?? \"/\", `http://${req.headers.host ?? \"localhost\"}`);\n const urlPath = requestUrl.pathname;\n\n // Server actions endpoint.\n if (urlPath === \"/__elur-js/actions\" && req.method === \"POST\") {\n try {\n const body = await readRequestBody(req);\n const request = incomingMessageToRequest(req, body);\n const response = await handleActionRequest(request, resolveAction, options.actionSecurity);\n res.writeHead(response.status, Object.fromEntries(response.headers.entries()));\n res.end(await response.text());\n } catch (err) {\n console.error(\"[elur-kit] action error:\", err);\n res.writeHead(500, { \"Content-Type\": \"text/plain; charset=utf-8\" });\n res.end(String(err));\n }\n return;\n }\n\n if (urlPath.startsWith(\"/_elur/entry-client.js\")) {\n const transformed = await server.transformRequest(\n \"/.elur/entry-client.ts\",\n );\n if (transformed) {\n res.writeHead(200, {\n \"Content-Type\": \"application/javascript; charset=utf-8\",\n \"Cache-Control\": \"no-store, must-revalidate\",\n });\n res.end(transformed.code);\n return;\n }\n }\n\n const currentRoutes = routes ?? (routes = await scanRoutes(appDirPath));\n const currentActions = Object.keys(actions).length ? actions : (actions = await scanActions(appDirPath));\n\n // Render endpoint used by the SPA router and streaming boundaries.\n if (urlPath === \"/__elur-js/render\") {\n const { renderPageBody, RouteNotFoundError } = await import(\"../ssr/stream.js\");\n try {\n const page = requestUrl.searchParams.get(\"page\") ?? \"/\";\n const search = requestUrl.searchParams.get(\"search\") ?? \"\";\n const wantsJson = (req.headers[\"accept\"] ?? \"\").includes(\"application/json\");\n const request = incomingMessageToRequest(req);\n const { body, title, head, clearActionErrorCookie } = await renderPageBody({\n routes: currentRoutes,\n pathname: page,\n searchParams: new URLSearchParams(search),\n config: { lang, clientEntry },\n actions: actionNames(currentActions),\n importer: ssrLoad,\n request,\n });\n if (wantsJson) {\n const headers: Record<string, string> = { \"Content-Type\": \"application/json; charset=utf-8\" };\n if (clearActionErrorCookie) headers[\"X-Elur-Action-Clear-Cookie\"] = clearActionErrorCookie;\n res.writeHead(200, headers);\n res.end(JSON.stringify({ title, body, head, clearActionErrorCookie }));\n } else {\n const headers: Record<string, string> = { \"Content-Type\": \"text/html; charset=utf-8\" };\n if (clearActionErrorCookie) headers[\"Set-Cookie\"] = clearActionErrorCookie;\n res.writeHead(200, headers);\n res.end(body);\n }\n return;\n } catch (err) {\n if (err instanceof RouteNotFoundError) {\n res.writeHead(404, { \"Content-Type\": \"text/plain; charset=utf-8\" });\n res.end(\"Not Found\");\n return;\n }\n console.error(\"[elur-kit] render endpoint error:\", err);\n res.writeHead(500, { \"Content-Type\": \"text/plain; charset=utf-8\" });\n res.end(String(err));\n return;\n }\n }\n\n if (!urlPath.startsWith(\"/@\") && !urlPath.startsWith(\"/node_modules/\") && !urlPath.includes(\".\")) {\n const apiMatch = matchApiRoute(urlPath, currentRoutes.api);\n if (apiMatch) {\n try {\n const mod = (await ssrLoad(apiMatch.route.routePath)) as Record<\n string,\n (request: Request, context?: { params: Record<string, string | string[]> }) => unknown\n >;\n const handler = mod[req.method ?? \"GET\"];\n if (typeof handler !== \"function\") {\n res.writeHead(405, { \"Content-Type\": \"text/plain\" });\n res.end(`Method not allowed: ${req.method}`);\n return;\n }\n const body = req.method && req.method !== \"GET\" && req.method !== \"HEAD\" ? await readRequestBody(req) : undefined;\n const request = incomingMessageToRequest(req, body);\n const response = (await handler(request, { params: apiMatch.params })) as Response;\n res.writeHead(response.status, Object.fromEntries(response.headers.entries()));\n res.end(Buffer.from(await response.arrayBuffer()));\n } catch (err) {\n console.error(\"[elur-kit] API route error:\", err);\n res.writeHead(500, { \"Content-Type\": \"text/plain; charset=utf-8\" });\n res.end(String(err));\n }\n return;\n }\n }\n\n // Run middleware before SSR rendering.\n let middlewareHeaders: Record<string, string> | undefined;\n if (middleware && matchesMiddleware(urlPath, middleware.config)) {\n const mwResult = await runMiddleware(middleware, incomingMessageToRequest(req));\n if (mwResult.kind === \"response\") {\n res.writeHead(mwResult.response.status, Object.fromEntries(mwResult.response.headers.entries()));\n res.end(Buffer.from(await mwResult.response.arrayBuffer()));\n return;\n }\n middlewareHeaders = mwResult.headers;\n }\n\n const handled = await handleSsrRequest(req, res, next, {\n routes: currentRoutes,\n actions: currentActions,\n clientEntry,\n lang,\n ssrLoad,\n middlewareHeaders,\n });\n if (!handled) next();\n });\n },\n };\n\n return shouldUseLegacyInterpolation(options.interpolation ?? \"auto\")\n ? [mainPlugin, elurJsInterpolationPlugin({ appDir, islandsDir })]\n : [mainPlugin];\n}\n\nexport { elurJsInterpolationPlugin, type InterpolationPluginOptions } from \"./interpolation-plugin.js\";\nexport type { InterpolationMode } from \"./interpolation-plugin.js\";\nexport { coreSupportsPartialInterpolation, shouldUseLegacyInterpolation } from \"./interpolation-plugin.js\";\n\nfunction setupHmr(\n server: ViteDevServer,\n appDirPath: string,\n islandsDirPath: string,\n contentDirPath: string,\n root: string,\n generatedEntry: string,\n hydrateImport: string,\n routerImport: string,\n invalidate: () => void,\n) {\n const isRelevant = (path: string) =>\n path.startsWith(appDirPath) || path.startsWith(islandsDirPath) || path.startsWith(contentDirPath);\n\n async function regenerateIslandEntry() {\n const islands = await scanIslands(islandsDirPath);\n const entryPath = resolve(root, generatedEntry);\n const source = buildEntrySource(islands, entryPath, hydrateImport, routerImport);\n await mkdir(dirname(entryPath), { recursive: true });\n await writeFile(entryPath, source, \"utf8\");\n const entryMod = server.moduleGraph.getModuleById(entryPath);\n if (entryMod) server.moduleGraph.invalidateModule(entryMod);\n }\n\n server.watcher.on(\"change\", async (path) => {\n if (!isRelevant(path)) return;\n invalidate();\n const mod = server.moduleGraph.getModuleById(path);\n if (mod) server.moduleGraph.invalidateModule(mod);\n if (path.startsWith(islandsDirPath)) {\n await regenerateIslandEntry();\n console.log(\"[elur-kit] HMR reload islands after change:\", path);\n } else if (path.startsWith(contentDirPath) && path.endsWith(\".md\")) {\n console.log(\"[elur-kit] HMR content changed:\", path);\n } else if (path.includes(\".action.ts\") || path.includes(\".data.ts\") || path.includes(\"page.ts\") || path.includes(\"layout.ts\")) {\n console.log(\"[elur-kit] HMR reload routes/actions after change:\", path);\n }\n });\n\n server.watcher.on(\"add\", async (path) => {\n if (!isRelevant(path)) return;\n invalidate();\n if (path.startsWith(islandsDirPath)) {\n await regenerateIslandEntry();\n }\n console.log(\"[elur-kit] HMR new file detected:\", path);\n });\n\n server.watcher.on(\"unlink\", async (path) => {\n if (!isRelevant(path)) return;\n invalidate();\n const mod = server.moduleGraph.getModuleById(path);\n if (mod) server.moduleGraph.invalidateModule(mod);\n if (path.startsWith(islandsDirPath)) {\n await regenerateIslandEntry();\n }\n console.log(\"[elur-kit] HMR file removed:\", path);\n });\n}\n\nfunction createSsrLoader(server: ViteDevServer, root: string) {\n return (filePath: string) => {\n const rel = relative(root, filePath);\n const url = \"/\" + rel.split(\"\\\\\").join(\"/\");\n return server.ssrLoadModule(url);\n };\n}\n\nfunction createActionResolver(\n getActions: () => import(\"../action/scan.js\").ActionRegistry,\n getRoutes: () => Awaited<ReturnType<typeof scanRoutes>> | null,\n ssrLoad: (path: string) => Promise<unknown>,\n) {\n return async (name: string, page?: string) => {\n const actions = getActions();\n const routes = getRoutes();\n let pageKey: string | undefined;\n if (page && routes) {\n pageKey = routes.pages.some((route) => route.path === page)\n ? page\n : (matchRoute(page, routes.pages)?.route.path ?? page);\n }\n const pageActions = pageKey ? actions[pageKey] : Object.values(actions).find((p) => p[name]) ?? undefined;\n const actionPath = pageActions ? pageActions[name] : undefined;\n if (!actionPath) return undefined;\n const mod = (await ssrLoad(actionPath)) as Record<string, unknown>;\n const action = mod[name];\n if (typeof action === \"function\") {\n return action as (...args: unknown[]) => unknown;\n }\n return undefined;\n };\n}\n\nfunction readRequestBody(req: Connect.IncomingMessage): Promise<string> {\n return new Promise((resolve, reject) => {\n let body = \"\";\n req.setEncoding(\"utf8\");\n req.on(\"data\", (chunk) => {\n body += chunk;\n });\n req.on(\"end\", () => resolve(body));\n req.on(\"error\", reject);\n });\n}\n\ninterface SsrHandlerOptions {\n routes: Awaited<ReturnType<typeof scanRoutes>> | null;\n actions: ActionRegistry;\n clientEntry: string;\n lang: string;\n ssrLoad: (path: string) => Promise<unknown>;\n middlewareHeaders?: Record<string, string>;\n}\n\nasync function handleSsrRequest(\n req: Connect.IncomingMessage,\n res: import(\"node:http\").ServerResponse,\n _next: Connect.NextFunction,\n options: SsrHandlerOptions,\n): Promise<boolean> {\n if (!options.routes) return false;\n const publicActions = actionNames(options.actions);\n\n let urlPath = req.url ?? \"/\";\n if (urlPath.includes(\"?\")) urlPath = urlPath.split(\"?\")[0];\n\n // Let Vite handle its own internals and assets.\n if (urlPath.startsWith(\"/@\") || urlPath.startsWith(\"/node_modules/\")) {\n return false;\n }\n\n // Skip explicit file requests.\n if (urlPath.includes(\".\")) return false;\n\n const config = { lang: options.lang, clientEntry: options.clientEntry };\n const match = matchRoute(urlPath, options.routes.pages);\n if (match) {\n try {\n const request = incomingMessageToRequest(req);\n if (options.middlewareHeaders) {\n for (const [name, value] of Object.entries(options.middlewareHeaders)) request.headers.set(name, value);\n }\n const { html, clearActionErrorCookie } = await renderPage({\n route: match.route,\n params: match.params,\n searchParams: new URLSearchParams(req.url?.split(\"?\")[1] ?? \"\"),\n config,\n importer: options.ssrLoad,\n actions: publicActions,\n request,\n });\n const responseHeaders: Record<string, string> = {\n \"Content-Type\": \"text/html; charset=utf-8\",\n \"Cache-Control\": \"no-store, must-revalidate\",\n };\n if (clearActionErrorCookie) responseHeaders[\"Set-Cookie\"] = clearActionErrorCookie;\n res.writeHead(200, responseHeaders);\n res.end(html);\n return true;\n } catch (err) {\n console.error(\"[elur-kit] SSR render error:\", err);\n const errorResult = await renderErrorPage({\n routes: options.routes,\n status: 500,\n error: err,\n config,\n actions: publicActions,\n importer: options.ssrLoad,\n });\n if (errorResult) {\n res.writeHead(errorResult.status, {\n \"Content-Type\": \"text/html; charset=utf-8\",\n \"Cache-Control\": \"no-store, must-revalidate\",\n });\n res.end(errorResult.html);\n } else {\n res.writeHead(500, {\n \"Content-Type\": \"text/plain; charset=utf-8\",\n \"Cache-Control\": \"no-store, must-revalidate\",\n });\n res.end(String(err));\n }\n return true;\n }\n }\n\n const errorResult = await renderErrorPage({\n routes: options.routes,\n status: 404,\n config,\n actions: publicActions,\n importer: options.ssrLoad,\n });\n if (errorResult) {\n res.writeHead(errorResult.status, {\n \"Content-Type\": \"text/html; charset=utf-8\",\n \"Cache-Control\": \"no-store, must-revalidate\",\n });\n res.end(errorResult.html);\n return true;\n }\n\n return false;\n}\n"],"mappings":";;;;;;;;;AAkDA,SAAgB,EAAU,IAAgC,CAAC,GAAa;CACtE,IAAM,IAAS,EAAQ,UA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I,GACF,IAAI;EACF,IAAM,IAAU,EAAyB,CAAG;EAC5C,IAAI,EAAQ,mBACV,KAAK,IAAM,CAAC,GAAM,MAAU,OAAO,QAAQ,EAAQ,iBAAiB,GAAG,EAAQ,QAAQ,IAAI,GAAM,CAAK;EAExG,IAAM,EAAE,SAAM,8BAA2B,MAAM,EAAW;GACxD,OAAO,EAAM;GACb,QAAQ,EAAM;GACd,cAAc,IAAI,gBAAgB,EAAI,KAAK,MAAM,GAAG,CAAC,CAAC,MAAM,EAAE;GAC9D;GACA,UAAU,EAAQ;GAClB,SAAS;GACT;EACF,CAAC,GACK,IAA0C;GAC9C,gBAAgB;GAChB,iBAAiB;EACnB;EAIA,OAHI,MAAwB,EAAgB,gBAAgB,IAC5D,EAAI,UAAU,KAAK,CAAe,GAClC,EAAI,IAAI,CAAI,GACL;CACT,SAAS,GAAK;EACZ,QAAQ,MAAM,gCAAgC,CAAG;EACjD,IAAM,IAAc,MAAM,EAAgB;GACxC,QAAQ,EAAQ;GAChB,QAAQ;GACR,OAAO;GACP;GACA,SAAS;GACT,UAAU,EAAQ;EACpB,CAAC;EAcD,OAbI,KACF,EAAI,UAAU,EAAY,QAAQ;GAChC,gBAAgB;GAChB,iBAAiB;EACnB,CAAC,GACD,EAAI,IAAI,EAAY,IAAI,MAExB,EAAI,UAAU,KAAK;GACjB,gBAAgB;GAChB,iBAAiB;EACnB,CAAC,GACD,EAAI,IAAI,OAAO,CAAG,CAAC,IAEd;CACT;CAGF,IAAM,IAAc,MAAM,EAAgB;EACxC,QAAQ,EAAQ;EAChB,QAAQ;EACR;EACA,SAAS;EACT,UAAU,EAAQ;CACpB,CAAC;CAUD,OATI,KACF,EAAI,UAAU,EAAY,QAAQ;EAChC,gBAAgB;EAChB,iBAAiB;CACnB,CAAC,GACD,EAAI,IAAI,EAAY,IAAI,GACjB,MAGF;AACT"}
@@ -0,0 +1,64 @@
1
+ import type { Plugin } from "vite";
2
+ /**
3
+ * How the legacy interpolation transform is handled relative to the installed
4
+ * Elur core and Vite plugin:
5
+ *
6
+ * - `"auto"` (default): the kit's legacy transform is only applied when the
7
+ * Vite plugin (`@elurjs/vite-plugin-elur` >= 1.1.0) is NOT installed.
8
+ * The plugin has a more powerful state-machine lexer and takes precedence.
9
+ * - `"legacy"`: always apply the kit's transform (for migrations), with a
10
+ * one-time deprecation warning.
11
+ * - `"off"`: never apply the kit's transform. Recommended when the Vite
12
+ * plugin is installed.
13
+ */
14
+ export type InterpolationMode = "auto" | "legacy" | "off";
15
+ /**
16
+ * Detects whether the Vite plugin (`@elurjs/vite-plugin-elur`) is
17
+ * installed and provides compile-time partial attribute interpolation.
18
+ */
19
+ export declare function pluginSupportsPartialInterpolation(): boolean;
20
+ /**
21
+ * Detects whether the installed Elur core supports partial attribute
22
+ * interpolation natively (via the public `templateFeatures` capability).
23
+ * Note: as of core v3.4.0, this is always false — the lexer moved to the
24
+ * Vite plugin.
25
+ */
26
+ export declare function coreSupportsPartialInterpolation(): boolean;
27
+ /**
28
+ * Resolves whether the kit's legacy transform should be applied.
29
+ *
30
+ * In `"auto"` mode, the kit's transform runs only when neither the Vite
31
+ * plugin nor the core provides partial interpolation. When the Vite plugin
32
+ * is installed (>= 1.1.0), it takes precedence and the kit's transform is
33
+ * skipped to avoid double-processing.
34
+ */
35
+ export declare function shouldUseLegacyInterpolation(mode: InterpolationMode): boolean;
36
+ /**
37
+ * Transforms Elur `html\`\`` templates so that attributes with partial
38
+ * interpolation become a single interpolation expression.
39
+ *
40
+ * Elur requires every dynamic attribute to be a single interpolation covering
41
+ * the whole value. This plugin rewrites patterns such as:
42
+ *
43
+ * html\`<a href="/blog/${slug}">...</a>\`
44
+ *
45
+ * into:
46
+ *
47
+ * html\`<a href=${"/blog/" + slug}>...</a>\`
48
+ *
49
+ * Only files inside the app and islands directories are processed.
50
+ *
51
+ * @deprecated Elur core supports partial attribute interpolation natively.
52
+ * Keep this transform only for migrations against older cores
53
+ * (`interpolation: "legacy"`).
54
+ */
55
+ export interface InterpolationPluginOptions {
56
+ appDir?: string;
57
+ islandsDir?: string;
58
+ }
59
+ /**
60
+ * @deprecated Use the native partial attribute interpolation of Elur core
61
+ * (core >= 3.3). Kept for legacy migrations and direct consumers.
62
+ */
63
+ export declare function transformPartialInterpolations(source: string): string;
64
+ export declare function elurJsInterpolationPlugin(options?: InterpolationPluginOptions): Plugin;
@@ -0,0 +1,64 @@
1
+ import type { Plugin } from "vite";
2
+ /**
3
+ * How the legacy interpolation transform is handled relative to the installed
4
+ * Elur core and Vite plugin:
5
+ *
6
+ * - `"auto"` (default): the kit's legacy transform is only applied when the
7
+ * Vite plugin (`@elurjs/vite-plugin-elur` >= 1.1.0) is NOT installed.
8
+ * The plugin has a more powerful state-machine lexer and takes precedence.
9
+ * - `"legacy"`: always apply the kit's transform (for migrations), with a
10
+ * one-time deprecation warning.
11
+ * - `"off"`: never apply the kit's transform. Recommended when the Vite
12
+ * plugin is installed.
13
+ */
14
+ export type InterpolationMode = "auto" | "legacy" | "off";
15
+ /**
16
+ * Detects whether the Vite plugin (`@elurjs/vite-plugin-elur`) is
17
+ * installed and provides compile-time partial attribute interpolation.
18
+ */
19
+ export declare function pluginSupportsPartialInterpolation(): boolean;
20
+ /**
21
+ * Detects whether the installed Elur core supports partial attribute
22
+ * interpolation natively (via the public `templateFeatures` capability).
23
+ * Note: as of core v3.4.0, this is always false — the lexer moved to the
24
+ * Vite plugin.
25
+ */
26
+ export declare function coreSupportsPartialInterpolation(): boolean;
27
+ /**
28
+ * Resolves whether the kit's legacy transform should be applied.
29
+ *
30
+ * In `"auto"` mode, the kit's transform runs only when neither the Vite
31
+ * plugin nor the core provides partial interpolation. When the Vite plugin
32
+ * is installed (>= 1.1.0), it takes precedence and the kit's transform is
33
+ * skipped to avoid double-processing.
34
+ */
35
+ export declare function shouldUseLegacyInterpolation(mode: InterpolationMode): boolean;
36
+ /**
37
+ * Transforms Elur `html\`\`` templates so that attributes with partial
38
+ * interpolation become a single interpolation expression.
39
+ *
40
+ * Elur requires every dynamic attribute to be a single interpolation covering
41
+ * the whole value. This plugin rewrites patterns such as:
42
+ *
43
+ * html\`<a href="/blog/${slug}">...</a>\`
44
+ *
45
+ * into:
46
+ *
47
+ * html\`<a href=${"/blog/" + slug}>...</a>\`
48
+ *
49
+ * Only files inside the app and islands directories are processed.
50
+ *
51
+ * @deprecated Elur core supports partial attribute interpolation natively.
52
+ * Keep this transform only for migrations against older cores
53
+ * (`interpolation: "legacy"`).
54
+ */
55
+ export interface InterpolationPluginOptions {
56
+ appDir?: string;
57
+ islandsDir?: string;
58
+ }
59
+ /**
60
+ * @deprecated Use the native partial attribute interpolation of Elur core
61
+ * (core >= 3.3). Kept for legacy migrations and direct consumers.
62
+ */
63
+ export declare function transformPartialInterpolations(source: string): string;
64
+ export declare function elurJsInterpolationPlugin(options?: InterpolationPluginOptions): Plugin;