import { Component, ComponentChanged } from '@combos-fun/engine'; import { TextStyle } from 'pixi.js'; import { Renderer, RendererSystem, RendererManager, ContainerManager } from '@combos-fun/plugin-renderer'; import { Text as Text$2, Graphics } from '@combos-fun/renderer-adapter'; 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; /** Combos extra on Pixi v8 `TextStyle` — stripped before constructing Pixi Text. */ type TextColor = number | string; type TextStyleInput = Partial & { backgroundColor?: TextColor; }; declare function splitTextStyle(style?: TextStyleInput): { backgroundColor: TextColor | undefined; pixiStyle: Partial; }; /** * Accept the common agent guesses: `0xffffff`, `"#fff"`, `"#ffffff"`, `"0xff0000"`. * Returns `null` when the value cannot be used as a Pixi fill color. */ declare function parseTextColor(color: TextColor | undefined | null): number | null; interface TextParams { text: string; /** Values substituted into named placeholders such as `{score}`. */ replacements?: TextReplacements; style?: TextStyleInput; } declare class Text$1 extends Component { static componentName: string; text: string; replacements: TextReplacements; style: TextParams['style']; init(obj?: TextParams): void; } interface TextSystemParams { /** 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 Text extends Renderer { static systemName: string; name: string; texts: { [propName: number]: { text: Text$2; background?: Graphics; component: Text$1; }; }; renderSystem: RendererSystem; rendererManager: RendererManager; containerManager: ContainerManager; 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?: TextSystemParams): 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; change(changed: ComponentChanged): void; setSize(changed: ComponentChanged): void; private syncBackground; onDestroy(): void; private resolveText; private rememberSourceTexts; private collectSourceTexts; private scheduleI18nRequest; private startI18nRequest; private requestI18nAndApply; private refreshAllText; } /** 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, Text$1 as Text, Text as TextSystem, addSourceTexts, findTranslatedTemplate, hasCombosRequestI18n, hasMissingSourceTranslations, hasSourceTranslation, interpolateText, localizeText, mergeTranslations, parseI18nResult, parseTextColor, requestHostI18n, shouldHoldForMissingTranslation, shouldRequestI18nForSourceTexts, sourceTextsSignature, splitTextStyle, untranslatedSourceTexts }; export type { CombosHostSdk, CombosI18nRequest, CombosI18nResult, TextParams, TextReplacementValue, TextReplacements, TextStyleInput, TextSystemParams, TextTranslations };