@velastack/patterns 0.14.3 → 0.15.1
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 +28 -0
- package/dist/chunks/_page-Cg7LjaOE.js +5 -0
- package/dist/chunks/{_page-44USwLXO.js.map → _page-Cg7LjaOE.js.map} +1 -1
- package/dist/chunks/auth-pages-DSBqKjO0.js +311 -0
- package/dist/chunks/auth-pages-DSBqKjO0.js.map +1 -0
- package/dist/chunks/{collections-B_-NTtLW.js → collections-D2_2cxWD.js} +70 -73
- package/dist/chunks/collections-D2_2cxWD.js.map +1 -0
- package/dist/chunks/{constants-CTp-0HKk.js → constants-DbpctM1D.js} +21 -21
- package/dist/chunks/constants-DbpctM1D.js.map +1 -0
- package/dist/chunks/{currency.server-DOX4Rzyb.js → currency.server-CFrwmYra.js} +4 -4
- package/dist/chunks/{currency.server-DOX4Rzyb.js.map → currency.server-CFrwmYra.js.map} +1 -1
- package/dist/chunks/{env-vars-BbS_mWyP.js → env-vars-Dm3Xy4rl.js} +4 -4
- package/dist/chunks/{env-vars-BbS_mWyP.js.map → env-vars-Dm3Xy4rl.js.map} +1 -1
- package/dist/chunks/{generate-CKuUg3p-.js → generate-BDGmczK8.js} +2 -2
- package/dist/chunks/{generate-CKuUg3p-.js.map → generate-BDGmczK8.js.map} +1 -1
- package/dist/chunks/{generate-Bwkx_usZ.js → generate-BMWoD9E2.js} +4 -4
- package/dist/chunks/{generate-Bwkx_usZ.js.map → generate-BMWoD9E2.js.map} +1 -1
- package/dist/chunks/{generate-4iujJNAW.js → generate-BRTIGlqT.js} +5 -5
- package/dist/chunks/{generate-4iujJNAW.js.map → generate-BRTIGlqT.js.map} +1 -1
- package/dist/chunks/{generate-DYq5Oj58.js → generate-BrO9MOgL.js} +2 -2
- package/dist/chunks/{generate-DYq5Oj58.js.map → generate-BrO9MOgL.js.map} +1 -1
- package/dist/chunks/{generate-BJY8AtAp.js → generate-BvQ6VwYH.js} +5 -5
- package/dist/chunks/{generate-BJY8AtAp.js.map → generate-BvQ6VwYH.js.map} +1 -1
- package/dist/chunks/{generate-B4uDCW5D.js → generate-Cs_fdfD7.js} +4 -4
- package/dist/chunks/{generate-B4uDCW5D.js.map → generate-Cs_fdfD7.js.map} +1 -1
- package/dist/chunks/{generate-JkvSNTy-.js → generate-DZ9kT3iC.js} +31 -188
- package/dist/chunks/generate-DZ9kT3iC.js.map +1 -0
- package/dist/chunks/{generate.runtime-D9OC1RXu.js → generate.runtime-1eTnPFmA.js} +3 -3
- package/dist/chunks/{generate.runtime-D9OC1RXu.js.map → generate.runtime-1eTnPFmA.js.map} +1 -1
- package/dist/chunks/{generate.runtime-27KTIg_o.js → generate.runtime-B-H2F-sH.js} +48 -53
- package/dist/chunks/generate.runtime-B-H2F-sH.js.map +1 -0
- package/dist/chunks/{generate.runtime-DhSH1o8H.js → generate.runtime-B4mQEW54.js} +3 -3
- package/dist/chunks/{generate.runtime-DhSH1o8H.js.map → generate.runtime-B4mQEW54.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BFX_8erf.js → generate.runtime-B4rG6gSK.js} +10 -9
- package/dist/chunks/{generate.runtime-BFX_8erf.js.map → generate.runtime-B4rG6gSK.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DuAYqKxl.js → generate.runtime-B9nVU5iO.js} +2 -2
- package/dist/chunks/{generate.runtime-DuAYqKxl.js.map → generate.runtime-B9nVU5iO.js.map} +1 -1
- package/dist/chunks/{generate.runtime-D6l6uLiY.js → generate.runtime-BC1GJUXE.js} +2 -2
- package/dist/chunks/{generate.runtime-D6l6uLiY.js.map → generate.runtime-BC1GJUXE.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Duw_JI_b.js → generate.runtime-BJwSyslL.js} +2 -2
- package/dist/chunks/{generate.runtime-Duw_JI_b.js.map → generate.runtime-BJwSyslL.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CBVcsole.js → generate.runtime-Bda2_WK7.js} +2 -2
- package/dist/chunks/{generate.runtime-CBVcsole.js.map → generate.runtime-Bda2_WK7.js.map} +1 -1
- package/dist/chunks/{generate.runtime-sjFAWbZc.js → generate.runtime-BkQPchHe.js} +7 -7
- package/dist/chunks/{generate.runtime-sjFAWbZc.js.map → generate.runtime-BkQPchHe.js.map} +1 -1
- package/dist/chunks/{generate.runtime-bsuqrKOm.js → generate.runtime-BuQASx9Y.js} +2 -2
- package/dist/chunks/{generate.runtime-bsuqrKOm.js.map → generate.runtime-BuQASx9Y.js.map} +1 -1
- package/dist/chunks/{generate.runtime-D77ueFKY.js → generate.runtime-BvHK8IN-.js} +118 -134
- package/dist/chunks/generate.runtime-BvHK8IN-.js.map +1 -0
- package/dist/chunks/{generate.runtime-BXNBWGYr.js → generate.runtime-C1HlZnLC.js} +2 -2
- package/dist/chunks/{generate.runtime-BXNBWGYr.js.map → generate.runtime-C1HlZnLC.js.map} +1 -1
- package/dist/chunks/{generate.runtime-wiWdXXPi.js → generate.runtime-C62ChKGg.js} +6 -6
- package/dist/chunks/{generate.runtime-wiWdXXPi.js.map → generate.runtime-C62ChKGg.js.map} +1 -1
- package/dist/chunks/{generate.runtime-B8-ORwxT.js → generate.runtime-CIOi-XSm.js} +6 -6
- package/dist/chunks/{generate.runtime-B8-ORwxT.js.map → generate.runtime-CIOi-XSm.js.map} +1 -1
- package/dist/chunks/{generate.runtime-nXjFqHyb.js → generate.runtime-CQ_U4YTJ.js} +4 -4
- package/dist/chunks/{generate.runtime-nXjFqHyb.js.map → generate.runtime-CQ_U4YTJ.js.map} +1 -1
- package/dist/chunks/{generate.runtime-D0lI3Gt8.js → generate.runtime-CZA46Ghe.js} +5 -5
- package/dist/chunks/{generate.runtime-D0lI3Gt8.js.map → generate.runtime-CZA46Ghe.js.map} +1 -1
- package/dist/chunks/{generate.runtime-XT_JQlTk.js → generate.runtime-Cd742Yqf.js} +2 -2
- package/dist/chunks/{generate.runtime-XT_JQlTk.js.map → generate.runtime-Cd742Yqf.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BlEy2fFF.js → generate.runtime-CfCDLJ6Y.js} +3 -3
- package/dist/chunks/{generate.runtime-BlEy2fFF.js.map → generate.runtime-CfCDLJ6Y.js.map} +1 -1
- package/dist/chunks/{generate.runtime-RTGpwxcS.js → generate.runtime-CjLath7N.js} +6 -12
- package/dist/chunks/generate.runtime-CjLath7N.js.map +1 -0
- package/dist/chunks/{generate.runtime-UtkANHk1.js → generate.runtime-CnNtG_x5.js} +3 -3
- package/dist/chunks/{generate.runtime-UtkANHk1.js.map → generate.runtime-CnNtG_x5.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CCaCaXNu.js → generate.runtime-D8G8cwCr.js} +2 -2
- package/dist/chunks/{generate.runtime-CCaCaXNu.js.map → generate.runtime-D8G8cwCr.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Cm75waRD.js → generate.runtime-DBQvnQmR.js} +2 -2
- package/dist/chunks/{generate.runtime-Cm75waRD.js.map → generate.runtime-DBQvnQmR.js.map} +1 -1
- package/dist/chunks/{generate.runtime-PDnSxiek.js → generate.runtime-DE-vPcn4.js} +6 -6
- package/dist/chunks/{generate.runtime-PDnSxiek.js.map → generate.runtime-DE-vPcn4.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DLoYscQO.js → generate.runtime-DFSsgOmB.js} +3 -3
- package/dist/chunks/{generate.runtime-DLoYscQO.js.map → generate.runtime-DFSsgOmB.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DiEiFoxR.js → generate.runtime-DNjyaFml.js} +3 -3
- package/dist/chunks/{generate.runtime-DiEiFoxR.js.map → generate.runtime-DNjyaFml.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CuvdtjKc.js → generate.runtime-DQI69jkX.js} +2 -2
- package/dist/chunks/{generate.runtime-CuvdtjKc.js.map → generate.runtime-DQI69jkX.js.map} +1 -1
- package/dist/chunks/{generate.runtime-B7XOa9_A.js → generate.runtime-DQUZRJH8.js} +3 -3
- package/dist/chunks/{generate.runtime-B7XOa9_A.js.map → generate.runtime-DQUZRJH8.js.map} +1 -1
- package/dist/chunks/generate.runtime-DR8z6DyZ.js +169 -0
- package/dist/chunks/generate.runtime-DR8z6DyZ.js.map +1 -0
- package/dist/chunks/{generate.runtime-XpYi9SlM.js → generate.runtime-Diix70x4.js} +3 -3
- package/dist/chunks/{generate.runtime-XpYi9SlM.js.map → generate.runtime-Diix70x4.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BU-4sjyu.js → generate.runtime-Doumu0TL.js} +110 -113
- package/dist/chunks/generate.runtime-Doumu0TL.js.map +1 -0
- package/dist/chunks/{generate.runtime-TQmspB4Z.js → generate.runtime-Dtum580c.js} +27 -34
- package/dist/chunks/generate.runtime-Dtum580c.js.map +1 -0
- package/dist/chunks/{generate.runtime-BROXlbeJ.js → generate.runtime-GmsldrGj.js} +3 -3
- package/dist/chunks/{generate.runtime-BROXlbeJ.js.map → generate.runtime-GmsldrGj.js.map} +1 -1
- package/dist/chunks/{generate.runtime-ZgLxGWuy.js → generate.runtime-lP4eoera.js} +3 -3
- package/dist/chunks/{generate.runtime-ZgLxGWuy.js.map → generate.runtime-lP4eoera.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Dm7IEo2h.js → generate.runtime-liAz2TOE.js} +5 -5
- package/dist/chunks/{generate.runtime-Dm7IEo2h.js.map → generate.runtime-liAz2TOE.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DxyQqNpu.js → generate.runtime-rxzMCECc.js} +5 -11
- package/dist/chunks/generate.runtime-rxzMCECc.js.map +1 -0
- package/dist/chunks/{generate.runtime-VMTLHWLk.js → generate.runtime-ufoTIUXA.js} +55 -60
- package/dist/chunks/generate.runtime-ufoTIUXA.js.map +1 -0
- package/dist/chunks/gitignore-2XpeEFmr.js +139 -0
- package/dist/chunks/gitignore-2XpeEFmr.js.map +1 -0
- package/dist/chunks/{i18n-mnzzcYhz.js → i18n-CxT1kz8Y.js} +3 -3
- package/dist/chunks/{i18n-mnzzcYhz.js.map → i18n-CxT1kz8Y.js.map} +1 -1
- package/dist/chunks/{modify-file-CgJIza72.js → modify-file-BX9-aZD1.js} +3 -3
- package/dist/chunks/{modify-file-CgJIza72.js.map → modify-file-BX9-aZD1.js.map} +1 -1
- package/dist/chunks/pocketbase-Dq9UdK_j.js +232 -0
- package/dist/chunks/pocketbase-Dq9UdK_j.js.map +1 -0
- package/dist/chunks/{providers-CDUFaOeQ.js → providers-2UgxXRJW.js} +3 -3
- package/dist/chunks/{providers-CDUFaOeQ.js.map → providers-2UgxXRJW.js.map} +1 -1
- package/dist/chunks/{providers-tjlFH5di.js → providers-DrK_hjSr.js} +2 -2
- package/dist/chunks/{providers-tjlFH5di.js.map → providers-DrK_hjSr.js.map} +1 -1
- package/dist/chunks/route-BDhlro0V.js +162 -0
- package/dist/chunks/route-BDhlro0V.js.map +1 -0
- package/dist/chunks/schema-2frI_BS2.js +116 -0
- package/dist/chunks/schema-2frI_BS2.js.map +1 -0
- package/dist/chunks/{shared-BjTRQ5QH.js → shared-BOFCKWJs.js} +3 -3
- package/dist/chunks/{shared-BjTRQ5QH.js.map → shared-BOFCKWJs.js.map} +1 -1
- package/dist/chunks/shared-DJ4KvhTb.js +1182 -0
- package/dist/chunks/shared-DJ4KvhTb.js.map +1 -0
- package/dist/chunks/{site-C8Wcg6LT.js → site-qASrdyUt.js} +3 -3
- package/dist/chunks/{site-C8Wcg6LT.js.map → site-qASrdyUt.js.map} +1 -1
- package/dist/chunks/{table-core-RvMjoXpT.js → table-core-s2xjYgRD.js} +3 -3
- package/dist/chunks/{table-core-RvMjoXpT.js.map → table-core-s2xjYgRD.js.map} +1 -1
- package/dist/chunks/test-setup-jqVMmL83.js +103 -0
- package/dist/chunks/test-setup-jqVMmL83.js.map +1 -0
- package/dist/chunks/{translations-CiJnl574.js → translations-B5hX0Qq-.js} +5 -2
- package/dist/chunks/{translations-CiJnl574.js.map → translations-B5hX0Qq-.js.map} +1 -1
- package/dist/chunks/{ui-CE-8llQS.js → ui-DZuwcswv.js} +3 -3
- package/dist/chunks/{ui-CE-8llQS.js.map → ui-DZuwcswv.js.map} +1 -1
- package/dist/chunks/{util-ILWdjRAd.js → util-mXrQ89nG.js} +8 -2
- package/dist/chunks/util-mXrQ89nG.js.map +1 -0
- package/dist/chunks/{whatsapp-DT10x76l.js → whatsapp-BytvTPlS.js} +2 -2
- package/dist/chunks/{whatsapp-DT10x76l.js.map → whatsapp-BytvTPlS.js.map} +1 -1
- package/dist/chunks/write-result-BhfLWAXf.js +539 -0
- package/dist/chunks/write-result-BhfLWAXf.js.map +1 -0
- package/dist/index.d.ts +81 -0
- package/dist/index.js +2388 -3276
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/dist/chunks/_page-44USwLXO.js +0 -5
- package/dist/chunks/auth-pages-BW3_yluN.js +0 -285
- package/dist/chunks/auth-pages-BW3_yluN.js.map +0 -1
- package/dist/chunks/collections-B_-NTtLW.js.map +0 -1
- package/dist/chunks/constants-CTp-0HKk.js.map +0 -1
- package/dist/chunks/generate-JkvSNTy-.js.map +0 -1
- package/dist/chunks/generate.runtime-27KTIg_o.js.map +0 -1
- package/dist/chunks/generate.runtime-BU-4sjyu.js.map +0 -1
- package/dist/chunks/generate.runtime-D77ueFKY.js.map +0 -1
- package/dist/chunks/generate.runtime-Dn0_y2iV.js +0 -161
- package/dist/chunks/generate.runtime-Dn0_y2iV.js.map +0 -1
- package/dist/chunks/generate.runtime-DxyQqNpu.js.map +0 -1
- package/dist/chunks/generate.runtime-RTGpwxcS.js.map +0 -1
- package/dist/chunks/generate.runtime-TQmspB4Z.js.map +0 -1
- package/dist/chunks/generate.runtime-VMTLHWLk.js.map +0 -1
- package/dist/chunks/pocketbase-S8lUt0nI.js +0 -219
- package/dist/chunks/pocketbase-S8lUt0nI.js.map +0 -1
- package/dist/chunks/test-setup-CpjhQSl-.js +0 -176
- package/dist/chunks/test-setup-CpjhQSl-.js.map +0 -1
- package/dist/chunks/util-ILWdjRAd.js.map +0 -1
- package/dist/chunks/write-result-BguSfKV-.js +0 -499
- package/dist/chunks/write-result-BguSfKV-.js.map +0 -1
|
@@ -1,167 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { k as e, w as t } from "./constants-DbpctM1D.js";
|
|
2
2
|
import { t as n } from "./ui-D5xgIDR_.js";
|
|
3
|
-
import { c as r, i, r as a } from "./providers-
|
|
4
|
-
import { n as o, r as s } from "./util-
|
|
5
|
-
import { t as c } from "./
|
|
6
|
-
// node_modules/change-case/dist/index.js
|
|
7
|
-
var l = /([\p{Ll}\d])(\p{Lu})/gu, u = /(\p{Lu})([\p{Lu}][\p{Ll}])/gu, d = /(\d)\p{Ll}|(\p{L})\d/u, f = /[^\p{L}\d]+/giu, p = "$1\0$2", m = "";
|
|
8
|
-
function h(e) {
|
|
9
|
-
let t = e.trim();
|
|
10
|
-
t = t.replace(l, p).replace(u, p), t = t.replace(f, "\0");
|
|
11
|
-
let n = 0, r = t.length;
|
|
12
|
-
for (; t.charAt(n) === "\0";) n++;
|
|
13
|
-
if (n === r) return [];
|
|
14
|
-
for (; t.charAt(r - 1) === "\0";) r--;
|
|
15
|
-
return t.slice(n, r).split(/\0/g);
|
|
16
|
-
}
|
|
17
|
-
function g(e) {
|
|
18
|
-
let t = h(e);
|
|
19
|
-
for (let e = 0; e < t.length; e++) {
|
|
20
|
-
let n = t[e], r = d.exec(n);
|
|
21
|
-
if (r) {
|
|
22
|
-
let i = r.index + (r[1] ?? r[2]).length;
|
|
23
|
-
t.splice(e, 1, n.slice(0, i), n.slice(i));
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return t;
|
|
27
|
-
}
|
|
28
|
-
function _(e, t) {
|
|
29
|
-
let [n, r, i] = E(e, t);
|
|
30
|
-
return n + r.map(S(t?.locale)).join(t?.delimiter ?? " ") + i;
|
|
31
|
-
}
|
|
32
|
-
function v(e, t) {
|
|
33
|
-
let [n, r, i] = E(e, t), a = S(t?.locale), o = C(t?.locale), s = t?.mergeAmbiguousCharacters ? w(a, o) : T(a, o);
|
|
34
|
-
return n + r.map((e, t) => t === 0 ? a(e) : s(e, t)).join(t?.delimiter ?? "") + i;
|
|
35
|
-
}
|
|
36
|
-
function y(e, t) {
|
|
37
|
-
let [n, r, i] = E(e, t), a = S(t?.locale), o = C(t?.locale), s = t?.mergeAmbiguousCharacters ? w(a, o) : T(a, o);
|
|
38
|
-
return n + r.map(s).join(t?.delimiter ?? "") + i;
|
|
39
|
-
}
|
|
40
|
-
function b(e, t) {
|
|
41
|
-
let [n, r, i] = E(e, t), a = S(t?.locale), o = C(t?.locale);
|
|
42
|
-
return n + r.map(w(a, o)).join(t?.delimiter ?? " ") + i;
|
|
43
|
-
}
|
|
44
|
-
function x(e, t) {
|
|
45
|
-
return _(e, {
|
|
46
|
-
delimiter: "-",
|
|
47
|
-
...t
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
function ee(e, t) {
|
|
51
|
-
return _(e, {
|
|
52
|
-
delimiter: "_",
|
|
53
|
-
...t
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
function S(e) {
|
|
57
|
-
return e === !1 ? (e) => e.toLowerCase() : (t) => t.toLocaleLowerCase(e);
|
|
58
|
-
}
|
|
59
|
-
function C(e) {
|
|
60
|
-
return e === !1 ? (e) => e.toUpperCase() : (t) => t.toLocaleUpperCase(e);
|
|
61
|
-
}
|
|
62
|
-
function w(e, t) {
|
|
63
|
-
return (n) => `${t(n[0])}${e(n.slice(1))}`;
|
|
64
|
-
}
|
|
65
|
-
function T(e, t) {
|
|
66
|
-
return (n, r) => {
|
|
67
|
-
let i = n[0];
|
|
68
|
-
return (r > 0 && i >= "0" && i <= "9" ? "_" + i : t(i)) + e(n.slice(1));
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
function E(e, t = {}) {
|
|
72
|
-
let n = t.split ?? (t.separateNumbers ? g : h), r = t.prefixCharacters ?? m, i = t.suffixCharacters ?? m, a = 0, o = e.length;
|
|
73
|
-
for (; a < e.length;) {
|
|
74
|
-
let t = e.charAt(a);
|
|
75
|
-
if (!r.includes(t)) break;
|
|
76
|
-
a++;
|
|
77
|
-
}
|
|
78
|
-
for (; o > a;) {
|
|
79
|
-
let t = o - 1, n = e.charAt(t);
|
|
80
|
-
if (!i.includes(n)) break;
|
|
81
|
-
o = t;
|
|
82
|
-
}
|
|
83
|
-
return [
|
|
84
|
-
e.slice(0, a),
|
|
85
|
-
n(e.slice(a, o)),
|
|
86
|
-
e.slice(o)
|
|
87
|
-
];
|
|
88
|
-
}
|
|
89
|
-
// src/parse/route.ts
|
|
90
|
-
var D = "src/routes", O = /\[([^\]]+)\]/g, k = /^[a-zA-Z0-9_\-[\]()]+$/;
|
|
91
|
-
function A({ features: e, routeGroups: t }) {
|
|
92
|
-
let n = t ?? {
|
|
93
|
-
public: "(public)",
|
|
94
|
-
app: "(app)"
|
|
95
|
-
};
|
|
96
|
-
return e.auth ? n.app ?? n.public : n.public;
|
|
97
|
-
}
|
|
98
|
-
function j(e, t) {
|
|
99
|
-
return [
|
|
100
|
-
D,
|
|
101
|
-
e,
|
|
102
|
-
t
|
|
103
|
-
].filter(Boolean).join("/");
|
|
104
|
-
}
|
|
105
|
-
function M(e, t) {
|
|
106
|
-
return x(t === "scaffold" ? e.pluralDisplayName : e.displayName);
|
|
107
|
-
}
|
|
108
|
-
function N(e) {
|
|
109
|
-
return `/${(e.startsWith(`${D}/`) ? e.slice(11) : e).split("/").filter((e) => !(e.startsWith("(") && e.endsWith(")"))).join("/")}`;
|
|
110
|
-
}
|
|
111
|
-
function P(e) {
|
|
112
|
-
let t = [];
|
|
113
|
-
for (let n of e.matchAll(O)) t.push(n[1]);
|
|
114
|
-
return t;
|
|
115
|
-
}
|
|
116
|
-
function F(e) {
|
|
117
|
-
if (e.startsWith("/")) throw new c(`Route must not start with "/". Got: "${e}"`);
|
|
118
|
-
if (e.startsWith(`${D}/`) || e === D) throw new c(`Route must not start with "${D}/" — paths are rooted there automatically. Got: "${e}"`);
|
|
119
|
-
let t = e.split("/");
|
|
120
|
-
for (let n of t) {
|
|
121
|
-
if (n.length === 0) throw new c(`Route must not contain empty segments. Got: "${e}"`);
|
|
122
|
-
if (n === "." || n === "..") throw new c(`Route must not contain "." or ".." segments. Got: "${e}"`);
|
|
123
|
-
if (n.startsWith("_")) throw new c(`Route segments must not start with underscore. Got: "${n}"`);
|
|
124
|
-
if (!k.test(n)) throw new c(`Route segment "${n}" contains invalid characters. Allowed: letters, digits, underscore, dash, brackets, parentheses.`);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
function I(e) {
|
|
128
|
-
return e.split("/").some((e) => e.startsWith("(") && e.endsWith(")"));
|
|
129
|
-
}
|
|
130
|
-
function L(e, t, n, r) {
|
|
131
|
-
if (e === void 0 || e === "") {
|
|
132
|
-
let e = M(t, r), i = j(A(n), e);
|
|
133
|
-
return {
|
|
134
|
-
fileBase: i,
|
|
135
|
-
urlBase: N(i),
|
|
136
|
-
dynamicParams: P(i)
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
F(e);
|
|
140
|
-
let i = j(I(e) ? null : A(n), e);
|
|
141
|
-
return {
|
|
142
|
-
fileBase: i,
|
|
143
|
-
urlBase: N(i),
|
|
144
|
-
dynamicParams: P(i)
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
function R(e) {
|
|
148
|
-
return {
|
|
149
|
-
list: e.fileBase,
|
|
150
|
-
new: `${e.fileBase}/new`,
|
|
151
|
-
show: `${e.fileBase}/[id]`,
|
|
152
|
-
edit: `${e.fileBase}/[id]/edit`
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
function z(e) {
|
|
156
|
-
return {
|
|
157
|
-
list: e.urlBase,
|
|
158
|
-
new: `${e.urlBase}/new`,
|
|
159
|
-
show: `${e.urlBase}/[id]`,
|
|
160
|
-
edit: `${e.urlBase}/[id]/edit`
|
|
161
|
-
};
|
|
162
|
-
}
|
|
3
|
+
import { c as r, i, r as a } from "./providers-DrK_hjSr.js";
|
|
4
|
+
import { n as o, r as s } from "./util-mXrQ89nG.js";
|
|
5
|
+
import { t as c } from "./route-BDhlro0V.js";
|
|
163
6
|
// src/patterns/enable/ai/creates/src/routes/(public)/ai/+page.svelte?raw
|
|
164
|
-
var B = "<script lang=\"ts\">\n import { Chat } from '@ai-sdk/svelte';\n import { Button } from '#lib/components/ui/button/index.js';\n import { Textarea } from '#lib/components/ui/textarea/index.js';\n\n // Posts to /api/chat (src/routes/api/chat/+server.ts) and streams the reply\n // into `chat.messages`. This page is a demo, and it is yours to delete.\n const chat = new Chat({});\n\n let input = $state('');\n const busy = $derived(chat.status === 'submitted' || chat.status === 'streaming');\n\n function send(event: SubmitEvent) {\n event.preventDefault();\n const text = input.trim();\n if (!text || busy) return;\n chat.sendMessage({ text });\n input = '';\n }\n\n // Enter sends; Shift+Enter starts a new line.\n function onkeydown(event: KeyboardEvent & { currentTarget: HTMLTextAreaElement }) {\n if (event.key === 'Enter' && !event.shiftKey && !event.isComposing) {\n event.preventDefault();\n event.currentTarget.form?.requestSubmit();\n }\n }\n<\/script>\n\n<div class=\"mx-auto flex w-full max-w-3xl flex-1 flex-col gap-6 px-4 py-10\">\n <div>\n <h1 class=\"text-2xl font-semibold\">AI chat</h1>\n <p class=\"text-muted-foreground text-sm\">\n Replies stream from <code>src/routes/api/chat/+server.ts</code>. Pick the model in\n <code>src/lib/server/ai.ts</code>.\n </p>\n </div>\n\n <div class=\"flex flex-1 flex-col gap-4\" aria-live=\"polite\">\n {#each chat.messages as message (message.id)}\n <div\n class={message.role === 'user'\n ? 'bg-primary text-primary-foreground ml-auto max-w-[80%] rounded-lg px-4 py-2'\n : 'max-w-[80%]'}\n >\n {#each message.parts as part, index (index)}\n {#if part.type === 'text'}\n <p class=\"whitespace-pre-wrap\">{part.text}</p>\n {/if}\n {/each}\n </div>\n {:else}\n <p class=\"text-muted-foreground\">Ask anything to start the conversation.</p>\n {/each}\n\n {#if chat.status === 'submitted'}\n <p class=\"text-muted-foreground text-sm\">Thinking…</p>\n {/if}\n\n {#if chat.error}\n <div\n role=\"alert\"\n class=\"border-destructive text-destructive flex items-center justify-between gap-4 rounded-md border px-4 py-2 text-sm\"\n >\n <span>{chat.error.message}</span>\n <Button variant=\"outline\" size=\"sm\" onclick={() => chat.regenerate()}>Retry</Button>\n </div>\n {/if}\n </div>\n\n <form onsubmit={send} class=\"bg-background sticky bottom-0 flex items-end gap-2 py-2\">\n <Textarea\n bind:value={input}\n {onkeydown}\n rows={1}\n placeholder=\"Send a message\"\n aria-label=\"Message\"\n class=\"max-h-40 min-h-10 resize-none\"\n />\n {#if busy}\n <Button type=\"button\" variant=\"outline\" onclick={() => chat.stop()}>Stop</Button>\n {:else}\n <Button type=\"submit\" disabled={!input.trim()}>Send</Button>\n {/if}\n </form>\n</div>\n", V = "import { dev } from '$app/env';\nimport {\n convertToModelMessages,\n createUIMessageStreamResponse,\n safeValidateUIMessages,\n streamText,\n toUIMessageStream\n} from 'ai';\nimport { API_KEY, languageModel } from '#lib/server/ai.js';\nimport type { RequestHandler } from './$types';\n\n// Sent ahead of every conversation: give the assistant its role here.\nconst INSTRUCTIONS = 'You are a helpful assistant. Keep answers short unless asked for detail.';\n\n/**\n * Where `new Chat()` from @ai-sdk/svelte posts by default: the conversation so\n * far comes in, the model's reply streams back. Anyone who can reach the site\n * can call it, and every reply is billed to your API key, so put it behind\n * sign-in or a rate limit before you deploy.\n *\n * Errors are plain text, which `Chat` shows as `chat.error.message`.\n */\nexport const POST: RequestHandler = async ({ request }) => {\n const body = await request.json().catch(() => null);\n const messages = await safeValidateUIMessages({ messages: body?.messages });\n if (!messages.success) {\n return new Response('Expected a JSON body with a messages array.', { status: 400 });\n }\n\n const model = languageModel();\n if (!model) {\n return new Response(`Set ${API_KEY} in .env to start chatting.`, { status: 503 });\n }\n\n const result = streamText({\n model,\n instructions: INSTRUCTIONS,\n messages: await convertToModelMessages(messages.data)\n });\n\n return createUIMessageStreamResponse({\n stream: toUIMessageStream({\n stream: result.stream,\n // Provider errors (a bad key, an unknown model id) reach the chat in\n // dev only; in production they stay in the server log.\n onError: (error) =>\n dev && error instanceof Error ? error.message : 'The model could not answer.'\n })\n });\n};\n", H = "import { describe, it, expect } from 'vitest';\nimport type { Match } from '@velastack/kit';\nimport type { RouteId } from './$types';\n\n// None of these requests reach the model, so they pass without an API key and\n// cost nothing.\ndescribe('POST /api/chat', () => {\n it('should return 400 if the body is not JSON', async (context) => {\n const response = await context.request\n .post('/api/chat' satisfies Match<RouteId>)\n .set('Content-Type', 'application/json')\n .send('not json');\n\n expect(response.status).toBe(400);\n });\n\n it('should return 400 if messages are missing', async (context) => {\n const response = await context.request.post('/api/chat' satisfies Match<RouteId>).send({});\n\n expect(response.status).toBe(400);\n });\n\n it('should return 400 if messages are malformed', async (context) => {\n const response = await context.request\n .post('/api/chat' satisfies Match<RouteId>)\n .send({ messages: [{ role: 'user', content: 'Hello' }] });\n\n expect(response.status).toBe(400);\n });\n});\n", U = "import { dev } from '$app/env';\nimport {\n convertToModelMessages,\n createUIMessageStreamResponse,\n safeValidateUIMessages,\n streamText,\n toUIMessageStream\n} from 'ai';\nimport { API_KEY, languageModel } from '#lib/server/ai.js';\nimport type { RequestHandler } from './$types';\n\n// Sent ahead of every conversation: give the assistant its role here.\nconst INSTRUCTIONS = 'You are a helpful assistant. Keep answers short unless asked for detail.';\n\n/**\n * Where `new Chat()` from @ai-sdk/svelte posts by default: the conversation so\n * far comes in, the model's reply streams back. Every reply is billed to your\n * API key, so only signed-in users get one.\n *\n * Errors are plain text, which `Chat` shows as `chat.error.message`.\n */\nexport const POST: RequestHandler = async ({ request, locals }) => {\n if (!locals.pb.authStore.isValid) {\n return new Response('Sign in to chat.', { status: 401 });\n }\n\n const body = await request.json().catch(() => null);\n const messages = await safeValidateUIMessages({ messages: body?.messages });\n if (!messages.success) {\n return new Response('Expected a JSON body with a messages array.', { status: 400 });\n }\n\n const model = languageModel();\n if (!model) {\n return new Response(`Set ${API_KEY} in .env to start chatting.`, { status: 503 });\n }\n\n const result = streamText({\n model,\n instructions: INSTRUCTIONS,\n messages: await convertToModelMessages(messages.data)\n });\n\n return createUIMessageStreamResponse({\n stream: toUIMessageStream({\n stream: result.stream,\n // Provider errors (a bad key, an unknown model id) reach the chat in\n // dev only; in production they stay in the server log.\n onError: (error) =>\n dev && error instanceof Error ? error.message : 'The model could not answer.'\n })\n });\n};\n", W = "import { describe, it, expect } from 'vitest';\nimport type { Match } from '@velastack/kit';\nimport type { RouteId } from './$types';\n\n// None of these requests reach the model, so they pass without an API key and\n// cost nothing.\ndescribe('POST /api/chat', () => {\n it('should return 401 when signed out', async (context) => {\n const response = await context.request.post('/api/chat' satisfies Match<RouteId>).send({\n messages: [{ id: '1', role: 'user', parts: [{ type: 'text', text: 'Hello' }] }]\n });\n\n expect(response.status).toBe(401);\n });\n\n it('should return 400 if the body is not JSON', async (context) => {\n await context.agent.authenticateUser();\n\n const response = await context.agent\n .post('/api/chat' satisfies Match<RouteId>)\n .set('Content-Type', 'application/json')\n .send('not json');\n\n expect(response.status).toBe(400);\n });\n\n it('should return 400 if messages are missing', async (context) => {\n await context.agent.authenticateUser();\n\n const response = await context.agent.post('/api/chat' satisfies Match<RouteId>).send({});\n\n expect(response.status).toBe(400);\n });\n\n it('should return 400 if messages are malformed', async (context) => {\n await context.agent.authenticateUser();\n\n const response = await context.agent\n .post('/api/chat' satisfies Match<RouteId>)\n .send({ messages: [{ role: 'user', content: 'Hello' }] });\n\n expect(response.status).toBe(400);\n });\n});\n", G = "<script lang=\"ts\">\n import { Chat } from '@ai-sdk/svelte';\n\n // Posts to /api/chat (src/routes/api/chat/+server.ts) and streams the reply\n // into `chat.messages`. This page is a demo, and it is yours to delete.\n const chat = new Chat({});\n\n let input = $state('');\n const busy = $derived(chat.status === 'submitted' || chat.status === 'streaming');\n\n function send(event: SubmitEvent) {\n event.preventDefault();\n const text = input.trim();\n if (!text || busy) return;\n chat.sendMessage({ text });\n input = '';\n }\n\n // Enter sends; Shift+Enter starts a new line.\n function onkeydown(event: KeyboardEvent & { currentTarget: HTMLTextAreaElement }) {\n if (event.key === 'Enter' && !event.shiftKey && !event.isComposing) {\n event.preventDefault();\n event.currentTarget.form?.requestSubmit();\n }\n }\n<\/script>\n\n<h1>AI chat</h1>\n<p>\n Replies stream from <code>src/routes/api/chat/+server.ts</code>. Pick the model in\n <code>src/lib/server/ai.ts</code>.\n</p>\n\n<section aria-live=\"polite\">\n {#each chat.messages as message (message.id)}\n <article data-role={message.role}>\n <strong>{message.role === 'user' ? 'You' : 'Assistant'}</strong>\n {#each message.parts as part, index (index)}\n {#if part.type === 'text'}\n <p style=\"white-space: pre-wrap\">{part.text}</p>\n {/if}\n {/each}\n </article>\n {:else}\n <p>Ask anything to start the conversation.</p>\n {/each}\n\n {#if chat.status === 'submitted'}\n <p>Thinking…</p>\n {/if}\n\n {#if chat.error}\n <p role=\"alert\">\n {chat.error.message}\n <button type=\"button\" onclick={() => chat.regenerate()}>Retry</button>\n </p>\n {/if}\n</section>\n\n<form onsubmit={send}>\n <textarea bind:value={input} {onkeydown} rows=\"2\" placeholder=\"Send a message\" aria-label=\"Message\"\n ></textarea>\n {#if busy}\n <button type=\"button\" onclick={() => chat.stop()}>Stop</button>\n {:else}\n <button type=\"submit\" disabled={!input.trim()}>Send</button>\n {/if}\n</form>\n", K = "import { createAnthropic } from '@ai-sdk/anthropic';\nimport { ANTHROPIC_API_KEY } from '$app/env/private';\n\n/** The `.env` key holding the Anthropic API key, named in the endpoint's 503. */\nexport const API_KEY = 'ANTHROPIC_API_KEY';\n\n/**\n * The model the AI routes talk to, or `undefined` while ANTHROPIC_API_KEY is\n * blank. The key is read when the server starts, so a new value in `.env`\n * takes a restart, not a code change. Any id from\n * https://docs.claude.com/en/docs/about-claude/models works in place of this\n * one.\n */\nexport function languageModel() {\n const apiKey = ANTHROPIC_API_KEY;\n return apiKey ? createAnthropic({ apiKey })('claude-sonnet-5') : undefined;\n}\n", q = "import { createGateway } from 'ai';\nimport { AI_GATEWAY_API_KEY } from '$app/env/private';\n\n/** The `.env` key holding the Vercel AI Gateway API key, named in the endpoint's 503. */\nexport const API_KEY = 'AI_GATEWAY_API_KEY';\n\n/**\n * The model the AI routes talk to, or `undefined` while AI_GATEWAY_API_KEY is\n * blank. The key is read when the server starts, so a new value in `.env`\n * takes a restart, not a code change. The gateway routes `creator/model` ids\n * to their provider; any id from https://vercel.com/ai-gateway/models works in\n * place of this one.\n */\nexport function languageModel() {\n const apiKey = AI_GATEWAY_API_KEY;\n return apiKey ? createGateway({ apiKey })('anthropic/claude-sonnet-5') : undefined;\n}\n", J = "import { createOpenAI } from '@ai-sdk/openai';\nimport { OPENAI_API_KEY } from '$app/env/private';\n\n/** The `.env` key holding the OpenAI API key, named in the endpoint's 503. */\nexport const API_KEY = 'OPENAI_API_KEY';\n\n/**\n * The model the AI routes talk to, or `undefined` while OPENAI_API_KEY is\n * blank. The key is read when the server starts, so a new value in `.env`\n * takes a restart, not a code change. Any id from\n * https://platform.openai.com/docs/models works in place of this one.\n */\nexport function languageModel() {\n const apiKey = OPENAI_API_KEY;\n return apiKey ? createOpenAI({ apiKey })('gpt-5.5') : undefined;\n}\n", Y = [
|
|
7
|
+
var l = "<script lang=\"ts\">\n import { Chat } from '@ai-sdk/svelte';\n import { Button } from '#lib/components/ui/button/index.js';\n import { Textarea } from '#lib/components/ui/textarea/index.js';\n\n // Posts to /api/chat (src/routes/api/chat/+server.ts) and streams the reply\n // into `chat.messages`. This page is a demo, and it is yours to delete.\n const chat = new Chat({});\n\n let input = $state('');\n const busy = $derived(chat.status === 'submitted' || chat.status === 'streaming');\n\n function send(event: SubmitEvent) {\n event.preventDefault();\n const text = input.trim();\n if (!text || busy) return;\n chat.sendMessage({ text });\n input = '';\n }\n\n // Enter sends; Shift+Enter starts a new line.\n function onkeydown(event: KeyboardEvent & { currentTarget: HTMLTextAreaElement }) {\n if (event.key === 'Enter' && !event.shiftKey && !event.isComposing) {\n event.preventDefault();\n event.currentTarget.form?.requestSubmit();\n }\n }\n<\/script>\n\n<div class=\"mx-auto flex w-full max-w-3xl flex-1 flex-col gap-6 px-4 py-10\">\n <div>\n <h1 class=\"text-2xl font-semibold\">AI chat</h1>\n <p class=\"text-muted-foreground text-sm\">\n Replies stream from <code>src/routes/api/chat/+server.ts</code>. Pick the model in\n <code>src/lib/server/ai.ts</code>.\n </p>\n </div>\n\n <div class=\"flex flex-1 flex-col gap-4\" aria-live=\"polite\">\n {#each chat.messages as message (message.id)}\n <div\n class={message.role === 'user'\n ? 'bg-primary text-primary-foreground ml-auto max-w-[80%] rounded-lg px-4 py-2'\n : 'max-w-[80%]'}\n >\n {#each message.parts as part, index (index)}\n {#if part.type === 'text'}\n <p class=\"whitespace-pre-wrap\">{part.text}</p>\n {/if}\n {/each}\n </div>\n {:else}\n <p class=\"text-muted-foreground\">Ask anything to start the conversation.</p>\n {/each}\n\n {#if chat.status === 'submitted'}\n <p class=\"text-muted-foreground text-sm\">Thinking…</p>\n {/if}\n\n {#if chat.error}\n <div\n role=\"alert\"\n class=\"border-destructive text-destructive flex items-center justify-between gap-4 rounded-md border px-4 py-2 text-sm\"\n >\n <span>{chat.error.message}</span>\n <Button variant=\"outline\" size=\"sm\" onclick={() => chat.regenerate()}>Retry</Button>\n </div>\n {/if}\n </div>\n\n <form onsubmit={send} class=\"bg-background sticky bottom-0 flex items-end gap-2 py-2\">\n <Textarea\n bind:value={input}\n {onkeydown}\n rows={1}\n placeholder=\"Send a message\"\n aria-label=\"Message\"\n class=\"max-h-40 min-h-10 resize-none\"\n />\n {#if busy}\n <Button type=\"button\" variant=\"outline\" onclick={() => chat.stop()}>Stop</Button>\n {:else}\n <Button type=\"submit\" disabled={!input.trim()}>Send</Button>\n {/if}\n </form>\n</div>\n", u = "import { dev } from '$app/env';\nimport {\n convertToModelMessages,\n createUIMessageStreamResponse,\n safeValidateUIMessages,\n streamText,\n toUIMessageStream\n} from 'ai';\nimport { API_KEY, languageModel } from '#lib/server/ai.js';\nimport type { RequestHandler } from './$types';\n\n// Sent ahead of every conversation: give the assistant its role here.\nconst INSTRUCTIONS = 'You are a helpful assistant. Keep answers short unless asked for detail.';\n\n/**\n * Where `new Chat()` from @ai-sdk/svelte posts by default: the conversation so\n * far comes in, the model's reply streams back. Anyone who can reach the site\n * can call it, and every reply is billed to your API key, so put it behind\n * sign-in or a rate limit before you deploy.\n *\n * Errors are plain text, which `Chat` shows as `chat.error.message`.\n */\nexport const POST: RequestHandler = async ({ request }) => {\n const body = await request.json().catch(() => null);\n const messages = await safeValidateUIMessages({ messages: body?.messages });\n if (!messages.success) {\n return new Response('Expected a JSON body with a messages array.', { status: 400 });\n }\n\n const model = languageModel();\n if (!model) {\n return new Response(`Set ${API_KEY} in .env to start chatting.`, { status: 503 });\n }\n\n const result = streamText({\n model,\n instructions: INSTRUCTIONS,\n messages: await convertToModelMessages(messages.data)\n });\n\n return createUIMessageStreamResponse({\n stream: toUIMessageStream({\n stream: result.stream,\n // Provider errors (a bad key, an unknown model id) reach the chat in\n // dev only; in production they stay in the server log.\n onError: (error) =>\n dev && error instanceof Error ? error.message : 'The model could not answer.'\n })\n });\n};\n", d = "import { describe, it, expect } from 'vitest';\nimport type { Match } from '@velastack/kit';\nimport type { RouteId } from './$types';\n\n// None of these requests reach the model, so they pass without an API key and\n// cost nothing.\ndescribe('POST /api/chat', () => {\n it('should return 400 if the body is not JSON', async (context) => {\n const response = await context.request\n .post('/api/chat' satisfies Match<RouteId>)\n .set('Content-Type', 'application/json')\n .send('not json');\n\n expect(response.status).toBe(400);\n });\n\n it('should return 400 if messages are missing', async (context) => {\n const response = await context.request.post('/api/chat' satisfies Match<RouteId>).send({});\n\n expect(response.status).toBe(400);\n });\n\n it('should return 400 if messages are malformed', async (context) => {\n const response = await context.request\n .post('/api/chat' satisfies Match<RouteId>)\n .send({ messages: [{ role: 'user', content: 'Hello' }] });\n\n expect(response.status).toBe(400);\n });\n});\n", f = "import { dev } from '$app/env';\nimport {\n convertToModelMessages,\n createUIMessageStreamResponse,\n safeValidateUIMessages,\n streamText,\n toUIMessageStream\n} from 'ai';\nimport { API_KEY, languageModel } from '#lib/server/ai.js';\nimport type { RequestHandler } from './$types';\n\n// Sent ahead of every conversation: give the assistant its role here.\nconst INSTRUCTIONS = 'You are a helpful assistant. Keep answers short unless asked for detail.';\n\n/**\n * Where `new Chat()` from @ai-sdk/svelte posts by default: the conversation so\n * far comes in, the model's reply streams back. Every reply is billed to your\n * API key, so only signed-in users get one.\n *\n * Errors are plain text, which `Chat` shows as `chat.error.message`.\n */\nexport const POST: RequestHandler = async ({ request, locals }) => {\n if (!locals.pb.authStore.isValid) {\n return new Response('Sign in to chat.', { status: 401 });\n }\n\n const body = await request.json().catch(() => null);\n const messages = await safeValidateUIMessages({ messages: body?.messages });\n if (!messages.success) {\n return new Response('Expected a JSON body with a messages array.', { status: 400 });\n }\n\n const model = languageModel();\n if (!model) {\n return new Response(`Set ${API_KEY} in .env to start chatting.`, { status: 503 });\n }\n\n const result = streamText({\n model,\n instructions: INSTRUCTIONS,\n messages: await convertToModelMessages(messages.data)\n });\n\n return createUIMessageStreamResponse({\n stream: toUIMessageStream({\n stream: result.stream,\n // Provider errors (a bad key, an unknown model id) reach the chat in\n // dev only; in production they stay in the server log.\n onError: (error) =>\n dev && error instanceof Error ? error.message : 'The model could not answer.'\n })\n });\n};\n", p = "import { describe, it, expect } from 'vitest';\nimport type { Match } from '@velastack/kit';\nimport type { RouteId } from './$types';\n\n// None of these requests reach the model, so they pass without an API key and\n// cost nothing.\ndescribe('POST /api/chat', () => {\n it('should return 401 when signed out', async (context) => {\n const response = await context.request.post('/api/chat' satisfies Match<RouteId>).send({\n messages: [{ id: '1', role: 'user', parts: [{ type: 'text', text: 'Hello' }] }]\n });\n\n expect(response.status).toBe(401);\n });\n\n it('should return 400 if the body is not JSON', async (context) => {\n await context.agent.authenticateUser();\n\n const response = await context.agent\n .post('/api/chat' satisfies Match<RouteId>)\n .set('Content-Type', 'application/json')\n .send('not json');\n\n expect(response.status).toBe(400);\n });\n\n it('should return 400 if messages are missing', async (context) => {\n await context.agent.authenticateUser();\n\n const response = await context.agent.post('/api/chat' satisfies Match<RouteId>).send({});\n\n expect(response.status).toBe(400);\n });\n\n it('should return 400 if messages are malformed', async (context) => {\n await context.agent.authenticateUser();\n\n const response = await context.agent\n .post('/api/chat' satisfies Match<RouteId>)\n .send({ messages: [{ role: 'user', content: 'Hello' }] });\n\n expect(response.status).toBe(400);\n });\n});\n", m = "<script lang=\"ts\">\n import { Chat } from '@ai-sdk/svelte';\n\n // Posts to /api/chat (src/routes/api/chat/+server.ts) and streams the reply\n // into `chat.messages`. This page is a demo, and it is yours to delete.\n const chat = new Chat({});\n\n let input = $state('');\n const busy = $derived(chat.status === 'submitted' || chat.status === 'streaming');\n\n function send(event: SubmitEvent) {\n event.preventDefault();\n const text = input.trim();\n if (!text || busy) return;\n chat.sendMessage({ text });\n input = '';\n }\n\n // Enter sends; Shift+Enter starts a new line.\n function onkeydown(event: KeyboardEvent & { currentTarget: HTMLTextAreaElement }) {\n if (event.key === 'Enter' && !event.shiftKey && !event.isComposing) {\n event.preventDefault();\n event.currentTarget.form?.requestSubmit();\n }\n }\n<\/script>\n\n<h1>AI chat</h1>\n<p>\n Replies stream from <code>src/routes/api/chat/+server.ts</code>. Pick the model in\n <code>src/lib/server/ai.ts</code>.\n</p>\n\n<section aria-live=\"polite\">\n {#each chat.messages as message (message.id)}\n <article data-role={message.role}>\n <strong>{message.role === 'user' ? 'You' : 'Assistant'}</strong>\n {#each message.parts as part, index (index)}\n {#if part.type === 'text'}\n <p style=\"white-space: pre-wrap\">{part.text}</p>\n {/if}\n {/each}\n </article>\n {:else}\n <p>Ask anything to start the conversation.</p>\n {/each}\n\n {#if chat.status === 'submitted'}\n <p>Thinking…</p>\n {/if}\n\n {#if chat.error}\n <p role=\"alert\">\n {chat.error.message}\n <button type=\"button\" onclick={() => chat.regenerate()}>Retry</button>\n </p>\n {/if}\n</section>\n\n<form onsubmit={send}>\n <textarea bind:value={input} {onkeydown} rows=\"2\" placeholder=\"Send a message\" aria-label=\"Message\"\n ></textarea>\n {#if busy}\n <button type=\"button\" onclick={() => chat.stop()}>Stop</button>\n {:else}\n <button type=\"submit\" disabled={!input.trim()}>Send</button>\n {/if}\n</form>\n", h = "import { createAnthropic } from '@ai-sdk/anthropic';\nimport { ANTHROPIC_API_KEY } from '$app/env/private';\n\n/** The `.env` key holding the Anthropic API key, named in the endpoint's 503. */\nexport const API_KEY = 'ANTHROPIC_API_KEY';\n\n/**\n * The model the AI routes talk to, or `undefined` while ANTHROPIC_API_KEY is\n * blank. The key is read when the server starts, so a new value in `.env`\n * takes a restart, not a code change. Any id from\n * https://docs.claude.com/en/docs/about-claude/models works in place of this\n * one.\n */\nexport function languageModel() {\n const apiKey = ANTHROPIC_API_KEY;\n return apiKey ? createAnthropic({ apiKey })('claude-sonnet-5') : undefined;\n}\n", g = "import { createGateway } from 'ai';\nimport { AI_GATEWAY_API_KEY } from '$app/env/private';\n\n/** The `.env` key holding the Vercel AI Gateway API key, named in the endpoint's 503. */\nexport const API_KEY = 'AI_GATEWAY_API_KEY';\n\n/**\n * The model the AI routes talk to, or `undefined` while AI_GATEWAY_API_KEY is\n * blank. The key is read when the server starts, so a new value in `.env`\n * takes a restart, not a code change. The gateway routes `creator/model` ids\n * to their provider; any id from https://vercel.com/ai-gateway/models works in\n * place of this one.\n */\nexport function languageModel() {\n const apiKey = AI_GATEWAY_API_KEY;\n return apiKey ? createGateway({ apiKey })('anthropic/claude-sonnet-5') : undefined;\n}\n", _ = "import { createOpenAI } from '@ai-sdk/openai';\nimport { OPENAI_API_KEY } from '$app/env/private';\n\n/** The `.env` key holding the OpenAI API key, named in the endpoint's 503. */\nexport const API_KEY = 'OPENAI_API_KEY';\n\n/**\n * The model the AI routes talk to, or `undefined` while OPENAI_API_KEY is\n * blank. The key is read when the server starts, so a new value in `.env`\n * takes a restart, not a code change. Any id from\n * https://platform.openai.com/docs/models works in place of this one.\n */\nexport function languageModel() {\n const apiKey = OPENAI_API_KEY;\n return apiKey ? createOpenAI({ apiKey })('gpt-5.5') : undefined;\n}\n", v = [
|
|
165
8
|
{
|
|
166
9
|
id: "gateway",
|
|
167
10
|
label: "Vercel AI Gateway",
|
|
@@ -191,41 +34,41 @@ var B = "<script lang=\"ts\">\n import { Chat } from '@ai-sdk/svelte';\n import
|
|
|
191
34
|
secret: !0
|
|
192
35
|
}]
|
|
193
36
|
}
|
|
194
|
-
],
|
|
37
|
+
], y = [e("ai"), e("@ai-sdk/svelte")], b = {
|
|
195
38
|
openai: [e("@ai-sdk/openai")],
|
|
196
39
|
anthropic: [e("@ai-sdk/anthropic")]
|
|
197
|
-
},
|
|
40
|
+
}, x = {
|
|
198
41
|
slug: "enable-ai",
|
|
199
|
-
providers:
|
|
200
|
-
},
|
|
201
|
-
function
|
|
42
|
+
providers: v
|
|
43
|
+
}, S = "src/routes/(public)/ai/";
|
|
44
|
+
function C(e) {
|
|
202
45
|
return [
|
|
203
46
|
"src/routes",
|
|
204
|
-
|
|
47
|
+
c(e),
|
|
205
48
|
"ai"
|
|
206
49
|
].filter(Boolean).join("/");
|
|
207
50
|
}
|
|
208
|
-
function
|
|
51
|
+
function w(e, t = {}) {
|
|
209
52
|
return i(e, `AI SDK (${e.label})`, t);
|
|
210
53
|
}
|
|
211
|
-
var
|
|
212
|
-
"./creates/src/routes/(public)/ai/+page.svelte":
|
|
213
|
-
"./creates/src/routes/api/chat/+server.ts":
|
|
214
|
-
"./creates/src/routes/api/chat/server.test.ts":
|
|
215
|
-
}),
|
|
216
|
-
"./creates-app-mode/src/routes/api/chat/+server.ts":
|
|
217
|
-
"./creates-app-mode/src/routes/api/chat/server.test.ts":
|
|
218
|
-
}),
|
|
219
|
-
"./providers/anthropic/src/lib/server/ai.ts":
|
|
220
|
-
"./providers/gateway/src/lib/server/ai.ts":
|
|
221
|
-
"./providers/openai/src/lib/server/ai.ts":
|
|
54
|
+
var T = /* #__PURE__ */ Object.assign({
|
|
55
|
+
"./creates/src/routes/(public)/ai/+page.svelte": l,
|
|
56
|
+
"./creates/src/routes/api/chat/+server.ts": u,
|
|
57
|
+
"./creates/src/routes/api/chat/server.test.ts": d
|
|
58
|
+
}), E = /* #__PURE__ */ Object.assign({
|
|
59
|
+
"./creates-app-mode/src/routes/api/chat/+server.ts": f,
|
|
60
|
+
"./creates-app-mode/src/routes/api/chat/server.test.ts": p
|
|
61
|
+
}), D = /* #__PURE__ */ Object.assign({ "./variants/plain/src/routes/(public)/ai/+page.svelte": m }), O = /* #__PURE__ */ Object.assign({
|
|
62
|
+
"./providers/anthropic/src/lib/server/ai.ts": h,
|
|
63
|
+
"./providers/gateway/src/lib/server/ai.ts": g,
|
|
64
|
+
"./providers/openai/src/lib/server/ai.ts": _
|
|
222
65
|
});
|
|
223
|
-
async function
|
|
224
|
-
let i = r(
|
|
66
|
+
async function k(e) {
|
|
67
|
+
let i = r(x, e), c = n(e), l = e.input.serverTests ?? !0, u = {}, d = (e) => {
|
|
225
68
|
for (let t of e) u[t.path] = t;
|
|
226
69
|
};
|
|
227
|
-
d(o(
|
|
228
|
-
let f = `${
|
|
70
|
+
d(o(T, "./creates/", D, c === "plain" ? "plain" : void 0)), e.features.auth && d(Object.values(s(E, "./creates-app-mode/"))), d(a(O, i.id));
|
|
71
|
+
let f = `${C(e)}/`;
|
|
229
72
|
return {
|
|
230
73
|
creates: Object.values(u).filter((e) => l || !e.path.endsWith("server.test.ts")).map((e) => e.path.startsWith("src/routes/(public)/ai/") ? {
|
|
231
74
|
...e,
|
|
@@ -235,15 +78,15 @@ async function se(e) {
|
|
|
235
78
|
deletes: [],
|
|
236
79
|
components: c === "plain" ? [] : ["button", "textarea"],
|
|
237
80
|
packages: [
|
|
238
|
-
...
|
|
81
|
+
...y,
|
|
239
82
|
t,
|
|
240
|
-
...
|
|
83
|
+
...b[i.id] ?? []
|
|
241
84
|
],
|
|
242
85
|
collections: [],
|
|
243
86
|
collectionPatches: [],
|
|
244
87
|
collectionDrops: []
|
|
245
88
|
};
|
|
246
89
|
}
|
|
247
|
-
export {
|
|
90
|
+
export { b as a, k as c, h as d, p as f, l as g, u as h, v as i, _ as l, d as m, x as n, C as o, f as p, y as r, w as s, S as t, g as u };
|
|
248
91
|
|
|
249
|
-
//# sourceMappingURL=generate-
|
|
92
|
+
//# sourceMappingURL=generate-DZ9kT3iC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-DZ9kT3iC.js","names":["__import_glob__0_0_","__import_glob__0_1_","__import_glob__0_2_","__import_glob__1_0_","__import_glob__1_1_","__import_glob__2_0_","__import_glob__3_0_","__import_glob__3_1_","__import_glob__3_2_","spec","ZOD","resolveUi","resolveProvider","providerCreates","composeCreates","filesFromGlob","defaultGroup","_page_default$1","_server_default$1","server_test_default$1","_server_default","server_test_default","_page_default","ai_default$2","ai_default$1","ai_default","PROVIDERS","PACKAGES","PROVIDER_PACKAGES","META","DEMO_DIR","demoDir","options","envEditsFor","providerEnvEdits","provider","supplied","createsRaw","createsAppModeRaw","variantsRaw","providersRaw","generate","ui","serverTests","files","add","file","list","target","a","b"],"sources":["../../src/patterns/enable/ai/generate.ts"],"sourcesContent":["import type {\n File,\n Options,\n Package,\n Provider,\n Result,\n} from \"../../../core/types\";\nimport type { EnvEdit } from \"../../../runtime/env\";\nimport { ZOD } from \"../../../core/constants\";\nimport { resolveUi } from \"../../../core/field/ui\";\nimport {\n providerCreates,\n providerEnvEdits,\n resolveProvider,\n} from \"../../../core/providers\";\nimport { composeCreates, filesFromGlob } from \"../../../core/util\";\nimport { defaultGroup } from \"../../../parse/route\";\nimport { spec } from \"../../../core/versions\";\n\n/**\n * The providers in prompt order. Each one's `env` key is what the CLI asks\n * for (without echo), what `generate.runtime.ts` writes to `.env` and\n * declares in `src/env.ts`; the generated `src/lib/server/ai.ts` imports it\n * from `$app/env/private`, and `/api/chat` answers 503 while it is blank.\n */\nexport const PROVIDERS: Provider[] = [\n {\n id: \"gateway\",\n label: \"Vercel AI Gateway\",\n env: [\n {\n key: \"AI_GATEWAY_API_KEY\",\n label: \"Vercel AI Gateway API key\",\n secret: true,\n },\n ],\n },\n {\n id: \"openai\",\n label: \"OpenAI\",\n env: [\n {\n key: \"OPENAI_API_KEY\",\n label: \"OpenAI API key\",\n placeholder: \"sk-...\",\n secret: true,\n },\n ],\n },\n {\n id: \"anthropic\",\n label: \"Anthropic\",\n env: [\n {\n key: \"ANTHROPIC_API_KEY\",\n label: \"Anthropic API key\",\n placeholder: \"sk-ant-...\",\n secret: true,\n },\n ],\n },\n];\n\n/**\n * `ai` carries the gateway provider itself; the others are a package each.\n * zod, a peer of `ai`, is installed alongside but is not listed here: it is\n * not the pattern's to uninstall.\n */\nexport const PACKAGES: Package[] = [spec(\"ai\"), spec(\"@ai-sdk/svelte\")];\nexport const PROVIDER_PACKAGES: Record<string, Package[]> = {\n openai: [spec(\"@ai-sdk/openai\")],\n anthropic: [spec(\"@ai-sdk/anthropic\")],\n};\n\n/** What `resolveProvider` needs; `index.ts` spreads the rest of the metadata. */\nexport const META = { slug: \"enable-ai\", providers: PROVIDERS };\n\n/** Where the demo page is stored; `generate` moves it to the project's default group. */\nexport const DEMO_DIR = \"src/routes/(public)/ai/\";\n\n/**\n * The demo page's directory: `(public)/ai`, `(app)/ai` behind sign-in when\n * auth is on, or `ai` straight under `src/routes` in a project without groups.\n */\nexport function demoDir(\n options: Pick<Options, \"features\" | \"routeGroups\">,\n): string {\n return [\"src/routes\", defaultGroup(options), \"ai\"].filter(Boolean).join(\"/\");\n}\n\n/** The `.env` lines for a provider, under a `# AI SDK (<Label>)` heading. */\nexport function envEditsFor(\n provider: Provider,\n supplied: Record<string, string> = {},\n): EnvEdit[] {\n return providerEnvEdits(provider, `AI SDK (${provider.label})`, supplied);\n}\n\nconst createsRaw = import.meta.glob<string>(\"./creates/**\", {\n query: \"?raw\",\n import: \"default\",\n eager: true,\n});\n\n// With auth, the endpoint answers only signed-in users: every reply is\n// billed to the project's API key.\nconst createsAppModeRaw = import.meta.glob<string>(\"./creates-app-mode/**\", {\n query: \"?raw\",\n import: \"default\",\n eager: true,\n});\n\n// A plain project gets the demo page in native elements, at the same path.\nconst variantsRaw = import.meta.glob<string>(\"./variants/**\", {\n query: \"?raw\",\n import: \"default\",\n eager: true,\n});\n\nconst providersRaw = import.meta.glob<string>(\"./providers/**\", {\n query: \"?raw\",\n import: \"default\",\n eager: true,\n});\n\nexport async function generate(options: Options) {\n const provider = resolveProvider(META, options);\n const ui = resolveUi(options);\n const serverTests = options.input.serverTests ?? true;\n\n const files: Record<string, File> = {};\n const add = (list: File[]) => {\n for (const file of list) files[file.path] = file;\n };\n add(\n composeCreates(\n createsRaw,\n \"./creates/\",\n variantsRaw,\n ui === \"plain\" ? \"plain\" : undefined,\n ),\n );\n if (options.features.auth) {\n add(Object.values(filesFromGlob(createsAppModeRaw, \"./creates-app-mode/\")));\n }\n add(providerCreates(providersRaw, provider.id));\n\n const target = `${demoDir(options)}/`;\n const creates = Object.values(files)\n .filter((file) => serverTests || !file.path.endsWith(\"server.test.ts\"))\n .map((file) =>\n file.path.startsWith(DEMO_DIR)\n ? { ...file, path: target + file.path.slice(DEMO_DIR.length) }\n : file,\n )\n .sort((a, b) => a.path.localeCompare(b.path));\n\n return {\n creates,\n modifies: [],\n deletes: [],\n components: ui === \"plain\" ? [] : [\"button\", \"textarea\"],\n // vela's templates already have zod; a project vela did not create may not.\n packages: [...PACKAGES, ZOD, ...(PROVIDER_PACKAGES[provider.id] ?? [])],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;A,kwZAyBa0B,IAAwB;CACnC;EACE,IAAI;EACJ,OAAO;EACP,KAAK,CACH;GACE,KAAK;GACL,OAAO;GACP,QAAQ;EACV,CACF;CACF;CACA;EACE,IAAI;EACJ,OAAO;EACP,KAAK,CACH;GACE,KAAK;GACL,OAAO;GACP,aAAa;GACb,QAAQ;EACV,CACF;CACF;CACA;EACE,IAAI;EACJ,OAAO;EACP,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AqB,CAAC,CAAC,GAE5EO,EAAIhC,EAAgB2B,GAAcL,EAAS,EAAE,CAAC;CAE9C,IAAMa,IAAS,GAAGjB,EAAQC,CAAO,EAAE;CAUnC,OAAO;EACL,SAVc,OAAO,OAAOY,CAAK,CAAC,CACjC,QAAQ,MAASD,KAAe,CAACG,EAAK,KAAK,SAAS,gBAAgB,CAAC,CAAC,CACtE,KAAK,MACJA,EAAK,KAAK,WAAA,yBAAmB,IACzB;GAAE,GAAGA;GAAM,MAAME,IAASF,EAAK,KAAK,MAAM,EAAe;EAAE,IAC3DA,CACN,CAAC,CACA,MAAM,GAAG,MAAMG,EAAE,KAAK,cAAcC,EAAE,IAAI,CAG3C;EACA,UAAU,CAAC;EACX,SAAS,CAAC;EACV,YAAYR,MAAO,UAAU,CAAC,IAAI,CAAC,UAAU,UAAU;EAEvD,UAAU;GAAC,GAAGf;GAAUjB;GAAK,GAAIkB,EAAkBO,EAAS,OAAO,CAAC;EAAE;EACtE,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as e } from "./logger-t1HxmpG2.js";
|
|
2
2
|
import { t } from "./ui-D5xgIDR_.js";
|
|
3
|
-
import { r as n } from "./modify-file-
|
|
3
|
+
import { r as n } from "./modify-file-BX9-aZD1.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
6
|
import { a as l, c as u, p as ee, r as te, u as ne } from "./app-d-ts-h33RrYIv.js";
|
|
@@ -8,7 +8,7 @@ import { t as d } from "./dedent-CCUOcPFW.js";
|
|
|
8
8
|
import { t as f } from "./compose-handle-Da7m6lV_.js";
|
|
9
9
|
import { t as p } from "./svelte-file-DfplF3BU.js";
|
|
10
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-
|
|
11
|
+
import { a as ie, i as ae, n as oe, t as h } from "./translations-B5hX0Qq-.js";
|
|
12
12
|
import { r as g, t as _ } from "./wuchale-config-CNXoq4rc.js";
|
|
13
13
|
import v from "node:fs";
|
|
14
14
|
import y from "node:path";
|
|
@@ -461,4 +461,4 @@ async function ye(a) {
|
|
|
461
461
|
}
|
|
462
462
|
export { ye as generate, ve as withLibraryTexts };
|
|
463
463
|
|
|
464
|
-
//# sourceMappingURL=generate.runtime-
|
|
464
|
+
//# sourceMappingURL=generate.runtime-1eTnPFmA.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.runtime-D9OC1RXu.js","names":["FAILURE_HINT","NOT_FOUND_HINT","FAILURE_HINT","FAILURE_HINT","FAILURE_HINT","NOT_FOUND_HINT","NOT_FOUND_HINT","getLogger","modifyOutcomeToFile","probeFirstExisting","VITE_CONFIG_CANDIDATES","withInMemoryScript","ensureNamedImport","formatLikeSource","ensureImports","modifyLayoutServerLocale","ensureRootLayoutI18n","modifyPrettierignore","modifyAppDts","modifyPackageImportsI18n","dedent","addHandle","SvelteFile","APP_LAYOUT_PATH","modifyAppLayoutLanguageSelect","withTranslations","translateCatalog","entriesInProject","AUTH_TRANSLATIONS","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","HANDLE_BODY","types","indent","text","line","IMPORTS","STARTUP","UNTYPED_HANDLE","FAILURE_HINT$3","HOOKS_SERVER_SNIPPET","ensureNamespaceImport","moduleSpecifier","ns","modifyHooksServerI18n","hooksServerPath","original","composed","handleStmt","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","options","modifies","pushResult","imports","appDtsPath","layoutServerPath","rootLayoutCandidates","resolveUi","rootLayoutPath","p","appLayoutPath","prettierignorePath","catalog","shipped","content","translated"],"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\n/**\n * The handle's body: which language the request is in (the URL on a public\n * page, the visitor's preference elsewhere: see `src/lib/locale.ts`), and the\n * cookie that remembers the last public page opened.\n */\nconst HANDLE_BODY = (types: { locale: string; html: string }) => dedent`\n const urlLocale = deLocalizeDefault(event.url.pathname, locales)[1] as Locale | null;\n const localizedUrl = hasLocalizedUrl(event.url.pathname);\n const cookie${types.locale} = event.cookies.get(LOCALE_COOKIE);\n const locale = pickLocale({\n urlLocale,\n localizedUrl,\n cookie,\n acceptLanguage: event.request.headers.get('accept-language'),\n locales,\n defaultLocale\n });\n event.locals.locale = locale;\n\n const response${types.html ? \": Response\" : \"\"} = await runWithLocale(locale, () =>\n resolve(event, {\n transformPageChunk: ({ html }${types.html}) => html.replace('%sveltekit.lang%', locale)\n })\n );\n\n // Opening a public page sets the language of the pages that have no\n // language in their URL. Only when the page itself is opened: a preload\n // (hovering a link) must not change it.\n if (localizedUrl && cookie !== locale && event.request.method === 'GET' && !event.isDataRequest) {\n try {\n response.headers.append('set-cookie', localeCookie(locale));\n } catch {\n // a response with immutable headers (a proxied file): nothing to remember\n }\n }\n return response;\n`;\n\nconst indent = (text: string) =>\n text\n .split(\"\\n\")\n .map((line) => (line ? ` ${line}` : line))\n .join(\"\\n\");\n\nconst IMPORTS = dedent`\n import { runWithLocale, loadLocales } from 'wuchale/load-utils/server';\n import { deLocalizeDefault } from 'wuchale/url';\n import { locales, type Locale } from '#locales/data.js';\n import { defaultLocale, hasLocalizedUrl } from '#lib/url.js';\n import { LOCALE_COOKIE, localeCookie, pickLocale } from '#lib/locale.js';\n import * as main from '#locales/main.loader.server.svelte.js';\n import * as js from '#locales/js.loader.server.js';\n`;\n\nconst STARTUP = dedent`\n loadLocales(main.key, main.loadCount, main.loadCatalog, locales);\n loadLocales(js.key, js.loadCount, js.loadCatalog, locales);\n`;\n\n/** The handle as it is added to a file whose own handle is typed loosely. */\nconst UNTYPED_HANDLE = [\n `const ${I18N_HANDLE} = async ({ event, resolve }: any) => {`,\n indent(\n HANDLE_BODY({ locale: \": string | undefined\", html: \": { html: string }\" }),\n ),\n \"};\",\n].join(\"\\n\");\n\nconst FAILURE_HINT = [\n \"Wrap your exported handle with the wuchale i18n handler:\",\n \"\",\n \"import { sequence } from '@sveltejs/kit/hooks';\",\n IMPORTS,\n \"\",\n STARTUP,\n \"\",\n UNTYPED_HANDLE,\n \"\",\n \"export const handle = sequence(handleWuchale, /* your existing handle */);\",\n].join(\"\\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 = [\n \"import type { Handle } from '@sveltejs/kit/hooks';\",\n IMPORTS,\n \"\",\n STARTUP,\n \"\",\n `const ${I18N_HANDLE}: Handle = async ({ event, resolve }) => {`,\n indent(HANDLE_BODY({ locale: \"\", html: \"\" })),\n \"};\",\n \"\",\n `export const handle = ${I18N_HANDLE};`,\n].join(\"\\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, \"wuchale/url\", \"deLocalizeDefault\");\n ensureNamedImport(sourceFile, \"#locales/data.js\", \"locales\");\n ensureNamedImport(sourceFile, \"#locales/data.js\", \"Locale\", true);\n ensureNamedImport(sourceFile, \"#lib/url.js\", \"defaultLocale\");\n ensureNamedImport(sourceFile, \"#lib/url.js\", \"hasLocalizedUrl\");\n ensureNamedImport(sourceFile, \"#lib/locale.js\", \"LOCALE_COOKIE\");\n ensureNamedImport(sourceFile, \"#lib/locale.js\", \"localeCookie\");\n ensureNamedImport(sourceFile, \"#lib/locale.js\", \"pickLocale\");\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 // Above the handle and its JSDoc, so `handleWuchale` is declared before\n // the handle reads it.\n sourceFile.insertText(\n handleStmt.getStart(true),\n `${STARTUP}\\n\\n${UNTYPED_HANDLE}\\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 { modifyPrettierignore } from \"./modifies/prettierignore\";\nimport { ensureRootLayoutI18n } from \"./modifies/+layout\";\nimport { modifyRootLayoutLanguageSelect } from \"./modifies/root-layout.svelte\";\nimport { modifyLayoutServerLocale } from \"./modifies/layout.server\";\nimport { modifyAppDts } from \"./modifies/app-d-ts\";\nimport {\n APP_LAYOUT_PATH,\n modifyAppLayoutLanguageSelect,\n} from \"./modifies/app-layout.svelte\";\nimport { welcomePageCatalog } from \"./welcome-catalog\";\nimport {\n entriesInProject,\n translateCatalog,\n withTranslations,\n} from \"../../../runtime/wuchale-catalog\";\nimport { AUTH_TRANSLATIONS } from \"../auth/translations\";\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(\"Declaring the request's language in app.d.ts\");\n const appDtsPath = path.join(options.root, \"src\", \"app.d.ts\");\n pushResult(modifyOutcomeToFile(appDtsPath, modifyAppDts(appDtsPath)));\n\n logger.info(\"Modifying root +layout.server.ts\");\n const layoutServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n layoutServerPath,\n modifyLayoutServerLocale(layoutServerPath),\n ),\n );\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 // Signed-in pages have one URL for every language; the select is how a\n // visitor changes it there.\n const appLayoutPath = path.join(options.root, APP_LAYOUT_PATH);\n if (fs.existsSync(appLayoutPath)) {\n logger.info(\"Adding the language select to the signed-in layout\");\n pushResult(\n modifyOutcomeToFile(\n appLayoutPath,\n modifyAppLayoutLanguageSelect(appLayoutPath),\n ),\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 logger.info(\"Updating .prettierignore\");\n const prettierignorePath = path.join(options.root, \".prettierignore\");\n pushResult(\n modifyOutcomeToFile(\n prettierignorePath,\n modifyPrettierignore(prettierignorePath),\n ),\n );\n\n const catalog = welcomePageCatalog(options.root, ui);\n if (catalog) logger.info(\"Translating the welcome page into Spanish\");\n\n // Spanish for the pages other patterns wrote before this one: without it\n // they stay in English, and nothing says so.\n const shipped = entriesInProject(options.root, AUTH_TRANSLATIONS);\n if (shipped.length > 0)\n logger.info(\"Translating the sign-in pages into Spanish\");\n const creates: File[] = [];\n if (catalog) {\n const content = withTranslations(catalog.content, shipped).source;\n creates.push({ ...catalog, content });\n } else {\n const translated = translateCatalog(options.root, shipped);\n if (translated.create) creates.push(translated.create);\n pushResult(translated.modify);\n }\n\n return {\n creates,\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAKA,IAAMA,IAAe,oLAUfC,IAAiB;AAWvB,SAAgBkC,GAAiB,GAAuC;CACtE,IAAI,CAACJ,EAAG,WAAWK,CAAc,GAC/B,OAAO;EAAE,QAAQ;EAAa,SAASnC;CAAe;CAOxD,IAAMoC,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,CAC/C,MAAM,MAAOC,EAAG,cAAc,CAAC,CAAC,QAAQ,MAAM,cAE/B,CAAA,EAAkB,aAAa,CAAC,GAAG,IAC/CC,IACJH,GAAW,QAAQ,MAAMC,EAAW,0BAC/BD,IACD;CAEN,IAAI,CAACG,GACH,IAAS;MACJ;EACL,IAAMC,IAAcD,EAAU,YAAY,SAAS;EACnD,IAAI,CAACC,GAKH,AAJAD,EAAU,sBAAsB;GAC9B,MAAM;GACN,aAAa;EACf,CAAC,GACD,IAAU;OACL,IAAIC,EAAY,QAAQ,MAAMH,EAAW,oBAC9C,IAAS;OACJ;GACL,IAAMI,IACJD,EACA,eAAe;GAEjB,IAAI,CAACC,GAIH,AAHAD,EAAuD,eACrD,aACF,GACA,IAAU;QACL,IAAIC,EAAY,QAAQ,MAAMJ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AQnB,EAAQ,KAAKmB,EAAW,MAAM,GACrDb,EAAWa,EAAW,MAAM;CAC9B;CAEA,OAAO;EACL;EACA;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
|
|
1
|
+
{"version":3,"file":"generate.runtime-1eTnPFmA.js","names":["FAILURE_HINT","NOT_FOUND_HINT","FAILURE_HINT","FAILURE_HINT","FAILURE_HINT","NOT_FOUND_HINT","NOT_FOUND_HINT","getLogger","modifyOutcomeToFile","probeFirstExisting","VITE_CONFIG_CANDIDATES","withInMemoryScript","ensureNamedImport","formatLikeSource","ensureImports","modifyLayoutServerLocale","ensureRootLayoutI18n","modifyPrettierignore","modifyAppDts","modifyPackageImportsI18n","dedent","addHandle","SvelteFile","APP_LAYOUT_PATH","modifyAppLayoutLanguageSelect","withTranslations","translateCatalog","entriesInProject","AUTH_TRANSLATIONS","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","HANDLE_BODY","types","indent","text","line","IMPORTS","STARTUP","UNTYPED_HANDLE","FAILURE_HINT$3","HOOKS_SERVER_SNIPPET","ensureNamespaceImport","moduleSpecifier","ns","modifyHooksServerI18n","hooksServerPath","original","composed","handleStmt","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","options","modifies","pushResult","imports","appDtsPath","layoutServerPath","rootLayoutCandidates","resolveUi","rootLayoutPath","p","appLayoutPath","prettierignorePath","catalog","shipped","content","translated"],"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\n/**\n * The handle's body: which language the request is in (the URL on a public\n * page, the visitor's preference elsewhere: see `src/lib/locale.ts`), and the\n * cookie that remembers the last public page opened.\n */\nconst HANDLE_BODY = (types: { locale: string; html: string }) => dedent`\n const urlLocale = deLocalizeDefault(event.url.pathname, locales)[1] as Locale | null;\n const localizedUrl = hasLocalizedUrl(event.url.pathname);\n const cookie${types.locale} = event.cookies.get(LOCALE_COOKIE);\n const locale = pickLocale({\n urlLocale,\n localizedUrl,\n cookie,\n acceptLanguage: event.request.headers.get('accept-language'),\n locales,\n defaultLocale\n });\n event.locals.locale = locale;\n\n const response${types.html ? \": Response\" : \"\"} = await runWithLocale(locale, () =>\n resolve(event, {\n transformPageChunk: ({ html }${types.html}) => html.replace('%sveltekit.lang%', locale)\n })\n );\n\n // Opening a public page sets the language of the pages that have no\n // language in their URL. Only when the page itself is opened: a preload\n // (hovering a link) must not change it.\n if (localizedUrl && cookie !== locale && event.request.method === 'GET' && !event.isDataRequest) {\n try {\n response.headers.append('set-cookie', localeCookie(locale));\n } catch {\n // a response with immutable headers (a proxied file): nothing to remember\n }\n }\n return response;\n`;\n\nconst indent = (text: string) =>\n text\n .split(\"\\n\")\n .map((line) => (line ? ` ${line}` : line))\n .join(\"\\n\");\n\nconst IMPORTS = dedent`\n import { runWithLocale, loadLocales } from 'wuchale/load-utils/server';\n import { deLocalizeDefault } from 'wuchale/url';\n import { locales, type Locale } from '#locales/data.js';\n import { defaultLocale, hasLocalizedUrl } from '#lib/url.js';\n import { LOCALE_COOKIE, localeCookie, pickLocale } from '#lib/locale.js';\n import * as main from '#locales/main.loader.server.svelte.js';\n import * as js from '#locales/js.loader.server.js';\n`;\n\nconst STARTUP = dedent`\n loadLocales(main.key, main.loadCount, main.loadCatalog, locales);\n loadLocales(js.key, js.loadCount, js.loadCatalog, locales);\n`;\n\n/** The handle as it is added to a file whose own handle is typed loosely. */\nconst UNTYPED_HANDLE = [\n `const ${I18N_HANDLE} = async ({ event, resolve }: any) => {`,\n indent(\n HANDLE_BODY({ locale: \": string | undefined\", html: \": { html: string }\" }),\n ),\n \"};\",\n].join(\"\\n\");\n\nconst FAILURE_HINT = [\n \"Wrap your exported handle with the wuchale i18n handler:\",\n \"\",\n \"import { sequence } from '@sveltejs/kit/hooks';\",\n IMPORTS,\n \"\",\n STARTUP,\n \"\",\n UNTYPED_HANDLE,\n \"\",\n \"export const handle = sequence(handleWuchale, /* your existing handle */);\",\n].join(\"\\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 = [\n \"import type { Handle } from '@sveltejs/kit/hooks';\",\n IMPORTS,\n \"\",\n STARTUP,\n \"\",\n `const ${I18N_HANDLE}: Handle = async ({ event, resolve }) => {`,\n indent(HANDLE_BODY({ locale: \"\", html: \"\" })),\n \"};\",\n \"\",\n `export const handle = ${I18N_HANDLE};`,\n].join(\"\\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, \"wuchale/url\", \"deLocalizeDefault\");\n ensureNamedImport(sourceFile, \"#locales/data.js\", \"locales\");\n ensureNamedImport(sourceFile, \"#locales/data.js\", \"Locale\", true);\n ensureNamedImport(sourceFile, \"#lib/url.js\", \"defaultLocale\");\n ensureNamedImport(sourceFile, \"#lib/url.js\", \"hasLocalizedUrl\");\n ensureNamedImport(sourceFile, \"#lib/locale.js\", \"LOCALE_COOKIE\");\n ensureNamedImport(sourceFile, \"#lib/locale.js\", \"localeCookie\");\n ensureNamedImport(sourceFile, \"#lib/locale.js\", \"pickLocale\");\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 // Above the handle and its JSDoc, so `handleWuchale` is declared before\n // the handle reads it.\n sourceFile.insertText(\n handleStmt.getStart(true),\n `${STARTUP}\\n\\n${UNTYPED_HANDLE}\\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 { modifyPrettierignore } from \"./modifies/prettierignore\";\nimport { ensureRootLayoutI18n } from \"./modifies/+layout\";\nimport { modifyRootLayoutLanguageSelect } from \"./modifies/root-layout.svelte\";\nimport { modifyLayoutServerLocale } from \"./modifies/layout.server\";\nimport { modifyAppDts } from \"./modifies/app-d-ts\";\nimport {\n APP_LAYOUT_PATH,\n modifyAppLayoutLanguageSelect,\n} from \"./modifies/app-layout.svelte\";\nimport { welcomePageCatalog } from \"./welcome-catalog\";\nimport {\n entriesInProject,\n translateCatalog,\n withTranslations,\n} from \"../../../runtime/wuchale-catalog\";\nimport { AUTH_TRANSLATIONS } from \"../auth/translations\";\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(\"Declaring the request's language in app.d.ts\");\n const appDtsPath = path.join(options.root, \"src\", \"app.d.ts\");\n pushResult(modifyOutcomeToFile(appDtsPath, modifyAppDts(appDtsPath)));\n\n logger.info(\"Modifying root +layout.server.ts\");\n const layoutServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n layoutServerPath,\n modifyLayoutServerLocale(layoutServerPath),\n ),\n );\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 // Signed-in pages have one URL for every language; the select is how a\n // visitor changes it there.\n const appLayoutPath = path.join(options.root, APP_LAYOUT_PATH);\n if (fs.existsSync(appLayoutPath)) {\n logger.info(\"Adding the language select to the signed-in layout\");\n pushResult(\n modifyOutcomeToFile(\n appLayoutPath,\n modifyAppLayoutLanguageSelect(appLayoutPath),\n ),\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 logger.info(\"Updating .prettierignore\");\n const prettierignorePath = path.join(options.root, \".prettierignore\");\n pushResult(\n modifyOutcomeToFile(\n prettierignorePath,\n modifyPrettierignore(prettierignorePath),\n ),\n );\n\n const catalog = welcomePageCatalog(options.root, ui);\n if (catalog) logger.info(\"Translating the welcome page into Spanish\");\n\n // Spanish for the pages other patterns wrote before this one: without it\n // they stay in English, and nothing says so.\n const shipped = entriesInProject(options.root, AUTH_TRANSLATIONS);\n if (shipped.length > 0)\n logger.info(\"Translating the sign-in pages into Spanish\");\n const creates: File[] = [];\n if (catalog) {\n const content = withTranslations(catalog.content, shipped).source;\n creates.push({ ...catalog, content });\n } else {\n const translated = translateCatalog(options.root, shipped);\n if (translated.create) creates.push(translated.create);\n pushResult(translated.modify);\n }\n\n return {\n creates,\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAKA,IAAMA,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