@inlang/paraglide-js 2.26.0 → 2.27.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 (100) hide show
  1. package/README.md +2 -1
  2. package/dist/bundler-plugins/per-locale-build/vite-environments.test.js +2 -2
  3. package/dist/bundler-plugins/per-locale-build/vite-environments.test.js.map +1 -1
  4. package/dist/cli/commands/init/command.js +19 -1
  5. package/dist/cli/commands/init/command.js.map +1 -1
  6. package/dist/cli/defaults.js +2 -2
  7. package/dist/cli/defaults.js.map +1 -1
  8. package/dist/cli/steps/add-inlang-check.d.ts +19 -0
  9. package/dist/cli/steps/add-inlang-check.js +60 -0
  10. package/dist/cli/steps/add-inlang-check.js.map +1 -0
  11. package/dist/cli/steps/add-inlang-check.test.d.ts +1 -0
  12. package/dist/cli/steps/add-inlang-check.test.js +88 -0
  13. package/dist/cli/steps/add-inlang-check.test.js.map +1 -0
  14. package/dist/cli/steps/agents-md-suggestion.d.ts +11 -0
  15. package/dist/cli/steps/agents-md-suggestion.js +19 -0
  16. package/dist/cli/steps/agents-md-suggestion.js.map +1 -0
  17. package/dist/cli/steps/agents-md-suggestion.test.d.ts +1 -0
  18. package/dist/cli/steps/agents-md-suggestion.test.js +36 -0
  19. package/dist/cli/steps/agents-md-suggestion.test.js.map +1 -0
  20. package/dist/cli/steps/maybe-add-machine-translation.js +3 -2
  21. package/dist/cli/steps/maybe-add-machine-translation.js.map +1 -1
  22. package/dist/cli/steps/maybe-add-sherlock.js +1 -1
  23. package/dist/cli/steps/maybe-add-sherlock.js.map +1 -1
  24. package/dist/cli/utils.d.ts +9 -0
  25. package/dist/cli/utils.js +15 -0
  26. package/dist/cli/utils.js.map +1 -1
  27. package/dist/compiler/compile-annotation.d.ts +48 -1
  28. package/dist/compiler/compile-annotation.js +238 -10
  29. package/dist/compiler/compile-annotation.js.map +1 -1
  30. package/dist/compiler/compile-bundle.d.ts +3 -2
  31. package/dist/compiler/compile-bundle.js +30 -1
  32. package/dist/compiler/compile-bundle.js.map +1 -1
  33. package/dist/compiler/compile-bundle.test.js +18 -18
  34. package/dist/compiler/compile-bundle.test.js.map +1 -1
  35. package/dist/compiler/compile-local-variable.d.ts +3 -0
  36. package/dist/compiler/compile-local-variable.js +5 -2
  37. package/dist/compiler/compile-local-variable.js.map +1 -1
  38. package/dist/compiler/compile-local-variable.test.js +44 -4
  39. package/dist/compiler/compile-local-variable.test.js.map +1 -1
  40. package/dist/compiler/compile-message.d.ts +29 -1
  41. package/dist/compiler/compile-message.exact-number.test.d.ts +1 -0
  42. package/dist/compiler/compile-message.exact-number.test.js +786 -0
  43. package/dist/compiler/compile-message.exact-number.test.js.map +1 -0
  44. package/dist/compiler/compile-message.js +162 -66
  45. package/dist/compiler/compile-message.js.map +1 -1
  46. package/dist/compiler/compile-message.locals.test.d.ts +1 -0
  47. package/dist/compiler/compile-message.locals.test.js +498 -0
  48. package/dist/compiler/compile-message.locals.test.js.map +1 -0
  49. package/dist/compiler/compile-message.test.js +111 -20
  50. package/dist/compiler/compile-message.test.js.map +1 -1
  51. package/dist/compiler/compile-pattern.d.ts +5 -0
  52. package/dist/compiler/compile-pattern.js +6 -18
  53. package/dist/compiler/compile-pattern.js.map +1 -1
  54. package/dist/compiler/compile-pattern.test.js +165 -1
  55. package/dist/compiler/compile-pattern.test.js.map +1 -1
  56. package/dist/compiler/compile-project.js +4 -1
  57. package/dist/compiler/compile-project.js.map +1 -1
  58. package/dist/compiler/compile-project.test.js +1013 -31
  59. package/dist/compiler/compile-project.test.js.map +1 -1
  60. package/dist/compiler/compile.test.js +1 -1
  61. package/dist/compiler/compile.test.js.map +1 -1
  62. package/dist/compiler/create-readme.d.ts +4 -1
  63. package/dist/compiler/create-readme.js +33 -125
  64. package/dist/compiler/create-readme.js.map +1 -1
  65. package/dist/compiler/emit-ts-declarations.interop.test.js +2 -2
  66. package/dist/compiler/emit-ts-declarations.interop.test.js.map +1 -1
  67. package/dist/compiler/emit-ts-declarations.test.js +4 -4
  68. package/dist/compiler/emit-ts-declarations.test.js.map +1 -1
  69. package/dist/compiler/index.d.ts +1 -1
  70. package/dist/compiler/index.js +1 -1
  71. package/dist/compiler/index.js.map +1 -1
  72. package/dist/compiler/input-alias.d.ts +21 -0
  73. package/dist/compiler/input-alias.js +42 -0
  74. package/dist/compiler/input-alias.js.map +1 -0
  75. package/dist/compiler/input-alias.test.d.ts +1 -0
  76. package/dist/compiler/input-alias.test.js +58 -0
  77. package/dist/compiler/input-alias.test.js.map +1 -0
  78. package/dist/compiler/message-locals.d.ts +46 -0
  79. package/dist/compiler/message-locals.js +129 -0
  80. package/dist/compiler/message-locals.js.map +1 -0
  81. package/dist/compiler/output-structure/locale-modules.js +7 -1
  82. package/dist/compiler/output-structure/locale-modules.js.map +1 -1
  83. package/dist/compiler/output-structure/locale-modules.test.js +35 -0
  84. package/dist/compiler/output-structure/locale-modules.test.js.map +1 -1
  85. package/dist/compiler/output-structure/message-modules.js +5 -3
  86. package/dist/compiler/output-structure/message-modules.js.map +1 -1
  87. package/dist/compiler/output-structure/message-modules.test.js +35 -0
  88. package/dist/compiler/output-structure/message-modules.test.js.map +1 -1
  89. package/dist/compiler/registry.d.ts +12 -0
  90. package/dist/compiler/registry.js +97 -28
  91. package/dist/compiler/registry.js.map +1 -1
  92. package/dist/compiler/server/create-server-file.js +24 -0
  93. package/dist/compiler/server/create-server-file.js.map +1 -1
  94. package/dist/compiler/server/create-server-file.test.js +8 -2
  95. package/dist/compiler/server/create-server-file.test.js.map +1 -1
  96. package/dist/compiler/server/middleware.js +29 -4
  97. package/dist/compiler/server/middleware.js.map +1 -1
  98. package/dist/services/env-variables/index.js +1 -1
  99. package/dist/services/env-variables/index.js.map +1 -1
  100. package/package.json +3 -3
