@velastack/patterns 0.6.0 → 0.7.0

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 (142) hide show
  1. package/README.md +11 -0
  2. package/dist/chunks/{_layout-D-FzWqn0.js → _layout-Bsx3eNrC.js} +3 -3
  3. package/dist/chunks/{_layout-D-FzWqn0.js.map → _layout-Bsx3eNrC.js.map} +1 -1
  4. package/dist/chunks/{auth-pages-B52ei-4z.js → auth-pages-jsyDV1GR.js} +7 -10
  5. package/dist/chunks/{auth-pages-B52ei-4z.js.map → auth-pages-jsyDV1GR.js.map} +1 -1
  6. package/dist/chunks/collections-BrEA7a62.js +309 -0
  7. package/dist/chunks/collections-BrEA7a62.js.map +1 -0
  8. package/dist/chunks/{collections-B_DisSfA.js → collections-DrUG8ngq.js} +39 -35
  9. package/dist/chunks/collections-DrUG8ngq.js.map +1 -0
  10. package/dist/chunks/{compose-handle-BDlZ7Pif.js → compose-handle-BBlamPfx.js} +18 -22
  11. package/dist/chunks/{compose-handle-BDlZ7Pif.js.map → compose-handle-BBlamPfx.js.map} +1 -1
  12. package/dist/chunks/{config-target-rHgjaA8u.js → config-target-BgyFkbFL.js} +2 -2
  13. package/dist/chunks/{config-target-rHgjaA8u.js.map → config-target-BgyFkbFL.js.map} +1 -1
  14. package/dist/chunks/dedent-Gq6Krl4n.js.map +1 -1
  15. package/dist/chunks/{env-BPfk1VAw.js → env-BugddEjd.js} +5 -9
  16. package/dist/chunks/{env-BPfk1VAw.js.map → env-BugddEjd.js.map} +1 -1
  17. package/dist/chunks/{env-vars-cqQU0ECK.js → env-vars-CdarYsrc.js} +6 -11
  18. package/dist/chunks/{env-vars-cqQU0ECK.js.map → env-vars-CdarYsrc.js.map} +1 -1
  19. package/dist/chunks/{generate-CXoQPz7n.js → generate-27CjLiGW.js} +2 -2
  20. package/dist/chunks/{generate-CXoQPz7n.js.map → generate-27CjLiGW.js.map} +1 -1
  21. package/dist/chunks/{generate-Bm_jOMtF.js → generate-BFcy2wrS.js} +2 -2
  22. package/dist/chunks/{generate-Bm_jOMtF.js.map → generate-BFcy2wrS.js.map} +1 -1
  23. package/dist/chunks/generate-BxOzEdc_.js +171 -0
  24. package/dist/chunks/generate-BxOzEdc_.js.map +1 -0
  25. package/dist/chunks/generate-D3mSFPdT.js.map +1 -1
  26. package/dist/chunks/{generate-jx5Iuq5w.js → generate-DdLwP0E7.js} +54 -53
  27. package/dist/chunks/generate-DdLwP0E7.js.map +1 -0
  28. package/dist/chunks/generate-DyV5R8NP.js.map +1 -1
  29. package/dist/chunks/{generate.runtime-Dug2UIhV.js → generate.runtime-9KuMcI5r.js} +9 -12
  30. package/dist/chunks/{generate.runtime-Dug2UIhV.js.map → generate.runtime-9KuMcI5r.js.map} +1 -1
  31. package/dist/chunks/{generate.runtime-wziCW3ct.js → generate.runtime-B10-KA87.js} +5 -5
  32. package/dist/chunks/{generate.runtime-wziCW3ct.js.map → generate.runtime-B10-KA87.js.map} +1 -1
  33. package/dist/chunks/{generate.runtime-N1KtAG8C.js → generate.runtime-B8-GLMkk.js} +90 -175
  34. package/dist/chunks/generate.runtime-B8-GLMkk.js.map +1 -0
  35. package/dist/chunks/{generate.runtime-CWnIiXwV.js → generate.runtime-BGuXHl5o.js} +3 -3
  36. package/dist/chunks/{generate.runtime-CWnIiXwV.js.map → generate.runtime-BGuXHl5o.js.map} +1 -1
  37. package/dist/chunks/{generate.runtime-DCqf7nYM.js → generate.runtime-BJxM7FNA.js} +7 -7
  38. package/dist/chunks/{generate.runtime-DCqf7nYM.js.map → generate.runtime-BJxM7FNA.js.map} +1 -1
  39. package/dist/chunks/{generate.runtime-gFr2Gsjz.js → generate.runtime-BWRtyQeD.js} +5 -5
  40. package/dist/chunks/{generate.runtime-gFr2Gsjz.js.map → generate.runtime-BWRtyQeD.js.map} +1 -1
  41. package/dist/chunks/{generate.runtime-DeniHg8L.js → generate.runtime-B_tWu-Bw.js} +5 -5
  42. package/dist/chunks/{generate.runtime-DeniHg8L.js.map → generate.runtime-B_tWu-Bw.js.map} +1 -1
  43. package/dist/chunks/{generate.runtime-CyGR8VTx.js → generate.runtime-BdghkfNp.js} +3 -3
  44. package/dist/chunks/{generate.runtime-CyGR8VTx.js.map → generate.runtime-BdghkfNp.js.map} +1 -1
  45. package/dist/chunks/{generate.runtime-DY5vQ3aZ.js → generate.runtime-Blb6QPZn.js} +6 -6
  46. package/dist/chunks/{generate.runtime-DY5vQ3aZ.js.map → generate.runtime-Blb6QPZn.js.map} +1 -1
  47. package/dist/chunks/{generate.runtime-CHb4znYx.js → generate.runtime-CEexT8cJ.js} +6 -6
  48. package/dist/chunks/{generate.runtime-CHb4znYx.js.map → generate.runtime-CEexT8cJ.js.map} +1 -1
  49. package/dist/chunks/{generate.runtime-wGRE1zwZ.js → generate.runtime-CIZO2XO9.js} +4 -4
  50. package/dist/chunks/{generate.runtime-wGRE1zwZ.js.map → generate.runtime-CIZO2XO9.js.map} +1 -1
  51. package/dist/chunks/{generate.runtime-_c7daMAw.js → generate.runtime-CK0MTeqc.js} +4 -4
  52. package/dist/chunks/{generate.runtime-_c7daMAw.js.map → generate.runtime-CK0MTeqc.js.map} +1 -1
  53. package/dist/chunks/{generate.runtime-Dmob2wFf.js → generate.runtime-CMO-Skpk.js} +5 -5
  54. package/dist/chunks/{generate.runtime-Dmob2wFf.js.map → generate.runtime-CMO-Skpk.js.map} +1 -1
  55. package/dist/chunks/{generate.runtime-CkmledBw.js → generate.runtime-CVDb-yLt.js} +12 -20
  56. package/dist/chunks/{generate.runtime-CkmledBw.js.map → generate.runtime-CVDb-yLt.js.map} +1 -1
  57. package/dist/chunks/generate.runtime-C_5Ghjri.js +17 -0
  58. package/dist/chunks/generate.runtime-C_5Ghjri.js.map +1 -0
  59. package/dist/chunks/{generate.runtime-Du4uf98c.js → generate.runtime-CbOMXQSo.js} +3 -3
  60. package/dist/chunks/{generate.runtime-Du4uf98c.js.map → generate.runtime-CbOMXQSo.js.map} +1 -1
  61. package/dist/chunks/{generate.runtime-CRhD98rs.js → generate.runtime-CbT-EbQT.js} +5 -5
  62. package/dist/chunks/{generate.runtime-CRhD98rs.js.map → generate.runtime-CbT-EbQT.js.map} +1 -1
  63. package/dist/chunks/{generate.runtime-kpqW3dVO.js → generate.runtime-Cxr15Y5H.js} +8 -8
  64. package/dist/chunks/{generate.runtime-kpqW3dVO.js.map → generate.runtime-Cxr15Y5H.js.map} +1 -1
  65. package/dist/chunks/{generate.runtime-B4u9C2YH.js → generate.runtime-CyTxBcX3.js} +4 -4
  66. package/dist/chunks/{generate.runtime-B4u9C2YH.js.map → generate.runtime-CyTxBcX3.js.map} +1 -1
  67. package/dist/chunks/{generate.runtime-aN5QWygO.js → generate.runtime-D5HxAups.js} +39 -36
  68. package/dist/chunks/generate.runtime-D5HxAups.js.map +1 -0
  69. package/dist/chunks/{generate.runtime-CYBs0JgY.js → generate.runtime-D6vhkGs8.js} +5 -5
  70. package/dist/chunks/{generate.runtime-CYBs0JgY.js.map → generate.runtime-D6vhkGs8.js.map} +1 -1
  71. package/dist/chunks/{generate.runtime-B2r11K7S.js → generate.runtime-DIeAeOJg.js} +6 -6
  72. package/dist/chunks/{generate.runtime-B2r11K7S.js.map → generate.runtime-DIeAeOJg.js.map} +1 -1
  73. package/dist/chunks/{generate.runtime-FGYc365Q.js → generate.runtime-DMTAocSE.js} +6 -6
  74. package/dist/chunks/{generate.runtime-FGYc365Q.js.map → generate.runtime-DMTAocSE.js.map} +1 -1
  75. package/dist/chunks/{generate.runtime-DdcVnK8J.js → generate.runtime-DlLwmjGF.js} +133 -121
  76. package/dist/chunks/generate.runtime-DlLwmjGF.js.map +1 -0
  77. package/dist/chunks/{generate.runtime-BxUGDXIK.js → generate.runtime-DtCaz98N.js} +6 -6
  78. package/dist/chunks/{generate.runtime-BxUGDXIK.js.map → generate.runtime-DtCaz98N.js.map} +1 -1
  79. package/dist/chunks/{generate.runtime-x-o4LS8d.js → generate.runtime-HSZD935T.js} +4 -4
  80. package/dist/chunks/{generate.runtime-x-o4LS8d.js.map → generate.runtime-HSZD935T.js.map} +1 -1
  81. package/dist/chunks/{generate.runtime-bpH3DB0t.js → generate.runtime-Nnk5E8Pi.js} +3 -3
  82. package/dist/chunks/{generate.runtime-bpH3DB0t.js.map → generate.runtime-Nnk5E8Pi.js.map} +1 -1
  83. package/dist/chunks/{generate.runtime-BxDUtkpT.js → generate.runtime-NxuWvkKt.js} +4 -4
  84. package/dist/chunks/{generate.runtime-BxDUtkpT.js.map → generate.runtime-NxuWvkKt.js.map} +1 -1
  85. package/dist/chunks/{generate.runtime-DYdkrHJ1.js → generate.runtime-dFTOU_KE.js} +6 -6
  86. package/dist/chunks/{generate.runtime-DYdkrHJ1.js.map → generate.runtime-dFTOU_KE.js.map} +1 -1
  87. package/dist/chunks/{generate.runtime-DUo-pLRr.js → generate.runtime-m0m43lkL.js} +6 -6
  88. package/dist/chunks/{generate.runtime-DUo-pLRr.js.map → generate.runtime-m0m43lkL.js.map} +1 -1
  89. package/dist/chunks/{generate.runtime-Bh9Z2cRN.js → generate.runtime-si5Za61F.js} +3 -3
  90. package/dist/chunks/{generate.runtime-Bh9Z2cRN.js.map → generate.runtime-si5Za61F.js.map} +1 -1
  91. package/dist/chunks/{generate.runtime-BRCzUO94.js → generate.runtime-tGKorg85.js} +10 -14
  92. package/dist/chunks/{generate.runtime-BRCzUO94.js.map → generate.runtime-tGKorg85.js.map} +1 -1
  93. package/dist/chunks/{generate.runtime-BVavIXtX.js → generate.runtime-ww3-1FWf.js} +6 -6
  94. package/dist/chunks/{generate.runtime-BVavIXtX.js.map → generate.runtime-ww3-1FWf.js.map} +1 -1
  95. package/dist/chunks/{modify-file-289rStJ2.js → modify-file-COBp4eCh.js} +4 -4
  96. package/dist/chunks/{modify-file-289rStJ2.js.map → modify-file-COBp4eCh.js.map} +1 -1
  97. package/dist/chunks/{modify-nav-user-B8h8WTrM.js → modify-nav-user-CJ1LevSU.js} +2 -2
  98. package/dist/chunks/{modify-nav-user-B8h8WTrM.js.map → modify-nav-user-CJ1LevSU.js.map} +1 -1
  99. package/dist/chunks/{modify-svelte-config-remote-DhuRX4FI.js → modify-svelte-config-remote-CEyYydL7.js} +2 -2
  100. package/dist/chunks/{modify-svelte-config-remote-DhuRX4FI.js.map → modify-svelte-config-remote-CEyYydL7.js.map} +1 -1
  101. package/dist/chunks/{modify-user-signup-BbqTiUuA.js → modify-user-signup-DLtopazD.js} +2 -2
  102. package/dist/chunks/{modify-user-signup-BbqTiUuA.js.map → modify-user-signup-DLtopazD.js.map} +1 -1
  103. package/dist/chunks/{package-imports-Bbw3iMPg.js → package-imports-Dx05A-4S.js} +2 -2
  104. package/dist/chunks/{package-imports-Bbw3iMPg.js.map → package-imports-Dx05A-4S.js.map} +1 -1
  105. package/dist/chunks/{pocketbase-B017Cqjq.js → pocketbase-DL02rq73.js} +4 -12
  106. package/dist/chunks/{pocketbase-B017Cqjq.js.map → pocketbase-DL02rq73.js.map} +1 -1
  107. package/dist/chunks/{providers-CN5J5_fY.js → providers-CAehyySB.js} +2 -2
  108. package/dist/chunks/{providers-CN5J5_fY.js.map → providers-CAehyySB.js.map} +1 -1
  109. package/dist/chunks/{rolldown-runtime-DArdT4gl.js → rolldown-runtime-5HNE8Q1r.js} +1 -1
  110. package/dist/chunks/{shared-BPlAVf-T.js → shared-C_Fr8wph.js} +2 -2
  111. package/dist/chunks/{shared-BPlAVf-T.js.map → shared-C_Fr8wph.js.map} +1 -1
  112. package/dist/chunks/{site-DkU1-VRq.js → site-BoujshKo.js} +2 -2
  113. package/dist/chunks/{site-DkU1-VRq.js.map → site-BoujshKo.js.map} +1 -1
  114. package/dist/chunks/{table-core-vXEjJDYP.js → table-core-BPv_RYgD.js} +2 -2
  115. package/dist/chunks/{table-core-vXEjJDYP.js.map → table-core-BPv_RYgD.js.map} +1 -1
  116. package/dist/chunks/{taggedTemplateLiteral-CswN2AAa.js → taggedTemplateLiteral-KSUnuvOk.js} +1 -1
  117. package/dist/chunks/{test-setup-CAfgVlwc.js → test-setup-pYUIfWb2.js} +4 -4
  118. package/dist/chunks/{test-setup-CAfgVlwc.js.map → test-setup-pYUIfWb2.js.map} +1 -1
  119. package/dist/chunks/{ts-morph-helpers-Bepc-Es2.js → ts-morph-helpers-CHI9wAil.js} +7 -11
  120. package/dist/chunks/{ts-morph-helpers-Bepc-Es2.js.map → ts-morph-helpers-CHI9wAil.js.map} +1 -1
  121. package/dist/chunks/{ui-CTdsenEv.js → ui-B2yn8c_-.js} +3 -3
  122. package/dist/chunks/{ui-CTdsenEv.js.map → ui-B2yn8c_-.js.map} +1 -1
  123. package/dist/chunks/{unmodify-load-Bl5vXQiL.js → unmodify-load-Buak-r1f.js} +2 -2
  124. package/dist/chunks/{unmodify-load-Bl5vXQiL.js.map → unmodify-load-Buak-r1f.js.map} +1 -1
  125. package/dist/chunks/{write-result-0HYIr5a6.js → write-result-Bn4bnrBI.js} +19 -49
  126. package/dist/chunks/write-result-Bn4bnrBI.js.map +1 -0
  127. package/dist/chunks/wuchale-config-c3Q4JVSF.js +50 -0
  128. package/dist/chunks/wuchale-config-c3Q4JVSF.js.map +1 -0
  129. package/dist/index.d.ts +162 -1
  130. package/dist/index.js +2001 -2176
  131. package/dist/index.js.map +1 -1
  132. package/package.json +2 -2
  133. package/dist/chunks/collections-B_DisSfA.js.map +0 -1
  134. package/dist/chunks/generate-8FS2ROOJ.js +0 -170
  135. package/dist/chunks/generate-8FS2ROOJ.js.map +0 -1
  136. package/dist/chunks/generate-jx5Iuq5w.js.map +0 -1
  137. package/dist/chunks/generate.runtime-DdcVnK8J.js.map +0 -1
  138. package/dist/chunks/generate.runtime-N1KtAG8C.js.map +0 -1
  139. package/dist/chunks/generate.runtime-aN5QWygO.js.map +0 -1
  140. package/dist/chunks/shopify-page-D-VFwGxI.js +0 -11
  141. package/dist/chunks/shopify-page-D-VFwGxI.js.map +0 -1
  142. package/dist/chunks/write-result-0HYIr5a6.js.map +0 -1
