@inlang/paraglide-js 2.0.4 → 2.0.6

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.
@@ -545,6 +545,30 @@ describe.each([
545
545
  runtime.setLocale("en-US");
546
546
  expect(m.missing_in_en_US()).toBe("Fallback message.");
547
547
  });
548
+ test("arbitrary module identifiers", async () => {
549
+ const project = await loadProjectInMemory({
550
+ blob: await newProject({
551
+ settings: { locales: ["en"], baseLocale: "en" },
552
+ }),
553
+ });
554
+ await insertBundleNested(project.db, createBundleNested({
555
+ id: "happy🍌",
556
+ messages: [
557
+ {
558
+ locale: "en",
559
+ variants: [{ pattern: [{ type: "text", value: "Hello" }] }],
560
+ },
561
+ ],
562
+ }));
563
+ const output = await compileProject({
564
+ project,
565
+ compilerOptions,
566
+ });
567
+ const code = await bundleCode(output, `export * as m from "./paraglide/messages.js"
568
+ export * as runtime from "./paraglide/runtime.js"`);
569
+ const { m } = await importCode(code);
570
+ expect(m["happy🍌"]()).toBe("Hello");
571
+ });
548
572
  });
549
573
  test("case sensitivity handling for bundle IDs", async () => {
550
574
  // skip local modules for now because the option might get removed in the future
@@ -719,6 +743,27 @@ const mockBundles = [
719
743
  },
720
744
  ],
721
745
  }),
746
+ createBundleNested({
747
+ id: "Sad_penguin_bundle",
748
+ messages: [
749
+ {
750
+ locale: "en",
751
+ variants: [
752
+ { pattern: [{ type: "text", value: "Capital Sad penguin" }] },
753
+ ],
754
+ },
755
+ {
756
+ locale: "de",
757
+ variants: [
758
+ {
759
+ pattern: [
760
+ { type: "text", value: "Grossgeschriebenes Sad penguin" },
761
+ ],
762
+ },
763
+ ],
764
+ },
765
+ ],
766
+ }),
722
767
  {
723
768
  id: "depressed_dog",
724
769
  declarations: [
@@ -1 +1 @@
1
- {"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../src/compiler/compile.ts"],"names":[],"mappings":"AASA,OAAO,EAEN,KAAK,eAAe,EACpB,MAAM,uBAAuB,CAAC;AAQ/B,MAAM,MAAM,iBAAiB,GAAG;IAC/B,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;CACjD,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,wBAAsB,OAAO,CAC5B,OAAO,EAAE,eAAe,GAAG;IAC1B,mBAAmB,CAAC,EAAE,iBAAiB,CAAC;CACxC,GACC,OAAO,CAAC,iBAAiB,CAAC,CA+D5B"}
1
+ {"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../src/compiler/compile.ts"],"names":[],"mappings":"AASA,OAAO,EAEN,KAAK,eAAe,EACpB,MAAM,uBAAuB,CAAC;AAS/B,MAAM,MAAM,iBAAiB,GAAG;IAC/B,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;CACjD,CAAC;AAIF;;;;;;;;;;;;GAYG;AACH,wBAAsB,OAAO,CAC5B,OAAO,EAAE,eAAe,GAAG;IAC1B,mBAAmB,CAAC,EAAE,iBAAiB,CAAC;CACxC,GACC,OAAO,CAAC,iBAAiB,CAAC,CAqE5B"}
@@ -5,9 +5,11 @@ import { compileProject } from "./compile-project.js";
5
5
  import { writeOutput } from "../services/file-handling/write-output.js";
6
6
  import { getLocalAccount, saveLocalAccount, } from "../services/account/index.js";
7
7
  import { defaultCompilerOptions, } from "./compiler-options.js";
8
+ import { Logger } from "../services/logger/index.js";
8
9
  // This is a workaround to prevent multiple compilations from running at the same time.
9
10
  // https://github.com/opral/inlang-paraglide-js/issues/320#issuecomment-2596951222
10
11
  let compilationInProgress = null;
