@velastack/patterns 0.13.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 (221) hide show
  1. package/dist/chunks/{_layout-DQhSAhfF.js → _layout-Dju9EYqa.js} +6 -8
  2. package/dist/chunks/{_layout-DQhSAhfF.js.map → _layout-Dju9EYqa.js.map} +1 -1
  3. package/dist/chunks/{_page-C7kGoW7_.js → _page-44USwLXO.js} +2 -3
  4. package/dist/chunks/{_page-C7kGoW7_.js.map → _page-44USwLXO.js.map} +1 -1
  5. package/dist/chunks/{_page-DoPdZgZv.js → _page-Bt37d4uo.js} +2 -3
  6. package/dist/chunks/_page-Bt37d4uo.js.map +1 -0
  7. package/dist/chunks/{_page-B6yd6_Vl.js → _page-DcbEFpyw.js} +2 -3
  8. package/dist/chunks/_page-DcbEFpyw.js.map +1 -0
  9. package/dist/chunks/{auth-pages-jsyDV1GR.js → auth-pages-BW3_yluN.js} +6 -9
  10. package/dist/chunks/{auth-pages-jsyDV1GR.js.map → auth-pages-BW3_yluN.js.map} +1 -1
  11. package/dist/chunks/{collections-DZOuRpvS.js → collections-CFW9ZqUE.js} +5 -7
  12. package/dist/chunks/{collections-DZOuRpvS.js.map → collections-CFW9ZqUE.js.map} +1 -1
  13. package/dist/chunks/{collections-zEoRuILr.js → collections-D-xbHi4M.js} +39 -45
  14. package/dist/chunks/{collections-zEoRuILr.js.map → collections-D-xbHi4M.js.map} +1 -1
  15. package/dist/chunks/{compose-handle-BBlamPfx.js → compose-handle-Da7m6lV_.js} +3 -4
  16. package/dist/chunks/{compose-handle-BBlamPfx.js.map → compose-handle-Da7m6lV_.js.map} +1 -1
  17. package/dist/chunks/{config-target-BgyFkbFL.js → config-target-DJbVHwHl.js} +3 -4
  18. package/dist/chunks/{config-target-BgyFkbFL.js.map → config-target-DJbVHwHl.js.map} +1 -1
  19. package/dist/chunks/{constants-CUv536Rj.js → constants-DpK-r_m5.js} +2 -4
  20. package/dist/chunks/{constants-CUv536Rj.js.map → constants-DpK-r_m5.js.map} +1 -1
  21. package/dist/chunks/{currency.server-DygAf6a1.js → currency.server-BwuXG0a9.js} +9 -11
  22. package/dist/chunks/{currency.server-DygAf6a1.js.map → currency.server-BwuXG0a9.js.map} +1 -1
  23. package/dist/chunks/{dedent-Gq6Krl4n.js → dedent-CCUOcPFW.js} +2 -3
  24. package/dist/chunks/{dedent-Gq6Krl4n.js.map → dedent-CCUOcPFW.js.map} +1 -1
  25. package/dist/chunks/{dispatch-BIvOwbKN.js → dispatch-BxlKS_5v.js} +2 -3
  26. package/dist/chunks/{dispatch-BIvOwbKN.js.map → dispatch-BxlKS_5v.js.map} +1 -1
  27. package/dist/chunks/{env-BugddEjd.js → env-AxyRWcC_.js} +2 -3
  28. package/dist/chunks/{env-BugddEjd.js.map → env-AxyRWcC_.js.map} +1 -1
  29. package/dist/chunks/{env-vars-mnRA0hOe.js → env-vars-CUh4mLM_.js} +2 -3
  30. package/dist/chunks/{env-vars-mnRA0hOe.js.map → env-vars-CUh4mLM_.js.map} +1 -1
  31. package/dist/chunks/{env-vars-XvAeH6u5.js → env-vars-CVn2076k.js} +58 -59
  32. package/dist/chunks/{env-vars-XvAeH6u5.js.map → env-vars-CVn2076k.js.map} +1 -1
  33. package/dist/chunks/{env-vars-Cr4lbMD_.js → env-vars-T3_7JNSg.js} +3 -4
  34. package/dist/chunks/{env-vars-Cr4lbMD_.js.map → env-vars-T3_7JNSg.js.map} +1 -1
  35. package/dist/chunks/{env-vars-file-B_6esJW3.js → env-vars-file-B2zHQZqO.js} +2 -3
  36. package/dist/chunks/{env-vars-file-B_6esJW3.js.map → env-vars-file-B2zHQZqO.js.map} +1 -1
  37. package/dist/chunks/{env.preview-uMRKT5Pc.js → env.preview-C676UTOP.js} +2 -3
  38. package/dist/chunks/{env.preview-uMRKT5Pc.js.map → env.preview-C676UTOP.js.map} +1 -1
  39. package/dist/chunks/{errors-DR3gF_7a.js → errors-DdSUZI8f.js} +2 -3
  40. package/dist/chunks/{errors-DR3gF_7a.js.map → errors-DdSUZI8f.js.map} +1 -1
  41. package/dist/chunks/{format-result-BVoLVknk.js → format-result-CojavkIZ.js} +2 -3
  42. package/dist/chunks/{format-result-BVoLVknk.js.map → format-result-CojavkIZ.js.map} +1 -1
  43. package/dist/chunks/{generate-Cbg-Z3sA.js → generate-BCYvhyF9.js} +62 -63
  44. package/dist/chunks/{generate-Cbg-Z3sA.js.map → generate-BCYvhyF9.js.map} +1 -1
  45. package/dist/chunks/{generate-DyV5R8NP.js → generate-CKuUg3p-.js} +3 -4
  46. package/dist/chunks/{generate-DyV5R8NP.js.map → generate-CKuUg3p-.js.map} +1 -1
  47. package/dist/chunks/{generate-DjuhSibA.js → generate-CY_Ii_bz.js} +61 -64
  48. package/dist/chunks/{generate-DjuhSibA.js.map → generate-CY_Ii_bz.js.map} +1 -1
  49. package/dist/chunks/generate-CuOm66dn.js +57 -0
  50. package/dist/chunks/{generate-BtWZCvuO.js.map → generate-CuOm66dn.js.map} +1 -1
  51. package/dist/chunks/{generate-BrOPb9tW.js → generate-DYq5Oj58.js} +3 -4
  52. package/dist/chunks/{generate-BrOPb9tW.js.map → generate-DYq5Oj58.js.map} +1 -1
  53. package/dist/chunks/{generate-Crdzw45a.js → generate-F4FDWvFo.js} +13 -14
  54. package/dist/chunks/{generate-Crdzw45a.js.map → generate-F4FDWvFo.js.map} +1 -1
  55. package/dist/chunks/{generate-DgZhFNjO.js → generate-oZ1QeqPr.js} +17 -19
  56. package/dist/chunks/{generate-DgZhFNjO.js.map → generate-oZ1QeqPr.js.map} +1 -1
  57. package/dist/chunks/{generate.runtime-ByC9kOl2.js → generate.runtime-22jW8aVT.js} +37 -41
  58. package/dist/chunks/{generate.runtime-ByC9kOl2.js.map → generate.runtime-22jW8aVT.js.map} +1 -1
  59. package/dist/chunks/{generate.runtime-BfQlxsWK.js → generate.runtime-B06rPt_j.js} +103 -108
  60. package/dist/chunks/{generate.runtime-BfQlxsWK.js.map → generate.runtime-B06rPt_j.js.map} +1 -1
  61. package/dist/chunks/{generate.runtime-CEd3qCtW.js → generate.runtime-BEmSIAop.js} +44 -47
  62. package/dist/chunks/generate.runtime-BEmSIAop.js.map +1 -0
  63. package/dist/chunks/{generate.runtime-DzCVGruq.js → generate.runtime-BgGeOqYG.js} +19 -21
  64. package/dist/chunks/{generate.runtime-DzCVGruq.js.map → generate.runtime-BgGeOqYG.js.map} +1 -1
  65. package/dist/chunks/generate.runtime-Bz9z0VPR.js +108 -0
  66. package/dist/chunks/{generate.runtime-DVUj1LJK.js.map → generate.runtime-Bz9z0VPR.js.map} +1 -1
  67. package/dist/chunks/{generate.runtime-CHaE6Mm9.js → generate.runtime-C37djibw.js} +25 -27
  68. package/dist/chunks/{generate.runtime-CHaE6Mm9.js.map → generate.runtime-C37djibw.js.map} +1 -1
  69. package/dist/chunks/{generate.runtime-BsjcGBme.js → generate.runtime-CM3bj0nP.js} +12 -14
  70. package/dist/chunks/{generate.runtime-BsjcGBme.js.map → generate.runtime-CM3bj0nP.js.map} +1 -1
  71. package/dist/chunks/generate.runtime-CMuxVUIY.js +46 -0
  72. package/dist/chunks/{generate.runtime-BfM3dX_R.js.map → generate.runtime-CMuxVUIY.js.map} +1 -1
  73. package/dist/chunks/{generate.runtime-DRZDjZqw.js → generate.runtime-CVqPHddZ.js} +44 -46
  74. package/dist/chunks/generate.runtime-CVqPHddZ.js.map +1 -0
  75. package/dist/chunks/generate.runtime-Cco2mFW2.js +63 -0
  76. package/dist/chunks/{generate.runtime-taYl9Tg5.js.map → generate.runtime-Cco2mFW2.js.map} +1 -1
  77. package/dist/chunks/generate.runtime-Cg-dfN9B.js +48 -0
  78. package/dist/chunks/{generate.runtime-TKR-qAJM.js.map → generate.runtime-Cg-dfN9B.js.map} +1 -1
  79. package/dist/chunks/{generate.runtime-C2pIioyZ.js → generate.runtime-Cgam_XCc.js} +47 -50
  80. package/dist/chunks/{generate.runtime-C2pIioyZ.js.map → generate.runtime-Cgam_XCc.js.map} +1 -1
  81. package/dist/chunks/{generate.runtime-DqYYJXAz.js → generate.runtime-CjqX4tDg.js} +5 -6
  82. package/dist/chunks/{generate.runtime-DqYYJXAz.js.map → generate.runtime-CjqX4tDg.js.map} +1 -1
  83. package/dist/chunks/generate.runtime-Cry-DBNl.js +111 -0
  84. package/dist/chunks/{generate.runtime-2GD2E1NK.js.map → generate.runtime-Cry-DBNl.js.map} +1 -1
  85. package/dist/chunks/{generate.runtime-DGmpjkRe.js → generate.runtime-Ct7cG8va.js} +76 -79
  86. package/dist/chunks/generate.runtime-Ct7cG8va.js.map +1 -0
  87. package/dist/chunks/generate.runtime-Cxg1b_BK.js +63 -0
  88. package/dist/chunks/{generate.runtime-CXGiQWDK.js.map → generate.runtime-Cxg1b_BK.js.map} +1 -1
  89. package/dist/chunks/{generate.runtime-4TxcYKld.js → generate.runtime-CyWuhV6m.js} +16 -18
  90. package/dist/chunks/{generate.runtime-4TxcYKld.js.map → generate.runtime-CyWuhV6m.js.map} +1 -1
  91. package/dist/chunks/{generate.runtime-C_5Ghjri.js → generate.runtime-D769VJFt.js} +3 -4
  92. package/dist/chunks/{generate.runtime-C_5Ghjri.js.map → generate.runtime-D769VJFt.js.map} +1 -1
  93. package/dist/chunks/{generate.runtime-s9ai7PxV.js → generate.runtime-DGnXHELM.js} +84 -89
  94. package/dist/chunks/{generate.runtime-s9ai7PxV.js.map → generate.runtime-DGnXHELM.js.map} +1 -1
  95. package/dist/chunks/{generate.runtime-USnFqTbU.js → generate.runtime-DHJqOJTr.js} +93 -98
  96. package/dist/chunks/{generate.runtime-USnFqTbU.js.map → generate.runtime-DHJqOJTr.js.map} +1 -1
  97. package/dist/chunks/{generate.runtime-C9yduilW.js → generate.runtime-DICcLOts.js} +19 -22
  98. package/dist/chunks/{generate.runtime-C9yduilW.js.map → generate.runtime-DICcLOts.js.map} +1 -1
  99. package/dist/chunks/generate.runtime-DWHoDisZ.js +42 -0
  100. package/dist/chunks/{generate.runtime-g6qaIY3k.js.map → generate.runtime-DWHoDisZ.js.map} +1 -1
  101. package/dist/chunks/{generate.runtime-B2DI0x05.js → generate.runtime-DfHFd8xs.js} +36 -44
  102. package/dist/chunks/{generate.runtime-B2DI0x05.js.map → generate.runtime-DfHFd8xs.js.map} +1 -1
  103. package/dist/chunks/{generate.runtime-BO1KyRcJ.js → generate.runtime-DhNspd-h.js} +64 -76
  104. package/dist/chunks/generate.runtime-DhNspd-h.js.map +1 -0
  105. package/dist/chunks/{generate.runtime-BPVZsAL0.js → generate.runtime-DkS7CBmK.js} +8 -10
  106. package/dist/chunks/{generate.runtime-BPVZsAL0.js.map → generate.runtime-DkS7CBmK.js.map} +1 -1
  107. package/dist/chunks/generate.runtime-Dtae524O.js +34 -0
  108. package/dist/chunks/{generate.runtime-Du8puIJQ.js.map → generate.runtime-Dtae524O.js.map} +1 -1
  109. package/dist/chunks/{generate.runtime-DIkM5xIB.js → generate.runtime-Dtf3tF3-.js} +82 -92
  110. package/dist/chunks/generate.runtime-Dtf3tF3-.js.map +1 -0
  111. package/dist/chunks/{generate.runtime-7sU7RzIA.js → generate.runtime-DvTbN-no.js} +88 -145
  112. package/dist/chunks/{generate.runtime-7sU7RzIA.js.map → generate.runtime-DvTbN-no.js.map} +1 -1
  113. package/dist/chunks/{generate.runtime-CvtSK0E1.js → generate.runtime-EB8vpc7D.js} +57 -66
  114. package/dist/chunks/{generate.runtime-CvtSK0E1.js.map → generate.runtime-EB8vpc7D.js.map} +1 -1
  115. package/dist/chunks/{generate.runtime-UrLaWKvN.js → generate.runtime-TCVlsBbJ.js} +7 -8
  116. package/dist/chunks/{generate.runtime-UrLaWKvN.js.map → generate.runtime-TCVlsBbJ.js.map} +1 -1
  117. package/dist/chunks/{generate.runtime-B8y_l-6N.js → generate.runtime-YFyuyFhh.js} +108 -132
  118. package/dist/chunks/generate.runtime-YFyuyFhh.js.map +1 -0
  119. package/dist/chunks/{generate.runtime-bWGwyz2U.js → generate.runtime-cYh0CQ5d.js} +36 -41
  120. package/dist/chunks/{generate.runtime-bWGwyz2U.js.map → generate.runtime-cYh0CQ5d.js.map} +1 -1
  121. package/dist/chunks/generate.runtime-erWI6j7m.js +64 -0
  122. package/dist/chunks/{generate.runtime-B-WOQsda.js.map → generate.runtime-erWI6j7m.js.map} +1 -1
  123. package/dist/chunks/{generate.runtime-DI73x08q.js → generate.runtime-hq8xt0m_.js} +21 -23
  124. package/dist/chunks/generate.runtime-hq8xt0m_.js.map +1 -0
  125. package/dist/chunks/{generate.runtime-C4hyve9h.js → generate.runtime-i3tMIA1A.js} +85 -108
  126. package/dist/chunks/{generate.runtime-C4hyve9h.js.map → generate.runtime-i3tMIA1A.js.map} +1 -1
  127. package/dist/chunks/generate.runtime-j_5K3Uue.js +120 -0
  128. package/dist/chunks/generate.runtime-j_5K3Uue.js.map +1 -0
  129. package/dist/chunks/{generate.runtime-BEvi6bml.js → generate.runtime-mE0knt2T.js} +34 -38
  130. package/dist/chunks/{generate.runtime-BEvi6bml.js.map → generate.runtime-mE0knt2T.js.map} +1 -1
  131. package/dist/chunks/{layout.svelte-Cb12mxua.js → layout.svelte-B6wOQ7SM.js} +10 -11
  132. package/dist/chunks/{layout.svelte-Cb12mxua.js.map → layout.svelte-B6wOQ7SM.js.map} +1 -1
  133. package/dist/chunks/{lib-specifier-Cngo1zF_.js → lib-specifier-C3M0WTev.js} +2 -3
  134. package/dist/chunks/{lib-specifier-Cngo1zF_.js.map → lib-specifier-C3M0WTev.js.map} +1 -1
  135. package/dist/chunks/{load-function-Dmkhg1pQ.js → load-function-BFvIVsh7.js} +3 -4
  136. package/dist/chunks/{load-function-Dmkhg1pQ.js.map → load-function-BFvIVsh7.js.map} +1 -1
  137. package/dist/chunks/{logger-CQONztPm.js → logger-t1HxmpG2.js} +2 -3
  138. package/dist/chunks/{logger-CQONztPm.js.map → logger-t1HxmpG2.js.map} +1 -1
  139. package/dist/chunks/{modify-file-D9U2LXEa.js → modify-file-CRZ_gMg0.js} +7 -10
  140. package/dist/chunks/{modify-file-D9U2LXEa.js.map → modify-file-CRZ_gMg0.js.map} +1 -1
  141. package/dist/chunks/{modify-nav-user-CJ1LevSU.js → modify-nav-user--7OwY9fI.js} +7 -16
  142. package/dist/chunks/{modify-nav-user-CJ1LevSU.js.map → modify-nav-user--7OwY9fI.js.map} +1 -1
  143. package/dist/chunks/{modify-nav-user-iUpv2lm-.js → modify-nav-user-D42kWyU6.js} +8 -14
  144. package/dist/chunks/{modify-nav-user-iUpv2lm-.js.map → modify-nav-user-D42kWyU6.js.map} +1 -1
  145. package/dist/chunks/modify-svelte-config-remote-wE5K2bU_.js +20 -0
  146. package/dist/chunks/{modify-svelte-config-remote-CEyYydL7.js.map → modify-svelte-config-remote-wE5K2bU_.js.map} +1 -1
  147. package/dist/chunks/{modify-user-signup-DLtopazD.js → modify-user-signup-ENhadGKH.js} +5 -6
  148. package/dist/chunks/{modify-user-signup-DLtopazD.js.map → modify-user-signup-ENhadGKH.js.map} +1 -1
  149. package/dist/chunks/{modify-utils-Cw-on_cL.js → modify-utils--zro3IGe.js} +3 -4
  150. package/dist/chunks/{modify-utils-Cw-on_cL.js.map → modify-utils--zro3IGe.js.map} +1 -1
  151. package/dist/chunks/{package-imports-B9Asv3ZH.js → package-imports-CcIIHbp5.js} +3 -4
  152. package/dist/chunks/{package-imports-B9Asv3ZH.js.map → package-imports-CcIIHbp5.js.map} +1 -1
  153. package/dist/chunks/{pocketbase-C5GS-Dh5.js → pocketbase-CvsJYXj-.js} +2 -3
  154. package/dist/chunks/{pocketbase-C5GS-Dh5.js.map → pocketbase-CvsJYXj-.js.map} +1 -1
  155. package/dist/chunks/{pocketbase-DpudAAmd.js → pocketbase-YG9yht8R.js} +2 -3
  156. package/dist/chunks/{pocketbase-DpudAAmd.js.map → pocketbase-YG9yht8R.js.map} +1 -1
  157. package/dist/chunks/{pocketbase-BTR3gI8o.js → pocketbase-gUn2UrDd.js} +6 -14
  158. package/dist/chunks/{pocketbase-BTR3gI8o.js.map → pocketbase-gUn2UrDd.js.map} +1 -1
  159. package/dist/chunks/{providers-CpRRQdMg.js → providers-BB3Z2TrN.js} +4 -5
  160. package/dist/chunks/{providers-CpRRQdMg.js.map → providers-BB3Z2TrN.js.map} +1 -1
  161. package/dist/chunks/{providers-CL9kQ4hp.js → providers-tjlFH5di.js} +4 -5
  162. package/dist/chunks/{providers-CL9kQ4hp.js.map → providers-tjlFH5di.js.map} +1 -1
  163. package/dist/chunks/{rolldown-runtime-5HNE8Q1r.js → rolldown-runtime-CwxnZyOB.js} +1 -2
  164. package/dist/chunks/{root-layout.svelte-CUVbnlX-.js → root-layout.svelte-DE0c_y-T.js} +12 -16
  165. package/dist/chunks/{root-layout.svelte-CUVbnlX-.js.map → root-layout.svelte-DE0c_y-T.js.map} +1 -1
  166. package/dist/chunks/{shared-CAjLx_8Z.js → shared-DE-J_b1j.js} +4 -5
  167. package/dist/chunks/{shared-CAjLx_8Z.js.map → shared-DE-J_b1j.js.map} +1 -1
  168. package/dist/chunks/{site-D0IuWkAR.js → site-B9hDxucR.js} +11 -12
  169. package/dist/chunks/{site-D0IuWkAR.js.map → site-B9hDxucR.js.map} +1 -1
  170. package/dist/chunks/{stripe-customer-B3tP8gtD.js → stripe-customer-5S-nOXP1.js} +2 -3
  171. package/dist/chunks/stripe-customer-5S-nOXP1.js.map +1 -0
  172. package/dist/chunks/{svelte-file-Dv5-bl79.js → svelte-file-DfplF3BU.js} +2 -3
  173. package/dist/chunks/{svelte-file-Dv5-bl79.js.map → svelte-file-DfplF3BU.js.map} +1 -1
  174. package/dist/chunks/{table-core-BKBoEStB.js → table-core-BXmnfjln.js} +26 -33
  175. package/dist/chunks/{table-core-BKBoEStB.js.map → table-core-BXmnfjln.js.map} +1 -1
  176. package/dist/chunks/{taggedTemplateLiteral-KSUnuvOk.js → taggedTemplateLiteral-CLenToGE.js} +1 -2
  177. package/dist/chunks/{test-setup-CbCXmPkE.js → test-setup-CbwhAJT4.js} +8 -11
  178. package/dist/chunks/{test-setup-CbCXmPkE.js.map → test-setup-CbwhAJT4.js.map} +1 -1
  179. package/dist/chunks/{ts-morph-helpers-CHI9wAil.js → ts-morph-helpers-B4KZXP44.js} +2 -3
  180. package/dist/chunks/{ts-morph-helpers-CHI9wAil.js.map → ts-morph-helpers-B4KZXP44.js.map} +1 -1
  181. package/dist/chunks/{ui-B3Db8cQg.js → ui-Ct6YQuPw.js} +53 -55
  182. package/dist/chunks/{ui-B3Db8cQg.js.map → ui-Ct6YQuPw.js.map} +1 -1
  183. package/dist/chunks/{ui-DD4NltyN.js → ui-D5xgIDR_.js} +3 -4
  184. package/dist/chunks/{ui-DD4NltyN.js.map → ui-D5xgIDR_.js.map} +1 -1
  185. package/dist/chunks/{unmodify-load-Buak-r1f.js → unmodify-load-CdWXJ_Ac.js} +3 -4
  186. package/dist/chunks/{unmodify-load-Buak-r1f.js.map → unmodify-load-CdWXJ_Ac.js.map} +1 -1
  187. package/dist/chunks/{util-BLYliuUK.js → util-ILWdjRAd.js} +2 -3
  188. package/dist/chunks/{util-BLYliuUK.js.map → util-ILWdjRAd.js.map} +1 -1
  189. package/dist/chunks/{whatsapp-Pya8Zi07.js → whatsapp-Bt4o4_q2.js} +3 -4
  190. package/dist/chunks/{whatsapp-Pya8Zi07.js.map → whatsapp-Bt4o4_q2.js.map} +1 -1
  191. package/dist/chunks/write-result-B5KFCqxw.js +487 -0
  192. package/dist/chunks/{write-result-BWXq9RRn.js.map → write-result-B5KFCqxw.js.map} +1 -1
  193. package/dist/chunks/{wuchale-config-c3Q4JVSF.js → wuchale-config-CNXoq4rc.js} +2 -3
  194. package/dist/chunks/{wuchale-config-c3Q4JVSF.js.map → wuchale-config-CNXoq4rc.js.map} +1 -1
  195. package/dist/index.js +1375 -1456
  196. package/dist/index.js.map +1 -1
  197. package/package.json +1 -1
  198. package/dist/chunks/_page-B6yd6_Vl.js.map +0 -1
  199. package/dist/chunks/_page-DoPdZgZv.js.map +0 -1
  200. package/dist/chunks/generate-BtWZCvuO.js +0 -58
  201. package/dist/chunks/generate.runtime-2GD2E1NK.js +0 -114
  202. package/dist/chunks/generate.runtime-B-WOQsda.js +0 -67
  203. package/dist/chunks/generate.runtime-B8y_l-6N.js.map +0 -1
  204. package/dist/chunks/generate.runtime-BO1KyRcJ.js.map +0 -1
  205. package/dist/chunks/generate.runtime-BfM3dX_R.js +0 -48
  206. package/dist/chunks/generate.runtime-CEd3qCtW.js.map +0 -1
  207. package/dist/chunks/generate.runtime-CXGiQWDK.js +0 -64
  208. package/dist/chunks/generate.runtime-DGmpjkRe.js.map +0 -1
  209. package/dist/chunks/generate.runtime-DI73x08q.js.map +0 -1
  210. package/dist/chunks/generate.runtime-DIkM5xIB.js.map +0 -1
  211. package/dist/chunks/generate.runtime-DRZDjZqw.js.map +0 -1
  212. package/dist/chunks/generate.runtime-DVUj1LJK.js +0 -112
  213. package/dist/chunks/generate.runtime-Deg1Tz9u.js +0 -124
  214. package/dist/chunks/generate.runtime-Deg1Tz9u.js.map +0 -1
  215. package/dist/chunks/generate.runtime-Du8puIJQ.js +0 -35
  216. package/dist/chunks/generate.runtime-TKR-qAJM.js +0 -50
  217. package/dist/chunks/generate.runtime-g6qaIY3k.js +0 -43
  218. package/dist/chunks/generate.runtime-taYl9Tg5.js +0 -65
  219. package/dist/chunks/modify-svelte-config-remote-CEyYydL7.js +0 -42
  220. package/dist/chunks/stripe-customer-B3tP8gtD.js.map +0 -1
  221. package/dist/chunks/write-result-BWXq9RRn.js +0 -499
