pdfjs-dist 1.8.425 → 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.

@@ -1960,7 +1960,8 @@ function ReadableStreamClose(stream) {
1960
1960
 
1961
1961
  if (IsReadableStreamDefaultReader(reader) === true) {
1962
1962
  for (var i = 0; i < reader._readRequests.length; i++) {
1963
- var _resolve = reader._readRequests[i];
1963
+ var _resolve = reader._readRequests[i]._resolve;
1964
+
1964
1965
  _resolve(CreateIterResultObject(undefined, true));
1965
1966
  }
1966
1967
  reader._readRequests = [];
@@ -1418,8 +1418,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() {
1418
1418
  }();
1419
1419
  var version, build;
1420
1420
  {
1421
- exports.version = version = '1.8.425';
1422
- exports.build = build = 'fccb0b5c';
1421
+ exports.version = version = '1.8.432';
1422
+ exports.build = build = '93420545';
1423
1423
  }
1424
1424
  exports.getDocument = getDocument;
1425
1425
  exports.LoopbackPort = LoopbackPort;
@@ -39,8 +39,8 @@ if (!_util.globalScope.PDFJS) {
39
39
  }
40
40
  var PDFJS = _util.globalScope.PDFJS;
41
41
  {
42
- PDFJS.version = '1.8.425';
43
- PDFJS.build = 'fccb0b5c';
42
+ PDFJS.version = '1.8.432';
43
+ PDFJS.build = '93420545';
44
44
  }
45
45
  PDFJS.pdfBug = false;
46
46
  if (PDFJS.verbosity !== undefined) {
package/lib/pdf.js CHANGED
@@ -14,8 +14,8 @@
14
14
  */
15
15
  'use strict';
16
16
 
17
- var pdfjsVersion = '1.8.425';
18
- var pdfjsBuild = 'fccb0b5c';
17
+ var pdfjsVersion = '1.8.432';
18
+ var pdfjsBuild = '93420545';
19
19
  var pdfjsSharedUtil = require('./shared/util.js');
20
20
  var pdfjsDisplayGlobal = require('./display/global.js');
21
21
  var pdfjsDisplayAPI = require('./display/api.js');
package/lib/pdf.worker.js CHANGED
@@ -14,8 +14,8 @@
14
14
  */
15
15
  'use strict';
16
16
 
17
- var pdfjsVersion = '1.8.425';
18
- var pdfjsBuild = 'fccb0b5c';
17
+ var pdfjsVersion = '1.8.432';
18
+ var pdfjsBuild = '93420545';
19
19
  var pdfjsCoreWorker = require('./core/worker.js');
20
20
  {
21
21
  require('./core/network.js');
@@ -917,14 +917,37 @@ var createObjectURL = function createObjectURLClosure() {
917
917
  return buffer;
918
918
  };
919
919
  }();
920
+ function resolveCall(fn, args) {
921
+ var thisArg = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
922
+
923
+ if (!fn) {
924
+ return Promise.resolve(undefined);
925
+ }
926
+ return new Promise(function (resolve, reject) {
927
+ resolve(fn.apply(thisArg, args));
928
+ });
929
+ }
930
+ function resolveOrReject(capability, success, reason) {
931
+ if (success) {
932
+ capability.resolve();
933
+ } else {
934
+ capability.reject(reason);
935
+ }
936
+ }
937
+ function finalize(promise) {
938
+ return Promise.resolve(promise).catch(function () {});
939
+ }
920
940
  function MessageHandler(sourceName, targetName, comObj) {
921
941
  var _this = this;
922
942
 
923
943
  this.sourceName = sourceName;
924
944
  this.targetName = targetName;
925
945
  this.comObj = comObj;
926
- this.callbackIndex = 1;
946
+ this.callbackId = 1;
947
+ this.streamId = 1;
927
948
  this.postMessageTransfers = true;
949
+ this.streamSinks = Object.create(null);
950
+ this.streamControllers = Object.create(null);
928
951
  var callbacksCapabilities = this.callbacksCapabilities = Object.create(null);
929
952
  var ah = this.actionHandler = Object.create(null);
930
953
  this._onComObjOnMessage = function (event) {
@@ -932,7 +955,9 @@ function MessageHandler(sourceName, targetName, comObj) {
932
955
  if (data.targetName !== _this.sourceName) {
933
956
  return;
934
957
  }
935
- if (data.isReply) {
958
+ if (data.stream) {
959
+ _this._processStreamMessage(data);
960
+ } else if (data.isReply) {
936
961
  var callbackId = data.callbackId;
937
962
  if (data.callbackId in callbacksCapabilities) {
938
963
  var callback = callbacksCapabilities[callbackId];
@@ -948,14 +973,14 @@ function MessageHandler(sourceName, targetName, comObj) {
948
973
  } else if (data.action in ah) {
949
974
  var action = ah[data.action];
950
975
  if (data.callbackId) {
951
- var sourceName = _this.sourceName;
952
- var targetName = data.sourceName;
976
+ var _sourceName = _this.sourceName;
977
+ var _targetName = data.sourceName;
953
978
  Promise.resolve().then(function () {
954
979
  return action[0].call(action[1], data.data);
955
980
  }).then(function (result) {
956
981
  comObj.postMessage({
957
- sourceName: sourceName,
958
- targetName: targetName,
982
+ sourceName: _sourceName,
983
+ targetName: _targetName,
959
984
  isReply: true,
960
985
  callbackId: data.callbackId,
961
986
  data: result
@@ -965,13 +990,15 @@ function MessageHandler(sourceName, targetName, comObj) {
965
990
  reason = reason + '';
966
991
  }
967
992
  comObj.postMessage({
968
- sourceName: sourceName,
969
- targetName: targetName,
993
+ sourceName: _sourceName,
994
+ targetName: _targetName,
970
995
  isReply: true,
971
996
  callbackId: data.callbackId,
972
997
  error: reason
973
998
  });
974
999
  });
1000
+ } else if (data.streamId) {
1001
+ _this._createStreamSink(data);
975
1002
  } else {
976
1003
  action[0].call(action[1], data.data);
977
1004
  }
@@ -999,7 +1026,7 @@ MessageHandler.prototype = {
999
1026
  this.postMessage(message, transfers);
1000
1027
  },
1001
1028
  sendWithPromise: function sendWithPromise(actionName, data, transfers) {
1002
- var callbackId = this.callbackIndex++;
1029
+ var callbackId = this.callbackId++;
1003
1030
  var message = {
1004
1031
  sourceName: this.sourceName,
1005
1032
  targetName: this.targetName,
@@ -1016,6 +1043,222 @@ MessageHandler.prototype = {
1016
1043
  }
1017
1044
  return capability.promise;
1018
1045
  },
1046
+ sendWithStream: function sendWithStream(actionName, data, queueingStrategy, transfers) {
1047
+ var _this2 = this;
1048
+
1049
+ var streamId = this.streamId++;
1050
+ var sourceName = this.sourceName;
1051
+ var targetName = this.targetName;
1052
+ return new _streamsLib.ReadableStream({
1053
+ start: function start(controller) {
1054
+ var startCapability = createPromiseCapability();
1055
+ _this2.streamControllers[streamId] = {
1056
+ controller: controller,
1057
+ startCall: startCapability
1058
+ };
1059
+ _this2.postMessage({
1060
+ sourceName: sourceName,
1061
+ targetName: targetName,
1062
+ action: actionName,
1063
+ streamId: streamId,
1064
+ data: data,
1065
+ desiredSize: controller.desiredSize
1066
+ });
1067
+ return startCapability.promise;
1068
+ },
1069
+ pull: function pull(controller) {
1070
+ var pullCapability = createPromiseCapability();
1071
+ _this2.streamControllers[streamId].pullCall = pullCapability;
1072
+ _this2.postMessage({
1073
+ sourceName: sourceName,
1074
+ targetName: targetName,
1075
+ stream: 'pull',
1076
+ streamId: streamId,
1077
+ desiredSize: controller.desiredSize
1078
+ });
1079
+ return pullCapability.promise;
1080
+ },
1081
+ cancel: function cancel(reason) {
1082
+ var cancelCapability = createPromiseCapability();
1083
+ _this2.streamControllers[streamId].cancelCall = cancelCapability;
1084
+ _this2.postMessage({
1085
+ sourceName: sourceName,
1086
+ targetName: targetName,
1087
+ stream: 'cancel',
1088
+ reason: reason,
1089
+ streamId: streamId
1090
+ });
1091
+ return cancelCapability.promise;
1092
+ }
1093
+ }, queueingStrategy);
1094
+ },
1095
+ _createStreamSink: function _createStreamSink(data) {
1096
+ var _this3 = this;
1097
+
1098
+ var self = this;
1099
+ var action = this.actionHandler[data.action];
1100
+ var streamId = data.streamId;
1101
+ var desiredSize = data.desiredSize;
1102
+ var sourceName = this.sourceName;
1103
+ var targetName = data.sourceName;
1104
+ var capability = createPromiseCapability();
1105
+ var sendStreamRequest = function sendStreamRequest(_ref) {
1106
+ var stream = _ref.stream,
1107
+ chunk = _ref.chunk,
1108
+ success = _ref.success,
1109
+ reason = _ref.reason;
1110
+
1111
+ _this3.comObj.postMessage({
1112
+ sourceName: sourceName,
1113
+ targetName: targetName,
1114
+ stream: stream,
1115
+ streamId: streamId,
1116
+ chunk: chunk,
1117
+ success: success,
1118
+ reason: reason
1119
+ });
1120
+ };
1121
+ var streamSink = {
1122
+ enqueue: function enqueue(chunk) {
1123
+ var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
1124
+
1125
+ var lastDesiredSize = this.desiredSize;
1126
+ this.desiredSize -= size;
1127
+ if (lastDesiredSize > 0 && this.desiredSize <= 0) {
1128
+ this.sinkCapability = createPromiseCapability();
1129
+ this.ready = this.sinkCapability.promise;
1130
+ }
1131
+ sendStreamRequest({
1132
+ stream: 'enqueue',
1133
+ chunk: chunk
1134
+ });
1135
+ },
1136
+ close: function close() {
1137
+ sendStreamRequest({ stream: 'close' });
1138
+ delete self.streamSinks[streamId];
1139
+ },
1140
+ error: function error(reason) {
1141
+ sendStreamRequest({
1142
+ stream: 'error',
1143
+ reason: reason
1144
+ });
1145
+ },
1146
+
1147
+ sinkCapability: capability,
1148
+ onPull: null,
1149
+ onCancel: null,
1150
+ desiredSize: desiredSize,
1151
+ ready: null
1152
+ };
1153
+ streamSink.sinkCapability.resolve();
1154
+ streamSink.ready = streamSink.sinkCapability.promise;
1155
+ this.streamSinks[streamId] = streamSink;
1156
+ resolveCall(action[0], [data.data, streamSink], action[1]).then(function () {
1157
+ sendStreamRequest({
1158
+ stream: 'start_complete',
1159
+ success: true
1160
+ });
1161
+ }, function (reason) {
1162
+ sendStreamRequest({
1163
+ stream: 'start_complete',
1164
+ success: false,
1165
+ reason: reason
1166
+ });
1167
+ });
1168
+ },
1169
+ _processStreamMessage: function _processStreamMessage(data) {
1170
+ var _this4 = this;
1171
+
1172
+ var sourceName = this.sourceName;
1173
+ var targetName = data.sourceName;
1174
+ var streamId = data.streamId;
1175
+ var sendStreamResponse = function sendStreamResponse(_ref2) {
1176
+ var stream = _ref2.stream,
1177
+ success = _ref2.success,
1178
+ reason = _ref2.reason;
1179
+
1180
+ _this4.comObj.postMessage({
1181
+ sourceName: sourceName,
1182
+ targetName: targetName,
1183
+ stream: stream,
1184
+ success: success,
1185
+ streamId: streamId,
1186
+ reason: reason
1187
+ });
1188
+ };
1189
+ var deleteStreamController = function deleteStreamController() {
1190
+ Promise.all([_this4.streamControllers[data.streamId].startCall, _this4.streamControllers[data.streamId].pullCall, _this4.streamControllers[data.streamId].cancelCall].map(function (capability) {
1191
+ return capability && finalize(capability.promise);
1192
+ })).then(function () {
1193
+ delete _this4.streamControllers[data.streamId];
1194
+ });
1195
+ };
1196
+ switch (data.stream) {
1197
+ case 'start_complete':
1198
+ resolveOrReject(this.streamControllers[data.streamId].startCall, data.success, data.reason);
1199
+ break;
1200
+ case 'pull_complete':
1201
+ resolveOrReject(this.streamControllers[data.streamId].pullCall, data.success, data.reason);
1202
+ break;
1203
+ case 'pull':
1204
+ if (!this.streamSinks[data.streamId]) {
1205
+ sendStreamResponse({
1206
+ stream: 'pull_complete',
1207
+ success: true
1208
+ });
1209
+ break;
1210
+ }
1211
+ if (this.streamSinks[data.streamId].desiredSize <= 0 && data.desiredSize > 0) {
1212
+ this.streamSinks[data.streamId].sinkCapability.resolve();
1213
+ }
1214
+ this.streamSinks[data.streamId].desiredSize = data.desiredSize;
1215
+ resolveCall(this.streamSinks[data.streamId].onPull).then(function () {
1216
+ sendStreamResponse({
1217
+ stream: 'pull_complete',
1218
+ success: true
1219
+ });
1220
+ }, function (reason) {
1221
+ sendStreamResponse({
1222
+ stream: 'pull_complete',
1223
+ success: false,
1224
+ reason: reason
1225
+ });
1226
+ });
1227
+ break;
1228
+ case 'enqueue':
1229
+ this.streamControllers[data.streamId].controller.enqueue(data.chunk);
1230
+ break;
1231
+ case 'close':
1232
+ this.streamControllers[data.streamId].controller.close();
1233
+ deleteStreamController();
1234
+ break;
1235
+ case 'error':
1236
+ this.streamControllers[data.streamId].controller.error(data.reason);
1237
+ deleteStreamController();
1238
+ break;
1239
+ case 'cancel_complete':
1240
+ resolveOrReject(this.streamControllers[data.streamId].cancelCall, data.success, data.reason);
1241
+ deleteStreamController();
1242
+ break;
1243
+ case 'cancel':
1244
+ resolveCall(this.streamSinks[data.streamId].onCancel, [data.reason]).then(function () {
1245
+ sendStreamResponse({
1246
+ stream: 'cancel_complete',
1247
+ success: true
1248
+ });
1249
+ }, function (reason) {
1250
+ sendStreamResponse({
1251
+ stream: 'cancel_complete',
1252
+ success: false,
1253
+ reason: reason
1254
+ });
1255
+ });
1256
+ delete this.streamSinks[data.streamId];
1257
+ break;
1258
+ default:
1259
+ throw new Error('Unexpected stream case');
1260
+ }
1261
+ },
1019
1262
  postMessage: function postMessage(message, transfers) {
1020
1263
  if (transfers && this.postMessageTransfers) {
1021
1264
  this.comObj.postMessage(message, transfers);
@@ -15,7 +15,7 @@
15
15
  'use strict';
16
16
 
17
17
  function initializePDFJS(callback) {
18
- Promise.all(['pdfjs/display/global', 'pdfjs-test/unit/annotation_spec', 'pdfjs-test/unit/api_spec', 'pdfjs-test/unit/bidi_spec', 'pdfjs-test/unit/cff_parser_spec', 'pdfjs-test/unit/cmap_spec', 'pdfjs-test/unit/crypto_spec', 'pdfjs-test/unit/document_spec', 'pdfjs-test/unit/dom_utils_spec', 'pdfjs-test/unit/evaluator_spec', 'pdfjs-test/unit/fonts_spec', 'pdfjs-test/unit/function_spec', 'pdfjs-test/unit/metadata_spec', 'pdfjs-test/unit/murmurhash3_spec', 'pdfjs-test/unit/network_spec', 'pdfjs-test/unit/parser_spec', 'pdfjs-test/unit/primitives_spec', 'pdfjs-test/unit/stream_spec', 'pdfjs-test/unit/type1_parser_spec', 'pdfjs-test/unit/ui_utils_spec', 'pdfjs-test/unit/unicode_spec', 'pdfjs-test/unit/util_spec', 'pdfjs-test/unit/custom_spec'].map(function (moduleName) {
18
+ Promise.all(['pdfjs/display/global', 'pdfjs-test/unit/annotation_spec', 'pdfjs-test/unit/api_spec', 'pdfjs-test/unit/bidi_spec', 'pdfjs-test/unit/cff_parser_spec', 'pdfjs-test/unit/cmap_spec', 'pdfjs-test/unit/crypto_spec', 'pdfjs-test/unit/custom_spec', 'pdfjs-test/unit/document_spec', 'pdfjs-test/unit/dom_utils_spec', 'pdfjs-test/unit/evaluator_spec', 'pdfjs-test/unit/fonts_spec', 'pdfjs-test/unit/function_spec', 'pdfjs-test/unit/metadata_spec', 'pdfjs-test/unit/murmurhash3_spec', 'pdfjs-test/unit/network_spec', 'pdfjs-test/unit/parser_spec', 'pdfjs-test/unit/primitives_spec', 'pdfjs-test/unit/stream_spec', 'pdfjs-test/unit/type1_parser_spec', 'pdfjs-test/unit/ui_utils_spec', 'pdfjs-test/unit/unicode_spec', 'pdfjs-test/unit/util_spec', 'pdfjs-test/unit/util_stream_spec'].map(function (moduleName) {
19
19
  return SystemJS.import(moduleName);
20
20
  })).then(function (modules) {
21
21
  var displayGlobal = modules[0];