@inlang/paraglide-js 2.26.0 → 2.28.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.
Files changed (225) hide show
  1. package/README.md +11 -1
  2. package/dist/bundler-plugins/per-locale-build/index.js +14 -7
  3. package/dist/bundler-plugins/per-locale-build/index.js.map +1 -1
  4. package/dist/bundler-plugins/per-locale-build/vite-environments.test.js +237 -4
  5. package/dist/bundler-plugins/per-locale-build/vite-environments.test.js.map +1 -1
  6. package/dist/bundler-plugins/unplugin.d.ts +1 -1
  7. package/dist/bundler-plugins/unplugin.js +79 -10
  8. package/dist/bundler-plugins/unplugin.js.map +1 -1
  9. package/dist/bundler-plugins/unplugin.test.js +334 -1
  10. package/dist/bundler-plugins/unplugin.test.js.map +1 -1
  11. package/dist/bundler-plugins/vite.js +2 -1
  12. package/dist/bundler-plugins/vite.js.map +1 -1
  13. package/dist/bundler-plugins/vite.test.js +1 -1
  14. package/dist/bundler-plugins/vite.test.js.map +1 -1
  15. package/dist/cli/commands/compile/command.js +13 -0
  16. package/dist/cli/commands/compile/command.js.map +1 -1
  17. package/dist/cli/commands/compile/command.test.js +87 -3
  18. package/dist/cli/commands/compile/command.test.js.map +1 -1
  19. package/dist/cli/commands/init/command.d.ts +5 -0
  20. package/dist/cli/commands/init/command.js +216 -44
  21. package/dist/cli/commands/init/command.js.map +1 -1
  22. package/dist/cli/commands/init/command.test.d.ts +1 -0
  23. package/dist/cli/commands/init/command.test.js +123 -0
  24. package/dist/cli/commands/init/command.test.js.map +1 -0
  25. package/dist/cli/defaults.js +2 -2
  26. package/dist/cli/defaults.js.map +1 -1
  27. package/dist/cli/init-options.d.ts +11 -0
  28. package/dist/cli/init-options.js +2 -0
  29. package/dist/cli/init-options.js.map +1 -0
  30. package/dist/cli/steps/add-inlang-check.d.ts +19 -0
  31. package/dist/cli/steps/add-inlang-check.js +60 -0
  32. package/dist/cli/steps/add-inlang-check.js.map +1 -0
  33. package/dist/cli/steps/add-inlang-check.test.d.ts +1 -0
  34. package/dist/cli/steps/add-inlang-check.test.js +88 -0
  35. package/dist/cli/steps/add-inlang-check.test.js.map +1 -0
  36. package/dist/cli/steps/add-message-lint.d.ts +34 -0
  37. package/dist/cli/steps/add-message-lint.js +105 -0
  38. package/dist/cli/steps/add-message-lint.js.map +1 -0
  39. package/dist/cli/steps/add-message-lint.test.d.ts +1 -0
  40. package/dist/cli/steps/add-message-lint.test.js +74 -0
  41. package/dist/cli/steps/add-message-lint.test.js.map +1 -0
  42. package/dist/cli/steps/add-vite-plugin.d.ts +18 -0
  43. package/dist/cli/steps/add-vite-plugin.js +34 -6
  44. package/dist/cli/steps/add-vite-plugin.js.map +1 -1
  45. package/dist/cli/steps/add-vite-plugin.test.js +25 -9
  46. package/dist/cli/steps/add-vite-plugin.test.js.map +1 -1
  47. package/dist/cli/steps/agents-md-suggestion.d.ts +11 -0
  48. package/dist/cli/steps/agents-md-suggestion.js +19 -0
  49. package/dist/cli/steps/agents-md-suggestion.js.map +1 -0
  50. package/dist/cli/steps/agents-md-suggestion.test.d.ts +1 -0
  51. package/dist/cli/steps/agents-md-suggestion.test.js +36 -0
  52. package/dist/cli/steps/agents-md-suggestion.test.js.map +1 -0
  53. package/dist/cli/steps/check-for-uncomitted-changes.d.ts +3 -0
  54. package/dist/cli/steps/check-for-uncomitted-changes.js +15 -3
  55. package/dist/cli/steps/check-for-uncomitted-changes.js.map +1 -1
  56. package/dist/cli/steps/detect-bundler.d.ts +1 -0
  57. package/dist/cli/steps/detect-bundler.js +7 -1
  58. package/dist/cli/steps/detect-bundler.js.map +1 -1
  59. package/dist/cli/steps/initialize-inlang-project.d.ts +4 -3
  60. package/dist/cli/steps/initialize-inlang-project.js +60 -157
  61. package/dist/cli/steps/initialize-inlang-project.js.map +1 -1
  62. package/dist/cli/steps/maybe-add-machine-translation.d.ts +4 -0
  63. package/dist/cli/steps/maybe-add-machine-translation.js +14 -8
  64. package/dist/cli/steps/maybe-add-machine-translation.js.map +1 -1
  65. package/dist/cli/steps/maybe-add-sherlock.d.ts +2 -0
  66. package/dist/cli/steps/maybe-add-sherlock.js +13 -7
  67. package/dist/cli/steps/maybe-add-sherlock.js.map +1 -1
  68. package/dist/cli/steps/maybe-add-sherlock.test.d.ts +1 -0
  69. package/dist/cli/steps/maybe-add-sherlock.test.js +44 -0
  70. package/dist/cli/steps/maybe-add-sherlock.test.js.map +1 -0
  71. package/dist/cli/steps/prompt-for-outdir.d.ts +2 -0
  72. package/dist/cli/steps/prompt-for-outdir.js +4 -0
  73. package/dist/cli/steps/prompt-for-outdir.js.map +1 -1
  74. package/dist/cli/steps/update-package-json.js +8 -13
  75. package/dist/cli/steps/update-package-json.js.map +1 -1
  76. package/dist/cli/steps/update-ts-config.d.ts +6 -0
  77. package/dist/cli/steps/update-ts-config.js +27 -4
  78. package/dist/cli/steps/update-ts-config.js.map +1 -1
  79. package/dist/cli/utils.d.ts +11 -0
  80. package/dist/cli/utils.js +21 -0
  81. package/dist/cli/utils.js.map +1 -1
  82. package/dist/cli/utils.test.d.ts +1 -0
  83. package/dist/cli/utils.test.js +16 -0
  84. package/dist/cli/utils.test.js.map +1 -0
  85. package/dist/compiler/compile-annotation.d.ts +48 -1
  86. package/dist/compiler/compile-annotation.js +243 -10
  87. package/dist/compiler/compile-annotation.js.map +1 -1
  88. package/dist/compiler/compile-bundle.d.ts +7 -2
  89. package/dist/compiler/compile-bundle.js +97 -3
  90. package/dist/compiler/compile-bundle.js.map +1 -1
  91. package/dist/compiler/compile-bundle.test.js +232 -19
  92. package/dist/compiler/compile-bundle.test.js.map +1 -1
  93. package/dist/compiler/compile-lifecycle.test.d.ts +1 -0
  94. package/dist/compiler/compile-lifecycle.test.js +69 -0
  95. package/dist/compiler/compile-lifecycle.test.js.map +1 -0
  96. package/dist/compiler/compile-local-variable.d.ts +3 -0
  97. package/dist/compiler/compile-local-variable.js +5 -2
  98. package/dist/compiler/compile-local-variable.js.map +1 -1
  99. package/dist/compiler/compile-local-variable.test.js +55 -15
  100. package/dist/compiler/compile-local-variable.test.js.map +1 -1
  101. package/dist/compiler/compile-message.d.ts +29 -1
  102. package/dist/compiler/compile-message.exact-number.test.d.ts +1 -0
  103. package/dist/compiler/compile-message.exact-number.test.js +786 -0
  104. package/dist/compiler/compile-message.exact-number.test.js.map +1 -0
  105. package/dist/compiler/compile-message.js +162 -66
  106. package/dist/compiler/compile-message.js.map +1 -1
  107. package/dist/compiler/compile-message.locals.test.d.ts +1 -0
  108. package/dist/compiler/compile-message.locals.test.js +498 -0
  109. package/dist/compiler/compile-message.locals.test.js.map +1 -0
  110. package/dist/compiler/compile-message.test.js +113 -22
  111. package/dist/compiler/compile-message.test.js.map +1 -1
  112. package/dist/compiler/compile-pattern.d.ts +5 -0
  113. package/dist/compiler/compile-pattern.js +6 -18
  114. package/dist/compiler/compile-pattern.js.map +1 -1
  115. package/dist/compiler/compile-pattern.test.js +169 -5
  116. package/dist/compiler/compile-pattern.test.js.map +1 -1
  117. package/dist/compiler/compile-project.js +5 -1
  118. package/dist/compiler/compile-project.js.map +1 -1
  119. package/dist/compiler/compile-project.test.js +1260 -185
  120. package/dist/compiler/compile-project.test.js.map +1 -1
  121. package/dist/compiler/compile.js +36 -17
  122. package/dist/compiler/compile.js.map +1 -1
  123. package/dist/compiler/compile.test.js +71 -1
  124. package/dist/compiler/compile.test.js.map +1 -1
  125. package/dist/compiler/compiler-options.d.ts +41 -0
  126. package/dist/compiler/compiler-options.js.map +1 -1
  127. package/dist/compiler/create-readme.d.ts +4 -1
  128. package/dist/compiler/create-readme.js +33 -125
  129. package/dist/compiler/create-readme.js.map +1 -1
  130. package/dist/compiler/emit-ts-declarations.interop.test.js +2 -2
  131. package/dist/compiler/emit-ts-declarations.interop.test.js.map +1 -1
  132. package/dist/compiler/emit-ts-declarations.test.js +4 -4
  133. package/dist/compiler/emit-ts-declarations.test.js.map +1 -1
  134. package/dist/compiler/index.d.ts +1 -1
  135. package/dist/compiler/index.js +1 -1
  136. package/dist/compiler/index.js.map +1 -1
  137. package/dist/compiler/input-alias.d.ts +21 -0
  138. package/dist/compiler/input-alias.js +42 -0
  139. package/dist/compiler/input-alias.js.map +1 -0
  140. package/dist/compiler/input-alias.test.d.ts +1 -0
  141. package/dist/compiler/input-alias.test.js +58 -0
  142. package/dist/compiler/input-alias.test.js.map +1 -0
  143. package/dist/compiler/message-locals.d.ts +46 -0
  144. package/dist/compiler/message-locals.js +129 -0
  145. package/dist/compiler/message-locals.js.map +1 -0
  146. package/dist/compiler/output-structure/locale-modules.js +7 -1
  147. package/dist/compiler/output-structure/locale-modules.js.map +1 -1
  148. package/dist/compiler/output-structure/locale-modules.test.js +35 -0
  149. package/dist/compiler/output-structure/locale-modules.test.js.map +1 -1
  150. package/dist/compiler/output-structure/message-modules.js +6 -4
  151. package/dist/compiler/output-structure/message-modules.js.map +1 -1
  152. package/dist/compiler/output-structure/message-modules.test.js +35 -0
  153. package/dist/compiler/output-structure/message-modules.test.js.map +1 -1
  154. package/dist/compiler/registry.d.ts +12 -0
  155. package/dist/compiler/registry.js +158 -31
  156. package/dist/compiler/registry.js.map +1 -1
  157. package/dist/compiler/registry.test.d.ts +1 -0
  158. package/dist/compiler/registry.test.js +291 -0
  159. package/dist/compiler/registry.test.js.map +1 -0
  160. package/dist/compiler/runtime/create-runtime.d.ts +2 -0
  161. package/dist/compiler/runtime/create-runtime.js +9 -0
  162. package/dist/compiler/runtime/create-runtime.js.map +1 -1
  163. package/dist/compiler/runtime/extract-locale-from-cookie.js +8 -1
  164. package/dist/compiler/runtime/extract-locale-from-cookie.js.map +1 -1
  165. package/dist/compiler/runtime/extract-locale-from-cookie.test.js +26 -0
  166. package/dist/compiler/runtime/extract-locale-from-cookie.test.js.map +1 -1
  167. package/dist/compiler/runtime/extract-locale-from-header.js +47 -5
  168. package/dist/compiler/runtime/extract-locale-from-header.js.map +1 -1
  169. package/dist/compiler/runtime/extract-locale-from-header.test.js +58 -0
  170. package/dist/compiler/runtime/extract-locale-from-header.test.js.map +1 -1
  171. package/dist/compiler/runtime/get-locale.js +7 -1
  172. package/dist/compiler/runtime/get-locale.js.map +1 -1
  173. package/dist/compiler/runtime/get-locale.test.js +95 -0
  174. package/dist/compiler/runtime/get-locale.test.js.map +1 -1
  175. package/dist/compiler/runtime/localize-href.d.ts +8 -0
  176. package/dist/compiler/runtime/localize-href.js +60 -0
  177. package/dist/compiler/runtime/localize-href.js.map +1 -1
  178. package/dist/compiler/runtime/localize-href.test.js +227 -1
  179. package/dist/compiler/runtime/localize-href.test.js.map +1 -1
  180. package/dist/compiler/runtime/set-locale.js +24 -6
  181. package/dist/compiler/runtime/set-locale.js.map +1 -1
  182. package/dist/compiler/runtime/set-locale.test.js +182 -0
  183. package/dist/compiler/runtime/set-locale.test.js.map +1 -1
  184. package/dist/compiler/runtime/type.d.ts +2 -0
  185. package/dist/compiler/runtime/type.js.map +1 -1
  186. package/dist/compiler/runtime/type.test.js +34 -0
  187. package/dist/compiler/runtime/type.test.js.map +1 -1
  188. package/dist/compiler/runtime/variables.d.ts +2 -0
  189. package/dist/compiler/runtime/variables.js +7 -0
  190. package/dist/compiler/runtime/variables.js.map +1 -1
  191. package/dist/compiler/server/create-server-file.js +24 -0
  192. package/dist/compiler/server/create-server-file.js.map +1 -1
  193. package/dist/compiler/server/create-server-file.test.js +8 -2
  194. package/dist/compiler/server/create-server-file.test.js.map +1 -1
  195. package/dist/compiler/server/middleware.d.ts +8 -2
  196. package/dist/compiler/server/middleware.js +204 -11
  197. package/dist/compiler/server/middleware.js.map +1 -1
  198. package/dist/compiler/server/middleware.test.js +750 -3
  199. package/dist/compiler/server/middleware.test.js.map +1 -1
  200. package/dist/eslint/index.d.ts +4 -0
  201. package/dist/eslint/index.js +8 -0
  202. package/dist/eslint/index.js.map +1 -0
  203. package/dist/eslint/no-dynamic-message-access.d.ts +3 -0
  204. package/dist/eslint/no-dynamic-message-access.js +150 -0
  205. package/dist/eslint/no-dynamic-message-access.js.map +1 -0
  206. package/dist/eslint/no-dynamic-message-access.test.d.ts +1 -0
  207. package/dist/eslint/no-dynamic-message-access.test.js +126 -0
  208. package/dist/eslint/no-dynamic-message-access.test.js.map +1 -0
  209. package/dist/eslint/oxlint.test.d.ts +1 -0
  210. package/dist/eslint/oxlint.test.js +64 -0
  211. package/dist/eslint/oxlint.test.js.map +1 -0
  212. package/dist/services/config/config-schema.d.ts +2 -0
  213. package/dist/services/config/config-schema.js +2 -0
  214. package/dist/services/config/config-schema.js.map +1 -1
  215. package/dist/services/config/load-paraglide-config.test.js +12 -0
  216. package/dist/services/config/load-paraglide-config.test.js.map +1 -1
  217. package/dist/services/env-variables/index.js +1 -1
  218. package/dist/services/env-variables/index.js.map +1 -1
  219. package/dist/services/file-handling/write-output.bench.js +51 -11
  220. package/dist/services/file-handling/write-output.bench.js.map +1 -1
  221. package/dist/services/file-handling/write-output.js +60 -20
  222. package/dist/services/file-handling/write-output.js.map +1 -1
  223. package/dist/services/file-handling/write-output.test.js +175 -0
  224. package/dist/services/file-handling/write-output.test.js.map +1 -1
  225. package/package.json +15 -5
