mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-01 05:05:25 +08:00
Typing for event payload
This commit is contained in:
parent
6386221718
commit
265129960f
@ -10,7 +10,16 @@ import {
|
||||
} from '@storybook/core-events';
|
||||
import global from 'global';
|
||||
|
||||
import { Call, CallRef, CallStates, ControlStates, LogItem, Options, State } from './types';
|
||||
import {
|
||||
Call,
|
||||
CallRef,
|
||||
CallStates,
|
||||
ControlStates,
|
||||
LogItem,
|
||||
Options,
|
||||
State,
|
||||
SyncPayload,
|
||||
} from './types';
|
||||
|
||||
export const EVENTS = {
|
||||
CALL: 'instrumenter/call',
|
||||
@ -251,7 +260,8 @@ export class Instrumenter {
|
||||
acc[storyId] = Object.assign(getInitialState(), retainedState);
|
||||
return acc;
|
||||
}, {} as Record<StoryId, State>);
|
||||
this.channel.emit(EVENTS.SYNC, { controlStates: controlsDisabled, logItems: [] });
|
||||
const payload: SyncPayload = { controlStates: controlsDisabled, logItems: [] };
|
||||
this.channel.emit(EVENTS.SYNC, payload);
|
||||
global.window.parent.__STORYBOOK_ADDON_INTERACTIONS_INSTRUMENTER_STATE__ = this.state;
|
||||
}
|
||||
|
||||
@ -558,7 +568,8 @@ export class Instrumenter {
|
||||
|
||||
const hasActive = logItems.some((item) => item.status === CallStates.ACTIVE);
|
||||
if (debuggerDisabled || isLocked || hasActive || logItems.length === 0) {
|
||||
this.channel.emit(EVENTS.SYNC, { controlStates: controlsDisabled, logItems });
|
||||
const payload: SyncPayload = { controlStates: controlsDisabled, logItems };
|
||||
this.channel.emit(EVENTS.SYNC, payload);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -574,7 +585,8 @@ export class Instrumenter {
|
||||
end: isPlaying,
|
||||
};
|
||||
|
||||
this.channel.emit(EVENTS.SYNC, { controlStates, logItems, pausedAt });
|
||||
const payload: SyncPayload = { controlStates, logItems, pausedAt };
|
||||
this.channel.emit(EVENTS.SYNC, payload);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,9 +55,10 @@ export interface LogItem {
|
||||
parentId?: Call['id'];
|
||||
}
|
||||
|
||||
export interface Payload {
|
||||
export interface SyncPayload {
|
||||
controlStates: ControlStates;
|
||||
logItems: LogItem[];
|
||||
pausedAt?: Call['id'];
|
||||
}
|
||||
|
||||
export interface State {
|
||||
|
Loading…
x
Reference in New Issue
Block a user