@velastack/patterns 0.5.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. package/README.md +11 -0
  2. package/dist/chunks/{_layout-D-FzWqn0.js → _layout-Bsx3eNrC.js} +3 -3
  3. package/dist/chunks/{_layout-D-FzWqn0.js.map → _layout-Bsx3eNrC.js.map} +1 -1
  4. package/dist/chunks/{auth-pages-B52ei-4z.js → auth-pages-jsyDV1GR.js} +7 -10
  5. package/dist/chunks/{auth-pages-B52ei-4z.js.map → auth-pages-jsyDV1GR.js.map} +1 -1
  6. package/dist/chunks/collections-BrEA7a62.js +309 -0
  7. package/dist/chunks/collections-BrEA7a62.js.map +1 -0
  8. package/dist/chunks/{collections-Cpjo2OiQ.js → collections-DrUG8ngq.js} +39 -35
  9. package/dist/chunks/collections-DrUG8ngq.js.map +1 -0
  10. package/dist/chunks/{compose-handle-BDlZ7Pif.js → compose-handle-BBlamPfx.js} +18 -22
  11. package/dist/chunks/{compose-handle-BDlZ7Pif.js.map → compose-handle-BBlamPfx.js.map} +1 -1
  12. package/dist/chunks/{config-target-rHgjaA8u.js → config-target-BgyFkbFL.js} +2 -2
  13. package/dist/chunks/{config-target-rHgjaA8u.js.map → config-target-BgyFkbFL.js.map} +1 -1
  14. package/dist/chunks/{constants-Rq8SCXwH.js → constants-iej3WkEa.js} +3 -3
  15. package/dist/chunks/constants-iej3WkEa.js.map +1 -0
  16. package/dist/chunks/dedent-Gq6Krl4n.js.map +1 -1
  17. package/dist/chunks/{env-BPfk1VAw.js → env-BugddEjd.js} +5 -9
  18. package/dist/chunks/{env-BPfk1VAw.js.map → env-BugddEjd.js.map} +1 -1
  19. package/dist/chunks/{env-vars-Bj41Nccm.js → env-vars-CdarYsrc.js} +6 -11
  20. package/dist/chunks/{env-vars-Bj41Nccm.js.map → env-vars-CdarYsrc.js.map} +1 -1
  21. package/dist/chunks/{generate-dNlBII84.js → generate-27CjLiGW.js} +2 -2
  22. package/dist/chunks/{generate-dNlBII84.js.map → generate-27CjLiGW.js.map} +1 -1
  23. package/dist/chunks/{generate-yi8AP3xH.js → generate-BFcy2wrS.js} +3 -3
  24. package/dist/chunks/{generate-yi8AP3xH.js.map → generate-BFcy2wrS.js.map} +1 -1
  25. package/dist/chunks/generate-BxOzEdc_.js +171 -0
  26. package/dist/chunks/generate-BxOzEdc_.js.map +1 -0
  27. package/dist/chunks/{generate-B6Odfk5f.js → generate-Cqwa8kD9.js} +2 -2
  28. package/dist/chunks/{generate-B6Odfk5f.js.map → generate-Cqwa8kD9.js.map} +1 -1
  29. package/dist/chunks/{generate-DjBMRzsB.js → generate-D3mSFPdT.js} +2 -2
  30. package/dist/chunks/{generate-DjBMRzsB.js.map → generate-D3mSFPdT.js.map} +1 -1
  31. package/dist/chunks/{generate-ZIOVLH6Q.js → generate-DdLwP0E7.js} +51 -47
  32. package/dist/chunks/generate-DdLwP0E7.js.map +1 -0
  33. package/dist/chunks/generate-DyV5R8NP.js.map +1 -1
  34. package/dist/chunks/{generate.runtime-MjWwR2Bd.js → generate.runtime-9KuMcI5r.js} +10 -13
  35. package/dist/chunks/{generate.runtime-MjWwR2Bd.js.map → generate.runtime-9KuMcI5r.js.map} +1 -1
  36. package/dist/chunks/{generate.runtime-BKINIJ2c.js → generate.runtime-B10-KA87.js} +69 -69
  37. package/dist/chunks/{generate.runtime-BKINIJ2c.js.map → generate.runtime-B10-KA87.js.map} +1 -1
  38. package/dist/chunks/{generate.runtime-DaRVyiSg.js → generate.runtime-B8-GLMkk.js} +131 -197
  39. package/dist/chunks/generate.runtime-B8-GLMkk.js.map +1 -0
  40. package/dist/chunks/{generate.runtime-Bdpu4rX0.js → generate.runtime-BGuXHl5o.js} +3 -3
  41. package/dist/chunks/{generate.runtime-Bdpu4rX0.js.map → generate.runtime-BGuXHl5o.js.map} +1 -1
  42. package/dist/chunks/{generate.runtime-DjCzW3zU.js → generate.runtime-BJxM7FNA.js} +7 -7
  43. package/dist/chunks/{generate.runtime-DjCzW3zU.js.map → generate.runtime-BJxM7FNA.js.map} +1 -1
  44. package/dist/chunks/{generate.runtime-BdmoAVJK.js → generate.runtime-BWRtyQeD.js} +5 -5
  45. package/dist/chunks/{generate.runtime-BdmoAVJK.js.map → generate.runtime-BWRtyQeD.js.map} +1 -1
  46. package/dist/chunks/{generate.runtime-CV4soy2n.js → generate.runtime-B_tWu-Bw.js} +47 -47
  47. package/dist/chunks/{generate.runtime-CV4soy2n.js.map → generate.runtime-B_tWu-Bw.js.map} +1 -1
  48. package/dist/chunks/{generate.runtime-NaSIZlP5.js → generate.runtime-BdghkfNp.js} +3 -3
  49. package/dist/chunks/{generate.runtime-NaSIZlP5.js.map → generate.runtime-BdghkfNp.js.map} +1 -1
  50. package/dist/chunks/{generate.runtime-B4QoBn5v.js → generate.runtime-Blb6QPZn.js} +8 -8
  51. package/dist/chunks/{generate.runtime-B4QoBn5v.js.map → generate.runtime-Blb6QPZn.js.map} +1 -1
  52. package/dist/chunks/{generate.runtime-DRRyPa-e.js → generate.runtime-CEexT8cJ.js} +66 -66
  53. package/dist/chunks/{generate.runtime-DRRyPa-e.js.map → generate.runtime-CEexT8cJ.js.map} +1 -1
  54. package/dist/chunks/{generate.runtime-BKTkVCEm.js → generate.runtime-CIZO2XO9.js} +4 -4
  55. package/dist/chunks/{generate.runtime-BKTkVCEm.js.map → generate.runtime-CIZO2XO9.js.map} +1 -1
  56. package/dist/chunks/{generate.runtime-DmsOEsJV.js → generate.runtime-CK0MTeqc.js} +4 -4
  57. package/dist/chunks/{generate.runtime-DmsOEsJV.js.map → generate.runtime-CK0MTeqc.js.map} +1 -1
  58. package/dist/chunks/{generate.runtime-BavEh01F.js → generate.runtime-CMO-Skpk.js} +5 -5
  59. package/dist/chunks/{generate.runtime-BavEh01F.js.map → generate.runtime-CMO-Skpk.js.map} +1 -1
  60. package/dist/chunks/{generate.runtime-BXZDKLbA.js → generate.runtime-CVDb-yLt.js} +12 -20
  61. package/dist/chunks/{generate.runtime-BXZDKLbA.js.map → generate.runtime-CVDb-yLt.js.map} +1 -1
  62. package/dist/chunks/generate.runtime-C_5Ghjri.js +17 -0
  63. package/dist/chunks/generate.runtime-C_5Ghjri.js.map +1 -0
  64. package/dist/chunks/{generate.runtime-CWgZhxQt.js → generate.runtime-CbOMXQSo.js} +3 -3
  65. package/dist/chunks/{generate.runtime-CWgZhxQt.js.map → generate.runtime-CbOMXQSo.js.map} +1 -1
  66. package/dist/chunks/{generate.runtime-DBBtYTAa.js → generate.runtime-CbT-EbQT.js} +5 -5
  67. package/dist/chunks/{generate.runtime-DBBtYTAa.js.map → generate.runtime-CbT-EbQT.js.map} +1 -1
  68. package/dist/chunks/{generate.runtime-CSUnP0l-.js → generate.runtime-Cxr15Y5H.js} +27 -27
  69. package/dist/chunks/{generate.runtime-CSUnP0l-.js.map → generate.runtime-Cxr15Y5H.js.map} +1 -1
  70. package/dist/chunks/{generate.runtime-pMpn0Pbf.js → generate.runtime-CyTxBcX3.js} +10 -10
  71. package/dist/chunks/{generate.runtime-pMpn0Pbf.js.map → generate.runtime-CyTxBcX3.js.map} +1 -1
  72. package/dist/chunks/{generate.runtime-azOvp6tl.js → generate.runtime-D5HxAups.js} +39 -36
  73. package/dist/chunks/generate.runtime-D5HxAups.js.map +1 -0
  74. package/dist/chunks/{generate.runtime-b2RtuPy4.js → generate.runtime-D6vhkGs8.js} +5 -5
  75. package/dist/chunks/{generate.runtime-b2RtuPy4.js.map → generate.runtime-D6vhkGs8.js.map} +1 -1
  76. package/dist/chunks/{generate.runtime-DlbG-8Xm.js → generate.runtime-DIeAeOJg.js} +6 -6
  77. package/dist/chunks/{generate.runtime-DlbG-8Xm.js.map → generate.runtime-DIeAeOJg.js.map} +1 -1
  78. package/dist/chunks/{generate.runtime-QbmCPT42.js → generate.runtime-DMTAocSE.js} +17 -17
  79. package/dist/chunks/{generate.runtime-QbmCPT42.js.map → generate.runtime-DMTAocSE.js.map} +1 -1
  80. package/dist/chunks/{generate.runtime-utFLS6Jz.js → generate.runtime-DlLwmjGF.js} +133 -121
  81. package/dist/chunks/generate.runtime-DlLwmjGF.js.map +1 -0
  82. package/dist/chunks/{generate.runtime-BYfyZHhs.js → generate.runtime-DtCaz98N.js} +6 -6
  83. package/dist/chunks/{generate.runtime-BYfyZHhs.js.map → generate.runtime-DtCaz98N.js.map} +1 -1
  84. package/dist/chunks/{generate.runtime-BcgjZJug.js → generate.runtime-HSZD935T.js} +4 -4
  85. package/dist/chunks/{generate.runtime-BcgjZJug.js.map → generate.runtime-HSZD935T.js.map} +1 -1
  86. package/dist/chunks/{generate.runtime-OEgsdWRP.js → generate.runtime-Nnk5E8Pi.js} +3 -3
  87. package/dist/chunks/{generate.runtime-OEgsdWRP.js.map → generate.runtime-Nnk5E8Pi.js.map} +1 -1
  88. package/dist/chunks/{generate.runtime-D-qtaVdq.js → generate.runtime-NxuWvkKt.js} +13 -13
  89. package/dist/chunks/{generate.runtime-D-qtaVdq.js.map → generate.runtime-NxuWvkKt.js.map} +1 -1
  90. package/dist/chunks/{generate.runtime-CCV4O6_I.js → generate.runtime-dFTOU_KE.js} +71 -71
  91. package/dist/chunks/{generate.runtime-CCV4O6_I.js.map → generate.runtime-dFTOU_KE.js.map} +1 -1
  92. package/dist/chunks/{generate.runtime-C7s1Mx5L.js → generate.runtime-m0m43lkL.js} +7 -7
  93. package/dist/chunks/{generate.runtime-C7s1Mx5L.js.map → generate.runtime-m0m43lkL.js.map} +1 -1
  94. package/dist/chunks/{generate.runtime-BdHv7Jp1.js → generate.runtime-si5Za61F.js} +3 -3
  95. package/dist/chunks/{generate.runtime-BdHv7Jp1.js.map → generate.runtime-si5Za61F.js.map} +1 -1
  96. package/dist/chunks/{generate.runtime-DetYynf4.js → generate.runtime-tGKorg85.js} +10 -14
  97. package/dist/chunks/{generate.runtime-DetYynf4.js.map → generate.runtime-tGKorg85.js.map} +1 -1
  98. package/dist/chunks/{generate.runtime-CcPCAEV0.js → generate.runtime-ww3-1FWf.js} +6 -6
  99. package/dist/chunks/{generate.runtime-CcPCAEV0.js.map → generate.runtime-ww3-1FWf.js.map} +1 -1
  100. package/dist/chunks/{modify-file-Bbhyfiy_.js → modify-file-COBp4eCh.js} +4 -4
  101. package/dist/chunks/{modify-file-Bbhyfiy_.js.map → modify-file-COBp4eCh.js.map} +1 -1
  102. package/dist/chunks/{modify-nav-user-B8h8WTrM.js → modify-nav-user-CJ1LevSU.js} +2 -2
  103. package/dist/chunks/{modify-nav-user-B8h8WTrM.js.map → modify-nav-user-CJ1LevSU.js.map} +1 -1
  104. package/dist/chunks/{modify-svelte-config-remote-DhuRX4FI.js → modify-svelte-config-remote-CEyYydL7.js} +2 -2
  105. package/dist/chunks/{modify-svelte-config-remote-DhuRX4FI.js.map → modify-svelte-config-remote-CEyYydL7.js.map} +1 -1
  106. package/dist/chunks/{modify-user-signup-BbqTiUuA.js → modify-user-signup-DLtopazD.js} +2 -2
  107. package/dist/chunks/{modify-user-signup-BbqTiUuA.js.map → modify-user-signup-DLtopazD.js.map} +1 -1
  108. package/dist/chunks/{package-imports-Bbw3iMPg.js → package-imports-Dx05A-4S.js} +2 -2
  109. package/dist/chunks/{package-imports-Bbw3iMPg.js.map → package-imports-Dx05A-4S.js.map} +1 -1
  110. package/dist/chunks/{pocketbase-CgwbH1gI.js → pocketbase-DL02rq73.js} +5 -13
  111. package/dist/chunks/{pocketbase-CgwbH1gI.js.map → pocketbase-DL02rq73.js.map} +1 -1
  112. package/dist/chunks/{providers-DwbwccSW.js → providers-CAehyySB.js} +2 -2
  113. package/dist/chunks/{providers-DwbwccSW.js.map → providers-CAehyySB.js.map} +1 -1
  114. package/dist/chunks/{rolldown-runtime-DArdT4gl.js → rolldown-runtime-5HNE8Q1r.js} +1 -1
  115. package/dist/chunks/{shared-D5GOS97l.js → shared-C_Fr8wph.js} +2 -2
  116. package/dist/chunks/{shared-D5GOS97l.js.map → shared-C_Fr8wph.js.map} +1 -1
  117. package/dist/chunks/site-BoujshKo.js +108 -0
  118. package/dist/chunks/site-BoujshKo.js.map +1 -0
  119. package/dist/chunks/{table-core-DhDqT03G.js → table-core-BPv_RYgD.js} +3 -3
  120. package/dist/chunks/{table-core-DhDqT03G.js.map → table-core-BPv_RYgD.js.map} +1 -1
  121. package/dist/chunks/{taggedTemplateLiteral-CswN2AAa.js → taggedTemplateLiteral-KSUnuvOk.js} +1 -1
  122. package/dist/chunks/{test-setup-DZoyF8Ak.js → test-setup-pYUIfWb2.js} +5 -5
  123. package/dist/chunks/{test-setup-DZoyF8Ak.js.map → test-setup-pYUIfWb2.js.map} +1 -1
  124. package/dist/chunks/{ts-morph-helpers-Bepc-Es2.js → ts-morph-helpers-CHI9wAil.js} +7 -11
  125. package/dist/chunks/{ts-morph-helpers-Bepc-Es2.js.map → ts-morph-helpers-CHI9wAil.js.map} +1 -1
  126. package/dist/chunks/{ui-BuocThuh.js → ui-B2yn8c_-.js} +3 -3
  127. package/dist/chunks/{ui-BuocThuh.js.map → ui-B2yn8c_-.js.map} +1 -1
  128. package/dist/chunks/{unmodify-load-Bl5vXQiL.js → unmodify-load-Buak-r1f.js} +2 -2
  129. package/dist/chunks/{unmodify-load-Bl5vXQiL.js.map → unmodify-load-Buak-r1f.js.map} +1 -1
  130. package/dist/chunks/{whatsapp-CguKGTtw.js → whatsapp-5qJ_xCV1.js} +2 -2
  131. package/dist/chunks/{whatsapp-CguKGTtw.js.map → whatsapp-5qJ_xCV1.js.map} +1 -1
  132. package/dist/chunks/{write-result-Cq-9A7Zy.js → write-result-Bn4bnrBI.js} +20 -50
  133. package/dist/chunks/write-result-Bn4bnrBI.js.map +1 -0
  134. package/dist/chunks/wuchale-config-c3Q4JVSF.js +50 -0
  135. package/dist/chunks/wuchale-config-c3Q4JVSF.js.map +1 -0
  136. package/dist/index.d.ts +162 -1
  137. package/dist/index.js +2193 -2330
  138. package/dist/index.js.map +1 -1
  139. package/package.json +2 -2
  140. package/dist/chunks/collections-Cpjo2OiQ.js.map +0 -1
  141. package/dist/chunks/constants-Rq8SCXwH.js.map +0 -1
  142. package/dist/chunks/generate-BClgUH4J.js +0 -137
  143. package/dist/chunks/generate-BClgUH4J.js.map +0 -1
  144. package/dist/chunks/generate-ZIOVLH6Q.js.map +0 -1
  145. package/dist/chunks/generate.runtime-DaRVyiSg.js.map +0 -1
  146. package/dist/chunks/generate.runtime-azOvp6tl.js.map +0 -1
  147. package/dist/chunks/generate.runtime-utFLS6Jz.js.map +0 -1
  148. package/dist/chunks/shopify-page-D-VFwGxI.js +0 -11
  149. package/dist/chunks/shopify-page-D-VFwGxI.js.map +0 -1
  150. package/dist/chunks/site-lj0CDdQ1.js +0 -55
  151. package/dist/chunks/site-lj0CDdQ1.js.map +0 -1
  152. package/dist/chunks/write-result-Cq-9A7Zy.js.map +0 -1
