@inlang/paraglide-js 2.29.0 → 2.29.2

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 (34) hide show
  1. package/dist/compiler/compile-bundle.js +58 -12
  2. package/dist/compiler/compile-bundle.js.map +1 -1
  3. package/dist/compiler/compile-bundle.test.js +208 -26
  4. package/dist/compiler/compile-bundle.test.js.map +1 -1
  5. package/dist/compiler/compile-lifecycle.test.js +83 -0
  6. package/dist/compiler/compile-lifecycle.test.js.map +1 -1
  7. package/dist/compiler/compile-message.d.ts +9 -0
  8. package/dist/compiler/compile-message.js +29 -12
  9. package/dist/compiler/compile-message.js.map +1 -1
  10. package/dist/compiler/compile-project.js +6 -1
  11. package/dist/compiler/compile-project.js.map +1 -1
  12. package/dist/compiler/compile-project.test.js +157 -0
  13. package/dist/compiler/compile-project.test.js.map +1 -1
  14. package/dist/compiler/compile.js +12 -0
  15. package/dist/compiler/compile.js.map +1 -1
  16. package/dist/compiler/compiler-options.d.ts +5 -2
  17. package/dist/compiler/compiler-options.js.map +1 -1
  18. package/dist/compiler/emit-ts-declarations.d.ts +4 -1
  19. package/dist/compiler/emit-ts-declarations.js +18 -11
  20. package/dist/compiler/emit-ts-declarations.js.map +1 -1
  21. package/dist/compiler/emit-ts-declarations.native.test.d.ts +1 -0
  22. package/dist/compiler/emit-ts-declarations.native.test.js +86 -0
  23. package/dist/compiler/emit-ts-declarations.native.test.js.map +1 -0
  24. package/dist/compiler/emit-ts-declarations.test.js +3 -0
  25. package/dist/compiler/emit-ts-declarations.test.js.map +1 -1
  26. package/dist/compiler/resolve-tsc-js-path.d.ts +6 -0
  27. package/dist/compiler/resolve-tsc-js-path.js +34 -1
  28. package/dist/compiler/resolve-tsc-js-path.js.map +1 -1
  29. package/dist/compiler/resolve-tsc-js-path.test.d.ts +1 -0
  30. package/dist/compiler/resolve-tsc-js-path.test.js +31 -0
  31. package/dist/compiler/resolve-tsc-js-path.test.js.map +1 -0
  32. package/dist/services/env-variables/index.js +1 -1
  33. package/dist/services/env-variables/index.js.map +1 -1
  34. package/package.json +1 -1
