@velastack/patterns 0.13.2 → 0.14.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 (45) hide show
  1. package/README.md +1 -1
  2. package/dist/chunks/app-d-ts-h33RrYIv.js +198 -0
  3. package/dist/chunks/app-d-ts-h33RrYIv.js.map +1 -0
  4. package/dist/chunks/app-layout.svelte-CZ0hw-pi.js +51 -0
  5. package/dist/chunks/app-layout.svelte-CZ0hw-pi.js.map +1 -0
  6. package/dist/chunks/constants-DpK-r_m5.js.map +1 -1
  7. package/dist/chunks/{generate.runtime-CzYArKUA.js → generate.runtime-BSxSHNh7.js} +2 -2
  8. package/dist/chunks/{generate.runtime-CzYArKUA.js.map → generate.runtime-BSxSHNh7.js.map} +1 -1
  9. package/dist/chunks/{generate.runtime-Dfl-07VS.js → generate.runtime-CZKIKP3B.js} +214 -178
  10. package/dist/chunks/generate.runtime-CZKIKP3B.js.map +1 -0
  11. package/dist/chunks/{generate.runtime-DaPA2NNL.js → generate.runtime-CqCXFeWH.js} +2 -2
  12. package/dist/chunks/{generate.runtime-DaPA2NNL.js.map → generate.runtime-CqCXFeWH.js.map} +1 -1
  13. package/dist/chunks/{generate.runtime-B6FeCL5I.js → generate.runtime-CsP4c8GY.js} +78 -77
  14. package/dist/chunks/generate.runtime-CsP4c8GY.js.map +1 -0
  15. package/dist/chunks/generate.runtime-DZUPtJVF.js +429 -0
  16. package/dist/chunks/generate.runtime-DZUPtJVF.js.map +1 -0
  17. package/dist/chunks/{generate.runtime-C_SdcnRs.js → generate.runtime-Db7JwGTb.js} +2 -2
  18. package/dist/chunks/{generate.runtime-C_SdcnRs.js.map → generate.runtime-Db7JwGTb.js.map} +1 -1
  19. package/dist/chunks/{generate.runtime-i3tMIA1A.js → generate.runtime-pbIrEsa7.js} +45 -45
  20. package/dist/chunks/generate.runtime-pbIrEsa7.js.map +1 -0
  21. package/dist/chunks/i18n-BHCytiiO.js +28 -0
  22. package/dist/chunks/i18n-BHCytiiO.js.map +1 -0
  23. package/dist/chunks/{table-core-BXmnfjln.js → table-core-Dua6QnXM.js} +14 -4
  24. package/dist/chunks/table-core-Dua6QnXM.js.map +1 -0
  25. package/dist/chunks/{test-setup-cZj1tqaf.js → test-setup-gJdzWWs_.js} +2 -2
  26. package/dist/chunks/{test-setup-cZj1tqaf.js.map → test-setup-gJdzWWs_.js.map} +1 -1
  27. package/dist/chunks/translations-CiJnl574.js +189 -0
  28. package/dist/chunks/translations-CiJnl574.js.map +1 -0
  29. package/dist/chunks/{ui-IkdkLwmB.js → ui-CD61O7Sb.js} +3 -3
  30. package/dist/chunks/{ui-IkdkLwmB.js.map → ui-CD61O7Sb.js.map} +1 -1
  31. package/dist/chunks/write-result-B7MewKhQ.js +499 -0
  32. package/dist/chunks/write-result-B7MewKhQ.js.map +1 -0
  33. package/dist/index.js +734 -721
  34. package/dist/index.js.map +1 -1
  35. package/package.json +1 -1
  36. package/dist/chunks/_layout-xBzFhszN.js +0 -78
  37. package/dist/chunks/_layout-xBzFhszN.js.map +0 -1
  38. package/dist/chunks/generate.runtime-B6FeCL5I.js.map +0 -1
  39. package/dist/chunks/generate.runtime-DLg2CKxQ.js +0 -341
  40. package/dist/chunks/generate.runtime-DLg2CKxQ.js.map +0 -1
  41. package/dist/chunks/generate.runtime-Dfl-07VS.js.map +0 -1
  42. package/dist/chunks/generate.runtime-i3tMIA1A.js.map +0 -1
  43. package/dist/chunks/table-core-BXmnfjln.js.map +0 -1
  44. package/dist/chunks/write-result-C1GYInL8.js +0 -499
  45. package/dist/chunks/write-result-C1GYInL8.js.map +0 -1
@@ -3,30 +3,32 @@ import { t } from "./ui-D5xgIDR_.js";
3
3
  import { r as n } from "./modify-file-CRZ_gMg0.js";
4
4
  import { a as r, t as i } from "./config-target-DJbVHwHl.js";
