@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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.runtime-j_5K3Uue.js","names":["removeNegotiateImport","toDeleteEntry","getLogger","revertOutcomeToFile","dedent","removeHandle","withInMemoryScript","removeNamedImportIfUnused","ensureBlankLineAfterImports","formatLikeSource","libModule","isLibSpecifier","SvelteFile","fs","path","FAILURE_HINT","removeNegotiateImport$1","decl","sourceFile","d","named","ni","unmodifyHooksServerNegotiate","hooksServerPath","original","Project","QuoteKind","removeNegotiateImport","isMeaningfullyEmpty","s","SyntaxKind","unmodifyHooksNegotiate","hooksPath","rerouteDecl","initText","hasI18nHelper","unmodifyRootLayoutNegotiate","layoutPath","file","hasElement","out","source","sf","generate","logger","options","modifies","deletes","pushResult","hooksServerRevert","hooksOutcome","modifyOutcomeToFile","rootLayoutPath"],"sources":["../../src/patterns/disable/content-negotiation/modifies/hooks.server.ts","../../src/patterns/disable/content-negotiation/modifies/hooks.ts","../../src/patterns/disable/content-negotiation/modifies/root-layout.svelte.ts","../../src/patterns/disable/content-negotiation/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Project, QuoteKind, type SourceFile } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { removeHandle } from \"../../../../runtime/compose-handle\";\nimport {\n ensureBlankLineAfterImports,\n removeNamedImportIfUnused,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport { isLibSpecifier } from \"../../../../runtime/lib-specifier\";\n\nconst FAILURE_HINT = dedent`\n Take handleNegotiate out of the exported handle in src/hooks.server.ts, then\n remove its import:\n\n import { handle as handleNegotiate } from '#lib/negotiate.js';\n`;\n\nfunction removeNegotiateImport(sourceFile: SourceFile): boolean {\n const decl = sourceFile\n .getImportDeclarations()\n .find((d) => isLibSpecifier(d.getModuleSpecifierValue(), \"negotiate\"));\n if (!decl) return false;\n\n const named = decl.getNamedImports().find((ni) => {\n return (\n ni.getName() === \"handle\" &&\n ni.getAliasNode()?.getText() === \"handleNegotiate\"\n );\n });\n\n if (!named) return false;\n\n if (decl.getNamedImports().length === 1 && !decl.getDefaultImport()) {\n decl.remove();\n } else {\n named.remove();\n }\n return true;\n}\n\n/**\n * Undo `modifyHooksServerNegotiate`: take `handleNegotiate` out of the\n * exported handle and drop its import. A file that held nothing else comes\n * out empty, for the caller to delete.\n */\nexport function unmodifyHooksServerNegotiate(\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(\"handleNegotiate\")) {\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 const removed = removeHandle(sourceFile, \"handleNegotiate\");\n if (removed.status === \"unsupported\") {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n removeNegotiateImport(sourceFile);\n removeNamedImportIfUnused(sourceFile, \"@sveltejs/kit/hooks\", \"sequence\");\n formatLikeSource(sourceFile);\n ensureBlankLineAfterImports(sourceFile);\n sourceFile.saveSync();\n\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== original,\n };\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\";\nimport { isLibSpecifier } from \"../../../../runtime/lib-specifier\";\n\nfunction removeNegotiateImport(sourceFile: SourceFile): boolean {\n const decl = sourceFile\n .getImportDeclarations()\n .find((d) => isLibSpecifier(d.getModuleSpecifierValue(), \"negotiate\"));\n if (!decl) return false;\n\n const named = decl.getNamedImports().find((ni) => {\n return (\n ni.getName() === \"reroute\" &&\n ni.getAliasNode()?.getText() === \"negotiateReroute\"\n );\n });\n if (!named) return false;\n\n if (decl.getNamedImports().length === 1 && !decl.getDefaultImport()) {\n decl.remove();\n } else {\n named.remove();\n }\n return true;\n}\n\nfunction isMeaningfullyEmpty(sourceFile: SourceFile): boolean {\n return sourceFile\n .getStatements()\n .every((s) => s.getKind() === SyntaxKind.EmptyStatement);\n}\n\nexport function unmodifyHooksNegotiate(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(\"negotiateReroute\")) {\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 rerouteDecl = sourceFile.getVariableDeclaration(\"reroute\");\n const init = rerouteDecl?.getInitializer();\n const initText = init?.getText() ?? \"\";\n\n const hasI18nHelper = sourceFile\n .getVariableDeclarations()\n .some((d) => d.getName() === \"rerouteDeLocalize\");\n\n if (\n rerouteDecl &&\n hasI18nHelper &&\n initText.includes(\"rerouteDeLocalize\") &&\n initText.includes(\"negotiateReroute\")\n ) {\n rerouteDecl.setInitializer(\"({ url }) => rerouteDeLocalize(url.pathname)\");\n } else if (rerouteDecl && initText.includes(\"negotiateReroute\")) {\n const stmt = rerouteDecl.getFirstAncestorByKind(\n SyntaxKind.VariableStatement,\n );\n stmt?.remove();\n }\n\n removeNegotiateImport(sourceFile);\n\n if (isMeaningfullyEmpty(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 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 removeImportByModuleSpecifier,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { libModule } from \"../../../../runtime/lib-specifier\";\n\nexport function unmodifyRootLayoutNegotiate(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"success\", changed: false };\n }\n\n const file = SvelteFile.fromPath(layoutPath);\n const hasElement = file.hasElement(\"Negotiate\");\n\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n removeImportByModuleSpecifier(sf, libModule(\"negotiate\"));\n });\n return out;\n });\n\n if (hasElement) {\n file.removeElement(\"Negotiate\");\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 { toDeleteEntry } from \"../../destroy/shared\";\nimport { getLogger } from \"../../../core/logger\";\nimport {\n modifyOutcomeToFile,\n revertOutcomeToFile,\n} from \"../../../runtime/modify-file\";\nimport { unmodifyHooksServerNegotiate } from \"./modifies/hooks.server\";\nimport { unmodifyHooksNegotiate } from \"./modifies/hooks\";\nimport { unmodifyRootLayoutNegotiate } 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 hooks.server.ts\");\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n // Emptied once the negotiation handle was all it held, it goes.\n const hooksServerRevert = revertOutcomeToFile(\n hooksServerPath,\n unmodifyHooksServerNegotiate(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 const hooksOutcome = unmodifyHooksNegotiate(hooksPath);\n if (\n fs.existsSync(hooksPath) &&\n fs.readFileSync(hooksPath, \"utf8\").trim() === \"\"\n ) {\n // The reroute was all it contained; the file goes with it.\n deletes.push(toDeleteEntry(hooksPath));\n } else {\n pushResult(modifyOutcomeToFile(hooksPath, hooksOutcome));\n }\n\n logger.info(\"Reverting src/routes/+layout.svelte\");\n const rootLayoutPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(\n rootLayoutPath,\n unmodifyRootLayoutNegotiate(rootLayoutPath),\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":";;;;;;;;;;;;AAYA,IAAMe,IAAe,CAAM;;;;;;AAO3B,SAASf,EAAsB,GAAiC;CAC9D,IAAMiB,IAAOC,EACV,sBAAsB,CAAC,CACvB,MAAM,MAAMP,EAAeQ,EAAE,wBAAwB,GAAG,WAAW,CAAC;CACvE,IAAI,CAACF,GAAM,OAAO;CAElB,IAAMG,IAAQH,EAAK,gBAAgB,CAAC,CAAC,MAAM,MAEvCI,EAAG,QAAQ,MAAM,YACjBA,EAAG,aAAa,CAAC,EAAE,QAAQ,MAAM,iBAEpC;CASD,OAPKD,KAEDH,EAAK,gBAAgB,CAAC,CAAC,WAAW,KAAK,CAACA,EAAK,iBAAiB,IAChEA,EAAK,OAAO,IAEZG,EAAM,OAAO,GAER,MAPY;AAQrB;AAOA,SAAgBE,EACd,GACe;CACf,IAAI,CAACT,EAAG,WAAWU,CAAe,GAChC,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAMC,IAAWX,EAAG,aAAaU,GAAiB,MAAM;CACxD,IAAI,CAACC,EAAS,SAAS,iBAAiB,GACtC,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAO7C,IAAMN,IAAa,IAJCO,EAAQ;EAC1B,iBAAiB,EAAE,SAAS,GAAK;EACjC,sBAAsB,EAAE,WAAWC,EAAU,OAAO;CACtD,CACmB,CAAA,CAAQ,oBAAoBH,CAAe;CAY9D,OAVgBlB,EAAaa,GAAY,iBACrC,CAAA,CAAQ,WAAW,gBACd;EAAE,QAAQ;EAAU,SAASH;CAAa,KAEnDC,EAAsBE,CAAU,GAChCX,EAA0BW,GAAY,uBAAuB,UA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yB,EAAWC,EAAkB,MAAM,GAC/BA,EAAkB,UAAQF,EAAQ,KAAKE,EAAkB,MAAM,GAEnEL,EAAO,KAAK,oBAAoB;CAChC,IAAMZ,IAAYlB,EAAK,KAAK+B,EAAQ,MAAM,OAAO,UAAU,GACrDK,IAAenB,EAAuBC,CAAS;CAWrD,AATEnB,EAAG,WAAWmB,CAAS,KACvBnB,EAAG,aAAamB,GAAW,MAAM,CAAC,CAAC,KAAK,MAAM,KAG9Ce,EAAQ,KAAK9C,EAAc+B,CAAS,CAAC,IAErCgB,EAAWG,EAAoBnB,GAAWkB,CAAY,CAAC,GAGzDN,EAAO,KAAK,qCAAqC;CACjD,IAAMQ,IAAiBtC,EAAK,KAC1B+B,EAAQ,MACR,OACA,UACA,gBACF;CAQA,OAPAG,EACEG,EACEC,GACAhB,EAA4BgB,CAAc,CAC5C,CACF,GAEO;EACL,SAAS,CAAC;EACV;EACA;EACA,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
@@ -1,16 +1,16 @@
1
- import { t as e } from "./dedent-Gq6Krl4n.js";
2
- import { t } from "./taggedTemplateLiteral-KSUnuvOk.js";
3
- import { n } from "./logger-CQONztPm.js";
4
- import { n as r } from "./site-CVtsbO_S.js";
5
- import { r as i } from "./ts-morph-helpers-CHI9wAil.js";
6
- import { r as a } from "./modify-file-DdXJCMHN.js";
7
- import { t as o } from "./svelte-file-Dv5-bl79.js";
8
- import { i as s } from "./config-target-BgyFkbFL.js";
1
+ import { n as e } from "./logger-t1HxmpG2.js";
2
+ import { r as t } from "./modify-file-CRZ_gMg0.js";
3
+ import { n } from "./site-B9hDxucR.js";
4
+ import { t as r } from "./dedent-CCUOcPFW.js";
5
+ import { i } from "./config-target-DJbVHwHl.js";
6
+ import { r as a } from "./ts-morph-helpers-B4KZXP44.js";
7
+ import { t as o } from "./svelte-file-DfplF3BU.js";
8
+ import { t as s } from "./taggedTemplateLiteral-CLenToGE.js";
9
9
  import c from "node:fs";
10
10
  import l from "node:path";
11
11
  import { SyntaxKind as u } from "ts-morph";
12
- //#region src/patterns/enable/blog/modifies/vite-config.ts
13
- var d = e`
12
+ // src/patterns/enable/blog/modifies/vite-config.ts
13
+ var d = r`
14
14
  Enable mdsvex in your config (the sveltekit() arg in vite.config):
15
15
 
16
16
  import { mdsvex } from 'mdsvex';
@@ -18,7 +18,7 @@ var d = e`
18
18
  // ...
19
19
  extensions: ['.svelte', '.svx'],
20
20
  preprocess: [mdsvex()],
21
- `, f = e`
21
+ `, f = r`
22
22
  Enable mdsvex by passing config to the sveltekit() plugin in vite.config.ts:
23
23
 
24
24
  import { sveltekit } from '@sveltejs/kit/vite';
@@ -63,17 +63,16 @@ function m(e) {
63
63
  return !/\bmdsvex\s*\(/.test(r) && (t.setInitializer(`[${r}, mdsvex()]`), !0);
64
64
  }
65
65
  function h(e) {
66
- return s(e, {
66
+ return i(e, {
67
67
  notFound: f,
68
68
  failed: d
69
- }, (e) => (p(e.configObject), m(e.configObject), i(e.sourceFile, [{
69
+ }, (e) => (p(e.configObject), m(e.configObject), a(e.sourceFile, [{
70
70
  namedImports: ["mdsvex"],
71
71
  moduleSpecifier: "mdsvex"
72
72
  }]), !0));
73
73
  }
74
- //#endregion
75
- //#region src/patterns/enable/blog/modifies/root-layout-svelte.ts
76
- var g, _ = "import '../css/prism-vsc-dark-plus.css';", v = e(g ||= t(["\n Create src/routes/+layout.svelte and import the Prism theme for\n code block highlighting in blog posts:\n\n <script lang=\"ts\">\n import '../app.css';\n ", "\n <\/script>\n"]), _), y = e`
74
+ // src/patterns/enable/blog/modifies/root-layout-svelte.ts
75
+ var g, _ = "import '../css/prism-vsc-dark-plus.css';", v = r(g ||= s(["\n Create src/routes/+layout.svelte and import the Prism theme for\n code block highlighting in blog posts:\n\n <script lang=\"ts\">\n import '../app.css';\n ", "\n <\/script>\n"]), _), y = r`
77
76
  Import the Prism theme in your root +layout.svelte for blog code
78
77
  block highlighting:
79
78
 
@@ -103,9 +102,8 @@ function b(e) {
103
102
  message: y
104
103
  };
105
104
  }
106
- //#endregion
107
- //#region src/patterns/enable/blog/modifies/public-root-layout-svelte.ts
108
- var x = "\n <Navbar.Item>\n <Button class=\"w-full justify-start md:justify-center md:w-auto\" href=\"/blog\" variant=\"ghost\">\n Blog\n </Button>\n </Navbar.Item>\n ", S = e`
105
+ // src/patterns/enable/blog/modifies/public-root-layout-svelte.ts
106
+ var x = "\n <Navbar.Item>\n <Button class=\"w-full justify-start md:justify-center md:w-auto\" href=\"/blog\" variant=\"ghost\">\n Blog\n </Button>\n </Navbar.Item>\n ", S = r`
109
107
  Add a Blog link inside <Navbar.List> in the public root layout:
110
108
 
111
109
  <Navbar.Item>
@@ -113,7 +111,7 @@ var x = "\n <Navbar.Item>\n <Button class=\"w-full justify-start md:justify-c
113
111
  Blog
114
112
  </Button>
115
113
  </Navbar.Item>
116
- `, C = e`
114
+ `, C = r`
117
115
  Create a public root layout with a Blog link in its Navbar.List:
118
116
 
119
117
  <Navbar.Item>
@@ -141,27 +139,26 @@ function w(e) {
141
139
  changed: t.hasChanged()
142
140
  });
143
141
  }
144
- //#endregion
145
- //#region src/patterns/enable/blog/generate.runtime.ts
146
- async function T(e) {
147
- let t = n(e), i = [], o = (e) => {
148
- e && i.push(e);
142
+ // src/patterns/enable/blog/generate.runtime.ts
143
+ async function T(r) {
144
+ let i = e(r), a = [], o = (e) => {
145
+ e && a.push(e);
149
146
  };
150
- t.info("Modifying vite.config for mdsvex");
151
- let s = h(e.root);
152
- o(a(s.filePath, s.outcome)), t.info("Modifying src/routes/+layout.svelte");
153
- let u = l.join(e.root, "src", "routes", "+layout.svelte");
154
- o(a(u, b(u))), t.info("Modifying public root layout");
147
+ i.info("Modifying vite.config for mdsvex");
148
+ let s = h(r.root);
149
+ o(t(s.filePath, s.outcome)), i.info("Modifying src/routes/+layout.svelte");
150
+ let u = l.join(r.root, "src", "routes", "+layout.svelte");
151
+ o(t(u, b(u))), i.info("Modifying public root layout");
155
152
  let d = [
156
- l.join(e.root, "src", "routes", "(public)", "root-layout.svelte"),
157
- l.join(e.root, "src", "routes", "root-layout.svelte"),
158
- l.join(e.root, "src", "routes", "(public)", "+layout.svelte")
153
+ l.join(r.root, "src", "routes", "(public)", "root-layout.svelte"),
154
+ l.join(r.root, "src", "routes", "root-layout.svelte"),
155
+ l.join(r.root, "src", "routes", "(public)", "+layout.svelte")
159
156
  ], f = d.find((e) => c.existsSync(e)) ?? d[0];
160
- o(a(f, w(f)));
161
- let p = await r(e);
157
+ o(t(f, w(f)));
158
+ let p = await n(r);
162
159
  return {
163
160
  creates: p ? [p] : [],
164
- modifies: i,
161
+ modifies: a,
165
162
  deletes: [],
166
163
  components: [],
167
164
  packages: [],
@@ -170,7 +167,6 @@ async function T(e) {
170
167
  collectionDrops: []
171
168
  };
172
169
  }
173
- //#endregion
174
170
  export { T as generate };
175
171
 
176
- //# sourceMappingURL=generate.runtime-DbSRJF-C.js.map
172
+ //# sourceMappingURL=generate.runtime-mE0knt2T.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate.runtime-DbSRJF-C.js","names":["FAILURE_HINT","NOT_FOUND_HINT","NOT_FOUND_HINT","FAILURE_HINT","dedent","ensureSiteFile","ensureImports","modifyOutcomeToFile","SvelteFile","modifyConfig","fs","path","FAILURE_HINT$2","NOT_FOUND_HINT$2","ensureExtensionsSvx","existing","obj","SyntaxKind","init","arr","el","ensurePreprocessMdsvex","text","modifyViteConfigMdsvex","root","target","_templateObject","PRISM_IMPORT","NOT_FOUND_HINT$1","_taggedTemplateLiteral","FAILURE_HINT$1","modifyRootLayoutSvelte","layoutPath","file","script","appCssMatch","source","insertion","end","BLOG_NAVBAR_ITEM","FAILURE_HINT","NOT_FOUND_HINT","modifyPublicRootLayout","raw","generate","logger","getLogger","options","modifies","pushResult","mdsvex","rootLayoutPath","publicLayoutCandidates","publicLayoutPath","p","siteFile"],"sources":["../../src/patterns/enable/blog/modifies/vite-config.ts","../../src/patterns/enable/blog/modifies/root-layout-svelte.ts","../../src/patterns/enable/blog/modifies/public-root-layout-svelte.ts","../../src/patterns/enable/blog/generate.runtime.ts"],"sourcesContent":["import dedent from \"dedent\";\nimport {\n SyntaxKind,\n type ArrayLiteralExpression,\n type ObjectLiteralExpression,\n} from \"ts-morph\";\nimport {\n modifyConfig,\n type ConfigModifyResult,\n} from \"../../../../runtime/config-target\";\nimport { ensureImports } from \"../../../../runtime/ts-morph-helpers\";\n\nconst FAILURE_HINT = dedent`\n Enable mdsvex in your config (the sveltekit() arg in vite.config):\n\n import { mdsvex } from 'mdsvex';\n\n // ...\n extensions: ['.svelte', '.svx'],\n preprocess: [mdsvex()],\n`;\n\nconst NOT_FOUND_HINT = dedent`\n Enable mdsvex by passing config to the sveltekit() plugin in vite.config.ts:\n\n import { sveltekit } from '@sveltejs/kit/vite';\n import { mdsvex } from 'mdsvex';\n import { defineConfig } from 'vite';\n\n export default defineConfig({\n plugins: [\n sveltekit({\n extensions: ['.svelte', '.svx'],\n preprocess: [mdsvex()],\n }),\n ],\n });\n`;\n\nfunction ensureExtensionsSvx(obj: ObjectLiteralExpression): boolean {\n const existing = obj.getProperty(\"extensions\");\n if (!existing) {\n obj.addPropertyAssignment({\n name: \"extensions\",\n initializer: \"['.svelte', '.svx']\",\n });\n return true;\n }\n if (existing.getKind() !== SyntaxKind.PropertyAssignment) return false;\n const init = (\n existing as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (!init || init.getKind() !== SyntaxKind.ArrayLiteralExpression) {\n (existing as import(\"ts-morph\").PropertyAssignment).setInitializer(\n \"['.svelte', '.svx']\",\n );\n return true;\n }\n const arr = init as ArrayLiteralExpression;\n const hasSvx = arr\n .getElements()\n .some((el) => el.getText().replace(/['\"`]/g, \"\") === \".svx\");\n if (hasSvx) return false;\n arr.addElement(\"'.svx'\");\n return true;\n}\n\nfunction ensurePreprocessMdsvex(obj: ObjectLiteralExpression): boolean {\n const existing = obj.getProperty(\"preprocess\");\n if (!existing) {\n obj.addPropertyAssignment({\n name: \"preprocess\",\n initializer: \"[mdsvex()]\",\n });\n return true;\n }\n if (existing.getKind() !== SyntaxKind.PropertyAssignment) return false;\n const init = (\n existing as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (!init) {\n (existing as import(\"ts-morph\").PropertyAssignment).setInitializer(\n \"[mdsvex()]\",\n );\n return true;\n }\n if (init.getKind() === SyntaxKind.ArrayLiteralExpression) {\n const arr = init as ArrayLiteralExpression;\n const hasMdsvex = arr\n .getElements()\n .some((el) => /\\bmdsvex\\s*\\(/.test(el.getText()));\n if (hasMdsvex) return false;\n arr.addElement(\"mdsvex()\");\n return true;\n }\n const text = init.getText();\n if (/\\bmdsvex\\s*\\(/.test(text)) return false;\n (existing as import(\"ts-morph\").PropertyAssignment).setInitializer(\n `[${text}, mdsvex()]`,\n );\n return true;\n}\n\n/**\n * Enable mdsvex: ensure `extensions` includes `.svx`, `preprocess` includes\n * `mdsvex()`, and the `mdsvex` import is present, at the top level of the\n * inline sveltekit() arg in vite.config.\n */\nexport function modifyViteConfigMdsvex(root: string): ConfigModifyResult {\n return modifyConfig(\n root,\n { notFound: NOT_FOUND_HINT, failed: FAILURE_HINT },\n (target) => {\n ensureExtensionsSvx(target.configObject);\n ensurePreprocessMdsvex(target.configObject);\n ensureImports(target.sourceFile, [\n { namedImports: [\"mdsvex\"], moduleSpecifier: \"mdsvex\" },\n ]);\n return true;\n },\n );\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst PRISM_IMPORT = `import '../css/prism-vsc-dark-plus.css';`;\n\nconst NOT_FOUND_HINT = dedent`\n Create src/routes/+layout.svelte and import the Prism theme for\n code block highlighting in blog posts:\n\n <script lang=\"ts\">\n import '../app.css';\n ${PRISM_IMPORT}\n </script>\n`;\n\nconst FAILURE_HINT = dedent`\n Import the Prism theme in your root +layout.svelte for blog code\n block highlighting:\n\n ${PRISM_IMPORT}\n`;\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 const script = file.getScript();\n if (!script) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n if (script.content.includes(\"prism-vsc-dark-plus.css\")) {\n return { status: \"success\", changed: false };\n }\n\n file.modifyScript((source) => {\n const appCssMatch = source.match(\n /^(\\s*)import\\s+['\"][^'\"]*app\\.css['\"];?\\s*$/m,\n );\n if (appCssMatch) {\n const indent = appCssMatch[1] ?? \"\";\n const insertion = `\\n${indent}${PRISM_IMPORT}`;\n const end = (appCssMatch.index ?? 0) + appCssMatch[0].length;\n return source.slice(0, end) + insertion + source.slice(end);\n }\n return source.replace(/^/, `\\n\\t${PRISM_IMPORT}\\n`);\n });\n\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst BLOG_NAVBAR_ITEM = `\n\t\t<Navbar.Item>\n\t\t\t<Button class=\"w-full justify-start md:justify-center md:w-auto\" href=\"/blog\" variant=\"ghost\">\n\t\t\t\tBlog\n\t\t\t</Button>\n\t\t</Navbar.Item>\n\t`;\n\nconst FAILURE_HINT = dedent`\n Add a Blog link inside <Navbar.List> in the public root layout:\n\n <Navbar.Item>\n <Button class=\"w-full justify-start md:justify-center md:w-auto\" href=\"/blog\" variant=\"ghost\">\n Blog\n </Button>\n </Navbar.Item>\n`;\n\nconst NOT_FOUND_HINT = dedent`\n Create a public root layout with a Blog link in its Navbar.List:\n\n <Navbar.Item>\n <Button class=\"w-full justify-start md:justify-center md:w-auto\" href=\"/blog\" variant=\"ghost\">\n Blog\n </Button>\n </Navbar.Item>\n`;\n\nexport function modifyPublicRootLayout(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\n const raw = fs.readFileSync(layoutPath, \"utf8\");\n if (/href=[\"']\\/blog[\"']/.test(raw)) {\n return { status: \"success\", changed: false };\n }\n\n file.insertBeforeClosingTag(\"Navbar.List\", BLOG_NAVBAR_ITEM);\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\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 { ensureSiteFile } from \"../../../runtime/site\";\nimport { modifyViteConfigMdsvex } from \"./modifies/vite-config\";\nimport { modifyRootLayoutSvelte } from \"./modifies/root-layout-svelte\";\nimport { modifyPublicRootLayout } from \"./modifies/public-root-layout-svelte\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Modifying vite.config for mdsvex\");\n const mdsvex = modifyViteConfigMdsvex(options.root);\n pushResult(modifyOutcomeToFile(mdsvex.filePath, mdsvex.outcome));\n\n logger.info(\"Modifying src/routes/+layout.svelte\");\n const rootLayoutPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(rootLayoutPath, modifyRootLayoutSvelte(rootLayoutPath)),\n );\n\n logger.info(\"Modifying public root layout\");\n const publicLayoutCandidates = [\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 ];\n const publicLayoutPath =\n publicLayoutCandidates.find((p) => fs.existsSync(p)) ??\n publicLayoutCandidates[0];\n pushResult(\n modifyOutcomeToFile(\n publicLayoutPath,\n modifyPublicRootLayout(publicLayoutPath),\n ),\n );\n\n // The RSS feed is titled and linked from `src/lib/site.ts`.\n const siteFile = await ensureSiteFile(options);\n\n return {\n creates: siteFile ? [siteFile] : [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;;;;AAYA,IAAMA,IAAe,CAAM;;;;;;;;GAUrBC,IAAiB,CAAM;;;;;;;;;;;;;;;;AAiB7B,SAASa,EAAoB,GAAuC;CAClE,IAAMC,IAAWC,EAAI,YAAY,YAAY;CAC7C,IAAI,CAACD,GAKH,OAJAC,EAAI,sBAAsB;EACxB,MAAM;EACN,aAAa;CACf,CAAC,GACM;CAET,IAAID,EAAS,QAAQ,MAAME,EAAW,oBAAoB,OAAO;CACjE,IAAMC,IACJH,EACA,eAAe;CACjB,IAAI,CAACG,KAAQA,EAAK,QAAQ,MAAMD,EAAW,wBAIzC,OAHAF,EAAoD,eAClD,qBACF,GACO;CAET,IAAMI,IAAMD;CAMZ,OAFA,CAHeC,EACZ,YAAY,CAAC,CACb,MAAM,MAAOC,EAAG,QAAQ,CAAC,CAAC,QAAQ,UAAU,EAAE,MAAM,MACnD,MACJD,EAAI,WAAW,QAAQ,GAChB;AACT;AAEA,SAASE,EAAuB,GAAuC;CACrE,IAAMN,IAAWC,EAAI,YAAY,YAAY;CAC7C,IAAI,CAACD,GAKH,OAJAC,EAAI,sBAAsB;EACxB,MAAM;EACN,aAAa;CACf,CAAC,GACM;CAET,IAAID,EAAS,QAAQ,MAAME,EAAW,oBAAoB,OAAO;CACjE,IAAMC,IACJH,EACA,eAAe;CACjB,IAAI,CAACG,GAIH,OAHAH,EAAoD,eAClD,YACF,GACO;CAET,IAA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EAAO,KAAK,8BAA8B;CAC1C,IAAMO,IAAyB;EAC7BzC,EAAK,KAAKoC,EAAQ,MAAM,OAAO,UAAU,YAAY,oBAAoB;EACzEpC,EAAK,KAAKoC,EAAQ,MAAM,OAAO,UAAU,oBAAoB;EAC7DpC,EAAK,KAAKoC,EAAQ,MAAM,OAAO,UAAU,YAAY,gBAAgB;CACvE,GACMM,IACJD,EAAuB,MAAM,MAAM1C,EAAG,WAAW4C,CAAC,CAAC,KACnDF,EAAuB;CACzB,EACE7C,EACE8C,GACAX,EAAuBW,CAAgB,CACzC,CACF;CAGA,IAAME,IAAW,MAAMlD,EAAe0C,CAAO;CAE7C,OAAO;EACL,SAASQ,IAAW,CAACA,CAAQ,IAAI,CAAC;EAClC;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-mE0knt2T.js","names":["FAILURE_HINT","NOT_FOUND_HINT","NOT_FOUND_HINT","FAILURE_HINT","getLogger","modifyOutcomeToFile","dedent","ensureImports","SvelteFile","_taggedTemplateLiteral","fs","path","FAILURE_HINT$2","NOT_FOUND_HINT$2","ensureExtensionsSvx","existing","obj","SyntaxKind","init","arr","el","ensurePreprocessMdsvex","text","modifyViteConfigMdsvex","modifyConfig","root","target","_templateObject","PRISM_IMPORT","NOT_FOUND_HINT$1","FAILURE_HINT$1","modifyRootLayoutSvelte","layoutPath","file","script","appCssMatch","source","insertion","end","BLOG_NAVBAR_ITEM","FAILURE_HINT","NOT_FOUND_HINT","modifyPublicRootLayout","raw","generate","logger","options","modifies","pushResult","mdsvex","rootLayoutPath","publicLayoutCandidates","publicLayoutPath","p","siteFile","ensureSiteFile"],"sources":["../../src/patterns/enable/blog/modifies/vite-config.ts","../../src/patterns/enable/blog/modifies/root-layout-svelte.ts","../../src/patterns/enable/blog/modifies/public-root-layout-svelte.ts","../../src/patterns/enable/blog/generate.runtime.ts"],"sourcesContent":["import dedent from \"dedent\";\nimport {\n SyntaxKind,\n type ArrayLiteralExpression,\n type ObjectLiteralExpression,\n} from \"ts-morph\";\nimport {\n modifyConfig,\n type ConfigModifyResult,\n} from \"../../../../runtime/config-target\";\nimport { ensureImports } from \"../../../../runtime/ts-morph-helpers\";\n\nconst FAILURE_HINT = dedent`\n Enable mdsvex in your config (the sveltekit() arg in vite.config):\n\n import { mdsvex } from 'mdsvex';\n\n // ...\n extensions: ['.svelte', '.svx'],\n preprocess: [mdsvex()],\n`;\n\nconst NOT_FOUND_HINT = dedent`\n Enable mdsvex by passing config to the sveltekit() plugin in vite.config.ts:\n\n import { sveltekit } from '@sveltejs/kit/vite';\n import { mdsvex } from 'mdsvex';\n import { defineConfig } from 'vite';\n\n export default defineConfig({\n plugins: [\n sveltekit({\n extensions: ['.svelte', '.svx'],\n preprocess: [mdsvex()],\n }),\n ],\n });\n`;\n\nfunction ensureExtensionsSvx(obj: ObjectLiteralExpression): boolean {\n const existing = obj.getProperty(\"extensions\");\n if (!existing) {\n obj.addPropertyAssignment({\n name: \"extensions\",\n initializer: \"['.svelte', '.svx']\",\n });\n return true;\n }\n if (existing.getKind() !== SyntaxKind.PropertyAssignment) return false;\n const init = (\n existing as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (!init || init.getKind() !== SyntaxKind.ArrayLiteralExpression) {\n (existing as import(\"ts-morph\").PropertyAssignment).setInitializer(\n \"['.svelte', '.svx']\",\n );\n return true;\n }\n const arr = init as ArrayLiteralExpression;\n const hasSvx = arr\n .getElements()\n .some((el) => el.getText().replace(/['\"`]/g, \"\") === \".svx\");\n if (hasSvx) return false;\n arr.addElement(\"'.svx'\");\n return true;\n}\n\nfunction ensurePreprocessMdsvex(obj: ObjectLiteralExpression): boolean {\n const existing = obj.getProperty(\"preprocess\");\n if (!existing) {\n obj.addPropertyAssignment({\n name: \"preprocess\",\n initializer: \"[mdsvex()]\",\n });\n return true;\n }\n if (existing.getKind() !== SyntaxKind.PropertyAssignment) return false;\n const init = (\n existing as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (!init) {\n (existing as import(\"ts-morph\").PropertyAssignment).setInitializer(\n \"[mdsvex()]\",\n );\n return true;\n }\n if (init.getKind() === SyntaxKind.ArrayLiteralExpression) {\n const arr = init as ArrayLiteralExpression;\n const hasMdsvex = arr\n .getElements()\n .some((el) => /\\bmdsvex\\s*\\(/.test(el.getText()));\n if (hasMdsvex) return false;\n arr.addElement(\"mdsvex()\");\n return true;\n }\n const text = init.getText();\n if (/\\bmdsvex\\s*\\(/.test(text)) return false;\n (existing as import(\"ts-morph\").PropertyAssignment).setInitializer(\n `[${text}, mdsvex()]`,\n );\n return true;\n}\n\n/**\n * Enable mdsvex: ensure `extensions` includes `.svx`, `preprocess` includes\n * `mdsvex()`, and the `mdsvex` import is present, at the top level of the\n * inline sveltekit() arg in vite.config.\n */\nexport function modifyViteConfigMdsvex(root: string): ConfigModifyResult {\n return modifyConfig(\n root,\n { notFound: NOT_FOUND_HINT, failed: FAILURE_HINT },\n (target) => {\n ensureExtensionsSvx(target.configObject);\n ensurePreprocessMdsvex(target.configObject);\n ensureImports(target.sourceFile, [\n { namedImports: [\"mdsvex\"], moduleSpecifier: \"mdsvex\" },\n ]);\n return true;\n },\n );\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst PRISM_IMPORT = `import '../css/prism-vsc-dark-plus.css';`;\n\nconst NOT_FOUND_HINT = dedent`\n Create src/routes/+layout.svelte and import the Prism theme for\n code block highlighting in blog posts:\n\n <script lang=\"ts\">\n import '../app.css';\n ${PRISM_IMPORT}\n </script>\n`;\n\nconst FAILURE_HINT = dedent`\n Import the Prism theme in your root +layout.svelte for blog code\n block highlighting:\n\n ${PRISM_IMPORT}\n`;\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 const script = file.getScript();\n if (!script) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n if (script.content.includes(\"prism-vsc-dark-plus.css\")) {\n return { status: \"success\", changed: false };\n }\n\n file.modifyScript((source) => {\n const appCssMatch = source.match(\n /^(\\s*)import\\s+['\"][^'\"]*app\\.css['\"];?\\s*$/m,\n );\n if (appCssMatch) {\n const indent = appCssMatch[1] ?? \"\";\n const insertion = `\\n${indent}${PRISM_IMPORT}`;\n const end = (appCssMatch.index ?? 0) + appCssMatch[0].length;\n return source.slice(0, end) + insertion + source.slice(end);\n }\n return source.replace(/^/, `\\n\\t${PRISM_IMPORT}\\n`);\n });\n\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst BLOG_NAVBAR_ITEM = `\n\t\t<Navbar.Item>\n\t\t\t<Button class=\"w-full justify-start md:justify-center md:w-auto\" href=\"/blog\" variant=\"ghost\">\n\t\t\t\tBlog\n\t\t\t</Button>\n\t\t</Navbar.Item>\n\t`;\n\nconst FAILURE_HINT = dedent`\n Add a Blog link inside <Navbar.List> in the public root layout:\n\n <Navbar.Item>\n <Button class=\"w-full justify-start md:justify-center md:w-auto\" href=\"/blog\" variant=\"ghost\">\n Blog\n </Button>\n </Navbar.Item>\n`;\n\nconst NOT_FOUND_HINT = dedent`\n Create a public root layout with a Blog link in its Navbar.List:\n\n <Navbar.Item>\n <Button class=\"w-full justify-start md:justify-center md:w-auto\" href=\"/blog\" variant=\"ghost\">\n Blog\n </Button>\n </Navbar.Item>\n`;\n\nexport function modifyPublicRootLayout(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\n const raw = fs.readFileSync(layoutPath, \"utf8\");\n if (/href=[\"']\\/blog[\"']/.test(raw)) {\n return { status: \"success\", changed: false };\n }\n\n file.insertBeforeClosingTag(\"Navbar.List\", BLOG_NAVBAR_ITEM);\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\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 { ensureSiteFile } from \"../../../runtime/site\";\nimport { modifyViteConfigMdsvex } from \"./modifies/vite-config\";\nimport { modifyRootLayoutSvelte } from \"./modifies/root-layout-svelte\";\nimport { modifyPublicRootLayout } from \"./modifies/public-root-layout-svelte\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Modifying vite.config for mdsvex\");\n const mdsvex = modifyViteConfigMdsvex(options.root);\n pushResult(modifyOutcomeToFile(mdsvex.filePath, mdsvex.outcome));\n\n logger.info(\"Modifying src/routes/+layout.svelte\");\n const rootLayoutPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(rootLayoutPath, modifyRootLayoutSvelte(rootLayoutPath)),\n );\n\n logger.info(\"Modifying public root layout\");\n const publicLayoutCandidates = [\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 ];\n const publicLayoutPath =\n publicLayoutCandidates.find((p) => fs.existsSync(p)) ??\n publicLayoutCandidates[0];\n pushResult(\n modifyOutcomeToFile(\n publicLayoutPath,\n modifyPublicRootLayout(publicLayoutPath),\n ),\n );\n\n // The RSS feed is titled and linked from `src/lib/site.ts`.\n const siteFile = await ensureSiteFile(options);\n\n return {\n creates: siteFile ? [siteFile] : [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;;;;AAYA,IAAMA,IAAe,CAAM;;;;;;;;GAUrBC,IAAiB,CAAM;;;;;;;;;;;;;;;;AAiB7B,SAASa,EAAoB,GAAuC;CAClE,IAAMC,IAAWC,EAAI,YAAY,YAAY;CAC7C,IAAI,CAACD,GAKH,OAJAC,EAAI,sBAAsB;EACxB,MAAM;EACN,aAAa;CACf,CAAC,GACM;CAET,IAAID,EAAS,QAAQ,MAAME,EAAW,oBAAoB,OAAO;CACjE,IAAMC,IACJH,EACA,eAAe;CACjB,IAAI,CAACG,KAAQA,EAAK,QAAQ,MAAMD,EAAW,wBAIzC,OAHAF,EAAoD,eAClD,qBACF,GACO;CAET,IAAMI,IAAMD;CAMZ,OAFA,CAHeC,EACZ,YAAY,CAAC,CACb,MAAM,MAAOC,EAAG,QAAQ,CAAC,CAAC,QAAQ,UAAU,EAAE,MAAM,MACnD,MACJD,EAAI,WAAW,QAAQ,GAChB;AACT;AAEA,SAASE,EAAuB,GAAuC;CACrE,IAAMN,IAAWC,EAAI,YAAY,YAAY;CAC7C,IAAI,CAACD,GAKH,OAJAC,EAAI,sBAAsB;EACxB,MAAM;EACN,aAAa;CACf,CAAC,GACM;CAET,IAAID,EAAS,QAAQ,MAAME,EAAW,oBAAoB,OAAO;CACjE,IAAMC,IACJH,EACA,eAAe;CACjB,IAAI,CAACG,GAIH,OAHAH,EAAoD,eAClD,YACF,GACO;CAET,IAAIG,EAAK,QAAQ,MAAMD,EAAW,wBAAwB;EACxD,IAAME,IAAMD;EAMZ,OAFA,CAHkBC,EACf,YAAY,CAA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Y,oBAAoB;EACzEnC,EAAK,KAAKmC,EAAQ,MAAM,OAAO,UAAU,oBAAoB;EAC7DnC,EAAK,KAAKmC,EAAQ,MAAM,OAAO,UAAU,YAAY,gBAAgB;CACvE,GACMM,IACJD,EAAuB,MAAM,MAAMzC,EAAG,WAAW2C,CAAC,CAAC,KACnDF,EAAuB;CACzB,EACE9C,EACE+C,GACAV,EAAuBU,CAAgB,CACzC,CACF;CAGA,IAAME,IAAW,MAAMC,EAAeT,CAAO;CAE7C,OAAO;EACL,SAASQ,IAAW,CAACA,CAAQ,IAAI,CAAC;EAClC;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
@@ -1,9 +1,9 @@
1
- import { t as e } from "./dedent-Gq6Krl4n.js";
2
- import { _ as t, r as n } from "./ts-morph-helpers-CHI9wAil.js";
3
- import { t as r } from "./svelte-file-Dv5-bl79.js";
1
+ import { t as e } from "./dedent-CCUOcPFW.js";
2
+ import { t } from "./svelte-file-DfplF3BU.js";
3
+ import { _ as n, r } from "./ts-morph-helpers-B4KZXP44.js";
4
4
  import i from "node:fs";
