pdfjs-dist 2.0.943 → 2.1.266

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.

Files changed (159) hide show
  1. package/bower.json +1 -1
  2. package/build/pdf.js +15329 -11095
  3. package/build/pdf.js.map +1 -1
  4. package/build/pdf.min.js +1 -1
  5. package/build/pdf.worker.js +12497 -4184
  6. package/build/pdf.worker.js.map +1 -1
  7. package/build/pdf.worker.min.js +1 -1
  8. package/image_decoders/pdf.image_decoders.js +3438 -1209
  9. package/image_decoders/pdf.image_decoders.js.map +1 -1
  10. package/image_decoders/pdf.image_decoders.min.js +1 -1
  11. package/lib/core/annotation.js +335 -109
  12. package/lib/core/arithmetic_decoder.js +274 -244
  13. package/lib/core/bidi.js +64 -5
  14. package/lib/core/ccitt.js +172 -17
  15. package/lib/core/ccitt_stream.js +14 -5
  16. package/lib/core/cff_parser.js +304 -28
  17. package/lib/core/charsets.js +4 -3
  18. package/lib/core/chunked_stream.js +379 -149
  19. package/lib/core/cmap.js +210 -40
  20. package/lib/core/colorspace.js +332 -187
  21. package/lib/core/crypto.js +289 -44
  22. package/lib/core/document.js +508 -249
  23. package/lib/core/encodings.js +18 -9
  24. package/lib/core/evaluator.js +657 -119
  25. package/lib/core/font_renderer.js +217 -34
  26. package/lib/core/fonts.js +632 -41
  27. package/lib/core/function.js +252 -26
  28. package/lib/core/glyphlist.js +2 -1
  29. package/lib/core/image.js +124 -27
  30. package/lib/core/jbig2.js +425 -65
  31. package/lib/core/jbig2_stream.js +18 -7
  32. package/lib/core/jpeg_stream.js +24 -8
  33. package/lib/core/jpg.js +208 -16
  34. package/lib/core/jpx.js +395 -5
  35. package/lib/core/jpx_stream.js +17 -5
  36. package/lib/core/metrics.js +3 -3
  37. package/lib/core/murmurhash3.js +23 -5
  38. package/lib/core/obj.js +625 -132
  39. package/lib/core/operator_list.js +104 -3
  40. package/lib/core/parser.js +262 -25
  41. package/lib/core/pattern.js +144 -12
  42. package/lib/core/pdf_manager.js +104 -70
  43. package/lib/core/primitives.js +74 -21
  44. package/lib/core/ps_parser.js +133 -44
  45. package/lib/core/standard_fonts.js +9 -9
  46. package/lib/core/stream.js +283 -31
  47. package/lib/core/type1_parser.js +138 -6
  48. package/lib/core/unicode.js +28 -1
  49. package/lib/core/worker.js +192 -57
  50. package/lib/display/annotation_layer.js +303 -123
  51. package/lib/display/api.js +1073 -574
  52. package/lib/display/api_compatibility.js +4 -1
  53. package/lib/display/canvas.js +314 -18
  54. package/lib/display/content_disposition.js +70 -23
  55. package/lib/display/dom_utils.js +112 -59
  56. package/lib/display/fetch_stream.js +95 -50
  57. package/lib/display/font_loader.js +250 -132
  58. package/lib/display/metadata.js +37 -15
  59. package/lib/display/network.js +123 -34
  60. package/lib/display/network_utils.js +23 -10
  61. package/lib/display/node_stream.js +162 -65
  62. package/lib/display/pattern_helper.js +57 -6
  63. package/lib/display/svg.js +194 -18
  64. package/lib/display/text_layer.js +128 -14
  65. package/lib/display/transport_stream.js +83 -27
  66. package/lib/display/webgl.js +63 -17
  67. package/lib/display/worker_options.js +4 -3
  68. package/lib/display/xml_parser.js +162 -52
  69. package/lib/examples/node/domstubs.js +56 -3
  70. package/lib/pdf.js +15 -2
  71. package/lib/pdf.worker.js +4 -2
  72. package/lib/shared/compatibility.js +129 -26
  73. package/lib/shared/global_scope.js +1 -1
  74. package/lib/shared/is_node.js +3 -3
  75. package/lib/shared/message_handler.js +103 -45
  76. package/lib/shared/streams_polyfill.js +20 -16
  77. package/lib/shared/url_polyfill.js +8 -2
  78. package/lib/shared/util.js +246 -84
  79. package/lib/test/unit/annotation_spec.js +99 -73
  80. package/lib/test/unit/api_spec.js +347 -113
  81. package/lib/test/unit/bidi_spec.js +6 -6
  82. package/lib/test/unit/cff_parser_spec.js +17 -5
  83. package/lib/test/unit/clitests_helper.js +7 -8
  84. package/lib/test/unit/cmap_spec.js +79 -25
  85. package/lib/test/unit/colorspace_spec.js +65 -18
  86. package/lib/test/unit/crypto_spec.js +16 -4
  87. package/lib/test/unit/custom_spec.js +40 -52
  88. package/lib/test/unit/display_svg_spec.js +32 -16
  89. package/lib/test/unit/document_spec.js +2 -2
  90. package/lib/test/unit/dom_utils_spec.js +8 -8
  91. package/lib/test/unit/encodings_spec.js +24 -44
  92. package/lib/test/unit/evaluator_spec.js +15 -8
  93. package/lib/test/unit/function_spec.js +16 -4
  94. package/lib/test/unit/jasmine-boot.js +29 -16
  95. package/lib/test/unit/message_handler_spec.js +19 -6
  96. package/lib/test/unit/metadata_spec.js +64 -11
  97. package/lib/test/unit/murmurhash3_spec.js +2 -2
  98. package/lib/test/unit/network_spec.js +19 -4
  99. package/lib/test/unit/network_utils_spec.js +6 -4
  100. package/lib/test/unit/node_stream_spec.js +50 -26
  101. package/lib/test/unit/parser_spec.js +13 -29
  102. package/lib/test/unit/pdf_find_controller_spec.js +144 -32
  103. package/lib/test/unit/pdf_find_utils_spec.js +10 -9
  104. package/lib/test/unit/pdf_history_spec.js +20 -8
  105. package/lib/test/unit/primitives_spec.js +23 -3
  106. package/lib/test/unit/stream_spec.js +8 -3
  107. package/lib/test/unit/test_utils.js +89 -26
  108. package/lib/test/unit/testreporter.js +19 -1
  109. package/lib/test/unit/type1_parser_spec.js +7 -5
  110. package/lib/test/unit/ui_utils_spec.js +162 -38
  111. package/lib/test/unit/unicode_spec.js +13 -10
  112. package/lib/test/unit/util_spec.js +89 -9
  113. package/lib/web/annotation_layer_builder.js +38 -21
  114. package/lib/web/app.js +610 -245
  115. package/lib/web/app_options.js +54 -34
  116. package/lib/web/base_viewer.js +359 -162
  117. package/lib/web/chromecom.js +159 -80
  118. package/lib/web/debugger.js +161 -17
  119. package/lib/web/download_manager.js +29 -11
  120. package/lib/web/firefox_print_service.js +16 -8
  121. package/lib/web/firefoxcom.js +127 -91
  122. package/lib/web/genericcom.js +50 -31
  123. package/lib/web/genericl10n.js +46 -34
  124. package/lib/web/grab_to_pan.js +25 -3
  125. package/lib/web/interfaces.js +108 -61
  126. package/lib/web/overlay_manager.js +67 -45
  127. package/lib/web/password_prompt.js +20 -12
  128. package/lib/web/pdf_attachment_viewer.js +37 -17
  129. package/lib/web/pdf_cursor_tools.js +38 -15
  130. package/lib/web/pdf_document_properties.js +65 -24
  131. package/lib/web/pdf_find_bar.js +48 -20
  132. package/lib/web/pdf_find_controller.js +290 -89
  133. package/lib/web/pdf_find_utils.js +19 -3
  134. package/lib/web/pdf_history.js +186 -49
  135. package/lib/web/pdf_link_service.js +127 -52
  136. package/lib/web/pdf_outline_viewer.js +71 -21
  137. package/lib/web/pdf_page_view.js +188 -63
  138. package/lib/web/pdf_presentation_mode.js +98 -33
  139. package/lib/web/pdf_print_service.js +54 -10
  140. package/lib/web/pdf_rendering_queue.js +26 -4
  141. package/lib/web/pdf_sidebar.js +116 -62
  142. package/lib/web/pdf_sidebar_resizer.js +41 -15
  143. package/lib/web/pdf_single_page_viewer.js +65 -68
  144. package/lib/web/pdf_thumbnail_view.js +102 -31
  145. package/lib/web/pdf_thumbnail_viewer.js +62 -22
  146. package/lib/web/pdf_viewer.component.js +111 -31
  147. package/lib/web/pdf_viewer.js +80 -60
  148. package/lib/web/preferences.js +61 -39
  149. package/lib/web/secondary_toolbar.js +101 -82
  150. package/lib/web/text_layer_builder.js +124 -69
  151. package/lib/web/toolbar.js +67 -27
  152. package/lib/web/ui_utils.js +284 -128
  153. package/lib/web/view_history.js +75 -51
  154. package/lib/web/viewer_compatibility.js +2 -1
  155. package/package.json +1 -1
  156. package/web/pdf_viewer.css +1 -1
  157. package/web/pdf_viewer.js +2200 -973
  158. package/web/pdf_viewer.js.map +1 -1
  159. package/lib/web/dom_events.js +0 -140
