@inlang/paraglide-js 2.27.0 → 2.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (180) hide show
  1. package/README.md +9 -0
  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 +235 -2
  5. package/dist/bundler-plugins/per-locale-build/vite-environments.test.js.map +1 -1
  6. package/dist/bundler-plugins/unplugin.d.ts +4 -1
  7. package/dist/bundler-plugins/unplugin.js +134 -22
  8. package/dist/bundler-plugins/unplugin.js.map +1 -1
  9. package/dist/bundler-plugins/unplugin.test.js +490 -1
  10. package/dist/bundler-plugins/unplugin.test.js.map +1 -1
  11. package/dist/bundler-plugins/vite-error-response.test.d.ts +1 -0
  12. package/dist/bundler-plugins/vite-error-response.test.js +171 -0
  13. package/dist/bundler-plugins/vite-error-response.test.js.map +1 -0
  14. package/dist/bundler-plugins/vite.d.ts +8 -0
  15. package/dist/bundler-plugins/vite.js +14 -4
  16. package/dist/bundler-plugins/vite.js.map +1 -1
  17. package/dist/bundler-plugins/vite.test.js +1 -1
  18. package/dist/bundler-plugins/vite.test.js.map +1 -1
  19. package/dist/cli/commands/compile/command.js +13 -0
  20. package/dist/cli/commands/compile/command.js.map +1 -1
  21. package/dist/cli/commands/compile/command.test.js +87 -3
  22. package/dist/cli/commands/compile/command.test.js.map +1 -1
  23. package/dist/cli/commands/init/command.d.ts +5 -0
  24. package/dist/cli/commands/init/command.js +213 -59
  25. package/dist/cli/commands/init/command.js.map +1 -1
  26. package/dist/cli/commands/init/command.test.d.ts +1 -0
  27. package/dist/cli/commands/init/command.test.js +123 -0
  28. package/dist/cli/commands/init/command.test.js.map +1 -0
  29. package/dist/cli/init-options.d.ts +11 -0
  30. package/dist/cli/init-options.js +2 -0
  31. package/dist/cli/init-options.js.map +1 -0
  32. package/dist/cli/steps/add-inlang-check.js +2 -2
  33. package/dist/cli/steps/add-inlang-check.js.map +1 -1
  34. package/dist/cli/steps/add-message-lint.d.ts +34 -0
  35. package/dist/cli/steps/add-message-lint.js +105 -0
  36. package/dist/cli/steps/add-message-lint.js.map +1 -0
  37. package/dist/cli/steps/add-message-lint.test.d.ts +1 -0
  38. package/dist/cli/steps/add-message-lint.test.js +74 -0
  39. package/dist/cli/steps/add-message-lint.test.js.map +1 -0
  40. package/dist/cli/steps/add-vite-plugin.d.ts +18 -0
  41. package/dist/cli/steps/add-vite-plugin.js +34 -6
  42. package/dist/cli/steps/add-vite-plugin.js.map +1 -1
  43. package/dist/cli/steps/add-vite-plugin.test.js +25 -9
  44. package/dist/cli/steps/add-vite-plugin.test.js.map +1 -1
  45. package/dist/cli/steps/check-for-uncomitted-changes.d.ts +3 -0
  46. package/dist/cli/steps/check-for-uncomitted-changes.js +15 -3
  47. package/dist/cli/steps/check-for-uncomitted-changes.js.map +1 -1
  48. package/dist/cli/steps/detect-bundler.d.ts +1 -0
  49. package/dist/cli/steps/detect-bundler.js +7 -1
  50. package/dist/cli/steps/detect-bundler.js.map +1 -1
  51. package/dist/cli/steps/initialize-inlang-project.d.ts +4 -3
  52. package/dist/cli/steps/initialize-inlang-project.js +60 -157
  53. package/dist/cli/steps/initialize-inlang-project.js.map +1 -1
  54. package/dist/cli/steps/maybe-add-machine-translation.d.ts +4 -0
  55. package/dist/cli/steps/maybe-add-machine-translation.js +11 -6
  56. package/dist/cli/steps/maybe-add-machine-translation.js.map +1 -1
  57. package/dist/cli/steps/maybe-add-sherlock.d.ts +2 -0
  58. package/dist/cli/steps/maybe-add-sherlock.js +12 -6
  59. package/dist/cli/steps/maybe-add-sherlock.js.map +1 -1
  60. package/dist/cli/steps/maybe-add-sherlock.test.d.ts +1 -0
  61. package/dist/cli/steps/maybe-add-sherlock.test.js +44 -0
  62. package/dist/cli/steps/maybe-add-sherlock.test.js.map +1 -0
  63. package/dist/cli/steps/prompt-for-outdir.d.ts +2 -0
  64. package/dist/cli/steps/prompt-for-outdir.js +4 -0
  65. package/dist/cli/steps/prompt-for-outdir.js.map +1 -1
  66. package/dist/cli/steps/update-package-json.js +8 -13
  67. package/dist/cli/steps/update-package-json.js.map +1 -1
  68. package/dist/cli/steps/update-ts-config.d.ts +6 -0
  69. package/dist/cli/steps/update-ts-config.js +27 -4
  70. package/dist/cli/steps/update-ts-config.js.map +1 -1
  71. package/dist/cli/utils.d.ts +2 -0
  72. package/dist/cli/utils.js +6 -0
  73. package/dist/cli/utils.js.map +1 -1
  74. package/dist/cli/utils.test.d.ts +1 -0
  75. package/dist/cli/utils.test.js +16 -0
  76. package/dist/cli/utils.test.js.map +1 -0
  77. package/dist/compiler/compile-annotation.js +6 -1
  78. package/dist/compiler/compile-annotation.js.map +1 -1
  79. package/dist/compiler/compile-bundle.d.ts +4 -0
  80. package/dist/compiler/compile-bundle.js +67 -2
  81. package/dist/compiler/compile-bundle.js.map +1 -1
  82. package/dist/compiler/compile-bundle.test.js +214 -1
  83. package/dist/compiler/compile-bundle.test.js.map +1 -1
  84. package/dist/compiler/compile-lifecycle.test.d.ts +1 -0
  85. package/dist/compiler/compile-lifecycle.test.js +69 -0
  86. package/dist/compiler/compile-lifecycle.test.js.map +1 -0
  87. package/dist/compiler/compile-local-variable.test.js +14 -14
  88. package/dist/compiler/compile-local-variable.test.js.map +1 -1
  89. package/dist/compiler/compile-message.exact-number.test.js +1 -1
  90. package/dist/compiler/compile-message.exact-number.test.js.map +1 -1
  91. package/dist/compiler/compile-message.locals.test.js +1 -1
  92. package/dist/compiler/compile-message.locals.test.js.map +1 -1
  93. package/dist/compiler/compile-message.test.js +2 -2
  94. package/dist/compiler/compile-message.test.js.map +1 -1
  95. package/dist/compiler/compile-pattern.test.js +5 -5
  96. package/dist/compiler/compile-pattern.test.js.map +1 -1
  97. package/dist/compiler/compile-project.js +1 -0
  98. package/dist/compiler/compile-project.js.map +1 -1
  99. package/dist/compiler/compile-project.test.js +94 -1
  100. package/dist/compiler/compile-project.test.js.map +1 -1
  101. package/dist/compiler/compile.js +36 -17
  102. package/dist/compiler/compile.js.map +1 -1
  103. package/dist/compiler/compile.test.js +70 -0
  104. package/dist/compiler/compile.test.js.map +1 -1
  105. package/dist/compiler/compiler-options.d.ts +41 -0
  106. package/dist/compiler/compiler-options.js.map +1 -1
  107. package/dist/compiler/output-structure/message-modules.js +1 -1
  108. package/dist/compiler/output-structure/message-modules.js.map +1 -1
  109. package/dist/compiler/registry.js +71 -13
  110. package/dist/compiler/registry.js.map +1 -1
  111. package/dist/compiler/registry.test.d.ts +1 -0
  112. package/dist/compiler/registry.test.js +291 -0
  113. package/dist/compiler/registry.test.js.map +1 -0
  114. package/dist/compiler/runtime/create-runtime.d.ts +2 -0
  115. package/dist/compiler/runtime/create-runtime.js +9 -0
  116. package/dist/compiler/runtime/create-runtime.js.map +1 -1
  117. package/dist/compiler/runtime/extract-locale-from-cookie.js +8 -1
  118. package/dist/compiler/runtime/extract-locale-from-cookie.js.map +1 -1
  119. package/dist/compiler/runtime/extract-locale-from-cookie.test.js +26 -0
  120. package/dist/compiler/runtime/extract-locale-from-cookie.test.js.map +1 -1
  121. package/dist/compiler/runtime/extract-locale-from-header.js +47 -5
  122. package/dist/compiler/runtime/extract-locale-from-header.js.map +1 -1
  123. package/dist/compiler/runtime/extract-locale-from-header.test.js +58 -0
  124. package/dist/compiler/runtime/extract-locale-from-header.test.js.map +1 -1
  125. package/dist/compiler/runtime/get-locale.js +7 -1
  126. package/dist/compiler/runtime/get-locale.js.map +1 -1
  127. package/dist/compiler/runtime/get-locale.test.js +95 -0
  128. package/dist/compiler/runtime/get-locale.test.js.map +1 -1
  129. package/dist/compiler/runtime/localize-href.d.ts +8 -0
  130. package/dist/compiler/runtime/localize-href.js +60 -0
  131. package/dist/compiler/runtime/localize-href.js.map +1 -1
  132. package/dist/compiler/runtime/localize-href.test.js +227 -1
  133. package/dist/compiler/runtime/localize-href.test.js.map +1 -1
  134. package/dist/compiler/runtime/localize-url.d.ts +8 -4
  135. package/dist/compiler/runtime/localize-url.js +12 -8
  136. package/dist/compiler/runtime/localize-url.js.map +1 -1
  137. package/dist/compiler/runtime/localize-url.test.js +45 -0
  138. package/dist/compiler/runtime/localize-url.test.js.map +1 -1
  139. package/dist/compiler/runtime/set-locale.js +24 -6
  140. package/dist/compiler/runtime/set-locale.js.map +1 -1
  141. package/dist/compiler/runtime/set-locale.test.js +182 -0
  142. package/dist/compiler/runtime/set-locale.test.js.map +1 -1
  143. package/dist/compiler/runtime/type.d.ts +2 -0
  144. package/dist/compiler/runtime/type.js.map +1 -1
  145. package/dist/compiler/runtime/type.test.js +75 -0
  146. package/dist/compiler/runtime/type.test.js.map +1 -1
  147. package/dist/compiler/runtime/variables.d.ts +2 -0
  148. package/dist/compiler/runtime/variables.js +7 -0
  149. package/dist/compiler/runtime/variables.js.map +1 -1
  150. package/dist/compiler/server/middleware.d.ts +8 -2
  151. package/dist/compiler/server/middleware.js +175 -7
  152. package/dist/compiler/server/middleware.js.map +1 -1
  153. package/dist/compiler/server/middleware.test.js +750 -3
  154. package/dist/compiler/server/middleware.test.js.map +1 -1
  155. package/dist/eslint/index.d.ts +4 -0
  156. package/dist/eslint/index.js +8 -0
  157. package/dist/eslint/index.js.map +1 -0
  158. package/dist/eslint/no-dynamic-message-access.d.ts +3 -0
  159. package/dist/eslint/no-dynamic-message-access.js +150 -0
  160. package/dist/eslint/no-dynamic-message-access.js.map +1 -0
  161. package/dist/eslint/no-dynamic-message-access.test.d.ts +1 -0
  162. package/dist/eslint/no-dynamic-message-access.test.js +126 -0
  163. package/dist/eslint/no-dynamic-message-access.test.js.map +1 -0
  164. package/dist/eslint/oxlint.test.d.ts +1 -0
  165. package/dist/eslint/oxlint.test.js +64 -0
  166. package/dist/eslint/oxlint.test.js.map +1 -0
  167. package/dist/services/config/config-schema.d.ts +2 -0
  168. package/dist/services/config/config-schema.js +2 -0
  169. package/dist/services/config/config-schema.js.map +1 -1
  170. package/dist/services/config/load-paraglide-config.test.js +12 -0
  171. package/dist/services/config/load-paraglide-config.test.js.map +1 -1
  172. package/dist/services/env-variables/index.js +1 -1
  173. package/dist/services/env-variables/index.js.map +1 -1
  174. package/dist/services/file-handling/write-output.bench.js +51 -11
  175. package/dist/services/file-handling/write-output.bench.js.map +1 -1
  176. package/dist/services/file-handling/write-output.js +60 -20
  177. package/dist/services/file-handling/write-output.js.map +1 -1
  178. package/dist/services/file-handling/write-output.test.js +175 -0
  179. package/dist/services/file-handling/write-output.test.js.map +1 -1
  180. package/package.json +14 -4
