@inlang/paraglide-js 2.28.0 → 2.29.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/bundler-plugins/unplugin.d.ts +4 -1
- package/dist/bundler-plugins/unplugin.js +55 -12
- package/dist/bundler-plugins/unplugin.js.map +1 -1
- package/dist/bundler-plugins/unplugin.test.js +156 -0
- package/dist/bundler-plugins/unplugin.test.js.map +1 -1
- package/dist/bundler-plugins/vite-error-response.test.d.ts +1 -0
- package/dist/bundler-plugins/vite-error-response.test.js +171 -0
- package/dist/bundler-plugins/vite-error-response.test.js.map +1 -0
- package/dist/bundler-plugins/vite.d.ts +8 -0
- package/dist/bundler-plugins/vite.js +14 -5
- package/dist/bundler-plugins/vite.js.map +1 -1
- package/dist/compiler/runtime/localize-url.d.ts +8 -4
- package/dist/compiler/runtime/localize-url.js +12 -8
- package/dist/compiler/runtime/localize-url.js.map +1 -1
- package/dist/compiler/runtime/localize-url.test.js +45 -0
- package/dist/compiler/runtime/localize-url.test.js.map +1 -1
- package/dist/compiler/runtime/type.test.js +41 -0
- package/dist/compiler/runtime/type.test.js.map +1 -1
- package/dist/services/env-variables/index.js +1 -1
- package/dist/services/env-variables/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,51 @@
|
|
|
1
1
|
import { test, expect } from "vitest";
|
|
2
2
|
import { createParaglide } from "../create-paraglide.js";
|
|
3
3
|
import { newProject } from "@inlang/sdk";
|
|
4
|
+
test.each([
|
|
5
|
+
{ name: "default patterns", urlPatterns: undefined },
|
|
6
|
+
{
|
|
7
|
+
name: "custom patterns",
|
|
8
|
+
urlPatterns: [
|
|
9
|
+
{
|
|
10
|
+
pattern: "/about",
|
|
11
|
+
localized: [
|
|
12
|
+
["en", "/about"],
|
|
13
|
+
["de", "/de/ueber"],
|
|
14
|
+
],
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
])("accepts readonly URL inputs with $name", async ({ urlPatterns }) => {
|
|
19
|
+
const runtime = await createParaglide({
|
|
20
|
+
blob: await newProject({
|
|
21
|
+
settings: { baseLocale: "en", locales: ["en", "de"] },
|
|
22
|
+
}),
|
|
23
|
+
strategy: ["url"],
|
|
24
|
+
urlPatterns,
|
|
25
|
+
});
|
|
26
|
+
// Match SvelteKit 3's page.url type, including readonly search parameters.
|
|
27
|
+
const input = new URL("https://example.com/about?q=one&q=two#section");
|
|
28
|
+
const before = input.href;
|
|
29
|
+
const localized = runtime.localizeUrl(input, { locale: "de" });
|
|
30
|
+
expect(localized.href).toBe(urlPatterns
|
|
31
|
+
? "https://example.com/de/ueber?q=one&q=two#section"
|
|
32
|
+
: "https://example.com/de/about?q=one&q=two#section");
|
|
33
|
+
expect(runtime.deLocalizeUrl(Object.freeze({ href: localized.href })).href).toBe(before);
|
|
34
|
+
expect(input.href).toBe(before);
|
|
35
|
+
// A URL-like object must never leak out of the unmatched-pattern fallback.
|
|
36
|
+
const unmatched = Object.freeze({
|
|
37
|
+
href: "https://example.com/assets/?q=one&q=two#section",
|
|
38
|
+
});
|
|
39
|
+
for (const result of [
|
|
40
|
+
runtime.localizeUrl(unmatched, { locale: "en" }),
|
|
41
|
+
runtime.deLocalizeUrl(unmatched),
|
|
42
|
+
]) {
|
|
43
|
+
expect(result).toBeInstanceOf(URL);
|
|
44
|
+
expect(result.href).toBe(unmatched.href);
|
|
45
|
+
result.searchParams.set("q", "changed");
|
|
46
|
+
expect(unmatched.href).toBe("https://example.com/assets/?q=one&q=two#section");
|
|
47
|
+
}
|
|
48
|
+
});
|
|
4
49
|
test("pathname based localization", async () => {
|
|
5
50
|
const runtime = await createParaglide({
|
|
6
51
|
blob: await newProject({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localize-url.test.js","sourceRoot":"","sources":["../../../src/compiler/runtime/localize-url.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;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C,WAAW,CAAC,6BAA6B,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CACzE,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAC;IAEtC,oEAAoE;IACpE,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,gCAAgC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CACxE,6BAA6B,CAC7B,CAAC;AACH,CAAC,CAAC,CAAC","sourcesContent":["import { test, expect } from \"vitest\";\nimport { createParaglide } from \"../create-paraglide.js\";\nimport { newProject } from \"@inlang/sdk\";\n\ntest(\"pathname based localization\", async () => {\n\tconst runtime = await createParaglide({\n\t\tblob: await newProject({\n\t\t\tsettings: {\n\t\t\t\tbaseLocale: \"en\",\n\t\t\t\tlocales: [\"en\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"url\"],\n\t\turlPatterns: [\n\t\t\t// literal match\n\t\t\t{\n\t\t\t\tpattern: \"/blog/about\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"en\", \"/blog/about\"],\n\t\t\t\t\t[\"de\", \"/de/artikel/ueber-uns\"],\n\t\t\t\t],\n\t\t\t},\n\t\t\t// parameter\n\t\t\t{\n\t\t\t\tpattern: \"/blog/:id\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"en\", \"/blog/:id\"],\n\t\t\t\t\t[\"de\", \"/de/artikel/:id\"],\n\t\t\t\t],\n\t\t\t},\n\t\t\t// wildcard\n\t\t\t{\n\t\t\t\tpattern: \"/:path(.*)\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"de\", \"/de/:path(.*)\"],\n\t\t\t\t\t[\"en\", \"/:path(.*)\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\t// wildcard - en to de\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/home\", { locale: \"de\" }).href\n\t).toBe(\"https://example.com/de/home\");\n\n\t// wildcard - de to en\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/de/home\", { locale: \"en\" }).href\n\t).toBe(\"https://example.com/home\");\n\n\t// wildcard - en to en\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/about\", { locale: \"en\" }).href\n\t).toBe(\"https://example.com/about\");\n\n\t// wildcard - delocalizing de\n\texpect(runtime.deLocalizeUrl(\"https://example.com/de/about\").href).toBe(\n\t\t\"https://example.com/about\"\n\t);\n\n\t// literal match\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/blog/about\", { locale: \"de\" }).href\n\t).toBe(\"https://example.com/de/artikel/ueber-uns\");\n\n\texpect(\n\t\truntime.deLocalizeUrl(\"https://example.com/de/artikel/ueber-uns\").href\n\t).toBe(\"https://example.com/blog/about\");\n\n\t// parameter matching\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/blog/56\", { locale: \"de\" }).href\n\t).toBe(\"https://example.com/de/artikel/56\");\n\n\texpect(runtime.deLocalizeUrl(\"https://example.com/de/artikel/56\").href).toBe(\n\t\t\"https://example.com/blog/56\"\n\t);\n});\n\n// https://github.com/opral/paraglide-js/issues/473\ntest(\"normalizes trailing slashes before matching translated pathnames\", async () => {\n\tconst runtime = await createParaglide({\n\t\tblob: await newProject({\n\t\t\tsettings: {\n\t\t\t\tbaseLocale: \"en\",\n\t\t\t\tlocales: [\"en\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"url\", \"baseLocale\"],\n\t\ttrailingSlash: \"never\",\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \"/\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"de\", \"/de\"],\n\t\t\t\t\t[\"en\", \"/\"],\n\t\t\t\t],\n\t\t\t},\n\t\t\t{\n\t\t\t\tpattern: \"/about\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"de\", \"/de/ueber\"],\n\t\t\t\t\t[\"en\", \"/about\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\texpect(runtime.trailingSlash).toBe(\"never\");\n\texpect(\"normalizeTrailingSlash\" in runtime).toBe(false);\n\texpect(\"execUrlPattern\" in runtime).toBe(false);\n\texpect(runtime.extractLocaleFromUrl(\"https://example.com/de/\")).toBe(\"de\");\n\texpect(runtime.extractLocaleFromUrl(\"https://example.com/de/ueber/\")).toBe(\n\t\t\"de\"\n\t);\n\texpect(runtime.deLocalizeUrl(\"https://example.com/de/\").href).toBe(\n\t\t\"https://example.com/\"\n\t);\n\texpect(runtime.deLocalizeUrl(\"https://example.com/de/ueber/\").href).toBe(\n\t\t\"https://example.com/about\"\n\t);\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/about/\", { locale: \"de\" }).href\n\t).toBe(\"https://example.com/de/ueber\");\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/about/?ref=docs#section\", {\n\t\t\tlocale: \"de\",\n\t\t}).href\n\t).toBe(\"https://example.com/de/ueber?ref=docs#section\");\n});\n\ntest(\"adds trailing slashes when configured\", async () => {\n\tconst runtime = await createParaglide({\n\t\tblob: await newProject({\n\t\t\tsettings: {\n\t\t\t\tbaseLocale: \"en\",\n\t\t\t\tlocales: [\"en\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"url\"],\n\t\ttrailingSlash: \"always\",\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\t// Existing patterns do not need to be rewritten for the policy.\n\t\t\t\tpattern: \"/about\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"de\", \"/de/ueber\"],\n\t\t\t\t\t[\"en\", \"/about\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/about\", { locale: \"de\" }).href\n\t).toBe(\"https://example.com/de/ueber/\");\n\texpect(runtime.deLocalizeUrl(\"https://example.com/de/ueber\").href).toBe(\n\t\t\"https://example.com/about/\"\n\t);\n});\n\ntest(\"does not include a canonical trailing slash in wildcard captures\", async () => {\n\tconst runtime = await createParaglide({\n\t\tblob: await newProject({\n\t\t\tsettings: {\n\t\t\t\tbaseLocale: \"en\",\n\t\t\t\tlocales: [\"en\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"url\"],\n\t\ttrailingSlash: \"always\",\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \"/:path(.*)\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"de\", \"/de/:path(.*)/details\"],\n\t\t\t\t\t[\"en\", \"/:path(.*)\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/foo\", { locale: \"de\" }).href\n\t).toBe(\"https://example.com/de/foo/details/\");\n\texpect(runtime.deLocalizeUrl(\"https://example.com/de/foo/details\").href).toBe(\n\t\t\"https://example.com/foo/\"\n\t);\n});\n\ntest(\"keeps unmatched custom URLs unchanged\", async () => {\n\tconst runtime = await createParaglide({\n\t\tblob: await newProject({\n\t\t\tsettings: {\n\t\t\t\tbaseLocale: \"en\",\n\t\t\t\tlocales: [\"en\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"url\"],\n\t\ttrailingSlash: \"never\",\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \"/about\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"en\", \"/about\"],\n\t\t\t\t\t[\"de\", \"/de/ueber\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\tconst input = new URL(\"https://example.com/assets/\");\n\texpect(runtime.localizeUrl(input, { locale: \"de\" })).toBe(input);\n\texpect(runtime.deLocalizeUrl(input)).toBe(input);\n\texpect(input.href).toBe(\"https://example.com/assets/\");\n});\n\ntest(\"omitting trailingSlash preserves exact custom pattern matching\", async () => {\n\tconst runtime = await createParaglide({\n\t\tblob: await newProject({\n\t\t\tsettings: {\n\t\t\t\tbaseLocale: \"en\",\n\t\t\t\tlocales: [\"en\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"url\"],\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \"/about\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"en\", \"/about\"],\n\t\t\t\t\t[\"de\", \"/de/ueber\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\tconst input = new URL(\"https://example.com/de/ueber/\");\n\texpect(runtime.trailingSlash).toBeUndefined();\n\texpect(runtime.extractLocaleFromUrl(input)).toBeUndefined();\n\texpect(runtime.deLocalizeUrl(input)).toBe(input);\n});\n\ntest(\"cross domain urls\", async () => {\n\tconst runtime = await createParaglide({\n\t\tblob: await newProject({\n\t\t\tsettings: {\n\t\t\t\tbaseLocale: \"en\",\n\t\t\t\tlocales: [\"en\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"url\"],\n\t\turlPatterns: [\n\t\t\t// Development/deployment mapping\n\t\t\t{\n\t\t\t\tpattern: \"https://localhost::port/:path*\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"de\", \"https://localhost::port/de/:path*\"],\n\t\t\t\t\t[\"en\", \"https://localhost::port/:path*\"],\n\t\t\t\t],\n\t\t\t},\n\t\t\t// Domain based localization\n\t\t\t{\n\t\t\t\tpattern: \"https://example.com/:path*\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"en\", \"https://example.com/:path*\"],\n\t\t\t\t\t[\"de\", \"https://de.example.com/:path*\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\t// in development use localhost with different mapping\n\texpect(\n\t\truntime.localizeUrl(\"https://localhost:5173/about\", { locale: \"de\" }).href\n\t).toBe(\"https://localhost:5173/de/about\");\n\n\texpect(\n\t\truntime.localizeUrl(\"https://localhost:5173/about\", { locale: \"en\" }).href\n\t).toBe(\"https://localhost:5173/about\");\n\n\texpect(runtime.deLocalizeUrl(\"https://localhost:5173/de/about\").href).toBe(\n\t\t\"https://localhost:5173/about\"\n\t);\n\n\t// DE routing\n\texpect(\n\t\truntime.localizeUrl(\"https://de.example.com/about\", { locale: \"de\" }).href\n\t).toBe(\"https://de.example.com/about\");\n\n\texpect(\n\t\truntime.localizeUrl(\"https://de.example.com/about\", { locale: \"en\" }).href\n\t).toBe(\"https://example.com/about\");\n\n\t// delocalizing\n\texpect(runtime.deLocalizeUrl(\"https://de.example.com/about\").href).toBe(\n\t\t\"https://example.com/about\"\n\t);\n\n\t// EN routing\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/about\", { locale: \"de\" }).href\n\t).toBe(\"https://de.example.com/about\");\n\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/about\", { locale: \"en\" }).href\n\t).toBe(\"https://example.com/about\");\n\n\t// delocalizing\n\texpect(runtime.deLocalizeUrl(\"https://example.com/about\").href).toBe(\n\t\t\"https://example.com/about\"\n\t);\n});\n\ntest(\"multi tenancy\", async () => {\n\tconst runtime = await createParaglide({\n\t\tblob: await newProject({\n\t\t\tsettings: {\n\t\t\t\tbaseLocale: \"en\",\n\t\t\t\tlocales: [\"en\", \"de\", \"fr\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"url\"],\n\t\turlPatterns: [\n\t\t\t// 1) customer1.fr => root path locale is fr, other locales via sub-path e.g. /en/\n\t\t\t{\n\t\t\t\tpattern: \"https://customer1.fr/:path*\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"en\", \"https://customer1.fr/en/:path*\"],\n\t\t\t\t\t[\"fr\", \"https://customer1.fr/:path*\"],\n\t\t\t\t],\n\t\t\t},\n\t\t\t// 2) customer2.com => root path locale is en, other locales via sub-path e.g. /fr/\n\t\t\t{\n\t\t\t\tpattern: \"https://customer2.com/:path*\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"fr\", \"https://customer2.com/fr/:path*\"],\n\t\t\t\t\t[\"en\", \"https://customer2.com/:path*\"],\n\t\t\t\t],\n\t\t\t},\n\t\t\t// 3) Any other domain => path-based for en/fr\n\t\t\t{\n\t\t\t\tpattern: \"https://:domain(.*)/:path*\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"en\", \"https://:domain(.*)/en/:path*\"],\n\t\t\t\t\t[\"fr\", \"https://:domain(.*)/fr/:path*\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\t// customer 1 - localizing french to french\n\texpect(\n\t\truntime.localizeUrl(\"https://customer1.fr/about\", { locale: \"fr\" }).href\n\t).toBe(\"https://customer1.fr/about\");\n\n\t// customer 1 - localizing from french to english\n\texpect(\n\t\truntime.localizeUrl(\"https://customer1.fr/about\", { locale: \"en\" }).href\n\t).toBe(\"https://customer1.fr/en/about\");\n\n\t// customer 1 - de-localizing french\n\texpect(runtime.deLocalizeUrl(\"https://customer1.fr/en/about\").href).toBe(\n\t\t\"https://customer1.fr/about\"\n\t);\n\n\t// customer 2 - english to english\n\texpect(\n\t\truntime.localizeUrl(\"https://customer2.com/about\", { locale: \"en\" }).href\n\t).toBe(\"https://customer2.com/about\");\n\n\t// customer 2 - english to french\n\texpect(\n\t\truntime.localizeUrl(\"https://customer2.com/about\", { locale: \"fr\" }).href\n\t).toBe(\"https://customer2.com/fr/about\");\n\n\t// customer 2 - de-localize french\n\texpect(runtime.deLocalizeUrl(\"https://customer2.com/fr/about\").href).toBe(\n\t\t\"https://customer2.com/about\"\n\t);\n});\n\ntest(\"providing a URL object as input\", async () => {\n\tconst runtime = await createParaglide({\n\t\tblob: await newProject({\n\t\t\tsettings: {\n\t\t\t\tbaseLocale: \"en\",\n\t\t\t\tlocales: [\"en\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"url\"],\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \"https://:domain(.*)/:path*\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"en\", \"https://:domain(.*)/:path*\"],\n\t\t\t\t\t[\"de\", \"https://de.:domain(.*)/:path*\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\tconst url = new URL(\"https://example.com/about\");\n\n\texpect(runtime.localizeUrl(url, { locale: \"de\" }).href).toBe(\n\t\t\"https://de.example.com/about\"\n\t);\n\n\texpect(runtime.deLocalizeUrl(url).href).toBe(\"https://example.com/about\");\n});\n\ntest(\"localhost with portname\", async () => {\n\tconst runtime = await createParaglide({\n\t\tblob: await newProject({\n\t\t\tsettings: {\n\t\t\t\tbaseLocale: \"en\",\n\t\t\t\tlocales: [\"en\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"url\"],\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \":protocol://:domain(.*)::port?/:path(.*)?\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"de\", \":protocol://:domain(.*)::port?/de/:path(.*)?\"],\n\t\t\t\t\t[\"en\", \":protocol://:domain(.*)::port?/:path(.*)?\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\t// http\n\texpect(\n\t\truntime.deLocalizeUrl(new URL(\"http://localhost:5173/de/about\")).href\n\t).toBe(\"http://localhost:5173/about\");\n\n\t// https\n\texpect(\n\t\truntime.deLocalizeUrl(new URL(\"https://localhost:5173/de/about\")).href\n\t).toBe(\"https://localhost:5173/about\");\n\n\t// no port\n\texpect(\n\t\truntime.deLocalizeUrl(new URL(\"https://localhost/de/about\")).href\n\t).toBe(\"https://localhost/about\");\n\n\t// pathnames\n\texpect(\n\t\truntime.deLocalizeUrl(new URL(\"http://localhost:5173/about\")).href\n\t).toBe(\"http://localhost:5173/about\");\n\n\texpect(runtime.deLocalizeUrl(new URL(\"http://localhost:5173/\")).href).toBe(\n\t\t\"http://localhost:5173/\"\n\t);\n\n\texpect(runtime.deLocalizeUrl(new URL(\"https://localhost:5173/de\")).href).toBe(\n\t\t\"https://localhost:5173/\"\n\t);\n});\n\ntest(\"it keeps the query parameters\", async () => {\n\tconst runtime = await createParaglide({\n\t\tblob: await newProject({\n\t\t\tsettings: {\n\t\t\t\tbaseLocale: \"en\",\n\t\t\t\tlocales: [\"en\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"url\"],\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \"https://:domain(.*)/:path(.*)?\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"de\", \"https://:domain(.*)/de/:path(.*)?\"],\n\t\t\t\t\t[\"en\", \"https://:domain(.*)/:path(.*)?\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/about?foo=bar&baz=qux\", {\n\t\t\tlocale: \"de\",\n\t\t}).href\n\t).toBe(\"https://example.com/de/about?foo=bar&baz=qux\");\n\n\texpect(\n\t\truntime.deLocalizeUrl(\"https://example.com/de/about?foo=bar&baz=qux\").href\n\t).toBe(\"https://example.com/about?foo=bar&baz=qux\");\n});\n\ntest(\"it keeps the url hash\", async () => {\n\tconst runtime = await createParaglide({\n\t\tblob: await newProject({\n\t\t\tsettings: {\n\t\t\t\tbaseLocale: \"en\",\n\t\t\t\tlocales: [\"en\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"url\"],\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \"https://:domain(.*)/:path(.*)?\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"de\", \"https://:domain(.*)/de/:path(.*)?\"],\n\t\t\t\t\t[\"en\", \"https://:domain(.*)/:path(.*)?\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/about#test\", { locale: \"de\" }).href\n\t).toBe(\"https://example.com/de/about#test\");\n\n\texpect(runtime.deLocalizeUrl(\"https://example.com/de/about#test\").href).toBe(\n\t\t\"https://example.com/about#test\"\n\t);\n});\n\n// URL Pattern implicitly matches all paths\n//\n// The pattern https://example.com is interpreted as https://example.com.*\n// It effectively matches every path under https://example.com/\n// This means any request, including https://example.com/about, will match.\ntest(\"it keeps the url path\", async () => {\n\tconst runtime = await createParaglide({\n\t\tblob: await newProject({\n\t\t\tsettings: {\n\t\t\t\tbaseLocale: \"en\",\n\t\t\t\tlocales: [\"en\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"url\"],\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \"https://example.com\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"de\", \"https://example.de\"],\n\t\t\t\t\t[\"en\", \"https://example.com\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/about\", { locale: \"de\" }).href\n\t).toBe(\"https://example.de/about\");\n\n\texpect(runtime.deLocalizeUrl(\"https://example.de/about\").href).toBe(\n\t\t\"https://example.com/about\"\n\t);\n});\n\ntest(\"uses getLocale when no locale is provided\", async () => {\n\tconst runtime = await createParaglide({\n\t\tblob: await newProject({\n\t\t\tsettings: {\n\t\t\t\tbaseLocale: \"en\",\n\t\t\t\tlocales: [\"en\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"url\"],\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \"https://:domain(.*)/:path(.*)?\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"de\", \"https://:domain(.*)/de/:path(.*)?\"],\n\t\t\t\t\t[\"en\", \"https://:domain(.*)/en/:path(.*)?\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\t// Override getLocale to return German\n\truntime.overwriteGetLocale(() => \"de\");\n\n\texpect(runtime.getLocale()).toBe(\"de\");\n\n\t// Should use \"de\" from getLocale since no locale provided\n\texpect(runtime.localizeUrl(\"https://example.com/about\").href).toBe(\n\t\t\"https://example.com/de/about\"\n\t);\n\n\t// Should still use explicit locale when provided\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/about\", { locale: \"en\" }).href\n\t).toBe(\"https://example.com/en/about\");\n});\n\ntest(\"normalizes mixed-case explicit locales for custom url patterns\", async () => {\n\tconst runtime = await createParaglide({\n\t\tblob: await newProject({\n\t\t\tsettings: {\n\t\t\t\tbaseLocale: \"en\",\n\t\t\t\tlocales: [\"en\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"url\"],\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \"https://:domain(.*)/:path(.*)?\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"de\", \"https://:domain(.*)/de/:path(.*)?\"],\n\t\t\t\t\t[\"en\", \"https://:domain(.*)/:path(.*)?\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/about\", {\n\t\t\tlocale: \"DE\",\n\t\t}).href\n\t).toBe(\"https://example.com/de/about\");\n\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/de/about\", {\n\t\t\tlocale: \"EN\",\n\t\t}).href\n\t).toBe(\"https://example.com/about\");\n});\n\n// https://github.com/opral/inlang-paraglide-js/issues/381\ntest.each([\n\t// empty url pattern will set TREE_SHAKE_DEFAULT_ULR_PATTERN_USED to true\n\t{},\n\t// real default url pattern to align behaviour\n\t{\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \":protocol://:domain(.*)::port?/:path(.*)?\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"de\", \":protocol://:domain(.*)::port?/de/:path(.*)?\"],\n\t\t\t\t\t[\"en\", \":protocol://:domain(.*)::port?/:path(.*)?\"],\n\t\t\t\t] as [string, string][],\n\t\t\t},\n\t\t],\n\t},\n])(\"default url pattern\", async (compilerOptions) => {\n\tconst runtime = await createParaglide({\n\t\tblob: await newProject({\n\t\t\tsettings: {\n\t\t\t\tbaseLocale: \"en\",\n\t\t\t\tlocales: [\"en\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\t...compilerOptions,\n\t});\n\n\truntime.overwriteGetLocale(() => \"en\");\n\n\texpect(runtime.localizeUrl(\"https://example.com/about\").href).toBe(\n\t\t\"https://example.com/about\"\n\t);\n\n\truntime.overwriteGetLocale(() => \"de\");\n\n\texpect(runtime.localizeUrl(\"https://example.com/\").href).toBe(\n\t\t\"https://example.com/de/\"\n\t);\n\n\texpect(runtime.localizeUrl(\"https://example.com/about\").href).toBe(\n\t\t\"https://example.com/de/about\"\n\t);\n\n\t// Should still use explicit locale when provided\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/about\", { locale: \"de\" }).href\n\t).toBe(\"https://example.com/de/about\");\n\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/about\", {\n\t\t\tlocale: \"DE\" as any,\n\t\t}).href\n\t).toBe(\"https://example.com/de/about\");\n\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/about\", { locale: \"en\" }).href\n\t).toBe(\"https://example.com/about\");\n\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/de/about\", {\n\t\t\tlocale: \"EN\" as any,\n\t\t}).href\n\t).toBe(\"https://example.com/about\");\n\n\texpect(runtime.deLocalizeUrl(\"https://example.com/de/about\").href).toBe(\n\t\t\"https://example.com/about\"\n\t);\n\n\texpect(runtime.deLocalizeUrl(\"https://example.com/about\").href).toBe(\n\t\t\"https://example.com/about\"\n\t);\n\tfor (const path of [\n\t\t\"/about/\",\n\t\t\"/about\",\n\t\t\"/nested/page/\",\n\t\t\"/about/?ref=docs#section\",\n\t\t\"/\",\n\t]) {\n\t\tconst original = new URL(path, \"https://example.com\");\n\t\tconst localized = new URL(original);\n\t\tlocalized.pathname = \"/de\" + original.pathname;\n\t\texpect(runtime.localizeUrl(original, { locale: \"de\" }).href).toBe(\n\t\t\tlocalized.href\n\t\t);\n\t\texpect(runtime.localizeUrl(localized, { locale: \"en\" }).href).toBe(\n\t\t\toriginal.href\n\t\t);\n\t\texpect(runtime.deLocalizeUrl(localized).href).toBe(original.href);\n\t\texpect(runtime.localizeUrl(localized, { locale: \"de\" }).href).toBe(\n\t\t\tlocalized.href\n\t\t);\n\t}\n});\n\ntest(\"auto fills the url base path\", async () => {\n\tconst runtime = await createParaglide({\n\t\tblob: await newProject({\n\t\t\tsettings: {\n\t\t\t\tbaseLocale: \"en\",\n\t\t\t\tlocales: [\"en\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"url\"],\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \"/:path(.*)?\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"de\", \"/de/:path(.*)?\"],\n\t\t\t\t\t[\"en\", \"/:path(.*)?\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/about\", { locale: \"en\" }).href\n\t).toBe(\"https://example.com/about\");\n\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/about\", { locale: \"de\" }).href\n\t).toBe(\"https://example.com/de/about\");\n\n\texpect(runtime.deLocalizeUrl(\"https://example.com/de/about\").href).toBe(\n\t\t\"https://example.com/about\"\n\t);\n});\n\n// https://github.com/opral/inlang-paraglide-js/issues/454\ntest(\"works with no trailing slash at the end\", async () => {\n\tconst runtime = await createParaglide({\n\t\tblob: await newProject({\n\t\t\tsettings: {\n\t\t\t\tbaseLocale: \"en\",\n\t\t\t\tlocales: [\"en\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"url\"],\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \"/:path(.*)?\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"en\", \"/en/:path(.*)?\"],\n\t\t\t\t\t[\"de\", \"/de/:path(.*)?\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\texpect(runtime.deLocalizeUrl(\"https://example.com/en/\").href).toBe(\n\t\t\"https://example.com/\"\n\t);\n\n\texpect(runtime.deLocalizeUrl(\"https://example.com/en\").href).toBe(\n\t\t\"https://example.com/\"\n\t);\n});\n\n// https://github.com/opral/inlang-paraglide-js/issues/452#issuecomment-2715761308\ntest(\"falls through if no match is found\", async () => {\n\tconst runtime = await createParaglide({\n\t\tblob: await newProject({\n\t\t\tsettings: {\n\t\t\t\tbaseLocale: \"en\",\n\t\t\t\tlocales: [\"en\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"url\"],\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \"/about\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"de\", \"/ueber\"],\n\t\t\t\t\t[\"en\", \"/about\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/\", { locale: \"en\" }).href\n\t).toBe(\"https://example.com/\");\n\n\texpect(runtime.deLocalizeUrl(\"https://example.com/\").href).toBe(\n\t\t\"https://example.com/\"\n\t);\n});\n\ntest(\"defining no localized pattern leads to a fallthrough\", async () => {\n\tconst runtime = await createParaglide({\n\t\tblob: await newProject({\n\t\t\tsettings: {\n\t\t\t\tbaseLocale: \"en\",\n\t\t\t\tlocales: [\"en\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"url\"],\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \"/specific-path\",\n\t\t\t\tlocalized: [[\"en\", \"/specific-path\"]],\n\t\t\t},\n\t\t],\n\t});\n\n\t// doesn't localize because no localized pattern is defined\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/specific-path\", { locale: \"de\" })\n\t\t\t.href\n\t).toBe(\"https://example.com/specific-path\");\n\n\t// doesn't delocalize because no localized pattern is defined\n\texpect(\n\t\truntime.deLocalizeUrl(\"https://example.com/de/specific-path\").href\n\t).toBe(\"https://example.com/de/specific-path\");\n});\n\ntest(\"does not cache base-relative patterns containing protocol syntax\", async () => {\n\tconst runtime = await createParaglide({\n\t\tblob: await newProject({\n\t\t\tsettings: {\n\t\t\t\tbaseLocale: \"en\",\n\t\t\t\tlocales: [\"en\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"url\"],\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \"specific-path{/:value(https://.*)}?\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"en\", \"specific-path{/:value(https://.*)}?\"],\n\t\t\t\t\t[\"de\", \"/de/specific-path\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\t// Warm the pattern against one base path before using another base path.\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/a/specific-path\", {\n\t\t\tlocale: \"de\",\n\t\t}).href\n\t).toBe(\"https://example.com/de/specific-path\");\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/b/specific-path\", {\n\t\t\tlocale: \"de\",\n\t\t}).href\n\t).toBe(\"https://example.com/de/specific-path\");\n});\n\n// https://github.com/opral/inlang-paraglide-js/issues/456\ntest(\"routing to a 404 page\", async () => {\n\tconst runtime = await createParaglide({\n\t\tblob: await newProject({\n\t\t\tsettings: {\n\t\t\t\tbaseLocale: \"en\",\n\t\t\t\tlocales: [\"en\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"url\"],\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \"/404\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"en\", \"/404\"],\n\t\t\t\t\t[\"de\", \"/de/404\"],\n\t\t\t\t],\n\t\t\t},\n\t\t\t{\n\t\t\t\tpattern: \"specific-path\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"en\", \"/specific-path\"],\n\t\t\t\t\t[\"de\", \"/de/404\"],\n\t\t\t\t],\n\t\t\t},\n\t\t\t{\n\t\t\t\tpattern: \"/:path(.*)?\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"en\", \"/:path(.*)?\"],\n\t\t\t\t\t[\"de\", \"/de/:path(.*)?\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/specific-path\", { locale: \"en\" })\n\t\t\t.href\n\t).toBe(\"https://example.com/specific-path\");\n\n\t// localizing to a 404 page\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/specific-path\", { locale: \"de\" })\n\t\t\t.href\n\t).toBe(\"https://example.com/de/404\");\n\n\t// other paths work because of the catch all\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/other-path\", { locale: \"de\" }).href\n\t).toBe(\"https://example.com/de/other-path\");\n});\n\n// Test showing the importance of pattern order in the localized array\ntest(\"pattern order in localized array - correct order (specific first)\", async () => {\n\tconst runtime = await createParaglide({\n\t\tblob: await newProject({\n\t\t\tsettings: {\n\t\t\t\tbaseLocale: \"en\",\n\t\t\t\tlocales: [\"en\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"url\"],\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \"/:path(.*)?\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t// CORRECT ORDER: more specific pattern first\n\t\t\t\t\t[\"de\", \"/de/:path(.*)?\"], // More specific pattern with prefix\n\t\t\t\t\t[\"en\", \"/:path(.*)?\"], // Less specific pattern without prefix\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\t// These should work correctly with the specific (de) pattern first\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/about\", { locale: \"en\" }).href\n\t).toBe(\"https://example.com/about\");\n\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/about\", { locale: \"de\" }).href\n\t).toBe(\"https://example.com/de/about\");\n\n\t// Delocalization should work correctly too\n\texpect(runtime.deLocalizeUrl(\"https://example.com/de/about\").href).toBe(\n\t\t\"https://example.com/about\"\n\t);\n});\n\n// Test showing the importance of pattern order in the localized array\ntest(\"pattern order in localized array - incorrect order (generic first)\", async () => {\n\tconst runtime = await createParaglide({\n\t\tblob: await newProject({\n\t\t\tsettings: {\n\t\t\t\tbaseLocale: \"en\",\n\t\t\t\tlocales: [\"en\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"url\"],\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \"/:path(.*)?\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t// INCORRECT ORDER: less specific pattern first\n\t\t\t\t\t[\"en\", \"/:path(.*)?\"], // Less specific pattern without prefix\n\t\t\t\t\t[\"de\", \"/de/:path(.*)?\"], // More specific pattern with prefix that may never match\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\t// English localization works as expected\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/about\", { locale: \"en\" }).href\n\t).toBe(\"https://example.com/about\");\n\n\t// German localization still works when explicitly requested\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/about\", { locale: \"de\" }).href\n\t).toBe(\"https://example.com/de/about\");\n\n\t// The problem happens with delocalization:\n\t// With incorrect pattern order, the generic /:path(.*)?\n\t// pattern matches first and swallows the /de/ prefix\n\texpect(runtime.deLocalizeUrl(\"https://example.com/de/about\").href).toBe(\n\t\t\"https://example.com/de/about\"\n\t); // Should be \"https://example.com/about\"\n});\n\n// Test for port number issue with specific port numbers in the URL pattern\ntest(\"handles explicit port numbers in URL patterns correctly\", async () => {\n\tconst runtime = await createParaglide({\n\t\tblob: await newProject({\n\t\t\tsettings: {\n\t\t\t\tbaseLocale: \"en\",\n\t\t\t\tlocales: [\"en\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"url\"],\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\t// Using explicit port number - this causes issues with deLocalizeUrl\n\t\t\t\tpattern: \"http://localhost:5173/:path(.*)?\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"de\", \"http://localhost:5173/de/:path(.*)?\"],\n\t\t\t\t\t[\"en\", \"http://localhost:5173/:path(.*)?\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\t// Localization should work correctly\n\texpect(\n\t\truntime.localizeUrl(\"http://localhost:5173/about\", { locale: \"de\" }).href\n\t).toBe(\"http://localhost:5173/de/about\");\n\n\texpect(\n\t\truntime.localizeUrl(\"http://localhost:5173/about\", { locale: \"en\" }).href\n\t).toBe(\"http://localhost:5173/about\");\n\n\t// This is where the bug occurs - delocalizing a URL with a port number\n\t// The port number (5173) is incorrectly treated as a path parameter\n\texpect(runtime.deLocalizeUrl(\"http://localhost:5173/de/about\").href).toBe(\n\t\t\"http://localhost:5173/about\"\n\t);\n});\n\n// Test for the correct approach using port as a pattern parameter\ntest(\"correctly handles port numbers as pattern parameters\", async () => {\n\tconst runtime = await createParaglide({\n\t\tblob: await newProject({\n\t\t\tsettings: {\n\t\t\t\tbaseLocale: \"en\",\n\t\t\t\tlocales: [\"en\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"url\"],\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\t// Using port as a proper pattern parameter with :: syntax\n\t\t\t\tpattern: \"http://localhost::port/:path(.*)?\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"de\", \"http://localhost::port/de/:path(.*)?\"],\n\t\t\t\t\t[\"en\", \"http://localhost::port/:path(.*)?\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\t// Localization should work correctly\n\texpect(\n\t\truntime.localizeUrl(\"http://localhost:5173/about\", { locale: \"de\" }).href\n\t).toBe(\"http://localhost:5173/de/about\");\n\n\texpect(\n\t\truntime.localizeUrl(\"http://localhost:5173/about\", { locale: \"en\" }).href\n\t).toBe(\"http://localhost:5173/about\");\n\n\t// Delocalization should also work correctly with the proper pattern\n\texpect(runtime.deLocalizeUrl(\"http://localhost:5173/de/about\").href).toBe(\n\t\t\"http://localhost:5173/about\"\n\t);\n});\n"]}
|
|
1
|
+
{"version":3,"file":"localize-url.test.js","sourceRoot":"","sources":["../../../src/compiler/runtime/localize-url.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAA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AAU,CAAC;YACtB,QAAQ,EAAE;gBACT,UAAU,EAAE,IAAI;gBAChB,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC;aACrB;SACD,CAAC;QACF,QAAQ,EAAE,CAAC,KAAK,CAAC;QACjB,WAAW,EAAE;YACZ;gBACC,0DAA0D;gBAC1D,OAAO,EAAE,mCAAmC;gBAC5C,SAAS,EAAE;oBACV,CAAC,IAAI,EAAE,sCAAsC,CAAC;oBAC9C,CAAC,IAAI,EAAE,mCAAmC,CAAC;iBAC3C;aACD;SACD;KACD,CAAC,CAAC;IAEH,qCAAqC;IACrC,MAAM,CACL,OAAO,CAAC,WAAW,CAAC,6BAA6B,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CACzE,CAAC,IAAI,CAAC,gCAAgC,CAAC,CAAC;IAEzC,MAAM,CACL,OAAO,CAAC,WAAW,CAAC,6BAA6B,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CACzE,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAC;IAEtC,oEAAoE;IACpE,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,gCAAgC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CACxE,6BAA6B,CAC7B,CAAC;AACH,CAAC,CAAC,CAAC","sourcesContent":["import { test, expect } from \"vitest\";\nimport { createParaglide } from \"../create-paraglide.js\";\nimport { newProject } from \"@inlang/sdk\";\n\ntest.each([\n\t{ name: \"default patterns\", urlPatterns: undefined },\n\t{\n\t\tname: \"custom patterns\",\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \"/about\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"en\", \"/about\"],\n\t\t\t\t\t[\"de\", \"/de/ueber\"],\n\t\t\t\t] as [string, string][],\n\t\t\t},\n\t\t],\n\t},\n])(\"accepts readonly URL inputs with $name\", async ({ urlPatterns }) => {\n\tconst runtime = await createParaglide({\n\t\tblob: await newProject({\n\t\t\tsettings: { baseLocale: \"en\", locales: [\"en\", \"de\"] },\n\t\t}),\n\t\tstrategy: [\"url\"],\n\t\turlPatterns,\n\t});\n\n\t// Match SvelteKit 3's page.url type, including readonly search parameters.\n\tconst input: Readonly<\n\t\tOmit<URL, \"searchParams\"> & {\n\t\t\tsearchParams: Omit<URLSearchParams, \"append\" | \"delete\" | \"set\" | \"sort\">;\n\t\t}\n\t> = new URL(\"https://example.com/about?q=one&q=two#section\");\n\tconst before = input.href;\n\tconst localized = runtime.localizeUrl(input, { locale: \"de\" });\n\texpect(localized.href).toBe(\n\t\turlPatterns\n\t\t\t? \"https://example.com/de/ueber?q=one&q=two#section\"\n\t\t\t: \"https://example.com/de/about?q=one&q=two#section\"\n\t);\n\texpect(\n\t\truntime.deLocalizeUrl(Object.freeze({ href: localized.href })).href\n\t).toBe(before);\n\texpect(input.href).toBe(before);\n\n\t// A URL-like object must never leak out of the unmatched-pattern fallback.\n\tconst unmatched = Object.freeze({\n\t\thref: \"https://example.com/assets/?q=one&q=two#section\",\n\t});\n\tfor (const result of [\n\t\truntime.localizeUrl(unmatched, { locale: \"en\" }),\n\t\truntime.deLocalizeUrl(unmatched),\n\t]) {\n\t\texpect(result).toBeInstanceOf(URL);\n\t\texpect(result.href).toBe(unmatched.href);\n\t\tresult.searchParams.set(\"q\", \"changed\");\n\t\texpect(unmatched.href).toBe(\n\t\t\t\"https://example.com/assets/?q=one&q=two#section\"\n\t\t);\n\t}\n});\n\ntest(\"pathname based localization\", async () => {\n\tconst runtime = await createParaglide({\n\t\tblob: await newProject({\n\t\t\tsettings: {\n\t\t\t\tbaseLocale: \"en\",\n\t\t\t\tlocales: [\"en\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"url\"],\n\t\turlPatterns: [\n\t\t\t// literal match\n\t\t\t{\n\t\t\t\tpattern: \"/blog/about\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"en\", \"/blog/about\"],\n\t\t\t\t\t[\"de\", \"/de/artikel/ueber-uns\"],\n\t\t\t\t],\n\t\t\t},\n\t\t\t// parameter\n\t\t\t{\n\t\t\t\tpattern: \"/blog/:id\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"en\", \"/blog/:id\"],\n\t\t\t\t\t[\"de\", \"/de/artikel/:id\"],\n\t\t\t\t],\n\t\t\t},\n\t\t\t// wildcard\n\t\t\t{\n\t\t\t\tpattern: \"/:path(.*)\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"de\", \"/de/:path(.*)\"],\n\t\t\t\t\t[\"en\", \"/:path(.*)\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\t// wildcard - en to de\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/home\", { locale: \"de\" }).href\n\t).toBe(\"https://example.com/de/home\");\n\n\t// wildcard - de to en\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/de/home\", { locale: \"en\" }).href\n\t).toBe(\"https://example.com/home\");\n\n\t// wildcard - en to en\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/about\", { locale: \"en\" }).href\n\t).toBe(\"https://example.com/about\");\n\n\t// wildcard - delocalizing de\n\texpect(runtime.deLocalizeUrl(\"https://example.com/de/about\").href).toBe(\n\t\t\"https://example.com/about\"\n\t);\n\n\t// literal match\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/blog/about\", { locale: \"de\" }).href\n\t).toBe(\"https://example.com/de/artikel/ueber-uns\");\n\n\texpect(\n\t\truntime.deLocalizeUrl(\"https://example.com/de/artikel/ueber-uns\").href\n\t).toBe(\"https://example.com/blog/about\");\n\n\t// parameter matching\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/blog/56\", { locale: \"de\" }).href\n\t).toBe(\"https://example.com/de/artikel/56\");\n\n\texpect(runtime.deLocalizeUrl(\"https://example.com/de/artikel/56\").href).toBe(\n\t\t\"https://example.com/blog/56\"\n\t);\n});\n\n// https://github.com/opral/paraglide-js/issues/473\ntest(\"normalizes trailing slashes before matching translated pathnames\", async () => {\n\tconst runtime = await createParaglide({\n\t\tblob: await newProject({\n\t\t\tsettings: {\n\t\t\t\tbaseLocale: \"en\",\n\t\t\t\tlocales: [\"en\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"url\", \"baseLocale\"],\n\t\ttrailingSlash: \"never\",\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \"/\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"de\", \"/de\"],\n\t\t\t\t\t[\"en\", \"/\"],\n\t\t\t\t],\n\t\t\t},\n\t\t\t{\n\t\t\t\tpattern: \"/about\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"de\", \"/de/ueber\"],\n\t\t\t\t\t[\"en\", \"/about\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\texpect(runtime.trailingSlash).toBe(\"never\");\n\texpect(\"normalizeTrailingSlash\" in runtime).toBe(false);\n\texpect(\"execUrlPattern\" in runtime).toBe(false);\n\texpect(runtime.extractLocaleFromUrl(\"https://example.com/de/\")).toBe(\"de\");\n\texpect(runtime.extractLocaleFromUrl(\"https://example.com/de/ueber/\")).toBe(\n\t\t\"de\"\n\t);\n\texpect(runtime.deLocalizeUrl(\"https://example.com/de/\").href).toBe(\n\t\t\"https://example.com/\"\n\t);\n\texpect(runtime.deLocalizeUrl(\"https://example.com/de/ueber/\").href).toBe(\n\t\t\"https://example.com/about\"\n\t);\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/about/\", { locale: \"de\" }).href\n\t).toBe(\"https://example.com/de/ueber\");\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/about/?ref=docs#section\", {\n\t\t\tlocale: \"de\",\n\t\t}).href\n\t).toBe(\"https://example.com/de/ueber?ref=docs#section\");\n});\n\ntest(\"adds trailing slashes when configured\", async () => {\n\tconst runtime = await createParaglide({\n\t\tblob: await newProject({\n\t\t\tsettings: {\n\t\t\t\tbaseLocale: \"en\",\n\t\t\t\tlocales: [\"en\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"url\"],\n\t\ttrailingSlash: \"always\",\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\t// Existing patterns do not need to be rewritten for the policy.\n\t\t\t\tpattern: \"/about\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"de\", \"/de/ueber\"],\n\t\t\t\t\t[\"en\", \"/about\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/about\", { locale: \"de\" }).href\n\t).toBe(\"https://example.com/de/ueber/\");\n\texpect(runtime.deLocalizeUrl(\"https://example.com/de/ueber\").href).toBe(\n\t\t\"https://example.com/about/\"\n\t);\n});\n\ntest(\"does not include a canonical trailing slash in wildcard captures\", async () => {\n\tconst runtime = await createParaglide({\n\t\tblob: await newProject({\n\t\t\tsettings: {\n\t\t\t\tbaseLocale: \"en\",\n\t\t\t\tlocales: [\"en\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"url\"],\n\t\ttrailingSlash: \"always\",\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \"/:path(.*)\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"de\", \"/de/:path(.*)/details\"],\n\t\t\t\t\t[\"en\", \"/:path(.*)\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/foo\", { locale: \"de\" }).href\n\t).toBe(\"https://example.com/de/foo/details/\");\n\texpect(runtime.deLocalizeUrl(\"https://example.com/de/foo/details\").href).toBe(\n\t\t\"https://example.com/foo/\"\n\t);\n});\n\ntest(\"keeps unmatched custom URLs unchanged\", async () => {\n\tconst runtime = await createParaglide({\n\t\tblob: await newProject({\n\t\t\tsettings: {\n\t\t\t\tbaseLocale: \"en\",\n\t\t\t\tlocales: [\"en\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"url\"],\n\t\ttrailingSlash: \"never\",\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \"/about\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"en\", \"/about\"],\n\t\t\t\t\t[\"de\", \"/de/ueber\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\tconst input = new URL(\"https://example.com/assets/\");\n\texpect(runtime.localizeUrl(input, { locale: \"de\" })).toBe(input);\n\texpect(runtime.deLocalizeUrl(input)).toBe(input);\n\texpect(input.href).toBe(\"https://example.com/assets/\");\n});\n\ntest(\"omitting trailingSlash preserves exact custom pattern matching\", async () => {\n\tconst runtime = await createParaglide({\n\t\tblob: await newProject({\n\t\t\tsettings: {\n\t\t\t\tbaseLocale: \"en\",\n\t\t\t\tlocales: [\"en\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"url\"],\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \"/about\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"en\", \"/about\"],\n\t\t\t\t\t[\"de\", \"/de/ueber\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\tconst input = new URL(\"https://example.com/de/ueber/\");\n\texpect(runtime.trailingSlash).toBeUndefined();\n\texpect(runtime.extractLocaleFromUrl(input)).toBeUndefined();\n\texpect(runtime.deLocalizeUrl(input)).toBe(input);\n});\n\ntest(\"cross domain urls\", async () => {\n\tconst runtime = await createParaglide({\n\t\tblob: await newProject({\n\t\t\tsettings: {\n\t\t\t\tbaseLocale: \"en\",\n\t\t\t\tlocales: [\"en\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"url\"],\n\t\turlPatterns: [\n\t\t\t// Development/deployment mapping\n\t\t\t{\n\t\t\t\tpattern: \"https://localhost::port/:path*\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"de\", \"https://localhost::port/de/:path*\"],\n\t\t\t\t\t[\"en\", \"https://localhost::port/:path*\"],\n\t\t\t\t],\n\t\t\t},\n\t\t\t// Domain based localization\n\t\t\t{\n\t\t\t\tpattern: \"https://example.com/:path*\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"en\", \"https://example.com/:path*\"],\n\t\t\t\t\t[\"de\", \"https://de.example.com/:path*\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\t// in development use localhost with different mapping\n\texpect(\n\t\truntime.localizeUrl(\"https://localhost:5173/about\", { locale: \"de\" }).href\n\t).toBe(\"https://localhost:5173/de/about\");\n\n\texpect(\n\t\truntime.localizeUrl(\"https://localhost:5173/about\", { locale: \"en\" }).href\n\t).toBe(\"https://localhost:5173/about\");\n\n\texpect(runtime.deLocalizeUrl(\"https://localhost:5173/de/about\").href).toBe(\n\t\t\"https://localhost:5173/about\"\n\t);\n\n\t// DE routing\n\texpect(\n\t\truntime.localizeUrl(\"https://de.example.com/about\", { locale: \"de\" }).href\n\t).toBe(\"https://de.example.com/about\");\n\n\texpect(\n\t\truntime.localizeUrl(\"https://de.example.com/about\", { locale: \"en\" }).href\n\t).toBe(\"https://example.com/about\");\n\n\t// delocalizing\n\texpect(runtime.deLocalizeUrl(\"https://de.example.com/about\").href).toBe(\n\t\t\"https://example.com/about\"\n\t);\n\n\t// EN routing\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/about\", { locale: \"de\" }).href\n\t).toBe(\"https://de.example.com/about\");\n\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/about\", { locale: \"en\" }).href\n\t).toBe(\"https://example.com/about\");\n\n\t// delocalizing\n\texpect(runtime.deLocalizeUrl(\"https://example.com/about\").href).toBe(\n\t\t\"https://example.com/about\"\n\t);\n});\n\ntest(\"multi tenancy\", async () => {\n\tconst runtime = await createParaglide({\n\t\tblob: await newProject({\n\t\t\tsettings: {\n\t\t\t\tbaseLocale: \"en\",\n\t\t\t\tlocales: [\"en\", \"de\", \"fr\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"url\"],\n\t\turlPatterns: [\n\t\t\t// 1) customer1.fr => root path locale is fr, other locales via sub-path e.g. /en/\n\t\t\t{\n\t\t\t\tpattern: \"https://customer1.fr/:path*\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"en\", \"https://customer1.fr/en/:path*\"],\n\t\t\t\t\t[\"fr\", \"https://customer1.fr/:path*\"],\n\t\t\t\t],\n\t\t\t},\n\t\t\t// 2) customer2.com => root path locale is en, other locales via sub-path e.g. /fr/\n\t\t\t{\n\t\t\t\tpattern: \"https://customer2.com/:path*\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"fr\", \"https://customer2.com/fr/:path*\"],\n\t\t\t\t\t[\"en\", \"https://customer2.com/:path*\"],\n\t\t\t\t],\n\t\t\t},\n\t\t\t// 3) Any other domain => path-based for en/fr\n\t\t\t{\n\t\t\t\tpattern: \"https://:domain(.*)/:path*\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"en\", \"https://:domain(.*)/en/:path*\"],\n\t\t\t\t\t[\"fr\", \"https://:domain(.*)/fr/:path*\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\t// customer 1 - localizing french to french\n\texpect(\n\t\truntime.localizeUrl(\"https://customer1.fr/about\", { locale: \"fr\" }).href\n\t).toBe(\"https://customer1.fr/about\");\n\n\t// customer 1 - localizing from french to english\n\texpect(\n\t\truntime.localizeUrl(\"https://customer1.fr/about\", { locale: \"en\" }).href\n\t).toBe(\"https://customer1.fr/en/about\");\n\n\t// customer 1 - de-localizing french\n\texpect(runtime.deLocalizeUrl(\"https://customer1.fr/en/about\").href).toBe(\n\t\t\"https://customer1.fr/about\"\n\t);\n\n\t// customer 2 - english to english\n\texpect(\n\t\truntime.localizeUrl(\"https://customer2.com/about\", { locale: \"en\" }).href\n\t).toBe(\"https://customer2.com/about\");\n\n\t// customer 2 - english to french\n\texpect(\n\t\truntime.localizeUrl(\"https://customer2.com/about\", { locale: \"fr\" }).href\n\t).toBe(\"https://customer2.com/fr/about\");\n\n\t// customer 2 - de-localize french\n\texpect(runtime.deLocalizeUrl(\"https://customer2.com/fr/about\").href).toBe(\n\t\t\"https://customer2.com/about\"\n\t);\n});\n\ntest(\"providing a URL object as input\", async () => {\n\tconst runtime = await createParaglide({\n\t\tblob: await newProject({\n\t\t\tsettings: {\n\t\t\t\tbaseLocale: \"en\",\n\t\t\t\tlocales: [\"en\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"url\"],\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \"https://:domain(.*)/:path*\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"en\", \"https://:domain(.*)/:path*\"],\n\t\t\t\t\t[\"de\", \"https://de.:domain(.*)/:path*\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\tconst url = new URL(\"https://example.com/about\");\n\n\texpect(runtime.localizeUrl(url, { locale: \"de\" }).href).toBe(\n\t\t\"https://de.example.com/about\"\n\t);\n\n\texpect(runtime.deLocalizeUrl(url).href).toBe(\"https://example.com/about\");\n});\n\ntest(\"localhost with portname\", async () => {\n\tconst runtime = await createParaglide({\n\t\tblob: await newProject({\n\t\t\tsettings: {\n\t\t\t\tbaseLocale: \"en\",\n\t\t\t\tlocales: [\"en\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"url\"],\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \":protocol://:domain(.*)::port?/:path(.*)?\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"de\", \":protocol://:domain(.*)::port?/de/:path(.*)?\"],\n\t\t\t\t\t[\"en\", \":protocol://:domain(.*)::port?/:path(.*)?\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\t// http\n\texpect(\n\t\truntime.deLocalizeUrl(new URL(\"http://localhost:5173/de/about\")).href\n\t).toBe(\"http://localhost:5173/about\");\n\n\t// https\n\texpect(\n\t\truntime.deLocalizeUrl(new URL(\"https://localhost:5173/de/about\")).href\n\t).toBe(\"https://localhost:5173/about\");\n\n\t// no port\n\texpect(\n\t\truntime.deLocalizeUrl(new URL(\"https://localhost/de/about\")).href\n\t).toBe(\"https://localhost/about\");\n\n\t// pathnames\n\texpect(\n\t\truntime.deLocalizeUrl(new URL(\"http://localhost:5173/about\")).href\n\t).toBe(\"http://localhost:5173/about\");\n\n\texpect(runtime.deLocalizeUrl(new URL(\"http://localhost:5173/\")).href).toBe(\n\t\t\"http://localhost:5173/\"\n\t);\n\n\texpect(runtime.deLocalizeUrl(new URL(\"https://localhost:5173/de\")).href).toBe(\n\t\t\"https://localhost:5173/\"\n\t);\n});\n\ntest(\"it keeps the query parameters\", async () => {\n\tconst runtime = await createParaglide({\n\t\tblob: await newProject({\n\t\t\tsettings: {\n\t\t\t\tbaseLocale: \"en\",\n\t\t\t\tlocales: [\"en\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"url\"],\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \"https://:domain(.*)/:path(.*)?\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"de\", \"https://:domain(.*)/de/:path(.*)?\"],\n\t\t\t\t\t[\"en\", \"https://:domain(.*)/:path(.*)?\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/about?foo=bar&baz=qux\", {\n\t\t\tlocale: \"de\",\n\t\t}).href\n\t).toBe(\"https://example.com/de/about?foo=bar&baz=qux\");\n\n\texpect(\n\t\truntime.deLocalizeUrl(\"https://example.com/de/about?foo=bar&baz=qux\").href\n\t).toBe(\"https://example.com/about?foo=bar&baz=qux\");\n});\n\ntest(\"it keeps the url hash\", async () => {\n\tconst runtime = await createParaglide({\n\t\tblob: await newProject({\n\t\t\tsettings: {\n\t\t\t\tbaseLocale: \"en\",\n\t\t\t\tlocales: [\"en\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"url\"],\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \"https://:domain(.*)/:path(.*)?\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"de\", \"https://:domain(.*)/de/:path(.*)?\"],\n\t\t\t\t\t[\"en\", \"https://:domain(.*)/:path(.*)?\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/about#test\", { locale: \"de\" }).href\n\t).toBe(\"https://example.com/de/about#test\");\n\n\texpect(runtime.deLocalizeUrl(\"https://example.com/de/about#test\").href).toBe(\n\t\t\"https://example.com/about#test\"\n\t);\n});\n\n// URL Pattern implicitly matches all paths\n//\n// The pattern https://example.com is interpreted as https://example.com.*\n// It effectively matches every path under https://example.com/\n// This means any request, including https://example.com/about, will match.\ntest(\"it keeps the url path\", async () => {\n\tconst runtime = await createParaglide({\n\t\tblob: await newProject({\n\t\t\tsettings: {\n\t\t\t\tbaseLocale: \"en\",\n\t\t\t\tlocales: [\"en\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"url\"],\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \"https://example.com\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"de\", \"https://example.de\"],\n\t\t\t\t\t[\"en\", \"https://example.com\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/about\", { locale: \"de\" }).href\n\t).toBe(\"https://example.de/about\");\n\n\texpect(runtime.deLocalizeUrl(\"https://example.de/about\").href).toBe(\n\t\t\"https://example.com/about\"\n\t);\n});\n\ntest(\"uses getLocale when no locale is provided\", async () => {\n\tconst runtime = await createParaglide({\n\t\tblob: await newProject({\n\t\t\tsettings: {\n\t\t\t\tbaseLocale: \"en\",\n\t\t\t\tlocales: [\"en\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"url\"],\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \"https://:domain(.*)/:path(.*)?\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"de\", \"https://:domain(.*)/de/:path(.*)?\"],\n\t\t\t\t\t[\"en\", \"https://:domain(.*)/en/:path(.*)?\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\t// Override getLocale to return German\n\truntime.overwriteGetLocale(() => \"de\");\n\n\texpect(runtime.getLocale()).toBe(\"de\");\n\n\t// Should use \"de\" from getLocale since no locale provided\n\texpect(runtime.localizeUrl(\"https://example.com/about\").href).toBe(\n\t\t\"https://example.com/de/about\"\n\t);\n\n\t// Should still use explicit locale when provided\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/about\", { locale: \"en\" }).href\n\t).toBe(\"https://example.com/en/about\");\n});\n\ntest(\"normalizes mixed-case explicit locales for custom url patterns\", async () => {\n\tconst runtime = await createParaglide({\n\t\tblob: await newProject({\n\t\t\tsettings: {\n\t\t\t\tbaseLocale: \"en\",\n\t\t\t\tlocales: [\"en\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"url\"],\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \"https://:domain(.*)/:path(.*)?\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"de\", \"https://:domain(.*)/de/:path(.*)?\"],\n\t\t\t\t\t[\"en\", \"https://:domain(.*)/:path(.*)?\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/about\", {\n\t\t\tlocale: \"DE\",\n\t\t}).href\n\t).toBe(\"https://example.com/de/about\");\n\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/de/about\", {\n\t\t\tlocale: \"EN\",\n\t\t}).href\n\t).toBe(\"https://example.com/about\");\n});\n\n// https://github.com/opral/inlang-paraglide-js/issues/381\ntest.each([\n\t// empty url pattern will set TREE_SHAKE_DEFAULT_ULR_PATTERN_USED to true\n\t{},\n\t// real default url pattern to align behaviour\n\t{\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \":protocol://:domain(.*)::port?/:path(.*)?\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"de\", \":protocol://:domain(.*)::port?/de/:path(.*)?\"],\n\t\t\t\t\t[\"en\", \":protocol://:domain(.*)::port?/:path(.*)?\"],\n\t\t\t\t] as [string, string][],\n\t\t\t},\n\t\t],\n\t},\n])(\"default url pattern\", async (compilerOptions) => {\n\tconst runtime = await createParaglide({\n\t\tblob: await newProject({\n\t\t\tsettings: {\n\t\t\t\tbaseLocale: \"en\",\n\t\t\t\tlocales: [\"en\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\t...compilerOptions,\n\t});\n\n\truntime.overwriteGetLocale(() => \"en\");\n\n\texpect(runtime.localizeUrl(\"https://example.com/about\").href).toBe(\n\t\t\"https://example.com/about\"\n\t);\n\n\truntime.overwriteGetLocale(() => \"de\");\n\n\texpect(runtime.localizeUrl(\"https://example.com/\").href).toBe(\n\t\t\"https://example.com/de/\"\n\t);\n\n\texpect(runtime.localizeUrl(\"https://example.com/about\").href).toBe(\n\t\t\"https://example.com/de/about\"\n\t);\n\n\t// Should still use explicit locale when provided\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/about\", { locale: \"de\" }).href\n\t).toBe(\"https://example.com/de/about\");\n\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/about\", {\n\t\t\tlocale: \"DE\" as any,\n\t\t}).href\n\t).toBe(\"https://example.com/de/about\");\n\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/about\", { locale: \"en\" }).href\n\t).toBe(\"https://example.com/about\");\n\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/de/about\", {\n\t\t\tlocale: \"EN\" as any,\n\t\t}).href\n\t).toBe(\"https://example.com/about\");\n\n\texpect(runtime.deLocalizeUrl(\"https://example.com/de/about\").href).toBe(\n\t\t\"https://example.com/about\"\n\t);\n\n\texpect(runtime.deLocalizeUrl(\"https://example.com/about\").href).toBe(\n\t\t\"https://example.com/about\"\n\t);\n\tfor (const path of [\n\t\t\"/about/\",\n\t\t\"/about\",\n\t\t\"/nested/page/\",\n\t\t\"/about/?ref=docs#section\",\n\t\t\"/\",\n\t]) {\n\t\tconst original = new URL(path, \"https://example.com\");\n\t\tconst localized = new URL(original);\n\t\tlocalized.pathname = \"/de\" + original.pathname;\n\t\texpect(runtime.localizeUrl(original, { locale: \"de\" }).href).toBe(\n\t\t\tlocalized.href\n\t\t);\n\t\texpect(runtime.localizeUrl(localized, { locale: \"en\" }).href).toBe(\n\t\t\toriginal.href\n\t\t);\n\t\texpect(runtime.deLocalizeUrl(localized).href).toBe(original.href);\n\t\texpect(runtime.localizeUrl(localized, { locale: \"de\" }).href).toBe(\n\t\t\tlocalized.href\n\t\t);\n\t}\n});\n\ntest(\"auto fills the url base path\", async () => {\n\tconst runtime = await createParaglide({\n\t\tblob: await newProject({\n\t\t\tsettings: {\n\t\t\t\tbaseLocale: \"en\",\n\t\t\t\tlocales: [\"en\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"url\"],\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \"/:path(.*)?\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"de\", \"/de/:path(.*)?\"],\n\t\t\t\t\t[\"en\", \"/:path(.*)?\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/about\", { locale: \"en\" }).href\n\t).toBe(\"https://example.com/about\");\n\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/about\", { locale: \"de\" }).href\n\t).toBe(\"https://example.com/de/about\");\n\n\texpect(runtime.deLocalizeUrl(\"https://example.com/de/about\").href).toBe(\n\t\t\"https://example.com/about\"\n\t);\n});\n\n// https://github.com/opral/inlang-paraglide-js/issues/454\ntest(\"works with no trailing slash at the end\", async () => {\n\tconst runtime = await createParaglide({\n\t\tblob: await newProject({\n\t\t\tsettings: {\n\t\t\t\tbaseLocale: \"en\",\n\t\t\t\tlocales: [\"en\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"url\"],\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \"/:path(.*)?\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"en\", \"/en/:path(.*)?\"],\n\t\t\t\t\t[\"de\", \"/de/:path(.*)?\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\texpect(runtime.deLocalizeUrl(\"https://example.com/en/\").href).toBe(\n\t\t\"https://example.com/\"\n\t);\n\n\texpect(runtime.deLocalizeUrl(\"https://example.com/en\").href).toBe(\n\t\t\"https://example.com/\"\n\t);\n});\n\n// https://github.com/opral/inlang-paraglide-js/issues/452#issuecomment-2715761308\ntest(\"falls through if no match is found\", async () => {\n\tconst runtime = await createParaglide({\n\t\tblob: await newProject({\n\t\t\tsettings: {\n\t\t\t\tbaseLocale: \"en\",\n\t\t\t\tlocales: [\"en\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"url\"],\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \"/about\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"de\", \"/ueber\"],\n\t\t\t\t\t[\"en\", \"/about\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/\", { locale: \"en\" }).href\n\t).toBe(\"https://example.com/\");\n\n\texpect(runtime.deLocalizeUrl(\"https://example.com/\").href).toBe(\n\t\t\"https://example.com/\"\n\t);\n});\n\ntest(\"defining no localized pattern leads to a fallthrough\", async () => {\n\tconst runtime = await createParaglide({\n\t\tblob: await newProject({\n\t\t\tsettings: {\n\t\t\t\tbaseLocale: \"en\",\n\t\t\t\tlocales: [\"en\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"url\"],\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \"/specific-path\",\n\t\t\t\tlocalized: [[\"en\", \"/specific-path\"]],\n\t\t\t},\n\t\t],\n\t});\n\n\t// doesn't localize because no localized pattern is defined\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/specific-path\", { locale: \"de\" })\n\t\t\t.href\n\t).toBe(\"https://example.com/specific-path\");\n\n\t// doesn't delocalize because no localized pattern is defined\n\texpect(\n\t\truntime.deLocalizeUrl(\"https://example.com/de/specific-path\").href\n\t).toBe(\"https://example.com/de/specific-path\");\n});\n\ntest(\"does not cache base-relative patterns containing protocol syntax\", async () => {\n\tconst runtime = await createParaglide({\n\t\tblob: await newProject({\n\t\t\tsettings: {\n\t\t\t\tbaseLocale: \"en\",\n\t\t\t\tlocales: [\"en\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"url\"],\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \"specific-path{/:value(https://.*)}?\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"en\", \"specific-path{/:value(https://.*)}?\"],\n\t\t\t\t\t[\"de\", \"/de/specific-path\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\t// Warm the pattern against one base path before using another base path.\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/a/specific-path\", {\n\t\t\tlocale: \"de\",\n\t\t}).href\n\t).toBe(\"https://example.com/de/specific-path\");\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/b/specific-path\", {\n\t\t\tlocale: \"de\",\n\t\t}).href\n\t).toBe(\"https://example.com/de/specific-path\");\n});\n\n// https://github.com/opral/inlang-paraglide-js/issues/456\ntest(\"routing to a 404 page\", async () => {\n\tconst runtime = await createParaglide({\n\t\tblob: await newProject({\n\t\t\tsettings: {\n\t\t\t\tbaseLocale: \"en\",\n\t\t\t\tlocales: [\"en\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"url\"],\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \"/404\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"en\", \"/404\"],\n\t\t\t\t\t[\"de\", \"/de/404\"],\n\t\t\t\t],\n\t\t\t},\n\t\t\t{\n\t\t\t\tpattern: \"specific-path\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"en\", \"/specific-path\"],\n\t\t\t\t\t[\"de\", \"/de/404\"],\n\t\t\t\t],\n\t\t\t},\n\t\t\t{\n\t\t\t\tpattern: \"/:path(.*)?\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"en\", \"/:path(.*)?\"],\n\t\t\t\t\t[\"de\", \"/de/:path(.*)?\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/specific-path\", { locale: \"en\" })\n\t\t\t.href\n\t).toBe(\"https://example.com/specific-path\");\n\n\t// localizing to a 404 page\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/specific-path\", { locale: \"de\" })\n\t\t\t.href\n\t).toBe(\"https://example.com/de/404\");\n\n\t// other paths work because of the catch all\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/other-path\", { locale: \"de\" }).href\n\t).toBe(\"https://example.com/de/other-path\");\n});\n\n// Test showing the importance of pattern order in the localized array\ntest(\"pattern order in localized array - correct order (specific first)\", async () => {\n\tconst runtime = await createParaglide({\n\t\tblob: await newProject({\n\t\t\tsettings: {\n\t\t\t\tbaseLocale: \"en\",\n\t\t\t\tlocales: [\"en\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"url\"],\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \"/:path(.*)?\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t// CORRECT ORDER: more specific pattern first\n\t\t\t\t\t[\"de\", \"/de/:path(.*)?\"], // More specific pattern with prefix\n\t\t\t\t\t[\"en\", \"/:path(.*)?\"], // Less specific pattern without prefix\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\t// These should work correctly with the specific (de) pattern first\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/about\", { locale: \"en\" }).href\n\t).toBe(\"https://example.com/about\");\n\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/about\", { locale: \"de\" }).href\n\t).toBe(\"https://example.com/de/about\");\n\n\t// Delocalization should work correctly too\n\texpect(runtime.deLocalizeUrl(\"https://example.com/de/about\").href).toBe(\n\t\t\"https://example.com/about\"\n\t);\n});\n\n// Test showing the importance of pattern order in the localized array\ntest(\"pattern order in localized array - incorrect order (generic first)\", async () => {\n\tconst runtime = await createParaglide({\n\t\tblob: await newProject({\n\t\t\tsettings: {\n\t\t\t\tbaseLocale: \"en\",\n\t\t\t\tlocales: [\"en\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"url\"],\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \"/:path(.*)?\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t// INCORRECT ORDER: less specific pattern first\n\t\t\t\t\t[\"en\", \"/:path(.*)?\"], // Less specific pattern without prefix\n\t\t\t\t\t[\"de\", \"/de/:path(.*)?\"], // More specific pattern with prefix that may never match\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\t// English localization works as expected\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/about\", { locale: \"en\" }).href\n\t).toBe(\"https://example.com/about\");\n\n\t// German localization still works when explicitly requested\n\texpect(\n\t\truntime.localizeUrl(\"https://example.com/about\", { locale: \"de\" }).href\n\t).toBe(\"https://example.com/de/about\");\n\n\t// The problem happens with delocalization:\n\t// With incorrect pattern order, the generic /:path(.*)?\n\t// pattern matches first and swallows the /de/ prefix\n\texpect(runtime.deLocalizeUrl(\"https://example.com/de/about\").href).toBe(\n\t\t\"https://example.com/de/about\"\n\t); // Should be \"https://example.com/about\"\n});\n\n// Test for port number issue with specific port numbers in the URL pattern\ntest(\"handles explicit port numbers in URL patterns correctly\", async () => {\n\tconst runtime = await createParaglide({\n\t\tblob: await newProject({\n\t\t\tsettings: {\n\t\t\t\tbaseLocale: \"en\",\n\t\t\t\tlocales: [\"en\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"url\"],\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\t// Using explicit port number - this causes issues with deLocalizeUrl\n\t\t\t\tpattern: \"http://localhost:5173/:path(.*)?\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"de\", \"http://localhost:5173/de/:path(.*)?\"],\n\t\t\t\t\t[\"en\", \"http://localhost:5173/:path(.*)?\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\t// Localization should work correctly\n\texpect(\n\t\truntime.localizeUrl(\"http://localhost:5173/about\", { locale: \"de\" }).href\n\t).toBe(\"http://localhost:5173/de/about\");\n\n\texpect(\n\t\truntime.localizeUrl(\"http://localhost:5173/about\", { locale: \"en\" }).href\n\t).toBe(\"http://localhost:5173/about\");\n\n\t// This is where the bug occurs - delocalizing a URL with a port number\n\t// The port number (5173) is incorrectly treated as a path parameter\n\texpect(runtime.deLocalizeUrl(\"http://localhost:5173/de/about\").href).toBe(\n\t\t\"http://localhost:5173/about\"\n\t);\n});\n\n// Test for the correct approach using port as a pattern parameter\ntest(\"correctly handles port numbers as pattern parameters\", async () => {\n\tconst runtime = await createParaglide({\n\t\tblob: await newProject({\n\t\t\tsettings: {\n\t\t\t\tbaseLocale: \"en\",\n\t\t\t\tlocales: [\"en\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"url\"],\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\t// Using port as a proper pattern parameter with :: syntax\n\t\t\t\tpattern: \"http://localhost::port/:path(.*)?\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"de\", \"http://localhost::port/de/:path(.*)?\"],\n\t\t\t\t\t[\"en\", \"http://localhost::port/:path(.*)?\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\t// Localization should work correctly\n\texpect(\n\t\truntime.localizeUrl(\"http://localhost:5173/about\", { locale: \"de\" }).href\n\t).toBe(\"http://localhost:5173/de/about\");\n\n\texpect(\n\t\truntime.localizeUrl(\"http://localhost:5173/about\", { locale: \"en\" }).href\n\t).toBe(\"http://localhost:5173/about\");\n\n\t// Delocalization should also work correctly with the proper pattern\n\texpect(runtime.deLocalizeUrl(\"http://localhost:5173/de/about\").href).toBe(\n\t\t\"http://localhost:5173/about\"\n\t);\n});\n"]}
|
|
@@ -92,6 +92,47 @@ test("import statements in JSDoc examples survive in the generated runtime", ()
|
|
|
92
92
|
expect(runtime).toContain(` * import { m } from './messages.js'\n * m.hello({ name: 'world' }, { locale: "en" })`);
|
|
93
93
|
expect(runtime).not.toMatch(/^\s*import\s/m);
|
|
94
94
|
});
|
|
95
|
+
test.each(["JSDoc", "declarations"])("URL helpers accept readonly URLs through generated %s", async (mode) => {
|
|
96
|
+
let project = await typescriptProject({
|
|
97
|
+
useInMemoryFileSystem: true,
|
|
98
|
+
compilerOptions: superStrictRuleOutAnyErrorTsSettings,
|
|
99
|
+
});
|
|
100
|
+
project.createSourceFile("./runtime.js", createRuntimeFile({
|
|
101
|
+
baseLocale: "en",
|
|
102
|
+
locales: ["en", "de"],
|
|
103
|
+
compilerOptions: defaultCompilerOptions,
|
|
104
|
+
}));
|
|
105
|
+
if (mode === "declarations") {
|
|
106
|
+
let declaration = "";
|
|
107
|
+
project.createProgram().emit(undefined, (name, content) => {
|
|
108
|
+
if (name.endsWith("runtime.d.ts"))
|
|
109
|
+
declaration = content;
|
|
110
|
+
}, undefined, true);
|
|
111
|
+
expect(declaration).not.toBe("");
|
|
112
|
+
project = await typescriptProject({
|
|
113
|
+
useInMemoryFileSystem: true,
|
|
114
|
+
compilerOptions: superStrictRuleOutAnyErrorTsSettings,
|
|
115
|
+
});
|
|
116
|
+
project.createSourceFile("./runtime.d.ts", declaration);
|
|
117
|
+
}
|
|
118
|
+
project.createSourceFile("./consumer.ts", `import { localizeUrl, deLocalizeUrl } from "./runtime.js";
|
|
119
|
+
type ReadonlyURL = Readonly<Omit<URL, "searchParams"> & {
|
|
120
|
+
searchParams: Omit<URLSearchParams, "append" | "delete" | "set" | "sort">;
|
|
121
|
+
}>;
|
|
122
|
+
declare const page: { url: ReadonlyURL };
|
|
123
|
+
for (const input of [page.url, new URL("https://example.com"), "https://example.com"]) {
|
|
124
|
+
localizeUrl(input, { locale: "de" }) satisfies URL;
|
|
125
|
+
deLocalizeUrl(input) satisfies URL;
|
|
126
|
+
}
|
|
127
|
+
// @ts-expect-error - URL-like objects need an href
|
|
128
|
+
deLocalizeUrl({ pathname: "/about" });
|
|
129
|
+
// @ts-expect-error - href must be a string
|
|
130
|
+
localizeUrl({ href: 123 }, { locale: "de" });`);
|
|
131
|
+
const diagnostics = ts
|
|
132
|
+
.getPreEmitDiagnostics(project.createProgram())
|
|
133
|
+
.map((d) => ts.flattenDiagnosticMessageText(d.messageText, "\n"));
|
|
134
|
+
expect(diagnostics).toEqual([]);
|
|
135
|
+
});
|
|
95
136
|
test("runtime type", async () => {
|
|
96
137
|
const project = await typescriptProject({
|
|
97
138
|
useInMemoryFileSystem: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type.test.js","sourceRoot":"","sources":["../../../src/compiler/runtime/type.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EACN,aAAa,IAAI,iBAAiB,EAClC,EAAE,GAEF,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,sBAAsB,EAAE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createProject as typescriptProject,\n\tts,\n\ttype ProjectOptions,\n} from \"@ts-morph/bootstrap\";\nimport { createRuntimeFile } from \"./create-runtime.js\";\nimport fs from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\nimport { fileURLToPath } from \"url\";\nimport { defaultCompilerOptions } from \"../compiler-options.js\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\nconst superStrictRuleOutAnyErrorTsSettings: ProjectOptions[\"compilerOptions\"] =\n\t{\n\t\toutDir: \"dist\",\n\t\tdeclaration: true,\n\t\tallowJs: true,\n\t\tcheckJs: true,\n\t\tnoImplicitAny: true,\n\t\tnoUnusedLocals: true,\n\t\tnoUnusedParameters: true,\n\t\tnoImplicitReturns: true,\n\t\tnoImplicitThis: true,\n\t\tnoUncheckedIndexedAccess: true,\n\t\tnoPropertyAccessFromIndexSignature: true,\n\t\tmodule: ts.ModuleKind.Node16,\n\t\tstrict: true,\n\t};\n\ntest(\"createRuntimeFile throws if urlPatterns contains an unknown locale\", () => {\n\texpect(() =>\n\t\tcreateRuntimeFile({\n\t\t\tbaseLocale: \"en\",\n\t\t\tlocales: [\"en\", \"de\"],\n\t\t\tcompilerOptions: {\n\t\t\t\t...defaultCompilerOptions,\n\t\t\t\turlPatterns: [\n\t\t\t\t\t{\n\t\t\t\t\t\tpattern: \"https://example.com/:path*\",\n\t\t\t\t\t\tlocalized: [[\"fr\", \"https://example.com/fr/:path*\"]],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t})\n\t).toThrow(\n\t\t'Invalid locale \"fr\" in urlPatterns. It must be one of the locales defined in the \"locales\" array.'\n\t);\n});\n\ntest(\"createRuntimeFile throws if cookieSameSite is 'none' without cookieSecure\", () => {\n\tconst create = (cookieSecure?: boolean | \"auto\") =>\n\t\tcreateRuntimeFile({\n\t\t\tbaseLocale: \"en\",\n\t\t\tlocales: [\"en\", \"de\"],\n\t\t\tcompilerOptions: {\n\t\t\t\t...defaultCompilerOptions,\n\t\t\t\tcookieSameSite: \"none\",\n\t\t\t\tcookieSecure,\n\t\t\t},\n\t\t});\n\n\texpect(() => create()).toThrow(\n\t\t'cookieSameSite \"none\" requires cookieSecure to be true or \"auto\". Browsers reject SameSite=None cookies without the Secure attribute.'\n\t);\n\texpect(() => create(false)).toThrow();\n\texpect(() => create(true)).not.toThrow();\n\texpect(() => create(\"auto\")).not.toThrow();\n});\n\ntest(\"runtime with cookie attributes passes checkJs\", async () => {\n\tconst project = await typescriptProject({\n\t\tuseInMemoryFileSystem: true,\n\t\tcompilerOptions: superStrictRuleOutAnyErrorTsSettings,\n\t});\n\n\tproject.createSourceFile(\n\t\t\"./runtime.js\",\n\t\tcreateRuntimeFile({\n\t\t\tbaseLocale: \"en\",\n\t\t\tlocales: [\"en\", \"de\"],\n\t\t\tcompilerOptions: {\n\t\t\t\t...defaultCompilerOptions,\n\t\t\t\tcookieSameSite: \"lax\",\n\t\t\t\tcookieSecure: \"auto\",\n\t\t\t},\n\t\t})\n\t);\n\n\tconst diagnostics = ts\n\t\t.getPreEmitDiagnostics(project.createProgram())\n\t\t.map((d) => ts.flattenDiagnosticMessageText(d.messageText, \"\\n\"));\n\n\texpect(diagnostics).toEqual([]);\n});\n\ntest(\"cookie cache clearer remains internal in the generated runtime\", () => {\n\tconst jsdocRuntime = createRuntimeFile({\n\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\", \"de\"],\n\t\tcompilerOptions: {\n\t\t\t...defaultCompilerOptions,\n\t\t\tstrategy: [\"cookie\", \"baseLocale\"],\n\t\t},\n\t});\n\n\texpect(jsdocRuntime).toContain(\"function clearLocaleCookieCache\");\n\texpect(jsdocRuntime).not.toContain(\"export function clearLocaleCookieCache\");\n});\n\ntest(\"import statements in JSDoc examples survive in the generated runtime\", () => {\n\tconst runtime = createRuntimeFile({\n\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\", \"de\"],\n\t\tcompilerOptions: defaultCompilerOptions,\n\t});\n\n\texpect(runtime).toContain(\n\t\t` * import { m } from './messages.js'\\n * m.hello({ name: 'world' }, { locale: \"en\" })`\n\t);\n\texpect(runtime).not.toMatch(/^\\s*import\\s/m);\n});\n\ntest(\"runtime type\", async () => {\n\tconst project = await typescriptProject({\n\t\tuseInMemoryFileSystem: true,\n\t\tcompilerOptions: superStrictRuleOutAnyErrorTsSettings,\n\t});\n\n\tconst jsdocRuntime = createRuntimeFile({\n\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\"],\n\t\tcompilerOptions: defaultCompilerOptions,\n\t}).replace(\n\t\t'import * as pathToRegexp from \"@inlang/paraglide-js/path-to-regexp\";',\n\t\t\"\"\n\t);\n\n\tconst file = (path: string) => {\n\t\treturn [path, fs.readFileSync(resolve(__dirname, path), \"utf-8\")!] as const;\n\t};\n\n\tproject.createSourceFile(\"./runtime.js\", jsdocRuntime);\n\tproject.createSourceFile(...file(\"./type.ts\"));\n\tproject.createSourceFile(...file(\"./ambient.d.ts\"));\n\n\t// add the imports for the types in the runtime type\n\tfor (const name of fs.readdirSync(__dirname)) {\n\t\tif (name.endsWith(\".js\")) {\n\t\t\tproject.createSourceFile(...file(name));\n\t\t}\n\t}\n\n\tproject.createSourceFile(\n\t\t\"./test.ts\",\n\t\t`\n import * as runtime from \"./runtime.js\"\n import type { Runtime } from \"./type.js\"\n\n runtime satisfies Runtime\n\n\t\t// getLocale() should return type should be a union of language tags, not a generic string\n runtime.getLocale() satisfies \"de\" | \"en\" | \"en-US\"\n\n // locales should have a narrow type, not a generic string\n runtime.locales satisfies Readonly<Array<\"de\" | \"en\" | \"en-US\">>\n\n // setLocale() should fail if the given language tag is not included in locales\n // @ts-expect-error - invalid locale\n runtime.setLocale(\"fr\")\n\n // setLocale() should not fail if the given language tag is included in locales\n runtime.setLocale(\"de\")\n\n\t\t// getTextDirection() should return a strict direction union\n\t\truntime.getTextDirection() satisfies \"ltr\" | \"rtl\"\n\n\t\t// isLocale should narrow the type of it's argument\n\t\tconst thing = 5;\n\n\t\tlet a: \"de\" | \"en\" | \"en-US\";\n\n\t\tif(runtime.isLocale(thing)) {\n\t\t\ta = thing\n\t\t} else {\n\t\t\t// @ts-expect-error - thing is not a language tag\n\t\t\ta = thing\n\t\t}\n\n\t\t// to make ts not complain about unused variables\n\t\truntime.toLocale(\"EN\") satisfies \"de\" | \"en\" | \"en-US\" | undefined\n\t\truntime.toLocale(123) satisfies \"de\" | \"en\" | \"en-US\" | undefined\n\n\t\tconsole.log(a)\n `\n\t);\n\n\tconst program = project.createProgram();\n\tconst diagnostics = ts\n\t\t.getPreEmitDiagnostics(program)\n\t\t// ignore 'export' modifier cannot be applied to ambient modules and module augmentations since they are always visible. /ambient.d.ts\n\t\t.filter((d) => d.code !== 2668)\n\t\t.filter((d) => d.messageText.toString().includes(\"path-to-regexp\"));\n\tfor (const diagnostic of diagnostics) {\n\t\tconsole.error(diagnostic.messageText, diagnostic.file?.fileName);\n\t}\n\texpect(diagnostics.length).toEqual(0);\n});\n"]}
|
|
1
|
+
{"version":3,"file":"type.test.js","sourceRoot":"","sources":["../../../src/compiler/runtime/type.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EACN,aAAa,IAAI,iBAAiB,EAClC,EAAE,GAEF,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,MAAM,UAAU,GAAG,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAEtC,MAAM,oCAAoC,GACzC;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\nimport { createRuntimeFile } from \"./create-runtime.js\";\nimport fs from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\nimport { fileURLToPath } from \"url\";\nimport { defaultCompilerOptions } from \"../compiler-options.js\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\nconst superStrictRuleOutAnyErrorTsSettings: ProjectOptions[\"compilerOptions\"] =\n\t{\n\t\toutDir: \"dist\",\n\t\tdeclaration: true,\n\t\tallowJs: true,\n\t\tcheckJs: true,\n\t\tnoImplicitAny: true,\n\t\tnoUnusedLocals: true,\n\t\tnoUnusedParameters: true,\n\t\tnoImplicitReturns: true,\n\t\tnoImplicitThis: true,\n\t\tnoUncheckedIndexedAccess: true,\n\t\tnoPropertyAccessFromIndexSignature: true,\n\t\tmodule: ts.ModuleKind.Node16,\n\t\tstrict: true,\n\t};\n\ntest(\"createRuntimeFile throws if urlPatterns contains an unknown locale\", () => {\n\texpect(() =>\n\t\tcreateRuntimeFile({\n\t\t\tbaseLocale: \"en\",\n\t\t\tlocales: [\"en\", \"de\"],\n\t\t\tcompilerOptions: {\n\t\t\t\t...defaultCompilerOptions,\n\t\t\t\turlPatterns: [\n\t\t\t\t\t{\n\t\t\t\t\t\tpattern: \"https://example.com/:path*\",\n\t\t\t\t\t\tlocalized: [[\"fr\", \"https://example.com/fr/:path*\"]],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t})\n\t).toThrow(\n\t\t'Invalid locale \"fr\" in urlPatterns. It must be one of the locales defined in the \"locales\" array.'\n\t);\n});\n\ntest(\"createRuntimeFile throws if cookieSameSite is 'none' without cookieSecure\", () => {\n\tconst create = (cookieSecure?: boolean | \"auto\") =>\n\t\tcreateRuntimeFile({\n\t\t\tbaseLocale: \"en\",\n\t\t\tlocales: [\"en\", \"de\"],\n\t\t\tcompilerOptions: {\n\t\t\t\t...defaultCompilerOptions,\n\t\t\t\tcookieSameSite: \"none\",\n\t\t\t\tcookieSecure,\n\t\t\t},\n\t\t});\n\n\texpect(() => create()).toThrow(\n\t\t'cookieSameSite \"none\" requires cookieSecure to be true or \"auto\". Browsers reject SameSite=None cookies without the Secure attribute.'\n\t);\n\texpect(() => create(false)).toThrow();\n\texpect(() => create(true)).not.toThrow();\n\texpect(() => create(\"auto\")).not.toThrow();\n});\n\ntest(\"runtime with cookie attributes passes checkJs\", async () => {\n\tconst project = await typescriptProject({\n\t\tuseInMemoryFileSystem: true,\n\t\tcompilerOptions: superStrictRuleOutAnyErrorTsSettings,\n\t});\n\n\tproject.createSourceFile(\n\t\t\"./runtime.js\",\n\t\tcreateRuntimeFile({\n\t\t\tbaseLocale: \"en\",\n\t\t\tlocales: [\"en\", \"de\"],\n\t\t\tcompilerOptions: {\n\t\t\t\t...defaultCompilerOptions,\n\t\t\t\tcookieSameSite: \"lax\",\n\t\t\t\tcookieSecure: \"auto\",\n\t\t\t},\n\t\t})\n\t);\n\n\tconst diagnostics = ts\n\t\t.getPreEmitDiagnostics(project.createProgram())\n\t\t.map((d) => ts.flattenDiagnosticMessageText(d.messageText, \"\\n\"));\n\n\texpect(diagnostics).toEqual([]);\n});\n\ntest(\"cookie cache clearer remains internal in the generated runtime\", () => {\n\tconst jsdocRuntime = createRuntimeFile({\n\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\", \"de\"],\n\t\tcompilerOptions: {\n\t\t\t...defaultCompilerOptions,\n\t\t\tstrategy: [\"cookie\", \"baseLocale\"],\n\t\t},\n\t});\n\n\texpect(jsdocRuntime).toContain(\"function clearLocaleCookieCache\");\n\texpect(jsdocRuntime).not.toContain(\"export function clearLocaleCookieCache\");\n});\n\ntest(\"import statements in JSDoc examples survive in the generated runtime\", () => {\n\tconst runtime = createRuntimeFile({\n\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\", \"de\"],\n\t\tcompilerOptions: defaultCompilerOptions,\n\t});\n\n\texpect(runtime).toContain(\n\t\t` * import { m } from './messages.js'\\n * m.hello({ name: 'world' }, { locale: \"en\" })`\n\t);\n\texpect(runtime).not.toMatch(/^\\s*import\\s/m);\n});\n\ntest.each([\"JSDoc\", \"declarations\"])(\n\t\"URL helpers accept readonly URLs through generated %s\",\n\tasync (mode) => {\n\t\tlet project = await typescriptProject({\n\t\t\tuseInMemoryFileSystem: true,\n\t\t\tcompilerOptions: superStrictRuleOutAnyErrorTsSettings,\n\t\t});\n\t\tproject.createSourceFile(\n\t\t\t\"./runtime.js\",\n\t\t\tcreateRuntimeFile({\n\t\t\t\tbaseLocale: \"en\",\n\t\t\t\tlocales: [\"en\", \"de\"],\n\t\t\t\tcompilerOptions: defaultCompilerOptions,\n\t\t\t})\n\t\t);\n\t\tif (mode === \"declarations\") {\n\t\t\tlet declaration = \"\";\n\t\t\tproject.createProgram().emit(\n\t\t\t\tundefined,\n\t\t\t\t(name, content) => {\n\t\t\t\t\tif (name.endsWith(\"runtime.d.ts\")) declaration = content;\n\t\t\t\t},\n\t\t\t\tundefined,\n\t\t\t\ttrue\n\t\t\t);\n\t\t\texpect(declaration).not.toBe(\"\");\n\t\t\tproject = await typescriptProject({\n\t\t\t\tuseInMemoryFileSystem: true,\n\t\t\t\tcompilerOptions: superStrictRuleOutAnyErrorTsSettings,\n\t\t\t});\n\t\t\tproject.createSourceFile(\"./runtime.d.ts\", declaration);\n\t\t}\n\t\tproject.createSourceFile(\n\t\t\t\"./consumer.ts\",\n\t\t\t`import { localizeUrl, deLocalizeUrl } from \"./runtime.js\";\ntype ReadonlyURL = Readonly<Omit<URL, \"searchParams\"> & {\n searchParams: Omit<URLSearchParams, \"append\" | \"delete\" | \"set\" | \"sort\">;\n}>;\ndeclare const page: { url: ReadonlyURL };\nfor (const input of [page.url, new URL(\"https://example.com\"), \"https://example.com\"]) {\n localizeUrl(input, { locale: \"de\" }) satisfies URL;\n deLocalizeUrl(input) satisfies URL;\n}\n// @ts-expect-error - URL-like objects need an href\ndeLocalizeUrl({ pathname: \"/about\" });\n// @ts-expect-error - href must be a string\nlocalizeUrl({ href: 123 }, { locale: \"de\" });`\n\t\t);\n\t\tconst diagnostics = ts\n\t\t\t.getPreEmitDiagnostics(project.createProgram())\n\t\t\t.map((d) => ts.flattenDiagnosticMessageText(d.messageText, \"\\n\"));\n\t\texpect(diagnostics).toEqual([]);\n\t}\n);\n\ntest(\"runtime type\", async () => {\n\tconst project = await typescriptProject({\n\t\tuseInMemoryFileSystem: true,\n\t\tcompilerOptions: superStrictRuleOutAnyErrorTsSettings,\n\t});\n\n\tconst jsdocRuntime = createRuntimeFile({\n\t\tbaseLocale: \"en\",\n\t\tlocales: [\"en\"],\n\t\tcompilerOptions: defaultCompilerOptions,\n\t}).replace(\n\t\t'import * as pathToRegexp from \"@inlang/paraglide-js/path-to-regexp\";',\n\t\t\"\"\n\t);\n\n\tconst file = (path: string) => {\n\t\treturn [path, fs.readFileSync(resolve(__dirname, path), \"utf-8\")!] as const;\n\t};\n\n\tproject.createSourceFile(\"./runtime.js\", jsdocRuntime);\n\tproject.createSourceFile(...file(\"./type.ts\"));\n\tproject.createSourceFile(...file(\"./ambient.d.ts\"));\n\n\t// add the imports for the types in the runtime type\n\tfor (const name of fs.readdirSync(__dirname)) {\n\t\tif (name.endsWith(\".js\")) {\n\t\t\tproject.createSourceFile(...file(name));\n\t\t}\n\t}\n\n\tproject.createSourceFile(\n\t\t\"./test.ts\",\n\t\t`\n import * as runtime from \"./runtime.js\"\n import type { Runtime } from \"./type.js\"\n\n runtime satisfies Runtime\n\n\t\t// getLocale() should return type should be a union of language tags, not a generic string\n runtime.getLocale() satisfies \"de\" | \"en\" | \"en-US\"\n\n // locales should have a narrow type, not a generic string\n runtime.locales satisfies Readonly<Array<\"de\" | \"en\" | \"en-US\">>\n\n // setLocale() should fail if the given language tag is not included in locales\n // @ts-expect-error - invalid locale\n runtime.setLocale(\"fr\")\n\n // setLocale() should not fail if the given language tag is included in locales\n runtime.setLocale(\"de\")\n\n\t\t// getTextDirection() should return a strict direction union\n\t\truntime.getTextDirection() satisfies \"ltr\" | \"rtl\"\n\n\t\t// isLocale should narrow the type of it's argument\n\t\tconst thing = 5;\n\n\t\tlet a: \"de\" | \"en\" | \"en-US\";\n\n\t\tif(runtime.isLocale(thing)) {\n\t\t\ta = thing\n\t\t} else {\n\t\t\t// @ts-expect-error - thing is not a language tag\n\t\t\ta = thing\n\t\t}\n\n\t\t// to make ts not complain about unused variables\n\t\truntime.toLocale(\"EN\") satisfies \"de\" | \"en\" | \"en-US\" | undefined\n\t\truntime.toLocale(123) satisfies \"de\" | \"en\" | \"en-US\" | undefined\n\n\t\tconsole.log(a)\n `\n\t);\n\n\tconst program = project.createProgram();\n\tconst diagnostics = ts\n\t\t.getPreEmitDiagnostics(program)\n\t\t// ignore 'export' modifier cannot be applied to ambient modules and module augmentations since they are always visible. /ambient.d.ts\n\t\t.filter((d) => d.code !== 2668)\n\t\t.filter((d) => d.messageText.toString().includes(\"path-to-regexp\"));\n\tfor (const diagnostic of diagnostics) {\n\t\tconsole.error(diagnostic.messageText, diagnostic.file?.fileName);\n\t}\n\texpect(diagnostics.length).toEqual(0);\n});\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/env-variables/index.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,aAAa,GAAG;IAC5B,qBAAqB,EAAE,QAAQ;CAC/B,CAAA","sourcesContent":["\nexport const ENV_VARIABLES = {\n\tPARJS_PACKAGE_VERSION: \"2.
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/env-variables/index.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,aAAa,GAAG;IAC5B,qBAAqB,EAAE,QAAQ;CAC/B,CAAA","sourcesContent":["\nexport const ENV_VARIABLES = {\n\tPARJS_PACKAGE_VERSION: \"2.29.0\",\n}\n"]}
|