@velastack/patterns 0.13.2 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/chunks/app-d-ts-h33RrYIv.js +198 -0
- package/dist/chunks/app-d-ts-h33RrYIv.js.map +1 -0
- package/dist/chunks/app-layout.svelte-CZ0hw-pi.js +51 -0
- package/dist/chunks/app-layout.svelte-CZ0hw-pi.js.map +1 -0
- package/dist/chunks/constants-DpK-r_m5.js.map +1 -1
- package/dist/chunks/{generate.runtime-CzYArKUA.js → generate.runtime-BSxSHNh7.js} +2 -2
- package/dist/chunks/{generate.runtime-CzYArKUA.js.map → generate.runtime-BSxSHNh7.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Dfl-07VS.js → generate.runtime-CZKIKP3B.js} +214 -178
- package/dist/chunks/generate.runtime-CZKIKP3B.js.map +1 -0
- package/dist/chunks/{generate.runtime-DaPA2NNL.js → generate.runtime-CqCXFeWH.js} +2 -2
- package/dist/chunks/{generate.runtime-DaPA2NNL.js.map → generate.runtime-CqCXFeWH.js.map} +1 -1
- package/dist/chunks/{generate.runtime-B6FeCL5I.js → generate.runtime-CsP4c8GY.js} +78 -77
- package/dist/chunks/generate.runtime-CsP4c8GY.js.map +1 -0
- package/dist/chunks/generate.runtime-DZUPtJVF.js +429 -0
- package/dist/chunks/generate.runtime-DZUPtJVF.js.map +1 -0
- package/dist/chunks/{generate.runtime-C_SdcnRs.js → generate.runtime-Db7JwGTb.js} +2 -2
- package/dist/chunks/{generate.runtime-C_SdcnRs.js.map → generate.runtime-Db7JwGTb.js.map} +1 -1
- package/dist/chunks/{generate.runtime-i3tMIA1A.js → generate.runtime-pbIrEsa7.js} +45 -45
- package/dist/chunks/generate.runtime-pbIrEsa7.js.map +1 -0
- package/dist/chunks/i18n-BHCytiiO.js +28 -0
- package/dist/chunks/i18n-BHCytiiO.js.map +1 -0
- package/dist/chunks/{table-core-BXmnfjln.js → table-core-Dua6QnXM.js} +14 -4
- package/dist/chunks/table-core-Dua6QnXM.js.map +1 -0
- package/dist/chunks/{test-setup-cZj1tqaf.js → test-setup-gJdzWWs_.js} +2 -2
- package/dist/chunks/{test-setup-cZj1tqaf.js.map → test-setup-gJdzWWs_.js.map} +1 -1
- package/dist/chunks/translations-CiJnl574.js +189 -0
- package/dist/chunks/translations-CiJnl574.js.map +1 -0
- package/dist/chunks/{ui-IkdkLwmB.js → ui-CD61O7Sb.js} +3 -3
- package/dist/chunks/{ui-IkdkLwmB.js.map → ui-CD61O7Sb.js.map} +1 -1
- package/dist/chunks/write-result-B7MewKhQ.js +499 -0
- package/dist/chunks/write-result-B7MewKhQ.js.map +1 -0
- package/dist/index.js +734 -721
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunks/_layout-xBzFhszN.js +0 -78
- package/dist/chunks/_layout-xBzFhszN.js.map +0 -1
- package/dist/chunks/generate.runtime-B6FeCL5I.js.map +0 -1
- package/dist/chunks/generate.runtime-DLg2CKxQ.js +0 -341
- package/dist/chunks/generate.runtime-DLg2CKxQ.js.map +0 -1
- package/dist/chunks/generate.runtime-Dfl-07VS.js.map +0 -1
- package/dist/chunks/generate.runtime-i3tMIA1A.js.map +0 -1
- package/dist/chunks/table-core-BXmnfjln.js.map +0 -1
- package/dist/chunks/write-result-C1GYInL8.js +0 -499
- package/dist/chunks/write-result-C1GYInL8.js.map +0 -1
package/README.md
CHANGED
|
@@ -188,7 +188,7 @@ lists in `components` is handed to `shadcn-svelte add`, which resolves it from t
|
|
|
188
188
|
- `customDependencies` must list every `#lib/components/ui/<x>/index.js` a shipped component imports, and
|
|
189
189
|
`customNpmPackages` every npm package no shadcn item installs for it.
|
|
190
190
|
- `data-table` is a local copy of `@tanstack/svelte-table`'s v9 adapter (`createTable`, `FlexRender`,
|
|
191
|
-
`renderComponent`) over `@tanstack/table-core` alone; `column-header`, `faceted-filter` and `pagination` type
|
|
191
|
+
`renderComponent`) over `@tanstack/table-core` alone; `column-header`, `faceted-filter` and `data-table-pagination` type
|
|
192
192
|
their props with table-core's per-feature interfaces (`Column_RowSorting<any, any>`, ...), since a
|
|
193
193
|
`Column<typeof features, Row>` is not assignable to `Column<any, any>` in v9. The scaffold list page
|
|
194
194
|
(`src/core/scaffold-list.ts`) declares its own `tableFeatures`. `installPackages` never upgrades a package
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { t as e } from "./dedent-CCUOcPFW.js";
|
|
2
|
+
import { i as t, o as n, r } from "./ts-morph-helpers-B4KZXP44.js";
|
|
3
|
+
import { t as i } from "./package-imports-CcIIHbp5.js";
|
|
4
|
+
import { a, c as o, i as s, l as c, r as l, s as u } from "./load-function-BFvIVsh7.js";
|
|
5
|
+
import d from "node:fs";
|
|
6
|
+
import f from "node:path";
|
|
7
|
+
import { Node as p, Project as m, QuoteKind as h } from "ts-morph";
|
|
8
|
+
// src/patterns/enable/i18n/modifies/prettierignore.ts
|
|
9
|
+
var g = "src/locales/", _ = "# Wuchale";
|
|
10
|
+
function v(e) {
|
|
11
|
+
if (!d.existsSync(e)) return {
|
|
12
|
+
status: "success",
|
|
13
|
+
changed: !1
|
|
14
|
+
};
|
|
15
|
+
let t = d.readFileSync(e, "utf8");
|
|
16
|
+
if (t.split("\n").some((e) => e.trim().replace(/^\//, "") === "src/locales/")) return {
|
|
17
|
+
status: "success",
|
|
18
|
+
changed: !1
|
|
19
|
+
};
|
|
20
|
+
let n = t.length > 0 && !t.endsWith("\n"), r = t.length > 0 ? "\n" : "";
|
|
21
|
+
return d.writeFileSync(e, `${t}${n ? "\n" : ""}${r}${_}\n${g}\n`), {
|
|
22
|
+
status: "success",
|
|
23
|
+
changed: !0
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
// src/patterns/enable/i18n/modifies/package-imports.ts
|
|
27
|
+
var y = { "#locales/*": "./src/locales/*" };
|
|
28
|
+
function b(e) {
|
|
29
|
+
return i(e, y);
|
|
30
|
+
}
|
|
31
|
+
// src/patterns/enable/i18n/modifies/+layout.ts
|
|
32
|
+
var x = e`
|
|
33
|
+
import { browser } from '$app/env';
|
|
34
|
+
import { loadLocale } from 'wuchale/load-utils';
|
|
35
|
+
|
|
36
|
+
import { getLocale } from '#locales/main.url.js';
|
|
37
|
+
import { hasLocalizedUrl } from '#lib/url.js';
|
|
38
|
+
import '#locales/main.loader.svelte.js';
|
|
39
|
+
import '#locales/js.loader.js';
|
|
40
|
+
`, S = e`
|
|
41
|
+
export const load = async ({ url, data }) => {
|
|
42
|
+
// A public page's language is in its URL. The others follow the visitor's
|
|
43
|
+
// preference, which only the server knows: see src/lib/locale.ts.
|
|
44
|
+
const locale = hasLocalizedUrl(url.pathname) ? getLocale(url) : data.locale;
|
|
45
|
+
|
|
46
|
+
if (browser) {
|
|
47
|
+
await loadLocale(locale);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return { ...data, locale };
|
|
51
|
+
};
|
|
52
|
+
`, C = e`
|
|
53
|
+
export const load = async ({ url, data }) => {
|
|
54
|
+
const locale = getLocale(url);
|
|
55
|
+
|
|
56
|
+
if (browser) {
|
|
57
|
+
await loadLocale(locale);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return data;
|
|
61
|
+
};
|
|
62
|
+
`, w = `${x}\n\n${S}`, T = [
|
|
63
|
+
"Merge the wuchale loader into your existing load function in +layout.ts:",
|
|
64
|
+
"",
|
|
65
|
+
w
|
|
66
|
+
].join("\n");
|
|
67
|
+
function E(e) {
|
|
68
|
+
if (!d.existsSync(e)) return d.mkdirSync(f.dirname(e), { recursive: !0 }), d.writeFileSync(e, w + "\n"), {
|
|
69
|
+
status: "success",
|
|
70
|
+
changed: !0
|
|
71
|
+
};
|
|
72
|
+
let i = d.readFileSync(e, "utf8");
|
|
73
|
+
if (i.includes("loadLocale") || i.includes("translateUrl")) return {
|
|
74
|
+
status: "success",
|
|
75
|
+
changed: !1
|
|
76
|
+
};
|
|
77
|
+
if (/\bexport\s+(const|function)\s+load\b/.test(i)) return {
|
|
78
|
+
status: "failed",
|
|
79
|
+
message: T
|
|
80
|
+
};
|
|
81
|
+
let a = new m({
|
|
82
|
+
compilerOptions: { allowJs: !0 },
|
|
83
|
+
manipulationSettings: { quoteKind: h.Single }
|
|
84
|
+
}).addSourceFileAtPath(e);
|
|
85
|
+
return t(a, "$app/env", "browser"), t(a, "wuchale/load-utils", "loadLocale"), t(a, "#locales/main.url.js", "getLocale"), t(a, "#lib/url.js", "hasLocalizedUrl"), r(a, [{ moduleSpecifier: "#locales/main.loader.svelte.js" }, { moduleSpecifier: "#locales/js.loader.js" }]), a.addStatements(`\n${S}\n`), n(a), a.saveSync(), {
|
|
86
|
+
status: "success",
|
|
87
|
+
changed: !0
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
// src/patterns/enable/i18n/modifies/layout.server.ts
|
|
91
|
+
var D = e`
|
|
92
|
+
import type { LayoutServerLoad } from './$types';
|
|
93
|
+
|
|
94
|
+
export const load: LayoutServerLoad = async ({ locals }) => {
|
|
95
|
+
// Decided on the server (src/hooks.server.ts), because pages without a
|
|
96
|
+
// language in their URL follow the visitor's preference.
|
|
97
|
+
return { locale: locals.locale };
|
|
98
|
+
};
|
|
99
|
+
`, O = "Return the request's language from the load in src/routes/+layout.server.ts:\n\nreturn {\n // ...what it returns today\n locale: locals.locale\n};";
|
|
100
|
+
function k(e) {
|
|
101
|
+
let t = e.getBody();
|
|
102
|
+
if (!t) return null;
|
|
103
|
+
if (p.isBlock(t)) {
|
|
104
|
+
let n = l(e, t);
|
|
105
|
+
return n ? c(n) : null;
|
|
106
|
+
}
|
|
107
|
+
let n = t;
|
|
108
|
+
for (; p.isParenthesizedExpression(n);) n = n.getExpression();
|
|
109
|
+
return p.isObjectLiteralExpression(n) ? n : null;
|
|
110
|
+
}
|
|
111
|
+
function A(e) {
|
|
112
|
+
if (!d.existsSync(e)) return d.mkdirSync(f.dirname(e), { recursive: !0 }), d.writeFileSync(e, D + "\n"), {
|
|
113
|
+
status: "success",
|
|
114
|
+
changed: !0
|
|
115
|
+
};
|
|
116
|
+
let t = d.readFileSync(e, "utf8");
|
|
117
|
+
if (t.includes("locals.locale")) return {
|
|
118
|
+
status: "success",
|
|
119
|
+
changed: !1
|
|
120
|
+
};
|
|
121
|
+
let r = o().addSourceFileAtPath(e), i = s(r);
|
|
122
|
+
if (!i) return /\bload\b/.test(t) ? {
|
|
123
|
+
status: "failed",
|
|
124
|
+
message: O
|
|
125
|
+
} : (r.addStatements("\n" + D.split("\n").slice(2).join("\n") + "\n"), r.insertStatements(0, D.split("\n")[0]), n(r), r.saveSync(), {
|
|
126
|
+
status: "success",
|
|
127
|
+
changed: !0
|
|
128
|
+
});
|
|
129
|
+
let c = u(i), l = k(i);
|
|
130
|
+
if (c.kind === "unsupported" || !l || a(l, "locale")) return {
|
|
131
|
+
status: "failed",
|
|
132
|
+
message: O
|
|
133
|
+
};
|
|
134
|
+
let p = "locals";
|
|
135
|
+
if (c.kind === "identifier") p = `${c.name}.locals`;
|
|
136
|
+
else if (c.kind === "none") i.addParameter({ name: "{ locals }" });
|
|
137
|
+
else {
|
|
138
|
+
let e = c.pattern.getElements(), t = e.find((e) => (e.getPropertyNameNode()?.getText() ?? e.getName()) === "locals");
|
|
139
|
+
if (t) p = t.getName();
|
|
140
|
+
else if (e.some((e) => e.getDotDotDotToken())) return {
|
|
141
|
+
status: "failed",
|
|
142
|
+
message: O
|
|
143
|
+
};
|
|
144
|
+
else {
|
|
145
|
+
let t = e.map((e) => e.getText());
|
|
146
|
+
c.pattern.replaceWithText(`{ ${["locals", ...t].join(", ")} }`);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return l.addPropertyAssignment({
|
|
150
|
+
name: "locale",
|
|
151
|
+
initializer: `${p}.locale`,
|
|
152
|
+
leadingTrivia: (e) => e.writeLine("// Decided on the server (src/hooks.server.ts), because pages without a").writeLine("// language in their URL follow the visitor's preference.")
|
|
153
|
+
}), n(r), r.saveSync(), {
|
|
154
|
+
status: "success",
|
|
155
|
+
changed: !0
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
// src/patterns/enable/i18n/modifies/app-d-ts.ts
|
|
159
|
+
var j = "locale: import('#locales/data.js').Locale;", M = "/** The language of this request: see src/lib/locale.ts. */", N = [
|
|
160
|
+
"Declare the request's language on App.Locals in src/app.d.ts:",
|
|
161
|
+
"",
|
|
162
|
+
"interface Locals {",
|
|
163
|
+
` ${M}`,
|
|
164
|
+
` ${j}`,
|
|
165
|
+
"}"
|
|
166
|
+
].join("\n"), P = /^([ \t]*)\/\/\s*interface Locals\s*\{\s*\}[ \t]*$/m, F = /^([ \t]*)interface Locals\s*\{/m;
|
|
167
|
+
function I(e) {
|
|
168
|
+
if (!d.existsSync(e)) return {
|
|
169
|
+
status: "not-found",
|
|
170
|
+
message: N
|
|
171
|
+
};
|
|
172
|
+
let t = d.readFileSync(e, "utf8"), n = F.exec(t);
|
|
173
|
+
if (n) {
|
|
174
|
+
let e = n.index + n[0].length, r = t.indexOf("}", e);
|
|
175
|
+
if (r !== -1 && /\blocale\??\s*:/.test(t.slice(e, r))) return {
|
|
176
|
+
status: "success",
|
|
177
|
+
changed: !1
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
let r = /^\t/m.test(t) ? " " : " ", i = (e) => `${e}${r}${M}\n${e}${r}${j}\n`, a, o = P.exec(t);
|
|
181
|
+
if (n) {
|
|
182
|
+
let e = n.index + n[0].length, r = t.slice(e);
|
|
183
|
+
a = t.slice(0, e) + "\n" + i(n[1]) + (r.startsWith("}") ? n[1] : "") + r.replace(/^[ \t]*\n/, "");
|
|
184
|
+
} else if (o) {
|
|
185
|
+
let e = o[1];
|
|
186
|
+
a = t.replace(P, `${e}interface Locals {\n${i(e)}${e}}`);
|
|
187
|
+
} else return {
|
|
188
|
+
status: "failed",
|
|
189
|
+
message: N
|
|
190
|
+
};
|
|
191
|
+
return d.writeFileSync(e, a), {
|
|
192
|
+
status: "success",
|
|
193
|
+
changed: !0
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
export { A as a, E as c, g as d, _ as f, D as i, y as l, j as n, C as o, v as p, I as r, S as s, M as t, b as u };
|
|
197
|
+
|
|
198
|
+
//# sourceMappingURL=app-d-ts-h33RrYIv.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-d-ts-h33RrYIv.js","names":["FAILURE_HINT","FAILURE_HINT","dedent","ensureNamedImport","formatLikeSource","ensurePackageImports","newProject","findLoadFunction","returnedObject","findFinalReturn","inspectEventParameter","fs","path","LOCALES_ENTRY","PRETTIERIGNORE_HEADER","modifyPrettierignore","filePath","original","line","needsNewline","separator","LOCALES_IMPORTS","modifyPackageImportsI18n","root","IMPORT_SNIPPET","LOAD_STATEMENT","LEGACY_LOAD_STATEMENT","LOAD_SNIPPET","FAILURE_HINT$2","ensureRootLayoutI18n","layoutPath","existing","sourceFile","Project","QuoteKind","ensureImports","LAYOUT_SERVER_SNIPPET","FAILURE_HINT$1","loadResult","body","fn","Node","returned","expression","modifyLayoutServerLocale","layoutServerPath","event","object","hasProperty","locals","elements","element","kept","writer","LOCALS_MEMBER","LOCALS_COMMENT","FAILURE_HINT","COMMENTED","DECLARED","modifyAppDts","appDtsPath","declared","start","end","unit","member","indent","updated","commented","at","rest"],"sources":["../../src/patterns/enable/i18n/modifies/prettierignore.ts","../../src/patterns/enable/i18n/modifies/package-imports.ts","../../src/patterns/enable/i18n/modifies/+layout.ts","../../src/patterns/enable/i18n/modifies/layout.server.ts","../../src/patterns/enable/i18n/modifies/app-d-ts.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\n/** Where wuchale writes its loaders, proxies and catalogs on every extract. */\nexport const LOCALES_ENTRY = \"src/locales/\";\nexport const PRETTIERIGNORE_HEADER = \"# Wuchale\";\n\n/**\n * wuchale rewrites `src/locales/` in its own style on every extract, which\n * the project's `prettier --check .` would flag. A project without a\n * `.prettierignore` is left alone: without prettier there is nothing to\n * ignore, and with it the file is the project's to start.\n */\nexport function modifyPrettierignore(filePath: string): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(filePath, \"utf8\");\n const ignored = original\n .split(\"\\n\")\n .some((line) => line.trim().replace(/^\\//, \"\") === LOCALES_ENTRY);\n if (ignored) {\n return { status: \"success\", changed: false };\n }\n\n const needsNewline = original.length > 0 && !original.endsWith(\"\\n\");\n const separator = original.length > 0 ? \"\\n\" : \"\";\n fs.writeFileSync(\n filePath,\n `${original}${needsNewline ? \"\\n\" : \"\"}${separator}${PRETTIERIGNORE_HEADER}\\n${LOCALES_ENTRY}\\n`,\n );\n return { status: \"success\", changed: true };\n}\n","import {\n ensurePackageImports,\n type PackageJsonEditResult,\n} from \"../../../../runtime/package-imports\";\n\n/**\n * The package.json `imports` entry the app's `#locales/*.js` specifiers\n * resolve through. wuchale writes its loaders and data to `src/locales`;\n * SvelteKit 3 deprecates `alias`, so the directory is mapped the way `#lib`\n * is. wuchale's own generated imports are relative and never go through it.\n */\nexport const LOCALES_IMPORTS = { \"#locales/*\": \"./src/locales/*\" };\n\n/** Add `#locales/*` to package.json `imports`; a different value already there is reported. */\nexport function modifyPackageImportsI18n(root: string): PackageJsonEditResult {\n return ensurePackageImports(root, LOCALES_IMPORTS);\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 {\n ensureImports,\n ensureNamedImport,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nconst IMPORT_SNIPPET = dedent`\n import { browser } from '$app/env';\n import { loadLocale } from 'wuchale/load-utils';\n\n import { getLocale } from '#locales/main.url.js';\n import { hasLocalizedUrl } from '#lib/url.js';\n import '#locales/main.loader.svelte.js';\n import '#locales/js.loader.js';\n`;\n\n/** The load `disable-i18n` looks for to take it out again. */\nexport const LOAD_STATEMENT = dedent`\n export const load = async ({ url, data }) => {\n // A public page's language is in its URL. The others follow the visitor's\n // preference, which only the server knows: see src/lib/locale.ts.\n const locale = hasLocalizedUrl(url.pathname) ? getLocale(url) : data.locale;\n\n if (browser) {\n await loadLocale(locale);\n }\n\n return { ...data, locale };\n };\n`;\n\n/**\n * The load enable-i18n wrote while every page took its language from the\n * URL. `disable-i18n` still takes it out of a project enabled back then.\n */\nexport const LEGACY_LOAD_STATEMENT = dedent`\n export const load = async ({ url, data }) => {\n const locale = getLocale(url);\n\n if (browser) {\n await loadLocale(locale);\n }\n\n return data;\n };\n`;\n\n/** The whole file, for a project that had no root `+layout.ts`. */\nexport const LOAD_SNIPPET = `${IMPORT_SNIPPET}\\n\\n${LOAD_STATEMENT}`;\n\nconst FAILURE_HINT = [\n \"Merge the wuchale loader into your existing load function in +layout.ts:\",\n \"\",\n LOAD_SNIPPET,\n].join(\"\\n\");\n\nexport function ensureRootLayoutI18n(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n fs.mkdirSync(path.dirname(layoutPath), { recursive: true });\n fs.writeFileSync(layoutPath, LOAD_SNIPPET + \"\\n\");\n return { status: \"success\", changed: true };\n }\n\n const existing = fs.readFileSync(layoutPath, \"utf8\");\n if (existing.includes(\"loadLocale\") || existing.includes(\"translateUrl\")) {\n return { status: \"success\", changed: false };\n }\n\n if (/\\bexport\\s+(const|function)\\s+load\\b/.test(existing)) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n // No load to merge with, but the file may hold other route options\n // (`export const prerender = true`, say), so the load is added to it\n // rather than written over it.\n const project = new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(layoutPath);\n\n ensureNamedImport(sourceFile, \"$app/env\", \"browser\");\n ensureNamedImport(sourceFile, \"wuchale/load-utils\", \"loadLocale\");\n ensureNamedImport(sourceFile, \"#locales/main.url.js\", \"getLocale\");\n ensureNamedImport(sourceFile, \"#lib/url.js\", \"hasLocalizedUrl\");\n ensureImports(sourceFile, [\n { moduleSpecifier: \"#locales/main.loader.svelte.js\" },\n { moduleSpecifier: \"#locales/js.loader.js\" },\n ]);\n\n sourceFile.addStatements(`\\n${LOAD_STATEMENT}\\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 { Node, type ObjectLiteralExpression } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport {\n findFinalReturn,\n findLoadFunction,\n hasProperty,\n inspectEventParameter,\n newProject,\n returnedObject,\n} from \"../../../../runtime/load-function\";\nimport { formatLikeSource } from \"../../../../runtime/ts-morph-helpers\";\n\n/**\n * The whole file, for a project that had no root `+layout.server.ts`.\n * `disable-i18n` deletes it again while it is still exactly this.\n */\nexport const LAYOUT_SERVER_SNIPPET = dedent`\n import type { LayoutServerLoad } from './$types';\n\n export const load: LayoutServerLoad = async ({ locals }) => {\n \t// Decided on the server (src/hooks.server.ts), because pages without a\n \t// language in their URL follow the visitor's preference.\n \treturn { locale: locals.locale };\n };\n`;\n\nconst FAILURE_HINT = [\n \"Return the request's language from the load in src/routes/+layout.server.ts:\",\n \"\",\n \"return {\",\n \" // ...what it returns today\",\n \" locale: locals.locale\",\n \"};\",\n].join(\"\\n\");\n\n/** The object a load yields: its final `return`, or an arrow's `({ ... })` body. */\nfunction loadResult(\n fn: NonNullable<ReturnType<typeof findLoadFunction>>,\n): ObjectLiteralExpression | null {\n const body = fn.getBody();\n if (!body) return null;\n if (Node.isBlock(body)) {\n const returned = findFinalReturn(fn, body);\n return returned ? returnedObject(returned) : null;\n }\n let expression: Node = body;\n while (Node.isParenthesizedExpression(expression)) {\n expression = expression.getExpression();\n }\n return Node.isObjectLiteralExpression(expression) ? expression : null;\n}\n\n/**\n * The root layout's server load returns `locale`, the language the hook chose\n * for the request, for `+layout.ts` and the language select to read. Created\n * when the project has no `+layout.server.ts`; otherwise the property joins\n * what the load returns already. A load with several returns, or one that\n * returns something other than an object literal, is reported as `failed`\n * with the line to add and left as it was.\n */\nexport function modifyLayoutServerLocale(\n layoutServerPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(layoutServerPath)) {\n fs.mkdirSync(path.dirname(layoutServerPath), { recursive: true });\n fs.writeFileSync(layoutServerPath, LAYOUT_SERVER_SNIPPET + \"\\n\");\n return { status: \"success\", changed: true };\n }\n\n const original = fs.readFileSync(layoutServerPath, \"utf8\");\n if (original.includes(\"locals.locale\")) {\n return { status: \"success\", changed: false };\n }\n\n const sourceFile = newProject().addSourceFileAtPath(layoutServerPath);\n const fn = findLoadFunction(sourceFile);\n if (!fn) {\n // Route options only (`export const prerender = true`, say).\n if (/\\bload\\b/.test(original)) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n sourceFile.addStatements(\n \"\\n\" + LAYOUT_SERVER_SNIPPET.split(\"\\n\").slice(2).join(\"\\n\") + \"\\n\",\n );\n sourceFile.insertStatements(0, LAYOUT_SERVER_SNIPPET.split(\"\\n\")[0]);\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n const event = inspectEventParameter(fn);\n const object = loadResult(fn);\n if (\n event.kind === \"unsupported\" ||\n !object ||\n hasProperty(object, \"locale\")\n ) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n let locals = \"locals\";\n if (event.kind === \"identifier\") {\n locals = `${event.name}.locals`;\n } else if (event.kind === \"none\") {\n fn.addParameter({ name: \"{ locals }\" });\n } else {\n const elements = event.pattern.getElements();\n const existing = elements.find(\n (element) =>\n (element.getPropertyNameNode()?.getText() ?? element.getName()) ===\n \"locals\",\n );\n if (existing) {\n locals = existing.getName();\n } else if (elements.some((element) => element.getDotDotDotToken())) {\n return { status: \"failed\", message: FAILURE_HINT };\n } else {\n const kept = elements.map((element) => element.getText());\n event.pattern.replaceWithText(`{ ${[\"locals\", ...kept].join(\", \")} }`);\n }\n }\n\n // After any spread, so nothing spread in can shadow it.\n object.addPropertyAssignment({\n name: \"locale\",\n initializer: `${locals}.locale`,\n leadingTrivia: (writer) =>\n writer\n .writeLine(\n \"// Decided on the server (src/hooks.server.ts), because pages without a\",\n )\n .writeLine(\"// language in their URL follow the visitor's preference.\"),\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\n/** The member `disable-i18n` looks for to take it out again. */\nexport const LOCALS_MEMBER = \"locale: import('#locales/data.js').Locale;\";\nexport const LOCALS_COMMENT =\n \"/** The language of this request: see src/lib/locale.ts. */\";\n\nconst FAILURE_HINT = [\n \"Declare the request's language on App.Locals in src/app.d.ts:\",\n \"\",\n \"interface Locals {\",\n ` ${LOCALS_COMMENT}`,\n ` ${LOCALS_MEMBER}`,\n \"}\",\n].join(\"\\n\");\n\n/** `// interface Locals {}`, as `sv create` leaves it. */\nconst COMMENTED = /^([ \\t]*)\\/\\/\\s*interface Locals\\s*\\{\\s*\\}[ \\t]*$/m;\nconst DECLARED = /^([ \\t]*)interface Locals\\s*\\{/m;\n\n/**\n * `event.locals.locale`, which the i18n handle sets, is declared on\n * `App.Locals`. The interface `sv create` leaves commented out is switched\n * on; one that is declared already gains the member.\n */\nexport function modifyAppDts(appDtsPath: string): ModifyOutcome {\n if (!fs.existsSync(appDtsPath)) {\n return { status: \"not-found\", message: FAILURE_HINT };\n }\n\n const original = fs.readFileSync(appDtsPath, \"utf8\");\n // Whatever its type, a `locale` on Locals is there.\n const declared = DECLARED.exec(original);\n if (declared) {\n const start = declared.index + declared[0].length;\n const end = original.indexOf(\"}\", start);\n if (end !== -1 && /\\blocale\\??\\s*:/.test(original.slice(start, end))) {\n return { status: \"success\", changed: false };\n }\n }\n\n const unit = /^\\t/m.test(original) ? \"\\t\" : \" \";\n const member = (indent: string) =>\n `${indent}${unit}${LOCALS_COMMENT}\\n${indent}${unit}${LOCALS_MEMBER}\\n`;\n\n let updated: string;\n const commented = COMMENTED.exec(original);\n if (declared) {\n const at = declared.index + declared[0].length;\n const rest = original.slice(at);\n updated =\n original.slice(0, at) +\n \"\\n\" +\n member(declared[1]) +\n // `interface Locals {}` on one line: the brace moves to its own.\n (rest.startsWith(\"}\") ? declared[1] : \"\") +\n rest.replace(/^[ \\t]*\\n/, \"\");\n } else if (commented) {\n const indent = commented[1];\n updated = original.replace(\n COMMENTED,\n `${indent}interface Locals {\\n${member(indent)}${indent}}`,\n );\n } else {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n fs.writeFileSync(appDtsPath, updated);\n return { status: \"success\", changed: true };\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { t as e } from "./dedent-CCUOcPFW.js";
|
|
2
|
+
import { t } from "./svelte-file-DfplF3BU.js";
|
|
3
|
+
import { _ as n, r } from "./ts-morph-helpers-B4KZXP44.js";
|
|
4
|
+
import i from "node:fs";
|
|
5
|
+
import a from "node:path";
|
|
6
|
+
// src/patterns/enable/i18n/modifies/app-layout.svelte.ts
|
|
7
|
+
var o = a.join("src", "routes", "(app)", "+layout.svelte"), s = " <div class=\"ml-auto px-4\">\n <LanguageSelect />\n </div>\n ", c = /[ \t]*<div class="ml-auto px-4">\s*<LanguageSelect\s*\/>\s*<\/div>[ \t]*\r?\n?/g, l = [
|
|
8
|
+
"Add the language select to the <header> of the signed-in layout,",
|
|
9
|
+
"src/routes/(app)/+layout.svelte. Signed-in pages have one URL for every",
|
|
10
|
+
"language, so the select is how a visitor changes it there.",
|
|
11
|
+
"",
|
|
12
|
+
"Import to add to the <script> tag:",
|
|
13
|
+
"",
|
|
14
|
+
e`
|
|
15
|
+
import LanguageSelect from '#lib/components/language-select.svelte';
|
|
16
|
+
`,
|
|
17
|
+
"",
|
|
18
|
+
"Markup to add at the end of <header>:",
|
|
19
|
+
"",
|
|
20
|
+
"<div class=\"ml-auto px-4\">",
|
|
21
|
+
" <LanguageSelect />",
|
|
22
|
+
"</div>"
|
|
23
|
+
].join("\n");
|
|
24
|
+
function u(e) {
|
|
25
|
+
if (!i.existsSync(e)) return {
|
|
26
|
+
status: "success",
|
|
27
|
+
changed: !1
|
|
28
|
+
};
|
|
29
|
+
let a = t.fromPath(e);
|
|
30
|
+
return a.hasElement("LanguageSelect") ? {
|
|
31
|
+
status: "success",
|
|
32
|
+
changed: !1
|
|
33
|
+
} : !a.getScript() || !a.hasElement("header") ? {
|
|
34
|
+
status: "failed",
|
|
35
|
+
message: l
|
|
36
|
+
} : (a.modifyScript((e) => {
|
|
37
|
+
let { source: t } = n(e, (e) => {
|
|
38
|
+
r(e, [{
|
|
39
|
+
defaultImport: "LanguageSelect",
|
|
40
|
+
moduleSpecifier: "#lib/components/language-select.svelte"
|
|
41
|
+
}]);
|
|
42
|
+
});
|
|
43
|
+
return t;
|
|
44
|
+
}), a.insertBeforeClosingTag("header", s), a.writeTo(e), {
|
|
45
|
+
status: "success",
|
|
46
|
+
changed: a.hasChanged()
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
export { o as n, u as r, c as t };
|
|
50
|
+
|
|
51
|
+
//# sourceMappingURL=app-layout.svelte-CZ0hw-pi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-layout.svelte-CZ0hw-pi.js","names":["dedent","withInMemoryScript","fs","path","APP_LAYOUT_PATH","LANGUAGE_SELECT_SNIPPET","APP_LANGUAGE_SELECT","FAILURE_HINT","modifyAppLayoutLanguageSelect","layoutPath","file","SvelteFile","out","source","sf"],"sources":["../../src/patterns/enable/i18n/modifies/app-layout.svelte.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport dedent from \"dedent\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n ensureImports,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\n/** The signed-in layout enable-auth writes, relative to the project root. */\nexport const APP_LAYOUT_PATH = path.join(\n \"src\",\n \"routes\",\n \"(app)\",\n \"+layout.svelte\",\n);\n\n/** At the end of the header, pushed to its right edge. */\nconst LANGUAGE_SELECT_SNIPPET = `\t<div class=\"ml-auto px-4\">\n\t\t\t\t\t<LanguageSelect />\n\t\t\t\t</div>\n\t\t\t`;\n\n/** What `disable-i18n` takes back out. */\nexport const APP_LANGUAGE_SELECT =\n /[ \\t]*<div class=\"ml-auto px-4\">\\s*<LanguageSelect\\s*\\/>\\s*<\\/div>[ \\t]*\\r?\\n?/g;\n\nconst IMPORT_SNIPPET = dedent`\n import LanguageSelect from '#lib/components/language-select.svelte';\n`;\n\nconst FAILURE_HINT = [\n \"Add the language select to the <header> of the signed-in layout,\",\n \"src/routes/(app)/+layout.svelte. Signed-in pages have one URL for every\",\n \"language, so the select is how a visitor changes it there.\",\n \"\",\n \"Import to add to the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup to add at the end of <header>:\",\n \"\",\n '<div class=\"ml-auto px-4\">',\n \" <LanguageSelect />\",\n \"</div>\",\n].join(\"\\n\");\n\n/**\n * The language select at the end of the signed-in layout's header. Signed-in\n * pages have no language in their URL and no public navbar, so without it a\n * visitor could only change language by going back to a public page.\n *\n * Shared by the two patterns that can be the second one enabled: enable-i18n\n * adds it to the layout enable-auth wrote, and enable-auth adds it to its own\n * layout when the project already has i18n. A project without the layout is\n * left alone.\n */\nexport function modifyAppLayoutLanguageSelect(\n layoutPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"success\", changed: false };\n }\n\n const file = SvelteFile.fromPath(layoutPath);\n if (file.hasElement(\"LanguageSelect\")) {\n return { status: \"success\", changed: false };\n }\n if (!file.getScript() || !file.hasElement(\"header\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\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 file.insertBeforeClosingTag(\"header\", LANGUAGE_SELECT_SNIPPET);\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n"],"mappings":";;;;;;AAWA,IAAaI,IAAkBD,EAAK,KAClC,OACA,UACA,SACA,gBACF,GAGME,IAA0B,2EAMnBC,IACX,mFAMIC,IAAe;CACnB;CACA;CACA;CACA;CACA;CACA;CACA,CAX2B;;;CAY3B;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,CAAC,KAAK,IAAI;AAYX,SAAgBC,EACd,GACe;CACf,IAAI,CAACN,EAAG,WAAWO,CAAU,GAC3B,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAMC,IAAOC,EAAW,SAASF,CAAU;CAqB3C,OApBIC,EAAK,WAAW,gBAAgB,IAC3B;EAAE,QAAQ;EAAW,SAAS;CAAM,IAEzC,CAACA,EAAK,UAAU,KAAK,CAACA,EAAK,WAAW,QAAQ,IACzC;EAAE,QAAQ;EAAU,SAASH;CAAa,KAGnDG,EAAK,cAAc,MAAW;EAC5B,IAAM,EAAE,QAAQE,MAAQX,EAAmBY,IAAS,MAAO;GACzD,EAAcC,GAAI,CAChB;IACE,eAAe;IACf,iBAAiB;GACnB,CACF,CAAC;EACH,CAAC;EACD,OAAOF;CACT,CAAC,GACDF,EAAK,uBAAuB,UAAUL,CAAuB,GAC7DK,EAAK,QAAQD,CAAU,GAChB;EAAE,QAAQ;EAAW,SAASC,EAAK,WAAW;CAAE;AACzD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants-DpK-r_m5.js","names":["data","versions_default","\"ai\"","\"clsx\"","\"croner\"","\"formsnap\"","\"marked\"","\"mdsvex\"","\"openworkflow\"","\"prettier\"","\"supertest\"","\"svelte\"","\"tailwindcss\"","\"typescript\"","\"vite\"","\"vitest\"","\"wuchale\"","\"zod\"","\"source\"","\"reason\"","\"since\"","VERSIONS","VERSION_HOLDS","VERSION_TRACKS","NODE_FLOOR","spec","range","name","DATA_DIR","MIGRATIONS_DIR","PUBLIC_DIR","APP_DIR","TANSTACK_TABLE_CORE","TANSTACK_TABLE_CORE_MAJOR","FORMSNAP","SUPERFORMS_VERSION","SUPERFORMS","FLASH","ADAPTER_NODE","ADAPTER_STATIC","VELASTACK_KIT","VELASTACK_POCKETBASE","VELASTACK_CMS","VELASTACK_WHATSAPP","NEGOTIATE","ZOD","TAKUMI","WUCHALE","WUCHALE_SVELTE"],"sources":["../../src/core/versions.json","../../src/core/versions.ts","../../src/core/constants.ts"],"sourcesContent":["{\n \"node\": \"22.22.0\",\n \"packages\": {\n \"@ai-sdk/anthropic\": \"^4.0.99\",\n \"@ai-sdk/openai\": \"^4.0.111\",\n \"@ai-sdk/svelte\": \"^5.0.165\",\n \"@internationalized/date\": \"^3.12.4\",\n \"@lucide/svelte\": \"^1.70.0\",\n \"@sveltejs/adapter-node\": \"^6.0.2\",\n \"@sveltejs/adapter-static\": \"^4.0.1\",\n \"@sveltejs/kit\": \"^3.2.0\",\n \"@sveltejs/vite-plugin-svelte\": \"^7.3.1\",\n \"@tailwindcss/forms\": \"^0.5.11\",\n \"@tailwindcss/typography\": \"^0.5.20\",\n \"@tailwindcss/vite\": \"^4.3.5\",\n \"@takumi-rs/core\": \"^2.20.0\",\n \"@tanstack/table-core\": \"^9.3.1\",\n \"@types/node\": \"^26.6.6\",\n \"@types/supertest\": \"^7.2.1\",\n \"@velastack/cms\": \"^0.9.1\",\n \"@velastack/kit\": \"^0.4.1\",\n \"@velastack/pocketbase\": \"^0.4.3\",\n \"@velastack/whatsapp\": \"^0.1.0\",\n \"@wuchale/svelte\": \"^0.21.4\",\n \"ai\": \"^7.0.165\",\n \"bits-ui\": \"^2.20.6\",\n \"clsx\": \"^2.1.1\",\n \"croner\": \"^10.0.1\",\n \"formsnap\": \"^2.1.0\",\n \"marked\": \"^18.1.3\",\n \"mdsvex\": \"^0.12.8\",\n \"mode-watcher\": \"^1.1.0\",\n \"openworkflow\": \"^0.11.0\",\n \"openworkflow-pocketbase\": \"^0.2.1\",\n \"pocketbase-sveltekit\": \"^0.28.2\",\n \"prettier\": \"^3.9.10\",\n \"prettier-plugin-svelte\": \"^4.1.1\",\n \"shadcn-svelte\": \"^1.8.0\",\n \"supertest\": \"^7.3.2\",\n \"svelte\": \"^5.57.2\",\n \"svelte-check\": \"^4.7.8\",\n \"svelte-meta-tags\": \"^5.0.3\",\n \"svelte-sonner\": \"^1.2.3\",\n \"sveltekit-flash-message\": \"^3.0.0\",\n \"sveltekit-negotiate\": \"^0.3.1\",\n \"sveltekit-superforms\": \"^3.1.0\",\n \"tailwind-merge\": \"^3.7.0\",\n \"tailwind-variants\": \"^3.3.1\",\n \"tailwindcss\": \"^4.3.5\",\n \"tw-animate-css\": \"^1.4.0\",\n \"typescript\": \"^6.0.3\",\n \"vite\": \"^8.3.6\",\n \"vitest\": \"^5.1.0\",\n \"wuchale\": \"^0.26.7\",\n \"zod\": \"^4.6.7\"\n },\n \"tracks\": {\n \"svelte\": {\n \"source\": \"sv-create\",\n \"reason\": \"The floor sv create's minimal template ships, so a vela project and a plain SvelteKit one start alike.\"\n }\n },\n \"holds\": {\n \"croner\": {\n \"reason\": \"11.0 is a major; the cron matching in the workflows runtime has not been checked against it.\",\n \"since\": \"2026-11-11\"\n },\n \"tailwind-variants\": {\n \"reason\": \"4.0 is a major; the shadcn-svelte components and the templates' own tv() calls have not been checked against it.\",\n \"since\": \"2026-11-11\"\n },\n \"typescript\": {\n \"reason\": \"TypeScript 7 (the native port) is outside @sveltejs/kit's peer range (^6.0.0) and breaks the install. Blocked upstream: lift once Kit admits 7.\",\n \"since\": \"2026-11-11\"\n }\n }\n}\n","import data from \"./versions.json\";\n\n/**\n * The dependency ranges every vela project starts from, in one place:\n * `versions.json` beside this file.\n *\n * Three things read it. The patterns here install from it (`spec`). The vela\n * CLI's `minimal` and `static` templates, and the velastack-templates\n * baselines built on them, list the same ranges and each carry a test that\n * they still do. And `scripts/bump-versions.ts` keeps it current.\n *\n * So a version is changed here and nowhere else; the other copies follow it,\n * and their tests fail until they do.\n */\nexport const VERSIONS: Readonly<Record<string, string>> = data.packages;\n\n/** Packages kept below their latest release on purpose, and why. */\nexport const VERSION_HOLDS: Readonly<\n Record<string, { reason: string; since: string }>\n> = data.holds;\n\n/** Packages whose range follows another project's rather than npm's latest. */\nexport const VERSION_TRACKS: Readonly<\n Record<string, { source: string; reason: string }>\n> = data.tracks;\n\n/**\n * The oldest Node a vela project may run on: the floor of its `engines.node`.\n * Projects set `engine-strict`, so no listed package may require a later one.\n */\nexport const NODE_FLOOR: string = data.node;\n\n/** The install spec for a listed package: `spec(\"zod\")` is `zod@^4.6.7`. */\nexport function spec(name: string): string {\n const range = VERSIONS[name];\n if (range === undefined) {\n throw new Error(\n `${name} is not in src/core/versions.json; add it there before installing it.`,\n );\n }\n return `${name}@${range}`;\n}\n","import { VERSIONS, spec } from \"./versions\";\n\nexport const DATA_DIR = \"data\";\nexport const MIGRATIONS_DIR = \"migrations\";\nexport const FIXTURE_PREFIX = \"vela\";\nexport const PUBLIC_DIR = \"(public)\";\nexport const APP_DIR = \"(app)\";\nexport const AUTHED_REDIRECT_PATH = \"/dashboard\";\nexport const API_URL = \"http://localhost:5173\";\n\n/**\n * The table helpers this repo ships (`data-table`, `column-header`,\n * `faceted-filter`, `pagination`) and the pages the scaffold generators emit\n * target TanStack Table v9, whose API and types are incompatible with v8; see\n * `assertTableCoreV9` for projects that still have the v8 helpers.\n */\nexport const TANSTACK_TABLE_CORE = spec(\"@tanstack/table-core\");\n\n/** The major `TANSTACK_TABLE_CORE` pins. */\nexport const TANSTACK_TABLE_CORE_MAJOR = Number(\n /\\d+/.exec(VERSIONS[\"@tanstack/table-core\"]!)![0],\n);\n\n/**\n * `file-form` and `multiselect` build on formsnap's field context. 2.1.0 is\n * the first release whose superforms peer admits 3.x; 2.0 needed an npm\n * override, which `writeResult` now removes (`reconcileFormsnap`).\n */\nexport const FORMSNAP = spec(\"formsnap\");\n\n/**\n * The superforms range a project starts on: 3.x, the line that supports\n * SvelteKit 3. A caret like any other dependency, now that formsnap 2.1 peers\n * `^3.0.0`; it was an exact version while 3.0 was a `next` prerelease, because\n * a caret on a prerelease follows every later `next` build. `writeResult`,\n * `vela migrate` and `vela bless` still move a project off one of those\n * prerelease pins (`reconcileFormsnap`).\n *\n * The name is from the exact-pin days and is kept for the CLI, which imports\n * it; the value is a range.\n */\nexport const SUPERFORMS_VERSION = VERSIONS[\"sveltekit-superforms\"]!;\n\n/**\n * What a generated superforms page needs. Vela's templates already carry\n * both; a project vela did not create may have neither.\n */\nexport const SUPERFORMS = spec(\"sveltekit-superforms\");\n\n/** The flash-message line that supports SvelteKit 3. */\nexport const FLASH = spec(\"sveltekit-flash-message\");\n\n/** The adapter `vela enable backend` moves a project to. */\nexport const ADAPTER_NODE = spec(\"@sveltejs/adapter-node\");\n\n/** The adapter a static project builds with (`vela disable backend`). */\nexport const ADAPTER_STATIC = spec(\"@sveltejs/adapter-static\");\n\n/** The VelaStack libraries' SvelteKit 3 releases. */\nexport const VELASTACK_KIT = spec(\"@velastack/kit\");\n/** 0.4.2 or later: it proxies plugin webhooks (pocketbase-whatsapp) to PocketBase. */\nexport const VELASTACK_POCKETBASE = spec(\"@velastack/pocketbase\");\nexport const VELASTACK_CMS = spec(\"@velastack/cms\");\n/** wa.me links, order messages and hosted order recording, for payments on WhatsApp. */\nexport const VELASTACK_WHATSAPP = spec(\"@velastack/whatsapp\");\nexport const NEGOTIATE = spec(\"sveltekit-negotiate\");\nexport const ZOD = spec(\"zod\");\n/** Renders HTML and CSS to an image; a native module, so it must be a dependency. */\nexport const TAKUMI = spec(\"@takumi-rs/core\");\n\n/** What `vela enable i18n` installs: wuchale and its Svelte adapter. */\nexport const WUCHALE = spec(\"wuchale\");\nexport const WUCHALE_SVELTE = spec(\"@wuchale/svelte\");\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;A,GCcaqB,IAA6CrB,EAAK,UAGlDsB,IAETtB,EAAK,OAGIuB,IAETvB,EAAK,QAMIwB,IAAqBxB,EAAK;AAGvC,SAAgByB,EAAK,GAAsB;CACzC,IAAMC,IAAQL,EAASM;CACvB,IAAID,MAAU,KAAA,GACZ,MAAU,MACR,GAAGC,EAAK,sEACV;CAEF,OAAO,GAAGA,EAAK,GAAGD;AACpB;;ACvCA,IAAaE,IAAW,QACXC,IAAiB,cAEjBC,IAAa,YACbC,IAAU,SAUVC,IAAsBP,EAAK,sBAAsB,GAGjDQ,IAA4B,OACvC,MAAM,KAAKZ,EAAS,uBAAwB,CAAC,CAAE,EACjD,GAOaa,IAAWT,EAAK,UAAU,GAa1BU,IAAqBd,EAAS,yBAM9Be,IAAaX,EAAK,sBAAsB,GAGxCY,IAAQZ,EAAK,yBAAyB,GAGtCa,IAAeb,EAAK,wBAAwB,GAG5Cc,IAAiBd,EAAK,0BAA0B,GAGhDe,IAAgBf,EAAK,gBAAgB,GAErCgB,IAAuBhB,EAAK,uBAAuB,GACnDiB,IAAgBjB,EAAK,gBAAgB,GAErCkB,IAAqBlB,EAAK,qBAAqB,GAC/CmB,IAAYnB,EAAK,qBAAqB,GACtCoB,IAAMpB,EAAK,KAAK,GAEhBqB,IAASrB,EAAK,iBAAiB,GAG/BsB,IAAUtB,EAAK,SAAS,GACxBuB,IAAiBvB,EAAK,iBAAiB"}
|
|
1
|
+
{"version":3,"file":"constants-DpK-r_m5.js","names":["data","versions_default","\"ai\"","\"clsx\"","\"croner\"","\"formsnap\"","\"marked\"","\"mdsvex\"","\"openworkflow\"","\"prettier\"","\"supertest\"","\"svelte\"","\"tailwindcss\"","\"typescript\"","\"vite\"","\"vitest\"","\"wuchale\"","\"zod\"","\"source\"","\"reason\"","\"since\"","VERSIONS","VERSION_HOLDS","VERSION_TRACKS","NODE_FLOOR","spec","range","name","DATA_DIR","MIGRATIONS_DIR","PUBLIC_DIR","APP_DIR","TANSTACK_TABLE_CORE","TANSTACK_TABLE_CORE_MAJOR","FORMSNAP","SUPERFORMS_VERSION","SUPERFORMS","FLASH","ADAPTER_NODE","ADAPTER_STATIC","VELASTACK_KIT","VELASTACK_POCKETBASE","VELASTACK_CMS","VELASTACK_WHATSAPP","NEGOTIATE","ZOD","TAKUMI","WUCHALE","WUCHALE_SVELTE"],"sources":["../../src/core/versions.json","../../src/core/versions.ts","../../src/core/constants.ts"],"sourcesContent":["{\n \"node\": \"22.22.0\",\n \"packages\": {\n \"@ai-sdk/anthropic\": \"^4.0.99\",\n \"@ai-sdk/openai\": \"^4.0.111\",\n \"@ai-sdk/svelte\": \"^5.0.165\",\n \"@internationalized/date\": \"^3.12.4\",\n \"@lucide/svelte\": \"^1.70.0\",\n \"@sveltejs/adapter-node\": \"^6.0.2\",\n \"@sveltejs/adapter-static\": \"^4.0.1\",\n \"@sveltejs/kit\": \"^3.2.0\",\n \"@sveltejs/vite-plugin-svelte\": \"^7.3.1\",\n \"@tailwindcss/forms\": \"^0.5.11\",\n \"@tailwindcss/typography\": \"^0.5.20\",\n \"@tailwindcss/vite\": \"^4.3.5\",\n \"@takumi-rs/core\": \"^2.20.0\",\n \"@tanstack/table-core\": \"^9.3.1\",\n \"@types/node\": \"^26.6.6\",\n \"@types/supertest\": \"^7.2.1\",\n \"@velastack/cms\": \"^0.9.1\",\n \"@velastack/kit\": \"^0.4.1\",\n \"@velastack/pocketbase\": \"^0.4.3\",\n \"@velastack/whatsapp\": \"^0.1.0\",\n \"@wuchale/svelte\": \"^0.21.4\",\n \"ai\": \"^7.0.165\",\n \"bits-ui\": \"^2.20.6\",\n \"clsx\": \"^2.1.1\",\n \"croner\": \"^10.0.1\",\n \"formsnap\": \"^2.1.0\",\n \"marked\": \"^18.1.3\",\n \"mdsvex\": \"^0.12.8\",\n \"mode-watcher\": \"^1.1.0\",\n \"openworkflow\": \"^0.11.0\",\n \"openworkflow-pocketbase\": \"^0.2.1\",\n \"pocketbase-sveltekit\": \"^0.28.2\",\n \"prettier\": \"^3.9.10\",\n \"prettier-plugin-svelte\": \"^4.1.1\",\n \"shadcn-svelte\": \"^1.8.0\",\n \"supertest\": \"^7.3.2\",\n \"svelte\": \"^5.57.2\",\n \"svelte-check\": \"^4.7.8\",\n \"svelte-meta-tags\": \"^5.0.3\",\n \"svelte-sonner\": \"^1.2.3\",\n \"sveltekit-flash-message\": \"^3.0.0\",\n \"sveltekit-negotiate\": \"^0.3.1\",\n \"sveltekit-superforms\": \"^3.1.0\",\n \"tailwind-merge\": \"^3.7.0\",\n \"tailwind-variants\": \"^3.3.1\",\n \"tailwindcss\": \"^4.3.5\",\n \"tw-animate-css\": \"^1.4.0\",\n \"typescript\": \"^6.0.3\",\n \"vite\": \"^8.3.6\",\n \"vitest\": \"^5.1.0\",\n \"wuchale\": \"^0.26.7\",\n \"zod\": \"^4.6.7\"\n },\n \"tracks\": {\n \"svelte\": {\n \"source\": \"sv-create\",\n \"reason\": \"The floor sv create's minimal template ships, so a vela project and a plain SvelteKit one start alike.\"\n }\n },\n \"holds\": {\n \"croner\": {\n \"reason\": \"11.0 is a major; the cron matching in the workflows runtime has not been checked against it.\",\n \"since\": \"2026-11-11\"\n },\n \"tailwind-variants\": {\n \"reason\": \"4.0 is a major; the shadcn-svelte components and the templates' own tv() calls have not been checked against it.\",\n \"since\": \"2026-11-11\"\n },\n \"typescript\": {\n \"reason\": \"TypeScript 7 (the native port) is outside @sveltejs/kit's peer range (^6.0.0) and breaks the install. Blocked upstream: lift once Kit admits 7.\",\n \"since\": \"2026-11-11\"\n }\n }\n}\n","import data from \"./versions.json\";\n\n/**\n * The dependency ranges every vela project starts from, in one place:\n * `versions.json` beside this file.\n *\n * Three things read it. The patterns here install from it (`spec`). The vela\n * CLI's `minimal` and `static` templates, and the velastack-templates\n * baselines built on them, list the same ranges and each carry a test that\n * they still do. And `scripts/bump-versions.ts` keeps it current.\n *\n * So a version is changed here and nowhere else; the other copies follow it,\n * and their tests fail until they do.\n */\nexport const VERSIONS: Readonly<Record<string, string>> = data.packages;\n\n/** Packages kept below their latest release on purpose, and why. */\nexport const VERSION_HOLDS: Readonly<\n Record<string, { reason: string; since: string }>\n> = data.holds;\n\n/** Packages whose range follows another project's rather than npm's latest. */\nexport const VERSION_TRACKS: Readonly<\n Record<string, { source: string; reason: string }>\n> = data.tracks;\n\n/**\n * The oldest Node a vela project may run on: the floor of its `engines.node`.\n * Projects set `engine-strict`, so no listed package may require a later one.\n */\nexport const NODE_FLOOR: string = data.node;\n\n/** The install spec for a listed package: `spec(\"zod\")` is `zod@^4.6.7`. */\nexport function spec(name: string): string {\n const range = VERSIONS[name];\n if (range === undefined) {\n throw new Error(\n `${name} is not in src/core/versions.json; add it there before installing it.`,\n );\n }\n return `${name}@${range}`;\n}\n","import { VERSIONS, spec } from \"./versions\";\n\nexport const DATA_DIR = \"data\";\nexport const MIGRATIONS_DIR = \"migrations\";\nexport const FIXTURE_PREFIX = \"vela\";\nexport const PUBLIC_DIR = \"(public)\";\nexport const APP_DIR = \"(app)\";\nexport const AUTHED_REDIRECT_PATH = \"/dashboard\";\nexport const API_URL = \"http://localhost:5173\";\n\n/**\n * The table helpers this repo ships (`data-table`, `column-header`,\n * `faceted-filter`, `data-table-pagination`) and the pages the scaffold generators emit\n * target TanStack Table v9, whose API and types are incompatible with v8; see\n * `assertTableCoreV9` for projects that still have the v8 helpers.\n */\nexport const TANSTACK_TABLE_CORE = spec(\"@tanstack/table-core\");\n\n/** The major `TANSTACK_TABLE_CORE` pins. */\nexport const TANSTACK_TABLE_CORE_MAJOR = Number(\n /\\d+/.exec(VERSIONS[\"@tanstack/table-core\"]!)![0],\n);\n\n/**\n * `file-form` and `multiselect` build on formsnap's field context. 2.1.0 is\n * the first release whose superforms peer admits 3.x; 2.0 needed an npm\n * override, which `writeResult` now removes (`reconcileFormsnap`).\n */\nexport const FORMSNAP = spec(\"formsnap\");\n\n/**\n * The superforms range a project starts on: 3.x, the line that supports\n * SvelteKit 3. A caret like any other dependency, now that formsnap 2.1 peers\n * `^3.0.0`; it was an exact version while 3.0 was a `next` prerelease, because\n * a caret on a prerelease follows every later `next` build. `writeResult`,\n * `vela migrate` and `vela bless` still move a project off one of those\n * prerelease pins (`reconcileFormsnap`).\n *\n * The name is from the exact-pin days and is kept for the CLI, which imports\n * it; the value is a range.\n */\nexport const SUPERFORMS_VERSION = VERSIONS[\"sveltekit-superforms\"]!;\n\n/**\n * What a generated superforms page needs. Vela's templates already carry\n * both; a project vela did not create may have neither.\n */\nexport const SUPERFORMS = spec(\"sveltekit-superforms\");\n\n/** The flash-message line that supports SvelteKit 3. */\nexport const FLASH = spec(\"sveltekit-flash-message\");\n\n/** The adapter `vela enable backend` moves a project to. */\nexport const ADAPTER_NODE = spec(\"@sveltejs/adapter-node\");\n\n/** The adapter a static project builds with (`vela disable backend`). */\nexport const ADAPTER_STATIC = spec(\"@sveltejs/adapter-static\");\n\n/** The VelaStack libraries' SvelteKit 3 releases. */\nexport const VELASTACK_KIT = spec(\"@velastack/kit\");\n/** 0.4.2 or later: it proxies plugin webhooks (pocketbase-whatsapp) to PocketBase. */\nexport const VELASTACK_POCKETBASE = spec(\"@velastack/pocketbase\");\nexport const VELASTACK_CMS = spec(\"@velastack/cms\");\n/** wa.me links, order messages and hosted order recording, for payments on WhatsApp. */\nexport const VELASTACK_WHATSAPP = spec(\"@velastack/whatsapp\");\nexport const NEGOTIATE = spec(\"sveltekit-negotiate\");\nexport const ZOD = spec(\"zod\");\n/** Renders HTML and CSS to an image; a native module, so it must be a dependency. */\nexport const TAKUMI = spec(\"@takumi-rs/core\");\n\n/** What `vela enable i18n` installs: wuchale and its Svelte adapter. */\nexport const WUCHALE = spec(\"wuchale\");\nexport const WUCHALE_SVELTE = spec(\"@wuchale/svelte\");\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;A,GCcaqB,IAA6CrB,EAAK,UAGlDsB,IAETtB,EAAK,OAGIuB,IAETvB,EAAK,QAMIwB,IAAqBxB,EAAK;AAGvC,SAAgByB,EAAK,GAAsB;CACzC,IAAMC,IAAQL,EAASM;CACvB,IAAID,MAAU,KAAA,GACZ,MAAU,MACR,GAAGC,EAAK,sEACV;CAEF,OAAO,GAAGA,EAAK,GAAGD;AACpB;;ACvCA,IAAaE,IAAW,QACXC,IAAiB,cAEjBC,IAAa,YACbC,IAAU,SAUVC,IAAsBP,EAAK,sBAAsB,GAGjDQ,IAA4B,OACvC,MAAM,KAAKZ,EAAS,uBAAwB,CAAC,CAAE,EACjD,GAOaa,IAAWT,EAAK,UAAU,GAa1BU,IAAqBd,EAAS,yBAM9Be,IAAaX,EAAK,sBAAsB,GAGxCY,IAAQZ,EAAK,yBAAyB,GAGtCa,IAAeb,EAAK,wBAAwB,GAG5Cc,IAAiBd,EAAK,0BAA0B,GAGhDe,IAAgBf,EAAK,gBAAgB,GAErCgB,IAAuBhB,EAAK,uBAAuB,GACnDiB,IAAgBjB,EAAK,gBAAgB,GAErCkB,IAAqBlB,EAAK,qBAAqB,GAC/CmB,IAAYnB,EAAK,qBAAqB,GACtCoB,IAAMpB,EAAK,KAAK,GAEhBqB,IAASrB,EAAK,iBAAiB,GAG/BsB,IAAUtB,EAAK,SAAS,GACxBuB,IAAiBvB,EAAK,iBAAiB"}
|
|
@@ -6,7 +6,7 @@ import { o } from "./config-target-DJbVHwHl.js";
|
|
|
6
6
|
import { t as s } from "./env-AxyRWcC_.js";
|
|
7
7
|
import { modifyEnvVarsFiles as c } from "./env-vars-CVn2076k.js";
|
|
8
8
|
import { r as l } from "./modify-file-CRZ_gMg0.js";
|
|
9
|
-
import { c as u } from "./write-result-
|
|
9
|
+
import { c as u } from "./write-result-B7MewKhQ.js";
|
|
10
10
|
import { n as d, s as f } from "./generate-CY_Ii_bz.js";
|
|
11
11
|
import p from "node:path";
|
|
12
12
|
// src/patterns/enable/ai/generate.runtime.ts
|
|
@@ -39,4 +39,4 @@ async function _(n) {
|
|
|
39
39
|
}
|
|
40
40
|
export { _ as generate };
|
|
41
41
|
|
|
42
|
-
//# sourceMappingURL=generate.runtime-
|
|
42
|
+
//# sourceMappingURL=generate.runtime-BSxSHNh7.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.runtime-
|
|
1
|
+
{"version":3,"file":"generate.runtime-BSxSHNh7.js","names":["ADAPTER_STATIC_SPEC","InvalidArgumentError","getLogger","providerEnvVars","resolveProvider","suppliedProviderEnv","modifyEnv","modifyOutcomeToFile","packageName","META","envEditsFor","path","ADAPTER_STATIC","ADAPTER_STATIC$1","STATIC_ADAPTER_MESSAGE","usesStaticAdapter","res","resolveConfigTarget","root","decl","generate","options","logger","provider","creates","modifies","envVars","modifyEnvVarsFiles","envPath","envFile"],"sources":["../../src/patterns/enable/ai/generate.runtime.ts"],"sourcesContent":["import path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { InvalidArgumentError } from \"../../../core/errors\";\nimport { getLogger } from \"../../../core/logger\";\nimport { ADAPTER_STATIC as ADAPTER_STATIC_SPEC } from \"../../../core/constants\";\nimport {\n providerEnvVars,\n resolveProvider,\n suppliedProviderEnv,\n} from \"../../../core/providers\";\nimport { resolveConfigTarget } from \"../../../runtime/config-target\";\nimport { modifyEnv } from \"../../../runtime/env\";\nimport { modifyEnvVarsFiles } from \"../../../runtime/env-vars\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { packageName } from \"../../../runtime/write-result\";\nimport { envEditsFor, META } from \"./generate\";\n\n// The config imports the package, not the versioned spec the constant installs.\nconst ADAPTER_STATIC = packageName(ADAPTER_STATIC_SPEC);\n\nexport const STATIC_ADAPTER_MESSAGE = [\n `AI needs a server, and this project builds with ${ADAPTER_STATIC}.`,\n \"The chat endpoint streams each reply from the server with a private API key, which a static site cannot do.\",\n \"Switch to a server adapter first: `vela enable backend` moves the project to @sveltejs/adapter-node.\",\n].join(\"\\n\");\n\n/**\n * Whether the SvelteKit config the project builds with imports\n * adapter-static. A config that cannot be resolved does not count: the\n * pattern only refuses what it can see.\n */\nexport function usesStaticAdapter(root: string): boolean {\n const res = resolveConfigTarget(root);\n if (res.status !== \"resolved\") return false;\n return res.target.sourceFile\n .getImportDeclarations()\n .some((decl) => decl.getModuleSpecifierValue() === ADAPTER_STATIC);\n}\n\nexport async function generate(options: Options) {\n if (usesStaticAdapter(options.root)) {\n throw new InvalidArgumentError(STATIC_ADAPTER_MESSAGE);\n }\n\n const logger = getLogger(options);\n const provider = resolveProvider(META, options);\n const creates: File[] = [];\n const modifies: File[] = [];\n\n // SvelteKit 3 exposes only declared variables: `src/lib/server/ai.ts`\n // imports the provider's key from `$app/env/private`.\n logger.info(\"Declaring the API key in src/env.ts\");\n const envVars = modifyEnvVarsFiles(options.root, providerEnvVars(provider));\n if (envVars.create) creates.push(envVars.create);\n if (envVars.modify) modifies.push(envVars.modify);\n\n logger.info(\"Updating .env\");\n const envPath = path.join(options.root, \".env\");\n const envFile = modifyOutcomeToFile(\n envPath,\n modifyEnv(envPath, envEditsFor(provider, suppliedProviderEnv(options))),\n );\n if (envFile) modifies.push(envFile);\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":";;;;;;;;;;;;AAkBA,IAAMY,IAAiBJ,EAAYR,CAAmB,GAEzCc,IAAyB;CACpC,mDAAmDF,EAAe;CAClE;CACA;AACF,CAAC,CAAC,KAAK,IAAI;AAOX,SAAgBG,EAAkB,GAAuB;CACvD,IAAMC,IAAMC,EAAoBC,CAAI;CAEpC,OADIF,EAAI,WAAW,cACZA,EAAI,OAAO,WACf,sBAAsB,CAAC,CACvB,MAAM,MAASG,EAAK,wBAAwB,MAAMP,CAAc;AACrE;AAEA,eAAsBQ,EAAS,GAAkB;CAC/C,IAAIL,EAAkBM,EAAQ,IAAI,GAChC,MAAM,IAAIpB,EAAqBa,CAAsB;CAGvD,IAAMQ,IAASpB,EAAUmB,CAAO,GAC1BE,IAAWnB,EAAgBK,GAAMY,CAAO,GACxCG,IAAkB,CAAC,GACnBC,IAAmB,CAAC;CAI1B,EAAO,KAAK,qCAAqC;CACjD,IAAMC,IAAUC,EAAmBN,EAAQ,MAAMlB,EAAgBoB,CAAQ,CAAC;CAI1E,AAHIG,EAAQ,UAAQF,EAAQ,KAAKE,EAAQ,MAAM,GAC3CA,EAAQ,UAAQD,EAAS,KAAKC,EAAQ,MAAM,GAEhDJ,EAAO,KAAK,eAAe;CAC3B,IAAMM,IAAUjB,EAAK,KAAKU,EAAQ,MAAM,MAAM,GACxCQ,IAAUtB,EACdqB,GACAtB,EAAUsB,GAASlB,EAAYa,GAAUlB,EAAoBgB,CAAO,CAAC,CAAC,CACxE;CAGA,OAFIQ,KAASJ,EAAS,KAAKI,CAAO,GAE3B;EACL;EACA;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
|