@@ -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,SAAS,qBAAqB,CAC7B,EAAU,EACV,YAAoC,EACpC,YAAY,GAAiC,EAAE;IAE/C,OAAO;QACN,EAAE;QACF,YAAY;QACZ,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;YAChE,EAAE,EAAE,GAAG,EAAE,IAAI,MAAM,EAAE;YACrB,SAAS,EAAE,EAAE;YACb,MAAM;YACN,SAAS,EAAE,EAAE;YACb,QAAQ,EAAE;gBACT;oBACC,EAAE,EAAE,GAAG,EAAE,IAAI,MAAM,UAAU;oBAC7B,UAAU,EAAE,GAAG,EAAE,IAAI,MAAM,EAAE;oBAC7B,OAAO,EAAE,EAAE;oBACX,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,KAAK,EAAE,CAAC;iBAC3C;aACD;SACD,CAAC,CAAC;KACH,CAAC;AACH,CAAC;AAED,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;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AAE,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;AAEH,IAAI,CAAC,oEAAoE,EAAE,GAAG,EAAE;IAC/E,MAAM,MAAM,GAAG,aAAa,CAAC;QAC5B,MAAM,EAAE,qBAAqB,CAAC,OAAO,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC;QACpE,WAAW,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,IAAI,EAAE;QACxC,QAAQ,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,EAAqB;QACxE,0BAA0B,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,MAAM,QAAQ;KACzD,CAAC,CAAC;IACH,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,yBAAyB,CAAC,CAAC;IAChE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,SAAS,CACvC,iDAAiD,CACjD,CAAC;AACH,CAAC,CAAC,CAAC","sourcesContent":["import { test, expect } from \"vitest\";\nimport { compileBundle, toBundleInputTypeAliasName } from \"./compile-bundle.js\";\nimport type { BundleNested, ProjectSettings } from \"@inlang/sdk\";\nimport { toSafeModuleId } from \"./safe-module-id.js\";\nimport { perLocaleBuildStaticLocaleExpression } from \"./per-locale-build.js\";\n\nfunction createPlainTextBundle(\n\tid: string,\n\ttextByLocale: Record<string, string>,\n\tdeclarations: BundleNested[\"declarations\"] = []\n): BundleNested {\n\treturn {\n\t\tid,\n\t\tdeclarations,\n\t\tmessages: Object.entries(textByLocale).map(([locale, value]) => ({\n\t\t\tid: `${id}-${locale}`,\n\t\t\tbundle_id: id,\n\t\t\tlocale,\n\t\t\tselectors: [],\n\t\t\tvariants: [\n\t\t\t\t{\n\t\t\t\t\tid: `${id}-${locale}-variant`,\n\t\t\t\t\tmessage_id: `${id}-${locale}`,\n\t\t\t\t\tmatches: [],\n\t\t\t\t\tpattern: [{ type: \"text\" as const, value }],\n\t\t\t\t},\n\t\t\t],\n\t\t})),\n\t};\n}\n\ntest(\"compiles to jsdoc\", async () => {\n\tconst mockBundle: BundleNested = {\n\t\tid: \"blue_moon_bottle\",\n\t\tdeclarations: [{ type: \"input-variable\", name: \"age\" }],\n\t\tmessages: [\n\t\t\t{\n\t\t\t\tid: \"message-id\",\n\t\t\t\tbundle_id: \"blue_moon_bottle\",\n\t\t\t\tlocale: \"en\",\n\t\t\t\tselectors: [],\n\t\t\t\tvariants: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"1\",\n\t\t\t\t\t\tmessage_id: \"message-id\",\n\t\t\t\t\t\tmatches: [],\n\t\t\t\t\t\tpattern: [\n\t\t\t\t\t\t\t{ type: \"text\", value: \"Hello\" },\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"expression\",\n\t\t\t\t\t\t\t\targ: { type: \"variable-reference\", name: \"age\" },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t};\n\n\tconst result = compileBundle({\n\t\tinlineMessages: true,\n\t\tfallbackMap: {\n\t\t\ten: \"en\",\n\t\t\t\"en-US\": \"en\",\n\t\t},\n\t\tbundle: mockBundle,\n\t\tmessageReferenceExpression: (locale) =>\n\t\t\t`${toSafeModuleId(locale)}.blue_moon_bottle`,\n\t\tsettings: {\n\t\t\tlocales: [\"en\", \"en-US\"],\n\t\t} as ProjectSettings,\n\t});\n\n\texpect(result.bundle.code).toMatchInlineSnapshot(\n\t\t`\n\t\t\"/**\n\t\t* | output |\n\t\t* | --- |\n\t\t* | \"Hello{age}\" |\n\t\t*\n\t\t* @param {Blue_Moon_BottleInputs} inputs\n\t\t* @param {{ locale?: \"en\" | \"en-US\" }} options\n\t\t* @returns {LocalizedString}\n\t\t*/\n\t\texport const blue_moon_bottle = /** @type {((inputs: Blue_Moon_BottleInputs, options?: { locale?: \"en\" | \"en-US\" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Blue_Moon_BottleInputs, { locale?: \"en\" | \"en-US\" }, {}>} */ ((inputs, options = {}) => {\n\t\t\tconst locale = experimentalStaticLocale ?? options.locale ?? getLocale()\n\t\t\tif (locale === \"en\") return en.blue_moon_bottle(inputs)\n\t\t\treturn en_us2.blue_moon_bottle(inputs)\n\t\t});\"\n\t`\n\t);\n});\n\ntest(\"uses the base locale as the exhaustive locale branch\", () => {\n\tconst mockBundle: BundleNested = {\n\t\tid: \"greeting\",\n\t\tdeclarations: [],\n\t\tmessages: [\n\t\t\t{\n\t\t\t\tid: \"message-id\",\n\t\t\t\tbundle_id: \"greeting\",\n\t\t\t\tlocale: \"en\",\n\t\t\t\tselectors: [],\n\t\t\t\tvariants: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"variant-id\",\n\t\t\t\t\t\tmessage_id: \"message-id\",\n\t\t\t\t\t\tmatches: [],\n\t\t\t\t\t\tpattern: [{ type: \"text\", value: \"Hello\" }],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t};\n\n\tconst result = compileBundle({\n\t\tinlineMessages: true,\n\t\tfallbackMap: {\n\t\t\tfr: \"en\",\n\t\t\tde: \"en\",\n\t\t\ten: undefined,\n\t\t\tja: \"en\",\n\t\t},\n\t\tbundle: mockBundle,\n\t\tmessageReferenceExpression: (locale) => `${locale}_greeting`,\n\t\tsettings: {\n\t\t\tbaseLocale: \"en\",\n\t\t\tlocales: [\"fr\", \"de\", \"en\", \"ja\"],\n\t\t} as ProjectSettings,\n\t});\n\n\texpect(result.bundle.code).toContain(\n\t\t[\n\t\t\t'if (locale === \"fr\") return fr_greeting(inputs)',\n\t\t\t'if (locale === \"de\") return de_greeting(inputs)',\n\t\t\t'if (locale === \"ja\") return ja_greeting(inputs)',\n\t\t\t'return /** @type {LocalizedString} */ (\"Hello\")',\n\t\t].join(\"\\n\\t\")\n\t);\n});\n\ntest(\"inlines static text with safe escaping and preserves missing-locale fallbacks\", async () => {\n\tconst id = \"$p@44🍌\";\n\tconst safeId = toSafeModuleId(id);\n\tconst trickyText =\n\t\t'quote \" backslash \\\\ backtick ` interpolation ${danger}\\r\\n</script><script>alert(1)</script> */\\u2028\\u2029';\n\tconst compiledText = trickyText.replace(/\\r\\n?/g, \"\\n\");\n\tconst bundle = createPlainTextBundle(id, { en: trickyText, de: \"Hallo\" }, [\n\t\t{ type: \"input-variable\", name: \"unused\" },\n\t]);\n\tconst result = compileBundle({\n\t\tinlineMessages: true,\n\t\tbundle,\n\t\tfallbackMap: { en: undefined, de: \"en\", fr: \"en\" },\n\t\tmessageReferenceExpression: (locale, bundleId) =>\n\t\t\t`${toSafeModuleId(locale)}_${toSafeModuleId(bundleId)}`,\n\t\tsettings: {\n\t\t\tbaseLocale: \"en\",\n\t\t\tlocales: [\"en\", \"de\", \"fr\"],\n\t\t} as ProjectSettings,\n\t\texperimentalMiddlewareLocaleSplitting: true,\n\t});\n\n\texpect(result.bundle.code).toContain(\n\t\t`if (locale === \"de\") return /** @type {LocalizedString} */ (${JSON.stringify(\"Hallo\")})`\n\t);\n\texpect(result.bundle.code).toContain(\n\t\t`if (locale === \"fr\") return fr_${safeId}(inputs)`\n\t);\n\texpect(result.bundle.code).toContain(\n\t\t`return /** @type {LocalizedString} */ (${JSON.stringify(compiledText)})`\n\t);\n\texpect(result.bundle.code).toContain(`trackMessageCall(\"${safeId}\", locale)`);\n\texpect(result.bundle.code).toContain(\n\t\t`globalThis).__paraglide.ssr.${safeId}(inputs)`\n\t);\n\texpect(result.messages.en?.code).toBeDefined();\n\n\tconst enMessage = result.messages.en;\n\tconst deMessage = result.messages.de;\n\tif (!enMessage || !deMessage) throw new Error(\"Expected compiled messages\");\n\tconst moduleSource = `\nconst getLocale = () => \"en\";\nconst trackMessageCall = () => {};\nconst experimentalMiddlewareLocaleSplitting = false;\nconst isServer = true;\nconst experimentalStaticLocale = undefined;\nconst en_${safeId} = ${enMessage.code.replace(/;\\s*$/, \"\")};\nconst de_${safeId} = ${deMessage.code.replace(/;\\s*$/, \"\")};\nconst fr_${safeId} = en_${safeId};\n${result.bundle.code}\n`;\n\tconst module = await import(\n\t\t\"data:text/javascript;charset=utf-8,\" + encodeURIComponent(moduleSource)\n\t);\n\tconst message = module[id];\n\tconst unreadInput = new Proxy(\n\t\t{},\n\t\t{\n\t\t\tget: () => {\n\t\t\t\tthrow new Error(\"static text should not read inputs\");\n\t\t\t},\n\t\t}\n\t);\n\n\texpect(message(unreadInput, { locale: \"en\" })).toBe(compiledText);\n\texpect(message({}, { locale: \"de\" })).toBe(\"Hallo\");\n\texpect(message({}, { locale: \"fr\" })).toBe(compiledText);\n});\n\ntest(\"leaves markup and multi-variant messages on their message functions\", () => {\n\tconst markupBundle: BundleNested = {\n\t\tid: \"notice\",\n\t\tdeclarations: [],\n\t\tmessages: [\n\t\t\t{\n\t\t\t\tid: \"notice-en\",\n\t\t\t\tbundle_id: \"notice\",\n\t\t\t\tlocale: \"en\",\n\t\t\t\tselectors: [],\n\t\t\t\tvariants: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"notice-en-variant\",\n\t\t\t\t\t\tmessage_id: \"notice-en\",\n\t\t\t\t\t\tmatches: [],\n\t\t\t\t\t\tpattern: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"markup-start\",\n\t\t\t\t\t\t\t\tname: \"strong\",\n\t\t\t\t\t\t\t\toptions: [],\n\t\t\t\t\t\t\t\tattributes: [],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{ type: \"text\", value: \"Hello\" },\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"markup-end\",\n\t\t\t\t\t\t\t\tname: \"strong\",\n\t\t\t\t\t\t\t\toptions: [],\n\t\t\t\t\t\t\t\tattributes: [],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t};\n\tconst markupResult = compileBundle({\n\t\tinlineMessages: true,\n\t\tbundle: markupBundle,\n\t\tfallbackMap: { en: undefined },\n\t\tmessageReferenceExpression: (locale) => `${locale}_notice`,\n\t\tsettings: { baseLocale: \"en\", locales: [\"en\"] } as ProjectSettings,\n\t});\n\texpect(markupResult.bundle.code).toContain(\"return en_notice(inputs)\");\n\texpect(markupResult.bundle.code).not.toContain(\n\t\t'return /** @type {LocalizedString} */ (\"Hello\")'\n\t);\n\n\tconst multiVariantBundle: BundleNested = {\n\t\tid: \"item_count\",\n\t\tdeclarations: [{ type: \"input-variable\", name: \"count\" }],\n\t\tmessages: [\"en\", \"de\"].map((locale) => ({\n\t\t\tid: `item_count-${locale}`,\n\t\t\tbundle_id: \"item_count\",\n\t\t\tlocale,\n\t\t\tselectors: [{ type: \"variable-reference\", name: \"count\" }],\n\t\t\tvariants: [\n\t\t\t\t{\n\t\t\t\t\tid: `item_count-${locale}-zero`,\n\t\t\t\t\tmessage_id: `item_count-${locale}`,\n\t\t\t\t\tmatches: [{ type: \"literal-match\", key: \"count\", value: \"0\" }],\n\t\t\t\t\tpattern: [{ type: \"text\", value: \"No items\" }],\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tid: `item_count-${locale}-other`,\n\t\t\t\t\tmessage_id: `item_count-${locale}`,\n\t\t\t\t\tmatches: [{ type: \"catchall-match\", key: \"count\" }],\n\t\t\t\t\tpattern: [{ type: \"text\", value: \"Some items\" }],\n\t\t\t\t},\n\t\t\t],\n\t\t})),\n\t};\n\tconst multiVariantResult = compileBundle({\n\t\tinlineMessages: true,\n\t\tbundle: multiVariantBundle,\n\t\tfallbackMap: { en: undefined, de: \"en\" },\n\t\tmessageReferenceExpression: (locale) => `${locale}_item_count`,\n\t\tsettings: { baseLocale: \"en\", locales: [\"en\", \"de\"] } as ProjectSettings,\n\t});\n\texpect(multiVariantResult.bundle.code).toContain(\n\t\t'if (locale === \"de\") return de_item_count(inputs)'\n\t);\n\texpect(multiVariantResult.bundle.code).toContain(\n\t\t\"return en_item_count(inputs)\"\n\t);\n});\n\ntest(\"keeps static text message references in a per-locale build\", () => {\n\tconst bundle = createPlainTextBundle(\"greeting\", {\n\t\ten: \"Hello\",\n\t\tde: \"Hallo\",\n\t});\n\tconst result = compileBundle({\n\t\tinlineMessages: true,\n\t\tbundle,\n\t\tfallbackMap: { en: undefined, de: \"en\" },\n\t\tmessageReferenceExpression: (locale) => `${locale}_greeting`,\n\t\tsettings: { baseLocale: \"en\", locales: [\"en\", \"de\"] } as ProjectSettings,\n\t\texperimentalStaticLocale: perLocaleBuildStaticLocaleExpression,\n\t});\n\n\texpect(result.bundle.code).toContain(\n\t\t'if (locale === \"de\") return de_greeting(inputs)'\n\t);\n\texpect(result.bundle.code).toContain(\"return en_greeting(inputs)\");\n});\n\ntest(\"marks an unused input parameter as used when every branch is inlined\", () => {\n\tconst bundle = createPlainTextBundle(\"greeting\", { en: \"Hello\" }, [\n\t\t{ type: \"input-variable\", name: \"unused\" },\n\t]);\n\tconst result = compileBundle({\n\t\tinlineMessages: true,\n\t\tbundle,\n\t\tfallbackMap: { en: undefined },\n\t\tmessageReferenceExpression: (locale) => `${locale}_greeting`,\n\t\tsettings: { baseLocale: \"en\", locales: [\"en\"] } as ProjectSettings,\n\t});\n\n\texpect(result.bundle.code).toContain(\"void inputs;\");\n\texpect(result.bundle.code).toContain(\n\t\t'return /** @type {LocalizedString} */ (\"Hello\")'\n\t);\n});\n\ntest(\"does not treat inherited object properties as inline locale messages\", () => {\n\tconst bundle = createPlainTextBundle(\"greeting\", { en: \"Hello\" });\n\tconst result = compileBundle({\n\t\tinlineMessages: true,\n\t\tbundle,\n\t\tfallbackMap: { en: undefined, toString: \"en\", constructor: \"en\" },\n\t\tmessageReferenceExpression: (locale) =>\n\t\t\t`${toSafeModuleId(locale)}_greeting`,\n\t\tsettings: {\n\t\t\tbaseLocale: \"en\",\n\t\t\tlocales: [\"en\", \"toString\", \"constructor\"],\n\t\t} as ProjectSettings,\n\t});\n\n\texpect(result.bundle.code).toContain(\n\t\t`if (locale === \"toString\") return ${toSafeModuleId(\"toString\")}_greeting(inputs)`\n\t);\n\texpect(result.bundle.code).toContain(\n\t\t`if (locale === \"constructor\") return ${toSafeModuleId(\"constructor\")}_greeting(inputs)`\n\t);\n\texpect(result.bundle.code).toContain(\n\t\t'return /** @type {LocalizedString} */ (\"Hello\")'\n\t);\n});\n\ntest(\"emits middleware locale splitting hooks when enabled\", () => {\n\tconst mockBundle: BundleNested = {\n\t\tid: \"blue_moon_bottle\",\n\t\tdeclarations: [{ type: \"input-variable\", name: \"age\" }],\n\t\tmessages: [\n\t\t\t{\n\t\t\t\tid: \"message-id\",\n\t\t\t\tbundle_id: \"blue_moon_bottle\",\n\t\t\t\tlocale: \"en\",\n\t\t\t\tselectors: [],\n\t\t\t\tvariants: [\n\t\t\t\t\t{ id: \"1\", message_id: \"message-id\", matches: [], pattern: [] },\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t};\n\n\tconst result = compileBundle({\n\t\tinlineMessages: true,\n\t\tfallbackMap: { en: \"en\" },\n\t\tbundle: mockBundle,\n\t\tmessageReferenceExpression: (locale) =>\n\t\t\t`${toSafeModuleId(locale)}.blue_moon_bottle`,\n\t\tsettings: {\n\t\t\tlocales: [\"en\"],\n\t\t} as ProjectSettings,\n\t\texperimentalMiddlewareLocaleSplitting: true,\n\t});\n\n\texpect(result.bundle.code).toContain(\n\t\t\"if (experimentalMiddlewareLocaleSplitting && isServer === false)\"\n\t);\n\texpect(result.bundle.code).toContain(\n\t\t'trackMessageCall(\"blue_moon_bottle\", locale)'\n\t);\n\texpect(result.bundle.code).toContain(\n\t\t\"globalThis).__paraglide.ssr.blue_moon_bottle(inputs)\"\n\t);\n});\n\ntest(\"emits the per-locale build marker inside the message function\", () => {\n\tconst mockBundle: BundleNested = {\n\t\tid: \"greeting\",\n\t\tdeclarations: [],\n\t\tmessages: [\n\t\t\t{\n\t\t\t\tid: \"greeting-en\",\n\t\t\t\tbundle_id: \"greeting\",\n\t\t\t\tlocale: \"en\",\n\t\t\t\tselectors: [],\n\t\t\t\tvariants: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"greeting-en-variant\",\n\t\t\t\t\t\tmessage_id: \"greeting-en\",\n\t\t\t\t\t\tmatches: [],\n\t\t\t\t\t\tpattern: [{ type: \"text\", value: \"hello\" }],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"greeting-de\",\n\t\t\t\tbundle_id: \"greeting\",\n\t\t\t\tlocale: \"de\",\n\t\t\t\tselectors: [],\n\t\t\t\tvariants: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"greeting-de-variant\",\n\t\t\t\t\t\tmessage_id: \"greeting-de\",\n\t\t\t\t\t\tmatches: [],\n\t\t\t\t\t\tpattern: [{ type: \"text\", value: \"hallo\" }],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t};\n\tconst expression = perLocaleBuildStaticLocaleExpression;\n\tconst result = compileBundle({\n\t\tinlineMessages: true,\n\t\tbundle: mockBundle,\n\t\tfallbackMap: { en: undefined, de: \"en\" },\n\t\tmessageReferenceExpression: (locale) => `${locale}_greeting`,\n\t\tsettings: { locales: [\"en\", \"de\"] } as ProjectSettings,\n\t\texperimentalStaticLocale: expression,\n\t});\n\n\texpect(result.bundle.code).toContain(\n\t\t`const locale = ${expression} ?? options.locale ?? getLocale()`\n\t);\n\texpect(result.bundle.code).toContain(\n\t\t`if (${expression} !== undefined && options.locale !== undefined && options.locale !== ${expression}) console.warn(`\n\t);\n\texpect(result.bundle.code).toContain(\"full document navigation\");\n});\n\ntest(\"compiles to jsdoc with missing translation\", async () => {\n\tconst mockBundle: BundleNested = {\n\t\tid: \"blue_moon_bottle\",\n\t\tdeclarations: [{ type: \"input-variable\", name: \"age\" }],\n\t\tmessages: [\n\t\t\t{\n\t\t\t\tid: \"message-id\",\n\t\t\t\tbundle_id: \"blue_moon_bottle\",\n\t\t\t\tlocale: \"en\",\n\t\t\t\tselectors: [],\n\t\t\t\tvariants: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"1\",\n\t\t\t\t\t\tmessage_id: \"message-id\",\n\t\t\t\t\t\tmatches: [],\n\t\t\t\t\t\tpattern: [\n\t\t\t\t\t\t\t{ type: \"text\", value: \"Hello\" },\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"expression\",\n\t\t\t\t\t\t\t\targ: { type: \"variable-reference\", name: \"age\" },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t};\n\n\tconst result = compileBundle({\n\t\tinlineMessages: true,\n\t\tfallbackMap: {\n\t\t\ten: \"en\",\n\t\t\t\"en-US\": \"en\",\n\t\t},\n\t\tbundle: mockBundle,\n\t\tmessageReferenceExpression: (locale) =>\n\t\t\t`${toSafeModuleId(locale)}.blue_moon_bottle`,\n\t\tsettings: {\n\t\t\tlocales: [\"en\", \"en-US\", \"fr\"],\n\t\t} as ProjectSettings,\n\t});\n\n\texpect(result.bundle.code).toMatchInlineSnapshot(\n\t\t`\n\t\t\"/**\n\t\t* | output |\n\t\t* | --- |\n\t\t* | \"Hello{age}\" |\n\t\t*\n\t\t* @param {Blue_Moon_BottleInputs} inputs\n\t\t* @param {{ locale?: \"en\" | \"en-US\" }} options\n\t\t* @returns {LocalizedString}\n\t\t*/\n\t\texport const blue_moon_bottle = /** @type {((inputs: Blue_Moon_BottleInputs, options?: { locale?: \"en\" | \"en-US\" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Blue_Moon_BottleInputs, { locale?: \"en\" | \"en-US\" }, {}>} */ ((inputs, options = {}) => {\n\t\t\tconst locale = experimentalStaticLocale ?? options.locale ?? getLocale()\n\t\t\tif (locale === \"en\") return en.blue_moon_bottle(inputs)\n\t\t\tif (locale === \"en-US\") return en_us2.blue_moon_bottle(inputs)\n\t\t\treturn /** @type {LocalizedString} */ (\"blue_moon_bottle\")\n\t\t});\"\n\t`\n\t);\n});\n\n// https://github.com/opral/inlang-paraglide-js/issues/285\ntest(\"compiles bundles with arbitrary module identifiers\", async () => {\n\tconst mockBundle: BundleNested = {\n\t\tid: \"$p@44🍌\",\n\t\tdeclarations: [{ type: \"input-variable\", name: \"age\" }],\n\t\tmessages: [\n\t\t\t{\n\t\t\t\tid: \"message-id\",\n\t\t\t\tbundle_id: \"$p@44🍌\",\n\t\t\t\tlocale: \"en\",\n\t\t\t\tselectors: [],\n\t\t\t\tvariants: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"1\",\n\t\t\t\t\t\tmessage_id: \"message-id\",\n\t\t\t\t\t\tmatches: [],\n\t\t\t\t\t\tpattern: [\n\t\t\t\t\t\t\t{ type: \"text\", value: \"Hello\" },\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"expression\",\n\t\t\t\t\t\t\t\targ: { type: \"variable-reference\", name: \"age\" },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t};\n\n\tconst result = compileBundle({\n\t\tinlineMessages: true,\n\t\tfallbackMap: {},\n\t\tbundle: mockBundle,\n\t\tmessageReferenceExpression: (locale) =>\n\t\t\t`${toSafeModuleId(locale)}.blue_moon_bottle`,\n\t});\n\n\texpect(result.bundle.code).includes(\n\t\t`export { ${toSafeModuleId(\"$p@44🍌\")} as \"$p@44🍌\" }`\n\t);\n});\n\ntest(\"keeps generated input typedef names collision-free for repeated underscores\", () => {\n\texpect(toBundleInputTypeAliasName(\"foo_bar\")).toBe(\"Foo_BarInputs\");\n\texpect(toBundleInputTypeAliasName(\"foo__bar\")).toBe(\"Foo__BarInputs\");\n\texpect(toBundleInputTypeAliasName(\"foo_bar\")).not.toBe(\n\t\ttoBundleInputTypeAliasName(\"foo__bar\")\n\t);\n});\n\ntest(\"handles message pattern with duplicate variable references\", async () => {\n\tconst mockBundle: BundleNested = {\n\t\tid: \"date_last_days\",\n\t\tdeclarations: [\n\t\t\t{ type: \"input-variable\", name: \"days\" },\n\t\t\t{ type: \"input-variable\", name: \"days\" },\n\t\t],\n\t\tmessages: [\n\t\t\t{\n\t\t\t\tid: \"date_last_days\",\n\t\t\t\tbundle_id: \"date_last_days\",\n\t\t\t\tlocale: \"en\",\n\t\t\t\tselectors: [],\n\t\t\t\tvariants: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"1\",\n\t\t\t\t\t\tmessage_id: \"date_last_days\",\n\t\t\t\t\t\tmatches: [],\n\t\t\t\t\t\tpattern: [\n\t\t\t\t\t\t\t{ type: \"text\", value: \"Last \" },\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"expression\",\n\t\t\t\t\t\t\t\targ: { type: \"variable-reference\", name: \"days\" },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{ type: \"text\", value: \" days, showing \" },\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"expression\",\n\t\t\t\t\t\t\t\targ: { type: \"variable-reference\", name: \"days\" },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{ type: \"text\", value: \" items\" },\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t};\n\n\tconst result = compileBundle({\n\t\tinlineMessages: true,\n\t\tfallbackMap: {\n\t\t\ten: \"en\",\n\t\t},\n\t\tbundle: mockBundle,\n\t\tmessageReferenceExpression: (locale) =>\n\t\t\t`${toSafeModuleId(locale)}.date_last_days`,\n\t});\n\n\t// The JSDoc should not have duplicate parameters\n\texpect(result.bundle.code).toContain(\"@param {Date_Last_DaysInputs} inputs\");\n\texpect(result.bundle.code).not.toContain(\n\t\t\"days: NonNullable<unknown>, days: NonNullable<unknown>\"\n\t);\n\n\t// Check that the pattern is compiled correctly\n\tconst enMessage = result.messages?.en;\n\texpect(enMessage).toBeDefined();\n\texpect(enMessage?.code).toContain(\n\t\t\"Last ${i?.days} days, showing ${i?.days} items\"\n\t);\n});\n\ntest(\"adds .parts() to bundle functions when markup exists\", async () => {\n\tconst mockBundle: BundleNested = {\n\t\tid: \"notice\",\n\t\tdeclarations: [{ type: \"input-variable\", name: \"count\" }],\n\t\tmessages: [\n\t\t\t{\n\t\t\t\tid: \"notice-id\",\n\t\t\t\tbundle_id: \"notice\",\n\t\t\t\tlocale: \"en\",\n\t\t\t\tselectors: [],\n\t\t\t\tvariants: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"1\",\n\t\t\t\t\t\tmessage_id: \"notice-id\",\n\t\t\t\t\t\tmatches: [],\n\t\t\t\t\t\tpattern: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"markup-start\",\n\t\t\t\t\t\t\t\tname: \"strong\",\n\t\t\t\t\t\t\t\toptions: [],\n\t\t\t\t\t\t\t\tattributes: [],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"expression\",\n\t\t\t\t\t\t\t\targ: { type: \"variable-reference\", name: \"count\" },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{ type: \"text\", value: \" items\" },\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"markup-end\",\n\t\t\t\t\t\t\t\tname: \"strong\",\n\t\t\t\t\t\t\t\toptions: [],\n\t\t\t\t\t\t\t\tattributes: [],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t};\n\n\tconst result = compileBundle({\n\t\tinlineMessages: true,\n\t\tfallbackMap: {\n\t\t\ten: undefined,\n\t\t},\n\t\tbundle: mockBundle,\n\t\tmessageReferenceExpression: (locale) => `${toSafeModuleId(locale)}.notice`,\n\t\tsettings: {\n\t\t\tlocales: [\"en\"],\n\t\t} as ProjectSettings,\n\t});\n\tconst compiledEnMessage = result.messages.en;\n\tif (!compiledEnMessage) {\n\t\tthrow new Error(\"Expected compiled english message\");\n\t}\n\n\tconst moduleSource = `\nconst getLocale = () => \"en\";\nconst trackMessageCall = () => {};\nconst experimentalMiddlewareLocaleSplitting = false;\nconst isServer = true;\nconst experimentalStaticLocale = undefined;\nconst en = {\n\tnotice: ${compiledEnMessage.code.replace(/;\\s*$/, \"\")}\n};\n${result.bundle.code}\n`;\n\n\tconst { notice } = await import(\n\t\t\"data:text/javascript;base64,\" + btoa(moduleSource)\n\t);\n\n\texpect(notice({ count: 3 })).toBe(\"3 items\");\n\texpect(notice.parts({ count: 3 })).toEqual([\n\t\t{ type: \"markup-start\", name: \"strong\", options: {}, attributes: {} },\n\t\t{ type: \"text\", value: \"3\" },\n\t\t{ type: \"text\", value: \" items\" },\n\t\t{ type: \"markup-end\", name: \"strong\", options: {}, attributes: {} },\n\t]);\n\texpect(result.bundle.code).toContain(\n\t\t'MessageMetadata<NoticeInputs, { locale?: \"en\" }, { strong: { options: {}; attributes: {}; children: true } }>'\n\t);\n});\n\ntest(\"low-level compilation preserves references without a layout opt-in\", () => {\n\tconst result = compileBundle({\n\t\tbundle: createPlainTextBundle(\"plain\", { en: \"Hello\", de: \"Hallo\" }),\n\t\tfallbackMap: { en: undefined, de: \"en\" },\n\t\tsettings: { baseLocale: \"en\", locales: [\"en\", \"de\"] } as ProjectSettings,\n\t\tmessageReferenceExpression: (locale) => `${locale}_plain`,\n\t});\n\texpect(result.bundle.code).toContain(\"return de_plain(inputs)\");\n\texpect(result.bundle.code).not.toContain(\n\t\t'return /** @type {LocalizedString} */ (\"Hallo\")'\n\t);\n});\n"]}
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,SAAS,qBAAqB,CAC7B,EAAU,EACV,YAAoC,EACpC,YAAY,GAAiC,EAAE;IAE/C,OAAO;QACN,EAAE;QACF,YAAY;QACZ,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;YAChE,EAAE,EAAE,GAAG,EAAE,IAAI,MAAM,EAAE;YACrB,SAAS,EAAE,EAAE;YACb,MAAM;YACN,SAAS,EAAE,EAAE;YACb,QAAQ,EAAE;gBACT;oBACC,EAAE,EAAE,GAAG,EAAE,IAAI,MAAM,UAAU;oBAC7B,UAAU,EAAE,GAAG,EAAE,IAAI,MAAM,EAAE;oBAC7B,OAAO,EAAE,EAAE;oBACX,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,KAAK,EAAE,CAAC;iBAC3C;aACD;SACD,CAAC,CAAC;KACH,CAAC;AACH,CAAC;AAED,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,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C,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 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\ntype Pattern = BundleNested[\"messages\"][number][\"variants\"][number][\"pattern\"];\n\nfunction createBundle(\n\tid: string,\n\tdeclarations: BundleNested[\"declarations\"],\n\tvariantsByLocale: Record<\n\t\tstring,\n\t\tArray<{\n\t\t\tmatches?: BundleNested[\"messages\"][number][\"variants\"][number][\"matches\"];\n\t\t\tpattern: Pattern;\n\t\t}>\n\t>,\n\tselectors: BundleNested[\"messages\"][number][\"selectors\"] = []\n): BundleNested {\n\treturn {\n\t\tid,\n\t\tdeclarations,\n\t\tmessages: Object.entries(variantsByLocale).map(([locale, variants]) => ({\n\t\t\tid: `${id}-${locale}`,\n\t\t\tbundle_id: id,\n\t\t\tlocale,\n\t\t\tselectors,\n\t\t\tvariants: variants.map((variant, index) => ({\n\t\t\t\tid: `${id}-${locale}-${index}`,\n\t\t\t\tmessage_id: `${id}-${locale}`,\n\t\t\t\tmatches: variant.matches ?? [],\n\t\t\t\tpattern: variant.pattern,\n\t\t\t})),\n\t\t})),\n\t};\n}\n\nconst variable = (name: string) => ({\n\ttype: \"expression\" as const,\n\targ: { type: \"variable-reference\" as const, name },\n});\n\nfunction createInputBundle(): BundleNested {\n\treturn createBundle(\"welcome\", [{ type: \"input-variable\", name: \"name\" }], {\n\t\ten: [{ pattern: [{ type: \"text\", value: \"Hello \" }, variable(\"name\")] }],\n\t\tde: [{ pattern: [{ type: \"text\", value: \"Hallo \" }, variable(\"name\")] }],\n\t});\n}\n\n/**\n * Imports a compiled bundle the way message-modules output assembles it: the\n * dispatcher plus the message functions of the locales it still references.\n */\nasync function importBundle(\n\tresult: ReturnType<typeof compileBundle>,\n\tbundleId: string,\n\tprelude = \"\"\n) {\n\tconst messageFunctions = Object.entries(result.messages)\n\t\t.filter(([locale]) => !result.unreferencedMessageLocales?.includes(locale))\n\t\t.map(\n\t\t\t([locale, message]) =>\n\t\t\t\t`const ${locale}_${bundleId} = ${message.code.replace(/;\\s*$/, \"\")};`\n\t\t);\n\treturn import(\n\t\t\"data:text/javascript;charset=utf-8,\" +\n\t\t\tencodeURIComponent(`\nconst getLocale = () => \"en\";\nconst experimentalStaticLocale = undefined;\n${prelude}\n${messageFunctions.join(\"\\n\")}\n${result.bundle.code}\n`)\n\t);\n}\n\ntest(\"inlines message bodies with inputs and keeps fallback targets as functions\", async () => {\n\tconst result = compileBundle({\n\t\tinlineMessages: true,\n\t\tbundle: createInputBundle(),\n\t\t// fr has no message and aliases de, so de stays a function fr can call.\n\t\tfallbackMap: { en: undefined, de: \"en\", fr: \"de\" },\n\t\tmessageReferenceExpression: (locale) => `${locale}_welcome`,\n\t\tsettings: {\n\t\t\tbaseLocale: \"en\",\n\t\t\tlocales: [\"en\", \"de\", \"fr\"],\n\t\t} as ProjectSettings,\n\t});\n\n\texpect(result.unreferencedMessageLocales).toEqual([\"en\"]);\n\texpect(result.bundle.code).not.toContain(\"en_welcome\");\n\texpect(result.bundle.code).toContain(\"fr_welcome(\");\n\n\tconst module = await importBundle(\n\t\tresult,\n\t\t\"welcome\",\n\t\t\"const fr_welcome = (i) => de_welcome(i);\"\n\t);\n\texpect(module.welcome({ name: \"Ada\" }, { locale: \"en\" })).toBe(\"Hello Ada\");\n\texpect(module.welcome({ name: \"Ada\" }, { locale: \"de\" })).toBe(\"Hallo Ada\");\n\texpect(module.welcome({ name: \"Ada\" }, { locale: \"fr\" })).toBe(\"Hallo Ada\");\n});\n\ntest(\"inlines multi-variant bodies in their own block scope\", async () => {\n\tconst variants = (none: string, some: string) => [\n\t\t{\n\t\t\tmatches: [{ type: \"literal-match\" as const, key: \"count\", value: \"0\" }],\n\t\t\tpattern: [{ type: \"text\" as const, value: none }],\n\t\t},\n\t\t{\n\t\t\tmatches: [{ type: \"catchall-match\" as const, key: \"count\" }],\n\t\t\tpattern: [{ type: \"text\" as const, value: some }],\n\t\t},\n\t];\n\tconst result = compileBundle({\n\t\tinlineMessages: true,\n\t\tbundle: createBundle(\n\t\t\t\"item_count\",\n\t\t\t[{ type: \"input-variable\", name: \"count\" }],\n\t\t\t{\n\t\t\t\ten: variants(\"No items\", \"Some items\"),\n\t\t\t\tde: variants(\"Keine Artikel\", \"Einige Artikel\"),\n\t\t\t},\n\t\t\t[{ type: \"variable-reference\", name: \"count\" }]\n\t\t),\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(result.unreferencedMessageLocales).toEqual([\"en\", \"de\"]);\n\texpect(result.bundle.code).not.toContain(\"_item_count\");\n\n\tconst module = await importBundle(result, \"item_count\");\n\texpect(module.item_count({ count: 0 }, { locale: \"en\" })).toBe(\"No items\");\n\texpect(module.item_count({ count: 3 }, { locale: \"en\" })).toBe(\"Some items\");\n\texpect(module.item_count({ count: \"0\" }, { locale: \"de\" })).toBe(\n\t\t\"Keine Artikel\"\n\t);\n\texpect(module.item_count({ count: 3 }, { locale: \"de\" })).toBe(\n\t\t\"Einige Artikel\"\n\t);\n});\n\ntest(\"inlines locals that repeat across locales and shadow the dispatcher's locale and options\", async () => {\n\t// Each locale declares `locale` and `options` again, next to the\n\t// dispatcher's own `locale` constant and `options` parameter.\n\tconst pattern = (label: string): Pattern => [\n\t\t{ type: \"text\", value: label },\n\t\tvariable(\"locale\"),\n\t\t{ type: \"text\", value: \" \" },\n\t\tvariable(\"options\"),\n\t];\n\tconst result = compileBundle({\n\t\tinlineMessages: true,\n\t\tbundle: createBundle(\n\t\t\t\"weight\",\n\t\t\t[\n\t\t\t\t{ type: \"input-variable\", name: \"amount\" },\n\t\t\t\t{\n\t\t\t\t\ttype: \"local-variable\",\n\t\t\t\t\tname: \"locale\",\n\t\t\t\t\tvalue: variable(\"amount\"),\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttype: \"local-variable\",\n\t\t\t\t\tname: \"options\",\n\t\t\t\t\tvalue: {\n\t\t\t\t\t\ttype: \"expression\",\n\t\t\t\t\t\targ: { type: \"literal\", value: \"kg\" },\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t],\n\t\t\t{\n\t\t\t\ten: [{ pattern: pattern(\"Weight: \") }],\n\t\t\t\tde: [{ pattern: pattern(\"Gewicht: \") }],\n\t\t\t}\n\t\t),\n\t\tfallbackMap: { en: undefined, de: \"en\" },\n\t\tmessageReferenceExpression: (locale) => `${locale}_weight`,\n\t\tsettings: { baseLocale: \"en\", locales: [\"en\", \"de\"] } as ProjectSettings,\n\t});\n\texpect(result.unreferencedMessageLocales).toEqual([\"en\", \"de\"]);\n\texpect(result.bundle.code).not.toContain(\"_weight\");\n\n\tconst module = await importBundle(result, \"weight\");\n\texpect(module.weight({ amount: 5 }, { locale: \"en\" })).toBe(\"Weight: 5 kg\");\n\texpect(module.weight({ amount: 5 }, { locale: \"de\" })).toBe(\"Gewicht: 5 kg\");\n\texpect(module.weight({ amount: 5 })).toBe(\"Weight: 5 kg\");\n});\n\ntest(\"returns the bundle id from an inlined body when no variant matches\", async () => {\n\tconst variants = (zero: string, one: string) => [\n\t\t{\n\t\t\tmatches: [{ type: \"literal-match\" as const, key: \"count\", value: \"0\" }],\n\t\t\tpattern: [{ type: \"text\" as const, value: zero }],\n\t\t},\n\t\t{\n\t\t\tmatches: [{ type: \"literal-match\" as const, key: \"count\", value: \"1\" }],\n\t\t\tpattern: [{ type: \"text\" as const, value: one }],\n\t\t},\n\t];\n\tconst result = compileBundle({\n\t\tinlineMessages: true,\n\t\tbundle: createBundle(\n\t\t\t\"bottles\",\n\t\t\t[{ type: \"input-variable\", name: \"count\" }],\n\t\t\t{\n\t\t\t\ten: variants(\"No bottles\", \"One bottle\"),\n\t\t\t\tde: variants(\"Keine Flaschen\", \"Eine Flasche\"),\n\t\t\t},\n\t\t\t[{ type: \"variable-reference\", name: \"count\" }]\n\t\t),\n\t\tfallbackMap: { en: undefined, de: \"en\" },\n\t\tmessageReferenceExpression: (locale) => `${locale}_bottles`,\n\t\tsettings: { baseLocale: \"en\", locales: [\"en\", \"de\"] } as ProjectSettings,\n\t});\n\texpect(result.unreferencedMessageLocales).toEqual([\"en\", \"de\"]);\n\texpect(result.bundle.code).not.toContain(\"_bottles\");\n\n\tconst module = await importBundle(result, \"bottles\");\n\texpect(module.bottles({ count: 1 }, { locale: \"de\" })).toBe(\"Eine Flasche\");\n\texpect(module.bottles({ count: 7 }, { locale: \"en\" })).toBe(\"bottles\");\n\texpect(module.bottles({ count: 7 }, { locale: \"de\" })).toBe(\"bottles\");\n});\n\ntest(\"keeps message functions with inputs in a per-locale build\", () => {\n\tconst result = compileBundle({\n\t\tinlineMessages: true,\n\t\tbundle: createInputBundle(),\n\t\tfallbackMap: { en: undefined, de: \"en\" },\n\t\tmessageReferenceExpression: (locale) => `${locale}_welcome`,\n\t\tsettings: { baseLocale: \"en\", locales: [\"en\", \"de\"] } as ProjectSettings,\n\t\texperimentalStaticLocale: perLocaleBuildStaticLocaleExpression,\n\t});\n\n\texpect(result.unreferencedMessageLocales).toEqual([]);\n\texpect(result.bundle.code).toContain(\n\t\t'if (locale === \"de\") return de_welcome(inputs)'\n\t);\n\texpect(result.bundle.code).toContain(\"return en_welcome(inputs)\");\n});\n\ntest(\"runs inlined bodies on the server and forwards the inputs on the client when middleware locale splitting is on\", async () => {\n\tconst result = compileBundle({\n\t\tinlineMessages: true,\n\t\tbundle: createInputBundle(),\n\t\tfallbackMap: { en: undefined, de: \"en\" },\n\t\tmessageReferenceExpression: (locale) => `${locale}_welcome`,\n\t\tsettings: { baseLocale: \"en\", locales: [\"en\", \"de\"] } as ProjectSettings,\n\t\texperimentalMiddlewareLocaleSplitting: true,\n\t});\n\texpect(result.unreferencedMessageLocales).toEqual([\"en\", \"de\"]);\n\texpect(result.bundle.code).not.toContain(\"_welcome\");\n\n\tconst module = await importBundle(\n\t\tresult,\n\t\t\"welcome\",\n\t\t`const experimentalMiddlewareLocaleSplitting = true;\nlet isServer = true;\nexport const setIsServer = (value) => { isServer = value; };\nexport const tracked = [];\nconst trackMessageCall = (id, locale) => tracked.push([id, locale]);`\n\t);\n\tconst inputs = { name: \"Ada\" };\n\n\texpect(module.welcome(inputs, { locale: \"de\" })).toBe(\"Hallo Ada\");\n\texpect(module.tracked).toEqual([[\"welcome\", \"de\"]]);\n\n\tconst serverCalls: unknown[] = [];\n\tconst scope = globalThis as { __paraglide?: unknown };\n\tscope.__paraglide = {\n\t\tssr: {\n\t\t\twelcome: (received: unknown) => {\n\t\t\t\tserverCalls.push(received);\n\t\t\t\treturn \"from the server\";\n\t\t\t},\n\t\t},\n\t};\n\ttry {\n\t\tmodule.setIsServer(false);\n\t\texpect(module.welcome(inputs, { locale: \"de\" })).toBe(\"from the server\");\n\t\texpect(serverCalls).toEqual([inputs]);\n\t\texpect(serverCalls[0]).toBe(inputs);\n\t} finally {\n\t\tdelete scope.__paraglide;\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"]}
@@ -66,4 +66,87 @@ test.each([false, true])("closes the loaded project after write failure and perm
66
66
  writeSpy.mockRestore();
67
67
  }
