@velastack/patterns 0.3.3 → 0.4.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.
- package/README.md +44 -2
- package/dist/chunks/_layout-kkgN0IF7.js +62 -0
- package/dist/chunks/_layout-kkgN0IF7.js.map +1 -0
- package/dist/chunks/{collections-CrOvS2E7.js → collections-Dz2fvKnz.js} +2 -2
- package/dist/chunks/{collections-CrOvS2E7.js.map → collections-Dz2fvKnz.js.map} +1 -1
- package/dist/chunks/{compose-handle-B-CkDcQD.js → compose-handle-D_Rz3Fzo.js} +10 -4
- package/dist/chunks/compose-handle-D_Rz3Fzo.js.map +1 -0
- package/dist/chunks/{config-target-Bln26FJe.js → config-target-Dx3w6WSk.js} +59 -70
- package/dist/chunks/config-target-Dx3w6WSk.js.map +1 -0
- package/dist/chunks/constants-BjyMU5s8.js +6 -0
- package/dist/chunks/constants-BjyMU5s8.js.map +1 -0
- package/dist/chunks/dispatch-CXOXPLFk.js +6 -0
- package/dist/chunks/dispatch-CXOXPLFk.js.map +1 -0
- package/dist/chunks/env-vars-C1NUX-bf.js +268 -0
- package/dist/chunks/env-vars-C1NUX-bf.js.map +1 -0
- package/dist/chunks/env-vars-Cr4lbMD_.js +21 -0
- package/dist/chunks/env-vars-Cr4lbMD_.js.map +1 -0
- package/dist/chunks/env-vars-De0Xs0L2.js +20 -0
- package/dist/chunks/env-vars-De0Xs0L2.js.map +1 -0
- package/dist/chunks/env-vars-file-B_6esJW3.js +34 -0
- package/dist/chunks/env-vars-file-B_6esJW3.js.map +1 -0
- package/dist/chunks/env-vars-mnRA0hOe.js +19 -0
- package/dist/chunks/env-vars-mnRA0hOe.js.map +1 -0
- package/dist/chunks/generate-BW3l5Fxw.js +252 -0
- package/dist/chunks/{generate-Ca_6FlPi.js.map → generate-BW3l5Fxw.js.map} +1 -1
- package/dist/chunks/{generate-CyuY2Ci7.js → generate-DeaBlnK6.js} +25 -24
- package/dist/chunks/generate-DeaBlnK6.js.map +1 -0
- package/dist/chunks/generate-DetW_gbr.js +68 -0
- package/dist/chunks/generate-DetW_gbr.js.map +1 -0
- package/dist/chunks/{generate-DwADTUob.js → generate-Gcc8iRkZ.js} +9 -6
- package/dist/chunks/{generate-DwADTUob.js.map → generate-Gcc8iRkZ.js.map} +1 -1
- package/dist/chunks/{generate-DQeWOEPY.js → generate-WMJo3QGZ.js} +9 -6
- package/dist/chunks/generate-WMJo3QGZ.js.map +1 -0
- package/dist/chunks/generate.runtime-1-91UmM8.js +85 -0
- package/dist/chunks/generate.runtime-1-91UmM8.js.map +1 -0
- package/dist/chunks/generate.runtime-6FXJM8hT.js +67 -0
- package/dist/chunks/generate.runtime-6FXJM8hT.js.map +1 -0
- package/dist/chunks/generate.runtime-B1jVAnDI.js +155 -0
- package/dist/chunks/generate.runtime-B1jVAnDI.js.map +1 -0
- package/dist/chunks/generate.runtime-BA3tDKnn.js +147 -0
- package/dist/chunks/generate.runtime-BA3tDKnn.js.map +1 -0
- package/dist/chunks/{generate.runtime-4FDxnvCl.js → generate.runtime-BO778G0r.js} +5 -5
- package/dist/chunks/{generate.runtime-4FDxnvCl.js.map → generate.runtime-BO778G0r.js.map} +1 -1
- package/dist/chunks/{generate.runtime-D1DNAY6k.js → generate.runtime-BXkZob1O.js} +8 -8
- package/dist/chunks/generate.runtime-BXkZob1O.js.map +1 -0
- package/dist/chunks/{generate.runtime-Um77JfwC.js → generate.runtime-B_UVGa3q.js} +7 -7
- package/dist/chunks/{generate.runtime-Um77JfwC.js.map → generate.runtime-B_UVGa3q.js.map} +1 -1
- package/dist/chunks/{generate.runtime-FdZw277n.js → generate.runtime-C6bSvGMb.js} +108 -142
- package/dist/chunks/generate.runtime-C6bSvGMb.js.map +1 -0
- package/dist/chunks/generate.runtime-C8zJRNYG.js +124 -0
- package/dist/chunks/generate.runtime-C8zJRNYG.js.map +1 -0
- package/dist/chunks/{generate.runtime-BKiJvE8I.js → generate.runtime-CA7Ofjlx.js} +104 -100
- package/dist/chunks/generate.runtime-CA7Ofjlx.js.map +1 -0
- package/dist/chunks/generate.runtime-CCr1lvo4.js +43 -0
- package/dist/chunks/generate.runtime-CCr1lvo4.js.map +1 -0
- package/dist/chunks/generate.runtime-CYagyR5c.js +326 -0
- package/dist/chunks/generate.runtime-CYagyR5c.js.map +1 -0
- package/dist/chunks/{generate.runtime-n9AFWtPp.js → generate.runtime-Ce_rwzNa.js} +4 -4
- package/dist/chunks/{generate.runtime-n9AFWtPp.js.map → generate.runtime-Ce_rwzNa.js.map} +1 -1
- package/dist/chunks/{generate.runtime-cQGLxuZM.js → generate.runtime-CexC1Oky.js} +4 -4
- package/dist/chunks/{generate.runtime-cQGLxuZM.js.map → generate.runtime-CexC1Oky.js.map} +1 -1
- package/dist/chunks/{generate.runtime-AYQVW1S-.js → generate.runtime-CnPraLKv.js} +35 -31
- package/dist/chunks/generate.runtime-CnPraLKv.js.map +1 -0
- package/dist/chunks/generate.runtime-CslAvllQ.js +112 -0
- package/dist/chunks/generate.runtime-CslAvllQ.js.map +1 -0
- package/dist/chunks/{generate.runtime-onBnOiS7.js → generate.runtime-CuNhY5hn.js} +10 -10
- package/dist/chunks/generate.runtime-CuNhY5hn.js.map +1 -0
- package/dist/chunks/{generate.runtime-B45MvtYm.js → generate.runtime-DD51OSuL.js} +14 -14
- package/dist/chunks/generate.runtime-DD51OSuL.js.map +1 -0
- package/dist/chunks/generate.runtime-DHBRyMAq.js +65 -0
- package/dist/chunks/generate.runtime-DHBRyMAq.js.map +1 -0
- package/dist/chunks/generate.runtime-DV3WmZtb.js +35 -0
- package/dist/chunks/generate.runtime-DV3WmZtb.js.map +1 -0
- package/dist/chunks/generate.runtime-D_sQOeQa.js +164 -0
- package/dist/chunks/generate.runtime-D_sQOeQa.js.map +1 -0
- package/dist/chunks/{generate.runtime-ofdnLtxS.js → generate.runtime-DqD3PW-W.js} +3 -3
- package/dist/chunks/{generate.runtime-ofdnLtxS.js.map → generate.runtime-DqD3PW-W.js.map} +1 -1
- package/dist/chunks/{generate.runtime-VgVwRiiN.js → generate.runtime-Dtgw9IQO.js} +8 -8
- package/dist/chunks/generate.runtime-Dtgw9IQO.js.map +1 -0
- package/dist/chunks/{generate.runtime-CN5c2xH8.js → generate.runtime-IlBCcXvv.js} +14 -14
- package/dist/chunks/generate.runtime-IlBCcXvv.js.map +1 -0
- package/dist/chunks/{generate.runtime-BSRFv4cJ.js → generate.runtime-cwvAoKoH.js} +3 -3
- package/dist/chunks/{generate.runtime-BSRFv4cJ.js.map → generate.runtime-cwvAoKoH.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DG-3G00z.js → generate.runtime-kvxmTlQb.js} +3 -3
- package/dist/chunks/{generate.runtime-DG-3G00z.js.map → generate.runtime-kvxmTlQb.js.map} +1 -1
- package/dist/chunks/generate.runtime-pVLzzpUM.js +122 -0
- package/dist/chunks/generate.runtime-pVLzzpUM.js.map +1 -0
- package/dist/chunks/{generate.runtime-BFOXm2DD.js → generate.runtime-zJpEufTc.js} +10 -10
- package/dist/chunks/generate.runtime-zJpEufTc.js.map +1 -0
- package/dist/chunks/lib-specifier-Cngo1zF_.js +33 -0
- package/dist/chunks/lib-specifier-Cngo1zF_.js.map +1 -0
- package/dist/chunks/{modify-file-Dwfv0dCI.js → modify-file-BlDeeurK.js} +3 -3
- package/dist/chunks/{modify-file-Dwfv0dCI.js.map → modify-file-BlDeeurK.js.map} +1 -1
- package/dist/chunks/{modify-svelte-config-remote-BUU_EaDf.js → modify-svelte-config-remote-p0TfVzxm.js} +8 -10
- package/dist/chunks/modify-svelte-config-remote-p0TfVzxm.js.map +1 -0
- package/dist/chunks/nav-user-BRIHOOpG.js +6 -0
- package/dist/chunks/nav-user-BRIHOOpG.js.map +1 -0
- package/dist/chunks/package-imports-Bbw3iMPg.js +173 -0
- package/dist/chunks/package-imports-Bbw3iMPg.js.map +1 -0
- package/dist/chunks/{pocketbase-BkhUywtb.js → pocketbase-Dry6ry17.js} +2 -2
- package/dist/chunks/{pocketbase-BkhUywtb.js.map → pocketbase-Dry6ry17.js.map} +1 -1
- package/dist/chunks/{providers-BL9vJP_9.js → providers-BHR6-XZ7.js} +11 -4
- package/dist/chunks/providers-BHR6-XZ7.js.map +1 -0
- package/dist/chunks/{shared-C8GtNxpm.js → shared-CZC4d7Uj.js} +2 -2
- package/dist/chunks/{shared-C8GtNxpm.js.map → shared-CZC4d7Uj.js.map} +1 -1
- package/dist/chunks/{site-BdMX8qrH.js → site-BwCA18Sv.js} +2 -2
- package/dist/chunks/{site-BdMX8qrH.js.map → site-BwCA18Sv.js.map} +1 -1
- package/dist/chunks/table-core-AjBpYi-y.js +127 -0
- package/dist/chunks/table-core-AjBpYi-y.js.map +1 -0
- package/dist/chunks/{test-setup-DHEFKEHE.js → test-setup-DEmWd9Ul.js} +76 -67
- package/dist/chunks/test-setup-DEmWd9Ul.js.map +1 -0
- package/dist/chunks/{ts-morph-helpers-CeduA--o.js → ts-morph-helpers-CDW4lhox.js} +77 -63
- package/dist/chunks/ts-morph-helpers-CDW4lhox.js.map +1 -0
- package/dist/chunks/ui-DD4NltyN.js.map +1 -1
- package/dist/chunks/{ui-TlEuI2Sz.js → ui-X698F10c.js} +47 -47
- package/dist/chunks/{ui-TlEuI2Sz.js.map → ui-X698F10c.js.map} +1 -1
- package/dist/chunks/{unmodify-load-jfdcVZ_a.js → unmodify-load-CyGzC1Hu.js} +2 -2
- package/dist/chunks/{unmodify-load-jfdcVZ_a.js.map → unmodify-load-CyGzC1Hu.js.map} +1 -1
- package/dist/chunks/write-result-B68lvI57.js +511 -0
- package/dist/chunks/write-result-B68lvI57.js.map +1 -0
- package/dist/index.d.ts +302 -157
- package/dist/index.js +2124 -2066
- package/dist/index.js.map +1 -1
- package/package.json +10 -9
- package/dist/chunks/_layout-B7ujvjnA.js +0 -55
- package/dist/chunks/_layout-B7ujvjnA.js.map +0 -1
- package/dist/chunks/compose-handle-B-CkDcQD.js.map +0 -1
- package/dist/chunks/config-target-Bln26FJe.js.map +0 -1
- package/dist/chunks/constants-BYkd9jeJ.js +0 -6
- package/dist/chunks/constants-BYkd9jeJ.js.map +0 -1
- package/dist/chunks/dispatch-BRnt8PcW.js +0 -6
- package/dist/chunks/dispatch-BRnt8PcW.js.map +0 -1
- package/dist/chunks/generate-6snrlnpA.js +0 -64
- package/dist/chunks/generate-6snrlnpA.js.map +0 -1
- package/dist/chunks/generate-Ca_6FlPi.js +0 -252
- package/dist/chunks/generate-CyuY2Ci7.js.map +0 -1
- package/dist/chunks/generate-DQeWOEPY.js.map +0 -1
- package/dist/chunks/generate.runtime-AYQVW1S-.js.map +0 -1
- package/dist/chunks/generate.runtime-B2aFFaac.js +0 -117
- package/dist/chunks/generate.runtime-B2aFFaac.js.map +0 -1
- package/dist/chunks/generate.runtime-B45MvtYm.js.map +0 -1
- package/dist/chunks/generate.runtime-BFOXm2DD.js.map +0 -1
- package/dist/chunks/generate.runtime-BHkFmI2Y.js +0 -146
- package/dist/chunks/generate.runtime-BHkFmI2Y.js.map +0 -1
- package/dist/chunks/generate.runtime-BKiJvE8I.js.map +0 -1
- package/dist/chunks/generate.runtime-BUqsF3AF.js +0 -123
- package/dist/chunks/generate.runtime-BUqsF3AF.js.map +0 -1
- package/dist/chunks/generate.runtime-BsaSyTnU.js +0 -82
- package/dist/chunks/generate.runtime-BsaSyTnU.js.map +0 -1
- package/dist/chunks/generate.runtime-CMnvmeVt.js +0 -111
- package/dist/chunks/generate.runtime-CMnvmeVt.js.map +0 -1
- package/dist/chunks/generate.runtime-CN5c2xH8.js.map +0 -1
- package/dist/chunks/generate.runtime-CgoSrP55.js +0 -146
- package/dist/chunks/generate.runtime-CgoSrP55.js.map +0 -1
- package/dist/chunks/generate.runtime-D1DNAY6k.js.map +0 -1
- package/dist/chunks/generate.runtime-DQwSY6Nc.js +0 -38
- package/dist/chunks/generate.runtime-DQwSY6Nc.js.map +0 -1
- package/dist/chunks/generate.runtime-D_yqWLcI.js +0 -66
- package/dist/chunks/generate.runtime-D_yqWLcI.js.map +0 -1
- package/dist/chunks/generate.runtime-Drmahmdl.js +0 -313
- package/dist/chunks/generate.runtime-Drmahmdl.js.map +0 -1
- package/dist/chunks/generate.runtime-FdZw277n.js.map +0 -1
- package/dist/chunks/generate.runtime-Lh1cW9Tz.js +0 -94
- package/dist/chunks/generate.runtime-Lh1cW9Tz.js.map +0 -1
- package/dist/chunks/generate.runtime-QGHToXRY.js +0 -32
- package/dist/chunks/generate.runtime-QGHToXRY.js.map +0 -1
- package/dist/chunks/generate.runtime-VgVwRiiN.js.map +0 -1
- package/dist/chunks/generate.runtime-YyIVd4oy.js +0 -61
- package/dist/chunks/generate.runtime-YyIVd4oy.js.map +0 -1
- package/dist/chunks/generate.runtime-onBnOiS7.js.map +0 -1
- package/dist/chunks/modify-svelte-config-remote-BUU_EaDf.js.map +0 -1
- package/dist/chunks/nav-user-BYI-h8Od.js +0 -6
- package/dist/chunks/nav-user-BYI-h8Od.js.map +0 -1
- package/dist/chunks/providers-BL9vJP_9.js.map +0 -1
- package/dist/chunks/table-core-G9Shld4F.js +0 -126
- package/dist/chunks/table-core-G9Shld4F.js.map +0 -1
- package/dist/chunks/test-setup-DHEFKEHE.js.map +0 -1
- package/dist/chunks/ts-morph-helpers-CeduA--o.js.map +0 -1
- package/dist/chunks/write-result-Djy0SZXX.js +0 -376
- package/dist/chunks/write-result-Djy0SZXX.js.map +0 -1
|
@@ -1,12 +1,12 @@
|
|
|
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-
|
|
5
|
-
import { modifyOutcomeToFile as s } from "./modify-file-
|
|
4
|
+
import { _ as r, i, o as a, r as o } from "./ts-morph-helpers-CDW4lhox.js";
|
|
5
|
+
import { modifyOutcomeToFile as s } from "./modify-file-BlDeeurK.js";
|
|
6
6
|
import { t as c } from "./svelte-file-B3RfgVdt.js";
|
|
7
|
-
import { t as l } from "./compose-handle-
|
|
8
|
-
import { a as u,
|
|
9
|
-
import { n as
|
|
7
|
+
import { t as l } from "./compose-handle-D_Rz3Fzo.js";
|
|
8
|
+
import { a as u, t as d } from "./config-target-Dx3w6WSk.js";
|
|
9
|
+
import { i as f, n as p } from "./_layout-kkgN0IF7.js";
|
|
10
10
|
import m from "node:fs";
|
|
11
11
|
import h from "node:path";
|
|
12
12
|
import { Project as g, QuoteKind as _, SyntaxKind as v } from "ts-morph";
|
|
@@ -70,50 +70,16 @@ function x(e) {
|
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
72
|
//#endregion
|
|
73
|
-
//#region src/patterns/enable/i18n/modifies/svelte-config.ts
|
|
74
|
-
var S = [
|
|
75
|
-
"Add the $locales alias to your config (sveltekit() arg in vite.config, or svelte.config):",
|
|
76
|
-
"",
|
|
77
|
-
"alias: {",
|
|
78
|
-
" $locales: 'src/locales',",
|
|
79
|
-
"},"
|
|
80
|
-
].join("\n"), C = [
|
|
81
|
-
"Add the $locales alias by passing config to the sveltekit() plugin in vite.config.ts:",
|
|
82
|
-
"",
|
|
83
|
-
"import { sveltekit } from '@sveltejs/kit/vite';",
|
|
84
|
-
"import { defineConfig } from 'vite';",
|
|
85
|
-
"",
|
|
86
|
-
"export default defineConfig({",
|
|
87
|
-
" plugins: [sveltekit({ alias: { $locales: 'src/locales' } })],",
|
|
88
|
-
"});"
|
|
89
|
-
].join("\n");
|
|
90
|
-
function w(e) {
|
|
91
|
-
return d(e, {
|
|
92
|
-
notFound: C,
|
|
93
|
-
failed: S
|
|
94
|
-
}, (e) => {
|
|
95
|
-
let t = e.kitContainer();
|
|
96
|
-
if (!t) return !1;
|
|
97
|
-
let n = f(t, "alias", "{}");
|
|
98
|
-
if (!n) return !1;
|
|
99
|
-
let r = n.getProperty("$locales");
|
|
100
|
-
return r ? r.getKind() === v.PropertyAssignment && (r.getInitializer()?.getText()?.replace(/['"`]/g, "") !== "src/locales" && r.setInitializer("'src/locales'"), !0) : (n.addPropertyAssignment({
|
|
101
|
-
name: "$locales",
|
|
102
|
-
initializer: "'src/locales'"
|
|
103
|
-
}), !0);
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
//#endregion
|
|
107
73
|
//#region src/patterns/enable/i18n/modifies/hooks.server.ts
|
|
108
|
-
var
|
|
74
|
+
var S = "handleWuchale", C = e`
|
|
109
75
|
Wrap your exported handle with the wuchale i18n handler:
|
|
110
76
|
|
|
111
77
|
import { sequence } from '@sveltejs/kit/hooks';
|
|
112
78
|
import { runWithLocale, loadLocales } from 'wuchale/load-utils/server';
|
|
113
|
-
import { getLocale } from '
|
|
114
|
-
import { locales } from '
|
|
115
|
-
import * as main from '
|
|
116
|
-
import * as js from '
|
|
79
|
+
import { getLocale } from '#locales/main.url.js';
|
|
80
|
+
import { locales } from '#locales/data.js';
|
|
81
|
+
import * as main from '#locales/main.loader.server.svelte.js';
|
|
82
|
+
import * as js from '#locales/js.loader.server.js';
|
|
117
83
|
|
|
118
84
|
loadLocales(main.key, main.loadCount, main.loadCatalog, locales);
|
|
119
85
|
loadLocales(js.key, js.loadCount, js.loadCatalog, locales);
|
|
@@ -129,13 +95,13 @@ var T = "handleWuchale", E = e`
|
|
|
129
95
|
};
|
|
130
96
|
|
|
131
97
|
export const handle = sequence(handleWuchale, /* your existing handle */);
|
|
132
|
-
`,
|
|
133
|
-
import type { Handle } from '@sveltejs/kit';
|
|
98
|
+
`, w = e`
|
|
99
|
+
import type { Handle } from '@sveltejs/kit/hooks';
|
|
134
100
|
import { runWithLocale, loadLocales } from 'wuchale/load-utils/server';
|
|
135
|
-
import { getLocale } from '
|
|
136
|
-
import { locales } from '
|
|
137
|
-
import * as main from '
|
|
138
|
-
import * as js from '
|
|
101
|
+
import { getLocale } from '#locales/main.url.js';
|
|
102
|
+
import { locales } from '#locales/data.js';
|
|
103
|
+
import * as main from '#locales/main.loader.server.svelte.js';
|
|
104
|
+
import * as js from '#locales/js.loader.server.js';
|
|
139
105
|
|
|
140
106
|
loadLocales(main.key, main.loadCount, main.loadCatalog, locales);
|
|
141
107
|
loadLocales(js.key, js.loadCount, js.loadCatalog, locales);
|
|
@@ -151,17 +117,17 @@ var T = "handleWuchale", E = e`
|
|
|
151
117
|
|
|
152
118
|
export const handle = handleWuchale;
|
|
153
119
|
`;
|
|
154
|
-
function
|
|
120
|
+
function T(e, t, n) {
|
|
155
121
|
e.getImportDeclarations().find((e) => e.getModuleSpecifierValue() === t) || e.addImportDeclaration({
|
|
156
122
|
namespaceImport: n,
|
|
157
123
|
moduleSpecifier: t
|
|
158
124
|
});
|
|
159
125
|
}
|
|
160
|
-
function
|
|
126
|
+
function E(t) {
|
|
161
127
|
if (!m.existsSync(t)) return m.existsSync(t.replace(/\.ts$/, ".js")) ? {
|
|
162
128
|
status: "failed",
|
|
163
|
-
message:
|
|
164
|
-
} : (m.mkdirSync(h.dirname(t), { recursive: !0 }), m.writeFileSync(t,
|
|
129
|
+
message: C
|
|
130
|
+
} : (m.mkdirSync(h.dirname(t), { recursive: !0 }), m.writeFileSync(t, w + "\n"), {
|
|
165
131
|
status: "success",
|
|
166
132
|
changed: !0
|
|
167
133
|
});
|
|
@@ -173,18 +139,18 @@ function k(t) {
|
|
|
173
139
|
let r = new g({
|
|
174
140
|
compilerOptions: { allowJs: !0 },
|
|
175
141
|
manipulationSettings: { quoteKind: _.Single }
|
|
176
|
-
}).addSourceFileAtPath(t), o = l(r, { expression:
|
|
142
|
+
}).addSourceFileAtPath(t), o = l(r, { expression: S });
|
|
177
143
|
if (o.status === "unsupported" || !o.statement) return {
|
|
178
144
|
status: "failed",
|
|
179
|
-
message:
|
|
145
|
+
message: C
|
|
180
146
|
};
|
|
181
147
|
let s = o.statement;
|
|
182
|
-
i(r, "wuchale/load-utils/server", "runWithLocale"), i(r, "wuchale/load-utils/server", "loadLocales"), i(r, "
|
|
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");
|
|
183
149
|
let c = e`
|
|
184
150
|
loadLocales(main.key, main.loadCount, main.loadCatalog, locales);
|
|
185
151
|
loadLocales(js.key, js.loadCount, js.loadCatalog, locales);
|
|
186
152
|
`, u = e`
|
|
187
|
-
const ${
|
|
153
|
+
const ${S} = async ({ event, resolve }: any) => {
|
|
188
154
|
const locale = getLocale(event.url);
|
|
189
155
|
return await runWithLocale(locale, () =>
|
|
190
156
|
resolve(event, {
|
|
@@ -201,16 +167,16 @@ function k(t) {
|
|
|
201
167
|
}
|
|
202
168
|
//#endregion
|
|
203
169
|
//#region src/patterns/enable/i18n/modifies/hooks.ts
|
|
204
|
-
var
|
|
170
|
+
var D = e`
|
|
205
171
|
const rerouteDeLocalize = (url: string) => {
|
|
206
172
|
const [upath, locale] = deLocalizeDefault(url, locales);
|
|
207
173
|
const { path } = matchUrl(upath, locale);
|
|
208
174
|
return path ?? url;
|
|
209
175
|
};
|
|
210
|
-
`,
|
|
176
|
+
`, O = e`
|
|
211
177
|
import { deLocalizeDefault } from 'wuchale/url';
|
|
212
|
-
import { matchUrl } from '
|
|
213
|
-
import { locales } from '
|
|
178
|
+
import { matchUrl } from '#locales/main.url.js';
|
|
179
|
+
import { locales } from '#locales/data.js';
|
|
214
180
|
|
|
215
181
|
const rerouteDeLocalize = (url: string) => {
|
|
216
182
|
const [upath, locale] = deLocalizeDefault(url, locales);
|
|
@@ -219,12 +185,12 @@ var A = e`
|
|
|
219
185
|
};
|
|
220
186
|
|
|
221
187
|
export const reroute = ({ url }) => rerouteDeLocalize(url.pathname);
|
|
222
|
-
`,
|
|
188
|
+
`, k = e`
|
|
223
189
|
Compose your existing reroute in src/hooks.ts with the wuchale de-localizer:
|
|
224
190
|
|
|
225
191
|
import { deLocalizeDefault } from 'wuchale/url';
|
|
226
|
-
import { matchUrl } from '
|
|
227
|
-
import { locales } from '
|
|
192
|
+
import { matchUrl } from '#locales/main.url.js';
|
|
193
|
+
import { locales } from '#locales/data.js';
|
|
228
194
|
|
|
229
195
|
const rerouteDeLocalize = (url: string) => {
|
|
230
196
|
const [upath, locale] = deLocalizeDefault(url, locales);
|
|
@@ -233,15 +199,15 @@ var A = e`
|
|
|
233
199
|
};
|
|
234
200
|
|
|
235
201
|
export const reroute = ({ url }) => rerouteDeLocalize(existingReroute(url.pathname));
|
|
236
|
-
`,
|
|
237
|
-
function
|
|
202
|
+
`, A = /^\(\s*\{\s*url\s*\}\s*\)\s*=>\s*negotiateReroute\(\s*url\.pathname\s*\)$/;
|
|
203
|
+
function j(e) {
|
|
238
204
|
return e.getFunction("reroute") ? !0 : e.getExportDeclarations().some((e) => e.getNamedExports().some((e) => (e.getAliasNode()?.getText() ?? e.getName()) === "reroute"));
|
|
239
205
|
}
|
|
240
|
-
function
|
|
241
|
-
i(e, "wuchale/url", "deLocalizeDefault"), i(e, "
|
|
206
|
+
function M(e) {
|
|
207
|
+
i(e, "wuchale/url", "deLocalizeDefault"), i(e, "#locales/main.url.js", "matchUrl"), i(e, "#locales/data.js", "locales");
|
|
242
208
|
}
|
|
243
|
-
function
|
|
244
|
-
if (!m.existsSync(e)) return m.mkdirSync(h.dirname(e), { recursive: !0 }), m.writeFileSync(e,
|
|
209
|
+
function N(e) {
|
|
210
|
+
if (!m.existsSync(e)) return m.mkdirSync(h.dirname(e), { recursive: !0 }), m.writeFileSync(e, O + "\n"), {
|
|
245
211
|
status: "success",
|
|
246
212
|
changed: !0
|
|
247
213
|
};
|
|
@@ -253,36 +219,36 @@ function F(e) {
|
|
|
253
219
|
compilerOptions: { allowJs: !0 },
|
|
254
220
|
manipulationSettings: { quoteKind: _.Single }
|
|
255
221
|
}).addSourceFileAtPath(e), n = t.getVariableDeclaration("reroute");
|
|
256
|
-
if (!n) return
|
|
222
|
+
if (!n) return j(t) ? {
|
|
257
223
|
status: "failed",
|
|
258
|
-
message:
|
|
259
|
-
} : (
|
|
224
|
+
message: k
|
|
225
|
+
} : (M(t), t.addStatements(`\n${D}\n\nexport const reroute = ({ url }) => rerouteDeLocalize(url.pathname);\n`), a(t), t.saveSync(), {
|
|
260
226
|
status: "success",
|
|
261
227
|
changed: !0
|
|
262
228
|
});
|
|
263
229
|
if (!n.getFirstAncestorByKind(v.VariableStatement)?.hasExportKeyword()) return {
|
|
264
230
|
status: "failed",
|
|
265
|
-
message:
|
|
231
|
+
message: k
|
|
266
232
|
};
|
|
267
233
|
let r = n.getInitializer();
|
|
268
|
-
if (!r || !
|
|
234
|
+
if (!r || !A.test(r.getText())) return {
|
|
269
235
|
status: "failed",
|
|
270
|
-
message:
|
|
236
|
+
message: k
|
|
271
237
|
};
|
|
272
|
-
|
|
238
|
+
M(t), n.setInitializer("({ url }) => rerouteDeLocalize(negotiateReroute(url.pathname))");
|
|
273
239
|
let i = t.getVariableStatements().find((e) => e.getDeclarations().some((e) => e.getName() === "reroute"));
|
|
274
|
-
return t.insertText(i.getStart(!0), `${
|
|
240
|
+
return t.insertText(i.getStart(!0), `${D}\n\n`), a(t), t.saveSync(), {
|
|
275
241
|
status: "success",
|
|
276
242
|
changed: !0
|
|
277
243
|
};
|
|
278
244
|
}
|
|
279
245
|
//#endregion
|
|
280
246
|
//#region src/patterns/enable/i18n/modifies/app-html.ts
|
|
281
|
-
var
|
|
247
|
+
var P = [
|
|
282
248
|
"Add the sveltekit lang placeholder to the <html> tag:",
|
|
283
249
|
"",
|
|
284
250
|
"<html lang=\"%sveltekit.lang%\">"
|
|
285
|
-
].join("\n"),
|
|
251
|
+
].join("\n"), F = [
|
|
286
252
|
"Create src/app.html with a lang placeholder:",
|
|
287
253
|
"",
|
|
288
254
|
"<!doctype html>",
|
|
@@ -296,10 +262,10 @@ var I = [
|
|
|
296
262
|
" </body>",
|
|
297
263
|
"</html>"
|
|
298
264
|
].join("\n");
|
|
299
|
-
function
|
|
265
|
+
function I(e) {
|
|
300
266
|
if (!m.existsSync(e)) return {
|
|
301
267
|
status: "not-found",
|
|
302
|
-
message:
|
|
268
|
+
message: F
|
|
303
269
|
};
|
|
304
270
|
let t = m.readFileSync(e, "utf8");
|
|
305
271
|
if (t.includes("lang=\"%sveltekit.lang%\"") || t.includes("lang='%sveltekit.lang%'")) return {
|
|
@@ -309,7 +275,7 @@ function R(e) {
|
|
|
309
275
|
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%\""));
|
|
310
276
|
return n === t ? {
|
|
311
277
|
status: "failed",
|
|
312
|
-
message:
|
|
278
|
+
message: P
|
|
313
279
|
} : (m.writeFileSync(e, n), {
|
|
314
280
|
status: "success",
|
|
315
281
|
changed: !0
|
|
@@ -317,16 +283,16 @@ function R(e) {
|
|
|
317
283
|
}
|
|
318
284
|
//#endregion
|
|
319
285
|
//#region src/patterns/enable/i18n/modifies/gitignore.ts
|
|
320
|
-
var
|
|
286
|
+
var L = [
|
|
321
287
|
"Create a .gitignore with the wuchale cache ignored:",
|
|
322
288
|
"",
|
|
323
289
|
"# Wuchale",
|
|
324
290
|
"src/locales/.wuchale"
|
|
325
291
|
].join("\n");
|
|
326
|
-
function
|
|
292
|
+
function R(t) {
|
|
327
293
|
if (!m.existsSync(t)) return {
|
|
328
294
|
status: "not-found",
|
|
329
|
-
message:
|
|
295
|
+
message: L
|
|
330
296
|
};
|
|
331
297
|
let n = m.readFileSync(t, "utf8");
|
|
332
298
|
if (n.includes("src/locales/.wuchale")) return {
|
|
@@ -344,97 +310,97 @@ function B(t) {
|
|
|
344
310
|
}
|
|
345
311
|
//#endregion
|
|
346
312
|
//#region src/patterns/enable/i18n/modifies/root-layout.svelte.ts
|
|
347
|
-
var
|
|
348
|
-
import LanguageSelect from '
|
|
349
|
-
`,
|
|
313
|
+
var z = "<Navbar.Item>\n <LanguageSelect />\n </Navbar.Item>\n ", B = "<LanguageSelect />", V = e`
|
|
314
|
+
import LanguageSelect from '#lib/components/language-select.svelte';
|
|
315
|
+
`, H = [
|
|
350
316
|
"Add the language select inside your <Navbar.List> in the root layout.",
|
|
351
317
|
"",
|
|
352
318
|
"Import to add to the <script> tag:",
|
|
353
319
|
"",
|
|
354
|
-
|
|
320
|
+
V,
|
|
355
321
|
"",
|
|
356
322
|
"Markup to add at the end of <Navbar.List>:",
|
|
357
|
-
|
|
358
|
-
].join("\n"),
|
|
323
|
+
z
|
|
324
|
+
].join("\n"), U = [
|
|
359
325
|
"Create a root layout that includes a language select inside <Navbar.List>.",
|
|
360
326
|
"",
|
|
361
327
|
"Import for the <script> tag:",
|
|
362
328
|
"",
|
|
363
|
-
|
|
329
|
+
V,
|
|
364
330
|
"",
|
|
365
331
|
"Markup at the end of <Navbar.List>:",
|
|
366
|
-
|
|
367
|
-
].join("\n"),
|
|
332
|
+
z
|
|
333
|
+
].join("\n"), W = [
|
|
368
334
|
"Add the language select to your root layout.",
|
|
369
335
|
"",
|
|
370
336
|
"Import to add to the <script> tag:",
|
|
371
337
|
"",
|
|
372
|
-
|
|
338
|
+
V,
|
|
373
339
|
"",
|
|
374
340
|
"Markup to add wherever it should render, e.g. above {@render children()}:",
|
|
375
341
|
"",
|
|
376
|
-
|
|
377
|
-
].join("\n"),
|
|
342
|
+
B
|
|
343
|
+
].join("\n"), G = [
|
|
378
344
|
"Create a root layout that includes the language select.",
|
|
379
345
|
"",
|
|
380
346
|
"Import for the <script> tag:",
|
|
381
347
|
"",
|
|
382
|
-
|
|
348
|
+
V,
|
|
383
349
|
"",
|
|
384
350
|
"Markup above {@render children()}:",
|
|
385
351
|
"",
|
|
386
|
-
|
|
352
|
+
B
|
|
387
353
|
].join("\n");
|
|
388
|
-
function
|
|
354
|
+
function K(e) {
|
|
389
355
|
e.modifyScript((e) => {
|
|
390
356
|
let { source: t } = r(e, (e) => {
|
|
391
357
|
o(e, [{
|
|
392
358
|
defaultImport: "LanguageSelect",
|
|
393
|
-
moduleSpecifier: "
|
|
359
|
+
moduleSpecifier: "#lib/components/language-select.svelte"
|
|
394
360
|
}]);
|
|
395
361
|
});
|
|
396
362
|
return t;
|
|
397
363
|
});
|
|
398
364
|
}
|
|
399
|
-
function
|
|
365
|
+
function q(e, t = "shadcn") {
|
|
400
366
|
let n = t === "plain";
|
|
401
367
|
if (!m.existsSync(e)) return {
|
|
402
368
|
status: "not-found",
|
|
403
|
-
message: n ?
|
|
369
|
+
message: n ? G : U
|
|
404
370
|
};
|
|
405
371
|
let r = c.fromPath(e);
|
|
406
372
|
return r.hasElement("LanguageSelect") ? {
|
|
407
373
|
status: "success",
|
|
408
374
|
changed: !1
|
|
409
|
-
} : n ? !r.getScript() || !r.insertBeforeChildren(
|
|
375
|
+
} : n ? !r.getScript() || !r.insertBeforeChildren(B) ? {
|
|
410
376
|
status: "failed",
|
|
411
|
-
message:
|
|
412
|
-
} : (
|
|
377
|
+
message: W
|
|
378
|
+
} : (K(r), r.writeTo(e), {
|
|
413
379
|
status: "success",
|
|
414
380
|
changed: r.hasChanged()
|
|
415
|
-
}) : r.hasElement("Navbar.List") ? (
|
|
381
|
+
}) : r.hasElement("Navbar.List") ? (K(r), r.insertBeforeClosingTag("Navbar.List", z), r.writeTo(e), {
|
|
416
382
|
status: "success",
|
|
417
383
|
changed: r.hasChanged()
|
|
418
384
|
}) : {
|
|
419
385
|
status: "failed",
|
|
420
|
-
message:
|
|
386
|
+
message: H
|
|
421
387
|
};
|
|
422
388
|
}
|
|
423
389
|
//#endregion
|
|
424
390
|
//#region src/patterns/enable/i18n/welcome-catalog.ts
|
|
425
|
-
var
|
|
426
|
-
reference:
|
|
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,
|
|
427
393
|
msgid: "Welcome to SvelteKit",
|
|
428
394
|
msgstr: "Bienvenido a SvelteKit"
|
|
429
395
|
}, {
|
|
430
|
-
reference:
|
|
396
|
+
reference: J,
|
|
431
397
|
msgid: "Visit <0>svelte.dev/docs/kit</0> to read the documentation",
|
|
432
398
|
msgstr: "Visita <0>svelte.dev/docs/kit</0> para leer la documentación"
|
|
433
|
-
}],
|
|
399
|
+
}], Q = {
|
|
434
400
|
reference: "src/lib/components/language-select.svelte",
|
|
435
401
|
msgid: "Language",
|
|
436
402
|
msgstr: "Idioma"
|
|
437
|
-
},
|
|
403
|
+
}, ee = [
|
|
438
404
|
"msgid \"\"",
|
|
439
405
|
"msgstr \"\"",
|
|
440
406
|
"\"Source-Language: en\\n\"",
|
|
@@ -445,13 +411,13 @@ var X = "src/routes/+page.svelte", Z = "src/locales/es.po", ne = ["<h1>Welcome t
|
|
|
445
411
|
"\"Plural-Forms: nplurals=3\\n\"",
|
|
446
412
|
"\"X-Plurals-Order: one, many, other\\n\""
|
|
447
413
|
].join("\n"), $ = (e) => e.replace(/\s+/g, "");
|
|
448
|
-
function
|
|
449
|
-
if (m.existsSync(h.join(e,
|
|
450
|
-
let n = h.join(e,
|
|
451
|
-
return !m.existsSync(n) || $(m.readFileSync(n, "utf8")) !== $(
|
|
452
|
-
path:
|
|
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,
|
|
453
419
|
language: "text",
|
|
454
|
-
content: [
|
|
420
|
+
content: [ee, ...(t === "plain" ? [...Z, Q] : Z).map((e) => [
|
|
455
421
|
`#: ${e.reference}`,
|
|
456
422
|
`msgid "${e.msgid}"`,
|
|
457
423
|
`msgstr "${e.msgstr}"`
|
|
@@ -461,35 +427,35 @@ function ae(e, t) {
|
|
|
461
427
|
}
|
|
462
428
|
//#endregion
|
|
463
429
|
//#region src/patterns/enable/i18n/generate.runtime.ts
|
|
464
|
-
async function
|
|
430
|
+
async function ne(e) {
|
|
465
431
|
let r = n(e), i = [], a = (e) => {
|
|
466
432
|
e && i.push(e);
|
|
467
433
|
};
|
|
468
434
|
r.info("Modifying vite.config");
|
|
469
|
-
let o = u(e.root,
|
|
470
|
-
a(s(o, x(o))), r.info("
|
|
471
|
-
let c =
|
|
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");
|
|
437
|
+
let c = f(e.root);
|
|
472
438
|
a(s(c.filePath, c.outcome)), r.info("Modifying hooks.server.ts");
|
|
473
439
|
let l = h.join(e.root, "src", "hooks.server.ts");
|
|
474
|
-
a(s(l,
|
|
475
|
-
let
|
|
476
|
-
a(s(
|
|
477
|
-
let
|
|
478
|
-
a(s(
|
|
479
|
-
let
|
|
480
|
-
a(s(
|
|
481
|
-
let
|
|
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");
|
|
446
|
+
a(s(v, p(v))), r.info("Modifying root layout language select");
|
|
447
|
+
let y = [
|
|
482
448
|
h.join(e.root, "src", "routes", "(public)", "root-layout.svelte"),
|
|
483
449
|
h.join(e.root, "src", "routes", "root-layout.svelte"),
|
|
484
450
|
h.join(e.root, "src", "routes", "(public)", "+layout.svelte"),
|
|
485
451
|
h.join(e.root, "src", "routes", "+layout.svelte")
|
|
486
|
-
],
|
|
487
|
-
a(s(
|
|
488
|
-
let
|
|
489
|
-
a(s(
|
|
490
|
-
let
|
|
491
|
-
return
|
|
492
|
-
creates:
|
|
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);
|
|
457
|
+
return w && r.info("Translating the welcome page into Spanish"), {
|
|
458
|
+
creates: w ? [w] : [],
|
|
493
459
|
modifies: i,
|
|
494
460
|
deletes: [],
|
|
495
461
|
components: [],
|
|
@@ -500,6 +466,6 @@ async function oe(e) {
|
|
|
500
466
|
};
|
|
501
467
|
}
|
|
502
468
|
//#endregion
|
|
503
|
-
export {
|
|
469
|
+
export { ne as generate };
|
|
504
470
|
|
|
505
|
-
//# sourceMappingURL=generate.runtime-
|
|
471
|
+
//# sourceMappingURL=generate.runtime-C6bSvGMb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.runtime-C6bSvGMb.js","names":[],"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\";\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,IAAM,IAAe;CACnB;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,CAAC,KAAK,IAAI,GAEL,IAAiB;CACrB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,CAAC,KAAK,IAAI;AAEX,SAAgB,EAAiB,GAAuC;CACtE,IAAI,CAAC,EAAG,WAAW,CAAc,GAC/B,OAAO;EAAE,QAAQ;EAAa,SAAS;CAAe;CAOxD,IAAM,IAAa,IAJC,EAAQ;EAC1B,iBAAiB,EAAE,SAAS,GAAK;EACjC,sBAAsB,EAAE,WAAW,EAAU,OAAO;CACtD,CACmB,CAAA,CAAQ,oBAAoB,CAAc,GAEzD,IAAU,IACV,IAAS;CAMb,AAJkB,EACf,sBAAsB,CAAC,CACvB,MAAM,MAAM,EAAE,wBAAwB,MAAM,cAE1C,MACH,EAAW,wBAAwB,GAAG;EACpC,cAAc,CAAC,SAAS;EACxB,iBAAiB;CACnB,CAAC,GACD,IAAU;CAOZ,IAAM,IAJmB,EACtB,qBAAqB,EAAW,cAAc,CAAC,CAC/C,MAAM,MAAO,EAAG,cAAc,CAAC,CAAC,QAAQ,MAAM,cAE/B,CAAA,EAAkB,aAAa,CAAC,GAAG,IAC/C,IACJ,GAAW,QAAQ,MAAM,EAAW,0BAC/B,IACD;CAEN,IAAI,CAAC,GACH,IAAS;MACJ;EACL,IAAM,IAAc,EAAU,YAAY,SAAS;EACnD,IAAI,CAAC,GAKH,AAJA,EAAU,sBAAsB;GAC9B,MAAM;GACN,aAAa;EACf,CAAC,GACD,IAAU;OACL,IAAI,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