Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/files_pdfviewer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'js/pdfjs/web/viewer.js')
-rw-r--r--js/pdfjs/web/viewer.js6209
1 files changed, 4035 insertions, 2174 deletions
diff --git a/js/pdfjs/web/viewer.js b/js/pdfjs/web/viewer.js
index b5b3248..408fb7d 100644
--- a/js/pdfjs/web/viewer.js
+++ b/js/pdfjs/web/viewer.js
@@ -20,108 +20,42 @@
* Javascript code in this page
*/
-/******/ (function(modules) { // webpackBootstrap
-/******/ // The module cache
-/******/ var installedModules = {};
-/******/
-/******/ // The require function
-/******/ function __webpack_require__(moduleId) {
-/******/
-/******/ // Check if module is in cache
-/******/ if(installedModules[moduleId]) {
-/******/ return installedModules[moduleId].exports;
-/******/ }
-/******/ // Create a new module (and put it into the cache)
-/******/ var module = installedModules[moduleId] = {
-/******/ i: moduleId,
-/******/ l: false,
-/******/ exports: {}
-/******/ };
-/******/
-/******/ // Execute the module function
-/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
-/******/
-/******/ // Flag the module as loaded
-/******/ module.l = true;
-/******/
-/******/ // Return the exports of the module
-/******/ return module.exports;
-/******/ }
-/******/
-/******/
-/******/ // expose the modules object (__webpack_modules__)
-/******/ __webpack_require__.m = modules;
-/******/
-/******/ // expose the module cache
-/******/ __webpack_require__.c = installedModules;
-/******/
-/******/ // define getter function for harmony exports
-/******/ __webpack_require__.d = function(exports, name, getter) {
-/******/ if(!__webpack_require__.o(exports, name)) {
-/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
-/******/ }
-/******/ };
-/******/
-/******/ // define __esModule on exports
-/******/ __webpack_require__.r = function(exports) {
-/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
-/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
-/******/ }
-/******/ Object.defineProperty(exports, '__esModule', { value: true });
-/******/ };
-/******/
-/******/ // create a fake namespace object
-/******/ // mode & 1: value is a module id, require it
-/******/ // mode & 2: merge all properties of value into the ns
-/******/ // mode & 4: return value when already ns object
-/******/ // mode & 8|1: behave like require
-/******/ __webpack_require__.t = function(value, mode) {
-/******/ if(mode & 1) value = __webpack_require__(value);
-/******/ if(mode & 8) return value;
-/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
-/******/ var ns = Object.create(null);
-/******/ __webpack_require__.r(ns);
-/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
-/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
-/******/ return ns;
-/******/ };
-/******/
-/******/ // getDefaultExport function for compatibility with non-harmony modules
-/******/ __webpack_require__.n = function(module) {
-/******/ var getter = module && module.__esModule ?
-/******/ function getDefault() { return module['default']; } :
-/******/ function getModuleExports() { return module; };
-/******/ __webpack_require__.d(getter, 'a', getter);
-/******/ return getter;
-/******/ };
-/******/
-/******/ // Object.prototype.hasOwnProperty.call
-/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
-/******/
-/******/ // __webpack_public_path__
-/******/ __webpack_require__.p = "";
-/******/
-/******/
-/******/ // Load entry module and return exports
-/******/ return __webpack_require__(__webpack_require__.s = 0);
-/******/ })
-/************************************************************************/
-/******/ ([
+/******/ (() => { // webpackBootstrap
+/******/ "use strict";
+/******/ var __webpack_modules__ = ([
/* 0 */
-/***/ (function(module, exports, __webpack_require__) {
+/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
+
+
+
+Object.defineProperty(exports, "__esModule", ({
+ value: true
+}));
+Object.defineProperty(exports, "PDFViewerApplicationOptions", ({
+ enumerable: true,
+ get: function get() {
+ return _app_options.AppOptions;
+ }
+}));
+Object.defineProperty(exports, "PDFViewerApplication", ({
+ enumerable: true,
+ get: function get() {
+ return _app.PDFViewerApplication;
+ }
+}));
-"use strict";
+var _app_options = __webpack_require__(1);
+var _app = __webpack_require__(3);
+var pdfjsVersion = '2.7.570';
+var pdfjsBuild = 'f2c7338b0';
+window.PDFViewerApplication = _app.PDFViewerApplication;
+window.PDFViewerApplicationOptions = _app_options.AppOptions;
;
-var pdfjsWebApp, pdfjsWebAppOptions;
-{
- pdfjsWebApp = __webpack_require__(1);
- pdfjsWebAppOptions = __webpack_require__(6);
-}
;
{
- __webpack_require__(38);
+ __webpack_require__(37);
}
;
{
@@ -192,7 +126,9 @@ function getViewerConfiguration() {
thumbnailView: document.getElementById("thumbnailView"),
outlineView: document.getElementById("outlineView"),
attachmentsView: document.getElementById("attachmentsView"),
- layersView: document.getElementById("layersView")
+ layersView: document.getElementById("layersView"),
+ outlineOptionsContainer: document.getElementById("outlineOptionsContainer"),
+ currentOutlineItemButton: document.getElementById("currentOutlineItem")
},
sidebarResizer: {
outerContainer: document.getElementById("outerContainer"),
@@ -255,8 +191,6 @@ function getViewerConfiguration() {
function webViewerLoad() {
var config = getViewerConfiguration();
- window.PDFViewerApplication = pdfjsWebApp.PDFViewerApplication;
- window.PDFViewerApplicationOptions = pdfjsWebAppOptions.AppOptions;
var event = document.createEvent("CustomEvent");
event.initCustomEvent("webviewerloaded", true, true, {
source: window
@@ -269,7 +203,7 @@ function webViewerLoad() {
document.dispatchEvent(event);
}
- pdfjsWebApp.PDFViewerApplication.run(config);
+ _app.PDFViewerApplication.run(config);
}
if (document.readyState === "interactive" || document.readyState === "complete") {
@@ -280,82 +214,409 @@ if (document.readyState === "interactive" || document.readyState === "complete")
/***/ }),
/* 1 */
-/***/ (function(module, exports, __webpack_require__) {
+/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
-"use strict";
-Object.defineProperty(exports, "__esModule", {
+Object.defineProperty(exports, "__esModule", ({
value: true
-});
-exports.PDFPrintServiceFactory = exports.DefaultExternalServices = exports.PDFViewerApplication = void 0;
+}));
+exports.OptionKind = exports.AppOptions = void 0;
+
+var _viewer_compatibility = __webpack_require__(2);
+
+function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
+
+function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
+
+var OptionKind = {
+ VIEWER: 0x02,
+ API: 0x04,
+ WORKER: 0x08,
+ PREFERENCE: 0x80
+};
+exports.OptionKind = OptionKind;
+var defaultOptions = {
+ cursorToolOnLoad: {
+ value: 0,
+ kind: OptionKind.VIEWER + OptionKind.PREFERENCE
+ },
+ defaultUrl: {
+ value: "compressed.tracemonkey-pldi-09.pdf",
+ kind: OptionKind.VIEWER
+ },
+ defaultZoomValue: {
+ value: "",
+ kind: OptionKind.VIEWER + OptionKind.PREFERENCE
+ },
+ disableHistory: {
+ value: false,
+ kind: OptionKind.VIEWER
+ },
+ disablePageLabels: {
+ value: false,
+ kind: OptionKind.VIEWER + OptionKind.PREFERENCE
+ },
+ enablePermissions: {
+ value: false,
+ kind: OptionKind.VIEWER + OptionKind.PREFERENCE
+ },
+ enablePrintAutoRotate: {
+ value: false,
+ kind: OptionKind.VIEWER + OptionKind.PREFERENCE
+ },
+ enableScripting: {
+ value: false,
+ kind: OptionKind.VIEWER + OptionKind.PREFERENCE
+ },
+ enableWebGL: {
+ value: false,
+ kind: OptionKind.VIEWER + OptionKind.PREFERENCE
+ },
+ externalLinkRel: {
+ value: "noopener noreferrer nofollow",
+ kind: OptionKind.VIEWER
+ },
+ externalLinkTarget: {
+ value: 0,
+ kind: OptionKind.VIEWER + OptionKind.PREFERENCE
+ },
+ historyUpdateUrl: {
+ value: false,
+ kind: OptionKind.VIEWER + OptionKind.PREFERENCE
+ },
+ ignoreDestinationZoom: {
+ value: false,
+ kind: OptionKind.VIEWER + OptionKind.PREFERENCE
+ },
+ imageResourcesPath: {
+ value: "./images/",
+ kind: OptionKind.VIEWER
+ },
+ maxCanvasPixels: {
+ value: 16777216,
+ compatibility: _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels,
+ kind: OptionKind.VIEWER
+ },
+ pdfBugEnabled: {
+ value: false,
+ kind: OptionKind.VIEWER + OptionKind.PREFERENCE
+ },
+ printResolution: {
+ value: 150,
+ kind: OptionKind.VIEWER
+ },
+ renderer: {
+ value: "canvas",
+ kind: OptionKind.VIEWER + OptionKind.PREFERENCE
+ },
+ renderInteractiveForms: {
+ value: true,
+ kind: OptionKind.VIEWER + OptionKind.PREFERENCE
+ },
+ sidebarViewOnLoad: {
+ value: -1,
+ kind: OptionKind.VIEWER + OptionKind.PREFERENCE
+ },
+ scrollModeOnLoad: {
+ value: -1,
+ kind: OptionKind.VIEWER + OptionKind.PREFERENCE
+ },
+ spreadModeOnLoad: {
+ value: -1,
+ kind: OptionKind.VIEWER + OptionKind.PREFERENCE
+ },
+ textLayerMode: {
+ value: 1,
+ kind: OptionKind.VIEWER + OptionKind.PREFERENCE
+ },
+ useOnlyCssZoom: {
+ value: false,
+ kind: OptionKind.VIEWER + OptionKind.PREFERENCE
+ },
+ viewerCssTheme: {
+ value: 0,
+ kind: OptionKind.VIEWER + OptionKind.PREFERENCE
+ },
+ viewOnLoad: {
+ value: 0,
+ kind: OptionKind.VIEWER + OptionKind.PREFERENCE
+ },
+ cMapPacked: {
+ value: true,
+ kind: OptionKind.API
+ },
+ cMapUrl: {
+ value: "../web/cmaps/",
+ kind: OptionKind.API
+ },
+ disableAutoFetch: {
+ value: false,
+ kind: OptionKind.API + OptionKind.PREFERENCE
+ },
+ disableFontFace: {
+ value: false,
+ kind: OptionKind.API + OptionKind.PREFERENCE
+ },
+ disableRange: {
+ value: false,
+ kind: OptionKind.API + OptionKind.PREFERENCE
+ },
+ disableStream: {
+ value: false,
+ kind: OptionKind.API + OptionKind.PREFERENCE
+ },
+ docBaseUrl: {
+ value: "",
+ kind: OptionKind.API
+ },
+ fontExtraProperties: {
+ value: false,
+ kind: OptionKind.API
+ },
+ isEvalSupported: {
+ value: true,
+ kind: OptionKind.API
+ },
+ maxImageSize: {
+ value: -1,
+ kind: OptionKind.API
+ },
+ pdfBug: {
+ value: false,
+ kind: OptionKind.API
+ },
+ verbosity: {
+ value: 1,
+ kind: OptionKind.API
+ },
+ workerPort: {
+ value: null,
+ kind: OptionKind.WORKER
+ },
+ workerSrc: {
+ value: "../build/pdf.worker.js",
+ kind: OptionKind.WORKER
+ }
+};
+{
+ defaultOptions.disablePreferences = {
+ value: false,
+ kind: OptionKind.VIEWER
+ };
+ defaultOptions.locale = {
+ value: typeof navigator !== "undefined" ? navigator.language : "en-US",
+ kind: OptionKind.VIEWER
+ };
+ defaultOptions.sandboxBundleSrc = {
+ value: "../build/pdf.sandbox.js",
+ kind: OptionKind.VIEWER
+ };
+}
+var userOptions = Object.create(null);
-var _regenerator = _interopRequireDefault(__webpack_require__(2));
+var AppOptions = /*#__PURE__*/function () {
+ function AppOptions() {
+ _classCallCheck(this, AppOptions);
-var _ui_utils = __webpack_require__(5);
+ throw new Error("Cannot initialize AppOptions.");
+ }
-var _app_options = __webpack_require__(6);
+ _createClass(AppOptions, null, [{
+ key: "get",
+ value: function get(name) {
+ var userOption = userOptions[name];
-var _pdfjsLib = __webpack_require__(8);
+ if (userOption !== undefined) {
+ return userOption;
+ }
-var _pdf_cursor_tools = __webpack_require__(9);
+ var defaultOption = defaultOptions[name];
-var _pdf_rendering_queue = __webpack_require__(11);
+ if (defaultOption !== undefined) {
+ return defaultOption.compatibility || defaultOption.value;
+ }
-var _pdf_sidebar = __webpack_require__(12);
+ return undefined;
+ }
+ }, {
+ key: "getAll",
+ value: function getAll() {
+ var kind = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
+ var options = Object.create(null);
-var _overlay_manager = __webpack_require__(13);
+ for (var name in defaultOptions) {
+ var defaultOption = defaultOptions[name];
-var _password_prompt = __webpack_require__(14);
+ if (kind) {
+ if ((kind & defaultOption.kind) === 0) {
+ continue;
+ }
-var _pdf_attachment_viewer = __webpack_require__(15);
+ if (kind === OptionKind.PREFERENCE) {
+ var value = defaultOption.value,
+ valueType = _typeof(value);
-var _pdf_document_properties = __webpack_require__(17);
+ if (valueType === "boolean" || valueType === "string" || valueType === "number" && Number.isInteger(value)) {
+ options[name] = value;
+ continue;
+ }
-var _pdf_find_bar = __webpack_require__(18);
+ throw new Error("Invalid type for preference: ".concat(name));
+ }
+ }
-var _pdf_find_controller = __webpack_require__(19);
+ var userOption = userOptions[name];
+ options[name] = userOption !== undefined ? userOption : defaultOption.compatibility || defaultOption.value;
+ }
-var _pdf_history = __webpack_require__(21);
+ return options;
+ }
+ }, {
+ key: "set",
+ value: function set(name, value) {
+ userOptions[name] = value;
+ }
+ }, {
+ key: "setAll",
+ value: function setAll(options) {
+ for (var name in options) {
+ userOptions[name] = options[name];
+ }
+ }
+ }, {
+ key: "remove",
+ value: function remove(name) {
+ delete userOptions[name];
+ }
+ }]);
-var _pdf_layer_viewer = __webpack_require__(22);
+ return AppOptions;
+}();
-var _pdf_link_service = __webpack_require__(23);
+exports.AppOptions = AppOptions;
-var _pdf_outline_viewer = __webpack_require__(24);
+/***/ }),
+/* 2 */
+/***/ ((__unused_webpack_module, exports) => {
-var _pdf_presentation_mode = __webpack_require__(25);
-var _pdf_sidebar_resizer = __webpack_require__(26);
-var _pdf_thumbnail_viewer = __webpack_require__(27);
+Object.defineProperty(exports, "__esModule", ({
+ value: true
+}));
+exports.viewerCompatibilityParams = void 0;
+var compatibilityParams = Object.create(null);
+{
+ var userAgent = typeof navigator !== "undefined" && navigator.userAgent || "";
+ var platform = typeof navigator !== "undefined" && navigator.platform || "";
+ var maxTouchPoints = typeof navigator !== "undefined" && navigator.maxTouchPoints || 1;
+ var isAndroid = /Android/.test(userAgent);
+ var isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent) || platform === "MacIntel" && maxTouchPoints > 1;
+ var isIOSChrome = /CriOS/.test(userAgent);
-var _pdf_viewer = __webpack_require__(29);
+ (function checkOnBlobSupport() {
+ if (isIOSChrome) {
+ compatibilityParams.disableCreateObjectURL = true;
+ }
+ })();
+
+ (function checkCanvasSizeLimitation() {
+ if (isIOS || isAndroid) {
+ compatibilityParams.maxCanvasPixels = 5242880;
+ }
+ })();
+}
+var viewerCompatibilityParams = Object.freeze(compatibilityParams);
+exports.viewerCompatibilityParams = viewerCompatibilityParams;
+
+/***/ }),
+/* 3 */
+/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
+
+
+
+Object.defineProperty(exports, "__esModule", ({
+ value: true
+}));
+exports.PDFViewerApplication = exports.PDFPrintServiceFactory = exports.DefaultExternalServices = void 0;
+
+var _regenerator = _interopRequireDefault(__webpack_require__(4));
+
+var _ui_utils = __webpack_require__(6);
+
+var _app_options = __webpack_require__(1);
+
+var _pdfjsLib = __webpack_require__(7);
-var _secondary_toolbar = __webpack_require__(34);
+var _pdf_cursor_tools = __webpack_require__(8);
-var _toolbar = __webpack_require__(36);
+var _pdf_rendering_queue = __webpack_require__(10);
-var _viewer_compatibility = __webpack_require__(7);
+var _overlay_manager = __webpack_require__(11);
-var _view_history = __webpack_require__(37);
+var _password_prompt = __webpack_require__(12);
+
+var _pdf_attachment_viewer = __webpack_require__(13);
+
+var _pdf_document_properties = __webpack_require__(15);
+
+var _pdf_find_bar = __webpack_require__(16);
+
+var _pdf_find_controller = __webpack_require__(17);
+
+var _pdf_history = __webpack_require__(19);
+
+var _pdf_layer_viewer = __webpack_require__(20);
+
+var _pdf_link_service = __webpack_require__(21);
+
+var _pdf_outline_viewer = __webpack_require__(22);
+
+var _pdf_presentation_mode = __webpack_require__(23);
+
+var _pdf_sidebar = __webpack_require__(24);
+
+var _pdf_sidebar_resizer = __webpack_require__(25);
+
+var _pdf_thumbnail_viewer = __webpack_require__(26);
+
+var _pdf_viewer = __webpack_require__(28);
+
+var _secondary_toolbar = __webpack_require__(33);
+
+var _toolbar = __webpack_require__(35);
+
+var _viewer_compatibility = __webpack_require__(2);
+
+var _view_history = __webpack_require__(36);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
-function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
+function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
-function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
+function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
-function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
+function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
-function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
+function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
-function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
+function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
+function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
+
+function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
+
+function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
@@ -376,6 +637,11 @@ var ViewOnLoad = {
PREVIOUS: 0,
INITIAL: 1
};
+var ViewerCssTheme = {
+ AUTOMATIC: 0,
+ LIGHT: 1,
+ DARK: 2
+};
var KNOWN_VERSIONS = ["1.0", "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9", "2.0", "2.1", "2.2", "2.3"];
var KNOWN_GENERATORS = ["acrobat distiller", "acrobat pdfwriter", "adobe livecycle", "adobe pdf library", "adobe photoshop", "ghostscript", "tcpdf", "cairo", "dvipdfm", "dvips", "pdftex", "pdfkit", "itext", "prince", "quarkxpress", "mac os x", "microsoft", "openoffice", "oracle", "luradocument", "pdf-xchange", "antenna house", "aspose.cells", "fpdf"];
@@ -397,7 +663,25 @@ var DefaultExternalServices = /*#__PURE__*/function () {
value: function initPassiveLoading(callbacks) {}
}, {
key: "fallback",
- value: function fallback(data, callback) {}
+ value: function () {
+ var _fallback = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(data) {
+ return _regenerator["default"].wrap(function _callee$(_context) {
+ while (1) {
+ switch (_context.prev = _context.next) {
+ case 0:
+ case "end":
+ return _context.stop();
+ }
+ }
+ }, _callee);
+ }));
+
+ function fallback(_x) {
+ return _fallback.apply(this, arguments);
+ }
+
+ return fallback;
+ }()
}, {
key: "reportTelemetry",
value: function reportTelemetry(data) {}
@@ -417,6 +701,11 @@ var DefaultExternalServices = /*#__PURE__*/function () {
throw new Error("Not implemented: createL10n");
}
}, {
+ key: "createScripting",
+ value: function createScripting(options) {
+ throw new Error("Not implemented: createScripting");
+ }
+ }, {
key: "supportsIntegratedFind",
get: function get() {
return (0, _pdfjsLib.shadow)(this, "supportsIntegratedFind", false);
@@ -480,42 +769,50 @@ var PDFViewerApplication = {
url: "",
baseUrl: "",
externalServices: DefaultExternalServices,
- _boundEvents: {},
- contentDispositionFilename: null,
+ _boundEvents: Object.create(null),
+ documentInfo: null,
+ metadata: null,
+ _contentDispositionFilename: null,
+ _contentLength: null,
triggerDelayedFallback: null,
_saveInProgress: false,
_wheelUnusedTicks: 0,
+ _idleCallbacks: new Set(),
+ _scriptingInstance: null,
+ _mouseState: Object.create(null),
initialize: function initialize(appConfig) {
var _this = this;
- return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
+ return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
var appContainer;
- return _regenerator["default"].wrap(function _callee$(_context) {
+ return _regenerator["default"].wrap(function _callee2$(_context2) {
while (1) {
- switch (_context.prev = _context.next) {
+ switch (_context2.prev = _context2.next) {
case 0:
_this.preferences = _this.externalServices.createPreferences();
_this.appConfig = appConfig;
- _context.next = 4;
+ _context2.next = 4;
return _this._readPreferences();
case 4:
- _context.next = 6;
+ _context2.next = 6;
return _this._parseHashParameters();
case 6:
- _context.next = 8;
+ _this._forceCssTheme();
+
+ _context2.next = 9;
return _this._initializeL10n();
- case 8:
+ case 9:
if (_this.isViewerEmbedded && _app_options.AppOptions.get("externalLinkTarget") === _pdfjsLib.LinkTarget.NONE) {
_app_options.AppOptions.set("externalLinkTarget", _pdfjsLib.LinkTarget.TOP);
}
- _context.next = 11;
+ _context2.next = 12;
return _this._initializeViewerComponents();
- case 11:
+ case 12:
_this.bindEvents();
_this.bindWindowEvents();
@@ -530,83 +827,81 @@ var PDFViewerApplication = {
_this._initializedCapability.resolve();
- case 16:
+ case 17:
case "end":
- return _context.stop();
+ return _context2.stop();
}
}
- }, _callee);
+ }, _callee2);
}))();
},
_readPreferences: function _readPreferences() {
var _this2 = this;
- return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
- var prefs, name;
- return _regenerator["default"].wrap(function _callee2$(_context2) {
+ return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
+ return _regenerator["default"].wrap(function _callee3$(_context3) {
while (1) {
- switch (_context2.prev = _context2.next) {
+ switch (_context3.prev = _context3.next) {
case 0:
if (!_app_options.AppOptions.get("disablePreferences")) {
- _context2.next = 2;
+ _context3.next = 2;
break;
}
- return _context2.abrupt("return");
+ return _context3.abrupt("return");
case 2:
- _context2.prev = 2;
- _context2.next = 5;
+ _context3.prev = 2;
+ _context3.t0 = _app_options.AppOptions;
+ _context3.next = 6;
return _this2.preferences.getAll();
- case 5:
- prefs = _context2.sent;
+ case 6:
+ _context3.t1 = _context3.sent;
- for (name in prefs) {
- _app_options.AppOptions.set(name, prefs[name]);
- }
+ _context3.t0.setAll.call(_context3.t0, _context3.t1);
- _context2.next = 12;
+ _context3.next = 13;
break;
- case 9:
- _context2.prev = 9;
- _context2.t0 = _context2["catch"](2);
- console.error("_readPreferences: \"".concat(_context2.t0.message, "\"."));
+ case 10:
+ _context3.prev = 10;
+ _context3.t2 = _context3["catch"](2);
+ console.error("_readPreferences: \"".concat(_context3.t2 === null || _context3.t2 === void 0 ? void 0 : _context3.t2.message, "\"."));
- case 12:
+ case 13:
case "end":
- return _context2.stop();
+ return _context3.stop();
}
}
- }, _callee2, null, [[2, 9]]);
+ }, _callee3, null, [[2, 10]]);
}))();
},
_parseHashParameters: function _parseHashParameters() {
var _this3 = this;
- return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
+ return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
var hash, hashParams, waitOn, viewer, enabled;
- return _regenerator["default"].wrap(function _callee3$(_context3) {
+ return _regenerator["default"].wrap(function _callee4$(_context4) {
while (1) {
- switch (_context3.prev = _context3.next) {
+ switch (_context4.prev = _context4.next) {
case 0:
if (_app_options.AppOptions.get("pdfBugEnabled")) {
- _context3.next = 2;
+ _context4.next = 2;
break;
}
- return _context3.abrupt("return", undefined);
+ return _context4.abrupt("return", undefined);
case 2:
hash = document.location.hash.substring(1);
if (hash) {
- _context3.next = 5;
+ _context4.next = 5;
break;
}
- return _context3.abrupt("return", undefined);
+ return _context4.abrupt("return", undefined);
case 5:
hashParams = (0, _ui_utils.parseQueryString)(hash), waitOn = [];
@@ -644,23 +939,23 @@ var PDFViewerApplication = {
}
if (!("textlayer" in hashParams)) {
- _context3.next = 23;
+ _context4.next = 23;
break;
}
- _context3.t0 = hashParams.textlayer;
- _context3.next = _context3.t0 === "off" ? 18 : _context3.t0 === "visible" ? 20 : _context3.t0 === "shadow" ? 20 : _context3.t0 === "hover" ? 20 : 23;
+ _context4.t0 = hashParams.textlayer;
+ _context4.next = _context4.t0 === "off" ? 18 : _context4.t0 === "visible" ? 20 : _context4.t0 === "shadow" ? 20 : _context4.t0 === "hover" ? 20 : 23;
break;
case 18:
_app_options.AppOptions.set("textLayerMode", _ui_utils.TextLayerMode.DISABLE);
- return _context3.abrupt("break", 23);
+ return _context4.abrupt("break", 23);
case 20:
viewer = _this3.appConfig.viewerContainer;
viewer.classList.add("textLayer-" + hashParams.textlayer);
- return _context3.abrupt("break", 23);
+ return _context4.abrupt("break", 23);
case 23:
if ("pdfbug" in hashParams) {
@@ -676,53 +971,97 @@ var PDFViewerApplication = {
_app_options.AppOptions.set("locale", hashParams.locale);
}
- return _context3.abrupt("return", Promise.all(waitOn)["catch"](function (reason) {
+ if (!(waitOn.length === 0)) {
+ _context4.next = 27;
+ break;
+ }
+
+ return _context4.abrupt("return", undefined);
+
+ case 27:
+ return _context4.abrupt("return", Promise.all(waitOn)["catch"](function (reason) {
console.error("_parseHashParameters: \"".concat(reason.message, "\"."));
}));
- case 26:
+ case 28:
case "end":
- return _context3.stop();
+ return _context4.stop();
}
}
- }, _callee3);
+ }, _callee4);
}))();
},
_initializeL10n: function _initializeL10n() {
var _this4 = this;
- return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
+ return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee5() {
var dir;
- return _regenerator["default"].wrap(function _callee4$(_context4) {
+ return _regenerator["default"].wrap(function _callee5$(_context5) {
while (1) {
- switch (_context4.prev = _context4.next) {
+ switch (_context5.prev = _context5.next) {
case 0:
_this4.l10n = _this4.externalServices.createL10n({
locale: _app_options.AppOptions.get("locale")
});
- _context4.next = 3;
+ _context5.next = 3;
return _this4.l10n.getDirection();
case 3:
- dir = _context4.sent;
+ dir = _context5.sent;
document.getElementsByTagName("html")[0].dir = dir;
case 5:
case "end":
- return _context4.stop();
+ return _context5.stop();
}
}
- }, _callee4);
+ }, _callee5);
}))();
},
+ _forceCssTheme: function _forceCssTheme() {
+ var cssTheme = _app_options.AppOptions.get("viewerCssTheme");
+
+ if (cssTheme === ViewerCssTheme.AUTOMATIC || !Object.values(ViewerCssTheme).includes(cssTheme)) {
+ return;
+ }
+
+ try {
+ var styleSheet = document.styleSheets[0];
+ var cssRules = (styleSheet === null || styleSheet === void 0 ? void 0 : styleSheet.cssRules) || [];
+
+ for (var i = 0, ii = cssRules.length; i < ii; i++) {
+ var _rule$media;
+
+ var rule = cssRules[i];
+
+ if (rule instanceof CSSMediaRule && ((_rule$media = rule.media) === null || _rule$media === void 0 ? void 0 : _rule$media[0]) === "(prefers-color-scheme: dark)") {
+ if (cssTheme === ViewerCssTheme.LIGHT) {
+ styleSheet.deleteRule(i);
+ return;
+ }
+
+ var darkRules = /^@media \(prefers-color-scheme: dark\) {\n\s*([\w\s-.,:;/\\{}()]+)\n}$/.exec(rule.cssText);
+
+ if (darkRules !== null && darkRules !== void 0 && darkRules[1]) {
+ styleSheet.deleteRule(i);
+ styleSheet.insertRule(darkRules[1], i);
+ }
+
+ return;
+ }
+ }
+ } catch (reason) {
+ console.error("_forceCssTheme: \"".concat(reason === null || reason === void 0 ? void 0 : reason.message, "\"."));
+ }
+ },
_initializeViewerComponents: function _initializeViewerComponents() {
var _this5 = this;
- return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee5() {
+ return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee6() {
var appConfig, eventBus, pdfRenderingQueue, pdfLinkService, downloadManager, findController, container, viewer;
- return _regenerator["default"].wrap(function _callee5$(_context5) {
+ return _regenerator["default"].wrap(function _callee6$(_context6) {
while (1) {
- switch (_context5.prev = _context5.next) {
+ switch (_context6.prev = _context6.next) {
case 0:
appConfig = _this5.appConfig;
eventBus = appConfig.eventBus || new _ui_utils.EventBus({
@@ -765,7 +1104,9 @@ var PDFViewerApplication = {
renderInteractiveForms: _app_options.AppOptions.get("renderInteractiveForms"),
enablePrintAutoRotate: _app_options.AppOptions.get("enablePrintAutoRotate"),
useOnlyCssZoom: _app_options.AppOptions.get("useOnlyCssZoom"),
- maxCanvasPixels: _app_options.AppOptions.get("maxCanvasPixels")
+ maxCanvasPixels: _app_options.AppOptions.get("maxCanvasPixels"),
+ enableScripting: _app_options.AppOptions.get("enableScripting"),
+ mouseState: _this5._mouseState
});
pdfRenderingQueue.setViewer(_this5.pdfViewer);
pdfLinkService.setViewer(_this5.pdfViewer);
@@ -833,10 +1174,10 @@ var PDFViewerApplication = {
case 35:
case "end":
- return _context5.stop();
+ return _context6.stop();
}
}
- }, _callee5);
+ }, _callee6);
}))();
},
run: function run(config) {
@@ -901,10 +1242,6 @@ var PDFViewerApplication = {
this.pdfViewer.currentPageNumber = val;
},
- get printing() {
- return !!this.printService;
- },
-
get supportsPrinting() {
return PDFPrintServiceFactory.instance.supportsPrinting;
},
@@ -912,9 +1249,9 @@ var PDFViewerApplication = {
get supportsFullscreen() {
var support;
var doc = document.documentElement;
- support = !!(doc.requestFullscreen || doc.mozRequestFullScreen || doc.webkitRequestFullScreen || doc.msRequestFullscreen);
+ support = !!(doc.requestFullscreen || doc.mozRequestFullScreen || doc.webkitRequestFullScreen);
- if (document.fullscreenEnabled === false || document.mozFullScreenEnabled === false || document.webkitFullscreenEnabled === false || document.msFullscreenEnabled === false) {
+ if (document.fullscreenEnabled === false || document.mozFullScreenEnabled === false || document.webkitFullscreenEnabled === false) {
support = false;
}
@@ -964,102 +1301,212 @@ var PDFViewerApplication = {
document.title = title;
},
- close: function close() {
+
+ get _docFilename() {
+ return this._contentDispositionFilename || (0, _ui_utils.getPDFFileNameFromURL)(this.url);
+ },
+
+ _cancelIdleCallbacks: function _cancelIdleCallbacks() {
+ if (!this._idleCallbacks.size) {
+ return;
+ }
+
+ var _iterator = _createForOfIteratorHelper(this._idleCallbacks),
+ _step;
+
+ try {
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
+ var callback = _step.value;
+ window.cancelIdleCallback(callback);
+ }
+ } catch (err) {
+ _iterator.e(err);
+ } finally {
+ _iterator.f();
+ }
+
+ this._idleCallbacks.clear();
+ },
+ _destroyScriptingInstance: function _destroyScriptingInstance() {
var _this6 = this;
- return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee6() {
- var errorWrapper, promise;
- return _regenerator["default"].wrap(function _callee6$(_context6) {
+ return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee7() {
+ var _this6$_scriptingInst, scripting, internalEvents, domEvents, _iterator2, _step2, _step2$value, name, listener, _iterator3, _step3, _step3$value, _name, _listener;
+
+ return _regenerator["default"].wrap(function _callee7$(_context7) {
while (1) {
- switch (_context6.prev = _context6.next) {
+ switch (_context7.prev = _context7.next) {
case 0:
- errorWrapper = _this6.appConfig.errorWrapper.container;
+ if (_this6._scriptingInstance) {
+ _context7.next = 2;
+ break;
+ }
+
+ return _context7.abrupt("return");
+
+ case 2:
+ _this6$_scriptingInst = _this6._scriptingInstance, scripting = _this6$_scriptingInst.scripting, internalEvents = _this6$_scriptingInst.internalEvents, domEvents = _this6$_scriptingInst.domEvents;
+ _context7.prev = 3;
+ _context7.next = 6;
+ return scripting.destroySandbox();
+
+ case 6:
+ _context7.next = 10;
+ break;
+
+ case 8:
+ _context7.prev = 8;
+ _context7.t0 = _context7["catch"](3);
+
+ case 10:
+ _iterator2 = _createForOfIteratorHelper(internalEvents);
+
+ try {
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
+ _step2$value = _slicedToArray(_step2.value, 2), name = _step2$value[0], listener = _step2$value[1];
+
+ _this6.eventBus._off(name, listener);
+ }
+ } catch (err) {
+ _iterator2.e(err);
+ } finally {
+ _iterator2.f();
+ }
+
+ internalEvents.clear();
+ _iterator3 = _createForOfIteratorHelper(domEvents);
+
+ try {
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
+ _step3$value = _slicedToArray(_step3.value, 2), _name = _step3$value[0], _listener = _step3$value[1];
+ window.removeEventListener(_name, _listener);
+ }
+ } catch (err) {
+ _iterator3.e(err);
+ } finally {
+ _iterator3.f();
+ }
+
+ domEvents.clear();
+ delete _this6._mouseState.isDown;
+ _this6._scriptingInstance = null;
+
+ case 18:
+ case "end":
+ return _context7.stop();
+ }
+ }
+ }, _callee7, null, [[3, 8]]);
+ }))();
+ },
+ close: function close() {
+ var _this7 = this;
+
+ return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee8() {
+ var errorWrapper, promises;
+ return _regenerator["default"].wrap(function _callee8$(_context8) {
+ while (1) {
+ switch (_context8.prev = _context8.next) {
+ case 0:
+ errorWrapper = _this7.appConfig.errorWrapper.container;
errorWrapper.setAttribute("hidden", "true");
- if (_this6.pdfLoadingTask) {
- _context6.next = 4;
+ if (_this7.pdfLoadingTask) {
+ _context8.next = 4;
break;
}
- return _context6.abrupt("return", undefined);
+ return _context8.abrupt("return", undefined);
case 4:
- promise = _this6.pdfLoadingTask.destroy();
- _this6.pdfLoadingTask = null;
+ promises = [];
+ promises.push(_this7.pdfLoadingTask.destroy());
+ _this7.pdfLoadingTask = null;
- if (_this6.pdfDocument) {
- _this6.pdfDocument = null;
+ if (_this7.pdfDocument) {
+ _this7.pdfDocument = null;
- _this6.pdfThumbnailViewer.setDocument(null);
+ _this7.pdfThumbnailViewer.setDocument(null);
- _this6.pdfViewer.setDocument(null);
+ _this7.pdfViewer.setDocument(null);
- _this6.pdfLinkService.setDocument(null);
+ _this7.pdfLinkService.setDocument(null);
- _this6.pdfDocumentProperties.setDocument(null);
+ _this7.pdfDocumentProperties.setDocument(null);
}
webViewerResetPermissions();
- _this6.store = null;
- _this6.isInitialViewSet = false;
- _this6.downloadComplete = false;
- _this6.url = "";
- _this6.baseUrl = "";
- _this6.contentDispositionFilename = null;
- _this6.triggerDelayedFallback = null;
- _this6._saveInProgress = false;
+ _this7.store = null;
+ _this7.isInitialViewSet = false;
+ _this7.downloadComplete = false;
+ _this7.url = "";
+ _this7.baseUrl = "";
+ _this7.documentInfo = null;
+ _this7.metadata = null;
+ _this7._contentDispositionFilename = null;
+ _this7._contentLength = null;
+ _this7.triggerDelayedFallback = null;
+ _this7._saveInProgress = false;
+
+ _this7._cancelIdleCallbacks();
+
+ promises.push(_this7._destroyScriptingInstance());
- _this6.pdfSidebar.reset();
+ _this7.pdfSidebar.reset();
- _this6.pdfOutlineViewer.reset();
+ _this7.pdfOutlineViewer.reset();
- _this6.pdfAttachmentViewer.reset();
+ _this7.pdfAttachmentViewer.reset();
- _this6.pdfLayerViewer.reset();
+ _this7.pdfLayerViewer.reset();
- if (_this6.pdfHistory) {
- _this6.pdfHistory.reset();
+ if (_this7.pdfHistory) {
+ _this7.pdfHistory.reset();
}
- if (_this6.findBar) {
- _this6.findBar.reset();
+ if (_this7.findBar) {
+ _this7.findBar.reset();
}
- _this6.toolbar.reset();
+ _this7.toolbar.reset();
- _this6.secondaryToolbar.reset();
+ _this7.secondaryToolbar.reset();
if (typeof PDFBug !== "undefined") {
PDFBug.cleanup();
}
- return _context6.abrupt("return", promise);
+ _context8.next = 33;
+ return Promise.all(promises);
- case 26:
+ case 33:
+ return _context8.abrupt("return", undefined);
+
+ case 34:
case "end":
- return _context6.stop();
+ return _context8.stop();
}
}
- }, _callee6);
+ }, _callee8);
}))();
},
open: function open(file, args) {
- var _this7 = this;
+ var _this8 = this;
- return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee7() {
- var workerParameters, key, parameters, apiParameters, _key, value, _key2, _value, loadingTask;
+ return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee9() {
+ var workerParameters, key, parameters, apiParameters, _key, value, _key2, loadingTask;
- return _regenerator["default"].wrap(function _callee7$(_context7) {
+ return _regenerator["default"].wrap(function _callee9$(_context9) {
while (1) {
- switch (_context7.prev = _context7.next) {
+ switch (_context9.prev = _context9.next) {
case 0:
- if (!_this7.pdfLoadingTask) {
- _context7.next = 3;
+ if (!_this8.pdfLoadingTask) {
+ _context9.next = 3;
break;
}
- _context7.next = 3;
- return _this7.close();
+ _context9.next = 3;
+ return _this8.close();
case 3:
workerParameters = _app_options.AppOptions.getAll(_app_options.OptionKind.WORKER);
@@ -1071,13 +1518,13 @@ var PDFViewerApplication = {
parameters = Object.create(null);
if (typeof file === "string") {
- _this7.setTitleUsingUrl(file);
+ _this8.setTitleUsingUrl(file);
parameters.url = file;
} else if (file && "byteLength" in file) {
parameters.data = file;
} else if (file.url && file.originalUrl) {
- _this7.setTitleUsingUrl(file.originalUrl);
+ _this8.setTitleUsingUrl(file.originalUrl);
parameters.url = file.url;
}
@@ -1094,57 +1541,51 @@ var PDFViewerApplication = {
if (args) {
for (_key2 in args) {
- _value = args[_key2];
-
- if (_key2 === "length") {
- _this7.pdfDocumentProperties.setFileSize(_value);
- }
-
- parameters[_key2] = _value;
+ parameters[_key2] = args[_key2];
}
}
loadingTask = (0, _pdfjsLib.getDocument)(parameters);
- _this7.pdfLoadingTask = loadingTask;
+ _this8.pdfLoadingTask = loadingTask;
loadingTask.onPassword = function (updateCallback, reason) {
- _this7.pdfLinkService.externalLinkEnabled = false;
+ _this8.pdfLinkService.externalLinkEnabled = false;
- _this7.passwordPrompt.setUpdateCallback(updateCallback, reason);
+ _this8.passwordPrompt.setUpdateCallback(updateCallback, reason);
- _this7.passwordPrompt.open();
+ _this8.passwordPrompt.open();
};
loadingTask.onProgress = function (_ref) {
var loaded = _ref.loaded,
total = _ref.total;
- _this7.progress(loaded / total);
+ _this8.progress(loaded / total);
};
- loadingTask.onUnsupportedFeature = _this7.fallback.bind(_this7);
- return _context7.abrupt("return", loadingTask.promise.then(function (pdfDocument) {
- _this7.load(pdfDocument);
+ loadingTask.onUnsupportedFeature = _this8.fallback.bind(_this8);
+ return _context9.abrupt("return", loadingTask.promise.then(function (pdfDocument) {
+ _this8.load(pdfDocument);
}, function (exception) {
- if (loadingTask !== _this7.pdfLoadingTask) {
+ if (loadingTask !== _this8.pdfLoadingTask) {
return undefined;
}
- var message = exception && exception.message;
+ var message = exception === null || exception === void 0 ? void 0 : exception.message;
var loadingErrorMessage;
if (exception instanceof _pdfjsLib.InvalidPDFException) {
- loadingErrorMessage = _this7.l10n.get("invalid_file_error", null, "Invalid or corrupted PDF file.");
+ loadingErrorMessage = _this8.l10n.get("invalid_file_error", null, "Invalid or corrupted PDF file.");
} else if (exception instanceof _pdfjsLib.MissingPDFException) {
- loadingErrorMessage = _this7.l10n.get("missing_file_error", null, "Missing PDF file.");
+ loadingErrorMessage = _this8.l10n.get("missing_file_error", null, "Missing PDF file.");
} else if (exception instanceof _pdfjsLib.UnexpectedResponseException) {
- loadingErrorMessage = _this7.l10n.get("unexpected_response_error", null, "Unexpected server response.");
+ loadingErrorMessage = _this8.l10n.get("unexpected_response_error", null, "Unexpected server response.");
} else {
- loadingErrorMessage = _this7.l10n.get("loading_error", null, "An error occurred while loading the PDF.");
+ loadingErrorMessage = _this8.l10n.get("loading_error", null, "An error occurred while loading the PDF.");
}
return loadingErrorMessage.then(function (msg) {
- _this7.error(msg, {
+ _this8.error(msg, {
message: message
});
@@ -1154,15 +1595,13 @@ var PDFViewerApplication = {
case 16:
case "end":
- return _context7.stop();
+ return _context9.stop();
}
}
- }, _callee7);
+ }, _callee9);
}))();
},
download: function download() {
- var _this8 = this;
-
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
_ref2$sourceEventType = _ref2.sourceEventType,
sourceEventType = _ref2$sourceEventType === void 0 ? "download" : _ref2$sourceEventType;
@@ -1171,13 +1610,9 @@ var PDFViewerApplication = {
downloadManager.downloadUrl(url, filename);
}
- var url = this.baseUrl;
- var filename = this.contentDispositionFilename || (0, _ui_utils.getPDFFileNameFromURL)(this.url);
- var downloadManager = this.downloadManager;
-
- downloadManager.onerror = function (err) {
- _this8.error("PDF failed to download: ".concat(err));
- };
+ var downloadManager = this.downloadManager,
+ url = this.baseUrl,
+ filename = this._docFilename;
if (!this.pdfDocument || !this.downloadComplete) {
downloadByUrl();
@@ -1192,44 +1627,99 @@ var PDFViewerApplication = {
})["catch"](downloadByUrl);
},
save: function save() {
- var _this9 = this;
+ var _arguments = arguments,
+ _this9 = this;
- var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
- _ref3$sourceEventType = _ref3.sourceEventType,
- sourceEventType = _ref3$sourceEventType === void 0 ? "download" : _ref3$sourceEventType;
+ return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee11() {
+ var _this9$_scriptingInst;
- if (this._saveInProgress) {
- return;
- }
+ var _ref3, _ref3$sourceEventType, sourceEventType, downloadManager, url, filename;
- var url = this.baseUrl;
- var filename = this.contentDispositionFilename || (0, _ui_utils.getPDFFileNameFromURL)(this.url);
- var downloadManager = this.downloadManager;
+ return _regenerator["default"].wrap(function _callee11$(_context11) {
+ while (1) {
+ switch (_context11.prev = _context11.next) {
+ case 0:
+ _ref3 = _arguments.length > 0 && _arguments[0] !== undefined ? _arguments[0] : {}, _ref3$sourceEventType = _ref3.sourceEventType, sourceEventType = _ref3$sourceEventType === void 0 ? "download" : _ref3$sourceEventType;
- downloadManager.onerror = function (err) {
- _this9.error("PDF failed to be saved: ".concat(err));
- };
+ if (!_this9._saveInProgress) {
+ _context11.next = 3;
+ break;
+ }
- if (!this.pdfDocument || !this.downloadComplete) {
- this.download({
- sourceEventType: sourceEventType
- });
- return;
- }
+ return _context11.abrupt("return");
- this._saveInProgress = true;
- this.pdfDocument.saveDocument(this.pdfDocument.annotationStorage).then(function (data) {
- var blob = new Blob([data], {
- type: "application/pdf"
- });
- downloadManager.download(blob, url, filename, sourceEventType);
- })["catch"](function () {
- _this9.download({
- sourceEventType: sourceEventType
- });
- })["finally"](function () {
- _this9._saveInProgress = false;
- });
+ case 3:
+ downloadManager = _this9.downloadManager, url = _this9.baseUrl, filename = _this9._docFilename;
+
+ if (!(!_this9.pdfDocument || !_this9.downloadComplete)) {
+ _context11.next = 7;
+ break;
+ }
+
+ _this9.download({
+ sourceEventType: sourceEventType
+ });
+
+ return _context11.abrupt("return");
+
+ case 7:
+ _this9._saveInProgress = true;
+ _context11.next = 10;
+ return (_this9$_scriptingInst = _this9._scriptingInstance) === null || _this9$_scriptingInst === void 0 ? void 0 : _this9$_scriptingInst.scripting.dispatchEventInSandbox({
+ id: "doc",
+ name: "WillSave"
+ });
+
+ case 10:
+ _this9.pdfDocument.saveDocument(_this9.pdfDocument.annotationStorage).then(function (data) {
+ var blob = new Blob([data], {
+ type: "application/pdf"
+ });
+ downloadManager.download(blob, url, filename, sourceEventType);
+ })["catch"](function () {
+ _this9.download({
+ sourceEventType: sourceEventType
+ });
+ })["finally"]( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee10() {
+ var _this9$_scriptingInst2;
+
+ return _regenerator["default"].wrap(function _callee10$(_context10) {
+ while (1) {
+ switch (_context10.prev = _context10.next) {
+ case 0:
+ _context10.next = 2;
+ return (_this9$_scriptingInst2 = _this9._scriptingInstance) === null || _this9$_scriptingInst2 === void 0 ? void 0 : _this9$_scriptingInst2.scripting.dispatchEventInSandbox({
+ id: "doc",
+ name: "DidSave"
+ });
+
+ case 2:
+ _this9._saveInProgress = false;
+
+ case 3:
+ case "end":
+ return _context10.stop();
+ }
+ }
+ }, _callee10);
+ })));
+
+ case 11:
+ case "end":
+ return _context11.stop();
+ }
+ }
+ }, _callee11);
+ }))();
+ },
+ downloadOrSave: function downloadOrSave(options) {
+ var _this$pdfDocument;
+
+ if (((_this$pdfDocument = this.pdfDocument) === null || _this$pdfDocument === void 0 ? void 0 : _this$pdfDocument.annotationStorage.size) > 0) {
+ this.save(options);
+ } else {
+ this.download(options);
+ }
},
_delayedFallback: function _delayedFallback(featureId) {
var _this10 = this;
@@ -1248,6 +1738,8 @@ var PDFViewerApplication = {
}
},
fallback: function fallback(featureId) {
+ var _this11 = this;
+
this.externalServices.reportTelemetry({
type: "unsupportedFeature",
featureId: featureId
@@ -1261,12 +1753,12 @@ var PDFViewerApplication = {
this.externalServices.fallback({
featureId: featureId,
url: this.baseUrl
- }, function response(download) {
+ }).then(function (download) {
if (!download) {
return;
}
- PDFViewerApplication.download({
+ _this11.download({
sourceEventType: "download"
});
});
@@ -1339,7 +1831,7 @@ var PDFViewerApplication = {
});
},
progress: function progress(level) {
- var _this11 = this;
+ var _this12 = this;
if (this.downloadComplete) {
return;
@@ -1359,25 +1851,27 @@ var PDFViewerApplication = {
this.loadingBar.show();
this.disableAutoFetchLoadingBarTimeout = setTimeout(function () {
- _this11.loadingBar.hide();
+ _this12.loadingBar.hide();
- _this11.disableAutoFetchLoadingBarTimeout = null;
+ _this12.disableAutoFetchLoadingBarTimeout = null;
}, DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT);
}
}
},
load: function load(pdfDocument) {
- var _this12 = this;
+ var _this13 = this;
this.pdfDocument = pdfDocument;
- pdfDocument.getDownloadInfo().then(function () {
- _this12.downloadComplete = true;
+ pdfDocument.getDownloadInfo().then(function (_ref5) {
+ var length = _ref5.length;
+ _this13._contentLength = length;
+ _this13.downloadComplete = true;
- _this12.loadingBar.hide();
+ _this13.loadingBar.hide();
firstPagePromise.then(function () {
- _this12.eventBus.dispatch("documentloaded", {
- source: _this12
+ _this13.eventBus.dispatch("documentloaded", {
+ source: _this13
});
});
});
@@ -1390,16 +1884,6 @@ var PDFViewerApplication = {
baseDocumentUrl = null;
this.pdfLinkService.setDocument(pdfDocument, baseDocumentUrl);
this.pdfDocumentProperties.setDocument(pdfDocument, this.url);
- var annotationStorage = pdfDocument.annotationStorage;
-
- annotationStorage.onSetModified = function () {
- window.addEventListener("beforeunload", beforeUnload);
- };
-
- annotationStorage.onResetModified = function () {
- window.removeEventListener("beforeunload", beforeUnload);
- };
-
var pdfViewer = this.pdfViewer;
pdfViewer.setDocument(pdfDocument);
var firstPagePromise = pdfViewer.firstPagePromise,
@@ -1413,33 +1897,35 @@ var PDFViewerApplication = {
scrollLeft: "0",
scrollTop: "0",
rotation: null,
- sidebarView: _pdf_sidebar.SidebarView.UNKNOWN,
+ sidebarView: _ui_utils.SidebarView.UNKNOWN,
scrollMode: _ui_utils.ScrollMode.UNKNOWN,
spreadMode: _ui_utils.SpreadMode.UNKNOWN
})["catch"](function () {
return Object.create(null);
});
firstPagePromise.then(function (pdfPage) {
- _this12.loadingBar.setWidth(_this12.appConfig.viewerContainer);
+ _this13.loadingBar.setWidth(_this13.appConfig.viewerContainer);
+
+ _this13._initializeAnnotationStorageCallbacks(pdfDocument);
Promise.all([_ui_utils.animationStarted, storedPromise, pageLayoutPromise, pageModePromise, openActionPromise]).then( /*#__PURE__*/function () {
- var _ref5 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee8(_ref4) {
- var _ref6, timeStamp, stored, pageLayout, pageMode, openAction, viewOnLoad, initialBookmark, zoom, hash, rotation, sidebarView, scrollMode, spreadMode;
+ var _ref7 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee12(_ref6) {
+ var _ref8, timeStamp, stored, pageLayout, pageMode, openAction, viewOnLoad, initialBookmark, zoom, hash, rotation, sidebarView, scrollMode, spreadMode;
- return _regenerator["default"].wrap(function _callee8$(_context8) {
+ return _regenerator["default"].wrap(function _callee12$(_context12) {
while (1) {
- switch (_context8.prev = _context8.next) {
+ switch (_context12.prev = _context12.next) {
case 0:
- _ref6 = _slicedToArray(_ref4, 5), timeStamp = _ref6[0], stored = _ref6[1], pageLayout = _ref6[2], pageMode = _ref6[3], openAction = _ref6[4];
+ _ref8 = _slicedToArray(_ref6, 5), timeStamp = _ref8[0], stored = _ref8[1], pageLayout = _ref8[2], pageMode = _ref8[3], openAction = _ref8[4];
viewOnLoad = _app_options.AppOptions.get("viewOnLoad");
- _this12._initializePdfHistory({
+ _this13._initializePdfHistory({
fingerprint: pdfDocument.fingerprint,
viewOnLoad: viewOnLoad,
initialDest: openAction && openAction.dest
});
- initialBookmark = _this12.initialBookmark;
+ initialBookmark = _this13.initialBookmark;
zoom = _app_options.AppOptions.get("defaultZoomValue");
hash = zoom ? "zoom=".concat(zoom) : null;
rotation = null;
@@ -1451,7 +1937,7 @@ var PDFViewerApplication = {
hash = "page=".concat(stored.page, "&zoom=").concat(zoom || stored.zoom, ",") + "".concat(stored.scrollLeft, ",").concat(stored.scrollTop);
rotation = parseInt(stored.rotation, 10);
- if (sidebarView === _pdf_sidebar.SidebarView.UNKNOWN) {
+ if (sidebarView === _ui_utils.SidebarView.UNKNOWN) {
sidebarView = stored.sidebarView | 0;
}
@@ -1464,7 +1950,7 @@ var PDFViewerApplication = {
}
}
- if (pageMode && sidebarView === _pdf_sidebar.SidebarView.UNKNOWN) {
+ if (pageMode && sidebarView === _ui_utils.SidebarView.UNKNOWN) {
sidebarView = apiPageModeToSidebarView(pageMode);
}
@@ -1472,128 +1958,557 @@ var PDFViewerApplication = {
spreadMode = apiPageLayoutToSpreadMode(pageLayout);
}
- _this12.setInitialView(hash, {
+ _this13.setInitialView(hash, {
rotation: rotation,
sidebarView: sidebarView,
scrollMode: scrollMode,
spreadMode: spreadMode
});
- _this12.eventBus.dispatch("documentinit", {
- source: _this12
+ _this13.eventBus.dispatch("documentinit", {
+ source: _this13
});
- if (!_this12.isViewerEmbedded) {
+ if (!_this13.isViewerEmbedded) {
pdfViewer.focus();
}
- _this12._initializePermissions(pdfDocument);
+ _this13._initializePermissions(pdfDocument);
- _context8.next = 19;
+ _context12.next = 19;
return Promise.race([pagesPromise, new Promise(function (resolve) {
setTimeout(resolve, FORCE_PAGES_LOADED_TIMEOUT);
})]);
case 19:
if (!(!initialBookmark && !hash)) {
- _context8.next = 21;
+ _context12.next = 21;
break;
}
- return _context8.abrupt("return");
+ return _context12.abrupt("return");
case 21:
if (!pdfViewer.hasEqualPageSizes) {
- _context8.next = 23;
+ _context12.next = 23;
break;
}
- return _context8.abrupt("return");
+ return _context12.abrupt("return");
case 23:
- _this12.initialBookmark = initialBookmark;
+ _this13.initialBookmark = initialBookmark;
pdfViewer.currentScaleValue = pdfViewer.currentScaleValue;
- _this12.setInitialView(hash);
+ _this13.setInitialView(hash);
case 26:
case "end":
- return _context8.stop();
+ return _context12.stop();
}
}
- }, _callee8);
+ }, _callee12);
}));
- return function (_x) {
- return _ref5.apply(this, arguments);
+ return function (_x2) {
+ return _ref7.apply(this, arguments);
};
}())["catch"](function () {
- _this12.setInitialView();
+ _this13.setInitialView();
}).then(function () {
pdfViewer.update();
});
});
pagesPromise.then(function () {
- _this12._initializeAutoPrint(pdfDocument, openActionPromise);
+ _this13._initializeAutoPrint(pdfDocument, openActionPromise);
});
onePageRendered.then(function () {
pdfDocument.getOutline().then(function (outline) {
- _this12.pdfOutlineViewer.render({
- outline: outline
+ _this13.pdfOutlineViewer.render({
+ outline: outline,
+ pdfDocument: pdfDocument
});
});
pdfDocument.getAttachments().then(function (attachments) {
- _this12.pdfAttachmentViewer.render({
+ _this13.pdfAttachmentViewer.render({
attachments: attachments
});
});
pdfViewer.optionalContentConfigPromise.then(function (optionalContentConfig) {
- _this12.pdfLayerViewer.render({
+ _this13.pdfLayerViewer.render({
optionalContentConfig: optionalContentConfig,
pdfDocument: pdfDocument
});
});
+
+ if ("requestIdleCallback" in window) {
+ var callback = window.requestIdleCallback(function () {
+ _this13._collectTelemetry(pdfDocument);
+
+ _this13._idleCallbacks["delete"](callback);
+ }, {
+ timeout: 1000
+ });
+
+ _this13._idleCallbacks.add(callback);
+ }
+
+ _this13._initializeJavaScript(pdfDocument);
});
this._initializePageLabels(pdfDocument);
this._initializeMetadata(pdfDocument);
},
+ _initializeJavaScript: function _initializeJavaScript(pdfDocument) {
+ var _this14 = this;
+
+ return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee15() {
+ var _yield$Promise$all, _yield$Promise$all2, objects, calculationOrder, docActions, scripting, internalEvents, domEvents, updateFromSandbox, visitedPages, pageOpen, pageClose, dispatchEventInSandbox, mouseDown, mouseUp, _iterator4, _step4, _step4$value, name, listener, _iterator5, _step5, _step5$value, _name2, _listener2, _this14$metadata, _this14$metadata2;
+
+ return _regenerator["default"].wrap(function _callee15$(_context15) {
+ while (1) {
+ switch (_context15.prev = _context15.next) {
+ case 0:
+ if (_app_options.AppOptions.get("enableScripting")) {
+ _context15.next = 2;
+ break;
+ }
+
+ return _context15.abrupt("return");
+
+ case 2:
+ _context15.next = 4;
+ return Promise.all([pdfDocument.getFieldObjects(), pdfDocument.getCalculationOrderIds(), pdfDocument.getJSActions()]);
+
+ case 4:
+ _yield$Promise$all = _context15.sent;
+ _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 3);
+ objects = _yield$Promise$all2[0];
+ calculationOrder = _yield$Promise$all2[1];
+ docActions = _yield$Promise$all2[2];
+
+ if (!(!objects && !docActions)) {
+ _context15.next = 11;
+ break;
+ }
+
+ return _context15.abrupt("return");
+
+ case 11:
+ if (!(pdfDocument !== _this14.pdfDocument)) {
+ _context15.next = 13;
+ break;
+ }
+
+ return _context15.abrupt("return");
+
+ case 13:
+ scripting = _this14.externalServices.createScripting({
+ sandboxBundleSrc: _app_options.AppOptions.get("sandboxBundleSrc")
+ });
+ internalEvents = new Map(), domEvents = new Map();
+ _this14._scriptingInstance = {
+ scripting: scripting,
+ ready: false,
+ internalEvents: internalEvents,
+ domEvents: domEvents
+ };
+
+ if (_this14.documentInfo) {
+ _context15.next = 21;
+ break;
+ }
+
+ _context15.next = 19;
+ return new Promise(function (resolve) {
+ _this14.eventBus._on("metadataloaded", function (evt) {
+ resolve();
+ }, {
+ once: true
+ });
+ });
+
+ case 19:
+ if (!(pdfDocument !== _this14.pdfDocument)) {
+ _context15.next = 21;
+ break;
+ }
+
+ return _context15.abrupt("return");
+
+ case 21:
+ if (_this14._contentLength) {
+ _context15.next = 26;
+ break;
+ }
+
+ _context15.next = 24;
+ return new Promise(function (resolve) {
+ _this14.eventBus._on("documentloaded", function (evt) {
+ resolve();
+ }, {
+ once: true
+ });
+ });
+
+ case 24:
+ if (!(pdfDocument !== _this14.pdfDocument)) {
+ _context15.next = 26;
+ break;
+ }
+
+ return _context15.abrupt("return");
+
+ case 26:
+ updateFromSandbox = function updateFromSandbox(_ref9) {
+ var detail = _ref9.detail;
+ var id = detail.id,
+ command = detail.command,
+ value = detail.value;
+
+ if (!id) {
+ switch (command) {
+ case "clear":
+ console.clear();
+ break;
+
+ case "error":
+ console.error(value);
+ break;
+
+ case "layout":
+ _this14.pdfViewer.spreadMode = apiPageLayoutToSpreadMode(value);
+ break;
+
+ case "page-num":
+ _this14.pdfViewer.currentPageNumber = value + 1;
+ break;
+
+ case "print":
+ _this14.pdfViewer.pagesPromise.then(function () {
+ _this14.triggerPrinting();
+ });
+
+ break;
+
+ case "println":
+ console.log(value);
+ break;
+
+ case "zoom":
+ _this14.pdfViewer.currentScaleValue = value;
+ break;
+ }
+
+ return;
+ }
+
+ var element = document.getElementById(id);
+
+ if (element) {
+ element.dispatchEvent(new CustomEvent("updatefromsandbox", {
+ detail: detail
+ }));
+ } else {
+ if (value !== undefined && value !== null) {
+ pdfDocument.annotationStorage.setValue(id, value);
+ }
+ }
+ };
+
+ internalEvents.set("updatefromsandbox", updateFromSandbox);
+ visitedPages = new Map();
+
+ pageOpen = function pageOpen(_ref10) {
+ var pageNumber = _ref10.pageNumber,
+ actionsPromise = _ref10.actionsPromise;
+ visitedPages.set(pageNumber, _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee13() {
+ var _this14$_scriptingIns;
+
+ var actions;
+ return _regenerator["default"].wrap(function _callee13$(_context13) {
+ while (1) {
+ switch (_context13.prev = _context13.next) {
+ case 0:
+ actions = null;
+
+ if (visitedPages.has(pageNumber)) {
+ _context13.next = 7;
+ break;
+ }
+
+ _context13.next = 4;
+ return actionsPromise;
+
+ case 4:
+ actions = _context13.sent;
+
+ if (!(pdfDocument !== _this14.pdfDocument)) {
+ _context13.next = 7;
+ break;
+ }
+
+ return _context13.abrupt("return");
+
+ case 7:
+ _context13.next = 9;
+ return (_this14$_scriptingIns = _this14._scriptingInstance) === null || _this14$_scriptingIns === void 0 ? void 0 : _this14$_scriptingIns.scripting.dispatchEventInSandbox({
+ id: "page",
+ name: "PageOpen",
+ pageNumber: pageNumber,
+ actions: actions
+ });
+
+ case 9:
+ case "end":
+ return _context13.stop();
+ }
+ }
+ }, _callee13);
+ }))());
+ };
+
+ pageClose = /*#__PURE__*/function () {
+ var _ref13 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee14(_ref12) {
+ var _this14$_scriptingIns2;
+
+ var pageNumber, actionsPromise;
+ return _regenerator["default"].wrap(function _callee14$(_context14) {
+ while (1) {
+ switch (_context14.prev = _context14.next) {
+ case 0:
+ pageNumber = _ref12.pageNumber;
+ actionsPromise = visitedPages.get(pageNumber);
+
+ if (actionsPromise) {
+ _context14.next = 4;
+ break;
+ }
+
+ return _context14.abrupt("return");
+
+ case 4:
+ visitedPages.set(pageNumber, null);
+ _context14.next = 7;
+ return actionsPromise;
+
+ case 7:
+ if (!(pdfDocument !== _this14.pdfDocument)) {
+ _context14.next = 9;
+ break;
+ }
+
+ return _context14.abrupt("return");
+
+ case 9:
+ _context14.next = 11;
+ return (_this14$_scriptingIns2 = _this14._scriptingInstance) === null || _this14$_scriptingIns2 === void 0 ? void 0 : _this14$_scriptingIns2.scripting.dispatchEventInSandbox({
+ id: "page",
+ name: "PageClose",
+ pageNumber: pageNumber
+ });
+
+ case 11:
+ case "end":
+ return _context14.stop();
+ }
+ }
+ }, _callee14);
+ }));
+
+ return function pageClose(_x3) {
+ return _ref13.apply(this, arguments);
+ };
+ }();
+
+ internalEvents.set("pageopen", pageOpen);
+ internalEvents.set("pageclose", pageClose);
+
+ dispatchEventInSandbox = function dispatchEventInSandbox(_ref14) {
+ var detail = _ref14.detail;
+ scripting.dispatchEventInSandbox(detail);
+ };
+
+ internalEvents.set("dispatcheventinsandbox", dispatchEventInSandbox);
+
+ mouseDown = function mouseDown(event) {
+ _this14._mouseState.isDown = true;
+ };
+
+ domEvents.set("mousedown", mouseDown);
+
+ mouseUp = function mouseUp(event) {
+ _this14._mouseState.isDown = false;
+ };
+
+ domEvents.set("mouseup", mouseUp);
+ _iterator4 = _createForOfIteratorHelper(internalEvents);
+
+ try {
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
+ _step4$value = _slicedToArray(_step4.value, 2), name = _step4$value[0], listener = _step4$value[1];
+
+ _this14.eventBus._on(name, listener);
+ }
+ } catch (err) {
+ _iterator4.e(err);
+ } finally {
+ _iterator4.f();
+ }
+
+ _iterator5 = _createForOfIteratorHelper(domEvents);
+
+ try {
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
+ _step5$value = _slicedToArray(_step5.value, 2), _name2 = _step5$value[0], _listener2 = _step5$value[1];
+ window.addEventListener(_name2, _listener2);
+ }
+ } catch (err) {
+ _iterator5.e(err);
+ } finally {
+ _iterator5.f();
+ }
+
+ _context15.prev = 43;
+ _context15.next = 46;
+ return scripting.createSandbox({
+ objects: objects,
+ calculationOrder: calculationOrder,
+ appInfo: {
+ platform: navigator.platform,
+ language: navigator.language
+ },
+ docInfo: _objectSpread(_objectSpread({}, _this14.documentInfo), {}, {
+ baseURL: _this14.baseUrl,
+ filesize: _this14._contentLength,
+ filename: _this14._docFilename,
+ metadata: (_this14$metadata = _this14.metadata) === null || _this14$metadata === void 0 ? void 0 : _this14$metadata.getRaw(),
+ authors: (_this14$metadata2 = _this14.metadata) === null || _this14$metadata2 === void 0 ? void 0 : _this14$metadata2.get("dc:creator"),
+ numPages: pdfDocument.numPages,
+ URL: _this14.url,
+ actions: docActions
+ })
+ });
+
+ case 46:
+ if (_this14.externalServices.isInAutomation) {
+ _this14.eventBus.dispatch("sandboxcreated", {
+ source: _this14
+ });
+ }
+
+ _context15.next = 54;
+ break;
+
+ case 49:
+ _context15.prev = 49;
+ _context15.t0 = _context15["catch"](43);
+ console.error("_initializeJavaScript: \"".concat(_context15.t0 === null || _context15.t0 === void 0 ? void 0 : _context15.t0.message, "\"."));
+
+ _this14._destroyScriptingInstance();
+
+ return _context15.abrupt("return");
+
+ case 54:
+ _context15.next = 56;
+ return scripting.dispatchEventInSandbox({
+ id: "doc",
+ name: "Open"
+ });
+
+ case 56:
+ _context15.next = 58;
+ return _this14.pdfViewer.initializeScriptingEvents();
+
+ case 58:
+ Promise.resolve().then(function () {
+ if (_this14._scriptingInstance) {
+ _this14._scriptingInstance.ready = true;
+ }
+ });
+
+ case 59:
+ case "end":
+ return _context15.stop();
+ }
+ }
+ }, _callee15, null, [[43, 49]]);
+ }))();
+ },
+ _collectTelemetry: function _collectTelemetry(pdfDocument) {
+ var _this15 = this;
+
+ return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee16() {
+ var markInfo, tagged;
+ return _regenerator["default"].wrap(function _callee16$(_context16) {
+ while (1) {
+ switch (_context16.prev = _context16.next) {
+ case 0:
+ _context16.next = 2;
+ return _this15.pdfDocument.getMarkInfo();
+
+ case 2:
+ markInfo = _context16.sent;
+
+ if (!(pdfDocument !== _this15.pdfDocument)) {
+ _context16.next = 5;
+ break;
+ }
+
+ return _context16.abrupt("return");
+
+ case 5:
+ tagged = (markInfo === null || markInfo === void 0 ? void 0 : markInfo.Marked) || false;
+
+ _this15.externalServices.reportTelemetry({
+ type: "tagged",
+ tagged: tagged
+ });
+
+ case 7:
+ case "end":
+ return _context16.stop();
+ }
+ }
+ }, _callee16);
+ }))();
+ },
_initializeAutoPrint: function _initializeAutoPrint(pdfDocument, openActionPromise) {
- var _this13 = this;
+ var _this16 = this;
- return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee9() {
- var _yield$Promise$all, _yield$Promise$all2, openAction, javaScript, triggerAutoPrint, _iterator, _step, js;
+ return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee17() {
+ var _yield$Promise$all3, _yield$Promise$all4, openAction, javaScript, triggerAutoPrint, _iterator6, _step6, js;
- return _regenerator["default"].wrap(function _callee9$(_context9) {
+ return _regenerator["default"].wrap(function _callee17$(_context17) {
while (1) {
- switch (_context9.prev = _context9.next) {
+ switch (_context17.prev = _context17.next) {
case 0:
- _context9.next = 2;
- return Promise.all([openActionPromise, pdfDocument.getJavaScript()]);
+ _context17.next = 2;
+ return Promise.all([openActionPromise, !_app_options.AppOptions.get("enableScripting") ? pdfDocument.getJavaScript() : null]);
case 2:
- _yield$Promise$all = _context9.sent;
- _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
- openAction = _yield$Promise$all2[0];
- javaScript = _yield$Promise$all2[1];
+ _yield$Promise$all3 = _context17.sent;
+ _yield$Promise$all4 = _slicedToArray(_yield$Promise$all3, 2);
+ openAction = _yield$Promise$all4[0];
+ javaScript = _yield$Promise$all4[1];
- if (!(pdfDocument !== _this13.pdfDocument)) {
- _context9.next = 8;
+ if (!(pdfDocument !== _this16.pdfDocument)) {
+ _context17.next = 8;
break;
}
- return _context9.abrupt("return");
+ return _context17.abrupt("return");
case 8:
triggerAutoPrint = false;
- if (openAction && openAction.action === "Print") {
+ if ((openAction === null || openAction === void 0 ? void 0 : openAction.action) === "Print") {
triggerAutoPrint = true;
}
if (!javaScript) {
- _context9.next = 31;
+ _context17.next = 31;
break;
}
@@ -1604,112 +2519,106 @@ var PDFViewerApplication = {
console.warn("Warning: JavaScript is not supported");
- _this13._delayedFallback(_pdfjsLib.UNSUPPORTED_FEATURES.javaScript);
+ _this16._delayedFallback(_pdfjsLib.UNSUPPORTED_FEATURES.javaScript);
return true;
});
if (triggerAutoPrint) {
- _context9.next = 31;
+ _context17.next = 31;
break;
}
- _iterator = _createForOfIteratorHelper(javaScript);
- _context9.prev = 14;
+ _iterator6 = _createForOfIteratorHelper(javaScript);
+ _context17.prev = 14;
- _iterator.s();
+ _iterator6.s();
case 16:
- if ((_step = _iterator.n()).done) {
- _context9.next = 23;
+ if ((_step6 = _iterator6.n()).done) {
+ _context17.next = 23;
break;
}
- js = _step.value;
+ js = _step6.value;
if (!(js && _ui_utils.AutoPrintRegExp.test(js))) {
- _context9.next = 21;
+ _context17.next = 21;
break;
}
triggerAutoPrint = true;
- return _context9.abrupt("break", 23);
+ return _context17.abrupt("break", 23);
case 21:
- _context9.next = 16;
+ _context17.next = 16;
break;
case 23:
- _context9.next = 28;
+ _context17.next = 28;
break;
case 25:
- _context9.prev = 25;
- _context9.t0 = _context9["catch"](14);
+ _context17.prev = 25;
+ _context17.t0 = _context17["catch"](14);
- _iterator.e(_context9.t0);
+ _iterator6.e(_context17.t0);
case 28:
- _context9.prev = 28;
+ _context17.prev = 28;
- _iterator.f();
+ _iterator6.f();
- return _context9.finish(28);
+ return _context17.finish(28);
case 31:
- if (_this13.supportsPrinting) {
- _context9.next = 33;
- break;
- }
-
- return _context9.abrupt("return");
-
- case 33:
if (triggerAutoPrint) {
- setTimeout(function () {
- window.print();
- });
+ _this16.triggerPrinting();
}
- case 34:
+ case 32:
case "end":
- return _context9.stop();
+ return _context17.stop();
}
}
- }, _callee9, null, [[14, 25, 28, 31]]);
+ }, _callee17, null, [[14, 25, 28, 31]]);
}))();
},
_initializeMetadata: function _initializeMetadata(pdfDocument) {
- var _this14 = this;
+ var _this17 = this;
- return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee10() {
- var _yield$pdfDocument$ge, info, metadata, contentDispositionFilename, pdfTitle, infoTitle, metadataTitle, versionId, generatorId, producer, formType;
+ return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee18() {
+ var _this17$_contentLengt;
- return _regenerator["default"].wrap(function _callee10$(_context10) {
+ var _yield$pdfDocument$ge, info, metadata, contentDispositionFilename, contentLength, pdfTitle, infoTitle, metadataTitle, versionId, generatorId, producer, formType;
+
+ return _regenerator["default"].wrap(function _callee18$(_context18) {
while (1) {
- switch (_context10.prev = _context10.next) {
+ switch (_context18.prev = _context18.next) {
case 0:
- _context10.next = 2;
+ _context18.next = 2;
return pdfDocument.getMetadata();
case 2:
- _yield$pdfDocument$ge = _context10.sent;
+ _yield$pdfDocument$ge = _context18.sent;
info = _yield$pdfDocument$ge.info;
metadata = _yield$pdfDocument$ge.metadata;
contentDispositionFilename = _yield$pdfDocument$ge.contentDispositionFilename;
+ contentLength = _yield$pdfDocument$ge.contentLength;
- if (!(pdfDocument !== _this14.pdfDocument)) {
- _context10.next = 8;
+ if (!(pdfDocument !== _this17.pdfDocument)) {
+ _context18.next = 9;
break;
}
- return _context10.abrupt("return");
+ return _context18.abrupt("return");
- case 8:
- _this14.documentInfo = info;
- _this14.metadata = metadata;
- _this14.contentDispositionFilename = contentDispositionFilename;
- console.log("PDF ".concat(pdfDocument.fingerprint, " [").concat(info.PDFFormatVersion, " ") + "".concat((info.Producer || "-").trim(), " / ").concat((info.Creator || "-").trim(), "] ") + "(PDF.js: ".concat(_pdfjsLib.version || "-") + "".concat(_this14.pdfViewer.enableWebGL ? " [WebGL]" : "", ")"));
+ case 9:
+ _this17.documentInfo = info;
+ _this17.metadata = metadata;
+ _this17._contentDispositionFilename = contentDispositionFilename;
+ (_this17$_contentLengt = _this17._contentLength) !== null && _this17$_contentLengt !== void 0 ? _this17$_contentLengt : _this17._contentLength = contentLength;
+ console.log("PDF ".concat(pdfDocument.fingerprint, " [").concat(info.PDFFormatVersion, " ") + "".concat((info.Producer || "-").trim(), " / ").concat((info.Creator || "-").trim(), "] ") + "(PDF.js: ".concat(_pdfjsLib.version || "-") + "".concat(_this17.pdfViewer.enableWebGL ? " [WebGL]" : "", ")"));
infoTitle = info && info.Title;
if (infoTitle) {
@@ -1725,19 +2634,19 @@ var PDFViewerApplication = {
}
if (pdfTitle) {
- _this14.setTitle("".concat(pdfTitle, " - ").concat(contentDispositionFilename || document.title));
+ _this17.setTitle("".concat(pdfTitle, " - ").concat(contentDispositionFilename || document.title));
} else if (contentDispositionFilename) {
- _this14.setTitle(contentDispositionFilename);
+ _this17.setTitle(contentDispositionFilename);
}
if (info.IsXFAPresent && !info.IsAcroFormPresent) {
console.warn("Warning: XFA is not supported");
- _this14._delayedFallback(_pdfjsLib.UNSUPPORTED_FEATURES.forms);
- } else if ((info.IsAcroFormPresent || info.IsXFAPresent) && !_this14.pdfViewer.renderInteractiveForms) {
+ _this17._delayedFallback(_pdfjsLib.UNSUPPORTED_FEATURES.forms);
+ } else if ((info.IsAcroFormPresent || info.IsXFAPresent) && !_this17.pdfViewer.renderInteractiveForms) {
console.warn("Warning: Interactive form support is not enabled");
- _this14._delayedFallback(_pdfjsLib.UNSUPPORTED_FEATURES.forms);
+ _this17._delayedFallback(_pdfjsLib.UNSUPPORTED_FEATURES.forms);
}
versionId = "other";
@@ -1755,7 +2664,7 @@ var PDFViewerApplication = {
return false;
}
- generatorId = generator.replace(/[ .\-]/g, "_");
+ generatorId = generator.replace(/[ .-]/g, "_");
return true;
});
}
@@ -1768,61 +2677,65 @@ var PDFViewerApplication = {
formType = "acroform";
}
- _this14.externalServices.reportTelemetry({
+ _this17.externalServices.reportTelemetry({
type: "documentInfo",
version: versionId,
generator: generatorId,
formType: formType
});
- case 25:
+ _this17.eventBus.dispatch("metadataloaded", {
+ source: _this17
+ });
+
+ case 28:
case "end":
- return _context10.stop();
+ return _context18.stop();
}
}
- }, _callee10);
+ }, _callee18);
}))();
},
_initializePageLabels: function _initializePageLabels(pdfDocument) {
- var _this15 = this;
+ var _this18 = this;
- return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee11() {
+ return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee19() {
var labels, numLabels, i, pdfViewer, pdfThumbnailViewer, toolbar;
- return _regenerator["default"].wrap(function _callee11$(_context11) {
+ return _regenerator["default"].wrap(function _callee19$(_context19) {
while (1) {
- switch (_context11.prev = _context11.next) {
+ switch (_context19.prev = _context19.next) {
case 0:
- _context11.next = 2;
+ _context19.next = 2;
return pdfDocument.getPageLabels();
case 2:
- labels = _context11.sent;
+ labels = _context19.sent;
- if (!(pdfDocument !== _this15.pdfDocument)) {
- _context11.next = 5;
+ if (!(pdfDocument !== _this18.pdfDocument)) {
+ _context19.next = 5;
break;
}
- return _context11.abrupt("return");
+ return _context19.abrupt("return");
case 5:
if (!(!labels || _app_options.AppOptions.get("disablePageLabels"))) {
- _context11.next = 7;
+ _context19.next = 7;
break;
}
- return _context11.abrupt("return");
+ return _context19.abrupt("return");
case 7:
numLabels = labels.length;
- if (!(numLabels !== _this15.pagesCount)) {
- _context11.next = 11;
+ if (!(numLabels !== _this18.pagesCount)) {
+ _context19.next = 11;
break;
}
console.error("The number of Page Labels does not match the number of pages in the document.");
- return _context11.abrupt("return");
+ return _context19.abrupt("return");
case 11:
i = 0;
@@ -1832,14 +2745,14 @@ var PDFViewerApplication = {
}
if (!(i === numLabels)) {
- _context11.next = 15;
+ _context19.next = 15;
break;
}
- return _context11.abrupt("return");
+ return _context19.abrupt("return");
case 15:
- pdfViewer = _this15.pdfViewer, pdfThumbnailViewer = _this15.pdfThumbnailViewer, toolbar = _this15.toolbar;
+ pdfViewer = _this18.pdfViewer, pdfThumbnailViewer = _this18.pdfThumbnailViewer, toolbar = _this18.toolbar;
pdfViewer.setPageLabels(labels);
pdfThumbnailViewer.setPageLabels(labels);
toolbar.setPagesCount(numLabels, true);
@@ -1847,17 +2760,17 @@ var PDFViewerApplication = {
case 20:
case "end":
- return _context11.stop();
+ return _context19.stop();
}
}
- }, _callee11);
+ }, _callee19);
}))();
},
- _initializePdfHistory: function _initializePdfHistory(_ref7) {
- var fingerprint = _ref7.fingerprint,
- viewOnLoad = _ref7.viewOnLoad,
- _ref7$initialDest = _ref7.initialDest,
- initialDest = _ref7$initialDest === void 0 ? null : _ref7$initialDest;
+ _initializePdfHistory: function _initializePdfHistory(_ref15) {
+ var fingerprint = _ref15.fingerprint,
+ viewOnLoad = _ref15.viewOnLoad,
+ _ref15$initialDest = _ref15.initialDest,
+ initialDest = _ref15$initialDest === void 0 ? null : _ref15$initialDest;
if (this.isViewerEmbedded || _app_options.AppOptions.get("disableHistory")) {
return;
@@ -1883,70 +2796,85 @@ var PDFViewerApplication = {
}
},
_initializePermissions: function _initializePermissions(pdfDocument) {
- var _this16 = this;
+ var _this19 = this;
- return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee12() {
+ return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee20() {
var permissions;
- return _regenerator["default"].wrap(function _callee12$(_context12) {
+ return _regenerator["default"].wrap(function _callee20$(_context20) {
while (1) {
- switch (_context12.prev = _context12.next) {
+ switch (_context20.prev = _context20.next) {
case 0:
- _context12.next = 2;
+ _context20.next = 2;
return pdfDocument.getPermissions();
case 2:
- permissions = _context12.sent;
+ permissions = _context20.sent;
- if (!(pdfDocument !== _this16.pdfDocument)) {
- _context12.next = 5;
+ if (!(pdfDocument !== _this19.pdfDocument)) {
+ _context20.next = 5;
break;
}
- return _context12.abrupt("return");
+ return _context20.abrupt("return");
case 5:
if (!(!permissions || !_app_options.AppOptions.get("enablePermissions"))) {
- _context12.next = 7;
+ _context20.next = 7;
break;
}
- return _context12.abrupt("return");
+ return _context20.abrupt("return");
case 7:
if (!permissions.includes(_pdfjsLib.PermissionFlag.COPY)) {
- _this16.appConfig.viewerContainer.classList.add(ENABLE_PERMISSIONS_CLASS);
+ _this19.appConfig.viewerContainer.classList.add(ENABLE_PERMISSIONS_CLASS);
}
case 8:
case "end":
- return _context12.stop();
+ return _context20.stop();
}
}
- }, _callee12);
+ }, _callee20);
}))();
},
+ _initializeAnnotationStorageCallbacks: function _initializeAnnotationStorageCallbacks(pdfDocument) {
+ if (pdfDocument !== this.pdfDocument) {
+ return;
+ }
+
+ var annotationStorage = pdfDocument.annotationStorage;
+
+ annotationStorage.onSetModified = function () {
+ window.addEventListener("beforeunload", beforeUnload);
+ };
+
+ annotationStorage.onResetModified = function () {
+ window.removeEventListener("beforeunload", beforeUnload);
+ };
+ },
setInitialView: function setInitialView(storedHash) {
- var _this17 = this;
+ var _this20 = this;
- var _ref8 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
- rotation = _ref8.rotation,
- sidebarView = _ref8.sidebarView,
- scrollMode = _ref8.scrollMode,
- spreadMode = _ref8.spreadMode;
+ var _ref16 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
+ rotation = _ref16.rotation,
+ sidebarView = _ref16.sidebarView,
+ scrollMode = _ref16.scrollMode,
+ spreadMode = _ref16.spreadMode;
var setRotation = function setRotation(angle) {
if ((0, _ui_utils.isValidRotation)(angle)) {
- _this17.pdfViewer.pagesRotation = angle;
+ _this20.pdfViewer.pagesRotation = angle;
}
};
var setViewerModes = function setViewerModes(scroll, spread) {
if ((0, _ui_utils.isValidScrollMode)(scroll)) {
- _this17.pdfViewer.scrollMode = scroll;
+ _this20.pdfViewer.scrollMode = scroll;
}
if ((0, _ui_utils.isValidSpreadMode)(spread)) {
- _this17.pdfViewer.spreadMode = spread;
+ _this20.pdfViewer.spreadMode = spread;
}
};
@@ -1984,12 +2912,18 @@ var PDFViewerApplication = {
}
},
forceRendering: function forceRendering() {
- this.pdfRenderingQueue.printing = this.printing;
+ this.pdfRenderingQueue.printing = !!this.printService;
this.pdfRenderingQueue.isThumbnailViewEnabled = this.pdfSidebar.isThumbnailViewVisible;
this.pdfRenderingQueue.renderHighestPriority();
},
beforePrint: function beforePrint() {
- var _this18 = this;
+ var _this$_scriptingInsta,
+ _this21 = this;
+
+ (_this$_scriptingInsta = this._scriptingInstance) === null || _this$_scriptingInsta === void 0 ? void 0 : _this$_scriptingInsta.scripting.dispatchEventInSandbox({
+ id: "doc",
+ name: "WillPrint"
+ });
if (this.printService) {
return;
@@ -1997,7 +2931,7 @@ var PDFViewerApplication = {
if (!this.supportsPrinting) {
this.l10n.get("printing_not_supported", null, "Warning: Printing is not fully supported by this browser.").then(function (printMessage) {
- _this18.error(printMessage);
+ _this21.error(printMessage);
});
return;
}
@@ -2024,6 +2958,13 @@ var PDFViewerApplication = {
});
},
afterPrint: function afterPrint() {
+ var _this$_scriptingInsta2;
+
+ (_this$_scriptingInsta2 = this._scriptingInstance) === null || _this$_scriptingInsta2 === void 0 ? void 0 : _this$_scriptingInsta2.scripting.dispatchEventInSandbox({
+ id: "doc",
+ name: "DidPrint"
+ });
+
if (this.printService) {
this.printService.destroy();
this.printService = null;
@@ -2050,6 +2991,13 @@ var PDFViewerApplication = {
this.pdfPresentationMode.request();
},
+ triggerPrinting: function triggerPrinting() {
+ if (!this.supportsPrinting) {
+ return;
+ }
+
+ window.print();
+ },
bindEvents: function bindEvents() {
var eventBus = this.eventBus,
_boundEvents = this._boundEvents;
@@ -2132,6 +3080,14 @@ var PDFViewerApplication = {
eventBus._on("updatefindcontrolstate", webViewerUpdateFindControlState);
+ if (_app_options.AppOptions.get("pdfBug")) {
+ _boundEvents.reportPageStatsPDFBug = reportPageStatsPDFBug;
+
+ eventBus._on("pagerendered", _boundEvents.reportPageStatsPDFBug);
+
+ eventBus._on("pagechanging", _boundEvents.reportPageStatsPDFBug);
+ }
+
eventBus._on("fileinputchange", webViewerFileInputChange);
eventBus._on("openfile", webViewerOpenFile);
@@ -2165,6 +3121,13 @@ var PDFViewerApplication = {
});
};
+ _boundEvents.windowUpdateFromSandbox = function (event) {
+ eventBus.dispatch("updatefromsandbox", {
+ source: window,
+ detail: event.detail
+ });
+ };
+
window.addEventListener("visibilitychange", webViewerVisibilityChange);
window.addEventListener("wheel", webViewerWheel, {
passive: false
@@ -2179,6 +3142,7 @@ var PDFViewerApplication = {
window.addEventListener("hashchange", _boundEvents.windowHashChange);
window.addEventListener("beforeprint", _boundEvents.windowBeforePrint);
window.addEventListener("afterprint", _boundEvents.windowAfterPrint);
+ window.addEventListener("updatefromsandbox", _boundEvents.windowUpdateFromSandbox);
},
unbindEvents: function unbindEvents() {
var eventBus = this.eventBus,
@@ -2260,6 +3224,14 @@ var PDFViewerApplication = {
eventBus._off("updatefindcontrolstate", webViewerUpdateFindControlState);
+ if (_boundEvents.reportPageStatsPDFBug) {
+ eventBus._off("pagerendered", _boundEvents.reportPageStatsPDFBug);
+
+ eventBus._off("pagechanging", _boundEvents.reportPageStatsPDFBug);
+
+ _boundEvents.reportPageStatsPDFBug = null;
+ }
+
eventBus._off("fileinputchange", webViewerFileInputChange);
eventBus._off("openfile", webViewerOpenFile);
@@ -2283,10 +3255,12 @@ var PDFViewerApplication = {
window.removeEventListener("hashchange", _boundEvents.windowHashChange);
window.removeEventListener("beforeprint", _boundEvents.windowBeforePrint);
window.removeEventListener("afterprint", _boundEvents.windowAfterPrint);
+ window.removeEventListener("updatefromsandbox", _boundEvents.windowUpdateFromSandbox);
_boundEvents.windowResize = null;
_boundEvents.windowHashChange = null;
_boundEvents.windowBeforePrint = null;
_boundEvents.windowAfterPrint = null;
+ _boundEvents.windowUpdateFromSandbox = null;
},
accumulateWheelTicks: function accumulateWheelTicks(ticks) {
if (this._wheelUnusedTicks > 0 && ticks < 0 || this._wheelUnusedTicks < 0 && ticks > 0) {
@@ -2297,7 +3271,14 @@ var PDFViewerApplication = {
var wholeTicks = Math.sign(this._wheelUnusedTicks) * Math.floor(Math.abs(this._wheelUnusedTicks));
this._wheelUnusedTicks -= wholeTicks;
return wholeTicks;
+ },
+
+ get scriptingReady() {
+ var _this$_scriptingInsta3;
+
+ return ((_this$_scriptingInsta3 = this._scriptingInstance) === null || _this$_scriptingInsta3 === void 0 ? void 0 : _this$_scriptingInsta3.ready) || false;
}
+
};
exports.PDFViewerApplication = PDFViewerApplication;
var validateFileURL;
@@ -2340,23 +3321,23 @@ function loadFakeWorker() {
}
function _loadFakeWorker() {
- _loadFakeWorker = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee13() {
- return _regenerator["default"].wrap(function _callee13$(_context13) {
+ _loadFakeWorker = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee21() {
+ return _regenerator["default"].wrap(function _callee21$(_context21) {
while (1) {
- switch (_context13.prev = _context13.next) {
+ switch (_context21.prev = _context21.next) {
case 0:
if (!_pdfjsLib.GlobalWorkerOptions.workerSrc) {
_pdfjsLib.GlobalWorkerOptions.workerSrc = _app_options.AppOptions.get("workerSrc");
}
- return _context13.abrupt("return", (0, _pdfjsLib.loadScript)(_pdfjsLib.PDFWorker.getWorkerSrc()));
+ return _context21.abrupt("return", (0, _pdfjsLib.loadScript)(_pdfjsLib.PDFWorker.getWorkerSrc()));
case 2:
case "end":
- return _context13.stop();
+ return _context21.stop();
}
}
- }, _callee13);
+ }, _callee21);
}));
return _loadFakeWorker.apply(this, arguments);
}
@@ -2371,6 +3352,23 @@ function loadAndEnablePDFBug(enabledTabs) {
});
}
+function reportPageStatsPDFBug(_ref17) {
+ var pageNumber = _ref17.pageNumber;
+
+ if (typeof Stats === "undefined" || !Stats.enabled) {
+ return;
+ }
+
+ var pageView = PDFViewerApplication.pdfViewer.getPageView(pageNumber - 1);
+ var pageStats = pageView && pageView.pdfPage && pageView.pdfPage.stats;
+
+ if (!pageStats) {
+ return;
+ }
+
+ Stats.add(pageNumber, pageStats);
+}
+
function webViewerInitialized() {
var appConfig = PDFViewerApplication.appConfig;
var file;
@@ -2494,37 +3492,33 @@ function webViewerResetPermissions() {
appConfig.viewerContainer.classList.remove(ENABLE_PERMISSIONS_CLASS);
}
-function webViewerPageRendered(evt) {
- var pageNumber = evt.pageNumber;
- var pageIndex = pageNumber - 1;
- var pageView = PDFViewerApplication.pdfViewer.getPageView(pageIndex);
+function webViewerPageRendered(_ref18) {
+ var pageNumber = _ref18.pageNumber,
+ timestamp = _ref18.timestamp,
+ error = _ref18.error;
if (pageNumber === PDFViewerApplication.page) {
PDFViewerApplication.toolbar.updateLoadingIndicatorState(false);
}
- if (!pageView) {
- return;
- }
-
if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
- var thumbnailView = PDFViewerApplication.pdfThumbnailViewer.getThumbnail(pageIndex);
- thumbnailView.setImage(pageView);
- }
+ var pageView = PDFViewerApplication.pdfViewer.getPageView(pageNumber - 1);
+ var thumbnailView = PDFViewerApplication.pdfThumbnailViewer.getThumbnail(pageNumber - 1);
- if (typeof Stats !== "undefined" && Stats.enabled && pageView.stats) {
- Stats.add(pageNumber, pageView.stats);
+ if (pageView && thumbnailView) {
+ thumbnailView.setImage(pageView);
+ }
}
- if (pageView.error) {
+ if (error) {
PDFViewerApplication.l10n.get("rendering_error", null, "An error occurred while rendering the page.").then(function (msg) {
- PDFViewerApplication.error(msg, pageView.error);
+ PDFViewerApplication.error(msg, error);
});
}
PDFViewerApplication.externalServices.reportTelemetry({
type: "pageInfo",
- timestamp: evt.timestamp
+ timestamp: timestamp
});
PDFViewerApplication.pdfDocument.getStats().then(function (stats) {
PDFViewerApplication.externalServices.reportTelemetry({
@@ -2534,30 +3528,30 @@ function webViewerPageRendered(evt) {
});
}
-function webViewerPageMode(_ref9) {
- var mode = _ref9.mode;
+function webViewerPageMode(_ref19) {
+ var mode = _ref19.mode;
var view;
switch (mode) {
case "thumbs":
- view = _pdf_sidebar.SidebarView.THUMBS;
+ view = _ui_utils.SidebarView.THUMBS;
break;
case "bookmarks":
case "outline":
- view = _pdf_sidebar.SidebarView.OUTLINE;
+ view = _ui_utils.SidebarView.OUTLINE;
break;
case "attachments":
- view = _pdf_sidebar.SidebarView.ATTACHMENTS;
+ view = _ui_utils.SidebarView.ATTACHMENTS;
break;
case "layers":
- view = _pdf_sidebar.SidebarView.LAYERS;
+ view = _ui_utils.SidebarView.LAYERS;
break;
case "none":
- view = _pdf_sidebar.SidebarView.NONE;
+ view = _ui_utils.SidebarView.NONE;
break;
default:
@@ -2582,10 +3576,7 @@ function webViewerNamedAction(evt) {
break;
case "Print":
- if (PDFViewerApplication.supportsPrinting) {
- webViewerPrint();
- }
-
+ PDFViewerApplication.triggerPrinting();
break;
case "SaveAs":
@@ -2594,18 +3585,8 @@ function webViewerNamedAction(evt) {
}
}
-function webViewerPresentationModeChanged(_ref10) {
- var active = _ref10.active,
- switchInProgress = _ref10.switchInProgress;
- var state = _ui_utils.PresentationModeState.NORMAL;
-
- if (switchInProgress) {
- state = _ui_utils.PresentationModeState.CHANGING;
- } else if (active) {
- state = _ui_utils.PresentationModeState.FULLSCREEN;
- }
-
- PDFViewerApplication.pdfViewer.presentationModeState = state;
+function webViewerPresentationModeChanged(evt) {
+ PDFViewerApplication.pdfViewer.presentationModeState = evt.state;
}
function webViewerSidebarViewChanged(evt) {
@@ -2635,7 +3616,7 @@ function webViewerUpdateViewarea(evt) {
PDFViewerApplication.appConfig.toolbar.viewBookmark.href = href;
PDFViewerApplication.appConfig.secondaryToolbar.viewBookmarkButton.href = href;
var currentPage = PDFViewerApplication.pdfViewer.getPageView(PDFViewerApplication.page - 1);
- var loading = currentPage.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED;
+ var loading = (currentPage && currentPage.renderingState) !== _pdf_rendering_queue.RenderingStates.FINISHED;
PDFViewerApplication.toolbar.updateLoadingIndicatorState(loading);
}
@@ -2736,27 +3717,19 @@ function webViewerPresentationMode() {
}
function webViewerPrint() {
- window.print();
-}
-
-function webViewerDownloadOrSave(sourceEventType) {
- if (PDFViewerApplication.pdfDocument && PDFViewerApplication.pdfDocument.annotationStorage.size > 0) {
- PDFViewerApplication.save({
- sourceEventType: sourceEventType
- });
- } else {
- PDFViewerApplication.download({
- sourceEventType: sourceEventType
- });
- }
+ PDFViewerApplication.triggerPrinting();
}
function webViewerDownload() {
- webViewerDownloadOrSave("download");
+ PDFViewerApplication.downloadOrSave({
+ sourceEventType: "download"
+ });
}
function webViewerSave() {
- webViewerDownloadOrSave("save");
+ PDFViewerApplication.downloadOrSave({
+ sourceEventType: "save"
+ });
}
function webViewerFirstPage() {
@@ -2772,11 +3745,11 @@ function webViewerLastPage() {
}
function webViewerNextPage() {
- PDFViewerApplication.page++;
+ PDFViewerApplication.pdfViewer.nextPage();
}
function webViewerPreviousPage() {
- PDFViewerApplication.page--;
+ PDFViewerApplication.pdfViewer.previousPage();
}
function webViewerZoomIn() {
@@ -2795,7 +3768,7 @@ function webViewerPageNumberChanged(evt) {
var pdfViewer = PDFViewerApplication.pdfViewer;
if (evt.value !== "") {
- pdfViewer.currentPageLabel = evt.value;
+ PDFViewerApplication.pdfLinkService.goToPage(evt.value);
}
if (evt.value !== pdfViewer.currentPageNumber.toString() && evt.value !== pdfViewer.currentPageLabel) {
@@ -2853,8 +3826,8 @@ function webViewerFindFromUrlHash(evt) {
});
}
-function webViewerUpdateFindMatchesCount(_ref11) {
- var matchesCount = _ref11.matchesCount;
+function webViewerUpdateFindMatchesCount(_ref20) {
+ var matchesCount = _ref20.matchesCount;
if (PDFViewerApplication.supportsIntegratedFind) {
PDFViewerApplication.externalServices.updateFindMatchesCount(matchesCount);
@@ -2863,11 +3836,11 @@ function webViewerUpdateFindMatchesCount(_ref11) {
}
}
-function webViewerUpdateFindControlState(_ref12) {
- var state = _ref12.state,
- previous = _ref12.previous,
- matchesCount = _ref12.matchesCount,
- rawQuery = _ref12.rawQuery;
+function webViewerUpdateFindControlState(_ref21) {
+ var state = _ref21.state,
+ previous = _ref21.previous,
+ matchesCount = _ref21.matchesCount,
+ rawQuery = _ref21.rawQuery;
if (PDFViewerApplication.supportsIntegratedFind) {
PDFViewerApplication.externalServices.updateFindControlState({
@@ -2892,21 +3865,14 @@ function webViewerRotationChanging(evt) {
PDFViewerApplication.pdfViewer.currentPageNumber = evt.pageNumber;
}
-function webViewerPageChanging(evt) {
- var page = evt.pageNumber;
- PDFViewerApplication.toolbar.setPageNumber(page, evt.pageLabel || null);
- PDFViewerApplication.secondaryToolbar.setPageNumber(page);
+function webViewerPageChanging(_ref22) {
+ var pageNumber = _ref22.pageNumber,
+ pageLabel = _ref22.pageLabel;
+ PDFViewerApplication.toolbar.setPageNumber(pageNumber, pageLabel);
+ PDFViewerApplication.secondaryToolbar.setPageNumber(pageNumber);
if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
- PDFViewerApplication.pdfThumbnailViewer.scrollThumbnailIntoView(page);
- }
-
- if (typeof Stats !== "undefined" && Stats.enabled) {
- var pageView = PDFViewerApplication.pdfViewer.getPageView(page - 1);
-
- if (pageView && pageView.stats) {
- Stats.add(page, pageView.stats);
- }
+ PDFViewerApplication.pdfThumbnailViewer.scrollThumbnailIntoView(pageNumber);
}
}
@@ -3023,7 +3989,7 @@ function webViewerKeyDown(evt) {
if (cmd === 1 || cmd === 8 || cmd === 5 || cmd === 12) {
switch (evt.keyCode) {
case 70:
- if (!PDFViewerApplication.supportsIntegratedFind) {
+ if (!PDFViewerApplication.supportsIntegratedFind && !evt.shiftKey) {
PDFViewerApplication.findBar.open();
handled = true;
}
@@ -3147,7 +4113,7 @@ function webViewerKeyDown(evt) {
return;
}
- var curElement = document.activeElement || document.querySelector(":focus");
+ var curElement = (0, _ui_utils.getActiveOrFocusedElement)();
var curElementTagName = curElement && curElement.tagName.toUpperCase();
if (curElementTagName === "INPUT" || curElementTagName === "TEXTAREA" || curElementTagName === "SELECT" || curElement && curElement.isContentEditable) {
@@ -3266,13 +4232,9 @@ function webViewerKeyDown(evt) {
if (turnPage !== 0 && (!turnOnlyIfPageFit || pdfViewer.currentScaleValue === "page-fit")) {
if (turnPage > 0) {
- if (PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
- PDFViewerApplication.page++;
- }
+ pdfViewer.nextPage();
} else {
- if (PDFViewerApplication.page > 1) {
- PDFViewerApplication.page--;
- }
+ pdfViewer.previousPage();
}
handled = true;
@@ -3342,22 +4304,22 @@ function apiPageLayoutToSpreadMode(layout) {
function apiPageModeToSidebarView(mode) {
switch (mode) {
case "UseNone":
- return _pdf_sidebar.SidebarView.NONE;
+ return _ui_utils.SidebarView.NONE;
case "UseThumbs":
- return _pdf_sidebar.SidebarView.THUMBS;
+ return _ui_utils.SidebarView.THUMBS;
case "UseOutlines":
- return _pdf_sidebar.SidebarView.OUTLINE;
+ return _ui_utils.SidebarView.OUTLINE;
case "UseAttachments":
- return _pdf_sidebar.SidebarView.ATTACHMENTS;
+ return _ui_utils.SidebarView.ATTACHMENTS;
case "UseOC":
- return _pdf_sidebar.SidebarView.LAYERS;
+ return _ui_utils.SidebarView.LAYERS;
}
- return _pdf_sidebar.SidebarView.NONE;
+ return _ui_utils.SidebarView.NONE;
}
var PDFPrintServiceFactory = {
@@ -3371,20 +4333,19 @@ var PDFPrintServiceFactory = {
exports.PDFPrintServiceFactory = PDFPrintServiceFactory;
/***/ }),
-/* 2 */
-/***/ (function(module, exports, __webpack_require__) {
+/* 4 */
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
-"use strict";
-module.exports = __webpack_require__(3);
+module.exports = __webpack_require__(5);
/***/ }),
-/* 3 */
-/***/ (function(module, exports, __webpack_require__) {
+/* 5 */
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+/* module decorator */ module = __webpack_require__.nmd(module);
-"use strict";
-/* WEBPACK VAR INJECTION */(function(module) {
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
@@ -3967,80 +4928,47 @@ var runtime = function (exports) {
}
};
return exports;
-}(( false ? undefined : _typeof(module)) === "object" ? module.exports : {});
+}(( false ? 0 : _typeof(module)) === "object" ? module.exports : {});
try {
regeneratorRuntime = runtime;
} catch (accidentalStrictMode) {
Function("r", "regeneratorRuntime = r")(runtime);
}
-/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(4)(module)))
/***/ }),
-/* 4 */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-
-
-module.exports = function (module) {
- if (!module.webpackPolyfill) {
- module.deprecate = function () {};
-
- module.paths = [];
- if (!module.children) module.children = [];
- Object.defineProperty(module, "loaded", {
- enumerable: true,
- get: function get() {
- return module.l;
- }
- });
- Object.defineProperty(module, "id", {
- enumerable: true,
- get: function get() {
- return module.i;
- }
- });
- module.webpackPolyfill = 1;
- }
-
- return module;
-};
-
-/***/ }),
-/* 5 */
-/***/ (function(module, exports, __webpack_require__) {
+/* 6 */
+/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
-"use strict";
-Object.defineProperty(exports, "__esModule", {
+Object.defineProperty(exports, "__esModule", ({
value: true
-});
+}));
+exports.approximateFraction = approximateFraction;
+exports.backtrackBeforeAllVisibleElements = backtrackBeforeAllVisibleElements;
+exports.binarySearchFirstItem = binarySearchFirstItem;
+exports.getActiveOrFocusedElement = getActiveOrFocusedElement;
+exports.getOutputScale = getOutputScale;
+exports.getPageSizeInches = getPageSizeInches;
+exports.getPDFFileNameFromURL = getPDFFileNameFromURL;
+exports.getVisibleElements = getVisibleElements;
+exports.isPortraitOrientation = isPortraitOrientation;
exports.isValidRotation = isValidRotation;
exports.isValidScrollMode = isValidScrollMode;
exports.isValidSpreadMode = isValidSpreadMode;
-exports.isPortraitOrientation = isPortraitOrientation;
-exports.clamp = clamp;
-exports.getPDFFileNameFromURL = getPDFFileNameFromURL;
+exports.moveToEndOfArray = moveToEndOfArray;
exports.noContextMenuHandler = noContextMenuHandler;
+exports.normalizeWheelEventDelta = normalizeWheelEventDelta;
+exports.normalizeWheelEventDirection = normalizeWheelEventDirection;
exports.parseQueryString = parseQueryString;
-exports.backtrackBeforeAllVisibleElements = backtrackBeforeAllVisibleElements;
-exports.getVisibleElements = getVisibleElements;
exports.roundToDivide = roundToDivide;
-exports.getPageSizeInches = getPageSizeInches;
-exports.approximateFraction = approximateFraction;
-exports.getOutputScale = getOutputScale;
exports.scrollIntoView = scrollIntoView;
-exports.watchScroll = watchScroll;
-exports.binarySearchFirstItem = binarySearchFirstItem;
-exports.normalizeWheelEventDirection = normalizeWheelEventDirection;
-exports.normalizeWheelEventDelta = normalizeWheelEventDelta;
exports.waitOnEventOrTimeout = waitOnEventOrTimeout;
-exports.moveToEndOfArray = moveToEndOfArray;
-exports.WaitOnType = exports.animationStarted = exports.ProgressBar = exports.EventBus = exports.NullL10n = exports.SpreadMode = exports.ScrollMode = exports.TextLayerMode = exports.RendererType = exports.PresentationModeState = exports.VERTICAL_PADDING = exports.SCROLLBAR_PADDING = exports.MAX_AUTO_SCALE = exports.UNKNOWN_SCALE = exports.MAX_SCALE = exports.MIN_SCALE = exports.DEFAULT_SCALE = exports.DEFAULT_SCALE_VALUE = exports.CSS_UNITS = exports.AutoPrintRegExp = void 0;
+exports.watchScroll = watchScroll;
+exports.WaitOnType = exports.VERTICAL_PADDING = exports.UNKNOWN_SCALE = exports.TextLayerMode = exports.SpreadMode = exports.SidebarView = exports.ScrollMode = exports.SCROLLBAR_PADDING = exports.RendererType = exports.ProgressBar = exports.PresentationModeState = exports.NullL10n = exports.MIN_SCALE = exports.MAX_SCALE = exports.MAX_AUTO_SCALE = exports.EventBus = exports.DEFAULT_SCALE_VALUE = exports.DEFAULT_SCALE = exports.CSS_UNITS = exports.AutoPrintRegExp = exports.animationStarted = void 0;
-var _regenerator = _interopRequireDefault(__webpack_require__(2));
+var _regenerator = _interopRequireDefault(__webpack_require__(4));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
@@ -4086,6 +5014,7 @@ var SCROLLBAR_PADDING = 40;
exports.SCROLLBAR_PADDING = SCROLLBAR_PADDING;
var VERTICAL_PADDING = 5;
exports.VERTICAL_PADDING = VERTICAL_PADDING;
+var LOADINGBAR_END_OFFSET_VAR = "--loadingBar-end-offset";
var PresentationModeState = {
UNKNOWN: 0,
NORMAL: 1,
@@ -4093,6 +5022,15 @@ var PresentationModeState = {
FULLSCREEN: 3
};
exports.PresentationModeState = PresentationModeState;
+var SidebarView = {
+ UNKNOWN: -1,
+ NONE: 0,
+ THUMBS: 1,
+ OUTLINE: 2,
+ ATTACHMENTS: 3,
+ LAYERS: 4
+};
+exports.SidebarView = SidebarView;
var RendererType = {
CANVAS: "canvas",
SVG: "svg"
@@ -4198,7 +5136,7 @@ exports.NullL10n = NullL10n;
function getOutputScale(ctx) {
var devicePixelRatio = window.devicePixelRatio || 1;
- var backingStoreRatio = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1;
+ var backingStoreRatio = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.backingStorePixelRatio || 1;
var pixelRatio = devicePixelRatio / backingStoreRatio;
return {
sx: pixelRatio,
@@ -4427,9 +5365,15 @@ function backtrackBeforeAllVisibleElements(index, views, top) {
return index;
}
-function getVisibleElements(scrollEl, views) {
- var sortByVisibility = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
- var horizontal = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
+function getVisibleElements(_ref2) {
+ var scrollEl = _ref2.scrollEl,
+ views = _ref2.views,
+ _ref2$sortByVisibilit = _ref2.sortByVisibility,
+ sortByVisibility = _ref2$sortByVisibilit === void 0 ? false : _ref2$sortByVisibilit,
+ _ref2$horizontal = _ref2.horizontal,
+ horizontal = _ref2$horizontal === void 0 ? false : _ref2$horizontal,
+ _ref2$rtl = _ref2.rtl,
+ rtl = _ref2$rtl === void 0 ? false : _ref2$rtl;
var top = scrollEl.scrollTop,
bottom = top + scrollEl.clientHeight;
var left = scrollEl.scrollLeft,
@@ -4441,15 +5385,16 @@ function getVisibleElements(scrollEl, views) {
return elementBottom > top;
}
- function isElementRightAfterViewLeft(view) {
+ function isElementNextAfterViewHorizontally(view) {
var element = view.div;
- var elementRight = element.offsetLeft + element.clientLeft + element.clientWidth;
- return elementRight > left;
+ var elementLeft = element.offsetLeft + element.clientLeft;
+ var elementRight = elementLeft + element.clientWidth;
+ return rtl ? elementLeft < right : elementRight > left;
}
var visible = [],
numViews = views.length;
- var firstVisibleElementInd = numViews === 0 ? 0 : binarySearchFirstItem(views, horizontal ? isElementRightAfterViewLeft : isElementBottomAfterViewTop);
+ var firstVisibleElementInd = binarySearchFirstItem(views, horizontal ? isElementNextAfterViewHorizontally : isElementBottomAfterViewTop);
if (firstVisibleElementInd > 0 && firstVisibleElementInd < numViews && !horizontal) {
firstVisibleElementInd = backtrackBeforeAllVisibleElements(firstVisibleElementInd, views, top);
@@ -4481,13 +5426,16 @@ function getVisibleElements(scrollEl, views) {
var hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, viewBottom - bottom);
var hiddenWidth = Math.max(0, left - currentWidth) + Math.max(0, viewRight - right);
- var percent = (viewHeight - hiddenHeight) * (viewWidth - hiddenWidth) * 100 / viewHeight / viewWidth | 0;
+ var fractionHeight = (viewHeight - hiddenHeight) / viewHeight,
+ fractionWidth = (viewWidth - hiddenWidth) / viewWidth;
+ var percent = fractionHeight * fractionWidth * 100 | 0;
visible.push({
id: view.id,
x: currentWidth,
y: currentHeight,
view: view,
- percent: percent
+ percent: percent,
+ widthPercent: fractionWidth * 100 | 0
});
}
@@ -4540,8 +5488,8 @@ function getPDFFileNameFromURL(url) {
return defaultFilename;
}
- var reURI = /^(?:(?:[^:]+:)?\/\/[^\/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
- var reFilename = /[^\/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
+ var reURI = /^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
+ var reFilename = /[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
var splitURI = reURI.exec(url);
var suggestedFilename = reFilename.exec(splitURI[1]) || reFilename.exec(splitURI[2]) || reFilename.exec(splitURI[3]);
@@ -4607,11 +5555,11 @@ var WaitOnType = {
};
exports.WaitOnType = WaitOnType;
-function waitOnEventOrTimeout(_ref2) {
- var target = _ref2.target,
- name = _ref2.name,
- _ref2$delay = _ref2.delay,
- delay = _ref2$delay === void 0 ? 0 : _ref2$delay;
+function waitOnEventOrTimeout(_ref3) {
+ var target = _ref3.target,
+ name = _ref3.name,
+ _ref3$delay = _ref3.delay,
+ delay = _ref3$delay === void 0 ? 0 : _ref3$delay;
return new Promise(function (resolve, reject) {
if (_typeof(target) !== "object" || !(name && typeof name === "string") || !(Number.isInteger(delay) && delay >= 0)) {
throw new Error("waitOnEventOrTimeout - invalid parameters.");
@@ -4664,20 +5612,28 @@ var EventBus = /*#__PURE__*/function () {
_createClass(EventBus, [{
key: "on",
value: function on(eventName, listener) {
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
+
this._on(eventName, listener, {
- external: true
+ external: true,
+ once: options === null || options === void 0 ? void 0 : options.once
});
}
}, {
key: "off",
value: function off(eventName, listener) {
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
+
this._off(eventName, listener, {
- external: true
+ external: true,
+ once: options === null || options === void 0 ? void 0 : options.once
});
}
}, {
key: "dispatch",
value: function dispatch(eventName) {
+ var _this = this;
+
var eventListeners = this._listeners[eventName];
if (!eventListeners || eventListeners.length === 0) {
@@ -4686,16 +5642,17 @@ var EventBus = /*#__PURE__*/function () {
var args = Array.prototype.slice.call(arguments, 1);
var externalListeners;
- eventListeners.slice(0).forEach(function (_ref3) {
- var listener = _ref3.listener,
- external = _ref3.external;
+ eventListeners.slice(0).forEach(function (_ref4) {
+ var listener = _ref4.listener,
+ external = _ref4.external,
+ once = _ref4.once;
- if (external) {
- if (!externalListeners) {
- externalListeners = [];
- }
+ if (once) {
+ _this._off(eventName, listener);
+ }
- externalListeners.push(listener);
+ if (external) {
+ (externalListeners || (externalListeners = [])).push(listener);
return;
}
@@ -4712,16 +5669,14 @@ var EventBus = /*#__PURE__*/function () {
}, {
key: "_on",
value: function _on(eventName, listener) {
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
- var eventListeners = this._listeners[eventName];
-
- if (!eventListeners) {
- this._listeners[eventName] = eventListeners = [];
- }
+ var _this$_listeners;
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
+ var eventListeners = (_this$_listeners = this._listeners)[eventName] || (_this$_listeners[eventName] = []);
eventListeners.push({
listener: listener,
- external: (options && options.external) === true
+ external: (options === null || options === void 0 ? void 0 : options.external) === true,
+ once: (options === null || options === void 0 ? void 0 : options.once) === true
});
}
}, {
@@ -4754,10 +5709,10 @@ function clamp(v, min, max) {
var ProgressBar = /*#__PURE__*/function () {
function ProgressBar(id) {
- var _ref4 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
- height = _ref4.height,
- width = _ref4.width,
- units = _ref4.units;
+ var _ref5 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
+ height = _ref5.height,
+ width = _ref5.width,
+ units = _ref5.units;
_classCallCheck(this, ProgressBar);
@@ -4795,7 +5750,8 @@ var ProgressBar = /*#__PURE__*/function () {
var scrollbarWidth = container.offsetWidth - viewer.offsetWidth;
if (scrollbarWidth > 0) {
- this.bar.style.width = "calc(100% - ".concat(scrollbarWidth, "px)");
+ var doc = document.documentElement;
+ doc.style.setProperty(LOADINGBAR_END_OFFSET_VAR, "".concat(scrollbarWidth, "px"));
}
}
}, {
@@ -4807,7 +5763,6 @@ var ProgressBar = /*#__PURE__*/function () {
this.visible = false;
this.bar.classList.add("hidden");
- document.body.classList.remove("loadingInProgress");
}
}, {
key: "show",
@@ -4817,7 +5772,6 @@ var ProgressBar = /*#__PURE__*/function () {
}
this.visible = true;
- document.body.classList.add("loadingInProgress");
this.bar.classList.remove("hidden");
}
}, {
@@ -4857,317 +5811,22 @@ function moveToEndOfArray(arr, condition) {
}
}
-/***/ }),
-/* 6 */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-
-
-Object.defineProperty(exports, "__esModule", {
- value: true
-});
-exports.OptionKind = exports.AppOptions = void 0;
-
-var _viewer_compatibility = __webpack_require__(7);
-
-function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
-
-function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
-
-function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
+function getActiveOrFocusedElement() {
+ var curRoot = document;
+ var curActiveOrFocused = curRoot.activeElement || curRoot.querySelector(":focus");
-function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
-
-var OptionKind = {
- VIEWER: 0x02,
- API: 0x04,
- WORKER: 0x08,
- PREFERENCE: 0x80
-};
-exports.OptionKind = OptionKind;
-var defaultOptions = {
- cursorToolOnLoad: {
- value: 0,
- kind: OptionKind.VIEWER + OptionKind.PREFERENCE
- },
- defaultUrl: {
- value: "compressed.tracemonkey-pldi-09.pdf",
- kind: OptionKind.VIEWER
- },
- defaultZoomValue: {
- value: "",
- kind: OptionKind.VIEWER + OptionKind.PREFERENCE
- },
- disableHistory: {
- value: false,
- kind: OptionKind.VIEWER
- },
- disablePageLabels: {
- value: false,
- kind: OptionKind.VIEWER + OptionKind.PREFERENCE
- },
- enablePermissions: {
- value: false,
- kind: OptionKind.VIEWER + OptionKind.PREFERENCE
- },
- enablePrintAutoRotate: {
- value: false,
- kind: OptionKind.VIEWER + OptionKind.PREFERENCE
- },
- enableWebGL: {
- value: false,
- kind: OptionKind.VIEWER + OptionKind.PREFERENCE
- },
- externalLinkRel: {
- value: "noopener noreferrer nofollow",
- kind: OptionKind.VIEWER
- },
- externalLinkTarget: {
- value: 0,
- kind: OptionKind.VIEWER + OptionKind.PREFERENCE
- },
- historyUpdateUrl: {
- value: false,
- kind: OptionKind.VIEWER + OptionKind.PREFERENCE
- },
- ignoreDestinationZoom: {
- value: false,
- kind: OptionKind.VIEWER + OptionKind.PREFERENCE
- },
- imageResourcesPath: {
- value: "./images/",
- kind: OptionKind.VIEWER
- },
- maxCanvasPixels: {
- value: 16777216,
- compatibility: _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels,
- kind: OptionKind.VIEWER
- },
- pdfBugEnabled: {
- value: false,
- kind: OptionKind.VIEWER + OptionKind.PREFERENCE
- },
- printResolution: {
- value: 150,
- kind: OptionKind.VIEWER
- },
- renderer: {
- value: "canvas",
- kind: OptionKind.VIEWER + OptionKind.PREFERENCE
- },
- renderInteractiveForms: {
- value: true,
- kind: OptionKind.VIEWER + OptionKind.PREFERENCE
- },
- sidebarViewOnLoad: {
- value: -1,
- kind: OptionKind.VIEWER + OptionKind.PREFERENCE
- },
- scrollModeOnLoad: {
- value: -1,
- kind: OptionKind.VIEWER + OptionKind.PREFERENCE
- },
- spreadModeOnLoad: {
- value: -1,
- kind: OptionKind.VIEWER + OptionKind.PREFERENCE
- },
- textLayerMode: {
- value: 1,
- kind: OptionKind.VIEWER + OptionKind.PREFERENCE
- },
- useOnlyCssZoom: {
- value: false,
- kind: OptionKind.VIEWER + OptionKind.PREFERENCE
- },
- viewOnLoad: {
- value: 0,
- kind: OptionKind.VIEWER + OptionKind.PREFERENCE
- },
- cMapPacked: {
- value: true,
- kind: OptionKind.API
- },
- cMapUrl: {
- value: "../web/cmaps/",
- kind: OptionKind.API
- },
- disableAutoFetch: {
- value: false,
- kind: OptionKind.API + OptionKind.PREFERENCE
- },
- disableFontFace: {
- value: false,
- kind: OptionKind.API + OptionKind.PREFERENCE
- },
- disableRange: {
- value: false,
- kind: OptionKind.API + OptionKind.PREFERENCE
- },
- disableStream: {
- value: false,
- kind: OptionKind.API + OptionKind.PREFERENCE
- },
- docBaseUrl: {
- value: "",
- kind: OptionKind.API
- },
- fontExtraProperties: {
- value: false,
- kind: OptionKind.API
- },
- isEvalSupported: {
- value: true,
- kind: OptionKind.API
- },
- maxImageSize: {
- value: -1,
- kind: OptionKind.API
- },
- pdfBug: {
- value: false,
- kind: OptionKind.API
- },
- verbosity: {
- value: 1,
- kind: OptionKind.API
- },
- workerPort: {
- value: null,
- kind: OptionKind.WORKER
- },
- workerSrc: {
- value: "../build/pdf.worker.js",
- kind: OptionKind.WORKER
- }
-};
-{
- defaultOptions.disablePreferences = {
- value: false,
- kind: OptionKind.VIEWER
- };
- defaultOptions.locale = {
- value: typeof navigator !== "undefined" ? navigator.language : "en-US",
- kind: OptionKind.VIEWER
- };
-}
-var userOptions = Object.create(null);
-
-var AppOptions = /*#__PURE__*/function () {
- function AppOptions() {
- _classCallCheck(this, AppOptions);
-
- throw new Error("Cannot initialize AppOptions.");
+ while (curActiveOrFocused && curActiveOrFocused.shadowRoot) {
+ curRoot = curActiveOrFocused.shadowRoot;
+ curActiveOrFocused = curRoot.activeElement || curRoot.querySelector(":focus");
}
- _createClass(AppOptions, null, [{
- key: "get",
- value: function get(name) {
- var userOption = userOptions[name];
-
- if (userOption !== undefined) {
- return userOption;
- }
-
- var defaultOption = defaultOptions[name];
-
- if (defaultOption !== undefined) {
- return defaultOption.compatibility || defaultOption.value;
- }
-
- return undefined;
- }
- }, {
- key: "getAll",
- value: function getAll() {
- var kind = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
- var options = Object.create(null);
-
- for (var name in defaultOptions) {
- var defaultOption = defaultOptions[name];
-
- if (kind) {
- if ((kind & defaultOption.kind) === 0) {
- continue;
- }
-
- if (kind === OptionKind.PREFERENCE) {
- var value = defaultOption.value,
- valueType = _typeof(value);
-
- if (valueType === "boolean" || valueType === "string" || valueType === "number" && Number.isInteger(value)) {
- options[name] = value;
- continue;
- }
-
- throw new Error("Invalid type for preference: ".concat(name));
- }
- }
-
- var userOption = userOptions[name];
- options[name] = userOption !== undefined ? userOption : defaultOption.compatibility || defaultOption.value;
- }
-
- return options;
- }
- }, {
- key: "set",
- value: function set(name, value) {
- userOptions[name] = value;
- }
- }, {
- key: "remove",
- value: function remove(name) {
- delete userOptions[name];
- }
- }]);
-
- return AppOptions;
-}();
-
-exports.AppOptions = AppOptions;
-
-/***/ }),
-/* 7 */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-
-
-Object.defineProperty(exports, "__esModule", {
- value: true
-});
-exports.viewerCompatibilityParams = void 0;
-var compatibilityParams = Object.create(null);
-{
- var userAgent = typeof navigator !== "undefined" && navigator.userAgent || "";
- var platform = typeof navigator !== "undefined" && navigator.platform || "";
- var maxTouchPoints = typeof navigator !== "undefined" && navigator.maxTouchPoints || 1;
- var isAndroid = /Android/.test(userAgent);
- var isIE = /Trident/.test(userAgent);
- var isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent) || platform === "MacIntel" && maxTouchPoints > 1;
- var isIOSChrome = /CriOS/.test(userAgent);
-
- (function checkOnBlobSupport() {
- if (isIE || isIOSChrome) {
- compatibilityParams.disableCreateObjectURL = true;
- }
- })();
-
- (function checkCanvasSizeLimitation() {
- if (isIOS || isAndroid) {
- compatibilityParams.maxCanvasPixels = 5242880;
- }
- })();
+ return curActiveOrFocused;
}
-var viewerCompatibilityParams = Object.freeze(compatibilityParams);
-exports.viewerCompatibilityParams = viewerCompatibilityParams;
/***/ }),
-/* 8 */
-/***/ (function(module, exports, __webpack_require__) {
+/* 7 */
+/***/ ((module) => {
-"use strict";
var pdfjsLib;
@@ -5181,18 +5840,19 @@ if (typeof window !== "undefined" && window["pdfjs-dist/build/pdf"]) {
module.exports = pdfjsLib;
/***/ }),
-/* 9 */
-/***/ (function(module, exports, __webpack_require__) {
+/* 8 */
+/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
-"use strict";
-Object.defineProperty(exports, "__esModule", {
+Object.defineProperty(exports, "__esModule", ({
value: true
-});
+}));
exports.PDFCursorTools = exports.CursorTool = void 0;
-var _grab_to_pan = __webpack_require__(10);
+var _grab_to_pan = __webpack_require__(9);
+
+var _ui_utils = __webpack_require__(6);
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@@ -5298,23 +5958,29 @@ var PDFCursorTools = /*#__PURE__*/function () {
});
this.eventBus._on("presentationmodechanged", function (evt) {
- if (evt.switchInProgress) {
- return;
- }
+ switch (evt.state) {
+ case _ui_utils.PresentationModeState.CHANGING:
+ break;
- var previouslyActive;
+ case _ui_utils.PresentationModeState.FULLSCREEN:
+ {
+ var previouslyActive = _this3.active;
- if (evt.active) {
- previouslyActive = _this3.active;
+ _this3.switchTool(CursorTool.SELECT);
- _this3.switchTool(CursorTool.SELECT);
+ _this3.activeBeforePresentationMode = previouslyActive;
+ break;
+ }
- _this3.activeBeforePresentationMode = previouslyActive;
- } else {
- previouslyActive = _this3.activeBeforePresentationMode;
- _this3.activeBeforePresentationMode = null;
+ case _ui_utils.PresentationModeState.NORMAL:
+ {
+ var _previouslyActive = _this3.activeBeforePresentationMode;
+ _this3.activeBeforePresentationMode = null;
- _this3.switchTool(previouslyActive);
+ _this3.switchTool(_previouslyActive);
+
+ break;
+ }
}
});
}
@@ -5331,15 +5997,14 @@ var PDFCursorTools = /*#__PURE__*/function () {
exports.PDFCursorTools = PDFCursorTools;
/***/ }),
-/* 10 */
-/***/ (function(module, exports, __webpack_require__) {
+/* 9 */
+/***/ ((__unused_webpack_module, exports) => {
-"use strict";
-Object.defineProperty(exports, "__esModule", {
+Object.defineProperty(exports, "__esModule", ({
value: true
-});
+}));
exports.GrabToPan = GrabToPan;
function GrabToPan(options) {
@@ -5463,7 +6128,7 @@ GrabToPan.prototype = {
}
};
var matchesSelector;
-["webkitM", "mozM", "msM", "oM", "m"].some(function (prefix) {
+["webkitM", "mozM", "m"].some(function (prefix) {
var name = prefix + "atches";
if (name in document.documentElement) {
@@ -5496,16 +6161,17 @@ function isLeftMouseReleased(event) {
}
/***/ }),
-/* 11 */
-/***/ (function(module, exports, __webpack_require__) {
+/* 10 */
+/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
-"use strict";
-Object.defineProperty(exports, "__esModule", {
+Object.defineProperty(exports, "__esModule", ({
value: true
-});
-exports.PDFRenderingQueue = exports.RenderingStates = void 0;
+}));
+exports.RenderingStates = exports.PDFRenderingQueue = void 0;
+
+var _pdfjsLib = __webpack_require__(7);
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@@ -5638,6 +6304,10 @@ var PDFRenderingQueue = /*#__PURE__*/function () {
view.draw()["finally"](function () {
_this.renderHighestPriority();
})["catch"](function (reason) {
+ if (reason instanceof _pdfjsLib.RenderingCancelledException) {
+ return;
+ }
+
console.error("renderView: \"".concat(reason, "\""));
});
break;
@@ -5653,464 +6323,17 @@ var PDFRenderingQueue = /*#__PURE__*/function () {
exports.PDFRenderingQueue = PDFRenderingQueue;
/***/ }),
-/* 12 */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-
-
-Object.defineProperty(exports, "__esModule", {
- value: true
-});
-exports.PDFSidebar = exports.SidebarView = void 0;
-
-var _ui_utils = __webpack_require__(5);
-
-var _pdf_rendering_queue = __webpack_require__(11);
-
-function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
-
-function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
-
-function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
-
-var UI_NOTIFICATION_CLASS = "pdfSidebarNotification";
-var SidebarView = {
- UNKNOWN: -1,
- NONE: 0,
- THUMBS: 1,
- OUTLINE: 2,
- ATTACHMENTS: 3,
- LAYERS: 4
-};
-exports.SidebarView = SidebarView;
-
-var PDFSidebar = /*#__PURE__*/function () {
- function PDFSidebar(_ref) {
- var elements = _ref.elements,
- pdfViewer = _ref.pdfViewer,
- pdfThumbnailViewer = _ref.pdfThumbnailViewer,
- eventBus = _ref.eventBus,
- _ref$l10n = _ref.l10n,
- l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n,
- _ref$disableNotificat = _ref.disableNotification,
- disableNotification = _ref$disableNotificat === void 0 ? false : _ref$disableNotificat;
-
- _classCallCheck(this, PDFSidebar);
-
- this.isOpen = false;
- this.active = SidebarView.THUMBS;
- this.isInitialViewSet = false;
- this.onToggled = null;
- this.pdfViewer = pdfViewer;
- this.pdfThumbnailViewer = pdfThumbnailViewer;
- this.outerContainer = elements.outerContainer;
- this.viewerContainer = elements.viewerContainer;
- this.toggleButton = elements.toggleButton;
- this.thumbnailButton = elements.thumbnailButton;
- this.outlineButton = elements.outlineButton;
- this.attachmentsButton = elements.attachmentsButton;
- this.layersButton = elements.layersButton;
- this.thumbnailView = elements.thumbnailView;
- this.outlineView = elements.outlineView;
- this.attachmentsView = elements.attachmentsView;
- this.layersView = elements.layersView;
- this.eventBus = eventBus;
- this.l10n = l10n;
- this._disableNotification = disableNotification;
-
- this._addEventListeners();
- }
-
- _createClass(PDFSidebar, [{
- key: "reset",
- value: function reset() {
- this.isInitialViewSet = false;
-
- this._hideUINotification(null);
-
- this.switchView(SidebarView.THUMBS);
- this.outlineButton.disabled = false;
- this.attachmentsButton.disabled = false;
- this.layersButton.disabled = false;
- }
- }, {
- key: "setInitialView",
- value: function setInitialView() {
- var view = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : SidebarView.NONE;
-
- if (this.isInitialViewSet) {
- return;
- }
-
- this.isInitialViewSet = true;
-
- if (view === SidebarView.NONE || view === SidebarView.UNKNOWN) {
- this._dispatchEvent();
-
- return;
- }
-
- if (!this._switchView(view, true)) {
- this._dispatchEvent();
- }
- }
- }, {
- key: "switchView",
- value: function switchView(view) {
- var forceOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
-
- this._switchView(view, forceOpen);
- }
- }, {
- key: "_switchView",
- value: function _switchView(view) {
- var forceOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
- var isViewChanged = view !== this.active;
- var shouldForceRendering = false;
-
- switch (view) {
- case SidebarView.NONE:
- if (this.isOpen) {
- this.close();
- return true;
- }
-
- return false;
-
- case SidebarView.THUMBS:
- if (this.isOpen && isViewChanged) {
- shouldForceRendering = true;
- }
-
- break;
-
- case SidebarView.OUTLINE:
- if (this.outlineButton.disabled) {
- return false;
- }
-
- break;
-
- case SidebarView.ATTACHMENTS:
- if (this.attachmentsButton.disabled) {
- return false;
- }
-
- break;
-
- case SidebarView.LAYERS:
- if (this.layersButton.disabled) {
- return false;
- }
-
- break;
-
- default:
- console.error("PDFSidebar._switchView: \"".concat(view, "\" is not a valid view."));
- return false;
- }
-
- this.active = view;
- this.thumbnailButton.classList.toggle("toggled", view === SidebarView.THUMBS);
- this.outlineButton.classList.toggle("toggled", view === SidebarView.OUTLINE);
- this.attachmentsButton.classList.toggle("toggled", view === SidebarView.ATTACHMENTS);
- this.layersButton.classList.toggle("toggled", view === SidebarView.LAYERS);
- this.thumbnailView.classList.toggle("hidden", view !== SidebarView.THUMBS);
- this.outlineView.classList.toggle("hidden", view !== SidebarView.OUTLINE);
- this.attachmentsView.classList.toggle("hidden", view !== SidebarView.ATTACHMENTS);
- this.layersView.classList.toggle("hidden", view !== SidebarView.LAYERS);
-
- if (forceOpen && !this.isOpen) {
- this.open();
- return true;
- }
-
- if (shouldForceRendering) {
- this._updateThumbnailViewer();
-
- this._forceRendering();
- }
-
- if (isViewChanged) {
- this._dispatchEvent();
- }
-
- this._hideUINotification(this.active);
-
- return isViewChanged;
- }
- }, {
- key: "open",
- value: function open() {
- if (this.isOpen) {
- return;
- }
-
- this.isOpen = true;
- this.toggleButton.classList.add("toggled");
- this.outerContainer.classList.add("sidebarMoving", "sidebarOpen");
-
- if (this.active === SidebarView.THUMBS) {
- this._updateThumbnailViewer();
- }
-
- this._forceRendering();
-
- this._dispatchEvent();
-
- this._hideUINotification(this.active);
- }
- }, {
- key: "close",
- value: function close() {
- if (!this.isOpen) {
- return;
- }
-
- this.isOpen = false;
- this.toggleButton.classList.remove("toggled");
- this.outerContainer.classList.add("sidebarMoving");
- this.outerContainer.classList.remove("sidebarOpen");
-
- this._forceRendering();
-
- this._dispatchEvent();
- }
- }, {
- key: "toggle",
- value: function toggle() {
- if (this.isOpen) {
- this.close();
- } else {
- this.open();
- }
- }
- }, {
- key: "_dispatchEvent",
- value: function _dispatchEvent() {
- this.eventBus.dispatch("sidebarviewchanged", {
- source: this,
- view: this.visibleView
- });
- }
- }, {
- key: "_forceRendering",
- value: function _forceRendering() {
- if (this.onToggled) {
- this.onToggled();
- } else {
- this.pdfViewer.forceRendering();
- this.pdfThumbnailViewer.forceRendering();
- }
- }
- }, {
- key: "_updateThumbnailViewer",
- value: function _updateThumbnailViewer() {
- var pdfViewer = this.pdfViewer,
- pdfThumbnailViewer = this.pdfThumbnailViewer;
- var pagesCount = pdfViewer.pagesCount;
-
- for (var pageIndex = 0; pageIndex < pagesCount; pageIndex++) {
- var pageView = pdfViewer.getPageView(pageIndex);
-
- if (pageView && pageView.renderingState === _pdf_rendering_queue.RenderingStates.FINISHED) {
- var thumbnailView = pdfThumbnailViewer.getThumbnail(pageIndex);
- thumbnailView.setImage(pageView);
- }
- }
-
- pdfThumbnailViewer.scrollThumbnailIntoView(pdfViewer.currentPageNumber);
- }
- }, {
- key: "_showUINotification",
- value: function _showUINotification(view) {
- var _this = this;
-
- if (this._disableNotification) {
- return;
- }
-
- this.l10n.get("toggle_sidebar_notification2.title", null, "Toggle Sidebar (document contains outline/attachments/layers)").then(function (msg) {
- _this.toggleButton.title = msg;
- });
-
- if (!this.isOpen) {
- this.toggleButton.classList.add(UI_NOTIFICATION_CLASS);
- } else if (view === this.active) {
- return;
- }
-
- switch (view) {
- case SidebarView.OUTLINE:
- this.outlineButton.classList.add(UI_NOTIFICATION_CLASS);
- break;
-
- case SidebarView.ATTACHMENTS:
- this.attachmentsButton.classList.add(UI_NOTIFICATION_CLASS);
- break;
-
- case SidebarView.LAYERS:
- this.layersButton.classList.add(UI_NOTIFICATION_CLASS);
- break;
- }
- }
- }, {
- key: "_hideUINotification",
- value: function _hideUINotification(view) {
- var _this2 = this;
-
- if (this._disableNotification) {
- return;
- }
-
- var removeNotification = function removeNotification(sidebarView) {
- switch (sidebarView) {
- case SidebarView.OUTLINE:
- _this2.outlineButton.classList.remove(UI_NOTIFICATION_CLASS);
-
- break;
-
- case SidebarView.ATTACHMENTS:
- _this2.attachmentsButton.classList.remove(UI_NOTIFICATION_CLASS);
-
- break;
-
- case SidebarView.LAYERS:
- _this2.layersButton.classList.remove(UI_NOTIFICATION_CLASS);
-
- break;
- }
- };
-
- if (!this.isOpen && view !== null) {
- return;
- }
-
- this.toggleButton.classList.remove(UI_NOTIFICATION_CLASS);
-
- if (view !== null) {
- removeNotification(view);
- return;
- }
-
- for (view in SidebarView) {
- removeNotification(SidebarView[view]);
- }
-
- this.l10n.get("toggle_sidebar.title", null, "Toggle Sidebar").then(function (msg) {
- _this2.toggleButton.title = msg;
- });
- }
- }, {
- key: "_addEventListeners",
- value: function _addEventListeners() {
- var _this3 = this;
-
- this.viewerContainer.addEventListener("transitionend", function (evt) {
- if (evt.target === _this3.viewerContainer) {
- _this3.outerContainer.classList.remove("sidebarMoving");
- }
- });
- this.toggleButton.addEventListener("click", function () {
- _this3.toggle();
- });
- this.thumbnailButton.addEventListener("click", function () {
- _this3.switchView(SidebarView.THUMBS);
- });
- this.outlineButton.addEventListener("click", function () {
- _this3.switchView(SidebarView.OUTLINE);
- });
- this.outlineButton.addEventListener("dblclick", function () {
- _this3.eventBus.dispatch("toggleoutlinetree", {
- source: _this3
- });
- });
- this.attachmentsButton.addEventListener("click", function () {
- _this3.switchView(SidebarView.ATTACHMENTS);
- });
- this.layersButton.addEventListener("click", function () {
- _this3.switchView(SidebarView.LAYERS);
- });
- this.layersButton.addEventListener("dblclick", function () {
- _this3.eventBus.dispatch("resetlayers", {
- source: _this3
- });
- });
-
- var onTreeLoaded = function onTreeLoaded(count, button, view) {
- button.disabled = !count;
-
- if (count) {
- _this3._showUINotification(view);
- } else if (_this3.active === view) {
- _this3.switchView(SidebarView.THUMBS);
- }
- };
-
- this.eventBus._on("outlineloaded", function (evt) {
- onTreeLoaded(evt.outlineCount, _this3.outlineButton, SidebarView.OUTLINE);
- });
-
- this.eventBus._on("attachmentsloaded", function (evt) {
- onTreeLoaded(evt.attachmentsCount, _this3.attachmentsButton, SidebarView.ATTACHMENTS);
- });
-
- this.eventBus._on("layersloaded", function (evt) {
- onTreeLoaded(evt.layersCount, _this3.layersButton, SidebarView.LAYERS);
- });
-
- this.eventBus._on("presentationmodechanged", function (evt) {
- if (!evt.active && !evt.switchInProgress && _this3.isThumbnailViewVisible) {
- _this3._updateThumbnailViewer();
- }
- });
- }
- }, {
- key: "visibleView",
- get: function get() {
- return this.isOpen ? this.active : SidebarView.NONE;
- }
- }, {
- key: "isThumbnailViewVisible",
- get: function get() {
- return this.isOpen && this.active === SidebarView.THUMBS;
- }
- }, {
- key: "isOutlineViewVisible",
- get: function get() {
- return this.isOpen && this.active === SidebarView.OUTLINE;
- }
- }, {
- key: "isAttachmentsViewVisible",
- get: function get() {
- return this.isOpen && this.active === SidebarView.ATTACHMENTS;
- }
- }, {
- key: "isLayersViewVisible",
- get: function get() {
- return this.isOpen && this.active === SidebarView.LAYERS;
- }
- }]);
-
- return PDFSidebar;
-}();
-
-exports.PDFSidebar = PDFSidebar;
-
-/***/ }),
-/* 13 */
-/***/ (function(module, exports, __webpack_require__) {
+/* 11 */
+/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
-"use strict";
-Object.defineProperty(exports, "__esModule", {
+Object.defineProperty(exports, "__esModule", ({
value: true
-});
+}));
exports.OverlayManager = void 0;
-var _regenerator = _interopRequireDefault(__webpack_require__(2));
+var _regenerator = _interopRequireDefault(__webpack_require__(4));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
@@ -6376,20 +6599,19 @@ var OverlayManager = /*#__PURE__*/function () {
exports.OverlayManager = OverlayManager;
/***/ }),
-/* 14 */
-/***/ (function(module, exports, __webpack_require__) {
+/* 12 */
+/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
-"use strict";
-Object.defineProperty(exports, "__esModule", {
+Object.defineProperty(exports, "__esModule", ({
value: true
-});
+}));
exports.PasswordPrompt = void 0;
-var _ui_utils = __webpack_require__(5);
+var _ui_utils = __webpack_require__(6);
-var _pdfjsLib = __webpack_require__(8);
+var _pdfjsLib = __webpack_require__(7);
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@@ -6479,24 +6701,23 @@ var PasswordPrompt = /*#__PURE__*/function () {
exports.PasswordPrompt = PasswordPrompt;
/***/ }),
-/* 15 */
-/***/ (function(module, exports, __webpack_require__) {
+/* 13 */
+/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
+
-"use strict";
+function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
-Object.defineProperty(exports, "__esModule", {
+Object.defineProperty(exports, "__esModule", ({
value: true
-});
+}));
exports.PDFAttachmentViewer = void 0;
-var _pdfjsLib = __webpack_require__(8);
-
-var _base_tree_viewer = __webpack_require__(16);
+var _pdfjsLib = __webpack_require__(7);
-var _viewer_compatibility = __webpack_require__(7);
+var _base_tree_viewer = __webpack_require__(14);
-function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
+var _viewer_compatibility = __webpack_require__(2);
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
@@ -6704,9 +6925,7 @@ var PDFAttachmentViewer = /*#__PURE__*/function (_BaseTreeViewer) {
_iterator.f();
}
- this.container.appendChild(fragment);
-
- this._dispatchEvent(attachmentsCount);
+ this._finishRendering(fragment, attachmentsCount);
}
}, {
key: "_appendAttachment",
@@ -6753,18 +6972,17 @@ var PDFAttachmentViewer = /*#__PURE__*/function (_BaseTreeViewer) {
exports.PDFAttachmentViewer = PDFAttachmentViewer;
/***/ }),
-/* 16 */
-/***/ (function(module, exports, __webpack_require__) {
+/* 14 */
+/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
-"use strict";
-Object.defineProperty(exports, "__esModule", {
+Object.defineProperty(exports, "__esModule", ({
value: true
-});
+}));
exports.BaseTreeViewer = void 0;
-var _pdfjsLib = __webpack_require__(8);
+var _pdfjsLib = __webpack_require__(7);
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
@@ -6778,6 +6996,9 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
+var TREEITEM_OFFSET_TOP = -100;
+var TREEITEM_SELECTED_CLASS = "selected";
+
var BaseTreeViewer = /*#__PURE__*/function () {
function BaseTreeViewer(options) {
_classCallCheck(this, BaseTreeViewer);
@@ -6794,7 +7015,9 @@ var BaseTreeViewer = /*#__PURE__*/function () {
_createClass(BaseTreeViewer, [{
key: "reset",
value: function reset() {
+ this._pdfDocument = null;
this._lastToggleIsShow = true;
+ this._currentTreeItem = null;
this.container.textContent = "";
this.container.classList.remove("treeWithDeepNesting");
}
@@ -6865,10 +7088,62 @@ var BaseTreeViewer = /*#__PURE__*/function () {
this._toggleTreeItem(this.container, !this._lastToggleIsShow);
}
}, {
+ key: "_finishRendering",
+ value: function _finishRendering(fragment, count) {
+ var hasAnyNesting = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
+
+ if (hasAnyNesting) {
+ this.container.classList.add("treeWithDeepNesting");
+ this._lastToggleIsShow = !fragment.querySelector(".treeItemsHidden");
+ }
+
+ this.container.appendChild(fragment);
+
+ this._dispatchEvent(count);
+ }
+ }, {
key: "render",
value: function render(params) {
throw new Error("Not implemented: render");
}
+ }, {
+ key: "_updateCurrentTreeItem",
+ value: function _updateCurrentTreeItem() {
+ var treeItem = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
+
+ if (this._currentTreeItem) {
+ this._currentTreeItem.classList.remove(TREEITEM_SELECTED_CLASS);
+
+ this._currentTreeItem = null;
+ }
+
+ if (treeItem) {
+ treeItem.classList.add(TREEITEM_SELECTED_CLASS);
+ this._currentTreeItem = treeItem;
+ }
+ }
+ }, {
+ key: "_scrollToCurrentTreeItem",
+ value: function _scrollToCurrentTreeItem(treeItem) {
+ if (!treeItem) {
+ return;
+ }
+
+ var currentNode = treeItem.parentNode;
+
+ while (currentNode && currentNode !== this.container) {
+ if (currentNode.classList.contains("treeItem")) {
+ var toggler = currentNode.firstElementChild;
+ toggler === null || toggler === void 0 ? void 0 : toggler.classList.remove("treeItemsHidden");
+ }
+
+ currentNode = currentNode.parentNode;
+ }
+
+ this._updateCurrentTreeItem(treeItem);
+
+ this.container.scrollTo(treeItem.offsetLeft, treeItem.offsetTop + TREEITEM_OFFSET_TOP);
+ }
}]);
return BaseTreeViewer;
@@ -6877,29 +7152,24 @@ var BaseTreeViewer = /*#__PURE__*/function () {
exports.BaseTreeViewer = BaseTreeViewer;
/***/ }),
-/* 17 */
-/***/ (function(module, exports, __webpack_require__) {
+/* 15 */
+/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
-"use strict";
-Object.defineProperty(exports, "__esModule", {
+Object.defineProperty(exports, "__esModule", ({
value: true
-});
+}));
exports.PDFDocumentProperties = void 0;
-var _regenerator = _interopRequireDefault(__webpack_require__(2));
+var _regenerator = _interopRequireDefault(__webpack_require__(4));
-var _pdfjsLib = __webpack_require__(8);
+var _pdfjsLib = __webpack_require__(7);
-var _ui_utils = __webpack_require__(5);
+var _ui_utils = __webpack_require__(6);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
-function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
-
-function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -6912,6 +7182,10 @@ function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
+function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
+
+function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
@@ -6974,85 +7248,124 @@ var PDFDocumentProperties = /*#__PURE__*/function () {
_createClass(PDFDocumentProperties, [{
key: "open",
- value: function open() {
- var _this2 = this;
+ value: function () {
+ var _open = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
+ var _this2 = this;
- var freezeFieldData = function freezeFieldData(data) {
- Object.defineProperty(_this2, "fieldData", {
- value: Object.freeze(data),
- writable: false,
- enumerable: true,
- configurable: true
- });
- };
+ var freezeFieldData, currentPageNumber, pagesRotation, _yield$this$pdfDocume, info, contentDispositionFilename, contentLength, _yield$Promise$all, _yield$Promise$all2, fileName, fileSize, creationDate, modificationDate, pageSize, isLinearized, _yield$this$pdfDocume2, length, data;
+
+ return _regenerator["default"].wrap(function _callee$(_context) {
+ while (1) {
+ switch (_context.prev = _context.next) {
+ case 0:
+ freezeFieldData = function freezeFieldData(data) {
+ Object.defineProperty(_this2, "fieldData", {
+ value: Object.freeze(data),
+ writable: false,
+ enumerable: true,
+ configurable: true
+ });
+ };
- Promise.all([this.overlayManager.open(this.overlayName), this._dataAvailableCapability.promise]).then(function () {
- var currentPageNumber = _this2._currentPageNumber;
- var pagesRotation = _this2._pagesRotation;
+ _context.next = 3;
+ return Promise.all([this.overlayManager.open(this.overlayName), this._dataAvailableCapability.promise]);
- if (_this2.fieldData && currentPageNumber === _this2.fieldData._currentPageNumber && pagesRotation === _this2.fieldData._pagesRotation) {
- _this2._updateUI();
+ case 3:
+ currentPageNumber = this._currentPageNumber;
+ pagesRotation = this._pagesRotation;
- return;
- }
+ if (!(this.fieldData && currentPageNumber === this.fieldData._currentPageNumber && pagesRotation === this.fieldData._pagesRotation)) {
+ _context.next = 8;
+ break;
+ }
- _this2.pdfDocument.getMetadata().then(function (_ref2) {
- var info = _ref2.info,
- metadata = _ref2.metadata,
- contentDispositionFilename = _ref2.contentDispositionFilename;
- return Promise.all([info, metadata, contentDispositionFilename || (0, _ui_utils.getPDFFileNameFromURL)(_this2.url), _this2._parseFileSize(_this2.maybeFileSize), _this2._parseDate(info.CreationDate), _this2._parseDate(info.ModDate), _this2.pdfDocument.getPage(currentPageNumber).then(function (pdfPage) {
- return _this2._parsePageSize((0, _ui_utils.getPageSizeInches)(pdfPage), pagesRotation);
- }), _this2._parseLinearization(info.IsLinearized)]);
- }).then(function (_ref3) {
- var _ref4 = _slicedToArray(_ref3, 8),
- info = _ref4[0],
- metadata = _ref4[1],
- fileName = _ref4[2],
- fileSize = _ref4[3],
- creationDate = _ref4[4],
- modDate = _ref4[5],
- pageSize = _ref4[6],
- isLinearized = _ref4[7];
-
- freezeFieldData({
- fileName: fileName,
- fileSize: fileSize,
- title: info.Title,
- author: info.Author,
- subject: info.Subject,
- keywords: info.Keywords,
- creationDate: creationDate,
- modificationDate: modDate,
- creator: info.Creator,
- producer: info.Producer,
- version: info.PDFFormatVersion,
- pageCount: _this2.pdfDocument.numPages,
- pageSize: pageSize,
- linearized: isLinearized,
- _currentPageNumber: currentPageNumber,
- _pagesRotation: pagesRotation
- });
+ this._updateUI();
+
+ return _context.abrupt("return");
- _this2._updateUI();
+ case 8:
+ _context.next = 10;
+ return this.pdfDocument.getMetadata();
- return _this2.pdfDocument.getDownloadInfo();
- }).then(function (_ref5) {
- var length = _ref5.length;
- _this2.maybeFileSize = length;
- return _this2._parseFileSize(length);
- }).then(function (fileSize) {
- if (fileSize === _this2.fieldData.fileSize) {
- return;
+ case 10:
+ _yield$this$pdfDocume = _context.sent;
+ info = _yield$this$pdfDocume.info;
+ contentDispositionFilename = _yield$this$pdfDocume.contentDispositionFilename;
+ contentLength = _yield$this$pdfDocume.contentLength;
+ _context.next = 16;
+ return Promise.all([contentDispositionFilename || (0, _ui_utils.getPDFFileNameFromURL)(this.url), this._parseFileSize(contentLength), this._parseDate(info.CreationDate), this._parseDate(info.ModDate), this.pdfDocument.getPage(currentPageNumber).then(function (pdfPage) {
+ return _this2._parsePageSize((0, _ui_utils.getPageSizeInches)(pdfPage), pagesRotation);
+ }), this._parseLinearization(info.IsLinearized)]);
+
+ case 16:
+ _yield$Promise$all = _context.sent;
+ _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 6);
+ fileName = _yield$Promise$all2[0];
+ fileSize = _yield$Promise$all2[1];
+ creationDate = _yield$Promise$all2[2];
+ modificationDate = _yield$Promise$all2[3];
+ pageSize = _yield$Promise$all2[4];
+ isLinearized = _yield$Promise$all2[5];
+ freezeFieldData({
+ fileName: fileName,
+ fileSize: fileSize,
+ title: info.Title,
+ author: info.Author,
+ subject: info.Subject,
+ keywords: info.Keywords,
+ creationDate: creationDate,
+ modificationDate: modificationDate,
+ creator: info.Creator,
+ producer: info.Producer,
+ version: info.PDFFormatVersion,
+ pageCount: this.pdfDocument.numPages,
+ pageSize: pageSize,
+ linearized: isLinearized,
+ _currentPageNumber: currentPageNumber,
+ _pagesRotation: pagesRotation
+ });
+
+ this._updateUI();
+
+ _context.next = 28;
+ return this.pdfDocument.getDownloadInfo();
+
+ case 28:
+ _yield$this$pdfDocume2 = _context.sent;
+ length = _yield$this$pdfDocume2.length;
+
+ if (!(contentLength === length)) {
+ _context.next = 32;
+ break;
+ }
+
+ return _context.abrupt("return");
+
+ case 32:
+ data = Object.assign(Object.create(null), this.fieldData);
+ _context.next = 35;
+ return this._parseFileSize(length);
+
+ case 35:
+ data.fileSize = _context.sent;
+ freezeFieldData(data);
+
+ this._updateUI();
+
+ case 38:
+ case "end":
+ return _context.stop();
+ }
}
+ }, _callee, this);
+ }));
- var data = Object.assign(Object.create(null), _this2.fieldData);
- data.fileSize = fileSize;
- freezeFieldData(data);
+ function open() {
+ return _open.apply(this, arguments);
+ }
- _this2._updateUI();
- });
- });
- }
+ return open;
+ }()
}, {
key: "close",
value: function close() {
@@ -7079,18 +7392,10 @@ var PDFDocumentProperties = /*#__PURE__*/function () {
this._dataAvailableCapability.resolve();
}
}, {
- key: "setFileSize",
- value: function setFileSize(fileSize) {
- if (Number.isInteger(fileSize) && fileSize > 0) {
- this.maybeFileSize = fileSize;
- }
- }
- }, {
key: "_reset",
value: function _reset() {
this.pdfDocument = null;
this.url = null;
- this.maybeFileSize = 0;
delete this.fieldData;
this._dataAvailableCapability = (0, _pdfjsLib.createPromiseCapability)();
this._currentPageNumber = 1;
@@ -7121,47 +7426,47 @@ var PDFDocumentProperties = /*#__PURE__*/function () {
}, {
key: "_parseFileSize",
value: function () {
- var _parseFileSize2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
+ var _parseFileSize2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
var fileSize,
kb,
- _args = arguments;
- return _regenerator["default"].wrap(function _callee$(_context) {
+ _args2 = arguments;
+ return _regenerator["default"].wrap(function _callee2$(_context2) {
while (1) {
- switch (_context.prev = _context.next) {
+ switch (_context2.prev = _context2.next) {
case 0:
- fileSize = _args.length > 0 && _args[0] !== undefined ? _args[0] : 0;
+ fileSize = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : 0;
kb = fileSize / 1024;
if (kb) {
- _context.next = 6;
+ _context2.next = 6;
break;
}
- return _context.abrupt("return", undefined);
+ return _context2.abrupt("return", undefined);
case 6:
if (!(kb < 1024)) {
- _context.next = 8;
+ _context2.next = 8;
break;
}
- return _context.abrupt("return", this.l10n.get("document_properties_kb", {
+ return _context2.abrupt("return", this.l10n.get("document_properties_kb", {
size_kb: (+kb.toPrecision(3)).toLocaleString(),
size_b: fileSize.toLocaleString()
}, "{{size_kb}} KB ({{size_b}} bytes)"));
case 8:
- return _context.abrupt("return", this.l10n.get("document_properties_mb", {
+ return _context2.abrupt("return", this.l10n.get("document_properties_mb", {
size_mb: (+(kb / 1024).toPrecision(3)).toLocaleString(),
size_b: fileSize.toLocaleString()
}, "{{size_mb}} MB ({{size_b}} bytes)"));
case 9:
case "end":
- return _context.stop();
+ return _context2.stop();
}
}
- }, _callee, this);
+ }, _callee2, this);
}));
function _parseFileSize() {
@@ -7173,20 +7478,20 @@ var PDFDocumentProperties = /*#__PURE__*/function () {
}, {
key: "_parsePageSize",
value: function () {
- var _parsePageSize2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(pageSizeInches, pagesRotation) {
+ var _parsePageSize2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3(pageSizeInches, pagesRotation) {
var _this3 = this;
var isPortrait, sizeInches, sizeMillimeters, pageName, rawName, exactMillimeters, intMillimeters;
- return _regenerator["default"].wrap(function _callee2$(_context2) {
+ return _regenerator["default"].wrap(function _callee3$(_context3) {
while (1) {
- switch (_context2.prev = _context2.next) {
+ switch (_context3.prev = _context3.next) {
case 0:
if (pageSizeInches) {
- _context2.next = 2;
+ _context3.next = 2;
break;
}
- return _context2.abrupt("return", undefined);
+ return _context3.abrupt("return", undefined);
case 2:
if (pagesRotation % 180 !== 0) {
@@ -7235,14 +7540,14 @@ var PDFDocumentProperties = /*#__PURE__*/function () {
pageName = this.l10n.get("document_properties_page_size_name_" + rawName.toLowerCase(), null, rawName);
}
- return _context2.abrupt("return", Promise.all([this._isNonMetricLocale ? sizeInches : sizeMillimeters, this.l10n.get("document_properties_page_size_unit_" + (this._isNonMetricLocale ? "inches" : "millimeters"), null, this._isNonMetricLocale ? "in" : "mm"), pageName, this.l10n.get("document_properties_page_size_orientation_" + (isPortrait ? "portrait" : "landscape"), null, isPortrait ? "portrait" : "landscape")]).then(function (_ref6) {
- var _ref7 = _slicedToArray(_ref6, 4),
- _ref7$ = _ref7[0],
- width = _ref7$.width,
- height = _ref7$.height,
- unit = _ref7[1],
- name = _ref7[2],
- orientation = _ref7[3];
+ return _context3.abrupt("return", Promise.all([this._isNonMetricLocale ? sizeInches : sizeMillimeters, this.l10n.get("document_properties_page_size_unit_" + (this._isNonMetricLocale ? "inches" : "millimeters"), null, this._isNonMetricLocale ? "in" : "mm"), pageName, this.l10n.get("document_properties_page_size_orientation_" + (isPortrait ? "portrait" : "landscape"), null, isPortrait ? "portrait" : "landscape")]).then(function (_ref2) {
+ var _ref3 = _slicedToArray(_ref2, 4),
+ _ref3$ = _ref3[0],
+ width = _ref3$.width,
+ height = _ref3$.height,
+ unit = _ref3[1],
+ name = _ref3[2],
+ orientation = _ref3[3];
return _this3.l10n.get("document_properties_page_size_dimension_" + (name ? "name_" : "") + "string", {
width: width.toLocaleString(),
@@ -7255,10 +7560,10 @@ var PDFDocumentProperties = /*#__PURE__*/function () {
case 11:
case "end":
- return _context2.stop();
+ return _context3.stop();
}
}
- }, _callee2, this);
+ }, _callee3, this);
}));
function _parsePageSize(_x, _x2) {
@@ -7270,33 +7575,33 @@ var PDFDocumentProperties = /*#__PURE__*/function () {
}, {
key: "_parseDate",
value: function () {
- var _parseDate2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3(inputDate) {
+ var _parseDate2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4(inputDate) {
var dateObject;
- return _regenerator["default"].wrap(function _callee3$(_context3) {
+ return _regenerator["default"].wrap(function _callee4$(_context4) {
while (1) {
- switch (_context3.prev = _context3.next) {
+ switch (_context4.prev = _context4.next) {
case 0:
dateObject = _pdfjsLib.PDFDateString.toDateObject(inputDate);
if (dateObject) {
- _context3.next = 3;
+ _context4.next = 3;
break;
}
- return _context3.abrupt("return", undefined);
+ return _context4.abrupt("return", undefined);
case 3:
- return _context3.abrupt("return", this.l10n.get("document_properties_date_string", {
+ return _context4.abrupt("return", this.l10n.get("document_properties_date_string", {
date: dateObject.toLocaleDateString(),
time: dateObject.toLocaleTimeString()
}, "{{date}}, {{time}}"));
case 4:
case "end":
- return _context3.stop();
+ return _context4.stop();
}
}
- }, _callee3, this);
+ }, _callee4, this);
}));
function _parseDate(_x3) {
@@ -7318,20 +7623,19 @@ var PDFDocumentProperties = /*#__PURE__*/function () {
exports.PDFDocumentProperties = PDFDocumentProperties;
/***/ }),
-/* 18 */
-/***/ (function(module, exports, __webpack_require__) {
+/* 16 */
+/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
-"use strict";
-Object.defineProperty(exports, "__esModule", {
+Object.defineProperty(exports, "__esModule", ({
value: true
-});
+}));
exports.PDFFindBar = void 0;
-var _pdf_find_controller = __webpack_require__(19);
+var _pdf_find_controller = __webpack_require__(17);
-var _ui_utils = __webpack_require__(5);
+var _ui_utils = __webpack_require__(6);
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@@ -7426,7 +7730,6 @@ var PDFFindBar = /*#__PURE__*/function () {
value: function updateUIState(state, previous, matchesCount) {
var _this2 = this;
- var notFound = false;
var findMsg = "";
var status = "";
@@ -7440,7 +7743,7 @@ var PDFFindBar = /*#__PURE__*/function () {
case _pdf_find_controller.FindState.NOT_FOUND:
findMsg = this.l10n.get("find_not_found", null, "Phrase not found");
- notFound = true;
+ status = "notFound";
break;
case _pdf_find_controller.FindState.WRAPPED:
@@ -7453,7 +7756,6 @@ var PDFFindBar = /*#__PURE__*/function () {
break;
}
- this.findField.classList.toggle("notFound", notFound);
this.findField.setAttribute("data-status", status);
Promise.resolve(findMsg).then(function (msg) {
_this2.findMsg.textContent = msg;
@@ -7561,22 +7863,21 @@ var PDFFindBar = /*#__PURE__*/function () {
exports.PDFFindBar = PDFFindBar;
/***/ }),
-/* 19 */
-/***/ (function(module, exports, __webpack_require__) {
+/* 17 */
+/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
-"use strict";
-Object.defineProperty(exports, "__esModule", {
+Object.defineProperty(exports, "__esModule", ({
value: true
-});
+}));
exports.PDFFindController = exports.FindState = void 0;
-var _pdfjsLib = __webpack_require__(8);
+var _pdfjsLib = __webpack_require__(7);
-var _pdf_find_utils = __webpack_require__(20);
+var _pdf_find_utils = __webpack_require__(18);
-var _ui_utils = __webpack_require__(5);
+var _ui_utils = __webpack_require__(6);
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@@ -7584,6 +7885,20 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
+function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
+
+function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
+
+function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
+
+function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
+
+function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
+
+function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
+
+function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
+
var FindState = {
FOUND: 0,
NOT_FOUND: 1,
@@ -7615,9 +7930,58 @@ function normalize(text) {
normalizationRegex = new RegExp("[".concat(replace, "]"), "g");
}
- return text.replace(normalizationRegex, function (ch) {
- return CHARACTERS_TO_NORMALIZE[ch];
+ var diffs = null;
+ var normalizedText = text.replace(normalizationRegex, function (ch, index) {
+ var normalizedCh = CHARACTERS_TO_NORMALIZE[ch],
+ diff = normalizedCh.length - ch.length;
+
+ if (diff !== 0) {
+ (diffs || (diffs = [])).push([index, diff]);
+ }
+
+ return normalizedCh;
});
+ return [normalizedText, diffs];
+}
+
+function getOriginalIndex(matchIndex) {
+ var diffs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
+
+ if (!diffs) {
+ return matchIndex;
+ }
+
+ var totalDiff = 0;
+
+ var _iterator = _createForOfIteratorHelper(diffs),
+ _step;
+
+ try {
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
+ var _step$value = _slicedToArray(_step.value, 2),
+ index = _step$value[0],
+ diff = _step$value[1];
+
+ var currentIndex = index + totalDiff;
+
+ if (currentIndex >= matchIndex) {
+ break;
+ }
+
+ if (currentIndex + diff > matchIndex) {
+ totalDiff += matchIndex - currentIndex;
+ break;
+ }
+
+ totalDiff += diff;
+ }
+ } catch (err) {
+ _iterator.e(err);
+ } finally {
+ _iterator.f();
+ }
+
+ return matchIndex - totalDiff;
}
var PDFFindController = /*#__PURE__*/function () {
@@ -7758,6 +8122,7 @@ var PDFFindController = /*#__PURE__*/function () {
};
this._extractTextPromises = [];
this._pageContents = [];
+ this._pageDiffs = [];
this._matchesCountTotal = 0;
this._pagesToSearch = null;
this._pendingFindMatches = Object.create(null);
@@ -7864,8 +8229,9 @@ var PDFFindController = /*#__PURE__*/function () {
}
}, {
key: "_calculatePhraseMatch",
- value: function _calculatePhraseMatch(query, pageIndex, pageContent, entireWord) {
- var matches = [];
+ value: function _calculatePhraseMatch(query, pageIndex, pageContent, pageDiffs, entireWord) {
+ var matches = [],
+ matchesLength = [];
var queryLen = query.length;
var matchIdx = -queryLen;
@@ -7880,14 +8246,19 @@ var PDFFindController = /*#__PURE__*/function () {
continue;
}
- matches.push(matchIdx);
+ var originalMatchIdx = getOriginalIndex(matchIdx, pageDiffs),
+ matchEnd = matchIdx + queryLen - 1,
+ originalQueryLen = getOriginalIndex(matchEnd, pageDiffs) - originalMatchIdx + 1;
+ matches.push(originalMatchIdx);
+ matchesLength.push(originalQueryLen);
}
this._pageMatches[pageIndex] = matches;
+ this._pageMatchesLength[pageIndex] = matchesLength;
}
}, {
key: "_calculateWordMatch",
- value: function _calculateWordMatch(query, pageIndex, pageContent, entireWord) {
+ value: function _calculateWordMatch(query, pageIndex, pageContent, pageDiffs, entireWord) {
var matchesWithLength = [];
var queryArray = query.match(/\S+/g);
@@ -7907,9 +8278,12 @@ var PDFFindController = /*#__PURE__*/function () {
continue;
}
+ var originalMatchIdx = getOriginalIndex(matchIdx, pageDiffs),
+ matchEnd = matchIdx + subqueryLen - 1,
+ originalQueryLen = getOriginalIndex(matchEnd, pageDiffs) - originalMatchIdx + 1;
matchesWithLength.push({
- match: matchIdx,
- matchLength: subqueryLen,
+ match: originalMatchIdx,
+ matchLength: originalQueryLen,
skipped: false
});
}
@@ -7924,6 +8298,7 @@ var PDFFindController = /*#__PURE__*/function () {
key: "_calculateMatch",
value: function _calculateMatch(pageIndex) {
var pageContent = this._pageContents[pageIndex];
+ var pageDiffs = this._pageDiffs[pageIndex];
var query = this._query;
var _this$_state = this._state,
caseSensitive = _this$_state.caseSensitive,
@@ -7940,9 +8315,9 @@ var PDFFindController = /*#__PURE__*/function () {
}
if (phraseSearch) {
- this._calculatePhraseMatch(query, pageIndex, pageContent, entireWord);
+ this._calculatePhraseMatch(query, pageIndex, pageContent, pageDiffs, entireWord);
} else {
- this._calculateWordMatch(query, pageIndex, pageContent, entireWord);
+ this._calculateWordMatch(query, pageIndex, pageContent, pageDiffs, entireWord);
}
if (this._state.highlightAll) {
@@ -7990,11 +8365,17 @@ var PDFFindController = /*#__PURE__*/function () {
strBuf.push(textItems[j].str);
}
- _this2._pageContents[i] = normalize(strBuf.join(""));
+ var _normalize = normalize(strBuf.join(""));
+
+ var _normalize2 = _slicedToArray(_normalize, 2);
+
+ _this2._pageContents[i] = _normalize2[0];
+ _this2._pageDiffs[i] = _normalize2[1];
extractTextCapability.resolve(i);
}, function (reason) {
console.error("Unable to get text content for page ".concat(i + 1), reason);
_this2._pageContents[i] = "";
+ _this2._pageDiffs[i] = null;
extractTextCapability.resolve(i);
});
});
@@ -8284,7 +8665,12 @@ var PDFFindController = /*#__PURE__*/function () {
get: function get() {
if (this._state.query !== this._rawQuery) {
this._rawQuery = this._state.query;
- this._normalizedQuery = normalize(this._state.query);
+
+ var _normalize3 = normalize(this._state.query);
+
+ var _normalize4 = _slicedToArray(_normalize3, 1);
+
+ this._normalizedQuery = _normalize4[0];
}
return this._normalizedQuery;
@@ -8297,15 +8683,14 @@ var PDFFindController = /*#__PURE__*/function () {
exports.PDFFindController = PDFFindController;
/***/ }),
-/* 20 */
-/***/ (function(module, exports, __webpack_require__) {
+/* 18 */
+/***/ ((__unused_webpack_module, exports) => {
-"use strict";
-Object.defineProperty(exports, "__esModule", {
+Object.defineProperty(exports, "__esModule", ({
value: true
-});
+}));
exports.getCharacterType = getCharacterType;
exports.CharacterType = void 0;
var CharacterType = {
@@ -8393,20 +8778,19 @@ function getCharacterType(charCode) {
}
/***/ }),
-/* 21 */
-/***/ (function(module, exports, __webpack_require__) {
+/* 19 */
+/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
-"use strict";
-Object.defineProperty(exports, "__esModule", {
+Object.defineProperty(exports, "__esModule", ({
value: true
-});
-exports.isDestHashesEqual = isDestHashesEqual;
+}));
exports.isDestArraysEqual = isDestArraysEqual;
+exports.isDestHashesEqual = isDestHashesEqual;
exports.PDFHistory = void 0;
-var _ui_utils = __webpack_require__(5);
+var _ui_utils = __webpack_require__(6);
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
@@ -8454,19 +8838,17 @@ var PDFHistory = /*#__PURE__*/function () {
this._isViewerInPresentationMode = false;
this.eventBus._on("presentationmodechanged", function (evt) {
- _this._isViewerInPresentationMode = evt.active || evt.switchInProgress;
+ _this._isViewerInPresentationMode = evt.state !== _ui_utils.PresentationModeState.NORMAL;
});
this.eventBus._on("pagesinit", function () {
_this._isPagesLoaded = false;
- var onPagesLoaded = function onPagesLoaded(evt) {
- _this.eventBus._off("pagesloaded", onPagesLoaded);
-
+ _this.eventBus._on("pagesloaded", function (evt) {
_this._isPagesLoaded = !!evt.pagesCount;
- };
-
- _this.eventBus._on("pagesloaded", onPagesLoaded);
+ }, {
+ once: true
+ });
});
}
@@ -8529,10 +8911,6 @@ var PDFHistory = /*#__PURE__*/function () {
this._updateInternalState(destination, state.uid, true);
- if (this._uid > this._maxUid) {
- this._maxUid = this._uid;
- }
-
if (destination.rotation !== undefined) {
this._initialRotation = destination.rotation;
}
@@ -8627,6 +9005,42 @@ var PDFHistory = /*#__PURE__*/function () {
}
}
}, {
+ key: "pushPage",
+ value: function pushPage(pageNumber) {
+ var _this$_destination,
+ _this3 = this;
+
+ if (!this._initialized) {
+ return;
+ }
+
+ if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.linkService.pagesCount)) {
+ console.error("PDFHistory.pushPage: \"".concat(pageNumber, "\" is not a valid page number."));
+ return;
+ }
+
+ if (((_this$_destination = this._destination) === null || _this$_destination === void 0 ? void 0 : _this$_destination.page) === pageNumber) {
+ return;
+ }
+
+ if (this._popStateInProgress) {
+ return;
+ }
+
+ this._pushOrReplaceState({
+ hash: "page=".concat(pageNumber),
+ page: pageNumber,
+ rotation: this.linkService.rotation
+ });
+
+ if (!this._popStateInProgress) {
+ this._popStateInProgress = true;
+ Promise.resolve().then(function () {
+ _this3._popStateInProgress = false;
+ });
+ }
+ }
+ }, {
key: "pushCurrentPosition",
value: function pushCurrentPosition() {
if (!this._initialized || this._popStateInProgress) {
@@ -8676,7 +9090,7 @@ var PDFHistory = /*#__PURE__*/function () {
var newUrl;
- if (this._updateUrl && destination && destination.hash) {
+ if (this._updateUrl && destination !== null && destination !== void 0 && destination.hash) {
var baseUrl = document.location.href.split("#")[0];
if (!baseUrl.startsWith("file://")) {
@@ -8687,7 +9101,6 @@ var PDFHistory = /*#__PURE__*/function () {
if (shouldReplace) {
window.history.replaceState(newState, "", newUrl);
} else {
- this._maxUid = this._uid;
window.history.pushState(newState, "", newUrl);
}
}
@@ -8758,7 +9171,7 @@ var PDFHistory = /*#__PURE__*/function () {
_performance$getEntri2 = _slicedToArray(_performance$getEntri, 1),
perfEntry = _performance$getEntri2[0];
- if (!perfEntry || perfEntry.type !== "reload") {
+ if ((perfEntry === null || perfEntry === void 0 ? void 0 : perfEntry.type) !== "reload") {
return false;
}
} else {
@@ -8786,12 +9199,13 @@ var PDFHistory = /*#__PURE__*/function () {
this._updateViewareaTimeout = null;
}
- if (removeTemporary && destination && destination.temporary) {
+ if (removeTemporary && destination !== null && destination !== void 0 && destination.temporary) {
delete destination.temporary;
}
this._destination = destination;
this._uid = uid;
+ this._maxUid = Math.max(this._maxUid, uid);
this._numPositionUpdates = 0;
}
}, {
@@ -8816,7 +9230,7 @@ var PDFHistory = /*#__PURE__*/function () {
}, {
key: "_updateViewarea",
value: function _updateViewarea(_ref4) {
- var _this3 = this;
+ var _this4 = this;
var location = _ref4.location;
@@ -8842,18 +9256,18 @@ var PDFHistory = /*#__PURE__*/function () {
if (UPDATE_VIEWAREA_TIMEOUT > 0) {
this._updateViewareaTimeout = setTimeout(function () {
- if (!_this3._popStateInProgress) {
- _this3._tryPushCurrentPosition(true);
+ if (!_this4._popStateInProgress) {
+ _this4._tryPushCurrentPosition(true);
}
- _this3._updateViewareaTimeout = null;
+ _this4._updateViewareaTimeout = null;
}, UPDATE_VIEWAREA_TIMEOUT);
}
}
}, {
key: "_popState",
value: function _popState(_ref5) {
- var _this4 = this;
+ var _this5 = this;
var state = _ref5.state;
var newHash = getCurrentHash(),
@@ -8890,7 +9304,7 @@ var PDFHistory = /*#__PURE__*/function () {
name: "hashchange",
delay: HASH_CHANGE_TIMEOUT
}).then(function () {
- _this4._blockHashChange--;
+ _this5._blockHashChange--;
});
}
@@ -8898,16 +9312,12 @@ var PDFHistory = /*#__PURE__*/function () {
this._updateInternalState(destination, state.uid, true);
- if (this._uid > this._maxUid) {
- this._maxUid = this._uid;
- }
-
if ((0, _ui_utils.isValidRotation)(destination.rotation)) {
this.linkService.rotation = destination.rotation;
}
if (destination.dest) {
- this.linkService.navigateTo(destination.dest);
+ this.linkService.goToDestination(destination.dest);
} else if (destination.hash) {
this.linkService.setHash(destination.hash);
} else if (destination.page) {
@@ -8915,7 +9325,7 @@ var PDFHistory = /*#__PURE__*/function () {
}
Promise.resolve().then(function () {
- _this4._popStateInProgress = false;
+ _this5._popStateInProgress = false;
});
}
}, {
@@ -9042,20 +9452,19 @@ function isDestArraysEqual(firstDest, secondDest) {
}
/***/ }),
-/* 22 */
-/***/ (function(module, exports, __webpack_require__) {
+/* 20 */
+/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
-"use strict";
-Object.defineProperty(exports, "__esModule", {
+Object.defineProperty(exports, "__esModule", ({
value: true
-});
+}));
exports.PDFLayerViewer = void 0;
-var _regenerator = _interopRequireDefault(__webpack_require__(2));
+var _regenerator = _interopRequireDefault(__webpack_require__(4));
-var _base_tree_viewer = __webpack_require__(16);
+var _base_tree_viewer = __webpack_require__(14);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
@@ -9121,7 +9530,6 @@ var PDFLayerViewer = /*#__PURE__*/function (_BaseTreeViewer) {
_get(_getPrototypeOf(PDFLayerViewer.prototype), "reset", this).call(this);
this._optionalContentConfig = null;
- this._pdfDocument = null;
}
}, {
key: "_dispatchEvent",
@@ -9305,14 +9713,7 @@ var PDFLayerViewer = /*#__PURE__*/function (_BaseTreeViewer) {
}
}
- if (hasAnyNesting) {
- this.container.classList.add("treeWithDeepNesting");
- this._lastToggleIsShow = fragment.querySelectorAll(".treeItemsHidden").length === 0;
- }
-
- this.container.appendChild(fragment);
-
- this._dispatchEvent(layersCount);
+ this._finishRendering(fragment, layersCount, hasAnyNesting);
}
}, {
key: "_resetLayers",
@@ -9367,21 +9768,28 @@ var PDFLayerViewer = /*#__PURE__*/function (_BaseTreeViewer) {
exports.PDFLayerViewer = PDFLayerViewer;
/***/ }),
-/* 23 */
-/***/ (function(module, exports, __webpack_require__) {
+/* 21 */
+/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
-"use strict";
-Object.defineProperty(exports, "__esModule", {
+Object.defineProperty(exports, "__esModule", ({
value: true
-});
+}));
exports.SimpleLinkService = exports.PDFLinkService = void 0;
-var _ui_utils = __webpack_require__(5);
+var _regenerator = _interopRequireDefault(__webpack_require__(4));
+
+var _ui_utils = __webpack_require__(6);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
+function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
+
+function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
@@ -9436,95 +9844,160 @@ var PDFLinkService = /*#__PURE__*/function () {
}, {
key: "navigateTo",
value: function navigateTo(dest) {
+ console.error("Deprecated method: `navigateTo`, use `goToDestination` instead.");
+ this.goToDestination(dest);
+ }
+ }, {
+ key: "_goToDestinationHelper",
+ value: function _goToDestinationHelper(rawDest) {
var _this = this;
- var goToDestination = function goToDestination(_ref2) {
- var namedDest = _ref2.namedDest,
- explicitDest = _ref2.explicitDest;
- var destRef = explicitDest[0];
- var pageNumber;
-
- if (destRef instanceof Object) {
- pageNumber = _this._cachedPageNumber(destRef);
+ var namedDest = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
+ var explicitDest = arguments.length > 2 ? arguments[2] : undefined;
+ var destRef = explicitDest[0];
+ var pageNumber;
- if (pageNumber === null) {
- _this.pdfDocument.getPageIndex(destRef).then(function (pageIndex) {
- _this.cachePageRef(pageIndex + 1, destRef);
+ if (destRef instanceof Object) {
+ pageNumber = this._cachedPageNumber(destRef);
- goToDestination({
- namedDest: namedDest,
- explicitDest: explicitDest
- });
- })["catch"](function () {
- console.error("PDFLinkService.navigateTo: \"".concat(destRef, "\" is not ") + "a valid page reference, for dest=\"".concat(dest, "\"."));
- });
+ if (pageNumber === null) {
+ this.pdfDocument.getPageIndex(destRef).then(function (pageIndex) {
+ _this.cachePageRef(pageIndex + 1, destRef);
- return;
- }
- } else if (Number.isInteger(destRef)) {
- pageNumber = destRef + 1;
- } else {
- console.error("PDFLinkService.navigateTo: \"".concat(destRef, "\" is not ") + "a valid destination reference, for dest=\"".concat(dest, "\"."));
+ _this._goToDestinationHelper(rawDest, namedDest, explicitDest);
+ })["catch"](function () {
+ console.error("PDFLinkService._goToDestinationHelper: \"".concat(destRef, "\" is not ") + "a valid page reference, for dest=\"".concat(rawDest, "\"."));
+ });
return;
}
+ } else if (Number.isInteger(destRef)) {
+ pageNumber = destRef + 1;
+ } else {
+ console.error("PDFLinkService._goToDestinationHelper: \"".concat(destRef, "\" is not ") + "a valid destination reference, for dest=\"".concat(rawDest, "\"."));
+ return;
+ }
- if (!pageNumber || pageNumber < 1 || pageNumber > _this.pagesCount) {
- console.error("PDFLinkService.navigateTo: \"".concat(pageNumber, "\" is not ") + "a valid page number, for dest=\"".concat(dest, "\"."));
- return;
- }
+ if (!pageNumber || pageNumber < 1 || pageNumber > this.pagesCount) {
+ console.error("PDFLinkService._goToDestinationHelper: \"".concat(pageNumber, "\" is not ") + "a valid page number, for dest=\"".concat(rawDest, "\"."));
+ return;
+ }
- if (_this.pdfHistory) {
- _this.pdfHistory.pushCurrentPosition();
+ if (this.pdfHistory) {
+ this.pdfHistory.pushCurrentPosition();
+ this.pdfHistory.push({
+ namedDest: namedDest,
+ explicitDest: explicitDest,
+ pageNumber: pageNumber
+ });
+ }
- _this.pdfHistory.push({
- namedDest: namedDest,
- explicitDest: explicitDest,
- pageNumber: pageNumber
- });
- }
+ this.pdfViewer.scrollPageIntoView({
+ pageNumber: pageNumber,
+ destArray: explicitDest,
+ ignoreDestinationZoom: this._ignoreDestinationZoom
+ });
+ }
+ }, {
+ key: "goToDestination",
+ value: function () {
+ var _goToDestination = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(dest) {
+ var namedDest, explicitDest;
+ return _regenerator["default"].wrap(function _callee$(_context) {
+ while (1) {
+ switch (_context.prev = _context.next) {
+ case 0:
+ if (this.pdfDocument) {
+ _context.next = 2;
+ break;
+ }
- _this.pdfViewer.scrollPageIntoView({
- pageNumber: pageNumber,
- destArray: explicitDest,
- ignoreDestinationZoom: _this._ignoreDestinationZoom
- });
- };
+ return _context.abrupt("return");
- new Promise(function (resolve, reject) {
- if (typeof dest === "string") {
- _this.pdfDocument.getDestination(dest).then(function (destArray) {
- resolve({
- namedDest: dest,
- explicitDest: destArray
- });
- });
+ case 2:
+ if (!(typeof dest === "string")) {
+ _context.next = 9;
+ break;
+ }
- return;
- }
+ namedDest = dest;
+ _context.next = 6;
+ return this.pdfDocument.getDestination(dest);
- resolve({
- namedDest: "",
- explicitDest: dest
- });
- }).then(function (data) {
- if (!Array.isArray(data.explicitDest)) {
- console.error("PDFLinkService.navigateTo: \"".concat(data.explicitDest, "\" is") + " not a valid destination array, for dest=\"".concat(dest, "\"."));
- return;
- }
+ case 6:
+ explicitDest = _context.sent;
+ _context.next = 13;
+ break;
- goToDestination(data);
+ case 9:
+ namedDest = null;
+ _context.next = 12;
+ return dest;
+
+ case 12:
+ explicitDest = _context.sent;
+
+ case 13:
+ if (Array.isArray(explicitDest)) {
+ _context.next = 16;
+ break;
+ }
+
+ console.error("PDFLinkService.goToDestination: \"".concat(explicitDest, "\" is not ") + "a valid destination array, for dest=\"".concat(dest, "\"."));
+ return _context.abrupt("return");
+
+ case 16:
+ this._goToDestinationHelper(dest, namedDest, explicitDest);
+
+ case 17:
+ case "end":
+ return _context.stop();
+ }
+ }
+ }, _callee, this);
+ }));
+
+ function goToDestination(_x) {
+ return _goToDestination.apply(this, arguments);
+ }
+
+ return goToDestination;
+ }()
+ }, {
+ key: "goToPage",
+ value: function goToPage(val) {
+ if (!this.pdfDocument) {
+ return;
+ }
+
+ var pageNumber = typeof val === "string" && this.pdfViewer.pageLabelToPageNumber(val) || val | 0;
+
+ if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.pagesCount)) {
+ console.error("PDFLinkService.goToPage: \"".concat(val, "\" is not a valid page."));
+ return;
+ }
+
+ if (this.pdfHistory) {
+ this.pdfHistory.pushCurrentPosition();
+ this.pdfHistory.pushPage(pageNumber);
+ }
+
+ this.pdfViewer.scrollPageIntoView({
+ pageNumber: pageNumber
});
}
}, {
key: "getDestinationHash",
value: function getDestinationHash(dest) {
if (typeof dest === "string") {
- return this.getAnchorUrl("#" + escape(dest));
- }
-
- if (Array.isArray(dest)) {
+ if (dest.length > 0) {
+ return this.getAnchorUrl("#" + escape(dest));
+ }
+ } else if (Array.isArray(dest)) {
var str = JSON.stringify(dest);
- return this.getAnchorUrl("#" + escape(str));
+
+ if (str.length > 0) {
+ return this.getAnchorUrl("#" + escape(str));
+ }
}
return this.getAnchorUrl("");
@@ -9537,6 +10010,10 @@ var PDFLinkService = /*#__PURE__*/function () {
}, {
key: "setHash",
value: function setHash(hash) {
+ if (!this.pdfDocument) {
+ return;
+ }
+
var pageNumber, dest;
if (hash.includes("=")) {
@@ -9604,7 +10081,7 @@ var PDFLinkService = /*#__PURE__*/function () {
}
if ("nameddest" in params) {
- this.navigateTo(params.nameddest);
+ this.goToDestination(params.nameddest);
}
} else {
dest = unescape(hash);
@@ -9618,7 +10095,7 @@ var PDFLinkService = /*#__PURE__*/function () {
} catch (ex) {}
if (typeof dest === "string" || isValidExplicitDestination(dest)) {
- this.navigateTo(dest);
+ this.goToDestination(dest);
return;
}
@@ -9644,17 +10121,11 @@ var PDFLinkService = /*#__PURE__*/function () {
break;
case "NextPage":
- if (this.page < this.pagesCount) {
- this.page++;
- }
-
+ this.pdfViewer.nextPage();
break;
case "PrevPage":
- if (this.page > 1) {
- this.page--;
- }
-
+ this.pdfViewer.previousPage();
break;
case "LastPage":
@@ -9696,6 +10167,11 @@ var PDFLinkService = /*#__PURE__*/function () {
return this.pdfViewer.isPageVisible(pageNumber);
}
}, {
+ key: "isPageCached",
+ value: function isPageCached(pageNumber) {
+ return this.pdfViewer.isPageCached(pageNumber);
+ }
+ }, {
key: "pagesCount",
get: function get() {
return this.pdfDocument ? this.pdfDocument.numPages : 0;
@@ -9804,8 +10280,29 @@ var SimpleLinkService = /*#__PURE__*/function () {
}
_createClass(SimpleLinkService, [{
- key: "navigateTo",
- value: function navigateTo(dest) {}
+ key: "goToDestination",
+ value: function () {
+ var _goToDestination2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(dest) {
+ return _regenerator["default"].wrap(function _callee2$(_context2) {
+ while (1) {
+ switch (_context2.prev = _context2.next) {
+ case 0:
+ case "end":
+ return _context2.stop();
+ }
+ }
+ }, _callee2);
+ }));
+
+ function goToDestination(_x2) {
+ return _goToDestination2.apply(this, arguments);
+ }
+
+ return goToDestination;
+ }()
+ }, {
+ key: "goToPage",
+ value: function goToPage(val) {}
}, {
key: "getDestinationHash",
value: function getDestinationHash(dest) {
@@ -9831,6 +10328,11 @@ var SimpleLinkService = /*#__PURE__*/function () {
return true;
}
}, {
+ key: "isPageCached",
+ value: function isPageCached(pageNumber) {
+ return true;
+ }
+ }, {
key: "pagesCount",
get: function get() {
return 0;
@@ -9855,27 +10357,52 @@ var SimpleLinkService = /*#__PURE__*/function () {
exports.SimpleLinkService = SimpleLinkService;
/***/ }),
-/* 24 */
-/***/ (function(module, exports, __webpack_require__) {
+/* 22 */
+/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
-"use strict";
-Object.defineProperty(exports, "__esModule", {
+Object.defineProperty(exports, "__esModule", ({
value: true
-});
+}));
exports.PDFOutlineViewer = void 0;
-var _pdfjsLib = __webpack_require__(8);
+var _regenerator = _interopRequireDefault(__webpack_require__(4));
+
+var _pdfjsLib = __webpack_require__(7);
+
+var _base_tree_viewer = __webpack_require__(14);
-var _base_tree_viewer = __webpack_require__(16);
+var _ui_utils = __webpack_require__(6);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
-function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
+function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
+
+function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
+
+function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
+
+function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
+
+function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
+
+function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
+
+function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
+
+function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
+
+function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
+function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
+
+function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@@ -9917,6 +10444,20 @@ var PDFOutlineViewer = /*#__PURE__*/function (_BaseTreeViewer) {
_this.eventBus._on("toggleoutlinetree", _this._toggleAllTreeItems.bind(_assertThisInitialized(_this)));
+ _this.eventBus._on("currentoutlineitem", _this._currentOutlineItem.bind(_assertThisInitialized(_this)));
+
+ _this.eventBus._on("pagechanging", function (evt) {
+ _this._currentPageNumber = evt.pageNumber;
+ });
+
+ _this.eventBus._on("pagesloaded", function (evt) {
+ _this._isPagesLoaded = !!evt.pagesCount;
+ });
+
+ _this.eventBus._on("sidebarviewchanged", function (evt) {
+ _this._sidebarView = evt.view;
+ });
+
return _this;
}
@@ -9926,18 +10467,26 @@ var PDFOutlineViewer = /*#__PURE__*/function (_BaseTreeViewer) {
_get(_getPrototypeOf(PDFOutlineViewer.prototype), "reset", this).call(this);
this._outline = null;
+ this._pageNumberToDestHashCapability = null;
+ this._currentPageNumber = 1;
+ this._isPagesLoaded = false;
}
}, {
key: "_dispatchEvent",
value: function _dispatchEvent(outlineCount) {
+ var _this$_pdfDocument;
+
this.eventBus.dispatch("outlineloaded", {
source: this,
- outlineCount: outlineCount
+ outlineCount: outlineCount,
+ enableCurrentOutlineItemButton: outlineCount > 0 && !((_this$_pdfDocument = this._pdfDocument) !== null && _this$_pdfDocument !== void 0 && _this$_pdfDocument.loadingParams.disableAutoFetch)
});
}
}, {
key: "_bindLink",
value: function _bindLink(element, _ref) {
+ var _this2 = this;
+
var url = _ref.url,
newWindow = _ref.newWindow,
dest = _ref.dest;
@@ -9955,9 +10504,11 @@ var PDFOutlineViewer = /*#__PURE__*/function (_BaseTreeViewer) {
element.href = linkService.getDestinationHash(dest);
- element.onclick = function () {
+ element.onclick = function (evt) {
+ _this2._updateCurrentTreeItem(evt.target.parentNode);
+
if (dest) {
- linkService.navigateTo(dest);
+ linkService.goToDestination(dest);
}
return false;
@@ -9982,7 +10533,30 @@ var PDFOutlineViewer = /*#__PURE__*/function (_BaseTreeViewer) {
value: function _addToggleButton(div, _ref3) {
var count = _ref3.count,
items = _ref3.items;
- var hidden = count < 0 && Math.abs(count) === items.length;
+ var hidden = false;
+
+ if (count < 0) {
+ var totalCount = items.length;
+
+ if (totalCount > 0) {
+ var queue = _toConsumableArray(items);
+
+ while (queue.length > 0) {
+ var _queue$shift = queue.shift(),
+ nestedCount = _queue$shift.count,
+ nestedItems = _queue$shift.items;
+
+ if (nestedCount > 0 && nestedItems.length > 0) {
+ totalCount += nestedItems.length;
+ queue.push.apply(queue, _toConsumableArray(nestedItems));
+ }
+ }
+ }
+
+ if (Math.abs(count) === totalCount) {
+ hidden = true;
+ }
+ }
_get(_getPrototypeOf(PDFOutlineViewer.prototype), "_addToggleButton", this).call(this, div, hidden);
}
@@ -9998,13 +10572,15 @@ var PDFOutlineViewer = /*#__PURE__*/function (_BaseTreeViewer) {
}, {
key: "render",
value: function render(_ref4) {
- var outline = _ref4.outline;
+ var outline = _ref4.outline,
+ pdfDocument = _ref4.pdfDocument;
if (this._outline) {
this.reset();
}
this._outline = outline || null;
+ this._pdfDocument = pdfDocument || null;
if (!outline) {
this._dispatchEvent(0);
@@ -10064,15 +10640,291 @@ var PDFOutlineViewer = /*#__PURE__*/function (_BaseTreeViewer) {
}
}
- if (hasAnyNesting) {
- this.container.classList.add("treeWithDeepNesting");
- this._lastToggleIsShow = fragment.querySelectorAll(".treeItemsHidden").length === 0;
+ this._finishRendering(fragment, outlineCount, hasAnyNesting);
+ }
+ }, {
+ key: "_currentOutlineItem",
+ value: function () {
+ var _currentOutlineItem2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
+ var pageNumberToDestHash, i, destHash, linkElement;
+ return _regenerator["default"].wrap(function _callee$(_context) {
+ while (1) {
+ switch (_context.prev = _context.next) {
+ case 0:
+ if (this._isPagesLoaded) {
+ _context.next = 2;
+ break;
+ }
+
+ throw new Error("_currentOutlineItem: All pages have not been loaded.");
+
+ case 2:
+ if (!(!this._outline || !this._pdfDocument)) {
+ _context.next = 4;
+ break;
+ }
+
+ return _context.abrupt("return");
+
+ case 4:
+ _context.next = 6;
+ return this._getPageNumberToDestHash(this._pdfDocument);
+
+ case 6:
+ pageNumberToDestHash = _context.sent;
+
+ if (pageNumberToDestHash) {
+ _context.next = 9;
+ break;
+ }
+
+ return _context.abrupt("return");
+
+ case 9:
+ this._updateCurrentTreeItem(null);
+
+ if (!(this._sidebarView !== _ui_utils.SidebarView.OUTLINE)) {
+ _context.next = 12;
+ break;
+ }
+
+ return _context.abrupt("return");
+
+ case 12:
+ i = this._currentPageNumber;
+
+ case 13:
+ if (!(i > 0)) {
+ _context.next = 25;
+ break;
+ }
+
+ destHash = pageNumberToDestHash.get(i);
+
+ if (destHash) {
+ _context.next = 17;
+ break;
+ }
+
+ return _context.abrupt("continue", 22);
+
+ case 17:
+ linkElement = this.container.querySelector("a[href=\"".concat(destHash, "\"]"));
+
+ if (linkElement) {
+ _context.next = 20;
+ break;
+ }
+
+ return _context.abrupt("continue", 22);
+
+ case 20:
+ this._scrollToCurrentTreeItem(linkElement.parentNode);
+
+ return _context.abrupt("break", 25);
+
+ case 22:
+ i--;
+ _context.next = 13;
+ break;
+
+ case 25:
+ case "end":
+ return _context.stop();
+ }
+ }
+ }, _callee, this);
+ }));
+
+ function _currentOutlineItem() {
+ return _currentOutlineItem2.apply(this, arguments);
}
- this.container.appendChild(fragment);
+ return _currentOutlineItem;
+ }()
+ }, {
+ key: "_getPageNumberToDestHash",
+ value: function () {
+ var _getPageNumberToDestHash2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(pdfDocument) {
+ var pageNumberToDestHash, pageNumberNesting, queue, levelData, currentNesting, _iterator2, _step2, _step2$value, dest, items, explicitDest, pageNumber, _explicitDest, _explicitDest2, destRef, destHash;
- this._dispatchEvent(outlineCount);
- }
+ return _regenerator["default"].wrap(function _callee2$(_context2) {
+ while (1) {
+ switch (_context2.prev = _context2.next) {
+ case 0:
+ if (!this._pageNumberToDestHashCapability) {
+ _context2.next = 2;
+ break;
+ }
+
+ return _context2.abrupt("return", this._pageNumberToDestHashCapability.promise);
+
+ case 2:
+ this._pageNumberToDestHashCapability = (0, _pdfjsLib.createPromiseCapability)();
+ pageNumberToDestHash = new Map(), pageNumberNesting = new Map();
+ queue = [{
+ nesting: 0,
+ items: this._outline
+ }];
+
+ case 5:
+ if (!(queue.length > 0)) {
+ _context2.next = 56;
+ break;
+ }
+
+ levelData = queue.shift(), currentNesting = levelData.nesting;
+ _iterator2 = _createForOfIteratorHelper(levelData.items);
+ _context2.prev = 8;
+
+ _iterator2.s();
+
+ case 10:
+ if ((_step2 = _iterator2.n()).done) {
+ _context2.next = 46;
+ break;
+ }
+
+ _step2$value = _step2.value, dest = _step2$value.dest, items = _step2$value.items;
+ explicitDest = void 0, pageNumber = void 0;
+
+ if (!(typeof dest === "string")) {
+ _context2.next = 21;
+ break;
+ }
+
+ _context2.next = 16;
+ return pdfDocument.getDestination(dest);
+
+ case 16:
+ explicitDest = _context2.sent;
+
+ if (!(pdfDocument !== this._pdfDocument)) {
+ _context2.next = 19;
+ break;
+ }
+
+ return _context2.abrupt("return", null);
+
+ case 19:
+ _context2.next = 22;
+ break;
+
+ case 21:
+ explicitDest = dest;
+
+ case 22:
+ if (!Array.isArray(explicitDest)) {
+ _context2.next = 43;
+ break;
+ }
+
+ _explicitDest = explicitDest, _explicitDest2 = _slicedToArray(_explicitDest, 1), destRef = _explicitDest2[0];
+
+ if (!(_typeof(destRef) === "object")) {
+ _context2.next = 41;
+ break;
+ }
+
+ pageNumber = this.linkService._cachedPageNumber(destRef);
+
+ if (pageNumber) {
+ _context2.next = 39;
+ break;
+ }
+
+ _context2.prev = 27;
+ _context2.next = 30;
+ return pdfDocument.getPageIndex(destRef);
+
+ case 30:
+ _context2.t0 = _context2.sent;
+ pageNumber = _context2.t0 + 1;
+
+ if (!(pdfDocument !== this._pdfDocument)) {
+ _context2.next = 34;
+ break;
+ }
+
+ return _context2.abrupt("return", null);
+
+ case 34:
+ this.linkService.cachePageRef(pageNumber, destRef);
+ _context2.next = 39;
+ break;
+
+ case 37:
+ _context2.prev = 37;
+ _context2.t1 = _context2["catch"](27);
+
+ case 39:
+ _context2.next = 42;
+ break;
+
+ case 41:
+ if (Number.isInteger(destRef)) {
+ pageNumber = destRef + 1;
+ }
+
+ case 42:
+ if (Number.isInteger(pageNumber) && (!pageNumberToDestHash.has(pageNumber) || currentNesting > pageNumberNesting.get(pageNumber))) {
+ destHash = this.linkService.getDestinationHash(dest);
+ pageNumberToDestHash.set(pageNumber, destHash);
+ pageNumberNesting.set(pageNumber, currentNesting);
+ }
+
+ case 43:
+ if (items.length > 0) {
+ queue.push({
+ nesting: currentNesting + 1,
+ items: items
+ });
+ }
+
+ case 44:
+ _context2.next = 10;
+ break;
+
+ case 46:
+ _context2.next = 51;
+ break;
+
+ case 48:
+ _context2.prev = 48;
+ _context2.t2 = _context2["catch"](8);
+
+ _iterator2.e(_context2.t2);
+
+ case 51:
+ _context2.prev = 51;
+
+ _iterator2.f();
+
+ return _context2.finish(51);
+
+ case 54:
+ _context2.next = 5;
+ break;
+
+ case 56:
+ this._pageNumberToDestHashCapability.resolve(pageNumberToDestHash.size > 0 ? pageNumberToDestHash : null);
+
+ return _context2.abrupt("return", this._pageNumberToDestHashCapability.promise);
+
+ case 58:
+ case "end":
+ return _context2.stop();
+ }
+ }
+ }, _callee2, this, [[8, 48, 51, 54], [27, 37]]);
+ }));
+
+ function _getPageNumberToDestHash(_x) {
+ return _getPageNumberToDestHash2.apply(this, arguments);
+ }
+
+ return _getPageNumberToDestHash;
+ }()
}]);
return PDFOutlineViewer;
@@ -10081,18 +10933,17 @@ var PDFOutlineViewer = /*#__PURE__*/function (_BaseTreeViewer) {
exports.PDFOutlineViewer = PDFOutlineViewer;
/***/ }),
-/* 25 */
-/***/ (function(module, exports, __webpack_require__) {
+/* 23 */
+/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
-"use strict";
-Object.defineProperty(exports, "__esModule", {
+Object.defineProperty(exports, "__esModule", ({
value: true
-});
+}));
exports.PDFPresentationMode = void 0;
-var _ui_utils = __webpack_require__(5);
+var _ui_utils = __webpack_require__(6);
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@@ -10182,8 +11033,6 @@ var PDFPresentationMode = /*#__PURE__*/function () {
this.container.mozRequestFullScreen();
} else if (this.container.webkitRequestFullscreen) {
this.container.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
- } else if (this.container.msRequestFullscreen) {
- this.container.msRequestFullscreen();
} else {
return false;
}
@@ -10221,7 +11070,7 @@ var PDFPresentationMode = /*#__PURE__*/function () {
this._resetMouseScrollState();
- var success = totalDelta > 0 ? this._goToPreviousPage() : this._goToNextPage();
+ var success = totalDelta > 0 ? this.pdfViewer.previousPage() : this.pdfViewer.nextPage();
if (success) {
this.mouseScrollTimeStamp = currentTime;
@@ -10229,36 +11078,28 @@ var PDFPresentationMode = /*#__PURE__*/function () {
}
}
}, {
- key: "_goToPreviousPage",
- value: function _goToPreviousPage() {
- var page = this.pdfViewer.currentPageNumber;
-
- if (page <= 1) {
- return false;
- }
-
- this.pdfViewer.currentPageNumber = page - 1;
- return true;
- }
- }, {
- key: "_goToNextPage",
- value: function _goToNextPage() {
- var page = this.pdfViewer.currentPageNumber;
+ key: "_notifyStateChange",
+ value: function _notifyStateChange() {
+ var state = _ui_utils.PresentationModeState.NORMAL;
- if (page >= this.pdfViewer.pagesCount) {
- return false;
+ if (this.switchInProgress) {
+ state = _ui_utils.PresentationModeState.CHANGING;
+ } else if (this.active) {
+ state = _ui_utils.PresentationModeState.FULLSCREEN;
}
- this.pdfViewer.currentPageNumber = page + 1;
- return true;
- }
- }, {
- key: "_notifyStateChange",
- value: function _notifyStateChange() {
this.eventBus.dispatch("presentationmodechanged", {
source: this,
- active: this.active,
- switchInProgress: !!this.switchInProgress
+ state: state,
+
+ get active() {
+ throw new Error("Deprecated parameter: `active`, please use `state` instead.");
+ },
+
+ get switchInProgress() {
+ throw new Error("Deprecated parameter: `switchInProgress`, please use `state` instead.");
+ }
+
});
}
}, {
@@ -10355,9 +11196,9 @@ var PDFPresentationMode = /*#__PURE__*/function () {
evt.preventDefault();
if (evt.shiftKey) {
- this._goToPreviousPage();
+ this.pdfViewer.previousPage();
} else {
- this._goToNextPage();
+ this.pdfViewer.nextPage();
}
}
}
@@ -10450,9 +11291,9 @@ var PDFPresentationMode = /*#__PURE__*/function () {
}
if (delta > 0) {
- this._goToPreviousPage();
+ this.pdfViewer.previousPage();
} else if (delta < 0) {
- this._goToNextPage();
+ this.pdfViewer.nextPage();
}
break;
@@ -10514,7 +11355,6 @@ var PDFPresentationMode = /*#__PURE__*/function () {
window.addEventListener("fullscreenchange", this.fullscreenChangeBind);
window.addEventListener("mozfullscreenchange", this.fullscreenChangeBind);
window.addEventListener("webkitfullscreenchange", this.fullscreenChangeBind);
- window.addEventListener("MSFullscreenChange", this.fullscreenChangeBind);
}
}, {
key: "_removeFullscreenChangeListeners",
@@ -10522,13 +11362,12 @@ var PDFPresentationMode = /*#__PURE__*/function () {
window.removeEventListener("fullscreenchange", this.fullscreenChangeBind);
window.removeEventListener("mozfullscreenchange", this.fullscreenChangeBind);
window.removeEventListener("webkitfullscreenchange", this.fullscreenChangeBind);
- window.removeEventListener("MSFullscreenChange", this.fullscreenChangeBind);
delete this.fullscreenChangeBind;
}
}, {
key: "isFullscreen",
get: function get() {
- return !!(document.fullscreenElement || document.mozFullScreen || document.webkitIsFullScreen || document.msFullscreenElement);
+ return !!(document.fullscreenElement || document.mozFullScreen || document.webkitIsFullScreen);
}
}]);
@@ -10538,18 +11377,415 @@ var PDFPresentationMode = /*#__PURE__*/function () {
exports.PDFPresentationMode = PDFPresentationMode;
/***/ }),
-/* 26 */
-/***/ (function(module, exports, __webpack_require__) {
+/* 24 */
+/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
-"use strict";
-Object.defineProperty(exports, "__esModule", {
+Object.defineProperty(exports, "__esModule", ({
value: true
-});
+}));
+exports.PDFSidebar = void 0;
+
+var _ui_utils = __webpack_require__(6);
+
+var _pdf_rendering_queue = __webpack_require__(10);
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
+
+function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
+
+var UI_NOTIFICATION_CLASS = "pdfSidebarNotification";
+
+var PDFSidebar = /*#__PURE__*/function () {
+ function PDFSidebar(_ref) {
+ var elements = _ref.elements,
+ pdfViewer = _ref.pdfViewer,
+ pdfThumbnailViewer = _ref.pdfThumbnailViewer,
+ eventBus = _ref.eventBus,
+ _ref$l10n = _ref.l10n,
+ l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n;
+
+ _classCallCheck(this, PDFSidebar);
+
+ this.isOpen = false;
+ this.active = _ui_utils.SidebarView.THUMBS;
+ this.isInitialViewSet = false;
+ this.onToggled = null;
+ this.pdfViewer = pdfViewer;
+ this.pdfThumbnailViewer = pdfThumbnailViewer;
+ this.outerContainer = elements.outerContainer;
+ this.viewerContainer = elements.viewerContainer;
+ this.toggleButton = elements.toggleButton;
+ this.thumbnailButton = elements.thumbnailButton;
+ this.outlineButton = elements.outlineButton;
+ this.attachmentsButton = elements.attachmentsButton;
+ this.layersButton = elements.layersButton;
+ this.thumbnailView = elements.thumbnailView;
+ this.outlineView = elements.outlineView;
+ this.attachmentsView = elements.attachmentsView;
+ this.layersView = elements.layersView;
+ this._outlineOptionsContainer = elements.outlineOptionsContainer;
+ this._currentOutlineItemButton = elements.currentOutlineItemButton;
+ this.eventBus = eventBus;
+ this.l10n = l10n;
+
+ this._addEventListeners();
+ }
+
+ _createClass(PDFSidebar, [{
+ key: "reset",
+ value: function reset() {
+ this.isInitialViewSet = false;
+
+ this._hideUINotification(true);
+
+ this.switchView(_ui_utils.SidebarView.THUMBS);
+ this.outlineButton.disabled = false;
+ this.attachmentsButton.disabled = false;
+ this.layersButton.disabled = false;
+ this._currentOutlineItemButton.disabled = true;
+ }
+ }, {
+ key: "setInitialView",
+ value: function setInitialView() {
+ var view = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _ui_utils.SidebarView.NONE;
+
+ if (this.isInitialViewSet) {
+ return;
+ }
+
+ this.isInitialViewSet = true;
+
+ if (view === _ui_utils.SidebarView.NONE || view === _ui_utils.SidebarView.UNKNOWN) {
+ this._dispatchEvent();
+
+ return;
+ }
+
+ if (!this._switchView(view, true)) {
+ this._dispatchEvent();
+ }
+ }
+ }, {
+ key: "switchView",
+ value: function switchView(view) {
+ var forceOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
+
+ this._switchView(view, forceOpen);
+ }
+ }, {
+ key: "_switchView",
+ value: function _switchView(view) {
+ var forceOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
+ var isViewChanged = view !== this.active;
+ var shouldForceRendering = false;
+
+ switch (view) {
+ case _ui_utils.SidebarView.NONE:
+ if (this.isOpen) {
+ this.close();
+ return true;
+ }
+
+ return false;
+
+ case _ui_utils.SidebarView.THUMBS:
+ if (this.isOpen && isViewChanged) {
+ shouldForceRendering = true;
+ }
+
+ break;
+
+ case _ui_utils.SidebarView.OUTLINE:
+ if (this.outlineButton.disabled) {
+ return false;
+ }
+
+ break;
+
+ case _ui_utils.SidebarView.ATTACHMENTS:
+ if (this.attachmentsButton.disabled) {
+ return false;
+ }
+
+ break;
+
+ case _ui_utils.SidebarView.LAYERS:
+ if (this.layersButton.disabled) {
+ return false;
+ }
+
+ break;
+
+ default:
+ console.error("PDFSidebar._switchView: \"".concat(view, "\" is not a valid view."));
+ return false;
+ }
+
+ this.active = view;
+ this.thumbnailButton.classList.toggle("toggled", view === _ui_utils.SidebarView.THUMBS);
+ this.outlineButton.classList.toggle("toggled", view === _ui_utils.SidebarView.OUTLINE);
+ this.attachmentsButton.classList.toggle("toggled", view === _ui_utils.SidebarView.ATTACHMENTS);
+ this.layersButton.classList.toggle("toggled", view === _ui_utils.SidebarView.LAYERS);
+ this.thumbnailView.classList.toggle("hidden", view !== _ui_utils.SidebarView.THUMBS);
+ this.outlineView.classList.toggle("hidden", view !== _ui_utils.SidebarView.OUTLINE);
+ this.attachmentsView.classList.toggle("hidden", view !== _ui_utils.SidebarView.ATTACHMENTS);
+ this.layersView.classList.toggle("hidden", view !== _ui_utils.SidebarView.LAYERS);
+
+ this._outlineOptionsContainer.classList.toggle("hidden", view !== _ui_utils.SidebarView.OUTLINE);
+
+ if (forceOpen && !this.isOpen) {
+ this.open();
+ return true;
+ }
+
+ if (shouldForceRendering) {
+ this._updateThumbnailViewer();
+
+ this._forceRendering();
+ }
+
+ if (isViewChanged) {
+ this._dispatchEvent();
+ }
+
+ return isViewChanged;
+ }
+ }, {
+ key: "open",
+ value: function open() {
+ if (this.isOpen) {
+ return;
+ }
+
+ this.isOpen = true;
+ this.toggleButton.classList.add("toggled");
+ this.outerContainer.classList.add("sidebarMoving", "sidebarOpen");
+
+ if (this.active === _ui_utils.SidebarView.THUMBS) {
+ this._updateThumbnailViewer();
+ }
+
+ this._forceRendering();
+
+ this._dispatchEvent();
+
+ this._hideUINotification();
+ }
+ }, {
+ key: "close",
+ value: function close() {
+ if (!this.isOpen) {
+ return;
+ }
+
+ this.isOpen = false;
+ this.toggleButton.classList.remove("toggled");
+ this.outerContainer.classList.add("sidebarMoving");
+ this.outerContainer.classList.remove("sidebarOpen");
+
+ this._forceRendering();
+
+ this._dispatchEvent();
+ }
+ }, {
+ key: "toggle",
+ value: function toggle() {
+ if (this.isOpen) {
+ this.close();
+ } else {
+ this.open();
+ }
+ }
+ }, {
+ key: "_dispatchEvent",
+ value: function _dispatchEvent() {
+ this.eventBus.dispatch("sidebarviewchanged", {
+ source: this,
+ view: this.visibleView
+ });
+ }
+ }, {
+ key: "_forceRendering",
+ value: function _forceRendering() {
+ if (this.onToggled) {
+ this.onToggled();
+ } else {
+ this.pdfViewer.forceRendering();
+ this.pdfThumbnailViewer.forceRendering();
+ }
+ }
+ }, {
+ key: "_updateThumbnailViewer",
+ value: function _updateThumbnailViewer() {
+ var pdfViewer = this.pdfViewer,
+ pdfThumbnailViewer = this.pdfThumbnailViewer;
+ var pagesCount = pdfViewer.pagesCount;
+
+ for (var pageIndex = 0; pageIndex < pagesCount; pageIndex++) {
+ var pageView = pdfViewer.getPageView(pageIndex);
+
+ if (pageView && pageView.renderingState === _pdf_rendering_queue.RenderingStates.FINISHED) {
+ var thumbnailView = pdfThumbnailViewer.getThumbnail(pageIndex);
+ thumbnailView.setImage(pageView);
+ }
+ }
+
+ pdfThumbnailViewer.scrollThumbnailIntoView(pdfViewer.currentPageNumber);
+ }
+ }, {
+ key: "_showUINotification",
+ value: function _showUINotification() {
+ var _this = this;
+
+ this.l10n.get("toggle_sidebar_notification2.title", null, "Toggle Sidebar (document contains outline/attachments/layers)").then(function (msg) {
+ _this.toggleButton.title = msg;
+ });
+
+ if (!this.isOpen) {
+ this.toggleButton.classList.add(UI_NOTIFICATION_CLASS);
+ }
+ }
+ }, {
+ key: "_hideUINotification",
+ value: function _hideUINotification() {
+ var _this2 = this;
+
+ var reset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
+
+ if (this.isOpen || reset) {
+ this.toggleButton.classList.remove(UI_NOTIFICATION_CLASS);
+ }
+
+ if (reset) {
+ this.l10n.get("toggle_sidebar.title", null, "Toggle Sidebar").then(function (msg) {
+ _this2.toggleButton.title = msg;
+ });
+ }
+ }
+ }, {
+ key: "_addEventListeners",
+ value: function _addEventListeners() {
+ var _this3 = this;
+
+ this.viewerContainer.addEventListener("transitionend", function (evt) {
+ if (evt.target === _this3.viewerContainer) {
+ _this3.outerContainer.classList.remove("sidebarMoving");
+ }
+ });
+ this.toggleButton.addEventListener("click", function () {
+ _this3.toggle();
+ });
+ this.thumbnailButton.addEventListener("click", function () {
+ _this3.switchView(_ui_utils.SidebarView.THUMBS);
+ });
+ this.outlineButton.addEventListener("click", function () {
+ _this3.switchView(_ui_utils.SidebarView.OUTLINE);
+ });
+ this.outlineButton.addEventListener("dblclick", function () {
+ _this3.eventBus.dispatch("toggleoutlinetree", {
+ source: _this3
+ });
+ });
+ this.attachmentsButton.addEventListener("click", function () {
+ _this3.switchView(_ui_utils.SidebarView.ATTACHMENTS);
+ });
+ this.layersButton.addEventListener("click", function () {
+ _this3.switchView(_ui_utils.SidebarView.LAYERS);
+ });
+ this.layersButton.addEventListener("dblclick", function () {
+ _this3.eventBus.dispatch("resetlayers", {
+ source: _this3
+ });
+ });
+
+ this._currentOutlineItemButton.addEventListener("click", function () {
+ _this3.eventBus.dispatch("currentoutlineitem", {
+ source: _this3
+ });
+ });
+
+ var onTreeLoaded = function onTreeLoaded(count, button, view) {
+ button.disabled = !count;
+
+ if (count) {
+ _this3._showUINotification();
+ } else if (_this3.active === view) {
+ _this3.switchView(_ui_utils.SidebarView.THUMBS);
+ }
+ };
+
+ this.eventBus._on("outlineloaded", function (evt) {
+ onTreeLoaded(evt.outlineCount, _this3.outlineButton, _ui_utils.SidebarView.OUTLINE);
+
+ if (evt.enableCurrentOutlineItemButton) {
+ _this3.pdfViewer.pagesPromise.then(function () {
+ _this3._currentOutlineItemButton.disabled = !_this3.isInitialViewSet;
+ });
+ }
+ });
+
+ this.eventBus._on("attachmentsloaded", function (evt) {
+ onTreeLoaded(evt.attachmentsCount, _this3.attachmentsButton, _ui_utils.SidebarView.ATTACHMENTS);
+ });
+
+ this.eventBus._on("layersloaded", function (evt) {
+ onTreeLoaded(evt.layersCount, _this3.layersButton, _ui_utils.SidebarView.LAYERS);
+ });
+
+ this.eventBus._on("presentationmodechanged", function (evt) {
+ if (evt.state === _ui_utils.PresentationModeState.NORMAL && _this3.isThumbnailViewVisible) {
+ _this3._updateThumbnailViewer();
+ }
+ });
+ }
+ }, {
+ key: "visibleView",
+ get: function get() {
+ return this.isOpen ? this.active : _ui_utils.SidebarView.NONE;
+ }
+ }, {
+ key: "isThumbnailViewVisible",
+ get: function get() {
+ return this.isOpen && this.active === _ui_utils.SidebarView.THUMBS;
+ }
+ }, {
+ key: "isOutlineViewVisible",
+ get: function get() {
+ return this.isOpen && this.active === _ui_utils.SidebarView.OUTLINE;
+ }
+ }, {
+ key: "isAttachmentsViewVisible",
+ get: function get() {
+ return this.isOpen && this.active === _ui_utils.SidebarView.ATTACHMENTS;
+ }
+ }, {
+ key: "isLayersViewVisible",
+ get: function get() {
+ return this.isOpen && this.active === _ui_utils.SidebarView.LAYERS;
+ }
+ }]);
+
+ return PDFSidebar;
+}();
+
+exports.PDFSidebar = PDFSidebar;
+
+/***/ }),
+/* 25 */
+/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
+
+
+
+Object.defineProperty(exports, "__esModule", ({
+ value: true
+}));
exports.PDFSidebarResizer = void 0;
-var _ui_utils = __webpack_require__(5);
+var _ui_utils = __webpack_require__(6);
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@@ -10569,7 +11805,6 @@ var PDFSidebarResizer = /*#__PURE__*/function () {
_classCallCheck(this, PDFSidebarResizer);
- this.enabled = false;
this.isRTL = false;
this.sidebarOpen = false;
this.doc = document.documentElement;
@@ -10579,16 +11814,7 @@ var PDFSidebarResizer = /*#__PURE__*/function () {
this.outerContainer = options.outerContainer;
this.resizer = options.resizer;
this.eventBus = eventBus;
- this.l10n = l10n;
-
- if (typeof CSS === "undefined" || typeof CSS.supports !== "function" || !CSS.supports(SIDEBAR_WIDTH_VAR, "calc(-1 * ".concat(SIDEBAR_MIN_WIDTH, "px)"))) {
- console.warn("PDFSidebarResizer: " + "The browser does not support resizing of the sidebar.");
- return;
- }
-
- this.enabled = true;
- this.resizer.classList.remove("hidden");
- this.l10n.getDirection().then(function (dir) {
+ l10n.getDirection().then(function (dir) {
_this.isRTL = dir === "rtl";
});
@@ -10599,19 +11825,22 @@ var PDFSidebarResizer = /*#__PURE__*/function () {
key: "_updateWidth",
value: function _updateWidth() {
var width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
+ var maxWidth = Math.floor(this.outerContainerWidth / 2);
- if (!this.enabled) {
- return false;
+ if (width > maxWidth) {
+ width = maxWidth;
}
- var newWidth = (0, _ui_utils.clamp)(width, SIDEBAR_MIN_WIDTH, Math.floor(this.outerContainerWidth / 2));
+ if (width < SIDEBAR_MIN_WIDTH) {
+ width = SIDEBAR_MIN_WIDTH;
+ }
- if (newWidth === this._width) {
+ if (width === this._width) {
return false;
}
- this._width = newWidth;
- this.doc.style.setProperty(SIDEBAR_WIDTH_VAR, "".concat(newWidth, "px"));
+ this._width = width;
+ this.doc.style.setProperty(SIDEBAR_WIDTH_VAR, "".concat(width, "px"));
return true;
}
}, {
@@ -10641,10 +11870,6 @@ var PDFSidebarResizer = /*#__PURE__*/function () {
value: function _addEventListeners() {
var _this2 = this;
- if (!this.enabled) {
- return;
- }
-
var _boundEvents = this._boundEvents;
_boundEvents.mouseMove = this._mouseMove.bind(this);
_boundEvents.mouseUp = this._mouseUp.bind(this);
@@ -10712,20 +11937,21 @@ var PDFSidebarResizer = /*#__PURE__*/function () {
exports.PDFSidebarResizer = PDFSidebarResizer;
/***/ }),
-/* 27 */
-/***/ (function(module, exports, __webpack_require__) {
+/* 26 */
+/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
-"use strict";
-Object.defineProperty(exports, "__esModule", {
+Object.defineProperty(exports, "__esModule", ({
value: true
-});
+}));
exports.PDFThumbnailViewer = void 0;
-var _ui_utils = __webpack_require__(5);
+var _ui_utils = __webpack_require__(6);
-var _pdf_thumbnail_view = __webpack_require__(28);
+var _pdf_thumbnail_view = __webpack_require__(27);
+
+var _pdf_rendering_queue = __webpack_require__(10);
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@@ -10775,7 +12001,10 @@ var PDFThumbnailViewer = /*#__PURE__*/function () {
}, {
key: "_getVisibleThumbs",
value: function _getVisibleThumbs() {
- return (0, _ui_utils.getVisibleElements)(this.container, this._thumbnails);
+ return (0, _ui_utils.getVisibleElements)({
+ scrollEl: this.container,
+ views: this._thumbnails
+ });
}
}, {
key: "scrollThumbnailIntoView",
@@ -10831,7 +12060,13 @@ var PDFThumbnailViewer = /*#__PURE__*/function () {
}, {
key: "cleanup",
value: function cleanup() {
- _pdf_thumbnail_view.PDFThumbnailView.cleanup();
+ for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
+ if (this._thumbnails[i] && this._thumbnails[i].renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
+ this._thumbnails[i].reset();
+ }
+ }
+
+ _pdf_thumbnail_view.TempImageFactory.destroyCanvas();
}
}, {
key: "_resetView",
@@ -11016,22 +12251,41 @@ var PDFThumbnailViewer = /*#__PURE__*/function () {
exports.PDFThumbnailViewer = PDFThumbnailViewer;
/***/ }),
-/* 28 */
-/***/ (function(module, exports, __webpack_require__) {
+/* 27 */
+/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
-"use strict";
-Object.defineProperty(exports, "__esModule", {
+Object.defineProperty(exports, "__esModule", ({
value: true
-});
-exports.PDFThumbnailView = void 0;
+}));
+exports.TempImageFactory = exports.PDFThumbnailView = void 0;
+
+var _regenerator = _interopRequireDefault(__webpack_require__(4));
+
+var _ui_utils = __webpack_require__(6);
+
+var _pdfjsLib = __webpack_require__(7);
+
+var _pdf_rendering_queue = __webpack_require__(10);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
-var _pdfjsLib = __webpack_require__(8);
+function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
+
+function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
+
+function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
+
+function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
+
+function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
-var _ui_utils = __webpack_require__(5);
+function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
+
+function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
-var _pdf_rendering_queue = __webpack_require__(11);
+function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@@ -11079,6 +12333,8 @@ var TempImageFactory = function TempImageFactoryClosure() {
};
}();
+exports.TempImageFactory = TempImageFactory;
+
var PDFThumbnailView = /*#__PURE__*/function () {
function PDFThumbnailView(_ref) {
var container = _ref.container,
@@ -11129,7 +12385,7 @@ var PDFThumbnailView = /*#__PURE__*/function () {
});
anchor.onclick = function () {
- linkService.page = id;
+ linkService.goToPage(id);
return false;
};
@@ -11221,7 +12477,6 @@ var PDFThumbnailView = /*#__PURE__*/function () {
}, {
key: "_getPageDrawContext",
value: function _getPageDrawContext() {
- var noCtxScale = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
var canvas = document.createElement("canvas");
this.canvas = canvas;
canvas.mozOpaque = true;
@@ -11233,12 +12488,8 @@ var PDFThumbnailView = /*#__PURE__*/function () {
canvas.height = this.canvasHeight * outputScale.sy | 0;
canvas.style.width = this.canvasWidth + "px";
canvas.style.height = this.canvasHeight + "px";
-
- if (!noCtxScale && outputScale.scaled) {
- ctx.scale(outputScale.sx, outputScale.sy);
- }
-
- return ctx;
+ var transform = outputScale.scaled ? [outputScale.sx, 0, 0, outputScale.sy, 0, 0] : null;
+ return [ctx, transform];
}
}, {
key: "_convertCanvasToImage",
@@ -11302,30 +12553,57 @@ var PDFThumbnailView = /*#__PURE__*/function () {
}
this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
- var renderCapability = (0, _pdfjsLib.createPromiseCapability)();
- var finishRenderTask = function finishRenderTask(error) {
- if (renderTask === _this2.renderTask) {
- _this2.renderTask = null;
- }
+ var finishRenderTask = /*#__PURE__*/function () {
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
+ var error,
+ _args = arguments;
+ return _regenerator["default"].wrap(function _callee$(_context) {
+ while (1) {
+ switch (_context.prev = _context.next) {
+ case 0:
+ error = _args.length > 0 && _args[0] !== undefined ? _args[0] : null;
- if (error instanceof _pdfjsLib.RenderingCancelledException) {
- renderCapability.resolve(undefined);
- return;
- }
+ if (renderTask === _this2.renderTask) {
+ _this2.renderTask = null;
+ }
- _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
+ if (!(error instanceof _pdfjsLib.RenderingCancelledException)) {
+ _context.next = 4;
+ break;
+ }
- _this2._convertCanvasToImage();
+ return _context.abrupt("return");
- if (!error) {
- renderCapability.resolve(undefined);
- } else {
- renderCapability.reject(error);
- }
- };
+ case 4:
+ _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
+
+ _this2._convertCanvasToImage();
+
+ if (!error) {
+ _context.next = 8;
+ break;
+ }
- var ctx = this._getPageDrawContext();
+ throw error;
+
+ case 8:
+ case "end":
+ return _context.stop();
+ }
+ }
+ }, _callee);
+ }));
+
+ return function finishRenderTask() {
+ return _ref2.apply(this, arguments);
+ };
+ }();
+
+ var _this$_getPageDrawCon = this._getPageDrawContext(),
+ _this$_getPageDrawCon2 = _slicedToArray(_this$_getPageDrawCon, 2),
+ ctx = _this$_getPageDrawCon2[0],
+ transform = _this$_getPageDrawCon2[1];
var drawViewport = this.viewport.clone({
scale: this.scale
@@ -11348,17 +12626,29 @@ var PDFThumbnailView = /*#__PURE__*/function () {
var renderContext = {
canvasContext: ctx,
+ transform: transform,
viewport: drawViewport,
optionalContentConfigPromise: this._optionalContentConfigPromise
};
var renderTask = this.renderTask = pdfPage.render(renderContext);
renderTask.onContinue = renderContinueCallback;
- renderTask.promise.then(function () {
+ var resultPromise = renderTask.promise.then(function () {
finishRenderTask(null);
}, function (error) {
finishRenderTask(error);
});
- return renderCapability.promise;
+ resultPromise["finally"](function () {
+ var _this2$pdfPage;
+
+ var pageCached = _this2.linkService.isPageCached(_this2.id);
+
+ if (pageCached) {
+ return;
+ }
+
+ (_this2$pdfPage = _this2.pdfPage) === null || _this2$pdfPage === void 0 ? void 0 : _this2$pdfPage.cleanup();
+ });
+ return resultPromise;
}
}, {
key: "setImage",
@@ -11383,7 +12673,9 @@ var PDFThumbnailView = /*#__PURE__*/function () {
this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
- var ctx = this._getPageDrawContext(true);
+ var _this$_getPageDrawCon3 = this._getPageDrawContext(),
+ _this$_getPageDrawCon4 = _slicedToArray(_this$_getPageDrawCon3, 1),
+ ctx = _this$_getPageDrawCon4[0];
var canvas = ctx.canvas;
@@ -11446,7 +12738,7 @@ var PDFThumbnailView = /*#__PURE__*/function () {
var _this$pageLabel;
return this.l10n.get("thumb_page_title", {
- page: (_this$pageLabel = this.pageLabel) != null ? _this$pageLabel : this.id
+ page: (_this$pageLabel = this.pageLabel) !== null && _this$pageLabel !== void 0 ? _this$pageLabel : this.id
}, "Page {{page}}");
}
}, {
@@ -11455,14 +12747,9 @@ var PDFThumbnailView = /*#__PURE__*/function () {
var _this$pageLabel2;
return this.l10n.get("thumb_page_canvas", {
- page: (_this$pageLabel2 = this.pageLabel) != null ? _this$pageLabel2 : this.id
+ page: (_this$pageLabel2 = this.pageLabel) !== null && _this$pageLabel2 !== void 0 ? _this$pageLabel2 : this.id
}, "Thumbnail of Page {{page}}");
}
- }], [{
- key: "cleanup",
- value: function cleanup() {
- TempImageFactory.destroyCanvas();
- }
}]);
return PDFThumbnailView;
@@ -11471,22 +12758,23 @@ var PDFThumbnailView = /*#__PURE__*/function () {
exports.PDFThumbnailView = PDFThumbnailView;
/***/ }),
-/* 29 */
-/***/ (function(module, exports, __webpack_require__) {
+/* 28 */
+/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
-"use strict";
-Object.defineProperty(exports, "__esModule", {
+function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
+
+Object.defineProperty(exports, "__esModule", ({
value: true
-});
+}));
exports.PDFViewer = void 0;
-var _base_viewer = __webpack_require__(30);
+var _ui_utils = __webpack_require__(6);
-var _pdfjsLib = __webpack_require__(8);
+var _base_viewer = __webpack_require__(29);
-function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
+var _pdfjsLib = __webpack_require__(7);
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
@@ -11589,7 +12877,7 @@ var PDFViewer = /*#__PURE__*/function (_BaseViewer) {
break;
}
- if (page.id === currentId) {
+ if (page.id === currentId && this._scrollMode === _ui_utils.ScrollMode.VERTICAL && this._spreadMode === _ui_utils.SpreadMode.NONE) {
stillFullyVisible = true;
break;
}
@@ -11619,30 +12907,29 @@ var PDFViewer = /*#__PURE__*/function (_BaseViewer) {
exports.PDFViewer = PDFViewer;
/***/ }),
-/* 30 */
-/***/ (function(module, exports, __webpack_require__) {
+/* 29 */
+/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
-"use strict";
-Object.defineProperty(exports, "__esModule", {
+Object.defineProperty(exports, "__esModule", ({
value: true
-});
+}));
exports.BaseViewer = void 0;
-var _ui_utils = __webpack_require__(5);
+var _pdfjsLib = __webpack_require__(7);
-var _pdf_rendering_queue = __webpack_require__(11);
+var _ui_utils = __webpack_require__(6);
-var _annotation_layer_builder = __webpack_require__(31);
+var _pdf_rendering_queue = __webpack_require__(10);
-var _pdfjsLib = __webpack_require__(8);
+var _annotation_layer_builder = __webpack_require__(30);
-var _pdf_page_view = __webpack_require__(32);
+var _pdf_page_view = __webpack_require__(31);
-var _pdf_link_service = __webpack_require__(23);
+var _pdf_link_service = __webpack_require__(21);
-var _text_layer_builder = __webpack_require__(33);
+var _text_layer_builder = __webpack_require__(32);
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
@@ -11694,6 +12981,10 @@ function PDFPageViewBuffer(size) {
data.shift().destroy();
}
};
+
+ this.has = function (view) {
+ return data.includes(view);
+ };
}
function isSameScale(oldScale, newScale) {
@@ -11710,7 +13001,9 @@ function isSameScale(oldScale, newScale) {
var BaseViewer = /*#__PURE__*/function () {
function BaseViewer(options) {
- var _this = this;
+ var _this$container,
+ _this$viewer,
+ _this = this;
_classCallCheck(this, BaseViewer);
@@ -11718,14 +13011,24 @@ var BaseViewer = /*#__PURE__*/function () {
throw new Error("Cannot initialize BaseViewer.");
}
+ var viewerVersion = '2.7.570';
+
+ if (_pdfjsLib.version !== viewerVersion) {
+ throw new Error("The API version \"".concat(_pdfjsLib.version, "\" does not match the Viewer version \"").concat(viewerVersion, "\"."));
+ }
+
this._name = this.constructor.name;
this.container = options.container;
this.viewer = options.viewer || options.container.firstElementChild;
- if (!(this.container instanceof HTMLDivElement && this.viewer instanceof HTMLDivElement)) {
+ if (!(((_this$container = this.container) === null || _this$container === void 0 ? void 0 : _this$container.tagName.toUpperCase()) === "DIV" && ((_this$viewer = this.viewer) === null || _this$viewer === void 0 ? void 0 : _this$viewer.tagName.toUpperCase()) === "DIV")) {
throw new Error("Invalid `container` and/or `viewer` option.");
}
+ if (getComputedStyle(this.container).position !== "absolute") {
+ throw new Error("The `container` must be absolutely positioned.");
+ }
+
this.eventBus = options.eventBus;
this.linkService = options.linkService || new _pdf_link_service.SimpleLinkService();
this.downloadManager = options.downloadManager || null;
@@ -11740,6 +13043,8 @@ var BaseViewer = /*#__PURE__*/function () {
this.useOnlyCssZoom = options.useOnlyCssZoom || false;
this.maxCanvasPixels = options.maxCanvasPixels;
this.l10n = options.l10n || _ui_utils.NullL10n;
+ this.enableScripting = options.enableScripting || false;
+ this._mouseState = options.mouseState || null;
this.defaultRenderingQueue = !options.renderingQueue;
if (this.defaultRenderingQueue) {
@@ -11788,11 +13093,13 @@ var BaseViewer = /*#__PURE__*/function () {
return false;
}
+ var previous = this._currentPageNumber;
this._currentPageNumber = val;
this.eventBus.dispatch("pagechanging", {
source: this,
pageNumber: val,
- pageLabel: this._pageLabels && this._pageLabels[val - 1]
+ pageLabel: this._pageLabels && this._pageLabels[val - 1],
+ previous: previous
});
if (resetCurrentPageView) {
@@ -11816,6 +13123,10 @@ var BaseViewer = /*#__PURE__*/function () {
var _this2 = this;
if (this.pdfDocument) {
+ this.eventBus.dispatch("pagesdestroy", {
+ source: this
+ });
+
this._cancelRendering();
this._resetView();
@@ -11833,7 +13144,6 @@ var BaseViewer = /*#__PURE__*/function () {
var pagesCount = pdfDocument.numPages;
var firstPagePromise = pdfDocument.getPage(1);
- var annotationStorage = pdfDocument.annotationStorage;
var optionalContentConfigPromise = pdfDocument.getOptionalContentConfig();
this._pagesCapability.promise.then(function () {
@@ -11886,7 +13196,6 @@ var BaseViewer = /*#__PURE__*/function () {
id: pageNum,
scale: scale,
defaultViewport: viewport.clone(),
- annotationStorage: annotationStorage,
optionalContentConfigPromise: optionalContentConfigPromise,
renderingQueue: _this2.renderingQueue,
textLayerFactory: textLayerFactory,
@@ -11898,7 +13207,8 @@ var BaseViewer = /*#__PURE__*/function () {
enableWebGL: _this2.enableWebGL,
useOnlyCssZoom: _this2.useOnlyCssZoom,
maxCanvasPixels: _this2.maxCanvasPixels,
- l10n: _this2.l10n
+ l10n: _this2.l10n,
+ enableScripting: _this2.enableScripting
});
_this2._pages.push(pageView);
@@ -12026,6 +13336,8 @@ var BaseViewer = /*#__PURE__*/function () {
this._onAfterDraw = null;
}
+ this._resetScriptingEvents();
+
this.viewer.textContent = "";
this._updateScrollMode();
@@ -12127,7 +13439,7 @@ var BaseViewer = /*#__PURE__*/function () {
vPadding = _ref2[1];
}
- var pageWidthScale = (this.container.clientWidth - hPadding) / currentPage.width * currentPage.scale;
+ var pageWidthScale = (this.container.clientWidth - hPadding) / currentPage.width * currentPage.scale / this._pageWidthScaleFactor;
var pageHeightScale = (this.container.clientHeight - vPadding) / currentPage.height * currentPage.scale;
switch (value) {
@@ -12174,6 +13486,21 @@ var BaseViewer = /*#__PURE__*/function () {
});
}
}, {
+ key: "pageLabelToPageNumber",
+ value: function pageLabelToPageNumber(label) {
+ if (!this._pageLabels) {
+ return null;
+ }
+
+ var i = this._pageLabels.indexOf(label);
+
+ if (i < 0) {
+ return null;
+ }
+
+ return i + 1;
+ }
+ }, {
key: "scrollPageIntoView",
value: function scrollPageIntoView(_ref3) {
var pageNumber = _ref3.pageNumber,
@@ -12234,6 +13561,8 @@ var BaseViewer = /*#__PURE__*/function () {
if (y === null && this._location) {
x = this._location.left;
y = this._location.top;
+ } else if (typeof y !== "number") {
+ y = pageHeight;
}
break;
@@ -12390,7 +13719,13 @@ var BaseViewer = /*#__PURE__*/function () {
}, {
key: "_getVisiblePages",
value: function _getVisiblePages() {
- return (0, _ui_utils.getVisibleElements)(this.container, this._pages, true, this._isScrollModeHorizontal);
+ return (0, _ui_utils.getVisibleElements)({
+ scrollEl: this.container,
+ views: this._pages,
+ sortByVisibility: true,
+ horizontal: this._isScrollModeHorizontal,
+ rtl: this._isScrollModeHorizontal && this._isContainerRtl
+ });
}
}, {
key: "isPageVisible",
@@ -12399,8 +13734,8 @@ var BaseViewer = /*#__PURE__*/function () {
return false;
}
- if (pageNumber < 1 || pageNumber > this.pagesCount) {
- console.error("".concat(this._name, ".isPageVisible: \"").concat(pageNumber, "\" is out of bounds."));
+ if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.pagesCount)) {
+ console.error("".concat(this._name, ".isPageVisible: \"").concat(pageNumber, "\" is not a valid page."));
return false;
}
@@ -12409,6 +13744,26 @@ var BaseViewer = /*#__PURE__*/function () {
});
}
}, {
+ key: "isPageCached",
+ value: function isPageCached(pageNumber) {
+ if (!this.pdfDocument || !this._buffer) {
+ return false;
+ }
+
+ if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.pagesCount)) {
+ console.error("".concat(this._name, ".isPageCached: \"").concat(pageNumber, "\" is not a valid page."));
+ return false;
+ }
+
+ var pageView = this._pages[pageNumber - 1];
+
+ if (!pageView) {
+ return false;
+ }
+
+ return this._buffer.has(pageView);
+ }
+ }, {
key: "cleanup",
value: function cleanup() {
for (var i = 0, ii = this._pages.length; i < ii; i++) {
@@ -12494,19 +13849,27 @@ var BaseViewer = /*#__PURE__*/function () {
}, {
key: "createAnnotationLayerBuilder",
value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
+ var _this$pdfDocument, _this$pdfDocument2;
+
var annotationStorage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
var imageResourcesPath = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "";
var renderInteractiveForms = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
var l10n = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : _ui_utils.NullL10n;
+ var enableScripting = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
+ var hasJSActionsPromise = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
+ var mouseState = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : null;
return new _annotation_layer_builder.AnnotationLayerBuilder({
pageDiv: pageDiv,
pdfPage: pdfPage,
- annotationStorage: annotationStorage,
+ annotationStorage: annotationStorage || ((_this$pdfDocument = this.pdfDocument) === null || _this$pdfDocument === void 0 ? void 0 : _this$pdfDocument.annotationStorage),
imageResourcesPath: imageResourcesPath,
renderInteractiveForms: renderInteractiveForms,
linkService: this.linkService,
downloadManager: this.downloadManager,
- l10n: l10n
+ l10n: l10n,
+ enableScripting: enableScripting,
+ hasJSActionsPromise: hasJSActionsPromise || ((_this$pdfDocument2 = this.pdfDocument) === null || _this$pdfDocument2 === void 0 ? void 0 : _this$pdfDocument2.hasJSActions()),
+ mouseState: mouseState || this._mouseState
});
}
}, {
@@ -12599,11 +13962,308 @@ var BaseViewer = /*#__PURE__*/function () {
return;
}
+ if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
+ this._setScale(this._currentScaleValue, true);
+ }
+
this._setCurrentPageNumber(pageNumber, true);
this.update();
}
}, {
+ key: "_getPageAdvance",
+ value: function _getPageAdvance(currentPageNumber) {
+ var previous = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
+
+ if (this.isInPresentationMode) {
+ return 1;
+ }
+
+ switch (this._scrollMode) {
+ case _ui_utils.ScrollMode.WRAPPED:
+ {
+ var _this$_getVisiblePage = this._getVisiblePages(),
+ views = _this$_getVisiblePage.views,
+ pageLayout = new Map();
+
+ var _iterator = _createForOfIteratorHelper(views),
+ _step;
+
+ try {
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
+ var _step$value = _step.value,
+ id = _step$value.id,
+ y = _step$value.y,
+ percent = _step$value.percent,
+ widthPercent = _step$value.widthPercent;
+
+ if (percent === 0 || widthPercent < 100) {
+ continue;
+ }
+
+ var yArray = pageLayout.get(y);
+
+ if (!yArray) {
+ pageLayout.set(y, yArray || (yArray = []));
+ }
+
+ yArray.push(id);
+ }
+ } catch (err) {
+ _iterator.e(err);
+ } finally {
+ _iterator.f();
+ }
+
+ var _iterator2 = _createForOfIteratorHelper(pageLayout.values()),
+ _step2;
+
+ try {
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
+ var _yArray = _step2.value;
+
+ var currentIndex = _yArray.indexOf(currentPageNumber);
+
+ if (currentIndex === -1) {
+ continue;
+ }
+
+ var numPages = _yArray.length;
+
+ if (numPages === 1) {
+ break;
+ }
+
+ if (previous) {
+ for (var i = currentIndex - 1, ii = 0; i >= ii; i--) {
+ var currentId = _yArray[i],
+ expectedId = _yArray[i + 1] - 1;
+
+ if (currentId < expectedId) {
+ return currentPageNumber - expectedId;
+ }
+ }
+ } else {
+ for (var _i2 = currentIndex + 1, _ii = numPages; _i2 < _ii; _i2++) {
+ var _currentId = _yArray[_i2],
+ _expectedId = _yArray[_i2 - 1] + 1;
+
+ if (_currentId > _expectedId) {
+ return _expectedId - currentPageNumber;
+ }
+ }
+ }
+
+ if (previous) {
+ var firstId = _yArray[0];
+
+ if (firstId < currentPageNumber) {
+ return currentPageNumber - firstId + 1;
+ }
+ } else {
+ var lastId = _yArray[numPages - 1];
+
+ if (lastId > currentPageNumber) {
+ return lastId - currentPageNumber + 1;
+ }
+ }
+
+ break;
+ }
+ } catch (err) {
+ _iterator2.e(err);
+ } finally {
+ _iterator2.f();
+ }
+
+ break;
+ }
+
+ case _ui_utils.ScrollMode.HORIZONTAL:
+ {
+ break;
+ }
+
+ case _ui_utils.ScrollMode.VERTICAL:
+ {
+ if (this._spreadMode === _ui_utils.SpreadMode.NONE) {
+ break;
+ }
+
+ var parity = this._spreadMode - 1;
+
+ if (previous && currentPageNumber % 2 !== parity) {
+ break;
+ } else if (!previous && currentPageNumber % 2 === parity) {
+ break;
+ }
+
+ var _this$_getVisiblePage2 = this._getVisiblePages(),
+ _views = _this$_getVisiblePage2.views,
+ _expectedId2 = previous ? currentPageNumber - 1 : currentPageNumber + 1;
+
+ var _iterator3 = _createForOfIteratorHelper(_views),
+ _step3;
+
+ try {
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
+ var _step3$value = _step3.value,
+ _id = _step3$value.id,
+ _percent = _step3$value.percent,
+ _widthPercent = _step3$value.widthPercent;
+
+ if (_id !== _expectedId2) {
+ continue;
+ }
+
+ if (_percent > 0 && _widthPercent === 100) {
+ return 2;
+ }
+
+ break;
+ }
+ } catch (err) {
+ _iterator3.e(err);
+ } finally {
+ _iterator3.f();
+ }
+
+ break;
+ }
+ }
+
+ return 1;
+ }
+ }, {
+ key: "nextPage",
+ value: function nextPage() {
+ var currentPageNumber = this._currentPageNumber,
+ pagesCount = this.pagesCount;
+
+ if (currentPageNumber >= pagesCount) {
+ return false;
+ }
+
+ var advance = this._getPageAdvance(currentPageNumber, false) || 1;
+ this.currentPageNumber = Math.min(currentPageNumber + advance, pagesCount);
+ return true;
+ }
+ }, {
+ key: "previousPage",
+ value: function previousPage() {
+ var currentPageNumber = this._currentPageNumber;
+
+ if (currentPageNumber <= 1) {
+ return false;
+ }
+
+ var advance = this._getPageAdvance(currentPageNumber, true) || 1;
+ this.currentPageNumber = Math.max(currentPageNumber - advance, 1);
+ return true;
+ }
+ }, {
+ key: "initializeScriptingEvents",
+ value: function initializeScriptingEvents() {
+ var _this5 = this;
+
+ if (!this.enableScripting || this._pageOpenPendingSet) {
+ return;
+ }
+
+ var eventBus = this.eventBus,
+ pageOpenPendingSet = this._pageOpenPendingSet = new Set(),
+ scriptingEvents = this._scriptingEvents || (this._scriptingEvents = Object.create(null));
+
+ var dispatchPageClose = function dispatchPageClose(pageNumber) {
+ if (pageOpenPendingSet.has(pageNumber)) {
+ return;
+ }
+
+ eventBus.dispatch("pageclose", {
+ source: _this5,
+ pageNumber: pageNumber
+ });
+ };
+
+ var dispatchPageOpen = function dispatchPageOpen(pageNumber) {
+ var pageView = _this5._pages[pageNumber - 1];
+
+ if ((pageView === null || pageView === void 0 ? void 0 : pageView.renderingState) === _pdf_rendering_queue.RenderingStates.FINISHED) {
+ var _pageView$pdfPage;
+
+ pageOpenPendingSet["delete"](pageNumber);
+ eventBus.dispatch("pageopen", {
+ source: _this5,
+ pageNumber: pageNumber,
+ actionsPromise: (_pageView$pdfPage = pageView.pdfPage) === null || _pageView$pdfPage === void 0 ? void 0 : _pageView$pdfPage.getJSActions()
+ });
+ } else {
+ pageOpenPendingSet.add(pageNumber);
+ }
+ };
+
+ scriptingEvents.onPageChanging = function (_ref4) {
+ var pageNumber = _ref4.pageNumber,
+ previous = _ref4.previous;
+
+ if (pageNumber === previous) {
+ return;
+ }
+
+ dispatchPageClose(previous);
+ dispatchPageOpen(pageNumber);
+ };
+
+ eventBus._on("pagechanging", scriptingEvents.onPageChanging);
+
+ scriptingEvents.onPageRendered = function (_ref5) {
+ var pageNumber = _ref5.pageNumber;
+
+ if (!pageOpenPendingSet.has(pageNumber)) {
+ return;
+ }
+
+ if (pageNumber !== _this5._currentPageNumber) {
+ return;
+ }
+
+ dispatchPageOpen(pageNumber);
+ };
+
+ eventBus._on("pagerendered", scriptingEvents.onPageRendered);
+
+ scriptingEvents.onPagesDestroy = function () {
+ dispatchPageClose(_this5._currentPageNumber);
+ };
+
+ eventBus._on("pagesdestroy", scriptingEvents.onPagesDestroy);
+
+ dispatchPageOpen(this._currentPageNumber);
+ }
+ }, {
+ key: "_resetScriptingEvents",
+ value: function _resetScriptingEvents() {
+ if (!this.enableScripting || !this._pageOpenPendingSet) {
+ return;
+ }
+
+ var eventBus = this.eventBus,
+ scriptingEvents = this._scriptingEvents;
+
+ eventBus._off("pagechanging", scriptingEvents.onPageChanging);
+
+ scriptingEvents.onPageChanging = null;
+
+ eventBus._off("pagerendered", scriptingEvents.onPageRendered);
+
+ scriptingEvents.onPageRendered = null;
+
+ eventBus._off("pagesdestroy", scriptingEvents.onPagesDestroy);
+
+ scriptingEvents.onPagesDestroy = null;
+ this._pageOpenPendingSet = null;
+ }
+ }, {
key: "pagesCount",
get: function get() {
return this._pages.length;
@@ -12750,11 +14410,25 @@ var BaseViewer = /*#__PURE__*/function () {
throw new Error("Not implemented: _viewerElement");
}
}, {
+ key: "_pageWidthScaleFactor",
+ get: function get() {
+ if (this.spreadMode !== _ui_utils.SpreadMode.NONE && this.scrollMode !== _ui_utils.ScrollMode.HORIZONTAL && !this.isInPresentationMode) {
+ return 2;
+ }
+
+ return 1;
+ }
+ }, {
key: "_isScrollModeHorizontal",
get: function get() {
return this.isInPresentationMode ? false : this._scrollMode === _ui_utils.ScrollMode.HORIZONTAL;
}
}, {
+ key: "_isContainerRtl",
+ get: function get() {
+ return getComputedStyle(this.container).direction === "rtl";
+ }
+ }, {
key: "isInPresentationMode",
get: function get() {
return this.presentationModeState === _ui_utils.PresentationModeState.FULLSCREEN;
@@ -12817,18 +14491,18 @@ var BaseViewer = /*#__PURE__*/function () {
this._optionalContentConfigPromise = promise;
- var _iterator = _createForOfIteratorHelper(this._pages),
- _step;
+ var _iterator4 = _createForOfIteratorHelper(this._pages),
+ _step4;
try {
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
- var pageView = _step.value;
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
+ var pageView = _step4.value;
pageView.update(pageView.scale, pageView.rotation, promise);
}
} catch (err) {
- _iterator.e(err);
+ _iterator4.e(err);
} finally {
- _iterator.f();
+ _iterator4.f();
}
this.update();
@@ -12889,22 +14563,33 @@ var BaseViewer = /*#__PURE__*/function () {
exports.BaseViewer = BaseViewer;
/***/ }),
-/* 31 */
-/***/ (function(module, exports, __webpack_require__) {
+/* 30 */
+/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
-"use strict";
-Object.defineProperty(exports, "__esModule", {
+Object.defineProperty(exports, "__esModule", ({
value: true
-});
+}));
exports.DefaultAnnotationLayerFactory = exports.AnnotationLayerBuilder = void 0;
-var _pdfjsLib = __webpack_require__(8);
+var _pdfjsLib = __webpack_require__(7);
+
+var _ui_utils = __webpack_require__(6);
+
+var _pdf_link_service = __webpack_require__(21);
+
+function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
+
+function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
+
+function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
-var _ui_utils = __webpack_require__(5);
+function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
-var _pdf_link_service = __webpack_require__(23);
+function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
+
+function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@@ -12925,7 +14610,13 @@ var AnnotationLayerBuilder = /*#__PURE__*/function () {
_ref$renderInteractiv = _ref.renderInteractiveForms,
renderInteractiveForms = _ref$renderInteractiv === void 0 ? true : _ref$renderInteractiv,
_ref$l10n = _ref.l10n,
- l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n;
+ l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n,
+ _ref$enableScripting = _ref.enableScripting,
+ enableScripting = _ref$enableScripting === void 0 ? false : _ref$enableScripting,
+ _ref$hasJSActionsProm = _ref.hasJSActionsPromise,
+ hasJSActionsPromise = _ref$hasJSActionsProm === void 0 ? null : _ref$hasJSActionsProm,
+ _ref$mouseState = _ref.mouseState,
+ mouseState = _ref$mouseState === void 0 ? null : _ref$mouseState;
_classCallCheck(this, AnnotationLayerBuilder);
@@ -12937,6 +14628,9 @@ var AnnotationLayerBuilder = /*#__PURE__*/function () {
this.renderInteractiveForms = renderInteractiveForms;
this.l10n = l10n;
this.annotationStorage = annotationStorage;
+ this.enableScripting = enableScripting;
+ this._hasJSActionsPromise = hasJSActionsPromise;
+ this._mouseState = mouseState;
this.div = null;
this._cancelled = false;
}
@@ -12947,9 +14641,14 @@ var AnnotationLayerBuilder = /*#__PURE__*/function () {
var _this = this;
var intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "display";
- return this.pdfPage.getAnnotations({
+ return Promise.all([this.pdfPage.getAnnotations({
intent: intent
- }).then(function (annotations) {
+ }), this._hasJSActionsPromise]).then(function (_ref2) {
+ var _ref3 = _slicedToArray(_ref2, 2),
+ annotations = _ref3[0],
+ _ref3$ = _ref3[1],
+ hasJSActions = _ref3$ === void 0 ? false : _ref3$;
+
if (_this._cancelled) {
return;
}
@@ -12969,7 +14668,10 @@ var AnnotationLayerBuilder = /*#__PURE__*/function () {
renderInteractiveForms: _this.renderInteractiveForms,
linkService: _this.linkService,
downloadManager: _this.downloadManager,
- annotationStorage: _this.annotationStorage
+ annotationStorage: _this.annotationStorage,
+ enableScripting: _this.enableScripting,
+ hasJSActions: hasJSActions,
+ mouseState: _this._mouseState
};
if (_this.div) {
@@ -13021,6 +14723,9 @@ var DefaultAnnotationLayerFactory = /*#__PURE__*/function () {
var imageResourcesPath = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "";
var renderInteractiveForms = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
var l10n = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : _ui_utils.NullL10n;
+ var enableScripting = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
+ var hasJSActionsPromise = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
+ var mouseState = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : null;
return new AnnotationLayerBuilder({
pageDiv: pageDiv,
pdfPage: pdfPage,
@@ -13028,7 +14733,10 @@ var DefaultAnnotationLayerFactory = /*#__PURE__*/function () {
renderInteractiveForms: renderInteractiveForms,
linkService: new _pdf_link_service.SimpleLinkService(),
l10n: l10n,
- annotationStorage: annotationStorage
+ annotationStorage: annotationStorage,
+ enableScripting: enableScripting,
+ hasJSActionsPromise: hasJSActionsPromise,
+ mouseState: mouseState
});
}
}]);
@@ -13039,26 +14747,25 @@ var DefaultAnnotationLayerFactory = /*#__PURE__*/function () {
exports.DefaultAnnotationLayerFactory = DefaultAnnotationLayerFactory;
/***/ }),
-/* 32 */
-/***/ (function(module, exports, __webpack_require__) {
+/* 31 */
+/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
-"use strict";
-Object.defineProperty(exports, "__esModule", {
+Object.defineProperty(exports, "__esModule", ({
value: true
-});
+}));
exports.PDFPageView = void 0;
-var _regenerator = _interopRequireDefault(__webpack_require__(2));
+var _regenerator = _interopRequireDefault(__webpack_require__(4));
-var _ui_utils = __webpack_require__(5);
+var _ui_utils = __webpack_require__(6);
-var _pdfjsLib = __webpack_require__(8);
+var _pdfjsLib = __webpack_require__(7);
-var _pdf_rendering_queue = __webpack_require__(11);
+var _pdf_rendering_queue = __webpack_require__(10);
-var _viewer_compatibility = __webpack_require__(7);
+var _viewer_compatibility = __webpack_require__(2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
@@ -13088,7 +14795,6 @@ var PDFPageView = /*#__PURE__*/function () {
this.scale = options.scale || _ui_utils.DEFAULT_SCALE;
this.viewport = defaultViewport;
this.pdfPageRotate = defaultViewport.rotation;
- this._annotationStorage = options.annotationStorage || null;
this._optionalContentConfigPromise = options.optionalContentConfigPromise || null;
this.hasRestrictedScaling = false;
this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
@@ -13103,11 +14809,12 @@ var PDFPageView = /*#__PURE__*/function () {
this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
this.enableWebGL = options.enableWebGL || false;
this.l10n = options.l10n || _ui_utils.NullL10n;
+ this.enableScripting = options.enableScripting || false;
this.paintTask = null;
this.paintedViewportMap = new WeakMap();
this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
this.resume = null;
- this.error = null;
+ this._renderError = null;
this.annotationLayer = null;
this.textLayer = null;
this.zoomLayer = null;
@@ -13130,7 +14837,6 @@ var PDFPageView = /*#__PURE__*/function () {
scale: this.scale * _ui_utils.CSS_UNITS,
rotation: totalRotation
});
- this.stats = pdfPage.stats;
this.reset();
}
}, {
@@ -13287,7 +14993,8 @@ var PDFPageView = /*#__PURE__*/function () {
source: this,
pageNumber: this.id,
cssTransform: true,
- timestamp: performance.now()
+ timestamp: performance.now(),
+ error: this._renderError
});
return;
}
@@ -13309,7 +15016,8 @@ var PDFPageView = /*#__PURE__*/function () {
source: this,
pageNumber: this.id,
cssTransform: true,
- timestamp: performance.now()
+ timestamp: performance.now(),
+ error: this._renderError
});
return;
}
@@ -13367,8 +15075,7 @@ var PDFPageView = /*#__PURE__*/function () {
scaleY = width / height;
}
- var cssTransform = "rotate(" + relativeRotation + "deg) " + "scale(" + scaleX + "," + scaleY + ")";
- target.style.transform = cssTransform;
+ target.style.transform = "rotate(".concat(relativeRotation, "deg) scale(").concat(scaleX, ", ").concat(scaleY, ")");
if (this.textLayer) {
var textLayerViewport = this.textLayer.viewport;
@@ -13408,7 +15115,7 @@ var PDFPageView = /*#__PURE__*/function () {
break;
}
- textLayerDiv.style.transform = "rotate(" + textAbsRotation + "deg) " + "scale(" + scale + ", " + scale + ") " + "translate(" + transX + ", " + transY + ")";
+ textLayerDiv.style.transform = "rotate(".concat(textAbsRotation, "deg) ") + "scale(".concat(scale, ") ") + "translate(".concat(transX, ", ").concat(transY, ")");
textLayerDiv.style.transformOrigin = "0% 0%";
}
@@ -13495,24 +15202,29 @@ var PDFPageView = /*#__PURE__*/function () {
}
var finishPaintTask = /*#__PURE__*/function () {
- var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(error) {
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
+ var error,
+ _args2 = arguments;
return _regenerator["default"].wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
+ error = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : null;
+
if (paintTask === _this.paintTask) {
_this.paintTask = null;
}
if (!(error instanceof _pdfjsLib.RenderingCancelledException)) {
- _context2.next = 4;
+ _context2.next = 5;
break;
}
- _this.error = null;
+ _this._renderError = null;
return _context2.abrupt("return");
- case 4:
+ case 5:
+ _this._renderError = error;
_this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
if (_this.loadingIconDiv) {
@@ -13522,14 +15234,12 @@ var PDFPageView = /*#__PURE__*/function () {
_this._resetZoomLayer(true);
- _this.error = error;
- _this.stats = pdfPage.stats;
-
_this.eventBus.dispatch("pagerendered", {
source: _this,
pageNumber: _this.id,
cssTransform: false,
- timestamp: performance.now()
+ timestamp: performance.now(),
+ error: _this._renderError
});
if (!error) {
@@ -13547,7 +15257,7 @@ var PDFPageView = /*#__PURE__*/function () {
}, _callee2);
}));
- return function finishPaintTask(_x) {
+ return function finishPaintTask() {
return _ref.apply(this, arguments);
};
}();
@@ -13571,7 +15281,7 @@ var PDFPageView = /*#__PURE__*/function () {
if (this.annotationLayerFactory) {
if (!this.annotationLayer) {
- this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(div, pdfPage, this._annotationStorage, this.imageResourcesPath, this.renderInteractiveForms, this.l10n);
+ this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(div, pdfPage, null, this.imageResourcesPath, this.renderInteractiveForms, this.l10n, this.enableScripting, null, null);
}
this._renderAnnotationLayer();
@@ -13754,18 +15464,17 @@ var PDFPageView = /*#__PURE__*/function () {
exports.PDFPageView = PDFPageView;
/***/ }),
-/* 33 */
-/***/ (function(module, exports, __webpack_require__) {
+/* 32 */
+/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
-"use strict";
-Object.defineProperty(exports, "__esModule", {
+Object.defineProperty(exports, "__esModule", ({
value: true
-});
-exports.DefaultTextLayerFactory = exports.TextLayerBuilder = void 0;
+}));
+exports.TextLayerBuilder = exports.DefaultTextLayerFactory = void 0;
-var _pdfjsLib = __webpack_require__(8);
+var _pdfjsLib = __webpack_require__(7);
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@@ -13899,12 +15608,10 @@ var TextLayerBuilder = /*#__PURE__*/function () {
return [];
}
- var findController = this.findController,
- textContentItemsStr = this.textContentItemsStr;
+ var textContentItemsStr = this.textContentItemsStr;
var i = 0,
iIndex = 0;
var end = textContentItemsStr.length - 1;
- var queryLen = findController.state.query.length;
var result = [];
for (var m = 0, mm = matches.length; m < mm; m++) {
@@ -13925,12 +15632,7 @@ var TextLayerBuilder = /*#__PURE__*/function () {
offset: matchIdx - iIndex
}
};
-
- if (matchesLength) {
- matchIdx += matchesLength[m];
- } else {
- matchIdx += queryLen;
- }
+ matchIdx += matchesLength[m];
while (i !== end && matchIdx > iIndex + textContentItemsStr[i].length) {
iIndex += textContentItemsStr[i].length;
@@ -14170,22 +15872,21 @@ var DefaultTextLayerFactory = /*#__PURE__*/function () {
exports.DefaultTextLayerFactory = DefaultTextLayerFactory;
/***/ }),
-/* 34 */
-/***/ (function(module, exports, __webpack_require__) {
+/* 33 */
+/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
-"use strict";
-Object.defineProperty(exports, "__esModule", {
+Object.defineProperty(exports, "__esModule", ({
value: true
-});
+}));
exports.SecondaryToolbar = void 0;
-var _ui_utils = __webpack_require__(5);
+var _ui_utils = __webpack_require__(6);
-var _pdf_cursor_tools = __webpack_require__(9);
+var _pdf_cursor_tools = __webpack_require__(8);
-var _pdf_single_page_viewer = __webpack_require__(35);
+var _pdf_single_page_viewer = __webpack_require__(34);
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
@@ -14536,22 +16237,21 @@ var SecondaryToolbar = /*#__PURE__*/function () {
exports.SecondaryToolbar = SecondaryToolbar;
/***/ }),
-/* 35 */
-/***/ (function(module, exports, __webpack_require__) {
+/* 34 */
+/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
-"use strict";
-Object.defineProperty(exports, "__esModule", {
+function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
+
+Object.defineProperty(exports, "__esModule", ({
value: true
-});
+}));
exports.PDFSinglePageViewer = void 0;
-var _base_viewer = __webpack_require__(30);
+var _base_viewer = __webpack_require__(29);
-var _pdfjsLib = __webpack_require__(8);
-
-function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
+var _pdfjsLib = __webpack_require__(7);
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@@ -14694,11 +16394,21 @@ var PDFSinglePageViewer = /*#__PURE__*/function (_BaseViewer) {
key: "_updateSpreadMode",
value: function _updateSpreadMode() {}
}, {
+ key: "_getPageAdvance",
+ value: function _getPageAdvance() {
+ return 1;
+ }
+ }, {
key: "_viewerElement",
get: function get() {
return (0, _pdfjsLib.shadow)(this, "_viewerElement", this._shadowViewer);
}
}, {
+ key: "_pageWidthScaleFactor",
+ get: function get() {
+ return 1;
+ }
+ }, {
key: "_isScrollModeHorizontal",
get: function get() {
return (0, _pdfjsLib.shadow)(this, "_isScrollModeHorizontal", false);
@@ -14711,20 +16421,19 @@ var PDFSinglePageViewer = /*#__PURE__*/function (_BaseViewer) {
exports.PDFSinglePageViewer = PDFSinglePageViewer;
/***/ }),
-/* 36 */
-/***/ (function(module, exports, __webpack_require__) {
+/* 35 */
+/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
-"use strict";
-Object.defineProperty(exports, "__esModule", {
+Object.defineProperty(exports, "__esModule", ({
value: true
-});
+}));
exports.Toolbar = void 0;
-var _regenerator = _interopRequireDefault(__webpack_require__(2));
+var _regenerator = _interopRequireDefault(__webpack_require__(4));
-var _ui_utils = __webpack_require__(5);
+var _ui_utils = __webpack_require__(6);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
@@ -15072,18 +16781,17 @@ var Toolbar = /*#__PURE__*/function () {
exports.Toolbar = Toolbar;
/***/ }),
-/* 37 */
-/***/ (function(module, exports, __webpack_require__) {
+/* 36 */
+/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
-"use strict";
-Object.defineProperty(exports, "__esModule", {
+Object.defineProperty(exports, "__esModule", ({
value: true
-});
+}));
exports.ViewHistory = void 0;
-var _regenerator = _interopRequireDefault(__webpack_require__(2));
+var _regenerator = _interopRequireDefault(__webpack_require__(4));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
@@ -15327,30 +17035,31 @@ var ViewHistory = /*#__PURE__*/function () {
exports.ViewHistory = ViewHistory;
/***/ }),
-/* 38 */
-/***/ (function(module, exports, __webpack_require__) {
+/* 37 */
+/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
-"use strict";
-Object.defineProperty(exports, "__esModule", {
+function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
+
+Object.defineProperty(exports, "__esModule", ({
value: true
-});
+}));
exports.GenericCom = void 0;
-var _regenerator = _interopRequireDefault(__webpack_require__(2));
+var _regenerator = _interopRequireDefault(__webpack_require__(4));
-var _app = __webpack_require__(1);
+var _app = __webpack_require__(3);
-var _preferences = __webpack_require__(39);
+var _preferences = __webpack_require__(38);
-var _download_manager = __webpack_require__(40);
+var _download_manager = __webpack_require__(39);
-var _genericl10n = __webpack_require__(41);
+var _genericl10n = __webpack_require__(40);
-function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
+var _generic_scripting = __webpack_require__(42);
-function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
@@ -15458,7 +17167,7 @@ var GenericExternalServices = /*#__PURE__*/function (_DefaultExternalServi) {
_createClass(GenericExternalServices, null, [{
key: "createDownloadManager",
value: function createDownloadManager(options) {
- return new _download_manager.DownloadManager(options);
+ return new _download_manager.DownloadManager();
}
}, {
key: "createPreferences",
@@ -15472,6 +17181,12 @@ var GenericExternalServices = /*#__PURE__*/function (_DefaultExternalServi) {
locale = _ref$locale === void 0 ? "en-US" : _ref$locale;
return new _genericl10n.GenericL10n(locale);
}
+ }, {
+ key: "createScripting",
+ value: function createScripting(_ref2) {
+ var sandboxBundleSrc = _ref2.sandboxBundleSrc;
+ return new _generic_scripting.GenericScripting(sandboxBundleSrc);
+ }
}]);
return GenericExternalServices;
@@ -15480,20 +17195,19 @@ var GenericExternalServices = /*#__PURE__*/function (_DefaultExternalServi) {
_app.PDFViewerApplication.externalServices = GenericExternalServices;
/***/ }),
-/* 39 */
-/***/ (function(module, exports, __webpack_require__) {
+/* 38 */
+/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
-"use strict";
-Object.defineProperty(exports, "__esModule", {
+Object.defineProperty(exports, "__esModule", ({
value: true
-});
+}));
exports.BasePreferences = void 0;
-var _regenerator = _interopRequireDefault(__webpack_require__(2));
+var _regenerator = _interopRequireDefault(__webpack_require__(4));
-var _app_options = __webpack_require__(6);
+var _app_options = __webpack_require__(1);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
@@ -15509,39 +17223,6 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
-var defaultPreferences = null;
-
-function getDefaultPreferences() {
- if (!defaultPreferences) {
- defaultPreferences = Promise.resolve({
- "cursorToolOnLoad": 0,
- "defaultZoomValue": "",
- "disablePageLabels": false,
- "enablePermissions": false,
- "enablePrintAutoRotate": false,
- "enableWebGL": false,
- "externalLinkTarget": 0,
- "historyUpdateUrl": false,
- "ignoreDestinationZoom": false,
- "pdfBugEnabled": false,
- "renderer": "canvas",
- "renderInteractiveForms": true,
- "sidebarViewOnLoad": -1,
- "scrollModeOnLoad": -1,
- "spreadModeOnLoad": -1,
- "textLayerMode": 1,
- "useOnlyCssZoom": false,
- "viewOnLoad": 0,
- "disableAutoFetch": false,
- "disableFontFace": false,
- "disableRange": false,
- "disableStream": false
- });
- }
-
- return defaultPreferences;
-}
-
var BasePreferences = /*#__PURE__*/function () {
function BasePreferences() {
var _this = this;
@@ -15552,17 +17233,39 @@ var BasePreferences = /*#__PURE__*/function () {
throw new Error("Cannot initialize BasePreferences.");
}
- this.prefs = null;
- this._initializedPromise = getDefaultPreferences().then(function (defaults) {
- Object.defineProperty(_this, "defaults", {
- value: Object.freeze(defaults),
- writable: false,
- enumerable: true,
- configurable: false
- });
- _this.prefs = Object.assign(Object.create(null), defaults);
- return _this._readFromStorage(defaults);
- }).then(function (prefs) {
+ Object.defineProperty(this, "defaults", {
+ value: Object.freeze({
+ "cursorToolOnLoad": 0,
+ "defaultZoomValue": "",
+ "disablePageLabels": false,
+ "enablePermissions": false,
+ "enablePrintAutoRotate": false,
+ "enableScripting": false,
+ "enableWebGL": false,
+ "externalLinkTarget": 0,
+ "historyUpdateUrl": false,
+ "ignoreDestinationZoom": false,
+ "pdfBugEnabled": false,
+ "renderer": "canvas",
+ "renderInteractiveForms": true,
+ "sidebarViewOnLoad": -1,
+ "scrollModeOnLoad": -1,
+ "spreadModeOnLoad": -1,
+ "textLayerMode": 1,
+ "useOnlyCssZoom": false,
+ "viewerCssTheme": 0,
+ "viewOnLoad": 0,
+ "disableAutoFetch": false,
+ "disableFontFace": false,
+ "disableRange": false,
+ "disableStream": false
+ }),
+ writable: false,
+ enumerable: true,
+ configurable: false
+ });
+ this.prefs = Object.assign(Object.create(null), this.defaults);
+ this._initializedPromise = this._readFromStorage(this.defaults).then(function (prefs) {
if (!prefs) {
return;
}
@@ -15823,20 +17526,19 @@ var BasePreferences = /*#__PURE__*/function () {
exports.BasePreferences = BasePreferences;
/***/ }),
-/* 40 */
-/***/ (function(module, exports, __webpack_require__) {
+/* 39 */
+/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
-"use strict";
-Object.defineProperty(exports, "__esModule", {
+Object.defineProperty(exports, "__esModule", ({
value: true
-});
+}));
exports.DownloadManager = void 0;
-var _pdfjsLib = __webpack_require__(8);
+var _pdfjsLib = __webpack_require__(7);
-var _viewer_compatibility = __webpack_require__(7);
+var _viewer_compatibility = __webpack_require__(2);
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@@ -15882,13 +17584,6 @@ var DownloadManager = /*#__PURE__*/function () {
}, {
key: "downloadData",
value: function downloadData(data, filename, contentType) {
- if (navigator.msSaveBlob) {
- navigator.msSaveBlob(new Blob([data], {
- type: contentType
- }), filename);
- return;
- }
-
var blobUrl = (0, _pdfjsLib.createObjectURL)(data, contentType, _viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL);
_download(blobUrl, filename);
@@ -15898,14 +17593,6 @@ var DownloadManager = /*#__PURE__*/function () {
value: function download(blob, url, filename) {
var sourceEventType = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "download";
- if (navigator.msSaveBlob) {
- if (!navigator.msSaveBlob(blob, filename)) {
- this.downloadUrl(url, filename);
- }
-
- return;
- }
-
if (_viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL) {
this.downloadUrl(url, filename);
return;
@@ -15923,20 +17610,19 @@ var DownloadManager = /*#__PURE__*/function () {
exports.DownloadManager = DownloadManager;
/***/ }),
-/* 41 */
-/***/ (function(module, exports, __webpack_require__) {
+/* 40 */
+/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
-"use strict";
-Object.defineProperty(exports, "__esModule", {
+Object.defineProperty(exports, "__esModule", ({
value: true
-});
+}));
exports.GenericL10n = void 0;
-var _regenerator = _interopRequireDefault(__webpack_require__(2));
+var _regenerator = _interopRequireDefault(__webpack_require__(4));
-__webpack_require__(42);
+__webpack_require__(41);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
@@ -16092,10 +17778,9 @@ var GenericL10n = /*#__PURE__*/function () {
exports.GenericL10n = GenericL10n;
/***/ }),
-/* 42 */
-/***/ (function(module, exports, __webpack_require__) {
+/* 41 */
+/***/ (() => {
-"use strict";
document.webL10n = function (window, document, undefined) {
@@ -16915,22 +18600,154 @@ document.webL10n = function (window, document, undefined) {
}(window, document);
/***/ }),
+/* 42 */
+/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
+
+
+
+Object.defineProperty(exports, "__esModule", ({
+ value: true
+}));
+exports.GenericScripting = void 0;
+
+var _regenerator = _interopRequireDefault(__webpack_require__(4));
+
+var _pdfjsLib = __webpack_require__(7);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
+
+function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
+
+function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
+
+function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
+
+var GenericScripting = /*#__PURE__*/function () {
+ function GenericScripting(sandboxBundleSrc) {
+ _classCallCheck(this, GenericScripting);
+
+ this._ready = (0, _pdfjsLib.loadScript)(sandboxBundleSrc, true).then(function () {
+ return window.pdfjsSandbox.QuickJSSandbox();
+ });
+ }
+
+ _createClass(GenericScripting, [{
+ key: "createSandbox",
+ value: function () {
+ var _createSandbox = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(data) {
+ var sandbox;
+ return _regenerator["default"].wrap(function _callee$(_context) {
+ while (1) {
+ switch (_context.prev = _context.next) {
+ case 0:
+ _context.next = 2;
+ return this._ready;
+
+ case 2:
+ sandbox = _context.sent;
+ sandbox.create(data);
+
+ case 4:
+ case "end":
+ return _context.stop();
+ }
+ }
+ }, _callee, this);
+ }));
+
+ function createSandbox(_x) {
+ return _createSandbox.apply(this, arguments);
+ }
+
+ return createSandbox;
+ }()
+ }, {
+ key: "dispatchEventInSandbox",
+ value: function () {
+ var _dispatchEventInSandbox = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2(event) {
+ var sandbox;
+ return _regenerator["default"].wrap(function _callee2$(_context2) {
+ while (1) {
+ switch (_context2.prev = _context2.next) {
+ case 0:
+ _context2.next = 2;
+ return this._ready;
+
+ case 2:
+ sandbox = _context2.sent;
+ sandbox.dispatchEvent(event);
+
+ case 4:
+ case "end":
+ return _context2.stop();
+ }
+ }
+ }, _callee2, this);
+ }));
+
+ function dispatchEventInSandbox(_x2) {
+ return _dispatchEventInSandbox.apply(this, arguments);
+ }
+
+ return dispatchEventInSandbox;
+ }()
+ }, {
+ key: "destroySandbox",
+ value: function () {
+ var _destroySandbox = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
+ var sandbox;
+ return _regenerator["default"].wrap(function _callee3$(_context3) {
+ while (1) {
+ switch (_context3.prev = _context3.next) {
+ case 0:
+ _context3.next = 2;
+ return this._ready;
+
+ case 2:
+ sandbox = _context3.sent;
+ sandbox.nukeSandbox();
+
+ case 4:
+ case "end":
+ return _context3.stop();
+ }
+ }
+ }, _callee3, this);
+ }));
+
+ function destroySandbox() {
+ return _destroySandbox.apply(this, arguments);
+ }
+
+ return destroySandbox;
+ }()
+ }]);
+
+ return GenericScripting;
+}();
+
+exports.GenericScripting = GenericScripting;
+
+/***/ }),
/* 43 */
-/***/ (function(module, exports, __webpack_require__) {
+/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
-"use strict";
-Object.defineProperty(exports, "__esModule", {
+Object.defineProperty(exports, "__esModule", ({
value: true
-});
+}));
exports.PDFPrintService = PDFPrintService;
-var _ui_utils = __webpack_require__(5);
+var _ui_utils = __webpack_require__(6);
-var _app = __webpack_require__(1);
+var _app = __webpack_require__(3);
-var _viewer_compatibility = __webpack_require__(7);
+var _viewer_compatibility = __webpack_require__(2);
var activeService = null;
var overlayManager = null;
@@ -17215,5 +19032,49 @@ _app.PDFPrintServiceFactory.instance = {
};
/***/ })
-/******/ ]);
+/******/ ]);
+/************************************************************************/
+/******/ // The module cache
+/******/ var __webpack_module_cache__ = {};
+/******/
+/******/ // The require function
+/******/ function __webpack_require__(moduleId) {
+/******/ // Check if module is in cache
+/******/ if(__webpack_module_cache__[moduleId]) {
+/******/ return __webpack_module_cache__[moduleId].exports;
+/******/ }
+/******/ // Create a new module (and put it into the cache)
+/******/ var module = __webpack_module_cache__[moduleId] = {
+/******/ id: moduleId,
+/******/ loaded: false,
+/******/ exports: {}
+/******/ };
+/******/
+/******/ // Execute the module function
+/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
+/******/
+/******/ // Flag the module as loaded
+/******/ module.loaded = true;
+/******/
+/******/ // Return the exports of the module
+/******/ return module.exports;
+/******/ }
+/******/
+/************************************************************************/
+/******/ /* webpack/runtime/node module decorator */
+/******/ (() => {
+/******/ __webpack_require__.nmd = (module) => {
+/******/ module.paths = [];
+/******/ if (!module.children) module.children = [];
+/******/ return module;
+/******/ };
+/******/ })();
+/******/
+/************************************************************************/
+/******/ // startup
+/******/ // Load entry module
+/******/ __webpack_require__(0);
+/******/ // This entry module used 'exports' so it can't be inlined
+/******/ })()
+;
//# sourceMappingURL=viewer.js.map \ No newline at end of file