@velastack/patterns 0.12.0 → 0.13.1

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 (229) hide show
  1. package/README.md +21 -2
  2. package/dist/chunks/{_layout-DQhSAhfF.js → _layout-Dju9EYqa.js} +6 -8
  3. package/dist/chunks/{_layout-DQhSAhfF.js.map → _layout-Dju9EYqa.js.map} +1 -1
  4. package/dist/chunks/{_page-C7kGoW7_.js → _page-44USwLXO.js} +2 -3
  5. package/dist/chunks/{_page-C7kGoW7_.js.map → _page-44USwLXO.js.map} +1 -1
  6. package/dist/chunks/{_page-DoPdZgZv.js → _page-Bt37d4uo.js} +2 -3
  7. package/dist/chunks/_page-Bt37d4uo.js.map +1 -0
  8. package/dist/chunks/{_page-B6yd6_Vl.js → _page-DcbEFpyw.js} +2 -3
  9. package/dist/chunks/_page-DcbEFpyw.js.map +1 -0
  10. package/dist/chunks/{auth-pages-jsyDV1GR.js → auth-pages-BW3_yluN.js} +6 -9
  11. package/dist/chunks/{auth-pages-jsyDV1GR.js.map → auth-pages-BW3_yluN.js.map} +1 -1
  12. package/dist/chunks/{collections-DZOuRpvS.js → collections-CFW9ZqUE.js} +5 -7
  13. package/dist/chunks/{collections-DZOuRpvS.js.map → collections-CFW9ZqUE.js.map} +1 -1
  14. package/dist/chunks/{collections-DzwWwFUQ.js → collections-D-xbHi4M.js} +39 -45
  15. package/dist/chunks/{collections-DzwWwFUQ.js.map → collections-D-xbHi4M.js.map} +1 -1
  16. package/dist/chunks/{compose-handle-BBlamPfx.js → compose-handle-Da7m6lV_.js} +3 -4
  17. package/dist/chunks/{compose-handle-BBlamPfx.js.map → compose-handle-Da7m6lV_.js.map} +1 -1
  18. package/dist/chunks/{config-target-BgyFkbFL.js → config-target-DJbVHwHl.js} +3 -4
  19. package/dist/chunks/{config-target-BgyFkbFL.js.map → config-target-DJbVHwHl.js.map} +1 -1
  20. package/dist/chunks/constants-DpK-r_m5.js +85 -0
  21. package/dist/chunks/constants-DpK-r_m5.js.map +1 -0
  22. package/dist/chunks/{currency.server-CzHS7Svd.js → currency.server-BwuXG0a9.js} +9 -11
  23. package/dist/chunks/{currency.server-CzHS7Svd.js.map → currency.server-BwuXG0a9.js.map} +1 -1
  24. package/dist/chunks/{dedent-Gq6Krl4n.js → dedent-CCUOcPFW.js} +2 -3
  25. package/dist/chunks/{dedent-Gq6Krl4n.js.map → dedent-CCUOcPFW.js.map} +1 -1
  26. package/dist/chunks/{dispatch-BIvOwbKN.js → dispatch-BxlKS_5v.js} +2 -3
  27. package/dist/chunks/{dispatch-BIvOwbKN.js.map → dispatch-BxlKS_5v.js.map} +1 -1
  28. package/dist/chunks/{env-BugddEjd.js → env-AxyRWcC_.js} +2 -3
  29. package/dist/chunks/{env-BugddEjd.js.map → env-AxyRWcC_.js.map} +1 -1
  30. package/dist/chunks/{env-vars-mnRA0hOe.js → env-vars-CUh4mLM_.js} +2 -3
  31. package/dist/chunks/{env-vars-mnRA0hOe.js.map → env-vars-CUh4mLM_.js.map} +1 -1
  32. package/dist/chunks/{env-vars-CNH-ItSY.js → env-vars-CVn2076k.js} +58 -59
  33. package/dist/chunks/{env-vars-CNH-ItSY.js.map → env-vars-CVn2076k.js.map} +1 -1
  34. package/dist/chunks/{env-vars-Cr4lbMD_.js → env-vars-T3_7JNSg.js} +3 -4
  35. package/dist/chunks/{env-vars-Cr4lbMD_.js.map → env-vars-T3_7JNSg.js.map} +1 -1
  36. package/dist/chunks/{env-vars-file-B_6esJW3.js → env-vars-file-B2zHQZqO.js} +2 -3
  37. package/dist/chunks/{env-vars-file-B_6esJW3.js.map → env-vars-file-B2zHQZqO.js.map} +1 -1
  38. package/dist/chunks/{env.preview-uMRKT5Pc.js → env.preview-C676UTOP.js} +2 -3
  39. package/dist/chunks/{env.preview-uMRKT5Pc.js.map → env.preview-C676UTOP.js.map} +1 -1
  40. package/dist/chunks/{errors-DR3gF_7a.js → errors-DdSUZI8f.js} +2 -3
  41. package/dist/chunks/{errors-DR3gF_7a.js.map → errors-DdSUZI8f.js.map} +1 -1
  42. package/dist/chunks/{format-result-BVoLVknk.js → format-result-CojavkIZ.js} +2 -3
  43. package/dist/chunks/{format-result-BVoLVknk.js.map → format-result-CojavkIZ.js.map} +1 -1
  44. package/dist/chunks/{generate-BEc_h7OI.js → generate-BCYvhyF9.js} +62 -63
  45. package/dist/chunks/{generate-BEc_h7OI.js.map → generate-BCYvhyF9.js.map} +1 -1
  46. package/dist/chunks/{generate-DyV5R8NP.js → generate-CKuUg3p-.js} +3 -4
  47. package/dist/chunks/{generate-DyV5R8NP.js.map → generate-CKuUg3p-.js.map} +1 -1
  48. package/dist/chunks/{generate-CtQcmjPM.js → generate-CY_Ii_bz.js} +79 -82
  49. package/dist/chunks/generate-CY_Ii_bz.js.map +1 -0
  50. package/dist/chunks/generate-CuOm66dn.js +57 -0
  51. package/dist/chunks/{generate-D21dCU-o.js.map → generate-CuOm66dn.js.map} +1 -1
  52. package/dist/chunks/{generate-BrOPb9tW.js → generate-DYq5Oj58.js} +3 -4
  53. package/dist/chunks/{generate-BrOPb9tW.js.map → generate-DYq5Oj58.js.map} +1 -1
  54. package/dist/chunks/{generate-DiwvSC9c.js → generate-F4FDWvFo.js} +13 -14
  55. package/dist/chunks/{generate-DiwvSC9c.js.map → generate-F4FDWvFo.js.map} +1 -1
  56. package/dist/chunks/{generate-C3OaUggX.js → generate-oZ1QeqPr.js} +25 -27
  57. package/dist/chunks/generate-oZ1QeqPr.js.map +1 -0
  58. package/dist/chunks/{generate.runtime-DOv-bhM6.js → generate.runtime-22jW8aVT.js} +37 -41
  59. package/dist/chunks/{generate.runtime-DOv-bhM6.js.map → generate.runtime-22jW8aVT.js.map} +1 -1
  60. package/dist/chunks/{generate.runtime-CtFCayo8.js → generate.runtime-B06rPt_j.js} +103 -108
  61. package/dist/chunks/{generate.runtime-CtFCayo8.js.map → generate.runtime-B06rPt_j.js.map} +1 -1
  62. package/dist/chunks/{generate.runtime-HkvT9gm6.js → generate.runtime-BEmSIAop.js} +44 -47
  63. package/dist/chunks/generate.runtime-BEmSIAop.js.map +1 -0
  64. package/dist/chunks/{generate.runtime-DRuPb-67.js → generate.runtime-BgGeOqYG.js} +19 -21
  65. package/dist/chunks/{generate.runtime-DRuPb-67.js.map → generate.runtime-BgGeOqYG.js.map} +1 -1
  66. package/dist/chunks/generate.runtime-Bz9z0VPR.js +108 -0
  67. package/dist/chunks/{generate.runtime-DUBOC6AA.js.map → generate.runtime-Bz9z0VPR.js.map} +1 -1
  68. package/dist/chunks/{generate.runtime-D34lCyet.js → generate.runtime-C37djibw.js} +25 -27
  69. package/dist/chunks/{generate.runtime-D34lCyet.js.map → generate.runtime-C37djibw.js.map} +1 -1
  70. package/dist/chunks/{generate.runtime-Drpy9sWO.js → generate.runtime-CM3bj0nP.js} +12 -14
  71. package/dist/chunks/{generate.runtime-Drpy9sWO.js.map → generate.runtime-CM3bj0nP.js.map} +1 -1
  72. package/dist/chunks/generate.runtime-CMuxVUIY.js +46 -0
  73. package/dist/chunks/{generate.runtime-DVwha8lZ.js.map → generate.runtime-CMuxVUIY.js.map} +1 -1
  74. package/dist/chunks/{generate.runtime-DlPeHx19.js → generate.runtime-CVqPHddZ.js} +44 -46
  75. package/dist/chunks/generate.runtime-CVqPHddZ.js.map +1 -0
  76. package/dist/chunks/generate.runtime-Cco2mFW2.js +63 -0
  77. package/dist/chunks/{generate.runtime-CPDJolef.js.map → generate.runtime-Cco2mFW2.js.map} +1 -1
  78. package/dist/chunks/generate.runtime-Cg-dfN9B.js +48 -0
  79. package/dist/chunks/{generate.runtime-CAO_SpsA.js.map → generate.runtime-Cg-dfN9B.js.map} +1 -1
  80. package/dist/chunks/{generate.runtime-Dy9uuf7M.js → generate.runtime-Cgam_XCc.js} +47 -50
  81. package/dist/chunks/{generate.runtime-Dy9uuf7M.js.map → generate.runtime-Cgam_XCc.js.map} +1 -1
  82. package/dist/chunks/{generate.runtime-DOWDoe6B.js → generate.runtime-CjqX4tDg.js} +5 -6
  83. package/dist/chunks/{generate.runtime-DOWDoe6B.js.map → generate.runtime-CjqX4tDg.js.map} +1 -1
  84. package/dist/chunks/generate.runtime-Cry-DBNl.js +111 -0
  85. package/dist/chunks/{generate.runtime-CaOO0281.js.map → generate.runtime-Cry-DBNl.js.map} +1 -1
  86. package/dist/chunks/{generate.runtime-CeoqgxiO.js → generate.runtime-Ct7cG8va.js} +76 -79
  87. package/dist/chunks/generate.runtime-Ct7cG8va.js.map +1 -0
  88. package/dist/chunks/generate.runtime-Cxg1b_BK.js +63 -0
  89. package/dist/chunks/{generate.runtime-DbMDlglD.js.map → generate.runtime-Cxg1b_BK.js.map} +1 -1
  90. package/dist/chunks/{generate.runtime-CowdMKQs.js → generate.runtime-CyWuhV6m.js} +16 -18
  91. package/dist/chunks/{generate.runtime-CowdMKQs.js.map → generate.runtime-CyWuhV6m.js.map} +1 -1
  92. package/dist/chunks/{generate.runtime-C_5Ghjri.js → generate.runtime-D769VJFt.js} +3 -4
  93. package/dist/chunks/{generate.runtime-C_5Ghjri.js.map → generate.runtime-D769VJFt.js.map} +1 -1
  94. package/dist/chunks/{generate.runtime-DroVnvQz.js → generate.runtime-DGnXHELM.js} +84 -89
  95. package/dist/chunks/{generate.runtime-DroVnvQz.js.map → generate.runtime-DGnXHELM.js.map} +1 -1
  96. package/dist/chunks/{generate.runtime-CGJ_4VS_.js → generate.runtime-DHJqOJTr.js} +93 -98
  97. package/dist/chunks/{generate.runtime-CGJ_4VS_.js.map → generate.runtime-DHJqOJTr.js.map} +1 -1
  98. package/dist/chunks/{generate.runtime-r9Ouwr5B.js → generate.runtime-DICcLOts.js} +19 -22
  99. package/dist/chunks/{generate.runtime-r9Ouwr5B.js.map → generate.runtime-DICcLOts.js.map} +1 -1
  100. package/dist/chunks/generate.runtime-DWHoDisZ.js +42 -0
  101. package/dist/chunks/{generate.runtime-BL62aRng.js.map → generate.runtime-DWHoDisZ.js.map} +1 -1
  102. package/dist/chunks/{generate.runtime-kEHEiLBL.js → generate.runtime-DfHFd8xs.js} +36 -44
  103. package/dist/chunks/{generate.runtime-kEHEiLBL.js.map → generate.runtime-DfHFd8xs.js.map} +1 -1
  104. package/dist/chunks/{generate.runtime-CCE-9xQV.js → generate.runtime-DhNspd-h.js} +64 -76
  105. package/dist/chunks/generate.runtime-DhNspd-h.js.map +1 -0
  106. package/dist/chunks/{generate.runtime-D_HYO-mG.js → generate.runtime-DkS7CBmK.js} +8 -10
  107. package/dist/chunks/{generate.runtime-D_HYO-mG.js.map → generate.runtime-DkS7CBmK.js.map} +1 -1
  108. package/dist/chunks/generate.runtime-Dtae524O.js +34 -0
  109. package/dist/chunks/{generate.runtime-C8-mjcn8.js.map → generate.runtime-Dtae524O.js.map} +1 -1
  110. package/dist/chunks/{generate.runtime-Bx_CaBZD.js → generate.runtime-Dtf3tF3-.js} +82 -92
  111. package/dist/chunks/generate.runtime-Dtf3tF3-.js.map +1 -0
  112. package/dist/chunks/{generate.runtime-B3yuIjJD.js → generate.runtime-DvTbN-no.js} +88 -145
  113. package/dist/chunks/{generate.runtime-B3yuIjJD.js.map → generate.runtime-DvTbN-no.js.map} +1 -1
  114. package/dist/chunks/{generate.runtime-BK7x32md.js → generate.runtime-EB8vpc7D.js} +57 -66
  115. package/dist/chunks/{generate.runtime-BK7x32md.js.map → generate.runtime-EB8vpc7D.js.map} +1 -1
  116. package/dist/chunks/{generate.runtime-sALBNh1T.js → generate.runtime-TCVlsBbJ.js} +7 -8
  117. package/dist/chunks/{generate.runtime-sALBNh1T.js.map → generate.runtime-TCVlsBbJ.js.map} +1 -1
  118. package/dist/chunks/{generate.runtime-BTHuPon9.js → generate.runtime-YFyuyFhh.js} +108 -132
  119. package/dist/chunks/generate.runtime-YFyuyFhh.js.map +1 -0
  120. package/dist/chunks/{generate.runtime-Ce2O5uWy.js → generate.runtime-cYh0CQ5d.js} +36 -41
  121. package/dist/chunks/{generate.runtime-Ce2O5uWy.js.map → generate.runtime-cYh0CQ5d.js.map} +1 -1
  122. package/dist/chunks/generate.runtime-erWI6j7m.js +64 -0
  123. package/dist/chunks/{generate.runtime-BBfiR_Le.js.map → generate.runtime-erWI6j7m.js.map} +1 -1
  124. package/dist/chunks/{generate.runtime-Brakd35X.js → generate.runtime-hq8xt0m_.js} +21 -23
  125. package/dist/chunks/generate.runtime-hq8xt0m_.js.map +1 -0
  126. package/dist/chunks/{generate.runtime--VeSxyIm.js → generate.runtime-i3tMIA1A.js} +85 -108
  127. package/dist/chunks/{generate.runtime--VeSxyIm.js.map → generate.runtime-i3tMIA1A.js.map} +1 -1
  128. package/dist/chunks/generate.runtime-j_5K3Uue.js +120 -0
  129. package/dist/chunks/generate.runtime-j_5K3Uue.js.map +1 -0
  130. package/dist/chunks/{generate.runtime-DbSRJF-C.js → generate.runtime-mE0knt2T.js} +34 -38
  131. package/dist/chunks/{generate.runtime-DbSRJF-C.js.map → generate.runtime-mE0knt2T.js.map} +1 -1
  132. package/dist/chunks/{layout.svelte-Cb12mxua.js → layout.svelte-B6wOQ7SM.js} +10 -11
  133. package/dist/chunks/{layout.svelte-Cb12mxua.js.map → layout.svelte-B6wOQ7SM.js.map} +1 -1
  134. package/dist/chunks/{lib-specifier-Cngo1zF_.js → lib-specifier-C3M0WTev.js} +2 -3
  135. package/dist/chunks/{lib-specifier-Cngo1zF_.js.map → lib-specifier-C3M0WTev.js.map} +1 -1
  136. package/dist/chunks/{load-function-Dmkhg1pQ.js → load-function-BFvIVsh7.js} +3 -4
  137. package/dist/chunks/{load-function-Dmkhg1pQ.js.map → load-function-BFvIVsh7.js.map} +1 -1
  138. package/dist/chunks/{logger-CQONztPm.js → logger-t1HxmpG2.js} +2 -3
  139. package/dist/chunks/{logger-CQONztPm.js.map → logger-t1HxmpG2.js.map} +1 -1
  140. package/dist/chunks/{modify-file-DdXJCMHN.js → modify-file-CRZ_gMg0.js} +7 -10
  141. package/dist/chunks/{modify-file-DdXJCMHN.js.map → modify-file-CRZ_gMg0.js.map} +1 -1
  142. package/dist/chunks/{modify-nav-user-CJ1LevSU.js → modify-nav-user--7OwY9fI.js} +7 -16
  143. package/dist/chunks/{modify-nav-user-CJ1LevSU.js.map → modify-nav-user--7OwY9fI.js.map} +1 -1
  144. package/dist/chunks/{modify-nav-user-iUpv2lm-.js → modify-nav-user-D42kWyU6.js} +8 -14
  145. package/dist/chunks/{modify-nav-user-iUpv2lm-.js.map → modify-nav-user-D42kWyU6.js.map} +1 -1
  146. package/dist/chunks/modify-svelte-config-remote-wE5K2bU_.js +20 -0
  147. package/dist/chunks/{modify-svelte-config-remote-CEyYydL7.js.map → modify-svelte-config-remote-wE5K2bU_.js.map} +1 -1
  148. package/dist/chunks/{modify-user-signup-DLtopazD.js → modify-user-signup-ENhadGKH.js} +5 -6
  149. package/dist/chunks/{modify-user-signup-DLtopazD.js.map → modify-user-signup-ENhadGKH.js.map} +1 -1
  150. package/dist/chunks/{modify-utils-Cw-on_cL.js → modify-utils--zro3IGe.js} +3 -4
  151. package/dist/chunks/{modify-utils-Cw-on_cL.js.map → modify-utils--zro3IGe.js.map} +1 -1
  152. package/dist/chunks/{package-imports-B9Asv3ZH.js → package-imports-CcIIHbp5.js} +3 -4
  153. package/dist/chunks/{package-imports-B9Asv3ZH.js.map → package-imports-CcIIHbp5.js.map} +1 -1
  154. package/dist/chunks/{pocketbase-C5GS-Dh5.js → pocketbase-CvsJYXj-.js} +2 -3
  155. package/dist/chunks/{pocketbase-C5GS-Dh5.js.map → pocketbase-CvsJYXj-.js.map} +1 -1
  156. package/dist/chunks/{pocketbase-DpudAAmd.js → pocketbase-YG9yht8R.js} +2 -3
  157. package/dist/chunks/{pocketbase-DpudAAmd.js.map → pocketbase-YG9yht8R.js.map} +1 -1
  158. package/dist/chunks/{pocketbase-uOpghyT5.js → pocketbase-gUn2UrDd.js} +6 -14
  159. package/dist/chunks/{pocketbase-uOpghyT5.js.map → pocketbase-gUn2UrDd.js.map} +1 -1
  160. package/dist/chunks/{providers-ypCW70Mb.js → providers-BB3Z2TrN.js} +4 -5
  161. package/dist/chunks/{providers-ypCW70Mb.js.map → providers-BB3Z2TrN.js.map} +1 -1
  162. package/dist/chunks/{providers-CL9kQ4hp.js → providers-tjlFH5di.js} +4 -5
  163. package/dist/chunks/{providers-CL9kQ4hp.js.map → providers-tjlFH5di.js.map} +1 -1
  164. package/dist/chunks/{rolldown-runtime-5HNE8Q1r.js → rolldown-runtime-CwxnZyOB.js} +1 -2
  165. package/dist/chunks/{root-layout.svelte-CUVbnlX-.js → root-layout.svelte-DE0c_y-T.js} +12 -16
  166. package/dist/chunks/{root-layout.svelte-CUVbnlX-.js.map → root-layout.svelte-DE0c_y-T.js.map} +1 -1
  167. package/dist/chunks/{shared-DIDAkVts.js → shared-DE-J_b1j.js} +4 -5
  168. package/dist/chunks/{shared-DIDAkVts.js.map → shared-DE-J_b1j.js.map} +1 -1
  169. package/dist/chunks/{site-CVtsbO_S.js → site-B9hDxucR.js} +11 -12
  170. package/dist/chunks/{site-CVtsbO_S.js.map → site-B9hDxucR.js.map} +1 -1
  171. package/dist/chunks/{stripe-customer-B3tP8gtD.js → stripe-customer-5S-nOXP1.js} +2 -3
  172. package/dist/chunks/stripe-customer-5S-nOXP1.js.map +1 -0
  173. package/dist/chunks/{svelte-file-Dv5-bl79.js → svelte-file-DfplF3BU.js} +2 -3
  174. package/dist/chunks/{svelte-file-Dv5-bl79.js.map → svelte-file-DfplF3BU.js.map} +1 -1
  175. package/dist/chunks/table-core-BXmnfjln.js +120 -0
  176. package/dist/chunks/table-core-BXmnfjln.js.map +1 -0
  177. package/dist/chunks/{taggedTemplateLiteral-KSUnuvOk.js → taggedTemplateLiteral-CLenToGE.js} +1 -2
  178. package/dist/chunks/{test-setup-B37g3TRn.js → test-setup-CbwhAJT4.js} +8 -11
  179. package/dist/chunks/{test-setup-B37g3TRn.js.map → test-setup-CbwhAJT4.js.map} +1 -1
  180. package/dist/chunks/{ts-morph-helpers-CHI9wAil.js → ts-morph-helpers-B4KZXP44.js} +2 -3
  181. package/dist/chunks/{ts-morph-helpers-CHI9wAil.js.map → ts-morph-helpers-B4KZXP44.js.map} +1 -1
  182. package/dist/chunks/{ui-Ct_9B91R.js → ui-Ct6YQuPw.js} +53 -55
  183. package/dist/chunks/{ui-Ct_9B91R.js.map → ui-Ct6YQuPw.js.map} +1 -1
  184. package/dist/chunks/{ui-DD4NltyN.js → ui-D5xgIDR_.js} +3 -4
  185. package/dist/chunks/{ui-DD4NltyN.js.map → ui-D5xgIDR_.js.map} +1 -1
  186. package/dist/chunks/{unmodify-load-Buak-r1f.js → unmodify-load-CdWXJ_Ac.js} +3 -4
  187. package/dist/chunks/{unmodify-load-Buak-r1f.js.map → unmodify-load-CdWXJ_Ac.js.map} +1 -1
  188. package/dist/chunks/{util-BLYliuUK.js → util-ILWdjRAd.js} +2 -3
  189. package/dist/chunks/{util-BLYliuUK.js.map → util-ILWdjRAd.js.map} +1 -1
  190. package/dist/chunks/{whatsapp-Dr29ohbb.js → whatsapp-Bt4o4_q2.js} +3 -4
  191. package/dist/chunks/{whatsapp-Dr29ohbb.js.map → whatsapp-Bt4o4_q2.js.map} +1 -1
  192. package/dist/chunks/write-result-B5KFCqxw.js +487 -0
  193. package/dist/chunks/{write-result-mtVbmDyQ.js.map → write-result-B5KFCqxw.js.map} +1 -1
  194. package/dist/chunks/{wuchale-config-c3Q4JVSF.js → wuchale-config-CNXoq4rc.js} +2 -3
  195. package/dist/chunks/{wuchale-config-c3Q4JVSF.js.map → wuchale-config-CNXoq4rc.js.map} +1 -1
  196. package/dist/index.d.ts +57 -17
  197. package/dist/index.js +2272 -2350
  198. package/dist/index.js.map +1 -1
  199. package/package.json +6 -3
  200. package/dist/chunks/_page-B6yd6_Vl.js.map +0 -1
  201. package/dist/chunks/_page-DoPdZgZv.js.map +0 -1
  202. package/dist/chunks/constants-8cLxGOB0.js +0 -6
  203. package/dist/chunks/constants-8cLxGOB0.js.map +0 -1
  204. package/dist/chunks/generate-C3OaUggX.js.map +0 -1
  205. package/dist/chunks/generate-CtQcmjPM.js.map +0 -1
  206. package/dist/chunks/generate-D21dCU-o.js +0 -58
  207. package/dist/chunks/generate.runtime--yCjGZ6-.js +0 -124
  208. package/dist/chunks/generate.runtime--yCjGZ6-.js.map +0 -1
  209. package/dist/chunks/generate.runtime-BBfiR_Le.js +0 -67
  210. package/dist/chunks/generate.runtime-BL62aRng.js +0 -43
  211. package/dist/chunks/generate.runtime-BTHuPon9.js.map +0 -1
  212. package/dist/chunks/generate.runtime-Brakd35X.js.map +0 -1
  213. package/dist/chunks/generate.runtime-Bx_CaBZD.js.map +0 -1
  214. package/dist/chunks/generate.runtime-C8-mjcn8.js +0 -35
  215. package/dist/chunks/generate.runtime-CAO_SpsA.js +0 -50
  216. package/dist/chunks/generate.runtime-CCE-9xQV.js.map +0 -1
  217. package/dist/chunks/generate.runtime-CPDJolef.js +0 -65
  218. package/dist/chunks/generate.runtime-CaOO0281.js +0 -114
  219. package/dist/chunks/generate.runtime-CeoqgxiO.js.map +0 -1
  220. package/dist/chunks/generate.runtime-DUBOC6AA.js +0 -112
  221. package/dist/chunks/generate.runtime-DVwha8lZ.js +0 -48
  222. package/dist/chunks/generate.runtime-DbMDlglD.js +0 -64
  223. package/dist/chunks/generate.runtime-DlPeHx19.js.map +0 -1
  224. package/dist/chunks/generate.runtime-HkvT9gm6.js.map +0 -1
  225. package/dist/chunks/modify-svelte-config-remote-CEyYydL7.js +0 -42
  226. package/dist/chunks/stripe-customer-B3tP8gtD.js.map +0 -1
  227. package/dist/chunks/table-core-CUGp4Rf2.js +0 -127
  228. package/dist/chunks/table-core-CUGp4Rf2.js.map +0 -1
  229. package/dist/chunks/write-result-mtVbmDyQ.js +0 -499
