From 6afcfee41b20bb3023d7345e4a9aec3f6909cc51 Mon Sep 17 00:00:00 2001 From: Joe Cowman Date: Fri, 14 Dec 2018 16:46:48 -0600 Subject: [PATCH] refactor(api): Move api-hooks.ts from api to api/impl --- src/api/api-hook-manager.ts | 2 +- src/api/{ => impl}/api-hooks.ts | 8 ++++---- src/api/impl/index.ts | 13 +++++++++++++ src/api/index.ts | 6 +----- 4 files changed, 19 insertions(+), 10 deletions(-) rename src/api/{ => impl}/api-hooks.ts (94%) create mode 100644 src/api/impl/index.ts diff --git a/src/api/api-hook-manager.ts b/src/api/api-hook-manager.ts index c0042ac..6765b5c 100644 --- a/src/api/api-hook-manager.ts +++ b/src/api/api-hook-manager.ts @@ -8,7 +8,7 @@ import { TrackedEvent } from "../events"; import { GameInstance } from "../state"; -import { returnTrue } from "./api-hooks"; +import { returnTrue } from "./impl"; /** * Manager for the Game's API hooks. diff --git a/src/api/api-hooks.ts b/src/api/impl/api-hooks.ts similarity index 94% rename from src/api/api-hooks.ts rename to src/api/impl/api-hooks.ts index b99f579..1c62684 100644 --- a/src/api/api-hooks.ts +++ b/src/api/impl/api-hooks.ts @@ -9,10 +9,10 @@ * Licensed under MIT License (see https://github.com/regal/regal) */ -import { RegalError } from "../error"; -import { EventFunction, isTrackedEvent, on } from "../events"; -import { GameInstance } from "../state"; -import { HookManager } from "./api-hook-manager"; +import { RegalError } from "../../error"; +import { EventFunction, isTrackedEvent, on } from "../../events"; +import { GameInstance } from "../../state"; +import { HookManager } from "../api-hook-manager"; /** Default implementation of `beforeUndoCommandHook`; always returns true. */ export const returnTrue = (game: GameInstance) => true; diff --git a/src/api/impl/index.ts b/src/api/impl/index.ts new file mode 100644 index 0000000..d6535a1 --- /dev/null +++ b/src/api/impl/index.ts @@ -0,0 +1,13 @@ +/* + * The purpose of this file is to abstract all api-related implementations + * by re-exporting their constructors from a single file. + * + * Copyright (c) 2018 Joseph R Cowman + * Licensed under MIT License (see https://github.com/regal/regal) + */ +export { + onPlayerCommand, + onStartCommand, + onBeforeUndoCommand, + returnTrue +} from "./api-hooks"; diff --git a/src/api/index.ts b/src/api/index.ts index 104001e..a07b97a 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -8,9 +8,5 @@ export { GameResponse, GameResponseOutput } from "./game-response"; export { Game } from "./game-api"; -export { - onPlayerCommand, - onStartCommand, - onBeforeUndoCommand -} from "./api-hooks"; +export { onPlayerCommand, onStartCommand, onBeforeUndoCommand } from "./impl"; export { HookManager } from "./api-hook-manager";