forked from dmitmel/ultimate-crosscode-typedefs
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move the type definitions for Localize Me out of cc-ru's source tree
Showing
4 changed files
with
93 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* eslint-disable @typescript-eslint/naming-convention */ | ||
|
||
export {}; | ||
|
||
declare global { | ||
namespace LocalizeMe { | ||
type Resource<T> = T | (() => MaybePromise<T>); | ||
interface TranslationResult { | ||
orig: string; | ||
text: string; | ||
} | ||
type TranslationPack = Record<string, TranslationResult>; | ||
|
||
type MapFileFunction = ( | ||
url_to_patch: string, | ||
) => string | (() => MaybePromise<TranslationPack | TranslationPackFunction>) | null; | ||
type TranslationPackFunction = (dict_path: string) => TranslationResult; | ||
|
||
interface Rectangle { | ||
x: number; | ||
y: number; | ||
width: number; | ||
height: number; | ||
} | ||
|
||
interface FontPatchingContextCommon { | ||
char_height: number; | ||
size_index: number; | ||
base_image: ig.Image.Data; | ||
} | ||
|
||
interface PrePatchFontContext extends FontPatchingContextCommon { | ||
set_base_image(img: ig.Image.Data): void; | ||
} | ||
|
||
interface PatchFontContext extends FontPatchingContextCommon { | ||
patched_base_image: ig.Image.Data; | ||
color: string; | ||
get_char_pos(c: string): Rectangle; | ||
set_char_pos(c: string, pos: Rectangle): void; | ||
recolor_from_base_image(canvas: HTMLCanvasElement): HTMLCanvasElement; | ||
} | ||
|
||
interface PatchBaseFontContext extends PatchFontContext { | ||
reserve_char(canvas: HTMLCanvasElement, width: number): Rectangle; | ||
import_from_font( | ||
canvas: HTMLCanvasElement, | ||
ig_font: ig.Font, | ||
start_char: string, | ||
): HTMLCanvasElement; | ||
} | ||
} | ||
|
||
namespace ig { | ||
interface LangOptions { | ||
localizeme_global_index?: number; | ||
|
||
from_locale?: string; | ||
map_file?: string | (() => MaybePromise<LocalizeMe.MapFileFunction>); | ||
url_prefix?: string; | ||
missing_cb?: (lang_label_or_string: ig.LangLabel.Data | string, dict_path: string) => string; | ||
language?: ig.LangLabel.Data; | ||
text_filter?: (text: string, translation_result: LocalizeMe.TranslationResult) => string; | ||
patch_base_font: ( | ||
canvas: HTMLCanvasElement, | ||
context: LocalizeMe.PatchBaseFontContext, | ||
) => ig.Image.Data; | ||
pre_patch_font: (context: LocalizeMe.PrePatchFontContext) => MaybePromise<void>; | ||
number_locale?: string; | ||
format_number?: ( | ||
number: number, | ||
precision: number, | ||
suffix: string, | ||
template: string, | ||
) => string; | ||
misc_time_function?: () => string; | ||
flag?: LocalizeMe.Resource<ig.Image.Data | string>; | ||
} | ||
} | ||
|
||
interface LocalizeMe { | ||
add_locale(this: this, name: string, options: NullablePartial<ig.LangOptions>): void; | ||
|
||
register_locale_chosen(this: this, func: () => void): void; | ||
} | ||
|
||
var localizeMe: LocalizeMe; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
type MaybePromise<T> = T | Promise<T>; | ||
type NullablePartial<T> = { [P in keyof T]?: T[P] | null }; | ||
type Writable<T> = { -readonly [P in keyof T]: T[P] }; |