@@ -1 +1 @@
1
- {"version":3,"file":"providers-CL9kQ4hp.js","names":["InvalidArgumentError","filesUnderPrefix","capabilityName","slug","providerFromArgv","i","argv","arg","unknownProviderMessage","raw","name","providers","provider","providerChoices","providerMarkers","first","resolveProvider","pattern","options","resolveInheritedProvider","candidate","detectedId","capability","detected","providerEnvEdits","heading","variable","supplied","providerEnvVars","suppliedProviderEnv","values","key","value","allProviderPaths","paths","providersRaw","match","id","providerCreates","files","root","a","b"],"sources":["../../src/core/providers.ts"],"sourcesContent":["import type { EnvEdit } from \"../runtime/env\";\nimport type { EnvVarSpec } from \"../runtime/env-vars-file\";\nimport { InvalidArgumentError } from \"./errors\";\nimport type { File, Options, Pattern, Provider, ProviderMarker } from \"./types\";\nimport { filesUnderPrefix } from \"./util\";\n\ntype ProviderPattern = Pick<Pattern, \"slug\" | \"providers\" | \"inheritsProvider\">;\n\n/** `analytics` for `enable-analytics`: how the capability is named to users. */\nexport function capabilityName(slug: string): string {\n return slug.replace(/^enable-/, \"\");\n}\n\n/** `--provider <id>` or `--provider=<id>`, for callers that hand flags through in argv. */\nexport function providerFromArgv(argv: string[]): string | undefined {\n for (let i = 0; i < argv.length; i++) {\n const arg = argv[i];\n if (arg === \"--provider\") return argv[i + 1];\n if (arg.startsWith(\"--provider=\")) return arg.slice(\"--provider=\".length);\n }\n return undefined;\n}\n\nexport function unknownProviderMessage(\n name: string,\n raw: string,\n providers: Provider[],\n): string {\n return [\n `Unknown provider \"${raw}\" for ${name}.`,\n \"\",\n \"Available providers:\",\n ...providers.map((provider) => ` ${provider.id}`),\n ].join(\"\\n\");\n}\n\nexport function providerChoices(providers: Provider[]): string {\n return `--provider <${providers.map((provider) => provider.id).join(\"|\")}>`;\n}\n\n/**\n * What `detectProviders` looks for: the declared markers, else the first env\n * key's declaration in `src/env.ts`. Empty for a provider with neither, which\n * can't be detected.\n */\nexport function providerMarkers(provider: Provider): ProviderMarker[] {\n if (provider.markers) return provider.markers;\n const first = provider.env?.[0];\n return first ? [{ env: first.key }] : [];\n}\n\n/**\n * The provider a generate call should produce, from `input.provider` or\n * `--provider` in argv.\n *\n * An unknown id is rejected with the list of known ones. With no provider at\n * all, a runtime call is rejected too: the CLI always supplies one, so this\n * is a caller bug. A preview call falls back to the first declared provider,\n * because the website loads patterns with argv only.\n *\n * A pattern with `inheritsProvider` takes the provider detected for that\n * capability instead; see `resolveInheritedProvider`.\n */\nexport function resolveProvider(\n pattern: ProviderPattern,\n options: Pick<Options, \"input\" | \"argv\" | \"env\" | \"providers\">,\n): Provider {\n const providers = pattern.providers ?? [];\n const name = capabilityName(pattern.slug);\n if (providers.length === 0) {\n throw new Error(`${pattern.slug} declares no providers.`);\n }\n\n const raw =\n typeof options.input.provider === \"string\"\n ? options.input.provider\n : providerFromArgv(options.argv);\n\n if (pattern.inheritsProvider) {\n return resolveInheritedProvider(\n pattern.inheritsProvider,\n name,\n providers,\n raw,\n options,\n );\n }\n\n if (raw === undefined || raw === \"\") {\n if (options.env === \"preview\") return providers[0];\n throw new InvalidArgumentError(\n `Choose a provider for ${name}: ${providerChoices(providers)}`,\n );\n }\n\n const provider = providers.find((candidate) => candidate.id === raw);\n if (!provider) {\n throw new InvalidArgumentError(\n unknownProviderMessage(name, raw, providers),\n );\n }\n return provider;\n}\n\n/**\n * A pattern built on another capability uses that capability's provider:\n * enable-ecommerce on a project with Shopify payments generates the Shopify\n * cart. A `--provider` that repeats the detected one is accepted; a different\n * one is an error, because switching means disabling the capability first.\n *\n * In preview nothing is detected, so it falls back like `resolveProvider`.\n */\nfunction resolveInheritedProvider(\n capability: string,\n name: string,\n providers: Provider[],\n raw: string | undefined,\n options: Pick<Options, \"env\" | \"providers\">,\n): Provider {\n const detectedId = options.providers?.[capability];\n\n if (detectedId === undefined) {\n if (options.env === \"preview\") {\n if (raw === undefined || raw === \"\") return providers[0];\n const provider = providers.find((candidate) => candidate.id === raw);\n if (provider) return provider;\n throw new InvalidArgumentError(\n unknownProviderMessage(name, raw, providers),\n );\n }\n throw new InvalidArgumentError(\n `${name} is built on ${capability}, and this project has none. ` +\n `Run \\`vela enable ${capability}\\` first.`,\n );\n }\n\n const detected = providers.find((candidate) => candidate.id === detectedId);\n if (!detected) {\n throw new InvalidArgumentError(\n `${name} does not support \"${detectedId}\" ${capability} yet. ` +\n `Supported: ${providers.map((provider) => provider.id).join(\", \")}.`,\n );\n }\n\n if (raw !== undefined && raw !== \"\" && raw !== detectedId) {\n throw new InvalidArgumentError(\n `This project uses ${detected.label} ${capability}, and ${name} follows it. ` +\n `Leave out --provider, or pass --provider ${detectedId}.`,\n );\n }\n\n return detected;\n}\n\n/**\n * The `.env` lines for a provider: `# heading`, then one `KEY=value` per\n * declared env var. `supplied` holds what the CLI collected; a blank value\n * falls back to the provider's default, else an empty assignment the\n * developer fills in later. Prompt placeholders are never written.\n */\nexport function providerEnvEdits(\n provider: Provider,\n heading: string,\n supplied: Record<string, string> = {},\n): EnvEdit[] {\n return [\n { type: \"comment\", key: heading },\n ...(provider.env ?? []).map((variable): EnvEdit => ({\n type: \"var\",\n key: variable.key,\n value: supplied[variable.key]?.trim() || variable.default || \"\",\n })),\n ];\n}\n\n/**\n * The `src/env.ts` declarations for a provider's env vars: optional, so an\n * empty `.env` still builds, and public only where the provider says so.\n */\nexport function providerEnvVars(provider: Provider): EnvVarSpec[] {\n return (provider.env ?? []).map((variable) => ({\n name: variable.key,\n ...(variable.public ? { public: true } : {}),\n description: variable.description ?? variable.label,\n }));\n}\n\n/** The string values of `input.providerEnv`, as the CLI collected them. */\nexport function suppliedProviderEnv(\n options: Pick<Options, \"input\">,\n): Record<string, string> {\n const raw = options.input.providerEnv;\n if (!raw || typeof raw !== \"object\") return {};\n const values: Record<string, string> = {};\n for (const [key, value] of Object.entries(raw)) {\n if (typeof value === \"string\") values[key] = value;\n }\n return values;\n}\n\n/**\n * Every app-relative path the providers create, sorted, for a disable pattern\n * that removes the files whichever provider was chosen. Works on a glob taken\n * from anywhere (`../../enable/<x>/providers/**`): only the part after\n * `providers/<id>/` (or `providers-<variant>/<id>/`) counts. `id` limits it to\n * one provider's files.\n */\nexport function allProviderPaths(\n providersRaw: Record<string, string>,\n id?: string,\n): string[] {\n const paths = new Set<string>();\n for (const key of Object.keys(providersRaw)) {\n const match = key.match(/\\/providers(?:-[^/]+)?\\/([^/]+)\\/(.+)$/);\n if (match && (id === undefined || match[1] === id)) paths.add(match[2]);\n }\n return [...paths].sort();\n}\n\n/**\n * The files under `providers/<id>/**` of a pattern, as creates. The glob map\n * is one `import.meta.glob(\"./providers/**\")` covering every provider. `root`\n * names a sibling tree for a variant of the provider's files, such as\n * `./providers-app-mode/`.\n */\nexport function providerCreates(\n providersRaw: Record<string, string>,\n id: string,\n root = \"./providers/\",\n): File[] {\n const files = filesUnderPrefix(providersRaw, `${root}${id}/`);\n return Object.values(files).sort((a, b) => a.path.localeCompare(b.path));\n}\n"],"mappings":";;;AASA,SAAgBE,EAAe,GAAsB;CACnD,OAAOC,EAAK,QAAQ,YAAY,EAAE;AACpC;AAGA,SAAgBC,EAAiB,GAAoC;CACnE,KAAK,IAAIC,IAAI,GAAGA,IAAIC,EAAK,QAAQ,KAAK;EACpC,IAAMC,IAAMD,EAAKD;EACjB,IAAIE,MAAQ,cAAc,OAAOD,EAAKD,IAAI;EAC1C,IAAIE,EAAI,WAAW,aAAa,GAAG,OAAOA,EAAI,MAAM,EAAoB;CAC1E;AAEF;AAEA,SAAgBC,EACd,GACA,GACA,GACQ;CACR,OAAO;EACL,qBAAqBC,EAAI,QAAQC,EAAK;EACtC;EACA;EACA,GAAGC,EAAU,KAAK,MAAa,KAAKC,EAAS,IAAI;CACnD,CAAC,CAAC,KAAK,IAAI;AACb;AAEA,SAAgBC,EAAgB,GAA+B;CAC7D,OAAO,eAAeF,EAAU,KAAK,MAAaC,EAAS,EAAE,CAAC,CAAC,KAAK,GAAG,EAAE;AAC3E;AAOA,SAAgBE,EAAgB,GAAsC;CACpE,IAAIF,EAAS,SAAS,OAAOA,EAAS;CACtC,IAAMG,IAAQH,EAAS,MAAM;CAC7B,OAAOG,IAAQ,CAAC,EAAE,KAAKA,EAAM,IAAI,CAAC,IAAI,CAAC;AACzC;AAcA,SAAgBC,EACd,GACA,GACU;CACV,IAAML,IAAYM,EAAQ,aAAa,CAAC,GAClCP,IAAOR,EAAee,EAAQ,IAAI;CACx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,GACA,IAAO,gBACC;CACR,IAAMC,IAAQtC,EAAiBkC,GAAc,GAAGK,IAAOH,EAAG,EAAE;CAC5D,OAAO,OAAO,OAAOE,CAAK,CAAC,CAAC,MAAM,GAAG,MAAME,EAAE,KAAK,cAAcC,EAAE,IAAI,CAAC;AACzE"}
1
+ {"version":3,"file":"providers-tjlFH5di.js","names":["InvalidArgumentError","filesUnderPrefix","capabilityName","slug","providerFromArgv","i","argv","arg","unknownProviderMessage","raw","name","providers","provider","providerChoices","providerMarkers","first","resolveProvider","pattern","options","resolveInheritedProvider","candidate","detectedId","capability","detected","providerEnvEdits","heading","variable","supplied","providerEnvVars","suppliedProviderEnv","values","key","value","allProviderPaths","paths","providersRaw","match","id","providerCreates","files","root","a","b"],"sources":["../../src/core/providers.ts"],"sourcesContent":["import type { EnvEdit } from \"../runtime/env\";\nimport type { EnvVarSpec } from \"../runtime/env-vars-file\";\nimport { InvalidArgumentError } from \"./errors\";\nimport type { File, Options, Pattern, Provider, ProviderMarker } from \"./types\";\nimport { filesUnderPrefix } from \"./util\";\n\ntype ProviderPattern = Pick<Pattern, \"slug\" | \"providers\" | \"inheritsProvider\">;\n\n/** `analytics` for `enable-analytics`: how the capability is named to users. */\nexport function capabilityName(slug: string): string {\n return slug.replace(/^enable-/, \"\");\n}\n\n/** `--provider <id>` or `--provider=<id>`, for callers that hand flags through in argv. */\nexport function providerFromArgv(argv: string[]): string | undefined {\n for (let i = 0; i < argv.length; i++) {\n const arg = argv[i];\n if (arg === \"--provider\") return argv[i + 1];\n if (arg.startsWith(\"--provider=\")) return arg.slice(\"--provider=\".length);\n }\n return undefined;\n}\n\nexport function unknownProviderMessage(\n name: string,\n raw: string,\n providers: Provider[],\n): string {\n return [\n `Unknown provider \"${raw}\" for ${name}.`,\n \"\",\n \"Available providers:\",\n ...providers.map((provider) => ` ${provider.id}`),\n ].join(\"\\n\");\n}\n\nexport function providerChoices(providers: Provider[]): string {\n return `--provider <${providers.map((provider) => provider.id).join(\"|\")}>`;\n}\n\n/**\n * What `detectProviders` looks for: the declared markers, else the first env\n * key's declaration in `src/env.ts`. Empty for a provider with neither, which\n * can't be detected.\n */\nexport function providerMarkers(provider: Provider): ProviderMarker[] {\n if (provider.markers) return provider.markers;\n const first = provider.env?.[0];\n return first ? [{ env: first.key }] : [];\n}\n\n/**\n * The provider a generate call should produce, from `input.provider` or\n * `--provider` in argv.\n *\n * An unknown id is rejected with the list of known ones. With no provider at\n * all, a runtime call is rejected too: the CLI always supplies one, so this\n * is a caller bug. A preview call falls back to the first declared provider,\n * because the website loads patterns with argv only.\n *\n * A pattern with `inheritsProvider` takes the provider detected for that\n * capability instead; see `resolveInheritedProvider`.\n */\nexport function resolveProvider(\n pattern: ProviderPattern,\n options: Pick<Options, \"input\" | \"argv\" | \"env\" | \"providers\">,\n): Provider {\n const providers = pattern.providers ?? [];\n const name = capabilityName(pattern.slug);\n if (providers.length === 0) {\n throw new Error(`${pattern.slug} declares no providers.`);\n }\n\n const raw =\n typeof options.input.provider === \"string\"\n ? options.input.provider\n : providerFromArgv(options.argv);\n\n if (pattern.inheritsProvider) {\n return resolveInheritedProvider(\n pattern.inheritsProvider,\n name,\n providers,\n raw,\n options,\n );\n }\n\n if (raw === undefined || raw === \"\") {\n if (options.env === \"preview\") return providers[0];\n throw new InvalidArgumentError(\n `Choose a provider for ${name}: ${providerChoices(providers)}`,\n );\n }\n\n const provider = providers.find((candidate) => candidate.id === raw);\n if (!provider) {\n throw new InvalidArgumentError(\n unknownProviderMessage(name, raw, providers),\n );\n }\n return provider;\n}\n\n/**\n * A pattern built on another capability uses that capability's provider:\n * enable-ecommerce on a project with Shopify payments generates the Shopify\n * cart. A `--provider` that repeats the detected one is accepted; a different\n * one is an error, because switching means disabling the capability first.\n *\n * In preview nothing is detected, so it falls back like `resolveProvider`.\n */\nfunction resolveInheritedProvider(\n capability: string,\n name: string,\n providers: Provider[],\n raw: string | undefined,\n options: Pick<Options, \"env\" | \"providers\">,\n): Provider {\n const detectedId = options.providers?.[capability];\n\n if (detectedId === undefined) {\n if (options.env === \"preview\") {\n if (raw === undefined || raw === \"\") return providers[0];\n const provider = providers.find((candidate) => candidate.id === raw);\n if (provider) return provider;\n throw new InvalidArgumentError(\n unknownProviderMessage(name, raw, providers),\n );\n }\n throw new InvalidArgumentError(\n `${name} is built on ${capability}, and this project has none. ` +\n `Run \\`vela enable ${capability}\\` first.`,\n );\n }\n\n const detected = providers.find((candidate) => candidate.id === detectedId);\n if (!detected) {\n throw new InvalidArgumentError(\n `${name} does not support \"${detectedId}\" ${capability} yet. ` +\n `Supported: ${providers.map((provider) => provider.id).join(\", \")}.`,\n );\n }\n\n if (raw !== undefined && raw !== \"\" && raw !== detectedId) {\n throw new InvalidArgumentError(\n `This project uses ${detected.label} ${capability}, and ${name} follows it. ` +\n `Leave out --provider, or pass --provider ${detectedId}.`,\n );\n }\n\n return detected;\n}\n\n/**\n * The `.env` lines for a provider: `# heading`, then one `KEY=value` per\n * declared env var. `supplied` holds what the CLI collected; a blank value\n * falls back to the provider's default, else an empty assignment the\n * developer fills in later. Prompt placeholders are never written.\n */\nexport function providerEnvEdits(\n provider: Provider,\n heading: string,\n supplied: Record<string, string> = {},\n): EnvEdit[] {\n return [\n { type: \"comment\", key: heading },\n ...(provider.env ?? []).map((variable): EnvEdit => ({\n type: \"var\",\n key: variable.key,\n value: supplied[variable.key]?.trim() || variable.default || \"\",\n })),\n ];\n}\n\n/**\n * The `src/env.ts` declarations for a provider's env vars: optional, so an\n * empty `.env` still builds, and public only where the provider says so.\n */\nexport function providerEnvVars(provider: Provider): EnvVarSpec[] {\n return (provider.env ?? []).map((variable) => ({\n name: variable.key,\n ...(variable.public ? { public: true } : {}),\n description: variable.description ?? variable.label,\n }));\n}\n\n/** The string values of `input.providerEnv`, as the CLI collected them. */\nexport function suppliedProviderEnv(\n options: Pick<Options, \"input\">,\n): Record<string, string> {\n const raw = options.input.providerEnv;\n if (!raw || typeof raw !== \"object\") return {};\n const values: Record<string, string> = {};\n for (const [key, value] of Object.entries(raw)) {\n if (typeof value === \"string\") values[key] = value;\n }\n return values;\n}\n\n/**\n * Every app-relative path the providers create, sorted, for a disable pattern\n * that removes the files whichever provider was chosen. Works on a glob taken\n * from anywhere (`../../enable/<x>/providers/**`): only the part after\n * `providers/<id>/` (or `providers-<variant>/<id>/`) counts. `id` limits it to\n * one provider's files.\n */\nexport function allProviderPaths(\n providersRaw: Record<string, string>,\n id?: string,\n): string[] {\n const paths = new Set<string>();\n for (const key of Object.keys(providersRaw)) {\n const match = key.match(/\\/providers(?:-[^/]+)?\\/([^/]+)\\/(.+)$/);\n if (match && (id === undefined || match[1] === id)) paths.add(match[2]);\n }\n return [...paths].sort();\n}\n\n/**\n * The files under `providers/<id>/**` of a pattern, as creates. The glob map\n * is one `import.meta.glob(\"./providers/**\")` covering every provider. `root`\n * names a sibling tree for a variant of the provider's files, such as\n * `./providers-app-mode/`.\n */\nexport function providerCreates(\n providersRaw: Record<string, string>,\n id: string,\n root = \"./providers/\",\n): File[] {\n const files = filesUnderPrefix(providersRaw, `${root}${id}/`);\n return Object.values(files).sort((a, b) => a.path.localeCompare(b.path));\n}\n"],"mappings":";;;AASA,SAAgBE,EAAe,GAAsB;CACnD,OAAOC,EAAK,QAAQ,YAAY,EAAE;AACpC;AAGA,SAAgBC,EAAiB,GAAoC;CACnE,KAAK,IAAIC,IAAI,GAAGA,IAAIC,EAAK,QAAQ,KAAK;EACpC,IAAMC,IAAMD,EAAKD;EACjB,IAAIE,MAAQ,cAAc,OAAOD,EAAKD,IAAI;EAC1C,IAAIE,EAAI,WAAW,aAAa,GAAG,OAAOA,EAAI,MAAM,EAAoB;CAC1E;AAEF;AAEA,SAAgBC,EACd,GACA,GACA,GACQ;CACR,OAAO;EACL,qBAAqBC,EAAI,QAAQC,EAAK;EACtC;EACA;EACA,GAAGC,EAAU,KAAK,MAAa,KAAKC,EAAS,IAAI;CACnD,CAAC,CAAC,KAAK,IAAI;AACb;AAEA,SAAgBC,EAAgB,GAA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OuB,KAAU,aAAU,EAAOD,KAAOC;CAE/C,OAAOF;AACT;AASA,SAAgBG,EACd,GACA,GACU;CACV,IAAMC,oBAAQ,IAAI,IAAY;CAC9B,KAAK,IAAMH,KAAO,OAAO,KAAKI,CAAY,GAAG;EAC3C,IAAMC,IAAQL,EAAI,MAAM,wCAAwC;EAChE,AAAIK,MAAUC,MAAO,KAAA,KAAaD,EAAM,OAAOC,MAAKH,EAAM,IAAIE,EAAM,EAAE;CACxE;CACA,OAAO,CAAC,GAAGF,CAAK,CAAC,CAAC,KAAK;AACzB;AAQA,SAAgBI,EACd,GACA,GACA,IAAO,gBACC;CACR,IAAMC,IAAQtC,EAAiBkC,GAAc,GAAGK,IAAOH,EAAG,EAAE;CAC5D,OAAO,OAAO,OAAOE,CAAK,CAAC,CAAC,MAAM,GAAG,MAAME,EAAE,KAAK,cAAcC,EAAE,IAAI,CAAC;AACzE"}
@@ -1,4 +1,4 @@
1
- //#region \0rolldown/runtime.js
1
+ // \0rolldown/runtime.js
2
2
  var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescriptor, r = Object.getOwnPropertyNames, i = Object.getPrototypeOf, a = Object.prototype.hasOwnProperty, o = (e, t) => () => (t || (e((t = { exports: {} }).exports, t, t.exports), e = null), t.exports), s = (e, n) => {
3
3
  let r = {};
4
4
  for (var i in e) t(r, i, {
@@ -19,5 +19,4 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
19
19
  if (typeof require < "u") return require.apply(this, arguments);
20
20
  throw Error("Calling `require` for \"" + e + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
21
21
  });
22
- //#endregion
23
22
  export { l as i, s as n, u as r, o as t };
@@ -1,14 +1,14 @@
1
- import { r as e } from "./lib-specifier-Cngo1zF_.js";
2
- import { t } from "./dedent-Gq6Krl4n.js";
3
- import { t as n } from "./taggedTemplateLiteral-KSUnuvOk.js";
4
- import { _ as r, a as i, d as a, g as o, i as s, n as c, o as l, p as u, r as d, u as f } from "./ts-morph-helpers-CHI9wAil.js";
5
- import { t as p } from "./svelte-file-Dv5-bl79.js";
6
- import { n as m, t as h } from "./compose-handle-BBlamPfx.js";
7
- import { a as g, c as _, i as v, l as y, r as b, s as x } from "./load-function-Dmkhg1pQ.js";
1
+ import { r as e } from "./lib-specifier-C3M0WTev.js";
2
+ import { t } from "./dedent-CCUOcPFW.js";
3
+ import { t as n } from "./taggedTemplateLiteral-CLenToGE.js";
4
+ import { _ as r, a as i, d as a, g as o, i as s, n as c, o as l, p as u, r as d, u as f } from "./ts-morph-helpers-B4KZXP44.js";
5
+ import { t as p } from "./svelte-file-DfplF3BU.js";
6
+ import { n as m, t as h } from "./compose-handle-Da7m6lV_.js";
7
+ import { a as g, c as _, i as v, l as y, r as b, s as x } from "./load-function-BFvIVsh7.js";
8
8
  import S from "node:fs";
9
9
  import C from "node:path";
10
10
  import { Node as w, Project as T, QuoteKind as E } from "ts-morph";
11
- //#region src/patterns/enable/payments/modifies/hooks.server.ts
11
+ // src/patterns/enable/payments/modifies/hooks.server.ts
12
12
  var D = "handleCurrency", O = "#lib/currency.server.js", k = t`
13
13
  Compose the currency handle into your exported handle:
14
14
 
@@ -74,8 +74,7 @@ function N(t) {
74
74
  changed: i !== n
75
75
  };
76
76
  }
77
- //#endregion
78
- //#region src/patterns/enable/payments/modifies/layout.server.ts
77
+ // src/patterns/enable/payments/modifies/layout.server.ts
79
78
  var P = "#lib/currency.server.js", F = ["currency", "rates"], I = t`
80
79
  Return the visitor's currency and the day's rates from the root +layout.server.ts load:
81
80
 
@@ -164,8 +163,7 @@ function R(t) {
164
163
  changed: f !== n
165
164
  };
166
165
  }
167
- //#endregion
168
- //#region src/patterns/enable/payments/modifies/layout.svelte.ts
166
+ // src/patterns/enable/payments/modifies/layout.svelte.ts
169
167
  var z, B = "currency.hydrate(data.currency, data.rates);", V = t(z ||= n(["\n Start the currency store from the layout's data in src/routes/+layout.svelte:\n\n <script lang=\"ts\">\n import { currency } from '#lib/currency.svelte.js';\n\n let { data, children } = $props();\n currency.hydrate(data.currency, data.rates);\n <\/script>\n"]));
170
168
  function H(e) {
171
169
  if (!S.existsSync(e)) return {
@@ -211,8 +209,7 @@ function U(t) {
211
209
  changed: n.hasChanged()
212
210
  };
213
211
  }
214
- //#endregion
215
- //#region src/patterns/enable/payments/modifies/root-layout.svelte.ts
212
+ // src/patterns/enable/payments/modifies/root-layout.svelte.ts
216
213
  function W(e) {
217
214
  return `<Navbar.Item>\n${e}\t<CurrencySelect />\n${e}</Navbar.Item>\n${e}`;
218
215
  }
@@ -296,7 +293,6 @@ function X(t) {
296
293
  changed: a !== n
297
294
  };
298
295
  }
299
- //#endregion
300
296
  export { L as a, N as c, U as i, X as n, R as o, H as r, M as s, Y as t };
301
297
 
302
- //# sourceMappingURL=root-layout.svelte-CUVbnlX-.js.map
298
+ //# sourceMappingURL=root-layout.svelte-DE0c_y-T.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"root-layout.svelte-CUVbnlX-.js","names":["MODULE","FAILURE_HINT","FAILURE_HINT","FAILURE_HINT","libModule","_taggedTemplateLiteral","withInMemoryScript","ensurePropsBinding","removeNamedImportIfUnused","removeUnusedBindingElement","ensureNamedImport","ensureBlankLineAfterImports","formatLikeSource","removePropsBindingIfUnused","ensureImports","removeImportByModuleSpecifier","SvelteFile","removeHandle","addHandle","hasProperty","newProject","findLoadFunction","returnedObject","findFinalReturn","inspectEventParameter","fs","path","HANDLE","MODULE$1","FAILURE_HINT$3","HOOKS_SERVER_SNIPPET","project","Project","QuoteKind","modifyHooksServerCurrency","hooksServerPath","original","sourceFile","updated","unmodifyHooksServerCurrency","MODULE","PROPERTIES","FAILURE_HINT$2","modifyLayoutServerCurrency","layoutServerPath","fn","body","Node","event","returned","object","locals","texts","unmodifyLayoutServerCurrency","name","_templateObject","STATEMENT","FAILURE_HINT$1","dedent","modifyLayoutSvelteCurrency","layoutPath","file","out","source","sf","props","statement","unmodifyLayoutSvelteCurrency","markup","snippet","indent","SNIPPET","IMPORT","FAILURE_HINT","NOT_FOUND_HINT","modifyRootLayoutCurrencySelect","language","item","unmodifyRootLayoutCurrencySelect"],"sources":["../../src/patterns/enable/payments/modifies/hooks.server.ts","../../src/patterns/enable/payments/modifies/layout.server.ts","../../src/patterns/enable/payments/modifies/layout.svelte.ts","../../src/patterns/enable/payments/modifies/root-layout.svelte.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport dedent from \"dedent\";\nimport { Project, QuoteKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { addHandle, removeHandle } from \"../../../../runtime/compose-handle\";\nimport { libModule } from \"../../../../runtime/lib-specifier\";\nimport {\n ensureBlankLineAfterImports,\n ensureNamedImport,\n formatLikeSource,\n removeNamedImportIfUnused,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nconst HANDLE = \"handleCurrency\";\nconst MODULE = \"#lib/currency.server.js\";\n\nconst FAILURE_HINT = dedent`\n Compose the currency handle into your exported handle:\n\n import { sequence } from '@sveltejs/kit/hooks';\n import { handleCurrency } from '#lib/currency.server.js';\n\n export const handle = sequence(handleCurrency, /* your existing handle */);\n`;\n\nconst HOOKS_SERVER_SNIPPET = dedent`\n import { handleCurrency } from '#lib/currency.server.js';\n\n export const handle = handleCurrency;\n`;\n\nfunction project(): Project {\n return new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n}\n\n/**\n * `handleCurrency` joins the server handle chain so every request knows the\n * currency its visitor reads prices in. Creates `hooks.server.ts` when the\n * project has none.\n */\nexport function modifyHooksServerCurrency(\n hooksServerPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n // SvelteKit loads the first `hooks.server.*` it finds, and `.js` sorts\n // first, so a new `.ts` beside it would never run.\n if (fs.existsSync(hooksServerPath.replace(/\\.ts$/, \".js\"))) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n fs.mkdirSync(path.dirname(hooksServerPath), { recursive: true });\n fs.writeFileSync(hooksServerPath, HOOKS_SERVER_SNIPPET + \"\\n\");\n return { status: \"success\", changed: true };\n }\n\n const original = fs.readFileSync(hooksServerPath, \"utf8\");\n if (original.includes(HANDLE)) return { status: \"success\", changed: false };\n\n const sourceFile = project().addSourceFileAtPath(hooksServerPath);\n // Composed first: an unsupported handle leaves the file untouched.\n const composed = addHandle(sourceFile, { expression: HANDLE });\n if (composed.status === \"unsupported\") {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n ensureNamedImport(sourceFile, MODULE, HANDLE);\n formatLikeSource(sourceFile);\n const updated = sourceFile.getFullText();\n fs.writeFileSync(hooksServerPath, updated, \"utf8\");\n return { status: \"success\", changed: updated !== original };\n}\n\n/** Take `handleCurrency` back out of the chain, and its import with it. */\nexport function unmodifyHooksServerCurrency(\n hooksServerPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n return { status: \"success\", changed: false };\n }\n const original = fs.readFileSync(hooksServerPath, \"utf8\");\n if (!original.includes(HANDLE)) return { status: \"success\", changed: false };\n\n const sourceFile = project().addSourceFileAtPath(hooksServerPath);\n const removed = removeHandle(sourceFile, HANDLE);\n if (removed.status === \"unsupported\") {\n return {\n status: \"failed\",\n message: `Remove ${HANDLE} from the handle chain in src/hooks.server.ts and its import from '${MODULE}'.`,\n };\n }\n removeNamedImportIfUnused(\n sourceFile,\n libModule(\"currency.server.js\"),\n HANDLE,\n );\n ensureBlankLineAfterImports(sourceFile);\n formatLikeSource(sourceFile);\n const updated = sourceFile.getFullText();\n fs.writeFileSync(hooksServerPath, updated, \"utf8\");\n return { status: \"success\", changed: updated !== original };\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 hasProperty,\n inspectEventParameter,\n newProject,\n returnedObject,\n} from \"../../../../runtime/load-function\";\nimport { libModule } from \"../../../../runtime/lib-specifier\";\nimport {\n ensureBlankLineAfterImports,\n ensureNamedImport,\n formatLikeSource,\n removeNamedImportIfUnused,\n removeUnusedBindingElement,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nconst MODULE = \"#lib/currency.server.js\";\nconst PROPERTIES = [\"currency\", \"rates\"] as const;\n\nconst FAILURE_HINT = dedent`\n Return the visitor's currency and the day's rates from the root +layout.server.ts load:\n\n import { displayRates } from '#lib/currency.server.js';\n\n export const load = async ({ locals }) => {\n \treturn {\n \t\tcurrency: locals.currency,\n \t\trates: await displayRates(locals.currency)\n \t};\n };\n\n The load has to be async with a single, final return of an object literal.\n`;\n\n/**\n * The root `+layout.server.ts` returns `currency` (what `handleCurrency`\n * resolved) and `rates` (the day's, when it isn't the business's own), so the\n * root layout can start the store before anything renders.\n *\n * A load that isn't async, has no final object-literal return, or receives\n * its event in a way the helpers can't extend is reported as `failed` with\n * the snippet to paste, and the file is left exactly as it was.\n */\nexport function modifyLayoutServerCurrency(\n layoutServerPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(layoutServerPath)) {\n return { status: \"not-found\", message: FAILURE_HINT };\n }\n const original = fs.readFileSync(layoutServerPath, \"utf8\");\n if (original.includes(\"displayRates(\")) {\n return { status: \"success\", changed: false };\n }\n\n const sourceFile = newProject().addSourceFileAtPath(layoutServerPath);\n const fn = findLoadFunction(sourceFile);\n if (!fn) return { status: \"failed\", message: FAILURE_HINT };\n const body = fn.getBody();\n if (!body || !Node.isBlock(body) || !fn.isAsync()) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n const event = inspectEventParameter(fn);\n if (event.kind === \"unsupported\") {\n return { status: \"failed\", message: FAILURE_HINT };\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 // Where `locals` comes from: the destructured parameter, the event's\n // property, or a parameter added for it.\n let locals = \"locals\";\n if (event.kind === \"identifier\") {\n locals = `${event.name}.locals`;\n } else if (event.kind === \"binding\") {\n const names = event.pattern.getElements().map((e) => e.getName());\n if (!names.includes(\"locals\")) {\n const texts = event.pattern.getElements().map((e) => e.getText());\n event.pattern.replaceWithText(`{ ${[...texts, \"locals\"].join(\", \")} }`);\n }\n } else {\n fn.addParameter({ name: \"{ locals }\" });\n }\n\n // After any spread, so nothing in it can shadow these.\n if (!hasProperty(object, \"currency\")) {\n object.addPropertyAssignment({\n name: \"currency\",\n initializer: `${locals}.currency`,\n });\n }\n if (!hasProperty(object, \"rates\")) {\n object.addPropertyAssignment({\n name: \"rates\",\n initializer: `await displayRates(${locals}.currency)`,\n });\n }\n ensureNamedImport(sourceFile, MODULE, \"displayRates\");\n formatLikeSource(sourceFile);\n const updated = sourceFile.getFullText();\n fs.writeFileSync(layoutServerPath, updated, \"utf8\");\n return { status: \"success\", changed: updated !== original };\n}\n\n/** Take `currency` and `rates` back out of the root layout's data. */\nexport function unmodifyLayoutServerCurrency(\n layoutServerPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(layoutServerPath)) {\n return { status: \"success\", changed: false };\n }\n const original = fs.readFileSync(layoutServerPath, \"utf8\");\n if (!original.includes(\"displayRates(\")) {\n return { status: \"success\", changed: false };\n }\n\n const sourceFile = newProject().addSourceFileAtPath(layoutServerPath);\n const fn = findLoadFunction(sourceFile);\n const body = fn?.getBody();\n const returned =\n fn && body && Node.isBlock(body) ? findFinalReturn(fn, body) : null;\n const object = returned && returnedObject(returned);\n if (!object) {\n return {\n status: \"failed\",\n message: `Remove currency and rates from the root +layout.server.ts load and the import from '${MODULE}'.`,\n };\n }\n for (const name of PROPERTIES) {\n object.getProperty(name)?.remove();\n }\n removeNamedImportIfUnused(\n sourceFile,\n libModule(\"currency.server.js\"),\n \"displayRates\",\n );\n removeUnusedBindingElement(sourceFile, \"locals\");\n ensureBlankLineAfterImports(sourceFile);\n formatLikeSource(sourceFile);\n const updated = sourceFile.getFullText();\n fs.writeFileSync(layoutServerPath, updated, \"utf8\");\n return { status: \"success\", changed: updated !== original };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport { libModule } from \"../../../../runtime/lib-specifier\";\nimport {\n ensureBlankLineAfterImports,\n ensureImports,\n ensurePropsBinding,\n removeImportByModuleSpecifier,\n removePropsBindingIfUnused,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nconst STATEMENT = \"currency.hydrate(data.currency, data.rates);\";\n\nconst FAILURE_HINT = dedent`\n Start the currency store from the layout's data in src/routes/+layout.svelte:\n\n <script lang=\"ts\">\n \timport { currency } from '#lib/currency.svelte.js';\n\n \tlet { data, children } = $props();\n \tcurrency.hydrate(data.currency, data.rates);\n </script>\n`;\n\n/**\n * The root `+layout.svelte` hands the store what the server resolved, before\n * any child renders: the first render already shows the visitor's currency,\n * on the server and in the browser alike.\n */\nexport function modifyLayoutSvelteCurrency(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"not-found\", message: FAILURE_HINT };\n }\n const file = SvelteFile.fromPath(layoutPath);\n if (file.toString().includes(\"currency.hydrate(\")) {\n return { status: \"success\", changed: false };\n }\n if (!file.getScript()) return { status: \"failed\", message: FAILURE_HINT };\n\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n ensureImports(sf, [\n {\n namedImports: [\"currency\"],\n moduleSpecifier: \"#lib/currency.svelte.js\",\n },\n ]);\n ensurePropsBinding(sf, \"data\");\n // Right after the props, which it reads.\n const props = sf\n .getVariableStatements()\n .find((statement) => statement.getText().includes(\"$props()\"));\n if (props) {\n sf.insertStatements(props.getChildIndex() + 1, STATEMENT);\n } else {\n sf.addStatements(STATEMENT);\n }\n });\n return out;\n });\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n\n/** Take the hydration back out, and the import and `data` prop if nothing else reads them. */\nexport function unmodifyLayoutSvelteCurrency(\n layoutPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"success\", changed: false };\n }\n const original = fs.readFileSync(layoutPath, \"utf8\");\n if (!original.includes(\"currency.hydrate(\")) {\n return { status: \"success\", changed: false };\n }\n const file = SvelteFile.fromPath(layoutPath);\n const markup = file.toString().replace(/<script[\\s\\S]*?<\\/script>/g, \"\");\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n for (const statement of sf.getStatements()) {\n if (statement.getText().includes(\"currency.hydrate(\"))\n statement.remove();\n }\n removeImportByModuleSpecifier(sf, libModule(\"currency.svelte.js\"));\n removePropsBindingIfUnused(sf, \"data\", markup);\n ensureBlankLineAfterImports(sf);\n });\n return out;\n });\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport { libModule } from \"../../../../runtime/lib-specifier\";\nimport {\n ensureBlankLineAfterImports,\n ensureImports,\n removeImportByModuleSpecifier,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\n\n/** The item, indented like the list it joins; `indent` is the list's closing tag's. */\nfunction snippet(indent: string): string {\n return `<Navbar.Item>\\n${indent}\\t<CurrencySelect />\\n${indent}</Navbar.Item>\\n${indent}`;\n}\n\nconst SNIPPET = snippet(\"\\t\\t\\t\");\n\nconst IMPORT = dedent`\n import CurrencySelect from '#lib/components/currency-select.svelte';\n`;\n\nconst FAILURE_HINT = [\n \"Add the currency select inside your <Navbar.List> in the root layout.\",\n \"\",\n \"Import to add to the <script> tag:\",\n \"\",\n IMPORT,\n \"\",\n \"Markup to add at the end of <Navbar.List>, after the language select if there is one:\",\n SNIPPET,\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create a root layout that includes a currency select inside <Navbar.List>.\",\n \"\",\n \"Import for the <script> tag:\",\n \"\",\n IMPORT,\n \"\",\n \"Markup at the end of <Navbar.List>:\",\n SNIPPET,\n].join(\"\\n\");\n\n/**\n * The currency select goes in the navbar beside the language select, when\n * there is one, else as the last item. It renders nothing until the business\n * offers a second currency, so the layout gains it with payments.\n */\nexport function modifyRootLayoutCurrencySelect(\n layoutPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n const file = SvelteFile.fromPath(layoutPath);\n if (file.hasElement(\"CurrencySelect\")) {\n return { status: \"success\", changed: false };\n }\n if (!file.hasElement(\"Navbar.List\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n const language = file.findElementContaining(\"Navbar.Item\", \"LanguageSelect\");\n if (language) {\n // On the line after the language select's item; the helper indents it.\n file.insertAfterElement(\n language,\n \"<Navbar.Item>\\n\\t<CurrencySelect />\\n</Navbar.Item>\",\n );\n } else {\n // The closing tag's own indentation already precedes the insertion point,\n // so the item starts one level in and hands that indentation back.\n const indent =\n /^([ \\t]*)<\\/Navbar\\.List>/m.exec(file.toString())?.[1] ?? \"\\t\\t\";\n const item = `\\t<Navbar.Item>\\n${indent}\\t\\t<CurrencySelect />\\n${indent}\\t</Navbar.Item>\\n${indent}`;\n if (!file.insertBeforeClosingTag(\"Navbar.List\", item))\n return { status: \"failed\", message: FAILURE_HINT };\n }\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n ensureImports(sf, [\n {\n defaultImport: \"CurrencySelect\",\n moduleSpecifier: \"#lib/components/currency-select.svelte\",\n },\n ]);\n });\n return out;\n });\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n\n/** Take the currency select (and the nav item around it) back out. */\nexport function unmodifyRootLayoutCurrencySelect(\n layoutPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"success\", changed: false };\n }\n const original = fs.readFileSync(layoutPath, \"utf8\");\n if (!original.includes(\"CurrencySelect\")) {\n return { status: \"success\", changed: false };\n }\n const file = SvelteFile.fromPath(layoutPath);\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n removeImportByModuleSpecifier(\n sf,\n libModule(\"components/currency-select.svelte\"),\n );\n ensureBlankLineAfterImports(sf);\n });\n return out;\n });\n let updated = file.toString();\n updated = updated.replace(\n /[ \\t]*<Navbar\\.Item>\\s*<CurrencySelect\\s*\\/>\\s*<\\/Navbar\\.Item>[ \\t]*\\r?\\n?/g,\n \"\",\n );\n updated = updated.replace(/[ \\t]*<CurrencySelect\\s*\\/>[ \\t]*\\r?\\n?/g, \"\");\n fs.writeFileSync(layoutPath, updated, \"utf8\");\n return { status: \"success\", changed: updated !== original };\n}\n"],"mappings":";;;;;;;;;;;AAcA,IAAM2B,IAAS,kBACT3B,IAAS,2BAETC,IAAe,CAAM;;;;;;;GASrB6B,IAAuB,CAAM;;;;;AAMnC,SAASC,IAAmB;CAC1B,OAAO,IAAIC,EAAQ;EACjB,iBAAiB,EAAE,SAAS,GAAK;EACjC,sBAAsB,EAAE,WAAWC,EAAU,OAAO;CACtD,CAAC;AACH;AAOA,SAAgBC,EACd,GACe;CACf,IAAI,CAACT,EAAG,WAAWU,CAAe,GAQhC,OALIV,EAAG,WAAWU,EAAgB,QAAQ,SAAS,KAAK,CAAC,IAChD;EAAE,QAAQ;EAAU,SAASlC;CAAa,KAEnDwB,EAAG,UAAUC,EAAK,QAAQS,CAAe,GAAG,EAAE,WAAW,GAAK,CAAC,GAC/DV,EAAG,cAAcU,GAAiBL,IAAuB,IAAI,GACtD;EAAE,QAAQ;EAAW,SAAS;CAAK;CAG5C,IAAMM,IAAWX,EAAG,aAAaU,GAAiB,MAAM;CACxD,IAAIC,EAAS,SAAST,CAAM,GAAG,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAE1E,IAAMU,IAAaN,EAAQ,CAAC,CAAC,oBAAoBI,CAAe;CAGh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,OAAO;GAAE,QAAQ;GAAU,SAASJ;EAAa;CACrD;CAaA,OAZAZ,EAAK,cAAc,MAAW;EAC5B,IAAM,EAAE,QAAQC,MAAQxD,EAAmByD,IAAS,MAAO;GACzD,EAAcC,GAAI,CAChB;IACE,eAAe;IACf,iBAAiB;GACnB,CACF,CAAC;EACH,CAAC;EACD,OAAOF;CACT,CAAC,GACDD,EAAK,QAAQD,CAAU,GAChB;EAAE,QAAQ;EAAW,SAASC,EAAK,WAAW;CAAE;AACzD;AAGA,SAAgBiB,EACd,GACe;CACf,IAAI,CAACrD,EAAG,WAAWmC,CAAU,GAC3B,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAE7C,IAAMxB,IAAWX,EAAG,aAAamC,GAAY,MAAM;CACnD,IAAI,CAACxB,EAAS,SAAS,gBAAgB,GACrC,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAE7C,IAAMyB,IAAO7C,EAAW,SAAS4C,CAAU;CAC3C,EAAK,cAAc,MAAW;EAC5B,IAAM,EAAE,QAAQE,MAAQxD,EAAmByD,IAAS,MAAO;GAKzD,AAJAhD,EACEiD,GACA5D,EAAU,mCAAmC,CAC/C,GACAO,EAA4BqD,CAAE;EAChC,CAAC;EACD,OAAOF;CACT,CAAC;CACD,IAAIxB,IAAUuB,EAAK,SAAS;CAO5B,OANA,IAAUvB,EAAQ,QAChB,gFACA,EACF,GACA,IAAUA,EAAQ,QAAQ,4CAA4C,EAAE,GACxEb,EAAG,cAAcmC,GAAYtB,GAAS,MAAM,GACrC;EAAE,QAAQ;EAAW,SAASA,MAAYF;CAAS;AAC5D"}
1
+ {"version":3,"file":"root-layout.svelte-DE0c_y-T.js","names":["MODULE","FAILURE_HINT","FAILURE_HINT","FAILURE_HINT","libModule","_taggedTemplateLiteral","withInMemoryScript","ensurePropsBinding","removeNamedImportIfUnused","removeUnusedBindingElement","ensureNamedImport","ensureBlankLineAfterImports","formatLikeSource","removePropsBindingIfUnused","ensureImports","removeImportByModuleSpecifier","SvelteFile","removeHandle","addHandle","hasProperty","newProject","findLoadFunction","returnedObject","findFinalReturn","inspectEventParameter","fs","path","HANDLE","MODULE$1","FAILURE_HINT$3","HOOKS_SERVER_SNIPPET","project","Project","QuoteKind","modifyHooksServerCurrency","hooksServerPath","original","sourceFile","updated","unmodifyHooksServerCurrency","MODULE","PROPERTIES","FAILURE_HINT$2","modifyLayoutServerCurrency","layoutServerPath","fn","body","Node","event","returned","object","locals","texts","unmodifyLayoutServerCurrency","name","_templateObject","STATEMENT","FAILURE_HINT$1","dedent","modifyLayoutSvelteCurrency","layoutPath","file","out","source","sf","props","statement","unmodifyLayoutSvelteCurrency","markup","snippet","indent","SNIPPET","IMPORT","FAILURE_HINT","NOT_FOUND_HINT","modifyRootLayoutCurrencySelect","language","item","unmodifyRootLayoutCurrencySelect"],"sources":["../../src/patterns/enable/payments/modifies/hooks.server.ts","../../src/patterns/enable/payments/modifies/layout.server.ts","../../src/patterns/enable/payments/modifies/layout.svelte.ts","../../src/patterns/enable/payments/modifies/root-layout.svelte.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport dedent from \"dedent\";\nimport { Project, QuoteKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { addHandle, removeHandle } from \"../../../../runtime/compose-handle\";\nimport { libModule } from \"../../../../runtime/lib-specifier\";\nimport {\n ensureBlankLineAfterImports,\n ensureNamedImport,\n formatLikeSource,\n removeNamedImportIfUnused,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nconst HANDLE = \"handleCurrency\";\nconst MODULE = \"#lib/currency.server.js\";\n\nconst FAILURE_HINT = dedent`\n Compose the currency handle into your exported handle:\n\n import { sequence } from '@sveltejs/kit/hooks';\n import { handleCurrency } from '#lib/currency.server.js';\n\n export const handle = sequence(handleCurrency, /* your existing handle */);\n`;\n\nconst HOOKS_SERVER_SNIPPET = dedent`\n import { handleCurrency } from '#lib/currency.server.js';\n\n export const handle = handleCurrency;\n`;\n\nfunction project(): Project {\n return new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n}\n\n/**\n * `handleCurrency` joins the server handle chain so every request knows the\n * currency its visitor reads prices in. Creates `hooks.server.ts` when the\n * project has none.\n */\nexport function modifyHooksServerCurrency(\n hooksServerPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n // SvelteKit loads the first `hooks.server.*` it finds, and `.js` sorts\n // first, so a new `.ts` beside it would never run.\n if (fs.existsSync(hooksServerPath.replace(/\\.ts$/, \".js\"))) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n fs.mkdirSync(path.dirname(hooksServerPath), { recursive: true });\n fs.writeFileSync(hooksServerPath, HOOKS_SERVER_SNIPPET + \"\\n\");\n return { status: \"success\", changed: true };\n }\n\n const original = fs.readFileSync(hooksServerPath, \"utf8\");\n if (original.includes(HANDLE)) return { status: \"success\", changed: false };\n\n const sourceFile = project().addSourceFileAtPath(hooksServerPath);\n // Composed first: an unsupported handle leaves the file untouched.\n const composed = addHandle(sourceFile, { expression: HANDLE });\n if (composed.status === \"unsupported\") {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n ensureNamedImport(sourceFile, MODULE, HANDLE);\n formatLikeSource(sourceFile);\n const updated = sourceFile.getFullText();\n fs.writeFileSync(hooksServerPath, updated, \"utf8\");\n return { status: \"success\", changed: updated !== original };\n}\n\n/** Take `handleCurrency` back out of the chain, and its import with it. */\nexport function unmodifyHooksServerCurrency(\n hooksServerPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n return { status: \"success\", changed: false };\n }\n const original = fs.readFileSync(hooksServerPath, \"utf8\");\n if (!original.includes(HANDLE)) return { status: \"success\", changed: false };\n\n const sourceFile = project().addSourceFileAtPath(hooksServerPath);\n const removed = removeHandle(sourceFile, HANDLE);\n if (removed.status === \"unsupported\") {\n return {\n status: \"failed\",\n message: `Remove ${HANDLE} from the handle chain in src/hooks.server.ts and its import from '${MODULE}'.`,\n };\n }\n removeNamedImportIfUnused(\n sourceFile,\n libModule(\"currency.server.js\"),\n HANDLE,\n );\n ensureBlankLineAfterImports(sourceFile);\n formatLikeSource(sourceFile);\n const updated = sourceFile.getFullText();\n fs.writeFileSync(hooksServerPath, updated, \"utf8\");\n return { status: \"success\", changed: updated !== original };\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 hasProperty,\n inspectEventParameter,\n newProject,\n returnedObject,\n} from \"../../../../runtime/load-function\";\nimport { libModule } from \"../../../../runtime/lib-specifier\";\nimport {\n ensureBlankLineAfterImports,\n ensureNamedImport,\n formatLikeSource,\n removeNamedImportIfUnused,\n removeUnusedBindingElement,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nconst MODULE = \"#lib/currency.server.js\";\nconst PROPERTIES = [\"currency\", \"rates\"] as const;\n\nconst FAILURE_HINT = dedent`\n Return the visitor's currency and the day's rates from the root +layout.server.ts load:\n\n import { displayRates } from '#lib/currency.server.js';\n\n export const load = async ({ locals }) => {\n \treturn {\n \t\tcurrency: locals.currency,\n \t\trates: await displayRates(locals.currency)\n \t};\n };\n\n The load has to be async with a single, final return of an object literal.\n`;\n\n/**\n * The root `+layout.server.ts` returns `currency` (what `handleCurrency`\n * resolved) and `rates` (the day's, when it isn't the business's own), so the\n * root layout can start the store before anything renders.\n *\n * A load that isn't async, has no final object-literal return, or receives\n * its event in a way the helpers can't extend is reported as `failed` with\n * the snippet to paste, and the file is left exactly as it was.\n */\nexport function modifyLayoutServerCurrency(\n layoutServerPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(layoutServerPath)) {\n return { status: \"not-found\", message: FAILURE_HINT };\n }\n const original = fs.readFileSync(layoutServerPath, \"utf8\");\n if (original.includes(\"displayRates(\")) {\n return { status: \"success\", changed: false };\n }\n\n const sourceFile = newProject().addSourceFileAtPath(layoutServerPath);\n const fn = findLoadFunction(sourceFile);\n if (!fn) return { status: \"failed\", message: FAILURE_HINT };\n const body = fn.getBody();\n if (!body || !Node.isBlock(body) || !fn.isAsync()) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n const event = inspectEventParameter(fn);\n if (event.kind === \"unsupported\") {\n return { status: \"failed\", message: FAILURE_HINT };\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 // Where `locals` comes from: the destructured parameter, the event's\n // property, or a parameter added for it.\n let locals = \"locals\";\n if (event.kind === \"identifier\") {\n locals = `${event.name}.locals`;\n } else if (event.kind === \"binding\") {\n const names = event.pattern.getElements().map((e) => e.getName());\n if (!names.includes(\"locals\")) {\n const texts = event.pattern.getElements().map((e) => e.getText());\n event.pattern.replaceWithText(`{ ${[...texts, \"locals\"].join(\", \")} }`);\n }\n } else {\n fn.addParameter({ name: \"{ locals }\" });\n }\n\n // After any spread, so nothing in it can shadow these.\n if (!hasProperty(object, \"currency\")) {\n object.addPropertyAssignment({\n name: \"currency\",\n initializer: `${locals}.currency`,\n });\n }\n if (!hasProperty(object, \"rates\")) {\n object.addPropertyAssignment({\n name: \"rates\",\n initializer: `await displayRates(${locals}.currency)`,\n });\n }\n ensureNamedImport(sourceFile, MODULE, \"displayRates\");\n formatLikeSource(sourceFile);\n const updated = sourceFile.getFullText();\n fs.writeFileSync(layoutServerPath, updated, \"utf8\");\n return { status: \"success\", changed: updated !== original };\n}\n\n/** Take `currency` and `rates` back out of the root layout's data. */\nexport function unmodifyLayoutServerCurrency(\n layoutServerPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(layoutServerPath)) {\n return { status: \"success\", changed: false };\n }\n const original = fs.readFileSync(layoutServerPath, \"utf8\");\n if (!original.includes(\"displayRates(\")) {\n return { status: \"success\", changed: false };\n }\n\n const sourceFile = newProject().addSourceFileAtPath(layoutServerPath);\n const fn = findLoadFunction(sourceFile);\n const body = fn?.getBody();\n const returned =\n fn && body && Node.isBlock(body) ? findFinalReturn(fn, body) : null;\n const object = returned && returnedObject(returned);\n if (!object) {\n return {\n status: \"failed\",\n message: `Remove currency and rates from the root +layout.server.ts load and the import from '${MODULE}'.`,\n };\n }\n for (const name of PROPERTIES) {\n object.getProperty(name)?.remove();\n }\n removeNamedImportIfUnused(\n sourceFile,\n libModule(\"currency.server.js\"),\n \"displayRates\",\n );\n removeUnusedBindingElement(sourceFile, \"locals\");\n ensureBlankLineAfterImports(sourceFile);\n formatLikeSource(sourceFile);\n const updated = sourceFile.getFullText();\n fs.writeFileSync(layoutServerPath, updated, \"utf8\");\n return { status: \"success\", changed: updated !== original };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport { libModule } from \"../../../../runtime/lib-specifier\";\nimport {\n ensureBlankLineAfterImports,\n ensureImports,\n ensurePropsBinding,\n removeImportByModuleSpecifier,\n removePropsBindingIfUnused,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nconst STATEMENT = \"currency.hydrate(data.currency, data.rates);\";\n\nconst FAILURE_HINT = dedent`\n Start the currency store from the layout's data in src/routes/+layout.svelte:\n\n <script lang=\"ts\">\n \timport { currency } from '#lib/currency.svelte.js';\n\n \tlet { data, children } = $props();\n \tcurrency.hydrate(data.currency, data.rates);\n </script>\n`;\n\n/**\n * The root `+layout.svelte` hands the store what the server resolved, before\n * any child renders: the first render already shows the visitor's currency,\n * on the server and in the browser alike.\n */\nexport function modifyLayoutSvelteCurrency(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"not-found\", message: FAILURE_HINT };\n }\n const file = SvelteFile.fromPath(layoutPath);\n if (file.toString().includes(\"currency.hydrate(\")) {\n return { status: \"success\", changed: false };\n }\n if (!file.getScript()) return { status: \"failed\", message: FAILURE_HINT };\n\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n ensureImports(sf, [\n {\n namedImports: [\"currency\"],\n moduleSpecifier: \"#lib/currency.svelte.js\",\n },\n ]);\n ensurePropsBinding(sf, \"data\");\n // Right after the props, which it reads.\n const props = sf\n .getVariableStatements()\n .find((statement) => statement.getText().includes(\"$props()\"));\n if (props) {\n sf.insertStatements(props.getChildIndex() + 1, STATEMENT);\n } else {\n sf.addStatements(STATEMENT);\n }\n });\n return out;\n });\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n\n/** Take the hydration back out, and the import and `data` prop if nothing else reads them. */\nexport function unmodifyLayoutSvelteCurrency(\n layoutPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"success\", changed: false };\n }\n const original = fs.readFileSync(layoutPath, \"utf8\");\n if (!original.includes(\"currency.hydrate(\")) {\n return { status: \"success\", changed: false };\n }\n const file = SvelteFile.fromPath(layoutPath);\n const markup = file.toString().replace(/<script[\\s\\S]*?<\\/script>/g, \"\");\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n for (const statement of sf.getStatements()) {\n if (statement.getText().includes(\"currency.hydrate(\"))\n statement.remove();\n }\n removeImportByModuleSpecifier(sf, libModule(\"currency.svelte.js\"));\n removePropsBindingIfUnused(sf, \"data\", markup);\n ensureBlankLineAfterImports(sf);\n });\n return out;\n });\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport { libModule } from \"../../../../runtime/lib-specifier\";\nimport {\n ensureBlankLineAfterImports,\n ensureImports,\n removeImportByModuleSpecifier,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\n\n/** The item, indented like the list it joins; `indent` is the list's closing tag's. */\nfunction snippet(indent: string): string {\n return `<Navbar.Item>\\n${indent}\\t<CurrencySelect />\\n${indent}</Navbar.Item>\\n${indent}`;\n}\n\nconst SNIPPET = snippet(\"\\t\\t\\t\");\n\nconst IMPORT = dedent`\n import CurrencySelect from '#lib/components/currency-select.svelte';\n`;\n\nconst FAILURE_HINT = [\n \"Add the currency select inside your <Navbar.List> in the root layout.\",\n \"\",\n \"Import to add to the <script> tag:\",\n \"\",\n IMPORT,\n \"\",\n \"Markup to add at the end of <Navbar.List>, after the language select if there is one:\",\n SNIPPET,\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create a root layout that includes a currency select inside <Navbar.List>.\",\n \"\",\n \"Import for the <script> tag:\",\n \"\",\n IMPORT,\n \"\",\n \"Markup at the end of <Navbar.List>:\",\n SNIPPET,\n].join(\"\\n\");\n\n/**\n * The currency select goes in the navbar beside the language select, when\n * there is one, else as the last item. It renders nothing until the business\n * offers a second currency, so the layout gains it with payments.\n */\nexport function modifyRootLayoutCurrencySelect(\n layoutPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n const file = SvelteFile.fromPath(layoutPath);\n if (file.hasElement(\"CurrencySelect\")) {\n return { status: \"success\", changed: false };\n }\n if (!file.hasElement(\"Navbar.List\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n const language = file.findElementContaining(\"Navbar.Item\", \"LanguageSelect\");\n if (language) {\n // On the line after the language select's item; the helper indents it.\n file.insertAfterElement(\n language,\n \"<Navbar.Item>\\n\\t<CurrencySelect />\\n</Navbar.Item>\",\n );\n } else {\n // The closing tag's own indentation already precedes the insertion point,\n // so the item starts one level in and hands that indentation back.\n const indent =\n /^([ \\t]*)<\\/Navbar\\.List>/m.exec(file.toString())?.[1] ?? \"\\t\\t\";\n const item = `\\t<Navbar.Item>\\n${indent}\\t\\t<CurrencySelect />\\n${indent}\\t</Navbar.Item>\\n${indent}`;\n if (!file.insertBeforeClosingTag(\"Navbar.List\", item))\n return { status: \"failed\", message: FAILURE_HINT };\n }\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n ensureImports(sf, [\n {\n defaultImport: \"CurrencySelect\",\n moduleSpecifier: \"#lib/components/currency-select.svelte\",\n },\n ]);\n });\n return out;\n });\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n\n/** Take the currency select (and the nav item around it) back out. */\nexport function unmodifyRootLayoutCurrencySelect(\n layoutPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"success\", changed: false };\n }\n const original = fs.readFileSync(layoutPath, \"utf8\");\n if (!original.includes(\"CurrencySelect\")) {\n return { status: \"success\", changed: false };\n }\n const file = SvelteFile.fromPath(layoutPath);\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n removeImportByModuleSpecifier(\n sf,\n libModule(\"components/currency-select.svelte\"),\n );\n ensureBlankLineAfterImports(sf);\n });\n return out;\n });\n let updated = file.toString();\n updated = updated.replace(\n /[ \\t]*<Navbar\\.Item>\\s*<CurrencySelect\\s*\\/>\\s*<\\/Navbar\\.Item>[ \\t]*\\r?\\n?/g,\n \"\",\n );\n updated = updated.replace(/[ \\t]*<CurrencySelect\\s*\\/>[ \\t]*\\r?\\n?/g, \"\");\n fs.writeFileSync(layoutPath, updated, \"utf8\");\n return { status: \"success\", changed: updated !== original };\n}\n"],"mappings":";;;;;;;;;;;AAcA,IAAM2B,IAAS,kBACT3B,IAAS,2BAETC,IAAe,CAAM;;;;;;;GASrB6B,IAAuB,CAAM;;;;;AAMnC,SAASC,IAAmB;CAC1B,OAAO,IAAIC,EAAQ;EACjB,iBAAiB,EAAE,SAAS,GAAK;EACjC,sBAAsB,EAAE,WAAWC,EAAU,OAAO;CACtD,CAAC;AACH;AAOA,SAAgBC,EACd,GACe;CACf,IAAI,CAACT,EAAG,WAAWU,CAAe,GAQhC,OALIV,EAAG,WAAWU,EAAgB,QA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vB,EAAQ,QAChB,gFACA,EACF,GACA,IAAUA,EAAQ,QAAQ,4CAA4C,EAAE,GACxEb,EAAG,cAAcmC,GAAYtB,GAAS,MAAM,GACrC;EAAE,QAAQ;EAAW,SAASA,MAAYF;CAAS;AAC5D"}
@@ -1,5 +1,5 @@
1
- import { a as e } from "./util-BLYliuUK.js";
2
- //#region src/patterns/destroy/shared.ts
1
+ import { a as e } from "./util-ILWdjRAd.js";
2
+ // src/patterns/destroy/shared.ts
3
3
  function t(t) {
4
4
  return {
5
5
  path: t,
@@ -15,13 +15,12 @@ async function n(e, t) {
15
15
  exists: !0,
16
16
  rowCount: 0
17
17
  }));
18
- let { withPocketbase: n } = await import("./pocketbase-uOpghyT5.js").then((e) => e.r), { planCollectionDrops: r } = await import("./collections-DzwWwFUQ.js").then((e) => e.n), i = [];
18
+ let { withPocketbase: n } = await import("./pocketbase-gUn2UrDd.js").then((e) => e.r), { planCollectionDrops: r } = await import("./collections-D-xbHi4M.js").then((e) => e.n), i = [];
19
19
  return await n(t.root, async (t) => {
20
20
  let n = await r(t, e);
21
21
  i.push(...n);
22
22
  }), i;
23
23
  }
