sv 0.16.2 → 0.16.3

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.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { _ as name, a as detectPackageManager, d as Command, g as helpConfig, h as forwardExitCode, l as from, n as add, r as create, u as program, v as version } from "./engine-2Sa2F6eX.mjs";
2
+ import { _ as name, a as detectPackageManager, d as Command, g as helpConfig, h as forwardExitCode, l as from, n as add, r as create, u as program, v as version } from "./engine-B1KphrBP.mjs";
3
3
  import { color, resolveCommandArray } from "@sveltejs/sv-utils";
4
4
  import V from "node:process";
5
5
  import { execSync } from "node:child_process";
@@ -1348,7 +1348,7 @@ ${i ? styleText("cyan", x$1) : ""}
1348
1348
  //#endregion
1349
1349
  //#region package.json
1350
1350
  var name = "sv";
1351
- var version = "0.16.2";
1351
+ var version = "0.16.3";
1352
1352
  //#endregion
1353
1353
  //#region src/core/errors.ts
1354
1354
  var UnsupportedError = class extends Error {
@@ -7164,9 +7164,14 @@ var paraglide_default = defineAddon({
7164
7164
  setup: ({ isKit, unsupported }) => {
7165
7165
  if (!isKit) unsupported("Requires SvelteKit");
7166
7166
  },
7167
- run: ({ sv, options, file, language, directory }) => {
7167
+ run: ({ sv, options, file, language, directory, cwd, dependencyVersion }) => {
7168
7168
  const [ts] = createPrinter(language === "ts");
7169
7169
  const paraglideOutDir = `${directory.lib}/paraglide`;
7170
+ const env = defineEnv({
7171
+ sv,
7172
+ cwd,
7173
+ dependencyVersion
7174
+ });
7170
7175
  sv.devDependency("@inlang/paraglide-js", "^2.18.2");
7171
7176
  sv.file(file.viteConfig, transforms.script(({ ast, js }) => {
7172
7177
  const vitePluginName = "paraglideVitePlugin";
@@ -7175,9 +7180,10 @@ var paraglide_default = defineAddon({
7175
7180
  from: "@inlang/paraglide-js"
7176
7181
  });
7177
7182
  js.vite.addPlugin(ast, { code: `${vitePluginName}({
7178
- project: './project.inlang',
7179
- outdir: './${paraglideOutDir}'
7180
- })` });
7183
+ project: './project.inlang',
7184
+ outdir: './${paraglideOutDir}',
7185
+ strategy: ['url']
7186
+ })` });
7181
7187
  }));
7182
7188
  sv.file(`src/hooks.${language}`, transforms.script(({ ast, comments, js }) => {
7183
7189
  js.imports.addNamed(ast, {
@@ -7232,11 +7238,66 @@ var paraglide_default = defineAddon({
7232
7238
  html.addAttribute(htmlNode, "lang", "%paraglide.lang%");
7233
7239
  html.addAttribute(htmlNode, "dir", "%paraglide.dir%");
7234
7240
  }));
7235
- sv.file(file.gitignore, transforms.text(({ content, text }) => {
7236
- if (!content) return false;
7237
- content = text.upsert(content, paraglideOutDir, { comment: "Paraglide" });
7238
- content = text.upsert(content, "project.inlang/cache/");
7239
- return content;
7241
+ sv.file(`${directory.lib}/paraglide.svelte.${language}`, transforms.script(({ ast, js, comments }) => {
7242
+ js.imports.addNamed(ast, {
7243
+ imports: [
7244
+ "baseLocale",
7245
+ "localizeUrl",
7246
+ "overwriteGetLocale",
7247
+ "overwriteSetLocale",
7248
+ "toLocale"
7249
+ ],
7250
+ from: "$lib/paraglide/runtime"
7251
+ });
7252
+ js.imports.addNamed(ast, {
7253
+ imports: ["page"],
7254
+ from: "$app/state"
7255
+ });
7256
+ js.imports.addNamed(ast, {
7257
+ imports: ["goto"],
7258
+ from: "$app/navigation"
7259
+ });
7260
+ env.importEnv(ast, js, ["browser"]);
7261
+ if (language === "ts") js.imports.addNamed(ast, {
7262
+ imports: { Locale: "_Locale" },
7263
+ from: "$lib/paraglide/runtime",
7264
+ isType: true
7265
+ });
7266
+ const codeBlock = dedent`
7267
+ export class Locale {
7268
+ #current${ts(": _Locale")} = $state(toLocale(browser && document.querySelector('html')?.lang) ?? baseLocale);
7269
+ constructor() {
7270
+ overwriteGetLocale(() => this.#current);
7271
+ overwriteSetLocale((locale) => {
7272
+ this.#current = locale;
7273
+ goto(localizeUrl(page.url.pathname, { locale }).href);
7274
+ });
7275
+ }
7276
+ }`;
7277
+ js.common.appendFromString(ast, {
7278
+ code: codeBlock,
7279
+ comments
7280
+ });
7281
+ }));
7282
+ sv.file(`src/hooks.client.${language}`, transforms.script(({ ast, comments, js }) => {
7283
+ js.imports.addNamed(ast, {
7284
+ imports: ["Locale"],
7285
+ from: "$lib/paraglide.svelte"
7286
+ });
7287
+ if (language === "ts") js.imports.addNamed(ast, {
7288
+ imports: ["ClientInit"],
7289
+ from: "@sveltejs/kit",
7290
+ isType: true
7291
+ });
7292
+ const init = dedent`
7293
+ export const init${ts(": ClientInit")} = () => {
7294
+ new Locale()
7295
+ }
7296
+ `;
7297
+ js.common.appendFromString(ast, {
7298
+ code: init,
7299
+ comments
7300
+ });
7240
7301
  }));
7241
7302
  sv.file("project.inlang/settings.json", transforms.json(({ data }) => {
7242
7303
  if (Object.keys(data).length > 0) return false;
@@ -1,4 +1,4 @@
1
- import { c as defineAddonOptions, m as create$1, o as officialAddons, s as defineAddon, t as add, y as svDeprecated } from "../engine-2Sa2F6eX.mjs";
1
+ import { c as defineAddonOptions, m as create$1, o as officialAddons, s as defineAddon, t as add, y as svDeprecated } from "../engine-B1KphrBP.mjs";
2
2
  //#region src/index.ts
3
3
  function create(cwdOrOptions, legacyOptions) {
4
4
  if (typeof cwdOrOptions === "string") {
@@ -1,4 +1,4 @@
1
- import { S as __toESM, b as __commonJSMin, f as R, i as addPnpmAllowBuilds, m as create, p as z, t as add, x as __require } from "../engine-2Sa2F6eX.mjs";
1
+ import { S as __toESM, b as __commonJSMin, f as R, i as addPnpmAllowBuilds, m as create, p as z, t as add, x as __require } from "../engine-B1KphrBP.mjs";
2
2
  import fs from "node:fs";
3
3
  import path from "node:path";
4
4
  import V from "node:process";
@@ -22,14 +22,15 @@
22
22
  "access": "public"
23
23
  },
24
24
  "peerDependencies": {
25
- "sv": "^0.16.2"
25
+ "sv": "^0.16.3"
26
26
  },
27
27
  "devDependencies": {
28
- "sv": "^0.16.2",
28
+ "sv": "^0.16.3",
29
29
  "@sveltejs/sv-utils": "^0.3.1",
30
30
  "@playwright/test": "^1.60.0",
31
31
  "@types/node": "^25.9.1",
32
32
  "tsdown": "^0.22.1",
33
+ "unrun": "^0.2.39",
33
34
  "vitest": "^4.1.8"
34
35
  },
35
36
  "keywords": ["sv-add", "svelte", "sveltekit"]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sv",
3
- "version": "0.16.2",
3
+ "version": "0.16.3",
4
4
  "type": "module",
5
5
  "description": "A command line interface (CLI) for creating and maintaining Svelte applications",
6
6
  "license": "MIT",