@@ -1 +1 @@
1
- {"version":3,"file":"set-locale.test.js","sourceRoot":"","sources":["../../../src/compiler/runtime/set-locale.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,IAAI,CAAC,uCAAuC,EAAE,KAAK,IAAI,EAAE;IACxD,gDAAgD;IAChD,UAAU,CAAC,QAAQ,GAAG,EAAE,CAAC;IACzB,gDAAgD;IAChD,UAAU,CAAC,MAAM,GAAG,EAAE,CAAC;IACvB,gDAAgD;IAChD,UAAU,CAAC,MAAM,CAAC,QAAQ,GAAG,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC;IACzD,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,M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E,OAAO;KACjB,CAAC,CAAC;IAEH,OAAO,CAAC,0BAA0B,CAAC,uBAAuB,EAAE;QAC3D,SAAS,EAAE,GAAG,EAAE,CAAC,kBAAkB;QACnC,SAAS,EAAE,CAAC,MAAM,EAAE,EAAE;YACrB,kBAAkB,GAAG,MAAM,CAAC;QAC7B,CAAC;KACD,CAAC,CAAC;IAEH,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAExB,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAC;IAC5E,MAAM,CAAC,kBAAkB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACvC,CAAC,CAAC,CAAC","sourcesContent":["import { newProject } from \"@inlang/sdk\";\nimport { expect, test, vi } from \"vitest\";\nimport { createParaglide } from \"../create-paraglide.js\";\n\ntest(\"sets the cookie to a different locale\", async () => {\n\t// @ts-expect-error - global variable definition\n\tglobalThis.document = {};\n\t// @ts-expect-error - global variable definition\n\tglobalThis.window = {};\n\t// @ts-expect-error - global variable definition\n\tglobalThis.window.location = { hostname: \"example.com\" };\n\tglobalThis.window.location.reload = vi.fn();\n\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: [\"cookie\"],\n\t\tcookieName: \"PARAGLIDE_LOCALE\",\n\t});\n\n\tglobalThis.document.cookie = \"PARAGLIDE_LOCALE=en\";\n\n\truntime.setLocale(\"de\");\n\n\t// set the locale\n\texpect(globalThis.document.cookie).toBe(\n\t\t\"PARAGLIDE_LOCALE=de; path=/; max-age=34560000\"\n\t);\n\t// reloads the site if window is available\n\texpect(globalThis.window.location.reload).toBeCalled();\n});\n\ntest(\"sets the cookie with explicit domain to a different locale navigating subdomain\", async () => {\n\t// @ts-expect-error - global variable definition\n\tglobalThis.document = {};\n\t// @ts-expect-error - global variable definition\n\tglobalThis.window = {};\n\t// @ts-expect-error - global variable definition\n\tglobalThis.window.location = { hostname: \"web.example.com\" };\n\tglobalThis.window.location.reload = vi.fn();\n\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: [\"cookie\"],\n\t\tcookieName: \"PARAGLIDE_LOCALE\",\n\t\tcookieDomain: \"example.com\",\n\t});\n\n\tglobalThis.document.cookie = \"PARAGLIDE_LOCALE=en\";\n\n\truntime.setLocale(\"de\");\n\n\t// set the locale\n\texpect(globalThis.document.cookie).toBe(\n\t\t\"PARAGLIDE_LOCALE=de; path=/; max-age=34560000; domain=example.com\"\n\t);\n\t// reloads the site if window is available\n\texpect(globalThis.window.location.reload).toBeCalled();\n});\n\ntest(\"sets the cookie with explicit domain to a different locale navigating domain\", async () => {\n\t// @ts-expect-error - global variable definition\n\tglobalThis.document = {};\n\t// @ts-expect-error - global variable definition\n\tglobalThis.window = {};\n\t// @ts-expect-error - global variable definition\n\tglobalThis.window.location = { hostname: \"example.com\" };\n\tglobalThis.window.location.reload = vi.fn();\n\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: [\"cookie\"],\n\t\tcookieName: \"PARAGLIDE_LOCALE\",\n\t\tcookieDomain: \"example.com\",\n\t});\n\n\tglobalThis.document.cookie = \"PARAGLIDE_LOCALE=en\";\n\n\truntime.setLocale(\"de\");\n\n\t// set the locale\n\texpect(globalThis.document.cookie).toBe(\n\t\t\"PARAGLIDE_LOCALE=de; path=/; max-age=34560000; domain=example.com\"\n\t);\n\t// reloads the site if window is available\n\texpect(globalThis.window.location.reload).toBeCalled();\n});\n\ntest(\"url pattern strategy sets the window location\", async () => {\n\t// @ts-expect-error - global variable definition\n\tglobalThis.window = {};\n\t// @ts-expect-error - global variable definition\n\tglobalThis.window.location = {};\n\tglobalThis.window.location.hostname = \"example.com\";\n\tglobalThis.window.location.reload = vi.fn();\n\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\t\t{\n\t\t\t\tpattern: \"https://example.:tld/: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://example.de/:path*\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\tglobalThis.window.location.href = \"https://example.com/page\";\n\n\truntime.setLocale(\"de\");\n\n\texpect(globalThis.window.location.href).toBe(\"https://example.de/page\");\n\t// setting window.location.hostname automatically reloads the page\n\texpect(globalThis.window.location.reload).not.toBeCalled();\n});\n\ntest(\"url strategy setLocale normalizes mixed-case explicit locales\", async () => {\n\t// @ts-expect-error - global variable definition\n\tglobalThis.window = {};\n\t// @ts-expect-error - global variable definition\n\tglobalThis.window.location = {};\n\tglobalThis.window.location.hostname = \"example.com\";\n\tglobalThis.window.location.reload = vi.fn();\n\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\t\t{\n\t\t\t\tpattern: \"https://example.:tld/: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://example.de/:path*\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\tglobalThis.window.location.href = \"https://example.com/page\";\n\n\truntime.setLocale(\"DE\" as any);\n\n\texpect(globalThis.window.location.href).toBe(\"https://example.de/page\");\n\t// setting window.location.hostname automatically reloads the page\n\texpect(globalThis.window.location.reload).not.toBeCalled();\n});\n\ntest(\"routeStrategies can disable url navigation on matching routes\", async () => {\n\t// @ts-expect-error - global variable definition\n\tglobalThis.window = {};\n\t// @ts-expect-error - global variable definition\n\tglobalThis.document = {};\n\t// @ts-expect-error - global variable definition\n\tglobalThis.window.location = {\n\t\thref: \"https://example.com/dashboard\",\n\t\thostname: \"example.com\",\n\t\treload: vi.fn(),\n\t};\n\n\tconst runtime = await createParaglide({\n\t\tblob: await newProject({\n\t\t\tsettings: { baseLocale: \"en\", locales: [\"en\", \"fr\"] },\n\t\t}),\n\t\tstrategy: [\"url\", \"cookie\", \"baseLocale\"],\n\t\tcookieName: \"PARAGLIDE_LOCALE\",\n\t\trouteStrategies: [\n\t\t\t{\n\t\t\t\tmatch: \"/dashboard/:path(.*)?\",\n\t\t\t\tstrategy: [\"cookie\", \"baseLocale\"],\n\t\t\t},\n\t\t],\n\t});\n\n\tglobalThis.document.cookie = \"PARAGLIDE_LOCALE=en\";\n\truntime.setLocale(\"fr\");\n\n\texpect(globalThis.document.cookie).toBe(\n\t\t\"PARAGLIDE_LOCALE=fr; path=/; max-age=34560000\"\n\t);\n\texpect(globalThis.window.location.href).toBe(\"https://example.com/dashboard\");\n\texpect(globalThis.window.location.reload).toBeCalled();\n});\n\n// `!document.cookie` was used which returned false for an empty string\ntest(\"sets the cookie when it's an empty string\", 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\", \"fr\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"cookie\"],\n\t\tcookieName: \"PARAGLIDE_LOCALE\",\n\t});\n\n\t/** @ts-expect-error - client side api */\n\tglobalThis.document = { cookie: \"\" };\n\n\truntime.setLocale(\"en\");\n\n\texpect(globalThis.document.cookie).toBe(\n\t\t\"PARAGLIDE_LOCALE=en; path=/; max-age=34560000\"\n\t);\n});\n\ntest(\"when strategy precedes URL, it should set the locale and re-direct to the URL\", 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\", \"fr\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"cookie\", \"url\", \"baseLocale\"],\n\t\tcookieName: \"PARAGLIDE_LOCALE\",\n\t\tisServer: \"false\",\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \"https://example.com/en/:path(.*)?\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"en\", \"https://example.com/en/:path(.*)?\"],\n\t\t\t\t\t[\"fr\", \"https://example.com/fr/:path(.*)?\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\t/** @ts-expect-error - client side api */\n\tglobalThis.document = { cookie: \"PARAGLIDE_LOCALE=fr\" };\n\tglobalThis.window = {\n\t\tlocation: new URL(\"https://example.com/fr/some-path\"),\n\t} as any;\n\n\t// Cookie strategy should determine locale as French\n\texpect(runtime.getLocale()).toBe(\"fr\");\n\n\truntime.setLocale(\"en\");\n\n\texpect(globalThis.document.cookie).toBe(\n\t\t\"PARAGLIDE_LOCALE=en; path=/; max-age=34560000\"\n\t);\n\texpect(globalThis.window.location.href).toBe(\n\t\t\"https://example.com/en/some-path\"\n\t);\n});\n\ntest(\"overwriteSetLocale receives the options object\", 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\", \"fr\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"cookie\"],\n\t\tcookieName: \"PARAGLIDE_LOCALE\",\n\t});\n\n\t// Provide minimal browser globals to avoid strategy branches failing.\n\t/** @ts-expect-error - browser shim for tests */\n\tglobalThis.document = { cookie: \"\" };\n\tglobalThis.window = {\n\t\tlocation: {\n\t\t\thref: \"https://example.com/en\",\n\t\t\treload: vi.fn(),\n\t\t},\n\t} as any;\n\n\tconst spy = vi.fn();\n\truntime.overwriteSetLocale(spy);\n\n\truntime.setLocale(\"fr\", { reload: false });\n\n\texpect(spy).toHaveBeenCalledWith(\"fr\", { reload: false });\n});\n\n// https://github.com/opral/inlang-paraglide-js/issues/430\ntest(\"should not reload when setting locale to current locale\", async () => {\n\t// @ts-expect-error - global variable definition\n\tglobalThis.document = {};\n\t// @ts-expect-error - global variable definition\n\tglobalThis.window = {};\n\t// @ts-expect-error - global variable definition\n\tglobalThis.window.location = { hostname: \"example.com\" };\n\tglobalThis.window.location.reload = vi.fn();\n\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: [\"cookie\"],\n\t\tcookieName: \"PARAGLIDE_LOCALE\",\n\t});\n\n\tglobalThis.document.cookie = \"PARAGLIDE_LOCALE=en; path=/\";\n\n\t// Setting to the current locale (en)\n\truntime.setLocale(\"en\");\n\n\t// Cookie should remain unchanged\n\texpect(globalThis.document.cookie).toBe(\n\t\t\"PARAGLIDE_LOCALE=en; path=/; max-age=34560000\"\n\t);\n\t// Should not trigger a reload\n\texpect(globalThis.window.location.reload).not.toBeCalled();\n\n\t// Setting to a different locale should still work\n\truntime.setLocale(\"de\");\n\texpect(globalThis.document.cookie).toBe(\n\t\t\"PARAGLIDE_LOCALE=de; path=/; max-age=34560000\"\n\t);\n\texpect(globalThis.window.location.reload).toBeCalled();\n});\n\ntest(\"static locale builds force a document reload when switching locales\", async () => {\n\t// @ts-expect-error - browser shim for tests\n\tglobalThis.document = { cookie: \"\" };\n\tglobalThis.window = {\n\t\tlocation: {\n\t\t\thref: \"https://example.com/en\",\n\t\t\thostname: \"example.com\",\n\t\t\treload: vi.fn(),\n\t\t},\n\t} as any;\n\tconst warn = vi.spyOn(console, \"warn\").mockImplementation(() => undefined);\n\n\ttry {\n\t\tconst runtime = await createParaglide({\n\t\t\tblob: await newProject({\n\t\t\t\tsettings: {\n\t\t\t\t\tbaseLocale: \"en\",\n\t\t\t\t\tlocales: [\"en\", \"de\"],\n\t\t\t\t},\n\t\t\t}),\n\t\t\tstrategy: [\"cookie\"],\n\t\t\tisServer: \"false\",\n\t\t\texperimentalStaticLocale: JSON.stringify(\"en\"),\n\t\t});\n\n\t\truntime.setLocale(\"de\", { reload: false });\n\n\t\texpect(warn).toHaveBeenCalledOnce();\n\t\texpect(globalThis.window.location.reload).toHaveBeenCalledOnce();\n\t} finally {\n\t\twarn.mockRestore();\n\t}\n});\n\ntest(\"sets the locale to localStorage\", async () => {\n\t// @ts-expect-error - global variable definition\n\tglobalThis.localStorage = {\n\t\tsetItem: vi.fn(),\n\t\tgetItem: () => \"en\",\n\t};\n\n\t// @ts-expect-error - global variable definition\n\tglobalThis.window = {};\n\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: [\"localStorage\"],\n\t});\n\n\truntime.setLocale(\"de\");\n\n\texpect(globalThis.localStorage.setItem).toHaveBeenCalledWith(\n\t\t\"PARAGLIDE_LOCALE\",\n\t\t\"de\"\n\t);\n});\n\n// Test that all strategies set their respective storage mechanisms\ntest(\"should set locale in all configured storage mechanisms regardless of which strategy resolved the locale\", async () => {\n\t// Setup global objects\n\t// @ts-expect-error - global variable definition\n\tglobalThis.document = { cookie: \"\" };\n\t// @ts-expect-error - global variable definition\n\tglobalThis.localStorage = {\n\t\tsetItem: vi.fn(),\n\t\tgetItem: () => null,\n\t};\n\t// @ts-expect-error - global variable definition\n\tglobalThis.window = {};\n\t// @ts-expect-error - global variable definition\n\tglobalThis.window.location = {};\n\tglobalThis.window.location.hostname = \"example.com\";\n\tglobalThis.window.location.href = \"https://example.com/en/page\";\n\tglobalThis.window.location.reload = vi.fn();\n\n\t// Create runtime with multiple strategies\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\", \"localStorage\", \"cookie\", \"baseLocale\"],\n\t\tcookieName: \"PARAGLIDE_LOCALE\",\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \"https://example.com/:locale/:path*\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"en\", \"https://example.com/en/:path*\"],\n\t\t\t\t\t[\"de\", \"https://example.com/de/:path*\"],\n\t\t\t\t\t[\"fr\", \"https://example.com/fr/:path*\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\t// Call setLocale\n\truntime.setLocale(\"fr\");\n\n\t// Verify that all storage mechanisms are updated\n\texpect(globalThis.window.location.href).toBe(\"https://example.com/fr/page\");\n\texpect(globalThis.localStorage.setItem).toHaveBeenCalledWith(\n\t\t\"PARAGLIDE_LOCALE\",\n\t\t\"fr\"\n\t);\n\texpect(globalThis.document.cookie).toBe(\n\t\t\"PARAGLIDE_LOCALE=fr; path=/; max-age=34560000\"\n\t);\n});\n\ntest(\"calls setLocale on custom strategy\", async () => {\n\tlet customLocale = \"en\";\n\tlet setLocaleCalled = false;\n\n\tglobalThis.window = {\n\t\tlocation: { reload: vi.fn() },\n\t} as any;\n\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\", \"fr\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"custom-setter\", \"baseLocale\"],\n\t\tisServer: \"false\",\n\t});\n\n\truntime.defineCustomClientStrategy(\"custom-setter\", {\n\t\tgetLocale: () => customLocale,\n\t\tsetLocale: (locale) => {\n\t\t\tcustomLocale = locale;\n\t\t\tsetLocaleCalled = true;\n\t\t},\n\t});\n\n\truntime.setLocale(\"fr\");\n\n\texpect(setLocaleCalled).toBe(true);\n\texpect(customLocale).toBe(\"fr\");\n\texpect(globalThis.window.location.reload).toHaveBeenCalled();\n});\n\ntest(\"calls setLocale on multiple custom strategies\", async () => {\n\tlet customLocale1 = \"en\";\n\tlet customLocale2 = \"en\";\n\tlet setLocaleCalled1 = false;\n\tlet setLocaleCalled2 = false;\n\n\tglobalThis.window = {\n\t\tlocation: { reload: vi.fn() },\n\t} as any;\n\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\", \"fr\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"custom-multi1\", \"custom-multi2\", \"baseLocale\"],\n\t\tisServer: \"false\",\n\t});\n\n\truntime.defineCustomClientStrategy(\"custom-multi1\", {\n\t\tgetLocale: () => customLocale1,\n\t\tsetLocale: (locale) => {\n\t\t\tcustomLocale1 = locale;\n\t\t\tsetLocaleCalled1 = true;\n\t\t},\n\t});\n\n\truntime.defineCustomClientStrategy(\"custom-multi2\", {\n\t\tgetLocale: () => customLocale2,\n\t\tsetLocale: (locale) => {\n\t\t\tcustomLocale2 = locale;\n\t\t\tsetLocaleCalled2 = true;\n\t\t},\n\t});\n\n\truntime.setLocale(\"de\");\n\n\texpect(setLocaleCalled1).toBe(true);\n\texpect(setLocaleCalled2).toBe(true);\n\texpect(customLocale1).toBe(\"de\");\n\texpect(customLocale2).toBe(\"de\");\n});\n\ntest(\"setLocale should return a promise if any custom setLocale function is async\", async () => {\n\tlet customLocale1 = \"en\";\n\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\", \"fr\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"custom-async\", \"baseLocale\"],\n\t\tisServer: \"false\",\n\t});\n\n\truntime.defineCustomClientStrategy(\"custom-async\", {\n\t\tgetLocale: () => customLocale1,\n\t\tsetLocale: async (locale) => {\n\t\t\tcustomLocale1 = locale;\n\t\t},\n\t});\n\n\tconst setLocalePromise = runtime.setLocale(\"de\");\n\tconst setLocalePromiseWithoutReload = runtime.setLocale(\"de\", {\n\t\treload: false,\n\t});\n\n\texpect(setLocalePromise).toBeInstanceOf(Promise);\n\texpect(setLocalePromiseWithoutReload).toBeInstanceOf(Promise);\n});\n\ntest(\"awaits async setLocale functions to resolve in custom strategy\", async () => {\n\tlet customLocale1 = \"en\";\n\n\tglobalThis.window = {\n\t\tlocation: {\n\t\t\treload: vi.fn(),\n\t\t},\n\t} as any;\n\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\", \"fr\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"custom-async\", \"baseLocale\"],\n\t\tisServer: \"false\",\n\t});\n\n\truntime.defineCustomClientStrategy(\"custom-async\", {\n\t\tgetLocale: () => customLocale1,\n\t\tsetLocale: async (locale) => {\n\t\t\tcustomLocale1 = locale;\n\t\t},\n\t});\n\n\tconst setLocalePromise = runtime.setLocale(\"de\");\n\texpect(window.location.reload).not.toHaveBeenCalled();\n\n\tawait setLocalePromise;\n\n\t// Verify that setLocale resolved before reload was called\n\texpect(window.location.reload).toHaveBeenCalledTimes(1);\n\texpect(customLocale1).toBe(\"de\");\n});\n\ntest(\"awaits async setLocale functions to resolve in multiple custom strategies\", async () => {\n\tlet customLocale1 = \"en\";\n\tlet customLocale2 = \"en\";\n\n\tglobalThis.window = {\n\t\tlocation: {\n\t\t\treload: vi.fn(),\n\t\t},\n\t} as any;\n\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\", \"fr\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"custom-async1\", \"custom-async2\", \"baseLocale\"],\n\t\tisServer: \"false\",\n\t});\n\n\truntime.defineCustomClientStrategy(\"custom-async1\", {\n\t\tgetLocale: () => customLocale1,\n\t\tsetLocale: async (locale) => {\n\t\t\tcustomLocale1 = locale;\n\t\t},\n\t});\n\n\truntime.defineCustomClientStrategy(\"custom-async2\", {\n\t\tgetLocale: () => customLocale2,\n\t\tsetLocale: async (locale) => {\n\t\t\tcustomLocale2 = locale;\n\t\t},\n\t});\n\n\tconst setLocalePromise = runtime.setLocale(\"de\");\n\texpect(window.location.reload).not.toHaveBeenCalled();\n\n\tawait setLocalePromise;\n\n\t// Verify that setLocale resolved before reload was called\n\texpect(window.location.reload).toHaveBeenCalledTimes(1);\n\texpect(customLocale1).toBe(\"de\");\n\texpect(customLocale2).toBe(\"de\");\n});\n\ntest(\"reload should not run if async setLocale function rejects in custom strategy\", async () => {\n\tconst customLocale1 = \"en\";\n\n\tglobalThis.window = {\n\t\tlocation: {\n\t\t\treload: vi.fn(),\n\t\t},\n\t} as any;\n\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\", \"fr\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"custom-async\", \"baseLocale\"],\n\t\tisServer: \"false\",\n\t});\n\n\truntime.defineCustomClientStrategy(\"custom-async\", {\n\t\tgetLocale: () => customLocale1,\n\t\tsetLocale: async () => {\n\t\t\tthrow new Error(\"fetch error\");\n\t\t},\n\t});\n\n\tconst error = expect(() => runtime.setLocale(\"de\")).rejects;\n\tawait error.toThrowError(`Custom strategy \"custom-async\" setLocale failed.`);\n\tawait error.toMatchObject({ cause: { message: \"fetch error\" } });\n\n\t// Verify that reload was never called\n\texpect(window.location.reload).toHaveBeenCalledTimes(0);\n\texpect(customLocale1).toBe(\"en\");\n});\n\ntest(\"custom strategy setLocale works with cookie and localStorage\", async () => {\n\tlet customData = \"en\";\n\n\tglobalThis.document = { cookie: \"\" } as any;\n\tglobalThis.localStorage = {\n\t\tsetItem: vi.fn(),\n\t\tgetItem: () => null,\n\t} as any;\n\tglobalThis.window = {\n\t\tlocation: {\n\t\t\thostname: \"example.com\",\n\t\t\treload: vi.fn(),\n\t\t},\n\t} as any;\n\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\", \"fr\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"custom-api\", \"localStorage\", \"cookie\", \"baseLocale\"],\n\t\tcookieName: \"PARAGLIDE_LOCALE\",\n\t\tisServer: \"false\",\n\t});\n\n\truntime.defineCustomClientStrategy(\"custom-api\", {\n\t\tgetLocale: () => customData,\n\t\tsetLocale: (locale) => {\n\t\t\tcustomData = locale;\n\t\t},\n\t});\n\n\truntime.setLocale(\"fr\");\n\n\texpect(customData).toBe(\"fr\");\n\texpect(globalThis.localStorage.setItem).toHaveBeenCalledWith(\n\t\t\"PARAGLIDE_LOCALE\",\n\t\t\"fr\"\n\t);\n\texpect(globalThis.document.cookie).toBe(\n\t\t\"PARAGLIDE_LOCALE=fr; path=/; max-age=34560000\"\n\t);\n});\n\ntest(\"custom strategy setLocale integrates with URL strategy\", async () => {\n\tlet customStoredLocale = \"en\";\n\n\tglobalThis.window = {\n\t\tlocation: {\n\t\t\thostname: \"example.com\",\n\t\t\thref: \"https://example.com/en/page\",\n\t\t\treload: vi.fn(),\n\t\t},\n\t} as any;\n\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\", \"fr\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"url\", \"custom-urlIntegration\", \"baseLocale\"],\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \"https://example.com/:locale/:path*\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"en\", \"https://example.com/en/:path*\"],\n\t\t\t\t\t[\"fr\", \"https://example.com/fr/:path*\"],\n\t\t\t\t\t[\"de\", \"https://example.com/de/:path*\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t\tisServer: \"false\",\n\t});\n\n\truntime.defineCustomClientStrategy(\"custom-urlIntegration\", {\n\t\tgetLocale: () => customStoredLocale,\n\t\tsetLocale: (locale) => {\n\t\t\tcustomStoredLocale = locale;\n\t\t},\n\t});\n\n\truntime.setLocale(\"de\");\n\n\texpect(globalThis.window.location.href).toBe(\"https://example.com/de/page\");\n\texpect(customStoredLocale).toBe(\"de\");\n});\n"]}
1
+ {"version":3,"file":"set-locale.test.js","sourceRoot":"","sources":["../../../src/compiler/runtime/set-locale.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,IAAI,CAAC,uCAAuC,EAAE,KAAK,IAAI,EAAE;IACxD,gDAAgD;IAChD,UAAU,CAAC,QAAQ,GAAG,EAAE,CAAC;IACzB,gDAAgD;IAChD,UAAU,CAAC,MAAM,GAAG,EAAE,CAAC;IACvB,gDAAgD;IAChD,UAAU,CAAC,MAAM,CAAC,QAAQ,GAAG,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC;IACzD,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;IAE5C,MAAM,OAAO,GAAG,MAAM,eAAe,CAAC;QACrC,IAAI,EAAE,MAAM,UAAU,CAAC;YACtB,QAAQ,EAAE;gBACT,UAAU,EAAE,IAAI;gBAChB,OAAO,EA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CAAC,EAAE,EAAE;SACf;KACM,CAAC;IAET,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAExB,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,CAAC;AACxD,CAAC,CAAC,CAAC","sourcesContent":["import { newProject } from \"@inlang/sdk\";\nimport { expect, test, vi } from \"vitest\";\nimport { createParaglide } from \"../create-paraglide.js\";\n\ntest(\"sets the cookie to a different locale\", async () => {\n\t// @ts-expect-error - global variable definition\n\tglobalThis.document = {};\n\t// @ts-expect-error - global variable definition\n\tglobalThis.window = {};\n\t// @ts-expect-error - global variable definition\n\tglobalThis.window.location = { hostname: \"example.com\" };\n\tglobalThis.window.location.reload = vi.fn();\n\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: [\"cookie\"],\n\t\tcookieName: \"PARAGLIDE_LOCALE\",\n\t});\n\n\tglobalThis.document.cookie = \"PARAGLIDE_LOCALE=en\";\n\n\truntime.setLocale(\"de\");\n\n\t// set the locale\n\texpect(globalThis.document.cookie).toBe(\n\t\t\"PARAGLIDE_LOCALE=de; path=/; max-age=34560000\"\n\t);\n\t// reloads the site if window is available\n\texpect(globalThis.window.location.reload).toBeCalled();\n});\n\ntest(\"sets the cookie with explicit domain to a different locale navigating subdomain\", async () => {\n\t// @ts-expect-error - global variable definition\n\tglobalThis.document = {};\n\t// @ts-expect-error - global variable definition\n\tglobalThis.window = {};\n\t// @ts-expect-error - global variable definition\n\tglobalThis.window.location = { hostname: \"web.example.com\" };\n\tglobalThis.window.location.reload = vi.fn();\n\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: [\"cookie\"],\n\t\tcookieName: \"PARAGLIDE_LOCALE\",\n\t\tcookieDomain: \"example.com\",\n\t});\n\n\tglobalThis.document.cookie = \"PARAGLIDE_LOCALE=en\";\n\n\truntime.setLocale(\"de\");\n\n\t// set the locale\n\texpect(globalThis.document.cookie).toBe(\n\t\t\"PARAGLIDE_LOCALE=de; path=/; max-age=34560000; domain=example.com\"\n\t);\n\t// reloads the site if window is available\n\texpect(globalThis.window.location.reload).toBeCalled();\n});\n\ntest(\"sets the cookie with explicit domain to a different locale navigating domain\", async () => {\n\t// @ts-expect-error - global variable definition\n\tglobalThis.document = {};\n\t// @ts-expect-error - global variable definition\n\tglobalThis.window = {};\n\t// @ts-expect-error - global variable definition\n\tglobalThis.window.location = { hostname: \"example.com\" };\n\tglobalThis.window.location.reload = vi.fn();\n\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: [\"cookie\"],\n\t\tcookieName: \"PARAGLIDE_LOCALE\",\n\t\tcookieDomain: \"example.com\",\n\t});\n\n\tglobalThis.document.cookie = \"PARAGLIDE_LOCALE=en\";\n\n\truntime.setLocale(\"de\");\n\n\t// set the locale\n\texpect(globalThis.document.cookie).toBe(\n\t\t\"PARAGLIDE_LOCALE=de; path=/; max-age=34560000; domain=example.com\"\n\t);\n\t// reloads the site if window is available\n\texpect(globalThis.window.location.reload).toBeCalled();\n});\n\ntest(\"sets the cookie with samesite and secure attributes\", async () => {\n\t// @ts-expect-error - global variable definition\n\tglobalThis.document = {};\n\t// @ts-expect-error - global variable definition\n\tglobalThis.window = {};\n\t// @ts-expect-error - global variable definition\n\tglobalThis.window.location = { hostname: \"example.com\" };\n\tglobalThis.window.location.reload = vi.fn();\n\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: [\"cookie\"],\n\t\tcookieName: \"PARAGLIDE_LOCALE\",\n\t\tcookieDomain: \"example.com\",\n\t\tcookieSameSite: \"strict\",\n\t\tcookieSecure: true,\n\t});\n\n\tglobalThis.document.cookie = \"PARAGLIDE_LOCALE=en\";\n\n\truntime.setLocale(\"de\");\n\n\texpect(globalThis.document.cookie).toBe(\n\t\t\"PARAGLIDE_LOCALE=de; path=/; max-age=34560000; domain=example.com; samesite=strict; secure\"\n\t);\n\t// exported so server code can write the cookie with the same attributes\n\texpect(runtime.cookieSameSite).toBe(\"strict\");\n\texpect(runtime.cookieSecure).toBe(true);\n});\n\ntest.each([true, \"auto\"] as const)(\n\t\"sets samesite=none with secure on https pages (cookieSecure: %s)\",\n\tasync (cookieSecure) => {\n\t\t// @ts-expect-error - global variable definition\n\t\tglobalThis.document = {};\n\t\t// @ts-expect-error - global variable definition\n\t\tglobalThis.window = {};\n\t\t// @ts-expect-error - global variable definition\n\t\tglobalThis.window.location = {\n\t\t\thostname: \"example.com\",\n\t\t\tprotocol: \"https:\",\n\t\t};\n\t\tglobalThis.window.location.reload = vi.fn();\n\n\t\tconst runtime = await createParaglide({\n\t\t\tblob: await newProject({\n\t\t\t\tsettings: {\n\t\t\t\t\tbaseLocale: \"en\",\n\t\t\t\t\tlocales: [\"en\", \"de\"],\n\t\t\t\t},\n\t\t\t}),\n\t\t\tstrategy: [\"cookie\"],\n\t\t\tcookieName: \"PARAGLIDE_LOCALE\",\n\t\t\tcookieSameSite: \"none\",\n\t\t\tcookieSecure,\n\t\t});\n\n\t\tglobalThis.document.cookie = \"PARAGLIDE_LOCALE=en\";\n\n\t\truntime.setLocale(\"de\");\n\n\t\texpect(globalThis.document.cookie).toBe(\n\t\t\t\"PARAGLIDE_LOCALE=de; path=/; max-age=34560000; samesite=none; secure\"\n\t\t);\n\t}\n);\n\ntest(\"cookieSecure 'auto' only sets the secure attribute on https pages\", async () => {\n\t// @ts-expect-error - global variable definition\n\tglobalThis.document = {};\n\t// @ts-expect-error - global variable definition\n\tglobalThis.window = {};\n\t// @ts-expect-error - global variable definition\n\tglobalThis.window.location = {\n\t\thostname: \"example.com\",\n\t\tprotocol: \"https:\",\n\t};\n\tglobalThis.window.location.reload = vi.fn();\n\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: [\"cookie\"],\n\t\tcookieName: \"PARAGLIDE_LOCALE\",\n\t\tcookieSameSite: \"lax\",\n\t\tcookieSecure: \"auto\",\n\t});\n\n\tglobalThis.document.cookie = \"PARAGLIDE_LOCALE=en\";\n\n\truntime.setLocale(\"de\");\n\n\texpect(globalThis.document.cookie).toBe(\n\t\t\"PARAGLIDE_LOCALE=de; path=/; max-age=34560000; samesite=lax; secure\"\n\t);\n\n\tglobalThis.window.location.protocol = \"http:\";\n\n\truntime.setLocale(\"en\");\n\n\texpect(globalThis.document.cookie).toBe(\n\t\t\"PARAGLIDE_LOCALE=en; path=/; max-age=34560000; samesite=lax\"\n\t);\n});\n\ntest(\"url pattern strategy sets the window location\", async () => {\n\t// @ts-expect-error - global variable definition\n\tglobalThis.window = {};\n\t// @ts-expect-error - global variable definition\n\tglobalThis.window.location = {};\n\tglobalThis.window.location.hostname = \"example.com\";\n\tglobalThis.window.location.reload = vi.fn();\n\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\t\t{\n\t\t\t\tpattern: \"https://example.:tld/: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://example.de/:path*\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\tglobalThis.window.location.href = \"https://example.com/page\";\n\n\truntime.setLocale(\"de\");\n\n\texpect(globalThis.window.location.href).toBe(\"https://example.de/page\");\n\t// setting window.location.hostname automatically reloads the page\n\texpect(globalThis.window.location.reload).not.toBeCalled();\n});\n\ntest(\"url strategy setLocale normalizes mixed-case explicit locales\", async () => {\n\t// @ts-expect-error - global variable definition\n\tglobalThis.window = {};\n\t// @ts-expect-error - global variable definition\n\tglobalThis.window.location = {};\n\tglobalThis.window.location.hostname = \"example.com\";\n\tglobalThis.window.location.reload = vi.fn();\n\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\t\t{\n\t\t\t\tpattern: \"https://example.:tld/: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://example.de/:path*\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\tglobalThis.window.location.href = \"https://example.com/page\";\n\n\truntime.setLocale(\"DE\" as any);\n\n\texpect(globalThis.window.location.href).toBe(\"https://example.de/page\");\n\t// setting window.location.hostname automatically reloads the page\n\texpect(globalThis.window.location.reload).not.toBeCalled();\n});\n\ntest(\"routeStrategies can disable url navigation on matching routes\", async () => {\n\t// @ts-expect-error - global variable definition\n\tglobalThis.window = {};\n\t// @ts-expect-error - global variable definition\n\tglobalThis.document = {};\n\t// @ts-expect-error - global variable definition\n\tglobalThis.window.location = {\n\t\thref: \"https://example.com/dashboard\",\n\t\thostname: \"example.com\",\n\t\treload: vi.fn(),\n\t};\n\n\tconst runtime = await createParaglide({\n\t\tblob: await newProject({\n\t\t\tsettings: { baseLocale: \"en\", locales: [\"en\", \"fr\"] },\n\t\t}),\n\t\tstrategy: [\"url\", \"cookie\", \"baseLocale\"],\n\t\tcookieName: \"PARAGLIDE_LOCALE\",\n\t\trouteStrategies: [\n\t\t\t{\n\t\t\t\tmatch: \"/dashboard/:path(.*)?\",\n\t\t\t\tstrategy: [\"cookie\", \"baseLocale\"],\n\t\t\t},\n\t\t],\n\t});\n\n\tglobalThis.document.cookie = \"PARAGLIDE_LOCALE=en\";\n\truntime.setLocale(\"fr\");\n\n\texpect(globalThis.document.cookie).toBe(\n\t\t\"PARAGLIDE_LOCALE=fr; path=/; max-age=34560000\"\n\t);\n\texpect(globalThis.window.location.href).toBe(\"https://example.com/dashboard\");\n\texpect(globalThis.window.location.reload).toBeCalled();\n});\n\n// `!document.cookie` was used which returned false for an empty string\ntest(\"sets the cookie when it's an empty string\", 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\", \"fr\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"cookie\"],\n\t\tcookieName: \"PARAGLIDE_LOCALE\",\n\t});\n\n\t/** @ts-expect-error - client side api */\n\tglobalThis.document = { cookie: \"\" };\n\n\truntime.setLocale(\"en\");\n\n\texpect(globalThis.document.cookie).toBe(\n\t\t\"PARAGLIDE_LOCALE=en; path=/; max-age=34560000\"\n\t);\n});\n\ntest(\"when strategy precedes URL, it should set the locale and re-direct to the URL\", 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\", \"fr\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"cookie\", \"url\", \"baseLocale\"],\n\t\tcookieName: \"PARAGLIDE_LOCALE\",\n\t\tisServer: \"false\",\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \"https://example.com/en/:path(.*)?\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"en\", \"https://example.com/en/:path(.*)?\"],\n\t\t\t\t\t[\"fr\", \"https://example.com/fr/:path(.*)?\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\t/** @ts-expect-error - client side api */\n\tglobalThis.document = { cookie: \"PARAGLIDE_LOCALE=fr\" };\n\tglobalThis.window = {\n\t\tlocation: new URL(\"https://example.com/fr/some-path\"),\n\t} as any;\n\n\t// Cookie strategy should determine locale as French\n\texpect(runtime.getLocale()).toBe(\"fr\");\n\n\truntime.setLocale(\"en\");\n\n\texpect(globalThis.document.cookie).toBe(\n\t\t\"PARAGLIDE_LOCALE=en; path=/; max-age=34560000\"\n\t);\n\texpect(globalThis.window.location.href).toBe(\n\t\t\"https://example.com/en/some-path\"\n\t);\n});\n\ntest(\"overwriteSetLocale receives the options object\", 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\", \"fr\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"cookie\"],\n\t\tcookieName: \"PARAGLIDE_LOCALE\",\n\t});\n\n\t// Provide minimal browser globals to avoid strategy branches failing.\n\t/** @ts-expect-error - browser shim for tests */\n\tglobalThis.document = { cookie: \"\" };\n\tglobalThis.window = {\n\t\tlocation: {\n\t\t\thref: \"https://example.com/en\",\n\t\t\treload: vi.fn(),\n\t\t},\n\t} as any;\n\n\tconst spy = vi.fn();\n\truntime.overwriteSetLocale(spy);\n\n\truntime.setLocale(\"fr\", { reload: false });\n\n\texpect(spy).toHaveBeenCalledWith(\"fr\", { reload: false });\n});\n\n// https://github.com/opral/inlang-paraglide-js/issues/430\ntest(\"should not reload when setting locale to current locale\", async () => {\n\t// @ts-expect-error - global variable definition\n\tglobalThis.document = {};\n\t// @ts-expect-error - global variable definition\n\tglobalThis.window = {};\n\t// @ts-expect-error - global variable definition\n\tglobalThis.window.location = { hostname: \"example.com\" };\n\tglobalThis.window.location.reload = vi.fn();\n\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: [\"cookie\"],\n\t\tcookieName: \"PARAGLIDE_LOCALE\",\n\t});\n\n\tglobalThis.document.cookie = \"PARAGLIDE_LOCALE=en; path=/\";\n\n\t// Setting to the current locale (en)\n\truntime.setLocale(\"en\");\n\n\t// Cookie should remain unchanged\n\texpect(globalThis.document.cookie).toBe(\n\t\t\"PARAGLIDE_LOCALE=en; path=/; max-age=34560000\"\n\t);\n\t// Should not trigger a reload\n\texpect(globalThis.window.location.reload).not.toBeCalled();\n\n\t// Setting to a different locale should still work\n\truntime.setLocale(\"de\");\n\texpect(globalThis.document.cookie).toBe(\n\t\t\"PARAGLIDE_LOCALE=de; path=/; max-age=34560000\"\n\t);\n\texpect(globalThis.window.location.reload).toBeCalled();\n});\n\ntest(\"static locale builds force a document reload when switching locales\", async () => {\n\t// @ts-expect-error - browser shim for tests\n\tglobalThis.document = { cookie: \"\" };\n\tglobalThis.window = {\n\t\tlocation: {\n\t\t\thref: \"https://example.com/en\",\n\t\t\thostname: \"example.com\",\n\t\t\treload: vi.fn(),\n\t\t},\n\t} as any;\n\tconst warn = vi.spyOn(console, \"warn\").mockImplementation(() => undefined);\n\n\ttry {\n\t\tconst runtime = await createParaglide({\n\t\t\tblob: await newProject({\n\t\t\t\tsettings: {\n\t\t\t\t\tbaseLocale: \"en\",\n\t\t\t\t\tlocales: [\"en\", \"de\"],\n\t\t\t\t},\n\t\t\t}),\n\t\t\tstrategy: [\"cookie\"],\n\t\t\tisServer: \"false\",\n\t\t\texperimentalStaticLocale: JSON.stringify(\"en\"),\n\t\t});\n\n\t\truntime.setLocale(\"de\", { reload: false });\n\n\t\texpect(warn).toHaveBeenCalledOnce();\n\t\texpect(globalThis.window.location.reload).toHaveBeenCalledOnce();\n\t} finally {\n\t\twarn.mockRestore();\n\t}\n});\n\ntest(\"sets the locale to localStorage\", async () => {\n\t// @ts-expect-error - global variable definition\n\tglobalThis.localStorage = {\n\t\tsetItem: vi.fn(),\n\t\tgetItem: () => \"en\",\n\t};\n\n\t// @ts-expect-error - global variable definition\n\tglobalThis.window = {};\n\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: [\"localStorage\"],\n\t});\n\n\truntime.setLocale(\"de\");\n\n\texpect(globalThis.localStorage.setItem).toHaveBeenCalledWith(\n\t\t\"PARAGLIDE_LOCALE\",\n\t\t\"de\"\n\t);\n});\n\n// Test that all strategies set their respective storage mechanisms\ntest(\"should set locale in all configured storage mechanisms regardless of which strategy resolved the locale\", async () => {\n\t// Setup global objects\n\t// @ts-expect-error - global variable definition\n\tglobalThis.document = { cookie: \"\" };\n\t// @ts-expect-error - global variable definition\n\tglobalThis.localStorage = {\n\t\tsetItem: vi.fn(),\n\t\tgetItem: () => null,\n\t};\n\t// @ts-expect-error - global variable definition\n\tglobalThis.window = {};\n\t// @ts-expect-error - global variable definition\n\tglobalThis.window.location = {};\n\tglobalThis.window.location.hostname = \"example.com\";\n\tglobalThis.window.location.href = \"https://example.com/en/page\";\n\tglobalThis.window.location.reload = vi.fn();\n\n\t// Create runtime with multiple strategies\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\", \"localStorage\", \"cookie\", \"baseLocale\"],\n\t\tcookieName: \"PARAGLIDE_LOCALE\",\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \"https://example.com/:locale/:path*\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"en\", \"https://example.com/en/:path*\"],\n\t\t\t\t\t[\"de\", \"https://example.com/de/:path*\"],\n\t\t\t\t\t[\"fr\", \"https://example.com/fr/:path*\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\t// Call setLocale\n\truntime.setLocale(\"fr\");\n\n\t// Verify that all storage mechanisms are updated\n\texpect(globalThis.window.location.href).toBe(\"https://example.com/fr/page\");\n\texpect(globalThis.localStorage.setItem).toHaveBeenCalledWith(\n\t\t\"PARAGLIDE_LOCALE\",\n\t\t\"fr\"\n\t);\n\texpect(globalThis.document.cookie).toBe(\n\t\t\"PARAGLIDE_LOCALE=fr; path=/; max-age=34560000\"\n\t);\n});\n\ntest(\"calls setLocale on custom strategy\", async () => {\n\tlet customLocale = \"en\";\n\tlet setLocaleCalled = false;\n\n\tglobalThis.window = {\n\t\tlocation: { reload: vi.fn() },\n\t} as any;\n\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\", \"fr\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"custom-setter\", \"baseLocale\"],\n\t\tisServer: \"false\",\n\t});\n\n\truntime.defineCustomClientStrategy(\"custom-setter\", {\n\t\tgetLocale: () => customLocale,\n\t\tsetLocale: (locale) => {\n\t\t\tcustomLocale = locale;\n\t\t\tsetLocaleCalled = true;\n\t\t},\n\t});\n\n\truntime.setLocale(\"fr\");\n\n\texpect(setLocaleCalled).toBe(true);\n\texpect(customLocale).toBe(\"fr\");\n\texpect(globalThis.window.location.reload).toHaveBeenCalled();\n});\n\ntest(\"calls setLocale on multiple custom strategies\", async () => {\n\tlet customLocale1 = \"en\";\n\tlet customLocale2 = \"en\";\n\tlet setLocaleCalled1 = false;\n\tlet setLocaleCalled2 = false;\n\n\tglobalThis.window = {\n\t\tlocation: { reload: vi.fn() },\n\t} as any;\n\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\", \"fr\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"custom-multi1\", \"custom-multi2\", \"baseLocale\"],\n\t\tisServer: \"false\",\n\t});\n\n\truntime.defineCustomClientStrategy(\"custom-multi1\", {\n\t\tgetLocale: () => customLocale1,\n\t\tsetLocale: (locale) => {\n\t\t\tcustomLocale1 = locale;\n\t\t\tsetLocaleCalled1 = true;\n\t\t},\n\t});\n\n\truntime.defineCustomClientStrategy(\"custom-multi2\", {\n\t\tgetLocale: () => customLocale2,\n\t\tsetLocale: (locale) => {\n\t\t\tcustomLocale2 = locale;\n\t\t\tsetLocaleCalled2 = true;\n\t\t},\n\t});\n\n\truntime.setLocale(\"de\");\n\n\texpect(setLocaleCalled1).toBe(true);\n\texpect(setLocaleCalled2).toBe(true);\n\texpect(customLocale1).toBe(\"de\");\n\texpect(customLocale2).toBe(\"de\");\n});\n\ntest(\"setLocale should return a promise if any custom setLocale function is async\", async () => {\n\tlet customLocale1 = \"en\";\n\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\", \"fr\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"custom-async\", \"baseLocale\"],\n\t\tisServer: \"false\",\n\t});\n\n\truntime.defineCustomClientStrategy(\"custom-async\", {\n\t\tgetLocale: () => customLocale1,\n\t\tsetLocale: async (locale) => {\n\t\t\tcustomLocale1 = locale;\n\t\t},\n\t});\n\n\tconst setLocalePromise = runtime.setLocale(\"de\");\n\tconst setLocalePromiseWithoutReload = runtime.setLocale(\"de\", {\n\t\treload: false,\n\t});\n\n\texpect(setLocalePromise).toBeInstanceOf(Promise);\n\texpect(setLocalePromiseWithoutReload).toBeInstanceOf(Promise);\n});\n\ntest(\"awaits async setLocale functions to resolve in custom strategy\", async () => {\n\tlet customLocale1 = \"en\";\n\n\tglobalThis.window = {\n\t\tlocation: {\n\t\t\treload: vi.fn(),\n\t\t},\n\t} as any;\n\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\", \"fr\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"custom-async\", \"baseLocale\"],\n\t\tisServer: \"false\",\n\t});\n\n\truntime.defineCustomClientStrategy(\"custom-async\", {\n\t\tgetLocale: () => customLocale1,\n\t\tsetLocale: async (locale) => {\n\t\t\tcustomLocale1 = locale;\n\t\t},\n\t});\n\n\tconst setLocalePromise = runtime.setLocale(\"de\");\n\texpect(window.location.reload).not.toHaveBeenCalled();\n\n\tawait setLocalePromise;\n\n\t// Verify that setLocale resolved before reload was called\n\texpect(window.location.reload).toHaveBeenCalledTimes(1);\n\texpect(customLocale1).toBe(\"de\");\n});\n\ntest(\"awaits async setLocale functions to resolve in multiple custom strategies\", async () => {\n\tlet customLocale1 = \"en\";\n\tlet customLocale2 = \"en\";\n\n\tglobalThis.window = {\n\t\tlocation: {\n\t\t\treload: vi.fn(),\n\t\t},\n\t} as any;\n\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\", \"fr\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"custom-async1\", \"custom-async2\", \"baseLocale\"],\n\t\tisServer: \"false\",\n\t});\n\n\truntime.defineCustomClientStrategy(\"custom-async1\", {\n\t\tgetLocale: () => customLocale1,\n\t\tsetLocale: async (locale) => {\n\t\t\tcustomLocale1 = locale;\n\t\t},\n\t});\n\n\truntime.defineCustomClientStrategy(\"custom-async2\", {\n\t\tgetLocale: () => customLocale2,\n\t\tsetLocale: async (locale) => {\n\t\t\tcustomLocale2 = locale;\n\t\t},\n\t});\n\n\tconst setLocalePromise = runtime.setLocale(\"de\");\n\texpect(window.location.reload).not.toHaveBeenCalled();\n\n\tawait setLocalePromise;\n\n\t// Verify that setLocale resolved before reload was called\n\texpect(window.location.reload).toHaveBeenCalledTimes(1);\n\texpect(customLocale1).toBe(\"de\");\n\texpect(customLocale2).toBe(\"de\");\n});\n\ntest(\"reload should not run if async setLocale function rejects in custom strategy\", async () => {\n\tconst customLocale1 = \"en\";\n\n\tglobalThis.window = {\n\t\tlocation: {\n\t\t\treload: vi.fn(),\n\t\t},\n\t} as any;\n\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\", \"fr\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"custom-async\", \"baseLocale\"],\n\t\tisServer: \"false\",\n\t});\n\n\truntime.defineCustomClientStrategy(\"custom-async\", {\n\t\tgetLocale: () => customLocale1,\n\t\tsetLocale: async () => {\n\t\t\tthrow new Error(\"fetch error\");\n\t\t},\n\t});\n\n\tconst error = expect(() => runtime.setLocale(\"de\")).rejects;\n\tawait error.toThrowError(`Custom strategy \"custom-async\" setLocale failed.`);\n\tawait error.toMatchObject({ cause: { message: \"fetch error\" } });\n\n\t// Verify that reload was never called\n\texpect(window.location.reload).toHaveBeenCalledTimes(0);\n\texpect(customLocale1).toBe(\"en\");\n});\n\ntest(\"custom strategy setLocale works with cookie and localStorage\", async () => {\n\tlet customData = \"en\";\n\n\tglobalThis.document = { cookie: \"\" } as any;\n\tglobalThis.localStorage = {\n\t\tsetItem: vi.fn(),\n\t\tgetItem: () => null,\n\t} as any;\n\tglobalThis.window = {\n\t\tlocation: {\n\t\t\thostname: \"example.com\",\n\t\t\treload: vi.fn(),\n\t\t},\n\t} as any;\n\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\", \"fr\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"custom-api\", \"localStorage\", \"cookie\", \"baseLocale\"],\n\t\tcookieName: \"PARAGLIDE_LOCALE\",\n\t\tisServer: \"false\",\n\t});\n\n\truntime.defineCustomClientStrategy(\"custom-api\", {\n\t\tgetLocale: () => customData,\n\t\tsetLocale: (locale) => {\n\t\t\tcustomData = locale;\n\t\t},\n\t});\n\n\truntime.setLocale(\"fr\");\n\n\texpect(customData).toBe(\"fr\");\n\texpect(globalThis.localStorage.setItem).toHaveBeenCalledWith(\n\t\t\"PARAGLIDE_LOCALE\",\n\t\t\"fr\"\n\t);\n\texpect(globalThis.document.cookie).toBe(\n\t\t\"PARAGLIDE_LOCALE=fr; path=/; max-age=34560000\"\n\t);\n});\n\ntest(\"custom strategy setLocale integrates with URL strategy\", async () => {\n\tlet customStoredLocale = \"en\";\n\n\tglobalThis.window = {\n\t\tlocation: {\n\t\t\thostname: \"example.com\",\n\t\t\thref: \"https://example.com/en/page\",\n\t\t\treload: vi.fn(),\n\t\t},\n\t} as any;\n\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\", \"fr\", \"de\"],\n\t\t\t},\n\t\t}),\n\t\tstrategy: [\"url\", \"custom-urlIntegration\", \"baseLocale\"],\n\t\turlPatterns: [\n\t\t\t{\n\t\t\t\tpattern: \"https://example.com/:locale/:path*\",\n\t\t\t\tlocalized: [\n\t\t\t\t\t[\"en\", \"https://example.com/en/:path*\"],\n\t\t\t\t\t[\"fr\", \"https://example.com/fr/:path*\"],\n\t\t\t\t\t[\"de\", \"https://example.com/de/:path*\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t\tisServer: \"false\",\n\t});\n\n\truntime.defineCustomClientStrategy(\"custom-urlIntegration\", {\n\t\tgetLocale: () => customStoredLocale,\n\t\tsetLocale: (locale) => {\n\t\t\tcustomStoredLocale = locale;\n\t\t},\n\t});\n\n\truntime.setLocale(\"de\");\n\n\texpect(globalThis.window.location.href).toBe(\"https://example.com/de/page\");\n\texpect(customStoredLocale).toBe(\"de\");\n});\n\n// sandboxed iframes without allow-same-origin have an opaque origin and throw\n// a SecurityError on document.cookie and localStorage access\ntest(\"navigates to the localized url when document.cookie throws\", 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\", \"cookie\", \"baseLocale\"],\n\t\tcookieName: \"PARAGLIDE_LOCALE\",\n\t\tisServer: \"false\",\n\t\turlPatterns: [\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/en/:path*\"],\n\t\t\t\t\t[\"de\", \"https://example.com/de/:path*\"],\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t});\n\n\t/** @ts-expect-error - client side api */\n\tglobalThis.document = {\n\t\tget cookie(): string {\n\t\t\tthrow new DOMException(\"The operation is insecure.\", \"SecurityError\");\n\t\t},\n\t\tset cookie(_value) {\n\t\t\tthrow new DOMException(\"The operation is insecure.\", \"SecurityError\");\n\t\t},\n\t};\n\tglobalThis.window = {\n\t\tlocation: new URL(\"https://example.com/en/some-path\"),\n\t} as any;\n\n\truntime.setLocale(\"de\");\n\n\texpect(globalThis.window.location.href).toBe(\n\t\t\"https://example.com/de/some-path\"\n\t);\n});\n\ntest(\"reloads when document.cookie throws\", 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: [\"cookie\", \"baseLocale\"],\n\t\tcookieName: \"PARAGLIDE_LOCALE\",\n\t\tisServer: \"false\",\n\t});\n\n\t/** @ts-expect-error - client side api */\n\tglobalThis.document = {\n\t\tget cookie(): string {\n\t\t\tthrow new DOMException(\"The operation is insecure.\", \"SecurityError\");\n\t\t},\n\t\tset cookie(_value) {\n\t\t\tthrow new DOMException(\"The operation is insecure.\", \"SecurityError\");\n\t\t},\n\t};\n\tglobalThis.window = {\n\t\tlocation: {\n\t\t\thref: \"https://example.com/page\",\n\t\t\treload: vi.fn(),\n\t\t},\n\t} as any;\n\n\truntime.setLocale(\"de\");\n\n\texpect(globalThis.window.location.reload).toBeCalled();\n});\n\ntest(\"reloads when localStorage throws\", 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: [\"localStorage\", \"baseLocale\"],\n\t\tisServer: \"false\",\n\t});\n\n\t// @ts-expect-error - global variable definition\n\tglobalThis.localStorage = {\n\t\tgetItem: () => {\n\t\t\tthrow new DOMException(\"The operation is insecure.\", \"SecurityError\");\n\t\t},\n\t\tsetItem: () => {\n\t\t\tthrow new DOMException(\"The operation is insecure.\", \"SecurityError\");\n\t\t},\n\t};\n\tglobalThis.window = {\n\t\tlocation: {\n\t\t\thref: \"https://example.com/page\",\n\t\t\treload: vi.fn(),\n\t\t},\n\t} as any;\n\n\truntime.setLocale(\"de\");\n\n\texpect(globalThis.window.location.reload).toBeCalled();\n});\n"]}
@@ -8,6 +8,8 @@ export type Runtime = {
8
8
  routeStrategies: typeof import("./variables.js").routeStrategies;
9
9
  cookieName: typeof import("./variables.js").cookieName;
10
10
  cookieMaxAge: typeof import("./variables.js").cookieMaxAge;
11
+ cookieSameSite: typeof import("./variables.js").cookieSameSite;
12
+ cookieSecure: typeof import("./variables.js").cookieSecure;
11
13
  urlPatterns: typeof import("./variables.js").urlPatterns;
12
14
  trailingSlash: typeof import("./variables.js").trailingSlash;
13
15
  disableAsyncLocalStorage: typeof import("./variables.js").disableAsyncLocalStorage;
@@ -1 +1 @@
1
- {"version":3,"file":"type.js","sourceRoot":"","sources":["../../../src/compiler/runtime/type.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * The Paraglide runtime API.\n */\nexport type Runtime = {\n\tbaseLocale: typeof import(\"./variables.js\").baseLocale;\n\tlocales: typeof import(\"./variables.js\").locales;\n\tstrategy: typeof import(\"./variables.js\").strategy;\n\trouteStrategies: typeof import(\"./variables.js\").routeStrategies;\n\tcookieName: typeof import(\"./variables.js\").cookieName;\n\tcookieMaxAge: typeof import(\"./variables.js\").cookieMaxAge;\n\turlPatterns: typeof import(\"./variables.js\").urlPatterns;\n\ttrailingSlash: typeof import(\"./variables.js\").trailingSlash;\n\tdisableAsyncLocalStorage: typeof import(\"./variables.js\").disableAsyncLocalStorage;\n\tserverAsyncLocalStorage: typeof import(\"./variables.js\").serverAsyncLocalStorage;\n\tgetServerAsyncLocalStorage: typeof import(\"./variables.js\").getServerAsyncLocalStorage;\n\texperimentalMiddlewareLocaleSplitting: typeof import(\"./variables.js\").experimentalMiddlewareLocaleSplitting;\n\tisServer: typeof import(\"./variables.js\").isServer;\n\texperimentalStaticLocale: typeof import(\"./variables.js\").experimentalStaticLocale;\n\tgetLocale: typeof import(\"./get-locale.js\").getLocale;\n\tgetTextDirection: typeof import(\"./get-text-direction.js\").getTextDirection;\n\tsetLocale: typeof import(\"./set-locale.js\").setLocale;\n\tgetUrlOrigin: typeof import(\"./get-url-origin.js\").getUrlOrigin;\n\toverwriteGetLocale: typeof import(\"./get-locale.js\").overwriteGetLocale;\n\toverwriteSetLocale: typeof import(\"./set-locale.js\").overwriteSetLocale;\n\toverwriteGetUrlOrigin: typeof import(\"./get-url-origin.js\").overwriteGetUrlOrigin;\n\toverwriteServerAsyncLocalStorage: typeof import(\"./variables.js\").overwriteServerAsyncLocalStorage;\n\ttoLocale: typeof import(\"./check-locale.js\").toLocale;\n\tassertIsLocale: typeof import(\"./check-locale.js\").assertIsLocale;\n\tisLocale: typeof import(\"./check-locale.js\").isLocale;\n\tlocalizeHref: typeof import(\"./localize-href.js\").localizeHref;\n\tdeLocalizeHref: typeof import(\"./localize-href.js\").deLocalizeHref;\n\tlocalizeUrl: typeof import(\"./localize-url.js\").localizeUrl;\n\tdeLocalizeUrl: typeof import(\"./localize-url.js\").deLocalizeUrl;\n\tshouldRedirect: typeof import(\"./should-redirect.js\").shouldRedirect;\n\textractLocaleFromUrl: typeof import(\"./extract-locale-from-url.js\").extractLocaleFromUrl;\n\textractLocaleFromRequest: typeof import(\"./extract-locale-from-request.js\").extractLocaleFromRequest;\n\textractLocaleFromRequestAsync: typeof import(\"./extract-locale-from-request-async.js\").extractLocaleFromRequestAsync;\n\textractLocaleFromCookie: typeof import(\"./extract-locale-from-cookie.js\").extractLocaleFromCookie;\n\textractLocaleFromHeader: typeof import(\"./extract-locale-from-header.js\").extractLocaleFromHeader;\n\textractLocaleFromNavigator: typeof import(\"./extract-locale-from-navigator.js\").extractLocaleFromNavigator;\n\tgenerateStaticLocalizedUrls: typeof import(\"./generate-static-localized-urls.js\").generateStaticLocalizedUrls;\n\ttrackMessageCall: typeof import(\"./track-message-call.js\").trackMessageCall;\n\tgetStrategyForUrl: typeof import(\"./route-strategy.js\").getStrategyForUrl;\n\tisExcludedByRouteStrategy: typeof import(\"./route-strategy.js\").isExcludedByRouteStrategy;\n\tdefineCustomServerStrategy: typeof import(\"./strategy.js\").defineCustomServerStrategy;\n\tdefineCustomClientStrategy: typeof import(\"./strategy.js\").defineCustomClientStrategy;\n};\n"]}
1
+ {"version":3,"file":"type.js","sourceRoot":"","sources":["../../../src/compiler/runtime/type.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * The Paraglide runtime API.\n */\nexport type Runtime = {\n\tbaseLocale: typeof import(\"./variables.js\").baseLocale;\n\tlocales: typeof import(\"./variables.js\").locales;\n\tstrategy: typeof import(\"./variables.js\").strategy;\n\trouteStrategies: typeof import(\"./variables.js\").routeStrategies;\n\tcookieName: typeof import(\"./variables.js\").cookieName;\n\tcookieMaxAge: typeof import(\"./variables.js\").cookieMaxAge;\n\tcookieSameSite: typeof import(\"./variables.js\").cookieSameSite;\n\tcookieSecure: typeof import(\"./variables.js\").cookieSecure;\n\turlPatterns: typeof import(\"./variables.js\").urlPatterns;\n\ttrailingSlash: typeof import(\"./variables.js\").trailingSlash;\n\tdisableAsyncLocalStorage: typeof import(\"./variables.js\").disableAsyncLocalStorage;\n\tserverAsyncLocalStorage: typeof import(\"./variables.js\").serverAsyncLocalStorage;\n\tgetServerAsyncLocalStorage: typeof import(\"./variables.js\").getServerAsyncLocalStorage;\n\texperimentalMiddlewareLocaleSplitting: typeof import(\"./variables.js\").experimentalMiddlewareLocaleSplitting;\n\tisServer: typeof import(\"./variables.js\").isServer;\n\texperimentalStaticLocale: typeof import(\"./variables.js\").experimentalStaticLocale;\n\tgetLocale: typeof import(\"./get-locale.js\").getLocale;\n\tgetTextDirection: typeof import(\"./get-text-direction.js\").getTextDirection;\n\tsetLocale: typeof import(\"./set-locale.js\").setLocale;\n\tgetUrlOrigin: typeof import(\"./get-url-origin.js\").getUrlOrigin;\n\toverwriteGetLocale: typeof import(\"./get-locale.js\").overwriteGetLocale;\n\toverwriteSetLocale: typeof import(\"./set-locale.js\").overwriteSetLocale;\n\toverwriteGetUrlOrigin: typeof import(\"./get-url-origin.js\").overwriteGetUrlOrigin;\n\toverwriteServerAsyncLocalStorage: typeof import(\"./variables.js\").overwriteServerAsyncLocalStorage;\n\ttoLocale: typeof import(\"./check-locale.js\").toLocale;\n\tassertIsLocale: typeof import(\"./check-locale.js\").assertIsLocale;\n\tisLocale: typeof import(\"./check-locale.js\").isLocale;\n\tlocalizeHref: typeof import(\"./localize-href.js\").localizeHref;\n\tdeLocalizeHref: typeof import(\"./localize-href.js\").deLocalizeHref;\n\tlocalizeUrl: typeof import(\"./localize-url.js\").localizeUrl;\n\tdeLocalizeUrl: typeof import(\"./localize-url.js\").deLocalizeUrl;\n\tshouldRedirect: typeof import(\"./should-redirect.js\").shouldRedirect;\n\textractLocaleFromUrl: typeof import(\"./extract-locale-from-url.js\").extractLocaleFromUrl;\n\textractLocaleFromRequest: typeof import(\"./extract-locale-from-request.js\").extractLocaleFromRequest;\n\textractLocaleFromRequestAsync: typeof import(\"./extract-locale-from-request-async.js\").extractLocaleFromRequestAsync;\n\textractLocaleFromCookie: typeof import(\"./extract-locale-from-cookie.js\").extractLocaleFromCookie;\n\textractLocaleFromHeader: typeof import(\"./extract-locale-from-header.js\").extractLocaleFromHeader;\n\textractLocaleFromNavigator: typeof import(\"./extract-locale-from-navigator.js\").extractLocaleFromNavigator;\n\tgenerateStaticLocalizedUrls: typeof import(\"./generate-static-localized-urls.js\").generateStaticLocalizedUrls;\n\ttrackMessageCall: typeof import(\"./track-message-call.js\").trackMessageCall;\n\tgetStrategyForUrl: typeof import(\"./route-strategy.js\").getStrategyForUrl;\n\tisExcludedByRouteStrategy: typeof import(\"./route-strategy.js\").isExcludedByRouteStrategy;\n\tdefineCustomServerStrategy: typeof import(\"./strategy.js\").defineCustomServerStrategy;\n\tdefineCustomClientStrategy: typeof import(\"./strategy.js\").defineCustomClientStrategy;\n};\n"]}
@@ -37,6 +37,40 @@ test("createRuntimeFile throws if urlPatterns contains an unknown locale", () =>
37
37
  },
38
38
  })).toThrow('Invalid locale "fr" in urlPatterns. It must be one of the locales defined in the "locales" array.');
