Skip to content

Commit

Permalink
All contexts will be equal in 8.2
Browse files Browse the repository at this point in the history
  • Loading branch information
kasperpeulen committed May 31, 2024
1 parent 459d398 commit 89e16ed
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions src/story.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,13 +247,6 @@ export interface StoryContextUpdate<TArgs = Args> {
}

export type ViewMode = 'story' | 'docs';
export interface StoryContextForLoaders<TRenderer extends Renderer = Renderer, TArgs = Args>
extends StoryContextForEnhancers<TRenderer, TArgs>,
Required<StoryContextUpdate<TArgs>> {
hooks: unknown;
viewMode: ViewMode;
originalStoryFn: StoryFn<TRenderer>;
}

export type LoaderFunction<TRenderer extends Renderer = Renderer, TArgs = Args> = (
context: StoryContextForLoaders<TRenderer, TArgs>
Expand All @@ -267,27 +260,33 @@ export type BeforeEach<TRenderer extends Renderer = Renderer, TArgs = Args> = (
) => Awaitable<CleanupCallback | void>;

export interface StoryContext<TRenderer extends Renderer = Renderer, TArgs = Args>
extends StoryContextForLoaders<TRenderer, TArgs> {
extends StoryContextForEnhancers<TRenderer, TArgs>,
Required<StoryContextUpdate<TArgs>> {
hooks: unknown;
viewMode: ViewMode;
originalStoryFn: StoryFn<TRenderer>;
loaded: Record<string, any>;
abortSignal: AbortSignal;
canvasElement: TRenderer['canvasElement'];
step: StepFunction<TRenderer, TArgs>;
mount: () => Promise<void>;
}

// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface StoryContextForLoaders<TRenderer extends Renderer = Renderer, TArgs = Args>
extends StoryContext<TRenderer, TArgs> {}

// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface PlayFunctionContext<TRenderer extends Renderer = Renderer, TArgs = Args>
extends StoryContext<TRenderer, TArgs> {}

export type StepLabel = string;

export type StepFunction<TRenderer extends Renderer = Renderer, TArgs = Args> = (
label: StepLabel,
play: PlayFunction<TRenderer, TArgs>
) => Promise<void> | void;

export type PlayFunctionContext<TRenderer extends Renderer = Renderer, TArgs = Args> = StoryContext<
TRenderer,
TArgs
> & {
step: StepFunction<TRenderer, TArgs>;
mount: () => Promise<void>;
};

export type PlayFunction<TRenderer extends Renderer = Renderer, TArgs = Args> = (
context: PlayFunctionContext<TRenderer, TArgs>
) => Promise<void> | void;
Expand Down Expand Up @@ -326,7 +325,7 @@ export type DecoratorApplicator<TRenderer extends Renderer = Renderer, TArgs = A
export type StepRunner<TRenderer extends Renderer = Renderer, TArgs = Args> = (
label: StepLabel,
play: PlayFunction<TRenderer, TArgs>,
context: PlayFunctionContext<TRenderer, TArgs>
context: StoryContext<TRenderer, TArgs>
) => Promise<void>;

export type BaseAnnotations<TRenderer extends Renderer = Renderer, TArgs = Args> = {
Expand Down

0 comments on commit 89e16ed

Please sign in to comment.