@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 +0,0 @@
1
- {"version":3,"file":"generate.runtime-Brakd35X.js","names":["dedent","getLogger","withInMemoryScript","modifyOutcomeToFile","SvelteFile","fs","path","CART_BUTTON_MODULE","CART_NAVBAR_ITEM","IMPORT_SNIPPET","FAILURE_HINT","NOT_FOUND_HINT","modifyRootLayoutSvelte","layoutPath","file","out","source","sf","authItem","items","lastItem","hasStripeCustomer","root","generate","logger","options","modifies"],"sources":["../../src/patterns/enable/ecommerce/modifies/root-layout.svelte.ts","../../src/patterns/enable/ecommerce/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n ensureImports,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport const CART_BUTTON_MODULE = \"#lib/components/cart/cart-button.svelte\";\n\nconst CART_NAVBAR_ITEM = \"<Navbar.Item>\\n\\t<CartButton />\\n</Navbar.Item>\";\n\nconst IMPORT_SNIPPET = `import CartButton from '${CART_BUTTON_MODULE}';`;\n\nconst FAILURE_HINT = dedent`\n Add the cart button inside your <Navbar.List> in the root layout.\n\n Import to add to the <script> tag:\n\n ${IMPORT_SNIPPET}\n\n Markup to add inside <Navbar.List>:\n\n ${CART_NAVBAR_ITEM}\n`;\n\nconst NOT_FOUND_HINT = dedent`\n Add the cart button to the layout your public pages share.\n\n Import for the <script> tag:\n\n ${IMPORT_SNIPPET}\n\n Markup, wherever your navigation is:\n\n <CartButton />\n`;\n\n/**\n * Puts the cart button in the navbar: left of the account menu when auth\n * added one, else after the last item.\n */\nexport function modifyRootLayoutSvelte(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const file = SvelteFile.fromPath(layoutPath);\n if (!file.hasElement(\"Navbar.List\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n if (file.hasElement(\"CartButton\")) {\n return { status: \"success\", changed: false };\n }\n\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n ensureImports(sf, [\n { defaultImport: \"CartButton\", moduleSpecifier: CART_BUTTON_MODULE },\n ]);\n });\n return out;\n });\n\n const authItem = file.findElementContaining(\"Navbar.Item\", \"AuthMenu.Root\");\n const items = file.childElements(\"Navbar.List\", \"Navbar.Item\");\n const lastItem = items[items.length - 1];\n if (authItem) {\n file.insertBeforeElement(authItem, CART_NAVBAR_ITEM);\n } else if (lastItem) {\n file.insertAfterElement(lastItem, CART_NAVBAR_ITEM);\n } else {\n file.insertBeforeClosingTag(\n \"Navbar.List\",\n `\\n\\t\\t${CART_NAVBAR_ITEM.replace(/\\n/g, \"\\n\\t\\t\")}\\n\\t`,\n );\n }\n\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { modifyRootLayoutSvelte } from \"./modifies/root-layout.svelte\";\n\n/** Created by enable-payments for Stripe when auth was already on. */\nexport function hasStripeCustomer(root: string): boolean {\n return fs.existsSync(\n path.join(root, \"src\", \"lib\", \"server\", \"stripe-customer.ts\"),\n );\n}\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n\n logger.info(\"Adding the cart to the navbar\");\n const layoutPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(public)\",\n \"root-layout.svelte\",\n );\n const file = modifyOutcomeToFile(\n layoutPath,\n modifyRootLayoutSvelte(layoutPath),\n );\n if (file) modifies.push(file);\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;AASA,IAAaO,IAAqB,2CAE5BC,IAAmB,kDAEnBC,IAAiB,2BAA2BF,EAAmB,KAE/DG,IAAe,CAAM;;;;;IAKvBD,EAAe;;;;IAIfD,EAAiB;GAGfG,IAAiB,CAAM;;;;;IAKzBF,EAAe;;;;;;AAWnB,SAAgBG,EAAuB,GAAmC;CACxE,IAAI,CAACP,EAAG,WAAWQ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EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"generate.runtime-Bx_CaBZD.js","names":["FAILURE_HINT","I18N_MODULES","FAILURE_HINT","libModule","withInMemoryScript","pruneUnusedImports","removeNamedImportIfUnused","removeTopLevelStatementByIdentifier","removeStatementWithComments","ensureBlankLineAfterImports","formatLikeSource","isEffectivelyEmpty","removeImportByModuleSpecifier","revertOutcomeToFile","modifyOutcomeToFile","SvelteFile","removeHandle","probeFirstExisting","resolveConfigTarget","saveTarget","VITE_CONFIG_CANDIDATES","removePackageImports","LOCALES_IMPORTS","LOAD_STATEMENT","fs","path","unmodifyGitignore","gitignorePath","original","lines","out","i","line","j","hasWuchale","updated","unmodifyViteConfig","viteConfigPath","sourceFile","Project","QuoteKind","removed","arr","SyntaxKind","index","el","HINTS","unmodifyLocalesAlias","res","root","aliasProp","target","aliasObj","locales","p","localesModule","escaped","name","pattern","specifier","I18N_HANDLE","FAILURE_HINT$2","I18N_MODULES$1","unmodifyHooksServerI18n","hooksServerPath","stmt","s","moduleSpecifier","DELOCALIZE_HELPER","FAILURE_HINT$1","I18N_MODULES","I18N_ONLY_REROUTE","COMPOSED_REROUTE","unmodifyHooksI18n","hooksPath","helperStatement","rerouteDecl","initText","composed","rerouteStatement","unmodifyAppHtml","appHtmlPath","FAILURE_HINT","SIDE_EFFECT_MODULES","BINDING_MODULES","normalize","source","unmodifyRootLayoutI18n","layoutPath","loadStatement","d","unmodifyRootLayoutLanguageSelect","file","sf","generate","logger","getLogger","options","modifies","deletes","pushResult","imports","alias","hooksServerRevert","hooksRevert","layoutRevert","rootLayoutCandidates","candidate"],"sources":["../../src/patterns/disable/i18n/modifies/gitignore.ts","../../src/patterns/disable/i18n/modifies/vite-config.ts","../../src/patterns/disable/i18n/modifies/locales-alias.ts","../../src/patterns/disable/i18n/modifies/locales-module.ts","../../src/patterns/disable/i18n/modifies/hooks.server.ts","../../src/patterns/disable/i18n/modifies/hooks.ts","../../src/patterns/disable/i18n/modifies/app-html.ts","../../src/patterns/disable/i18n/modifies/+layout.ts","../../src/patterns/disable/i18n/modifies/root-layout.svelte.ts","../../src/patterns/disable/i18n/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyGitignore(gitignorePath: string): ModifyOutcome {\n if (!fs.existsSync(gitignorePath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(gitignorePath, \"utf8\");\n if (!original.includes(\"src/locales/.wuchale\")) {\n return { status: \"success\", changed: false };\n }\n\n const lines = original.split(\"\\n\");\n const out: string[] = [];\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i];\n if (line === \"# Wuchale\") {\n let j = i + 1;\n let hasWuchale = false;\n while (j < lines.length && lines[j].trim() !== \"\") {\n if (lines[j] === \"src/locales/.wuchale\") {\n hasWuchale = true;\n }\n j++;\n }\n if (hasWuchale) {\n i = j;\n continue;\n }\n }\n if (line === \"src/locales/.wuchale\") continue;\n out.push(line);\n }\n\n let updated = out.join(\"\\n\");\n updated = updated.replace(/\\n{3,}/g, \"\\n\\n\");\n\n if (updated === original) {\n return { status: \"success\", changed: false };\n }\n\n fs.writeFileSync(gitignorePath, updated);\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport { Project, QuoteKind, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport {\n removeImportByModuleSpecifier,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\n\n/** Remove `wuchale()` from the Vite plugins and its import. */\nexport function unmodifyViteConfig(viteConfigPath: string): ModifyOutcome {\n if (!fs.existsSync(viteConfigPath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(viteConfigPath, \"utf8\");\n if (!original.includes(\"wuchale\")) {\n return { status: \"success\", changed: false };\n }\n\n const project = new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(viteConfigPath);\n\n // One removal at a time: manipulating the tree invalidates sibling nodes.\n for (;;) {\n let removed = false;\n for (const arr of sourceFile.getDescendantsOfKind(\n SyntaxKind.ArrayLiteralExpression,\n )) {\n const index = arr\n .getElements()\n .findIndex((el) => el.getText().replace(/\\s/g, \"\") === \"wuchale()\");\n if (index >= 0) {\n arr.removeElement(index);\n removed = true;\n break;\n }\n }\n if (!removed) break;\n }\n\n removeImportByModuleSpecifier(sourceFile, \"wuchale/vite\");\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== original,\n };\n}\n","import { SyntaxKind } from \"ts-morph\";\nimport {\n resolveConfigTarget,\n saveTarget,\n type ConfigModifyResult,\n} from \"../../../../runtime/config-target\";\n\nconst HINTS = {\n notFound: \"No SvelteKit config to revert.\",\n failed:\n \"Remove the $locales alias from the sveltekit() arg in vite.config by hand.\",\n};\n\n/**\n * Remove the `$locales` alias enable-i18n wrote before SvelteKit 3, which\n * `sv migrate sveltekit-3` moves into the inline `sveltekit({...})` arg;\n * `alias` goes too once it is empty. Projects enabled since then map\n * `#locales/*` in package.json `imports` instead.\n */\nexport function unmodifyLocalesAlias(root: string): ConfigModifyResult {\n const res = resolveConfigTarget(root, HINTS);\n // Nothing to revert in a project without a config.\n if (res.status === \"not-found\") {\n return {\n filePath: res.filePath,\n outcome: { status: \"success\", changed: false },\n };\n }\n if (res.status === \"failed\") {\n return {\n filePath: res.filePath,\n outcome: { status: \"failed\", message: res.message },\n };\n }\n\n const { target } = res;\n const aliasProp = target.configObject\n .getProperty(\"alias\")\n ?.asKind(SyntaxKind.PropertyAssignment);\n const aliasObj = aliasProp\n ?.getInitializer()\n ?.asKind(SyntaxKind.ObjectLiteralExpression);\n const locales = aliasObj\n ?.getProperties()\n .find((p) => p.getText().replace(/['\"]/g, \"\").startsWith(\"$locales\"));\n if (aliasProp && aliasObj && locales) {\n locales.remove();\n if (aliasObj.getProperties().length === 0) aliasProp.remove();\n }\n return { filePath: target.filePath, outcome: saveTarget(target) };\n}\n","/**\n * Matches an import of wuchale's `src/locales/<name>.js` the way enable-i18n\n * writes it (`#locales/main.url.js`), and the `$locales/main.url` alias form\n * it wrote before SvelteKit 3, so disabling works on either.\n */\nexport function localesModule(name: string): (specifier: string) => boolean {\n const escaped = name.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n const pattern = new RegExp(`^[$#]locales/${escaped}(\\\\.js)?$`);\n return (specifier) => pattern.test(specifier);\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Project, QuoteKind, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { removeHandle } from \"../../../../runtime/compose-handle\";\nimport {\n ensureBlankLineAfterImports,\n removeImportByModuleSpecifier,\n removeNamedImportIfUnused,\n removeTopLevelStatementByIdentifier,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport { localesModule } from \"./locales-module\";\n\nconst I18N_HANDLE = \"handleWuchale\";\nconst FAILURE_HINT = dedent`\n Take handleWuchale out of the exported handle in src/hooks.server.ts, then\n remove its declaration, the loadLocales(...) calls and the wuchale and\n #locales imports.\n`;\n\nconst I18N_MODULES = [\n \"wuchale/load-utils/server\",\n localesModule(\"main.url\"),\n localesModule(\"data\"),\n localesModule(\"main.loader.server.svelte\"),\n localesModule(\"js.loader.server\"),\n];\n\n/**\n * Undo `modifyHooksServerI18n`: drop the locale bootstrap, the wuchale handle\n * and its imports, and unwrap `sequence(handleWuchale, ...)`. A file that\n * enable-i18n created comes out empty, for the caller to delete.\n */\nexport function unmodifyHooksServerI18n(\n hooksServerPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(hooksServerPath, \"utf8\");\n if (!original.includes(I18N_HANDLE) && !original.includes(\"loadLocales(\")) {\n return { status: \"success\", changed: false };\n }\n\n const project = new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n // loadLocales(...) bootstrap calls, one at a time (removal invalidates siblings).\n for (;;) {\n const stmt = sourceFile\n .getStatements()\n .find(\n (s) =>\n s.getKind() === SyntaxKind.ExpressionStatement &&\n /^loadLocales\\s*\\(/.test(s.getText()),\n );\n if (!stmt) break;\n stmt.remove();\n }\n\n // `export const handle = handleWuchale` goes altogether; a sequence loses\n // the argument, or unwraps to the handle it composed with.\n const removed = removeHandle(sourceFile, I18N_HANDLE);\n if (removed.status === \"unsupported\") {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n removeTopLevelStatementByIdentifier(sourceFile, I18N_HANDLE);\n for (const moduleSpecifier of I18N_MODULES) {\n removeImportByModuleSpecifier(sourceFile, moduleSpecifier);\n }\n removeNamedImportIfUnused(sourceFile, \"@sveltejs/kit/hooks\", \"sequence\");\n removeNamedImportIfUnused(sourceFile, \"@sveltejs/kit/hooks\", \"Handle\");\n // A project from before SvelteKit 3 imports it from the package root.\n removeNamedImportIfUnused(sourceFile, \"@sveltejs/kit\", \"Handle\");\n\n formatLikeSource(sourceFile);\n ensureBlankLineAfterImports(sourceFile);\n sourceFile.saveSync();\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== original,\n };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Project, QuoteKind, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport {\n ensureBlankLineAfterImports,\n isEffectivelyEmpty,\n pruneUnusedImports,\n removeTopLevelStatementByIdentifier,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport { localesModule } from \"./locales-module\";\n\nconst DELOCALIZE_HELPER = \"rerouteDeLocalize\";\n\nconst FAILURE_HINT = dedent`\n Take rerouteDeLocalize out of the exported reroute in src/hooks.ts, then\n remove its declaration and the wuchale and #locales imports.\n`;\n\nconst I18N_MODULES = [\n \"wuchale/url\",\n localesModule(\"main.url\"),\n localesModule(\"data\"),\n];\n\n/** The two reroutes `modifyHooksI18n` writes: on its own, and composed. */\nconst I18N_ONLY_REROUTE =\n /^\\(\\s*\\{\\s*url\\s*\\}\\s*\\)\\s*=>\\s*rerouteDeLocalize\\(\\s*url\\.pathname\\s*\\)$/;\nconst COMPOSED_REROUTE =\n /^\\(\\s*\\{\\s*url\\s*\\}\\s*\\)\\s*=>\\s*rerouteDeLocalize\\(\\s*negotiateReroute\\(\\s*url\\.pathname\\s*\\)\\s*\\)$/;\n\n/**\n * Undo `modifyHooksI18n`: drop the de-localizer and its imports, leaving the\n * negotiation reroute it may have been composed with. A file that enable-i18n\n * created comes out empty, for the caller to delete.\n */\nexport function unmodifyHooksI18n(hooksPath: string): ModifyOutcome {\n if (!fs.existsSync(hooksPath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(hooksPath, \"utf8\");\n if (!original.includes(DELOCALIZE_HELPER)) {\n return { status: \"success\", changed: false };\n }\n\n const project = new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(hooksPath);\n\n const helperStatement = sourceFile\n .getVariableDeclaration(DELOCALIZE_HELPER)\n ?.getFirstAncestorByKind(SyntaxKind.VariableStatement);\n\n const rerouteDecl = sourceFile.getVariableDeclaration(\"reroute\");\n const initText = rerouteDecl?.getInitializer()?.getText() ?? \"\";\n const composed = COMPOSED_REROUTE.test(initText);\n const rerouteStatement =\n composed || I18N_ONLY_REROUTE.test(initText)\n ? rerouteDecl?.getFirstAncestorByKind(SyntaxKind.VariableStatement)\n : undefined;\n\n // Anything else reading the de-localizer is code enable-i18n did not write,\n // so undoing it is the developer's call.\n const otherReaders = sourceFile\n .getStatements()\n .filter(\n (s) =>\n s !== helperStatement &&\n s !== rerouteStatement &&\n s.getText().includes(DELOCALIZE_HELPER),\n );\n if (otherReaders.length > 0) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n if (composed) {\n // content-negotiation's reroute is underneath; it stays.\n rerouteDecl?.setInitializer(\"({ url }) => negotiateReroute(url.pathname)\");\n } else if (rerouteStatement) {\n removeTopLevelStatementByIdentifier(sourceFile, \"reroute\");\n }\n\n removeTopLevelStatementByIdentifier(sourceFile, DELOCALIZE_HELPER);\n pruneUnusedImports(sourceFile, I18N_MODULES);\n\n if (isEffectivelyEmpty(sourceFile)) {\n // Emptied rather than removed: the runtime turns an empty hooks.ts into a\n // delete entry, so the removal is written and reported like any other.\n fs.writeFileSync(hooksPath, \"\", \"utf8\");\n return { status: \"success\", changed: true };\n }\n\n formatLikeSource(sourceFile);\n ensureBlankLineAfterImports(sourceFile);\n sourceFile.saveSync();\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== original,\n };\n}\n","import fs from \"node:fs\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\n/**\n * Put a real language back. `%sveltekit.lang%` is not a SvelteKit\n * placeholder; only the wuchale hook replaced it, so without that hook it\n * would be served literally.\n */\nexport function unmodifyAppHtml(appHtmlPath: string): ModifyOutcome {\n if (!fs.existsSync(appHtmlPath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(appHtmlPath, \"utf8\");\n const updated = original.replace(\n /lang\\s*=\\s*(?:\"%sveltekit\\.lang%\"|'%sveltekit\\.lang%')/g,\n 'lang=\"en\"',\n );\n if (updated === original) {\n return { status: \"success\", changed: false };\n }\n\n fs.writeFileSync(appHtmlPath, updated, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Project, QuoteKind, type Statement } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { LOAD_STATEMENT } from \"../../../enable/i18n/modifies/+layout\";\nimport {\n ensureBlankLineAfterImports,\n isEffectivelyEmpty,\n pruneUnusedImports,\n removeImportByModuleSpecifier,\n removeStatementWithComments,\n formatLikeSource,\n type ModuleMatch,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport { localesModule } from \"./locales-module\";\n\nconst FAILURE_HINT = dedent`\n src/routes/+layout.ts still loads wuchale locales. Remove these from it:\n\n import { browser } from '$app/env';\n import { loadLocale } from 'wuchale/load-utils';\n import { getLocale } from '#locales/main.url.js';\n import '#locales/main.loader.svelte.js';\n import '#locales/js.loader.js';\n\n and the loadLocale(...) call inside load().\n`;\n\nconst SIDE_EFFECT_MODULES = [\n localesModule(\"main.loader.svelte\"),\n localesModule(\"js.loader\"),\n];\nconst BINDING_MODULES: ModuleMatch[] = [\n // `$app/env`, or the module it replaced before SvelteKit 3.\n (specifier) => /^\\$app\\/env(ironment)?$/.test(specifier),\n \"wuchale/load-utils\",\n localesModule(\"main.url\"),\n];\n\nfunction normalize(source: string): string {\n return source.replace(/[\"']/g, \"'\").replace(/\\s+/g, \"\");\n}\n\n/**\n * Undo `ensureRootLayoutI18n`: drop the wuchale load and its imports, leaving\n * whatever else the file holds. A file enable-i18n wrote whole comes out\n * empty, for the caller to delete.\n */\nexport function unmodifyRootLayoutI18n(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(layoutPath, \"utf8\");\n if (!original.includes(\"loadLocale\") && !/[$#]locales\\//.test(original)) {\n return { status: \"success\", changed: false };\n }\n\n const project = new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(layoutPath);\n\n const loadStatement: Statement | undefined =\n sourceFile\n .getVariableStatements()\n .find((s) => s.getDeclarations().some((d) => d.getName() === \"load\")) ??\n sourceFile.getFunction(\"load\");\n\n if (loadStatement) {\n // A load that grew code of its own needs a hand; only the one enable-i18n\n // wrote is safe to take out wholesale.\n if (normalize(loadStatement.getText()) !== normalize(LOAD_STATEMENT)) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n removeStatementWithComments(sourceFile, loadStatement);\n }\n\n for (const moduleSpecifier of SIDE_EFFECT_MODULES) {\n removeImportByModuleSpecifier(sourceFile, moduleSpecifier);\n }\n pruneUnusedImports(sourceFile, BINDING_MODULES);\n\n if (isEffectivelyEmpty(sourceFile)) {\n // Emptied rather than removed: the runtime turns an empty +layout.ts into\n // a delete entry, so the removal is written and reported like any other.\n fs.writeFileSync(layoutPath, \"\", \"utf8\");\n return { status: \"success\", changed: true };\n }\n\n formatLikeSource(sourceFile);\n ensureBlankLineAfterImports(sourceFile);\n sourceFile.saveSync();\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== original,\n };\n}\n","import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n ensureBlankLineAfterImports,\n removeImportByModuleSpecifier,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { libModule } from \"../../../../runtime/lib-specifier\";\n\n/** Take the language select (and the nav item enable-i18n wrapped it in) back out. */\nexport function unmodifyRootLayoutLanguageSelect(\n layoutPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(layoutPath, \"utf8\");\n if (!original.includes(\"LanguageSelect\")) {\n return { status: \"success\", changed: false };\n }\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/language-select.svelte\"),\n );\n ensureBlankLineAfterImports(sf);\n });\n return out;\n });\n\n let updated = file.toString();\n updated = updated.replace(\n /[ \\t]*<Navbar\\.Item>\\s*<LanguageSelect\\s*\\/>\\s*<\\/Navbar\\.Item>[ \\t]*\\r?\\n?/g,\n \"\",\n );\n updated = updated.replace(/[ \\t]*<LanguageSelect\\s*\\/>[ \\t]*\\r?\\n?/g, \"\");\n\n fs.writeFileSync(layoutPath, updated, \"utf8\");\n return { status: \"success\", changed: updated !== original };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport {\n modifyOutcomeToFile,\n revertOutcomeToFile,\n} from \"../../../runtime/modify-file\";\nimport {\n probeFirstExisting,\n VITE_CONFIG_CANDIDATES,\n} from \"../../../runtime/config-target\";\nimport { unmodifyGitignore } from \"./modifies/gitignore\";\nimport { unmodifyViteConfig } from \"./modifies/vite-config\";\nimport { unmodifyLocalesAlias } from \"./modifies/locales-alias\";\nimport { removePackageImports } from \"../../../runtime/package-imports\";\nimport { LOCALES_IMPORTS } from \"../../enable/i18n/modifies/package-imports\";\nimport { unmodifyHooksServerI18n } from \"./modifies/hooks.server\";\nimport { unmodifyHooksI18n } from \"./modifies/hooks\";\nimport { unmodifyAppHtml } from \"./modifies/app-html\";\nimport { unmodifyRootLayoutI18n } from \"./modifies/+layout\";\nimport { unmodifyRootLayoutLanguageSelect } from \"./modifies/root-layout.svelte\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n const deletes: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Reverting vite.config\");\n const viteConfigPath =\n probeFirstExisting(options.root, VITE_CONFIG_CANDIDATES) ??\n path.join(options.root, VITE_CONFIG_CANDIDATES[0]);\n pushResult(\n modifyOutcomeToFile(viteConfigPath, unmodifyViteConfig(viteConfigPath)),\n );\n\n logger.info(\"Removing #locales from package.json imports\");\n // Only while it still maps where enable-i18n pointed it.\n const imports = removePackageImports(\n options.root,\n Object.keys(LOCALES_IMPORTS),\n LOCALES_IMPORTS,\n );\n pushResult(modifyOutcomeToFile(imports.filePath, imports.outcome));\n\n // A project enabled before SvelteKit 3 has the `$locales` alias instead,\n // moved into the sveltekit() arg by `vela migrate sveltekit-3`.\n logger.info(\"Reverting the legacy $locales alias\");\n const alias = unmodifyLocalesAlias(options.root);\n pushResult(modifyOutcomeToFile(alias.filePath, alias.outcome));\n\n logger.info(\"Reverting hooks.server.ts\");\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n // enable-i18n may have created it; emptied, it goes.\n const hooksServerRevert = revertOutcomeToFile(\n hooksServerPath,\n unmodifyHooksServerI18n(hooksServerPath),\n );\n pushResult(hooksServerRevert.modify);\n if (hooksServerRevert.delete) deletes.push(hooksServerRevert.delete);\n\n logger.info(\"Reverting hooks.ts\");\n const hooksPath = path.join(options.root, \"src\", \"hooks.ts\");\n // The de-localizing reroute may be all it holds; emptied, it goes.\n const hooksRevert = revertOutcomeToFile(\n hooksPath,\n unmodifyHooksI18n(hooksPath),\n );\n pushResult(hooksRevert.modify);\n if (hooksRevert.delete) deletes.push(hooksRevert.delete);\n\n logger.info(\"Reverting app.html\");\n const appHtmlPath = path.join(options.root, \"src\", \"app.html\");\n pushResult(modifyOutcomeToFile(appHtmlPath, unmodifyAppHtml(appHtmlPath)));\n\n logger.info(\"Reverting root +layout.ts\");\n const layoutPath = path.join(options.root, \"src\", \"routes\", \"+layout.ts\");\n // enable-i18n may have written the whole file; emptied, it goes.\n const layoutRevert = revertOutcomeToFile(\n layoutPath,\n unmodifyRootLayoutI18n(layoutPath),\n );\n pushResult(layoutRevert.modify);\n if (layoutRevert.delete) deletes.push(layoutRevert.delete);\n\n logger.info(\"Reverting root layout language select\");\n const rootLayoutCandidates = [\n path.join(options.root, \"src\", \"routes\", \"(public)\", \"root-layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"root-layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"(public)\", \"+layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"+layout.svelte\"),\n ];\n for (const candidate of rootLayoutCandidates) {\n if (!fs.existsSync(candidate)) continue;\n pushResult(\n modifyOutcomeToFile(\n candidate,\n unmodifyRootLayoutLanguageSelect(candidate),\n ),\n );\n }\n\n logger.info(\"Reverting .gitignore\");\n const gitignorePath = path.join(options.root, \".gitignore\");\n pushResult(\n modifyOutcomeToFile(gitignorePath, unmodifyGitignore(gitignorePath)),\n );\n\n return {\n creates: [],\n modifies,\n deletes,\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;;;;;;AAGA,SAAgB0B,EAAkB,GAAsC;CACtE,IAAI,CAACF,EAAG,WAAWG,CAAa,GAC9B,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAMC,IAAWJ,EAAG,aAAaG,GAAe,MAAM;CACtD,IAAI,CAACC,EAAS,SAAS,sBAAsB,GAC3C,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAMC,IAAQD,EAAS,MAAM,IAAI,GAC3BE,IAAgB,CAAC;CACvB,KAAK,IAAIC,IAAI,GAAGA,IAAIF,EAAM,QAAQ,KAAK;EACrC,IAAMG,IAAOH,EAAME;EACnB,IAAIC,MAAS,aAAa;GACxB,IAAIC,IAAIF,IAAI,GACRG,IAAa;GACjB,OAAOD,IAAIJ,EAAM,UAAUA,EAAMI,EAAE,CAAC,KAAK,MAAM,KAI7C,AAHIJ,EAAMI,OAAO,2BACf,IAAa,KAEf;GAEF,IAAIC,GAAY;IACd,IAAID;IACJ;GACF;EACF;EACA,AAAID,MAAS,0BACbF,EAAI,KAAKE,CAAI;CACf;CAEA,IAAIG,IAAUL,EAAI,KAAK,IAAI;CAQ3B,OAPA,IAAUK,EAAQ,QAAQ,WAAW,MAAM,GAEvCA,MAAYP,IACP;EAAE,QAAQ;EAAW,SAAS;CAAM,KAG7CJ,EAAG,cAAcG,GAAeQ,CAAO,GAChC;EAAE,QAAQ;EAAW,SAAS;CAAK;AAC5C;;;ACnCA,SAAgBC,EAAmB,GAAuC;CACxE,IAAI,CAACZ,EAAG,WA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,GACtB,AAAKlF,EAAG,WAAWmF,CAAS,KAC5BP,EACEtF,EACE6F,GACAhB,EAAiCgB,CAAS,CAC5C,CACF;CAGF,EAAO,KAAK,sBAAsB;CAClC,IAAMhF,IAAgBF,EAAK,KAAKwE,EAAQ,MAAM,YAAY;CAK1D,OAJAG,EACEtF,EAAoBa,GAAeD,EAAkBC,CAAa,CAAC,CACrE,GAEO;EACL,SAAS,CAAC;EACV;EACA;EACA,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
@@ -1,35 +0,0 @@
1
- import { o as e } from "./generate-CtQcmjPM.js";
2
- import { n as t } from "./logger-CQONztPm.js";
3
- import { n } from "./shared-DIDAkVts.js";
4
- import { n as r, r as i, t as a } from "./generate-D21dCU-o.js";
5
- import { n as o } from "./env-BugddEjd.js";
6
- import { t as s } from "./modify-file-DdXJCMHN.js";
7
- import { unmodifyEnvVarsFiles as c } from "./env-vars-CNH-ItSY.js";
8
- import l from "node:fs";
9
- import u from "node:path";
10
- //#region src/patterns/disable/ai/generate.runtime.ts
11
- async function d(d) {
12
- let f = t(d), p = [], m = [], h = e(d);
13
- for (let e of i(d)) {
14
- let t = `${e}/+page.svelte`;
15
- e !== h && l.existsSync(u.join(d.root, t)) && m.push(n(t));
16
- }
17
- f.info("Removing the AI provider's API key from src/env.ts");
18
- let g = c(d.root, r());
19
- g.modify && p.push(g.modify), g.delete && m.push(g.delete), f.info("Removing the AI provider's API key from .env");
20
- let _ = u.join(d.root, ".env"), v = s(_, o(_, a()));
21
- return v.modify && p.push(v.modify), v.delete && m.push(v.delete), {
22
- creates: [],
23
- modifies: p,
24
- deletes: m,
25
- components: [],
26
- packages: [],
27
- collections: [],
28
- collectionPatches: [],
29
- collectionDrops: []
30
- };
31
- }
32
- //#endregion
33
- export { d as generate };
34
-
35
- //# sourceMappingURL=generate.runtime-C8-mjcn8.js.map
@@ -1,50 +0,0 @@
1
- import { n as e } from "./logger-CQONztPm.js";
2
- import { _ as t, n, u as r } from "./ts-morph-helpers-CHI9wAil.js";
3
- import { r as i } from "./modify-file-DdXJCMHN.js";
4
- import { t as a } from "./svelte-file-Dv5-bl79.js";
5
- import { n as o, t as s } from "./layout.svelte-Cb12mxua.js";
6
- import c from "node:fs";
7
- import l from "node:path";
8
- import { Node as u } from "ts-morph";
9
- //#region src/patterns/disable/og/modifies/layout.svelte.ts
10
- function d(e) {
11
- if (!c.existsSync(e)) return {
12
- status: "success",
13
- changed: !1
14
- };
15
- let i = a.fromPath(e);
16
- return i.getScript()?.content.includes("withCard") ? (i.modifyScript((e) => {
17
- let { source: i } = t(e, (e) => {
18
- let t = o(e)?.getArguments()[0];
19
- t && u.isCallExpression(t) && t.getExpression().getText() === "withCard" && t.replaceWithText(t.getArguments()[0].getText()), r(e, s), n(e);
20
- });
21
- return i;
22
- }), i.writeTo(e), {
23
- status: "success",
24
- changed: i.hasChanged()
25
- }) : {
26
- status: "success",
27
- changed: !1
28
- };
29
- }
30
- //#endregion
31
- //#region src/patterns/disable/og/generate.runtime.ts
32
- async function f(t) {
33
- let n = e(t), r = [];
34
- n.info("Reverting src/routes/+layout.svelte");
35
- let a = l.join(t.root, "src", "routes", "+layout.svelte"), o = i(a, d(a));
36
- return o && r.push(o), {
37
- creates: [],
38
- modifies: r,
39
- deletes: [],
40
- components: [],
41
- packages: [],
42
- collections: [],
43
- collectionPatches: [],
44
- collectionDrops: []
45
- };
46
- }
47
- //#endregion
48
- export { f as generate };
49
-
50
- //# sourceMappingURL=generate.runtime-CAO_SpsA.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"generate.runtime-CCE-9xQV.js","names":["FAILURE_HINT","NOT_FOUND_HINT","NOT_FOUND_HINT","FAILURE_HINT","NOT_FOUND_HINT","NOT_FOUND_HINT","NOT_FOUND_HINT","__import_glob__0_0_","__import_glob__0_1_","__import_glob__0_2_","__import_glob__0_3_","__import_glob__0_4_","__import_glob__0_5_","__import_glob__0_6_","stripeCustomerHelper","InvalidArgumentError","stripe_customer_default","_layout_server_default","_layout_default","_page_default","nav_user_default","_page_server_default","app_sidebar_default","dispatch_default","withInMemoryScript","formatLikeSource","ensureImports","keepMissing","modifyOutcomeToFile","SvelteFile","modifyNavUser","fs","path","FAILURE_HINT$2","NOT_FOUND_HINT$5","SUBSCRIPTION_CASES_SNIPPET","modifyWebhookServer","filePath","original","addedCases","sf","switchStmt","SyntaxKind","stmt","clauses","defaultClause","c","prefix","last","source","LOAD_LINE","NOT_FOUND_HINT$4","failureHint","helper","helperFrom","clean","template","start","end","findLoad","varDecl","init","fn","modifyAppLayoutServer","Project","QuoteKind","load","body","block","binding","hasLocals","el","userIndex","s","d","statements","ret","returned","text","writer","FAILURE_HINT$1","NOT_FOUND_HINT$3","modifyAppLayoutSvelte","file","SUBSCRIPTION_TYPE","FAILURE_HINT","NOT_FOUND_HINT$2","updateScript","wasAdded","out","decl","nameNode","pattern","elements","typeNode","intersection","member","lit","propTexts","p","t","elementTexts","insertIdx","modifyAppSidebar","scriptChanged","src","templateChanged","modifyByTemplate","notFoundHint","current","idempotencyMarker","stripped","NOT_FOUND_HINT$1","modifyBillingPageServer","NOT_FOUND_HINT","modifyBillingPageSvelte","STRIPE_CUSTOMER_HELPER","BILLING_PAGE","assertPaymentsAppMode","root","previewRaw","content","relativePath","generate","logger","getLogger","options","modifies","pushResult","webhookServerPath","appLayoutServerPath","appLayoutSveltePath","appSidebarPath","navUserPath","billingPageServerPath","billingPageSveltePath"],"sources":["../../src/patterns/enable/subscriptions/modifies/modify-webhook-server.ts","../../src/patterns/enable/subscriptions/modifies/modify-app-layout-server.ts","../../src/patterns/enable/subscriptions/modifies/modify-app-layout-svelte.ts","../../src/patterns/enable/subscriptions/modifies/modify-app-sidebar.ts","../../src/patterns/enable/subscriptions/modifies/modify-by-template.ts","../../src/patterns/enable/subscriptions/modifies/modify-billing-page-server.ts","../../src/patterns/enable/subscriptions/modifies/modify-billing-page-svelte.ts","../../src/patterns/enable/subscriptions/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { SyntaxKind } from \"ts-morph\";\nimport dedent from \"dedent\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport {\n ensureImports,\n withInMemoryScript,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nconst FAILURE_HINT = dedent`\n Wire the subscription event handlers into src/routes/webhooks/stripe/handlers/dispatch.ts:\n\n Add imports:\n import { handleSubscriptionCreated } from \"./subscription/created\";\n import { handleSubscriptionUpdated } from \"./subscription/updated\";\n import { handleSubscriptionDeleted } from \"./subscription/deleted\";\n\n Add switch cases inside the event.type switch:\n case \"customer.subscription.created\":\n await handleSubscriptionCreated(event.data.object, locals);\n break;\n case \"customer.subscription.updated\":\n await handleSubscriptionUpdated(event.data.object, locals);\n break;\n case \"customer.subscription.deleted\":\n await handleSubscriptionDeleted(event.data.object, locals);\n break;\n`;\n\nconst NOT_FOUND_HINT =\n \"Enable payments first — src/routes/webhooks/stripe/handlers/dispatch.ts is created by enable-payments.\";\n\nconst SUBSCRIPTION_CASES_SNIPPET = dedent`\n case \"customer.subscription.created\":\n await handleSubscriptionCreated(event.data.object, locals);\n break;\n\n case \"customer.subscription.updated\":\n await handleSubscriptionUpdated(event.data.object, locals);\n break;\n\n case \"customer.subscription.deleted\":\n await handleSubscriptionDeleted(event.data.object, locals);\n break;\n`;\n\nexport function modifyWebhookServer(filePath: string): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const original = fs.readFileSync(filePath, \"utf8\");\n if (original.includes(\"handleSubscriptionCreated\")) {\n return { status: \"success\", changed: false };\n }\n\n let addedCases = false;\n const { source } = withInMemoryScript(original, (sf) => {\n ensureImports(sf, [\n {\n namedImports: [\"handleSubscriptionCreated\"],\n moduleSpecifier: \"./subscription/created\",\n },\n {\n namedImports: [\"handleSubscriptionUpdated\"],\n moduleSpecifier: \"./subscription/updated\",\n },\n {\n namedImports: [\"handleSubscriptionDeleted\"],\n moduleSpecifier: \"./subscription/deleted\",\n },\n ]);\n\n const switchStmt = sf\n .getDescendantsOfKind(SyntaxKind.SwitchStatement)\n .find((stmt) => stmt.getExpression().getText().includes(\"event.type\"));\n if (!switchStmt) return;\n\n const caseBlock = switchStmt.getCaseBlock();\n const clauses = caseBlock.getClauses();\n const defaultClause = clauses.find(\n (c) => c.getKind() === SyntaxKind.DefaultClause,\n );\n\n // Prepend subscription cases in front of the default clause, or append\n // before the closing brace of the case block if there's no default.\n const prefix = `${SUBSCRIPTION_CASES_SNIPPET}\\n\\n`;\n if (defaultClause) {\n defaultClause.replaceWithText(prefix + defaultClause.getText());\n } else if (clauses.length > 0) {\n const last = clauses[clauses.length - 1];\n last.replaceWithText(\n last.getText() + `\\n\\n${SUBSCRIPTION_CASES_SNIPPET}`,\n );\n } else {\n return;\n }\n\n formatLikeSource(sf);\n addedCases = true;\n });\n\n if (!addedCases) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n fs.writeFileSync(filePath, source, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport { Project, QuoteKind, SyntaxKind, type SourceFile } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { formatLikeSource } from \"../../../../runtime/ts-morph-helpers\";\n\nconst LOAD_LINE =\n \"const subscription = await loadActiveSubscription(locals, user.id);\";\n\nconst NOT_FOUND_HINT = [\n \"Create src/routes/(app)/+layout.server.ts before enabling subscriptions.\",\n \"Enable auth first — the (app) layout is provided by the velastack-auth baseline.\",\n].join(\"\\n\");\n\nconst failureHint = (helper: string) =>\n [\n \"Could not find the user and the returned object in the (app) layout load.\",\n \"Add the active subscription to it by hand:\",\n \"\",\n helper,\n \"\",\n \"// In load, once `user` is set:\",\n LOAD_LINE,\n \"// ...and return it with the rest:\",\n \"return { ..., subscription };\",\n ].join(\"\\n\");\n\n/**\n * The `loadActiveSubscription` helper, taken from the preview template so the\n * docs and what gets written stay the same.\n */\nfunction helperFrom(template: string): string {\n const clean = template.replace(\n /^[ \\t]*\\/\\/[ \\t]*\\[!code highlight:\\d+\\][ \\t]*\\r?\\n/gm,\n \"\",\n );\n const start = clean.indexOf(\"async function loadActiveSubscription\");\n const end = clean.indexOf(\"\\n}\\n\", start);\n if (start === -1 || end === -1) {\n throw new Error(\"No loadActiveSubscription in the layout template\");\n }\n return clean.slice(start, end + 2);\n}\n\nfunction findLoad(sf: SourceFile) {\n const varDecl = sf.getVariableDeclaration(\"load\");\n if (varDecl?.getVariableStatement()?.hasExportKeyword()) {\n const init = varDecl.getInitializer();\n const fn =\n varDecl.getInitializerIfKind(SyntaxKind.ArrowFunction) ??\n init?.getFirstDescendantByKind(SyntaxKind.ArrowFunction) ??\n init?.getFirstDescendantByKind(SyntaxKind.FunctionExpression);\n if (fn) return { fn, statement: varDecl.getVariableStatement()! };\n }\n const fn = sf.getFunction(\"load\");\n return fn?.isExported() ? { fn, statement: fn } : undefined;\n}\n\n/**\n * Adds the active subscription to the (app) layout's data: the\n * `loadActiveSubscription` helper, a call to it in `load`, and `subscription`\n * in what `load` returns. Edits the file rather than replacing it, so what\n * other patterns put in the load (teams' `team`/`teams`, say) stays.\n */\nexport function modifyAppLayoutServer(\n filePath: string,\n template: string,\n): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n const original = fs.readFileSync(filePath, \"utf8\");\n if (original.includes(\"loadActiveSubscription\")) {\n return { status: \"success\", changed: false };\n }\n\n const helper = helperFrom(template);\n const project = new Project({\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sf = project.addSourceFileAtPath(filePath);\n const load = findLoad(sf);\n const body = load?.fn.getBody();\n if (!load || !body || body.getKind() !== SyntaxKind.Block) {\n return { status: \"failed\", message: failureHint(helper) };\n }\n const block = body.asKindOrThrow(SyntaxKind.Block);\n\n // The call needs `locals` and `user`, and goes before the return.\n const params = load.fn.getParameters();\n const binding = params[0]?.getNameNode();\n const hasLocals =\n binding?.getKind() === SyntaxKind.ObjectBindingPattern &&\n binding\n .asKindOrThrow(SyntaxKind.ObjectBindingPattern)\n .getElements()\n .some((el) => el.getName() === \"locals\");\n const userIndex = block.getStatements().findIndex(\n (s) =>\n s.getKind() === SyntaxKind.VariableStatement &&\n s\n .asKindOrThrow(SyntaxKind.VariableStatement)\n .getDeclarations()\n .some((d) => d.getName() === \"user\"),\n );\n const statements = block.getStatements();\n const ret = [...statements]\n .reverse()\n .find((s) => s.getKind() === SyntaxKind.ReturnStatement)\n ?.asKind(SyntaxKind.ReturnStatement);\n const returned = ret\n ?.getExpression()\n ?.asKind(SyntaxKind.ObjectLiteralExpression);\n if (!hasLocals || userIndex === -1 || !ret || !returned) {\n return { status: \"failed\", message: failureHint(helper) };\n }\n\n block.insertStatements(statements.indexOf(ret), LOAD_LINE);\n if (!returned.getProperty(\"subscription\")) {\n const text = returned.getText();\n if (text.includes(\"\\n\")) {\n returned.addShorthandPropertyAssignment({ name: \"subscription\" });\n } else {\n // Kept on one line, as written.\n returned.replaceWithText(text.replace(/\\s*\\}$/, \", subscription }\"));\n }\n }\n if (!load.fn.isAsync()) load.fn.setIsAsync(true);\n sf.insertStatements(sf.getStatements().indexOf(load.statement), (writer) =>\n writer.write(helper).blankLine(),\n );\n\n formatLikeSource(sf);\n sf.saveSync();\n return { status: \"success\", changed: sf.getFullText() !== original };\n}\n","import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst FAILURE_HINT = [\n \"Pass the subscription prop to <AppSidebar> in src/routes/(app)/+layout.svelte:\",\n \"\",\n \"<AppSidebar user={data.user} subscription={data.subscription} />\",\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create src/routes/(app)/+layout.svelte with an <AppSidebar /> that receives the subscription prop.\",\n].join(\"\\n\");\n\nexport function modifyAppLayoutSvelte(filePath: string): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const file = SvelteFile.fromPath(filePath);\n if (!file.hasElement(\"AppSidebar\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n if (file.hasAttribute(\"AppSidebar\", \"subscription\")) {\n return { status: \"success\", changed: false };\n }\n\n const appended = file.appendToAttributes(\n \"AppSidebar\",\n \" subscription={data.subscription}\",\n );\n if (!appended) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n file.writeTo(filePath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport { SyntaxKind } from \"ts-morph\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n withInMemoryScript,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst SUBSCRIPTION_TYPE = \"{ id: string; productName: string | null } | null\";\n\nconst FAILURE_HINT = [\n \"Update src/lib/components/app-sidebar.svelte to forward a subscription prop:\",\n \"\",\n \"1. Add `subscription = null` to the destructured $props() call.\",\n `2. Add \\`subscription?: ${SUBSCRIPTION_TYPE}\\` to the props type.`,\n \"3. Pass `{subscription}` to <NavUser>.\",\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create src/lib/components/app-sidebar.svelte before enabling subscriptions.\",\n].join(\"\\n\");\n\nfunction updateScript(source: string): {\n source: string;\n wasAdded: boolean;\n} {\n let wasAdded = false;\n const { source: out } = withInMemoryScript(source, (sf) => {\n for (const decl of sf.getVariableDeclarations()) {\n const init = decl.getInitializer();\n if (!init || init.getText() !== \"$props()\") continue;\n\n const nameNode = decl.getNameNode();\n if (nameNode.getKind() !== SyntaxKind.ObjectBindingPattern) continue;\n const pattern = nameNode.asKindOrThrow(SyntaxKind.ObjectBindingPattern);\n const elements = pattern.getElements();\n if (elements.some((e) => e.getName() === \"subscription\")) {\n // Already has subscription prop — no-op.\n return;\n }\n\n // Insert subscription?: ... into the props type literal if present.\n const typeNode = decl.getTypeNode();\n if (typeNode?.getKind() === SyntaxKind.IntersectionType) {\n const intersection = typeNode.asKindOrThrow(\n SyntaxKind.IntersectionType,\n );\n for (const member of intersection.getTypeNodes()) {\n if (member.getKind() !== SyntaxKind.TypeLiteral) continue;\n const lit = member.asKindOrThrow(SyntaxKind.TypeLiteral);\n const propTexts = lit\n .getProperties()\n .map((p) => p.getText().replace(/[;,]\\s*$/, \"\"));\n if (propTexts.some((t) => /^\\s*subscription\\??\\s*:/.test(t))) {\n continue;\n }\n propTexts.push(`subscription?: ${SUBSCRIPTION_TYPE}`);\n lit.replaceWithText(`{ ${propTexts.join(\"; \")}; }`);\n break;\n }\n }\n\n // Insert `subscription = null` before the first rest/default-only element.\n const elementTexts = elements.map((e) => e.getText());\n let insertIdx = elements.findIndex(\n (e) => e.getDotDotDotToken() || e.getInitializer(),\n );\n if (insertIdx === -1) insertIdx = elementTexts.length;\n elementTexts.splice(insertIdx, 0, \"subscription = null\");\n pattern.replaceWithText(`{ ${elementTexts.join(\", \")} }`);\n wasAdded = true;\n }\n formatLikeSource(sf);\n });\n return { source: out, wasAdded };\n}\n\nexport function modifyAppSidebar(filePath: string): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const original = fs.readFileSync(filePath, \"utf8\");\n if (\n original.includes(\"subscription?: {\") ||\n original.includes(\"subscription={subscription}\") ||\n original.includes(\"{subscription}\")\n ) {\n return { status: \"success\", changed: false };\n }\n\n const file = new SvelteFile(original);\n if (!file.hasElement(\"NavUser\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const scriptChanged = file.modifyScript((src) => updateScript(src).source);\n\n const templateChanged = !file.hasAttribute(\"NavUser\", \"subscription\")\n ? file.appendToAttributes(\"NavUser\", \" {subscription}\")\n : false;\n\n if (!scriptChanged && !templateChanged) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n file.writeTo(filePath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\n/**\n * Overwrites a file with the given template content, guarded by an idempotency\n * marker: if the current file already contains the marker, the modify is a\n * no-op. Used for complex rewrites where surgical AST changes aren't worth it\n * (e.g. pages that are largely replaced).\n *\n * Strips leading `// [!code highlight:N]` and `<!-- [!code highlight:N] -->`\n * lines so the same content can be shared with preview-modifies, which uses\n * those comments for documentation highlighting.\n */\nexport function modifyByTemplate(\n filePath: string,\n template: string,\n idempotencyMarker: string,\n notFoundHint: string,\n): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"not-found\", message: notFoundHint };\n }\n const current = fs.readFileSync(filePath, \"utf8\");\n if (current.includes(idempotencyMarker)) {\n return { status: \"success\", changed: false };\n }\n const stripped = template\n .replace(/^[ \\t]*\\/\\/[ \\t]*\\[!code highlight:\\d+\\][ \\t]*\\r?\\n/gm, \"\")\n .replace(\n /^[ \\t]*<!--[ \\t]*\\[!code highlight:\\d+\\][ \\t]*-->[ \\t]*\\r?\\n/gm,\n \"\",\n );\n if (current === stripped) {\n return { status: \"success\", changed: false };\n }\n fs.writeFileSync(filePath, stripped, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import { modifyByTemplate } from \"./modify-by-template\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst NOT_FOUND_HINT = [\n \"src/routes/(app)/billing/+page.server.ts is missing.\",\n \"Enable payments first — subscriptions extends the billing page with plan management.\",\n].join(\"\\n\");\n\nexport function modifyBillingPageServer(\n filePath: string,\n template: string,\n): ModifyOutcome {\n return modifyByTemplate(filePath, template, \"selectPlan\", NOT_FOUND_HINT);\n}\n","import { modifyByTemplate } from \"./modify-by-template\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst NOT_FOUND_HINT = [\n \"src/routes/(app)/billing/+page.svelte is missing.\",\n \"Enable payments first — subscriptions extends the billing page with plan management.\",\n].join(\"\\n\");\n\nexport function modifyBillingPageSvelte(\n filePath: string,\n template: string,\n): ModifyOutcome {\n return modifyByTemplate(filePath, template, \"availablePlans\", NOT_FOUND_HINT);\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { InvalidArgumentError } from \"../../../core/errors\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { keepMissing, modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { modifyWebhookServer } from \"./modifies/modify-webhook-server\";\nimport { modifyAppLayoutServer } from \"./modifies/modify-app-layout-server\";\nimport { modifyAppLayoutSvelte } from \"./modifies/modify-app-layout-svelte\";\nimport { modifyAppSidebar } from \"./modifies/modify-app-sidebar\";\nimport { modifyNavUser } from \"./modifies/modify-nav-user\";\nimport { modifyBillingPageServer } from \"./modifies/modify-billing-page-server\";\nimport { modifyBillingPageSvelte } from \"./modifies/modify-billing-page-svelte\";\nimport stripeCustomerHelper from \"../payments/providers-app-mode/stripe/src/lib/server/stripe-customer.ts?raw\";\n\n// The billing page imports this payments helper, which apps that enabled\n// payments before it existed do not have yet.\nconst STRIPE_CUSTOMER_HELPER = \"src/lib/server/stripe-customer.ts\";\n\n// enable-payments writes the billing page (and the stripe_customers collection\n// subscriptions relate to) only when auth is already on.\nconst BILLING_PAGE = \"src/routes/(app)/billing/+page.server.ts\";\n\n/**\n * Refuses a project whose payments were enabled before auth. Every `requires`\n * flag passes there (auth and payments are both on), yet the billing page and\n * `stripe_customers` don't exist, so this runs before any collection is made.\n */\nexport function assertPaymentsAppMode(root: string): void {\n if (fs.existsSync(path.join(root, BILLING_PAGE))) return;\n throw new InvalidArgumentError(\n [\n \"Subscriptions need payments set up with auth on: they add plans to the billing page\",\n `(${BILLING_PAGE}) and link to the stripe_customers collection, which enable-payments`,\n \"creates only when auth is already enabled. This project enabled payments before auth.\",\n \"\",\n \"Re-enable payments now that auth is on: `vela disable payments`, then `vela enable payments`.\",\n \"disable-payments drops the catalog collections, which the sync workflow refills from Stripe.\",\n ].join(\"\\n\"),\n );\n}\n\n// Share the final-state files between preview (rendered as-is) and runtime\n// (used as overwrite templates for modifies that amount to full rewrites).\nconst previewRaw = import.meta.glob<string>(\"./preview-modifies/**\", {\n query: \"?raw\",\n import: \"default\",\n eager: true,\n});\n\nfunction template(relativePath: string): string {\n const key = `./preview-modifies/${relativePath}`;\n const content = previewRaw[key];\n if (content === undefined) {\n throw new Error(\n `Missing template for ${relativePath} in subscriptions preview-modifies`,\n );\n }\n return content;\n}\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Modifying webhooks/stripe/handlers/dispatch.ts\");\n const webhookServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"webhooks\",\n \"stripe\",\n \"handlers\",\n \"dispatch.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n webhookServerPath,\n modifyWebhookServer(webhookServerPath),\n ),\n );\n\n logger.info(\"Modifying (app)/+layout.server.ts\");\n const appLayoutServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"+layout.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n appLayoutServerPath,\n modifyAppLayoutServer(\n appLayoutServerPath,\n template(\"src/routes/(app)/+layout.server.ts\"),\n ),\n ),\n );\n\n logger.info(\"Modifying (app)/+layout.svelte\");\n const appLayoutSveltePath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"+layout.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(\n appLayoutSveltePath,\n modifyAppLayoutSvelte(appLayoutSveltePath),\n ),\n );\n\n logger.info(\"Modifying app-sidebar.svelte\");\n const appSidebarPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"app-sidebar.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(appSidebarPath, modifyAppSidebar(appSidebarPath)),\n );\n\n logger.info(\"Modifying nav-user.svelte\");\n const navUserPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"nav-user.svelte\",\n );\n pushResult(modifyOutcomeToFile(navUserPath, modifyNavUser(navUserPath)));\n\n logger.info(\"Modifying billing/+page.server.ts\");\n const billingPageServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"billing\",\n \"+page.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n billingPageServerPath,\n modifyBillingPageServer(\n billingPageServerPath,\n template(\"src/routes/(app)/billing/+page.server.ts\"),\n ),\n ),\n );\n\n logger.info(\"Modifying billing/+page.svelte\");\n const billingPageSveltePath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"billing\",\n \"+page.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(\n billingPageSveltePath,\n modifyBillingPageSvelte(\n billingPageSveltePath,\n template(\"src/routes/(app)/billing/+page.svelte\"),\n ),\n ),\n );\n\n const creates = keepMissing(\n [\n {\n path: STRIPE_CUSTOMER_HELPER,\n language: \"ts\",\n content: stripeCustomerHelper,\n status: \"success\",\n },\n ],\n options.root,\n );\n\n return {\n creates,\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;;;;;AAUA,IAAMA,IAAe,CAAM;;;;;;;;;;;;;;;;;;GAoBrBC,IACJ,0GAEIkC,IAA6B,CAAM;;;;;;;;;;;;;AAczC,SAAgBC,EAAoB,GAAiC;CACnE,IAAI,CAACL,EAAG,WAAWM,CAAQ,GACzB,OAAO;EAAE,QAAQ;EAAa,SAASpC;CAAe;CAGxD,IAAMqC,IAAWP,EAAG,aAAaM,GAAU,MAAM;CACjD,IAAIC,EAAS,SAAS,2BAA2B,GAC/C,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAIC,IAAa,IACX,EAAE,cAAWf,EAAmBc,IAA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iBpG,EAAK,KAC1B8F,EAAQ,MACR,OACA,OACA,cACA,oBACF;CAKA,AAJAE,EACEpG,EAAoBwG,GAAgB7B,EAAiB6B,CAAc,CAAC,CACtE,GAEAR,EAAO,KAAK,2BAA2B;CACvC,IAAMS,IAAcrG,EAAK,KACvB8F,EAAQ,MACR,OACA,OACA,cACA,iBACF;CAGA,AAFAE,EAAWpG,EAAoByG,GAAavG,EAAcuG,CAAW,CAAC,CAAC,GAEvET,EAAO,KAAK,mCAAmC;CAC/C,IAAMU,IAAwBtG,EAAK,KACjC8F,EAAQ,MACR,OACA,UACA,SACA,WACA,iBACF;CAWA,AAVAE,EACEpG,EACE0G,GACArB,EACEqB,GACA9E,EAAS,0CAA0C,CACrD,CACF,CACF,GAEAoE,EAAO,KAAK,gCAAgC;CAC5C,IAAMW,IAAwBvG,EAAK,KACjC8F,EAAQ,MACR,OACA,UACA,SACA,WACA,cACF;CAuBA,OAtBAE,EACEpG,EACE2G,GACApB,EACEoB,GACA/E,EAAS,uCAAuC,CAClD,CACF,CACF,GAcO;EACL,SAbc7B,EACd,CACE;GACE,MAAMyF;GACN,UAAU;GACV,SAAStG;GACT,QAAQ;EACV,CACF,GACAgH,EAAQ,IAIR;EACA;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
@@ -1,65 +0,0 @@
1
- import { r as e } from "./lib-specifier-Cngo1zF_.js";
2
- import { n as t } from "./logger-CQONztPm.js";
3
- import { n, t as r } from "./generate-DiwvSC9c.js";
4
- import { n as i } from "./env-BugddEjd.js";
5
- import { _ as a, n as o, u as s } from "./ts-morph-helpers-CHI9wAil.js";
6
- import { r as c, t as l } from "./modify-file-DdXJCMHN.js";
7
- import { unmodifyEnvVarsFiles as u } from "./env-vars-CNH-ItSY.js";
8
- import { t as d } from "./svelte-file-Dv5-bl79.js";
9
- import f from "node:fs";
10
- import p from "node:path";
11
- //#region src/patterns/disable/analytics/modifies/layout.svelte.ts
12
- var m = "components/analytics/analytics.svelte";
13
- function h(t) {
14
- if (!f.existsSync(t)) return {
15
- status: "success",
16
- changed: !1
17
- };
18
- let n = f.readFileSync(t, "utf8");
19
- if (!n.includes(m) && !n.includes("<Analytics")) return {
20
- status: "success",
21
- changed: !1
22
- };
23
- let r = d.fromPath(t);
24
- r.modifyScript((t) => {
25
- let { source: n } = a(t, (t) => {
26
- s(t, e(m)), o(t);
27
- });
28
- return n;
29
- });
30
- let i = r.toString().replace(/[ \t]*<Analytics\s*\/>[ \t]*\r?\n?/g, "");
31
- return i === n ? {
32
- status: "success",
33
- changed: !1
34
- } : (f.writeFileSync(t, i, "utf8"), {
35
- status: "success",
36
- changed: !0
37
- });
38
- }
39
- //#endregion
40
- //#region src/patterns/disable/analytics/generate.runtime.ts
41
- async function g(e) {
42
- let a = t(e), o = [], s = [], d = (e) => {
43
- e && o.push(e);
44
- };
45
- a.info("Reverting src/routes/+layout.svelte");
46
- let f = p.join(e.root, "src", "routes", "+layout.svelte");
47
- d(c(f, h(f))), a.info("Removing analytics variables from src/env.ts");
48
- let m = u(e.root, n());
49
- d(m.modify), m.delete && s.push(m.delete), a.info("Removing analytics variables from .env");
50
- let g = p.join(e.root, ".env"), _ = l(g, i(g, r()));
51
- return d(_.modify), _.delete && s.push(_.delete), {
52
- creates: [],
53
- modifies: o,
54
- deletes: s,
55
- components: [],
56
- packages: [],
57
- collections: [],
58
- collectionPatches: [],
59
- collectionDrops: []
60
- };
61
- }
62
- //#endregion
63
- export { g as generate };
64
-
65
- //# sourceMappingURL=generate.runtime-CPDJolef.js.map
@@ -1,114 +0,0 @@
1
- import { t as e } from "./lib-specifier-Cngo1zF_.js";
2
- import { n as t } from "./logger-CQONztPm.js";
3
- import { a as n } from "./currency.server-CzHS7Svd.js";
4
- import { t as r } from "./shared-DIDAkVts.js";
5
- import { n as i } from "./generate-BEc_h7OI.js";
6
- import { n as a } from "./env-BugddEjd.js";
7
- import { f as o, m as s, n as c, o as l } from "./ts-morph-helpers-CHI9wAil.js";
8
- import { r as u } from "./modify-file-DdXJCMHN.js";
9
- import { unmodifyEnvVarsFiles as d } from "./env-vars-CNH-ItSY.js";
10
- import { t as f } from "./svelte-file-Dv5-bl79.js";
11
- import { c as p, i as m, n as h, o as g } from "./root-layout.svelte-CUVbnlX-.js";
12
- import { n as _, t as v } from "./wuchale-config-c3Q4JVSF.js";
13
- import y from "node:fs";
14
- import b from "node:path";
15
- import { Project as x, QuoteKind as S, SyntaxKind as C } from "ts-morph";
16
- //#region src/patterns/disable/payments/modifies/modify-nav-user.ts
17
- function w(e) {
18
- if (!y.existsSync(e)) return {
19
- status: "success",
20
- changed: !1
21
- };
22
- let t = y.readFileSync(e, "utf8");
23
- if (!t.includes("/billing")) return {
24
- status: "success",
25
- changed: !1
26
- };
27
- let n = new f(t), r = !1, i = (e) => {
28
- r || e((e) => {
29
- let t = o(e, "Billing", "@lucide/svelte/icons/credit-card");
30
- return t.wasRemoved && (r = !0), t.source;
31
- });
32
- };
33
- return i((e) => n.modifyModuleScript(e)), r || i((e) => n.modifyScript(e)), r ? (y.writeFileSync(e, n.toString(), "utf8"), {
34
- status: "success",
35
- changed: !0
36
- }) : {
37
- status: "success",
38
- changed: !1
39
- };
40
- }
41
- //#endregion
42
- //#region src/patterns/disable/payments/modifies/modify-user-signup.ts
43
- var T = /* @__PURE__ */ new Set(["linkStripeCustomer.run", "linkStripeCustomer"]);
44
- function E(t) {
45
- if (!y.existsSync(t)) return {
46
- status: "success",
47
- changed: !1
48
- };
49
- let n = y.readFileSync(t, "utf8");
50
- if (!n.includes("linkStripeCustomer")) return {
51
- status: "success",
52
- changed: !1
53
- };
54
- let r = new x({ manipulationSettings: { quoteKind: S.Single } }).addSourceFileAtPath(t);
55
- for (let t of ["workflows/link-stripe-customer", "stripe"]) {
56
- let n = r.getImportDeclarations().find((n) => e(n.getModuleSpecifierValue(), t));
57
- n && n.remove();
58
- }
59
- let i = r.getVariableStatement((e) => e.getDeclarations().some((e) => e.getName() === "linkStripeCustomer"));
60
- i && i.remove();
61
- let a = r.getDescendantsOfKind(C.CallExpression).filter((e) => T.has(e.getExpression().getText()));
62
- for (let e of a) {
63
- let t = e.getFirstAncestorByKind(C.ExpressionStatement);
64
- t && s(r, t);
65
- }
66
- return l(r), c(r), r.saveSync(), {
67
- status: "success",
68
- changed: r.getFullText() !== n
69
- };
70
- }
71
- //#endregion
72
- //#region src/patterns/disable/payments/generate.runtime.ts
73
- var D = [
74
- "transactions",
75
- "stripe_customers",
76
- "stripe_payment_methods",
77
- "stripe_prices",
78
- "stripe_products"
79
- ];
80
- async function O(e) {
81
- let o = e.features.auth, s = t(e), c = i(e), l = c.some((e) => e.id === "stripe"), f = [], x = [], S = (e) => {
82
- e && f.push(e);
83
- }, C = b.join(e.root, ".env");
84
- for (let e of c) s.info(`Stripping ${e.label} credentials from .env`), S(u(C, a(C, n(e))));
85
- s.info("Removing the currency select from the navbar");
86
- let T = b.join(e.root, "src", "routes", "(public)", "root-layout.svelte");
87
- S(u(T, h(T)));
88
- let O = b.join(e.root, "src", "hooks.server.ts"), k = b.join(e.root, "src", "routes", "+layout.server.ts"), A = b.join(e.root, "src", "routes", "+layout.svelte");
89
- y.existsSync(k) && (s.info("Removing the visitor's currency from the server"), S(u(A, m(A))), S(u(k, g(k))), S(u(O, p(O)))), s.info("Removing payment variables from src/env.ts");
90
- let j = d(e.root, c.flatMap((e) => (e.env ?? []).map((e) => e.key)));
91
- S(j.modify), j.delete && x.push(j.delete);
92
- let M = b.join(e.root, "wuchale.config.js");
93
- if (c.some((e) => e.id === "whatsapp") && y.existsSync(M) && (s.info("Removing src/lib/order.ts from wuchale's js adapter"), S(u(M, _(M, v, "remove")))), l && o) {
94
- s.info("Reverting nav-user.svelte");
95
- let t = b.join(e.root, "src", "lib", "components", "nav-user.svelte");
96
- S(u(t, w(t))), s.info("Reverting signup +page.server.ts");
97
- let n = b.join(e.root, "src", "routes", "(public)", "(auth)", "signup", "+page.server.ts");
98
- S(u(n, E(n)));
99
- }
100
- return {
101
- creates: [],
102
- modifies: f,
103
- deletes: x,
104
- components: [],
105
- packages: [],
106
- collections: [],
107
- collectionPatches: [],
108
- collectionDrops: l && e.features.backend ? await r(D, e) : []
109
- };
110
- }
111
- //#endregion
112
- export { O as generate };
113
-
114
- //# sourceMappingURL=generate.runtime-CaOO0281.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"generate.runtime-CeoqgxiO.js","names":["languageFromPath","NOTIFICATION_RULE_PATCHES","migrationDelay","getMigrationFile","withInMemoryScript","formatLikeSource","ensureImports","modifyOutcomeToFile","SvelteFile","modifyUtils","createCollectionIdempotent","applyCollectionRulePatches","fs","path","BELL_SNIPPET","IMPORT_SNIPPET","FAILURE_HINT","NOT_FOUND_HINT","modifyAppLayout","layoutPath","file","out","source","sf","FETCH_STATEMENT","NOTIFICATIONS_STATEMENT","DEPENDS_STATEMENT","modifyLayoutServer","layoutServerPath","snippet","originalSource","sourceFile","Project","addProperty","obj","name","initializer","loadArrow","loadFn","varDecl","SyntaxKind","directArrow","init","innerArrow","innerFnExpr","maybeFn","fnLike","params","first","original","nameNode","obp","elementNames","el","hasDepends","hasLocals","existingParts","parts","currentName","body","blockBody","statements","declaresVar","stmt","d","hasDependsCall","ce","args","argText","hasNotificationsList","hasNotifications","returnIdx","s","insertAt","augmentReturnObject","augmentReturns","expr","ret","inner","arrowBody","bodyExpr","fnBody","pushMigrationCreates","created","migrationFile","collectionName","options","creates","generate","logger","getLogger","withPocketbase","userCollection","pb","create","spec","result","ruleMigrations","modifies","pushResult","appLayoutPath","appLayoutServerPath","utilsPath"],"sources":["../../src/patterns/enable/notifications/modifies/modify-app-layout.ts","../../src/patterns/enable/notifications/modifies/+layout.server.ts","../../src/patterns/enable/notifications/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n ensureImports,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst BELL_SNIPPET = `\n\t\t<div class=\"ml-auto px-4\">\n\t\t\t<NotificationsBell />\n\t\t</div>\n\t`;\n\nconst IMPORT_SNIPPET = dedent`\n import NotificationsBell from '#lib/components/notifications-bell.svelte';\n`;\n\nconst FAILURE_HINT = [\n \"Add the notifications bell inside the (app) layout's <header>.\",\n \"\",\n \"Imports to add to the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup to add inside <header>:\",\n BELL_SNIPPET,\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create src/routes/(app)/+layout.svelte with a <header> that includes the bell.\",\n \"\",\n \"Imports for the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup inside <header>:\",\n BELL_SNIPPET,\n].join(\"\\n\");\n\nexport function modifyAppLayout(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const file = SvelteFile.fromPath(layoutPath);\n if (!file.hasElement(\"header\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n if (file.hasElement(\"NotificationsBell\")) {\n return { status: \"success\", changed: false };\n }\n\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n ensureImports(sf, [\n {\n defaultImport: \"NotificationsBell\",\n moduleSpecifier: \"#lib/components/notifications-bell.svelte\",\n },\n ]);\n });\n return out;\n });\n\n file.insertBeforeClosingTag(\"header\", BELL_SNIPPET);\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Project, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { formatLikeSource } from \"../../../../runtime/ts-morph-helpers\";\n\nconst FETCH_STATEMENT = dedent`\n const notificationsList = await locals.pb\n .collection(\"notifications\")\n .getList(1, 5, {\n filter: \\`user = \"\\${locals.pb.authStore.record!.id}\" && read = false\\`,\n sort: \"-created\",\n });\n`;\n\nconst NOTIFICATIONS_STATEMENT =\n \"const notifications = { count: notificationsList.totalItems, items: notificationsList.items };\";\n\nconst DEPENDS_STATEMENT = 'depends(\"app:notifications\");';\n\nexport function modifyLayoutServer(layoutServerPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutServerPath)) {\n const snippet = dedent`\n export const load = async ({ locals, depends }) => {\n ${FETCH_STATEMENT}\n ${NOTIFICATIONS_STATEMENT}\n ${DEPENDS_STATEMENT}\n return { notifications };\n };\n `;\n fs.writeFileSync(layoutServerPath, snippet);\n return { status: \"success\", changed: true };\n }\n\n const originalSource = fs.readFileSync(layoutServerPath, \"utf8\");\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(layoutServerPath);\n\n const addProperty = (\n obj: import(\"ts-morph\").ObjectLiteralExpression,\n name: string,\n initializer: string,\n ) => {\n if (obj.getProperty(name)) return;\n if (name === initializer) {\n obj.addShorthandPropertyAssignment({ name });\n } else {\n obj.addPropertyAssignment({ name, initializer });\n }\n };\n\n let loadArrow: import(\"ts-morph\").ArrowFunction | undefined;\n let loadFn:\n | import(\"ts-morph\").FunctionDeclaration\n | import(\"ts-morph\").FunctionExpression\n | undefined;\n\n const varDecl = sourceFile.getVariableDeclaration(\"load\");\n if (varDecl) {\n const vs = varDecl.getFirstAncestorByKind(SyntaxKind.VariableStatement);\n if (vs?.hasExportKeyword()) {\n const directArrow = varDecl.getInitializerIfKind(\n SyntaxKind.ArrowFunction,\n );\n if (directArrow) {\n loadArrow = directArrow;\n } else {\n const init = varDecl.getInitializer();\n if (init) {\n const innerArrow = init.getFirstDescendantByKind(\n SyntaxKind.ArrowFunction,\n );\n if (innerArrow) {\n loadArrow = innerArrow;\n } else {\n const innerFnExpr = init.getFirstDescendantByKind(\n SyntaxKind.FunctionExpression,\n );\n if (innerFnExpr) loadFn = innerFnExpr;\n }\n }\n }\n }\n }\n\n if (!loadArrow && !loadFn) {\n const maybeFn = sourceFile.getFunction(\"load\");\n if (maybeFn && maybeFn.isExported()) loadFn = maybeFn;\n }\n\n if (!loadArrow && !loadFn) {\n sourceFile.addFunction({\n isExported: true,\n isAsync: true,\n name: \"load\",\n parameters: [{ name: \"{ locals, depends }\" }],\n statements: [\n FETCH_STATEMENT,\n NOTIFICATIONS_STATEMENT,\n DEPENDS_STATEMENT,\n \"return { notifications };\",\n ],\n });\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n const fnLike = (loadArrow ?? loadFn!) as\n | import(\"ts-morph\").ArrowFunction\n | import(\"ts-morph\").FunctionDeclaration\n | import(\"ts-morph\").FunctionExpression;\n\n // Ensure first param destructures { locals, depends }\n const params = fnLike.getParameters();\n if (params.length === 0) {\n fnLike.insertParameter(0, { name: \"{ locals, depends }\" });\n } else {\n const first = params[0];\n const original = first.getStructure();\n const nameNode = first.getNameNode();\n if (nameNode.getKind() === SyntaxKind.ObjectBindingPattern) {\n const obp = nameNode as import(\"ts-morph\").ObjectBindingPattern;\n const elementNames = obp.getElements().map((el) => el.getName());\n const hasDepends = elementNames.includes(\"depends\");\n const hasLocals = elementNames.includes(\"locals\");\n\n if (!hasDepends || !hasLocals) {\n const existingParts = obp\n .getElements()\n .map((el) => el.getText())\n .filter(Boolean);\n const parts: string[] = hasLocals ? [] : [\"locals\"];\n parts.push(...existingParts);\n if (!hasDepends) parts.push(\"depends\");\n first.set({\n name: `{ ${parts.join(\", \")} }`,\n type: original.type,\n initializer: (original as { initializer?: string }).initializer,\n });\n }\n } else {\n const currentName = first.getName();\n if (currentName !== \"locals\") {\n first.set({\n name: `{ locals, depends, ...${currentName} }`,\n type: original.type,\n initializer: (original as { initializer?: string }).initializer,\n });\n } else {\n first.set({\n name: `{ locals, depends }`,\n type: original.type,\n initializer: (original as { initializer?: string }).initializer,\n });\n }\n }\n }\n\n if (loadArrow && !loadArrow.isAsync()) loadArrow.setIsAsync(true);\n else if (loadFn && !loadFn.isAsync()) loadFn.setIsAsync(true);\n\n const body = fnLike.getBody();\n if (body && body.getKind() === SyntaxKind.Block) {\n const blockBody = body as import(\"ts-morph\").Block;\n const statements = blockBody.getStatements();\n\n const declaresVar = (name: string) =>\n statements.some((stmt) => {\n if (stmt.getKind() !== SyntaxKind.VariableStatement) return false;\n return (stmt as import(\"ts-morph\").VariableStatement)\n .getDeclarations()\n .some((d) => d.getName() === name);\n });\n\n const hasDependsCall = statements.some(\n (stmt) =>\n stmt.getKind() === SyntaxKind.ExpressionStatement &&\n stmt.getDescendantsOfKind(SyntaxKind.CallExpression).some((ce) => {\n if (ce.getExpression().getText() !== \"depends\") return false;\n const args = ce.getArguments();\n const argText = args[0]?.getText() ?? \"\";\n return (\n args.length === 1 &&\n (argText === \"'app:notifications'\" ||\n argText === '\"app:notifications\"')\n );\n }),\n );\n\n const hasNotificationsList = declaresVar(\"notificationsList\");\n const hasNotifications = declaresVar(\"notifications\");\n\n const returnIdx = statements.findIndex(\n (s) => s.getKind() === SyntaxKind.ReturnStatement,\n );\n let insertAt = returnIdx >= 0 ? returnIdx : statements.length;\n\n if (!hasNotificationsList) {\n blockBody.insertStatements(insertAt, FETCH_STATEMENT);\n insertAt++;\n }\n if (!hasNotifications) {\n blockBody.insertStatements(insertAt, NOTIFICATIONS_STATEMENT);\n insertAt++;\n }\n if (!hasDependsCall) {\n blockBody.insertStatements(insertAt, DEPENDS_STATEMENT);\n }\n }\n\n const augmentReturnObject = (\n obj: import(\"ts-morph\").ObjectLiteralExpression,\n ) => {\n addProperty(obj, \"notifications\", \"notifications\");\n };\n\n const augmentReturns = (target: import(\"ts-morph\").Node) => {\n const returns = target.getDescendantsOfKind(SyntaxKind.ReturnStatement);\n returns.forEach((ret) => {\n const expr = ret.getExpression();\n if (!expr) return;\n if (expr.getKind() === SyntaxKind.ObjectLiteralExpression) {\n augmentReturnObject(expr as import(\"ts-morph\").ObjectLiteralExpression);\n } else if (expr.getKind() === SyntaxKind.ParenthesizedExpression) {\n const inner = (\n expr as import(\"ts-morph\").ParenthesizedExpression\n ).getExpression();\n if (inner.getKind() === SyntaxKind.ObjectLiteralExpression) {\n augmentReturnObject(\n inner as import(\"ts-morph\").ObjectLiteralExpression,\n );\n }\n }\n });\n };\n\n if (loadArrow) {\n const arrowBody = loadArrow.getBody();\n if (arrowBody.getKind() === SyntaxKind.Block) {\n augmentReturns(arrowBody);\n } else {\n const bodyExpr = arrowBody as import(\"ts-morph\").Expression;\n if (bodyExpr.getKind() === SyntaxKind.ParenthesizedExpression) {\n const inner = (\n bodyExpr as import(\"ts-morph\").ParenthesizedExpression\n ).getExpression();\n if (inner.getKind() === SyntaxKind.ObjectLiteralExpression) {\n augmentReturnObject(\n inner as import(\"ts-morph\").ObjectLiteralExpression,\n );\n }\n } else if (bodyExpr.getKind() === SyntaxKind.ObjectLiteralExpression) {\n augmentReturnObject(\n bodyExpr as import(\"ts-morph\").ObjectLiteralExpression,\n );\n }\n }\n } else if (loadFn) {\n const fnBody = loadFn.getBody();\n if (fnBody) augmentReturns(fnBody);\n }\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { languageFromPath } from \"../../../core/util\";\nimport {\n applyCollectionRulePatches,\n createCollectionIdempotent,\n} from \"../../../runtime/collections\";\nimport {\n getMigrationFile,\n migrationDelay,\n withPocketbase,\n} from \"../../../runtime/pocketbase\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { modifyUtils } from \"../../../runtime/modify-utils\";\nimport { modifyAppLayout } from \"./modifies/modify-app-layout\";\nimport { modifyLayoutServer } from \"./modifies/+layout.server\";\nimport { NOTIFICATION_RULE_PATCHES } from \"./runtime/pocketbase\";\n\nasync function pushMigrationCreates(\n creates: File[],\n collectionName: string,\n options: Options,\n created = true,\n) {\n if (!created) return;\n await migrationDelay();\n const migrationFile = getMigrationFile(collectionName, \"created\", options);\n if (!migrationFile) return;\n creates.push({\n path: migrationFile,\n language: languageFromPath(migrationFile),\n content: fs.readFileSync(migrationFile, \"utf8\"),\n status: \"success\",\n });\n}\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const creates: File[] = [];\n\n await withPocketbase(options.root, async (pb) => {\n const userCollection = await pb.collections.getOne(\"users\");\n const create = (spec: Parameters<typeof createCollectionIdempotent>[1]) =>\n createCollectionIdempotent(pb, spec, logger);\n\n logger.info(\"Creating notifications collection\");\n const result = await create({\n name: \"notifications\",\n type: \"base\",\n fields: [\n {\n name: \"id\",\n type: \"text\",\n primaryKey: true,\n autogeneratePattern: \"[a-z0-9]{15}\",\n max: 15,\n min: 15,\n pattern: \"^[a-z0-9]+$\",\n required: true,\n },\n {\n name: \"user\",\n type: \"relation\",\n cascadeDelete: true,\n collectionId: userCollection.id,\n maxSelect: 1,\n minSelect: 0,\n required: true,\n },\n {\n name: \"title\",\n type: \"text\",\n required: true,\n },\n {\n name: \"body\",\n type: \"text\",\n },\n {\n name: \"read\",\n type: \"bool\",\n },\n {\n name: \"created\",\n type: \"autodate\",\n onCreate: true,\n onUpdate: false,\n },\n {\n name: \"updated\",\n type: \"autodate\",\n onCreate: true,\n onUpdate: true,\n },\n ],\n indexes: [\n \"CREATE INDEX `idx_notifications_user_read_created` ON `notifications` (`user`, `read`, `created` DESC)\",\n ],\n });\n await pushMigrationCreates(\n creates,\n \"notifications\",\n options,\n result.created,\n );\n\n logger.info(\"Applying notifications rule patches\");\n const ruleMigrations = await applyCollectionRulePatches(\n pb,\n NOTIFICATION_RULE_PATCHES,\n options,\n logger,\n );\n creates.push(...ruleMigrations);\n });\n\n const modifies: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Modifying (app) +layout.svelte\");\n const appLayoutPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"+layout.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(appLayoutPath, modifyAppLayout(appLayoutPath)),\n );\n\n logger.info(\"Modifying (app) +layout.server.ts\");\n const appLayoutServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"+layout.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n appLayoutServerPath,\n modifyLayoutServer(appLayoutServerPath),\n ),\n );\n\n logger.info(\"Modifying utils.ts\");\n const utilsPath = path.join(options.root, \"src\", \"lib\", \"utils.ts\");\n pushResult(modifyOutcomeToFile(utilsPath, modifyUtils(utilsPath)));\n\n return {\n creates,\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;;;;;;AASA,IAAMc,IAAe,2EAMfC,IAAiB,CAAM;;GAIvBC,IAAe;CACnB;CACA;CACA;CACA;CACAD;CACA;CACA;CACAD;AACF,CAAC,CAAC,KAAK,IAAI,GAELG,IAAiB;CACrB;CACA;CACA;CACA;CACAF;CACA;CACA;CACAD;AACF,CAAC,CAAC,KAAK,IAAI;AAEX,SAAgBI,EAAgB,GAAmC;CACjE,IAAI,CAACN,EAAG,WAAWO,CAAU,GAC3B,OAAO;EAAE,QAAQ;EAAa,SAASF;CAAe;CAGxD,IAAMG,IAAOZ,EAAW,SAASW,CAAU;CAsB3C,OArBKC,EAAK,WAAW,QAAQ,IAGzBA,EAAK,WAAW,mBAAmB,IAC9B;EAAE,QAAQ;EAAW,SAAS;CAAM,KAG7CA,EAAK,cAAc,MAAW;EAC5B,IAAM,EAAE,QAAQC,MAAQjB,EAAmBkB,IAAS,MAAO;GACzD,EAAcC,GAAI,CAChB;IACE,eAAe;IACf,iBAAiB;GACnB,CACF,CAAC;EACH,CAAC;EACD,OAAOF;CACT,CAAC,GAEDD,EAAK,uBAAuB,U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kF,CAAa,CAAC,CACnE,GAEAX,EAAO,KAAK,mCAAmC;CAC/C,IAAMY,IAAsBxF,EAAK,KAC/ByE,EAAQ,MACR,OACA,UACA,SACA,mBACF;CAQA,AAPAa,EACE5F,EACE8F,GACA1E,EAAmB0E,CAAmB,CACxC,CACF,GAEAZ,EAAO,KAAK,oBAAoB;CAChC,IAAMa,IAAYzF,EAAK,KAAKyE,EAAQ,MAAM,OAAO,OAAO,UAAU;CAGlE,OAFAa,EAAW5F,EAAoB+F,GAAW7F,EAAY6F,CAAS,CAAC,CAAC,GAE1D;EACL;EACA;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
@@ -1,112 +0,0 @@
1
- import { r as e } from "./lib-specifier-Cngo1zF_.js";
2
- import { n as t } from "./logger-CQONztPm.js";
3
- import { t as n } from "./shared-DIDAkVts.js";
4
- import { _ as r, g as i, n as a, o, p as s, u as c } from "./ts-morph-helpers-CHI9wAil.js";
5
- import { r as l } from "./modify-file-DdXJCMHN.js";
6
- import { t as u } from "./svelte-file-Dv5-bl79.js";
7
- import d from "node:fs";
8
- import f from "node:path";
9
- import { Project as p, SyntaxKind as m } from "ts-morph";
10
- //#region src/patterns/disable/auth/modifies/+layout.server.ts
11
- function h(e) {
12
- if (!d.existsSync(e)) return {
13
- status: "success",
14
- changed: !1
15
- };
16
- let t = d.readFileSync(e, "utf8");
17
- if (!t.includes("locals.pb.authStore.record")) return {
18
- status: "success",
19
- changed: !1
20
- };
21
- let n = new p().addSourceFileAtPath(e), r = n.getDescendantsOfKind(m.ObjectLiteralExpression);
22
- for (let e of r) {
23
- let t = e.getProperty("user");
24
- t && t.getKind() === m.PropertyAssignment && t.getInitializer()?.getText() === "locals.pb.authStore.record" && t.remove();
25
- }
26
- return i(n, "locals"), o(n), n.saveSync(), {
27
- status: "success",
28
- changed: n.getFullText() !== t
29
- };
30
- }
31
- //#endregion
32
- //#region src/patterns/disable/auth/modifies/root-layout.svelte.ts
33
- function g(t) {
34
- if (!d.existsSync(t)) return {
35
- status: "success",
36
- changed: !1
37
- };
38
- let n = d.readFileSync(t, "utf8"), i = new u(n);
39
- if (!i.hasElement("AuthMenu.Root")) return {
40
- status: "success",
41
- changed: !1
42
- };
43
- i.removeElementContaining("Navbar.Item", "AuthMenu.Root") || i.removeElement("AuthMenu.Root");
44
- let o = i.toString().replace(/<script[\s\S]*?<\/script>/g, "");
45
- return i.modifyScript((t) => {
46
- let { source: n } = r(t, (t) => {
47
- c(t, e("components/ui/auth-menu")), c(t, e("components/user-avatar.svelte")), c(t, e("components/ui/avatar")), s(t, "data", o), a(t);
48
- });
49
- return n;
50
- }), i.writeTo(t), {
51
- status: "success",
52
- changed: i.hasChanged()
53
- };
54
- }
55
- //#endregion
56
- //#region src/patterns/disable/auth/modifies/hooks.server.ts
57
- function _(e) {
58
- if (!d.existsSync(e)) return {
59
- status: "success",
60
- changed: !1
61
- };
62
- let t = d.readFileSync(e, "utf8"), n = new p().addSourceFileAtPath(e), r = n.getDescendantsOfKind(m.CallExpression).find((e) => e.getExpression().getText() === "handlePocketbase");
63
- if (!r) return {
64
- status: "success",
65
- changed: !1
66
- };
67
- let [i] = r.getArguments();
68
- if (!i || i.getKind() !== m.ObjectLiteralExpression) return {
69
- status: "success",
70
- changed: !1
71
- };
72
- let a = i.asKindOrThrow(m.ObjectLiteralExpression), s = a.getProperty("auth");
73
- return s ? (s.remove(), a.getProperties().length === 0 && r.removeArgument(0), o(n), n.saveSync(), {
74
- status: "success",
75
- changed: n.getFullText() !== t
76
- }) : {
77
- status: "success",
78
- changed: !1
79
- };
80
- }
81
- //#endregion
82
- //#region src/patterns/disable/auth/generate.runtime.ts
83
- async function v(e) {
84
- let r = t(e), i = [], a = (e) => {
85
- e && i.push(e);
86
- };
87
- r.info("Reverting +layout.server.ts");
88
- let o = f.join(e.root, "src", "routes", "+layout.server.ts");
89
- a(l(o, h(o))), r.info("Reverting root layout");
90
- let s = [
91
- f.join(e.root, "src", "routes", "(public)", "root-layout.svelte"),
92
- f.join(e.root, "src", "routes", "root-layout.svelte"),
93
- f.join(e.root, "src", "routes", "(public)", "+layout.svelte"),
94
- f.join(e.root, "src", "routes", "+layout.svelte")
95
- ], c = s.find((e) => d.existsSync(e)) ?? s[0];
96
- a(l(c, g(c))), r.info("Reverting hooks.server.ts");
97
- let u = f.join(e.root, "src", "hooks.server.ts");
98
- return a(l(u, _(u))), {
99
- creates: [],
100
- modifies: i,
101
- deletes: [],
102
- components: [],
103
- packages: [],
104
- collections: [],
105
- collectionPatches: [],
106
- collectionDrops: await n(["oauth_accounts"], e)
107
- };
108
- }
109
- //#endregion
110
- export { v as generate };
111
-
112
- //# sourceMappingURL=generate.runtime-DUBOC6AA.js.map