5
5
  import { _ as a, i as o, o as s, r as c } from "./ts-morph-helpers-B4KZXP44.js";
6
- import { i as l, n as u, s as d } from "./_layout-xBzFhszN.js";
7
- import { t as f } from "./dedent-CCUOcPFW.js";
8
- import { t as p } from "./compose-handle-Da7m6lV_.js";
9
- import { t as m } from "./svelte-file-DfplF3BU.js";
10
- import { r as h, t as g } from "./wuchale-config-CNXoq4rc.js";
11
- import _ from "node:fs";
12
- import v from "node:path";
13
- import { Project as y, QuoteKind as b, SyntaxKind as x } from "ts-morph";
6
+ import { a as l, c as u, p as ee, r as te, u as ne } from "./app-d-ts-h33RrYIv.js";
7
+ import { t as d } from "./dedent-CCUOcPFW.js";
8
+ import { t as f } from "./compose-handle-Da7m6lV_.js";
9
+ import { t as p } from "./svelte-file-DfplF3BU.js";
10
+ import { n as m, r as re } from "./app-layout.svelte-CZ0hw-pi.js";
11
+ import { a as ie, i as ae, n as oe, t as h } from "./translations-CiJnl574.js";
12
+ import { r as g, t as _ } from "./wuchale-config-CNXoq4rc.js";
13
+ import v from "node:fs";
14
+ import y from "node:path";
15
+ import { Project as b, QuoteKind as x, SyntaxKind as S } from "ts-morph";
14
16
  // src/patterns/enable/i18n/modifies/vite-config.ts
