@velastack/patterns 0.14.3 → 0.15.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 (156) hide show
  1. package/README.md +28 -0
  2. package/dist/chunks/{_page-44USwLXO.js → _page-6d3DCr0p.js} +2 -2
  3. package/dist/chunks/{_page-44USwLXO.js.map → _page-6d3DCr0p.js.map} +1 -1
  4. package/dist/chunks/{auth-pages-BW3_yluN.js → auth-pages-DHzh31mw.js} +2 -2
  5. package/dist/chunks/{auth-pages-BW3_yluN.js.map → auth-pages-DHzh31mw.js.map} +1 -1
  6. package/dist/chunks/{collections-B_-NTtLW.js → collections-FKsKGtaH.js} +70 -73
  7. package/dist/chunks/collections-FKsKGtaH.js.map +1 -0
  8. package/dist/chunks/{constants-CTp-0HKk.js → constants-BHuzzsKu.js} +19 -19
  9. package/dist/chunks/constants-BHuzzsKu.js.map +1 -0
  10. package/dist/chunks/{currency.server-DOX4Rzyb.js → currency.server-DRuEFc6D.js} +4 -4
  11. package/dist/chunks/{currency.server-DOX4Rzyb.js.map → currency.server-DRuEFc6D.js.map} +1 -1
  12. package/dist/chunks/{env-vars-BbS_mWyP.js → env-vars-BcHu8247.js} +4 -4
  13. package/dist/chunks/{env-vars-BbS_mWyP.js.map → env-vars-BcHu8247.js.map} +1 -1
  14. package/dist/chunks/{generate-B4uDCW5D.js → generate-9O0VdZOl.js} +4 -4
  15. package/dist/chunks/{generate-B4uDCW5D.js.map → generate-9O0VdZOl.js.map} +1 -1
  16. package/dist/chunks/{generate-CKuUg3p-.js → generate-BDGmczK8.js} +2 -2
  17. package/dist/chunks/{generate-CKuUg3p-.js.map → generate-BDGmczK8.js.map} +1 -1
  18. package/dist/chunks/{generate-DYq5Oj58.js → generate-BrO9MOgL.js} +2 -2
  19. package/dist/chunks/{generate-DYq5Oj58.js.map → generate-BrO9MOgL.js.map} +1 -1
  20. package/dist/chunks/{generate-Bwkx_usZ.js → generate-CXAKf1Hh.js} +4 -4
  21. package/dist/chunks/{generate-Bwkx_usZ.js.map → generate-CXAKf1Hh.js.map} +1 -1
  22. package/dist/chunks/{generate-4iujJNAW.js → generate-CkfJrlEg.js} +5 -5
  23. package/dist/chunks/{generate-4iujJNAW.js.map → generate-CkfJrlEg.js.map} +1 -1
  24. package/dist/chunks/{generate-BJY8AtAp.js → generate-a3U8uDzW.js} +5 -5
  25. package/dist/chunks/{generate-BJY8AtAp.js.map → generate-a3U8uDzW.js.map} +1 -1
  26. package/dist/chunks/{generate-JkvSNTy-.js → generate-rcDj36TD.js} +31 -188
  27. package/dist/chunks/generate-rcDj36TD.js.map +1 -0
  28. package/dist/chunks/{generate.runtime-D0lI3Gt8.js → generate.runtime-4gS2ZHpj.js} +5 -5
  29. package/dist/chunks/{generate.runtime-D0lI3Gt8.js.map → generate.runtime-4gS2ZHpj.js.map} +1 -1
  30. package/dist/chunks/{generate.runtime-BFX_8erf.js → generate.runtime-As1It8o7.js} +10 -9
  31. package/dist/chunks/{generate.runtime-BFX_8erf.js.map → generate.runtime-As1It8o7.js.map} +1 -1
  32. package/dist/chunks/{generate.runtime-XT_JQlTk.js → generate.runtime-B5SP9iyN.js} +2 -2
  33. package/dist/chunks/{generate.runtime-XT_JQlTk.js.map → generate.runtime-B5SP9iyN.js.map} +1 -1
  34. package/dist/chunks/{generate.runtime-DiEiFoxR.js → generate.runtime-B8t8HtB6.js} +3 -3
  35. package/dist/chunks/{generate.runtime-DiEiFoxR.js.map → generate.runtime-B8t8HtB6.js.map} +1 -1
  36. package/dist/chunks/{generate.runtime-XpYi9SlM.js → generate.runtime-B9U3kzHD.js} +3 -3
  37. package/dist/chunks/{generate.runtime-XpYi9SlM.js.map → generate.runtime-B9U3kzHD.js.map} +1 -1
  38. package/dist/chunks/{generate.runtime-RTGpwxcS.js → generate.runtime-BDVPJJbh.js} +6 -12
  39. package/dist/chunks/generate.runtime-BDVPJJbh.js.map +1 -0
  40. package/dist/chunks/{generate.runtime-CBVcsole.js → generate.runtime-BGLekCHZ.js} +2 -2
  41. package/dist/chunks/{generate.runtime-CBVcsole.js.map → generate.runtime-BGLekCHZ.js.map} +1 -1
  42. package/dist/chunks/{generate.runtime-PDnSxiek.js → generate.runtime-BKA41qV0.js} +6 -6
  43. package/dist/chunks/{generate.runtime-PDnSxiek.js.map → generate.runtime-BKA41qV0.js.map} +1 -1
  44. package/dist/chunks/{generate.runtime-DhSH1o8H.js → generate.runtime-BKsrh3ZN.js} +3 -3
  45. package/dist/chunks/{generate.runtime-DhSH1o8H.js.map → generate.runtime-BKsrh3ZN.js.map} +1 -1
  46. package/dist/chunks/{generate.runtime-BXNBWGYr.js → generate.runtime-BL7O2fy8.js} +2 -2
  47. package/dist/chunks/{generate.runtime-BXNBWGYr.js.map → generate.runtime-BL7O2fy8.js.map} +1 -1
  48. package/dist/chunks/{generate.runtime-VMTLHWLk.js → generate.runtime-BOtYaNA5.js} +55 -60
  49. package/dist/chunks/generate.runtime-BOtYaNA5.js.map +1 -0
  50. package/dist/chunks/{generate.runtime-bsuqrKOm.js → generate.runtime-BY5VmBG4.js} +2 -2
  51. package/dist/chunks/{generate.runtime-bsuqrKOm.js.map → generate.runtime-BY5VmBG4.js.map} +1 -1
  52. package/dist/chunks/{generate.runtime-Dm7IEo2h.js → generate.runtime-BYhWm9JA.js} +5 -5
  53. package/dist/chunks/{generate.runtime-Dm7IEo2h.js.map → generate.runtime-BYhWm9JA.js.map} +1 -1
  54. package/dist/chunks/{generate.runtime-D9OC1RXu.js → generate.runtime-BmdO8oKV.js} +2 -2
  55. package/dist/chunks/{generate.runtime-D9OC1RXu.js.map → generate.runtime-BmdO8oKV.js.map} +1 -1
  56. package/dist/chunks/{generate.runtime-BROXlbeJ.js → generate.runtime-C7NexMXs.js} +3 -3
  57. package/dist/chunks/{generate.runtime-BROXlbeJ.js.map → generate.runtime-C7NexMXs.js.map} +1 -1
  58. package/dist/chunks/{generate.runtime-wiWdXXPi.js → generate.runtime-CFSBH8yG.js} +6 -6
  59. package/dist/chunks/{generate.runtime-wiWdXXPi.js.map → generate.runtime-CFSBH8yG.js.map} +1 -1
  60. package/dist/chunks/{generate.runtime-ZgLxGWuy.js → generate.runtime-CG3udLj8.js} +3 -3
  61. package/dist/chunks/{generate.runtime-ZgLxGWuy.js.map → generate.runtime-CG3udLj8.js.map} +1 -1
  62. package/dist/chunks/{generate.runtime-DuAYqKxl.js → generate.runtime-CGbSe_nd.js} +2 -2
  63. package/dist/chunks/{generate.runtime-DuAYqKxl.js.map → generate.runtime-CGbSe_nd.js.map} +1 -1
  64. package/dist/chunks/{generate.runtime-BU-4sjyu.js → generate.runtime-CI_rUVZo.js} +110 -113
  65. package/dist/chunks/generate.runtime-CI_rUVZo.js.map +1 -0
  66. package/dist/chunks/{generate.runtime-CCaCaXNu.js → generate.runtime-COo85dGX.js} +2 -2
  67. package/dist/chunks/{generate.runtime-CCaCaXNu.js.map → generate.runtime-COo85dGX.js.map} +1 -1
  68. package/dist/chunks/{generate.runtime-DLoYscQO.js → generate.runtime-CTQvLaU0.js} +3 -3
  69. package/dist/chunks/{generate.runtime-DLoYscQO.js.map → generate.runtime-CTQvLaU0.js.map} +1 -1
  70. package/dist/chunks/{generate.runtime-TQmspB4Z.js → generate.runtime-Cc5Aw1zc.js} +27 -34
  71. package/dist/chunks/generate.runtime-Cc5Aw1zc.js.map +1 -0
  72. package/dist/chunks/{generate.runtime-B7XOa9_A.js → generate.runtime-CnGVlvxN.js} +3 -3
  73. package/dist/chunks/{generate.runtime-B7XOa9_A.js.map → generate.runtime-CnGVlvxN.js.map} +1 -1
  74. package/dist/chunks/{generate.runtime-sjFAWbZc.js → generate.runtime-Cqbsn5Ov.js} +7 -7
  75. package/dist/chunks/{generate.runtime-sjFAWbZc.js.map → generate.runtime-Cqbsn5Ov.js.map} +1 -1
  76. package/dist/chunks/{generate.runtime-Cm75waRD.js → generate.runtime-CtV9Gn9T.js} +2 -2
  77. package/dist/chunks/{generate.runtime-Cm75waRD.js.map → generate.runtime-CtV9Gn9T.js.map} +1 -1
  78. package/dist/chunks/{generate.runtime-UtkANHk1.js → generate.runtime-Cxa24AOd.js} +3 -3
  79. package/dist/chunks/{generate.runtime-UtkANHk1.js.map → generate.runtime-Cxa24AOd.js.map} +1 -1
  80. package/dist/chunks/generate.runtime-CyteiEzT.js +169 -0
  81. package/dist/chunks/generate.runtime-CyteiEzT.js.map +1 -0
  82. package/dist/chunks/{generate.runtime-BlEy2fFF.js → generate.runtime-D7EETq9M.js} +3 -3
  83. package/dist/chunks/{generate.runtime-BlEy2fFF.js.map → generate.runtime-D7EETq9M.js.map} +1 -1
  84. package/dist/chunks/{generate.runtime-nXjFqHyb.js → generate.runtime-DaJ4gLPv.js} +4 -4
  85. package/dist/chunks/{generate.runtime-nXjFqHyb.js.map → generate.runtime-DaJ4gLPv.js.map} +1 -1
  86. package/dist/chunks/{generate.runtime-D6l6uLiY.js → generate.runtime-DcBEbV-k.js} +2 -2
  87. package/dist/chunks/{generate.runtime-D6l6uLiY.js.map → generate.runtime-DcBEbV-k.js.map} +1 -1
  88. package/dist/chunks/{generate.runtime-B8-ORwxT.js → generate.runtime-DiAnQ9MW.js} +6 -6
  89. package/dist/chunks/{generate.runtime-B8-ORwxT.js.map → generate.runtime-DiAnQ9MW.js.map} +1 -1
  90. package/dist/chunks/{generate.runtime-Duw_JI_b.js → generate.runtime-Dp3x08St.js} +2 -2
  91. package/dist/chunks/{generate.runtime-Duw_JI_b.js.map → generate.runtime-Dp3x08St.js.map} +1 -1
  92. package/dist/chunks/{generate.runtime-D77ueFKY.js → generate.runtime-DsW0Q5S5.js} +118 -134
  93. package/dist/chunks/generate.runtime-DsW0Q5S5.js.map +1 -0
  94. package/dist/chunks/{generate.runtime-27KTIg_o.js → generate.runtime-DtcKbzOm.js} +48 -53
  95. package/dist/chunks/generate.runtime-DtcKbzOm.js.map +1 -0
  96. package/dist/chunks/{generate.runtime-DxyQqNpu.js → generate.runtime-ICaKVEuW.js} +5 -11
  97. package/dist/chunks/generate.runtime-ICaKVEuW.js.map +1 -0
  98. package/dist/chunks/{generate.runtime-CuvdtjKc.js → generate.runtime-SZInujfP.js} +2 -2
  99. package/dist/chunks/{generate.runtime-CuvdtjKc.js.map → generate.runtime-SZInujfP.js.map} +1 -1
  100. package/dist/chunks/gitignore-CPardo4E.js +139 -0
  101. package/dist/chunks/gitignore-CPardo4E.js.map +1 -0
  102. package/dist/chunks/{i18n-mnzzcYhz.js → i18n-C8OfN_nr.js} +2 -2
  103. package/dist/chunks/{i18n-mnzzcYhz.js.map → i18n-C8OfN_nr.js.map} +1 -1
  104. package/dist/chunks/{modify-file-CgJIza72.js → modify-file-DvIwtj4o.js} +3 -3
  105. package/dist/chunks/{modify-file-CgJIza72.js.map → modify-file-DvIwtj4o.js.map} +1 -1
  106. package/dist/chunks/pocketbase-Ir-TPv7H.js +232 -0
  107. package/dist/chunks/pocketbase-Ir-TPv7H.js.map +1 -0
  108. package/dist/chunks/{providers-CDUFaOeQ.js → providers-B386TYCN.js} +3 -3
  109. package/dist/chunks/{providers-CDUFaOeQ.js.map → providers-B386TYCN.js.map} +1 -1
  110. package/dist/chunks/{providers-tjlFH5di.js → providers-DrK_hjSr.js} +2 -2
  111. package/dist/chunks/{providers-tjlFH5di.js.map → providers-DrK_hjSr.js.map} +1 -1
  112. package/dist/chunks/route-BJBV1DtX.js +162 -0
  113. package/dist/chunks/route-BJBV1DtX.js.map +1 -0
  114. package/dist/chunks/schema-DSNYWlel.js +116 -0
  115. package/dist/chunks/schema-DSNYWlel.js.map +1 -0
  116. package/dist/chunks/shared-BofFBVmT.js +1182 -0
  117. package/dist/chunks/shared-BofFBVmT.js.map +1 -0
  118. package/dist/chunks/{shared-BjTRQ5QH.js → shared-CZHopdly.js} +3 -3
  119. package/dist/chunks/{shared-BjTRQ5QH.js.map → shared-CZHopdly.js.map} +1 -1
  120. package/dist/chunks/{site-C8Wcg6LT.js → site-B9-emR6D.js} +3 -3
  121. package/dist/chunks/{site-C8Wcg6LT.js.map → site-B9-emR6D.js.map} +1 -1
  122. package/dist/chunks/{table-core-RvMjoXpT.js → table-core-CHsfbi-n.js} +3 -3
  123. package/dist/chunks/{table-core-RvMjoXpT.js.map → table-core-CHsfbi-n.js.map} +1 -1
  124. package/dist/chunks/test-setup-jqVMmL83.js +103 -0
  125. package/dist/chunks/test-setup-jqVMmL83.js.map +1 -0
  126. package/dist/chunks/{ui-CE-8llQS.js → ui-BUhkIHse.js} +3 -3
  127. package/dist/chunks/{ui-CE-8llQS.js.map → ui-BUhkIHse.js.map} +1 -1
  128. package/dist/chunks/{util-ILWdjRAd.js → util-mXrQ89nG.js} +8 -2
  129. package/dist/chunks/util-mXrQ89nG.js.map +1 -0
  130. package/dist/chunks/{whatsapp-DT10x76l.js → whatsapp-DFZUsKWe.js} +2 -2
  131. package/dist/chunks/{whatsapp-DT10x76l.js.map → whatsapp-DFZUsKWe.js.map} +1 -1
  132. package/dist/chunks/write-result-Bkdkp7u2.js +539 -0
  133. package/dist/chunks/write-result-Bkdkp7u2.js.map +1 -0
  134. package/dist/index.d.ts +81 -0
  135. package/dist/index.js +2387 -3275
  136. package/dist/index.js.map +1 -1
  137. package/package.json +3 -3
  138. package/dist/chunks/collections-B_-NTtLW.js.map +0 -1
  139. package/dist/chunks/constants-CTp-0HKk.js.map +0 -1
  140. package/dist/chunks/generate-JkvSNTy-.js.map +0 -1
  141. package/dist/chunks/generate.runtime-27KTIg_o.js.map +0 -1
  142. package/dist/chunks/generate.runtime-BU-4sjyu.js.map +0 -1
  143. package/dist/chunks/generate.runtime-D77ueFKY.js.map +0 -1
  144. package/dist/chunks/generate.runtime-Dn0_y2iV.js +0 -161
  145. package/dist/chunks/generate.runtime-Dn0_y2iV.js.map +0 -1
  146. package/dist/chunks/generate.runtime-DxyQqNpu.js.map +0 -1
  147. package/dist/chunks/generate.runtime-RTGpwxcS.js.map +0 -1
  148. package/dist/chunks/generate.runtime-TQmspB4Z.js.map +0 -1
  149. package/dist/chunks/generate.runtime-VMTLHWLk.js.map +0 -1
  150. package/dist/chunks/pocketbase-S8lUt0nI.js +0 -219
  151. package/dist/chunks/pocketbase-S8lUt0nI.js.map +0 -1
  152. package/dist/chunks/test-setup-CpjhQSl-.js +0 -176
  153. package/dist/chunks/test-setup-CpjhQSl-.js.map +0 -1
  154. package/dist/chunks/util-ILWdjRAd.js.map +0 -1
  155. package/dist/chunks/write-result-BguSfKV-.js +0 -499
  156. package/dist/chunks/write-result-BguSfKV-.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"generate-BJY8AtAp.js","names":["__import_glob__0_0_","__import_glob__0_1_","__import_glob__0_2_","spec","VELASTACK_KIT","VELASTACK_CMS","InvalidArgumentError","filesFromGlob","backendRaw","BACKEND_PREFIX","LOCAL_ENDPOINT","ENDPOINT_EXAMPLE","endpointFromArgv","i","argv","arg","resolveMode","endpoint","options","cmsLibSource","imports","i18n","where","mode","which","generate","creates","a","b"],"sources":["../../src/patterns/enable/cms/generate.ts"],"sourcesContent":["import type { File, Options, Result } from \"../../../core/types\";\nimport { VELASTACK_CMS, VELASTACK_KIT } from \"../../../core/constants\";\nimport { spec } from \"../../../core/versions\";\nimport { InvalidArgumentError } from \"../../../core/errors\";\nimport { filesFromGlob } from \"../../../core/util\";\n\n// The backend, for an app that hosts the CMS itself: the SQLite-backed HTTP\n// API and the two routes that mount it and serve uploads.\nconst backendRaw = import.meta.glob<string>(\"./creates-backend/**\", {\n query: \"?raw\",\n import: \"default\",\n eager: true,\n});\n\nconst BACKEND_PREFIX = \"./creates-backend/\";\n\n/** Where an app that hosts the backend itself mounts it. Also the admin bar's default. */\nexport const LOCAL_ENDPOINT = \"/api/cms\";\n\nexport const ENDPOINT_EXAMPLE =\n \"https://velastack.dev/v1/projects/<project>/cms\";\n\nexport interface CmsMode {\n /** What the read path and the admin bar talk to. */\n endpoint: string;\n /** Whether this app hosts the backend at `endpoint` itself. */\n local: boolean;\n}\n\n/** `--endpoint <url>` or `--endpoint=<url>`, for callers that hand flags through in argv. */\nfunction endpointFromArgv(argv: string[]): string | undefined {\n for (let i = 0; i < argv.length; i++) {\n const arg = argv[i];\n if (arg === \"--endpoint\") return argv[i + 1];\n if (arg.startsWith(\"--endpoint=\")) return arg.slice(\"--endpoint=\".length);\n }\n return undefined;\n}\n\n/**\n * Which of the two shapes to produce.\n *\n * An explicit `--endpoint` means a hosted CMS: the app only reads from it and\n * the admin bar signs in there, so no backend is installed. Without one, an\n * app with a server hosts the backend itself at `/api/cms`. A static site has\n * no server to host it, so there the endpoint is required.\n */\nexport function resolveMode(options: Options): CmsMode {\n const raw =\n typeof options.input.endpoint === \"string\"\n ? options.input.endpoint\n : endpointFromArgv(options.argv);\n const endpoint = raw?.trim().replace(/\\/+$/, \"\");\n\n if (endpoint) {\n if (!/^https?:\\/\\/\\S+$/.test(endpoint)) {\n throw new InvalidArgumentError(\n `--endpoint must be the absolute URL of a hosted CMS, like ${ENDPOINT_EXAMPLE}; got ${endpoint}`,\n );\n }\n return { endpoint, local: false };\n }\n\n // A PocketBase backend implies a Node server, but it is not the only way to\n // have one: a project on adapter-node alone can host the SQLite backend too.\n // The caller detects that and says so with `input.server`.\n if (!(options.input.server ?? options.features.backend)) {\n throw new InvalidArgumentError(\n \"This site has no server to host the CMS backend. \" +\n `Point it at a hosted CMS instead: vela enable cms --endpoint ${ENDPOINT_EXAMPLE}`,\n );\n }\n\n return { endpoint: LOCAL_ENDPOINT, local: true };\n}\n\n/** `src/lib/cms.ts`: the read path, with the endpoint and locales bound. */\nfunction cmsLibSource(mode: CmsMode, i18n: boolean): string {\n const imports = [\n \"import { apiAdapter, createCms } from '@velastack/cms/server';\",\n ];\n if (i18n) imports.push(\"import { locales } from '#locales/data.js';\");\n\n const where = mode.local\n ? [\n \" * `/api/cms` is where `src/routes/api/cms/[...path]/+server.ts` mounts the\",\n \" * backend. It is also the admin bar's default, so the endpoint is named here\",\n \" * and nowhere else.\",\n ]\n : [\n \" * The CMS is hosted at this endpoint: the app reads published content from\",\n \" * it and the admin bar signs in there. The same URL is given to the `cms()`\",\n \" * plugin in vite.config.ts, which downloads media into the build.\",\n ];\n\n const which = i18n\n ? [\n \" * The locales are the site's own, from wuchale, so the CMS supports exactly\",\n \" * the languages the UI does; the first is the default that a missing\",\n \" * translation falls back to.\",\n ]\n : [\n \" * `locales` lists every locale the site supports; the first is the default\",\n \" * that a missing translation falls back to.\",\n ];\n\n return [\n ...imports,\n \"\",\n \"/**\",\n \" * The CMS read path, called from the root `+layout.server.ts`.\",\n \" *\",\n ...where,\n \" *\",\n ...which,\n \" */\",\n \"export const { load: loadCms, generateEntries } = createCms({\",\n `\\tadapter: apiAdapter({ endpoint: '${mode.endpoint}' }),`,\n `\\tlocales: ${i18n ? \"[...locales]\" : \"['en']\"}`,\n \"});\",\n \"\",\n ].join(\"\\n\");\n}\n\nexport async function generate(options: Options) {\n const mode = resolveMode(options);\n const creates: Record<string, File> = {};\n\n if (mode.local) {\n Object.assign(creates, filesFromGlob(backendRaw, BACKEND_PREFIX));\n }\n\n creates[\"src/lib/cms.ts\"] = {\n path: \"src/lib/cms.ts\",\n language: \"ts\",\n content: cmsLibSource(mode, options.features.i18n),\n status: \"success\",\n };\n\n const sortedCreates = Object.values(creates).sort((a, b) =>\n a.path.localeCompare(b.path),\n );\n\n // better-sqlite3 and marked are the package's optional peers, which npm\n // skips on install precisely because they are optional — so they have to be\n // named here. The backend needs the first; the root entry imports the\n // second statically, so <AdminBar /> cannot render without it.\n // @velastack/cms 0.6 is the SvelteKit 3 line; 0.5 and older peer on Kit 2.\n // The backend's cms.ts resolves its database with `dataPath` from\n // @velastack/kit, which a backend template has and a project on adapter-node\n // alone does not.\n const packages = mode.local\n ? [VELASTACK_CMS, VELASTACK_KIT, \"better-sqlite3\", spec(\"marked\")]\n : [VELASTACK_CMS, spec(\"marked\")];\n\n return {\n creates: sortedCreates,\n modifies: [],\n deletes: [],\n components: [],\n packages,\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;AAQA,I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CAAC,CAAC,KAAK,IAAI;AACb;AAEA,eAAsBI,EAAS,GAAkB;CAC/C,IAAMF,IAAOP,EAAYE,CAAO,GAC1BQ,IAAgC,CAAC;CA6BvC,OA3BIH,EAAK,SACP,OAAO,OAAOG,GAASnB,EAAcC,GAAYC,CAAc,CAAC,GAGlE,EAAQ,oBAAoB;EAC1B,MAAM;EACN,UAAU;EACV,SAASU,EAAaI,GAAML,EAAQ,SAAS,IAAI;EACjD,QAAQ;CACV,GAkBO;EACL,SAjBoB,OAAO,OAAOQ,CAAO,CAAC,CAAC,MAAM,GAAG,MACpDC,EAAE,KAAK,cAAcC,EAAE,IAAI,CAgBlB;EACT,UAAU,CAAC;EACX,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UATeL,EAAK,QAClB;GAAClB;GAAeD;GAAe;GAAkBD,EAAK,QAAQ;EAAC,IAC/D,CAACE,GAAeF,EAAK,QAAQ,CAAC;EAQhC,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
1
+ {"version":3,"file":"generate-a3U8uDzW.js","names":["__import_glob__0_0_","__import_glob__0_1_","__import_glob__0_2_","spec","VELASTACK_CMS","VELASTACK_KIT","InvalidArgumentError","filesFromGlob","backendRaw","BACKEND_PREFIX","LOCAL_ENDPOINT","ENDPOINT_EXAMPLE","endpointFromArgv","i","argv","arg","resolveMode","endpoint","options","cmsLibSource","imports","i18n","where","mode","which","generate","creates","a","b"],"sources":["../../src/patterns/enable/cms/generate.ts"],"sourcesContent":["import type { File, Options, Result } from \"../../../core/types\";\nimport { VELASTACK_CMS, VELASTACK_KIT } from \"../../../core/constants\";\nimport { spec } from \"../../../core/versions\";\nimport { InvalidArgumentError } from \"../../../core/errors\";\nimport { filesFromGlob } from \"../../../core/util\";\n\n// The backend, for an app that hosts the CMS itself: the SQLite-backed HTTP\n// API and the two routes that mount it and serve uploads.\nconst backendRaw = import.meta.glob<string>(\"./creates-backend/**\", {\n query: \"?raw\",\n import: \"default\",\n eager: true,\n});\n\nconst BACKEND_PREFIX = \"./creates-backend/\";\n\n/** Where an app that hosts the backend itself mounts it. Also the admin bar's default. */\nexport const LOCAL_ENDPOINT = \"/api/cms\";\n\nexport const ENDPOINT_EXAMPLE =\n \"https://velastack.dev/v1/projects/<project>/cms\";\n\nexport interface CmsMode {\n /** What the read path and the admin bar talk to. */\n endpoint: string;\n /** Whether this app hosts the backend at `endpoint` itself. */\n local: boolean;\n}\n\n/** `--endpoint <url>` or `--endpoint=<url>`, for callers that hand flags through in argv. */\nfunction endpointFromArgv(argv: string[]): string | undefined {\n for (let i = 0; i < argv.length; i++) {\n const arg = argv[i];\n if (arg === \"--endpoint\") return argv[i + 1];\n if (arg.startsWith(\"--endpoint=\")) return arg.slice(\"--endpoint=\".length);\n }\n return undefined;\n}\n\n/**\n * Which of the two shapes to produce.\n *\n * An explicit `--endpoint` means a hosted CMS: the app only reads from it and\n * the admin bar signs in there, so no backend is installed. Without one, an\n * app with a server hosts the backend itself at `/api/cms`. A static site has\n * no server to host it, so there the endpoint is required.\n */\nexport function resolveMode(options: Options): CmsMode {\n const raw =\n typeof options.input.endpoint === \"string\"\n ? options.input.endpoint\n : endpointFromArgv(options.argv);\n const endpoint = raw?.trim().replace(/\\/+$/, \"\");\n\n if (endpoint) {\n if (!/^https?:\\/\\/\\S+$/.test(endpoint)) {\n throw new InvalidArgumentError(\n `--endpoint must be the absolute URL of a hosted CMS, like ${ENDPOINT_EXAMPLE}; got ${endpoint}`,\n );\n }\n return { endpoint, local: false };\n }\n\n // A PocketBase backend implies a Node server, but it is not the only way to\n // have one: a project on adapter-node alone can host the SQLite backend too.\n // The caller detects that and says so with `input.server`.\n if (!(options.input.server ?? options.features.backend)) {\n throw new InvalidArgumentError(\n \"This site has no server to host the CMS backend. \" +\n `Point it at a hosted CMS instead: vela enable cms --endpoint ${ENDPOINT_EXAMPLE}`,\n );\n }\n\n return { endpoint: LOCAL_ENDPOINT, local: true };\n}\n\n/** `src/lib/cms.ts`: the read path, with the endpoint and locales bound. */\nfunction cmsLibSource(mode: CmsMode, i18n: boolean): string {\n const imports = [\n \"import { apiAdapter, createCms } from '@velastack/cms/server';\",\n ];\n if (i18n) imports.push(\"import { locales } from '#locales/data.js';\");\n\n const where = mode.local\n ? [\n \" * `/api/cms` is where `src/routes/api/cms/[...path]/+server.ts` mounts the\",\n \" * backend. It is also the admin bar's default, so the endpoint is named here\",\n \" * and nowhere else.\",\n ]\n : [\n \" * The CMS is hosted at this endpoint: the app reads published content from\",\n \" * it and the admin bar signs in there. The same URL is given to the `cms()`\",\n \" * plugin in vite.config.ts, which downloads media into the build.\",\n ];\n\n const which = i18n\n ? [\n \" * The locales are the site's own, from wuchale, so the CMS supports exactly\",\n \" * the languages the UI does; the first is the default that a missing\",\n \" * translation falls back to.\",\n ]\n : [\n \" * `locales` lists every locale the site supports; the first is the default\",\n \" * that a missing translation falls back to.\",\n ];\n\n return [\n ...imports,\n \"\",\n \"/**\",\n \" * The CMS read path, called from the root `+layout.server.ts`.\",\n \" *\",\n ...where,\n \" *\",\n ...which,\n \" */\",\n \"export const { load: loadCms, generateEntries } = createCms({\",\n `\\tadapter: apiAdapter({ endpoint: '${mode.endpoint}' }),`,\n `\\tlocales: ${i18n ? \"[...locales]\" : \"['en']\"}`,\n \"});\",\n \"\",\n ].join(\"\\n\");\n}\n\nexport async function generate(options: Options) {\n const mode = resolveMode(options);\n const creates: Record<string, File> = {};\n\n if (mode.local) {\n Object.assign(creates, filesFromGlob(backendRaw, BACKEND_PREFIX));\n }\n\n creates[\"src/lib/cms.ts\"] = {\n path: \"src/lib/cms.ts\",\n language: \"ts\",\n content: cmsLibSource(mode, options.features.i18n),\n status: \"success\",\n };\n\n const sortedCreates = Object.values(creates).sort((a, b) =>\n a.path.localeCompare(b.path),\n );\n\n // better-sqlite3 and marked are the package's optional peers, which npm\n // skips on install precisely because they are optional — so they have to be\n // named here. The backend needs the first; the root entry imports the\n // second statically, so <AdminBar /> cannot render without it.\n // @velastack/cms 0.6 is the SvelteKit 3 line; 0.5 and older peer on Kit 2.\n // The backend's cms.ts resolves its database with `dataPath` from\n // @velastack/kit, which a backend template has and a project on adapter-node\n // alone does not.\n const packages = mode.local\n ? [VELASTACK_CMS, VELASTACK_KIT, \"better-sqlite3\", spec(\"marked\")]\n : [VELASTACK_CMS, spec(\"marked\")];\n\n return {\n creates: sortedCreates,\n modifies: [],\n deletes: [],\n components: [],\n packages,\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;AAQA,IAAMQ,IAAa,uBAAA,OAAA;CAAA,2CAAAR;CAAA,6DAAAC;CAAA,8DAAAC;AAIlB,CAAA,GAEKO,IAAiB,sBAGVC,IAAiB,YAEjBC,IACX;AAUF,SAASC,EAAiB,GAAoC;CAC5D,KAAK,IAAIC,IAAI,GAAGA,IAAIC,EAAK,QAAQ,KAAK;EACpC,IAAMC,IAAMD,EAAKD;EACjB,IAAIE,MAAQ,cAAc,OAAOD,EAAKD,IAAI;EAC1C,IAAIE,EAAI,WAAW,aAAa,GAAG,OAAOA,EAAI,MAAM,EAAoB;CAC1E;AAEF;AAUA,SAAgBC,EAAY,GAA2B;CAKrD,IAAMC,KAHJ,OAAOC,EAAQ,MAAM,YAAa,WAC9BA,EAAQ,MAAM,WACdN,EAAiBM,EAAQ,IAAI,EAAA,EACb,KAAK,CAAC,CAAC,QAAQ,QAAQ,EAAE;CAE/C,IAAID,GAAU;EACZ,IAAI,CAAC,mBAAmB,KAAKA,CAAQ,GACnC,MAAM,IAAIX,EACR,6DAA6DK,EAAiB,QAAQM,GACxF;EAEF,OAAO;GAAE;GAAU,OAAO;EAAM;CAClC;CAKA,IAAI,EAAEC,EAAQ,MAAM,UAAUA,EAAQ,SAAS,UAC7C,MAAM,IAAIZ,EACR,iHACkEK,GACpE;CAGF,OAAO;EAAE,UAAUD;EAAgB,OAAO;CAAK;AACjD;AAGA,SAASS,EAAa,GAAe,GAAuB;CAC1D,IAAMC,IAAU,CACd,gEACF;CACA,AAAIC,KAAMD,EAAQ,KAAK,6CAA6C;CAEpE,IAAME,IAAQC,EAAK,QACf;EACE;EACA;EACA;CACF,IACA;EACE;EACA;EACA;CACF,GAEEC,IAAQH,IACV;EACE;EACA;EACA;CACF,IACA,CACE,+EACA,8CACF;CAEJ,OAAO;EACL,GAAGD;EACH;EACA;EACA;EACA;EACA,GAAGE;EACH;EACA,GAAGE;EACH;EACA;EACA,sCAAsCD,EAAK,SAAS;EACpD,cAAcF,IAAO,iBAAiB;EACtC;EACA;CACF,CAAC,CAAC,KAAK,IAAI;AACb;AAEA,eAAsBI,EAAS,GAAkB;CAC/C,IAAMF,IAAOP,EAAYE,CAAO,GAC1BQ,IAAgC,CAAC;CA6BvC,OA3BIH,EAAK,SACP,OAAO,OAAOG,GAASnB,EAAcC,GAAYC,CAAc,CAAC,GAGlE,EAAQ,oBAAoB;EAC1B,MAAM;EACN,UAAU;EACV,SAASU,EAAaI,GAAML,EAAQ,SAAS,IAAI;EACjD,QAAQ;CACV,GAkBO;EACL,SAjBoB,OAAO,OAAOQ,CAAO,CAAC,CAAC,MAAM,GAAG,MACpDC,EAAE,KAAK,cAAcC,EAAE,IAAI,CAgBlB;EACT,UAAU,CAAC;EACX,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UATeL,EAAK,QAClB;GAACnB;GAAeC;GAAe;GAAkBF,EAAK,QAAQ;EAAC,IAC/D,CAACC,GAAeD,EAAK,QAAQ,CAAC;EAQhC,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
@@ -1,167 +1,10 @@
1
- import { E as e, x as t } from "./constants-CTp-0HKk.js";
1
+ import { k as e, w as t } from "./constants-BHuzzsKu.js";
2
2
  import { t as n } from "./ui-D5xgIDR_.js";
3
- import { c as r, i, r as a } from "./providers-tjlFH5di.js";
4
- import { n as o, r as s } from "./util-ILWdjRAd.js";
5
- import { t as c } from "./errors-DdSUZI8f.js";
6
- // node_modules/change-case/dist/index.js
7
- var l = /([\p{Ll}\d])(\p{Lu})/gu, u = /(\p{Lu})([\p{Lu}][\p{Ll}])/gu, d = /(\d)\p{Ll}|(\p{L})\d/u, f = /[^\p{L}\d]+/giu, p = "$1\0$2", m = "";
8
- function h(e) {
9
- let t = e.trim();
10
- t = t.replace(l, p).replace(u, p), t = t.replace(f, "\0");
11
- let n = 0, r = t.length;
12
- for (; t.charAt(n) === "\0";) n++;
13
- if (n === r) return [];
14
- for (; t.charAt(r - 1) === "\0";) r--;
15
- return t.slice(n, r).split(/\0/g);
16
- }
17
- function g(e) {
18
- let t = h(e);
19
- for (let e = 0; e < t.length; e++) {
20
- let n = t[e], r = d.exec(n);
21
- if (r) {
22
- let i = r.index + (r[1] ?? r[2]).length;
23
- t.splice(e, 1, n.slice(0, i), n.slice(i));
24
- }
25
- }
26
- return t;
27
- }
28
- function _(e, t) {
29
- let [n, r, i] = E(e, t);
30
- return n + r.map(S(t?.locale)).join(t?.delimiter ?? " ") + i;
31
- }
32
- function v(e, t) {
33
- let [n, r, i] = E(e, t), a = S(t?.locale), o = C(t?.locale), s = t?.mergeAmbiguousCharacters ? w(a, o) : T(a, o);
34
- return n + r.map((e, t) => t === 0 ? a(e) : s(e, t)).join(t?.delimiter ?? "") + i;
35
- }
36
- function y(e, t) {
37
- let [n, r, i] = E(e, t), a = S(t?.locale), o = C(t?.locale), s = t?.mergeAmbiguousCharacters ? w(a, o) : T(a, o);
38
- return n + r.map(s).join(t?.delimiter ?? "") + i;
39
- }
40
- function b(e, t) {
41
- let [n, r, i] = E(e, t), a = S(t?.locale), o = C(t?.locale);
42
- return n + r.map(w(a, o)).join(t?.delimiter ?? " ") + i;
43
- }
44
- function x(e, t) {
45
- return _(e, {
46
- delimiter: "-",
47
- ...t
48
- });
49
- }
50
- function ee(e, t) {
51
- return _(e, {
52
- delimiter: "_",
53
- ...t
54
- });
55
- }
56
- function S(e) {
57
- return e === !1 ? (e) => e.toLowerCase() : (t) => t.toLocaleLowerCase(e);
58
- }
59
- function C(e) {
60
- return e === !1 ? (e) => e.toUpperCase() : (t) => t.toLocaleUpperCase(e);
61
- }
62
- function w(e, t) {
63
- return (n) => `${t(n[0])}${e(n.slice(1))}`;
64
- }
65
- function T(e, t) {
66
- return (n, r) => {
67
- let i = n[0];
68
- return (r > 0 && i >= "0" && i <= "9" ? "_" + i : t(i)) + e(n.slice(1));
69
- };
70
- }
71
- function E(e, t = {}) {
72
- let n = t.split ?? (t.separateNumbers ? g : h), r = t.prefixCharacters ?? m, i = t.suffixCharacters ?? m, a = 0, o = e.length;
73
- for (; a < e.length;) {
74
- let t = e.charAt(a);
75
- if (!r.includes(t)) break;
76
- a++;
77
- }
78
- for (; o > a;) {
79
- let t = o - 1, n = e.charAt(t);
80
- if (!i.includes(n)) break;
81
- o = t;
82
- }
83
- return [
84
- e.slice(0, a),
85
- n(e.slice(a, o)),
86
- e.slice(o)
87
- ];
88
- }
89
- // src/parse/route.ts
90
- var D = "src/routes", O = /\[([^\]]+)\]/g, k = /^[a-zA-Z0-9_\-[\]()]+$/;
91
- function A({ features: e, routeGroups: t }) {
92
- let n = t ?? {
93
- public: "(public)",
94
- app: "(app)"
95
- };
96
- return e.auth ? n.app ?? n.public : n.public;
97
- }
98
- function j(e, t) {
99
- return [
100
- D,
101
- e,
102
- t
103
- ].filter(Boolean).join("/");
104
- }
105
- function M(e, t) {
106
- return x(t === "scaffold" ? e.pluralDisplayName : e.displayName);
107
- }
108
- function N(e) {
109
- return `/${(e.startsWith(`${D}/`) ? e.slice(11) : e).split("/").filter((e) => !(e.startsWith("(") && e.endsWith(")"))).join("/")}`;
110
- }
111
- function P(e) {
112
- let t = [];
113
- for (let n of e.matchAll(O)) t.push(n[1]);
114
- return t;
115
- }
116
- function F(e) {
117
- if (e.startsWith("/")) throw new c(`Route must not start with "/". Got: "${e}"`);
118
- if (e.startsWith(`${D}/`) || e === D) throw new c(`Route must not start with "${D}/" — paths are rooted there automatically. Got: "${e}"`);
119
- let t = e.split("/");
120
- for (let n of t) {
121
- if (n.length === 0) throw new c(`Route must not contain empty segments. Got: "${e}"`);
122
- if (n === "." || n === "..") throw new c(`Route must not contain "." or ".." segments. Got: "${e}"`);
123
- if (n.startsWith("_")) throw new c(`Route segments must not start with underscore. Got: "${n}"`);
124
- if (!k.test(n)) throw new c(`Route segment "${n}" contains invalid characters. Allowed: letters, digits, underscore, dash, brackets, parentheses.`);
125
- }
126
- }
127
- function I(e) {
128
- return e.split("/").some((e) => e.startsWith("(") && e.endsWith(")"));
129
- }
130
- function L(e, t, n, r) {
131
- if (e === void 0 || e === "") {
132
- let e = M(t, r), i = j(A(n), e);
133
- return {
134
- fileBase: i,
135
- urlBase: N(i),
136
- dynamicParams: P(i)
137
- };
138
- }
139
- F(e);
140
- let i = j(I(e) ? null : A(n), e);
141
- return {
142
- fileBase: i,
143
- urlBase: N(i),
144
- dynamicParams: P(i)
145
- };
146
- }
147
- function R(e) {
148
- return {
149
- list: e.fileBase,
150
- new: `${e.fileBase}/new`,
151
- show: `${e.fileBase}/[id]`,
152
- edit: `${e.fileBase}/[id]/edit`
153
- };
154
- }
155
- function z(e) {
156
- return {
157
- list: e.urlBase,
158
- new: `${e.urlBase}/new`,
159
- show: `${e.urlBase}/[id]`,
160
- edit: `${e.urlBase}/[id]/edit`
161
- };
162
- }
3
+ import { c as r, i, r as a } from "./providers-DrK_hjSr.js";
4
+ import { n as o, r as s } from "./util-mXrQ89nG.js";
5
+ import { t as c } from "./route-BJBV1DtX.js";
163
6
  // src/patterns/enable/ai/creates/src/routes/(public)/ai/+page.svelte?raw
164
- var B = "<script lang=\"ts\">\n import { Chat } from '@ai-sdk/svelte';\n import { Button } from '#lib/components/ui/button/index.js';\n import { Textarea } from '#lib/components/ui/textarea/index.js';\n\n // Posts to /api/chat (src/routes/api/chat/+server.ts) and streams the reply\n // into `chat.messages`. This page is a demo, and it is yours to delete.\n const chat = new Chat({});\n\n let input = $state('');\n const busy = $derived(chat.status === 'submitted' || chat.status === 'streaming');\n\n function send(event: SubmitEvent) {\n event.preventDefault();\n const text = input.trim();\n if (!text || busy) return;\n chat.sendMessage({ text });\n input = '';\n }\n\n // Enter sends; Shift+Enter starts a new line.\n function onkeydown(event: KeyboardEvent & { currentTarget: HTMLTextAreaElement }) {\n if (event.key === 'Enter' && !event.shiftKey && !event.isComposing) {\n event.preventDefault();\n event.currentTarget.form?.requestSubmit();\n }\n }\n<\/script>\n\n<div class=\"mx-auto flex w-full max-w-3xl flex-1 flex-col gap-6 px-4 py-10\">\n <div>\n <h1 class=\"text-2xl font-semibold\">AI chat</h1>\n <p class=\"text-muted-foreground text-sm\">\n Replies stream from <code>src/routes/api/chat/+server.ts</code>. Pick the model in\n <code>src/lib/server/ai.ts</code>.\n </p>\n </div>\n\n <div class=\"flex flex-1 flex-col gap-4\" aria-live=\"polite\">\n {#each chat.messages as message (message.id)}\n <div\n class={message.role === 'user'\n ? 'bg-primary text-primary-foreground ml-auto max-w-[80%] rounded-lg px-4 py-2'\n : 'max-w-[80%]'}\n >\n {#each message.parts as part, index (index)}\n {#if part.type === 'text'}\n <p class=\"whitespace-pre-wrap\">{part.text}</p>\n {/if}\n {/each}\n </div>\n {:else}\n <p class=\"text-muted-foreground\">Ask anything to start the conversation.</p>\n {/each}\n\n {#if chat.status === 'submitted'}\n <p class=\"text-muted-foreground text-sm\">Thinking…</p>\n {/if}\n\n {#if chat.error}\n <div\n role=\"alert\"\n class=\"border-destructive text-destructive flex items-center justify-between gap-4 rounded-md border px-4 py-2 text-sm\"\n >\n <span>{chat.error.message}</span>\n <Button variant=\"outline\" size=\"sm\" onclick={() => chat.regenerate()}>Retry</Button>\n </div>\n {/if}\n </div>\n\n <form onsubmit={send} class=\"bg-background sticky bottom-0 flex items-end gap-2 py-2\">\n <Textarea\n bind:value={input}\n {onkeydown}\n rows={1}\n placeholder=\"Send a message\"\n aria-label=\"Message\"\n class=\"max-h-40 min-h-10 resize-none\"\n />\n {#if busy}\n <Button type=\"button\" variant=\"outline\" onclick={() => chat.stop()}>Stop</Button>\n {:else}\n <Button type=\"submit\" disabled={!input.trim()}>Send</Button>\n {/if}\n </form>\n</div>\n", V = "import { dev } from '$app/env';\nimport {\n convertToModelMessages,\n createUIMessageStreamResponse,\n safeValidateUIMessages,\n streamText,\n toUIMessageStream\n} from 'ai';\nimport { API_KEY, languageModel } from '#lib/server/ai.js';\nimport type { RequestHandler } from './$types';\n\n// Sent ahead of every conversation: give the assistant its role here.\nconst INSTRUCTIONS = 'You are a helpful assistant. Keep answers short unless asked for detail.';\n\n/**\n * Where `new Chat()` from @ai-sdk/svelte posts by default: the conversation so\n * far comes in, the model's reply streams back. Anyone who can reach the site\n * can call it, and every reply is billed to your API key, so put it behind\n * sign-in or a rate limit before you deploy.\n *\n * Errors are plain text, which `Chat` shows as `chat.error.message`.\n */\nexport const POST: RequestHandler = async ({ request }) => {\n const body = await request.json().catch(() => null);\n const messages = await safeValidateUIMessages({ messages: body?.messages });\n if (!messages.success) {\n return new Response('Expected a JSON body with a messages array.', { status: 400 });\n }\n\n const model = languageModel();\n if (!model) {\n return new Response(`Set ${API_KEY} in .env to start chatting.`, { status: 503 });\n }\n\n const result = streamText({\n model,\n instructions: INSTRUCTIONS,\n messages: await convertToModelMessages(messages.data)\n });\n\n return createUIMessageStreamResponse({\n stream: toUIMessageStream({\n stream: result.stream,\n // Provider errors (a bad key, an unknown model id) reach the chat in\n // dev only; in production they stay in the server log.\n onError: (error) =>\n dev && error instanceof Error ? error.message : 'The model could not answer.'\n })\n });\n};\n", H = "import { describe, it, expect } from 'vitest';\nimport type { Match } from '@velastack/kit';\nimport type { RouteId } from './$types';\n\n// None of these requests reach the model, so they pass without an API key and\n// cost nothing.\ndescribe('POST /api/chat', () => {\n it('should return 400 if the body is not JSON', async (context) => {\n const response = await context.request\n .post('/api/chat' satisfies Match<RouteId>)\n .set('Content-Type', 'application/json')\n .send('not json');\n\n expect(response.status).toBe(400);\n });\n\n it('should return 400 if messages are missing', async (context) => {\n const response = await context.request.post('/api/chat' satisfies Match<RouteId>).send({});\n\n expect(response.status).toBe(400);\n });\n\n it('should return 400 if messages are malformed', async (context) => {\n const response = await context.request\n .post('/api/chat' satisfies Match<RouteId>)\n .send({ messages: [{ role: 'user', content: 'Hello' }] });\n\n expect(response.status).toBe(400);\n });\n});\n", U = "import { dev } from '$app/env';\nimport {\n convertToModelMessages,\n createUIMessageStreamResponse,\n safeValidateUIMessages,\n streamText,\n toUIMessageStream\n} from 'ai';\nimport { API_KEY, languageModel } from '#lib/server/ai.js';\nimport type { RequestHandler } from './$types';\n\n// Sent ahead of every conversation: give the assistant its role here.\nconst INSTRUCTIONS = 'You are a helpful assistant. Keep answers short unless asked for detail.';\n\n/**\n * Where `new Chat()` from @ai-sdk/svelte posts by default: the conversation so\n * far comes in, the model's reply streams back. Every reply is billed to your\n * API key, so only signed-in users get one.\n *\n * Errors are plain text, which `Chat` shows as `chat.error.message`.\n */\nexport const POST: RequestHandler = async ({ request, locals }) => {\n if (!locals.pb.authStore.isValid) {\n return new Response('Sign in to chat.', { status: 401 });\n }\n\n const body = await request.json().catch(() => null);\n const messages = await safeValidateUIMessages({ messages: body?.messages });\n if (!messages.success) {\n return new Response('Expected a JSON body with a messages array.', { status: 400 });\n }\n\n const model = languageModel();\n if (!model) {\n return new Response(`Set ${API_KEY} in .env to start chatting.`, { status: 503 });\n }\n\n const result = streamText({\n model,\n instructions: INSTRUCTIONS,\n messages: await convertToModelMessages(messages.data)\n });\n\n return createUIMessageStreamResponse({\n stream: toUIMessageStream({\n stream: result.stream,\n // Provider errors (a bad key, an unknown model id) reach the chat in\n // dev only; in production they stay in the server log.\n onError: (error) =>\n dev && error instanceof Error ? error.message : 'The model could not answer.'\n })\n });\n};\n", W = "import { describe, it, expect } from 'vitest';\nimport type { Match } from '@velastack/kit';\nimport type { RouteId } from './$types';\n\n// None of these requests reach the model, so they pass without an API key and\n// cost nothing.\ndescribe('POST /api/chat', () => {\n it('should return 401 when signed out', async (context) => {\n const response = await context.request.post('/api/chat' satisfies Match<RouteId>).send({\n messages: [{ id: '1', role: 'user', parts: [{ type: 'text', text: 'Hello' }] }]\n });\n\n expect(response.status).toBe(401);\n });\n\n it('should return 400 if the body is not JSON', async (context) => {\n await context.agent.authenticateUser();\n\n const response = await context.agent\n .post('/api/chat' satisfies Match<RouteId>)\n .set('Content-Type', 'application/json')\n .send('not json');\n\n expect(response.status).toBe(400);\n });\n\n it('should return 400 if messages are missing', async (context) => {\n await context.agent.authenticateUser();\n\n const response = await context.agent.post('/api/chat' satisfies Match<RouteId>).send({});\n\n expect(response.status).toBe(400);\n });\n\n it('should return 400 if messages are malformed', async (context) => {\n await context.agent.authenticateUser();\n\n const response = await context.agent\n .post('/api/chat' satisfies Match<RouteId>)\n .send({ messages: [{ role: 'user', content: 'Hello' }] });\n\n expect(response.status).toBe(400);\n });\n});\n", G = "<script lang=\"ts\">\n import { Chat } from '@ai-sdk/svelte';\n\n // Posts to /api/chat (src/routes/api/chat/+server.ts) and streams the reply\n // into `chat.messages`. This page is a demo, and it is yours to delete.\n const chat = new Chat({});\n\n let input = $state('');\n const busy = $derived(chat.status === 'submitted' || chat.status === 'streaming');\n\n function send(event: SubmitEvent) {\n event.preventDefault();\n const text = input.trim();\n if (!text || busy) return;\n chat.sendMessage({ text });\n input = '';\n }\n\n // Enter sends; Shift+Enter starts a new line.\n function onkeydown(event: KeyboardEvent & { currentTarget: HTMLTextAreaElement }) {\n if (event.key === 'Enter' && !event.shiftKey && !event.isComposing) {\n event.preventDefault();\n event.currentTarget.form?.requestSubmit();\n }\n }\n<\/script>\n\n<h1>AI chat</h1>\n<p>\n Replies stream from <code>src/routes/api/chat/+server.ts</code>. Pick the model in\n <code>src/lib/server/ai.ts</code>.\n</p>\n\n<section aria-live=\"polite\">\n {#each chat.messages as message (message.id)}\n <article data-role={message.role}>\n <strong>{message.role === 'user' ? 'You' : 'Assistant'}</strong>\n {#each message.parts as part, index (index)}\n {#if part.type === 'text'}\n <p style=\"white-space: pre-wrap\">{part.text}</p>\n {/if}\n {/each}\n </article>\n {:else}\n <p>Ask anything to start the conversation.</p>\n {/each}\n\n {#if chat.status === 'submitted'}\n <p>Thinking…</p>\n {/if}\n\n {#if chat.error}\n <p role=\"alert\">\n {chat.error.message}\n <button type=\"button\" onclick={() => chat.regenerate()}>Retry</button>\n </p>\n {/if}\n</section>\n\n<form onsubmit={send}>\n <textarea bind:value={input} {onkeydown} rows=\"2\" placeholder=\"Send a message\" aria-label=\"Message\"\n ></textarea>\n {#if busy}\n <button type=\"button\" onclick={() => chat.stop()}>Stop</button>\n {:else}\n <button type=\"submit\" disabled={!input.trim()}>Send</button>\n {/if}\n</form>\n", K = "import { createAnthropic } from '@ai-sdk/anthropic';\nimport { ANTHROPIC_API_KEY } from '$app/env/private';\n\n/** The `.env` key holding the Anthropic API key, named in the endpoint's 503. */\nexport const API_KEY = 'ANTHROPIC_API_KEY';\n\n/**\n * The model the AI routes talk to, or `undefined` while ANTHROPIC_API_KEY is\n * blank. The key is read when the server starts, so a new value in `.env`\n * takes a restart, not a code change. Any id from\n * https://docs.claude.com/en/docs/about-claude/models works in place of this\n * one.\n */\nexport function languageModel() {\n const apiKey = ANTHROPIC_API_KEY;\n return apiKey ? createAnthropic({ apiKey })('claude-sonnet-5') : undefined;\n}\n", q = "import { createGateway } from 'ai';\nimport { AI_GATEWAY_API_KEY } from '$app/env/private';\n\n/** The `.env` key holding the Vercel AI Gateway API key, named in the endpoint's 503. */\nexport const API_KEY = 'AI_GATEWAY_API_KEY';\n\n/**\n * The model the AI routes talk to, or `undefined` while AI_GATEWAY_API_KEY is\n * blank. The key is read when the server starts, so a new value in `.env`\n * takes a restart, not a code change. The gateway routes `creator/model` ids\n * to their provider; any id from https://vercel.com/ai-gateway/models works in\n * place of this one.\n */\nexport function languageModel() {\n const apiKey = AI_GATEWAY_API_KEY;\n return apiKey ? createGateway({ apiKey })('anthropic/claude-sonnet-5') : undefined;\n}\n", J = "import { createOpenAI } from '@ai-sdk/openai';\nimport { OPENAI_API_KEY } from '$app/env/private';\n\n/** The `.env` key holding the OpenAI API key, named in the endpoint's 503. */\nexport const API_KEY = 'OPENAI_API_KEY';\n\n/**\n * The model the AI routes talk to, or `undefined` while OPENAI_API_KEY is\n * blank. The key is read when the server starts, so a new value in `.env`\n * takes a restart, not a code change. Any id from\n * https://platform.openai.com/docs/models works in place of this one.\n */\nexport function languageModel() {\n const apiKey = OPENAI_API_KEY;\n return apiKey ? createOpenAI({ apiKey })('gpt-5.5') : undefined;\n}\n", Y = [
7
+ var l = "<script lang=\"ts\">\n import { Chat } from '@ai-sdk/svelte';\n import { Button } from '#lib/components/ui/button/index.js';\n import { Textarea } from '#lib/components/ui/textarea/index.js';\n\n // Posts to /api/chat (src/routes/api/chat/+server.ts) and streams the reply\n // into `chat.messages`. This page is a demo, and it is yours to delete.\n const chat = new Chat({});\n\n let input = $state('');\n const busy = $derived(chat.status === 'submitted' || chat.status === 'streaming');\n\n function send(event: SubmitEvent) {\n event.preventDefault();\n const text = input.trim();\n if (!text || busy) return;\n chat.sendMessage({ text });\n input = '';\n }\n\n // Enter sends; Shift+Enter starts a new line.\n function onkeydown(event: KeyboardEvent & { currentTarget: HTMLTextAreaElement }) {\n if (event.key === 'Enter' && !event.shiftKey && !event.isComposing) {\n event.preventDefault();\n event.currentTarget.form?.requestSubmit();\n }\n }\n<\/script>\n\n<div class=\"mx-auto flex w-full max-w-3xl flex-1 flex-col gap-6 px-4 py-10\">\n <div>\n <h1 class=\"text-2xl font-semibold\">AI chat</h1>\n <p class=\"text-muted-foreground text-sm\">\n Replies stream from <code>src/routes/api/chat/+server.ts</code>. Pick the model in\n <code>src/lib/server/ai.ts</code>.\n </p>\n </div>\n\n <div class=\"flex flex-1 flex-col gap-4\" aria-live=\"polite\">\n {#each chat.messages as message (message.id)}\n <div\n class={message.role === 'user'\n ? 'bg-primary text-primary-foreground ml-auto max-w-[80%] rounded-lg px-4 py-2'\n : 'max-w-[80%]'}\n >\n {#each message.parts as part, index (index)}\n {#if part.type === 'text'}\n <p class=\"whitespace-pre-wrap\">{part.text}</p>\n {/if}\n {/each}\n </div>\n {:else}\n <p class=\"text-muted-foreground\">Ask anything to start the conversation.</p>\n {/each}\n\n {#if chat.status === 'submitted'}\n <p class=\"text-muted-foreground text-sm\">Thinking…</p>\n {/if}\n\n {#if chat.error}\n <div\n role=\"alert\"\n class=\"border-destructive text-destructive flex items-center justify-between gap-4 rounded-md border px-4 py-2 text-sm\"\n >\n <span>{chat.error.message}</span>\n <Button variant=\"outline\" size=\"sm\" onclick={() => chat.regenerate()}>Retry</Button>\n </div>\n {/if}\n </div>\n\n <form onsubmit={send} class=\"bg-background sticky bottom-0 flex items-end gap-2 py-2\">\n <Textarea\n bind:value={input}\n {onkeydown}\n rows={1}\n placeholder=\"Send a message\"\n aria-label=\"Message\"\n class=\"max-h-40 min-h-10 resize-none\"\n />\n {#if busy}\n <Button type=\"button\" variant=\"outline\" onclick={() => chat.stop()}>Stop</Button>\n {:else}\n <Button type=\"submit\" disabled={!input.trim()}>Send</Button>\n {/if}\n </form>\n</div>\n", u = "import { dev } from '$app/env';\nimport {\n convertToModelMessages,\n createUIMessageStreamResponse,\n safeValidateUIMessages,\n streamText,\n toUIMessageStream\n} from 'ai';\nimport { API_KEY, languageModel } from '#lib/server/ai.js';\nimport type { RequestHandler } from './$types';\n\n// Sent ahead of every conversation: give the assistant its role here.\nconst INSTRUCTIONS = 'You are a helpful assistant. Keep answers short unless asked for detail.';\n\n/**\n * Where `new Chat()` from @ai-sdk/svelte posts by default: the conversation so\n * far comes in, the model's reply streams back. Anyone who can reach the site\n * can call it, and every reply is billed to your API key, so put it behind\n * sign-in or a rate limit before you deploy.\n *\n * Errors are plain text, which `Chat` shows as `chat.error.message`.\n */\nexport const POST: RequestHandler = async ({ request }) => {\n const body = await request.json().catch(() => null);\n const messages = await safeValidateUIMessages({ messages: body?.messages });\n if (!messages.success) {\n return new Response('Expected a JSON body with a messages array.', { status: 400 });\n }\n\n const model = languageModel();\n if (!model) {\n return new Response(`Set ${API_KEY} in .env to start chatting.`, { status: 503 });\n }\n\n const result = streamText({\n model,\n instructions: INSTRUCTIONS,\n messages: await convertToModelMessages(messages.data)\n });\n\n return createUIMessageStreamResponse({\n stream: toUIMessageStream({\n stream: result.stream,\n // Provider errors (a bad key, an unknown model id) reach the chat in\n // dev only; in production they stay in the server log.\n onError: (error) =>\n dev && error instanceof Error ? error.message : 'The model could not answer.'\n })\n });\n};\n", d = "import { describe, it, expect } from 'vitest';\nimport type { Match } from '@velastack/kit';\nimport type { RouteId } from './$types';\n\n// None of these requests reach the model, so they pass without an API key and\n// cost nothing.\ndescribe('POST /api/chat', () => {\n it('should return 400 if the body is not JSON', async (context) => {\n const response = await context.request\n .post('/api/chat' satisfies Match<RouteId>)\n .set('Content-Type', 'application/json')\n .send('not json');\n\n expect(response.status).toBe(400);\n });\n\n it('should return 400 if messages are missing', async (context) => {\n const response = await context.request.post('/api/chat' satisfies Match<RouteId>).send({});\n\n expect(response.status).toBe(400);\n });\n\n it('should return 400 if messages are malformed', async (context) => {\n const response = await context.request\n .post('/api/chat' satisfies Match<RouteId>)\n .send({ messages: [{ role: 'user', content: 'Hello' }] });\n\n expect(response.status).toBe(400);\n });\n});\n", f = "import { dev } from '$app/env';\nimport {\n convertToModelMessages,\n createUIMessageStreamResponse,\n safeValidateUIMessages,\n streamText,\n toUIMessageStream\n} from 'ai';\nimport { API_KEY, languageModel } from '#lib/server/ai.js';\nimport type { RequestHandler } from './$types';\n\n// Sent ahead of every conversation: give the assistant its role here.\nconst INSTRUCTIONS = 'You are a helpful assistant. Keep answers short unless asked for detail.';\n\n/**\n * Where `new Chat()` from @ai-sdk/svelte posts by default: the conversation so\n * far comes in, the model's reply streams back. Every reply is billed to your\n * API key, so only signed-in users get one.\n *\n * Errors are plain text, which `Chat` shows as `chat.error.message`.\n */\nexport const POST: RequestHandler = async ({ request, locals }) => {\n if (!locals.pb.authStore.isValid) {\n return new Response('Sign in to chat.', { status: 401 });\n }\n\n const body = await request.json().catch(() => null);\n const messages = await safeValidateUIMessages({ messages: body?.messages });\n if (!messages.success) {\n return new Response('Expected a JSON body with a messages array.', { status: 400 });\n }\n\n const model = languageModel();\n if (!model) {\n return new Response(`Set ${API_KEY} in .env to start chatting.`, { status: 503 });\n }\n\n const result = streamText({\n model,\n instructions: INSTRUCTIONS,\n messages: await convertToModelMessages(messages.data)\n });\n\n return createUIMessageStreamResponse({\n stream: toUIMessageStream({\n stream: result.stream,\n // Provider errors (a bad key, an unknown model id) reach the chat in\n // dev only; in production they stay in the server log.\n onError: (error) =>\n dev && error instanceof Error ? error.message : 'The model could not answer.'\n })\n });\n};\n", p = "import { describe, it, expect } from 'vitest';\nimport type { Match } from '@velastack/kit';\nimport type { RouteId } from './$types';\n\n// None of these requests reach the model, so they pass without an API key and\n// cost nothing.\ndescribe('POST /api/chat', () => {\n it('should return 401 when signed out', async (context) => {\n const response = await context.request.post('/api/chat' satisfies Match<RouteId>).send({\n messages: [{ id: '1', role: 'user', parts: [{ type: 'text', text: 'Hello' }] }]\n });\n\n expect(response.status).toBe(401);\n });\n\n it('should return 400 if the body is not JSON', async (context) => {\n await context.agent.authenticateUser();\n\n const response = await context.agent\n .post('/api/chat' satisfies Match<RouteId>)\n .set('Content-Type', 'application/json')\n .send('not json');\n\n expect(response.status).toBe(400);\n });\n\n it('should return 400 if messages are missing', async (context) => {\n await context.agent.authenticateUser();\n\n const response = await context.agent.post('/api/chat' satisfies Match<RouteId>).send({});\n\n expect(response.status).toBe(400);\n });\n\n it('should return 400 if messages are malformed', async (context) => {\n await context.agent.authenticateUser();\n\n const response = await context.agent\n .post('/api/chat' satisfies Match<RouteId>)\n .send({ messages: [{ role: 'user', content: 'Hello' }] });\n\n expect(response.status).toBe(400);\n });\n});\n", m = "<script lang=\"ts\">\n import { Chat } from '@ai-sdk/svelte';\n\n // Posts to /api/chat (src/routes/api/chat/+server.ts) and streams the reply\n // into `chat.messages`. This page is a demo, and it is yours to delete.\n const chat = new Chat({});\n\n let input = $state('');\n const busy = $derived(chat.status === 'submitted' || chat.status === 'streaming');\n\n function send(event: SubmitEvent) {\n event.preventDefault();\n const text = input.trim();\n if (!text || busy) return;\n chat.sendMessage({ text });\n input = '';\n }\n\n // Enter sends; Shift+Enter starts a new line.\n function onkeydown(event: KeyboardEvent & { currentTarget: HTMLTextAreaElement }) {\n if (event.key === 'Enter' && !event.shiftKey && !event.isComposing) {\n event.preventDefault();\n event.currentTarget.form?.requestSubmit();\n }\n }\n<\/script>\n\n<h1>AI chat</h1>\n<p>\n Replies stream from <code>src/routes/api/chat/+server.ts</code>. Pick the model in\n <code>src/lib/server/ai.ts</code>.\n</p>\n\n<section aria-live=\"polite\">\n {#each chat.messages as message (message.id)}\n <article data-role={message.role}>\n <strong>{message.role === 'user' ? 'You' : 'Assistant'}</strong>\n {#each message.parts as part, index (index)}\n {#if part.type === 'text'}\n <p style=\"white-space: pre-wrap\">{part.text}</p>\n {/if}\n {/each}\n </article>\n {:else}\n <p>Ask anything to start the conversation.</p>\n {/each}\n\n {#if chat.status === 'submitted'}\n <p>Thinking…</p>\n {/if}\n\n {#if chat.error}\n <p role=\"alert\">\n {chat.error.message}\n <button type=\"button\" onclick={() => chat.regenerate()}>Retry</button>\n </p>\n {/if}\n</section>\n\n<form onsubmit={send}>\n <textarea bind:value={input} {onkeydown} rows=\"2\" placeholder=\"Send a message\" aria-label=\"Message\"\n ></textarea>\n {#if busy}\n <button type=\"button\" onclick={() => chat.stop()}>Stop</button>\n {:else}\n <button type=\"submit\" disabled={!input.trim()}>Send</button>\n {/if}\n</form>\n", h = "import { createAnthropic } from '@ai-sdk/anthropic';\nimport { ANTHROPIC_API_KEY } from '$app/env/private';\n\n/** The `.env` key holding the Anthropic API key, named in the endpoint's 503. */\nexport const API_KEY = 'ANTHROPIC_API_KEY';\n\n/**\n * The model the AI routes talk to, or `undefined` while ANTHROPIC_API_KEY is\n * blank. The key is read when the server starts, so a new value in `.env`\n * takes a restart, not a code change. Any id from\n * https://docs.claude.com/en/docs/about-claude/models works in place of this\n * one.\n */\nexport function languageModel() {\n const apiKey = ANTHROPIC_API_KEY;\n return apiKey ? createAnthropic({ apiKey })('claude-sonnet-5') : undefined;\n}\n", g = "import { createGateway } from 'ai';\nimport { AI_GATEWAY_API_KEY } from '$app/env/private';\n\n/** The `.env` key holding the Vercel AI Gateway API key, named in the endpoint's 503. */\nexport const API_KEY = 'AI_GATEWAY_API_KEY';\n\n/**\n * The model the AI routes talk to, or `undefined` while AI_GATEWAY_API_KEY is\n * blank. The key is read when the server starts, so a new value in `.env`\n * takes a restart, not a code change. The gateway routes `creator/model` ids\n * to their provider; any id from https://vercel.com/ai-gateway/models works in\n * place of this one.\n */\nexport function languageModel() {\n const apiKey = AI_GATEWAY_API_KEY;\n return apiKey ? createGateway({ apiKey })('anthropic/claude-sonnet-5') : undefined;\n}\n", _ = "import { createOpenAI } from '@ai-sdk/openai';\nimport { OPENAI_API_KEY } from '$app/env/private';\n\n/** The `.env` key holding the OpenAI API key, named in the endpoint's 503. */\nexport const API_KEY = 'OPENAI_API_KEY';\n\n/**\n * The model the AI routes talk to, or `undefined` while OPENAI_API_KEY is\n * blank. The key is read when the server starts, so a new value in `.env`\n * takes a restart, not a code change. Any id from\n * https://platform.openai.com/docs/models works in place of this one.\n */\nexport function languageModel() {\n const apiKey = OPENAI_API_KEY;\n return apiKey ? createOpenAI({ apiKey })('gpt-5.5') : undefined;\n}\n", v = [
165
8
  {
166
9
  id: "gateway",
167
10
  label: "Vercel AI Gateway",
@@ -191,41 +34,41 @@ var B = "<script lang=\"ts\">\n import { Chat } from '@ai-sdk/svelte';\n import
191
34
  secret: !0
192
35
  }]
193
36
  }
194
- ], X = [e("ai"), e("@ai-sdk/svelte")], Z = {
37
+ ], y = [e("ai"), e("@ai-sdk/svelte")], b = {
195
38
  openai: [e("@ai-sdk/openai")],
196
39
  anthropic: [e("@ai-sdk/anthropic")]
197
- }, Q = {
40
+ }, x = {
198
41
  slug: "enable-ai",
199
- providers: Y
200
- }, te = "src/routes/(public)/ai/";
201
- function $(e) {
42
+ providers: v
43
+ }, S = "src/routes/(public)/ai/";
44
+ function C(e) {
202
45
  return [
203
46
  "src/routes",
204
- A(e),
47
+ c(e),
205
48
  "ai"
206
49
  ].filter(Boolean).join("/");
207
50
  }
208
- function ne(e, t = {}) {
51
+ function w(e, t = {}) {
209
52
  return i(e, `AI SDK (${e.label})`, t);
210
53
  }
211
- var re = /* #__PURE__ */ Object.assign({
212
- "./creates/src/routes/(public)/ai/+page.svelte": B,
213
- "./creates/src/routes/api/chat/+server.ts": V,
214
- "./creates/src/routes/api/chat/server.test.ts": H
215
- }), ie = /* #__PURE__ */ Object.assign({
216
- "./creates-app-mode/src/routes/api/chat/+server.ts": U,
217
- "./creates-app-mode/src/routes/api/chat/server.test.ts": W
218
- }), ae = /* #__PURE__ */ Object.assign({ "./variants/plain/src/routes/(public)/ai/+page.svelte": G }), oe = /* #__PURE__ */ Object.assign({
219
- "./providers/anthropic/src/lib/server/ai.ts": K,
220
- "./providers/gateway/src/lib/server/ai.ts": q,
221
- "./providers/openai/src/lib/server/ai.ts": J
54
+ var T = /* #__PURE__ */ Object.assign({
55
+ "./creates/src/routes/(public)/ai/+page.svelte": l,
56
+ "./creates/src/routes/api/chat/+server.ts": u,
57
+ "./creates/src/routes/api/chat/server.test.ts": d
58
+ }), E = /* #__PURE__ */ Object.assign({
59
+ "./creates-app-mode/src/routes/api/chat/+server.ts": f,
60
+ "./creates-app-mode/src/routes/api/chat/server.test.ts": p
61
+ }), D = /* #__PURE__ */ Object.assign({ "./variants/plain/src/routes/(public)/ai/+page.svelte": m }), O = /* #__PURE__ */ Object.assign({
62
+ "./providers/anthropic/src/lib/server/ai.ts": h,
63
+ "./providers/gateway/src/lib/server/ai.ts": g,
64
+ "./providers/openai/src/lib/server/ai.ts": _
222
65
  });
223
- async function se(e) {
224
- let i = r(Q, e), c = n(e), l = e.input.serverTests ?? !0, u = {}, d = (e) => {
66
+ async function k(e) {
67
+ let i = r(x, e), c = n(e), l = e.input.serverTests ?? !0, u = {}, d = (e) => {
225
68
  for (let t of e) u[t.path] = t;
226
69
  };
227
- d(o(re, "./creates/", ae, c === "plain" ? "plain" : void 0)), e.features.auth && d(Object.values(s(ie, "./creates-app-mode/"))), d(a(oe, i.id));
228
- let f = `${$(e)}/`;
70
+ d(o(T, "./creates/", D, c === "plain" ? "plain" : void 0)), e.features.auth && d(Object.values(s(E, "./creates-app-mode/"))), d(a(O, i.id));
71
+ let f = `${C(e)}/`;
229
72
  return {
230
73
  creates: Object.values(u).filter((e) => l || !e.path.endsWith("server.test.ts")).map((e) => e.path.startsWith("src/routes/(public)/ai/") ? {
231
74
  ...e,
@@ -235,15 +78,15 @@ async function se(e) {
235
78
  deletes: [],
236
79
  components: c === "plain" ? [] : ["button", "textarea"],
237
80
  packages: [
238
- ...X,
81
+ ...y,
239
82
  t,
240
- ...Z[i.id] ?? []
83
+ ...b[i.id] ?? []
241
84
  ],
242
85
  collections: [],
243
86
  collectionPatches: [],
244
87
  collectionDrops: []
245
88
  };
246
89
  }
247
- export { y as C, x as S, L as _, Z as a, v as b, se as c, K as d, W as f, B as g, V as h, Y as i, J as l, H as m, Q as n, $ as o, U as p, X as r, ne as s, te as t, q as u, R as v, ee as w, b as x, z as y };
90
+ export { b as a, k as c, h as d, p as f, l as g, u as h, v as i, _ as l, d as m, x as n, C as o, f as p, y as r, w as s, S as t, g as u };
248
91
 
249
- //# sourceMappingURL=generate-JkvSNTy-.js.map
92
+ //# sourceMappingURL=generate-rcDj36TD.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-rcDj36TD.js","names":["__import_glob__0_0_","__import_glob__0_1_","__import_glob__0_2_","__import_glob__1_0_","__import_glob__1_1_","__import_glob__2_0_","__import_glob__3_0_","__import_glob__3_1_","__import_glob__3_2_","spec","ZOD","resolveUi","resolveProvider","providerCreates","composeCreates","filesFromGlob","defaultGroup","_page_default$1","_server_default$1","server_test_default$1","_server_default","server_test_default","_page_default","ai_default$2","ai_default$1","ai_default","PROVIDERS","PACKAGES","PROVIDER_PACKAGES","META","DEMO_DIR","demoDir","options","envEditsFor","providerEnvEdits","provider","supplied","createsRaw","createsAppModeRaw","variantsRaw","providersRaw","generate","ui","serverTests","files","add","file","list","target","a","b"],"sources":["../../src/patterns/enable/ai/generate.ts"],"sourcesContent":["import type {\n File,\n Options,\n Package,\n Provider,\n Result,\n} from \"../../../core/types\";\nimport type { EnvEdit } from \"../../../runtime/env\";\nimport { ZOD } from \"../../../core/constants\";\nimport { resolveUi } from \"../../../core/field/ui\";\nimport {\n providerCreates,\n providerEnvEdits,\n resolveProvider,\n} from \"../../../core/providers\";\nimport { composeCreates, filesFromGlob } from \"../../../core/util\";\nimport { defaultGroup } from \"../../../parse/route\";\nimport { spec } from \"../../../core/versions\";\n\n/**\n * The providers in prompt order. Each one's `env` key is what the CLI asks\n * for (without echo), what `generate.runtime.ts` writes to `.env` and\n * declares in `src/env.ts`; the generated `src/lib/server/ai.ts` imports it\n * from `$app/env/private`, and `/api/chat` answers 503 while it is blank.\n */\nexport const PROVIDERS: Provider[] = [\n {\n id: \"gateway\",\n label: \"Vercel AI Gateway\",\n env: [\n {\n key: \"AI_GATEWAY_API_KEY\",\n label: \"Vercel AI Gateway API key\",\n secret: true,\n },\n ],\n },\n {\n id: \"openai\",\n label: \"OpenAI\",\n env: [\n {\n key: \"OPENAI_API_KEY\",\n label: \"OpenAI API key\",\n placeholder: \"sk-...\",\n secret: true,\n },\n ],\n },\n {\n id: \"anthropic\",\n label: \"Anthropic\",\n env: [\n {\n key: \"ANTHROPIC_API_KEY\",\n label: \"Anthropic API key\",\n placeholder: \"sk-ant-...\",\n secret: true,\n },\n ],\n },\n];\n\n/**\n * `ai` carries the gateway provider itself; the others are a package each.\n * zod, a peer of `ai`, is installed alongside but is not listed here: it is\n * not the pattern's to uninstall.\n */\nexport const PACKAGES: Package[] = [spec(\"ai\"), spec(\"@ai-sdk/svelte\")];\nexport const PROVIDER_PACKAGES: Record<string, Package[]> = {\n openai: [spec(\"@ai-sdk/openai\")],\n anthropic: [spec(\"@ai-sdk/anthropic\")],\n};\n\n/** What `resolveProvider` needs; `index.ts` spreads the rest of the metadata. */\nexport const META = { slug: \"enable-ai\", providers: PROVIDERS };\n\n/** Where the demo page is stored; `generate` moves it to the project's default group. */\nexport const DEMO_DIR = \"src/routes/(public)/ai/\";\n\n/**\n * The demo page's directory: `(public)/ai`, `(app)/ai` behind sign-in when\n * auth is on, or `ai` straight under `src/routes` in a project without groups.\n */\nexport function demoDir(\n options: Pick<Options, \"features\" | \"routeGroups\">,\n): string {\n return [\"src/routes\", defaultGroup(options), \"ai\"].filter(Boolean).join(\"/\");\n}\n\n/** The `.env` lines for a provider, under a `# AI SDK (<Label>)` heading. */\nexport function envEditsFor(\n provider: Provider,\n supplied: Record<string, string> = {},\n): EnvEdit[] {\n return providerEnvEdits(provider, `AI SDK (${provider.label})`, supplied);\n}\n\nconst createsRaw = import.meta.glob<string>(\"./creates/**\", {\n query: \"?raw\",\n import: \"default\",\n eager: true,\n});\n\n// With auth, the endpoint answers only signed-in users: every reply is\n// billed to the project's API key.\nconst createsAppModeRaw = import.meta.glob<string>(\"./creates-app-mode/**\", {\n query: \"?raw\",\n import: \"default\",\n eager: true,\n});\n\n// A plain project gets the demo page in native elements, at the same path.\nconst variantsRaw = import.meta.glob<string>(\"./variants/**\", {\n query: \"?raw\",\n import: \"default\",\n eager: true,\n});\n\nconst providersRaw = import.meta.glob<string>(\"./providers/**\", {\n query: \"?raw\",\n import: \"default\",\n eager: true,\n});\n\nexport async function generate(options: Options) {\n const provider = resolveProvider(META, options);\n const ui = resolveUi(options);\n const serverTests = options.input.serverTests ?? true;\n\n const files: Record<string, File> = {};\n const add = (list: File[]) => {\n for (const file of list) files[file.path] = file;\n };\n add(\n composeCreates(\n createsRaw,\n \"./creates/\",\n variantsRaw,\n ui === \"plain\" ? \"plain\" : undefined,\n ),\n );\n if (options.features.auth) {\n add(Object.values(filesFromGlob(createsAppModeRaw, \"./creates-app-mode/\")));\n }\n add(providerCreates(providersRaw, provider.id));\n\n const target = `${demoDir(options)}/`;\n const creates = Object.values(files)\n .filter((file) => serverTests || !file.path.endsWith(\"server.test.ts\"))\n .map((file) =>\n file.path.startsWith(DEMO_DIR)\n ? { ...file, path: target + file.path.slice(DEMO_DIR.length) }\n : file,\n )\n .sort((a, b) => a.path.localeCompare(b.path));\n\n return {\n creates,\n modifies: [],\n deletes: [],\n components: ui === \"plain\" ? [] : [\"button\", \"textarea\"],\n // vela's templates already have zod; a project vela did not create may not.\n packages: [...PACKAGES, ZOD, ...(PROVIDER_PACKAGES[provider.id] ?? [])],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;A,kwZAyBa0B,IAAwB;CACnC;EACE,IAAI;EACJ,OAAO;EACP,KAAK,CACH;GACE,KAAK;GACL,OAAO;GACP,QAAQ;EACV,CACF;CACF;CACA;EACE,IAAI;EACJ,OAAO;EACP,KAAK,CACH;GACE,KAAK;GACL,OAAO;GACP,aAAa;GACb,QAAQ;EACV,CACF;CACF;CACA;EACE,IAAI;EACJ,OAAO;EACP,KAAK,CACH;GACE,KAAK;GACL,OAAO;GACP,aAAa;GACb,QAAQ;EACV,CACF;CACF;AACF,GAOaC,IAAsB,CAAClB,EAAK,IAAI,GAAGA,EAAK,gBAAgB,CAAC,GACzDmB,IAA+C;CAC1D,QAAQ,CAACnB,EAAK,gBAAgB,CAAC;CAC/B,WAAW,CAACA,EAAK,mBAAmB,CAAC;AACvC,GAGaoB,IAAO;CAAE,MAAM;CAAa,WAAWH;AAAU,GAGjDI,IAAW;AAMxB,SAAgBC,EACd,GACQ;CACR,OAAO;EAAC;EAAcf,EAAagB,CAAO;EAAG;CAAI,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;AAC7E;AAGA,SAAgBC,EACd,GACA,IAAmC,CAAC,GACzB;CACX,OAAOC,EAAiBC,GAAU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CAAC,UAAU,UAAU;EAEvD,UAAU;GAAC,GAAGf;GAAUjB;GAAK,GAAIkB,EAAkBO,EAAS,OAAO,CAAC;EAAE;EACtE,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
@@ -1,8 +1,8 @@
1
1
  import { n as e } from "./logger-t1HxmpG2.js";
2
- import { i as t, n } from "./pocketbase-S8lUt0nI.js";
3
- import { r } from "./modify-file-CgJIza72.js";
4
- import { i, n as a, o } from "./whatsapp-DT10x76l.js";
5
- import { swapAuthPages as s } from "./auth-pages-BW3_yluN.js";
2
+ import { i as t, n } from "./pocketbase-Ir-TPv7H.js";
3
+ import { r } from "./modify-file-DvIwtj4o.js";
4
+ import { i, n as a, o } from "./whatsapp-DFZUsKWe.js";
5
+ import { swapAuthPages as s } from "./auth-pages-DHzh31mw.js";
6
6
  import c from "node:fs";
7
7
  import l from "node:path";
8
8
  // src/patterns/disable/whatsapp/generate.runtime.ts
@@ -38,4 +38,4 @@ async function d(d) {
38
38
  }
39
39
  export { d as generate };
40
40
 
41
- //# sourceMappingURL=generate.runtime-D0lI3Gt8.js.map
41
+ //# sourceMappingURL=generate.runtime-4gS2ZHpj.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate.runtime-D0lI3Gt8.js","names":["getLogger","withPocketbase","disableWhatsAppAuth","fs","path","DOCS_URL","generate","logger","options","creates","hasWhatsAppPlugin","pb","migrationDelay","file","writeWhatsAppConfigMigration","modifies","outcomes","swapAuthPages","filePath","outcome","modifyOutcomeToFile"],"sources":["../../src/patterns/disable/whatsapp/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { migrationDelay, withPocketbase } from \"../../../runtime/pocketbase\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport {\n disableWhatsAppAuth,\n hasWhatsAppPlugin,\n writeWhatsAppConfigMigration,\n} from \"../../enable/whatsapp/runtime/whatsapp\";\nimport { swapAuthPages } from \"../../enable/whatsapp/modifies/auth-pages\";\n\nconst DOCS_URL = \"https://velastack.dev/docs/disable/whatsapp\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const creates: File[] = [];\n\n await withPocketbase(options.root, async (pb) => {\n // Without the plugin there is no WhatsApp sign-in to turn off.\n if (!(await hasWhatsAppPlugin(pb))) return;\n\n logger.info(\"Turning off WhatsApp sign-in for users\");\n await disableWhatsAppAuth(pb);\n await migrationDelay();\n const file = writeWhatsAppConfigMigration(options, false);\n if (!file) return;\n creates.push({\n path: file,\n language: \"js\",\n content: fs.readFileSync(file, \"utf8\"),\n status: \"success\",\n });\n });\n logger.info(\n \"Keeping the phone fields on users, and email optional: they hold your users' data\",\n );\n\n logger.info(\"Taking WhatsApp off the login and signup pages\");\n const modifies: File[] = [];\n const outcomes = await swapAuthPages(\n options.root,\n \"disable\",\n (filePath) =>\n `${path.relative(options.root, filePath)} is not the page enable-whatsapp wrote, so it was left as it is. Take the WhatsApp option out of it by hand: ${DOCS_URL}`,\n );\n for (const [filePath, outcome] of outcomes) {\n const file = modifyOutcomeToFile(filePath, outcome);\n if (file) modifies.push(file);\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":";;;;;;;;AAaA,IAAMK,IAAW;AAEjB,eAAsBC,EAAS,GAAkB;CAC/C,IAAMC,IAASP,EAAUQ,CAAO,GAC1BC,IAAkB,CAAC;CAsBzB,AApBA,MAAMR,EAAeO,EAAQ,MAAM,OAAO,MAAO;EAE/C,IAAI,CAAE,MAAME,EAAkBC,CAAE,GAAI;EAIpC,AAFAJ,EAAO,KAAK,wCAAwC,GACpD,MAAML,EAAoBS,CAAE,GAC5B,MAAMC,EAAe;EACrB,IAAMC,IAAOC,EAA6BN,GAAS,EAAK;EACxD,AAAKK,KACLJ,EAAQ,KAAK;GACX,MAAMI;GACN,UAAU;GACV,SAASV,EAAG,aAAaU,GAAM,MAAM;GACrC,QAAQ;EACV,CAAC;CACH,CAAC,GACDN,EAAO,KACL,mFACF,GAEAA,EAAO,KAAK,gDAAgD;CAC5D,IAAMQ,IAAmB,CAAC,GACpBC,IAAW,MAAMC,EACrBT,EAAQ,MACR,YACC,MACC,GAAGJ,EAAK,SAASI,EAAQ,MAAMU,CAAQ,EAAE,+GAA+Gb,GAC5J;CACA,KAAK,IAAM,CAACa,GAAUC,MAAYH,GAAU;EAC1C,IAAMH,IAAOO,EAAoBF,GAAUC,CAAO;EAClD,AAAIN,KAAME,EAAS,KAAKF,CAAI;CAC9B;CAEA,OAAO;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-4gS2ZHpj.js","names":["getLogger","withPocketbase","disableWhatsAppAuth","fs","path","DOCS_URL","generate","logger","options","creates","hasWhatsAppPlugin","pb","migrationDelay","file","writeWhatsAppConfigMigration","modifies","outcomes","swapAuthPages","filePath","outcome","modifyOutcomeToFile"],"sources":["../../src/patterns/disable/whatsapp/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { migrationDelay, withPocketbase } from \"../../../runtime/pocketbase\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport {\n disableWhatsAppAuth,\n hasWhatsAppPlugin,\n writeWhatsAppConfigMigration,\n} from \"../../enable/whatsapp/runtime/whatsapp\";\nimport { swapAuthPages } from \"../../enable/whatsapp/modifies/auth-pages\";\n\nconst DOCS_URL = \"https://velastack.dev/docs/disable/whatsapp\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const creates: File[] = [];\n\n await withPocketbase(options.root, async (pb) => {\n // Without the plugin there is no WhatsApp sign-in to turn off.\n if (!(await hasWhatsAppPlugin(pb))) return;\n\n logger.info(\"Turning off WhatsApp sign-in for users\");\n await disableWhatsAppAuth(pb);\n await migrationDelay();\n const file = writeWhatsAppConfigMigration(options, false);\n if (!file) return;\n creates.push({\n path: file,\n language: \"js\",\n content: fs.readFileSync(file, \"utf8\"),\n status: \"success\",\n });\n });\n logger.info(\n \"Keeping the phone fields on users, and email optional: they hold your users' data\",\n );\n\n logger.info(\"Taking WhatsApp off the login and signup pages\");\n const modifies: File[] = [];\n const outcomes = await swapAuthPages(\n options.root,\n \"disable\",\n (filePath) =>\n `${path.relative(options.root, filePath)} is not the page enable-whatsapp wrote, so it was left as it is. Take the WhatsApp option out of it by hand: ${DOCS_URL}`,\n );\n for (const [filePath, outcome] of outcomes) {\n const file = modifyOutcomeToFile(filePath, outcome);\n if (file) modifies.push(file);\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":";;;;;;;;AAaA,IAAMK,IAAW;AAEjB,eAAsBC,EAAS,GAAkB;CAC/C,IAAMC,IAASP,EAAUQ,CAAO,GAC1BC,IAAkB,CAAC;CAsBzB,AApBA,MAAMR,EAAeO,EAAQ,MAAM,OAAO,MAAO;EAE/C,IAAI,CAAE,MAAME,EAAkBC,CAAE,GAAI;EAIpC,AAFAJ,EAAO,KAAK,wCAAwC,GACpD,MAAML,EAAoBS,CAAE,GAC5B,MAAMC,EAAe;EACrB,IAAMC,IAAOC,EAA6BN,GAAS,EAAK;EACxD,AAAKK,KACLJ,EAAQ,KAAK;GACX,MAAMI;GACN,UAAU;GACV,SAASV,EAAG,aAAaU,GAAM,MAAM;GACrC,QAAQ;EACV,CAAC;CACH,CAAC,GACDN,EAAO,KACL,mFACF,GAEAA,EAAO,KAAK,gDAAgD;CAC5D,IAAMQ,IAAmB,CAAC,GACpBC,IAAW,MAAMC,EACrBT,EAAQ,MACR,YACC,MACC,GAAGJ,EAAK,SAASI,EAAQ,MAAMU,CAAQ,EAAE,+GAA+Gb,GAC5J;CACA,KAAK,IAAM,CAACa,GAAUC,MAAYH,GAAU;EAC1C,IAAMH,IAAOO,EAAoBF,GAAUC,CAAO;EAClD,AAAIN,KAAME,EAAS,KAAKF,CAAI;CAC9B;CAEA,OAAO;EACL;EACA;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
@@ -1,15 +1,16 @@
1
1
  import { n as e } from "./logger-t1HxmpG2.js";
2
- import { a as t, r as n } from "./modify-file-CgJIza72.js";
3
- import { n as r } from "./shared-BjTRQ5QH.js";
4
- import { n as i } from "./site-C8Wcg6LT.js";
2
+ import { a as t, r as n } from "./modify-file-DvIwtj4o.js";
3
+ import { n as r } from "./shared-CZHopdly.js";
4
+ import { n as i } from "./site-B9-emR6D.js";
5
5
  import { t as a } from "./dedent-CCUOcPFW.js";
6
6
  import { n as o } from "./compose-handle-Da7m6lV_.js";
7
7
  import { c as s, m as c, n as l, o as u } from "./ts-morph-helpers-B4KZXP44.js";
8
8
  import { r as d, t as f } from "./lib-specifier-C3M0WTev.js";
9
- import { a as p, l as m, s as h } from "./test-setup-CpjhQSl-.js";
9
+ import { i as p, n as m } from "./gitignore-CPardo4E.js";
10
+ import { o as h } from "./test-setup-jqVMmL83.js";
10
11
  import { t as g } from "./env-vars-CUh4mLM_.js";
11
12
  import { t as _ } from "./env-vars-T3_7JNSg.js";
12
- import { unmodifyEnvVarsFiles as v } from "./env-vars-BbS_mWyP.js";
13
+ import { unmodifyEnvVarsFiles as v } from "./env-vars-BcHu8247.js";
13
14
  import y from "node:fs";
14
15
  import b from "node:path";
15
16
  import { Node as x, Project as S, QuoteKind as C } from "ts-morph";
@@ -118,7 +119,7 @@ function N(e) {
118
119
  async function P(a) {
119
120
  let o = e(a), s = [], c = [], l = [];
120
121
  o.info("Reverting adapter config");
121
- let u = m(a.root), d = n(u.filePath, u.outcome);
122
+ let u = p(a.root), d = n(u.filePath, u.outcome);
122
123
  d && c.push(d), o.info("Reverting hooks.server.ts");
123
124
  let f = b.join(a.root, "src", "hooks.server.ts"), x = t(f, A(f));
124
125
  x.modify && c.push(x.modify), x.delete && l.push(x.delete);
@@ -126,7 +127,7 @@ async function P(a) {
126
127
  o.info(S ? "Removing the PocketBase and workflow variables from src/env.ts" : "Removing the PocketBase variables from src/env.ts");
127
128
  let C = v(a.root, (S ? _ : g).map((e) => e.name));
128
129
  C.modify && c.push(C.modify), C.delete && l.push(C.delete), o.info("Reverting .gitignore");
129
- let w = b.join(a.root, ".gitignore"), T = n(w, h(w));
130
+ let w = b.join(a.root, ".gitignore"), T = n(w, m(w));
130
131
  T && c.push(T), o.info("Reverting src/routes/+layout.server.ts");
131
132
  let E = b.join(a.root, "src", "routes", "+layout.server.ts"), D = n(E, M(E));
132
133
  if (D && c.push(D), D?.status === "success") {
@@ -135,7 +136,7 @@ async function P(a) {
135
136
  }
136
137
  for (let e of N(b.join(a.root, "src"))) o.info(`Removing ${b.relative(a.root, e)}`), l.push(r(e));
137
138
  o.info("Reverting test/setup.ts");
138
- let O = b.join(a.root, "test", "setup.ts"), k = n(O, p(O));
139
+ let O = b.join(a.root, "test", "setup.ts"), k = n(O, h(O));
139
140
  return k && c.push(k), {
140
141
  creates: s,
141
142
  modifies: c,
@@ -149,4 +150,4 @@ async function P(a) {
149
150
  }
150
151
  export { P as generate };
151
152
 
152
- //# sourceMappingURL=generate.runtime-BFX_8erf.js.map
153
+ //# sourceMappingURL=generate.runtime-As1It8o7.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate.runtime-BFX_8erf.js","names":["getLogger","revertOutcomeToFile","modifyOutcomeToFile","toDeleteEntry","ensureSiteFile","dedent","removeHandle","pruneUnusedImports","removeStatementWithComments","ensureBlankLineAfterImports","formatLikeSource","libModule","isLibSpecifier","unmodifyTestSetup","unmodifySvelteConfig","unmodifyGitignore","BACKEND_ENV_VARS","WORKFLOWS_ENV_VARS","fs","path","HANDLE_HINT","INIT_HINT","BACKEND_MODULES","isStartWorkerCall","node","Node","onlyStartsWorker","fn","body","statements","workerInit","sf","decl","target","unmodifyHooksServerBackend","hooksServerPath","original","sourceFile","Project","QuoteKind","init","FAILURE_HINT","unmodifyLayoutServerMeta","layoutServerPath","updated","withoutParam","m","serverTestFiles","dir","found","entry","full","generate","logger","options","creates","modifies","deletes","revert","svelteConfigFile","hooksServerRevert","hasWorkflows","envVars","unmodifyEnvVarsFiles","spec","gitignorePath","gitignoreFile","layoutServerFile","siteFile","testFile","testSetupPath","testSetupFile"],"sources":["../../src/patterns/disable/backend/modifies/hooks.server.ts","../../src/patterns/disable/backend/modifies/layout-server.ts","../../src/patterns/disable/backend/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport {\n Node,\n Project,\n QuoteKind,\n type SourceFile,\n type Statement,\n} from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { removeHandle } from \"../../../../runtime/compose-handle\";\nimport {\n ensureBlankLineAfterImports,\n pruneUnusedImports,\n removeStatementWithComments,\n formatLikeSource,\n type ModuleMatch,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport { libModule } from \"../../../../runtime/lib-specifier\";\n\nconst HANDLE_HINT = dedent`\n Take handlePocketbase(...) out of the exported handle in src/hooks.server.ts,\n and its imports from '@velastack/pocketbase' and '$app/env/private'.\n`;\n\nconst INIT_HINT = dedent`\n The workflows are removed with the backend. Take the startWorker() call out\n of the init hook in src/hooks.server.ts, and its import:\n\n import { startWorker } from '#lib/server/workflows.js';\n`;\n\n/**\n * Modules only the backend's handle and init import from. An import nothing\n * references any more is dropped; a variable other code still reads stays.\n * `$env/dynamic/private` is the `env` object hooks written before SvelteKit 3\n * read the PocketBase variables from.\n */\nconst BACKEND_MODULES: ModuleMatch[] = [\n \"@velastack/pocketbase\",\n \"$app/env/private\",\n \"$env/dynamic/private\",\n libModule(\"server/workflows\"),\n \"@sveltejs/kit\",\n \"@sveltejs/kit/hooks\",\n];\n\n/** `startWorker()`, `await startWorker()` or `return startWorker()`. */\nfunction isStartWorkerCall(node: Node | undefined): boolean {\n if (!node) return false;\n if (Node.isAwaitExpression(node))\n return isStartWorkerCall(node.getExpression());\n if (Node.isExpressionStatement(node) || Node.isReturnStatement(node)) {\n return isStartWorkerCall(node.getExpression());\n }\n return (\n Node.isCallExpression(node) &&\n node.getExpression().getText() === \"startWorker\" &&\n node.getArguments().length === 0\n );\n}\n\n/** A function whose whole body starts the worker. */\nfunction onlyStartsWorker(fn: Node | undefined): boolean {\n if (\n !Node.isArrowFunction(fn) &&\n !Node.isFunctionExpression(fn) &&\n !Node.isFunctionDeclaration(fn)\n ) {\n return false;\n }\n const body = fn.getBody();\n if (!body) return false;\n if (!Node.isBlock(body)) return isStartWorkerCall(body);\n const statements = body.getStatements();\n return statements.length === 1 && isStartWorkerCall(statements[0]);\n}\n\n/**\n * The `init` export when all it does is start the workflow worker, the way\n * the minimal template and enable-workflows write it. `\"custom\"` when an init\n * starts the worker among other things; null when there is nothing to do.\n */\nfunction workerInit(sf: SourceFile): Statement | \"custom\" | null {\n const fn = sf.getFunction(\"init\");\n const decl = sf.getVariableDeclaration(\"init\");\n const target = fn ?? decl?.getVariableStatement();\n if (!target || !target.getText().includes(\"startWorker\")) return null;\n const onlyWorker = fn\n ? onlyStartsWorker(fn)\n : decl?.getVariableStatement()?.getDeclarations().length === 1 &&\n onlyStartsWorker(decl.getInitializer());\n return onlyWorker ? target : \"custom\";\n}\n\n/**\n * Undo what the backend put in `hooks.server.ts`: the PocketBase handle, and\n * the `init` that starts the workflow worker, which is deleted along with the\n * backend. Whatever else the file holds (i18n, content negotiation) stays; a\n * file with nothing else comes out empty, for the caller to delete.\n */\nexport function unmodifyHooksServerBackend(\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 (\n !original.includes(\"handlePocketbase\") &&\n !original.includes(\"startWorker\")\n ) {\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 // Checked before anything changes, so a failure leaves the file as it was.\n if (workerInit(sourceFile) === \"custom\") {\n return { status: \"failed\", message: INIT_HINT };\n }\n\n const removed = removeHandle(sourceFile, \"handlePocketbase\");\n if (removed.status === \"unsupported\") {\n return { status: \"failed\", message: HANDLE_HINT };\n }\n // Looked up again: edits to the file forget the nodes found before them.\n const init = workerInit(sourceFile);\n if (init && init !== \"custom\") removeStatementWithComments(sourceFile, init);\n\n pruneUnusedImports(sourceFile, BACKEND_MODULES);\n formatLikeSource(sourceFile);\n ensureBlankLineAfterImports(sourceFile);\n sourceFile.saveSync();\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== original,\n };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { isLibSpecifier } from \"../../../../runtime/lib-specifier\";\n\nconst FAILURE_HINT = dedent`\n src/routes/+layout.server.ts still reads locals.meta, which only the\n PocketBase hook provides. Read the values from a static module instead:\n\n import { site } from '#lib/site.js';\n\n // locals.meta.appName -> site.name\n // locals.meta.appURL -> site.url\n // meta: locals.meta -> meta: { appName: site.name, appURL: site.url }\n`;\n\n/**\n * Point an older root layout's meta at `#lib/site.js` instead of `locals.meta`.\n * Templates from before `src/lib/site.ts` read the app name and URL off the\n * PocketBase hook; without the backend nothing sets them, and `App.Locals` no\n * longer declares them. Current templates read `#lib/site.js` already, so this\n * leaves them alone.\n */\nexport function unmodifyLayoutServerMeta(\n layoutServerPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(layoutServerPath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(layoutServerPath, \"utf8\");\n if (!original.includes(\"locals.meta\")) {\n return { status: \"success\", changed: false };\n }\n\n let updated = original\n .replace(/\\blocals\\.meta\\.appName\\b/g, \"site.name\")\n .replace(/\\blocals\\.meta\\.appURL\\b/g, \"site.url\")\n .replace(\n /\\bmeta:\\s*locals\\.meta\\b/g,\n \"meta: { appName: site.name, appURL: site.url }\",\n );\n\n if (updated.includes(\"locals.meta\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n // `locals` usually only carried meta; drop it from the destructuring when\n // nothing else reads it.\n const withoutParam = updated\n .replace(/\\(\\{\\s*locals\\s*,\\s*/g, \"({ \")\n .replace(/,\\s*locals\\s*\\}/g, \" }\");\n if (!/\\blocals\\b/.test(withoutParam)) {\n updated = withoutParam;\n }\n\n const importsSite = [...updated.matchAll(/from\\s+['\"]([^'\"]+)['\"]/g)].some(\n (m) => isLibSpecifier(m[1], \"site\"),\n );\n if (!importsSite) {\n updated = \"import { site } from '#lib/site.js';\\n\" + updated;\n }\n\n fs.writeFileSync(layoutServerPath, updated, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport {\n modifyOutcomeToFile,\n revertOutcomeToFile,\n} from \"../../../runtime/modify-file\";\nimport { toDeleteEntry } from \"../../destroy/shared\";\nimport { ensureSiteFile } from \"../../../runtime/site\";\nimport { unmodifyHooksServerBackend } from \"./modifies/hooks.server\";\nimport { unmodifyLayoutServerMeta } from \"./modifies/layout-server\";\nimport { unmodifySvelteConfig } from \"../../enable/backend/modifies/svelte-config\";\nimport { unmodifyGitignore } from \"../../enable/backend/modifies/gitignore\";\nimport { unmodifyTestSetup } from \"../../enable/backend/modifies/test-setup\";\nimport { BACKEND_ENV_VARS } from \"../../enable/backend/env-vars\";\nimport { WORKFLOWS_ENV_VARS } from \"../../enable/workflows/env-vars\";\nimport { unmodifyEnvVarsFiles } from \"../../../runtime/env-vars\";\n\n/** Every server test under a directory; they need the PocketBase test context. */\nfunction serverTestFiles(dir: string): string[] {\n if (!fs.existsSync(dir)) return [];\n const found: string[] = [];\n for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {\n const full = path.join(dir, entry.name);\n if (entry.isDirectory()) found.push(...serverTestFiles(full));\n else if (entry.name === \"server.test.ts\") found.push(full);\n }\n return found;\n}\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const creates: File[] = [];\n const modifies: File[] = [];\n const deletes: File[] = [];\n\n logger.info(\"Reverting adapter config\");\n const revert = unmodifySvelteConfig(options.root);\n const svelteConfigFile = modifyOutcomeToFile(revert.filePath, revert.outcome);\n if (svelteConfigFile) modifies.push(svelteConfigFile);\n\n // Only the backend's handle and worker come out; handles other patterns\n // composed in stay. The file goes when nothing else was in it.\n logger.info(\"Reverting hooks.server.ts\");\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n const hooksServerRevert = revertOutcomeToFile(\n hooksServerPath,\n unmodifyHooksServerBackend(hooksServerPath),\n );\n if (hooksServerRevert.modify) modifies.push(hooksServerRevert.modify);\n if (hooksServerRevert.delete) deletes.push(hooksServerRevert.delete);\n\n // The file goes when these were all it declared. The workflow runtime\n // (deleted with the backend) is the only reader of its switches, so they\n // go too, but only from a project that has it: `TEST` is a common name.\n const hasWorkflows = fs.existsSync(\n path.join(options.root, \"src\", \"lib\", \"server\", \"workflows.ts\"),\n );\n logger.info(\n hasWorkflows\n ? \"Removing the PocketBase and workflow variables from src/env.ts\"\n : \"Removing the PocketBase variables from src/env.ts\",\n );\n const envVars = unmodifyEnvVarsFiles(\n options.root,\n (hasWorkflows ? WORKFLOWS_ENV_VARS : BACKEND_ENV_VARS).map(\n (spec) => spec.name,\n ),\n );\n if (envVars.modify) modifies.push(envVars.modify);\n if (envVars.delete) deletes.push(envVars.delete);\n\n logger.info(\"Reverting .gitignore\");\n const gitignorePath = path.join(options.root, \".gitignore\");\n const gitignoreFile = modifyOutcomeToFile(\n gitignorePath,\n unmodifyGitignore(gitignorePath),\n );\n if (gitignoreFile) modifies.push(gitignoreFile);\n\n logger.info(\"Reverting src/routes/+layout.server.ts\");\n const layoutServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.server.ts\",\n );\n const layoutServerFile = modifyOutcomeToFile(\n layoutServerPath,\n unmodifyLayoutServerMeta(layoutServerPath),\n );\n if (layoutServerFile) modifies.push(layoutServerFile);\n\n // The converted layout reads `src/lib/site.ts`. Every template ships it; a\n // project from before that gets one here, named as PocketBase knew it.\n if (layoutServerFile?.status === \"success\") {\n const siteFile = await ensureSiteFile(options);\n if (siteFile) creates.push(siteFile);\n }\n\n // Server tests run against the PocketBase-backed test context that the\n // backend's test/setup.ts provides; without it they neither type-check nor\n // run.\n for (const testFile of serverTestFiles(path.join(options.root, \"src\"))) {\n logger.info(`Removing ${path.relative(options.root, testFile)}`);\n deletes.push(toDeleteEntry(testFile));\n }\n\n logger.info(\"Reverting test/setup.ts\");\n const testSetupPath = path.join(options.root, \"test\", \"setup.ts\");\n const testSetupFile = modifyOutcomeToFile(\n testSetupPath,\n unmodifyTestSetup(testSetupPath),\n );\n if (testSetupFile) modifies.push(testSetupFile);\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":";;;;;;;;;;;;;;;;AAoBA,IAAMoB,IAAc,CAAM;;;GAKpBC,IAAY,CAAM;;;;;GAalBC,IAAiC;CACrC;CACA;CACA;CACAX,EAAU,kBAAkB;CAC5B;CACA;AACF;AAGA,SAASY,EAAkB,GAAiC;CAO1D,OANKC,IACDC,EAAK,kBAAkBD,CAAI,KAE3BC,EAAK,sBAAsBD,CAAI,KAAKC,EAAK,kBAAkBD,CAAI,IAC1DD,EAAkBC,EAAK,cAAc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AAQ,UAAQN,EAAS,KAAKM,EAAQ,MAAM,GAC5CA,EAAQ,UAAQL,EAAQ,KAAKK,EAAQ,MAAM,GAE/CT,EAAO,KAAK,sBAAsB;CAClC,IAAMY,IAAgB9C,EAAK,KAAKmC,EAAQ,MAAM,YAAY,GACpDY,IAAgBhE,EACpB+D,GACAlD,EAAkBkD,CAAa,CACjC;CAGA,AAFIC,KAAeV,EAAS,KAAKU,CAAa,GAE9Cb,EAAO,KAAK,wCAAwC;CACpD,IAAMV,IAAmBxB,EAAK,KAC5BmC,EAAQ,MACR,OACA,UACA,mBACF,GACMa,IAAmBjE,EACvByC,GACAD,EAAyBC,CAAgB,CAC3C;CAKA,IAJIwB,KAAkBX,EAAS,KAAKW,CAAgB,GAIhDA,GAAkB,WAAW,WAAW;EAC1C,IAAMC,IAAW,MAAMhE,EAAekD,CAAO;EAC7C,AAAIc,KAAUb,EAAQ,KAAKa,CAAQ;CACrC;CAKA,KAAK,IAAMC,KAAYtB,EAAgB5B,EAAK,KAAKmC,EAAQ,MAAM,KAAK,CAAC,GAEnE,AADAD,EAAO,KAAK,YAAYlC,EAAK,SAASmC,EAAQ,MAAMe,CAAQ,GAAG,GAC/DZ,EAAQ,KAAKtD,EAAckE,CAAQ,CAAC;CAGtC,EAAO,KAAK,yBAAyB;CACrC,IAAMC,IAAgBnD,EAAK,KAAKmC,EAAQ,MAAM,QAAQ,UAAU,GAC1DiB,IAAgBrE,EACpBoE,GACAzD,EAAkByD,CAAa,CACjC;CAGA,OAFIC,KAAef,EAAS,KAAKe,CAAa,GAEvC;EACL;EACA;EACA;EACA,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
1
+ {"version":3,"file":"generate.runtime-As1It8o7.js","names":["getLogger","revertOutcomeToFile","modifyOutcomeToFile","toDeleteEntry","ensureSiteFile","dedent","removeHandle","pruneUnusedImports","removeStatementWithComments","ensureBlankLineAfterImports","formatLikeSource","libModule","isLibSpecifier","unmodifySvelteConfig","unmodifyGitignore","unmodifyTestSetup","BACKEND_ENV_VARS","WORKFLOWS_ENV_VARS","fs","path","HANDLE_HINT","INIT_HINT","BACKEND_MODULES","isStartWorkerCall","node","Node","onlyStartsWorker","fn","body","statements","workerInit","sf","decl","target","unmodifyHooksServerBackend","hooksServerPath","original","sourceFile","Project","QuoteKind","init","FAILURE_HINT","unmodifyLayoutServerMeta","layoutServerPath","updated","withoutParam","m","serverTestFiles","dir","found","entry","full","generate","logger","options","creates","modifies","deletes","revert","svelteConfigFile","hooksServerRevert","hasWorkflows","envVars","unmodifyEnvVarsFiles","spec","gitignorePath","gitignoreFile","layoutServerFile","siteFile","testFile","testSetupPath","testSetupFile"],"sources":["../../src/patterns/disable/backend/modifies/hooks.server.ts","../../src/patterns/disable/backend/modifies/layout-server.ts","../../src/patterns/disable/backend/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport {\n Node,\n Project,\n QuoteKind,\n type SourceFile,\n type Statement,\n} from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { removeHandle } from \"../../../../runtime/compose-handle\";\nimport {\n ensureBlankLineAfterImports,\n pruneUnusedImports,\n removeStatementWithComments,\n formatLikeSource,\n type ModuleMatch,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport { libModule } from \"../../../../runtime/lib-specifier\";\n\nconst HANDLE_HINT = dedent`\n Take handlePocketbase(...) out of the exported handle in src/hooks.server.ts,\n and its imports from '@velastack/pocketbase' and '$app/env/private'.\n`;\n\nconst INIT_HINT = dedent`\n The workflows are removed with the backend. Take the startWorker() call out\n of the init hook in src/hooks.server.ts, and its import:\n\n import { startWorker } from '#lib/server/workflows.js';\n`;\n\n/**\n * Modules only the backend's handle and init import from. An import nothing\n * references any more is dropped; a variable other code still reads stays.\n * `$env/dynamic/private` is the `env` object hooks written before SvelteKit 3\n * read the PocketBase variables from.\n */\nconst BACKEND_MODULES: ModuleMatch[] = [\n \"@velastack/pocketbase\",\n \"$app/env/private\",\n \"$env/dynamic/private\",\n libModule(\"server/workflows\"),\n \"@sveltejs/kit\",\n \"@sveltejs/kit/hooks\",\n];\n\n/** `startWorker()`, `await startWorker()` or `return startWorker()`. */\nfunction isStartWorkerCall(node: Node | undefined): boolean {\n if (!node) return false;\n if (Node.isAwaitExpression(node))\n return isStartWorkerCall(node.getExpression());\n if (Node.isExpressionStatement(node) || Node.isReturnStatement(node)) {\n return isStartWorkerCall(node.getExpression());\n }\n return (\n Node.isCallExpression(node) &&\n node.getExpression().getText() === \"startWorker\" &&\n node.getArguments().length === 0\n );\n}\n\n/** A function whose whole body starts the worker. */\nfunction onlyStartsWorker(fn: Node | undefined): boolean {\n if (\n !Node.isArrowFunction(fn) &&\n !Node.isFunctionExpression(fn) &&\n !Node.isFunctionDeclaration(fn)\n ) {\n return false;\n }\n const body = fn.getBody();\n if (!body) return false;\n if (!Node.isBlock(body)) return isStartWorkerCall(body);\n const statements = body.getStatements();\n return statements.length === 1 && isStartWorkerCall(statements[0]);\n}\n\n/**\n * The `init` export when all it does is start the workflow worker, the way\n * the minimal template and enable-workflows write it. `\"custom\"` when an init\n * starts the worker among other things; null when there is nothing to do.\n */\nfunction workerInit(sf: SourceFile): Statement | \"custom\" | null {\n const fn = sf.getFunction(\"init\");\n const decl = sf.getVariableDeclaration(\"init\");\n const target = fn ?? decl?.getVariableStatement();\n if (!target || !target.getText().includes(\"startWorker\")) return null;\n const onlyWorker = fn\n ? onlyStartsWorker(fn)\n : decl?.getVariableStatement()?.getDeclarations().length === 1 &&\n onlyStartsWorker(decl.getInitializer());\n return onlyWorker ? target : \"custom\";\n}\n\n/**\n * Undo what the backend put in `hooks.server.ts`: the PocketBase handle, and\n * the `init` that starts the workflow worker, which is deleted along with the\n * backend. Whatever else the file holds (i18n, content negotiation) stays; a\n * file with nothing else comes out empty, for the caller to delete.\n */\nexport function unmodifyHooksServerBackend(\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 (\n !original.includes(\"handlePocketbase\") &&\n !original.includes(\"startWorker\")\n ) {\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 // Checked before anything changes, so a failure leaves the file as it was.\n if (workerInit(sourceFile) === \"custom\") {\n return { status: \"failed\", message: INIT_HINT };\n }\n\n const removed = removeHandle(sourceFile, \"handlePocketbase\");\n if (removed.status === \"unsupported\") {\n return { status: \"failed\", message: HANDLE_HINT };\n }\n // Looked up again: edits to the file forget the nodes found before them.\n const init = workerInit(sourceFile);\n if (init && init !== \"custom\") removeStatementWithComments(sourceFile, init);\n\n pruneUnusedImports(sourceFile, BACKEND_MODULES);\n formatLikeSource(sourceFile);\n ensureBlankLineAfterImports(sourceFile);\n sourceFile.saveSync();\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== original,\n };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { isLibSpecifier } from \"../../../../runtime/lib-specifier\";\n\nconst FAILURE_HINT = dedent`\n src/routes/+layout.server.ts still reads locals.meta, which only the\n PocketBase hook provides. Read the values from a static module instead:\n\n import { site } from '#lib/site.js';\n\n // locals.meta.appName -> site.name\n // locals.meta.appURL -> site.url\n // meta: locals.meta -> meta: { appName: site.name, appURL: site.url }\n`;\n\n/**\n * Point an older root layout's meta at `#lib/site.js` instead of `locals.meta`.\n * Templates from before `src/lib/site.ts` read the app name and URL off the\n * PocketBase hook; without the backend nothing sets them, and `App.Locals` no\n * longer declares them. Current templates read `#lib/site.js` already, so this\n * leaves them alone.\n */\nexport function unmodifyLayoutServerMeta(\n layoutServerPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(layoutServerPath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(layoutServerPath, \"utf8\");\n if (!original.includes(\"locals.meta\")) {\n return { status: \"success\", changed: false };\n }\n\n let updated = original\n .replace(/\\blocals\\.meta\\.appName\\b/g, \"site.name\")\n .replace(/\\blocals\\.meta\\.appURL\\b/g, \"site.url\")\n .replace(\n /\\bmeta:\\s*locals\\.meta\\b/g,\n \"meta: { appName: site.name, appURL: site.url }\",\n );\n\n if (updated.includes(\"locals.meta\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n // `locals` usually only carried meta; drop it from the destructuring when\n // nothing else reads it.\n const withoutParam = updated\n .replace(/\\(\\{\\s*locals\\s*,\\s*/g, \"({ \")\n .replace(/,\\s*locals\\s*\\}/g, \" }\");\n if (!/\\blocals\\b/.test(withoutParam)) {\n updated = withoutParam;\n }\n\n const importsSite = [...updated.matchAll(/from\\s+['\"]([^'\"]+)['\"]/g)].some(\n (m) => isLibSpecifier(m[1], \"site\"),\n );\n if (!importsSite) {\n updated = \"import { site } from '#lib/site.js';\\n\" + updated;\n }\n\n fs.writeFileSync(layoutServerPath, updated, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport {\n modifyOutcomeToFile,\n revertOutcomeToFile,\n} from \"../../../runtime/modify-file\";\nimport { toDeleteEntry } from \"../../destroy/shared\";\nimport { ensureSiteFile } from \"../../../runtime/site\";\nimport { unmodifyHooksServerBackend } from \"./modifies/hooks.server\";\nimport { unmodifyLayoutServerMeta } from \"./modifies/layout-server\";\nimport { unmodifySvelteConfig } from \"../../enable/backend/modifies/svelte-config\";\nimport { unmodifyGitignore } from \"../../enable/backend/modifies/gitignore\";\nimport { unmodifyTestSetup } from \"../../enable/backend/modifies/test-setup\";\nimport { BACKEND_ENV_VARS } from \"../../enable/backend/env-vars\";\nimport { WORKFLOWS_ENV_VARS } from \"../../enable/workflows/env-vars\";\nimport { unmodifyEnvVarsFiles } from \"../../../runtime/env-vars\";\n\n/** Every server test under a directory; they need the PocketBase test context. */\nfunction serverTestFiles(dir: string): string[] {\n if (!fs.existsSync(dir)) return [];\n const found: string[] = [];\n for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {\n const full = path.join(dir, entry.name);\n if (entry.isDirectory()) found.push(...serverTestFiles(full));\n else if (entry.name === \"server.test.ts\") found.push(full);\n }\n return found;\n}\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const creates: File[] = [];\n const modifies: File[] = [];\n const deletes: File[] = [];\n\n logger.info(\"Reverting adapter config\");\n const revert = unmodifySvelteConfig(options.root);\n const svelteConfigFile = modifyOutcomeToFile(revert.filePath, revert.outcome);\n if (svelteConfigFile) modifies.push(svelteConfigFile);\n\n // Only the backend's handle and worker come out; handles other patterns\n // composed in stay. The file goes when nothing else was in it.\n logger.info(\"Reverting hooks.server.ts\");\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n const hooksServerRevert = revertOutcomeToFile(\n hooksServerPath,\n unmodifyHooksServerBackend(hooksServerPath),\n );\n if (hooksServerRevert.modify) modifies.push(hooksServerRevert.modify);\n if (hooksServerRevert.delete) deletes.push(hooksServerRevert.delete);\n\n // The file goes when these were all it declared. The workflow runtime\n // (deleted with the backend) is the only reader of its switches, so they\n // go too, but only from a project that has it: `TEST` is a common name.\n const hasWorkflows = fs.existsSync(\n path.join(options.root, \"src\", \"lib\", \"server\", \"workflows.ts\"),\n );\n logger.info(\n hasWorkflows\n ? \"Removing the PocketBase and workflow variables from src/env.ts\"\n : \"Removing the PocketBase variables from src/env.ts\",\n );\n const envVars = unmodifyEnvVarsFiles(\n options.root,\n (hasWorkflows ? WORKFLOWS_ENV_VARS : BACKEND_ENV_VARS).map(\n (spec) => spec.name,\n ),\n );\n if (envVars.modify) modifies.push(envVars.modify);\n if (envVars.delete) deletes.push(envVars.delete);\n\n logger.info(\"Reverting .gitignore\");\n const gitignorePath = path.join(options.root, \".gitignore\");\n const gitignoreFile = modifyOutcomeToFile(\n gitignorePath,\n unmodifyGitignore(gitignorePath),\n );\n if (gitignoreFile) modifies.push(gitignoreFile);\n\n logger.info(\"Reverting src/routes/+layout.server.ts\");\n const layoutServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.server.ts\",\n );\n const layoutServerFile = modifyOutcomeToFile(\n layoutServerPath,\n unmodifyLayoutServerMeta(layoutServerPath),\n );\n if (layoutServerFile) modifies.push(layoutServerFile);\n\n // The converted layout reads `src/lib/site.ts`. Every template ships it; a\n // project from before that gets one here, named as PocketBase knew it.\n if (layoutServerFile?.status === \"success\") {\n const siteFile = await ensureSiteFile(options);\n if (siteFile) creates.push(siteFile);\n }\n\n // Server tests run against the PocketBase-backed test context that the\n // backend's test/setup.ts provides; without it they neither type-check nor\n // run.\n for (const testFile of serverTestFiles(path.join(options.root, \"src\"))) {\n logger.info(`Removing ${path.relative(options.root, testFile)}`);\n deletes.push(toDeleteEntry(testFile));\n }\n\n logger.info(\"Reverting test/setup.ts\");\n const testSetupPath = path.join(options.root, \"test\", \"setup.ts\");\n const testSetupFile = modifyOutcomeToFile(\n testSetupPath,\n unmodifyTestSetup(testSetupPath),\n );\n if (testSetupFile) modifies.push(testSetupFile);\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":";;;;;;;;;;;;;;;;;AAoBA,IAAMoB,IAAc,CAAM;;;GAKpBC,IAAY,CAAM;;;;;GAalBC,IAAiC;CACrC;CACA;CACA;CACAX,EAAU,kBAAkB;CAC5B;CACA;AACF;AAGA,SAASY,EAAkB,GAAiC;CAO1D,OANKC,IACDC,EAAK,kBAAkBD,CAAI,KAE3BC,EAAK,sBAAsBD,CAAI,KAAKC,EAAK,kBAAkBD,CAAI,IAC1DD,EAAkBC,EAAK,cAAc,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Q,UAAQN,EAAS,KAAKM,EAAQ,MAAM,GAC5CA,EAAQ,UAAQL,EAAQ,KAAKK,EAAQ,MAAM,GAE/CT,EAAO,KAAK,sBAAsB;CAClC,IAAMY,IAAgB9C,EAAK,KAAKmC,EAAQ,MAAM,YAAY,GACpDY,IAAgBhE,EACpB+D,GACAnD,EAAkBmD,CAAa,CACjC;CAGA,AAFIC,KAAeV,EAAS,KAAKU,CAAa,GAE9Cb,EAAO,KAAK,wCAAwC;CACpD,IAAMV,IAAmBxB,EAAK,KAC5BmC,EAAQ,MACR,OACA,UACA,mBACF,GACMa,IAAmBjE,EACvByC,GACAD,EAAyBC,CAAgB,CAC3C;CAKA,IAJIwB,KAAkBX,EAAS,KAAKW,CAAgB,GAIhDA,GAAkB,WAAW,WAAW;EAC1C,IAAMC,IAAW,MAAMhE,EAAekD,CAAO;EAC7C,AAAIc,KAAUb,EAAQ,KAAKa,CAAQ;CACrC;CAKA,KAAK,IAAMC,KAAYtB,EAAgB5B,EAAK,KAAKmC,EAAQ,MAAM,KAAK,CAAC,GAEnE,AADAD,EAAO,KAAK,YAAYlC,EAAK,SAASmC,EAAQ,MAAMe,CAAQ,GAAG,GAC/DZ,EAAQ,KAAKtD,EAAckE,CAAQ,CAAC;CAGtC,EAAO,KAAK,yBAAyB;CACrC,IAAMC,IAAgBnD,EAAK,KAAKmC,EAAQ,MAAM,QAAQ,UAAU,GAC1DiB,IAAgBrE,EACpBoE,GACAvD,EAAkBuD,CAAa,CACjC;CAGA,OAFIC,KAAef,EAAS,KAAKe,CAAa,GAEvC;EACL;EACA;EACA;EACA,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
@@ -1,7 +1,7 @@
1
1
  import { a as e, i as t, n, o as r, r as i, s as a, t as o } from "./dispatch-BxlKS_5v.js";
2
2
  import { t as s } from "./errors-DdSUZI8f.js";
3
3
  import { n as c } from "./logger-t1HxmpG2.js";
4
- import { n as l, r as u } from "./modify-file-CgJIza72.js";
4
+ import { n as l, r as u } from "./modify-file-DvIwtj4o.js";
5
5
  import { t as d } from "./dedent-CCUOcPFW.js";
6
6
  import { _ as f, o as p, r as m } from "./ts-morph-helpers-B4KZXP44.js";
7
7
  import { t as h } from "./svelte-file-DfplF3BU.js";
@@ -323,4 +323,4 @@ async function Z(e) {
323
323
  }
324
324
  export { J as assertPaymentsAppMode, Z as generate };
325
325
 
326
- //# sourceMappingURL=generate.runtime-XT_JQlTk.js.map
326
+ //# sourceMappingURL=generate.runtime-B5SP9iyN.js.map