39
39
  });
40
+ test("createRuntimeFile throws if cookieSameSite is 'none' without cookieSecure", () => {
41
+ const create = (cookieSecure) => createRuntimeFile({
42
+ baseLocale: "en",
43
+ locales: ["en", "de"],
44
+ compilerOptions: {
45
+ ...defaultCompilerOptions,
46
+ cookieSameSite: "none",
47
+ cookieSecure,
48
+ },
49
+ });
50
+ expect(() => create()).toThrow('cookieSameSite "none" requires cookieSecure to be true or "auto". Browsers reject SameSite=None cookies without the Secure attribute.');
51
+ expect(() => create(false)).toThrow();
52
+ expect(() => create(true)).not.toThrow();
53
+ expect(() => create("auto")).not.toThrow();
54
+ });
55
+ test("runtime with cookie attributes passes checkJs", async () => {
56
+ const project = await typescriptProject({
57
+ useInMemoryFileSystem: true,
58
+ compilerOptions: superStrictRuleOutAnyErrorTsSettings,
59
+ });
60
+ project.createSourceFile("./runtime.js", createRuntimeFile({
61
+ baseLocale: "en",
62
+ locales: ["en", "de"],
63
+ compilerOptions: {
64
+ ...defaultCompilerOptions,
65
+ cookieSameSite: "lax",
66
+ cookieSecure: "auto",
67
+ },
68
+ }));
69
+ const diagnostics = ts
70
+ .getPreEmitDiagnostics(project.createProgram())
71
+ .map((d) => ts.flattenDiagnosticMessageText(d.messageText, "\n"));
72
+ expect(diagnostics).toEqual([]);
73
+ });
40
74
  test("cookie cache clearer remains internal in the generated runtime", () => {
41
75
  const jsdocRuntime = createRuntimeFile({
42
76
  baseLocale: "en",
@@ -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,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;IACC,MAAM,EAAE,MAAM;IACd,WAAW,EAAE,IAAI;IACjB,OAAO,EAAE,IAAI;IACb,OAAO,EAAE,IAAI;IACb,aAAa,EAAE,IAAI;IACnB,cAAc,EAAE,IAAI;IACpB,kBAAkB,EAAE,IAAI;IACxB,iBAAiB,EAAE,IAA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;;;;;;;;;;;;;;;;;;;;;;;KAuCG,CACH,CAAC;IAEF,MAAM,OAAO,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IACxC,MAAM,WAAW,GAAG,EAAE;SACpB,qBAAqB,CAAC,OAAO,CAAC;QAC/B,sIAAsI;SACrI,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC;SAC9B,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC,CAAC;IACrE,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;QACtC,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,WAAW,EAAE,UAAU,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAClE,CAAC;IACD,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AACvC,CAAC,CAAC,CAAC","sourcesContent":["import { expect, test } from \"vitest\";\nimport {\n\tcreateProject 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(\"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;IACC,MAAM,EAAE,MAAM;IACd,WAAW,EAAE,IAAI;IACjB,OAAO,EAAE,IAAI;IACb,OAAO,EAAE,IAAI;IACb,aAAa,EAAE,IAAI;IACnB,cAAc,EAAE,IAAI;IACpB,kBAAkB,EAAE,IAAI;IACxB,iBAAiB,EAAE,IAAI;IACvB,cAAc,EAAE,IAAI;IACpB,wBAAwB,EAAE,IAAI;IAC9B,kCAAkC,EAAE,IAAI;IACxC,MAA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QACzC,CAAC;IACF,CAAC;IAED,OAAO,CAAC,gBAAgB,CACvB,WAAW,EACX;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAuCG,CACH,CAAC;IAEF,MAAM,OAAO,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IACxC,MAAM,WAAW,GAAG,EAAE;SACpB,qBAAqB,CAAC,OAAO,CAAC;QAC/B,sIAAsI;SACrI,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC;SAC9B,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC,CAAC;IACrE,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;QACtC,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,WAAW,EAAE,UAAU,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAClE,CAAC;IACD,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AACvC,CAAC,CAAC,CAAC","sourcesContent":["import { expect, test } from \"vitest\";\nimport {\n\tcreateProject 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"]}
@@ -22,6 +22,8 @@ export declare const cookieName: string;
22
22
  export declare const cookieMaxAge: number;
23
23
  /** @type {string} */
24
24
  export declare const cookieDomain: string;
25
+ export declare const cookieSameSite: "lax" | "strict" | "none" | undefined;
26
+ export declare const cookieSecure: boolean | "auto";
25
27
  /** @type {string} */
26
28
  export declare const localStorageKey: string;
27
29
  /**
@@ -22,6 +22,13 @@ export const cookieName = "<cookie-name>";
22
22
  export const cookieMaxAge = 60 * 60 * 24 * 400;
23
23
  /** @type {string} */
24
24
  export const cookieDomain = "<cookie-domain>";
25
+ // Casts instead of `@type` tags: with a tag, TS narrows `cookieSecure` to its
26
+ // initializer in the bundled runtime.js and the `=== true` / `=== "auto"`
27
+ // checks in set-locale.js fail checkJs. `cookieSameSite` uses the same form
28
+ // for consistency.
29
+ export const cookieSameSite =
30
+ /** @type {"lax" | "strict" | "none" | undefined} */ (undefined);
31
+ export const cookieSecure = /** @type {boolean | "auto"} */ (false);
25
32
  /** @type {string} */
26
33
  export const localStorageKey = "PARAGLIDE_LOCALE";
27
34
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"variables.js","sourceRoot":"","sources":["../../../src/compiler/runtime/variables.js"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC;AAE/B;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,gCAAgC,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AAEvE,qBAAqB;AACrB,MAAM,CAAC,MAAM,UAAU,GAAG,eAAe,CAAC;AAE1C,qBAAqB;AACrB,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC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Content":["/**\n * The project's base locale.\n *\n * @example\n * if (locale === baseLocale) {\n * // do something\n * }\n */\nexport const baseLocale = \"en\";\n\n/**\n * The project's locales that have been specified in the settings.\n *\n * @example\n * if (locales.includes(userSelectedLocale) === false) {\n * throw new Error('Locale is not available');\n * }\n */\nexport const locales = /** @type {readonly string[]} */ ([\"en\", \"de\"]);\n\n/** @type {string} */\nexport const cookieName = \"<cookie-name>\";\n\n/** @type {number} */\nexport const cookieMaxAge = 60 * 60 * 24 * 400;\n\n/** @type {string} */\nexport const cookieDomain = \"<cookie-domain>\";\n\n/** @type {string} */\nexport const localStorageKey = \"PARAGLIDE_LOCALE\";\n\n/**\n * @type {Array<\"cookie\" | \"baseLocale\" | \"globalVariable\" | \"url\" | \"preferredLanguage\" | \"localStorage\" | `custom-${string}`>}\n */\nexport const strategy = [\"globalVariable\"];\n\n/**\n * Route-level strategy overrides.\n *\n * `match` uses URLPattern syntax.\n *\n * @type {Array<{\n * match: string;\n * strategy?: Array<\"cookie\" | \"baseLocale\" | \"globalVariable\" | \"url\" | \"preferredLanguage\" | \"localStorage\" | `custom-${string}`>;\n * exclude?: boolean;\n * }>}\n */\nexport const routeStrategies = [];\n\n/**\n * The used URL patterns.\n *\n * @type {Array<{ pattern: string, localized: Array<[Locale, string]> }>}\n */\nexport const urlPatterns = [];\n\n/**\n * Controls trailing slash canonicalization for localized URLs.\n *\n * @type {\"always\" | \"never\" | undefined}\n */\nexport const trailingSlash = undefined;\n\n/**\n * @typedef {{\n * \t\tgetStore(): {\n * \t\tlocale?: Locale,\n * \t\t\torigin?: string,\n * \t\t\tmessageCalls?: Set<string>\n * \t} | undefined,\n * \t\trun: (store: { locale?: Locale, origin?: string, messageCalls?: Set<string>},\n * cb: any) => any\n * }} ParaglideAsyncLocalStorage\n */\n\n/**\n * Server side async local storage that is set by `serverMiddleware()`.\n *\n * The variable is used to retrieve the locale and origin in a server-side\n * rendering context without effecting other requests.\n *\n * @type {ParaglideAsyncLocalStorage | undefined}\n */\nexport let serverAsyncLocalStorage = undefined;\n\n/**\n * Returns the current server-side async local storage instance.\n *\n * Accessing the mutable value through a function keeps it observable when\n * module interceptors wrap exported bindings and snapshot their initial value.\n *\n * @returns {ParaglideAsyncLocalStorage | undefined}\n */\nexport function getServerAsyncLocalStorage() {\n\treturn serverAsyncLocalStorage;\n}\n\nexport const disableAsyncLocalStorage = false;\n\nexport const experimentalMiddlewareLocaleSplitting = false;\n\nexport const isServer = typeof window === \"undefined\";\n\n/** @type {Locale | undefined} */\nexport const experimentalStaticLocale = undefined;\n\n/**\n * Sets the server side async local storage.\n *\n * The function is needed because the `runtime.js` file\n * must define the `serverAsyncLocalStorage` variable to\n * avoid a circular import between `runtime.js` and\n * `server.js` files.\n *\n * @param {ParaglideAsyncLocalStorage | undefined} value\n */\nexport function overwriteServerAsyncLocalStorage(value) {\n\tserverAsyncLocalStorage = value;\n}\n\nexport const TREE_SHAKE_COOKIE_STRATEGY_USED = false;\n\nexport const TREE_SHAKE_URL_STRATEGY_USED = false;\n\nexport const TREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED = false;\n\nexport const TREE_SHAKE_PREFERRED_LANGUAGE_STRATEGY_USED = false;\n\nexport const TREE_SHAKE_DEFAULT_URL_PATTERN_USED = false;\n\nexport const TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED = false;\n"]}
1
+ {"version":3,"file":"variables.js","sourceRoot":"","sources":["../../../src/compiler/runtime/variables.js"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC;AAE/B;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,gCAAgC,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AAEvE,qBAAqB;AACrB,MAAM,CAAC,MAAM,UAAU,GAAG,eAAe,CAAC;AAE1C,qBAAqB;AACrB,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,GAAG,EAAE,GAA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,4BAA4B,GAAG,KAAK,CAAC;AAElD,MAAM,CAAC,MAAM,wCAAwC,GAAG,KAAK,CAAC;AAE9D,MAAM,CAAC,MAAM,2CAA2C,GAAG,KAAK,CAAC;AAEjE,MAAM,CAAC,MAAM,mCAAmC,GAAG,KAAK,CAAC;AAEzD,MAAM,CAAC,MAAM,sCAAsC,GAAG,KAAK,CAAC","sourcesContent":["/**\n * The project's base locale.\n *\n * @example\n * if (locale === baseLocale) {\n * // do something\n * }\n */\nexport const baseLocale = \"en\";\n\n/**\n * The project's locales that have been specified in the settings.\n *\n * @example\n * if (locales.includes(userSelectedLocale) === false) {\n * throw new Error('Locale is not available');\n * }\n */\nexport const locales = /** @type {readonly string[]} */ ([\"en\", \"de\"]);\n\n/** @type {string} */\nexport const cookieName = \"<cookie-name>\";\n\n/** @type {number} */\nexport const cookieMaxAge = 60 * 60 * 24 * 400;\n\n/** @type {string} */\nexport const cookieDomain = \"<cookie-domain>\";\n\n// Casts instead of `@type` tags: with a tag, TS narrows `cookieSecure` to its\n// initializer in the bundled runtime.js and the `=== true` / `=== \"auto\"`\n// checks in set-locale.js fail checkJs. `cookieSameSite` uses the same form\n// for consistency.\nexport const cookieSameSite =\n\t/** @type {\"lax\" | \"strict\" | \"none\" | undefined} */ (undefined);\n\nexport const cookieSecure = /** @type {boolean | \"auto\"} */ (false);\n\n/** @type {string} */\nexport const localStorageKey = \"PARAGLIDE_LOCALE\";\n\n/**\n * @type {Array<\"cookie\" | \"baseLocale\" | \"globalVariable\" | \"url\" | \"preferredLanguage\" | \"localStorage\" | `custom-${string}`>}\n */\nexport const strategy = [\"globalVariable\"];\n\n/**\n * Route-level strategy overrides.\n *\n * `match` uses URLPattern syntax.\n *\n * @type {Array<{\n * match: string;\n * strategy?: Array<\"cookie\" | \"baseLocale\" | \"globalVariable\" | \"url\" | \"preferredLanguage\" | \"localStorage\" | `custom-${string}`>;\n * exclude?: boolean;\n * }>}\n */\nexport const routeStrategies = [];\n\n/**\n * The used URL patterns.\n *\n * @type {Array<{ pattern: string, localized: Array<[Locale, string]> }>}\n */\nexport const urlPatterns = [];\n\n/**\n * Controls trailing slash canonicalization for localized URLs.\n *\n * @type {\"always\" | \"never\" | undefined}\n */\nexport const trailingSlash = undefined;\n\n/**\n * @typedef {{\n * \t\tgetStore(): {\n * \t\tlocale?: Locale,\n * \t\t\torigin?: string,\n * \t\t\tmessageCalls?: Set<string>\n * \t} | undefined,\n * \t\trun: (store: { locale?: Locale, origin?: string, messageCalls?: Set<string>},\n * cb: any) => any\n * }} ParaglideAsyncLocalStorage\n */\n\n/**\n * Server side async local storage that is set by `serverMiddleware()`.\n *\n * The variable is used to retrieve the locale and origin in a server-side\n * rendering context without effecting other requests.\n *\n * @type {ParaglideAsyncLocalStorage | undefined}\n */\nexport let serverAsyncLocalStorage = undefined;\n\n/**\n * Returns the current server-side async local storage instance.\n *\n * Accessing the mutable value through a function keeps it observable when\n * module interceptors wrap exported bindings and snapshot their initial value.\n *\n * @returns {ParaglideAsyncLocalStorage | undefined}\n */\nexport function getServerAsyncLocalStorage() {\n\treturn serverAsyncLocalStorage;\n}\n\nexport const disableAsyncLocalStorage = false;\n\nexport const experimentalMiddlewareLocaleSplitting = false;\n\nexport const isServer = typeof window === \"undefined\";\n\n/** @type {Locale | undefined} */\nexport const experimentalStaticLocale = undefined;\n\n/**\n * Sets the server side async local storage.\n *\n * The function is needed because the `runtime.js` file\n * must define the `serverAsyncLocalStorage` variable to\n * avoid a circular import between `runtime.js` and\n * `server.js` files.\n *\n * @param {ParaglideAsyncLocalStorage | undefined} value\n */\nexport function overwriteServerAsyncLocalStorage(value) {\n\tserverAsyncLocalStorage = value;\n}\n\nexport const TREE_SHAKE_COOKIE_STRATEGY_USED = false;\n\nexport const TREE_SHAKE_URL_STRATEGY_USED = false;\n\nexport const TREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED = false;\n\nexport const TREE_SHAKE_PREFERRED_LANGUAGE_STRATEGY_USED = false;\n\nexport const TREE_SHAKE_DEFAULT_URL_PATTERN_USED = false;\n\nexport const TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED = false;\n"]}
@@ -1,5 +1,6 @@
1
1
  import fs from "node:fs";
2
2
  import { toSafeModuleId } from "../safe-module-id.js";
3
+ import { registryFunctionCode, withRegistryDependencies } from "../registry.js";
3
4
  /**
4
5
  * Returns the code for the `runtime.js` module
5
6
  */
@@ -57,6 +58,7 @@ ${injectCode("./middleware.js")}
57
58
  // corrupting the generated server file. A function's return value is
58
59
  // used literally, with no pattern expansion.
59
60
  code = code.replace("const compiledBundles = {};", () => `const compiledBundles = ${JSON.stringify(createCompiledMessagesObject(args.compiledBundles))};`);
61
+ code = code.replace("const compiledRegistry = { functions: {}, messages: {} };", () => `const compiledRegistry = ${JSON.stringify(createCompiledRegistryObject(args.compiledBundles))};`);
60
62
  }
61
63
  return code.replace(/\t/g, " ");
62
64
  }
