@velastack/patterns 0.5.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. package/README.md +11 -0
  2. package/dist/chunks/{_layout-D-FzWqn0.js → _layout-Bsx3eNrC.js} +3 -3
  3. package/dist/chunks/{_layout-D-FzWqn0.js.map → _layout-Bsx3eNrC.js.map} +1 -1
  4. package/dist/chunks/{auth-pages-B52ei-4z.js → auth-pages-jsyDV1GR.js} +7 -10
  5. package/dist/chunks/{auth-pages-B52ei-4z.js.map → auth-pages-jsyDV1GR.js.map} +1 -1
  6. package/dist/chunks/collections-BrEA7a62.js +309 -0
  7. package/dist/chunks/collections-BrEA7a62.js.map +1 -0
  8. package/dist/chunks/{collections-Cpjo2OiQ.js → collections-DrUG8ngq.js} +39 -35
  9. package/dist/chunks/collections-DrUG8ngq.js.map +1 -0
  10. package/dist/chunks/{compose-handle-BDlZ7Pif.js → compose-handle-BBlamPfx.js} +18 -22
  11. package/dist/chunks/{compose-handle-BDlZ7Pif.js.map → compose-handle-BBlamPfx.js.map} +1 -1
  12. package/dist/chunks/{config-target-rHgjaA8u.js → config-target-BgyFkbFL.js} +2 -2
  13. package/dist/chunks/{config-target-rHgjaA8u.js.map → config-target-BgyFkbFL.js.map} +1 -1
  14. package/dist/chunks/{constants-Rq8SCXwH.js → constants-iej3WkEa.js} +3 -3
  15. package/dist/chunks/constants-iej3WkEa.js.map +1 -0
  16. package/dist/chunks/dedent-Gq6Krl4n.js.map +1 -1
  17. package/dist/chunks/{env-BPfk1VAw.js → env-BugddEjd.js} +5 -9
  18. package/dist/chunks/{env-BPfk1VAw.js.map → env-BugddEjd.js.map} +1 -1
  19. package/dist/chunks/{env-vars-Bj41Nccm.js → env-vars-CdarYsrc.js} +6 -11
  20. package/dist/chunks/{env-vars-Bj41Nccm.js.map → env-vars-CdarYsrc.js.map} +1 -1
  21. package/dist/chunks/{generate-dNlBII84.js → generate-27CjLiGW.js} +2 -2
  22. package/dist/chunks/{generate-dNlBII84.js.map → generate-27CjLiGW.js.map} +1 -1
  23. package/dist/chunks/{generate-yi8AP3xH.js → generate-BFcy2wrS.js} +3 -3
  24. package/dist/chunks/{generate-yi8AP3xH.js.map → generate-BFcy2wrS.js.map} +1 -1
  25. package/dist/chunks/generate-BxOzEdc_.js +171 -0
  26. package/dist/chunks/generate-BxOzEdc_.js.map +1 -0
  27. package/dist/chunks/{generate-B6Odfk5f.js → generate-Cqwa8kD9.js} +2 -2
  28. package/dist/chunks/{generate-B6Odfk5f.js.map → generate-Cqwa8kD9.js.map} +1 -1
  29. package/dist/chunks/{generate-DjBMRzsB.js → generate-D3mSFPdT.js} +2 -2
  30. package/dist/chunks/{generate-DjBMRzsB.js.map → generate-D3mSFPdT.js.map} +1 -1
  31. package/dist/chunks/{generate-ZIOVLH6Q.js → generate-DdLwP0E7.js} +51 -47
  32. package/dist/chunks/generate-DdLwP0E7.js.map +1 -0
  33. package/dist/chunks/generate-DyV5R8NP.js.map +1 -1
  34. package/dist/chunks/{generate.runtime-MjWwR2Bd.js → generate.runtime-9KuMcI5r.js} +10 -13
  35. package/dist/chunks/{generate.runtime-MjWwR2Bd.js.map → generate.runtime-9KuMcI5r.js.map} +1 -1
  36. package/dist/chunks/{generate.runtime-BKINIJ2c.js → generate.runtime-B10-KA87.js} +69 -69
  37. package/dist/chunks/{generate.runtime-BKINIJ2c.js.map → generate.runtime-B10-KA87.js.map} +1 -1
  38. package/dist/chunks/{generate.runtime-DaRVyiSg.js → generate.runtime-B8-GLMkk.js} +131 -197
  39. package/dist/chunks/generate.runtime-B8-GLMkk.js.map +1 -0
  40. package/dist/chunks/{generate.runtime-Bdpu4rX0.js → generate.runtime-BGuXHl5o.js} +3 -3
  41. package/dist/chunks/{generate.runtime-Bdpu4rX0.js.map → generate.runtime-BGuXHl5o.js.map} +1 -1
  42. package/dist/chunks/{generate.runtime-DjCzW3zU.js → generate.runtime-BJxM7FNA.js} +7 -7
  43. package/dist/chunks/{generate.runtime-DjCzW3zU.js.map → generate.runtime-BJxM7FNA.js.map} +1 -1
  44. package/dist/chunks/{generate.runtime-BdmoAVJK.js → generate.runtime-BWRtyQeD.js} +5 -5
  45. package/dist/chunks/{generate.runtime-BdmoAVJK.js.map → generate.runtime-BWRtyQeD.js.map} +1 -1
  46. package/dist/chunks/{generate.runtime-CV4soy2n.js → generate.runtime-B_tWu-Bw.js} +47 -47
  47. package/dist/chunks/{generate.runtime-CV4soy2n.js.map → generate.runtime-B_tWu-Bw.js.map} +1 -1
  48. package/dist/chunks/{generate.runtime-NaSIZlP5.js → generate.runtime-BdghkfNp.js} +3 -3
  49. package/dist/chunks/{generate.runtime-NaSIZlP5.js.map → generate.runtime-BdghkfNp.js.map} +1 -1
  50. package/dist/chunks/{generate.runtime-B4QoBn5v.js → generate.runtime-Blb6QPZn.js} +8 -8
  51. package/dist/chunks/{generate.runtime-B4QoBn5v.js.map → generate.runtime-Blb6QPZn.js.map} +1 -1
  52. package/dist/chunks/{generate.runtime-DRRyPa-e.js → generate.runtime-CEexT8cJ.js} +66 -66
  53. package/dist/chunks/{generate.runtime-DRRyPa-e.js.map → generate.runtime-CEexT8cJ.js.map} +1 -1
  54. package/dist/chunks/{generate.runtime-BKTkVCEm.js → generate.runtime-CIZO2XO9.js} +4 -4
  55. package/dist/chunks/{generate.runtime-BKTkVCEm.js.map → generate.runtime-CIZO2XO9.js.map} +1 -1
  56. package/dist/chunks/{generate.runtime-DmsOEsJV.js → generate.runtime-CK0MTeqc.js} +4 -4
  57. package/dist/chunks/{generate.runtime-DmsOEsJV.js.map → generate.runtime-CK0MTeqc.js.map} +1 -1
  58. package/dist/chunks/{generate.runtime-BavEh01F.js → generate.runtime-CMO-Skpk.js} +5 -5
  59. package/dist/chunks/{generate.runtime-BavEh01F.js.map → generate.runtime-CMO-Skpk.js.map} +1 -1
  60. package/dist/chunks/{generate.runtime-BXZDKLbA.js → generate.runtime-CVDb-yLt.js} +12 -20
  61. package/dist/chunks/{generate.runtime-BXZDKLbA.js.map → generate.runtime-CVDb-yLt.js.map} +1 -1
  62. package/dist/chunks/generate.runtime-C_5Ghjri.js +17 -0
  63. package/dist/chunks/generate.runtime-C_5Ghjri.js.map +1 -0
  64. package/dist/chunks/{generate.runtime-CWgZhxQt.js → generate.runtime-CbOMXQSo.js} +3 -3
  65. package/dist/chunks/{generate.runtime-CWgZhxQt.js.map → generate.runtime-CbOMXQSo.js.map} +1 -1
  66. package/dist/chunks/{generate.runtime-DBBtYTAa.js → generate.runtime-CbT-EbQT.js} +5 -5
  67. package/dist/chunks/{generate.runtime-DBBtYTAa.js.map → generate.runtime-CbT-EbQT.js.map} +1 -1
  68. package/dist/chunks/{generate.runtime-CSUnP0l-.js → generate.runtime-Cxr15Y5H.js} +27 -27
  69. package/dist/chunks/{generate.runtime-CSUnP0l-.js.map → generate.runtime-Cxr15Y5H.js.map} +1 -1
  70. package/dist/chunks/{generate.runtime-pMpn0Pbf.js → generate.runtime-CyTxBcX3.js} +10 -10
  71. package/dist/chunks/{generate.runtime-pMpn0Pbf.js.map → generate.runtime-CyTxBcX3.js.map} +1 -1
  72. package/dist/chunks/{generate.runtime-azOvp6tl.js → generate.runtime-D5HxAups.js} +39 -36
  73. package/dist/chunks/generate.runtime-D5HxAups.js.map +1 -0
  74. package/dist/chunks/{generate.runtime-b2RtuPy4.js → generate.runtime-D6vhkGs8.js} +5 -5
  75. package/dist/chunks/{generate.runtime-b2RtuPy4.js.map → generate.runtime-D6vhkGs8.js.map} +1 -1
  76. package/dist/chunks/{generate.runtime-DlbG-8Xm.js → generate.runtime-DIeAeOJg.js} +6 -6
  77. package/dist/chunks/{generate.runtime-DlbG-8Xm.js.map → generate.runtime-DIeAeOJg.js.map} +1 -1
  78. package/dist/chunks/{generate.runtime-QbmCPT42.js → generate.runtime-DMTAocSE.js} +17 -17
  79. package/dist/chunks/{generate.runtime-QbmCPT42.js.map → generate.runtime-DMTAocSE.js.map} +1 -1
  80. package/dist/chunks/{generate.runtime-utFLS6Jz.js → generate.runtime-DlLwmjGF.js} +133 -121
  81. package/dist/chunks/generate.runtime-DlLwmjGF.js.map +1 -0
  82. package/dist/chunks/{generate.runtime-BYfyZHhs.js → generate.runtime-DtCaz98N.js} +6 -6
  83. package/dist/chunks/{generate.runtime-BYfyZHhs.js.map → generate.runtime-DtCaz98N.js.map} +1 -1
  84. package/dist/chunks/{generate.runtime-BcgjZJug.js → generate.runtime-HSZD935T.js} +4 -4
  85. package/dist/chunks/{generate.runtime-BcgjZJug.js.map → generate.runtime-HSZD935T.js.map} +1 -1
  86. package/dist/chunks/{generate.runtime-OEgsdWRP.js → generate.runtime-Nnk5E8Pi.js} +3 -3
  87. package/dist/chunks/{generate.runtime-OEgsdWRP.js.map → generate.runtime-Nnk5E8Pi.js.map} +1 -1
  88. package/dist/chunks/{generate.runtime-D-qtaVdq.js → generate.runtime-NxuWvkKt.js} +13 -13
  89. package/dist/chunks/{generate.runtime-D-qtaVdq.js.map → generate.runtime-NxuWvkKt.js.map} +1 -1
  90. package/dist/chunks/{generate.runtime-CCV4O6_I.js → generate.runtime-dFTOU_KE.js} +71 -71
  91. package/dist/chunks/{generate.runtime-CCV4O6_I.js.map → generate.runtime-dFTOU_KE.js.map} +1 -1
  92. package/dist/chunks/{generate.runtime-C7s1Mx5L.js → generate.runtime-m0m43lkL.js} +7 -7
  93. package/dist/chunks/{generate.runtime-C7s1Mx5L.js.map → generate.runtime-m0m43lkL.js.map} +1 -1
  94. package/dist/chunks/{generate.runtime-BdHv7Jp1.js → generate.runtime-si5Za61F.js} +3 -3
  95. package/dist/chunks/{generate.runtime-BdHv7Jp1.js.map → generate.runtime-si5Za61F.js.map} +1 -1
  96. package/dist/chunks/{generate.runtime-DetYynf4.js → generate.runtime-tGKorg85.js} +10 -14
  97. package/dist/chunks/{generate.runtime-DetYynf4.js.map → generate.runtime-tGKorg85.js.map} +1 -1
  98. package/dist/chunks/{generate.runtime-CcPCAEV0.js → generate.runtime-ww3-1FWf.js} +6 -6
  99. package/dist/chunks/{generate.runtime-CcPCAEV0.js.map → generate.runtime-ww3-1FWf.js.map} +1 -1
  100. package/dist/chunks/{modify-file-Bbhyfiy_.js → modify-file-COBp4eCh.js} +4 -4
  101. package/dist/chunks/{modify-file-Bbhyfiy_.js.map → modify-file-COBp4eCh.js.map} +1 -1
  102. package/dist/chunks/{modify-nav-user-B8h8WTrM.js → modify-nav-user-CJ1LevSU.js} +2 -2
  103. package/dist/chunks/{modify-nav-user-B8h8WTrM.js.map → modify-nav-user-CJ1LevSU.js.map} +1 -1
  104. package/dist/chunks/{modify-svelte-config-remote-DhuRX4FI.js → modify-svelte-config-remote-CEyYydL7.js} +2 -2
  105. package/dist/chunks/{modify-svelte-config-remote-DhuRX4FI.js.map → modify-svelte-config-remote-CEyYydL7.js.map} +1 -1
  106. package/dist/chunks/{modify-user-signup-BbqTiUuA.js → modify-user-signup-DLtopazD.js} +2 -2
  107. package/dist/chunks/{modify-user-signup-BbqTiUuA.js.map → modify-user-signup-DLtopazD.js.map} +1 -1
  108. package/dist/chunks/{package-imports-Bbw3iMPg.js → package-imports-Dx05A-4S.js} +2 -2
  109. package/dist/chunks/{package-imports-Bbw3iMPg.js.map → package-imports-Dx05A-4S.js.map} +1 -1
  110. package/dist/chunks/{pocketbase-CgwbH1gI.js → pocketbase-DL02rq73.js} +5 -13
  111. package/dist/chunks/{pocketbase-CgwbH1gI.js.map → pocketbase-DL02rq73.js.map} +1 -1
  112. package/dist/chunks/{providers-DwbwccSW.js → providers-CAehyySB.js} +2 -2
  113. package/dist/chunks/{providers-DwbwccSW.js.map → providers-CAehyySB.js.map} +1 -1
  114. package/dist/chunks/{rolldown-runtime-DArdT4gl.js → rolldown-runtime-5HNE8Q1r.js} +1 -1
  115. package/dist/chunks/{shared-D5GOS97l.js → shared-C_Fr8wph.js} +2 -2
  116. package/dist/chunks/{shared-D5GOS97l.js.map → shared-C_Fr8wph.js.map} +1 -1
  117. package/dist/chunks/site-BoujshKo.js +108 -0
  118. package/dist/chunks/site-BoujshKo.js.map +1 -0
  119. package/dist/chunks/{table-core-DhDqT03G.js → table-core-BPv_RYgD.js} +3 -3
  120. package/dist/chunks/{table-core-DhDqT03G.js.map → table-core-BPv_RYgD.js.map} +1 -1
  121. package/dist/chunks/{taggedTemplateLiteral-CswN2AAa.js → taggedTemplateLiteral-KSUnuvOk.js} +1 -1
  122. package/dist/chunks/{test-setup-DZoyF8Ak.js → test-setup-pYUIfWb2.js} +5 -5
  123. package/dist/chunks/{test-setup-DZoyF8Ak.js.map → test-setup-pYUIfWb2.js.map} +1 -1
  124. package/dist/chunks/{ts-morph-helpers-Bepc-Es2.js → ts-morph-helpers-CHI9wAil.js} +7 -11
  125. package/dist/chunks/{ts-morph-helpers-Bepc-Es2.js.map → ts-morph-helpers-CHI9wAil.js.map} +1 -1
  126. package/dist/chunks/{ui-BuocThuh.js → ui-B2yn8c_-.js} +3 -3
  127. package/dist/chunks/{ui-BuocThuh.js.map → ui-B2yn8c_-.js.map} +1 -1
  128. package/dist/chunks/{unmodify-load-Bl5vXQiL.js → unmodify-load-Buak-r1f.js} +2 -2
  129. package/dist/chunks/{unmodify-load-Bl5vXQiL.js.map → unmodify-load-Buak-r1f.js.map} +1 -1
  130. package/dist/chunks/{whatsapp-CguKGTtw.js → whatsapp-5qJ_xCV1.js} +2 -2
  131. package/dist/chunks/{whatsapp-CguKGTtw.js.map → whatsapp-5qJ_xCV1.js.map} +1 -1
  132. package/dist/chunks/{write-result-Cq-9A7Zy.js → write-result-Bn4bnrBI.js} +20 -50
  133. package/dist/chunks/write-result-Bn4bnrBI.js.map +1 -0
  134. package/dist/chunks/wuchale-config-c3Q4JVSF.js +50 -0
  135. package/dist/chunks/wuchale-config-c3Q4JVSF.js.map +1 -0
  136. package/dist/index.d.ts +162 -1
  137. package/dist/index.js +2193 -2330
  138. package/dist/index.js.map +1 -1
  139. package/package.json +2 -2
  140. package/dist/chunks/collections-Cpjo2OiQ.js.map +0 -1
  141. package/dist/chunks/constants-Rq8SCXwH.js.map +0 -1
  142. package/dist/chunks/generate-BClgUH4J.js +0 -137
  143. package/dist/chunks/generate-BClgUH4J.js.map +0 -1
  144. package/dist/chunks/generate-ZIOVLH6Q.js.map +0 -1
  145. package/dist/chunks/generate.runtime-DaRVyiSg.js.map +0 -1
  146. package/dist/chunks/generate.runtime-azOvp6tl.js.map +0 -1
  147. package/dist/chunks/generate.runtime-utFLS6Jz.js.map +0 -1
  148. package/dist/chunks/shopify-page-D-VFwGxI.js +0 -11
  149. package/dist/chunks/shopify-page-D-VFwGxI.js.map +0 -1
  150. package/dist/chunks/site-lj0CDdQ1.js +0 -55
  151. package/dist/chunks/site-lj0CDdQ1.js.map +0 -1
  152. package/dist/chunks/write-result-Cq-9A7Zy.js.map +0 -1