@@ -1,16 +1,16 @@
1
- import { a as e } from "./util-BLYliuUK.js";
2
- import { t } from "./dedent-Gq6Krl4n.js";
3
- import { n } from "./logger-CQONztPm.js";
4
- import { t as r } from "./env-vars-mnRA0hOe.js";
5
- import { c as i, i as a, n as o, o as s } from "./ts-morph-helpers-CHI9wAil.js";
6
- import { r as c } from "./modify-file-D9U2LXEa.js";
7
- import { modifyEnvVarsFiles as l } from "./env-vars-XvAeH6u5.js";
8
- import { r as u } from "./compose-handle-BBlamPfx.js";
9
- import { c as d, i as f, n as p, o as m, r as h, t as g } from "./test-setup-CbCXmPkE.js";
1
+ import { n as e } from "./logger-t1HxmpG2.js";
2
+ import { r as t } from "./modify-file-CRZ_gMg0.js";
3
+ import { c as n, i as r, n as i, o as a, r as o, t as s } from "./test-setup-CbwhAJT4.js";
4
+ import { a as c } from "./util-ILWdjRAd.js";
5
+ import { t as l } from "./dedent-CCUOcPFW.js";
6
+ import { r as u } from "./compose-handle-Da7m6lV_.js";
7
+ import { c as d, i as f, n as p, o as m } from "./ts-morph-helpers-B4KZXP44.js";
8
+ import { modifyEnvVarsFiles as h } from "./env-vars-CVn2076k.js";
9
+ import { t as g } from "./env-vars-CUh4mLM_.js";
10
10
  import _ from "node:fs";
