@inlang/paraglide-js 2.28.0 → 2.29.1

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/bundler-plugins/unplugin.d.ts +4 -1
  2. package/dist/bundler-plugins/unplugin.js +55 -12
  3. package/dist/bundler-plugins/unplugin.js.map +1 -1
  4. package/dist/bundler-plugins/unplugin.test.js +156 -0
  5. package/dist/bundler-plugins/unplugin.test.js.map +1 -1
  6. package/dist/bundler-plugins/vite-error-response.test.d.ts +1 -0
  7. package/dist/bundler-plugins/vite-error-response.test.js +171 -0
  8. package/dist/bundler-plugins/vite-error-response.test.js.map +1 -0
  9. package/dist/bundler-plugins/vite.d.ts +8 -0
  10. package/dist/bundler-plugins/vite.js +14 -5
  11. package/dist/bundler-plugins/vite.js.map +1 -1
  12. package/dist/compiler/compile-bundle.js +58 -12
  13. package/dist/compiler/compile-bundle.js.map +1 -1
  14. package/dist/compiler/compile-bundle.test.js +208 -26
  15. package/dist/compiler/compile-bundle.test.js.map +1 -1
  16. package/dist/compiler/compile-lifecycle.test.js +83 -0
  17. package/dist/compiler/compile-lifecycle.test.js.map +1 -1
  18. package/dist/compiler/compile-message.d.ts +9 -0
  19. package/dist/compiler/compile-message.js +29 -12
  20. package/dist/compiler/compile-message.js.map +1 -1
  21. package/dist/compiler/compile-project.test.js +157 -0
  22. package/dist/compiler/compile-project.test.js.map +1 -1
  23. package/dist/compiler/compile.js +12 -0
  24. package/dist/compiler/compile.js.map +1 -1
  25. package/dist/compiler/runtime/localize-url.d.ts +8 -4
  26. package/dist/compiler/runtime/localize-url.js +12 -8
  27. package/dist/compiler/runtime/localize-url.js.map +1 -1
  28. package/dist/compiler/runtime/localize-url.test.js +45 -0
  29. package/dist/compiler/runtime/localize-url.test.js.map +1 -1
  30. package/dist/compiler/runtime/type.test.js +41 -0
  31. package/dist/compiler/runtime/type.test.js.map +1 -1
  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.js","sourceRoot":"","sources":["../../src/compiler/compile-bundle.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,cAAc,EAAwB,MAAM,sBAAsB,CAAC;AAE5E,OAAO,EACN,gBAAgB,EAChB,wBAAwB,GAExB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAE3E,OAAO,EAAE,oCAAoC,EAAE,MAAM,uBAAuB,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAiBrD;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,IAS7B,EAA8B,EAAE;IAChC,MAAM,gBAAgB,GAAoC,EAAE,CAAC;IAC7D,MAAM,YAAY,GAAG,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACpD,MAAM,kBAAkB,GAAG,0BAA0B,CAAC,YAAY,CAAC,CAAC;IACpE,MAAM,UAAU,GAAG,sBAAsB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACvD,MAAM,SAAS,GAAG,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAE/C,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;QAC5C,IAAI,gBAAgB,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YACtC,MAAM,IAAI,KAAK,CAAC,qBAAqB,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;QACxD,CAAC;QAED,MAAM,eAAe,GAAG,cAAc,CACrC,IAAI,CAAC,MAAM,CAAC,YAAY,EACxB,OAAO,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,EAAE,CACR,IAAI,CAAC,IAAI,KAAK,cAAc;QAC5B,IAAI,CAAC,IAAI,KAAK,YAAY;QAC1B,IAAI,CAAC,IAAI,KAAK,mBAAmB,CAClC,CACD,CACD,CAAC;AACH,CAAC","sourcesContent":["import type {\n\tBundle,\n\tBundleNested,\n\tMarkupStandalone,\n\tMarkupStart,\n\tProjectSettings,\n} from \"@inlang/sdk\";\nimport { compileMessage, type CompiledMessage } from \"./compile-message.js\";\nimport type { Compiled } from \"./types.js\";\nimport {\n\tinputTypeForName,\n\tjsDocBundleFunctionTypes,\n\ttype InputMatchTypes,\n} from \"./jsdoc-types.js\";\nimport { isValidIdentifier, quotePropertyKey } from \"./variable-access.js\";\nimport { toSafeModuleId } from \"./safe-module-id.js\";\nimport { escapeForDoubleQuoteString } from \"../services/codegen/escape.js\";\nimport type { CompilerOptions } from \"./compiler-options.js\";\nimport { perLocaleBuildStaticLocaleExpression } from \"./per-locale-build.js\";\nimport { resolveInputAlias } from \"./input-alias.js\";\n\nexport type CompiledBundleWithMessages = {\n\t/** The compilation result for the bundle index */\n\tbundle: Compiled<Bundle>;\n\t/** The compilation results for the languages */\n\tmessages: {\n\t\t[locale: string]: CompiledMessage;\n\t};\n\t/** Match literal types inferred from bundle variants */\n\tmatchTypes: InputMatchTypes;\n\t/** Shared typedef name for bundle input types used across emitted JSDoc */\n\tinputTypeAliasName?: string;\n\t/** Compiled message helpers with no emitted reference in message-modules. */\n\tunreferencedMessageLocales?: string[];\n};\n\n/**\n * Compiles all the messages in the bundle and returns an index-function + each compiled message\n */\nexport const compileBundle = (args: {\n\tbundle: BundleNested;\n\tfallbackMap: Record<string, string | undefined>;\n\tmessageReferenceExpression: (locale: string, bundleId: string) => string;\n\tsettings?: ProjectSettings;\n\t/** Internal layout control; locale modules keep text grouped by language. */\n\tinlineMessages?: boolean;\n\texperimentalMiddlewareLocaleSplitting?: boolean;\n\texperimentalStaticLocale?: CompilerOptions[\"experimentalStaticLocale\"];\n}): CompiledBundleWithMessages => {\n\tconst compiledMessages: Record<string, CompiledMessage> = {};\n\tconst safeBundleId = toSafeModuleId(args.bundle.id);\n\tconst inputTypeAliasName = toBundleInputTypeAliasName(safeBundleId);\n\tconst matchTypes = collectInputMatchTypes(args.bundle);\n\tconst hasMarkup = bundleHasMarkup(args.bundle);\n\n\tfor (const message of args.bundle.messages) {\n\t\tif (compiledMessages[message.locale]) {\n\t\t\tthrow new Error(`Duplicate locale: ${message.locale}`);\n\t\t}\n\n\t\tconst compiledMessage = compileMessage(\n\t\t\targs.bundle.declarations,\n\t\t\tmessage,\n\t\t\tmessage.variants,\n\t\t\tmatchTypes,\n\t\t\tinputTypeAliasName\n\t\t);\n\n\t\t// set the pattern for the language tag\n\t\tcompiledMessages[message.locale] = compiledMessage;\n\t}\n\tconst inlinePlainTextByLocale =\n\t\targs.inlineMessages !== true ||\n\t\targs.experimentalStaticLocale === perLocaleBuildStaticLocaleExpression\n\t\t\t? undefined\n\t\t\t: findPlainTextMessages(args.bundle);\n\tconst unreferencedMessageLocales = findUnreferencedMessageLocales({\n\t\tinlinePlainTextByLocale: inlinePlainTextByLocale ?? Object.create(null),\n\t\tcompiledMessages,\n\t\tfallbackMap: args.fallbackMap,\n\t\thasMarkup,\n\t});\n\n\treturn {\n\t\tbundle: compileBundleFunction({\n\t\t\tbundle: args.bundle,\n\t\t\tavailableLocales: Object.keys(args.fallbackMap),\n\t\t\tmessageReferenceExpression: args.messageReferenceExpression,\n\t\t\tinlinePlainTextByLocale,\n\t\t\tsettings: args.settings,\n\t\t\tmatchTypes,\n\t\t\thasMarkup,\n\t\t\texperimentalMiddlewareLocaleSplitting:\n\t\t\t\targs.experimentalMiddlewareLocaleSplitting ?? false,\n\t\t\texperimentalStaticLocale: args.experimentalStaticLocale,\n\t\t\tinputTypeAliasName,\n\t\t}),\n\t\tmessages: compiledMessages,\n\t\tmatchTypes,\n\t\tinputTypeAliasName,\n\t\tunreferencedMessageLocales,\n\t};\n};\n\n/**\n * Finds one-variant messages whose pattern is entirely static text. Their\n * dispatcher branch can return the string directly without retaining a\n * locale message function in the client bundle.\n */\nfunction findPlainTextMessages(bundle: BundleNested): Record<string, string> {\n\tconst result = Object.create(null) as Record<string, string>;\n\n\tfor (const message of bundle.messages) {\n\t\tif (message.variants.length !== 1) continue;\n\t\tconst variant = message.variants[0];\n\t\tif (!variant || !variant.pattern.every((part) => part.type === \"text\")) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// compilePattern emits static text inside a template literal, whose\n\t\t// cooked value normalizes CR and CRLF line endings to LF.\n\t\tresult[message.locale] = variant.pattern\n\t\t\t.map((part) => (part.type === \"text\" ? part.value : \"\"))\n\t\t\t.join(\"\")\n\t\t\t.replace(/\\r\\n?/g, \"\\n\");\n\t}\n\n\treturn result;\n}\n\nfunction findUnreferencedMessageLocales(args: {\n\tinlinePlainTextByLocale: Record<string, string>;\n\tcompiledMessages: Record<string, CompiledMessage>;\n\tfallbackMap: Record<string, string | undefined>;\n\thasMarkup: boolean;\n}): string[] {\n\tif (args.hasMarkup) return [];\n\n\t// Missing-locale aliases still call the first available compiled fallback\n\t// function, even when the dispatcher's own branch uses an inline string.\n\tconst fallbackTargets = new Set<string>();\n\tfor (const locale of Object.keys(args.fallbackMap)) {\n\t\tif (Object.hasOwn(args.compiledMessages, locale)) continue;\n\n\t\tlet fallbackLocale = args.fallbackMap[locale];\n\t\tconst visited = new Set([locale]);\n\t\twhile (fallbackLocale && !visited.has(fallbackLocale)) {\n\t\t\tvisited.add(fallbackLocale);\n\t\t\tif (Object.hasOwn(args.compiledMessages, fallbackLocale)) {\n\t\t\t\tfallbackTargets.add(fallbackLocale);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tfallbackLocale = args.fallbackMap[fallbackLocale];\n\t\t}\n\t}\n\n\treturn Object.keys(args.inlinePlainTextByLocale).filter(\n\t\t(locale) => !fallbackTargets.has(locale)\n\t);\n}\n\nconst compileBundleFunction = (args: {\n\t/**\n\t * The bundle to compile\n\t */\n\tbundle: BundleNested;\n\t/**\n\t * The language tags which are available\n\t */\n\tavailableLocales: string[];\n\t/**\n\t * The message reference expression\n\t */\n\tmessageReferenceExpression: (locale: string, bundleId: string) => string;\n\t/** Static text messages that can be returned directly from the dispatcher. */\n\tinlinePlainTextByLocale?: Record<string, string>;\n\t/**\n\t * The project settings\n\t */\n\tsettings?: ProjectSettings;\n\t/**\n\t * Match literal types inferred from bundle variants\n\t */\n\tmatchTypes: InputMatchTypes;\n\t/**\n\t * Whether at least one variant in this bundle contains markup.\n\t */\n\thasMarkup: boolean;\n\t/**\n\t * Whether middleware locale splitting runtime hooks should be emitted.\n\t */\n\texperimentalMiddlewareLocaleSplitting: boolean;\n\t/**\n\t * Static locale expression emitted inside the message function so a\n\t * bundler can tree-shake unselected locale modules.\n\t */\n\texperimentalStaticLocale?: CompilerOptions[\"experimentalStaticLocale\"];\n\t/**\n\t * Shared typedef name for bundle input types used across emitted JSDoc.\n\t */\n\tinputTypeAliasName: string;\n}): Compiled<Bundle> => {\n\tconst inputs = args.bundle.declarations.filter(\n\t\t(decl) => decl.type === \"input-variable\"\n\t);\n\tconst hasInputs = inputs.length > 0;\n\tconst safeBundleId = toSafeModuleId(args.bundle.id);\n\n\tconst isSafeBundleId = safeBundleId === args.bundle.id;\n\n\tconst isFullyTranslated =\n\t\targs.availableLocales.length === args.settings?.locales.length;\n\tconst baseLocale = args.settings?.baseLocale;\n\tconst dispatchLocales =\n\t\tbaseLocale && args.availableLocales.includes(baseLocale)\n\t\t\t? [\n\t\t\t\t\t...args.availableLocales.filter((locale) => locale !== baseLocale),\n\t\t\t\t\tbaseLocale,\n\t\t\t\t]\n\t\t\t: args.availableLocales;\n\tconst allStringBranchesInline = dispatchLocales.every(\n\t\t(locale) => args.inlinePlainTextByLocale?.[locale] !== undefined\n\t);\n\n\tconst inputType = args.inputTypeAliasName;\n\tconst localesUnion =\n\t\targs.availableLocales.length === 0\n\t\t\t? \"never\"\n\t\t\t: args.availableLocales.map((locale) => `\"${locale}\"`).join(\" | \");\n\tconst optionsType = `{ locale?: ${localesUnion} }`;\n\tconst inputsParameterType = `${hasInputs ? \"inputs\" : \"inputs?\"}: ${inputType}`;\n\tconst bundleFunctionType = `(${inputsParameterType}, options?: ${optionsType}) => LocalizedString`;\n\tconst partsFunctionType = `(${inputsParameterType}, options?: ${optionsType}) => import('../runtime.js').MessagePart[]`;\n\tconst markupSchemaType = buildMarkupSchemaType(args.bundle, args.matchTypes);\n\tconst messageMetadataType = `import('../runtime.js').MessageMetadata<${inputType}, ${optionsType}, ${markupSchemaType}>`;\n\n\tconst compileLocaleReturnStatements = (\n\t\tmode: \"string\" | \"parts\",\n\t\tcontinuationIndent: string\n\t): string =>\n\t\tdispatchLocales\n\t\t\t.map((locale, index) => {\n\t\t\t\tconst condition =\n\t\t\t\t\t!isFullyTranslated || index < dispatchLocales.length - 1\n\t\t\t\t\t\t? `if (locale === \"${locale}\") `\n\t\t\t\t\t\t: \"\";\n\t\t\t\tconst prefix = index > 0 ? continuationIndent : \"\";\n\t\t\t\tconst messageRef = args.messageReferenceExpression(\n\t\t\t\t\tlocale,\n\t\t\t\t\targs.bundle.id\n\t\t\t\t);\n\n\t\t\t\tif (mode === \"string\") {\n\t\t\t\t\tconst inlineText = args.inlinePlainTextByLocale?.[locale];\n\t\t\t\t\tif (inlineText !== undefined) {\n\t\t\t\t\t\treturn `${prefix}${condition}return /** @type {LocalizedString} */ (${JSON.stringify(inlineText)})`;\n\t\t\t\t\t}\n\t\t\t\t\treturn `${prefix}${condition}return ${messageRef}(inputs)`;\n\t\t\t\t}\n\n\t\t\t\t// A locale's message has .parts() only if its own variants have\n\t\t\t\t// markup. Fallbacks and messages without markup are typed without\n\t\t\t\t// it, so read it through a type that declares it optional.\n\t\t\t\treturn `${prefix}${condition}return /** @type {{ parts?: (inputs: ${inputType}) => import('../runtime.js').MessagePart[] }} */ (${messageRef}).parts?.(inputs) ?? [{ type: \"text\", value: ${messageRef}(inputs) }]`;\n\t\t\t})\n\t\t\t.join(\"\\n\");\n\n\tconst perLocaleBuild =\n\t\targs.experimentalStaticLocale === perLocaleBuildStaticLocaleExpression;\n\t// A locale-specialized graph may ship source maps. Keeping the English\n\t// pattern preview in the shared dispatcher would leak base-locale message\n\t// text into every locale's map even after the English module is tree-shaken.\n\tconst englishMatchTableDoc = perLocaleBuild\n\t\t? \"\"\n\t\t: buildEnglishMatchTableDoc(args.bundle);\n\n\tconst commonJsDoc = `/**\n${englishMatchTableDoc}${jsDocBundleFunctionTypes({\n\t\tinputs,\n\t\tlocales: args.availableLocales,\n\t\tmatchTypes: args.matchTypes,\n\t\tinputTypeOverride: args.inputTypeAliasName,\n\t})}\n*/`;\n\n\tconst clientMiddlewareGuard = (indent: string): string => {\n\t\tif (!args.experimentalMiddlewareLocaleSplitting) {\n\t\t\treturn \"\";\n\t\t}\n\n\t\treturn `\\n${indent}if (experimentalMiddlewareLocaleSplitting && isServer === false) {\\n${indent}\\treturn /** @type {any} */ (globalThis).__paraglide.ssr.${safeBundleId}(inputs)\\n${indent}}`;\n\t};\n\n\tconst clientPartsMiddlewareGuard = (indent: string): string => {\n\t\tif (!args.experimentalMiddlewareLocaleSplitting) {\n\t\t\treturn \"\";\n\t\t}\n\n\t\treturn `\\n${indent}if (experimentalMiddlewareLocaleSplitting && isServer === false) {\\n${indent}\\tconst serverMessage = /** @type {any} */ (globalThis).__paraglide.ssr.${safeBundleId}\\n${indent}\\tif (typeof serverMessage.parts === \"function\") {\\n${indent}\\t\\treturn /** @type {import('../runtime.js').MessagePart[]} */ (serverMessage.parts(inputs))\\n${indent}\\t}\\n${indent}\\treturn /** @type {import('../runtime.js').MessagePart[]} */ ([{ type: \"text\", value: serverMessage(inputs) }])\\n${indent}}`;\n\t};\n\n\tconst maybeTrackMessageCall = (indent: string): string => {\n\t\tif (!args.experimentalMiddlewareLocaleSplitting) {\n\t\t\treturn \"\";\n\t\t}\n\n\t\treturn `\\n${indent}trackMessageCall(\"${safeBundleId}\", locale)`;\n\t};\n\n\tconst localeResolutionStatement = (indent: string): string => {\n\t\tconst localeExpression = perLocaleBuild\n\t\t\t? `${perLocaleBuildStaticLocaleExpression} ?? options.locale ?? getLocale()`\n\t\t\t: \"experimentalStaticLocale ?? options.locale ?? getLocale()\";\n\t\tconst overrideWarning = perLocaleBuild\n\t\t\t? `\\n${indent}if (${perLocaleBuildStaticLocaleExpression} !== undefined && options.locale !== undefined && options.locale !== ${perLocaleBuildStaticLocaleExpression}) console.warn(\"Paraglide: options.locale cannot override a locale-specialized client bundle; use a full document navigation to switch locales.\")`\n\t\t\t: \"\";\n\n\t\tif (\n\t\t\tisFullyTranslated &&\n\t\t\targs.availableLocales.length === 1 &&\n\t\t\t!args.experimentalMiddlewareLocaleSplitting\n\t\t) {\n\t\t\treturn `${indent}${localeExpression}${overrideWarning}`;\n\t\t}\n\n\t\treturn `${indent}const locale = ${localeExpression}${overrideWarning}${maybeTrackMessageCall(\n\t\t\tindent\n\t\t)}`;\n\t};\n\tconst keepUnusedInputsParameter = (indent: string): string =>\n\t\tallStringBranchesInline && !args.experimentalMiddlewareLocaleSplitting\n\t\t\t? `\\n${indent}void inputs;`\n\t\t\t: \"\";\n\n\tlet code = \"\";\n\n\tif (!args.hasMarkup) {\n\t\tcode = `${commonJsDoc}\n${isSafeBundleId ? \"export \" : \"\"}const ${safeBundleId} = /** @type {(${bundleFunctionType}) & ${messageMetadataType}} */ ((inputs${hasInputs ? \"\" : \" = {}\"}, options = {}) => {${clientMiddlewareGuard(\n\t\t\t\"\\t\"\n\t\t)}${keepUnusedInputsParameter(\"\\t\")}\n${localeResolutionStatement(\"\\t\")}\n\t${compileLocaleReturnStatements(\"string\", \"\\t\")}${\n\t\t!isFullyTranslated\n\t\t\t? `\\n\treturn /** @type {LocalizedString} */ (\"${args.bundle.id}\")`\n\t\t\t: \"\"\n\t}\n});`;\n\t} else {\n\t\tcode = `${commonJsDoc}\n${isSafeBundleId ? \"export \" : \"\"}const ${safeBundleId} = /** @type {(${bundleFunctionType}) & { parts: ${partsFunctionType} } & ${messageMetadataType}} */ (\n\t/* @__PURE__ */ Object.assign(\n\t\t/** @type {${bundleFunctionType}} */ ((inputs${hasInputs ? \"\" : \" = {}\"}, options = {}) => {${clientMiddlewareGuard(\n\t\t\t\"\\t\\t\\t\"\n\t\t)}${keepUnusedInputsParameter(\"\\t\\t\\t\")}\n${localeResolutionStatement(\"\\t\\t\\t\")}\n\t\t\t${compileLocaleReturnStatements(\"string\", \"\\t\\t\\t\")}${\n\t\t\t\t!isFullyTranslated\n\t\t\t\t\t? `\\n\t\t\treturn /** @type {LocalizedString} */ (${JSON.stringify(args.bundle.id)})`\n\t\t\t\t\t: \"\"\n\t\t\t}\n\t\t}),\n\t\t{\n\t\t\tparts: /** @type {${partsFunctionType}} */ ((inputs${\n\t\t\t\thasInputs ? \"\" : \" = {}\"\n\t\t\t}, options = {}) => {${clientPartsMiddlewareGuard(\"\\t\\t\\t\\t\")}\n${localeResolutionStatement(\"\\t\\t\\t\\t\")}\n\t\t\t\t${compileLocaleReturnStatements(\"parts\", \"\\t\\t\\t\\t\")}${\n\t\t\t\t\t!isFullyTranslated\n\t\t\t\t\t\t? `\\n\t\t\t\treturn /** @type {import('../runtime.js').MessagePart[]} */ ([{ type: \"text\", value: ${JSON.stringify(args.bundle.id)} }])`\n\t\t\t\t\t\t: \"\"\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\t)\n);`;\n\t}\n\n\tif (isSafeBundleId === false) {\n\t\tcode += `\\nexport { ${safeBundleId} as \"${escapeForDoubleQuoteString(args.bundle.id)}\" }`;\n\t}\n\n\treturn {\n\t\tcode,\n\t\tnode: args.bundle,\n\t};\n};\n\nfunction buildEnglishMatchTableDoc(bundle: BundleNested): string {\n\tconst message = selectEnglishMessage(bundle);\n\tif (!message) {\n\t\treturn \"\";\n\t}\n\n\tconst selectorKeys = collectSelectorKeys(message);\n\tconst headerCells = [...selectorKeys, \"output\"];\n\tconst lines = [\n\t\t`* | ${headerCells.map(escapeTableCell).join(\" | \")} |`,\n\t\t`* | ${headerCells.map(() => \"---\").join(\" | \")} |`,\n\t];\n\n\tfor (const variant of message.variants) {\n\t\tconst rowValues = selectorKeys.map((key) =>\n\t\t\tgetMatchCellValue(variant, key)\n\t\t);\n\t\tconst serializedOutput = serializePatternPreview(variant.pattern);\n\t\tconst outputValue = JSON.stringify(\n\t\t\tserializedOutput.length > 160\n\t\t\t\t? `${serializedOutput.slice(0, 157)}...`\n\t\t\t\t: serializedOutput\n\t\t);\n\t\tlines.push(\n\t\t\t`* | ${[...rowValues, outputValue].map(escapeTableCell).join(\" | \")} |`\n\t\t);\n\t}\n\n\tlines.push(\"*\");\n\n\treturn lines.join(\"\\n\");\n}\n\nfunction selectEnglishMessage(\n\tbundle: BundleNested\n): BundleNested[\"messages\"][number] | undefined {\n\treturn (\n\t\tbundle.messages.find((message) => message.locale === \"en\") ??\n\t\tbundle.messages.find((message) => message.locale.startsWith(\"en-\"))\n\t);\n}\n\nfunction collectSelectorKeys(\n\tmessage: BundleNested[\"messages\"][number]\n): string[] {\n\tconst keys: string[] = [];\n\tconst seen = new Set<string>();\n\n\tfor (const variant of message.variants) {\n\t\tfor (const match of variant.matches ?? []) {\n\t\t\tif (seen.has(match.key)) continue;\n\t\t\tseen.add(match.key);\n\t\t\tkeys.push(match.key);\n\t\t}\n\t}\n\n\treturn keys;\n}\n\nfunction getMatchCellValue(\n\tvariant: BundleNested[\"messages\"][number][\"variants\"][number],\n\tkey: string\n): string {\n\tconst match = (variant.matches ?? []).find((entry) => entry.key === key);\n\tif (!match || match.type === \"catchall-match\") {\n\t\treturn \"*\";\n\t}\n\n\treturn JSON.stringify(match.value);\n}\n\nfunction escapeTableCell(value: string): string {\n\treturn value\n\t\t.replace(/\\|/g, \"\\\\|\")\n\t\t.replace(/\\r?\\n/g, \" \")\n\t\t.replaceAll(\"*/\", \"*\\\\/\");\n}\n\nexport function toBundleInputTypeAliasName(safeBundleId: string): string {\n\treturn `${toBundleTypeBaseName(safeBundleId)}Inputs`;\n}\n\nfunction toBundleTypeBaseName(safeBundleId: string): string {\n\tlet baseName = \"\";\n\tlet capitalizeNext = true;\n\n\tfor (const character of safeBundleId) {\n\t\tif (character === \"_\") {\n\t\t\tbaseName += \"_\";\n\t\t\tcapitalizeNext = true;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (character >= \"a\" && character <= \"z\") {\n\t\t\tbaseName += capitalizeNext ? character.toUpperCase() : character;\n\t\t} else {\n\t\t\tbaseName += character;\n\t\t}\n\t\tcapitalizeNext = false;\n\t}\n\n\tif (!baseName) {\n\t\tbaseName = \"Message\";\n\t}\n\n\tif (!/^[A-Za-z_]/.test(baseName)) {\n\t\tbaseName = `Message${baseName}`;\n\t}\n\n\treturn baseName;\n}\n\nfunction serializePatternPreview(\n\tpattern: BundleNested[\"messages\"][number][\"variants\"][number][\"pattern\"]\n): string {\n\tlet result = \"\";\n\n\tfor (const part of pattern) {\n\t\tif (part.type === \"text\") {\n\t\t\tresult += part.value;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (part.type === \"expression\") {\n\t\t\tif (part.arg.type === \"literal\") {\n\t\t\t\tresult += part.arg.value;\n\t\t\t} else {\n\t\t\t\tresult += `{${part.arg.name}}`;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn result.replace(/\\s+/g, \" \").trim();\n}\n\ntype MarkupValueAccumulator = {\n\tcount: number;\n\ttypes: Set<string>;\n};\n\ntype MarkupTagAccumulator = {\n\toccurrences: number;\n\tchildrenTrue: boolean;\n\tchildrenFalse: boolean;\n\toptions: Map<string, MarkupValueAccumulator>;\n\tattributes: Map<string, MarkupValueAccumulator>;\n};\n\nfunction buildMarkupSchemaType(\n\tbundle: BundleNested,\n\tmatchTypes: InputMatchTypes\n): string {\n\tconst tagAccumulators = new Map<string, MarkupTagAccumulator>();\n\tconst inputVariableNames = new Set(\n\t\tbundle.declarations\n\t\t\t.filter((declaration) => declaration.type === \"input-variable\")\n\t\t\t.map((declaration) => declaration.name)\n\t);\n\n\tfor (const message of bundle.messages) {\n\t\tfor (const variant of message.variants) {\n\t\t\tfor (const part of variant.pattern) {\n\t\t\t\tif (part.type !== \"markup-start\" && part.type !== \"markup-standalone\") {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tconst tag = ensureMarkupTagAccumulator(tagAccumulators, part.name);\n\t\t\t\ttag.occurrences += 1;\n\t\t\t\tif (part.type === \"markup-start\") {\n\t\t\t\t\ttag.childrenTrue = true;\n\t\t\t\t} else {\n\t\t\t\t\ttag.childrenFalse = true;\n\t\t\t\t}\n\n\t\t\t\tcollectMarkupOptions(tag, part, inputVariableNames, matchTypes);\n\t\t\t\tcollectMarkupAttributes(tag, part);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (tagAccumulators.size === 0) {\n\t\treturn \"{}\";\n\t}\n\n\tconst tagEntries = Array.from(tagAccumulators.entries())\n\t\t.sort(([leftName], [rightName]) => leftName.localeCompare(rightName))\n\t\t.map(\n\t\t\t([tagName, tag]) =>\n\t\t\t\t`${renderTypeObjectKey(tagName)}: ${renderMarkupTagType(tag)}`\n\t\t);\n\n\treturn `{ ${tagEntries.join(\"; \")} }`;\n}\n\nfunction ensureMarkupTagAccumulator(\n\taccumulators: Map<string, MarkupTagAccumulator>,\n\ttagName: string\n): MarkupTagAccumulator {\n\tconst existing = accumulators.get(tagName);\n\tif (existing) {\n\t\treturn existing;\n\t}\n\tconst created: MarkupTagAccumulator = {\n\t\toccurrences: 0,\n\t\tchildrenTrue: false,\n\t\tchildrenFalse: false,\n\t\toptions: new Map(),\n\t\tattributes: new Map(),\n\t};\n\taccumulators.set(tagName, created);\n\treturn created;\n}\n\nfunction collectMarkupOptions(\n\ttag: MarkupTagAccumulator,\n\tpart: MarkupStart | MarkupStandalone,\n\tinputVariableNames: Set<string>,\n\tmatchTypes: InputMatchTypes\n): void {\n\tconst seenOptions = new Set<string>();\n\n\tfor (const option of part.options ?? []) {\n\t\tconst optionAccumulator = ensureMarkupValueAccumulator(\n\t\t\ttag.options,\n\t\t\toption.name\n\t\t);\n\t\toptionAccumulator.types.add(\n\t\t\tresolveMarkupOptionType(option.value, inputVariableNames, matchTypes)\n\t\t);\n\t\tif (!seenOptions.has(option.name)) {\n\t\t\toptionAccumulator.count += 1;\n\t\t\tseenOptions.add(option.name);\n\t\t}\n\t}\n}\n\nfunction collectMarkupAttributes(\n\ttag: MarkupTagAccumulator,\n\tpart: MarkupStart | MarkupStandalone\n): void {\n\tconst seenAttributes = new Set<string>();\n\n\tfor (const attribute of part.attributes ?? []) {\n\t\tconst attributeAccumulator = ensureMarkupValueAccumulator(\n\t\t\ttag.attributes,\n\t\t\tattribute.name\n\t\t);\n\t\tattributeAccumulator.types.add(\n\t\t\tattribute.value === true ? \"true\" : \"string\"\n\t\t);\n\t\tif (!seenAttributes.has(attribute.name)) {\n\t\t\tattributeAccumulator.count += 1;\n\t\t\tseenAttributes.add(attribute.name);\n\t\t}\n\t}\n}\n\nfunction resolveMarkupOptionType(\n\tvalue:\n\t\t| {\n\t\t\t\ttype: \"literal\";\n\t\t\t\tvalue: string;\n\t\t }\n\t\t| {\n\t\t\t\ttype: \"variable-reference\";\n\t\t\t\tname: string;\n\t\t },\n\tinputVariableNames: Set<string>,\n\tmatchTypes: InputMatchTypes\n): string {\n\tif (value.type === \"literal\") {\n\t\treturn \"string\";\n\t}\n\n\tif (inputVariableNames.has(value.name)) {\n\t\treturn inputTypeForName(value.name, matchTypes);\n\t}\n\n\treturn \"NonNullable<unknown>\";\n}\n\nfunction ensureMarkupValueAccumulator(\n\tvalues: Map<string, MarkupValueAccumulator>,\n\tname: string\n): MarkupValueAccumulator {\n\tconst existing = values.get(name);\n\tif (existing) {\n\t\treturn existing;\n\t}\n\n\tconst created: MarkupValueAccumulator = { count: 0, types: new Set() };\n\tvalues.set(name, created);\n\treturn created;\n}\n\nfunction renderMarkupTagType(tag: MarkupTagAccumulator): string {\n\treturn `{ options: ${renderMarkupObjectType(tag.options, tag.occurrences)}; attributes: ${renderMarkupObjectType(tag.attributes, tag.occurrences)}; children: ${renderChildrenType(tag)} }`;\n}\n\nfunction renderMarkupObjectType(\n\tvalues: Map<string, MarkupValueAccumulator>,\n\toccurrenceCount: number\n): string {\n\tif (values.size === 0) {\n\t\treturn \"{}\";\n\t}\n\n\tconst properties = Array.from(values.entries())\n\t\t.sort(([leftName], [rightName]) => leftName.localeCompare(rightName))\n\t\t.map(([name, value]) => {\n\t\t\tconst isOptional = value.count < occurrenceCount;\n\t\t\treturn `${renderTypeObjectKey(name)}${isOptional ? \"?\" : \"\"}: ${renderTypeUnion(value.types)}`;\n\t\t});\n\n\treturn `{ ${properties.join(\"; \")} }`;\n}\n\nfunction renderChildrenType(tag: MarkupTagAccumulator): string {\n\tif (tag.childrenTrue && tag.childrenFalse) {\n\t\treturn \"boolean\";\n\t}\n\tif (tag.childrenTrue) {\n\t\treturn \"true\";\n\t}\n\tif (tag.childrenFalse) {\n\t\treturn \"false\";\n\t}\n\treturn \"boolean\";\n}\n\nfunction renderTypeUnion(types: Set<string>): string {\n\tconst sorted = Array.from(types).sort();\n\tif (sorted.length === 0) {\n\t\treturn \"never\";\n\t}\n\tif (sorted.length === 1) {\n\t\treturn sorted[0] ?? \"never\";\n\t}\n\treturn sorted.join(\" | \");\n}\n\nfunction renderTypeObjectKey(name: string): string {\n\treturn isValidIdentifier(name) ? name : quotePropertyKey(name);\n}\n\nfunction collectInputMatchTypes(bundle: BundleNested): InputMatchTypes {\n\tconst inputNames = new Set(\n\t\tbundle.declarations\n\t\t\t?.filter((decl) => decl.type === \"input-variable\")\n\t\t\t.map((decl) => decl.name) ?? []\n\t);\n\tconst matchTypes: InputMatchTypes = new Map();\n\n\tconst ensureInfo = (name: string) => {\n\t\tconst existing = matchTypes.get(name);\n\t\tif (existing) return existing;\n\t\tconst created = { literals: new Set<string>(), hasCatchAll: false };\n\t\tmatchTypes.set(name, created);\n\t\treturn created;\n\t};\n\n\tfor (const message of bundle.messages) {\n\t\tfor (const variant of message.variants) {\n\t\t\tif (!variant.matches || variant.matches.length === 0) {\n\t\t\t\tfor (const name of inputNames) {\n\t\t\t\t\tconst info = ensureInfo(name);\n\t\t\t\t\tinfo.hasCatchAll = true;\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tfor (const match of variant.matches ?? []) {\n\t\t\t\tif (!inputNames.has(match.key)) continue;\n\t\t\t\tconst info = ensureInfo(match.key);\n\t\t\t\tif (match.type === \"catchall-match\") {\n\t\t\t\t\tinfo.hasCatchAll = true;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (match.type === \"literal-match\") {\n\t\t\t\t\tinfo.literals.add(match.value);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Matches on un-annotated aliases of an input match the input value too.\n\t// Widen an input type that was narrowed by direct matches: alias literals\n\t// join the union and an alias catchall accepts any value. Inputs that are\n\t// only matched through aliases keep their unnarrowed type.\n\tconst declarations = bundle.declarations ?? [];\n\tfor (const message of bundle.messages) {\n\t\tfor (const variant of message.variants) {\n\t\t\tfor (const match of variant.matches ?? []) {\n\t\t\t\tif (inputNames.has(match.key)) continue;\n\t\t\t\tconst inputName = resolveInputAlias(match.key, declarations);\n\t\t\t\tif (inputName === undefined) continue;\n\t\t\t\tconst info = matchTypes.get(inputName);\n\t\t\t\tif (!info) continue;\n\t\t\t\tif (match.type === \"catchall-match\") {\n\t\t\t\t\tinfo.hasCatchAll = true;\n\t\t\t\t} else if (match.type === \"literal-match\") {\n\t\t\t\t\tinfo.literals.add(match.value);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn matchTypes;\n}\n\nfunction bundleHasMarkup(bundle: BundleNested): boolean {\n\treturn bundle.messages.some((message) =>\n\t\tmessage.variants.some((variant) =>\n\t\t\tvariant.pattern.some(\n\t\t\t\t(part) =>\n\t\t\t\t\tpart.type === \"markup-start\" ||\n\t\t\t\t\tpart.type === \"markup-end\" ||\n\t\t\t\t\tpart.type === \"markup-standalone\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IAAI,KAAK,gBAAgB,EAAE,CAAC;oBACrC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;gBACzB,CAAC;qBAAM,IAAI,KAAK,CAAC,IAAI,KAAK,eAAe,EAAE,CAAC;oBAC3C,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;gBAChC,CAAC;YACF,CAAC;QACF,CAAC;IACF,CAAC;IAED,OAAO,UAAU,CAAC;AACnB,CAAC;AAED,SAAS,eAAe,CAAC,MAAoB;IAC5C,OAAO,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CACvC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CACjC,OAAO,CAAC,OAAO,CAAC,IAAI,CACnB,CAAC,IAAI,EAAE,EAAE,CACR,IAAI,CAAC,IAAI,KAAK,cAAc;QAC5B,IAAI,CAAC,IAAI,KAAK,YAAY;QAC1B,IAAI,CAAC,IAAI,KAAK,mBAAmB,CAClC,CACD,CACD,CAAC;AACH,CAAC","sourcesContent":["import type {\n\tBundle,\n\tBundleNested,\n\tMarkupStandalone,\n\tMarkupStart,\n\tProjectSettings,\n} from \"@inlang/sdk\";\nimport { compileMessage, type CompiledMessage } from \"./compile-message.js\";\nimport type { Compiled } from \"./types.js\";\nimport {\n\tinputTypeForName,\n\tjsDocBundleFunctionTypes,\n\ttype InputMatchTypes,\n} from \"./jsdoc-types.js\";\nimport { isValidIdentifier, quotePropertyKey } from \"./variable-access.js\";\nimport { toSafeModuleId } from \"./safe-module-id.js\";\nimport { escapeForDoubleQuoteString } from \"../services/codegen/escape.js\";\nimport type { CompilerOptions } from \"./compiler-options.js\";\nimport { perLocaleBuildStaticLocaleExpression } from \"./per-locale-build.js\";\nimport { resolveInputAlias } from \"./input-alias.js\";\n\ntype InlineBody = NonNullable<CompiledMessage[\"inline\"]>;\n\nexport type CompiledBundleWithMessages = {\n\t/** The compilation result for the bundle index */\n\tbundle: Compiled<Bundle>;\n\t/** The compilation results for the languages */\n\tmessages: {\n\t\t[locale: string]: CompiledMessage;\n\t};\n\t/** Match literal types inferred from bundle variants */\n\tmatchTypes: InputMatchTypes;\n\t/** Shared typedef name for bundle input types used across emitted JSDoc */\n\tinputTypeAliasName?: string;\n\t/** Compiled message helpers with no emitted reference in message-modules. */\n\tunreferencedMessageLocales?: string[];\n};\n\n/**\n * Compiles all the messages in the bundle and returns an index-function + each compiled message\n */\nexport const compileBundle = (args: {\n\tbundle: BundleNested;\n\tfallbackMap: Record<string, string | undefined>;\n\tmessageReferenceExpression: (locale: string, bundleId: string) => string;\n\tsettings?: ProjectSettings;\n\t/** Internal layout control; locale modules keep text grouped by language. */\n\tinlineMessages?: boolean;\n\texperimentalMiddlewareLocaleSplitting?: boolean;\n\texperimentalStaticLocale?: CompilerOptions[\"experimentalStaticLocale\"];\n}): CompiledBundleWithMessages => {\n\tconst compiledMessages: Record<string, CompiledMessage> = {};\n\tconst safeBundleId = toSafeModuleId(args.bundle.id);\n\tconst inputTypeAliasName = toBundleInputTypeAliasName(safeBundleId);\n\tconst matchTypes = collectInputMatchTypes(args.bundle);\n\tconst hasMarkup = bundleHasMarkup(args.bundle);\n\n\tfor (const message of args.bundle.messages) {\n\t\tif (compiledMessages[message.locale]) {\n\t\t\tthrow new Error(`Duplicate locale: ${message.locale}`);\n\t\t}\n\n\t\tconst compiledMessage = compileMessage(\n\t\t\targs.bundle.declarations,\n\t\t\tmessage,\n\t\t\tmessage.variants,\n\t\t\tmatchTypes,\n\t\t\tinputTypeAliasName\n\t\t);\n\n\t\t// set the pattern for the language tag\n\t\tcompiledMessages[message.locale] = compiledMessage;\n\t}\n\tconst inlineMessages =\n\t\targs.inlineMessages === true &&\n\t\targs.experimentalStaticLocale !== perLocaleBuildStaticLocaleExpression;\n\tconst inlinePlainTextByLocale = inlineMessages\n\t\t? findPlainTextMessages(args.bundle)\n\t\t: undefined;\n\tconst inlineCandidates = inlineMessages\n\t\t? findInlineBodies(compiledMessages, inlinePlainTextByLocale ?? {})\n\t\t: {};\n\tconst unreferencedMessageLocales = findUnreferencedMessageLocales({\n\t\tinlinedLocales: [\n\t\t\t...Object.keys(inlinePlainTextByLocale ?? {}),\n\t\t\t...Object.keys(inlineCandidates),\n\t\t],\n\t\tcompiledMessages,\n\t\tfallbackMap: args.fallbackMap,\n\t\thasMarkup,\n\t});\n\t// A fallback target stays a message function that the missing-locale alias\n\t// calls, so its dispatcher branch calls it too instead of repeating the body.\n\tconst inlineBodiesByLocale = Object.create(null) as Record<\n\t\tstring,\n\t\tInlineBody\n\t>;\n\tfor (const locale of unreferencedMessageLocales) {\n\t\tconst body = inlineCandidates[locale];\n\t\tif (body) inlineBodiesByLocale[locale] = body;\n\t}\n\n\treturn {\n\t\tbundle: compileBundleFunction({\n\t\t\tbundle: args.bundle,\n\t\t\tavailableLocales: Object.keys(args.fallbackMap),\n\t\t\tmessageReferenceExpression: args.messageReferenceExpression,\n\t\t\tinlinePlainTextByLocale,\n\t\t\tinlineBodiesByLocale,\n\t\t\tsettings: args.settings,\n\t\t\tmatchTypes,\n\t\t\thasMarkup,\n\t\t\texperimentalMiddlewareLocaleSplitting:\n\t\t\t\targs.experimentalMiddlewareLocaleSplitting ?? false,\n\t\t\texperimentalStaticLocale: args.experimentalStaticLocale,\n\t\t\tinputTypeAliasName,\n\t\t}),\n\t\tmessages: compiledMessages,\n\t\tmatchTypes,\n\t\tinputTypeAliasName,\n\t\tunreferencedMessageLocales,\n\t};\n};\n\n/**\n * Finds one-variant messages whose pattern is entirely static text. Their\n * dispatcher branch can return the string directly without retaining a\n * locale message function in the client bundle.\n */\nfunction findPlainTextMessages(bundle: BundleNested): Record<string, string> {\n\tconst result = Object.create(null) as Record<string, string>;\n\n\tfor (const message of bundle.messages) {\n\t\tif (message.variants.length !== 1) continue;\n\t\tconst variant = message.variants[0];\n\t\tif (!variant || !variant.pattern.every((part) => part.type === \"text\")) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// compilePattern emits static text inside a template literal, whose\n\t\t// cooked value normalizes CR and CRLF line endings to LF.\n\t\tresult[message.locale] = variant.pattern\n\t\t\t.map((part) => (part.type === \"text\" ? part.value : \"\"))\n\t\t\t.join(\"\")\n\t\t\t.replace(/\\r\\n?/g, \"\\n\");\n\t}\n\n\treturn result;\n}\n\n/**\n * Finds the messages with inputs whose function body the dispatcher can run\n * in place of calling the message function. Markup messages keep their `.parts`\n * function, and messages that are plain text are returned as a string instead.\n */\nfunction findInlineBodies(\n\tcompiledMessages: Record<string, CompiledMessage>,\n\tinlinePlainTextByLocale: Record<string, string>\n): Record<string, InlineBody> {\n\tconst result = Object.create(null) as Record<string, InlineBody>;\n\n\tfor (const [locale, message] of Object.entries(compiledMessages)) {\n\t\tif (message.inline && inlinePlainTextByLocale[locale] === undefined) {\n\t\t\tresult[locale] = message.inline;\n\t\t}\n\t}\n\n\treturn result;\n}\n\nfunction findUnreferencedMessageLocales(args: {\n\tinlinedLocales: string[];\n\tcompiledMessages: Record<string, CompiledMessage>;\n\tfallbackMap: Record<string, string | undefined>;\n\thasMarkup: boolean;\n}): string[] {\n\tif (args.hasMarkup) return [];\n\n\t// Missing-locale aliases still call the first available compiled fallback\n\t// function, even when the dispatcher's own branch uses an inline string.\n\tconst fallbackTargets = new Set<string>();\n\tfor (const locale of Object.keys(args.fallbackMap)) {\n\t\tif (Object.hasOwn(args.compiledMessages, locale)) continue;\n\n\t\tlet fallbackLocale = args.fallbackMap[locale];\n\t\tconst visited = new Set([locale]);\n\t\twhile (fallbackLocale && !visited.has(fallbackLocale)) {\n\t\t\tvisited.add(fallbackLocale);\n\t\t\tif (Object.hasOwn(args.compiledMessages, fallbackLocale)) {\n\t\t\t\tfallbackTargets.add(fallbackLocale);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tfallbackLocale = args.fallbackMap[fallbackLocale];\n\t\t}\n\t}\n\n\treturn args.inlinedLocales.filter((locale) => !fallbackTargets.has(locale));\n}\n\nconst compileBundleFunction = (args: {\n\t/**\n\t * The bundle to compile\n\t */\n\tbundle: BundleNested;\n\t/**\n\t * The language tags which are available\n\t */\n\tavailableLocales: string[];\n\t/**\n\t * The message reference expression\n\t */\n\tmessageReferenceExpression: (locale: string, bundleId: string) => string;\n\t/** Static text messages that can be returned directly from the dispatcher. */\n\tinlinePlainTextByLocale?: Record<string, string>;\n\t/** Message function bodies that the dispatcher runs in place of a call. */\n\tinlineBodiesByLocale?: Record<string, InlineBody>;\n\t/**\n\t * The project settings\n\t */\n\tsettings?: ProjectSettings;\n\t/**\n\t * Match literal types inferred from bundle variants\n\t */\n\tmatchTypes: InputMatchTypes;\n\t/**\n\t * Whether at least one variant in this bundle contains markup.\n\t */\n\thasMarkup: boolean;\n\t/**\n\t * Whether middleware locale splitting runtime hooks should be emitted.\n\t */\n\texperimentalMiddlewareLocaleSplitting: boolean;\n\t/**\n\t * Static locale expression emitted inside the message function so a\n\t * bundler can tree-shake unselected locale modules.\n\t */\n\texperimentalStaticLocale?: CompilerOptions[\"experimentalStaticLocale\"];\n\t/**\n\t * Shared typedef name for bundle input types used across emitted JSDoc.\n\t */\n\tinputTypeAliasName: string;\n}): Compiled<Bundle> => {\n\tconst inputs = args.bundle.declarations.filter(\n\t\t(decl) => decl.type === \"input-variable\"\n\t);\n\tconst hasInputs = inputs.length > 0;\n\tconst safeBundleId = toSafeModuleId(args.bundle.id);\n\n\tconst isSafeBundleId = safeBundleId === args.bundle.id;\n\n\tconst isFullyTranslated =\n\t\targs.availableLocales.length === args.settings?.locales.length;\n\tconst baseLocale = args.settings?.baseLocale;\n\tconst dispatchLocales =\n\t\tbaseLocale && args.availableLocales.includes(baseLocale)\n\t\t\t? [\n\t\t\t\t\t...args.availableLocales.filter((locale) => locale !== baseLocale),\n\t\t\t\t\tbaseLocale,\n\t\t\t\t]\n\t\t\t: args.availableLocales;\n\t// Inlined bodies read their inputs as `i`.\n\tconst inputsName = Object.keys(args.inlineBodiesByLocale ?? {}).length\n\t\t? \"i\"\n\t\t: \"inputs\";\n\tconst anyBranchReadsInputs = dispatchLocales.some((locale) => {\n\t\tif (args.inlinePlainTextByLocale?.[locale] !== undefined) return false;\n\t\treturn args.inlineBodiesByLocale?.[locale]?.readsInput ?? true;\n\t});\n\n\tconst inputType = args.inputTypeAliasName;\n\tconst localesUnion =\n\t\targs.availableLocales.length === 0\n\t\t\t? \"never\"\n\t\t\t: args.availableLocales.map((locale) => `\"${locale}\"`).join(\" | \");\n\tconst optionsType = `{ locale?: ${localesUnion} }`;\n\tconst inputsParameterType = `${hasInputs ? \"inputs\" : \"inputs?\"}: ${inputType}`;\n\tconst bundleFunctionType = `(${inputsParameterType}, options?: ${optionsType}) => LocalizedString`;\n\tconst partsFunctionType = `(${inputsParameterType}, options?: ${optionsType}) => import('../runtime.js').MessagePart[]`;\n\tconst markupSchemaType = buildMarkupSchemaType(args.bundle, args.matchTypes);\n\tconst messageMetadataType = `import('../runtime.js').MessageMetadata<${inputType}, ${optionsType}, ${markupSchemaType}>`;\n\n\tconst compileLocaleReturnStatements = (\n\t\tmode: \"string\" | \"parts\",\n\t\tcontinuationIndent: string\n\t): string =>\n\t\tdispatchLocales\n\t\t\t.map((locale, index) => {\n\t\t\t\tconst condition =\n\t\t\t\t\t!isFullyTranslated || index < dispatchLocales.length - 1\n\t\t\t\t\t\t? `if (locale === \"${locale}\") `\n\t\t\t\t\t\t: \"\";\n\t\t\t\tconst prefix = index > 0 ? continuationIndent : \"\";\n\t\t\t\tconst messageRef = args.messageReferenceExpression(\n\t\t\t\t\tlocale,\n\t\t\t\t\targs.bundle.id\n\t\t\t\t);\n\n\t\t\t\tif (mode === \"string\") {\n\t\t\t\t\tconst inlineText = args.inlinePlainTextByLocale?.[locale];\n\t\t\t\t\tif (inlineText !== undefined) {\n\t\t\t\t\t\treturn `${prefix}${condition}return /** @type {LocalizedString} */ (${JSON.stringify(inlineText)})`;\n\t\t\t\t\t}\n\t\t\t\t\tconst inlineBody = args.inlineBodiesByLocale?.[locale];\n\t\t\t\t\tif (inlineBody) {\n\t\t\t\t\t\tconst [onlyStatement] = inlineBody.statements;\n\t\t\t\t\t\treturn inlineBody.statements.length === 1 &&\n\t\t\t\t\t\t\tonlyStatement?.startsWith(\"return \")\n\t\t\t\t\t\t\t? `${prefix}${condition}${onlyStatement}`\n\t\t\t\t\t\t\t: `${prefix}${condition}{\\n${continuationIndent}\\t${inlineBody.statements.join(`\\n${continuationIndent}\\t`)}\\n${continuationIndent}}`;\n\t\t\t\t\t}\n\t\t\t\t\treturn `${prefix}${condition}return ${messageRef}(${inputsName})`;\n\t\t\t\t}\n\n\t\t\t\t// A locale's message has .parts() only if its own variants have\n\t\t\t\t// markup. Fallbacks and messages without markup are typed without\n\t\t\t\t// it, so read it through a type that declares it optional.\n\t\t\t\treturn `${prefix}${condition}return /** @type {{ parts?: (inputs: ${inputType}) => import('../runtime.js').MessagePart[] }} */ (${messageRef}).parts?.(inputs) ?? [{ type: \"text\", value: ${messageRef}(inputs) }]`;\n\t\t\t})\n\t\t\t.join(\"\\n\");\n\n\tconst perLocaleBuild =\n\t\targs.experimentalStaticLocale === perLocaleBuildStaticLocaleExpression;\n\t// A locale-specialized graph may ship source maps. Keeping the English\n\t// pattern preview in the shared dispatcher would leak base-locale message\n\t// text into every locale's map even after the English module is tree-shaken.\n\tconst englishMatchTableDoc = perLocaleBuild\n\t\t? \"\"\n\t\t: buildEnglishMatchTableDoc(args.bundle);\n\n\tconst commonJsDoc = `/**\n${englishMatchTableDoc}${jsDocBundleFunctionTypes({\n\t\tinputs,\n\t\tlocales: args.availableLocales,\n\t\tmatchTypes: args.matchTypes,\n\t\tinputTypeOverride: args.inputTypeAliasName,\n\t})}\n*/`;\n\n\tconst clientMiddlewareGuard = (indent: string): string => {\n\t\tif (!args.experimentalMiddlewareLocaleSplitting) {\n\t\t\treturn \"\";\n\t\t}\n\n\t\treturn `\\n${indent}if (experimentalMiddlewareLocaleSplitting && isServer === false) {\\n${indent}\\treturn /** @type {any} */ (globalThis).__paraglide.ssr.${safeBundleId}(${inputsName})\\n${indent}}`;\n\t};\n\n\tconst clientPartsMiddlewareGuard = (indent: string): string => {\n\t\tif (!args.experimentalMiddlewareLocaleSplitting) {\n\t\t\treturn \"\";\n\t\t}\n\n\t\treturn `\\n${indent}if (experimentalMiddlewareLocaleSplitting && isServer === false) {\\n${indent}\\tconst serverMessage = /** @type {any} */ (globalThis).__paraglide.ssr.${safeBundleId}\\n${indent}\\tif (typeof serverMessage.parts === \"function\") {\\n${indent}\\t\\treturn /** @type {import('../runtime.js').MessagePart[]} */ (serverMessage.parts(inputs))\\n${indent}\\t}\\n${indent}\\treturn /** @type {import('../runtime.js').MessagePart[]} */ ([{ type: \"text\", value: serverMessage(inputs) }])\\n${indent}}`;\n\t};\n\n\tconst maybeTrackMessageCall = (indent: string): string => {\n\t\tif (!args.experimentalMiddlewareLocaleSplitting) {\n\t\t\treturn \"\";\n\t\t}\n\n\t\treturn `\\n${indent}trackMessageCall(\"${safeBundleId}\", locale)`;\n\t};\n\n\tconst localeResolutionStatement = (indent: string): string => {\n\t\tconst localeExpression = perLocaleBuild\n\t\t\t? `${perLocaleBuildStaticLocaleExpression} ?? options.locale ?? getLocale()`\n\t\t\t: \"experimentalStaticLocale ?? options.locale ?? getLocale()\";\n\t\tconst overrideWarning = perLocaleBuild\n\t\t\t? `\\n${indent}if (${perLocaleBuildStaticLocaleExpression} !== undefined && options.locale !== undefined && options.locale !== ${perLocaleBuildStaticLocaleExpression}) console.warn(\"Paraglide: options.locale cannot override a locale-specialized client bundle; use a full document navigation to switch locales.\")`\n\t\t\t: \"\";\n\n\t\tif (\n\t\t\tisFullyTranslated &&\n\t\t\targs.availableLocales.length === 1 &&\n\t\t\t!args.experimentalMiddlewareLocaleSplitting\n\t\t) {\n\t\t\treturn `${indent}${localeExpression}${overrideWarning}`;\n\t\t}\n\n\t\treturn `${indent}const locale = ${localeExpression}${overrideWarning}${maybeTrackMessageCall(\n\t\t\tindent\n\t\t)}`;\n\t};\n\tconst keepUnusedInputsParameter = (indent: string): string =>\n\t\t!anyBranchReadsInputs && !args.experimentalMiddlewareLocaleSplitting\n\t\t\t? `\\n${indent}void ${inputsName};`\n\t\t\t: \"\";\n\n\tlet code = \"\";\n\n\tif (!args.hasMarkup) {\n\t\tcode = `${commonJsDoc}\n${isSafeBundleId ? \"export \" : \"\"}const ${safeBundleId} = /** @type {(${bundleFunctionType}) & ${messageMetadataType}} */ ((${inputsName}${hasInputs ? \"\" : \" = {}\"}, options = {}) => {${clientMiddlewareGuard(\n\t\t\t\"\\t\"\n\t\t)}${keepUnusedInputsParameter(\"\\t\")}\n${localeResolutionStatement(\"\\t\")}\n\t${compileLocaleReturnStatements(\"string\", \"\\t\")}${\n\t\t!isFullyTranslated\n\t\t\t? `\\n\treturn /** @type {LocalizedString} */ (\"${args.bundle.id}\")`\n\t\t\t: \"\"\n\t}\n});`;\n\t} else {\n\t\tcode = `${commonJsDoc}\n${isSafeBundleId ? \"export \" : \"\"}const ${safeBundleId} = /** @type {(${bundleFunctionType}) & { parts: ${partsFunctionType} } & ${messageMetadataType}} */ (\n\t/* @__PURE__ */ Object.assign(\n\t\t/** @type {${bundleFunctionType}} */ ((inputs${hasInputs ? \"\" : \" = {}\"}, options = {}) => {${clientMiddlewareGuard(\n\t\t\t\"\\t\\t\\t\"\n\t\t)}${keepUnusedInputsParameter(\"\\t\\t\\t\")}\n${localeResolutionStatement(\"\\t\\t\\t\")}\n\t\t\t${compileLocaleReturnStatements(\"string\", \"\\t\\t\\t\")}${\n\t\t\t\t!isFullyTranslated\n\t\t\t\t\t? `\\n\t\t\treturn /** @type {LocalizedString} */ (${JSON.stringify(args.bundle.id)})`\n\t\t\t\t\t: \"\"\n\t\t\t}\n\t\t}),\n\t\t{\n\t\t\tparts: /** @type {${partsFunctionType}} */ ((inputs${\n\t\t\t\thasInputs ? \"\" : \" = {}\"\n\t\t\t}, options = {}) => {${clientPartsMiddlewareGuard(\"\\t\\t\\t\\t\")}\n${localeResolutionStatement(\"\\t\\t\\t\\t\")}\n\t\t\t\t${compileLocaleReturnStatements(\"parts\", \"\\t\\t\\t\\t\")}${\n\t\t\t\t\t!isFullyTranslated\n\t\t\t\t\t\t? `\\n\t\t\t\treturn /** @type {import('../runtime.js').MessagePart[]} */ ([{ type: \"text\", value: ${JSON.stringify(args.bundle.id)} }])`\n\t\t\t\t\t\t: \"\"\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\t)\n);`;\n\t}\n\n\tif (isSafeBundleId === false) {\n\t\tcode += `\\nexport { ${safeBundleId} as \"${escapeForDoubleQuoteString(args.bundle.id)}\" }`;\n\t}\n\n\treturn {\n\t\tcode,\n\t\tnode: args.bundle,\n\t};\n};\n\nfunction buildEnglishMatchTableDoc(bundle: BundleNested): string {\n\tconst message = selectEnglishMessage(bundle);\n\tif (!message) {\n\t\treturn \"\";\n\t}\n\n\tconst selectorKeys = collectSelectorKeys(message);\n\tconst headerCells = [...selectorKeys, \"output\"];\n\tconst lines = [\n\t\t`* | ${headerCells.map(escapeTableCell).join(\" | \")} |`,\n\t\t`* | ${headerCells.map(() => \"---\").join(\" | \")} |`,\n\t];\n\n\tfor (const variant of message.variants) {\n\t\tconst rowValues = selectorKeys.map((key) =>\n\t\t\tgetMatchCellValue(variant, key)\n\t\t);\n\t\tconst serializedOutput = serializePatternPreview(variant.pattern);\n\t\tconst outputValue = JSON.stringify(\n\t\t\tserializedOutput.length > 160\n\t\t\t\t? `${serializedOutput.slice(0, 157)}...`\n\t\t\t\t: serializedOutput\n\t\t);\n\t\tlines.push(\n\t\t\t`* | ${[...rowValues, outputValue].map(escapeTableCell).join(\" | \")} |`\n\t\t);\n\t}\n\n\tlines.push(\"*\");\n\n\treturn lines.join(\"\\n\");\n}\n\nfunction selectEnglishMessage(\n\tbundle: BundleNested\n): BundleNested[\"messages\"][number] | undefined {\n\treturn (\n\t\tbundle.messages.find((message) => message.locale === \"en\") ??\n\t\tbundle.messages.find((message) => message.locale.startsWith(\"en-\"))\n\t);\n}\n\nfunction collectSelectorKeys(\n\tmessage: BundleNested[\"messages\"][number]\n): string[] {\n\tconst keys: string[] = [];\n\tconst seen = new Set<string>();\n\n\tfor (const variant of message.variants) {\n\t\tfor (const match of variant.matches ?? []) {\n\t\t\tif (seen.has(match.key)) continue;\n\t\t\tseen.add(match.key);\n\t\t\tkeys.push(match.key);\n\t\t}\n\t}\n\n\treturn keys;\n}\n\nfunction getMatchCellValue(\n\tvariant: BundleNested[\"messages\"][number][\"variants\"][number],\n\tkey: string\n): string {\n\tconst match = (variant.matches ?? []).find((entry) => entry.key === key);\n\tif (!match || match.type === \"catchall-match\") {\n\t\treturn \"*\";\n\t}\n\n\treturn JSON.stringify(match.value);\n}\n\nfunction escapeTableCell(value: string): string {\n\treturn value\n\t\t.replace(/\\|/g, \"\\\\|\")\n\t\t.replace(/\\r?\\n/g, \" \")\n\t\t.replaceAll(\"*/\", \"*\\\\/\");\n}\n\nexport function toBundleInputTypeAliasName(safeBundleId: string): string {\n\treturn `${toBundleTypeBaseName(safeBundleId)}Inputs`;\n}\n\nfunction toBundleTypeBaseName(safeBundleId: string): string {\n\tlet baseName = \"\";\n\tlet capitalizeNext = true;\n\n\tfor (const character of safeBundleId) {\n\t\tif (character === \"_\") {\n\t\t\tbaseName += \"_\";\n\t\t\tcapitalizeNext = true;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (character >= \"a\" && character <= \"z\") {\n\t\t\tbaseName += capitalizeNext ? character.toUpperCase() : character;\n\t\t} else {\n\t\t\tbaseName += character;\n\t\t}\n\t\tcapitalizeNext = false;\n\t}\n\n\tif (!baseName) {\n\t\tbaseName = \"Message\";\n\t}\n\n\tif (!/^[A-Za-z_]/.test(baseName)) {\n\t\tbaseName = `Message${baseName}`;\n\t}\n\n\treturn baseName;\n}\n\nfunction serializePatternPreview(\n\tpattern: BundleNested[\"messages\"][number][\"variants\"][number][\"pattern\"]\n): string {\n\tlet result = \"\";\n\n\tfor (const part of pattern) {\n\t\tif (part.type === \"text\") {\n\t\t\tresult += part.value;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (part.type === \"expression\") {\n\t\t\tif (part.arg.type === \"literal\") {\n\t\t\t\tresult += part.arg.value;\n\t\t\t} else {\n\t\t\t\tresult += `{${part.arg.name}}`;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn result.replace(/\\s+/g, \" \").trim();\n}\n\ntype MarkupValueAccumulator = {\n\tcount: number;\n\ttypes: Set<string>;\n};\n\ntype MarkupTagAccumulator = {\n\toccurrences: number;\n\tchildrenTrue: boolean;\n\tchildrenFalse: boolean;\n\toptions: Map<string, MarkupValueAccumulator>;\n\tattributes: Map<string, MarkupValueAccumulator>;\n};\n\nfunction buildMarkupSchemaType(\n\tbundle: BundleNested,\n\tmatchTypes: InputMatchTypes\n): string {\n\tconst tagAccumulators = new Map<string, MarkupTagAccumulator>();\n\tconst inputVariableNames = new Set(\n\t\tbundle.declarations\n\t\t\t.filter((declaration) => declaration.type === \"input-variable\")\n\t\t\t.map((declaration) => declaration.name)\n\t);\n\n\tfor (const message of bundle.messages) {\n\t\tfor (const variant of message.variants) {\n\t\t\tfor (const part of variant.pattern) {\n\t\t\t\tif (part.type !== \"markup-start\" && part.type !== \"markup-standalone\") {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tconst tag = ensureMarkupTagAccumulator(tagAccumulators, part.name);\n\t\t\t\ttag.occurrences += 1;\n\t\t\t\tif (part.type === \"markup-start\") {\n\t\t\t\t\ttag.childrenTrue = true;\n\t\t\t\t} else {\n\t\t\t\t\ttag.childrenFalse = true;\n\t\t\t\t}\n\n\t\t\t\tcollectMarkupOptions(tag, part, inputVariableNames, matchTypes);\n\t\t\t\tcollectMarkupAttributes(tag, part);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (tagAccumulators.size === 0) {\n\t\treturn \"{}\";\n\t}\n\n\tconst tagEntries = Array.from(tagAccumulators.entries())\n\t\t.sort(([leftName], [rightName]) => leftName.localeCompare(rightName))\n\t\t.map(\n\t\t\t([tagName, tag]) =>\n\t\t\t\t`${renderTypeObjectKey(tagName)}: ${renderMarkupTagType(tag)}`\n\t\t);\n\n\treturn `{ ${tagEntries.join(\"; \")} }`;\n}\n\nfunction ensureMarkupTagAccumulator(\n\taccumulators: Map<string, MarkupTagAccumulator>,\n\ttagName: string\n): MarkupTagAccumulator {\n\tconst existing = accumulators.get(tagName);\n\tif (existing) {\n\t\treturn existing;\n\t}\n\tconst created: MarkupTagAccumulator = {\n\t\toccurrences: 0,\n\t\tchildrenTrue: false,\n\t\tchildrenFalse: false,\n\t\toptions: new Map(),\n\t\tattributes: new Map(),\n\t};\n\taccumulators.set(tagName, created);\n\treturn created;\n}\n\nfunction collectMarkupOptions(\n\ttag: MarkupTagAccumulator,\n\tpart: MarkupStart | MarkupStandalone,\n\tinputVariableNames: Set<string>,\n\tmatchTypes: InputMatchTypes\n): void {\n\tconst seenOptions = new Set<string>();\n\n\tfor (const option of part.options ?? []) {\n\t\tconst optionAccumulator = ensureMarkupValueAccumulator(\n\t\t\ttag.options,\n\t\t\toption.name\n\t\t);\n\t\toptionAccumulator.types.add(\n\t\t\tresolveMarkupOptionType(option.value, inputVariableNames, matchTypes)\n\t\t);\n\t\tif (!seenOptions.has(option.name)) {\n\t\t\toptionAccumulator.count += 1;\n\t\t\tseenOptions.add(option.name);\n\t\t}\n\t}\n}\n\nfunction collectMarkupAttributes(\n\ttag: MarkupTagAccumulator,\n\tpart: MarkupStart | MarkupStandalone\n): void {\n\tconst seenAttributes = new Set<string>();\n\n\tfor (const attribute of part.attributes ?? []) {\n\t\tconst attributeAccumulator = ensureMarkupValueAccumulator(\n\t\t\ttag.attributes,\n\t\t\tattribute.name\n\t\t);\n\t\tattributeAccumulator.types.add(\n\t\t\tattribute.value === true ? \"true\" : \"string\"\n\t\t);\n\t\tif (!seenAttributes.has(attribute.name)) {\n\t\t\tattributeAccumulator.count += 1;\n\t\t\tseenAttributes.add(attribute.name);\n\t\t}\n\t}\n}\n\nfunction resolveMarkupOptionType(\n\tvalue:\n\t\t| {\n\t\t\t\ttype: \"literal\";\n\t\t\t\tvalue: string;\n\t\t }\n\t\t| {\n\t\t\t\ttype: \"variable-reference\";\n\t\t\t\tname: string;\n\t\t },\n\tinputVariableNames: Set<string>,\n\tmatchTypes: InputMatchTypes\n): string {\n\tif (value.type === \"literal\") {\n\t\treturn \"string\";\n\t}\n\n\tif (inputVariableNames.has(value.name)) {\n\t\treturn inputTypeForName(value.name, matchTypes);\n\t}\n\n\treturn \"NonNullable<unknown>\";\n}\n\nfunction ensureMarkupValueAccumulator(\n\tvalues: Map<string, MarkupValueAccumulator>,\n\tname: string\n): MarkupValueAccumulator {\n\tconst existing = values.get(name);\n\tif (existing) {\n\t\treturn existing;\n\t}\n\n\tconst created: MarkupValueAccumulator = { count: 0, types: new Set() };\n\tvalues.set(name, created);\n\treturn created;\n}\n\nfunction renderMarkupTagType(tag: MarkupTagAccumulator): string {\n\treturn `{ options: ${renderMarkupObjectType(tag.options, tag.occurrences)}; attributes: ${renderMarkupObjectType(tag.attributes, tag.occurrences)}; children: ${renderChildrenType(tag)} }`;\n}\n\nfunction renderMarkupObjectType(\n\tvalues: Map<string, MarkupValueAccumulator>,\n\toccurrenceCount: number\n): string {\n\tif (values.size === 0) {\n\t\treturn \"{}\";\n\t}\n\n\tconst properties = Array.from(values.entries())\n\t\t.sort(([leftName], [rightName]) => leftName.localeCompare(rightName))\n\t\t.map(([name, value]) => {\n\t\t\tconst isOptional = value.count < occurrenceCount;\n\t\t\treturn `${renderTypeObjectKey(name)}${isOptional ? \"?\" : \"\"}: ${renderTypeUnion(value.types)}`;\n\t\t});\n\n\treturn `{ ${properties.join(\"; \")} }`;\n}\n\nfunction renderChildrenType(tag: MarkupTagAccumulator): string {\n\tif (tag.childrenTrue && tag.childrenFalse) {\n\t\treturn \"boolean\";\n\t}\n\tif (tag.childrenTrue) {\n\t\treturn \"true\";\n\t}\n\tif (tag.childrenFalse) {\n\t\treturn \"false\";\n\t}\n\treturn \"boolean\";\n}\n\nfunction renderTypeUnion(types: Set<string>): string {\n\tconst sorted = Array.from(types).sort();\n\tif (sorted.length === 0) {\n\t\treturn \"never\";\n\t}\n\tif (sorted.length === 1) {\n\t\treturn sorted[0] ?? \"never\";\n\t}\n\treturn sorted.join(\" | \");\n}\n\nfunction renderTypeObjectKey(name: string): string {\n\treturn isValidIdentifier(name) ? name : quotePropertyKey(name);\n}\n\nfunction collectInputMatchTypes(bundle: BundleNested): InputMatchTypes {\n\tconst inputNames = new Set(\n\t\tbundle.declarations\n\t\t\t?.filter((decl) => decl.type === \"input-variable\")\n\t\t\t.map((decl) => decl.name) ?? []\n\t);\n\tconst matchTypes: InputMatchTypes = new Map();\n\n\tconst ensureInfo = (name: string) => {\n\t\tconst existing = matchTypes.get(name);\n\t\tif (existing) return existing;\n\t\tconst created = { literals: new Set<string>(), hasCatchAll: false };\n\t\tmatchTypes.set(name, created);\n\t\treturn created;\n\t};\n\n\tfor (const message of bundle.messages) {\n\t\tfor (const variant of message.variants) {\n\t\t\tif (!variant.matches || variant.matches.length === 0) {\n\t\t\t\tfor (const name of inputNames) {\n\t\t\t\t\tconst info = ensureInfo(name);\n\t\t\t\t\tinfo.hasCatchAll = true;\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tfor (const match of variant.matches ?? []) {\n\t\t\t\tif (!inputNames.has(match.key)) continue;\n\t\t\t\tconst info = ensureInfo(match.key);\n\t\t\t\tif (match.type === \"catchall-match\") {\n\t\t\t\t\tinfo.hasCatchAll = true;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (match.type === \"literal-match\") {\n\t\t\t\t\tinfo.literals.add(match.value);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Matches on un-annotated aliases of an input match the input value too.\n\t// Widen an input type that was narrowed by direct matches: alias literals\n\t// join the union and an alias catchall accepts any value. Inputs that are\n\t// only matched through aliases keep their unnarrowed type.\n\tconst declarations = bundle.declarations ?? [];\n\tfor (const message of bundle.messages) {\n\t\tfor (const variant of message.variants) {\n\t\t\tfor (const match of variant.matches ?? []) {\n\t\t\t\tif (inputNames.has(match.key)) continue;\n\t\t\t\tconst inputName = resolveInputAlias(match.key, declarations);\n\t\t\t\tif (inputName === undefined) continue;\n\t\t\t\tconst info = matchTypes.get(inputName);\n\t\t\t\tif (!info) continue;\n\t\t\t\tif (match.type === \"catchall-match\") {\n\t\t\t\t\tinfo.hasCatchAll = true;\n\t\t\t\t} else if (match.type === \"literal-match\") {\n\t\t\t\t\tinfo.literals.add(match.value);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn matchTypes;\n}\n\nfunction bundleHasMarkup(bundle: BundleNested): boolean {\n\treturn bundle.messages.some((message) =>\n\t\tmessage.variants.some((variant) =>\n\t\t\tvariant.pattern.some(\n\t\t\t\t(part) =>\n\t\t\t\t\tpart.type === \"markup-start\" ||\n\t\t\t\t\tpart.type === \"markup-end\" ||\n\t\t\t\t\tpart.type === \"markup-standalone\"\n\t\t\t)\n\t\t)\n\t);\n}\n"]}
