Commit e3e1f66c authored by Robert Knight's avatar Robert Knight

Move DocumentInfo type to types/annotator.ts

This type is for a message sent from the guest to the sidebar, so it
belongs with other shared types.
parent 066fc0c1
...@@ -29,6 +29,7 @@ import type { ...@@ -29,6 +29,7 @@ import type {
Anchor, Anchor,
ContentInfoConfig, ContentInfoConfig,
Destroyable, Destroyable,
DocumentInfo,
Integration, Integration,
SidebarLayout, SidebarLayout,
} from '../types/annotator'; } from '../types/annotator';
...@@ -333,7 +334,7 @@ export class Guest implements Annotator, Destroyable { ...@@ -333,7 +334,7 @@ export class Guest implements Annotator, Destroyable {
/** /**
* Retrieve metadata for the current document. * Retrieve metadata for the current document.
*/ */
async getDocumentInfo() { async getDocumentInfo(): Promise<DocumentInfo> {
const [uri, metadata, segmentInfo] = await Promise.all([ const [uri, metadata, segmentInfo] = await Promise.all([
this._integration.uri(), this._integration.uri(),
this._integration.getMetadata(), this._integration.getMetadata(),
......
...@@ -13,11 +13,7 @@ import { annotationMatchesSegment } from '../helpers/annotation-segment'; ...@@ -13,11 +13,7 @@ import { annotationMatchesSegment } from '../helpers/annotation-segment';
import { watch } from '../util/watch'; import { watch } from '../util/watch';
import type { Message } from '../../shared/messaging'; import type { Message } from '../../shared/messaging';
import type { import type { AnnotationData, DocumentInfo } from '../../types/annotator';
AnnotationData,
DocumentMetadata,
SegmentInfo,
} from '../../types/annotator';
import type { Annotation } from '../../types/api'; import type { Annotation } from '../../types/api';
import type { import type {
SidebarToHostEvent, SidebarToHostEvent,
...@@ -29,12 +25,6 @@ import type { SidebarStore } from '../store'; ...@@ -29,12 +25,6 @@ import type { SidebarStore } from '../store';
import type { Frame } from '../store/modules/frames'; import type { Frame } from '../store/modules/frames';
import type { AnnotationsService } from './annotations'; import type { AnnotationsService } from './annotations';
type DocumentInfo = {
uri: string;
metadata: DocumentMetadata;
segmentInfo?: SegmentInfo;
};
/** /**
* Return a minimal representation of an annotation that can be sent from the * Return a minimal representation of an annotation that can be sent from the
* sidebar app to a guest frame. * sidebar app to a guest frame.
......
...@@ -284,3 +284,25 @@ export type ContentInfoConfig = { ...@@ -284,3 +284,25 @@ export type ContentInfoConfig = {
container: ContentInfoItem; container: ContentInfoItem;
links: ContentInfoLinks; links: ContentInfoLinks;
}; };
/**
* Details about the document that is loaded in a guest frame.
*/
export type DocumentInfo = {
/**
* The main URI of the document. This is the primary URI that is associated with
* annotations created on the document.
*/
uri: string;
/** Additional URIs and other metadata about the document. */
metadata: DocumentMetadata;
/**
* Information about which segment (page, chapter etc.) of a multi-segment
* document is loaded in a guest frame.
*
* This is used in EPUBs for example.
*/
segmentInfo?: SegmentInfo;
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment