refactor: reduce api surface
This commit is contained in:
+7
-6
@@ -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,
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user