68
68
  });
69
+ async function createMessageFormatProject() {
70
+ const fs = memfs().fs;
71
+ const diskFs = await import("node:fs/promises");
72
+ await fs.promises.mkdir("/project.inlang", { recursive: true });
73
+ await fs.promises.mkdir("/messages", { recursive: true });
74
+ await fs.promises.writeFile("/plugin.js", await diskFs.readFile(new URL("../../node_modules/@inlang/plugin-message-format/dist/index.js", import.meta.url)));
75
+ await fs.promises.writeFile("/project.inlang/settings.json", JSON.stringify({
76
+ baseLocale: "en",
77
+ // fr has no resource file: a missing file stays tolerated
78
+ locales: ["en", "de", "fr"],
79
+ modules: ["/plugin.js"],
80
+ "plugin.inlang.messageFormat": {
81
+ pathPattern: "/messages/{locale}.json",
82
+ },
83
+ }));
84
+ await fs.promises.writeFile("/messages/en.json", JSON.stringify({ greeting: "Hello" }));
85
+ await fs.promises.writeFile("/messages/de.json", JSON.stringify({ greeting: "Hallo" }));
86
+ return fs;
87
+ }
88
+ test.each([
89
+ ["cleaning the output directory", true],
90
+ ["updating the previous compilation", false],
91
+ ])("rejects unreadable translation resources before %s", async (_, cleanOutdir) => {
92
+ const sdk = await import("@inlang/sdk");
93
+ const { hashDirectory } = await import("../services/file-handling/write-output.js");
94
+ const fs = await createMessageFormatProject();
95
+ const load = sdk.loadProjectFromDirectory;
96
+ const closed = vi.fn();
97
+ const loadSpy = vi
98
+ .spyOn(sdk, "loadProjectFromDirectory")
99
+ .mockImplementation(async (args) => {
100
+ const loaded = await load(args);
101
+ const close = loaded.close.bind(loaded);
102
+ loaded.close = async () => {
103
+ closed();
104
+ await close();
105
+ };
106
+ return loaded;
107
+ });
108
+ const originalRead = fs.promises.readFile.bind(fs.promises);
109
+ const denied = Object.assign(new Error("EACCES: permission denied, open '/messages/de.json'"), { code: "EACCES" });
110
+ const readSpy = vi.spyOn(fs.promises, "readFile");
111
+ const options = {
112
+ project: "/project.inlang",
113
+ outdir: "/output",
114
+ fs,
115
+ cleanOutdir,
116
+ };
117
+ try {
118
+ const previous = await compile(options);
119
+ const before = await hashDirectory("/output", fs.promises);
120
+ expect(before).toEqual(previous.outputHashes);
121
+ expect(await fs.promises.readFile("/output/messages/greeting.js", "utf8")).toContain("Hallo");
122
+ readSpy.mockImplementation((async (...args) => {
123
+ if (String(args[0]) === "/messages/de.json")
124
+ throw denied;
125
+ return originalRead(...args);
126
+ }));
127
+ const failure = await compile({
128
+ ...options,
129
+ previousCompilation: cleanOutdir ? undefined : previous,
130
+ }).then(() => undefined, (error) => error);
131
+ expect(await hashDirectory("/output", fs.promises)).toEqual(before);
132
+ expect(failure).toBeInstanceOf(AggregateError);
133
+ expect(failure.message).toContain("/messages/de.json (EACCES)");
134
+ expect(failure.errors).toEqual([
135
+ expect.objectContaining({
136
+ name: "ResourceFileImportError",
137
+ cause: denied,
138
+ }),
139
+ ]);
140
+ expect(closed).toHaveBeenCalledTimes(2);
141
+ readSpy.mockRestore();
142
+ const recovered = await compile(options);
143
+ expect(recovered.outputHashes).toEqual(previous.outputHashes);
144
+ expect(await hashDirectory("/output", fs.promises)).toEqual(before);
145
+ expect(closed).toHaveBeenCalledTimes(3);
146
+ }
147
+ finally {
148
+ loadSpy.mockRestore();
149
+ readSpy.mockRestore();
150
+ }
151
+ });
69
152
  //# sourceMappingURL=compile-lifecycle.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"compile-lifecycle.test.js","sourceRoot":"","sources":["../../src/compiler/compile-lifecycle.test.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,mBAAmB,EACnB,UAAU,EACV,sBAAsB,GACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC1C,OAAO,EAAE,OAAO,EAA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E;SACF,CAAC,CAAC;QACH,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;QACzD,MAAM,CAAC,MAAM,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;IACzC,CAAC;YAAS,CAAC;QACV,OAAO,CAAC,WAAW,EAAE,CAAC;QACtB,QAAQ,CAAC,WAAW,EAAE,CAAC;IACxB,CAAC;AACF,CAAC,CACD,CAAC","sourcesContent":["import {\n\tloadProjectInMemory,\n\tnewProject,\n\tsaveProjectToDirectory,\n} from \"@inlang/sdk\";\nimport { memfs } from \"memfs\";\nimport { test, expect, vi } from \"vitest\";\nimport { compile } from \"./compile.js\";\n\nvi.mock(\"@inlang/sdk\", async (importOriginal) => {\n\tconst sdk = await importOriginal<typeof import(\"@inlang/sdk\")>();\n\treturn {\n\t\t...sdk,\n\t\tloadProjectFromDirectory: vi.fn(sdk.loadProjectFromDirectory),\n\t};\n});\n\ntest.each([false, true])(\n\t\"closes the loaded project after write failure and permits a retry (cleanup fails: %s)\",\n\tasync (cleanupFails) => {\n\t\tconst sdk = await import(\"@inlang/sdk\");\n\t\tconst fs = memfs().fs as unknown as typeof import(\"node:fs\");\n\t\tconst project = await loadProjectInMemory({ blob: await newProject({}) });\n\t\ttry {\n\t\t\tawait saveProjectToDirectory({\n\t\t\t\tproject,\n\t\t\t\tpath: \"/project.inlang\",\n\t\t\t\tfs: fs.promises,\n\t\t\t});\n\t\t} finally {\n\t\t\tawait project.close();\n\t\t}\n\t\tconst load = sdk.loadProjectFromDirectory;\n\t\tconst closed = vi.fn();\n\t\tconst loadSpy = vi\n\t\t\t.spyOn(sdk, \"loadProjectFromDirectory\")\n\t\t\t.mockImplementation(async (args) => {\n\t\t\t\tconst loaded = await load(args);\n\t\t\t\tconst close = loaded.close.bind(loaded);\n\t\t\t\tloaded.close = async () => {\n\t\t\t\t\tclosed();\n\t\t\t\t\tawait close();\n\t\t\t\t\tif (cleanupFails && closed.mock.calls.length === 1)\n\t\t\t\t\t\tthrow new Error(\"close failed\");\n\t\t\t\t};\n\t\t\t\treturn loaded;\n\t\t\t});\n\t\tconst originalWrite = fs.promises.writeFile.bind(fs.promises);\n\t\tconst error = Object.assign(new Error(\"write: no space left on device\"), {\n\t\t\tcode: \"ENOSPC\",\n\t\t});\n\t\tconst writeSpy = vi\n\t\t\t.spyOn(fs.promises, \"writeFile\")\n\t\t\t.mockImplementation((async (...args) => {\n\t\t\t\tif (String(args[0]).startsWith(\"/output/\")) throw error;\n\t\t\t\treturn originalWrite(...args);\n\t\t\t}) as typeof fs.promises.writeFile);\n\t\ttry {\n\t\t\tawait expect(\n\t\t\t\tcompile({ project: \"/project.inlang\", outdir: \"/output\", fs })\n\t\t\t).rejects.toBe(error);\n\t\t\texpect(closed).toHaveBeenCalledTimes(1);\n\t\t\twriteSpy.mockRestore();\n\t\t\tconst result = await compile({\n\t\t\t\tproject: \"/project.inlang\",\n\t\t\t\toutdir: \"/output\",\n\t\t\t\tfs,\n\t\t\t});\n\t\t\texpect(result.outputHashes).toHaveProperty(\"runtime.js\");\n\t\t\texpect(closed).toHaveBeenCalledTimes(2);\n\t\t} finally {\n\t\t\tloadSpy.mockRestore();\n\t\t\twriteSpy.mockRestore();\n\t\t}\n\t}\n);\n"]}