24
- //#endregion
25
24
  export { t as n, n as t };
26
25
 
27
- //# sourceMappingURL=shared-DIDAkVts.js.map
26
+ //# sourceMappingURL=shared-DE-J_b1j.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"shared-DIDAkVts.js","names":["languageFromPath","toDeleteEntry","path","planDropsForCollections","collectionNames","options","n","drops","withPocketbase","plans","planCollectionDrops","pb"],"sources":["../../src/patterns/destroy/shared.ts"],"sourcesContent":["import type { CollectionDropSpec, File, Options } from \"../../core/types\";\nimport { languageFromPath } from \"../../core/util\";\n\nexport function toDeleteEntry(path: string): File {\n return {\n path,\n language: languageFromPath(path),\n content: \"\",\n status: \"success\",\n };\n}\n\n/**\n * Build `CollectionDropSpec` entries for each collection name, with live row\n * counts from PocketBase when `env === \"runtime\"`. In preview mode, returns\n * `{ exists: true, rowCount: 0 }` placeholders.\n */\nexport async function planDropsForCollections(\n collectionNames: string[],\n options: Options,\n): Promise<CollectionDropSpec[]> {\n if (collectionNames.length === 0) return [];\n\n if (options.env !== \"runtime\") {\n return collectionNames.map((name) => ({\n name,\n exists: true,\n rowCount: 0,\n }));\n }\n\n const { withPocketbase } = await import(\"../../runtime/pocketbase\");\n const { planCollectionDrops } = await import(\"../../runtime/collections\");\n const drops: CollectionDropSpec[] = [];\n await withPocketbase(options.root, async (pb) => {\n const plans = await planCollectionDrops(pb, collectionNames);\n drops.push(...plans);\n });\n return drops;\n}\n"],"mappings":";;AAGA,SAAgBC,EAAc,GAAoB;CAChD,OAAO;EACL;EACA,UAAUD,EAAiBE,CAAI;EAC/B,SAAS;EACT,QAAQ;CACV;AACF;AAOA,eAAsBC,EACpB,GACA,GAC+B;CAC/B,IAAIC,EAAgB,WAAW,GAAG,OAAO,CAAC;CAE1C,IAAIC,EAAQ,QAAQ,WAClB,OAAOD,EAAgB,KAAK,OAAU;EACpC;EACA,QAAQ;EACR,UAAU;CACZ,EAAE;CAGJ,IAAM,EAAE,sBAAmB,MAAM,OAAO,2BAAA,CAAA,MAAA,MAAAE,EAAA,CAAA,GAClC,EAAE,2BAAwB,MAAM,OAAO,4BAAA,CAAA,MAAA,MAAAA,EAAA,CAAA,GACvCC,IAA8B,CAAC;CAKrC,OAJA,MAAMC,EAAeH,EAAQ,MAAM,OAAO,MAAO;EAC/C,IAAMI,IAAQ,MAAMC,EAAoBC,GAAIP,CAAe;EAC3D,EAAM,KAAK,GAAGK,CAAK;CACrB,CAAC,GACMF;AACT"}
1
+ {"version":3,"file":"shared-DE-J_b1j.js","names":["languageFromPath","toDeleteEntry","path","planDropsForCollections","collectionNames","options","n","drops","withPocketbase","plans","planCollectionDrops","pb"],"sources":["../../src/patterns/destroy/shared.ts"],"sourcesContent":["import type { CollectionDropSpec, File, Options } from \"../../core/types\";\nimport { languageFromPath } from \"../../core/util\";\n\nexport function toDeleteEntry(path: string): File {\n return {\n path,\n language: languageFromPath(path),\n content: \"\",\n status: \"success\",\n };\n}\n\n/**\n * Build `CollectionDropSpec` entries for each collection name, with live row\n * counts from PocketBase when `env === \"runtime\"`. In preview mode, returns\n * `{ exists: true, rowCount: 0 }` placeholders.\n */\nexport async function planDropsForCollections(\n collectionNames: string[],\n options: Options,\n): Promise<CollectionDropSpec[]> {\n if (collectionNames.length === 0) return [];\n\n if (options.env !== \"runtime\") {\n return collectionNames.map((name) => ({\n name,\n exists: true,\n rowCount: 0,\n }));\n }\n\n const { withPocketbase } = await import(\"../../runtime/pocketbase\");\n const { planCollectionDrops } = await import(\"../../runtime/collections\");\n const drops: CollectionDropSpec[] = [];\n await withPocketbase(options.root, async (pb) => {\n const plans = await planCollectionDrops(pb, collectionNames);\n drops.push(...plans);\n });\n return drops;\n}\n"],"mappings":";;AAGA,SAAgBC,EAAc,GAAoB;CAChD,OAAO;EACL;EACA,UAAUD,EAAiBE,CAAI;EAC/B,SAAS;EACT,QAAQ;CACV;AACF;AAOA,eAAsBC,EACpB,GACA,GAC+B;CAC/B,IAAIC,EAAgB,WAAW,GAAG,OAAO,CAAC;CAE1C,IAAIC,EAAQ,QAAQ,WAClB,OAAOD,EAAgB,KAAK,OAAU;EACpC;EACA,QAAQ;EACR,UAAU;CACZ,EAAE;CAGJ,IAAM,EAAE,sBAAmB,MAAM,OAAO,2BAAA,CAAA,MAAA,MAAAE,EAAA,CAAA,GAClC,EAAE,2BAAwB,MAAM,OAAO,4BAAA,CAAA,MAAA,MAAAA,EAAA,CAAA,GACvCC,IAA8B,CAAC;CAKrC,OAJA,MAAMC,EAAeH,EAAQ,MAAM,OAAO,MAAO;EAC/C,IAAMI,IAAQ,MAAMC,EAAoBC,GAAIP,CAAe;EAC3D,EAAM,KAAK,GAAGK,CAAK;CACrB,CAAC,GACMF;AACT"}
@@ -1,9 +1,9 @@
1
- import { a as e } from "./util-BLYliuUK.js";
2
- import { n as t } from "./logger-CQONztPm.js";
3
- import { i as n } from "./pocketbase-uOpghyT5.js";
1
+ import { n as e } from "./logger-t1HxmpG2.js";
2
+ import { a as t } from "./util-ILWdjRAd.js";
3
+ import { i as n } from "./pocketbase-gUn2UrDd.js";
4
4
  import r from "node:fs";
