@velastack/patterns 0.2.11 → 0.3.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 (132) hide show
  1. package/README.md +4 -3
  2. package/dist/chunks/{_layout-D0OmzCu1.js → _layout-DqH4lA_r.js} +8 -8
  3. package/dist/chunks/{_layout-D0OmzCu1.js.map → _layout-DqH4lA_r.js.map} +1 -1
  4. package/dist/chunks/{collections-DDYlpDNO.js → collections-CgdvZXmh.js} +17 -17
  5. package/dist/chunks/{collections-DDYlpDNO.js.map → collections-CgdvZXmh.js.map} +1 -1
  6. package/dist/chunks/compose-handle-Cg9jnCsS.js +322 -0
  7. package/dist/chunks/compose-handle-Cg9jnCsS.js.map +1 -0
  8. package/dist/chunks/{config-target-DOi8kI_f.js → config-target-Co-ij8p3.js} +9 -9
  9. package/dist/chunks/{config-target-DOi8kI_f.js.map → config-target-Co-ij8p3.js.map} +1 -1
  10. package/dist/chunks/dispatch-BRnt8PcW.js +6 -0
  11. package/dist/chunks/dispatch-BRnt8PcW.js.map +1 -0
  12. package/dist/chunks/format-result-Cb2hWsb8.js +64 -0
  13. package/dist/chunks/format-result-Cb2hWsb8.js.map +1 -0
  14. package/dist/chunks/generate-BkQ1xMDp.js +30 -0
  15. package/dist/chunks/generate-BkQ1xMDp.js.map +1 -0
  16. package/dist/chunks/{generate-Va1sxVPG.js → generate-DRA63W0r.js} +17 -64
  17. package/dist/chunks/generate-DRA63W0r.js.map +1 -0
  18. package/dist/chunks/generate-_LvrYK6i.js +55 -0
  19. package/dist/chunks/generate-_LvrYK6i.js.map +1 -0
  20. package/dist/chunks/generate-iQP31-m1.js +252 -0
  21. package/dist/chunks/generate-iQP31-m1.js.map +1 -0
  22. package/dist/chunks/{generate.runtime-Dtf2BI_5.js → generate.runtime-B0hhtyAL.js} +9 -9
  23. package/dist/chunks/{generate.runtime-Dtf2BI_5.js.map → generate.runtime-B0hhtyAL.js.map} +1 -1
  24. package/dist/chunks/generate.runtime-B49wetSx.js +122 -0
  25. package/dist/chunks/generate.runtime-B49wetSx.js.map +1 -0
  26. package/dist/chunks/{generate.runtime-SQhCLSah.js → generate.runtime-B7LRx-BU.js} +13 -13
  27. package/dist/chunks/{generate.runtime-SQhCLSah.js.map → generate.runtime-B7LRx-BU.js.map} +1 -1
  28. package/dist/chunks/generate.runtime-BKo-Nidn.js +38 -0
  29. package/dist/chunks/generate.runtime-BKo-Nidn.js.map +1 -0
  30. package/dist/chunks/{generate.runtime-vTneb2SY.js → generate.runtime-BORbegw_.js} +111 -101
  31. package/dist/chunks/generate.runtime-BORbegw_.js.map +1 -0
  32. package/dist/chunks/{generate.runtime-BtX_9lLk.js → generate.runtime-BbIN0tUZ.js} +34 -34
  33. package/dist/chunks/{generate.runtime-BtX_9lLk.js.map → generate.runtime-BbIN0tUZ.js.map} +1 -1
  34. package/dist/chunks/{generate.runtime-OjW1XETW.js → generate.runtime-BnWE4qsu.js} +42 -42
  35. package/dist/chunks/generate.runtime-BnWE4qsu.js.map +1 -0
  36. package/dist/chunks/{generate.runtime-B_Fk1Jjs.js → generate.runtime-BwhGDnGu.js} +32 -35
  37. package/dist/chunks/generate.runtime-BwhGDnGu.js.map +1 -0
  38. package/dist/chunks/{generate.runtime-BgezGu15.js → generate.runtime-CCg2Pjcv.js} +95 -94
  39. package/dist/chunks/generate.runtime-CCg2Pjcv.js.map +1 -0
  40. package/dist/chunks/{generate.runtime-DRcq4d5D.js → generate.runtime-CRYjWJRe.js} +31 -31
  41. package/dist/chunks/{generate.runtime-DRcq4d5D.js.map → generate.runtime-CRYjWJRe.js.map} +1 -1
  42. package/dist/chunks/generate.runtime-CcuAXuV2.js +60 -0
  43. package/dist/chunks/generate.runtime-CcuAXuV2.js.map +1 -0
  44. package/dist/chunks/{generate.runtime-DK7iXmAZ.js → generate.runtime-D0icLb5j.js} +50 -47
  45. package/dist/chunks/{generate.runtime-DK7iXmAZ.js.map → generate.runtime-D0icLb5j.js.map} +1 -1
  46. package/dist/chunks/{generate.runtime-fSDNxfGG.js → generate.runtime-D2e_KRj0.js} +11 -11
  47. package/dist/chunks/{generate.runtime-fSDNxfGG.js.map → generate.runtime-D2e_KRj0.js.map} +1 -1
  48. package/dist/chunks/{generate.runtime-CycY6kPr.js → generate.runtime-D44gjxRA.js} +102 -99
  49. package/dist/chunks/generate.runtime-D44gjxRA.js.map +1 -0
  50. package/dist/chunks/{generate.runtime-AjCpCfv3.js → generate.runtime-D8vgh5MH.js} +186 -138
  51. package/dist/chunks/generate.runtime-D8vgh5MH.js.map +1 -0
  52. package/dist/chunks/generate.runtime-DAmYsIvF.js +32 -0
  53. package/dist/chunks/generate.runtime-DAmYsIvF.js.map +1 -0
  54. package/dist/chunks/{generate.runtime-B6kxV3Bi.js → generate.runtime-DNaQxed-.js} +45 -45
  55. package/dist/chunks/{generate.runtime-B6kxV3Bi.js.map → generate.runtime-DNaQxed-.js.map} +1 -1
  56. package/dist/chunks/{generate.runtime-CZQoVNt3.js → generate.runtime-DOuufRLr.js} +35 -35
  57. package/dist/chunks/generate.runtime-DOuufRLr.js.map +1 -0
  58. package/dist/chunks/{generate.runtime-BpYOznG5.js → generate.runtime-DSqkXvps.js} +21 -21
  59. package/dist/chunks/{generate.runtime-BpYOznG5.js.map → generate.runtime-DSqkXvps.js.map} +1 -1
  60. package/dist/chunks/{generate.runtime-BYJZB1ad.js → generate.runtime-DhkaXTq3.js} +37 -57
  61. package/dist/chunks/generate.runtime-DhkaXTq3.js.map +1 -0
  62. package/dist/chunks/{generate.runtime-Cq1gqxzg.js → generate.runtime-DoZdSh9W.js} +22 -22
  63. package/dist/chunks/{generate.runtime-Cq1gqxzg.js.map → generate.runtime-DoZdSh9W.js.map} +1 -1
  64. package/dist/chunks/{generate.runtime-qjsxSPaH.js → generate.runtime-S5RIgbQx.js} +102 -99
  65. package/dist/chunks/generate.runtime-S5RIgbQx.js.map +1 -0
  66. package/dist/chunks/generate.runtime-WmSMWL15.js +82 -0
  67. package/dist/chunks/generate.runtime-WmSMWL15.js.map +1 -0
  68. package/dist/chunks/generate.runtime-acRmiU7e.js +81 -0
  69. package/dist/chunks/generate.runtime-acRmiU7e.js.map +1 -0
  70. package/dist/chunks/generate.runtime-flFRYzpi.js +145 -0
  71. package/dist/chunks/generate.runtime-flFRYzpi.js.map +1 -0
  72. package/dist/chunks/generate.runtime-gtpOuLNO.js +110 -0
  73. package/dist/chunks/generate.runtime-gtpOuLNO.js.map +1 -0
  74. package/dist/chunks/{generate.runtime-DHRCNPVx.js → generate.runtime-kLxeDGnS.js} +23 -23
  75. package/dist/chunks/{generate.runtime-DHRCNPVx.js.map → generate.runtime-kLxeDGnS.js.map} +1 -1
  76. package/dist/chunks/{generate.runtime-DH9o-888.js → generate.runtime-wA1G3tQ4.js} +27 -27
  77. package/dist/chunks/{generate.runtime-DH9o-888.js.map → generate.runtime-wA1G3tQ4.js.map} +1 -1
  78. package/dist/chunks/modify-file-GQD6uNgI.js +254 -0
  79. package/dist/chunks/modify-file-GQD6uNgI.js.map +1 -0
  80. package/dist/chunks/{modify-svelte-config-remote-D3eBzcZc.js → modify-svelte-config-remote-CDKs_Qi0.js} +2 -2
  81. package/dist/chunks/{modify-svelte-config-remote-D3eBzcZc.js.map → modify-svelte-config-remote-CDKs_Qi0.js.map} +1 -1
  82. package/dist/chunks/{pocketbase-BerjVikJ.js → pocketbase-CeG5BMN2.js} +57 -50
  83. package/dist/chunks/{pocketbase-BerjVikJ.js.map → pocketbase-CeG5BMN2.js.map} +1 -1
  84. package/dist/chunks/providers-DO9kMyzB.js +69 -0
  85. package/dist/chunks/providers-DO9kMyzB.js.map +1 -0
  86. package/dist/chunks/rolldown-runtime-DArdT4gl.js +23 -0
  87. package/dist/chunks/{shared-Cmbzu7Od.js → shared-BwHQM-a9.js} +2 -2
  88. package/dist/chunks/{shared-Cmbzu7Od.js.map → shared-BwHQM-a9.js.map} +1 -1
  89. package/dist/chunks/site-D027dpBm.js +55 -0
  90. package/dist/chunks/site-D027dpBm.js.map +1 -0
  91. package/dist/chunks/svelte-file-B3RfgVdt.js +123 -0
  92. package/dist/chunks/svelte-file-B3RfgVdt.js.map +1 -0
  93. package/dist/chunks/{test-setup-DjbhQYZC.js → test-setup-B2hd8I-s.js} +15 -15
  94. package/dist/chunks/{test-setup-DjbhQYZC.js.map → test-setup-B2hd8I-s.js.map} +1 -1
  95. package/dist/chunks/{ui-BdkuOXPw.js → ui-B4Tuit-7.js} +12 -12
  96. package/dist/chunks/{ui-BdkuOXPw.js.map → ui-B4Tuit-7.js.map} +1 -1
  97. package/dist/chunks/ui-jhXrsw4T.js +12 -0
  98. package/dist/chunks/ui-jhXrsw4T.js.map +1 -0
  99. package/dist/chunks/{write-result-BVWPlGvE.js → write-result-DewHCNhM.js} +51 -51
  100. package/dist/chunks/{write-result-BVWPlGvE.js.map → write-result-DewHCNhM.js.map} +1 -1
  101. package/dist/index.d.ts +272 -65
  102. package/dist/index.js +2279 -2268
  103. package/dist/index.js.map +1 -1
  104. package/package.json +1 -1
  105. package/dist/chunks/dispatch-B5PfQ2CA.js +0 -6
  106. package/dist/chunks/dispatch-B5PfQ2CA.js.map +0 -1
  107. package/dist/chunks/format-result-BdAy5M8C.js +0 -50
  108. package/dist/chunks/format-result-BdAy5M8C.js.map +0 -1
  109. package/dist/chunks/generate-Va1sxVPG.js.map +0 -1
  110. package/dist/chunks/generate.runtime-AjCpCfv3.js.map +0 -1
  111. package/dist/chunks/generate.runtime-BYJZB1ad.js.map +0 -1
  112. package/dist/chunks/generate.runtime-B_Fk1Jjs.js.map +0 -1
  113. package/dist/chunks/generate.runtime-BcVAKzoY.js +0 -138
  114. package/dist/chunks/generate.runtime-BcVAKzoY.js.map +0 -1
  115. package/dist/chunks/generate.runtime-BgezGu15.js.map +0 -1
  116. package/dist/chunks/generate.runtime-CTiJEVF2.js +0 -107
  117. package/dist/chunks/generate.runtime-CTiJEVF2.js.map +0 -1
  118. package/dist/chunks/generate.runtime-CZQoVNt3.js.map +0 -1
  119. package/dist/chunks/generate.runtime-CycY6kPr.js.map +0 -1
  120. package/dist/chunks/generate.runtime-D2WfvXm2.js +0 -106
  121. package/dist/chunks/generate.runtime-D2WfvXm2.js.map +0 -1
  122. package/dist/chunks/generate.runtime-DEl6b1Ti.js +0 -87
  123. package/dist/chunks/generate.runtime-DEl6b1Ti.js.map +0 -1
  124. package/dist/chunks/generate.runtime-DaPNrIyg.js +0 -28
  125. package/dist/chunks/generate.runtime-DaPNrIyg.js.map +0 -1
  126. package/dist/chunks/generate.runtime-OjW1XETW.js.map +0 -1
  127. package/dist/chunks/generate.runtime-qjsxSPaH.js.map +0 -1
  128. package/dist/chunks/generate.runtime-vTneb2SY.js.map +0 -1
  129. package/dist/chunks/modify-file-Cgu_WeFk.js +0 -22
  130. package/dist/chunks/modify-file-Cgu_WeFk.js.map +0 -1
  131. package/dist/chunks/ts-morph-helpers-teS3yXg-.js +0 -229
  132. package/dist/chunks/ts-morph-helpers-teS3yXg-.js.map +0 -1