1
+ {"version":3,"file":"compile-lifecycle.test.js","sourceRoot":"","sources":["../../src/compiler/compile-lifecycle.test.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,mBAAmB,EACnB,UAAU,EACV,sBAAsB,GACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,EAAE,CAAC,IAAI,CAAC,aAAa,EAAE,KAAK,EAAE,cAAc,EAAE,EAAE;IAC/C,MAAM,GAAG,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AAC;QAC/C,MAAM,CAAE,OAA0B,CAAC,OAAO,CAAC,CAAC,SAAS,CACpD,4BAA4B,CAC5B,CAAC;QACF,MAAM,CAAE,OAA0B,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;YAClD,MAAM,CAAC,gBAAgB,CAAC;gBACvB,IAAI,EAAE,yBAAyB;gBAC/B,KAAK,EAAE,MAAM;aACb,CAAC;SACF,CAAC,CAAC;QACH,MAAM,CAAC,MAAM,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;QAExC,OAAO,CAAC,WAAW,EAAE,CAAC;QACtB,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;QACzC,MAAM,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;QAC9D,MAAM,CAAC,MAAM,aAAa,CAAC,SAAS,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACpE,MAAM,CAAC,MAAM,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;IACzC,CAAC;YAAS,CAAC;QACV,OAAO,CAAC,WAAW,EAAE,CAAC;QACtB,OAAO,CAAC,WAAW,EAAE,CAAC;IACvB,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\nasync function createMessageFormatProject() {\n\tconst fs = memfs().fs as unknown as typeof import(\"node:fs\");\n\tconst diskFs = await import(\"node:fs/promises\");\n\tawait fs.promises.mkdir(\"/project.inlang\", { recursive: true });\n\tawait fs.promises.mkdir(\"/messages\", { recursive: true });\n\tawait fs.promises.writeFile(\n\t\t\"/plugin.js\",\n\t\tawait diskFs.readFile(\n\t\t\tnew URL(\n\t\t\t\t\"../../node_modules/@inlang/plugin-message-format/dist/index.js\",\n\t\t\t\timport.meta.url\n\t\t\t)\n\t\t)\n\t);\n\tawait fs.promises.writeFile(\n\t\t\"/project.inlang/settings.json\",\n\t\tJSON.stringify({\n\t\t\tbaseLocale: \"en\",\n\t\t\t// fr has no resource file: a missing file stays tolerated\n\t\t\tlocales: [\"en\", \"de\", \"fr\"],\n\t\t\tmodules: [\"/plugin.js\"],\n\t\t\t\"plugin.inlang.messageFormat\": {\n\t\t\t\tpathPattern: \"/messages/{locale}.json\",\n\t\t\t},\n\t\t})\n\t);\n\tawait fs.promises.writeFile(\n\t\t\"/messages/en.json\",\n\t\tJSON.stringify({ greeting: \"Hello\" })\n\t);\n\tawait fs.promises.writeFile(\n\t\t\"/messages/de.json\",\n\t\tJSON.stringify({ greeting: \"Hallo\" })\n\t);\n\treturn fs;\n}\n\ntest.each([\n\t[\"cleaning the output directory\", true],\n\t[\"updating the previous compilation\", false],\n] as const)(\n\t\"rejects unreadable translation resources before %s\",\n\tasync (_, cleanOutdir) => {\n\t\tconst sdk = await import(\"@inlang/sdk\");\n\t\tconst { hashDirectory } =\n\t\t\tawait import(\"../services/file-handling/write-output.js\");\n\t\tconst fs = await createMessageFormatProject();\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};\n\t\t\t\treturn loaded;\n\t\t\t});\n\t\tconst originalRead = fs.promises.readFile.bind(fs.promises);\n\t\tconst denied = Object.assign(\n\t\t\tnew Error(\"EACCES: permission denied, open '/messages/de.json'\"),\n\t\t\t{ code: \"EACCES\" }\n\t\t);\n\t\tconst readSpy = vi.spyOn(fs.promises, \"readFile\");\n\t\tconst options = {\n\t\t\tproject: \"/project.inlang\",\n\t\t\toutdir: \"/output\",\n\t\t\tfs,\n\t\t\tcleanOutdir,\n\t\t};\n\t\ttry {\n\t\t\tconst previous = await compile(options);\n\t\t\tconst before = await hashDirectory(\"/output\", fs.promises);\n\t\t\texpect(before).toEqual(previous.outputHashes);\n\t\t\texpect(\n\t\t\t\tawait fs.promises.readFile(\"/output/messages/greeting.js\", \"utf8\")\n\t\t\t).toContain(\"Hallo\");\n\n\t\t\treadSpy.mockImplementation((async (...args) => {\n\t\t\t\tif (String(args[0]) === \"/messages/de.json\") throw denied;\n\t\t\t\treturn originalRead(...args);\n\t\t\t}) as typeof fs.promises.readFile);\n\t\t\tconst failure = await compile({\n\t\t\t\t...options,\n\t\t\t\tpreviousCompilation: cleanOutdir ? undefined : previous,\n\t\t\t}).then(\n\t\t\t\t() => undefined,\n\t\t\t\t(error: unknown) => error\n\t\t\t);\n\t\t\texpect(await hashDirectory(\"/output\", fs.promises)).toEqual(before);\n\t\t\texpect(failure).toBeInstanceOf(AggregateError);\n\t\t\texpect((failure as AggregateError).message).toContain(\n\t\t\t\t\"/messages/de.json (EACCES)\"\n\t\t\t);\n\t\t\texpect((failure as AggregateError).errors).toEqual([\n\t\t\t\texpect.objectContaining({\n\t\t\t\t\tname: \"ResourceFileImportError\",\n\t\t\t\t\tcause: denied,\n\t\t\t\t}),\n\t\t\t]);\n\t\t\texpect(closed).toHaveBeenCalledTimes(2);\n\n\t\t\treadSpy.mockRestore();\n\t\t\tconst recovered = await compile(options);\n\t\t\texpect(recovered.outputHashes).toEqual(previous.outputHashes);\n\t\t\texpect(await hashDirectory(\"/output\", fs.promises)).toEqual(before);\n\t\t\texpect(closed).toHaveBeenCalledTimes(3);\n\t\t} finally {\n\t\t\tloadSpy.mockRestore();\n\t\t\treadSpy.mockRestore();\n\t\t}\n\t}\n);\n"]}
@@ -28,6 +28,15 @@ export type CompiledMessage = Compiled<CompilableMessage> & {
28
28
  * The output imports the registry only if a message calls it.
29
29
  */
30
30
  registryFunctions: string[];
31
+ /**
32
+ * The statements of the message function body, for messages without markup.
33
+ * The statements read the inputs as `i` and return on every path, so a
34
+ * dispatcher can run them in place of calling the message function.
35
+ */
36
+ inline?: {
37
+ statements: string[];
38
+ readsInput: boolean;
39
+ };
31
40
  };