5
5
  import i from "node:path";
6
- //#region src/runtime/site.ts
6
+ // src/runtime/site.ts
7
7
  function a(e) {
8
8
  return i.join(e, "src", "lib", "site.ts");
9
9
  }
@@ -103,9 +103,9 @@ async function v(e) {
103
103
  }
104
104
  async function y(n) {
105
105
  let i = a(n.root);
106
- return r.existsSync(i) ? null : (t(n).info("Creating src/lib/site.ts"), {
106
+ return r.existsSync(i) ? null : (e(n).info("Creating src/lib/site.ts"), {
107
107
  path: i,
108
- language: e(i),
108
+ language: t(i),
109
109
  content: s(await v(n)),
110
110
  status: "success"
111
111
  });
@@ -115,10 +115,10 @@ async function b(n, i) {
115
115
  if (!r.existsSync(c)) return l.length === 0 ? {
116
116
  file: null,
117
117
  business: {}
118
- } : (t(n).info("Creating src/lib/site.ts"), {
118
+ } : (e(n).info("Creating src/lib/site.ts"), {
119
119
  file: {
120
120
  path: c,
121
- language: e(c),
121
+ language: t(c),
122
122
  content: s(await v(n), void 0, i),
123
123
  status: "success"
124
124
  },
@@ -133,17 +133,16 @@ async function b(n, i) {
133
133
  return f.length === 0 ? {
134
134
  file: null,
135
135
  business: u
136
- } : (t(n).info(`Adding ${f.join(", ")} to src/lib/site.ts`), {
136
+ } : (e(n).info(`Adding ${f.join(", ")} to src/lib/site.ts`), {
137
137
  file: {
138
138
  path: c,
139
- language: e(c),
139
+ language: t(c),
140
140
  content: d,
141
141
  status: "success"
142
142
  },
143
143
  business: u
144
144
  });
145
145
  }
146
- //#endregion
147
146
  export { d as a, p as i, y as n, s as o, f as r, a as s, b as t };
148
147
 
149
- //# sourceMappingURL=site-CVtsbO_S.js.map
148
+ //# sourceMappingURL=site-B9hDxucR.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"site-CVtsbO_S.js","names":["languageFromPath","getLogger","withPocketbase","fs","path","sitePath","root","BUSINESS_KEYS","siteModule","declared","business","lines","key","propertyLines","properties","quote","name","url","entry","i","ensureComma","value","SUPPORTED_CURRENCIES","normalizeCurrency","raw","code","normalizeCountry","normalizeCurrencies","entries","codes","home","SITE_OBJECT","withSiteProperty","match","source","body","siteBusiness","text","shape","list","currency","country","m","existingName","options","appName","pb","pkg","ensureSiteFile","file","ensureSiteBusiness","wanted","existing","added","next"],"sources":["../../src/runtime/site.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, Options } from \"../core/types\";\nimport { getLogger } from \"../core/logger\";\nimport { languageFromPath } from \"../core/util\";\nimport { withPocketbase } from \"./pocketbase\";\n\n/** Where every VelaStack app keeps its name and public URL. */\nexport function sitePath(root: string): string {\n return path.join(root, \"src\", \"lib\", \"site.ts\");\n}\n\n/**\n * What a business declares about itself in `src/lib/site.ts`, next to the\n * app's name: the currency it prices in and is paid in, the country it is in\n * (prices format for it: `es-MX`, not `es`) and the other currencies it shows\n * prices in, as estimates. Every property is optional; a payments provider\n * asks for what it needs.\n */\nexport interface SiteBusiness {\n /** ISO 4217, e.g. `MXN`. */\n currency?: string;\n /** ISO 3166-1 alpha-2, e.g. `MX`. */\n country?: string;\n /** ISO 4217 codes the site also shows prices in; empty means the home currency only. */\n currencies?: string[];\n}\n\ntype BusinessKey = keyof SiteBusiness;\n\nconst BUSINESS_KEYS: BusinessKey[] = [\"currency\", \"country\", \"currencies\"];\n\n/**\n * `src/lib/site.ts` as the CLI templates ship it (`site.template.ts`), with\n * the placeholders filled in, plus whatever the business declares.\n */\nexport function siteModule(\n name: string,\n url = \"http://localhost:5173\",\n business: SiteBusiness | string = {},\n): string {\n // The old third argument was the currency alone.\n const declared: SiteBusiness =\n typeof business === \"string\" ? { currency: business } : business;\n const lines = BUSINESS_KEYS.filter((key) => declared[key] !== undefined).map(\n (key) => propertyLines(key, declared[key]!),\n );\n const properties = [\n `\\tname: ${quote(name)},`,\n `\\turl: ${quote(url)}`,\n ...lines.map((entry) => entry.join(\"\\n\")),\n ];\n return [\n \"/**\",\n \" * Site-wide metadata, and the one place the app's name and public URL live.\",\n \" *\",\n \" * Set `url` to where the site is deployed: canonical links, Open Graph images\",\n \" * and feeds are built from it, including in prerendered pages. With a backend,\",\n \" * `vela dev` and `vela deploy` copy `name` into PocketBase's application name\",\n \" * for the emails it sends, so change it here rather than in the admin panel.\",\n \" */\",\n \"export const site = {\",\n // Every property but the last ends in a comma.\n ...properties.map((entry, i) =>\n i < properties.length - 1 ? ensureComma(entry) : entry,\n ),\n \"};\",\n \"\",\n ].join(\"\\n\");\n}\n\nfunction ensureComma(entry: string): string {\n return entry.endsWith(\",\") ? entry : `${entry},`;\n}\n\n/** A property's lines: its doc comment, then `key: value` with no trailing comma. */\nfunction propertyLines(key: BusinessKey, value: string | string[]): string[] {\n switch (key) {\n case \"currency\":\n return [\n \"\\t/** ISO 4217: the currency the business prices in and is paid in. */\",\n `\\tcurrency: ${quote(value as string)}`,\n ];\n case \"country\":\n return [\n \"\\t/** ISO 3166-1: the country the business is in; prices format for it. */\",\n `\\tcountry: ${quote(value as string)}`,\n ];\n case \"currencies\":\n return [\n \"\\t/** Other currencies prices are shown in, as estimates at the day's rate. */\",\n `\\tcurrencies: [${(value as string[]).map(quote).join(\", \")}]`,\n ];\n }\n}\n\nconst SUPPORTED_CURRENCIES = (\n Intl as unknown as {\n supportedValuesOf: (key: \"currency\") => string[];\n }\n).supportedValuesOf(\"currency\");\n\n/** A three-letter code `Intl` knows, upper-cased; anything else is refused. */\nexport function normalizeCurrency(raw: unknown): string | null {\n if (typeof raw !== \"string\") return null;\n const code = raw.trim().toUpperCase();\n if (!/^[A-Z]{3}$/.test(code)) return null;\n // Any well-formed code formats, so ask for the list of real ones. Node has\n // had it since 18; the repo's ES2020 lib types just don't declare it.\n return SUPPORTED_CURRENCIES.includes(code) ? code : null;\n}\n\n/** A two-letter ISO 3166-1 code, upper-cased; anything else is refused. */\nexport function normalizeCountry(raw: unknown): string | null {\n if (typeof raw !== \"string\") return null;\n const code = raw.trim().toUpperCase();\n if (!/^[A-Z]{2}$/.test(code)) return null;\n // `Intl.DisplayNames` knows every region; an unknown one comes back as is.\n const names = new Intl.DisplayNames([\"en\"], { type: \"region\" });\n return names.of(code) !== code ? code : null;\n}\n\n/**\n * A list of currency codes, from an array or a comma-separated string,\n * upper-cased and deduplicated; `null` when any entry is not a currency.\n * `home` is left out: the business's own currency is never a display one.\n */\nexport function normalizeCurrencies(\n raw: unknown,\n home?: string,\n): string[] | null {\n const entries = Array.isArray(raw)\n ? raw\n : typeof raw === \"string\"\n ? raw.split(/[,\\s]+/)\n : null;\n if (!entries) return null;\n const codes: string[] = [];\n for (const entry of entries) {\n if (entry === \"\" || entry === undefined) continue;\n const code = normalizeCurrency(entry);\n if (!code) return null;\n if (code !== home && !codes.includes(code)) codes.push(code);\n }\n return codes;\n}\n\nconst SITE_OBJECT = /export const site = \\{\\n([\\s\\S]*?)\\n\\};/;\n\n/**\n * `src/lib/site.ts` with `key` added as the object's last property, or\n * `null` when it already has one (a project's declaration is never changed\n * behind its back) or has no `export const site = { ... };` to add it to.\n */\nexport function withSiteProperty(\n source: string,\n key: BusinessKey,\n value: string | string[],\n): string | null {\n const match = SITE_OBJECT.exec(source);\n if (!match || new RegExp(`^\\\\s*${key}\\\\s*:`, \"m\").test(match[1])) return null;\n const body = match[1].replace(/,?\\s*$/, \",\");\n return source.replace(\n match[0],\n `export const site = {\\n${body}\\n${propertyLines(key, value).join(\"\\n\")}\\n};`,\n );\n}\n\n/** `withSiteProperty` for the currency, as the Phase 1.5 code called it. */\nexport function withSiteCurrency(\n source: string,\n currency: string,\n): string | null {\n return withSiteProperty(source, \"currency\", currency);\n}\n\n/** What `src/lib/site.ts` declares about the business, if anything. */\nexport function siteBusiness(root: string): SiteBusiness {\n let source: string;\n try {\n source = fs.readFileSync(sitePath(root), \"utf8\");\n } catch {\n return {};\n }\n const text = (key: string, shape: string) =>\n new RegExp(`^\\\\s*${key}\\\\s*:\\\\s*['\"](${shape})['\"]`, \"m\").exec(source)?.[1];\n const list = /^\\s*currencies\\s*:\\s*\\[([^\\]]*)\\]/m.exec(source)?.[1];\n const business: SiteBusiness = {};\n const currency = text(\"currency\", \"[A-Za-z]{3}\");\n if (currency) business.currency = currency;\n const country = text(\"country\", \"[A-Za-z]{2}\");\n if (country) business.country = country;\n if (list !== undefined) {\n business.currencies = [...list.matchAll(/['\"]([A-Za-z]{3})['\"]/g)].map(\n (m) => m[1],\n );\n }\n return business;\n}\n\n/** The currency `src/lib/site.ts` declares, if any. */\nexport function siteCurrency(root: string): string | null {\n return siteBusiness(root).currency ?? null;\n}\n\n/** Single-quoted, as the templates write their strings. */\nfunction quote(value: string): string {\n return `'${value.replace(/\\\\/g, \"\\\\\\\\\").replace(/'/g, \"\\\\'\")}'`;\n}\n\n/**\n * The name a project created before `site.ts` existed already goes by.\n *\n * Those projects kept it in PocketBase's settings, so that is asked first; the\n * package name is the fallback for a project without a backend, or one whose\n * database can't be reached.\n */\nasync function existingName(options: Options): Promise<string> {\n if (options.features.backend) {\n try {\n let appName: unknown;\n await withPocketbase(options.root, async (pb) => {\n const settings = (await pb.settings.getAll()) as {\n meta?: { appName?: unknown };\n };\n appName = settings.meta?.appName;\n });\n if (typeof appName === \"string\" && appName.trim()) return appName;\n } catch {\n // No database to ask; fall through to package.json.\n }\n }\n\n try {\n const pkg = JSON.parse(\n fs.readFileSync(path.join(options.root, \"package.json\"), \"utf8\"),\n ) as { name?: unknown };\n if (typeof pkg.name === \"string\" && pkg.name.trim()) return pkg.name;\n } catch {\n // No package.json to name the site after; the placeholder stands.\n }\n return \"My App\";\n}\n\n/**\n * Create `src/lib/site.ts` for a pattern whose files import `#lib/site.js`, when\n * the project doesn't have one yet. Every template ships it; projects created\n * before that read the app name from `locals.meta` instead.\n *\n * Returns null when the file exists, so an existing one is never overwritten.\n */\nexport async function ensureSiteFile(options: Options): Promise<File | null> {\n const file = sitePath(options.root);\n if (fs.existsSync(file)) return null;\n\n getLogger(options).info(\"Creating src/lib/site.ts\");\n return {\n path: file,\n language: languageFromPath(file),\n content: siteModule(await existingName(options)),\n status: \"success\",\n };\n}\n\n/**\n * Make `src/lib/site.ts` declare what the business says about itself: create\n * the file with it, or add the properties an existing one lacks. A property\n * already there is kept, whatever `business` says; the result says what the\n * file declares after the call, and the file to write, if anything changed.\n */\nexport async function ensureSiteBusiness(\n options: Options,\n business: SiteBusiness,\n): Promise<{ file: File | null; business: SiteBusiness }> {\n const file = sitePath(options.root);\n const wanted = BUSINESS_KEYS.filter((key) => business[key] !== undefined);\n if (!fs.existsSync(file)) {\n if (wanted.length === 0) return { file: null, business: {} };\n getLogger(options).info(\"Creating src/lib/site.ts\");\n return {\n file: {\n path: file,\n language: languageFromPath(file),\n content: siteModule(await existingName(options), undefined, business),\n status: \"success\",\n },\n business,\n };\n }\n\n const existing = siteBusiness(options.root);\n let source = fs.readFileSync(file, \"utf8\");\n const added: string[] = [];\n for (const key of wanted) {\n if (existing[key] !== undefined) continue;\n const next = withSiteProperty(source, key, business[key]!);\n if (next === null) continue;\n source = next;\n added.push(key);\n (existing as Record<string, unknown>)[key] = business[key];\n }\n if (added.length === 0) return { file: null, business: existing };\n getLogger(options).info(`Adding ${added.join(\", \")} to src/lib/site.ts`);\n return {\n file: {\n path: file,\n language: languageFromPath(file),\n content: source,\n status: \"success\",\n },\n business: existing,\n };\n}\n\n/** `ensureSiteBusiness` for the currency alone, as the Phase 1.5 code called it. */\nexport async function ensureSiteCurrency(\n options: Options,\n currency: string,\n): Promise<{ file: File | null; currency: string }> {\n const { file, business } = await ensureSiteBusiness(options, { currency });\n return { file, currency: business.currency ?? currency };\n}\n"],"mappings":";;;;;;AAQA,SAAgBK,EAAS,GAAsB;CAC7C,OAAOD,EAAK,KAAKE,GAAM,OAAO,OAAO,SAAS;AAChD;AAoBA,IAAMC,IAA+B;CAAC;CAAY;CAAW;AAAY;AAMzE,SAAgBC,EACd,GACA,IAAM,yBACN,IAAkC,CAAC,GAC3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ACpB,GACA,GACwD;CACxD,IAAMD,IAAO5C,EAASuC,EAAQ,IAAI,GAC5BO,IAAS5C,EAAc,QAAQ,MAAQG,EAASE,OAAS,KAAA,CAAS;CACxE,IAAI,CAACT,EAAG,WAAW8C,CAAI,GAGrB,OAFIE,EAAO,WAAW,IAAU;EAAE,MAAM;EAAM,UAAU,CAAC;CAAE,KAC3DlD,EAAU2C,CAAO,CAAC,CAAC,KAAK,0BAA0B,GAC3C;EACL,MAAM;GACJ,MAAMK;GACN,UAAUjD,EAAiBiD,CAAI;GAC/B,SAASzC,EAAW,MAAMmC,EAAaC,CAAO,GAAG,KAAA,GAAWlC,CAAQ;GACpE,QAAQ;EACV;EACA;CACF;CAGF,IAAM0C,IAAWhB,EAAaQ,EAAQ,IAAI,GACtCV,IAAS/B,EAAG,aAAa8C,GAAM,MAAM,GACnCI,IAAkB,CAAC;CACzB,KAAK,IAAMzC,KAAOuC,GAAQ;EACxB,IAAIC,EAASxC,OAAS,KAAA,GAAW;EACjC,IAAM0C,IAAOtB,EAAiBE,GAAQtB,GAAKF,EAASE,EAAK;EACzD,AAAI0C,MAAS,SACb,IAASA,GACTD,EAAM,KAAKzC,CAAG,GACd,EAAsCA,KAAOF,EAASE;CACxD;CAGA,OAFIyC,EAAM,WAAW,IAAU;EAAE,MAAM;EAAM,UAAUD;CAAS,KAChEnD,EAAU2C,CAAO,CAAC,CAAC,KAAK,UAAUS,EAAM,KAAK,IAAI,EAAE,oBAAoB,GAChE;EACL,MAAM;GACJ,MAAMJ;GACN,UAAUjD,EAAiBiD,CAAI;GAC/B,SAASf;GACT,QAAQ;EACV;EACA,UAAUkB;CACZ;AACF"}
1
+ {"version":3,"file":"site-B9hDxucR.js","names":["getLogger","languageFromPath","withPocketbase","fs","path","sitePath","root","BUSINESS_KEYS","siteModule","declared","business","lines","key","propertyLines","properties","quote","name","url","entry","i","ensureComma","value","SUPPORTED_CURRENCIES","normalizeCurrency","raw","code","normalizeCountry","normalizeCurrencies","entries","codes","home","SITE_OBJECT","withSiteProperty","match","source","body","siteBusiness","text","shape","list","currency","country","m","existingName","options","appName","pb","pkg","ensureSiteFile","file","ensureSiteBusiness","wanted","existing","added","next"],"sources":["../../src/runtime/site.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, Options } from \"../core/types\";\nimport { getLogger } from \"../core/logger\";\nimport { languageFromPath } from \"../core/util\";\nimport { withPocketbase } from \"./pocketbase\";\n\n/** Where every VelaStack app keeps its name and public URL. */\nexport function sitePath(root: string): string {\n return path.join(root, \"src\", \"lib\", \"site.ts\");\n}\n\n/**\n * What a business declares about itself in `src/lib/site.ts`, next to the\n * app's name: the currency it prices in and is paid in, the country it is in\n * (prices format for it: `es-MX`, not `es`) and the other currencies it shows\n * prices in, as estimates. Every property is optional; a payments provider\n * asks for what it needs.\n */\nexport interface SiteBusiness {\n /** ISO 4217, e.g. `MXN`. */\n currency?: string;\n /** ISO 3166-1 alpha-2, e.g. `MX`. */\n country?: string;\n /** ISO 4217 codes the site also shows prices in; empty means the home currency only. */\n currencies?: string[];\n}\n\ntype BusinessKey = keyof SiteBusiness;\n\nconst BUSINESS_KEYS: BusinessKey[] = [\"currency\", \"country\", \"currencies\"];\n\n/**\n * `src/lib/site.ts` as the CLI templates ship it (`site.template.ts`), with\n * the placeholders filled in, plus whatever the business declares.\n */\nexport function siteModule(\n name: string,\n url = \"http://localhost:5173\",\n business: SiteBusiness | string = {},\n): string {\n // The old third argument was the currency alone.\n const declared: SiteBusiness =\n typeof business === \"string\" ? { currency: business } : business;\n const lines = BUSINESS_KEYS.filter((key) => declared[key] !== undefined).map(\n (key) => propertyLines(key, declared[key]!),\n );\n const properties = [\n `\\tname: ${quote(name)},`,\n `\\turl: ${quote(url)}`,\n ...lines.map((entry) => entry.join(\"\\n\")),\n ];\n return [\n \"/**\",\n \" * Site-wide metadata, and the one place the app's name and public URL live.\",\n \" *\",\n \" * Set `url` to where the site is deployed: canonical links, Open Graph images\",\n \" * and feeds are built from it, including in prerendered pages. With a backend,\",\n \" * `vela dev` and `vela deploy` copy `name` into PocketBase's application name\",\n \" * for the emails it sends, so change it here rather than in the admin panel.\",\n \" */\",\n \"export const site = {\",\n // Every property but the last ends in a comma.\n ...properties.map((entry, i) =>\n i < properties.length - 1 ? ensureComma(entry) : entry,\n ),\n \"};\",\n \"\",\n ].join(\"\\n\");\n}\n\nfunction ensureComma(entry: string): string {\n return entry.endsWith(\",\") ? entry : `${entry},`;\n}\n\n/** A property's lines: its doc comment, then `key: value` with no trailing comma. */\nfunction propertyLines(key: BusinessKey, value: string | string[]): string[] {\n switch (key) {\n case \"currency\":\n return [\n \"\\t/** ISO 4217: the currency the business prices in and is paid in. */\",\n `\\tcurrency: ${quote(value as string)}`,\n ];\n case \"country\":\n return [\n \"\\t/** ISO 3166-1: the country the business is in; prices format for it. */\",\n `\\tcountry: ${quote(value as string)}`,\n ];\n case \"currencies\":\n return [\n \"\\t/** Other currencies prices are shown in, as estimates at the day's rate. */\",\n `\\tcurrencies: [${(value as string[]).map(quote).join(\", \")}]`,\n ];\n }\n}\n\nconst SUPPORTED_CURRENCIES = (\n Intl as unknown as {\n supportedValuesOf: (key: \"currency\") => string[];\n }\n).supportedValuesOf(\"currency\");\n\n/** A three-letter code `Intl` knows, upper-cased; anything else is refused. */\nexport function normalizeCurrency(raw: unknown): string | null {\n if (typeof raw !== \"string\") return null;\n const code = raw.trim().toUpperCase();\n if (!/^[A-Z]{3}$/.test(code)) return null;\n // Any well-formed code formats, so ask for the list of real ones. Node has\n // had it since 18; the repo's ES2020 lib types just don't declare it.\n return SUPPORTED_CURRENCIES.includes(code) ? code : null;\n}\n\n/** A two-letter ISO 3166-1 code, upper-cased; anything else is refused. */\nexport function normalizeCountry(raw: unknown): string | null {\n if (typeof raw !== \"string\") return null;\n const code = raw.trim().toUpperCase();\n if (!/^[A-Z]{2}$/.test(code)) return null;\n // `Intl.DisplayNames` knows every region; an unknown one comes back as is.\n const names = new Intl.DisplayNames([\"en\"], { type: \"region\" });\n return names.of(code) !== code ? code : null;\n}\n\n/**\n * A list of currency codes, from an array or a comma-separated string,\n * upper-cased and deduplicated; `null` when any entry is not a currency.\n * `home` is left out: the business's own currency is never a display one.\n */\nexport function normalizeCurrencies(\n raw: unknown,\n home?: string,\n): string[] | null {\n const entries = Array.isArray(raw)\n ? raw\n : typeof raw === \"string\"\n ? raw.split(/[,\\s]+/)\n : null;\n if (!entries) return null;\n const codes: string[] = [];\n for (const entry of entries) {\n if (entry === \"\" || entry === undefined) continue;\n const code = normalizeCurrency(entry);\n if (!code) return null;\n if (code !== home && !codes.includes(code)) codes.push(code);\n }\n return codes;\n}\n\nconst SITE_OBJECT = /export const site = \\{\\n([\\s\\S]*?)\\n\\};/;\n\n/**\n * `src/lib/site.ts` with `key` added as the object's last property, or\n * `null` when it already has one (a project's declaration is never changed\n * behind its back) or has no `export const site = { ... };` to add it to.\n */\nexport function withSiteProperty(\n source: string,\n key: BusinessKey,\n value: string | string[],\n): string | null {\n const match = SITE_OBJECT.exec(source);\n if (!match || new RegExp(`^\\\\s*${key}\\\\s*:`, \"m\").test(match[1])) return null;\n const body = match[1].replace(/,?\\s*$/, \",\");\n return source.replace(\n match[0],\n `export const site = {\\n${body}\\n${propertyLines(key, value).join(\"\\n\")}\\n};`,\n );\n}\n\n/** `withSiteProperty` for the currency, as the Phase 1.5 code called it. */\nexport function withSiteCurrency(\n source: string,\n currency: string,\n): string | null {\n return withSiteProperty(source, \"currency\", currency);\n}\n\n/** What `src/lib/site.ts` declares about the business, if anything. */\nexport function siteBusiness(root: string): SiteBusiness {\n let source: string;\n try {\n source = fs.readFileSync(sitePath(root), \"utf8\");\n } catch {\n return {};\n }\n const text = (key: string, shape: string) =>\n new RegExp(`^\\\\s*${key}\\\\s*:\\\\s*['\"](${shape})['\"]`, \"m\").exec(source)?.[1];\n const list = /^\\s*currencies\\s*:\\s*\\[([^\\]]*)\\]/m.exec(source)?.[1];\n const business: SiteBusiness = {};\n const currency = text(\"currency\", \"[A-Za-z]{3}\");\n if (currency) business.currency = currency;\n const country = text(\"country\", \"[A-Za-z]{2}\");\n if (country) business.country = country;\n if (list !== undefined) {\n business.currencies = [...list.matchAll(/['\"]([A-Za-z]{3})['\"]/g)].map(\n (m) => m[1],\n );\n }\n return business;\n}\n\n/** The currency `src/lib/site.ts` declares, if any. */\nexport function siteCurrency(root: string): string | null {\n return siteBusiness(root).currency ?? null;\n}\n\n/** Single-quoted, as the templates write their strings. */\nfunction quote(value: string): string {\n return `'${value.replace(/\\\\/g, \"\\\\\\\\\").replace(/'/g, \"\\\\'\")}'`;\n}\n\n/**\n * The name a project created before `site.ts` existed already goes by.\n *\n * Those projects kept it in PocketBase's settings, so that is asked first; the\n * package name is the fallback for a project without a backend, or one whose\n * database can't be reached.\n */\nasync function existingName(options: Options): Promise<string> {\n if (options.features.backend) {\n try {\n let appName: unknown;\n await withPocketbase(options.root, async (pb) => {\n const settings = (await pb.settings.getAll()) as {\n meta?: { appName?: unknown };\n };\n appName = settings.meta?.appName;\n });\n if (typeof appName === \"string\" && appName.trim()) return appName;\n } catch {\n // No database to ask; fall through to package.json.\n }\n }\n\n try {\n const pkg = JSON.parse(\n fs.readFileSync(path.join(options.root, \"package.json\"), \"utf8\"),\n ) as { name?: unknown };\n if (typeof pkg.name === \"string\" && pkg.name.trim()) return pkg.name;\n } catch {\n // No package.json to name the site after; the placeholder stands.\n }\n return \"My App\";\n}\n\n/**\n * Create `src/lib/site.ts` for a pattern whose files import `#lib/site.js`, when\n * the project doesn't have one yet. Every template ships it; projects created\n * before that read the app name from `locals.meta` instead.\n *\n * Returns null when the file exists, so an existing one is never overwritten.\n */\nexport async function ensureSiteFile(options: Options): Promise<File | null> {\n const file = sitePath(options.root);\n if (fs.existsSync(file)) return null;\n\n getLogger(options).info(\"Creating src/lib/site.ts\");\n return {\n path: file,\n language: languageFromPath(file),\n content: siteModule(await existingName(options)),\n status: \"success\",\n };\n}\n\n/**\n * Make `src/lib/site.ts` declare what the business says about itself: create\n * the file with it, or add the properties an existing one lacks. A property\n * already there is kept, whatever `business` says; the result says what the\n * file declares after the call, and the file to write, if anything changed.\n */\nexport async function ensureSiteBusiness(\n options: Options,\n business: SiteBusiness,\n): Promise<{ file: File | null; business: SiteBusiness }> {\n const file = sitePath(options.root);\n const wanted = BUSINESS_KEYS.filter((key) => business[key] !== undefined);\n if (!fs.existsSync(file)) {\n if (wanted.length === 0) return { file: null, business: {} };\n getLogger(options).info(\"Creating src/lib/site.ts\");\n return {\n file: {\n path: file,\n language: languageFromPath(file),\n content: siteModule(await existingName(options), undefined, business),\n status: \"success\",\n },\n business,\n };\n }\n\n const existing = siteBusiness(options.root);\n let source = fs.readFileSync(file, \"utf8\");\n const added: string[] = [];\n for (const key of wanted) {\n if (existing[key] !== undefined) continue;\n const next = withSiteProperty(source, key, business[key]!);\n if (next === null) continue;\n source = next;\n added.push(key);\n (existing as Record<string, unknown>)[key] = business[key];\n }\n if (added.length === 0) return { file: null, business: existing };\n getLogger(options).info(`Adding ${added.join(\", \")} to src/lib/site.ts`);\n return {\n file: {\n path: file,\n language: languageFromPath(file),\n content: source,\n status: \"success\",\n },\n business: existing,\n };\n}\n\n/** `ensureSiteBusiness` for the currency alone, as the Phase 1.5 code called it. */\nexport async function ensureSiteCurrency(\n options: Options,\n currency: string,\n): Promise<{ file: File | null; currency: string }> {\n const { file, business } = await ensureSiteBusiness(options, { currency });\n return { file, currency: business.currency ?? currency };\n}\n"],"mappings":";;;;;;AAQA,SAAgBK,EAAS,GAAsB;CAC7C,OAAOD,EAAK,KAAKE,GAAM,OAAO,OAAO,SAAS;AAChD;AAoBA,IAAMC,IAA+B;CAAC;CAAY;CAAW;AAAY;AAMzE,SAAgBC,EACd,GACA,IAAM,yBACN,IAAkC,CAAC,GAC3B;CAER,IAAMC,IACJ,OAAOC,KAAa,WAAW,EAAE,UAAUA,EAAS,IAAIA,GACpDC,IAAQJ,EAAc,QAAQ,MAAQE,EAASG,OAAS,KAAA,CAAS,CAAC,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CAACT,EAAG,WAAW8C,CAAI,GAGrB,OAFIE,EAAO,WAAW,IAAU;EAAE,MAAM;EAAM,UAAU,CAAC;CAAE,KAC3DnD,EAAU4C,CAAO,CAAC,CAAC,KAAK,0BAA0B,GAC3C;EACL,MAAM;GACJ,MAAMK;GACN,UAAUhD,EAAiBgD,CAAI;GAC/B,SAASzC,EAAW,MAAMmC,EAAaC,CAAO,GAAG,KAAA,GAAWlC,CAAQ;GACpE,QAAQ;EACV;EACA;CACF;CAGF,IAAM0C,IAAWhB,EAAaQ,EAAQ,IAAI,GACtCV,IAAS/B,EAAG,aAAa8C,GAAM,MAAM,GACnCI,IAAkB,CAAC;CACzB,KAAK,IAAMzC,KAAOuC,GAAQ;EACxB,IAAIC,EAASxC,OAAS,KAAA,GAAW;EACjC,IAAM0C,IAAOtB,EAAiBE,GAAQtB,GAAKF,EAASE,EAAK;EACzD,AAAI0C,MAAS,SACb,IAASA,GACTD,EAAM,KAAKzC,CAAG,GACd,EAAsCA,KAAOF,EAASE;CACxD;CAGA,OAFIyC,EAAM,WAAW,IAAU;EAAE,MAAM;EAAM,UAAUD;CAAS,KAChEpD,EAAU4C,CAAO,CAAC,CAAC,KAAK,UAAUS,EAAM,KAAK,IAAI,EAAE,oBAAoB,GAChE;EACL,MAAM;GACJ,MAAMJ;GACN,UAAUhD,EAAiBgD,CAAI;GAC/B,SAASf;GACT,QAAQ;EACV;EACA,UAAUkB;CACZ;AACF"}
@@ -1,6 +1,5 @@
1
- //#region src/patterns/enable/payments/providers-app-mode/stripe/src/lib/server/stripe-customer.ts?raw
1
+ // src/patterns/enable/payments/providers-app-mode/stripe/src/lib/server/stripe-customer.ts?raw
2
2
  var e = "import { linkStripeCustomer } from '#lib/workflows/link-stripe-customer.js';\n\n/**\n * The user's Stripe customer id. Signup starts link-stripe-customer in the\n * background, so a user can get here before it finishes, or without it ever\n * starting (a one-time-code signup, an import). Either way this starts or\n * joins that same run (the user's id is its idempotency key, so there is still\n * one customer) and waits a little for it.\n *\n * Throws when the customer is not there in time; the caller decides whether to\n * say \"try again shortly\" or fail.\n */\nexport async function getStripeCustomerId(\n admin: App.Locals['admin'],\n user: { id: string; email?: string },\n timeoutMs = 10_000\n): Promise<string> {\n try {\n const customer = await admin\n .collection('stripe_customers')\n .getFirstListItem(admin.filter('user = {:user}', { user: user.id }));\n return customer.id;\n } catch {\n // Not linked yet.\n }\n\n const handle = await linkStripeCustomer.run(\n { userId: user.id, email: user.email || undefined },\n { idempotencyKey: user.id }\n );\n const { customerId } = await handle.result({ timeoutMs });\n return customerId;\n}\n";
3
- //#endregion
4
3
  export { e as t };
5
4
 
6
- //# sourceMappingURL=stripe-customer-B3tP8gtD.js.map
5
+ //# sourceMappingURL=stripe-customer-5S-nOXP1.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stripe-customer-5S-nOXP1.js","names":["stripe_customer_default"],"sources":[],"mappings":""}
@@ -1,7 +1,7 @@
1
1
  import e from "node:fs";
2
2
  import { parse as t } from "svelte/compiler";
3
3
  import n from "magic-string";
4
- //#region src/runtime/svelte-file.ts
4
+ // src/runtime/svelte-file.ts
5
5
  var r = class r {
6
6
  constructor(e) {
7
7
  this.source = e, this.ast = t(e, { modern: !0 }), this.s = new n(e);
@@ -152,7 +152,6 @@ function a(e, t) {
152
152
  }
153
153
  return r(e);
154
154
  }
155
- //#endregion
156
155
  export { r as t };
157
156
 
158
- //# sourceMappingURL=svelte-file-Dv5-bl79.js.map
157
+ //# sourceMappingURL=svelte-file-DfplF3BU.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"svelte-file-Dv5-bl79.js","names":["fs","MagicString","SvelteFile","source","parse","filePath","script","start","end","fn","block","next","findNode","node","name","componentName","attr","attrName","closingTag","closingPos","content","newContent","isElement","outer","child","inner","candidate","indent","lineStart","pos","lead","unit","nested","line","tabs","i","nodes","index","trimmed","prev","last","insertAt","attrs","a","seen","visit","predicate","key","item","found","root"],"sources":["../../src/runtime/svelte-file.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { parse, type AST } from \"svelte/compiler\";\nimport MagicString from \"magic-string\";\n\ntype SvelteAst = AST.Root;\ntype SvelteNode = any;\n\ninterface ScriptBlock {\n content: string;\n start: number;\n end: number;\n}\n\n/**\n * Surgical, AST-aware editing of .svelte files.\n *\n * Parses the source with svelte/compiler to discover precise character offsets,\n * then applies edits via magic-string so untouched regions remain byte-for-byte\n * identical to the original. Script-block contents are exposed as plain strings\n * so callers can hand them to ts-morph.\n */\nexport class SvelteFile {\n private readonly source: string;\n private readonly ast: SvelteAst;\n private readonly s: MagicString;\n\n constructor(source: string) {\n this.source = source;\n this.ast = parse(source, { modern: true });\n this.s = new MagicString(source);\n }\n\n static fromPath(filePath: string): SvelteFile {\n return new SvelteFile(fs.readFileSync(filePath, \"utf8\"));\n }\n\n getScript(): ScriptBlock | null {\n return this.scriptInner((this.ast as any).instance);\n }\n\n getModuleScript(): ScriptBlock | null {\n return this.scriptInner((this.ast as any).module);\n }\n\n private scriptInner(script: SvelteNode | null): ScriptBlock | null {\n if (!script) return null;\n const start = script.content.start as number;\n const end = script.content.end as number;\n return { content: this.source.slice(start, end), start, end };\n }\n\n /**\n * Replace the inner contents of <script>. Use for ts-morph round-trips.\n * Returns true when an edit was made.\n */\n modifyScript(fn: (content: string) => string): boolean {\n return this.modifyScriptBlock(this.getScript(), fn);\n }\n\n modifyModuleScript(fn: (content: string) => string): boolean {\n return this.modifyScriptBlock(this.getModuleScript(), fn);\n }\n\n private modifyScriptBlock(\n block: ScriptBlock | null,\n fn: (content: string) => string,\n ): boolean {\n if (!block) return false;\n const next = fn(block.content);\n if (next === block.content) return false;\n this.s.overwrite(block.start, block.end, next);\n return true;\n }\n\n /** First Component or RegularElement node with the given name. */\n findElement(name: string): SvelteNode | null {\n return findNode(\n (this.ast as any).fragment,\n (node) =>\n (node.type === \"Component\" || node.type === \"RegularElement\") &&\n node.name === name,\n );\n }\n\n hasElement(name: string): boolean {\n return this.findElement(name) !== null;\n }\n\n hasAttribute(componentName: string, attrName: string): boolean {\n const node = this.findElement(componentName);\n if (!node) return false;\n return (node.attributes ?? []).some(\n (attr: SvelteNode) => attr.type === \"Attribute\" && attr.name === attrName,\n );\n }\n\n /**\n * Insert content at the end of <ComponentName>'s children, just before the\n * closing tag. No-op if the element is not found.\n */\n insertBeforeClosingTag(name: string, content: string): boolean {\n const node = this.findElement(name);\n if (!node) return false;\n const closingTag = `</${name}>`;\n const closingPos = this.source.lastIndexOf(closingTag, node.end);\n if (closingPos === -1) return false;\n this.s.appendLeft(closingPos, content);\n return true;\n }\n\n /** Replace the element entirely (start tag through close tag). */\n replaceElement(name: string, newContent: string): boolean {\n const node = this.findElement(name);\n if (!node) return false;\n this.s.overwrite(node.start, node.end, newContent);\n return true;\n }\n\n /** Remove the element (start tag through close tag). */\n removeElement(name: string): boolean {\n return this.replaceElement(name, \"\");\n }\n\n /**\n * The first <outer> element with an <inner> element somewhere inside it:\n * the `Navbar.Item` that holds `AuthMenu.Root`, among several items.\n */\n findElementContaining(outer: string, inner: string): SvelteNode | null {\n return findNode(\n (this.ast as any).fragment,\n (node) =>\n isElement(node, outer) &&\n findNode(node.fragment, (child) => isElement(child, inner)) !== null,\n );\n }\n\n /** The <child> elements directly inside the first <name> element, in order. */\n childElements(name: string, child: string): SvelteNode[] {\n const node = this.findElement(name);\n const nodes: SvelteNode[] = node?.fragment?.nodes ?? [];\n return nodes.filter((candidate) => isElement(candidate, child));\n }\n\n /**\n * Put `content` on its own line directly before `node`, at `node`'s\n * indentation. Lines after the first are indented to match too, with their\n * leading tabs turned into the file's indent unit.\n */\n insertBeforeElement(node: SvelteNode, content: string): void {\n const indent = this.indentOf(node.start as number);\n this.s.appendLeft(\n node.start as number,\n `${this.reindent(content, indent)}\\n${indent}`,\n );\n }\n\n /** Like `insertBeforeElement`, on the line after `node`. */\n insertAfterElement(node: SvelteNode, content: string): void {\n const indent = this.indentOf(node.start as number);\n this.s.appendLeft(\n node.end as number,\n `\\n${indent}${this.reindent(content, indent)}`,\n );\n }\n\n /**\n * Remove the first <outer> containing <inner>, and the line it stood on\n * when nothing else shared it. Returns false when there is none.\n */\n removeElementContaining(outer: string, inner: string): boolean {\n const node = this.findElementContaining(outer, inner);\n if (!node) return false;\n let start = node.start as number;\n while (start > 0 && /[ \\t]/.test(this.source[start - 1]!)) start--;\n if (start > 0 && this.source[start - 1] === \"\\n\") start--;\n this.s.remove(start, node.end as number);\n return true;\n }\n\n /** The whitespace between the start of `pos`'s line and `pos`. */\n private indentOf(pos: number): string {\n const lineStart = this.source.lastIndexOf(\"\\n\", pos - 1) + 1;\n const lead = this.source.slice(lineStart, pos);\n return /^[ \\t]*$/.test(lead) ? lead : \"\";\n }\n\n private reindent(content: string, indent: string): string {\n const unit = indent.includes(\" \") ? \" \" : \"\\t\";\n return content\n .split(\"\\n\")\n .map((line, i) => {\n const nested = line.replace(/^\\t+/, (tabs) => unit.repeat(tabs.length));\n return i === 0 ? nested : `${indent}${nested}`;\n })\n .join(\"\\n\");\n }\n\n /** Append raw markup to the end of the source file. */\n appendMarkup(content: string): void {\n this.s.append(content);\n }\n\n /**\n * Insert markup so it renders before the layout's children — i.e. ahead of\n * the top-level `{@render children()}` (or legacy `<slot />`). The markup\n * lands on its own line directly after the preceding sibling, so\n *\n * <Toaster />\n *\n * {@render children?.()}\n *\n * becomes `<Toaster />\\n<AdminBar />\\n\\n{@render children?.()}`. When the\n * render tag is the first node the markup goes immediately before it.\n * Returns false (and changes nothing) if no such tag exists.\n */\n insertBeforeChildren(content: string): boolean {\n const nodes: SvelteNode[] = (this.ast as any).fragment?.nodes ?? [];\n const index = nodes.findIndex(\n (node) =>\n node.type === \"RenderTag\" ||\n node.type === \"SlotElement\" ||\n (node.type === \"RegularElement\" && node.name === \"slot\"),\n );\n if (index === -1) return false;\n\n const trimmed = content.trim();\n for (let i = index - 1; i >= 0; i--) {\n const prev = nodes[i]!;\n if (prev.type === \"Text\" && prev.data.trim() === \"\") continue;\n this.s.appendLeft(prev.end as number, `\\n${trimmed}`);\n return true;\n }\n this.s.appendLeft(nodes[index]!.start as number, `${trimmed}\\n\\n`);\n return true;\n }\n\n /**\n * Append attribute text (e.g. \" team={data.team}\") just after the last\n * existing attribute on the element's start tag.\n */\n appendToAttributes(name: string, attrs: string): boolean {\n const node = this.findElement(name);\n if (!node) return false;\n const last = (node.attributes ?? []).at(-1) as SvelteNode | undefined;\n const insertAt = last\n ? (last.end as number)\n : (node.start as number) + `<${name}`.length;\n this.s.appendLeft(insertAt, attrs);\n return true;\n }\n\n /**\n * Remove a named attribute from a component's start tag, including the\n * leading whitespace. No-op if the element or attribute isn't present.\n */\n removeAttribute(name: string, attrName: string): boolean {\n const node = this.findElement(name);\n if (!node) return false;\n const attr = (node.attributes ?? []).find(\n (a: SvelteNode) => a.type === \"Attribute\" && a.name === attrName,\n );\n if (!attr) return false;\n // Extend the removal backwards over the whitespace between the previous\n // token and this attribute so the tag doesn't collapse `<Foo />`.\n let start = attr.start as number;\n while (start > 0 && /\\s/.test(this.source[start - 1]!)) start--;\n this.s.remove(start, attr.end as number);\n return true;\n }\n\n hasChanged(): boolean {\n return this.s.hasChanged();\n }\n\n toString(): string {\n return this.s.toString();\n }\n\n writeTo(filePath: string): void {\n if (this.hasChanged()) {\n fs.writeFileSync(filePath, this.toString(), \"utf8\");\n }\n }\n}\n\nfunction isElement(node: any, name: string): boolean {\n return (\n (node?.type === \"Component\" || node?.type === \"RegularElement\") &&\n node.name === name\n );\n}\n\nfunction findNode(\n root: unknown,\n predicate: (node: any) => boolean,\n): any | null {\n const seen = new WeakSet<object>();\n function visit(node: unknown): any | null {\n if (!node || typeof node !== \"object\" || seen.has(node as object)) {\n return null;\n }\n seen.add(node as object);\n if (predicate(node as any)) return node;\n for (const key of Object.keys(node as Record<string, unknown>)) {\n if (key === \"parent\") continue;\n const child = (node as Record<string, unknown>)[key];\n if (Array.isArray(child)) {\n for (const item of child) {\n const found = visit(item);\n if (found) return found;\n }\n } else if (\n child &&\n typeof child === \"object\" &&\n \"type\" in (child as object)\n ) {\n const found = visit(child);\n if (found) return found;\n }\n }\n return null;\n }\n return visit(root);\n}\n"],"mappings":";;;;AAqBA,IAAaE,IAAb,MAAaA,EAAW;CAKtB,YAAY,GAAgB;EAG1B,AAFA,KAAK,SAASC,GACd,KAAK,MAAMC,EAAMD,GAAQ,EAAE,QAAQ,GAAK,CAAC,GACzC,KAAK,IAAI,IAAIF,EAAYE,CAAM;CACjC;CAEA,OAAO,SAAS,GAA8B;EAC5C,OAAO,IAAID,EAAWF,EAAG,aAAaK,GAAU,MAAM,CAAC;CACzD;CAEA,YAAgC;EAC9B,OAAO,KAAK,YAAa,KAAK,IAAY,QAAQ;CACpD;CAEA,kBAAsC;EACpC,OAAO,KAAK,YAAa,KAAK,IAAY,MAAM;CAClD;CAEA,YAAoB,GAA+C;EACjE,IAAI,CAACC,GAAQ,OAAO;EACpB,IAAMC,IAAQD,EAAO,QAAQ,OACvBE,IAAMF,EAAO,QAAQ;EAC3B,OAAO;GAAE,SAAS,KAAK,OAAO,MAAMC,GAAOC,CAAG;GAAG;GAAO;EAAI;CAC9D;CAMA,aAAa,GAA0C;EACrD,OAAO,KAAK,kBAAkB,KAAK,UAAU,GAAGC,CAAE;CACpD;CAEA,mBAAmB,GAA0C;EAC3D,OAAO,KAAK,kBAAkB,KAAK,gBAAgB,GAAGA,CAAE;CAC1D;CAEA,kBACE,GACA,GACS;EACT,IAAI,CAACC,GAAO,OAAO;EACnB,IAAMC,IAAOF,EAAGC,EAAM,OAAO;EAG7B,OAFIC,MAASD,EAAM,YACnB,KAAK,EAAE,UAAUA,EAAM,OAAOA,EAAM,KAAKC,CAAI,GACtC;CACT;CAGA,YAAY,GAAiC;EAC3C,OAAOC,EACJ,KAAK,IAAY,WACjB,OACEC,EAAK,SAAS,eAAeA,EAAK,SAAS,qBAC5CA,EAAK,SAASC,CAClB;CACF;CAEA,WAAW,GAAuB;EAChC,OAAO,KAAK,YAAYA,CAAI,MAAM;CACpC;CAEA,aAAa,GAA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ACA,GACY;CACZ,IAAMgC,oBAAO,IAAI,QAAgB;CACjC,SAASC,EAAM,GAA2B;EACxC,IAAI,CAAChC,KAAQ,OAAOA,KAAS,YAAY+B,EAAK,IAAI/B,CAAc,GAC9D,OAAO;EAGT,IADA+B,EAAK,IAAI/B,CAAc,GACnBiC,EAAUjC,CAAW,GAAG,OAAOA;EACnC,KAAK,IAAMkC,KAAO,OAAO,KAAKlC,CAA+B,GAAG;GAC9D,IAAIkC,MAAQ,UAAU;GACtB,IAAMvB,IAASX,EAAiCkC;GAChD,IAAI,MAAM,QAAQvB,CAAK,GACrB,KAAK,IAAMwB,KAAQxB,GAAO;IACxB,IAAMyB,IAAQJ,EAAMG,CAAI;IACxB,IAAIC,GAAO,OAAOA;GACpB;QACK,IACLzB,KACA,OAAOA,KAAU,YACjB,UAAWA,GACX;IACA,IAAMyB,IAAQJ,EAAMrB,CAAK;IACzB,IAAIyB,GAAO,OAAOA;GACpB;EACF;EACA,OAAO;CACT;CACA,OAAOJ,EAAMK,CAAI;AACnB"}
1
+ {"version":3,"file":"svelte-file-DfplF3BU.js","names":["fs","MagicString","SvelteFile","source","parse","filePath","script","start","end","fn","block","next","findNode","node","name","componentName","attr","attrName","closingTag","closingPos","content","newContent","isElement","outer","child","inner","candidate","indent","lineStart","pos","lead","unit","nested","line","tabs","i","nodes","index","trimmed","prev","last","insertAt","attrs","a","seen","visit","predicate","key","item","found","root"],"sources":["../../src/runtime/svelte-file.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { parse, type AST } from \"svelte/compiler\";\nimport MagicString from \"magic-string\";\n\ntype SvelteAst = AST.Root;\ntype SvelteNode = any;\n\ninterface ScriptBlock {\n content: string;\n start: number;\n end: number;\n}\n\n/**\n * Surgical, AST-aware editing of .svelte files.\n *\n * Parses the source with svelte/compiler to discover precise character offsets,\n * then applies edits via magic-string so untouched regions remain byte-for-byte\n * identical to the original. Script-block contents are exposed as plain strings\n * so callers can hand them to ts-morph.\n */\nexport class SvelteFile {\n private readonly source: string;\n private readonly ast: SvelteAst;\n private readonly s: MagicString;\n\n constructor(source: string) {\n this.source = source;\n this.ast = parse(source, { modern: true });\n this.s = new MagicString(source);\n }\n\n static fromPath(filePath: string): SvelteFile {\n return new SvelteFile(fs.readFileSync(filePath, \"utf8\"));\n }\n\n getScript(): ScriptBlock | null {\n return this.scriptInner((this.ast as any).instance);\n }\n\n getModuleScript(): ScriptBlock | null {\n return this.scriptInner((this.ast as any).module);\n }\n\n private scriptInner(script: SvelteNode | null): ScriptBlock | null {\n if (!script) return null;\n const start = script.content.start as number;\n const end = script.content.end as number;\n return { content: this.source.slice(start, end), start, end };\n }\n\n /**\n * Replace the inner contents of <script>. Use for ts-morph round-trips.\n * Returns true when an edit was made.\n */\n modifyScript(fn: (content: string) => string): boolean {\n return this.modifyScriptBlock(this.getScript(), fn);\n }\n\n modifyModuleScript(fn: (content: string) => string): boolean {\n return this.modifyScriptBlock(this.getModuleScript(), fn);\n }\n\n private modifyScriptBlock(\n block: ScriptBlock | null,\n fn: (content: string) => string,\n ): boolean {\n if (!block) return false;\n const next = fn(block.content);\n if (next === block.content) return false;\n this.s.overwrite(block.start, block.end, next);\n return true;\n }\n\n /** First Component or RegularElement node with the given name. */\n findElement(name: string): SvelteNode | null {\n return findNode(\n (this.ast as any).fragment,\n (node) =>\n (node.type === \"Component\" || node.type === \"RegularElement\") &&\n node.name === name,\n );\n }\n\n hasElement(name: string): boolean {\n return this.findElement(name) !== null;\n }\n\n hasAttribute(componentName: string, attrName: string): boolean {\n const node = this.findElement(componentName);\n if (!node) return false;\n return (node.attributes ?? []).some(\n (attr: SvelteNode) => attr.type === \"Attribute\" && attr.name === attrName,\n );\n }\n\n /**\n * Insert content at the end of <ComponentName>'s children, just before the\n * closing tag. No-op if the element is not found.\n */\n insertBeforeClosingTag(name: string, content: string): boolean {\n const node = this.findElement(name);\n if (!node) return false;\n const closingTag = `</${name}>`;\n const closingPos = this.source.lastIndexOf(closingTag, node.end);\n if (closingPos === -1) return false;\n this.s.appendLeft(closingPos, content);\n return true;\n }\n\n /** Replace the element entirely (start tag through close tag). */\n replaceElement(name: string, newContent: string): boolean {\n const node = this.findElement(name);\n if (!node) return false;\n this.s.overwrite(node.start, node.end, newContent);\n return true;\n }\n\n /** Remove the element (start tag through close tag). */\n removeElement(name: string): boolean {\n return this.replaceElement(name, \"\");\n }\n\n /**\n * The first <outer> element with an <inner> element somewhere inside it:\n * the `Navbar.Item` that holds `AuthMenu.Root`, among several items.\n */\n findElementContaining(outer: string, inner: string): SvelteNode | null {\n return findNode(\n (this.ast as any).fragment,\n (node) =>\n isElement(node, outer) &&\n findNode(node.fragment, (child) => isElement(child, inner)) !== null,\n );\n }\n\n /** The <child> elements directly inside the first <name> element, in order. */\n childElements(name: string, child: string): SvelteNode[] {\n const node = this.findElement(name);\n const nodes: SvelteNode[] = node?.fragment?.nodes ?? [];\n return nodes.filter((candidate) => isElement(candidate, child));\n }\n\n /**\n * Put `content` on its own line directly before `node`, at `node`'s\n * indentation. Lines after the first are indented to match too, with their\n * leading tabs turned into the file's indent unit.\n */\n insertBeforeElement(node: SvelteNode, content: string): void {\n const indent = this.indentOf(node.start as number);\n this.s.appendLeft(\n node.start as number,\n `${this.reindent(content, indent)}\\n${indent}`,\n );\n }\n\n /** Like `insertBeforeElement`, on the line after `node`. */\n insertAfterElement(node: SvelteNode, content: string): void {\n const indent = this.indentOf(node.start as number);\n this.s.appendLeft(\n node.end as number,\n `\\n${indent}${this.reindent(content, indent)}`,\n );\n }\n\n /**\n * Remove the first <outer> containing <inner>, and the line it stood on\n * when nothing else shared it. Returns false when there is none.\n */\n removeElementContaining(outer: string, inner: string): boolean {\n const node = this.findElementContaining(outer, inner);\n if (!node) return false;\n let start = node.start as number;\n while (start > 0 && /[ \\t]/.test(this.source[start - 1]!)) start--;\n if (start > 0 && this.source[start - 1] === \"\\n\") start--;\n this.s.remove(start, node.end as number);\n return true;\n }\n\n /** The whitespace between the start of `pos`'s line and `pos`. */\n private indentOf(pos: number): string {\n const lineStart = this.source.lastIndexOf(\"\\n\", pos - 1) + 1;\n const lead = this.source.slice(lineStart, pos);\n return /^[ \\t]*$/.test(lead) ? lead : \"\";\n }\n\n private reindent(content: string, indent: string): string {\n const unit = indent.includes(\" \") ? \" \" : \"\\t\";\n return content\n .split(\"\\n\")\n .map((line, i) => {\n const nested = line.replace(/^\\t+/, (tabs) => unit.repeat(tabs.length));\n return i === 0 ? nested : `${indent}${nested}`;\n })\n .join(\"\\n\");\n }\n\n /** Append raw markup to the end of the source file. */\n appendMarkup(content: string): void {\n this.s.append(content);\n }\n\n /**\n * Insert markup so it renders before the layout's children — i.e. ahead of\n * the top-level `{@render children()}` (or legacy `<slot />`). The markup\n * lands on its own line directly after the preceding sibling, so\n *\n * <Toaster />\n *\n * {@render children?.()}\n *\n * becomes `<Toaster />\\n<AdminBar />\\n\\n{@render children?.()}`. When the\n * render tag is the first node the markup goes immediately before it.\n * Returns false (and changes nothing) if no such tag exists.\n */\n insertBeforeChildren(content: string): boolean {\n const nodes: SvelteNode[] = (this.ast as any).fragment?.nodes ?? [];\n const index = nodes.findIndex(\n (node) =>\n node.type === \"RenderTag\" ||\n node.type === \"SlotElement\" ||\n (node.type === \"RegularElement\" && node.name === \"slot\"),\n );\n if (index === -1) return false;\n\n const trimmed = content.trim();\n for (let i = index - 1; i >= 0; i--) {\n const prev = nodes[i]!;\n if (prev.type === \"Text\" && prev.data.trim() === \"\") continue;\n this.s.appendLeft(prev.end as number, `\\n${trimmed}`);\n return true;\n }\n this.s.appendLeft(nodes[index]!.start as number, `${trimmed}\\n\\n`);\n return true;\n }\n\n /**\n * Append attribute text (e.g. \" team={data.team}\") just after the last\n * existing attribute on the element's start tag.\n */\n appendToAttributes(name: string, attrs: string): boolean {\n const node = this.findElement(name);\n if (!node) return false;\n const last = (node.attributes ?? []).at(-1) as SvelteNode | undefined;\n const insertAt = last\n ? (last.end as number)\n : (node.start as number) + `<${name}`.length;\n this.s.appendLeft(insertAt, attrs);\n return true;\n }\n\n /**\n * Remove a named attribute from a component's start tag, including the\n * leading whitespace. No-op if the element or attribute isn't present.\n */\n removeAttribute(name: string, attrName: string): boolean {\n const node = this.findElement(name);\n if (!node) return false;\n const attr = (node.attributes ?? []).find(\n (a: SvelteNode) => a.type === \"Attribute\" && a.name === attrName,\n );\n if (!attr) return false;\n // Extend the removal backwards over the whitespace between the previous\n // token and this attribute so the tag doesn't collapse `<Foo />`.\n let start = attr.start as number;\n while (start > 0 && /\\s/.test(this.source[start - 1]!)) start--;\n this.s.remove(start, attr.end as number);\n return true;\n }\n\n hasChanged(): boolean {\n return this.s.hasChanged();\n }\n\n toString(): string {\n return this.s.toString();\n }\n\n writeTo(filePath: string): void {\n if (this.hasChanged()) {\n fs.writeFileSync(filePath, this.toString(), \"utf8\");\n }\n }\n}\n\nfunction isElement(node: any, name: string): boolean {\n return (\n (node?.type === \"Component\" || node?.type === \"RegularElement\") &&\n node.name === name\n );\n}\n\nfunction findNode(\n root: unknown,\n predicate: (node: any) => boolean,\n): any | null {\n const seen = new WeakSet<object>();\n function visit(node: unknown): any | null {\n if (!node || typeof node !== \"object\" || seen.has(node as object)) {\n return null;\n }\n seen.add(node as object);\n if (predicate(node as any)) return node;\n for (const key of Object.keys(node as Record<string, unknown>)) {\n if (key === \"parent\") continue;\n const child = (node as Record<string, unknown>)[key];\n if (Array.isArray(child)) {\n for (const item of child) {\n const found = visit(item);\n if (found) return found;\n }\n } else if (\n child &&\n typeof child === \"object\" &&\n \"type\" in (child as object)\n ) {\n const found = visit(child);\n if (found) return found;\n }\n }\n return null;\n }\n return visit(root);\n}\n"],"mappings":";;;;AAqBA,IAAaE,IAAb,MAAaA,EAAW;CAKtB,YAAY,GAAgB;EAG1B,AAFA,KAAK,SAASC,GACd,KAAK,MAAMC,EAAMD,GAAQ,EAAE,QAAQ,GAAK,CAAC,GACzC,KAAK,IAAI,IAAIF,EAAYE,CAAM;CACjC;CAEA,OAAO,SAAS,GAA8B;EAC5C,OAAO,IAAID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