aboutsummaryrefslogtreecommitdiff
path: root/web/src/wasm.d.ts
diff options
context:
space:
mode:
Diffstat (limited to 'web/src/wasm.d.ts')
-rw-r--r--web/src/wasm.d.ts25
1 files changed, 25 insertions, 0 deletions
diff --git a/web/src/wasm.d.ts b/web/src/wasm.d.ts
new file mode 100644
index 0000000..6692774
--- /dev/null
+++ b/web/src/wasm.d.ts
@@ -0,0 +1,25 @@
+export class TyperPunkGame {
+ constructor(text: string);
+ handle_input(input: string): Result<void, string>;
+ handle_backspace(ctrl: boolean): Result<boolean, string>;
+ get_stats(): Result<[number, number], string>;
+ get_stats_and_input(): Result<[string, number, number], string>;
+ is_finished(): boolean;
+ can_backspace_to_position(position: number): boolean;
+ get_current_word_start(): number;
+ set_text(text: string): Result<void, string>;
+ get_text(): string;
+ get_input(): string;
+ start(): void;
+ get_wpm(): number;
+ get_time_elapsed(): number;
+ get_raw_wpm(): number;
+ free(): void;
+}
+
+export type Result<T, E> = {
+ isOk(): boolean;
+ isErr(): boolean;
+ unwrap(): T;
+ unwrapErr(): E;
+}; \ No newline at end of file