@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":"compile-bundle.test.js","sourceRoot":"","sources":["../../src/compiler/compile-bundle.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AAEhF,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,oCAAoC,EAAE,MAAM,uBAAuB,CAAC;AAE7E,IAAI,CAAC,mBAAmB,EAAE,KAAK,IAAI,EAAE;IACpC,MAAM,UAAU,GAAiB;QAChC,EAAE,EAAE,kBAAkB;QACtB,YAAY,EAAE,CAAC,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;QACvD,QAAQ,EAAE;YACT;gBACC,EAAE,EAAE,YAAY;gBAChB,QAA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iB,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;;EAEpD,MAAM,CAAC,MAAM,CAAC,IAAI;CACnB,CAAC;IAED,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,MAAM,CAC9B,8BAA8B,GAAG,IAAI,CAAC,YAAY,CAAC,CACnD,CAAC;IAEF,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC7C,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;QAC1C,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE;QACrE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE;QAC5B,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE;QACjC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE;KACnE,CAAC,CAAC;IACH,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,CACnC,+GAA+G,CAC/G,CAAC;AACH,CAAC,CAAC,CAAC","sourcesContent":["import { test, expect } from \"vitest\";\nimport { compileBundle, toBundleInputTypeAliasName } from \"./compile-bundle.js\";\nimport type { BundleNested, ProjectSettings } from \"@inlang/sdk\";\nimport { toSafeModuleId } from \"./safe-module-id.js\";\nimport { perLocaleBuildStaticLocaleExpression } from \"./per-locale-build.js\";\n\ntest(\"compiles to jsdoc\", async () => {\n\tconst mockBundle: BundleNested = {\n\t\tid: \"blue_moon_bottle\",\n\t\tdeclarations: [{ type: \"input-variable\", name: \"age\" }],\n\t\tmessages: [\n\t\t\t{\n\t\t\t\tid: \"message-id\",\n\t\t\t\tbundleId: \"blue_moon_bottle\",\n\t\t\t\tlocale: \"en\",\n\t\t\t\tselectors: [],\n\t\t\t\tvariants: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"1\",\n\t\t\t\t\t\tmessageId: \"message-id\",\n\t\t\t\t\t\tmatches: [],\n\t\t\t\t\t\tpattern: [\n\t\t\t\t\t\t\t{ type: \"text\", value: \"Hello\" },\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"expression\",\n\t\t\t\t\t\t\t\targ: { type: \"variable-reference\", name: \"age\" },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t};\n\n\tconst result = compileBundle({\n\t\tfallbackMap: {\n\t\t\ten: \"en\",\n\t\t\t\"en-US\": \"en\",\n\t\t},\n\t\tbundle: mockBundle,\n\t\tmessageReferenceExpression: (locale) =>\n\t\t\t`${toSafeModuleId(locale)}.blue_moon_bottle`,\n\t\tsettings: {\n\t\t\tlocales: [\"en\", \"en-US\"],\n\t\t} as ProjectSettings,\n\t});\n\n\texpect(result.bundle.code).toMatchInlineSnapshot(\n\t\t`\n\t\t\"/**\n\t\t* | output |\n\t\t* | --- |\n\t\t* | \"Hello{age}\" |\n\t\t*\n\t\t* @param {Blue_Moon_BottleInputs} inputs\n\t\t* @param {{ locale?: \"en\" | \"en-US\" }} options\n\t\t* @returns {LocalizedString}\n\t\t*/\n\t\texport const blue_moon_bottle = /** @type {((inputs: Blue_Moon_BottleInputs, options?: { locale?: \"en\" | \"en-US\" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Blue_Moon_BottleInputs, { locale?: \"en\" | \"en-US\" }, {}>} */ ((inputs, options = {}) => {\n\t\t\tconst locale = experimentalStaticLocale ?? options.locale ?? getLocale()\n\t\t\tif (locale === \"en\") return en.blue_moon_bottle(inputs)\n\t\t\treturn en_us2.blue_moon_bottle(inputs)\n\t\t});\"\n\t`\n\t);\n});\n\ntest(\"uses the base locale as the exhaustive locale branch\", () => {\n\tconst mockBundle: BundleNested = {\n\t\tid: \"greeting\",\n\t\tdeclarations: [],\n\t\tmessages: [\n\t\t\t{\n\t\t\t\tid: \"message-id\",\n\t\t\t\tbundleId: \"greeting\",\n\t\t\t\tlocale: \"en\",\n\t\t\t\tselectors: [],\n\t\t\t\tvariants: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"variant-id\",\n\t\t\t\t\t\tmessageId: \"message-id\",\n\t\t\t\t\t\tmatches: [],\n\t\t\t\t\t\tpattern: [{ type: \"text\", value: \"Hello\" }],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t};\n\n\tconst result = compileBundle({\n\t\tfallbackMap: {\n\t\t\tfr: \"en\",\n\t\t\tde: \"en\",\n\t\t\ten: undefined,\n\t\t\tja: \"en\",\n\t\t},\n\t\tbundle: mockBundle,\n\t\tmessageReferenceExpression: (locale) => `${locale}_greeting`,\n\t\tsettings: {\n\t\t\tbaseLocale: \"en\",\n\t\t\tlocales: [\"fr\", \"de\", \"en\", \"ja\"],\n\t\t} as ProjectSettings,\n\t});\n\n\texpect(result.bundle.code).toContain(\n\t\t[\n\t\t\t'if (locale === \"fr\") return fr_greeting(inputs)',\n\t\t\t'if (locale === \"de\") return de_greeting(inputs)',\n\t\t\t'if (locale === \"ja\") return ja_greeting(inputs)',\n\t\t\t\"return en_greeting(inputs)\",\n\t\t].join(\"\\n\\t\")\n\t);\n});\n\ntest(\"emits middleware locale splitting hooks when enabled\", () => {\n\tconst mockBundle: BundleNested = {\n\t\tid: \"blue_moon_bottle\",\n\t\tdeclarations: [{ type: \"input-variable\", name: \"age\" }],\n\t\tmessages: [\n\t\t\t{\n\t\t\t\tid: \"message-id\",\n\t\t\t\tbundleId: \"blue_moon_bottle\",\n\t\t\t\tlocale: \"en\",\n\t\t\t\tselectors: [],\n\t\t\t\tvariants: [\n\t\t\t\t\t{ id: \"1\", messageId: \"message-id\", matches: [], pattern: [] },\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t};\n\n\tconst result = compileBundle({\n\t\tfallbackMap: { en: \"en\" },\n\t\tbundle: mockBundle,\n\t\tmessageReferenceExpression: (locale) =>\n\t\t\t`${toSafeModuleId(locale)}.blue_moon_bottle`,\n\t\tsettings: {\n\t\t\tlocales: [\"en\"],\n\t\t} as ProjectSettings,\n\t\texperimentalMiddlewareLocaleSplitting: true,\n\t});\n\n\texpect(result.bundle.code).toContain(\n\t\t\"if (experimentalMiddlewareLocaleSplitting && isServer === false)\"\n\t);\n\texpect(result.bundle.code).toContain(\n\t\t'trackMessageCall(\"blue_moon_bottle\", locale)'\n\t);\n\texpect(result.bundle.code).toContain(\n\t\t\"globalThis).__paraglide.ssr.blue_moon_bottle(inputs)\"\n\t);\n});\n\ntest(\"emits the per-locale build marker inside the message function\", () => {\n\tconst mockBundle: BundleNested = {\n\t\tid: \"greeting\",\n\t\tdeclarations: [],\n\t\tmessages: [\n\t\t\t{\n\t\t\t\tid: \"greeting-en\",\n\t\t\t\tbundleId: \"greeting\",\n\t\t\t\tlocale: \"en\",\n\t\t\t\tselectors: [],\n\t\t\t\tvariants: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"greeting-en-variant\",\n\t\t\t\t\t\tmessageId: \"greeting-en\",\n\t\t\t\t\t\tmatches: [],\n\t\t\t\t\t\tpattern: [{ type: \"text\", value: \"hello\" }],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"greeting-de\",\n\t\t\t\tbundleId: \"greeting\",\n\t\t\t\tlocale: \"de\",\n\t\t\t\tselectors: [],\n\t\t\t\tvariants: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"greeting-de-variant\",\n\t\t\t\t\t\tmessageId: \"greeting-de\",\n\t\t\t\t\t\tmatches: [],\n\t\t\t\t\t\tpattern: [{ type: \"text\", value: \"hallo\" }],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t};\n\tconst expression = perLocaleBuildStaticLocaleExpression;\n\tconst result = compileBundle({\n\t\tbundle: mockBundle,\n\t\tfallbackMap: { en: undefined, de: \"en\" },\n\t\tmessageReferenceExpression: (locale) => `${locale}_greeting`,\n\t\tsettings: { locales: [\"en\", \"de\"] } as ProjectSettings,\n\t\texperimentalStaticLocale: expression,\n\t});\n\n\texpect(result.bundle.code).toContain(\n\t\t`const locale = ${expression} ?? options.locale ?? getLocale()`\n\t);\n\texpect(result.bundle.code).toContain(\n\t\t`if (${expression} !== undefined && options.locale !== undefined && options.locale !== ${expression}) console.warn(`\n\t);\n\texpect(result.bundle.code).toContain(\"full document navigation\");\n});\n\ntest(\"compiles to jsdoc with missing translation\", async () => {\n\tconst mockBundle: BundleNested = {\n\t\tid: \"blue_moon_bottle\",\n\t\tdeclarations: [{ type: \"input-variable\", name: \"age\" }],\n\t\tmessages: [\n\t\t\t{\n\t\t\t\tid: \"message-id\",\n\t\t\t\tbundleId: \"blue_moon_bottle\",\n\t\t\t\tlocale: \"en\",\n\t\t\t\tselectors: [],\n\t\t\t\tvariants: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"1\",\n\t\t\t\t\t\tmessageId: \"message-id\",\n\t\t\t\t\t\tmatches: [],\n\t\t\t\t\t\tpattern: [\n\t\t\t\t\t\t\t{ type: \"text\", value: \"Hello\" },\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"expression\",\n\t\t\t\t\t\t\t\targ: { type: \"variable-reference\", name: \"age\" },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t};\n\n\tconst result = compileBundle({\n\t\tfallbackMap: {\n\t\t\ten: \"en\",\n\t\t\t\"en-US\": \"en\",\n\t\t},\n\t\tbundle: mockBundle,\n\t\tmessageReferenceExpression: (locale) =>\n\t\t\t`${toSafeModuleId(locale)}.blue_moon_bottle`,\n\t\tsettings: {\n\t\t\tlocales: [\"en\", \"en-US\", \"fr\"],\n\t\t} as ProjectSettings,\n\t});\n\n\texpect(result.bundle.code).toMatchInlineSnapshot(\n\t\t`\n\t\t\"/**\n\t\t* | output |\n\t\t* | --- |\n\t\t* | \"Hello{age}\" |\n\t\t*\n\t\t* @param {Blue_Moon_BottleInputs} inputs\n\t\t* @param {{ locale?: \"en\" | \"en-US\" }} options\n\t\t* @returns {LocalizedString}\n\t\t*/\n\t\texport const blue_moon_bottle = /** @type {((inputs: Blue_Moon_BottleInputs, options?: { locale?: \"en\" | \"en-US\" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Blue_Moon_BottleInputs, { locale?: \"en\" | \"en-US\" }, {}>} */ ((inputs, options = {}) => {\n\t\t\tconst locale = experimentalStaticLocale ?? options.locale ?? getLocale()\n\t\t\tif (locale === \"en\") return en.blue_moon_bottle(inputs)\n\t\t\tif (locale === \"en-US\") return en_us2.blue_moon_bottle(inputs)\n\t\t\treturn /** @type {LocalizedString} */ (\"blue_moon_bottle\")\n\t\t});\"\n\t`\n\t);\n});\n\n// https://github.com/opral/inlang-paraglide-js/issues/285\ntest(\"compiles bundles with arbitrary module identifiers\", async () => {\n\tconst mockBundle: BundleNested = {\n\t\tid: \"$p@44🍌\",\n\t\tdeclarations: [{ type: \"input-variable\", name: \"age\" }],\n\t\tmessages: [\n\t\t\t{\n\t\t\t\tid: \"message-id\",\n\t\t\t\tbundleId: \"$p@44🍌\",\n\t\t\t\tlocale: \"en\",\n\t\t\t\tselectors: [],\n\t\t\t\tvariants: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"1\",\n\t\t\t\t\t\tmessageId: \"message-id\",\n\t\t\t\t\t\tmatches: [],\n\t\t\t\t\t\tpattern: [\n\t\t\t\t\t\t\t{ type: \"text\", value: \"Hello\" },\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"expression\",\n\t\t\t\t\t\t\t\targ: { type: \"variable-reference\", name: \"age\" },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t};\n\n\tconst result = compileBundle({\n\t\tfallbackMap: {},\n\t\tbundle: mockBundle,\n\t\tmessageReferenceExpression: (locale) =>\n\t\t\t`${toSafeModuleId(locale)}.blue_moon_bottle`,\n\t});\n\n\texpect(result.bundle.code).includes(\n\t\t`export { ${toSafeModuleId(\"$p@44🍌\")} as \"$p@44🍌\" }`\n\t);\n});\n\ntest(\"keeps generated input typedef names collision-free for repeated underscores\", () => {\n\texpect(toBundleInputTypeAliasName(\"foo_bar\")).toBe(\"Foo_BarInputs\");\n\texpect(toBundleInputTypeAliasName(\"foo__bar\")).toBe(\"Foo__BarInputs\");\n\texpect(toBundleInputTypeAliasName(\"foo_bar\")).not.toBe(\n\t\ttoBundleInputTypeAliasName(\"foo__bar\")\n\t);\n});\n\ntest(\"handles message pattern with duplicate variable references\", async () => {\n\tconst mockBundle: BundleNested = {\n\t\tid: \"date_last_days\",\n\t\tdeclarations: [\n\t\t\t{ type: \"input-variable\", name: \"days\" },\n\t\t\t{ type: \"input-variable\", name: \"days\" },\n\t\t],\n\t\tmessages: [\n\t\t\t{\n\t\t\t\tid: \"date_last_days\",\n\t\t\t\tbundleId: \"date_last_days\",\n\t\t\t\tlocale: \"en\",\n\t\t\t\tselectors: [],\n\t\t\t\tvariants: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"1\",\n\t\t\t\t\t\tmessageId: \"date_last_days\",\n\t\t\t\t\t\tmatches: [],\n\t\t\t\t\t\tpattern: [\n\t\t\t\t\t\t\t{ type: \"text\", value: \"Last \" },\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"expression\",\n\t\t\t\t\t\t\t\targ: { type: \"variable-reference\", name: \"days\" },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{ type: \"text\", value: \" days, showing \" },\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"expression\",\n\t\t\t\t\t\t\t\targ: { type: \"variable-reference\", name: \"days\" },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{ type: \"text\", value: \" items\" },\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t};\n\n\tconst result = compileBundle({\n\t\tfallbackMap: {\n\t\t\ten: \"en\",\n\t\t},\n\t\tbundle: mockBundle,\n\t\tmessageReferenceExpression: (locale) =>\n\t\t\t`${toSafeModuleId(locale)}.date_last_days`,\n\t});\n\n\t// The JSDoc should not have duplicate parameters\n\texpect(result.bundle.code).toContain(\"@param {Date_Last_DaysInputs} inputs\");\n\texpect(result.bundle.code).not.toContain(\n\t\t\"days: NonNullable<unknown>, days: NonNullable<unknown>\"\n\t);\n\n\t// Check that the pattern is compiled correctly\n\tconst enMessage = result.messages?.en;\n\texpect(enMessage).toBeDefined();\n\texpect(enMessage?.code).toContain(\n\t\t\"Last ${i?.days} days, showing ${i?.days} items\"\n\t);\n});\n\ntest(\"adds .parts() to bundle functions when markup exists\", async () => {\n\tconst mockBundle: BundleNested = {\n\t\tid: \"notice\",\n\t\tdeclarations: [{ type: \"input-variable\", name: \"count\" }],\n\t\tmessages: [\n\t\t\t{\n\t\t\t\tid: \"notice-id\",\n\t\t\t\tbundleId: \"notice\",\n\t\t\t\tlocale: \"en\",\n\t\t\t\tselectors: [],\n\t\t\t\tvariants: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"1\",\n\t\t\t\t\t\tmessageId: \"notice-id\",\n\t\t\t\t\t\tmatches: [],\n\t\t\t\t\t\tpattern: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"markup-start\",\n\t\t\t\t\t\t\t\tname: \"strong\",\n\t\t\t\t\t\t\t\toptions: [],\n\t\t\t\t\t\t\t\tattributes: [],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"expression\",\n\t\t\t\t\t\t\t\targ: { type: \"variable-reference\", name: \"count\" },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{ type: \"text\", value: \" items\" },\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"markup-end\",\n\t\t\t\t\t\t\t\tname: \"strong\",\n\t\t\t\t\t\t\t\toptions: [],\n\t\t\t\t\t\t\t\tattributes: [],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t};\n\n\tconst result = compileBundle({\n\t\tfallbackMap: {\n\t\t\ten: undefined,\n\t\t},\n\t\tbundle: mockBundle,\n\t\tmessageReferenceExpression: (locale) => `${toSafeModuleId(locale)}.notice`,\n\t\tsettings: {\n\t\t\tlocales: [\"en\"],\n\t\t} as ProjectSettings,\n\t});\n\tconst compiledEnMessage = result.messages.en;\n\tif (!compiledEnMessage) {\n\t\tthrow new Error(\"Expected compiled english message\");\n\t}\n\n\tconst moduleSource = `\nconst getLocale = () => \"en\";\nconst trackMessageCall = () => {};\nconst experimentalMiddlewareLocaleSplitting = false;\nconst isServer = true;\nconst experimentalStaticLocale = undefined;\nconst en = {\n\tnotice: ${compiledEnMessage.code.replace(/;\\s*$/, \"\")}\n};\n${result.bundle.code}\n`;\n\n\tconst { notice } = await import(\n\t\t\"data:text/javascript;base64,\" + btoa(moduleSource)\n\t);\n\n\texpect(notice({ count: 3 })).toBe(\"3 items\");\n\texpect(notice.parts({ count: 3 })).toEqual([\n\t\t{ type: \"markup-start\", name: \"strong\", options: {}, attributes: {} },\n\t\t{ type: \"text\", value: \"3\" },\n\t\t{ type: \"text\", value: \" items\" },\n\t\t{ type: \"markup-end\", name: \"strong\", options: {}, attributes: {} },\n\t]);\n\texpect(result.bundle.code).toContain(\n\t\t'MessageMetadata<NoticeInputs, { locale?: \"en\" }, { strong: { options: {}; attributes: {}; children: true } }>'\n\t);\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ACjC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE;KACnE,CAAC,CAAC;IACH,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,CACnC,+GAA+G,CAC/G,CAAC;AACH,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,oEAAoE,EAAE,GAAG,EAAE;IAC/E,MAAM,MAAM,GAAG,aAAa,CAAC;QAC5B,MAAM,EAAE,qBAAqB,CAAC,OAAO,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC;QACpE,WAAW,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,IAAI,EAAE;QACxC,QAAQ,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,EAAqB;QACxE,0BAA0B,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,MAAM,QAAQ;KACzD,CAAC,CAAC;IACH,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,yBAAyB,CAAC,CAAC;IAChE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,SAAS,CACvC,iDAAiD,CACjD,CAAC;AACH,CAAC,CAAC,CAAC","sourcesContent":["import { test, expect } from \"vitest\";\nimport { compileBundle, toBundleInputTypeAliasName } from \"./compile-bundle.js\";\nimport type { BundleNested, ProjectSettings } from \"@inlang/sdk\";\nimport { toSafeModuleId } from \"./safe-module-id.js\";\nimport { perLocaleBuildStaticLocaleExpression } from \"./per-locale-build.js\";\n\nfunction createPlainTextBundle(\n\tid: string,\n\ttextByLocale: Record<string, string>,\n\tdeclarations: BundleNested[\"declarations\"] = []\n): BundleNested {\n\treturn {\n\t\tid,\n\t\tdeclarations,\n\t\tmessages: Object.entries(textByLocale).map(([locale, value]) => ({\n\t\t\tid: `${id}-${locale}`,\n\t\t\tbundle_id: id,\n\t\t\tlocale,\n\t\t\tselectors: [],\n\t\t\tvariants: [\n\t\t\t\t{\n\t\t\t\t\tid: `${id}-${locale}-variant`,\n\t\t\t\t\tmessage_id: `${id}-${locale}`,\n\t\t\t\t\tmatches: [],\n\t\t\t\t\tpattern: [{ type: \"text\" as const, value }],\n\t\t\t\t},\n\t\t\t],\n\t\t})),\n\t};\n}\n\ntest(\"compiles to jsdoc\", async () => {\n\tconst mockBundle: BundleNested = {\n\t\tid: \"blue_moon_bottle\",\n\t\tdeclarations: [{ type: \"input-variable\", name: \"age\" }],\n\t\tmessages: [\n\t\t\t{\n\t\t\t\tid: \"message-id\",\n\t\t\t\tbundle_id: \"blue_moon_bottle\",\n\t\t\t\tlocale: \"en\",\n\t\t\t\tselectors: [],\n\t\t\t\tvariants: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"1\",\n\t\t\t\t\t\tmessage_id: \"message-id\",\n\t\t\t\t\t\tmatches: [],\n\t\t\t\t\t\tpattern: [\n\t\t\t\t\t\t\t{ type: \"text\", value: \"Hello\" },\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"expression\",\n\t\t\t\t\t\t\t\targ: { type: \"variable-reference\", name: \"age\" },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t};\n\n\tconst result = compileBundle({\n\t\tinlineMessages: true,\n\t\tfallbackMap: {\n\t\t\ten: \"en\",\n\t\t\t\"en-US\": \"en\",\n\t\t},\n\t\tbundle: mockBundle,\n\t\tmessageReferenceExpression: (locale) =>\n\t\t\t`${toSafeModuleId(locale)}.blue_moon_bottle`,\n\t\tsettings: {\n\t\t\tlocales: [\"en\", \"en-US\"],\n\t\t} as ProjectSettings,\n\t});\n\n\texpect(result.bundle.code).toMatchInlineSnapshot(\n\t\t`\n\t\t\"/**\n\t\t* | output |\n\t\t* | --- |\n\t\t* | \"Hello{age}\" |\n\t\t*\n\t\t* @param {Blue_Moon_BottleInputs} inputs\n\t\t* @param {{ locale?: \"en\" | \"en-US\" }} options\n\t\t* @returns {LocalizedString}\n\t\t*/\n\t\texport const blue_moon_bottle = /** @type {((inputs: Blue_Moon_BottleInputs, options?: { locale?: \"en\" | \"en-US\" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Blue_Moon_BottleInputs, { locale?: \"en\" | \"en-US\" }, {}>} */ ((inputs, options = {}) => {\n\t\t\tconst locale = experimentalStaticLocale ?? options.locale ?? getLocale()\n\t\t\tif (locale === \"en\") return en.blue_moon_bottle(inputs)\n\t\t\treturn en_us2.blue_moon_bottle(inputs)\n\t\t});\"\n\t`\n\t);\n});\n\ntest(\"uses the base locale as the exhaustive locale branch\", () => {\n\tconst mockBundle: BundleNested = {\n\t\tid: \"greeting\",\n\t\tdeclarations: [],\n\t\tmessages: [\n\t\t\t{\n\t\t\t\tid: \"message-id\",\n\t\t\t\tbundle_id: \"greeting\",\n\t\t\t\tlocale: \"en\",\n\t\t\t\tselectors: [],\n\t\t\t\tvariants: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"variant-id\",\n\t\t\t\t\t\tmessage_id: \"message-id\",\n\t\t\t\t\t\tmatches: [],\n\t\t\t\t\t\tpattern: [{ type: \"text\", value: \"Hello\" }],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t};\n\n\tconst result = compileBundle({\n\t\tinlineMessages: true,\n\t\tfallbackMap: {\n\t\t\tfr: \"en\",\n\t\t\tde: \"en\",\n\t\t\ten: undefined,\n\t\t\tja: \"en\",\n\t\t},\n\t\tbundle: mockBundle,\n\t\tmessageReferenceExpression: (locale) => `${locale}_greeting`,\n\t\tsettings: {\n\t\t\tbaseLocale: \"en\",\n\t\t\tlocales: [\"fr\", \"de\", \"en\", \"ja\"],\n\t\t} as ProjectSettings,\n\t});\n\n\texpect(result.bundle.code).toContain(\n\t\t[\n\t\t\t'if (locale === \"fr\") return fr_greeting(inputs)',\n\t\t\t'if (locale === \"de\") return de_greeting(inputs)',\n\t\t\t'if (locale === \"ja\") return ja_greeting(inputs)',\n\t\t\t'return /** @type {LocalizedString} */ (\"Hello\")',\n\t\t].join(\"\\n\\t\")\n\t);\n});\n\ntest(\"inlines static text with safe escaping and preserves missing-locale fallbacks\", async () => {\n\tconst id = \"$p@44🍌\";\n\tconst safeId = toSafeModuleId(id);\n\tconst trickyText =\n\t\t'quote \" backslash \\\\ backtick ` interpolation ${danger}\\r\\n</script><script>alert(1)</script> */\\u2028\\u2029';\n\tconst compiledText = trickyText.replace(/\\r\\n?/g, \"\\n\");\n\tconst bundle = createPlainTextBundle(id, { en: trickyText, de: \"Hallo\" }, [\n\t\t{ type: \"input-variable\", name: \"unused\" },\n\t]);\n\tconst result = compileBundle({\n\t\tinlineMessages: true,\n\t\tbundle,\n\t\tfallbackMap: { en: undefined, de: \"en\", fr: \"en\" },\n\t\tmessageReferenceExpression: (locale, bundleId) =>\n\t\t\t`${toSafeModuleId(locale)}_${toSafeModuleId(bundleId)}`,\n\t\tsettings: {\n\t\t\tbaseLocale: \"en\",\n\t\t\tlocales: [\"en\", \"de\", \"fr\"],\n\t\t} as ProjectSettings,\n\t\texperimentalMiddlewareLocaleSplitting: true,\n\t});\n\n\texpect(result.bundle.code).toContain(\n\t\t`if (locale === \"de\") return /** @type {LocalizedString} */ (${JSON.stringify(\"Hallo\")})`\n\t);\n\texpect(result.bundle.code).toContain(\n\t\t`if (locale === \"fr\") return fr_${safeId}(inputs)`\n\t);\n\texpect(result.bundle.code).toContain(\n\t\t`return /** @type {LocalizedString} */ (${JSON.stringify(compiledText)})`\n\t);\n\texpect(result.bundle.code).toContain(`trackMessageCall(\"${safeId}\", locale)`);\n\texpect(result.bundle.code).toContain(\n\t\t`globalThis).__paraglide.ssr.${safeId}(inputs)`\n\t);\n\texpect(result.messages.en?.code).toBeDefined();\n\n\tconst enMessage = result.messages.en;\n\tconst deMessage = result.messages.de;\n\tif (!enMessage || !deMessage) throw new Error(\"Expected compiled messages\");\n\tconst moduleSource = `\nconst getLocale = () => \"en\";\nconst trackMessageCall = () => {};\nconst experimentalMiddlewareLocaleSplitting = false;\nconst isServer = true;\nconst experimentalStaticLocale = undefined;\nconst en_${safeId} = ${enMessage.code.replace(/;\\s*$/, \"\")};\nconst de_${safeId} = ${deMessage.code.replace(/;\\s*$/, \"\")};\nconst fr_${safeId} = en_${safeId};\n${result.bundle.code}\n`;\n\tconst module = await import(\n\t\t\"data:text/javascript;charset=utf-8,\" + encodeURIComponent(moduleSource)\n\t);\n\tconst message = module[id];\n\tconst unreadInput = new Proxy(\n\t\t{},\n\t\t{\n\t\t\tget: () => {\n\t\t\t\tthrow new Error(\"static text should not read inputs\");\n\t\t\t},\n\t\t}\n\t);\n\n\texpect(message(unreadInput, { locale: \"en\" })).toBe(compiledText);\n\texpect(message({}, { locale: \"de\" })).toBe(\"Hallo\");\n\texpect(message({}, { locale: \"fr\" })).toBe(compiledText);\n});\n\ntest(\"leaves markup and multi-variant messages on their message functions\", () => {\n\tconst markupBundle: BundleNested = {\n\t\tid: \"notice\",\n\t\tdeclarations: [],\n\t\tmessages: [\n\t\t\t{\n\t\t\t\tid: \"notice-en\",\n\t\t\t\tbundle_id: \"notice\",\n\t\t\t\tlocale: \"en\",\n\t\t\t\tselectors: [],\n\t\t\t\tvariants: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"notice-en-variant\",\n\t\t\t\t\t\tmessage_id: \"notice-en\",\n\t\t\t\t\t\tmatches: [],\n\t\t\t\t\t\tpattern: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"markup-start\",\n\t\t\t\t\t\t\t\tname: \"strong\",\n\t\t\t\t\t\t\t\toptions: [],\n\t\t\t\t\t\t\t\tattributes: [],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{ type: \"text\", value: \"Hello\" },\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"markup-end\",\n\t\t\t\t\t\t\t\tname: \"strong\",\n\t\t\t\t\t\t\t\toptions: [],\n\t\t\t\t\t\t\t\tattributes: [],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t};\n\tconst markupResult = compileBundle({\n\t\tinlineMessages: true,\n\t\tbundle: markupBundle,\n\t\tfallbackMap: { en: undefined },\n\t\tmessageReferenceExpression: (locale) => `${locale}_notice`,\n\t\tsettings: { baseLocale: \"en\", locales: [\"en\"] } as ProjectSettings,\n\t});\n\texpect(markupResult.bundle.code).toContain(\"return en_notice(inputs)\");\n\texpect(markupResult.bundle.code).not.toContain(\n\t\t'return /** @type {LocalizedString} */ (\"Hello\")'\n\t);\n\n\tconst multiVariantBundle: BundleNested = {\n\t\tid: \"item_count\",\n\t\tdeclarations: [{ type: \"input-variable\", name: \"count\" }],\n\t\tmessages: [\"en\", \"de\"].map((locale) => ({\n\t\t\tid: `item_count-${locale}`,\n\t\t\tbundle_id: \"item_count\",\n\t\t\tlocale,\n\t\t\tselectors: [{ type: \"variable-reference\", name: \"count\" }],\n\t\t\tvariants: [\n\t\t\t\t{\n\t\t\t\t\tid: `item_count-${locale}-zero`,\n\t\t\t\t\tmessage_id: `item_count-${locale}`,\n\t\t\t\t\tmatches: [{ type: \"literal-match\", key: \"count\", value: \"0\" }],\n\t\t\t\t\tpattern: [{ type: \"text\", value: \"No items\" }],\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tid: `item_count-${locale}-other`,\n\t\t\t\t\tmessage_id: `item_count-${locale}`,\n\t\t\t\t\tmatches: [{ type: \"catchall-match\", key: \"count\" }],\n\t\t\t\t\tpattern: [{ type: \"text\", value: \"Some items\" }],\n\t\t\t\t},\n\t\t\t],\n\t\t})),\n\t};\n\tconst multiVariantResult = compileBundle({\n\t\tinlineMessages: true,\n\t\tbundle: multiVariantBundle,\n\t\tfallbackMap: { en: undefined, de: \"en\" },\n\t\tmessageReferenceExpression: (locale) => `${locale}_item_count`,\n\t\tsettings: { baseLocale: \"en\", locales: [\"en\", \"de\"] } as ProjectSettings,\n\t});\n\texpect(multiVariantResult.bundle.code).toContain(\n\t\t'if (locale === \"de\") return de_item_count(inputs)'\n\t);\n\texpect(multiVariantResult.bundle.code).toContain(\n\t\t\"return en_item_count(inputs)\"\n\t);\n});\n\ntest(\"keeps static text message references in a per-locale build\", () => {\n\tconst bundle = createPlainTextBundle(\"greeting\", {\n\t\ten: \"Hello\",\n\t\tde: \"Hallo\",\n\t});\n\tconst result = compileBundle({\n\t\tinlineMessages: true,\n\t\tbundle,\n\t\tfallbackMap: { en: undefined, de: \"en\" },\n\t\tmessageReferenceExpression: (locale) => `${locale}_greeting`,\n\t\tsettings: { baseLocale: \"en\", locales: [\"en\", \"de\"] } as ProjectSettings,\n\t\texperimentalStaticLocale: perLocaleBuildStaticLocaleExpression,\n\t});\n\n\texpect(result.bundle.code).toContain(\n\t\t'if (locale === \"de\") return de_greeting(inputs)'\n\t);\n\texpect(result.bundle.code).toContain(\"return en_greeting(inputs)\");\n});\n\ntest(\"marks an unused input parameter as used when every branch is inlined\", () => {\n\tconst bundle = createPlainTextBundle(\"greeting\", { en: \"Hello\" }, [\n\t\t{ type: \"input-variable\", name: \"unused\" },\n\t]);\n\tconst result = compileBundle({\n\t\tinlineMessages: true,\n\t\tbundle,\n\t\tfallbackMap: { en: undefined },\n\t\tmessageReferenceExpression: (locale) => `${locale}_greeting`,\n\t\tsettings: { baseLocale: \"en\", locales: [\"en\"] } as ProjectSettings,\n\t});\n\n\texpect(result.bundle.code).toContain(\"void inputs;\");\n\texpect(result.bundle.code).toContain(\n\t\t'return /** @type {LocalizedString} */ (\"Hello\")'\n\t);\n});\n\ntest(\"does not treat inherited object properties as inline locale messages\", () => {\n\tconst bundle = createPlainTextBundle(\"greeting\", { en: \"Hello\" });\n\tconst result = compileBundle({\n\t\tinlineMessages: true,\n\t\tbundle,\n\t\tfallbackMap: { en: undefined, toString: \"en\", constructor: \"en\" },\n\t\tmessageReferenceExpression: (locale) =>\n\t\t\t`${toSafeModuleId(locale)}_greeting`,\n\t\tsettings: {\n\t\t\tbaseLocale: \"en\",\n\t\t\tlocales: [\"en\", \"toString\", \"constructor\"],\n\t\t} as ProjectSettings,\n\t});\n\n\texpect(result.bundle.code).toContain(\n\t\t`if (locale === \"toString\") return ${toSafeModuleId(\"toString\")}_greeting(inputs)`\n\t);\n\texpect(result.bundle.code).toContain(\n\t\t`if (locale === \"constructor\") return ${toSafeModuleId(\"constructor\")}_greeting(inputs)`\n\t);\n\texpect(result.bundle.code).toContain(\n\t\t'return /** @type {LocalizedString} */ (\"Hello\")'\n\t);\n});\n\ntest(\"emits middleware locale splitting hooks when enabled\", () => {\n\tconst mockBundle: BundleNested = {\n\t\tid: \"blue_moon_bottle\",\n\t\tdeclarations: [{ type: \"input-variable\", name: \"age\" }],\n\t\tmessages: [\n\t\t\t{\n\t\t\t\tid: \"message-id\",\n\t\t\t\tbundle_id: \"blue_moon_bottle\",\n\t\t\t\tlocale: \"en\",\n\t\t\t\tselectors: [],\n\t\t\t\tvariants: [\n\t\t\t\t\t{ id: \"1\", message_id: \"message-id\", matches: [], pattern: [] },\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t};\n\n\tconst result = compileBundle({\n\t\tinlineMessages: true,\n\t\tfallbackMap: { en: \"en\" },\n\t\tbundle: mockBundle,\n\t\tmessageReferenceExpression: (locale) =>\n\t\t\t`${toSafeModuleId(locale)}.blue_moon_bottle`,\n\t\tsettings: {\n\t\t\tlocales: [\"en\"],\n\t\t} as ProjectSettings,\n\t\texperimentalMiddlewareLocaleSplitting: true,\n\t});\n\n\texpect(result.bundle.code).toContain(\n\t\t\"if (experimentalMiddlewareLocaleSplitting && isServer === false)\"\n\t);\n\texpect(result.bundle.code).toContain(\n\t\t'trackMessageCall(\"blue_moon_bottle\", locale)'\n\t);\n\texpect(result.bundle.code).toContain(\n\t\t\"globalThis).__paraglide.ssr.blue_moon_bottle(inputs)\"\n\t);\n});\n\ntest(\"emits the per-locale build marker inside the message function\", () => {\n\tconst mockBundle: BundleNested = {\n\t\tid: \"greeting\",\n\t\tdeclarations: [],\n\t\tmessages: [\n\t\t\t{\n\t\t\t\tid: \"greeting-en\",\n\t\t\t\tbundle_id: \"greeting\",\n\t\t\t\tlocale: \"en\",\n\t\t\t\tselectors: [],\n\t\t\t\tvariants: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"greeting-en-variant\",\n\t\t\t\t\t\tmessage_id: \"greeting-en\",\n\t\t\t\t\t\tmatches: [],\n\t\t\t\t\t\tpattern: [{ type: \"text\", value: \"hello\" }],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"greeting-de\",\n\t\t\t\tbundle_id: \"greeting\",\n\t\t\t\tlocale: \"de\",\n\t\t\t\tselectors: [],\n\t\t\t\tvariants: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"greeting-de-variant\",\n\t\t\t\t\t\tmessage_id: \"greeting-de\",\n\t\t\t\t\t\tmatches: [],\n\t\t\t\t\t\tpattern: [{ type: \"text\", value: \"hallo\" }],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t};\n\tconst expression = perLocaleBuildStaticLocaleExpression;\n\tconst result = compileBundle({\n\t\tinlineMessages: true,\n\t\tbundle: mockBundle,\n\t\tfallbackMap: { en: undefined, de: \"en\" },\n\t\tmessageReferenceExpression: (locale) => `${locale}_greeting`,\n\t\tsettings: { locales: [\"en\", \"de\"] } as ProjectSettings,\n\t\texperimentalStaticLocale: expression,\n\t});\n\n\texpect(result.bundle.code).toContain(\n\t\t`const locale = ${expression} ?? options.locale ?? getLocale()`\n\t);\n\texpect(result.bundle.code).toContain(\n\t\t`if (${expression} !== undefined && options.locale !== undefined && options.locale !== ${expression}) console.warn(`\n\t);\n\texpect(result.bundle.code).toContain(\"full document navigation\");\n});\n\ntest(\"compiles to jsdoc with missing translation\", async () => {\n\tconst mockBundle: BundleNested = {\n\t\tid: \"blue_moon_bottle\",\n\t\tdeclarations: [{ type: \"input-variable\", name: \"age\" }],\n\t\tmessages: [\n\t\t\t{\n\t\t\t\tid: \"message-id\",\n\t\t\t\tbundle_id: \"blue_moon_bottle\",\n\t\t\t\tlocale: \"en\",\n\t\t\t\tselectors: [],\n\t\t\t\tvariants: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"1\",\n\t\t\t\t\t\tmessage_id: \"message-id\",\n\t\t\t\t\t\tmatches: [],\n\t\t\t\t\t\tpattern: [\n\t\t\t\t\t\t\t{ type: \"text\", value: \"Hello\" },\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"expression\",\n\t\t\t\t\t\t\t\targ: { type: \"variable-reference\", name: \"age\" },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t};\n\n\tconst result = compileBundle({\n\t\tinlineMessages: true,\n\t\tfallbackMap: {\n\t\t\ten: \"en\",\n\t\t\t\"en-US\": \"en\",\n\t\t},\n\t\tbundle: mockBundle,\n\t\tmessageReferenceExpression: (locale) =>\n\t\t\t`${toSafeModuleId(locale)}.blue_moon_bottle`,\n\t\tsettings: {\n\t\t\tlocales: [\"en\", \"en-US\", \"fr\"],\n\t\t} as ProjectSettings,\n\t});\n\n\texpect(result.bundle.code).toMatchInlineSnapshot(\n\t\t`\n\t\t\"/**\n\t\t* | output |\n\t\t* | --- |\n\t\t* | \"Hello{age}\" |\n\t\t*\n\t\t* @param {Blue_Moon_BottleInputs} inputs\n\t\t* @param {{ locale?: \"en\" | \"en-US\" }} options\n\t\t* @returns {LocalizedString}\n\t\t*/\n\t\texport const blue_moon_bottle = /** @type {((inputs: Blue_Moon_BottleInputs, options?: { locale?: \"en\" | \"en-US\" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Blue_Moon_BottleInputs, { locale?: \"en\" | \"en-US\" }, {}>} */ ((inputs, options = {}) => {\n\t\t\tconst locale = experimentalStaticLocale ?? options.locale ?? getLocale()\n\t\t\tif (locale === \"en\") return en.blue_moon_bottle(inputs)\n\t\t\tif (locale === \"en-US\") return en_us2.blue_moon_bottle(inputs)\n\t\t\treturn /** @type {LocalizedString} */ (\"blue_moon_bottle\")\n\t\t});\"\n\t`\n\t);\n});\n\n// https://github.com/opral/inlang-paraglide-js/issues/285\ntest(\"compiles bundles with arbitrary module identifiers\", async () => {\n\tconst mockBundle: BundleNested = {\n\t\tid: \"$p@44🍌\",\n\t\tdeclarations: [{ type: \"input-variable\", name: \"age\" }],\n\t\tmessages: [\n\t\t\t{\n\t\t\t\tid: \"message-id\",\n\t\t\t\tbundle_id: \"$p@44🍌\",\n\t\t\t\tlocale: \"en\",\n\t\t\t\tselectors: [],\n\t\t\t\tvariants: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"1\",\n\t\t\t\t\t\tmessage_id: \"message-id\",\n\t\t\t\t\t\tmatches: [],\n\t\t\t\t\t\tpattern: [\n\t\t\t\t\t\t\t{ type: \"text\", value: \"Hello\" },\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"expression\",\n\t\t\t\t\t\t\t\targ: { type: \"variable-reference\", name: \"age\" },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t};\n\n\tconst result = compileBundle({\n\t\tinlineMessages: true,\n\t\tfallbackMap: {},\n\t\tbundle: mockBundle,\n\t\tmessageReferenceExpression: (locale) =>\n\t\t\t`${toSafeModuleId(locale)}.blue_moon_bottle`,\n\t});\n\n\texpect(result.bundle.code).includes(\n\t\t`export { ${toSafeModuleId(\"$p@44🍌\")} as \"$p@44🍌\" }`\n\t);\n});\n\ntest(\"keeps generated input typedef names collision-free for repeated underscores\", () => {\n\texpect(toBundleInputTypeAliasName(\"foo_bar\")).toBe(\"Foo_BarInputs\");\n\texpect(toBundleInputTypeAliasName(\"foo__bar\")).toBe(\"Foo__BarInputs\");\n\texpect(toBundleInputTypeAliasName(\"foo_bar\")).not.toBe(\n\t\ttoBundleInputTypeAliasName(\"foo__bar\")\n\t);\n});\n\ntest(\"handles message pattern with duplicate variable references\", async () => {\n\tconst mockBundle: BundleNested = {\n\t\tid: \"date_last_days\",\n\t\tdeclarations: [\n\t\t\t{ type: \"input-variable\", name: \"days\" },\n\t\t\t{ type: \"input-variable\", name: \"days\" },\n\t\t],\n\t\tmessages: [\n\t\t\t{\n\t\t\t\tid: \"date_last_days\",\n\t\t\t\tbundle_id: \"date_last_days\",\n\t\t\t\tlocale: \"en\",\n\t\t\t\tselectors: [],\n\t\t\t\tvariants: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"1\",\n\t\t\t\t\t\tmessage_id: \"date_last_days\",\n\t\t\t\t\t\tmatches: [],\n\t\t\t\t\t\tpattern: [\n\t\t\t\t\t\t\t{ type: \"text\", value: \"Last \" },\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"expression\",\n\t\t\t\t\t\t\t\targ: { type: \"variable-reference\", name: \"days\" },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{ type: \"text\", value: \" days, showing \" },\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"expression\",\n\t\t\t\t\t\t\t\targ: { type: \"variable-reference\", name: \"days\" },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{ type: \"text\", value: \" items\" },\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t};\n\n\tconst result = compileBundle({\n\t\tinlineMessages: true,\n\t\tfallbackMap: {\n\t\t\ten: \"en\",\n\t\t},\n\t\tbundle: mockBundle,\n\t\tmessageReferenceExpression: (locale) =>\n\t\t\t`${toSafeModuleId(locale)}.date_last_days`,\n\t});\n\n\t// The JSDoc should not have duplicate parameters\n\texpect(result.bundle.code).toContain(\"@param {Date_Last_DaysInputs} inputs\");\n\texpect(result.bundle.code).not.toContain(\n\t\t\"days: NonNullable<unknown>, days: NonNullable<unknown>\"\n\t);\n\n\t// Check that the pattern is compiled correctly\n\tconst enMessage = result.messages?.en;\n\texpect(enMessage).toBeDefined();\n\texpect(enMessage?.code).toContain(\n\t\t\"Last ${i?.days} days, showing ${i?.days} items\"\n\t);\n});\n\ntest(\"adds .parts() to bundle functions when markup exists\", async () => {\n\tconst mockBundle: BundleNested = {\n\t\tid: \"notice\",\n\t\tdeclarations: [{ type: \"input-variable\", name: \"count\" }],\n\t\tmessages: [\n\t\t\t{\n\t\t\t\tid: \"notice-id\",\n\t\t\t\tbundle_id: \"notice\",\n\t\t\t\tlocale: \"en\",\n\t\t\t\tselectors: [],\n\t\t\t\tvariants: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"1\",\n\t\t\t\t\t\tmessage_id: \"notice-id\",\n\t\t\t\t\t\tmatches: [],\n\t\t\t\t\t\tpattern: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"markup-start\",\n\t\t\t\t\t\t\t\tname: \"strong\",\n\t\t\t\t\t\t\t\toptions: [],\n\t\t\t\t\t\t\t\tattributes: [],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"expression\",\n\t\t\t\t\t\t\t\targ: { type: \"variable-reference\", name: \"count\" },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{ type: \"text\", value: \" items\" },\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"markup-end\",\n\t\t\t\t\t\t\t\tname: \"strong\",\n\t\t\t\t\t\t\t\toptions: [],\n\t\t\t\t\t\t\t\tattributes: [],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t};\n\n\tconst result = compileBundle({\n\t\tinlineMessages: true,\n\t\tfallbackMap: {\n\t\t\ten: undefined,\n\t\t},\n\t\tbundle: mockBundle,\n\t\tmessageReferenceExpression: (locale) => `${toSafeModuleId(locale)}.notice`,\n\t\tsettings: {\n\t\t\tlocales: [\"en\"],\n\t\t} as ProjectSettings,\n\t});\n\tconst compiledEnMessage = result.messages.en;\n\tif (!compiledEnMessage) {\n\t\tthrow new Error(\"Expected compiled english message\");\n\t}\n\n\tconst moduleSource = `\nconst getLocale = () => \"en\";\nconst trackMessageCall = () => {};\nconst experimentalMiddlewareLocaleSplitting = false;\nconst isServer = true;\nconst experimentalStaticLocale = undefined;\nconst en = {\n\tnotice: ${compiledEnMessage.code.replace(/;\\s*$/, \"\")}\n};\n${result.bundle.code}\n`;\n\n\tconst { notice } = await import(\n\t\t\"data:text/javascript;base64,\" + btoa(moduleSource)\n\t);\n\n\texpect(notice({ count: 3 })).toBe(\"3 items\");\n\texpect(notice.parts({ count: 3 })).toEqual([\n\t\t{ type: \"markup-start\", name: \"strong\", options: {}, attributes: {} },\n\t\t{ type: \"text\", value: \"3\" },\n\t\t{ type: \"text\", value: \" items\" },\n\t\t{ type: \"markup-end\", name: \"strong\", options: {}, attributes: {} },\n\t]);\n\texpect(result.bundle.code).toContain(\n\t\t'MessageMetadata<NoticeInputs, { locale?: \"en\" }, { strong: { options: {}; attributes: {}; children: true } }>'\n\t);\n});\n\ntest(\"low-level compilation preserves references without a layout opt-in\", () => {\n\tconst result = compileBundle({\n\t\tbundle: createPlainTextBundle(\"plain\", { en: \"Hello\", de: \"Hallo\" }),\n\t\tfallbackMap: { en: undefined, de: \"en\" },\n\t\tsettings: { baseLocale: \"en\", locales: [\"en\", \"de\"] } as ProjectSettings,\n\t\tmessageReferenceExpression: (locale) => `${locale}_plain`,\n\t});\n\texpect(result.bundle.code).toContain(\"return de_plain(inputs)\");\n\texpect(result.bundle.code).not.toContain(\n\t\t'return /** @type {LocalizedString} */ (\"Hallo\")'\n\t);\n});\n"]}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,69 @@
1
+ import { loadProjectInMemory, newProject, saveProjectToDirectory, } from "@inlang/sdk";
2
+ import { memfs } from "memfs";
3
+ import { test, expect, vi } from "vitest";
4
+ import { compile } from "./compile.js";
5
+ vi.mock("@inlang/sdk", async (importOriginal) => {
6
+ const sdk = await importOriginal();
7
+ return {
8
+ ...sdk,
9
+ loadProjectFromDirectory: vi.fn(sdk.loadProjectFromDirectory),
10
+ };
11
+ });
12
+ test.each([false, true])("closes the loaded project after write failure and permits a retry (cleanup fails: %s)", async (cleanupFails) => {
13
+ const sdk = await import("@inlang/sdk");
14
+ const fs = memfs().fs;
15
+ const project = await loadProjectInMemory({ blob: await newProject({}) });
16
+ try {
17
+ await saveProjectToDirectory({
18
+ project,
19
+ path: "/project.inlang",
20
+ fs: fs.promises,
21
+ });
22
+ }
23
+ finally {
24
+ await project.close();
25
+ }
26
+ const load = sdk.loadProjectFromDirectory;
27
+ const closed = vi.fn();
28
+ const loadSpy = vi
29
+ .spyOn(sdk, "loadProjectFromDirectory")
30
+ .mockImplementation(async (args) => {
31
+ const loaded = await load(args);
32
+ const close = loaded.close.bind(loaded);
33
+ loaded.close = async () => {
34
+ closed();
35
+ await close();
36
+ if (cleanupFails && closed.mock.calls.length === 1)
37
+ throw new Error("close failed");
38
+ };
39
+ return loaded;
40
+ });
41
+ const originalWrite = fs.promises.writeFile.bind(fs.promises);
42
+ const error = Object.assign(new Error("write: no space left on device"), {
43
+ code: "ENOSPC",
44
+ });
45
+ const writeSpy = vi
46
+ .spyOn(fs.promises, "writeFile")
47
+ .mockImplementation((async (...args) => {
48
+ if (String(args[0]).startsWith("/output/"))
49
+ throw error;
50
+ return originalWrite(...args);
51
+ }));
52
+ try {
53
+ await expect(compile({ project: "/project.inlang", outdir: "/output", fs })).rejects.toBe(error);
54
+ expect(closed).toHaveBeenCalledTimes(1);
55
+ writeSpy.mockRestore();
56
+ const result = await compile({
57
+ project: "/project.inlang",
58
+ outdir: "/output",
59
+ fs,
60
+ });
61
+ expect(result.outputHashes).toHaveProperty("runtime.js");
62
+ expect(closed).toHaveBeenCalledTimes(2);
63
+ }
64
+ finally {
65
+ loadSpy.mockRestore();
66
+ writeSpy.mockRestore();
67
+ }
68
+ });
69
+ //# sourceMappingURL=compile-lifecycle.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compile-lifecycle.test.js","sourceRoot":"","sources":["../../src/compiler/compile-lifecycle.test.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,mBAAmB,EACnB,UAAU,EACV,sBAAsB,GACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,EAAE,CAAC,IAAI,CAAC,aAAa,EAAE,KAAK,EAAE,cAAc,EAAE,EAAE;IAC/C,MAAM,GAAG,GAAG,MAAM,cAAc,EAAgC,CAAC;IACjE,OAAO;QACN,GAAG,GAAG;QACN,wBAAwB,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,wBAAwB,CAAC;KAC7D,CAAC;AACH,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CACvB,uFAAuF,EACvF,KAAK,EAAE,YAAY,EAAE,EAAE;IACtB,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,CAAC;IACxC,MAAM,EAAE,GAAG,KAAK,EAAE,CAAC,EAAyC,CAAC;IAC7D,MAAM,OAAO,GAAG,MAAM,mBAAmB,CAAC,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAC1E,IAAI,CAAC;QACJ,MAAM,sBAA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I,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC;YAAE,MAAM,KAAK,CAAC;QACxD,OAAO,aAAa,CAAC,GAAG,IAAI,CAAC,CAAC;IAC/B,CAAC,CAAiC,CAAC,CAAC;IACrC,IAAI,CAAC;QACJ,MAAM,MAAM,CACX,OAAO,CAAC,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,CAC9D,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACtB,MAAM,CAAC,MAAM,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;QACxC,QAAQ,CAAC,WAAW,EAAE,CAAC;QACvB,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC;YAC5B,OAAO,EAAE,iBAAiB;YAC1B,MAAM,EAAE,SAAS;YACjB,EAAE;SACF,CAAC,CAAC;QACH,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;QACzD,MAAM,CAAC,MAAM,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;IACzC,CAAC;YAAS,CAAC;QACV,OAAO,CAAC,WAAW,EAAE,CAAC;QACtB,QAAQ,CAAC,WAAW,EAAE,CAAC;IACxB,CAAC;AACF,CAAC,CACD,CAAC","sourcesContent":["import {\n\tloadProjectInMemory,\n\tnewProject,\n\tsaveProjectToDirectory,\n} from \"@inlang/sdk\";\nimport { memfs } from \"memfs\";\nimport { test, expect, vi } from \"vitest\";\nimport { compile } from \"./compile.js\";\n\nvi.mock(\"@inlang/sdk\", async (importOriginal) => {\n\tconst sdk = await importOriginal<typeof import(\"@inlang/sdk\")>();\n\treturn {\n\t\t...sdk,\n\t\tloadProjectFromDirectory: vi.fn(sdk.loadProjectFromDirectory),\n\t};\n});\n\ntest.each([false, true])(\n\t\"closes the loaded project after write failure and permits a retry (cleanup fails: %s)\",\n\tasync (cleanupFails) => {\n\t\tconst sdk = await import(\"@inlang/sdk\");\n\t\tconst fs = memfs().fs as unknown as typeof import(\"node:fs\");\n\t\tconst project = await loadProjectInMemory({ blob: await newProject({}) });\n\t\ttry {\n\t\t\tawait saveProjectToDirectory({\n\t\t\t\tproject,\n\t\t\t\tpath: \"/project.inlang\",\n\t\t\t\tfs: fs.promises,\n\t\t\t});\n\t\t} finally {\n\t\t\tawait project.close();\n\t\t}\n\t\tconst load = sdk.loadProjectFromDirectory;\n\t\tconst closed = vi.fn();\n\t\tconst loadSpy = vi\n\t\t\t.spyOn(sdk, \"loadProjectFromDirectory\")\n\t\t\t.mockImplementation(async (args) => {\n\t\t\t\tconst loaded = await load(args);\n\t\t\t\tconst close = loaded.close.bind(loaded);\n\t\t\t\tloaded.close = async () => {\n\t\t\t\t\tclosed();\n\t\t\t\t\tawait close();\n\t\t\t\t\tif (cleanupFails && closed.mock.calls.length === 1)\n\t\t\t\t\t\tthrow new Error(\"close failed\");\n\t\t\t\t};\n\t\t\t\treturn loaded;\n\t\t\t});\n\t\tconst originalWrite = fs.promises.writeFile.bind(fs.promises);\n\t\tconst error = Object.assign(new Error(\"write: no space left on device\"), {\n\t\t\tcode: \"ENOSPC\",\n\t\t});\n\t\tconst writeSpy = vi\n\t\t\t.spyOn(fs.promises, \"writeFile\")\n\t\t\t.mockImplementation((async (...args) => {\n\t\t\t\tif (String(args[0]).startsWith(\"/output/\")) throw error;\n\t\t\t\treturn originalWrite(...args);\n\t\t\t}) as typeof fs.promises.writeFile);\n\t\ttry {\n\t\t\tawait expect(\n\t\t\t\tcompile({ project: \"/project.inlang\", outdir: \"/output\", fs })\n\t\t\t).rejects.toBe(error);\n\t\t\texpect(closed).toHaveBeenCalledTimes(1);\n\t\t\twriteSpy.mockRestore();\n\t\t\tconst result = await compile({\n\t\t\t\tproject: \"/project.inlang\",\n\t\t\t\toutdir: \"/output\",\n\t\t\t\tfs,\n\t\t\t});\n\t\t\texpect(result.outputHashes).toHaveProperty(\"runtime.js\");\n\t\t\texpect(closed).toHaveBeenCalledTimes(2);\n\t\t} finally {\n\t\t\tloadSpy.mockRestore();\n\t\t\twriteSpy.mockRestore();\n\t\t}\n\t}\n);\n"]}
@@ -1,4 +1,5 @@
1
1
  import type { Declaration, LocalVariable } from "@inlang/sdk";
