Browse Source

PDF.js version 1.5.452 - See mozilla/pdf.js@230b1e327531bda277bd94748b6b7f26eec2c0fb

Pdf Bot 8 years ago
parent
commit
abd6cbad3f
5 changed files with 176 additions and 44 deletions
  1. 1 1
      bower.json
  2. 86 20
      build/pdf.combined.js
  3. 86 20
      build/pdf.js
  4. 2 2
      build/pdf.worker.js
  5. 1 1
      package.json

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
 {
   "name": "pdfjs-dist",
   "name": "pdfjs-dist",
-  "version": "1.5.450",
+  "version": "1.5.452",
   "main": [
   "main": [
     "build/pdf.js",
     "build/pdf.js",
     "build/pdf.worker.js"
     "build/pdf.worker.js"

+ 86 - 20
build/pdf.combined.js

@@ -28,8 +28,8 @@ factory((root.pdfjsDistBuildPdfCombined = {}));
   // Use strict in our context only - users might not want it
   // Use strict in our context only - users might not want it
   'use strict';
   'use strict';
 
 
-var pdfjsVersion = '1.5.450';
-var pdfjsBuild = '6b05cfd';
+var pdfjsVersion = '1.5.452';
+var pdfjsBuild = '230b1e3';
 
 
   var pdfjsFilePath =
   var pdfjsFilePath =
     typeof document !== 'undefined' && document.currentScript ?
     typeof document !== 'undefined' && document.currentScript ?
@@ -39122,6 +39122,7 @@ var deprecated = sharedUtil.deprecated;
 var getVerbosityLevel = sharedUtil.getVerbosityLevel;
 var getVerbosityLevel = sharedUtil.getVerbosityLevel;
 var info = sharedUtil.info;
 var info = sharedUtil.info;
 var isInt = sharedUtil.isInt;
 var isInt = sharedUtil.isInt;
+var isArray = sharedUtil.isArray;
 var isArrayBuffer = sharedUtil.isArrayBuffer;
 var isArrayBuffer = sharedUtil.isArrayBuffer;
 var isSameOrigin = sharedUtil.isSameOrigin;
 var isSameOrigin = sharedUtil.isSameOrigin;
 var loadJpegStream = sharedUtil.loadJpegStream;
 var loadJpegStream = sharedUtil.loadJpegStream;
@@ -40113,6 +40114,84 @@ var PDFWorker = (function PDFWorkerClosure() {
     return fakeWorkerFilesLoadedCapability.promise;
     return fakeWorkerFilesLoadedCapability.promise;
   }
   }
 
 
+  function FakeWorkerPort(defer) {
+    this._listeners = [];
+    this._defer = defer;
+    this._deferred = Promise.resolve(undefined);
+  }
+  FakeWorkerPort.prototype = {
+    postMessage: function (obj, transfers) {
+      function cloneValue(value) {
+        // Trying to perform a structured clone close to the spec, including
+        // transfers.
+        if (typeof value !== 'object' || value === null) {
+          return value;
+        }
+        if (cloned.has(value)) { // already cloned the object
+          return cloned.get(value);
+        }
+        var result;
+        var buffer;
+        if ((buffer = value.buffer) && isArrayBuffer(buffer)) {
+          // We found object with ArrayBuffer (typed array).
+          var transferable = transfers && transfers.indexOf(buffer) >= 0;
+          if (value === buffer) {
+            // Special case when we are faking typed arrays in compatibility.js.
+            result = value;
+          } else if (transferable) {
+            result = new value.constructor(buffer, value.byteOffset,
+                                           value.byteLength);
+          } else {
+            result = new value.constructor(value);
+          }
+          cloned.set(value, result);
+          return result;
+        }
+        result = isArray(value) ? [] : {};
+        cloned.set(value, result); // adding to cache now for cyclic references
+        // Cloning all value and object properties, however ignoring properties
+        // defined via getter.
+        for (var i in value) {
+          var desc, p = value;
+          while (!(desc = Object.getOwnPropertyDescriptor(p, i))) {
+            p = Object.getPrototypeOf(p);
+          }
+          if (typeof desc.value === 'undefined' ||
+              typeof desc.value === 'function') {
+            continue;
+          }
+          result[i] = cloneValue(desc.value);
+        }
+        return result;
+      }
+
+      if (!this._defer) {
+        this._listeners.forEach(function (listener) {
+          listener.call(this, {data: obj});
+        }, this);
+        return;
+      }
+
+      var cloned = new WeakMap();
+      var e = {data: cloneValue(obj)};
+      this._deferred.then(function () {
+        this._listeners.forEach(function (listener) {
+          listener.call(this, e);
+        }, this);
+      }.bind(this));
+    },
+    addEventListener: function (name, listener) {
+      this._listeners.push(listener);
+    },
+    removeEventListener: function (name, listener) {
+      var i = this._listeners.indexOf(listener);
+      this._listeners.splice(i, 1);
+    },
+    terminate: function () {
+      this._listeners = [];
+    }
+  };
+
   function createCDNWrapper(url) {
   function createCDNWrapper(url) {
     // We will rely on blob URL's property to specify origin.
     // We will rely on blob URL's property to specify origin.
     // We want this function to fail in case if createObjectURL or Blob do not
     // We want this function to fail in case if createObjectURL or Blob do not
@@ -40168,24 +40247,11 @@ var PDFWorker = (function PDFWorkerClosure() {
           return;
           return;
         }
         }
 
 
-        // If we don't use a worker, just post/sendMessage to the main thread.
-        var port = {
-          _listeners: [],
-          postMessage: function (obj) {
-            var e = {data: obj};
-            this._listeners.forEach(function (listener) {
-              listener.call(this, e);
-            }, this);
-          },
-          addEventListener: function (name, listener) {
-            this._listeners.push(listener);
-          },
-          removeEventListener: function (name, listener) {
-            var i = this._listeners.indexOf(listener);
-            this._listeners.splice(i, 1);
-          },
-          terminate: function () {}
-        };
+        // We cannot turn on proper fake port simulation (this includes
+        // structured cloning) when typed arrays are not supported. Relying
+        // on a chance that messages will be sent in proper order.
+        var isTypedArraysPresent = Uint8Array !== Float32Array;
+        var port = new FakeWorkerPort(isTypedArraysPresent);
         this._port = port;
         this._port = port;
 
 
         // All fake workers use the same port, making id unique.
         // All fake workers use the same port, making id unique.

+ 86 - 20
build/pdf.js

@@ -28,8 +28,8 @@ factory((root.pdfjsDistBuildPdf = {}));
   // Use strict in our context only - users might not want it
   // Use strict in our context only - users might not want it
   'use strict';
   'use strict';
 
 
-var pdfjsVersion = '1.5.450';
-var pdfjsBuild = '6b05cfd';
+var pdfjsVersion = '1.5.452';
+var pdfjsBuild = '230b1e3';
 
 
   var pdfjsFilePath =
   var pdfjsFilePath =
     typeof document !== 'undefined' && document.currentScript ?
     typeof document !== 'undefined' && document.currentScript ?
@@ -9042,6 +9042,7 @@ var deprecated = sharedUtil.deprecated;
 var getVerbosityLevel = sharedUtil.getVerbosityLevel;
 var getVerbosityLevel = sharedUtil.getVerbosityLevel;
 var info = sharedUtil.info;
 var info = sharedUtil.info;
 var isInt = sharedUtil.isInt;
 var isInt = sharedUtil.isInt;
+var isArray = sharedUtil.isArray;
 var isArrayBuffer = sharedUtil.isArrayBuffer;
 var isArrayBuffer = sharedUtil.isArrayBuffer;
 var isSameOrigin = sharedUtil.isSameOrigin;
 var isSameOrigin = sharedUtil.isSameOrigin;
 var loadJpegStream = sharedUtil.loadJpegStream;
 var loadJpegStream = sharedUtil.loadJpegStream;
@@ -10065,6 +10066,84 @@ var PDFWorker = (function PDFWorkerClosure() {
     return fakeWorkerFilesLoadedCapability.promise;
     return fakeWorkerFilesLoadedCapability.promise;
   }
   }
 
 
+  function FakeWorkerPort(defer) {
+    this._listeners = [];
+    this._defer = defer;
+    this._deferred = Promise.resolve(undefined);
+  }
+  FakeWorkerPort.prototype = {
+    postMessage: function (obj, transfers) {
+      function cloneValue(value) {
+        // Trying to perform a structured clone close to the spec, including
+        // transfers.
+        if (typeof value !== 'object' || value === null) {
+          return value;
+        }
+        if (cloned.has(value)) { // already cloned the object
+          return cloned.get(value);
+        }
+        var result;
+        var buffer;
+        if ((buffer = value.buffer) && isArrayBuffer(buffer)) {
+          // We found object with ArrayBuffer (typed array).
+          var transferable = transfers && transfers.indexOf(buffer) >= 0;
+          if (value === buffer) {
+            // Special case when we are faking typed arrays in compatibility.js.
+            result = value;
+          } else if (transferable) {
+            result = new value.constructor(buffer, value.byteOffset,
+                                           value.byteLength);
+          } else {
+            result = new value.constructor(value);
+          }
+          cloned.set(value, result);
+          return result;
+        }
+        result = isArray(value) ? [] : {};
+        cloned.set(value, result); // adding to cache now for cyclic references
+        // Cloning all value and object properties, however ignoring properties
+        // defined via getter.
+        for (var i in value) {
+          var desc, p = value;
+          while (!(desc = Object.getOwnPropertyDescriptor(p, i))) {
+            p = Object.getPrototypeOf(p);
+          }
+          if (typeof desc.value === 'undefined' ||
+              typeof desc.value === 'function') {
+            continue;
+          }
+          result[i] = cloneValue(desc.value);
+        }
+        return result;
+      }
+
+      if (!this._defer) {
+        this._listeners.forEach(function (listener) {
+          listener.call(this, {data: obj});
+        }, this);
+        return;
+      }
+
+      var cloned = new WeakMap();
+      var e = {data: cloneValue(obj)};
+      this._deferred.then(function () {
+        this._listeners.forEach(function (listener) {
+          listener.call(this, e);
+        }, this);
+      }.bind(this));
+    },
+    addEventListener: function (name, listener) {
+      this._listeners.push(listener);
+    },
+    removeEventListener: function (name, listener) {
+      var i = this._listeners.indexOf(listener);
+      this._listeners.splice(i, 1);
+    },
+    terminate: function () {
+      this._listeners = [];
+    }
+  };
+
   function createCDNWrapper(url) {
   function createCDNWrapper(url) {
     // We will rely on blob URL's property to specify origin.
     // We will rely on blob URL's property to specify origin.
     // We want this function to fail in case if createObjectURL or Blob do not
     // We want this function to fail in case if createObjectURL or Blob do not
@@ -10230,24 +10309,11 @@ var PDFWorker = (function PDFWorkerClosure() {
           return;
           return;
         }
         }
 
 
-        // If we don't use a worker, just post/sendMessage to the main thread.
-        var port = {
-          _listeners: [],
-          postMessage: function (obj) {
-            var e = {data: obj};
-            this._listeners.forEach(function (listener) {
-              listener.call(this, e);
-            }, this);
-          },
-          addEventListener: function (name, listener) {
-            this._listeners.push(listener);
-          },
-          removeEventListener: function (name, listener) {
-            var i = this._listeners.indexOf(listener);
-            this._listeners.splice(i, 1);
-          },
-          terminate: function () {}
-        };
+        // We cannot turn on proper fake port simulation (this includes
+        // structured cloning) when typed arrays are not supported. Relying
+        // on a chance that messages will be sent in proper order.
+        var isTypedArraysPresent = Uint8Array !== Float32Array;
+        var port = new FakeWorkerPort(isTypedArraysPresent);
         this._port = port;
         this._port = port;
 
 
         // All fake workers use the same port, making id unique.
         // All fake workers use the same port, making id unique.

+ 2 - 2
build/pdf.worker.js

@@ -28,8 +28,8 @@ factory((root.pdfjsDistBuildPdfWorker = {}));
   // Use strict in our context only - users might not want it
   // Use strict in our context only - users might not want it
   'use strict';
   'use strict';
 
 
-var pdfjsVersion = '1.5.450';
-var pdfjsBuild = '6b05cfd';
+var pdfjsVersion = '1.5.452';
+var pdfjsBuild = '230b1e3';
 
 
   var pdfjsFilePath =
   var pdfjsFilePath =
     typeof document !== 'undefined' && document.currentScript ?
     typeof document !== 'undefined' && document.currentScript ?

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
 {
   "name": "pdfjs-dist",
   "name": "pdfjs-dist",
-  "version": "1.5.450",
+  "version": "1.5.452",
   "main": "build/pdf.js",
   "main": "build/pdf.js",
   "description": "Generic build of Mozilla's PDF.js library.",
   "description": "Generic build of Mozilla's PDF.js library.",
   "keywords": [
   "keywords": [