12
+ const logger = new Logger();
11
13
  /**
12
14
  * Loads, compiles, and writes the output to disk.
13
15
  *
@@ -58,6 +60,10 @@ export async function compile(options) {
58
60
  .executeTakeFirstOrThrow();
59
61
  saveLocalAccount({ fs, account: activeAccount });
60
62
  }
63
+ const warningsAndErrors = await project.errors.get();
64
+ for (const warningOrError of warningsAndErrors) {
65
+ logger.warn(warningOrError);
66
+ }
61
67
  await project.close();
62
68
  return { outputHashes };
63
69
  }
@@ -4,6 +4,7 @@ import { test, expect, vi } from "vitest";
4
4
  import { compile } from "./compile.js";
5
5
  import { getAccountFilePath } from "../services/account/index.js";
6
6
  import { defaultCompilerOptions } from "./compiler-options.js";
7
+ import consola from "consola";
7
8
  test("loads a project and compiles it", async () => {
8
9
  const project = await loadProjectInMemory({
9
10
  blob: await newProject({
@@ -258,3 +259,55 @@ test("default compiler options should include cookied, variable and baseLocale t
258
259
  "baseLocale",
259
260
  ]);
260
261
  });
262
+ test("emits warnings for modules that couldn't be imported locally", async () => {
263
+ const project = await loadProjectInMemory({
264
+ blob: await newProject({
265
+ settings: {
266
+ baseLocale: "en",
267
+ locales: ["en", "de", "fr"],
268
+ modules: ["./non-existent-paraglide-plugin.js"],
269
+ },
270
+ }),
271
+ });
272
+ const mock = vi.fn();
273
+ consola.mockTypes(() => mock);
274
+ const fs = memfs().fs;
275
+ // save project to directory to test loading
276
+ await saveProjectToDirectory({
277
+ project,
278
+ path: "/project.inlang",
279
+ fs: fs.promises,
280
+ });
281
+ await compile({
282
+ project: "/project.inlang",
283
+ outdir: "/output",
284
+ fs: fs,
285
+ });
286
+ expect(mock).toHaveBeenCalled();
287
+ });
288
+ test("emits warnings for modules that couldn't be imported via http", async () => {
289
+ const project = await loadProjectInMemory({
290
+ blob: await newProject({
291
+ settings: {
292
+ baseLocale: "en",
293
+ locales: ["en", "de", "fr"],
294
+ modules: ["https://example.com/non-existent-paraglide-plugin.js"],
295
+ },
296
+ }),
297
+ });
298
+ const mock = vi.fn();
299
+ consola.mockTypes(() => mock);
300
+ const fs = memfs().fs;
301
+ // save project to directory to test loading
302
+ await saveProjectToDirectory({
303
+ project,
304
+ path: "/project.inlang",
305
+ fs: fs.promises,
306
+ });
307
+ await compile({
308
+ project: "/project.inlang",
309
+ outdir: "/output",
310
+ fs: fs,
311
+ });
312
+ expect(mock).toHaveBeenCalled();
313
+ });
@@ -11,6 +11,7 @@ export declare const defaultCompilerOptions: {
11
11
  readonly isServer: "typeof window === 'undefined'";
12
12
  readonly strategy: ["cookie", "globalVariable", "baseLocale"];
13
13
  readonly cookieName: "PARAGLIDE_LOCALE";
14
+ readonly cookieMaxAge: number;
14
15
  };
15
16
  export type CompilerOptions = {
16
17
  /**
@@ -94,6 +95,12 @@ export type CompilerOptions = {
94
95
  * @default 'PARAGLIDE_LOCALE'
95
96
  */
96
97
  cookieName?: string;