2
+ import { type RegistryUsage } from "./compile-annotation.js";
2
3
  /**
3
4
  * Compiles a local variable.
4
5
  *
@@ -14,4 +15,6 @@ export declare function compileLocalVariable(args: {
14
15
  locale: string;
15
16
  declaration: LocalVariable;
16
17
  declarations?: Declaration[];
18
+ /** Collects the registry functions the compiled local calls. */
19
+ registryUsage?: RegistryUsage;
17
20
  }): string;
@@ -1,6 +1,6 @@
1
1
  import { compileVariableAccess } from "./variable-access.js";
2
2
  import { escapeForDoubleQuoteString } from "../services/codegen/escape.js";
3
- import { compileAnnotation } from "./compile-annotation.js";
3
+ import { compileAnnotation, ignoreUnknownFormatter, isRegistryFunction, } from "./compile-annotation.js";
4
4
  /**
5
5
  * Compiles a local variable.
6
6
  *
@@ -14,7 +14,10 @@ import { compileAnnotation } from "./compile-annotation.js";
14
14
  */
15
15
  export function compileLocalVariable(args) {
16
16
  const annotation = args.declaration.value.annotation;
17
- const value = compileAnnotation(compileLiteralOrVarRef(args.declaration.value.arg, args.declarations), args.locale, annotation, args.declarations);
17
+ const arg = compileLiteralOrVarRef(args.declaration.value.arg, args.declarations);
18
+ const value = annotation && !isRegistryFunction(annotation.name)
19
+ ? ignoreUnknownFormatter(annotation.name, arg)
20
+ : compileAnnotation(arg, args.locale, annotation, args.declarations, args.registryUsage);
18
21
  return `const ${args.declaration.name} = ${value};`;
19
22
  }
