From e41d4ac5ecc1c2975c8985726e5a4a66c3bcd994 Mon Sep 17 00:00:00 2001 From: Edward Silverton Date: Mon, 13 Jan 2025 11:40:19 +0000 Subject: [PATCH] rename contentType and assignedContentHandler to remove leading underscore --- src/BaseContentHandler.ts | 4 +--- src/UniversalViewer.ts | 33 ++++++++++++++++++++------------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/BaseContentHandler.ts b/src/BaseContentHandler.ts index d0a1a14d0..91a7fc882 100644 --- a/src/BaseContentHandler.ts +++ b/src/BaseContentHandler.ts @@ -13,8 +13,7 @@ export type EventListener = { type EventListenerDictionaryItem = Pick; export default class BaseContentHandler - implements IContentHandler -{ + implements IContentHandler { protected _el: HTMLElement; private _eventListeners: { [key: string]: EventListenerDictionaryItem[]; @@ -27,7 +26,6 @@ export default class BaseContentHandler ) { // console.log("create YouTubeContentHandler"); this._el = this.options.target; - // this._assignedContentHandler.adapter = this.adapter; // set adapter // add event listeners if (eventListeners) { diff --git a/src/UniversalViewer.ts b/src/UniversalViewer.ts index 8b563eeb6..251d4c58f 100644 --- a/src/UniversalViewer.ts +++ b/src/UniversalViewer.ts @@ -30,17 +30,24 @@ const ContentHandler: IContentHandlerRegistry = { }; export class UniversalViewer extends BaseContentHandler> { - private _contentType: ContentType = ContentType.UNKNOWN; - private _assignedContentHandler: IContentHandler>; + public contentType: ContentType = ContentType.UNKNOWN; + public assignedContentHandler: IContentHandler>; + + // for backwards compat, remove in next major version + public _contentType = this.contentType; + public _assignedContentHandler; + private _externalEventListeners: EventListener[] = []; constructor(public options: IUVOptions) { super(options); this._assignContentHandler(this.options.data); + // for backwards compat, remove in next major version + this._assignedContentHandler = this.assignedContentHandler; } public get() { - return this._assignedContentHandler; + return this.assignedContentHandler; } public on(name: string, cb: Function, ctx?: any): void { @@ -63,22 +70,22 @@ export class UniversalViewer extends BaseContentHandler> { contentType = ContentType.IIIF; } else if (data[ContentType.YOUTUBE]) { contentType = ContentType.YOUTUBE; - } else if (this._contentType) { - contentType = this._contentType; + } else if (this.contentType) { + contentType = this.contentType; } else { contentType = ContentType.UNKNOWN; } - const handlerChanged: boolean = this._contentType !== contentType; + const handlerChanged: boolean = this.contentType !== contentType; if (contentType === ContentType.UNKNOWN) { console.error("Unknown content type"); } else if (handlerChanged) { - this._contentType = contentType; // set content type - this._assignedContentHandler?.dispose(); // dispose previous content handler + this.contentType = contentType; // set content type + this.assignedContentHandler?.dispose(); // dispose previous content handler const m = await ContentHandler[contentType](); // import content handler this.showSpinner(); // show spinner - this._assignedContentHandler = new m.default( + this.assignedContentHandler = new m.default( { target: this._el, data: data, @@ -100,20 +107,20 @@ export class UniversalViewer extends BaseContentHandler> { } else { // the handler didn't change, therefore handler's initial set didn't run // so we need to call set - this._assignedContentHandler.set(data, initial); + this.assignedContentHandler.set(data, initial); } }); } public exitFullScreen(): void { - this._assignedContentHandler?.exitFullScreen(); + this.assignedContentHandler?.exitFullScreen(); } public resize(): void { - this._assignedContentHandler?.resize(); + this.assignedContentHandler?.resize(); } public dispose(): void { - this._assignedContentHandler?.dispose(); + this.assignedContentHandler?.dispose(); } }