5
5
  import { Node as a, SyntaxKind as o } from "ts-morph";
6
- //#region src/patterns/enable/og/modifies/layout.svelte.ts
6
+ // src/patterns/enable/og/modifies/layout.svelte.ts
7
7
  var s = "#lib/og/index.js", c = [
8
8
  "Pass the meta tags the root src/routes/+layout.svelte renders through withCard.",
9
9
  "",
@@ -27,7 +27,7 @@ function u(e) {
27
27
  status: "not-found",
28
28
  message: c
29
29
  };
30
- let a = r.fromPath(e), o = a.getScript();
30
+ let a = t.fromPath(e), o = a.getScript();
31
31
  if (!o) return {
32
32
  status: "failed",
33
33
  message: c
@@ -38,11 +38,11 @@ function u(e) {
38
38
  };
39
39
  let u = !1;
40
40
  return a.modifyScript((e) => {
41
- let { source: r } = t(e, (e) => {
41
+ let { source: t } = n(e, (e) => {
42
42
  let t = l(e);
43
43
  if (!t) return;
44
- let [r] = t.getArguments();
45
- r.replaceWithText(`withCard(${r.getText()}, page.url)`), u = !0, n(e, [{
44
+ let [n] = t.getArguments();
45
+ n.replaceWithText(`withCard(${n.getText()}, page.url)`), u = !0, r(e, [{
46
46
  namedImports: ["page"],
47
47
  moduleSpecifier: "$app/state"
48
48
  }, {
@@ -50,7 +50,7 @@ function u(e) {
50
50
  moduleSpecifier: s
51
51
  }]);
52
52
  });
53
- return u ? r : e;
53
+ return u ? t : e;
54
54
  }), u ? (a.writeTo(e), {
55
55
  status: "success",
56
56
  changed: a.hasChanged()
@@ -59,7 +59,6 @@ function u(e) {
59
59
  message: c
60
60
  };
61
61
  }
62
- //#endregion
63
62
  export { l as n, u as r, s as t };
64
63
 
65
- //# sourceMappingURL=layout.svelte-Cb12mxua.js.map
64
+ //# sourceMappingURL=layout.svelte-B6wOQ7SM.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"layout.svelte-Cb12mxua.js","names":["dedent","withInMemoryScript","ensureImports","SvelteFile","fs","MODULE_SPECIFIER","HINT","findMetaTagsDerived","init","sf","SyntaxKind","d","Node","modifyLayoutSvelte","layoutPath","file","script","wrapped","out","source","derived","arg"],"sources":["../../src/patterns/enable/og/modifies/layout.svelte.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Node, SyntaxKind, type CallExpression } from \"ts-morph\";\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 MODULE_SPECIFIER = \"#lib/og/index.js\";\n\nconst HINT = [\n \"Pass the meta tags the root src/routes/+layout.svelte renders through withCard.\",\n \"\",\n 'Imports for the <script lang=\"ts\"> tag:',\n \"\",\n dedent`\n import { page } from '$app/state';\n import { withCard } from '${MODULE_SPECIFIER}';\n `,\n \"\",\n \"Then wrap what <MetaTags> is given:\",\n \"\",\n \"let metaTags = $derived(withCard(deepMerge(data.baseMetaTags, page.data.pageMetaTags), page.url));\",\n].join(\"\\n\");\n\n/** The `$derived(...)` call that `let metaTags = ...` is initialised with. */\nexport function findMetaTagsDerived(\n sf: import(\"ts-morph\").SourceFile,\n): CallExpression | null {\n const declaration = sf\n .getDescendantsOfKind(SyntaxKind.VariableDeclaration)\n .find((d) => d.getName() === \"metaTags\");\n const init = declaration?.getInitializer();\n if (!init || !Node.isCallExpression(init)) return null;\n if (init.getExpression().getText() !== \"$derived\") return null;\n return init.getArguments().length === 1 ? init : null;\n}\n\n/**\n * Wraps the root layout's `metaTags` in `withCard(..., page.url)`, which swaps\n * the site-wide `/og.jpg` for the page's generated card. Vela's templates all\n * build `metaTags` the same way; a layout that does not gets the snippet to\n * paste instead.\n */\nexport function modifyLayoutSvelte(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"not-found\", message: HINT };\n }\n\n const file = SvelteFile.fromPath(layoutPath);\n const script = file.getScript();\n if (!script) return { status: \"failed\", message: HINT };\n if (script.content.includes(\"withCard(\")) {\n return { status: \"success\", changed: false };\n }\n\n let wrapped = false;\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n const derived = findMetaTagsDerived(sf);\n if (!derived) return;\n const [arg] = derived.getArguments();\n arg.replaceWithText(`withCard(${arg.getText()}, page.url)`);\n wrapped = true;\n ensureImports(sf, [\n { namedImports: [\"page\"], moduleSpecifier: \"$app/state\" },\n { namedImports: [\"withCard\"], moduleSpecifier: MODULE_SPECIFIER },\n ]);\n });\n return wrapped ? out : source;\n });\n\n if (!wrapped) return { status: \"failed\", message: HINT };\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n"],"mappings":";;;;;;AAUA,IAAaK,IAAmB,oBAE1BC,IAAO;CACX;CACA;CACA;CACA;CACA,CAAM;;gCAEwBD,EAAiB;;CAE/C;CACA;CACA;CACA;AACF,CAA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ST;CAAK;AAGzD"}
1
+ {"version":3,"file":"layout.svelte-B6wOQ7SM.js","names":["dedent","withInMemoryScript","fs","MODULE_SPECIFIER","HINT","findMetaTagsDerived","init","sf","SyntaxKind","d","Node","modifyLayoutSvelte","layoutPath","file","SvelteFile","script","wrapped","out","source","derived","arg","ensureImports"],"sources":["../../src/patterns/enable/og/modifies/layout.svelte.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Node, SyntaxKind, type CallExpression } from \"ts-morph\";\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 MODULE_SPECIFIER = \"#lib/og/index.js\";\n\nconst HINT = [\n \"Pass the meta tags the root src/routes/+layout.svelte renders through withCard.\",\n \"\",\n 'Imports for the <script lang=\"ts\"> tag:',\n \"\",\n dedent`\n import { page } from '$app/state';\n import { withCard } from '${MODULE_SPECIFIER}';\n `,\n \"\",\n \"Then wrap what <MetaTags> is given:\",\n \"\",\n \"let metaTags = $derived(withCard(deepMerge(data.baseMetaTags, page.data.pageMetaTags), page.url));\",\n].join(\"\\n\");\n\n/** The `$derived(...)` call that `let metaTags = ...` is initialised with. */\nexport function findMetaTagsDerived(\n sf: import(\"ts-morph\").SourceFile,\n): CallExpression | null {\n const declaration = sf\n .getDescendantsOfKind(SyntaxKind.VariableDeclaration)\n .find((d) => d.getName() === \"metaTags\");\n const init = declaration?.getInitializer();\n if (!init || !Node.isCallExpression(init)) return null;\n if (init.getExpression().getText() !== \"$derived\") return null;\n return init.getArguments().length === 1 ? init : null;\n}\n\n/**\n * Wraps the root layout's `metaTags` in `withCard(..., page.url)`, which swaps\n * the site-wide `/og.jpg` for the page's generated card. Vela's templates all\n * build `metaTags` the same way; a layout that does not gets the snippet to\n * paste instead.\n */\nexport function modifyLayoutSvelte(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"not-found\", message: HINT };\n }\n\n const file = SvelteFile.fromPath(layoutPath);\n const script = file.getScript();\n if (!script) return { status: \"failed\", message: HINT };\n if (script.content.includes(\"withCard(\")) {\n return { status: \"success\", changed: false };\n }\n\n let wrapped = false;\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n const derived = findMetaTagsDerived(sf);\n if (!derived) return;\n const [arg] = derived.getArguments();\n arg.replaceWithText(`withCard(${arg.getText()}, page.url)`);\n wrapped = true;\n ensureImports(sf, [\n { namedImports: [\"page\"], moduleSpecifier: \"$app/state\" },\n { namedImports: [\"withCard\"], moduleSpecifier: MODULE_SPECIFIER },\n ]);\n });\n return wrapped ? out : source;\n });\n\n if (!wrapped) return { status: \"failed\", message: HINT };\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n"],"mappings":";;;;;;AAUA,IAAaG,IAAmB,oBAE1BC,IAAO;CACX;CACA;CACA;CACA;CACA,CAAM;;gCAEwBD,EAAiB;;CAE/C;CACA;CACA;CACA;AACF,CAAC,CAAC,KAAK,IAAI;AAGX,SAAgBE,EACd,GACuB;CAIvB,IAAMC,IAHcC,EACjB,qBAAqBC,EAAW,mBAAmB,CAAC,CACpD,MAAM,MAAMC,EAAE,QAAQ,MAAM,UAClB,CAAA,EAAa,eAAe;CAGzC,OAFI,CAACH,KAAQ,CAACI,EAAK,iBAAiBJ,CAAI,KACpCA,EAAK,cAAc,CAAC,CAAC,QAAQ,MAAM,aAAmB,OACnDA,EAAK,aAAa,CAAC,CAAC,WAAW,IAAIA,IAAO;AACnD;AAQA,SAAgBK,EAAmB,GAAmC;CACpE,IAAI,CAACT,EAAG,WAAWU,CAAU,GAC3B,OAAO;EAAE,QAAQ;EAAa,SAASR;CAAK;CAG9C,IAAMS,IAAOC,EAAW,SAASF,CAAU,GACrCG,IAASF,EAAK,UAAU;CAC9B,IAAI,CAACE,GAAQ,OAAO;EAAE,QAAQ;EAAU,SAASX;CAAK;CACtD,IAAIW,EAAO,QAAQ,SAAS,WAAW,GACrC,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAIC,IAAU;CAkBd,OAjBAH,EAAK,cAAc,MAAW;EAC5B,IAAM,EAAE,QAAQI,MAAQhB,EAAmBiB,IAAS,MAAO;GACzD,IAAMC,IAAUd,EAAoBE,CAAE;GACtC,IAAI,CAACY,GAAS;GACd,IAAM,CAACC,KAAOD,EAAQ,aAAa;GAGnC,AAFAC,EAAI,gBAAgB,YAAYA,EAAI,QAAQ,EAAE,YAAY,GAC1D,IAAU,IACVC,EAAcd,GAAI,CAChB;IAAE,cAAc,CAAC,MAAM;IAAG,iBAAiB;GAAa,GACxD;IAAE,cAAc,CAAC,UAAU;IAAG,iBAAiBJ;GAAiB,CAClE,CAAC;EACH,CAAC;EACD,OAAOa,IAAUC,IAAMC;CACzB,CAAC,GAEIF,KACLH,EAAK,QAAQD,CAAU,GAChB;EAAE,QAAQ;EAAW,SAASC,EAAK,WAAW;CAAE,KAFlC;EAAE,QAAQ;EAAU,SAAST;CAAK;AAGzD"}
@@ -1,4 +1,4 @@
1
- //#region src/runtime/lib-specifier.ts
1
+ // src/runtime/lib-specifier.ts
2
2
  var e = [
3
3
  ".svelte",
4
4
  ".svg",
@@ -27,7 +27,6 @@ function s(e) {
27
27
  function c(e) {
28
28
  return (t) => o(t, e);
29
29
  }
30
- //#endregion
31
30
  export { i, s as n, c as r, o as t };
32
31
 
33
- //# sourceMappingURL=lib-specifier-Cngo1zF_.js.map
32
+ //# sourceMappingURL=lib-specifier-C3M0WTev.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"lib-specifier-Cngo1zF_.js","names":["KEPT_EXTENSIONS","SCRIPT_EXTENSION","INDEX_SUFFIX","trimSlashes","rel","libSpecifier","relPathUnderSrcLib","ext","modulePath","isLibSpecifier","match","spec","relPath","libAliasPath","alias","libModule"],"sources":["../../src/runtime/lib-specifier.ts"],"sourcesContent":["/**\n * `#lib` specifiers, written the way `sv migrate sveltekit-3` (sv 1.0.1, the\n * `lib-alias` task) writes them. SvelteKit 3 drops `$lib`; projects map\n * `\"#lib/*\": \"./src/lib/*\"` in package.json `imports`, and Node subpath\n * imports don't add extensions or resolve directories, so every specifier\n * names the file the import loads:\n *\n * - a `.ts` or `.js` module gets `.js` (`site.ts` → `#lib/site.js`,\n * `x.svelte.ts` → `#lib/x.svelte.js`);\n * - a directory gets `/index.js` (`components/ui/button` →\n * `#lib/components/ui/button/index.js`);\n * - `.svelte`, `.svg`, `.svx`, `.css` and `.json` files keep their name.\n */\n\n/** Extensions an import names as they are on disk. */\nconst KEPT_EXTENSIONS = [\".svelte\", \".svg\", \".svx\", \".css\", \".json\"];\n\nconst SCRIPT_EXTENSION = /\\.(ts|js)$/;\nconst INDEX_SUFFIX = /\\/index(\\.(ts|js))?$/;\n\nfunction trimSlashes(rel: string): string {\n return rel\n .replace(/\\\\/g, \"/\")\n .replace(/^\\.?\\/+/, \"\")\n .replace(/\\/+$/, \"\");\n}\n\n/**\n * The `#lib` specifier for a path under `src/lib`. `rel` names a file by its\n * name on disk (`site.ts`, `components/app-sidebar.svelte`) or, when its last\n * segment has none of the extensions above, a directory imported through its\n * `index` (`components/ui/button`). `\"\"` is `src/lib` itself: `#lib`.\n */\nexport function libSpecifier(relPathUnderSrcLib: string): string {\n const rel = trimSlashes(relPathUnderSrcLib);\n if (rel === \"\" || rel === \".\") return \"#lib\";\n if (SCRIPT_EXTENSION.test(rel))\n return `#lib/${rel.replace(SCRIPT_EXTENSION, \".js\")}`;\n if (KEPT_EXTENSIONS.some((ext) => rel.endsWith(ext))) return `#lib/${rel}`;\n return `#lib/${rel}/index.js`;\n}\n\n/** `components/ui/avatar/index.js` and `site.ts` → `components/ui/avatar`, `site`. */\nfunction modulePath(rel: string): string {\n return trimSlashes(rel)\n .replace(INDEX_SUFFIX, \"\")\n .replace(SCRIPT_EXTENSION, \"\");\n}\n\n/**\n * Whether `spec` imports `relPath` under `src/lib`: `#lib/x.js`, `#lib/x.ts`,\n * `#lib/x/index.js`, or the `$lib/x` a project from before SvelteKit 3 still\n * has. `relPath` is written either way (`site`, `site.ts`,\n * `components/ui/avatar`, `components/notifications-bell.svelte`).\n */\nexport function isLibSpecifier(spec: string, relPath: string): boolean {\n const match = /^[#$]lib(?:\\/(.*))?$/.exec(spec);\n if (!match) return false;\n return modulePath(match[1] ?? \"\") === modulePath(relPath);\n}\n\n/**\n * The directory under `src/lib` a `components.json` alias names: `#lib` and\n * `#lib/components/ui` (what shadcn-svelte writes for a SvelteKit 3 project),\n * or the `$lib` forms of a project from before it. Aliases name directories,\n * so no extension is involved. `\"\"` is `src/lib` itself; anything else (a\n * custom alias) is null.\n */\nexport function libAliasPath(alias: string): string | null {\n const match = /^[#$]lib(?:\\/(.*))?$/.exec(alias);\n if (!match) return null;\n return trimSlashes(match[1] ?? \"\");\n}\n\n/** `isLibSpecifier` bound to one path, for the import helpers' module matchers. */\nexport function libModule(relPath: string): (spec: string) => boolean {\n return (spec) => isLibSpecifier(spec, relPath);\n}\n"],"mappings":";AAeA,IAAMA,IAAkB;CAAC;CAAW;CAAQ;CAAQ;CAAQ;AAAO,GAE7DC,IAAmB,cACnBC,IAAe;AAErB,SAASC,EAAY,GAAqB;CACxC,OAAOC,EACJ,QAAQ,OAAO,GAAG,CAAC,CACnB,QAAQ,WAAW,EAAE,CAAC,CACtB,QAAQ,QAAQ,EAAE;AACvB;AAQA,SAAgBC,EAAa,GAAoC;CAC/D,IAAMD,IAAMD,EAAYG,CAAkB;CAK1C,OAJIF,MAAQ,MAAMA,MAAQ,MAAY,SAClCH,EAAiB,KAAKG,CAAG,IACpB,QAAQA,EAAI,QAAQH,GAAkB,KAAK,MAChDD,EAAgB,MAAM,MAAQI,EAAI,SAASG,CAAG,CAAC,IAAU,QAAQH,MAC9D,QAAQA,EAAI;AACrB;AAGA,SAASI,EAAW,GAAqB;CACvC,OAAOL,EAAYC,CAAG,CAAC,CACpB,QAAQF,GAAc,EAAE,CAAC,CACzB,QAAQD,GAAkB,EAAE;AACjC;AAQA,SAAgBQ,EAAe,GAAc,GAA0B;CACrE,IAAMC,IAAQ,uBAAuB,KAAKC,CAAI;CAE9C,OADKD,IACEF,EAAWE,EAAM,MAAM,EAAE,MAAMF,EAAWI,CAAO,IADrC;AAErB;AASA,SAAgBC,EAAa,GAA8B;CACzD,IAAMH,IAAQ,uBAAuB,KAAKI,CAAK;CAE/C,OADKJ,IACEP,EAAYO,EAAM,MAAM,EAAE,IADd;AAErB;AAGA,SAAgBK,EAAU,GAA4C;CACpE,QAAQ,MAASN,EAAeE,GAAMC,CAAO;AAC/C"}
1
+ {"version":3,"file":"lib-specifier-C3M0WTev.js","names":["KEPT_EXTENSIONS","SCRIPT_EXTENSION","INDEX_SUFFIX","trimSlashes","rel","libSpecifier","relPathUnderSrcLib","ext","modulePath","isLibSpecifier","match","spec","relPath","libAliasPath","alias","libModule"],"sources":["../../src/runtime/lib-specifier.ts"],"sourcesContent":["/**\n * `#lib` specifiers, written the way `sv migrate sveltekit-3` (sv 1.0.1, the\n * `lib-alias` task) writes them. SvelteKit 3 drops `$lib`; projects map\n * `\"#lib/*\": \"./src/lib/*\"` in package.json `imports`, and Node subpath\n * imports don't add extensions or resolve directories, so every specifier\n * names the file the import loads:\n *\n * - a `.ts` or `.js` module gets `.js` (`site.ts` → `#lib/site.js`,\n * `x.svelte.ts` → `#lib/x.svelte.js`);\n * - a directory gets `/index.js` (`components/ui/button` →\n * `#lib/components/ui/button/index.js`);\n * - `.svelte`, `.svg`, `.svx`, `.css` and `.json` files keep their name.\n */\n\n/** Extensions an import names as they are on disk. */\nconst KEPT_EXTENSIONS = [\".svelte\", \".svg\", \".svx\", \".css\", \".json\"];\n\nconst SCRIPT_EXTENSION = /\\.(ts|js)$/;\nconst INDEX_SUFFIX = /\\/index(\\.(ts|js))?$/;\n\nfunction trimSlashes(rel: string): string {\n return rel\n .replace(/\\\\/g, \"/\")\n .replace(/^\\.?\\/+/, \"\")\n .replace(/\\/+$/, \"\");\n}\n\n/**\n * The `#lib` specifier for a path under `src/lib`. `rel` names a file by its\n * name on disk (`site.ts`, `components/app-sidebar.svelte`) or, when its last\n * segment has none of the extensions above, a directory imported through its\n * `index` (`components/ui/button`). `\"\"` is `src/lib` itself: `#lib`.\n */\nexport function libSpecifier(relPathUnderSrcLib: string): string {\n const rel = trimSlashes(relPathUnderSrcLib);\n if (rel === \"\" || rel === \".\") return \"#lib\";\n if (SCRIPT_EXTENSION.test(rel))\n return `#lib/${rel.replace(SCRIPT_EXTENSION, \".js\")}`;\n if (KEPT_EXTENSIONS.some((ext) => rel.endsWith(ext))) return `#lib/${rel}`;\n return `#lib/${rel}/index.js`;\n}\n\n/** `components/ui/avatar/index.js` and `site.ts` → `components/ui/avatar`, `site`. */\nfunction modulePath(rel: string): string {\n return trimSlashes(rel)\n .replace(INDEX_SUFFIX, \"\")\n .replace(SCRIPT_EXTENSION, \"\");\n}\n\n/**\n * Whether `spec` imports `relPath` under `src/lib`: `#lib/x.js`, `#lib/x.ts`,\n * `#lib/x/index.js`, or the `$lib/x` a project from before SvelteKit 3 still\n * has. `relPath` is written either way (`site`, `site.ts`,\n * `components/ui/avatar`, `components/notifications-bell.svelte`).\n */\nexport function isLibSpecifier(spec: string, relPath: string): boolean {\n const match = /^[#$]lib(?:\\/(.*))?$/.exec(spec);\n if (!match) return false;\n return modulePath(match[1] ?? \"\") === modulePath(relPath);\n}\n\n/**\n * The directory under `src/lib` a `components.json` alias names: `#lib` and\n * `#lib/components/ui` (what shadcn-svelte writes for a SvelteKit 3 project),\n * or the `$lib` forms of a project from before it. Aliases name directories,\n * so no extension is involved. `\"\"` is `src/lib` itself; anything else (a\n * custom alias) is null.\n */\nexport function libAliasPath(alias: string): string | null {\n const match = /^[#$]lib(?:\\/(.*))?$/.exec(alias);\n if (!match) return null;\n return trimSlashes(match[1] ?? \"\");\n}\n\n/** `isLibSpecifier` bound to one path, for the import helpers' module matchers. */\nexport function libModule(relPath: string): (spec: string) => boolean {\n return (spec) => isLibSpecifier(spec, relPath);\n}\n"],"mappings":";AAeA,IAAMA,IAAkB;CAAC;CAAW;CAAQ;CAAQ;CAAQ;AAAO,GAE7DC,IAAmB,cACnBC,IAAe;AAErB,SAASC,EAAY,GAAqB;CACxC,OAAOC,EACJ,QAAQ,OAAO,GAAG,CAAC,CACnB,QAAQ,WAAW,EAAE,CAAC,CACtB,QAAQ,QAAQ,EAAE;AACvB;AAQA,SAAgBC,EAAa,GAAoC;CAC/D,IAAMD,IAAMD,EAAYG,CAAkB;CAK1C,OAJIF,MAAQ,MAAMA,MAAQ,MAAY,SAClCH,EAAiB,KAAKG,CAAG,IACpB,QAAQA,EAAI,QAAQH,GAAkB,KAAK,MAChDD,EAAgB,MAAM,MAAQI,EAAI,SAASG,CAAG,CAAC,IAAU,QAAQH,MAC9D,QAAQA,EAAI;AACrB;AAGA,SAASI,EAAW,GAAqB;CACvC,OAAOL,EAAYC,CAAG,CAAC,CACpB,QAAQF,GAAc,EAAE,CAAC,CACzB,QAAQD,GAAkB,EAAE;AACjC;AAQA,SAAgBQ,EAAe,GAAc,GAA0B;CACrE,IAAMC,IAAQ,uBAAuB,KAAKC,CAAI;CAE9C,OADKD,IACEF,EAAWE,EAAM,MAAM,EAAE,MAAMF,EAAWI,CAAO,IADrC;AAErB;AASA,SAAgBC,EAAa,GAA8B;CACzD,IAAMH,IAAQ,uBAAuB,KAAKI,CAAK;CAE/C,OADKJ,IACEP,EAAYO,EAAM,MAAM,EAAE,IADd;AAErB;AAGA,SAAgBK,EAAU,GAA4C;CACpE,QAAQ,MAASN,EAAeE,GAAMC,CAAO;AAC/C"}
@@ -1,5 +1,5 @@
1
1
  import { Node as e, Project as t, QuoteKind as n, SyntaxKind as r } from "ts-morph";
2
- //#region src/runtime/load-function.ts
2
+ // src/runtime/load-function.ts
3
3
  function i() {
4
4
  return new t({
5
5
  compilerOptions: { allowJs: !0 },
@@ -15,7 +15,7 @@ function a(e, t, n) {
15
15
  else for (let e of n) r.getNamedImports().some((t) => t.getName() === e) || r.addNamedImport(e);
16
16
  }
17
17
  function o(e, t) {
18
- t.namedImports?.length && a(e, t.moduleSpecifier, t.namedImports), !e.getImportDeclarations().find((e) => e.getModuleSpecifierValue() === t.moduleSpecifier) && e.addImportDeclaration({
18
+ t.namedImports?.length && a(e, t.moduleSpecifier, t.namedImports), e.getImportDeclarations().find((e) => e.getModuleSpecifierValue() === t.moduleSpecifier) || e.addImportDeclaration({
19
19
  moduleSpecifier: t.moduleSpecifier,
20
20
  defaultImport: t.defaultImport,
21
21
  namespaceImport: t.namespaceImport
@@ -73,7 +73,6 @@ function m(t) {
73
73
  param: r
74
74
  } : { kind: "unsupported" };
75
75
  }
76
- //#endregion
77
76
  export { f as a, i as c, c as i, d as l, a as n, p as o, u as r, m as s, o as t };
78
77
 
79
- //# sourceMappingURL=load-function-Dmkhg1pQ.js.map
78
+ //# sourceMappingURL=load-function-BFvIVsh7.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"load-function-Dmkhg1pQ.js","names":["newProject","Project","QuoteKind","ensureNamedImports","existing","sourceFile","d","moduleSpecifier","names","name","ni","ensureImportSpec","spec","unwrapFunction","Node","node","arg","fn","findLoadFunction","declaration","variable","initializer","isFunctionNode","findFinalReturn","statements","body","last","SyntaxKind","r","returnedObject","expression","statement","hasProperty","object","property","hasSpreadOf","expressionText","inspectEventParameter","params","param","nameNode"],"sources":["../../src/runtime/load-function.ts"],"sourcesContent":["import {\n Node,\n Project,\n QuoteKind,\n SyntaxKind,\n type ArrowFunction,\n type Block,\n type FunctionDeclaration,\n type FunctionExpression,\n type ObjectLiteralExpression,\n type ParameterDeclaration,\n type ReturnStatement,\n type SourceFile,\n} from \"ts-morph\";\nimport type { ImportSpec } from \"./ts-morph-helpers\";\n\n/**\n * What the two layout modifiers have in common: finding a SvelteKit `load`,\n * working out how it receives its event, and locating the object it returns.\n */\n\nexport type LoadFunction =\n ArrowFunction | FunctionExpression | FunctionDeclaration;\n\nexport function newProject(): Project {\n return new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n}\n\nexport function ensureNamedImports(\n sourceFile: SourceFile,\n moduleSpecifier: string,\n names: string[],\n) {\n const existing = sourceFile\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === moduleSpecifier);\n if (!existing) {\n sourceFile.addImportDeclaration({ namedImports: names, moduleSpecifier });\n return;\n }\n for (const name of names) {\n const has = existing.getNamedImports().some((ni) => ni.getName() === name);\n if (!has) existing.addNamedImport(name);\n }\n}\n\nexport function ensureImportSpec(sourceFile: SourceFile, spec: ImportSpec) {\n if (spec.namedImports?.length) {\n ensureNamedImports(sourceFile, spec.moduleSpecifier, spec.namedImports);\n }\n const existing = sourceFile\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === spec.moduleSpecifier);\n if (existing) return;\n sourceFile.addImportDeclaration({\n moduleSpecifier: spec.moduleSpecifier,\n defaultImport: spec.defaultImport,\n namespaceImport: spec.namespaceImport,\n });\n}\n\n/** Peel wrappers (`loadFlash(fn)`, `(fn)`, `fn satisfies X`) down to the function. */\nfunction unwrapFunction(node: Node): ArrowFunction | FunctionExpression | null {\n if (Node.isArrowFunction(node) || Node.isFunctionExpression(node)) {\n return node;\n }\n if (\n Node.isParenthesizedExpression(node) ||\n Node.isAsExpression(node) ||\n Node.isSatisfiesExpression(node)\n ) {\n return unwrapFunction(node.getExpression());\n }\n if (Node.isCallExpression(node)) {\n for (const arg of node.getArguments()) {\n const fn = unwrapFunction(arg);\n if (fn) return fn;\n }\n }\n return null;\n}\n\n/** The exported `load`, whether declared as a function or wrapped in a const. */\nexport function findLoadFunction(sourceFile: SourceFile): LoadFunction | null {\n const declaration = sourceFile.getFunction(\"load\");\n if (declaration) {\n return declaration.isExported() ? declaration : null;\n }\n\n const variable = sourceFile.getVariableDeclaration(\"load\");\n if (!variable) return null;\n if (!variable.getVariableStatement()?.isExported()) return null;\n\n const initializer = variable.getInitializer();\n return initializer ? unwrapFunction(initializer) : null;\n}\n\nfunction isFunctionNode(node: Node): boolean {\n return (\n Node.isArrowFunction(node) ||\n Node.isFunctionExpression(node) ||\n Node.isFunctionDeclaration(node) ||\n Node.isMethodDeclaration(node)\n );\n}\n\n/**\n * The single, final `return <expression>` of the load body, or null when the\n * body has early returns — those would need any insertion hoisted above them,\n * and guessing where is worse than refusing.\n */\nexport function findFinalReturn(\n fn: LoadFunction,\n body: Block,\n): ReturnStatement | null {\n const statements = body.getStatements();\n const last = statements[statements.length - 1];\n if (!last || !Node.isReturnStatement(last)) return null;\n\n const returns = body\n .getDescendantsOfKind(SyntaxKind.ReturnStatement)\n .filter((r) => r.getFirstAncestor(isFunctionNode) === fn);\n if (returns.length !== 1) return null;\n\n return last;\n}\n\n/** The object literal a return statement yields, unwrapping parentheses. */\nexport function returnedObject(\n statement: ReturnStatement,\n): ObjectLiteralExpression | null {\n let expression = statement.getExpression();\n while (expression && Node.isParenthesizedExpression(expression)) {\n expression = expression.getExpression();\n }\n if (!expression || !Node.isObjectLiteralExpression(expression)) return null;\n return expression;\n}\n\nexport function hasProperty(\n object: ObjectLiteralExpression,\n name: string,\n): boolean {\n return object.getProperties().some((property) => {\n if (\n Node.isPropertyAssignment(property) ||\n Node.isShorthandPropertyAssignment(property)\n ) {\n return property.getName() === name;\n }\n return false;\n });\n}\n\nexport function hasSpreadOf(\n object: ObjectLiteralExpression,\n expressionText: string,\n): boolean {\n return object\n .getProperties()\n .some(\n (property) =>\n Node.isSpreadAssignment(property) &&\n property.getExpression().getText() === expressionText,\n );\n}\n\n/** How a load receives its event: not at all, by name, or destructured. */\nexport type EventParameter =\n | { kind: \"none\" }\n | { kind: \"identifier\"; name: string; param: ParameterDeclaration }\n | {\n kind: \"binding\";\n pattern: import(\"ts-morph\").ObjectBindingPattern;\n param: ParameterDeclaration;\n }\n | { kind: \"unsupported\" };\n\nexport function inspectEventParameter(fn: LoadFunction): EventParameter {\n const params = fn.getParameters();\n if (params.length === 0) return { kind: \"none\" };\n if (params.length > 1) return { kind: \"unsupported\" };\n\n const param = params[0];\n if (param.getInitializer() || param.isRestParameter()) {\n return { kind: \"unsupported\" };\n }\n const nameNode = param.getNameNode();\n if (Node.isIdentifier(nameNode)) {\n return { kind: \"identifier\", name: nameNode.getText(), param };\n }\n if (Node.isObjectBindingPattern(nameNode)) {\n return { kind: \"binding\", pattern: nameNode, param };\n }\n return { kind: \"unsupported\" };\n}\n"],"mappings":";;AAwBA,SAAgBA,IAAsB;CACpC,OAAO,IAAIC,EAAQ;EACjB,iBAAiB,EAAE,SAAS,GAAK;EACjC,sBAAsB,EAAE,WAAWC,EAAU,OAAO;CACtD,CAAC;AACH;AAEA,SAAgBC,EACd,GACA,GACA,GACA;CACA,IAAMC,IAAWC,EACd,sBAAsB,CAAC,CACvB,MAAM,MAAMC,EAAE,wBAAwB,MAAMC,CAAe;CAC9D,IAAI,CAACH,GACH,EAAW,qBAAqB;EAAE,cAAcI;EAAO;CAAgB,CAAC;MAG1E,KAAK,IAAMC,KAAQD,GAEjB,AADYJ,EAAS,gBAAgB,CAAC,CAAC,MAAM,MAAOM,EAAG,QAAQ,MAAMD,CAChE,KAAKL,EAAS,eAAeK,CAAI;AAE1C;AAEA,SAAgBE,EAAiB,GAAwB,GAAkB;CAOzE,AANIC,EAAK,cAAc,UACrBT,EAAmBE,GAAYO,EAAK,iBAAiBA,EAAK,YAAY,GAEvD,GACd,sBAAsB,CAAC,CACvB,MAAM,MAAMN,EAAE,wBAAwB,MAAMM,EAAK,eAChD,KACJP,EAAW,qBAAqB;EAC9B,iBAAiBO,EAAK;EACtB,eAAeA,EAAK;EACpB,iBAAiBA,EAAK;CACxB,CAAC;AACH;AAGA,SAASC,EAAe,GAAuD;CAC7E,IAAIC,EAAK,gBAAgBC,CAAI,KAAKD,EAAK,qBAAqBC,CAAI,GAC9D,OAAOA;CAET,IACED,EAAK,0BAA0BC,CAAI,KACnCD,EAAK,eAAeC,CAAI,KACxBD,EAAK,s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AAC,CAAC,MAAM,MAEhCnB,EAAK,qBAAqBoB,CAAQ,KAClCpB,EAAK,8BAA8BoB,CAAQ,IAEpCA,EAAS,QAAQ,MAAMzB,IAEzB,EACR;AACH;AAEA,SAAgB0B,EACd,GACA,GACS;CACT,OAAOF,EACJ,cAAc,CAAC,CACf,MACE,MACCnB,EAAK,mBAAmBoB,CAAQ,KAChCA,EAAS,cAAc,CAAC,CAAC,QAAQ,MAAME,CAC3C;AACJ;AAaA,SAAgBC,EAAsB,GAAkC;CACtE,IAAMC,IAASrB,EAAG,cAAc;CAChC,IAAIqB,EAAO,WAAW,GAAG,OAAO,EAAE,MAAM,OAAO;CAC/C,IAAIA,EAAO,SAAS,GAAG,OAAO,EAAE,MAAM,cAAc;CAEpD,IAAMC,IAAQD,EAAO;CACrB,IAAIC,EAAM,eAAe,KAAKA,EAAM,gBAAgB,GAClD,OAAO,EAAE,MAAM,cAAc;CAE/B,IAAMC,IAAWD,EAAM,YAAY;CAOnC,OANIzB,EAAK,aAAa0B,CAAQ,IACrB;EAAE,MAAM;EAAc,MAAMA,EAAS,QAAQ;EAAG;CAAM,IAE3D1B,EAAK,uBAAuB0B,CAAQ,IAC/B;EAAE,MAAM;EAAW,SAASA;EAAU;CAAM,IAE9C,EAAE,MAAM,cAAc;AAC/B"}
1
+ {"version":3,"file":"load-function-BFvIVsh7.js","names":["newProject","Project","QuoteKind","ensureNamedImports","existing","sourceFile","d","moduleSpecifier","names","name","ni","ensureImportSpec","spec","unwrapFunction","Node","node","arg","fn","findLoadFunction","declaration","variable","initializer","isFunctionNode","findFinalReturn","statements","body","last","SyntaxKind","r","returnedObject","expression","statement","hasProperty","object","property","hasSpreadOf","expressionText","inspectEventParameter","params","param","nameNode"],"sources":["../../src/runtime/load-function.ts"],"sourcesContent":["import {\n Node,\n Project,\n QuoteKind,\n SyntaxKind,\n type ArrowFunction,\n type Block,\n type FunctionDeclaration,\n type FunctionExpression,\n type ObjectLiteralExpression,\n type ParameterDeclaration,\n type ReturnStatement,\n type SourceFile,\n} from \"ts-morph\";\nimport type { ImportSpec } from \"./ts-morph-helpers\";\n\n/**\n * What the two layout modifiers have in common: finding a SvelteKit `load`,\n * working out how it receives its event, and locating the object it returns.\n */\n\nexport type LoadFunction =\n ArrowFunction | FunctionExpression | FunctionDeclaration;\n\nexport function newProject(): Project {\n return new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n}\n\nexport function ensureNamedImports(\n sourceFile: SourceFile,\n moduleSpecifier: string,\n names: string[],\n) {\n const existing = sourceFile\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === moduleSpecifier);\n if (!existing) {\n sourceFile.addImportDeclaration({ namedImports: names, moduleSpecifier });\n return;\n }\n for (const name of names) {\n const has = existing.getNamedImports().some((ni) => ni.getName() === name);\n if (!has) existing.addNamedImport(name);\n }\n}\n\nexport function ensureImportSpec(sourceFile: SourceFile, spec: ImportSpec) {\n if (spec.namedImports?.length) {\n ensureNamedImports(sourceFile, spec.moduleSpecifier, spec.namedImports);\n }\n const existing = sourceFile\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === spec.moduleSpecifier);\n if (existing) return;\n sourceFile.addImportDeclaration({\n moduleSpecifier: spec.moduleSpecifier,\n defaultImport: spec.defaultImport,\n namespaceImport: spec.namespaceImport,\n });\n}\n\n/** Peel wrappers (`loadFlash(fn)`, `(fn)`, `fn satisfies X`) down to the function. */\nfunction unwrapFunction(node: Node): ArrowFunction | FunctionExpression | null {\n if (Node.isArrowFunction(node) || Node.isFunctionExpression(node)) {\n return node;\n }\n if (\n Node.isParenthesizedExpression(node) ||\n Node.isAsExpression(node) ||\n Node.isSatisfiesExpression(node)\n ) {\n return unwrapFunction(node.getExpression());\n }\n if (Node.isCallExpression(node)) {\n for (const arg of node.getArguments()) {\n const fn = unwrapFunction(arg);\n if (fn) return fn;\n }\n }\n return null;\n}\n\n/** The exported `load`, whether declared as a function or wrapped in a const. */\nexport function findLoadFunction(sourceFile: SourceFile): LoadFunction | null {\n const declaration = sourceFile.getFunction(\"load\");\n if (declaration) {\n return declaration.isExported() ? declaration : null;\n }\n\n const variable = sourceFile.getVariableDeclaration(\"load\");\n if (!variable) return null;\n if (!variable.getVariableStatement()?.isExported()) return null;\n\n const initializer = variable.getInitializer();\n return initializer ? unwrapFunction(initializer) : null;\n}\n\nfunction isFunctionNode(node: Node): boolean {\n return (\n Node.isArrowFunction(node) ||\n Node.isFunctionExpression(node) ||\n Node.isFunctionDeclaration(node) ||\n Node.isMethodDeclaration(node)\n );\n}\n\n/**\n * The single, final `return <expression>` of the load body, or null when the\n * body has early returns — those would need any insertion hoisted above them,\n * and guessing where is worse than refusing.\n */\nexport function findFinalReturn(\n fn: LoadFunction,\n body: Block,\n): ReturnStatement | null {\n const statements = body.getStatements();\n const last = statements[statements.length - 1];\n if (!last || !Node.isReturnStatement(last)) return null;\n\n const returns = body\n .getDescendantsOfKind(SyntaxKind.ReturnStatement)\n .filter((r) => r.getFirstAncestor(isFunctionNode) === fn);\n if (returns.length !== 1) return null;\n\n return last;\n}\n\n/** The object literal a return statement yields, unwrapping parentheses. */\nexport function returnedObject(\n statement: ReturnStatement,\n): ObjectLiteralExpression | null {\n let expression = statement.getExpression();\n while (expression && Node.isParenthesizedExpression(expression)) {\n expression = expression.getExpression();\n }\n if (!expression || !Node.isObjectLiteralExpression(expression)) return null;\n return expression;\n}\n\nexport function hasProperty(\n object: ObjectLiteralExpression,\n name: string,\n): boolean {\n return object.getProperties().some((property) => {\n if (\n Node.isPropertyAssignment(property) ||\n Node.isShorthandPropertyAssignment(property)\n ) {\n return property.getName() === name;\n }\n return false;\n });\n}\n\nexport function hasSpreadOf(\n object: ObjectLiteralExpression,\n expressionText: string,\n): boolean {\n return object\n .getProperties()\n .some(\n (property) =>\n Node.isSpreadAssignment(property) &&\n property.getExpression().getText() === expressionText,\n );\n}\n\n/** How a load receives its event: not at all, by name, or destructured. */\nexport type EventParameter =\n | { kind: \"none\" }\n | { kind: \"identifier\"; name: string; param: ParameterDeclaration }\n | {\n kind: \"binding\";\n pattern: import(\"ts-morph\").ObjectBindingPattern;\n param: ParameterDeclaration;\n }\n | { kind: \"unsupported\" };\n\nexport function inspectEventParameter(fn: LoadFunction): EventParameter {\n const params = fn.getParameters();\n if (params.length === 0) return { kind: \"none\" };\n if (params.length > 1) return { kind: \"unsupported\" };\n\n const param = params[0];\n if (param.getInitializer() || param.isRestParameter()) {\n return { kind: \"unsupported\" };\n }\n const nameNode = param.getNameNode();\n if (Node.isIdentifier(nameNode)) {\n return { kind: \"identifier\", name: nameNode.getText(), param };\n }\n if (Node.isObjectBindingPattern(nameNode)) {\n return { kind: \"binding\", pattern: nameNode, param };\n }\n return { kind: \"unsupported\" };\n}\n"],"mappings":";;AAwBA,SAAgBA,IAAsB;CACpC,OAAO,IAAIC,EAAQ;EACjB,iBAAiB,EAAE,SAAS,GAAK;EACjC,sBAAsB,EAAE,WAAWC,EAAU,OAAO;CACtD,CAAC;AACH;AAEA,SAAgBC,EACd,GACA,GACA,GACA;CACA,IAAMC,IAAWC,EACd,sBAAsB,CAAC,CACvB,MAAM,MAAMC,EAAE,wBAAwB,MAAMC,CAAe;CAC9D,IAAI,CAACH,GACH,EAAW,qBAAqB;EAAE,cAAcI;EAAO;CAAgB,CAAC;MAG1E,KAAK,IAAMC,KAAQD,GAEjB,AADYJ,EAAS,gBAAgB,CAAC,CAAC,MAAM,MAAOM,EAAG,QAAQ,MAAMD,CAChE,KAAKL,EAAS,eAAeK,CAAI;AAE1C;AAEA,SAAgBE,EAAiB,GAAwB,GAAkB;CAOzE,AANIC,EAAK,cAAc,UACrBT,EAAmBE,GAAYO,EAAK,iBAAiBA,EAAK,YAAY,GAEvDP,EACd,sBAAsB,CAAC,CACvB,MAAM,MAAMC,EAAE,wBAAwB,MAAMM,EAAK,eAChD,KACJP,EAAW,qBAAqB;EAC9B,iBAAiBO,EAAK;EACtB,eAAeA,EAAK;EACpB,iBAAiBA,EAAK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ACzC,OAAOD,KAAchB,EAAK,0BAA0BgB,CAAU,IAC5D,IAAaA,EAAW,cAAc;CAGxC,OADI,CAACA,KAAc,CAAChB,EAAK,0BAA0BgB,CAAU,IAAU,OAChEA;AACT;AAEA,SAAgBE,EACd,GACA,GACS;CACT,OAAOC,EAAO,cAAc,CAAC,CAAC,MAAM,MAEhCnB,EAAK,qBAAqBoB,CAAQ,KAClCpB,EAAK,8BAA8BoB,CAAQ,IAEpCA,EAAS,QAAQ,MAAMzB,IAEzB,EACR;AACH;AAEA,SAAgB0B,EACd,GACA,GACS;CACT,OAAOF,EACJ,cAAc,CAAC,CACf,MACE,MACCnB,EAAK,mBAAmBoB,CAAQ,KAChCA,EAAS,cAAc,CAAC,CAAC,QAAQ,MAAME,CAC3C;AACJ;AAaA,SAAgBC,EAAsB,GAAkC;CACtE,IAAMC,IAASrB,EAAG,cAAc;CAChC,IAAIqB,EAAO,WAAW,GAAG,OAAO,EAAE,MAAM,OAAO;CAC/C,IAAIA,EAAO,SAAS,GAAG,OAAO,EAAE,MAAM,cAAc;CAEpD,IAAMC,IAAQD,EAAO;CACrB,IAAIC,EAAM,eAAe,KAAKA,EAAM,gBAAgB,GAClD,OAAO,EAAE,MAAM,cAAc;CAE/B,IAAMC,IAAWD,EAAM,YAAY;CAOnC,OANIzB,EAAK,aAAa0B,CAAQ,IACrB;EAAE,MAAM;EAAc,MAAMA,EAAS,QAAQ;EAAG;CAAM,IAE3D1B,EAAK,uBAAuB0B,CAAQ,IAC/B;EAAE,MAAM;EAAW,SAASA;EAAU;CAAM,IAE9C,EAAE,MAAM,cAAc;AAC/B"}
@@ -1,9 +1,8 @@
1
- //#region src/core/logger.ts
1
+ // src/core/logger.ts
2
2
  var e = { info: () => {} };
3
3
  function t(t) {
4
4
  return t.logger ?? e;
5
5
  }
6
- //#endregion
7
6
  export { t as n, e as t };
8
7
 
9
- //# sourceMappingURL=logger-CQONztPm.js.map
8
+ //# sourceMappingURL=logger-t1HxmpG2.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"logger-CQONztPm.js","names":["NOOP_LOGGER","getLogger","options"],"sources":["../../src/core/logger.ts"],"sourcesContent":["export interface Logger {\n info: (message: string) => void;\n}\n\nexport const NOOP_LOGGER: Logger = {\n info: () => {},\n};\n\nexport function getLogger(options: { logger?: Logger }): Logger {\n return options.logger ?? NOOP_LOGGER;\n}\n"],"mappings":";AAIA,IAAaA,IAAsB,EACjC,YAAY,CAAC,EACf;AAEA,SAAgBC,EAAU,GAAsC;CAC9D,OAAOC,EAAQ,UAAUF;AAC3B"}
1
+ {"version":3,"file":"logger-t1HxmpG2.js","names":["NOOP_LOGGER","getLogger","options"],"sources":["../../src/core/logger.ts"],"sourcesContent":["export interface Logger {\n info: (message: string) => void;\n}\n\nexport const NOOP_LOGGER: Logger = {\n info: () => {},\n};\n\nexport function getLogger(options: { logger?: Logger }): Logger {\n return options.logger ?? NOOP_LOGGER;\n}\n"],"mappings":";AAIA,IAAaA,IAAsB,EACjC,YAAY,CAAC,EACf;AAEA,SAAgBC,EAAU,GAAsC;CAC9D,OAAOC,EAAQ,UAAUF;AAC3B"}
@@ -1,15 +1,13 @@
1
- import { n as e } from "./rolldown-runtime-5HNE8Q1r.js";
2
- import { a as t } from "./util-BLYliuUK.js";
3
- import { n } from "./shared-DIDAkVts.js";
4
- import { _ as r, s as i } from "./ts-morph-helpers-CHI9wAil.js";
1
+ import { n as e } from "./rolldown-runtime-CwxnZyOB.js";
2
+ import { a as t } from "./util-ILWdjRAd.js";
3
+ import { n } from "./shared-DE-J_b1j.js";
4
+ import { _ as r, s as i } from "./ts-morph-helpers-B4KZXP44.js";
5
5
  import a from "node:fs";
6
6
  import o from "node:path";
7
- //#region src/runtime/modify-file.ts
7
+ // src/runtime/modify-file.ts
8
8
  var s = /* @__PURE__ */ e({
9
- envRevertOutcomeToFile: () => u,
10
9
  keepMissing: () => d,
11
- modifyOutcomeToFile: () => c,
12
- revertOutcomeToFile: () => l
10
+ modifyOutcomeToFile: () => c
13
11
  });
14
12
  function c(e, n) {
15
13
  let r = t(e);
@@ -47,7 +45,6 @@ function u(e, t) {
47
45
  function d(e, t) {
48
46
  return e.filter((e) => !a.existsSync(o.join(t, e.path)));
49
47
  }
50
- //#endregion
51
48
  export { l as a, s as i, d as n, c as r, u as t };
52
49
 
53
- //# sourceMappingURL=modify-file-DdXJCMHN.js.map
50
+ //# sourceMappingURL=modify-file-CRZ_gMg0.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"modify-file-DdXJCMHN.js","names":["__exportAll","languageFromPath","withInMemoryScript","isEffectivelyEmpty","fs","path","modify_file_exports","envRevertOutcomeToFile","keepMissing","modifyOutcomeToFile","revertOutcomeToFile","language","filePath","outcome","toDeleteEntry","envPath","creates","root","file"],"sources":["../../src/runtime/modify-file.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, ModifyOutcome } from \"../core/types\";\nimport { languageFromPath } from \"../core/util\";\nimport { toDeleteEntry } from \"../patterns/destroy/shared\";\nimport { isEffectivelyEmpty, withInMemoryScript } from \"./ts-morph-helpers\";\n\nexport function modifyOutcomeToFile(\n filePath: string,\n outcome: ModifyOutcome,\n): File | null {\n const language = languageFromPath(filePath);\n\n if (outcome.status === \"success\") {\n if (!outcome.changed) return null;\n return {\n path: filePath,\n language,\n content: fs.readFileSync(filePath, \"utf8\"),\n status: \"success\",\n };\n }\n\n const content =\n outcome.status === \"failed\" && fs.existsSync(filePath)\n ? fs.readFileSync(filePath, \"utf8\")\n : \"\";\n\n return {\n path: filePath,\n language,\n content,\n status: outcome.status,\n message: outcome.message,\n };\n}\n\n/**\n * `modifyOutcomeToFile` for a revert that may have taken out everything the\n * file held: a script left with no statements, only comments and whitespace,\n * is reported as a delete. For hooks files a pattern created, or that ended\n * up holding nothing but what patterns put there.\n */\nexport function revertOutcomeToFile(\n filePath: string,\n outcome: ModifyOutcome,\n): { modify: File | null; delete: File | null } {\n if (\n outcome.status === \"success\" &&\n outcome.changed &&\n fs.existsSync(filePath) &&\n withInMemoryScript(fs.readFileSync(filePath, \"utf8\"), isEffectivelyEmpty)\n .result\n ) {\n return { modify: null, delete: toDeleteEntry(filePath) };\n }\n return { modify: modifyOutcomeToFile(filePath, outcome), delete: null };\n}\n\n/**\n * `modifyOutcomeToFile` for a `.env` revert: a file the revert left empty is\n * reported as a delete. The enable pattern most likely created it, and an\n * empty `.env` holds nothing worth keeping.\n */\nexport function envRevertOutcomeToFile(\n envPath: string,\n outcome: ModifyOutcome,\n): { modify: File | null; delete: File | null } {\n if (\n outcome.status === \"success\" &&\n outcome.changed &&\n fs.existsSync(envPath) &&\n fs.readFileSync(envPath, \"utf8\").trim() === \"\"\n ) {\n return { modify: null, delete: toDeleteEntry(envPath) };\n }\n return { modify: modifyOutcomeToFile(envPath, outcome), delete: null };\n}\n\n/**\n * Drop any create that already exists on disk.\n *\n * `writeResult` overwrites an existing create whose content differs and\n * reports it as a modify, which would mean a re-run silently resetting a\n * developer's edits, or a create clobbering a file other patterns have\n * already written to. The file is theirs once it exists; a pattern that has\n * something to add to it does so with a modifier.\n */\nexport function keepMissing(creates: File[], root: string): File[] {\n return creates.filter((file) => !fs.existsSync(path.join(root, file.path)));\n}\n"],"mappings":";;;;;;;;;;;;;AAOA,SAAgBS,EACd,GACA,GACa;CACb,IAAME,IAAWV,EAAiBW,CAAQ;CAiB1C,OAfIC,EAAQ,WAAW,YAChBA,EAAQ,UACN;EACL,MAAMD;EACN;EACA,SAASR,EAAG,aAAaQ,GAAU,MAAM;EACzC,QAAQ;CACV,IAN6B,OAcxB;EACL,MAAMA;EACN;EACA,SAPAC,EAAQ,WAAW,YAAYT,EAAG,WAAWQ,CAAQ,IACjDR,EAAG,aAAaQ,GAAU,MAAM,IAChC;EAMJ,QAAQC,EAAQ;EAChB,SAASA,EAAQ;CACnB;AACF;AAQA,SAAgBH,EACd,GACA,GAC8C;CAU9C,OAREG,EAAQ,WAAW,aACnBA,EAAQ,WACRT,EAAG,WAAWQ,CAAQ,KACtBV,EAAmBE,EAAG,aAAaQ,GAAU,MAAM,GAAGT,CAAkB,CAAC,CACtE,SAEI;EAAE,QAAQ;EAAM,QAAQW,EAAcF,CAAQ;CAAE,IAElD;EAAE,QAAQH,EAAoBG,GAAUC,CAAO;EAAG,QAAQ;CAAK;AACxE;AAOA,SAAgBN,EACd,GACA,GAC8C;CAS9C,OAPEM,EAAQ,WAAW,aACnBA,EAAQ,WACRT,EAAG,WAAWW,CAAO,KACrBX,EAAG,aAAaW,GAAS,MAAM,CAAC,CAAC,KAAK,MAAM,KAErC;EAAE,QAAQ;EAAM,QAAQD,EAAcC,CAAO;CAAE,IAEjD;EAAE,QAAQN,EAAoBM,GAASF,CAAO;EAAG,QAAQ;CAAK;AACvE;AAWA,SAAgBL,EAAY,GAAiB,GAAsB;CACjE,OAAOQ,EAAQ,QAAQ,MAAS,CAACZ,EAAG,WAAWC,EAAK,KAAKY,GAAMC,EAAK,IAAI,CAAC,CAAC;AAC5E"}
1
+ {"version":3,"file":"modify-file-CRZ_gMg0.js","names":["__exportAll","languageFromPath","withInMemoryScript","isEffectivelyEmpty","fs","path","modify_file_exports","keepMissing","modifyOutcomeToFile","language","filePath","outcome","revertOutcomeToFile","toDeleteEntry","envRevertOutcomeToFile","envPath","creates","root","file"],"sources":["../../src/runtime/modify-file.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, ModifyOutcome } from \"../core/types\";\nimport { languageFromPath } from \"../core/util\";\nimport { toDeleteEntry } from \"../patterns/destroy/shared\";\nimport { isEffectivelyEmpty, withInMemoryScript } from \"./ts-morph-helpers\";\n\nexport function modifyOutcomeToFile(\n filePath: string,\n outcome: ModifyOutcome,\n): File | null {\n const language = languageFromPath(filePath);\n\n if (outcome.status === \"success\") {\n if (!outcome.changed) return null;\n return {\n path: filePath,\n language,\n content: fs.readFileSync(filePath, \"utf8\"),\n status: \"success\",\n };\n }\n\n const content =\n outcome.status === \"failed\" && fs.existsSync(filePath)\n ? fs.readFileSync(filePath, \"utf8\")\n : \"\";\n\n return {\n path: filePath,\n language,\n content,\n status: outcome.status,\n message: outcome.message,\n };\n}\n\n/**\n * `modifyOutcomeToFile` for a revert that may have taken out everything the\n * file held: a script left with no statements, only comments and whitespace,\n * is reported as a delete. For hooks files a pattern created, or that ended\n * up holding nothing but what patterns put there.\n */\nexport function revertOutcomeToFile(\n filePath: string,\n outcome: ModifyOutcome,\n): { modify: File | null; delete: File | null } {\n if (\n outcome.status === \"success\" &&\n outcome.changed &&\n fs.existsSync(filePath) &&\n withInMemoryScript(fs.readFileSync(filePath, \"utf8\"), isEffectivelyEmpty)\n .result\n ) {\n return { modify: null, delete: toDeleteEntry(filePath) };\n }\n return { modify: modifyOutcomeToFile(filePath, outcome), delete: null };\n}\n\n/**\n * `modifyOutcomeToFile` for a `.env` revert: a file the revert left empty is\n * reported as a delete. The enable pattern most likely created it, and an\n * empty `.env` holds nothing worth keeping.\n */\nexport function envRevertOutcomeToFile(\n envPath: string,\n outcome: ModifyOutcome,\n): { modify: File | null; delete: File | null } {\n if (\n outcome.status === \"success\" &&\n outcome.changed &&\n fs.existsSync(envPath) &&\n fs.readFileSync(envPath, \"utf8\").trim() === \"\"\n ) {\n return { modify: null, delete: toDeleteEntry(envPath) };\n }\n return { modify: modifyOutcomeToFile(envPath, outcome), delete: null };\n}\n\n/**\n * Drop any create that already exists on disk.\n *\n * `writeResult` overwrites an existing create whose content differs and\n * reports it as a modify, which would mean a re-run silently resetting a\n * developer's edits, or a create clobbering a file other patterns have\n * already written to. The file is theirs once it exists; a pattern that has\n * something to add to it does so with a modifier.\n */\nexport function keepMissing(creates: File[], root: string): File[] {\n return creates.filter((file) => !fs.existsSync(path.join(root, file.path)));\n}\n"],"mappings":";;;;;;;;;;;AAOA,SAAgBQ,EACd,GACA,GACa;CACb,IAAMC,IAAWR,EAAiBS,CAAQ;CAiB1C,OAfIC,EAAQ,WAAW,YAChBA,EAAQ,UACN;EACL,MAAMD;EACN;EACA,SAASN,EAAG,aAAaM,GAAU,MAAM;EACzC,QAAQ;CACV,IAN6B,OAcxB;EACL,MAAMA;EACN;EACA,SAPAC,EAAQ,WAAW,YAAYP,EAAG,WAAWM,CAAQ,IACjDN,EAAG,aAAaM,GAAU,MAAM,IAChC;EAMJ,QAAQC,EAAQ;EAChB,SAASA,EAAQ;CACnB;AACF;AAQA,SAAgBC,EACd,GACA,GAC8C;CAU9C,OARED,EAAQ,WAAW,aACnBA,EAAQ,WACRP,EAAG,WAAWM,CAAQ,KACtBR,EAAmBE,EAAG,aAAaM,GAAU,MAAM,GAAGP,CAAkB,CAAC,CACtE,SAEI;EAAE,QAAQ;EAAM,QAAQU,EAAcH,CAAQ;CAAE,IAElD;EAAE,QAAQF,EAAoBE,GAAUC,CAAO;EAAG,QAAQ;CAAK;AACxE;AAOA,SAAgBG,EACd,GACA,GAC8C;CAS9C,OAPEH,EAAQ,WAAW,aACnBA,EAAQ,WACRP,EAAG,WAAWW,CAAO,KACrBX,EAAG,aAAaW,GAAS,MAAM,CAAC,CAAC,KAAK,MAAM,KAErC;EAAE,QAAQ;EAAM,QAAQF,EAAcE,CAAO;CAAE,IAEjD;EAAE,QAAQP,EAAoBO,GAASJ,CAAO;EAAG,QAAQ;CAAK;AACvE;AAWA,SAAgBJ,EAAY,GAAiB,GAAsB;CACjE,OAAOS,EAAQ,QAAQ,MAAS,CAACZ,EAAG,WAAWC,EAAK,KAAKY,GAAMC,EAAK,IAAI,CAAC,CAAC;AAC5E"}
@@ -1,17 +1,9 @@
1
- import { _ as e } from "./ts-morph-helpers-CHI9wAil.js";
2
- import { t } from "./svelte-file-Dv5-bl79.js";
1
+ import { t as e } from "./svelte-file-DfplF3BU.js";
2
+ import { _ as t } from "./ts-morph-helpers-B4KZXP44.js";
3
3
  import n from "node:fs";
4
4
  import { SyntaxKind as r } from "ts-morph";
5
- //#region src/patterns/enable/subscriptions/modifies/modify-nav-user.ts
6
- var i = ["src/lib/components/nav-user.svelte is missing.", "Enable auth and payments first; subscriptions layers a plan label on top of the existing nav-user."].join("\n"), a = [
7
- "Could not find the props and the name lines in nav-user.svelte. Show the plan by hand:",
8
- "",
9
- "let { user, subscription = null }: { ...; subscription?: { id: string; productName: string | null } | null } = $props();",
10
- "const planLabel = $derived(subscription?.productName ?? 'Free');",
11
- "",
12
- "<!-- Under the name, in the trigger and in the dropdown label: -->",
13
- "<span class=\"truncate text-xs text-muted-foreground\">{planLabel}</span>"
14
- ].join("\n"), o = "{ id: string; productName: string | null } | null", s = "const planLabel = $derived(subscription?.productName ?? 'Free');", c = ["<span class=\"truncate text-xs text-muted-foreground\">{planLabel}</span>", "<span class=\"truncate text-xs\">{planLabel}</span>"];
5
+ // src/patterns/enable/subscriptions/modifies/modify-nav-user.ts
6
+ var i = "src/lib/components/nav-user.svelte is missing.\nEnable auth and payments first; subscriptions layers a plan label on top of the existing nav-user.", a = "Could not find the props and the name lines in nav-user.svelte. Show the plan by hand:\n\nlet { user, subscription = null }: { ...; subscription?: { id: string; productName: string | null } | null } = $props();\nconst planLabel = $derived(subscription?.productName ?? 'Free');\n\n<!-- Under the name, in the trigger and in the dropdown label: -->\n<span class=\"truncate text-xs text-muted-foreground\">{planLabel}</span>", o = "{ id: string; productName: string | null } | null", s = "const planLabel = $derived(subscription?.productName ?? 'Free');", c = ["<span class=\"truncate text-xs text-muted-foreground\">{planLabel}</span>", "<span class=\"truncate text-xs\">{planLabel}</span>"];
15
7
  function l(e) {
16
8
  return e.getVariableStatements().find((e) => e.getDeclarations().some((e) => e.getInitializer()?.getText() === "$props()" && e.getNameNode().getKind() === r.ObjectBindingPattern));
17
9
  }
@@ -43,8 +35,8 @@ function f(r) {
43
35
  status: "success",
44
36
  changed: !1
45
37
  };
46
- let s = new t(o), l = !1;
47
- if (s.modifyScript((t) => e(t, (e) => {
38
+ let s = new e(o), l = !1;
39
+ if (s.modifyScript((e) => t(e, (e) => {
48
40
  l = d(e);
49
41
  }).source), !l) return {
50
42
  status: "failed",
@@ -65,7 +57,6 @@ function f(r) {
65
57
  changed: !0
66
58
  };
67
59
  }
68
- //#endregion
69
60
  export { f as n, l as r, u as t };
70
61
 
71
- //# sourceMappingURL=modify-nav-user-CJ1LevSU.js.map
62
+ //# sourceMappingURL=modify-nav-user--7OwY9fI.js.map