15
- var S = "Add the wuchale plugin to your Vite config:\n\nimport { wuchale } from 'wuchale/vite';\n\nexport default defineConfig({\n plugins: [wuchale(), /* ...existing plugins */],\n});", C = "Create a Vite config with the wuchale plugin:\n\nimport { defineConfig } from 'vite';\nimport { wuchale } from 'wuchale/vite';\n\nexport default defineConfig({\n plugins: [wuchale()],\n});";
16
- function w(e) {
17
- if (!_.existsSync(e)) return {
17
+ var C = "Add the wuchale plugin to your Vite config:\n\nimport { wuchale } from 'wuchale/vite';\n\nexport default defineConfig({\n plugins: [wuchale(), /* ...existing plugins */],\n});", w = "Create a Vite config with the wuchale plugin:\n\nimport { defineConfig } from 'vite';\nimport { wuchale } from 'wuchale/vite';\n\nexport default defineConfig({\n plugins: [wuchale()],\n});";
18
+ function se(e) {
19
+ if (!v.existsSync(e)) return {
18
20
  status: "not-found",
19
- message: C
21
+ message: w
20
22
  };
21
- let t = new y({
23
+ let t = new b({
22
24
  compilerOptions: { allowJs: !0 },
23
- manipulationSettings: { quoteKind: b.Single }
25
+ manipulationSettings: { quoteKind: x.Single }
24
26
  }).addSourceFileAtPath(e), n = !1, r = !1;
25
27
  t.getImportDeclarations().some((e) => e.getModuleSpecifierValue() === "wuchale/vite") || (t.insertImportDeclaration(0, {
26
28
  namedImports: ["wuchale"],
27
29
  moduleSpecifier: "wuchale/vite"
28
30
  }), n = !0);
29
- let i = t.getDescendantsOfKind(x.CallExpression).find((e) => e.getExpression().getText() === "defineConfig")?.getArguments()?.[0], a = i?.getKind() === x.ObjectLiteralExpression ? i : null;
31
+ let i = t.getDescendantsOfKind(S.CallExpression).find((e) => e.getExpression().getText() === "defineConfig")?.getArguments()?.[0], a = i?.getKind() === S.ObjectLiteralExpression ? i : null;
30
32
  if (!a) r = !0;
31
33
  else {
32
34
  let e = a.getProperty("plugins");
@@ -34,11 +36,11 @@ function w(e) {
34
36
  name: "plugins",
35
37
  initializer: "[wuchale()]"
36
38
  }), n = !0;
37
- else if (e.getKind() !== x.PropertyAssignment) r = !0;
39
+ else if (e.getKind() !== S.PropertyAssignment) r = !0;
38
40
  else {
39
41
  let t = e.getInitializer();
40
42
  if (!t) e.setInitializer("[wuchale()]"), n = !0;
41
- else if (t.getKind() !== x.ArrayLiteralExpression) r = !0;
43
+ else if (t.getKind() !== S.ArrayLiteralExpression) r = !0;
42
44
  else {
43
45
  let e = t;
44
46
  e.getElements().some((e) => e.getText().replace(/\s/g, "") === "wuchale()") || (e.insertElement(0, "wuchale()"), n = !0);
@@ -47,115 +49,129 @@ function w(e) {
47
49
  }
48
50
  return n && (s(t), t.saveSync()), r ? {
49
51
  status: "failed",
50
- message: S
52
+ message: C
51
53
  } : {
52
54
  status: "success",
53
55
  changed: n
54
56
  };
55
57
  }
56
58
  // src/patterns/enable/i18n/modifies/hooks.server.ts
57
- var T = "handleWuchale", E = f`
58
- Wrap your exported handle with the wuchale i18n handler:
59
+ var T = "handleWuchale", E = (e) => d`
60
+ const urlLocale = deLocalizeDefault(event.url.pathname, locales)[1] as Locale | null;
61
+ const localizedUrl = hasLocalizedUrl(event.url.pathname);
62
+ const cookie${e.locale} = event.cookies.get(LOCALE_COOKIE);
63
+ const locale = pickLocale({
64
+ urlLocale,
65
+ localizedUrl,
66
+ cookie,
67
+ acceptLanguage: event.request.headers.get('accept-language'),
68
+ locales,
69
+ defaultLocale
70
+ });
71
+ event.locals.locale = locale;
59
72
 
60
- import { sequence } from '@sveltejs/kit/hooks';
61
- import { runWithLocale, loadLocales } from 'wuchale/load-utils/server';
62
- import { getLocale } from '#locales/main.url.js';
63
- import { locales } from '#locales/data.js';
64
- import * as main from '#locales/main.loader.server.svelte.js';
65
- import * as js from '#locales/js.loader.server.js';
73
+ const response${e.html ? ": Response" : ""} = await runWithLocale(locale, () =>
74
+ resolve(event, {
75
+ transformPageChunk: ({ html }${e.html}) => html.replace('%sveltekit.lang%', locale)
76
+ })
77
+ );
66
78
 
67
- loadLocales(main.key, main.loadCount, main.loadCatalog, locales);
68
- loadLocales(js.key, js.loadCount, js.loadCatalog, locales);
69
-
70
- const handleWuchale = async ({ event, resolve }: any) => {
71
- const locale = getLocale(event.url);
72
- return await runWithLocale(locale, () =>
73
- resolve(event, {
74
- transformPageChunk: ({ html }: { html: string }) =>
75
- html.replace('%sveltekit.lang%', locale),
76
- }),
77
- );
78
- };
79
-
80
- export const handle = sequence(handleWuchale, /* your existing handle */);
81
- `, D = f`
82
- import type { Handle } from '@sveltejs/kit/hooks';
79
+ // Opening a public page sets the language of the pages that have no
80
+ // language in their URL. Only when the page itself is opened: a preload
81
+ // (hovering a link) must not change it.
82
+ if (localizedUrl && cookie !== locale && event.request.method === 'GET' && !event.isDataRequest) {
83
+ try {
84
+ response.headers.append('set-cookie', localeCookie(locale));
85
+ } catch {
86
+ // a response with immutable headers (a proxied file): nothing to remember
87
+ }
88
+ }
89
+ return response;
90
+ `, D = (e) => e.split("\n").map((e) => e && ` ${e}`).join("\n"), O = d`
83
91
  import { runWithLocale, loadLocales } from 'wuchale/load-utils/server';
84
- import { getLocale } from '#locales/main.url.js';
85
- import { locales } from '#locales/data.js';
92
+ import { deLocalizeDefault } from 'wuchale/url';
93
+ import { locales, type Locale } from '#locales/data.js';
94
+ import { defaultLocale, hasLocalizedUrl } from '#lib/url.js';
95
+ import { LOCALE_COOKIE, localeCookie, pickLocale } from '#lib/locale.js';
86
96
  import * as main from '#locales/main.loader.server.svelte.js';
87
97
  import * as js from '#locales/js.loader.server.js';
88
-
98
+ `, k = d`
89
99
  loadLocales(main.key, main.loadCount, main.loadCatalog, locales);
90
100
  loadLocales(js.key, js.loadCount, js.loadCatalog, locales);
91
-
92
- const handleWuchale: Handle = async ({ event, resolve }) => {
93
- const locale = getLocale(event.url);
94
- return await runWithLocale(locale, () =>
95
- resolve(event, {
96
- transformPageChunk: ({ html }) => html.replace('%sveltekit.lang%', locale)
97
- })
98
- );
99
- };
100
-
101
- export const handle = handleWuchale;
102
- `;
103
- function O(e, t, n) {
101
+ `, A = [
102
+ `const ${T} = async ({ event, resolve }: any) => {`,
103
+ D(E({
104
+ locale: ": string | undefined",
105
+ html: ": { html: string }"
106
+ })),
107
+ "};"
108
+ ].join("\n"), j = [
109
+ "Wrap your exported handle with the wuchale i18n handler:",
110
+ "",
111
+ "import { sequence } from '@sveltejs/kit/hooks';",
112
+ O,
113
+ "",
114
+ k,
115
+ "",
116
+ A,
117
+ "",
118
+ "export const handle = sequence(handleWuchale, /* your existing handle */);"
119
+ ].join("\n"), ce = [
120
+ "import type { Handle } from '@sveltejs/kit/hooks';",
121
+ O,
122
+ "",
123
+ k,
124
+ "",
125
+ `const ${T}: Handle = async ({ event, resolve }) => {`,
126
+ D(E({
127
+ locale: "",
128
+ html: ""
129
+ })),
130
+ "};",
131
+ "",
132
+ `export const handle = ${T};`
133
+ ].join("\n");
134
+ function M(e, t, n) {
104
135
  e.getImportDeclarations().find((e) => e.getModuleSpecifierValue() === t) || e.addImportDeclaration({
105
136
  namespaceImport: n,
106
137
  moduleSpecifier: t
107
138
  });
108
139
  }
109
- function k(e) {
110
- if (!_.existsSync(e)) return _.existsSync(e.replace(/\.ts$/, ".js")) ? {
140
+ function N(e) {
141
+ if (!v.existsSync(e)) return v.existsSync(e.replace(/\.ts$/, ".js")) ? {
111
142
  status: "failed",
112
- message: E
113
- } : (_.mkdirSync(v.dirname(e), { recursive: !0 }), _.writeFileSync(e, D + "\n"), {
143
+ message: j
144
+ } : (v.mkdirSync(y.dirname(e), { recursive: !0 }), v.writeFileSync(e, ce + "\n"), {
114
145
  status: "success",
115
146
  changed: !0
116
147
  });
117
- let t = _.readFileSync(e, "utf8");
148
+ let t = v.readFileSync(e, "utf8");
118
149
  if (t.includes("runWithLocale") || t.includes("loadLocales(")) return {
119
150
  status: "success",
120
151
  changed: !1
121
152
  };
122
- let n = new y({
153
+ let n = new b({
123
154
  compilerOptions: { allowJs: !0 },
124
- manipulationSettings: { quoteKind: b.Single }
125
- }).addSourceFileAtPath(e), r = p(n, { expression: T });
155
+ manipulationSettings: { quoteKind: x.Single }
156
+ }).addSourceFileAtPath(e), r = f(n, { expression: T });
126
157
  if (r.status === "unsupported" || !r.statement) return {
127
158
  status: "failed",
128
- message: E
159
+ message: j
129
160
  };
130
161
  let i = r.statement;
131
- o(n, "wuchale/load-utils/server", "runWithLocale"), o(n, "wuchale/load-utils/server", "loadLocales"), o(n, "#locales/main.url.js", "getLocale"), o(n, "#locales/data.js", "locales"), O(n, "#locales/main.loader.server.svelte.js", "main"), O(n, "#locales/js.loader.server.js", "js");
132
- let a = f`
133
- loadLocales(main.key, main.loadCount, main.loadCatalog, locales);
134
- loadLocales(js.key, js.loadCount, js.loadCatalog, locales);
135
- `, c = f`
136
- const ${T} = async ({ event, resolve }: any) => {
137
- const locale = getLocale(event.url);
138
- return await runWithLocale(locale, () =>
139
- resolve(event, {
140
- transformPageChunk: ({ html }: { html: string }) =>
141
- html.replace('%sveltekit.lang%', locale)
142
- })
143
- );
144
- };
145
- `;
146
- return n.insertText(i.getStart(!0), `${a}\n\n${c}\n\n`), s(n), n.saveSync(), {
162
+ return o(n, "wuchale/load-utils/server", "runWithLocale"), o(n, "wuchale/load-utils/server", "loadLocales"), o(n, "wuchale/url", "deLocalizeDefault"), o(n, "#locales/data.js", "locales"), o(n, "#locales/data.js", "Locale", !0), o(n, "#lib/url.js", "defaultLocale"), o(n, "#lib/url.js", "hasLocalizedUrl"), o(n, "#lib/locale.js", "LOCALE_COOKIE"), o(n, "#lib/locale.js", "localeCookie"), o(n, "#lib/locale.js", "pickLocale"), M(n, "#locales/main.loader.server.svelte.js", "main"), M(n, "#locales/js.loader.server.js", "js"), n.insertText(i.getStart(!0), `${k}\n\n${A}\n\n`), s(n), n.saveSync(), {
147
163
  status: "success",
148
164
  changed: !0
149
165
  };
150
166
  }
151
167
  // src/patterns/enable/i18n/modifies/hooks.ts
152
- var A = f`
168
+ var P = d`
153
169
  const rerouteDeLocalize = (url: string) => {
154
170
  const [upath, locale] = deLocalizeDefault(url, locales);
155
171
  const { path } = matchUrl(upath, locale);
156
172
  return path ?? url;
157
173
  };
158
- `, j = f`
174
+ `, F = d`
159
175
  import { deLocalizeDefault } from 'wuchale/url';
160
176
  import { matchUrl } from '#locales/main.url.js';
161
177
  import { locales } from '#locales/data.js';
@@ -167,7 +183,7 @@ var A = f`
167
183
  };
168
184
 
169
185
  export const reroute = ({ url }) => rerouteDeLocalize(url.pathname);
170
- `, M = f`
186
+ `, I = d`
171
187
  Compose your existing reroute in src/hooks.ts with the wuchale de-localizer:
172
188
 
173
189
  import { deLocalizeDefault } from 'wuchale/url';
@@ -181,57 +197,57 @@ var A = f`
181
197
  };
182
198
 
183
199
  export const reroute = ({ url }) => rerouteDeLocalize(existingReroute(url.pathname));
184
- `, N = /^\(\s*\{\s*url\s*\}\s*\)\s*=>\s*negotiateReroute\(\s*url\.pathname\s*\)$/;
185
- function P(e) {
200
+ `, L = /^\(\s*\{\s*url\s*\}\s*\)\s*=>\s*negotiateReroute\(\s*url\.pathname\s*\)$/;
201
+ function R(e) {
186
202
  return e.getFunction("reroute") ? !0 : e.getExportDeclarations().some((e) => e.getNamedExports().some((e) => (e.getAliasNode()?.getText() ?? e.getName()) === "reroute"));
187
203
  }
188
- function F(e) {
204
+ function z(e) {
189
205
  o(e, "wuchale/url", "deLocalizeDefault"), o(e, "#locales/main.url.js", "matchUrl"), o(e, "#locales/data.js", "locales");
190
206
  }
191
- function I(e) {
192
- if (!_.existsSync(e)) return _.mkdirSync(v.dirname(e), { recursive: !0 }), _.writeFileSync(e, j + "\n"), {
207
+ function B(e) {
208
+ if (!v.existsSync(e)) return v.mkdirSync(y.dirname(e), { recursive: !0 }), v.writeFileSync(e, F + "\n"), {
193
209
  status: "success",
194
210
  changed: !0
195
211
  };
196
- if (_.readFileSync(e, "utf8").includes("rerouteDeLocalize")) return {
212
+ if (v.readFileSync(e, "utf8").includes("rerouteDeLocalize")) return {
197
213
  status: "success",
198
214
  changed: !1
199
215
  };
200
- let t = new y({
216
+ let t = new b({
201
217
  compilerOptions: { allowJs: !0 },
202
- manipulationSettings: { quoteKind: b.Single }
218
+ manipulationSettings: { quoteKind: x.Single }
203
219
  }).addSourceFileAtPath(e), n = t.getVariableDeclaration("reroute");
204
- if (!n) return P(t) ? {
220
+ if (!n) return R(t) ? {
205
221
  status: "failed",
206
- message: M
207
- } : (F(t), t.addStatements(`\n${A}\n\nexport const reroute = ({ url }) => rerouteDeLocalize(url.pathname);\n`), s(t), t.saveSync(), {
222
+ message: I
223
+ } : (z(t), t.addStatements(`\n${P}\n\nexport const reroute = ({ url }) => rerouteDeLocalize(url.pathname);\n`), s(t), t.saveSync(), {
208
224
  status: "success",
209
225
  changed: !0
210
226
  });
211
- if (!n.getFirstAncestorByKind(x.VariableStatement)?.hasExportKeyword()) return {
227
+ if (!n.getFirstAncestorByKind(S.VariableStatement)?.hasExportKeyword()) return {
212
228
  status: "failed",
213
- message: M
229
+ message: I
214
230
  };
215
231
  let r = n.getInitializer();
216
- if (!r || !N.test(r.getText())) return {
232
+ if (!r || !L.test(r.getText())) return {
217
233
  status: "failed",
218
- message: M
234
+ message: I
219
235
  };
220
- F(t), n.setInitializer("({ url }) => rerouteDeLocalize(negotiateReroute(url.pathname))");
236
+ z(t), n.setInitializer("({ url }) => rerouteDeLocalize(negotiateReroute(url.pathname))");
221
237
  let i = t.getVariableStatements().find((e) => e.getDeclarations().some((e) => e.getName() === "reroute"));
222
- return t.insertText(i.getStart(!0), `${A}\n\n`), s(t), t.saveSync(), {
238
+ return t.insertText(i.getStart(!0), `${P}\n\n`), s(t), t.saveSync(), {
223
239
  status: "success",
224
240
  changed: !0
225
241
  };
226
242
  }
227
243
  // src/patterns/enable/i18n/modifies/app-html.ts
228
- var L = "Add the sveltekit lang placeholder to the <html> tag:\n\n<html lang=\"%sveltekit.lang%\">", R = "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>";
229
- function z(e) {
230
- if (!_.existsSync(e)) return {
244
+ var V = "Add the sveltekit lang placeholder to the <html> tag:\n\n<html lang=\"%sveltekit.lang%\">", H = "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>";
245
+ function U(e) {
246
+ if (!v.existsSync(e)) return {
231
247
  status: "not-found",
232
- message: R
248
+ message: H
233
249
  };
234
- let t = _.readFileSync(e, "utf8");
250
+ let t = v.readFileSync(e, "utf8");
235
251
  if (t.includes("lang=\"%sveltekit.lang%\"") || t.includes("lang='%sveltekit.lang%'")) return {
236
252
  status: "success",
237
253
  changed: !1
@@ -239,74 +255,74 @@ function z(e) {
239
255
  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%\""));
240
256
  return n === t ? {
241
257
  status: "failed",
242
- message: L
243
- } : (_.writeFileSync(e, n), {
258
+ message: V
259
+ } : (v.writeFileSync(e, n), {
244
260
  status: "success",
245
261
  changed: !0
246
262
  });
247
263
  }
248
264
  // src/patterns/enable/i18n/modifies/gitignore.ts
249
- var B = "Create a .gitignore with the wuchale cache ignored:\n\n# Wuchale\nsrc/locales/.wuchale";
250
- function V(e) {
251
- if (!_.existsSync(e)) return {
265
+ var W = "Create a .gitignore with the wuchale cache ignored:\n\n# Wuchale\nsrc/locales/.wuchale";
266
+ function G(e) {
267
+ if (!v.existsSync(e)) return {
252
268
  status: "not-found",
253
- message: B
269
+ message: W
254
270
  };
255
- let t = _.readFileSync(e, "utf8");
271
+ let t = v.readFileSync(e, "utf8");
256
272
  if (t.includes("src/locales/.wuchale")) return {
257
273
  status: "success",
258
274
  changed: !1
259
275
  };
260
- let n = f`
276
+ let n = d`
261
277
  # Wuchale
262
278
  src/locales/.wuchale
263
279
  `, r = t + (t.length > 0 && !t.endsWith("\n") ? "\n" : "") + "\n" + n + "\n";
264
- return _.writeFileSync(e, r), {
280
+ return v.writeFileSync(e, r), {
265
281
  status: "success",
266
282
  changed: !0
267
283
  };
268
284
  }
269
285
  // src/patterns/enable/i18n/modifies/root-layout.svelte.ts
270
- var H = "<Navbar.Item>\n <LanguageSelect />\n </Navbar.Item>\n ", U = "<LanguageSelect />", W = f`
286
+ var K = "<Navbar.Item>\n <LanguageSelect />\n </Navbar.Item>\n ", q = "<LanguageSelect />", J = d`
271
287
  import LanguageSelect from '#lib/components/language-select.svelte';
272
- `, G = [
288
+ `, le = [
273
289
  "Add the language select inside your <Navbar.List> in the root layout.",
274
290
  "",
275
291
  "Import to add to the <script> tag:",
276
292
  "",
277
- W,
293
+ J,
278
294
  "",
279
295
  "Markup to add at the end of <Navbar.List>:",
280
- H
281
- ].join("\n"), K = [
296
+ K
297
+ ].join("\n"), ue = [
282
298
  "Create a root layout that includes a language select inside <Navbar.List>.",
283
299
  "",
284
300
  "Import for the <script> tag:",
285
301
  "",
286
- W,
302
+ J,
287
303
  "",
288
304
  "Markup at the end of <Navbar.List>:",
289
- H
290
- ].join("\n"), q = [
305
+ K
306
+ ].join("\n"), de = [
291
307
  "Add the language select to your root layout.",
292
308
  "",
293
309
  "Import to add to the <script> tag:",
294
310
  "",
295
- W,
311
+ J,
296
312
  "",
297
313
  "Markup to add wherever it should render, e.g. above {@render children()}:",
298
314
  "",
299
- U
300
- ].join("\n"), J = [
315
+ q
316
+ ].join("\n"), fe = [
301
317
  "Create a root layout that includes the language select.",
302
318
  "",
303
319
  "Import for the <script> tag:",
304
320
  "",
305
- W,
321
+ J,
306
322
  "",
307
323
  "Markup above {@render children()}:",
308
324
  "",
309
- U
325
+ q
310
326
  ].join("\n");
311
327
  function Y(e) {
312
328
  e.modifyScript((e) => {
@@ -319,32 +335,32 @@ function Y(e) {
319
335
  return t;
320
336
  });
321
337
  }
322
- function ee(e, t = "shadcn") {
338
+ function pe(e, t = "shadcn") {
323
339
  let n = t === "plain";
324
- if (!_.existsSync(e)) return {
340
+ if (!v.existsSync(e)) return {
325
341
  status: "not-found",
326
- message: n ? J : K
342
+ message: n ? fe : ue
327
343
  };
328
- let r = m.fromPath(e);
344
+ let r = p.fromPath(e);
329
345
  return r.hasElement("LanguageSelect") ? {
330
346
  status: "success",
331
347
  changed: !1
332
- } : n ? !r.getScript() || !r.insertBeforeChildren(U) ? {
348
+ } : n ? !r.getScript() || !r.insertBeforeChildren(q) ? {
333
349
  status: "failed",
334
- message: q
350
+ message: de
335
351
  } : (Y(r), r.writeTo(e), {
336
352
  status: "success",
337
353
  changed: r.hasChanged()
338
- }) : r.hasElement("Navbar.List") ? (Y(r), r.insertBeforeClosingTag("Navbar.List", H), r.writeTo(e), {
354
+ }) : r.hasElement("Navbar.List") ? (Y(r), r.insertBeforeClosingTag("Navbar.List", K), r.writeTo(e), {
339
355
  status: "success",
340
356
  changed: r.hasChanged()
341
357
  }) : {
342
358
  status: "failed",
343
- message: G
359
+ message: le
344
360
  };
345
361
  }
346
362
  // src/patterns/enable/i18n/welcome-catalog.ts
347
- var X = "src/routes/+page.svelte", Z = "src/locales/es.po", te = "<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>", Q = [{
363
+ var X = "src/routes/+page.svelte", Z = "src/locales/es.po", me = "<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>", Q = [{
348
364
  reference: X,
349
365
  msgid: "Welcome to SvelteKit",
350
366
  msgstr: "Bienvenido a SvelteKit"
@@ -352,18 +368,18 @@ var X = "src/routes/+page.svelte", Z = "src/locales/es.po", te = "<h1>Welcome to
352
368
  reference: X,
353
369
  msgid: "Visit <0>svelte.dev/docs/kit</0> to read the documentation",
354
370
  msgstr: "Visita <0>svelte.dev/docs/kit</0> para leer la documentación"
355
- }], ne = {
371
+ }], he = {
356
372
  reference: "src/lib/components/language-select.svelte",
357
373
  msgid: "Language",
358
374
  msgstr: "Idioma"
359
- }, re = "msgid \"\"\nmsgstr \"\"\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\"", $ = (e) => e.replace(/\s+/g, "");
360
- function ie(e, t) {
361
- if (_.existsSync(v.join(e, Z))) return null;
362
- let n = v.join(e, X);
363
- return !_.existsSync(n) || $(_.readFileSync(n, "utf8")) !== $(te) ? null : {
375
+ }, ge = "msgid \"\"\nmsgstr \"\"\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\"", $ = (e) => e.replace(/\s+/g, "");
376
+ function _e(e, t) {
377
+ if (v.existsSync(y.join(e, Z))) return null;
378
+ let n = y.join(e, X);
379
+ return !v.existsSync(n) || $(v.readFileSync(n, "utf8")) !== $(me) ? null : {
364
380
  path: Z,
365
381
  language: "text",
366
- content: [re, ...(t === "plain" ? [...Q, ne] : Q).map((e) => [
382
+ content: [ge, ...(t === "plain" ? [...Q, he] : Q).map((e) => [
367
383
  `#: ${e.reference}`,
368
384
  `msgid "${e.msgid}"`,
369
385
  `msgstr "${e.msgstr}"`
@@ -372,48 +388,68 @@ function ie(e, t) {
372
388
  };
373
389
  }
374
390
  // src/patterns/enable/i18n/generate.runtime.ts
375
- function ae(e, t) {
376
- let n = g.filter((t) => _.existsSync(v.join(e, t)));
391
+ function ve(e, t) {
392
+ let n = _.filter((t) => v.existsSync(y.join(e, t)));
377
393
  return n.length === 0 ? t : t.map((e) => {
378
394
  if (!e.path.endsWith("wuchale.config.js")) return e;
379
- let t = h(e.content, n);
395
+ let t = g(e.content, n);
380
396
  return t?.changed ? {
381
397
  ...e,
382
398
  content: t.source
383
399
  } : e;
384
400
  });
385
401
  }
386
- async function oe(a) {
402
+ async function ye(a) {
387
403
  let o = e(a), s = [], c = (e) => {
388
404
  e && s.push(e);
389
405
  };
390
406
  o.info("Modifying vite.config");
391
- let f = r(a.root, i) ?? v.join(a.root, i[0]);
392
- c(n(f, w(f))), o.info("Adding #locales to package.json imports");
393
- let p = l(a.root);
394
- c(n(p.filePath, p.outcome)), o.info("Modifying hooks.server.ts");
395
- let m = v.join(a.root, "src", "hooks.server.ts");
396
- c(n(m, k(m))), o.info("Modifying hooks.ts");
397
- let h = v.join(a.root, "src", "hooks.ts");
398
- c(n(h, I(h))), o.info("Modifying app.html");
399
- let g = v.join(a.root, "src", "app.html");
400
- c(n(g, z(g))), o.info("Modifying root +layout.ts");
401
- let y = v.join(a.root, "src", "routes", "+layout.ts");
402
- c(n(y, u(y))), o.info("Modifying root layout language select");
403
- let b = [
404
- v.join(a.root, "src", "routes", "(public)", "root-layout.svelte"),
405
- v.join(a.root, "src", "routes", "root-layout.svelte"),
406
- v.join(a.root, "src", "routes", "(public)", "+layout.svelte"),
407
- v.join(a.root, "src", "routes", "+layout.svelte")
408
- ], x = t(a), S = b.find((e) => _.existsSync(e)) ?? (x === "plain" ? b[3] : b[0]);
409
- c(n(S, ee(S, x))), o.info("Updating .gitignore");
410
- let C = v.join(a.root, ".gitignore");
411
- c(n(C, V(C))), o.info("Updating .prettierignore");
412
- let T = v.join(a.root, ".prettierignore");
413
- c(n(T, d(T)));
414
- let E = ie(a.root, x);
415
- return E && o.info("Translating the welcome page into Spanish"), {
416
- creates: E ? [E] : [],
407
+ let d = r(a.root, i) ?? y.join(a.root, i[0]);
408
+ c(n(d, se(d))), o.info("Adding #locales to package.json imports");
409
+ let f = ne(a.root);
410
+ c(n(f.filePath, f.outcome)), o.info("Modifying hooks.server.ts");
411
+ let p = y.join(a.root, "src", "hooks.server.ts");
412
+ c(n(p, N(p))), o.info("Modifying hooks.ts");
413
+ let g = y.join(a.root, "src", "hooks.ts");
414
+ c(n(g, B(g))), o.info("Modifying app.html");
415
+ let _ = y.join(a.root, "src", "app.html");
416
+ c(n(_, U(_))), o.info("Declaring the request's language in app.d.ts");
417
+ let b = y.join(a.root, "src", "app.d.ts");
418
+ c(n(b, te(b))), o.info("Modifying root +layout.server.ts");
419
+ let x = y.join(a.root, "src", "routes", "+layout.server.ts");
420
+ c(n(x, l(x))), o.info("Modifying root +layout.ts");
421
+ let S = y.join(a.root, "src", "routes", "+layout.ts");
422
+ c(n(S, u(S))), o.info("Modifying root layout language select");
423
+ let C = [
424
+ y.join(a.root, "src", "routes", "(public)", "root-layout.svelte"),
425
+ y.join(a.root, "src", "routes", "root-layout.svelte"),
426
+ y.join(a.root, "src", "routes", "(public)", "+layout.svelte"),
427
+ y.join(a.root, "src", "routes", "+layout.svelte")
428
+ ], w = t(a), T = C.find((e) => v.existsSync(e)) ?? (w === "plain" ? C[3] : C[0]);
429
+ c(n(T, pe(T, w)));
430
+ let E = y.join(a.root, m);
431
+ v.existsSync(E) && (o.info("Adding the language select to the signed-in layout"), c(n(E, re(E)))), o.info("Updating .gitignore");
432
+ let D = y.join(a.root, ".gitignore");
433
+ c(n(D, G(D))), o.info("Updating .prettierignore");
434
+ let O = y.join(a.root, ".prettierignore");
435
+ c(n(O, ee(O)));
436
+ let k = _e(a.root, w);
437
+ k && o.info("Translating the welcome page into Spanish");
438
+ let A = oe(a.root, h);
439
+ A.length > 0 && o.info("Translating the sign-in pages into Spanish");
440
+ let j = [];
441
+ if (k) {
442
+ let e = ie(k.content, A).source;
443
+ j.push({
444
+ ...k,
445
+ content: e
446
+ });
447
+ } else {
448
+ let e = ae(a.root, A);
449
+ e.create && j.push(e.create), c(e.modify);
450
+ }
451
+ return {
452
+ creates: j,
417
453
  modifies: s,
418
454
  deletes: [],
419
455
  components: [],
@@ -423,6 +459,6 @@ async function oe(a) {
423
459
  collectionDrops: []
424
460
  };
425
461
  }
426
- export { oe as generate, ae as withLibraryTexts };
462
+ export { ye as generate, ve as withLibraryTexts };
427
463
 
428
- //# sourceMappingURL=generate.runtime-Dfl-07VS.js.map
464
+ //# sourceMappingURL=generate.runtime-CZKIKP3B.js.map