11
11
  import v from "node:path";
12
12
  import { Node as y, Project as b, QuoteKind as x } from "ts-morph";
13
- //#region src/patterns/enable/backend/modifies/tsconfig.ts
13
+ // src/patterns/enable/backend/modifies/tsconfig.ts
14
14
  var S = ".svelte-kit/types/pocketbase/*.d.ts", C = [
15
15
  "ts",
16
16
  "mts",
@@ -63,19 +63,18 @@ function w(e) {
63
63
  changed: !0
64
64
  };
65
65
  }
66
- //#endregion
67
- //#region src/patterns/enable/backend/modifies/hooks.server.ts
66
+ // src/patterns/enable/backend/modifies/hooks.server.ts
68
67
  var T = [
69
68
  "POCKETBASE_URL",
70
69
  "POCKETBASE_SUPERUSER_EMAIL",
71
70
  "POCKETBASE_SUPERUSER_PASSWORD"
72
- ], E = t`
71
+ ], E = l`
73
72
  handlePocketbase({
74
73
  pocketbaseUrl: POCKETBASE_URL,
75
74
  superuserEmail: POCKETBASE_SUPERUSER_EMAIL,
76
75
  superuserPassword: POCKETBASE_SUPERUSER_PASSWORD
77
76
  })
78
- `, D = t`
77
+ `, D = l`
79
78
  Add the PocketBase handle to the exported handle in src/hooks.server.ts:
80
79
 
81
80
  import { sequence } from '@sveltejs/kit/hooks';
@@ -112,44 +111,43 @@ function O(e) {
112
111
  status: "success",
113
112
  changed: !1
114
113
  };
115
- let c = r.statement;
116
- if (c && y.isJSDocable(c)) for (let e of c.getJsDocs()) e.getText().includes("vela legal") && e.remove();
117
- i(n, ["@velastack/kit"]);
118
- for (let e of T) a(n, "$app/env/private", e);
119
- return a(n, "@velastack/pocketbase", "handlePocketbase"), s(n), o(n), n.saveSync(), {
114
+ let i = r.statement;
115
+ if (i && y.isJSDocable(i)) for (let e of i.getJsDocs()) e.getText().includes("vela legal") && e.remove();
116
+ d(n, ["@velastack/kit"]);
117
+ for (let e of T) f(n, "$app/env/private", e);
118
+ return f(n, "@velastack/pocketbase", "handlePocketbase"), m(n), p(n), n.saveSync(), {
120
119
  status: "success",
121
120
  changed: n.getFullText() !== t
122
121
  };
123
122
  }