@@ -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,SAAS,EAAE,kBAAkB;gBAC7B,MAAM,EAAE,IAAI;gBACZ,SAAS,EAAE,EAAE;gBACb,QAAQ,EAAE;oBACT;wBACC,EAAE,EAAE,GAAG;wBACP,UAAU,EAAE,YAAY;wBACxB,OAAO,EAAE,EAAE;wBACX,OAAO,EAAE;4BACR,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE;4BAChC;gCACC,IAAI,EAAE,YAAY;gCAClB,GAAG,EAAE,EAAE,IAAI,EAAE,oBA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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\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\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\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\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\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\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\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\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\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\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"]}
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,MAA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AG,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":["../../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AC9D,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"]}
@@ -77,7 +77,7 @@ test("compiles a local variable with an annotation and empty options", () => {
77
77
  },
78
78
  },
79
79
  });
80
- expect(code).toEqual('const myVar = registry.number("en", "Hello", {});');
80
+ expect(code).toEqual('const myVar = registry.number("en", "Hello", {}, true);');
81
81
  });
82
82
  test("interpolates the raw value for an unknown annotation, like a pattern", () => {
83
83
  const code = compileLocalVariable({
@@ -123,7 +123,7 @@ test("compiles a local variable with an annotation and options", () => {
123
123
  },
124
124
  },
125
125
  });
126
- expect(code).toEqual('const myVar = registry.number("en", "Hello", { option1: "value1", option2: i?.varRef });');
126
+ expect(code).toEqual('const myVar = registry.number("en", "Hello", { option1: "value1", option2: i?.varRef }, true);');
127
127
  });
128
128
  test("compiles formatter options referencing earlier local variables", () => {
129
129
  const code = compileLocalVariable({
@@ -155,7 +155,7 @@ test("compiles formatter options referencing earlier local variables", () => {
155
155
  },
156
156
  },
157
157
  });
158
- 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);');
159
159
  });
160
160
  test("compiles number formatter fraction digit options as numeric literals", () => {
161
161
  const code = compileLocalVariable({
@@ -183,7 +183,7 @@ test("compiles number formatter fraction digit options as numeric literals", ()
183
183
  },
184
184
  },
185
185
  });
186
- 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);');
187
187
  });
188
188
  test("compiles number formatter useGrouping option as boolean literal", () => {
189
189
  const code = compileLocalVariable({
@@ -207,7 +207,7 @@ test("compiles number formatter useGrouping option as boolean literal", () => {
207
207
  },
208
208
  },
209
209
  });
210
- 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);');
211
211
  });
212
212
  test("keeps negative digit options as strings to avoid emitting invalid numeric literals", () => {
213
213
  const code = compileLocalVariable({
@@ -231,7 +231,7 @@ test("keeps negative digit options as strings to avoid emitting invalid numeric
231
231
  },
232
232
  },
233
233
  });
234
- 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);');
235
235
  });
236
236
  test("compiles relative time formatter with a literal unit", () => {
237
237
  const code = compileLocalVariable({
@@ -254,7 +254,7 @@ test("compiles relative time formatter with a literal unit", () => {
254
254
  },
255
255
  },
256
256
  });
257
- 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);');
258
258
  });
259
259
  test("compiles relative time formatter with a dynamic unit cast", () => {
260
260
  const code = compileLocalVariable({
@@ -279,7 +279,7 @@ test("compiles relative time formatter with a dynamic unit cast", () => {
279
279
  },
280
280
  },
281
281
  });
282
- 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);');
283
283
  });
284
284
  test("throws if relative time formatter is missing a unit option", () => {
285
285
  expect(() => compileLocalVariable({
@@ -359,7 +359,7 @@ test("accepts plural relative time formatter units", () => {
359
359
  },
360
360
  },
361
361
  });
362
- 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);');
363
363
  });
