Skip to content

Commit

Permalink
Simplification of the types
Browse files Browse the repository at this point in the history
Instead of using an enum, I use an union.
  • Loading branch information
esanzgar committed Oct 12, 2021
1 parent f86dfbf commit 3e8cb2f
Showing 1 changed file with 31 additions and 35 deletions.
66 changes: 31 additions & 35 deletions src/types/bridge-events.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,145 +6,141 @@
/**
* Events that the sidebar sends to the host
*/
type SidebarToHostEvent = {
export type SidebarToHostEvent =
/**
* The sidebar is asking the host to open the sidebar.
*/
CLOSE_SIDEBAR: 'closeSidebar';
| 'closeSidebar'

/**
* The updated feature flags for the user
*/
FEATURE_FLAGS_UPDATED: 'featureFlagsUpdated';
| 'featureFlagsUpdated'

/**
* The sidebar is asking the host to open the partner site help page.
*/
HELP_REQUESTED: 'helpRequested';
| 'helpRequested'

/**
* The sidebar is asking the host to do a partner site log in
* (for example, pop up a log in window). This is used when the client is
* embedded in a partner site and a log in button in the client is clicked.
*/
LOGIN_REQUESTED: 'loginRequested';
| 'loginRequested'

/**
* The sidebar is asking the host to do a partner site log out.
* This is used when the client is embedded in a partner site and a log out
* button in the client is clicked.
*/
LOGOUT_REQUESTED: 'logoutRequested';
| 'logoutRequested'

/**
* The sidebar is asking the host to open the notebook.
*/
OPEN_NOTEBOOK: 'openNotebook';
| 'openNotebook'

/**
* The sidebar is asking the host to open the sidebar.
*/
OPEN_SIDEBAR: 'openSidebar';
| 'openSidebar'

/**
* The sidebar is asking the host to open the partner site profile page.
*/
PROFILE_REQUESTED: 'profileRequested';
| 'profileRequested'

/**
* The sidebar is updating the number of annotations in the partner site.
*/
PUBLIC_ANNOTATION_COUNT_CHANGED: 'publicAnnotationCountChanged';
| 'publicAnnotationCountChanged'

/**
* The sidebar is asking the host to do a partner site sign-up.
*/
SIGNUP_REQUESTED: 'signupRequested';
};
| 'signupRequested';

/**
* Events that the host sends to the sidebar
*/
type HostToSidebarEvent = {
type HostToSidebarEvent =
/**
* The host is asking the sidebar to delete a frame using an identifier
*/
DESTROY_FRAME: 'destroyFrame';
| 'destroyFrame'

/**
* The host informs the sidebar that the sidebar has been opened
*/
SIDEBAR_OPENED: 'sidebarOpened';
};
| 'sidebarOpened';

/**
* Events that the sidebar sends to the guest/s
*/
type SidebarToGuestEvent = {
export type SidebarToGuestEvent =
/**
* The sidebar is asking the guest/s to focus on certain annotations.
*/
FOCUS_ANNOTATIONS: 'focusAnnotations';
| 'focusAnnotations'

/**
* The sidebar is asking the guest/s to get the document metadata.
*/
GET_DOCUMENT_INFO: 'getDocumentInfo';
| 'getDocumentInfo'

/**
* The sidebar is asking the guest/s to load annotations.
*/
LOAD_ANNOTATIONS: 'loadAnnotations';
| 'loadAnnotations'

/**
* The sidebar is asking the guest/s to scroll to certain annotation.
*/
SCROLL_TO_ANNOTATION: 'scrollToAnnotation';
| 'scrollToAnnotation'

/**
* The sidebar is asking the guest/s to set the annotation highlights on/off.
*/
SET_VISIBLE_HIGHLIGHTS: 'setVisibleHighlights';
};
| 'setVisibleHighlights';

/**
* Events that the guest sends to the sidebar
*/
type GuestToSidebarEvent = {
export type GuestToSidebarEvent =
/**
* The guest is asking the sidebar to create an annotation
*/
BEFORE_CREATE_ANNOTATION: 'beforeCreateAnnotation';
| 'beforeCreateAnnotation'

/**
* The guest is asking the sidebar to delete an annotation
*/
DELETE_ANNOTATION: 'deleteAnnotation';
| 'deleteAnnotation'

/**
* The guest is asking the sidebar to open the sidebar.
*/
OPEN_SIDEBAR: 'openSidebar';
| 'openSidebar'

/**
* The guest is asking the sidebar to display some annotations
*/
SHOW_ANNOTATIONS: 'showAnnotations';
| 'showAnnotations'

/**
* The guest is asking the sidebar to sync the annotations
*/
SYNC: 'sync';
| 'sync'

/**
* The guest is asking the host to toggle some annotations
*/
TOGGLE_ANNOTATION_SELECTION: 'toggleAnnotationSelection';
};
| 'toggleAnnotationSelection';

export type BridgeEvent =
| 'connect'
| SidebarToHostEvent[keyof SidebarToHostEvent]
| HostToSidebarEvent[keyof HostToSidebarEvent]
| SidebarToGuestEvent[keyof SidebarToGuestEvent]
| GuestToSidebarEvent[keyof GuestToSidebarEvent];
| SidebarToHostEvent
| HostToSidebarEvent
| SidebarToGuestEvent
| GuestToSidebarEvent;

0 comments on commit 3e8cb2f

Please sign in to comment.