@@ -1,58 +1,59 @@
1
1
  import { a as e } from "./util-BLYliuUK.js";
2
2
  import { t } from "./providers-CL9kQ4hp.js";
3
- import { A as n, B as r, C as i, D as a, E as o, F as s, I as c, L as l, M as u, N as d, O as f, P as p, R as m, S as h, T as g, V as _, _ as v, a as y, b, c as x, d as S, f as C, g as w, h as T, j as E, k as D, l as O, m as k, n as A, o as j, p as M, s as N, u as P, v as F, w as I, x as L, y as R, z } from "./generate-8FS2ROOJ.js";
4
- import { t as B } from "./stripe-customer-B3tP8gtD.js";
5
- import { n as V, t as H } from "./_page-DoPdZgZv.js";
3
+ import { A as n, B as r, C as i, D as a, E as o, F as s, H as c, I as l, L as u, M as d, N as f, O as p, P as m, R as h, S as g, T as _, V as v, _ as y, a as b, b as x, c as S, d as C, f as w, g as T, h as E, j as D, k as O, l as k, m as A, n as j, o as M, p as N, s as P, u as F, v as I, w as L, x as R, y as z, z as B } from "./generate-BxOzEdc_.js";
4
+ import { t as V } from "./stripe-customer-B3tP8gtD.js";
5
+ import { n as H, t as U } from "./_page-DoPdZgZv.js";
6
6
  //#region src/patterns/disable/payments/generate.ts