364
364
  test("accepts dynamic relative time formatter units", () => {
365
365
  const code = compileLocalVariable({
@@ -383,7 +383,7 @@ test("accepts dynamic relative time formatter units", () => {
383
383
  },
384
384
  },
385
385
  });
386
- 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);');
387
387
  });
388
388
  test("accepts dollar-prefixed relative time formatter unit options from message files", () => {
389
389
  const code = compileLocalVariable({
@@ -404,7 +404,7 @@ test("accepts dollar-prefixed relative time formatter unit options from message
404
404
  },
405
405
  },
406
406
  });
407
- 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);');
408
408
  });
409
409
  test("compiles dollar-prefixed relative time units referencing local variables", () => {
410
410
  const code = compileLocalVariable({
@@ -433,7 +433,7 @@ test("compiles dollar-prefixed relative time units referencing local variables",
433
433
  },
434
434
  },
435
435
  });
436
- 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);');
437
437
  });
438
438
  test("accepts dollar-prefixed relative time formatter unit options with non-identifier input names", () => {
439
439
  const code = compileLocalVariable({
@@ -457,7 +457,7 @@ test("accepts dollar-prefixed relative time formatter unit options with non-iden
457
457
  },
458
458
  },
459
459
  });
460
- 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
461
  });
462
462
  test.each([
463
463
  ["date", '{ dateStyle: "medium" }'],
@@ -476,6 +476,6 @@ test.each([
476
476
  },
477
477
  },
478
478
  });
479
- expect(code).toBe(`const formatted = registry.datetime("en", i?.d, ${options});`);
479
+ expect(code).toBe(`const formatted = registry.datetime("en", i?.d, ${options}, true);`);
480
480
  });
