import { Component, ComponentChanged, GameObject } from '@combos-fun/engine'; import { Renderer3D } from '@combos-fun/plugin-renderer-3d'; /** Keep identical to `@combos-fun/plugin-renderer-text` localization. */ type TextReplacementValue = string | number; type TextReplacements = Record; type TextTranslations = Record; declare function interpolateText(template: string, replacements?: TextReplacements): string; declare function findTranslatedTemplate(sourceText: string, translations: TextTranslations): string | undefined; declare function hasSourceTranslation(sourceText: string, translations: TextTranslations): boolean; /** Templates that still have no translation; later `requestI18n` sends only these. */ declare function untranslatedSourceTexts(sourceTexts: readonly string[], translations: TextTranslations): string[]; declare function hasMissingSourceTranslations(sourceTexts: readonly string[], translations: TextTranslations): boolean; declare function sourceTextsSignature(sourceTexts: readonly string[]): string; /** After the first host reply, only request again for templates still missing. */ declare function shouldRequestI18nForSourceTexts(sourceTexts: readonly string[], translations: TextTranslations, state: { i18nNeeded: boolean; lastRequestedSourceTexts: string; }): boolean; declare function shouldHoldForMissingTranslation(sourceText: string, translations: TextTranslations, state: { sourceLocale: string; targetLocale: string; i18nNeeded: boolean; firstI18nSettled: boolean; resolvedSourceTexts: ReadonlySet; }): boolean; declare function localizeText(sourceText: string, replacements: TextReplacements | undefined, sourceLocale: string, targetLocale: string, translations: TextTranslations): string; declare function addSourceTexts(target: Set, texts?: Iterable): void; declare function mergeTranslations(current: TextTranslations, incoming: Record): TextTranslations; interface Text3DParams { text?: string; /** Values substituted into named placeholders such as `{score}`. */ replacements?: TextReplacements; fontSize?: number; color?: number; anchorX?: string; anchorY?: string; maxWidth?: number; font?: string; positionX?: number; positionY?: number; positionZ?: number; rotationX?: number; rotationY?: number; rotationZ?: number; } declare class Text3D extends Component { static componentName: string; text: string; replacements: TextReplacements; fontSize: number; color: number; anchorX: string; anchorY: string; maxWidth: number; font: string; positionX: number; positionY: number; positionZ: number; rotationX: number; rotationY: number; rotationZ: number; init(obj?: Text3DParams): void; } interface Text3DSystemParams { /** BCP 47 locale of the source text, for example `zh-CN`. Omit to disable host-driven i18n. */ sourceLocale?: string; /** * All source templates to translate on first `requestI18n`, including copy * for screens that are not mounted yet. The system also keeps a growing * session catalog of every later template it sees. */ sourceTexts?: string[]; } declare class Text3DSystem extends Renderer3D { static systemName: string; name: string; private texts; private poseBridges; private sourceLocale; private targetLocale; private translations; /** Growing catalog of every source template seen this session. */ private knownSourceTexts; private lastRequestedSourceTexts; private i18nRequestScheduled; private i18nRequestId; private firstI18nSettled; private i18nNeeded; private resolvedSourceTexts; init(params?: Text3DSystemParams): void; /** Register extra source templates before or after ready. First request includes these. */ declareSourceTexts(texts?: string[]): void; beforeReady(): Promise; setI18n(locale: string, translations: TextTranslations): void; componentChanged(changed: ComponentChanged): void; rendererUpdate(gameObject: GameObject): void; private handleAdd; private handleChange; private handleRemove; private syncTextProps; private applyPose; onDestroy(): void; private resolveText; private rememberSourceTexts; private collectSourceTexts; private scheduleI18nRequest; private startI18nRequest; private requestI18nAndApply; private refreshAllText; } /** Keep identical to `@combos-fun/plugin-renderer-text` hostSdk. */ /** Host-injected global. The SDK itself is not part of this repo. */ declare const COMBOS_HOST_SDK: "combos"; interface CombosI18nRequest { sourceLocale: string; sourceTexts: string[]; } type CombosI18nResult = { needed: false; } | { needed: true; locale: string; translations: TextTranslations; }; interface CombosHostSdk { requestI18n?(request: CombosI18nRequest): Promise; } declare global { interface Window { combos?: CombosHostSdk; } } declare function hasCombosRequestI18n(sdk?: CombosHostSdk | undefined | null): sdk is CombosHostSdk & { requestI18n: NonNullable; }; declare function parseI18nResult(data: unknown): CombosI18nResult; /** Ask the injected host SDK. Always resolves; missing method means no translation. */ declare function requestHostI18n(request: CombosI18nRequest): Promise; export { COMBOS_HOST_SDK, Text3D, Text3DSystem, addSourceTexts, findTranslatedTemplate, hasCombosRequestI18n, hasMissingSourceTranslations, hasSourceTranslation, interpolateText, localizeText, mergeTranslations, parseI18nResult, requestHostI18n, shouldHoldForMissingTranslation, shouldRequestI18nForSourceTexts, sourceTextsSignature, untranslatedSourceTexts }; export type { CombosHostSdk, CombosI18nRequest, CombosI18nResult, Text3DParams, Text3DSystemParams, TextReplacementValue, TextReplacements, TextTranslations };