7
- var U = /* #__PURE__ */ Object.assign({
8
- "../../enable/payments/providers/shopify/src/lib/components/payments/buy-button.svelte": _,
9
- "../../enable/payments/providers/shopify/src/lib/shopify.ts": r,
10
- "../../enable/payments/providers/stripe/src/lib/components/payments/confirm-dialog.svelte": z,
11
- "../../enable/payments/providers/stripe/src/lib/components/payments/payment-button.svelte": m,
12
- "../../enable/payments/providers/stripe/src/lib/components/payments/payment-dialog.svelte": l,
13
- "../../enable/payments/providers/stripe/src/lib/components/payments/stripe-constants.ts": c,
14
- "../../enable/payments/providers/stripe/src/lib/components/payments/stripe-payment-form.svelte": s,
15
- "../../enable/payments/providers/stripe/src/lib/components/payments/use-payment-intent.svelte.ts": p,
16
- "../../enable/payments/providers/stripe/src/lib/components/payments/use-stripe.svelte.ts": d,
17
- "../../enable/payments/providers/stripe/src/lib/stripe.ts": u,
18
- "../../enable/payments/providers/stripe/src/lib/workflows/stripe-event.ts": E,
19
- "../../enable/payments/providers/stripe/src/lib/workflows/sync-stripe-catalog.ts": n,
20
- "../../enable/payments/providers/stripe/src/routes/api/stripe/payment-intent/+server.ts": D,
21
- "../../enable/payments/providers/stripe/src/routes/api/stripe/payment-intent/server.test.ts": f,
22
- "../../enable/payments/providers/stripe/src/routes/webhooks/stripe/+server.ts": a,
23
- "../../enable/payments/providers/stripe/src/routes/webhooks/stripe/handlers/dispatch.ts": o,
24
- "../../enable/payments/providers/stripe/src/routes/webhooks/stripe/handlers/payment-intent/server.test.ts": g,
25
- "../../enable/payments/providers/stripe/src/routes/webhooks/stripe/handlers/payment-intent/succeeded.ts": I,
26
- "../../enable/payments/providers/stripe/src/routes/webhooks/stripe/server.test.ts": i,
27
- "../../enable/payments/providers/whatsapp/src/lib/components/payments/customer-fields.svelte": h,
28
- "../../enable/payments/providers/whatsapp/src/lib/components/payments/order-button.svelte": L,
29
- "../../enable/payments/providers/whatsapp/src/lib/order.ts": b,
30
- "../../enable/payments/providers-app-mode/stripe/src/lib/components/payments/setup-button.svelte": R,
31
- "../../enable/payments/providers-app-mode/stripe/src/lib/components/payments/setup-dialog.svelte": F,
32
- "../../enable/payments/providers-app-mode/stripe/src/lib/server/stripe-customer.ts": B,
33
- "../../enable/payments/providers-app-mode/stripe/src/lib/workflows/link-stripe-customer.ts": v,
34
- "../../enable/payments/providers-app-mode/stripe/src/lib/workflows/sync-stripe-customers.ts": w,
35
- "../../enable/payments/providers-app-mode/stripe/src/routes/(app)/billing/+layout.server.ts": T,
36
- "../../enable/payments/providers-app-mode/stripe/src/routes/(app)/billing/+page.server.ts": V,
37
- "../../enable/payments/providers-app-mode/stripe/src/routes/(app)/billing/+page.svelte": H,
38
- "../../enable/payments/providers-app-mode/stripe/src/routes/(app)/billing/README.md": k,
39
- "../../enable/payments/providers-app-mode/stripe/src/routes/api/stripe/payment-intent/+server.ts": M,
40
- "../../enable/payments/providers-app-mode/stripe/src/routes/api/stripe/payment-intent/server.test.ts": C,
41
- "../../enable/payments/providers-app-mode/stripe/src/routes/api/stripe/setup-intent/+server.ts": S,
42
- "../../enable/payments/providers-app-mode/stripe/src/routes/api/stripe/setup-intent/server.test.ts": P,
43
- "../../enable/payments/providers-app-mode/stripe/src/routes/webhooks/stripe/handlers/dispatch.ts": O,
44
- "../../enable/payments/providers-app-mode/stripe/src/routes/webhooks/stripe/handlers/payment-intent/server.test.ts": x,
45
- "../../enable/payments/providers-app-mode/stripe/src/routes/webhooks/stripe/handlers/payment-intent/succeeded.ts": N,
46
- "../../enable/payments/providers-app-mode/stripe/src/routes/webhooks/stripe/handlers/payment-method/attached.ts": j,
47
- "../../enable/payments/providers-app-mode/stripe/src/routes/webhooks/stripe/handlers/payment-method/server.test.ts": y
48
- }), W = "src/routes/(public)/payment/+page.svelte";
49
- function G(e) {
50
- let t = e.providers?.payments, n = A.filter((e) => e.id === t);
51
- return n.length > 0 ? n : A;
7
+ var W = /* #__PURE__ */ Object.assign({
8
+ "../../enable/payments/providers/shopify/src/lib/components/payments/buy-button.svelte": c,
9
+ "../../enable/payments/providers/shopify/src/lib/shopify.ts": v,
10
+ "../../enable/payments/providers/stripe/src/lib/components/payments/confirm-dialog.svelte": r,
11
+ "../../enable/payments/providers/stripe/src/lib/components/payments/payment-button.svelte": B,
12
+ "../../enable/payments/providers/stripe/src/lib/components/payments/payment-dialog.svelte": h,
13
+ "../../enable/payments/providers/stripe/src/lib/components/payments/stripe-constants.ts": u,
14
+ "../../enable/payments/providers/stripe/src/lib/components/payments/stripe-payment-form.svelte": l,
15
+ "../../enable/payments/providers/stripe/src/lib/components/payments/use-payment-intent.svelte.ts": s,
16
+ "../../enable/payments/providers/stripe/src/lib/components/payments/use-stripe.svelte.ts": m,
17
+ "../../enable/payments/providers/stripe/src/lib/stripe.ts": f,
18
+ "../../enable/payments/providers/stripe/src/lib/workflows/stripe-event.ts": d,
19
+ "../../enable/payments/providers/stripe/src/lib/workflows/sync-stripe-catalog.ts": D,
20
+ "../../enable/payments/providers/stripe/src/routes/api/stripe/payment-intent/+server.ts": n,
21
+ "../../enable/payments/providers/stripe/src/routes/api/stripe/payment-intent/server.test.ts": O,
22
+ "../../enable/payments/providers/stripe/src/routes/webhooks/stripe/+server.ts": p,
23
+ "../../enable/payments/providers/stripe/src/routes/webhooks/stripe/handlers/dispatch.ts": a,
24
+ "../../enable/payments/providers/stripe/src/routes/webhooks/stripe/handlers/payment-intent/server.test.ts": o,
25
+ "../../enable/payments/providers/stripe/src/routes/webhooks/stripe/handlers/payment-intent/succeeded.ts": _,
26
+ "../../enable/payments/providers/stripe/src/routes/webhooks/stripe/server.test.ts": L,
27
+ "../../enable/payments/providers/whatsapp/src/lib/components/payments/customer-fields.svelte": i,
28
+ "../../enable/payments/providers/whatsapp/src/lib/components/payments/order-button.svelte": g,
29
+ "../../enable/payments/providers/whatsapp/src/lib/order.test.ts": R,
30
+ "../../enable/payments/providers/whatsapp/src/lib/order.ts": x,
31
+ "../../enable/payments/providers-app-mode/stripe/src/lib/components/payments/setup-button.svelte": z,
32
+ "../../enable/payments/providers-app-mode/stripe/src/lib/components/payments/setup-dialog.svelte": I,
33
+ "../../enable/payments/providers-app-mode/stripe/src/lib/server/stripe-customer.ts": V,
34
+ "../../enable/payments/providers-app-mode/stripe/src/lib/workflows/link-stripe-customer.ts": y,
35
+ "../../enable/payments/providers-app-mode/stripe/src/lib/workflows/sync-stripe-customers.ts": T,
36
+ "../../enable/payments/providers-app-mode/stripe/src/routes/(app)/billing/+layout.server.ts": E,
37
+ "../../enable/payments/providers-app-mode/stripe/src/routes/(app)/billing/+page.server.ts": H,
38
+ "../../enable/payments/providers-app-mode/stripe/src/routes/(app)/billing/+page.svelte": U,
39
+ "../../enable/payments/providers-app-mode/stripe/src/routes/(app)/billing/README.md": A,
40
+ "../../enable/payments/providers-app-mode/stripe/src/routes/api/stripe/payment-intent/+server.ts": N,
41
+ "../../enable/payments/providers-app-mode/stripe/src/routes/api/stripe/payment-intent/server.test.ts": w,
42
+ "../../enable/payments/providers-app-mode/stripe/src/routes/api/stripe/setup-intent/+server.ts": C,
43
+ "../../enable/payments/providers-app-mode/stripe/src/routes/api/stripe/setup-intent/server.test.ts": F,
44
+ "../../enable/payments/providers-app-mode/stripe/src/routes/webhooks/stripe/handlers/dispatch.ts": k,
45
+ "../../enable/payments/providers-app-mode/stripe/src/routes/webhooks/stripe/handlers/payment-intent/server.test.ts": S,
46
+ "../../enable/payments/providers-app-mode/stripe/src/routes/webhooks/stripe/handlers/payment-intent/succeeded.ts": P,
47
+ "../../enable/payments/providers-app-mode/stripe/src/routes/webhooks/stripe/handlers/payment-method/attached.ts": M,
48
+ "../../enable/payments/providers-app-mode/stripe/src/routes/webhooks/stripe/handlers/payment-method/server.test.ts": b
49
+ }), G = "src/routes/(public)/payment/+page.svelte";
50
+ function K(e) {
51
+ let t = e.providers?.payments, n = j.filter((e) => e.id === t);
52
+ return n.length > 0 ? n : j;
52
53
  }
53
- async function K(n) {
54
- let r = /* @__PURE__ */ new Set([W]);
55
- for (let e of G(n)) for (let n of t(U, e.id)) r.add(n);
54
+ async function q(n) {
55
+ let r = /* @__PURE__ */ new Set([G]);
56
+ for (let e of K(n)) for (let n of t(W, e.id)) r.add(n);
56
57
  return {
57
58
  creates: [],
58
59
  modifies: [],
@@ -70,6 +71,6 @@ async function K(n) {
70
71
  };
71
72
  }
72
73
  //#endregion
73
- export { G as n, K as t };
74
+ export { K as n, q as t };
74
75
 
75
- //# sourceMappingURL=generate-jx5Iuq5w.js.map
76
+ //# sourceMappingURL=generate-DdLwP0E7.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-DdLwP0E7.js","names":["__import_glob__0_0_","__import_glob__0_1_","__import_glob__0_2_","__import_glob__0_3_","__import_glob__0_4_","__import_glob__0_5_","__import_glob__0_6_","__import_glob__0_7_","__import_glob__0_8_","__import_glob__0_9_","__import_glob__0_10_","__import_glob__0_11_","__import_glob__0_12_","__import_glob__0_13_","__import_glob__0_14_","__import_glob__0_15_","__import_glob__0_16_","__import_glob__0_17_","__import_glob__0_18_","__import_glob__0_19_","__import_glob__0_20_","__import_glob__0_21_","__import_glob__0_22_","__import_glob__0_23_","__import_glob__0_24_","__import_glob__0_25_","__import_glob__0_26_","__import_glob__0_27_","__import_glob__0_28_","__import_glob__0_29_","__import_glob__0_30_","__import_glob__0_31_","__import_glob__0_32_","__import_glob__0_33_","__import_glob__0_34_","__import_glob__0_35_","__import_glob__0_36_","__import_glob__0_37_","__import_glob__0_38_","__import_glob__0_39_","__import_glob__0_40_","languageFromPath","_server_default","confirm_dialog_default","customer_fields_default","dispatch_default","server_test_default$1","use_payment_intent_svelte_default","buy_button_default","stripe_payment_form_default","stripe_constants_default","stripe_event_default","stripe_default","_server_default$1","use_stripe_svelte_default","payment_dialog_default","order_button_default","succeeded_default","shopify_default","link_stripe_customer_default","server_test_default$6","order_default","server_test_default$5","_server_default$3","server_test_default$3","sync_stripe_customers_default","_layout_server_default","sync_stripe_catalog_default","server_test_default","dispatch_default$1","README_default","PROVIDERS","attached_default","_server_default$2","succeeded_default$1","server_test_default$4","setup_dialog_default","server_test_default$2","order_test_default","setup_button_default","payment_button_default","stripe_customer_default","_page_server_default","_page_default","providersRaw","DEMO_PAGE","providersToRemove","detected","options","match","provider","generate","paths","path","allProviderPaths"],"sources":["../../src/patterns/disable/payments/generate.ts"],"sourcesContent":["import type { File, Options, Provider, Result } from \"../../../core/types\";\nimport { allProviderPaths } from \"../../../core/providers\";\nimport { languageFromPath } from \"../../../core/util\";\nimport { PROVIDERS } from \"../../enable/payments/generate\";\n\nconst providersRaw = import.meta.glob<string>(\n [\n \"../../enable/payments/providers/**\",\n \"../../enable/payments/providers-app-mode/**\",\n ],\n { query: \"?raw\", import: \"default\", eager: true },\n);\n\n// The demo page enable-payments writes at runtime (it carries the price or\n// variant id), so it is in no template tree: without the payment components it\n// would no longer build.\nconst DEMO_PAGE = \"src/routes/(public)/payment/+page.svelte\";\n\n/**\n * The provider whose files to remove: the one detected, else every one.\n * Removing every provider's files is safe, since a missing path is skipped.\n */\nexport function providersToRemove(\n options: Pick<Options, \"providers\">,\n): Provider[] {\n const detected = options.providers?.payments;\n const match = PROVIDERS.filter((provider) => provider.id === detected);\n return match.length > 0 ? match : PROVIDERS;\n}\n\nexport async function generate(options: Options) {\n // Both the plain and the app-mode files go, whatever auth is now: auth may\n // have been turned on or off since payments was enabled.\n const paths = new Set([DEMO_PAGE]);\n for (const provider of providersToRemove(options)) {\n for (const path of allProviderPaths(providersRaw, provider.id)) {\n paths.add(path);\n }\n }\n\n const deletes: File[] = [...paths].sort().map((path) => ({\n path,\n language: languageFromPath(path),\n content: \"\",\n status: \"success\",\n }));\n\n return {\n creates: [],\n modifies: [],\n deletes,\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;AAKA,IAAMoF,IAAe,uBAAA,OAAA;CAAA,yFAAApF;CAAA,8DAAAC;CAAA,4FAAAC;CAAA,4FAAAC;CAAA,4FAAAC;CAAA,0FAAAC;CAAA,iGAAAC;CAAA,mGAAAC;CAAA,2FAAAC;CAAA,4DAAAC;CAAA,4EAAAC;CAAA,mFAAAC;CAAA,0FAAAC;CAAA,8FAAAC;CAAA,gFAAAC;CAAA,0FAAAC;CAAA,4GAAAC;CAAA,0GAAAC;CAAA,oFAAAC;CAAA,+FAAAC;CAAA,4FAAAC;CAAA,kEAAAC;CAAA,6DAAAC;CAAA,mGAAAC;CAAA,mGAAAC;CAAA,qFAAAC;CAAA,6FAAAC;CAAA,8FAAAC;CAAA,8FAAAC;CAAA,4FAAAC;CAAA,yFAAAC;CAAA,sFAAAC;CAAA,mGAAAC;CAAA,uGAAAC;CAAA,iGAAAC;CAAA,qGAAAC;CAAA,mGAAAC;CAAA,qHAAAC;CAAA,mHAAAC;CAAA,kHAAAC;CAAA,qHAAAC;AAMrB,CAAA,GAKM6C,IAAY;AAMlB,SAAgBC,EACd,GACY;CACZ,IAAMC,IAAWC,EAAQ,WAAW,UAC9BC,IAAQlB,EAAU,QAAQ,MAAamB,EAAS,OAAOH,CAAQ;CACrE,OAAOE,EAAM,SAAS,IAAIA,IAAQlB;AACpC;AAEA,eAAsBoB,EAAS,GAAkB;CAG/C,IAAMC,oBAAQ,IAAI,IAAI,CAACP,CAAS,CAAC;CACjC,KAAK,IAAMK,KAAYJ,EAAkBE,CAAO,GAC9C,KAAK,IAAMK,KAAQC,EAAiBV,GAAcM,EAAS,EAAE,GAC3D,EAAM,IAAIG,CAAI;CAWlB,OAAO;EACL,SAAS,CAAC;EACV,UAAU,CAAC;EACX,SAVsB,CAAC,GAAGD,CAAK,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,OAAU;GACvD;GACA,UAAUnD,EAAiBoD,CAAI;GAC/B,SAAS;GACT,QAAQ;EACV,EAKE;EACA,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"generate-DyV5R8NP.js","names":["__import_glob__0_0_","__import_glob__0_1_","__import_glob__0_2_","__import_glob__0_3_","resolveProvider","providerEnvEdits","providerCreates","analytics_default$2","gtag_default","analytics_default$1","analytics_default","PROVIDERS","PACKAGES","META","envEditsFor","provider","supplied","providersRaw","generate","options"],"sources":["../../src/patterns/enable/analytics/generate.ts"],"sourcesContent":["import type { Options, Package, Provider, Result } from \"../../../core/types\";\nimport type { EnvEdit } from \"../../../runtime/env\";\nimport {\n providerCreates,\n providerEnvEdits,\n resolveProvider,\n} from \"../../../core/providers\";\n\n/** Every provider ships the same component, so the root layout mounts one path. */\nexport const COMPONENT_PATH = \"src/lib/components/analytics/analytics.svelte\";\n\n/**\n * The providers in prompt order. Each one's `env` keys are what the CLI asks\n * for, what `generate.runtime.ts` writes to `.env` and declares in\n * `src/env.ts` (`public: true`, since the browser reads them); the generated\n * component imports them from `$app/env/public` and stays inert while they\n * are blank.\n */\nexport const PROVIDERS: Provider[] = [\n {\n id: \"plausible\",\n label: \"Plausible\",\n env: [\n {\n key: \"PUBLIC_PLAUSIBLE_DOMAIN\",\n public: true,\n label: \"Plausible site domain\",\n placeholder: \"example.com\",\n },\n ],\n },\n {\n id: \"google\",\n label: \"Google Analytics\",\n env: [\n {\n key: \"PUBLIC_GA_MEASUREMENT_ID\",\n public: true,\n label: \"Google Analytics measurement ID\",\n placeholder: \"G-XXXXXXXXXX\",\n },\n ],\n },\n {\n id: \"posthog\",\n label: \"PostHog\",\n env: [\n {\n key: \"PUBLIC_POSTHOG_KEY\",\n public: true,\n label: \"PostHog project API key\",\n placeholder: \"phc_...\",\n },\n {\n key: \"PUBLIC_POSTHOG_HOST\",\n public: true,\n label: \"PostHog host\",\n default: \"https://us.i.posthog.com\",\n },\n ],\n },\n];\n\nconst PACKAGES: Record<string, Package[]> = {\n posthog: [\"posthog-js\"],\n};\n\n/** What `resolveProvider` needs; `index.ts` spreads the rest of the metadata. */\nexport const META = { slug: \"enable-analytics\", providers: PROVIDERS };\n\n/** The `.env` lines for a provider, under a `# <Label> analytics` heading. */\nexport function envEditsFor(\n provider: Provider,\n supplied: Record<string, string> = {},\n): EnvEdit[] {\n return providerEnvEdits(provider, `${provider.label} analytics`, supplied);\n}\n\nconst providersRaw = import.meta.glob<string>(\"./providers/**\", {\n query: \"?raw\",\n import: \"default\",\n eager: true,\n});\n\nexport async function generate(options: Options) {\n const provider = resolveProvider(META, options);\n\n return {\n creates: providerCreates(providersRaw, provider.id),\n modifies: [],\n deletes: [],\n components: [],\n packages: PACKAGES[provider.id] ?? [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;msGAkBaW,IAAwB;CACnC;EACE,IAAI;EACJ,OAAO;EACP,KAAK,CACH;GACE,KAAK;GACL,QAAQ;GACR,OAAO;GACP,aAAa;EACf,CACF;CACF;CACA;EACE,IAAI;EACJ,OAAO;EACP,KAAK,CACH;GACE,KAAK;GACL,QAAQ;GACR,OAAO;GACP,aAAa;EACf,CACF;CACF;CACA;EACE,IAAI;EACJ,OAAO;EACP,KAAK,CACH;GACE,KAAK;GACL,QAAQ;GACR,OAAO;GACP,aAAa;EACf,GACA;GACE,KAAK;GACL,QAAQ;GACR,OAAO;GACP,SAAS;EACX,CACF;CACF;AACF,GAEMC,IAAsC,EAC1C,SAAS,CAAC,YAAY,EACxB,GAGaC,IAAO;CAAE,MAAM;CAAoB,WAAWF;AAAU;AAGrE,SAAgBG,EACd,GACA,IAAmC,CAAC,GACzB;CACX,OAAOT,EAAiBU,GAAU,GAAGA,EAAS,MAAM,aAAaC,CAAQ;AAC3E;AAEA,IAAMC,IAAe,uBAAA,OAAA;CAAA,oEAAAjB;CAAA,2DAAAC;CAAA,uEAAAC;CAAA,qEAAAC;AAIpB,CAAA;AAED,eAAsBe,EAAS,GAAkB;CAC/C,IAAMH,IAAWX,EAAgBS,GAAMM,CAAO;CAE9C,OAAO;EACL,SAASb,EAAgBW,GAAcF,EAAS,EAAE;EAClD,UAAU,CAAC;EACX,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAUH,EAASG,EAAS,OAAO,CAAC;EACpC,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
1
+ {"version":3,"file":"generate-DyV5R8NP.js","names":["__import_glob__0_0_","__import_glob__0_1_","__import_glob__0_2_","__import_glob__0_3_","resolveProvider","providerEnvEdits","providerCreates","analytics_default$2","gtag_default","analytics_default$1","analytics_default","PROVIDERS","PACKAGES","META","envEditsFor","provider","supplied","providersRaw","generate","options"],"sources":["../../src/patterns/enable/analytics/generate.ts"],"sourcesContent":["import type { Options, Package, Provider, Result } from \"../../../core/types\";\nimport type { EnvEdit } from \"../../../runtime/env\";\nimport {\n providerCreates,\n providerEnvEdits,\n resolveProvider,\n} from \"../../../core/providers\";\n\n/** Every provider ships the same component, so the root layout mounts one path. */\nexport const COMPONENT_PATH = \"src/lib/components/analytics/analytics.svelte\";\n\n/**\n * The providers in prompt order. Each one's `env` keys are what the CLI asks\n * for, what `generate.runtime.ts` writes to `.env` and declares in\n * `src/env.ts` (`public: true`, since the browser reads them); the generated\n * component imports them from `$app/env/public` and stays inert while they\n * are blank.\n */\nexport const PROVIDERS: Provider[] = [\n {\n id: \"plausible\",\n label: \"Plausible\",\n env: [\n {\n key: \"PUBLIC_PLAUSIBLE_DOMAIN\",\n public: true,\n label: \"Plausible site domain\",\n placeholder: \"example.com\",\n },\n ],\n },\n {\n id: \"google\",\n label: \"Google Analytics\",\n env: [\n {\n key: \"PUBLIC_GA_MEASUREMENT_ID\",\n public: true,\n label: \"Google Analytics measurement ID\",\n placeholder: \"G-XXXXXXXXXX\",\n },\n ],\n },\n {\n id: \"posthog\",\n label: \"PostHog\",\n env: [\n {\n key: \"PUBLIC_POSTHOG_KEY\",\n public: true,\n label: \"PostHog project API key\",\n placeholder: \"phc_...\",\n },\n {\n key: \"PUBLIC_POSTHOG_HOST\",\n public: true,\n label: \"PostHog host\",\n default: \"https://us.i.posthog.com\",\n },\n ],\n },\n];\n\nconst PACKAGES: Record<string, Package[]> = {\n posthog: [\"posthog-js\"],\n};\n\n/** What `resolveProvider` needs; `index.ts` spreads the rest of the metadata. */\nexport const META = { slug: \"enable-analytics\", providers: PROVIDERS };\n\n/** The `.env` lines for a provider, under a `# <Label> analytics` heading. */\nexport function envEditsFor(\n provider: Provider,\n supplied: Record<string, string> = {},\n): EnvEdit[] {\n return providerEnvEdits(provider, `${provider.label} analytics`, supplied);\n}\n\nconst providersRaw = import.meta.glob<string>(\"./providers/**\", {\n query: \"?raw\",\n import: \"default\",\n eager: true,\n});\n\nexport async function generate(options: Options) {\n const provider = resolveProvider(META, options);\n\n return {\n creates: providerCreates(providersRaw, provider.id),\n modifies: [],\n deletes: [],\n components: [],\n packages: PACKAGES[provider.id] ?? [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;A,msGAkBaW,IAAwB;CACnC;EACE,IAAI;EACJ,OAAO;EACP,KAAK,CACH;GACE,KAAK;GACL,QAAQ;GACR,OAAO;GACP,aAAa;EACf,CACF;CACF;CACA;EACE,IAAI;EACJ,OAAO;EACP,KAAK,CACH;GACE,KAAK;GACL,QAAQ;GACR,OAAO;GACP,aAAa;EACf,CACF;CACF;CACA;EACE,IAAI;EACJ,OAAO;EACP,KAAK,CACH;GACE,KAAK;GACL,QAAQ;GACR,OAAO;GACP,aAAa;EACf,GACA;GACE,KAAK;GACL,QAAQ;GACR,OAAO;GACP,SAAS;EACX,CACF;CACF;AACF,GAEMC,IAAsC,EAC1C,SAAS,CAAC,YAAY,EACxB,GAGaC,IAAO;CAAE,MAAM;CAAoB,WAAWF;AAAU;AAGrE,SAAgBG,EACd,GACA,IAAmC,CAAC,GACzB;CACX,OAAOT,EAAiBU,GAAU,GAAGA,EAAS,MAAM,aAAaC,CAAQ;AAC3E;AAEA,IAAMC,IAAe,uBAAA,OAAA;CAAA,oEAAAjB;CAAA,2DAAAC;CAAA,uEAAAC;CAAA,qEAAAC;AAIpB,CAAA;AAED,eAAsBe,EAAS,GAAkB;CAC/C,IAAMH,IAAWX,EAAgBS,GAAMM,CAAO;CAE9C,OAAO;EACL,SAASb,EAAgBW,GAAcF,EAAS,EAAE;EAClD,UAAU,CAAC;EACX,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAUH,EAASG,EAAS,OAAO,CAAC;EACpC,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
@@ -1,10 +1,10 @@
1
1
  import { t as e } from "./dedent-Gq6Krl4n.js";
2
2
  import { n as t } from "./logger-CQONztPm.js";
3
3
  import { n } from "./generate-Cqwa8kD9.js";
4
- import { _ as r, o as i, r as a } from "./ts-morph-helpers-Bepc-Es2.js";
5
- import { r as o } from "./modify-file-289rStJ2.js";
4
+ import { _ as r, o as i, r as a } from "./ts-morph-helpers-CHI9wAil.js";
5
+ import { r as o } from "./modify-file-COBp4eCh.js";
6
6
  import { t as s } from "./svelte-file-Dv5-bl79.js";
7
- import { a as c, t as l } from "./config-target-rHgjaA8u.js";
7
+ import { a as c, t as l } from "./config-target-BgyFkbFL.js";
8
8
  import u from "node:fs";
9
9
  import d from "node:path";
10
10
  import { Node as f, Project as p, QuoteKind as m, SyntaxKind as h } from "ts-morph";
@@ -85,14 +85,11 @@ function b() {
85
85
  }
86
86
  function x(e, t, n) {
87
87
  let r = e.getImportDeclarations().find((e) => e.getModuleSpecifierValue() === t);
88
- if (!r) {
89
- e.addImportDeclaration({
90
- namedImports: n,
91
- moduleSpecifier: t
92
- });
93
- return;
94
- }
95
- for (let e of n) r.getNamedImports().some((t) => t.getName() === e) || r.addNamedImport(e);
88
+ if (!r) e.addImportDeclaration({
89
+ namedImports: n,
90
+ moduleSpecifier: t
91
+ });
92
+ else for (let e of n) r.getNamedImports().some((t) => t.getName() === e) || r.addNamedImport(e);
96
93
  }
97
94
  function S(e, t) {
98
95
  t.namedImports?.length && x(e, t.moduleSpecifier, t.namedImports), !e.getImportDeclarations().find((e) => e.getModuleSpecifierValue() === t.moduleSpecifier) && e.addImportDeclaration({
@@ -397,4 +394,4 @@ async function q(e) {
397
394
  //#endregion
398
395
  export { q as generate };
399
396
 
400
- //# sourceMappingURL=generate.runtime-Dug2UIhV.js.map
397
+ //# sourceMappingURL=generate.runtime-9KuMcI5r.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate.runtime-Dug2UIhV.js","names":["FAILURE_HINT","NOT_FOUND_HINT","FAILURE_HINT","FAILURE_HINT","dedent","getLogger","withInMemoryScript","formatLikeSource","ensureImports","modifyOutcomeToFile","SvelteFile","probeFirstExisting","VITE_CONFIG_CANDIDATES","fs","path","FAILURE_HINT$3","NOT_FOUND_HINT$1","elementName","text","modifyViteConfig","call","pluginArgs","viteConfigPath","sourceFile","Project","QuoteKind","changed","failed","d","configArg","SyntaxKind","ce","configObj","pluginsProp","pluginsInit","arr","elements","el","sveltekitIndex","newProject","ensureNamedImports","existing","moduleSpecifier","names","name","ni","ensureImportSpec","spec","unwrapFunction","Node","node","arg","fn","findLoadFunction","declaration","variable","initializer","isFunctionNode","findFinalReturn","statements","body","last","r","returnedObject","expression","statement","hasProperty","object","property","hasSpreadOf","expressionText","inspectEventParameter","params","param","nameNode","DEFAULT_LOCALE","WUCHALE_LOCALE","eventName","cmsSnippet","locale","importLine","parts","createdLayoutServer","imports","snippet","FAILURE_HINT$2","modifyLayoutServer","layoutServerPath","event","returned","spreadIndex","returnIndex","destructuring","typeText","FAILURE_HINT$1","modifyLayoutUniversal","layoutPath","dataExpression","element","IMPORT_SNIPPET","MARKUP_SNIPPET","NOT_FOUND_HINT","FAILURE_HINT","modifyLayoutSvelte","file","out","source","sf","readWuchaleLocales","configPath","root","match","locales","m","vitePluginArgs","mode","list","generate","logger","options","modifies","resolveMode","i18n","pushResult","layoutUniversalPath","layoutSveltePath"],"sources":["../../src/patterns/enable/cms/modifies/vite-config.ts","../../src/patterns/enable/cms/modifies/load-function.ts","../../src/patterns/enable/cms/modifies/layout.server.ts","../../src/patterns/enable/cms/modifies/layout.ts","../../src/patterns/enable/cms/modifies/layout.svelte.ts","../../src/patterns/enable/cms/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport {\n Project,\n QuoteKind,\n SyntaxKind,\n type ArrayLiteralExpression,\n type ObjectLiteralExpression,\n type PropertyAssignment,\n} from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { formatLikeSource } from \"../../../../runtime/ts-morph-helpers\";\n\nconst FAILURE_HINT = [\n \"Add the CMS plugin to your Vite config, ahead of sveltekit():\",\n \"\",\n \"import { cms } from '@velastack/cms/vite';\",\n \"\",\n \"export default defineConfig({\",\n \" plugins: [cms(), sveltekit(), /* ...existing plugins */],\",\n \"});\",\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create a Vite config with the CMS plugin ahead of sveltekit():\",\n \"\",\n \"import { defineConfig } from 'vite';\",\n \"import { sveltekit } from '@sveltejs/kit/vite';\",\n \"import { cms } from '@velastack/cms/vite';\",\n \"\",\n \"export default defineConfig({\",\n \" plugins: [cms(), sveltekit()],\",\n \"});\",\n].join(\"\\n\");\n\nfunction elementName(text: string): string {\n return text.replace(/\\s/g, \"\");\n}\n\n/**\n * Registers `cms(...)` from `@velastack/cms/vite` in the Vite plugin list, just\n * ahead of `sveltekit()`. Only the plugin array is touched, so the inline\n * `sveltekit({ ... })` shape the templates use is left alone.\n */\nexport function modifyViteConfig(\n viteConfigPath: string,\n pluginArgs = \"\",\n): ModifyOutcome {\n const call = `cms(${pluginArgs})`;\n if (!fs.existsSync(viteConfigPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const project = new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(viteConfigPath);\n\n let changed = false;\n let failed = false;\n\n const hasImport = sourceFile\n .getImportDeclarations()\n .some((d) => d.getModuleSpecifierValue() === \"@velastack/cms/vite\");\n\n if (!hasImport) {\n sourceFile.insertImportDeclaration(0, {\n namedImports: [\"cms\"],\n moduleSpecifier: \"@velastack/cms/vite\",\n });\n changed = true;\n }\n\n const defineConfigCall = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((ce) => ce.getExpression().getText() === \"defineConfig\");\n\n const configArg = defineConfigCall?.getArguments()?.[0];\n const configObj =\n configArg?.getKind() === SyntaxKind.ObjectLiteralExpression\n ? (configArg as ObjectLiteralExpression)\n : null;\n\n if (!configObj) {\n failed = true;\n } else {\n const pluginsProp = configObj.getProperty(\"plugins\");\n if (!pluginsProp) {\n configObj.addPropertyAssignment({\n name: \"plugins\",\n initializer: `[${call}]`,\n });\n changed = true;\n } else if (pluginsProp.getKind() !== SyntaxKind.PropertyAssignment) {\n failed = true;\n } else {\n const pluginsInit = (pluginsProp as PropertyAssignment).getInitializer();\n\n if (!pluginsInit) {\n (pluginsProp as PropertyAssignment).setInitializer(`[${call}]`);\n changed = true;\n } else if (pluginsInit.getKind() !== SyntaxKind.ArrayLiteralExpression) {\n failed = true;\n } else {\n const arr = pluginsInit as ArrayLiteralExpression;\n const elements = arr.getElements();\n const hasCms = elements.some((el) =>\n elementName(el.getText()).startsWith(\"cms(\"),\n );\n\n if (!hasCms) {\n const sveltekitIndex = elements.findIndex((el) =>\n elementName(el.getText()).startsWith(\"sveltekit(\"),\n );\n arr.insertElement(sveltekitIndex === -1 ? 0 : sveltekitIndex, call);\n changed = true;\n }\n }\n }\n }\n\n if (changed) {\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n }\n\n if (failed) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n return { status: \"success\", changed };\n}\n","import {\n Node,\n Project,\n QuoteKind,\n SyntaxKind,\n type ArrowFunction,\n type Block,\n type FunctionDeclaration,\n type FunctionExpression,\n type ObjectLiteralExpression,\n type ParameterDeclaration,\n type ReturnStatement,\n type SourceFile,\n} from \"ts-morph\";\nimport type { ImportSpec } from \"../../../../runtime/ts-morph-helpers\";\n\n/**\n * What the two layout modifiers have in common: finding a SvelteKit `load`,\n * working out how it receives its event, and locating the object it returns.\n */\n\nexport type LoadFunction =\n ArrowFunction | FunctionExpression | FunctionDeclaration;\n\nexport function newProject(): Project {\n return new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n}\n\nexport function ensureNamedImports(\n sourceFile: SourceFile,\n moduleSpecifier: string,\n names: string[],\n) {\n const existing = sourceFile\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === moduleSpecifier);\n if (!existing) {\n sourceFile.addImportDeclaration({ namedImports: names, moduleSpecifier });\n return;\n }\n for (const name of names) {\n const has = existing.getNamedImports().some((ni) => ni.getName() === name);\n if (!has) existing.addNamedImport(name);\n }\n}\n\nexport function ensureImportSpec(sourceFile: SourceFile, spec: ImportSpec) {\n if (spec.namedImports?.length) {\n ensureNamedImports(sourceFile, spec.moduleSpecifier, spec.namedImports);\n }\n const existing = sourceFile\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === spec.moduleSpecifier);\n if (existing) return;\n sourceFile.addImportDeclaration({\n moduleSpecifier: spec.moduleSpecifier,\n defaultImport: spec.defaultImport,\n namespaceImport: spec.namespaceImport,\n });\n}\n\n/** Peel wrappers (`loadFlash(fn)`, `(fn)`, `fn satisfies X`) down to the function. */\nfunction unwrapFunction(node: Node): ArrowFunction | FunctionExpression | null {\n if (Node.isArrowFunction(node) || Node.isFunctionExpression(node)) {\n return node;\n }\n if (\n Node.isParenthesizedExpression(node) ||\n Node.isAsExpression(node) ||\n Node.isSatisfiesExpression(node)\n ) {\n return unwrapFunction(node.getExpression());\n }\n if (Node.isCallExpression(node)) {\n for (const arg of node.getArguments()) {\n const fn = unwrapFunction(arg);\n if (fn) return fn;\n }\n }\n return null;\n}\n\n/** The exported `load`, whether declared as a function or wrapped in a const. */\nexport function findLoadFunction(sourceFile: SourceFile): LoadFunction | null {\n const declaration = sourceFile.getFunction(\"load\");\n if (declaration) {\n return declaration.isExported() ? declaration : null;\n }\n\n const variable = sourceFile.getVariableDeclaration(\"load\");\n if (!variable) return null;\n if (!variable.getVariableStatement()?.isExported()) return null;\n\n const initializer = variable.getInitializer();\n return initializer ? unwrapFunction(initializer) : null;\n}\n\nfunction isFunctionNode(node: Node): boolean {\n return (\n Node.isArrowFunction(node) ||\n Node.isFunctionExpression(node) ||\n Node.isFunctionDeclaration(node) ||\n Node.isMethodDeclaration(node)\n );\n}\n\n/**\n * The single, final `return <expression>` of the load body, or null when the\n * body has early returns — those would need any insertion hoisted above them,\n * and guessing where is worse than refusing.\n */\nexport function findFinalReturn(\n fn: LoadFunction,\n body: Block,\n): ReturnStatement | null {\n const statements = body.getStatements();\n const last = statements[statements.length - 1];\n if (!last || !Node.isReturnStatement(last)) return null;\n\n const returns = body\n .getDescendantsOfKind(SyntaxKind.ReturnStatement)\n .filter((r) => r.getFirstAncestor(isFunctionNode) === fn);\n if (returns.length !== 1) return null;\n\n return last;\n}\n\n/** The object literal a return statement yields, unwrapping parentheses. */\nexport function returnedObject(\n statement: ReturnStatement,\n): ObjectLiteralExpression | null {\n let expression = statement.getExpression();\n while (expression && Node.isParenthesizedExpression(expression)) {\n expression = expression.getExpression();\n }\n if (!expression || !Node.isObjectLiteralExpression(expression)) return null;\n return expression;\n}\n\nexport function hasProperty(\n object: ObjectLiteralExpression,\n name: string,\n): boolean {\n return object.getProperties().some((property) => {\n if (\n Node.isPropertyAssignment(property) ||\n Node.isShorthandPropertyAssignment(property)\n ) {\n return property.getName() === name;\n }\n return false;\n });\n}\n\nexport function hasSpreadOf(\n object: ObjectLiteralExpression,\n expressionText: string,\n): boolean {\n return object\n .getProperties()\n .some(\n (property) =>\n Node.isSpreadAssignment(property) &&\n property.getExpression().getText() === expressionText,\n );\n}\n\n/** How a load receives its event: not at all, by name, or destructured. */\nexport type EventParameter =\n | { kind: \"none\" }\n | { kind: \"identifier\"; name: string; param: ParameterDeclaration }\n | {\n kind: \"binding\";\n pattern: import(\"ts-morph\").ObjectBindingPattern;\n param: ParameterDeclaration;\n }\n | { kind: \"unsupported\" };\n\nexport function inspectEventParameter(fn: LoadFunction): EventParameter {\n const params = fn.getParameters();\n if (params.length === 0) return { kind: \"none\" };\n if (params.length > 1) return { kind: \"unsupported\" };\n\n const param = params[0];\n if (param.getInitializer() || param.isRestParameter()) {\n return { kind: \"unsupported\" };\n }\n const nameNode = param.getNameNode();\n if (Node.isIdentifier(nameNode)) {\n return { kind: \"identifier\", name: nameNode.getText(), param };\n }\n if (Node.isObjectBindingPattern(nameNode)) {\n return { kind: \"binding\", pattern: nameNode, param };\n }\n return { kind: \"unsupported\" };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport dedent from \"dedent\";\nimport { Node } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport type { ImportSpec } from \"../../../../runtime/ts-morph-helpers\";\nimport {\n ensureImportSpec,\n ensureNamedImports,\n findFinalReturn,\n findLoadFunction,\n hasProperty,\n inspectEventParameter,\n newProject,\n returnedObject,\n} from \"./load-function\";\nimport { formatLikeSource } from \"../../../../runtime/ts-morph-helpers\";\n\nexport interface LayoutServerLocale {\n /**\n * Expression passed as `locale` to `loadCms`, given the name of the load's\n * event parameter: `() => \"'en'\"` or `(event) => \\`getLocale(${event}.url)\\``.\n */\n expression: (eventName: string) => string;\n /** Imports the expression depends on. */\n imports?: ImportSpec[];\n}\n\n/** A single-locale site: the literal default locale. */\nexport const DEFAULT_LOCALE: LayoutServerLocale = {\n expression: () => \"'en'\",\n};\n\n/** A wuchale site: the locale enable-i18n's reroute already resolved from the URL. */\nexport const WUCHALE_LOCALE: LayoutServerLocale = {\n expression: (eventName) => `getLocale(${eventName}.url)`,\n imports: [\n { namedImports: [\"getLocale\"], moduleSpecifier: \"#locales/main.url.js\" },\n ],\n};\n\nfunction cmsSnippet(eventName: string, locale: string): string {\n return dedent`\n const { cms, notFound, gone, redirectTo } = await loadCms(${eventName}, { locale: ${locale} });\n if (redirectTo) redirect(308, redirectTo);\n if (gone) error(410, 'Gone');\n if (notFound) error(404, 'Not found');\n `;\n}\n\nfunction importLine(spec: ImportSpec): string {\n const parts: string[] = [];\n if (spec.defaultImport) parts.push(spec.defaultImport);\n if (spec.namespaceImport) parts.push(`* as ${spec.namespaceImport}`);\n if (spec.namedImports?.length)\n parts.push(`{ ${spec.namedImports.join(\", \")} }`);\n return `import ${parts.join(\", \")} from '${spec.moduleSpecifier}';`;\n}\n\n/**\n * A root `+layout.server.ts` written from scratch, for a project that has\n * none — the static template keeps its layout load universal.\n */\nexport function createdLayoutServer(locale: LayoutServerLocale): string {\n const imports = [\n \"import { error, redirect } from '@sveltejs/kit';\",\n \"import { loadCms } from '#lib/cms.js';\",\n ...(locale.imports ?? []).map(importLine),\n \"import type { LayoutServerLoad } from './$types';\",\n ].join(\"\\n\");\n const snippet = cmsSnippet(\"event\", locale.expression(\"event\"))\n .split(\"\\n\")\n .join(\"\\n\\t\");\n\n return dedent`\n ${imports}\n\n export const load: LayoutServerLoad = async (event) => {\n \t${snippet}\n\n \treturn { cms };\n };\n `.concat(\"\\n\");\n}\n\nconst FAILURE_HINT = [\n \"Call loadCms from the root +layout.server.ts load and return `cms`:\",\n \"\",\n createdLayoutServer(DEFAULT_LOCALE).trimEnd(),\n \"\",\n \"loadCms needs the whole event, so a destructured parameter has to become\",\n \"`event` with the destructuring moved into the body.\",\n].join(\"\\n\");\n\n/**\n * Wires `loadCms` into the root `+layout.server.ts`, creating the file when\n * the project has none:\n *\n * - `loadCms` needs the whole request event, so a destructured parameter is\n * renamed to `event` and the destructuring becomes the first statement.\n * - The tombstone triple (`redirectTo`, `gone`, `notFound`) is handled just\n * before the return.\n * - `cms` is added to the returned object, ahead of any spread so nothing\n * later can shadow it.\n *\n * Anything else — no exported `load`, an expression-bodied arrow, several\n * returns, a non-literal return — is reported as `failed` with the snippet to\n * paste, and the file is left exactly as it was.\n */\nexport function modifyLayoutServer(\n layoutServerPath: string,\n locale: LayoutServerLocale = DEFAULT_LOCALE,\n): ModifyOutcome {\n if (!fs.existsSync(layoutServerPath)) {\n fs.mkdirSync(path.dirname(layoutServerPath), { recursive: true });\n fs.writeFileSync(layoutServerPath, createdLayoutServer(locale));\n return { status: \"success\", changed: true };\n }\n\n const original = fs.readFileSync(layoutServerPath, \"utf8\");\n if (original.includes(\"loadCms(\")) {\n return { status: \"success\", changed: false };\n }\n\n const sourceFile = newProject().addSourceFileAtPath(layoutServerPath);\n\n // --- Inspect everything before touching anything. ---\n const fn = findLoadFunction(sourceFile);\n if (!fn) return { status: \"failed\", message: FAILURE_HINT };\n\n const body = fn.getBody();\n if (!body || !Node.isBlock(body)) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const event = inspectEventParameter(fn);\n if (event.kind === \"unsupported\") {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const returned = findFinalReturn(fn, body);\n const object = returned && returnedObject(returned);\n if (!returned || !object) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const eventName = event.kind === \"identifier\" ? event.name : \"event\";\n\n // --- Mutate bottom-up so earlier node references stay valid. ---\n if (!hasProperty(object, \"cms\")) {\n const spreadIndex = object\n .getProperties()\n .findIndex((property) => Node.isSpreadAssignment(property));\n if (spreadIndex === -1) {\n object.addShorthandPropertyAssignment({ name: \"cms\" });\n } else {\n object.insertShorthandPropertyAssignment(spreadIndex, { name: \"cms\" });\n }\n }\n\n // insertStatements counts comment lines, which getStatements() skips.\n const returnIndex = body.getStatementsWithComments().indexOf(returned);\n body.insertStatements(\n returnIndex,\n `\\n${cmsSnippet(eventName, locale.expression(eventName))}\\n`,\n );\n\n if (event.kind === \"binding\") {\n const destructuring = event.pattern.getText();\n body.insertStatements(0, `const ${destructuring} = ${eventName};`);\n const typeText = event.param.getTypeNode()?.getText();\n event.param.replaceWithText(\n typeText ? `${eventName}: ${typeText}` : eventName,\n );\n } else if (event.kind === \"none\") {\n fn.addParameter({ name: eventName });\n }\n\n if (!fn.isAsync()) fn.setIsAsync(true);\n\n ensureNamedImports(sourceFile, \"@sveltejs/kit\", [\"error\", \"redirect\"]);\n ensureNamedImports(sourceFile, \"#lib/cms.js\", [\"loadCms\"]);\n for (const spec of locale.imports ?? []) {\n ensureImportSpec(sourceFile, spec);\n }\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Node } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport {\n findFinalReturn,\n findLoadFunction,\n hasSpreadOf,\n inspectEventParameter,\n newProject,\n returnedObject,\n} from \"./load-function\";\nimport { formatLikeSource } from \"../../../../runtime/ts-morph-helpers\";\n\nconst FAILURE_HINT = dedent`\n Forward the server load's data through the root +layout.ts, so \\`cms\\` reaches\n the page:\n\n export const load = async ({ url, data }) => {\n // ...existing code...\n return { ...data, /* existing keys */ };\n };\n`;\n\n/**\n * Make a universal root \\`+layout.ts\\` forward its server load's data.\n *\n * SvelteKit hands a universal load the server load's result as \\`data\\`, and\n * only what the universal load returns reaches the page. A layout that\n * returns its own object without spreading \\`data\\` — the static template\n * does — would drop \\`cms\\` on the floor once \\`+layout.server.ts\\` exists.\n *\n * No file, or a file without a \\`load\\`, needs nothing: server data flows\n * through on its own.\n */\nexport function modifyLayoutUniversal(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"success\", changed: false };\n }\n\n const sourceFile = newProject().addSourceFileAtPath(layoutPath);\n\n const fn = findLoadFunction(sourceFile);\n if (!fn) return { status: \"success\", changed: false };\n\n const body = fn.getBody();\n if (!body || !Node.isBlock(body)) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const event = inspectEventParameter(fn);\n if (event.kind === \"unsupported\") {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const returned = findFinalReturn(fn, body);\n if (!returned) return { status: \"failed\", message: FAILURE_HINT };\n\n const dataExpression =\n event.kind === \"identifier\" ? `${event.name}.data` : \"data\";\n\n // `return data;` already forwards everything.\n const expression = returned.getExpression();\n if (expression && expression.getText() === dataExpression) {\n return { status: \"success\", changed: false };\n }\n\n const object = returnedObject(returned);\n if (!object) return { status: \"failed\", message: FAILURE_HINT };\n if (hasSpreadOf(object, dataExpression)) {\n return { status: \"success\", changed: false };\n }\n\n // --- Mutate bottom-up so earlier node references stay valid. ---\n // First, so the layout's own keys still win over anything the server sent.\n object.insertSpreadAssignment(0, { expression: dataExpression });\n\n if (event.kind === \"binding\") {\n const hasData = event.pattern\n .getElements()\n .some((element) => element.getName() === \"data\");\n if (!hasData) {\n const text = event.pattern.getText();\n event.pattern.replaceWithText(text.replace(/^\\{\\s*/, \"{ data, \"));\n }\n } else if (event.kind === \"none\") {\n fn.addParameter({ name: \"{ data }\" });\n }\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n ensureImports,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst IMPORT_SNIPPET = dedent`\n import { AdminBar } from '@velastack/cms';\n`;\n\nconst MARKUP_SNIPPET = \"\\n<AdminBar />\\n\";\n\nconst NOT_FOUND_HINT = [\n \"Create the root src/routes/+layout.svelte and mount <AdminBar /> inside it.\",\n \"\",\n \"Import for the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup to add at the top level of the layout, above {@render children()}:\",\n MARKUP_SNIPPET.trim(),\n].join(\"\\n\");\n\nconst FAILURE_HINT = [\n \"Mount <AdminBar /> in the root src/routes/+layout.svelte.\",\n \"\",\n 'Import for a <script lang=\"ts\"> tag:',\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup to add at the top level of the layout, above {@render children()}:\",\n MARKUP_SNIPPET.trim(),\n].join(\"\\n\");\n\n/**\n * Mounts `<AdminBar />` at the top level of the root layout, ahead of\n * `{@render children()}` so the bar is in the DOM before the page content.\n * Falls back to appending when the layout has no render tag or slot.\n */\nexport function modifyLayoutSvelte(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const file = SvelteFile.fromPath(layoutPath);\n if (file.hasElement(\"AdminBar\")) {\n return { status: \"success\", changed: false };\n }\n if (!file.getScript()) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n ensureImports(sf, [\n { namedImports: [\"AdminBar\"], moduleSpecifier: \"@velastack/cms\" },\n ]);\n });\n return out;\n });\n\n if (!file.insertBeforeChildren(MARKUP_SNIPPET)) {\n file.appendMarkup(MARKUP_SNIPPET);\n }\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport {\n probeFirstExisting,\n VITE_CONFIG_CANDIDATES,\n} from \"../../../runtime/config-target\";\nimport { resolveMode, type CmsMode } from \"./generate\";\nimport { modifyViteConfig } from \"./modifies/vite-config\";\nimport {\n DEFAULT_LOCALE,\n WUCHALE_LOCALE,\n modifyLayoutServer,\n} from \"./modifies/layout.server\";\nimport { modifyLayoutUniversal } from \"./modifies/layout\";\nimport { modifyLayoutSvelte } from \"./modifies/layout.svelte\";\n\n/** The locale list from `wuchale.config.js`, or null when it cannot be read. */\nexport function readWuchaleLocales(root: string): string[] | null {\n const configPath = path.join(root, \"wuchale.config.js\");\n if (!fs.existsSync(configPath)) return null;\n const match = fs\n .readFileSync(configPath, \"utf8\")\n .match(/locales:\\s*\\[([^\\]]*)\\]/);\n if (!match) return null;\n const locales = [...match[1].matchAll(/['\"]([^'\"]+)['\"]/g)].map((m) => m[1]);\n return locales.length > 0 ? locales : null;\n}\n\n/**\n * Arguments for the `cms()` Vite plugin.\n *\n * A hosted CMS needs the endpoint and locales at build time so media can be\n * downloaded into the prerendered site. An app hosting the backend itself\n * needs nothing: the media steps are no-ops without an endpoint.\n */\nexport function vitePluginArgs(mode: CmsMode, locales: string[]): string {\n if (mode.local) return \"\";\n const list = locales.map((locale) => `'${locale}'`).join(\", \");\n return `{ endpoint: '${mode.endpoint}', locales: [${list}] }`;\n}\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n const mode = resolveMode(options);\n const i18n = options.features.i18n;\n\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Modifying vite.config\");\n const viteConfigPath =\n probeFirstExisting(options.root, VITE_CONFIG_CANDIDATES) ??\n path.join(options.root, VITE_CONFIG_CANDIDATES[0]);\n const locales = (i18n && readWuchaleLocales(options.root)) || [\"en\"];\n pushResult(\n modifyOutcomeToFile(\n viteConfigPath,\n modifyViteConfig(viteConfigPath, vitePluginArgs(mode, locales)),\n ),\n );\n\n logger.info(\"Modifying src/routes/+layout.server.ts\");\n const layoutServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.server.ts\",\n );\n const locale = i18n ? WUCHALE_LOCALE : DEFAULT_LOCALE;\n pushResult(\n modifyOutcomeToFile(\n layoutServerPath,\n modifyLayoutServer(layoutServerPath, locale),\n ),\n );\n\n // A universal root layout has to pass the server load's data along, or\n // `cms` never reaches the page. The static template has one.\n logger.info(\"Modifying src/routes/+layout.ts\");\n const layoutUniversalPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n layoutUniversalPath,\n modifyLayoutUniversal(layoutUniversalPath),\n ),\n );\n\n logger.info(\"Modifying src/routes/+layout.svelte\");\n const layoutSveltePath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(layoutSveltePath, modifyLayoutSvelte(layoutSveltePath)),\n );\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;;;AAYA,IAAMA,IAAe;CACnB;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,CAAC,KAAK,IAAI,GAELC,IAAiB;CACrB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,CAAC,KAAK,IAAI;AAEX,SAASgB,EAAY,GAAsB;CACzC,OAAOC,EAAK,QAAQ,OAAO,EAAE;AAC/B;AAOA,SAAgBC,EACd,GACA,IAAa,IACE;CACf,IAAMC,IAAO,OAAOC,EAAW;CAC/B,IAAI,CAACR,EAAG,WAAWS,CAAc,GAC/B,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G,EAAQ,MACR,OACA,UACA,mBACF;CAWA,AATAI,EACElH,EACE8E,GACAD,EAAmBC,GAJRmC,IAAO9C,IAAiBD,CAIQ,CAC7C,CACF,GAIA2C,EAAO,KAAK,iCAAiC;CAC7C,IAAMM,IAAsB9G,EAAK,KAC/ByG,EAAQ,MACR,OACA,UACA,YACF;CAQA,AAPAI,EACElH,EACEmH,GACA7B,EAAsB6B,CAAmB,CAC3C,CACF,GAEAN,EAAO,KAAK,qCAAqC;CACjD,IAAMO,IAAmB/G,EAAK,KAC5ByG,EAAQ,MACR,OACA,UACA,gBACF;CAKA,OAJAI,EACElH,EAAoBoH,GAAkBtB,EAAmBsB,CAAgB,CAAC,CAC5E,GAEO;EACL,SAAS,CAAC;EACV;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
1
+ {"version":3,"file":"generate.runtime-9KuMcI5r.js","names":["FAILURE_HINT","NOT_FOUND_HINT","FAILURE_HINT","FAILURE_HINT","dedent","getLogger","withInMemoryScript","formatLikeSource","ensureImports","modifyOutcomeToFile","SvelteFile","probeFirstExisting","VITE_CONFIG_CANDIDATES","fs","path","FAILURE_HINT$3","NOT_FOUND_HINT$1","elementName","text","modifyViteConfig","call","pluginArgs","viteConfigPath","sourceFile","Project","QuoteKind","changed","failed","d","configArg","SyntaxKind","ce","configObj","pluginsProp","pluginsInit","arr","elements","el","sveltekitIndex","newProject","ensureNamedImports","existing","moduleSpecifier","names","name","ni","ensureImportSpec","spec","unwrapFunction","Node","node","arg","fn","findLoadFunction","declaration","variable","initializer","isFunctionNode","findFinalReturn","statements","body","last","r","returnedObject","expression","statement","hasProperty","object","property","hasSpreadOf","expressionText","inspectEventParameter","params","param","nameNode","DEFAULT_LOCALE","WUCHALE_LOCALE","eventName","cmsSnippet","locale","importLine","parts","createdLayoutServer","imports","snippet","FAILURE_HINT$2","modifyLayoutServer","layoutServerPath","event","returned","spreadIndex","returnIndex","destructuring","typeText","FAILURE_HINT$1","modifyLayoutUniversal","layoutPath","dataExpression","element","IMPORT_SNIPPET","MARKUP_SNIPPET","NOT_FOUND_HINT","FAILURE_HINT","modifyLayoutSvelte","file","out","source","sf","readWuchaleLocales","configPath","root","match","locales","m","vitePluginArgs","mode","list","generate","logger","options","modifies","resolveMode","i18n","pushResult","layoutUniversalPath","layoutSveltePath"],"sources":["../../src/patterns/enable/cms/modifies/vite-config.ts","../../src/patterns/enable/cms/modifies/load-function.ts","../../src/patterns/enable/cms/modifies/layout.server.ts","../../src/patterns/enable/cms/modifies/layout.ts","../../src/patterns/enable/cms/modifies/layout.svelte.ts","../../src/patterns/enable/cms/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport {\n Project,\n QuoteKind,\n SyntaxKind,\n type ArrayLiteralExpression,\n type ObjectLiteralExpression,\n type PropertyAssignment,\n} from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { formatLikeSource } from \"../../../../runtime/ts-morph-helpers\";\n\nconst FAILURE_HINT = [\n \"Add the CMS plugin to your Vite config, ahead of sveltekit():\",\n \"\",\n \"import { cms } from '@velastack/cms/vite';\",\n \"\",\n \"export default defineConfig({\",\n \" plugins: [cms(), sveltekit(), /* ...existing plugins */],\",\n \"});\",\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create a Vite config with the CMS plugin ahead of sveltekit():\",\n \"\",\n \"import { defineConfig } from 'vite';\",\n \"import { sveltekit } from '@sveltejs/kit/vite';\",\n \"import { cms } from '@velastack/cms/vite';\",\n \"\",\n \"export default defineConfig({\",\n \" plugins: [cms(), sveltekit()],\",\n \"});\",\n].join(\"\\n\");\n\nfunction elementName(text: string): string {\n return text.replace(/\\s/g, \"\");\n}\n\n/**\n * Registers `cms(...)` from `@velastack/cms/vite` in the Vite plugin list, just\n * ahead of `sveltekit()`. Only the plugin array is touched, so the inline\n * `sveltekit({ ... })` shape the templates use is left alone.\n */\nexport function modifyViteConfig(\n viteConfigPath: string,\n pluginArgs = \"\",\n): ModifyOutcome {\n const call = `cms(${pluginArgs})`;\n if (!fs.existsSync(viteConfigPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const project = new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(viteConfigPath);\n\n let changed = false;\n let failed = false;\n\n const hasImport = sourceFile\n .getImportDeclarations()\n .some((d) => d.getModuleSpecifierValue() === \"@velastack/cms/vite\");\n\n if (!hasImport) {\n sourceFile.insertImportDeclaration(0, {\n namedImports: [\"cms\"],\n moduleSpecifier: \"@velastack/cms/vite\",\n });\n changed = true;\n }\n\n const defineConfigCall = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((ce) => ce.getExpression().getText() === \"defineConfig\");\n\n const configArg = defineConfigCall?.getArguments()?.[0];\n const configObj =\n configArg?.getKind() === SyntaxKind.ObjectLiteralExpression\n ? (configArg as ObjectLiteralExpression)\n : null;\n\n if (!configObj) {\n failed = true;\n } else {\n const pluginsProp = configObj.getProperty(\"plugins\");\n if (!pluginsProp) {\n configObj.addPropertyAssignment({\n name: \"plugins\",\n initializer: `[${call}]`,\n });\n changed = true;\n } else if (pluginsProp.getKind() !== SyntaxKind.PropertyAssignment) {\n failed = true;\n } else {\n const pluginsInit = (pluginsProp as PropertyAssignment).getInitializer();\n\n if (!pluginsInit) {\n (pluginsProp as PropertyAssignment).setInitializer(`[${call}]`);\n changed = true;\n } else if (pluginsInit.getKind() !== SyntaxKind.ArrayLiteralExpression) {\n failed = true;\n } else {\n const arr = pluginsInit as ArrayLiteralExpression;\n const elements = arr.getElements();\n const hasCms = elements.some((el) =>\n elementName(el.getText()).startsWith(\"cms(\"),\n );\n\n if (!hasCms) {\n const sveltekitIndex = elements.findIndex((el) =>\n elementName(el.getText()).startsWith(\"sveltekit(\"),\n );\n arr.insertElement(sveltekitIndex === -1 ? 0 : sveltekitIndex, call);\n changed = true;\n }\n }\n }\n }\n\n if (changed) {\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n }\n\n if (failed) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n return { status: \"success\", changed };\n}\n","import {\n Node,\n Project,\n QuoteKind,\n SyntaxKind,\n type ArrowFunction,\n type Block,\n type FunctionDeclaration,\n type FunctionExpression,\n type ObjectLiteralExpression,\n type ParameterDeclaration,\n type ReturnStatement,\n type SourceFile,\n} from \"ts-morph\";\nimport type { ImportSpec } from \"../../../../runtime/ts-morph-helpers\";\n\n/**\n * What the two layout modifiers have in common: finding a SvelteKit `load`,\n * working out how it receives its event, and locating the object it returns.\n */\n\nexport type LoadFunction =\n ArrowFunction | FunctionExpression | FunctionDeclaration;\n\nexport function newProject(): Project {\n return new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n}\n\nexport function ensureNamedImports(\n sourceFile: SourceFile,\n moduleSpecifier: string,\n names: string[],\n) {\n const existing = sourceFile\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === moduleSpecifier);\n if (!existing) {\n sourceFile.addImportDeclaration({ namedImports: names, moduleSpecifier });\n return;\n }\n for (const name of names) {\n const has = existing.getNamedImports().some((ni) => ni.getName() === name);\n if (!has) existing.addNamedImport(name);\n }\n}\n\nexport function ensureImportSpec(sourceFile: SourceFile, spec: ImportSpec) {\n if (spec.namedImports?.length) {\n ensureNamedImports(sourceFile, spec.moduleSpecifier, spec.namedImports);\n }\n const existing = sourceFile\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === spec.moduleSpecifier);\n if (existing) return;\n sourceFile.addImportDeclaration({\n moduleSpecifier: spec.moduleSpecifier,\n defaultImport: spec.defaultImport,\n namespaceImport: spec.namespaceImport,\n });\n}\n\n/** Peel wrappers (`loadFlash(fn)`, `(fn)`, `fn satisfies X`) down to the function. */\nfunction unwrapFunction(node: Node): ArrowFunction | FunctionExpression | null {\n if (Node.isArrowFunction(node) || Node.isFunctionExpression(node)) {\n return node;\n }\n if (\n Node.isParenthesizedExpression(node) ||\n Node.isAsExpression(node) ||\n Node.isSatisfiesExpression(node)\n ) {\n return unwrapFunction(node.getExpression());\n }\n if (Node.isCallExpression(node)) {\n for (const arg of node.getArguments()) {\n const fn = unwrapFunction(arg);\n if (fn) return fn;\n }\n }\n return null;\n}\n\n/** The exported `load`, whether declared as a function or wrapped in a const. */\nexport function findLoadFunction(sourceFile: SourceFile): LoadFunction | null {\n const declaration = sourceFile.getFunction(\"load\");\n if (declaration) {\n return declaration.isExported() ? declaration : null;\n }\n\n const variable = sourceFile.getVariableDeclaration(\"load\");\n if (!variable) return null;\n if (!variable.getVariableStatement()?.isExported()) return null;\n\n const initializer = variable.getInitializer();\n return initializer ? unwrapFunction(initializer) : null;\n}\n\nfunction isFunctionNode(node: Node): boolean {\n return (\n Node.isArrowFunction(node) ||\n Node.isFunctionExpression(node) ||\n Node.isFunctionDeclaration(node) ||\n Node.isMethodDeclaration(node)\n );\n}\n\n/**\n * The single, final `return <expression>` of the load body, or null when the\n * body has early returns — those would need any insertion hoisted above them,\n * and guessing where is worse than refusing.\n */\nexport function findFinalReturn(\n fn: LoadFunction,\n body: Block,\n): ReturnStatement | null {\n const statements = body.getStatements();\n const last = statements[statements.length - 1];\n if (!last || !Node.isReturnStatement(last)) return null;\n\n const returns = body\n .getDescendantsOfKind(SyntaxKind.ReturnStatement)\n .filter((r) => r.getFirstAncestor(isFunctionNode) === fn);\n if (returns.length !== 1) return null;\n\n return last;\n}\n\n/** The object literal a return statement yields, unwrapping parentheses. */\nexport function returnedObject(\n statement: ReturnStatement,\n): ObjectLiteralExpression | null {\n let expression = statement.getExpression();\n while (expression && Node.isParenthesizedExpression(expression)) {\n expression = expression.getExpression();\n }\n if (!expression || !Node.isObjectLiteralExpression(expression)) return null;\n return expression;\n}\n\nexport function hasProperty(\n object: ObjectLiteralExpression,\n name: string,\n): boolean {\n return object.getProperties().some((property) => {\n if (\n Node.isPropertyAssignment(property) ||\n Node.isShorthandPropertyAssignment(property)\n ) {\n return property.getName() === name;\n }\n return false;\n });\n}\n\nexport function hasSpreadOf(\n object: ObjectLiteralExpression,\n expressionText: string,\n): boolean {\n return object\n .getProperties()\n .some(\n (property) =>\n Node.isSpreadAssignment(property) &&\n property.getExpression().getText() === expressionText,\n );\n}\n\n/** How a load receives its event: not at all, by name, or destructured. */\nexport type EventParameter =\n | { kind: \"none\" }\n | { kind: \"identifier\"; name: string; param: ParameterDeclaration }\n | {\n kind: \"binding\";\n pattern: import(\"ts-morph\").ObjectBindingPattern;\n param: ParameterDeclaration;\n }\n | { kind: \"unsupported\" };\n\nexport function inspectEventParameter(fn: LoadFunction): EventParameter {\n const params = fn.getParameters();\n if (params.length === 0) return { kind: \"none\" };\n if (params.length > 1) return { kind: \"unsupported\" };\n\n const param = params[0];\n if (param.getInitializer() || param.isRestParameter()) {\n return { kind: \"unsupported\" };\n }\n const nameNode = param.getNameNode();\n if (Node.isIdentifier(nameNode)) {\n return { kind: \"identifier\", name: nameNode.getText(), param };\n }\n if (Node.isObjectBindingPattern(nameNode)) {\n return { kind: \"binding\", pattern: nameNode, param };\n }\n return { kind: \"unsupported\" };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport dedent from \"dedent\";\nimport { Node } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport type { ImportSpec } from \"../../../../runtime/ts-morph-helpers\";\nimport {\n ensureImportSpec,\n ensureNamedImports,\n findFinalReturn,\n findLoadFunction,\n hasProperty,\n inspectEventParameter,\n newProject,\n returnedObject,\n} from \"./load-function\";\nimport { formatLikeSource } from \"../../../../runtime/ts-morph-helpers\";\n\nexport interface LayoutServerLocale {\n /**\n * Expression passed as `locale` to `loadCms`, given the name of the load's\n * event parameter: `() => \"'en'\"` or `(event) => \\`getLocale(${event}.url)\\``.\n */\n expression: (eventName: string) => string;\n /** Imports the expression depends on. */\n imports?: ImportSpec[];\n}\n\n/** A single-locale site: the literal default locale. */\nexport const DEFAULT_LOCALE: LayoutServerLocale = {\n expression: () => \"'en'\",\n};\n\n/** A wuchale site: the locale enable-i18n's reroute already resolved from the URL. */\nexport const WUCHALE_LOCALE: LayoutServerLocale = {\n expression: (eventName) => `getLocale(${eventName}.url)`,\n imports: [\n { namedImports: [\"getLocale\"], moduleSpecifier: \"#locales/main.url.js\" },\n ],\n};\n\nfunction cmsSnippet(eventName: string, locale: string): string {\n return dedent`\n const { cms, notFound, gone, redirectTo } = await loadCms(${eventName}, { locale: ${locale} });\n if (redirectTo) redirect(308, redirectTo);\n if (gone) error(410, 'Gone');\n if (notFound) error(404, 'Not found');\n `;\n}\n\nfunction importLine(spec: ImportSpec): string {\n const parts: string[] = [];\n if (spec.defaultImport) parts.push(spec.defaultImport);\n if (spec.namespaceImport) parts.push(`* as ${spec.namespaceImport}`);\n if (spec.namedImports?.length)\n parts.push(`{ ${spec.namedImports.join(\", \")} }`);\n return `import ${parts.join(\", \")} from '${spec.moduleSpecifier}';`;\n}\n\n/**\n * A root `+layout.server.ts` written from scratch, for a project that has\n * none — the static template keeps its layout load universal.\n */\nexport function createdLayoutServer(locale: LayoutServerLocale): string {\n const imports = [\n \"import { error, redirect } from '@sveltejs/kit';\",\n \"import { loadCms } from '#lib/cms.js';\",\n ...(locale.imports ?? []).map(importLine),\n \"import type { LayoutServerLoad } from './$types';\",\n ].join(\"\\n\");\n const snippet = cmsSnippet(\"event\", locale.expression(\"event\"))\n .split(\"\\n\")\n .join(\"\\n\\t\");\n\n return dedent`\n ${imports}\n\n export const load: LayoutServerLoad = async (event) => {\n \t${snippet}\n\n \treturn { cms };\n };\n `.concat(\"\\n\");\n}\n\nconst FAILURE_HINT = [\n \"Call loadCms from the root +layout.server.ts load and return `cms`:\",\n \"\",\n createdLayoutServer(DEFAULT_LOCALE).trimEnd(),\n \"\",\n \"loadCms needs the whole event, so a destructured parameter has to become\",\n \"`event` with the destructuring moved into the body.\",\n].join(\"\\n\");\n\n/**\n * Wires `loadCms` into the root `+layout.server.ts`, creating the file when\n * the project has none:\n *\n * - `loadCms` needs the whole request event, so a destructured parameter is\n * renamed to `event` and the destructuring becomes the first statement.\n * - The tombstone triple (`redirectTo`, `gone`, `notFound`) is handled just\n * before the return.\n * - `cms` is added to the returned object, ahead of any spread so nothing\n * later can shadow it.\n *\n * Anything else — no exported `load`, an expression-bodied arrow, several\n * returns, a non-literal return — is reported as `failed` with the snippet to\n * paste, and the file is left exactly as it was.\n */\nexport function modifyLayoutServer(\n layoutServerPath: string,\n locale: LayoutServerLocale = DEFAULT_LOCALE,\n): ModifyOutcome {\n if (!fs.existsSync(layoutServerPath)) {\n fs.mkdirSync(path.dirname(layoutServerPath), { recursive: true });\n fs.writeFileSync(layoutServerPath, createdLayoutServer(locale));\n return { status: \"success\", changed: true };\n }\n\n const original = fs.readFileSync(layoutServerPath, \"utf8\");\n if (original.includes(\"loadCms(\")) {\n return { status: \"success\", changed: false };\n }\n\n const sourceFile = newProject().addSourceFileAtPath(layoutServerPath);\n\n // --- Inspect everything before touching anything. ---\n const fn = findLoadFunction(sourceFile);\n if (!fn) return { status: \"failed\", message: FAILURE_HINT };\n\n const body = fn.getBody();\n if (!body || !Node.isBlock(body)) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const event = inspectEventParameter(fn);\n if (event.kind === \"unsupported\") {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const returned = findFinalReturn(fn, body);\n const object = returned && returnedObject(returned);\n if (!returned || !object) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const eventName = event.kind === \"identifier\" ? event.name : \"event\";\n\n // --- Mutate bottom-up so earlier node references stay valid. ---\n if (!hasProperty(object, \"cms\")) {\n const spreadIndex = object\n .getProperties()\n .findIndex((property) => Node.isSpreadAssignment(property));\n if (spreadIndex === -1) {\n object.addShorthandPropertyAssignment({ name: \"cms\" });\n } else {\n object.insertShorthandPropertyAssignment(spreadIndex, { name: \"cms\" });\n }\n }\n\n // insertStatements counts comment lines, which getStatements() skips.\n const returnIndex = body.getStatementsWithComments().indexOf(returned);\n body.insertStatements(\n returnIndex,\n `\\n${cmsSnippet(eventName, locale.expression(eventName))}\\n`,\n );\n\n if (event.kind === \"binding\") {\n const destructuring = event.pattern.getText();\n body.insertStatements(0, `const ${destructuring} = ${eventName};`);\n const typeText = event.param.getTypeNode()?.getText();\n event.param.replaceWithText(\n typeText ? `${eventName}: ${typeText}` : eventName,\n );\n } else if (event.kind === \"none\") {\n fn.addParameter({ name: eventName });\n }\n\n if (!fn.isAsync()) fn.setIsAsync(true);\n\n ensureNamedImports(sourceFile, \"@sveltejs/kit\", [\"error\", \"redirect\"]);\n ensureNamedImports(sourceFile, \"#lib/cms.js\", [\"loadCms\"]);\n for (const spec of locale.imports ?? []) {\n ensureImportSpec(sourceFile, spec);\n }\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Node } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport {\n findFinalReturn,\n findLoadFunction,\n hasSpreadOf,\n inspectEventParameter,\n newProject,\n returnedObject,\n} from \"./load-function\";\nimport { formatLikeSource } from \"../../../../runtime/ts-morph-helpers\";\n\nconst FAILURE_HINT = dedent`\n Forward the server load's data through the root +layout.ts, so \\`cms\\` reaches\n the page:\n\n export const load = async ({ url, data }) => {\n // ...existing code...\n return { ...data, /* existing keys */ };\n };\n`;\n\n/**\n * Make a universal root \\`+layout.ts\\` forward its server load's data.\n *\n * SvelteKit hands a universal load the server load's result as \\`data\\`, and\n * only what the universal load returns reaches the page. A layout that\n * returns its own object without spreading \\`data\\` — the static template\n * does — would drop \\`cms\\` on the floor once \\`+layout.server.ts\\` exists.\n *\n * No file, or a file without a \\`load\\`, needs nothing: server data flows\n * through on its own.\n */\nexport function modifyLayoutUniversal(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"success\", changed: false };\n }\n\n const sourceFile = newProject().addSourceFileAtPath(layoutPath);\n\n const fn = findLoadFunction(sourceFile);\n if (!fn) return { status: \"success\", changed: false };\n\n const body = fn.getBody();\n if (!body || !Node.isBlock(body)) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const event = inspectEventParameter(fn);\n if (event.kind === \"unsupported\") {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const returned = findFinalReturn(fn, body);\n if (!returned) return { status: \"failed\", message: FAILURE_HINT };\n\n const dataExpression =\n event.kind === \"identifier\" ? `${event.name}.data` : \"data\";\n\n // `return data;` already forwards everything.\n const expression = returned.getExpression();\n if (expression && expression.getText() === dataExpression) {\n return { status: \"success\", changed: false };\n }\n\n const object = returnedObject(returned);\n if (!object) return { status: \"failed\", message: FAILURE_HINT };\n if (hasSpreadOf(object, dataExpression)) {\n return { status: \"success\", changed: false };\n }\n\n // --- Mutate bottom-up so earlier node references stay valid. ---\n // First, so the layout's own keys still win over anything the server sent.\n object.insertSpreadAssignment(0, { expression: dataExpression });\n\n if (event.kind === \"binding\") {\n const hasData = event.pattern\n .getElements()\n .some((element) => element.getName() === \"data\");\n if (!hasData) {\n const text = event.pattern.getText();\n event.pattern.replaceWithText(text.replace(/^\\{\\s*/, \"{ data, \"));\n }\n } else if (event.kind === \"none\") {\n fn.addParameter({ name: \"{ data }\" });\n }\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n ensureImports,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst IMPORT_SNIPPET = dedent`\n import { AdminBar } from '@velastack/cms';\n`;\n\nconst MARKUP_SNIPPET = \"\\n<AdminBar />\\n\";\n\nconst NOT_FOUND_HINT = [\n \"Create the root src/routes/+layout.svelte and mount <AdminBar /> inside it.\",\n \"\",\n \"Import for the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup to add at the top level of the layout, above {@render children()}:\",\n MARKUP_SNIPPET.trim(),\n].join(\"\\n\");\n\nconst FAILURE_HINT = [\n \"Mount <AdminBar /> in the root src/routes/+layout.svelte.\",\n \"\",\n 'Import for a <script lang=\"ts\"> tag:',\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup to add at the top level of the layout, above {@render children()}:\",\n MARKUP_SNIPPET.trim(),\n].join(\"\\n\");\n\n/**\n * Mounts `<AdminBar />` at the top level of the root layout, ahead of\n * `{@render children()}` so the bar is in the DOM before the page content.\n * Falls back to appending when the layout has no render tag or slot.\n */\nexport function modifyLayoutSvelte(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const file = SvelteFile.fromPath(layoutPath);\n if (file.hasElement(\"AdminBar\")) {\n return { status: \"success\", changed: false };\n }\n if (!file.getScript()) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n ensureImports(sf, [\n { namedImports: [\"AdminBar\"], moduleSpecifier: \"@velastack/cms\" },\n ]);\n });\n return out;\n });\n\n if (!file.insertBeforeChildren(MARKUP_SNIPPET)) {\n file.appendMarkup(MARKUP_SNIPPET);\n }\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport {\n probeFirstExisting,\n VITE_CONFIG_CANDIDATES,\n} from \"../../../runtime/config-target\";\nimport { resolveMode, type CmsMode } from \"./generate\";\nimport { modifyViteConfig } from \"./modifies/vite-config\";\nimport {\n DEFAULT_LOCALE,\n WUCHALE_LOCALE,\n modifyLayoutServer,\n} from \"./modifies/layout.server\";\nimport { modifyLayoutUniversal } from \"./modifies/layout\";\nimport { modifyLayoutSvelte } from \"./modifies/layout.svelte\";\n\n/** The locale list from `wuchale.config.js`, or null when it cannot be read. */\nexport function readWuchaleLocales(root: string): string[] | null {\n const configPath = path.join(root, \"wuchale.config.js\");\n if (!fs.existsSync(configPath)) return null;\n const match = fs\n .readFileSync(configPath, \"utf8\")\n .match(/locales:\\s*\\[([^\\]]*)\\]/);\n if (!match) return null;\n const locales = [...match[1].matchAll(/['\"]([^'\"]+)['\"]/g)].map((m) => m[1]);\n return locales.length > 0 ? locales : null;\n}\n\n/**\n * Arguments for the `cms()` Vite plugin.\n *\n * A hosted CMS needs the endpoint and locales at build time so media can be\n * downloaded into the prerendered site. An app hosting the backend itself\n * needs nothing: the media steps are no-ops without an endpoint.\n */\nexport function vitePluginArgs(mode: CmsMode, locales: string[]): string {\n if (mode.local) return \"\";\n const list = locales.map((locale) => `'${locale}'`).join(\", \");\n return `{ endpoint: '${mode.endpoint}', locales: [${list}] }`;\n}\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n const mode = resolveMode(options);\n const i18n = options.features.i18n;\n\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Modifying vite.config\");\n const viteConfigPath =\n probeFirstExisting(options.root, VITE_CONFIG_CANDIDATES) ??\n path.join(options.root, VITE_CONFIG_CANDIDATES[0]);\n const locales = (i18n && readWuchaleLocales(options.root)) || [\"en\"];\n pushResult(\n modifyOutcomeToFile(\n viteConfigPath,\n modifyViteConfig(viteConfigPath, vitePluginArgs(mode, locales)),\n ),\n );\n\n logger.info(\"Modifying src/routes/+layout.server.ts\");\n const layoutServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.server.ts\",\n );\n const locale = i18n ? WUCHALE_LOCALE : DEFAULT_LOCALE;\n pushResult(\n modifyOutcomeToFile(\n layoutServerPath,\n modifyLayoutServer(layoutServerPath, locale),\n ),\n );\n\n // A universal root layout has to pass the server load's data along, or\n // `cms` never reaches the page. The static template has one.\n logger.info(\"Modifying src/routes/+layout.ts\");\n const layoutUniversalPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n layoutUniversalPath,\n modifyLayoutUniversal(layoutUniversalPath),\n ),\n );\n\n logger.info(\"Modifying src/routes/+layout.svelte\");\n const layoutSveltePath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(layoutSveltePath, modifyLayoutSvelte(layoutSveltePath)),\n );\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;;;AAYA,IAAMA,IAAe;CACnB;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,CAAC,KAAK,IAAI,GAELC,IAAiB;CACrB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,CAAC,KAAK,IAAI;AAEX,SAASgB,EAAY,GAAsB;CACzC,OAAOC,EAAK,QAAQ,OAAO,EAAE;AAC/B;AAOA,SAAgBC,EACd,GACA,IAAa,IACE;CACf,IAAMC,IAAO,OAAOC,EAAW;CAC/B,IAAI,CAACR,EAAG,WAAWS,CAAc,GAC/B,OAAO;EAAE,QAAQ;EAAa,SAASrB;CAAe;CAOxD,IAAMsB,IAAa,IAJCC,EAAQ;EAC1B,iBAAiB,EAAE,SAAS,GAAK;EACjC,sBAAsB,EAAE,WAAWC,EAAU,OAAO;CACtD,CACmB,CAAA,CAAQ,oBAAoBH,CAAc,GAEzDI,IAAU,IACVC,IAAS;CAMb,AAJkBJ,EACf,sBAAsB,CAAC,CACvB,MAAM,MAAMK,EAAE,wBAAwB,MAAM,qBAE1C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,IAAmB/G,EAAK,KAC5ByG,EAAQ,MACR,OACA,UACA,gBACF;CAKA,OAJAI,EACElH,EAAoBoH,GAAkBtB,EAAmBsB,CAAgB,CAAC,CAC5E,GAEO;EACL,SAAS,CAAC;EACV;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
@@ -1,9 +1,9 @@
1
1
  import { t as e } from "./dedent-Gq6Krl4n.js";
2
2
  import { n as t } from "./logger-CQONztPm.js";
3
- import { i as n, n as r, t as i } from "./pocketbase-B017Cqjq.js";
4
- import { n as a } from "./site-DkU1-VRq.js";
5
- import { _ as o, a as s, o as c, r as l } from "./ts-morph-helpers-Bepc-Es2.js";
6
- import { r as u } from "./modify-file-289rStJ2.js";
3
+ import { i as n, n as r, t as i } from "./pocketbase-DL02rq73.js";
4
+ import { n as a } from "./site-BoujshKo.js";
5
+ import { _ as o, a as s, o as c, r as l } from "./ts-morph-helpers-CHI9wAil.js";
6
+ import { r as u } from "./modify-file-COBp4eCh.js";
7
7
  import { t as d } from "./svelte-file-Dv5-bl79.js";
8
8
  import f from "node:fs";
9
9
  import p from "node:path";
@@ -330,4 +330,4 @@ async function O(e) {
330
330
  //#endregion
331
331
  export { O as generate };
332
332
 
333
- //# sourceMappingURL=generate.runtime-wziCW3ct.js.map
333
+ //# sourceMappingURL=generate.runtime-B10-KA87.js.map