pdfjs-dist 1.8.430 → 1.8.432

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of pdfjs-dist might be problematic. Click here for more details.

package/bower.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pdfjs-dist",
3
- "version": "1.8.430",
3
+ "version": "1.8.432",
4
4
  "main": [
5
5
  "build/pdf.js",
6
6
  "build/pdf.worker.js"
@@ -1001,14 +1001,37 @@ var createObjectURL = function createObjectURLClosure() {
1001
1001
  return buffer;
1002
1002
  };
1003
1003
  }();
1004
+ function resolveCall(fn, args) {
1005
+ var thisArg = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
1006
+
1007
+ if (!fn) {
1008
+ return Promise.resolve(undefined);
1009
+ }
1010
+ return new Promise(function (resolve, reject) {
1011
+ resolve(fn.apply(thisArg, args));
1012
+ });
1013
+ }
1014
+ function resolveOrReject(capability, success, reason) {
1015
+ if (success) {
1016
+ capability.resolve();
1017
+ } else {
1018
+ capability.reject(reason);
1019
+ }
1020
+ }
1021
+ function finalize(promise) {
1022
+ return Promise.resolve(promise).catch(function () {});
1023
+ }
1004
1024
  function MessageHandler(sourceName, targetName, comObj) {
1005
1025
  var _this = this;
1006
1026
 
1007
1027
  this.sourceName = sourceName;
1008
1028
  this.targetName = targetName;
1009
1029
  this.comObj = comObj;
1010
- this.callbackIndex = 1;
1030
+ this.callbackId = 1;
1031
+ this.streamId = 1;
1011
1032
  this.postMessageTransfers = true;
1033
+ this.streamSinks = Object.create(null);
1034
+ this.streamControllers = Object.create(null);
1012
1035
  var callbacksCapabilities = this.callbacksCapabilities = Object.create(null);
1013
1036
  var ah = this.actionHandler = Object.create(null);
1014
1037
  this._onComObjOnMessage = function (event) {
@@ -1016,7 +1039,9 @@ function MessageHandler(sourceName, targetName, comObj) {
1016
1039
  if (data.targetName !== _this.sourceName) {
1017
1040
  return;
1018
1041
  }
1019
- if (data.isReply) {
1042
+ if (data.stream) {
1043
+ _this._processStreamMessage(data);
1044
+ } else if (data.isReply) {
1020
1045
  var callbackId = data.callbackId;
1021
1046
  if (data.callbackId in callbacksCapabilities) {
1022
1047
  var callback = callbacksCapabilities[callbackId];
@@ -1032,14 +1057,14 @@ function MessageHandler(sourceName, targetName, comObj) {
1032
1057
  } else if (data.action in ah) {
1033
1058
  var action = ah[data.action];
1034
1059
  if (data.callbackId) {
1035
- var sourceName = _this.sourceName;
1036
- var targetName = data.sourceName;
1060
+ var _sourceName = _this.sourceName;
1061
+ var _targetName = data.sourceName;
1037
1062
  Promise.resolve().then(function () {
1038
1063
  return action[0].call(action[1], data.data);
1039
1064
  }).then(function (result) {
1040
1065
  comObj.postMessage({
1041
- sourceName: sourceName,
1042
- targetName: targetName,
1066
+ sourceName: _sourceName,
1067
+ targetName: _targetName,
1043
1068
  isReply: true,
1044
1069
  callbackId: data.callbackId,
1045
1070
  data: result
@@ -1049,13 +1074,15 @@ function MessageHandler(sourceName, targetName, comObj) {
1049
1074
  reason = reason + '';
1050
1075
  }
1051
1076
  comObj.postMessage({
1052
- sourceName: sourceName,
1053
- targetName: targetName,
1077
+ sourceName: _sourceName,
1078
+ targetName: _targetName,
1054
1079
  isReply: true,
1055
1080
  callbackId: data.callbackId,
1056
1081
  error: reason
1057
1082
  });
1058
1083
  });
1084
+ } else if (data.streamId) {
1085
+ _this._createStreamSink(data);
1059
1086
  } else {
1060
1087
  action[0].call(action[1], data.data);
1061
1088
  }
@@ -1083,7 +1110,7 @@ MessageHandler.prototype = {
1083
1110
  this.postMessage(message, transfers);
1084
1111
  },
1085
1112
  sendWithPromise: function sendWithPromise(actionName, data, transfers) {
1086
- var callbackId = this.callbackIndex++;
1113
+ var callbackId = this.callbackId++;
1087
1114
  var message = {
1088
1115
  sourceName: this.sourceName,
1089
1116
  targetName: this.targetName,
@@ -1100,6 +1127,222 @@ MessageHandler.prototype = {
1100
1127
  }
1101
1128
  return capability.promise;
1102
1129
  },
1130
+ sendWithStream: function sendWithStream(actionName, data, queueingStrategy, transfers) {
1131
+ var _this2 = this;
1132
+
1133
+ var streamId = this.streamId++;
1134
+ var sourceName = this.sourceName;
1135
+ var targetName = this.targetName;
1136
+ return new _streamsLib.ReadableStream({
1137
+ start: function start(controller) {
1138
+ var startCapability = createPromiseCapability();
1139
+ _this2.streamControllers[streamId] = {
1140
+ controller: controller,
1141
+ startCall: startCapability
1142
+ };
1143
+ _this2.postMessage({
1144
+ sourceName: sourceName,
1145
+ targetName: targetName,
1146
+ action: actionName,
1147
+ streamId: streamId,
1148
+ data: data,
1149
+ desiredSize: controller.desiredSize
1150
+ });
1151
+ return startCapability.promise;
1152
+ },
1153
+ pull: function pull(controller) {
1154
+ var pullCapability = createPromiseCapability();
1155
+ _this2.streamControllers[streamId].pullCall = pullCapability;
1156
+ _this2.postMessage({
1157
+ sourceName: sourceName,
1158
+ targetName: targetName,
1159
+ stream: 'pull',
1160
+ streamId: streamId,
1161
+ desiredSize: controller.desiredSize
1162
+ });
1163
+ return pullCapability.promise;
1164
+ },
1165
+ cancel: function cancel(reason) {
1166
+ var cancelCapability = createPromiseCapability();
1167
+ _this2.streamControllers[streamId].cancelCall = cancelCapability;
1168
+ _this2.postMessage({
1169
+ sourceName: sourceName,
1170
+ targetName: targetName,
1171
+ stream: 'cancel',
1172
+ reason: reason,
1173
+ streamId: streamId
1174
+ });
1175
+ return cancelCapability.promise;
1176
+ }
1177
+ }, queueingStrategy);
1178
+ },
1179
+ _createStreamSink: function _createStreamSink(data) {
1180
+ var _this3 = this;
1181
+
1182
+ var self = this;
1183
+ var action = this.actionHandler[data.action];
1184
+ var streamId = data.streamId;
1185
+ var desiredSize = data.desiredSize;
1186
+ var sourceName = this.sourceName;
1187
+ var targetName = data.sourceName;
1188
+ var capability = createPromiseCapability();
1189
+ var sendStreamRequest = function sendStreamRequest(_ref) {
1190
+ var stream = _ref.stream,
1191
+ chunk = _ref.chunk,
1192
+ success = _ref.success,
1193
+ reason = _ref.reason;
1194
+
1195
+ _this3.comObj.postMessage({
1196
+ sourceName: sourceName,
1197
+ targetName: targetName,
1198
+ stream: stream,
1199
+ streamId: streamId,
1200
+ chunk: chunk,
1201
+ success: success,
1202
+ reason: reason
1203
+ });
1204
+ };
1205
+ var streamSink = {
1206
+ enqueue: function enqueue(chunk) {
1207
+ var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
1208
+
1209
+ var lastDesiredSize = this.desiredSize;
1210
+ this.desiredSize -= size;
1211
+ if (lastDesiredSize > 0 && this.desiredSize <= 0) {
1212
+ this.sinkCapability = createPromiseCapability();
1213
+ this.ready = this.sinkCapability.promise;
1214
+ }
1215
+ sendStreamRequest({
1216
+ stream: 'enqueue',
1217
+ chunk: chunk
1218
+ });
1219
+ },
1220
+ close: function close() {
1221
+ sendStreamRequest({ stream: 'close' });
1222
+ delete self.streamSinks[streamId];
1223
+ },
1224
+ error: function error(reason) {
1225
+ sendStreamRequest({
1226
+ stream: 'error',
1227
+ reason: reason
1228
+ });
1229
+ },
1230
+
1231
+ sinkCapability: capability,
1232
+ onPull: null,
1233
+ onCancel: null,
1234
+ desiredSize: desiredSize,
1235
+ ready: null
1236
+ };
1237
+ streamSink.sinkCapability.resolve();
1238
+ streamSink.ready = streamSink.sinkCapability.promise;
1239
+ this.streamSinks[streamId] = streamSink;
1240
+ resolveCall(action[0], [data.data, streamSink], action[1]).then(function () {
1241
+ sendStreamRequest({
1242
+ stream: 'start_complete',
1243
+ success: true
1244
+ });
1245
+ }, function (reason) {
1246
+ sendStreamRequest({
1247
+ stream: 'start_complete',
1248
+ success: false,
1249
+ reason: reason
1250
+ });
1251
+ });
1252
+ },
1253
+ _processStreamMessage: function _processStreamMessage(data) {
1254
+ var _this4 = this;
1255
+
1256
+ var sourceName = this.sourceName;
1257
+ var targetName = data.sourceName;
1258
+ var streamId = data.streamId;
1259
+ var sendStreamResponse = function sendStreamResponse(_ref2) {
1260
+ var stream = _ref2.stream,
1261
+ success = _ref2.success,
1262
+ reason = _ref2.reason;
1263
+
1264
+ _this4.comObj.postMessage({
1265
+ sourceName: sourceName,
1266
+ targetName: targetName,
1267
+ stream: stream,
1268
+ success: success,
1269
+ streamId: streamId,
1270
+ reason: reason
1271
+ });
1272
+ };
1273
+ var deleteStreamController = function deleteStreamController() {
1274
+ Promise.all([_this4.streamControllers[data.streamId].startCall, _this4.streamControllers[data.streamId].pullCall, _this4.streamControllers[data.streamId].cancelCall].map(function (capability) {
1275
+ return capability && finalize(capability.promise);
1276
+ })).then(function () {
1277
+ delete _this4.streamControllers[data.streamId];
1278
+ });
1279
+ };
1280
+ switch (data.stream) {
1281
+ case 'start_complete':
1282
+ resolveOrReject(this.streamControllers[data.streamId].startCall, data.success, data.reason);
1283
+ break;
1284
+ case 'pull_complete':
1285
+ resolveOrReject(this.streamControllers[data.streamId].pullCall, data.success, data.reason);
1286
+ break;
1287
+ case 'pull':
1288
+ if (!this.streamSinks[data.streamId]) {
1289
+ sendStreamResponse({
1290
+ stream: 'pull_complete',
1291
+ success: true
1292
+ });
1293
+ break;
1294
+ }
1295
+ if (this.streamSinks[data.streamId].desiredSize <= 0 && data.desiredSize > 0) {
1296
+ this.streamSinks[data.streamId].sinkCapability.resolve();
1297
+ }
1298
+ this.streamSinks[data.streamId].desiredSize = data.desiredSize;
1299
+ resolveCall(this.streamSinks[data.streamId].onPull).then(function () {
1300
+ sendStreamResponse({
1301
+ stream: 'pull_complete',
1302
+ success: true
1303
+ });
1304
+ }, function (reason) {
1305
+ sendStreamResponse({
1306
+ stream: 'pull_complete',
1307
+ success: false,
1308
+ reason: reason
1309
+ });
1310
+ });
1311
+ break;
1312
+ case 'enqueue':
1313
+ this.streamControllers[data.streamId].controller.enqueue(data.chunk);
1314
+ break;
1315
+ case 'close':
1316
+ this.streamControllers[data.streamId].controller.close();
1317
+ deleteStreamController();
1318
+ break;
1319
+ case 'error':
1320
+ this.streamControllers[data.streamId].controller.error(data.reason);
1321
+ deleteStreamController();
1322
+ break;
1323
+ case 'cancel_complete':
1324
+ resolveOrReject(this.streamControllers[data.streamId].cancelCall, data.success, data.reason);
1325
+ deleteStreamController();
1326
+ break;
1327
+ case 'cancel':
1328
+ resolveCall(this.streamSinks[data.streamId].onCancel, [data.reason]).then(function () {
1329
+ sendStreamResponse({
1330
+ stream: 'cancel_complete',
1331
+ success: true
1332
+ });
1333
+ }, function (reason) {
1334
+ sendStreamResponse({
1335
+ stream: 'cancel_complete',
1336
+ success: false,
1337
+ reason: reason
1338
+ });
1339
+ });
1340
+ delete this.streamSinks[data.streamId];
1341
+ break;
1342
+ default:
1343
+ throw new Error('Unexpected stream case');
1344
+ }
1345
+ },
1103
1346
  postMessage: function postMessage(message, transfers) {
1104
1347
  if (transfers && this.postMessageTransfers) {
1105
1348
  this.comObj.postMessage(message, transfers);
@@ -12809,8 +13052,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() {
12809
13052
  }();
12810
13053
  var version, build;
12811
13054
  {
12812
- exports.version = version = '1.8.430';
12813
- exports.build = build = 'e6f5b3e3';
13055
+ exports.version = version = '1.8.432';
13056
+ exports.build = build = '93420545';
12814
13057
  }
12815
13058
  exports.getDocument = getDocument;
12816
13059
  exports.LoopbackPort = LoopbackPort;
@@ -28147,8 +28390,8 @@ if (!_util.globalScope.PDFJS) {
28147
28390
  }
28148
28391
  var PDFJS = _util.globalScope.PDFJS;
28149
28392
  {
28150
- PDFJS.version = '1.8.430';
28151
- PDFJS.build = 'e6f5b3e3';
28393
+ PDFJS.version = '1.8.432';
28394
+ PDFJS.build = '93420545';
28152
28395
  }
28153
28396
  PDFJS.pdfBug = false;
28154
28397
  if (PDFJS.verbosity !== undefined) {
@@ -29793,7 +30036,7 @@ var _typeof2 = typeof Symbol === "function" && typeof Symbol.iterator === "symbo
29793
30036
  }
29794
30037
  if (IsReadableStreamDefaultReader(reader) === true) {
29795
30038
  for (var i = 0; i < reader._readRequests.length; i++) {
29796
- var _resolve = reader._readRequests[i];
30039
+ var _resolve = reader._readRequests[i]._resolve;
29797
30040
  _resolve(CreateIterResultObject(undefined, true));
29798
30041
  }
29799
30042
  reader._readRequests = [];
@@ -46762,8 +47005,8 @@ exports.TilingPattern = TilingPattern;
46762
47005
  "use strict";
46763
47006
 
46764
47007
 
46765
- var pdfjsVersion = '1.8.430';
46766
- var pdfjsBuild = 'e6f5b3e3';
47008
+ var pdfjsVersion = '1.8.432';
47009
+ var pdfjsBuild = '93420545';
46767
47010
  var pdfjsSharedUtil = __w_pdfjs_require__(0);
46768
47011
  var pdfjsDisplayGlobal = __w_pdfjs_require__(26);
46769
47012
  var pdfjsDisplayAPI = __w_pdfjs_require__(10);