@file-viewer/assets-standard 3.0.2 → 3.0.3

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.
@@ -66846,15 +66846,21 @@ class WorkerMessageHandler {
66846
66846
  };
66847
66847
  return pdfManagerCapability.promise;
66848
66848
  }
66849
+ // File Viewer modification: canceled initialization must not reject detached
66850
+ // startup promises or send messages through an already destroyed handler.
66849
66851
  function setupDoc(data) {
66850
66852
  function onSuccess(doc) {
66851
- ensureNotTerminated();
66853
+ if (terminated) {
66854
+ return;
66855
+ }
66852
66856
  handler.send("GetDoc", {
66853
66857
  pdfInfo: doc
66854
66858
  });
66855
66859
  }
66856
66860
  function onFailure(ex) {
66857
- ensureNotTerminated();
66861
+ if (terminated) {
66862
+ return;
66863
+ }
66858
66864
  if (ex instanceof PasswordException) {
66859
66865
  const task = new WorkerTask(`PasswordException: response ${ex.code}`);
66860
66866
  startWorkerTask(task);
@@ -66862,43 +66868,67 @@ class WorkerMessageHandler {
66862
66868
  password
66863
66869
  }) {
66864
66870
  finishWorkerTask(task);
66871
+ if (terminated) {
66872
+ return;
66873
+ }
66865
66874
  pdfManager.updatePassword(password);
66866
66875
  pdfManagerReady();
66867
66876
  }).catch(function () {
66868
66877
  finishWorkerTask(task);
66878
+ if (terminated) {
66879
+ return;
66880
+ }
66869
66881
  handler.send("DocException", ex);
66870
66882
  });
66871
66883
  } else {
66872
66884
  handler.send("DocException", wrapReason(ex));
66873
66885
  }
66874
66886
  }
66875
- function pdfManagerReady() {
66876
- ensureNotTerminated();
66877
- loadDocument(false).then(onSuccess, function (reason) {
66878
- ensureNotTerminated();
66879
- if (!(reason instanceof XRefParseException)) {
66880
- onFailure(reason);
66881
- return;
66887
+ async function pdfManagerReady() {
66888
+ if (terminated) {
66889
+ return;
66890
+ }
66891
+ try {
66892
+ let doc;
66893
+ try {
66894
+ doc = await loadDocument(false);
66895
+ } catch (reason) {
66896
+ if (terminated) {
66897
+ return;
66898
+ }
66899
+ if (!(reason instanceof XRefParseException)) {
66900
+ throw reason;
66901
+ }
66902
+ await pdfManager.requestLoadedStream();
66903
+ if (terminated) {
66904
+ return;
66905
+ }
66906
+ doc = await loadDocument(true);
66882
66907
  }
66883
- pdfManager.requestLoadedStream().then(function () {
66884
- ensureNotTerminated();
66885
- loadDocument(true).then(onSuccess, onFailure);
66886
- });
66887
- });
66908
+ onSuccess(doc);
66909
+ } catch (reason) {
66910
+ onFailure(reason);
66911
+ }
66912
+ }
66913
+ if (terminated) {
66914
+ return;
66888
66915
  }
66889
- ensureNotTerminated();
66890
66916
  getPdfManager(data).then(function (newPdfManager) {
66891
66917
  if (terminated) {
66892
66918
  newPdfManager.terminate(new AbortException("Worker was terminated."));
66893
- throw new Error("Worker was terminated");
66919
+ return;
66894
66920
  }
66895
66921
  pdfManager = newPdfManager;
66896
66922
  pdfManager.requestLoadedStream(true).then(stream => {
66923
+ if (terminated) {
66924
+ return;
66925
+ }
66897
66926
  handler.send("DataLoaded", {
66898
66927
  length: stream.bytes.byteLength
66899
66928
  });
66900
- });
66901
- }).then(pdfManagerReady, onFailure);
66929
+ }, onFailure);
66930
+ return pdfManagerReady();
66931
+ }).catch(onFailure);
66902
66932
  }
66903
66933
  handler.on("GetPage", function (data) {
66904
66934
  return pdfManager.getPage(data.pageIndex).then(function (page) {