react-pdf-js
Advanced tools
Comparing version 1.0.27 to 1.0.28
157
lib/Pdf.js
@@ -27,2 +27,6 @@ 'use strict'; | ||
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn'); | ||
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2); | ||
var _createClass2 = require('babel-runtime/helpers/createClass'); | ||
@@ -32,6 +36,2 @@ | ||
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn'); | ||
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2); | ||
var _inherits2 = require('babel-runtime/helpers/inherits'); | ||
@@ -76,7 +76,77 @@ | ||
(0, _inherits3.default)(Pdf, _React$Component); | ||
(0, _createClass3.default)(Pdf, null, [{ | ||
key: 'onDocumentError', | ||
value: function onDocumentError(err) { | ||
if (err.isCanceled && err.pdf) { | ||
err.pdf.destroy(); | ||
} | ||
} | ||
// Converts an ArrayBuffer directly to base64, without any intermediate 'convert to string then | ||
// use window.btoa' step and without risking a blow of the stack. According to [Jon Leightons's] | ||
// tests, this appears to be a faster approach: http://jsperf.com/encoding-xhr-image-data/5 | ||
// Jon Leighton https://gist.github.com/jonleighton/958841 | ||
}, { | ||
key: 'defaultBinaryToBase64', | ||
value: function defaultBinaryToBase64(arrayBuffer) { | ||
var base64 = ''; | ||
var encodings = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; | ||
var bytes = new Uint8Array(arrayBuffer); | ||
var byteLength = bytes.byteLength; | ||
var byteRemainder = byteLength % 3; | ||
var mainLength = byteLength - byteRemainder; | ||
var a = void 0; | ||
var b = void 0; | ||
var c = void 0; | ||
var d = void 0; | ||
var chunk = void 0; | ||
// Main loop deals with bytes in chunks of 3 | ||
for (var i = 0; i < mainLength; i += 3) { | ||
// Combine the three bytes into a single integer | ||
chunk = bytes[i] << 16 | bytes[i + 1] << 8 | bytes[i + 2]; | ||
// Use bitmasks to extract 6-bit segments from the triplet | ||
a = (chunk & 16515072) >> 18; // 16515072 = (2^6 - 1) << 18 | ||
b = (chunk & 258048) >> 12; // 258048 = (2^6 - 1) << 12 | ||
c = (chunk & 4032) >> 6; // 4032 = (2^6 - 1) << 6 | ||
d = chunk & 63; // 63 = 2^6 - 1 | ||
// Convert the raw binary segments to the appropriate ASCII encoding | ||
base64 = [base64, encodings[a], encodings[b], encodings[c], encodings[d]].join(''); | ||
} | ||
// Deal with the remaining bytes and padding | ||
if (byteRemainder === 1) { | ||
chunk = bytes[mainLength]; | ||
a = (chunk & 252) >> 2; // 252 = (2^6 - 1) << 2 | ||
// Set the 4 least significant bits to zero | ||
b = (chunk & 3) << 4; // 3 = 2^2 - 1 | ||
base64 = [base64, encodings[a], encodings[b], '=='].join(''); | ||
} else if (byteRemainder === 2) { | ||
chunk = bytes[mainLength] << 8 | bytes[mainLength + 1]; | ||
a = (chunk & 64512) >> 10; // 64512 = (2^6 - 1) << 10 | ||
b = (chunk & 1008) >> 4; // 1008 = (2^6 - 1) << 4 | ||
// Set the 2 least significant bits to zero | ||
c = (chunk & 15) << 2; // 15 = 2^4 - 1 | ||
base64 = [base64, encodings[a], encodings[b], encodings[c], '='].join(''); | ||
} | ||
return base64; | ||
} | ||
}]); | ||
function Pdf(props) { | ||
(0, _classCallCheck3.default)(this, Pdf); | ||
var _this = (0, _possibleConstructorReturn3.default)(this, (0, _getPrototypeOf2.default)(Pdf).call(this, props)); | ||
var _this = (0, _possibleConstructorReturn3.default)(this, (Pdf.__proto__ || (0, _getPrototypeOf2.default)(Pdf)).call(this, props)); | ||
@@ -192,9 +262,2 @@ _this.state = {}; | ||
}, { | ||
key: 'onDocumentError', | ||
value: function onDocumentError(err) { | ||
if (err.isCanceled && err.pdf) { | ||
err.pdf.destroy(); | ||
} | ||
} | ||
}, { | ||
key: 'onPageComplete', | ||
@@ -252,3 +315,3 @@ value: function onPageComplete(page) { | ||
var byteArray = new Uint8Array(new ArrayBuffer(byteLength)); | ||
for (var index = 0; index < byteLength; index++) { | ||
for (var index = 0; index < byteLength; index += 1) { | ||
byteArray[index] = bytes.charCodeAt(index); | ||
@@ -263,65 +326,3 @@ } | ||
} | ||
// Converts an ArrayBuffer directly to base64, without any intermediate 'convert to string then | ||
// use window.btoa' step and without risking a blow of the stack. According to [Jon Leightons's] | ||
// tests, this appears to be a faster approach: http://jsperf.com/encoding-xhr-image-data/5 | ||
// Jon Leighton https://gist.github.com/jonleighton/958841 | ||
}, { | ||
key: 'defaultBinaryToBase64', | ||
value: function defaultBinaryToBase64(arrayBuffer) { | ||
var base64 = ''; | ||
var encodings = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; | ||
var bytes = new Uint8Array(arrayBuffer); | ||
var byteLength = bytes.byteLength; | ||
var byteRemainder = byteLength % 3; | ||
var mainLength = byteLength - byteRemainder; | ||
var a = void 0; | ||
var b = void 0; | ||
var c = void 0; | ||
var d = void 0; | ||
var chunk = void 0; | ||
// Main loop deals with bytes in chunks of 3 | ||
for (var i = 0; i < mainLength; i += 3) { | ||
// Combine the three bytes into a single integer | ||
chunk = bytes[i] << 16 | bytes[i + 1] << 8 | bytes[i + 2]; | ||
// Use bitmasks to extract 6-bit segments from the triplet | ||
a = (chunk & 16515072) >> 18; // 16515072 = (2^6 - 1) << 18 | ||
b = (chunk & 258048) >> 12; // 258048 = (2^6 - 1) << 12 | ||
c = (chunk & 4032) >> 6; // 4032 = (2^6 - 1) << 6 | ||
d = chunk & 63; // 63 = 2^6 - 1 | ||
// Convert the raw binary segments to the appropriate ASCII encoding | ||
base64 = [base64, encodings[a], encodings[b], encodings[c], encodings[d]].join(''); | ||
} | ||
// Deal with the remaining bytes and padding | ||
if (byteRemainder === 1) { | ||
chunk = bytes[mainLength]; | ||
a = (chunk & 252) >> 2; // 252 = (2^6 - 1) << 2 | ||
// Set the 4 least significant bits to zero | ||
b = (chunk & 3) << 4; // 3 = 2^2 - 1 | ||
base64 = [base64, encodings[a], encodings[b], '=='].join(''); | ||
} else if (byteRemainder === 2) { | ||
chunk = bytes[mainLength] << 8 | bytes[mainLength + 1]; | ||
a = (chunk & 64512) >> 10; // 64512 = (2^6 - 1) << 10 | ||
b = (chunk & 1008) >> 4; // 1008 = (2^6 - 1) << 4 | ||
// Set the 2 least significant bits to zero | ||
c = (chunk & 15) << 2; // 15 = 2^4 - 1 | ||
base64 = [base64, encodings[a], encodings[b], encodings[c], '='].join(''); | ||
} | ||
return base64; | ||
} | ||
}, { | ||
key: 'renderPdf', | ||
@@ -352,3 +353,3 @@ value: function renderPdf() { | ||
return page ? _react2.default.createElement('canvas', { ref: function ref(c) { | ||
return _this3.canvas = c; | ||
_this3.canvas = c; | ||
} }) : loading || _react2.default.createElement( | ||
@@ -367,4 +368,4 @@ 'div', | ||
content: _react2.default.PropTypes.string, | ||
documentInitParameters: _react2.default.PropTypes.object, | ||
binaryContent: _react2.default.PropTypes.object, | ||
documentInitParameters: _react2.default.PropTypes.shape, | ||
binaryContent: _react2.default.PropTypes.shape, | ||
file: _react2.default.PropTypes.any, // Could be File object or URL string. | ||
@@ -371,0 +372,0 @@ loading: _react2.default.PropTypes.any, |
{ | ||
"name": "react-pdf-js", | ||
"version": "1.0.27", | ||
"version": "1.0.28", | ||
"description": "A React component to wrap PDF.js", | ||
@@ -17,3 +17,3 @@ "main": "./lib/index.js", | ||
"clean": "rimraf dist lib", | ||
"lint": "eslint src", | ||
"lint": "eslint src --ext .js --ext .jsx", | ||
"prepublish": "npm run lint && npm run clean && npm run build" | ||
@@ -34,24 +34,24 @@ }, | ||
"dependencies": { | ||
"pdfjs-dist": "1.5.376", | ||
"react": "15.3.0" | ||
"pdfjs-dist": "1.5.496", | ||
"react": "15.3.2" | ||
}, | ||
"devDependencies": { | ||
"babel-cli": "6.11.4", | ||
"babel-core": "6.13.2", | ||
"babel-eslint": "6.1.2", | ||
"babel-loader": "6.2.4", | ||
"babel-cli": "6.14.0", | ||
"babel-core": "6.14.0", | ||
"babel-eslint": "7.0.0", | ||
"babel-loader": "6.2.5", | ||
"babel-plugin-react-transform": "2.0.2", | ||
"babel-plugin-transform-runtime": "6.12.0", | ||
"babel-plugin-transform-runtime": "6.15.0", | ||
"babel-plugin-typecheck": "3.9.0", | ||
"babel-preset-es2015": "6.13.2", | ||
"babel-preset-es2015": "6.14.0", | ||
"babel-preset-react": "6.11.1", | ||
"babel-runtime": "6.11.6", | ||
"eslint": "3.3.0", | ||
"eslint-config-airbnb": "10.0.1", | ||
"eslint-plugin-import": "1.13.0", | ||
"eslint-plugin-react": "6.1.0", | ||
"eslint-plugin-jsx-a11y": "2.1.0", | ||
"eslint": "3.6.1", | ||
"eslint-config-airbnb": "12.0.0", | ||
"eslint-plugin-import": "1.16.0", | ||
"eslint-plugin-react": "6.3.0", | ||
"eslint-plugin-jsx-a11y": "2.2.2", | ||
"rifraf": "2.0.2", | ||
"rimraf": "2.5.4", | ||
"webpack": "1.13.1" | ||
"webpack": "1.13.2" | ||
}, | ||
@@ -58,0 +58,0 @@ "npmName": "react-pdf-js", |
import Pdf from './Pdf'; | ||
export default Pdf; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
2676341
10
54979
+ Addedpdfjs-dist@1.5.496(transitive)
+ Addedreact@15.3.2(transitive)
- Removedpdfjs-dist@1.5.376(transitive)
- Removedreact@15.3.0(transitive)
Updatedpdfjs-dist@1.5.496
Updatedreact@15.3.2