@@ -81,6 +83,28 @@ function createCompiledMessagesObject(compiledBundles) {
81
83
  }
82
84
  return result;
83
85
  }
86
+ /**
87
+ * The registry functions each compiled message calls, and their code, for
88
+ * the messages the middleware injects into the page. Those run without
89
+ * registry.js.
90
+ */
91
+ function createCompiledRegistryObject(compiledBundles) {
92
+ const messages = {};
93
+ const used = new Set();
94
+ for (const compiledBundle of compiledBundles) {
95
+ const safeModuleId = toSafeModuleId(compiledBundle.bundle.node.id);
96
+ for (const [locale, compiledMessage] of Object.entries(compiledBundle.messages)) {
97
+ const names = withRegistryDependencies(compiledMessage.registryFunctions);
98
+ if (names.length === 0)
99
+ continue;
100
+ messages[safeModuleId] ??= {};
101
+ messages[safeModuleId][locale] = names;
102
+ for (const name of names)
103
+ used.add(name);
104
+ }
105
+ }
106
+ return { functions: registryFunctionCode(used), messages };
107
+ }
84
108
  /**
85
109
  * Load a file from the current directory.
86
110
  *
@@ -1 +1 @@
1
- {"version":3,"file":"create-server-file.js","sourceRoot":"","sources":["../../../src/compiler/server/create-server-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAA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C;YACxC,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC;QAC3B,CAAC;QACD,KAAK,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,IAAI,MAAM,CAAC,OAAO,CACrD,cAAc,CAAC,QAAQ,CACvB,EAAE,CAAC;YACH,MAAM,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,GAAG,eAAe,CAAC,IAAI;iBACjD,OAAO,CAAC,gBAAgB,YAAY,KAAK,EAAE,EAAE,CAAC;iBAC9C,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACrB,CAAC;IACF,CAAC;IACD,OAAO,MAAM,CAAC;AACf,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS,UAAU,CAAC,IAAY;IAC/B,MAAM,IAAI,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,GAAG,CAAC,IAAI,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC;IACtE,oDAAoD;IACpD,MAAM,WAAW,GAAG,mDAAmD,CAAC;IACxE,MAAM,cAAc,GAAG,8BAA8B,CAAC;IACtD,MAAM,mBAAmB,GAAG,iCAAiC,CAAC;IAC9D,OAAO,IAAI;SACT,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC;SACxB,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC;SAC3B,OAAO,CAAC,mBAAmB,EAAE,EAAE,CAAC;SAChC,IAAI,EAAE,CAAC;AACV,CAAC","sourcesContent":["import fs from \"node:fs\";\nimport type { CompiledBundleWithMessages } from \"../compile-bundle.js\";\nimport type { CompilerOptions } from \"../compiler-options.js\";\nimport { toSafeModuleId } from \"../safe-module-id.js\";\nimport type { Locale } from \"./runtime.d.ts\";\n\n/**\n * Returns the code for the `runtime.js` module\n */\nexport function createServerFile(args: {\n\tcompiledBundles: CompiledBundleWithMessages[];\n\tcompilerOptions: {\n\t\texperimentalMiddlewareLocaleSplitting: NonNullable<\n\t\t\tCompilerOptions[\"experimentalMiddlewareLocaleSplitting\"]\n\t\t>;\n\t\tdisableAsyncLocalStorage: NonNullable<\n\t\t\tCompilerOptions[\"disableAsyncLocalStorage\"]\n\t\t>;\n\t};\n}): string {\n\tlet code = `\nimport * as runtime from \"./runtime.js\";\n\n${injectCode(\"./middleware.js\")}\n`;\n\n\tconst asyncLocalStorageMarker = \"// %async-local-storage\";\n\tconst markerIndex = code.indexOf(asyncLocalStorageMarker);\n\tif (markerIndex === -1) {\n\t\tthrow new Error(\n\t\t\t\"Expected a single %async-local-storage marker in server middleware.\"\n\t\t);\n\t}\n\n\tconst lineStart = code.lastIndexOf(\"\\n\", markerIndex) + 1;\n\tconst indent = code.slice(lineStart, markerIndex).replace(/\\t/g, \" \");\n\tconst innerIndent = `${indent} `;\n\tconst asyncLocalStorageBlock = args.compilerOptions.disableAsyncLocalStorage\n\t\t? [\n\t\t\t\t`${indent}requestAsyncLocalStorage = runtime.getServerAsyncLocalStorage();`,\n\t\t\t\t`${indent}if (!requestAsyncLocalStorage) {`,\n\t\t\t\t`${innerIndent}requestAsyncLocalStorage = createMockAsyncLocalStorage();`,\n\t\t\t\t`${innerIndent}runtime.overwriteServerAsyncLocalStorage(requestAsyncLocalStorage);`,\n\t\t\t\t`${indent}}`,\n\t\t\t]\n\t\t: [\n\t\t\t\t`${indent}requestAsyncLocalStorage = runtime.getServerAsyncLocalStorage();`,\n\t\t\t\t`${indent}if (!runtime.disableAsyncLocalStorage && !requestAsyncLocalStorage) {`,\n\t\t\t\t`${innerIndent}const { AsyncLocalStorage } = await import(\"async_hooks\");`,\n\t\t\t\t`${innerIndent}requestAsyncLocalStorage = runtime.getServerAsyncLocalStorage();`,\n\t\t\t\t`${innerIndent}if (!requestAsyncLocalStorage) {`,\n\t\t\t\t`${innerIndent} requestAsyncLocalStorage = new AsyncLocalStorage();`,\n\t\t\t\t`${innerIndent} runtime.overwriteServerAsyncLocalStorage(requestAsyncLocalStorage);`,\n\t\t\t\t`${innerIndent}}`,\n\t\t\t\t`${indent}}`,\n\t\t\t\t`${indent}if (!requestAsyncLocalStorage) {`,\n\t\t\t\t`${innerIndent}requestAsyncLocalStorage = createMockAsyncLocalStorage();`,\n\t\t\t\t`${innerIndent}runtime.overwriteServerAsyncLocalStorage(requestAsyncLocalStorage);`,\n\t\t\t\t`${indent}}`,\n\t\t\t];\n\n\tconst lineEnd = code.indexOf(\"\\n\", markerIndex);\n\tconst endOfMarkerLine = lineEnd === -1 ? code.length : lineEnd + 1;\n\n\tcode =\n\t\tcode.slice(0, lineStart) +\n\t\t`${asyncLocalStorageBlock.join(\"\\n\")}\\n` +\n\t\tcode.slice(endOfMarkerLine);\n\n\tif (args.compilerOptions.experimentalMiddlewareLocaleSplitting) {\n\t\t// Use a replacer function, not a replacement string. `String.replace()`\n\t\t// treats a string replacement as a pattern where `$&`, `` $` ``, `$'`,\n\t\t// `$$`, and `$<name>` have special meaning. A translated message value\n\t\t// that contains a literal `$` (a price, a currency symbol) can produce\n\t\t// one of these sequences inside the JSON payload, which `String.replace`\n\t\t// then expands - e.g. `` $` `` is replaced with \"everything before the\n\t\t// match\", splicing the file's own header into the string being built and\n\t\t// corrupting the generated server file. A function's return value is\n\t\t// used literally, with no pattern expansion.\n\t\tcode = code.replace(\n\t\t\t\"const compiledBundles = {};\",\n\t\t\t() =>\n\t\t\t\t`const compiledBundles = ${JSON.stringify(createCompiledMessagesObject(args.compiledBundles))};`\n\t\t);\n\t}\n\n\treturn code.replace(/\\t/g, \" \");\n}\n\nfunction createCompiledMessagesObject(\n\tcompiledBundles: CompiledBundleWithMessages[]\n): Record<string, Record<Locale, string>> {\n\tconst result = {} as Record<string, Record<Locale, string>>;\n\n\tfor (const compiledBundle of compiledBundles) {\n\t\tconst bundleId = compiledBundle.bundle.node.id;\n\t\tconst safeModuleId = toSafeModuleId(bundleId);\n\t\t// Key by the safe module id, not the raw bundle id: trackMessageCall()\n\t\t// records calls under safeModuleId, the client reads\n\t\t// globalThis.__paraglide.ssr[safeModuleId], and middleware.js looks up\n\t\t// compiledBundles[id] with that same safe id. Keying by the raw\n\t\t// bundleId here made every split-mode lookup miss.\n\t\tif (result[safeModuleId] === undefined) {\n\t\t\tresult[safeModuleId] = {};\n\t\t}\n\t\tfor (const [locale, compiledMessage] of Object.entries(\n\t\t\tcompiledBundle.messages\n\t\t)) {\n\t\t\tresult[safeModuleId][locale] = compiledMessage.code\n\t\t\t\t.replace(`export const ${safeModuleId} = `, \"\")\n\t\t\t\t.replace(/;$/, \"\");\n\t\t}\n\t}\n\treturn result;\n}\n\n/**\n * Load a file from the current directory.\n *\n * Prunes the imports on top of the file as the runtime is\n * self-contained.\n *\n * @param {string} path\n * @returns {string}\n */\nfunction injectCode(path: string): string {\n\tconst code = fs.readFileSync(new URL(path, import.meta.url), \"utf-8\");\n\t// Regex to match single-line and multi-line imports\n\tconst importRegex = /^\\s*import\\s+[\\s\\S]*?from\\s+['\"][^'\"]+['\"]\\s*;?/gm;\n\tconst sourceMapRegex = /\\/\\/# sourceMappingURL=.*$/gm;\n\tconst blockSourceMapRegex = /\\/\\*# sourceMappingURL=.*?\\*\\//g;\n\treturn code\n\t\t.replace(importRegex, \"\")\n\t\t.replace(sourceMapRegex, \"\")\n\t\t.replace(blockSourceMapRegex, \"\")\n\t\t.trim();\n}\n"]}
1
+ {"version":3,"file":"create-server-file.js","sourceRoot":"","sources":["../../../src/compiler/server/create-server-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AAGzB,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAEhF;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAUhC;IACA,IAAI,IAAI,GAAG;;;EAGV,UAAU,CAAC,iBAAiB,CAAC;CAC9B,CAAC;IAED,MAAM,uBAAuB,GAAG,yBAAyB,CAAC;IAC1D,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,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AY,CAAC,IAAI,GAAG,CAAC,IAAI,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC;IACtE,oDAAoD;IACpD,MAAM,WAAW,GAAG,mDAAmD,CAAC;IACxE,MAAM,cAAc,GAAG,8BAA8B,CAAC;IACtD,MAAM,mBAAmB,GAAG,iCAAiC,CAAC;IAC9D,OAAO,IAAI;SACT,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC;SACxB,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC;SAC3B,OAAO,CAAC,mBAAmB,EAAE,EAAE,CAAC;SAChC,IAAI,EAAE,CAAC;AACV,CAAC","sourcesContent":["import fs from \"node:fs\";\nimport type { CompiledBundleWithMessages } from \"../compile-bundle.js\";\nimport type { CompilerOptions } from \"../compiler-options.js\";\nimport { toSafeModuleId } from \"../safe-module-id.js\";\nimport type { Locale } from \"./runtime.d.ts\";\nimport { registryFunctionCode, withRegistryDependencies } from \"../registry.js\";\n\n/**\n * Returns the code for the `runtime.js` module\n */\nexport function createServerFile(args: {\n\tcompiledBundles: CompiledBundleWithMessages[];\n\tcompilerOptions: {\n\t\texperimentalMiddlewareLocaleSplitting: NonNullable<\n\t\t\tCompilerOptions[\"experimentalMiddlewareLocaleSplitting\"]\n\t\t>;\n\t\tdisableAsyncLocalStorage: NonNullable<\n\t\t\tCompilerOptions[\"disableAsyncLocalStorage\"]\n\t\t>;\n\t};\n}): string {\n\tlet code = `\nimport * as runtime from \"./runtime.js\";\n\n${injectCode(\"./middleware.js\")}\n`;\n\n\tconst asyncLocalStorageMarker = \"// %async-local-storage\";\n\tconst markerIndex = code.indexOf(asyncLocalStorageMarker);\n\tif (markerIndex === -1) {\n\t\tthrow new Error(\n\t\t\t\"Expected a single %async-local-storage marker in server middleware.\"\n\t\t);\n\t}\n\n\tconst lineStart = code.lastIndexOf(\"\\n\", markerIndex) + 1;\n\tconst indent = code.slice(lineStart, markerIndex).replace(/\\t/g, \" \");\n\tconst innerIndent = `${indent} `;\n\tconst asyncLocalStorageBlock = args.compilerOptions.disableAsyncLocalStorage\n\t\t? [\n\t\t\t\t`${indent}requestAsyncLocalStorage = runtime.getServerAsyncLocalStorage();`,\n\t\t\t\t`${indent}if (!requestAsyncLocalStorage) {`,\n\t\t\t\t`${innerIndent}requestAsyncLocalStorage = createMockAsyncLocalStorage();`,\n\t\t\t\t`${innerIndent}runtime.overwriteServerAsyncLocalStorage(requestAsyncLocalStorage);`,\n\t\t\t\t`${indent}}`,\n\t\t\t]\n\t\t: [\n\t\t\t\t`${indent}requestAsyncLocalStorage = runtime.getServerAsyncLocalStorage();`,\n\t\t\t\t`${indent}if (!runtime.disableAsyncLocalStorage && !requestAsyncLocalStorage) {`,\n\t\t\t\t`${innerIndent}const { AsyncLocalStorage } = await import(\"async_hooks\");`,\n\t\t\t\t`${innerIndent}requestAsyncLocalStorage = runtime.getServerAsyncLocalStorage();`,\n\t\t\t\t`${innerIndent}if (!requestAsyncLocalStorage) {`,\n\t\t\t\t`${innerIndent} requestAsyncLocalStorage = new AsyncLocalStorage();`,\n\t\t\t\t`${innerIndent} runtime.overwriteServerAsyncLocalStorage(requestAsyncLocalStorage);`,\n\t\t\t\t`${innerIndent}}`,\n\t\t\t\t`${indent}}`,\n\t\t\t\t`${indent}if (!requestAsyncLocalStorage) {`,\n\t\t\t\t`${innerIndent}requestAsyncLocalStorage = createMockAsyncLocalStorage();`,\n\t\t\t\t`${innerIndent}runtime.overwriteServerAsyncLocalStorage(requestAsyncLocalStorage);`,\n\t\t\t\t`${indent}}`,\n\t\t\t];\n\n\tconst lineEnd = code.indexOf(\"\\n\", markerIndex);\n\tconst endOfMarkerLine = lineEnd === -1 ? code.length : lineEnd + 1;\n\n\tcode =\n\t\tcode.slice(0, lineStart) +\n\t\t`${asyncLocalStorageBlock.join(\"\\n\")}\\n` +\n\t\tcode.slice(endOfMarkerLine);\n\n\tif (args.compilerOptions.experimentalMiddlewareLocaleSplitting) {\n\t\t// Use a replacer function, not a replacement string. `String.replace()`\n\t\t// treats a string replacement as a pattern where `$&`, `` $` ``, `$'`,\n\t\t// `$$`, and `$<name>` have special meaning. A translated message value\n\t\t// that contains a literal `$` (a price, a currency symbol) can produce\n\t\t// one of these sequences inside the JSON payload, which `String.replace`\n\t\t// then expands - e.g. `` $` `` is replaced with \"everything before the\n\t\t// match\", splicing the file's own header into the string being built and\n\t\t// corrupting the generated server file. A function's return value is\n\t\t// used literally, with no pattern expansion.\n\t\tcode = code.replace(\n\t\t\t\"const compiledBundles = {};\",\n\t\t\t() =>\n\t\t\t\t`const compiledBundles = ${JSON.stringify(createCompiledMessagesObject(args.compiledBundles))};`\n\t\t);\n\t\tcode = code.replace(\n\t\t\t\"const compiledRegistry = { functions: {}, messages: {} };\",\n\t\t\t() =>\n\t\t\t\t`const compiledRegistry = ${JSON.stringify(createCompiledRegistryObject(args.compiledBundles))};`\n\t\t);\n\t}\n\n\treturn code.replace(/\\t/g, \" \");\n}\n\nfunction createCompiledMessagesObject(\n\tcompiledBundles: CompiledBundleWithMessages[]\n): Record<string, Record<Locale, string>> {\n\tconst result = {} as Record<string, Record<Locale, string>>;\n\n\tfor (const compiledBundle of compiledBundles) {\n\t\tconst bundleId = compiledBundle.bundle.node.id;\n\t\tconst safeModuleId = toSafeModuleId(bundleId);\n\t\t// Key by the safe module id, not the raw bundle id: trackMessageCall()\n\t\t// records calls under safeModuleId, the client reads\n\t\t// globalThis.__paraglide.ssr[safeModuleId], and middleware.js looks up\n\t\t// compiledBundles[id] with that same safe id. Keying by the raw\n\t\t// bundleId here made every split-mode lookup miss.\n\t\tif (result[safeModuleId] === undefined) {\n\t\t\tresult[safeModuleId] = {};\n\t\t}\n\t\tfor (const [locale, compiledMessage] of Object.entries(\n\t\t\tcompiledBundle.messages\n\t\t)) {\n\t\t\tresult[safeModuleId][locale] = compiledMessage.code\n\t\t\t\t.replace(`export const ${safeModuleId} = `, \"\")\n\t\t\t\t.replace(/;$/, \"\");\n\t\t}\n\t}\n\treturn result;\n}\n\n/**\n * The registry functions each compiled message calls, and their code, for\n * the messages the middleware injects into the page. Those run without\n * registry.js.\n */\nfunction createCompiledRegistryObject(\n\tcompiledBundles: CompiledBundleWithMessages[]\n): {\n\tfunctions: Record<string, string>;\n\tmessages: Record<string, Record<string, string[]>>;\n} {\n\tconst messages: Record<string, Record<string, string[]>> = {};\n\tconst used = new Set<string>();\n\n\tfor (const compiledBundle of compiledBundles) {\n\t\tconst safeModuleId = toSafeModuleId(compiledBundle.bundle.node.id);\n\t\tfor (const [locale, compiledMessage] of Object.entries(\n\t\t\tcompiledBundle.messages\n\t\t)) {\n\t\t\tconst names = withRegistryDependencies(compiledMessage.registryFunctions);\n\t\t\tif (names.length === 0) continue;\n\t\t\tmessages[safeModuleId] ??= {};\n\t\t\tmessages[safeModuleId][locale] = names;\n\t\t\tfor (const name of names) used.add(name);\n\t\t}\n\t}\n\n\treturn { functions: registryFunctionCode(used), messages };\n}\n\n/**\n * Load a file from the current directory.\n *\n * Prunes the imports on top of the file as the runtime is\n * self-contained.\n *\n * @param {string} path\n * @returns {string}\n */\nfunction injectCode(path: string): string {\n\tconst code = fs.readFileSync(new URL(path, import.meta.url), \"utf-8\");\n\t// Regex to match single-line and multi-line imports\n\tconst importRegex = /^\\s*import\\s+[\\s\\S]*?from\\s+['\"][^'\"]+['\"]\\s*;?/gm;\n\tconst sourceMapRegex = /\\/\\/# sourceMappingURL=.*$/gm;\n\tconst blockSourceMapRegex = /\\/\\*# sourceMappingURL=.*?\\*\\//g;\n\treturn code\n\t\t.replace(importRegex, \"\")\n\t\t.replace(sourceMapRegex, \"\")\n\t\t.replace(blockSourceMapRegex, \"\")\n\t\t.trim();\n}\n"]}
@@ -71,7 +71,10 @@ test("keys compiledBundles by the safe module id, not the raw bundle id (experim
71
71
  {
72
72
  bundle: { node: { id: bundleId } },
73
73
  messages: {
74
- en: { code: `export const ${safeModuleId} = () => "hello";` },
74
+ en: {
75
+ code: `export const ${safeModuleId} = () => "hello";`,
76
+ registryFunctions: [],
77
+ },
75
78
  },
76
79
  },
77
80
  ];
@@ -99,7 +102,10 @@ test("a literal '$' in a compiled message does not corrupt the generated file (e
99
102
  {
100
103
  bundle: { node: { id: "price_symbol" } },
101
104
  messages: {
102
- en: { code: "export const price_symbol = () => `$`;" },
105
+ en: {
106
+ code: "export const price_symbol = () => `$`;",
107
+ registryFunctions: [],
108
+ },
103
109
  },
104
110
  },
105
111
  ];