20
23
  function compileLiteralOrVarRef(value, declarations) {
@@ -1 +1 @@
1
- {"version":3,"file":"compile-local-variable.js","sourceRoot":"","sources":["../../src/compiler/compile-local-variable.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D;;;;;;;;;;GAUG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAIpC;IACA,MAAM,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,UAAU,CAAC;IAErD,MAAM,KAAK,GAAG,iBAAiB,CAC9B,sBAAsB,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,YAAY,CAAC,EACrE,IAAI,CAAC,MAAM,EACX,UAAU,EACV,IAAI,CAAC,YAAY,CACjB,CAAC;IAEF,OAAO,SAAS,IAAI,CAAC,WAAW,CAAC,IAAI,MAAM,KAAK,GAAG,CAAC;AACrD,CAAC;AAED,SAAS,sBAAsB,CAC9B,KAAkC,EAClC,YAA4B;IAE5B,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,SAAS;YACb,OAAO,IAAI,0BAA0B,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;QACvD,KAAK,oBAAoB;YACxB,OAAO,qBAAqB,CAAC,KAAK,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IACzD,CAAC;AACF,CAAC","sourcesContent":["import type {\n\tDeclaration,\n\tLiteral,\n\tLocalVariable,\n\tVariableReference,\n} from \"@inlang/sdk\";\nimport { compileVariableAccess } from \"./variable-access.js\";\nimport { escapeForDoubleQuoteString } from \"../services/codegen/escape.js\";\nimport { compileAnnotation } from \"./compile-annotation.js\";\n\n/**\n * Compiles a local variable.\n *\n * @example\n * const code = compileLocalVariable({\n * type: \"local-variable\",\n * name: \"myVar\",\n * value: { type: \"literal\", value: \"Hello\" }\n * });\n * >> code === \"const myVar = 'Hello';\"\n */\nexport function compileLocalVariable(args: {\n\tlocale: string;\n\tdeclaration: LocalVariable;\n\tdeclarations?: Declaration[];\n}): string {\n\tconst annotation = args.declaration.value.annotation;\n\n\tconst value = compileAnnotation(\n\t\tcompileLiteralOrVarRef(args.declaration.value.arg, args.declarations),\n\t\targs.locale,\n\t\tannotation,\n\t\targs.declarations\n\t);\n\n\treturn `const ${args.declaration.name} = ${value};`;\n}\n\nfunction compileLiteralOrVarRef(\n\tvalue: Literal | VariableReference,\n\tdeclarations?: Declaration[]\n): string {\n\tswitch (value.type) {\n\t\tcase \"literal\":\n\t\t\treturn `\"${escapeForDoubleQuoteString(value.value)}\"`;\n\t\tcase \"variable-reference\":\n\t\t\treturn compileVariableAccess(value.name, declarations);\n\t}\n}\n"]}
1
+ {"version":3,"file":"compile-local-variable.js","sourceRoot":"","sources":["../../src/compiler/compile-local-variable.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EACN,iBAAiB,EACjB,sBAAsB,EACtB,kBAAkB,GAElB,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;;;;GAUG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAMpC;IACA,MAAM,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,UAAU,CAAC;IACrD,MAAM,GAAG,GAAG,sBAAsB,CACjC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG,EAC1B,IAAI,CAAC,YAAY,CACjB,CAAC;IAEF,MAAM,KAAK,GACV,UAAU,IAAI,CAAC,kBAAkB,CAAC,UAAU,CAAC,IAAI,CAAC;QACjD,CAAC,CAAC,sBAAsB,CAAC,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC;QAC9C,CAAC,CAAC,iBAAiB,CACjB,GAAG,EACH,IAAI,CAAC,MAAM,EACX,UAAU,EACV,IAAI,CAAC,YAAY,EACjB,IAAI,CAAC,aAAa,CAClB,CAAC;IAEL,OAAO,SAAS,IAAI,CAAC,WAAW,CAAC,IAAI,MAAM,KAAK,GAAG,CAAC;AACrD,CAAC;AAED,SAAS,sBAAsB,CAC9B,KAAkC,EAClC,YAA4B;IAE5B,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,SAAS;YACb,OAAO,IAAI,0BAA0B,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;QACvD,KAAK,oBAAoB;YACxB,OAAO,qBAAqB,CAAC,KAAK,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IACzD,CAAC;AACF,CAAC","sourcesContent":["import type {\n\tDeclaration,\n\tLiteral,\n\tLocalVariable,\n\tVariableReference,\n} from \"@inlang/sdk\";\nimport { compileVariableAccess } from \"./variable-access.js\";\nimport { escapeForDoubleQuoteString } from \"../services/codegen/escape.js\";\nimport {\n\tcompileAnnotation,\n\tignoreUnknownFormatter,\n\tisRegistryFunction,\n\ttype RegistryUsage,\n} from \"./compile-annotation.js\";\n\n/**\n * Compiles a local variable.\n *\n * @example\n * const code = compileLocalVariable({\n * type: \"local-variable\",\n * name: \"myVar\",\n * value: { type: \"literal\", value: \"Hello\" }\n * });\n * >> code === \"const myVar = 'Hello';\"\n */\nexport function compileLocalVariable(args: {\n\tlocale: string;\n\tdeclaration: LocalVariable;\n\tdeclarations?: Declaration[];\n\t/** Collects the registry functions the compiled local calls. */\n\tregistryUsage?: RegistryUsage;\n}): string {\n\tconst annotation = args.declaration.value.annotation;\n\tconst arg = compileLiteralOrVarRef(\n\t\targs.declaration.value.arg,\n\t\targs.declarations\n\t);\n\n\tconst value =\n\t\tannotation && !isRegistryFunction(annotation.name)\n\t\t\t? ignoreUnknownFormatter(annotation.name, arg)\n\t\t\t: compileAnnotation(\n\t\t\t\t\targ,\n\t\t\t\t\targs.locale,\n\t\t\t\t\tannotation,\n\t\t\t\t\targs.declarations,\n\t\t\t\t\targs.registryUsage\n\t\t\t\t);\n\n\treturn `const ${args.declaration.name} = ${value};`;\n}\n\nfunction compileLiteralOrVarRef(\n\tvalue: Literal | VariableReference,\n\tdeclarations?: Declaration[]\n): string {\n\tswitch (value.type) {\n\t\tcase \"literal\":\n\t\t\treturn `\"${escapeForDoubleQuoteString(value.value)}\"`;\n\t\tcase \"variable-reference\":\n\t\t\treturn compileVariableAccess(value.name, declarations);\n\t}\n}\n"]}
@@ -71,13 +71,34 @@ test("compiles a local variable with an annotation and empty options", () => {
71
71
  arg: { type: "literal", value: "Hello" },
72
72
  annotation: {
73
73
  type: "function-reference",
74
- name: "myFunction",
74
+ name: "number",
75
75
  options: [],
76
76
  },
77
77
  },
78
78
  },
79
79
  });
80
- expect(code).toEqual('const myVar = registry.myFunction("en", "Hello", {});');
80
+ expect(code).toEqual('const myVar = registry.number("en", "Hello", {}, true);');
81
+ });
82
+ test("interpolates the raw value for an unknown annotation, like a pattern", () => {
83
+ const code = compileLocalVariable({
84
+ locale: "en",
85
+ declaration: {
86
+ type: "local-variable",
87
+ name: "myVar",
88
+ value: {
89
+ type: "expression",
90
+ arg: { type: "variable-reference", name: "amount" },
91
+ annotation: {
92
+ type: "function-reference",
93
+ name: "myFunction",
94
+ options: [
95
+ { name: "option1", value: { type: "literal", value: "value1" } },
96
+ ],
97
+ },
98
+ },
99
+ },
100
+ });
101
+ expect(code).toEqual("const myVar = i?.amount;");
81
102
  });
