@vertexvis/doc-viewer 1.0.2-canary.8 → 1.0.2-testing.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -625,22 +625,10 @@ function apiSupportsLayers(api) {
625
625
  class DocumentLayersController {
626
626
  constructor(api) {
627
627
  this.apiSupportsLayers = false;
628
- if (api != null) {
629
- this.setApi(api);
630
- }
631
- }
632
- setApi(api) {
633
628
  if (apiSupportsLayers(api)) {
634
629
  this.apiSupportsLayers = true;
635
630
  this.api = api;
636
631
  }
637
- else {
638
- this.clear();
639
- }
640
- }
641
- clear() {
642
- this.apiSupportsLayers = false;
643
- this.api = undefined;
644
632
  }
645
633
  /**
646
634
  * Returns a boolean indicating whether the document supports layers.
@@ -34675,7 +34663,6 @@ const VertexDocumentViewer = class {
34675
34663
  this.handleDocumentApiStateChanged = this.handleDocumentApiStateChanged.bind(this);
34676
34664
  this.handlePageLoaded = this.handlePageLoaded.bind(this);
34677
34665
  this.handlePageDrawn = this.handlePageDrawn.bind(this);
34678
- this.layers = new DocumentLayersController();
34679
34666
  this.resizeObserver = new ResizeObserver(this.handleElementResize);
34680
34667
  this.registerSlotChangeListeners();
34681
34668
  }
@@ -34688,7 +34675,7 @@ const VertexDocumentViewer = class {
34688
34675
  var _a;
34689
34676
  (_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.observe(this.hostEl);
34690
34677
  this.updateComponentDimensions();
34691
- this.loadInitialSrc();
34678
+ this.handleSrcChange();
34692
34679
  this.injectViewerApi();
34693
34680
  }
34694
34681
  disconnectedCallback() {
@@ -34755,13 +34742,12 @@ const VertexDocumentViewer = class {
34755
34742
  await documentApi.loadPage(pageNumber);
34756
34743
  }
34757
34744
  async handleSrcChange() {
34758
- var _a;
34759
34745
  if (this.src != null && this.canvasEl != null) {
34760
34746
  this.clearCurrentDocument();
34761
34747
  const { api, renderer } = this.provider.create(this.canvasEl, this.config);
34762
34748
  this.documentApi = api;
34763
34749
  this.documentRenderer = renderer;
34764
- (_a = this.layers) === null || _a === void 0 ? void 0 : _a.setApi(api);
34750
+ this.layers = new DocumentLayersController(api);
34765
34751
  this.updateInteractionHandler();
34766
34752
  this.updateDocumentApiListeners();
34767
34753
  await this.documentApi.updateViewport(this.dimensions);
@@ -34778,9 +34764,9 @@ const VertexDocumentViewer = class {
34778
34764
  this.updateInteractionHandler();
34779
34765
  }
34780
34766
  render() {
34781
- return (index.h(index.Host, { key: 'a990831d5f2328f2cf21be0b82d4018b05decd51' }, index.h("div", { key: '349abae36254da570e640417fab459680c576465', ref: ref => (this.viewerContainerElement = ref), class: "viewer-container", onContextMenu: event => event.preventDefault() }, index.h("div", { key: '6fca3f1d5a2c31bdcc0c8dbbd468e306db981740', ref: ref => (this.canvasContainerElement = ref), class: classNames('canvas-container', {
34767
+ return (index.h(index.Host, { key: 'f1ddf0b4e321bc244a5d757e48f6d71c23caca3c' }, index.h("div", { key: '174c64c537f4b0f1c45fc6543e5b7f54515e4063', ref: ref => (this.viewerContainerElement = ref), class: "viewer-container", onContextMenu: event => event.preventDefault() }, index.h("div", { key: '4c47dadba03b32bde017252a9a8ea7f6e6d323f3', ref: ref => (this.canvasContainerElement = ref), class: classNames('canvas-container', {
34782
34768
  'enable-pointer-events ': window.PointerEvent != null,
34783
- }) }, index.h("canvas", { key: 'deb1c58d8d20000053cd829401163bf1e68ca88e', id: "document-viewer-canvas", role: "presentation", ref: el => (this.canvasEl = el) })), index.h("slot", { key: '6b87846ef17b330b0fae5d03103765bad6fdafa6' }))));
34769
+ }) }, index.h("canvas", { key: 'ae645889dd5cb93084f820f9f3d14a56de0213f7', id: "document-viewer-canvas", role: "presentation", ref: el => (this.canvasEl = el) })), index.h("slot", { key: '7762c493306bf5d21cd16218f1abd3c6d0300ace' }))));
34784
34770
  }
34785
34771
  getDocumentApi() {
34786
34772
  if (this.documentApi == null) {
@@ -34788,25 +34774,15 @@ const VertexDocumentViewer = class {
34788
34774
  }
34789
34775
  return this.documentApi;
34790
34776
  }
34791
- async loadInitialSrc() {
34792
- await Promise.resolve();
34793
- await this.handleSrcChange();
34794
- }
34795
34777
  clearCurrentDocument() {
34796
- var _a, _b, _c, _d, _e, _f, _g;
34778
+ var _a, _b, _c, _d, _e, _f;
34797
34779
  (_a = this.documentRenderer) === null || _a === void 0 ? void 0 : _a.dispose();
34798
34780
  (_b = this.documentApi) === null || _b === void 0 ? void 0 : _b.dispose();
34799
34781
  (_c = this.panInteractionHandler) === null || _c === void 0 ? void 0 : _c.dispose();
34800
34782
  (_d = this.documentApiStateChangedDisposable) === null || _d === void 0 ? void 0 : _d.dispose();
34801
34783
  (_e = this.pageLoadedDisposable) === null || _e === void 0 ? void 0 : _e.dispose();
34802
34784
  (_f = this.pageDrawnDisposable) === null || _f === void 0 ? void 0 : _f.dispose();
34803
- this.documentRenderer = undefined;
34804
- this.documentApi = undefined;
34805
- this.panInteractionHandler = undefined;
34806
- this.documentApiStateChangedDisposable = undefined;
34807
- this.pageLoadedDisposable = undefined;
34808
- this.pageDrawnDisposable = undefined;
34809
- (_g = this.layers) === null || _g === void 0 ? void 0 : _g.clear();
34785
+ this.layers = undefined;
34810
34786
  }
34811
34787
  handleDocumentApiStateChanged(state) {
34812
34788
  this.documentState = state;
@@ -34,7 +34,6 @@ export class VertexDocumentViewer {
34
34
  this.handleDocumentApiStateChanged = this.handleDocumentApiStateChanged.bind(this);
35
35
  this.handlePageLoaded = this.handlePageLoaded.bind(this);
36
36
  this.handlePageDrawn = this.handlePageDrawn.bind(this);
37
- this.layers = new DocumentLayersController();
38
37
  this.resizeObserver = new ResizeObserver(this.handleElementResize);
39
38
  this.registerSlotChangeListeners();
40
39
  }
@@ -47,7 +46,7 @@ export class VertexDocumentViewer {
47
46
  var _a;
48
47
  (_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.observe(this.hostEl);
49
48
  this.updateComponentDimensions();
50
- this.loadInitialSrc();
49
+ this.handleSrcChange();
51
50
  this.injectViewerApi();
52
51
  }
53
52
  disconnectedCallback() {
@@ -114,13 +113,12 @@ export class VertexDocumentViewer {
114
113
  await documentApi.loadPage(pageNumber);
115
114
  }
116
115
  async handleSrcChange() {
117
- var _a;
118
116
  if (this.src != null && this.canvasEl != null) {
119
117
  this.clearCurrentDocument();
120
118
  const { api, renderer } = this.provider.create(this.canvasEl, this.config);
121
119
  this.documentApi = api;
122
120
  this.documentRenderer = renderer;
123
- (_a = this.layers) === null || _a === void 0 ? void 0 : _a.setApi(api);
121
+ this.layers = new DocumentLayersController(api);
124
122
  this.updateInteractionHandler();
125
123
  this.updateDocumentApiListeners();
126
124
  await this.documentApi.updateViewport(this.dimensions);
@@ -137,9 +135,9 @@ export class VertexDocumentViewer {
137
135
  this.updateInteractionHandler();
138
136
  }
139
137
  render() {
140
- return (h(Host, { key: 'a990831d5f2328f2cf21be0b82d4018b05decd51' }, h("div", { key: '349abae36254da570e640417fab459680c576465', ref: ref => (this.viewerContainerElement = ref), class: "viewer-container", onContextMenu: event => event.preventDefault() }, h("div", { key: '6fca3f1d5a2c31bdcc0c8dbbd468e306db981740', ref: ref => (this.canvasContainerElement = ref), class: classNames('canvas-container', {
138
+ return (h(Host, { key: 'f1ddf0b4e321bc244a5d757e48f6d71c23caca3c' }, h("div", { key: '174c64c537f4b0f1c45fc6543e5b7f54515e4063', ref: ref => (this.viewerContainerElement = ref), class: "viewer-container", onContextMenu: event => event.preventDefault() }, h("div", { key: '4c47dadba03b32bde017252a9a8ea7f6e6d323f3', ref: ref => (this.canvasContainerElement = ref), class: classNames('canvas-container', {
141
139
  'enable-pointer-events ': window.PointerEvent != null,
142
- }) }, h("canvas", { key: 'deb1c58d8d20000053cd829401163bf1e68ca88e', id: "document-viewer-canvas", role: "presentation", ref: el => (this.canvasEl = el) })), h("slot", { key: '6b87846ef17b330b0fae5d03103765bad6fdafa6' }))));
140
+ }) }, h("canvas", { key: 'ae645889dd5cb93084f820f9f3d14a56de0213f7', id: "document-viewer-canvas", role: "presentation", ref: el => (this.canvasEl = el) })), h("slot", { key: '7762c493306bf5d21cd16218f1abd3c6d0300ace' }))));
143
141
  }
144
142
  getDocumentApi() {
145
143
  if (this.documentApi == null) {
@@ -147,25 +145,15 @@ export class VertexDocumentViewer {
147
145
  }
148
146
  return this.documentApi;
149
147
  }
150
- async loadInitialSrc() {
151
- await Promise.resolve();
152
- await this.handleSrcChange();
153
- }
154
148
  clearCurrentDocument() {
155
- var _a, _b, _c, _d, _e, _f, _g;
149
+ var _a, _b, _c, _d, _e, _f;
156
150
  (_a = this.documentRenderer) === null || _a === void 0 ? void 0 : _a.dispose();
157
151
  (_b = this.documentApi) === null || _b === void 0 ? void 0 : _b.dispose();
158
152
  (_c = this.panInteractionHandler) === null || _c === void 0 ? void 0 : _c.dispose();
159
153
  (_d = this.documentApiStateChangedDisposable) === null || _d === void 0 ? void 0 : _d.dispose();
160
154
  (_e = this.pageLoadedDisposable) === null || _e === void 0 ? void 0 : _e.dispose();
161
155
  (_f = this.pageDrawnDisposable) === null || _f === void 0 ? void 0 : _f.dispose();
162
- this.documentRenderer = undefined;
163
- this.documentApi = undefined;
164
- this.panInteractionHandler = undefined;
165
- this.documentApiStateChangedDisposable = undefined;
166
- this.pageLoadedDisposable = undefined;
167
- this.pageDrawnDisposable = undefined;
168
- (_g = this.layers) === null || _g === void 0 ? void 0 : _g.clear();
156
+ this.layers = undefined;
169
157
  }
170
158
  handleDocumentApiStateChanged(state) {
171
159
  this.documentState = state;
@@ -5,22 +5,10 @@ import { apiSupportsLayers } from "./types";
5
5
  export class DocumentLayersController {
6
6
  constructor(api) {
7
7
  this.apiSupportsLayers = false;
8
- if (api != null) {
9
- this.setApi(api);
10
- }
11
- }
12
- setApi(api) {
13
8
  if (apiSupportsLayers(api)) {
14
9
  this.apiSupportsLayers = true;
15
10
  this.api = api;
16
11
  }
17
- else {
18
- this.clear();
19
- }
20
- }
21
- clear() {
22
- this.apiSupportsLayers = false;
23
- this.api = undefined;
24
12
  }
25
13
  /**
26
14
  * Returns a boolean indicating whether the document supports layers.