@@ -1,7 +1,7 @@
1
1
  import { n as e } from "./logger-CQONztPm.js";
2
- import { t } from "./shared-D5GOS97l.js";
3
- import { f as n, o as r } from "./ts-morph-helpers-Bepc-Es2.js";
4
- import { r as i } from "./modify-file-Bbhyfiy_.js";
2
+ import { t } from "./shared-C_Fr8wph.js";
3
+ import { f as n, o as r } from "./ts-morph-helpers-CHI9wAil.js";
4
+ import { r as i } from "./modify-file-COBp4eCh.js";
5
5
  import { t as a } from "./svelte-file-Dv5-bl79.js";
6
6
  import o from "node:fs";
7
7
  import s from "node:path";
@@ -91,4 +91,4 @@ async function f(n) {
91
91
  //#endregion
92
92
  export { f as generate };
93
93
 
94
- //# sourceMappingURL=generate.runtime-BKTkVCEm.js.map
94
+ //# sourceMappingURL=generate.runtime-CIZO2XO9.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate.runtime-BKTkVCEm.js","names":["apiObj","getLogger","removeNavItemFromScript","formatLikeSource","modifyOutcomeToFile","SvelteFile","fs","path","unmodifyHooksServer","hooksServerPath","originalSource","sourceFile","Project","callExpr","SyntaxKind","ce","firstArg","apiProp","apiInit","apiKeysProp","unmodifyNavUser","navUserPath","source","file","wasRemoved","tryRemove","run","result","src","fn","generate","logger","options","modifies","pushResult","planDropsForCollections"],"sources":["../../src/patterns/disable/api-keys/modifies/hooks.server.ts","../../src/patterns/disable/api-keys/modifies/nav-user.svelte.ts","../../src/patterns/disable/api-keys/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { Project, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { formatLikeSource } from \"../../../../runtime/ts-morph-helpers\";\n\nexport function unmodifyHooksServer(hooksServerPath: string): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n return { status: \"success\", changed: false };\n }\n\n const originalSource = fs.readFileSync(hooksServerPath, \"utf8\");\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n const callExpr = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((ce) => ce.getExpression().getText() === \"handlePocketbase\");\n if (!callExpr) return { status: \"success\", changed: false };\n\n const [firstArg] = callExpr.getArguments();\n if (!firstArg || firstArg.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n return { status: \"success\", changed: false };\n }\n\n const optionsObj = firstArg.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n const apiProp = optionsObj.getProperty(\"api\");\n if (!apiProp || apiProp.getKind() !== SyntaxKind.PropertyAssignment) {\n return { status: \"success\", changed: false };\n }\n\n const apiInit = (\n apiProp as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (!apiInit || apiInit.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n return { status: \"success\", changed: false };\n }\n\n const apiObj = apiInit as import(\"ts-morph\").ObjectLiteralExpression;\n const apiKeysProp = apiObj.getProperty(\"apiKeys\");\n if (!apiKeysProp) {\n return { status: \"success\", changed: false };\n }\n\n apiKeysProp.remove();\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport { removeNavItemFromScript } from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyNavUser(navUserPath: string): ModifyOutcome {\n if (!fs.existsSync(navUserPath)) {\n return { status: \"success\", changed: false };\n }\n\n const source = fs.readFileSync(navUserPath, \"utf8\");\n if (!source.includes(\"/api-keys\")) {\n return { status: \"success\", changed: false };\n }\n\n const file = new SvelteFile(source);\n let wasRemoved = false;\n\n const tryRemove = (run: (fn: (s: string) => string) => boolean) => {\n if (wasRemoved) return;\n run((src) => {\n const result = removeNavItemFromScript(\n src,\n \"API Keys\",\n \"@lucide/svelte/icons/key-round\",\n );\n if (result.wasRemoved) wasRemoved = true;\n return result.source;\n });\n };\n\n tryRemove((fn) => file.modifyModuleScript(fn));\n if (!wasRemoved) tryRemove((fn) => file.modifyScript(fn));\n\n if (!wasRemoved) {\n return { status: \"success\", changed: false };\n }\n\n fs.writeFileSync(navUserPath, file.toString(), \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { unmodifyHooksServer } from \"./modifies/hooks.server\";\nimport { unmodifyNavUser } from \"./modifies/nav-user.svelte\";\nimport { planDropsForCollections } from \"../../destroy/shared\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Reverting hooks.server.ts\");\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n pushResult(\n modifyOutcomeToFile(hooksServerPath, unmodifyHooksServer(hooksServerPath)),\n );\n\n logger.info(\"Reverting nav-user.svelte\");\n const navUserPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"nav-user.svelte\",\n );\n pushResult(modifyOutcomeToFile(navUserPath, unmodifyNavUser(navUserPath)));\n\n const collectionDrops = await planDropsForCollections([\"api_keys\"], options);\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops,\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;AAKA,SAAgBQ,EAAoB,GAAwC;CAC1E,IAAI,CAACF,EAAG,WAAWG,CAAe,GAChC,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAMC,IAAiBJ,EAAG,aAAaG,GAAiB,MAAM,GAExDE,IAAa,IADCC,EACD,CAAA,CAAQ,oBAAoBH,CAAe,GAExDI,IAAWF,EACd,qBAAqBG,EAAW,cAAc,CAAC,CAC/C,MAAM,MAAOC,EAAG,cAAc,CAAC,CAAC,QAAQ,MAAM,kBAAkB;CACnE,IAAI,CAACF,GAAU,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAE1D,IAAM,CAACG,KAAYH,EAAS,aAAa;CACzC,IAAI,CAACG,KAAYA,EAAS,QAAQ,MAAMF,EAAW,yBACjD,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAI7C,IAAMG,IADaD,EAAS,cAAcF,EAAW,uBACrC,CAAA,CAAW,YAAY,KAAK;CAC5C,IAAI,CAACG,KAAWA,EAAQ,QAAQ,MAAMH,EAAW,oBAC/C,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAMI,IACJD,EACA,eAAe;CACjB,IAAI,CAACC,KAAWA,EAAQ,QAAQ,MAAMJ,EAAW,yBAC/C,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAI7C,IAAMK,IAAcnB,EAAO,YAAY,SAAS;CAUhD,OATKmB,KAILA,EAAY,OAAO,GAEnBhB,EAAiBQ,CAAU,GAC3BA,EAAW,SAAS,GAEb;EACL,QAAQ;EACR,SAASA,EAAW,YAAY,MAAMD;CACxC,KAXS;EAAE,QAAQ;EAAW,SAAS;CAAM;AAY/C;;;AC/CA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,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAA,MAV4Bc,EAAwB,CAAC,UAAU,GAAGH,CAAO;CAW3E;AACF"}
1
+ {"version":3,"file":"generate.runtime-CIZO2XO9.js","names":["apiObj","getLogger","removeNavItemFromScript","formatLikeSource","modifyOutcomeToFile","SvelteFile","fs","path","unmodifyHooksServer","hooksServerPath","originalSource","sourceFile","Project","callExpr","SyntaxKind","ce","firstArg","apiProp","apiInit","apiKeysProp","unmodifyNavUser","navUserPath","source","file","wasRemoved","tryRemove","run","result","src","fn","generate","logger","options","modifies","pushResult","planDropsForCollections"],"sources":["../../src/patterns/disable/api-keys/modifies/hooks.server.ts","../../src/patterns/disable/api-keys/modifies/nav-user.svelte.ts","../../src/patterns/disable/api-keys/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { Project, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { formatLikeSource } from \"../../../../runtime/ts-morph-helpers\";\n\nexport function unmodifyHooksServer(hooksServerPath: string): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n return { status: \"success\", changed: false };\n }\n\n const originalSource = fs.readFileSync(hooksServerPath, \"utf8\");\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n const callExpr = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((ce) => ce.getExpression().getText() === \"handlePocketbase\");\n if (!callExpr) return { status: \"success\", changed: false };\n\n const [firstArg] = callExpr.getArguments();\n if (!firstArg || firstArg.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n return { status: \"success\", changed: false };\n }\n\n const optionsObj = firstArg.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n const apiProp = optionsObj.getProperty(\"api\");\n if (!apiProp || apiProp.getKind() !== SyntaxKind.PropertyAssignment) {\n return { status: \"success\", changed: false };\n }\n\n const apiInit = (\n apiProp as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (!apiInit || apiInit.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n return { status: \"success\", changed: false };\n }\n\n const apiObj = apiInit as import(\"ts-morph\").ObjectLiteralExpression;\n const apiKeysProp = apiObj.getProperty(\"apiKeys\");\n if (!apiKeysProp) {\n return { status: \"success\", changed: false };\n }\n\n apiKeysProp.remove();\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport { removeNavItemFromScript } from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyNavUser(navUserPath: string): ModifyOutcome {\n if (!fs.existsSync(navUserPath)) {\n return { status: \"success\", changed: false };\n }\n\n const source = fs.readFileSync(navUserPath, \"utf8\");\n if (!source.includes(\"/api-keys\")) {\n return { status: \"success\", changed: false };\n }\n\n const file = new SvelteFile(source);\n let wasRemoved = false;\n\n const tryRemove = (run: (fn: (s: string) => string) => boolean) => {\n if (wasRemoved) return;\n run((src) => {\n const result = removeNavItemFromScript(\n src,\n \"API Keys\",\n \"@lucide/svelte/icons/key-round\",\n );\n if (result.wasRemoved) wasRemoved = true;\n return result.source;\n });\n };\n\n tryRemove((fn) => file.modifyModuleScript(fn));\n if (!wasRemoved) tryRemove((fn) => file.modifyScript(fn));\n\n if (!wasRemoved) {\n return { status: \"success\", changed: false };\n }\n\n fs.writeFileSync(navUserPath, file.toString(), \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { unmodifyHooksServer } from \"./modifies/hooks.server\";\nimport { unmodifyNavUser } from \"./modifies/nav-user.svelte\";\nimport { planDropsForCollections } from \"../../destroy/shared\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Reverting hooks.server.ts\");\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n pushResult(\n modifyOutcomeToFile(hooksServerPath, unmodifyHooksServer(hooksServerPath)),\n );\n\n logger.info(\"Reverting nav-user.svelte\");\n const navUserPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"nav-user.svelte\",\n );\n pushResult(modifyOutcomeToFile(navUserPath, unmodifyNavUser(navUserPath)));\n\n const collectionDrops = await planDropsForCollections([\"api_keys\"], options);\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops,\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;AAKA,SAAgBQ,EAAoB,GAAwC;CAC1E,IAAI,CAACF,EAAG,WAAWG,CAAe,GAChC,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAMC,IAAiBJ,EAAG,aAAaG,GAAiB,MAAM,GAExDE,IAAa,IADCC,EACD,CAAA,CAAQ,oBAAoBH,CAAe,GAExDI,IAAWF,EACd,qBAAqBG,EAAW,cAAc,CAAC,CAC/C,MAAM,MAAOC,EAAG,cAAc,CAAC,CAAC,QAAQ,MAAM,kBAAkB;CACnE,IAAI,CAACF,GAAU,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAE1D,IAAM,CAACG,KAAYH,EAAS,aAAa;CACzC,IAAI,CAACG,KAAYA,EAAS,QAAQ,MAAMF,EAAW,yBACjD,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAI7C,IAAMG,IADaD,EAAS,cAAcF,EAAW,uBACrC,CAAA,CAAW,YAAY,KAAK;CAC5C,IAAI,CAACG,KAAWA,EAAQ,QAAQ,MAAMH,EAAW,oBAC/C,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CA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ACvC,IAAMd,IAAkBF,EAAK,KAAKyB,EAAQ,MAAM,OAAO,iBAAiB;CAKxE,AAJAE,EACE9B,EAAoBK,GAAiBD,EAAoBC,CAAe,CAAC,CAC3E,GAEAsB,EAAO,KAAK,2BAA2B;CACvC,IAAMV,IAAcd,EAAK,KACvByB,EAAQ,MACR,OACA,OACA,cACA,iBACF;CAKA,OAJAE,EAAW9B,EAAoBiB,GAAaD,EAAgBC,CAAW,CAAC,CAAC,GAIlE;EACL,SAAS,CAAC;EACV;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAA,MAV4Bc,EAAwB,CAAC,UAAU,GAAGH,CAAO;CAW3E;AACF"}
@@ -1,8 +1,8 @@
1
1
  import { r as e } from "./lib-specifier-Cngo1zF_.js";
2
2
  import { n as t } from "./logger-CQONztPm.js";
3
- import { t as n } from "./shared-D5GOS97l.js";
4
- import { _ as r, g as i, n as a, o, p as s, u as c } from "./ts-morph-helpers-Bepc-Es2.js";
5
- import { r as l } from "./modify-file-Bbhyfiy_.js";
3
+ import { t as n } from "./shared-C_Fr8wph.js";
4
+ import { _ as r, g as i, n as a, o, p as s, u as c } from "./ts-morph-helpers-CHI9wAil.js";
5
+ import { r as l } from "./modify-file-COBp4eCh.js";
6
6
  import { t as u } from "./svelte-file-Dv5-bl79.js";
7
7
  import d from "node:fs";
8
8
  import f from "node:path";
@@ -109,4 +109,4 @@ async function v(e) {
109
109
  //#endregion
110
110
  export { v as generate };
111
111
 
112
- //# sourceMappingURL=generate.runtime-DmsOEsJV.js.map
112
+ //# sourceMappingURL=generate.runtime-CK0MTeqc.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate.runtime-DmsOEsJV.js","names":["libModule","getLogger","planDropsForCollections","withInMemoryScript","removeUnusedBindingElement","ensureBlankLineAfterImports","removePropsBindingIfUnused","removeImportByModuleSpecifier","modifyOutcomeToFile","SvelteFile","fs","path","unmodifyLayoutServer","layoutPath","originalSource","sourceFile","Project","literals","SyntaxKind","obj","userProp","formatLikeSource","unmodifyRootLayoutSvelte","source","file","markup","out","content","sf","unmodifyHooksServer","hooksServerPath","callExpr","ce","firstArg","optionsObj","authProp","generate","logger","options","modifies","pushResult","layoutServerFile","layoutCandidates","layoutFile","p","hooksServerFile"],"sources":["../../src/patterns/disable/auth/modifies/+layout.server.ts","../../src/patterns/disable/auth/modifies/root-layout.svelte.ts","../../src/patterns/disable/auth/modifies/hooks.server.ts","../../src/patterns/disable/auth/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { Project, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport {\n removeUnusedBindingElement,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nexport function unmodifyLayoutServer(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"success\", changed: false };\n }\n\n const originalSource = fs.readFileSync(layoutPath, \"utf8\");\n if (!originalSource.includes(\"locals.pb.authStore.record\")) {\n return { status: \"success\", changed: false };\n }\n\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(layoutPath);\n\n const literals = sourceFile.getDescendantsOfKind(\n SyntaxKind.ObjectLiteralExpression,\n );\n for (const obj of literals) {\n const userProp = obj.getProperty(\"user\");\n if (!userProp || userProp.getKind() !== SyntaxKind.PropertyAssignment) {\n continue;\n }\n const value = (userProp as import(\"ts-morph\").PropertyAssignment)\n .getInitializer()\n ?.getText();\n if (value === \"locals.pb.authStore.record\") {\n userProp.remove();\n }\n }\n // `user` was often the layout's only use of `locals`, which enable-auth\n // destructured for it.\n removeUnusedBindingElement(sourceFile, \"locals\");\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n ensureBlankLineAfterImports,\n removeImportByModuleSpecifier,\n removePropsBindingIfUnused,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { libModule } from \"../../../../runtime/lib-specifier\";\n\nexport function unmodifyRootLayoutSvelte(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"success\", changed: false };\n }\n\n const source = fs.readFileSync(layoutPath, \"utf8\");\n const file = new SvelteFile(source);\n if (!file.hasElement(\"AuthMenu.Root\")) {\n return { status: \"success\", changed: false };\n }\n\n // The whole navbar item enable-auth added goes, not just the menu inside\n // it; a layout that placed the menu without one loses only the menu.\n if (!file.removeElementContaining(\"Navbar.Item\", \"AuthMenu.Root\")) {\n file.removeElement(\"AuthMenu.Root\");\n }\n const markup = file.toString().replace(/<script[\\s\\S]*?<\\/script>/g, \"\");\n\n file.modifyScript((content) => {\n const { source: out } = withInMemoryScript(content, (sf) => {\n removeImportByModuleSpecifier(sf, libModule(\"components/ui/auth-menu\"));\n removeImportByModuleSpecifier(\n sf,\n libModule(\"components/user-avatar.svelte\"),\n );\n // Layouts from before UserAvatar import the avatar parts directly.\n removeImportByModuleSpecifier(sf, libModule(\"components/ui/avatar\"));\n // enable-auth added `data` for the menu's `data.user`.\n removePropsBindingIfUnused(sf, \"data\", markup);\n ensureBlankLineAfterImports(sf);\n });\n return out;\n });\n\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport { Project, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { formatLikeSource } from \"../../../../runtime/ts-morph-helpers\";\n\nexport function unmodifyHooksServer(hooksServerPath: string): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n return { status: \"success\", changed: false };\n }\n\n const originalSource = fs.readFileSync(hooksServerPath, \"utf8\");\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n const callExpr = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((ce) => ce.getExpression().getText() === \"handlePocketbase\");\n if (!callExpr) return { status: \"success\", changed: false };\n\n const [firstArg] = callExpr.getArguments();\n if (!firstArg || firstArg.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n return { status: \"success\", changed: false };\n }\n\n const optionsObj = firstArg.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n const authProp = optionsObj.getProperty(\"auth\");\n if (!authProp) {\n return { status: \"success\", changed: false };\n }\n\n authProp.remove();\n\n if (optionsObj.getProperties().length === 0) {\n callExpr.removeArgument(0);\n }\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import path from \"node:path\";\nimport fs from \"node:fs\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { unmodifyLayoutServer } from \"./modifies/+layout.server\";\nimport { unmodifyRootLayoutSvelte } from \"./modifies/root-layout.svelte\";\nimport { unmodifyHooksServer } from \"./modifies/hooks.server\";\nimport { planDropsForCollections } from \"../../destroy/shared\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Reverting +layout.server.ts\");\n const layoutServerFile = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n layoutServerFile,\n unmodifyLayoutServer(layoutServerFile),\n ),\n );\n\n logger.info(\"Reverting root layout\");\n const layoutCandidates = [\n path.join(options.root, \"src\", \"routes\", \"(public)\", \"root-layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"root-layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"(public)\", \"+layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"+layout.svelte\"),\n ];\n const layoutFile =\n layoutCandidates.find((p) => fs.existsSync(p)) ?? layoutCandidates[0];\n pushResult(\n modifyOutcomeToFile(layoutFile, unmodifyRootLayoutSvelte(layoutFile)),\n );\n\n logger.info(\"Reverting hooks.server.ts\");\n const hooksServerFile = path.join(options.root, \"src\", \"hooks.server.ts\");\n pushResult(\n modifyOutcomeToFile(hooksServerFile, unmodifyHooksServer(hooksServerFile)),\n );\n\n const collectionDrops = await planDropsForCollections(\n [\"oauth_accounts\"],\n options,\n );\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops,\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;;AAQA,SAAgBY,EAAqB,GAAmC;CACtE,IAAI,CAACF,EAAG,WAAWG,CAAU,GAC3B,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAMC,IAAiBJ,EAAG,aAAaG,GAAY,MAAM;CACzD,IAAI,CAACC,EAAe,SAAS,4BAA4B,GACvD,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAI7C,IAAMC,IAAa,IADCC,EACD,CAAA,CAAQ,oBAAoBH,CAAU,GAEnDI,IAAWF,EAAW,qBAC1BG,EAAW,uBACb;CACA,KAAK,IAAMC,KAAOF,GAAU;EAC1B,IAAMG,IAAWD,EAAI,YAAY,MAAM;EACvC,AAAKC,KAAYA,EAAS,QAAQ,MAAMF,EAAW,sBAGpCE,EACZ,eAAe,CAAC,EACf,QAAQ,MACE,gCACZA,EAAS,OAAO;CAEpB;CAQA,OALAhB,EAA2BW,GAAY,QAAQ,GAE/CM,EAAiBN,CAAU,GAC3BA,EAAW,SAAS,GAEb;EACL,QAAQ;EACR,SAASA,EAAW,YAAY,MAAMD;CACxC;AACF;;;ACpCA,SAAgBQ,EAAyB,GAAmC;CAC1E,IAAI,CAACZ,EAAG,WAAWG,CAAU,GAC3B,OAAO;EAAE,QAAQ;EAAW,SAAS;CA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e,CAAC,CAC3E,GAOO;EACL,SAAS,CAAC;EACV;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAA,MAb4B3C,EAC5B,CAAC,gBAAgB,GACjBoC,CACF;CAWA;AACF"}
1
+ {"version":3,"file":"generate.runtime-CK0MTeqc.js","names":["libModule","getLogger","planDropsForCollections","withInMemoryScript","removeUnusedBindingElement","ensureBlankLineAfterImports","removePropsBindingIfUnused","removeImportByModuleSpecifier","modifyOutcomeToFile","SvelteFile","fs","path","unmodifyLayoutServer","layoutPath","originalSource","sourceFile","Project","literals","SyntaxKind","obj","userProp","formatLikeSource","unmodifyRootLayoutSvelte","source","file","markup","out","content","sf","unmodifyHooksServer","hooksServerPath","callExpr","ce","firstArg","optionsObj","authProp","generate","logger","options","modifies","pushResult","layoutServerFile","layoutCandidates","layoutFile","p","hooksServerFile"],"sources":["../../src/patterns/disable/auth/modifies/+layout.server.ts","../../src/patterns/disable/auth/modifies/root-layout.svelte.ts","../../src/patterns/disable/auth/modifies/hooks.server.ts","../../src/patterns/disable/auth/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { Project, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport {\n removeUnusedBindingElement,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nexport function unmodifyLayoutServer(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"success\", changed: false };\n }\n\n const originalSource = fs.readFileSync(layoutPath, \"utf8\");\n if (!originalSource.includes(\"locals.pb.authStore.record\")) {\n return { status: \"success\", changed: false };\n }\n\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(layoutPath);\n\n const literals = sourceFile.getDescendantsOfKind(\n SyntaxKind.ObjectLiteralExpression,\n );\n for (const obj of literals) {\n const userProp = obj.getProperty(\"user\");\n if (!userProp || userProp.getKind() !== SyntaxKind.PropertyAssignment) {\n continue;\n }\n const value = (userProp as import(\"ts-morph\").PropertyAssignment)\n .getInitializer()\n ?.getText();\n if (value === \"locals.pb.authStore.record\") {\n userProp.remove();\n }\n }\n // `user` was often the layout's only use of `locals`, which enable-auth\n // destructured for it.\n removeUnusedBindingElement(sourceFile, \"locals\");\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n ensureBlankLineAfterImports,\n removeImportByModuleSpecifier,\n removePropsBindingIfUnused,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { libModule } from \"../../../../runtime/lib-specifier\";\n\nexport function unmodifyRootLayoutSvelte(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"success\", changed: false };\n }\n\n const source = fs.readFileSync(layoutPath, \"utf8\");\n const file = new SvelteFile(source);\n if (!file.hasElement(\"AuthMenu.Root\")) {\n return { status: \"success\", changed: false };\n }\n\n // The whole navbar item enable-auth added goes, not just the menu inside\n // it; a layout that placed the menu without one loses only the menu.\n if (!file.removeElementContaining(\"Navbar.Item\", \"AuthMenu.Root\")) {\n file.removeElement(\"AuthMenu.Root\");\n }\n const markup = file.toString().replace(/<script[\\s\\S]*?<\\/script>/g, \"\");\n\n file.modifyScript((content) => {\n const { source: out } = withInMemoryScript(content, (sf) => {\n removeImportByModuleSpecifier(sf, libModule(\"components/ui/auth-menu\"));\n removeImportByModuleSpecifier(\n sf,\n libModule(\"components/user-avatar.svelte\"),\n );\n // Layouts from before UserAvatar import the avatar parts directly.\n removeImportByModuleSpecifier(sf, libModule(\"components/ui/avatar\"));\n // enable-auth added `data` for the menu's `data.user`.\n removePropsBindingIfUnused(sf, \"data\", markup);\n ensureBlankLineAfterImports(sf);\n });\n return out;\n });\n\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport { Project, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { formatLikeSource } from \"../../../../runtime/ts-morph-helpers\";\n\nexport function unmodifyHooksServer(hooksServerPath: string): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n return { status: \"success\", changed: false };\n }\n\n const originalSource = fs.readFileSync(hooksServerPath, \"utf8\");\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n const callExpr = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((ce) => ce.getExpression().getText() === \"handlePocketbase\");\n if (!callExpr) return { status: \"success\", changed: false };\n\n const [firstArg] = callExpr.getArguments();\n if (!firstArg || firstArg.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n return { status: \"success\", changed: false };\n }\n\n const optionsObj = firstArg.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n const authProp = optionsObj.getProperty(\"auth\");\n if (!authProp) {\n return { status: \"success\", changed: false };\n }\n\n authProp.remove();\n\n if (optionsObj.getProperties().length === 0) {\n callExpr.removeArgument(0);\n }\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import path from \"node:path\";\nimport fs from \"node:fs\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { unmodifyLayoutServer } from \"./modifies/+layout.server\";\nimport { unmodifyRootLayoutSvelte } from \"./modifies/root-layout.svelte\";\nimport { unmodifyHooksServer } from \"./modifies/hooks.server\";\nimport { planDropsForCollections } from \"../../destroy/shared\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Reverting +layout.server.ts\");\n const layoutServerFile = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n layoutServerFile,\n unmodifyLayoutServer(layoutServerFile),\n ),\n );\n\n logger.info(\"Reverting root layout\");\n const layoutCandidates = [\n path.join(options.root, \"src\", \"routes\", \"(public)\", \"root-layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"root-layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"(public)\", \"+layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"+layout.svelte\"),\n ];\n const layoutFile =\n layoutCandidates.find((p) => fs.existsSync(p)) ?? layoutCandidates[0];\n pushResult(\n modifyOutcomeToFile(layoutFile, unmodifyRootLayoutSvelte(layoutFile)),\n );\n\n logger.info(\"Reverting hooks.server.ts\");\n const hooksServerFile = path.join(options.root, \"src\", \"hooks.server.ts\");\n pushResult(\n modifyOutcomeToFile(hooksServerFile, unmodifyHooksServer(hooksServerFile)),\n );\n\n const collectionDrops = await planDropsForCollections(\n [\"oauth_accounts\"],\n options,\n );\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops,\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;;AAQA,SAAgBY,EAAqB,GAAmC;CACtE,IAAI,CAACF,EAAG,WAAWG,CAAU,GAC3B,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAMC,IAAiBJ,EAAG,aAAaG,GAAY,MAAM;CACzD,IAAI,CAACC,EAAe,SAAS,4BAA4B,GACvD,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAI7C,IAAMC,IAAa,IADCC,EACD,CAAA,CAAQ,oBAAoBH,CAAU,GAEnDI,IAAWF,EAAW,qBAC1BG,EAAW,uBACb;CACA,KAAK,IAAMC,KAAOF,GAAU;EAC1B,IAAMG,IAAWD,EAAI,YAAY,MAAM;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U,YAAY,gBAAgB;EACrE3B,EAAK,KAAK2B,EAAQ,MAAM,OAAO,UAAU,gBAAgB;CAC3D,GACMK,IACJD,EAAiB,MAAM,MAAMhC,EAAG,WAAWkC,CAAC,CAAC,KAAKF,EAAiB;CAKrE,AAJAF,EACEhC,EAAoBmC,GAAYrB,EAAyBqB,CAAU,CAAC,CACtE,GAEAN,EAAO,KAAK,2BAA2B;CACvC,IAAMQ,IAAkBlC,EAAK,KAAK2B,EAAQ,MAAM,OAAO,iBAAiB;CAUxE,OATAE,EACEhC,EAAoBqC,GAAiBhB,EAAoBgB,CAAe,CAAC,CAC3E,GAOO;EACL,SAAS,CAAC;EACV;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAA,MAb4B3C,EAC5B,CAAC,gBAAgB,GACjBoC,CACF;CAWA;AACF"}
@@ -2,10 +2,10 @@ import { a as e, c as t, l as n } from "./providers-CL9kQ4hp.js";
2
2
  import { t as r } from "./dedent-Gq6Krl4n.js";
3
3
  import { n as i } from "./logger-CQONztPm.js";
4
4
  import { r as a, t as o } from "./generate-DyV5R8NP.js";
5
- import { t as s } from "./env-BPfk1VAw.js";
6
- import { _ as c, r as l } from "./ts-morph-helpers-Bepc-Es2.js";
7
- import { r as u } from "./modify-file-Bbhyfiy_.js";
8
- import { modifyEnvVarsFiles as d } from "./env-vars-Bj41Nccm.js";
5
+ import { t as s } from "./env-BugddEjd.js";
6
+ import { _ as c, r as l } from "./ts-morph-helpers-CHI9wAil.js";
7
+ import { r as u } from "./modify-file-COBp4eCh.js";
8
+ import { modifyEnvVarsFiles as d } from "./env-vars-CdarYsrc.js";
9
9
  import { t as f } from "./svelte-file-Dv5-bl79.js";
10
10
  import p from "node:fs";
11
11
  import m from "node:path";
@@ -82,4 +82,4 @@ async function x(r) {
82
82
  //#endregion
83
83
  export { x as generate };
84
84
 
85
- //# sourceMappingURL=generate.runtime-BavEh01F.js.map
85
+ //# sourceMappingURL=generate.runtime-CMO-Skpk.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate.runtime-BavEh01F.js","names":["providerEnvVars","resolveProvider","suppliedProviderEnv","dedent","getLogger","envEditsFor","META","modifyEnv","withInMemoryScript","ensureImports","modifyOutcomeToFile","SvelteFile","fs","path","MODULE_SPECIFIER","IMPORT_SNIPPET","MARKUP_SNIPPET","NOT_FOUND_HINT","FAILURE_HINT","modifyLayoutSvelte","layoutPath","file","out","source","sf","generate","logger","options","provider","creates","modifies","pushResult","envVars","modifyEnvVarsFiles","envPath"],"sources":["../../src/patterns/enable/analytics/modifies/layout.svelte.ts","../../src/patterns/enable/analytics/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n ensureImports,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst MODULE_SPECIFIER = \"#lib/components/analytics/analytics.svelte\";\n\nconst IMPORT_SNIPPET = dedent`\n import Analytics from '${MODULE_SPECIFIER}';\n`;\n\nconst MARKUP_SNIPPET = \"\\n<Analytics />\\n\";\n\nconst NOT_FOUND_HINT = [\n \"Create the root src/routes/+layout.svelte and mount <Analytics /> inside it.\",\n \"\",\n \"Import for the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup to add at the top level of the layout, above {@render children()}:\",\n MARKUP_SNIPPET.trim(),\n].join(\"\\n\");\n\nconst FAILURE_HINT = [\n \"Mount <Analytics /> in the root src/routes/+layout.svelte.\",\n \"\",\n 'Import for a <script lang=\"ts\"> tag:',\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup to add at the top level of the layout, above {@render children()}:\",\n MARKUP_SNIPPET.trim(),\n].join(\"\\n\");\n\n/**\n * Mounts `<Analytics />` at the top level of the root layout, ahead of\n * `{@render children()}`. The component is the same path for every provider,\n * so this modifier is provider-agnostic and a re-run with another provider\n * leaves the layout alone.\n */\nexport function modifyLayoutSvelte(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const file = SvelteFile.fromPath(layoutPath);\n if (file.hasElement(\"Analytics\")) {\n return { status: \"success\", changed: false };\n }\n if (!file.getScript()) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n ensureImports(sf, [\n { defaultImport: \"Analytics\", moduleSpecifier: MODULE_SPECIFIER },\n ]);\n });\n return out;\n });\n\n if (!file.insertBeforeChildren(MARKUP_SNIPPET)) {\n file.appendMarkup(MARKUP_SNIPPET);\n }\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport {\n providerEnvVars,\n resolveProvider,\n suppliedProviderEnv,\n} from \"../../../core/providers\";\nimport { modifyEnvVarsFiles } from \"../../../runtime/env-vars\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { modifyEnv } from \"../../../runtime/env\";\nimport { envEditsFor, META } from \"./generate\";\nimport { modifyLayoutSvelte } from \"./modifies/layout.svelte\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const provider = resolveProvider(META, options);\n const creates: File[] = [];\n const modifies: File[] = [];\n\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Modifying src/routes/+layout.svelte\");\n const layoutPath = path.join(options.root, \"src\", \"routes\", \"+layout.svelte\");\n pushResult(modifyOutcomeToFile(layoutPath, modifyLayoutSvelte(layoutPath)));\n\n // SvelteKit 3 exposes only declared variables, and only `public: true`\n // ones through `$app/env/public`, where the component imports them.\n logger.info(\"Declaring the analytics variables in src/env.ts\");\n const envVars = modifyEnvVarsFiles(options.root, providerEnvVars(provider));\n if (envVars.create) creates.push(envVars.create);\n pushResult(envVars.modify);\n\n logger.info(\"Updating .env\");\n const envPath = path.join(options.root, \".env\");\n pushResult(\n modifyOutcomeToFile(\n envPath,\n modifyEnv(envPath, envEditsFor(provider, suppliedProviderEnv(options))),\n ),\n );\n\n return {\n creates,\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;;;;AASA,IAAMc,IAAmB,8CAEnBC,IAAiB,CAAM;2BACFD,EAAiB;GAGtCE,IAAiB,qBAEjBC,IAAiB;CACrB;CACA;CACA;CACA;CACAF;CACA;CACA;CACAC,EAAe,KAAK;AACtB,CAAC,CAAC,KAAK,IAAI,GAELE,IAAe;CACnB;CACA;CACA;CACA;CACAH;CACA;CACA;CACAC,EAAe,KAAK;AACtB,CAAC,CAAC,KAAK,IAAI;AAQX,SAAgBG,EAAmB,GAAmC;CACpE,IAAI,CAACP,EAAG,WAAWQ,CAAU,GAC3B,OAAO;EAAE,QAAQ;EAAa,SAASH;CAAe;CAGxD,IAAMI,IAAOV,EAAW,SAASS,CAAU;CAqB3C,OApBIC,EAAK,WAAW,WAAW,IACtB;EAAE,QAAQ;EAAW,SAAS;CAAM,IAExCA,EAAK,UAAU,KAIpBA,EAAK,cAAc,MAAW;EAC5B,IAAM,EAAE,QAAQC,MAAQd,EAAmBe,IAAS,MAAO;GACzD,EAAcC,GAAI,CAChB;IAAE,eAAe;IAAa,iBAAiBV;GAAiB,CAClE,CAAC;EACH,CAAC;EACD,OAAOQ;CACT,CAAC,GAEID,EAAK,qBAAqBL,CAAc,KAC3CK,EAAK,aAAaL,CAAc,GAElCK,EAAK,QAAQD,CAAU,GAChB;EAAE,QAAQ;EAAW,SAASC,EAAK,WAAW;CAAE,KAhB9C;EAAE,QAAQ;EAAU,SAASH;CAAa;AAiBrD;;;AC1DA,eAAsBO,EAAS,GAAkB;CAC/C,IAAMC,IAAStB,EAAUuB,CAAO,GAC1BC,IAAW3B,EAAgBK,GAAMqB,CAAO,GACxCE,IAAkB,CAAC,GACnBC,IAAmB,CAAC,GAEpBC,KAAc,MAAsB;EACxC,AAAIV,KAAMS,EAAS,KAAKT,CAAI;CAC9B;CAEA,EAAO,KAAK,qCAAqC;CACjD,IAAMD,IAAaP,EAAK,KAAKc,EAAQ,MAAM,OAAO,UAAU,gBAAgB;CAK5E,AAJAI,EAAWrB,EAAoBU,GAAYD,EAAmBC,CAAU,CAAC,CAAC,GAI1EM,EAAO,KAAK,iDAAiD;CAC7D,IAAMM,IAAUC,EAAmBN,EAAQ,MAAM3B,EAAgB4B,CAAQ,CAAC;CAI1E,AAHII,EAAQ,UAAQH,EAAQ,KAAKG,EAAQ,MAAM,GAC/CD,EAAWC,EAAQ,MAAM,GAEzBN,EAAO,KAAK,eAAe;CAC3B,IAAMQ,IAAUrB,EAAK,KAAKc,EAAQ,MAAM,MAAM;CAQ9C,OAPAI,EACErB,EACEwB,GACA3B,EAAU2B,GAAS7B,EAAYuB,GAAU1B,EAAoByB,CAAO,CAAC,CAAC,CACxE,CACF,GAEO;EACL;EACA;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
1
+ {"version":3,"file":"generate.runtime-CMO-Skpk.js","names":["providerEnvVars","resolveProvider","suppliedProviderEnv","dedent","getLogger","envEditsFor","META","modifyEnv","withInMemoryScript","ensureImports","modifyOutcomeToFile","SvelteFile","fs","path","MODULE_SPECIFIER","IMPORT_SNIPPET","MARKUP_SNIPPET","NOT_FOUND_HINT","FAILURE_HINT","modifyLayoutSvelte","layoutPath","file","out","source","sf","generate","logger","options","provider","creates","modifies","pushResult","envVars","modifyEnvVarsFiles","envPath"],"sources":["../../src/patterns/enable/analytics/modifies/layout.svelte.ts","../../src/patterns/enable/analytics/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n ensureImports,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst MODULE_SPECIFIER = \"#lib/components/analytics/analytics.svelte\";\n\nconst IMPORT_SNIPPET = dedent`\n import Analytics from '${MODULE_SPECIFIER}';\n`;\n\nconst MARKUP_SNIPPET = \"\\n<Analytics />\\n\";\n\nconst NOT_FOUND_HINT = [\n \"Create the root src/routes/+layout.svelte and mount <Analytics /> inside it.\",\n \"\",\n \"Import for the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup to add at the top level of the layout, above {@render children()}:\",\n MARKUP_SNIPPET.trim(),\n].join(\"\\n\");\n\nconst FAILURE_HINT = [\n \"Mount <Analytics /> in the root src/routes/+layout.svelte.\",\n \"\",\n 'Import for a <script lang=\"ts\"> tag:',\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup to add at the top level of the layout, above {@render children()}:\",\n MARKUP_SNIPPET.trim(),\n].join(\"\\n\");\n\n/**\n * Mounts `<Analytics />` at the top level of the root layout, ahead of\n * `{@render children()}`. The component is the same path for every provider,\n * so this modifier is provider-agnostic and a re-run with another provider\n * leaves the layout alone.\n */\nexport function modifyLayoutSvelte(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const file = SvelteFile.fromPath(layoutPath);\n if (file.hasElement(\"Analytics\")) {\n return { status: \"success\", changed: false };\n }\n if (!file.getScript()) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n ensureImports(sf, [\n { defaultImport: \"Analytics\", moduleSpecifier: MODULE_SPECIFIER },\n ]);\n });\n return out;\n });\n\n if (!file.insertBeforeChildren(MARKUP_SNIPPET)) {\n file.appendMarkup(MARKUP_SNIPPET);\n }\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport {\n providerEnvVars,\n resolveProvider,\n suppliedProviderEnv,\n} from \"../../../core/providers\";\nimport { modifyEnvVarsFiles } from \"../../../runtime/env-vars\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { modifyEnv } from \"../../../runtime/env\";\nimport { envEditsFor, META } from \"./generate\";\nimport { modifyLayoutSvelte } from \"./modifies/layout.svelte\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const provider = resolveProvider(META, options);\n const creates: File[] = [];\n const modifies: File[] = [];\n\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Modifying src/routes/+layout.svelte\");\n const layoutPath = path.join(options.root, \"src\", \"routes\", \"+layout.svelte\");\n pushResult(modifyOutcomeToFile(layoutPath, modifyLayoutSvelte(layoutPath)));\n\n // SvelteKit 3 exposes only declared variables, and only `public: true`\n // ones through `$app/env/public`, where the component imports them.\n logger.info(\"Declaring the analytics variables in src/env.ts\");\n const envVars = modifyEnvVarsFiles(options.root, providerEnvVars(provider));\n if (envVars.create) creates.push(envVars.create);\n pushResult(envVars.modify);\n\n logger.info(\"Updating .env\");\n const envPath = path.join(options.root, \".env\");\n pushResult(\n modifyOutcomeToFile(\n envPath,\n modifyEnv(envPath, envEditsFor(provider, suppliedProviderEnv(options))),\n ),\n );\n\n return {\n creates,\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;;;;AASA,IAAMc,IAAmB,8CAEnBC,IAAiB,CAAM;2BACFD,EAAiB;GAGtCE,IAAiB,qBAEjBC,IAAiB;CACrB;CACA;CACA;CACA;CACAF;CACA;CACA;CACAC,EAAe,KAAK;AAC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,EAAQ,KAAKG,EAAQ,MAAM,GAC/CD,EAAWC,EAAQ,MAAM,GAEzBN,EAAO,KAAK,eAAe;CAC3B,IAAMQ,IAAUrB,EAAK,KAAKc,EAAQ,MAAM,MAAM;CAQ9C,OAPAI,EACErB,EACEwB,GACA3B,EAAU2B,GAAS7B,EAAYuB,GAAU1B,EAAoByB,CAAO,CAAC,CAAC,CACxE,CACF,GAEO;EACL;EACA;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
@@ -1,9 +1,9 @@
1
1
  import { t as e } from "./dedent-Gq6Krl4n.js";
2
2
  import { n as t } from "./logger-CQONztPm.js";
3
- import { _ as n, o as r, r as i } from "./ts-morph-helpers-Bepc-Es2.js";
4
- import { r as a } from "./modify-file-Bbhyfiy_.js";
3
+ import { _ as n, o as r, r as i } from "./ts-morph-helpers-CHI9wAil.js";
4
+ import { r as a } from "./modify-file-COBp4eCh.js";
5
5
  import { t as o } from "./svelte-file-Dv5-bl79.js";
6
- import { t as s } from "./compose-handle-BDlZ7Pif.js";
6
+ import { t as s } from "./compose-handle-BBlamPfx.js";
7
7
  import c from "node:fs";
8
8
  import l from "node:path";
9
9
  import { Project as u, QuoteKind as d, SyntaxKind as f } from "ts-morph";
@@ -22,14 +22,10 @@ var p = e`
22
22
  `;
23
23
  function h(e) {
24
24
  let t = e.getImportDeclarations().find((e) => e.getModuleSpecifierValue() === "#lib/negotiate.js");
25
- if (t) {
26
- t.getNamedImports().some((e) => e.getName() === "handle" && e.getAliasNode()?.getText() === "handleNegotiate") || t.addNamedImport({
27
- name: "handle",
28
- alias: "handleNegotiate"
29
- });
30
- return;
31
- }
32
- e.addImportDeclaration({
25
+ t ? t.getNamedImports().some((e) => e.getName() === "handle" && e.getAliasNode()?.getText() === "handleNegotiate") || t.addNamedImport({
26
+ name: "handle",
27
+ alias: "handleNegotiate"
28
+ }) : e.addImportDeclaration({
33
29
  namedImports: [{
34
30
  name: "handle",
35
31
  alias: "handleNegotiate"
@@ -77,14 +73,10 @@ var _ = e`
77
73
  `;
78
74
  function y(e) {
79
75
  let t = e.getImportDeclarations().find((e) => e.getModuleSpecifierValue() === "#lib/negotiate.js");
80
- if (t) {
81
- t.getNamedImports().some((e) => e.getName() === "reroute" && e.getAliasNode()?.getText() === "negotiateReroute") || t.addNamedImport({
82
- name: "reroute",
83
- alias: "negotiateReroute"
84
- });
85
- return;
86
- }
87
- e.addImportDeclaration({
76
+ t ? t.getNamedImports().some((e) => e.getName() === "reroute" && e.getAliasNode()?.getText() === "negotiateReroute") || t.addNamedImport({
77
+ name: "reroute",
78
+ alias: "negotiateReroute"
79
+ }) : e.addImportDeclaration({
88
80
  namedImports: [{
89
81
  name: "reroute",
90
82
  alias: "negotiateReroute"
@@ -189,4 +181,4 @@ async function T(e) {
189
181
  //#endregion
190
182
  export { T as generate };
191
183
 
192
- //# sourceMappingURL=generate.runtime-BXZDKLbA.js.map
184
+ //# sourceMappingURL=generate.runtime-CVDb-yLt.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate.runtime-BXZDKLbA.js","names":["FAILURE_HINT","dedent","getLogger","withInMemoryScript","formatLikeSource","ensureImports","modifyOutcomeToFile","SvelteFile","addHandle","fs","path","FAILURE_HINT$1","HOOKS_SERVER_SNIPPET","ensureNegotiateHandleImport","existing","sourceFile","d","ni","modifyHooksServerNegotiate","hooksServerPath","original","Project","QuoteKind","NEGOTIATE_ONLY_SNIPPET","FAILURE_HINT","ensureNegotiateImport","modifyHooksNegotiate","hooksPath","rerouteDecl","SyntaxKind","init","hasI18nHelper","initText","IMPORT_SNIPPET","MARKUP_SNIPPET","NOT_FOUND_HINT","modifyRootLayoutNegotiate","layoutPath","file","out","source","sf","generate","logger","options","modifies","pushResult","rootLayoutPath"],"sources":["../../src/patterns/enable/content-negotiation/modifies/hooks.server.ts","../../src/patterns/enable/content-negotiation/modifies/hooks.ts","../../src/patterns/enable/content-negotiation/modifies/root-layout.svelte.ts","../../src/patterns/enable/content-negotiation/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport dedent from \"dedent\";\nimport { Project, QuoteKind, type SourceFile } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { addHandle } from \"../../../../runtime/compose-handle\";\nimport { formatLikeSource } from \"../../../../runtime/ts-morph-helpers\";\n\nconst FAILURE_HINT = dedent`\n Wrap your exported handle with the negotiation handler:\n\n import { sequence } from '@sveltejs/kit/hooks';\n import { handle as handleNegotiate } from '#lib/negotiate.js';\n\n export const handle = sequence(handleNegotiate, /* your existing handle */);\n`;\n\nconst HOOKS_SERVER_SNIPPET = dedent`\n import { handle as handleNegotiate } from '#lib/negotiate.js';\n\n export const handle = handleNegotiate;\n`;\n\nfunction ensureNegotiateHandleImport(sourceFile: SourceFile) {\n const existing = sourceFile\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === \"#lib/negotiate.js\");\n if (existing) {\n const has = existing.getNamedImports().some((ni) => {\n return (\n ni.getName() === \"handle\" &&\n ni.getAliasNode()?.getText() === \"handleNegotiate\"\n );\n });\n if (!has)\n existing.addNamedImport({ name: \"handle\", alias: \"handleNegotiate\" });\n return;\n }\n sourceFile.addImportDeclaration({\n namedImports: [{ name: \"handle\", alias: \"handleNegotiate\" }],\n moduleSpecifier: \"#lib/negotiate.js\",\n });\n}\n\nexport function modifyHooksServerNegotiate(\n hooksServerPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n // SvelteKit loads the first `hooks.server.*` it finds, and `.js` sorts\n // first, so a new `.ts` beside it would never run.\n if (fs.existsSync(hooksServerPath.replace(/\\.ts$/, \".js\"))) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n fs.mkdirSync(path.dirname(hooksServerPath), { recursive: true });\n fs.writeFileSync(hooksServerPath, HOOKS_SERVER_SNIPPET + \"\\n\");\n return { status: \"success\", changed: true };\n }\n\n const original = fs.readFileSync(hooksServerPath, \"utf8\");\n if (original.includes(\"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 composed = addHandle(sourceFile, { expression: \"handleNegotiate\" });\n if (composed.status === \"unsupported\") {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n ensureNegotiateHandleImport(sourceFile);\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 path from \"node:path\";\nimport dedent from \"dedent\";\nimport { Project, QuoteKind, SyntaxKind, type SourceFile } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { formatLikeSource } from \"../../../../runtime/ts-morph-helpers\";\n\nconst NEGOTIATE_ONLY_SNIPPET = dedent`\n import { reroute as negotiateReroute } from '#lib/negotiate.js';\n\n export const reroute = ({ url }) => negotiateReroute(url.pathname);\n`;\n\nconst FAILURE_HINT = dedent`\n Compose your existing reroute in src/hooks.ts with the negotiation reroute:\n\n import { reroute as negotiateReroute } from '#lib/negotiate.js';\n\n export const reroute = ({ url }) => existingReroute(negotiateReroute(url.pathname));\n`;\n\nfunction ensureNegotiateImport(sourceFile: SourceFile) {\n const existing = sourceFile\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === \"#lib/negotiate.js\");\n if (existing) {\n const has = existing.getNamedImports().some((ni) => {\n return (\n ni.getName() === \"reroute\" &&\n ni.getAliasNode()?.getText() === \"negotiateReroute\"\n );\n });\n if (!has) {\n existing.addNamedImport({ name: \"reroute\", alias: \"negotiateReroute\" });\n }\n return;\n }\n sourceFile.addImportDeclaration({\n namedImports: [{ name: \"reroute\", alias: \"negotiateReroute\" }],\n moduleSpecifier: \"#lib/negotiate.js\",\n });\n}\n\nexport function modifyHooksNegotiate(hooksPath: string): ModifyOutcome {\n if (!fs.existsSync(hooksPath)) {\n fs.mkdirSync(path.dirname(hooksPath), { recursive: true });\n fs.writeFileSync(hooksPath, NEGOTIATE_ONLY_SNIPPET + \"\\n\");\n return { status: \"success\", changed: true };\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\n if (!rerouteDecl) {\n ensureNegotiateImport(sourceFile);\n sourceFile.addStatements(\n `\\nexport const reroute = ({ url }) => negotiateReroute(url.pathname);\\n`,\n );\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n const rerouteStmt = rerouteDecl.getFirstAncestorByKind(\n SyntaxKind.VariableStatement,\n );\n if (!rerouteStmt?.hasExportKeyword()) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const init = rerouteDecl.getInitializer();\n if (!init) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const hasI18nHelper = sourceFile\n .getVariableDeclarations()\n .some((d) => d.getName() === \"rerouteDeLocalize\");\n const initText = init.getText();\n\n if (hasI18nHelper && initText.includes(\"rerouteDeLocalize\")) {\n ensureNegotiateImport(sourceFile);\n rerouteDecl.setInitializer(\n \"({ url }) => rerouteDeLocalize(negotiateReroute(url.pathname))\",\n );\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n return { status: \"failed\", message: FAILURE_HINT };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n ensureImports,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst IMPORT_SNIPPET = dedent`\n import { Negotiate } from '#lib/negotiate.js';\n`;\n\nconst MARKUP_SNIPPET = \"\\n<Negotiate />\\n\";\n\nconst NOT_FOUND_HINT = [\n \"Create the root +layout.svelte and mount <Negotiate /> inside it.\",\n \"\",\n \"Import for the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup to add at the top level of the layout:\",\n MARKUP_SNIPPET.trim(),\n].join(\"\\n\");\n\nexport function modifyRootLayoutNegotiate(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(\"Negotiate\")) {\n return { status: \"success\", changed: false };\n }\n\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n ensureImports(sf, [\n {\n namedImports: [\"Negotiate\"],\n moduleSpecifier: \"#lib/negotiate.js\",\n },\n ]);\n });\n return out;\n });\n\n file.appendMarkup(MARKUP_SNIPPET);\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { modifyHooksServerNegotiate } from \"./modifies/hooks.server\";\nimport { modifyHooksNegotiate } from \"./modifies/hooks\";\nimport { modifyRootLayoutNegotiate } from \"./modifies/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 hooks.server.ts\");\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n pushResult(\n modifyOutcomeToFile(\n hooksServerPath,\n modifyHooksServerNegotiate(hooksServerPath),\n ),\n );\n\n logger.info(\"Modifying hooks.ts\");\n const hooksPath = path.join(options.root, \"src\", \"hooks.ts\");\n pushResult(modifyOutcomeToFile(hooksPath, modifyHooksNegotiate(hooksPath)));\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(\n rootLayoutPath,\n modifyRootLayoutNegotiate(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":";;;;;;;;;;AAQA,IAAMA,IAAe,CAAM;;;;;;;GASrBY,IAAuB,CAAM;;;;;AAMnC,SAASC,EAA4B,GAAwB;CAC3D,IAAMC,IAAWC,EACd,sBAAsB,CAAC,CACvB,MAAM,MAAMC,EAAE,wBAAwB,MAAM,mBAAmB;CAClE,IAAIF,GAAU;EAOZ,AANYA,EAAS,gBAAgB,CAAC,CAAC,MAAM,MAEzCG,EAAG,QAAQ,MAAM,YACjBA,EAAG,aAAa,CAAC,EAAE,QAAQ,MAAM,iBAGhC,KACHH,EAAS,eAAe;GAAE,MAAM;GAAU,OAAO;EAAkB,CAAC;EACtE;CACF;CACA,EAAW,qBAAqB;EAC9B,cAAc,CAAC;GAAE,MAAM;GAAU,OAAO;EAAkB,CAAC;EAC3D,iBAAiB;CACnB,CAAC;AACH;AAEA,SAAgBI,EACd,GACe;CACf,IAAI,CAACT,EAAG,WAAWU,CAAe,GAQhC,OALIV,EAAG,WAAWU,EAAgB,QAAQ,SAAS,KAAK,CAAC,IAChD;EAAE,QAAQ;EAAU,SAASnB;CAAa,KAEnDS,EAAG,UAAUC,EAAK,QAAQS,CAAe,GAAG,EAAE,WAAW,GAAK,CAAC,GAC/DV,EAAG,cAAcU,GAAiBP,IAAuB,IAAI,GACtD;EAAE,QAAQ;EAAW,SAAS;CAAK;CAG5C,IAAMQ,IAAWX,EAAG,aAAaU,GAAiB,MAA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ript","formatLikeSource","ensureImports","modifyOutcomeToFile","SvelteFile","addHandle","fs","path","FAILURE_HINT$1","HOOKS_SERVER_SNIPPET","ensureNegotiateHandleImport","existing","sourceFile","d","ni","modifyHooksServerNegotiate","hooksServerPath","original","Project","QuoteKind","NEGOTIATE_ONLY_SNIPPET","FAILURE_HINT","ensureNegotiateImport","modifyHooksNegotiate","hooksPath","rerouteDecl","SyntaxKind","init","hasI18nHelper","initText","IMPORT_SNIPPET","MARKUP_SNIPPET","NOT_FOUND_HINT","modifyRootLayoutNegotiate","layoutPath","file","out","source","sf","generate","logger","options","modifies","pushResult","rootLayoutPath"],"sources":["../../src/patterns/enable/content-negotiation/modifies/hooks.server.ts","../../src/patterns/enable/content-negotiation/modifies/hooks.ts","../../src/patterns/enable/content-negotiation/modifies/root-layout.svelte.ts","../../src/patterns/enable/content-negotiation/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport dedent from \"dedent\";\nimport { Project, QuoteKind, type SourceFile } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { addHandle } from \"../../../../runtime/compose-handle\";\nimport { formatLikeSource } from \"../../../../runtime/ts-morph-helpers\";\n\nconst FAILURE_HINT = dedent`\n Wrap your exported handle with the negotiation handler:\n\n import { sequence } from '@sveltejs/kit/hooks';\n import { handle as handleNegotiate } from '#lib/negotiate.js';\n\n export const handle = sequence(handleNegotiate, /* your existing handle */);\n`;\n\nconst HOOKS_SERVER_SNIPPET = dedent`\n import { handle as handleNegotiate } from '#lib/negotiate.js';\n\n export const handle = handleNegotiate;\n`;\n\nfunction ensureNegotiateHandleImport(sourceFile: SourceFile) {\n const existing = sourceFile\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === \"#lib/negotiate.js\");\n if (existing) {\n const has = existing.getNamedImports().some((ni) => {\n return (\n ni.getName() === \"handle\" &&\n ni.getAliasNode()?.getText() === \"handleNegotiate\"\n );\n });\n if (!has)\n existing.addNamedImport({ name: \"handle\", alias: \"handleNegotiate\" });\n return;\n }\n sourceFile.addImportDeclaration({\n namedImports: [{ name: \"handle\", alias: \"handleNegotiate\" }],\n moduleSpecifier: \"#lib/negotiate.js\",\n });\n}\n\nexport function modifyHooksServerNegotiate(\n hooksServerPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n // SvelteKit loads the first `hooks.server.*` it finds, and `.js` sorts\n // first, so a new `.ts` beside it would never run.\n if (fs.existsSync(hooksServerPath.replace(/\\.ts$/, \".js\"))) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n fs.mkdirSync(path.dirname(hooksServerPath), { recursive: true });\n fs.writeFileSync(hooksServerPath, HOOKS_SERVER_SNIPPET + \"\\n\");\n return { status: \"success\", changed: true };\n }\n\n const original = fs.readFileSync(hooksServerPath, \"utf8\");\n if (original.includes(\"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 composed = addHandle(sourceFile, { expression: \"handleNegotiate\" });\n if (composed.status === \"unsupported\") {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n ensureNegotiateHandleImport(sourceFile);\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 path from \"node:path\";\nimport dedent from \"dedent\";\nimport { Project, QuoteKind, SyntaxKind, type SourceFile } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { formatLikeSource } from \"../../../../runtime/ts-morph-helpers\";\n\nconst NEGOTIATE_ONLY_SNIPPET = dedent`\n import { reroute as negotiateReroute } from '#lib/negotiate.js';\n\n export const reroute = ({ url }) => negotiateReroute(url.pathname);\n`;\n\nconst FAILURE_HINT = dedent`\n Compose your existing reroute in src/hooks.ts with the negotiation reroute:\n\n import { reroute as negotiateReroute } from '#lib/negotiate.js';\n\n export const reroute = ({ url }) => existingReroute(negotiateReroute(url.pathname));\n`;\n\nfunction ensureNegotiateImport(sourceFile: SourceFile) {\n const existing = sourceFile\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === \"#lib/negotiate.js\");\n if (existing) {\n const has = existing.getNamedImports().some((ni) => {\n return (\n ni.getName() === \"reroute\" &&\n ni.getAliasNode()?.getText() === \"negotiateReroute\"\n );\n });\n if (!has) {\n existing.addNamedImport({ name: \"reroute\", alias: \"negotiateReroute\" });\n }\n return;\n }\n sourceFile.addImportDeclaration({\n namedImports: [{ name: \"reroute\", alias: \"negotiateReroute\" }],\n moduleSpecifier: \"#lib/negotiate.js\",\n });\n}\n\nexport function modifyHooksNegotiate(hooksPath: string): ModifyOutcome {\n if (!fs.existsSync(hooksPath)) {\n fs.mkdirSync(path.dirname(hooksPath), { recursive: true });\n fs.writeFileSync(hooksPath, NEGOTIATE_ONLY_SNIPPET + \"\\n\");\n return { status: \"success\", changed: true };\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\n if (!rerouteDecl) {\n ensureNegotiateImport(sourceFile);\n sourceFile.addStatements(\n `\\nexport const reroute = ({ url }) => negotiateReroute(url.pathname);\\n`,\n );\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n const rerouteStmt = rerouteDecl.getFirstAncestorByKind(\n SyntaxKind.VariableStatement,\n );\n if (!rerouteStmt?.hasExportKeyword()) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const init = rerouteDecl.getInitializer();\n if (!init) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const hasI18nHelper = sourceFile\n .getVariableDeclarations()\n .some((d) => d.getName() === \"rerouteDeLocalize\");\n const initText = init.getText();\n\n if (hasI18nHelper && initText.includes(\"rerouteDeLocalize\")) {\n ensureNegotiateImport(sourceFile);\n rerouteDecl.setInitializer(\n \"({ url }) => rerouteDeLocalize(negotiateReroute(url.pathname))\",\n );\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n return { status: \"failed\", message: FAILURE_HINT };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n ensureImports,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst IMPORT_SNIPPET = dedent`\n import { Negotiate } from '#lib/negotiate.js';\n`;\n\nconst MARKUP_SNIPPET = \"\\n<Negotiate />\\n\";\n\nconst NOT_FOUND_HINT = [\n \"Create the root +layout.svelte and mount <Negotiate /> inside it.\",\n \"\",\n \"Import for the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup to add at the top level of the layout:\",\n MARKUP_SNIPPET.trim(),\n].join(\"\\n\");\n\nexport function modifyRootLayoutNegotiate(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(\"Negotiate\")) {\n return { status: \"success\", changed: false };\n }\n\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n ensureImports(sf, [\n {\n namedImports: [\"Negotiate\"],\n moduleSpecifier: \"#lib/negotiate.js\",\n },\n ]);\n });\n return out;\n });\n\n file.appendMarkup(MARKUP_SNIPPET);\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { modifyHooksServerNegotiate } from \"./modifies/hooks.server\";\nimport { modifyHooksNegotiate } from \"./modifies/hooks\";\nimport { modifyRootLayoutNegotiate } from \"./modifies/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 hooks.server.ts\");\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n pushResult(\n modifyOutcomeToFile(\n hooksServerPath,\n modifyHooksServerNegotiate(hooksServerPath),\n ),\n );\n\n logger.info(\"Modifying hooks.ts\");\n const hooksPath = path.join(options.root, \"src\", \"hooks.ts\");\n pushResult(modifyOutcomeToFile(hooksPath, modifyHooksNegotiate(hooksPath)));\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(\n rootLayoutPath,\n modifyRootLayoutNegotiate(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":";;;;;;;;;;AAQA,IAAMA,IAAe,CAAM;;;;;;;GASrBY,IAAuB,CAAM;;;;;AAMnC,SAASC,EAA4B,GAAwB;CAC3D,IAAMC,IAAWC,EACd,sBAAsB,CAAC,CACvB,MAAM,MAAMC,EAAE,wBAAwB,MAAM,mBAAmB;CAClE,AAAIF,IACUA,EAAS,gBAAgB,CAAC,CAAC,MAAM,MAEzCG,EAAG,QAAQ,MAAM,YACjBA,EAAG,aAAa,CAAC,EAAE,QAAQ,MAAM,iBAGhC,KACHH,EAAS,eAAe;EAAE,MAAM;EAAU,OAAO;CAAkB,CAAC,IAGxEC,EAAW,qBAAqB;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WxC,EAAoBqB,GAAWD,EAAqBC,CAAS,CAAC,CAAC,GAE1EgB,EAAO,KAAK,qCAAqC;CACjD,IAAMI,IAAiBrC,EAAK,KAC1BkC,EAAQ,MACR,OACA,UACA,gBACF;CAQA,OAPAE,EACExC,EACEyC,GACAX,EAA0BW,CAAc,CAC1C,CACF,GAEO;EACL,SAAS,CAAC;EACV;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
@@ -0,0 +1,17 @@
1
+ import { t as e } from "./errors-DR3gF_7a.js";
2
+ import t from "node:fs";
3
+ import n from "node:path";
4
+ //#region src/patterns/generate/shop/generate.runtime.ts
5
+ function r(r, i) {
6
+ let a = i.map((e) => e.path).filter((e) => t.existsSync(n.join(r, e)));
7
+ if (a.length !== 0) throw new e([
8
+ "These files already exist, and generating the shop would write over them:",
9
+ ...a.map((e) => ` ${e}`),
10
+ "",
11
+ "Nothing was changed. Run `vela destroy shop` to remove a shop generated before, or move the files aside."
12
+ ].join("\n"));
13
+ }
14
+ //#endregion
15
+ export { r as assertNoneExist };
16
+
17
+ //# sourceMappingURL=generate.runtime-C_5Ghjri.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.runtime-C_5Ghjri.js","names":["InvalidArgumentError","fs","path","assertNoneExist","existing","creates","file","root"],"sources":["../../src/patterns/generate/shop/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, Options } from \"../../../core/types\";\nimport { InvalidArgumentError } from \"../../../core/errors\";\n\n/**\n * A generator writes files the developer then owns, so it never writes over\n * one that exists: the shop pages are refused while any of them is there.\n * `vela destroy shop` takes them out; a project that still has the demo page\n * an older `vela enable ecommerce` wrote removes that by hand.\n */\nexport function assertNoneExist(root: string, creates: File[]): void {\n const existing = creates\n .map((file) => file.path)\n .filter((file) => fs.existsSync(path.join(root, file)));\n if (existing.length === 0) return;\n throw new InvalidArgumentError(\n [\n \"These files already exist, and generating the shop would write over them:\",\n ...existing.map((file) => ` ${file}`),\n \"\",\n \"Nothing was changed. Run `vela destroy shop` to remove a shop generated before, or move the files aside.\",\n ].join(\"\\n\"),\n );\n}\n\nexport async function generate(_options: Options) {\n // Everything the shop needs is in the base creates; this module exists so\n // the refusal above can look at the disk, which the base generator can't.\n return null;\n}\n"],"mappings":";;;;AAWA,SAAgBG,EAAgB,GAAc,GAAuB;CACnE,IAAMC,IAAWC,EACd,KAAK,MAASC,EAAK,IAAI,CAAC,CACxB,QAAQ,MAASL,EAAG,WAAWC,EAAK,KAAKK,GAAMD,CAAI,CAAC,CAAC;CACxD,IAAIF,EAAS,WAAW,GACxB,MAAM,IAAIJ,EACR;EACE;EACA,GAAGI,EAAS,KAAK,MAAS,KAAKE,GAAM;EACrC;EACA;CACF,CAAC,CAAC,KAAK,IAAI,CACb;AACF"}
@@ -1,7 +1,7 @@
1
1
  import { t as e } from "./dedent-Gq6Krl4n.js";
2
2
  import { n as t } from "./logger-CQONztPm.js";
3
- import { o as n } from "./ts-morph-helpers-Bepc-Es2.js";
4
- import { r } from "./modify-file-Bbhyfiy_.js";
3
+ import { o as n } from "./ts-morph-helpers-CHI9wAil.js";
4
+ import { r } from "./modify-file-COBp4eCh.js";
5
5
  import i from "node:fs";
6
6
  import a from "node:path";
7
7
  import { Project as o, SyntaxKind as s } from "ts-morph";
@@ -84,4 +84,4 @@ async function d(e) {
84
84
  //#endregion
85
85
  export { d as generate };
86
86
 
87
- //# sourceMappingURL=generate.runtime-CWgZhxQt.js.map
87
+ //# sourceMappingURL=generate.runtime-CbOMXQSo.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate.runtime-CWgZhxQt.js","names":["dedent","getLogger","formatLikeSource","fs","path","FAILURE_HINT","NOT_FOUND_HINT","modifyHooksServer","hooksServerPath","originalSource","sourceFile","Project","callExpr","SyntaxKind","ce","args","firstArg","optionsObj","apiProp","apiInit","apiObj","generate","logger","options","modifies","file","modifyOutcomeToFile"],"sources":["../../src/patterns/enable/api/modifies/hooks.server.ts","../../src/patterns/enable/api/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Project, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { formatLikeSource } from \"../../../../runtime/ts-morph-helpers\";\n\nconst FAILURE_HINT = dedent`\n Configure handlePocketbase() with the api option in hooks.server.ts:\n\n handlePocketbase({\n api: { enabled: true },\n });\n`;\n\nconst NOT_FOUND_HINT = dedent`\n Create src/hooks.server.ts with handlePocketbase:\n\n import { handlePocketbase } from 'velastack/handle';\n\n export const handle = handlePocketbase({\n api: { enabled: true },\n });\n`;\n\nexport function modifyHooksServer(hooksServerPath: string): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const originalSource = fs.readFileSync(hooksServerPath, \"utf8\");\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n const callExpr = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((ce) => ce.getExpression().getText() === \"handlePocketbase\");\n\n if (!callExpr) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const args = callExpr.getArguments();\n if (args.length === 0) {\n callExpr.addArgument(`{ api: { enabled: true } }`);\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n const firstArg = args[0];\n if (firstArg.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n callExpr.insertArgument(0, `{ api: { enabled: true } }`);\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n const optionsObj = firstArg.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n const apiProp = optionsObj.getProperty(\"api\");\n\n if (!apiProp) {\n optionsObj.addPropertyAssignment({\n name: \"api\",\n initializer: `{ enabled: true }`,\n });\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n if (apiProp.getKind() === SyntaxKind.PropertyAssignment) {\n const apiInit = (\n apiProp as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (apiInit && apiInit.getKind() === SyntaxKind.ObjectLiteralExpression) {\n const apiObj = apiInit as import(\"ts-morph\").ObjectLiteralExpression;\n const enabledProp = apiObj.getProperty(\"enabled\");\n if (!enabledProp) {\n apiObj.addPropertyAssignment({ name: \"enabled\", initializer: \"true\" });\n }\n }\n }\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { modifyHooksServer } from \"./modifies/hooks.server\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n\n logger.info(\"Modifying hooks.server.ts\");\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n const file = modifyOutcomeToFile(\n hooksServerPath,\n modifyHooksServer(hooksServerPath),\n );\n if (file) modifies.push(file);\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;AAMA,IAAMK,IAAe,CAAM;;;;;;GAQrBC,IAAiB,CAAM;;;;;;;;;AAU7B,SAAgBC,EAAkB,GAAwC;CACxE,IAAI,CAACJ,EAAG,WAAWK,CAAe,GAChC,OAAO;EAAE,QAAQ;EAAa,SAASF;CAAe;CAGxD,IAAMG,IAAiBN,EAAG,aAAaK,GAAiB,MAAM,GAExDE,IAAa,IADCC,EACD,CAAA,CAAQ,oBAAoBH,CAAe,GAExDI,IAAWF,EACd,qBAAqBG,EAAW,cAAc,CAAC,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J,EAAK,KAAKmB,EAAQ,MAAM,OAAO,iBAAiB,GAClEE,IAAOC,EACXlB,GACAD,EAAkBC,CAAe,CACnC;CAGA,OAFIiB,KAAMD,EAAS,KAAKC,CAAI,GAErB;EACL,SAAS,CAAC;EACV;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
1
+ {"version":3,"file":"generate.runtime-CbOMXQSo.js","names":["dedent","getLogger","formatLikeSource","fs","path","FAILURE_HINT","NOT_FOUND_HINT","modifyHooksServer","hooksServerPath","originalSource","sourceFile","Project","callExpr","SyntaxKind","ce","args","firstArg","optionsObj","apiProp","apiInit","apiObj","generate","logger","options","modifies","file","modifyOutcomeToFile"],"sources":["../../src/patterns/enable/api/modifies/hooks.server.ts","../../src/patterns/enable/api/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Project, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { formatLikeSource } from \"../../../../runtime/ts-morph-helpers\";\n\nconst FAILURE_HINT = dedent`\n Configure handlePocketbase() with the api option in hooks.server.ts:\n\n handlePocketbase({\n api: { enabled: true },\n });\n`;\n\nconst NOT_FOUND_HINT = dedent`\n Create src/hooks.server.ts with handlePocketbase:\n\n import { handlePocketbase } from 'velastack/handle';\n\n export const handle = handlePocketbase({\n api: { enabled: true },\n });\n`;\n\nexport function modifyHooksServer(hooksServerPath: string): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const originalSource = fs.readFileSync(hooksServerPath, \"utf8\");\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n const callExpr = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((ce) => ce.getExpression().getText() === \"handlePocketbase\");\n\n if (!callExpr) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const args = callExpr.getArguments();\n if (args.length === 0) {\n callExpr.addArgument(`{ api: { enabled: true } }`);\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n const firstArg = args[0];\n if (firstArg.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n callExpr.insertArgument(0, `{ api: { enabled: true } }`);\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n const optionsObj = firstArg.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n const apiProp = optionsObj.getProperty(\"api\");\n\n if (!apiProp) {\n optionsObj.addPropertyAssignment({\n name: \"api\",\n initializer: `{ enabled: true }`,\n });\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n if (apiProp.getKind() === SyntaxKind.PropertyAssignment) {\n const apiInit = (\n apiProp as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (apiInit && apiInit.getKind() === SyntaxKind.ObjectLiteralExpression) {\n const apiObj = apiInit as import(\"ts-morph\").ObjectLiteralExpression;\n const enabledProp = apiObj.getProperty(\"enabled\");\n if (!enabledProp) {\n apiObj.addPropertyAssignment({ name: \"enabled\", initializer: \"true\" });\n }\n }\n }\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { modifyHooksServer } from \"./modifies/hooks.server\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n\n logger.info(\"Modifying hooks.server.ts\");\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n const file = modifyOutcomeToFile(\n hooksServerPath,\n modifyHooksServer(hooksServerPath),\n );\n if (file) modifies.push(file);\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;AAMA,IAAMK,IAAe,CAAM;;;;;;GAQrBC,IAAiB,CAAM;;;;;;;;;AAU7B,SAAgBC,EAAkB,GAAwC;CACxE,IAAI,CAACJ,EAAG,WAAWK,CAAe,GAChC,OAAO;EAAE,QAAQ;EAAa,SAASF;CAAe;CAGxD,IAAMG,IAAiBN,EAAG,aAAaK,GAAiB,MAAM,GAExDE,IAAa,IADCC,EACD,CAAA,CAAQ,oBAAoBH,CAAe,GAExDI,IAAWF,EACd,qBAAqBG,EAAW,cAAc,CAAC,CAC/C,MAAM,MAAOC,EAAG,cAAc,CAAC,CAAC,QAAQ,MAAM,kBAAkB;CAEnE,IAAI,CAACF,GACH,OAAO;EAAE,QAAQ;EAAU,SAASP;CAAa;CAGnD,IAAMU,IAAOH,EAAS,aAAa;CACnC,IAAIG,EAAK,WAAW,GAIlB,OAHAH,EAAS,YAAY,4BAA4B,GACjDV,EAAiBQ,CAAU,GAC3BA,EAAW,SAAS,GACb;EAAE,QAAQ;EAAW,SAAS;CAAK;CAG5C,IAAMM,IAAWD,EAAK;CACtB,IAAIC,EAAS,QAAQ,MAAMH,EAAW,yBAIpC,OAHAD,EAAS,eAAe,GAAG,4BAA4B,GACvDV,EAAiBQ,CAAU,GAC3BA,EAAW,SAAS,GACb;EAAE,QAAQ;EAAW,SAAS;CAAK;CAG5C,IAAMO,IAAaD,EAAS,cAAcH,EAAW,uBAAuB,GACtEK,IAAUD,EAAW,YAAY,KAAK;CAE5C,IAAI,CAACC,GAOH,OANAD,EAAW,sBAAsB;EAC/B,MAAM;EACN,aAAa;CACf,CAAC,GACDf,EAAiBQ,CAAU,GAC3BA,EAAW,SAAS,GACb;EAAE,QAAQ;EAAW,SAAS;CAAK;CAG5C,IAAIQ,EAAQ,QAAQ,MAAML,EAAW,oBAAoB;EACvD,IAAMM,IACJD,EACA,eAAe;EACjB,IAAIC,KAAWA,EAAQ,QAAQ,MAAMN,EAAW,yBAAyB;GACvE,IAAMO,IAASD;GAEf,AADoBC,EAAO,YAAY,SAClC,KACHA,EAAO,sBAAsB;IAAE,MAAM;IAAW,aAAa;GAAO,CAAC;EAEzE;CACF;CAIA,OAFAlB,EAAiBQ,CAAU,GAC3BA,EAAW,SAAS,GACb;EACL,QAAQ;EACR,SAASA,EAAW,YAAY,MAAMD;CACxC;AACF;;;ACnFA,eAAsBY,EAAS,GAAkB;CAC/C,IAAMC,IAASrB,EAAUsB,CAAO,GAC1BC,IAAmB,CAAC;CAE1B,EAAO,KAAK,2BAA2B;CACvC,IAAMhB,IAAkBJ,EAAK,KAAKmB,EAAQ,MAAM,OAAO,iBAAiB,GAClEE,IAAOC,EACXlB,GACAD,EAAkBC,CAAe,CACnC;CAGA,OAFIiB,KAAMD,EAAS,KAAKC,CAAI,GAErB;EACL,SAAS,CAAC;EACV;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
@@ -1,11 +1,11 @@
1
1
  import { r as e, t } from "./lib-specifier-Cngo1zF_.js";
2
2
  import { t as n } from "./dedent-Gq6Krl4n.js";
3
3
  import { n as r } from "./logger-CQONztPm.js";
4
- import { n as i } from "./shared-D5GOS97l.js";
5
- import { _ as a, d as o, n as s, o as c, u as l } from "./ts-morph-helpers-Bepc-Es2.js";
6
- import { a as u, r as d } from "./modify-file-Bbhyfiy_.js";
4
+ import { n as i } from "./shared-C_Fr8wph.js";
5
+ import { _ as a, d as o, n as s, o as c, u as l } from "./ts-morph-helpers-CHI9wAil.js";
6
+ import { a as u, r as d } from "./modify-file-COBp4eCh.js";
7
7
  import { t as f } from "./svelte-file-Dv5-bl79.js";
8
- import { n as p } from "./compose-handle-BDlZ7Pif.js";
8
+ import { n as p } from "./compose-handle-BBlamPfx.js";
9
9
  import m from "node:fs";
10
10
  import h from "node:path";
11
11
  import { Project as g, QuoteKind as _, SyntaxKind as v } from "ts-morph";
@@ -121,4 +121,4 @@ async function E(e) {
121
121
  //#endregion
122
122
  export { E as generate };
123
123
 
124
- //# sourceMappingURL=generate.runtime-DBBtYTAa.js.map
124
+ //# sourceMappingURL=generate.runtime-CbT-EbQT.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate.runtime-DBBtYTAa.js","names":["removeNegotiateImport","libModule","dedent","getLogger","toDeleteEntry","withInMemoryScript","removeNamedImportIfUnused","ensureBlankLineAfterImports","formatLikeSource","removeImportByModuleSpecifier","revertOutcomeToFile","modifyOutcomeToFile","SvelteFile","removeHandle","fs","path","FAILURE_HINT","removeNegotiateImport$1","decl","sourceFile","isLibSpecifier","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","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,IAAMgB,IAAe,CAAM;;;;;;AAO3B,SAAShB,EAAsB,GAAiC;CAC9D,IAAMkB,IAAOC,EACV,sBAAsB,CAAC,CACvB,MAAM,MAAMC,EAAeC,EAAE,wBAAwB,GAAG,WAAW,CAAC;CACvE,IAAI,CAACH,GAAM,OAAO;CAElB,IAAMI,IAAQJ,EAAK,gBAAgB,CAAC,CAAC,MAAM,MAEvCK,EAAG,QAAQ,MAAM,YACjBA,EAAG,aAAa,CAAC,EAAE,QAAQ,MAAM,iBAEpC;CASD,OAPKD,KAEDJ,EAAK,gBAAgB,CAAC,CAAC,WAAW,KAAK,CAACA,EAAK,iBAAiB,IAChEA,EAAK,OAAO,IAEZI,EAAM,OAAO,GAER,MAPY;AAQrB;AAOA,SAAgBE,EACd,GACe;CACf,IAAI,CAACV,EAAG,WAAWW,CAAe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leteEntry","withInMemoryScript","removeNamedImportIfUnused","ensureBlankLineAfterImports","formatLikeSource","removeImportByModuleSpecifier","revertOutcomeToFile","modifyOutcomeToFile","SvelteFile","removeHandle","fs","path","FAILURE_HINT","removeNegotiateImport$1","decl","sourceFile","isLibSpecifier","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","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,IAAMgB,IAAe,CAAM;;;;;;AAO3B,SAAShB,EAAsB,GAAiC;CAC9D,IAAMkB,IAAOC,EACV,sBAAsB,CAAC,CACvB,MAAM,MAAMC,EAAeC,EAAE,wBAAwB,GAAG,WAAW,CAAC;CACvE,IAAI,CAACH,GAAM,OAAO;CAElB,IAAMI,IAAQJ,EAAK,gBAAgB,CAAC,CAAC,MAAM,MAEvCK,EAAG,QAAQ,MAAM,YACjBA,EAAG,aAAa,CAAC,EAAE,QAAQ,MAAM,iBAEpC;CASD,OAPKD,KAEDJ,EAAK,gBAAgB,CAAC,CAAC,WAAW,KAAK,CAACA,EAAK,iBAAiB,IAChEA,EAAK,OAAO,IAEZI,EAAM,OAAO,GAER,MAPY;AAQrB;AAOA,SAAgBE,EACd,GACe;CACf,IAAI,CAACV,EAAG,WAAWW,CAAe,GAChC,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAMC,IAAWZ,EAAG,aAAaW,GAAiB,MAAM;CACxD,IAAI,CAACC,EAAS,SAAS,iBAAiB,GACtC,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAO7C,IAAMP,IAAa,IAJCQ,EAAQ;EAC1B,iBAAiB,EAAE,SAAS,GAAK;EACjC,sBAAsB,EAAE,WAAWC,EAAU,OAAO;CACtD,CACmB,CAAA,CAAQ,oBAAoBH,CAAe;CAY9D,OAVgBZ,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O,KAAK,2BAA2B;CACvC,IAAMf,IAAkBV,EAAK,KAAKgC,EAAQ,MAAM,OAAO,iBAAiB,GAElEI,IAAoBzC,EACxBe,GACAD,EAA6BC,CAAe,CAC9C;CAIA,AAHAyB,EAAWC,EAAkB,MAAM,GAC/BA,EAAkB,UAAQF,EAAQ,KAAKE,EAAkB,MAAM,GAEnEL,EAAO,KAAK,oBAAoB;CAChC,IAAMZ,IAAYnB,EAAK,KAAKgC,EAAQ,MAAM,OAAO,UAAU,GACrDK,IAAenB,EAAuBC,CAAS;CAWrD,AATEpB,EAAG,WAAWoB,CAAS,KACvBpB,EAAG,aAAaoB,GAAW,MAAM,CAAC,CAAC,KAAK,MAAM,KAG9Ce,EAAQ,KAAK7C,EAAc8B,CAAS,CAAC,IAErCgB,EAAWvC,EAAoBuB,GAAWkB,CAAY,CAAC,GAGzDN,EAAO,KAAK,qCAAqC;CACjD,IAAMO,IAAiBtC,EAAK,KAC1BgC,EAAQ,MACR,OACA,UACA,gBACF;CAQA,OAPAG,EACEvC,EACE0C,GACAf,EAA4Be,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"}
@@ -2,14 +2,14 @@ import { r as e, t } from "./lib-specifier-Cngo1zF_.js";
2
2
  import { t as n } from "./dedent-Gq6Krl4n.js";
3
3
  import { n as r } from "./logger-CQONztPm.js";
4
4
  import { t as i } from "./env-vars-mnRA0hOe.js";
5
- import { t as a } from "./env-vars-Cr4lbMD_.js";
6
- import { n as o } from "./shared-D5GOS97l.js";
7
- import { c as s, m as c, n as l, o as u } from "./ts-morph-helpers-Bepc-Es2.js";
8
- import { a as d, r as f } from "./modify-file-Bbhyfiy_.js";
9
- import { unmodifyEnvVarsFiles as p } from "./env-vars-Bj41Nccm.js";
10
- import { t as m } from "./site-lj0CDdQ1.js";
11
- import { n as h } from "./compose-handle-BDlZ7Pif.js";
12
- import { a as g, l as _, s as v } from "./test-setup-DZoyF8Ak.js";
5
+ import { n as a } from "./site-BoujshKo.js";
6
+ import { t as o } from "./env-vars-Cr4lbMD_.js";
7
+ import { n as s } from "./shared-C_Fr8wph.js";
8
+ import { c, m as l, n as u, o as d } from "./ts-morph-helpers-CHI9wAil.js";
9
+ import { a as f, r as p } from "./modify-file-COBp4eCh.js";
10
+ import { unmodifyEnvVarsFiles as m } from "./env-vars-CdarYsrc.js";
11
+ import { n as h } from "./compose-handle-BBlamPfx.js";
12
+ import { a as g, l as _, s as v } from "./test-setup-pYUIfWb2.js";
13
13
  import y from "node:fs";
14
14
  import b from "node:path";
15
15
  import { Node as x, Project as S, QuoteKind as C } from "ts-morph";
@@ -68,7 +68,7 @@ function A(e) {
68
68
  message: w
69
69
  };
70
70
  let r = k(n);
71
- return r && r !== "custom" && c(n, r), s(n, E), u(n), l(n), n.saveSync(), {
71
+ return r && r !== "custom" && l(n, r), c(n, E), d(n), u(n), n.saveSync(), {
72
72
  status: "success",
73
73
  changed: n.getFullText() !== t
74
74
  };
@@ -118,30 +118,30 @@ function N(e) {
118
118
  return t;
119
119
  }
120
120
  async function P(e) {
121
- let t = r(e), n = [], s = [], c = [];
121
+ let t = r(e), n = [], c = [], l = [];
122
122
  t.info("Reverting adapter config");
123
- let l = _(e.root), u = f(l.filePath, l.outcome);
124
- u && s.push(u), t.info("Reverting hooks.server.ts");
125
- let h = b.join(e.root, "src", "hooks.server.ts"), x = d(h, A(h));
126
- x.modify && s.push(x.modify), x.delete && c.push(x.delete);
123
+ let u = _(e.root), d = p(u.filePath, u.outcome);
124
+ d && c.push(d), t.info("Reverting hooks.server.ts");
125
+ let h = b.join(e.root, "src", "hooks.server.ts"), x = f(h, A(h));
126
+ x.modify && c.push(x.modify), x.delete && l.push(x.delete);
127
127
  let S = y.existsSync(b.join(e.root, "src", "lib", "server", "workflows.ts"));
128
128
  t.info(S ? "Removing the PocketBase and workflow variables from src/env.ts" : "Removing the PocketBase variables from src/env.ts");
129
- let C = p(e.root, (S ? a : i).map((e) => e.name));
130
- C.modify && s.push(C.modify), C.delete && c.push(C.delete), t.info("Reverting .gitignore");
131
- let w = b.join(e.root, ".gitignore"), T = f(w, v(w));
132
- T && s.push(T), t.info("Reverting src/routes/+layout.server.ts");
133
- let E = b.join(e.root, "src", "routes", "+layout.server.ts"), D = f(E, M(E));
134
- if (D && s.push(D), D?.status === "success") {
135
- let t = await m(e);
129
+ let C = m(e.root, (S ? o : i).map((e) => e.name));
130
+ C.modify && c.push(C.modify), C.delete && l.push(C.delete), t.info("Reverting .gitignore");
131
+ let w = b.join(e.root, ".gitignore"), T = p(w, v(w));
132
+ T && c.push(T), t.info("Reverting src/routes/+layout.server.ts");
133
+ let E = b.join(e.root, "src", "routes", "+layout.server.ts"), D = p(E, M(E));
134
+ if (D && c.push(D), D?.status === "success") {
135
+ let t = await a(e);
136
136
  t && n.push(t);
137
137
  }
138
- for (let n of N(b.join(e.root, "src"))) t.info(`Removing ${b.relative(e.root, n)}`), c.push(o(n));
138
+ for (let n of N(b.join(e.root, "src"))) t.info(`Removing ${b.relative(e.root, n)}`), l.push(s(n));
139
139
  t.info("Reverting test/setup.ts");
140
- let O = b.join(e.root, "test", "setup.ts"), k = f(O, g(O));
141
- return k && s.push(k), {
140
+ let O = b.join(e.root, "test", "setup.ts"), k = p(O, g(O));
141
+ return k && c.push(k), {
142
142
  creates: n,
143
- modifies: s,
144
- deletes: c,
143
+ modifies: c,
144
+ deletes: l,
145
145
  components: [],
146
146
  packages: [],
147
147
  collections: [],
@@ -152,4 +152,4 @@ async function P(e) {
152
152
  //#endregion
153
153
  export { P as generate };
154
154
 
155
- //# sourceMappingURL=generate.runtime-CSUnP0l-.js.map
155
+ //# sourceMappingURL=generate.runtime-Cxr15Y5H.js.map