32
41
  /**
33
42
  * Returns the compiled message as a string
@@ -52,10 +52,13 @@ function compileMessageWithOneVariant(declarations, message, variants, matchType
52
52
  registryUsage,
53
53
  });
54
54
  if (!hasMarkup) {
55
- const code = `/** @type {(inputs: ${messageInputType}) => LocalizedString} */ (${stringLocals.readsInput ? "i" : ""}) => {
56
- ${stringLocals.code.join("\n\t")}return /** @type {LocalizedString} */ (${compiledPattern.code})
57
- };`;
58
- return { code, node: message, registryFunctions: [...registryUsage] };
55
+ return compiledStringMessage(message, messageInputType, registryUsage, {
56
+ statements: [
57
+ ...stringLocals.code,
58
+ `return /** @type {LocalizedString} */ (${compiledPattern.code})`,
59
+ ],
60
+ readsInput: stringLocals.readsInput,
61
+ });
59
62
  }
60
63
  const compiledPartsPattern = compilePattern({
61
64
  pattern: variant.pattern,
@@ -175,12 +178,16 @@ function compileMessageWithMultipleVariants(declarations, message, variants, mat
175
178
  : `if (${step.condition}) return /** @type {import('../runtime.js').MessagePart[]} */ (${compiledPartsPattern.code});`);
176
179
  }
177
180
  }
181
+ const fallbackString = `return /** @type {LocalizedString} */ (${JSON.stringify(messageBundleId(message))});`;
178
182
  if (!hasMarkup) {
179
- const code = `/** @type {(inputs: ${messageInputType}) => LocalizedString} */ (${stringLocals.readsInput ? "i" : ""}) => {${stringLocals.code.join("\n\t")}
180
- ${compiledVariants.join("\n\t")}
181
- ${hasCatchAll ? "" : `return /** @type {LocalizedString} */ (${JSON.stringify(messageBundleId(message))});`}
182
- };`;
183
- return { code, node: message, registryFunctions: [...registryUsage] };
183
+ return compiledStringMessage(message, messageInputType, registryUsage, {
184
+ statements: [
185
+ ...stringLocals.code,
186
+ ...compiledVariants,
187
+ ...(hasCatchAll ? [] : [fallbackString]),
188
+ ],
189
+ readsInput: stringLocals.readsInput,
190
+ });
184
191
  }
185
192
  const localVariablesCode = joinLocalVariables(stringLocals.code);
186
193
  const partsLocalVariablesCode = joinLocalVariables(partsLocals.code);
@@ -198,9 +205,7 @@ function compileMessageWithMultipleVariants(declarations, message, variants, mat
198
205
  const code = `/** @type {((inputs: ${inputType}) => LocalizedString) & { parts: (inputs: ${inputType}) => import('../runtime.js').MessagePart[] }} */ (
199
206
  /* @__PURE__ */ Object.assign(
200
207
  /** @type {(inputs: ${inputType}) => LocalizedString} */ ((${messageInput}) => {
201
- ${localVariablesCode}${stringVariantsCode}${hasCatchAll
202
- ? ""
203
- : `return /** @type {LocalizedString} */ (${JSON.stringify(messageBundleId(message))});`}
208
+ ${localVariablesCode}${stringVariantsCode}${hasCatchAll ? "" : fallbackString}
204
209
  }),
205
210
  {
206
211
  parts: /** @type {(inputs: ${inputType}) => import('../runtime.js').MessagePart[]} */ ((${partsMessageInput}) => {
@@ -213,6 +218,18 @@ function compileMessageWithMultipleVariants(declarations, message, variants, mat
213
218
  );`;
214
219
  return { code, node: message, registryFunctions: [...registryUsage] };
215
220
  }
221
+ /**
222
+ * A message without markup: the function and its body statements, which a
223
+ * dispatcher can run in place of calling the function.
224
+ */
225
+ function compiledStringMessage(message, inputType, registryUsage, inline) {
226
+ return {
227
+ code: `/** @type {(inputs: ${inputType}) => LocalizedString} */ (${inline.readsInput ? "i" : ""}) => {\n\t${inline.statements.join("\n\t")}\n};`,
228
+ node: message,
229
+ registryFunctions: [...registryUsage],
230
+ inline,
231
+ };
232
+ }
216
233
  /**
217
234
  * Compiles the local variables a message function reads, directly or through
218
235
  * other locals, in dependency order. Unread locals are left out. `readsInput`
@@ -1 +1 @@
1
- {"version":3,"file":"compile-message.js","sourceRoot":"","sources":["../../src/compiler/compile-message.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAAE,UAAU,EAAwB,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAEnE,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EACN,yBAAyB,EACzB,oBAAoB,GACpB,MAAM,qBAAqB,CAAC;AAkB7B;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,OAA0B;IACzD,MAAM,GAAG,GAAG,OAAoD,CAAC;IACjE,MAAM,QAAQ,GAAG,GAAG,CAAC,SAAS,IAAI,GAAG,CAAC,QAAQ,CAAC;IAC/C,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAClC,MAAM,IAAI,KAAK,CACd,WAAW,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC,YAAY,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,oBAAoB,CACnG,CAAC;IACH,CAAC;IACD,OAAO,QAAQ,CAAC;AACjB,CAAC;AAUD;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAC7B,YAA2B,EAC3B,OAA0B,EAC1B,QAA6B,EAC7B,UAA4B,EAC5B,kBAA2B,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,CAAC,CAAC;SAClE,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QACrB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAC3C,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAE,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAE,CAAC;YAC5C,IAAI,IAAI,KAAK,CAAC;gBAAE,OAAO,IAAI,CAAC;QAC7B,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;IACjC,CAAC,CAAC;SACD,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AACjC,CAAC;AAED,SAAS,gBAAgB,CAAC,OAAgB;IACzC,OAAO,OAAO,CAAC,IAAI,CAClB,CAAC,IAAI,EAAE,EAAE,CACR,IAAI,CAAC,IAAI,KAAK,cAAc;QAC5B,IAAI,CAAC,IAAI,KAAK,YAAY;QAC1B,IAAI,CAAC,IAAI,KAAK,mBAAmB,CAClC,CAAC;AACH,CAAC","sourcesContent":["import type {\n\tDeclaration,\n\tLocalVariable,\n\tMessage,\n\tPattern,\n\tVariant,\n} from \"@inlang/sdk\";\nimport { compilePattern } from \"./compile-pattern.js\";\nimport type { Compiled } from \"./types.js\";\nimport { inputsType, type InputMatchTypes } from \"./jsdoc-types.js\";\nimport { compileLocalVariable } from \"./compile-local-variable.js\";\nimport type { RegistryUsage } from \"./compile-annotation.js\";\nimport { renderInputMatchCondition } from \"./match-literals.js\";\nimport { compileInputAccess } from \"./variable-access.js\";\nimport { resolveInputAlias } from \"./input-alias.js\";\nimport {\n\tpatternVariableReferences,\n\tresolveMessageLocals,\n} from \"./message-locals.js\";\n\n/**\n * The message fields the compiler reads.\n *\n * `selectBundleNested()` of `@inlang/sdk` 4 returns the bundle id as\n * `bundle_id` (the database column). The camelCase `bundleId` of the SDK's\n * plugin `Message` shape is accepted too.\n */\nexport type CompilableMessage = Pick<Message, \"id\" | \"locale\" | \"selectors\"> &\n\t({ bundleId: string } | { bundle_id: string });\n\n/**\n * The variant fields the compiler reads. The message id (`message_id` in\n * `@inlang/sdk` 4 rows) is not needed.\n */\nexport type CompilableVariant = Pick<Variant, \"id\" | \"matches\" | \"pattern\">;\n\n/**\n * The bundle id of a message with either SDK version.\n */\nexport function messageBundleId(message: CompilableMessage): string {\n\tconst ids = message as { bundle_id?: string; bundleId?: string };\n\tconst bundleId = ids.bundle_id ?? ids.bundleId;\n\tif (typeof bundleId !== \"string\") {\n\t\tthrow new Error(\n\t\t\t`Message ${JSON.stringify(message.id)} (locale ${JSON.stringify(message.locale)}) has no bundle id`\n\t\t);\n\t}\n\treturn bundleId;\n}\n\nexport type CompiledMessage = Compiled<CompilableMessage> & {\n\t/**\n\t * The registry functions the compiled code calls, e.g. `[\"plural\"]`.\n\t * The output imports the registry only if a message calls it.\n\t */\n\tregistryFunctions: string[];\n};\n\n/**\n * Returns the compiled message as a string\n *\n */\nexport const compileMessage = (\n\tdeclarations: Declaration[],\n\tmessage: CompilableMessage,\n\tvariants: CompilableVariant[],\n\tmatchTypes?: InputMatchTypes,\n\tinputTypeAliasName?: string\n): CompiledMessage => {\n\t// return empty string instead?\n\tif (variants.length == 0) {\n\t\tthrow new Error(\"Message must have at least one variant\");\n\t}\n\n\tconst hasMultipleVariants = variants.length > 1;\n\treturn hasMultipleVariants\n\t\t? compileMessageWithMultipleVariants(\n\t\t\t\tdeclarations,\n\t\t\t\tmessage,\n\t\t\t\tvariants,\n\t\t\t\tmatchTypes,\n\t\t\t\tinputTypeAliasName\n\t\t\t)\n\t\t: compileMessageWithOneVariant(\n\t\t\t\tdeclarations,\n\t\t\t\tmessage,\n\t\t\t\tvariants,\n\t\t\t\tmatchTypes,\n\t\t\t\tinputTypeAliasName\n\t\t\t);\n};\n\nfunction compileMessageWithOneVariant(\n\tdeclarations: Declaration[],\n\tmessage: CompilableMessage,\n\tvariants: CompilableVariant[],\n\tmatchTypes?: InputMatchTypes,\n\tinputTypeAliasName?: string\n): CompiledMessage {\n\tconst variant = variants[0];\n\tif (!variant || variants.length !== 1) {\n\t\tthrow new Error(\"Message must have exactly one variant\");\n\t}\n\n\tconst hasMarkup = patternHasMarkup(variant.pattern);\n\tconst inputs = declarations.filter((decl) => decl.type === \"input-variable\");\n\tconst registryUsage: RegistryUsage = new Set();\n\tconst messageInputType = inputTypeAliasName ?? inputsType(inputs, matchTypes);\n\t// resolve before compiling the pattern to report undeclared variables\n\t// with the bundle id and locale\n\tconst stringLocals = compileLocalVariables(\n\t\tpatternVariableReferences(variant.pattern, \"string\"),\n\t\tdeclarations,\n\t\tmessage,\n\t\tregistryUsage\n\t);\n\tconst partsLocals = hasMarkup\n\t\t? compileLocalVariables(\n\t\t\t\tpatternVariableReferences(variant.pattern, \"parts\"),\n\t\t\t\tdeclarations,\n\t\t\t\tmessage,\n\t\t\t\tregistryUsage\n\t\t\t)\n\t\t: { code: [], readsInput: false };\n\tconst compiledPattern = compilePattern({\n\t\tpattern: variant.pattern,\n\t\tdeclarations,\n\t\tlocale: message.locale,\n\t\tregistryUsage,\n\t});\n\n\tif (!hasMarkup) {\n\t\tconst code = `/** @type {(inputs: ${messageInputType}) => LocalizedString} */ (${stringLocals.readsInput ? \"i\" : \"\"}) => {\n\t${stringLocals.code.join(\"\\n\\t\")}return /** @type {LocalizedString} */ (${compiledPattern.code})\n};`;\n\n\t\treturn { code, node: message, registryFunctions: [...registryUsage] };\n\t}\n\n\tconst compiledPartsPattern = compilePattern({\n\t\tpattern: variant.pattern,\n\t\tdeclarations,\n\t\tmode: \"parts\",\n\t\tlocale: message.locale,\n\t\tregistryUsage,\n\t});\n\tconst localVariablesCode = joinLocalVariables(stringLocals.code);\n\tconst partsLocalVariablesCode = joinLocalVariables(partsLocals.code);\n\tconst inputType = messageInputType;\n\t// only declare the input parameter where it is read (noUnusedParameters)\n\tconst messageInput = stringLocals.readsInput ? \"i\" : \"\";\n\tconst partsMessageInput = partsLocals.readsInput ? \"i\" : \"\";\n\n\tconst partsCode = `/** @type {((inputs: ${inputType}) => LocalizedString) & { parts: (inputs: ${inputType}) => import('../runtime.js').MessagePart[] }} */ (\n\t/* @__PURE__ */ Object.assign(\n\t\t/** @type {(inputs: ${inputType}) => LocalizedString} */ ((${messageInput}) => {\n\t\t\t${localVariablesCode}return /** @type {LocalizedString} */ (${compiledPattern.code})\n\t\t}),\n\t\t{\n\t\t\tparts: /** @type {(inputs: ${inputType}) => import('../runtime.js').MessagePart[]} */ ((${partsMessageInput}) => {\n\t\t\t\t${partsLocalVariablesCode}return /** @type {import('../runtime.js').MessagePart[]} */ (${compiledPartsPattern.code})\n\t\t\t})\n\t\t}\n\t)\n);`;\n\n\treturn {\n\t\tcode: partsCode,\n\t\tnode: message,\n\t\tregistryFunctions: [...registryUsage],\n\t};\n}\n\nfunction compileMessageWithMultipleVariants(\n\tdeclarations: Declaration[],\n\tmessage: CompilableMessage,\n\tvariants: CompilableVariant[],\n\tmatchTypes?: InputMatchTypes,\n\tinputTypeAliasName?: string\n): CompiledMessage {\n\tif (variants.length <= 1) {\n\t\tthrow new Error(\"Message must have more than one variant\");\n\t}\n\n\tconst hasMarkup = variants.some((variant) =>\n\t\tpatternHasMarkup(variant.pattern)\n\t);\n\tconst inputs = declarations.filter((decl) => decl.type === \"input-variable\");\n\tconst registryUsage: RegistryUsage = new Set();\n\tconst messageInputType = inputTypeAliasName ?? inputsType(inputs, matchTypes);\n\n\t// The variants the function checks, in preference order. A variant without\n\t// a condition is a catchall and returns unconditionally.\n\tconst steps: Array<{ pattern: Pattern; condition?: string }> = [];\n\t// variables the match conditions read\n\tconst conditionReads: string[] = [];\n\n\tlet hasCatchAll = false;\n\n\tfor (const variant of sortVariantsBySelectorPreference(\n\t\tvariants,\n\t\tmessage.selectors\n\t)) {\n\t\tconst isCatchAll = variant.matches.every(\n\t\t\t(match) => match.type === \"catchall-match\"\n\t\t);\n\n\t\tif (isCatchAll) {\n\t\t\tsteps.push({ pattern: variant.pattern });\n\t\t\thasCatchAll = true;\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst conditions: string[] = [];\n\n\t\tfor (const match of variant.matches) {\n\t\t\t// catch all matches are not used in the conditions\n\t\t\tif (match.type !== \"literal-match\") {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst variableType = declarations.find(\n\t\t\t\t(decl) => decl.name === match.key\n\t\t\t)?.type;\n\t\t\tif (variableType === \"input-variable\") {\n\t\t\t\tconditionReads.push(match.key);\n\t\t\t\tconditions.push(\n\t\t\t\t\trenderInputMatchCondition(compileInputAccess(match.key), match.value)\n\t\t\t\t);\n\t\t\t} else if (variableType === \"local-variable\") {\n\t\t\t\tconditionReads.push(match.key);\n\t\t\t\t// An un-annotated local that aliases an input holds the raw input\n\t\t\t\t// value (e.g. ICU `=0` imports as `.local countPluralExact = {$count}`)\n\t\t\t\t// and must match like the input itself, numerically for numbers.\n\t\t\t\t// Annotated locals hold the function's result and match as strings.\n\t\t\t\tconditions.push(\n\t\t\t\t\tresolveInputAlias(match.key, declarations) !== undefined\n\t\t\t\t\t\t? renderInputMatchCondition(match.key, match.value)\n\t\t\t\t\t\t: `${match.key} === ${JSON.stringify(match.value)}`\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tif (conditions.length === 0) continue;\n\t\tsteps.push({\n\t\t\tpattern: variant.pattern,\n\t\t\tcondition: conditions.join(\" && \"),\n\t\t});\n\t}\n\n\t// resolve before compiling the patterns to report undeclared variables\n\t// with the bundle id and locale\n\tconst stringLocals = compileLocalVariables(\n\t\t[\n\t\t\t...conditionReads,\n\t\t\t...steps.flatMap((step) =>\n\t\t\t\tpatternVariableReferences(step.pattern, \"string\")\n\t\t\t),\n\t\t],\n\t\tdeclarations,\n\t\tmessage,\n\t\tregistryUsage\n\t);\n\tconst partsLocals = hasMarkup\n\t\t? compileLocalVariables(\n\t\t\t\t[\n\t\t\t\t\t...conditionReads,\n\t\t\t\t\t...steps.flatMap((step) =>\n\t\t\t\t\t\tpatternVariableReferences(step.pattern, \"parts\")\n\t\t\t\t\t),\n\t\t\t\t],\n\t\t\t\tdeclarations,\n\t\t\t\tmessage,\n\t\t\t\tregistryUsage\n\t\t\t)\n\t\t: { code: [], readsInput: false };\n\n\tconst compiledVariants: string[] = [];\n\tconst compiledPartsVariants: string[] = [];\n\n\tfor (const step of steps) {\n\t\tconst compiledPattern = compilePattern({\n\t\t\tpattern: step.pattern,\n\t\t\tdeclarations,\n\t\t\tlocale: message.locale,\n\t\t\tregistryUsage,\n\t\t});\n\t\tcompiledVariants.push(\n\t\t\tstep.condition === undefined\n\t\t\t\t? `return /** @type {LocalizedString} */ (${compiledPattern.code})`\n\t\t\t\t: `if (${step.condition}) return /** @type {LocalizedString} */ (${compiledPattern.code});`\n\t\t);\n\t\tif (hasMarkup) {\n\t\t\tconst compiledPartsPattern = compilePattern({\n\t\t\t\tpattern: step.pattern,\n\t\t\t\tdeclarations,\n\t\t\t\tmode: \"parts\",\n\t\t\t\tlocale: message.locale,\n\t\t\t\tregistryUsage,\n\t\t\t});\n\t\t\tcompiledPartsVariants.push(\n\t\t\t\tstep.condition === undefined\n\t\t\t\t\t? `return /** @type {import('../runtime.js').MessagePart[]} */ (${compiledPartsPattern.code})`\n\t\t\t\t\t: `if (${step.condition}) return /** @type {import('../runtime.js').MessagePart[]} */ (${compiledPartsPattern.code});`\n\t\t\t);\n\t\t}\n\t}\n\n\tif (!hasMarkup) {\n\t\tconst code = `/** @type {(inputs: ${messageInputType}) => LocalizedString} */ (${stringLocals.readsInput ? \"i\" : \"\"}) => {${stringLocals.code.join(\"\\n\\t\")}\n\t${compiledVariants.join(\"\\n\\t\")}\n\t${hasCatchAll ? \"\" : `return /** @type {LocalizedString} */ (${JSON.stringify(messageBundleId(message))});`}\n};`;\n\n\t\treturn { code, node: message, registryFunctions: [...registryUsage] };\n\t}\n\n\tconst localVariablesCode = joinLocalVariables(stringLocals.code);\n\tconst partsLocalVariablesCode = joinLocalVariables(partsLocals.code);\n\tconst stringVariantsCode = compiledVariants.length\n\t\t? compiledVariants.join(\"\\n\\t\") + \"\\n\\t\"\n\t\t: \"\";\n\tconst partsVariantsCode = compiledPartsVariants.length\n\t\t? compiledPartsVariants.join(\"\\n\\t\") + \"\\n\\t\"\n\t\t: \"\";\n\tconst inputType = messageInputType;\n\tconst fallbackParts = `[{ type: \"text\", value: ${JSON.stringify(messageBundleId(message))} }]`;\n\t// only declare the input parameter where it is read (noUnusedParameters)\n\tconst messageInput = stringLocals.readsInput ? \"i\" : \"\";\n\tconst partsMessageInput = partsLocals.readsInput ? \"i\" : \"\";\n\n\tconst code = `/** @type {((inputs: ${inputType}) => LocalizedString) & { parts: (inputs: ${inputType}) => import('../runtime.js').MessagePart[] }} */ (\n\t/* @__PURE__ */ Object.assign(\n\t\t/** @type {(inputs: ${inputType}) => LocalizedString} */ ((${messageInput}) => {\n\t\t\t${localVariablesCode}${stringVariantsCode}${\n\t\t\t\thasCatchAll\n\t\t\t\t\t? \"\"\n\t\t\t\t\t: `return /** @type {LocalizedString} */ (${JSON.stringify(messageBundleId(message))});`\n\t\t\t}\n\t\t}),\n\t\t{\n\t\t\tparts: /** @type {(inputs: ${inputType}) => import('../runtime.js').MessagePart[]} */ ((${partsMessageInput}) => {\n\t\t\t\t${partsLocalVariablesCode}${partsVariantsCode}${\n\t\t\t\t\thasCatchAll\n\t\t\t\t\t\t? \"\"\n\t\t\t\t\t\t: `return /** @type {import('../runtime.js').MessagePart[]} */ (${fallbackParts});`\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\t)\n);`;\n\n\treturn { code, node: message, registryFunctions: [...registryUsage] };\n}\n\n/**\n * Compiles the local variables a message function reads, directly or through\n * other locals, in dependency order. Unread locals are left out. `readsInput`\n * tells whether the function reads its inputs parameter.\n */\nfunction compileLocalVariables(\n\treads: string[],\n\tdeclarations: Declaration[],\n\tmessage: CompilableMessage,\n\tregistryUsage: RegistryUsage\n): { code: string[]; readsInput: boolean } {\n\tconst { locals, readsInput } = resolveMessageLocals({\n\t\treads,\n\t\tdeclarations,\n\t\tbundleId: messageBundleId(message),\n\t\tlocale: message.locale,\n\t});\n\treturn {\n\t\tcode: locals.map((declaration: LocalVariable) =>\n\t\t\tcompileLocalVariable({\n\t\t\t\tdeclaration,\n\t\t\t\tdeclarations,\n\t\t\t\tlocale: message.locale,\n\t\t\t\tregistryUsage,\n\t\t\t})\n\t\t),\n\t\treadsInput,\n\t};\n}\n\nfunction joinLocalVariables(compiledLocalVariables: string[]): string {\n\treturn compiledLocalVariables.length\n\t\t? compiledLocalVariables.join(\"\\n\\t\") + \"\\n\\t\"\n\t\t: \"\";\n}\n\n/**\n * Orders variants by key preference in selector order, as in MessageFormat 2\n * variant selection: for the first selector, variants with a literal key come\n * before variants with a catchall key, then the next selector breaks ties, and\n * so on. Ties keep their original order.\n *\n * The compiled message returns the first variant whose conditions hold, so\n * this makes `countPluralExact=0 × countPlural=*` win over\n * `countPluralExact=* × countPlural=one` for French count 0 regardless of the\n * order the variants are stored in.\n */\nfunction sortVariantsBySelectorPreference<V extends CompilableVariant>(\n\tvariants: V[],\n\tselectors: Message[\"selectors\"]\n): V[] {\n\tif (selectors.length === 0) {\n\t\treturn variants;\n\t}\n\tconst rank = (variant: CompilableVariant) =>\n\t\tselectors.map((selector) =>\n\t\t\tvariant.matches.some(\n\t\t\t\t(match) => match.key === selector.name && match.type === \"literal-match\"\n\t\t\t)\n\t\t\t\t? 0\n\t\t\t\t: 1\n\t\t);\n\treturn variants\n\t\t.map((variant, index) => ({ variant, index, rank: rank(variant) }))\n\t\t.sort((left, right) => {\n\t\t\tfor (let i = 0; i < selectors.length; i++) {\n\t\t\t\tconst diff = left.rank[i]! - right.rank[i]!;\n\t\t\t\tif (diff !== 0) return diff;\n\t\t\t}\n\t\t\treturn left.index - right.index;\n\t\t})\n\t\t.map((entry) => entry.variant);\n}\n\nfunction patternHasMarkup(pattern: Pattern): boolean {\n\treturn pattern.some(\n\t\t(part) =>\n\t\t\tpart.type === \"markup-start\" ||\n\t\t\tpart.type === \"markup-end\" ||\n\t\t\tpart.type === \"markup-standalone\"\n\t);\n}\n"]}
1
+ {"version":3,"file":"compile-message.js","sourceRoot":"","sources":["../../src/compiler/compile-message.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAAE,UAAU,EAAwB,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAEnE,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EACN,yBAAyB,EACzB,oBAAoB,GACpB,MAAM,qBAAqB,CAAC;AAkB7B;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,OAA0B;IACzD,MAAM,GAAG,GAAG,OAAoD,CAAC;IACjE,MAAM,QAAQ,GAAG,GAAG,CAAC,SAAS,IAAI,GAAG,CAAC,QAAQ,CAAC;IAC/C,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAClC,MAAM,IAAI,KAAK,CACd,WAAW,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC,YAAY,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,oBAAoB,CACnG,CAAC;IACH,CAAC;IACD,OAAO,QAAQ,CAAC;AACjB,CAAC;AAgBD;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAC7B,YAA2B,EAC3B,OAA0B,EAC1B,QAA6B,EAC7B,UAA4B,EAC5B,kBAA2B,EACT,EAAE;IACpB,+BAA+B;IAC/B,IAAI,QAAQ,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;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,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;SAClE,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QACrB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAC3C,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAE,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAE,CAAC;YAC5C,IAAI,IAAI,KAAK,CAAC;gBAAE,OAAO,IAAI,CAAC;QAC7B,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;IACjC,CAAC,CAAC;SACD,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AACjC,CAAC;AAED,SAAS,gBAAgB,CAAC,OAAgB;IACzC,OAAO,OAAO,CAAC,IAAI,CAClB,CAAC,IAAI,EAAE,EAAE,CACR,IAAI,CAAC,IAAI,KAAK,cAAc;QAC5B,IAAI,CAAC,IAAI,KAAK,YAAY;QAC1B,IAAI,CAAC,IAAI,KAAK,mBAAmB,CAClC,CAAC;AACH,CAAC","sourcesContent":["import type {\n\tDeclaration,\n\tLocalVariable,\n\tMessage,\n\tPattern,\n\tVariant,\n} from \"@inlang/sdk\";\nimport { compilePattern } from \"./compile-pattern.js\";\nimport type { Compiled } from \"./types.js\";\nimport { inputsType, type InputMatchTypes } from \"./jsdoc-types.js\";\nimport { compileLocalVariable } from \"./compile-local-variable.js\";\nimport type { RegistryUsage } from \"./compile-annotation.js\";\nimport { renderInputMatchCondition } from \"./match-literals.js\";\nimport { compileInputAccess } from \"./variable-access.js\";\nimport { resolveInputAlias } from \"./input-alias.js\";\nimport {\n\tpatternVariableReferences,\n\tresolveMessageLocals,\n} from \"./message-locals.js\";\n\n/**\n * The message fields the compiler reads.\n *\n * `selectBundleNested()` of `@inlang/sdk` 4 returns the bundle id as\n * `bundle_id` (the database column). The camelCase `bundleId` of the SDK's\n * plugin `Message` shape is accepted too.\n */\nexport type CompilableMessage = Pick<Message, \"id\" | \"locale\" | \"selectors\"> &\n\t({ bundleId: string } | { bundle_id: string });\n\n/**\n * The variant fields the compiler reads. The message id (`message_id` in\n * `@inlang/sdk` 4 rows) is not needed.\n */\nexport type CompilableVariant = Pick<Variant, \"id\" | \"matches\" | \"pattern\">;\n\n/**\n * The bundle id of a message with either SDK version.\n */\nexport function messageBundleId(message: CompilableMessage): string {\n\tconst ids = message as { bundle_id?: string; bundleId?: string };\n\tconst bundleId = ids.bundle_id ?? ids.bundleId;\n\tif (typeof bundleId !== \"string\") {\n\t\tthrow new Error(\n\t\t\t`Message ${JSON.stringify(message.id)} (locale ${JSON.stringify(message.locale)}) has no bundle id`\n\t\t);\n\t}\n\treturn bundleId;\n}\n\nexport type CompiledMessage = Compiled<CompilableMessage> & {\n\t/**\n\t * The registry functions the compiled code calls, e.g. `[\"plural\"]`.\n\t * The output imports the registry only if a message calls it.\n\t */\n\tregistryFunctions: string[];\n\t/**\n\t * The statements of the message function body, for messages without markup.\n\t * The statements read the inputs as `i` and return on every path, so a\n\t * dispatcher can run them in place of calling the message function.\n\t */\n\tinline?: { statements: string[]; readsInput: boolean };\n};\n\n/**\n * Returns the compiled message as a string\n *\n */\nexport const compileMessage = (\n\tdeclarations: Declaration[],\n\tmessage: CompilableMessage,\n\tvariants: CompilableVariant[],\n\tmatchTypes?: InputMatchTypes,\n\tinputTypeAliasName?: string\n): CompiledMessage => {\n\t// return empty string instead?\n\tif (variants.length == 0) {\n\t\tthrow new Error(\"Message must have at least one variant\");\n\t}\n\n\tconst hasMultipleVariants = variants.length > 1;\n\treturn hasMultipleVariants\n\t\t? compileMessageWithMultipleVariants(\n\t\t\t\tdeclarations,\n\t\t\t\tmessage,\n\t\t\t\tvariants,\n\t\t\t\tmatchTypes,\n\t\t\t\tinputTypeAliasName\n\t\t\t)\n\t\t: compileMessageWithOneVariant(\n\t\t\t\tdeclarations,\n\t\t\t\tmessage,\n\t\t\t\tvariants,\n\t\t\t\tmatchTypes,\n\t\t\t\tinputTypeAliasName\n\t\t\t);\n};\n\nfunction compileMessageWithOneVariant(\n\tdeclarations: Declaration[],\n\tmessage: CompilableMessage,\n\tvariants: CompilableVariant[],\n\tmatchTypes?: InputMatchTypes,\n\tinputTypeAliasName?: string\n): CompiledMessage {\n\tconst variant = variants[0];\n\tif (!variant || variants.length !== 1) {\n\t\tthrow new Error(\"Message must have exactly one variant\");\n\t}\n\n\tconst hasMarkup = patternHasMarkup(variant.pattern);\n\tconst inputs = declarations.filter((decl) => decl.type === \"input-variable\");\n\tconst registryUsage: RegistryUsage = new Set();\n\tconst messageInputType = inputTypeAliasName ?? inputsType(inputs, matchTypes);\n\t// resolve before compiling the pattern to report undeclared variables\n\t// with the bundle id and locale\n\tconst stringLocals = compileLocalVariables(\n\t\tpatternVariableReferences(variant.pattern, \"string\"),\n\t\tdeclarations,\n\t\tmessage,\n\t\tregistryUsage\n\t);\n\tconst partsLocals = hasMarkup\n\t\t? compileLocalVariables(\n\t\t\t\tpatternVariableReferences(variant.pattern, \"parts\"),\n\t\t\t\tdeclarations,\n\t\t\t\tmessage,\n\t\t\t\tregistryUsage\n\t\t\t)\n\t\t: { code: [], readsInput: false };\n\tconst compiledPattern = compilePattern({\n\t\tpattern: variant.pattern,\n\t\tdeclarations,\n\t\tlocale: message.locale,\n\t\tregistryUsage,\n\t});\n\n\tif (!hasMarkup) {\n\t\treturn compiledStringMessage(message, messageInputType, registryUsage, {\n\t\t\tstatements: [\n\t\t\t\t...stringLocals.code,\n\t\t\t\t`return /** @type {LocalizedString} */ (${compiledPattern.code})`,\n\t\t\t],\n\t\t\treadsInput: stringLocals.readsInput,\n\t\t});\n\t}\n\n\tconst compiledPartsPattern = compilePattern({\n\t\tpattern: variant.pattern,\n\t\tdeclarations,\n\t\tmode: \"parts\",\n\t\tlocale: message.locale,\n\t\tregistryUsage,\n\t});\n\tconst localVariablesCode = joinLocalVariables(stringLocals.code);\n\tconst partsLocalVariablesCode = joinLocalVariables(partsLocals.code);\n\tconst inputType = messageInputType;\n\t// only declare the input parameter where it is read (noUnusedParameters)\n\tconst messageInput = stringLocals.readsInput ? \"i\" : \"\";\n\tconst partsMessageInput = partsLocals.readsInput ? \"i\" : \"\";\n\n\tconst partsCode = `/** @type {((inputs: ${inputType}) => LocalizedString) & { parts: (inputs: ${inputType}) => import('../runtime.js').MessagePart[] }} */ (\n\t/* @__PURE__ */ Object.assign(\n\t\t/** @type {(inputs: ${inputType}) => LocalizedString} */ ((${messageInput}) => {\n\t\t\t${localVariablesCode}return /** @type {LocalizedString} */ (${compiledPattern.code})\n\t\t}),\n\t\t{\n\t\t\tparts: /** @type {(inputs: ${inputType}) => import('../runtime.js').MessagePart[]} */ ((${partsMessageInput}) => {\n\t\t\t\t${partsLocalVariablesCode}return /** @type {import('../runtime.js').MessagePart[]} */ (${compiledPartsPattern.code})\n\t\t\t})\n\t\t}\n\t)\n);`;\n\n\treturn {\n\t\tcode: partsCode,\n\t\tnode: message,\n\t\tregistryFunctions: [...registryUsage],\n\t};\n}\n\nfunction compileMessageWithMultipleVariants(\n\tdeclarations: Declaration[],\n\tmessage: CompilableMessage,\n\tvariants: CompilableVariant[],\n\tmatchTypes?: InputMatchTypes,\n\tinputTypeAliasName?: string\n): CompiledMessage {\n\tif (variants.length <= 1) {\n\t\tthrow new Error(\"Message must have more than one variant\");\n\t}\n\n\tconst hasMarkup = variants.some((variant) =>\n\t\tpatternHasMarkup(variant.pattern)\n\t);\n\tconst inputs = declarations.filter((decl) => decl.type === \"input-variable\");\n\tconst registryUsage: RegistryUsage = new Set();\n\tconst messageInputType = inputTypeAliasName ?? inputsType(inputs, matchTypes);\n\n\t// The variants the function checks, in preference order. A variant without\n\t// a condition is a catchall and returns unconditionally.\n\tconst steps: Array<{ pattern: Pattern; condition?: string }> = [];\n\t// variables the match conditions read\n\tconst conditionReads: string[] = [];\n\n\tlet hasCatchAll = false;\n\n\tfor (const variant of sortVariantsBySelectorPreference(\n\t\tvariants,\n\t\tmessage.selectors\n\t)) {\n\t\tconst isCatchAll = variant.matches.every(\n\t\t\t(match) => match.type === \"catchall-match\"\n\t\t);\n\n\t\tif (isCatchAll) {\n\t\t\tsteps.push({ pattern: variant.pattern });\n\t\t\thasCatchAll = true;\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst conditions: string[] = [];\n\n\t\tfor (const match of variant.matches) {\n\t\t\t// catch all matches are not used in the conditions\n\t\t\tif (match.type !== \"literal-match\") {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst variableType = declarations.find(\n\t\t\t\t(decl) => decl.name === match.key\n\t\t\t)?.type;\n\t\t\tif (variableType === \"input-variable\") {\n\t\t\t\tconditionReads.push(match.key);\n\t\t\t\tconditions.push(\n\t\t\t\t\trenderInputMatchCondition(compileInputAccess(match.key), match.value)\n\t\t\t\t);\n\t\t\t} else if (variableType === \"local-variable\") {\n\t\t\t\tconditionReads.push(match.key);\n\t\t\t\t// An un-annotated local that aliases an input holds the raw input\n\t\t\t\t// value (e.g. ICU `=0` imports as `.local countPluralExact = {$count}`)\n\t\t\t\t// and must match like the input itself, numerically for numbers.\n\t\t\t\t// Annotated locals hold the function's result and match as strings.\n\t\t\t\tconditions.push(\n\t\t\t\t\tresolveInputAlias(match.key, declarations) !== undefined\n\t\t\t\t\t\t? renderInputMatchCondition(match.key, match.value)\n\t\t\t\t\t\t: `${match.key} === ${JSON.stringify(match.value)}`\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tif (conditions.length === 0) continue;\n\t\tsteps.push({\n\t\t\tpattern: variant.pattern,\n\t\t\tcondition: conditions.join(\" && \"),\n\t\t});\n\t}\n\n\t// resolve before compiling the patterns to report undeclared variables\n\t// with the bundle id and locale\n\tconst stringLocals = compileLocalVariables(\n\t\t[\n\t\t\t...conditionReads,\n\t\t\t...steps.flatMap((step) =>\n\t\t\t\tpatternVariableReferences(step.pattern, \"string\")\n\t\t\t),\n\t\t],\n\t\tdeclarations,\n\t\tmessage,\n\t\tregistryUsage\n\t);\n\tconst partsLocals = hasMarkup\n\t\t? compileLocalVariables(\n\t\t\t\t[\n\t\t\t\t\t...conditionReads,\n\t\t\t\t\t...steps.flatMap((step) =>\n\t\t\t\t\t\tpatternVariableReferences(step.pattern, \"parts\")\n\t\t\t\t\t),\n\t\t\t\t],\n\t\t\t\tdeclarations,\n\t\t\t\tmessage,\n\t\t\t\tregistryUsage\n\t\t\t)\n\t\t: { code: [], readsInput: false };\n\n\tconst compiledVariants: string[] = [];\n\tconst compiledPartsVariants: string[] = [];\n\n\tfor (const step of steps) {\n\t\tconst compiledPattern = compilePattern({\n\t\t\tpattern: step.pattern,\n\t\t\tdeclarations,\n\t\t\tlocale: message.locale,\n\t\t\tregistryUsage,\n\t\t});\n\t\tcompiledVariants.push(\n\t\t\tstep.condition === undefined\n\t\t\t\t? `return /** @type {LocalizedString} */ (${compiledPattern.code})`\n\t\t\t\t: `if (${step.condition}) return /** @type {LocalizedString} */ (${compiledPattern.code});`\n\t\t);\n\t\tif (hasMarkup) {\n\t\t\tconst compiledPartsPattern = compilePattern({\n\t\t\t\tpattern: step.pattern,\n\t\t\t\tdeclarations,\n\t\t\t\tmode: \"parts\",\n\t\t\t\tlocale: message.locale,\n\t\t\t\tregistryUsage,\n\t\t\t});\n\t\t\tcompiledPartsVariants.push(\n\t\t\t\tstep.condition === undefined\n\t\t\t\t\t? `return /** @type {import('../runtime.js').MessagePart[]} */ (${compiledPartsPattern.code})`\n\t\t\t\t\t: `if (${step.condition}) return /** @type {import('../runtime.js').MessagePart[]} */ (${compiledPartsPattern.code});`\n\t\t\t);\n\t\t}\n\t}\n\n\tconst fallbackString = `return /** @type {LocalizedString} */ (${JSON.stringify(messageBundleId(message))});`;\n\n\tif (!hasMarkup) {\n\t\treturn compiledStringMessage(message, messageInputType, registryUsage, {\n\t\t\tstatements: [\n\t\t\t\t...stringLocals.code,\n\t\t\t\t...compiledVariants,\n\t\t\t\t...(hasCatchAll ? [] : [fallbackString]),\n\t\t\t],\n\t\t\treadsInput: stringLocals.readsInput,\n\t\t});\n\t}\n\n\tconst localVariablesCode = joinLocalVariables(stringLocals.code);\n\tconst partsLocalVariablesCode = joinLocalVariables(partsLocals.code);\n\tconst stringVariantsCode = compiledVariants.length\n\t\t? compiledVariants.join(\"\\n\\t\") + \"\\n\\t\"\n\t\t: \"\";\n\tconst partsVariantsCode = compiledPartsVariants.length\n\t\t? compiledPartsVariants.join(\"\\n\\t\") + \"\\n\\t\"\n\t\t: \"\";\n\tconst inputType = messageInputType;\n\tconst fallbackParts = `[{ type: \"text\", value: ${JSON.stringify(messageBundleId(message))} }]`;\n\t// only declare the input parameter where it is read (noUnusedParameters)\n\tconst messageInput = stringLocals.readsInput ? \"i\" : \"\";\n\tconst partsMessageInput = partsLocals.readsInput ? \"i\" : \"\";\n\n\tconst code = `/** @type {((inputs: ${inputType}) => LocalizedString) & { parts: (inputs: ${inputType}) => import('../runtime.js').MessagePart[] }} */ (\n\t/* @__PURE__ */ Object.assign(\n\t\t/** @type {(inputs: ${inputType}) => LocalizedString} */ ((${messageInput}) => {\n\t\t\t${localVariablesCode}${stringVariantsCode}${hasCatchAll ? \"\" : fallbackString}\n\t\t}),\n\t\t{\n\t\t\tparts: /** @type {(inputs: ${inputType}) => import('../runtime.js').MessagePart[]} */ ((${partsMessageInput}) => {\n\t\t\t\t${partsLocalVariablesCode}${partsVariantsCode}${\n\t\t\t\t\thasCatchAll\n\t\t\t\t\t\t? \"\"\n\t\t\t\t\t\t: `return /** @type {import('../runtime.js').MessagePart[]} */ (${fallbackParts});`\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\t)\n);`;\n\n\treturn { code, node: message, registryFunctions: [...registryUsage] };\n}\n\n/**\n * A message without markup: the function and its body statements, which a\n * dispatcher can run in place of calling the function.\n */\nfunction compiledStringMessage(\n\tmessage: CompilableMessage,\n\tinputType: string,\n\tregistryUsage: RegistryUsage,\n\tinline: NonNullable<CompiledMessage[\"inline\"]>\n): CompiledMessage {\n\treturn {\n\t\tcode: `/** @type {(inputs: ${inputType}) => LocalizedString} */ (${inline.readsInput ? \"i\" : \"\"}) => {\\n\\t${inline.statements.join(\"\\n\\t\")}\\n};`,\n\t\tnode: message,\n\t\tregistryFunctions: [...registryUsage],\n\t\tinline,\n\t};\n}\n\n/**\n * Compiles the local variables a message function reads, directly or through\n * other locals, in dependency order. Unread locals are left out. `readsInput`\n * tells whether the function reads its inputs parameter.\n */\nfunction compileLocalVariables(\n\treads: string[],\n\tdeclarations: Declaration[],\n\tmessage: CompilableMessage,\n\tregistryUsage: RegistryUsage\n): { code: string[]; readsInput: boolean } {\n\tconst { locals, readsInput } = resolveMessageLocals({\n\t\treads,\n\t\tdeclarations,\n\t\tbundleId: messageBundleId(message),\n\t\tlocale: message.locale,\n\t});\n\treturn {\n\t\tcode: locals.map((declaration: LocalVariable) =>\n\t\t\tcompileLocalVariable({\n\t\t\t\tdeclaration,\n\t\t\t\tdeclarations,\n\t\t\t\tlocale: message.locale,\n\t\t\t\tregistryUsage,\n\t\t\t})\n\t\t),\n\t\treadsInput,\n\t};\n}\n\nfunction joinLocalVariables(compiledLocalVariables: string[]): string {\n\treturn compiledLocalVariables.length\n\t\t? compiledLocalVariables.join(\"\\n\\t\") + \"\\n\\t\"\n\t\t: \"\";\n}\n\n/**\n * Orders variants by key preference in selector order, as in MessageFormat 2\n * variant selection: for the first selector, variants with a literal key come\n * before variants with a catchall key, then the next selector breaks ties, and\n * so on. Ties keep their original order.\n *\n * The compiled message returns the first variant whose conditions hold, so\n * this makes `countPluralExact=0 × countPlural=*` win over\n * `countPluralExact=* × countPlural=one` for French count 0 regardless of the\n * order the variants are stored in.\n */\nfunction sortVariantsBySelectorPreference<V extends CompilableVariant>(\n\tvariants: V[],\n\tselectors: Message[\"selectors\"]\n): V[] {\n\tif (selectors.length === 0) {\n\t\treturn variants;\n\t}\n\tconst rank = (variant: CompilableVariant) =>\n\t\tselectors.map((selector) =>\n\t\t\tvariant.matches.some(\n\t\t\t\t(match) => match.key === selector.name && match.type === \"literal-match\"\n\t\t\t)\n\t\t\t\t? 0\n\t\t\t\t: 1\n\t\t);\n\treturn variants\n\t\t.map((variant, index) => ({ variant, index, rank: rank(variant) }))\n\t\t.sort((left, right) => {\n\t\t\tfor (let i = 0; i < selectors.length; i++) {\n\t\t\t\tconst diff = left.rank[i]! - right.rank[i]!;\n\t\t\t\tif (diff !== 0) return diff;\n\t\t\t}\n\t\t\treturn left.index - right.index;\n\t\t})\n\t\t.map((entry) => entry.variant);\n}\n\nfunction patternHasMarkup(pattern: Pattern): boolean {\n\treturn pattern.some(\n\t\t(part) =>\n\t\t\tpart.type === \"markup-start\" ||\n\t\t\tpart.type === \"markup-end\" ||\n\t\t\tpart.type === \"markup-standalone\"\n\t);\n}\n"]}