Skip to content

Commit

Permalink
fix(plugins): Don’t pass api to isInvalid
Browse files Browse the repository at this point in the history
`isInvalid` is always called *after* `flush`, so a plugin’s API shouldn’t be available.
  • Loading branch information
delucis committed Aug 2, 2021
1 parent 1e435c2 commit 1078b13
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 0 additions & 1 deletion src/plugins/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ const IsInvalid = (
G: state.G,
ctx: state.ctx,
game: opts.game,
api: pluginState && pluginState.api,
data: pluginState && pluginState.data,
});

Expand Down
4 changes: 3 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ export interface Plugin<
> {
name: string;
noClient?: (context: PluginContext<API, Data, G>) => boolean;
isInvalid?: (context: PluginContext<API, Data, G>) => false | string;
isInvalid?: (
context: Omit<PluginContext<API, Data, G>, 'api'>
) => false | string;
setup?: (setupCtx: { G: G; ctx: Ctx; game: Game<G, Ctx> }) => Data;
action?: (data: Data, payload: ActionShape.Plugin['payload']) => Data;
api?: (context: {
Expand Down

0 comments on commit 1078b13

Please sign in to comment.