|
| 1 | +/* tslint:disable */ |
| 2 | +/* eslint-disable */ |
| 3 | + |
| 4 | +export class OpenCC { |
| 5 | + free(): void; |
| 6 | + [Symbol.dispose](): void; |
| 7 | + /** |
| 8 | + * 根据加载的配置转换字符串。 |
| 9 | + * |
| 10 | + * @param {string} input - 需要转换的字符串。 |
| 11 | + * @returns {string} - 转换后的字符串。 |
| 12 | + * |
| 13 | + * @example |
| 14 | + * ```javascript |
| 15 | + * const traditionalText = converter.convert("开放中文转换"); |
| 16 | + * console.log(traditionalText); // 预期: 開放中文轉換 |
| 17 | + * ``` |
| 18 | + */ |
| 19 | + convert(input: string): string; |
| 20 | + /** |
| 21 | + * 创建一个新的 `OpenCC` 实例。 |
| 22 | + * |
| 23 | + * @param {`string`} `config_name` - 要使用的内置配置名称, 例如 "s2t.json"。 |
| 24 | + * @returns {`OpenCC`} - 一个 `OpenCC` 实例。 |
| 25 | + * @throws {`JsValue`} - 如果配置加载失败,则抛出一个错误对象。 |
| 26 | + * |
| 27 | + * @example |
| 28 | + * ```javascript |
| 29 | + * import init, { OpenCC } from './pkg/ferrous_opencc.js'; |
| 30 | + * |
| 31 | + * async function main() { |
| 32 | + * await init(); |
| 33 | + * try { |
| 34 | + * const converter = new OpenCC("s2t.json"); |
| 35 | + * console.log('加载成功:', converter.name); |
| 36 | + * } catch (err) { |
| 37 | + * console.error('加载失败:', err); |
| 38 | + * } |
| 39 | + * } |
| 40 | + * main(); |
| 41 | + * ``` |
| 42 | + */ |
| 43 | + constructor(config_name: string); |
| 44 | + /** |
| 45 | + * 获取当前加载的配置的名称。 |
| 46 | + * |
| 47 | + * @returns {string} - 配置的名称。 |
| 48 | + * |
| 49 | + * @example |
| 50 | + * ```javascript |
| 51 | + * const configName = converter.name; |
| 52 | + * console.log(configName); |
| 53 | + * ``` |
| 54 | + */ |
| 55 | + readonly name: string; |
| 56 | +} |
| 57 | + |
| 58 | +export class TextConverter { |
| 59 | + free(): void; |
| 60 | + [Symbol.dispose](): void; |
| 61 | + /** |
| 62 | + * 使用指定的配置文件创建一个 `TextConverter` 实例 |
| 63 | + * @param `config_name` 内置配置文件的名称,参见 {@link <https://docs.rs/ferrous-opencc/0.3.1/ferrous_opencc/config/enum.BuiltinConfig.html>} |
| 64 | + * @returns 返回初始化的转换器实例 |
| 65 | + * @throws 如果传入的配置名称不存在或加载失败,抛出错误 |
| 66 | + */ |
| 67 | + constructor(config_name: string); |
| 68 | + /** |
| 69 | + * 根据之前初始化时的配置进行简繁转换 |
| 70 | + * @see OpenCC.convert |
| 71 | + */ |
| 72 | + convert(input: string): string; |
| 73 | +} |
| 74 | + |
| 75 | +export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module; |
| 76 | + |
| 77 | +export interface InitOutput { |
| 78 | + readonly memory: WebAssembly.Memory; |
| 79 | + readonly __wbg_textconverter_free: (a: number, b: number) => void; |
| 80 | + readonly textconverter_convert: (a: number, b: number, c: number) => [number, number]; |
| 81 | + readonly textconverter_new: (a: number, b: number) => [number, number, number]; |
| 82 | + readonly __wbg_opencc_free: (a: number, b: number) => void; |
| 83 | + readonly opencc_convert: (a: number, b: number, c: number) => [number, number]; |
| 84 | + readonly opencc_name: (a: number) => [number, number]; |
| 85 | + readonly opencc_new_wasm: (a: number, b: number) => [number, number, number]; |
| 86 | + readonly rust_zstd_wasm_shim_calloc: (a: number, b: number) => number; |
| 87 | + readonly rust_zstd_wasm_shim_free: (a: number) => void; |
| 88 | + readonly rust_zstd_wasm_shim_malloc: (a: number) => number; |
| 89 | + readonly rust_zstd_wasm_shim_memcmp: (a: number, b: number, c: number) => number; |
| 90 | + readonly rust_zstd_wasm_shim_memcpy: (a: number, b: number, c: number) => number; |
| 91 | + readonly rust_zstd_wasm_shim_memmove: (a: number, b: number, c: number) => number; |
| 92 | + readonly rust_zstd_wasm_shim_memset: (a: number, b: number, c: number) => number; |
| 93 | + readonly rust_zstd_wasm_shim_qsort: (a: number, b: number, c: number, d: number) => void; |
| 94 | + readonly __wbindgen_externrefs: WebAssembly.Table; |
| 95 | + readonly __wbindgen_malloc: (a: number, b: number) => number; |
| 96 | + readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number; |
| 97 | + readonly __externref_table_dealloc: (a: number) => void; |
| 98 | + readonly __wbindgen_free: (a: number, b: number, c: number) => void; |
| 99 | + readonly __wbindgen_start: () => void; |
| 100 | +} |
| 101 | + |
| 102 | +export type SyncInitInput = BufferSource | WebAssembly.Module; |
| 103 | + |
| 104 | +/** |
| 105 | +* Instantiates the given `module`, which can either be bytes or |
| 106 | +* a precompiled `WebAssembly.Module`. |
| 107 | +* |
| 108 | +* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated. |
| 109 | +* |
| 110 | +* @returns {InitOutput} |
| 111 | +*/ |
| 112 | +export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput; |
| 113 | + |
| 114 | +/** |
| 115 | +* If `module_or_path` is {RequestInfo} or {URL}, makes a request and |
| 116 | +* for everything else, calls `WebAssembly.instantiate` directly. |
| 117 | +* |
| 118 | +* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated. |
| 119 | +* |
| 120 | +* @returns {Promise<InitOutput>} |
| 121 | +*/ |
| 122 | +export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>; |
0 commit comments