@@ -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,Q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8F,EAAE,GAAG,EAAE;IACzG,MAAM,IAAI,GAAG,oBAAoB,CAAC;QACjC,MAAM,EAAE,IAAI;QACZ,WAAW,EAAE;YACZ,IAAI,EAAE,gBAAgB;YACtB,IAAI,EAAE,mBAAmB;YACzB,KAAK,EAAE;gBACN,IAAI,EAAE,YAAY;gBAClB,GAAG,EAAE,EAAE,IAAI,EAAE,oBAAoB,EAAE,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,sKAAsK,CACtK,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: \"myFunction\",\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.myFunction(\"en\", \"Hello\", {});');\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: \"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\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.myFunction(\"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"]}
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,GAAG,EAAE;I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E,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,8 +1,36 @@
1
1
  import type { Declaration, Message, Variant } from "@inlang/sdk";
2
2
  import type { Compiled } from "./types.js";
3
3
  import { type InputMatchTypes } from "./jsdoc-types.js";
4
+ /**
5
+ * The message fields the compiler reads.
6
+ *
7
+ * `selectBundleNested()` of `@inlang/sdk` 4 returns the bundle id as
8
+ * `bundle_id` (the database column). The camelCase `bundleId` of the SDK's
9
+ * plugin `Message` shape is accepted too.
10
+ */
11
+ export type CompilableMessage = Pick<Message, "id" | "locale" | "selectors"> & ({
12
+ bundleId: string;
13
+ } | {
14
+ bundle_id: string;
15
+ });
16
+ /**
17
+ * The variant fields the compiler reads. The message id (`message_id` in
18
+ * `@inlang/sdk` 4 rows) is not needed.
19
+ */
20
+ export type CompilableVariant = Pick<Variant, "id" | "matches" | "pattern">;
21
+ /**
22
+ * The bundle id of a message with either SDK version.
23
+ */
24
+ export declare function messageBundleId(message: CompilableMessage): string;
25
+ export type CompiledMessage = Compiled<CompilableMessage> & {
26
+ /**
27
+ * The registry functions the compiled code calls, e.g. `["plural"]`.
28
+ * The output imports the registry only if a message calls it.
29
+ */
30
+ registryFunctions: string[];
31
+ };
4
32
  /**
5
33
  * Returns the compiled message as a string
6
34
  *
7
35
  */
8
- export declare const compileMessage: (declarations: Declaration[], message: Message, variants: Variant[], matchTypes?: InputMatchTypes, inputTypeAliasName?: string) => Compiled<Message>;
36
+ export declare const compileMessage: (declarations: Declaration[], message: CompilableMessage, variants: CompilableVariant[], matchTypes?: InputMatchTypes, inputTypeAliasName?: string) => CompiledMessage;