refactor: reduce api surface

This commit is contained in:
2026-04-02 14:11:35 +08:00
parent e3bc63b088
commit b2b35c3a99
2 changed files with 63 additions and 70 deletions
+7 -6
View File
@@ -4,10 +4,10 @@ import {Region} from "./region";
import {
Command,
CommandRegistry,
type CommandRunner, CommandRunnerContext,
CommandRunnerContext,
CommandRunnerContextExport, CommandSchema, createCommandRegistry,
createCommandRunnerContext, parseCommandSchema,
PromptEvent
PromptEvent, registerCommand
} from "../utils/command";
import {AsyncQueue} from "../utils/async-queue";
@@ -60,11 +60,12 @@ export function createGameCommandRegistry<TState extends Record<string, unknown>
}
export function createGameCommand<TState extends Record<string, unknown> = {} , TResult = unknown>(
registry: CommandRegistry<IGameContext<TState>>,
schema: CommandSchema | string,
run: (this: CommandRunnerContext<IGameContext<TState>>, command: Command) => Promise<TResult>
): CommandRunner<IGameContext<TState>, TResult> {
return {
) {
registerCommand(registry, {
schema: typeof schema === 'string' ? parseCommandSchema(schema) : schema,
run,
};
}
});
}