481
481
  //# sourceMappingURL=compile-local-variable.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"compile-local-variable.test.js","sourceRoot":"","sources":["../../src/compiler/compile-local-variable.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAEnE,IAAI,CAAC,mCAAmC,EAAE,GAAG,EAAE;IAC9C,MAAM,IAAI,GAAG,oBAAoB,CAAC;QACjC,MAAM,EAAE,IAAI;QACZ,WAAW,EAAE;YACZ,IAAI,EAAE,gBAAgB;YACtB,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;SACvE;KACD,CAAC,CAAC;IACH,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,wBAAwB,CAAC,CAAC;AAChD,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,8CAA8C,EAAE,GAAG,EAAE;IACzD,MAAM,IAAI,GAAG,oBAAoB,CAAC;QACjC,MAAM,EAAE,IAAI;QACZ,WAAW,EAAE;YACZ,IAAI,EAAE,gBAAgB;YACtB,IAAI,EAAE,OAAO;YACb,KAAK,EAAE;gBACN,IAAI,EAAE,YAAY;gBAClB,GAAG,EAAE,EAAE,IAAI,EAAE,oBAAoB,EAAE,IAAI,EAAE,MAAM,EAAE;aACjD;SACD;KACD,CAAC,CAAC;IACH,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,wBAAwB,CAAC,CAAC;AAChD,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,4DAA4D,EAAE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BACX,IAAI,EAAE,oBAAoB;oBAC1B,IAAI,EAAE,cAAc;oBACpB,OAAO,EAAE;wBACR;4BACC,IAAI,EAAE,MAAM;4BACZ,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,gBAAgB,EAAE;yBACnD;qBACD;iBACD;aACD;SACD;KACD,CAAC,CAAC;IAEH,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,CACnB,sKAAsK,CACtK,CAAC;AACH,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,IAAI,CAAC;IACT,CAAC,MAAM,EAAE,yBAAyB,CAAC;IACnC,CAAC,MAAM,EAAE,yBAAyB,CAAC;IACnC,CAAC,UAAU,EAAE,6CAA6C,CAAC;CAC3D,CAAC,CAAC,qDAAqD,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE;IAC3E,MAAM,IAAI,GAAG,oBAAoB,CAAC;QACjC,MAAM,EAAE,IAAI;QACZ,WAAW,EAAE;YACZ,IAAI,EAAE,gBAAgB;YACtB,IAAI,EAAE,WAAW;YACjB,KAAK,EAAE;gBACN,IAAI,EAAE,YAAY;gBAClB,GAAG,EAAE,EAAE,IAAI,EAAE,oBAAoB,EAAE,IAAI,EAAE,GAAG,EAAE;gBAC9C,UAAU,EAAE,EAAE,IAAI,EAAE,oBAAoB,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE;aAC7D;SACD;KACD,CAAC,CAAC;IACH,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAChB,mDAAmD,OAAO,IAAI,CAC9D,CAAC;AACH,CAAC,CAAC,CAAC","sourcesContent":["import { test, expect } from \"vitest\";\nimport { compileLocalVariable } from \"./compile-local-variable.js\";\n\ntest(\"compiles a literal local variable\", () => {\n\tconst code = compileLocalVariable({\n\t\tlocale: \"en\",\n\t\tdeclaration: {\n\t\t\ttype: \"local-variable\",\n\t\t\tname: \"myVar\",\n\t\t\tvalue: { type: \"expression\", arg: { type: \"literal\", value: \"Hello\" } },\n\t\t},\n\t});\n\texpect(code).toEqual('const myVar = \"Hello\";');\n});\n\ntest(\"compiles a variable reference local variable\", () => {\n\tconst code = compileLocalVariable({\n\t\tlocale: \"en\",\n\t\tdeclaration: {\n\t\t\ttype: \"local-variable\",\n\t\t\tname: \"myVar\",\n\t\t\tvalue: {\n\t\t\t\ttype: \"expression\",\n\t\t\t\targ: { type: \"variable-reference\", name: \"name\" },\n\t\t\t},\n\t\t},\n\t});\n\texpect(code).toEqual(\"const myVar = i?.name;\");\n});\n\ntest(\"compiles a variable reference to an earlier local variable\", () => {\n\tconst code = compileLocalVariable({\n\t\tlocale: \"en\",\n\t\tdeclarations: [\n\t\t\t{\n\t\t\t\ttype: \"local-variable\",\n\t\t\t\tname: \"earlierLocal\",\n\t\t\t\tvalue: { type: \"expression\", arg: { type: \"literal\", value: \"42\" } },\n\t\t\t},\n\t\t],\n\t\tdeclaration: {\n\t\t\ttype: \"local-variable\",\n\t\t\tname: \"myVar\",\n\t\t\tvalue: {\n\t\t\t\ttype: \"expression\",\n\t\t\t\targ: { type: \"variable-reference\", name: \"earlierLocal\" },\n\t\t\t},\n\t\t},\n\t});\n\n\texpect(code).toEqual(\"const myVar = earlierLocal;\");\n});\n\ntest(\"compiles a variable reference local variable with a non-identifier name\", () => {\n\tconst code = compileLocalVariable({\n\t\tlocale: \"en\",\n\t\tdeclaration: {\n\t\t\ttype: \"local-variable\",\n\t\t\tname: \"myVar\",\n\t\t\tvalue: {\n\t\t\t\ttype: \"expression\",\n\t\t\t\targ: { type: \"variable-reference\", name: \"half!\" },\n\t\t\t},\n\t\t},\n\t});\n\texpect(code).toEqual('const myVar = i?.[\"half!\"];');\n});\n\ntest(\"compiles a local variable with an annotation and empty options\", () => {\n\tconst code = compileLocalVariable({\n\t\tlocale: \"en\",\n\t\tdeclaration: {\n\t\t\ttype: \"local-variable\",\n\t\t\tname: \"myVar\",\n\t\t\tvalue: {\n\t\t\t\ttype: \"expression\",\n\t\t\t\targ: { type: \"literal\", value: \"Hello\" },\n\t\t\t\tannotation: {\n\t\t\t\t\ttype: \"function-reference\",\n\t\t\t\t\tname: \"number\",\n\t\t\t\t\toptions: [],\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t});\n\texpect(code).toEqual('const myVar = registry.number(\"en\", \"Hello\", {});');\n});\n\ntest(\"interpolates the raw value for an unknown annotation, like a pattern\", () => {\n\tconst code = compileLocalVariable({\n\t\tlocale: \"en\",\n\t\tdeclaration: {\n\t\t\ttype: \"local-variable\",\n\t\t\tname: \"myVar\",\n\t\t\tvalue: {\n\t\t\t\ttype: \"expression\",\n\t\t\t\targ: { type: \"variable-reference\", name: \"amount\" },\n\t\t\t\tannotation: {\n\t\t\t\t\ttype: \"function-reference\",\n\t\t\t\t\tname: \"myFunction\",\n\t\t\t\t\toptions: [\n\t\t\t\t\t\t{ name: \"option1\", value: { type: \"literal\", value: \"value1\" } },\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t});\n\texpect(code).toEqual(\"const myVar = i?.amount;\");\n});\n\ntest(\"compiles a local variable with an annotation and options\", () => {\n\tconst code = compileLocalVariable({\n\t\tlocale: \"en\",\n\t\tdeclaration: {\n\t\t\ttype: \"local-variable\",\n\t\t\tname: \"myVar\",\n\t\t\tvalue: {\n\t\t\t\ttype: \"expression\",\n\t\t\t\targ: { type: \"literal\", value: \"Hello\" },\n\t\t\t\tannotation: {\n\t\t\t\t\ttype: \"function-reference\",\n\t\t\t\t\tname: \"number\",\n\t\t\t\t\toptions: [\n\t\t\t\t\t\t{ name: \"option1\", value: { type: \"literal\", value: \"value1\" } },\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tname: \"option2\",\n\t\t\t\t\t\t\tvalue: { type: \"variable-reference\", name: \"varRef\" },\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\texpect(code).toEqual(\n\t\t'const myVar = registry.number(\"en\", \"Hello\", { option1: \"value1\", option2: i?.varRef });'\n\t);\n});\n\ntest(\"compiles formatter options referencing earlier local variables\", () => {\n\tconst code = compileLocalVariable({\n\t\tlocale: \"en\",\n\t\tdeclarations: [\n\t\t\t{ type: \"input-variable\", name: \"amount\" },\n\t\t\t{\n\t\t\t\ttype: \"local-variable\",\n\t\t\t\tname: \"digits\",\n\t\t\t\tvalue: { type: \"expression\", arg: { type: \"literal\", value: \"2\" } },\n\t\t\t},\n\t\t],\n\t\tdeclaration: {\n\t\t\ttype: \"local-variable\",\n\t\t\tname: \"formattedAmount\",\n\t\t\tvalue: {\n\t\t\t\ttype: \"expression\",\n\t\t\t\targ: { type: \"variable-reference\", name: \"amount\" },\n\t\t\t\tannotation: {\n\t\t\t\t\ttype: \"function-reference\",\n\t\t\t\t\tname: \"number\",\n\t\t\t\t\toptions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tname: \"minimumFractionDigits\",\n\t\t\t\t\t\t\tvalue: { type: \"variable-reference\", name: \"digits\" },\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\texpect(code).toEqual(\n\t\t'const formattedAmount = registry.number(\"en\", i?.amount, { minimumFractionDigits: digits });'\n\t);\n});\n\ntest(\"compiles number formatter fraction digit options as numeric literals\", () => {\n\tconst code = compileLocalVariable({\n\t\tlocale: \"en\",\n\t\tdeclaration: {\n\t\t\ttype: \"local-variable\",\n\t\t\tname: \"formattedValue\",\n\t\t\tvalue: {\n\t\t\t\ttype: \"expression\",\n\t\t\t\targ: { type: \"variable-reference\", name: \"value\" },\n\t\t\t\tannotation: {\n\t\t\t\t\ttype: \"function-reference\",\n\t\t\t\t\tname: \"number\",\n\t\t\t\t\toptions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tname: \"minimumFractionDigits\",\n\t\t\t\t\t\t\tvalue: { type: \"literal\", value: \"1\" },\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tname: \"maximumFractionDigits\",\n\t\t\t\t\t\t\tvalue: { type: \"literal\", value: \"1\" },\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\texpect(code).toEqual(\n\t\t'const formattedValue = registry.number(\"en\", i?.value, { minimumFractionDigits: 1, maximumFractionDigits: 1 });'\n\t);\n});\n\ntest(\"compiles number formatter useGrouping option as boolean literal\", () => {\n\tconst code = compileLocalVariable({\n\t\tlocale: \"en\",\n\t\tdeclaration: {\n\t\t\ttype: \"local-variable\",\n\t\t\tname: \"formattedValue\",\n\t\t\tvalue: {\n\t\t\t\ttype: \"expression\",\n\t\t\t\targ: { type: \"variable-reference\", name: \"value\" },\n\t\t\t\tannotation: {\n\t\t\t\t\ttype: \"function-reference\",\n\t\t\t\t\tname: \"number\",\n\t\t\t\t\toptions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tname: \"useGrouping\",\n\t\t\t\t\t\t\tvalue: { type: \"literal\", value: \"false\" },\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\texpect(code).toEqual(\n\t\t'const formattedValue = registry.number(\"en\", i?.value, { useGrouping: false });'\n\t);\n});\n\ntest(\"keeps negative digit options as strings to avoid emitting invalid numeric literals\", () => {\n\tconst code = compileLocalVariable({\n\t\tlocale: \"en\",\n\t\tdeclaration: {\n\t\t\ttype: \"local-variable\",\n\t\t\tname: \"formattedValue\",\n\t\t\tvalue: {\n\t\t\t\ttype: \"expression\",\n\t\t\t\targ: { type: \"variable-reference\", name: \"value\" },\n\t\t\t\tannotation: {\n\t\t\t\t\ttype: \"function-reference\",\n\t\t\t\t\tname: \"number\",\n\t\t\t\t\toptions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tname: \"minimumFractionDigits\",\n\t\t\t\t\t\t\tvalue: { type: \"literal\", value: \"-1\" },\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\texpect(code).toEqual(\n\t\t'const formattedValue = registry.number(\"en\", i?.value, { minimumFractionDigits: \"-1\" });'\n\t);\n});\n\ntest(\"compiles relative time formatter with a literal unit\", () => {\n\tconst code = compileLocalVariable({\n\t\tlocale: \"en\",\n\t\tdeclaration: {\n\t\t\ttype: \"local-variable\",\n\t\t\tname: \"formattedDuration\",\n\t\t\tvalue: {\n\t\t\t\ttype: \"expression\",\n\t\t\t\targ: { type: \"variable-reference\", name: \"duration\" },\n\t\t\t\tannotation: {\n\t\t\t\t\ttype: \"function-reference\",\n\t\t\t\t\tname: \"relativetime\",\n\t\t\t\t\toptions: [\n\t\t\t\t\t\t{ name: \"unit\", value: { type: \"literal\", value: \"day\" } },\n\t\t\t\t\t\t{ name: \"numeric\", value: { type: \"literal\", value: \"auto\" } },\n\t\t\t\t\t\t{ name: \"style\", value: { type: \"literal\", value: \"short\" } },\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t});\n\n\texpect(code).toEqual(\n\t\t'const formattedDuration = registry.relativetime(\"en\", i?.duration, { unit: \"day\", numeric: \"auto\", style: \"short\" });'\n\t);\n});\n\ntest(\"compiles relative time formatter with a dynamic unit cast\", () => {\n\tconst code = compileLocalVariable({\n\t\tlocale: \"en\",\n\t\tdeclaration: {\n\t\t\ttype: \"local-variable\",\n\t\t\tname: \"formattedDuration\",\n\t\t\tvalue: {\n\t\t\t\ttype: \"expression\",\n\t\t\t\targ: { type: \"variable-reference\", name: \"duration\" },\n\t\t\t\tannotation: {\n\t\t\t\t\ttype: \"function-reference\",\n\t\t\t\t\tname: \"relativetime\",\n\t\t\t\t\toptions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tname: \"unit\",\n\t\t\t\t\t\t\tvalue: { type: \"variable-reference\", name: \"unit\" },\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{ name: \"style\", value: { type: \"literal\", value: \"short\" } },\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t});\n\n\texpect(code).toEqual(\n\t\t'const formattedDuration = registry.relativetime(\"en\", i?.duration, { unit: /** @type {import(\"../registry.js\").RelativeTimeFormatUnit} */ (i?.unit), style: \"short\" });'\n\t);\n});\n\ntest(\"throws if relative time formatter is missing a unit option\", () => {\n\texpect(() =>\n\t\tcompileLocalVariable({\n\t\t\tlocale: \"en\",\n\t\t\tdeclaration: {\n\t\t\t\ttype: \"local-variable\",\n\t\t\t\tname: \"formattedDuration\",\n\t\t\t\tvalue: {\n\t\t\t\t\ttype: \"expression\",\n\t\t\t\t\targ: { type: \"variable-reference\", name: \"duration\" },\n\t\t\t\t\tannotation: {\n\t\t\t\t\t\ttype: \"function-reference\",\n\t\t\t\t\t\tname: \"relativetime\",\n\t\t\t\t\t\toptions: [],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t})\n\t).toThrow('The \"relativetime\" formatter requires a \"unit\" option.');\n});\n\ntest(\"throws if relative time formatter has duplicate unit options\", () => {\n\texpect(() =>\n\t\tcompileLocalVariable({\n\t\t\tlocale: \"en\",\n\t\t\tdeclaration: {\n\t\t\t\ttype: \"local-variable\",\n\t\t\t\tname: \"formattedDuration\",\n\t\t\t\tvalue: {\n\t\t\t\t\ttype: \"expression\",\n\t\t\t\t\targ: { type: \"variable-reference\", name: \"duration\" },\n\t\t\t\t\tannotation: {\n\t\t\t\t\t\ttype: \"function-reference\",\n\t\t\t\t\t\tname: \"relativetime\",\n\t\t\t\t\t\toptions: [\n\t\t\t\t\t\t\t{ name: \"unit\", value: { type: \"literal\", value: \"day\" } },\n\t\t\t\t\t\t\t{ name: \"unit\", value: { type: \"literal\", value: \"hour\" } },\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).toThrow('The \"relativetime\" formatter requires exactly one \"unit\" option.');\n});\n\ntest(\"throws if relative time formatter has an invalid literal unit\", () => {\n\texpect(() =>\n\t\tcompileLocalVariable({\n\t\t\tlocale: \"en\",\n\t\t\tdeclaration: {\n\t\t\t\ttype: \"local-variable\",\n\t\t\t\tname: \"formattedDuration\",\n\t\t\t\tvalue: {\n\t\t\t\t\ttype: \"expression\",\n\t\t\t\t\targ: { type: \"variable-reference\", name: \"duration\" },\n\t\t\t\t\tannotation: {\n\t\t\t\t\t\ttype: \"function-reference\",\n\t\t\t\t\t\tname: \"relativetime\",\n\t\t\t\t\t\toptions: [\n\t\t\t\t\t\t\t{ name: \"unit\", value: { type: \"literal\", value: \"century\" } },\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).toThrow('Invalid \"relativetime\" unit \"century\".');\n});\n\ntest(\"accepts plural relative time formatter units\", () => {\n\tconst code = compileLocalVariable({\n\t\tlocale: \"en\",\n\t\tdeclaration: {\n\t\t\ttype: \"local-variable\",\n\t\t\tname: \"formattedDuration\",\n\t\t\tvalue: {\n\t\t\t\ttype: \"expression\",\n\t\t\t\targ: { type: \"variable-reference\", name: \"duration\" },\n\t\t\t\tannotation: {\n\t\t\t\t\ttype: \"function-reference\",\n\t\t\t\t\tname: \"relativetime\",\n\t\t\t\t\toptions: [\n\t\t\t\t\t\t{ name: \"unit\", value: { type: \"literal\", value: \"days\" } },\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t});\n\n\texpect(code).toEqual(\n\t\t'const formattedDuration = registry.relativetime(\"en\", i?.duration, { unit: \"days\" });'\n\t);\n});\n\ntest(\"accepts dynamic relative time formatter units\", () => {\n\tconst code = compileLocalVariable({\n\t\tlocale: \"en\",\n\t\tdeclaration: {\n\t\t\ttype: \"local-variable\",\n\t\t\tname: \"formattedDuration\",\n\t\t\tvalue: {\n\t\t\t\ttype: \"expression\",\n\t\t\t\targ: { type: \"variable-reference\", name: \"duration\" },\n\t\t\t\tannotation: {\n\t\t\t\t\ttype: \"function-reference\",\n\t\t\t\t\tname: \"relativetime\",\n\t\t\t\t\toptions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tname: \"unit\",\n\t\t\t\t\t\t\tvalue: { type: \"variable-reference\", name: \"unit\" },\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\texpect(code).toEqual(\n\t\t'const formattedDuration = registry.relativetime(\"en\", i?.duration, { unit: /** @type {import(\"../registry.js\").RelativeTimeFormatUnit} */ (i?.unit) });'\n\t);\n});\n\ntest(\"accepts dollar-prefixed relative time formatter unit options from message files\", () => {\n\tconst code = compileLocalVariable({\n\t\tlocale: \"en\",\n\t\tdeclaration: {\n\t\t\ttype: \"local-variable\",\n\t\t\tname: \"formattedDuration\",\n\t\t\tvalue: {\n\t\t\t\ttype: \"expression\",\n\t\t\t\targ: { type: \"variable-reference\", name: \"duration\" },\n\t\t\t\tannotation: {\n\t\t\t\t\ttype: \"function-reference\",\n\t\t\t\t\tname: \"relativetime\",\n\t\t\t\t\toptions: [\n\t\t\t\t\t\t{ name: \"unit\", value: { type: \"literal\", value: \"$unit\" } },\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t});\n\n\texpect(code).toEqual(\n\t\t'const formattedDuration = registry.relativetime(\"en\", i?.duration, { unit: /** @type {import(\"../registry.js\").RelativeTimeFormatUnit} */ (i?.unit) });'\n\t);\n});\n\ntest(\"compiles dollar-prefixed relative time units referencing local variables\", () => {\n\tconst code = compileLocalVariable({\n\t\tlocale: \"en\",\n\t\tdeclarations: [\n\t\t\t{ type: \"input-variable\", name: \"duration\" },\n\t\t\t{\n\t\t\t\ttype: \"local-variable\",\n\t\t\t\tname: \"localUnit\",\n\t\t\t\tvalue: { type: \"expression\", arg: { type: \"literal\", value: \"day\" } },\n\t\t\t},\n\t\t],\n\t\tdeclaration: {\n\t\t\ttype: \"local-variable\",\n\t\t\tname: \"formattedDuration\",\n\t\t\tvalue: {\n\t\t\t\ttype: \"expression\",\n\t\t\t\targ: { type: \"variable-reference\", name: \"duration\" },\n\t\t\t\tannotation: {\n\t\t\t\t\ttype: \"function-reference\",\n\t\t\t\t\tname: \"relativetime\",\n\t\t\t\t\toptions: [\n\t\t\t\t\t\t{ name: \"unit\", value: { type: \"literal\", value: \"$localUnit\" } },\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t});\n\n\texpect(code).toEqual(\n\t\t'const formattedDuration = registry.relativetime(\"en\", i?.duration, { unit: /** @type {import(\"../registry.js\").RelativeTimeFormatUnit} */ (localUnit) });'\n\t);\n});\n\ntest(\"accepts dollar-prefixed relative time formatter unit options with non-identifier input names\", () => {\n\tconst code = compileLocalVariable({\n\t\tlocale: \"en\",\n\t\tdeclaration: {\n\t\t\ttype: \"local-variable\",\n\t\t\tname: \"formattedDuration\",\n\t\t\tvalue: {\n\t\t\t\ttype: \"expression\",\n\t\t\t\targ: { type: \"variable-reference\", name: \"duration\" },\n\t\t\t\tannotation: {\n\t\t\t\t\ttype: \"function-reference\",\n\t\t\t\t\tname: \"relativetime\",\n\t\t\t\t\toptions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tname: \"unit\",\n\t\t\t\t\t\t\tvalue: { type: \"literal\", value: \"$relative-unit\" },\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\texpect(code).toEqual(\n\t\t'const formattedDuration = registry.relativetime(\"en\", i?.duration, { unit: /** @type {import(\"../registry.js\").RelativeTimeFormatUnit} */ (i?.[\"relative-unit\"]) });'\n\t);\n});\n\ntest.each([\n\t[\"date\", '{ dateStyle: \"medium\" }'],\n\t[\"time\", '{ timeStyle: \"medium\" }'],\n\t[\"datetime\", '{ dateStyle: \"medium\", timeStyle: \"short\" }'],\n])(\"compiles a %s local variable with its default style\", (name, options) => {\n\tconst code = compileLocalVariable({\n\t\tlocale: \"en\",\n\t\tdeclaration: {\n\t\t\ttype: \"local-variable\",\n\t\t\tname: \"formatted\",\n\t\t\tvalue: {\n\t\t\t\ttype: \"expression\",\n\t\t\t\targ: { type: \"variable-reference\", name: \"d\" },\n\t\t\t\tannotation: { type: \"function-reference\", name, options: [] },\n\t\t\t},\n\t\t},\n\t});\n\texpect(code).toBe(\n\t\t`const formatted = registry.datetime(\"en\", i?.d, ${options});`\n\t);\n});\n"]}