82
103
  test("compiles a local variable with an annotation and options", () => {
83
104
  const code = compileLocalVariable({
@@ -90,7 +111,7 @@ test("compiles a local variable with an annotation and options", () => {
90
111
  arg: { type: "literal", value: "Hello" },
91
112
  annotation: {
92
113
  type: "function-reference",
93
- name: "myFunction",
114
+ name: "number",
94
115
  options: [
95
116
  { name: "option1", value: { type: "literal", value: "value1" } },
96
117
  {
@@ -102,7 +123,7 @@ test("compiles a local variable with an annotation and options", () => {
102
123
  },
103
124
  },
104
125
  });
105
- expect(code).toEqual('const myVar = registry.myFunction("en", "Hello", { option1: "value1", option2: i?.varRef });');
126
+ expect(code).toEqual('const myVar = registry.number("en", "Hello", { option1: "value1", option2: i?.varRef }, true);');
106
127
  });
107
128
  test("compiles formatter options referencing earlier local variables", () => {
108
129
  const code = compileLocalVariable({
@@ -134,7 +155,7 @@ test("compiles formatter options referencing earlier local variables", () => {
134
155
  },
135
156
  },
136
157
  });
137
- expect(code).toEqual('const formattedAmount = registry.number("en", i?.amount, { minimumFractionDigits: digits });');
158
+ expect(code).toEqual('const formattedAmount = registry.number("en", i?.amount, { minimumFractionDigits: digits }, true);');
138
159
  });
139
160
  test("compiles number formatter fraction digit options as numeric literals", () => {
140
161
  const code = compileLocalVariable({
@@ -162,7 +183,7 @@ test("compiles number formatter fraction digit options as numeric literals", ()
162
183
  },
163
184
  },
164
185
  });
165
- expect(code).toEqual('const formattedValue = registry.number("en", i?.value, { minimumFractionDigits: 1, maximumFractionDigits: 1 });');
186
+ expect(code).toEqual('const formattedValue = registry.number("en", i?.value, { minimumFractionDigits: 1, maximumFractionDigits: 1 }, true);');
166
187
  });
167
188
  test("compiles number formatter useGrouping option as boolean literal", () => {
168
189
  const code = compileLocalVariable({
@@ -186,7 +207,7 @@ test("compiles number formatter useGrouping option as boolean literal", () => {
186
207
  },
187
208
  },
188
209
  });
189
- expect(code).toEqual('const formattedValue = registry.number("en", i?.value, { useGrouping: false });');
210
+ expect(code).toEqual('const formattedValue = registry.number("en", i?.value, { useGrouping: false }, true);');
190
211
  });
191
212
  test("keeps negative digit options as strings to avoid emitting invalid numeric literals", () => {
192
213
  const code = compileLocalVariable({
@@ -210,7 +231,7 @@ test("keeps negative digit options as strings to avoid emitting invalid numeric
210
231
  },
211
232
  },
212
233
  });
213
- expect(code).toEqual('const formattedValue = registry.number("en", i?.value, { minimumFractionDigits: "-1" });');
234
+ expect(code).toEqual('const formattedValue = registry.number("en", i?.value, { minimumFractionDigits: "-1" }, true);');
214
235
  });
215
236
  test("compiles relative time formatter with a literal unit", () => {
216
237
  const code = compileLocalVariable({
@@ -233,7 +254,7 @@ test("compiles relative time formatter with a literal unit", () => {
233
254
  },
234
255
  },
235
256
  });
236
- expect(code).toEqual('const formattedDuration = registry.relativetime("en", i?.duration, { unit: "day", numeric: "auto", style: "short" });');
257
+ expect(code).toEqual('const formattedDuration = registry.relativetime("en", i?.duration, { unit: "day", numeric: "auto", style: "short" }, true);');
237
258
  });
238
259
  test("compiles relative time formatter with a dynamic unit cast", () => {
239
260
  const code = compileLocalVariable({
@@ -258,7 +279,7 @@ test("compiles relative time formatter with a dynamic unit cast", () => {
258
279
  },
259
280
  },
260
281
  });
261
- expect(code).toEqual('const formattedDuration = registry.relativetime("en", i?.duration, { unit: /** @type {import("../registry.js").RelativeTimeFormatUnit} */ (i?.unit), style: "short" });');
282
+ expect(code).toEqual('const formattedDuration = registry.relativetime("en", i?.duration, { unit: /** @type {import("../registry.js").RelativeTimeFormatUnit} */ (i?.unit), style: "short" }, true);');
262
283
  });
263
284
  test("throws if relative time formatter is missing a unit option", () => {
264
285
  expect(() => compileLocalVariable({
@@ -338,7 +359,7 @@ test("accepts plural relative time formatter units", () => {
338
359
  },
339
360
  },
340
361
  });
341
- expect(code).toEqual('const formattedDuration = registry.relativetime("en", i?.duration, { unit: "days" });');
362
+ expect(code).toEqual('const formattedDuration = registry.relativetime("en", i?.duration, { unit: "days" }, true);');
342
363
  });
343
364
  test("accepts dynamic relative time formatter units", () => {
344
365
  const code = compileLocalVariable({
@@ -362,7 +383,7 @@ test("accepts dynamic relative time formatter units", () => {
362
383
  },
363
384
  },
364
385
  });
365
- expect(code).toEqual('const formattedDuration = registry.relativetime("en", i?.duration, { unit: /** @type {import("../registry.js").RelativeTimeFormatUnit} */ (i?.unit) });');
386
+ expect(code).toEqual('const formattedDuration = registry.relativetime("en", i?.duration, { unit: /** @type {import("../registry.js").RelativeTimeFormatUnit} */ (i?.unit) }, true);');
366
387
  });
367
388
  test("accepts dollar-prefixed relative time formatter unit options from message files", () => {
368
389
  const code = compileLocalVariable({
@@ -383,7 +404,7 @@ test("accepts dollar-prefixed relative time formatter unit options from message
383
404
  },
384
405
  },
385
406
  });
386
- expect(code).toEqual('const formattedDuration = registry.relativetime("en", i?.duration, { unit: /** @type {import("../registry.js").RelativeTimeFormatUnit} */ (i?.unit) });');
407
+ expect(code).toEqual('const formattedDuration = registry.relativetime("en", i?.duration, { unit: /** @type {import("../registry.js").RelativeTimeFormatUnit} */ (i?.unit) }, true);');
387
408
  });
388
409
  test("compiles dollar-prefixed relative time units referencing local variables", () => {
389
410
  const code = compileLocalVariable({
@@ -412,7 +433,7 @@ test("compiles dollar-prefixed relative time units referencing local variables",
412
433
  },
413
434
  },
414
435
  });
415
- expect(code).toEqual('const formattedDuration = registry.relativetime("en", i?.duration, { unit: /** @type {import("../registry.js").RelativeTimeFormatUnit} */ (localUnit) });');
436
+ expect(code).toEqual('const formattedDuration = registry.relativetime("en", i?.duration, { unit: /** @type {import("../registry.js").RelativeTimeFormatUnit} */ (localUnit) }, true);');
416
437
  });
417
438
  test("accepts dollar-prefixed relative time formatter unit options with non-identifier input names", () => {
418
439
  const code = compileLocalVariable({
@@ -436,6 +457,25 @@ test("accepts dollar-prefixed relative time formatter unit options with non-iden
436
457
  },
437
458
  },
438
459
  });
439
- expect(code).toEqual('const formattedDuration = registry.relativetime("en", i?.duration, { unit: /** @type {import("../registry.js").RelativeTimeFormatUnit} */ (i?.["relative-unit"]) });');
460
+ expect(code).toEqual('const formattedDuration = registry.relativetime("en", i?.duration, { unit: /** @type {import("../registry.js").RelativeTimeFormatUnit} */ (i?.["relative-unit"]) }, true);');
461
+ });
462
+ test.each([
463
+ ["date", '{ dateStyle: "medium" }'],
464
+ ["time", '{ timeStyle: "medium" }'],
465
+ ["datetime", '{ dateStyle: "medium", timeStyle: "short" }'],
466
+ ])("compiles a %s local variable with its default style", (name, options) => {
467
+ const code = compileLocalVariable({
468
+ locale: "en",
469
+ declaration: {
470
+ type: "local-variable",
471
+ name: "formatted",
472
+ value: {
473
+ type: "expression",
474
+ arg: { type: "variable-reference", name: "d" },
475
+ annotation: { type: "function-reference", name, options: [] },
476
+ },
477
+ },
478
+ });
479
+ expect(code).toBe(`const formatted = registry.datetime("en", i?.d, ${options}, true);`);
440
480
  });
441
481
  //# sourceMappingURL=compile-local-variable.test.js.map