@@ -19,76 +19,89 @@
19
19
  * @licend The above is the entire license notice for the
20
20
  * Javascript code in this page
21
21
  */
22
- 'use strict';
22
+ "use strict";
23
23
 
24
24
  Object.defineProperty(exports, "__esModule", {
25
25
  value: true
26
26
  });
27
- exports.MessageHandler = undefined;
27
+ exports.MessageHandler = MessageHandler;
28
28
 
29
- var _regenerator = require('babel-runtime/regenerator');
29
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
30
30
 
31
- var _regenerator2 = _interopRequireDefault(_regenerator);
31
+ var _util = require("./util");
32
32
 
33
- var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
33
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
34
+
35
+ function _typeof(obj) { 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); }
36
+
37
+ 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); } }
38
+
39
+ 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); }); }; }
40
+
41
+ function resolveCall(_x, _x2) {
42
+ return _resolveCall.apply(this, arguments);
43
+ }
34
44
 
35
- var resolveCall = function () {
36
- var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee(fn, args) {
37
- var thisArg = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
38
- return _regenerator2.default.wrap(function _callee$(_context) {
45
+ function _resolveCall() {
46
+ _resolveCall = _asyncToGenerator(
47
+ /*#__PURE__*/
48
+ _regenerator.default.mark(function _callee(fn, args) {
49
+ var thisArg,
50
+ _args = arguments;
51
+ return _regenerator.default.wrap(function _callee$(_context) {
39
52
  while (1) {
40
53
  switch (_context.prev = _context.next) {
41
54
  case 0:
55
+ thisArg = _args.length > 2 && _args[2] !== undefined ? _args[2] : null;
56
+
42
57
  if (fn) {
43
- _context.next = 2;
58
+ _context.next = 3;
44
59
  break;
45
60
  }
46
61
 
47
- return _context.abrupt('return');
48
-
49
- case 2:
50
- return _context.abrupt('return', fn.apply(thisArg, args));
62
+ return _context.abrupt("return");
51
63
 
52
64
  case 3:
53
- case 'end':
65
+ return _context.abrupt("return", fn.apply(thisArg, args));
66
+
67
+ case 4:
68
+ case "end":
54
69
  return _context.stop();
55
70
  }
56
71
  }
57
72
  }, _callee, this);
58
73
  }));
59
-
60
- return function resolveCall(_x2, _x3) {
61
- return _ref.apply(this, arguments);
62
- };
63
- }();
64
-
65
- var _util = require('./util');
66
-
67
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
68
-
69
- function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
74
+ return _resolveCall.apply(this, arguments);
75
+ }
70
76
 
71
77
  function wrapReason(reason) {
72
- if ((typeof reason === 'undefined' ? 'undefined' : _typeof(reason)) !== 'object') {
78
+ if (_typeof(reason) !== 'object') {
73
79
  return reason;
74
80
  }
81
+
75
82
  switch (reason.name) {
76
83
  case 'AbortException':
77
84
  return new _util.AbortException(reason.message);
85
+
78
86
  case 'MissingPDFException':
79
87
  return new _util.MissingPDFException(reason.message);
88
+
80
89
  case 'UnexpectedResponseException':
81
90
  return new _util.UnexpectedResponseException(reason.message, reason.status);
91
+
82
92
  default:
83
93
  return new _util.UnknownErrorException(reason.message, reason.details);
84
94
  }
85
95
  }
96
+
86
97
  function makeReasonSerializable(reason) {
87
98
  if (!(reason instanceof Error) || reason instanceof _util.AbortException || reason instanceof _util.MissingPDFException || reason instanceof _util.UnexpectedResponseException || reason instanceof _util.UnknownErrorException) {
88
99
  return reason;
89
100
  }
101
+
90
102
  return new _util.UnknownErrorException(reason.message, reason.toString());
91
103
  }
104
+
92
105
  function resolveOrReject(capability, success, reason) {
93
106
  if (success) {
94
107
  capability.resolve();
@@ -96,9 +109,11 @@ function resolveOrReject(capability, success, reason) {
96
109
  capability.reject(reason);
97
110
  }
98
111
  }
112
+
99
113
  function finalize(promise) {
100
114
  return Promise.resolve(promise).catch(function () {});
101
115
  }
116
+
102
117
  function MessageHandler(sourceName, targetName, comObj) {
103
118
  var _this = this;
104
119
 
@@ -112,28 +127,34 @@ function MessageHandler(sourceName, targetName, comObj) {
112
127
  this.streamControllers = Object.create(null);
113
128
  var callbacksCapabilities = this.callbacksCapabilities = Object.create(null);
114
129
  var ah = this.actionHandler = Object.create(null);
130
+
115
131
  this._onComObjOnMessage = function (event) {
116
132
  var data = event.data;
133
+
117
134
  if (data.targetName !== _this.sourceName) {
118
135
  return;
119
136
  }
137
+
120
138
  if (data.stream) {
121
139
  _this._processStreamMessage(data);
122
140
  } else if (data.isReply) {
123
141
  var callbackId = data.callbackId;
142
+
124
143
  if (data.callbackId in callbacksCapabilities) {
125
144
  var callback = callbacksCapabilities[callbackId];
126
145
  delete callbacksCapabilities[callbackId];
146
+
127
147
  if ('error' in data) {
128
148
  callback.reject(wrapReason(data.error));
129
149
  } else {
130
150
  callback.resolve(data.data);
131
151
  }
132
152
  } else {
133
- throw new Error('Cannot resolve callback ' + callbackId);
153
+ throw new Error("Cannot resolve callback ".concat(callbackId));
134
154
  }
135
155
  } else if (data.action in ah) {
136
156
  var action = ah[data.action];
157
+
137
158
  if (data.callbackId) {
138
159
  var _sourceName = _this.sourceName;
139
160
  var _targetName = data.sourceName;
@@ -162,17 +183,21 @@ function MessageHandler(sourceName, targetName, comObj) {
162
183
  action[0].call(action[1], data.data);
163
184
  }
164
185
  } else {
165
- throw new Error('Unknown action from worker: ' + data.action);
186
+ throw new Error("Unknown action from worker: ".concat(data.action));
166
187
  }
167
188
  };
189
+
168
190
  comObj.addEventListener('message', this._onComObjOnMessage);
169
191
  }
192
+
170
193
  MessageHandler.prototype = {
171
194
  on: function on(actionName, handler, scope) {
172
195
  var ah = this.actionHandler;
196
+
173
197
  if (ah[actionName]) {
174
- throw new Error('There is already an actionName called "' + actionName + '"');
198
+ throw new Error("There is already an actionName called \"".concat(actionName, "\""));
175
199
  }
200
+
176
201
  ah[actionName] = [handler, scope];
177
202
  },
178
203
  send: function send(actionName, data, transfers) {
@@ -195,11 +220,13 @@ MessageHandler.prototype = {
195
220
  };
196
221
  var capability = (0, _util.createPromiseCapability)();
197
222
  this.callbacksCapabilities[callbackId] = capability;
223
+
198
224
  try {
199
225
  this.postMessage(message, transfers);
200
226
  } catch (e) {
201
227
  capability.reject(e);
202
228
  }
229
+
203
230
  return capability.promise;
204
231
  },
205
232
  sendWithStream: function sendWithStream(actionName, data, queueingStrategy, transfers) {
@@ -216,6 +243,7 @@ MessageHandler.prototype = {
216
243
  startCall: startCapability,
217
244
  isClosed: false
218
245
  };
246
+
219
247
  _this2.postMessage({
220
248
  sourceName: sourceName,
221
249
  targetName: targetName,
@@ -224,11 +252,13 @@ MessageHandler.prototype = {
224
252
  data: data,
225
253
  desiredSize: controller.desiredSize
226
254
  });
255
+
227
256
  return startCapability.promise;
228
257
  },
229
258
  pull: function pull(controller) {
230
259
  var pullCapability = (0, _util.createPromiseCapability)();
231
260
  _this2.streamControllers[streamId].pullCall = pullCapability;
261
+
232
262
  _this2.postMessage({
233
263
  sourceName: sourceName,
234
264
  targetName: targetName,
@@ -236,12 +266,14 @@ MessageHandler.prototype = {
236
266
  streamId: streamId,
237
267
  desiredSize: controller.desiredSize
238
268
  });
269
+
239
270
  return pullCapability.promise;
240
271
  },
241
272
  cancel: function cancel(reason) {
242
273
  var cancelCapability = (0, _util.createPromiseCapability)();
243
274
  _this2.streamControllers[streamId].cancelCall = cancelCapability;
244
275
  _this2.streamControllers[streamId].isClosed = true;
276
+
245
277
  _this2.postMessage({
246
278
  sourceName: sourceName,
247
279
  targetName: targetName,
@@ -249,6 +281,7 @@ MessageHandler.prototype = {
249
281
  reason: reason,
250
282
  streamId: streamId
251
283
  });
284
+
252
285
  return cancelCapability.promise;
253
286
  }
254
287
  }, queueingStrategy);
@@ -263,12 +296,13 @@ MessageHandler.prototype = {
263
296
  var sourceName = this.sourceName;
264
297
  var targetName = data.sourceName;
265
298
  var capability = (0, _util.createPromiseCapability)();
266
- var sendStreamRequest = function sendStreamRequest(_ref2) {
267
- var stream = _ref2.stream,
268
- chunk = _ref2.chunk,
269
- transfers = _ref2.transfers,
270
- success = _ref2.success,
271
- reason = _ref2.reason;
299
+
300
+ var sendStreamRequest = function sendStreamRequest(_ref) {
301
+ var stream = _ref.stream,
302
+ chunk = _ref.chunk,
303
+ transfers = _ref.transfers,
304
+ success = _ref.success,
305
+ reason = _ref.reason;
272
306
 
273
307
  _this3.postMessage({
274
308
  sourceName: sourceName,
@@ -280,20 +314,24 @@ MessageHandler.prototype = {
280
314
  reason: reason
281
315
  }, transfers);
282
316
  };
317
+
283
318
  var streamSink = {
284
319
  enqueue: function enqueue(chunk) {
285
320
  var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
286
- var transfers = arguments[2];
321
+ var transfers = arguments.length > 2 ? arguments[2] : undefined;
287
322
 
288
323
  if (this.isCancelled) {
289
324
  return;
290
325
  }
326
+
291
327
  var lastDesiredSize = this.desiredSize;
292
328
  this.desiredSize -= size;
329
+
293
330
  if (lastDesiredSize > 0 && this.desiredSize <= 0) {
294
331
  this.sinkCapability = (0, _util.createPromiseCapability)();
295
332
  this.ready = this.sinkCapability.promise;
296
333
  }
334
+
297
335
  sendStreamRequest({
298
336
  stream: 'enqueue',
299
337
  chunk: chunk,
@@ -304,21 +342,24 @@ MessageHandler.prototype = {
304
342
  if (this.isCancelled) {
305
343
  return;
306
344
  }
345
+
307
346
  this.isCancelled = true;
308
- sendStreamRequest({ stream: 'close' });
347
+ sendStreamRequest({
348
+ stream: 'close'
349
+ });
309
350
  delete self.streamSinks[streamId];
310
351
  },
311
352
  error: function error(reason) {
312
353
  if (this.isCancelled) {
313
354
  return;
314
355
  }
356
+
315
357
  this.isCancelled = true;
316
358
  sendStreamRequest({
317
359
  stream: 'error',
318
360
  reason: reason
319
361
  });
320
362
  },
321
-
322
363
  sinkCapability: capability,
323
364
  onPull: null,
324
365
  onCancel: null,
@@ -348,10 +389,11 @@ MessageHandler.prototype = {
348
389
  var sourceName = this.sourceName;
349
390
  var targetName = data.sourceName;
350
391
  var streamId = data.streamId;
351
- var sendStreamResponse = function sendStreamResponse(_ref3) {
352
- var stream = _ref3.stream,
353
- success = _ref3.success,
354
- reason = _ref3.reason;
392
+
393
+ var sendStreamResponse = function sendStreamResponse(_ref2) {
394
+ var stream = _ref2.stream,
395
+ success = _ref2.success,
396
+ reason = _ref2.reason;
355
397
 
356
398
  _this4.comObj.postMessage({
357
399
  sourceName: sourceName,
@@ -362,6 +404,7 @@ MessageHandler.prototype = {
362
404
  reason: reason
363
405
  });
364
406
  };
407
+
365
408
  var deleteStreamController = function deleteStreamController() {
366
409
  Promise.all([_this4.streamControllers[data.streamId].startCall, _this4.streamControllers[data.streamId].pullCall, _this4.streamControllers[data.streamId].cancelCall].map(function (capability) {
367
410
  return capability && finalize(capability.promise);
@@ -369,13 +412,16 @@ MessageHandler.prototype = {
369
412
  delete _this4.streamControllers[data.streamId];
370
413
  });
371
414
  };
415
+
372
416
  switch (data.stream) {
373
417
  case 'start_complete':
374
418
  resolveOrReject(this.streamControllers[data.streamId].startCall, data.success, wrapReason(data.reason));
375
419
  break;
420
+
376
421
  case 'pull_complete':
377
422
  resolveOrReject(this.streamControllers[data.streamId].pullCall, data.success, wrapReason(data.reason));
378
423
  break;
424
+
379
425
  case 'pull':
380
426
  if (!this.streamSinks[data.streamId]) {
381
427
  sendStreamResponse({
@@ -384,9 +430,11 @@ MessageHandler.prototype = {
384
430
  });
385
431
  break;
386
432
  }
433
+
387
434
  if (this.streamSinks[data.streamId].desiredSize <= 0 && data.desiredSize > 0) {
388
435
  this.streamSinks[data.streamId].sinkCapability.resolve();
389
436
  }
437
+
390
438
  this.streamSinks[data.streamId].desiredSize = data.desiredSize;
391
439
  resolveCall(this.streamSinks[data.streamId].onPull).then(function () {
392
440
  sendStreamResponse({
@@ -401,34 +449,44 @@ MessageHandler.prototype = {
401
449
  });
402
450
  });
403
451
  break;
452
+
404
453
  case 'enqueue':
405
454
  (0, _util.assert)(this.streamControllers[data.streamId], 'enqueue should have stream controller');
455
+
406
456
  if (!this.streamControllers[data.streamId].isClosed) {
407
457
  this.streamControllers[data.streamId].controller.enqueue(data.chunk);
408
458
  }
459
+
409
460
  break;
461
+
410
462
  case 'close':
411
463
  (0, _util.assert)(this.streamControllers[data.streamId], 'close should have stream controller');
464
+
412
465
  if (this.streamControllers[data.streamId].isClosed) {
413
466
  break;
414
467
  }
468
+
415
469
  this.streamControllers[data.streamId].isClosed = true;
416
470
  this.streamControllers[data.streamId].controller.close();
417
471
  deleteStreamController();
418
472
  break;
473
+
419
474
  case 'error':
420
475
  (0, _util.assert)(this.streamControllers[data.streamId], 'error should have stream controller');
421
476
  this.streamControllers[data.streamId].controller.error(wrapReason(data.reason));
422
477
  deleteStreamController();
423
478
  break;
479
+
424
480
  case 'cancel_complete':
425
481
  resolveOrReject(this.streamControllers[data.streamId].cancelCall, data.success, wrapReason(data.reason));
426
482
  deleteStreamController();
427
483
  break;
484
+
428
485
  case 'cancel':
429
486
  if (!this.streamSinks[data.streamId]) {
430
487
  break;
431
488
  }
489
+
432
490
  resolveCall(this.streamSinks[data.streamId].onCancel, [wrapReason(data.reason)]).then(function () {
433
491
  sendStreamResponse({
434
492
  stream: 'cancel_complete',
@@ -445,6 +503,7 @@ MessageHandler.prototype = {
445
503
  this.streamSinks[data.streamId].isCancelled = true;
446
504
  delete this.streamSinks[data.streamId];
447
505
  break;
506
+
448
507
  default:
449
508
  throw new Error('Unexpected stream case');
450
509
  }
@@ -459,5 +518,4 @@ MessageHandler.prototype = {
459
518
  destroy: function destroy() {
460
519
  this.comObj.removeEventListener('message', this._onComObjOnMessage);
461
520
  }
462
- };
463
- exports.MessageHandler = MessageHandler;
521
+ };
@@ -19,21 +19,25 @@
19
19
  * @licend The above is the entire license notice for the
20
20
  * Javascript code in this page
21
21
  */
22
- 'use strict';
22
+ "use strict";
23
23
 
24
- var isReadableStreamSupported = false;
25
- if (typeof ReadableStream !== 'undefined') {
26
- try {
27
- new ReadableStream({
28
- start: function start(controller) {
29
- controller.close();
30
- }
31
- });
32
- isReadableStreamSupported = true;
33
- } catch (e) {}
34
- }
35
- if (isReadableStreamSupported) {
36
- exports.ReadableStream = ReadableStream;
37
- } else {
38
- exports.ReadableStream = require('../../external/streams/streams-lib').ReadableStream;
24
+ {
25
+ var isReadableStreamSupported = false;
26
+
27
+ if (typeof ReadableStream !== 'undefined') {
28
+ try {
29
+ new ReadableStream({
30
+ start: function start(controller) {
31
+ controller.close();
32
+ }
33
+ });
34
+ isReadableStreamSupported = true;
35
+ } catch (e) {}
36
+ }
37
+
38
+ if (isReadableStreamSupported) {
39
+ exports.ReadableStream = ReadableStream;
40
+ } else {
41
+ exports.ReadableStream = require('../../external/streams/streams-lib').ReadableStream;
42
+ }
39
43
  }
@@ -19,12 +19,13 @@
19
19
  * @licend The above is the entire license notice for the
20
20
  * Javascript code in this page
21
21
  */
22
- 'use strict';
22
+ "use strict";
23
23
 
24
- var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
24
+ function _typeof(obj) { 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); }
25
25
 
26
26
  {
27
27
  var isURLSupported = false;
28
+
28
29
  try {
29
30
  if (typeof URL === 'function' && _typeof(URL.prototype) === 'object' && 'origin' in URL.prototype) {
30
31
  var u = new URL('b', 'http://a');
@@ -32,19 +33,24 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
32
33
  isURLSupported = u.href === 'http://a/c%20d';
33
34
  }
34
35
  } catch (ex) {}
36
+
35
37
  if (isURLSupported) {
36
38
  exports.URL = URL;
37
39
  } else {
38
40
  var PolyfillURL = require('../../external/url/url-lib').URL;
41
+
39
42
  var OriginalURL = require('./global_scope').URL;
43
+
40
44
  if (OriginalURL) {
41
45
  PolyfillURL.createObjectURL = function (blob) {
42
46
  return OriginalURL.createObjectURL.apply(OriginalURL, arguments);
43
47
  };
48
+
44
49
  PolyfillURL.revokeObjectURL = function (url) {
45
50
  OriginalURL.revokeObjectURL(url);
46
51
  };
47
52
  }
53
+
48
54
  exports.URL = PolyfillURL;
49
55
  }
50
56
  }