1
+ {"version":3,"file":"compile-local-variable.test.js","sourceRoot":"","sources":["../../src/compiler/compile-local-variable.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAEnE,IAAI,CAAC,mCAAmC,EAAE,GAAG,EAAE;IAC9C,MAAM,IAAI,GAAG,oBAAoB,CAAC;QACjC,MAAM,EAAE,IAAI;QACZ,WAAW,EAAE;YACZ,IAAI,EAAE,gBAAgB;YACtB,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;SACvE;KACD,CAAC,CAAC;IACH,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,wBAAwB,CAAC,CAAC;AAChD,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,8CAA8C,EAAE,GAAG,EAAE;IACzD,MAAM,IAAI,GAAG,oBAAoB,CAAC;QACjC,MAAM,EAAE,IAAI;QACZ,WAAW,EAAE;YACZ,IAAI,EAAE,gBAAgB;YACtB,IAAI,EAAE,OAAO;YACb,KAAK,EAAE;gBACN,IAAI,EAAE,YAAY;gBAClB,GAAG,EAAE,EAAE,IAAI,EAAE,oBAAoB,EAAE,IAAI,EAAE,MAAM,EAAE;aACjD;SACD;KACD,CAAC,CAAC;IACH,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,wBAAwB,CAAC,CAAC;A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AAE,IAAI,EAAE,UAAU,EAAE;gBACrD,UAAU,EAAE;oBACX,IAAI,EAAE,oBAAoB;oBAC1B,IAAI,EAAE,cAAc;oBACpB,OAAO,EAAE;wBACR;4BACC,IAAI,EAAE,MAAM;4BACZ,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,gBAAgB,EAAE;yBACnD;qBACD;iBACD;aACD;SACD;KACD,CAAC,CAAC;IAEH,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,CACnB,4KAA4K,CAC5K,CAAC;AACH,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,IAAI,CAAC;IACT,CAAC,MAAM,EAAE,yBAAyB,CAAC;IACnC,CAAC,MAAM,EAAE,yBAAyB,CAAC;IACnC,CAAC,UAAU,EAAE,6CAA6C,CAAC;CAC3D,CAAC,CAAC,qDAAqD,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE;IAC3E,MAAM,IAAI,GAAG,oBAAoB,CAAC;QACjC,MAAM,EAAE,IAAI;QACZ,WAAW,EAAE;YACZ,IAAI,EAAE,gBAAgB;YACtB,IAAI,EAAE,WAAW;YACjB,KAAK,EAAE;gBACN,IAAI,EAAE,YAAY;gBAClB,GAAG,EAAE,EAAE,IAAI,EAAE,oBAAoB,EAAE,IAAI,EAAE,GAAG,EAAE;gBAC9C,UAAU,EAAE,EAAE,IAAI,EAAE,oBAAoB,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE;aAC7D;SACD;KACD,CAAC,CAAC;IACH,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAChB,mDAAmD,OAAO,UAAU,CACpE,CAAC;AACH,CAAC,CAAC,CAAC","sourcesContent":["import { test, expect } from \"vitest\";\nimport { compileLocalVariable } from \"./compile-local-variable.js\";\n\ntest(\"compiles a literal local variable\", () => {\n\tconst code = compileLocalVariable({\n\t\tlocale: \"en\",\n\t\tdeclaration: {\n\t\t\ttype: \"local-variable\",\n\t\t\tname: \"myVar\",\n\t\t\tvalue: { type: \"expression\", arg: { type: \"literal\", value: \"Hello\" } },\n\t\t},\n\t});\n\texpect(code).toEqual('const myVar = \"Hello\";');\n});\n\ntest(\"compiles a variable reference local variable\", () => {\n\tconst code = compileLocalVariable({\n\t\tlocale: \"en\",\n\t\tdeclaration: {\n\t\t\ttype: \"local-variable\",\n\t\t\tname: \"myVar\",\n\t\t\tvalue: {\n\t\t\t\ttype: \"expression\",\n\t\t\t\targ: { type: \"variable-reference\", name: \"name\" },\n\t\t\t},\n\t\t},\n\t});\n\texpect(code).toEqual(\"const myVar = i?.name;\");\n});\n\ntest(\"compiles a variable reference to an earlier local variable\", () => {\n\tconst code = compileLocalVariable({\n\t\tlocale: \"en\",\n\t\tdeclarations: [\n\t\t\t{\n\t\t\t\ttype: \"local-variable\",\n\t\t\t\tname: \"earlierLocal\",\n\t\t\t\tvalue: { type: \"expression\", arg: { type: \"literal\", value: \"42\" } },\n\t\t\t},\n\t\t],\n\t\tdeclaration: {\n\t\t\ttype: \"local-variable\",\n\t\t\tname: \"myVar\",\n\t\t\tvalue: {\n\t\t\t\ttype: \"expression\",\n\t\t\t\targ: { type: \"variable-reference\", name: \"earlierLocal\" },\n\t\t\t},\n\t\t},\n\t});\n\n\texpect(code).toEqual(\"const myVar = earlierLocal;\");\n});\n\ntest(\"compiles a variable reference local variable with a non-identifier name\", () => {\n\tconst code = compileLocalVariable({\n\t\tlocale: \"en\",\n\t\tdeclaration: {\n\t\t\ttype: \"local-variable\",\n\t\t\tname: \"myVar\",\n\t\t\tvalue: {\n\t\t\t\ttype: \"expression\",\n\t\t\t\targ: { type: \"variable-reference\", name: \"half!\" },\n\t\t\t},\n\t\t},\n\t});\n\texpect(code).toEqual('const myVar = i?.[\"half!\"];');\n});\n\ntest(\"compiles a local variable with an annotation and empty options\", () => {\n\tconst code = compileLocalVariable({\n\t\tlocale: \"en\",\n\t\tdeclaration: {\n\t\t\ttype: \"local-variable\",\n\t\t\tname: \"myVar\",\n\t\t\tvalue: {\n\t\t\t\ttype: \"expression\",\n\t\t\t\targ: { type: \"literal\", value: \"Hello\" },\n\t\t\t\tannotation: {\n\t\t\t\t\ttype: \"function-reference\",\n\t\t\t\t\tname: \"number\",\n\t\t\t\t\toptions: [],\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t});\n\texpect(code).toEqual('const myVar = registry.number(\"en\", \"Hello\", {}, true);');\n});\n\ntest(\"interpolates the raw value for an unknown annotation, like a pattern\", () => {\n\tconst code = compileLocalVariable({\n\t\tlocale: \"en\",\n\t\tdeclaration: {\n\t\t\ttype: \"local-variable\",\n\t\t\tname: \"myVar\",\n\t\t\tvalue: {\n\t\t\t\ttype: \"expression\",\n\t\t\t\targ: { type: \"variable-reference\", name: \"amount\" },\n\t\t\t\tannotation: {\n\t\t\t\t\ttype: \"function-reference\",\n\t\t\t\t\tname: \"myFunction\",\n\t\t\t\t\toptions: [\n\t\t\t\t\t\t{ name: \"option1\", value: { type: \"literal\", value: \"value1\" } },\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t});\n\texpect(code).toEqual(\"const myVar = i?.amount;\");\n});\n\ntest(\"compiles a local variable with an annotation and options\", () => {\n\tconst code = compileLocalVariable({\n\t\tlocale: \"en\",\n\t\tdeclaration: {\n\t\t\ttype: \"local-variable\",\n\t\t\tname: \"myVar\",\n\t\t\tvalue: {\n\t\t\t\ttype: \"expression\",\n\t\t\t\targ: { type: \"literal\", value: \"Hello\" },\n\t\t\t\tannotation: {\n\t\t\t\t\ttype: \"function-reference\",\n\t\t\t\t\tname: \"number\",\n\t\t\t\t\toptions: [\n\t\t\t\t\t\t{ name: \"option1\", value: { type: \"literal\", value: \"value1\" } },\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tname: \"option2\",\n\t\t\t\t\t\t\tvalue: { type: \"variable-reference\", name: \"varRef\" },\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\texpect(code).toEqual(\n\t\t'const myVar = registry.number(\"en\", \"Hello\", { option1: \"value1\", option2: i?.varRef }, true);'\n\t);\n});\n\ntest(\"compiles formatter options referencing earlier local variables\", () => {\n\tconst code = compileLocalVariable({\n\t\tlocale: \"en\",\n\t\tdeclarations: [\n\t\t\t{ type: \"input-variable\", name: \"amount\" },\n\t\t\t{\n\t\t\t\ttype: \"local-variable\",\n\t\t\t\tname: \"digits\",\n\t\t\t\tvalue: { type: \"expression\", arg: { type: \"literal\", value: \"2\" } },\n\t\t\t},\n\t\t],\n\t\tdeclaration: {\n\t\t\ttype: \"local-variable\",\n\t\t\tname: \"formattedAmount\",\n\t\t\tvalue: {\n\t\t\t\ttype: \"expression\",\n\t\t\t\targ: { type: \"variable-reference\", name: \"amount\" },\n\t\t\t\tannotation: {\n\t\t\t\t\ttype: \"function-reference\",\n\t\t\t\t\tname: \"number\",\n\t\t\t\t\toptions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tname: \"minimumFractionDigits\",\n\t\t\t\t\t\t\tvalue: { type: \"variable-reference\", name: \"digits\" },\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\texpect(code).toEqual(\n\t\t'const formattedAmount = registry.number(\"en\", i?.amount, { minimumFractionDigits: digits }, true);'\n\t);\n});\n\ntest(\"compiles number formatter fraction digit options as numeric literals\", () => {\n\tconst code = compileLocalVariable({\n\t\tlocale: \"en\",\n\t\tdeclaration: {\n\t\t\ttype: \"local-variable\",\n\t\t\tname: \"formattedValue\",\n\t\t\tvalue: {\n\t\t\t\ttype: \"expression\",\n\t\t\t\targ: { type: \"variable-reference\", name: \"value\" },\n\t\t\t\tannotation: {\n\t\t\t\t\ttype: \"function-reference\",\n\t\t\t\t\tname: \"number\",\n\t\t\t\t\toptions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tname: \"minimumFractionDigits\",\n\t\t\t\t\t\t\tvalue: { type: \"literal\", value: \"1\" },\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tname: \"maximumFractionDigits\",\n\t\t\t\t\t\t\tvalue: { type: \"literal\", value: \"1\" },\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\texpect(code).toEqual(\n\t\t'const formattedValue = registry.number(\"en\", i?.value, { minimumFractionDigits: 1, maximumFractionDigits: 1 }, true);'\n\t);\n});\n\ntest(\"compiles number formatter useGrouping option as boolean literal\", () => {\n\tconst code = compileLocalVariable({\n\t\tlocale: \"en\",\n\t\tdeclaration: {\n\t\t\ttype: \"local-variable\",\n\t\t\tname: \"formattedValue\",\n\t\t\tvalue: {\n\t\t\t\ttype: \"expression\",\n\t\t\t\targ: { type: \"variable-reference\", name: \"value\" },\n\t\t\t\tannotation: {\n\t\t\t\t\ttype: \"function-reference\",\n\t\t\t\t\tname: \"number\",\n\t\t\t\t\toptions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tname: \"useGrouping\",\n\t\t\t\t\t\t\tvalue: { type: \"literal\", value: \"false\" },\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\texpect(code).toEqual(\n\t\t'const formattedValue = registry.number(\"en\", i?.value, { useGrouping: false }, true);'\n\t);\n});\n\ntest(\"keeps negative digit options as strings to avoid emitting invalid numeric literals\", () => {\n\tconst code = compileLocalVariable({\n\t\tlocale: \"en\",\n\t\tdeclaration: {\n\t\t\ttype: \"local-variable\",\n\t\t\tname: \"formattedValue\",\n\t\t\tvalue: {\n\t\t\t\ttype: \"expression\",\n\t\t\t\targ: { type: \"variable-reference\", name: \"value\" },\n\t\t\t\tannotation: {\n\t\t\t\t\ttype: \"function-reference\",\n\t\t\t\t\tname: \"number\",\n\t\t\t\t\toptions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tname: \"minimumFractionDigits\",\n\t\t\t\t\t\t\tvalue: { type: \"literal\", value: \"-1\" },\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\texpect(code).toEqual(\n\t\t'const formattedValue = registry.number(\"en\", i?.value, { minimumFractionDigits: \"-1\" }, true);'\n\t);\n});\n\ntest(\"compiles relative time formatter with a literal unit\", () => {\n\tconst code = compileLocalVariable({\n\t\tlocale: \"en\",\n\t\tdeclaration: {\n\t\t\ttype: \"local-variable\",\n\t\t\tname: \"formattedDuration\",\n\t\t\tvalue: {\n\t\t\t\ttype: \"expression\",\n\t\t\t\targ: { type: \"variable-reference\", name: \"duration\" },\n\t\t\t\tannotation: {\n\t\t\t\t\ttype: \"function-reference\",\n\t\t\t\t\tname: \"relativetime\",\n\t\t\t\t\toptions: [\n\t\t\t\t\t\t{ name: \"unit\", value: { type: \"literal\", value: \"day\" } },\n\t\t\t\t\t\t{ name: \"numeric\", value: { type: \"literal\", value: \"auto\" } },\n\t\t\t\t\t\t{ name: \"style\", value: { type: \"literal\", value: \"short\" } },\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t});\n\n\texpect(code).toEqual(\n\t\t'const formattedDuration = registry.relativetime(\"en\", i?.duration, { unit: \"day\", numeric: \"auto\", style: \"short\" }, true);'\n\t);\n});\n\ntest(\"compiles relative time formatter with a dynamic unit cast\", () => {\n\tconst code = compileLocalVariable({\n\t\tlocale: \"en\",\n\t\tdeclaration: {\n\t\t\ttype: \"local-variable\",\n\t\t\tname: \"formattedDuration\",\n\t\t\tvalue: {\n\t\t\t\ttype: \"expression\",\n\t\t\t\targ: { type: \"variable-reference\", name: \"duration\" },\n\t\t\t\tannotation: {\n\t\t\t\t\ttype: \"function-reference\",\n\t\t\t\t\tname: \"relativetime\",\n\t\t\t\t\toptions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tname: \"unit\",\n\t\t\t\t\t\t\tvalue: { type: \"variable-reference\", name: \"unit\" },\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{ name: \"style\", value: { type: \"literal\", value: \"short\" } },\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t});\n\n\texpect(code).toEqual(\n\t\t'const formattedDuration = registry.relativetime(\"en\", i?.duration, { unit: /** @type {import(\"../registry.js\").RelativeTimeFormatUnit} */ (i?.unit), style: \"short\" }, true);'\n\t);\n});\n\ntest(\"throws if relative time formatter is missing a unit option\", () => {\n\texpect(() =>\n\t\tcompileLocalVariable({\n\t\t\tlocale: \"en\",\n\t\t\tdeclaration: {\n\t\t\t\ttype: \"local-variable\",\n\t\t\t\tname: \"formattedDuration\",\n\t\t\t\tvalue: {\n\t\t\t\t\ttype: \"expression\",\n\t\t\t\t\targ: { type: \"variable-reference\", name: \"duration\" },\n\t\t\t\t\tannotation: {\n\t\t\t\t\t\ttype: \"function-reference\",\n\t\t\t\t\t\tname: \"relativetime\",\n\t\t\t\t\t\toptions: [],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t})\n\t).toThrow('The \"relativetime\" formatter requires a \"unit\" option.');\n});\n\ntest(\"throws if relative time formatter has duplicate unit options\", () => {\n\texpect(() =>\n\t\tcompileLocalVariable({\n\t\t\tlocale: \"en\",\n\t\t\tdeclaration: {\n\t\t\t\ttype: \"local-variable\",\n\t\t\t\tname: \"formattedDuration\",\n\t\t\t\tvalue: {\n\t\t\t\t\ttype: \"expression\",\n\t\t\t\t\targ: { type: \"variable-reference\", name: \"duration\" },\n\t\t\t\t\tannotation: {\n\t\t\t\t\t\ttype: \"function-reference\",\n\t\t\t\t\t\tname: \"relativetime\",\n\t\t\t\t\t\toptions: [\n\t\t\t\t\t\t\t{ name: \"unit\", value: { type: \"literal\", value: \"day\" } },\n\t\t\t\t\t\t\t{ name: \"unit\", value: { type: \"literal\", value: \"hour\" } },\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).toThrow('The \"relativetime\" formatter requires exactly one \"unit\" option.');\n});\n\ntest(\"throws if relative time formatter has an invalid literal unit\", () => {\n\texpect(() =>\n\t\tcompileLocalVariable({\n\t\t\tlocale: \"en\",\n\t\t\tdeclaration: {\n\t\t\t\ttype: \"local-variable\",\n\t\t\t\tname: \"formattedDuration\",\n\t\t\t\tvalue: {\n\t\t\t\t\ttype: \"expression\",\n\t\t\t\t\targ: { type: \"variable-reference\", name: \"duration\" },\n\t\t\t\t\tannotation: {\n\t\t\t\t\t\ttype: \"function-reference\",\n\t\t\t\t\t\tname: \"relativetime\",\n\t\t\t\t\t\toptions: [\n\t\t\t\t\t\t\t{ name: \"unit\", value: { type: \"literal\", value: \"century\" } },\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).toThrow('Invalid \"relativetime\" unit \"century\".');\n});\n\ntest(\"accepts plural relative time formatter units\", () => {\n\tconst code = compileLocalVariable({\n\t\tlocale: \"en\",\n\t\tdeclaration: {\n\t\t\ttype: \"local-variable\",\n\t\t\tname: \"formattedDuration\",\n\t\t\tvalue: {\n\t\t\t\ttype: \"expression\",\n\t\t\t\targ: { type: \"variable-reference\", name: \"duration\" },\n\t\t\t\tannotation: {\n\t\t\t\t\ttype: \"function-reference\",\n\t\t\t\t\tname: \"relativetime\",\n\t\t\t\t\toptions: [\n\t\t\t\t\t\t{ name: \"unit\", value: { type: \"literal\", value: \"days\" } },\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t});\n\n\texpect(code).toEqual(\n\t\t'const formattedDuration = registry.relativetime(\"en\", i?.duration, { unit: \"days\" }, true);'\n\t);\n});\n\ntest(\"accepts dynamic relative time formatter units\", () => {\n\tconst code = compileLocalVariable({\n\t\tlocale: \"en\",\n\t\tdeclaration: {\n\t\t\ttype: \"local-variable\",\n\t\t\tname: \"formattedDuration\",\n\t\t\tvalue: {\n\t\t\t\ttype: \"expression\",\n\t\t\t\targ: { type: \"variable-reference\", name: \"duration\" },\n\t\t\t\tannotation: {\n\t\t\t\t\ttype: \"function-reference\",\n\t\t\t\t\tname: \"relativetime\",\n\t\t\t\t\toptions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tname: \"unit\",\n\t\t\t\t\t\t\tvalue: { type: \"variable-reference\", name: \"unit\" },\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\texpect(code).toEqual(\n\t\t'const formattedDuration = registry.relativetime(\"en\", i?.duration, { unit: /** @type {import(\"../registry.js\").RelativeTimeFormatUnit} */ (i?.unit) }, true);'\n\t);\n});\n\ntest(\"accepts dollar-prefixed relative time formatter unit options from message files\", () => {\n\tconst code = compileLocalVariable({\n\t\tlocale: \"en\",\n\t\tdeclaration: {\n\t\t\ttype: \"local-variable\",\n\t\t\tname: \"formattedDuration\",\n\t\t\tvalue: {\n\t\t\t\ttype: \"expression\",\n\t\t\t\targ: { type: \"variable-reference\", name: \"duration\" },\n\t\t\t\tannotation: {\n\t\t\t\t\ttype: \"function-reference\",\n\t\t\t\t\tname: \"relativetime\",\n\t\t\t\t\toptions: [\n\t\t\t\t\t\t{ name: \"unit\", value: { type: \"literal\", value: \"$unit\" } },\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t});\n\n\texpect(code).toEqual(\n\t\t'const formattedDuration = registry.relativetime(\"en\", i?.duration, { unit: /** @type {import(\"../registry.js\").RelativeTimeFormatUnit} */ (i?.unit) }, true);'\n\t);\n});\n\ntest(\"compiles dollar-prefixed relative time units referencing local variables\", () => {\n\tconst code = compileLocalVariable({\n\t\tlocale: \"en\",\n\t\tdeclarations: [\n\t\t\t{ type: \"input-variable\", name: \"duration\" },\n\t\t\t{\n\t\t\t\ttype: \"local-variable\",\n\t\t\t\tname: \"localUnit\",\n\t\t\t\tvalue: { type: \"expression\", arg: { type: \"literal\", value: \"day\" } },\n\t\t\t},\n\t\t],\n\t\tdeclaration: {\n\t\t\ttype: \"local-variable\",\n\t\t\tname: \"formattedDuration\",\n\t\t\tvalue: {\n\t\t\t\ttype: \"expression\",\n\t\t\t\targ: { type: \"variable-reference\", name: \"duration\" },\n\t\t\t\tannotation: {\n\t\t\t\t\ttype: \"function-reference\",\n\t\t\t\t\tname: \"relativetime\",\n\t\t\t\t\toptions: [\n\t\t\t\t\t\t{ name: \"unit\", value: { type: \"literal\", value: \"$localUnit\" } },\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t});\n\n\texpect(code).toEqual(\n\t\t'const formattedDuration = registry.relativetime(\"en\", i?.duration, { unit: /** @type {import(\"../registry.js\").RelativeTimeFormatUnit} */ (localUnit) }, true);'\n\t);\n});\n\ntest(\"accepts dollar-prefixed relative time formatter unit options with non-identifier input names\", () => {\n\tconst code = compileLocalVariable({\n\t\tlocale: \"en\",\n\t\tdeclaration: {\n\t\t\ttype: \"local-variable\",\n\t\t\tname: \"formattedDuration\",\n\t\t\tvalue: {\n\t\t\t\ttype: \"expression\",\n\t\t\t\targ: { type: \"variable-reference\", name: \"duration\" },\n\t\t\t\tannotation: {\n\t\t\t\t\ttype: \"function-reference\",\n\t\t\t\t\tname: \"relativetime\",\n\t\t\t\t\toptions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tname: \"unit\",\n\t\t\t\t\t\t\tvalue: { type: \"literal\", value: \"$relative-unit\" },\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\texpect(code).toEqual(\n\t\t'const formattedDuration = registry.relativetime(\"en\", i?.duration, { unit: /** @type {import(\"../registry.js\").RelativeTimeFormatUnit} */ (i?.[\"relative-unit\"]) }, true);'\n\t);\n});\n\ntest.each([\n\t[\"date\", '{ dateStyle: \"medium\" }'],\n\t[\"time\", '{ timeStyle: \"medium\" }'],\n\t[\"datetime\", '{ dateStyle: \"medium\", timeStyle: \"short\" }'],\n])(\"compiles a %s local variable with its default style\", (name, options) => {\n\tconst code = compileLocalVariable({\n\t\tlocale: \"en\",\n\t\tdeclaration: {\n\t\t\ttype: \"local-variable\",\n\t\t\tname: \"formatted\",\n\t\t\tvalue: {\n\t\t\t\ttype: \"expression\",\n\t\t\t\targ: { type: \"variable-reference\", name: \"d\" },\n\t\t\t\tannotation: { type: \"function-reference\", name, options: [] },\n\t\t\t},\n\t\t},\n\t});\n\texpect(code).toBe(\n\t\t`const formatted = registry.datetime(\"en\", i?.d, ${options}, true);`\n\t);\n});\n"]}
@@ -612,7 +612,7 @@ describe("ICU plural offset (`{count, plural, offset:1 …}`)", () => {
612
612
  ],
613
613
  });
614
614
  // a number, not the string "1"
615
- expect(code).toContain('registry.plural("en", i?.count, { offset: 1 })');
615
+ expect(code).toContain('registry.plural("en", i?.count, { offset: 1 }, true)');
616
616
  expect(render(message, [0, 1, 2, 3, 22, "1", "2"])).toEqual({
617
617
  "0": "Nobody",
618
618
  "1": "Only you",