124
- //#endregion
125
- //#region src/patterns/enable/backend/generate.runtime.ts
126
- async function k(t) {
127
- let i = n(t), a = [], o = [], s = (t, n) => o.push({
128
- path: t,
129
- language: e(t),
130
- content: n,
123
+ // src/patterns/enable/backend/generate.runtime.ts
124
+ async function k(l) {
125
+ let u = e(l), d = [], f = [], p = (e, t) => f.push({
126
+ path: e,
127
+ language: c(e),
128
+ content: t,
131
129
  status: "success"
132
130
  });
133
- i.info("Modifying adapter config");
134
- let u = d(t.root), y = c(u.filePath, u.outcome);
135
- y && a.push(y);
136
- let b = v.join(t.root, "src", "hooks.server.ts"), x = c(b, O(b));
137
- x && (i.info("Modifying hooks.server.ts"), a.push(x)), i.info("Declaring the PocketBase variables in src/env.ts");
138
- let S = l(t.root, r);
139
- S.create && o.push(S.create), S.modify && a.push(S.modify), i.info("Modifying .gitignore");
140
- let C = v.join(t.root, ".gitignore"), T = c(C, m(C));
141
- T && a.push(T);
142
- let E = v.join(t.root, "test", "setup.ts");
131
+ u.info("Modifying adapter config");
132
+ let m = n(l.root), y = t(m.filePath, m.outcome);
133
+ y && d.push(y);
134
+ let b = v.join(l.root, "src", "hooks.server.ts"), x = t(b, O(b));
135
+ x && (u.info("Modifying hooks.server.ts"), d.push(x)), u.info("Declaring the PocketBase variables in src/env.ts");
136
+ let S = h(l.root, g);
137
+ S.create && f.push(S.create), S.modify && d.push(S.modify), u.info("Modifying .gitignore");
138
+ let C = v.join(l.root, ".gitignore"), T = t(C, a(C));
139
+ T && d.push(T);
140
+ let E = v.join(l.root, "test", "setup.ts");
143
141
  if (_.existsSync(E)) {
144
- i.info("Modifying test/setup.ts");
145
- let e = c(E, f(E));
146
- e && a.push(e);
147
- } else i.info("Creating test/setup.ts"), s("test/setup.ts", p);
148
- h(t.root) || (i.info("Creating vitest.config.ts"), s("vitest.config.ts", g));
149
- let D = v.join(t.root, "tsconfig.json"), k = c(D, w(t.root));
150
- return k && (i.info("Modifying tsconfig.json"), a.push(k)), {
151
- creates: o,
152
- modifies: a,
142
+ u.info("Modifying test/setup.ts");
143
+ let e = t(E, r(E));
144
+ e && d.push(e);
145
+ } else u.info("Creating test/setup.ts"), p("test/setup.ts", i);
146
+ o(l.root) || (u.info("Creating vitest.config.ts"), p("vitest.config.ts", s));
147
+ let D = v.join(l.root, "tsconfig.json"), k = t(D, w(l.root));
148
+ return k && (u.info("Modifying tsconfig.json"), d.push(k)), {
149
+ creates: f,
150
+ modifies: d,
153
151
  deletes: [],
154
152
  components: [],
155
153
  packages: [],
@@ -158,7 +156,6 @@ async function k(t) {
158
156
  collectionDrops: []
159
157
  };
160
158
  }
161
- //#endregion
162
159
  export { k as generate };
163
160
 
164
- //# sourceMappingURL=generate.runtime-CEd3qCtW.js.map
161
+ //# sourceMappingURL=generate.runtime-BEmSIAop.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.runtime-BEmSIAop.js","names":["getLogger","modifyOutcomeToFile","modifySvelteConfig","modifyTestSetup","WITH_BACKEND","modifyGitignore","hasVitestConfig","VITEST_CONFIG","languageFromPath","dedent","replaceHandle","pruneUnusedImports","ensureNamedImport","ensureBlankLineAfterImports","formatLikeSource","BACKEND_ENV_VARS","fs","path","POCKETBASE_TYPES","VITEST_CONFIGS","ext","modifyTsconfigBackend","filePath","root","original","vitestConfig","name","wanted","config","entry","include","normalize","has","existing","next","insertAfter","index","after","i","indent","POCKETBASE_ENV_NAMES","POCKETBASE_HANDLE","FAILURE_HINT","modifyHooksServerBackend","hooksServerPath","sourceFile","Project","QuoteKind","composed","statement","Node","doc","generate","logger","options","modifies","creates","create","adapter","svelteConfigFile","hooksServerFile","envVars","modifyEnvVarsFiles","gitignorePath","gitignoreFile","testSetupPath","testSetupFile","tsconfigPath","tsconfigFile"],"sources":["../../src/patterns/enable/backend/modifies/tsconfig.ts","../../src/patterns/enable/backend/modifies/hooks.server.ts","../../src/patterns/enable/backend/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\n/** Where `vela sync` writes PocketBase's generated types (`Schemas`, the typed client). */\nexport const POCKETBASE_TYPES = \".svelte-kit/types/pocketbase/*.d.ts\";\n\nconst VITEST_CONFIGS = [\"ts\", \"mts\", \"js\", \"mjs\"].map(\n (ext) => `vitest.config.${ext}`,\n);\n\n/**\n * SvelteKit 3's `$app/tsconfig` lists no files: the project's own `include`\n * decides what is type-checked, and `sv create` writes `[\"src\",\n * \"vite.config.ts\"]`. A backend adds three things that have to be in it, as\n * they are in vela's minimal template: `test` (the server-test context that\n * every `server.test.ts` reads), the vitest config, and PocketBase's generated\n * types, without which `Schemas` is missing from `@velastack/pocketbase`.\n *\n * Entries already there stay, in their order. A tsconfig with no `include`\n * checks everything already; one that is not plain JSON (comments) is left\n * alone with the entries to add.\n */\nexport function modifyTsconfigBackend(root: string): ModifyOutcome {\n const filePath = path.join(root, \"tsconfig.json\");\n if (!fs.existsSync(filePath)) {\n return { status: \"success\", changed: false };\n }\n const original = fs.readFileSync(filePath, \"utf8\");\n const vitestConfig =\n VITEST_CONFIGS.find((name) => fs.existsSync(path.join(root, name))) ??\n \"vitest.config.ts\";\n const wanted = [\"test\", vitestConfig, POCKETBASE_TYPES];\n\n let config: Record<string, unknown>;\n try {\n config = JSON.parse(original) as Record<string, unknown>;\n } catch {\n return {\n status: \"failed\",\n message: `Add these to the \"include\" array of tsconfig.json: ${wanted\n .map((entry) => JSON.stringify(entry))\n .join(\", \")}`,\n };\n }\n const include = config.include;\n if (include === undefined) {\n return { status: \"success\", changed: false };\n }\n if (!Array.isArray(include)) {\n return {\n status: \"failed\",\n message: `tsconfig.json \"include\" is not an array; it needs ${wanted.join(\", \")}`,\n };\n }\n\n const normalize = (entry: unknown) =>\n typeof entry === \"string\" ? entry.replace(/^\\.\\//, \"\") : entry;\n const has = (entry: string) =>\n include.some((existing) => normalize(existing) === entry);\n const next = [...include] as unknown[];\n const insertAfter = (entry: string, after: (e: unknown) => boolean) => {\n if (has(entry)) return;\n let index = -1;\n next.forEach((e, i) => {\n if (after(e)) index = i;\n });\n next.splice(index === -1 ? next.length : index + 1, 0, entry);\n };\n insertAfter(\"test\", (e) => normalize(e) === \"src\");\n insertAfter(vitestConfig, (e) =>\n /^vite\\.config\\.[cm]?[jt]s$/.test(String(normalize(e))),\n );\n insertAfter(POCKETBASE_TYPES, () => false);\n\n if (next.length === include.length) {\n return { status: \"success\", changed: false };\n }\n config.include = next;\n const indent = original.match(/^\\{\\s*\\n([\\t ]+)/)?.[1] ?? \"\\t\";\n fs.writeFileSync(filePath, `${JSON.stringify(config, null, indent)}\\n`);\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Node, Project, QuoteKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { replaceHandle } from \"../../../../runtime/compose-handle\";\nimport {\n ensureBlankLineAfterImports,\n ensureNamedImport,\n pruneUnusedImports,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\n\n/** The variables the handle reads, imported from `$app/env/private`. */\nexport const POCKETBASE_ENV_NAMES = [\n \"POCKETBASE_URL\",\n \"POCKETBASE_SUPERUSER_EMAIL\",\n \"POCKETBASE_SUPERUSER_PASSWORD\",\n] as const;\n\n/** The handle `creates/src/hooks.server.ts` exports, for a file that already exists. */\nexport const POCKETBASE_HANDLE = dedent`\n handlePocketbase({\n \tpocketbaseUrl: POCKETBASE_URL,\n \tsuperuserEmail: POCKETBASE_SUPERUSER_EMAIL,\n \tsuperuserPassword: POCKETBASE_SUPERUSER_PASSWORD\n })\n`;\n\nconst FAILURE_HINT = dedent`\n Add the PocketBase handle to the exported handle in src/hooks.server.ts:\n\n import { sequence } from '@sveltejs/kit/hooks';\n import {\n \tPOCKETBASE_URL,\n \tPOCKETBASE_SUPERUSER_EMAIL,\n \tPOCKETBASE_SUPERUSER_PASSWORD\n } from '$app/env/private';\n import { handlePocketbase } from '@velastack/pocketbase';\n\n export const handle = sequence(\n \t/* your existing handle */,\n \t${POCKETBASE_HANDLE.replace(/\\n/g, \"\\n\\t\")}\n );\n`;\n\n/**\n * Compose the PocketBase handle into a `hooks.server.ts` the project already\n * has, instead of the create overwriting it: a static site's, or one i18n or\n * content negotiation wrote. It takes `handleStatic()`'s place, since\n * `handlePocketbase` does what that did and more; otherwise it goes last, so\n * the handles already there keep running first.\n */\nexport function modifyHooksServerBackend(\n hooksServerPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n // The create writes it.\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(hooksServerPath, \"utf8\");\n const project = new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n const composed = replaceHandle(sourceFile, \"handleStatic\", {\n expression: POCKETBASE_HANDLE,\n name: \"handlePocketbase\",\n position: \"last\",\n });\n if (composed.status === \"unsupported\") {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n if (composed.status === \"unchanged\") {\n return { status: \"success\", changed: false };\n }\n\n // The static template's comment explains handleStatic(). Where that was the\n // whole handle, replaceHandle already dropped it; in a sequence (i18n or\n // negotiation composed in since) it is still there, describing a handle\n // that is gone.\n const statement = composed.statement;\n if (statement && Node.isJSDocable(statement)) {\n for (const doc of statement.getJsDocs()) {\n if (doc.getText().includes(\"vela legal\")) doc.remove();\n }\n }\n\n pruneUnusedImports(sourceFile, [\"@velastack/kit\"]);\n for (const name of POCKETBASE_ENV_NAMES) {\n ensureNamedImport(sourceFile, \"$app/env/private\", name);\n }\n ensureNamedImport(sourceFile, \"@velastack/pocketbase\", \"handlePocketbase\");\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 path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { modifySvelteConfig } from \"./modifies/svelte-config\";\nimport { modifyGitignore } from \"./modifies/gitignore\";\nimport { modifyTsconfigBackend } from \"./modifies/tsconfig\";\nimport { languageFromPath } from \"../../../core/util\";\nimport {\n hasVitestConfig,\n modifyTestSetup,\n VITEST_CONFIG,\n WITH_BACKEND,\n} from \"./modifies/test-setup\";\nimport { modifyHooksServerBackend } from \"./modifies/hooks.server\";\nimport { modifyEnvVarsFiles } from \"../../../runtime/env-vars\";\nimport { BACKEND_ENV_VARS } from \"./env-vars\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n const creates: File[] = [];\n const create = (filePath: string, content: string) =>\n creates.push({\n path: filePath,\n language: languageFromPath(filePath),\n content,\n status: \"success\",\n });\n\n logger.info(\"Modifying adapter config\");\n const adapter = modifySvelteConfig(options.root);\n const svelteConfigFile = modifyOutcomeToFile(\n adapter.filePath,\n adapter.outcome,\n );\n if (svelteConfigFile) modifies.push(svelteConfigFile);\n\n // A hooks.server.ts the project already has keeps its handles; the create\n // only writes the file where there is none (see `keepMissing` in index.ts).\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n const hooksServerFile = modifyOutcomeToFile(\n hooksServerPath,\n modifyHooksServerBackend(hooksServerPath),\n );\n if (hooksServerFile) {\n logger.info(\"Modifying hooks.server.ts\");\n modifies.push(hooksServerFile);\n }\n\n // SvelteKit 3 exposes only declared variables: the handle above reads\n // these three from `$app/env/private`.\n logger.info(\"Declaring the PocketBase variables in src/env.ts\");\n const envVars = modifyEnvVarsFiles(options.root, BACKEND_ENV_VARS);\n if (envVars.create) creates.push(envVars.create);\n if (envVars.modify) modifies.push(envVars.modify);\n\n logger.info(\"Modifying .gitignore\");\n const gitignorePath = path.join(options.root, \".gitignore\");\n const gitignoreFile = modifyOutcomeToFile(\n gitignorePath,\n modifyGitignore(gitignorePath),\n );\n if (gitignoreFile) modifies.push(gitignoreFile);\n\n // A backend brings server tests with it. The static template and a project\n // vela did not create have no harness at all, so what is missing is created:\n // the setup file, and the vitest config that loads it.\n const testSetupPath = path.join(options.root, \"test\", \"setup.ts\");\n if (fs.existsSync(testSetupPath)) {\n logger.info(\"Modifying test/setup.ts\");\n const testSetupFile = modifyOutcomeToFile(\n testSetupPath,\n modifyTestSetup(testSetupPath),\n );\n if (testSetupFile) modifies.push(testSetupFile);\n } else {\n logger.info(\"Creating test/setup.ts\");\n create(\"test/setup.ts\", WITH_BACKEND);\n }\n\n if (!hasVitestConfig(options.root)) {\n logger.info(\"Creating vitest.config.ts\");\n create(\"vitest.config.ts\", VITEST_CONFIG);\n }\n\n // Kit 3's tsconfig lists no files, so the test harness and PocketBase's\n // generated types are type-checked only when the project's include names them.\n const tsconfigPath = path.join(options.root, \"tsconfig.json\");\n const tsconfigFile = modifyOutcomeToFile(\n tsconfigPath,\n modifyTsconfigBackend(options.root),\n );\n if (tsconfigFile) {\n logger.info(\"Modifying tsconfig.json\");\n modifies.push(tsconfigFile);\n }\n\n return {\n creates,\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;;;;;AAKA,IAAakB,IAAmB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EAAgB0D,CAAa,CAC/B;CACA,AAAIC,KAAeT,EAAS,KAAKS,CAAa;CAK9C,IAAMC,IAAgBhD,EAAK,KAAKqC,EAAQ,MAAM,QAAQ,UAAU;CAChE,IAAItC,EAAG,WAAWiD,CAAa,GAAG;EAChC,EAAO,KAAK,yBAAyB;EACrC,IAAMC,IAAgBjE,EACpBgE,GACA9D,EAAgB8D,CAAa,CAC/B;EACA,AAAIC,KAAeX,EAAS,KAAKW,CAAa;CAChD,OAEE,AADAb,EAAO,KAAK,wBAAwB,GACpCI,EAAO,iBAAiBrD,CAAY;CAGtC,AAAKE,EAAgBgD,EAAQ,IAAI,MAC/BD,EAAO,KAAK,2BAA2B,GACvCI,EAAO,oBAAoBlD,CAAa;CAK1C,IAAM4D,IAAelD,EAAK,KAAKqC,EAAQ,MAAM,eAAe,GACtDc,IAAenE,EACnBkE,GACA9C,EAAsBiC,EAAQ,IAAI,CACpC;CAMA,OALIc,MACFf,EAAO,KAAK,yBAAyB,GACrCE,EAAS,KAAKa,CAAY,IAGrB;EACL;EACA;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
@@ -1,18 +1,18 @@
1
- import { t as e } from "./dedent-Gq6Krl4n.js";
2
- import { n as t } from "./logger-CQONztPm.js";
3
- import { o as n } from "./ts-morph-helpers-CHI9wAil.js";
4
- import { r } from "./modify-file-D9U2LXEa.js";
1
+ import { n as e } from "./logger-t1HxmpG2.js";
2
+ import { r as t } from "./modify-file-CRZ_gMg0.js";
3
+ import { t as n } from "./dedent-CCUOcPFW.js";
4
+ import { o as r } from "./ts-morph-helpers-B4KZXP44.js";
5
5
  import i from "node:fs";
6
6
  import a from "node:path";
7
7
  import { Project as o, SyntaxKind as s } from "ts-morph";
8
- //#region src/patterns/enable/api/modifies/hooks.server.ts
9
- var c = e`
8
+ // src/patterns/enable/api/modifies/hooks.server.ts
9
+ var c = n`
10
10
  Configure handlePocketbase() with the api option in hooks.server.ts:
11
11
 
12
12
  handlePocketbase({
13
13
  api: { enabled: true },
14
14
  });
15
- `, l = e`
15
+ `, l = n`
16
16
  Create src/hooks.server.ts with handlePocketbase:
17
17
 
18
18
  import { handlePocketbase } from 'velastack/handle';
@@ -26,18 +26,18 @@ function u(e) {
26
26
  status: "not-found",
27
27
  message: l
28
28
  };
29
- let t = i.readFileSync(e, "utf8"), r = new o().addSourceFileAtPath(e), a = r.getDescendantsOfKind(s.CallExpression).find((e) => e.getExpression().getText() === "handlePocketbase");
29
+ let t = i.readFileSync(e, "utf8"), n = new o().addSourceFileAtPath(e), a = n.getDescendantsOfKind(s.CallExpression).find((e) => e.getExpression().getText() === "handlePocketbase");
30
30
  if (!a) return {
31
31
  status: "failed",
32
32
  message: c
33
33
  };
34
34
  let u = a.getArguments();
35
- if (u.length === 0) return a.addArgument("{ api: { enabled: true } }"), n(r), r.saveSync(), {
35
+ if (u.length === 0) return a.addArgument("{ api: { enabled: true } }"), r(n), n.saveSync(), {
36
36
  status: "success",
37
37
  changed: !0
38
38
  };
39
39
  let d = u[0];
40
- if (d.getKind() !== s.ObjectLiteralExpression) return a.insertArgument(0, "{ api: { enabled: true } }"), n(r), r.saveSync(), {
40
+ if (d.getKind() !== s.ObjectLiteralExpression) return a.insertArgument(0, "{ api: { enabled: true } }"), r(n), n.saveSync(), {
41
41
  status: "success",
42
42
  changed: !0
43
43
  };
@@ -45,7 +45,7 @@ function u(e) {
45
45
  if (!p) return f.addPropertyAssignment({
46
46
  name: "api",
47
47
  initializer: "{ enabled: true }"
48
- }), n(r), r.saveSync(), {
48
+ }), r(n), n.saveSync(), {
49
49
  status: "success",
50
50
  changed: !0
51
51
  };
@@ -59,17 +59,16 @@ function u(e) {
59
59
  });
60
60
  }
61
61
  }
62
- return n(r), r.saveSync(), {
62
+ return r(n), n.saveSync(), {
63
63
  status: "success",
64
- changed: r.getFullText() !== t
64
+ changed: n.getFullText() !== t
65
65
  };
66
66
  }
67
- //#endregion
68
- //#region src/patterns/enable/api/generate.runtime.ts
69
- async function d(e) {
70
- let n = t(e), i = [];
71
- n.info("Modifying hooks.server.ts");
72
- let o = a.join(e.root, "src", "hooks.server.ts"), s = r(o, u(o));
67
+ // src/patterns/enable/api/generate.runtime.ts
68
+ async function d(n) {
69
+ let r = e(n), i = [];
70
+ r.info("Modifying hooks.server.ts");
71
+ let o = a.join(n.root, "src", "hooks.server.ts"), s = t(o, u(o));
73
72
  return s && i.push(s), {
74
73
  creates: [],
75
74
  modifies: i,
@@ -81,7 +80,6 @@ async function d(e) {
81
80
  collectionDrops: []
82
81
  };
83
82
  }
84
- //#endregion
85
83
  export { d as generate };
86
84
 
87
- //# sourceMappingURL=generate.runtime-DzCVGruq.js.map
85
+ //# sourceMappingURL=generate.runtime-BgGeOqYG.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate.runtime-DzCVGruq.js","names":["dedent","getLogger","formatLikeSource","fs","path","FAILURE_HINT","NOT_FOUND_HINT","modifyHooksServer","hooksServerPath","originalSource","sourceFile","Project","callExpr","SyntaxKind","ce","args","firstArg","optionsObj","apiProp","apiInit","apiObj","generate","logger","options","modifies","file","modifyOutcomeToFile"],"sources":["../../src/patterns/enable/api/modifies/hooks.server.ts","../../src/patterns/enable/api/generate.runtime.ts"],"sourcesContent":["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 FAILURE_HINT = dedent`\n Configure handlePocketbase() with the api option in hooks.server.ts:\n\n handlePocketbase({\n api: { enabled: true },\n });\n`;\n\nconst NOT_FOUND_HINT = dedent`\n Create src/hooks.server.ts with handlePocketbase:\n\n import { handlePocketbase } from 'velastack/handle';\n\n export const handle = handlePocketbase({\n api: { enabled: true },\n });\n`;\n\nexport function modifyHooksServer(hooksServerPath: string): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const originalSource = fs.readFileSync(hooksServerPath, \"utf8\");\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n const callExpr = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((ce) => ce.getExpression().getText() === \"handlePocketbase\");\n\n if (!callExpr) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const args = callExpr.getArguments();\n if (args.length === 0) {\n callExpr.addArgument(`{ api: { enabled: true } }`);\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n const firstArg = args[0];\n if (firstArg.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n callExpr.insertArgument(0, `{ api: { enabled: true } }`);\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n const optionsObj = firstArg.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n const apiProp = optionsObj.getProperty(\"api\");\n\n if (!apiProp) {\n optionsObj.addPropertyAssignment({\n name: \"api\",\n initializer: `{ enabled: true }`,\n });\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n if (apiProp.getKind() === SyntaxKind.PropertyAssignment) {\n const apiInit = (\n apiProp as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (apiInit && apiInit.getKind() === SyntaxKind.ObjectLiteralExpression) {\n const apiObj = apiInit as import(\"ts-morph\").ObjectLiteralExpression;\n const enabledProp = apiObj.getProperty(\"enabled\");\n if (!enabledProp) {\n apiObj.addPropertyAssignment({ name: \"enabled\", initializer: \"true\" });\n }\n }\n }\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { modifyHooksServer } from \"./modifies/hooks.server\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n\n logger.info(\"Modifying hooks.server.ts\");\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n const file = modifyOutcomeToFile(\n hooksServerPath,\n modifyHooksServer(hooksServerPath),\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":";;;;;;;;AAMA,IAAMK,IAAe,CAAM;;;;;;GAQrBC,IAAiB,CAAM;;;;;;;;;AAU7B,SAAgBC,EAAkB,GAAwC;CACxE,IAAI,CAACJ,EAAG,WAAWK,CAAe,GAChC,OAAO;EAAE,QAAQ;EAAa,SAASF;CAAe;CAGxD,IAAMG,IAAiBN,EAAG,aAAaK,GAAiB,MAAM,GAExDE,IAAa,IADCC,EACD,CAAA,CAAQ,oBAAoBH,CAAe,GAExDI,IAAWF,EACd,qBAAqBG,EAAW,cAAc,CAAC,CAC/C,MAAM,MAAOC,EAAG,cAAc,CAAC,CAAC,QAAQ,MAAM,kBAAkB;CAEnE,IAAI,CAACF,GACH,OAAO;EAAE,QAAQ;EAAU,SAASP;CAAa;CAGnD,IAAMU,IAAOH,EAAS,aAAa;CACnC,IAAIG,EAAK,WAAW,GAIlB,OAHAH,EAAS,YAAY,4BAA4B,GACjDV,EAAiBQ,CAAU,GAC3BA,EAAW,SAAS,GACb;EAAE,QAAQ;EAAW,SAAS;CAAK;CAG5C,IAAMM,IAAWD,EAAK;CACtB,IAAIC,EAAS,QAAQ,MAAMH,EAAW,yBAIpC,OAHAD,EAAS,eAAe,GAAG,4BAA4B,GACvDV,EAAiBQ,CAAU,GAC3BA,EAAW,SAAS,GACb;EAAE,QAAQ;EAAW,SAAS;CAAK;CAG5C,IAAMO,IAAaD,EAAS,cAAcH,EAAW,uBAAuB,GACtEK,IAAUD,EAAW,YAAY,KAAK;CAE5C,IAAI,CAACC,GAOH,OANAD,EAAW,sBAAsB;EAC/B,MAAM;EACN,aAAa;CACf,CAAC,GACDf,EAAiBQ,CAAU,GAC3BA,EAAW,SAAS,GACb;EAAE,QAAQ;EAAW,SAAS;CAAK;CAG5C,IAAIQ,EAAQ,QAAQ,MAAML,EAAW,oBAAoB;EACvD,IAAMM,IACJD,EACA,eAAe;EACjB,IAAIC,KAAWA,EAAQ,QAAQ,MAAMN,EAAW,yBAAyB;GACvE,IAAMO,IAASD;GAEf,AADoBC,EAAO,YAAY,SAClC,KACHA,EAAO,sBAAsB;IAAE,MAAM;IAAW,aAAa;GAAO,CAAC;EAEzE;CACF;CAIA,OAFAlB,EAAiBQ,CAAU,GAC3BA,EAAW,SAAS,GACb;EACL,QAAQ;EACR,SAASA,EAAW,YAAY,MAAMD;CACxC;AACF;;;ACnFA,eAAsBY,EAAS,GAAkB;CAC/C,IAAMC,IAASrB,EAAUsB,CAAO,GAC1BC,IAAmB,CAAC;CAE1B,EAAO,KAAK,2BAA2B;CACvC,IAAMhB,IAAkBJ,EAAK,KAAKmB,EAAQ,MAAM,OAAO,iBAAiB,GAClEE,IAAOC,EACXlB,GACAD,EAAkBC,CAAe,CACnC;CAGA,OAFIiB,KAAMD,EAAS,KAAKC,CAAI,GAErB;EACL,SAAS,CAAC;EACV;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
1
+ {"version":3,"file":"generate.runtime-BgGeOqYG.js","names":["getLogger","modifyOutcomeToFile","dedent","formatLikeSource","fs","path","FAILURE_HINT","NOT_FOUND_HINT","modifyHooksServer","hooksServerPath","originalSource","sourceFile","Project","callExpr","SyntaxKind","ce","args","firstArg","optionsObj","apiProp","apiInit","apiObj","generate","logger","options","modifies","file"],"sources":["../../src/patterns/enable/api/modifies/hooks.server.ts","../../src/patterns/enable/api/generate.runtime.ts"],"sourcesContent":["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 FAILURE_HINT = dedent`\n Configure handlePocketbase() with the api option in hooks.server.ts:\n\n handlePocketbase({\n api: { enabled: true },\n });\n`;\n\nconst NOT_FOUND_HINT = dedent`\n Create src/hooks.server.ts with handlePocketbase:\n\n import { handlePocketbase } from 'velastack/handle';\n\n export const handle = handlePocketbase({\n api: { enabled: true },\n });\n`;\n\nexport function modifyHooksServer(hooksServerPath: string): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const originalSource = fs.readFileSync(hooksServerPath, \"utf8\");\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n const callExpr = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((ce) => ce.getExpression().getText() === \"handlePocketbase\");\n\n if (!callExpr) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const args = callExpr.getArguments();\n if (args.length === 0) {\n callExpr.addArgument(`{ api: { enabled: true } }`);\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n const firstArg = args[0];\n if (firstArg.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n callExpr.insertArgument(0, `{ api: { enabled: true } }`);\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n const optionsObj = firstArg.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n const apiProp = optionsObj.getProperty(\"api\");\n\n if (!apiProp) {\n optionsObj.addPropertyAssignment({\n name: \"api\",\n initializer: `{ enabled: true }`,\n });\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n if (apiProp.getKind() === SyntaxKind.PropertyAssignment) {\n const apiInit = (\n apiProp as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (apiInit && apiInit.getKind() === SyntaxKind.ObjectLiteralExpression) {\n const apiObj = apiInit as import(\"ts-morph\").ObjectLiteralExpression;\n const enabledProp = apiObj.getProperty(\"enabled\");\n if (!enabledProp) {\n apiObj.addPropertyAssignment({ name: \"enabled\", initializer: \"true\" });\n }\n }\n }\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { modifyHooksServer } from \"./modifies/hooks.server\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n\n logger.info(\"Modifying hooks.server.ts\");\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n const file = modifyOutcomeToFile(\n hooksServerPath,\n modifyHooksServer(hooksServerPath),\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":";;;;;;;;AAMA,IAAMM,IAAe,CAAM;;;;;;GAQrBC,IAAiB,CAAM;;;;;;;;;AAU7B,SAAgBC,EAAkB,GAAwC;CACxE,IAAI,CAACJ,EAAG,WAAWK,CAAe,GAChC,OAAO;EAAE,QAAQ;EAAa,SAASF;CAAe;CAGxD,IAAMG,IAAiBN,EAAG,aAAaK,GAAiB,MAAM,GAExDE,IAAa,IADCC,EACD,CAAA,CAAQ,oBAAoBH,CAAe,GAExDI,IAAWF,EACd,qBAAqBG,EAAW,cAAc,CAAC,CAC/C,MAAM,MAAOC,EAAG,cAAc,CAAC,CAAC,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GAClEE,IAAOzB,EACXQ,GACAD,EAAkBC,CAAe,CACnC;CAGA,OAFIiB,KAAMD,EAAS,KAAKC,CAAI,GAErB;EACL,SAAS,CAAC;EACV;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
@@ -0,0 +1,108 @@
1
+ import { n as e } from "./logger-t1HxmpG2.js";
2
+ import { r as t } from "./modify-file-CRZ_gMg0.js";
3
+ import { _ as n, g as r, n as i, o as a, p as o, u as s } from "./ts-morph-helpers-B4KZXP44.js";
4
+ import { t as c } from "./svelte-file-DfplF3BU.js";
5
+ import { r as l } from "./lib-specifier-C3M0WTev.js";
6
+ import { t as u } from "./shared-DE-J_b1j.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
+ // 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), i = n.getDescendantsOfKind(m.ObjectLiteralExpression);
22
+ for (let e of i) {
23
+ let t = e.getProperty("user");
24
+ t && t.getKind() === m.PropertyAssignment && t.getInitializer()?.getText() === "locals.pb.authStore.record" && t.remove();
25
+ }
26
+ return r(n, "locals"), a(n), n.saveSync(), {
27
+ status: "success",
28
+ changed: n.getFullText() !== t
29
+ };
30
+ }
31
+ // src/patterns/disable/auth/modifies/root-layout.svelte.ts
32
+ function g(e) {
33
+ if (!d.existsSync(e)) return {
34
+ status: "success",
35
+ changed: !1
36
+ };
37
+ let t = d.readFileSync(e, "utf8"), r = new c(t);
38
+ if (!r.hasElement("AuthMenu.Root")) return {
39
+ status: "success",
40
+ changed: !1
41
+ };
42
+ r.removeElementContaining("Navbar.Item", "AuthMenu.Root") || r.removeElement("AuthMenu.Root");
43
+ let a = r.toString().replace(/<script[\s\S]*?<\/script>/g, "");
44
+ return r.modifyScript((e) => {
45
+ let { source: t } = n(e, (e) => {
46
+ s(e, l("components/ui/auth-menu")), s(e, l("components/user-avatar.svelte")), s(e, l("components/ui/avatar")), o(e, "data", a), i(e);
47
+ });
48
+ return t;
49
+ }), r.writeTo(e), {
50
+ status: "success",
51
+ changed: r.hasChanged()
52
+ };
53
+ }
54
+ // src/patterns/disable/auth/modifies/hooks.server.ts
55
+ function _(e) {
56
+ if (!d.existsSync(e)) return {
57
+ status: "success",
58
+ changed: !1
59
+ };
60
+ let t = d.readFileSync(e, "utf8"), n = new p().addSourceFileAtPath(e), r = n.getDescendantsOfKind(m.CallExpression).find((e) => e.getExpression().getText() === "handlePocketbase");
61
+ if (!r) return {
62
+ status: "success",
63
+ changed: !1
64
+ };
65
+ let [i] = r.getArguments();
66
+ if (!i || i.getKind() !== m.ObjectLiteralExpression) return {
67
+ status: "success",
68
+ changed: !1
69
+ };
70
+ let o = i.asKindOrThrow(m.ObjectLiteralExpression), s = o.getProperty("auth");
71
+ return s ? (s.remove(), o.getProperties().length === 0 && r.removeArgument(0), a(n), n.saveSync(), {
72
+ status: "success",
73
+ changed: n.getFullText() !== t
74
+ }) : {
75
+ status: "success",
76
+ changed: !1
77
+ };
78
+ }
79
+ // src/patterns/disable/auth/generate.runtime.ts
80
+ async function v(n) {
81
+ let r = e(n), i = [], a = (e) => {
82
+ e && i.push(e);
83
+ };
84
+ r.info("Reverting +layout.server.ts");
85
+ let o = f.join(n.root, "src", "routes", "+layout.server.ts");
86
+ a(t(o, h(o))), r.info("Reverting root layout");
87
+ let s = [
88
+ f.join(n.root, "src", "routes", "(public)", "root-layout.svelte"),
89
+ f.join(n.root, "src", "routes", "root-layout.svelte"),
90
+ f.join(n.root, "src", "routes", "(public)", "+layout.svelte"),
91
+ f.join(n.root, "src", "routes", "+layout.svelte")
92
+ ], c = s.find((e) => d.existsSync(e)) ?? s[0];
93
+ a(t(c, g(c))), r.info("Reverting hooks.server.ts");
94
+ let l = f.join(n.root, "src", "hooks.server.ts");
95
+ return a(t(l, _(l))), {
96
+ creates: [],
97
+ modifies: i,
98
+ deletes: [],
99
+ components: [],
100
+ packages: [],
101
+ collections: [],
102
+ collectionPatches: [],
103
+ collectionDrops: await u(["oauth_accounts"], n)
104
+ };
105
+ }
106
+ export { v as generate };
107
+
108
+ //# sourceMappingURL=generate.runtime-Bz9z0VPR.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate.runtime-DVUj1LJK.js","names":["libModule","getLogger","planDropsForCollections","withInMemoryScript","removeUnusedBindingElement","ensureBlankLineAfterImports","removePropsBindingIfUnused","removeImportByModuleSpecifier","modifyOutcomeToFile","SvelteFile","fs","path","unmodifyLayoutServer","layoutPath","originalSource","sourceFile","Project","literals","SyntaxKind","obj","userProp","formatLikeSource","unmodifyRootLayoutSvelte","source","file","markup","out","content","sf","unmodifyHooksServer","hooksServerPath","callExpr","ce","firstArg","optionsObj","authProp","generate","logger","options","modifies","pushResult","layoutServerFile","layoutCandidates","layoutFile","p","hooksServerFile"],"sources":["../../src/patterns/disable/auth/modifies/+layout.server.ts","../../src/patterns/disable/auth/modifies/root-layout.svelte.ts","../../src/patterns/disable/auth/modifies/hooks.server.ts","../../src/patterns/disable/auth/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { Project, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport {\n removeUnusedBindingElement,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nexport function unmodifyLayoutServer(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"success\", changed: false };\n }\n\n const originalSource = fs.readFileSync(layoutPath, \"utf8\");\n if (!originalSource.includes(\"locals.pb.authStore.record\")) {\n return { status: \"success\", changed: false };\n }\n\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(layoutPath);\n\n const literals = sourceFile.getDescendantsOfKind(\n SyntaxKind.ObjectLiteralExpression,\n );\n for (const obj of literals) {\n const userProp = obj.getProperty(\"user\");\n if (!userProp || userProp.getKind() !== SyntaxKind.PropertyAssignment) {\n continue;\n }\n const value = (userProp as import(\"ts-morph\").PropertyAssignment)\n .getInitializer()\n ?.getText();\n if (value === \"locals.pb.authStore.record\") {\n userProp.remove();\n }\n }\n // `user` was often the layout's only use of `locals`, which enable-auth\n // destructured for it.\n removeUnusedBindingElement(sourceFile, \"locals\");\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n ensureBlankLineAfterImports,\n removeImportByModuleSpecifier,\n removePropsBindingIfUnused,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { libModule } from \"../../../../runtime/lib-specifier\";\n\nexport function unmodifyRootLayoutSvelte(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"success\", changed: false };\n }\n\n const source = fs.readFileSync(layoutPath, \"utf8\");\n const file = new SvelteFile(source);\n if (!file.hasElement(\"AuthMenu.Root\")) {\n return { status: \"success\", changed: false };\n }\n\n // The whole navbar item enable-auth added goes, not just the menu inside\n // it; a layout that placed the menu without one loses only the menu.\n if (!file.removeElementContaining(\"Navbar.Item\", \"AuthMenu.Root\")) {\n file.removeElement(\"AuthMenu.Root\");\n }\n const markup = file.toString().replace(/<script[\\s\\S]*?<\\/script>/g, \"\");\n\n file.modifyScript((content) => {\n const { source: out } = withInMemoryScript(content, (sf) => {\n removeImportByModuleSpecifier(sf, libModule(\"components/ui/auth-menu\"));\n removeImportByModuleSpecifier(\n sf,\n libModule(\"components/user-avatar.svelte\"),\n );\n // Layouts from before UserAvatar import the avatar parts directly.\n removeImportByModuleSpecifier(sf, libModule(\"components/ui/avatar\"));\n // enable-auth added `data` for the menu's `data.user`.\n removePropsBindingIfUnused(sf, \"data\", markup);\n ensureBlankLineAfterImports(sf);\n });\n return out;\n });\n\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport { Project, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { formatLikeSource } from \"../../../../runtime/ts-morph-helpers\";\n\nexport function unmodifyHooksServer(hooksServerPath: string): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n return { status: \"success\", changed: false };\n }\n\n const originalSource = fs.readFileSync(hooksServerPath, \"utf8\");\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n const callExpr = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((ce) => ce.getExpression().getText() === \"handlePocketbase\");\n if (!callExpr) return { status: \"success\", changed: false };\n\n const [firstArg] = callExpr.getArguments();\n if (!firstArg || firstArg.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n return { status: \"success\", changed: false };\n }\n\n const optionsObj = firstArg.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n const authProp = optionsObj.getProperty(\"auth\");\n if (!authProp) {\n return { status: \"success\", changed: false };\n }\n\n authProp.remove();\n\n if (optionsObj.getProperties().length === 0) {\n callExpr.removeArgument(0);\n }\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import path from \"node:path\";\nimport fs from \"node:fs\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { unmodifyLayoutServer } from \"./modifies/+layout.server\";\nimport { unmodifyRootLayoutSvelte } from \"./modifies/root-layout.svelte\";\nimport { unmodifyHooksServer } from \"./modifies/hooks.server\";\nimport { planDropsForCollections } from \"../../destroy/shared\";\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(\"Reverting +layout.server.ts\");\n const layoutServerFile = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n layoutServerFile,\n unmodifyLayoutServer(layoutServerFile),\n ),\n );\n\n logger.info(\"Reverting root layout\");\n const layoutCandidates = [\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 const layoutFile =\n layoutCandidates.find((p) => fs.existsSync(p)) ?? layoutCandidates[0];\n pushResult(\n modifyOutcomeToFile(layoutFile, unmodifyRootLayoutSvelte(layoutFile)),\n );\n\n logger.info(\"Reverting hooks.server.ts\");\n const hooksServerFile = path.join(options.root, \"src\", \"hooks.server.ts\");\n pushResult(\n modifyOutcomeToFile(hooksServerFile, unmodifyHooksServer(hooksServerFile)),\n );\n\n const collectionDrops = await planDropsForCollections(\n [\"oauth_accounts\"],\n options,\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":";;;;;;;;;;AAQA,SAAgBY,EAAqB,GAAmC;CACtE,IAAI,CAACF,EAAG,WAAWG,CAAU,GAC3B,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAMC,IAAiBJ,EAAG,aAAaG,GAAY,MAAM;CACzD,IAAI,CAACC,EAAe,SAAS,4BAA4B,GACvD,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAI7C,IAAMC,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B,EAAK,KAAK2B,EAAQ,MAAM,OAAO,UAAU,YAAY,oBAAoB;EACzE3B,EAAK,KAAK2B,EAAQ,MAAM,OAAO,UAAU,oBAAoB;EAC7D3B,EAAK,KAAK2B,EAAQ,MAAM,OAAO,UAAU,YAAY,gBAAgB;EACrE3B,EAAK,KAAK2B,EAAQ,MAAM,OAAO,UAAU,gBAAgB;CAC3D,GACMK,IACJD,EAAiB,MAAM,MAAMhC,EAAG,WAAWkC,CAAC,CAAC,KAAKF,EAAiB;CAKrE,AAJAF,EACEhC,EAAoBmC,GAAYrB,EAAyBqB,CAAU,CAAC,CACtE,GAEAN,EAAO,KAAK,2BAA2B;CACvC,IAAMQ,IAAkBlC,EAAK,KAAK2B,EAAQ,MAAM,OAAO,iBAAiB;CAUxE,OATAE,EACEhC,EAAoBqC,GAAiBhB,EAAoBgB,CAAe,CAAC,CAC3E,GAOO;EACL,SAAS,CAAC;EACV;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAA,MAb4B3C,EAC5B,CAAC,gBAAgB,GACjBoC,CACF;CAWA;AACF"}
1
+ {"version":3,"file":"generate.runtime-Bz9z0VPR.js","names":["getLogger","modifyOutcomeToFile","withInMemoryScript","removeUnusedBindingElement","ensureBlankLineAfterImports","formatLikeSource","removePropsBindingIfUnused","removeImportByModuleSpecifier","SvelteFile","libModule","planDropsForCollections","fs","path","unmodifyLayoutServer","layoutPath","originalSource","sourceFile","Project","literals","SyntaxKind","obj","userProp","unmodifyRootLayoutSvelte","source","file","markup","out","content","sf","unmodifyHooksServer","hooksServerPath","callExpr","ce","firstArg","optionsObj","authProp","generate","logger","options","modifies","pushResult","layoutServerFile","layoutCandidates","layoutFile","p","hooksServerFile"],"sources":["../../src/patterns/disable/auth/modifies/+layout.server.ts","../../src/patterns/disable/auth/modifies/root-layout.svelte.ts","../../src/patterns/disable/auth/modifies/hooks.server.ts","../../src/patterns/disable/auth/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { Project, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport {\n removeUnusedBindingElement,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nexport function unmodifyLayoutServer(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"success\", changed: false };\n }\n\n const originalSource = fs.readFileSync(layoutPath, \"utf8\");\n if (!originalSource.includes(\"locals.pb.authStore.record\")) {\n return { status: \"success\", changed: false };\n }\n\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(layoutPath);\n\n const literals = sourceFile.getDescendantsOfKind(\n SyntaxKind.ObjectLiteralExpression,\n );\n for (const obj of literals) {\n const userProp = obj.getProperty(\"user\");\n if (!userProp || userProp.getKind() !== SyntaxKind.PropertyAssignment) {\n continue;\n }\n const value = (userProp as import(\"ts-morph\").PropertyAssignment)\n .getInitializer()\n ?.getText();\n if (value === \"locals.pb.authStore.record\") {\n userProp.remove();\n }\n }\n // `user` was often the layout's only use of `locals`, which enable-auth\n // destructured for it.\n removeUnusedBindingElement(sourceFile, \"locals\");\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n ensureBlankLineAfterImports,\n removeImportByModuleSpecifier,\n removePropsBindingIfUnused,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { libModule } from \"../../../../runtime/lib-specifier\";\n\nexport function unmodifyRootLayoutSvelte(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"success\", changed: false };\n }\n\n const source = fs.readFileSync(layoutPath, \"utf8\");\n const file = new SvelteFile(source);\n if (!file.hasElement(\"AuthMenu.Root\")) {\n return { status: \"success\", changed: false };\n }\n\n // The whole navbar item enable-auth added goes, not just the menu inside\n // it; a layout that placed the menu without one loses only the menu.\n if (!file.removeElementContaining(\"Navbar.Item\", \"AuthMenu.Root\")) {\n file.removeElement(\"AuthMenu.Root\");\n }\n const markup = file.toString().replace(/<script[\\s\\S]*?<\\/script>/g, \"\");\n\n file.modifyScript((content) => {\n const { source: out } = withInMemoryScript(content, (sf) => {\n removeImportByModuleSpecifier(sf, libModule(\"components/ui/auth-menu\"));\n removeImportByModuleSpecifier(\n sf,\n libModule(\"components/user-avatar.svelte\"),\n );\n // Layouts from before UserAvatar import the avatar parts directly.\n removeImportByModuleSpecifier(sf, libModule(\"components/ui/avatar\"));\n // enable-auth added `data` for the menu's `data.user`.\n removePropsBindingIfUnused(sf, \"data\", markup);\n ensureBlankLineAfterImports(sf);\n });\n return out;\n });\n\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport { Project, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { formatLikeSource } from \"../../../../runtime/ts-morph-helpers\";\n\nexport function unmodifyHooksServer(hooksServerPath: string): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n return { status: \"success\", changed: false };\n }\n\n const originalSource = fs.readFileSync(hooksServerPath, \"utf8\");\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n const callExpr = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((ce) => ce.getExpression().getText() === \"handlePocketbase\");\n if (!callExpr) return { status: \"success\", changed: false };\n\n const [firstArg] = callExpr.getArguments();\n if (!firstArg || firstArg.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n return { status: \"success\", changed: false };\n }\n\n const optionsObj = firstArg.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n const authProp = optionsObj.getProperty(\"auth\");\n if (!authProp) {\n return { status: \"success\", changed: false };\n }\n\n authProp.remove();\n\n if (optionsObj.getProperties().length === 0) {\n callExpr.removeArgument(0);\n }\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import path from \"node:path\";\nimport fs from \"node:fs\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { unmodifyLayoutServer } from \"./modifies/+layout.server\";\nimport { unmodifyRootLayoutSvelte } from \"./modifies/root-layout.svelte\";\nimport { unmodifyHooksServer } from \"./modifies/hooks.server\";\nimport { planDropsForCollections } from \"../../destroy/shared\";\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(\"Reverting +layout.server.ts\");\n const layoutServerFile = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n layoutServerFile,\n unmodifyLayoutServer(layoutServerFile),\n ),\n );\n\n logger.info(\"Reverting root layout\");\n const layoutCandidates = [\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 const layoutFile =\n layoutCandidates.find((p) => fs.existsSync(p)) ?? layoutCandidates[0];\n pushResult(\n modifyOutcomeToFile(layoutFile, unmodifyRootLayoutSvelte(layoutFile)),\n );\n\n logger.info(\"Reverting hooks.server.ts\");\n const hooksServerFile = path.join(options.root, \"src\", \"hooks.server.ts\");\n pushResult(\n modifyOutcomeToFile(hooksServerFile, unmodifyHooksServer(hooksServerFile)),\n );\n\n const collectionDrops = await planDropsForCollections(\n [\"oauth_accounts\"],\n options,\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":";;;;;;;;;;AAQA,SAAgBa,EAAqB,GAAmC;CACtE,IAAI,CAACF,EAAG,WAAWG,CAAU,GAC3B,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAMC,IAAiBJ,EAAG,aAAaG,GAAY,MAAM;CACzD,IAAI,CAACC,EAAe,SAAS,4BAA4B,GACvD,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAI7C,IAAMC,IAAa,IADCC,EACD,CAAA,CAAQ,oBAAoBH,CAAU,GAEnDI,IAAWF,EAAW,qBAC1BG,EAAW,uBACb;CACA,KAAK,IAAMC,KAAOF,GAAU;EAC1B,IAAMG,IAAWD,EAAI,YAAY,MAAM;EACvC,AAAKC,KAAYA,EAAS,QAAQ,MAAMF,EAAW,sBAGpCE,EACZ,eAAe,CAAC,EACf,QAAQ,MACE,gCACZA,EAAS,OAAO;CAEpB;CAQA,OALAlB,EAA2Ba,GAAY,QAAQ,GAE/CX,EAAiBW,CAAU,GAC3BA,EAAW,SAAS,GAEb;EACL,QAAQ;EACR,SAASA,EAAW,YAAY,MAAMD;CACxC;AACF;;ACpCA,SAAgBO,EAAyB,GAAmC;CAC1E,IAAI,CAACX,EAAG,WAAWG,CAAU,GAC3B,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAMS,IAASZ,EAAG,aAAaG,GAAY,MAAM,GAC3CU,IAAO,IAAIhB,EAAWe,CAAM;CAClC,IAAI,CAACC,EAAK,WAAW,eAAe,GAClC,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAK7C,AAAKA,EAAK,wBAAwB,eAAe,eAAe,KAC9DA,EAAK,cAAc,eAAe;CAEpC,IAAMC,IAASD,EAAK,SAAS,CAAC,CAAC,QAAQ,8BAA8B,EAAE;CAmBvE,OAjBAA,EAAK,cAAc,MAAY;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eAAsBqB,EAAS,GAAkB;CAC/C,IAAMC,IAASrC,EAAUsC,CAAO,GAC1BC,IAAmB,CAAC,GACpBC,KAAc,MAAsB;EACxC,AAAIhB,KAAMe,EAAS,KAAKf,CAAI;CAC9B;CAEA,EAAO,KAAK,6BAA6B;CACzC,IAAMiB,IAAmB7B,EAAK,KAC5B0B,EAAQ,MACR,OACA,UACA,mBACF;CAQA,AAPAE,EACEvC,EACEwC,GACA5B,EAAqB4B,CAAgB,CACvC,CACF,GAEAJ,EAAO,KAAK,uBAAuB;CACnC,IAAMK,IAAmB;EACvB9B,EAAK,KAAK0B,EAAQ,MAAM,OAAO,UAAU,YAAY,oBAAoB;EACzE1B,EAAK,KAAK0B,EAAQ,MAAM,OAAO,UAAU,oBAAoB;EAC7D1B,EAAK,KAAK0B,EAAQ,MAAM,OAAO,UAAU,YAAY,gBAAgB;EACrE1B,EAAK,KAAK0B,EAAQ,MAAM,OAAO,UAAU,gBAAgB;CAC3D,GACMK,IACJD,EAAiB,MAAM,MAAM/B,EAAG,WAAWiC,CAAC,CAAC,KAAKF,EAAiB;CAKrE,AAJAF,EACEvC,EAAoB0C,GAAYrB,EAAyBqB,CAAU,CAAC,CACtE,GAEAN,EAAO,KAAK,2BAA2B;CACvC,IAAMQ,IAAkBjC,EAAK,KAAK0B,EAAQ,MAAM,OAAO,iBAAiB;CAUxE,OATAE,EACEvC,EAAoB4C,GAAiBhB,EAAoBgB,CAAe,CAAC,CAC3E,GAOO;EACL,SAAS,CAAC;EACV;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAA,MAb4BnC,EAC5B,CAAC,gBAAgB,GACjB4B,CACF;CAWA;AACF"}
@@ -1,16 +1,16 @@
1
- import { a as e, c as t, l as n } from "./providers-CL9kQ4hp.js";
2
- import { t as r } from "./dedent-Gq6Krl4n.js";
3
- import { n as i } from "./logger-CQONztPm.js";
4
- import { r as a, t as o } from "./generate-DyV5R8NP.js";
5
- import { t as s } from "./env-BugddEjd.js";
6
- import { _ as c, r as l } from "./ts-morph-helpers-CHI9wAil.js";
7
- import { r as u } from "./modify-file-D9U2LXEa.js";
8
- import { modifyEnvVarsFiles as d } from "./env-vars-XvAeH6u5.js";
9
- import { t as f } from "./svelte-file-Dv5-bl79.js";
1
+ import { n as e } from "./logger-t1HxmpG2.js";
2
+ import { a as t, c as n, l as r } from "./providers-tjlFH5di.js";
3
+ import { modifyEnvVarsFiles as i } from "./env-vars-CVn2076k.js";
4
+ import { r as a } from "./modify-file-CRZ_gMg0.js";
5
+ import { t as o } from "./env-AxyRWcC_.js";
6
+ import { r as s, t as c } from "./generate-CKuUg3p-.js";
7
+ import { t as l } from "./dedent-CCUOcPFW.js";
8
+ import { t as u } from "./svelte-file-DfplF3BU.js";
9
+ import { _ as d, r as f } from "./ts-morph-helpers-B4KZXP44.js";
10
10
  import p from "node:fs";
11
11
  import m from "node:path";
12
- //#region src/patterns/enable/analytics/modifies/layout.svelte.ts
13
- var h = "#lib/components/analytics/analytics.svelte", g = r`
12
+ // src/patterns/enable/analytics/modifies/layout.svelte.ts
13
+ var h = "#lib/components/analytics/analytics.svelte", g = l`
14
14
  import Analytics from '${h}';
15
15
  `, _ = "\n<Analytics />\n", v = [
16
16
  "Create the root src/routes/+layout.svelte and mount <Analytics /> inside it.",
@@ -36,13 +36,13 @@ function b(e) {
36
36
  status: "not-found",
37
37
  message: v
38
38
  };
39
- let t = f.fromPath(e);
39
+ let t = u.fromPath(e);
40
40
  return t.hasElement("Analytics") ? {
41
41
  status: "success",
42
42
  changed: !1
43
43
  } : t.getScript() ? (t.modifyScript((e) => {
44
- let { source: t } = c(e, (e) => {
45
- l(e, [{
44
+ let { source: t } = d(e, (e) => {
45
+ f(e, [{
46
46
  defaultImport: "Analytics",
47
47
  moduleSpecifier: h
48
48
  }]);
@@ -56,19 +56,18 @@ function b(e) {
56
56
  message: y
57
57
  };
58
58
  }
59
- //#endregion
60
- //#region src/patterns/enable/analytics/generate.runtime.ts
61
- async function x(r) {
62
- let c = i(r), l = t(o, r), f = [], p = [], h = (e) => {
59
+ // src/patterns/enable/analytics/generate.runtime.ts
60
+ async function x(l) {
61
+ let u = e(l), d = n(c, l), f = [], p = [], h = (e) => {
63
62
  e && p.push(e);
64
63
  };
65
- c.info("Modifying src/routes/+layout.svelte");
66
- let g = m.join(r.root, "src", "routes", "+layout.svelte");
67
- h(u(g, b(g))), c.info("Declaring the analytics variables in src/env.ts");
68
- let _ = d(r.root, e(l));
69
- _.create && f.push(_.create), h(_.modify), c.info("Updating .env");
70
- let v = m.join(r.root, ".env");
71
- return h(u(v, s(v, a(l, n(r))))), {
64
+ u.info("Modifying src/routes/+layout.svelte");
65
+ let g = m.join(l.root, "src", "routes", "+layout.svelte");
66
+ h(a(g, b(g))), u.info("Declaring the analytics variables in src/env.ts");
67
+ let _ = i(l.root, t(d));
68
+ _.create && f.push(_.create), h(_.modify), u.info("Updating .env");
69
+ let v = m.join(l.root, ".env");
70
+ return h(a(v, o(v, s(d, r(l))))), {
72
71
  creates: f,
73
72
  modifies: p,
74
73
  deletes: [],
@@ -79,7 +78,6 @@ async function x(r) {
79
78
  collectionDrops: []
80
79
  };
81
80
  }
82
- //#endregion
83
81
  export { x as generate };
84
82
 
85
- //# sourceMappingURL=generate.runtime-CHaE6Mm9.js.map
83
+ //# sourceMappingURL=generate.runtime-C37djibw.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate.runtime-CHaE6Mm9.js","names":["providerEnvVars","resolveProvider","suppliedProviderEnv","dedent","getLogger","envEditsFor","META","modifyEnv","withInMemoryScript","ensureImports","modifyOutcomeToFile","SvelteFile","fs","path","MODULE_SPECIFIER","IMPORT_SNIPPET","MARKUP_SNIPPET","NOT_FOUND_HINT","FAILURE_HINT","modifyLayoutSvelte","layoutPath","file","out","source","sf","generate","logger","options","provider","creates","modifies","pushResult","envVars","modifyEnvVarsFiles","envPath"],"sources":["../../src/patterns/enable/analytics/modifies/layout.svelte.ts","../../src/patterns/enable/analytics/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 MODULE_SPECIFIER = \"#lib/components/analytics/analytics.svelte\";\n\nconst IMPORT_SNIPPET = dedent`\n import Analytics from '${MODULE_SPECIFIER}';\n`;\n\nconst MARKUP_SNIPPET = \"\\n<Analytics />\\n\";\n\nconst NOT_FOUND_HINT = [\n \"Create the root src/routes/+layout.svelte and mount <Analytics /> inside it.\",\n \"\",\n \"Import for the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup to add at the top level of the layout, above {@render children()}:\",\n MARKUP_SNIPPET.trim(),\n].join(\"\\n\");\n\nconst FAILURE_HINT = [\n \"Mount <Analytics /> in the root src/routes/+layout.svelte.\",\n \"\",\n 'Import for a <script lang=\"ts\"> tag:',\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup to add at the top level of the layout, above {@render children()}:\",\n MARKUP_SNIPPET.trim(),\n].join(\"\\n\");\n\n/**\n * Mounts `<Analytics />` at the top level of the root layout, ahead of\n * `{@render children()}`. The component is the same path for every provider,\n * so this modifier is provider-agnostic and a re-run with another provider\n * leaves the layout alone.\n */\nexport function modifyLayoutSvelte(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const file = SvelteFile.fromPath(layoutPath);\n if (file.hasElement(\"Analytics\")) {\n return { status: \"success\", changed: false };\n }\n if (!file.getScript()) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n ensureImports(sf, [\n { defaultImport: \"Analytics\", moduleSpecifier: MODULE_SPECIFIER },\n ]);\n });\n return out;\n });\n\n if (!file.insertBeforeChildren(MARKUP_SNIPPET)) {\n file.appendMarkup(MARKUP_SNIPPET);\n }\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport {\n providerEnvVars,\n resolveProvider,\n suppliedProviderEnv,\n} from \"../../../core/providers\";\nimport { modifyEnvVarsFiles } from \"../../../runtime/env-vars\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { modifyEnv } from \"../../../runtime/env\";\nimport { envEditsFor, META } from \"./generate\";\nimport { modifyLayoutSvelte } from \"./modifies/layout.svelte\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const provider = resolveProvider(META, options);\n const creates: File[] = [];\n const modifies: File[] = [];\n\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Modifying src/routes/+layout.svelte\");\n const layoutPath = path.join(options.root, \"src\", \"routes\", \"+layout.svelte\");\n pushResult(modifyOutcomeToFile(layoutPath, modifyLayoutSvelte(layoutPath)));\n\n // SvelteKit 3 exposes only declared variables, and only `public: true`\n // ones through `$app/env/public`, where the component imports them.\n logger.info(\"Declaring the analytics variables in src/env.ts\");\n const envVars = modifyEnvVarsFiles(options.root, providerEnvVars(provider));\n if (envVars.create) creates.push(envVars.create);\n pushResult(envVars.modify);\n\n logger.info(\"Updating .env\");\n const envPath = path.join(options.root, \".env\");\n pushResult(\n modifyOutcomeToFile(\n envPath,\n modifyEnv(envPath, envEditsFor(provider, suppliedProviderEnv(options))),\n ),\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":";;;;;;;;;;;;AASA,IAAMc,IAAmB,8CAEnBC,IAAiB,CAAM;2BACFD,EAAiB;GAGtCE,IAAiB,qBAEjBC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EAAQ,MAAM3B,EAAgB4B,CAAQ,CAAC;CAI1E,AAHII,EAAQ,UAAQH,EAAQ,KAAKG,EAAQ,MAAM,GAC/CD,EAAWC,EAAQ,MAAM,GAEzBN,EAAO,KAAK,eAAe;CAC3B,IAAMQ,IAAUrB,EAAK,KAAKc,EAAQ,MAAM,MAAM;CAQ9C,OAPAI,EACErB,EACEwB,GACA3B,EAAU2B,GAAS7B,EAAYuB,GAAU1B,EAAoByB,CAAO,CAAC,CAAC,CACxE,CACF,GAEO;EACL;EACA;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
1
+ {"version":3,"file":"generate.runtime-C37djibw.js","names":["getLogger","providerEnvVars","resolveProvider","suppliedProviderEnv","modifyOutcomeToFile","modifyEnv","envEditsFor","META","dedent","SvelteFile","withInMemoryScript","ensureImports","fs","path","MODULE_SPECIFIER","IMPORT_SNIPPET","MARKUP_SNIPPET","NOT_FOUND_HINT","FAILURE_HINT","modifyLayoutSvelte","layoutPath","file","out","source","sf","generate","logger","options","provider","creates","modifies","pushResult","envVars","modifyEnvVarsFiles","envPath"],"sources":["../../src/patterns/enable/analytics/modifies/layout.svelte.ts","../../src/patterns/enable/analytics/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 MODULE_SPECIFIER = \"#lib/components/analytics/analytics.svelte\";\n\nconst IMPORT_SNIPPET = dedent`\n import Analytics from '${MODULE_SPECIFIER}';\n`;\n\nconst MARKUP_SNIPPET = \"\\n<Analytics />\\n\";\n\nconst NOT_FOUND_HINT = [\n \"Create the root src/routes/+layout.svelte and mount <Analytics /> inside it.\",\n \"\",\n \"Import for the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup to add at the top level of the layout, above {@render children()}:\",\n MARKUP_SNIPPET.trim(),\n].join(\"\\n\");\n\nconst FAILURE_HINT = [\n \"Mount <Analytics /> in the root src/routes/+layout.svelte.\",\n \"\",\n 'Import for a <script lang=\"ts\"> tag:',\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup to add at the top level of the layout, above {@render children()}:\",\n MARKUP_SNIPPET.trim(),\n].join(\"\\n\");\n\n/**\n * Mounts `<Analytics />` at the top level of the root layout, ahead of\n * `{@render children()}`. The component is the same path for every provider,\n * so this modifier is provider-agnostic and a re-run with another provider\n * leaves the layout alone.\n */\nexport function modifyLayoutSvelte(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const file = SvelteFile.fromPath(layoutPath);\n if (file.hasElement(\"Analytics\")) {\n return { status: \"success\", changed: false };\n }\n if (!file.getScript()) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n ensureImports(sf, [\n { defaultImport: \"Analytics\", moduleSpecifier: MODULE_SPECIFIER },\n ]);\n });\n return out;\n });\n\n if (!file.insertBeforeChildren(MARKUP_SNIPPET)) {\n file.appendMarkup(MARKUP_SNIPPET);\n }\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport {\n providerEnvVars,\n resolveProvider,\n suppliedProviderEnv,\n} from \"../../../core/providers\";\nimport { modifyEnvVarsFiles } from \"../../../runtime/env-vars\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { modifyEnv } from \"../../../runtime/env\";\nimport { envEditsFor, META } from \"./generate\";\nimport { modifyLayoutSvelte } from \"./modifies/layout.svelte\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const provider = resolveProvider(META, options);\n const creates: File[] = [];\n const modifies: File[] = [];\n\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Modifying src/routes/+layout.svelte\");\n const layoutPath = path.join(options.root, \"src\", \"routes\", \"+layout.svelte\");\n pushResult(modifyOutcomeToFile(layoutPath, modifyLayoutSvelte(layoutPath)));\n\n // SvelteKit 3 exposes only declared variables, and only `public: true`\n // ones through `$app/env/public`, where the component imports them.\n logger.info(\"Declaring the analytics variables in src/env.ts\");\n const envVars = modifyEnvVarsFiles(options.root, providerEnvVars(provider));\n if (envVars.create) creates.push(envVars.create);\n pushResult(envVars.modify);\n\n logger.info(\"Updating .env\");\n const envPath = path.join(options.root, \".env\");\n pushResult(\n modifyOutcomeToFile(\n envPath,\n modifyEnv(envPath, envEditsFor(provider, suppliedProviderEnv(options))),\n ),\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":";;;;;;;;;;;;AASA,IAAMc,IAAmB,8CAEnBC,IAAiB,CAAM;2BACFD,EAAiB;GAGtCE,IAAiB,qBAEjBC,IAAiB;CACrB;CACA;CACA;CACA;CACAF;CACA;CACA;CACAC,EAAe,KAAK;AACtB,CAAC,CAAC,KAAK,IAAI,GAELE,IAAe;CACnB;CACA;CACA;CACA;CACAH;CACA;CACA;CACAC,EAAe,KAAK;AACtB,CAAC,CAAC,KAAK,IAAI;AAQX,SAAgBG,EAAmB,GAAmC;CACpE,IAAI,CAACP,EAAG,WAAWQ,CAAU,GAC3B,OAAO;EAAE,QAAQ;EAAa,SAASH;CAAe;CAGxD,IAAMI,IAAOZ,EAAW,SAASW,CAAU;CAqB3C,OApBIC,EAAK,WAAW,WAAW,IACtB;EAAE,QAAQ;EAAW,SAAS;CAAM,IAExCA,EAAK,UAAU,KAIpBA,EAAK,cAAc,MAAW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