98
+ /**
99
+ * The max-age in seconds of the cookie until it expires.
100
+ *
101
+ * @default 60 * 60 * 24 * 400
102
+ */
103
+ cookieMaxAge?: number;
97
104
  /**
98
105
  * The `additionalFiles` option is an array of paths to additional files that should be copied to the output directory.
99
106
  *
@@ -1 +1 @@
1
- {"version":3,"file":"compiler-options.d.ts","sourceRoot":"","sources":["../../src/compiler/compiler-options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEjD,eAAO,MAAM,sBAAsB;;;;;;;;;;;;CAYU,CAAC;AAE9C,MAAM,MAAM,eAAe,GAAG;IAC7B;;;;;;;;;;OAUG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;;;;;;OAUG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;;;;;;;;;;;;OAcG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IAC/B;;;;;;;;;;;;;;OAcG;IACH,qCAAqC,CAAC,EAAE,OAAO,CAAC;IAChD;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC;;;;;;;;;;;;OAYG;IACH,kBAAk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Ae,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC;;;;;;;;;;;;OAYG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;IACrC;;;;OAIG;IACH,2BAA2B,CAAC,EAAE,OAAO,CAAC;IACtC;;;;;;;;;OASG;IACH,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC;;;;;;;;;;;;OAYG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6CG;IACH,eAAe,CAAC,EAAE,gBAAgB,GAAG,iBAAiB,CAAC;IACvD;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;;;OAIG;IACH,EAAE,CAAC,EAAE,GAAG,CAAC;CACT,CAAC"}
@@ -10,4 +10,5 @@ export const defaultCompilerOptions = {
10
10
  isServer: "typeof window === 'undefined'",
11
11
  strategy: ["cookie", "globalVariable", "baseLocale"],
12
12
  cookieName: "PARAGLIDE_LOCALE",
13
+ cookieMaxAge: 60 * 60 * 24 * 400,
13
14
  };
@@ -1 +1 @@
1
- {"version":3,"file":"locale-modules.d.ts","sourceRoot":"","sources":["../../../src/compiler/output-structure/locale-modules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAIvE,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,UAE1E;AAED,wBAAgB,cAAc,CAC7B,eAAe,EAAE,0BAA0B,EAAE,EAC7C,QAAQ,EAAE,IAAI,CAAC,eAAe,EAAE,SAAS,GAAG,YAAY,CAAC,EACzD,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAC7C,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAoDxB"}
1
+ {"version":3,"file":"locale-modules.d.ts","sourceRoot":"","sources":["../../../src/compiler/output-structure/locale-modules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAavE,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,UAY1E;AAED,wBAAgB,cAAc,CAC7B,eAAe,EAAE,0BAA0B,EAAE,EAC7C,QAAQ,EAAE,IAAI,CAAC,eAAe,EAAE,SAAS,GAAG,YAAY,CAAC,EACzD,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAC7C,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAgIxB"}
@@ -1,15 +1,66 @@
1
1
  import { toSafeModuleId } from "../safe-module-id.js";
2
2
  import { inputsType } from "../jsdoc-types.js";
3
+ // Helper function to escape special characters in a string for use in a regular expression
4
+ function escapeRegExp(string) {
5
+ return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
6
+ }
7
+ // This map will be used to track which bundle IDs have been renamed to which unique IDs
8
+ // It will be populated during the generateOutput function and used in messageReferenceExpression
9
+ const bundleIdToUniqueIdMap = new Map();
3
10
  export function messageReferenceExpression(locale, bundleId) {
4
- return `${toSafeModuleId(locale)}.${toSafeModuleId(bundleId)}`;
11
+ // First convert to safe module ID
12
+ const safeModuleId = toSafeModuleId(bundleId);
13
+ // Check if this bundleId has been mapped to a unique identifier
14
+ const uniqueId = bundleIdToUniqueIdMap.get(bundleId);
15
+ if (uniqueId) {
16
+ return `${toSafeModuleId(locale)}.${uniqueId}`;
17
+ }
18
+ // Otherwise, return the default safe module ID
19
+ return `${toSafeModuleId(locale)}.${safeModuleId}`;
5
20
  }
6
21
  export function generateOutput(compiledBundles, settings, fallbackMap) {
22
+ // Create a map to track module IDs in the index file to avoid duplicates
23
+ const indexModuleIdMap = new Map();
24
+ // Process the bundles to ensure no duplicate bundle IDs
25
+ // Generate unique moduleIds for duplicate IDs
26
+ const processedBundleCodes = compiledBundles
27
+ .map(({ bundle }) => {
28
+ const bundleId = bundle.node.id;
29
+ const bundleModuleId = toSafeModuleId(bundleId);
30
+ // Check if this safe module ID has been used before
31
+ if (indexModuleIdMap.has(bundleModuleId)) {
32
+ // Create a unique identifier by adding a counter
33
+ let counter = 1;
34
+ let uniqueModuleId = `${bundleModuleId}${counter}`;
35
+ while (indexModuleIdMap.has(uniqueModuleId)) {
36
+ counter++;
37
+ uniqueModuleId = `${bundleModuleId}${counter}`;
38
+ }
39
+ // Modify the code to use the unique identifier
40
+ const modifiedCode = bundle.code
41
+ .replace(new RegExp(`const ${bundleModuleId} =`, "g"), `const ${uniqueModuleId} =`)
42
+ .replace(new RegExp(`export const ${bundleModuleId} =`, "g"), `export const ${uniqueModuleId} =`)
43
+ .replace(new RegExp(`export { ${bundleModuleId}`, "g"), `export { ${uniqueModuleId}`)
44
+ .replace(
45
+ // Also update the trackMessageCall to use the new identifier
46
+ new RegExp(`trackMessageCall\\("${escapeRegExp(bundleId)}"`, "g"), `trackMessageCall("${bundleId}"`);
47
+ // Store the unique ID mapping
48
+ indexModuleIdMap.set(uniqueModuleId, bundleId);
49
+ // Also store in the global map for messageReferenceExpression to use
50
+ bundleIdToUniqueIdMap.set(bundleId, uniqueModuleId);
51
+ return modifiedCode;
52
+ }
53
+ // Store the mapping
54
+ indexModuleIdMap.set(bundleModuleId, bundleId);
55
+ return bundle.code;
56
+ })
57
+ .join("\n");
7
58
  const indexFile = [
8
59
  `import { getLocale, trackMessageCall, experimentalMiddlewareLocaleSplitting, isServer } from "../runtime.js"`,
9
60
  settings.locales
10
61
  .map((locale) => `import * as ${toSafeModuleId(locale)} from "./${locale}.js"`)
11
62
  .join("\n"),
12
- compiledBundles.map(({ bundle }) => bundle.code).join("\n"),
63
+ processedBundleCodes,
13
64
  ].join("\n");
14
65
  const output = {
15
66
  ["messages/_index.js"]: indexFile,
@@ -18,24 +69,39 @@ export function generateOutput(compiledBundles, settings, fallbackMap) {
18
69
  for (const locale of settings.locales) {
19
70
  const filename = `messages/${locale}.js`;
20
71
  let file = "";
72
+ // Keep track of module IDs to avoid duplicates
73
+ const moduleIdMap = new Map();
21
74
  for (const compiledBundle of compiledBundles) {
22
75
  const compiledMessage = compiledBundle.messages[locale];
23
- const bundleModuleId = toSafeModuleId(compiledBundle.bundle.node.id);
24
76
  const bundleId = compiledBundle.bundle.node.id;
77
+ const bundleModuleId = toSafeModuleId(compiledBundle.bundle.node.id);
78
+ // Check if this module ID has already been used
79
+ let uniqueModuleId = bundleModuleId;
80
+ if (moduleIdMap.has(bundleModuleId)) {
81
+ // If it has, create a unique ID by adding an index
82
+ let counter = 1;
83
+ uniqueModuleId = `${bundleModuleId}${counter}`;
84
+ while (moduleIdMap.has(uniqueModuleId)) {
85
+ counter++;
86
+ uniqueModuleId = `${bundleModuleId}${counter}`;
87
+ }
88
+ }
89
+ // Store this module ID
90
+ moduleIdMap.set(uniqueModuleId, bundleId);
25
91
  const inputs = compiledBundle.bundle.node.declarations?.filter((decl) => decl.type === "input-variable") ?? [];
26
92
  if (!compiledMessage) {
27
93
  const fallbackLocale = fallbackMap[locale];
28
94
  if (fallbackLocale) {
29
95
  // use the fall back locale e.g. render the message in English if the German message is missing
30
- file += `\nexport { ${bundleModuleId} } from "./${fallbackLocale}.js"`;
96
+ file += `\nexport { ${uniqueModuleId} } from "./${fallbackLocale}.js"`;
31
97
  }
32
98
  else {
33
99
  // no fallback exists, render the bundleId
34
- file += `\n/** @type {(inputs: ${inputsType(inputs)}) => string} */ */\nexport const ${bundleModuleId} = () => '${bundleId}'`;
100
+ file += `\n/** @type {(inputs: ${inputsType(inputs)}) => string} */\nexport const ${uniqueModuleId} = () => '${bundleId}'`;
35
101
  }
36
102
  continue;
37
103
  }
38
- file += `\n\nexport const ${bundleModuleId} = ${compiledMessage.code}`;
104
+ file += `\n\nexport const ${uniqueModuleId} = ${compiledMessage.code}`;
39
105
  }
40
106
  // add import if used
41
107
  if (file.includes("registry.")) {
@@ -59,3 +59,47 @@ test("the files should include files for each locale, even if there are no messa
59
59
  expect(output).toHaveProperty("messages/de.js");
60
60
  expect(output).toHaveProperty("messages/fr.js");
61
61
  });
62
+ test("should handle case sensitivity in message IDs correctly", () => {
63
+ const bundles = [
64
+ {
65
+ bundle: {
66
+ code: 'console.log("bundle code");',
67
+ node: {
68
+ id: "sad_penguin_bundle",
69
+ },
70
+ },
71
+ messages: {
72
+ en: {
73
+ code: 'console.log("sad_penguin_bundle");',
74
+ node: {},
75
+ },
76
+ },
77
+ },
78
+ {
79
+ bundle: {
80
+ code: 'console.log("bundle code");',
81
+ node: {
82
+ id: "Sad_penguin_bundle",
83
+ },
84
+ },
85
+ messages: {
86
+ en: {
87
+ code: 'console.log("Sad_penguin_bundle");',
88
+ node: {},
89
+ },
90
+ },
91
+ },
92
+ ];
93
+ const settings = {
94
+ locales: ["en"],
95
+ baseLocale: "en",
96
+ };
97
+ const fallbackMap = {};
98
+ const output = generateOutput(bundles, settings, fallbackMap);
99
+ // Check that the output exists
100
+ expect(output).toHaveProperty("messages/en.js");
101
+ // The exported constants should not conflict
102
+ const content = output["messages/en.js"];
103
+ expect(content).toContain("export const sad_penguin_bundle");
104
+ expect(content).toContain("export const sad_penguin_bundle1"); // or some other unique name
105
+ });
@@ -8,6 +8,7 @@ export declare function createRuntimeFile(args: {
8
8
  compilerOptions: {
9
9
  strategy: NonNullable<CompilerOptions["strategy"]>;
10
10
  cookieName: NonNullable<CompilerOptions["cookieName"]>;
11
+ cookieMaxAge: NonNullable<CompilerOptions["cookieMaxAge"]>;
11
12
  urlPatterns?: CompilerOptions["urlPatterns"];
12
13
  experimentalMiddlewareLocaleSplitting: CompilerOptions["experimentalMiddlewareLocaleSplitting"];
13
14
  isServer: CompilerOptions["isServer"];
@@ -1 +1 @@
1
- {"version":3,"file":"create-runtime.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/create-runtime.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,eAAe,EAAE;QAChB,QAAQ,EAAE,WAAW,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC,CAAC;QACnD,UAAU,EAAE,WAAW,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC,CAAC;QACvD,WAAW,CAAC,EAAE,eAAe,CAAC,aAAa,CAAC,CAAC;QAC7C,qCAAqC,EAAE,eAAe,CAAC,uCAAuC,CAAC,CAAC;QAChG,QAAQ,EAAE,eAAe,CAAC,UAAU,CAAC,CAAC;QACtC,eAAe,EAAE,eAAe,CAAC,iBAAiB,CAAC,CAAC;QACpD,wBAAwB,EAAE,WAAW,CACpC,eAAe,CAAC,0BAA0B,CAAC,CAC3C,CAAC;KACF,CAAC;CACF,GAAG,MAAM,CAgIT"}
1
+ {"version":3,"file":"create-runtime.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/create-runtime.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,eAAe,EAAE;QAChB,QAAQ,EAAE,WAAW,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC,CAAC;QACnD,UAAU,EAAE,WAAW,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC,CAAC;QACvD,YAAY,EAAE,WAAW,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC,CAAC;QAC3D,WAAW,CAAC,EAAE,eAAe,CAAC,aAAa,CAAC,CAAC;QAC7C,qCAAqC,EAAE,eAAe,CAAC,uCAAuC,CAAC,CAAC;QAChG,QAAQ,EAAE,eAAe,CAAC,UAAU,CAAC,CAAC;QACtC,eAAe,EAAE,eAAe,CAAC,iBAAiB,CAAC,CAAC;QACpD,wBAAwB,EAAE,WAAW,CACpC,eAAe,CAAC,0BAA0B,CAAC,CAC3C,CAAC;KACF,CAAC;CACF,GAAG,MAAM,CAiIT"}
@@ -34,6 +34,7 @@ ${injectCode("./variables.js")
34
34
  .replace(`export const locales = /** @type {const} */ (["en", "de"]);`, `export const locales = /** @type {const} */ (["${args.locales.join('", "')}"]);`)
35
35
  .replace(`export const strategy = ["globalVariable"];`, `export const strategy = ${JSON.stringify(args.compilerOptions.strategy, null, 2)};`)
36
36
  .replace(`<cookie-name>`, `${args.compilerOptions.cookieName}`)
37
+ .replace(`60 * 60 * 24 * 400`, `${args.compilerOptions.cookieMaxAge}`)
37
38
  .replace(`export const TREE_SHAKE_COOKIE_STRATEGY_USED = false;`, `const TREE_SHAKE_COOKIE_STRATEGY_USED = ${args.compilerOptions.strategy.includes("cookie")};`)
38
39
  .replace(`export const TREE_SHAKE_URL_STRATEGY_USED = false;`, `const TREE_SHAKE_URL_STRATEGY_USED = ${args.compilerOptions.strategy.includes("url")};`)
39
40
  .replace(`export const TREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED = false;`, `const TREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED = ${args.compilerOptions.strategy.includes("globalVariable")};`)
@@ -48,7 +49,7 @@ ${injectCode("./variables.js")
48
49
 
49
50
  globalThis.__paraglide = {}
50
51
 
51
- ${injectCode("./get-locale.js")}
52
+ ${injectCode("./get-locale.js")}
52
53
 
53
54
  ${injectCode("./set-locale.js")}
54
55
 
@@ -1,6 +1,6 @@
1
- import { test, expect, vi } from "vitest";
2
- import { createParaglide } from "../create-paraglide.js";
3
1
  import { newProject } from "@inlang/sdk";
2
+ import { expect, test, vi } from "vitest";
3
+ import { createParaglide } from "../create-paraglide.js";
4
4
  test("matching by strategy works", async () => {
5
5
  const baseLocale = "en";
6
6
  const runtime = await createParaglide({
@@ -195,6 +195,6 @@ test("initially sets the locale after resolving it for the first time", async ()
195
195
  // First call to getLocale should resolve and set the locale
196
196
  expect(runtime.getLocale()).toBe("de");
197
197
  // Cookie should be set, proving that the locale was initially set
198
- expect(globalThis.document.cookie).toBe("PARAGLIDE_LOCALE=de; path=/");
198
+ expect(globalThis.document.cookie).toBe("PARAGLIDE_LOCALE=de; path=/; max-age=34560000");
199
199
  expect(globalThis.window.location.href).toBe("https://example.com/de/page");
200
200
  });
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Set locale reloads the site by default on the client. Reloading
5
5
  * can be disabled by passing \`reload: false\` as an option. If
6
- * reloading is disbaled, you need to ensure that the UI is updated
6
+ * reloading is disabled, you need to ensure that the UI is updated
7
7
  * to reflect the new locale.
8
8
  *
9
9
  * @example
@@ -1 +1 @@
1
- {"version":3,"file":"set-locale.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/set-locale.js"],"names":[],"mappings":"AAaA;;;;;;;;;;;;;;;GAeG;AACH,sBAFU,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,KAAK,IAAI,CA2EnE;AAgBK,uCAFI,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,QAIrC"}
1
+ {"version":3,"file":"set-locale.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/set-locale.js"],"names":[],"mappings":"AAcA;;;;;;;;;;;;;;;GAeG;AACH,sBAFU,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,KAAK,IAAI,CA2EnE;AAgBK,uCAFI,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,QAIrC"}
@@ -1,12 +1,12 @@
1
- import { cookieName, isServer, localStorageKey, strategy, TREE_SHAKE_COOKIE_STRATEGY_USED, TREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED, TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED, TREE_SHAKE_URL_STRATEGY_USED, } from "./variables.js";
2
- import { localizeUrl } from "./localize-url.js";
3
1
  import { getLocale } from "./get-locale.js";
2
+ import { localizeUrl } from "./localize-url.js";
3
+ import { cookieMaxAge, cookieName, isServer, localStorageKey, strategy, TREE_SHAKE_COOKIE_STRATEGY_USED, TREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED, TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED, TREE_SHAKE_URL_STRATEGY_USED, } from "./variables.js";
4
4
  /**
5
5
  * Set the locale.
6
6
  *
7
7
  * Set locale reloads the site by default on the client. Reloading
8
8
  * can be disabled by passing \`reload: false\` as an option. If
9
- * reloading is disbaled, you need to ensure that the UI is updated
9
+ * reloading is disabled, you need to ensure that the UI is updated
10
10
  * to reflect the new locale.
11
11
  *
12
12
  * @example
@@ -45,7 +45,7 @@ export let setLocale = (newLocale, options) => {
45
45
  continue;
46
46
  }
47
47
  // set the cookie
48
- document.cookie = `${cookieName}=${newLocale}; path=/`;
48
+ document.cookie = `${cookieName}=${newLocale}; path=/; max-age=${cookieMaxAge}`;
49
49
  }
50
50
  else if (strat === "baseLocale") {
51
51
  // nothing to be set here. baseLocale is only a fallback
@@ -1,6 +1,6 @@
1
- import { test, expect, vi } from "vitest";
2
- import { createParaglide } from "../create-paraglide.js";
3
1
  import { newProject } from "@inlang/sdk";
2
+ import { expect, test, vi } from "vitest";
3
+ import { createParaglide } from "../create-paraglide.js";
4
4
  test("sets the cookie to a different locale", async () => {
5
5
  // @ts-expect-error - global variable definition
6
6
  globalThis.document = {};
@@ -24,7 +24,7 @@ test("sets the cookie to a different locale", async () => {
24
24
  globalThis.document.cookie = "PARAGLIDE_LOCALE=en";
25
25
  runtime.setLocale("de");
26
26
  // set the locale
27
- expect(globalThis.document.cookie).toBe("PARAGLIDE_LOCALE=de; path=/");
27
+ expect(globalThis.document.cookie).toBe("PARAGLIDE_LOCALE=de; path=/; max-age=34560000");
28
28
  // reloads the site if window is available
29
29
  expect(globalThis.window.location.reload).toBeCalled();
30
30
  });
@@ -75,7 +75,7 @@ test("sets the cookie when it's an empty string", async () => {
75
75
  /** @ts-expect-error - client side api */
76
76
  globalThis.document = { cookie: "" };
77
77
  runtime.setLocale("en");
78
- expect(globalThis.document.cookie).toBe("PARAGLIDE_LOCALE=en; path=/");
78
+ expect(globalThis.document.cookie).toBe("PARAGLIDE_LOCALE=en; path=/; max-age=34560000");
79
79
  });
80
80
  test("when strategy precedes URL, it should set the locale and re-direct to the URL", async () => {
81
81
  const runtime = await createParaglide({
@@ -108,7 +108,7 @@ test("when strategy precedes URL, it should set the locale and re-direct to the
108
108
  // Cookie strategy should determine locale as French
109
109
  expect(runtime.getLocale()).toBe("fr");
110
110
  runtime.setLocale("en");
111
- expect(globalThis.document.cookie).toBe("PARAGLIDE_LOCALE=en; path=/");
111
+ expect(globalThis.document.cookie).toBe("PARAGLIDE_LOCALE=en; path=/; max-age=34560000");
112
112
  expect(globalThis.window.location.href).toBe("https://example.com/en/some-path");
113
113
  });
114
114
  // https://github.com/opral/inlang-paraglide-js/issues/430
@@ -136,12 +136,12 @@ test("should not reload when setting locale to current locale", async () => {
136
136
  // Setting to the current locale (en)
137
137
  runtime.setLocale("en");
138
138
  // Cookie should remain unchanged
139
- expect(globalThis.document.cookie).toBe("PARAGLIDE_LOCALE=en; path=/");
139
+ expect(globalThis.document.cookie).toBe("PARAGLIDE_LOCALE=en; path=/; max-age=34560000");
140
140
  // Should not trigger a reload
141
141
  expect(globalThis.window.location.reload).not.toBeCalled();
142
142
  // Setting to a different locale should still work
143
143
  runtime.setLocale("de");
144
- expect(globalThis.document.cookie).toBe("PARAGLIDE_LOCALE=de; path=/");
144
+ expect(globalThis.document.cookie).toBe("PARAGLIDE_LOCALE=de; path=/; max-age=34560000");
145
145
  expect(globalThis.window.location.reload).toBeCalled();
146
146
  });
147
147
  test("sets the locale to localStorage", async () => {
@@ -211,5 +211,5 @@ test("should set locale in all configured storage mechanisms regardless of which
211
211
  // Verify that all storage mechanisms are updated
212
212
  expect(globalThis.window.location.href).toBe("https://example.com/fr/page");
213
213
  expect(globalThis.localStorage.setItem).toHaveBeenCalledWith("PARAGLIDE_LOCALE", "fr");
214
- expect(globalThis.document.cookie).toBe("PARAGLIDE_LOCALE=fr; path=/");
214
+ expect(globalThis.document.cookie).toBe("PARAGLIDE_LOCALE=fr; path=/; max-age=34560000");
215
215
  });
@@ -6,6 +6,7 @@ export type Runtime = {
6
6
  locales: typeof import("./variables.js").locales;
7
7
  strategy: typeof import("./variables.js").strategy;
8
8
  cookieName: typeof import("./variables.js").cookieName;
9
+ cookieMaxAge: typeof import("./variables.js").cookieMaxAge;
9
10
  urlPatterns: typeof import("./variables.js").urlPatterns;
10
11
  disableAsyncLocalStorage: typeof import("./variables.js").disableAsyncLocalStorage;
11
12
  serverAsyncLocalStorage: typeof import("./variables.js").serverAsyncLocalStorage;
@@ -1 +1 @@
1
- {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/type.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG;IACrB,UAAU,EAAE,cAAc,gBAAgB,EAAE,UAAU,CAAC;IACvD,OAAO,EAAE,cAAc,gBAAgB,EAAE,OAAO,CAAC;IACjD,QAAQ,EAAE,cAAc,gBAAgB,EAAE,QAAQ,CAAC;IACnD,UAAU,EAAE,cAAc,gBAAgB,EAAE,UAAU,CAAC;IACvD,WAAW,EAAE,cAAc,gBAAgB,EAAE,WAAW,CAAC;IACzD,wBAAwB,EAAE,cAAc,gBAAgB,EAAE,wBAAwB,CAAC;IACnF,uBAAuB,EAAE,cAAc,gBAAgB,EAAE,uBAAuB,CAAC;IACjF,q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,wBAAwB,EAAE,cAAc,kCAAkC,EAAE,wBAAwB,CAAC;IACrG,uBAAuB,EAAE,cAAc,iCAAiC,EAAE,uBAAuB,CAAC;IAClG,2BAA2B,EAAE,cAAc,qCAAqC,EAAE,2BAA2B,CAAC;IAC9G,gBAAgB,EAAE,cAAc,yBAAyB,EAAE,gBAAgB,CAAC;CAC5E,CAAC"}
@@ -29,6 +29,8 @@ export const baseLocale: "en";
29
29
  export const locales: readonly ["en", "de"];
30
30
  /** @type {string} */
31
31
  export const cookieName: string;
32
+ /** @type {number} */
33
+ export const cookieMaxAge: number;
32
34
  /** @type {string} */
33
35
  export const localStorageKey: string;
34
36
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"variables.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/variables.js"],"names":[],"mappings":"AAkEA;;;;;;;;;GASG;AACH,wDAFW,0BAA0B,GAAG,SAAS,QAIhD;AA9ED;;;;;;;GAOG;AACH,yBAA0B,IAAI,CAAC;AAE/B;;;;;;;GAOG;AACH,4CAA2D;AAE3D,qBAAqB;AACrB,yBADW,MAAM,CACyB;AAE1C,qBAAqB;AACrB,8BADW,MAAM,CACiC;AAElD;;GAEG;AACH,uBAFU,KAAK,CAAC,QAAQ,GAAG,YAAY,GAAG,gBAAgB,GAAG,KAAK,GAAG,mBAAmB,GAAG,cAAc,CAAC,CAE/D;AAE3C;;;;GAIG;AACH,0BAFU,KAAK,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;CAAE,CAAC,CAE1C;AAE9B;;;;;;;;;;GAUG;AAEH;;;;;;;GAOG;AACH,oCAFU,0BAA0B,GAAG,SAAS,CAED;AAE/C,uCAAwC,KAAK,CAAC;AAE9C,oDAAqD,KAAK,CAAC;AAE3D,+BAAsD;AAgBtD,8CAA+C,KAAK,CAAC;AAErD,2CAA4C,KAAK,CAAC;AAElD,uDAAwD,K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AAqD,KAAK,CAAC;AAE3D,+BAAsD;AAgBtD,8CAA+C,KAAK,CAAC;AAErD,2CAA4C,KAAK,CAAC;AAElD,uDAAwD,KAAK,CAAC;AAE9D,0DAA2D,KAAK,CAAC;AAEjE,kDAAmD,KAAK,CAAC;AAEzD,qDAAsD,KAAK,CAAC;yCAnD/C;IACR,QAAQ,IAAI;QACV,MAAM,CAAC,EAAE,MAAM,CAAC;QACjB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,YAAY,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;KACzB,GAAG,SAAS,CAAC;IACf,GAAG,EAAE,CAAC,KAAK,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;KAAC,EAC3E,EAAE,EAAE,GAAG,KAAK,GAAG,CAAA;CACjB"}
@@ -18,6 +18,8 @@ export const baseLocale = "en";
18
18
  export const locales = /** @type {const} */ (["en", "de"]);
19
19
  /** @type {string} */
20
20
  export const cookieName = "<cookie-name>";
21
+ /** @type {number} */
22
+ export const cookieMaxAge = 60 * 60 * 24 * 400;
21
23
  /** @type {string} */
22
24
  export const localStorageKey = "PARAGLIDE_LOCALE";
23
25
  /**
@@ -1,5 +1,5 @@
1
1
  export const ENV_VARIABLES = {
2
2
  PARJS_APP_ID: "library.inlang.paraglideJs",
3
3
  PARJS_POSTHOG_TOKEN: "phc_m5yJZCxjOGxF8CJvP5sQ3H0d76xpnLrsmiZHduT4jDz",
4
- PARJS_PACKAGE_VERSION: "2.0.4",
4
+ PARJS_PACKAGE_VERSION: "2.0.6",
5
5
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@inlang/paraglide-js",
3
3
  "type": "module",
4
- "version": "2.0.4",
4
+ "version": "2.0.6",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
7
7
  "access": "public",
@@ -32,7 +32,7 @@
32
32
  "unplugin": "^2.1.2",
33
33
  "urlpattern-polyfill": "^10.0.0",
34
34
  "@inlang/recommend-sherlock": "0.2.1",
35
- "@inlang/sdk": "2.4.4"
35
+ "@inlang/sdk": "2.4.5"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@eslint/js": "^9.18.0",
@@ -51,8 +51,8 @@
51
51
  "typescript-eslint": "^8.20.0",
52
52
  "vitest": "2.1.8",
53
53
  "@inlang/plugin-message-format": "4.0.0",
54
- "@opral/tsconfig": "1.1.0",
55
- "@inlang/paraglide-js": "2.0.4"
54
+ "@inlang/paraglide-js": "2.0.6",
55
+ "@opral/tsconfig": "1.1.0"
56
56
  },
57
57
  "keywords": [
58
58
  "inlang",