@@ -1,17 +1,18 @@
1
1
  import { t as e } from "./dedent-Gq6Krl4n.js";
2
2
  import { t } from "./ui-DD4NltyN.js";
3
3
  import { n } from "./logger-CQONztPm.js";
4
- import { _ as r, i, o as a, r as o } from "./ts-morph-helpers-Bepc-Es2.js";
5
- import { r as s } from "./modify-file-Bbhyfiy_.js";
4
+ import { _ as r, i, o as a, r as o } from "./ts-morph-helpers-CHI9wAil.js";
5
+ import { r as s } from "./modify-file-COBp4eCh.js";
6
6
  import { t as c } from "./svelte-file-Dv5-bl79.js";
7
- import { t as l } from "./compose-handle-BDlZ7Pif.js";
8
- import { a as u, t as d } from "./config-target-rHgjaA8u.js";
9
- import { i as f, n as p } from "./_layout-D-FzWqn0.js";
10
- import m from "node:fs";
11
- import h from "node:path";
12
- import { Project as g, QuoteKind as _, SyntaxKind as v } from "ts-morph";
7
+ import { t as l } from "./compose-handle-BBlamPfx.js";
8
+ import { a as u, t as d } from "./config-target-BgyFkbFL.js";
9
+ import { i as f, n as p } from "./_layout-Bsx3eNrC.js";
10
+ import { r as m, t as h } from "./wuchale-config-c3Q4JVSF.js";
11
+ import g from "node:fs";
12
+ import _ from "node:path";
13
+ import { Project as v, QuoteKind as y, SyntaxKind as b } from "ts-morph";
13
14
  //#region src/patterns/enable/i18n/modifies/vite-config.ts