@@ -172,7 +172,7 @@ ${result.bundle.code}
172
172
  expect(message({}, { locale: "de" })).toBe("Hallo");
173
173
  expect(message({}, { locale: "fr" })).toBe(compiledText);
174
174
  });
175
- test("leaves markup and multi-variant messages on their message functions", () => {
175
+ test("leaves markup messages on their message functions", () => {
176
176
  const markupBundle = {
177
177
  id: "notice",
178
178
  declarations: [],
@@ -216,39 +216,221 @@ test("leaves markup and multi-variant messages on their message functions", () =
216
216
  });
217
217
  expect(markupResult.bundle.code).toContain("return en_notice(inputs)");
218
218
  expect(markupResult.bundle.code).not.toContain('return /** @type {LocalizedString} */ ("Hello")');
219
- const multiVariantBundle = {
220
- id: "item_count",
221
- declarations: [{ type: "input-variable", name: "count" }],
222
- messages: ["en", "de"].map((locale) => ({
223
- id: `item_count-${locale}`,
224
- bundle_id: "item_count",
219
+ });
220
+ function createBundle(id, declarations, variantsByLocale, selectors = []) {
221
+ return {
222
+ id,
223
+ declarations,
224
+ messages: Object.entries(variantsByLocale).map(([locale, variants]) => ({
225
+ id: `${id}-${locale}`,
226
+ bundle_id: id,
225
227
  locale,
226
- selectors: [{ type: "variable-reference", name: "count" }],
227
- variants: [
228
- {
229
- id: `item_count-${locale}-zero`,
230
- message_id: `item_count-${locale}`,
231
- matches: [{ type: "literal-match", key: "count", value: "0" }],
232
- pattern: [{ type: "text", value: "No items" }],
233
- },
234
- {
235
- id: `item_count-${locale}-other`,
236
- message_id: `item_count-${locale}`,
237
- matches: [{ type: "catchall-match", key: "count" }],
238
- pattern: [{ type: "text", value: "Some items" }],
239
- },
240
- ],
228
+ selectors,
229
+ variants: variants.map((variant, index) => ({
230
+ id: `${id}-${locale}-${index}`,
231
+ message_id: `${id}-${locale}`,
232
+ matches: variant.matches ?? [],
233
+ pattern: variant.pattern,
234
+ })),
241
235
  })),
242
236
  };
243
- const multiVariantResult = compileBundle({
237
+ }
238
+ const variable = (name) => ({
239
+ type: "expression",
240
+ arg: { type: "variable-reference", name },
241
+ });
242
+ function createInputBundle() {
243
+ return createBundle("welcome", [{ type: "input-variable", name: "name" }], {
244
+ en: [{ pattern: [{ type: "text", value: "Hello " }, variable("name")] }],
245
+ de: [{ pattern: [{ type: "text", value: "Hallo " }, variable("name")] }],
246
+ });
247
+ }
248
+ /**
249
+ * Imports a compiled bundle the way message-modules output assembles it: the
250
+ * dispatcher plus the message functions of the locales it still references.
251
+ */
252
+ async function importBundle(result, bundleId, prelude = "") {
253
+ const messageFunctions = Object.entries(result.messages)
254
+ .filter(([locale]) => !result.unreferencedMessageLocales?.includes(locale))
255
+ .map(([locale, message]) => `const ${locale}_${bundleId} = ${message.code.replace(/;\s*$/, "")};`);
256
+ return import("data:text/javascript;charset=utf-8," +
257
+ encodeURIComponent(`
258
+ const getLocale = () => "en";
259
+ const experimentalStaticLocale = undefined;
260
+ ${prelude}
261
+ ${messageFunctions.join("\n")}
262
+ ${result.bundle.code}
263
+ `));
264
+ }
265
+ test("inlines message bodies with inputs and keeps fallback targets as functions", async () => {
266
+ const result = compileBundle({
244
267
  inlineMessages: true,
245
- bundle: multiVariantBundle,
268
+ bundle: createInputBundle(),
269
+ // fr has no message and aliases de, so de stays a function fr can call.
270
+ fallbackMap: { en: undefined, de: "en", fr: "de" },
271
+ messageReferenceExpression: (locale) => `${locale}_welcome`,
272
+ settings: {
273
+ baseLocale: "en",
274
+ locales: ["en", "de", "fr"],
275
+ },
276
+ });
277
+ expect(result.unreferencedMessageLocales).toEqual(["en"]);
278
+ expect(result.bundle.code).not.toContain("en_welcome");
279
+ expect(result.bundle.code).toContain("fr_welcome(");
280
+ const module = await importBundle(result, "welcome", "const fr_welcome = (i) => de_welcome(i);");
281
+ expect(module.welcome({ name: "Ada" }, { locale: "en" })).toBe("Hello Ada");
282
+ expect(module.welcome({ name: "Ada" }, { locale: "de" })).toBe("Hallo Ada");
283
+ expect(module.welcome({ name: "Ada" }, { locale: "fr" })).toBe("Hallo Ada");
284
+ });
285
+ test("inlines multi-variant bodies in their own block scope", async () => {
286
+ const variants = (none, some) => [
287
+ {
288
+ matches: [{ type: "literal-match", key: "count", value: "0" }],
289
+ pattern: [{ type: "text", value: none }],
290
+ },
291
+ {
292
+ matches: [{ type: "catchall-match", key: "count" }],
293
+ pattern: [{ type: "text", value: some }],
294
+ },
295
+ ];
296
+ const result = compileBundle({
297
+ inlineMessages: true,
298
+ bundle: createBundle("item_count", [{ type: "input-variable", name: "count" }], {
299
+ en: variants("No items", "Some items"),
300
+ de: variants("Keine Artikel", "Einige Artikel"),
301
+ }, [{ type: "variable-reference", name: "count" }]),
246
302
  fallbackMap: { en: undefined, de: "en" },
247
303
  messageReferenceExpression: (locale) => `${locale}_item_count`,
248
304
  settings: { baseLocale: "en", locales: ["en", "de"] },
249
305
  });
250
- expect(multiVariantResult.bundle.code).toContain('if (locale === "de") return de_item_count(inputs)');
251
- expect(multiVariantResult.bundle.code).toContain("return en_item_count(inputs)");
306
+ expect(result.unreferencedMessageLocales).toEqual(["en", "de"]);
307
+ expect(result.bundle.code).not.toContain("_item_count");
308
+ const module = await importBundle(result, "item_count");
309
+ expect(module.item_count({ count: 0 }, { locale: "en" })).toBe("No items");
310
+ expect(module.item_count({ count: 3 }, { locale: "en" })).toBe("Some items");
311
+ expect(module.item_count({ count: "0" }, { locale: "de" })).toBe("Keine Artikel");
312
+ expect(module.item_count({ count: 3 }, { locale: "de" })).toBe("Einige Artikel");
313
+ });
314
+ test("inlines locals that repeat across locales and shadow the dispatcher's locale and options", async () => {
315
+ // Each locale declares `locale` and `options` again, next to the
316
+ // dispatcher's own `locale` constant and `options` parameter.
317
+ const pattern = (label) => [
318
+ { type: "text", value: label },
319
+ variable("locale"),
320
+ { type: "text", value: " " },
321
+ variable("options"),
322
+ ];
323
+ const result = compileBundle({
324
+ inlineMessages: true,
325
+ bundle: createBundle("weight", [
326
+ { type: "input-variable", name: "amount" },
327
+ {
328
+ type: "local-variable",
329
+ name: "locale",
330
+ value: variable("amount"),
331
+ },
332
+ {
333
+ type: "local-variable",
334
+ name: "options",
335
+ value: {
336
+ type: "expression",
337
+ arg: { type: "literal", value: "kg" },
338
+ },
339
+ },
340
+ ], {
341
+ en: [{ pattern: pattern("Weight: ") }],
342
+ de: [{ pattern: pattern("Gewicht: ") }],
343
+ }),
344
+ fallbackMap: { en: undefined, de: "en" },
345
+ messageReferenceExpression: (locale) => `${locale}_weight`,
346
+ settings: { baseLocale: "en", locales: ["en", "de"] },
347
+ });
348
+ expect(result.unreferencedMessageLocales).toEqual(["en", "de"]);
349
+ expect(result.bundle.code).not.toContain("_weight");
350
+ const module = await importBundle(result, "weight");
351
+ expect(module.weight({ amount: 5 }, { locale: "en" })).toBe("Weight: 5 kg");
352
+ expect(module.weight({ amount: 5 }, { locale: "de" })).toBe("Gewicht: 5 kg");
353
+ expect(module.weight({ amount: 5 })).toBe("Weight: 5 kg");
354
+ });
355
+ test("returns the bundle id from an inlined body when no variant matches", async () => {
356
+ const variants = (zero, one) => [
357
+ {
358
+ matches: [{ type: "literal-match", key: "count", value: "0" }],
359
+ pattern: [{ type: "text", value: zero }],
360
+ },
361
+ {
362
+ matches: [{ type: "literal-match", key: "count", value: "1" }],
363
+ pattern: [{ type: "text", value: one }],
364
+ },
365
+ ];
366
+ const result = compileBundle({
367
+ inlineMessages: true,
368
+ bundle: createBundle("bottles", [{ type: "input-variable", name: "count" }], {
369
+ en: variants("No bottles", "One bottle"),
370
+ de: variants("Keine Flaschen", "Eine Flasche"),
371
+ }, [{ type: "variable-reference", name: "count" }]),
372
+ fallbackMap: { en: undefined, de: "en" },
373
+ messageReferenceExpression: (locale) => `${locale}_bottles`,
374
+ settings: { baseLocale: "en", locales: ["en", "de"] },
375
+ });
376
+ expect(result.unreferencedMessageLocales).toEqual(["en", "de"]);
377
+ expect(result.bundle.code).not.toContain("_bottles");
378
+ const module = await importBundle(result, "bottles");
379
+ expect(module.bottles({ count: 1 }, { locale: "de" })).toBe("Eine Flasche");
380
+ expect(module.bottles({ count: 7 }, { locale: "en" })).toBe("bottles");
381
+ expect(module.bottles({ count: 7 }, { locale: "de" })).toBe("bottles");
382
+ });
383
+ test("keeps message functions with inputs in a per-locale build", () => {
384
+ const result = compileBundle({
385
+ inlineMessages: true,
386
+ bundle: createInputBundle(),
387
+ fallbackMap: { en: undefined, de: "en" },
388
+ messageReferenceExpression: (locale) => `${locale}_welcome`,
389
+ settings: { baseLocale: "en", locales: ["en", "de"] },
390
+ experimentalStaticLocale: perLocaleBuildStaticLocaleExpression,
391
+ });
392
+ expect(result.unreferencedMessageLocales).toEqual([]);
393
+ expect(result.bundle.code).toContain('if (locale === "de") return de_welcome(inputs)');
394
+ expect(result.bundle.code).toContain("return en_welcome(inputs)");
395
+ });
396
+ test("runs inlined bodies on the server and forwards the inputs on the client when middleware locale splitting is on", async () => {
397
+ const result = compileBundle({
398
+ inlineMessages: true,
399
+ bundle: createInputBundle(),
400
+ fallbackMap: { en: undefined, de: "en" },
401
+ messageReferenceExpression: (locale) => `${locale}_welcome`,
402
+ settings: { baseLocale: "en", locales: ["en", "de"] },
403
+ experimentalMiddlewareLocaleSplitting: true,
404
+ });
405
+ expect(result.unreferencedMessageLocales).toEqual(["en", "de"]);
406
+ expect(result.bundle.code).not.toContain("_welcome");
407
+ const module = await importBundle(result, "welcome", `const experimentalMiddlewareLocaleSplitting = true;
408
+ let isServer = true;
409
+ export const setIsServer = (value) => { isServer = value; };
410
+ export const tracked = [];
411
+ const trackMessageCall = (id, locale) => tracked.push([id, locale]);`);
412
+ const inputs = { name: "Ada" };
413
+ expect(module.welcome(inputs, { locale: "de" })).toBe("Hallo Ada");
414
+ expect(module.tracked).toEqual([["welcome", "de"]]);
415
+ const serverCalls = [];
416
+ const scope = globalThis;
417
+ scope.__paraglide = {
418
+ ssr: {
419
+ welcome: (received) => {
420
+ serverCalls.push(received);
421
+ return "from the server";
422
+ },
423
+ },
424
+ };
425
+ try {
426
+ module.setIsServer(false);
427
+ expect(module.welcome(inputs, { locale: "de" })).toBe("from the server");
428
+ expect(serverCalls).toEqual([inputs]);
429
+ expect(serverCalls[0]).toBe(inputs);
430
+ }
431
+ finally {
432
+ delete scope.__paraglide;
433
+ }
252
434
  });
253
435
  test("keeps static text message references in a per-locale build", () => {
254
436
  const bundle = createPlainTextBundle("greeting", {