@@ -1,11 +1,11 @@
1
1
  import { t as e } from "./dedent-Gq6Krl4n.js";
2
2
  import { n as t } from "./logger-CQONztPm.js";
3
3
  import { n } from "./generate-tOkjJFUf.js";
4
- import { modifyOutcomeToFile as r } from "./modify-file-Cgu_WeFk.js";
5
- import { c as i, l as a, r as o } from "./ts-morph-helpers-teS3yXg-.js";
6
- import { a as s, t as c } from "./config-target-DOi8kI_f.js";
7
- import l from "node:path";
8
- import u from "node:fs";
4
+ import { h as r, modifyOutcomeToFile as i, r as a } from "./modify-file-GQD6uNgI.js";
5
+ import { t as o } from "./svelte-file-B3RfgVdt.js";
6
+ import { a as s, t as c } from "./config-target-Co-ij8p3.js";
7
+ import l from "node:fs";
8
+ import u from "node:path";
9
9
  import { Node as d, Project as f, QuoteKind as p, SyntaxKind as m } from "ts-morph";
10
10
  //#region src/patterns/enable/cms/modifies/vite-config.ts
11
11
  var h = [
@@ -32,7 +32,7 @@ function _(e) {
32
32
  }
33
33
  function v(e, t = "") {
34
34
  let n = `cms(${t})`;
35
- if (!u.existsSync(e)) return {
35
+ if (!l.existsSync(e)) return {
36
36
  status: "not-found",
37
37
  message: g
38
38
  };
@@ -199,11 +199,11 @@ var F = [
199
199
  "`event` with the destructuring moved into the body."
200
200
  ].join("\n");
201
201
  function I(e, t = A) {
202
- if (!u.existsSync(e)) return u.mkdirSync(l.dirname(e), { recursive: !0 }), u.writeFileSync(e, P(t)), {
202
+ if (!l.existsSync(e)) return l.mkdirSync(u.dirname(e), { recursive: !0 }), l.writeFileSync(e, P(t)), {
203
203
  status: "success",
204
204
  changed: !0
205
205
  };
206
- if (u.readFileSync(e, "utf8").includes("loadCms(")) return {
206
+ if (l.readFileSync(e, "utf8").includes("loadCms(")) return {
207
207
  status: "success",
208
208
  changed: !1
209
209
  };
@@ -232,7 +232,7 @@ function I(e, t = A) {
232
232
  let e = s.getProperties().findIndex((e) => d.isSpreadAssignment(e));
233
233
  e === -1 ? s.addShorthandPropertyAssignment({ name: "cms" }) : s.insertShorthandPropertyAssignment(e, { name: "cms" });
234
234
  }
235
- let f = i.getStatements().indexOf(o);
235
+ let f = i.getStatementsWithComments().indexOf(o);
236
236
  if (i.insertStatements(f, `\n${M(c, t.expression(c))}\n`), a.kind === "binding") {
237
237
  let e = a.pattern.getText();
238
238
  i.insertStatements(0, `const ${e} = ${c};`);
@@ -258,7 +258,7 @@ var L = e`
258
258
  };
259
259
  `;
260
260
  function R(e) {
261
- if (!u.existsSync(e)) return {
261
+ if (!l.existsSync(e)) return {
262
262
  status: "success",
263
263
  changed: !1
264
264
  };
@@ -331,17 +331,17 @@ var z = e`
331
331
  B.trim()
332
332
  ].join("\n");
333
333
  function U(e) {
334
- if (!u.existsSync(e)) return {
334
+ if (!l.existsSync(e)) return {
335
335
  status: "not-found",
336
336
  message: V
337
337
  };
338
- let t = a.fromPath(e);
338
+ let t = o.fromPath(e);
339
339
  return t.hasElement("AdminBar") ? {
340
340
  status: "success",
341
341
  changed: !1
342
342
  } : t.getScript() ? (t.modifyScript((e) => {
343
- let { source: t } = i(e, (e) => {
344
- o(e, [{
343
+ let { source: t } = r(e, (e) => {
344
+ a(e, [{
345
345
  namedImports: ["AdminBar"],
346
346
  moduleSpecifier: "@velastack/cms"
347
347
  }]);
@@ -357,35 +357,32 @@ function U(e) {
357
357
  }
358
358
  //#endregion
359
359
  //#region src/patterns/enable/cms/generate.runtime.ts
360
- function W(e, t) {
361
- return e.filter((e) => !u.existsSync(l.join(t, e.path)));
362
- }
363
- function G(e) {
364
- let t = l.join(e, "wuchale.config.js");
365
- if (!u.existsSync(t)) return null;
366
- let n = u.readFileSync(t, "utf8").match(/locales:\s*\[([^\]]*)\]/);
360
+ function W(e) {
361
+ let t = u.join(e, "wuchale.config.js");
362
+ if (!l.existsSync(t)) return null;
363
+ let n = l.readFileSync(t, "utf8").match(/locales:\s*\[([^\]]*)\]/);
367
364
  if (!n) return null;
368
365
  let r = [...n[1].matchAll(/['"]([^'"]+)['"]/g)].map((e) => e[1]);
369
366
  return r.length > 0 ? r : null;
370
367
  }
371
- function K(e, t) {
368
+ function G(e, t) {
372
369
  if (e.local) return "";
373
370
  let n = t.map((e) => `'${e}'`).join(", ");
374
371
  return `{ endpoint: '${e.endpoint}', locales: [${n}] }`;
375
372
  }
376
- async function q(e) {
377
- let i = t(e), a = [], o = n(e), u = e.features.i18n, d = (e) => {
373
+ async function K(e) {
374
+ let r = t(e), a = [], o = n(e), l = e.features.i18n, d = (e) => {
378
375
  e && a.push(e);
379
376
  };
380
- i.info("Modifying vite.config");
381
- let f = s(e.root, c) ?? l.join(e.root, c[0]), p = u && G(e.root) || ["en"];
382
- d(r(f, v(f, K(o, p)))), i.info("Modifying src/routes/+layout.server.ts");
383
- let m = l.join(e.root, "src", "routes", "+layout.server.ts");
384
- d(r(m, I(m, u ? j : A))), i.info("Modifying src/routes/+layout.ts");
385
- let h = l.join(e.root, "src", "routes", "+layout.ts");
386
- d(r(h, R(h))), i.info("Modifying src/routes/+layout.svelte");
387
- let g = l.join(e.root, "src", "routes", "+layout.svelte");
388
- return d(r(g, U(g))), {
377
+ r.info("Modifying vite.config");
378
+ let f = s(e.root, c) ?? u.join(e.root, c[0]), p = l && W(e.root) || ["en"];
379
+ d(i(f, v(f, G(o, p)))), r.info("Modifying src/routes/+layout.server.ts");
380
+ let m = u.join(e.root, "src", "routes", "+layout.server.ts");
381
+ d(i(m, I(m, l ? j : A))), r.info("Modifying src/routes/+layout.ts");
382
+ let h = u.join(e.root, "src", "routes", "+layout.ts");
383
+ d(i(h, R(h))), r.info("Modifying src/routes/+layout.svelte");
384
+ let g = u.join(e.root, "src", "routes", "+layout.svelte");
385
+ return d(i(g, U(g))), {
389
386
  creates: [],
390
387
  modifies: a,
391
388
  deletes: [],
@@ -397,6 +394,6 @@ async function q(e) {
397
394
  };
398
395
  }
399
396
  //#endregion
400
- export { q as generate, W as keepMissing };
397
+ export { K as generate };
401
398
 
402
- //# sourceMappingURL=generate.runtime-B_Fk1Jjs.js.map
399
+ //# sourceMappingURL=generate.runtime-BwhGDnGu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.runtime-BwhGDnGu.js","names":[],"sources":["../../src/patterns/enable/cms/modifies/vite-config.ts","../../src/patterns/enable/cms/modifies/load-function.ts","../../src/patterns/enable/cms/modifies/layout.server.ts","../../src/patterns/enable/cms/modifies/layout.ts","../../src/patterns/enable/cms/modifies/layout.svelte.ts","../../src/patterns/enable/cms/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport {\n Project,\n QuoteKind,\n SyntaxKind,\n type ArrayLiteralExpression,\n type ObjectLiteralExpression,\n type PropertyAssignment,\n} from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst FAILURE_HINT = [\n \"Add the CMS plugin to your Vite config, ahead of sveltekit():\",\n \"\",\n \"import { cms } from '@velastack/cms/vite';\",\n \"\",\n \"export default defineConfig({\",\n \" plugins: [cms(), sveltekit(), /* ...existing plugins */],\",\n \"});\",\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create a Vite config with the CMS plugin ahead of sveltekit():\",\n \"\",\n \"import { defineConfig } from 'vite';\",\n \"import { sveltekit } from '@sveltejs/kit/vite';\",\n \"import { cms } from '@velastack/cms/vite';\",\n \"\",\n \"export default defineConfig({\",\n \" plugins: [cms(), sveltekit()],\",\n \"});\",\n].join(\"\\n\");\n\nfunction elementName(text: string): string {\n return text.replace(/\\s/g, \"\");\n}\n\n/**\n * Registers `cms(...)` from `@velastack/cms/vite` in the Vite plugin list, just\n * ahead of `sveltekit()`. Only the plugin array is touched, so the inline\n * `sveltekit({ ... })` shape the templates use is left alone.\n */\nexport function modifyViteConfig(\n viteConfigPath: string,\n pluginArgs = \"\",\n): ModifyOutcome {\n const call = `cms(${pluginArgs})`;\n if (!fs.existsSync(viteConfigPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const project = new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(viteConfigPath);\n\n let changed = false;\n let failed = false;\n\n const hasImport = sourceFile\n .getImportDeclarations()\n .some((d) => d.getModuleSpecifierValue() === \"@velastack/cms/vite\");\n\n if (!hasImport) {\n sourceFile.insertImportDeclaration(0, {\n namedImports: [\"cms\"],\n moduleSpecifier: \"@velastack/cms/vite\",\n });\n changed = true;\n }\n\n const defineConfigCall = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((ce) => ce.getExpression().getText() === \"defineConfig\");\n\n const configArg = defineConfigCall?.getArguments()?.[0];\n const configObj =\n configArg?.getKind() === SyntaxKind.ObjectLiteralExpression\n ? (configArg as ObjectLiteralExpression)\n : null;\n\n if (!configObj) {\n failed = true;\n } else {\n const pluginsProp = configObj.getProperty(\"plugins\");\n if (!pluginsProp) {\n configObj.addPropertyAssignment({\n name: \"plugins\",\n initializer: `[${call}]`,\n });\n changed = true;\n } else if (pluginsProp.getKind() !== SyntaxKind.PropertyAssignment) {\n failed = true;\n } else {\n const pluginsInit = (pluginsProp as PropertyAssignment).getInitializer();\n\n if (!pluginsInit) {\n (pluginsProp as PropertyAssignment).setInitializer(`[${call}]`);\n changed = true;\n } else if (pluginsInit.getKind() !== SyntaxKind.ArrayLiteralExpression) {\n failed = true;\n } else {\n const arr = pluginsInit as ArrayLiteralExpression;\n const elements = arr.getElements();\n const hasCms = elements.some((el) =>\n elementName(el.getText()).startsWith(\"cms(\"),\n );\n\n if (!hasCms) {\n const sveltekitIndex = elements.findIndex((el) =>\n elementName(el.getText()).startsWith(\"sveltekit(\"),\n );\n arr.insertElement(sveltekitIndex === -1 ? 0 : sveltekitIndex, call);\n changed = true;\n }\n }\n }\n }\n\n if (changed) {\n sourceFile.formatText();\n sourceFile.saveSync();\n }\n\n if (failed) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n return { status: \"success\", changed };\n}\n","import {\n Node,\n Project,\n QuoteKind,\n SyntaxKind,\n type ArrowFunction,\n type Block,\n type FunctionDeclaration,\n type FunctionExpression,\n type ObjectLiteralExpression,\n type ParameterDeclaration,\n type ReturnStatement,\n type SourceFile,\n} from \"ts-morph\";\nimport type { ImportSpec } from \"../../../../runtime/ts-morph-helpers\";\n\n/**\n * What the two layout modifiers have in common: finding a SvelteKit `load`,\n * working out how it receives its event, and locating the object it returns.\n */\n\nexport type LoadFunction =\n ArrowFunction | FunctionExpression | FunctionDeclaration;\n\nexport function newProject(): Project {\n return new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n}\n\nexport function ensureNamedImports(\n sourceFile: SourceFile,\n moduleSpecifier: string,\n names: string[],\n) {\n const existing = sourceFile\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === moduleSpecifier);\n if (!existing) {\n sourceFile.addImportDeclaration({ namedImports: names, moduleSpecifier });\n return;\n }\n for (const name of names) {\n const has = existing.getNamedImports().some((ni) => ni.getName() === name);\n if (!has) existing.addNamedImport(name);\n }\n}\n\nexport function ensureImportSpec(sourceFile: SourceFile, spec: ImportSpec) {\n if (spec.namedImports?.length) {\n ensureNamedImports(sourceFile, spec.moduleSpecifier, spec.namedImports);\n }\n const existing = sourceFile\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === spec.moduleSpecifier);\n if (existing) return;\n sourceFile.addImportDeclaration({\n moduleSpecifier: spec.moduleSpecifier,\n defaultImport: spec.defaultImport,\n namespaceImport: spec.namespaceImport,\n });\n}\n\n/** Peel wrappers (`loadFlash(fn)`, `(fn)`, `fn satisfies X`) down to the function. */\nfunction unwrapFunction(node: Node): ArrowFunction | FunctionExpression | null {\n if (Node.isArrowFunction(node) || Node.isFunctionExpression(node)) {\n return node;\n }\n if (\n Node.isParenthesizedExpression(node) ||\n Node.isAsExpression(node) ||\n Node.isSatisfiesExpression(node)\n ) {\n return unwrapFunction(node.getExpression());\n }\n if (Node.isCallExpression(node)) {\n for (const arg of node.getArguments()) {\n const fn = unwrapFunction(arg);\n if (fn) return fn;\n }\n }\n return null;\n}\n\n/** The exported `load`, whether declared as a function or wrapped in a const. */\nexport function findLoadFunction(sourceFile: SourceFile): LoadFunction | null {\n const declaration = sourceFile.getFunction(\"load\");\n if (declaration) {\n return declaration.isExported() ? declaration : null;\n }\n\n const variable = sourceFile.getVariableDeclaration(\"load\");\n if (!variable) return null;\n if (!variable.getVariableStatement()?.isExported()) return null;\n\n const initializer = variable.getInitializer();\n return initializer ? unwrapFunction(initializer) : null;\n}\n\nfunction isFunctionNode(node: Node): boolean {\n return (\n Node.isArrowFunction(node) ||\n Node.isFunctionExpression(node) ||\n Node.isFunctionDeclaration(node) ||\n Node.isMethodDeclaration(node)\n );\n}\n\n/**\n * The single, final `return <expression>` of the load body, or null when the\n * body has early returns — those would need any insertion hoisted above them,\n * and guessing where is worse than refusing.\n */\nexport function findFinalReturn(\n fn: LoadFunction,\n body: Block,\n): ReturnStatement | null {\n const statements = body.getStatements();\n const last = statements[statements.length - 1];\n if (!last || !Node.isReturnStatement(last)) return null;\n\n const returns = body\n .getDescendantsOfKind(SyntaxKind.ReturnStatement)\n .filter((r) => r.getFirstAncestor(isFunctionNode) === fn);\n if (returns.length !== 1) return null;\n\n return last;\n}\n\n/** The object literal a return statement yields, unwrapping parentheses. */\nexport function returnedObject(\n statement: ReturnStatement,\n): ObjectLiteralExpression | null {\n let expression = statement.getExpression();\n while (expression && Node.isParenthesizedExpression(expression)) {\n expression = expression.getExpression();\n }\n if (!expression || !Node.isObjectLiteralExpression(expression)) return null;\n return expression;\n}\n\nexport function hasProperty(\n object: ObjectLiteralExpression,\n name: string,\n): boolean {\n return object.getProperties().some((property) => {\n if (\n Node.isPropertyAssignment(property) ||\n Node.isShorthandPropertyAssignment(property)\n ) {\n return property.getName() === name;\n }\n return false;\n });\n}\n\nexport function hasSpreadOf(\n object: ObjectLiteralExpression,\n expressionText: string,\n): boolean {\n return object\n .getProperties()\n .some(\n (property) =>\n Node.isSpreadAssignment(property) &&\n property.getExpression().getText() === expressionText,\n );\n}\n\n/** How a load receives its event: not at all, by name, or destructured. */\nexport type EventParameter =\n | { kind: \"none\" }\n | { kind: \"identifier\"; name: string; param: ParameterDeclaration }\n | {\n kind: \"binding\";\n pattern: import(\"ts-morph\").ObjectBindingPattern;\n param: ParameterDeclaration;\n }\n | { kind: \"unsupported\" };\n\nexport function inspectEventParameter(fn: LoadFunction): EventParameter {\n const params = fn.getParameters();\n if (params.length === 0) return { kind: \"none\" };\n if (params.length > 1) return { kind: \"unsupported\" };\n\n const param = params[0];\n if (param.getInitializer() || param.isRestParameter()) {\n return { kind: \"unsupported\" };\n }\n const nameNode = param.getNameNode();\n if (Node.isIdentifier(nameNode)) {\n return { kind: \"identifier\", name: nameNode.getText(), param };\n }\n if (Node.isObjectBindingPattern(nameNode)) {\n return { kind: \"binding\", pattern: nameNode, param };\n }\n return { kind: \"unsupported\" };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport dedent from \"dedent\";\nimport { Node } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport type { ImportSpec } from \"../../../../runtime/ts-morph-helpers\";\nimport {\n ensureImportSpec,\n ensureNamedImports,\n findFinalReturn,\n findLoadFunction,\n hasProperty,\n inspectEventParameter,\n newProject,\n returnedObject,\n} from \"./load-function\";\n\nexport interface LayoutServerLocale {\n /**\n * Expression passed as `locale` to `loadCms`, given the name of the load's\n * event parameter: `() => \"'en'\"` or `(event) => \\`getLocale(${event}.url)\\``.\n */\n expression: (eventName: string) => string;\n /** Imports the expression depends on. */\n imports?: ImportSpec[];\n}\n\n/** A single-locale site: the literal default locale. */\nexport const DEFAULT_LOCALE: LayoutServerLocale = {\n expression: () => \"'en'\",\n};\n\n/** A wuchale site: the locale enable-i18n's reroute already resolved from the URL. */\nexport const WUCHALE_LOCALE: LayoutServerLocale = {\n expression: (eventName) => `getLocale(${eventName}.url)`,\n imports: [\n { namedImports: [\"getLocale\"], moduleSpecifier: \"$locales/main.url\" },\n ],\n};\n\nfunction cmsSnippet(eventName: string, locale: string): string {\n return dedent`\n const { cms, notFound, gone, redirectTo } = await loadCms(${eventName}, { locale: ${locale} });\n if (redirectTo) redirect(308, redirectTo);\n if (gone) error(410, 'Gone');\n if (notFound) error(404, 'Not found');\n `;\n}\n\nfunction importLine(spec: ImportSpec): string {\n const parts: string[] = [];\n if (spec.defaultImport) parts.push(spec.defaultImport);\n if (spec.namespaceImport) parts.push(`* as ${spec.namespaceImport}`);\n if (spec.namedImports?.length)\n parts.push(`{ ${spec.namedImports.join(\", \")} }`);\n return `import ${parts.join(\", \")} from '${spec.moduleSpecifier}';`;\n}\n\n/**\n * A root `+layout.server.ts` written from scratch, for a project that has\n * none — the static template keeps its layout load universal.\n */\nexport function createdLayoutServer(locale: LayoutServerLocale): string {\n const imports = [\n \"import { error, redirect } from '@sveltejs/kit';\",\n \"import { loadCms } from '$lib/cms';\",\n ...(locale.imports ?? []).map(importLine),\n \"import type { LayoutServerLoad } from './$types';\",\n ].join(\"\\n\");\n const snippet = cmsSnippet(\"event\", locale.expression(\"event\"))\n .split(\"\\n\")\n .join(\"\\n\\t\");\n\n return dedent`\n ${imports}\n\n export const load: LayoutServerLoad = async (event) => {\n \t${snippet}\n\n \treturn { cms };\n };\n `.concat(\"\\n\");\n}\n\nconst FAILURE_HINT = [\n \"Call loadCms from the root +layout.server.ts load and return `cms`:\",\n \"\",\n createdLayoutServer(DEFAULT_LOCALE).trimEnd(),\n \"\",\n \"loadCms needs the whole event, so a destructured parameter has to become\",\n \"`event` with the destructuring moved into the body.\",\n].join(\"\\n\");\n\n/**\n * Wires `loadCms` into the root `+layout.server.ts`, creating the file when\n * the project has none:\n *\n * - `loadCms` needs the whole request event, so a destructured parameter is\n * renamed to `event` and the destructuring becomes the first statement.\n * - The tombstone triple (`redirectTo`, `gone`, `notFound`) is handled just\n * before the return.\n * - `cms` is added to the returned object, ahead of any spread so nothing\n * later can shadow it.\n *\n * Anything else — no exported `load`, an expression-bodied arrow, several\n * returns, a non-literal return — is reported as `failed` with the snippet to\n * paste, and the file is left exactly as it was.\n */\nexport function modifyLayoutServer(\n layoutServerPath: string,\n locale: LayoutServerLocale = DEFAULT_LOCALE,\n): ModifyOutcome {\n if (!fs.existsSync(layoutServerPath)) {\n fs.mkdirSync(path.dirname(layoutServerPath), { recursive: true });\n fs.writeFileSync(layoutServerPath, createdLayoutServer(locale));\n return { status: \"success\", changed: true };\n }\n\n const original = fs.readFileSync(layoutServerPath, \"utf8\");\n if (original.includes(\"loadCms(\")) {\n return { status: \"success\", changed: false };\n }\n\n const sourceFile = newProject().addSourceFileAtPath(layoutServerPath);\n\n // --- Inspect everything before touching anything. ---\n const fn = findLoadFunction(sourceFile);\n if (!fn) return { status: \"failed\", message: FAILURE_HINT };\n\n const body = fn.getBody();\n if (!body || !Node.isBlock(body)) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const event = inspectEventParameter(fn);\n if (event.kind === \"unsupported\") {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const returned = findFinalReturn(fn, body);\n const object = returned && returnedObject(returned);\n if (!returned || !object) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const eventName = event.kind === \"identifier\" ? event.name : \"event\";\n\n // --- Mutate bottom-up so earlier node references stay valid. ---\n if (!hasProperty(object, \"cms\")) {\n const spreadIndex = object\n .getProperties()\n .findIndex((property) => Node.isSpreadAssignment(property));\n if (spreadIndex === -1) {\n object.addShorthandPropertyAssignment({ name: \"cms\" });\n } else {\n object.insertShorthandPropertyAssignment(spreadIndex, { name: \"cms\" });\n }\n }\n\n // insertStatements counts comment lines, which getStatements() skips.\n const returnIndex = body.getStatementsWithComments().indexOf(returned);\n body.insertStatements(\n returnIndex,\n `\\n${cmsSnippet(eventName, locale.expression(eventName))}\\n`,\n );\n\n if (event.kind === \"binding\") {\n const destructuring = event.pattern.getText();\n body.insertStatements(0, `const ${destructuring} = ${eventName};`);\n const typeText = event.param.getTypeNode()?.getText();\n event.param.replaceWithText(\n typeText ? `${eventName}: ${typeText}` : eventName,\n );\n } else if (event.kind === \"none\") {\n fn.addParameter({ name: eventName });\n }\n\n if (!fn.isAsync()) fn.setIsAsync(true);\n\n ensureNamedImports(sourceFile, \"@sveltejs/kit\", [\"error\", \"redirect\"]);\n ensureNamedImports(sourceFile, \"$lib/cms\", [\"loadCms\"]);\n for (const spec of locale.imports ?? []) {\n ensureImportSpec(sourceFile, spec);\n }\n\n sourceFile.formatText();\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Node } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport {\n findFinalReturn,\n findLoadFunction,\n hasSpreadOf,\n inspectEventParameter,\n newProject,\n returnedObject,\n} from \"./load-function\";\n\nconst FAILURE_HINT = dedent`\n Forward the server load's data through the root +layout.ts, so \\`cms\\` reaches\n the page:\n\n export const load = async ({ url, data }) => {\n // ...existing code...\n return { ...data, /* existing keys */ };\n };\n`;\n\n/**\n * Make a universal root \\`+layout.ts\\` forward its server load's data.\n *\n * SvelteKit hands a universal load the server load's result as \\`data\\`, and\n * only what the universal load returns reaches the page. A layout that\n * returns its own object without spreading \\`data\\` — the static template\n * does — would drop \\`cms\\` on the floor once \\`+layout.server.ts\\` exists.\n *\n * No file, or a file without a \\`load\\`, needs nothing: server data flows\n * through on its own.\n */\nexport function modifyLayoutUniversal(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"success\", changed: false };\n }\n\n const sourceFile = newProject().addSourceFileAtPath(layoutPath);\n\n const fn = findLoadFunction(sourceFile);\n if (!fn) return { status: \"success\", changed: false };\n\n const body = fn.getBody();\n if (!body || !Node.isBlock(body)) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const event = inspectEventParameter(fn);\n if (event.kind === \"unsupported\") {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const returned = findFinalReturn(fn, body);\n if (!returned) return { status: \"failed\", message: FAILURE_HINT };\n\n const dataExpression =\n event.kind === \"identifier\" ? `${event.name}.data` : \"data\";\n\n // `return data;` already forwards everything.\n const expression = returned.getExpression();\n if (expression && expression.getText() === dataExpression) {\n return { status: \"success\", changed: false };\n }\n\n const object = returnedObject(returned);\n if (!object) return { status: \"failed\", message: FAILURE_HINT };\n if (hasSpreadOf(object, dataExpression)) {\n return { status: \"success\", changed: false };\n }\n\n // --- Mutate bottom-up so earlier node references stay valid. ---\n // First, so the layout's own keys still win over anything the server sent.\n object.insertSpreadAssignment(0, { expression: dataExpression });\n\n if (event.kind === \"binding\") {\n const hasData = event.pattern\n .getElements()\n .some((element) => element.getName() === \"data\");\n if (!hasData) {\n const text = event.pattern.getText();\n event.pattern.replaceWithText(text.replace(/^\\{\\s*/, \"{ data, \"));\n }\n } else if (event.kind === \"none\") {\n fn.addParameter({ name: \"{ data }\" });\n }\n\n sourceFile.formatText();\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n ensureImports,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst IMPORT_SNIPPET = dedent`\n import { AdminBar } from '@velastack/cms';\n`;\n\nconst MARKUP_SNIPPET = \"\\n<AdminBar />\\n\";\n\nconst NOT_FOUND_HINT = [\n \"Create the root src/routes/+layout.svelte and mount <AdminBar /> inside it.\",\n \"\",\n \"Import for the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup to add at the top level of the layout, above {@render children()}:\",\n MARKUP_SNIPPET.trim(),\n].join(\"\\n\");\n\nconst FAILURE_HINT = [\n \"Mount <AdminBar /> in the root src/routes/+layout.svelte.\",\n \"\",\n 'Import for a <script lang=\"ts\"> tag:',\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup to add at the top level of the layout, above {@render children()}:\",\n MARKUP_SNIPPET.trim(),\n].join(\"\\n\");\n\n/**\n * Mounts `<AdminBar />` at the top level of the root layout, ahead of\n * `{@render children()}` so the bar is in the DOM before the page content.\n * Falls back to appending when the layout has no render tag or slot.\n */\nexport function modifyLayoutSvelte(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const file = SvelteFile.fromPath(layoutPath);\n if (file.hasElement(\"AdminBar\")) {\n return { status: \"success\", changed: false };\n }\n if (!file.getScript()) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n ensureImports(sf, [\n { namedImports: [\"AdminBar\"], moduleSpecifier: \"@velastack/cms\" },\n ]);\n });\n return out;\n });\n\n if (!file.insertBeforeChildren(MARKUP_SNIPPET)) {\n file.appendMarkup(MARKUP_SNIPPET);\n }\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport {\n probeFirstExisting,\n VITE_CONFIG_CANDIDATES,\n} from \"../../../runtime/config-target\";\nimport { resolveMode, type CmsMode } from \"./generate\";\nimport { modifyViteConfig } from \"./modifies/vite-config\";\nimport {\n DEFAULT_LOCALE,\n WUCHALE_LOCALE,\n modifyLayoutServer,\n} from \"./modifies/layout.server\";\nimport { modifyLayoutUniversal } from \"./modifies/layout\";\nimport { modifyLayoutSvelte } from \"./modifies/layout.svelte\";\n\n/** The locale list from `wuchale.config.js`, or null when it cannot be read. */\nexport function readWuchaleLocales(root: string): string[] | null {\n const configPath = path.join(root, \"wuchale.config.js\");\n if (!fs.existsSync(configPath)) return null;\n const match = fs\n .readFileSync(configPath, \"utf8\")\n .match(/locales:\\s*\\[([^\\]]*)\\]/);\n if (!match) return null;\n const locales = [...match[1].matchAll(/['\"]([^'\"]+)['\"]/g)].map((m) => m[1]);\n return locales.length > 0 ? locales : null;\n}\n\n/**\n * Arguments for the `cms()` Vite plugin.\n *\n * A hosted CMS needs the endpoint and locales at build time so media can be\n * downloaded into the prerendered site. An app hosting the backend itself\n * needs nothing: the media steps are no-ops without an endpoint.\n */\nexport function vitePluginArgs(mode: CmsMode, locales: string[]): string {\n if (mode.local) return \"\";\n const list = locales.map((locale) => `'${locale}'`).join(\", \");\n return `{ endpoint: '${mode.endpoint}', locales: [${list}] }`;\n}\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n const mode = resolveMode(options);\n const i18n = options.features.i18n;\n\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Modifying vite.config\");\n const viteConfigPath =\n probeFirstExisting(options.root, VITE_CONFIG_CANDIDATES) ??\n path.join(options.root, VITE_CONFIG_CANDIDATES[0]);\n const locales = (i18n && readWuchaleLocales(options.root)) || [\"en\"];\n pushResult(\n modifyOutcomeToFile(\n viteConfigPath,\n modifyViteConfig(viteConfigPath, vitePluginArgs(mode, locales)),\n ),\n );\n\n logger.info(\"Modifying src/routes/+layout.server.ts\");\n const layoutServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.server.ts\",\n );\n const locale = i18n ? WUCHALE_LOCALE : DEFAULT_LOCALE;\n pushResult(\n modifyOutcomeToFile(\n layoutServerPath,\n modifyLayoutServer(layoutServerPath, locale),\n ),\n );\n\n // A universal root layout has to pass the server load's data along, or\n // `cms` never reaches the page. The static template has one.\n logger.info(\"Modifying src/routes/+layout.ts\");\n const layoutUniversalPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n layoutUniversalPath,\n modifyLayoutUniversal(layoutUniversalPath),\n ),\n );\n\n logger.info(\"Modifying src/routes/+layout.svelte\");\n const layoutSveltePath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(layoutSveltePath, modifyLayoutSvelte(layoutSveltePath)),\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":";;;;;;;;;;AAWA,IAAM,IAAe;CACnB;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,CAAC,KAAK,IAAI,GAEL,IAAiB;CACrB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,CAAC,KAAK,IAAI;AAEX,SAAS,EAAY,GAAsB;CACzC,OAAO,EAAK,QAAQ,OAAO,EAAE;AAC/B;AAOA,SAAgB,EACd,GACA,IAAa,IACE;CACf,IAAM,IAAO,OAAO,EAAW;CAC/B,IAAI,CAAC,EAAG,WAAW,CAAc,GAC/B,OAAO;EAAE,QAAQ;EAAa,SAAS;CAA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3D;AAEA,eAAsB,EAAS,GAAkB;CAC/C,IAAM,IAAS,EAAU,CAAO,GAC1B,IAAmB,CAAC,GACpB,IAAO,EAAY,CAAO,GAC1B,IAAO,EAAQ,SAAS,MAExB,KAAc,MAAsB;EACxC,AAAI,KAAM,EAAS,KAAK,CAAI;CAC9B;CAEA,EAAO,KAAK,uBAAuB;CACnC,IAAM,IACJ,EAAmB,EAAQ,MAAM,CAAsB,KACvD,EAAK,KAAK,EAAQ,MAAM,EAAuB,EAAE,GAC7C,IAAW,KAAQ,EAAmB,EAAQ,IAAI,KAAM,CAAC,IAAI;CAQnE,AAPA,EACE,EACE,GACA,EAAiB,GAAgB,EAAe,GAAM,CAAO,CAAC,CAChE,CACF,GAEA,EAAO,KAAK,wCAAwC;CACpD,IAAM,IAAmB,EAAK,KAC5B,EAAQ,MACR,OACA,UACA,mBACF;CAWA,AATA,EACE,EACE,GACA,EAAmB,GAJR,IAAO,IAAiB,CAIQ,CAC7C,CACF,GAIA,EAAO,KAAK,iCAAiC;CAC7C,IAAM,IAAsB,EAAK,KAC/B,EAAQ,MACR,OACA,UACA,YACF;CAQA,AAPA,EACE,EACE,GACA,EAAsB,CAAmB,CAC3C,CACF,GAEA,EAAO,KAAK,qCAAqC;CACjD,IAAM,IAAmB,EAAK,KAC5B,EAAQ,MACR,OACA,UACA,gBACF;CAKA,OAJA,EACE,EAAoB,GAAkB,EAAmB,CAAgB,CAAC,CAC5E,GAEO;EACL,SAAS,CAAC;EACV;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
@@ -1,21 +1,22 @@
1
1
  import { a as e } from "./util-BLYliuUK.js";
2
2
  import { t } from "./dedent-Gq6Krl4n.js";
3
3
  import { n } from "./logger-CQONztPm.js";
4
- import { n as r } from "./shared-Cmbzu7Od.js";
5
- import { modifyOutcomeToFile as i } from "./modify-file-Cgu_WeFk.js";
6
- import { a, c as o, i as s, l as c, n as l, s as u } from "./ts-morph-helpers-teS3yXg-.js";
7
- import { a as d, i as f, t as p } from "./config-target-DOi8kI_f.js";
8
- import { t as m } from "./_layout-D0OmzCu1.js";
9
- import h from "node:path";
10
- import g from "node:fs";
11
- import { Project as _, QuoteKind as v, SyntaxKind as y } from "ts-morph";
4
+ import { n as r } from "./shared-BwHQM-a9.js";
5
+ import { c as i, h as a, l as o, modifyOutcomeToFile as s, n as c, p as l, revertOutcomeToFile as u } from "./modify-file-GQD6uNgI.js";
6
+ import { t as d } from "./svelte-file-B3RfgVdt.js";
7
+ import { n as f } from "./compose-handle-Cg9jnCsS.js";
8
+ import { a as p, i as m, t as h } from "./config-target-Co-ij8p3.js";
9
+ import { t as g } from "./_layout-DqH4lA_r.js";
10
+ import _ from "node:fs";
11
+ import v from "node:path";
12
+ import { Project as y, QuoteKind as b, SyntaxKind as x } from "ts-morph";
12
13
  //#region src/patterns/disable/i18n/modifies/gitignore.ts
13
- function b(e) {
14
- if (!g.existsSync(e)) return {
14
+ function S(e) {
15
+ if (!_.existsSync(e)) return {
15
16
  status: "success",
16
17
  changed: !1
17
18
  };
18
- let t = g.readFileSync(e, "utf8");
19
+ let t = _.readFileSync(e, "utf8");
19
20
  if (!t.includes("src/locales/.wuchale")) return {
20
21
  status: "success",
21
22
  changed: !1
@@ -37,30 +38,30 @@ function b(e) {
37
38
  return i = i.replace(/\n{3,}/g, "\n\n"), i === t ? {
38
39
  status: "success",
39
40
  changed: !1
40
- } : (g.writeFileSync(e, i), {
41
+ } : (_.writeFileSync(e, i), {
41
42
  status: "success",
42
43
  changed: !0
43
44
  });
44
45
  }
45
46
  //#endregion
46
47
  //#region src/patterns/disable/i18n/modifies/vite-config.ts
47
- function x(e) {
48
- if (!g.existsSync(e)) return {
48
+ function C(e) {
49
+ if (!_.existsSync(e)) return {
49
50
  status: "success",
50
51
  changed: !1
51
52
  };
52
- let t = g.readFileSync(e, "utf8");
53
+ let t = _.readFileSync(e, "utf8");
53
54
  if (!t.includes("wuchale")) return {
54
55
  status: "success",
55
56
  changed: !1
56
57
  };
57
- let n = new _({
58
+ let n = new y({
58
59
  compilerOptions: { allowJs: !0 },
59
- manipulationSettings: { quoteKind: v.Single }
60
+ manipulationSettings: { quoteKind: b.Single }
60
61
  }).addSourceFileAtPath(e);
61
62
  for (;;) {
62
63
  let e = !1;
63
- for (let t of n.getDescendantsOfKind(y.ArrayLiteralExpression)) {
64
+ for (let t of n.getDescendantsOfKind(x.ArrayLiteralExpression)) {
64
65
  let n = t.getElements().findIndex((e) => e.getText().replace(/\s/g, "") === "wuchale()");
65
66
  if (n >= 0) {
66
67
  t.removeElement(n), e = !0;
@@ -69,26 +70,26 @@ function x(e) {
69
70
  }
70
71
  if (!e) break;
71
72
  }
72
- return s(n, "wuchale/vite"), n.formatText(), n.saveSync(), {
73
+ return i(n, "wuchale/vite"), n.formatText(), n.saveSync(), {
73
74
  status: "success",
74
75
  changed: n.getFullText() !== t
75
76
  };
76
77
  }
77
78
  //#endregion
78
79
  //#region src/patterns/disable/i18n/modifies/svelte-config.ts
79
- var S = {
80
+ var w = {
80
81
  notFound: "No SvelteKit config to revert.",
81
82
  failed: "Remove the $locales alias from the kit config by hand."
82
83
  };
83
- function C(e) {
84
- let t = f(e, S, (e) => {
84
+ function T(e) {
85
+ let t = m(e, w, (e) => {
85
86
  let t = e.kitContainer();
86
87
  if (!t) return !0;
87
88
  let n = t.getProperty("alias");
88
- if (!n || n.getKind() !== y.PropertyAssignment) return !0;
89
+ if (!n || n.getKind() !== x.PropertyAssignment) return !0;
89
90
  let r = n.getInitializer();
90
- if (!r || r.getKind() !== y.ObjectLiteralExpression) return !0;
91
- let i = r.asKindOrThrow(y.ObjectLiteralExpression), a = i.getProperties().find((e) => e.getText().replace(/['"]/g, "").startsWith("$locales"));
91
+ if (!r || r.getKind() !== x.ObjectLiteralExpression) return !0;
92
+ let i = r.asKindOrThrow(x.ObjectLiteralExpression), a = i.getProperties().find((e) => e.getText().replace(/['"]/g, "").startsWith("$locales"));
92
93
  return !a || (a.remove(), i.getProperties().length === 0 && n.remove(), !0);
93
94
  });
94
95
  return t.outcome.status === "not-found" ? {
@@ -101,66 +102,66 @@ function C(e) {
101
102
  }
102
103
  //#endregion
103
104
  //#region src/patterns/disable/i18n/modifies/hooks.server.ts
104
- var w = "handleWuchale", T = [
105
+ var E = "handleWuchale", D = t`
106
+ Take handleWuchale out of the exported handle in src/hooks.server.ts, then
107
+ remove its declaration, the loadLocales(...) calls and the wuchale and
108
+ $locales imports.
109
+ `, O = [
105
110
  "wuchale/load-utils/server",
106
111
  "$locales/main.url",
107
112
  "$locales/data",
108
113
  "$locales/main.loader.server.svelte.js",
109
114
  "$locales/js.loader.server.js"
110
115
  ];
111
- function E(e) {
112
- if (!g.existsSync(e)) return {
116
+ function k(e) {
117
+ if (!_.existsSync(e)) return {
113
118
  status: "success",
114
119
  changed: !1
115
120
  };
116
- let t = g.readFileSync(e, "utf8");
117
- if (!t.includes(w) && !t.includes("loadLocales(")) return {
121
+ let t = _.readFileSync(e, "utf8");
122
+ if (!t.includes(E) && !t.includes("loadLocales(")) return {
118
123
  status: "success",
119
124
  changed: !1
120
125
  };
121
- let n = new _({
126
+ let n = new y({
122
127
  compilerOptions: { allowJs: !0 },
123
- manipulationSettings: { quoteKind: v.Single }
128
+ manipulationSettings: { quoteKind: b.Single }
124
129
  }).addSourceFileAtPath(e);
125
130
  for (;;) {
126
- let e = n.getStatements().find((e) => e.getKind() === y.ExpressionStatement && /^loadLocales\s*\(/.test(e.getText()));
131
+ let e = n.getStatements().find((e) => e.getKind() === x.ExpressionStatement && /^loadLocales\s*\(/.test(e.getText()));
127
132
  if (!e) break;
128
133
  e.remove();
129
134
  }
130
- let r = n.getVariableDeclaration("handle"), i = r?.getInitializer();
131
- if (r && i?.getKind() === y.CallExpression) {
132
- let e = i.asKindOrThrow(y.CallExpression);
133
- if (e.getExpression().getText() === "sequence") {
134
- let t = e.getArguments(), n = t.findIndex((e) => e.getText() === w);
135
- n >= 0 && (t.length === 2 ? r.setInitializer(t[+(n === 0)].getText()) : e.removeArgument(n));
136
- }
137
- }
138
- u(n, w);
139
- for (let e of T) s(n, e);
140
- return a(n, "@sveltejs/kit/hooks", "sequence"), n.formatText(), l(n), n.saveSync(), {
135
+ if (f(n, E).status === "unsupported") return {
136
+ status: "failed",
137
+ message: D
138
+ };
139
+ l(n, E);
140
+ for (let e of O) i(n, e);
141
+ return o(n, "@sveltejs/kit/hooks", "sequence"), o(n, "@sveltejs/kit", "Handle"), n.formatText(), c(n), n.saveSync(), {
141
142
  status: "success",
142
143
  changed: n.getFullText() !== t
143
144
  };
144
145
  }
145
146
  //#endregion
146
147
  //#region src/patterns/disable/i18n/modifies/app-html.ts
147
- function D(e) {
148
- if (!g.existsSync(e)) return {
148
+ function A(e) {
149
+ if (!_.existsSync(e)) return {
149
150
  status: "success",
150
151
  changed: !1
151
152
  };
152
- let t = g.readFileSync(e, "utf8"), n = t.replace(/lang\s*=\s*(?:"%sveltekit\.lang%"|'%sveltekit\.lang%')/g, "lang=\"en\"");
153
+ let t = _.readFileSync(e, "utf8"), n = t.replace(/lang\s*=\s*(?:"%sveltekit\.lang%"|'%sveltekit\.lang%')/g, "lang=\"en\"");
153
154
  return n === t ? {
154
155
  status: "success",
155
156
  changed: !1
156
- } : (g.writeFileSync(e, n, "utf8"), {
157
+ } : (_.writeFileSync(e, n, "utf8"), {
157
158
  status: "success",
158
159
  changed: !0
159
160
  });
160
161
  }
161
162
  //#endregion
162
163
  //#region src/patterns/disable/i18n/modifies/+layout.ts
163
- var O = t`
164
+ var j = t`
164
165
  src/routes/+layout.ts still loads wuchale locales. Remove these from it:
165
166
 
166
167
  import { browser } from '$app/environment';
@@ -171,78 +172,78 @@ var O = t`
171
172
 
172
173
  and the loadLocale(...) call inside load().
173
174
  `;
174
- function k(e) {
175
+ function M(e) {
175
176
  return e.replace(/["']/g, "'").replace(/\s+/g, "");
176
177
  }
177
- function A(e) {
178
- if (!g.existsSync(e)) return { action: "none" };
179
- let t = g.readFileSync(e, "utf8");
180
- return !t.includes("loadLocale") && !t.includes("$locales") ? { action: "none" } : k(t) === k(m) ? { action: "delete" } : {
178
+ function N(e) {
179
+ if (!_.existsSync(e)) return { action: "none" };
180
+ let t = _.readFileSync(e, "utf8");
181
+ return !t.includes("loadLocale") && !t.includes("$locales") ? { action: "none" } : M(t) === M(g) ? { action: "delete" } : {
181
182
  action: "failed",
182
- message: O
183
+ message: j
183
184
  };
184
185
  }
185
186
  //#endregion
186
187
  //#region src/patterns/disable/i18n/modifies/root-layout.svelte.ts
187
- function j(e) {
188
- if (!g.existsSync(e)) return {
188
+ function P(e) {
189
+ if (!_.existsSync(e)) return {
189
190
  status: "success",
190
191
  changed: !1
191
192
  };
192
- let t = g.readFileSync(e, "utf8");
193
+ let t = _.readFileSync(e, "utf8");
193
194
  if (!t.includes("LanguageSelect")) return {
194
195
  status: "success",
195
196
  changed: !1
196
197
  };
197
- let n = c.fromPath(e);
198
+ let n = d.fromPath(e);
198
199
  n.modifyScript((e) => {
199
- let { source: t } = o(e, (e) => {
200
- s(e, "$lib/components/language-select.svelte"), l(e);
200
+ let { source: t } = a(e, (e) => {
201
+ i(e, "$lib/components/language-select.svelte"), c(e);
201
202
  });
202
203
  return t;
203
204
  });
204
205
  let r = n.toString();
205
- return r = r.replace(/[ \t]*<Navbar\.Item>\s*<LanguageSelect\s*\/>\s*<\/Navbar\.Item>[ \t]*\r?\n?/g, ""), r = r.replace(/[ \t]*<LanguageSelect\s*\/>[ \t]*\r?\n?/g, ""), g.writeFileSync(e, r, "utf8"), {
206
+ return r = r.replace(/[ \t]*<Navbar\.Item>\s*<LanguageSelect\s*\/>\s*<\/Navbar\.Item>[ \t]*\r?\n?/g, ""), r = r.replace(/[ \t]*<LanguageSelect\s*\/>[ \t]*\r?\n?/g, ""), _.writeFileSync(e, r, "utf8"), {
206
207
  status: "success",
207
208
  changed: r !== t
208
209
  };
209
210
  }
210
211
  //#endregion
211
212
  //#region src/patterns/disable/i18n/generate.runtime.ts
212
- async function M(t) {
213
- let a = n(t), o = [], s = [], c = (e) => {
214
- e && o.push(e);
213
+ async function F(t) {
214
+ let i = n(t), a = [], o = [], c = (e) => {
215
+ e && a.push(e);
215
216
  };
216
- a.info("Reverting vite.config");
217
- let l = d(t.root, p) ?? h.join(t.root, p[0]);
218
- c(i(l, x(l))), a.info("Reverting the $locales alias");
219
- let u = C(t.root);
220
- c(i(u.filePath, u.outcome)), a.info("Reverting hooks.server.ts");
221
- let f = h.join(t.root, "src", "hooks.server.ts");
222
- c(i(f, E(f))), a.info("Reverting app.html");
223
- let m = h.join(t.root, "src", "app.html");
224
- c(i(m, D(m))), a.info("Reverting root +layout.ts");
225
- let _ = h.join(t.root, "src", "routes", "+layout.ts"), v = A(_);
226
- v.action === "delete" ? s.push(r(_)) : v.action === "failed" && o.push({
227
- path: _,
228
- language: e(_),
229
- content: g.readFileSync(_, "utf8"),
217
+ i.info("Reverting vite.config");
218
+ let l = p(t.root, h) ?? v.join(t.root, h[0]);
219
+ c(s(l, C(l))), i.info("Reverting the $locales alias");
220
+ let d = T(t.root);
221
+ c(s(d.filePath, d.outcome)), i.info("Reverting hooks.server.ts");
222
+ let f = v.join(t.root, "src", "hooks.server.ts"), m = u(f, k(f));
223
+ c(m.modify), m.delete && o.push(m.delete), i.info("Reverting app.html");
224
+ let g = v.join(t.root, "src", "app.html");
225
+ c(s(g, A(g))), i.info("Reverting root +layout.ts");
226
+ let y = v.join(t.root, "src", "routes", "+layout.ts"), b = N(y);
227
+ b.action === "delete" ? o.push(r(y)) : b.action === "failed" && a.push({
228
+ path: y,
229
+ language: e(y),
230
+ content: _.readFileSync(y, "utf8"),
230
231
  status: "failed",
231
- message: v.message
232
- }), a.info("Reverting root layout language select");
233
- let y = [
234
- h.join(t.root, "src", "routes", "(public)", "root-layout.svelte"),
235
- h.join(t.root, "src", "routes", "root-layout.svelte"),
236
- h.join(t.root, "src", "routes", "(public)", "+layout.svelte"),
237
- h.join(t.root, "src", "routes", "+layout.svelte")
232
+ message: b.message
233
+ }), i.info("Reverting root layout language select");
234
+ let x = [
235
+ v.join(t.root, "src", "routes", "(public)", "root-layout.svelte"),
236
+ v.join(t.root, "src", "routes", "root-layout.svelte"),
237
+ v.join(t.root, "src", "routes", "(public)", "+layout.svelte"),
238
+ v.join(t.root, "src", "routes", "+layout.svelte")
238
239
  ];
239
- for (let e of y) g.existsSync(e) && c(i(e, j(e)));
240
- a.info("Reverting .gitignore");
241
- let S = h.join(t.root, ".gitignore");
242
- return c(i(S, b(S))), {
240
+ for (let e of x) _.existsSync(e) && c(s(e, P(e)));
241
+ i.info("Reverting .gitignore");
242
+ let w = v.join(t.root, ".gitignore");
243
+ return c(s(w, S(w))), {
243
244
  creates: [],
244
- modifies: o,
245
- deletes: s,
245
+ modifies: a,
246
+ deletes: o,
246
247
  components: [],
247
248
  packages: [],
248
249
  collections: [],
@@ -251,6 +252,6 @@ async function M(t) {
251
252
  };
252
253
  }
253
254
  //#endregion
254
- export { M as generate };
255
+ export { F as generate };
255
256
 
256
- //# sourceMappingURL=generate.runtime-BgezGu15.js.map
257
+ //# sourceMappingURL=generate.runtime-CCg2Pjcv.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.runtime-CCg2Pjcv.js","names":[],"sources":["../../src/patterns/disable/i18n/modifies/gitignore.ts","../../src/patterns/disable/i18n/modifies/vite-config.ts","../../src/patterns/disable/i18n/modifies/svelte-config.ts","../../src/patterns/disable/i18n/modifies/hooks.server.ts","../../src/patterns/disable/i18n/modifies/app-html.ts","../../src/patterns/disable/i18n/modifies/+layout.ts","../../src/patterns/disable/i18n/modifies/root-layout.svelte.ts","../../src/patterns/disable/i18n/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyGitignore(gitignorePath: string): ModifyOutcome {\n if (!fs.existsSync(gitignorePath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(gitignorePath, \"utf8\");\n if (!original.includes(\"src/locales/.wuchale\")) {\n return { status: \"success\", changed: false };\n }\n\n const lines = original.split(\"\\n\");\n const out: string[] = [];\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i];\n if (line === \"# Wuchale\") {\n let j = i + 1;\n let hasWuchale = false;\n while (j < lines.length && lines[j].trim() !== \"\") {\n if (lines[j] === \"src/locales/.wuchale\") {\n hasWuchale = true;\n }\n j++;\n }\n if (hasWuchale) {\n i = j;\n continue;\n }\n }\n if (line === \"src/locales/.wuchale\") continue;\n out.push(line);\n }\n\n let updated = out.join(\"\\n\");\n updated = updated.replace(/\\n{3,}/g, \"\\n\\n\");\n\n if (updated === original) {\n return { status: \"success\", changed: false };\n }\n\n fs.writeFileSync(gitignorePath, updated);\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport { Project, QuoteKind, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { removeImportByModuleSpecifier } from \"../../../../runtime/ts-morph-helpers\";\n\n/** Remove `wuchale()` from the Vite plugins and its import. */\nexport function unmodifyViteConfig(viteConfigPath: string): ModifyOutcome {\n if (!fs.existsSync(viteConfigPath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(viteConfigPath, \"utf8\");\n if (!original.includes(\"wuchale\")) {\n return { status: \"success\", changed: false };\n }\n\n const project = new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(viteConfigPath);\n\n // One removal at a time: manipulating the tree invalidates sibling nodes.\n for (;;) {\n let removed = false;\n for (const arr of sourceFile.getDescendantsOfKind(\n SyntaxKind.ArrayLiteralExpression,\n )) {\n const index = arr\n .getElements()\n .findIndex((el) => el.getText().replace(/\\s/g, \"\") === \"wuchale()\");\n if (index >= 0) {\n arr.removeElement(index);\n removed = true;\n break;\n }\n }\n if (!removed) break;\n }\n\n removeImportByModuleSpecifier(sourceFile, \"wuchale/vite\");\n\n sourceFile.formatText();\n sourceFile.saveSync();\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== original,\n };\n}\n","import { SyntaxKind, type PropertyAssignment } from \"ts-morph\";\nimport {\n modifyConfig,\n type ConfigModifyResult,\n} from \"../../../../runtime/config-target\";\n\nconst HINTS = {\n notFound: \"No SvelteKit config to revert.\",\n failed: \"Remove the $locales alias from the kit config by hand.\",\n};\n\n/** Remove the `$locales` alias; drop `alias` too once it is empty. */\nexport function unmodifySvelteConfig(root: string): ConfigModifyResult {\n const result = modifyConfig(root, HINTS, (target) => {\n const kit = target.kitContainer();\n if (!kit) return true;\n\n const aliasProp = kit.getProperty(\"alias\");\n if (!aliasProp || aliasProp.getKind() !== SyntaxKind.PropertyAssignment) {\n return true;\n }\n const aliasObj = (aliasProp as PropertyAssignment).getInitializer();\n if (\n !aliasObj ||\n aliasObj.getKind() !== SyntaxKind.ObjectLiteralExpression\n ) {\n return true;\n }\n const obj = aliasObj.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n const locales = obj\n .getProperties()\n .find((p) => p.getText().replace(/['\"]/g, \"\").startsWith(\"$locales\"));\n if (!locales) return true;\n\n locales.remove();\n if (obj.getProperties().length === 0) {\n aliasProp.remove();\n }\n return true;\n });\n\n // Nothing to revert in a project without a config.\n if (result.outcome.status === \"not-found\") {\n return { ...result, outcome: { status: \"success\", changed: false } };\n }\n return result;\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Project, QuoteKind, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { removeHandle } from \"../../../../runtime/compose-handle\";\nimport {\n ensureBlankLineAfterImports,\n removeImportByModuleSpecifier,\n removeNamedImportIfUnused,\n removeTopLevelStatementByIdentifier,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nconst I18N_HANDLE = \"handleWuchale\";\nconst FAILURE_HINT = dedent`\n Take handleWuchale out of the exported handle in src/hooks.server.ts, then\n remove its declaration, the loadLocales(...) calls and the wuchale and\n $locales imports.\n`;\n\nconst I18N_MODULES = [\n \"wuchale/load-utils/server\",\n \"$locales/main.url\",\n \"$locales/data\",\n \"$locales/main.loader.server.svelte.js\",\n \"$locales/js.loader.server.js\",\n];\n\n/**\n * Undo `modifyHooksServerI18n`: drop the locale bootstrap, the wuchale handle\n * and its imports, and unwrap `sequence(handleWuchale, ...)`. A file that\n * enable-i18n created comes out empty, for the caller to delete.\n */\nexport function unmodifyHooksServerI18n(\n hooksServerPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(hooksServerPath, \"utf8\");\n if (!original.includes(I18N_HANDLE) && !original.includes(\"loadLocales(\")) {\n return { status: \"success\", changed: false };\n }\n\n const project = new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n // loadLocales(...) bootstrap calls, one at a time (removal invalidates siblings).\n for (;;) {\n const stmt = sourceFile\n .getStatements()\n .find(\n (s) =>\n s.getKind() === SyntaxKind.ExpressionStatement &&\n /^loadLocales\\s*\\(/.test(s.getText()),\n );\n if (!stmt) break;\n stmt.remove();\n }\n\n // `export const handle = handleWuchale` goes altogether; a sequence loses\n // the argument, or unwraps to the handle it composed with.\n const removed = removeHandle(sourceFile, I18N_HANDLE);\n if (removed.status === \"unsupported\") {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n removeTopLevelStatementByIdentifier(sourceFile, I18N_HANDLE);\n for (const moduleSpecifier of I18N_MODULES) {\n removeImportByModuleSpecifier(sourceFile, moduleSpecifier);\n }\n removeNamedImportIfUnused(sourceFile, \"@sveltejs/kit/hooks\", \"sequence\");\n removeNamedImportIfUnused(sourceFile, \"@sveltejs/kit\", \"Handle\");\n\n sourceFile.formatText();\n ensureBlankLineAfterImports(sourceFile);\n sourceFile.saveSync();\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== original,\n };\n}\n","import fs from \"node:fs\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\n/**\n * Put a real language back. `%sveltekit.lang%` is not a SvelteKit\n * placeholder; only the wuchale hook replaced it, so without that hook it\n * would be served literally.\n */\nexport function unmodifyAppHtml(appHtmlPath: string): ModifyOutcome {\n if (!fs.existsSync(appHtmlPath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(appHtmlPath, \"utf8\");\n const updated = original.replace(\n /lang\\s*=\\s*(?:\"%sveltekit\\.lang%\"|'%sveltekit\\.lang%')/g,\n 'lang=\"en\"',\n );\n if (updated === original) {\n return { status: \"success\", changed: false };\n }\n\n fs.writeFileSync(appHtmlPath, updated, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { LOAD_SNIPPET } from \"../../../enable/i18n/modifies/+layout\";\n\nconst FAILURE_HINT = dedent`\n src/routes/+layout.ts still loads wuchale locales. Remove these from it:\n\n import { browser } from '$app/environment';\n import { loadLocale } from 'wuchale/load-utils';\n import { getLocale } from '$locales/main.url';\n import '$locales/main.loader.svelte';\n import '$locales/js.loader';\n\n and the loadLocale(...) call inside load().\n`;\n\nfunction normalize(source: string): string {\n return source.replace(/[\"']/g, \"'\").replace(/\\s+/g, \"\");\n}\n\nexport type RootLayoutRevert =\n | { action: \"none\" }\n | { action: \"delete\" }\n | { action: \"failed\"; message: string };\n\n/**\n * enable-i18n wrote the whole file when no `+layout.ts` existed, so the\n * revert is to delete it; a file that grew other code needs a hand.\n */\nexport function planRootLayoutRevert(layoutPath: string): RootLayoutRevert {\n if (!fs.existsSync(layoutPath)) {\n return { action: \"none\" };\n }\n const existing = fs.readFileSync(layoutPath, \"utf8\");\n if (!existing.includes(\"loadLocale\") && !existing.includes(\"$locales\")) {\n return { action: \"none\" };\n }\n if (normalize(existing) === normalize(LOAD_SNIPPET)) {\n return { action: \"delete\" };\n }\n return { action: \"failed\", message: FAILURE_HINT };\n}\n","import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n ensureBlankLineAfterImports,\n removeImportByModuleSpecifier,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\n/** Take the language select (and the nav item enable-i18n wrapped it in) back out. */\nexport function unmodifyRootLayoutLanguageSelect(\n layoutPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(layoutPath, \"utf8\");\n if (!original.includes(\"LanguageSelect\")) {\n return { status: \"success\", changed: false };\n }\n\n const file = SvelteFile.fromPath(layoutPath);\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n removeImportByModuleSpecifier(\n sf,\n \"$lib/components/language-select.svelte\",\n );\n ensureBlankLineAfterImports(sf);\n });\n return out;\n });\n\n let updated = file.toString();\n updated = updated.replace(\n /[ \\t]*<Navbar\\.Item>\\s*<LanguageSelect\\s*\\/>\\s*<\\/Navbar\\.Item>[ \\t]*\\r?\\n?/g,\n \"\",\n );\n updated = updated.replace(/[ \\t]*<LanguageSelect\\s*\\/>[ \\t]*\\r?\\n?/g, \"\");\n\n fs.writeFileSync(layoutPath, updated, \"utf8\");\n return { status: \"success\", changed: updated !== original };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { languageFromPath } from \"../../../core/util\";\nimport {\n modifyOutcomeToFile,\n revertOutcomeToFile,\n} from \"../../../runtime/modify-file\";\nimport {\n probeFirstExisting,\n VITE_CONFIG_CANDIDATES,\n} from \"../../../runtime/config-target\";\nimport { toDeleteEntry } from \"../../destroy/shared\";\nimport { unmodifyGitignore } from \"./modifies/gitignore\";\nimport { unmodifyViteConfig } from \"./modifies/vite-config\";\nimport { unmodifySvelteConfig } from \"./modifies/svelte-config\";\nimport { unmodifyHooksServerI18n } from \"./modifies/hooks.server\";\nimport { unmodifyAppHtml } from \"./modifies/app-html\";\nimport { planRootLayoutRevert } from \"./modifies/+layout\";\nimport { unmodifyRootLayoutLanguageSelect } from \"./modifies/root-layout.svelte\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n const deletes: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Reverting vite.config\");\n const viteConfigPath =\n probeFirstExisting(options.root, VITE_CONFIG_CANDIDATES) ??\n path.join(options.root, VITE_CONFIG_CANDIDATES[0]);\n pushResult(\n modifyOutcomeToFile(viteConfigPath, unmodifyViteConfig(viteConfigPath)),\n );\n\n logger.info(\"Reverting the $locales alias\");\n const alias = unmodifySvelteConfig(options.root);\n pushResult(modifyOutcomeToFile(alias.filePath, alias.outcome));\n\n logger.info(\"Reverting hooks.server.ts\");\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n // enable-i18n may have created it; emptied, it goes.\n const hooksRevert = revertOutcomeToFile(\n hooksServerPath,\n unmodifyHooksServerI18n(hooksServerPath),\n );\n pushResult(hooksRevert.modify);\n if (hooksRevert.delete) deletes.push(hooksRevert.delete);\n\n logger.info(\"Reverting app.html\");\n const appHtmlPath = path.join(options.root, \"src\", \"app.html\");\n pushResult(modifyOutcomeToFile(appHtmlPath, unmodifyAppHtml(appHtmlPath)));\n\n logger.info(\"Reverting root +layout.ts\");\n const layoutPath = path.join(options.root, \"src\", \"routes\", \"+layout.ts\");\n const layoutRevert = planRootLayoutRevert(layoutPath);\n if (layoutRevert.action === \"delete\") {\n deletes.push(toDeleteEntry(layoutPath));\n } else if (layoutRevert.action === \"failed\") {\n modifies.push({\n path: layoutPath,\n language: languageFromPath(layoutPath),\n content: fs.readFileSync(layoutPath, \"utf8\"),\n status: \"failed\",\n message: layoutRevert.message,\n });\n }\n\n logger.info(\"Reverting root layout language select\");\n const rootLayoutCandidates = [\n path.join(options.root, \"src\", \"routes\", \"(public)\", \"root-layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"root-layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"(public)\", \"+layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"+layout.svelte\"),\n ];\n for (const candidate of rootLayoutCandidates) {\n if (!fs.existsSync(candidate)) continue;\n pushResult(\n modifyOutcomeToFile(\n candidate,\n unmodifyRootLayoutLanguageSelect(candidate),\n ),\n );\n }\n\n logger.info(\"Reverting .gitignore\");\n const gitignorePath = path.join(options.root, \".gitignore\");\n pushResult(\n modifyOutcomeToFile(gitignorePath, unmodifyGitignore(gitignorePath)),\n );\n\n return {\n creates: [],\n modifies,\n deletes,\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;;;;;AAGA,SAAgB,EAAkB,GAAsC;CACtE,IAAI,CAAC,EAAG,WAAW,CAAa,GAC9B,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAM,IAAW,EAAG,aAAa,GAAe,MAAM;CACtD,IAAI,CAAC,EAAS,SAAS,sBAAsB,GAC3C,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAM,IAAQ,EAAS,MAAM,IAAI,GAC3B,IAAgB,CAAC;CACvB,KAAK,IAAI,IAAI,GAAG,IAAI,EAAM,QAAQ,KAAK;EACrC,IAAM,IAAO,EAAM;EACnB,IAAI,MAAS,aAAa;GACxB,IAAI,IAAI,IAAI,GACR,IAAa;GACjB,OAAO,IAAI,EAAM,UAAU,EAAM,EAAE,CAAC,KAAK,MAAM,KAI7C,AAHI,EAAM,OAAO,2BACf,IAAa,KAEf;GAEF,IAAI,GAAY;IACd,IAAI;IACJ;GACF;EACF;EACI,MAAS,0BACb,EAAI,KAAK,CAAI;CACf;CAEA,IAAI,IAAU,EAAI,KAAK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