14
- var y = [
15
+ var x = [
15
16
  "Add the wuchale plugin to your Vite config:",
16
17
  "",
17
18
  "import { wuchale } from 'wuchale/vite';",
@@ -19,7 +20,7 @@ var y = [
19
20
  "export default defineConfig({",
20
21
  " plugins: [wuchale(), /* ...existing plugins */],",
21
22
  "});"
22
- ].join("\n"), b = [
23
+ ].join("\n"), S = [
23
24
  "Create a Vite config with the wuchale plugin:",
24
25
  "",
25
26
  "import { defineConfig } from 'vite';",
@@ -29,20 +30,20 @@ var y = [
29
30
  " plugins: [wuchale()],",
30
31
  "});"
31
32
  ].join("\n");
32
- function x(e) {
33
- if (!m.existsSync(e)) return {
33
+ function C(e) {
34
+ if (!g.existsSync(e)) return {
34
35
  status: "not-found",
35
- message: b
36
+ message: S
36
37
  };
37
- let t = new g({
38
+ let t = new v({
38
39
  compilerOptions: { allowJs: !0 },
39
- manipulationSettings: { quoteKind: _.Single }
40
+ manipulationSettings: { quoteKind: y.Single }
40
41
  }).addSourceFileAtPath(e), n = !1, r = !1;
41
42
  t.getImportDeclarations().some((e) => e.getModuleSpecifierValue() === "wuchale/vite") || (t.insertImportDeclaration(0, {
42
43
  namedImports: ["wuchale"],
43
44
  moduleSpecifier: "wuchale/vite"
44
45
  }), n = !0);
45
- let i = t.getDescendantsOfKind(v.CallExpression).find((e) => e.getExpression().getText() === "defineConfig")?.getArguments()?.[0], o = i?.getKind() === v.ObjectLiteralExpression ? i : null;
46
+ let i = t.getDescendantsOfKind(b.CallExpression).find((e) => e.getExpression().getText() === "defineConfig")?.getArguments()?.[0], o = i?.getKind() === b.ObjectLiteralExpression ? i : null;
46
47
  if (!o) r = !0;
47
48
  else {
48
49
  let e = o.getProperty("plugins");
@@ -50,11 +51,11 @@ function x(e) {
50
51
  name: "plugins",
51
52
  initializer: "[wuchale()]"
52
53
  }), n = !0;
53
- else if (e.getKind() !== v.PropertyAssignment) r = !0;
54
+ else if (e.getKind() !== b.PropertyAssignment) r = !0;
54
55
  else {
55
56
  let t = e.getInitializer();
56
57
  if (!t) e.setInitializer("[wuchale()]"), n = !0;
57
- else if (t.getKind() !== v.ArrayLiteralExpression) r = !0;
58
+ else if (t.getKind() !== b.ArrayLiteralExpression) r = !0;
58
59
  else {
59
60
  let e = t;
60
61
  e.getElements().some((e) => e.getText().replace(/\s/g, "") === "wuchale()") || (e.insertElement(0, "wuchale()"), n = !0);
@@ -63,7 +64,7 @@ function x(e) {
63
64
  }
64
65
  return n && (a(t), t.saveSync()), r ? {
65
66
  status: "failed",
66
- message: y
67
+ message: x
67
68
  } : {
68
69
  status: "success",
69
70
  changed: n
@@ -71,7 +72,7 @@ function x(e) {
71
72
  }
72
73
  //#endregion
73
74
  //#region src/patterns/enable/i18n/modifies/hooks.server.ts
74
- var S = "handleWuchale", C = e`
75
+ var w = "handleWuchale", T = e`
75
76
  Wrap your exported handle with the wuchale i18n handler:
76
77
 
77
78
  import { sequence } from '@sveltejs/kit/hooks';
@@ -95,7 +96,7 @@ var S = "handleWuchale", C = e`
95
96
  };
96
97
 
97
98
  export const handle = sequence(handleWuchale, /* your existing handle */);
98
- `, w = e`
99
+ `, E = e`
99
100
  import type { Handle } from '@sveltejs/kit/hooks';
100
101
  import { runWithLocale, loadLocales } from 'wuchale/load-utils/server';
101
102
  import { getLocale } from '#locales/main.url.js';
@@ -117,40 +118,40 @@ var S = "handleWuchale", C = e`
117
118
 
118
119
  export const handle = handleWuchale;
119
120
  `;
120
- function T(e, t, n) {
121
+ function D(e, t, n) {
121
122
  e.getImportDeclarations().find((e) => e.getModuleSpecifierValue() === t) || e.addImportDeclaration({
122
123
  namespaceImport: n,
123
124
  moduleSpecifier: t
124
125
  });
125
126
  }
126
- function E(t) {
127
- if (!m.existsSync(t)) return m.existsSync(t.replace(/\.ts$/, ".js")) ? {
127
+ function O(t) {
128
+ if (!g.existsSync(t)) return g.existsSync(t.replace(/\.ts$/, ".js")) ? {
128
129
  status: "failed",
129
- message: C
130
- } : (m.mkdirSync(h.dirname(t), { recursive: !0 }), m.writeFileSync(t, w + "\n"), {
130
+ message: T
131
+ } : (g.mkdirSync(_.dirname(t), { recursive: !0 }), g.writeFileSync(t, E + "\n"), {
131
132
  status: "success",
132
133
  changed: !0
133
134
  });
134
- let n = m.readFileSync(t, "utf8");
135
+ let n = g.readFileSync(t, "utf8");
135
136
  if (n.includes("runWithLocale") || n.includes("loadLocales(")) return {
136
137
  status: "success",
137
138
  changed: !1
138
139
  };
139
- let r = new g({
140
+ let r = new v({
140
141
  compilerOptions: { allowJs: !0 },
141
- manipulationSettings: { quoteKind: _.Single }
142
- }).addSourceFileAtPath(t), o = l(r, { expression: S });
142
+ manipulationSettings: { quoteKind: y.Single }
143
+ }).addSourceFileAtPath(t), o = l(r, { expression: w });
143
144
  if (o.status === "unsupported" || !o.statement) return {
144
145
  status: "failed",
145
- message: C
146
+ message: T
146
147
  };
147
148
  let s = o.statement;
148
- i(r, "wuchale/load-utils/server", "runWithLocale"), i(r, "wuchale/load-utils/server", "loadLocales"), i(r, "#locales/main.url.js", "getLocale"), i(r, "#locales/data.js", "locales"), T(r, "#locales/main.loader.server.svelte.js", "main"), T(r, "#locales/js.loader.server.js", "js");
149
+ i(r, "wuchale/load-utils/server", "runWithLocale"), i(r, "wuchale/load-utils/server", "loadLocales"), i(r, "#locales/main.url.js", "getLocale"), i(r, "#locales/data.js", "locales"), D(r, "#locales/main.loader.server.svelte.js", "main"), D(r, "#locales/js.loader.server.js", "js");
149
150
  let c = e`
150
151
  loadLocales(main.key, main.loadCount, main.loadCatalog, locales);
151
152
  loadLocales(js.key, js.loadCount, js.loadCatalog, locales);
152
153
  `, u = e`
153
- const ${S} = async ({ event, resolve }: any) => {
154
+ const ${w} = async ({ event, resolve }: any) => {
154
155
  const locale = getLocale(event.url);
155
156
  return await runWithLocale(locale, () =>
156
157
  resolve(event, {
@@ -167,13 +168,13 @@ function E(t) {
167
168
  }
168
169
  //#endregion
169
170
  //#region src/patterns/enable/i18n/modifies/hooks.ts
170
- var D = e`
171
+ var k = e`
171
172
  const rerouteDeLocalize = (url: string) => {
172
173
  const [upath, locale] = deLocalizeDefault(url, locales);
173
174
  const { path } = matchUrl(upath, locale);
174
175
  return path ?? url;
175
176
  };
176
- `, O = e`
177
+ `, A = e`
177
178
  import { deLocalizeDefault } from 'wuchale/url';
178
179
  import { matchUrl } from '#locales/main.url.js';
179
180
  import { locales } from '#locales/data.js';
@@ -185,7 +186,7 @@ var D = e`
185
186
  };
186
187
 
187
188
  export const reroute = ({ url }) => rerouteDeLocalize(url.pathname);
188
- `, k = e`
189
+ `, j = e`
189
190
  Compose your existing reroute in src/hooks.ts with the wuchale de-localizer:
190
191
 
191
192
  import { deLocalizeDefault } from 'wuchale/url';
@@ -199,56 +200,56 @@ var D = e`
199
200
  };
200
201
 
201
202
  export const reroute = ({ url }) => rerouteDeLocalize(existingReroute(url.pathname));
202
- `, A = /^\(\s*\{\s*url\s*\}\s*\)\s*=>\s*negotiateReroute\(\s*url\.pathname\s*\)$/;
203
- function j(e) {
203
+ `, M = /^\(\s*\{\s*url\s*\}\s*\)\s*=>\s*negotiateReroute\(\s*url\.pathname\s*\)$/;
204
+ function N(e) {
204
205
  return e.getFunction("reroute") ? !0 : e.getExportDeclarations().some((e) => e.getNamedExports().some((e) => (e.getAliasNode()?.getText() ?? e.getName()) === "reroute"));
205
206
  }
206
- function M(e) {
207
+ function P(e) {
207
208
  i(e, "wuchale/url", "deLocalizeDefault"), i(e, "#locales/main.url.js", "matchUrl"), i(e, "#locales/data.js", "locales");
208
209
  }
209
- function N(e) {
210
- if (!m.existsSync(e)) return m.mkdirSync(h.dirname(e), { recursive: !0 }), m.writeFileSync(e, O + "\n"), {
210
+ function ee(e) {
211
+ if (!g.existsSync(e)) return g.mkdirSync(_.dirname(e), { recursive: !0 }), g.writeFileSync(e, A + "\n"), {
211
212
  status: "success",
212
213
  changed: !0
213
214
  };
214
- if (m.readFileSync(e, "utf8").includes("rerouteDeLocalize")) return {
215
+ if (g.readFileSync(e, "utf8").includes("rerouteDeLocalize")) return {
215
216
  status: "success",
216
217
  changed: !1
217
218
  };
218
- let t = new g({
219
+ let t = new v({
219
220
  compilerOptions: { allowJs: !0 },
220
- manipulationSettings: { quoteKind: _.Single }
221
+ manipulationSettings: { quoteKind: y.Single }
221
222
  }).addSourceFileAtPath(e), n = t.getVariableDeclaration("reroute");
222
- if (!n) return j(t) ? {
223
+ if (!n) return N(t) ? {
223
224
  status: "failed",
224
- message: k
225
- } : (M(t), t.addStatements(`\n${D}\n\nexport const reroute = ({ url }) => rerouteDeLocalize(url.pathname);\n`), a(t), t.saveSync(), {
225
+ message: j
226
+ } : (P(t), t.addStatements(`\n${k}\n\nexport const reroute = ({ url }) => rerouteDeLocalize(url.pathname);\n`), a(t), t.saveSync(), {
226
227
  status: "success",
227
228
  changed: !0
228
229
  });
229
- if (!n.getFirstAncestorByKind(v.VariableStatement)?.hasExportKeyword()) return {
230
+ if (!n.getFirstAncestorByKind(b.VariableStatement)?.hasExportKeyword()) return {
230
231
  status: "failed",
231
- message: k
232
+ message: j
232
233
  };
233
234
  let r = n.getInitializer();
234
- if (!r || !A.test(r.getText())) return {
235
+ if (!r || !M.test(r.getText())) return {
235
236
  status: "failed",
236
- message: k
237
+ message: j
237
238
  };
238
- M(t), n.setInitializer("({ url }) => rerouteDeLocalize(negotiateReroute(url.pathname))");
239
+ P(t), n.setInitializer("({ url }) => rerouteDeLocalize(negotiateReroute(url.pathname))");
239
240
  let i = t.getVariableStatements().find((e) => e.getDeclarations().some((e) => e.getName() === "reroute"));
240
- return t.insertText(i.getStart(!0), `${D}\n\n`), a(t), t.saveSync(), {
241
+ return t.insertText(i.getStart(!0), `${k}\n\n`), a(t), t.saveSync(), {
241
242
  status: "success",
242
243
  changed: !0
243
244
  };
244
245
  }
245
246
  //#endregion
246
247
  //#region src/patterns/enable/i18n/modifies/app-html.ts
247
- var P = [
248
+ var F = [
248
249
  "Add the sveltekit lang placeholder to the <html> tag:",
249
250
  "",
250
251
  "<html lang=\"%sveltekit.lang%\">"
251
- ].join("\n"), F = [
252
+ ].join("\n"), I = [
252
253
  "Create src/app.html with a lang placeholder:",
253
254
  "",
254
255
  "<!doctype html>",
@@ -262,12 +263,12 @@ var P = [
262
263
  " </body>",
263
264
  "</html>"
264
265
  ].join("\n");
265
- function I(e) {
266
- if (!m.existsSync(e)) return {
266
+ function L(e) {
267
+ if (!g.existsSync(e)) return {
267
268
  status: "not-found",
268
- message: F
269
+ message: I
269
270
  };
270
- let t = m.readFileSync(e, "utf8");
271
+ let t = g.readFileSync(e, "utf8");
271
272
  if (t.includes("lang=\"%sveltekit.lang%\"") || t.includes("lang='%sveltekit.lang%'")) return {
272
273
  status: "success",
273
274
  changed: !1
@@ -275,26 +276,26 @@ function I(e) {
275
276
  let n = t.replace(/<html(\s[^>]*?)?>/i, (e) => /\slang\s*=/i.test(e) ? e.replace(/\slang\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/i, " lang=\"%sveltekit.lang%\"") : e.replace(/<html/i, "<html lang=\"%sveltekit.lang%\""));
276
277
  return n === t ? {
277
278
  status: "failed",
278
- message: P
279
- } : (m.writeFileSync(e, n), {
279
+ message: F
280
+ } : (g.writeFileSync(e, n), {
280
281
  status: "success",
281
282
  changed: !0
282
283
  });
283
284
  }
284
285
  //#endregion
285
286
  //#region src/patterns/enable/i18n/modifies/gitignore.ts
286
- var L = [
287
+ var R = [
287
288
  "Create a .gitignore with the wuchale cache ignored:",
288
289
  "",
289
290
  "# Wuchale",
290
291
  "src/locales/.wuchale"
291
292
  ].join("\n");
292
- function R(t) {
293
- if (!m.existsSync(t)) return {
293
+ function z(t) {
294
+ if (!g.existsSync(t)) return {
294
295
  status: "not-found",
295
- message: L
296
+ message: R
296
297
  };
297
- let n = m.readFileSync(t, "utf8");
298
+ let n = g.readFileSync(t, "utf8");
298
299
  if (n.includes("src/locales/.wuchale")) return {
299
300
  status: "success",
300
301
  changed: !1
@@ -303,55 +304,55 @@ function R(t) {
303
304
  # Wuchale
304
305
  src/locales/.wuchale
305
306
  `, i = n + (n.length > 0 && !n.endsWith("\n") ? "\n" : "") + "\n" + r + "\n";
306
- return m.writeFileSync(t, i), {
307
+ return g.writeFileSync(t, i), {
307
308
  status: "success",
308
309
  changed: !0
309
310
  };
310
311
  }
311
312
  //#endregion
312
313
  //#region src/patterns/enable/i18n/modifies/root-layout.svelte.ts
313
- var z = "<Navbar.Item>\n <LanguageSelect />\n </Navbar.Item>\n ", B = "<LanguageSelect />", V = e`
314
+ var B = "<Navbar.Item>\n <LanguageSelect />\n </Navbar.Item>\n ", V = "<LanguageSelect />", H = e`
314
315
  import LanguageSelect from '#lib/components/language-select.svelte';
315
- `, H = [
316
+ `, U = [
316
317
  "Add the language select inside your <Navbar.List> in the root layout.",
317
318
  "",
318
319
  "Import to add to the <script> tag:",
319
320
  "",
320
- V,
321
+ H,
321
322
  "",
322
323
  "Markup to add at the end of <Navbar.List>:",
323
- z
324
- ].join("\n"), U = [
324
+ B
325
+ ].join("\n"), W = [
325
326
  "Create a root layout that includes a language select inside <Navbar.List>.",
326
327
  "",
327
328
  "Import for the <script> tag:",
328
329
  "",
329
- V,
330
+ H,
330
331
  "",
331
332
  "Markup at the end of <Navbar.List>:",
332
- z
333
- ].join("\n"), W = [
333
+ B
334
+ ].join("\n"), G = [
334
335
  "Add the language select to your root layout.",
335
336
  "",
336
337
  "Import to add to the <script> tag:",
337
338
  "",
338
- V,
339
+ H,
339
340
  "",
340
341
  "Markup to add wherever it should render, e.g. above {@render children()}:",
341
342
  "",
342
- B
343
- ].join("\n"), G = [
343
+ V
344
+ ].join("\n"), K = [
344
345
  "Create a root layout that includes the language select.",
345
346
  "",
346
347
  "Import for the <script> tag:",
347
348
  "",
348
- V,
349
+ H,
349
350
  "",
350
351
  "Markup above {@render children()}:",
351
352
  "",
352
- B
353
+ V
353
354
  ].join("\n");
354
- function K(e) {
355
+ function q(e) {
355
356
  e.modifyScript((e) => {
356
357
  let { source: t } = r(e, (e) => {
357
358
  o(e, [{
@@ -362,45 +363,45 @@ function K(e) {
362
363
  return t;
363
364
  });
364
365
  }
365
- function q(e, t = "shadcn") {
366
+ function J(e, t = "shadcn") {
366
367
  let n = t === "plain";
367
- if (!m.existsSync(e)) return {
368
+ if (!g.existsSync(e)) return {
368
369
  status: "not-found",
369
- message: n ? G : U
370
+ message: n ? K : W
370
371
  };
371
372
  let r = c.fromPath(e);
372
373
  return r.hasElement("LanguageSelect") ? {
373
374
  status: "success",
374
375
  changed: !1
375
- } : n ? !r.getScript() || !r.insertBeforeChildren(B) ? {
376
+ } : n ? !r.getScript() || !r.insertBeforeChildren(V) ? {
376
377
  status: "failed",
377
- message: W
378
- } : (K(r), r.writeTo(e), {
378
+ message: G
379
+ } : (q(r), r.writeTo(e), {
379
380
  status: "success",
380
381
  changed: r.hasChanged()
381
- }) : r.hasElement("Navbar.List") ? (K(r), r.insertBeforeClosingTag("Navbar.List", z), r.writeTo(e), {
382
+ }) : r.hasElement("Navbar.List") ? (q(r), r.insertBeforeClosingTag("Navbar.List", B), r.writeTo(e), {
382
383
  status: "success",
383
384
  changed: r.hasChanged()
384
385
  }) : {
385
386
  status: "failed",
386
- message: H
387
+ message: U
387
388
  };
388
389
  }
389
390
  //#endregion
390
391
  //#region src/patterns/enable/i18n/welcome-catalog.ts
391
- var J = "src/routes/+page.svelte", Y = "src/locales/es.po", X = ["<h1>Welcome to SvelteKit</h1>", "<p>Visit <a href=\"https://svelte.dev/docs/kit\">svelte.dev/docs/kit</a> to read the documentation</p>"].join("\n"), Z = [{
392
- reference: J,
392
+ var Y = "src/routes/+page.svelte", X = "src/locales/es.po", Z = ["<h1>Welcome to SvelteKit</h1>", "<p>Visit <a href=\"https://svelte.dev/docs/kit\">svelte.dev/docs/kit</a> to read the documentation</p>"].join("\n"), Q = [{
393
+ reference: Y,
393
394
  msgid: "Welcome to SvelteKit",
394
395
  msgstr: "Bienvenido a SvelteKit"
395
396
  }, {
396
- reference: J,
397
+ reference: Y,
397
398
  msgid: "Visit <0>svelte.dev/docs/kit</0> to read the documentation",
398
399
  msgstr: "Visita <0>svelte.dev/docs/kit</0> para leer la documentación"
399
- }], Q = {
400
+ }], te = {
400
401
  reference: "src/lib/components/language-select.svelte",
401
402
  msgid: "Language",
402
403
  msgstr: "Idioma"
403
- }, ee = [
404
+ }, ne = [
404
405
  "msgid \"\"",
405
406
  "msgstr \"\"",
406
407
  "\"Source-Language: en\\n\"",
@@ -411,13 +412,13 @@ var J = "src/routes/+page.svelte", Y = "src/locales/es.po", X = ["<h1>Welcome to
411
412
  "\"Plural-Forms: nplurals=3\\n\"",
412
413
  "\"X-Plurals-Order: one, many, other\\n\""
413
414
  ].join("\n"), $ = (e) => e.replace(/\s+/g, "");
414
- function te(e, t) {
415
- if (m.existsSync(h.join(e, Y))) return null;
416
- let n = h.join(e, J);
417
- return !m.existsSync(n) || $(m.readFileSync(n, "utf8")) !== $(X) ? null : {
418
- path: Y,
415
+ function re(e, t) {
416
+ if (g.existsSync(_.join(e, X))) return null;
417
+ let n = _.join(e, Y);
418
+ return !g.existsSync(n) || $(g.readFileSync(n, "utf8")) !== $(Z) ? null : {
419
+ path: X,
419
420
  language: "text",
420
- content: [ee, ...(t === "plain" ? [...Z, Q] : Z).map((e) => [
421
+ content: [ne, ...(t === "plain" ? [...Q, te] : Q).map((e) => [
421
422
  `#: ${e.reference}`,
422
423
  `msgid "${e.msgid}"`,
423
424
  `msgstr "${e.msgstr}"`
@@ -427,33 +428,44 @@ function te(e, t) {
427
428
  }
428
429
  //#endregion
429
430
  //#region src/patterns/enable/i18n/generate.runtime.ts
430
- async function ne(e) {
431
+ function ie(e, t) {
432
+ let n = h.filter((t) => g.existsSync(_.join(e, t)));
433
+ return n.length === 0 ? t : t.map((e) => {
434
+ if (!e.path.endsWith("wuchale.config.js")) return e;
435
+ let t = m(e.content, n);
436
+ return t?.changed ? {
437
+ ...e,
438
+ content: t.source
439
+ } : e;
440
+ });
441
+ }
442
+ async function ae(e) {
431
443
  let r = n(e), i = [], a = (e) => {
432
444
  e && i.push(e);
433
445
  };
434
446
  r.info("Modifying vite.config");
435
- let o = u(e.root, d) ?? h.join(e.root, d[0]);
436
- a(s(o, x(o))), r.info("Adding #locales to package.json imports");
447
+ let o = u(e.root, d) ?? _.join(e.root, d[0]);
448
+ a(s(o, C(o))), r.info("Adding #locales to package.json imports");
437
449
  let c = f(e.root);
438
450
  a(s(c.filePath, c.outcome)), r.info("Modifying hooks.server.ts");
439
- let l = h.join(e.root, "src", "hooks.server.ts");
440
- a(s(l, E(l))), r.info("Modifying hooks.ts");
441
- let g = h.join(e.root, "src", "hooks.ts");
442
- a(s(g, N(g))), r.info("Modifying app.html");
443
- let _ = h.join(e.root, "src", "app.html");
444
- a(s(_, I(_))), r.info("Modifying root +layout.ts");
445
- let v = h.join(e.root, "src", "routes", "+layout.ts");
451
+ let l = _.join(e.root, "src", "hooks.server.ts");
452
+ a(s(l, O(l))), r.info("Modifying hooks.ts");
453
+ let m = _.join(e.root, "src", "hooks.ts");
454
+ a(s(m, ee(m))), r.info("Modifying app.html");
455
+ let h = _.join(e.root, "src", "app.html");
456
+ a(s(h, L(h))), r.info("Modifying root +layout.ts");
457
+ let v = _.join(e.root, "src", "routes", "+layout.ts");
446
458
  a(s(v, p(v))), r.info("Modifying root layout language select");
447
459
  let y = [
448
- h.join(e.root, "src", "routes", "(public)", "root-layout.svelte"),
449
- h.join(e.root, "src", "routes", "root-layout.svelte"),
450
- h.join(e.root, "src", "routes", "(public)", "+layout.svelte"),
451
- h.join(e.root, "src", "routes", "+layout.svelte")
452
- ], b = t(e), S = y.find((e) => m.existsSync(e)) ?? (b === "plain" ? y[3] : y[0]);
453
- a(s(S, q(S, b))), r.info("Updating .gitignore");
454
- let C = h.join(e.root, ".gitignore");
455
- a(s(C, R(C)));
456
- let w = te(e.root, b);
460
+ _.join(e.root, "src", "routes", "(public)", "root-layout.svelte"),
461
+ _.join(e.root, "src", "routes", "root-layout.svelte"),
462
+ _.join(e.root, "src", "routes", "(public)", "+layout.svelte"),
463
+ _.join(e.root, "src", "routes", "+layout.svelte")
464
+ ], b = t(e), x = y.find((e) => g.existsSync(e)) ?? (b === "plain" ? y[3] : y[0]);
465
+ a(s(x, J(x, b))), r.info("Updating .gitignore");
466
+ let S = _.join(e.root, ".gitignore");
467
+ a(s(S, z(S)));
468
+ let w = re(e.root, b);
457
469
  return w && r.info("Translating the welcome page into Spanish"), {
458
470
  creates: w ? [w] : [],
459
471
  modifies: i,
@@ -466,6 +478,6 @@ async function ne(e) {
466
478
  };
467
479
  }
468
480
  //#endregion
469
- export { ne as generate };
481
+ export { ae as generate, ie as withLibraryTexts };
470
482
 
471
- //# sourceMappingURL=generate.runtime-utFLS6Jz.js.map
483
+ //# sourceMappingURL=generate.runtime-DlLwmjGF.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.runtime-DlLwmjGF.js","names":["FAILURE_HINT","NOT_FOUND_HINT","FAILURE_HINT","FAILURE_HINT","FAILURE_HINT","NOT_FOUND_HINT","NOT_FOUND_HINT","dedent","withInMemoryScript","formatLikeSource","ensureImports","modifyOutcomeToFile","SvelteFile","addHandle","probeFirstExisting","VITE_CONFIG_CANDIDATES","modifyPackageImportsI18n","ensureRootLayoutI18n","withWuchaleJsFiles","TRANSLATED_LIB_FILES","fs","path","FAILURE_HINT$4","NOT_FOUND_HINT$3","modifyViteConfig","viteConfigPath","sourceFile","Project","QuoteKind","changed","failed","d","configArg","SyntaxKind","ce","configObj","pluginsProp","pluginsInit","arr","el","I18N_HANDLE","FAILURE_HINT$3","HOOKS_SERVER_SNIPPET","ensureNamespaceImport","moduleSpecifier","ns","modifyHooksServerI18n","hooksServerPath","original","composed","handleStmt","ensureNamedImport","startupSnippet","i18nHandleSnippet","DELOCALIZE_HELPER","HOOKS_SNIPPET","FAILURE_HINT$2","NEGOTIATE_ONLY_REROUTE","hasOtherReroute","n","ensureDeLocalizeImports","modifyHooksI18n","hooksPath","rerouteDecl","init","target","s","FAILURE_HINT$1","NOT_FOUND_HINT$2","modifyAppHtml","appHtmlPath","updated","match","NOT_FOUND_HINT$1","modifyGitignore","gitignorePath","block","LANGUAGE_SELECT_SNIPPET","PLAIN_LANGUAGE_SELECT_SNIPPET","IMPORT_SNIPPET","FAILURE_HINT","NOT_FOUND_HINT","PLAIN_FAILURE_HINT","PLAIN_NOT_FOUND_HINT","addImport","out","source","sf","modifyRootLayoutLanguageSelect","plain","ui","layoutPath","file","PAGE_PATH","CATALOG_PATH","WELCOME_PAGE","PAGE_ENTRIES","PLAIN_SELECT_ENTRY","HEADER","normalize","welcomePageCatalog","root","pagePath","entry","withLibraryTexts","present","creates","edited","generate","logger","getLogger","options","modifies","pushResult","imports","rootLayoutCandidates","resolveUi","rootLayoutPath","p","catalog"],"sources":["../../src/patterns/enable/i18n/modifies/vite-config.ts","../../src/patterns/enable/i18n/modifies/hooks.server.ts","../../src/patterns/enable/i18n/modifies/hooks.ts","../../src/patterns/enable/i18n/modifies/app-html.ts","../../src/patterns/enable/i18n/modifies/gitignore.ts","../../src/patterns/enable/i18n/modifies/root-layout.svelte.ts","../../src/patterns/enable/i18n/welcome-catalog.ts","../../src/patterns/enable/i18n/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { Project, QuoteKind, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { formatLikeSource } from \"../../../../runtime/ts-morph-helpers\";\n\nconst FAILURE_HINT = [\n \"Add the wuchale plugin to your Vite config:\",\n \"\",\n \"import { wuchale } from 'wuchale/vite';\",\n \"\",\n \"export default defineConfig({\",\n \" plugins: [wuchale(), /* ...existing plugins */],\",\n \"});\",\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create a Vite config with the wuchale plugin:\",\n \"\",\n \"import { defineConfig } from 'vite';\",\n \"import { wuchale } from 'wuchale/vite';\",\n \"\",\n \"export default defineConfig({\",\n \" plugins: [wuchale()],\",\n \"});\",\n].join(\"\\n\");\n\nexport function modifyViteConfig(viteConfigPath: string): ModifyOutcome {\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() === \"wuchale/vite\");\n\n if (!hasImport) {\n sourceFile.insertImportDeclaration(0, {\n namedImports: [\"wuchale\"],\n moduleSpecifier: \"wuchale/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 import(\"ts-morph\").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: \"[wuchale()]\",\n });\n changed = true;\n } else if (pluginsProp.getKind() !== SyntaxKind.PropertyAssignment) {\n failed = true;\n } else {\n const pluginsInit = (\n pluginsProp as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n\n if (!pluginsInit) {\n (pluginsProp as import(\"ts-morph\").PropertyAssignment).setInitializer(\n \"[wuchale()]\",\n );\n changed = true;\n } else if (pluginsInit.getKind() !== SyntaxKind.ArrayLiteralExpression) {\n failed = true;\n } else {\n const arr = pluginsInit as import(\"ts-morph\").ArrayLiteralExpression;\n const hasWuchale = arr\n .getElements()\n .some((el) => el.getText().replace(/\\s/g, \"\") === \"wuchale()\");\n\n if (!hasWuchale) {\n arr.insertElement(0, \"wuchale()\");\n changed = true;\n }\n }\n }\n }\n\n if (changed) {\n formatLikeSource(sourceFile);\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 fs from \"node:fs\";\nimport path from \"node:path\";\nimport dedent from \"dedent\";\nimport { Project, QuoteKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { addHandle } from \"../../../../runtime/compose-handle\";\nimport {\n ensureNamedImport,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nconst I18N_HANDLE = \"handleWuchale\";\n\nconst FAILURE_HINT = dedent`\n Wrap your exported handle with the wuchale i18n handler:\n\n import { sequence } from '@sveltejs/kit/hooks';\n import { runWithLocale, loadLocales } from 'wuchale/load-utils/server';\n import { getLocale } from '#locales/main.url.js';\n import { locales } from '#locales/data.js';\n import * as main from '#locales/main.loader.server.svelte.js';\n import * as js from '#locales/js.loader.server.js';\n\n loadLocales(main.key, main.loadCount, main.loadCatalog, locales);\n loadLocales(js.key, js.loadCount, js.loadCatalog, locales);\n\n const handleWuchale = async ({ event, resolve }: any) => {\n const locale = getLocale(event.url);\n return await runWithLocale(locale, () =>\n resolve(event, {\n transformPageChunk: ({ html }: { html: string }) =>\n html.replace('%sveltekit.lang%', locale),\n }),\n );\n };\n\n export const handle = sequence(handleWuchale, /* your existing handle */);\n`;\n\n/**\n * The whole file, for a project that had no server hooks: a fresh `sv create`\n * app or a static site. `disable-i18n` deletes it again once the i18n handle\n * is all that is left.\n */\nexport const HOOKS_SERVER_SNIPPET = dedent`\n import type { Handle } from '@sveltejs/kit/hooks';\n import { runWithLocale, loadLocales } from 'wuchale/load-utils/server';\n import { getLocale } from '#locales/main.url.js';\n import { locales } from '#locales/data.js';\n import * as main from '#locales/main.loader.server.svelte.js';\n import * as js from '#locales/js.loader.server.js';\n\n loadLocales(main.key, main.loadCount, main.loadCatalog, locales);\n loadLocales(js.key, js.loadCount, js.loadCatalog, locales);\n\n const handleWuchale: Handle = async ({ event, resolve }) => {\n const locale = getLocale(event.url);\n return await runWithLocale(locale, () =>\n resolve(event, {\n transformPageChunk: ({ html }) => html.replace('%sveltekit.lang%', locale)\n })\n );\n };\n\n export const handle = handleWuchale;\n`;\n\nfunction ensureNamespaceImport(\n sourceFile: import(\"ts-morph\").SourceFile,\n moduleSpecifier: string,\n ns: string,\n) {\n const existing = sourceFile\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === moduleSpecifier);\n if (existing) return;\n sourceFile.addImportDeclaration({ namespaceImport: ns, moduleSpecifier });\n}\n\nexport function modifyHooksServerI18n(hooksServerPath: string): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n // SvelteKit loads the first `hooks.server.*` it finds, and `.js` sorts\n // first, so a new `.ts` beside it would never run.\n if (fs.existsSync(hooksServerPath.replace(/\\.ts$/, \".js\"))) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n fs.mkdirSync(path.dirname(hooksServerPath), { recursive: true });\n fs.writeFileSync(hooksServerPath, HOOKS_SERVER_SNIPPET + \"\\n\");\n return { status: \"success\", changed: true };\n }\n\n const original = fs.readFileSync(hooksServerPath, \"utf8\");\n if (original.includes(\"runWithLocale\") || 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 // Composed first: an unsupported handle leaves the file untouched.\n const composed = addHandle(sourceFile, { expression: I18N_HANDLE });\n if (composed.status === \"unsupported\" || !composed.statement) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n const handleStmt = composed.statement;\n\n ensureNamedImport(sourceFile, \"wuchale/load-utils/server\", \"runWithLocale\");\n ensureNamedImport(sourceFile, \"wuchale/load-utils/server\", \"loadLocales\");\n ensureNamedImport(sourceFile, \"#locales/main.url.js\", \"getLocale\");\n ensureNamedImport(sourceFile, \"#locales/data.js\", \"locales\");\n ensureNamespaceImport(\n sourceFile,\n \"#locales/main.loader.server.svelte.js\",\n \"main\",\n );\n ensureNamespaceImport(sourceFile, \"#locales/js.loader.server.js\", \"js\");\n\n const startupSnippet = dedent`\n loadLocales(main.key, main.loadCount, main.loadCatalog, locales);\n loadLocales(js.key, js.loadCount, js.loadCatalog, locales);\n `;\n\n const i18nHandleSnippet = dedent`\n const ${I18N_HANDLE} = async ({ event, resolve }: any) => {\n const locale = getLocale(event.url);\n return await runWithLocale(locale, () =>\n resolve(event, {\n transformPageChunk: ({ html }: { html: string }) =>\n html.replace('%sveltekit.lang%', locale)\n })\n );\n };\n `;\n\n // Above the handle and its JSDoc, so `handleWuchale` is declared before\n // the handle reads it.\n sourceFile.insertText(\n handleStmt.getStart(true),\n `${startupSnippet}\\n\\n${i18nHandleSnippet}\\n\\n`,\n );\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport dedent from \"dedent\";\nimport { Project, QuoteKind, SyntaxKind, type SourceFile } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport {\n ensureNamedImport,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nconst DELOCALIZE_HELPER = dedent`\n const rerouteDeLocalize = (url: string) => {\n const [upath, locale] = deLocalizeDefault(url, locales);\n const { path } = matchUrl(upath, locale);\n return path ?? url;\n };\n`;\n\n/**\n * The whole file, for a project that had no universal hooks. `disable-i18n`\n * deletes it again once the de-localizing reroute is all that is left.\n */\nexport const HOOKS_SNIPPET = dedent`\n import { deLocalizeDefault } from 'wuchale/url';\n import { matchUrl } from '#locales/main.url.js';\n import { locales } from '#locales/data.js';\n\n const rerouteDeLocalize = (url: string) => {\n const [upath, locale] = deLocalizeDefault(url, locales);\n const { path } = matchUrl(upath, locale);\n return path ?? url;\n };\n\n export const reroute = ({ url }) => rerouteDeLocalize(url.pathname);\n`;\n\nconst FAILURE_HINT = dedent`\n Compose your existing reroute in src/hooks.ts with the wuchale de-localizer:\n\n import { deLocalizeDefault } from 'wuchale/url';\n import { matchUrl } from '#locales/main.url.js';\n import { locales } from '#locales/data.js';\n\n const rerouteDeLocalize = (url: string) => {\n const [upath, locale] = deLocalizeDefault(url, locales);\n const { path } = matchUrl(upath, locale);\n return path ?? url;\n };\n\n export const reroute = ({ url }) => rerouteDeLocalize(existingReroute(url.pathname));\n`;\n\n/** What `enable-content-negotiation` leaves behind, to the whitespace. */\nconst NEGOTIATE_ONLY_REROUTE =\n /^\\(\\s*\\{\\s*url\\s*\\}\\s*\\)\\s*=>\\s*negotiateReroute\\(\\s*url\\.pathname\\s*\\)$/;\n\n/** A `reroute` this modifier cannot compose with: not a variable declaration. */\nfunction hasOtherReroute(sourceFile: SourceFile): boolean {\n if (sourceFile.getFunction(\"reroute\")) return true;\n return sourceFile\n .getExportDeclarations()\n .some((d) =>\n d\n .getNamedExports()\n .some(\n (n) => (n.getAliasNode()?.getText() ?? n.getName()) === \"reroute\",\n ),\n );\n}\n\nfunction ensureDeLocalizeImports(sourceFile: SourceFile) {\n ensureNamedImport(sourceFile, \"wuchale/url\", \"deLocalizeDefault\");\n ensureNamedImport(sourceFile, \"#locales/main.url.js\", \"matchUrl\");\n ensureNamedImport(sourceFile, \"#locales/data.js\", \"locales\");\n}\n\n/**\n * Add the de-localizing reroute to `src/hooks.ts`, composing with the one\n * `enable-content-negotiation` wrote rather than replacing the file: either\n * pattern may be enabled first, and negotiation's `modifyHooksNegotiate`\n * composes the other way round.\n */\nexport function modifyHooksI18n(hooksPath: string): ModifyOutcome {\n if (!fs.existsSync(hooksPath)) {\n fs.mkdirSync(path.dirname(hooksPath), { recursive: true });\n fs.writeFileSync(hooksPath, HOOKS_SNIPPET + \"\\n\");\n return { status: \"success\", changed: true };\n }\n\n const original = fs.readFileSync(hooksPath, \"utf8\");\n if (original.includes(\"rerouteDeLocalize\")) {\n return { status: \"success\", changed: false };\n }\n\n const project = new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(hooksPath);\n\n const rerouteDecl = sourceFile.getVariableDeclaration(\"reroute\");\n\n if (!rerouteDecl) {\n // A reroute in a shape ts-morph cannot rewrite (a function declaration,\n // a re-export) would collide with the one added below.\n if (hasOtherReroute(sourceFile)) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n ensureDeLocalizeImports(sourceFile);\n sourceFile.addStatements(\n `\\n${DELOCALIZE_HELPER}\\n\\nexport const reroute = ({ url }) => rerouteDeLocalize(url.pathname);\\n`,\n );\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n const rerouteStmt = rerouteDecl.getFirstAncestorByKind(\n SyntaxKind.VariableStatement,\n );\n if (!rerouteStmt?.hasExportKeyword()) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const init = rerouteDecl.getInitializer();\n if (!init || !NEGOTIATE_ONLY_REROUTE.test(init.getText())) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n ensureDeLocalizeImports(sourceFile);\n rerouteDecl.setInitializer(\n \"({ url }) => rerouteDeLocalize(negotiateReroute(url.pathname))\",\n );\n\n // Last: inserting text forgets the nodes above, and the helper has to be\n // declared before the reroute that reads it.\n const target = sourceFile\n .getVariableStatements()\n .find((s) => s.getDeclarations().some((d) => d.getName() === \"reroute\"))!;\n sourceFile.insertText(target.getStart(true), `${DELOCALIZE_HELPER}\\n\\n`);\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst FAILURE_HINT = [\n \"Add the sveltekit lang placeholder to the <html> tag:\",\n \"\",\n '<html lang=\"%sveltekit.lang%\">',\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create src/app.html with a lang placeholder:\",\n \"\",\n \"<!doctype html>\",\n '<html lang=\"%sveltekit.lang%\">',\n \" <head>\",\n ' <meta charset=\"utf-8\" />',\n \" %sveltekit.head%\",\n \" </head>\",\n ' <body data-sveltekit-preload-data=\"hover\">',\n ' <div style=\"display: contents\">%sveltekit.body%</div>',\n \" </body>\",\n \"</html>\",\n].join(\"\\n\");\n\nexport function modifyAppHtml(appHtmlPath: string): ModifyOutcome {\n if (!fs.existsSync(appHtmlPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const original = fs.readFileSync(appHtmlPath, \"utf8\");\n if (\n original.includes('lang=\"%sveltekit.lang%\"') ||\n original.includes(\"lang='%sveltekit.lang%'\")\n ) {\n return { status: \"success\", changed: false };\n }\n\n const updated = original.replace(/<html(\\s[^>]*?)?>/i, (match) => {\n // A static lang (the templates ship lang=\"en\") is replaced by the\n // placeholder so the server hook can fill in the negotiated locale.\n if (/\\slang\\s*=/i.test(match)) {\n return match.replace(\n /\\slang\\s*=\\s*(?:\"[^\"]*\"|'[^']*'|[^\\s>]+)/i,\n ' lang=\"%sveltekit.lang%\"',\n );\n }\n return match.replace(/<html/i, '<html lang=\"%sveltekit.lang%\"');\n });\n\n if (updated === original) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n fs.writeFileSync(appHtmlPath, updated);\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst NOT_FOUND_HINT = [\n \"Create a .gitignore with the wuchale cache ignored:\",\n \"\",\n \"# Wuchale\",\n \"src/locales/.wuchale\",\n].join(\"\\n\");\n\nexport function modifyGitignore(gitignorePath: string): ModifyOutcome {\n if (!fs.existsSync(gitignorePath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\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 block = dedent`\n # Wuchale\n src/locales/.wuchale\n `;\n\n const needsNewline = original.length > 0 && !original.endsWith(\"\\n\");\n const updated = original + (needsNewline ? \"\\n\" : \"\") + \"\\n\" + block + \"\\n\";\n fs.writeFileSync(gitignorePath, updated);\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\";\nimport type { Ui } from \"../../../../core/field/ui\";\n\nconst LANGUAGE_SELECT_SNIPPET = `<Navbar.Item>\n\t\t\t\t<LanguageSelect />\n\t\t\t</Navbar.Item>\n\t\t\t`;\n\nconst PLAIN_LANGUAGE_SELECT_SNIPPET = \"<LanguageSelect />\";\n\nconst IMPORT_SNIPPET = dedent`\n import LanguageSelect from '#lib/components/language-select.svelte';\n`;\n\nconst FAILURE_HINT = [\n \"Add the language select inside your <Navbar.List> in the root layout.\",\n \"\",\n \"Import to add to the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup to add at the end of <Navbar.List>:\",\n LANGUAGE_SELECT_SNIPPET,\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create a root layout that includes a language select inside <Navbar.List>.\",\n \"\",\n \"Import for the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup at the end of <Navbar.List>:\",\n LANGUAGE_SELECT_SNIPPET,\n].join(\"\\n\");\n\nconst PLAIN_FAILURE_HINT = [\n \"Add the language select to your root layout.\",\n \"\",\n \"Import to add to the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup to add wherever it should render, e.g. above {@render children()}:\",\n \"\",\n PLAIN_LANGUAGE_SELECT_SNIPPET,\n].join(\"\\n\");\n\nconst PLAIN_NOT_FOUND_HINT = [\n \"Create a root layout that includes the language select.\",\n \"\",\n \"Import for the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup above {@render children()}:\",\n \"\",\n PLAIN_LANGUAGE_SELECT_SNIPPET,\n].join(\"\\n\");\n\nfunction addImport(file: SvelteFile): void {\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n ensureImports(sf, [\n {\n defaultImport: \"LanguageSelect\",\n moduleSpecifier: \"#lib/components/language-select.svelte\",\n },\n ]);\n });\n return out;\n });\n}\n\n/**\n * A vela layout gets the select as the last `<Navbar.List>` item. A plain one\n * (a project vela did not create) has no navbar, so the select goes above the\n * layout's children.\n */\nexport function modifyRootLayoutLanguageSelect(\n layoutPath: string,\n ui: Ui = \"shadcn\",\n): ModifyOutcome {\n const plain = ui === \"plain\";\n if (!fs.existsSync(layoutPath)) {\n return {\n status: \"not-found\",\n message: plain ? PLAIN_NOT_FOUND_HINT : NOT_FOUND_HINT,\n };\n }\n\n const file = SvelteFile.fromPath(layoutPath);\n if (file.hasElement(\"LanguageSelect\")) {\n return { status: \"success\", changed: false };\n }\n\n if (plain) {\n // Without a <script> the import has nowhere to go, and the markup alone\n // would not compile.\n if (!file.getScript()) {\n return { status: \"failed\", message: PLAIN_FAILURE_HINT };\n }\n if (!file.insertBeforeChildren(PLAIN_LANGUAGE_SELECT_SNIPPET)) {\n return { status: \"failed\", message: PLAIN_FAILURE_HINT };\n }\n addImport(file);\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n }\n\n if (!file.hasElement(\"Navbar.List\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n addImport(file);\n file.insertBeforeClosingTag(\"Navbar.List\", LANGUAGE_SELECT_SNIPPET);\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 } from \"../../../core/types\";\nimport type { Ui } from \"../../../core/field/ui\";\n\nconst PAGE_PATH = \"src/routes/+page.svelte\";\nconst CATALOG_PATH = \"src/locales/es.po\";\n\n/** `src/routes/+page.svelte` as `sv create` writes it. */\nconst WELCOME_PAGE = [\n \"<h1>Welcome to SvelteKit</h1>\",\n '<p>Visit <a href=\"https://svelte.dev/docs/kit\">svelte.dev/docs/kit</a> to read the documentation</p>',\n].join(\"\\n\");\n\ninterface Entry {\n reference: string;\n msgid: string;\n msgstr: string;\n}\n\nconst PAGE_ENTRIES: Entry[] = [\n {\n reference: PAGE_PATH,\n msgid: \"Welcome to SvelteKit\",\n msgstr: \"Bienvenido a SvelteKit\",\n },\n {\n reference: PAGE_PATH,\n msgid: \"Visit <0>svelte.dev/docs/kit</0> to read the documentation\",\n msgstr: \"Visita <0>svelte.dev/docs/kit</0> para leer la documentación\",\n },\n];\n\n// The native <select>'s aria-label. The shadcn select has no text of its own:\n// locale names come from Intl.DisplayNames.\nconst PLAIN_SELECT_ENTRY: Entry = {\n reference: \"src/lib/components/language-select.svelte\",\n msgid: \"Language\",\n msgstr: \"Idioma\",\n};\n\n// What wuchale writes for `es`. It rewrites the file on the first extraction,\n// keeping these translations and adding the source locale's catalog.\nconst HEADER = [\n 'msgid \"\"',\n 'msgstr \"\"',\n '\"Source-Language: en\\\\n\"',\n '\"Language: es\\\\n\"',\n '\"MIME-Version: 1.0\\\\n\"',\n '\"Content-Type: text/plain; charset=utf-8\\\\n\"',\n '\"Content-Transfer-Encoding: 8bit\\\\n\"',\n '\"Plural-Forms: nplurals=3\\\\n\"',\n '\"X-Plurals-Order: one, many, other\\\\n\"',\n].join(\"\\n\");\n\n// Whitespace is ignored so a page prettier has rewrapped still counts.\nconst normalize = (source: string) => source.replace(/\\s+/g, \"\");\n\n/**\n * A Spanish catalog for the `sv create` welcome page, so the language select\n * visibly does something on a fresh project. Anything else in the project is\n * left for the user to translate. Null unless the page is untouched, and never\n * over an existing catalog.\n */\nexport function welcomePageCatalog(root: string, ui: Ui): File | null {\n if (fs.existsSync(path.join(root, CATALOG_PATH))) return null;\n\n const pagePath = path.join(root, PAGE_PATH);\n if (!fs.existsSync(pagePath)) return null;\n const page = fs.readFileSync(pagePath, \"utf8\");\n if (normalize(page) !== normalize(WELCOME_PAGE)) return null;\n\n const entries =\n ui === \"plain\" ? [...PAGE_ENTRIES, PLAIN_SELECT_ENTRY] : PAGE_ENTRIES;\n const blocks = entries.map((entry) =>\n [\n `#: ${entry.reference}`,\n `msgid \"${entry.msgid}\"`,\n `msgstr \"${entry.msgstr}\"`,\n ].join(\"\\n\"),\n );\n\n return {\n path: CATALOG_PATH,\n language: \"text\",\n content: [HEADER, ...blocks].join(\"\\n\\n\") + \"\\n\",\n status: \"success\",\n };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { resolveUi } from \"../../../core/field/ui\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport {\n probeFirstExisting,\n VITE_CONFIG_CANDIDATES,\n} from \"../../../runtime/config-target\";\nimport { modifyViteConfig } from \"./modifies/vite-config\";\nimport { modifyPackageImportsI18n } from \"./modifies/package-imports\";\nimport { modifyHooksServerI18n } from \"./modifies/hooks.server\";\nimport { modifyHooksI18n } from \"./modifies/hooks\";\nimport { modifyAppHtml } from \"./modifies/app-html\";\nimport { modifyGitignore } from \"./modifies/gitignore\";\nimport { ensureRootLayoutI18n } from \"./modifies/+layout\";\nimport { modifyRootLayoutLanguageSelect } from \"./modifies/root-layout.svelte\";\nimport { welcomePageCatalog } from \"./welcome-catalog\";\nimport {\n TRANSLATED_LIB_FILES,\n withWuchaleJsFiles,\n} from \"../../../runtime/wuchale-config\";\n\n/**\n * The `wuchale.config.js` create, with the library modules that carry\n * visitor-facing text and already exist in the project (the WhatsApp order\n * message, say) listed for the js adapter. A pattern enabled later adds its\n * own module to the written config.\n */\nexport function withLibraryTexts(root: string, creates: File[]): File[] {\n const present = TRANSLATED_LIB_FILES.filter((file) =>\n fs.existsSync(path.join(root, file)),\n );\n if (present.length === 0) return creates;\n return creates.map((file) => {\n if (!file.path.endsWith(\"wuchale.config.js\")) return file;\n const edited = withWuchaleJsFiles(file.content, present);\n return edited?.changed ? { ...file, content: edited.source } : file;\n });\n}\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Modifying vite.config\");\n const viteConfigPath =\n probeFirstExisting(options.root, VITE_CONFIG_CANDIDATES) ??\n path.join(options.root, VITE_CONFIG_CANDIDATES[0]);\n pushResult(\n modifyOutcomeToFile(viteConfigPath, modifyViteConfig(viteConfigPath)),\n );\n\n logger.info(\"Adding #locales to package.json imports\");\n const imports = modifyPackageImportsI18n(options.root);\n pushResult(modifyOutcomeToFile(imports.filePath, imports.outcome));\n\n logger.info(\"Modifying hooks.server.ts\");\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n pushResult(\n modifyOutcomeToFile(\n hooksServerPath,\n modifyHooksServerI18n(hooksServerPath),\n ),\n );\n\n logger.info(\"Modifying hooks.ts\");\n const hooksPath = path.join(options.root, \"src\", \"hooks.ts\");\n pushResult(modifyOutcomeToFile(hooksPath, modifyHooksI18n(hooksPath)));\n\n logger.info(\"Modifying app.html\");\n const appHtmlPath = path.join(options.root, \"src\", \"app.html\");\n pushResult(modifyOutcomeToFile(appHtmlPath, modifyAppHtml(appHtmlPath)));\n\n logger.info(\"Modifying root +layout.ts\");\n const layoutPath = path.join(options.root, \"src\", \"routes\", \"+layout.ts\");\n pushResult(modifyOutcomeToFile(layoutPath, ensureRootLayoutI18n(layoutPath)));\n\n logger.info(\"Modifying 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 const ui = resolveUi(options);\n // With no layout at all, a plain project's not-found hint names the\n // +layout.svelte it would have rather than vela's root-layout.svelte.\n const rootLayoutPath =\n rootLayoutCandidates.find((p) => fs.existsSync(p)) ??\n (ui === \"plain\" ? rootLayoutCandidates[3] : rootLayoutCandidates[0]);\n pushResult(\n modifyOutcomeToFile(\n rootLayoutPath,\n modifyRootLayoutLanguageSelect(rootLayoutPath, ui),\n ),\n );\n\n logger.info(\"Updating .gitignore\");\n const gitignorePath = path.join(options.root, \".gitignore\");\n pushResult(\n modifyOutcomeToFile(gitignorePath, modifyGitignore(gitignorePath)),\n );\n\n const catalog = welcomePageCatalog(options.root, ui);\n if (catalog) logger.info(\"Translating the welcome page into Spanish\");\n\n return {\n creates: catalog ? [catalog] : [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;;;;;;AAKA,IAAMA,IAAe;CACnB;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,CAAC,KAAK,IAAI,GAELC,IAAiB;CACrB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,CAAC,KAAK,IAAI;AAEX,SAAgBuB,EAAiB,GAAuC;CACtE,IAAI,CAACJ,EAAG,WAAWK,CAAc,GAC/B,OAAO;EAAE,QAAQ;EAAa,SAASxB;CAAe;CAOxD,IAAMyB,IAAa,IAJCC,EAAQ;EAC1B,iBAAiB,EAAE,SAAS,GAAK;EACjC,sBAAsB,EAAE,WAAWC,EAAU,OAAO;CACtD,CACmB,CAAA,CAAQ,oBAAoBH,CAAc,GAEzDI,IAAU,IACVC,IAAS;CAMb,AAJkBJ,EACf,sBAAsB,CAAC,CACvB,MAAM,MAAMK,EAAE,wBAAwB,MAAM,cAE1C,MACHL,EAAW,wBAAwB,GAAG;EACpC,cAAc,CAAC,SAAS;EACxB,iBAAiB;CACnB,CAAC,GACD,IAAU;CAOZ,IAAMM,IAJmBN,EACtB,qBAAqBO,EAAW,cAAc,CAAC,CA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