sv 0.6.26 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.js +76 -101
- package/dist/index.js +2 -2
- package/dist/{install-D7XPOwHS.js → install-CZqJBCaI.js} +60 -47
- package/dist/package-manager-BfHgHI9y.js +24314 -0
- package/dist/shared.json +1 -1
- package/dist/templates/demo/files.types=checkjs.json +1 -1
- package/dist/templates/demo/files.types=none.json +1 -1
- package/dist/templates/demo/files.types=typescript.json +1 -1
- package/dist/templates/demo/package.json +1 -1
- package/dist/testing.js +1 -1
- package/package.json +1 -1
- package/dist/package-manager-BF1V21Xa.js +0 -40227
package/dist/bin.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { Element, __commonJS, __require, __toESM, addPnpmBuildDependendencies, box, cancel, confirm, create, detect, esm_exports, from, getUserAgent, group, installDependencies, intro, isCancel, log, multiselect, note, outro, packageManagerPrompt, parseCss, parseHtml, parseHtml$1, parseJson, parseScript, parseSvelte, resolveCommand, select, spinner, templates, text, up, walk_exports } from "./package-manager-
|
|
3
|
-
import { __commonJS$1, __export, __toESM$1, addFromString, applyAddons, array_exports, common_exports, createWorkspace, dedent_default, exports_exports, formatFiles, function_exports, getHighlighter, imports_exports, kit_exports, object_exports, require_picocolors, setupAddons, variables_exports } from "./install-
|
|
2
|
+
import { Element, __commonJS, __require, __toESM, addPnpmBuildDependendencies, box, cancel, confirm, create, detect, esm_exports, from, getUserAgent, group, installDependencies, intro, isCancel, log, multiselect, note, outro, packageManagerPrompt, parseCss, parseHtml as parseHtml$1, parseHtml$1 as parseHtml, parseJson, parseScript, parseSvelte, resolveCommand, select, spinner, templates, text, up, walk_exports } from "./package-manager-BfHgHI9y.js";
|
|
3
|
+
import { __commonJS$1, __export, __toESM$1, addFromString, applyAddons, array_exports, common_exports, createWorkspace, dedent_default, exports_exports, formatFiles, function_exports, getHighlighter, imports_exports, kit_exports, object_exports, require_picocolors, setupAddons, variables_exports } from "./install-CZqJBCaI.js";
|
|
4
4
|
import fs, { existsSync } from "node:fs";
|
|
5
5
|
import path, { dirname, join } from "node:path";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
@@ -12,7 +12,7 @@ import { promisify } from "node:util";
|
|
|
12
12
|
|
|
13
13
|
//#region packages/cli/package.json
|
|
14
14
|
var name = "sv";
|
|
15
|
-
var version = "0.
|
|
15
|
+
var version = "0.7.0";
|
|
16
16
|
var type = "module";
|
|
17
17
|
var description = "A CLI for creating and updating SvelteKit projects";
|
|
18
18
|
var license = "MIT";
|
|
@@ -4160,11 +4160,19 @@ var drizzle_default = defineAddon({
|
|
|
4160
4160
|
if (options$6.mysql === "mysql2") dbSpecificContent = `
|
|
4161
4161
|
MYSQL_ROOT_PASSWORD: ${PASSWORD}
|
|
4162
4162
|
MYSQL_DATABASE: ${DB_NAME}
|
|
4163
|
+
volumes:
|
|
4164
|
+
- mysqldata:/var/lib/mysql
|
|
4165
|
+
volumes:
|
|
4166
|
+
mysqldata:
|
|
4163
4167
|
`;
|
|
4164
4168
|
if (options$6.postgresql === "postgres.js") dbSpecificContent = `
|
|
4165
4169
|
POSTGRES_USER: ${USER}
|
|
4166
4170
|
POSTGRES_PASSWORD: ${PASSWORD}
|
|
4167
4171
|
POSTGRES_DB: ${DB_NAME}
|
|
4172
|
+
volumes:
|
|
4173
|
+
- pgdata:/var/lib/postgresql/data
|
|
4174
|
+
volumes:
|
|
4175
|
+
pgdata:
|
|
4168
4176
|
`;
|
|
4169
4177
|
content = dedent_default`
|
|
4170
4178
|
services:
|
|
@@ -4210,11 +4218,11 @@ var drizzle_default = defineAddon({
|
|
|
4210
4218
|
authToken
|
|
4211
4219
|
}),
|
|
4212
4220
|
verbose: {
|
|
4213
|
-
type: "
|
|
4221
|
+
type: "Literal",
|
|
4214
4222
|
value: true
|
|
4215
4223
|
},
|
|
4216
4224
|
strict: {
|
|
4217
|
-
type: "
|
|
4225
|
+
type: "Literal",
|
|
4218
4226
|
value: true
|
|
4219
4227
|
}
|
|
4220
4228
|
});
|
|
@@ -4308,8 +4316,8 @@ var drizzle_default = defineAddon({
|
|
|
4308
4316
|
common_exports.addStatement(ast, clientIdentifier);
|
|
4309
4317
|
const drizzleCall = function_exports.callByIdentifier("drizzle", ["client"]);
|
|
4310
4318
|
const paramObject = object_exports.create({ schema: variables_exports.identifier("schema") });
|
|
4311
|
-
if (options$6.database
|
|
4312
|
-
const mode = options$6.mysql
|
|
4319
|
+
if (options$6.database === "mysql") {
|
|
4320
|
+
const mode = options$6.mysql === "planetscale" ? "planetscale" : "default";
|
|
4313
4321
|
object_exports.property(paramObject, "mode", common_exports.createLiteral(mode));
|
|
4314
4322
|
}
|
|
4315
4323
|
drizzleCall.arguments.push(paramObject);
|
|
@@ -4385,7 +4393,7 @@ function addEslintConfigPrettier(content) {
|
|
|
4385
4393
|
const nodesToInsert = [];
|
|
4386
4394
|
if (!common_exports.hasNode(eslintConfig, prettier)) nodesToInsert.push(prettier);
|
|
4387
4395
|
if (!common_exports.hasNode(eslintConfig, configSpread)) nodesToInsert.push(configSpread);
|
|
4388
|
-
const elements = eslintConfig.type
|
|
4396
|
+
const elements = eslintConfig.type === "ArrayExpression" ? eslintConfig.elements : eslintConfig.arguments;
|
|
4389
4397
|
const idx = elements.findIndex((el) => el?.type === "SpreadElement" && el.argument.type === "MemberExpression" && el.argument.object.type === "MemberExpression" && el.argument.object.property.type === "Identifier" && el.argument.object.property.name === "configs" && el.argument.object.object.type === "Identifier" && el.argument.object.object.name === svelteImportName);
|
|
4390
4398
|
if (idx !== -1) elements.splice(idx + 1, 0, ...nodesToInsert);
|
|
4391
4399
|
else elements.push(...nodesToInsert);
|
|
@@ -4435,7 +4443,7 @@ var eslint_default = defineAddon({
|
|
|
4435
4443
|
const { ast, generateCode } = parseScript(content);
|
|
4436
4444
|
const eslintConfigs = [];
|
|
4437
4445
|
imports_exports.addDefault(ast, "./svelte.config.js", "svelteConfig");
|
|
4438
|
-
const gitIgnorePathStatement = common_exports.statementFromString("\nconst gitignorePath = fileURLToPath(new URL(
|
|
4446
|
+
const gitIgnorePathStatement = common_exports.statementFromString("\nconst gitignorePath = fileURLToPath(new URL('./.gitignore', import.meta.url));");
|
|
4439
4447
|
common_exports.addStatement(ast, gitIgnorePathStatement);
|
|
4440
4448
|
const ignoresConfig = common_exports.expressionFromString("includeIgnoreFile(gitignorePath)");
|
|
4441
4449
|
eslintConfigs.push(ignoresConfig);
|
|
@@ -4451,12 +4459,25 @@ var eslint_default = defineAddon({
|
|
|
4451
4459
|
const globalsNode = common_exports.createSpreadElement(common_exports.expressionFromString("globals.node"));
|
|
4452
4460
|
const globalsObjLiteral = object_exports.createEmpty();
|
|
4453
4461
|
globalsObjLiteral.properties = [globalsBrowser, globalsNode];
|
|
4454
|
-
const
|
|
4462
|
+
const off = common_exports.createLiteral("off");
|
|
4463
|
+
const rules = object_exports.create({ "\"no-undef\"": off });
|
|
4464
|
+
if (rules.properties[0].type !== "Property") throw new Error("rules.properties[0].type !== \"Property\"");
|
|
4465
|
+
rules.properties[0].key.leadingComments = [{
|
|
4466
|
+
type: "Line",
|
|
4467
|
+
value: " typescript-eslint strongly recommend that you do not use the no-undef lint rule on TypeScript projects."
|
|
4468
|
+
}, {
|
|
4469
|
+
type: "Line",
|
|
4470
|
+
value: " see: https://typescript-eslint.io/troubleshooting/faqs/eslint/#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors"
|
|
4471
|
+
}];
|
|
4472
|
+
const globalsConfig = object_exports.create({
|
|
4473
|
+
languageOptions: object_exports.create({ globals: globalsObjLiteral }),
|
|
4474
|
+
rules: typescript ? rules : undefined
|
|
4475
|
+
});
|
|
4455
4476
|
eslintConfigs.push(globalsConfig);
|
|
4456
4477
|
if (typescript) {
|
|
4457
4478
|
const svelteTSParserConfig = object_exports.create({
|
|
4458
|
-
files: common_exports.expressionFromString("[
|
|
4459
|
-
ignores: common_exports.expressionFromString("[
|
|
4479
|
+
files: common_exports.expressionFromString("['**/*.svelte', '**/*.svelte.ts', '**/*.svelte.js']"),
|
|
4480
|
+
ignores: common_exports.expressionFromString("['eslint.config.js', 'svelte.config.js']"),
|
|
4460
4481
|
languageOptions: object_exports.create({ parserOptions: object_exports.create({
|
|
4461
4482
|
projectService: common_exports.expressionFromString("true"),
|
|
4462
4483
|
extraFileExtensions: common_exports.expressionFromString("['.svelte']"),
|
|
@@ -4467,7 +4488,7 @@ var eslint_default = defineAddon({
|
|
|
4467
4488
|
eslintConfigs.push(svelteTSParserConfig);
|
|
4468
4489
|
} else {
|
|
4469
4490
|
const svelteTSParserConfig = object_exports.create({
|
|
4470
|
-
files: common_exports.expressionFromString("[
|
|
4491
|
+
files: common_exports.expressionFromString("['**/*.svelte', '**/*.svelte.js']"),
|
|
4471
4492
|
languageOptions: object_exports.create({ parserOptions: object_exports.create({ svelteConfig: common_exports.expressionFromString("svelteConfig") }) })
|
|
4472
4493
|
});
|
|
4473
4494
|
eslintConfigs.push(svelteTSParserConfig);
|
|
@@ -4574,13 +4595,14 @@ var sveltekit_adapter_default = defineAddon({
|
|
|
4574
4595
|
let adapterName = "adapter";
|
|
4575
4596
|
if (adapterImportDecl) {
|
|
4576
4597
|
adapterImportDecl.source.value = adapter.package;
|
|
4598
|
+
adapterImportDecl.source.raw = undefined;
|
|
4577
4599
|
adapterName = adapterImportDecl.specifiers?.find((s$1) => s$1.type === "ImportDefaultSpecifier")?.local?.name;
|
|
4578
4600
|
} else imports_exports.addDefault(ast, adapter.package, adapterName);
|
|
4579
4601
|
const { value: config } = exports_exports.defaultExport(ast, object_exports.createEmpty());
|
|
4580
|
-
const kitConfig = config.properties.find((p) => p.type === "
|
|
4602
|
+
const kitConfig = config.properties.find((p) => p.type === "Property" && p.key.type === "Identifier" && p.key.name === "kit");
|
|
4581
4603
|
if (kitConfig && kitConfig.value.type === "ObjectExpression") {
|
|
4582
|
-
const adapterProp = kitConfig.value.properties.find((p) => p.type === "
|
|
4583
|
-
if (adapterProp) adapterProp.
|
|
4604
|
+
const adapterProp = kitConfig.value.properties.find((p) => p.type === "Property" && p.key.type === "Identifier" && p.key.name === "adapter");
|
|
4605
|
+
if (adapterProp) adapterProp.leadingComments = [];
|
|
4584
4606
|
object_exports.overrideProperties(kitConfig.value, { adapter: function_exports.callByIdentifier(adapterName, []) });
|
|
4585
4607
|
} else object_exports.properties(config, { kit: object_exports.create({ adapter: function_exports.callByIdentifier(adapterName, []) }) });
|
|
4586
4608
|
return generateCode();
|
|
@@ -5633,9 +5655,9 @@ var lucia_default = defineAddon({
|
|
|
5633
5655
|
sv.file(`drizzle.config.${ext}`, (content) => {
|
|
5634
5656
|
const { ast, generateCode } = parseScript(content);
|
|
5635
5657
|
const isProp = (name$1, node) => node.key.type === "Identifier" && node.key.name === name$1;
|
|
5636
|
-
walk_exports.walk(ast,
|
|
5637
|
-
if (isProp("dialect", node) && node.value.type === "
|
|
5638
|
-
if (isProp("schema", node) && node.value.type === "
|
|
5658
|
+
walk_exports.walk(ast, null, { Property(node) {
|
|
5659
|
+
if (isProp("dialect", node) && node.value.type === "Literal" && typeof node.value.value === "string") drizzleDialect = node.value.value;
|
|
5660
|
+
if (isProp("schema", node) && node.value.type === "Literal" && typeof node.value.value === "string") schemaPath = node.value.value;
|
|
5639
5661
|
} });
|
|
5640
5662
|
if (!drizzleDialect) throw new Error("Failed to detect DB dialect in your `drizzle.config.[js|ts]` file");
|
|
5641
5663
|
if (!schemaPath) throw new Error("Failed to find schema path in your `drizzle.config.[js|ts]` file");
|
|
@@ -6074,6 +6096,7 @@ function createLuciaType(name$1) {
|
|
|
6074
6096
|
type: "Identifier",
|
|
6075
6097
|
name: name$1
|
|
6076
6098
|
},
|
|
6099
|
+
computed: false,
|
|
6077
6100
|
typeAnnotation: {
|
|
6078
6101
|
type: "TSTypeAnnotation",
|
|
6079
6102
|
typeAnnotation: {
|
|
@@ -6081,7 +6104,7 @@ function createLuciaType(name$1) {
|
|
|
6081
6104
|
objectType: {
|
|
6082
6105
|
type: "TSImportType",
|
|
6083
6106
|
argument: {
|
|
6084
|
-
type: "
|
|
6107
|
+
type: "Literal",
|
|
6085
6108
|
value: "$lib/server/auth"
|
|
6086
6109
|
},
|
|
6087
6110
|
qualifier: {
|
|
@@ -6092,7 +6115,7 @@ function createLuciaType(name$1) {
|
|
|
6092
6115
|
indexType: {
|
|
6093
6116
|
type: "TSLiteralType",
|
|
6094
6117
|
literal: {
|
|
6095
|
-
type: "
|
|
6118
|
+
type: "Literal",
|
|
6096
6119
|
value: name$1
|
|
6097
6120
|
}
|
|
6098
6121
|
}
|
|
@@ -6125,7 +6148,7 @@ function getAuthHandleContent() {
|
|
|
6125
6148
|
}
|
|
6126
6149
|
function getCallExpression(ast) {
|
|
6127
6150
|
let callExpression;
|
|
6128
|
-
walk_exports.walk(ast,
|
|
6151
|
+
walk_exports.walk(ast, null, { CallExpression(node) {
|
|
6129
6152
|
callExpression ??= node;
|
|
6130
6153
|
} });
|
|
6131
6154
|
return callExpression;
|
|
@@ -6173,7 +6196,7 @@ function appendElement(childNodes, elementToAppend) {
|
|
|
6173
6196
|
childNodes.push(elementToAppend);
|
|
6174
6197
|
}
|
|
6175
6198
|
function addFromRawHtml(childNodes, html) {
|
|
6176
|
-
const document = parseHtml
|
|
6199
|
+
const document = parseHtml(html);
|
|
6177
6200
|
for (const childNode of document.childNodes) childNodes.push(childNode);
|
|
6178
6201
|
}
|
|
6179
6202
|
function addSlot(jsAst, htmlAst, svelteVersion) {
|
|
@@ -6191,22 +6214,14 @@ function addSlot(jsAst, htmlAst, svelteVersion) {
|
|
|
6191
6214
|
//#region packages/addons/paraglide/index.ts
|
|
6192
6215
|
const DEFAULT_INLANG_PROJECT = {
|
|
6193
6216
|
$schema: "https://inlang.com/schema/project-settings",
|
|
6194
|
-
modules: [
|
|
6195
|
-
|
|
6196
|
-
"https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-identical-pattern@1/dist/index.js",
|
|
6197
|
-
"https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-missing-translation@1/dist/index.js",
|
|
6198
|
-
"https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-without-source@1/dist/index.js",
|
|
6199
|
-
"https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-valid-js-identifier@1/dist/index.js",
|
|
6200
|
-
"https://cdn.jsdelivr.net/npm/@inlang/plugin-message-format@2/dist/index.js",
|
|
6201
|
-
"https://cdn.jsdelivr.net/npm/@inlang/plugin-m-function-matcher@0/dist/index.js"
|
|
6202
|
-
],
|
|
6203
|
-
"plugin.inlang.messageFormat": { pathPattern: "./messages/{languageTag}.json" }
|
|
6217
|
+
modules: ["https://cdn.jsdelivr.net/npm/@inlang/plugin-message-format@4/dist/index.js", "https://cdn.jsdelivr.net/npm/@inlang/plugin-m-function-matcher@2/dist/index.js"],
|
|
6218
|
+
"plugin.inlang.messageFormat": { pathPattern: "./messages/{locale}.json" }
|
|
6204
6219
|
};
|
|
6205
6220
|
const options$2 = defineAddonOptions({
|
|
6206
6221
|
availableLanguageTags: {
|
|
6207
6222
|
question: `Which languages would you like to support? ${colors.gray("(e.g. en,de-ch)")}`,
|
|
6208
6223
|
type: "string",
|
|
6209
|
-
default: "en",
|
|
6224
|
+
default: "en, es",
|
|
6210
6225
|
validate(input) {
|
|
6211
6226
|
const { invalidLanguageTags, validLanguageTags } = parseLanguageTagInput(input);
|
|
6212
6227
|
if (invalidLanguageTags.length > 0) if (invalidLanguageTags.length === 1) return `The input "${invalidLanguageTags[0]}" is not a valid IETF BCP 47 language tag`;
|
|
@@ -6230,30 +6245,30 @@ else {
|
|
|
6230
6245
|
var paraglide_default = defineAddon({
|
|
6231
6246
|
id: "paraglide",
|
|
6232
6247
|
shortDescription: "i18n",
|
|
6233
|
-
homepage: "https://inlang.com",
|
|
6248
|
+
homepage: "https://inlang.com/m/gerre34r/library-inlang-paraglideJs",
|
|
6234
6249
|
options: options$2,
|
|
6235
6250
|
setup: ({ kit, unsupported }) => {
|
|
6236
6251
|
if (!kit) unsupported("Requires SvelteKit");
|
|
6237
6252
|
},
|
|
6238
|
-
run: ({ sv, options: options$6, typescript, kit
|
|
6253
|
+
run: ({ sv, options: options$6, typescript, kit }) => {
|
|
6239
6254
|
const ext = typescript ? "ts" : "js";
|
|
6240
6255
|
if (!kit) throw new Error("SvelteKit is required");
|
|
6241
6256
|
const paraglideOutDir = "src/lib/paraglide";
|
|
6242
|
-
sv.dependency("@inlang/paraglide-
|
|
6257
|
+
sv.dependency("@inlang/paraglide-js", "^2.0.0");
|
|
6243
6258
|
sv.file("project.inlang/settings.json", (content) => {
|
|
6244
6259
|
if (content) return content;
|
|
6245
6260
|
const { data, generateCode } = parseJson(content);
|
|
6246
6261
|
for (const key in DEFAULT_INLANG_PROJECT) data[key] = DEFAULT_INLANG_PROJECT[key];
|
|
6247
6262
|
const { validLanguageTags: validLanguageTags$1 } = parseLanguageTagInput(options$6.availableLanguageTags);
|
|
6248
|
-
const
|
|
6249
|
-
data.
|
|
6250
|
-
data.
|
|
6263
|
+
const baseLocale = validLanguageTags$1[0];
|
|
6264
|
+
data.baseLocale = baseLocale;
|
|
6265
|
+
data.locales = validLanguageTags$1;
|
|
6251
6266
|
return generateCode();
|
|
6252
6267
|
});
|
|
6253
6268
|
sv.file(`vite.config.${ext}`, (content) => {
|
|
6254
6269
|
const { ast, generateCode } = parseScript(content);
|
|
6255
|
-
const vitePluginName = "
|
|
6256
|
-
imports_exports.addNamed(ast, "@inlang/paraglide-
|
|
6270
|
+
const vitePluginName = "paraglideVitePlugin";
|
|
6271
|
+
imports_exports.addNamed(ast, "@inlang/paraglide-js", { paraglideVitePlugin: vitePluginName });
|
|
6257
6272
|
const { value: rootObject } = exports_exports.defaultExport(ast, function_exports.call("defineConfig", []));
|
|
6258
6273
|
const param1 = function_exports.argumentByIndex(rootObject, 0, object_exports.createEmpty());
|
|
6259
6274
|
const pluginsArray = object_exports.property(param1, "plugins", array_exports.createEmpty());
|
|
@@ -6266,20 +6281,10 @@ var paraglide_default = defineAddon({
|
|
|
6266
6281
|
array_exports.push(pluginsArray, pluginFunctionCall);
|
|
6267
6282
|
return generateCode();
|
|
6268
6283
|
});
|
|
6269
|
-
sv.file(`src/lib/i18n.${ext}`, (content) => {
|
|
6270
|
-
const { ast, generateCode } = parseScript(content);
|
|
6271
|
-
imports_exports.addNamed(ast, "@inlang/paraglide-sveltekit", { createI18n: "createI18n" });
|
|
6272
|
-
imports_exports.addDefault(ast, "$lib/paraglide/runtime", "* as runtime");
|
|
6273
|
-
const createI18nExpression = common_exports.expressionFromString("createI18n(runtime)");
|
|
6274
|
-
const i18n = variables_exports.declaration(ast, "const", "i18n", createI18nExpression);
|
|
6275
|
-
const existingExport = exports_exports.namedExport(ast, "i18n", i18n);
|
|
6276
|
-
if (existingExport.declaration !== i18n) log$1.warn("Setting up $lib/i18n failed because it already exports an i18n function");
|
|
6277
|
-
return generateCode();
|
|
6278
|
-
});
|
|
6279
6284
|
sv.file(`src/hooks.${ext}`, (content) => {
|
|
6280
6285
|
const { ast, generateCode } = parseScript(content);
|
|
6281
|
-
imports_exports.addNamed(ast, "$lib/
|
|
6282
|
-
const expression = common_exports.expressionFromString("
|
|
6286
|
+
imports_exports.addNamed(ast, "$lib/paraglide/runtime", { deLocalizeUrl: "deLocalizeUrl" });
|
|
6287
|
+
const expression = common_exports.expressionFromString("(request) => deLocalizeUrl(request.url).pathname");
|
|
6283
6288
|
const rerouteIdentifier = variables_exports.declaration(ast, "const", "reroute", expression);
|
|
6284
6289
|
const existingExport = exports_exports.namedExport(ast, "reroute", rerouteIdentifier);
|
|
6285
6290
|
if (existingExport.declaration !== rerouteIdentifier) log$1.warn("Adding the reroute hook automatically failed. Add it manually");
|
|
@@ -6287,34 +6292,18 @@ var paraglide_default = defineAddon({
|
|
|
6287
6292
|
});
|
|
6288
6293
|
sv.file(`src/hooks.server.${ext}`, (content) => {
|
|
6289
6294
|
const { ast, generateCode } = parseScript(content);
|
|
6290
|
-
imports_exports.addNamed(ast, "$lib/
|
|
6291
|
-
const hookHandleContent =
|
|
6295
|
+
imports_exports.addNamed(ast, "$lib/paraglide/server", { paraglideMiddleware: "paraglideMiddleware" });
|
|
6296
|
+
const hookHandleContent = `({ event, resolve }) => paraglideMiddleware(event.request, ({ request, locale }) => {
|
|
6297
|
+
event.request = request;
|
|
6298
|
+
return resolve(event, {
|
|
6299
|
+
transformPageChunk: ({ html }) => html.replace('%paraglide.lang%', locale)
|
|
6300
|
+
});
|
|
6301
|
+
});`;
|
|
6292
6302
|
kit_exports.addHooksHandle(ast, typescript, "handleParaglide", hookHandleContent);
|
|
6293
6303
|
return generateCode();
|
|
6294
6304
|
});
|
|
6295
|
-
sv.file(`${kit.routesDirectory}/+layout.svelte`, (content) => {
|
|
6296
|
-
const { script, template, generateCode } = parseSvelte(content, { typescript });
|
|
6297
|
-
const paraglideComponentName = "ParaglideJS";
|
|
6298
|
-
imports_exports.addNamed(script.ast, "@inlang/paraglide-sveltekit", { [paraglideComponentName]: paraglideComponentName });
|
|
6299
|
-
imports_exports.addNamed(script.ast, "$lib/i18n", { i18n: "i18n" });
|
|
6300
|
-
if (template.source.length === 0) {
|
|
6301
|
-
const svelteVersion = dependencyVersion("svelte");
|
|
6302
|
-
if (!svelteVersion) throw new Error("Failed to determine svelte version");
|
|
6303
|
-
addSlot(script.ast, template.ast, svelteVersion);
|
|
6304
|
-
}
|
|
6305
|
-
const templateCode = new MagicString(template.generateCode());
|
|
6306
|
-
if (!templateCode.original.includes("<ParaglideJS")) {
|
|
6307
|
-
templateCode.indent();
|
|
6308
|
-
templateCode.prepend("<ParaglideJS {i18n}>\n");
|
|
6309
|
-
templateCode.append("\n</ParaglideJS>");
|
|
6310
|
-
}
|
|
6311
|
-
return generateCode({
|
|
6312
|
-
script: script.generateCode(),
|
|
6313
|
-
template: templateCode.toString()
|
|
6314
|
-
});
|
|
6315
|
-
});
|
|
6316
6305
|
sv.file("src/app.html", (content) => {
|
|
6317
|
-
const { ast, generateCode } = parseHtml(content);
|
|
6306
|
+
const { ast, generateCode } = parseHtml$1(content);
|
|
6318
6307
|
const htmlNode = ast.children.find((child) => child.type === esm_exports.Tag && child.name === "html");
|
|
6319
6308
|
if (!htmlNode) {
|
|
6320
6309
|
log$1.warn("Could not find <html> node in app.html. You'll need to add the language placeholder manually");
|
|
@@ -6322,8 +6311,7 @@ var paraglide_default = defineAddon({
|
|
|
6322
6311
|
}
|
|
6323
6312
|
htmlNode.attribs = {
|
|
6324
6313
|
...htmlNode.attribs,
|
|
6325
|
-
lang: "%paraglide.lang%"
|
|
6326
|
-
dir: "%paraglide.textDirection%"
|
|
6314
|
+
lang: "%paraglide.lang%"
|
|
6327
6315
|
};
|
|
6328
6316
|
return generateCode();
|
|
6329
6317
|
});
|
|
@@ -6338,32 +6326,17 @@ var paraglide_default = defineAddon({
|
|
|
6338
6326
|
});
|
|
6339
6327
|
sv.file(`${kit.routesDirectory}/demo/paraglide/+page.svelte`, (content) => {
|
|
6340
6328
|
const { script, template, generateCode } = parseSvelte(content, { typescript });
|
|
6341
|
-
imports_exports.
|
|
6329
|
+
imports_exports.addNamed(script.ast, "$lib/paraglide/messages.js", { m: "m" });
|
|
6342
6330
|
imports_exports.addNamed(script.ast, "$app/navigation", { goto: "goto" });
|
|
6343
6331
|
imports_exports.addNamed(script.ast, "$app/state", { page: "page" });
|
|
6344
|
-
imports_exports.addNamed(script.ast, "$lib/
|
|
6345
|
-
if (typescript) imports_exports.addNamed(script.ast, "$lib/paraglide/runtime", { AvailableLanguageTag: "AvailableLanguageTag" }, true);
|
|
6346
|
-
const [ts] = utils_exports.createPrinter(typescript);
|
|
6332
|
+
imports_exports.addNamed(script.ast, "$lib/paraglide/runtime", { setLocale: "setLocale" });
|
|
6347
6333
|
const scriptCode = new MagicString(script.generateCode());
|
|
6348
|
-
if (!scriptCode.original.includes("function switchToLanguage")) {
|
|
6349
|
-
scriptCode.trim();
|
|
6350
|
-
scriptCode.append("\n\n");
|
|
6351
|
-
scriptCode.append(dedent_default`
|
|
6352
|
-
${ts("", "/**")}
|
|
6353
|
-
${ts("", "* @param {import(\"$lib/paraglide/runtime\").AvailableLanguageTag} newLanguage")}
|
|
6354
|
-
${ts("", "*/")}
|
|
6355
|
-
function switchToLanguage(newLanguage${ts(": AvailableLanguageTag")}) {
|
|
6356
|
-
const canonicalPath = i18n.route(page.url.pathname);
|
|
6357
|
-
const localisedPath = i18n.resolveRoute(canonicalPath, newLanguage);
|
|
6358
|
-
goto(localisedPath);
|
|
6359
|
-
}
|
|
6360
|
-
`);
|
|
6361
|
-
}
|
|
6362
6334
|
const templateCode = new MagicString(template.source);
|
|
6363
6335
|
templateCode.append("\n\n<h1>{m.hello_world({ name: 'SvelteKit User' })}</h1>\n");
|
|
6364
6336
|
const { validLanguageTags: validLanguageTags$1 } = parseLanguageTagInput(options$6.availableLanguageTags);
|
|
6365
|
-
const links = validLanguageTags$1.map((x) => `${templateCode.getIndentString()}<button onclick={() =>
|
|
6337
|
+
const links = validLanguageTags$1.map((x) => `${templateCode.getIndentString()}<button onclick={() => setLocale('${x}')}>${x}</button>`).join("\n");
|
|
6366
6338
|
templateCode.append(`<div>\n${links}\n</div>`);
|
|
6339
|
+
templateCode.append("<p>\nIf you use VSCode, install the <a href=\"https://marketplace.visualstudio.com/items?itemName=inlang.vs-code-extension\" target=\"_blank\">Sherlock i18n extension</a> for a better i18n experience.\n</p>");
|
|
6367
6340
|
return generateCode({
|
|
6368
6341
|
script: scriptCode.toString(),
|
|
6369
6342
|
template: templateCode.toString()
|
|
@@ -6379,7 +6352,7 @@ var paraglide_default = defineAddon({
|
|
|
6379
6352
|
});
|
|
6380
6353
|
},
|
|
6381
6354
|
nextSteps: ({ highlighter }) => {
|
|
6382
|
-
const steps = [`Edit your messages in ${highlighter.path("messages/en.json")}
|
|
6355
|
+
const steps = [`Edit your messages in ${highlighter.path("messages/en.json")}`];
|
|
6383
6356
|
if (options$2.demo) steps.push(`Visit ${highlighter.route("/demo/paraglide")} route to view the demo`);
|
|
6384
6357
|
return steps;
|
|
6385
6358
|
}
|
|
@@ -6472,6 +6445,8 @@ var prettier_default = defineAddon({
|
|
|
6472
6445
|
package-lock.json
|
|
6473
6446
|
pnpm-lock.yaml
|
|
6474
6447
|
yarn.lock
|
|
6448
|
+
bun.lock
|
|
6449
|
+
bun.lockb
|
|
6475
6450
|
`;
|
|
6476
6451
|
});
|
|
6477
6452
|
sv.file(".prettierrc", (content) => {
|
|
@@ -6876,7 +6851,7 @@ function getPadding(lines) {
|
|
|
6876
6851
|
return Math.max(...lengths);
|
|
6877
6852
|
}
|
|
6878
6853
|
function forwardExitCode(error) {
|
|
6879
|
-
if (error && typeof error === "object" && "status" in error && typeof error.status
|
|
6854
|
+
if (error && typeof error === "object" && "status" in error && typeof error.status === "number") process$1.exit(error.status);
|
|
6880
6855
|
else process$1.exit(1);
|
|
6881
6856
|
}
|
|
6882
6857
|
|
package/dist/index.js
CHANGED